Skip to content

Commit 6367038

Browse files
authored
update flash (#1288)
* update flash * remove output * remove output in test
1 parent deec4a2 commit 6367038

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/main/java/neqsim/thermodynamicoperations/flashops/Flash.java

+10-3
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException,
158158
}
159159
iterations = 0;
160160
fNorm = 1.0e10;
161+
boolean acceleration = true;
162+
double olderror = 1.0e10;
161163

162164
do {
163165
iterations++;
@@ -191,7 +193,8 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException,
191193
break;
192194
}
193195
}
194-
if (iterations % 7 == 0 && fNorm < fNormOld && !secondOrderStabilityAnalysis) {
196+
if (iterations % 7 == 0 && fNorm < fNormOld && !secondOrderStabilityAnalysis
197+
&& acceleration) {
195198
double vec1 = 0.0;
196199

197200
double vec2 = 0.0;
@@ -211,6 +214,9 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException,
211214
error[j] += Math.abs((logWi[i] - oldlogw[i]) / oldlogw[i]);
212215
Wi[j][i] = Math.exp(logWi[i]);
213216
}
217+
if (error[j] > olderror) {
218+
acceleration = false;
219+
}
214220
} else {
215221
// succsessive substitution
216222
for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) {
@@ -268,14 +274,15 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException,
268274
// logger.info("fnorm " + f.norm1() + " err " + error[j] + " iterations " +
269275
// iterations
270276
// + " phase " + j);
271-
} while ((f.norm1() > 1e-6 && error[j] > 1e-9 && iterations < maxiterations)
277+
// logger.info("error " + error[j]);
278+
olderror = error[j];
279+
} while ((f.norm1() > 1e-3 && error[j] > 1e-3 && iterations < maxiterations)
272280
|| (iterations % 7) == 0 || iterations < 3);
273281
// (error[j]<oldErr && oldErr<oldOldErr) &&
274282
// logger.info("err " + error[j]);
275283
// logger.info("iterations " + iterations);
276284
// logger.info("f.norm1() " + f.norm1());
277285
if (iterations >= maxiterations) {
278-
logger.error("err staability check " + error[j]);
279286
throw new neqsim.util.exception.TooManyIterationsException("too many iterations", null,
280287
maxiterations);
281288
}

src/test/java/neqsim/process/equipment/valve/ThrottlingValveTest.java

-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ void testCalcCvLiquidPropnane() {
130130
valve1.setOutletPressure(19);
131131
valve1.run();
132132

133-
stream1.getFluid().prettyPrint();
134133
assertEquals(135.3602060, valve1.getCv(), 1e-2);
135134
assertEquals(135.3602060, valve1.getCv("SI"), 1e-2);
136135
assertEquals(2.46557752, valve1.getCv("US"), 1e-2);

src/test/java/neqsim/process/processmodel/LargeCombinedModelsTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ public void testExpanderProcess() {
624624
combinedProcess.run();
625625
combinedProcess.run();
626626

627-
((Separator) sepprocessTrain1.getUnit("dew point scrubber")).getFluid().prettyPrint();
627+
// ((Separator) sepprocessTrain1.getUnit("dew point scrubber")).getFluid().prettyPrint();
628628

629629
Assertions.assertEquals(8.14523949005678,
630630
((Separator) sepprocessTrain1.getUnit("dew point scrubber 2")).getGasOutStream()

0 commit comments

Comments
 (0)