Skip to content

Commit

Permalink
update flash
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol committed Feb 22, 2025
1 parent deec4a2 commit 2933d20
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/java/neqsim/thermodynamicoperations/flashops/Flash.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException,
}
iterations = 0;
fNorm = 1.0e10;
boolean acceleration = true;
double olderror = 1.0e10;

do {
iterations++;
Expand Down Expand Up @@ -191,7 +193,8 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException,
break;
}
}
if (iterations % 7 == 0 && fNorm < fNormOld && !secondOrderStabilityAnalysis) {
if (iterations % 7 == 0 && fNorm < fNormOld && !secondOrderStabilityAnalysis
&& acceleration) {
double vec1 = 0.0;

double vec2 = 0.0;
Expand All @@ -211,6 +214,9 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException,
error[j] += Math.abs((logWi[i] - oldlogw[i]) / oldlogw[i]);
Wi[j][i] = Math.exp(logWi[i]);
}
if (error[j] > olderror) {
acceleration = false;
}
} else {
// succsessive substitution
for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) {
Expand Down Expand Up @@ -268,14 +274,15 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException,
// logger.info("fnorm " + f.norm1() + " err " + error[j] + " iterations " +
// iterations
// + " phase " + j);
} while ((f.norm1() > 1e-6 && error[j] > 1e-9 && iterations < maxiterations)
// logger.info("error " + error[j]);
olderror = error[j];
} while ((f.norm1() > 1e-3 && error[j] > 1e-3 && iterations < maxiterations)
|| (iterations % 7) == 0 || iterations < 3);
// (error[j]<oldErr && oldErr<oldOldErr) &&
// logger.info("err " + error[j]);
// logger.info("iterations " + iterations);
// logger.info("f.norm1() " + f.norm1());
if (iterations >= maxiterations) {
logger.error("err staability check " + error[j]);
throw new neqsim.util.exception.TooManyIterationsException("too many iterations", null,
maxiterations);
}
Expand Down

0 comments on commit 2933d20

Please sign in to comment.