From d63864619b0e100b4121c21a83e832f31b760da9 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, 9 May 2023 23:05:34 +0200 Subject: [PATCH] refact: clean up setBeta/getBeta functions and docfix (#671) * refact: cleanup various setBeta stuff --- .../dataPresentation/SampleXYDataSource.java | 7 +- .../dataPresentation/userInterface.java | 26 --- .../neqsim/thermo/component/Component.java | 8 +- .../thermo/component/ComponentInterface.java | 15 +- src/main/java/neqsim/thermo/phase/Phase.java | 22 ++- .../neqsim/thermo/phase/PhaseInterface.java | 25 +-- .../neqsim/thermo/system/SystemInterface.java | 152 +++++++++--------- .../neqsim/thermo/system/SystemThermo.java | 6 +- .../ThermodynamicOperations.java | 20 +-- .../flashOps/Flash.java | 13 +- .../flashOps/TPflash.java | 2 +- ...e.java => ConstantDutyFlashInterface.java} | 13 +- .../saturationOps/constantDutyFlash.java | 10 +- .../thermo/util/example/FreezeMEGwater.java | 3 - 14 files changed, 151 insertions(+), 171 deletions(-) delete mode 100644 src/main/java/neqsim/dataPresentation/userInterface.java rename src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/{constantDutyFlashInterface.java => ConstantDutyFlashInterface.java} (59%) diff --git a/src/main/java/neqsim/dataPresentation/SampleXYDataSource.java b/src/main/java/neqsim/dataPresentation/SampleXYDataSource.java index d3f36ad31d..dac34dedda 100644 --- a/src/main/java/neqsim/dataPresentation/SampleXYDataSource.java +++ b/src/main/java/neqsim/dataPresentation/SampleXYDataSource.java @@ -19,12 +19,11 @@ /** * A dummy data source for an XY plot. - *

+ * + *

* Note that the aim of this class is to create a self-contained data source for demo purposes - it * is NOT intended to show how you should go about writing your own data sources. - * - * @author asmund - * @version $Id: $Id + *

*/ public class SampleXYDataSource { double[][] points; diff --git a/src/main/java/neqsim/dataPresentation/userInterface.java b/src/main/java/neqsim/dataPresentation/userInterface.java deleted file mode 100644 index e3a8a71000..0000000000 --- a/src/main/java/neqsim/dataPresentation/userInterface.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * userInterface.java - * - * Created on 15. juni 2000, 18:28 - */ - -package neqsim.dataPresentation; - -/** - *

- * userInterface class. - *

- * - * @author Even Solbraa - * @version $Id: $Id - */ -public class userInterface implements java.io.Serializable { - private static final long serialVersionUID = 1000; - - /** - *

- * Constructor for userInterface. - *

- */ - public userInterface() {} -} diff --git a/src/main/java/neqsim/thermo/component/Component.java b/src/main/java/neqsim/thermo/component/Component.java index 44ff1073ab..4a6f90d426 100644 --- a/src/main/java/neqsim/thermo/component/Component.java +++ b/src/main/java/neqsim/thermo/component/Component.java @@ -145,7 +145,7 @@ abstract class Component implements ComponentInterface { private double triplePointTemperature = 1000.0; double meltingPointTemperature = 110.0; private double idealGasEnthalpyOfFormation = 0.0; - double idealGasGibsEnergyOfFormation = 0.0; + double idealGasGibbsEnergyOfFormation = 0.0; double idealGasAbsoluteEntropy = 0.0; @@ -363,7 +363,7 @@ public void createComponent(String component_name, double moles, double molesInP setIdealGasEnthalpyOfFormation( Double.parseDouble(dataSet.getString("EnthalpyOfFormation"))); - idealGasGibsEnergyOfFormation = gibbsEnergyOfFormation; + idealGasGibbsEnergyOfFormation = gibbsEnergyOfFormation; idealGasAbsoluteEntropy = Double.parseDouble(dataSet.getString("AbsoluteEntropy")); for (int i = 0; i < 5; i++) { @@ -656,8 +656,8 @@ public final double getIdealGasEnthalpyOfFormation() { /** {@inheritDoc} */ @Override - public final double getIdealGasGibsEnergyOfFormation() { - return idealGasGibsEnergyOfFormation; + public final double getIdealGasGibbsEnergyOfFormation() { + return idealGasGibbsEnergyOfFormation; } /** {@inheritDoc} */ diff --git a/src/main/java/neqsim/thermo/component/ComponentInterface.java b/src/main/java/neqsim/thermo/component/ComponentInterface.java index 14feeff94f..d42f54c889 100644 --- a/src/main/java/neqsim/thermo/component/ComponentInterface.java +++ b/src/main/java/neqsim/thermo/component/ComponentInterface.java @@ -685,8 +685,21 @@ public default double getTripplePointDensity() { *

* * @return a double + * @deprecated Replaced by {@link getIdealGasGibbsEnergyOfFormation} */ - public double getIdealGasGibsEnergyOfFormation(); + @Deprecated + public default double getIdealGasGibsEnergyOfFormation() { + return getIdealGasGibbsEnergyOfFormation(); + } + + /** + *

+ * getIdealGasGibsEnergyOfFormation. + *

+ * + * @return a double + */ + public double getIdealGasGibbsEnergyOfFormation(); /** *

diff --git a/src/main/java/neqsim/thermo/phase/Phase.java b/src/main/java/neqsim/thermo/phase/Phase.java index 2398b0355f..7e5ffc912d 100644 --- a/src/main/java/neqsim/thermo/phase/Phase.java +++ b/src/main/java/neqsim/thermo/phase/Phase.java @@ -1612,12 +1612,6 @@ public final double getPhaseFraction() { return getBeta(); } - /** {@inheritDoc} */ - @Override - public final double getBeta() { - return this.beta; - } - /** {@inheritDoc} */ @Override public double getdPdrho() { @@ -1922,8 +1916,20 @@ public double[] groupTBPfractions() { /** {@inheritDoc} */ @Override - public final void setBeta(double beta) { - this.beta = beta; + public final double getBeta() { + return this.beta; + } + + /** {@inheritDoc} */ + @Override + public final void setBeta(double b) { + if (b < 0) { + b = neqsim.thermo.ThermodynamicModelSettings.phaseFractionMinimumLimit; + } + if (b > 1) { + b = 1.0 - neqsim.thermo.ThermodynamicModelSettings.phaseFractionMinimumLimit; + } + this.beta = b; } /** {@inheritDoc} */ diff --git a/src/main/java/neqsim/thermo/phase/PhaseInterface.java b/src/main/java/neqsim/thermo/phase/PhaseInterface.java index b830ebed25..f595ce61a9 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseInterface.java +++ b/src/main/java/neqsim/thermo/phase/PhaseInterface.java @@ -590,16 +590,6 @@ public default double getExessGibbsEnergySymetric() { */ public double getSresTP(); - /** - *

- * Setter for property beta. Beta is the mole fraction of a phase of all the moles of - * a system. - *

- * - * @param b Beta value to set. - */ - public void setBeta(double b); - /** *

* setProperties. Transfer properties from another phase object. @@ -629,13 +619,24 @@ public default double getExessGibbsEnergySymetric() { /** *

- * getBeta. + * Getter for property beta. Beta is the mole fraction of a phase of all the moles of + * a system. *

* - * @return a double + * @return Beta value */ public double getBeta(); + /** + *

+ * Setter for property beta. Beta is the mole fraction of a phase of all the moles of + * a system. + *

+ * + * @param b Beta value to set. + */ + public void setBeta(double b); + /** *

* getWtFrac. diff --git a/src/main/java/neqsim/thermo/system/SystemInterface.java b/src/main/java/neqsim/thermo/system/SystemInterface.java index 25fc15d744..5f1b6b3f69 100644 --- a/src/main/java/neqsim/thermo/system/SystemInterface.java +++ b/src/main/java/neqsim/thermo/system/SystemInterface.java @@ -1051,7 +1051,7 @@ public void addPlusFraction(String componentName, double numberOfMoles, double m /** *

- * Getter for property modelName. + * Getter for property modelName. *

* * @return a {@link java.lang.String} object @@ -1070,33 +1070,36 @@ public void addPlusFraction(String componentName, double numberOfMoles, double m public void tuneModel(String model, double val, int phase); /** - * add a component to a fluid. If component name already exists, it will be added to the component + * add a component to a fluid. If component already exists, the moles will be added to the + * existing component. * - * @param inComponent a {@link neqsim.thermo.component.ComponentInterface} object + * @param inComponent Component object to add. */ public void addComponent(ComponentInterface inComponent); /** - * add a component to a fluid. If component already exists, it will be added to the component + * add a component to a fluid. If component already exists, the moles will be added to the + * existing component. * - * @param name a {@link java.lang.String} object + * @param name Name of the component to add. See NeqSim database for component in the database. */ public void addComponent(String name); /** - * add a component to a fluid. If component already exists, it will be added to the component + * add a component to a fluid. If component already exists, the moles will be added to the + * existing component. * * @param moles number of moles (per second) of the component to be added to the fluid - * @param name a {@link java.lang.String} object + * @param name Name of the component to add. See NeqSim database for component in the database. */ public void addComponent(String name, double moles); /** - * add a component to a fluid. If component already exists, it will be added to the component + * add a component to a fluid. If component already exists, the moles will be added to the + * existing component. * - * @param name Name of the component to be added. See NeqSim database for component in the - * database. - * @param value a double + * @param name Name of the component to add. See NeqSim database for component in the database. + * @param value The amount * @param unitName the unit of rate (sported units are kg/sec, mol/sec, Nlitre/min, kg/hr, * Sm^3/hr, Sm^3/day, MSm^3/day .. */ @@ -1107,20 +1110,19 @@ public void addPlusFraction(String componentName, double numberOfMoles, double m * addComponent. *

* - * @param name Name of the component to be added. See NeqSim database for component in the - * database. - * @param moles a double - * @param TC a double - * @param PC a double + * @param name Name of the component to add. See NeqSim database for component in the database. + * @param moles number of moles (per second) of the component to be added to the fluid + * @param TC Critical temperature + * @param PC Critical pressure * @param acs a double */ public void addComponent(String name, double moles, double TC, double PC, double acs); /** - * add a component to a fluid. I component already exists, it will be added to the component + * add a component to a fluid. If component already exists, the moles will be added to the + * existing component. * - * @param name Name of the component to be added. See NeqSim database for component in the - * database. + * @param name Name of the component to add. See NeqSim database for component in the database. * @param moles number of moles (per second) of the component to be added to the fluid * @param phaseNumber the phase number of the phase to add the component to */ @@ -1129,9 +1131,8 @@ public void addPlusFraction(String componentName, double numberOfMoles, double m /** * add a component to a fluid. I component already exists, it will be added to the component * - * @param name Name of the component to be added. See NeqSim database for component in the - * database. - * @param value rate of the component to be added to the fluid + * @param name Name of the component to add. See NeqSim database for component in the database. + * @param value rate of the component to add to the fluid * @param unitName the unit of the flow rate (eg. mol/sec, kg/sec, etc.) * @param phaseNumber the phase number of the phase to add the component to */ @@ -1147,6 +1148,15 @@ public void addPlusFraction(String componentName, double numberOfMoles, double m */ public void addComponent(int index, double moles); + /** + *

+ * removeComponent. + *

+ * + * @param name Name of the component to remove. See NeqSim database for component in the database. + */ + public void removeComponent(String name); + /** *

* addComponent. @@ -1160,60 +1170,63 @@ public void addPlusFraction(String componentName, double numberOfMoles, double m /** *

- * getBeta. + * Getter for property beta. + * + * Gets value for heaviest phase. *

* - * @return a double + * @return Beta value */ public double getBeta(); /** *

- * getBeta. + * Getter for property beta for a specific phase. *

* - * @param phase a int - * @return a double + * @param phase Index of phase to get beta for. + * @return Beta value */ public double getBeta(int phase); /** *

- * save. + * Setter for property beta. NB! Sets beta = b for first phase and 1-b for second + * phase, not for multiphase systems. *

* - * @param name a {@link java.lang.String} object + * @param b Beta value to set. */ - public void save(String name); + public void setBeta(double b); /** *

- * setModel. + * Setter for property beta for a given phase. *

* - * @param model a {@link java.lang.String} object - * @return a {@link neqsim.thermo.system.SystemInterface} object + * @param phase Index of phase to set beta for. + * @param b Beta value to set. */ - public SystemInterface setModel(String model); + public void setBeta(int phase, double b); /** *

- * removeComponent. + * Save System object to file. *

* - * @param name a {@link java.lang.String} object + * @param name File path to save to. */ - public void removeComponent(String name); + public void save(String name); /** *

- * setMixingRule. + * setModel. *

* - * @param typename a {@link java.lang.String} object - * @param GEmodel a {@link java.lang.String} object + * @param model a {@link java.lang.String} object + * @return a {@link neqsim.thermo.system.SystemInterface} object */ - public void setMixingRule(String typename, String GEmodel); + public SystemInterface setModel(String model); /** * method to set mixing rule used for the fluid. @@ -1235,6 +1248,16 @@ public void addPlusFraction(String componentName, double numberOfMoles, double m */ public void setMixingRule(String typename); + /** + *

+ * setMixingRule. + *

+ * + * @param typename a {@link java.lang.String} object + * @param GEmodel a {@link java.lang.String} object + */ + public void setMixingRule(String typename, String GEmodel); + /** *

* normalizeBeta. @@ -1456,7 +1479,7 @@ public void addPlusFraction(String componentName, double numberOfMoles, double m /** *

- * Getter for property multiPhaseCheck. + * Getter for property multiPhaseCheck. *

* * @return a boolean @@ -1638,25 +1661,6 @@ public double calcBeta() */ public void setAttractiveTerm(int i); - /** - *

- * setBeta. NB! Set beta = b for first phase and 1-b for second phase. - *

- * - * @param b Beta value to set. - */ - public void setBeta(double b); - - /** - *

- * setBeta for a given phase. - *

- * - * @param phase Index of phase to set beta for. - * @param b Beta value to set. - */ - public void setBeta(int phase, double b); - /** *

* removePhase. @@ -1903,37 +1907,37 @@ public double calcBeta() /** *

- * getTC. + * Getter for property TC. *

* - * @return a double + * @return Critical temperature */ public double getTC(); /** *

- * getPC. + * Getter for property TC. *

* - * @return a double + * @param TC Critical temperature to set */ - public double getPC(); + public void setTC(double TC); /** *

- * setTC. + * Getter for property PC. *

* - * @param TC a double + * @return Critical pressure */ - public void setTC(double TC); + public double getPC(); /** *

- * setPC. + * Getter for property PC. *

* - * @param PC a double + * @param PC Critical pressure to set */ public void setPC(double PC); @@ -1951,7 +1955,7 @@ public double calcBeta() * Getter for property numberOfPhases. *

* - * @return a int + * @return Number of phases in use */ public int getNumberOfPhases(); @@ -1960,7 +1964,7 @@ public double calcBeta() * Setter for property numberOfPhases. *

* - * @param number a int + * @param number Value of number of phases to use to set. */ public void setNumberOfPhases(int number); @@ -2025,7 +2029,7 @@ public double calcBeta() * getComponentNames. *

* - * @return an array of {@link java.lang.String} objects + * @return Component names in system. */ public String[] getComponentNames(); diff --git a/src/main/java/neqsim/thermo/system/SystemThermo.java b/src/main/java/neqsim/thermo/system/SystemThermo.java index 567ccaf5bf..f82105f2b8 100644 --- a/src/main/java/neqsim/thermo/system/SystemThermo.java +++ b/src/main/java/neqsim/thermo/system/SystemThermo.java @@ -3249,7 +3249,6 @@ public void normalizeBeta() { public String[][] createTable(String name) { // System.out.println("number of comps : " + numberOfComponents + " number of // phases " + numberOfPhases); - String[][] table = new String[getPhases()[0].getNumberOfComponents() + 30][7]; if (isInitialized) { initProperties(); @@ -3272,6 +3271,7 @@ public String[][] createTable(String name) { // 30][7]; // String[] names = {"", "Feed", "Phase 1", "Phase 2", "Phase 3", "Phase 4", // "Unit"}; + String[][] table = new String[getPhases()[0].getNumberOfComponents() + 30][7]; table[0][0] = ""; // getPhases()[0].getType(); //""; for (int i = 0; i < getPhases()[0].getNumberOfComponents() + 30; i++) { @@ -3587,7 +3587,7 @@ public final void setPhaseIndex(int index, int phaseIndex) { @Override public void setSolidPhaseCheck(boolean solidPhaseCheck) { // init(0); - int oldphase = numberOfPhases; + final int oldphase = numberOfPhases; if (!this.solidPhaseCheck) { addSolidPhase(); } @@ -3607,7 +3607,7 @@ public void setSolidPhaseCheck(boolean solidPhaseCheck) { @Override public void setSolidPhaseCheck(String solidComponent) { init(0); - int oldphase = numberOfPhases; + final int oldphase = numberOfPhases; if (!solidPhaseCheck) { addSolidPhase(); } diff --git a/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java b/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java index 60210a4aa8..bc265a1a2c 100644 --- a/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java +++ b/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java @@ -29,6 +29,7 @@ import neqsim.thermodynamicOperations.flashOps.VUflashQfunc; import neqsim.thermodynamicOperations.flashOps.calcIonicComposition; import neqsim.thermodynamicOperations.flashOps.dTPflash; +import neqsim.thermodynamicOperations.flashOps.saturationOps.ConstantDutyFlashInterface; import neqsim.thermodynamicOperations.flashOps.saturationOps.HCdewPointPressureFlash; import neqsim.thermodynamicOperations.flashOps.saturationOps.HydrateEquilibriumLine; import neqsim.thermodynamicOperations.flashOps.saturationOps.HydrateFormationPressureFlash; @@ -44,7 +45,6 @@ import neqsim.thermodynamicOperations.flashOps.saturationOps.bubblePointTemperatureNoDer; import neqsim.thermodynamicOperations.flashOps.saturationOps.calcSaltSatauration; import neqsim.thermodynamicOperations.flashOps.saturationOps.checkScalePotential; -import neqsim.thermodynamicOperations.flashOps.saturationOps.constantDutyFlashInterface; import neqsim.thermodynamicOperations.flashOps.saturationOps.constantDutyPressureFlash; import neqsim.thermodynamicOperations.flashOps.saturationOps.constantDutyTemperatureFlash; import neqsim.thermodynamicOperations.flashOps.saturationOps.cricondebarFlash; @@ -705,7 +705,7 @@ public void VUflash(double Vspec, double Uspec) { * @throws java.lang.Exception if any. */ public void bubblePointTemperatureFlash() throws Exception { - constantDutyFlashInterface operation = new bubblePointTemperatureNoDer(system); + ConstantDutyFlashInterface operation = new bubblePointTemperatureNoDer(system); operation.run(); if (Double.isNaN(system.getTemperature()) || operation.isSuperCritical()) { throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), @@ -1280,7 +1280,7 @@ public double calcCricondenBar() { */ public void bubblePointPressureFlash() throws Exception { system.init(0); - constantDutyFlashInterface operation = new constantDutyPressureFlash(system); + ConstantDutyFlashInterface operation = new constantDutyPressureFlash(system); system.setBeta(1, 1.0 - 1e-10); system.setBeta(0, 1e-10); operation.run(); @@ -1299,7 +1299,7 @@ public void bubblePointPressureFlash() throws Exception { * @throws java.lang.Exception if any. */ public void bubblePointPressureFlash(boolean derivatives) throws Exception { - constantDutyFlashInterface operation = null; + ConstantDutyFlashInterface operation = null; if (derivatives == true) { operation = new bubblePointPressureFlashDer(system); } else { @@ -1328,7 +1328,7 @@ public void constantPhaseFractionPressureFlash(double fraction) throws Exception if (fraction > 1.0 - 1e-10) { fraction = 1.0 - 1.0e-10; } - constantDutyFlashInterface operation = new constantDutyPressureFlash(system); + ConstantDutyFlashInterface operation = new constantDutyPressureFlash(system); system.setBeta(1, 1.0 - fraction); system.setBeta(0, fraction); operation.run(); @@ -1355,7 +1355,7 @@ public void constantPhaseFractionTemperatureFlash(double fraction) throws Except if (fraction > 1.0 - 1e-10) { fraction = 1.0 - 1.0e-10; } - constantDutyFlashInterface operation = new constantDutyTemperatureFlash(system); + ConstantDutyFlashInterface operation = new constantDutyTemperatureFlash(system); system.setBeta(1, fraction); system.setBeta(0, fraction); operation.run(); @@ -1430,7 +1430,7 @@ public void dewPointMach(String componentName, String specification, double spec * @throws java.lang.Exception if any. */ public void dewPointTemperatureFlash() throws Exception { - constantDutyFlashInterface operation = + ConstantDutyFlashInterface operation = new neqsim.thermodynamicOperations.flashOps.saturationOps.dewPointTemperatureFlash(system); operation.run(); if (Double.isNaN(system.getTemperature()) || operation.isSuperCritical()) { @@ -1448,7 +1448,7 @@ public void dewPointTemperatureFlash() throws Exception { * @throws java.lang.Exception if any. */ public void dewPointTemperatureFlash(boolean derivatives) throws Exception { - constantDutyFlashInterface operation = + ConstantDutyFlashInterface operation = new neqsim.thermodynamicOperations.flashOps.saturationOps.dewPointTemperatureFlash(system); if (derivatives) { operation = new dewPointTemperatureFlashDer(system); @@ -1470,7 +1470,7 @@ public void dewPointTemperatureFlash(boolean derivatives) throws Exception { public void dewPointPressureFlashHC() throws Exception { // try{ system.init(0); - constantDutyFlashInterface operation = new HCdewPointPressureFlash(system); + ConstantDutyFlashInterface operation = new HCdewPointPressureFlash(system); operation.run(); if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), @@ -1489,7 +1489,7 @@ public void dewPointPressureFlashHC() throws Exception { public void dewPointPressureFlash() throws Exception { // try{ system.init(0); - constantDutyFlashInterface operation = new dewPointPressureFlash(system); + ConstantDutyFlashInterface operation = new dewPointPressureFlash(system); operation.run(); if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java index f51e39eb3a..cd12218847 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java @@ -13,6 +13,8 @@ import neqsim.thermodynamicOperations.BaseOperation; /** + * Abstract base class for all flash classes. + * * @author Even Solbraa */ abstract class Flash extends BaseOperation { @@ -47,7 +49,7 @@ abstract class Flash extends BaseOperation { /** Set true to check for solid phase and do solid phase calculations. */ protected boolean solidCheck = false; protected boolean stabilityCheck = false; - boolean findLowesGibsPhaseIsChecked = false; + protected boolean findLowestGibbsPhaseIsChecked = false; /** *

@@ -64,7 +66,7 @@ public Flash() {} * @return a int */ public int findLowestGibbsEnergyPhase() { - if (!findLowesGibsPhaseIsChecked) { + if (!findLowestGibbsPhaseIsChecked) { minimumGibbsEnergySystem = system.clone(); minimumGibbsEnergySystem.init(0); minimumGibbsEnergySystem.init(1); @@ -75,7 +77,7 @@ public int findLowestGibbsEnergyPhase() { } else { lowestGibbsEnergyPhase = 1; } - findLowesGibsPhaseIsChecked = true; + findLowestGibbsPhaseIsChecked = true; } return lowestGibbsEnergyPhase; } @@ -95,7 +97,7 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException, double[] oldDeltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; double[] oldoldDeltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; double[][] Wi = new double[2][system.getPhases()[0].getNumberOfComponents()]; - double[] sumw = new double[2]; + boolean secondOrderStabilityAnalysis = false; double[] oldlogw = new double[system.getPhases()[0].getNumberOfComponents()]; double[] oldoldlogw = new double[system.getPhases()[0].getNumberOfComponents()]; @@ -116,9 +118,10 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException, SystemInterface clonedSystem = minimumGibbsEnergySystem; clonedSystem.setTotalNumberOfMoles(1.0); + + double[] sumw = new double[2]; sumw[1] = 0.0; sumw[0] = 0.0; - for (int i = 0; i < clonedSystem.getPhase(0).getNumberOfComponents(); i++) { sumw[1] += clonedSystem.getPhase(0).getComponent(i).getz() / clonedSystem.getPhase(0).getComponent(i).getK(); diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPflash.java index 6750748502..814f1e4fae 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPflash.java @@ -189,7 +189,7 @@ public void run() { return; } - findLowesGibsPhaseIsChecked = false; + findLowestGibbsPhaseIsChecked = false; int minGibbsPhase = 0; double minimumGibbsEnergy = 0; diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/constantDutyFlashInterface.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/ConstantDutyFlashInterface.java similarity index 59% rename from src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/constantDutyFlashInterface.java rename to src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/ConstantDutyFlashInterface.java index 44e9e54445..c8517bcc84 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/constantDutyFlashInterface.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/ConstantDutyFlashInterface.java @@ -4,22 +4,13 @@ /** *

- * constantDutyFlashInterface interface. + * ConstantDutyFlashInterface interface. *

* * @author Even Solbraa * @version $Id: $Id */ -public interface constantDutyFlashInterface extends OperationInterface { - /** - *

- * setBeta. - *

- * - * @param beta a double - */ - public void setBeta(double beta); - +public interface ConstantDutyFlashInterface extends OperationInterface { /** *

* isSuperCritical. diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/constantDutyFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/constantDutyFlash.java index 1d7803076c..e493bab589 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/constantDutyFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/constantDutyFlash.java @@ -12,7 +12,7 @@ * @author asmund * @version $Id: $Id */ -public abstract class constantDutyFlash implements constantDutyFlashInterface { +public abstract class constantDutyFlash implements ConstantDutyFlashInterface { private static final long serialVersionUID = 1000; static Logger logger = LogManager.getLogger(constantDutyFlash.class); @@ -35,7 +35,6 @@ public abstract class constantDutyFlash implements constantDutyFlashInterface { double[] oldDeltalnK; double[] deltalnK; double[] tm = {1, 1}; - double beta = 1e-5; int lowestGibbsEnergyPhase = 0; // lowestGibbsEnergyPhase /** @@ -61,12 +60,6 @@ public constantDutyFlash(SystemInterface system) { deltalnK = new double[system.getPhases()[0].getNumberOfComponents()]; } - /** {@inheritDoc} */ - @Override - public void setBeta(double beta) { - this.beta = beta; - } - /** {@inheritDoc} */ @Override public void run() { @@ -83,7 +76,6 @@ public void run() { double dxidt = 0; double Told = 0; do { - // system.setBeta(beta+0.65); system.init(2); for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { diff --git a/src/test/java/neqsim/thermo/util/example/FreezeMEGwater.java b/src/test/java/neqsim/thermo/util/example/FreezeMEGwater.java index 1d7abb77ed..e3fc00351a 100644 --- a/src/test/java/neqsim/thermo/util/example/FreezeMEGwater.java +++ b/src/test/java/neqsim/thermo/util/example/FreezeMEGwater.java @@ -2,7 +2,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import neqsim.dataPresentation.dataHandeling; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkCPAstatoil; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -26,13 +25,11 @@ public class FreezeMEGwater { * * @param args an array of {@link java.lang.String} objects */ - @SuppressWarnings("unused") public static void main(String args[]) { SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 10.0, 1.0); // SystemInterface testSystem = new SystemSrkCPAstatoil(273.15-23.0, 1.0); // testSystem.setMultiPhaseCheck(true); ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - dataHandeling output = new dataHandeling(); testSystem.addComponent("methane", 1.1); // testSystem.addComponent("ethane", 15.0); testSystem.addComponent("MEG", 0.9);