Skip to content

Commit

Permalink
improve flash
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol committed Nov 26, 2023
1 parent dad7d81 commit 7a68815
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class TPmultiflash extends TPflash {
static Logger logger = LogManager.getLogger(TPmultiflash.class);

// SystemInterface clonedSystem;
boolean startFromBottom = true;
boolean multiPhaseTest = false;
double[][] dQdbeta;
double[][] Qmatrix;
Expand Down Expand Up @@ -340,7 +341,15 @@ public void stabilityAnalysis() {
}
}

for (int j = system.getPhase(0).getNumberOfComponents() - 1; j >= 0; j--) {
int start = system.getPhase(0).getNumberOfComponents() - 1;
int end = 0;
int val = -1;
if (!startFromBottom) {
start = 0;
val = 1;
end = system.getPhase(0).getNumberOfComponents() - 1;
}
for (int j = start; j != end; j = j + val) {
if (minimumGibbsEnergySystem.getPhase(0).getComponent(j).getx() < 1e-100
|| (minimumGibbsEnergySystem.getPhase(0).getComponent(j).getIonicCharge() != 0)
|| (minimumGibbsEnergySystem.getPhase(0).getComponent(j).isHydrocarbon()
Expand Down Expand Up @@ -372,6 +381,7 @@ public void stabilityAnalysis() {
double errOld = 1.0e100;
boolean useaccsubst = true;
do {
clonedSystem.get(0).init(1);
errOld = err;
iter++;
err = 0;
Expand Down Expand Up @@ -1028,6 +1038,8 @@ public void run() {
*/
if (hasRemovedPhase && !secondTime) {
secondTime = true;
startFromBottom = false;
stabilityAnalysis();
run();
}
/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package neqsim.thermodynamicOperations.flashOps;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import neqsim.thermodynamicOperations.ThermodynamicOperations;
Expand Down Expand Up @@ -143,7 +142,7 @@ void testRun6() {

@Test
void testTPflash1() {
testSystem = new neqsim.thermo.system.SystemSrkEos(273.15 + 177.0, 316.0);
testSystem = new neqsim.thermo.system.SystemSrkEos(273.15 + 290, 400.0);
testSystem.addComponent("water", 65.93229747922976);
testSystem.addComponent("NaCl", 0.784426208131475);
testSystem.addComponent("nitrogen", 0.578509157534656);
Expand All @@ -166,23 +165,11 @@ void testTPflash1() {
testSystem.setMixingRule("classic");
testSystem.setMultiPhaseCheck(true);
testOps = new ThermodynamicOperations(testSystem);
testOps.TPflash();
testSystem.prettyPrint();

}

for (int i = 0; i < 50; i++) {
testSystem.setTemperature(i, "C");
for (int j = 1; j < 50; j++) {
testSystem.setPressure(j, "bara");
try {
testOps.TPflash();
testSystem.initProperties();
} catch (Exception e) {
System.out.println("temperature " + testSystem.getTemperature("C") + " pressure "
+ testSystem.getPressure("bara"));
e.printStackTrace();
assertTrue(false);
}
}
}


}
}

0 comments on commit 7a68815

Please sign in to comment.