API Documentation¶
Blocks module¶
This module contains all of the classes that represent distinct blocks within a battery simulation.
-
class
battery_sizing_model.blocks.Battery(cell_chemistry: str, pack_capacity: float, pack_voltage: float = 0, cell_discharge_energy_eff: float = 1, cell_charge_energy_eff: float = 1)[source]¶ -
Represents a full battery pack of a single chemistry.
Attributes¶
cell_chemistry:strChemistry of the battery. Currently only supports NCA.
pack_capacity:floatCapacity of the pack in Watt-hours.
pack_voltage:float, optionalRated voltage of the pack, doesn’t have any bearing on the performance of the simulation. Default = 0.
cell_dishcarge_energy_eff:float, optionalEnergy efficiency of the battery during discharge. Default = 1.
cell_charge_energy_eff:float, optionalEnergy efficiency of the battery during charge. Default = 1.
cell_capacity_ah:floatCell capacity in Amp-hours.
cell_capacity_wh:floatCell capacity in Watt-hours.
cell_nom_voltage:floatNominal voltage of the cell.
cell_min_voltage:floatMinimum voltage of the cell.
price_per_kwh:floatEstimated price_per_kwh of the cell chemistry.
capital_cost:floatCapital cost of the battery pack cells.
num_series:intCalculated number of cells in series in the pack. Only valid if
pack_voltage> 0.num_parallel:intCalculated number of cells in parallel in the pack.
-
class
battery_sizing_model.blocks.BatterySimulator(ecm: ECM, ocv: OCVTable, integrator: SOCIntegrator, deg_model: DegradationModel, battery: Battery, soc: float = 1, soh: float = 1)[source]¶ -
Represents a simulation for a battery.
Attributes¶
ecm:ECMEquivalent circuit model object.
ocv:OCVTableOpen circuit voltgate lookup table object.
integrator:SOCIntegratorState of charge integrator.
deg_model:DegradationModelState of health estimation model.
battery:BatteryBattery object.
soc:floatState of charge at this step.
soh:floatState of health at this step.
voltage:floatVoltage at this step.
soh_i:floatBeginning of life state of health.
nom_cap:floatCell nominal capacity.
voltage_result:list[float]Estimated voltage for every step in the simulation.
current_result:list[float]Calculated current for every step in the simulation.
soc_result:list[float]State of charge calculated at every step in the simulation.
soh_result:list[float]State of health calculated every 340 hours of simulation.
-
run(power: list[float], timestep: float, validate: bool = False) None[source]¶ -
Simulation loop that estimates battery state of health, state of charge, and voltage.
Parameters¶
power:array[float]Entire power signal for the battery with magnitudes on the pack level scale. Points are spaced out in time with a distance of
timestepbetween them.timestep:floatTimestep of the simulation.
validate:boolFlag for turning off error checking to account for varying charge/discharge efficiencies in real life data.
-
exception
battery_sizing_model.blocks.CapacityError(*args: object, message='State of charge is greater than the current state of health or less than 0.')[source]¶
-
class
battery_sizing_model.blocks.DegradationModel(ref_soc: float = 0.5)[source]¶ -
Represents a model that predicts the battery SOH.
Attributes¶
model_params:numpy.arrayFitted coefficients for the model using molicel P42A cell data.
dod:listDepth of discharge of every step in the simulation.
delta_soc:floatChange in state of charge between steps.
soc_sign:int1 for positive change in state of charge. -1 for negative change in state of charge.
ref_soc:floatReference state of charge for the depth of discharge calculation.
soc_chg:floatAmount of charge added to the battery for each step.
cycle_chg:intNumber of equivalent full cycles * 2.
-
increment_dod(prev_soc: float, curr_soc: float) None[source]¶ -
Increments the depth of discharge based on the previoius and current soc.
DOD is only calculated if the sign of the current changes.
Parameters¶
prev_soc:floatPrevious steps state of charge.
curr_soc:floatCurrent steps state of charge.
-
increment_efc(prev_soc: float, curr_soc: float) None[source]¶ -
Increments the equivalent full cycle value given the previous and current state of charge.
An equivalent full cycle is counted when the battery has experienced enough cumulative charge to fully charge or discharge the battery.
Parameters¶
prev_soc:floatPrevious steps state of charge.
curr_soc:floatCurrent steps state of charge.
-
model(efc: float, c_rate: list[float], dod: list[float], t: float, soh_i: float) float[source]¶ -
State of health estimation model that estimates the state of health of the battery for a given time-period.
Parameters¶
efc:floatEquivalent full cycles, defined as the amount of charge needed to fully charge or discharge the battery. See
increment_efc().c_rate:list[float]C-rate for every soh estimation step.
dod:list[float]Depth of discharge for every soh estimation step. See
increment_dod().t:floatTotal time in hours that the battery has existed.
soh_i:floatBeginning of life state of health of the battery.
Returns¶
floatEstimeated state of health for the given input parameters.
-
class
battery_sizing_model.blocks.ECM(num_rc_pairs: int, R0: float, R: list[float], C: list[float], timestep: int)[source]¶ -
Represents an equivalent circuit model.
This class is used for simulating a circuit given circuit parameters.
Currently only supports multi-RC Randles circuits.
Attributes¶
r0:floatSeries resistance of the Randles circuit.
R:numpy.arrayArray of resistances in the RC pairs.
C:numpy.arrayArray of capacitances in the RC pairs.
A_rc:numpy.arrayState matrix for the circuit.
B_rc:numpy.arrayControl matrix for the circuit.
I_rk:numpy.arrayPrevious current estimate through the RC pairs.
-
class
battery_sizing_model.blocks.OCVTable[source]¶ -
Represents an open circuit voltage lookup table.
Currently only supports the molicel P42A cell (NCA).
Attributes¶
charge_ocv:dictCharge open circuit voltage indexed by state of health.
discharge_ocv:dictDischarge open circuit voltage indexed by state of health.
x:arrayInterpolation points for the lookup table.
-
class
battery_sizing_model.blocks.SOCIntegrator(charge_eff: float = 1, discharge_eff: float = 1, validate: bool = False)[source]¶ -
Represents an integrator for counting couloumbs and calculating state of charge.
Attributes¶
charge_eff:float, optionalCharge efficiency of the battery [0,1]. Default = 1.
discharge_eff:float, optionalDischarge efficiency of the battery [0,1]. Default = 1.
validate:bool, optionalFlag for indicating whether the sim should compensate for the varying charge/discharge efficiency in real data when validating. Default = False.
-
step(soc_k: float, timestep: float, I_k: float, nom_cap: float) float[source]¶ -
Integrate the current for this timestep.
Assumes that current is constant over the sampling interval.
Parameters¶
soc_k:floatState of charge of the previous step.
timestep:floatDuration in time for this step.
I_k:floatCurrent for this step.
nom_cap:floatNominal capacity of the battery.
Returns¶
floatState of charge from this step.