Wolfram Computation Meets Knowledge

Valve Example

Drag-in ComponentsDefine System Parameters
Define Tank ParametersConnect and Simulate
Define Valve ParametersAnalyze
Define Ramp Parameters

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:

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.

Medium (This parameter cannot be left blank.) Select a fluid from the drop-down menu, e.g. Extension of the standard water package.

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.

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 valve, 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 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 standard water 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

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 System Parameters

Under the Assumptions tab, set massDynamics to FixedInitial (this prioritizes the use of the initial values, as you want the tanks to start from their initial levels).


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:



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).