Fault sweep — earthing impedance and reduction factors per bus¶
When the fault location is not known a priori, a common analysis is to
sweep the fault across every candidate bus and read off the earthing
impedance $Z_E$ and the reduction factors at each fault site. This notebook
demonstrates that workflow on a 10-bus MV cable line and visualises the
results with Network.res_all_impedances().
Steps:
- Build a 10-bus MV cable line at five frequencies (50, 250, 350, 450, 550 Hz).
- Create one fault per bus, plus a single source at
bus01. - Loop
gi.run_faultover every fault. - Read the long-format DataFrame returned by
res_all_impedances(). - Plot $|Z_E|$ and both reduction factors per fault bus and frequency.
import warnings
import numpy as np
import polars as pl
import matplotlib.pyplot as plt
import groundinsight as gi
print("groundinsight", gi.__version__)
groundinsight 2026.11.1
1. Bus and branch types¶
Illustrative MV cable values: a shield-earth loop of $0.25 + j0.6\ \Omega$/km at 50 Hz whose reactance and the mutual reactance both grow with frequency. The cable has full mutual coupling ($\mathrm{Im}\,Z_\text{self} = \mathrm{Im}\,Z_\text{mutual}$), so its reduction factor at 50 Hz is $|1 - Z_\text{mutual}/Z_\text{self}| = 0.25/|0.25 + j0.6| = 0.384615$. Every station has an electrode of 1 Ω.
rho = 100.0 # specific earth resistivity in Ohm*m
bus_type = gi.BusType(
name="BusUnit",
description="Unit-like bus impedance, dominated by cable shield path",
system_type="Grounded",
voltage_level=20.0,
impedance_formula="rho * 0 + 1.0 + I * f * 0",
)
cable_type = gi.BranchType(
name="MSCable",
description="MV cable with shield (constant L, M)",
grounding_conductor=True,
self_impedance_formula="(0.25 + I * 0.6 * f / 50) * l",
mutual_impedance_formula="(0.0 + I * 0.6 * f / 50) * l",
)
2. Build a 10-bus line¶
Source at bus01, one fault definition at every bus. Each fault re-uses the
same source; run_fault solves one fault at a time.
FREQS = [50.0, 250.0, 350.0, 450.0, 550.0]
N_BUS = 10
LINE_LENGTH_KM = 0.5 # km per section
net = gi.create_network(name="FaultSweep", frequencies=FREQS,
description="10-bus MV cable line, fault sweep demo")
for i in range(1, N_BUS + 1):
gi.create_bus(name=f"bus{i:02d}", type=bus_type, network=net,
specific_earth_resistance=rho)
for i in range(1, N_BUS):
gi.create_branch(
name=f"b{i:02d}_{i+1:02d}",
type=cable_type,
from_bus=f"bus{i:02d}",
to_bus=f"bus{i+1:02d}",
length=LINE_LENGTH_KM,
specific_earth_resistance=rho,
network=net,
)
gi.create_source(name="src", bus="bus01", values={f: 1000.0 for f in FREQS}, network=net)
for i in range(1, N_BUS + 1):
gi.create_fault(name=f"f{i:02d}", bus=f"bus{i:02d}", network=net)
print(f"{len(net.buses)} buses, {len(net.branches)} branches, "
f"{len(net.faults)} faults, {len(net.frequencies)} frequencies")
10 buses, 9 branches, 10 faults, 5 frequencies
3. Run the sweep¶
One gi.run_fault call per fault location. The fault at bus01 sits on the
source bus itself: the source current enters and leaves the earthing system at
the same bus, no current flows through the network, and both reduction factors
are undefined there — res_all_impedances emits null for them. The earthing
impedance is a property of the network at the fault bus and is defined there
as well.
Seven of the ten fault locations add EARTH_GROUP_SPREAD to their
diagnostics: the electrode currents of the stations point in clearly
different directions, so the earth current $I_E$ and the reduction factor on
a current basis describe the dominant direction only
(Reduction factor on a current basis).
diagnostics = {}
with warnings.catch_warnings():
warnings.simplefilter("ignore", gi.ModelAssumptionWarning) # kept in result.diagnostics
for i in range(1, N_BUS + 1):
result = gi.run_fault(net, fault=f"f{i:02d}")
diagnostics[result.fault] = sorted({d.code for d in result.diagnostics})
print("diagnostics:", {fault: codes for fault, codes in diagnostics.items() if codes})
impedance_df = net.res_all_impedances()
impedance_df.filter(pl.col("frequency_Hz") == 50.0)
diagnostics: {'f01': ['FAULT_AT_FEEDING_BUS'], 'f03': ['EARTH_GROUP_SPREAD'], 'f05': ['EARTH_GROUP_SPREAD'], 'f06': ['EARTH_GROUP_SPREAD'], 'f07': ['EARTH_GROUP_SPREAD'], 'f08': ['EARTH_GROUP_SPREAD'], 'f09': ['EARTH_GROUP_SPREAD'], 'f10': ['EARTH_GROUP_SPREAD']}
| fault_name | fault_bus | frequency_Hz | grounding_impedance_Ohm | grounding_impedance_deg | reduction_factor | reduction_factor_current |
|---|---|---|---|---|---|---|
| str | str | f64 | f64 | f64 | f64 | f64 |
| "f01" | "bus01" | 50.0 | 0.449527 | 24.849157 | null | null |
| "f02" | "bus02" | 50.0 | 0.325323 | 22.104718 | 0.384615 | 0.078871 |
| "f03" | "bus03" | 50.0 | 0.282231 | 26.372095 | 0.384615 | 0.15294 |
| "f04" | "bus04" | 50.0 | 0.274513 | 29.961539 | 0.384615 | 0.215082 |
| "f05" | "bus05" | 50.0 | 0.275286 | 31.402783 | 0.384615 | 0.269796 |
| "f06" | "bus06" | 50.0 | 0.275286 | 31.402783 | 0.384615 | 0.308884 |
| "f07" | "bus07" | 50.0 | 0.274513 | 29.961539 | 0.384615 | 0.340709 |
| "f08" | "bus08" | 50.0 | 0.282231 | 26.372095 | 0.384615 | 0.363236 |
| "f09" | "bus09" | 50.0 | 0.325323 | 22.104718 | 0.384615 | 0.379426 |
| "f10" | "bus10" | 50.0 | 0.449527 | 24.849157 | 0.384615 | 0.389328 |
4. Slice and pivot¶
res_all_impedances() returns one row per (fault, frequency). To plot the
sweep we pivot it to one row per fault bus and one column per frequency.
def wide(column):
return impedance_df.pivot(values=column, index="fault_bus", on="frequency_Hz").sort("fault_bus")
ze_wide = wide("grounding_impedance_Ohm")
r_epr_wide = wide("reduction_factor")
r_wide = wide("reduction_factor_current")
print("--- |Z_E| per fault bus ---")
print(ze_wide)
print("\n--- EPR ratio per fault bus ---")
print(r_epr_wide)
print("\n--- EN 50522 reduction factor per fault bus ---")
print(r_wide)
--- |Z_E| per fault bus --- shape: (10, 6) ┌───────────┬──────────┬──────────┬──────────┬──────────┬──────────┐ │ fault_bus ┆ 50.0 ┆ 250.0 ┆ 350.0 ┆ 450.0 ┆ 550.0 │ │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │ │ str ┆ f64 ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ ╞═══════════╪══════════╪══════════╪══════════╪══════════╪══════════╡ │ bus01 ┆ 0.449527 ┆ 0.767392 ┆ 0.832287 ┆ 0.874608 ┆ 0.903522 │ │ bus02 ┆ 0.325323 ┆ 0.562936 ┆ 0.652888 ┆ 0.723998 ┆ 0.778718 │ │ bus03 ┆ 0.282231 ┆ 0.581457 ┆ 0.673454 ┆ 0.74069 ┆ 0.791043 │ │ bus04 ┆ 0.274513 ┆ 0.586093 ┆ 0.674438 ┆ 0.740526 ┆ 0.790681 │ │ bus05 ┆ 0.275286 ┆ 0.585693 ┆ 0.674149 ┆ 0.740429 ┆ 0.790657 │ │ bus06 ┆ 0.275286 ┆ 0.585693 ┆ 0.674149 ┆ 0.740429 ┆ 0.790657 │ │ bus07 ┆ 0.274513 ┆ 0.586093 ┆ 0.674438 ┆ 0.740526 ┆ 0.790681 │ │ bus08 ┆ 0.282231 ┆ 0.581457 ┆ 0.673454 ┆ 0.74069 ┆ 0.791043 │ │ bus09 ┆ 0.325323 ┆ 0.562936 ┆ 0.652888 ┆ 0.723998 ┆ 0.778718 │ │ bus10 ┆ 0.449527 ┆ 0.767392 ┆ 0.832287 ┆ 0.874608 ┆ 0.903522 │ └───────────┴──────────┴──────────┴──────────┴──────────┴──────────┘ --- EPR ratio per fault bus --- shape: (10, 6) ┌───────────┬──────────┬──────────┬──────────┬──────────┬──────────┐ │ fault_bus ┆ 50.0 ┆ 250.0 ┆ 350.0 ┆ 450.0 ┆ 550.0 │ │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │ │ str ┆ f64 ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ ╞═══════════╪══════════╪══════════╪══════════╪══════════╪══════════╡ │ bus01 ┆ null ┆ null ┆ null ┆ null ┆ null │ │ bus02 ┆ 0.384615 ┆ 0.083045 ┆ 0.059419 ┆ 0.046247 ┆ 0.037852 │ │ bus03 ┆ 0.384615 ┆ 0.083045 ┆ 0.059419 ┆ 0.046247 ┆ 0.037852 │ │ bus04 ┆ 0.384615 ┆ 0.083045 ┆ 0.059419 ┆ 0.046247 ┆ 0.037852 │ │ bus05 ┆ 0.384615 ┆ 0.083045 ┆ 0.059419 ┆ 0.046247 ┆ 0.037852 │ │ bus06 ┆ 0.384615 ┆ 0.083045 ┆ 0.059419 ┆ 0.046247 ┆ 0.037852 │ │ bus07 ┆ 0.384615 ┆ 0.083045 ┆ 0.059419 ┆ 0.046247 ┆ 0.037852 │ │ bus08 ┆ 0.384615 ┆ 0.083045 ┆ 0.059419 ┆ 0.046247 ┆ 0.037852 │ │ bus09 ┆ 0.384615 ┆ 0.083045 ┆ 0.059419 ┆ 0.046247 ┆ 0.037852 │ │ bus10 ┆ 0.384615 ┆ 0.083045 ┆ 0.059419 ┆ 0.046247 ┆ 0.037852 │ └───────────┴──────────┴──────────┴──────────┴──────────┴──────────┘ --- EN 50522 reduction factor per fault bus --- shape: (10, 6) ┌───────────┬──────────┬──────────┬──────────┬──────────┬──────────┐ │ fault_bus ┆ 50.0 ┆ 250.0 ┆ 350.0 ┆ 450.0 ┆ 550.0 │ │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │ │ str ┆ f64 ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ ╞═══════════╪══════════╪══════════╪══════════╪══════════╪══════════╡ │ bus01 ┆ null ┆ null ┆ null ┆ null ┆ null │ │ bus02 ┆ 0.078871 ┆ 0.05094 ┆ 0.0425 ┆ 0.036564 ┆ 0.031921 │ │ bus03 ┆ 0.15294 ┆ 0.069071 ┆ 0.052721 ┆ 0.043374 ┆ 0.036547 │ │ bus04 ┆ 0.215082 ┆ 0.085926 ┆ 0.063426 ┆ 0.049836 ┆ 0.040863 │ │ bus05 ┆ 0.269796 ┆ 0.088582 ┆ 0.063994 ┆ 0.04957 ┆ 0.040429 │ │ bus06 ┆ 0.308884 ┆ 0.090795 ┆ 0.064061 ┆ 0.048921 ┆ 0.039977 │ │ bus07 ┆ 0.340709 ┆ 0.089482 ┆ 0.063133 ┆ 0.048705 ┆ 0.040238 │ │ bus08 ┆ 0.363236 ┆ 0.086928 ┆ 0.061668 ┆ 0.049196 ┆ 0.040623 │ │ bus09 ┆ 0.379426 ┆ 0.086656 ┆ 0.061981 ┆ 0.048505 ┆ 0.03985 │ │ bus10 ┆ 0.389328 ┆ 0.08871 ┆ 0.063263 ┆ 0.049593 ┆ 0.04045 │ └───────────┴──────────┴──────────┴──────────┴──────────┴──────────┘
5. A second way to $Z_E$¶
$Z_E$ is the driving-point impedance of the earthing network at the fault bus.
gi.bus_response computes, from two solves, the impedance $Z_\text{net}$ that
the rest of the network offers at a bus; in parallel with the bus's own
electrode (1 Ω) it must give $Z_E$.
response = gi.bus_response(net, fault="f05", bus="bus05")
z_net = response.z_network[50.0]
z_e_second_way = 1.0 / (1.0 / 1.0 + 1.0 / z_net)
z_e_sweep = impedance_df.filter(
(pl.col("fault_name") == "f05") & (pl.col("frequency_Hz") == 50.0)
)["grounding_impedance_Ohm"][0]
print(f"|Z_E| at bus05, 50 Hz: sweep {z_e_sweep:.6f} ohm, bus_response {abs(z_e_second_way):.6f} ohm")
|Z_E| at bus05, 50 Hz: sweep 0.275286 ohm, bus_response 0.275286 ohm
6. Visualisation¶
Grouped bar plots: one bar per frequency at each fault bus.
fault_buses = ze_wide["fault_bus"].to_list()
x = np.arange(len(fault_buses))
width = 0.16
fig, axes = plt.subplots(3, 1, figsize=(10, 10), sharex=True)
panels = [
(axes[0], ze_wide, "|Z_E| / Ohm", "Earthing impedance at the fault bus"),
(axes[1], r_epr_wide, "EPR ratio", "EPR ratio (reduction factor of the cable)"),
(axes[2], r_wide, "r", "Reduction factor of EN 50522, |I_E| / |3I_0|"),
]
for ax, frame, ylabel, title in panels:
for k, f in enumerate(FREQS):
values = [np.nan if v is None else v for v in frame[str(f)].to_list()]
ax.bar(x + (k - (len(FREQS) - 1) / 2) * width, values, width=width, label=f"{int(f)} Hz")
ax.set_ylabel(ylabel)
ax.set_title(title)
ax.grid(True, axis="y", alpha=0.3)
axes[0].legend(ncol=len(FREQS), loc="upper center", fontsize=9)
axes[2].set_xlabel("Fault bus (1 kA injected at bus01)")
axes[2].set_xticks(x)
axes[2].set_xticklabels(fault_buses, rotation=30, ha="right")
fig.tight_layout()
plt.show()
7. Profile interpretation¶
- $|Z_E|$ is symmetric about the middle of the line. It is the impedance of the earthing network seen from the fault bus — all electrodes in parallel through the shields — and does not depend on where the source is. The two end stations have bonded neighbours on one side only and show the highest value; inside the line it is nearly constant.
- The EPR ratio is the same at every fault location at a given frequency: every section is the same cable, so it is $|1 - Z_m/Z_s|$ of the cable, 0.384615 at 50 Hz. It falls with frequency, because the shield reactance grows while its resistance stays — to below 0.05 at 550 Hz.
- The reduction factor of EN 50522 depends on the position. Close to
the infeed the shield back to it is short and carries almost all of the
return current; the farther away the fault, the longer that path and the
more current takes the soil. At 50 Hz it grows from 0.079 at
bus02to 0.389 atbus10; at the harmonics, where the shield reactance dominates, it levels off after a few stations close to the EPR ratio of that frequency. It is the factor that responds to the electrodes and the position; the EPR ratio describes the cable.
The wide DataFrames can be exported to CSV or Excel directly via
polars.DataFrame.write_csv / write_excel for downstream reporting.
Reduction factors and earthing impedance
explains the two factors.