Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol committed Dec 9, 2024
1 parent 0a880ae commit 7f887a6
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/main/java/neqsim/thermodynamicoperations/flashops/Flash.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public int findLowestGibbsEnergyPhase() {
if (!findLowestGibbsPhaseIsChecked) {
minimumGibbsEnergySystem = system.clone();
minimumGibbsEnergySystem.init(0);
minimumGibbsEnergySystem.setTotalNumberOfMoles(1.0);
minimumGibbsEnergySystem.init(1);
if ((minimumGibbsEnergySystem.getPhase(0).getGibbsEnergy()
* (1.0 - Math.signum(minimumGibbsEnergySystem.getPhase(0).getGibbsEnergy())
Expand Down Expand Up @@ -119,8 +120,10 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException,
sumw[1] = 0.0;
sumw[0] = 0.0;
for (int i = 0; i < clonedSystem.getPhase(0).getNumberOfComponents(); i++) {
sumw[1] += clonedSystem.getPhase(0).getComponent(i).getz()
/ clonedSystem.getPhase(0).getComponent(i).getK();
if (clonedSystem.getPhase(0).getComponent(i).getK() > 0) {
sumw[1] += clonedSystem.getPhase(0).getComponent(i).getz()
/ clonedSystem.getPhase(0).getComponent(i).getK();
}
if (clonedSystem.getPhase(0).getComponent(i).getz() > 0) {
sumw[0] += clonedSystem.getPhase(0).getComponent(i).getK()
* clonedSystem.getPhase(0).getComponent(i).getz();
Expand Down Expand Up @@ -168,7 +171,17 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException,

if ((iterations <= maxiterations - 10)
|| !system.isImplementedCompositionDeriativesofFugacity()) {
clonedSystem.init(1, j);
try {
clonedSystem.init(1, j);
} catch (Exception e) {
if (j == 0) {
clonedSystem.init(1, 1);
} else {
clonedSystem.init(1, 0);
}
logger.error(e.toString());
throw e;
}
fNormOld = fNorm;
for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) {
f.set(i, 0, Math.sqrt(Wi[j][i]) * (Math.log(Wi[j][i])
Expand Down Expand Up @@ -263,7 +276,7 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException,
// logger.info("iterations " + iterations);
// logger.info("f.norm1() " + f.norm1());
if (iterations >= maxiterations) {
// logger.error("err staability check " + error[j]);
logger.error("err staability check " + error[j]);
throw new neqsim.util.exception.TooManyIterationsException("too many iterations", null,
maxiterations);
}
Expand Down

0 comments on commit 7f887a6

Please sign in to comment.