Class DynamicProcessHelper
java.lang.Object
neqsim.process.util.DynamicProcessHelper
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<String, ControllerDeviceInterface> Generated controllers keyed by tag name.private doubleprivate doubleDefault PID proportional gain for flow controllers.private doubleDefault PID integral time (seconds) for flow controllers.private doubleDefault PID proportional gain for level controllers.private doubleDefault PID integral time (seconds) for level controllers.private doubleDefault PID proportional gain for pressure controllers.private doubleDefault PID integral time (seconds) for pressure controllers.private final ProcessSystemprivate doubleDefault PID proportional gain for temperature controllers.private doubleDefault PID integral time (seconds) for temperature controllers.private final Map<String, MeasurementDeviceInterface> Generated transmitters keyed by tag name. -
Constructor Summary
ConstructorsConstructorDescriptionDynamicProcessHelper(ProcessSystem process) Creates a helper for the given process system. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddController(String tag, ControllerDeviceInterface controller) Adds a controller to the internal registry.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.addTemperatureController(String tag, ProcessEquipmentInterface heatExchanger, StreamInterface outletStream, double tempSetpointC) Creates a temperature transmitter and a temperature controller that drives a heater or cooler duty.private voidaddTransmitter(String tag, MeasurementDeviceInterface device) Adds a transmitter to the internal registry and to the process.private ControllerDeviceInterfacecreatePIDController(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.voidexportDexpi(File file) Exports the process and its instruments to a DEXPI XML file.getController(String tag) Gets a specific controller by tag name.Returns all generated controllers keyed by tag name (e.g.doubleGets the default time step.getTransmitter(String tag) Gets a specific transmitter by tag name.Returns all generated transmitters keyed by tag name (e.g.voidScans the process for equipment and auto-creates typical transmitters and PID controllers.private voidInstruments a compressor with pressure and temperature transmitters on the discharge.private voidInstruments a heater or cooler with a temperature transmitter on the outlet.private voidinstrumentSeparator(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.readDexpiInstruments(File file) Reads instrument metadata from a DEXPI XML file.voidsetDefaultTimeStep(double dt) Sets the transient time step in seconds (default 1.0).voidsetFlowTuning(double kp, double ti) Sets PID tuning parameters for flow controllers.voidsetLevelTuning(double kp, double ti) Sets PID tuning parameters for level controllers.voidsetPressureTuning(double kp, double ti) Sets PID tuning parameters for pressure controllers.voidsetTemperatureTuning(double kp, double ti) Sets PID tuning parameters for temperature controllers.
-
Field Details
-
process
-
defaultTimeStep
private double defaultTimeStep -
pressureKp
private double pressureKpDefault PID proportional gain for pressure controllers. -
pressureTi
private double pressureTiDefault PID integral time (seconds) for pressure controllers. -
levelKp
private double levelKpDefault PID proportional gain for level controllers. -
levelTi
private double levelTiDefault PID integral time (seconds) for level controllers. -
flowKp
private double flowKpDefault PID proportional gain for flow controllers. -
flowTi
private double flowTiDefault PID integral time (seconds) for flow controllers. -
temperatureKp
private double temperatureKpDefault PID proportional gain for temperature controllers. -
temperatureTi
private double temperatureTiDefault PID integral time (seconds) for temperature controllers. -
transmitters
Generated transmitters keyed by tag name. -
controllers
Generated controllers keyed by tag name.
-
-
Constructor Details
-
DynamicProcessHelper
Creates a helper for the given process system.- Parameters:
process- aProcessSystemthat 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 gainti- integral time in seconds
-
setLevelTuning
public void setLevelTuning(double kp, double ti) Sets PID tuning parameters for level controllers.- Parameters:
kp- proportional gainti- integral time in seconds
-
setFlowTuning
public void setFlowTuning(double kp, double ti) Sets PID tuning parameters for flow controllers.- Parameters:
kp- proportional gainti- integral time in seconds
-
setTemperatureTuning
public void setTemperatureTuning(double kp, double ti) Sets PID tuning parameters for temperature controllers.- Parameters:
kp- proportional gainti- 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 instrumentgasValves- map of separator name to downstream gas valveliquidValves- map of separator name to downstream liquid valvewaterValves- map of separator name to downstream water valve
-
instrumentCompressor
Instruments a compressor with pressure and temperature transmitters on the discharge.- Parameters:
comp- the compressor to instrument
-
instrumentHeatExchanger
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 nametransmitter- measurement inputsetpoint- controller set pointkp- proportional gainti- integral time in secondstd- derivative time in secondsreverseActing- true if controller output increases when measurement is above setpoint- Returns:
- configured PID controller
-
addTransmitter
Adds a transmitter to the internal registry and to the process.- Parameters:
tag- transmitter tag namedevice- the transmitter
-
addController
Adds a controller to the internal registry.- Parameters:
tag- controller tag namecontroller- the controller
-
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
Returns all generated controllers keyed by tag name (e.g. "PC-HP sep", "LC-HP sep").- Returns:
- map of tag name to controller
-
getTransmitter
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
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 controlstream- the stream to measure flow on (typically the valve inlet)flowSetpoint- the desired flow rateflowUnit- 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 controloutletStream- the outlet stream to measure temperature ontempSetpointC- the desired outlet temperature in Celsius- Returns:
- the temperature controller
-
exportDexpi
Exports the process and its instruments to a DEXPI XML file. The generated transmitters and controllers are included asProcessInstrumentationFunctionandInstrumentationLoopFunctionelements.- 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 structuredDexpiInstrumentInforecords 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 readDexpiXmlReaderException- if the file cannot be parsed
-