Skip to content

Commit d1007e2

Browse files
authored
first version flow efficiency (#1209)
* first version flow efficiency * update
1 parent 5f2520b commit d1007e2

File tree

4 files changed

+137
-24
lines changed

4 files changed

+137
-24
lines changed

src/main/java/neqsim/process/equipment/compressor/CompressorChart.java

+52-8
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ public class CompressorChart implements CompressorChartInterface, java.io.Serial
4646
PolynomialFunction fanLawCorrectionFunc = null;
4747
double[] speed;
4848
double[][] flow;
49+
double[][] flowPolytropicEfficiency;
4950
double[][] head;
5051
double[][] polytropicEfficiency;
5152
double[][] redflow;
53+
double[][] redflowPolytropicEfficiency;
5254
double[][] redhead;
5355
double[][] redpolytropicEfficiency;
5456

@@ -62,7 +64,16 @@ public CompressorChart() {}
6264
/** {@inheritDoc} */
6365
@Override
6466
public void addCurve(double speed, double[] flow, double[] head, double[] polytropicEfficiency) {
65-
CompressorCurve curve = new CompressorCurve(speed, flow, head, polytropicEfficiency);
67+
CompressorCurve curve = new CompressorCurve(speed, flow, head, flow, polytropicEfficiency);
68+
chartValues.add(curve);
69+
}
70+
71+
/** {@inheritDoc} */
72+
@Override
73+
public void addCurve(double speed, double[] flow, double[] head,
74+
double[] flowPolytropicEfficiency, double[] polytropicEfficiency) {
75+
CompressorCurve curve =
76+
new CompressorCurve(speed, flow, head, flowPolytropicEfficiency, polytropicEfficiency);
6677
chartValues.add(curve);
6778
}
6879

@@ -80,21 +91,48 @@ public void addCurve(double speed, double[] flow, double[] head, double[] polytr
8091
@Override
8192
public void setCurves(double[] chartConditions, double[] speed, double[][] flow, double[][] head,
8293
double[][] polyEff) {
94+
this.setCurves(chartConditions, speed, flow, head, flow, polyEff);
95+
}
96+
97+
/**
98+
* {@inheritDoc}
99+
*
100+
* This method initializes the compressor performance curves, including speed, flow, head, and
101+
* polytropic efficiency.
102+
*
103+
* <p>
104+
* The method takes chart conditions and initializes internal variables for different performance
105+
* parameters based on input arrays for speed, flow, head, and polytropic efficiency. It also
106+
* normalizes these parameters by calculating reduced values based on speed.
107+
*/
108+
@Override
109+
public void setCurves(double[] chartConditions, double[] speed, double[][] flow, double[][] head,
110+
double[][] flowPolyEff, double[][] polyEff) {
83111
this.speed = speed;
84112
this.head = head;
85113
this.polytropicEfficiency = polyEff;
86114
this.flow = flow;
115+
this.flowPolytropicEfficiency = flowPolyEff;
87116

88117
// Dynamically initialize arrays based on the maximum length of flow, head, and polyEff
89118
int maxLength = 0;
90119
for (double[] f : flow) {
91-
if (f.length > maxLength)
120+
if (f.length > maxLength) {
92121
maxLength = f.length;
122+
}
123+
}
124+
125+
int maxLengthPolyEff = 0;
126+
for (double[] f : flowPolytropicEfficiency) {
127+
if (f.length > maxLengthPolyEff) {
128+
maxLengthPolyEff = f.length;
129+
}
93130
}
94131

95132
this.redhead = new double[head.length][maxLength];
96133
this.redpolytropicEfficiency = new double[polyEff.length][maxLength];
97134
this.redflow = new double[flow.length][maxLength];
135+
this.redflowPolytropicEfficiency = new double[polyEff.length][maxLength];
98136

99137
for (int i = 0; i < speed.length; i++) {
100138
if (speed[i] > maxSpeedCurve) {
@@ -103,25 +141,31 @@ public void setCurves(double[] chartConditions, double[] speed, double[][] flow,
103141
if (speed[i] < minSpeedCurve) {
104142
minSpeedCurve = speed[i];
105143
}
106-
CompressorCurve curve = new CompressorCurve(speed[i], flow[i], head[i], polyEff[i]);
144+
CompressorCurve curve =
145+
new CompressorCurve(speed[i], flow[i], head[i], flowPolyEff[i], polyEff[i]);
107146
chartValues.add(curve);
108147

109148
for (int j = 0; j < flow[i].length; j++) { // Handle differing lengths for each speed
110149
redflow[i][j] = flow[i][j] / speed[i];
111-
redpolytropicEfficiency[i][j] = polyEff[i][j];
112150
redhead[i][j] = head[i][j] / speed[i] / speed[i];
113151
reducedHeadFitter.add(redflow[i][j], redhead[i][j]);
114-
reducedPolytropicEfficiencyFitter.add(redflow[i][j], redpolytropicEfficiency[i][j]);
115152
double flowFanLaw = flow[i][j] * speed[i] / speed[0];
116153
// TODO: MLLU: not correct. speed[0] should be the requested speed
117154
fanLawCorrectionFitter.add(speed[i] / speed[0], flow[i][j] / flowFanLaw);
118155
}
119156

157+
for (int j = 0; j < flowPolytropicEfficiency[i].length; j++) { // Handle differing lengths for
158+
// each speed
159+
redflowPolytropicEfficiency[i][j] = flowPolyEff[i][j] / speed[i];
160+
redpolytropicEfficiency[i][j] = polyEff[i][j];
161+
reducedPolytropicEfficiencyFitter.add(redflowPolytropicEfficiency[i][j],
162+
redpolytropicEfficiency[i][j]);
163+
}
164+
120165
// Fill remaining slots with default values (e.g., 0) if arrays are shorter
121-
for (int j = flow[i].length; j < maxLength; j++) {
122-
redflow[i][j] = 0;
166+
for (int j = flowPolytropicEfficiency[i].length; j < maxLengthPolyEff; j++) {
167+
redflowPolytropicEfficiency[i][j] = 0;
123168
redpolytropicEfficiency[i][j] = 0;
124-
redhead[i][j] = 0;
125169
}
126170
}
127171

src/main/java/neqsim/process/equipment/compressor/CompressorChartAlternativeMapLookup.java

+30-11
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import org.apache.commons.math3.analysis.interpolation.SplineInterpolator;
66
import org.apache.commons.math3.analysis.polynomials.PolynomialFunction;
77
import org.apache.commons.math3.analysis.polynomials.PolynomialSplineFunction;
8-
import org.apache.commons.math3.fitting.WeightedObservedPoints;
98
import org.apache.logging.log4j.LogManager;
109
import org.apache.logging.log4j.Logger;
1110
import neqsim.process.equipment.stream.Stream;
@@ -123,7 +122,9 @@
123122
*/
124123

125124
/**
126-
* <p>CompressorChartAlternativeMapLookup class.</p>
125+
* <p>
126+
* CompressorChartAlternativeMapLookup class.
127+
* </p>
127128
*
128129
* @author asmund
129130
* @version $Id: $Id
@@ -148,10 +149,6 @@ public class CompressorChartAlternativeMapLookup
148149
double refZ;
149150
private boolean useRealKappa = false;
150151
double[] chartConditions = null;
151-
final WeightedObservedPoints reducedHeadFitter = new WeightedObservedPoints();
152-
final WeightedObservedPoints reducedFlowFitter = new WeightedObservedPoints();
153-
final WeightedObservedPoints fanLawCorrectionFitter = new WeightedObservedPoints();
154-
final WeightedObservedPoints reducedPolytropicEfficiencyFitter = new WeightedObservedPoints();
155152
PolynomialFunction reducedHeadFitterFunc = null;
156153
PolynomialFunction reducedPolytropicEfficiencyFunc = null;
157154
PolynomialFunction fanLawCorrectionFunc = null;
@@ -167,7 +164,15 @@ public CompressorChartAlternativeMapLookup() {}
167164
/** {@inheritDoc} */
168165
@Override
169166
public void addCurve(double speed, double[] flow, double[] head, double[] polytropicEfficiency) {
170-
CompressorCurve curve = new CompressorCurve(speed, flow, head, polytropicEfficiency);
167+
addCurve(speed, flow, head, flow, polytropicEfficiency);
168+
}
169+
170+
/** {@inheritDoc} */
171+
@Override
172+
public void addCurve(double speed, double[] flow, double[] head,
173+
double[] flowPolytropicEfficiency, double[] polytropicEfficiency) {
174+
CompressorCurve curve =
175+
new CompressorCurve(speed, flow, head, flowPolytropicEfficiency, polytropicEfficiency);
171176
chartValues.add(curve);
172177
chartSpeeds.add(speed);
173178
}
@@ -182,8 +187,22 @@ public void addCurve(double speed, double[] flow, double[] head, double[] polytr
182187
@Override
183188
public void setCurves(double[] chartConditions, double[] speed, double[][] flow, double[][] head,
184189
double[][] polyEff) {
190+
setCurves(chartConditions, speed, flow, head, flow, polyEff);
191+
}
192+
193+
/** {@inheritDoc} */
194+
/**
195+
* {@inheritDoc}
196+
*
197+
* Sets the compressor curves based on the provided chart conditions, speed, flow, head,
198+
* flowPolytrpicEfficiency and polytropic efficiency values.
199+
*/
200+
@Override
201+
public void setCurves(double[] chartConditions, double[] speed, double[][] flow, double[][] head,
202+
double[][] flowPolyEff, double[][] polyEff) {
185203
for (int i = 0; i < speed.length; i++) {
186-
CompressorCurve curve = new CompressorCurve(speed[i], flow[i], head[i], polyEff[i]);
204+
CompressorCurve curve =
205+
new CompressorCurve(speed[i], flow[i], head[i], flowPolyEff[i], polyEff[i]);
187206
chartValues.add(curve);
188207
chartSpeeds.add(speed[i]);
189208
}
@@ -291,8 +310,8 @@ public double getPolytropicEfficiency(double flow, double speed) {
291310

292311
for (int i = 0; i < closestRefSpeeds.size(); i++) {
293312
s = closestRefSpeeds.get(i);
294-
PolynomialSplineFunction psf =
295-
asi.interpolate(getCurveAtRefSpeed(s).flow, getCurveAtRefSpeed(s).polytropicEfficiency);
313+
PolynomialSplineFunction psf = asi.interpolate(getCurveAtRefSpeed(s).flowPolytropicEfficiency,
314+
getCurveAtRefSpeed(s).polytropicEfficiency);
296315
tempEffs.add(psf.value(flow));
297316
}
298317

@@ -578,7 +597,7 @@ public static void main(String[] args) {
578597
operations.add(stream_1);
579598
operations.add(comp1);
580599
operations.run();
581-
operations.displayResult();
600+
// operations.displayResult();
582601

583602
System.out.println("power " + comp1.getPower());
584603
System.out

src/main/java/neqsim/process/equipment/compressor/CompressorChartInterface.java

+30-5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ public interface CompressorChartInterface extends Cloneable {
1919
*/
2020
public void addCurve(double speed, double[] flow, double[] head, double[] polytropicEfficiency);
2121

22+
/**
23+
* This method is used add a curve to the CompressorChart object.
24+
*
25+
* @param speed a double
26+
* @param flowHead an array of type double
27+
* @param head an array of type double
28+
* @param flowPolytropicEfficiency an array of type double
29+
* @param polytropicEfficiency an array of type double
30+
*/
31+
public void addCurve(double speed, double[] flowHead, double[] head,
32+
double[] flowPolytropicEfficiency, double[] polytropicEfficiency);
33+
2234
/**
2335
* This method is used add a set of curves to the CompressorChart object.
2436
*
@@ -31,6 +43,19 @@ public interface CompressorChartInterface extends Cloneable {
3143
public void setCurves(double[] chartConditions, double[] speed, double[][] flow, double[][] head,
3244
double[][] polyEff);
3345

46+
/**
47+
* This method is used add a set of curves to the CompressorChart object.
48+
*
49+
* @param chartConditions an array of type double
50+
* @param speed an array of type double
51+
* @param flow an array of type double
52+
* @param head an array of type double
53+
* @param flowPolyEff an array of type double
54+
* @param polyEff an array of type double
55+
*/
56+
public void setCurves(double[] chartConditions, double[] speed, double[][] flow, double[][] head,
57+
double[][] flowPolyEff, double[][] polyEff);
58+
3459
/**
3560
* Get method for polytropic head from reference curves.
3661
*
@@ -117,8 +142,7 @@ public void setReferenceConditions(double refMW, double refTemperature, double r
117142
* setSurgeCurve.
118143
* </p>
119144
*
120-
* @param surgeCurve a {@link neqsim.process.equipment.compressor.SurgeCurve}
121-
* object
145+
* @param surgeCurve a {@link neqsim.process.equipment.compressor.SurgeCurve} object
122146
*/
123147
public void setSurgeCurve(SurgeCurve surgeCurve);
124148

@@ -136,8 +160,7 @@ public void setReferenceConditions(double refMW, double refTemperature, double r
136160
* setStoneWallCurve.
137161
* </p>
138162
*
139-
* @param stoneWallCurve a
140-
* {@link neqsim.process.equipment.compressor.StoneWallCurve} object
163+
* @param stoneWallCurve a {@link neqsim.process.equipment.compressor.StoneWallCurve} object
141164
*/
142165
public void setStoneWallCurve(StoneWallCurve stoneWallCurve);
143166

@@ -168,7 +191,9 @@ public void setReferenceConditions(double refMW, double refTemperature, double r
168191
public int hashCode();
169192

170193
/**
171-
* <p>getFlow.</p>
194+
* <p>
195+
* getFlow.
196+
* </p>
172197
*
173198
* @param head a double
174199
* @param speed a double

src/main/java/neqsim/process/equipment/compressor/CompressorCurve.java

+25
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
public class CompressorCurve implements java.io.Serializable {
1515
private static final long serialVersionUID = 1000;
1616
public double[] flow;
17+
public double[] flowPolytropicEfficiency;
1718
public double[] head;
1819
public double[] polytropicEfficiency;
1920
public double speed = 1000.0;
@@ -25,6 +26,7 @@ public class CompressorCurve implements java.io.Serializable {
2526
*/
2627
public CompressorCurve() {
2728
flow = new double[] {453.2, 600.0, 750.0};
29+
flowPolytropicEfficiency = Arrays.copyOf(flow, flow.length);
2830
head = new double[] {1000.0, 900.0, 800.0};
2931
polytropicEfficiency = new double[] {78.0, 79.0, 78.0};
3032
}
@@ -43,6 +45,27 @@ public CompressorCurve(double speed, double[] flow, double[] head,
4345
double[] polytropicEfficiency) {
4446
this.speed = speed;
4547
this.flow = flow;
48+
flowPolytropicEfficiency = Arrays.copyOf(flow, flow.length);
49+
this.head = head;
50+
this.polytropicEfficiency = polytropicEfficiency;
51+
}
52+
53+
/**
54+
* <p>
55+
* Constructor for CompressorCurve.
56+
* </p>
57+
*
58+
* @param speed a double
59+
* @param flow an array of type double
60+
* @param head an array of type double
61+
* @param flowPolytropicEfficiency an array of type double
62+
* @param polytropicEfficiency an array of type double
63+
*/
64+
public CompressorCurve(double speed, double[] flow, double[] head,
65+
double[] flowPolytropicEfficiency, double[] polytropicEfficiency) {
66+
this.speed = speed;
67+
this.flow = flow;
68+
this.flowPolytropicEfficiency = flowPolytropicEfficiency;
4669
this.head = head;
4770
this.polytropicEfficiency = polytropicEfficiency;
4871
}
@@ -55,6 +78,7 @@ public int hashCode() {
5578
result = prime * result + Arrays.hashCode(flow);
5679
result = prime * result + Arrays.hashCode(head);
5780
result = prime * result + Arrays.hashCode(polytropicEfficiency);
81+
result = prime * result + Arrays.hashCode(flowPolytropicEfficiency);
5882
result = prime * result + Objects.hash(speed);
5983
return result;
6084
}
@@ -73,6 +97,7 @@ public boolean equals(Object obj) {
7397
}
7498
CompressorCurve other = (CompressorCurve) obj;
7599
return Arrays.equals(flow, other.flow) && Arrays.equals(head, other.head)
100+
&& Arrays.equals(flowPolytropicEfficiency, other.flowPolytropicEfficiency)
76101
&& Arrays.equals(polytropicEfficiency, other.polytropicEfficiency)
77102
&& Double.doubleToLongBits(speed) == Double.doubleToLongBits(other.speed);
78103
}

0 commit comments

Comments
 (0)