echo Ports
Ports terminate a network edge and represent the connection of an edge to a node. Ports are associated with an individual commodity and represent the flow of the that commodity into or out of a node.
Base Port Models
Note
Where variables are indexed by \((x, t)\), \(x\) refers to the planning interval, and \(t\) refers to the time interval. Sometimes these indices are left out of the constraint equations, and in this case, please refer to the variable definition to see whether it is an indexed variable or not.
Port
This is the base port class. The main port variable is \(p_{x, t}\), which represents the port flow value.
If \(p\) needs to be split into a positive and negative component, the following variables are introduced:
\(p^+_{x, t}\), the positive component of the port flow
\(p^-_{x, t}\), the negative component of the port flow
\(p_{x, t}^\text{*}\), a binary variable for indicating whether \(p^+\) is non-zero.
The following constraints are used to split the variable.
\(p = p^+ + p^-\)
\(p^+ \leq p^* \cdot M\)
\(p^- \geq (p^* - 1) \cdot M\)
Parameters
flows: A parameter for defining what flows are possible. Options areFlows.Both,Flows.Import,Flows.Export. This parameter controls the domain of \(p\).import_constraint_value(\(p^\text{import constraint}\)): A constraint on imports. Can be None, a non-negative float, or an array of non-negative floats .export_constraint_value(\(p^\text{export constraint}\)): A constraint on exports. Can be None, a non-positive float, or an array of non-positive floats.active_periods(\(p^\text{active}\)): An array of periods when the port is active (on). 1=on, 0=off.slack: A bool parameter for enabling a slack variable on the port. A slack variable is useful when there are import or export constraints that may not be feasible. They ensure that the solver returns a solution even if the constraints cannot be satisfied, and we can interrogate by how much the import/export constraint was violated.
Note
If slack=True, a large cost is automatically added to the objective, so that the optimiser will only use the slack if it has no alternative. The costs are added in such a way that the maximum violation is penalised more heavily than the total violations.
If import constraint is not None: \(p \leq p^\text{import constraint}\)
If export constraint is not None: \(p \geq p^\text{export constraint}\)
If slack is True and import constraint is not None, the following variables and constraints are used instead:
\(p^\text{import slack}\), the slack at each time interval
\(p^\text{max import slack}\), the max import slack over all time intervals
\(p + p^\text{import slack} \leq p^\text{import constraint}\)
\(p^\text{max import slack} \geq p^\text{import slack}\)
If slack is True, and if export constraint is not None, the following variables and constraints are used instead:
\(p^\text{export slack}\), the slack at each time interval
\(p^\text{max export slack}\), the max export slack over all time intervals
\(p + p^\text{export slack} \geq p^\text{export constraint}\)
\(p^\text{max export slack} \geq p^\text{export slack}\)
If active_periods is not None, the following constraints are added:
\(p \leq p^\text{active} \cdot M\)
\(p \geq - p^\text{active} \cdot M\)
Storage
A storage port is a child of the Port class. It has the following additional parameters, variables, and constraints:
max_capacity(\(E^\text{max}\)): Maximum battery capacity in kWhdepth_of_discharge_limit(\(dod\)): Percentage to which the battery can discharge to, written as a decimal.charging_power_limit(\(lim^\text{charge}\)): Limit on charging power in kWdischarging_power_limit(\(lim^\text{discharge}\)): Limit on discharging power in kWcharging_efficiency(\(\eta^\text{charge}\)): Efficiency that applies when converting energy imported to a change in stored energy.discharging_efficiency(\(\eta^\text{discharge}\)): Efficiency that applies when converting energy exported to a change in stored energy.initial_state_of_charge: Initial state of charge of the battery in kWhfixed_storage_capacity: IfTruestorage capacity is optimised between 0 andmax capacity. Default isFalsestorage_capacity_cost: Cost on storage capacity in $ per kWh.regularise: Optional regularisation term on the battery. Default isFalse.
Note
storage_capacity_cost must be set to some value if fixed_storage_capacity is True. Default is None.
Variables
These are inherited from the Port class, and are repeated here for clarity:
\(p_{x, t}\), battery power
\(p^+_{x, t}\), power imported by the battery
\(p^-_{x, t}\), power exported by the battery
\(E_{x, t}\), energy stored in the battery
Constraints
Charging/discharging constraint:
\(lim^\text{discharge} \leq p \leq lim^\text{charge}\)
State of charge constraint:
\(E_{x, t} = E_{x, t-1} + p^+_{x, t} \cdot \eta^\text{charge} + p^-_{x, t} \cdot \eta^\text{discharge}\)
Depth of discharge constraint:
\(E^\text{max} \cdot dod \leq E \leq E^\text{max}\)
Mobile Storage
Could potentially create a new port model, for EV battery. It would be a child of the Storage class. It could have the EV-specific parameters:
trip_slacksoc_conservsoc_conserv_costavailable
If trip_slack is True, the modified battery state of charge equation accounting for the trip slack variable is:
\(E_{x, t} = E_{x,t-1} + \eta^\text{charge} p^\text{battery,+}_{x,t} d^\text{interval} + p^\text{battery, -}_{x,t} \frac{d^\text{interval}}{\eta^\text{discharge}} + S^\text{trip}_{x,t}\)
If SOC_conserv is not None, conservative state of charge lower limit:
\(\text{if} \quad t^\text{available}_{x,t} \quad \text{then} \quad E_{p,t} + S^\text{conserv}_{x,t} - L^\text{conserv} \geq 0\)
Bounded
A bounded port is a child of the Port class. It must have a value between a lower and upper bound, which may be specified as time varying values.
Parameters
upper_bound(\(p^\text{ub}_{x, t}\)): port upper boundlower_bound(\(p^\text{lb}_{x, t}\)): port lower bound
Constraints
\(p \geq p^\text{lb}\)
\(p \leq p^\text{ub}\)
Off or Constrained
An off or constrained port is a child of the Port class. It must have a value between a lower and upper bound, which may be specified as time varying values. If it is off, it has a value of zero.
Parameters
upper_bound(\(p^\text{ub}_{x, t}\)): port upper boundlower_bound(\(p^\text{lb}_{x, t}\)): port lower bound
Variables
on(\(p^\text{on}_{x, t}\)): on/off binary variable
\(p \geq p^\text{on} \cdot p^\text{lb}\)
\(p \leq p^\text{on} \cdot p^\text{ub}\)
Controlled Load or Generation
A controlled load or generation port is a child of the Port class. It can have a min and/or max utilisation. Min utilisation is the ratio between the minimum energy consumed, and the maxinimum energy that would be consumed if the load operated at max power. Max utilisation is the ratio between the maximum energy consumed, and the maximum energy that would be consumed if the load operated at max power.
Parameters
\(p^\text{max}\), the maximum port power
\(p^\text{min}\), the minimum port power
\(util^\text{min}\), the minimum utilisation
\(util^\text{max}\), the maximum utilisation
\(d^\text{interval}\), the time interval in minutes
\(d^\text{total}\), the total number of time intervals
Constraints
If there is a minimum utilisation specified:
\(\sum_{i=0}^x \sum_{j=0}^t p_{i, j} \cdot \frac{d^\text{interval}}{60} \geq util^\text{min} \cdot p^\text{max} \cdot \frac{d^\text{interval}}{60} \cdot d^\text{total}\)
If there is a maximum utilisation specified:
\(\sum_{i=0}^x \sum_{j=0}^t p_{i, j} \cdot \frac{d^\text{interval}}{60} \leq util^\text{max} \cdot p^\text{max} \cdot \frac{d^\text{interval}}{60} \cdot d^\text{total}\)