Class HeatExchanger

All Implemented Interfaces:
Serializable, Runnable, AutoSizeable, CapacityConstrainedEquipment, HeaterInterface, HeatExchangerInterface, ProcessEquipmentInterface, TwoPortInterface, StateVectorProvider, SimulationInterface, NamedInterface

public class HeatExchanger extends Heater implements HeatExchangerInterface, StateVectorProvider, CapacityConstrainedEquipment

HeatExchanger class.

Version:
$Id: $Id
Author:
Even Solbraa
See Also:
  • Field Details

    • serialVersionUID

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

      boolean setTemperature
    • outStream

      StreamInterface[] outStream
    • inStream

      StreamInterface[] inStream
    • system

    • NTU

      double NTU
    • temperatureOut

      protected double temperatureOut
    • dT

      protected double dT
    • dH

      double dH
    • UAvalue

      private double UAvalue
    • duty

      double duty
    • hotColdDutyBalance

      private double hotColdDutyBalance
    • firstTime

      boolean firstTime
    • guessOutTemperature

      public double guessOutTemperature
    • guessOutTemperatureUnit

      public String guessOutTemperatureUnit
    • outStreamSpecificationNumber

      int outStreamSpecificationNumber
    • thermalEffectiveness

      public double thermalEffectiveness
    • flowArrangement

      private String flowArrangement
    • useDeltaT

      private boolean useDeltaT
    • deltaT

      private double deltaT
    • designDuty

      private double designDuty
      Design duty in Watts for capacity constraint.
    • designUAValue

      private double designUAValue
      Design UA value in W/K for capacity constraint.
    • minApproachTemperature

      private double minApproachTemperature
      Minimum approach temperature in K.
    • maxShellPressureDrop

      private double maxShellPressureDrop
      Maximum shell-side pressure drop in bar.
    • maxTubePressureDrop

      private double maxTubePressureDrop
      Maximum tube-side pressure drop in bar.
    • hxCapacityConstraints

      private Map<String, CapacityConstraint> hxCapacityConstraints
      Capacity constraints map.
    • hxCapacityAnalysisEnabled

      private boolean hxCapacityAnalysisEnabled
      Flag for HX-specific capacity analysis.
    • hxAutoSized

      private boolean hxAutoSized
      Internal auto-sized flag for heat exchanger.
  • Constructor Details

    • HeatExchanger

      public HeatExchanger(String name)
      Constructor for HeatExchanger.
      Parameters:
      name - name of heat exchanger
    • HeatExchanger

      public HeatExchanger(String name, StreamInterface inStream1)
      Constructor for HeatExchanger.
      Parameters:
      name - name of heat exchanger
      inStream1 - input stream
    • HeatExchanger

      public HeatExchanger(String name, StreamInterface inStream1, StreamInterface inStream2)
      Constructor for HeatExchanger.
      Parameters:
      name - name of heat exchanger
      inStream1 - input stream 1
      inStream2 - input stream 2
  • Method Details

    • addInStream

      public void addInStream(StreamInterface inStream)

      Add inlet stream.

      Parameters:
      inStream - a StreamInterface object
    • setFeedStream

      public void setFeedStream(int number, StreamInterface inStream)

      setFeedStream. Will also set name of outstreams.

      Parameters:
      number - a int
      inStream - a StreamInterface object
    • getMechanicalDesign

      public HeatExchangerMechanicalDesign getMechanicalDesign()

      Get a mechanicalDesign for the equipment.

      Specified by:
      getMechanicalDesign in interface ProcessEquipmentInterface
      Overrides:
      getMechanicalDesign in class Heater
      Returns:
      a MechanicalDesign object
    • initMechanicalDesign

      public void initMechanicalDesign()

      Initialize a initMechanicalDesign for the equipment.

      Specified by:
      initMechanicalDesign in interface ProcessEquipmentInterface
      Overrides:
      initMechanicalDesign in class Heater
    • setName

      public void setName(String name)

      Setter for the field name.

      Specified by:
      setName in interface NamedInterface
      Overrides:
      setName in class NamedBaseClass
      Parameters:
      name - a String object
    • setdT

      public void setdT(double dT)

      setdT.

      Specified by:
      setdT in interface HeaterInterface
      Overrides:
      setdT in class Heater
      Parameters:
      dT - a double
    • getOutStream

      public StreamInterface getOutStream(int i)

      getOutStream.

      Specified by:
      getOutStream in interface HeatExchangerInterface
      Parameters:
      i - a int
      Returns:
      a StreamInterface object
    • getInStream

      public StreamInterface getInStream(int i)

      Getter for the field inStream.

      Parameters:
      i - a int
      Returns:
      a StreamInterface object
    • setOutTemperature

      public void setOutTemperature(double temperature)

      Set the outlet temperature of the heater.

      Specified by:
      setOutTemperature in interface TwoPortInterface
      Overrides:
      setOutTemperature in class Heater
      Parameters:
      temperature - Temperature in Kelvin
    • getOutTemperature

      public double getOutTemperature(int i)

      Get temperature of outstream i.

      Parameters:
      i - a int
      Returns:
      a double
    • getInTemperature

      public double getInTemperature(int i)

      Get temperature of instream i.

      Parameters:
      i - a int
      Returns:
      a double
    • setOutStream

      public void setOutStream(int streamNumber, StreamInterface outStream)

      Setter for the field outStream.

      Parameters:
      streamNumber - a int
      outStream - the outStream to set
    • runSpecifiedStream

      public void runSpecifiedStream(UUID id)

      runSpecifiedStream.

      Parameters:
      id - UUID of run
    • runDeltaT

      public void runDeltaT(UUID id)

      runDeltaT.

      Parameters:
      id - UUID of run
    • 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
    • getDuty

      public double getDuty()

      getDuty.

      Overrides:
      getDuty in class Heater
      Returns:
      a double
    • displayResult

      public void displayResult()

      displayResult.

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

      public double getUAvalue()

      getUAvalue.

      Returns:
      the UAvalue
    • setUAvalue

      public void setUAvalue(double UAvalue)

      setUAvalue.

      Parameters:
      UAvalue - the UAvalue to set
    • getGuessOutTemperature

      public double getGuessOutTemperature()

      Getter for the field guessOutTemperature.

      Returns:
      a double
    • setGuessOutTemperature

      public void setGuessOutTemperature(double guessOutTemperature)

      Setter for the field guessOutTemperature.

      Parameters:
      guessOutTemperature - a double
    • setGuessOutTemperature

      public void setGuessOutTemperature(double guessOutTemperature, String unit)

      Setter for the field guessOutTemperature.

      Parameters:
      guessOutTemperature - a double
      unit - a String
    • getEntropyProduction

      public double getEntropyProduction(String unit)

      getEntropyProduction.

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

      public double getMassBalance(String unit)

      getMassBalance.

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

      public void runConditionAnalysis(ProcessEquipmentInterface refExchanger)

      runConditionAnalysis.

      Specified by:
      runConditionAnalysis in interface ProcessEquipmentInterface
      Overrides:
      runConditionAnalysis in class ProcessEquipmentBaseClass
      Parameters:
      refExchanger - a ProcessEquipmentInterface object
    • runConditionAnalysis

      public void runConditionAnalysis()

      runConditionAnalysis.

    • getThermalEffectiveness

      public double getThermalEffectiveness()

      Getter for the field thermalEffectiveness.

      Returns:
      a double
    • setThermalEffectiveness

      public void setThermalEffectiveness(double thermalEffectiveness)

      Setter for the field thermalEffectiveness.

      Parameters:
      thermalEffectiveness - a double
    • getFlowArrangement

      public String getFlowArrangement()

      Getter for the field flowArrangement.

      Returns:
      String
    • setFlowArrangement

      public void setFlowArrangement(String flowArrangement)

      Setter for the field flowArrangement.

      Parameters:
      flowArrangement - name of flow arrangement
    • calcThermalEffectivenes

      public double calcThermalEffectivenes(double NTU, double Cr)

      calcThermalEffectivenes.

      Parameters:
      NTU - a double
      Cr - a double
      Returns:
      a double
    • getHotColdDutyBalance

      public double getHotColdDutyBalance()

      Getter for the field hotColdDutyBalance.

      Returns:
      a double
    • setHotColdDutyBalance

      public void setHotColdDutyBalance(double hotColdDutyBalance)

      Setter for the field hotColdDutyBalance.

      Parameters:
      hotColdDutyBalance - a double
    • toJson

      public String toJson()

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

      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 ProcessEquipmentInterface
      Overrides:
      toJson in class Heater
      Parameters:
      cfg - report configuration
      Returns:
      json string
    • autoSize

      public void autoSize(double safetyFactor)
      Automatically size the equipment based on connected stream conditions.

      This method calculates dimensions and design parameters using the inlet stream properties and applies the specified safety factor. The equipment must have a valid inlet stream connected before calling this method.

      Specified by:
      autoSize in interface AutoSizeable
      Overrides:
      autoSize in class Heater
      Parameters:
      safetyFactor - multiplier for design capacity, typically 1.1-1.3 (10-30% over design)
    • setAutoSized

      protected void setAutoSized(boolean autoSized)
      Sets the autoSized flag. Protected to allow subclass access.
      Parameters:
      autoSized - true if equipment has been auto-sized
    • isAutoSized

      public boolean isAutoSized()
      Check if equipment has been auto-sized.
      Specified by:
      isAutoSized in interface AutoSizeable
      Overrides:
      isAutoSized in class Heater
      Returns:
      true if autoSize() has been called successfully
    • getSizingReport

      public String getSizingReport()
      Get a detailed sizing report after auto-sizing.

      The report includes:

      • Design basis (flow rates, pressures, temperatures)
      • Calculated dimensions
      • Design parameters (K-factor, Cv, velocity, etc.)
      • Safety margins
      Specified by:
      getSizingReport in interface AutoSizeable
      Overrides:
      getSizingReport in class Heater
      Returns:
      formatted sizing report string
    • setUseDeltaT

      public void setUseDeltaT(boolean useDeltaT)

      Setter for the field useDeltaT.

      Parameters:
      useDeltaT - a boolean
    • getDeltaT

      public double getDeltaT()

      Getter for the field deltaT.

      Returns:
      a double
    • setDeltaT

      public void setDeltaT(double deltaT)

      Setter for the field deltaT.

      Parameters:
      deltaT - a double
    • getStateVector

      public StateVector getStateVector()
      Get the current state as a standardized vector.

      The state vector should include all observable variables relevant for control and monitoring. Values should be in physical units with appropriate bounds.

      Returns state vector containing:

      • hot_inlet_temp - Hot side inlet temperature [K]
      • hot_outlet_temp - Hot side outlet temperature [K]
      • cold_inlet_temp - Cold side inlet temperature [K]
      • cold_outlet_temp - Cold side outlet temperature [K]
      • duty - Heat duty [kW]
      • ua_value - UA value [W/K]
      • effectiveness - Thermal effectiveness [fraction]
      • lmtd - Log mean temperature difference [K]
      • hot_flow - Hot side mass flow [kg/s]
      • cold_flow - Cold side mass flow [kg/s]
      Specified by:
      getStateVector in interface StateVectorProvider
      Returns:
      current state vector
    • builder

      public static HeatExchanger.Builder builder(String name)
      Creates a new Builder for constructing a HeatExchanger with a fluent API.

      Example usage:

      HeatExchanger hx = HeatExchanger.builder("E-100").hotStream(hotFeed).coldStream(coldFeed)
          .UAvalue(5000.0).flowArrangement("counterflow").build();
      
      Parameters:
      name - the name of the heat exchanger
      Returns:
      a new Builder instance
    • setDesignDuty

      public void setDesignDuty(double duty)
      Sets the design duty for capacity calculations.
      Parameters:
      duty - design duty in Watts
    • getDesignDuty

      public double getDesignDuty()
      Gets the design duty.
      Returns:
      design duty in Watts
    • setDesignUAValue

      public void setDesignUAValue(double uaValue)
      Sets the design UA value for capacity calculations.
      Parameters:
      uaValue - design UA value in W/K
    • getDesignUAValue

      public double getDesignUAValue()
      Gets the design UA value.
      Returns:
      design UA value in W/K
    • setMinApproachTemperature

      public void setMinApproachTemperature(double temperature)
      Sets the minimum approach temperature.
      Parameters:
      temperature - minimum approach temperature in K
    • getMinApproachTemperature

      public double getMinApproachTemperature()
      Gets the minimum approach temperature.
      Returns:
      minimum approach temperature in K
    • setMaxShellPressureDrop

      public void setMaxShellPressureDrop(double pressureDrop)
      Sets the maximum shell-side pressure drop.
      Parameters:
      pressureDrop - maximum pressure drop in bar
    • setMaxTubePressureDrop

      public void setMaxTubePressureDrop(double pressureDrop)
      Sets the maximum tube-side pressure drop.
      Parameters:
      pressureDrop - maximum pressure drop in bar
    • getApproachTemperature

      public double getApproachTemperature()
      Calculates the current approach temperature.
      Returns:
      current approach temperature in K
    • initializeHxCapacityConstraints

      private void initializeHxCapacityConstraints()
      Initialize heat exchanger specific capacity constraints.
    • isCapacityAnalysisEnabled

      public boolean isCapacityAnalysisEnabled()
      Checks if capacity analysis is enabled for this equipment.

      When disabled, this equipment is excluded from bottleneck detection, capacity utilization summaries, and optimization routines. The equipment still tracks its constraints but doesn't contribute to system-level analysis.

      Specified by:
      isCapacityAnalysisEnabled in interface CapacityConstrainedEquipment
      Overrides:
      isCapacityAnalysisEnabled in class ProcessEquipmentBaseClass
      Returns:
      true if capacity analysis is enabled (default is true)
    • setCapacityAnalysisEnabled

      public void setCapacityAnalysisEnabled(boolean enabled)
      Enables or disables capacity analysis for this equipment.

      When disabled, this equipment is excluded from:

      • System bottleneck detection (ProcessSystem.findBottleneck())
      • Capacity utilization summaries (ProcessSystem.getCapacityUtilizationSummary())
      • Equipment near capacity lists (ProcessSystem.getEquipmentNearCapacityLimit())
      • Optimization constraint checking

      The equipment still calculates and tracks its constraints internally.

      Specified by:
      setCapacityAnalysisEnabled in interface CapacityConstrainedEquipment
      Overrides:
      setCapacityAnalysisEnabled in class ProcessEquipmentBaseClass
      Parameters:
      enabled - true to include in capacity analysis, false to exclude
    • getCapacityConstraints

      public Map<String, CapacityConstraint> getCapacityConstraints()
      Gets all capacity constraints defined for this equipment.

      The map keys are constraint names (e.g., "speed", "gasLoadFactor") and values are the corresponding CapacityConstraint objects containing design values, current values, and utilization calculations.

      Specified by:
      getCapacityConstraints in interface CapacityConstrainedEquipment
      Overrides:
      getCapacityConstraints in class Heater
      Returns:
      unmodifiable map of constraint name to CapacityConstraint
    • getBottleneckConstraint

      public CapacityConstraint getBottleneckConstraint()
      Gets the constraint with the highest utilization (the bottleneck).

      This method identifies which constraint is closest to or exceeding its design limit. Use this to determine what is limiting equipment capacity.

      Specified by:
      getBottleneckConstraint in interface CapacityConstrainedEquipment
      Overrides:
      getBottleneckConstraint in class Heater
      Returns:
      the bottleneck constraint, or null if no constraints are defined
    • isCapacityExceeded

      public boolean isCapacityExceeded()
      Checks if any capacity constraint is violated (exceeds 100% utilization).

      A violated constraint means the equipment is operating beyond its design capacity. For HARD constraints, this may indicate equipment trip or failure. For SOFT constraints, this indicates reduced efficiency or accelerated wear.

      Specified by:
      isCapacityExceeded in interface CapacityConstrainedEquipment
      Overrides:
      isCapacityExceeded in class Heater
      Returns:
      true if any constraint utilization exceeds 1.0 (100%)
    • isHardLimitExceeded

      public boolean isHardLimitExceeded()
      Checks if any HARD constraint limit is exceeded.

      HARD limits represent absolute equipment limits (e.g., maximum speed) that cannot be exceeded without equipment trip or damage. This is more severe than general capacity exceedance.

      Specified by:
      isHardLimitExceeded in interface CapacityConstrainedEquipment
      Overrides:
      isHardLimitExceeded in class Heater
      Returns:
      true if any HARD constraint's max value is exceeded
    • getMaxUtilization

      public double getMaxUtilization()
      Gets the maximum utilization across all constraints.

      This gives a single number representing how close the equipment is to its limiting constraint. Values above 1.0 indicate the equipment is over capacity.

      Specified by:
      getMaxUtilization in interface CapacityConstrainedEquipment
      Overrides:
      getMaxUtilization in class Heater
      Returns:
      maximum utilization as fraction (1.0 = 100% of design capacity)
    • addCapacityConstraint

      public void addCapacityConstraint(CapacityConstraint constraint)
      Adds a new capacity constraint to this equipment.

      This allows dynamic addition of constraints at runtime. Constraints can be added during equipment configuration or based on operating conditions.

      Specified by:
      addCapacityConstraint in interface CapacityConstrainedEquipment
      Overrides:
      addCapacityConstraint in class Heater
      Parameters:
      constraint - the constraint to add
    • removeCapacityConstraint

      public boolean removeCapacityConstraint(String constraintName)
      Removes a capacity constraint by name.
      Specified by:
      removeCapacityConstraint in interface CapacityConstrainedEquipment
      Overrides:
      removeCapacityConstraint in class Heater
      Parameters:
      constraintName - the name of the constraint to remove
      Returns:
      true if the constraint was found and removed
    • clearCapacityConstraints

      public void clearCapacityConstraints()
      Clears all capacity constraints from this equipment.
      Specified by:
      clearCapacityConstraints in interface CapacityConstrainedEquipment
      Overrides:
      clearCapacityConstraints in class Heater