Skip to content

Commit 08fd18d

Browse files
committed
chore: fix calculate line capacity documentations
1 parent c5eb6bc commit 08fd18d

File tree

1 file changed

+67
-40
lines changed

1 file changed

+67
-40
lines changed

src/pownet/core/data_processor.py

Lines changed: 67 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import json
44
import os
5+
import sys
56

67
import networkx as nx
78
import numpy as np
@@ -82,77 +83,103 @@ def load_transmission_data(self) -> None:
8283
].copy()
8384

8485
def calc_stability_limit(
85-
self,
86-
source_kv: int,
87-
sink_kv: int,
88-
distance: float,
89-
n_circuits: int,
90-
) -> float:
91-
"""Calculates the theoretical steady-state stability limit of a transmission line.
86+
self,source_kv: int,sink_kv: int,distance: float, n_circuits: int,
87+
) -> int:
88+
"""Calculates the theoretical steady-state stability limit of the transmission line.
9289
93-
This function uses the fundamental power transfer formula based on total line
94-
reactance, as shown in "Power System Analysis and Design" (Eq. 5.4.27):
90+
This method applies the classical Power Transfer Equation for a lossless line
91+
(Chapter 5 of Power System Analysis and Design, Eq. 5.4.27).
9592
96-
P_max = (V_S * V_R) / X'
93+
Formula:
94+
P_max_circuit = (V_S * V_R) / X_total
9795
98-
where:
99-
P_max is the stability limit in MW.
100-
V_S and V_R are the sending and receiving end voltages in kV.
101-
X' is the total line reactance in ohms.
96+
Where:
97+
P_max_circuit: The maximum Real Power transfer per circuit in MW.
98+
(Assumes Power Factor = 1.0, so MW = MVA).
99+
V_S, V_R: The Line-to-Line voltages at sending and receiving ends in kV.
100+
X_total: The total reactance of the line in Ohms.
101+
Calculated as (Reactance_per_km * distance).
102+
103+
Note on "Perfect Condition":
104+
This calculates the static stability limit (steady-state). Practical operations
105+
typically constrain flow to a safety margin (e.g., 30-45 degrees load angle)
106+
well below this theoretical maximum.
102107
103108
Args:
104109
source_kv (int): Voltage level of the source bus in kV.
105110
sink_kv (int): Voltage level of the sink bus in kV.
106-
distance (float): Distance between the two buses in km.
107-
n_circuits (int): Number of circuits in the transmission line.
111+
distance (float): Length of the transmission line in km.
112+
n_circuits (int): Number of parallel circuits (e.g., 2 for double-circuit).
108113
109114
Returns:
110-
float: The stability limit of the transmission line in MW.
115+
int: The combined stability limit for all circuits in MW.
116+
Returns infinity if distance is 0 (co-located buses).
111117
"""
112-
# Get the reactance per kilometer for the line's voltage level.
118+
# Determine the voltage class to look up line parameters
119+
# Use the higher voltage if they differ to determine line construction
113120
max_kv = max(source_kv, sink_kv)
121+
122+
# Retrieve Reactance per km (Ohms/km) from database
114123
reactance_per_km = self.transmission_params["reactance_ohms_per_km"][max_kv]
115124

116-
# 1. Calculate the TOTAL line reactance.
125+
# 1. Calculate TOTAL line reactance (X_total)
117126
total_reactance = reactance_per_km * distance
118127

119-
# Avoid division by zero for co-located buses (distance = 0).
128+
# Handle co-located buses (Zero Impedance)
120129
if total_reactance == 0:
121-
return float('inf')
130+
return sys.maxsize # Represents infinity
122131

123-
# 2. Calculate the stability limit per circuit.
124-
# The result is in MW because (kV * kV) / ohms = MVA. We assume a
125-
# power factor of 1 (MW = MVA).
132+
# 2. Calculate stability limit per circuit (MW)
133+
# P = (kV * kV) / Ohms = MW
126134
stability_limit_per_circuit = (source_kv * sink_kv) / total_reactance
127135

128-
# 3. Return the total limit for all circuits.
136+
# 3. Return total limit sum for all parallel circuits
129137
return int(n_circuits * stability_limit_per_circuit)
130138

131139
def calc_thermal_limit(
132140
self, source_kv: int, sink_kv: int, n_circuits: int
133-
) -> float:
134-
"""From Chapter 5 of Power System Analysis and Design 5th. See Example 5.6b.
135-
The full-load current at 1 per-unit factor is
141+
) -> int:
142+
"""Calculates the thermal rating (MVA) of the transmission line based on
143+
conductor ampacity (Chapter 5 of Power System Analysis and Design 5th
144+
See Example 5.6b).
145+
146+
Let 'n_conductors' parameter in 'transmission_params' represents the number
147+
of sub-conductors per phase (bundling factor).
136148
137-
I = P/(sqrt(3) * V)
149+
Formula:
150+
S_thermal = sqrt(3) * V_line_LL * I_phase_max
138151
139-
Here, P is the surge impedance factor (SIL) and V is the voltage of the
140-
receiving bus. This voltage is the minimum voltage between the two ends.
152+
Where:
153+
S_thermal: The total Apparent Power capacity of the circuit in MVA.
154+
(Note: S_thermal = P_real_power only when Power Factor = 1.0)
155+
V_line_LL: The Line-to-Line voltage in kV (the standard voltage rating, e.g., 115 kV).
156+
I_phase_max: The maximum current capacity per phase in kilo-Amps (kA).
157+
Calculated as (Ampacity per wire * Bundling Factor).
141158
142159
Args:
143-
source_kv (int): Voltage level of the source bus
144-
sink_kv (int): Voltage level of the sink bus
145-
n_circuits (int): Number of circuits in the transmission line
160+
source_kv (int): Voltage level of the source bus (kV).
161+
sink_kv (int): Voltage level of the sink bus (kV).
162+
n_circuits (int): Number of distinct circuits (e.g., double circuit tower = 2).
146163
147164
Returns:
148-
float: The thermal limit of the transmission line in MW
165+
int: The maximum thermal capacity in MVA.
149166
"""
150167
max_kv = max(source_kv, sink_kv)
151-
n_conductors = self.transmission_params["n_conductors"][max_kv]
152-
# in Amps
153-
current_capacity = self.transmission_params["current_capacity_amps"][max_kv]
154-
total_current_capacity = n_conductors * current_capacity / 1000 # in kilo-A
155-
thermal_limit_per_circuit = total_current_capacity * np.sqrt(3) * max_kv
168+
169+
# Retrieve bundle size (e.g., 1 for 115kV, 2 for 345kV)
170+
# This is the count of sub-conductors per phase.
171+
n_conductors_per_phase = self.transmission_params["n_conductors"][max_kv]
172+
173+
# Ampacity per individual sub-conductor wire (in Amps)
174+
current_capacity_amps = self.transmission_params["current_capacity_amps"][max_kv]
175+
176+
# Calculate total current capacity per phase in kilo-Amps (kA)
177+
total_current_capacity_kA = (n_conductors_per_phase * current_capacity_amps) / 1000
178+
179+
# Calculate 3-Phase Power Capacity per circuit
180+
# S = sqrt(3) * V_LL * I_Line
181+
thermal_limit_per_circuit = np.sqrt(3) * max_kv * total_current_capacity_kA
182+
156183
return int(n_circuits * thermal_limit_per_circuit)
157184

158185
def calc_line_capacity(self) -> None:

0 commit comments

Comments
 (0)