States, Solutions & Plotting
In order to properly interact with the state space of the power grid model, we defined two data structures PowerDynamics.State
and PowerDynamics.PowerGridSolution
.
States
PowerDynamics.State
— Type
State(base; t=nothing)
State(grid, vec; t=nothing)
Encode the information on the value of a state vector at a particular time point.
Keyword Arguments
- Use a
PowerGrid
instancegrid
and a properly sized state vectorvec
to instantiate aState
.
Indexing
Concerning the indexing, a State
object $s$ basically behaves like a an array. There are plenty of convenient ways to access its contents at a node $j$ by using a particular symbol:
s[j, :u]
: complex voltages[j, :v]
: voltage magnitudes[j, :φ]
: voltage angles[j, :i]
: complex nodal currents[j, :iabs]
: nodal current magnitudes[j, :δ]
: nodal current angles[j, :s]
: apparent powers[j, :p]
: real powers[j, :q]
: reactive power
Currently, setting the state value is only implemented for $u$ and $v$, the other quantities are derived automatically.
You can access (and set) the $k$-th variable by calling
s[j, :var, k]
.
The variables can be also directly accessed with symbols, i.e.
s[j, :ω]
returns the frequency $ω$ at node $j$. To find out the proper symbol, the easiest way is to look into the docs of the corresponding node type, check the output of symbolsof or simply look at the output of println
:
julia> symbolsof(SwingEq(H=2, P=3, D=4, Ω=5))
1-element Array{Symbol,1}:
:ω
julia> println(SwingEq(H=2, P=3, D=4, Ω=5))
SwingEq[:ω](H=2, P=3, D=4, Ω=5)
Solutions & Plotting
PowerDynamics.PowerGridSolution
— Typestruct PowerGridSolution
dqsol::AbstractTimeseriesSolution
powergrid::PowerGrid
end
The data structure interfacing to the solution of the differential equations of a power grid. Normally, it is not created by hand but return from PowerDynSolve.solve
.
Accessing the solution in a similar interface as State
.
For some grid solution sol
, one can access the variables as
sol(t, n, s)
where t
is the time (either float or array), n
the node number(s) (either integer, array, range (e.g. 2:3) or colon (:, for all nodes)), and s
is the symbol represnting the chosen value. s
can be either: :v
, :φ
, :i
, :iabs
, :δ
, :s
, :p
, :q
, or the symbol of the internal variable of the nodes. The meaning of the symbols derives from the conventions of PowerDynamics.jl. Finally, one can access the a
-th internal variable of a node by using sol(t, n, :int, a)
.
Interfacing the Plots.jl library via plotting recipes, that follow similar instructions as the direct access to the solution.
For some grid solution sol
, one plot variables of the solution asin
using Plots
plot(sol, n, s, plots_kwargs...)
where n
and s
are as in the accessing of plots, and plots_kwargs
are the keyword arguments for Plots.jl.