From a74a7dc76e8d5261911e54b957b8e77da27b010e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?= <34712686+asmfstatoil@users.noreply.github.com> Date: Tue, 4 Oct 2022 12:55:15 +0200 Subject: [PATCH] Formatting (#541) * refact: autoformatting and fix of checkstyle violations --- .../flashOps/PHflash.java | 18 +- .../flashOps/PHflashGERG2008.java | 19 +- .../flashOps/PUflash.java | 194 +++++++++--------- .../flashOps/QfuncFlash.java | 167 ++++++++------- .../flashOps/saturationOps/FreezeOut.java | 19 +- .../flashOps/saturationOps/FugTestConstP.java | 17 +- .../HydrateFormationPressureFlash.java | 128 ++++++------ .../SolidComplexTemperatureCalc.java | 15 +- .../flashOps/saturationOps/WATcalc.java | 130 ++++++------ .../WaterDewPointEquilibriumLine.java | 4 +- 10 files changed, 371 insertions(+), 340 deletions(-) diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflash.java index 5a3a489d6b..744094c300 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflash.java @@ -78,16 +78,18 @@ public double calcdQdT() { * @return a double */ public double solveQ() { - double oldTemp = 1.0 / system.getTemperature(), nyTemp = 1.0 / system.getTemperature(); + double oldTemp = 1.0 / system.getTemperature(); + double nyTemp = 1.0 / system.getTemperature(); double iterations = 1; - double error = 1.0, erorOld = 1.0e10; + double error = 1.0; + double erorOld = 1.0e10; double factor = 0.8; double newCorr = 1.0; system.init(2); boolean correctFactor = true; - - double maxTemperature = 1e10, minTemperature = 0.0; - + double maxTemperature = 1e10; + double minTemperature = 0.0; + do { if (Math.abs(error) > Math.abs(erorOld) && factor > 0.1 && correctFactor) { factor *= 0.5; @@ -144,9 +146,11 @@ public double solveQ() { * @return a double */ public double solveQ2() { - double oldTemp = 1.0 / system.getTemperature(), nyTemp = 1.0 / system.getTemperature(); + double oldTemp = 1.0 / system.getTemperature(); + double nyTemp = 1.0 / system.getTemperature(); double iterations = 1; - double error = 1.0, erorOld = 1.0e10; + double error = 1.0; + double erorOld = 1.0e10; double factor = 0.8; double newCorr = 1.0; system.init(2); diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflashGERG2008.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflashGERG2008.java index 38bd9b2464..9357990b72 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflashGERG2008.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflashGERG2008.java @@ -77,16 +77,18 @@ public double calcdQdT() { * @return a double */ public double solveQ() { - double oldTemp = 1.0 / system.getTemperature(), nyTemp = 1.0 / system.getTemperature(); + double oldTemp = 1.0 / system.getTemperature(); + double nyTemp = 1.0 / system.getTemperature(); double iterations = 1; - double error = 1.0, erorOld = 1.0e10; + double error = 1.0; + double erorOld = 1.0e10; double factor = 0.8; double newCorr = 1.0; system.init(2); boolean correctFactor = true; - double maxTemperature = 1e10, minTemperature = 0.0; - + double maxTemperature = 1e10; + double minTemperature = 0.0; do { if (Math.abs(error) > Math.abs(erorOld) && factor > 0.1 && correctFactor) { factor *= 0.5; @@ -97,8 +99,7 @@ public double solveQ() { 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 + 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) { @@ -152,9 +153,11 @@ public double solveQ() { * @return a double */ public double solveQ2() { - double oldTemp = 1.0 / system.getTemperature(), nyTemp = 1.0 / system.getTemperature(); + double oldTemp = 1.0 / system.getTemperature(); + double nyTemp = 1.0 / system.getTemperature(); double iterations = 1; - double error = 1.0, erorOld = 1.0e10; + double error = 1.0; + double erorOld = 1.0e10; double factor = 0.8; double newCorr = 1.0; system.init(2); diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/PUflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/PUflash.java index 79bc5cdb4d..de8b27f132 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/PUflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/PUflash.java @@ -11,109 +11,111 @@ * @version $Id: $Id */ public class PUflash extends Flash { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - double Uspec = 0; - Flash tpFlash; + double Uspec = 0; + Flash tpFlash; - /** - *
- * Constructor for PUflash. - *
- */ - public PUflash() {} + /** + *+ * Constructor for PUflash. + *
+ */ + public PUflash() {} - /** - *- * Constructor for PUflash. - *
- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param Uspec a double - */ - public PUflash(SystemInterface system, double Uspec) { - this.system = system; - this.tpFlash = new TPflash(system); - this.Uspec = Uspec; - } + /** + *+ * Constructor for PUflash. + *
+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param Uspec a double + */ + public PUflash(SystemInterface system, double Uspec) { + this.system = system; + this.tpFlash = new TPflash(system); + this.Uspec = Uspec; + } - /** - *- * calcdQdTT. - *
- * - * @return a double - */ - public double calcdQdTT() { - double dQdTT = -system.getTemperature() * system.getTemperature() * system.getCv(); - return dQdTT; - } + /** + *+ * calcdQdTT. + *
+ * + * @return a double + */ + public double calcdQdTT() { + double dQdTT = -system.getTemperature() * system.getTemperature() * system.getCv(); + return dQdTT; + } - /** - *- * calcdQdT. - *
- * - * @return a double - */ - public double calcdQdT() { - double dQ = system.getInternalEnergy() - Uspec; - return dQ; - } + /** + *+ * calcdQdT. + *
+ * + * @return a double + */ + public double calcdQdT() { + double dQ = system.getInternalEnergy() - Uspec; + return dQ; + } - /** - *- * solveQ. - *
- * - * @return a double - */ - public double solveQ() { - double oldTemp = 1.0 / system.getTemperature(), nyTemp = 1.0 / system.getTemperature(); - double iterations = 1; - double error = 1.0, erorOld = 10.0e10; - double factor = 0.8; - do { - if (error > erorOld) { - factor /= 2.0; - } else if (error < erorOld && factor < 0.8) { - factor *= 1.1; - } - iterations++; - oldTemp = nyTemp; - system.init(2); - nyTemp = oldTemp - factor * calcdQdT() / calcdQdTT(); - // f(Math.abs(1.0/nyTemp-1.0/oldTemp)>5.0) nyTemp = 1.0/(1.0/oldTemp + - // Math.signum(1.0/nyTemp-1.0/oldTemp)*5.0); - if (Double.isNaN(nyTemp)) { - nyTemp = oldTemp + 1.0; - } - system.setTemperature(1.0 / nyTemp); - tpFlash.run(); - erorOld = error; - error = Math.abs((1.0 / nyTemp - 1.0 / oldTemp) / (1.0 / oldTemp)); - // System.out.println("error " + error); - // System.out.println("temperature " + system.getTemperature() + " " + - // iterations); - } while (error > 1e-8 && iterations < 500); + /** + *+ * solveQ. + *
+ * + * @return a double + */ + public double solveQ() { + double oldTemp = 1.0 / system.getTemperature(); + double nyTemp = 1.0 / system.getTemperature(); + double iterations = 1; + double error = 1.0; + double erorOld = 10.0e10; + double factor = 0.8; + do { + if (error > erorOld) { + factor /= 2.0; + } else if (error < erorOld && factor < 0.8) { + factor *= 1.1; + } + iterations++; + oldTemp = nyTemp; + system.init(2); + nyTemp = oldTemp - factor * calcdQdT() / calcdQdTT(); + // f(Math.abs(1.0/nyTemp-1.0/oldTemp)>5.0) nyTemp = 1.0/(1.0/oldTemp + + // Math.signum(1.0/nyTemp-1.0/oldTemp)*5.0); + if (Double.isNaN(nyTemp)) { + nyTemp = oldTemp + 1.0; + } + system.setTemperature(1.0 / nyTemp); + tpFlash.run(); + erorOld = error; + error = Math.abs((1.0 / nyTemp - 1.0 / oldTemp) / (1.0 / oldTemp)); + // System.out.println("error " + error); + // System.out.println("temperature " + system.getTemperature() + " " + + // iterations); + } while (error > 1e-8 && iterations < 500); - return 1.0 / nyTemp; - } + return 1.0 / nyTemp; + } - /** {@inheritDoc} */ - @Override - public void run() { - tpFlash.run(); - // System.out.println("internal energy start: " + system.getInternalEnergy()); - solveQ(); - // System.out.println("internal energy end: " + system.getInternalEnergy()); - // System.out.println("enthalpy: " + system.getEnthalpy()); - // System.out.println("Temperature: " + system.getTemperature()); - } + /** {@inheritDoc} */ + @Override + public void run() { + tpFlash.run(); + // System.out.println("internal energy start: " + system.getInternalEnergy()); + solveQ(); + // System.out.println("internal energy end: " + system.getInternalEnergy()); + // System.out.println("enthalpy: " + system.getEnthalpy()); + // System.out.println("Temperature: " + system.getTemperature()); + } - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - return null; - } + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + return null; + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/QfuncFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/QfuncFlash.java index f7e0ad1e45..8e94a55d2c 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/QfuncFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/QfuncFlash.java @@ -13,96 +13,95 @@ * @version $Id: $Id */ public class QfuncFlash extends Flash { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(QfuncFlash.class); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(QfuncFlash.class); - double Hspec = 0; - Flash tpFlash; - int type = 0; + double Hspec = 0; + Flash tpFlash; + int type = 0; - /** - *- * Constructor for QfuncFlash. - *
- */ - public QfuncFlash() {} + /** + *+ * Constructor for QfuncFlash. + *
+ */ + public QfuncFlash() {} - /** - *- * Constructor for QfuncFlash. - *
- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param Hspec a double - * @param type a int - */ - public QfuncFlash(SystemInterface system, double Hspec, int type) { - this.system = system; - this.tpFlash = new TPflash(system); - this.Hspec = Hspec; - this.type = type; - } + /** + *+ * Constructor for QfuncFlash. + *
+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param Hspec a double + * @param type a int + */ + public QfuncFlash(SystemInterface system, double Hspec, int type) { + this.system = system; + this.tpFlash = new TPflash(system); + this.Hspec = Hspec; + this.type = type; + } - /** - *- * calcdQdTT. - *
- * - * @return a double - */ - public double calcdQdTT() { - double dQdTT = -system.getTemperature() * system.getTemperature() * system.getCp(); - return dQdTT; - } + /** + *+ * calcdQdTT. + *
+ * + * @return a double + */ + public double calcdQdTT() { + double dQdTT = -system.getTemperature() * system.getTemperature() * system.getCp(); + return dQdTT; + } - /** - *- * calcdQdT. - *
- * - * @return a double - */ - public double calcdQdT() { - double dQ = system.getEnthalpy() - Hspec; - return dQ; - } + /** + *+ * calcdQdT. + *
+ * + * @return a double + */ + public double calcdQdT() { + double dQ = system.getEnthalpy() - Hspec; + return dQ; + } - /** - *- * solveQ. - *
- * - * @return a double - */ - public double solveQ() { - double oldTemp = 1.0 / system.getTemperature(), nyTemp = 1.0 / system.getTemperature(); - double iterations = 1; - do { - iterations++; - oldTemp = nyTemp; - system.init(3); - nyTemp = oldTemp - calcdQdT() / calcdQdTT(); - system.setTemperature(1.0 / nyTemp); - tpFlash.run(); - } while (Math.abs((1.0 / nyTemp - 1.0 / oldTemp) / (1.0 / nyTemp)) > 1e-9 - && iterations < 1000); - return 1.0 / nyTemp; - } + /** + *+ * solveQ. + *
+ * + * @return a double + */ + public double solveQ() { + double oldTemp = 1.0 / system.getTemperature(), nyTemp = 1.0 / system.getTemperature(); + double iterations = 1; + do { + iterations++; + oldTemp = nyTemp; + system.init(3); + nyTemp = oldTemp - calcdQdT() / calcdQdTT(); + system.setTemperature(1.0 / nyTemp); + tpFlash.run(); + } while (Math.abs((1.0 / nyTemp - 1.0 / oldTemp) / (1.0 / nyTemp)) > 1e-9 && iterations < 1000); + return 1.0 / nyTemp; + } - /** {@inheritDoc} */ - @Override - public void run() { - tpFlash.run(); - logger.info("entropy: " + system.getEntropy()); - sysNewtonRhapsonPHflash secondOrderSolver = new sysNewtonRhapsonPHflash(system, 2, - system.getPhases()[0].getNumberOfComponents(), type); - secondOrderSolver.setSpec(Hspec); - secondOrderSolver.solve(1); - } + /** {@inheritDoc} */ + @Override + public void run() { + tpFlash.run(); + logger.info("entropy: " + system.getEntropy()); + sysNewtonRhapsonPHflash secondOrderSolver = + new sysNewtonRhapsonPHflash(system, 2, system.getPhases()[0].getNumberOfComponents(), type); + secondOrderSolver.setSpec(Hspec); + secondOrderSolver.solve(1); + } - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - return null; - } + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + return null; + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/FreezeOut.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/FreezeOut.java index 5955d0fdb0..fa2c78c819 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/FreezeOut.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/FreezeOut.java @@ -53,12 +53,21 @@ public void run() { // double[][] Fug = new double[12][35]; // double[][] Fugrel = new double[2][40]; int iterations = 0; - double newTemp = 0, OldTemp = 0; + double newTemp = 0; + double OldTemp = 0; double FugRatio; - double T2low = 0, T2high = 0; - boolean Left = true, half = false; - double SolidFug = 0.0, FluidFug = 0.0, temp = 0.0, pres = 0.0, Pvapsolid = 0.0; - double solvol = 0.0, soldens = 0.0, trpTemp = 0.0; + double T2low = 0; + double T2high = 0; + boolean Left = true; + boolean half = false; + double SolidFug = 0.0; + double FluidFug = 0.0; + double temp = 0.0; + double pres = 0.0; + double Pvapsolid = 0.0; + double solvol = 0.0; + double soldens = 0.0; + double trpTemp = 0.0; boolean CCequation = true; boolean noFreezeliq = true; boolean SolidForms = true; diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/FugTestConstP.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/FugTestConstP.java index 5c9f553499..4f14e68f43 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/FugTestConstP.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/FugTestConstP.java @@ -20,9 +20,12 @@ public class FugTestConstP extends constantDutyTemperatureFlash implements ThermodynamicConstantsInterface { private static final long serialVersionUID = 1000; static Logger logger = LogManager.getLogger(FugTestConstP.class); - public double temp = 0.0, pres = 0.0; - public SystemInterface testSystem, testSystem2; - public ThermodynamicOperations testOps, testOps2; + public double temp = 0.0; + public double pres = 0.0; + public SystemInterface testSystem; + public SystemInterface testSystem2; + public ThermodynamicOperations testOps; + public ThermodynamicOperations testOps2; public int compNumber = 0; public String compName; public boolean compNameGiven = false; @@ -79,9 +82,13 @@ public void initTestSystem2(int K) { /** {@inheritDoc} */ @Override public void run() { - double SolidFug = 0.0, Pvapsolid = 0.0, SolVapFugCoeff = 0.0; + double SolidFug = 0.0; + double Pvapsolid = 0.0; + double SolVapFugCoeff = 0.0; // double dfugdt = 0.0; - double solvol = 0.0, soldens = 0.0, trpTemp = 0.0; + double solvol = 0.0; + double soldens = 0.0; + double trpTemp = 0.0; boolean CCequation = true; double[][] Fug = new double[4][20]; double[][] Fugrel = new double[2][20]; diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/HydrateFormationPressureFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/HydrateFormationPressureFlash.java index daa05bc8ba..626aa79402 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/HydrateFormationPressureFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/HydrateFormationPressureFlash.java @@ -15,75 +15,75 @@ * @version $Id: $Id */ public class HydrateFormationPressureFlash extends constantDutyTemperatureFlash { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(HydrateFormationPressureFlash.class); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(HydrateFormationPressureFlash.class); - /** - *- * Constructor for HydrateFormationPressureFlash. - *
- */ - public HydrateFormationPressureFlash() {} + /** + *+ * Constructor for HydrateFormationPressureFlash. + *
+ */ + public HydrateFormationPressureFlash() {} - /** - *- * Constructor for HydrateFormationPressureFlash. - *
- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public HydrateFormationPressureFlash(SystemInterface system) { - super(system); - } + /** + *+ * Constructor for HydrateFormationPressureFlash. + *
+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public HydrateFormationPressureFlash(SystemInterface system) { + super(system); + } - /** {@inheritDoc} */ - @Override - public void run() { - double olfFug = 0.0; - // system.setHydrateCheck(true); - ThermodynamicOperations ops = new ThermodynamicOperations(system); - system.getPhase(4).getComponent("water").setx(1.0); - system.init(0); - system.init(1); - int iter = 0; - do { - iter++; - olfFug = system.getPhase(4).getFugacity("water"); - setFug(); - ops.TPflash(); + /** {@inheritDoc} */ + @Override + public void run() { + double olfFug = 0.0; + // system.setHydrateCheck(true); + ThermodynamicOperations ops = new ThermodynamicOperations(system); + system.getPhase(4).getComponent("water").setx(1.0); + system.init(0); + system.init(1); + int iter = 0; + do { + iter++; + olfFug = system.getPhase(4).getFugacity("water"); + setFug(); + ops.TPflash(); - system.init(1); - system.getPhase(4).getComponent("water").setx(1.0); - logger.info("diff " + (system.getPhase(4).getFugacity("water") - / system.getPhase(0).getFugacity("water"))); - system.setPressure(system.getPressure() * (system.getPhase(4).getFugacity("water") - / system.getPhase(0).getFugacity("water"))); - logger.info("pressure " + system.getPressure()); - // logger.info("x water " + system.getPhase(3).getComponent("water").getx()); - } while (Math.abs((olfFug - system.getPhase(4).getFugacity("water")) / olfFug) > 1e-8 - && iter < 100); - // logger.info("hydrate structure = " + ((ComponentHydrate) - // system.getPhase(3).getComponent("water")).getHydrateStructure()); - logger.info("end"); - } + system.init(1); + system.getPhase(4).getComponent("water").setx(1.0); + logger.info("diff " + + (system.getPhase(4).getFugacity("water") / system.getPhase(0).getFugacity("water"))); + system.setPressure(system.getPressure() + * (system.getPhase(4).getFugacity("water") / system.getPhase(0).getFugacity("water"))); + logger.info("pressure " + system.getPressure()); + // logger.info("x water " + system.getPhase(3).getComponent("water").getx()); + } while (Math.abs((olfFug - system.getPhase(4).getFugacity("water")) / olfFug) > 1e-8 + && iter < 100); + // logger.info("hydrate structure = " + ((ComponentHydrate) + // system.getPhase(3).getComponent("water")).getHydrateStructure()); + logger.info("end"); + } - /** - *- * setFug. - *
- */ - public void setFug() { - for (int j = 0; j < system.getPhase(0).getNumberOfComponents(); j++) { - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - ((ComponentHydrate) system.getPhase(4).getComponent(j)).setRefFug(i, - system.getPhase(0).getFugacity(i)); - } - } - system.getPhase(4).getComponent("water").fugcoef(system.getPhase(4)); - system.getPhase(4).getComponent("water").setx(1.0); + /** + *+ * setFug. + *
+ */ + public void setFug() { + for (int j = 0; j < system.getPhase(0).getNumberOfComponents(); j++) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + ((ComponentHydrate) system.getPhase(4).getComponent(j)).setRefFug(i, + system.getPhase(0).getFugacity(i)); + } } + system.getPhase(4).getComponent("water").fugcoef(system.getPhase(4)); + system.getPhase(4).getComponent("water").setx(1.0); + } - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/SolidComplexTemperatureCalc.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/SolidComplexTemperatureCalc.java index 8bf209a8af..54543cc36f 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/SolidComplexTemperatureCalc.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/SolidComplexTemperatureCalc.java @@ -17,7 +17,8 @@ public class SolidComplexTemperatureCalc extends constantDutyTemperatureFlash { private static final long serialVersionUID = 1000; static Logger logger = LogManager.getLogger(SolidComplexTemperatureCalc.class); - String comp1, comp2; + String comp1; + String comp2; /** ConstantKcomplex=0.133736021815520500
. */
public static double Kcomplex = 0.133736021815520500;
/** Constant HrefComplex=4598.717135
. */
@@ -88,7 +89,8 @@ public void runOld() {
// system.setHydrateCheck(true);
ThermodynamicOperations ops = new ThermodynamicOperations(system);
int iter = 0;
- double funkOld = 0.0, deltaT = 1.0;
+ double funkOld = 0.0;
+ double deltaT = 1.0;
double[] Ksolid = new double[system.getPhase(0).getNumberOfComponents()];
for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) {
Ksolid[i] = 1.0;
@@ -145,12 +147,15 @@ public void run() {
double deltaT = 1.0;
// logger.info("starting.... ");
- int compNumber_1 = system.getPhase(0).getComponent(comp1).getComponentNumber(),
- compNumber_2 = system.getPhase(0).getComponent(comp2).getComponentNumber();
+ int compNumber_1 = system.getPhase(0).getComponent(comp1).getComponentNumber();
// MEGwater parameters
- double temperature = 0.0, oldTemperature = 0.0, oldError = 0.0, error = 0.0;
+ int compNumber_2 = system.getPhase(0).getComponent(comp2).getComponentNumber();
+ double temperature = 0.0;
+ double oldTemperature = 0.0;
+ double oldError = 0.0;
+ double error = 0.0;
boolean testFalse = true;
int iteration = 0;
do {
diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/WATcalc.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/WATcalc.java
index 0906c556fb..b9b7d8fbf5 100644
--- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/WATcalc.java
+++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/WATcalc.java
@@ -14,75 +14,75 @@
* @version $Id: $Id
*/
public class WATcalc extends constantDutyTemperatureFlash {
- private static final long serialVersionUID = 1000;
- static Logger logger = LogManager.getLogger(WATcalc.class);
+ private static final long serialVersionUID = 1000;
+ static Logger logger = LogManager.getLogger(WATcalc.class);
- /**
- * - * Constructor for WATcalc. - *
- */ - public WATcalc() {} + /** + *+ * Constructor for WATcalc. + *
+ */ + public WATcalc() {} - /** - *- * Constructor for WATcalc. - *
- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public WATcalc(SystemInterface system) { - super(system); - } + /** + *+ * Constructor for WATcalc. + *
+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public WATcalc(SystemInterface system) { + super(system); + } - /** {@inheritDoc} */ - @Override - public void run() { - double sumx = 0.0; - // system.setHydrateCheck(true); - ThermodynamicOperations ops = new ThermodynamicOperations(system); - int iter = 0; - double funkOld = 0.0, deltaT = 1.0; - double[] Ksolid = new double[system.getPhase(0).getNumberOfComponents()]; - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - system.getPhases()[5].getComponent(i).setx(1.0); - Ksolid[i] = 1.0; - } - do { - iter++; - ops.TPflash(); + /** {@inheritDoc} */ + @Override + public void run() { + double sumx = 0.0; + // system.setHydrateCheck(true); + ThermodynamicOperations ops = new ThermodynamicOperations(system); + int iter = 0; + double funkOld = 0.0, deltaT = 1.0; + double[] Ksolid = new double[system.getPhase(0).getNumberOfComponents()]; + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + system.getPhases()[5].getComponent(i).setx(1.0); + Ksolid[i] = 1.0; + } + do { + iter++; + ops.TPflash(); - sumx = 0.0; - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - system.getPhases()[5].getComponent(i) - .setx(Ksolid[i] * system.getPhase(0).getComponent(i).getx()); - Ksolid[i] = system.getPhase(0).getComponent(i).getFugacityCoefficient() - / system.getPhases()[5].getComponent(i).fugcoef(system.getPhases()[5]); - sumx += Ksolid[i] * system.getPhase(0).getComponent(i).getx(); - } - double funk = sumx - 1.0; - double dfunkdt = (funk - funkOld) / deltaT; - funkOld = funk; - double dT = -funk / dfunkdt; - double oldTemp = system.getTemperature(); - if (iter > 1) { - system.setTemperature(system.getTemperature() + dT * iter * 1.0 / (5.0 + iter)); - } else { - system.setTemperature(system.getTemperature() - 0.1); - } - deltaT = system.getTemperature() - oldTemp; - // logger.info("sumx " + sumx + " deltaT "+ deltaT + " dT "+dT + " temperature " - // + system.getTemperature()); - } while (Math.abs(sumx - 1.0) > 1e-8 && iter < 100); - // logger.info("sumx " + sumx); + sumx = 0.0; + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + system.getPhases()[5].getComponent(i) + .setx(Ksolid[i] * system.getPhase(0).getComponent(i).getx()); + Ksolid[i] = system.getPhase(0).getComponent(i).getFugacityCoefficient() + / system.getPhases()[5].getComponent(i).fugcoef(system.getPhases()[5]); + sumx += Ksolid[i] * system.getPhase(0).getComponent(i).getx(); + } + double funk = sumx - 1.0; + double dfunkdt = (funk - funkOld) / deltaT; + funkOld = funk; + double dT = -funk / dfunkdt; + double oldTemp = system.getTemperature(); + if (iter > 1) { + system.setTemperature(system.getTemperature() + dT * iter * 1.0 / (5.0 + iter)); + } else { + system.setTemperature(system.getTemperature() - 0.1); + } + deltaT = system.getTemperature() - oldTemp; + // logger.info("sumx " + sumx + " deltaT "+ deltaT + " dT "+dT + " temperature " + // + system.getTemperature()); + } while (Math.abs(sumx - 1.0) > 1e-8 && iter < 100); + // logger.info("sumx " + sumx); - system.setNumberOfPhases(system.getNumberOfPhases() + 1); - system.setPhaseIndex(system.getNumberOfPhases() - 1, 5); - system.setBeta(system.getNumberOfPhases() - 1, 1e-10); - system.init(3); - } + system.setNumberOfPhases(system.getNumberOfPhases() + 1); + system.setPhaseIndex(system.getNumberOfPhases() - 1, 5); + system.setBeta(system.getNumberOfPhases() - 1, 1e-10); + system.init(3); + } - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/WaterDewPointEquilibriumLine.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/WaterDewPointEquilibriumLine.java index ec4ac5c7ca..24369eae9c 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/WaterDewPointEquilibriumLine.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/WaterDewPointEquilibriumLine.java @@ -15,7 +15,9 @@ public class WaterDewPointEquilibriumLine extends constantDutyTemperatureFlash { private static final long serialVersionUID = 1000; double[][] hydratePoints = null; - double minPressure = 1.0, maxPressure = 200.0; + double minPressure = 1.0; + double maxPressure = 200.0; + int numberOfPoints = 10; /**