-
Notifications
You must be signed in to change notification settings - Fork 30
Compressor curves
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.
-
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.
-
Initialize Variables: The method starts by assigning the input values to the class-level variables for speed, flow, head, and polytropic efficiency.
-
Determine Maximum Length: It then determines the maximum length among the
flow
,head
, andpolytropic efficiency
arrays to dynamically initialize arrays (redhead
,redpolytropicEfficiency
,redflow
) for storing reduced values. -
Iterate Through Speed Values:
- For each speed, it creates a
CompressorCurve
object representing the compressor's performance at that speed, and adds it to thechartValues
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.
- For each speed, it creates a
-
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
). -
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
-
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
). -
Enable Compressor Chart: Finally, the use of the compressor chart is enabled by calling
setUseCompressorChart(true)
.
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.
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.
-
Sort the Reference Speeds:
Let the reference speeds be represented by an arrayspeedArray
of sizen
.
SortspeedArray
in ascending order. -
Check for Exact Match:
Iterate through the sortedspeedArray
to check if the inputspeed
matches any value.
If a match is found, add the speed to the list of closest reference speeds. -
Determine the Closest Reference Speeds:
If no exact match is found, use a method similar to binary search (bisect_left
) to determine the positionpos
wherespeed
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 inspeedArray
. - If
pos == n
, the input speed is higher than the highest reference speed. The closest reference speed is the last element inspeedArray
. - Otherwise, the input speed lies between two reference speeds. The closest reference speeds are the elements at positions
pos - 1
andpos
.
- If
-
Add the Closest Speeds to the List:
Based on the determined position, add the closest reference speeds to the result list.
Consider an array of reference speeds: speedArray = [50, 100, 200, 300, 400]
.
- If
speed = 250
, the method will identify thatspeed
lies between200
and300
. 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]
.
Description:
Calculates the polytropic head for a given flow rate and speed using spline interpolation.
-
Find the Closest Reference Speeds:
UsegetClosestRefSpeeds
to determine the reference speeds closest to the given speed. -
Spline Interpolation:
For each reference speed, interpolate the polytropic head using spline interpolation.Spline Interpolation Process:
Given a set of data points(xi, yi)
, wherexi
represents the flow rate andyi
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
whereai
,bi
,ci
, anddi
are coefficients determined based on the boundary conditions and continuity requirements of the spline. -
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. -
Combine Results:
Combine the interpolated results from each reference speed to provide a comprehensive polytropic head calculation.
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.
Description: Retrieves the closest reference speeds to the given speed from the compressor chart values.
- 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.
-
speed
: The speed to find the closest reference speeds for.
- A list of the closest reference speeds.
-
IllegalStateException
if no reference speeds are available.
Description: Calculates the polytropic head for a given flow and speed by interpolating or extrapolating between reference compressor curves.
-
flow
: Flow rate for which the polytropic head is calculated. -
speed
: Operating speed of the compressor.
- The polytropic head at the given flow and speed.
- For interpolation or extrapolation: Head = Spline(flow) or: Head = Linear Interpolation/Extrapolation using speeds and heads
Description: Calculates the polytropic efficiency for a given flow and speed by interpolating or extrapolating between reference compressor curves.
-
flow
: Flow rate for which the efficiency is calculated. -
speed
: Operating speed of the compressor.
- The polytropic efficiency at the given flow and speed.
-
IllegalArgumentException
if no valid reference speeds are found or if the curve data is invalid.
- 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.
-
flow
: Flow value for extrapolation or interpolation. -
flowData
: Array of flow data points. -
valueData
: Array of value data points corresponding toflowData
. -
spline
: Polynomial spline function created fromflowData
andvalueData
.
- The interpolated or extrapolated value at the given flow.
- 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.
-
speed
: Speed for extrapolation or interpolation. -
speed1
,speed2
: Reference speeds. -
value1
,value2
: Values corresponding tospeed1
andspeed2
.
- The interpolated or extrapolated value at the given speed.
- Below range: Value = Value1 + Slope * (Speed - Speed1)
- Above range: Value = Value2 + Slope * (Speed - Speed2)
Description: Performs linear interpolation for a value based on two known points.
-
x
: X-value at which to interpolate. -
x1
,x2
: Known x-values. -
y1
,y2
: Known y-values corresponding tox1
andx2
.
- The interpolated y-value at the given x.
y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1)
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.
Description: Initializes the generator with the given compressor.
-
Parameter:
-
inpCompressor
: The compressor object for which charts are generated.
-
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.
-
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
- For "normal curves":
-
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
- For "normal curves":
-
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
- 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
- Surge Head:
- Calculated using the
getPolytropicHead
method fromCompressorChart
:Head[Min] = getPolytropicHead(Min Flow, Min Speed) Head[Ref] = getPolytropicHead(Reference Flow, Reference Speed) Head[Max] = getPolytropicHead(Max Flow, Max Speed)
- Initialize Conditions:
- Retrieve reference speed, flow, and head from the compressor.
- Initialize arrays for flow, head, and efficiency based on the chosen generation option.
- Configure Compressor Chart:
- Use normalized or alternative data for chart conditions.
- Set head unit as
"kJ/kg"
.
- 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.
- 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.
- Getting started with NeqSim and GitHub
- Getting started as a NeqSim developer
- The NeqSim parameter database
- Example of setting up a fluid and running simple flash calculations
- Select thermodynamic model and mixing rule
- Flash calculations and phase envelope calculations using NeqSim
- Calculation of thermodynamic and physical properties using NeqSim
- Oil Characterization in NeqSim
- Aqueous fluids and NeqSim
- Electrolytes and NeqSim
- Process Calculations in NeqSim