Class CompressorChartMWInterpolation

java.lang.Object
neqsim.process.equipment.compressor.CompressorChart
neqsim.process.equipment.compressor.CompressorChartMWInterpolation
All Implemented Interfaces:
Serializable, Cloneable, CompressorChartInterface

public class CompressorChartMWInterpolation extends CompressorChart
Compressor chart with multiple performance maps at different molecular weights.

This class allows storing multiple compressor maps, each measured at a different molecular weight (or gas composition), and interpolates between them based on the actual operating molecular weight.

Use case: When compressor maps are measured at several discrete MW values (e.g., 18, 20, 22 g/mol), this class interpolates the performance parameters (head, efficiency) for an actual MW that falls between the measured values.

Interpolation method: Linear interpolation between the two nearest MW maps. Extrapolation uses the nearest boundary map.

Version:
1.0
Author:
NeqSim Development Team
See Also:
  • Field Details

    • serialVersionUID

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

      private static final org.apache.logging.log4j.Logger logger
      Logger object for class.
    • mapMolecularWeights

      private List<Double> mapMolecularWeights
      List of MW values for which maps are defined, sorted in ascending order.
    • mapCharts

      private List<CompressorChart> mapCharts
      List of compressor charts corresponding to each MW.
    • operatingMW

      private double operatingMW
      Current operating molecular weight for interpolation.
    • interpolationEnabled

      private boolean interpolationEnabled
      Flag indicating if interpolation is needed.
    • autoGenerateSurgeCurves

      private boolean autoGenerateSurgeCurves
      Flag to auto-generate surge curves when maps are added.
    • autoGenerateStoneWallCurves

      private boolean autoGenerateStoneWallCurves
      Flag to auto-generate stone wall curves when maps are added.
    • allowExtrapolation

      private boolean allowExtrapolation
      Flag to allow extrapolation outside the MW range.
    • useActualMW

      private boolean useActualMW
      Flag to automatically use the inlet stream's molecular weight.
    • inletStream

      private transient StreamInterface inletStream
      Reference to inlet stream for automatic MW detection.
  • Constructor Details

    • CompressorChartMWInterpolation

      public CompressorChartMWInterpolation()
      Default constructor for CompressorChartMWInterpolation.
  • Method Details

    • addMapAtMW

      public void addMapAtMW(double molecularWeight, double[] chartConditions, double[] speed, double[][] flow, double[][] head, double[][] polyEff)
      Add a compressor map at a specific molecular weight.

      Multiple maps can be added at different MW values. The maps are stored sorted by MW.

      Parameters:
      molecularWeight - the molecular weight (g/mol) at which this map was measured
      chartConditions - reference conditions [temp °C, pres bara, density kg/m³, MW g/mol]
      speed - array of speed values (RPM)
      flow - 2D array of flow values for each speed curve (m³/hr)
      head - 2D array of head values for each speed curve (kJ/kg or meter)
      polyEff - 2D array of polytropic efficiency values for each speed curve (%)
    • addMapAtMW

      public void addMapAtMW(double molecularWeight, double[] speed, double[][] flow, double[][] head, double[][] polyEff)
      Add a multi-speed compressor map at a specific molecular weight.

      Convenience method without chartConditions - uses default conditions based on MW.

      Parameters:
      molecularWeight - the molecular weight (g/mol) at which this map was measured
      speed - array of speed values (RPM)
      flow - 2D array of flow values for each speed curve (m³/hr)
      head - 2D array of head values for each speed curve (kJ/kg or meter)
      polyEff - 2D array of polytropic efficiency values for each speed curve (%)
    • addMapAtMW

      public void addMapAtMW(double molecularWeight, double[] speed, double[][] flow, double[][] head, double[][] flowPolyEff, double[][] polyEff)
      Add a multi-speed compressor map at a specific molecular weight with separate flow arrays.

      Convenience method without chartConditions - uses default conditions based on MW.

      Parameters:
      molecularWeight - the molecular weight (g/mol) at which this map was measured
      speed - array of speed values (RPM)
      flow - 2D array of flow values for head curves (m³/hr)
      head - 2D array of head values for each speed curve (kJ/kg or meter)
      flowPolyEff - 2D array of flow values for efficiency curves (m³/hr)
      polyEff - 2D array of polytropic efficiency values for each speed curve (%)
    • addMapAtMW

      public void addMapAtMW(double molecularWeight, double speed, double[] flow, double[] head, double[] polyEff)
      Add a single-speed compressor map at a specific molecular weight.

      This is a convenience method for single-speed compressors where flow, head, and efficiency are 1D arrays for a single speed curve.

      Parameters:
      molecularWeight - the molecular weight (g/mol) at which this map was measured
      speed - the compressor speed (RPM)
      flow - array of flow values (m³/hr)
      head - array of head values (kJ/kg or meter)
      polyEff - array of polytropic efficiency values (%)
    • addMapAtMW

      public void addMapAtMW(double molecularWeight, double speed, double[] flow, double[] head, double[] flowPolyEff, double[] polyEff)
      Add a single-speed compressor map at a specific molecular weight with separate flow arrays.

      This is a convenience method for single-speed compressors where efficiency is measured at different flow points than head.

      Parameters:
      molecularWeight - the molecular weight (g/mol) at which this map was measured
      speed - the compressor speed (RPM)
      flow - array of flow values for head curve (m³/hr)
      head - array of head values (kJ/kg or meter)
      flowPolyEff - array of flow values for efficiency curve (m³/hr)
      polyEff - array of polytropic efficiency values (%)
    • addMapAtMW

      public void addMapAtMW(double molecularWeight, double[] chartConditions, double[] speed, double[][] flow, double[][] head, double[][] flowPolyEff, double[][] polyEff)
      Add a compressor map at a specific molecular weight.

      Multiple maps can be added at different MW values. The maps are stored sorted by MW.

      Parameters:
      molecularWeight - the molecular weight (g/mol) at which this map was measured
      chartConditions - reference conditions [temp °C, pres bara, density kg/m³, MW g/mol]
      speed - array of speed values (RPM)
      flow - 2D array of flow values for each speed curve (m³/hr)
      head - 2D array of head values for each speed curve (kJ/kg or meter)
      flowPolyEff - 2D array of flow values for efficiency curves (m³/hr)
      polyEff - 2D array of polytropic efficiency values for each speed curve (%)
    • setOperatingMW

      public void setOperatingMW(double mw)
      Set the operating molecular weight for interpolation.

      The polytropic head and efficiency will be interpolated between maps based on this MW.

      Parameters:
      mw - the operating molecular weight in g/mol
    • getOperatingMW

      public double getOperatingMW()
      Get the operating molecular weight.
      Returns:
      the operating molecular weight in g/mol
    • setInterpolationEnabled

      public void setInterpolationEnabled(boolean enabled)
      Enable or disable MW interpolation.

      When disabled, the chart behaves like a standard CompressorChart using the first added map.

      Parameters:
      enabled - true to enable interpolation, false to disable
    • isInterpolationEnabled

      public boolean isInterpolationEnabled()
      Check if MW interpolation is enabled.
      Returns:
      true if interpolation is enabled
    • setAutoGenerateSurgeCurves

      public void setAutoGenerateSurgeCurves(boolean autoGenerate)
      Enable auto-generation of surge curves when maps are added.
      Parameters:
      autoGenerate - true to auto-generate surge curves
    • isAutoGenerateSurgeCurves

      public boolean isAutoGenerateSurgeCurves()
      Check if auto-generation of surge curves is enabled.
      Returns:
      true if auto-generation is enabled
    • setAutoGenerateStoneWallCurves

      public void setAutoGenerateStoneWallCurves(boolean autoGenerate)
      Enable auto-generation of stone wall curves when maps are added.
      Parameters:
      autoGenerate - true to auto-generate stone wall curves
    • isAutoGenerateStoneWallCurves

      public boolean isAutoGenerateStoneWallCurves()
      Check if auto-generation of stone wall curves is enabled.
      Returns:
      true if auto-generation is enabled
    • getNumberOfMaps

      public int getNumberOfMaps()
      Get the number of MW maps defined.
      Returns:
      number of MW maps
    • getMapMolecularWeights

      public List<Double> getMapMolecularWeights()
      Get the list of molecular weights for which maps are defined.
      Returns:
      unmodifiable list of MW values in ascending order
    • setAllowExtrapolation

      public void setAllowExtrapolation(boolean allow)
      Enable or disable extrapolation outside the MW range.

      When enabled, linear extrapolation is used for MW values outside the range of defined maps. When disabled (default), the nearest boundary map is used.

      Parameters:
      allow - true to enable extrapolation, false to use boundary maps
    • isAllowExtrapolation

      public boolean isAllowExtrapolation()
      Check if extrapolation outside the MW range is allowed.
      Returns:
      true if extrapolation is allowed
    • setUseActualMW

      public void setUseActualMW(boolean useActual)
      Set whether to automatically use the inlet stream's molecular weight.

      When enabled (default), the operating MW is automatically updated from the inlet stream's fluid molecular weight before each calculation. This ensures the compressor chart uses the actual gas composition.

      Parameters:
      useActual - true to use inlet stream's MW automatically
    • isUseActualMW

      public boolean isUseActualMW()
      Check if automatic MW detection from inlet stream is enabled.
      Returns:
      true if using inlet stream's MW automatically
    • setInletStream

      public void setInletStream(StreamInterface stream)
      Set the inlet stream reference for automatic MW detection.
      Parameters:
      stream - the inlet stream
    • getInletStream

      public StreamInterface getInletStream()
      Get the inlet stream reference.
      Returns:
      the inlet stream, or null if not set
    • updateOperatingMWFromStream

      private void updateOperatingMWFromStream()
      Update the operating MW from the inlet stream's fluid.

      Called automatically before calculations if useActualMW is enabled.

    • findInterpolationIndices

      private CompressorChartMWInterpolation.InterpolationIndices findInterpolationIndices(double mw)
      Find the two nearest MW maps and their interpolation weight.
      Parameters:
      mw - the target molecular weight
      Returns:
      InterpolationIndices containing lower index, upper index, and interpolation fraction
    • getPolytropicHead

      public double getPolytropicHead(double flow, double speed)
      Get method for polytropic head from reference curves.

      Returns the polytropic head interpolated between MW maps based on the operating MW.

      Specified by:
      getPolytropicHead in interface CompressorChartInterface
      Overrides:
      getPolytropicHead in class CompressorChart
      Parameters:
      flow - [m3/h], speed in [rpm].
      speed - a double
      Returns:
      polytropic head in unit [getHeadUnit]
    • getPolytropicEfficiency

      public double getPolytropicEfficiency(double flow, double speed)
      Get method for polytropic efficiency from reference curves.

      Returns the polytropic efficiency interpolated between MW maps based on the operating MW.

      Specified by:
      getPolytropicEfficiency in interface CompressorChartInterface
      Overrides:
      getPolytropicEfficiency in class CompressorChart
      Parameters:
      flow - [m3/h], speed in [rpm].
      speed - a double
      Returns:
      polytropic efficiency [%].
    • getSurgeFlowAtSpeed

      public double getSurgeFlowAtSpeed(double speed)
      Get the surge flow at a specific speed, interpolated between MW maps.
      Specified by:
      getSurgeFlowAtSpeed in interface CompressorChartInterface
      Overrides:
      getSurgeFlowAtSpeed in class CompressorChart
      Parameters:
      speed - the compressor speed in RPM
      Returns:
      the surge flow interpolated for the operating MW
    • getStoneWallFlowAtSpeed

      public double getStoneWallFlowAtSpeed(double speed)
      Get the stone wall flow at a specific speed, interpolated between MW maps.
      Specified by:
      getStoneWallFlowAtSpeed in interface CompressorChartInterface
      Overrides:
      getStoneWallFlowAtSpeed in class CompressorChart
      Parameters:
      speed - the compressor speed in RPM
      Returns:
      the stone wall flow interpolated for the operating MW
    • getSurgeHeadAtSpeed

      public double getSurgeHeadAtSpeed(double speed)
      Get the surge head at a specific speed, interpolated between MW maps.
      Specified by:
      getSurgeHeadAtSpeed in interface CompressorChartInterface
      Overrides:
      getSurgeHeadAtSpeed in class CompressorChart
      Parameters:
      speed - the compressor speed in RPM
      Returns:
      the surge head interpolated for the operating MW
    • getStoneWallHeadAtSpeed

      public double getStoneWallHeadAtSpeed(double speed)
      Get the stone wall head at a specific speed, interpolated between MW maps.
      Specified by:
      getStoneWallHeadAtSpeed in interface CompressorChartInterface
      Overrides:
      getStoneWallHeadAtSpeed in class CompressorChart
      Parameters:
      speed - the compressor speed in RPM
      Returns:
      the stone wall head interpolated for the operating MW
    • isSurge

      public boolean isSurge(double head, double flow)
      Check if operating point is in surge, using interpolated surge curve.
      Parameters:
      head - the polytropic head
      flow - the volumetric flow
      Returns:
      true if the operating point is below the surge curve (in surge)
    • isStoneWall

      public boolean isStoneWall(double head, double flow)
      Check if operating point is at stone wall (choke), using interpolated stone wall curve.
      Parameters:
      head - the polytropic head
      flow - the volumetric flow
      Returns:
      true if the operating point is beyond the stone wall curve (choked)
    • getSurgeFlow

      public double getSurgeFlow(double head)
      Get interpolated surge flow at a given head.
      Parameters:
      head - the polytropic head
      Returns:
      the surge flow interpolated for the operating MW
    • getStoneWallFlow

      public double getStoneWallFlow(double head)
      Get interpolated stone wall flow at a given head.
      Parameters:
      head - the polytropic head
      Returns:
      the stone wall flow interpolated for the operating MW
    • getDistanceToSurge

      public double getDistanceToSurge(double head, double flow)
      Get the distance to surge as a ratio, using interpolated surge curve.
      Parameters:
      head - the polytropic head
      flow - the current volumetric flow
      Returns:
      ratio (current flow / surge flow) - 1; positive means above surge
    • getDistanceToStoneWall

      public double getDistanceToStoneWall(double head, double flow)
      Get the distance to stone wall as a ratio, using interpolated stone wall curve.
      Parameters:
      head - the polytropic head
      flow - the current volumetric flow
      Returns:
      ratio (stone wall flow / current flow) - 1; positive means below stone wall
    • linearInterpolate

      private double linearInterpolate(double valueLower, double valueUpper, double fraction)
      Linear interpolation between two values.
      Parameters:
      valueLower - the value at the lower bound
      valueUpper - the value at the upper bound
      fraction - the interpolation fraction (0.0 = lower, 1.0 = upper)
      Returns:
      the interpolated value
    • setSurgeCurveAtMW

      public void setSurgeCurveAtMW(double molecularWeight, double[] chartConditions, double[] surgeFlow, double[] surgeHead)
      Set surge curve for a specific MW map.
      Parameters:
      molecularWeight - the MW of the map to update
      chartConditions - reference conditions
      surgeFlow - array of surge flow values
      surgeHead - array of surge head values
    • setStoneWallCurveAtMW

      public void setStoneWallCurveAtMW(double molecularWeight, double[] chartConditions, double[] stoneWallFlow, double[] stoneWallHead)
      Set stone wall curve for a specific MW map.
      Parameters:
      molecularWeight - the MW of the map to update
      chartConditions - reference conditions
      stoneWallFlow - array of stone wall flow values
      stoneWallHead - array of stone wall head values
    • generateAllSurgeCurves

      public void generateAllSurgeCurves()
      Generate surge curves for all MW maps.
    • generateAllStoneWallCurves

      public void generateAllStoneWallCurves()
      Generate stone wall curves for all MW maps.
    • findMapIndex

      private int findMapIndex(double molecularWeight)
      Find the index of a map by molecular weight.
      Parameters:
      molecularWeight - the MW to find
      Returns:
      the index, or -1 if not found
    • getChartAtMW

      public CompressorChart getChartAtMW(double molecularWeight)
      Get the chart at a specific MW.
      Parameters:
      molecularWeight - the MW to find
      Returns:
      the CompressorChart at that MW, or null if not found
    • setHeadUnit

      public void setHeadUnit(String headUnit)
      Set the head unit for all maps.
      Specified by:
      setHeadUnit in interface CompressorChartInterface
      Overrides:
      setHeadUnit in class CompressorChart
      Parameters:
      headUnit - the unit of head (e.g., "kJ/kg" or "meter")