GasModel

Gas Model

All methods for constructing gasmodels should be defined on the following 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 like Dict("output" => Dict("flows" => true)), and
  • ref 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. See build_ref(data) for further details.

Methods on GenericGasModel for defining variables and adding constraints should

  • work with the ref dict, rather than the original data dict,
  • add them to model::JuMP.Model, and
  • follow the conventions for variable and constraint names.
source

which utilizes the following (internal) functions:

GasModels.build_refFunction.

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 (see max_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 mapping Dict(i => [consumer["ql_junc"] for (i,consumer) in ref[:consumer]]).
  • :junction_producers – the mapping Dict(i => [producer["qg_junc"] for (i,producer) in ref[:producer]]).
  • :degree – the degree of junction i using existing connections (see degree_ref!)),
  • degree_ne – the degree of junction i using existing and new connections (see degree_ne_ref!)),
  • :pd_min,:pd_max – the max and min square pressure difference (see calc_pd_bounds_sqr)),
source