Class MultiStreamHeatExchanger2

All Implemented Interfaces:
Serializable, Runnable, HeaterInterface, MultiStreamHeatExchangerInterface, ProcessEquipmentInterface, TwoPortInterface, SimulationInterface, NamedInterface

public class MultiStreamHeatExchanger2 extends Heater implements MultiStreamHeatExchangerInterface

MultiStreamHeatExchanger2 class.

Author:
esol
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • logger

      static org.apache.logging.log4j.Logger logger
      Logger object for class.
    • thermoSystem

      SystemInterface thermoSystem
    • tolerance

      private double tolerance
    • maxIterations

      private int maxIterations
    • jacobiDelta

      private double jacobiDelta
    • SINGULAR_JACOBIAN_MSG

      private static final String SINGULAR_JACOBIAN_MSG
      Message used when the Jacobian is singular.
      See Also:
    • extremeEnergy

      private final double extremeEnergy
      See Also:
    • extremeUA

      private final double extremeUA
      See Also:
    • extremeAttempts

      private final int extremeAttempts
      See Also:
    • prevOutletTemps

      private List<Double> prevOutletTemps
    • stallCounter

      private int stallCounter
    • stallLimit

      private final int stallLimit
      See Also:
    • localRange

      private double localRange
    • damping

      private double damping
    • approachTemperature

      private Double approachTemperature
    • UA

      private Double UA
    • hotLoad

      private double hotLoad
    • coldLoad

      private double coldLoad
    • compositeCurvePoints

      private Map<String, List<Map<String,Object>>> compositeCurvePoints
    • hInlet

      private List<Double> hInlet
    • fluidInlet

      private List<SystemInterface> fluidInlet
    • allLoad

      private List<Double> allLoad
    • hotTempAll

      private List<Double> hotTempAll
    • coldTempAll

      private List<Double> coldTempAll
    • tempDiff

      private List<Double> tempDiff
    • inStreams

      private List<StreamInterface> inStreams
    • outStreams

      private List<StreamInterface> outStreams
    • streamTypes

      private List<String> streamTypes
    • inletTemps

      private List<Double> inletTemps
    • outletTemps

      private List<Double> outletTemps
    • unknownOutlets

      private List<Object> unknownOutlets
    • pressures

      private List<Double> pressures
    • massFlows

      private List<Double> massFlows
    • streamLoads

      private List<Double> streamLoads
  • Constructor Details

    • MultiStreamHeatExchanger2

      public MultiStreamHeatExchanger2(String name)
      Constructor for MultiStreamHeatExchanger2.
      Parameters:
      name - Name of the heat exchanger
  • Method Details

    • addInStream

      public void addInStream(StreamInterface inStream)
      Adds an inlet stream to the heat exchanger.
      Specified by:
      addInStream in interface MultiStreamHeatExchangerInterface
      Parameters:
      inStream - Input stream to be added
    • addInStreamMSHE

      public void addInStreamMSHE(StreamInterface inStream, String streamType, Double outletTemp)
      Adds an inlet stream to the multi-stream heat exchanger.
      Parameters:
      inStream - a StreamInterface object
      streamType - a String object
      outletTemp - a Double object
    • setTemperatureApproach

      public void setTemperatureApproach(double temperatureApproach)

      setTemperatureApproach.

      Parameters:
      temperatureApproach - a double
    • setUAvalue

      public void setUAvalue(double UAvalue)
      Sets the overall heat transfer coefficient times area (UA value).
      Specified by:
      setUAvalue in interface MultiStreamHeatExchangerInterface
      Parameters:
      UAvalue - UA value to set
    • run

      public void run(UUID id)

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

      Specified by:
      run in interface SimulationInterface
      Overrides:
      run in class Heater
      Parameters:
      id - UUID
    • oneUnknown

      public void oneUnknown()
      Calculates the outlet temperatures for the heat exchanger when there is one unknown.
    • residualFunctionOneUnknown

      private double[] residualFunctionOneUnknown()
    • numericalJacobiOneUnknown

      private double[][] numericalJacobiOneUnknown(List<Integer> unknownIndices)
    • linearSystemOneUnknown

      private double[] linearSystemOneUnknown(double[][] A, double[] b)
    • twoUnknowns

      public void twoUnknowns()
      Calculates the outlet temperatures for the heat exchanger when there are two unknowns.
    • residualFunctionTwoUnknowns

      private double[] residualFunctionTwoUnknowns()
    • numericalJacobiTwoUnknowns

      private double[][] numericalJacobiTwoUnknowns(List<Integer> unknownIndices)
    • linearSystemTwoUnknowns

      private double[] linearSystemTwoUnknowns(double[][] A, double[] b)
    • threeUnknowns

      public void threeUnknowns()
      Calculates the outlet temperatures for the heat exchanger when there are three unknowns.
    • residualFunctionThreeUnknowns

      private double[] residualFunctionThreeUnknowns()
    • numericalJacobiThreeUnknowns

      private double[][] numericalJacobiThreeUnknowns(List<Integer> unknownIndices)
    • linearSystemThreeUnknowns

      private double[] linearSystemThreeUnknowns(double[][] A, double[] b)
    • energyDiff

      public double energyDiff()
      Calculates the energy difference between the inlet and outlet streams.
      Returns:
      a double representing the total energy difference
    • pinch

      public double pinch()
      Calculates the minimum approach temperature for the heat exchanger.
      Returns:
      a double
    • calculateUA

      public double calculateUA()
      Calculates the overall heat transfer coefficient (UA) for the heat exchanger.
      Returns:
      the overall heat transfer coefficient (UA) value in W/K
    • enthalpyTPFlash

      private double enthalpyTPFlash(int index, double pressure, double temperature)
    • compositeCurve

      public Map<String, List<Map<String,Object>>> compositeCurve()
      Calculates the composite curve data for the heat exchanger.
      Returns:
      a Map object
    • initializeOutletGuess

      private double initializeOutletGuess(int i)
    • intervalLoad

      private double intervalLoad(int i, double tempStart, double tempEnd)
    • calculateIntervalTemp

      private double calculateIntervalTemp(double loadStart, double targetLoad, double loadEnd, double tempStart, double tempEnd)
    • interpolateTemperature

      private double interpolateTemperature(List<Map<String,Object>> points, double load)
    • resetOfExtremesAndStalls

      private void resetOfExtremesAndStalls(List<Integer> unknownIndices, boolean localMin, boolean UATest)
    • stallDetection

      private boolean stallDetection(List<Integer> unknownIndices)
    • getCompositeCurve

      public Map<String, List<Map<String,Object>>> getCompositeCurve()
      Returns hot and cold composite curves.
      Returns:
      a Map object
    • getUA

      public double getUA()

      getUA.

      Returns:
      a double
    • getTemperatureApproach

      public double getTemperatureApproach()

      getTemperatureApproach.

      Returns:
      a double
    • getOutStream

      public StreamInterface getOutStream(int i)
      Retrieves the output stream at the specified index.
      Specified by:
      getOutStream in interface MultiStreamHeatExchangerInterface
      Parameters:
      i - Index of the output stream
      Returns:
      The output StreamInterface at the given index
    • getInStream

      public StreamInterface getInStream(int i)
      Retrieves the input stream at the specified index.
      Specified by:
      getInStream in interface MultiStreamHeatExchangerInterface
      Parameters:
      i - Index of the input stream
      Returns:
      The input StreamInterface at the given index
    • getInTemperature

      public double getInTemperature(int i)
      Gets the inlet temperature of a specific input stream.
      Specified by:
      getInTemperature in interface MultiStreamHeatExchangerInterface
      Parameters:
      i - Index of the input stream
      Returns:
      Inlet temperature in Kelvin
    • getOutTemperature

      public double getOutTemperature(int i)
      Gets the outlet temperature of a specific output stream.
      Specified by:
      getOutTemperature in interface MultiStreamHeatExchangerInterface
      Parameters:
      i - Index of the output stream
      Returns:
      Outlet temperature in Kelvin
    • getDuty

      public double getDuty()

      getDuty.

      Specified by:
      getDuty in interface MultiStreamHeatExchangerInterface
      Overrides:
      getDuty in class Heater
      Returns:
      a double
    • displayResult

      public void displayResult()

      displayResult.

      Specified by:
      displayResult in interface ProcessEquipmentInterface
      Overrides:
      displayResult in class Heater
    • runConditionAnalysis

      public void runConditionAnalysis()
      Runs a condition analysis using the current heat exchanger as the reference.
      Specified by:
      runConditionAnalysis in interface MultiStreamHeatExchangerInterface
    • getGuessOutTemperature

      public double getGuessOutTemperature()
      Retrieves the guessed outlet temperature used during initialization.
      Specified by:
      getGuessOutTemperature in interface MultiStreamHeatExchangerInterface
      Returns:
      Guessed outlet temperature
    • setGuessOutTemperature

      public void setGuessOutTemperature(double temp)
      Sets the guessed outlet temperature in Kelvin.
      Specified by:
      setGuessOutTemperature in interface MultiStreamHeatExchangerInterface
      Parameters:
      temp - Guessed outlet temperature
    • setGuessOutTemperature

      public void setGuessOutTemperature(double temp, String unit)
      Sets the guessed outlet temperature with a specified unit.
      Specified by:
      setGuessOutTemperature in interface MultiStreamHeatExchangerInterface
      Parameters:
      temp - Guessed outlet temperature
      unit - Unit of the temperature (e.g., "K", "C")
    • setFlowArrangement

      public void setFlowArrangement(String arrangement)
      Sets the flow arrangement of the heat exchanger.
      Specified by:
      setFlowArrangement in interface MultiStreamHeatExchangerInterface
      Parameters:
      arrangement - Name of the flow arrangement
    • getFlowArrangement

      public String getFlowArrangement()
      Retrieves the flow arrangement of the heat exchanger.
      Specified by:
      getFlowArrangement in interface MultiStreamHeatExchangerInterface
      Returns:
      Flow arrangement as a String (e.g., "counterflow", "parallelflow")
    • setThermalEffectiveness

      public void setThermalEffectiveness(double effectiveness)
      Sets the thermal effectiveness of the heat exchanger.
      Specified by:
      setThermalEffectiveness in interface MultiStreamHeatExchangerInterface
      Parameters:
      effectiveness - Thermal effectiveness to set
    • getThermalEffectiveness

      public double getThermalEffectiveness()
      Gets the thermal effectiveness of the heat exchanger.
      Specified by:
      getThermalEffectiveness in interface MultiStreamHeatExchangerInterface
      Returns:
      Thermal effectiveness
    • getHotColdDutyBalance

      public double getHotColdDutyBalance()
      Retrieves the hot and cold duty balance of the heat exchanger.
      Specified by:
      getHotColdDutyBalance in interface MultiStreamHeatExchangerInterface
      Returns:
      Hot and cold duty balance
    • setHotColdDutyBalance

      public void setHotColdDutyBalance(double value)
      Sets the hot and cold duty balance of the heat exchanger.
      Specified by:
      setHotColdDutyBalance in interface MultiStreamHeatExchangerInterface
      Parameters:
      value - Hot and cold duty balance to set
    • calcThermalEffectiveness

      public double calcThermalEffectiveness(double NTU, double Cr)
      Calculates the thermal effectiveness based on the Number of Transfer Units (NTU) and the capacity ratio (Cr).
      Specified by:
      calcThermalEffectiveness in interface MultiStreamHeatExchangerInterface
      Parameters:
      NTU - Number of Transfer Units
      Cr - Capacity ratio (Cmin/Cmax)
      Returns:
      Calculated thermal effectiveness
    • setUseDeltaT

      public void setUseDeltaT(boolean use)
      Enables or disables the use of a fixed temperature difference (ΔT) in calculations.
      Specified by:
      setUseDeltaT in interface MultiStreamHeatExchangerInterface
      Parameters:
      use - True to use ΔT, false otherwise
    • setFeedStream

      public void setFeedStream(int index, StreamInterface stream)
      Sets the feed stream at a specific index.
      Specified by:
      setFeedStream in interface MultiStreamHeatExchangerInterface
      Parameters:
      index - Index of the stream to set
      stream - Input stream to set at the specified index
    • setDeltaT

      public void setDeltaT(double dT)
      Sets the fixed temperature difference (ΔT) for calculations and enables its usage.
      Specified by:
      setDeltaT in interface MultiStreamHeatExchangerInterface
      Parameters:
      dT - Fixed temperature difference to set
    • getDeltaT

      public double getDeltaT()
      Retrieves the fixed temperature difference (ΔT) used in calculations.
      Specified by:
      getDeltaT in interface MultiStreamHeatExchangerInterface
      Returns:
      Temperature difference ΔT
    • getUAvalue

      public double getUAvalue()
      Retrieves the overall heat transfer coefficient times area (UA value).
      Specified by:
      getUAvalue in interface MultiStreamHeatExchangerInterface
      Returns:
      UA value
    • toJson

      public String toJson()

      Serializes the Process Equipment along with its state to a JSON string.

      Specified by:
      toJson in interface MultiStreamHeatExchangerInterface
      Specified by:
      toJson in interface ProcessEquipmentInterface
      Overrides:
      toJson in class Heater
      Returns:
      json string.
    • toJson

      public String toJson(ReportConfig cfg)
      Serializes the Process Equipment with configurable level of detail.
      Specified by:
      toJson in interface MultiStreamHeatExchangerInterface
      Specified by:
      toJson in interface ProcessEquipmentInterface
      Overrides:
      toJson in class Heater
      Parameters:
      cfg - report configuration
      Returns:
      json string