Battery API¶
The simses.battery module holds the top-level Battery simulator, its mutable state, the CellType ABC that chemistry implementations subclass, the per-cell property dataclasses, cell-format presets, and current-derating strategies. For the system-level framing — ECM, series-parallel scaling, step() lifecycle — see the Battery concept page.
Battery system¶
Top-level simulator. Composes a CellType with a (serial, parallel) circuit, solves the ECM for the equilibrium current at each step, clamps to hard limits, and optionally applies derating and degradation.
simses.battery.battery.Battery
¶
Battery system composed of cells in a series-parallel circuit.
Models a pack of identical cells arranged as (serial, parallel) using
an equivalent-circuit model (ECM): terminal voltage is
OCV(SOC,T) + hysteresis + Rint × I. Each call to :meth:step solves
the equilibrium current for a requested power setpoint, clamps it to the
hard limits (C-rate, voltage window, SOC window), optionally applies a
:class:~simses.battery.derating.CurrentDerating strategy, and updates
the state.
Composition: a :class:~simses.battery.cell.CellType supplies the
electrochemistry and per-cell physical properties; an optional
:class:~simses.degradation.degradation.DegradationModel accumulates
capacity fade and resistance rise; an optional CurrentDerating
reduces current in voltage or temperature derating zones.
Sign convention: positive power / current = charging, negative = discharging.
Source code in src/simses/battery/battery.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 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 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | |
nominal_capacity
property
¶
Nominal capacity of the battery system in Ah.
nominal_voltage
property
¶
Nominal voltage of the battery system in V.
nominal_energy_capacity
property
¶
Nominal energy capacity of the battery system in Wh.
min_voltage
property
¶
Minimum allowed voltage of the battery system in V.
max_voltage
property
¶
Maximum allowed voltage of the battery system in V.
max_charge_current
property
¶
Maximum allowed charge current in A.
max_discharge_current
property
¶
Maximum allowed discharge current in A.
coulomb_efficiency
property
¶
Coulomb efficiency of the cell in p.u.
thermal_capacity
property
¶
Total thermal capacity of the battery system in J/K.
convection_coefficient
property
¶
Convection coefficient of the cell in W/m2K.
thermal_resistance
property
¶
Thermal resistance of the battery system in K/W.
min_temperature
property
¶
Minimum allowed temperature in °C.
max_temperature
property
¶
Maximum allowed temperature in °C.
area
property
¶
Effective cooling area of the pack in m².
Equals the per-cell surface area (cell.format.area) scaled by the
effective_cooling_area fraction and the pack size
(serial × parallel). Used by :attr:thermal_resistance to compute
the convective coupling between the pack and the thermal environment.
__init__(cell, circuit, initial_states, soc_limits=(0.0, 1.0), degradation=None, derating=None, effective_cooling_area=1.0)
¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cell
|
CellType
|
Cell model defining OCV, Rint, and physical parameters. |
required |
circuit
|
tuple[int, int]
|
Series-parallel configuration as |
required |
initial_states
|
dict
|
Dict with keys |
required |
soc_limits
|
tuple[float, float]
|
|
(0.0, 1.0)
|
degradation
|
DegradationModel | bool | None
|
Degradation model, or |
None
|
derating
|
CurrentDerating | None
|
Optional current-derating strategy applied after hard limits. |
None
|
effective_cooling_area
|
float
|
Fraction of the total cell surface area that participates in heat exchange with the environment, in p.u. (default 1.0 = full surface area). Use values below 1 to model packs where only a portion of each cell face is exposed to coolant, e.g. 0.5 for a two-sided cooling plate that covers half the cell surface. |
1.0
|
Source code in src/simses/battery/battery.py
initialize_state(start_soc, start_T, start_soh_Q=1.0, start_soh_R=1.0)
¶
Create the initial battery state from starting conditions.
Sets SOC, temperature, and SoH from the arguments, then evaluates
OCV, hysteresis, Rint, and entropic coefficient at that initial
state so the returned object is consistent before the first
:meth:step call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_soc
|
float
|
Initial state of charge in p.u. |
required |
start_T
|
float
|
Initial cell temperature in °C. |
required |
start_soh_Q
|
float
|
Initial capacity SoH in p.u. (default 1.0 = fresh). |
1.0
|
start_soh_R
|
float
|
Initial resistance SoH in p.u. (default 1.0 = fresh). |
1.0
|
Returns:
| Type | Description |
|---|---|
BatteryState
|
A fully-initialised :class: |
Source code in src/simses/battery/battery.py
step(power_setpoint, dt)
¶
Advance the battery state by one timestep.
If the battery cannot fulfil the power setpoint due to hard limits
(C-rate, voltage window, SOC window) or optional derating, the
current is curtailed and state.power reflects what was actually
delivered — not the original setpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
power_setpoint
|
float
|
Requested power in W. Positive = charging, negative = discharging. |
required |
dt
|
float
|
Timestep in seconds. |
required |
Source code in src/simses/battery/battery.py
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 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |
equilibrium_current(power_setpoint, ocv, hys, rint)
¶
Solve the ECM for the current that meets a power setpoint.
Solves the quadratic P = I × (OCV + hys + Rint × I) for I
and returns the physically meaningful (positive-discriminant) root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
power_setpoint
|
float
|
Target power in W. |
required |
ocv
|
float
|
System open-circuit voltage in V. |
required |
hys
|
float
|
System hysteresis voltage in V. |
required |
rint
|
float
|
System internal resistance in Ω. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Equilibrium current in A. Positive = charging, negative = |
float
|
discharging. |
Source code in src/simses/battery/battery.py
calculate_max_currents(state, dt, ocv, hys, rint, Q)
¶
Return the allowed current window for the next timestep.
Each bound is the most restrictive of three limits: the C-rate
limit (from cell max_charge_rate / max_discharge_rate), the
voltage limit (current that would drive terminal voltage to
max_voltage or min_voltage this step), and the SOC limit
(current that would drive SOC to the configured soc_limits
this step).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
BatteryState
|
Current battery state (reads |
required |
dt
|
float
|
Timestep in seconds. |
required |
ocv
|
float
|
System open-circuit voltage in V. |
required |
hys
|
float
|
System hysteresis voltage in V. |
required |
rint
|
float
|
System internal resistance in Ω. |
required |
Q
|
float
|
Current capacity in Ah (scaled by |
required |
Returns:
| Type | Description |
|---|---|
float
|
Tuple |
float
|
is non-negative; discharge bound is non-positive. |
Source code in src/simses/battery/battery.py
open_circuit_voltage(state)
¶
Return the system-level open-circuit voltage in V.
hysteresis_voltage(state)
¶
Return the system-level hysteresis voltage in V.
internal_resistance(state)
¶
Return the system-level internal resistance in Ohms, scaled by SoH.
Source code in src/simses/battery/battery.py
entropic_coefficient(state)
¶
Return the system-level entropic coefficient in V/K.
capacity(state)
¶
energy_capacity(state)
¶
State¶
Plain mutable dataclass mutated in place by Battery.step(). No methods — all logic is in Battery.
simses.battery.state.BatteryState
dataclass
¶
Dataclass representing the state of a battery.
float
Terminal voltage of the battery in volts (V).
i: float Current flowing into the battery in amperes (A). Positive for charging, negative for discharging. T: float Temperature of the battery in degrees Celsius (°C). power: float Power of the battery in watts (W). power_setpoint: float Desired power setpoint for the battery in watts (W). soc: float State of charge of the battery in per unit (p.u.). ocv: float Open-circuit voltage of the battery in volts (V). hys: float Hysteresis voltage of the battery in volts (V). rint: float Internal resistance of the battery in ohms (Ω). entropy: float Entropic coefficient of the battery in volts per Kelvin (V/K). soh_Q: float State of health of the battery in terms of capacity in per unit (p.u.). soh_R: float State of health of the battery in terms of resistance in per unit (p.u.). is_charge: bool True if the battery is charging, False if discharging. loss: float Power loss of the battery in watts (W). heat: float Internal heat generation of the battery in watts (W). i_max_charge: float Theoretical maximum charge current this timestep in amperes (A). i_max_discharge: float Theoretical maximum discharge current this timestep in amperes (A). Negative value.
Source code in src/simses/battery/state.py
Cell interface¶
Abstract base class for cell chemistries — the "datasheet" side of the composition. Required methods: open_circuit_voltage, internal_resistance. Optional overrides for hysteresis, entropic coefficient, and a default degradation model. See Extending Cell Models.
simses.battery.cell.CellType
¶
Bases: ABC
Abstract base class defining the interface and common properties for different types of battery cells. Subclasses must implement methods for calculating open-circuit voltage and internal resistance. Optionally, subclasses can override default_degradation_model() to ship a built-in degradation model.
Attributes:
| Name | Type | Description |
|---|---|---|
electrical |
ElectricalCellProperties
|
Electrical properties of the cell. |
thermal |
ThermalCellProperties
|
Thermal properties of the cell. |
format |
CellFormat
|
Physical format of the cell. |
Methods: open_circuit_voltage(state: BatteryState) -> float: Abstract method to compute the open-circuit voltage for a given battery state. hysteresis_voltage(state: BatteryState) -> float: Returns the hysteresis voltage for a given battery state. Default is 0. internal_resistance(state: BatteryState) -> float: Abstract method to compute the internal resistance (beginning of life) for a given battery state. default_degradation_model(initial_soc: float) -> DegradationModel | None: Returns the cell's built-in default degradation model, or None if not defined.
Source code in src/simses/battery/cell.py
open_circuit_voltage(state)
abstractmethod
¶
hysteresis_voltage(state)
¶
internal_resistance(state)
abstractmethod
¶
Compute the beginning-of-life internal resistance (in Ohms) for a given battery state.
entropic_coefficient(state)
¶
default_degradation_model(initial_soc, initial_state=None)
classmethod
¶
Return the cell's built-in default degradation model, or None if not defined.
Source code in src/simses/battery/cell.py
Cell properties¶
Per-cell electrical and thermal parameter dataclasses passed to CellType.__init__. Every chemistry supplies one of each.
simses.battery.properties.ElectricalCellProperties
dataclass
¶
Electrical parameters of a single cell.
Attributes:
| Name | Type | Description |
|---|---|---|
nominal_capacity |
float
|
Nominal capacity in Ah. |
nominal_voltage |
float
|
Nominal voltage in V. |
min_voltage |
float
|
Minimum allowed terminal voltage in V. |
max_voltage |
float
|
Maximum allowed terminal voltage in V. |
max_charge_rate |
float
|
Maximum charge C-rate in 1/h. |
max_discharge_rate |
float
|
Maximum discharge C-rate in 1/h. |
self_discharge_rate |
float
|
Self-discharge rate in p.u. SOC per day
(e.g. |
coulomb_efficiency |
float
|
Coulomb efficiency in p.u. Default: 1.0. |
charge_derate_voltage_start |
float | None
|
Terminal voltage at which charge
current derating begins, in V. Current is linearly reduced
from the C-rate limit at this voltage down to 0 at
|
discharge_derate_voltage_start |
float | None
|
Terminal voltage at which
discharge current derating begins, in V. Current is linearly
reduced from the C-rate limit at this voltage down to 0 at
|
Source code in src/simses/battery/properties.py
simses.battery.properties.ThermalCellProperties
dataclass
¶
Thermal parameters of a single cell.
Attributes:
| Name | Type | Description |
|---|---|---|
min_temperature |
float
|
Minimum allowed cell temperature in °C. |
max_temperature |
float
|
Maximum allowed cell temperature in °C. |
mass |
float
|
Mass of one cell in kg. |
specific_heat |
float
|
Specific heat capacity in J/kgK. |
convection_coefficient |
float
|
Convective heat transfer coefficient between the cell surface and the thermal environment, in W/m²K. |
Source code in src/simses/battery/properties.py
Cell formats¶
Physical format descriptors used to compute surface area and volume for thermal coupling. The two 26650 / 18650 presets bundle common dimensions.
simses.battery.format.CellFormat
dataclass
¶
simses.battery.format.PrismaticCell
dataclass
¶
Bases: CellFormat
Prismatic cell format with height, width, and length in mm.
Source code in src/simses/battery/format.py
simses.battery.format.RoundCell
dataclass
¶
Bases: CellFormat
Cylindrical cell format with diameter and length in mm.
Source code in src/simses/battery/format.py
simses.battery.format.RoundCell18650
dataclass
¶
simses.battery.format.RoundCell26650
dataclass
¶
Derating¶
Optional current-curtailment strategies applied after hard limits. Protocol-based — use the shipped linear voltage / thermal strategies, compose them with DeratingChain, or implement your own.
simses.battery.derating.CurrentDerating
¶
Bases: Protocol
Protocol for current derating strategies.
A derating function receives the candidate current (already clamped to hard limits) and the current battery state, and returns a (possibly reduced) current.
Sign convention: - If i > 0 (charging), return a value in [0, i] - If i < 0 (discharging), return a value in [i, 0] - If i == 0, return 0
Source code in src/simses/battery/derating.py
simses.battery.derating.DeratingChain
¶
Applies multiple derating strategies in sequence.
Each strategy receives the output of the previous one. Since each step can only reduce |i|, the most restrictive combination wins naturally. The chain short-circuits when i reaches 0.
DeratingChain itself satisfies the CurrentDerating protocol and can be nested.
Source code in src/simses/battery/derating.py
derate(i, state)
¶
Apply each strategy in sequence, short-circuiting at zero.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
i
|
float
|
Candidate current in A. |
required |
state
|
BatteryState
|
Current battery state. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Current after all strategies have been applied in order. |
Source code in src/simses/battery/derating.py
simses.battery.derating.LinearVoltageDerating
¶
Linearly reduce current when terminal voltage enters the derating zone.
Charge: ramp from full current at charge_start_voltage down to 0 at max_voltage. Discharge: ramp from full current at discharge_start_voltage down to 0 at min_voltage.
All voltage values must be at the system level (cell voltage * serial count).
Source code in src/simses/battery/derating.py
from_cell(cell, serial)
classmethod
¶
Build from cell electrical properties, scaling voltages to system level.
Returns None if neither derating threshold is configured on the cell.
Source code in src/simses/battery/derating.py
derate(i, state)
¶
Return the current scaled down if the derating zone is active.
The terminal voltage is computed from the incoming current and the state's OCV / hysteresis / Rint, then:
- Charge (
i > 0): full current belowcharge_start_voltage, zero atmax_voltage, linear in between. - Discharge (
i < 0): full current abovedischarge_start_voltage, zero atmin_voltage, linear in between.
If the corresponding start voltage is None, no derating is
applied for that direction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
i
|
float
|
Candidate current in A (already clamped to hard limits). |
required |
state
|
BatteryState
|
Current battery state. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Derated current in A (same sign as |
Source code in src/simses/battery/derating.py
simses.battery.derating.LinearThermalDerating
¶
Linearly reduce current when temperature enters the derating zone.
Between T_start and T_max, current is scaled linearly from 100% down to 0%. Below T_start: no derating. At or above T_max: current is forced to 0.
All temperatures must be in °C. Separate thresholds can be configured for charge and discharge; if omitted, discharge reuses the charge thresholds.
Source code in src/simses/battery/derating.py
derate(i, state)
¶
Return the current scaled down if the temperature derating zone is active.
Below the start temperature no derating is applied; between start and max the current is scaled linearly from 100% down to 0%; at or above the max temperature the current is forced to 0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
i
|
float
|
Candidate current in A (already clamped to hard limits). |
required |
state
|
BatteryState
|
Current battery state (reads |
required |
Returns:
| Type | Description |
|---|---|
float
|
Derated current in A (same sign as |