Skip to content
Even Solbraa edited this page Nov 18, 2024 · 13 revisions

Compressor Calculations using fan law

https://github.com/equinor/neqsim/blob/master/src/main/java/neqsim/process/equipment/compressor/CompressorChart.java

Overview

The setCurves method initializes the compressor performance curves, including speed, flow, head, and polytropic efficiency. It takes various inputs to initialize internal variables for different performance parameters, normalize them, and calculate reduced values.

The method also fits polynomial functions to represent relationships between the reduced parameters, which are later used for compressor performance analysis.

Parameters

  • chartConditions (double[]): An array of conditions used for the compressor chart. (Currently unused)
  • speed (double[]): An array representing the compressor speed values.
  • flow (double[][]): A 2D array representing the flow rates at different speeds.
  • head (double[][]): A 2D array representing the head values at different speeds.
  • polyEff (double[][]): A 2D array representing the polytropic efficiency values at different speeds.

Method Workflow

  1. Initialize Variables: The method starts by assigning the input values to the class-level variables for speed, flow, head, and polytropic efficiency.

  2. Determine Maximum Length: It then determines the maximum length among the flow, head, and polytropic efficiency arrays to dynamically initialize arrays (redhead, redpolytropicEfficiency, redflow) for storing reduced values.

  3. Iterate Through Speed Values:

    • For each speed, it creates a CompressorCurve object representing the compressor's performance at that speed, and adds it to the chartValues list.
    • It computes the reduced values (redflow, redhead, redpolytropicEfficiency) by normalizing the original values with respect to speed. These reduced values are used to add data points to curve fitters (reducedHeadFitter, reducedPolytropicEfficiencyFitter, fanLawCorrectionFitter).

    The reduced values are computed using the following equations:

    • Reduced Flow:

      Q_red = Q / N

      Where:

      • Q is the flow rate at a given speed.
      • N is the speed.
    • Reduced Head:

      H_red = H / N^2

      Where:

      • H is the head at a given speed.
      • N is the speed.
    • Fan Law Correction:

      Q_fanlaw = Q * (N / N_0)

      Where:

      • Q_fanlaw is the flow rate corrected by the fan law.
      • N_0 is the reference speed.
  4. Fill Remaining Slots: If any of the original arrays (flow, head, polyEff) have fewer elements than the maximum length, the remaining slots are filled with default values (e.g., 0).

  5. Calculate Reference Speed: The reference speed is calculated as the average of the maximum and minimum speed values.

    N_ref = (N_max + N_min) / 2

  6. Fit Polynomial Functions: Polynomial functions are fitted to the reduced head, polytropic efficiency, and fan law correction data using a second-degree polynomial curve fitter (PolynomialCurveFitter).

  7. Enable Compressor Chart: Finally, the use of the compressor chart is enabled by calling setUseCompressorChart(true).

Example Usage

The setCurves method is typically used to set up compressor performance charts, which are critical for analyzing the performance of compressors under different operating conditions. This is useful in both simulation and optimization tasks.

Compressor Calculations using interpolation method

https://github.com/equinor/neqsim/blob/master/src/main/java/neqsim/process/equipment/compressor/CompressorChartAlternativeMapLookup.java

Method: getClosestRefSpeeds

Description:
Retrieves a list of reference speeds that are closest to the given speed. This method helps in identifying reference speeds for further calculations such as interpolation.

Parameters:

  • speed (double): The speed value for which the closest reference speeds are sought.

Returns:

  • ArrayList<Double>: A list containing the closest reference speeds.

Mathematical Representation:

  1. Sort the Reference Speeds:
    Let the reference speeds be represented by an array speedArray of size n.
    Sort speedArray in ascending order.

  2. Check for Exact Match:
    Iterate through the sorted speedArray to check if the input speed matches any value.
    If a match is found, add the speed to the list of closest reference speeds.

  3. Determine the Closest Reference Speeds:
    If no exact match is found, use a method similar to binary search (bisect_left) to determine the position pos where speed would fit in the sorted array.

    • If pos == 0, the input speed is lower than the lowest reference speed. The closest reference speed is the first element in speedArray.
    • If pos == n, the input speed is higher than the highest reference speed. The closest reference speed is the last element in speedArray.
    • Otherwise, the input speed lies between two reference speeds. The closest reference speeds are the elements at positions pos - 1 and pos.
  4. Add the Closest Speeds to the List:
    Based on the determined position, add the closest reference speeds to the result list.

Example:

Consider an array of reference speeds: speedArray = [50, 100, 200, 300, 400].

  • If speed = 250, the method will identify that speed lies between 200 and 300. Thus, the closest reference speeds are [200, 300].
  • If speed = 100, the exact match is found, and the closest reference speed is [100].
  • If speed = 50, which is below the lowest reference speed, the closest reference speed is [50].

Method: getPolytropicHead

Description:
Calculates the polytropic head for a given flow rate and speed using spline interpolation.

Mathematical Representation:

  1. Find the Closest Reference Speeds:
    Use getClosestRefSpeeds to determine the reference speeds closest to the given speed.

  2. Spline Interpolation:
    For each reference speed, interpolate the polytropic head using spline interpolation.

    Spline Interpolation Process:
    Given a set of data points (xi, yi), where xi represents the flow rate and yi represents the polytropic head at that flow rate, spline interpolation is used to create a smooth curve that passes through all the given points.
    The interpolation is performed using a piecewise cubic polynomial known as a cubic spline. This ensures that the first and second derivatives are continuous at each of the data points, resulting in a smooth curve.

    Mathematical Formulation:
    For each interval [xi, xi+1], the cubic spline is represented by a polynomial of the form:
    Si(x) = ai + bi * (x - xi) + ci * (x - xi)^2 + di * (x - xi)^3
    where ai, bi, ci, and di are coefficients determined based on the boundary conditions and continuity requirements of the spline.

  3. Calculate Polytropic Head:
    Use the interpolated values from the spline to determine the polytropic head for the given flow rate at the specific reference speed.

  4. Combine Results:
    Combine the interpolated results from each reference speed to provide a comprehensive polytropic head calculation.


Compressor Calculations using interpolation and extrapolation method

https://github.com/equinor/neqsim/blob/master/src/main/java/neqsim/process/equipment/compressor/CompressorChartAlternativeMapLookupExtrapolate.java

CompressorChartAlternativeMapLookupExtrapolate Class Documentation

This class is part of the neqsim.process.equipment.compressor package and extends the CompressorChartAlternativeMapLookup class. It provides methods for interpolating or extrapolating compressor data, including polytropic head and efficiency, based on flow and speed. The class also supports determining the closest reference speeds to a given speed.

Methods

getClosestRefSpeeds(double speed)

Description: Retrieves the closest reference speeds to the given speed from the compressor chart values.

Behavior:

  • If the given speed matches a reference speed, the method returns that speed.
  • If the given speed is between two reference speeds, both speeds are returned.
  • If the given speed is outside the range of reference speeds, the closest boundary speed is returned.

Parameters:

  • speed: The speed to find the closest reference speeds for.

Returns:

  • A list of the closest reference speeds.

Throws:

  • IllegalStateException if no reference speeds are available.

getPolytropicHead(double flow, double speed)

Description: Calculates the polytropic head for a given flow and speed by interpolating or extrapolating between reference compressor curves.

Parameters:

  • flow: Flow rate for which the polytropic head is calculated.
  • speed: Operating speed of the compressor.

Returns:

  • The polytropic head at the given flow and speed.

Formula:

  • For interpolation or extrapolation: Head = Spline(flow) or: Head = Linear Interpolation/Extrapolation using speeds and heads

getPolytropicEfficiency(double flow, double speed)

Description: Calculates the polytropic efficiency for a given flow and speed by interpolating or extrapolating between reference compressor curves.

Parameters:

  • flow: Flow rate for which the efficiency is calculated.
  • speed: Operating speed of the compressor.

Returns:

  • The polytropic efficiency at the given flow and speed.

Throws:

  • IllegalArgumentException if no valid reference speeds are found or if the curve data is invalid.

Formula:

  • For interpolation or extrapolation: Efficiency = Spline(flow) or: Efficiency = Linear Interpolation/Extrapolation using speeds and efficiencies

extrapolateOrInterpolate(double flow, double[] flowData, double[] valueData, PolynomialSplineFunction spline)

Description: Performs extrapolation or interpolation for a given flow based on flow data, value data, and a spline function.

Parameters:

  • flow: Flow value for extrapolation or interpolation.
  • flowData: Array of flow data points.
  • valueData: Array of value data points corresponding to flowData.
  • spline: Polynomial spline function created from flowData and valueData.

Returns:

  • The interpolated or extrapolated value at the given flow.

Formula:

  • Below range: Value = Value[0] + Slope * (Flow - Flow[0])
  • Above range: Value = Value[last] + Slope * (Flow - Flow[last])

extrapolateOrInterpolateSpeed(double speed, double speed1, double speed2, double value1, double value2)

Description: Performs extrapolation or interpolation based on speed and two reference speeds with corresponding values.

Parameters:

  • speed: Speed for extrapolation or interpolation.
  • speed1, speed2: Reference speeds.
  • value1, value2: Values corresponding to speed1 and speed2.

Returns:

  • The interpolated or extrapolated value at the given speed.

Formula:

  • Below range: Value = Value1 + Slope * (Speed - Speed1)
  • Above range: Value = Value2 + Slope * (Speed - Speed2)

linearInterpolate(double x, double x1, double x2, double y1, double y2)

Description: Performs linear interpolation for a value based on two known points.

Parameters:

  • x: X-value at which to interpolate.
  • x1, x2: Known x-values.
  • y1, y2: Known y-values corresponding to x1 and x2.

Returns:

  • The interpolated y-value at the given x.

Formula:

y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1)


Generation of compressor curves

https://github.com/equinor/neqsim/blob/master/src/main/java/neqsim/process/equipment/compressor/CompressorChartGenerator.java

CompressorChartGenerator Documentation\

This class generates compressor charts for a given compressor based on specified options. It supports generating normal curves and alternative curves while ensuring realistic flow, head, and efficiency values.


Methods

Constructor

CompressorChartGenerator(Compressor inpCompressor)

Description: Initializes the generator with the given compressor.

  • Parameter:
    • inpCompressor: The compressor object for which charts are generated.

generateCompressorChart(String generationOption)

Description: Generates a compressor chart based on the specified generation option.

  • Parameter:

    • generationOption: Specifies the chart type. Use "normal curves" for normalized data or other values for alternative curves.
  • Returns: A CompressorChart object containing the generated curves.


Equations Used

  1. Flow Data:

    • For "normal curves":
      Flow[0] = Reference Flow / 1.3
      Flow[1] = Reference Flow
      Flow[2] = Reference Flow * (2.5 / 1.3)
      
    • For other options:
      Flow[0] = Reference Flow * 0.7
      Flow[1] = Reference Flow
      Flow[2] = Reference Flow * 1.43
      
  2. Head Data:

    • For "normal curves":
      Head[0] = Reference Head * 1.2
      Head[1] = Reference Head
      Head[2] = Reference Head * 1.2 * 0.4
      
    • For other options:
      Head[0] = Reference Head * 1.5
      Head[1] = Reference Head
      Head[2] = Reference Head * 0.5
      
  3. Efficiency Data: Efficiency[0] = Reference Efficiency * 100.0 * 0.9 Efficiency[1] = Reference Efficiency * 100.0 Efficiency[2] = Reference Efficiency * 100.0 * 0.85

markdown Kopier kode

  1. Surge Flow:
  • For "normal curves":
    Surge Flow Min = Reference Flow * 0.7
    Surge Flow Ref = Reference Flow / 1.3
    Surge Flow Max = Reference Flow * 0.9
    
  • For other options:
    Surge Flow Min = Reference Flow * 0.7
    Surge Flow Ref = Reference Flow * 0.8
    Surge Flow Max = Reference Flow * 0.9
    
  1. Surge Head:
  • Calculated using the getPolytropicHead method from CompressorChart:
    Head[Min] = getPolytropicHead(Min Flow, Min Speed)
    Head[Ref] = getPolytropicHead(Reference Flow, Reference Speed)
    Head[Max] = getPolytropicHead(Max Flow, Max Speed)
    

Workflow

  1. Initialize Conditions:
  • Retrieve reference speed, flow, and head from the compressor.
  • Initialize arrays for flow, head, and efficiency based on the chosen generation option.
  1. Configure Compressor Chart:
  • Use normalized or alternative data for chart conditions.
  • Set head unit as "kJ/kg".
  1. Generate Surge Curve:
  • Define surge flow and head values for minimum, reference, and maximum conditions.
  • Create a SurgeCurve object and add it to the compressor chart.

Notes

  • The flow, head, and efficiency data are normalized or scaled based on the generation option.
  • Surge points are calculated to ensure realistic and accurate compressor performance curves.
  • This implementation adheres to best practices for compressor modeling, supporting both normal and alternative configurations.
Clone this wiki locally