Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

API — Multi-Period OPF

BatterySpec

Battery parameters for multi-period optimization.

FieldTypeDefaultDescription
namestrBattery identifier
nodetuple[str, str](bus_name, phase) connection point
energy_capacity_whfloatTotal energy capacity (Wh)
p_charge_max_wfloatMaximum charging power (W)
p_discharge_max_wfloatMaximum discharging power (W)
soc_initialfloat0.5Initial state of charge
soc_minfloat0.1Minimum allowable SOC
soc_maxfloat0.9Maximum allowable SOC
charge_efficiencyfloat0.95Charging efficiency
discharge_efficiencyfloat0.95Discharging efficiency
cost_linearfloat10.0Linear cost coefficient

MultiPeriodResult

Result from multi-period optimization.

FieldTypeDescription
successboolWhether solver converged
messagestrStatus message
solverstrSolver used ("dc" or "ldf")
num_timestepsintNumber of timesteps
objectivefloatOptimal objective value
generator_dispatch_wdict[int, dict[str, float]]timestep → {gen_name → watts}
battery_socdict[str, list[float]]battery_name → SOC trace
nodal_voltagedict | NonePer-timestep voltages (LinDistFlow only)
theta_raddict | NonePer-timestep angles (DC OPF only)
slack_injection_wdict | NonePer-timestep slack injection (DC OPF only)
db_pathstr | NoneSQLite database path
run_idstr | NoneUnique run identifier

Functions

build_battery_specs_from_components(system, ...)

Extract BatterySpec list from system battery components.

Parameters:

ParameterTypeDefaultDescription
systemDistributionSystemInput system
soc_initialfloat0.5Initial SOC for all batteries
soc_minfloat0.1Minimum SOC
soc_maxfloat0.9Maximum SOC
charge_efficiencyfloat0.95Charging efficiency
discharge_efficiencyfloat0.95Discharging efficiency
cost_linearfloat10.0Linear cost

Returns: list[BatterySpec]

solve_multiperiod_dc_opf(system, *, generators, timestep_range, ...)

Solve multi-period DC OPF with battery SOC coupling and optional ramp constraints.

Parameters:

ParameterTypeDefaultDescription
systemDistributionSystemInput system with time series
generatorslist[DCGenerator]Dispatchable generators
timestep_rangerangeTimestep indices
battery_specslist[BatterySpec] | NoneNoneBattery parameters (auto-extracted if None)
ramp_limit_wfloat | NoneNoneGenerator ramp limit (W)
db_pathstr | NoneNoneSQLite output path

Returns: MultiPeriodResult

Formulation: Joint LP over all timesteps with:

solve_multiperiod_lindistflow(system, *, timestep_range, ...)

Solve multi-period LinDistFlow with battery SOC coupling.

Two-stage approach:

  1. LP optimizes battery dispatch schedule across all timesteps

  2. LinDistFlow re-solves per timestep with optimized battery injections

Parameters:

ParameterTypeDefaultDescription
systemDistributionSystemInput system with time series
timestep_rangerangeTimestep indices
battery_specslist[BatterySpec] | NoneNoneBattery parameters
db_pathstr | NoneNoneSQLite output path

Returns: MultiPeriodResult