INDEX
CONTENTS PAGE NO
1. INTRODUCTION 5
2. OBJECTIVE 5
3. POWER FLOW ANALYSIS 6
4. SHORT CIRCUIT FAULT ANALYSIS 7
5. VOLTAGE STABILITY ANALYSIS 10
6. LOAD SHEDDING STRATERGY 12
7. CONCLUSION 13
Power Systems Analysis using Python Libraries
1. Introduction
Power system analysis is a critical electrical engineering discipline leveraging Python libraries
like pandapower to comprehensively evaluate network performance. By integrating advanced
computational techniques, engineers can conduct power flow simulations, assess short-circuit
fault conditions, analyze voltage stability, and develop strategic load management approaches.
Through systematic modeling and computational analysis, power system engineers can
optimize infrastructure reliability, predict potential failure modes, enhance operational
efficiency, and ensure safe, stable electrical network performance. The multifaceted approach
enables proactive decision-making, infrastructure planning, and risk mitigation in complex
electrical distribution systems. Python's robust libraries transform sophisticated power system
analysis from theoretical concepts into practical, actionable engineering insights, bridging
theoretical knowledge with real-world implementation strategies.
2. Objective:
The primary objective of power system analysis using Python and Pandapower is to
comprehensively evaluate electrical network performance through advanced computational
techniques. By implementing power flow, fault analysis, voltage stability, and load
management studies, engineers can assess system reliability, predict potential vulnerabilities,
and optimize infrastructure design. These analytical methods enable proactive decision-
making, risk mitigation, and efficient power network management across various operational
scenarios.
1. Power Flow Analysis
o Determine voltage, current, and power distribution
o Assess system stability and performance
o Evaluate network operating conditions
2. Fault Analysis
o Identify short-circuit scenarios
o Calculate fault currents and potential system impacts
o Design protective equipment and safety measures
3. Voltage Stability Assessment
o Evaluate system's ability to maintain voltage levels
o Predict voltage collapse conditions
o Determine maximum power transfer capabilities
4. Load Management
o Analyze load distribution and network capacity
o Optimize power allocation
3. Power Flow Analysis
3.1 Explanation
Power flow (or load flow) analysis is fundamental in determining voltage magnitudes, angles,
active and reactive power flows within a power network. It helps ensure the stability and
efficiency of power distribution.
This single line diagram shows all the key components of your power system:
1. External Grid (left side):
o Connected to Bus 1
o Operating at 1.02 p.u. voltage
2. Bus 1 (Grid Bus):
o Voltage level: 110 kV
o Connection point for external grid
3. Transmission Line:
o Connects Bus 1 to Bus 2
o Length: 1.0 km
o Type: NAYY 4x50 SE cable
4. Bus 2 (Load Bus):
o Voltage level: 110 kV
o Connection point for load
5. Load (bottom right):
o Active power (P): 10 MW
o Reactive power (Q): 5 MVAr
The diagram follows standard electrical notation:
• Buses are represented by dots with voltage levels
• The zigzag symbol represents the transmission line
• The arrow-like symbol at the bottom represents the load
• The external grid is shown with the typical grid connection symbol
3.2 Code for Power Flow Analysis
import pandapower as pp
# Create an empty power network
net = pp.create_empty_network()
# Create buses
bus1 = pp.create_bus(net, vn_kv=110, name="Grid Bus")
bus2 = pp.create_bus(net, vn_kv=110, name="Load Bus")
# Add external grid to Bus 1
pp.create_ext_grid(net, bus=bus1, vm_pu=1.02, name="Grid Connection")
# Add a line between Bus 1 and Bus 2
pp.create_line(net, bus1, bus2, length_km=1.0, std_type="NAYY 4x50 SE",
name="Transmission Line")
# Add a load to Bus 2
pp.create_load(net, bus=bus2, p_mw=10, q_mvar=5, name="Load")
# Run power flow
pp.runpp(net)
print("Load Data:\n", net.load)
print("Line Results:\n", net.res_line)
# Print results
print("Bus Results:\n", net.res_bus)
3.3 Output
Bus Results:
vm_pu va_degree p_mw q_mvar
0 1.020000 0.000000 -10.006179 -4.170718
1 1.019449 0.009625 10.000000 5.000000
4. Short-Circuit Fault Analysis
4.1 Explanation
Short-circuit analysis determines the fault currents at different buses, which is crucial for the
design of protective devices.
This single line diagram shows all components of your power system with both power flow
and short circuit analysis parameters:
1. External Grid (Left):
o Voltage level: 110 kV
o Operating voltage: 1.02 p.u.
o Short circuit power: 500 MVA
o R/X ratio: 0.1
2. Bus 1 (Grid Bus):
o Operating at 110 kV
o Connection point for external grid
o Serves as the slack bus for power flow calculations
3. Transmission Line:
o Length: 10 km
o Type: NAYY 4x50 SE cable and Connects Bus 1 to Bus 2
4. Bus 2 (Load Bus):
o Operating at 110 kV
o Load connection point and Short circuit analysis point (indicated by dashed
red circle)
5. Load:
o Active power (P): 10 MW
o Reactive power (Q): 5 MVAr
Key Features:
• The diagram includes short circuit parameters for fault analysis
• Fault point is indicated at Bus 2 with a dashed red circle
• Clear legend explaining all symbols
• Detailed parameter boxes for both grid and line characteristics
The diagram follows standard electrical notation and color coding:
• Black for main power components
• Blue for grid parameters
• Orange for line parameters
• Red for fault indicators
4.2 Code for Short Circuit Analysis
import pandapower as pp
import pandapower.shortcircuit as sc
# Step 1: Create an empty network
net = pp.create_empty_network()
# Step 2: Create buses
bus1 = pp.create_bus(net, vn_kv=110, name="Grid Bus")
bus2 = pp.create_bus(net, vn_kv=110, name="Load Bus")
# Step 3: Add an external grid (Slack Bus)
pp.create_ext_grid(net, bus=bus1, vm_pu=1.02, s_sc_max_mva=500, rx_max=0.1,
name="Grid Connection")
# Step 4: Add a transmission line
pp.create_line(net, from_bus=bus1, to_bus=bus2, length_km=10, std_type="NAYY 4x50
SE", name="Transmission Line")
# Step 5: Add a load at Bus 2
pp.create_load(net, bus=bus2, p_mw=10, q_mvar=5, name="Load")
# Step 6: Run Power Flow Analysis
pp.runpp(net)
print("\n Power Flow Results (Bus Voltages):")
print(net.res_bus)
# Step 7: Set Short-Circuit Calculation Parameters
net.ext_grid["s_sc_max_mva"] = 500 # Short circuit power (MVA)
net.ext_grid["rx_max"] = 0.1 # R/X ratio of external grid
# Step 8: Run Short-Circuit Analysis
sc.calc_sc(net)
# Step 9: Print Short-Circuit Results
print("\n Short-Circuit Results (Fault Currents in kA):")
print(net.res_bus_sc)
4.3 Output
Short-Circuit Results (Fault Currents in kA):
ikss_ka skss_mw rk_ohm xk_ohm
0 2.624319 500.000000 2.648789 26.48789
1 2.427034 462.412074 9.068789 27.31789
5. Voltage Stability Analysis
5.1 Explanation
Voltage stability ensures that the system maintains acceptable voltage levels under varying load
conditions. The P-V curve is a commonly used method for this analysis.
Real-World Example: Let's say this is an industrial park with:
1. An automotive manufacturing plant
2. Several smaller factories
3. Planning to add new facilities
What The Code Does:
1. Initial Setup:
o Connects to main grid (110 kV)
o Has a 1 km transmission line
o Starting load: 10 MW (current factories)
2. Voltage Stability Analysis:
o Gradually increases load (like adding new factories)
o Monitors voltage at the industrial park
o Determines when voltage becomes unstable.
o
Practical Applications:
1. Expansion Planning:
o Example: If a new facility needs 20 MW:
o Initial load: 10 MW
o New total: 30 MW
o Analysis shows: Safe up to 45 MW
o Conclusion: Expansion is feasible
2. Safety Limits:
o Maximum safe power consumption
o Warning points for operators Example: System operators should:
o Monitor closely above 40 MW
o Take action if voltage drops below 0.9 p.u.
o Have emergency plans ready at 50 MW
3. Investment Planning:
o When to upgrade infrastructure
o What improvements are needed Example: Analysis shows:
o Current limit: 45 MW
o Future needs: 60 MW
o Solution: Need voltage support equipment
Key Findings From P-V Curve:
1. Safe Operation Zone:
o 0-45 MW: Normal operation
o Voltage stays above 0.9 p.u.
o No special measures needed
2. Warning Zone:
o 45-60 MW: Careful monitoring required
o Voltage becoming unstable
o Have contingency plans ready
3. Critical Zone:
o Above 60 MW: Risk of voltage collapse
o System cannot operate safely
o Must prevent reaching this point
Practical Uses:
1. Operations Planning:
o Setting load limits
o Defining operating procedures
o Training operators
2. Emergency Response:
o Identifying critical points
o Setting alarm thresholds
o Planning load shedding steps
5.2 Code for Voltage Stability (P-V Curve)
import numpy as np
import matplotlib.pyplot as plt
loads = np.linspace(5, 20, 10) # Increase load gradually
voltages = []
for load in loads:
net.load.p_mw = load # Increase load demand
pp.runpp(net)
voltages.append(net.res_bus.vm_pu.values[1])
plt.plot(loads, voltages, marker='o')
plt.xlabel("Load (MW)")
plt.ylabel("Voltage (p.u.)")
plt.title("P-V Curve")
plt.grid()
plt.show()
5.3 Output
A P-V curve will be generated, showing the relationship between load and voltage.
6. Load Shedding Strategy
6.1 Explanation
Load shedding prevents system instability by disconnecting non-essential loads when voltage
drops below a certain threshold.
6.2 Code for Load Shedding
import pandapower as pp
import matplotlib.pyplot as plt
import numpy as np
# Create an empty network
net = pp.create_empty_network()
# Create buses
bus1 = pp.create_bus(net, vn_kv=110, name="Grid bus")
bus2 = pp.create_bus(net, vn_kv=110, name="Load bus")
# Add an external grid connection
pp.create_ext_grid(net, bus=bus1, vm_pu=1.02, name="Grid connection")
# Create a transmission line
pp.create_line(net, bus1, bus2, length_km=1.0, std_type="NAYY 4x50 SE",
name="Transmission Line")
# Add load
load = pp.create_load(net, bus=bus2, p_mw=10, q_mvar=5, name="Load")
# Function for load shedding
def load_shedding(voltage_threshold=0.9, load_shedding_percentage=0.1):
"""
Perform load shedding based on the voltage threshold.
If voltage falls below the threshold, shed a percentage of the load.
Parameters:
voltage_threshold (float): Voltage threshold to trigger load shedding.
load_shedding_percentage (float): Percentage of load to shed (between 0 and 1).
"""
if net.res_bus.vm_pu[bus2] < voltage_threshold:
# Calculate the load to shed
load_to_shed = net.load.p_mw[load] * load_shedding_percentage
# Reduce load
net.load.p_mw[load] -= load_to_shed
print(f"Voltage below {voltage_threshold} p.u. - shedding {load_to_shed} MW of
load.")
else:
print(f"Voltage above {voltage_threshold} p.u. - no load shedding.")
# Run initial power flow
pp.runpp(net)
# Print initial voltage at load bus
print("Initial voltage at load bus:", net.res_bus.vm_pu[1])
# Array for storing voltages after load shedding
voltages = []
# Array for load variation
loads = np.arange(10, 100, 5)
# Loop over loads and perform power flow calculation with load shedding
for load_value in loads:
net.load.p_mw[load] = load_value # Update the load value
try:
pp.runpp(net) # Run power flow with the updated load
# Check for load shedding
load_shedding(voltage_threshold=0.9, load_shedding_percentage=0.2)
# Trigger load shedding if voltage < 0.9 p.u.
voltages.append(net.res_bus.vm_pu[bus2]) # Store voltage at load bus
except:
voltages.append(np.nan) # In case power flow does not converge
# Plot the P-V curve after load shedding
plt.figure(figsize=(8, 5))
plt.plot(loads, voltages, marker="o", linestyle="-", color="b", label="Load bus voltage")
plt.xlabel("Active Power (MW)")
plt.ylabel("Voltage (p.u.)")
plt.title("P-V Curve with Load Shedding")
plt.axhline(y=0.9, color="r", linestyle="--", label="Voltage Limit (0.9 p.u.)")
plt.legend()
plt.grid(True)
plt.show()
6.3 Output
Load at Bus 1 is shedding due to low voltage.
7. Conclusion
Power system analysis is a sophisticated engineering discipline that leverages Python libraries
like pandapower to model and simulate complex electrical networks. These tools enable
comprehensive evaluations including power flow calculations, short-circuit fault detection,
voltage stability assessments, and load management strategies. By providing computational
techniques for network modeling, engineers can predict system performance, identify potential
vulnerabilities, and optimize infrastructure reliability. Python's integration of advanced
analytical libraries transforms theoretical power system concepts into practical, actionable
insights. The systematic approach facilitates proactive decision-making, infrastructure
planning, and risk mitigation in electrical distribution systems. Such computational methods
are crucial for maintaining safe, efficient, and resilient power networks in an increasingly
complex energy landscape.