Class DynamicProcessHelper

java.lang.Object
neqsim.process.util.DynamicProcessHelper

public class DynamicProcessHelper extends Object
Helper that converts a sized steady-state ProcessSystem into a dynamic simulation by auto-creating transmitters and PID controllers with sensible defaults. The generated instruments and controllers are added to the process and wired to the appropriate equipment.

Typical usage:

// 1. Build and run steady-state process
ProcessSystem process = new ProcessSystem();
process.add(feed);
process.add(valve);
process.add(separator);
process.add(gasValve);
process.add(liqValve);
process.run();

// 2. Convert to dynamic in one call
DynamicProcessHelper helper = new DynamicProcessHelper(process);
helper.setDefaultTimeStep(1.0);
helper.instrumentAndControl();

// 3. Run transient loop
for (int i = 0; i < 600; i++) {
  process.runTransient();
}
Version:
1.0
Author:
NeqSim
  • Field Details

    • process

      private final ProcessSystem process
    • defaultTimeStep

      private double defaultTimeStep
    • pressureKp

      private double pressureKp
      Default PID proportional gain for pressure controllers.
    • pressureTi

      private double pressureTi
      Default PID integral time (seconds) for pressure controllers.
    • levelKp

      private double levelKp
      Default PID proportional gain for level controllers.
    • levelTi

      private double levelTi
      Default PID integral time (seconds) for level controllers.
    • flowKp

      private double flowKp
      Default PID proportional gain for flow controllers.
    • flowTi

      private double flowTi
      Default PID integral time (seconds) for flow controllers.
    • temperatureKp

      private double temperatureKp
      Default PID proportional gain for temperature controllers.
    • temperatureTi

      private double temperatureTi
      Default PID integral time (seconds) for temperature controllers.
    • transmitters

      private final Map<String, MeasurementDeviceInterface> transmitters
      Generated transmitters keyed by tag name.
    • controllers

      private final Map<String, ControllerDeviceInterface> controllers
      Generated controllers keyed by tag name.
  • Constructor Details

    • DynamicProcessHelper

      public DynamicProcessHelper(ProcessSystem process)
      Creates a helper for the given process system.
      Parameters:
      process - a ProcessSystem that has been run in steady-state with sized equipment
  • Method Details

    • setDefaultTimeStep

      public void setDefaultTimeStep(double dt)
      Sets the transient time step in seconds (default 1.0).
      Parameters:
      dt - time step in seconds (must be positive)
    • getDefaultTimeStep

      public double getDefaultTimeStep()
      Gets the default time step.
      Returns:
      time step in seconds
    • setPressureTuning

      public void setPressureTuning(double kp, double ti)
      Sets PID tuning parameters for pressure controllers.
      Parameters:
      kp - proportional gain
      ti - integral time in seconds
    • setLevelTuning

      public void setLevelTuning(double kp, double ti)
      Sets PID tuning parameters for level controllers.
      Parameters:
      kp - proportional gain
      ti - integral time in seconds
    • setFlowTuning

      public void setFlowTuning(double kp, double ti)
      Sets PID tuning parameters for flow controllers.
      Parameters:
      kp - proportional gain
      ti - integral time in seconds
    • setTemperatureTuning

      public void setTemperatureTuning(double kp, double ti)
      Sets PID tuning parameters for temperature controllers.
      Parameters:
      kp - proportional gain
      ti - integral time in seconds
    • instrumentAndControl

      public void instrumentAndControl()
      Scans the process for equipment and auto-creates typical transmitters and PID controllers. Adds them to the process, wires controllers to valves, and switches all equipment to dynamic (non-steady-state) mode.

      The method handles:

      • Separators: PT on gas outlet, LT on vessel, controllers on downstream gas/liquid valves
      • ThreePhaseSeparators: additional water LT and controller
      • Compressors: PT and TT on discharge
      • Heaters/Coolers: TT on outlet
      • Valves: FT on inlet if no controller already assigned
    • instrumentSeparator

      private void instrumentSeparator(Separator sep, Map<String, ThrottlingValve> gasValves, Map<String, ThrottlingValve> liquidValves, Map<String, ThrottlingValve> waterValves)
      Instruments a separator with pressure and level transmitters and creates PID controllers on downstream valves.
      Parameters:
      sep - the separator to instrument
      gasValves - map of separator name to downstream gas valve
      liquidValves - map of separator name to downstream liquid valve
      waterValves - map of separator name to downstream water valve
    • instrumentCompressor

      private void instrumentCompressor(Compressor comp)
      Instruments a compressor with pressure and temperature transmitters on the discharge.
      Parameters:
      comp - the compressor to instrument
    • instrumentHeatExchanger

      private void instrumentHeatExchanger(ProcessEquipmentInterface unit)
      Instruments a heater or cooler with a temperature transmitter on the outlet.
      Parameters:
      unit - the heater or cooler equipment
    • createPIDController

      private ControllerDeviceInterface createPIDController(String name, MeasurementDeviceInterface transmitter, double setpoint, double kp, double ti, double td, boolean reverseActing)
      Creates a PID controller connected to a transmitter with the given tuning.
      Parameters:
      name - controller tag name
      transmitter - measurement input
      setpoint - controller set point
      kp - proportional gain
      ti - integral time in seconds
      td - derivative time in seconds
      reverseActing - true if controller output increases when measurement is above setpoint
      Returns:
      configured PID controller
    • addTransmitter

      private void addTransmitter(String tag, MeasurementDeviceInterface device)
      Adds a transmitter to the internal registry and to the process.
      Parameters:
      tag - transmitter tag name
      device - the transmitter
    • addController

      private void addController(String tag, ControllerDeviceInterface controller)
      Adds a controller to the internal registry.
      Parameters:
      tag - controller tag name
      controller - the controller
    • getTransmitters

      public Map<String, MeasurementDeviceInterface> getTransmitters()
      Returns all generated transmitters keyed by tag name (e.g. "PT-HP sep", "LT-HP sep").
      Returns:
      map of tag name to transmitter
    • getControllers

      public Map<String, ControllerDeviceInterface> getControllers()
      Returns all generated controllers keyed by tag name (e.g. "PC-HP sep", "LC-HP sep").
      Returns:
      map of tag name to controller
    • getTransmitter

      public MeasurementDeviceInterface getTransmitter(String tag)
      Gets a specific transmitter by tag name.
      Parameters:
      tag - the transmitter tag (e.g. "PT-HP sep")
      Returns:
      the transmitter, or null if not found
    • getController

      public ControllerDeviceInterface getController(String tag)
      Gets a specific controller by tag name.
      Parameters:
      tag - the controller tag (e.g. "PC-HP sep")
      Returns:
      the controller, or null if not found
    • addFlowController

      public ControllerDeviceInterface addFlowController(String tag, ThrottlingValve valve, StreamInterface stream, double flowSetpoint, String flowUnit)
      Creates a flow transmitter on a stream and a flow controller that drives a valve. This is a convenience method for adding flow control to any valve in the process.
      Parameters:
      tag - ISA tag for the flow loop (e.g. "FIC-101")
      valve - the valve to control
      stream - the stream to measure flow on (typically the valve inlet)
      flowSetpoint - the desired flow rate
      flowUnit - the unit for flow measurement (e.g. "kg/hr")
      Returns:
      the flow controller
    • addTemperatureController

      public ControllerDeviceInterface addTemperatureController(String tag, ProcessEquipmentInterface heatExchanger, StreamInterface outletStream, double tempSetpointC)
      Creates a temperature transmitter and a temperature controller that drives a heater or cooler duty. This is a convenience method for adding temperature control.
      Parameters:
      tag - ISA tag for the temperature loop (e.g. "TIC-101")
      heatExchanger - the heater or cooler to control
      outletStream - the outlet stream to measure temperature on
      tempSetpointC - the desired outlet temperature in Celsius
      Returns:
      the temperature controller
    • exportDexpi

      public void exportDexpi(File file) throws IOException
      Exports the process and its instruments to a DEXPI XML file. The generated transmitters and controllers are included as ProcessInstrumentationFunction and InstrumentationLoopFunction elements.
      Parameters:
      file - output DEXPI XML file
      Throws:
      IOException - if writing fails
    • readDexpiInstruments

      public List<DexpiInstrumentInfo> readDexpiInstruments(File file) throws IOException, DexpiXmlReaderException
      Reads instrument metadata from a DEXPI XML file. Returns structured DexpiInstrumentInfo records describing the P&ID instrumentation found in the file.

      Note that live transmitter and controller objects are not created because they require connected process streams. Use the returned info to identify which instruments exist in the P&ID.

      Parameters:
      file - DEXPI XML file to read
      Returns:
      list of instrument info records
      Throws:
      IOException - if the file cannot be read
      DexpiXmlReaderException - if the file cannot be parsed