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

ConcreteTypeSuperTypesCount
StringStringInt64
1ArcTopology <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any109
2AreaAggregationTopology <: Topology <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any3
3BusTopology <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any73
4FixedAdmittanceElectricLoad <: StaticInjection <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any3
5HVDCLineDCBranch <: Branch <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any1
6HydroDispatchHydroGen <: Generator <: StaticInjection <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any20
7LineACBranch <: Branch <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any104
8LoadZoneAggregationTopology <: Topology <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any21
9PowerLoadStaticLoad <: ElectricLoad <: StaticInjection <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any51
10RenewableDispatchRenewableGen <: Generator <: StaticInjection <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any30
11RenewableFixRenewableGen <: Generator <: StaticInjection <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any31
12TapTransformerACBranch <: Branch <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any15
13ThermalStandardThermalGen <: Generator <: StaticInjection <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any76
14Transformer2WACBranch <: Branch <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any1

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