BatteryModel¶
- class flexops.unit_models.storage.battery.BatteryModel(*args, **kwds)¶
Bases:
ProcessBlock- Parameters:
rule (function) – A rule function or None. Default rule calls build().
concrete (bool) – If True, make this a toplevel model. Default - False.
ctype (class) –
Pyomo ctype of the block. Default - pyomo.environ.Block
Config args
- dynamic
Indicates whether this model will be dynamic or not, default = useDefault. Valid values: { useDefault - get flag from parent (default = False), True - set as a dynamic model, False - set as a steady-state model.}
- has_holdup
Indicates whether holdup terms should be constructed or not. Must be True if dynamic = True, default - False. Valid values: { useDefault - get flag from parent (default = False), True - construct holdup terms, False - do not construct holdup terms}
- property_package
Property (parameter) block carrying flow between units; None for units that need no fluid properties.
- flexops_config
Optional already-validated UnitConfig for this unit (never a raw dict).
- unit_commitment
Per-unit unit-commitment sub-config.
- external_dispatch
Optional external (DERMS) dispatch source consumed by set_external_dispatch.
- relaxation
Discrete-structure relaxation policy.
- allow_pass_through
Whether add_bypass_constraints() builds inlet-to-outlet pass-through equalities for this unit’s non-excluded state variables. SISOBlock (and its subclasses Pump/Tank) override the base default to True so the flow-topology units are well-posed out of the box; the base OpsBlock default stays False.
- costing_package
Optional FlexCosting block this unit associates with: register_power forwards the unit’s power draw to it. None for standalone units; the forwarding is strictly conditional.
- energy_capacity
Initial battery energy capacity, kWh – the fixed design Var value at construction. Required.
- power_charge_max
Maximum charging power, kW. None (default) falls back to a 1C rate (the whole energy capacity in one hour) – with unit_commitment.status enabled, its semicontinuous link needs a finite bound; the fallback applies either way so a bare battery is never unbounded. Give it and power_discharge_max together or not at all.
- power_discharge_max
Maximum discharging power, kW. Same rule as power_charge_max, including the 1C fallback.
- eta_charge
Charging efficiency, a fraction in (0, 1].
- eta_discharge
Discharging efficiency, a fraction in (0, 1].
- soc_min
Minimum state of charge, a fraction of energy capacity in [0, 1].
- soc_max
Maximum state of charge, a fraction of energy capacity in [0, 1].
- initial_soc
Initial state of charge, a fraction of energy capacity in [0, 1], before step 0’s flows; sets the charge_init Var (rolling-horizon state).
- fix_initial_state
Fix the charge_init Var and register it as rolling-horizon initial state; False leaves it free, so the solve chooses the starting charge.
- cyclic
Require the final charge to be at least the starting charge.
- soh
State of health, a fraction of nameplate energy capacity still available due to degradation; fixes soh at construction. Default 0.85 represents a mid-life battery.
- charge_leakage_rate
Self-discharge (charge leakage) rate: fraction of stored charge lost per day, fixing charge_leakage_rate at construction. Default 0.0005/day (0.05%/day).
initialize (dict) – ProcessBlockData config for individual elements. Keys are BlockData indexes and values are dictionaries with config arguments as keys.
idx_map (function) – Function to take the index of a BlockData element and return the index in the initialize dict from which to read arguments. This can be provided to override the default behavior of matching the BlockData index exactly to the index in initialize.
- Returns:
(BatteryModel) New instance
Variables
Name |
Index |
Units |
Role |
Description |
|---|---|---|---|---|
power_charge |
time |
kW |
input |
Charging power draw (dispatch input). |
power_discharge |
time |
kW |
input |
Discharging power output (dispatch input). |
power_electrical |
time |
kW |
output |
Electrical draw of the unit |
charge |
time |
kWh |
output |
Stored energy content. |
Constraints
Name |
Description |
|---|---|
power_charge_limit |
power_charge[t] <= power_capacity. |
power_discharge_limit |
power_discharge[t] <= power_capacity. |
net_electrical |
power_electrical == power_charge - power_discharge (discharge is a negative/export draw; v0 is behind-the-meter). |
charge_balance |
Charge holdup (backward difference): charge[t] == charge[t-1]*(1 - charge_leakage_rate*dt) + dt*(eta_charge*power_charge[t] - power_discharge[t]/eta_discharge); t=0 references charge_init in place of charge[-1], so power_charge[0]/power_discharge[0] are energy-conserving too (a separate, unconstrained-at-t=0 initial condition would let power_charge[0]/power_discharge[0] move for free, manufacturing energy from nothing). |
soc_lower_limit |
charge[t] >= soc_min * energy_capacity. |
soc_upper_limit |
charge[t] <= soc_max * energy_capacity. |
charge_init_lower_limit |
charge_init >= soc_min * energy_capacity. |
charge_init_upper_limit |
charge_init <= soc_max * energy_capacity. |
charge_init_soh_limit |
charge_init <= soh * energy_capacity. |
soh_capacity_limit |
State-of-health limit: charge[t] <= soh * energy_capacity. Independent of soc_max – soh models capacity fade from degradation, while soc_max is an operational headroom fraction of nameplate energy capacity. |
Degrees of Freedom
Name |
Units |
Description |
|---|---|---|
power_charge |
kW |
Charging power draw (dispatch input). |
power_discharge |
kW |
Discharging power output (dispatch input). |