Class UnisimCalculator

All Implemented Interfaces:
Serializable, Runnable, ProcessEquipmentInterface, ProcessElementInterface, SimulationInterface, NamedInterface

public class UnisimCalculator extends ProcessEquipmentBaseClass
Generic UniSim calculation block used when importing UniSim operations that carry process stream topology but do not have a one-to-one physical NeqSim equivalent.

The block behaves as a deterministic pass-through by default: the first connected inlet stream is cloned to one outlet stream and optional outlet specifications are applied. This is useful for UniSim balance blocks, virtual streams, template-interface placeholders, and lightweight calculator blocks where preserving connectivity is more important than silently dropping the operation.

Version:
1.0
Author:
ESOL
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Serialization version UID.
      See Also:
    • inletStreams

      private final List<StreamInterface> inletStreams
      Inlet streams connected to the imported UniSim operation.
    • outletStream

      private StreamInterface outletStream
      Outlet stream exposed to downstream NeqSim equipment.
    • sourceOperationType

      private String sourceOperationType
      UniSim operation type that created this block.
    • calculationMode

      private String calculationMode
      Description of the current calculation mode.
    • outletFlowRate

      private double outletFlowRate
      Optional outlet flow rate value.
    • outletFlowRateUnit

      private String outletFlowRateUnit
      Unit for the optional outlet flow rate value.
    • outletFlowRateSpecified

      private boolean outletFlowRateSpecified
      Whether an outlet flow rate override has been specified.
    • outletPressure

      private double outletPressure
      Optional outlet pressure value.
    • outletPressureUnit

      private String outletPressureUnit
      Unit for the optional outlet pressure value.
    • outletPressureSpecified

      private boolean outletPressureSpecified
      Whether an outlet pressure override has been specified.
    • outletTemperature

      private double outletTemperature
      Optional outlet temperature value.
    • outletTemperatureUnit

      private String outletTemperatureUnit
      Unit for the optional outlet temperature value.
    • outletTemperatureSpecified

      private boolean outletTemperatureSpecified
      Whether an outlet temperature override has been specified.
    • outletMolarComposition

      private double[] outletMolarComposition
      Optional outlet molar composition value.
    • outletMolarCompositionSpecified

      private boolean outletMolarCompositionSpecified
      Whether an outlet molar composition override has been specified.
  • Constructor Details

    • UnisimCalculator

      public UnisimCalculator(String name)
      Creates an empty UniSim calculator block.
      Parameters:
      name - name of the imported UniSim calculation block
    • UnisimCalculator

      public UnisimCalculator(String name, StreamInterface inletStream)
      Creates a UniSim calculator block with one inlet stream.
      Parameters:
      name - name of the imported UniSim calculation block
      inletStream - inlet stream used as the pass-through reference
      Throws:
      IllegalArgumentException - if the inlet stream is null
  • Method Details

    • setInletStream

      public void setInletStream(StreamInterface inletStream)
      Sets the single inlet stream, replacing any previously connected inlet streams.
      Parameters:
      inletStream - inlet stream used as the pass-through reference
      Throws:
      IllegalArgumentException - if the inlet stream is null
    • addStream

      public void addStream(StreamInterface inletStream)
      Adds an inlet stream. The first inlet is used as the pass-through reference.
      Parameters:
      inletStream - inlet stream to add
      Throws:
      IllegalArgumentException - if the inlet stream is null
    • getInletStream

      public StreamInterface getInletStream()
      Gets the first inlet stream.
      Returns:
      first inlet stream, or null if no inlet is connected
    • getInletStreams

      public List<StreamInterface> getInletStreams()
      Returns all inlet streams connected to this equipment. Subclasses override to report their specific inlets. Used by graph builders, DEXPI export, and auto-instrumentation to discover topology without instanceof checks.
      Returns:
      unmodifiable list of inlet streams (empty by default)
    • setOutletStream

      public void setOutletStream(StreamInterface outletStream)
      Sets an explicit outlet stream.
      Parameters:
      outletStream - outlet stream exposed to downstream equipment
    • getOutletStream

      public StreamInterface getOutletStream()
      Gets the outlet stream.
      Returns:
      outlet stream, or null if the block has not been connected
    • getOutStream

      public StreamInterface getOutStream()
      Gets the outlet stream using the shorter NeqSim utility naming convention.
      Returns:
      outlet stream, or null if the block has not been connected
    • getOutletStreams

      public List<StreamInterface> getOutletStreams()
      Returns all outlet streams produced by this equipment. Subclasses override to report their specific outlets. Used by graph builders, DEXPI export, and auto-instrumentation to discover topology without instanceof checks.
      Returns:
      unmodifiable list of outlet streams (empty by default)
    • setSourceOperationType

      public void setSourceOperationType(String sourceOperationType)
      Sets the UniSim operation type that created this calculator block.
      Parameters:
      sourceOperationType - UniSim operation type, for example balanceop
    • getSourceOperationType

      public String getSourceOperationType()
      Gets the UniSim operation type that created this calculator block.
      Returns:
      UniSim operation type, or an empty string if unset
    • setCalculationMode

      public void setCalculationMode(String calculationMode)
      Sets the calculation mode label.
      Parameters:
      calculationMode - calculation mode label, for example passThrough
    • getCalculationMode

      public String getCalculationMode()
      Gets the calculation mode label.
      Returns:
      calculation mode label
    • setOutletFlowRate

      public void setOutletFlowRate(double flowRate, String unit)
      Sets an outlet flow rate override.
      Parameters:
      flowRate - outlet flow rate value
      unit - unit of the flow rate value
    • setFlowRate

      public void setFlowRate(double flowRate, String unit)
      Sets an outlet flow rate override using the generic stream-style setter name.
      Parameters:
      flowRate - outlet flow rate value
      unit - unit of the flow rate value
    • setOutletPressure

      public void setOutletPressure(double pressure)
      Sets an outlet pressure override in bara.
      Parameters:
      pressure - outlet pressure in bara
    • setOutletPressure

      public void setOutletPressure(double pressure, String unit)
      Sets an outlet pressure override.
      Parameters:
      pressure - outlet pressure value
      unit - unit of the pressure value
    • setPressure

      public void setPressure(double pressure, String unit)
      Sets an outlet pressure override using the generic stream-style setter name.
      Parameters:
      pressure - outlet pressure value
      unit - unit of the pressure value
    • setOutletTemperature

      public void setOutletTemperature(double temperature)
      Sets an outlet temperature override in Kelvin.
      Parameters:
      temperature - outlet temperature in Kelvin
    • setOutletTemperature

      public void setOutletTemperature(double temperature, String unit)
      Sets an outlet temperature override.
      Parameters:
      temperature - outlet temperature value
      unit - unit of the temperature value
    • setTemperature

      public void setTemperature(double temperature, String unit)
      Sets an outlet temperature override using the generic stream-style setter name.
      Parameters:
      temperature - outlet temperature value
      unit - unit of the temperature value
    • setMolarComposition

      public void setMolarComposition(double[] molarComposition)
      Sets an outlet molar composition override.
      Parameters:
      molarComposition - component molar fractions in NeqSim component order
    • getThermoSystem

      public SystemInterface getThermoSystem()

      getThermoSystem.

      Specified by:
      getThermoSystem in interface ProcessEquipmentInterface
      Overrides:
      getThermoSystem in class ProcessEquipmentBaseClass
      Returns:
      a SystemInterface object
    • getPressure

      public double getPressure()

      Getter for the field pressure.

      Specified by:
      getPressure in interface ProcessEquipmentInterface
      Overrides:
      getPressure in class ProcessEquipmentBaseClass
      Returns:
      Pressure in bara
    • getPressure

      public double getPressure(String unit)

      Getter for the field pressure converted to specified unit.

      Specified by:
      getPressure in interface ProcessEquipmentInterface
      Overrides:
      getPressure in class ProcessEquipmentBaseClass
      Parameters:
      unit - a String object
      Returns:
      a double
    • getTemperature

      public double getTemperature()

      Getter for the field temperature.

      Specified by:
      getTemperature in interface ProcessEquipmentInterface
      Overrides:
      getTemperature in class ProcessEquipmentBaseClass
      Returns:
      a double
    • getTemperature

      public double getTemperature(String unit)

      Getter for the field temperature converted to specified unit.

      Specified by:
      getTemperature in interface ProcessEquipmentInterface
      Overrides:
      getTemperature in class ProcessEquipmentBaseClass
      Parameters:
      unit - a String object
      Returns:
      a double
    • getMassBalance

      public double getMassBalance()

      getMassBalance in kg/sec.

      Specified by:
      getMassBalance in interface ProcessEquipmentInterface
      Overrides:
      getMassBalance in class ProcessEquipmentBaseClass
      Returns:
      The mass balance of the process equipment in kg/sec.
    • run

      public void run(UUID id)

      In this method all thermodynamic and unit operations will be calculated in a steady state calculation.

      Parameters:
      id - UUID
    • createOutletStream

      private StreamInterface createOutletStream(StreamInterface inletStream)
      Creates a new outlet stream from an inlet stream.
      Parameters:
      inletStream - inlet stream to clone
      Returns:
      outlet stream with a cloned thermodynamic system
    • applyOutletSpecifications

      private void applyOutletSpecifications()
      Applies configured outlet specifications before flashing the outlet stream.