Skip to content

Commit

Permalink
fix solid flash (#975)
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol authored Mar 31, 2024
1 parent d85c9d2 commit ae2bc5f
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 17 deletions.
36 changes: 20 additions & 16 deletions src/main/java/neqsim/thermo/component/ComponentSolid.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,11 @@ public double fugcoef(double temp, double pres) {
public double fugcoef2(PhaseInterface phase1) {
refPhase.setTemperature(phase1.getTemperature());
refPhase.setPressure(phase1.getPressure());
refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, PhaseType.byValue(0), 1.0);
try {
refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, PhaseType.byValue(0), 1.0);
} catch (Exception ex) {
logger.error(ex.getMessage());
}
refPhase.getComponent(0).fugcoef(refPhase);

double liquidPhaseFugacity =
Expand Down Expand Up @@ -230,22 +234,22 @@ public double getMolarVolumeSolid() {
*/
public void setSolidRefFluidPhase(PhaseInterface phase) {
try {
if ((!isTBPfraction && !isPlusFraction)
|| neqsim.util.database.NeqSimDataBase.createTemporaryTables()) {
refPhase = phase.getClass().getDeclaredConstructor().newInstance();
refPhase.setTemperature(273.0);
refPhase.setPressure(1.0);
try {
refPhase.addComponent(componentName, 10.0, 10.0, 0);
} catch (Exception ex) {
logger.error("error occured in setSolidRefFluidPhase ", ex);
refPhase.addComponent("methane", 10.0, 10.0, 0);
refPhase.getComponent("methane").setComponentName(componentName);
}
refPhase.getComponent(componentName)
.setAttractiveTerm(phase.getComponent(componentName).getAttractiveTermNumber());
refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 0, PhaseType.byValue(1), 1.0);
// if ((!isTBPfraction && !isPlusFraction)
// || neqsim.util.database.NeqSimDataBase.createTemporaryTables()) {
refPhase = phase.getClass().getDeclaredConstructor().newInstance();
refPhase.setTemperature(273.0);
refPhase.setPressure(1.0);
try {
refPhase.addComponent(componentName, 10.0, 10.0, 0);
} catch (Exception ex) {
logger.error("error occured in setSolidRefFluidPhase ", ex);
refPhase.addComponent("methane", 10.0, 10.0, 0);
refPhase.getComponent("methane").setComponentName(componentName);
}
refPhase.getComponent(componentName)
.setAttractiveTerm(phase.getComponent(componentName).getAttractiveTermNumber());
refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 0, PhaseType.byValue(1), 1.0);
// }
} catch (Exception ex) {
logger.error("error occured", ex);
}
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/neqsim/thermo/phase/PhaseSolid.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ public PhaseSolid clone() {
@Override
public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt,
double beta) {
super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta);
try {
super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta);
} catch (Exception ex) {
logger.error(ex.getMessage());
}
setType(PhaseType.SOLID);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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.Test;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermodynamicOperations.ThermodynamicOperations;

/**
* @author ESOL
*/
class TPsolidFlash {
@Test
void testSolidFLash() {
neqsim.thermo.system.SystemPrEos testSystem =
new neqsim.thermo.system.SystemPrEos(283.15, 20.0);
testSystem.addComponent("CO2", 1.0);
testSystem.addComponent("methane", 80.0);
testSystem.addComponent("ethane", 5.0);
testSystem.addTBPfraction("C11", 0.01, 150.0 / 1000.0, 0.82);
testSystem.addTBPfraction("C12", 0.01, 170.0 / 1000.0, 0.84);
testSystem.addComponent("S8", 10.0);
testSystem.setMixingRule("classic");
testSystem.setMultiPhaseCheck(true);
testSystem.setSolidPhaseCheck("S8");
ThermodynamicOperations thermoops = new ThermodynamicOperations(testSystem);
// thermoops.TPflash();
thermoops.TPSolidflash();
// testSystem.prettyPrint();
assertEquals(3, testSystem.getNumberOfPhases());
assertTrue(testSystem.hasPhaseType(PhaseType.SOLID));

// System.out.println(
// "kg S8 per kg HC " + (testSystem.getPhase(0).getComponent("S8").getFlowRate("kg/hr")
// + testSystem.getPhase(1).getComponent("S8").getFlowRate("kg/hr"))
// / (testSystem.getPhase(0).getFlowRate("kg/hr")
// + testSystem.getPhase(1).getFlowRate("kg/hr")));

}

}

0 comments on commit ae2bc5f

Please sign in to comment.