modelPartialTwoWayValve

Partial model for a two way valve

Extends from Buildings.Fluid.BaseClasses.PartialResistance (Partial model for a hydraulic resistance), Buildings.Fluid.Actuators.BaseClasses.ValveParameters (Model with parameters for valves), Buildings.Fluid.Actuators.BaseClasses.ActuatorSignal (Partial model that implements the filtered opening for valves and dampers).

Information

Partial model for a two way valve. This is the base model for valves with different opening characteristics, such as linear, equal percentage, quick opening or pressure-independent.

To prevent the derivative d/dP (m_flow) to be infinite near the origin, this model linearizes the pressure drop versus flow relation ship. The region in which it is linearized is parameterized by

  m_turbulent_flow = deltaM * m_flow_nominal

Because the parameterization contains Kv_SI, the values for deltaM and dp_nominal need not be changed if the valve size changes.

In contrast to the model in Modelica.Fluid, this model uses the parameter Kv_SI, which is the flow coefficient in SI units, i.e., it is the ratio between mass flow rate in kg/s and square root of pressure drop in Pa.

Options

This model allows different parameterization of the flow resistance. The different parameterizations are described in Buildings.Fluid.Actuators.BaseClasses.ValveParameters.

Implementation

The two way valve models are implemented using this partial model, as opposed to using different functions for the valve opening characteristics, because each valve opening characteristics has different parameters.

Parameters

TypeNameDefaultDescription
BooleanhomotopyInitialization (from PartialResistance)true= true, use homotopy method
Modelica.Units.SI.MassFlowRatem_flow_turbulent (from PartialResistance)Turbulent flow if |m_flow| >= m_flow_turbulent
Reall0.0001Valve leakage, l=Kv(y=0)/Kv(y=1)
RealkFixedif dpFixed_nominal > Modelica.Constants.eps then m_flow_nominal/sqrt(dpFixed_nominal) else 0Flow coefficient of fixed resistance that may be in series with valve, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2).
Assumptions
BooleanallowFlowReversal (from PartialTwoPort)true= false to simplify equations, assuming, but not enforcing, no flow reversal
Nominal condition
Modelica.Units.SI.MassFlowRatem_flow_nominal (from PartialTwoPortInterface)Nominal mass flow rate
Modelica.Units.SI.PressureDifferencedp_nominal (from PartialResistance)Pressure drop at nominal mass flow rate
Modelica.Units.SI.PressureDifferencedpValve_nominal (from ValveParameters)Nominal pressure drop of fully open valve, used if CvData=Buildings.Fluid.Types.CvTypes.OpPoint
Modelica.Units.SI.PressureDifferencedpFixed_nominal0Pressure drop of pipe and other resistances that are in series
Advanced
Modelica.Units.SI.MassFlowRatem_flow_small (from PartialTwoPortInterface)1E-4*abs(m_flow_nominal)Small mass flow rate for regularization of zero flow
Booleanfrom_dp (from PartialResistance)false= true, use m_flow = f(dp) else dp = f(m_flow)
Realn (from PartialResistance)2Flow exponent, n=1 for laminar, n=2 for turbulent
Booleanlinearized (from PartialResistance)false= true, use linear relation between m_flow and dp for any flow rate
Advanced › Diagnostics
Booleanshow_T (from PartialTwoPortInterface)false= true, if actual temperature at port is computed
Flow Coefficient
Buildings.Fluid.Types.CvTypesCvData (from ValveParameters)Buildings.Fluid.Types.CvTypes.OpPointSelection of flow coefficient
RealKv (from ValveParameters)Kv (metric) flow coefficient [m3/h/(bar)^(1/2)]
RealCv (from ValveParameters)Cv (US) flow coefficient [USG/min/(psi)^(1/2)]
Modelica.Units.SI.AreaAv (from ValveParameters)Av (metric) flow coefficient
Pressure-flow linearization
RealdeltaM (from ValveParameters)0.02Fraction of nominal flow rate where linearization starts, if y=1
Advanced › Nominal condition
Modelica.Units.SI.DensityrhoStd (from ValveParameters)Inlet density for which valve coefficients are defined
Dynamics › Actuator position
Booleanuse_strokeTime (from ActuatorSignal)trueSet to true to continuously open and close valve using strokeTime
Modelica.Units.SI.TimestrokeTime (from ActuatorSignal)120Time needed to fully open or close actuator
Modelica.Blocks.Types.Initinit (from ActuatorSignal)Modelica.Blocks.Types.Init.InitialOutputType of initialization (no init/steady state/initial state/initial output)
Realy_start (from ActuatorSignal)1Initial position of actuator

Connectors

TypeNameDefaultDescription
Modelica.Fluid.Interfaces.FluidPort_aport_a (from PartialTwoPort)Fluid connector a (positive design flow direction is from port_a to port_b)
Modelica.Fluid.Interfaces.FluidPort_bport_b (from PartialTwoPort)Fluid connector b (positive design flow direction is from port_a to port_b)
Modelica.Blocks.Interfaces.RealInputy (from ActuatorSignal)Actuator position (0: closed, 1: open)
Modelica.Blocks.Interfaces.RealOutputy_actual (from ActuatorSignal)Actual actuator position

Components

TypeNameDefaultDescription
Modelica.Units.SI.MassFlowRatem_flow (from PartialTwoPortInterface)port_a.m_flowMass flow rate from port_a to port_b (m_flow > 0 is design flow direction)
Modelica.Units.SI.PressureDifferencedp (from PartialTwoPortInterface)port_a.p - port_b.pPressure difference between port_a and port_b
Medium.ThermodynamicStatesta_a (from PartialTwoPortInterface)if allowFlowReversal then Medium.setState_phX(port_a.p, noEvent(actualStream(port_a.h_outflow)), noEvent(actualStream(port_a.Xi_outflow))) else Medium.setState_phX(port_a.p, noEvent(inStream(port_a.h_outflow)), noEvent(inStream(port_a.Xi_outflow)))Medium properties in port_a
Medium.ThermodynamicStatesta_b (from PartialTwoPortInterface)if allowFlowReversal then Medium.setState_phX(port_b.p, noEvent(actualStream(port_b.h_outflow)), noEvent(actualStream(port_b.Xi_outflow))) else Medium.setState_phX(port_b.p, noEvent(port_b.h_outflow), noEvent(port_b.Xi_outflow))Medium properties in port_b
RealphiRatio actual to nominal mass flow rate of valve, phi=Kv(y)/Kv(y=1)
RealkValFlow coefficient of valve, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2).
RealkFlow coefficient of valve and pipe in series, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2).

Revisions

  • March 31, 2026, by Michael Wetter:
    Corrected unit propagation error that causes Dymola 2026x to not show certain units.
    See #2100.
  • January 19, 2026, by Jelger Jansen:
    Added unit 1 to parameter kVal to avoid FMU unit errors.
    This is for #2074.
  • April 2, 2020, by Filip Jorissen:
    Added model name in assert message.
    This is for #1334.
  • February 21, 2020, by Michael Wetter:
    Changed icon to display its operating stage.
    This is for #1294.
  • November 9, 2019, by Filip Jorissen:
    Removed assert for phi>-0.2 since the valve control input is now lower limited to zero. See issue 1223.
  • October 25, 2019, by Jianjun Hu:
    Improved icon graphics annotation. This is for #1225.
  • March 24, 2017, by Michael Wetter:
    Renamed filteredInput to use_inputFilter.
    This is for #665.
  • November 16, 2017, by Michael Wetter:
    Relaxed assertion on phi.
    This is for #592.
  • October 27, 2016, by Filip Jorissen:
    Added assert for phi > 0. This fixes a bug that caused valves to behave like pumps for negative control signals. This is for #558.
  • April 23, 2016, by Michael Wetter:
    Changed test in assertion from dpFixed_nominal > -Modelica.Constants.small to dpFixed_nominal > -Modelica.Constants.eps. Otherwise, JModelica evaluates it as true in Buildings.Fluid.Actuators.Valves.Examples.TwoWayValves. See also https://trac.jmodelica.org/ticket/4932. This is for Buildings, issue 510.
  • January 22, 2016, by Michael Wetter:
    Corrected type declaration of pressure difference. This is for #404.
  • January 29, 2015, by Filip Jorissen:
    Moved the governing equations to PartialTwoWayValveKv in order to be able to extend from this partial in TwoWayPressureIndependent
  • August 8, 2014, by Michael Wetter:
    Reformulated the computation of k to make the model work in OpenModelica.
  • April 4, 2014, by Michael Wetter:
    Added keyword input to variable phi to require models that extend this model to provide a binding equation. This is done to use the same modeling concept as is used for example in Buildings.Fluid.Interfaces.StaticTwoPortHeatMassExchanger.
  • March 27, 2014 by Michael Wetter:
    Revised model for implementation of new valve model that computes the flow function based on a table.
  • March 20, 2013, by Michael Wetter:
    Set dp(nominal=6000) as the previous formulation gives an error during model check in Dymola 2014. The reason is that the previous formulation used dpValve_nominal, which is not known at translation time.
  • February 28, 2013, by Michael Wetter:
    Reformulated assignment of parameters. Removed default value for dpValve_nominal, as this parameter has the attribute fixed=false for some values of CvData. In this case, assigning a value is not allowed. Changed assignment of nominal attribute of dp to avoid assigning a non-literal value.
  • February 20, 2012 by Michael Wetter:
    Renamed parameter dp_nominal to dpValve_nominal, and added new parameter dpFixed_nominal. See Buildings.Fluid.Actuators.UsersGuide.
  • January 16, 2012 by Michael Wetter:
    To simplify object inheritance tree, revised base classes Buildings.Fluid.BaseClasses.PartialResistance, Buildings.Fluid.Actuators.BaseClasses.PartialTwoWayValve, Buildings.Fluid.Actuators.BaseClasses.PartialDamperExponential, Buildings.Fluid.Actuators.BaseClasses.PartialActuator and model Buildings.Fluid.FixedResistances.PressureDrop.
  • August 12, 2011 by Michael Wetter:
    Added assert statement to prevent l=0 due to the implementation of Buildings.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow.
  • April 4, 2011 by Michael Wetter:
    Revised implementation to use new base class for actuators.
  • February 18, 2009 by Michael Wetter:
    Implemented parameterization of flow coefficient as in Modelica.Fluid.
  • August 15, 2008 by Michael Wetter:
    Set valve leakage to nonzero value.
  • June 3, 2008 by Michael Wetter:
    First implementation.