Examples¶
The examples below demonstrate PyPSA's capabilities for energy system modeling. They cover a broad range of topics, including electricity markets, linear optimal power flow, unit commitment, capacity expansion, grid modelling, and more.
Operational Problems¶
-
Electricity Market
Demonstrates basic electricity market modeling with with multiple bidding zones, renewables and storage.
-
Demand and Supply Bids
Demonstrates market-clearing with supply and demand bids in single and two-zone configurations.
-
Unit Commitment
Models generator unit commitment with start-up and shut-down costs, ramping limits, minimum part loads, up and down times using binary variables.
-
Negative Prices in Linearized UC
Shows how negative electricity prices emerge from linearized unit commitment constraints due to the trade-off between cycling costs and operating at minimum load.
-
Meshed AC-DC Networks
Builds a stylized 3-node AC network coupled via AC-DC converters to a 3-node DC network.
-
SciGRID Network
Performs linear optimal power flow on a high-resolution German grid model to analyze power flows and nodal prices.
-
Security-Constrained LOPF
Implements N-1 security constraints in linear optimal power flow models to ensure grid reliability under line outage events.
-
Newton-Raphson Power Flow
Solves non-linear AC power flow equations using the Newton-Raphson method to inspect voltage magnitudes and angles.
-
Negative LMPs from Line Congestion
Explores how Kirchhoff's Voltage Law can lead to negative locational marginal prices when lines are congested.
-
Rolling-Horizon Optimization
Explores how rolling-horizon optimization can be used to account for imperfect forecast horizons in reality.
-
Water Values
Explores how water values, the marginal values of stored energy, can improve seasonal storage operation in rolling-horizon optimization.
Planning Problems¶
-
Single-Node Capacity Expansion
Models investment decisions for generation and storage in a single-node system in the style of model.energy.
-
Three-Node Capacity Expansion
Co-optimizes generation, storage and transmission investments in a stylized three-node network in Australia
.
-
Pathway Planning
Optimizes investment decisions across multiple investment periods for a long-term transition pathway with perfect foresight.
-
Myopic Pathway Planning
Optimizes investment decisions across multiple investment periods for a long-term transition pathway with myopic foresight.
-
Stochastic Optimization
Demonstrates investment planning under uncertainty with scenario-based two-stage stochastic optimization.
-
Modelling-to-Generate Alternatives
Explores near-optimal solution diversity by generating alternative system designs with similar costs.
-
Exploring Near-Optimal Spaces
Explores near-optimal space to understand flexibility in investment decisions while maintaining cost-effectiveness.
-
Modular Capacity Expansion
Models discrete capacity additions with integer constraints on investment decisions considering predefined unit sizes.
-
Committable and Extendable Components
Co-optimize capacity expansion and unit commitment using big-M linearization. Demonstrates continuous capacity decisions with start-up/shut-down costs, ramp limits, and minimum load constraints.
-
Modular and Committable Components
Model discrete capacity blocks with unit commitment where status represents the number of committed modules. Shows modular gas turbines, HVDC links, and multi-module operational dynamics.
Special Problems¶
-
Redispatch
Sketches how redispatch can be modelled by separating market clearing and congestion management.
-
Demand Elasticity
Demonstrates modelling of price-responsive electricity demands and how they affect price formation.
-
Imperfect Competition
Models oligopolistic behavior in energy markets using Cournot-Nash equilibrium with the fictitious objective approach, avoiding KKT conditions.
-
Screening Curves
Determines optimal generation capacity mix based on screening curves.
-
Chained Hydro Reservoirs
Models cascaded hydropower systems with water flow constraints between reservoirs.
-
Transformers
Shows how transformers can be considered with varying tap ratios and phase shifts.
-
Reserve Constraints
Implements operating reserve requirements in power system optimization.
-
Link Delay
Demonstrates time-delayed energy transport through links, modeling pipeline or shipping delays with cyclic and non-cyclic boundary behavior.
Sector Coupling¶
-
Single-Node Sector-Coupling
Extends the 1-node capacity expansion example with hydrogen, heat and transport demand.
-
Islanded Methanol Production
Optimizes islanded renewable methanol production systems in Namibia
or Argentina
.
-
Electric Vehicles
Demonstrates how to model flexible electric vehicle charging and discharging.
-
Backpressure CHPs
Models combined heat and power plants with fixed heat-to-power ratios.
-
Extraction-Condensing CHPs
Models combined heat and power plants with variable heat-to-power ratios.
-
Heat Pumps and Thermal Storage
Models sector coupling with heat pumps and thermal energy storage.
-
Carbon Management
Models carbon flows between atmosphere, biomass, and synthetic fuels.
Complexity Management¶
-
Time Series Aggregation
Shows how model complexity can be reduced by aggregating snapshots.
-
Global Sensitivity Analysis
Combines PyPSA with SALib's Sobol indices to understand how technology cost uncertainties affect optimal system design and total costs.
-
Storage Units as Links & Stores
Shows how storage units can be replaced by more fundamental links and stores.
-
Tracing Infeasibilities
Shows how to trace infeasibilities in the optimization problem using Irreducible Infeasible Subsets (IIS).