fluxopt.constraints.storage
¶
Storage constraint helpers.
Module-level functions that add accumulation balance constraints to a linopy Model. Used by FlowSystem to build storage features.
Functions:
| Name | Description |
|---|---|
add_accumulation_constraints |
Add state accumulation balance constraints. |
add_accumulation_constraints
¶
add_accumulation_constraints(
m: Model,
variable: Variable,
*,
inflow: LinearExpression | Variable | DataArray | float = 0,
outflow: LinearExpression | Variable | DataArray | float = 0,
decay: DataArray | float = 1.0,
initial: LinearExpression | Variable | DataArray | float | None = None,
dim: str = 'time',
name: str = 'accumulation',
) -> Constraint | tuple[Constraint, Constraint]
Add state accumulation balance constraints.
Uses end-of-period convention: variable[t] is the state at the
END of period t. The balance reads::
variable[t] = variable[t - 1] * decay[t] + inflow[t] - outflow[t]
For t=0 the initial parameter replaces variable[t-1].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Model
|
Linopy model. |
required |
|
Variable
|
State variable with a |
required |
|
LinearExpression | Variable | DataArray | float
|
Additive inflow per period (aligned to variable dims). |
0
|
|
LinearExpression | Variable | DataArray | float
|
Additive outflow per period (aligned to variable dims). |
0
|
|
DataArray | float
|
Multiplicative retention factor per period (1 = no loss). |
1.0
|
|
LinearExpression | Variable | DataArray | float | None
|
State before period 0. If None, t=0 is unconstrained. |
None
|
|
str
|
Temporal dimension name. |
'time'
|
|
str
|
Base name for constraints. |
'accumulation'
|
Returns:
| Type | Description |
|---|---|
Constraint | tuple[Constraint, Constraint]
|
Single balance constraint if initial is None, otherwise a tuple |
Constraint | tuple[Constraint, Constraint]
|
of (initial_constraint, balance_constraint). |