Skip to content

Commit

Permalink
set method for force single phase type (#1134)
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol authored Oct 16, 2024
1 parent d6d5203 commit 4efcea6
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/main/java/neqsim/thermo/system/SystemInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -2612,4 +2612,24 @@ public void setImplementedTemperatureDeriativesofFugacity(
* @return a {@link java.lang.String} object
*/
public String toCompJson();

/**
* <p>
* setForceSinglePhase - force the fluid to be single phase of type as spesified by phasetype
* input
* </p>
*
* @param phasetype a {@link neqsim.thermo.phase.PhaseType} object
*/
public void setForceSinglePhase(PhaseType phasetype);

/**
* <p>
* setForceSinglePhase - force the fluid to be single phase of type as spesified by phasetype
* input. phasetypename can be GAS, OIL and AQUEOUS
* </p>
*
* @param phasetypename a {@link java.lang.String} object
*/
public void setForceSinglePhase(String phasetypename);
}
16 changes: 16 additions & 0 deletions src/main/java/neqsim/thermo/system/SystemThermo.java
Original file line number Diff line number Diff line change
Expand Up @@ -5071,4 +5071,20 @@ public String toCompJson() {
return new GsonBuilder().create()
.toJson(new neqsim.processsimulation.util.monitor.FluidComponentResponse(this));
}

/** {@inheritDoc} */
@Override
public void setForceSinglePhase(PhaseType phasetype) {
this.init(0);
this.setNumberOfPhases(1);
this.setMaxNumberOfPhases(1);
this.setForcePhaseTypes(true);
this.setPhaseType(0, phasetype);
}

/** {@inheritDoc} */
@Override
public void setForceSinglePhase(String phasetype) {
setForceSinglePhase(PhaseType.byName(phasetype));
}
}
29 changes: 29 additions & 0 deletions src/test/java/neqsim/thermo/system/SystemThermoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermodynamicoperations.ThermodynamicOperations;

class SystemThermoTest extends neqsim.NeqSimTest {
Expand Down Expand Up @@ -118,4 +119,32 @@ void testDisplay() {
SystemEos s = new SystemPrEos();
s.display();
}

@Test
void TESTsetForceSinglePhase() {
testSystem = new neqsim.thermo.system.SystemPrEos(298.0, 10.0);
testSystem.addComponent("nitrogen", 0.01);
testSystem.addComponent("CO2", 0.01);
testSystem.addComponent("methane", 0.68);
testSystem.setMixingRule("classic");
ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem);
testOps.TPflash();
testSystem.initProperties();


double density = testSystem.getDensity("kg/m3");

testSystem.setForceSinglePhase(PhaseType.GAS);
testSystem.initProperties();

assertEquals(density, testSystem.getDensity("kg/m3"), 1e-4);

testSystem.setForceSinglePhase("GAS");
testOps.TPflash();
testSystem.initProperties();

assertEquals(density, testSystem.getDensity("kg/m3"), 1e-4);


}
}

0 comments on commit 4efcea6

Please sign in to comment.