From f8b602d7b5a52f27af51e808518a8ec66bff2185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?= Date: Fri, 7 Jan 2022 18:33:56 +0100 Subject: [PATCH 1/2] refact: commented out dead code --- .../flashOps/PHflash.java | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflash.java index 079d341de0..05d82ced2d 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflash.java @@ -128,20 +128,16 @@ public double solveQ() { minTemperature = system.getTemperature(); } - if (false && error * erorOld < 0) { - system.setTemperature( - (Math.abs(erorOld) * 1.0 / oldTemp + Math.abs(error) * 1.0 / nyTemp) - / (Math.abs(erorOld) + Math.abs(error))); - tpFlash.run(); - system.init(2); - erorOld = error; - error = calcdQdT(); - System.out.println("reset temperature -- new temp " + system.getTemperature() - + " error " + error + " iter " + iterations); - } - // error = Math.abs((1.0 / nyTemp - 1.0 / oldTemp) / (1.0 / oldTemp)); - // System.out.println("temp " + system.getTemperature() + " iter "+ iterations + - // " error "+ error + " correction " + newCorr + " factor "+ factor); + /* + * if (false && error * erorOld < 0) { system.setTemperature( (Math.abs(erorOld) * 1.0 / + * oldTemp + Math.abs(error) * 1.0 / nyTemp) / (Math.abs(erorOld) + Math.abs(error))); + * tpFlash.run(); system.init(2); erorOld = error; error = calcdQdT(); + * System.out.println("reset temperature -- new temp " + system.getTemperature() + + * " error " + error + " iter " + iterations); } error = Math.abs((1.0 / nyTemp - 1.0 / + * oldTemp) / (1.0 / oldTemp)); System.out.println("temp " + system.getTemperature() + + * " iter "+ iterations + " error "+ error + " correction " + newCorr + " factor "+ + * factor); + */ } while (((Math.abs(error) + Math.abs(erorOld)) > 1e-8 || iterations < 3) && iterations < 200); // System.out.println("temp " + system.getTemperature() + " iter " + iterations From aff6f78e03348a6df94c64e60e822fa55a9e6efc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?= Date: Fri, 14 Jan 2022 21:11:25 +0100 Subject: [PATCH 2/2] chore: rm dead code --- .../flashOps/PHflashGERG2008.java | 47 ++++++++++--------- .../OLGApropertyTableGeneratorWater.java | 11 +++-- .../OLGApropertyTableGeneratorWaterEven.java | 13 +++-- ...GApropertyTableGeneratorWaterStudents.java | 5 +- ...propertyTableGeneratorWaterStudentsPH.java | 5 +- 5 files changed, 45 insertions(+), 36 deletions(-) diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflashGERG2008.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflashGERG2008.java index 45a5881c09..b38f10cc53 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflashGERG2008.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflashGERG2008.java @@ -22,6 +22,7 @@ public class PHflashGERG2008 extends Flash { Flash tpFlash; double enthalpy_GERG2008 = 0.0; double cP_GERG2008 = 0.0; + /** *

* Constructor for PHflashGERG2008. @@ -64,7 +65,7 @@ public double calcdQdTT() { * @return a double */ public double calcdQdT() { - double dQ = (enthalpy_GERG2008 - Hspec) / Math.abs(Hspec); + double dQ = (enthalpy_GERG2008 - Hspec) / Math.abs(Hspec); return dQ; } @@ -95,8 +96,9 @@ public double solveQ() { iterations++; oldTemp = nyTemp; double[] gergProps = system.getPhase(0).getProperties_GERG2008(); - cP_GERG2008 = gergProps[10]*system.getPhase(0).getNumberOfMolesInPhase(); // J/mol K - enthalpy_GERG2008 = gergProps[7]*system.getPhase(0).getNumberOfMolesInPhase(); // J/mol K + cP_GERG2008 = gergProps[10] * system.getPhase(0).getNumberOfMolesInPhase(); // J/mol K + enthalpy_GERG2008 = gergProps[7] * system.getPhase(0).getNumberOfMolesInPhase(); // J/mol + // K newCorr = factor * calcdQdT() / calcdQdTT(); nyTemp = oldTemp - newCorr; if (Math.abs(system.getTemperature() - 1.0 / nyTemp) > 10.0) { @@ -127,18 +129,16 @@ public double solveQ() { minTemperature = system.getTemperature(); } - if (false && error * erorOld < 0) { - system.setTemperature( - (Math.abs(erorOld) * 1.0 / oldTemp + Math.abs(error) * 1.0 / nyTemp) - / (Math.abs(erorOld) + Math.abs(error))); - erorOld = error; - error = calcdQdT(); - System.out.println("reset temperature -- new temp " + system.getTemperature() - + " error " + error + " iter " + iterations); - } - // error = Math.abs((1.0 / nyTemp - 1.0 / oldTemp) / (1.0 / oldTemp)); - // System.out.println("temp " + system.getTemperature() + " iter "+ iterations + - // " error "+ error + " correction " + newCorr + " factor "+ factor); + /* + * if (false && error * erorOld < 0) { system.setTemperature( (Math.abs(erorOld) * 1.0 / + * oldTemp + Math.abs(error) * 1.0 / nyTemp) / (Math.abs(erorOld) + Math.abs(error))); + * erorOld = error; error = calcdQdT(); + * System.out.println("reset temperature -- new temp " + system.getTemperature() + + * " error " + error + " iter " + iterations); } // error = Math.abs((1.0 / nyTemp - 1.0 + * / oldTemp) / (1.0 / oldTemp)); // System.out.println("temp " + + * system.getTemperature() + " iter "+ iterations + // " error "+ error + " correction " + * + newCorr + " factor "+ factor); + */ } while (((Math.abs(error) + Math.abs(erorOld)) > 1e-8 || iterations < 3) && iterations < 200); // System.out.println("temp " + system.getTemperature() + " iter " + iterations @@ -171,9 +171,10 @@ public double solveQ2() { iterations++; oldTemp = nyTemp; double[] gergProps = system.getPhase(0).getProperties_GERG2008(); - cP_GERG2008 = gergProps[10]*system.getPhase(0).getNumberOfMolesInPhase(); // J/mol K - enthalpy_GERG2008 = gergProps[7]*system.getPhase(0).getNumberOfMolesInPhase(); // J/mol K - + cP_GERG2008 = gergProps[10] * system.getPhase(0).getNumberOfMolesInPhase(); // J/mol K + enthalpy_GERG2008 = gergProps[7] * system.getPhase(0).getNumberOfMolesInPhase(); // J/mol + // K + newCorr = factor * calcdQdT() / calcdQdTT(); nyTemp = oldTemp - newCorr; if (Math.abs(system.getTemperature() - 1.0 / nyTemp) > 10.0) { @@ -206,12 +207,12 @@ public double solveQ2() { @Override public void run() { tpFlash.run(); - if(system.getNumberOfPhases()>1) { - logger.error("PSFlashGERG2008 only supprt single phase gas calculations"); - return; + if (system.getNumberOfPhases() > 1) { + logger.error("PSFlashGERG2008 only support single phase gas calculations"); + return; } - solveQ(); - system.init(3); + solveQ(); + system.init(3); } /** {@inheritDoc} */ diff --git a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWater.java b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWater.java index b41c19d360..827866df42 100644 --- a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWater.java +++ b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWater.java @@ -250,8 +250,10 @@ public void initCalc() { thermoOps.TPflash(); - // GOR = thermoSystem.getPhase(0).getTotalVolume() / thermoSystem.getPhase(1).getTotalVolume(); - // GLR = thermoSystem.getPhase(0).getTotalVolume() / thermoSystem.getPhase(1).getTotalVolume(); + // GOR = thermoSystem.getPhase(0).getTotalVolume() / + // thermoSystem.getPhase(1).getTotalVolume(); + // GLR = thermoSystem.getPhase(0).getTotalVolume() / + // thermoSystem.getPhase(1).getTotalVolume(); } /** @@ -427,8 +429,9 @@ public void run() { k++; } while (k < 9);// names[k] = "GAS DENSITY"; // units[k] = "KG/M3"; - } else if (false && !hasGasValues) { - // startGasTemperatures = j; + /* + * } else if (false && !hasGasValues) { startGasTemperatures = j; + */ } else { gasSystem.setTemperature(temperatures[j]); gasSystem.setPressure(pressures[i]); diff --git a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterEven.java b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterEven.java index 5473f68f1b..b02fc08bb7 100644 --- a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterEven.java +++ b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterEven.java @@ -219,8 +219,10 @@ public void initCalc() { thermoOps.TPflash(); - // GOR = thermoSystem.getPhase(0).getTotalVolume() / thermoSystem.getPhase(1).getTotalVolume(); - // GLR = thermoSystem.getPhase(0).getTotalVolume() / thermoSystem.getPhase(1).getTotalVolume(); + // GOR = thermoSystem.getPhase(0).getTotalVolume() / + // thermoSystem.getPhase(1).getTotalVolume(); + // GLR = thermoSystem.getPhase(0).getTotalVolume() / + // thermoSystem.getPhase(1).getTotalVolume(); } /** @@ -250,7 +252,7 @@ public void run() { units = new String[nProps]; names = new String[nProps]; - int startGasTemperatures = 0; + // int startGasTemperatures = 0; boolean acceptedFlash = true; for (int j = 0; j < temperatures.length; j++) { thermoSystem.setTemperature(temperatures[j]); @@ -395,9 +397,10 @@ public void run() { k++; } while (k < 9);// names[k] = "GAS DENSITY"; // units[k] = "KG/M3"; - } else if (false && !hasGasValues) { - startGasTemperatures = j; } + /* + * else if (false && !hasGasValues) { startGasTemperatures = j; } + */ } /* * double[] gasVals = new double[9]; for (int kk = 0; kk < 9; kk++) { gasVals[kk] = diff --git a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudents.java b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudents.java index 4ca06c8c89..110c596b85 100644 --- a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudents.java +++ b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudents.java @@ -505,8 +505,9 @@ public void run() { k++; } while (k < 9);// names[k] = "GAS DENSITY"; // units[k] = "KG/M3"; - } else if (false && !hasGasValues) { - // startGasTemperatures = j; + /* + * } else if (false && !hasGasValues) { startGasTemperatures = j; + */ } else { gasSystem.setTemperature(temperatures[j]); gasSystem.setPressure(pressures[i]); diff --git a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudentsPH.java b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudentsPH.java index a08263dcd7..d9169a2ce2 100644 --- a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudentsPH.java +++ b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudentsPH.java @@ -503,8 +503,9 @@ public void run() { k++; } while (k < 9);// names[k] = "GAS DENSITY"; // units[k] = "KG/M3"; - } else if (false && !hasGasValues) { - // startGasTemperatures = j; + /* + * } else if (false && !hasGasValues) { startGasTemperatures = j; + */ } else { gasSystem.setTemperature(enthalpies[j]); gasSystem.setPressure(pressures[i]);