Originally Contributed by: Clayton Barrows and Jose Daniel Lara
This notebook is intended to show a power system data specification framework that exploits the capabilities of Julia to improve performance and allow modelers to develop modular software to create problems with different complexities and enable large scale analysis. The PowerSystems documentation is also an excellent resource.
PowerSystems.jl provides a type specification for bulk power system data. The objective is to exploit Julia's integration of dynamic types to enable efficient data handling and enable functional dispatch in modeling and analysis applications As explained in Julia's documentation:
"Julia’s type system is dynamic, but gains some of the advantages of static type systems by making it possible to indicate that certain values are of specific types. This can be of great assistance in generating efficient code, but even more significantly, it allows method dispatch on the types of function arguments to be deeply integrated with the language."
For more details on Julia types, refer to the documentation
PowerSystems.jl relies on a framework for data handling established in InfrastructureSystems.jl. Users of PowerSystems.jl should not need to interact directly with InfrastructureSystems.jl. However, it's worth recognizing that InfrastructureSystems provides much of the back end code for managing and accessing data, especially time series data.
using SIIPExamples;
using PowerSystems;
Normally, I'd add the following two lines to configure logging behavior, but something about Literate.jl makes this fail, so these examples only work with the default log configuration.
using Logging
logger = configure_logging(console_level = Logging.Error, file_level = Logging.Info, filename = "ex.log")
PowerSystems.jl provides a type hierarchy for specifying power system data. Data that
describes infrastructure components is held in struct
s. For example, a Bus
is defined
as follows with fields for the parameters required to describe a bus (along with an
internal
field used by InfrastructureSystems to improve the efficiency of handling data).
print_struct(Bus)
mutable struct Bus number::Int64 name::String bustype::Union{Nothing, BusTypes} angle::Union{Nothing, Float64} magnitude::Union{Nothing, Float64} voltage_limits::Union{Nothing, NamedTuple{(:min, :max),Tuple{Float64,Float64}}} base_voltage::Union{Nothing, Float64} area::Union{Nothing, Area} load_zone::Union{Nothing, LoadZone} ext::Dict{String,Any} internal::InfrastructureSystems.InfrastructureSystemsInternal end
PowerSystems is intended to organize data containers by the behavior of the devices that
the data represents. To that end, a type hierarchy has been defined with several levels of
abstract types starting with InfrastructureSystemsType
. There are a bunch of subtypes of
InfrastructureSystemsType
, but the important ones to know about are:
Component
: includes all elements of power system dataTopology
: includes non physical elements describing network connectivityService
: includes descriptions of system requirements (other than energy balance)Device
: includes descriptions of all the physical devices in a power systemInfrastructureSystems.DeviceParameter
: includes structs that hold data describing thedynamic, or economic capabilities of Device
.
TimeSeriesData
: Includes all time series typesForecast
: includes structs to define time series of forecasted data where multiplevalues can represent each time stamp
StaticTimeSeries
: includes structs to define time series with a single value for eachtime stamp
System
: collects all of the Component
sprint_tree(PowerSystems.IS.InfrastructureSystemsType)
InfrastructureSystemsType ├─ DeviceParameter │ ├─ DynamicComponent │ │ ├─ DynamicGeneratorComponent │ │ │ ├─ AVR │ │ │ │ ├─ AVRFixed │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ AVRSimple │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ AVRTypeI │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ AVRTypeII │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ ESAC1A │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ ESAC6A │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ ESDC1A │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ ESDC2A │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ ESST1A │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ ESST4B │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ EXAC1 │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ EXAC1A │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ EXAC2 │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ EXPIC1 │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ IEEET1 │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ └─ SCRX │ │ │ │ ⋮ │ │ │ │ │ │ │ ├─ Machine │ │ │ │ ├─ AndersonFouadMachine │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ BaseMachine │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ FullMachine │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ MarconatoMachine │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ OneDOneQMachine │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ RoundRotorExponential │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ RoundRotorMachine │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ RoundRotorQuadratic │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ SalientPoleExponential │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ SalientPoleMachine │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ SalientPoleQuadratic │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ SimpleAFMachine │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ SimpleFullMachine │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ └─ SimpleMarconatoMachine │ │ │ │ ⋮ │ │ │ │ │ │ │ ├─ PSS │ │ │ │ ├─ IEEEST │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ PSSFixed │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ └─ PSSSimple │ │ │ │ ⋮ │ │ │ │ │ │ │ ├─ Shaft │ │ │ │ ├─ FiveMassShaft │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ └─ SingleMass │ │ │ │ ⋮ │ │ │ │ │ │ │ └─ TurbineGov │ │ │ ├─ GasTG │ │ │ │ ⋮ │ │ │ │ │ │ │ ├─ GeneralGovModel │ │ │ │ ⋮ │ │ │ │ │ │ │ ├─ HydroTurbineGov │ │ │ │ ⋮ │ │ │ │ │ │ │ ├─ IEEETurbineGov1 │ │ │ │ ⋮ │ │ │ │ │ │ │ ├─ SteamTurbineGov1 │ │ │ │ ⋮ │ │ │ │ │ │ │ ├─ TGFixed │ │ │ │ ⋮ │ │ │ │ │ │ │ ├─ TGTypeI │ │ │ │ ⋮ │ │ │ │ │ │ │ └─ TGTypeII │ │ │ ⋮ │ │ │ │ │ ├─ DynamicInverterComponent │ │ │ ├─ Converter │ │ │ │ └─ AverageConverter │ │ │ │ ⋮ │ │ │ │ │ │ │ ├─ DCSource │ │ │ │ ├─ FixedDCSource │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ └─ ZeroOrderBESS │ │ │ │ ⋮ │ │ │ │ │ │ │ ├─ Filter │ │ │ │ ├─ LCFilter │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ └─ LCLFilter │ │ │ │ ⋮ │ │ │ │ │ │ │ ├─ FrequencyEstimator │ │ │ │ └─ KauraPLL │ │ │ │ ⋮ │ │ │ │ │ │ │ ├─ InnerControl │ │ │ │ └─ CurrentControl │ │ │ │ ⋮ │ │ │ │ │ │ │ └─ OuterControl │ │ └─ InverterComponent │ ├─ ActivePowerControl │ │ └─ VirtualInertia │ ├─ OperationalCost │ │ ├─ MarketBidCost │ │ ├─ MultiStartCost │ │ ├─ StorageManagementCost │ │ ├─ ThreePartCost │ │ └─ TwoPartCost │ └─ ReactivePowerControl │ └─ ReactivePowerDroop ├─ ForecastParameters ├─ InfrastructureSystemsComponent │ ├─ Component │ │ ├─ Device │ │ │ ├─ Branch │ │ │ │ ├─ ACBranch │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ └─ DCBranch │ │ │ │ ⋮ │ │ │ │ │ │ │ ├─ DynamicInjection │ │ │ │ ├─ DynamicGenerator │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ └─ DynamicInverter │ │ │ │ ⋮ │ │ │ │ │ │ │ ├─ RegulationDevice │ │ │ └─ StaticInjection │ │ │ ├─ ElectricLoad │ │ │ │ ⋮ │ │ │ │ │ │ │ ├─ Generator │ │ │ │ ⋮ │ │ │ │ │ │ │ ├─ HybridSystem │ │ │ │ ⋮ │ │ │ │ │ │ │ ├─ Source │ │ │ │ ⋮ │ │ │ │ │ │ │ └─ Storage │ │ │ ⋮ │ │ │ │ │ ├─ Service │ │ │ ├─ AGC │ │ │ ├─ ReserveNonSpinning │ │ │ │ ├─ StaticReserveNonSpinning │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ └─ VariableReserveNonSpinning │ │ │ │ ⋮ │ │ │ │ │ │ │ ├─ Reserve │ │ │ │ ├─ ReserveDemandCurve │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ ├─ StaticReserve │ │ │ │ │ ⋮ │ │ │ │ │ │ │ │ │ └─ VariableReserve │ │ │ │ ⋮ │ │ │ │ │ │ │ ├─ StaticReserveGroup │ │ │ └─ Transfer │ │ └─ Topology │ │ ├─ AggregationTopology │ │ │ ├─ Area │ │ │ │ ⋮ │ │ │ │ │ │ │ └─ LoadZone │ │ │ ⋮ │ │ │ │ │ ├─ Arc │ │ └─ Bus │ ├─ AdditionalTestComponent │ ├─ TestComponent │ └─ TimeSeriesData │ ├─ Forecast │ │ ├─ AbstractDeterministic │ │ │ ├─ Deterministic │ │ │ │ ⋮ │ │ │ │ │ │ │ └─ DeterministicSingleTimeSeries │ │ │ ⋮ │ │ │ │ │ ├─ Probabilistic │ │ └─ Scenarios │ └─ StaticTimeSeries │ └─ SingleTimeSeries ├─ InfrastructureSystemsInternal ├─ SystemData ├─ TimeSeriesKey ├─ TimeSeriesMetadata │ ├─ ForecastMetadata │ │ ├─ DeterministicMetadata │ │ ├─ ProbabilisticMetadata │ │ └─ ScenariosMetadata │ └─ StaticTimeSeriesMetadata │ └─ SingleTimeSeriesMetadata ├─ TimeSeriesParameters ├─ PowerSystemCaseBuilderType │ ├─ SystemBuildStats │ ├─ SystemCategory │ │ ├─ MatPowerTestSystems │ │ ├─ PSIDTestSystems │ │ ├─ PSITestSystems │ │ ├─ PSSETestSystems │ │ ├─ PSYTestSystems │ │ └─ SIIPExampleSystems │ └─ SystemDescriptor └─ System
TimeSeriesData
¶Read the Docs!
Every Component
has a time_series_container::InfrastructureSystems.TimeSeriesContainer
field. TimeSeriesData
are used to hold time series information that describes the
temporally dependent data of fields within the same struct. For example, the
ThermalStandard.time_series_container
field can
describe other fields in the struct (available
, activepower
, reactivepower
).
TimeSeriesData
s themselves can take the form of the following:
print_tree(TimeSeriesData)
TimeSeriesData ├─ Forecast │ ├─ AbstractDeterministic │ │ ├─ Deterministic │ │ └─ DeterministicSingleTimeSeries │ ├─ Probabilistic │ └─ Scenarios └─ StaticTimeSeries └─ SingleTimeSeries
In each case, the time series contains fields for scaling_factor_multiplier
and data
to identify the details of th Component
field that the time series describes, and the
time series data
. For example: we commonly want to use a time series to
describe the maximum active power capability of a renewable generator. In this case, we
can create a SingleTimeSeries
with a TimeArray
and an accessor function to the
maximum active power field in the struct describing the generator. In this way, we can
store a scaling factor time series that will get multiplied by the maximum active power
rather than the magnitudes of the maximum active power time series.
print_struct(Deterministic)
mutable struct Deterministic name::String data::Union{DataStructures.SortedDict{DateTime,Array{Array{Tuple{Float64,Float64},1},1},Ord} where Ord<:Base.Order.Ordering, DataStructures.SortedDict{DateTime,Array{Float64,1},Ord} where Ord<:Base.Order.Ordering, DataStructures.SortedDict{DateTime,Array{Tuple{Float64,Float64},1},Ord} where Ord<:Base.Order.Ordering} resolution::Period scaling_factor_multiplier::Union{Nothing, Function} internal::InfrastructureSystems.InfrastructureSystemsInternal end
Examples of how to create and add time series to system can be found in the Add Time Series Example
The System
object collects all of the individual components into a single struct along
with some metadata about the system itself (e.g. base_power
)
print_struct(System)
struct System data::InfrastructureSystems.SystemData frequency::Float64 bus_numbers::Set{Int64} runchecks::Base.RefValue{Bool} units_settings::InfrastructureSystems.SystemUnitsSettings internal::InfrastructureSystems.InfrastructureSystemsInternal end
PowerSystems contains a few basic data files (mostly for testing and demonstration).
BASE_DIR = abspath(joinpath(dirname(Base.find_package("PowerSystems")), ".."))
include(joinpath(BASE_DIR, "test", "data_5bus_pu.jl")) #.jl file containing 5-bus system data
nodes_5 = nodes5() # function to create 5-bus buses
5-element Array{Bus,1}: Bus(1, nodeA, BusTypes.PV = 3, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}()) Bus(2, nodeB, BusTypes.PQ = 2, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}()) Bus(3, nodeC, BusTypes.PV = 3, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}()) Bus(4, nodeD, BusTypes.REF = 4, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}()) Bus(5, nodeE, BusTypes.PV = 3, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}())
System
¶sys = System(
100.0,
nodes_5,
vcat(thermal_generators5(nodes_5), renewable_generators5(nodes_5)),
loads5(nodes_5),
branches5(nodes_5),
)
┌ Warning: Rate 200.0 MW for 1 is larger than the max expected in the range of (min = 134.0, max = 145.0). └ @ PowerSystems ~/.julia/packages/PowerSystems/N2l8o/src/utils/IO/branchdata_checks.jl:148 ┌ Warning: Rate 200.0 MW for 2 is larger than the max expected in the range of (min = 134.0, max = 145.0). └ @ PowerSystems ~/.julia/packages/PowerSystems/N2l8o/src/utils/IO/branchdata_checks.jl:148 ┌ Warning: Rate 1881.2 MW for 3 is larger than the max expected in the range of (min = 134.0, max = 145.0). └ @ PowerSystems ~/.julia/packages/PowerSystems/N2l8o/src/utils/IO/branchdata_checks.jl:148 ┌ Warning: Rate 1114.8 MW for 4 is larger than the max expected in the range of (min = 134.0, max = 145.0). └ @ PowerSystems ~/.julia/packages/PowerSystems/N2l8o/src/utils/IO/branchdata_checks.jl:148 ┌ Warning: Rate 4053.0 MW for 5 is larger than the max expected in the range of (min = 134.0, max = 145.0). └ @ PowerSystems ~/.julia/packages/PowerSystems/N2l8o/src/utils/IO/branchdata_checks.jl:148 ┌ Warning: Rate 200.0 MW for 6 is larger than the max expected in the range of (min = 134.0, max = 145.0). └ @ PowerSystems ~/.julia/packages/PowerSystems/N2l8o/src/utils/IO/branchdata_checks.jl:148
Base Power: 100.0
Num components: 28
ConcreteType | SuperTypes | Count | |
---|---|---|---|
String | String | Int64 | |
1 | Arc | Topology <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any | 6 |
2 | Bus | Topology <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any | 5 |
3 | Line | ACBranch <: Branch <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any | 6 |
4 | PowerLoad | StaticLoad <: ElectricLoad <: StaticInjection <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any | 3 |
5 | RenewableDispatch | RenewableGen <: Generator <: StaticInjection <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any | 3 |
6 | ThermalStandard | ThermalGen <: Generator <: StaticInjection <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any | 5 |
Components with time series data: 0
Total StaticTimeSeries: 0
Total Forecasts: 0
Resolution: 0 seconds
System
Data¶PowerSystems provides functional interfaces to all data. The following examples outline the intended approach to accessing data expressed using PowerSystems.
PowerSystems enforces unique name
fields between components of a particular concrete type.
So, in order to retrieve a specific component, the user must specify the type of the component
along with the name and system
@show get_component(Bus, sys, "nodeA")
@show get_component(Line, sys, "1")
get_component(Bus, sys, "nodeA") = Bus(1, nodeA, BusTypes.PV = 3, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}()) get_component(Line, sys, "1") = Line(1, true, 0.0, 0.0, Arc(Bus(1, nodeA, BusTypes.PV = 3, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}()), Bus(2, nodeB, BusTypes.PQ = 2, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}())), 0.00281, 0.0281, (from = 0.00356, to = 0.00356), 2.0, (min = -0.7, max = 0.7), Service[], Dict{String,Any}())
1 (Line): name: 1 available: true active_power_flow: 0.0 reactive_power_flow: 0.0 arc: nodeA -> nodeB (Arc) r: 0.00281 x: 0.0281 b: (from = 0.00356, to = 0.00356) rate: 2.0 angle_limits: (min = -0.7, max = 0.7) services: 0-element Array{Service,1} ext: Dict{String,Any}() time_series_container: InfrastructureSystems.TimeSeriesContainer: 0 InfrastructureSystems.SystemUnitsSettings: base_value: 100.0 unit_system: UnitSystem.SYSTEM_BASE = 0
Similarly, you can access all the components of a particular type: *note: the return type
of get_components is a FlattenIteratorWrapper
, so call collect
to get an Array
get_components(Bus, sys) |> collect
5-element Array{Bus,1}: Bus(1, nodeA, BusTypes.PV = 3, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}()) Bus(3, nodeC, BusTypes.PV = 3, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}()) Bus(5, nodeE, BusTypes.PV = 3, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}()) Bus(2, nodeB, BusTypes.PQ = 2, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}()) Bus(4, nodeD, BusTypes.REF = 4, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}())
get_components
also works on abstract types:
get_components(Branch, sys) |> collect
6-element Array{Branch,1}: Line(4, true, 0.0, 0.0, Arc(Bus(2, nodeB, BusTypes.PQ = 2, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}()), Bus(3, nodeC, BusTypes.PV = 3, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}())), 0.00108, 0.0108, (from = 0.00926, to = 0.00926), 11.148, (min = -0.7, max = 0.7), Service[], Dict{String,Any}()) Line(1, true, 0.0, 0.0, Arc(Bus(1, nodeA, BusTypes.PV = 3, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}()), Bus(2, nodeB, BusTypes.PQ = 2, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}())), 0.00281, 0.0281, (from = 0.00356, to = 0.00356), 2.0, (min = -0.7, max = 0.7), Service[], Dict{String,Any}()) Line(5, true, 0.0, 0.0, Arc(Bus(3, nodeC, BusTypes.PV = 3, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}()), Bus(4, nodeD, BusTypes.REF = 4, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}())), 0.00297, 0.0297, (from = 0.00337, to = 0.00337), 40.53, (min = -0.7, max = 0.7), Service[], Dict{String,Any}()) Line(2, true, 0.0, 0.0, Arc(Bus(1, nodeA, BusTypes.PV = 3, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}()), Bus(4, nodeD, BusTypes.REF = 4, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}())), 0.00304, 0.0304, (from = 0.00329, to = 0.00329), 2.0, (min = -0.7, max = 0.7), Service[], Dict{String,Any}()) Line(6, true, 0.0, 0.0, Arc(Bus(4, nodeD, BusTypes.REF = 4, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}()), Bus(5, nodeE, BusTypes.PV = 3, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}())), 0.00297, 0.0297, (from = 0.00337, to = 0.00337), 2.0, (min = -0.7, max = 0.7), Service[], Dict{String,Any}()) Line(3, true, 0.0, 0.0, Arc(Bus(1, nodeA, BusTypes.PV = 3, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}()), Bus(5, nodeE, BusTypes.PV = 3, 0.0, 1.0, (min = 0.9, max = 1.05), 230.0, nothing, nothing, Dict{String,Any}())), 0.00064, 0.0064, (from = 0.01563, to = 0.01563), 18.812, (min = -0.7, max = 0.7), Service[], Dict{String,Any}())
The fields within a component can be accessed using the get_*
functions:
It's highly recommended that users avoid using the .
to access fields since we make no
guarantees on the stability field names and locations. We do however promise to keep the
accessor functions stable.
bus1 = get_component(Bus, sys, "nodeA")
@show get_name(bus1);
@show get_magnitude(bus1);
get_name(bus1) = "nodeA" get_magnitude(bus1) = 1.0
TimeSeries
¶First we need to add some time series to the System
loads = collect(get_components(PowerLoad, sys))
for (l, ts) in zip(loads, load_timeseries_DA[2])
add_time_series!(
sys,
l,
Deterministic(
"activepower",
Dict(TimeSeries.timestamp(load_timeseries_DA[2][1])[1] => ts),
),
)
end
If we want to access a specific time series for a specific component, we need to specify:
component
We can find the initial time of all the time series in the system:
get_forecast_initial_times(sys)
DateTime("2024-01-02T00:00:00"):Second(1):DateTime("2024-01-02T00:00:00")
We can find the names of all time series attached to a component:
ts_names = get_time_series_names(Deterministic, loads[1])
1-element Array{String,1}: "activepower"
We can access a specific time series for a specific component:
ta = get_time_series_array(Deterministic, loads[1], ts_names[1])
24×1 TimeSeries.TimeArray{Float64,1,DateTime,SubArray{Float64,1,Array{Float64,1},Tuple{UnitRange{Int64}},true}} 2024-01-02T00:00:00 to 2024-01-02T23:00:00 │ │ A │ ├─────────────────────┼────────┤ │ 2024-01-02T00:00:00 │ 0.8764 │ │ 2024-01-02T01:00:00 │ 0.7735 │ │ 2024-01-02T02:00:00 │ 0.7261 │ │ 2024-01-02T03:00:00 │ 0.7376 │ │ 2024-01-02T04:00:00 │ 0.751 │ │ 2024-01-02T05:00:00 │ 0.7379 │ │ 2024-01-02T06:00:00 │ 0.7541 │ │ 2024-01-02T07:00:00 │ 0.7925 │ │ 2024-01-02T08:00:00 │ 0.7619 │ ⋮ │ 2024-01-02T16:00:00 │ 0.8527 │ │ 2024-01-02T17:00:00 │ 1.0014 │ │ 2024-01-02T18:00:00 │ 1.0834 │ │ 2024-01-02T19:00:00 │ 1.0734 │ │ 2024-01-02T20:00:00 │ 1.0506 │ │ 2024-01-02T21:00:00 │ 1.0027 │ │ 2024-01-02T22:00:00 │ 0.9632 │ │ 2024-01-02T23:00:00 │ 0.8395 │
Or, we can just get the values of the time series:
ts = get_time_series_values(Deterministic, loads[1], ts_names[1])
24-element view(::Array{Float64,1}, 1:24) with eltype Float64: 0.8763530521031297 0.7735213628850688 0.7260728702850817 0.7375952082331995 0.7510109696584579 0.7379475737361705 0.7540501444535201 0.7924645353213167 0.7619228514495343 0.8371976140823855 ⋮ 0.8504880594378538 0.8527232257415814 1.001433175173374 1.0834259785719857 1.073383487426426 1.050553466438029 1.0026865202289015 0.9632169229923295 0.8395488368157675
This notebook was generated using Literate.jl.