Class Compressor

All Implemented Interfaces:
Serializable, Runnable, AutoSizeable, CapacityConstrainedEquipment, CompressorInterface, ProcessEquipmentInterface, TwoPortInterface, StateVectorProvider, SimulationInterface, NamedInterface
Direct Known Subclasses:
Expander

Compressor class.

Version:
$Id: $Id
Author:
esol
See Also:
  • Field Details

    • serialVersionUID

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

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

      public SystemInterface thermoSystem
    • outTemperature

      private double outTemperature
    • useOutTemperature

      private boolean useOutTemperature
    • compressionRatio

      private double compressionRatio
    • actualCompressionRatio

      private double actualCompressionRatio
    • useCompressionRatio

      private boolean useCompressionRatio
    • maxOutletPressure

      private double maxOutletPressure
    • isSetMaxOutletPressure

      private boolean isSetMaxOutletPressure
    • maxDischargeTemperature

      private double maxDischargeTemperature
      Maximum discharge temperature in Kelvin for capacity constraint.
    • isSetMaxDischargeTemperature

      private boolean isSetMaxDischargeTemperature
    • propertyProfile

      private CompressorPropertyProfile propertyProfile
    • dH

      public double dH
    • inletEnthalpy

      public double inletEnthalpy
    • solveSpeed

      private boolean solveSpeed
    • pressure

      public double pressure
    • speed

      private double speed
    • maxspeed

      private double maxspeed
    • minspeed

      private double minspeed
    • isentropicEfficiency

      public double isentropicEfficiency
    • polytropicEfficiency

      public double polytropicEfficiency
    • usePolytropicCalc

      public boolean usePolytropicCalc
    • powerSet

      public boolean powerSet
    • calcPressureOut

      public boolean calcPressureOut
    • compressorChart

      private CompressorChartInterface compressorChart
    • antiSurge

      private AntiSurge antiSurge
    • polytropicHead

      private double polytropicHead
    • polytropicFluidHead

      private double polytropicFluidHead
    • polytropicHeadMeter

      private double polytropicHeadMeter
    • polytropicExponent

      private double polytropicExponent
    • numberOfCompressorCalcSteps

      private int numberOfCompressorCalcSteps
    • useRigorousPolytropicMethod

      private boolean useRigorousPolytropicMethod
    • useGERG2008

      private boolean useGERG2008
    • useLeachman

      private boolean useLeachman
    • useVega

      private boolean useVega
    • limitSpeed

      private boolean limitSpeed
    • useEnergyEfficiencyChart

      private boolean useEnergyEfficiencyChart
    • operatingState

      private CompressorState operatingState
    • driver

      private CompressorDriver driver
    • operatingHistory

      private CompressorOperatingHistory operatingHistory
    • startupProfile

      private StartupProfile startupProfile
    • shutdownProfile

      private ShutdownProfile shutdownProfile
    • eventListeners

      private transient List<CompressorEventListener> eventListeners
    • rotationalInertia

      private double rotationalInertia
    • maxAccelerationRate

      private double maxAccelerationRate
    • maxDecelerationRate

      private double maxDecelerationRate
    • targetSpeed

      private double targetSpeed
    • autoSpeedMode

      private boolean autoSpeedMode
    • degradationFactor

      private double degradationFactor
    • foulingFactor

      private double foulingFactor
    • operatingHours

      private double operatingHours
    • efficiencySolveTolerance

      private double efficiencySolveTolerance
    • autoSized

      private boolean autoSized
      Flag indicating if compressor has been auto-sized.
    • curveTemplate

      private String curveTemplate
      Template used for curve generation.
    • numberOfSpeedCurves

      private int numberOfSpeedCurves
      Number of speed curves to generate.
    • surgeWarningThreshold

      private double surgeWarningThreshold
    • surgeCriticalThreshold

      private double surgeCriticalThreshold
    • stoneWallWarningThreshold

      private double stoneWallWarningThreshold
    • startupElapsedTime

      private double startupElapsedTime
    • shutdownElapsedTime

      private double shutdownElapsedTime
    • speedAtShutdownStart

      private double speedAtShutdownStart
    • surgeWarningActive

      private boolean surgeWarningActive
    • surgeCriticalActive

      private boolean surgeCriticalActive
    • speedLimitWarningActive

      private boolean speedLimitWarningActive
    • previousActualFlow

      private double previousActualFlow
    • previousPolyHead

      private double previousPolyHead
    • mechanicalDesign

      CompressorMechanicalDesign mechanicalDesign
    • mechanicalLosses

      private CompressorMechanicalLosses mechanicalLosses
      Mechanical losses model for seal gas and bearing calculations.
    • pressureUnit

      private String pressureUnit
    • polytropicMethod

      private String polytropicMethod
    • capacityConstraints

      private transient Map<String, CapacityConstraint> capacityConstraints
      Capacity constraints map for this compressor. Marked transient because constraints contain lambdas/method references that are not serializable. Constraints are re-initialized after deserialization when needed.
    • MIN_DEFAULT_DESIGN_POWER_KW

      private static final double MIN_DEFAULT_DESIGN_POWER_KW
      Minimum default design power in kW for zero-flow compressors.
      See Also:
    • MIN_DEFAULT_DESIGN_FLOW_M3H

      private static final double MIN_DEFAULT_DESIGN_FLOW_M3H
      Minimum default design volume flow in m3/hr for zero-flow compressors.
      See Also:
  • Constructor Details

    • Compressor

      public Compressor(String name)
      Constructor for Compressor.
      Parameters:
      name - Name of compressor
    • Compressor

      public Compressor(String name, StreamInterface inletStream)

      Constructor for Compressor.

      Parameters:
      name - a String object
      inletStream - a StreamInterface object
    • Compressor

      public Compressor(String name, boolean interpolateMapLookup)

      Constructor for Compressor.

      Parameters:
      name - Name of compressor
      interpolateMapLookup - a boolean
  • Method Details

    • getMechanicalDesign

      public CompressorMechanicalDesign getMechanicalDesign()

      Get a mechanicalDesign for the equipment.

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

      public void initMechanicalDesign()

      Initialize a initMechanicalDesign for the equipment.

      Specified by:
      initMechanicalDesign in interface ProcessEquipmentInterface
      Overrides:
      initMechanicalDesign in class ProcessEquipmentBaseClass
    • getMechanicalLosses

      public CompressorMechanicalLosses getMechanicalLosses()
      Get the mechanical losses model for seal gas and bearing calculations.
      Returns:
      mechanical losses model, or null if not configured
    • setMechanicalLosses

      public void setMechanicalLosses(CompressorMechanicalLosses mechanicalLosses)
      Set the mechanical losses model.
      Parameters:
      mechanicalLosses - the mechanical losses model
    • initMechanicalLosses

      public CompressorMechanicalLosses initMechanicalLosses()
      Initialize a default mechanical losses model based on current compressor configuration.

      This creates a mechanical losses model with typical parameters for a centrifugal compressor with dry gas seals and tilting pad bearings.

      Returns:
      the initialized mechanical losses model
    • initMechanicalLosses

      public CompressorMechanicalLosses initMechanicalLosses(double shaftDiameterMm)
      Initialize a mechanical losses model with specified shaft diameter.
      Parameters:
      shaftDiameterMm - shaft diameter in mm
      Returns:
      the initialized mechanical losses model
    • updateMechanicalLosses

      public void updateMechanicalLosses()
      Update mechanical losses model with current operating conditions.

      Call this after running the compressor to update seal gas consumption and bearing losses.

    • getSealGasConsumption

      public double getSealGasConsumption()
      Get total seal gas consumption including primary leakage, buffer gas, and separation gas.
      Returns:
      seal gas consumption in Nm³/hr, or 0.0 if mechanical losses not configured
    • getBearingLoss

      public double getBearingLoss()
      Get total bearing power loss.
      Returns:
      bearing power loss in kW, or 0.0 if mechanical losses not configured
    • getMechanicalEfficiency

      public double getMechanicalEfficiency()
      Get mechanical efficiency accounting for bearing and seal friction losses.
      Returns:
      mechanical efficiency (0-1), or 0.98 if mechanical losses not configured
    • copy

      public Compressor copy()
      Create deep copy.
      Overrides:
      copy in class ProcessEquipmentBaseClass
      Returns:
      a deep copy of the unit operation/process equipment
    • setInletStream

      public void setInletStream(StreamInterface inletStream)
      Set inlet Stream of twoport.
      Specified by:
      setInletStream in interface TwoPortInterface
      Overrides:
      setInletStream in class TwoPortEquipment
      Parameters:
      inletStream - value to set
    • solveAntiSurge

      public void solveAntiSurge()

      solveAntiSurge.

    • setOutletPressure

      public void setOutletPressure(double pressure)
      Set outlet pressure of twoport.
      Specified by:
      setOutletPressure in interface TwoPortInterface
      Overrides:
      setOutletPressure in class TwoPortEquipment
      Parameters:
      pressure - value to set in unit bara
    • setOutletPressure

      public void setOutletPressure(double pressure, String unit)

      setOutletPressure.

      Specified by:
      setOutletPressure in interface TwoPortInterface
      Overrides:
      setOutletPressure in class TwoPortEquipment
      Parameters:
      pressure - a double
      unit - a String object
    • getOutletPressure

      public double getOutletPressure()
      Get outlet pressure of twoport.
      Specified by:
      getOutletPressure in interface TwoPortInterface
      Overrides:
      getOutletPressure in class TwoPortEquipment
      Returns:
      outlet pressure of TwoPortEquipment in unit bara
    • getEnergy

      public double getEnergy()

      getEnergy.

      Specified by:
      getEnergy in interface CompressorInterface
      Returns:
      a double
    • getPower

      public double getPower()

      getPower.

      Returns:
      a double
    • getPower

      public double getPower(String unit)

      getPower.

      Parameters:
      unit - a String object
      Returns:
      a double
    • setPower

      public void setPower(double p)

      setPower.

      Parameters:
      p - a double
    • solveEfficiency

      public double solveEfficiency(double outTemperature)
      Calculates polytropic or isentropic efficiency by iteratively matching the specified outlet temperature. The iteration continues until the temperature difference is within the tolerance set by setEfficiencySolveTolerance(double) (default 0.01 K) or the maximum iteration count is reached.
      Parameters:
      outTemperature - the target outlet temperature in Kelvin
      Returns:
      the calculated efficiency (polytropic or isentropic depending on configuration)
      See Also:
    • findOutPressure

      public double findOutPressure(double hinn, double hout, double polytropicEfficiency)

      findOutPressure.

      Parameters:
      hinn - a double
      hout - a double
      polytropicEfficiency - a double
      Returns:
      a double
    • 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
      Parameters:
      id - UUID
    • useEnergyEfficiencyChart

      private boolean useEnergyEfficiencyChart()
    • setUseEnergyEfficiencyChart

      public void setUseEnergyEfficiencyChart(boolean useEnergyEfficiencyChart)
    • runTransient

      public void runTransient(double dt, UUID id)

      runTransient

      This method calculates thermodynamic and unit operations using difference equations if available and calculateSteadyState is true. Use setCalculateSteadyState to set the parameter. Sets calc identifier UUID.
      Specified by:
      runTransient in interface SimulationInterface
      Parameters:
      dt - Delta time [s]
      id - Calculation identifier
    • generateCompressorCurves

      public void generateCompressorCurves()

      generateCompressorCurves.

    • displayResult

      public void displayResult()

      displayResult.

      Specified by:
      displayResult in interface ProcessEquipmentInterface
      Overrides:
      displayResult in class ProcessEquipmentBaseClass
    • getResultTable

      public String[][] getResultTable()

      getResultTable.

      Specified by:
      getResultTable in interface ProcessEquipmentInterface
      Overrides:
      getResultTable in class ProcessEquipmentBaseClass
      Returns:
      an array of String objects
    • getTotalWork

      public double getTotalWork()

      getTotalWork.

      Returns:
      a double
    • getIsentropicEfficiency

      public double getIsentropicEfficiency()

      getIsentropicEfficiency.

      Specified by:
      getIsentropicEfficiency in interface CompressorInterface
      Returns:
      a double
    • setIsentropicEfficiency

      public void setIsentropicEfficiency(double isentropicEfficiency)

      setIsentropicEfficiency.

      Specified by:
      setIsentropicEfficiency in interface CompressorInterface
      Parameters:
      isentropicEfficiency - a double
    • usePolytropicCalc

      public boolean usePolytropicCalc()

      usePolytropicCalc.

      Returns:
      the usePolytropicCalc
    • setUsePolytropicCalc

      public void setUsePolytropicCalc(boolean usePolytropicCalc)

      Setter for the field usePolytropicCalc.

      Parameters:
      usePolytropicCalc - the usePolytropicCalc to set
    • getPolytropicEfficiency

      public double getPolytropicEfficiency()

      getPolytropicEfficiency.

      Specified by:
      getPolytropicEfficiency in interface CompressorInterface
      Returns:
      a double
    • setPolytropicEfficiency

      public void setPolytropicEfficiency(double polytropicEfficiency)

      setPolytropicEfficiency.

      Specified by:
      setPolytropicEfficiency in interface CompressorInterface
      Parameters:
      polytropicEfficiency - a double
    • getEfficiencySolveTolerance

      public double getEfficiencySolveTolerance()
      Get the temperature tolerance used for efficiency solving iterations.
      Returns:
      the efficiency solve tolerance in Kelvin
    • setEfficiencySolveTolerance

      public void setEfficiencySolveTolerance(double tolerance)
      Set the temperature tolerance used for efficiency solving iterations. A larger tolerance provides faster convergence when using computationally expensive equations of state like GERG-2008, while still providing good engineering accuracy.
      Parameters:
      tolerance - the temperature tolerance in Kelvin (default is 0.01 K)
    • getThermoSystem

      public SystemInterface getThermoSystem()

      getThermoSystem.

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

      public CompressorChartInterface getCompressorChart()

      Getter for the field compressorChart.

      Returns:
      a CompressorChartInterface object
    • setCompressorChart

      public void setCompressorChart(CompressorChartInterface compressorChart)

      Setter for the field compressorChart.

      Parameters:
      compressorChart - a CompressorChartInterface object
    • saveCompressorChartToCsv

      public void saveCompressorChartToCsv(String filePath) throws IOException
      Save compressor chart to a CSV file.

      The CSV format is compatible with CompressorChartReader for loading:

      speed;flow;head;polyEff
      2000.00;9598.75;33.36;78.30
      ...
      
      Parameters:
      filePath - the path to save the CSV file
      Throws:
      IOException - if file cannot be written
    • saveCompressorChartToJson

      public void saveCompressorChartToJson(String filePath) throws IOException
      Save compressor chart to a JSON file.

      The JSON format includes metadata (name, head unit, max design power) and is compatible with CompressorChartJsonReader for loading:

      {
        "compressorName": "Compressor Name",
        "headUnit": "kJ/kg",
        "maxDesignPower_kW": 16619.42,
        "speedCurves": [...]
      }
      
      Parameters:
      filePath - the path to save the JSON file
      Throws:
      IOException - if file cannot be written
    • loadCompressorChartFromCsv

      public void loadCompressorChartFromCsv(String filePath) throws Exception
      Load compressor chart from a CSV file.

      The CSV format should match the output of saveCompressorChartToCsv(String):

      speed;flow;head;polyEff
      2000.00;9598.75;33.36;78.30
      ...
      
      Parameters:
      filePath - the path to the CSV file
      Throws:
      Exception - if file cannot be read or parsed
    • loadCompressorChartFromJson

      public void loadCompressorChartFromJson(String filePath) throws Exception
      Load compressor chart from a JSON file.

      The JSON format should match the output of saveCompressorChartToJson(String). This method also restores the maxDesignPower if present in the JSON file.

      Parameters:
      filePath - the path to the JSON file
      Throws:
      Exception - if file cannot be read or parsed
    • loadCompressorChartFromJsonString

      public void loadCompressorChartFromJsonString(String jsonString) throws Exception
      Load compressor chart from a JSON string.
      Parameters:
      jsonString - the JSON string containing chart data
      Throws:
      Exception - if JSON cannot be parsed
    • getCompressorChartAsJson

      public String getCompressorChartAsJson()
      Get the compressor chart as a JSON string.
      Returns:
      JSON string representation of the compressor chart
    • getAntiSurge

      public AntiSurge getAntiSurge()

      getAntiSurge.

      Specified by:
      getAntiSurge in interface CompressorInterface
      Returns:
      a AntiSurge object
    • isSurge

      public boolean isSurge(double flow, double head)

      isSurge.

      Parameters:
      flow - a double
      head - a double
      Returns:
      a boolean
    • getDistanceToSurge

      public double getDistanceToSurge()

      getDistanceToSurge.

      Specified by:
      getDistanceToSurge in interface CompressorInterface
      Returns:
      a double
    • getSurgeFlowRateMargin

      public double getSurgeFlowRateMargin()

      getSurgeFlowRateMargin.

      Specified by:
      getSurgeFlowRateMargin in interface CompressorInterface
      Returns:
      a double
    • getSurgeFlowRate

      public double getSurgeFlowRate()

      getSurgeFlowRate.

      Specified by:
      getSurgeFlowRate in interface CompressorInterface
      Returns:
      a double
    • getSurgeFlowRateStd

      public double getSurgeFlowRateStd()
      Specified by:
      getSurgeFlowRateStd in interface CompressorInterface
    • isStoneWall

      public boolean isStoneWall()
      Description copied from interface: CompressorInterface

      isStoneWall.

      Specified by:
      isStoneWall in interface CompressorInterface
      Returns:
      a boolean
    • getDistanceToStoneWall

      public double getDistanceToStoneWall()
      Calculate the distance to the stone wall (choke) limit.

      Returns a positive value indicating the percentage margin to stone wall. For example, 0.5 means the stone wall is 50% above the current flow rate.

      For single speed compressors where the stone wall curve is not active, this method uses the maximum flow point at the current speed. For multi-speed compressors, it uses the stone wall curve interpolation.

      Returns:
      distance to stone wall as a ratio (stone wall flow / current flow - 1)
    • isStoneWall

      public boolean isStoneWall(double flow, double head)

      isStoneWall.

      Parameters:
      flow - a double
      head - a double
      Returns:
      a boolean
    • setAntiSurge

      public void setAntiSurge(AntiSurge antiSurge)

      Setter for the field antiSurge.

      Parameters:
      antiSurge - a AntiSurge object
    • getSafetyFactorCorrectedFlowHeadAtCurrentSpeed

      public double[] getSafetyFactorCorrectedFlowHeadAtCurrentSpeed()

      Get the safety-factor-corrected surge flow and head at the current compressor speed.

      This method returns the safe minimum operating point by applying the surge control factor (typically 1.05 for 5% margin) to the surge flow at the current speed. The head is calculated at this safe flow rate using the compressor chart. This is particularly useful for single speed compressors where speed cannot be adjusted to move away from surge.

      Returns:
      A double array with two elements: [0] = safe surge flow (m3/hr), [1] = head at safe flow (kJ/kg or meter depending on chart headUnit)
    • getSpeed

      public double getSpeed()

      Getter for the field speed.

      Returns:
      a double
    • isHigherThanMaxSpeed

      public boolean isHigherThanMaxSpeed()
      Check if the current compressor speed is higher than the maximum speed in the compressor curves.

      This method is useful for detecting when the compressor is operating outside its design envelope (requires speed extrapolation beyond the defined curves).

      Returns:
      true if the current speed exceeds the maximum curve speed, false otherwise
    • isHigherThanMaxSpeed

      public boolean isHigherThanMaxSpeed(double calculatedSpeed)
      Check if a calculated speed is higher than the maximum speed in the compressor curves.
      Parameters:
      calculatedSpeed - the speed to check in RPM
      Returns:
      true if the calculated speed exceeds the maximum curve speed, false otherwise
    • getRatioToMaxSpeed

      public double getRatioToMaxSpeed()
      Get the ratio of the current compressor speed to the maximum speed in the compressor curves.

      A ratio greater than 1.0 indicates the speed exceeds the maximum curve speed.

      Returns:
      the ratio speed/maxSpeedCurve (dimensionless), or NaN if chart not set
    • getRatioToMaxSpeed

      public double getRatioToMaxSpeed(double calculatedSpeed)
      Get the ratio of a calculated speed to the maximum speed in the compressor curves.
      Parameters:
      calculatedSpeed - the speed to compare in RPM
      Returns:
      the ratio calculatedSpeed/maxSpeedCurve (dimensionless), or NaN if chart not set
    • isLowerThanMinSpeed

      public boolean isLowerThanMinSpeed()
      Check if the current compressor speed is lower than the minimum speed in the compressor curves.

      This method is useful for detecting when the compressor is operating below its design envelope (requires speed extrapolation below the defined curves), which may indicate turndown issues.

      Returns:
      true if the current speed is below the minimum curve speed, false otherwise
    • isLowerThanMinSpeed

      public boolean isLowerThanMinSpeed(double calculatedSpeed)
      Check if a calculated speed is lower than the minimum speed in the compressor curves.
      Parameters:
      calculatedSpeed - the speed to check in RPM
      Returns:
      true if the calculated speed is below the minimum curve speed, false otherwise
    • getRatioToMinSpeed

      public double getRatioToMinSpeed()
      Get the ratio of the current compressor speed to the minimum speed in the compressor curves.

      A ratio less than 1.0 indicates the speed is below the minimum curve speed.

      Returns:
      the ratio speed/minSpeedCurve (dimensionless), or NaN if chart not set
    • getRatioToMinSpeed

      public double getRatioToMinSpeed(double calculatedSpeed)
      Get the ratio of a calculated speed to the minimum speed in the compressor curves.
      Parameters:
      calculatedSpeed - the speed to compare in RPM
      Returns:
      the ratio calculatedSpeed/minSpeedCurve (dimensionless), or NaN if chart not set
    • isSpeedWithinRange

      public boolean isSpeedWithinRange()
      Check if the current compressor speed is within the defined compressor curve speed range.
      Returns:
      true if the speed is within [minSpeedCurve, maxSpeedCurve], false otherwise
    • isSpeedWithinRange

      public boolean isSpeedWithinRange(double calculatedSpeed)
      Check if a calculated speed is within the defined compressor curve speed range.
      Parameters:
      calculatedSpeed - the speed to check in RPM
      Returns:
      true if the speed is within [minSpeedCurve, maxSpeedCurve], false otherwise
    • setSpeed

      public void setSpeed(double speed)

      Setter for the field speed.

      Parameters:
      speed - a int
    • getPolytropicHead

      public double getPolytropicHead(String unit)

      Getter for the field polytropicHead.

      Parameters:
      unit - a String object
      Returns:
      a double
    • getPolytropicHead

      public double getPolytropicHead()

      Getter for the field polytropicHead.

      Returns:
      a double
    • getPolytropicFluidHead

      public double getPolytropicFluidHead()

      Getter for the field polytropicFluidHead.

      Returns:
      a double
    • getPolytropicExponent

      public double getPolytropicExponent()

      Getter for the field polytropicExponent.

      Returns:
      a double
    • getPolytropicHeadMeter

      public double getPolytropicHeadMeter()

      Getter for the field polytropicHeadMeter.

      Returns:
      a double
    • setPolytropicHeadMeter

      public void setPolytropicHeadMeter(double polytropicHeadMeter)

      Setter for the field polytropicHeadMeter.

      Parameters:
      polytropicHeadMeter - a double
    • getOutTemperature

      public double getOutTemperature()

      Getter for the field outTemperature.

      Returns:
      outlet temperature in Kelvin
    • setOutletTemperature

      public void setOutletTemperature(double outTemperature)

      Set the outlet temperature of the compressor.

      Specified by:
      setOutletTemperature in interface TwoPortInterface
      Overrides:
      setOutletTemperature in class TwoPortEquipment
      Parameters:
      outTemperature - outlet temperature in Kelvin
    • setOutletTemperature

      public void setOutletTemperature(double temperature, String unit)

      Set the outlet temperature of the compressor with unit specification.

      Specified by:
      setOutletTemperature in interface TwoPortInterface
      Overrides:
      setOutletTemperature in class TwoPortEquipment
      Parameters:
      temperature - outlet temperature value
      unit - temperature unit (e.g., "K", "C", "R", "F")
    • setOutTemperature

      @Deprecated public void setOutTemperature(double outTemperature)
      Deprecated.

      Setter for the field outTemperature.

      Specified by:
      setOutTemperature in interface TwoPortInterface
      Parameters:
      outTemperature - outlet temperature in Kelvin
    • useOutTemperature

      public void useOutTemperature(boolean useOutTemperature)

      useOutTemperature.

      Parameters:
      useOutTemperature - a boolean
    • getNumberOfCompressorCalcSteps

      public int getNumberOfCompressorCalcSteps()

      Getter for the field numberOfCompressorCalcSteps.

      Returns:
      the number of calculation steps in compressor
    • setNumberOfCompressorCalcSteps

      public void setNumberOfCompressorCalcSteps(int numberOfCompressorCalcSteps)

      Setter for the field numberOfCompressorCalcSteps.

      Parameters:
      numberOfCompressorCalcSteps - a int
    • isUseRigorousPolytropicMethod

      public boolean isUseRigorousPolytropicMethod()

      isUseRigorousPolytropicMethod.

      Returns:
      a boolean
    • setUseRigorousPolytropicMethod

      public void setUseRigorousPolytropicMethod(boolean useRigorousPolytropicMethod)

      Setter for the field useRigorousPolytropicMethod.

      Parameters:
      useRigorousPolytropicMethod - a boolean
    • setPressure

      public void setPressure(double pressure)

      Setter for the field pressure.

      Specified by:
      setPressure in interface ProcessEquipmentInterface
      Overrides:
      setPressure in class ProcessEquipmentBaseClass
      Parameters:
      pressure - a double
    • setPressure

      public void setPressure(double pressure, String unit)

      Setter for the field pressure.

      Parameters:
      pressure - a double
      unit - a String object
    • getEntropyProduction

      public double getEntropyProduction(String unit)

      getEntropyProduction.

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

      public double getExergyChange(String unit, double surroundingTemperature)
      Get exergy change production of the process equipment.
      Specified by:
      getExergyChange in interface ProcessEquipmentInterface
      Overrides:
      getExergyChange in class ProcessEquipmentBaseClass
      Parameters:
      unit - Supported units are J and kJ
      surroundingTemperature - The surrounding temperature in Kelvin
      Returns:
      change in exergy in specified unit
    • getPolytropicMethod

      public String getPolytropicMethod()

      Getter for the field polytropicMethod.

      Returns:
      a String object
    • setPolytropicMethod

      public void setPolytropicMethod(String polytropicMethod)

      Setter for the field polytropicMethod.

      Parameters:
      polytropicMethod - a String object
    • isUseGERG2008

      public boolean isUseGERG2008()
      Getter for property useGERG2008.
      Returns:
      Value
    • setUseGERG2008

      public void setUseGERG2008(boolean useGERG2008)
      Setter for property useGERG2008.
      Parameters:
      useGERG2008 - Value to set
    • isUseLeachman

      public boolean isUseLeachman()
      Getter for property useLeachman.
      Returns:
      Value
    • setUseLeachman

      public void setUseLeachman(boolean useLeachman)
      Setter for property useLeachman.
      Parameters:
      useLeachman - Value to set
    • isUseVega

      public boolean isUseVega()
      Getter for property useVega.
      Returns:
      Value
    • setUseVega

      public void setUseVega(boolean useVega)
      Setter for property useVega.
      Parameters:
      useVega - Value to set
    • getPropertyProfile

      public CompressorPropertyProfile getPropertyProfile()

      Getter for the field propertyProfile.

      Returns:
      a CompressorPropertyProfile object
    • setPropertyProfile

      public void setPropertyProfile(CompressorPropertyProfile propertyProfile)

      Setter for the field propertyProfile.

      Parameters:
      propertyProfile - a CompressorPropertyProfile object
    • runController

      public void runController(double dt, UUID id)

      runController.

      Parameters:
      dt - a double
      id - Calculation identifier
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface ProcessEquipmentInterface
      Overrides:
      hashCode in class ProcessEquipmentBaseClass
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface ProcessEquipmentInterface
      Overrides:
      equals in class ProcessEquipmentBaseClass
    • setMaximumSpeed

      public void setMaximumSpeed(double maxSpeed)

      setMaximumSpeed.

      Specified by:
      setMaximumSpeed in interface CompressorInterface
      Parameters:
      maxSpeed - a double
    • setMinimumSpeed

      public void setMinimumSpeed(double minspeed)

      setMinimumSpeed.

      Specified by:
      setMinimumSpeed in interface CompressorInterface
      Parameters:
      minspeed - a double
    • getMaximumSpeed

      public double getMaximumSpeed()

      getMaximumSpeed.

      Specified by:
      getMaximumSpeed in interface CompressorInterface
      Returns:
      a double
    • getMinimumSpeed

      public double getMinimumSpeed()

      getMinimumSpeed.

      Specified by:
      getMinimumSpeed in interface CompressorInterface
      Returns:
      a double
    • setCompressionRatio

      public void setCompressionRatio(double compRatio)

      Setter for the field compressionRatio.

      Parameters:
      compRatio - a double
    • getCompressionRatio

      public double getCompressionRatio()

      Getter for the field compressionRatio.

      Returns:
      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 TwoPortEquipment
      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 TwoPortEquipment
      Parameters:
      cfg - report configuration
      Returns:
      json string
    • getMaxOutletPressure

      public double getMaxOutletPressure()

      Getter for the field maxOutletPressure.

      Returns:
      a double
    • setMaxOutletPressure

      public void setMaxOutletPressure(double maxOutletPressure)

      Setter for the field maxOutletPressure.

      Parameters:
      maxOutletPressure - a double
    • isSetMaxOutletPressure

      public boolean isSetMaxOutletPressure()

      isSetMaxOutletPressure.

      Returns:
      a boolean
    • setIsSetMaxOutletPressure

      public void setIsSetMaxOutletPressure(boolean isSetMaxOutletPressure)

      Setter for the field isSetMaxOutletPressure.

      Parameters:
      isSetMaxOutletPressure - a boolean
    • getMaxDischargeTemperature

      public double getMaxDischargeTemperature()
      Gets the maximum discharge temperature.
      Returns:
      maximum discharge temperature in Kelvin
    • getMaxDischargeTemperature

      public double getMaxDischargeTemperature(String unit)
      Gets the maximum discharge temperature in specified unit.
      Parameters:
      unit - temperature unit ("K", "C", or "F")
      Returns:
      maximum discharge temperature in specified unit
    • setMaxDischargeTemperature

      public void setMaxDischargeTemperature(double temp, String unit)
      Sets the maximum discharge temperature constraint.

      This value is used by the capacity constraint framework to track discharge temperature utilization. When the actual discharge temperature exceeds this limit, the compressor will be flagged as over-utilized.

      Parameters:
      temp - maximum discharge temperature
      unit - temperature unit ("K", "C", or "F")
    • setMaxDischargeTemperature

      public void setMaxDischargeTemperature(double tempKelvin)
      Sets the maximum discharge temperature in Kelvin.
      Parameters:
      tempKelvin - maximum discharge temperature in Kelvin
    • isSetMaxDischargeTemperature

      public boolean isSetMaxDischargeTemperature()
      Checks if maximum discharge temperature has been explicitly set.
      Returns:
      true if max discharge temperature is set
    • getActualCompressionRatio

      public double getActualCompressionRatio()

      Getter for the field actualCompressionRatio.

      Returns:
      a double
    • setCompressorChartType

      public void setCompressorChartType(String type)

      Set CompressorChartType

      Specified by:
      setCompressorChartType in interface CompressorInterface
      Parameters:
      type - a String object
    • generateCompressorChart

      public void generateCompressorChart()
      Generates a compressor chart based on the current operating point.

      This is a convenience method that creates a single-speed compressor chart using the compressor's current speed and operating conditions. The chart type will match the compressor's current chart type setting.

      Example usage:

      compressor.setSpeed(10000);
      compressor.run();
      compressor.generateCompressorChart(); // Generates chart at current speed
      
    • generateCompressorChart

      public void generateCompressorChart(int numberOfSpeeds)
      Generates a compressor chart with multiple speed curves.

      Creates a multi-speed compressor chart centered around the current speed. The speeds are distributed from 80% to 120% of the current speed.

      Parameters:
      numberOfSpeeds - Number of speed curves to generate (must be at least 1)
    • generateCompressorChart

      public void generateCompressorChart(String generationOption)
      Generates a compressor chart with specified options.

      Available generation options:

      • "normal curves" - Standard 5-point curves with surge, design, and stonewall points
      • "mid range" - 3-point simplified curves
      Parameters:
      generationOption - The generation option to use
    • generateCompressorChart

      public void generateCompressorChart(String generationOption, int numberOfSpeeds)
      Generates a compressor chart with specified options and number of speeds.

      This is the main chart generation method that provides full control over the generated chart. The generated chart will automatically use the compressor's current chart type (simple, interpolate, or interpolate and extrapolate).

      Example usage:

      // Generate 5-speed chart with normal curves
      compressor.generateCompressorChart("normal curves", 5);
      
      // Generate 3-speed chart with simplified curves
      compressor.generateCompressorChart("mid range", 3);
      
      Parameters:
      generationOption - The generation option: "normal curves" or "mid range"
      numberOfSpeeds - Number of speed curves to generate (must be at least 1)
    • generateCompressorChartFromTemplate

      public void generateCompressorChartFromTemplate(String templateName, int numberOfSpeeds)
      Generates a compressor chart from a predefined template.

      Templates provide realistic compressor curve shapes based on typical compressor characteristics. Available templates:

      • "CENTRIFUGAL_STANDARD" - Standard centrifugal compressor curves
      • "CENTRIFUGAL_HIGH_FLOW" - High flow, lower head compressor
      • "CENTRIFUGAL_HIGH_HEAD" - High head, narrower operating range

      Example usage:

      compressor.generateCompressorChartFromTemplate("CENTRIFUGAL_STANDARD", 9);
      
      Parameters:
      templateName - Name of the template to use
      numberOfSpeeds - Number of speed curves to generate
    • generateCompressorChart

      public void generateCompressorChart(String generationOption, double[] speeds)
      Generates a compressor chart with specific speed values.

      This method allows precise control over which speeds are included in the chart.

      Parameters:
      generationOption - The generation option: "normal curves" or "mid range"
      speeds - Array of speed values in RPM
    • getCompressorChartType

      public String getCompressorChartType()
      Gets the current compressor chart type as a string.
      Returns:
      The chart type: "simple", "interpolate", or "interpolate and extrapolate"
    • isSolveSpeed

      public boolean isSolveSpeed()

      isSolveSpeed.

      Returns:
      a boolean
    • setSolveSpeed

      public void setSolveSpeed(boolean solveSpeed)

      Setter for the field solveSpeed.

      Parameters:
      solveSpeed - a boolean
    • isCalcPressureOut

      public boolean isCalcPressureOut()

      isCalcPressureOut.

      Returns:
      a boolean
    • setCalcPressureOut

      public void setCalcPressureOut(boolean calcPressureOut)

      Setter for the field calcPressureOut.

      Parameters:
      calcPressureOut - a boolean
    • isLimitSpeed

      public boolean isLimitSpeed()
      Checks if the compressor speed is limited.
      Returns:
      true if the compressor speed is limited, false otherwise.
    • setLimitSpeed

      public void setLimitSpeed(boolean limitSpeed)
      Sets whether the compressor speed should be limited.
      Parameters:
      limitSpeed - true to limit the compressor speed, false otherwise.
    • getExergyChange

      public double getExergyChange(String unit)

      getExergyChange.

      Specified by:
      getExergyChange in interface ProcessEquipmentInterface
      Parameters:
      unit - a String object
      Returns:
      a double
    • getCapacityDuty

      public double getCapacityDuty()

      getCapacityDuty.

      For compressors, capacity duty is defined as the total shaft work (power consumption) in Watts. This is used in conjunction with getCapacityMax() for bottleneck analysis via ProcessSystem.getBottleneck().

      For more detailed constraint analysis including speed and surge limits, use the CapacityConstrainedEquipment interface methods.

      Specified by:
      getCapacityDuty in interface ProcessEquipmentInterface
      Returns:
      shaft power in Watts
    • getCapacityMax

      public double getCapacityMax()

      getCapacityMax.

      For compressors, maximum capacity is determined in priority order:

      1. Driver speed-dependent max power curve (if driver and speed are set)
      2. Mechanical design maximum power
      3. Driver rated power with 10% overload margin
      Specified by:
      getCapacityMax in interface ProcessEquipmentInterface
      Returns:
      maximum design power in Watts (converted from kW if from driver)
    • 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:

      • inlet_pressure - Inlet pressure [bar]
      • outlet_pressure - Outlet pressure [bar]
      • inlet_temperature - Inlet temperature [K]
      • outlet_temperature - Outlet temperature [K]
      • compression_ratio - Compression ratio [-]
      • polytropic_efficiency - Polytropic efficiency [fraction]
      • isentropic_efficiency - Isentropic efficiency [fraction]
      • power - Shaft power [kW]
      • speed - Rotational speed [rpm]
      • surge_margin - Distance to surge [%]
      • polytropic_head - Polytropic head [kJ/kg]
      • inlet_flow - Inlet mass flow [kg/s]
      Specified by:
      getStateVector in interface StateVectorProvider
      Returns:
      current state vector
    • getOperatingState

      public CompressorState getOperatingState()
      Get the current operating state of the compressor.
      Returns:
      the current CompressorState
    • setOperatingState

      public void setOperatingState(CompressorState state)
      Set the operating state of the compressor.
      Parameters:
      state - the new operating state
    • getDriver

      public CompressorDriver getDriver()
      Get the compressor driver model.
      Returns:
      the driver model, or null if not set
    • setDriver

      public void setDriver(CompressorDriver driver)
      Set the compressor driver model.

      Setting a new driver will reinitialize capacity constraints to incorporate the driver's rated speed limit into the speed constraint.

      Parameters:
      driver - the driver model
    • setDriver

      public void setDriver(DriverType type, double ratedPower)
      Create and set a new driver with specified type and rated power.

      Setting a new driver will reinitialize capacity constraints to incorporate the driver's rated speed limit into the speed constraint.

      Parameters:
      type - driver type
      ratedPower - rated power in kW
    • getOperatingHistory

      public CompressorOperatingHistory getOperatingHistory()
      Get the operating history tracker.
      Returns:
      the operating history, or null if not enabled
    • enableOperatingHistory

      public void enableOperatingHistory()
      Enable operating history tracking.
    • disableOperatingHistory

      public void disableOperatingHistory()
      Disable operating history tracking.
    • recordOperatingPoint

      public void recordOperatingPoint(double time)
      Record the current operating point to history.
      Parameters:
      time - simulation time in seconds
    • getStartupProfile

      public StartupProfile getStartupProfile()
      Get the startup profile.
      Returns:
      the startup profile, or null if not set
    • setStartupProfile

      public void setStartupProfile(StartupProfile profile)
      Set the startup profile.
      Parameters:
      profile - the startup profile
    • getShutdownProfile

      public ShutdownProfile getShutdownProfile()
      Get the shutdown profile.
      Returns:
      the shutdown profile, or null if not set
    • setShutdownProfile

      public void setShutdownProfile(ShutdownProfile profile)
      Set the shutdown profile.
      Parameters:
      profile - the shutdown profile
    • addEventListener

      public void addEventListener(CompressorEventListener listener)
      Add an event listener for compressor events.
      Parameters:
      listener - the event listener to add
    • removeEventListener

      public void removeEventListener(CompressorEventListener listener)
      Remove an event listener.
      Parameters:
      listener - the event listener to remove
    • getRotationalInertia

      public double getRotationalInertia()
      Get the rotational inertia of the compressor rotor.
      Returns:
      inertia in kg⋅m²
    • setRotationalInertia

      public void setRotationalInertia(double inertia)
      Set the rotational inertia of the compressor rotor.
      Parameters:
      inertia - inertia in kg⋅m²
    • getMaxAccelerationRate

      public double getMaxAccelerationRate()
      Get the maximum acceleration rate.
      Returns:
      max acceleration in RPM/s
    • setMaxAccelerationRate

      public void setMaxAccelerationRate(double rate)
      Set the maximum acceleration rate.
      Parameters:
      rate - max acceleration in RPM/s
    • getMaxDecelerationRate

      public double getMaxDecelerationRate()
      Get the maximum deceleration rate.
      Returns:
      max deceleration in RPM/s
    • setMaxDecelerationRate

      public void setMaxDecelerationRate(double rate)
      Set the maximum deceleration rate.
      Parameters:
      rate - max deceleration in RPM/s
    • getTargetSpeed

      public double getTargetSpeed()
      Get the target speed for dynamic control.
      Returns:
      target speed in RPM
    • setTargetSpeed

      public void setTargetSpeed(double speed)
      Set the target speed for dynamic control.
      Parameters:
      speed - target speed in RPM
    • isAutoSpeedMode

      public boolean isAutoSpeedMode()
      Check if auto-speed mode is enabled.

      In auto-speed mode, the compressor automatically calculates the required speed from the current operating point (flow and head) using the compressor chart.

      Returns:
      true if auto-speed mode is enabled
    • setAutoSpeedMode

      public void setAutoSpeedMode(boolean enabled)
      Enable or disable auto-speed mode.
      Parameters:
      enabled - true to enable auto-speed mode
    • getDegradationFactor

      public double getDegradationFactor()
      Get the performance degradation factor.
      Returns:
      degradation factor (1.0 = new, less than 1.0 = degraded)
    • setDegradationFactor

      public void setDegradationFactor(double factor)
      Set the performance degradation factor.
      Parameters:
      factor - degradation factor (1.0 = new, less than 1.0 = degraded)
    • getFoulingFactor

      public double getFoulingFactor()
      Get the fouling factor.
      Returns:
      fouling factor (0 = clean, higher = more fouled)
    • setFoulingFactor

      public void setFoulingFactor(double factor)
      Set the fouling factor.
      Parameters:
      factor - fouling factor (0 = clean, higher = more fouled)
    • getOperatingHours

      public double getOperatingHours()
      Get the total operating hours.
      Returns:
      operating hours
    • setOperatingHours

      public void setOperatingHours(double hours)
      Set the total operating hours.
      Parameters:
      hours - operating hours
    • addOperatingHours

      public void addOperatingHours(double hours)
      Add operating time.
      Parameters:
      hours - hours to add
    • getSurgeWarningThreshold

      public double getSurgeWarningThreshold()
      Get the surge warning threshold.
      Returns:
      threshold as ratio (e.g., 0.15 = 15% margin)
    • setSurgeWarningThreshold

      public void setSurgeWarningThreshold(double threshold)
      Set the surge warning threshold.
      Parameters:
      threshold - threshold as ratio
    • getSurgeCriticalThreshold

      public double getSurgeCriticalThreshold()
      Get the surge critical threshold.
      Returns:
      threshold as ratio (e.g., 0.05 = 5% margin)
    • setSurgeCriticalThreshold

      public void setSurgeCriticalThreshold(double threshold)
      Set the surge critical threshold.
      Parameters:
      threshold - threshold as ratio
    • getStoneWallWarningThreshold

      public double getStoneWallWarningThreshold()
      Get the stone wall warning threshold.
      Returns:
      threshold as ratio
    • setStoneWallWarningThreshold

      public void setStoneWallWarningThreshold(double threshold)
      Set the stone wall warning threshold.
      Parameters:
      threshold - threshold as ratio
    • checkSurgeMargin

      public void checkSurgeMargin()
      Check surge margin and fire events if thresholds are crossed.
    • checkStoneWallMargin

      public void checkStoneWallMargin()
      Check stone wall margin and fire events if threshold is crossed.
    • checkSpeedLimits

      public void checkSpeedLimits()
      Check speed limits and fire events if limits are exceeded.
    • checkPowerLimits

      public void checkPowerLimits()
      Check driver power limits and fire events if limits are exceeded.
    • startCompressor

      public void startCompressor(double targetOperatingSpeed)
      Start the compressor following the startup profile.
      Parameters:
      targetOperatingSpeed - the final target speed in RPM
    • stopCompressor

      public void stopCompressor(ShutdownProfile.ShutdownType type)
      Stop the compressor following the shutdown profile.
      Parameters:
      type - the type of shutdown
    • stopCompressor

      public void stopCompressor()
      Normal shutdown.
    • emergencyShutdown

      public void emergencyShutdown()
      Emergency shutdown (ESD).
    • updateDynamicState

      public void updateDynamicState(double timeStep)
      Update the compressor state during a transient simulation step.

      This method should be called during dynamic simulation to update the compressor speed, state, and fire appropriate events.

      Parameters:
      timeStep - the time step in seconds
    • updateStartup

      private void updateStartup(double timeStep)
      Update startup sequence.
      Parameters:
      timeStep - time step in seconds
    • updateShutdown

      private void updateShutdown(double timeStep)
      Update shutdown sequence.
      Parameters:
      timeStep - time step in seconds
    • updateSpeedWithInertia

      private void updateSpeedWithInertia(double targetSpd, double timeStep)
      Update speed considering inertia constraints.
      Parameters:
      targetSpd - target speed in RPM
      timeStep - time step in seconds
    • updateAutoSpeed

      private void updateAutoSpeed()
      Update speed automatically based on operating point.
    • getEffectivePolytropicHead

      public double getEffectivePolytropicHead()
      Get the effective polytropic head accounting for degradation.
      Returns:
      effective head in kJ/kg
    • getEffectivePolytropicEfficiency

      public double getEffectivePolytropicEfficiency()
      Get the effective efficiency accounting for degradation.
      Returns:
      effective polytropic efficiency
    • fireSurgeApproachEvent

      private void fireSurgeApproachEvent(double surgeMargin, boolean isCritical)
      Fire surge approach event to all listeners.
      Parameters:
      surgeMargin - current surge margin
      isCritical - true if critical threshold
    • fireSurgeOccurredEvent

      private void fireSurgeOccurredEvent(double surgeMargin)
      Fire surge occurred event.
      Parameters:
      surgeMargin - current surge margin
    • fireSpeedLimitExceededEvent

      private void fireSpeedLimitExceededEvent(double currentSpeed, double ratio)
      Fire speed limit exceeded event.
      Parameters:
      currentSpeed - current speed
      ratio - ratio to max speed
    • fireSpeedBelowMinimumEvent

      private void fireSpeedBelowMinimumEvent(double currentSpeed, double ratio)
      Fire speed below minimum event.
      Parameters:
      currentSpeed - current speed
      ratio - ratio to min speed
    • firePowerLimitExceededEvent

      private void firePowerLimitExceededEvent(double currentPower, double maxPower)
      Fire power limit exceeded event.
      Parameters:
      currentPower - current power in kW
      maxPower - max available power in kW
    • fireStateChangeEvent

      private void fireStateChangeEvent(CompressorState oldState, CompressorState newState)
      Fire state change event.
      Parameters:
      oldState - previous state
      newState - new state
    • fireStoneWallApproachEvent

      private void fireStoneWallApproachEvent(double stoneWallMargin)
      Fire stone wall approach event.
      Parameters:
      stoneWallMargin - margin to stone wall
    • fireStartupCompleteEvent

      private void fireStartupCompleteEvent()
      Fire startup complete event.
    • fireShutdownCompleteEvent

      private void fireShutdownCompleteEvent()
      Fire shutdown complete event.
    • acknowledgeTrip

      public void acknowledgeTrip()
      Acknowledge a tripped compressor to allow restart.
    • resetDynamicState

      public void resetDynamicState()
      Reset all dynamic simulation state.
    • initializeCapacityConstraints

      protected void initializeCapacityConstraints()
      Initializes default capacity constraints for this compressor.

      Creates constraints for speed, power, and surge margin based on the compressor's design parameters. Additional constraints can be added after construction.

    • reinitializeCapacityConstraints

      public void reinitializeCapacityConstraints()
      Reinitializes capacity constraints with current configuration.

      Call this method after setting compressor charts or changing speed limits to update the constraints with the new values. This clears existing constraints and recreates them based on current settings.

    • ensureCapacityConstraintsInitialized

      private void ensureCapacityConstraintsInitialized()
      Ensures the capacity constraints map is initialized. Called after deserialization since the map is transient.
    • 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
      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
      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
      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
      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
      Returns:
      maximum utilization as fraction (1.0 = 100% of design capacity)
    • isSimulationValid

      public boolean isSimulationValid()
      Checks if the current simulation result is physically valid.

      Returns false if calculated values are outside physically possible ranges. This method should be overridden by specific equipment types to perform equipment-specific validation. For example:

      • Compressor: power must be positive, head must be positive
      • Heat exchanger: duty direction must match temperature change
      • Separator: phase fractions must sum to 1.0

      Validates that the compressor simulation produced physically reasonable results. Checks for:

      • Positive power consumption (compressors consume energy)
      • Positive polytropic head (work done on gas)
      • Outlet temperature greater than inlet (compression heats gas)
      • Pressure ratio greater than 1.0
      • Non-NaN values for key properties
      • Speed within compressor chart limits (if chart is active)
      • Operating point not in surge region (if surge curve is defined)
      • Operating point not beyond stonewall/choke (if stonewall curve is defined)
      Specified by:
      isSimulationValid in interface ProcessEquipmentInterface
      Returns:
      true if simulation results are physically valid, false otherwise
    • getSimulationValidationErrors

      public List<String> getSimulationValidationErrors()
      Gets validation errors for the current simulation state.

      Returns a list of human-readable error messages describing why the simulation result is invalid. Returns an empty list if the simulation is valid.

      Returns detailed validation errors for the compressor simulation.

      Specified by:
      getSimulationValidationErrors in interface ProcessEquipmentInterface
      Returns:
      list of validation error messages, empty if valid
    • isWithinOperatingEnvelope

      public boolean isWithinOperatingEnvelope()
      Checks if the equipment is operating within its valid operating envelope.

      This is different from capacity utilization - it checks whether the equipment can physically operate at the current conditions, not whether it's operating efficiently. For example:

      • Compressor: checks if between surge and stonewall
      • Pump: checks if above minimum flow (no cavitation)
      • Heat exchanger: checks if approach temperature is positive

      Checks if the compressor is operating within its valid envelope (between surge and stonewall).

      Specified by:
      isWithinOperatingEnvelope in interface ProcessEquipmentInterface
      Returns:
      true if operating within valid envelope
    • getOperatingEnvelopeViolation

      public String getOperatingEnvelopeViolation()
      Gets the reason why equipment is outside its operating envelope.
      Specified by:
      getOperatingEnvelopeViolation in interface ProcessEquipmentInterface
      Returns:
      description of envelope violation, or null if within envelope
    • 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
      Parameters:
      constraint - the constraint to add
    • removeCapacityConstraint

      public boolean removeCapacityConstraint(String constraintName)
      Removes a capacity constraint by name.
      Specified by:
      removeCapacityConstraint in interface CapacityConstrainedEquipment
      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
    • updateSpeedConstraint

      public void updateSpeedConstraint(double designSpeed, double maximumSpeed)
      Updates the speed constraint design values.

      Call this method after setting design speed and maximum speed to update the constraint.

      Parameters:
      designSpeed - the design speed in RPM
      maximumSpeed - the maximum allowable speed in RPM
    • updatePowerConstraint

      public void updatePowerConstraint(double driverPowerRating)
      Updates the power constraint design value based on driver rating.
      Parameters:
      driverPowerRating - the driver power rating in kW
    • 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
      Parameters:
      safetyFactor - multiplier for design capacity, typically 1.1-1.3 (10-30% over design)
    • autoSize

      public void autoSize()
      Automatically size using default safety factor (1.2 = 20% margin).
      Specified by:
      autoSize in interface AutoSizeable
    • autoSize

      public void autoSize(String company, String trDocument)
      Automatically size using company-specific design standards.

      This method applies design rules from the specified company's technical requirements (TR) documents. The standards are loaded from the NeqSim design database.

      Specified by:
      autoSize in interface AutoSizeable
      Parameters:
      company - company name (e.g., "Equinor", "Shell", "TotalEnergies")
      trDocument - TR document reference (e.g., "TR2000", "DEP-31.38.01.11")
    • isAutoSized

      public boolean isAutoSized()
      Check if equipment has been auto-sized.
      Specified by:
      isAutoSized in interface AutoSizeable
      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
      Returns:
      formatted sizing report string
    • getSizingReportJson

      public String getSizingReportJson()
      Get sizing report as JSON for programmatic access.
      Specified by:
      getSizingReportJson in interface AutoSizeable
      Returns:
      JSON string with sizing data
    • setCurveTemplate

      public void setCurveTemplate(String template)
      Set the curve template to use for auto-sizing.

      Available templates:

      • "CENTRIFUGAL_STANDARD" - Standard centrifugal compressor (default)
      • "CENTRIFUGAL_HIGH_FLOW" - High flow, lower head compressor
      • "CENTRIFUGAL_HIGH_HEAD" - High head, narrower operating range
      • "PIPELINE" - Pipeline/export compressor
      • "EXPORT" - Offshore export compressor
      • "INJECTION" - Gas injection compressor
      • "GAS_LIFT" - Gas lift compressor
      • "REFRIGERATION" - Refrigeration compressor
      • "BOOSTER" - Booster compressor
      Parameters:
      template - the template name
    • getCurveTemplate

      public String getCurveTemplate()
      Get the curve template used for auto-sizing.
      Returns:
      the template name
    • setNumberOfSpeedCurves

      public void setNumberOfSpeedCurves(int numberOfCurves)
      Set the number of speed curves to generate during auto-sizing.
      Parameters:
      numberOfCurves - number of curves (typically 3-9)
    • getNumberOfSpeedCurves

      public int getNumberOfSpeedCurves()
      Get the number of speed curves generated during auto-sizing.
      Returns:
      number of speed curves
    • selectTemplateForApplication

      private void selectTemplateForApplication()
      Select an appropriate curve template based on operating conditions. Called during autoSize(company, trDocument) to pick a suitable template.
    • builder

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

      Example usage:

      Compressor comp = Compressor.builder("K-100").inletStream(feed).outletPressure(50.0, "bara")
          .polytropicEfficiency(0.75).speed(8000).build();
      
      Parameters:
      name - the name of the compressor
      Returns:
      a new Builder instance