Pattern for Edge and Bus models
- make a
mutable struct
usingwith_kw
(for ease of parameter validation) forYourType
- subtype either
AbstractEdge
orAbstractBus
- any required fields should have no default
- any optional fields should have default of
missing
- subtype either
- Define a constructor
function build_{your_types}
for your new edge or bus that takes adict
as the only argument- the
dict
is parsed fromyaml
orjson
file(s). For example, thebuild_loads
function requires a:loads
key in thedict
- replace any
missing
fields that must be derived from user inputs (i.e. things needed in the power flow model)- for example, in a
Load
the reactive power can be derived using theq_to_p
value
- for example, in a
- the constructor function must return a subtype of
AbstractVector{YourType}
- the
- Ensure commptibilty with the
MetaGraph
- If you subtyped
AbstractEdge
make sure theAbstractVector{YourType}
returned from your
fill_edge_attributes!
.- If you subtyped
AbstractBus
make sure theAbstractVector{YourType}
returned from your
fill_node_attributes!
. - If you subtyped
The fill_{edge,node}_attributes!
methods are used in the Network
builder to store all the attributes of YourType
in the Network.graph
. The Network.graph
is used to build the power flow models – so you also will probably need to modify BranchFlowModel.jl
to account for your new type. (But in the future we might be able to handle abstract edge or bus models that implement a certain set of attributes).
You might also want to extend the Network
interface for your type. For example, when adding the Load
type we added:
load_busses(net::AbstractNetwork) = (b for b in busses(net) if haskey(net[b], :Load))