odys.optimization.formulations.storage¶
The shared battery model of battery storage and electric vehicles (StorageFormulation), a reusable part both formulations compose. Variable and constraint names carry the entity dimension as a prefix.
The variables, constraints and objective terms are written out on the Batteries formulation page.
See also Battery for the domain model and entity_arrays for the parameter arrays.
Battery physics shared by every storage-like entity type (battery storage, electric vehicles).
StorageFormulation
¶
The battery model of one storage-like entity type, composed by that type's formulation.
It is a reusable part, not a Formulation: it holds no variables (the
composing formulation does, and passes them in), and each method returns
one constraint. Variable and constraint names are prefixed with the
dimension name ("battery_storage", "ev"). An optional SOC drop (EV trip
energy as a fraction of capacity) is subtracted at each step.
Source code in src/odys/optimization/formulations/storage.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
dimension
property
¶
Return the dimension the batteries are indexed along.
__init__(coordinates, battery, states, context, soc_drop=None)
¶
Initialize the battery model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coordinates
|
Coordinates
|
The labels of the batteries along their dimension, which also names them. |
required |
battery
|
BatteryArrays
|
The battery parameters, vectorized along that dimension. |
required |
states
|
BatteryStateArrays
|
The initial and final state of charge of the batteries, from the run's conditions. |
required |
context
|
ModelContext
|
The shared indexing of the problem. |
required |
soc_drop
|
DataArray | None
|
SOC lost at each step outside charging (EV trips), if any. |
None
|
Source code in src/odys/optimization/formulations/storage.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
capacity_constraint(variables)
¶
The SOC never exceeds a full battery (1).
Source code in src/odys/optimization/formulations/storage.py
162 163 164 165 166 167 | |
create_variables(model)
¶
Add the battery variables: powers and SOC are non-negative, net power is free, the mode is binary.
Source code in src/odys/optimization/formulations/storage.py
72 73 74 75 76 77 78 79 80 81 | |
degradation_cost(variables)
¶
Return the degradation cost per scenario: throughput times step length times cost per MWh.
Source code in src/odys/optimization/formulations/storage.py
182 183 184 185 186 | |
dispatch_data(solution)
¶
Return the net power, state of charge and charge mode of the batteries, read from the solution.
Source code in src/odys/optimization/formulations/storage.py
188 189 190 | |
max_charge_constraint(variables)
¶
Charging power is limited by max_charge_power, and only in charging mode.
Source code in src/odys/optimization/formulations/storage.py
83 84 85 86 87 88 | |
max_discharge_constraint(variables)
¶
Discharging power is limited by max_discharge_power, and only outside charging mode.
Source code in src/odys/optimization/formulations/storage.py
90 91 92 93 94 95 96 | |
name(what)
¶
Return the model name of a variable or constraint of this entity type, such as ev_soc.
Source code in src/odys/optimization/formulations/storage.py
68 69 70 | |
net_power_constraint(variables)
¶
Net power is charging minus discharging power.
Source code in src/odys/optimization/formulations/storage.py
169 170 171 172 173 174 | |
power_injection(variables)
¶
Return discharging minus charging power, summed over the batteries.
Source code in src/odys/optimization/formulations/storage.py
176 177 178 179 180 | |
soc_dynamics_constraint(variables)
¶
SOC follows self-discharge, charging and discharging (with efficiencies) from step to step.
Source code in src/odys/optimization/formulations/storage.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
soc_end_constraint(variables)
¶
The SOC at the last step equals soc_end, for the batteries that set one.
Source code in src/odys/optimization/formulations/storage.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
soc_max_constraint(variables)
¶
The SOC never exceeds soc_max.
Source code in src/odys/optimization/formulations/storage.py
155 156 157 158 159 160 | |
soc_min_constraint(variables)
¶
The SOC never falls below soc_min.
Source code in src/odys/optimization/formulations/storage.py
148 149 150 151 152 153 | |
soc_start_constraint(variables)
¶
The SOC after the first step starts from soc_start, less self-discharge and the SOC drop at t=0.
Source code in src/odys/optimization/formulations/storage.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
StorageVariables
¶
Bases: BaseModel
Decision variables of a battery: charge and discharge power, net power, state of charge and mode.
Source code in src/odys/optimization/formulations/storage.py
18 19 20 21 22 23 24 25 26 27 | |