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.
In [8]:
Copied!
%%capture
'''
if this is your first time running WEC-GRID, you will need to set the database path to the location of your WECGrid.db file. Uncomment the line below and provide the correct path to your database file.
'''
# import wecgrid
# setup = wecgrid.Engine()
# setup.database.set_database_path('./WECGrid.db')
%%capture
'''
if this is your first time running WEC-GRID, you will need to set the database path to the location of your WECGrid.db file. Uncomment the line below and provide the correct path to your database file.
'''
# import wecgrid
# setup = wecgrid.Engine()
# setup.database.set_database_path('./WECGrid.db')
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 [9]:
Copied!
import wecgrid
import wecgrid
In [10]:
Copied!
example1 = wecgrid.Engine()
example1.case("grid_models/IEEE_14_bus.RAW")
example1.load(["pypsa"])
example1 = wecgrid.Engine()
example1.case("grid_models/IEEE_14_bus.RAW")
example1.load(["pypsa"])
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 [11]:
Copied!
grid = example1.pypsa.grid
grid
grid = example1.pypsa.grid
grid
Out[11]:
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 [12]:
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: 100%|āāāāāāāāāā| 20/20 [00:02<00:00, 9.98step/s]
Out[12]:
SolveReport: Successful, steps=20, time=2.01s, case=IEEE 14 bus, sw=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 [13]:
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()
In [ ]:
Copied!