Data Model And Conventions

March 30, 2026 · View on GitHub

This page documents the per-unit system, sign conventions, and core entity schema used throughout Surge. These conventions apply uniformly to the Rust crates, the Python package, the CLI, and the native file formats.

Per-Unit System

Surge stores all electrical quantities in the per-unit system on a common system base.

QuantityInternal unitBase
Voltage magnitudeper-unitbase_kv of the local bus
Voltage angleradiansabsolute
Active powerMW
Reactive powerMVAr
Apparent powerMVA
Branch impedance (r, x)per-unitsystem base_mva and from_bus base_kv
Branch charging (b)per-unitsystem base_mva and from_bus base_kv
Tap ratioper-unitoff-nominal turns ratio (1.0 = no transformation)
Phase shiftradians
Shunt conductance / susceptanceMW / MVAr at V = 1.0 p.u.
Branch thermal ratingsMVA

The default system base is 100 MVA (Network.base_mva = 100.0). All per-unit impedances, admittances, and injections are on this base unless stated otherwise.

Converting Physical To Per-Unit

Branch impedance from ohms to per-unit:

Z_base = base_kv^2 / base_mva

r_pu = r_ohm / Z_base
x_pu = x_ohm / Z_base
b_pu = b_siemens * Z_base

The Python helper surge.units.ohm_to_pu(ohm, base_kv, base_mva) performs this conversion.

Transformer Per-Unit Convention

Transformer r and x are stored in per-unit on the system base and the from-bus (winding-1) base_kv, matching MATPOWER and PSS/E convention. The tap field is the off-nominal turns ratio:

  • tap = 1.0 means the transformer operates at nominal ratio.
  • tap > 1.0 means the from-side voltage is boosted relative to the to-side.
  • tap < 1.0 means the from-side voltage is bucked.

For phase-shifting transformers, phase_shift_rad is the additional angle shift introduced by the transformer, in radians. Positive shift advances the from-side angle relative to the to-side.

Sign Conventions

QuantitySign convention
Generator active power (p)Positive = injecting into the network
Generator reactive power (q)Positive = injecting vars into the network
Load active power (active_power_demand_mw)Positive = consuming from the network
Load reactive power (reactive_power_demand_mvar)Positive = consuming vars from the network
Branch flow (branch_p_from_mw)Positive = power flowing from the from-bus into the branch
Shunt susceptance (b_mvar)Positive = capacitive (generating vars)
Shunt conductance (g_mw)Positive = power consumption
HVDC station p_ac_mwPositive = injecting into the AC network; negative = drawing from AC
HVDC station p_dc_mwPositive = injecting into the DC network; negative = drawing from DC

System Frequency

Network.freq_hz defaults to 60 Hz. Individual buses may override this with bus.freq_hz for mixed-frequency systems. Solvers use the network-level default unless a bus-level override is present.

Core Entity Schema

Network

The top-level container. Key fields:

FieldTypeDescription
namestringCase name
base_mvafloatSystem MVA base (default 100.0)
freq_hzfloatSystem frequency in Hz (default 60.0)
buseslistAll buses
brancheslistAll branches (lines and transformers)
generatorslistAll generators
loadslistAll loads
fixed_shuntslistFixed shunt devices
facts_deviceslistFACTS devices (SVC, STATCOM, TCSC)
hvdcobjectHVDC links and DC grids
topologyoptionalNode-breaker topology (from CGMES/XIIDM)
controlsobjectSwitched shunts, OLTCs, PARs
area_scheduleslistArea interchange schedules
interfaceslistTransmission interfaces
flowgateslistMonitored flowgates

Bus

FieldTypeUnitDescription
numberu32Unique bus identifier
namestringHuman-readable name
bus_typeenumPQ, PV, Slack, or Isolated
base_kvfloatkVNominal voltage
voltage_magnitude_pufloatp.u.Initial or solved voltage magnitude
voltage_angle_radfloatradInitial or solved voltage angle
voltage_min_pufloatp.u.OPF lower voltage bound
voltage_max_pufloatp.u.OPF upper voltage bound
shunt_conductance_mwfloatMWFixed shunt G at V = 1.0 p.u.
shunt_susceptance_mvarfloatMVArFixed shunt B at V = 1.0 p.u.
areau32Area number
zoneu32Zone number

Bus types:

  • PQ — Load bus. Active and reactive power are specified; voltage is solved.
  • PV — Generator bus. Active power and voltage magnitude are specified; reactive power is solved within [qmin, qmax]. If the reactive limit is hit, the bus switches to PQ.
  • Slack — Reference bus. Voltage magnitude and angle are specified; active and reactive power are solved to close the system power balance.
  • Isolated — Disconnected bus. Excluded from the solve.

Branch

FieldTypeUnitDescription
from_busu32From-bus number
to_busu32To-bus number
circuitstringCircuit identifier for parallel branches
rfloatp.u.Series resistance
xfloatp.u.Series reactance
bfloatp.u.Total line charging susceptance
tapfloatp.u.Off-nominal turns ratio (1.0 = line or nominal transformer)
phase_shift_radfloatradPhase-shifter angle
rating_a_mvafloatMVALong-term (continuous) thermal rating
rating_b_mvafloatMVAShort-term (emergency) thermal rating
rating_c_mvafloatMVAUltimate emergency thermal rating
in_serviceboolWhether the branch is in service
branch_typeenumLine, Transformer, Transformer3W, SeriesCapacitor, ZeroImpedanceTie
g_magfloatp.u.Magnetizing conductance (transformers)
b_magfloatp.u.Magnetizing susceptance (transformers)

The branch admittance model follows the standard pi-equivalent circuit. For transmission lines, b is the total line charging susceptance (split equally between the two ends). For transformers, tap and phase_shift_rad define the complex turns ratio t = tap * exp(j * phase_shift_rad).

Generator

FieldTypeUnitDescription
idstringStable generator identifier
busu32Bus number
pfloatMWActive power output
qfloatMVArReactive power output
pmaxfloatMWMaximum active power
pminfloatMWMinimum active power (negative for storage charging)
qmaxfloatMVArMaximum reactive power
qminfloatMVArMinimum reactive power
voltage_setpoint_pufloatp.u.Voltage regulation target
machine_base_mvafloatMVAMachine base rating
in_serviceboolWhether the generator is online
gen_typeenumSynchronous, Wind, Solar, InverterOther
costoptionalCost curve for OPF dispatch

Generators with cost data participate in economic dispatch. The cost curve can be polynomial (up to quadratic: c0 + c1*P + c2*P^2 in /hr)orpiecewiselinear(breakpointpairsofMWand/hr) or piecewise-linear (breakpoint pairs of MW and /hr).

Load

FieldTypeUnitDescription
busu32Bus number
idstringLoad identifier
active_power_demand_mwfloatMWActive demand
reactive_power_demand_mvarfloatMVArReactive demand
in_serviceboolWhether the load is connected
zip_p_impedance_fracfloatConstant-impedance P fraction
zip_p_current_fracfloatConstant-current P fraction
zip_p_power_fracfloatConstant-power P fraction (default 1.0)
zip_q_impedance_fracfloatConstant-impedance Q fraction
zip_q_current_fracfloatConstant-current Q fraction
zip_q_power_fracfloatConstant-power Q fraction (default 1.0)

The ZIP model expresses load as a weighted sum of constant-impedance (Z), constant-current (I), and constant-power (P) components. The three fractions for each of P and Q must sum to 1.0. The default is pure constant-power (zip_p_power_frac = 1.0, zip_q_power_frac = 1.0), which is the standard assumption for transmission-level steady-state studies.

Fixed Shunt

FieldTypeUnitDescription
busu32Bus number
idstringShunt identifier
g_mwfloatMWConductance at V = 1.0 p.u.
b_mvarfloatMVArSusceptance at V = 1.0 p.u. (positive = capacitive)
in_serviceboolWhether the shunt is connected

Thermal Ratings

Branches carry three thermal ratings used by different study types:

RatingFieldTypical use
Rate Arating_a_mvaBase-case continuous limit; default for OPF and contingency
Rate Brating_b_mvaShort-term emergency; post-contingency limit in some RTO practices
Rate Crating_c_mvaUltimate emergency; extreme contingency scenarios

A rating of 0.0 means the branch is unconstrained for that tier. When a post-contingency study selects Rate B or Rate C and the value is zero, Surge falls back to Rate A.

Multi-Island Networks

Surge automatically detects electrically disconnected islands. Each island gets its own slack bus and is solved independently. The island_id field on each bus records which island it belongs to after topology processing.