A comprehensive power system analysis package written in Julia, featuring Newton-Raphson power flow analysis, generator capability modeling, and advanced visualization capabilities.
JuliaPowerFlow/
├── src/ # Source code
│ └── JuliaPowerFlow.jl # Main module
├── data/ # Test case data
│ └── case9.jl # IEEE 9-bus system
├── algorithms/ # Core algorithms
│ └── power_flow.jl # Newton-Raphson power flow
├── visualization/ # Visualization tools
│ └── power_flow_visualization.jl
├── examples/ # Usage examples
│ ├── usage_example.jl # Main usage demonstration
│ └── basic_newton_raphson.jl # Newton-Raphson examples
├── tests/ # Test suite
│ └── test_all_functions.jl # Comprehensive tests
├── docs/ # Documentation
│ └── static_generator.md # Generator modeling docs
├── Project.toml # Package configuration
└── README.md # This file
- Load the package:
push!(LOAD_PATH, "src")
using JuliaPowerFlow- Run power flow analysis:
case_data = case9()
V, S, Sf, St = run_power_flow(case_data)- Create power system components:
sys = PowerSystem(100.0) # 100 MVA base
bus = Bus(1, bus_type=SLACK_BUS, voltage_magnitude=1.04)
gen = Generator(1, 1, p_max=250.0, s_max=300.0)
add_component!(sys, bus)
add_component!(sys, gen)- Newton-Raphson solver with automatic convergence monitoring
- Support for PV, PQ, and slack buses
- Line flow calculations and loss analysis
- Comprehensive result visualization
- Cylindrical rotor synchronous machine constraints
- P-Q capability region analysis
- Dynamic Q_min calculation based on power angle limits
- Generator capability curve visualization
- Interactive power flow convergence plots
- Generator capability curve plotting
- System topology visualization
- Jacobian matrix heatmaps with animation
- IEEE 9-bus standard test system
- Modular component-based system building
- Extensible framework for custom test cases
# Load IEEE 9-bus system
case_data = case9()
# Run power flow analysis
V, S, Sf, St = run_power_flow(case_data)
# Run with visualization
V, S, Sf, St = run_power_flow_with_visualization(case_data)# Create generator
gen = Generator(1, 1, p_max=250.0, q_max=100.0, s_max=300.0)
# Test operating point
valid, msg = check_capability_constraints(gen, 200.0, 80.0)
# Calculate Q_min as function of P
q_min = calculate_qmin_function(gen, 150.0)# Create system
sys = PowerSystem(100.0)
# Add components
add_component!(sys, Bus(1, bus_type=SLACK_BUS))
add_component!(sys, Generator(1, 1, p_max=100.0))
add_component!(sys, Branch(1, 1, 2, reactance=0.1))
# Get system information
println("Buses: $(get_bus_count(sys))")# Run comprehensive test suite
include("tests/test_all_functions.jl")
# Run specific examples
include("examples/basic_newton_raphson.jl")
include("examples/usage_example.jl")- Generator Modeling: See
docs/static_generator.mdfor detailed mathematical formulation - API Reference: All functions include comprehensive docstrings
- Examples: Check
examples/directory for usage demonstrations
The package is organized into modular components:
- Algorithms: Core computational methods
- Data: Test case definitions and system data
- Visualization: Plotting and animation tools
- Examples: Demonstration scripts
- Tests: Validation and verification
- LinearAlgebra.jl
- SparseArrays.jl
- Plots.jl
- Printf.jl
- Statistics.jl
- ColorSchemes.jl
This project is developed for educational and research purposes.
Contributions are welcome! Please feel free to submit issues or pull requests.