text
stringlengths
1
4.74k
code
stringlengths
69
637k
Package that contains state machines and control models used by the utilities
within AixLib.Electrical.Utilities; package Controllers "Package that contains state machines and control models used by the utilities" extends Modelica.Icons.BasesPackage; end Controllers;
This model represents a simple voltage controller that unplug a load when there is a voltage fluctuation higher that a given threshold.. Function that implements a state machine that detects voltage deviations. If the voltage input <code>V</code> exceeds the nominal value <code>V_nominal</code> by more than <i>1+V<sub>tr</sub></i> then the control signal <code>y</code> becones zero for a period equal to <code>tDelay</code>.
within AixLib.Electrical.Utilities.Controllers; model StateMachineVoltCtrl "This model represents a simple voltage controller that unplug a load when there is a voltage fluctuation higher that a given threshold." Modelica.Blocks.Interfaces.RealInput V "Voltage of the node to be controlled"; parameter Modelica.Units.SI.Voltage V_nominal "Nominal voltage of the node to be controlled"; parameter Real vThresh(min=0.0, max=1.0) = 0.1 "Threshold that activates voltage ctrl (ratio of nominal voltage)"; parameter Modelica.Units.SI.Time tDelay=300 "Time to wait before plugging the load back"; output Real y "Output signal that represents whether the load should be connected to the grid or not"; protected discrete Boolean connected "Boolean variable that indicates when the load is connected"; discrete Real tSwitch "Time instant when the last event occurred"; initial algorithm // Initialize with load connected and last event at t = 0 connected := true; tSwitch := 0; equation // Output for every state, connected or not if connected then y = 1.0; else y = 0.0; end if; algorithm // Detect an overshoot in the voltage when (connected and (V > V_nominal*(1+vThresh))) then tSwitch := time; connected := false; end when; // Transition between not connected and connected again after the delay time has been elapsed when (not connected and time >= tSwitch + tDelay) then connected := true; end when; end StateMachineVoltCtrl;
This package contais tests for check the correctness of the models
within AixLib.Electrical.Utilities; package Examples "This package contais tests for check the correctness of the models" extends Modelica.Icons.ExamplesPackage; end Examples;
This test check the correctness of the voltage controller model
within AixLib.Electrical.Utilities.Examples; model TestVoltageCTRL "This test check the correctness of the voltage controller model" extends Modelica.Icons.Example; VoltageControl voltageControl( redeclare AixLib.Electrical.DC.Interfaces.Terminal_p terminal, redeclare package PhaseSystem = AixLib.Electrical.PhaseSystems.TwoConductor, V_nominal=120, tDelay=2) "Voltage controller" DC.Sources.VoltageSource sou "Varriable voltage source" Modelica.Electrical.Analog.Basic.Ground ground Modelica.Blocks.Sources.Sine cosine( amplitude=20, f=0.1, phase=0, offset=120) "Variable voltage signal" Modelica.Blocks.Sources.Constant Vtr_high(k=120*(1 + 0.1)) "Voltage threshold high" equation connect(sou.terminal, voltageControl.terminal) connect(ground.p, sou.n) connect(cosine.y, sou.V_in) end TestVoltageCTRL;
Collection of models that illustrate model use and test models
within AixLib; package Examples "Collection of models that illustrate model use and test models" extends Modelica.Icons.ExamplesPackage; end Examples;
Illustrative example of a simple heating, ventilation and room model
within AixLib.Examples; model SimpleHouse "Illustrative example of a simple heating, ventilation and room model" extends Modelica.Icons.Example; package MediumAir = AixLib.Media.Air; package MediumWater = AixLib.Media.Water; parameter Modelica.Units.SI.Area AWall=100 "Wall area"; parameter Modelica.Units.SI.Area AWin=5 "Window area"; parameter Real gWin(min=0, max=1, unit="1") = 0.3 "Solar heat gain coefficient of window"; parameter Modelica.Units.SI.Volume VZone=AWall*3 "Wall area"; parameter Modelica.Units.SI.HeatFlowRate QHea_flow_nominal=700 "Nominal capacity of heating system"; parameter Modelica.Units.SI.MassFlowRate mWat_flow_nominal=QHea_flow_nominal/ 10/4200 "Nominal mass flow rate for water loop"; parameter Modelica.Units.SI.MassFlowRate mAir_flow_nominal=VZone*2*1.2/3600 "Nominal mass flow rate for air loop"; parameter Modelica.Units.SI.PressureDifference dpAir_nominal=200 "Pressure drop at nominal mass flow rate for air loop"; parameter Boolean allowFlowReversal=false "= false because flow will not reverse in these circuits"; Modelica.Thermal.HeatTransfer.Components.HeatCapacitor walCap( T(fixed=true), C=10*AWall*0.05*1000*1000) "Thermal mass of walls" Fluid.MixingVolumes.MixingVolume zon( redeclare package Medium = MediumAir, V=VZone, nPorts=2, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, m_flow_nominal=mAir_flow_nominal, massDynamics=Modelica.Fluid.Types.Dynamics.DynamicFreeInitial) "Very based zone air model" Modelica.Thermal.HeatTransfer.Components.ThermalResistor conRes(R=1/2/AWall) "Thermal resistance for convective heat transfer with h=2" Fluid.HeatExchangers.Radiators.RadiatorEN442_2 rad( redeclare package Medium = MediumWater, T_a_nominal=273.15 + 50, T_b_nominal=273.15 + 40, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, allowFlowReversal=allowFlowReversal, Q_flow_nominal=QHea_flow_nominal) "Radiator" Fluid.Sources.Boundary_pT bouAir( redeclare package Medium = MediumAir, nPorts=2, use_T_in=true) "Air boundary with constant temperature" Fluid.Sources.Boundary_pT bouWat(redeclare package Medium = MediumWater, nPorts=1) "Pressure bound for water circuit" BoundaryConditions.WeatherData.ReaderTMY3 weaDat( filNam=Modelica.Utilities.Files.loadResource("modelica://AixLib/Resources/weatherdata/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.mos")) "Weather data reader" BoundaryConditions.WeatherData.Bus weaBus "Weather data bus" Modelica.Thermal.HeatTransfer.Components.ThermalResistor walRes(R=0.25/AWall/ 0.04) "Thermal resistor for wall: 25 cm of rockwool" Modelica.Thermal.HeatTransfer.Sources.PrescribedTemperature TOut "Exterior temperature boundary condition" Fluid.HeatExchangers.HeaterCooler_u heaWat( redeclare package Medium = MediumWater, m_flow_nominal=mWat_flow_nominal, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, allowFlowReversal=allowFlowReversal, dp_nominal=5000, Q_flow_nominal=QHea_flow_nominal) "Heater for water circuit" Fluid.Movers.FlowControlled_m_flow pum( redeclare package Medium = MediumWater, use_inputFilter=false, m_flow_nominal=mWat_flow_nominal, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, allowFlowReversal=allowFlowReversal, nominalValuesDefineDefaultPressureCurve=true, inputType=AixLib.Fluid.Types.InputType.Stages, massFlowRates=mWat_flow_nominal*{1}) "Pump" Modelica.Thermal.HeatTransfer.Sensors.TemperatureSensor senTemZonAir "Zone air temperature sensor" Fluid.Actuators.Dampers.Exponential vavDam( redeclare package Medium = MediumAir, from_dp=true, m_flow_nominal=mAir_flow_nominal, dpDamper_nominal=10, dpFixed_nominal=dpAir_nominal - 10) "Damper" Fluid.Movers.FlowControlled_dp fan( redeclare package Medium = MediumAir, dp_nominal=dpAir_nominal, use_inputFilter=false, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, nominalValuesDefineDefaultPressureCurve=true, m_flow_nominal=mAir_flow_nominal, show_T=true) "Constant head fan" Modelica.Thermal.HeatTransfer.Sources.PrescribedHeatFlow win "Very simple window model" Fluid.HeatExchangers.ConstantEffectiveness hexRec( redeclare package Medium1 = MediumAir, redeclare package Medium2 = MediumAir, dp1_nominal=0, dp2_nominal=0, m1_flow_nominal=mAir_flow_nominal, m2_flow_nominal=mAir_flow_nominal, eps=0.85) "Heat exchanger for heat recuperation" Modelica.Blocks.Logical.Hysteresis hysRad(uLow=273.15 + 20, uHigh=273.15 + 22) "Hysteresis controller for radiator" Modelica.Blocks.Logical.Not not1 "negation for enabling heating when temperatur is low" Modelica.Blocks.Math.BooleanToReal booToRea "Boolean to real" Modelica.Blocks.Sources.Constant con_dp(k=dpAir_nominal) "Pressure head" Modelica.Blocks.Math.Gain gaiWin(k=AWin*gWin) "Gain for window solar transmittance and area as HGloHor is in W/m2" Modelica.Blocks.Math.BooleanToInteger booToInt "Boolean to integer" Controls.Continuous.LimPID conDam( controllerType=Modelica.Blocks.Types.SimpleController.P, yMin=0.25) "Controller for damper" Modelica.Blocks.Sources.Constant TSetRoo(k=273.15 + 24) "Room temperature set point for air system" Fluid.HeatExchangers.SensibleCooler_T cooAir( energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, allowFlowReversal=allowFlowReversal, m_flow_nominal=mAir_flow_nominal, dp_nominal=0, redeclare package Medium = MediumAir) "Cooling for supply air" Modelica.Blocks.Sources.Constant TSupAirCoo(k=273.15 + 20) "Cooling setpoint for supply air" equation connect(conRes.port_a, zon.heatPort) connect(weaDat.weaBus, weaBus) connect(walRes.port_b, walCap.port) connect(TOut.T, weaBus.TDryBul) connect(TOut.port, walRes.port_a) connect(heaWat.port_b, rad.port_a) connect(bouWat.ports[1], heaWat.port_a) connect(rad.port_b, pum.port_a) connect(senTemZonAir.port, zon.heatPort) connect(bouAir.ports[1], hexRec.port_b1) connect(rad.heatPortCon, zon.heatPort) connect(not1.y, booToRea.u) connect(not1.u, hysRad.y) connect(booToRea.y, heaWat.u) connect(heaWat.port_a, pum.port_b) connect(con_dp.y, fan.dp_in) connect(gaiWin.y, win.Q_flow) connect(gaiWin.u, weaBus.HGloHor) connect(booToInt.u, not1.y) connect(booToInt.y, pum.stage) connect(hexRec.port_b2, fan.port_a) connect(vavDam.port_b, zon.ports[1]) connect(senTemZonAir.T, hysRad.u) connect(senTemZonAir.T,conDam. u_s) connect(conDam.y, vavDam.y) connect(TSetRoo.y,conDam. u_m) connect(fan.port_b, cooAir.port_a) connect(cooAir.port_b, vavDam.port_a) connect(TSupAirCoo.y, cooAir.TSet) connect(bouAir.T_in, weaBus.TDryBul) connect(bouAir.ports[2], hexRec.port_a2) connect(hexRec.port_a1, zon.ports[2]) connect(conRes.port_b, walCap.port) connect(win.port, walCap.port) connect(rad.heatPortRad, walCap.port) end SimpleHouse;
Tutorial with step by step instructions for how to build system models
within AixLib.Examples; package Tutorial "Tutorial with step by step instructions for how to build system models" extends Modelica.Icons.Information; end Tutorial;
Package with example for how to build a simple building envelope with a radiator heating system and ventilation system
within AixLib.Examples.Tutorial; package SimpleHouse "Package with example for how to build a simple building envelope with a radiator heating system and ventilation system" extends Modelica.Icons.ExamplesPackage; end SimpleHouse;
Start file for simple house example
within AixLib.Examples.Tutorial.SimpleHouse; model SimpleHouse0 "Start file for simple house example" extends Modelica.Icons.Example; package MediumAir = AixLib.Media.Air "Medium model for air"; package MediumWater = AixLib.Media.Water "Medium model for water"; parameter Modelica.Units.SI.Area AWall = 100 "Wall area"; parameter Modelica.Units.SI.Length dWall = 0.25 "Wall thickness"; parameter Modelica.Units.SI.ThermalConductivity kWall = 0.04 "Wall thermal conductivity"; parameter Modelica.Units.SI.Density rhoWall = 2000 "Wall density"; parameter Modelica.Units.SI.SpecificHeatCapacity cpWall = 1000 "Wall specific heat capacity"; AixLib.BoundaryConditions.WeatherData.ReaderTMY3 weaDat(filNam= Modelica.Utilities.Files.loadResource( "modelica://AixLib/Resources/weatherdata/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.mos")) "Weather data reader" AixLib.BoundaryConditions.WeatherData.Bus weaBus "Weather data bus" Modelica.Thermal.HeatTransfer.Sources.PrescribedTemperature TOut "Exterior temperature boundary condition" equation connect(weaDat.weaBus, weaBus) connect(TOut.T, weaBus.TDryBul) end SimpleHouse0;
Building wall model. A very simple building envelope model will be constructed manually using thermal resistors and heat capacitors. The house consists of a wall represented by a single heat capacitor and a thermal resistor. The boundary temperature are already included in <a href=\"modelica://AixLib.Examples.Tutorial.SimpleHouse.SimpleHouse0\"> AixLib.Examples.Tutorial.SimpleHouse.SimpleHouse0</a>. The wall has a surface area of <i>A<sub>wall</sub>=100 m<sup>2</sup></i>, a thickness of <i>d<sub>wall</sub>=25 cm</i>, a thermal conductivity of <i>k<sub>wall</sub>=0.04 W/(m K)</i>, a density of <i>&rho;<sub>wall</sub>=2000 kg/m<sup>3</sup></i>, and a specific heat capacity of <i>c<sub>p,wall</sub>= 1000 J/(kg K)</i>
within AixLib.Examples.Tutorial.SimpleHouse; model SimpleHouse1 "Building wall model" extends SimpleHouse0; Modelica.Thermal.HeatTransfer.Components.HeatCapacitor walCap( C=AWall*dWall*cpWall*rhoWall, T(fixed=true)) "Thermal mass of wall" Modelica.Thermal.HeatTransfer.Components.ThermalResistor walRes( R=dWall/AWall/kWall) "Thermal resistor for wall: 25 cm of rockwool" equation connect(walRes.port_b, walCap.port) connect(TOut.port, walRes.port_a) end SimpleHouse1;
Building window model. The window has a surface area of <i>2 m<sup>2</sup></i>. In this simple model we will therefore assume that two times the outdoor solar irradiance is injected as heat onto the inside of the wall.
within AixLib.Examples.Tutorial.SimpleHouse; model SimpleHouse2 "Building window model" extends SimpleHouse1; parameter Modelica.Units.SI.Area AWin=2 "Window area"; Modelica.Blocks.Math.Gain gaiWin(k=AWin) "Gain for solar irradiance through the window" Modelica.Thermal.HeatTransfer.Sources.PrescribedHeatFlow win "Very simple window model" equation connect(gaiWin.y, win.Q_flow) connect(gaiWin.u, weaBus.HDirNor) connect(win.port, walCap.port) end SimpleHouse2;
Air model
within AixLib.Examples.Tutorial.SimpleHouse; model SimpleHouse3 "Air model" extends SimpleHouse2; parameter Modelica.Units.SI.Volume VZone=8*8*3 "Zone volume"; parameter Modelica.Units.SI.MassFlowRate mAir_flow_nominal=1 "Nominal mass flow rate for air loop"; parameter Modelica.Units.SI.CoefficientOfHeatTransfer hWall=2 "Convective heat transfer coefficient at the wall"; Modelica.Thermal.HeatTransfer.Components.ThermalResistor conRes(R=1/hWall/ AWall) "Thermal resistance for convective heat transfer" AixLib.Fluid.MixingVolumes.MixingVolume zon( redeclare package Medium = MediumAir, V=VZone, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, m_flow_nominal=mAir_flow_nominal) "Very simple zone air model" equation connect(zon.heatPort, conRes.port_a) connect(conRes.port_b, walCap.port) end SimpleHouse3;
Heating model
within AixLib.Examples.Tutorial.SimpleHouse; model SimpleHouse4 "Heating model" extends SimpleHouse3; constant Boolean use_constantHeater=true "To enable/disable the connection between the constant source and heater and circulation pump"; parameter Modelica.Units.SI.HeatFlowRate QHea_flow_nominal=3000 "Nominal capacity of heating system"; parameter Modelica.Units.SI.MassFlowRate mWat_flow_nominal=0.1 "Nominal mass flow rate for water loop"; AixLib.Fluid.HeatExchangers.Radiators.RadiatorEN442_2 rad( redeclare package Medium = MediumWater, T_a_nominal=333.15, T_b_nominal=313.15, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, allowFlowReversal=false, Q_flow_nominal=QHea_flow_nominal) "Radiator" AixLib.Fluid.HeatExchangers.HeaterCooler_u heaWat( redeclare package Medium = MediumWater, m_flow_nominal=mWat_flow_nominal, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, allowFlowReversal=false, dp_nominal=5000, Q_flow_nominal=QHea_flow_nominal) "Heater for water circuit" Fluid.Movers.Preconfigured.FlowControlled_m_flow pum( redeclare package Medium = MediumWater, use_inputFilter=false, m_flow_nominal=mWat_flow_nominal, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, allowFlowReversal=false) "Pump" AixLib.Fluid.Sources.Boundary_pT bouWat( redeclare package Medium = MediumWater, nPorts=1) "Pressure bound for water circuit" Modelica.Blocks.Sources.Constant conHea(k=1) if use_constantHeater "Gain for heater" Modelica.Blocks.Sources.Constant conPum(k=mWat_flow_nominal) if use_constantHeater "Gain for pump" equation connect(heaWat.port_b,rad. port_a) connect(rad.port_b, pum.port_a) connect(heaWat.port_a, pum.port_b) connect(rad.heatPortCon, zon.heatPort) connect(rad.heatPortRad, walCap.port) connect(conPum.y, pum.m_flow_in) connect(conHea.y, heaWat.u) connect(bouWat.ports[1], pum.port_b) end SimpleHouse4;
Heating controller model. Since the zone becomes too warm, a controller is required that disables the heater when a setpoint is reached. We will implement a hysteresis controller with a setpoint of <i>295.15 +/- 1K</i> (<i>21-23°C</i>). A temperature sensor will measure the zone air temperature.
within AixLib.Examples.Tutorial.SimpleHouse; model SimpleHouse5 "Heating controller model" extends SimpleHouse4(final use_constantHeater=false); Modelica.Blocks.Math.BooleanToReal booRea1(realTrue=mWat_flow_nominal) "Boolean to integer" Modelica.Blocks.Math.BooleanToReal booRea "Boolean to real" Modelica.Blocks.Logical.Hysteresis hysRad(uLow=273.15 + 21, uHigh=273.15 + 23) "Hysteresis controller for radiator" Modelica.Blocks.Logical.Not not1 "Negation for enabling heating when temperature is low" Modelica.Thermal.HeatTransfer.Sensors.TemperatureSensor senTemZonAir "Zone air temperature sensor" equation connect(booRea1.u, not1.y) connect(not1.u,hysRad. y) connect(senTemZonAir.T,hysRad. u) connect(senTemZonAir.port, zon.heatPort) connect(not1.y, booRea.u) connect(booRea.y, heaWat.u) connect(booRea1.y, pum.m_flow_in) end SimpleHouse5;
Free cooling model
within AixLib.Examples.Tutorial.SimpleHouse; model SimpleHouse6 "Free cooling model" extends SimpleHouse5( zon(nPorts=2), mAir_flow_nominal=0.1, AWin=6); parameter Modelica.Units.SI.PressureDifference dpAir_nominal=200 "Pressure drop at nominal mass flow rate for air loop"; AixLib.Fluid.Actuators.Dampers.Exponential vavDam( redeclare package Medium = MediumAir, from_dp=true, m_flow_nominal=mAir_flow_nominal, dpDamper_nominal=dpAir_nominal) "Damper" Fluid.Movers.Preconfigured.FlowControlled_dp fan( redeclare package Medium = MediumAir, show_T=true, dp_nominal=dpAir_nominal, use_inputFilter=false, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, m_flow_nominal=mAir_flow_nominal) "Constant head fan" AixLib.Fluid.HeatExchangers.ConstantEffectiveness hexRec( redeclare package Medium1 = MediumAir, redeclare package Medium2 = MediumAir, dp1_nominal=10, dp2_nominal=10, m1_flow_nominal=mAir_flow_nominal, m2_flow_nominal=mAir_flow_nominal, eps=0.85) "Heat exchanger for heat recuperation" AixLib.Fluid.Sources.Boundary_pT bouAir( redeclare package Medium = MediumAir, use_T_in=true, nPorts=2) "Air boundary with constant temperature" Modelica.Blocks.Logical.Hysteresis hysAir(uLow=273.15 + 23, uHigh=273.15 + 25) "Hysteresis controller for damper" Modelica.Blocks.Math.BooleanToReal booRea2 "Boolean to real" Modelica.Blocks.Math.BooleanToReal booRea3(realTrue=dpAir_nominal) "Boolean to real" equation connect(hexRec.port_a1, zon.ports[1]) connect(bouAir.T_in, weaBus.TDryBul) connect(vavDam.port_b, zon.ports[2]) connect(booRea2.y, vavDam.y) connect(hysAir.y, booRea2.u) connect(vavDam.port_a, fan.port_b) connect(bouAir.ports[1], hexRec.port_a2) connect(fan.port_a, hexRec.port_b2) connect(hexRec.port_b1, bouAir.ports[2]) connect(booRea1.y, pum.m_flow_in) connect(hysAir.u, hysRad.u) connect(booRea3.y, fan.dp_in) connect(booRea3.u, hysAir.y) end SimpleHouse6;
Package with models for fluid flow systems
within AixLib; package Fluid "Package with models for fluid flow systems" extends Modelica.Icons.Package; package UsersGuide "User's Guide" extends Modelica.Icons.Information; end UsersGuide; end Fluid;
Package with type definitions
within AixLib.Fluid; package Types "Package with type definitions" extends Modelica.Icons.TypesPackage; type EfficiencyCurves = enumeration( Constant "constant", Polynomial "Polynomial", QuadraticLinear "quadratic in x1, linear in x2") "Enumeration to define the efficiency curves"; type CvTypes = enumeration( OpPoint "flow coefficient defined by m_flow_nominal/sqrt(dp_nominal)", Kv "Kv (metric) flow coefficient", Cv "Cv (US) flow coefficient", Av "Av (metric) flow coefficient") "Enumeration to define the choice of valve flow coefficient" type HeatExchangerConfiguration = enumeration( ParallelFlow "Parallel flow", CounterFlow "Counter flow", CrossFlowUnmixed "Cross flow, both streams unmixed", CrossFlowStream1MixedStream2Unmixed "Cross flow, stream 1 mixed, stream 2 unmixed", CrossFlowStream1UnmixedStream2Mixed "Cross flow, stream 1 unmixed, stream 2 mixed", ConstantTemperaturePhaseChange "Constant temperature phase change in one stream") "Enumeration for heat exchanger construction" type HeatExchangerFlowRegime = enumeration( ParallelFlow "Parallel flow", CounterFlow "Counter flow", CrossFlowUnmixed "Cross flow, both streams unmixed", CrossFlowCMinMixedCMaxUnmixed "Cross flow, CMin mixed, CMax unmixed", CrossFlowCMinUnmixedCMaxMixed "Cross flow, CMin unmixed, CMax mixed", ConstantTemperaturePhaseChange "Constant temperature phase change in one stream") "Enumeration for heat exchanger flow configuration" type InputType = enumeration( Constant "Use parameter to set stage", Stages "Use integer input to select stage", Continuous "Use continuous, real input") "Input options for movers" end Types;
Package with actuator models such as valves and dampers
within AixLib.Fluid; package Actuators "Package with actuator models such as valves and dampers" extends Modelica.Icons.VariantsPackage; package UsersGuide "User's Guide" extends Modelica.Icons.Information; res(dp_nominal=10000, m_flow_nominal=0.1); </pre> <p> Instead of this arrangement, the model <code>res</code> can be deleted and the valve configured as </p> <pre> val(dpValve_nominal=6000, dpFixed=10000, m_flow_nominal=0.1); </pre> <p> This yields the same simulation results, but a nonlinear equation can be avoided in some cases. Although lumping the pressure drop of other components into the valve model violates the intent that in component-based modeling, each component should only model its own behavior, having the option of eliminating a nonlinear equation can be worthwhile. </p> <p> For three way valves, similar parameters exist for the controlled ports of the valve. For example, consider the configuration below. </p> <p align=\"center\"> <img alt=\"image\" src=\"modelica://AixLib/Resources/Images/Fluid/Actuators/threeWayValvePressureDropSeries.png\"/> </p> <p> Suppose the parameters are </p> <pre> val(dpValve_nominal=6000, dpFixed={0, 0}, m_flow_nominal=0.1); res1(dp_nominal=10000, m_flow_nominal=0.1); res3(dp_nominal=100, m_flow_nominal=0.1); </pre> <p> An equivalent model could be created by deleting the two resistance models <code>res1</code> and <code>res3</code>, and configuring the valve as </p> <pre> val(dpValve_nominal=6000, dpFixed={10000, 100}, m_flow_nominal=0.1); </pre> <h4>Leakage flow rate</h4> <p> Valves and air dampers should for numerical reasons have a small leakage flow rate. This leakage <i>l</i> is a non-dimensional number, defined as <i>l=K<sub>v</sub>(y=0) &frasl; =K<sub>v</sub>(y=1)</i>. A typical default value is <i>l=0.0001</i>. </p> <p> If <i>l=0</i>, models will issue an error message as this can in some situations lead to numerical problems if a flow leg becomes decoupled from a reference pressure source. </p> <h4>Transients of actuators</h4> <p> This section describes how valves and dampers can be configured to approximate the travel time of an actuator. Such an approximation can also lead to faster simulation because discrete or fast changes in controllers are damped before they influence the flow network. </p> <h5>Approximation using a 2nd order filter</h5> <p> The valves and dampers in the package <a href=\"modelica://AixLib.Fluid.Actuators\"> AixLib.Fluid.Actuators</a> all have a parameter <code>use_inputFilter</code>. This parameter is used as follows: </p> <ul> <li> If <code>use_inputFilter=false</code>, then the actual valve or damper position is equal to the input signal <code>y</code>. </li> <li> If <code>use_inputFilter=true</code>, then the actual valve or damper position is computed in such a way that it approximates a valve motor. This approximation is implemented using a 2nd order low-pass filter. The filter has a parameter <code>riseTime</code>, which by default is set to <i>120</i> seconds. The rise time is the time required to reach 99.6% of the opening. </li> </ul> <p> Using a filter often leads to a more robust simulation, because a step change in the input signal is \"smoothened\" by the filter, and hence the flow network is only exposed to a continuously differentiable change in the input signal. However, if the filter is part of a closed loop control, then the transient response gets changed. Therefore, if the parameter <code>use_inputFilter</code> is changed, control gains may need to be retuned. </p> <p> For example, suppose there is a closed loop control with a PI-controller <a href=\"modelica://AixLib.Controls.Continuous.LimPID\"> AixLib.Controls.Continuous.LimPID</a> and a valve, configured with <code>use_inputFilter=true</code> and <code>riseTime=120</code> seconds. Assume that the transient response of the other dynamic elements in the control loop is fast compared to the rise time of the filter. Then, a proportional gain of <code>k=0.1</code> and an integrator time constant of <code>Ti=120</code> seconds often yields satisfactory closed loop control performance. These values may need to be changed for different applications as they are also a function of the loop gain. If the control loop shows oscillatory behavior, then reduce <code>k</code> and/or increase <code>Ti</code>. If the control loop reacts too slow, do the opposite. </p> <p> We will now show how the parameter <code>riseTime</code> affects the actual position of a control valve. The figure below shows a model with two control valves. The valve <code>val1</code> is configured with <code>use_inputFilter=true</code> and a rise time <code>riseTime=120</code> seconds. The grey motor symbol above the control valve <code>val1</code> indicates that <code>use_inputFilter=true</code>. </p> <p align=\"center\"> <img alt=\"image\" src=\"modelica://AixLib/Resources/Images/Fluid/Actuators/valveSchematic.png\"/> </p> <p> If these valves both have a step input signal at <i>10</i> seconds, then the actual opening of the valves are as follows: </p> <p align=\"center\"> <img alt=\"image\" src=\"modelica://AixLib/Resources/Images/Fluid/Actuators/valveResponse.png\"/> </p> <p> Thus, in the valve <code>val1</code>, the mass flow rate will slowly increase, whereas in <code>val2</code>, the mass flow rate changes instantaneously. </p> <p> If <code>use_inputFilter=true</code>, then the parameter <code>y_start</code> can be used to set the initial position of the actuator, and the parameter <code>init</code> can be used to configure how the position should be initialized. </p> <p> For most applications, the default values are appropriate. Although adding a filter increases the number of equations, it can reduce computing time because the equations are easier to solve when a controller switches. </p> <h5>Approximation using a motor model with hysteresis</h5> <p> The model <a href=\"modelica://AixLib.Fluid.Actuators.Motors.IdealMotor\"> AixLib.Fluid.Actuators.Motors.IdealMotor</a> models a motor with hysteresis. It is more detailed than the above approximation. However, it can significantly increase computing time because it generates a state event whenever the valve position changes. </p> </html>")); end UsersGuide; end Actuators;
Partial model that implements the filtered opening for valves and dampers. This model implements the filter that is used to approximate the travel time of the actuator. Models that extend this model use the signal <code>y_actual</code> to obtain the current position of the actuator.
within AixLib.Fluid.Actuators.BaseClasses; model ActuatorSignal "Partial model that implements the filtered opening for valves and dampers" constant Integer order(min=1) = 2 "Order of filter"; parameter Boolean use_inputFilter=true "= true, if opening is filtered with a 2nd order CriticalDamping filter" parameter Modelica.Units.SI.Time riseTime=120 "Rise time of the filter (time to reach 99.6 % of an opening step)" parameter Modelica.Blocks.Types.Init init=Modelica.Blocks.Types.Init.InitialOutput "Type of initialization (no init/steady state/initial state/initial output)" parameter Real y_start=1 "Initial position of actuator" Modelica.Blocks.Interfaces.RealInput y(min=0, max=1) "Actuator position (0: closed, 1: open)" Modelica.Blocks.Interfaces.RealOutput y_actual "Actual actuator position" // Classes used to implement the filtered opening protected final parameter Modelica.Units.SI.Frequency fCut=5/(2*Modelica.Constants.pi* riseTime) "Cut-off frequency of filter"; parameter Boolean casePreInd = false "In case of PressureIndependent the model I/O is modified" Modelica.Blocks.Interfaces.RealOutput y_internal(unit="1") "Output connector for internal use (= y_actual if not casePreInd)"; Modelica.Blocks.Interfaces.RealOutput y_filtered if use_inputFilter "Filtered valve position in the range 0..1" AixLib.Fluid.BaseClasses.ActuatorFilter filter( final n=order, final f=fCut, final normalized=true, final initType=init, final y_start=y_start) if use_inputFilter "Second order filter to approximate actuator opening time, and to improve numerics" equation connect(filter.y, y_filtered) if use_inputFilter then connect(y, filter.u) connect(filter.y, y_internal) else connect(y, y_internal) end if; if not casePreInd then connect(y_internal, y_actual); end if; end ActuatorSignal;
Package with base classes for AixLib.Fluid.Actuators
within AixLib.Fluid.Actuators; package BaseClasses "Package with base classes for AixLib.Fluid.Actuators" extends Modelica.Icons.BasesPackage; end BaseClasses;
Partial model for air dampers with exponential opening characteristics. Partial model for air dampers with exponential opening characteristics. This is the base model for air dampers. The model implements the functions that relate the opening signal and the flow coefficient. The model also defines parameters that are used by different air damper models.
within AixLib.Fluid.Actuators.BaseClasses; partial model PartialDamperExponential "Partial model for air dampers with exponential opening characteristics" extends AixLib.Fluid.BaseClasses.PartialResistance( final dp_nominal=dpDamper_nominal+dpFixed_nominal, final m_flow_turbulent=if use_deltaM then deltaM * m_flow_nominal else eta_default*ReC*sqrt(A)*facRouDuc); extends AixLib.Fluid.Actuators.BaseClasses.ActuatorSignal; parameter Modelica.Units.SI.PressureDifference dpDamper_nominal(displayUnit= "Pa") "Pressure drop of fully open damper at nominal mass flow rate" parameter Modelica.Units.SI.PressureDifference dpFixed_nominal(displayUnit= "Pa") = 0 "Pressure drop of duct and resistances other than the damper in series, at nominal mass flow rate" parameter Boolean use_deltaM = true "Set to true to use deltaM for turbulent transition, else ReC is used"; parameter Real deltaM = 0.3 "Fraction of nominal mass flow rate where transition to turbulent occurs" final parameter Modelica.Units.SI.Velocity v_nominal=(2/rho_default/k1* dpDamper_nominal)^0.5 "Nominal face velocity"; final parameter Modelica.Units.SI.Area A=m_flow_nominal/rho_default/v_nominal "Face area"; parameter Boolean roundDuct = false "Set to true for round duct, false for square cross section" parameter Real ReC=4000 "Reynolds number where transition to turbulence starts" parameter Real a(unit="1")=-1.51 "Coefficient a for damper characteristics" parameter Real b(unit="1")=0.105*90 "Coefficient b for damper characteristics" parameter Real yL(unit="1") = 15/90 "Lower value for damper curve" parameter Real yU(unit="1") = 55/90 "Upper value for damper curve" final parameter Real k0(min=0, unit="1") = 2 * rho_default * (A / kDamMin)^2 "Loss coefficient for y=0 (pressure drop divided by dynamic pressure)" parameter Real k1(min=0, unit="1") = 0.45 "Loss coefficient for y=1 (pressure drop divided by dynamic pressure)" parameter Real l(min=1e-10, max=1) = 0.0001 "Damper leakage, ratio of flow coefficients k(y=0)/k(y=1)" parameter Boolean use_constant_density=true "Set to true to use constant density for flow friction" Medium.Density rho "Medium density"; final parameter Real kFixed = if dpFixed_nominal > Modelica.Constants.eps then m_flow_nominal / sqrt(dpFixed_nominal) else Modelica.Constants.inf "Flow coefficient of fixed resistance that may be in series with damper, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2)."; Real kDam "Flow coefficient of damper, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2)"; Real k "Flow coefficient of damper plus fixed resistance, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2)"; protected parameter Medium.Density rho_default=Medium.density(sta_default) "Density, used to compute fluid volume"; parameter Real facRouDuc= if roundDuct then sqrt(Modelica.Constants.pi)/2 else 1 "Shape factor used to compute the hydraulic diameter for round ducts"; parameter Real kL = AixLib.Fluid.Actuators.BaseClasses.exponentialDamper( y=yL, a=a, b=b, cL=cL, cU=cU, yL=yL, yU=yU)^2 "Loss coefficient at the lower limit of the exponential characteristics"; parameter Real kU = AixLib.Fluid.Actuators.BaseClasses.exponentialDamper( y=yU, a=a, b=b, cL=cL, cU=cU, yL=yL, yU=yU)^2 "Loss coefficient at the upper limit of the exponential characteristics"; parameter Real[3] cL={ (Modelica.Math.log(k0) - b - a)/yL^2, (-b*yL - 2*Modelica.Math.log(k0) + 2*b + 2*a)/yL, Modelica.Math.log(k0)} "Polynomial coefficients for curve fit for y < yl"; parameter Real[3] cU={ (Modelica.Math.log(k1) - a)/(yU^2 - 2*yU + 1), (-b*yU^2 - 2*Modelica.Math.log(k1)*yU - (-2*b - 2*a)*yU - b)/(yU^2 - 2*yU + 1), (Modelica.Math.log(k1)*yU^2 + b*yU^2 + (-2*b - 2*a)*yU + b + a)/(yU^2 - 2*yU + 1)} "Polynomial coefficients for curve fit for y > yu"; parameter Real kDamMax = (2 * rho_default / k1)^0.5 * A "Flow coefficient of damper fully open, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2)"; parameter Real kTotMax = if dpFixed_nominal > Modelica.Constants.eps then sqrt(1 / (1 / kFixed^2 + 1 / kDamMax^2)) else kDamMax "Flow coefficient of damper fully open plus fixed resistance, with unit=(kg.m)^(1/2)"; parameter Real kDamMin = l * kDamMax "Flow coefficient of damper fully closed, with unit=(kg.m)^(1/2)"; parameter Real kTotMin = if dpFixed_nominal > Modelica.Constants.eps then sqrt(1 / (1 / kFixed^2 + 1 / kDamMin^2)) else kDamMin "Flow coefficient of damper fully closed + fixed resistance, with unit=(kg.m)^(1/2)"; initial equation assert(dpDamper_nominal > Modelica.Constants.eps, "In " + getInstanceName() + ": dpDamper_nominal must be strictly greater than zero."); assert(dpFixed_nominal >= 0, "In " + getInstanceName() + ": dpFixed_nominal must be greater than zero."); assert(yL < yU, "In " + getInstanceName() + ": yL must be strictly lower than yU."); assert(m_flow_turbulent > 0, "In " + getInstanceName() + ": m_flow_turbulent must be strictly greater than zero."); assert(k1 >= 0.2, "In " + getInstanceName() + ": k1 must be greater than 0.2. k1=" + String(k1)); assert(k1 < kU, "In " + getInstanceName() + ": k1 must be strictly lower than exp(a + b * (1 - yU)). k1=" + String(k1) + ", exp(...) = " + String(kU)); assert(k0 <= 1e10, "In " + getInstanceName() + ": k0 must be lower than 1e10. k0=" + String(k0)); assert(k0 > kL, "In " + getInstanceName() + ": k0 must be strictly higher than exp(a + b * (1 - yL)). k0=" + String(k0) + ", exp(...) = " + String(kL)); equation rho = if use_constant_density then rho_default else Medium.density(Medium.setState_phX( port_a.p, inStream(port_a.h_outflow), inStream(port_a.Xi_outflow))); // flow coefficient, k = m_flow/sqrt(dp) kDam=sqrt(2*rho)*A/AixLib.Fluid.Actuators.BaseClasses.exponentialDamper( y=y_actual, a=a, b=b, cL=cL, cU=cU, yL=yL, yU=yU); k = if dpFixed_nominal > Modelica.Constants.eps then sqrt(1/(1/kFixed^2 + 1/kDam^2)) else kDam; end PartialDamperExponential;
Partial three way valve
within AixLib.Fluid.Actuators.BaseClasses; partial model PartialThreeWayValve "Partial three way valve" extends AixLib.Fluid.BaseClasses.PartialThreeWayResistance( m_flow_small = m_flow_nominal*1e-4, final mDyn_flow_nominal = m_flow_nominal, redeclare replaceable AixLib.Fluid.Actuators.BaseClasses.PartialTwoWayValve res1 constrainedby AixLib.Fluid.Actuators.BaseClasses.PartialTwoWayValve( deltaM=deltaM, from_dp=from_dp, final linearized=linearized[1], final homotopyInitialization=homotopyInitialization, final CvData=AixLib.Fluid.Types.CvTypes.OpPoint, final m_flow_nominal=m_flow_nominal, final dpValve_nominal=dpValve_nominal, final dpFixed_nominal=dpFixed_nominal[1], final use_inputFilter=false, final riseTime=riseTime), redeclare FixedResistances.LosslessPipe res2( m_flow_nominal=m_flow_nominal), redeclare replaceable AixLib.Fluid.Actuators.BaseClasses.PartialTwoWayValve res3 constrainedby AixLib.Fluid.Actuators.BaseClasses.PartialTwoWayValve( deltaM=deltaM, from_dp=from_dp, final linearized=linearized[2], final homotopyInitialization=homotopyInitialization, final CvData=AixLib.Fluid.Types.CvTypes.OpPoint, final m_flow_nominal=m_flow_nominal, final dpValve_nominal=dpValve_nominal/fraK^2, final dpFixed_nominal=dpFixed_nominal[2], final use_inputFilter=false, final riseTime=riseTime)); extends AixLib.Fluid.Actuators.BaseClasses.ActuatorSignal; extends AixLib.Fluid.Actuators.BaseClasses.ValveParameters( rhoStd=Medium.density_pTX(101325, 273.15+4, Medium.X_default)); constant Boolean homotopyInitialization = true "= true, use homotopy method" parameter Modelica.Units.SI.PressureDifference dpFixed_nominal[2]( each displayUnit="Pa", each min=0) = {0,0} "Nominal pressure drop of pipes and other equipment in flow legs at port_1 and port_3" parameter Real fraK(min=0, max=1) = 0.7 "Fraction Kv(port_3&rarr;port_2)/Kv(port_1&rarr;port_2)"; parameter Real[2] l(each min=0, each max=1) = {0.0001, 0.0001} "Valve leakage, l=Kv(y=0)/Kv(y=1)"; parameter Real deltaM = 0.02 "Fraction of nominal flow rate where linearization starts, if y=1" parameter Boolean[2] linearized = {false, false} "= true, use linear relation between m_flow and dp for any flow rate" protected Modelica.Blocks.Math.Feedback inv "Inversion of control signal" Modelica.Blocks.Sources.Constant uni(final k=1) "Outputs one for bypass valve" initial equation assert(homotopyInitialization, "In " + getInstanceName() + ": The constant homotopyInitialization has been modified from its default value. This constant will be removed in future releases.", level = AssertionLevel.warning); equation connect(uni.y, inv.u1) end PartialThreeWayValve;
Partial model for a two way valve. 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.
within AixLib.Fluid.Actuators.BaseClasses; partial model PartialTwoWayValve "Partial model for a two way valve" extends AixLib.Fluid.BaseClasses.PartialResistance( final dp_nominal=dpValve_nominal + dpFixed_nominal, dp(nominal=6000), final m_flow_turbulent = deltaM * abs(m_flow_nominal)); extends AixLib.Fluid.Actuators.BaseClasses.ValveParameters( rhoStd=Medium.density_pTX(101325, 273.15+4, Medium.X_default)); extends AixLib.Fluid.Actuators.BaseClasses.ActuatorSignal; parameter Modelica.Units.SI.PressureDifference dpFixed_nominal( displayUnit="Pa", min=0) = 0 "Pressure drop of pipe and other resistances that are in series" parameter Real l(min=1e-10, max=1) = 0.0001 "Valve leakage, l=Kv(y=0)/Kv(y=1)"; input Real phi "Ratio actual to nominal mass flow rate of valve, phi=Kv(y)/Kv(y=1)"; parameter Real kFixed(unit="", min=0) = if dpFixed_nominal > Modelica.Constants.eps then m_flow_nominal / sqrt(dpFixed_nominal) else 0 "Flow coefficient of fixed resistance that may be in series with valve, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2)."; Real kVal(unit="", min=Modelica.Constants.small) "Flow coefficient of valve, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2)."; Real k(unit="", min=Modelica.Constants.small) "Flow coefficient of valve and pipe in series, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2)."; initial equation assert(dpFixed_nominal > -Modelica.Constants.eps, "In " + getInstanceName() + ": Model requires dpFixed_nominal >= 0 but received dpFixed_nominal = " + String(dpFixed_nominal) + " Pa."); end PartialTwoWayValve;
Partial model for a two way valve using a Kv characteristic. Partial model for valves with different opening characteristics, such as linear, equal percentage or quick opening. This partial extends from <a href=\"modelica://AixLib.Fluid.Actuators.BaseClasses.PartialTwoWayValve\"> AixLib.Fluid.Actuators.BaseClasses.PartialTwoWayValve</a> and also contains the governing equations for these three two way valve models.
within AixLib.Fluid.Actuators.BaseClasses; partial model PartialTwoWayValveKv "Partial model for a two way valve using a Kv characteristic" extends AixLib.Fluid.Actuators.BaseClasses.PartialTwoWayValve; equation kVal = phi*Kv_SI; if (dpFixed_nominal > Modelica.Constants.eps) then k = sqrt(1/(1/kFixed^2 + 1/kVal^2)); else k = kVal; end if; if linearized then // This implementation yields m_flow_nominal = phi*kv_SI * sqrt(dp_nominal) // if m_flow = m_flow_nominal and dp = dp_nominal m_flow*m_flow_nominal_pos = k^2 * dp; else if homotopyInitialization then if from_dp then m_flow=homotopy(actual=AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp(dp=dp, k=k, m_flow_turbulent=m_flow_turbulent), simplified=m_flow_nominal_pos*dp/dp_nominal_pos); else dp=homotopy(actual=AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow(m_flow=m_flow, k=k, m_flow_turbulent=m_flow_turbulent), simplified=dp_nominal_pos*m_flow/m_flow_nominal_pos); end if; else // do not use homotopy if from_dp then m_flow=AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp(dp=dp, k=k, m_flow_turbulent=m_flow_turbulent); else dp=AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow(m_flow=m_flow, k=k, m_flow_turbulent=m_flow_turbulent); end if; end if; // homotopyInitialization end if; // linearized end PartialTwoWayValveKv;
Model with parameters for valves. Model that computes the flow coefficients of valves. This base class allows the following modeling options, which have been adapted from the valve implementation in <a href=\"modelica://Modelica.Fluid\"> Modelica.Fluid</a> to specify the valve flow coefficient in fully open conditions:
within AixLib.Fluid.Actuators.BaseClasses; partial model ValveParameters "Model with parameters for valves" parameter AixLib.Fluid.Types.CvTypes CvData=AixLib.Fluid.Types.CvTypes.OpPoint "Selection of flow coefficient" parameter Real Kv( fixed= if CvData==AixLib.Fluid.Types.CvTypes.Kv then true else false) "Kv (metric) flow coefficient [m3/h/(bar)^(1/2)]" parameter Real Cv( fixed= if CvData==AixLib.Fluid.Types.CvTypes.Cv then true else false) "Cv (US) flow coefficient [USG/min/(psi)^(1/2)]" parameter Modelica.Units.SI.Area Av(fixed=if CvData == AixLib.Fluid.Types.CvTypes.Av then true else false) "Av (metric) flow coefficient" parameter Real deltaM = 0.02 "Fraction of nominal flow rate where linearization starts, if y=1" parameter Modelica.Units.SI.MassFlowRate m_flow_nominal "Nominal mass flow rate" parameter Modelica.Units.SI.PressureDifference dpValve_nominal( displayUnit="Pa", min=0, fixed=if CvData == AixLib.Fluid.Types.CvTypes.OpPoint then true else false) "Nominal pressure drop of fully open valve, used if CvData=AixLib.Fluid.Types.CvTypes.OpPoint" parameter Modelica.Units.SI.Density rhoStd "Inlet density for which valve coefficients are defined" protected parameter Real Kv_SI( min=0, fixed= false) "Flow coefficient for fully open valve in SI units, Kv=m_flow/sqrt(dp) [kg/s/(Pa)^(1/2)]" initial equation if CvData == AixLib.Fluid.Types.CvTypes.OpPoint then Kv_SI = m_flow_nominal/sqrt(dpValve_nominal); Kv = Kv_SI/(rhoStd/3600/sqrt(1E5)); Cv = Kv_SI/(rhoStd*0.0631/1000/sqrt(6895)); Av = Kv_SI/sqrt(rhoStd); elseif CvData == AixLib.Fluid.Types.CvTypes.Kv then Kv_SI = Kv*rhoStd/3600/sqrt(1E5) "Unit conversion m3/(h*sqrt(bar)) to kg/(s*sqrt(Pa))"; Cv = Kv_SI/(rhoStd*0.0631/1000/sqrt(6895)); Av = Kv_SI/sqrt(rhoStd); dpValve_nominal = (m_flow_nominal/Kv_SI)^2; elseif CvData == AixLib.Fluid.Types.CvTypes.Cv then Kv_SI = Cv*rhoStd*0.0631/1000/sqrt(6895) "Unit conversion USG/(min*sqrt(psi)) to kg/(s*sqrt(Pa))"; Kv = Kv_SI/(rhoStd/3600/sqrt(1E5)); Av = Kv_SI/sqrt(rhoStd); dpValve_nominal = (m_flow_nominal/Kv_SI)^2; else assert(CvData == AixLib.Fluid.Types.CvTypes.Av, "Invalid value for CvData. Obtained CvData = " + String(CvData) + "."); Kv_SI = Av*sqrt(rhoStd); Kv = Kv_SI/(rhoStd/3600/sqrt(1E5)); Cv = Kv_SI/(rhoStd*0.0631/1000/sqrt(6895)); dpValve_nominal = (m_flow_nominal/Kv_SI)^2; end if; end ValveParameters;
Rangeability. This example checks whether the function derivative is implemented correctly. If the derivative implementation is not correct, the model will stop with an assert statement.
within AixLib.Fluid.Actuators.BaseClasses.Examples; model EqualPercentageDerivativeCheck extends Modelica.Icons.Example; parameter Real R = 50 "Rangeability"; parameter Real delta = 0.01 "Value where transition occurs"; parameter Real l = 0.001 "Leakage"; Real x; Real y; initial equation y=x; equation x=AixLib.Fluid.Actuators.BaseClasses.equalPercentage(time, R, l, delta); der(y)=der(x); assert(abs(x-y) < 1E-2, "Model has an error"); end EqualPercentageDerivativeCheck;
Collection of models that illustrate model use and test models
within AixLib.Fluid.Actuators.BaseClasses; package Examples "Collection of models that illustrate model use and test models" extends Modelica.Icons.ExamplesPackage; end Examples;
Air damper with exponential opening characteristics. Model of two flow resistances in series:
within AixLib.Fluid.Actuators.Dampers; model Exponential "Air damper with exponential opening characteristics" extends AixLib.Fluid.Actuators.BaseClasses.PartialDamperExponential; equation // Pressure drop calculation if linearized then m_flow*m_flow_nominal_pos = k^2*dp; else if homotopyInitialization then if from_dp then m_flow=homotopy( actual=AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp( dp=dp, k=k, m_flow_turbulent=m_flow_turbulent), simplified= m_flow_nominal_pos*dp/max(Modelica.Constants.eps, dp_nominal_pos)); else dp=homotopy( actual=AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow( m_flow=m_flow, k=k, m_flow_turbulent=m_flow_turbulent), simplified=dp_nominal_pos*m_flow/m_flow_nominal_pos); end if; // from_dp else // do not use homotopy if from_dp then m_flow=AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp( dp=dp, k=k, m_flow_turbulent=m_flow_turbulent); else dp=AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow( m_flow=m_flow, k=k, m_flow_turbulent=m_flow_turbulent); end if; // from_dp end if; // homotopyInitialization end if; // linearized end Exponential;
Outside air mixing box with interlocked air dampers
within AixLib.Fluid.Actuators.Dampers; model MixingBox "Outside air mixing box with interlocked air dampers" extends AixLib.Fluid.Actuators.BaseClasses.ActuatorSignal; replaceable package Medium = Modelica.Media.Interfaces.PartialMedium "Medium in the component" import Modelica.Constants; parameter Boolean allowFlowReversal = true "= false to simplify equations, assuming, but not enforcing, no flow reversal" parameter Boolean use_deltaM = true "Set to true to use deltaM for turbulent transition, else ReC is used"; parameter Real deltaM = 0.3 "Fraction of nominal mass flow rate where transition to turbulent occurs" parameter Boolean roundDuct = false "Set to true for round duct, false for square cross section" parameter Real ReC=4000 "Reynolds number where transition to turbulence starts" parameter Modelica.Units.SI.MassFlowRate mOut_flow_nominal "Mass flow rate outside air damper" parameter Modelica.Units.SI.PressureDifference dpDamOut_nominal(min=0, displayUnit="Pa") "Pressure drop of damper in outside air leg" parameter Modelica.Units.SI.PressureDifference dpFixOut_nominal( min=0, displayUnit="Pa") = 0 "Pressure drop of duct and other resistances in outside air leg" parameter Modelica.Units.SI.MassFlowRate mRec_flow_nominal "Mass flow rate recirculation air damper" parameter Modelica.Units.SI.PressureDifference dpDamRec_nominal(min=0, displayUnit="Pa") "Pressure drop of damper in recirculation air leg" parameter Modelica.Units.SI.PressureDifference dpFixRec_nominal( min=0, displayUnit="Pa") = 0 "Pressure drop of duct and other resistances in recirculation air leg" parameter Modelica.Units.SI.MassFlowRate mExh_flow_nominal "Mass flow rate exhaust air damper" parameter Modelica.Units.SI.PressureDifference dpDamExh_nominal(min=0, displayUnit="Pa") "Pressure drop of damper in exhaust air leg" parameter Modelica.Units.SI.PressureDifference dpFixExh_nominal( min=0, displayUnit="Pa") = 0 "Pressure drop of duct and other resistances in exhaust air leg" parameter Boolean from_dp=true "= true, use m_flow = f(dp) else dp = f(m_flow)" parameter Boolean linearized=false "= true, use linear relation between m_flow and dp for any flow rate" parameter Boolean use_constant_density=true "Set to true to use constant density for flow friction" parameter Real a=-1.51 "Coefficient a for damper characteristics" parameter Real b=0.105*90 "Coefficient b for damper characteristics" parameter Real yL=15/90 "Lower value for damper curve" parameter Real yU=55/90 "Upper value for damper curve" parameter Real k1=0.45 "Flow coefficient for y=1, k1 = pressure drop divided by dynamic pressure" parameter Real l(min=1e-10, max=1) = 0.0001 "Damper leakage, ratio of flow coefficients k(y=0)/k(y=1)" Modelica.Fluid.Interfaces.FluidPort_a port_Out(redeclare package Medium = Medium, m_flow(start=0, min=if allowFlowReversal then -Constants.inf else 0)) "Fluid connector a (positive design flow direction is from port_a to port_b)" Modelica.Fluid.Interfaces.FluidPort_b port_Exh(redeclare package Medium = Medium, m_flow(start=0, max=if allowFlowReversal then +Constants.inf else 0)) "Fluid connector b (positive design flow direction is from port_a to port_b)" Modelica.Fluid.Interfaces.FluidPort_a port_Ret(redeclare package Medium = Medium, m_flow(start=0, min=if allowFlowReversal then -Constants.inf else 0)) "Fluid connector a (positive design flow direction is from port_a to port_b)" Modelica.Fluid.Interfaces.FluidPort_b port_Sup(redeclare package Medium = Medium, m_flow(start=0, max=if allowFlowReversal then +Constants.inf else 0)) "Fluid connector b (positive design flow direction is from port_a to port_b)" AixLib.Fluid.Actuators.Dampers.Exponential damOA( redeclare final package Medium = Medium, final m_flow_nominal=mOut_flow_nominal, final dpDamper_nominal=dpDamOut_nominal, final dpFixed_nominal=dpFixOut_nominal, final from_dp=from_dp, final linearized=linearized, final use_deltaM=use_deltaM, final deltaM=deltaM, final roundDuct=roundDuct, final ReC=ReC, final a=a, final b=b, final yL=yL, final yU=yU, final l=l, final k1=k1, final use_constant_density=use_constant_density, final allowFlowReversal=allowFlowReversal, final use_inputFilter=false) "Outdoor air damper" AixLib.Fluid.Actuators.Dampers.Exponential damExh( redeclare final package Medium = Medium, final m_flow_nominal=mExh_flow_nominal, final dpDamper_nominal=dpDamExh_nominal, final dpFixed_nominal=dpFixExh_nominal, final from_dp=from_dp, final linearized=linearized, final use_deltaM=use_deltaM, final deltaM=deltaM, final roundDuct=roundDuct, final ReC=ReC, final a=a, final b=b, final yL=yL, final yU=yU, final l=l, final k1=k1, final use_constant_density=use_constant_density, final allowFlowReversal=allowFlowReversal, final use_inputFilter=false) "Exhaust air damper" AixLib.Fluid.Actuators.Dampers.Exponential damRec( redeclare final package Medium = Medium, final m_flow_nominal=mRec_flow_nominal, final dpDamper_nominal=dpDamRec_nominal, final dpFixed_nominal=dpFixRec_nominal, final from_dp=from_dp, final linearized=linearized, final use_deltaM=use_deltaM, final deltaM=deltaM, final roundDuct=roundDuct, final ReC=ReC, final a=a, final b=b, final yL=yL, final yU=yU, final l=l, final k1=k1, final use_constant_density=use_constant_density, final allowFlowReversal=allowFlowReversal, final use_inputFilter=false) "Recirculation air damper" Modelica.Blocks.Sources.Constant uni(k=1) "Unity signal" Modelica.Blocks.Math.Add add(k2=-1) "Adder" protected parameter Medium.Density rho_default=Medium.density(sta_default) "Density, used to compute fluid volume"; parameter Medium.ThermodynamicState sta_default= Medium.setState_pTX(T=Medium.T_default, p=Medium.p_default, X=Medium.X_default) "Default medium state"; equation connect(uni.y, add.u1) connect(add.y, damRec.y) connect(damOA.port_a, port_Out) connect(damExh.port_b, port_Exh) connect(port_Sup, damOA.port_b) connect(damRec.port_b, port_Sup) connect(port_Ret, damExh.port_a) connect(port_Ret, damRec.port_a) connect(y_actual, add.u2) connect(y_actual, damOA.y) connect(y_actual, damExh.y) end MixingBox;
Package with air damper models
within AixLib.Fluid.Actuators; package Dampers "Package with air damper models" extends Modelica.Icons.VariantsPackage; end Dampers;
Model for an air damper whose mass flow is proportional to the input signal. Model for an air damper whose airflow is proportional to the input signal, assuming that at <code>y = 1</code>, <code>m_flow = m_flow_nominal</code>. This is unless the pressure difference <code>dp</code> is too low, in which case a <code>kDam = m_flow_nominal/sqrt(dp_nominal)</code> characteristic is used.
within AixLib.Fluid.Actuators.Dampers; model PressureIndependent "Model for an air damper whose mass flow is proportional to the input signal" extends AixLib.Fluid.Actuators.BaseClasses.PartialDamperExponential( final linearized=false, final casePreInd=true, from_dp=true); input Real phi = l + y_internal*(1 - l) "Ratio actual to nominal mass flow rate of damper, phi=kDam(y)/kDam(y=1)"; parameter Real l2(unit="1", min=1e-10) = 0.01 "Gain for mass flow increase if pressure is above nominal pressure" parameter Real deltax(unit="1", min=1E-5) = 0.02 "Transition interval for flow rate" protected constant Real y_min = 2E-2 "Minimum value of control signal before zeroing of the opening"; constant Integer sizeSupSplBnd = 5 "Number of support points on each quadratic domain for spline interpolation"; constant Integer sizeSupSpl = 2 * sizeSupSplBnd + 3 "Total number of support points for spline interpolation"; constant Real y2dd = 0 "Second derivative at second support point"; parameter Real[sizeSupSpl] ySupSpl_raw = cat( 1, linspace(1, yU, sizeSupSplBnd), {yU-1/3*(yU-yL), (yU+yL)/2, yU-2/3*(yU-yL)}, linspace(yL, 0, sizeSupSplBnd)) "y values of unsorted support points for spline interpolation"; parameter Real[sizeSupSpl] kSupSpl_raw = AixLib.Fluid.Actuators.BaseClasses.exponentialDamper( y=ySupSpl_raw, a=a, b=b, cL=cL, cU=cU, yL=yL, yU=yU) .^ 2 "k values of unsorted support points for spline interpolation"; parameter Real[sizeSupSpl] ySupSpl(each fixed=false) "y values of sorted support points for spline interpolation"; parameter Real[sizeSupSpl] kSupSpl(each fixed=false) "k values of sorted support points for spline interpolation"; parameter Integer[sizeSupSpl] idx_sorted(each fixed=false) "Indices of sorted support points"; parameter Real[sizeSupSpl] invSplDer(each fixed=false) "Derivatives at support points for spline interpolation"; parameter Real coeff1 = l2/dpDamper_nominal*m_flow_nominal "Parameter for avoiding unnecessary computations"; parameter Real coeff2 = 1/coeff1 "Parameter for avoiding unnecessary computations"; Real kSquInv "Square inverse of flow coefficient (damper plus fixed resistance)"; Real kDamSquInv "Square inverse of flow coefficient (damper only)"; Modelica.Units.SI.MassFlowRate m_flow_set "Requested mass flow rate"; Modelica.Units.SI.PressureDifference dp_min(displayUnit="Pa") "Minimum pressure difference required for delivering requested mass flow rate"; Modelica.Units.SI.PressureDifference dp_x; Modelica.Units.SI.PressureDifference dp_x1; Modelica.Units.SI.PressureDifference dp_x2; Modelica.Units.SI.PressureDifference dp_y2; Modelica.Units.SI.PressureDifference dp_y1 "Support points for interpolation flow functions"; Modelica.Units.SI.MassFlowRate m_flow_x; Modelica.Units.SI.MassFlowRate m_flow_x1; Modelica.Units.SI.MassFlowRate m_flow_x2; Modelica.Units.SI.MassFlowRate m_flow_y2; Modelica.Units.SI.MassFlowRate m_flow_y1 "Support points for interpolation flow functions"; Modelica.Units.SI.MassFlowRate m_flow_smooth "Smooth interpolation result between two flow regimes"; Modelica.Units.SI.PressureDifference dp_smooth "Smooth interpolation result between two flow regimes"; Real y_actual_smooth(final unit="1") "Fractional opening computed based on m_flow_smooth and dp"; function basicFlowFunction_dp_m_flow "Inverse of flow function that computes that computes the square inverse of flow coefficient" extends Modelica.Icons.Function; input Modelica.Units.SI.MassFlowRate m_flow "Mass flow rate in design flow direction"; input Modelica.Units.SI.PressureDifference dp "Pressure difference between port_a and port_b (= port_a.p - port_b.p)"; input Modelica.Units.SI.MassFlowRate m_flow_small "Minimum value of mass flow rate guarding against k=(0)/sqrt(dp)"; input Modelica.Units.SI.PressureDifference dp_small "Minimum value of pressure drop guarding against k=m_flow/(0)"; output Real kSquInv "Square inverse of flow coefficient"; protected Modelica.Units.SI.PressureDifference dpPos= AixLib.Utilities.Math.Functions.smoothMax( dp, -dp, dp_small) "Regularized absolute value of pressure drop"; Real mSqu_flow = AixLib.Utilities.Math.Functions.smoothMax( m_flow^2, m_flow_small^2, m_flow_small^2) "Regularized square value of mass flow rate"; algorithm kSquInv := dpPos / mSqu_flow; end basicFlowFunction_dp_m_flow; function exponentialDamper_inv "Inverse function of the exponential damper characteristics" extends Modelica.Icons.Function; input Real kTheta "Loss coefficient"; input Real[:] kSupSpl "k values of support points"; input Real[:] ySupSpl "y values of support points"; input Real[:] invSplDer "Derivatives at support points"; output Real y "Fractional opening"; protected parameter Integer sizeSupSpl = size(kSupSpl, 1) "Number of spline support points"; Integer i "Integer to select data interval"; algorithm i := 1; for j in 2:sizeSupSpl loop if kTheta <= kSupSpl[j] then i := j; break; end if; end for; y := AixLib.Utilities.Math.Functions.smoothLimit( AixLib.Utilities.Math.Functions.cubicHermiteLinearExtrapolation( x=kTheta, x1=kSupSpl[i - 1], x2=kSupSpl[i], y1=ySupSpl[i - 1], y2=ySupSpl[i], y1d=invSplDer[i - 1], y2d=invSplDer[i]), 0, 1, 1E-3); end exponentialDamper_inv; initial equation (kSupSpl, idx_sorted) = Modelica.Math.Vectors.sort(kSupSpl_raw, ascending=true); // The sum below is a trick to avoid in OPTIMICA the warning // Variable array index in equation can result in slow simulation time. // This warning was issued for the formulation ySupSpl = ySupSpl_raw[idx_sorted]; for i in 1:sizeSupSpl loop ySupSpl[i] = sum((if k == idx_sorted[i] then ySupSpl_raw[k] else 0) for k in 1:sizeSupSpl); end for; invSplDer = AixLib.Utilities.Math.Functions.splineDerivatives(x=kSupSpl_raw, y=ySupSpl_raw); equation // From TwoWayPressureIndependent valve model m_flow_set = m_flow_nominal*phi; dp_min = AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow( m_flow=m_flow_set, k=kTotMax, m_flow_turbulent=m_flow_turbulent); if from_dp then m_flow_x=0; m_flow_x1=0; m_flow_x2=0; dp_y1=0; dp_y2=0; dp_smooth=0; dp_x = dp-dp_min; dp_x1 = -dp_x2; dp_x2 = deltax*dp_min; // min function ensures that m_flow_y1 does not increase further for dp_x > dp_x1 m_flow_y1 = AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp( dp=min(dp, dp_min+dp_x1), k=kTotMax, m_flow_turbulent=m_flow_turbulent); // max function ensures that m_flow_y2 does not decrease further for dp_x < dp_x2 m_flow_y2 = m_flow_set + coeff1*max(dp_x,dp_x2); m_flow_smooth = noEvent(smooth(2, if dp_x <= dp_x1 then m_flow_y1 elseif dp_x >=dp_x2 then m_flow_y2 else AixLib.Utilities.Math.Functions.quinticHermite( x=dp_x, x1=dp_x1, x2=dp_x2, y1=m_flow_y1, y2=m_flow_y2, y1d= AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp_der( dp=dp_min + dp_x1, k=kTotMax, m_flow_turbulent=m_flow_turbulent, dp_der=1), y2d=coeff1, y1dd=AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp_der2( dp=dp_min + dp_x1, k=kTotMax, m_flow_turbulent=m_flow_turbulent, dp_der=1, dp_der2=0), y2dd=y2dd))); else dp_x=0; dp_x1=0; dp_x2=0; m_flow_y1=0; m_flow_y2=0; m_flow_smooth=0; m_flow_x = m_flow-m_flow_set; m_flow_x1 = -m_flow_x2; m_flow_x2 = deltax*m_flow_set; // min function ensures that dp_y1 does not increase further for m_flow_x > m_flow_x1 dp_y1 = AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow( m_flow=min(m_flow, m_flow_set + m_flow_x1), k=kTotMax, m_flow_turbulent=m_flow_turbulent); // max function ensures that dp_y2 does not decrease further for m_flow_x < m_flow_x2 dp_y2 = dp_min + coeff2*max(m_flow_x, m_flow_x2); dp_smooth = noEvent(smooth(2, if m_flow_x <= m_flow_x1 then dp_y1 elseif m_flow_x >=m_flow_x2 then dp_y2 else AixLib.Utilities.Math.Functions.quinticHermite( x=m_flow_x, x1=m_flow_x1, x2=m_flow_x2, y1=dp_y1, y2=dp_y2, y1d=AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow_der( m_flow=m_flow_set + m_flow_x1, k=kTotMax, m_flow_turbulent=m_flow_turbulent, m_flow_der=1), y2d=coeff2, y1dd=AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow_der2( m_flow=m_flow_set + m_flow_x1, k=kTotMax, m_flow_turbulent=m_flow_turbulent, m_flow_der=1, m_flow_der2=0), y2dd=y2dd))); end if; // Computation of damper opening kSquInv = basicFlowFunction_dp_m_flow( m_flow=m_flow, dp=dp, m_flow_small=1E-3*abs(m_flow_nominal), dp_small=1E-4*dp_nominal_pos); kDamSquInv = if dpFixed_nominal > Modelica.Constants.eps then kSquInv - 1 / kFixed^2 else kSquInv; // Use of regStep might no longer be needed when the leakage flow modeling is updated. y_actual_smooth = AixLib.Utilities.Math.Functions.regStep( x=y_internal - y_min, y1=exponentialDamper_inv( kTheta=kDamSquInv*2*rho*A^2, kSupSpl=kSupSpl, ySupSpl=ySupSpl, invSplDer=invSplDer), y2=0, x_small=1E-3); // Homotopy transformation if homotopyInitialization then if from_dp then m_flow=homotopy(actual=m_flow_smooth, simplified=m_flow_nominal_pos*dp/dp_nominal_pos); else dp=homotopy(actual=dp_smooth, simplified=dp_nominal_pos*m_flow/m_flow_nominal_pos); end if; y_actual = homotopy( actual=y_actual_smooth, simplified=y); else if from_dp then m_flow=m_flow_smooth; else dp=dp_smooth; end if; y_actual = y_actual_smooth; end if; </li> <li> inverting the exponential characteristics to compute the fractional opening from the loss coefficient value (directly derived from the flow coefficient). </li> </ul> <p> The quadratic interpolation used outside the exponential domain in the function <a href=\"modelica://AixLib.Fluid.Actuators.BaseClasses.exponentialDamper\"> AixLib.Fluid.Actuators.BaseClasses.exponentialDamper</a> yields a local extremum. Therefore, the formal inversion of the function is not possible. A cubic spline is used instead to fit the inverse of the damper characteristics. The central domain of the characteritics having a monotonous exponential profile, its inverse can be properly approximated with three equidistant support points. However, the quadratic functions used outside of the exponential domain can have various profiles depending on the damper coefficients. Therefore, five linearly distributed support points are used on each side domain to ensure a good fit of the inverse. </p> <p> Note that below a threshold value of the input control signal (fixed at 0.02), the fractional opening is forced to zero and no more related to the actual flow coefficient of the damper. This avoids steep transients of the computed opening while transitioning from reverse flow. This is to be considered as a modeling workaround (avoiding the introduction of an additional state variable) to prevent control chattering during shut off operation where the pressure difference at the damper boundaries can vary between slightly positive and negative values due to outdoor pressure variations. </p> </html>", revisions="<html> <ul> <li> August 11, 2021, by Michael Wetter:<br/> Reformulated initial equation section to avoid warning in OPTIMICA about variable array index.<br/> This is for <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1513\">IBPSA #1513</a>. </li> <li> June 10, 2021, by Michael Wetter:<br/> Changed implementation of the filter and changed the parameter <code>order</code> to a constant as most users need not change this value.<br/> This is for <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1498\">IBPSA #1498</a>. </li> <li> April 6, 2020, by Antoine Gautier:<br/> Added the computation of the damper opening. </li> <li> December 23, 2019 by Antoine Gautier:<br/> Refactored as the model can now extend directly <a href=\"modelica://AixLib.Fluid.Actuators.BaseClasses.PartialDamperExponential\"> AixLib.Fluid.Actuators.BaseClasses.PartialDamperExponential</a>.<br/> This is for <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1188\">IBPSA #1188</a>. </li> <li> March 21, 2017 by David Blum:<br/> First implementation. </li> </ul> </html>"), Icon(graphics={Line( points={{0,100},{0,-24}}), Rectangle( extent={{-100,40},{100,-42}}, lineColor={0,0,0}, fillPattern=FillPattern.HorizontalCylinder, fillColor={192,192,192}), Rectangle( extent={{-100,22},{100,-24}}, lineColor={0,0,0}, fillPattern=FillPattern.HorizontalCylinder, fillColor={0,127,255})}), __Dymola_LockedEditing="Model from IBPSA"); end PressureIndependent;
VAV box with a fixed resistance plus a damper model withe exponential characteristics. Model of two resistances in series. One resistance has a fixed flow coefficient, the other resistance is an air damper whose flow coefficient is an exponential function of the opening angle.
within AixLib.Fluid.Actuators.Dampers; model VAVBoxExponential "VAV box with a fixed resistance plus a damper model withe exponential characteristics" extends AixLib.Fluid.Actuators.BaseClasses.PartialDamperExponential( dp(nominal=dp_nominal), final kFixed=sqrt(kResSqu)); parameter Boolean dp_nominalIncludesDamper = true "set to true if dp_nominal includes the pressure loss of the open damper" protected parameter Modelica.Units.SI.PressureDifference dpDamOpe_nominal(displayUnit= "Pa") = k1*m_flow_nominal^2/2/Medium.density(sta_default)/A^2 "Pressure drop of fully open damper at nominal flow rate"; parameter Real kResSqu(unit="kg.m", fixed=false) "Resistance coefficient for fixed resistance element"; initial equation kResSqu = if dp_nominalIncludesDamper then m_flow_nominal^2 / (dp_nominal-dpDamOpe_nominal) else m_flow_nominal^2 / dp_nominal; assert(kResSqu > 0, "Wrong parameters in damper model: dp_nominal < dpDamOpe_nominal" + "\n dp_nominal = " + String(dp_nominal) + "\n dpDamOpe_nominal = " + String(dpDamOpe_nominal)); end VAVBoxExponential;
Dampers with constant pressure difference and varying control signal.
within AixLib.Fluid.Actuators.Dampers.Examples; model Damper "Dampers with constant pressure difference and varying control signal." extends Modelica.Icons.Example; package Medium = AixLib.Media.Air "Medium model for air"; AixLib.Fluid.Actuators.Dampers.Exponential res( redeclare package Medium = Medium, use_inputFilter=false, dpDamper_nominal=10, m_flow_nominal=1, k1=0.45) "A damper with quadratic relationship between m_flow and dp" Modelica.Blocks.Sources.Ramp yRam( duration=0.3, offset=0, startTime=0.2, height=1) AixLib.Fluid.Sources.Boundary_pT sou( redeclare package Medium = Medium, p(displayUnit="Pa") = 101335, T=293.15, nPorts=4) "Pressure boundary condition" AixLib.Fluid.Sources.Boundary_pT sin( redeclare package Medium = Medium, nPorts=4) "Pressure boundary condition" AixLib.Fluid.Actuators.Dampers.PressureIndependent preIndDpFixed_nominal( use_inputFilter=false, redeclare package Medium = Medium, m_flow_nominal=1, dpFixed_nominal=5, dpDamper_nominal=10) "A damper with a mass flow proportional to the input signal and using dpFixed_nominal" AixLib.Fluid.Actuators.Dampers.PressureIndependent preIndFrom_dp( use_inputFilter=false, redeclare package Medium = Medium, m_flow_nominal=1, dpFixed_nominal=0, dpDamper_nominal=10, from_dp=false) "A damper with a mass flow proportional to the input signal and using from_dp = false" AixLib.Fluid.Actuators.Dampers.PressureIndependent preInd( redeclare package Medium = Medium, m_flow_nominal=1, dpDamper_nominal=10, use_inputFilter=false) "A damper with a mass flow proportional to the input signal" equation connect(yRam.y, res.y) connect(yRam.y, preInd.y) connect(res.port_a, sou.ports[1]) connect(preInd.port_a, sou.ports[2]) connect(preIndFrom_dp.port_a, sou.ports[3]) connect(res.port_b, sin.ports[1]) connect(preInd.port_b, sin.ports[2]) connect(sou.ports[4], preIndDpFixed_nominal.port_a) connect(preIndFrom_dp.port_b, sin.ports[3]) connect(preIndDpFixed_nominal.port_b, sin.ports[4]) connect(preIndFrom_dp.y, yRam.y) connect(preIndDpFixed_nominal.y, yRam.y) end Damper;
Mixing box with constant pressure difference and varying control signal
within AixLib.Fluid.Actuators.Dampers.Examples; model MixingBox "Mixing box with constant pressure difference and varying control signal" extends Modelica.Icons.Example; package Medium = AixLib.Media.Air "Medium in the component" AixLib.Fluid.Actuators.Dampers.MixingBox mixBox( mOut_flow_nominal=1, mRec_flow_nominal=1, mExh_flow_nominal=1, redeclare package Medium = Medium, dpDamExh_nominal=10, dpDamOut_nominal=10, dpDamRec_nominal=10, dpFixExh_nominal=20, dpFixOut_nominal=20, dpFixRec_nominal=20) "mixing box" AixLib.Fluid.Sources.Boundary_pT bouIn( redeclare package Medium = Medium, T=273.15 + 10, use_p_in=true, nPorts=2) AixLib.Fluid.Sources.Boundary_pT bouSup( redeclare package Medium = Medium, T=273.15 + 26, use_p_in=true, nPorts=1) AixLib.Fluid.Sources.Boundary_pT bouRet( redeclare package Medium = Medium, T=273.15 + 20, use_p_in=true, nPorts=1) Modelica.Blocks.Sources.Constant PAtm(k=101325) Modelica.Blocks.Sources.Ramp PSup( offset=101320, height=-10, startTime=0, duration=20) Modelica.Blocks.Sources.Ramp PRet( height=10, offset=101330, duration=20, startTime=20) Modelica.Blocks.Sources.Step yDam( height=1, offset=0, startTime=60) equation connect(yDam.y, mixBox.y) connect(bouIn.p_in, PAtm.y) connect(PRet.y, bouRet.p_in) connect(bouSup.p_in, PSup.y) connect(bouIn.ports[1], mixBox.port_Out) connect(bouIn.ports[2], mixBox.port_Exh) connect(bouSup.ports[1], mixBox.port_Sup) connect(bouRet.ports[1], mixBox.port_Ret) end MixingBox;
Collection of models that illustrate model use and test models
within AixLib.Fluid.Actuators.Dampers; package Examples "Collection of models that illustrate model use and test models" extends Modelica.Icons.ExamplesPackage; end Examples;
VAV box with constant pressure difference and varying control signal
within AixLib.Fluid.Actuators.Dampers.Examples; model VAVBoxExponential "VAV box with constant pressure difference and varying control signal" extends Modelica.Icons.Example; package Medium = AixLib.Media.Air; AixLib.Fluid.Actuators.Dampers.Exponential dam( redeclare package Medium = Medium, dpDamper_nominal=5, m_flow_nominal=2) Modelica.Blocks.Sources.Step yDam( height=-1, offset=1, startTime=60) Modelica.Blocks.Sources.Ramp P( height=-20, offset=101335, startTime=0, duration=60) AixLib.Fluid.Sources.Boundary_pT sou( redeclare package Medium = Medium, T=273.15 + 20, nPorts=2, use_p_in=true) AixLib.Fluid.Sources.Boundary_pT sin( redeclare package Medium = Medium, T=273.15 + 20, nPorts=2, use_p_in=true) Modelica.Blocks.Sources.Constant PAtm(k=101325) AixLib.Fluid.Actuators.Dampers.Exponential vav( redeclare package Medium = Medium, dpDamper_nominal=5, dpFixed_nominal=5, m_flow_nominal=2) AixLib.Fluid.FixedResistances.PressureDrop res( from_dp=true, m_flow_nominal=2, redeclare package Medium = Medium, dp_nominal=5) equation connect(yDam.y,dam. y) connect(P.y, sou.p_in) connect(PAtm.y, sin.p_in) connect(yDam.y, vav.y) connect(res.port_b, dam.port_a) connect(sou.ports[1], res.port_a) connect(sou.ports[2], vav.port_a) connect(dam.port_b, sin.ports[1]) connect(sin.ports[2], vav.port_b) end VAVBoxExponential;
Collection of validation models
within AixLib.Fluid.Actuators.Dampers; package Validation "Collection of validation models" extends Modelica.Icons.ExamplesPackage; end Validation;
Test model for the pressure independent damper model
within AixLib.Fluid.Actuators.Dampers.Validation; model PressureIndependent "Test model for the pressure independent damper model" extends Modelica.Icons.Example; package Medium = AixLib.Media.Air "Medium model for air"; parameter Modelica.Units.SI.PressureDifference dp_nominal(displayUnit="Pa") = 10 "Damper nominal pressure drop"; parameter Modelica.Units.SI.MassFlowRate m_flow_nominal=1 "Damper nominal mass flow rate"; AixLib.Fluid.Actuators.Dampers.Exponential damExp( redeclare final package Medium = Medium, use_inputFilter=false, final dpDamper_nominal=dp_nominal, final m_flow_nominal=m_flow_nominal) "Damper with exponential opening characteristics" Modelica.Blocks.Sources.Ramp yRam( duration=0.3, offset=0, startTime=0.3, height=1) "Ramp up damper control signal" AixLib.Fluid.Sources.Boundary_pT sou( redeclare final package Medium = Medium, use_p_in=true, p(displayUnit="Pa") = 101335, T=293.15, nPorts=4) "Pressure boundary condition" AixLib.Fluid.Sources.Boundary_pT sin( redeclare final package Medium = Medium, nPorts=4) "Pressure boundary condition" AixLib.Fluid.Actuators.Dampers.PressureIndependent damPreInd( redeclare final package Medium = Medium, final m_flow_nominal=m_flow_nominal, final dpDamper_nominal=dp_nominal, use_inputFilter=false) "Pressure independent damper" Exponential damExpPI( redeclare final package Medium = Medium, use_inputFilter=false, final dpDamper_nominal=dp_nominal, final m_flow_nominal=m_flow_nominal) "Damper with exponential opening characteristics" Controls.Continuous.LimPID conPID( k=10, Ti=0.001, controllerType=Modelica.Blocks.Types.SimpleController.PID, initType=Modelica.Blocks.Types.Init.InitialState) "Discharge flow rate controller" Sensors.MassFlowRate senMasFlo( redeclare final package Medium = Medium) "Discharge flow rate sensor" Modelica.Blocks.Sources.Ramp yRam1( duration=0.3, offset=Medium.p_default - 20, startTime=0, height=40) "Ram up supply pressure" Modelica.Blocks.Sources.Ramp yRam2( duration=0.3, offset=0, startTime=0.7, height=-40) "Ramp down supply pressure" Modelica.Blocks.Math.Add add Sensors.RelativePressure senRelPre( redeclare final package Medium = Medium) "Pressure drop sensor" Modelica.Blocks.Math.Gain gain(final k=1/m_flow_nominal) "Normalize discharge flow rate" equation connect(damExp.port_a, sou.ports[1]) connect(damExp.port_b, sin.ports[1]) connect(sou.ports[2], damPreInd.port_a) connect(damPreInd.port_b, sin.ports[2]) connect(yRam.y, damPreInd.y) connect(damPreInd.y_actual, damExp.y) connect(damExpPI.port_b, senMasFlo.port_a) connect(senMasFlo.port_b, sin.ports[3]) connect(sou.ports[3], damExpPI.port_a) connect(conPID.y, damExpPI.y) connect(yRam.y, conPID.u_s) connect(yRam1.y, add.u1) connect(yRam2.y, add.u2) connect(add.y, sou.p_in) connect(sou.ports[4], senRelPre.port_a) connect(senRelPre.port_b, sin.ports[4]) connect(senMasFlo.m_flow, gain.u) connect(gain.y, conPID.u_m) end PressureIndependent;
Ideal motor model with hysteresis. Ideal actuator motor model with hysteresis and finite actuation speed. If the current actuator position <code>y</code> is below (or above) the input signal <code>u</code> by an amount bigger than the hysteresis <code>delta</code>, then the position <code>y</code> is increased (decreased) until it reaches <code>u</code>. The output <code>y</code> is bounded between <code>0</code> and <code>1</code>.
within AixLib.Fluid.Actuators.Motors; model IdealMotor "Ideal motor model with hysteresis" extends Modelica.Blocks.Interfaces.SISO; parameter Real delta(min=0, max=0.5) = 0.05 "Hysteresis"; parameter Modelica.Units.SI.Time tOpe(min=0) = 120 "Opening time"; parameter Modelica.Units.SI.Time tClo(min=0) = tOpe "Closing time"; parameter Real y_start(min=0, max=1) = 0.5 "Start position"; Modelica.Blocks.Logical.Hysteresis uppHys(final uLow=0, uHigh=delta, final pre_y_start=false) Modelica.Blocks.Logical.Hysteresis lowHys(uLow=-delta, final uHigh=0, final pre_y_start=true) "Lower hysteresis" Modelica.Blocks.Logical.Switch uppSwi Modelica.Blocks.Continuous.LimIntegrator int( final y_start=y_start, final k=1, outMax=1, outMin=0, initType=Modelica.Blocks.Types.Init.InitialState, limitsAtInit=true, y(stateSelect=StateSelect.always)) "Integrator for valve opening position" protected final Modelica.Blocks.Sources.Constant zer(final k=0) "Zero signal" Modelica.Blocks.Sources.Constant vOpe(final k=1/tOpe) "Opening speed" Modelica.Blocks.Sources.Constant vClo(final k=-1/tClo) "Closing speed" Modelica.Blocks.Logical.Switch lowSwi Modelica.Blocks.Math.Add add Modelica.Blocks.Math.Feedback feeBac "Feedback to compute position error" equation connect(zer.y, uppSwi.u3) connect(uppHys.y, uppSwi.u2) connect(vOpe.y, uppSwi.u1) connect(lowHys.y, lowSwi.u2) connect(vClo.y, lowSwi.u3) connect(zer.y, lowSwi.u1) connect(add.y, int.u) connect(uppSwi.y, add.u1) connect(u, feeBac.u1) connect(feeBac.y, uppHys.u) connect(feeBac.y, lowHys.u) connect(lowSwi.y, add.u2) connect(int.y, y) connect(int.y, feeBac.u2) end IdealMotor;
Package with motor models for valves and dampers
within AixLib.Fluid.Actuators; package Motors "Package with motor models for valves and dampers" extends Modelica.Icons.VariantsPackage; end Motors;
Test model for IdealMotor. Test model for the ideal motor with hysteresis model. The motor receives at its control input a time-varying signal. It adjusts its position whenever the input signal differs from the current position by more than the hysteresis.
within AixLib.Fluid.Actuators.Motors.Examples; model IdealMotor "Test model for IdealMotor" extends Modelica.Icons.Example; AixLib.Fluid.Actuators.Motors.IdealMotor mot(tOpe=60) "Motor model" Modelica.Blocks.Sources.TimeTable ySet(table=[0,0; 60,0; 60,1; 120,1; 180,0.5; 240,0.5; 300,0; 360,0; 360,0.25; 420,0.25; 480,1; 540,1.5; 600,-0.25]) "Set point for actuator" equation connect(ySet.y, mot.u) end IdealMotor;
Collection of models that illustrate model use and test models
within AixLib.Fluid.Actuators.Motors; package Examples "Collection of models that illustrate model use and test models" extends Modelica.Icons.ExamplesPackage; end Examples;
Package with valve models
within AixLib.Fluid.Actuators; package Valves "Package with valve models" extends Modelica.Icons.VariantsPackage; end Valves;
Three way valve with equal percentage and linear characteristics. Three way valve with equal percentage characteristics between <code>port_1</code> and <code>port_2</code> and linear opening characteristic between <code>port_3</code> and <code>port_2</code>. Such opening characteristics were typical for valves from Landis &amp; Gyr (now Siemens).
within AixLib.Fluid.Actuators.Valves; model ThreeWayEqualPercentageLinear "Three way valve with equal percentage and linear characteristics" extends BaseClasses.PartialThreeWayValve( redeclare TwoWayEqualPercentage res1( R=R, delta0=delta0, final l=l[1]), redeclare TwoWayLinear res3( final l=l[2])); parameter Real R = 50 "Rangeability, R=50...100 typically"; parameter Real delta0 = 0.01 "Range of significant deviation from equal percentage law"; equation connect(inv.y, res3.y) connect(y_actual, inv.u2) connect(y_actual, res1.y) end ThreeWayEqualPercentageLinear;
Three way valve with linear characteristics. Three way valve with linear opening characteristic.
within AixLib.Fluid.Actuators.Valves; model ThreeWayLinear "Three way valve with linear characteristics" extends BaseClasses.PartialThreeWayValve( redeclare TwoWayLinear res1( final l=l[1]), redeclare TwoWayLinear res3( final l=l[2])); equation connect(inv.y, res3.y) connect(y_actual, inv.u2) connect(y_actual, res1.y) end ThreeWayLinear;
Three way valve with table-specified characteristics. Three way valve with table-specified opening characteristics. A separate characteristic for each flow path is used.
within AixLib.Fluid.Actuators.Valves; model ThreeWayTable "Three way valve with table-specified characteristics" extends BaseClasses.PartialThreeWayValve(final l={0,0}, redeclare TwoWayTable res1(final flowCharacteristics=flowCharacteristics1), redeclare TwoWayTable res3(final flowCharacteristics=flowCharacteristics3)); parameter Data.Generic flowCharacteristics1 "Table with flow characteristics for direct flow path at port_1" parameter Data.Generic flowCharacteristics3 "Table with flow characteristics for bypass flow path at port_3" equation connect(inv.y, res3.y) connect(y_actual, inv.u2) connect(y_actual, res1.y) end ThreeWayTable;
Two way valve with the flow characteristic of a typical butterfly valve. Two way valve with the flow characteristic of a typical butterfly valve as listed below.
within AixLib.Fluid.Actuators.Valves; model TwoWayButterfly "Two way valve with the flow characteristic of a typical butterfly valve" extends AixLib.Fluid.Actuators.Valves.TwoWayPolynomial( final CvData = AixLib.Fluid.Types.CvTypes.Kv, final Kv = Kvs, final c={0,1.101898284705380E-01, 2.217227395456580, -7.483401207660790, 1.277617623360130E+01, -6.618045307070130}); parameter Real Kvs "Kv value at fully open valve" end TwoWayButterfly;
Two way valve with equal percentage flow characteristics. Two way valve with an equal percentage valve opening characteristic.
within AixLib.Fluid.Actuators.Valves; model TwoWayEqualPercentage "Two way valve with equal percentage flow characteristics" extends BaseClasses.PartialTwoWayValveKv( phi=max(0.1*l, if homotopyInitialization then homotopy(actual=AixLib.Fluid.Actuators.BaseClasses.equalPercentage( y_actual, R, l, delta0), simplified=l + y_actual*(1 - l)) else AixLib.Fluid.Actuators.BaseClasses.equalPercentage( y_actual, R, l, delta0))); parameter Real R=50 "Rangeability, R=50...100 typically"; parameter Real delta0=0.01 "Range of significant deviation from equal percentage law"; initial equation // Since the flow model AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow computes // 1/k^2, the parameter l must not be zero. assert(l > 0, "Valve leakage parameter l must be bigger than zero."); assert(l < 1/R, "Wrong parameters in valve model.\n" + " Rangeability R = " + String(R) + "\n" + " Leakage flow l = " + String(l) + "\n" + " Must have l < 1/R = " + String(1/R)); end TwoWayEqualPercentage;
Two way valve with linear flow characteristics. Two way valve with linear opening characteristic.
within AixLib.Fluid.Actuators.Valves; model TwoWayLinear "Two way valve with linear flow characteristics" extends BaseClasses.PartialTwoWayValveKv(phi=max(0.1*l, l + y_actual*(1 - l))); initial equation // Since the flow model AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow computes // 1/k^2, the parameter l must not be zero. assert(l > 0, "Valve leakage parameter l must be bigger than zero."); end TwoWayLinear;
Two way valve with polynomial characteristic. Two way valve with polynomial opening characteristic. The polynomial coefficients are defined using parameter <code>c</code>. The elements of <code>c</code> are coefficients for increasing powers of <code>y</code>, starting with the power <code>0</code>, which corresponds to a fixed offset. This valve model can be used to implement valves with a custom opening characteristic, such as a combination of a linear and an equal percentage characteristic.
within AixLib.Fluid.Actuators.Valves; model TwoWayPolynomial "Two way valve with polynomial characteristic" extends AixLib.Fluid.Actuators.BaseClasses.PartialTwoWayValveKv( phi=max(0.1*l, l + pol_y*(1 - l))); parameter Real[:] c "Polynomial coefficients, starting with fixed offset"; protected constant Integer nP = 100 "Number of points for initial algorithm test"; Real pol_y = sum(c.*{y_actual^i for i in 0:size(c,1)-1}) "Polynomial of valve control signal"; // Test the validity of the provided valve coefficients initial equation // We compute the analytic derivative of the polynomial for y=(1/points), // where the derivative of y^j = j*y^(j-1). if size(c, 1)>=2 then for i in 0:nP/2 loop assert(sum({c[j+1]*j*(i/nP)^(j-1) for j in 1:size(c, 1) - 1})>=0, "The provided valve polynomial coefficients do not lead to a strictly increasing characteristic for y=" + String(i/nP)+ ". This is not allowed."); end for; end if; assert(c[1]>=0, "The provided valve polynomial coefficients do not lead to a valve opening that is larger than or equal to zero for a control signal of zero."); assert(sum(c)<=1.1, "The provided valve polynomial coefficients do not lead to a valve opening that is smaller than or equal to one for a control signal of one."); end TwoWayPolynomial;
Model of a pressure-independent two way valve. Two way valve with a pressure-independent valve opening characteristic. The mass flow rate is controlled such that it is nearly equal to its set point <code>y*m_flow_nominal</code>, unless the pressure <code>dp</code> is too low, in which case a regular <code>Kv</code> characteristic is used.
within AixLib.Fluid.Actuators.Valves; model TwoWayPressureIndependent "Model of a pressure-independent two way valve" extends AixLib.Fluid.Actuators.BaseClasses.PartialTwoWayValve( final linearized = false, from_dp=true, phi=max(0.1*l, l + y_actual*(1 - l))); parameter Real l2(min=1e-10) = 0.01 "Gain for mass flow increase if pressure is above nominal pressure" parameter Real deltax = 0.02 "Transition interval for flow rate" protected parameter Real coeff1 = l2/dp_nominal*m_flow_nominal "Parameter for avoiding unnecessary computations"; parameter Real coeff2 = 1/coeff1 "Parameter for avoiding unnecessary computations"; constant Real y2dd = 0 "Second derivative at second support point"; Modelica.Units.SI.MassFlowRate m_flow_set "Requested mass flow rate"; Modelica.Units.SI.PressureDifference dp_min(displayUnit="Pa") "Minimum pressure difference required for delivering requested mass flow rate"; Modelica.Units.SI.PressureDifference dp_x; Modelica.Units.SI.PressureDifference dp_x1; Modelica.Units.SI.PressureDifference dp_x2; Modelica.Units.SI.PressureDifference dp_y2; Modelica.Units.SI.PressureDifference dp_y1 "Support points for interpolation flow functions"; Modelica.Units.SI.MassFlowRate m_flow_x; Modelica.Units.SI.MassFlowRate m_flow_x1; Modelica.Units.SI.MassFlowRate m_flow_x2; Modelica.Units.SI.MassFlowRate m_flow_y2; Modelica.Units.SI.MassFlowRate m_flow_y1 "Support points for interpolation flow functions"; Modelica.Units.SI.MassFlowRate m_flow_smooth "Smooth interpolation result between two flow regimes"; Modelica.Units.SI.PressureDifference dp_smooth "Smooth interpolation result between two flow regimes"; equation m_flow_set = m_flow_nominal*phi; kVal = Kv_SI; if (dpFixed_nominal > Modelica.Constants.eps) then k = sqrt(1/(1/kFixed^2 + 1/kVal^2)); else k = kVal; end if; dp_min = AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow( m_flow=m_flow_set, k=k, m_flow_turbulent=m_flow_turbulent); if from_dp then m_flow_x=0; m_flow_x1=0; m_flow_x2=0; dp_y1=0; dp_y2=0; dp_smooth=0; dp_x = dp-dp_min; dp_x1 = -dp_x2; dp_x2 = deltax*dp_min; // min function ensures that m_flow_y1 does not increase further for dp_x > dp_x1 m_flow_y1 = AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp( dp=min(dp, dp_min+dp_x1), k=k, m_flow_turbulent=m_flow_turbulent); // max function ensures that m_flow_y2 does not decrease further for dp_x < dp_x2 m_flow_y2 = m_flow_set + coeff1*max(dp_x,dp_x2); m_flow_smooth = noEvent(smooth(2, if dp_x <= dp_x1 then m_flow_y1 elseif dp_x >=dp_x2 then m_flow_y2 else AixLib.Utilities.Math.Functions.quinticHermite( x=dp_x, x1=dp_x1, x2=dp_x2, y1=m_flow_y1, y2=m_flow_y2, y1d= AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp_der( dp=dp_min + dp_x1, k=k, m_flow_turbulent=m_flow_turbulent, dp_der=1), y2d=coeff1, y1dd=AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp_der2( dp=dp_min + dp_x1, k=k, m_flow_turbulent=m_flow_turbulent, dp_der=1, dp_der2=0), y2dd=y2dd))); else dp_x=0; dp_x1=0; dp_x2=0; m_flow_y1=0; m_flow_y2=0; m_flow_smooth=0; m_flow_x = m_flow-m_flow_set; m_flow_x1 = -m_flow_x2; m_flow_x2 = deltax*m_flow_set; // min function ensures that dp_y1 does not increase further for m_flow_x > m_flow_x1 dp_y1 = AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow( m_flow=min(m_flow, m_flow_set + m_flow_x1), k=k, m_flow_turbulent=m_flow_turbulent); // max function ensures that dp_y2 does not decrease further for m_flow_x < m_flow_x2 dp_y2 = dp_min + coeff2*max(m_flow_x, m_flow_x2); dp_smooth = noEvent(smooth(2, if m_flow_x <= m_flow_x1 then dp_y1 elseif m_flow_x >=m_flow_x2 then dp_y2 else AixLib.Utilities.Math.Functions.quinticHermite( x=m_flow_x, x1=m_flow_x1, x2=m_flow_x2, y1=dp_y1, y2=dp_y2, y1d=AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow_der( m_flow=m_flow_set + m_flow_x1, k=k, m_flow_turbulent=m_flow_turbulent, m_flow_der=1), y2d=coeff2, y1dd=AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow_der2( m_flow=m_flow_set + m_flow_x1, k=k, m_flow_turbulent=m_flow_turbulent, m_flow_der=1, m_flow_der2=0), y2dd=y2dd))); end if; if homotopyInitialization then if from_dp then m_flow=homotopy(actual=m_flow_smooth, simplified=m_flow_nominal_pos*dp/dp_nominal_pos); else dp=homotopy( actual=dp_smooth, simplified=dp_nominal_pos*m_flow/m_flow_nominal_pos); end if; else if from_dp then m_flow=m_flow_smooth; else dp=dp_smooth; end if; end if; end TwoWayPressureIndependent;
Two way valve with quick opening flow characteristics. Two way valve with a power function for the valve opening characteristic. Valves that need to open quickly typically have such a valve characteristics.
within AixLib.Fluid.Actuators.Valves; model TwoWayQuickOpening "Two way valve with quick opening flow characteristics" extends BaseClasses.PartialTwoWayValveKv( phi=max(0.1*l, if homotopyInitialization then homotopy( actual=l + Modelica.Fluid.Utilities.regPow( y_actual, alpInv, delta0)*(1 - l), simplified=l + y_actual*(1 - l)) else l + Modelica.Fluid.Utilities.regPow(y_actual, alpInv, delta0)*(1 - l))); parameter Real alp = 2 "Parameter for valve characteristics, alp>0"; parameter Real delta0 = 0.01 "Range of significant deviation from power law"; protected parameter Real alpInv = 1/alp "Inverse of alpha"; initial equation // Since the flow model AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow computes // 1/k^2, the parameter l must not be zero. assert(l > 0, "Valve leakage parameter l must be bigger than zero."); end TwoWayQuickOpening;
Two way valve with table-specified flow characteristics. Two way valve with opening characteristic that is configured through a table.
within AixLib.Fluid.Actuators.Valves; model TwoWayTable "Two way valve with table-specified flow characteristics" extends BaseClasses.PartialTwoWayValveKv( phi=max(0.1*l, phiLooUp.y[1]), final l = phiLooUp.table[1, 2]); parameter Data.Generic flowCharacteristics "Table with flow characteristics" // Since the flow model AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow computes // 1/k^2, the flowCharacteristics.phi[1] must not be zero. // We therefore set a lower bound. protected Modelica.Blocks.Tables.CombiTable1Dv phiLooUp( final tableOnFile=false, final table=[flowCharacteristics.y,cat( 1, {max(flowCharacteristics.phi[1], 1E-8)}, {flowCharacteristics.phi[i] for i in 2:size(flowCharacteristics.phi, 1)})], final columns=2:2, final smoothness=Modelica.Blocks.Types.Smoothness.ContinuousDerivative) "Normalized mass flow rate for the given valve position under the assumption of a constant pressure" initial equation assert(abs(flowCharacteristics.y[1]) < Modelica.Constants.eps, "flowCharateristics.y[1] must be 0."); assert(abs(flowCharacteristics.y[size(flowCharacteristics.y, 1)] - 1) < Modelica.Constants.eps, "flowCharateristics.y[end] must be 1."); assert(abs(flowCharacteristics.phi[size(flowCharacteristics.phi, 1)] - 1) < Modelica.Constants.eps, "flowCharateristics.phi[end] must be 1."); // Assert that the sequences are strictly increasing assert(AixLib.Utilities.Math.Functions.isMonotonic( x=flowCharacteristics.y, strict=true), "The values for y in flowCharacteristics must be strictly increasing."); assert(AixLib.Utilities.Math.Functions.isMonotonic( x=flowCharacteristics.phi, strict=true), "The values for phi in flowCharacteristics must be strictly increasing."); equation connect(phiLooUp.u[1], y_actual) end TwoWayTable;
Data records for table-based valves
within AixLib.Fluid.Actuators.Valves; package Data "Data records for table-based valves" extends Modelica.Icons.MaterialPropertiesPackage; end Data;
<html><p> This model shows the usage of a MixingValve against its design-direction. The results show that it is possible to use the MixingValve against its design-direction. The valve will then split the incoming flow into two fractions according to the opening of the valve. </p> <p> 26.11.2014, by <i>Roozbeh Sangi</i>: implemented </p> </html>
within AixLib.Fluid.Actuators.Valves.Examples; model MixingValveBackwardDirection extends Modelica.Icons.Example; package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater; inner AixLib.Utilities.Sources.BaseParameters baseParameters AixLib.Fluid.Sources.Boundary_pT boundary_ph( redeclare package Medium = Medium, p=150000, nPorts=1) AixLib.Fluid.Sources.Boundary_pT boundary_ph1(nPorts=1, redeclare package Medium = Medium) AixLib.Fluid.Sources.Boundary_pT boundary_ph2(nPorts=1, redeclare package Medium = Medium) AixLib.Obsolete.Year2021.Fluid.Actuators.Valves.MixingValve mixingValveFiltered( filteredOpening=true, riseTime=100, redeclare package Medium = Medium) AixLib.Fluid.Sensors.TemperatureTwoPort temperatureSensorMixed(redeclare package Medium = Medium, m_flow_nominal=1) AixLib.Fluid.Sensors.MassFlowRate massFlowSensorMixed(redeclare package Medium = Medium) AixLib.Fluid.Sensors.TemperatureTwoPort temperatureSensor1(redeclare package Medium = Medium, m_flow_nominal=1) AixLib.Fluid.Sensors.MassFlowRate massFlowSensor1(redeclare package Medium = Medium) AixLib.Fluid.Sensors.TemperatureTwoPort temperatureSensor2(redeclare package Medium = Medium, m_flow_nominal=1) AixLib.Fluid.Sensors.MassFlowRate massFlowSensor2(redeclare package Medium = Medium) Modelica.Blocks.Sources.Step step(startTime=100, height=0.7) equation connect(temperatureSensorMixed.port_b, massFlowSensorMixed.port_a) connect(massFlowSensorMixed.port_b, mixingValveFiltered.port_2) connect(temperatureSensor1.port_b, massFlowSensor1.port_a) connect(temperatureSensor2.port_b, massFlowSensor2.port_a) connect(mixingValveFiltered.port_3, temperatureSensor1.port_a) connect(mixingValveFiltered.port_1, temperatureSensor2.port_a) connect(mixingValveFiltered.opening, step.y) connect(massFlowSensor1.port_b, boundary_ph1.ports[1]) connect(massFlowSensor2.port_b, boundary_ph2.ports[1]) connect(temperatureSensorMixed.port_a, boundary_ph.ports[1]) end MixingValveBackwardDirection;
<html><p> This model shows the usage of a MixingValve in its design-direction. The results are consistent with ones expectation of the function of a mixing valve. A step on the opening of the valve is applied after some time, which changes the the ratio between the two inflowing streams. </p> </html>
within AixLib.Fluid.Actuators.Valves.Examples; model MixingValveForwardDirection extends Modelica.Icons.Example; package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater; inner AixLib.Utilities.Sources.BaseParameters baseParameters AixLib.Fluid.Sources.Boundary_pT boundary_ph( nPorts=1, redeclare package Medium = Medium, p=150000) AixLib.Fluid.Sources.Boundary_pT boundary_ph1(nPorts=1, redeclare package Medium = Medium) AixLib.Fluid.Sources.Boundary_pT boundary_ph2( nPorts=1, redeclare package Medium = Medium, p=150000) AixLib.Obsolete.Year2021.Fluid.Actuators.Valves.MixingValve mixingValveFiltered( filteredOpening=true, riseTime=100, redeclare package Medium = Medium) AixLib.Fluid.Sensors.TemperatureTwoPort temperatureSensor1(redeclare package Medium = Medium, m_flow_nominal=1) AixLib.Fluid.Sensors.TemperatureTwoPort temperatureSensor2(redeclare package Medium = Medium, tau=1, m_flow_nominal=1) AixLib.Fluid.Sensors.MassFlowRate massFlowSensor1(redeclare package Medium = Medium) AixLib.Fluid.Sensors.MassFlowRate massFlowSensor2(redeclare package Medium = Medium) Modelica.Blocks.Sources.Step step(startTime=100, height=0.7) AixLib.Fluid.Sensors.TemperatureTwoPort temperatureSensorMixed(redeclare package Medium = Medium, m_flow_nominal=1) AixLib.Fluid.Sensors.MassFlowRate massFlowSensorMixed(redeclare package Medium = Medium) equation connect(temperatureSensor2.port_b, massFlowSensor2.port_a) connect(temperatureSensor1.port_b, massFlowSensor1.port_a) connect(massFlowSensor1.port_b, mixingValveFiltered.port_3) connect(massFlowSensor2.port_b, mixingValveFiltered.port_1) connect(step.y, mixingValveFiltered.opening) connect(mixingValveFiltered.port_2, temperatureSensorMixed.port_a) connect(temperatureSensorMixed.port_b, massFlowSensorMixed.port_a) connect(temperatureSensor1.port_a, boundary_ph.ports[1]) connect(massFlowSensorMixed.port_b, boundary_ph1.ports[1]) connect(temperatureSensor2.port_a, boundary_ph2.ports[1]) end MixingValveForwardDirection;
Collection of models that illustrate model use and test models
within AixLib.Fluid.Actuators.Valves; package Examples "Collection of models that illustrate model use and test models" extends Modelica.Icons.ExamplesPackage; end Examples;
Three way valves with different opening characteristics
within AixLib.Fluid.Actuators.Valves.Examples; model ThreeWayValves "Three way valves with different opening characteristics" extends Modelica.Icons.Example; package Medium = AixLib.Media.Water "Medium in the component"; AixLib.Fluid.Actuators.Valves.ThreeWayLinear valLin( redeclare package Medium = Medium, l={0.05,0.05}, m_flow_nominal=2, use_inputFilter=false, dpValve_nominal=6000, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial) "Valve model, linear opening characteristics" Modelica.Blocks.Sources.Ramp y( height=1, duration=1, offset=0) "Control signal" AixLib.Fluid.Sources.Boundary_pT sou( redeclare package Medium = Medium, nPorts=3, use_p_in=true, T=313.15) "Boundary condition for flow source" AixLib.Fluid.Sources.Boundary_pT sin( redeclare package Medium = Medium, nPorts=3, use_p_in=true, T=313.15) "Boundary condition for flow sink" Modelica.Blocks.Sources.Constant PSin(k=3E5) Modelica.Blocks.Sources.Constant PSou(k=306000) Actuators.Valves.ThreeWayEqualPercentageLinear valEquPerLin( l={0.05,0.05}, redeclare package Medium = Medium, R=10, m_flow_nominal=2, use_inputFilter=false, dpValve_nominal=6000, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial) AixLib.Fluid.Sources.Boundary_pT ret( redeclare package Medium = Medium, nPorts=3, use_p_in=true, T=303.15) "Boundary condition for flow sink" AixLib.Fluid.Actuators.Valves.ThreeWayTable valTab( redeclare package Medium = Medium, m_flow_nominal=2, use_inputFilter=false, dpValve_nominal=6000, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, flowCharacteristics1=AixLib.Fluid.Actuators.Valves.Data.Linear(), flowCharacteristics3(y={0,0.5,1}, phi={0.001,0.3,1})) "Valve model, linear opening characteristics" equation connect(y.y, valLin.y) connect(PSin.y, sin.p_in) connect(y.y, valEquPerLin.y) connect(sou.ports[1], valLin.port_1) connect(sou.ports[2], valEquPerLin.port_1) connect(valLin.port_2, sin.ports[1]) connect(valEquPerLin.port_2, sin.ports[2]) connect(PSou.y, ret.p_in) connect(ret.ports[1], valLin.port_3) connect(ret.ports[2], valEquPerLin.port_3) connect(PSou.y, sou.p_in) connect(valTab.port_1, sou.ports[3]) connect(valTab.port_2, sin.ports[3]) connect(valTab.port_3, ret.ports[3]) connect(valTab.y, y.y) end ThreeWayValves;
Two way valves with pressure independent opening characteristic
within AixLib.Fluid.Actuators.Valves.Examples; model TwoWayValvePressureIndependent "Two way valves with pressure independent opening characteristic" extends Modelica.Icons.Example; package Medium = AixLib.Media.Water; Modelica.Blocks.Sources.Ramp y( height=1, duration=1, offset=0) "Control signal" AixLib.Fluid.Sources.Boundary_pT sou( redeclare package Medium = Medium, use_p_in=true, T=293.15, nPorts=3) "Boundary condition for flow source" AixLib.Fluid.Sources.Boundary_pT sin( redeclare package Medium = Medium, p(displayUnit="Pa") = 3E5, T=293.15, nPorts=3) "Boundary condition for flow sink" TwoWayPressureIndependent valInd( redeclare package Medium = Medium, m_flow_nominal=1, CvData=AixLib.Fluid.Types.CvTypes.OpPoint, use_inputFilter=false, l=0.05, from_dp=true, dpFixed_nominal=0, l2=0.1, dpValve_nominal=10000) "Pressure independent valve" Modelica.Blocks.Sources.Ramp dp( duration=1, startTime=1, offset=303000, height=12000) "Pressure ramp" TwoWayPressureIndependent valIndDpFix( redeclare package Medium = Medium, m_flow_nominal=1, CvData=AixLib.Fluid.Types.CvTypes.OpPoint, use_inputFilter=false, l=0.05, dpFixed_nominal=5000, from_dp=true, l2=0.1, dpValve_nominal=10000) "Pressure independent valve using dp_Fixed_nominal" TwoWayPressureIndependent valIndFromMflow( redeclare package Medium = Medium, m_flow_nominal=1, CvData=AixLib.Fluid.Types.CvTypes.OpPoint, use_inputFilter=false, l=0.05, from_dp=false, dpFixed_nominal=0, l2=0.1, dpValve_nominal=10000) "Pressure independent valve using from_dp = false" equation connect(valInd.y, y.y) connect(sou.ports[1], valInd.port_a) connect(valInd.port_b, sin.ports[1]) connect(dp.y, sou.p_in) connect(valIndDpFix.port_a, sou.ports[2]) connect(valIndDpFix.port_b, sin.ports[2]) connect(valIndFromMflow.port_a, sou.ports[3]) connect(valIndFromMflow.port_b, sin.ports[3]) connect(y.y, valIndDpFix.y) connect(y.y, valIndFromMflow.y) end TwoWayValvePressureIndependent;
Two way valves with different opening characteristics
within AixLib.Fluid.Actuators.Valves.Examples; model TwoWayValves "Two way valves with different opening characteristics" extends Modelica.Icons.Example; package Medium = AixLib.Media.Water; AixLib.Fluid.Actuators.Valves.TwoWayLinear valLin( redeclare package Medium = Medium, l=0.05, m_flow_nominal=2, use_inputFilter=false, dpValve_nominal=6000) "Valve model, linear opening characteristics" Modelica.Blocks.Sources.Ramp y( height=1, duration=1, offset=0) "Control signal" AixLib.Fluid.Sources.Boundary_pT sou( redeclare package Medium = Medium, nPorts=6, use_p_in=false, p(displayUnit="Pa") = 306000, T=293.15) "Boundary condition for flow source" AixLib.Fluid.Sources.Boundary_pT sin( redeclare package Medium = Medium, nPorts=6, p(displayUnit="Pa") = 3E5, T=293.15) "Boundary condition for flow sink" AixLib.Fluid.Actuators.Valves.TwoWayQuickOpening valQui( redeclare package Medium = Medium, l=0.05, m_flow_nominal=2, use_inputFilter=false, dpValve_nominal=6000) "Valve model, quick opening characteristics" AixLib.Fluid.Actuators.Valves.TwoWayEqualPercentage valEqu( redeclare package Medium = Medium, l=0.05, R=10, delta0=0.1, m_flow_nominal=2, use_inputFilter=false, dpValve_nominal=6000) "Valve model, equal percentage opening characteristics" TwoWayPressureIndependent valInd( redeclare package Medium = Medium, m_flow_nominal=1, CvData=AixLib.Fluid.Types.CvTypes.OpPoint, dpValve_nominal=10000, use_inputFilter=false, l=0.05, l2=0.01) TwoWayPolynomial valPol( c={0,0.5304,-0.7698,1.2278}, l=0.05, m_flow_nominal=1, dpValve_nominal=10000, use_inputFilter=false, redeclare package Medium = Medium, CvData=AixLib.Fluid.Types.CvTypes.OpPoint) "Valve with polynomial opening characteristic" TwoWayButterfly valBut( redeclare package Medium = Medium, Kvs=1492, use_inputFilter=false, m_flow_nominal=1, l=0.05) "Butterfly valve" equation connect(y.y, valLin.y) connect(y.y, valQui.y) connect(y.y, valEqu.y) connect(sou.ports[1], valLin.port_a) connect(valQui.port_a, sou.ports[2]) connect(valEqu.port_a, sou.ports[3]) connect(valLin.port_b, sin.ports[1]) connect(valQui.port_b, sin.ports[2]) connect(valEqu.port_b, sin.ports[3]) connect(valInd.y, y.y) connect(valInd.port_b, sin.ports[4]) connect(valInd.port_a, sou.ports[4]) connect(valPol.port_b, sin.ports[5]) connect(valPol.port_a, sou.ports[5]) connect(valPol.y, y.y) connect(valBut.port_b, sin.ports[6]) connect(valBut.port_a, sou.ports[6]) connect(valBut.y, y.y) end TwoWayValves;
Two way valves with different opening characteristics and motor
within AixLib.Fluid.Actuators.Valves.Examples; model TwoWayValvesMotor "Two way valves with different opening characteristics and motor" extends Modelica.Icons.Example; package Medium = AixLib.Media.Water; AixLib.Fluid.Actuators.Valves.TwoWayLinear valLin( redeclare package Medium = Medium, l=0.05, m_flow_nominal=2, use_inputFilter=false, dpValve_nominal=6000) "Valve model, linear opening characteristics" AixLib.Fluid.Sources.Boundary_pT sou( redeclare package Medium = Medium, nPorts=4, use_p_in=true, T=293.15) "Boundary condition for flow source" AixLib.Fluid.Sources.Boundary_pT sin( redeclare package Medium = Medium, nPorts=4, use_p_in=true, T=293.15) "Boundary condition for flow sink" Modelica.Blocks.Sources.Constant PSin(k=3E5) Modelica.Blocks.Sources.Constant PSou(k=306000) AixLib.Fluid.Actuators.Valves.TwoWayQuickOpening valQui( redeclare package Medium = Medium, l=0.05, m_flow_nominal=2, use_inputFilter=false, dpValve_nominal=6000) "Valve model, quick opening characteristics" AixLib.Fluid.Actuators.Valves.TwoWayEqualPercentage valEqu( redeclare package Medium = Medium, l=0.05, R=10, delta0=0.1, m_flow_nominal=2, use_inputFilter=false, dpValve_nominal=6000) "Valve model, equal percentage opening characteristics" Modelica.Blocks.Sources.TimeTable ySet(table=[0,0; 60,0; 60,1; 120,1; 180,0.5; 240,0.5; 300,0; 360,0; 360,0.25; 420,0.25; 480,1; 540,1.5; 600,-0.25]) "Set point for actuator" Actuators.Motors.IdealMotor mot( tOpe=60) "Motor model" TwoWayPressureIndependent valInd( redeclare package Medium = Medium, m_flow_nominal=1, CvData=AixLib.Fluid.Types.CvTypes.OpPoint, dpValve_nominal=10000, use_inputFilter=false, l=0.05, l2=0.01) equation connect(PSin.y, sin.p_in) connect(PSou.y, sou.p_in) connect(ySet.y, mot.u) connect(mot.y, valEqu.y) connect(mot.y, valQui.y) connect(mot.y, valLin.y) connect(sou.ports[1], valLin.port_a) connect(sou.ports[2], valQui.port_a) connect(sou.ports[3], valEqu.port_a) connect(valLin.port_b, sin.ports[1]) connect(valQui.port_b, sin.ports[2]) connect(valEqu.port_b, sin.ports[3]) connect(valInd.port_a, sou.ports[4]) connect(valInd.port_b, sin.ports[4]) connect(valInd.y, valEqu.y) end TwoWayValvesMotor;
Two way valve with linear opening characteristics
within AixLib.Fluid.Actuators.Valves.Examples; model TwoWayValvesTable "Two way valve with linear opening characteristics" extends Modelica.Icons.Example; package Medium = AixLib.Media.Water "Medium"; Modelica.Blocks.Sources.Ramp y( height=1, duration=1, offset=0) "Control signal" AixLib.Fluid.Sources.Boundary_pT sou( redeclare package Medium = Medium, nPorts=2, use_p_in=false, p(displayUnit="Pa") = 306000, T=293.15) "Boundary condition for flow source" AixLib.Fluid.Sources.Boundary_pT sin( redeclare package Medium = Medium, nPorts=2, p(displayUnit="Pa") = 3E5, T=293.15) "Boundary condition for flow sink" Valves.TwoWayTable valTab( redeclare package Medium = Medium, m_flow_nominal=2, use_inputFilter=false, dpValve_nominal=6000, flowCharacteristics=AixLib.Fluid.Actuators.Valves.Data.Linear(), from_dp=true) "Valve model with opening characteristics based on a table" TwoWayLinear valLin( use_inputFilter=false, redeclare package Medium = Medium, l=0.0001, m_flow_nominal=2, dpValve_nominal=6000, from_dp=true) "Valve model with linear opening characteristics" equation connect(y.y,valTab. y) connect(valTab.port_a, sou.ports[1]) connect(valTab.port_b, sin.ports[1]) connect(valLin.y, y.y) connect(sou.ports[2], valLin.port_a) connect(valLin.port_b, sin.ports[2]) end TwoWayValvesTable;
Two way valve with nonlinear opening characteristics based on a table
within AixLib.Fluid.Actuators.Valves.Examples; model TwoWayValveTable "Two way valve with nonlinear opening characteristics based on a table" extends Modelica.Icons.Example; package Medium = AixLib.Media.Water "Medium"; Modelica.Blocks.Sources.Ramp y( height=1, duration=1, offset=0) "Control signal" AixLib.Fluid.Sources.Boundary_pT sou( redeclare package Medium = Medium, use_p_in=false, p(displayUnit="Pa") = 306000, T=293.15, nPorts=1) "Boundary condition for flow source" AixLib.Fluid.Sources.Boundary_pT sin( redeclare package Medium = Medium, p(displayUnit="Pa") = 3E5, T=293.15, nPorts=1) "Boundary condition for flow sink" Valves.TwoWayTable valTab( redeclare package Medium = Medium, use_inputFilter=false, from_dp=true, flowCharacteristics=datVal, CvData=AixLib.Fluid.Types.CvTypes.Kv, Kv=0.65, m_flow_nominal=0.04) "Valve model with opening characteristics based on a table" parameter Data.Generic datVal( y={0,0.1667,0.3333,0.5,0.6667,1}, phi={0, 0.19, 0.35, 0.45, 0.5, 0.65}/0.65) "Valve characteristics" Modelica.Blocks.Math.UnitConversions.To_bar to_bar Sensors.RelativePressure senRelPre(redeclare package Medium = Medium) "Pressure differential sensor" Sensors.VolumeFlowRate senVolFlo(redeclare package Medium = Medium, m_flow_nominal=0.04) "Volume flow rate sensor" Modelica.Blocks.Math.Sqrt sqrt1 Modelica.Blocks.Math.Gain to_m3_h(k=3600) "Conversion to m3/h" Modelica.Blocks.Math.Division kv "Kv-value" equation connect(y.y,valTab. y) connect(sou.ports[1], senVolFlo.port_a) connect(senVolFlo.port_b, valTab.port_a) connect(valTab.port_a, senRelPre.port_a) connect(valTab.port_b, senRelPre.port_b) connect(valTab.port_b, sin.ports[1]) connect(to_bar.u, senRelPre.p_rel) connect(sqrt1.u, to_bar.y) connect(senVolFlo.V_flow, to_m3_h.u) connect(to_m3_h.y,kv. u1) connect(sqrt1.y,kv. u2) end TwoWayValveTable;
Package that contains models of expansion valves
within AixLib.Fluid.Actuators.Valves; package ExpansionValves "Package that contains models of expansion valves" extends Modelica.Icons.Package; end ExpansionValves;
Package that contains base classes used for the expansion valve models
within AixLib.Fluid.Actuators.Valves.ExpansionValves; package BaseClasses "Package that contains base classes used for the expansion valve models" extends Modelica.Icons.BasesPackage; end BaseClasses;
Base model for all expansion valve models
within AixLib.Fluid.Actuators.Valves.ExpansionValves.BaseClasses; partial model PartialExpansionValve "Base model for all expansion valve models" // Definition of parameters // parameter Modelica.Units.SI.Area AVal=2.5e-6 "Cross-sectional area of the valve when it is fully opened" parameter Modelica.Units.SI.Diameter dInlPip=7.5e-3 "Diameter of the pipe at valve's inlet" parameter Boolean useInpFil = true "= true, if transient behaviour of valve opening or closing is computed" parameter Modelica.Units.SI.Time risTim=0.5 "Time until valve opening reaches 99.6 % of its set value" parameter Utilities.Types.CalcProc calcProc=Utilities.Types.CalcProc.nominal "Chose predefined calculation method for flow coefficient" parameter Modelica.Units.SI.MassFlowRate mFlowNom=m_flow_nominal "Mass flow at nominal conditions" parameter Modelica.Units.SI.PressureDifference dpNom=15e5 "Pressure drop at nominal conditions" // Definition of model describing flow coefficient // replaceable model FlowCoefficient = Utilities.FlowCoefficient.SpecifiedFlowCoefficients.ConstantFlowCoefficient constrainedby PartialFlowCoefficient "Model that describes the calculation of the flow coefficient" // Extends from partial two port (insert here for position of tabs) // extends AixLib.Fluid.Interfaces.PartialTwoPortTransport( redeclare replaceable package Medium = Modelica.Media.R134a.R134a_ph, show_T = false, show_V_flow = false, dp_start = 1e6, m_flow_start = 0.5*m_flow_nominal, m_flow_small = 1e-6*m_flow_nominal); // Definition of parameters describing diagnostic options // parameter Medium.MassFlowRate m_flow_nominal = 0.1 "Nominal mass flow rate" parameter Boolean show_flow_coefficient = true "= true, if flow coefficient model is computed" parameter Boolean show_staInl = true "= true, if thermodynamic state at valve's inlet is computed" parameter Boolean show_staOut = false "= true, if thermodynamic state at valve's outlet is computed" // Definition of variables // Medium.ThermodynamicState staInl "Thermodynamic state of the fluid at inlet condtions" Medium.ThermodynamicState staOut "Thermodynamic state of the fluid at outlet condtions" FlowCoefficient flowCoefficient( redeclare package Medium = Medium, opening = opening, AVal = AVal, dInlPip = dInlPip, staInl = staInl, staOut = staOut, pInl = pInl, pOut = pOut) "Instance of model 'flow coefficient'"; // Real C "Flow coefficient used to calculate mass flow and pressure drop"; // Definition of connectors and submodels // Modelica.Blocks.Interfaces.RealInput manVarVal(min=0, max=1) "Prescribed expansion valve's opening" Modelica.Blocks.Interfaces.RealOutput curManVarVal(min=0, max=1) "Current expansion valve's opening" Modelica.Blocks.Continuous.Filter filterOpening( final analogFilter=Modelica.Blocks.Types.AnalogFilter.CriticalDamping, final filterType=Modelica.Blocks.Types.FilterType.LowPass, order=2, f_cut=5/(2*Modelica.Constants.pi*risTim), x(each stateSelect=StateSelect.always)) if useInpFil "Second order filter to approximate valve opening or closing time" Modelica.Blocks.Routing.RealPassThrough openingThrough "Dummy passing through of opening signal to allow usage of filter" protected Modelica.Units.SI.Area AThr "Current cross-sectional area of the valve"; Real opening(unit="1") "Current valve's opening"; Modelica.Units.SI.Density dInl=Medium.density(staInl) "Density at valves's inlet conditions"; Modelica.Units.SI.AbsolutePressure pInl=port_a.p "Pressure of the fluid at inlet conditions"; Modelica.Units.SI.AbsolutePressure pOut=port_b.p "Pressure of the fluid at outlet conditions"; equation // Calculation of thermodynamic states // staInl = Medium.setState_phX(port_a.p, actualStream(port_a.h_outflow), actualStream(port_a.Xi_outflow)) "Thermodynamic state of the fluid at inlet condtions"; staOut = Medium.setState_phX(port_b.p, actualStream(port_b.h_outflow), actualStream(port_b.Xi_outflow)) "Thermodynamic state of the fluid at outlet condtions"; // Calculation of valve's opening degree // connect(filterOpening.u, manVarVal); if useInpFil then connect(openingThrough.u, filterOpening.y) "Transient behaviour of valve's opening"; else connect(openingThrough.u, manVarVal) "No transient behaiviour of valve's opnening"; end if; opening = smooth(1, noEvent(if openingThrough.y>0 then openingThrough.y else 1e-15)) "Current valve's opening"; // Calculation of active cross-sectional flow area // AThr = opening * AVal "Current cross-sectional area of the valve"; // Calculation of outputs // curManVarVal = opening "Current valve's opening"; end PartialExpansionValve;
Partial model describing base flow coefficient
within AixLib.Fluid.Actuators.Valves.ExpansionValves.BaseClasses; partial model PartialFlowCoefficient "Partial model describing base flow coefficient" // Definition of inputs // replaceable package Medium = Modelica.Media.R134a.R134a_ph constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium "Definition of two-phase medium"; input Real opening(unit="1") "Current valve's opening"; input Modelica.Units.SI.Area AVal "Cross-sectional area of the expansion valve"; input Modelica.Units.SI.Diameter dInlPip "Diameter of the pipe at valve's inlet"; input Medium.ThermodynamicState staInl "Thermodynamic state at valve's inlet conditions"; input Medium.ThermodynamicState staOut "Thermodynamic state at valve's outlet conditions"; input Modelica.Units.SI.AbsolutePressure pInl "Pressure at valves's inlet conditions"; input Modelica.Units.SI.AbsolutePressure pOut "Pressure at valves's outlet conditions"; // Definition of base variables // Real C(unit="1", min = 0, max = 100, nominal = 25) "Mass flow coefficient used for expansion valves"; end PartialFlowCoefficient;
Base model for all isenthalpic expansion valves. This is a base model for simple isenthalpic expansion valves that are used, for example, in close-loop systems like heat pumps or chillers. This model inherits from <a href= \"modelica://AixLib.Fluid.Actuators.Valves.ExpansionValves.BaseClasses.PartialExpansionValve\"> AixLib.Fluid.Actuators.Valves.ExpansionValves.BaseClasses.PartialExpansionValve</a> and, hence, please check out the PartialExpansionValve model if detailed information is required about the modelling approach.
within AixLib.Fluid.Actuators.Valves.ExpansionValves.BaseClasses; partial model PartialIsenthalpicExpansionValve "Base model for all isenthalpic expansion valves" extends BaseClasses.PartialExpansionValve; equation // Calculation of energy balance // port_a.h_outflow = inStream(port_b.h_outflow) "Isenthalpic expansion valve"; port_b.h_outflow = inStream(port_a.h_outflow) "Isenthalpic expansion valve"; end PartialIsenthalpicExpansionValve;
Base model for all modular expansion valve models
within AixLib.Fluid.Actuators.Valves.ExpansionValves.BaseClasses; partial model PartialModularExpansionVavles "Base model for all modular expansion valve models" // Definition of parameters describing the modular approach in general // parameter Integer nVal = 1 "Number of valves - each valve will be connected to an individual port_b" // Definition of replaceable expansion valve models // replaceable model SimpleExpansionValve = SimpleExpansionValves.IsenthalpicExpansionValve constrainedby PartialExpansionValve "Model of simple expansion valve" SimpleExpansionValve modExpVal[nVal]( redeclare each final package Medium = Medium, final AVal=AVal, final dInlPip=dInlPip, final useInpFil=useInpFil, final risTim=risTim, final calcProc=calcProc, final mFlowNom=mFlowNom, final dpNom=dpNom, redeclare final model FlowCoefficient = FlowCoefficient, each final allowFlowReversal=allowFlowReversal, each final dp_start=dp_start, final m_flow_nominal=mFlowNom) "Array of expansion valves" // Definition of parameters describing the expansion valves // parameter Modelica.Units.SI.Area AVal[nVal]=fill(2e-6, nVal) "Cross-sectional areas of the valves when they are fully opened" parameter Modelica.Units.SI.Diameter dInlPip[nVal]=fill(7.5e-3, nVal) "Diameters of the pipes at valves' inlets" parameter Boolean useInpFil[nVal] = fill(false, nVal) "= true, if transient behaviours of valves opening or closing are computed" parameter Modelica.Units.SI.Time risTim[nVal]=fill(0.5, nVal) "Time until valves opening reach 99.6 % of the set values" parameter Utilities.Types.CalcProc calcProc[nVal]=fill(Utilities.Types.CalcProc.flowCoefficient, nVal) "Chose predefined calculation method for flow coefficients" parameter Modelica.Units.SI.MassFlowRate mFlowNom[nVal]={m_flow_nominal/sum( AVal)*AVal[i] for i in 1:nVal} "Mass flow at nominal conditions" parameter Modelica.Units.SI.PressureDifference dpNom[nVal]=fill(dp_nominal, nVal) "Pressure drop at nominal conditions" replaceable model FlowCoefficient = Utilities.FlowCoefficient.SpecifiedFlowCoefficients.ConstantFlowCoefficient constrainedby BaseClasses.PartialFlowCoefficient "Model that describes the calculation of the flow coefficient" /*Parameters presented above are used to define each element of the expansion valve vector. Therefore, the parameters are identically to the parameters of a simple expension valve aside from the fact that the parameters are introduced as arraies */ // Definition of replaceable controller model // replaceable model ModularController = Controls.HeatPump.ModularHeatPumps.ModularExpansionValveController constrainedby Controls.HeatPump.ModularHeatPumps.BaseClasses.PartialModularController "Model of the modular controller" ModularController expValCon( final nCom=nVal, final useExt=useExt, final controllerType=controllerType, final reverseAction=reverseAction, final reset=reset, final k=k, final Ti=Ti, final Ni=Ni, final Td=Td, final Nd=Nd, final wp=wp, final wd=wd, final yMax=yMax, final yMin=yMin, final initType=initType, final xi_start=xi_start, final xd_start=xd_start, final y_start=y_start) "Model of internal controller" // Definition of parameters describing the expansion valve controller // parameter Boolean useExt = false "= true, if external signal is used instead of internal controllers" parameter Modelica.Blocks.Types.SimpleController controllerType[nVal]= fill(Modelica.Blocks.Types.SimpleController.PID,nVal) "Type of controller" parameter Boolean reverseAction[nVal] = fill(false,nVal) "= true, if medium flow rate is throttled through cooling coil controller" parameter AixLib.Types.Reset reset[nVal]= fill(AixLib.Types.Reset.Disabled,nVal) "Type of controller output reset" parameter Real k[nVal] = fill(1,nVal) "Gain of controller" parameter Modelica.Units.SI.Time Ti[nVal]=fill(0.5, nVal) "Time constant of integrator block" parameter Real Ni[nVal] = fill(0.9,nVal) "Ni*Ti is time constant of anti-windup compensation" parameter Modelica.Units.SI.Time Td[nVal]=fill(0.1, nVal) "Time constant of derivative block" parameter Real Nd[nVal] = fill(10,nVal) "The higher Nd, the more ideal the derivative block" parameter Real wp[nVal] = fill(1,nVal) "Set-point weight for Proportional block (0..1)" parameter Real wd[nVal] = fill(0,nVal) "Set-point weight for Derivative block (0..1)" parameter Real yMax[nVal] = fill(1,nVal) "Upper limit of output" parameter Real yMin[nVal] = fill(0,nVal) "Lower limit of output" parameter Modelica.Blocks.Types.Init initType[nVal]=fill(Modelica.Blocks.Types.Init.InitialState, nVal) "Init: (1: no init, 2: steady state, 3: initial state, 4: initial output)" parameter Real xi_start[nVal]=fill(0, nVal) "Initial or guess value value for integrator output (= integrator state)" parameter Real xd_start[nVal]=fill(0, nVal) "Initial or guess value for state of derivative block" parameter Real y_start[nVal]=fill(0, nVal) "Initial value of output" /*Parameters presented above are used to define each element of the expansion valve controller. Therefore, the parameters are identically to the parameters of the controller aside from the fact that the parameters are introduced as arraies */ // Extends base port model and set base parameters // extends Fluid.Interfaces.PartialModularPort_b( redeclare replaceable package Medium = Modelica.Media.R134a.R134a_ph, final nPorts=nVal); // Definition of parameters describing diagnostics // parameter Boolean show_parVal = false "= true, if expansions valves' input parameters are shown in results" parameter Boolean show_parCon = false "= true, if controller's input parameters are shown in results" // Definition of connectors // Controls.Interfaces.ModularHeatPumpControlBus dataBus( final nVal=nVal) "Data bus connector" equation // Connect port_a with inlet ports of expansion valves // for i in 1:nVal loop connect(port_a, modExpVal[i].port_a); end for; // Connect data bus and further control signals // connect(expValCon.manVar, modExpVal.manVarVal) connect(modExpVal.curManVarVal, expValCon.curManVar) connect(dataBus, expValCon.dataBus) end PartialModularExpansionVavles;
Base model to test compressors using static heat pump boundaries
within AixLib.Fluid.Actuators.Valves.ExpansionValves.Examples; model BaseModelStaticHeatPumps "Base model to test compressors using static heat pump boundaries" extends Modelica.Icons.Example; // Definition of medium // replaceable package Medium = Modelica.Media.R134a.R134a_ph constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium "Medium of the compressor" // Definition of parameters describing compressors // parameter Integer nVal = 1 "Numer of compressors in parallel" // Definition of parameters describing boundary conditions // parameter Modelica.Units.SI.TemperatureDifference dTPinEva=2 "Pinch temperature at evaporator's outlet" parameter Modelica.Units.SI.TemperatureDifference dTSupHea=1 "Superheating of working fluid" parameter Modelica.Units.SI.TemperatureDifference dTPinCond=2 "Pinch temperature at condenser's outlet" parameter Modelica.Units.SI.TemperatureDifference dTSubCool=4 "Supercooling of working fluid" parameter Modelica.Units.SI.Density dSec=1000 "Constant density of secondary fluid" parameter Modelica.Units.SI.SpecificHeatCapacity cpSec=4.1813e3 "Constant specific heat capacity of secondary fluid" parameter Modelica.Units.SI.VolumeFlowRate V_flowSec=(0.776 + 0.781 + 0.44)/3 /3600 "Constant volume flow of secondary fluid" // Definition of variables describing boundary conditions // Modelica.Blocks.Sources.CombiTimeTable inpDat( extrapolation=Modelica.Blocks.Types.Extrapolation.NoExtrapolation, columns=2:7, table=[0,64,285.15,5180,308.15,900,5.755555556; 1,64,283.15,4920,308.15,910, 5.406593407; 2,63,280.15,4370,308.15,930,4.698924731; 3,64,285.15,4980,318.15, 1140,4.368421053; 4,64,283.15,4730,318.15,1140,4.149122807; 5,55,285.15, 4180,328.15,1240,3.370967742; 6,64,283.15,4650,328.15,1380,3.369565217; 7,63,280.15,4160,318.15,1610,2.583850932; 8,55,275.15,2800,308.15,790,3.544303797; 9,106,258.15,3760,308.15,1570,2.394904459; 10,115,266.15,4850,308.15,1940, 2.5; 11,55,275.15,2640,318.15,960,2.75; 12,111,258.15,4150,318.15,2120,1.95754717; 13,107,270.15,4780,318.15,2210,2.162895928; 14,113,266.15,4560,318.15,2290, 1.991266376; 15,100,266.15,3880,328.15,2240,1.732142857; 16,63,275.15,3280, 328.15,1330,2.466165414; 17,63,280.15,4080,328.15,1400,2.914285714], smoothness=Modelica.Blocks.Types.Smoothness.ContinuousDerivative) "Static boundaries of compressor model" Modelica.Blocks.Sources.RealExpression inpSetSpeEnt(y=con.hOut) "Expressions describing set point of specific enthalpy" Modelica.Blocks.Sources.RealExpression inpAmbTemp(y=inpDat.y[2]) "Expressions describing ambient temperature" Modelica.Blocks.Sources.RealExpression inpColCap(y=inpDat.y[3] - inpDat.y[5]) "Expressions describing col capacity" Modelica.Blocks.Sources.RealExpression inpHeaCap(y=inpDat.y[3]) "Expressions describing heat capacity" Modelica.Blocks.Sources.RealExpression inpTFlo(y=inpDat.y[4]) "Expressions describing flow temperature at heat capacity" // Definition of subcomponents // StaticEvaporator eva( redeclare final package Medium = Medium, final dTPin=dTPinEva, final dTSupHea=dTSupHea, nPorts=nVal) "Model that describes a simple static evaporator" Modelica.Blocks.Continuous.LimPID conPID( k=0.001, Ti=10, controllerType=Modelica.Blocks.Types.SimpleController.P, yMax=1, yMin=0.05) "PID controller to set valves' openings" Modelica.Blocks.Sources.RealExpression inpCurSpeEnt(y=eva.hInl) "Expressions describing current specific enthalpy" Modelica.Blocks.Routing.Replicator repMea(nout=nVal) "Replicating the current value of the manipulated variables" ModularExpansionValves.ModularExpansionValvesSensors modExpVal( redeclare package Medium = Medium, nVal=nVal, redeclare model SimpleExpansionValve = SimpleExpansionValves.IsenthalpicExpansionValve, AVal=fill(1.767e-6, nVal), useExt=true, useInpFil=fill(true, nVal), redeclare model FlowCoefficient = Utilities.FlowCoefficient.SpecifiedFlowCoefficients.Poly_R22R407CR410A_EEV_15_22, risTim=fill(0.01328, nVal)) "Model that describes modular expansion valves in parallel" StaticCondenser con( redeclare package Medium = Medium, dTSubCool=dTSubCool, dTPin=dTPinCond, dSec=dSec, cpSec=cpSec, V_flowSec=V_flowSec) "Model that describes a simple static condenser" AixLib.Controls.Interfaces.ModularHeatPumpControlBus dataBus(nVal=nVal) "Connector that contains all control signals" protected model StaticEvaporator "Static evaporator assuming constant pinch point at evaporator's outlet" // Definition of medium // replaceable package Medium = Modelica.Media.R134a.R134a_ph constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium "Medium of the expansion valve" // Definition of parameters describing evaporator // parameter Integer nPorts = 1; parameter Modelica.Units.SI.TemperatureDifference dTPin=5 "Pinch temperature at evaporator's outlet" parameter Modelica.Units.SI.TemperatureDifference dTSupHea=1 "Superheating of working fluid" // Definition of parameters describing assumptions // parameter Boolean allowFlowReversal = false "= false to simplify equations, assuming, but not enforcing, no flow reversal" // Definition of connecotrs // Modelica.Fluid.Interfaces.FluidPorts_b ports_b[nPorts]( redeclare each final package Medium = Medium, h_outflow(each start = Medium.h_default), m_flow(each max=Modelica.Constants.inf)) "Fluid connectors b (positive design flow direction is from port_a to port_b)" Modelica.Blocks.Interfaces.RealInput inpTAmb "Input of ambient temperature" Modelica.Blocks.Interfaces.RealInput inpQ_flow "Input of cold capacity" // Definition of submodels // Modelica.Blocks.Sources.RealExpression inlPEva(y=pSat) "Expressions describing saturation pressure at evaporator's inlet" Modelica.Blocks.Sources.RealExpression inlhEva(y=hInl) "Expressions describing specific enthalpy at evaporator's inlet" AixLib.Fluid.Sources.Boundary_ph source( redeclare package Medium = Medium, use_p_in=true, use_h_in=true, nPorts=1) "Source with constant pressure and specific enthalpy" Interfaces.PortsAThroughPortB outVal( redeclare package Medium = Medium, nVal=nPorts) "Model that combines the outputs of modular expansion valves" Sensors.SpecificEnthalpyTwoPort senSpeEnt[nPorts]( redeclare package Medium = Medium, each m_flow_nominal=0.05, each initType=Modelica.Blocks.Types.Init.NoInit, each tau=0, each h_out_start=275e3) "Sensor that measures current specific enthalpy" Sensors.MassFlowRate senMasFlo[nPorts](redeclare package Medium = Medium) "Sensor that measures current mas flow rate" // Definition of variables describing evaporator // Medium.SaturationProperties satEva "Saturation properties of the evaporator's working fluid" Medium.ThermodynamicState staOut "Thermodynamic state of the working fluid at evaporator's outlet" public Modelica.Units.SI.AbsolutePressure pSat "Absolute pressure at evaporator's outlet"; Modelica.Units.SI.Temperature TSat "Saturation temperature"; Modelica.Units.SI.SpecificEnthalpy hInl "Specific enthalpy at evaporator's inlet"; Modelica.Units.SI.SpecificEnthalpy hOut "Specific enthalpy at evaporator's outlet"; Modelica.Units.SI.Temperature TOut "Temperature at evaporator's outlet"; Modelica.Units.SI.Temperature TAmb "Temperature of ambient"; Modelica.Units.SI.MassFlowRate m_flow "Mass flow rate"; Modelica.Units.SI.HeatFlowRate Q_flow "Cooling capacity"; equation // Connection of ports // connect(inlPEva.y, source.p_in) connect(inlhEva.y, source.h_in) connect(ports_b, senSpeEnt.port_a) connect(senSpeEnt.port_b, senMasFlo.port_a) connect(source.ports[1], outVal.port_b) connect(senMasFlo.port_b, outVal.ports_a) TAmb = inpTAmb "Temperature of ambient"; m_flow = senMasFlo[1].m_flow "Mass flow rate"; Q_flow = inpQ_flow "Cooling capacity"; // Calculation of state properties of working fluid // satEva = Medium.setSat_T(T=TSat) "Saturation properties"; staOut = Medium.setState_pT(p=pSat,T=TOut) "Thermodynamic state of the working fluid at evaporator's outlet"; pSat = Medium.saturationPressure(satEva.Tsat) "Absolute pressure at evaporator's outlet"; TSat = TOut - dTSupHea "Saturation temperature"; hInl = hOut - Q_flow/m_flow "Specific enthalpy at evaporator's inlet"; TOut = TAmb - dTPin "Temperature at evaporator's outlet"; hOut = Medium.specificEnthalpy(staOut) "Specific enthalpy at evaporator's outlet"; end StaticEvaporator; model StaticCondenser "Static condenser assuming constant pinch point at condenser's outlet" // Definition of medium // replaceable package Medium = Modelica.Media.R134a.R134a_ph constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium "Medium of the expansion valve" // Definition of parameters describing condenser // parameter Modelica.Units.SI.TemperatureDifference dTPin=5 "Pinch temperature at condenser's outlet" parameter Modelica.Units.SI.TemperatureDifference dTSubCool=8 "Supercooling of working fluid" parameter Modelica.Units.SI.Density dSec=1000 "Constant density of secondary fluid" parameter Modelica.Units.SI.SpecificHeatCapacity cpSec=4.1813e3 "Constant specific heat capacity of secondary fluid" parameter Modelica.Units.SI.VolumeFlowRate V_flowSec=(0.776 + 0.781 + 0.44) /3/3600 "Constant volume flow of secondary fluid" // Definition of parameters describing assumptions // parameter Boolean allowFlowReversal = false "= false to simplify equations, assuming, but not enforcing, no flow reversal" // Definition of connecotrs // Modelica.Fluid.Interfaces.FluidPort_b port_b( redeclare final package Medium = Medium, m_flow(max=if allowFlowReversal then +Modelica.Constants.inf else 0), h_outflow(start = Medium.h_default)) "Fluid connector b (positive design flow direction is from port_a to port_b)" Modelica.Blocks.Interfaces.RealInput inpQ_flow "Heat capacity" Modelica.Blocks.Interfaces.RealInput inpTFlo "Temperature flow at heat capacity" // Definition of subcomponents // Modelica.Blocks.Sources.RealExpression inlPCond(y=pSat) "Expressions describing saturation pressure at condenser's inlet" Modelica.Blocks.Sources.RealExpression inlTCon(y=TOut) "Expressions describing temperature at condenser's inlet" AixLib.Fluid.Sources.Boundary_pT sink( redeclare package Medium = Medium, use_p_in=true, use_T_in=true, nPorts=1) "Source with constant pressure and temperature" AixLib.Fluid.Sensors.SpecificEnthalpyTwoPort senSpeEnt( redeclare package Medium = Medium, m_flow_nominal=0.05, initType=Modelica.Blocks.Types.Init.NoInit, h_out_start=400e3, tau=0) "Sensor that measures current specific enthalpy" AixLib.Fluid.Sensors.MassFlowRate senMasFlo( redeclare package Medium =Medium) "Sensor that measures current mas flow rate" // Definition of variables describing condenser // Medium.SaturationProperties satCon "Saturation properties of the condenser's working fluid" Medium.ThermodynamicState staOut "Thermodynamic state of the working fluid at condenser's outlet" public Modelica.Units.SI.AbsolutePressure pSat "Absolute pressure at condenser's outlet"; Modelica.Units.SI.Temperature TSat "Saturation temperature"; Modelica.Units.SI.Temperature TOut "Temperature at condenser's outlet"; Modelica.Units.SI.SpecificEnthalpy hOut "Specific enthalpy at condenser's outlet"; Modelica.Units.SI.MassFlowRate m_flow "Mass flow rate"; Modelica.Units.SI.HeatFlowRate Q_flow "Heat capacity"; Modelica.Units.SI.MassFlowRate m_flowSec "Mass flow rate of secondary fluid"; Modelica.Units.SI.Temperature TFlo "Temperature flow at heat capacity"; Modelica.Units.SI.Temperature TRetFlo "Temperature return flow at heat capacity"; equation // Connection of ports // connect(inlPCond.y, sink.p_in) connect(inlTCon.y, sink.T_in) connect(sink.ports[1], senMasFlo.port_b) connect(senMasFlo.port_a, senSpeEnt.port_b) connect(senSpeEnt.port_a,port_b) m_flow = senMasFlo.m_flow "Mass flow rate"; Q_flow = inpQ_flow "Heat capacity"; TFlo = inpTFlo "Temperature flow at heat capacity"; // Calculation of state properties of working fluid // satCon = Medium.setSat_T(T=TSat) "Saturation properties"; staOut = Medium.setState_pT(p=pSat,T=TOut) "Thermodynamic state of the working fluid at condenser's outlet"; pSat = Medium.saturationPressure(T=TSat) "Absolute pressure at condenser's outlet"; TSat = TOut + dTSubCool "Saturation temperature"; TOut = TRetFlo + dTPin "Temperature at condenser's outlet"; hOut = Medium.specificEnthalpy(state=staOut) "Specific enthalpy at condenser's outlet"; TRetFlo = TFlo - Q_flow/(m_flowSec*cpSec) "Temperature return flow at heat capacity"; m_flowSec = dSec*V_flowSec "Mass flow rate of secondary fluid"; end StaticCondenser; equation // Connection of main components // connect(con.port_b, modExpVal.port_a) // Connection of signals // connect(modExpVal.dataBus, dataBus) connect(inpHeaCap.y, con.inpQ_flow) connect(inpTFlo.y, con.inpTFlo) connect(repMea.y, dataBus.expValBus.extManVarVal) connect(inpColCap.y, eva.inpQ_flow) connect(inpAmbTemp.y, eva.inpTAmb) connect(inpCurSpeEnt.y, conPID.u_m) connect(inpSetSpeEnt.y, conPID.u_s) connect(conPID.y, repMea.u) connect(eva.ports_b, modExpVal.ports_b) end BaseModelStaticHeatPumps;
Simple model to check different flow coefficient models with fixed mass flow rate
within AixLib.Fluid.Actuators.Valves.ExpansionValves.Examples; model ExpansionValveMassFlowRate "Simple model to check different flow coefficient models with fixed mass flow rate" extends Modelica.Icons.Example; // Define medium and parameters // package Medium = Modelica.Media.R134a.R134a_ph "Actual medium of the compressor"; parameter Modelica.Units.SI.Temperature TInl=343.15 "Actual temperature at inlet conditions"; parameter Modelica.Units.SI.AbsolutePressure pOut=Medium.pressure( Medium.setDewState(Medium.setSat_T(TOut))) "Actual set point of the compressor's outlet pressure"; parameter Modelica.Units.SI.Temperature TOut=278.15 "Actual temperature at outlet conditions"; parameter Modelica.Units.SI.MassFlowRate m_flow_nominal=0.1 "Nominal mass flow rate"; // Define components // AixLib.Fluid.Sources.MassFlowSource_T source( redeclare package Medium = Medium, T=TInl, nPorts=1, m_flow=1) "Source of constant mass flow and temperature" Modelica.Blocks.Sources.Sine valOpe( f=1, amplitude=0.3, offset=0.7) "Input signal to prediscribe expansion valve's opening" SimpleExpansionValves.IsenthalpicExpansionValve linearValve( redeclare package Medium = Medium, m_flow_small=1e-6, m_flow_nominal=m_flow_nominal, show_flow_coefficient=false, show_staInl=false, show_staOut=false, dp_start=1e6, AVal=2.55e-5, calcProc=Utilities.Types.CalcProc.flowCoefficient, useInpFil=true, risTim=0.25, dpNom=1000000, redeclare model FlowCoefficient = Utilities.FlowCoefficient.SpecifiedFlowCoefficients.Poly_R407c_EEV_18) "Simple isothermal valve" AixLib.Fluid.FixedResistances.PressureDrop simplePipe( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, dp_nominal=7.5e5) " Simple pipe to provide pressure loss" Sources.Boundary_pT sink( redeclare package Medium = Medium, p=pOut, T=TOut, nPorts=1) "Sink of constant pressure and temperature" equation // Define connections of components // connect(valOpe.y, linearValve.manVarVal) connect(linearValve.port_b, simplePipe.port_a) connect(simplePipe.port_b,sink. ports[1]) connect(source.ports[1], linearValve.port_a) end ExpansionValveMassFlowRate;
Simple model to check different flow coefficient models with fixed inlet and outlet states
within AixLib.Fluid.Actuators.Valves.ExpansionValves.Examples; model ExpansionValvePressureDifference "Simple model to check different flow coefficient models with fixed inlet and outlet states" extends Modelica.Icons.Example; // Define medium and parameters // package Medium = Modelica.Media.R134a.R134a_ph "Actual medium of the compressor"; parameter Modelica.Units.SI.AbsolutePressure pInl=Medium.pressure( Medium.setBubbleState(Medium.setSat_T(TInl + 5))) "Actual pressure at inlet conditions"; parameter Modelica.Units.SI.Temperature TInl=348.15 "Actual temperature at inlet conditions"; parameter Modelica.Units.SI.AbsolutePressure pOut=Medium.pressure( Medium.setDewState(Medium.setSat_T(TOut))) "Actual set point of the compressor's outlet pressure"; parameter Modelica.Units.SI.Temperature TOut=278.15 "Actual temperature at outlet conditions"; parameter Modelica.Units.SI.MassFlowRate m_flow_nominal=0.1 "Nominal mass flow rate"; // Define components // Sources.Boundary_pT source( redeclare package Medium = Medium, nPorts=1, p=pInl, T=TInl) "Source of constant pressure and temperature" Modelica.Blocks.Sources.Sine valOpe( amplitude=0.45, f=1, offset=0.5) "Input signal to prediscribe expansion valve's opening" SimpleExpansionValves.IsenthalpicExpansionValve linearValve( redeclare package Medium = Medium, show_flow_coefficient=true, show_staInl=true, show_staOut=false, useInpFil=false, AVal=2.01e-6, m_flow_nominal=m_flow_nominal, calcProc=AixLib.Fluid.Actuators.Valves.ExpansionValves.Utilities.Types.CalcProc.flowCoefficient, dpNom=1000000, redeclare model FlowCoefficient = Utilities.FlowCoefficient.SpecifiedFlowCoefficients.Power_R134a_EEV_15) "Simple isothermal valve" Sources.Boundary_pT sink( redeclare package Medium = Medium, p=pOut, T=TOut, nPorts=1) "Sink of constant pressure and temperature" equation // Define connections of components // connect(source.ports[1], linearValve.port_a) connect(valOpe.y, linearValve.manVarVal) connect(linearValve.port_b,sink. ports[1]) end ExpansionValvePressureDifference;
Simple model to check modular expansion valves models with fixed mass flow rate
within AixLib.Fluid.Actuators.Valves.ExpansionValves.Examples; model ModularExpansionValvesMassFlowRate "Simple model to check modular expansion valves models with fixed mass flow rate" extends Modelica.Icons.Example; // Definition of medium and parameters // package Medium = Modelica.Media.R134a.R134a_ph "Current medium of the compressor"; parameter Integer nVal = 3 "Number of valves - each valve will be connected to an individual port_b"; parameter Modelica.Units.SI.AbsolutePressure pInl=Medium.pressure( Medium.setBubbleState(Medium.setSat_T(TInl + 5))) "Current pressure at inlet conditions"; parameter Modelica.Units.SI.Temperature TInl=348.15 "Current temperature at inlet conditions"; parameter Modelica.Units.SI.AbsolutePressure pOut=Medium.pressure( Medium.setDewState(Medium.setSat_T(TOut))) "Current set point of the compressor's outlet pressure"; parameter Modelica.Units.SI.Temperature TOut=278.15 "Current temperature at outlet conditions"; // Definition of models // Sources.MassFlowSource_T source( redeclare package Medium = Medium, T=TInl, nPorts=1, m_flow=1) "Source of constant mass flow and temperature" replaceable ModularExpansionValves.ModularExpansionValvesSensors modVal( redeclare package Medium = Medium, nVal=nVal, redeclare model SimpleExpansionValve = SimpleExpansionValves.IsenthalpicExpansionValve, show_parVal=false, show_parCon=false, useInpFil={true,true,true}, AVal={2e-6,1.5e-6,1e-6}, risTim={0.25,0.25,0.5}, controllerType={Modelica.Blocks.Types.SimpleController.P,Modelica.Blocks.Types.SimpleController.P, Modelica.Blocks.Types.SimpleController.P}, useExt=true, redeclare model FlowCoefficient = Utilities.FlowCoefficient.SpecifiedFlowCoefficients.Power_R134a_EEV_15, redeclare model ModularController = Controls.HeatPump.ModularHeatPumps.ModularExpansionValveController) "Modular expansion valves in parallel" Interfaces.PortsAThroughPortB portsAThroughPortB( redeclare package Medium = Medium, nVal=nVal) "Model to connect each valves' outlet pipe with each other" AixLib.Fluid.Sources.Boundary_pT sink( redeclare package Medium = Medium, p=pOut, T=TOut, nPorts=1) "Sink of constant pressure and temperature" Controls.Interfaces.ModularHeatPumpControlBus dataBus(nVal=nVal) "Data bus used to enable communication with dummy signals" Modelica.Blocks.Routing.Replicator repValOpe(nout=nVal) "Replicating the valves' opening signal" Modelica.Blocks.Sources.Sine valOpe( f=1, amplitude=0.45, offset=0.5) "Input signal to prediscribe expansion valve's opening" Modelica.Blocks.Routing.Replicator repInt(nout=nVal) "Replicating the internal set signal" Modelica.Blocks.Routing.Replicator repCur(nout=nVal) "Replicating the actual value of the manipulated variables" Modelica.Blocks.Sources.Ramp ramCur( height=0.5, offset=0.3, duration=1) "Ramp to fake actual value of the controlled variables" equation connect(source.ports[1], modVal.port_a) connect(modVal.ports_b, portsAThroughPortB.ports_a) connect(portsAThroughPortB.port_b,sink. ports[1]) connect(valOpe.y, repValOpe.u) connect(valOpe.y, repInt.u) connect(ramCur.y,repCur. u) connect(modVal.dataBus, dataBus) connect(repValOpe.y, dataBus.expValBus.extManVarVal) connect(repInt.y, dataBus.expValBus.intSetPoiVal) connect(repCur.y, dataBus.expValBus.meaConVarVal) end ModularExpansionValvesMassFlowRate;
Simple model to check modular expansion valves models with fixed inlet and outlet states
within AixLib.Fluid.Actuators.Valves.ExpansionValves.Examples; model ModularExpansionValvesPressureDifference "Simple model to check modular expansion valves models with fixed inlet and outlet states" extends Modelica.Icons.Example; // Definition of medium and parameters // package Medium = Modelica.Media.R134a.R134a_ph "Current medium of the compressor"; parameter Integer nVal = 3 "Number of valves - each valve will be connected to an individual port_b"; parameter Modelica.Units.SI.AbsolutePressure pInl=Medium.pressure( Medium.setBubbleState(Medium.setSat_T(TInl + 5))) "Current pressure at inlet conditions"; parameter Modelica.Units.SI.Temperature TInl=348.15 "Current temperature at inlet conditions"; parameter Modelica.Units.SI.AbsolutePressure pOut=Medium.pressure( Medium.setDewState(Medium.setSat_T(TOut))) "Current set point of the compressor's outlet pressure"; parameter Modelica.Units.SI.Temperature TOut=278.15 "Current temperature at outlet conditions"; // Definition of models // Sources.MassFlowSource_T source( redeclare package Medium = Medium, T=TInl, nPorts=1, m_flow=1) "Source of constant mass flow and temperature" replaceable ModularExpansionValves.ModularExpansionValvesSensors modVal( redeclare package Medium = Medium, nVal=nVal, redeclare model SimpleExpansionValve = SimpleExpansionValves.IsenthalpicExpansionValve, show_parVal=false, show_parCon=false, useInpFil={true,true,true}, AVal={2e-6,1.5e-6,1e-6}, risTim={0.25,0.25,0.5}, useExt=true, redeclare model FlowCoefficient = Utilities.FlowCoefficient.SpecifiedFlowCoefficients.ConstantFlowCoefficient, redeclare model ModularController = Controls.HeatPump.ModularHeatPumps.ModularExpansionValveController) "Modular expansion valves in parallel" Interfaces.PortsAThroughPortB portsAThroughPortB( redeclare package Medium = Medium, nVal=nVal) "Model to connect each valves' outlet pipe with each other" AixLib.Fluid.Sources.Boundary_pT sink( redeclare package Medium = Medium, p=pOut, T=TOut, nPorts=1) "Sink of constant pressure and temperature" Controls.Interfaces.ModularHeatPumpControlBus dataBus(nVal=nVal) "Data bus used to enable communication with dummy signals" Modelica.Blocks.Routing.Replicator repValOpe(nout=nVal) "Replicating the valves' opening signal" Modelica.Blocks.Sources.Sine valOpe( f=1, amplitude=0.45, offset=0.5) "Input signal to prediscribe expansion valve's opening" Modelica.Blocks.Routing.Replicator repInt(nout=nVal) "Replicating the internal set signal" Modelica.Blocks.Routing.Replicator repCur(nout=nVal) "Replicating the current value of the manipulated variables" Modelica.Blocks.Sources.Ramp ramCur( height=0.5, offset=0.3, duration=1) "Ramp to fake current value of the controlled variables" equation connect(source.ports[1], modVal.port_a) connect(modVal.ports_b, portsAThroughPortB.ports_a) connect(portsAThroughPortB.port_b,sink. ports[1]) connect(valOpe.y, repValOpe.u) connect(valOpe.y, repInt.u) connect(ramCur.y,repCur. u) connect(modVal.dataBus, dataBus) connect(repValOpe.y, dataBus.expValBus.extManVarVal) connect(repInt.y, dataBus.expValBus.intSetPoiVal) connect(repCur.y, dataBus.expValBus.meaConVarVal) end ModularExpansionValvesPressureDifference;
Package that contains example models
within AixLib.Fluid.Actuators.Valves.ExpansionValves; package Examples "Package that contains example models" extends Modelica.Icons.ExamplesPackage; end Examples;
Base model to test expansion valve using static heat pump boundaries
within AixLib.Fluid.Actuators.Valves.ExpansionValves.Examples; model StaticHeatPumpBoundaries "Base model to test expansion valve using static heat pump boundaries" extends Modelica.Icons.Example; // Definition of medium // replaceable package Medium = Modelica.Media.R134a.R134a_ph constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium "Medium of the compressor" // Definition of parameters describing compressors // parameter Integer nVal = 1 "Numer of compressors in parallel" // Definition of parameters describing boundary conditions // parameter Modelica.Units.SI.TemperatureDifference dTPinEva=2 "Pinch temperature at evaporator's outlet" parameter Modelica.Units.SI.TemperatureDifference dTSupHea=1 "Superheating of working fluid" parameter Modelica.Units.SI.TemperatureDifference dTPinCond=2 "Pinch temperature at condenser's outlet" parameter Modelica.Units.SI.TemperatureDifference dTSubCool=4 "Supercooling of working fluid" parameter Modelica.Units.SI.Density dSec=1000 "Constant density of secondary fluid" parameter Modelica.Units.SI.SpecificHeatCapacity cpSec=4.1813e3 "Constant specific heat capacity of secondary fluid" parameter Modelica.Units.SI.VolumeFlowRate V_flowSec=(0.776 + 0.781 + 0.44)/3 /3600 "Constant volume flow of secondary fluid" // Definition of variables describing boundary conditions // Modelica.Blocks.Sources.CombiTimeTable inpDat( extrapolation=Modelica.Blocks.Types.Extrapolation.NoExtrapolation, columns=2:7, table=[0,64,285.15,5180,308.15,900,5.755555556; 1,64,283.15,4920,308.15,910, 5.406593407; 2,63,280.15,4370,308.15,930,4.698924731; 3,64,285.15,4980,318.15, 1140,4.368421053; 4,64,283.15,4730,318.15,1140,4.149122807; 5,55,285.15, 4180,328.15,1240,3.370967742; 6,64,283.15,4650,328.15,1380,3.369565217; 7,63,280.15,4160,318.15,1610,2.583850932; 8,55,275.15,2800,308.15,790,3.544303797; 9,106,258.15,3760,308.15,1570,2.394904459; 10,115,266.15,4850,308.15,1940, 2.5; 11,55,275.15,2640,318.15,960,2.75; 12,111,258.15,4150,318.15,2120,1.95754717; 13,107,270.15,4780,318.15,2210,2.162895928; 14,113,266.15,4560,318.15,2290, 1.991266376; 15,100,266.15,3880,328.15,2240,1.732142857; 16,63,275.15,3280, 328.15,1330,2.466165414; 17,63,280.15,4080,328.15,1400,2.914285714], smoothness=Modelica.Blocks.Types.Smoothness.ContinuousDerivative) "Static boundaries of compressor model" Modelica.Blocks.Sources.RealExpression inpSetSpeEnt(y=con.hOut) "Expressions describing set point of specific enthalpy" Modelica.Blocks.Sources.RealExpression inpAmbTemp(y=inpDat.y[2]) "Expressions describing ambient temperature" Modelica.Blocks.Sources.RealExpression inpColCap(y=inpDat.y[3] - inpDat.y[5]) "Expressions describing col capacity" Modelica.Blocks.Sources.RealExpression inpHeaCap(y=inpDat.y[3]) "Expressions describing heat capacity" Modelica.Blocks.Sources.RealExpression inpTFlo(y=inpDat.y[4]) "Expressions describing flow temperature at heat capacity" // Definition of subcomponents // StaticEvaporator eva( redeclare final package Medium = Medium, final dTPin=dTPinEva, final dTSupHea=dTSupHea, nPorts=nVal) "Model that describes a simple static evaporator" Modelica.Blocks.Continuous.LimPID conPID( k=0.001, Ti=10, controllerType=Modelica.Blocks.Types.SimpleController.P, yMax=1, yMin=0.05) "PID controller to set valves' openings" Modelica.Blocks.Sources.RealExpression inpCurSpeEnt(y=eva.hInl) "Expressions describing current specific enthalpy" Modelica.Blocks.Routing.Replicator repMea(nout=nVal) "Replicating the current value of the manipulated variables" ModularExpansionValves.ModularExpansionValvesSensors modExpVal( redeclare package Medium = Medium, nVal=nVal, redeclare model SimpleExpansionValve = SimpleExpansionValves.IsenthalpicExpansionValve, AVal=fill(1.767e-6, nVal), useExt=true, useInpFil=fill(true, nVal), redeclare model FlowCoefficient = Utilities.FlowCoefficient.SpecifiedFlowCoefficients.Poly_R22R407CR410A_EEV_15_22, risTim=fill(0.01328, nVal)) "Model that describes modular expansion valves in parallel" StaticCondenser con( redeclare package Medium = Medium, dTSubCool=dTSubCool, dTPin=dTPinCond, dSec=dSec, cpSec=cpSec, V_flowSec=V_flowSec) "Model that describes a simple static condenser" AixLib.Controls.Interfaces.ModularHeatPumpControlBus dataBus(nVal=nVal) "Connector that contains all control signals" protected model StaticEvaporator "Static evaporator assuming constant pinch point at evaporator's outlet" // Definition of medium // replaceable package Medium = Modelica.Media.R134a.R134a_ph constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium "Medium of the expansion valve" // Definition of parameters describing evaporator // parameter Integer nPorts = 1; parameter Modelica.Units.SI.TemperatureDifference dTPin=5 "Pinch temperature at evaporator's outlet" parameter Modelica.Units.SI.TemperatureDifference dTSupHea=1 "Superheating of working fluid" // Definition of parameters describing assumptions // parameter Boolean allowFlowReversal = false "= false to simplify equations, assuming, but not enforcing, no flow reversal" // Definition of connecotrs // Modelica.Fluid.Interfaces.FluidPorts_b ports_b[nPorts]( redeclare each final package Medium = Medium, h_outflow(each start = Medium.h_default), m_flow(each max=Modelica.Constants.inf)) "Fluid connectors b (positive design flow direction is from port_a to port_b)" Modelica.Blocks.Interfaces.RealInput inpTAmb "Input of ambient temperature" Modelica.Blocks.Interfaces.RealInput inpQ_flow "Input of cold capacity" // Definition of submodels // Modelica.Blocks.Sources.RealExpression inlPEva(y=pSat) "Expressions describing saturation pressure at evaporator's inlet" Modelica.Blocks.Sources.RealExpression inlhEva(y=hInl) "Expressions describing specific enthalpy at evaporator's inlet" AixLib.Fluid.Sources.Boundary_ph source( redeclare package Medium = Medium, use_p_in=true, use_h_in=true, nPorts=1) "Source with constant pressure and specific enthalpy" Interfaces.PortsAThroughPortB outVal( redeclare package Medium = Medium, nVal=nPorts) "Model that combines the outputs of modular expansion valves" Sensors.SpecificEnthalpyTwoPort senSpeEnt[nPorts]( redeclare package Medium = Medium, each m_flow_nominal=0.05, each initType=Modelica.Blocks.Types.Init.NoInit, each tau=0, each h_out_start=275e3) "Sensor that measures current specific enthalpy" Sensors.MassFlowRate senMasFlo[nPorts](redeclare package Medium = Medium) "Sensor that measures current mas flow rate" // Definition of variables describing evaporator // Medium.SaturationProperties satEva "Saturation properties of the evaporator's working fluid" Medium.ThermodynamicState staOut "Thermodynamic state of the working fluid at evaporator's outlet" public Modelica.Units.SI.AbsolutePressure pSat "Absolute pressure at evaporator's outlet"; Modelica.Units.SI.Temperature TSat "Saturation temperature"; Modelica.Units.SI.SpecificEnthalpy hInl "Specific enthalpy at evaporator's inlet"; Modelica.Units.SI.SpecificEnthalpy hOut "Specific enthalpy at evaporator's outlet"; Modelica.Units.SI.Temperature TOut "Temperature at evaporator's outlet"; Modelica.Units.SI.Temperature TAmb "Temperature of ambient"; Modelica.Units.SI.MassFlowRate m_flow "Mass flow rate"; Modelica.Units.SI.HeatFlowRate Q_flow "Cooling capacity"; equation // Connection of ports // connect(inlPEva.y, source.p_in) connect(inlhEva.y, source.h_in) connect(ports_b, senSpeEnt.port_a) connect(senSpeEnt.port_b, senMasFlo.port_a) connect(source.ports[1], outVal.port_b) connect(senMasFlo.port_b, outVal.ports_a) TAmb = inpTAmb "Temperature of ambient"; m_flow = senMasFlo[1].m_flow "Mass flow rate"; Q_flow = inpQ_flow "Cooling capacity"; // Calculation of state properties of working fluid // satEva = Medium.setSat_T(T=TSat) "Saturation properties"; staOut = Medium.setState_pT(p=pSat,T=TOut) "Thermodynamic state of the working fluid at evaporator's outlet"; pSat = Medium.saturationPressure(satEva.Tsat) "Absolute pressure at evaporator's outlet"; TSat = TOut - dTSupHea "Saturation temperature"; hInl = hOut - Q_flow/m_flow "Specific enthalpy at evaporator's inlet"; TOut = TAmb - dTPin "Temperature at evaporator's outlet"; hOut = Medium.specificEnthalpy(staOut) "Specific enthalpy at evaporator's outlet"; end StaticEvaporator; model StaticCondenser "Static condenser assuming constant pinch point at condenser's outlet" // Definition of medium // replaceable package Medium = Modelica.Media.R134a.R134a_ph constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium "Medium of the expansion valve" // Definition of parameters describing condenser // parameter Modelica.Units.SI.TemperatureDifference dTPin=5 "Pinch temperature at condenser's outlet" parameter Modelica.Units.SI.TemperatureDifference dTSubCool=8 "Supercooling of working fluid" parameter Modelica.Units.SI.Density dSec=1000 "Constant density of secondary fluid" parameter Modelica.Units.SI.SpecificHeatCapacity cpSec=4.1813e3 "Constant specific heat capacity of secondary fluid" parameter Modelica.Units.SI.VolumeFlowRate V_flowSec=(0.776 + 0.781 + 0.44) /3/3600 "Constant volume flow of secondary fluid" // Definition of parameters describing assumptions // parameter Boolean allowFlowReversal = false "= false to simplify equations, assuming, but not enforcing, no flow reversal" // Definition of connecotrs // Modelica.Fluid.Interfaces.FluidPort_b port_b( redeclare final package Medium = Medium, m_flow(max=if allowFlowReversal then +Modelica.Constants.inf else 0), h_outflow(start = Medium.h_default)) "Fluid connector b (positive design flow direction is from port_a to port_b)" Modelica.Blocks.Interfaces.RealInput inpQ_flow "Heat capacity" Modelica.Blocks.Interfaces.RealInput inpTFlo "Temperature flow at heat capacity" // Definition of subcomponents // Modelica.Blocks.Sources.RealExpression inlPCond(y=pSat) "Expressions describing saturation pressure at condenser's inlet" Modelica.Blocks.Sources.RealExpression inlTCon(y=TOut) "Expressions describing temperature at condenser's inlet" AixLib.Fluid.Sources.Boundary_pT sink( redeclare package Medium = Medium, use_p_in=true, use_T_in=true, nPorts=1) "Source with constant pressure and temperature" AixLib.Fluid.Sensors.SpecificEnthalpyTwoPort senSpeEnt( redeclare package Medium = Medium, m_flow_nominal=0.05, initType=Modelica.Blocks.Types.Init.NoInit, h_out_start=400e3, tau=0) "Sensor that measures current specific enthalpy" AixLib.Fluid.Sensors.MassFlowRate senMasFlo( redeclare package Medium =Medium) "Sensor that measures current mas flow rate" // Definition of variables describing condenser // Medium.SaturationProperties satCon "Saturation properties of the condenser's working fluid" Medium.ThermodynamicState staOut "Thermodynamic state of the working fluid at condenser's outlet" public Modelica.Units.SI.AbsolutePressure pSat "Absolute pressure at condenser's outlet"; Modelica.Units.SI.Temperature TSat "Saturation temperature"; Modelica.Units.SI.Temperature TOut "Temperature at condenser's outlet"; Modelica.Units.SI.SpecificEnthalpy hOut "Specific enthalpy at condenser's outlet"; Modelica.Units.SI.MassFlowRate m_flow "Mass flow rate"; Modelica.Units.SI.HeatFlowRate Q_flow "Heat capacity"; Modelica.Units.SI.MassFlowRate m_flowSec "Mass flow rate of secondary fluid"; Modelica.Units.SI.Temperature TFlo "Temperature flow at heat capacity"; Modelica.Units.SI.Temperature TRetFlo "Temperature return flow at heat capacity"; equation // Connection of ports // connect(inlPCond.y, sink.p_in) connect(inlTCon.y, sink.T_in) connect(sink.ports[1], senMasFlo.port_b) connect(senMasFlo.port_a, senSpeEnt.port_b) connect(senSpeEnt.port_a,port_b) m_flow = senMasFlo.m_flow "Mass flow rate"; Q_flow = inpQ_flow "Heat capacity"; TFlo = inpTFlo "Temperature flow at heat capacity"; // Calculation of state properties of working fluid // satCon = Medium.setSat_T(T=TSat) "Saturation properties"; staOut = Medium.setState_pT(p=pSat,T=TOut) "Thermodynamic state of the working fluid at condenser's outlet"; pSat = Medium.saturationPressure(T=TSat) "Absolute pressure at condenser's outlet"; TSat = TOut + dTSubCool "Saturation temperature"; TOut = TRetFlo + dTPin "Temperature at condenser's outlet"; hOut = Medium.specificEnthalpy(state=staOut) "Specific enthalpy at condenser's outlet"; TRetFlo = TFlo - Q_flow/(m_flowSec*cpSec) "Temperature return flow at heat capacity"; m_flowSec = dSec*V_flowSec "Mass flow rate of secondary fluid"; end StaticCondenser; equation // Connection of main components // connect(con.port_b, modExpVal.port_a) // Connection of signals // connect(modExpVal.dataBus, dataBus) connect(inpHeaCap.y, con.inpQ_flow) connect(inpTFlo.y, con.inpTFlo) connect(repMea.y, dataBus.expValBus.extManVarVal) connect(inpColCap.y, eva.inpQ_flow) connect(inpAmbTemp.y, eva.inpTAmb) connect(inpCurSpeEnt.y, conPID.u_m) connect(inpSetSpeEnt.y, conPID.u_s) connect(conPID.y, repMea.u) connect(eva.ports_b, modExpVal.ports_b) end StaticHeatPumpBoundaries;
Model of modular expansion valves, i.g. each valves is in front of an evaporator. This is a model of modular expansion valves that are used, for example, in close-loop systems like heat pumps or chillers.<br/> It consists of <code>nVal</code> expansion valves in parallel and also <code>nVal</code> PID conrollers if no external controller is used.
within AixLib.Fluid.Actuators.Valves.ExpansionValves.ModularExpansionValves; model ModularExpansionValves "Model of modular expansion valves, i.g. each valves is in front of an evaporator" extends BaseClasses.PartialModularExpansionVavles; equation // Connect ports_b with outlet ports of expansion valves // for i in 1:nVal loop connect(modExpVal[i].port_b, ports_b[i]); end for; end ModularExpansionValves;
Model of modular expansion valves, i.g. each valves is in front of an evaporator, combined with sensors
within AixLib.Fluid.Actuators.Valves.ExpansionValves.ModularExpansionValves; model ModularExpansionValvesSensors "Model of modular expansion valves, i.g. each valves is in front of an evaporator, combined with sensors" extends BaseClasses.PartialModularExpansionVavles; // Definition of parameters // parameter Modelica.Units.SI.Time tau=1 "Time constant at nominal flow rate" parameter Boolean transferHeat = false "if true, temperature T converges towards TAmb when no flow" parameter Modelica.Units.SI.Temperature TAmb=Medium.T_default "Fixed ambient temperature for heat transfer" parameter Modelica.Units.SI.Time tauHeaTra=1200 "Time constant for heat transfer, default 20 minutes" parameter Modelica.Blocks.Types.Init initTypeSen= Modelica.Blocks.Types.Init.InitialState "Type of initialization (InitialState and InitialOutput are identical)" parameter Modelica.Units.SI.Temperature T_start=Medium.T_default "Initial or guess value of output (= state)" parameter Modelica.Units.SI.SpecificEnthalpy h_out_start= Medium.specificEnthalpy_pTX( p=Medium.p_default, T=Medium.T_default, X=Medium.X_default) "Initial or guess value of output (= state)" parameter Boolean show_parSen = false "= true, if sensors' input parameters are shown in results" // Definition of models // Utilities.ModularSensors modularSensors( redeclare final package Medium = Medium, final nPorts=nVal, final m_flow_nominal=m_flow_nominal, final m_flow_small=1e-6*m_flow_nominal, final tau=tau, final transferHeat=transferHeat, final TAmb=TAmb, final tauHeaTra=tauHeaTra, final initType=initTypeSen, final T_start=T_start, final h_out_start=h_out_start) "Model that contains different sensors located behind expansion valves" equation // Connect expansion valves with sensors and sensors with ports_b // for i in 1:nVal loop connect(modExpVal[i].port_b, modularSensors.ports_a[i]); connect(modularSensors.ports_b[i],ports_b[i]); end for; // Connect sensors with data bus // connect(modularSensors.preMea, dataBus.senBus.meaPreVal) connect(modularSensors.temMea, dataBus.senBus.meaTemVal) connect(modularSensors.masFloMea, dataBus.senBus.meaMasFloVal) connect(modularSensors.quaMea, dataBus.senBus.meaPhaVal) end ModularExpansionValvesSensors;
Package that contains models of modular expansion valves based on simple expansion valves
within AixLib.Fluid.Actuators.Valves.ExpansionValves; package ModularExpansionValves "Package that contains models of modular expansion valves based on simple expansion valves" extends Modelica.Icons.VariantsPackage; end ModularExpansionValves;
Model of a simple isenthalpic expansion valve. This is a model of a simple expansion valve that is used, for example, in close-loop systems like heat pumps or chillers. It inherits from PartialIsenthalpicExpansionValve which inherits from PartialExpansionValve. Therefore, please checkout these sub-models for further information of underlying modeling approaches and parameterisation:
within AixLib.Fluid.Actuators.Valves.ExpansionValves.SimpleExpansionValves; model IsenthalpicExpansionValve "Model of a simple isenthalpic expansion valve" extends BaseClasses.PartialIsenthalpicExpansionValve; equation // Calculation of mass flow and pressure drop // if (calcProc == Utilities.Types.CalcProc.linear) then C = 1 "Linear relationship"; m_flow = C * AThr * dp "Simple linear relationship between mass flow and pressure drop"; elseif (calcProc == Utilities.Types.CalcProc.nominal) then C * dpNom = mFlowNom "Nominal relationship"; m_flow = C * AThr * dp "Simple nominal relationship between mass flow and pressure drop"; elseif (calcProc == Utilities.Types.CalcProc.flowCoefficient) then C = flowCoefficient.C "Flow coefficient model"; m_flow = homotopy(C * AThr * sqrt(abs(2*dInl*dp)), mFlowNom/dpNom * AThr * dp) "Usage of flow coefficient model"; else assert(false, "Invalid choice of calculation procedure"); end if; end IsenthalpicExpansionValve;
Package that contains simple expansion valves
within AixLib.Fluid.Actuators.Valves.ExpansionValves; package SimpleExpansionValves "Package that contains simple expansion valves" extends Modelica.Icons.VariantsPackage; end SimpleExpansionValves;
Model that contains mass flow, pressure, temperature and quality sensors for modular heat pump models
within AixLib.Fluid.Actuators.Valves.ExpansionValves.Utilities; model ModularSensors "Model that contains mass flow, pressure, temperature and quality sensors for modular heat pump models" // Definition of parameters // parameter Modelica.Units.SI.Time tau=1 "Time constant at nominal flow rate" parameter Boolean transferHeat=false "if true, temperature T converges towards TAmb when no flow" parameter Modelica.Units.SI.Temperature TAmb=Medium.T_default "Fixed ambient temperature for heat transfer" parameter Modelica.Units.SI.Time tauHeaTra=1200 "Time constant for heat transfer, default 20 minutes" parameter Modelica.Blocks.Types.Init initType= Modelica.Blocks.Types.Init.InitialState "Type of initialization (InitialState and InitialOutput are identical)" parameter Modelica.Units.SI.Temperature T_start=Medium.T_default "Initial or guess value of output (= state)" parameter Modelica.Units.SI.SpecificEnthalpy h_out_start= Medium.specificEnthalpy_pTX( p=Medium.p_default, T=Medium.T_default, X=Medium.X_default) "Initial or guess value of output (= state)" // Extensions // extends Interfaces.PartialModularPort_ab; // Definition of variables // Medium.SaturationProperties satPro[nPorts] "Saturation states for each fluid port"; Modelica.Units.SI.SpecificEnthalpy bubEnt[nPorts] "Bubble enthalpies for each fluid port"; Modelica.Units.SI.SpecificEnthalpy dewEnt[nPorts] "Dew enthalpies for each fluid port"; Real pTriCri[nPorts] "Trigger to check if medium exceeds critical pressure"; // Definition of models // Sensors.MassFlowRate senMasFlo[nPorts]( redeclare each final package Medium = Medium) "Mass flow sensors" Sensors.Pressure senPre[nPorts]( redeclare each final package Medium = Medium) "Pressure sensors" Sensors.TemperatureTwoPort senTem[nPorts]( redeclare each final package Medium = Medium, each final m_flow_nominal=m_flow_nominal, each final m_flow_small=m_flow_small, each final tau=tau, each final initType=initType, each final T_start=T_start, each final transferHeat=transferHeat, each final TAmb=TAmb, each final tauHeaTra=tauHeaTra) "Temperature sensors" Sensors.SpecificEnthalpyTwoPort senSpeEnt[nPorts]( redeclare each final package Medium = Medium, each final m_flow_nominal=m_flow_nominal, each final m_flow_small=m_flow_small, each final tau=tau, each final initType=initType, each final h_out_start=h_out_start) "Specific enthalpy sensors" // Definition of connectors // Modelica.Blocks.Interfaces.RealOutput preMea[nPorts] "Pressures measured by sensors" Modelica.Blocks.Interfaces.RealOutput temMea[nPorts] "Temperatures measured by sensors" Modelica.Blocks.Interfaces.RealOutput masFloMea[nPorts] "Mass flow rates measured by sensors" Modelica.Blocks.Interfaces.RealOutput quaMea[nPorts] "Qualities measured by sensors" equation // Calculating vapour qualities // for i in 1:nPorts loop satPro[i] = Medium.setSat_p(senPre[i].p) "Set saturation properties"; bubEnt[i] = Medium.bubbleEnthalpy(satPro[i]) "Calculate bubble enthalpies"; dewEnt[i] = Medium.dewEnthalpy(satPro[i]) "Calculate dew enthalpies"; pTriCri[i] = senPre[i].p/Medium.fluidConstants[1].criticalPressure "Check if medium exceeds critical pressure"; quaMea[i] = noEvent(if (pTriCri[i]<1 and senSpeEnt[i].h_out<bubEnt[i]) then 0 else if (pTriCri[i]<1 and senSpeEnt[i].h_out>bubEnt[i] and senSpeEnt[i].h_out<dewEnt[i]) then (senSpeEnt[i].h_out - bubEnt[i])/ max(dewEnt[i] - bubEnt[i], 1e-6) else 1.0) "Calculate vapour qualities"; end for; // Connection of sensors // for i in 1:nPorts loop connect(ports_a[i],senMasFlo[i].port_a); connect(senMasFlo[i].port_b,senPre[i].port); connect(senMasFlo[i].port_b,senTem[i].port_a); connect(senTem[i].port_b,senSpeEnt[i].port_a); connect(senSpeEnt[i].port_b,ports_b[i]); end for; // Connection of outputs // connect(preMea,senPre.p); connect(temMea,senTem.T); connect(masFloMea,senMasFlo.m_flow); end ModularSensors;
Package that contains further functions needed to compute the expnasion valves
within AixLib.Fluid.Actuators.Valves.ExpansionValves; package Utilities "Package that contains further functions needed to compute the expnasion valves" extends Modelica.Icons.UtilitiesPackage; end Utilities;
Package that contains models describing different flow coefficients
within AixLib.Fluid.Actuators.Valves.ExpansionValves.Utilities; package FlowCoefficient "Package that contains models describing different flow coefficients" extends Modelica.Icons.Package; end FlowCoefficient;
Model describing flow coefficient based on polynomial approach. This model contains calculation procedures for flow coefficients (for more information, please check out <a href= \"modelica://AixLib.Fluid.Actuators.Valves.ExpansionValves.BaseClasses.PartialExpansionValve\"> AixLib.Fluid.Actuators.Valves.ExpansionValves.BaseClasses.PartialExpansionValve</a>). The calculation procedures based on a polynomial approach and are presented below.
within AixLib.Fluid.Actuators.Valves.ExpansionValves.Utilities.FlowCoefficient; model PolynomialFlowCoefficient "Model describing flow coefficient based on polynomial approach" extends BaseClasses.PartialFlowCoefficient; // Definition of parameters // parameter Types.PolynomialModels polyMod=Types.PolynomialModels.ShanweiEtAl2005 "Chose predefined polynomial model for flow coefficient" parameter Real a[:] "Multiplication factors for each summand" parameter Real b[:] "Exponents for each summand" parameter Integer nT = size(a,1) "Number of terms used for the calculation procedure" parameter Modelica.Units.SI.Diameter dCle=0.02e-3 "Clearance diameter dCle = d_inner - d_needle" parameter Real pDifRat = 0.84 "Pressure differential ratio factor depending on valve moddeld" // Definition of coefficients // Real P[nT] "Array that contains all coefficients used for the calculation procedure"; Real corFact "Corraction factor used to correct flow coefficient"; /*The correction factor is used to correct the flow coefficient if the formula presented by the author is not equal to m_flow = C_D*A*sqrt(2*rho_inlet*(pInl-pOut)) */ protected Medium.SaturationProperties satInl "Saturation properties at valve's inlet conditions"; Medium.SaturationProperties satOut "Saturation properties at valve's outlet conditions"; equation // Calculation of protected variables // satInl = Medium.setSat_p(pInl) "Saturation properties at valve's inlet conditions"; satOut = Medium.setSat_p(pOut) "Saturation properties at valve's outlet conditions"; // Calculation of coefficients // if (polyMod == Types.PolynomialModels.ShanweiEtAl2005) then /*Polynomial approach presented by Shanwei et al. (2005): C_D = a1*AVal + a2*rho_inlet + a3*rho_outlet + a4*T_subcooling + a5*dCle + a6*(pInl-pOut) Caution with units - In the following, none S.I units are presented: Pressure: in kPa Temperature: in °C Heat capacity: in kJ/(kg*K) Heat of vap.: in kJ/kg */ P[1] = opening*AVal "Actual coss-sectional flow area"; P[2] = Medium.bubbleDensity(satInl) "Density at valve's inlet"; P[3] = Medium.density(staOut) "Density at valve's outlet"; P[4] = satInl.Tsat - Medium.temperature(staInl) "Degree of subcooling"; P[5] = dCle "Radial clearance"; P[6] = (pInl-pOut)*1e-3 "Pressure difference between inlet and outlet"; corFact = 1 "No correction factor is needed"; elseif (polyMod == Types.PolynomialModels.Li2013) then /*Polynomial approach presented by Li (2013): C_D = a1 + a2*opening + a3*opening^2 + a4*opening*(T_subcooling/T_crit) + a5*(T_subcooling/T_crit) + a6*(T_subcooling/T_crit)^2 Caution with units - In the following, none S.I units are presented: Pressure: in kPa Temperature: in °C */ P[1] = 1 "Dummy coefficient since no coefficient is needed"; P[2] = opening "Degree of valve's opening"; P[3] = opening^2 "Quadratic degree of valve's opening"; P[4] = opening*(satInl.Tsat - Medium.temperature(staInl))/ (Medium.fluidConstants[1].criticalTemperature-273.15) "Degree of valve's opening times degree of subcooling"; P[5] = (satInl.Tsat - Medium.temperature(staInl))/ (Medium.fluidConstants[1].criticalTemperature-273.15) "Degree of subcooling"; P[6] = ((satInl.Tsat - Medium.temperature(staInl))/ (Medium.fluidConstants[1].criticalTemperature-273.15))^2 "Quadratic degree of subcooling"; corFact = 1 - ((1-pOut/pInl)/ (3*(Medium.isentropicExponent(staOut)/1.4)*pDifRat)) "Correction factor taking partial vaporisation into account"; /*The correction factos takes into accout that a partial vaporisation takes place while throttling process. It is a function of the pressure difference between inlet and outlet, the isentropic exponent and the pressure differential ratio factor depending on the valve moddeld. */ else assert(false, "Invalid choice of polynomial approach"); end if; // Calculationg of flow coefficient // C = corFact * sum(a[i]*P[i]^b[i] for i in 1:nT) "Calculation procedure of general polynomial"; end PolynomialFlowCoefficient;
Model describing flow coefficient based on power approach. This model contains calculation procedures for flow coefficients (for more information, please check out <a href= \"modelica://AixLib.Fluid.Actuators.Valves.ExpansionValves.BaseClasses.PartialExpansionValve\"> AixLib.Fluid.Actuators.Valves.ExpansionValves.BaseClasses.PartialExpansionValve</a>). The calculation procedures based on a power approach and are presented below.
within AixLib.Fluid.Actuators.Valves.ExpansionValves.Utilities.FlowCoefficient; model PowerFlowCoefficient "Model describing flow coefficient based on power approach" extends BaseClasses.PartialFlowCoefficient; // Definition of parameters // parameter Types.PowerModels powMod=Types.PowerModels.ShanweiEtAl2005 "Chose predefined power model for flow coefficient" parameter Real a "Multiplication factor for generic power approach" parameter Real b[:] "Exponents for each multiplier" parameter Integer nT = size(b,1) "Number of terms used for the calculation procedure" parameter Modelica.Units.SI.Diameter dCle=0.02e-3 "Clearance diameter dCle = d_inner - d_needle" parameter Real pDifRat = 0.84 "Pressure differential ratio factor depending on valve moddeld" // Definition of coefficients // Real P[nT] "Array that contains all coefficients used for the calculation procedure"; Real corFact "Corraction factor used to correct flow coefficient"; /*The correction factor is used to correct the flow coefficient if the formula presented by the author is not equal to m_flow = C_D*A*sqrt(2*rho_inlet*(pInl-pOut)) */ protected Medium.SaturationProperties satInl "Saturation properties at valve's inlet conditions"; Medium.SaturationProperties satOut "Saturation properties at valve's outlet conditions"; equation // Calculation of protected variables // satInl = Medium.setSat_p(pInl) "Saturation properties at valve's inlet conditions"; satOut = Medium.setSat_p(pOut) "Saturation properties at valve's outlet conditions"; // Calculation of coefficients // if (powMod == Types.PowerModels.ShanweiEtAl2005) then /*Polynomial approach presented by Shanwei et al. (2005): C_D = C * (AVal/dCle^2)^b1 * ((pInl-pOut)/p_crit)^b2 * (T_crit/T_supercooled)^b3 * (rho_inlet/rho_outlet)^b4 * (quality)^b5 Caution with units - In the following, none S.I units are presented: Pressure: in kPa Temperature: in °C Heat capacity: in kJ/(kg*K) Heat of vap.: in kJ/kg */ P[1] = opening*AVal/(dCle^2) "Actual coss-sectional flow area"; P[2] = (pInl-pOut)/Medium.fluidConstants[1].criticalPressure "Pressure difference"; P[3] = (Medium.fluidConstants[1].criticalTemperature-273.15)/ max((satInl.Tsat - Medium.temperature(staInl)),0.01) "Degree of subooling"; P[4] = Medium.bubbleDensity(satInl)/Medium.density(staOut) "Density at valve's inlet and at valve's outlet"; P[5] = (Medium.bubbleDensity(satOut)/Medium.density(staOut)- 1)/ (Medium.bubbleDensity(satOut)/Medium.dewDensity(satOut) - 1) "Vapour quality at valve's outlet"; corFact = 1 "No correction factor is needed"; elseif (powMod == Types.PowerModels.ZhifangAndOu2008) then /*Polynomial approach presented by Zhifang and Ou (2008): C_D = C * ((pInl-pOut)*sqrt(AVal)/sigma_inlet)^b1 * (dInlPip*sqrt(rho_inlet*pInl)/eta_inlet)^b2 Caution with units - In the following, none S.I units are presented: Pressure: in kPa */ P[1] = (pInl-pOut)*1e-3*sqrt(abs(opening*AVal))/ max(Medium.surfaceTension(satInl),1e-6) "Surface tension at valve's inlet"; P[2] = dInlPip*sqrt(abs(Medium.density(staInl)*pInl*1e-3))/ Medium.dynamicViscosity(staInl) "Dynamic viscosity at valve's inlet"; corFact = 1 "No correction factor is needed"; elseif (powMod == Types.PowerModels.Li2013) then /*Polynomial approach presented by Li (2013): C_D = C * (opening)^b1 * (T_supercooled/T_crit)^b2 Caution with units - In the following, none S.I units are presented: Pressure: in kPa Temperature: in °C */ P[1] = opening "Degree of valve's opening"; P[2] = (satInl.Tsat - Medium.temperature(staInl))/ (Medium.fluidConstants[1].criticalTemperature-273.15) "Degree of subcooling"; corFact = 1 - ((1-pOut/pInl)/ (3*(Medium.isentropicExponent(staOut)/1.4)*pDifRat)) "Correction factor taking partial vaporisation into account"; /*The correction factos takes into accout that a partial vaporisation takes place while throttling process. It is a function of the pressure difference between inlet and outlet, the isentropic exponent and the pressure differential ratio factor depending on the valve moddeld. */ else assert(false, "Invalid choice of power approach"); end if; // Calculationg of flow coefficient // C = corFact * a * product(abs(P[i])^b[i] for i in 1:nT) "Calculation procedure of generic power approach"; end PowerFlowCoefficient;
Buckingham - Similitude for R22, R407C, R410A - EEV - 1.5 mm to 2.2 mm . This model contains a calculation procedure for flow coefficients presented by Shanwei et al. (2005).<br/>
within AixLib.Fluid.Actuators.Valves.ExpansionValves.Utilities.FlowCoefficient.SpecifiedFlowCoefficients; model Buck_R22R407CR410A_EEV_15_22 "Buckingham - Similitude for R22, R407C, R410A - EEV - 1.5 mm to 2.2 mm " extends PowerFlowCoefficient( final powMod=Types.PowerModels.ShanweiEtAl2005, final a=0.2343, final b={0.0281,0.0260,-0.0477,-0.1420,-0.1291}, final dCle=0.02e-3); end Buck_R22R407CR410A_EEV_15_22;
Buckingham - Similitude for R22, R407C, R410A - EEV - 1.6 mm to 1.8 mm . This model contains a calculation procedure for flow coefficients presented by Li (2013).<br/>
within AixLib.Fluid.Actuators.Valves.ExpansionValves.Utilities.FlowCoefficient.SpecifiedFlowCoefficients; model Buck_R22R407CR410A_EEV_16_18 "Buckingham - Similitude for R22, R407C, R410A - EEV - 1.6 mm to 1.8 mm " extends PowerFlowCoefficient( final powMod=Types.PowerModels.Li2013, final a=1.066, final b={0.8006,0.0609}, final pDifRat=0.84); end Buck_R22R407CR410A_EEV_16_18;
General model that describes a constant flow coefficient. This model contains a simple calculation procedure for flow coefficients (for more information, please check out <a href= \"modelica://AixLib.Fluid.Actuators.Valves.ExpansionValves.BaseClasses.PartialExpansionValve\"> AixLib.Fluid.Actuators.Valves.ExpansionValves.BaseClasses.PartialExpansionValve</a>). The model provides a constant flow coefficient and is the most basic flow coefficient model.
within AixLib.Fluid.Actuators.Valves.ExpansionValves.Utilities.FlowCoefficient.SpecifiedFlowCoefficients; model ConstantFlowCoefficient "General model that describes a constant flow coefficient" extends BaseClasses.PartialFlowCoefficient; // Definition of parameters // parameter Real C_const(unit="1", min = 0, max = 100, nominal = 25) = 15 "Constant flow coefficient"; equation // Calculate flow coefficient // C = C_const "Allocation of constant flow coefficient"; end ConstantFlowCoefficient;
Package that cointains flow coefficients that are specified
within AixLib.Fluid.Actuators.Valves.ExpansionValves.Utilities.FlowCoefficient; package SpecifiedFlowCoefficients "Package that cointains flow coefficients that are specified" extends Modelica.Icons.VariantsPackage; end SpecifiedFlowCoefficients;
Polynomial - Similitude for R22, R407C, R410A - EEV - 1.5 mm to 2.2 mm. This model contains a calculation procedure for flow coefficients presented by Shanwei et al. (2005).<br/>
within AixLib.Fluid.Actuators.Valves.ExpansionValves.Utilities.FlowCoefficient.SpecifiedFlowCoefficients; model Poly_R22R407CR410A_EEV_15_22 "Polynomial - Similitude for R22, R407C, R410A - EEV - 1.5 mm to 2.2 mm" extends PolynomialFlowCoefficient( final polyMod=Types.PolynomialModels.ShanweiEtAl2005, final a={-1.615e4,3.328e-4,1.4465e-3,2.9968e-3,-3.3890e2,7.0925e-5}, final b={1,1,1,1,1,1}, final dCle=0.02e-3); end Poly_R22R407CR410A_EEV_15_22;
Polynomial - R22 - EEV - 1.6 mm. This model contains a calculation procedure for flow coefficients presented by Li (2013).<br/>
within AixLib.Fluid.Actuators.Valves.ExpansionValves.Utilities.FlowCoefficient.SpecifiedFlowCoefficients; model Poly_R22_EEV_16 "Polynomial - R22 - EEV - 1.6 mm" extends PolynomialFlowCoefficient( final polyMod=Types.PolynomialModels.Li2013, final a={-0.03469,1.64866,-0.84227,1.19513,0,0}, final b={1,1,1,1,1,1}, final pDifRat=0.84); end Poly_R22_EEV_16;
Polynomial - R407c - EEV - 1.8 mm. This model contains a calculation procedure for flow coefficients presented by Li (2013).<br/>
within AixLib.Fluid.Actuators.Valves.ExpansionValves.Utilities.FlowCoefficient.SpecifiedFlowCoefficients; model Poly_R407c_EEV_18 "Polynomial - R407c - EEV - 1.8 mm" extends PolynomialFlowCoefficient( final polyMod=Types.PolynomialModels.Li2013, final a={-0.07154,1.67713,-0.79141,1.09516,0,0}, final b={1,1,1,1,1,1}, final pDifRat=0.84); end Poly_R407c_EEV_18;
Polynomial - R410a - EEV - 1.8 mm. This model contains a calculation procedure for flow coefficients presented by Li (2013).<br/>
within AixLib.Fluid.Actuators.Valves.ExpansionValves.Utilities.FlowCoefficient.SpecifiedFlowCoefficients; model Poly_R410a_EEV_18 "Polynomial - R410a - EEV - 1.8 mm" extends PolynomialFlowCoefficient( final polyMod=Types.PolynomialModels.Li2013, final a={-0.07374,1.5461,-0.73679,1.09651,0,0}, final b={1,1,1,1,1,1}, final pDifRat=0.84); end Poly_R410a_EEV_18;
Power - R134a - EEV - 1.5 mm. This model contains a calculation procedure for flow coefficients presented by Zhifang et al. (2008).<br/>
within AixLib.Fluid.Actuators.Valves.ExpansionValves.Utilities.FlowCoefficient.SpecifiedFlowCoefficients; model Power_R134a_EEV_15 "Power - R134a - EEV - 1.5 mm" extends PowerFlowCoefficient( final powMod=Types.PowerModels.ZhifangAndOu2008, final a=1.1868e-13, final b={-1.4347,3.6426}); end Power_R134a_EEV_15;
Types, constants to define menu choices
within AixLib.Fluid.Actuators.Valves.ExpansionValves.Utilities; package Types "Types, constants to define menu choices" extends Modelica.Icons.TypesPackage; // Types describing calculation procedures of mass flow and pressure drop // // Types describing calculation procedures of flow coefficients // end Types;
Collection of validation models
within AixLib.Fluid.Actuators.Valves; package Validation "Collection of validation models" extends Modelica.Icons.ExamplesPackage; end Validation;
Test model for parameterization of three-way valves
within AixLib.Fluid.Actuators.Valves.Validation; model ThreeWayValveParameterization "Test model for parameterization of three-way valves" extends Modelica.Icons.Example; package Medium = AixLib.Media.Water "Medium in the component"; parameter Modelica.Units.SI.MassFlowRate m_flow_nominal=0.4 "Design mass flow rate"; parameter Modelica.Units.SI.PressureDifference dp_nominal=4500 "Design pressure drop"; parameter Real Kv_SI = m_flow_nominal/sqrt(dp_nominal) "Flow coefficient for fully open valve in SI units, Kv=m_flow/sqrt(dp) [kg/s/(Pa)^(1/2)]"; parameter Real Kv = Kv_SI/(rhoStd/3600/sqrt(1E5)) "Kv (metric) flow coefficient [m3/h/(bar)^(1/2)]"; parameter Real Cv = Kv_SI/(rhoStd*0.0631/1000/sqrt(6895)) "Cv (US) flow coefficient [USG/min/(psi)^(1/2)]"; parameter Modelica.Units.SI.Area Av=Kv_SI/sqrt(rhoStd) "Av (metric) flow coefficient"; parameter Modelica.Units.SI.Density rhoStd=Medium.density_pTX( 101325, 273.15 + 4, Medium.X_default) "Standard density"; AixLib.Fluid.Actuators.Valves.ThreeWayEqualPercentageLinear valOPPoi( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, CvData=AixLib.Fluid.Types.CvTypes.OpPoint, dpValve_nominal(displayUnit="kPa") = 4500, use_inputFilter=false, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState) "Three way valve with operating point as parameter" AixLib.Fluid.Actuators.Valves.ThreeWayEqualPercentageLinear valKv( redeclare package Medium = Medium, CvData=AixLib.Fluid.Types.CvTypes.Kv, m_flow_nominal=m_flow_nominal, Kv=Kv, use_inputFilter=false, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState) "Three way valve with Kv-value as parameter" AixLib.Fluid.Actuators.Valves.ThreeWayEqualPercentageLinear valCv( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, CvData=AixLib.Fluid.Types.CvTypes.Cv, Cv=Cv, use_inputFilter=false, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState) "Three way valve with Cv-value as parameter" AixLib.Fluid.Actuators.Valves.ThreeWayEqualPercentageLinear valAv( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, Av=Av, use_inputFilter=false, CvData=AixLib.Fluid.Types.CvTypes.Av, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState) "Three way valve with Av-value as parameter" AixLib.Fluid.Sources.Boundary_pT sou1( redeclare package Medium = Medium, nPorts=4, use_p_in=false, p(displayUnit="Pa") = 300000 + 4500, T=293.15) "Boundary condition for flow source" AixLib.Fluid.Sources.Boundary_pT sin( redeclare package Medium = Medium, nPorts=4, use_p_in=false, p=300000, T=293.15) "Boundary condition for flow sink" Modelica.Blocks.Sources.Ramp y( duration=1, height=1, offset=0) "Control signal" AixLib.Fluid.Sensors.MassFlowRate senM_flowOpPoi( redeclare package Medium = Medium) "Mass flow rate sensor" AixLib.Fluid.Sensors.MassFlowRate senM_flowKv( redeclare package Medium = Medium) "Mass flow rate sensor" AixLib.Fluid.Sensors.MassFlowRate senM_flowCv( redeclare package Medium = Medium) "Mass flow rate sensor" AixLib.Fluid.Sensors.MassFlowRate senM_flowAv(redeclare package Medium = Medium) "Mass flow rate sensor" AixLib.Fluid.Sources.Boundary_pT sou3( redeclare package Medium = Medium, nPorts=4, use_p_in=false, p(displayUnit="Pa") = 300000 + 4500, T=293.15) "Boundary condition for flow source" equation connect(sou1.ports[1], valOPPoi.port_1) connect(sou1.ports[2], valKv.port_1) connect(sou1.ports[3], valCv.port_1) connect(sou1.ports[4], valAv.port_1) connect(sou3.ports[1], valOPPoi.port_3) connect(sou3.ports[2], valKv.port_3) connect(sou3.ports[3], valCv.port_3) connect(sou3.ports[4], valAv.port_3) connect(valOPPoi.port_2, senM_flowOpPoi.port_a) connect(valKv.port_2, senM_flowKv.port_a) connect(valCv.port_2, senM_flowCv.port_a) connect(valAv.port_2, senM_flowAv.port_a) connect(senM_flowOpPoi.port_b, sin.ports[1]) connect(senM_flowKv.port_b, sin.ports[2]) connect(senM_flowCv.port_b, sin.ports[3]) connect(senM_flowAv.port_b, sin.ports[4]) connect(y.y, valOPPoi.y) connect(y.y, valKv.y) connect(y.y, valCv.y) connect(y.y, valAv.y) end ThreeWayValveParameterization;
Model to test and illustrate different parameterization for valves
within AixLib.Fluid.Actuators.Valves.Validation; model TwoWayValveParameterization "Model to test and illustrate different parameterization for valves" extends Modelica.Icons.Example; package Medium = AixLib.Media.Water; parameter Modelica.Units.SI.MassFlowRate m_flow_nominal=0.4 "Design mass flow rate"; parameter Modelica.Units.SI.PressureDifference dp_nominal=4500 "Design pressure drop"; parameter Real Kv_SI = m_flow_nominal/sqrt(dp_nominal) "Flow coefficient for fully open valve in SI units, Kv=m_flow/sqrt(dp) [kg/s/(Pa)^(1/2)]"; parameter Real Kv = Kv_SI/(rhoStd/3600/sqrt(1E5)) "Kv (metric) flow coefficient [m3/h/(bar)^(1/2)]"; parameter Real Cv = Kv_SI/(rhoStd*0.0631/1000/sqrt(6895)) "Cv (US) flow coefficient [USG/min/(psi)^(1/2)]"; parameter Modelica.Units.SI.Area Av=Kv_SI/sqrt(rhoStd) "Av (metric) flow coefficient"; parameter Modelica.Units.SI.Density rhoStd=Medium.density_pTX( 101325, 273.15 + 4, Medium.X_default) "Standard density"; AixLib.Fluid.Actuators.Valves.TwoWayLinear valOPPoi( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, CvData=AixLib.Fluid.Types.CvTypes.OpPoint, dpValve_nominal(displayUnit="kPa") = dp_nominal, use_inputFilter=false) "Valve model, linear opening characteristics" Modelica.Blocks.Sources.Ramp y(duration=1) "Control signal" Valves.TwoWayLinear valKv( redeclare package Medium = Medium, CvData=AixLib.Fluid.Types.CvTypes.Kv, m_flow_nominal=m_flow_nominal, Kv=Kv, use_inputFilter=false) "Valve model, linear opening characteristics" Valves.TwoWayLinear valCv( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, CvData=AixLib.Fluid.Types.CvTypes.Cv, Cv=Cv, use_inputFilter=false) "Valve model, linear opening characteristics" AixLib.Fluid.Sources.Boundary_pT sou( redeclare package Medium = Medium, nPorts=4, p(displayUnit="Pa") = 300000 + 4500, T=293.15) "Boundary condition for flow source" AixLib.Fluid.Sources.Boundary_pT sin( redeclare package Medium = Medium, nPorts=4, use_p_in=false, p=300000, T=293.15) "Boundary condition for flow sink" AixLib.Fluid.Sensors.MassFlowRate senM_flowOpPoi( redeclare package Medium = Medium) "Mass flow rate sensor" AixLib.Fluid.Sensors.MassFlowRate senM_flowKv( redeclare package Medium = Medium) "Mass flow rate sensor" AixLib.Fluid.Sensors.MassFlowRate senM_flowCv( redeclare package Medium = Medium) "Mass flow rate sensor" Valves.TwoWayLinear valAv( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, use_inputFilter=false, CvData=AixLib.Fluid.Types.CvTypes.Av, Av=Av) "Valve model, linear opening characteristics" AixLib.Fluid.Sensors.MassFlowRate senM_flowAv(redeclare package Medium = Medium) "Mass flow rate sensor" equation connect(y.y, valOPPoi.y) connect(y.y, valKv.y) connect(valKv.port_a, sou.ports[2]) connect(sou.ports[3], valCv.port_a) connect(y.y, valCv.y) connect(sou.ports[1], valOPPoi.port_a) connect(valOPPoi.port_b, senM_flowOpPoi.port_a) connect(valKv.port_b, senM_flowKv.port_a) connect(valCv.port_b, senM_flowCv.port_a) connect(senM_flowCv.port_b, sin.ports[3]) connect(senM_flowKv.port_b, sin.ports[2]) connect(senM_flowOpPoi.port_b, sin.ports[1]) connect(sou.ports[4], valAv.port_a) connect(valAv.port_b, senM_flowAv.port_a) connect(senM_flowAv.port_b, sin.ports[4]) connect(valAv.y, y.y) end TwoWayValveParameterization;
Filter used for actuators of valves, dampers and movers. This block implements a filter that is used to approximate the actuators of valves, dampers and fans.
within AixLib.Fluid.BaseClasses; block ActuatorFilter "Filter used for actuators of valves, dampers and movers" import Modelica.Blocks.Types.Init; extends Modelica.Blocks.Interfaces.SISO; constant Integer n=2 "Order of filter"; parameter Modelica.Units.SI.Frequency f(start=1) "Cut-off frequency"; parameter Boolean normalized = true "= true, if amplitude at f_cut is 3 dB, otherwise unmodified filter"; parameter Modelica.Blocks.Types.Init initType=Modelica.Blocks.Types.Init.NoInit "Type of initialization (1: no init, 2: steady state, 3: initial state, 4: initial output)" parameter Real x_start[n]=zeros(n) "Initial or guess values of states" parameter Real y_start=0.0 "Initial value of output (remaining states are in steady state)" parameter Real u_nominal = 1 "Magnitude of input"; Real x[n](each final stateSelect=StateSelect.never) = u_nom*s "Transformed filter states"; protected final parameter Real u_nom = if abs(u_nominal-1) < 1E-12 then 1-1E-12 else u_nominal "Magnitude of input (set to a value different from 1 to avoid elimination by symbolic processing)"; parameter Real alpha=if normalized then sqrt(2^(1/n) - 1) else 1.0 "Frequency correction factor for normalized filter"; parameter Real w_u=2*Modelica.Constants.pi*f/alpha/u_nom; Real s[n](start=x_start/u_nom) "Filter states"; initial equation if initType == Init.SteadyState then der(s) = zeros(n); elseif initType == Init.InitialState then s = x_start/u_nom; elseif initType == Init.InitialOutput then y = y_start; der(s[1:n - 1]) = zeros(n - 1); end if; equation der(s[1]) = (u - u_nom*s[1])*w_u; for i in 2:n loop der(s[i]) = (u_nom*s[i - 1] - u_nom*s[i])*w_u; end for; y =u_nom*s[n]; end ActuatorFilter;