Public API Reference

Modeling

PowerSystems.ComponentType

Supertype for all PowerSystems components. All subtypes must include a InfrastructureSystemsInternal member. Subtypes should call InfrastructureSystemsInternal() by default, but also must provide a constructor that allows existing values to be deserialized.

source
PowerSystems.get_base_powerMethod
get_base_power(c::Component) -> Float64
Default behavior of a component. If there is no base_power field, assume is in the system's base power.
source
PowerSystems.set_dynamic_injector!Method
set_dynamic_injector!(
    static_injector::StaticInjection,
    dynamic_injector::Union{Nothing, DynamicInjection}
)

Any StaticInjection struct that wants to support dynamic injectors must implement this method to set the value.

The method is only for internal uses.

source
PowerSystems.has_serviceMethod
has_service(device::Device, _::Type{T<:Service}) -> Bool

Return true if a service with type T is attached to the device.

source
PowerSystems.remove_service!Method
remove_service!(device::Device, service::Service)

Remove a service from a device.

Throws ArgumentError if the service is not attached to the device.

source
PowerSystems.RenewableGenType

Supertype for all renewable generation technologies Requires the implementation of get_ratingand get_power_factor methods

source
PowerSystems.get_dynamic_componentsMethod
get_dynamic_components(
    device::DynamicInjection
) -> Base.Generator{I, F} where {I<:(Base.Iterators.Filter{PowerSystems.var"#6#8", I} where I<:(Base.Iterators.Zip{Is} where Is<:Tuple{Any, Tuple})), F<:(PowerSystems.var"#5#7"{<:DynamicInjection})}

Return all the dynamic components of a DynamicInjection device

source
PowerSystems.get_states_typesMethod
get_states_types(d::DynamicComponent) -> Vector{StateTypes}
Default implementation of get_state_types for dynamic components. Assumes all states are
Differential
source
PowerSystems.get_breakpoint_upperboundsMethod
get_breakpoint_upperbounds(
    vc::VariableCost{Vector{Tuple{Float64, Float64}}}
) -> Vector{Float64}

Calculates the upper bounds of a variable cost function represented as a collection of piece-wise linear segments.

source
PowerSystems.get_slopesMethod
get_slopes(
    vc::VariableCost{Vector{Tuple{Float64, Float64}}}
) -> Vector{Float64}

Calculates the slopes for the variable cost represented as a piece wise linear cost function. This function returns n - slopes for n - piecewise linear elements in the function. The first element of the return array corresponds to the average cost at the minimum operating point. If your formulation uses n -1 slopes, you can disregard the first component of the array. If the first point in the variable cost has a quantity of 0.0, the first slope returned will be 0.0, otherwise, the first slope represents the trajectory to get from the origin to the first point in the variable cost.

source

TimeSeries

InfrastructureSystems.TimeSeriesDataType

Abstract type for time series stored in the system. Components store references to these through TimeSeriesMetadata values so that data can reside on storage media instead of memory.

InfrastructureSystems.DeterministicType
mutable struct Deterministic <: AbstractDeterministic
    name::String
    data::Union{
        SortedDict{Dates.DateTime, Vector{CONSTANT}},
        SortedDict{Dates.DateTime, Vector{POLYNOMIAL}},
        SortedDict{Dates.DateTime, Vector{PWL}},
    }
    resolution::Dates.Period
    scaling_factor_multiplier::Union{Nothing, Function}
    internal::InfrastructureSystemsInternal
end

A deterministic forecast for a particular data field in a Component.

Arguments

  • name::String: user-defined name
  • data::Union{SortedDict{Dates.DateTime, Vector{CONSTANT}}, SortedDict{Dates.DateTime, Vector{POLYNOMIAL}}, SortedDict{Dates.DateTime, Vector{PWL}}}: timestamp - scalingfactor
  • resolution::Dates.Period: forecast resolution
  • scaling_factor_multiplier::Union{Nothing, Function}: Applicable when the time series data are scaling factors. Called on the associated component to convert the values.
  • internal::InfrastructureSystemsInternal
InfrastructureSystems.DeterministicMethod
Deterministic(
    name::AbstractString,
    input_data::AbstractDict{Dates.DateTime, <:TimeSeries.TimeArray};
    normalization_factor,
    scaling_factor_multiplier
) -> Deterministic

Construct Deterministic from a Dict of TimeArrays.

Arguments

  • name::AbstractString: user-defined name
  • input_data::AbstractDict{Dates.DateTime, TimeSeries.TimeArray}: time series data.
  • normalization_factor::NormalizationFactor = 1.0: optional normalization factor to apply to each data entry
  • scaling_factor_multiplier::Union{Nothing, Function} = nothing: If the data are scaling factors then this function will be called on the component and applied to the data when get_time_series_array is called.
  • timestamp = :timestamp: If the values are DataFrames is passed then this must be the column name that contains timestamps.
InfrastructureSystems.DeterministicMethod
Deterministic(
    name::AbstractString,
    filename::AbstractString,
    component::InfrastructureSystems.InfrastructureSystemsComponent,
    resolution::Dates.Period;
    normalization_factor,
    scaling_factor_multiplier
) -> Deterministic

Construct Deterministic from a CSV file. The first column must be a timestamp in DateTime format and the columns the values in the forecast window.

Arguments

  • name::AbstractString: user-defined name
  • filename::AbstractString: name of CSV file containing data
  • component::InfrastructureSystemsComponent: component associated with the data
  • normalization_factor::NormalizationFactor = 1.0: optional normalization factor to apply to each data entry
  • scaling_factor_multiplier::Union{Nothing, Function} = nothing: If the data are scaling factors then this function will be called on the component and applied to the data when get_time_series_array is called.
InfrastructureSystems.DeterministicMethod
Deterministic(
    name::AbstractString,
    series_data::InfrastructureSystems.RawTimeSeries,
    resolution::Dates.Period;
    normalization_factor,
    scaling_factor_multiplier
) -> Deterministic

Construct Deterministic from RawTimeSeries.

InfrastructureSystems.DeterministicMethod
Deterministic(
    forecast::Deterministic,
    data
) -> Deterministic

Construct a new Deterministic from an existing instance and a subset of data.

InfrastructureSystems.get_dataMethod
get_data(
    value::Deterministic
) -> Union{DataStructures.SortedDict{Dates.DateTime, Vector{Vector{Tuple{Float64, Float64}}}}, DataStructures.SortedDict{Dates.DateTime, Vector{Float64}}, DataStructures.SortedDict{Dates.DateTime, Vector{Tuple{Float64, Float64}}}}

Get Deterministic data.

InfrastructureSystems.ProbabilisticType
mutable struct Probabilistic <: Forecast
    name::String
    resolution::Dates.Period
    percentiles::Vector{Float64}
    data::Union{
        SortedDict{Dates.DateTime, Matrix{CONSTANT}},
        SortedDict{Dates.DateTime, Matrix{POLYNOMIAL}},
        SortedDict{Dates.DateTime, Matrix{PWL}},
    }
    scaling_factor_multiplier::Union{Nothing, Function}
    internal::InfrastructureSystemsInternal
end

A Probabilistic forecast for a particular data field in a Component.

Arguments

  • name::String: user-defined name
  • resolution::Dates.Period: forecast resolution
  • percentiles::Vector{Float64}: Percentiles for the probabilistic forecast
  • data::Union{SortedDict{Dates.DateTime, Matrix{CONSTANT}}, SortedDict{Dates.DateTime, Matrix{POLYNOMIAL}}, SortedDict{Dates.DateTime, Matrix{PWL}}}: timestamp - scalingfactor
  • scaling_factor_multiplier::Union{Nothing, Function}: Applicable when the time series data are scaling factors. Called on the associated component to convert the values.
  • internal::InfrastructureSystemsInternal
InfrastructureSystems.ProbabilisticMethod
Probabilistic(
    name::AbstractString,
    input_data::AbstractDict,
    percentiles::Vector,
    resolution::Dates.Period;
    normalization_factor,
    scaling_factor_multiplier
) -> Probabilistic

Construct Probabilistic from a SortedDict of Arrays.

Arguments

  • name::AbstractString: user-defined name
  • input_data::AbstractDict{Dates.DateTime, Matrix{Float64}}: time series data.
  • percentiles: Percentiles represented in the probabilistic forecast
  • resolution::Dates.Period: The resolution of the forecast in Dates.Period`
  • normalization_factor::NormalizationFactor = 1.0: optional normalization factor to apply to each data entry
  • scaling_factor_multiplier::Union{Nothing, Function} = nothing: If the data are scaling factors then this function will be called on the component and applied to the data when get_time_series_array is called.
InfrastructureSystems.ProbabilisticMethod
Probabilistic(
    name::AbstractString,
    input_data::AbstractDict{Dates.DateTime, <:TimeSeries.TimeArray},
    percentiles::Vector{Float64};
    normalization_factor,
    scaling_factor_multiplier
) -> Probabilistic

Construct Probabilistic from a Dict of TimeArrays.

Arguments

  • name::AbstractString: user-defined name
  • input_data::AbstractDict{Dates.DateTime, TimeSeries.TimeArray}: time series data.
  • percentiles: Percentiles represented in the probabilistic forecast
  • normalization_factor::NormalizationFactor = 1.0: optional normalization factor to apply to each data entry
  • scaling_factor_multiplier::Union{Nothing, Function} = nothing: If the data are scaling factors then this function will be called on the component and applied to the data when get_time_series_array is called.
  • timestamp = :timestamp: If the values are DataFrames is passed then this must be the column name that contains timestamps.
InfrastructureSystems.ProbabilisticMethod
Probabilistic(
    name::AbstractString,
    series_data::InfrastructureSystems.RawTimeSeries,
    percentiles::Vector,
    resolution::Dates.Period;
    normalization_factor,
    scaling_factor_multiplier
) -> Probabilistic

Construct Deterministic from RawTimeSeries.

InfrastructureSystems.get_dataMethod
get_data(
    value::Probabilistic
) -> Union{DataStructures.SortedDict{Dates.DateTime, Matrix{Vector{Tuple{Float64, Float64}}}}, DataStructures.SortedDict{Dates.DateTime, Matrix{Float64}}, DataStructures.SortedDict{Dates.DateTime, Matrix{Tuple{Float64, Float64}}}}

Get Probabilistic data.

InfrastructureSystems.ScenariosType
mutable struct Scenarios <: Forecast
    name::String
    resolution::Dates.Period
    scenario_count::Int64
    data::Union{
        SortedDict{Dates.DateTime, Matrix{CONSTANT}},
        SortedDict{Dates.DateTime, Matrix{POLYNOMIAL}},
        SortedDict{Dates.DateTime, Matrix{PWL}},
    }
    scaling_factor_multiplier::Union{Nothing, Function}
    internal::InfrastructureSystemsInternal
end

A Discrete Scenario Based time series for a particular data field in a Component.

Arguments

  • name::String: user-defined name
  • resolution::Dates.Period: forecast resolution
  • scenario_count::Int64: Number of scenarios
  • data::Union{SortedDict{Dates.DateTime, Matrix{CONSTANT}}, SortedDict{Dates.DateTime, Matrix{POLYNOMIAL}}, SortedDict{Dates.DateTime, Matrix{PWL}}}: timestamp - scalingfactor
  • scaling_factor_multiplier::Union{Nothing, Function}: Applicable when the time series data are scaling factors. Called on the associated component to convert the values.
  • internal::InfrastructureSystemsInternal
InfrastructureSystems.ScenariosMethod
Scenarios(
    name::AbstractString,
    input_data::AbstractDict,
    resolution::Dates.Period;
    normalization_factor,
    scaling_factor_multiplier
) -> Scenarios

Construct Scenarios from a SortedDict of Arrays.

Arguments

  • name::AbstractString: user-defined name
  • input_data::AbstractDict{Dates.DateTime, Matrix{Float64}}: time series data.
  • resolution::Dates.Period: The resolution of the forecast in Dates.Period`
  • normalization_factor::NormalizationFactor = 1.0: optional normalization factor to apply to each data entry
  • scaling_factor_multiplier::Union{Nothing, Function} = nothing: If the data are scaling factors then this function will be called on the component and applied to the data when get_time_series_array is called.
InfrastructureSystems.ScenariosMethod
Scenarios(
    name::AbstractString,
    input_data::AbstractDict{Dates.DateTime, <:TimeSeries.TimeArray};
    normalization_factor,
    scaling_factor_multiplier
) -> Scenarios

Construct Scenarios from a Dict of TimeArrays.

Arguments

  • name::AbstractString: user-defined name
  • input_data::AbstractDict{Dates.DateTime, TimeSeries.TimeArray}: time series data.
  • normalization_factor::NormalizationFactor = 1.0: optional normalization factor to apply to each data entry
  • scaling_factor_multiplier::Union{Nothing, Function} = nothing: If the data are scaling factors then this function will be called on the component and applied to the data when get_time_series_array is called.
  • timestamp = :timestamp: If the values are DataFrames is passed then this must be the column name that contains timestamps.
InfrastructureSystems.get_dataMethod
get_data(
    value::Scenarios
) -> Union{DataStructures.SortedDict{Dates.DateTime, Matrix{Vector{Tuple{Float64, Float64}}}}, DataStructures.SortedDict{Dates.DateTime, Matrix{Float64}}, DataStructures.SortedDict{Dates.DateTime, Matrix{Tuple{Float64, Float64}}}}

Get Scenarios data.

InfrastructureSystems.DeterministicSingleTimeSeriesType
mutable struct DeterministicSingleTimeSeries <: AbstractDeterministic
    single_time_series::SingleTimeSeries
    initial_timestamp::Dates.DateTime
    interval::Dates.Period
    count::Int
    horizon::Int
end

A deterministic forecast for a particular data field in a Component that wraps a SingleTimeSeries.

Arguments

  • single_time_series::SingleTimeSeries: wrapped SingleTimeSeries object
  • initial_timestamp::Dates.DateTime: time series availability time
  • interval::Dates.Period: time step between forecast windows
  • count::Int: number of forecast windows
  • horizon::Int: length of this time series
InfrastructureSystems.SingleTimeSeriesType
mutable struct SingleTimeSeries <: StaticTimeSeries
    name::String
    data::TimeSeries.TimeArray
    scaling_factor_multiplier::Union{Nothing, Function}
    internal::InfrastructureSystemsInternal
end

A deterministic forecast for a particular data field in a Component.

Arguments

  • name::String: user-defined name
  • data::TimeSeries.TimeArray: timestamp - scalingfactor
  • scaling_factor_multiplier::Union{Nothing, Function}: Applicable when the time series data are scaling factors. Called on the associated component to convert the values.
  • internal::InfrastructureSystemsInternal
InfrastructureSystems.SingleTimeSeriesMethod
SingleTimeSeries(
    name::AbstractString,
    filename::AbstractString,
    component::InfrastructureSystems.InfrastructureSystemsComponent,
    resolution::Dates.Period;
    normalization_factor,
    scaling_factor_multiplier
) -> SingleTimeSeries

Construct SingleTimeSeries from a CSV file. The file must have a column that is the name of the component.

Arguments

  • name::AbstractString: user-defined name
  • filename::AbstractString: name of CSV file containing data
  • component::InfrastructureSystemsComponent: component associated with the data
  • resolution::Dates.Period: resolution of the time series
  • normalization_factor::NormalizationFactor = 1.0: optional normalization factor to apply to each data entry
  • scaling_factor_multiplier::Union{Nothing, Function} = nothing: If the data are scaling factors then this function will be called on the component and applied to the data when get_time_series_array is called.
InfrastructureSystems.SingleTimeSeriesMethod
SingleTimeSeries(
    name::AbstractString,
    data::Union{DataFrames.DataFrame, TimeSeries.TimeArray};
    normalization_factor,
    scaling_factor_multiplier,
    timestamp
) -> SingleTimeSeries

Construct SingleTimeSeries from a TimeArray or DataFrame.

Arguments

  • name::AbstractString: user-defined name
  • data::Union{TimeSeries.TimeArray, DataFrames.DataFrame}: time series data
  • normalization_factor::NormalizationFactor = 1.0: optional normalization factor to apply to each data entry
  • scaling_factor_multiplier::Union{Nothing, Function} = nothing: If the data are scaling factors then this function will be called on the component and applied to the data when get_time_series_array is called.
  • timestamp = :timestamp: If a DataFrame is passed then this must be the column name that contains timestamps.
InfrastructureSystems.SingleTimeSeriesMethod
SingleTimeSeries(
    time_series::SingleTimeSeries,
    data::TimeSeries.TimeArray
) -> Any

Creates a new SingleTimeSeries from an existing instance and a subset of data.

InfrastructureSystems.SingleTimeSeriesMethod
SingleTimeSeries(
    name::String,
    resolution::Dates.Period,
    initial_time::Dates.DateTime,
    time_steps::Int64
) -> SingleTimeSeries

Construct SingleTimeSeries after constructing a TimeArray from initial_time and time_steps.

InfrastructureSystems.fromMethod
from(
    time_series::SingleTimeSeries,
    timestamp
) -> SingleTimeSeries

Return a time_series truncated starting with timestamp.

InfrastructureSystems.headMethod
head(time_series::SingleTimeSeries) -> Any

Return a time_series with only the first num values.

InfrastructureSystems.tailMethod
tail(time_series::SingleTimeSeries) -> Any

Return a time_series with only the ending num values.

InfrastructureSystems.toMethod
to(
    time_series::SingleTimeSeries,
    timestamp
) -> SingleTimeSeries

Return a time_series truncated after timestamp.

InfrastructureSystems.whenMethod
when(
    time_series::SingleTimeSeries,
    period::Function,
    t::Integer
) -> Any

Refer to TimeSeries.when(). Underlying data is copied.

InfrastructureSystems.get_next_time_series_array!Method
get_next_time_series_array!(
    cache::InfrastructureSystems.TimeSeriesCache
) -> Any

Return the next TimeSeries.TimeArray.

Returns nothing when all data has been read. Call reset! to restart. Call get_next_time to check the start time.

Reads from storage if the data is not already in cache.

Arguments

  • cache::StaticTimeSeriesCache: cached instance

System

PowerSystems.SystemType

System

A power system defined by fields for base_power, components, and time series.

System(base_power)
System(base_power, buses, components...)
System(base_power, buses, generators, loads, branches, storage, services; kwargs...)
System(base_power, buses, generators, loads; kwargs...)
System(file; kwargs...)
System(; buses, generators, loads, branches, storage, base_power, services, kwargs...)
System(; kwargs...)

Arguments

  • base_power::Float64: the base power value for the system
  • buses::Vector{ACBus}: an array of buses
  • components...: Each element must be an iterable containing subtypes of Component.

Keyword arguments

  • ext::Dict: Contains user-defined parameters. Should only contain standard types.
  • runchecks::Bool: Run available checks on input fields and when add_component! is called. Throws InvalidValue if an error is found.
  • time_series_in_memory::Bool=false: Store time series data in memory instead of HDF5.
  • enable_compression::Bool=false: Enable compression of time series data in HDF5.
  • compression::CompressionSettings: Allows customization of HDF5 compression settings.
  • config_path::String: specify path to validation config file
source
PowerSystems.SystemMethod
System(
    sys_file::AbstractString,
    dyr_file::AbstractString;
    kwargs...
) -> Any

Parse static and dynamic data directly from PSS/e text files. Automatically generates all the relationships between the available dynamic injection models and the static counterpart

Each dictionary indexed by id contains a vector with 5 of its components:

  • Machine
  • Shaft
  • AVR
  • TurbineGov
  • PSS

Files must be parsed from a .raw file (PTI data format) and a .dyr file.

Examples:

raw_file = "Example.raw"
dyr_file = "Example.dyr"
sys = System(raw_file, dyr_file)
source
PowerSystems.SystemMethod
System(
    file_path::AbstractString;
    assign_new_uuids,
    kwargs...
) -> Any

Constructs a System from a file path ending with .m, .RAW, or .json

If the file is JSON then assignnewuuids = true will generate new UUIDs for the system and all components.

source
PowerSystems.SystemMethod
System(
    data,
    base_power::Number;
    internal,
    kwargs...
) -> System

Construct a System from InfrastructureSystems.SystemData

source
PowerSystems.SystemMethod
System(
    base_power::Float64,
    buses::Vector{ACBus},
    components...;
    kwargs...
) -> System

System constructor when components are constructed externally.

source
PowerSystems.SystemMethod
System(
    ::Nothing;
    buses,
    generators,
    loads,
    branches,
    storage,
    base_power,
    services,
    kwargs...
) -> System

Constructs a non-functional System for demo purposes.

source
PowerSystems.SystemMethod
System(base_power::Number; kwargs...) -> System

Construct an empty System. Useful for building a System while parsing raw data.

source
PowerSystems.SystemMethod
System(
    data::PowerSystemTableData;
    time_series_resolution,
    time_series_in_memory,
    time_series_directory,
    runchecks,
    kwargs...
) -> System

Construct a System from PowerSystemTableData data.

Arguments

  • time_series_resolution::Union{DateTime, Nothing}=nothing: only store time_series that match this resolution.
  • time_series_in_memory::Bool=false: Store time series data in memory instead of HDF5 file
  • time_series_directory=nothing: Store time series data in directory instead of tmpfs
  • runchecks::Bool=true: Validate struct fields.

Throws DataFormatError if time_series with multiple resolutions are detected.

  • A time_series has a different resolution than others.
  • A time_series has a different horizon than others.
source
PowerSystems.SystemMethod
System(pm_data::PowerModelsData; kwargs...) -> Any

Constructs a System from PowerModelsData.

Arguments

  • pm_data::Union{PowerModelsData, Union{String, IO}}: PowerModels data object or supported

load flow case (*.m, *.raw)

Keyword arguments

  • ext::Dict: Contains user-defined parameters. Should only contain standard types.
  • runchecks::Bool: Run available checks on input fields and when add_component! is called. Throws InvalidValue if an error is found.
  • time_series_in_memory::Bool=false: Store time series data in memory instead of HDF5.
  • config_path::String: specify path to validation config file
  • pm_data_corrections::Bool=true : Run the PowerModels data corrections (aka :validate in PowerModels)
  • import_all:Bool=false : Import all fields from PTI files

Examples

sys = System(
    pm_data, config_path = "ACTIVSg25k_validation.json",
    bus_name_formatter = x->string(x["name"]*"-"*string(x["index"])),
    load_name_formatter = x->strip(join(x["source_id"], "_"))
)
source
InfrastructureSystems.get_time_series_multipleFunction
get_time_series_multiple(sys::System; ...) -> Channel{Any}
get_time_series_multiple(
    sys::System,
    filter_func;
    type,
    name
) -> Channel{Any}

Return an iterator of time series in order of initial time.

Note that passing a filter function can be much slower than the other filtering parameters because it reads time series data from media.

Call collect on the result to get an array.

Arguments

  • data::SystemData: system
  • filter_func = nothing: Only return time series for which this returns true.
  • type = nothing: Only return time series with this type.
  • name = nothing: Only return time series matching this value.

Examples

for time_series in get_time_series_multiple(sys)
    @show time_series
end

ts = collect(get_time_series_multiple(sys; type = SingleTimeSeries))
source
InfrastructureSystems.set_name!Method
set_name!(
    component::Component,
    name::AbstractString
) -> AbstractString

Set the name of a component.

Throws an exception if the component is attached to a system.

source
InfrastructureSystems.to_jsonMethod
to_json(
    sys::System,
    filename::AbstractString;
    user_data,
    pretty,
    force,
    runchecks
)

Serializes a system to a JSON string.

Arguments

  • sys::System: system
  • filename::AbstractString: filename to write

Keyword arguments

  • user_data::Union{Nothing, Dict} = nothing: optional metadata to record
  • pretty::Bool = false: whether to pretty-print the JSON
  • force::Bool = false: whether to overwrite existing files
  • check::Bool = false: whether to run system validation checks

Refer to check_component for exceptions thrown if check = true.

source
PowerSystems.add_component!Method
add_component!(
    sys::System,
    dyn_injector::DynamicInjection,
    static_injector::StaticInjection;
    kwargs...
)

Add a dynamic injector to the system.

Throws ArgumentError if the name does not match the staticinjector name. Throws ArgumentError if the staticinjector is not attached to the system.

All rules for the generic add_component! method also apply.

source
PowerSystems.add_component!Method
add_component!(
    sys::System,
    component::Component;
    skip_validation,
    kwargs...
)

Add a component to the system.

Throws ArgumentError if the component's name is already stored for its concrete type. Throws ArgumentError if any Component-specific rule is violated. Throws InvalidValue if any of the component's field values are outside of defined valid range.

Examples

sys = System(100.0)

# Add a single component.
add_component!(sys, bus)

# Add many at once.
buses = [bus1, bus2, bus3]
generators = [gen1, gen2, gen3]
foreach(x -> add_component!(sys, x), Iterators.flatten((buses, generators)))
source
PowerSystems.add_components!Method
add_components!(sys::System, components)

Add many components to the system at once.

Throws ArgumentError if the component's name is already stored for its concrete type. Throws ArgumentError if any Component-specific rule is violated. Throws InvalidValue if any of the component's field values are outside of defined valid range.

Examples

sys = System(100.0)

buses = [bus1, bus2, bus3]
generators = [gen1, gen2, gen3]
foreach(x -> add_component!(sys, x), Iterators.flatten((buses, generators)))
source
PowerSystems.add_service!Method
add_service!(device::Device, service::Service, sys::System)

Similar to add_service! but for Service and Device already stored in the system. Performs validation checks on the device and the system

Arguments

  • device::Device: Device
  • service::Service: Service
  • sys::System: system
source
PowerSystems.add_service!Method
add_service!(
    sys::System,
    service::Service,
    contributing_devices;
    kwargs...
)

Similar to add_component! but for services.

Arguments

  • sys::System: system
  • service::Service: service to add
  • contributing_devices: Must be an iterable of type Device
source
PowerSystems.add_service!Method
add_service!(
    sys::System,
    service::Service,
    contributing_device::Device;
    kwargs...
)

Similar to add_component! but for services.

Arguments

  • sys::System: system
  • service::Service: service to add
  • contributing_device::Device: Valid Device
source
PowerSystems.add_service!Method
add_service!(
    sys::System,
    service::StaticReserveGroup,
    contributing_services::Vector{<:Service};
    skip_validation,
    kwargs...
)

Similar to add_component! but for StaticReserveGroup.

Arguments

  • sys::System: system
  • service::StaticReserveGroup: service to add
  • contributing_services: contributing services to the group
source
PowerSystems.add_service!Method
add_service!(
    sys::System,
    service::StaticReserveGroup;
    skip_validation,
    kwargs...
)

Similar to add_component! but for StaticReserveGroup.

Arguments

  • sys::System: system
  • service::StaticReserveGroup: service to add
source
PowerSystems.add_time_series!Method
add_time_series!(
    sys::System,
    metadata_file::AbstractString;
    resolution
)

Add time series data from a metadata file or metadata descriptors.

Arguments

  • sys::System: system
  • metadata_file::AbstractString: metadata file for timeseries that includes an array of IS.TimeSeriesFileMetadata instances or a vector.
  • resolution::DateTime.Period=nothing: skip time series that don't match this resolution.
source
PowerSystems.add_time_series!Method
add_time_series!(
    sys::System,
    components,
    time_series::TimeSeriesData
)

Add the same time series data to multiple components.

This is significantly more efficent than calling add_time_series! for each component individually with the same data because in this case, only one time series array is stored.

Throws ArgumentError if a component is not stored in the system.

source
PowerSystems.add_time_series!Method
add_time_series!(
    sys::System,
    component::Component,
    time_series::TimeSeriesData
)

Add time series data to a component.

Throws ArgumentError if the component is not stored in the system.

source
PowerSystems.add_time_series!Method
add_time_series!(
    sys::System,
    file_metadata::Vector{InfrastructureSystems.TimeSeriesFileMetadata};
    resolution
)

Add time series data from a metadata file or metadata descriptors.

Arguments

  • sys::System: system
  • timeseries_metadata::Vector{IS.TimeSeriesFileMetadata}: metadata for timeseries
  • resolution::DateTime.Period=nothing: skip time series that don't match this resolution.
source
PowerSystems.check_componentMethod
check_component(sys::System, component::Component)

Check the values of a component.

Throws InvalidValue if any of the component's field values are outside of defined valid range or if the custom validate method for the type fails its check.

source
PowerSystems.check_time_series_consistencyMethod
check_time_series_consistency(
    sys::System,
    _::Type{T<:TimeSeriesData}
) -> Union{Nothing, Tuple{Any, Int64}}

Checks time series in the system for inconsistencies.

For SingleTimeSeries, returns a Tuple of initial_timestamp and length.

This is a no-op for subtypes of Forecast because those are already guaranteed to be consistent.

Throws InfrastructureSystems.InvalidValue if any time series is inconsistent.

source
PowerSystems.convert_component!Method
convert_component!(
    sys::System,
    line::Line,
    linetype::Type{MonitoredLine};
    kwargs...
)

Converts a Line component to a MonitoredLine component and replaces the original in the system

source
PowerSystems.convert_component!Method
convert_component!(
    sys::System,
    line::MonitoredLine,
    linetype::Type{Line};
    kwargs...
)

Converts a MonitoredLine component to a Line component and replaces the original in the system

source
PowerSystems.convert_component!Method
convert_component!(
    sys::System,
    old_load::PowerLoad,
    new_type::Type{StandardLoad};
    kwargs...
)

Converts a PowerLoad component to a StandardLoad component and replaces the original in the system. Does not set any fields in StandardLoad that lack a PowerLoad equivalent

source
PowerSystems.get_busesMethod
get_buses(
    sys::System,
    aggregator::AggregationTopology
) -> Vector{ACBus}

Return a vector of buses contained within the AggregationTopology.

source
PowerSystems.get_busesMethod
get_buses(
    sys::System,
    bus_numbers::Set{Int64}
) -> Vector{ACBus}

Return all buses values with bus_numbers.

source
PowerSystems.get_componentMethod
get_component(
    _::Type{T<:Component},
    sys::System,
    name::AbstractString
) -> Any

Get the component of type T with name. Returns nothing if no component matches. If T is an abstract type then the names of components across all subtypes of T must be unique.

See get_components_by_name for abstract types with non-unique names across subtypes.

Throws ArgumentError if T is not a concrete type and there is more than one component with requested name

source
PowerSystems.get_componentsMethod
get_components(
    _::Type{T<:Component},
    sys::System
) -> InfrastructureSystems.FlattenIteratorWrapper{T, I} where {T<:Component, I<:(Vector)}

Returns an iterator of components. T can be concrete or abstract. Call collect on the result if an array is desired.

Examples

iter = PowerSystems.get_components(ThermalStandard, sys)
iter = PowerSystems.get_components(Generator, sys)
iter = PowerSystems.get_components(x -> PowerSystems.get_available(x), Generator, sys)
thermal_gens = get_components(ThermalStandard, sys) do gen
    get_available(gen)
end
generators = collect(PowerSystems.get_components(Generator, sys))

See also: iterate_components

source
PowerSystems.get_components_by_nameMethod
get_components_by_name(
    _::Type{T<:Component},
    sys::System,
    name::AbstractString
) -> Vector{T} where T<:InfrastructureSystems.InfrastructureSystemsComponent

Get the components of abstract type T with name. Note that PowerSystems enforces unique names on each concrete type but not across concrete types.

See get_component if the concrete type is known.

Throws ArgumentError if T is not an abstract type.

source
PowerSystems.get_components_in_aggregation_topologyMethod
get_components_in_aggregation_topology(
    _::Type{T<:StaticInjection},
    sys::System,
    aggregator::AggregationTopology
) -> Vector{T} where T<:StaticInjection

Return a vector of components with buses in the AggregationTopology.

source
PowerSystems.get_extMethod
get_ext(sys::System) -> Union{Nothing, Dict{String, Any}}

Return a user-modifiable dictionary to store extra information.

source
PowerSystems.get_time_series_countsMethod
get_time_series_counts(
    sys::System
) -> Tuple{Int64, Any, Any}

Return a tuple of counts of components with time series and total time series and forecasts.

source
PowerSystems.remove_component!Method
remove_component!(sys::System, component::Component)

Remove a component from the system by its value.

Throws ArgumentError if the component is not stored.

source
PowerSystems.remove_component!Method
remove_component!(
    _::Type{T<:Component},
    sys::System,
    name::AbstractString
)

Remove a component from the system by its name.

Throws ArgumentError if the component is not stored.

source
PowerSystems.remove_time_series!Method
remove_time_series!(
    sys::System,
    _::Type{T<:TimeSeriesData},
    component::Component,
    name::String
)

Remove the time series data for a component and time series type.

source
PowerSystems.set_runchecks!Method
set_runchecks!(sys::System, value::Bool)

Enable or disable system checks. Applies to component addition as well as overall system consistency.

source
PowerSystems.set_units_base_system!Method
set_units_base_system!(system::System, settings::String)

Sets the units base for the getter functions on the devices. It modifies the behavior of all getter functions

source

Additional Component Methods

PowerSystems.get_max_reactive_powerMethod
get_max_reactive_power(d::RenewableDispatch) -> Any

Return the max reactive power for the Renewable Generation calculated as the rating * powerfactor if reactivepower_limits is nothing

source
InfrastructureSystems.get_time_seriesMethod
get_time_series(
    ::Type{T<:TimeSeriesData},
    component::InfrastructureSystems.InfrastructureSystemsComponent,
    name::AbstractString;
    start_time,
    len,
    count
) -> Any

Return a time series corresponding to the given parameters.

Arguments

  • ::Type{T}: Concrete subtype of TimeSeriesData to return
  • component::InfrastructureSystemsComponent: Component containing the time series
  • name::AbstractString: name of time series
  • start_time::Union{Nothing, Dates.DateTime} = nothing: If nothing, use the initial_timestamp of the time series. If T is a subtype of Forecast then start_time must be the first timstamp of a window.
  • len::Union{Nothing, Int} = nothing: Length in the time dimension. If nothing, use the entire length.
  • count::Union{Nothing, Int} = nothing: Only applicable to subtypes of Forecast. Number of forecast windows starting at start_time to return. Defaults to all available.
InfrastructureSystems.get_time_series_arrayFunction
get_time_series_array(
    component::InfrastructureSystems.InfrastructureSystemsComponent,
    time_series::StaticTimeSeries;
    ...
) -> Any
get_time_series_array(
    component::InfrastructureSystems.InfrastructureSystemsComponent,
    time_series::StaticTimeSeries,
    start_time::Union{Nothing, Dates.DateTime};
    len,
    ignore_scaling_factors
) -> Any

Return a TimeSeries.TimeArray from a cached StaticTimeSeries instance.

If the data are scaling factors then the stored scalingfactormultiplier will be called on the component and applied to the data unless ignorescalingfactors is true.

See also StaticTimeSeriesCache.

InfrastructureSystems.get_time_series_arrayMethod
get_time_series_array(
    component::InfrastructureSystems.InfrastructureSystemsComponent,
    forecast::Forecast,
    start_time::Dates.DateTime;
    len,
    ignore_scaling_factors
) -> Any

Return a TimeSeries.TimeArray for one forecast window from a cached Forecast instance.

If the data are scaling factors then the stored scalingfactormultiplier will be called on the component and applied to the data unless ignorescalingfactors is true.

See also ForecastCache.

InfrastructureSystems.get_time_series_arrayMethod
get_time_series_array(
    ::Type{T<:TimeSeriesData},
    component::InfrastructureSystems.InfrastructureSystemsComponent,
    name::AbstractString;
    start_time,
    len,
    ignore_scaling_factors
) -> Any

Return a TimeSeries.TimeArray from storage for the given time series parameters.

If the data are scaling factors then the stored scalingfactormultiplier will be called on the component and applied to the data unless ignorescalingfactors is true.

InfrastructureSystems.get_time_series_timestampsFunction
get_time_series_timestamps(
    component::InfrastructureSystems.InfrastructureSystemsComponent,
    time_series::StaticTimeSeries;
    ...
) -> Vector{D} where D<:Dates.TimeType
get_time_series_timestamps(
    component::InfrastructureSystems.InfrastructureSystemsComponent,
    time_series::StaticTimeSeries,
    start_time::Union{Nothing, Dates.DateTime};
    len
) -> Vector{D} where D<:Dates.TimeType

Return a vector of timestamps from a cached StaticTimeSeries instance.

InfrastructureSystems.get_time_series_timestampsFunction
get_time_series_timestamps(
    component::InfrastructureSystems.InfrastructureSystemsComponent,
    forecast::Forecast;
    ...
)
get_time_series_timestamps(
    component::InfrastructureSystems.InfrastructureSystemsComponent,
    forecast::Forecast,
    start_time::Union{Nothing, Dates.DateTime};
    len
) -> Vector{D} where D<:Dates.TimeType

Return a vector of timestamps from a cached Forecast instance.

InfrastructureSystems.get_time_series_timestampsMethod
get_time_series_timestamps(
    ::Type{T<:TimeSeriesData},
    component::InfrastructureSystems.InfrastructureSystemsComponent,
    name::AbstractString;
    start_time,
    len
) -> Vector{D} where D<:Dates.TimeType

Return a vector of timestamps from storage for the given time series parameters.

InfrastructureSystems.get_time_series_valuesFunction
get_time_series_values(
    component::InfrastructureSystems.InfrastructureSystemsComponent,
    time_series::StaticTimeSeries;
    ...
) -> Any
get_time_series_values(
    component::InfrastructureSystems.InfrastructureSystemsComponent,
    time_series::StaticTimeSeries,
    start_time::Union{Nothing, Dates.DateTime};
    len,
    ignore_scaling_factors
) -> Any

Return an Array of values from a cached StaticTimeSeries instance for the requested time series parameters.

InfrastructureSystems.get_time_series_valuesMethod
get_time_series_values(
    component::InfrastructureSystems.InfrastructureSystemsComponent,
    forecast::Forecast,
    start_time::Dates.DateTime;
    len,
    ignore_scaling_factors
) -> Any

Return an Array of values for one forecast window from a cached Forecast instance.

InfrastructureSystems.get_time_series_valuesMethod
get_time_series_values(
    ::Type{T<:TimeSeriesData},
    component::InfrastructureSystems.InfrastructureSystemsComponent,
    name::AbstractString;
    start_time,
    len,
    ignore_scaling_factors
) -> Any

Return an Array of values from storage for the requested time series parameters.

If the data size is small and this will be called many times, consider using the version that accepts a cached TimeSeriesData instance.

Network Matrices

Power Flow

Parsing

PowerSystems.PowerSystemTableDataMethod
PowerSystemTableData(
    directory::AbstractString,
    base_power::Float64,
    user_descriptor_file::AbstractString;
    descriptor_file,
    generator_mapping_file,
    timeseries_metadata_file
) -> PowerSystemTableData

Reads in all the data stored in csv files The general format for data is folder: gen.csv branch.csv bus.csv .. load.csv

Arguments

  • directory::AbstractString: directory containing CSV files
  • base_power::Float64: base power for System
  • user_descriptor_file::AbstractString: customized input descriptor file
  • descriptor_file=POWER_SYSTEM_DESCRIPTOR_FILE: PowerSystems descriptor file
  • generator_mapping_file=GENERATOR_MAPPING_FILE: generator mapping configuration file
source
PowerSystems.PowerModelsDataMethod
PowerModelsData(
    file::Union{IO, String};
    kwargs...
) -> PowerModelsData

Constructs PowerModelsData from a raw file. Currently Supports MATPOWER and PSSE data files parsed by PowerModels.

source
PowerSystems.TamuSystemMethod
TamuSystem(tamu_folder::AbstractString; kwargs...) -> Any

Creates a system from a PSS/e .RAW (v33) load flow case, and an associated .csv with MW load time series data. The format is established by the Texas A&M University Test Case Archive

The general format for data is folder: [casename].raw [casename]loadtimeseriesMW.csv

Arguments

  • directory::AbstractString: directory containing RAW and CSV files

Examples

sys = TamuSystem(
    "./ACTIVSg25k",
    config_path = "ACTIVSg25k_validation.json",
    bus_name_formatter = x->string(x["name"]*"-"*string(x["index"])),
    load_name_formatter = x->strip(join(x["source_id"], "_"))
)
source
PowerSystems.add_dyn_injectors!Method
add_dyn_injectors!(sys::System, dyr_file::AbstractString)

Add to a system already created the dynamic components. The system should already be parsed from a .raw file.

Examples:

dyr_file = "Example.dyr"
add_dyn_injectors!(sys, dyr_file)
source

Logging

PowerSystems.configure_loggingMethod
configure_logging(
;
    console_level,
    file_level,
    filename
) -> MultiLogger

Creates console and file loggers.

Note: Log messages may not be written to the file until flush() or close() is called on the returned logger.

Arguments

  • console_level = Logging.Error: level for console messages
  • file_level = Logging.Info: level for file messages
  • filename::Union{Nothing, AbstractString} = "power-systems.log": log file; pass nothing to disable file logging

Example

logger = configure_logging(console_level = Logging.Info)
@info "log message"
close(logger)
source