WEC-Grid
    • IntroductionIntroductionIntroduction
    • Software Design
    • Installation
    • Engine
        • Base
        • Grid State
        • PSS/E
        • PyPSA
        • Runner
      • WEC Module
      • WEC Farm
      • WEC Device
      • Database
      • Time
      • Plot
      • Example 1
        • Basic Grid Simulation and Plotting
        • Initialize the WEC-GRID and an Engine
        • Explore the Grid State
        • Run a Basic Steady State Power Flow Simulation.
        • Visualize the Grid with WEC-GRID Plotting
      • Example 2
      • Example 3
      • Example 4
      • Grid Models
      • WEC Models
      • Database
    • API Reference
    • Troubleshooting
    • Citation
GitHub
« Previous
Next »
WEC-Grid
  • Examples & Data »
  • Jupyter notebooks

Example 1¶

Basic Grid Simulation and Plotting¶

This notebook demonstrates the basic functionality of WEC-GRID:

  • Loading a power system model
  • Running a basic simulation
  • Creating visualizations with the plotting module
  • Exploring grid state data

This example uses the IEEE 14-bus test system for demonstration.

Initialize the WEC-GRID and an Engine¶

The Engine is the core component that manages power system simulations. We'll initialize it with the IEEE 14-bus test system.

In [1]:
Copied!
import wecgrid
import wecgrid
In [ ]:
Copied!
example1 = wecgrid.Engine()
example1.case("grid_models/IEEE_14_bus.RAW")
example1.load(["pypsa"])
example1
example1 = wecgrid.Engine() example1.case("grid_models/IEEE_14_bus.RAW") example1.load(["pypsa"]) example1
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[1], line 1
----> 1 example1 = wecgrid.Engine()
      2 example1.case("grid_models/RTS-96.RAW")
      3 example1.load(["pypsa"])

NameError: name 'wecgrid' is not defined

Explore the Grid State¶

WEC-Grid uses a unified GridState object to represent power system data across different power system modelers. Let's examine the grid structure.

In [3]:
Copied!
grid = example1.pypsa.grid
grid
grid = example1.pypsa.grid grid
Out[3]:
GridState:
├─ Components:
│   ├─ bus:   14 components
│   ├─ gen:   5 components
│   ├─ line:  17 components
│   └─ load:  11 components
├─ Case: IEEE 14 bus
└─ Modeler: pypsa

Run a Basic Steady State Power Flow Simulation.¶

Now let's run a power flow simulation to solve the grid state and analyze the results with a load.

In [4]:
Copied!
example1.simulate(num_steps=20) # only run a few iterations
example1.pypsa.report
example1.simulate(num_steps=20) # only run a few iterations example1.pypsa.report
PyPSA Simulating:   0%|          | 0/20 [00:00<?, ?step/s]
PyPSA Simulating: 100%|██████████| 20/20 [00:10<00:00,  1.90step/s]
Out[4]:
SolveReport:
├─ Converged: Successful
├─ Simulation Time: 10.56 s
├─ Num Steps: 20
├─ Case: IEEE 14 bus
└─ Modeler: pypsa

Visualize the Grid with WEC-GRID Plotting¶

The WECGridPlot module provides basic visualization capabilities including single-line diagrams, time series plots, and more.

In [5]:
Copied!
# should see flat lines
plot = example1.plot
plot.bus()
plot.gen()
plot.sld()
# should see flat lines plot = example1.plot plot.bus() plot.gen() plot.sld()
No description has been provided for this image
No description has been provided for this image
SLD Data Summary:
  Buses: 14
  Lines: 17
  Generators: 5
  Loads: 11
No description has been provided for this image
In [ ]:
Copied!

Previous
Next

Built with MkDocs using Ivory theme.