Part 4—Valve Example
Part 4—Valve Example
This is part 4 of a 5 part series on modeling a fluid circuit using the Modelica Fluid library. Please go through the previous part, if you have not done it already:
In this post, I will use a valve to control the flow between two tanks.
Model to check the flow between tanks that are connected by a valve.
Steps
Steps
◼
Create a new model
◼
Drag the following components from the Modelica standard library:
◼
Fluid.Vessels.OpenTank: 2 num
◼
Blocks.Sources.Ramp
◼
Fluid.Valves.ValveIncompressible
◼
Fluid.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 (we will use the same parameters for both the tanks. Only the initial value of the fluid will be different):
◼
Medium (This parameter cannot be left blank)
◼
Select a fluid from the drop-down. Eg: “Extension of the standard water package”
◼
height
◼
Total height of the tank
◼
Change level_start (in the Initialization tab) of tank 1 to 10 m and tank 2 to 1 m.
◼
crossArea
◼
Define cross sectional area of the tank
◼
Ports (Important) : This refers to the outlet of the tank to which other components can be connected
◼
nPorts
◼
In this example as we want to connect only to the valve so we will 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 the name in the search field in the Class Browser) and check the inputs
◼
You can define diameter, height and other parameters
◼
For our example we want to set the port height to 1 m and diameter to 0.3 m. We will 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 the parameters of the valve:
◼
Medium
◼
Select a fluid from the drop-down. Eg: “Extension of the standard water package”
◼
valveCharacteristic
◼
Choose a valve characteristics. 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
◼
Eg: for a ball vale of size 10 inch (150 rating) Cv value is 15771 (Ref: https://www.piping-world.com/cv-flow-coefficients-of-ball-valve )
◼
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 the parameters of the valveOpening ramp:
◼
startTime
◼
Set start time
◼
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
◼
Define the parameters of the system:
◼
under the Assumptions tab
◼
Set massDynamics to FixedInitial (this priorities the use of the initial values as we want our tanks to start from their initial levels)
◼
Connect the ports of the tanks and the ramp to the valve:
◼
Provide a simulation time in the Experiment Setup and simulate:
◼
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: valve.m_flow
◼
Flow of water starts at 2 seconds when the ramp signal starts. Water flows from tank with higher height (tank 1) to the tank with lower height (tank 2).
In this post, we saw how to instantiate a valve and used it to model flow between tanks. In the final post, model filling of a tank using a pipe that heats the fluid flowing through it.
Other posts in this series can be found here: