Constraints
Constraint Templates
Constraint templates help simplify data wrangling across multiple Gas Flow formulations by providing an abstraction layer between the network data and network constraint definitions. The constraint template's job is to extract the required parameters from a given network data structure and pass the data as named arguments to the Gas Flow formulations.
These templates should be defined over AbstractGasModel
and should not refer to model variables. For more details, see the files: core/constraint_template.jl
and core/constraint.jl
.
Junction Constraints
Flow balance constraints
The primary constraints related to junctions ensure that mass flow is balanced at these nodes. The specifics of the constraint implementation will change if there are network design options (denoted by \_ne
in the name of the function).
GasModels.constraint_mass_flow_balance
— FunctionConstraint: standard flow balance equation where demand and production are variables
Template: Constraints for mass flow balance equation where demand and production is are a mix of constants and variables
Constraint: standard flow balance equation where demand and production are variables
GasModels.constraint_mass_flow_balance_ne
— FunctionConstraint: standard flow balance equation where demand and production are variables and there are expansion connections
Template: Constraints for mass flow balance equation where demand and production is are a mix of constants and variables and there are expansion connections
Constraint: standard flow balance equation where demand and production are variables and there are expansion connections
Direction On/off Constraints
The disjunctive forms of problems (where directions are controlled by on/off variables) include special (redundant) constraints which tie the direction variables together. Examples include ensuring that ensure at least one edge of junction that has only sources of natural gas has outgoing flow.
GasModels.constraint_source_flow
— FunctionConstraint: Make sure there is at least one direction set to take flow away from a junction (typically used on source nodes)
Template: Constraints for ensuring that at least one direction is set to take flow away from a junction (typically used on source nodes)
GasModels.constraint_sink_flow
— FunctionConstraint: Make sure there is at least one direction set to take flow to a junction (typically used on sink nodes)
Template: Constraints for ensuring that at least one direction is set to take flow away from a junction (typically used on sink nodes)
GasModels.constraint_conserve_flow
— FunctionConstraint: This constraint is intended to ensure that flow is one direction through a node with degree 2 and no production or consumption
Template: Constraints to ensure that flow is the same direction through a node with degree 2 and no production or consumption
GasModels.constraint_source_flow_ne
— FunctionConstraint: Make sure there is at least one direction set to take flow away from a junction (typically used on source nodes)
Template: Constraints for ensuring that at least one direction is set to take flow away from a junction (typically used on source nodes)
GasModels.constraint_sink_flow_ne
— FunctionConstraint: Make sure there is at least one direction set to take flow to a junction (typically used on sink nodes)
Template: Constraints for ensuring that at least one direction is set to take flow away from a junction (typically used on sink nodes)
GasModels.constraint_conserve_flow_ne
— FunctionConstraint: This constraint is intended to ensure that flow is on direction through a node with degree 2 and no production or consumption for a node with expansion edges
Template: Constraints to ensure that flow is the same direction through a node with degree 2 and no production or consumption
Pipe Constraints
Weymouth's law constraints
The primary constraints related to pipes ensure that that pressure drop and flow across a pipe is related through the Weymouth relationships. Here, the naming convention ne
is used to denote the form of the constraint used for expansion pipes and directed
is used to denote the form of the constraint used when the direction of flow is constrained.
GasModels.constraint_pipe_weymouth
— FunctionTemplate: Weymouth equation for defining the relationship between pressure drop and flow across a pipe
Constraint: Weymouth equation–not applicable for MIP models
Constraint: Weymouth equation–not applicable for LP models
Weymouth equation with absolute value
Weymouth equation with discrete direction variables
Weymouth equation for an undirected pipe
GasModels.constraint_pipe_weymouth_ne
— FunctionTemplate: Weymouth equation for expansion pipes
Constraint: Weymouth equation–not applicable for MIP models–not applicable for MIP models
Constraint: Weymouth equation–not applicable for MIP models–not applicable for LP models
Weymouth equation for an undirected expansion pipe
Weymouth equation for an undirected expansion pipe
Weymouth equation for an undirected expansion pipe
GasModels.constraint_pipe_weymouth_directed
— FunctionTemplate: Weymouth equation for defining the relationship between pressure drop and flow across a pipe where flow is constrained in one direction
Constraint: Weymouth equation with one way direction–not applicable for MIP models
Constraint: Weymouth equation with one way direction–not applicable for LP models
Weymouth equation with one way direction
Weymouth equation with one way direction
Weymouth equation with a pipe with one way flow
GasModels.constraint_pipe_weymouth_ne_directed
— FunctionTemplate: Weymouth equation for expansion pipes where flow is restricted to one direction
Constraint: Weymouth equation–not applicable for MIP models–not applicable for MIP models
Constraint: Weymouth equation–not applicable for MIP models–not applicable for LP models
Weymouth equation for directed expansion pipes
Weymouth equation for directed expansion pipes
Weymouth equation for expansion pipes with undirected expansion pipes
Mass flow and pressure drop constraints
Secondarily, there are constraints associated with limits on pressure drop or mass flow across pipes. These constraints also use the ne
and directed
naming conventions.
GasModels.constraint_pipe_mass_flow
— FunctionConstraint: Constraint on mass flow across the pipe
Template: Constraint on mass flow across a pipe
Constraint: Constraint on flow across a pipe when there are on/off direction variables
GasModels.constraint_pipe_pressure
— FunctionConstraint: Constraints which define pressure drop across a pipe
Template: Pressure drop across pipes with on/off direction variables
Constraint: Constraints which define pressure drop across a pipe when there are on/off direction variables
Constraint: Constraints which define pressure drop across a pipe
Constraint: Constraints which define pressure drop across a pipe
Network expansion constraints
These constraints turn on or off the association between pressure and flow for pipes desiginated as expansion options.
GasModels.constraint_pipe_ne
— FunctionConstraint: on/off constraints on flow across pipes for expansion pipes
Template: Constraint associatd with turning off flow depending on the status of expansion pipes
Direction on/off constraints
The disjunctive forms of problems (where directions are controlled by on/off variables) include special (redundant) constraints which tie the direction variables together. Examples include ensuring that ensuring that parallel pipes have flow in the same direction.
Missing docstring for constraint_parallel_flow
. Check Documenter's build log for details.
Missing docstring for constraint_parallel_flow_ne
. Check Documenter's build log for details.
Resistor Constraints
Weymouth's law constraints
The primary constraints related to resistor ensure that that pressure drop and flow across a resistor is related through the Weymouth relationships. Here, directed
is used to denote the form of the constraint used when the direction of flow is constrained.
GasModels.constraint_resistor_weymouth
— FunctionTemplate: Weymouth equation for defining the relationship between pressure drop and flow across a resistor
Constraint: Weymouth equation–not applicable for MIP models
Constraint: Weymouth equation–not applicable for LP models
Weymouth equation with absolute value
Weymouth equation with discrete direction variables
Weymouth equation for an undirected pipe
GasModels.constraint_resistor_weymouth_directed
— FunctionTemplate: Weymouth equation for defining the relationship between pressure drop and flow across a resistor where flow is constrained in one direction
Constraint: Weymouth equation with one way direction–not applicable for MIP models
Constraint: Weymouth equation with one way direction–not applicable for LP models
Weymouth equation with one way direction
Weymouth equation with one way direction
Weymouth equation with a resistor with one way flow
Mass flow and pressure drop constraints
Secondarily, there are constraints associated with limits on pressure drop or mass flow across pipes. These constraints also use the directed
naming conventions.
GasModels.constraint_resistor_mass_flow
— FunctionConstraint: Constraint on mass flow across the resistor
Template: Constraint on mass flow across a pipe
GasModels.constraint_resistor_pressure
— FunctionConstraint: Constraints which define pressure drop across a resistor
Template: Pressure drop across resistor with on/off direction variables
Constraint: Constraints which define pressure drop across a resistor
Constraint: Constraints which define pressure drop across a resistor
Direction on/off constraints
The disjunctive forms of problems (where directions are controlled by on/off variables) include special (redundant) constraints which tie the direction variables together. Examples include ensuring that ensuring that parallel pipes have flow in the same direction.
Missing docstring for constraint_parallel_flow
. Check Documenter's build log for details.
Missing docstring for constraint_parallel_flow_ne
. Check Documenter's build log for details.
Compressor Constraints
Operations Constraints
The primary constraints related to compressors ensure that that the compressors operate within the limits of their capability (boost ratio, energy consumption, etc.). These constraints use the ne
and directed
naming conventions to denote constraints where the compressor is an expansion option or direction of flow is fixed, respectively.
GasModels.constraint_compressor_ratios
— FunctionTemplate: Compression ratios for a compressor
Constraint: enforces pressure changes bounds that obey compression ratios for a compressor with on/off direction variables
Constraint: Compressor ratio constraints on pressure differentials–not applicable for MIP models
Constraint: Compressor ratio constraints on pressure differentials–not applicable for LP models
enforces pressure changes bounds that obey compression ratios for an undirected compressor.
GasModels.constraint_compressor_ratios_directed
— FunctionConstraint: Compressor ratio when the flow direction is constrained
Template: Constraints on compressor ratios when flow is restricted to one direction
Constraint: Compressor ratio when the flow direction is constrained–not applicable for MIP models
Constraint: Compressor ratio when the flow direction is constrained–not applicable for LP models
GasModels.constraint_compressor_ratios_ne
— FunctionTemplate: constraints on pressure drop across a compressor
Constraint: constraints on pressure drop across expansion compressors with on/off decision variables
Constraint: compressor ratios on a new compressor–not applicable for MIP models-not applicable for MIP models
Constraint: compressor ratios on a new compressor–not applicable for MIP models-not applicable for LP models
constraints on pressure drop across a compressor
GasModels.constraint_compressor_ratios_ne_directed
— FunctionConstraint: Pressure drop across an expansion compressor when direction is constrained
Template: Constraints on compressor ratios when flow is restricted to one direction and the compressor is an expanson option
Constraint: Pressure drop across an expansion compressor when direction is constrained-not applicable for MIP models
Constraint: Pressure drop across an expansion compressor when direction is constrained-not applicable for LP models
GasModels.constraint_compressor_mass_flow
— FunctionConstraint: constraints on flow across a compressor with on/off direction variables
Template: constraints on flow across a compressor
Constraint: constraints on flow across a compressor with on/off direction variables
Direction On/off Constraints
The disjunctive forms of problems (where directions are controlled by on/off variables) include special constraints to connect direction of flow with the choice of the binary variable.
Missing docstring for constraint_parallel_flow
. Check Documenter's build log for details.
Missing docstring for constraint_parallel_flow_ne
. Check Documenter's build log for details.
Network Expansion Constraints
Constraints are also used to turn on/off flow through a compressor in expansion planning formulations
GasModels.constraint_compressor_ne
— FunctionConstraint: on/off constraints on flow across compressors for expansion variables
Template: Constraint for turning on or off flow through expansion compressor
Control Valve Constraints
Operations Constraints
The primary constraints related to control valves ensure that that the valves operate within the limits of their capability (pressure reduction). These constraints use the directed
naming conventions to denote constraints where the control valve direction of flow is fixed. The control valve also has an open/close variable to determine whether or not flow is allowed through the valve
Missing docstring for constraint_on_off_control_valve_mass_flow
. Check Documenter's build log for details.
Missing docstring for constraint_on_off_control_valve_pressure
. Check Documenter's build log for details.
Missing docstring for constraint_on_off_control_valve_mass_flow_directed
. Check Documenter's build log for details.
Missing docstring for constraint_on_off_control_valve_pressure_directed
. Check Documenter's build log for details.
Direction On/off Constraints
The disjunctive forms of problems (where directions are controlled by on/off variables) include special constraints to connect direction of flow with the choice of the binary variable.
Missing docstring for constraint_parallel_flow
. Check Documenter's build log for details.
Missing docstring for constraint_parallel_flow_ne
. Check Documenter's build log for details.
Valve Constraints
Operations Constraints
The primary function of a valve is to open or close a pipe. These constraints use the directed
naming conventions to denote constraints where the valve direction of flow is fixed.
GasModels.constraint_on_off_valve_mass_flow
— Functionconstraints on flow across undirected valves
Template: constraints on flow across valves modeled with on/off direction variables
Constraint: Constraints on flow across valves with on/off direction variables
GasModels.constraint_on_off_valve_pressure
— FunctionConstraint: Constraints on pressure drop across valves where the valve can open or close
Template: Constraint on pressure drop across valves, where the valve may be closed or opened
Constraint: Constraints on pressure drop across valves where the valve can open or close–not applicable for MIP models
Constraint: Constraints on pressure drop across valves where the valve can open or close–not applicable for LP models
Direction On/off Constraints
The disjunctive forms of problems (where directions are controlled by on/off variables) include special constraints to connect direction of flow with the choice of the binary variable.
Missing docstring for constraint_parallel_flow
. Check Documenter's build log for details.
Missing docstring for constraint_parallel_flow_ne
. Check Documenter's build log for details.
Short Pipes
Pressure Constraints
Short pipes are used to model frictionless connections between junctions. The primary constraint ensures the pressure on both sides of the short pipe are the same. These constraints use the directed
naming conventions to denote constraints where the control valve direction of flow is fixed.
GasModels.constraint_short_pipe_pressure
— FunctionConstraint: Constraint on pressure drop across a short pipe
Template: Constraint on pressure drop across a short pipe
Constraint: Constraint on pressure drop across a short pipe–not applicable for MIP models
Constraint: Constraint on pressure drop across a short pipe–not applicable for LP models
GasModels.constraint_short_pipe_mass_flow
— FunctionConstraint: Constraints on flow across a short pipe with on/off direction variables
Constraint: constraints on flow across a short pipe
Constraint: Constraints on flow across a short pipe with on/off direction variables
Missing docstring for cconstraint_short_pipe_mass_flow_directed
. Check Documenter's build log for details.
Direction On/off Constraints
The disjunctive forms of problems (where directions are controlled by on/off variables) include special constraints to connect direction of flow with the choice of the binary variable.
Missing docstring for constraint_parallel_flow
. Check Documenter's build log for details.
Missing docstring for constraint_parallel_flow_ne
. Check Documenter's build log for details.