Valve#
This section describes the generic adiabatic valve model. By default the model is based on molar flow, but the pressure-flow equation and the flow basis is configurable. This model inherits the PressureChanger model with the adiabatic options. Beyond the base pressure changer model this provides a pressure flow relation as a function of the valve opening fraction.
Example#
from pyomo.environ import ConcreteModel, SolverFactory, TransformationFactory
from idaes.core import FlowsheetBlock
from idaes.models.unit_models import Valve
from idaes.models.properties import iapws95
import idaes.core.util.scaling as iscale
m = ConcreteModel()
m.fs = FlowsheetBlock(dynamic=False)
m.fs.properties = iapws95.Iapws95ParameterBlock()
m.fs.valve = Valve(property_package=m.fs.properties)
fin = 900 # mol/s
pin = 200000 # Pa
pout = 100000 # Pa
tin = 300 # K
hin = iapws95.htpx(T=tin*units.K, P=pin*units.Pa) # J/mol
# Calculate the flow coefficient to give 1000 mol/s flow with given P
cv = 1000/math.sqrt(pin - pout)/0.5
# set inlet
m.fs.valve.inlet.enth_mol[0].fix(hin)
m.fs.valve.inlet.flow_mol[0].fix(fin)
m.fs.valve.inlet.flow_mol[0].unfix()
m.fs.valve.inlet.pressure[0].fix(pin)
m.fs.valve.outlet.pressure[0].fix(pout)
m.fs.valve.Cv.fix(cv)
m.fs.valve.valve_opening.fix(0.5)
iscale.calculate_scaling_factors(m)
m.fs.valve.initialize(outlvl=1)
solver = pyo.SolverFactory("ipopt")
solver.options = {"nlp_scaling_method": "user-scaling"}
solver(m, tee=True)
Variables#
Variable |
Symbol |
Index Sets |
Doc |
---|---|---|---|
|
\(C_v\) |
None |
Valve coefficient |
|
\(x\) |
time |
The fraction that the valve is open from 0 to 1 |
The Cv
variable is highly recommended but can be omitted in custom pressure-flow relations.
Expressions#
Expression |
Symbol |
Index Sets |
Doc |
---|---|---|---|
|
\(f(x)\) |
time |
This is a valve function that describes how the fraction open affects flow. |
Built-in Valve Functions#
Standard valve functions can be specified by providing a ValveFunctionType
enumerated type to the valve_function_callback
argument. Standard functions
are given below.
ValveFunctionType.linear
ValveFunctionType.quick_opening
ValveFunctionType.equal_percentage
For the equal-percentage valve function an additional variable alpha
is defined
which by default is fixed and set to 100.
Custom Valve Functions#
In general, the valve opening should be restricted to range from 0 to 1. The valve
function should be a named expression attached to the valve model called
valve_function
which takes the valve opening and computes a value that goes
from approximately zero when valve opening is 0 to 1 when the valve opening is one.
The valve function can have parameters as needed, so custom valve functions are
defined using a callback function.
The callback function should take an object of the Valve
class as an argument
and add the valve_function
named expression. Any additional parameters can also
be added. The standard equal-percentage valve function is provided below as an
example. The callback can be provided for the valve_function_callback
configuration option.
def equal_percentage_cb(b):
"""
Equal percentage valve function callback.
"""
# Parameters can be defined as Var or Param. If Var is used the parameter
# can be included in a parameter estimation problem.
b.alpha = pyo.Var(initialize=100, doc="Valve function parameter")
b.alpha.fix()
@b.Expression(b.flowsheet().config.time)
def valve_function(b2, t):
return b2.alpha ** (b2.valve_opening[t] - 1)
Constraints#
The pressure flow relation is added to the inherited constraints from the PressureChanger model.
The default pressure-flow relation is given below where \(F\) is the molar flow. The default valve function assumes an incompressible fluid of constant density. In this case the fluid specific gravity is included in the flow coefficient. For rigorous modeling of valves with gases, it is recommended that a custom pressure-flow equation be specified.
Custom Pressure Flow Relations#
Other pressure-flow equations can be specified via callback supplied to the unit
configuration option pressure_flow_callback
. The callback allows both the form
and flow basis of the pressure-flow equation to be specified.
The callback can add parameters and variables as needed. It is recommended that
only the pressure_flow_equation
be specified as additional constraints would
not be scaled by the valve model’s scaling routines. The pressure flow relation
generally should be written in the form below to facilitate scaling where \(F\)
is flow variable.
The callback takes a Valve model object as an argument. There are three attributes
that the pressure_flow_callback
should define:
1. flow_var
a time indexed reference to the flow variable basis,
2. pressure_flow_equation_scale
a function that takes flow_var
and defines the form of the flow term
3. pressure_flow_equation
the pressure flow relation constraint.
The first two items, flow_var
and pressure_flow_equation_scale
, are
not directly used in the model, but are used by the model scaling routine.
The example callback below is the model default pressure-flow equation.
def pressure_flow_default_callback(b):
"""
Add the default pressure flow relation constraint. This will be used in the
valve model, a custom callback is provided.
"""
umeta = b.control_volume.config.property_package.get_metadata().get_derived_units
b.Cv = pyo.Var(
initialize=0.1,
doc="Valve flow coefficient",
units=umeta("amount")/umeta("time")/umeta("pressure")**0.5
)
b.Cv.fix()
b.flow_var = pyo.Reference(b.control_volume.properties_in[:].flow_mol)
b.pressure_flow_equation_scale = lambda x : x**2
@b.Constraint(b.flowsheet().config.time)
def pressure_flow_equation(b2, t):
Po = b2.control_volume.properties_out[t].pressure
Pi = b2.control_volume.properties_in[t].pressure
F = b2.control_volume.properties_in[t].flow_mol
Cv = b2.Cv
fun = b2.valve_function[t]
return F ** 2 == Cv ** 2 * (Pi - Po) * fun ** 2
Initialization#
This just calls the initialization routine from PressureChanger. Either an outlet pressure value or deltaP can be specified to aid the initialization.
Valve Class#
- class idaes.models.unit_models.valve.Valve(*args, **kwds)#
Adiabatic valves
- Parameters:
rule (function) – A rule function or None. Default rule calls build().
concrete (bool) – If True, make this a toplevel model. Default - False.
ctype (class) –
Pyomo ctype of the block. Default - pyomo.environ.Block
Config args
- dynamic
Indicates whether this model will be dynamic or not, default = useDefault. Valid values: { useDefault - get flag from parent (default = False), True - set as a dynamic model, False - set as a steady-state model.}
- has_holdup
Indicates whether holdup terms should be constructed or not. Must be True if dynamic = True, default - False. Valid values: { useDefault - get flag from parent (default = False), True - construct holdup terms, False - do not construct holdup terms}
- material_balance_type
Indicates what type of mass balance should be constructed, default - MaterialBalanceType.useDefault. Valid values: { MaterialBalanceType.useDefault - refer to property package for default balance type **MaterialBalanceType.none - exclude material balances, MaterialBalanceType.componentPhase - use phase component balances, MaterialBalanceType.componentTotal - use total component balances, MaterialBalanceType.elementTotal - use total element balances, MaterialBalanceType.total - use total material balance.}
- energy_balance_type
Indicates what type of energy balance should be constructed, default - EnergyBalanceType.useDefault. Valid values: { EnergyBalanceType.useDefault - refer to property package for default balance type **EnergyBalanceType.none - exclude energy balances, EnergyBalanceType.enthalpyTotal - single enthalpy balance for material, EnergyBalanceType.enthalpyPhase - enthalpy balances for each phase, EnergyBalanceType.energyTotal - single energy balance for material, EnergyBalanceType.energyPhase - energy balances for each phase.}
- momentum_balance_type
Indicates what type of momentum balance should be constructed, default - MomentumBalanceType.pressureTotal. Valid values: { MomentumBalanceType.none - exclude momentum balances, MomentumBalanceType.pressureTotal - single pressure balance for material, MomentumBalanceType.pressurePhase - pressure balances for each phase, MomentumBalanceType.momentumTotal - single momentum balance for material, MomentumBalanceType.momentumPhase - momentum balances for each phase.}
- has_phase_equilibrium
Indicates whether terms for phase equilibrium should be constructed, default = False. Valid values: { True - include phase equilibrium terms False - exclude phase equilibrium terms.}
- compressor
Indicates whether this unit should be considered a compressor (True (default), pressure increase) or an expander (False, pressure decrease).
- thermodynamic_assumption
Flag to set the thermodynamic assumption to use for the unit. - ThermodynamicAssumption.isothermal (default) - ThermodynamicAssumption.isentropic - ThermodynamicAssumption.pump - ThermodynamicAssumption.adiabatic
- property_package
Property parameter object used to define property calculations, default - useDefault. Valid values: { useDefault - use default package from parent model or flowsheet, PropertyParameterObject - a PropertyParameterBlock object.}
- property_package_args
A ConfigBlock with arguments to be passed to a property block(s) and used when constructing these, default - None. Valid values: { see property package for documentation.}
- support_isentropic_performance_curves
Include a block for performance curves, configure via isentropic_performance_curves.
- isentropic_performance_curves
Configuration dictionary for the performance curve block.
- isentropic_performance_curves
- build_callback
Optional callback to add performance curve constraints
- build_head_expressions
If true add expressions for ‘head’ and ‘head_isentropic’. These expressions can be used in performance curve constraints.
- valve_function_callback
This takes either an enumerated valve function type in: { ValveFunctionType.linear, ValveFunctionType.quick_opening, ValveFunctionType.equal_percentage, ValveFunctionType.custom} or a callback function that takes a valve model object as an argument and adds a time- indexed valve_function expression to it. Any additional required variables, expressions, or constraints required can also be added by the callback.
- pressure_flow_callback
This callback function takes a valve model object as an argument and adds a time-indexed valve_function expression to it. Any additional required variables, expressions, or constraints required can also be added by the callback.
initialize (dict) – ProcessBlockData config for individual elements. Keys are BlockData indexes and values are dictionaries with config arguments as keys.
idx_map (function) – Function to take the index of a BlockData element and return the index in the initialize dict from which to read arguments. This can be provided to override the default behavior of matching the BlockData index exactly to the index in initialize.
- Returns:
(Valve) New instance
ValveData Class#
- class idaes.models.unit_models.valve.ValveData(component)[source]#
Basic valve model class.
- calculate_scaling_factors()[source]#
Calculate pressure flow constraint scaling from flow variable scale.