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_balanceFunction

Constraint: standard flow balance equation where demand and production are variables

source

Template: Constraints for mass flow balance equation where demand and production is are a mix of constants and variables

source

Constraint: standard flow balance equation where demand and production are variables

source
GasModels.constraint_mass_flow_balance_neFunction

Constraint: standard flow balance equation where demand and production are variables and there are expansion connections

source

Template: Constraints for mass flow balance equation where demand and production is are a mix of constants and variables and there are expansion connections

source

Constraint: standard flow balance equation where demand and production are variables and there are expansion connections

source

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_flowFunction

Constraint: Make sure there is at least one direction set to take flow away from a junction (typically used on source nodes)

source

Template: Constraints for ensuring that at least one direction is set to take flow away from a junction (typically used on source nodes)

source
GasModels.constraint_sink_flowFunction

Constraint: Make sure there is at least one direction set to take flow to a junction (typically used on sink nodes)

source

Template: Constraints for ensuring that at least one direction is set to take flow away from a junction (typically used on sink nodes)

source
GasModels.constraint_conserve_flowFunction

Constraint: This constraint is intended to ensure that flow is one direction through a node with degree 2 and no production or consumption

source

Template: Constraints to ensure that flow is the same direction through a node with degree 2 and no production or consumption

source
GasModels.constraint_source_flow_neFunction

Constraint: Make sure there is at least one direction set to take flow away from a junction (typically used on source nodes)

source

Template: Constraints for ensuring that at least one direction is set to take flow away from a junction (typically used on source nodes)

source
GasModels.constraint_sink_flow_neFunction

Constraint: Make sure there is at least one direction set to take flow to a junction (typically used on sink nodes)

source

Template: Constraints for ensuring that at least one direction is set to take flow away from a junction (typically used on sink nodes)

source
GasModels.constraint_conserve_flow_neFunction

Constraint: 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

source

Template: Constraints to ensure that flow is the same direction through a node with degree 2 and no production or consumption

source

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.

GasModels.constraint_pipe_weymouthFunction

Template: Weymouth equation for defining the relationship between pressure drop and flow across a pipe

source

Constraint: Weymouth equation–not applicable for LRDWP models

source

Constraint: Weymouth equation–not applicable for LRWP models

source

Weymouth equation with absolute value

source

Weymouth equation with discrete direction variables

Constraint 1:

This constraint should be active when flow goes from i to j. Pressure needs to decrease from i to j. y = 1 models this condition When y = 1, this constraint becomes w(pi - pj) >= f^2, which is only true when pi >= pj When y = 0, we have w(pi - pj) >= f^2 - fmin^2 + w*pdmin. By definition, w(pi - pj) <= 0. The lower bound on w(pi - pj) is w*pdmin. Since flow is reversed in this situation, f^2 is bounded by fmin^2. Thus f^2 - f_min^2 only further decreases the rhs. Thus, this constraint is always true (inactive when y = 0)

Constraint 2:

When y = 1, w(pi - pj) >= 0 this constraint needs to be active, so should be upper bounded by f^2 to get equality when combined with weymouth1

When y = 0, w(pi - pj) <= 0, making this constraint always true (inactive when y = 0)

Constraint 3:

This constraint should be active when flow goes from j to i. Pressure needs to decrease from j to i. y = 0 models this condition

When y = 0, this constraint becomes w*(pj - pi) >= f^2, which is only true when pj >= pi

When y = 1, we have w(pj - pi) >= f^2 - f_max^2 - wpd_max. By definition, w(pj - pi) <= 0. The lower bound on w(pi - pj) is

-w*pdmax (sign flip on pi amnd pj). Since flow is forward in this situation, f^2 is bounded by fmax^2. Thus f^2 - f_max^2 only further decreases the rhs.

Thus, this constraint is always true (inactive when y = 1)

Constraint 4:

When y = 0, w(pj - pi) >= 0 this constraint needs to be active, so should be upper bounded by f^2 to get equality when combined with weymouth3

When y = 1, w(pj - pi) <= 0, making this constraint always true (inactive when y = 1)

note the sign flip between pi and pj

source

Weymouth equation for a pipe

source
GasModels.constraint_pipe_weymouth_neFunction

Template: Weymouth equation for expansion pipes

source

Constraint: Weymouth equation

source

Constraint: Weymouth equation

source

Weymouth equation for an expansion pipe

source

Weymouth equation for an expansion pipe

Constraint 1:

When zp = 1, this constraint reduces to constraint weymouth1 in constraintpipeweymouth, which is what we want (i.e. an active constraint) When zp = 0, we want this constraint to be in active AND any y value should be valid. In this case, since f^2 = 0 (there is no flow) the constraint becomes w(pi - pj) >= -(1-y) * (f_min^2 - wpdmin) - abs(w*pdmin). When y = 1, we have w(pi - pj) >= -abs(wpdmin). Since pdmin is the lower bound on pi - pj, this is always true. When y = 0, we have w(pi - pj) >= -f_min^2 + wpdmin - abs(w*pdmin). Which is always true. wpd_min is the lower bound on wpi - pj and the other two terms just drive the lower bound further down.

Constraint 2:

When zp = 1, this constraint reduces to constraint weymouth2 in constraintpipeweymouth, which is what we want (i.e. an active constraint) When zp = 0, we have w(pi - pj) <= f^2 + wpdmax. Since w*pdmax is the upper bound on w*(pi-pj), this is always true.

Constraint 3:

When zp = 1, this constraint reduces to constraint weymouth3 in constraintpipeweymouth, which is what we want (i.e. an active constraint) When zp = 0, we want this constraint to be in active AND any y value should be valid. In this case, since f^2 = 0 (there is no flow) the constraint becomes w(pj - pi) >= - y * (f_max^2 + wpdmax) - abs(w*pdmax). When y = 0, we have w(pj - pi) >= -abs(wpdmax). Since -pdmax is the lower bound on pj - pi note reversal of pressure sign, this is always true. When y = 1, we have w(pj - pi) >= -f_max^2 - wpdmax - abs(w*pdmax). Which is always true. -wpd_max is the lower bound on w(pj - pi) (note the sign flip). The other two terms just drive the lower bound further down.

Constraint 4:

When zp = 1, this constraint reduces to constraint weymouth4 in constraintpipeweymouth, which is what we want (i.e. an active constraint)

When zp = 0, we have (pj - pi) <= f^2 - wpd_min). Since -wpd_min is the upper bound on w*(pj-pi)–the pi and pj are flipped, this is always true.

source

Weymouth equation for an expansion pipe

source
Missing docstring.

Missing docstring for constraint_pipe_weymouth_ne. Check Documenter's build log for details.

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 naming conventions.

GasModels.constraint_pipe_pressureFunction

Constraint: Constraints which define pressure drop across a pipe

source

Template: Pressure drop across pipes

source

Constraint: Constraints which define pressure drop across a pipe when there are on/off direction variables

source

Network expansion constraints

These constraints turn on or off the association between pressure and flow for pipes designated as expansion options.

GasModels.constraint_pipe_neFunction

Constraint: on/off constraints on flow across pipes for expansion pipes

source

Template: Constraint associatd with turning off flow depending on the status of expansion pipes

source

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.

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.

Missing docstring.

Missing docstring for constraint_resistor_weymouth. Check Documenter's build log for details.

Mass flow and pressure drop constraints

Secondarily, there are constraints associated with limits on pressure drop or mass flow across pipes.

GasModels.constraint_resistor_pressureFunction

Template: Pressure drop across resistor with on/off direction variables

source

Constraint: Define pressures across a resistor

source

Constraint: Define pressures across a resistor

source

Constraint: Constraints which define pressure drop across a resistor

source

Constraint: Define pressures across a resistor

source

Constraint: Define pressures across a resistor

source

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.

Loss Resistor Constraints

The primary constraints related to loss resistors ensure that the pressure drop is constant along each edge. They also ensure that squared pressure variables are somehow related to (nonsquared) pressure variables.

Mass flow and pressure drop constraints

GasModels.constraint_loss_resistor_pressureFunction

Template: Pressure drop across loss_resistor with on/off direction variables

source

Constraint: Constraints which define pressure drop across a loss resistor

source

Constraint: Constraints which define pressure drop across a loss resistor

source

Constraint: Constraints which define pressure drop across a loss resistor

source

Constraint: Constraints which define pressure drop across a loss resistor

source

Constraint: Constraints which define pressure drop across a loss resistor

source

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 naming conventions to denote constraints where the compressor is an expansion option.

GasModels.constraint_compressor_ratiosFunction

Template: Compression ratios for a compressor

source

Constraint: enforces pressure changes bounds that obey compression ratios for a compressor with on/off direction variables

source

Constraint: Compressor ratio constraints on pressure differentials–not applicable for LRWP models

source

enforces pressure changes bounds that obey compression ratios

source
GasModels.constraint_compressor_ratios_neFunction

Template: constraints on pressure drop across a compressor

source

Constraint: constraints on pressure drop across expansion compressors with on/off decision variables

source

Constraint: compressor ratios on a new compressor

source

constraints on pressure drop across a compressor

source
GasModels.constraint_compressor_energyFunction

Template: Constraints on the compressor energy

source

Constraint: constrains the energy of the compressor

source

Constraint: constrains the energy of the compressor

source

Constraint: constrains the energy of the compressor

source

Constraint: constrains the energy of the compressor

source

Constraint: constrains the energy of the compressor

source

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.

Network Expansion Constraints

Constraints are also used to turn on/off flow through a compressor in expansion planning formulations

Regulator Constraints

Operations Constraints

The primary constraints related to regulator ensure that that the valves operate within the limits of their capability (pressure reduction). The control valve also has an open/close variable to determine whether or not flow is allowed through the valve

GasModels.constraint_on_off_regulator_pressureFunction

Constraint Enforces pressure changes bounds that obey decompression ratios for

source

Constraint: Constraints on pressure drop across control valves that have on/off direction variables

source

constraints on pressure drop across control valves–not applicable for LRWP models

source

constraints on pressure drop across control valves

source

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.

Valve Constraints

Operations Constraints

The primary function of a valve is to open or close a pipe.

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.

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.

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.