Storage
Two components are available for modelling storage: Store and StorageUnit. See
the Store Component and Storage Unit Component descriptions for an overview of
the conceptual differences.
Stores
Stores have three time-dependent variables, the net dispatch in MW (positive when discharging), the charge in MW and the energy level in MWh. The discharge is derived. Only enters the nodal balance.
The energy level is constrained by maximum and minimum energy levels.
For non-extendable stores (e_nom_extendable=False):
| Constraint | Dual Variable | Name |
|---|---|---|
n.stores_t.mu_lower | Store-fix-e-lower | |
n.stores_t.mu_upper | Store-fix-e-upper | |
only in n.model | Store-fix-p-lower | |
only in n.model | Store-fix-p-upper | |
only in n.model | Store-fix-p_store-lower | |
only in n.model | Store-fix-p_store-upper |
where is the nominal energy capacity, and are time-dependent restrictions on the energy level given per unit of nominal capacity, is the number of hours at full power that fill the store (max_hours), and and restrict discharging and charging per unit of the power capacity (usually is negative, -1 by default). The power constraints are only built where is finite; by default () charging and discharging power are unconstrained. For stores with unit efficiencies, no direction-specific marginal costs and an infinite cycles_max, is fixed to zero and the charging bound applies to directly, which avoids a degenerate pair of variables; the outputs p_dispatch and p_store are then split by sign.
These constraints are set in the function define_operational_constraints_for_non_extendables().
For extendable stores (e_nom_extendable=True):
| Constraint | Dual Variable | Name |
|---|---|---|
n.stores_t.mu_lower | Store-ext-e-lower | |
n.stores_t.mu_upper | Store-ext-e-upper | |
only in n.model | Store-ext-p-lower | |
only in n.model | Store-ext-p-upper | |
only in n.model | Store-ext-p_store-lower | |
only in n.model | Store-ext-p_store-upper |
where is the energy capacity to be optimised.
These constraints are set in the function define_operational_constraints_for_extendables().
Capacity limits of Store components
For handling of capacity limits, see the Capacity Limits section.
The variables can also be fixed to certain values:
| Constraint | Dual Variable | Name |
|---|---|---|
only in n.model | Store-e_set | |
only in n.model | Store-p_set |
These constraints are set in the function define_fixed_operation_constraints().
The power and energy variables are related by the storage consistency equation (Store-energy_balance):
which is equivalent to in terms of charge and discharge.
where represents the storage efficiency after accounting for standing losses (e.g. thermal losses in thermal storage) per hour, and are the efficiencies for power going into and out of the store, and is the snapshot weighting (defaulting to 1 hour). The spillage variable is only created for stores with positive inflow. The dual variable represents the marginal storage value (also known as water value in the hydro-electricity literature).
These constraints are set in the function define_store_constraints().
The marginal costs enter the objective as , i.e. marginal_cost applies to the net dispatch while marginal_cost_dispatch and marginal_cost_store apply to one direction each. See the Store component description.
Furthermore, there are two options for specifying the initial energy level :
- Set
e_cyclic=False(default) and the value ofe_initialin MWh.
- Set
e_cyclic=Trueand the optimisation sets the initial energy to be equal to the final energy level.
Store cyclicity constraints with multiple investment periods
For how storage cyclicity constraints are handled with multiple investment periods, see the Pathway Planning section.
Cycle Limits
Stores may wear out with use. The attribute cycles_max limits the number of equivalent full cycles over all snapshots of the optimisation, including all investment periods. One cycle is a discharge equal to the energy capacity . The limit stays linear for extendable capacities. The formulation follows eq. (22) in Cardoso et al. (2018).[^1]
| Constraint | Dual Variable | Name |
|---|---|---|
only in n.model | Store-cycles_max |
Stores with a finite cycles_max always get the separate charging variable , so that the discharge is well defined. Where unit efficiencies and no direction-specific marginal costs make simultaneous charging and discharging free, the reported p_store and p_dispatch are netted and split by sign of .
In a rolling horizon optimisation, the cycles of previous windows count against cycles_max.
A cycle life over a technical lifetime translates into for an optimisation over years.
This constraint is set in the function define_store_cycle_constraints().
Mapping of symbols to component attributes
| Symbol | Attribute | Type |
|---|---|---|
n.stores_t.p | Decision Variable | |
n.stores_t.p_store | Decision Variable | |
n.stores_t.p_dispatch | Derived Output | |
n.stores_t.e | Decision Variable | |
n.stores_t.spill | Decision Variable | |
n.stores.e_nom_opt | Decision Variable | |
n.stores_t.mu_energy_balance | Dual Variable | |
n.stores.e_nom | Parameter | |
n.stores.max_hours | Parameter | |
n.stores_t.e_min_pu | Parameter | |
n.stores_t.e_max_pu | Parameter | |
n.stores_t.p_min_pu | Parameter | |
n.stores_t.p_max_pu | Parameter | |
n.stores_t.e_set | Parameter | |
n.stores_t.p_set | Parameter | |
n.stores_t.inflow | Parameter | |
n.stores.standing_loss | Parameter | |
n.stores.efficiency_store | Parameter | |
n.stores.efficiency_dispatch | Parameter | |
n.stores_t.marginal_cost | Parameter | |
n.stores_t.marginal_cost_dispatch | Parameter | |
n.stores_t.marginal_cost_store | Parameter | |
n.stores.cycles_max | Parameter | |
n.snapshot_weightings.stores | Parameter |
Storage Units
Storage units have three time-dependent variables, the discharge in MW, the charge in MW and the state of charge in MWh.
With a storage unit the nominal state of charge may not be independently optimised from the nominal power output (they are linked by the maximum hours parameter max_hours) and the nominal charging power is linked to the maximum discharging power.
For non-extendable storage units (p_nom_extendable=False), the charge (), discharge (), and state of charge () variables are constrained by:
| Constraint | Dual Variable | Name |
|---|---|---|
only in n.model | StorageUnit-p_dispatch-lower | |
only in n.model | StorageUnit-p_dispatch-upper | |
only in n.model | StorageUnit-p_store-lower | |
only in n.model | StorageUnit-p_store-upper | |
only in n.model | StorageUnit-state_of_charge-lower | |
only in n.model | StorageUnit-state_of_charge-upper |
where is the nominal power capacity, is a time-dependent restriction on the discharge per unit of nominal capacity, is a time-dependent restriction on the maximum charge per unit of nominal capacity (usually negative, -1 by default), and is the number of hours at nominal power that fill the state of charge.
These constraints are set in the function define_operational_constraints_for_non_extendables().
For extendable storage units (p_nom_extendable=True), the charge and discharge variables are constrained by:
| Constraint | Dual Variable | Name |
|---|---|---|
only in n.model | StorageUnit-ext-p_dispatch-lower | |
only in n.model | StorageUnit-ext-p_dispatch-upper | |
only in n.model | StorageUnit-ext-p_store-lower | |
only in n.model | StorageUnit-ext-p_store-upper |
where is the power capacity to be optimised.
These constraints are set in the function define_operational_constraints_for_extendables().
Capacity limits of StorageUnit components
For handling of capacity limits, see the Capacity Limits section.
All three variables can also be fixed to certain values , , and :
| Constraint | Dual Variable | Name |
|---|---|---|
only in n.model | StorageUnit-p_dispatch_set | |
only in n.model | StorageUnit-p_store_set | |
n.storage_units_t.mu_state_of_charge_set | StorageUnit-state_of_charge_set |
An example use case would be if a storage unit must be empty and/or full every day.
These constraints are set in the function define_fixed_operation_constraints().
The charging, discharging and state of charge variables are related by (StorageUnit-energy_balance):
is the standing efficiency (e.g. due to thermal losses for thermal storage). and are the efficiencies for power going into and out of the storage unit, and is the snapshot weighting for stores (e.g. 1 hour). The dual variable represents the marginal storage value (also known as water value in the hydro-electricity literature).
These constraints are set in the function define_storage_unit_constraints().
Furthermore, there are two options for specifying the initial state of charge :
- Set
cyclic_state_of_charge=False(default) and the value ofstate_of_charge_initialin MWh. - Set
cyclic_state_of_charge=Trueand the optimisation set the initial state of charge to the final state of charge.
StorageUnit cyclicity constraints with multiple investment periods
For how store cyclicity constraints are handled with multiple investment periods, see the Pathway Planning section.
Mapping of symbols to component attributes
| Symbol | Attribute | Type |
|---|---|---|
n.stores_t.p_dispatch | Decision Variable | |
n.stores_t.p_store | Decision Variable | |
n.storage_units_t.state_of_charge | Decision Variable | |
n.storage_units.p_nom_opt | Decision Variable | |
n.storage_units_t.inflow | Decision Variable | |
n.storage_units_t.spillage | Decision Variable | |
n.storage_units_t.mu_energy_balance | Dual Variable | |
n.storage_units.p_nom | Parameter | |
n.storage_units_t.p_min_pu | Parameter | |
n.storage_units_t.p_max_pu | Parameter | |
n.storage_units.max_hours | Parameter | |
n.storage_units_t.p_dispatch_set | Parameter | |
n.storage_units_t.p_store_set | Parameter | |
n.storage_units_t.state_of_charge_set | Parameter | |
n.storage_units.standing_loss | Parameter | |
n.storage_units.store_efficiency | Parameter | |
n.storage_units.dispatch_efficiency | Parameter | |
n.snapshot_weightings.stores | Parameter |
Examples
Storage Units as Links & Stores
Shows how storage units can be replaced by more fundamental links and stores.
[^1]: G. Cardoso, T. Brouhard, N. DeForest, D. Wang, M. Heleno, L. Kotzur (2018), Battery aging in multi-energy microgrid design using mixed integer linear programming, Applied Energy, 231, 1059-1069.
2026-11-02
2025-10-09