-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathSurgeCurve.java
More file actions
153 lines (139 loc) · 3.84 KB
/
SurgeCurve.java
File metadata and controls
153 lines (139 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
package neqsim.processSimulation.processEquipment.compressor;
import java.util.Arrays;
import java.util.Objects;
import org.apache.commons.math3.analysis.polynomials.PolynomialFunction;
import org.apache.commons.math3.fitting.PolynomialCurveFitter;
import org.apache.commons.math3.fitting.WeightedObservedPoints;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* <p>
* SurgeCurve class.
* </p>
*
* @author asmund
* @version $Id: $Id
*/
public class SurgeCurve implements java.io.Serializable {
private static final long serialVersionUID = 1000;
static Logger logger = LogManager.getLogger(SurgeCurve.class);
double[] flow;
double[] head;
double[] chartConditions = null;
private boolean isActive = false;
final WeightedObservedPoints flowFitter = new WeightedObservedPoints();
PolynomialFunction flowFitterFunc = null;
/**
* <p>
* Constructor for SurgeCurve.
* </p>
*/
public SurgeCurve() {}
/**
* <p>
* Constructor for SurgeCurve.
* </p>
*
* @param flow an array of {@link double} objects
* @param head an array of {@link double} objects
*/
public SurgeCurve(double[] flow, double[] head) {
this.flow = flow;
this.head = head;
}
/**
* <p>
* setCurve.
* </p>
*
* @param chartConditions an array of {@link double} objects
* @param flow an array of {@link double} objects
* @param head an array of {@link double} objects
*/
public void setCurve(double[] chartConditions, double[] flow, double[] head) {
this.flow = flow;
this.head = head;
this.chartConditions = chartConditions;
flowFitter.clear();
for (int i = 0; i < flow.length; i++) {
flowFitter.add(head[i], flow[i]);
}
PolynomialCurveFitter fitter = PolynomialCurveFitter.create(2);
flowFitterFunc = new PolynomialFunction(fitter.fit(flowFitter.toList()));
isActive = true;
// trykkforhold paa y-aksen mot redused flow
// dp over sugetrykk
// surge kurva er invariat i plottet trykkforhold mot redused flow
// CCC bruker dP/ (over maaleblnde som representerer flow) dP/Ps - paa x-aksen
// trykkforhold paa y-aksen (trykk ut/trykk inn)
}
/**
* <p>
* getSurgeFlow.
* </p>
*
* @param head a double
* @return a double
*/
public double getSurgeFlow(double head) {
return flowFitterFunc.value(head);
}
/**
* <p>
* isSurge.
* </p>
*
* @param head a double
* @param flow a double
* @return a boolean
*/
public boolean isSurge(double head, double flow) {
if (getSurgeFlow(head) > flow) {
return true;
} else {
return false;
}
}
/**
* @return boolean
*/
boolean isActive() {
return isActive;
}
/**
* @param isActive true if surge curve should be used for compressor calculations
*/
void setActive(boolean isActive) {
this.isActive = isActive;
}
/** {@inheritDoc} */
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + Arrays.hashCode(chartConditions);
result = prime * result + Arrays.hashCode(flow);
result = prime * result + Arrays.hashCode(head);
result = prime * result + Objects.hash(flowFitterFunc, isActive);
// result = prime * result + Objects.hash(flowFitter);
return result;
}
/** {@inheritDoc} */
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
SurgeCurve other = (SurgeCurve) obj;
return Arrays.equals(chartConditions, other.chartConditions) && Arrays.equals(flow, other.flow)
&& Objects.equals(flowFitterFunc, other.flowFitterFunc) && Arrays.equals(head, other.head)
&& isActive == other.isActive;
// && Objects.equals(flowFitter, other.flowFitter)
}
}