Transient process simulation patterns from tests
Dynamic process behavior in NeqSim is validated through ProcessSystemRunTransientTest, which assembles streams, valves, separators, transmitters, and controllers before stepping a transient solver. Reusing the tested scaffolding ensures that custom flowsheets converge and maintain synchronized calculation identifiers across unit operations.
Minimal transient loop with flow control
The first scenario creates a single feed stream, lets it down through a valve into a separator, and attaches a flow controller to the inlet valve based on a volume-flow transmitter.【F:src/test/java/neqsim/process/processmodel/ProcessSystemRunTransientTest.java†L58-L120】 Key steps reproduced below:
- Build a thermodynamic system with SRK EOS and set a mixing rule.
- Define a
Stream, set mass flow and pressure, and connect it to aThrottlingValvewith a target outlet pressure. - Route the valve outlet to a
Separator, configure geometry (diameter, length) and initial liquid level. - Add downstream valves for gas and liquid outlets to define back-pressure targets.
- Attach a
VolumeFlowTransmitterto the inlet stream, wire it to aControllerDeviceBaseClass, and assign the controller to the inlet valve. - Run a steady-state initialization (
p.run()), choose a transient timestep, and iteraterunTransient()to observe controller action converging toward the setpoint (73.5 kg/hr in the test).
The assertions in the test check that every unit operation shares the same calculation identifier during the loop and that the transmitter stabilizes near the requested flow, confirming correct coupling of controller logic and transport equations.【F:src/test/java/neqsim/process/processmodel/ProcessSystemRunTransientTest.java†L106-L120】 Use this template when debugging control loops or valve responses in your own cases.
Level- and pressure-controlled separator case
A second scenario adds a purge stream to the separator, introduces level and pressure transmitters, and binds each to a dedicated controller that manipulates the liquid and gas outlet valves respectively.【F:src/test/java/neqsim/process/processmodel/ProcessSystemRunTransientTest.java†L122-L232】 After a steady-state start, the process is marched forward with a 10-second timestep and the level transmitter reading is checked against the 0.45 m setpoint, demonstrating how controller gains drive the separator toward balanced holdup.
When replicating this pattern:
- Set transmitter bounds (
setMaximumValue,setMinimumValue) to guard against unrealistic signals. - Apply
setCalculateSteadyState(false)on dynamic equipment to ensure the transient integrator, not a steady solver, advances the state. - Verify calculation identifiers after each
runTransient()to confirm that all equipment is synchronized before trusting control trajectories.
Why calculation identifiers matter
Throughout the transient loops the test asserts that each unit operation’s getCalculationIdentifier() matches the process system’s identifier.【F:src/test/java/neqsim/process/processmodel/ProcessSystemRunTransientTest.java†L114-L118】【F:src/test/java/neqsim/process/processmodel/ProcessSystemRunTransientTest.java†L221-L229】 This guards against stale states or partial updates when complex equipment is added. If you see divergence, reinitialize the process system or inspect units for disabled steady-state flags.