Internal
PowerFlows.SystemPowerFlowContainer
— TypeA PowerFlowContainer
that represents its data as a PSY.System
PowerFlows._first_choice_gen_id
— MethodTry to make an informative one or two character name for the load/generator/etc.
- "generator-1234-AB" -> "AB"
- "123CT7" -> "7"
- "load1234" -> "34"
PowerFlows._get_load_data
— MethodObtain total load on bus b
PowerFlows._map_psse_container_names
— MethodValidate that the Sienna area/zone names parse as PSS/E-compatible area/zone numbers, output a mapping
PowerFlows._psse_bus_names
— MethodGiven a vector of Sienna bus names, create a dictionary from Sienna bus name to PSS/E-compatible bus name. Guarantees determinism and minimal changes.
WRITTEN TO SPEC: PSS/E 33.3 POM 5.2.1 Bus Data
PowerFlows._psse_bus_numbers
— MethodGiven a vector of Sienna bus numbers, create a dictionary from Sienna bus number to PSS/E-compatible bus number. Assumes that the Sienna bus numbers are positive and unique. Guarantees determinism: if the input contains the same bus numbers in the same order, the output will. Guarantees minimal changes: that if an existing bus number is compliant, it will not be changed.
WRITTEN TO SPEC: PSS/E 33.3 POM 5.2.1 Bus Data
PowerFlows._psse_transformer_names
— MethodGiven a vector of Sienna transformer names, create a dictionary from Sienna transformer name to PSS/E-compatible transformer name. Guarantees determinism and minimal changes.
WRITTEN TO SPEC: PSS/E 33.3 POM 5.2.1 Transformer Data
PowerFlows._update_branch_flow!
— MethodUpdates the flow on the branches
PowerFlows.better_float_to_buf
— MethodTemporary, very specialized proof of concept patch for https://github.com/JuliaLang/julia/issues/55835
PowerFlows.check_33
— MethodThrow a NotImplementedError
if the psse_version
is not :v33
PowerFlows.convert_empty
— MethodIf val
is empty, returns T()
; if not, asserts that val isa T
and returns val
. Has nice type checker semantics.
Examples
convert_empty(Vector{String}, []) # -> String[]
convert_empty(Vector{String}, ["a"]) # -> ["a"]
convert_empty(Vector{String}, [2]) # -> TypeError: in typeassert, expected Vector{String}, got a value of type Vector{Int64}
Base.return_types(Base.Fix1(convert_empty, Vector{String})) # -> [Vector{String}]
PowerFlows.create_component_ids
— MethodGiven a vector of component names and a corresponding vector of container IDs (e.g., bus numbers), create unique-per-container PSS/E-compatible IDs, output a dictionary from (container ID, component name) to PSS/E-compatible component ID. The "singlesto1" flag detects components that are the only one on their bus and gives them the name "1".
PowerFlows.flatten_power_flow_evaluation_model
— MethodExpand a single PowerFlowEvaluationModel
into its possibly multiple parts for separate evaluation. Namely, if pfem
contains a non-nothing exporter
, return [pfem, exporter]
, else return [pfem]
.
PowerFlows.flow_func
— MethodCalculates the From - To complex power flow using external data of voltages of branch of type Line
PowerFlows.flow_func
— MethodCalculates the From - To complex power flow using external data of voltages of branch of type TapTransformer
PowerFlows.flow_func
— MethodCalculates the From - To complex power flow using external data of voltages of branch of type Transformer2W
PowerFlows.flow_val
— MethodCalculates the From - To complex power flow (Flow injected at the bus) of branch of type Line
PowerFlows.flow_val
— MethodCalculates the From - To complex power flow (Flow injected at the bus) of branch of type Line
PowerFlows.flow_val
— MethodCalculates the From - To complex power flow (Flow injected at the bus) of branch of type TapTransformer
PowerFlows.flow_val
— MethodCalculates the From - To complex power flow (Flow injected at the bus) of branch of type Transformer2W
PowerFlows.get_active_power_limits_for_power_flow
— MethodReturn the active power limits that should be used in power flow calculations and PSS/E exports. Redirects to PSY.get_active_power_limits
in all but special cases.
PowerFlows.get_reactive_power_limits_for_power_flow
— MethodReturn the reactive power limits that should be used in power flow calculations and PSS/E exports. Redirects to PSY.get_reactive_power_limits
in all but special cases.
PowerFlows.make_power_flow_container
— FunctionCreate an appropriate PowerFlowContainer
for the given PowerFlowEvaluationModel
and initialize it from the given PSY.System
.
Arguments:
pfem::PowerFlowEvaluationModel
: power flow model to construct a container for (e.g.,DCPowerFlow()
)sys::PSY.System
: the system from which to initialize the power flow containertime_steps::Int
: number of time periods to consider (default is1
)timestep_names::Vector{String}
: names of the time periods defines by the argument "time_steps". Default value isString[]
.check_connectivity::Bool
: Perform connectivity check on the network matrix. Default value istrue
.
PowerFlows.penalty_factors!
— Methodpenalty_factors!(J::SparseMatrixCSC{Float64, Int64}, dSbus_dV_ref::Vector{Float64}, destination::SubArray{Float64})
Compute the penalty factors (active power loss factors) and store the result in destination
, which is the view in the loss_factors
matrix of the
PowerFlowData`. The loss factors are computed using the Jacobian matrix
Jand the vector of partial derivatives of slack power with respect to bus voltages (angle and magnitude)
dSbusdVref`. The approach is interpreting the change in slack active power injection as the change of the grid active power losses. The function uses the KLU library for sparse matrix factorization to calculate the loss factors. The loss factors are a linear approximation of the change in slack active power injection respect to the change in active power injections at each bus.
Arguments
J::SparseMatrixCSC{Float64, Int64}
: The Jacobian matrix in sparse format.dSbus_dV_ref::Vector{Float64}
: The reference vector for the change in slack bus power with respect to bus voltages (PV, PQ buses for voltage angle, PQ buses for voltage magnitude).destination::SubArray{Float64}
: The view in the penalty factors matrix where the computed penalty factors will be stored.
PowerFlows.reset_caches
— MethodForce all cached information (serialized metadata, component lists, etc.) to be regenerated
PowerFlows.serialize_component_ids
— MethodTake the output of create_component_ids
and make it more suitable for JSON serialization
PowerFlows.supports_multi_period
— MethodTrait signifying whether the PowerFlowContainer
can represent multi-period data. Must be implemented for all concrete subtypes.
PowerFlows.update_system!
— MethodModify the values in the given System
to correspond to the given PowerFlowData
such that if a new PowerFlowData
is constructed from the resulting system it is the same as data
. See also write_powerflow_solution!
. NOTE that this assumes that data
was initialized from sys
and then solved with no further modifications.
PowerFlows.write_powerflow_solution!
— MethodUpdates system voltages and powers with power flow results
PowerFlows.write_to_buffers!
— MethodWRITTEN TO SPEC: PSS/E 33.3 POM 5.2.1 Bus Data. Sienna voltage limits treated as PSS/E normal voltage limits; PSSE emergency voltage limits left as default.
PowerFlows.write_to_buffers!
— MethodWRITTEN TO SPEC: PSS/E 33.3 POM 5.2.1 Case Identification Data
PowerFlows.write_to_buffers!
— MethodWRITTEN TO SPEC: PSS/E 33.3 POM 5.2.1 Fixed Bus Shunt Data
PowerFlows.write_to_buffers!
— MethodIf the exportsettings flag `sourcesasgeneratorsis set, export
PSY.Sourceinstances as PSS/E generators in addition to
PSY.Generators. Same for
storagesas_generatorsand
PSY.Storage`.
WRITTEN TO SPEC: PSS/E 33.3 POM 5.2.1 Generator Data
PowerFlows.write_to_buffers!
— MethodWRITTEN TO SPEC: PSS/E 33.3 POM 5.2.1 Load Data
PowerFlows.write_to_buffers!
— MethodWRITTEN TO SPEC: PSS/E 33.3 POM 5.2.1 Non-Transformer Branch Data
PowerFlows.write_to_buffers!
— MethodWRITTEN TO SPEC: PSS/E 33.3 POM 5.2.1 Q Record
PowerFlows.write_to_buffers!
— MethodCurrently only supports two-winding transformers
WRITTEN TO SPEC: PSS/E 33.3 POM 5.2.1 Transformer Data
PowerFlows.write_to_buffers!
— MethodWRITTEN TO SPEC: PSS/E 33.3 POM 5.2.1 Zone Data