Reactors and Exchangers in Dynamics¶
In this tutorial you will open three dynamic samples shipped with DWSIM in the Classic UI, a CSTR, a PFR and a shell-and-tube heat exchanger, and read what their dynamic setup adds to the steady-state objects: a reaction holdup with a level, a heat exchanger with volumes and conductances on each side, and the duty as the knob that drives the run. The pages before this one built everything from scratch; this one is about reading a flowsheet someone else prepared, which is most of what a dynamic simulator is used for.
What you will learn
- Which dynamic properties a reactor and an exchanger carry (holdup volume, level, wall thermal mass, flow conductance, reset) and what each one does to the response
- How an input slider bound to an energy stream lets you move a duty while the integrator runs
- How to read a sample's Dynamics Manager before pressing Run: integrator, monitored variables, events and initial state
Prerequisites
- Completed Events, Schedules and States
- The reactors of Reaction Systems and the exchanger of Heat Exchanger Design
Process Overview¶
Three flowsheets from the Samples list, each already prepared for dynamic mode:
Dynamic Simulation - CSTR: methanol carbonylation to acetic acid (CH3OH + CO → CH3COOH, kinetic, Arrhenius) in a 100 m³ adiabatic CSTR at 28 bar, fed at 63 kg/s through a valve, with an energy stream of 3000 kW on an input slider. Monitored: acetic acid conversion and reactor temperature. Integrator 1 s, 10 min.Dynamic Simulation - PFR: ethylene oxide hydration to ethylene glycol in a 1 m³ adiabatic PFR (1.2 m long, 20 sections), 1000 kg/h of feed at 55 °C, energy stream on a slider, charts of the concentration and temperature profiles. Integrator 1 s, 10 min.Dynamic Simulation - Heat Exchanger: 0.008 kg/s of methane at 70 °C and 10 bar cooled by 0.1 kg/s of water at 25 °C in a rated shell-and-tube exchanger (46 m², U 223 W/m²K), four Kv valves, a PIDPID-01holding the gas outlet pressure at 8 atm through the gas outlet valve, an event setES1that steps the gas inlet temperature to 110, 140 and 180 °C at 1, 2 and 5 min, and a stored initial stateSt2. Monitored: the exchanger's hot and cold outlet temperatures. Integrator 1 s, 10 min.
Process Flow Diagram¶
graph LR
F["Feed<br/>63 kg/s, 35 bar"] --> V1["V-01<br/>Kv 615"]
V1 --> R["CSTR-01<br/>100 m³, adiabatic"]
E["e1<br/>3000 kW (slider)"] -.-> R
R --> V2["V-02<br/>Kv 616"]
V2 --> P["products"]
graph LR
GI["GAS IN<br/>70 °C, 10 bar"] --> V2["V-02"] --> HE["HE-012<br/>shell and tube<br/>46 m²"]
CI["CW IN<br/>25 °C, 3 bar"] --> V1["V-01"] --> HE
HE -->|gas| V3["V-03<br/>(PID-01)"] --> GO["GAS OUT<br/>4 bar"]
HE -->|water| V4["V-04"] --> CO["CW OUT"]
Key Design Parameters¶
| Sample | Holdup and dynamics | Knob | Monitored |
|---|---|---|---|
| CSTR | Volume 100 m³, height 1 m, adiabatic, initialise from inlet, reset contents | e1 duty (slider IN-009) | acetic acid conversion (%), reactor temperature (°C) |
| PFR | Volume 1 m³, 20 sections, adiabatic, reset contents | Energy duty (slider IN-009) | concentration and temperature profiles (charts) |
| Heat exchanger | 0.05 m³ per side, flow conductance 0.01 per side, initialise from inlets, minimum pressure 1 atm | GAS IN temperature (events), sliders on the two inlet flows | hot and cold outlet temperatures (°C), hot and cold side pressures (gauges) |
Step-by-Step in the Classic UI¶
1. Open the CSTR sample and read its Dynamics tab¶
File > Samples, Dynamic Simulation - CSTR. Double-click CSTR-01, tab Dynamics. Besides the 100 m³ of volume it has a Height, a Liquid Level (the holdup is a level, the vapour space above it is the rest of the volume), an Operating Pressure, a Minimum Pressure, Initialize using Inlet Stream and Reset Contents. A reactor in dynamic mode is a vessel that reacts: the level and the pressure come from the mass and energy balances of the holdup, and the reaction rate from the holdup's composition and temperature.
2. Run it and move the duty¶
Integrator Controls, Sch1, Run. The reaction is exothermic and the reactor adiabatic: in ten minutes the temperature climbs from 55.9 to 71.0 °C and the acetic acid conversion settles near 1.05 %. Drag the slider IN-009 (bound to the energy stream e1) while the run is going, or between runs. From 3000 to 6000 kW the temperature climbs another 16 K, to 87.0 °C, while the conversion rises only during the climb (1.49 % at 2 min) and is back at 1.06 % at 10 min: in this sample the duty moves the temperature far more than the conversion. The chart CHART1 draws both monitored variables against time.

3. Open the PFR sample¶
Dynamic Simulation - PFR. Double-click PFR-001, tab Dynamics: Reset Contents and Max Sections (20). A tubular reactor in dynamic mode is a chain of small holdups, one per section; the concentration and temperature profiles along the tube are what the two charts draw. Run Sch1: the outlet stays at the steady-state temperature, because the resting profile is the steady state. Move the energy slider: the profiles shift, and the outlet temperature follows in a ramp that lasts one residence time (about four minutes at the design flow), because the contents advance one section every residence time over the number of sections and the duty is spread over the sections as heat.
4. Open the heat exchanger sample¶
Dynamic Simulation - Heat Exchanger. Double-click HE-012, tab Dynamics: Volume for Hot Fluid and Volume for Cold Fluid (0.05 m³ each), Hot Fluid Flow Conductance and Cold Fluid Flow Conductance (0.01 each), Hot Side Pressure and Cold Side Pressure, Initialize using Inlet Streams. Each side of the exchanger is a holdup with its own pressure; the conductance is what turns the pressure difference between inlet and outlet into a flow, the exchanger's own Kv. On the main tab the exchanger is in Shell and Tube Rating mode with its geometry, so the U of 223 W/m²K is computed, and the run recomputes it as flows change.
Wall thermal mass
Heaters, coolers and exchangers carry two more dynamic properties, Wall Thermal Mass (J/K) and Wall Temperature. At zero the outlet temperature follows the duty at once; with a real value (a few hundred kilojoules per kelvin for a small shell-and-tube unit) the metal has to warm up first, and the outlet lags the duty by a time constant of the wall mass over the product of flow and heat capacity. Leave it at zero to see the process without the metal, set it to see the equipment.
5. Read the loop and the events¶
PID-01 holds the pressure of MSTR-002, the hot outlet stream, at 8 atm by moving V-03; it is reverse acting with Kp 10, Ki 2 and Kd 2. The event set ES1 steps GAS IN temperature to 110 °C at 1 min, 140 °C at 2 min and 180 °C at 5 min. The schedule Sch1 starts from the stored state St2.
6. Run it¶
Integrator Controls, Sch1, Run: ten minutes at 1 s. The monitored HotTemp and ColdTemp are the gas and water outlet temperatures; the gauges PI-01 and PI-02 show the two side pressures. As the gas comes in hotter, the gas outlet rises with it and the water outlet rises a little, the exchanger's U changes with the gas properties, and PID-01 moves V-03 to keep the hot side at 8 atm.
Results and Validation¶
| Sample | What to watch | Direction |
|---|---|---|
CSTR, more duty on e1 |
reactor temperature and acetic acid conversion | both rise; the temperature rise across the reactor grows |
| CSTR, duty to zero | temperature | settles at the adiabatic value set by the feed and the reaction heat |
| PFR, more duty | temperature profile along the tube, outlet temperature | profile shifts up; the outlet ramps up over about one residence time |
| Heat exchanger, GAS IN steps | gas outlet temperature, V-03 opening | outlet follows each step within a minute; V-03 moves to hold 8 atm |
Expected results
These samples are read qualitatively: their numbers depend on the slider positions and on where the run is stopped. The checks that matter are the shape of each response, the delay of the PFR outlet behind its duty, and the pressure loop of the exchanger holding 8 atm through the temperature steps.
Understanding the Results¶
A reactor in dynamic mode differs from its steady-state self in one thing: it has an inventory. The steady-state CSTR finds the composition that makes the reaction rate match the throughput; the dynamic CSTR starts from whatever is in the vessel and moves toward that composition at the rate the inventory allows, which is the residence time. The PFR does the same section by section, and its outlet answers a change at the inlet only after the change has travelled the tube. The exchanger has two small inventories and a wall; its temperatures answer in seconds, its pressures in a fraction of a second, and it is the pressures that the flow conductances and the outlet valves have to hold sensible.
Reading a prepared flowsheet is a skill of its own. Before pressing Run: which streams are the boundaries and what they hold; which objects have a volume and what level they start at; which schedule is current, which state it restores, which events it carries; which variables are monitored. Ten minutes on the Dynamics Manager save an hour of wondering what a chart is showing.
Reset Contents
Every holdup has a Reset Contents flag: at the next run step the holdup is discarded and built again as on a first run (see Initialize using Inlet Stream); the PFR builds its section contents again from the inlet stream. A run from the current state honours it once and clears it; a run from a stored state follows the flag the state stored. Use it when a previous run left a vessel in a state you do not want to carry forward.
Automating This Tutorial¶
Files in this repository
- Python script:
examples/dynamics/05_run_reactor_samples.py - In DWSIM: Samples list on the welcome screen,
Dynamic Simulation - CSTR,Dynamic Simulation - PFRandDynamic Simulation - Heat Exchanger
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, Q
# the samples ship in the "samples" folder of the DWSIM installation; DWSIM_SAMPLES overrides it
samples = os.environ.get("DWSIM_SAMPLES", os.path.join(DWSIM_BIN, "samples"))
# the heat exchanger sample: run its schedule from the stored state St2
fs = Flowsheet.Load(os.path.join(samples, "Dynamic Simulation - Heat Exchanger.dwxmz"))
result = fs.RunDynamics("Sch1").Execute()
print(result.Completed, result.Steps)
for name in ("HotTemp", "ColdTemp"):
s = result.GetSeries(name)
print(f"{name}: start {s.Initial:.1f} C, end {s.Final:.1f} C, min {s.Min:.1f}, max {s.Max:.1f}")
# the CSTR sample: run as it ships, then again with a duty step scheduled as an event
fs = Flowsheet.Load(os.path.join(samples, "Dynamic Simulation - CSTR.dwxmz"))
fs.Solve()
base = fs.RunDynamics("Sch1").FromCurrentState(True).Execute()
print("base run:", base.Completed, base.GetSeries("Temperature").Final)
fs.Dynamics.WithHistorian(True, 5000)
fs.Dynamics.StoreCurrentStateAs("Base")
(fs.Dynamics.DefineEventSet("Duty")
.AddStepChange("e1", "PROP_ES_0", 6000.0, Q.Seconds(120.0), "kW", "duty step"))
(fs.Dynamics.DefineSchedule("DutyStep").WithIntegrator("Int1")
.WithEventSet("Duty").WithInitialState("Base").MakeCurrent())
r = fs.RunDynamics("DutyStep").Execute()
print("duty step:", r.Completed, r.GetSeries("Temperature").Final, r.GetSeries("Acetic Acid Conversion").Final)
Open each sample with dwsim.flowsheet.open, list its schedules and monitored variables with the dwsim.dynamics.* tools, run the schedule and read the series; change the duty with dwsim.unitop.set on the energy stream between runs.
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.
Open the DWSIM sample "Dynamic Simulation - Heat Exchanger" via the MCP server.
List its integrators, schedules, event sets, stored states and monitored variables.
Run the schedule "Sch1" and report the hot and cold outlet temperatures at the start,
at 1.5, 3 and 6 minutes, and at the end, together with the V-03 opening at the same
times. Then explain which event set entry caused each change.
Exercises
- In the CSTR sample, set the duty to zero and run. Where does the temperature settle, and what does that say about the adiabatic temperature rise of the reaction at this conversion?
- In the heat exchanger sample, set the Wall Thermal Mass of HE-012 to 500 kJ/K and rerun
Sch1. How much later does the gas outlet answer each temperature step? - In the PFR sample, halve the feed flow with the slider and run. How does the delay between a duty change and the outlet temperature change?
Further Reading¶
Selected references from the DWSIM technical bibliography.
- H. S. Fogler. (2016). Elements of Chemical Reaction Engineering. Pearson
- W. L. Luyben. (2007). Chemical Reactor Design and Control. Wiley
Next Steps¶
In Custom Controllers and Networks, a controller written in Python replaces the PID on the tank, and a district water network holds a tank level through a pressure-reducing valve.