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 — AC PF (Fixed-Point Iteration)

ACPowerFlowResult

Dataclass returned by AC PF solvers.

FieldTypeDescription
successboolWhether solver converged
messagestrSolver status message
ybus_resultYBusResultY-bus matrix and node mapping
voltagenp.ndarrayComplex nodal voltages (V)
voltage_punp.ndarrayPer-unit voltage magnitudes
power_injectionnp.ndarrayComplex power injections (W + j·var)
iterationsintFixed-point iterations
max_mismatch_pufloatFinal maximum per-unit voltage change

solve_ac_power_flow

Low-level fixed-point iteration AC power flow solver (OpenDSS-style).

def solve_ac_power_flow(
    system: DistributionSystem,
    *,
    p_spec_w: dict[BusPhaseLabel, float] | None = None,
    q_spec_var: dict[BusPhaseLabel, float] | None = None,
    slack_label: BusPhaseLabel | list[BusPhaseLabel] | None = None,
    include_neutral: bool = False,
    include_shunt: bool = False,
    convert_geometry_to_matrix: bool = True,
    max_iterations: int = 100,
    tolerance: float = 1e-6,
) -> ACPowerFlowResult:

Parameters:

ParameterDefaultDescription
p_spec_wNoneActive power spec per node (W, positive = generation)
q_spec_varNoneReactive power spec per node (var)
slack_labelNoneSlack bus-phase node(s). Defaults to all non-neutral phases of the source bus
include_neutralFalseInclude neutral phase in Y-bus
include_shuntFalseInclude shunt admittance from c_matrix
convert_geometry_to_matrixTrueConvert geometry-based impedances to matrix form
max_iterations100Maximum fixed-point iterations
tolerance1e-6Per-unit voltage change convergence threshold

solve_ac_power_flow_from_components

Convenience wrapper that auto-derives P/Q specs from system components.

def solve_ac_power_flow_from_components(
    system: DistributionSystem,
    *,
    include_loads: bool = True,
    include_solar: bool = True,
    include_battery: bool = False,
    include_capacitor: bool = True,
    load_scale: float = 1.0,
    solar_scale: float = 1.0,
    battery_scale: float = 1.0,
    capacitor_scale: float = 1.0,
    slack_label: BusPhaseLabel | list[BusPhaseLabel] | None = None,
    include_neutral: bool = False,
    include_shunt: bool = False,
    convert_geometry_to_matrix: bool = True,
    max_iterations: int = 100,
    tolerance: float = 1e-6,
) -> ACPowerFlowResult:

Parameters:

ParameterDefaultDescription
include_loadsTrueInclude distribution loads in P/Q specs
include_solarTrueInclude solar PV generation
include_batteryFalseInclude battery storage
include_capacitorTrueInclude capacitor reactive injection
load_scale1.0Multiplier for load magnitudes
solar_scale1.0Multiplier for solar generation
battery_scale1.0Multiplier for battery dispatch
capacitor_scale1.0Multiplier for capacitor injection
slack_labelNoneSlack bus-phase node(s)
max_iterations100Maximum fixed-point iterations
tolerance1e-6Per-unit voltage change convergence threshold