Gas Model
All methods for constructing gasmodels should be defined on the following type:
GasModels.GenericGasModel
— Type.mutable struct GenericGasModel{T<:AbstractGasFormulation}
model::JuMP.Model
data::Dict{String,Any}
setting::Dict{String,Any}
solution::Dict{String,Any}
var::Dict{Symbol,Any} # model variable lookup
constraint::Dict{Symbol, Dict{Any, ConstraintRef}} # model constraint lookup
ref::Dict{Symbol,Any} # reference data
ext::Dict{Symbol,Any} # user extensions
end
where
data
is the original data, usually from reading in a.json
file,setting
usually looks something likeDict("output" => Dict("flows" => true))
, andref
is a place to store commonly used pre-computed data from of the data dictionary, primarily for converting data-types, filtering out deactivated components, and storing system-wide values that need to be computed globally. Seebuild_ref(data)
for further details.
Methods on GenericGasModel
for defining variables and adding constraints should
- work with the
ref
dict, rather than the originaldata
dict, - add them to
model::JuMP.Model
, and - follow the conventions for variable and constraint names.
which utilizes the following (internal) functions:
GasModels.build_ref
— Function.Returns a dict that stores commonly used pre-computed data from of the data dictionary, primarily for converting data-types, filtering out deactivated components, and storing system-wide values that need to be computed globally.
Some of the common keys include:
:max_mass_flow
(seemax_mass_flow(data)
),:connection
– the set of connections that are active in the network (based on the component status values),:pipe
– the set of connections that are pipes (based on the component type values),:short_pipe
– the set of connections that are short pipes (based on the component type values),:compressor
– the set of connections that are compressors (based on the component type values),:valve
– the set of connections that are valves (based on the component type values),:control_valve
– the set of connections that are control valves (based on the component type values),:resistor
– the set of connections that are resistors (based on the component type values),:parallel_connections
– the set of all existing connections between junction pairs (i,j),:all_parallel_connections
– the set of all existing and new connections between junction pairs (i,j),:junction_connections
– the set of all existing connections of junction i,:junction_ne_connections
– the set of all new connections of junction i,:junction_consumers
– the mappingDict(i => [consumer["ql_junc"] for (i,consumer) in ref[:consumer]])
.:junction_producers
– the mappingDict(i => [producer["qg_junc"] for (i,producer) in ref[:producer]])
.junction[degree]
– the degree of junction i using existing connections (seeadd_degree
)),junction[all_degree]
– the degree of junction i using existing and new connections (seeadd_degree
)),connection[pd_min,pd_max]
– the max and min square pressure difference (seeadd_pd_bounds_swr
)),
If :ne_connection
does not exist, then an empty reference is added If status
does not exist in the data, then 1 is added If construction cost
does not exist in the :ne_connection
, then 0 is added