Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refact: reorder code in PhaseEos init, remove logging #1145

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions src/main/java/neqsim/thermo/phase/PhaseEos.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,15 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int initType
}

if (initType != 0) {
try {
if (calcMolarVolume) {
if (calcMolarVolume) {
try {
molarVolume = molarVolume(pressure, temperature,
getA() / numberOfMolesInPhase / numberOfMolesInPhase, getB() / numberOfMolesInPhase,
pt);
} catch (Exception ex) {
// reraise IsNaNException and TooManyIterationsException as RuntimeException
throw new RuntimeException(ex);
}
} catch (Exception ex) {
logger.warn("Failed to solve for molarVolume within the iteration limit.");
logger.error(ex.getMessage());
throw new RuntimeException(ex);
// logger.error("too many iterations in volume calc!", ex);
// logger.info("moles " + numberOfMolesInPhase);
// logger.info("molarVolume " + getMolarVolume());
// logger.info("setting molar volume to ideal gas molar volume.............");
// setMolarVolume((R * temperature) / pressure);
// System.exit(0);
}

Z = pressure * getMolarVolume() / (R * temperature);
Expand All @@ -135,8 +128,7 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int initType
double sumAqueous = 0.0;
for (int i = 0; i < numberOfComponents; i++) {
if ((getComponent(i).isHydrocarbon() || getComponent(i).isInert()
|| getComponent(i).isIsTBPfraction())
&& !getComponent(i).getName().equals("water")
|| getComponent(i).isIsTBPfraction()) && !getComponent(i).getName().equals("water")
&& !getComponent(i).getName().equals("water_PC")) {
sumHydrocarbons += getComponent(i).getx();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ public void TPVflash(double volumeSpec, String unit) {
*/
public void TPflash() {
double flowRate = system.getTotalNumberOfMoles();
double minimumFlowRate = 1e-50;
if (flowRate < 1e-5) {
system.setTotalNumberOfMoles(1.0);
system.init(1);
Expand All @@ -162,7 +161,9 @@ public void TPflash() {
} else {
run();
}

if (flowRate < 1e-5) {
final double minimumFlowRate = 1e-50;
if (flowRate < minimumFlowRate) {
system.setTotalNumberOfMoles(minimumFlowRate);
} else {
Expand Down Expand Up @@ -1023,6 +1024,7 @@ public double[] calcImobilePhaseHydrateTemperature(double[] temperature, double[
systemTemp = system.clone();

for (int i = 0; i < temperature.length; i++) {
// todo: this function does not actually set hydTemps which is the returned variable
/*
* opsTemp = new ThermodynamicOperations(systemTemp);
* systemTemp.setTemperature(temperature[i]); systemTemp.setPressure(pressure[i]);
Expand Down