Valve Example
Drag-in Components | Define Ramp Parameters |
Define Tank Parameters | Connect and Simulate |
Define Valve Parameters | Analyze |
In this part, you will use a valve to control the flow between two tanks.
Model to check the flow between tanks that are connected by a valve.
Drag-in Components
Create a new model and drag the following components from the Modelica standard library:
- System: Used to define system properties and default values so that you do not need to define it for every component
Define the parameters of the tank (the same parameters will be used for both tanks. Only the initial value of the fluid will be different):
Define Tank Parameters
The same parameters will be used for both tanks. Only the initial value of the level of the fluid will be different.
height: Total height of the tank. Change level_start (in the Initialization tab) of tank1 to 10 m and tank2 to 1 m.
crossArea: Define cross-sectional area of the tank.
Medium (This parameter cannot be left blank.) Select a fluid from the drop-down menu, e.g. “Extension of the StandardWater package.”
Ports: This refers to the outlet of the tank to which other components can be connected.
nPorts: In this example, as you want to connect only to the ambient, set the nPorts to 1.
use_portsData: Set use_portsData to true.
portsData: Provide the portsData as a list, which means they need to be specified using curly braces {}. It takes a function as an argument. The function is Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(). You can open the function (type Modelica.Fluid.Vessels.BaseClasses.VesselPortsData in the search field in the Class Browser) and check the inputs:
You can define diameter, height and other parameters. For this example, set the port height to 1 m and diameter to 0.3 m. Use the defaults for zeta_out and zeta_in. The input to the portsData should look like this: {Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter=0.3,height=1)}
Define Valve Parameters
Medium: Select a fluid from the drop-down menu, e.g. “Extension of the StandardWater package.”
valveCharacteristic: Choose a valve characteristic. Using the default setting (linear) should work for most cases.
CvData:Use a flow coefficient for the valve. Cv (US) flow coefficient is typically used.
Cv: Set the Cv value. For a ball valve of size 10 inch (150 rating), Cv value is 15771.
dp_nominal:Set nominal pressure drop across the valve.
m_flow_nominal: Set nominal mass flow rate through the valve.
filteredOpening: Set it to true to improve the numerics.
Define Ramp Parameters
height: Here, height is used as the normalized opening value of the valve. Set the height of the ramp.
duration: Set the duration for the ramp to reach the desired height from its initial value.
Connect and Simulate
Connect the ports of the tanks and the ramp to the valve:
Provide a simulation time in the Experiment Setup and simulate:
Analyze
Plot the mass flow rate through the valve and the levels of the tank. Mass flow rate through the valve can be plotted using the following variable: valveIncompressible1.m_flow.
Flow of water starts at two seconds when the ramp signal starts. Water flows from tank with higher height (tank 1) to the tank with lower height (tank 2).