Python Result Objects

April 23, 2026 ยท View on GitHub

This page documents the fields and methods on the result objects returned by Surge's Python analysis functions.

AcPfResult

Returned by surge.solve_ac_pf() and surge.powerflow.solve_ac_pf().

Properties

PropertyTypeDescription
convergedboolWhether the solver converged
statusstr"Converged", "MaxIterations", "Diverged", or "Unsolved"
iterationsintNewton-Raphson iteration count
max_mismatchfloatFinal maximum power mismatch (p.u.)
solve_time_secsfloatWall-clock solve time in seconds
vmndarrayBus voltage magnitudes (p.u.)
va_radndarrayBus voltage angles (radians)
va_degndarrayBus voltage angles (degrees)
p_inject_mwndarrayNet active power injection per bus (MW)
q_inject_mvarndarrayNet reactive power injection per bus (MVAr)
gen_q_mvarndarrayReactive power output per generator (MVAr)
q_limited_buseslist[int]Bus numbers where PV-to-PQ switching occurred
n_q_limit_switchesintTotal PV/PQ bus type switches
island_idslist[int]Per-bus island assignment (when island detection enabled)
n_islandsintNumber of electrical islands detected
area_interchangedict or NoneArea interchange results (when enforce_interchange enabled)
convergence_historyndarrayNx2 array of [iteration, mismatch] (when recorded)
branch_apparent_powerndarrayBranch apparent power flows (MVA)
branch_loading_pctndarrayBranch loading as percentage of Rate A (requires attached network)

Methods

MethodReturnDescription
get_buses()listAll buses with solved voltages and injections
bus(number)objectSingle bus result by bus number
get_branches()listAll branches with solved power flows
get_generators()listAll generators with solved reactive output
violated_buses(vmin, vmax)listBuses with voltage outside [vmin, vmax]
overloaded_branches(threshold_pct)listBranches above loading threshold
to_dataframe()DataFrameBus results: bus_id, vm_pu, va_deg, p_mw, q_mvar
to_json() / from_json()str / resultJSON serialization round-trip
to_dict()dictPlain Python dictionary of all results

DcPfResult

Returned by surge.solve_dc_pf() and surge.powerflow.solve_dc_pf().

Properties

PropertyTypeDescription
va_radndarrayBus voltage angles (radians)
va_degndarrayBus voltage angles (degrees)
branch_p_mwndarrayBranch active power flows (MW)
slack_p_mwfloatSlack bus real power injection (MW)
solve_time_secsfloatSolve time in seconds
total_generation_mwfloatTotal system generation after slack balancing
bus_p_inject_mwndarrayNet real power injection per bus (MW)
bus_numberslist[int]Bus numbers in bus order
branch_fromlist[int]From-bus numbers in branch order
branch_tolist[int]To-bus numbers in branch order
branch_circuitlist[str]Circuit identifiers in branch order

Methods

MethodReturnDescription
to_dataframe()DataFrameBus results: bus_id, va_rad, va_deg
branch_dataframe()DataFrameBranch results: from_bus, to_bus, circuit, p_mw

DcOpfResult

Returned by surge.solve_dc_opf().

Wraps the base OpfResult and adds DC-OPF-specific fields. All OpfResult properties are accessible directly on the DcOpfResult object.

Additional Properties

PropertyTypeDescription
hvdc_dispatch_mwlistOptimal HVDC P_dc setpoints (MW)
hvdc_shadow_priceslistHVDC capacity shadow prices ($/MWh)
generator_limit_violationslist(gen_index, violation_mw) pairs
feasibleboolWhether all hard constraints are satisfied

AcOpfResult

Returned by surge.solve_ac_opf(). Wraps OpfResult with the same delegation pattern as DcOpfResult.

OpfResult (Base)

The shared OPF solution surface used by DC-OPF, AC-OPF, and SCOPF results.

Properties

PropertyTypeDescription
total_costfloatOptimal generation cost ($/hr)
opf_typestrFormulation: "dc_opf", "ac_opf", "dc_scopf", "ac_scopf"
solve_time_secsfloatWall-clock solve time
iterationsintSolver iterations
gen_p_mwndarrayGenerator active power dispatch (MW)
gen_q_mvarndarrayGenerator reactive dispatch (MVAr); AC-OPF only
gen_bus_numberslist[int]Bus number per generator
gen_idslist[str]Generator IDs
lmpndarrayLocational marginal prices ($/MWh)
lmp_energyndarrayEnergy component of LMP ($/MWh)
lmp_congestionndarrayCongestion component of LMP ($/MWh)
lmp_lossndarrayLoss component of LMP ($/MWh)
lmp_reactivendarrayReactive LMP ($/MVAr-h); AC-OPF only
vmndarrayBus voltage magnitudes (p.u.); all 1.0 for DC-OPF
va_radndarrayBus voltage angles (radians)
total_load_mwfloatTotal system load (MW)
total_generation_mwfloatTotal generation (MW)
total_losses_mwfloatTotal system losses (MW); zero for DC-OPF
branch_pf_mwndarrayFrom-end active power flow per branch (MW)
branch_pt_mwndarrayTo-end active power flow per branch (MW)
branch_qf_mvarndarrayFrom-end reactive flow (MVAr); AC-OPF only
branch_qt_mvarndarrayTo-end reactive flow (MVAr); AC-OPF only
branch_loading_pctndarrayBranch loading as % of Rate A
branch_shadow_pricesndarrayBranch constraint shadow prices ($/MWh)
binding_branch_indiceslist[int]Indices of branches with active constraints
mu_pg_min / mu_pg_maxndarrayGenerator P bound duals ($/MWh)
mu_qg_min / mu_qg_maxndarrayGenerator Q bound duals; AC only
mu_vm_min / mu_vm_maxndarrayVoltage bound duals; AC only

ScopfResult

Returned by surge.solve_scopf().

Properties

PropertyTypeDescription
base_opfOpfResultBase-case OPF solution
convergedboolWhether constraint generation converged
iterationsintConstraint generation iterations
formulationstr"dc" or "ac"
modestr"preventive" or "corrective"
total_contingencies_evaluatedintContingencies checked
binding_contingencieslistContingencies with non-zero shadow prices
lmp_contingency_congestionlistPer-bus contingency congestion component ($/MWh)
solve_time_secsfloatWall-clock time

ContingencyAnalysis

Returned by surge.analyze_n1_branch(), surge.analyze_n1_generator(), surge.analyze_n2_branch(), and surge.analyze_contingencies().

Properties

PropertyTypeDescription
n_contingenciesintTotal contingencies analyzed
n_screened_outintContingencies filtered by screening
n_ac_solvedintContingencies solved with full AC NR
n_convergedintAC-solved contingencies that converged
n_with_violationsintContingencies with at least one violation
n_violationsintTotal violations across all contingencies
n_voltage_criticalintContingencies classified as voltage-critical
solve_time_secsfloatWall-clock analysis time

Methods

MethodReturnDescription
to_dataframe()DataFramePer-contingency summary with violations
results_dataframe()DataFramePer-contingency: id, converged, n_violations, max_loading
violations_dataframe()DataFrameFlat violation table across all contingencies
voltage_critical_df()DataFrameVoltage-critical contingencies sorted by L-index
post_contingency_vm(id)ndarray or NonePost-contingency voltages for a specific contingency
post_contingency_va(id)ndarray or NonePost-contingency angles for a specific contingency

HvdcResult

Returned by surge.solve_hvdc().

Properties

PropertyTypeDescription
convergedboolConvergence status
iterationsintSolver iterations
methodstrSolution method used
total_converter_loss_mwfloatTotal converter losses (MW)
total_dc_network_loss_mwfloatTotal DC network losses (MW)
total_loss_mwfloatTotal HVDC losses (MW)
stationslistConverter station solutions
dc_buseslistDC bus voltage solutions

Each HvdcStationSolution contains: name, technology, ac_bus, dc_bus, p_ac_mw, q_ac_mvar, p_dc_mw, v_dc_pu, converter_loss_mw, converged, and optionally lcc_detail (with alpha_deg, gamma_deg, i_dc_pu, power_factor).

NercAtcResult

Returned by surge.transfer.compute_nerc_atc().

Properties

PropertyTypeDescription
atc_mwfloatAvailable Transfer Capability (MW)
ttc_mwfloatTotal Transfer Capability (MW)
trm_mwfloatTransmission Reliability Margin (MW)
cbm_mwfloatCapacity Benefit Margin (MW)
etc_mwfloatExisting Transmission Commitments (MW)
binding_branchint or NoneIndex of the branch limiting transfer
binding_contingencyint or NoneIndex of the contingency causing the limit
transfer_ptdflist[float]Per-monitored-branch sensitivity to the transfer
reactive_margin_warningboolTrue if generators approach reactive limits