Skip to content

From Steady State to Dynamic

In this tutorial you will take a small water system, a tank between two valves, from a solved steady state to a dynamic run in DWSIM's Classic UI. The level in the tank rises, the outlet flow follows it, and after a few minutes the two balance. Every dynamic simulation in DWSIM starts the way this one does: a converged flowsheet, a holdup with a volume, valves that turn pressure into flow, boundary streams with a pressure or a flow specification, and a schedule that tells the integrator how long to run.

What you will learn

  • What changes when Dynamic Mode is on: holdups set pressures, valves set flows, boundary streams keep a pressure or a flow
  • How to give a tank a volume and a height, a valve a Kv, and a stream a Dynamics specification
  • How to create an integrator, a schedule and monitored variables in the Dynamics Manager, run the schedule from Integrator Controls and read the results in the spreadsheet

Prerequisites

  • Completed Heater and Cooler or any steady-state tutorial: you should be comfortable creating streams and unit operations
  • The idea of a mass balance with accumulation: what comes in and does not go out stays in the tank

Process Overview

A water supply at 1.3 bar feeds a tank through a valve; the tank drains through a second valve to a line at atmospheric pressure:

  1. Inlet delivers 10 kg/s of water, fixed by a Flow specification
  2. V-01 is the inlet valve, with a fixed Kv of 100 and 50 % opening
  3. T-01 is an open tank of 2 m³ and 2 m height
  4. V-02 is the outlet valve, Kv 400 at full opening, half open
  5. Outlet is held at 1 atm by a Pressure specification

In steady state the tank has no level: it just passes 10 kg/s along. In dynamic mode the level is the state variable of the system, and it settles where the head of liquid pushes exactly 10 kg/s through V-02.

Process Flow Diagram

graph LR
    IN["Inlet<br/>25 °C, 1.3 bar<br/>10 kg/s Water<br/>(Flow spec)"] --> V1["V-01<br/>Kv 100, 50 %"]
    V1 --> T["T-01<br/>(Tank)<br/>2 m³, 2 m"]
    T --> V2["V-02<br/>Kv 400, 50 %"]
    V2 --> OUT["Outlet<br/>1 atm<br/>(Pressure spec)"]

Key Design Parameters

Parameter Value Unit
Compound Water -
Property Package Steam Tables (IAPWS-IF97) -
Inlet temperature 298.15 (25 °C) K
Inlet pressure 130000 (1.3 bar) Pa
Inlet mass flow 10 kg/s
V-01 Kv (fixed), opening 100, 50 m³/h, %
Tank volume, height 2, 2 m³, m
V-02 Kv (at 100 %), opening 400, 50 m³/h, %
Outlet pressure 101325 Pa
Integration step, duration 5, 10 s, min

Step-by-Step in the Classic UI

1. Set up the simulation

File > New Chemical Process Model:

  • Compounds: Water
  • Property Package: Steam Tables (IAPWS-IF97)
  • Click Finish

2. Create the streams and units

Drag four Material Streams to the canvas and name them Inlet, S-1, S-2 and Outlet. Set Inlet to T = 298.15 K, P = 130000 Pa, Mass Flow = 10 kg/s, Water = 1.0. Leave the other three empty.

Drag two Valves and one Tank from the Object Palette and rename them V-01, T-01 and V-02. Connect them in the order Inlet → V-01 → S-1 → T-01 → S-2 → V-02 → Outlet.

3. Configure the valves

Open V-01:

  • Calculation Type: Liquid Service Kv/Cv (Deprecated), the liquid Kv mode this page was measured with
  • Kv[Cv](max) (IEC 60534): 100, with Kv selected
  • Valve Opening (%): 50
  • Leave Use Opening (%) versus Kv[Cv]/Kv[Cv]max (%) relationship unticked: this valve passes its full Kv whatever its opening

Open V-02:

  • Calculation Type: Liquid Service Kv/Cv (Deprecated)
  • Kv[Cv](max) (IEC 60534): 400, with Kv selected
  • Use Opening (%) versus Kv[Cv]/Kv[Cv]max (%) relationship: ticked, with Opening/Kv[Cv] rel. type = Linear
  • Valve Opening (%): 50

Why Kv and not a pressure drop

In dynamic mode a valve is the only object that turns a pressure difference into a flow. A valve in pressure-drop mode needs a flow told to it from outside; a valve in Kv mode works the flow out from the pressures on its two sides, which is what a real valve does. Put every valve that will run in dynamic mode in one of the Kv modes.

4. Solve the steady state

Press Solve (F5). The valves compute their outlet pressures from the Kv equation: S-1 and S-2 come out at about 1.17 bar and the Outlet at about 1.14 bar. The tank passes the flow through. This steady state is the starting point of every dynamic run, and it has to converge before anything else is done.

The solved steady state

5. Turn Dynamic Mode on

Dynamics > Dynamic Mode Active, or the Dynamic Mode Active/Inactive button in the Dynamics Solver group of the flowsheet toolbar. From now on, opening an object that has dynamic properties also opens a second panel, Dynamic Mode Properties, docked beside its editor, and objects that cannot run in dynamic mode show an exclamation icon.

6. Give the tank a volume and a height

Open T-01. In its editor:

  • Volume: 2 m³

In its Dynamic Mode Properties panel:

  • Height: 2 m
  • Initialize using Inlet Stream: leave unticked
  • Reset Content: leave unticked

The tank starts a run empty and fills from the inlet. Its cross-section is volume over height, 1 m², so every 997 kg of water in it is one metre of level.

Tank dynamic properties

7. Specify the boundary streams

Open Inlet and, under Stream Conditions, set Dynamic P/F Spec = Flow. Open Outlet, set Dynamic P/F Spec = Pressure and its pressure to 101325 Pa.

Pressure or Flow

Every stream that enters or leaves the flowsheet needs one of the two. Flow means the stream brings a fixed mass flow whatever the pressure downstream; Pressure means the stream holds a fixed pressure and takes whatever flow arrives. A feed pump or a compressor discharge is a Flow boundary; a header, a flare or the atmosphere is a Pressure boundary. Inside the flowsheet the streams need no specification: the holdups set their pressures and the valves set their flows.

8. Create the integrator and the schedule

Dynamics > Dynamics Manager:

  • Integrators: add Int1 with Integration Step (ms) = 5000 and Duration = 10 min. Under Monitored Variables, add T-01 Liquid Level (m), V-02 Opening (%) and Outlet Mass Flow (kg/s).
  • Schedules: add Sch1, choose Int1 as its Associated Integrator, tick Use Current State and tick Reset/Empty Contents of All Volume-Defined Objects Before Running. Every run of Sch1 then starts from an empty tank with the settings the flowsheet has at that moment, which is what the exercises at the end of the page need.

The Dynamics Manager

9. Run the schedule

Dynamics > Integrator Controls: pick Sch1 in the Schedule box and press Run Schedule. The clock advances 5 s per step; the run takes a few seconds. When it stops, press View Results: a new spreadsheet tab holds the monitored variables against time.

10. Read the results

The level starts near zero (the first sample reads 0.01 m) and climbs: 0.23 m at 1 min, 0.30 m at 2 min, 0.32 m at 3 min, and 0.333 m from 7 min on. The outlet flow follows the level: 8.4 kg/s at 1 min, 9.4 kg/s at 2 min, 10.0 kg/s at the end. The opening of V-02 stays at 50 %: nothing moves it yet.

Level and outlet flow against time

Results and Validation

Variable Expected Unit
Level at 1 min 0.23 m
Level at 2 min 0.30 m
Final level (from 7 min) 0.333 m
Outlet flow at 1 min 8.4 kg/s
Final outlet flow 10.0 kg/s
Tank pressure 101325 (open tank) Pa

Expected results

The level settles where the head of liquid drives exactly the inlet flow through V-02. Half open, V-02 has Kv = 200 m³/h; 10 kg/s is 36 m³/h; the Kv equation gives ΔP = (36/200)² = 0.032 bar, and 3.2 kPa of water is 0.33 m. The simulator lands on 0.333 m.

Understanding the Results

The tank is the only object with a state. Its mass balance is dm/dt = w_in − w_out: the inlet is fixed at 10 kg/s by its specification, and the outlet is what V-02 passes under the pressure difference between the tank bottom (atmospheric pressure plus the liquid head) and the Outlet at 1 atm. When the tank is empty the head is zero, nothing leaves, and the level rises fastest. As the level rises the head grows, the outlet flow grows with the square root of the head, and the level slows down until the two flows match. The approach is exponential: the level is within 1 % of its final value after about four and a half minutes.

Three things decided that number, and none of them was the inlet valve. The inlet is a Flow boundary, so 10 kg/s comes in whatever V-01 does; the tank is open, so its pressure is atmospheric; and the outlet is a Pressure boundary at 1 atm, so all the driving force across V-02 is the head. Change the Outlet to 1.2 bar and nothing leaves until the head alone makes up the 0.19 bar between the atmosphere and the Outlet, about 1.9 m of water; 10 kg/s through V-02 then needs 2.24 m of level, above the 2 m top of the tank. A real open tank would overflow at 2 m. DWSIM's tank has no overflow: when the level passes the tank height it writes one warning to the log ("T-01: the liquid level (2.01 m) is above the tank height (2.00 m). The tank has no overflow in this model: the excess stays inside and the level goes on rising.") and the level settles at 2.24 m. Change V-02 to 100 % open and the level settles at 0.08 m.

The Dynamics Wizard

Dynamics > Dynamics Wizard walks a solved steady-state flowsheet through the same list you just did by hand: a volume for every holdup, a Kv for every valve, a specification on every boundary stream, and an integrator with a schedule, each with a proposed value that you confirm or edit. It is the fast way through steps 5 to 8 on a larger flowsheet. Doing them by hand once, as here, is what makes the wizard's proposals readable.

Automating This Tutorial

Files in this repository

import os
import sys

import pythonnet
pythonnet.load("netfx")              # DWSIM is a .NET Framework application
import clr  # noqa: E402

DWSIM_BIN = os.environ.get("DWSIM_BIN")
if not DWSIM_BIN:
    raise SystemExit("Set DWSIM_BIN to the DWSIM installation folder before running.")
for sub in ("", "unitops", "ppacks", "extenders"):
    sys.path.append(os.path.join(DWSIM_BIN, sub))
clr.AddReference("DWSIM.Automation")
clr.AddReference("DWSIM.Automation.FluentAPI")
clr.AddReference("DWSIM.UnitOperations")

from DWSIM.Automation.FluentAPI import Flowsheet, PropertyPackages, Q
from DWSIM.UnitOperations.UnitOperations import Valve
from System import TimeSpan

fs = (Flowsheet.Create("WaterTankDynamic")
      .WithCompound("Water")
      .WithPropertyPackage(PropertyPackages.SteamTables))

inlet = (fs.AddMaterialStream("Inlet")
         .At(Q.Kelvin(298.15), Q.Pascal(130000.0))
         .WithMassFlow(Q.KgPerSecond(10.0))
         .AsFlowSpec())
s1 = fs.AddMaterialStream("S-1").AsPressureSpec()
s2 = fs.AddMaterialStream("S-2").AsPressureSpec()
outlet = fs.AddMaterialStream("Outlet").AsPressureSpec()

(fs.AddValve("V-01")
   .WithCalcMode(Valve.CalculationMode.Kv_Liquid)
   .WithKv(100.0).WithOpeningPercent(50.0)
   .ConnectFeed(inlet, 0).ConnectProduct(s1, 0))

tank = (fs.AddTank("T-01")
        .WithVolume(Q.CubicMeters(2.0)).WithHeight(Q.Meters(2.0))
        .ConnectFeed(s1, 0).ConnectProduct(s2, 0))

(fs.AddValve("V-02")
   .WithCalcMode(Valve.CalculationMode.Kv_Liquid)
   .WithKv(400.0).WithOpeningKvRelationship()
   .WithOpeningPercent(50.0)
   .ConnectFeed(s2, 0).ConnectProduct(outlet, 0))

fs.AutoLayout()
fs.Solve()

# the boundary pressure: set it after the steady state, which overwrote it
outlet.Object.Phases[0].Properties.pressure = 101325.0

(fs.Dynamics.DefineIntegrator("Int1")
   .WithIntegrationStep(TimeSpan.FromSeconds(5))
   .WithDuration(TimeSpan.FromMinutes(10))
   .Monitor("T-01", "Liquid Level", "m", "level")
   .Monitor("V-02", "PROP_VA_5", "", "V-02 opening")
   .Monitor("Outlet", "PROP_MS_2", "kg/s", "outlet flow"))
fs.Dynamics.DefineSchedule("Sch1").WithIntegrator("Int1").UseCurrentStateAsInitial(True).MakeCurrent()

result = fs.RunDynamics("Sch1").Execute()
level = result.GetSeries("level")
print(f"level at 1 min = {level.ValueAt(60.0):.3f} m, final = {level.Final:.3f} m")
print(f"outlet flow final = {result.GetSeries('outlet flow').Final:.2f} kg/s")
fs.Save("dynamic_tank_open_loop.dwxmz")

Build the flowsheet with dwsim.unitop.add and dwsim.unitop.connect, solve with dwsim.solve.run, then use the dynamics tools (dwsim.dynamics.*) to define the integrator and schedule and run it.

Output may vary

Results depend on the LLM's reasoning quality and tool-use accuracy. Always verify the simulation matches your intent before relying on the numbers.

Use DWSIM (via the MCP server) to build and run the following dynamic simulation:

- Create a flowsheet called "WaterTankDynamic" with Water and the Steam Tables package
- Material stream "Inlet" at 298.15 K, 130000 Pa, 10 kg/s of water, dynamics
  specification Flow; empty streams "S-1", "S-2" and "Outlet" (Outlet: dynamics
  specification Pressure, 101325 Pa)
- Valve "V-01" in liquid Kv mode, Kv 100, 50 % open, no opening/Kv relationship,
  from Inlet to S-1
- Tank "T-01" with volume 2 m3 and height 2 m, from S-1 to S-2
- Valve "V-02" in liquid Kv mode, Kv 400 with a linear opening/Kv relationship,
  50 % open, from S-2 to Outlet
- Solve the steady state
- Define an integrator "Int1" (step 5 s, duration 10 min) monitoring the tank
  liquid level, the V-02 opening and the Outlet mass flow, and a schedule "Sch1"
  that uses it from the current state
- Run the schedule and report the level at 1, 2 and 10 minutes and the final
  outlet mass flow

Exercises

  1. Set the Outlet pressure to 1.2 bar and run again. Where does the level go, and why? Read the log when the level passes 2 m: what would a real open tank do at that moment, and what does DWSIM's tank do?
  2. Open V-02 fully. Predict the final level from the Kv equation before running, then compare.
  3. Change the integration step to 30 s. Does the final level change? Does the shape of the curve?

Further Reading

Selected references from the DWSIM technical bibliography. Click the DOI link to access each paper.

  • W. L. Luyben. (1990). Process Modeling, Simulation and Control for Chemical Engineers. McGraw-Hill
  • D. E. Seborg, T. F. Edgar, D. A. Mellichamp & F. J. Doyle. (2016). Process Dynamics and Control. Wiley

Next Steps

In PID Level Control, you will add a PID controller that moves V-02 to hold the level at a setpoint, and see what proportional and integral action each do.