Quick Start Guide
PowerSystems.jl is structured to enable data creation scripts, flexible interfaces for data intake and extension of the data model. These features are enabled through three main features:
- Abstract type hierarchy,
- Optimized read/write data container (the container is called
System
), - Utilities to facilitate modeling, extensions, and integration.
You can access example data in the Power Systems Test Data Repository, the data can be downloaded with the submodule UtilsData
using PowerSystems
DATA_DIR = download(PowerSystems.UtilsData.TestData, folder = pwd())
Loading data
Data can be loaded from several file formats and return a summary of the system's components and time-series.
using PowerSystems
system_data = System(joinpath(DATA_DIR, "matpower/RTS_GMLC.m"))
System
Base Power: 100.0
Components
Num components: 538
14 rows × 3 columns
ConcreteType | SuperTypes | Count | |
---|---|---|---|
String | String | Int64 | |
1 | Arc | Topology <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any | 109 |
2 | Area | AggregationTopology <: Topology <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any | 3 |
3 | Bus | Topology <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any | 73 |
4 | FixedAdmittance | ElectricLoad <: StaticInjection <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any | 3 |
5 | HVDCLine | DCBranch <: Branch <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any | 1 |
6 | HydroDispatch | HydroGen <: Generator <: StaticInjection <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any | 20 |
7 | Line | ACBranch <: Branch <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any | 104 |
8 | LoadZone | AggregationTopology <: Topology <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any | 21 |
9 | PowerLoad | StaticLoad <: ElectricLoad <: StaticInjection <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any | 51 |
10 | RenewableDispatch | RenewableGen <: Generator <: StaticInjection <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any | 30 |
11 | RenewableFix | RenewableGen <: Generator <: StaticInjection <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any | 31 |
12 | TapTransformer | ACBranch <: Branch <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any | 15 |
13 | ThermalStandard | ThermalGen <: Generator <: StaticInjection <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any | 76 |
14 | Transformer2W | ACBranch <: Branch <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any | 1 |
TimeSeriesContainer
Components with time series data: 0
Total StaticTimeSeries: 0
Total Forecasts: 0
Resolution: 0 seconds
More details about parsing text files from different formats in this section
Using PowerSystems.jl
for modeling
This example function implements a function where the modeler can choose the technology by its type and use the different implementations of get_max_active_power
. Using the "dot" access to get a parameter value from a device is actively discouraged, use "getter" functions instead
Refer to Modeling with JuMP for a more detailed use of PowerSystems.jl
to develop a model
function installed_capacity(system::System; technology::Type{T} = Generator) where T <: Generator
installed_capacity = 0.0
for g in get_components(T, system)
installed_capacity += get_max_active_power(g)
end
return installed_capacity
end
installed_capacity (generic function with 1 method)
- Total installed capacity
installed_capacity(system_data)
144.99799999999996
- Installed capacity of the thermal generation
installed_capacity(system_data; technology = ThermalStandard)
80.75999999999998
- Installed capacity of renewable generation
installed_capacity(system_data; technology = RenewableGen)
54.23799999999999
Adding Time Series data to a System
PowerSystems.jl
provides interfaces to augment the data sets already created. You can also add time series data to a system from one or more CSV files, more details in Time Series Data
. This example implements SingleTimeSeries
using PowerSystems
using TimeSeries
using Dates
system = System(joinpath(DATA_DIR, "matpower/case5.m"))
new_renewable = RenewableDispatch(
name = "WindPowerNew",
available = true,
bus = get_component(Bus, system, "3"),
active_power = 2.0,
reactive_power = 1.0,
rating = 1.2,
prime_mover = PrimeMovers.WT,
reactive_power_limits = (min = 0.0, max = 0.0),
base_power = 100.0,
operation_cost = TwoPartCost(22.0, 0.0),
power_factor = 1.0
)
add_component!(system, new_renewable)
ts_data = [0.98, 0.99, 0.99, 1.0, 0.99, 0.99, 0.99, 0.98, 0.95, 0.92, 0.90, 0.88, 0.84, 0.76,
0.65, 0.52, 0.39, 0.28, 0.19, 0.15, 0.13, 0.11, 0.09, 0.06,]
time_stamps = range(DateTime("2020-01-01"); step = Hour(1), length = 24)
time_series_data_raw = TimeArray(time_stamps, ts_data)
time_series = SingleTimeSeries(name = "active_power", data = time_series_data_raw)
#Add the forecast to the system and component
add_time_series!(system, new_renewable, time_series)
[ Info: extending matpower format with data: areas 1x3 [ Info: reversing the orientation of branch 6 (4, 3) to be consistent with other parallel branches [ Info: the voltage setpoint on generator 4 does not match the value at bus 4 [ Info: the voltage setpoint on generator 1 does not match the value at bus 1 [ Info: the voltage setpoint on generator 5 does not match the value at bus 10 [ Info: the voltage setpoint on generator 2 does not match the value at bus 1 [ Info: the voltage setpoint on generator 3 does not match the value at bus 3 [ Info: removing 1 cost terms from generator 4: [4000.0, 0.0] [ Info: removing 1 cost terms from generator 1: [1400.0, 0.0] [ Info: removing 1 cost terms from generator 5: [1000.0, 0.0] [ Info: removing 1 cost terms from generator 2: [1500.0, 0.0] [ Info: removing 1 cost terms from generator 3: [3000.0, 0.0] ┌ Info: Constructing System from Power Models │ data["name"] = "nesta_case5_pjm" └ data["source_type"] = "matpower" [ Info: Reading bus data [ Info: Reading generator data [ Info: Reading branch data ┌ Warning: Rate 426.0 MW for 2-3-i_4 is larger than the max expected in the range of (min = 134.0, max = 145.0). └ @ PowerSystems ~/work/PowerSystems.jl/PowerSystems.jl/src/utils/IO/branchdata_checks.jl:148 ┌ Warning: Rate 400.0 MW for 1-2-i_1 is larger than the max expected in the range of (min = 134.0, max = 145.0). └ @ PowerSystems ~/work/PowerSystems.jl/PowerSystems.jl/src/utils/IO/branchdata_checks.jl:148 ┌ Warning: Rate 426.0 MW for 1-4-i_2 is larger than the max expected in the range of (min = 134.0, max = 145.0). └ @ PowerSystems ~/work/PowerSystems.jl/PowerSystems.jl/src/utils/IO/branchdata_checks.jl:148 ┌ Warning: Rate 240.0 MW for 4-10-i_7 is larger than the max expected in the range of (min = 134.0, max = 145.0). └ @ PowerSystems ~/work/PowerSystems.jl/PowerSystems.jl/src/utils/IO/branchdata_checks.jl:148 ┌ Warning: Rate 426.0 MW for 1-10-i_3 is larger than the max expected in the range of (min = 134.0, max = 145.0). └ @ PowerSystems ~/work/PowerSystems.jl/PowerSystems.jl/src/utils/IO/branchdata_checks.jl:148 [ Info: Reading branch data [ Info: Reading DC Line data [ Info: Reading storage data