Post · 12 min read· pp. 336–344

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 hn,s,th_{n,s,t} in MW (positive when discharging), the charge hn,s,t+h_{n,s,t}^+ in MW and the energy level en,s,te_{n,s,t} in MWh. The discharge hn,s,t−=hn,s,t+hn,s,t+h_{n,s,t}^- = h_{n,s,t} + h_{n,s,t}^+ is derived. Only hn,s,th_{n,s,t} enters the nodal balance.

The energy level en,s,te_{n,s,t} is constrained by maximum and minimum energy levels.

For non-extendable stores (e_nom_extendable=False):

ConstraintDual VariableName
en,s,t≥e‾n,s,te^n,se_{n,s,t} \geq \underline{e}_{n,s,t} \hat{e}_{n,s}n.stores_t.mu_lowerStore-fix-e-lower
en,s,t≤eˉn,s,te^n,se_{n,s,t} \leq \bar{e}_{n,s,t} \hat{e}_{n,s}n.stores_t.mu_upperStore-fix-e-upper
hn,s,t−≥0h_{n,s,t}^- \geq 0only in n.modelStore-fix-p-lower
hn,s,t−≤hˉn,s,te^n,s/rn,sh_{n,s,t}^- \leq \bar{h}_{n,s,t} \hat{e}_{n,s} / r_{n,s}only in n.modelStore-fix-p-upper
hn,s,t+≥0h_{n,s,t}^+ \geq 0only in n.modelStore-fix-p_store-lower
hn,s,t+≤−h‾n,s,te^n,s/rn,sh_{n,s,t}^+ \leq - \underline{h}_{n,s,t} \hat{e}_{n,s} / r_{n,s}only in n.modelStore-fix-p_store-upper

where e^n,s\hat{e}_{n,s} is the nominal energy capacity, e‾n,s,t\underline{e}_{n,s,t} and eˉn,s,t\bar{e}_{n,s,t} are time-dependent restrictions on the energy level given per unit of nominal capacity, rn,sr_{n,s} is the number of hours at full power that fill the store (max_hours), and hˉn,s,t\bar{h}_{n,s,t} and h‾n,s,t\underline{h}_{n,s,t} restrict discharging and charging per unit of the power capacity e^n,s/rn,s\hat{e}_{n,s} / r_{n,s} (usually h‾n,s,t\underline{h}_{n,s,t} is negative, -1 by default). The power constraints are only built where rn,sr_{n,s} is finite; by default (rn,s=∞r_{n,s} = \infty) charging and discharging power are unconstrained. For stores with unit efficiencies, no direction-specific marginal costs and an infinite cycles_max, hn,s,t+h_{n,s,t}^+ is fixed to zero and the charging bound applies to hn,s,th_{n,s,t} 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):

ConstraintDual VariableName
en,s,t≥e‾n,s,tEn,se_{n,s,t} \geq \underline{e}_{n,s,t} E_{n,s}n.stores_t.mu_lowerStore-ext-e-lower
en,s,t≤eˉn,s,tEn,se_{n,s,t} \leq \bar{e}_{n,s,t} E_{n,s}n.stores_t.mu_upperStore-ext-e-upper
hn,s,t−≥0h_{n,s,t}^- \geq 0only in n.modelStore-ext-p-lower
hn,s,t−≤hˉn,s,tEn,s/rn,sh_{n,s,t}^- \leq \bar{h}_{n,s,t} E_{n,s} / r_{n,s}only in n.modelStore-ext-p-upper
hn,s,t+≥0h_{n,s,t}^+ \geq 0only in n.modelStore-ext-p_store-lower
hn,s,t+≤−h‾n,s,tEn,s/rn,sh_{n,s,t}^+ \leq - \underline{h}_{n,s,t} E_{n,s} / r_{n,s}only in n.modelStore-ext-p_store-upper

where En,sE_{n,s} 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:

ConstraintDual VariableName
en,s,t=e~n,s,te_{n,s,t} = \tilde{e}_{n,s,t}only in n.modelStore-e_set
hn,s,t=h~n,s,th_{n,s,t} = \tilde{h}_{n,s,t}only in n.modelStore-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):

en,s,t=ηstand,n,swtsen,s,t−1−ηdispatch;n,s−1wtshn,s,t+(ηstore;n,s−ηdispatch;n,s−1)wtshn,s,t++wtsinflown,s,t−wtsspillagen,s,t↔λn,s,tMSV\begin{gather*}e_{n,s,t} = \eta_{\textrm{stand},n,s}^{w_t^s} e_{n,s,t-1} - \eta^{-1}_{\textrm{dispatch};n,s} w_t^s h_{n,s,t} + \left(\eta_{\textrm{store};n,s} - \eta^{-1}_{\textrm{dispatch};n,s}\right) w_t^s h_{n,s,t}^+ \\ + w_t^s\textrm{inflow}_{n,s,t} - w_t^s\textrm{spillage}_{n,s,t} \quad \leftrightarrow \quad \lambda_{n,s,t}^\textrm{MSV} \end{gather*}

which is equivalent to ηstoreh+−ηdispatch−1h−\eta_{\textrm{store}} h^+ - \eta^{-1}_{\textrm{dispatch}} h^- in terms of charge and discharge.

where ηstand,n,s\eta_{\textrm{stand},n,s} represents the storage efficiency after accounting for standing losses (e.g. thermal losses in thermal storage) per hour, ηstore;n,s\eta_{\textrm{store};n,s} and ηdispatch;n,s\eta_{\textrm{dispatch};n,s} are the efficiencies for power going into and out of the store, and wtsw_t^s is the snapshot weighting (defaulting to 1 hour). The spillage variable 0≤spillagen,s,t≤inflown,s,t0 \leq \textrm{spillage}_{n,s,t} \leq \textrm{inflow}_{n,s,t} is only created for stores with positive inflow. The dual variable λn,s,tMSV\lambda_{n,s,t}^\textrm{MSV} 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 on,s,thn,s,t+on,s,t−hn,s,t−+on,s,t+hn,s,t+o_{n,s,t} h_{n,s,t} + o^-_{n,s,t} h_{n,s,t}^- + o^+_{n,s,t} h_{n,s,t}^+, 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 en,s,t=−1e_{n,s,t=-1}:

  1. Set e_cyclic=False (default) and the value of e_initial in MWh.

en,s,t=−1=en,s,initiale_{n,s,t=-1} = e_{n,s,\textrm{initial}}

  1. Set e_cyclic=True and the optimisation sets the initial energy to be equal to the final energy level.

en,s,t=−1=en,s,t=∣T∣−1e_{n,s,t=-1} = e_{n,s,t=|T|-1}

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 Nn,sN_{n,s} 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 En,sE_{n,s}. The limit stays linear for extendable capacities. The formulation follows eq. (22) in Cardoso et al. (2018).[^1]

ConstraintDual VariableName
∑twtshn,s,t−≤Nn,sEn,s∀n,s\sum_t w_t^s h_{n,s,t}^- \leq N_{n,s} E_{n,s} \quad \forall n,sonly in n.modelStore-cycles_max

Stores with a finite cycles_max always get the separate charging variable hn,s,t+h_{n,s,t}^+, so that the discharge hn,s,t−h_{n,s,t}^- 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 hn,s,th_{n,s,t}.

In a rolling horizon optimisation, the cycles of previous windows count against cycles_max.

A cycle life NlifeN^\textrm{life} over a technical lifetime LL translates into N=Nlife⋅Y/LN = N^\textrm{life} \cdot Y / L for an optimisation over YY years.

This constraint is set in the function define_store_cycle_constraints().

Mapping of symbols to component attributes

SymbolAttributeType
hn,s,th_{n,s,t}n.stores_t.pDecision Variable
hn,s,t+h_{n,s,t}^+n.stores_t.p_storeDecision Variable
hn,s,t−h_{n,s,t}^-n.stores_t.p_dispatchDerived Output
en,s,te_{n,s,t}n.stores_t.eDecision Variable
spillagen,s,t\textrm{spillage}_{n,s,t}n.stores_t.spillDecision Variable
En,sE_{n,s}n.stores.e_nom_optDecision Variable
λn,s,tMSV\lambda_{n,s,t}^\textrm{MSV}n.stores_t.mu_energy_balanceDual Variable
e^n,s\hat{e}_{n,s}n.stores.e_nomParameter
rn,sr_{n,s}n.stores.max_hoursParameter
e‾n,s,t\underline{e}_{n,s,t}n.stores_t.e_min_puParameter
eˉn,s,t\bar{e}_{n,s,t}n.stores_t.e_max_puParameter
h‾n,s,t\underline{h}_{n,s,t}n.stores_t.p_min_puParameter
hˉn,s,t\bar{h}_{n,s,t}n.stores_t.p_max_puParameter
e~n,s,t\tilde{e}_{n,s,t}n.stores_t.e_setParameter
h~n,s,t\tilde{h}_{n,s,t}n.stores_t.p_setParameter
inflown,s,t\textrm{inflow}_{n,s,t}n.stores_t.inflowParameter
ηstand;n,s\eta_{\textrm{stand};n,s}n.stores.standing_lossParameter
ηstore;n,s\eta_{\textrm{store};n,s}n.stores.efficiency_storeParameter
ηdispatch;n,s\eta_{\textrm{dispatch};n,s}n.stores.efficiency_dispatchParameter
on,s,to_{n,s,t}n.stores_t.marginal_costParameter
on,s,t−o^-_{n,s,t}n.stores_t.marginal_cost_dispatchParameter
on,s,t+o^+_{n,s,t}n.stores_t.marginal_cost_storeParameter
Nn,sN_{n,s}n.stores.cycles_maxParameter
wtsw_t^sn.snapshot_weightings.storesParameter

Storage Units

Storage units have three time-dependent variables, the discharge hn,s,t−h_{n,s,t}^- in MW, the charge hn,s,t+h_{n,s,t}^+ in MW and the state of charge socn,s,tsoc_{n,s,t} 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 (hn,s,t+h_{n,s,t}^+), discharge (hn,s,t−h_{n,s,t}^-), and state of charge (socn,s,tsoc_{n,s,t}) variables are constrained by:

ConstraintDual VariableName
hn,s,t−≥0h_{n,s,t}^- \geq 0only in n.modelStorageUnit-p_dispatch-lower
hn,s,t−≤hˉn,s,th^n,sh_{n,s,t}^- \leq \bar{h}_{n,s,t} \hat{h}_{n,s}only in n.modelStorageUnit-p_dispatch-upper
hn,s,t+≥0h_{n,s,t}^+ \geq 0only in n.modelStorageUnit-p_store-lower
hn,s,t+≤−h‾n,s,th^n,sh_{n,s,t}^+ \leq - \underline{h}_{n,s,t} \hat{h}_{n,s}only in n.modelStorageUnit-p_store-upper
socn,s,t≥0soc_{n,s,t} \geq 0only in n.modelStorageUnit-state_of_charge-lower
socn,s,t≤rn,sh^n,ssoc_{n,s,t} \leq r_{n,s} \hat{h}_{n,s}only in n.modelStorageUnit-state_of_charge-upper

where h^n,s\hat{h}_{n,s} is the nominal power capacity, hˉn,s,t\bar{h}_{n,s,t} is a time-dependent restriction on the discharge per unit of nominal capacity, h‾n,s,t\underline{h}_{n,s,t} is a time-dependent restriction on the maximum charge per unit of nominal capacity (usually negative, -1 by default), and rn,sr_{n,s} 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:

ConstraintDual VariableName
hn,s,t−≥0h_{n,s,t}^- \geq 0only in n.modelStorageUnit-ext-p_dispatch-lower
hn,s,t−≤hˉn,s,tHn,sh_{n,s,t}^- \leq \bar{h}_{n,s,t}H_{n,s}only in n.modelStorageUnit-ext-p_dispatch-upper
hn,s,t+≥0h_{n,s,t}^+ \geq 0only in n.modelStorageUnit-ext-p_store-lower
hn,s,t+≤−h‾n,s,tHn,sh_{n,s,t}^+ \leq - \underline{h}_{n,s,t} H_{n,s}only in n.modelStorageUnit-ext-p_store-upper

where Hn,sH_{n,s} 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 h~n,s,t−\tilde{h}_{n,s,t}^-, h~n,s,t+\tilde{h}_{n,s,t}^+, and soc~n,s,t\tilde{soc}_{n,s,t}:

ConstraintDual VariableName
hn,s,t−=h~n,s,t−h_{n,s,t}^- = \tilde{h}_{n,s,t}^-only in n.modelStorageUnit-p_dispatch_set
hn,s,t+=h~n,s,t+h_{n,s,t}^+ = \tilde{h}_{n,s,t}^+only in n.modelStorageUnit-p_store_set
socn,s,t=soc~n,s,tsoc_{n,s,t} = \tilde{soc}_{n,s,t}n.storage_units_t.mu_state_of_charge_setStorageUnit-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):

socn,s,t=ηstand;n,swtssocn,s,t−1+ηstore;n,swtshn,s,t+−ηdispatch;n,s−1wtshn,s,t−+wtsinflown,s,t−wtsspillagen,s,t↔λn,s,tMSV\begin{gather*}soc_{n,s,t} = \eta_{\textrm{stand};n,s}^{w_t^s} soc_{n,s,t-1}\\ + \eta_{\textrm{store};n,s} w_t^s h_{n,s,t}^+ - \eta^{-1}_{\textrm{dispatch};n,s} w_t^s h_{n,s,t}^- \\ + w_t^s\textrm{inflow}_{n,s,t} - w_t^s\textrm{spillage}_{n,s,t} \quad \leftrightarrow \quad \lambda_{n,s,t}^\textrm{MSV} \end{gather*}

ηstand;n,s\eta_{\textrm{stand};n,s} is the standing efficiency (e.g. due to thermal losses for thermal storage). ηstore;n,s\eta_{\textrm{store};n,s} and ηdispatch;n,s\eta_{\textrm{dispatch};n,s} are the efficiencies for power going into and out of the storage unit, and wtsw_t^s is the snapshot weighting for stores (e.g. 1 hour). The dual variable λn,s,tMSV\lambda_{n,s,t}^\textrm{MSV} 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 socn,s,t=−1soc_{n,s,t=-1}:

  1. Set cyclic_state_of_charge=False (default) and the value of state_of_charge_initial in MWh.
  2. Set cyclic_state_of_charge=True and the optimisation set the initial state of charge to the final state of charge.

socn,s,t=−1=socn,s,t=∣T∣−1soc_{n,s,t=-1} = soc_{n,s,t=|T|-1}

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

SymbolAttributeType
hn,s,t+h_{n,s,t}^+n.stores_t.p_dispatchDecision Variable
hn,s,t−h_{n,s,t}^-n.stores_t.p_storeDecision Variable
socn,s,tsoc_{n,s,t}n.storage_units_t.state_of_chargeDecision Variable
Hn,sH_{n,s}n.storage_units.p_nom_optDecision Variable
inflown,s,t\textrm{inflow}_{n,s,t}n.storage_units_t.inflowDecision Variable
spillagen,s,t\textrm{spillage}_{n,s,t}n.storage_units_t.spillageDecision Variable
λn,s,tMSV\lambda_{n,s,t}^\textrm{MSV}n.storage_units_t.mu_energy_balanceDual Variable
hˉn,s\bar{h}_{n,s}n.storage_units.p_nomParameter
h‾n,s,t\underline{h}_{n,s,t}n.storage_units_t.p_min_puParameter
hˉn,s,t\bar{h}_{n,s,t}n.storage_units_t.p_max_puParameter
rn,sr_{n,s}n.storage_units.max_hoursParameter
h~n,s,t−\tilde{h}_{n,s,t}^-n.storage_units_t.p_dispatch_setParameter
h~n,s,t+\tilde{h}_{n,s,t}^+n.storage_units_t.p_store_setParameter
soc~n,s,t\tilde{soc}_{n,s,t}n.storage_units_t.state_of_charge_setParameter
ηstand;n,s\eta_{\textrm{stand};n,s}n.storage_units.standing_lossParameter
ηstore;n,s\eta_{\textrm{store};n,s}n.storage_units.store_efficiencyParameter
ηdispatch;n,s\eta_{\textrm{dispatch};n,s}n.storage_units.dispatch_efficiencyParameter
wtsw_t^sn.snapshot_weightings.storesParameter

Examples

  • Storage Units as Links & Stores


    Shows how storage units can be replaced by more fundamental links and stores.

    Go to example


[^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.

diagram 2026-11-02

diagram 2025-10-09