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 — Y-Bus

YBusResult

Dataclass returned by calculate_ybus.

FieldTypeDescription
ybusnp.ndarray or scipy.sparse.csr_matrixComplex admittance matrix
index_to_labellist[tuple[str, str]]Maps integer index → (bus_name, phase)
label_to_indexdict[tuple[str, str], int]Maps (bus_name, phase) → integer index

calculate_ybus

def calculate_ybus(
    system: DistributionSystem,
    *,
    include_neutral: bool = False,
    include_shunt: bool = True,
    include_transformers: bool = True,
    include_regulators: bool = True,
    sparse: bool = False,
    frequency_hz: float = 60.0,
    vbase_override: dict[str, float] | None = None,
    debug: bool = False,
) -> YBusResult:

Build the bus admittance matrix from all branches and transformers in the system.

Parameters:

ParameterDefaultDescription
systemA DistributionSystem instance
include_neutralFalseInclude neutral (N) phase nodes
include_shuntTrueInclude line charging admittance (pi model)
include_transformersTrueInclude transformer admittance stamps
include_regulatorsTrueInclude regulator turns ratio and impedance
sparseFalseReturn scipy.sparse.csr_matrix instead of dense np.ndarray
frequency_hz60.0System frequency for computing shunt susceptance
vbase_overrideNoneOverride nominal voltage bases per bus
debugFalsePrint diagnostic information during construction

Returns: YBusResult

Example:

from gdm.distribution import DistributionSystem
from gdm_flow import calculate_ybus

system = DistributionSystem.from_json("model.json")
result = calculate_ybus(system, sparse=True)

print(f"Matrix shape: {result.ybus.shape}")
print(f"Number of nodes: {len(result.index_to_label)}")