From db5385cba4d68e432a8c033db8e7cef02e078b7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?= <34712686+asmfstatoil@users.noreply.github.com> Date: Thu, 21 Jul 2022 19:02:38 +0200 Subject: [PATCH 1/9] refact: clean out empty/unused cdf code (#487) * refact: clean out empty/unused cdf code --- .vscode/settings.json | 2 +- .../createTextFile/TextFile.java | 163 +- .../stirredCellSystem/StirredCellSystem.java | 283 +- .../TwoPhasePipeFlowSystem.java | 303 +- .../TwoPhasePipeFlowSystemReac.java | 135 +- .../TwoPhaseReactorFlowSystem.java | 1 - .../FlowSystemVisualization.java | 123 +- .../FlowSystemVisualizationInterface.java | 9 - .../PipeFlowVisualization.java | 301 +- .../TwoPhasePipeFlowVisualization.java | 348 +- .../pipeline/OnePhasePipeLine.java | 115 +- .../processEquipment/pipeline/Pipeline.java | 545 ++- .../pipeline/TwoPhasePipeLine.java | 109 +- .../parameterFitting/StatisticsInterface.java | 153 +- ...stIonicInteractionParameterFittingCH4.java | 186 +- ...stCPAParameterFittingToSolubilityData.java | 172 +- ...arameterFittingToSolubilityData_Lucia.java | 313 +- ...AParameterFittingToSolubilityGlycolHC.java | 208 +- ...osParameterFittingToMercurySolubility.java | 123 +- ...ParameterFittingToSolubilityDataEinar.java | 112 +- ...inaryHVParameterFittingToDewPointData.java | 171 +- ...aryHVParameterFittingToSolubilityData.java | 180 +- ...arameterFittingToSolubilityData_Lucia.java | 461 +- ...rFittingToSolubilityData_LuciaPropane.java | 320 +- ...ameterFittingToSolubilityDatawaterCO2.java | 206 +- ...stBinaryUMRPRUFittingToSolubilityData.java | 557 ++- ...arameterFittingToSolubilityData_Lucia.java | 373 +- .../TestSolidAntoine.java | 101 +- .../TestIonicInteractionParameterFitting.java | 485 +-- ...stIonicInteractionParameterFittingCH4.java | 249 +- ...nicInteractionParameterFittingCo2nacl.java | 138 +- ...ractionParameterFittingMDEAPiperazine.java | 127 +- ...InteractionParameterFittingPiperazine.java | 126 +- .../AntoineParameter/TestSolidAntoine.java | 111 +- .../AntoineParameter/TestSolidAntoine_S8.java | 91 +- .../TestAcentricSchwartzentruber.java | 149 +- .../TestFitToAntoineVapPres.java | 106 +- .../TestMathiasCopeman.java | 211 +- .../TestMathiasCopemanToDewPoint.java | 291 +- .../acentricFactorFitting/TestTwuCoon.java | 213 +- .../TestFurstIonicParameterFunction.java | 307 +- .../hydrate/TestHydrateFunction.java | 151 +- .../BaseOperation.java | 82 +- .../OperationInterface.java | 9 - .../ThermodynamicOperations.java | 3877 ++++++++--------- .../ChemicalEquilibrium.java | 138 +- .../flashOps/Flash.java | 839 ++-- .../saturationOps/constantDutyFlash.java | 276 +- .../saturationOps/cricondenBarTemp1.java | 9 - .../HPTphaseEnvelope.java | 179 +- .../pTphaseEnvelope.java | 8 - .../pTphaseEnvelope1.java | 853 ++-- .../pTphaseEnvelopeMay.java | 1446 +++--- .../pTphaseEnvelopeNew.java | 733 ++-- .../reactiveCurves/pLoadingCurve2.java | 341 +- .../pipeFlowSystem/PipeFlowSystemTest.java | 11 +- .../util/example/PressureLoadingCurve.java | 108 +- 57 files changed, 8725 insertions(+), 9012 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 14a6208281..4e980e2539 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,7 @@ { "java.configuration.updateBuildConfiguration": "interactive", "[java]": { - "editor.defaultFormatter": "serikb.google-java-format", + "editor.defaultFormatter": "redhat.java", "editor.formatOnSave": true, }, "java.format.settings.url": "https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml", diff --git a/src/main/java/neqsim/dataPresentation/fileHandeling/createTextFile/TextFile.java b/src/main/java/neqsim/dataPresentation/fileHandeling/createTextFile/TextFile.java index 0c975642dc..e1ac4c1465 100644 --- a/src/main/java/neqsim/dataPresentation/fileHandeling/createTextFile/TextFile.java +++ b/src/main/java/neqsim/dataPresentation/fileHandeling/createTextFile/TextFile.java @@ -12,98 +12,97 @@ * @version $Id: $Id */ public class TextFile implements java.io.Serializable { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - String fileName = "c:/example.txt"; - String[][] values; - // NetcdfFileWriteable ncfile; + String fileName = "c:/example.txt"; + String[][] values; - /** - *

- * Constructor for TextFile. - *

- */ - public TextFile() {} + /** + *

+ * Constructor for TextFile. + *

+ */ + public TextFile() {} - /** - *

- * setOutputFileName. - *

- * - * @param name a {@link java.lang.String} object - */ - public void setOutputFileName(String name) { - this.fileName = name; - } + /** + *

+ * setOutputFileName. + *

+ * + * @param name a {@link java.lang.String} object + */ + public void setOutputFileName(String name) { + this.fileName = name; + } - /** - *

- * newFile. - *

- * - * @param name a {@link java.lang.String} object - */ - public void newFile(String name) { - try (FileWriter out = new FileWriter(new File(name))) { - out.write(""); - } catch (Exception e) { - System.out.println(e.toString()); - } + /** + *

+ * newFile. + *

+ * + * @param name a {@link java.lang.String} object + */ + public void newFile(String name) { + try (FileWriter out = new FileWriter(new File(name))) { + out.write(""); + } catch (Exception e) { + System.out.println(e.toString()); } + } - /** - *

- * Setter for the field values. - *

- * - * @param values an array of {@link java.lang.String} objects - */ - public void setValues(String[][] values) { - System.out.println("writing " + values[0][0] + " data"); - this.values = values; - } + /** + *

+ * Setter for the field values. + *

+ * + * @param values an array of {@link java.lang.String} objects + */ + public void setValues(String[][] values) { + System.out.println("writing " + values[0][0] + " data"); + this.values = values; + } - /** - *

- * Setter for the field values. - *

- * - * @param valuesloca an array of {@link double} objects - */ - public void setValues(double[][] valuesloca) { - values = new String[valuesloca[0].length][valuesloca.length]; - // System.out.println("writing " + values[0][0] + " data"); - for (int i = 0; i < values.length; i++) { - for (int j = 0; j < values[0].length; j++) { - values[i][j] = Double.toString(valuesloca[j][i]) + " "; - } - } + /** + *

+ * Setter for the field values. + *

+ * + * @param valuesloca an array of {@link double} objects + */ + public void setValues(double[][] valuesloca) { + values = new String[valuesloca[0].length][valuesloca.length]; + // System.out.println("writing " + values[0][0] + " data"); + for (int i = 0; i < values.length; i++) { + for (int j = 0; j < values[0].length; j++) { + values[i][j] = Double.toString(valuesloca[j][i]) + " "; + } } + } - /** - *

- * createFile. - *

- */ - public void createFile() { - System.out.println("writing " + values[0][0] + " data"); - System.out.println("length " + values.length); - System.out.println("length2 " + values[0].length); + /** + *

+ * createFile. + *

+ */ + public void createFile() { + System.out.println("writing " + values[0][0] + " data"); + System.out.println("length " + values.length); + System.out.println("length2 " + values[0].length); - try (FileWriter out = new FileWriter(new File(fileName), true)) { - for (int i = 0; i < values.length; i++) { - for (int j = 0; j < values[0].length; j++) { - if (values[i][j] != null) { - out.write(values[i][j]); - } - out.write("\t"); - } - out.write("\n"); - } - out.flush(); - } catch (Exception e) { - System.err.println("error writing file: " + e.toString()); + try (FileWriter out = new FileWriter(new File(fileName), true)) { + for (int i = 0; i < values.length; i++) { + for (int j = 0; j < values[0].length; j++) { + if (values[i][j] != null) { + out.write(values[i][j]); + } + out.write("\t"); } - System.out.println("writing data to file: " + fileName + " ... ok"); + out.write("\n"); + } + out.flush(); + } catch (Exception e) { + System.err.println("error writing file: " + e.toString()); } + System.out.println("writing data to file: " + fileName + " ... ok"); + } } diff --git a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/stirredCellSystem/StirredCellSystem.java b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/stirredCellSystem/StirredCellSystem.java index fbcc61469e..24bc8c906d 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/stirredCellSystem/StirredCellSystem.java +++ b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/stirredCellSystem/StirredCellSystem.java @@ -11,154 +11,153 @@ * @version $Id: $Id */ public class StirredCellSystem - extends neqsim.fluidMechanics.flowSystem.twoPhaseFlowSystem.TwoPhaseFlowSystem { - private static final long serialVersionUID = 1000; - - /** - *

- * Constructor for StirredCellSystem. - *

- */ - public StirredCellSystem() {} - - /** {@inheritDoc} */ - @Override - public void createSystem() { - flowLeg = new neqsim.fluidMechanics.flowLeg.pipeLeg.PipeLeg[this.getNumberOfLegs()]; - - for (int i = 0; i < getNumberOfLegs(); i++) { - flowLeg[i] = new neqsim.fluidMechanics.flowLeg.pipeLeg.PipeLeg(); - } - - flowNode = new neqsim.fluidMechanics.flowNode.FlowNodeInterface[totalNumberOfNodes]; - flowNode[0] = - new neqsim.fluidMechanics.flowNode.twoPhaseNode.twoPhaseStirredCellNode.StirredCellNode( - thermoSystem, equipmentGeometry[0]); - - flowNode[totalNumberOfNodes - 1] = flowNode[0].getNextNode(); - - super.createSystem(); - this.setNodes(); + extends neqsim.fluidMechanics.flowSystem.twoPhaseFlowSystem.TwoPhaseFlowSystem { + private static final long serialVersionUID = 1000; + + /** + *

+ * Constructor for StirredCellSystem. + *

+ */ + public StirredCellSystem() {} + + /** {@inheritDoc} */ + @Override + public void createSystem() { + flowLeg = new neqsim.fluidMechanics.flowLeg.pipeLeg.PipeLeg[this.getNumberOfLegs()]; + + for (int i = 0; i < getNumberOfLegs(); i++) { + flowLeg[i] = new neqsim.fluidMechanics.flowLeg.pipeLeg.PipeLeg(); } - /** {@inheritDoc} */ - @Override - public void init() { - for (int j = 0; j < getTotalNumberOfNodes(); j++) { - flowNode[j].init(); - } - - for (int j = 0; j < getTotalNumberOfNodes(); j++) { - for (int phase = 0; phase < 2; phase++) { - flowNode[j].setVelocityOut(phase, this.flowNode[j].getVelocity(phase)); - } - } - - for (int k = 1; k < getTotalNumberOfNodes(); k++) { - for (int phase = 0; phase < 2; phase++) { - this.flowNode[k].setVelocityIn(phase, this.flowNode[k - 1].getVelocityOut(phase)); - } - } - } + flowNode = new neqsim.fluidMechanics.flowNode.FlowNodeInterface[totalNumberOfNodes]; + flowNode[0] = + new neqsim.fluidMechanics.flowNode.twoPhaseNode.twoPhaseStirredCellNode.StirredCellNode( + thermoSystem, equipmentGeometry[0]); + + flowNode[totalNumberOfNodes - 1] = flowNode[0].getNextNode(); + + super.createSystem(); + this.setNodes(); + } - /** {@inheritDoc} */ - @Override - public void solveSteadyState(int solverType) { - flowSolver = - new neqsim.fluidMechanics.flowSolver.twoPhaseFlowSolver.stirredCellSolver.StirredCellSolver( - this, getSystemLength(), getTotalNumberOfNodes(), false); + /** {@inheritDoc} */ + @Override + public void init() { + for (int j = 0; j < getTotalNumberOfNodes(); j++) { + flowNode[j].init(); } - /** {@inheritDoc} */ - @Override - public void solveTransient(int solverType) { - getTimeSeries().init(this); - display = - new neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowSystemVisualization.twoPhaseFlowVisualization.twoPhasePipeFlowVisualization.TwoPhasePipeFlowVisualization( - this.getTotalNumberOfNodes(), getTimeSeries().getTime().length); - for (int i = 0; i < this.getTimeSeries().getTime().length; i++) { - getNode(0).setBulkSystem(this.getTimeSeries().getThermoSystem()[i]); - flowNode[0].initFlowCalc(); - flowNode[0].init(); - flowNode[0].setVelocityIn(this.flowNode[0].getVelocity()); - flowNode[getTotalNumberOfNodes() - 1] - .setVelocity(this.getTimeSeries().getOutletMolarFlowRates()[i]); - // System.out.println("vel: " + this.flowNode[0].getVelocity()); - // getSolver().setTimeStep(this.getTimeSeries().getTimeStep()[i]); - // System.out.println("time step: " + i + " " + - // this.getTimeSeries().getTimeStep()[i]); - System.out.println("time: " + i + " " + this.getTimeSeries().getTime()[i]); - flowSolver.solveTDMA(); - display.setNextData(this, this.getTimeSeries().getTime(i)); - } + for (int j = 0; j < getTotalNumberOfNodes(); j++) { + for (int phase = 0; phase < 2; phase++) { + flowNode[j].setVelocityOut(phase, this.flowNode[j].getVelocity(phase)); + } } - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - // Initierer et nyt rorsystem - neqsim.fluidMechanics.flowSystem.FlowSystemInterface pipe = new StirredCellSystem(); - - // Definerer termodyanmikken5 - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos(295.3, 5.0); - testSystem.addComponent("methane", 0.11152181, 0); - // testSystem.addComponent("ethane", 0.0011152181, 0); - testSystem.addComponent("water", 0.04962204876, 1); - // testSystem.addComponent("TEG", 0.4962204876, 1); - testSystem.setMixingRule(2); - // benytter klassiske blandingsregler - - pipe.setInletThermoSystem(testSystem); // setter termodyanmikken for rorsystemet - pipe.setNumberOfLegs(1); // deler inn roret i et gitt antall legger - pipe.setNumberOfNodesInLeg(10); // setter antall nodepunkter (beregningspunkter/grid) pr. - // leg - double[] height = {0, 0}; - double[] length = {0.0, 10.0}; - double[] outerTemperature = {278.0, 278.0}; - double[] outerHeatTransferCoef = {2.0, 2.0}; - double[] wallHeatTransferCoef = {2.0, 2.0}; - - pipe.setLegHeights(height); // setter inn hoyde for hver leg-ende - pipe.setLegPositions(length); // setter avstand til hver leg-ende - pipe.setLegOuterTemperatures(outerTemperature); - pipe.setLegOuterHeatTransferCoefficients(outerHeatTransferCoef); - pipe.setLegWallHeatTransferCoefficients(wallHeatTransferCoef); - - neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface[] pipeGemometry = - new neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData[6]; // Deffinerer - // geometrien - // for - // roret - double[] pipeDiameter = {0.02588, 0.02588}; - for (int i = 0; i < pipeDiameter.length; i++) { - pipeGemometry[i] = - new neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData(pipeDiameter[i]); - } - pipe.setEquipmentGeometry(pipeGemometry); // setter inn rorgeometrien for hver leg - // utforer bergninger - pipe.createSystem(); - pipe.init(); - - double[] times = {0, 10}; - pipe.getTimeSeries().setTimes(times); - SystemInterface[] systems = {testSystem, testSystem, testSystem}; - pipe.getTimeSeries().setInletThermoSystems(systems); - pipe.getTimeSeries().setNumberOfTimeStepsInInterval(5); - pipe.solveSteadyState(2); - pipe.solveTransient(2); - System.out.println("disp"); - pipe.getNode(0).display(); - // pipe.solveTransient(2); - // pipe.solveTransient(2); - - pipe.getNode(0).display(); - pipe.getNode(10).display(); - // pipe.getDisplay().createNetCdfFile("c:/temp5.nc"); + for (int k = 1; k < getTotalNumberOfNodes(); k++) { + for (int phase = 0; phase < 2; phase++) { + this.flowNode[k].setVelocityIn(phase, this.flowNode[k - 1].getVelocityOut(phase)); + } + } + } + + /** {@inheritDoc} */ + @Override + public void solveSteadyState(int solverType) { + flowSolver = + new neqsim.fluidMechanics.flowSolver.twoPhaseFlowSolver.stirredCellSolver.StirredCellSolver( + this, getSystemLength(), getTotalNumberOfNodes(), false); + } + + /** {@inheritDoc} */ + @Override + public void solveTransient(int solverType) { + getTimeSeries().init(this); + display = + new neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowSystemVisualization.twoPhaseFlowVisualization.twoPhasePipeFlowVisualization.TwoPhasePipeFlowVisualization( + this.getTotalNumberOfNodes(), getTimeSeries().getTime().length); + for (int i = 0; i < this.getTimeSeries().getTime().length; i++) { + getNode(0).setBulkSystem(this.getTimeSeries().getThermoSystem()[i]); + flowNode[0].initFlowCalc(); + flowNode[0].init(); + flowNode[0].setVelocityIn(this.flowNode[0].getVelocity()); + flowNode[getTotalNumberOfNodes() - 1] + .setVelocity(this.getTimeSeries().getOutletMolarFlowRates()[i]); + // System.out.println("vel: " + this.flowNode[0].getVelocity()); + // getSolver().setTimeStep(this.getTimeSeries().getTimeStep()[i]); + // System.out.println("time step: " + i + " " + + // this.getTimeSeries().getTimeStep()[i]); + System.out.println("time: " + i + " " + this.getTimeSeries().getTime()[i]); + flowSolver.solveTDMA(); + display.setNextData(this, this.getTimeSeries().getTime(i)); + } + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + // Initierer et nyt rorsystem + neqsim.fluidMechanics.flowSystem.FlowSystemInterface pipe = new StirredCellSystem(); + + // Definerer termodyanmikken5 + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos(295.3, 5.0); + testSystem.addComponent("methane", 0.11152181, 0); + // testSystem.addComponent("ethane", 0.0011152181, 0); + testSystem.addComponent("water", 0.04962204876, 1); + // testSystem.addComponent("TEG", 0.4962204876, 1); + testSystem.setMixingRule(2); + // benytter klassiske blandingsregler + + pipe.setInletThermoSystem(testSystem); // setter termodyanmikken for rorsystemet + pipe.setNumberOfLegs(1); // deler inn roret i et gitt antall legger + pipe.setNumberOfNodesInLeg(10); // setter antall nodepunkter (beregningspunkter/grid) pr. + // leg + double[] height = {0, 0}; + double[] length = {0.0, 10.0}; + double[] outerTemperature = {278.0, 278.0}; + double[] outerHeatTransferCoef = {2.0, 2.0}; + double[] wallHeatTransferCoef = {2.0, 2.0}; + + pipe.setLegHeights(height); // setter inn hoyde for hver leg-ende + pipe.setLegPositions(length); // setter avstand til hver leg-ende + pipe.setLegOuterTemperatures(outerTemperature); + pipe.setLegOuterHeatTransferCoefficients(outerHeatTransferCoef); + pipe.setLegWallHeatTransferCoefficients(wallHeatTransferCoef); + + neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface[] pipeGemometry = + new neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData[6]; // Deffinerer + // geometrien + // for + // roret + double[] pipeDiameter = {0.02588, 0.02588}; + for (int i = 0; i < pipeDiameter.length; i++) { + pipeGemometry[i] = + new neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData(pipeDiameter[i]); } + pipe.setEquipmentGeometry(pipeGemometry); // setter inn rorgeometrien for hver leg + // utforer bergninger + pipe.createSystem(); + pipe.init(); + + double[] times = {0, 10}; + pipe.getTimeSeries().setTimes(times); + SystemInterface[] systems = {testSystem, testSystem, testSystem}; + pipe.getTimeSeries().setInletThermoSystems(systems); + pipe.getTimeSeries().setNumberOfTimeStepsInInterval(5); + pipe.solveSteadyState(2); + pipe.solveTransient(2); + System.out.println("disp"); + pipe.getNode(0).display(); + // pipe.solveTransient(2); + // pipe.solveTransient(2); + + pipe.getNode(0).display(); + pipe.getNode(10).display(); + } } diff --git a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhasePipeFlowSystem/TwoPhasePipeFlowSystem.java b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhasePipeFlowSystem/TwoPhasePipeFlowSystem.java index ffebbde898..5ffc04a681 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhasePipeFlowSystem/TwoPhasePipeFlowSystem.java +++ b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhasePipeFlowSystem/TwoPhasePipeFlowSystem.java @@ -1,166 +1,171 @@ package neqsim.fluidMechanics.flowSystem.twoPhaseFlowSystem.twoPhasePipeFlowSystem; /** - *

TwoPhasePipeFlowSystem class.

+ *

+ * TwoPhasePipeFlowSystem class. + *

* * @author asmund * @version $Id: $Id */ public class TwoPhasePipeFlowSystem - extends neqsim.fluidMechanics.flowSystem.twoPhaseFlowSystem.TwoPhaseFlowSystem { - private static final long serialVersionUID = 1000; - - /** - *

Constructor for TwoPhasePipeFlowSystem.

- */ - public TwoPhasePipeFlowSystem() {} - - /** {@inheritDoc} */ - @Override - public void createSystem() { - // thermoSystem.init(1); - flowLeg = new neqsim.fluidMechanics.flowLeg.pipeLeg.PipeLeg[this.getNumberOfLegs()]; - - for (int i = 0; i < getNumberOfLegs(); i++) { - flowLeg[i] = new neqsim.fluidMechanics.flowLeg.pipeLeg.PipeLeg(); - } - - flowNode = new neqsim.fluidMechanics.flowNode.FlowNodeInterface[totalNumberOfNodes]; - if (initFlowPattern.equals("stratified")) { - flowNode[0] = - new neqsim.fluidMechanics.flowNode.twoPhaseNode.twoPhasePipeFlowNode.StratifiedFlowNode( - thermoSystem, equipmentGeometry[0]); - } else if (initFlowPattern.equals("annular")) { - flowNode[0] = - new neqsim.fluidMechanics.flowNode.twoPhaseNode.twoPhasePipeFlowNode.AnnularFlow( - thermoSystem, equipmentGeometry[0]); - } else { - flowNode[0] = - new neqsim.fluidMechanics.flowNode.twoPhaseNode.twoPhasePipeFlowNode.StratifiedFlowNode( - thermoSystem, equipmentGeometry[0]); - } - flowNode[totalNumberOfNodes - 1] = flowNode[0].getNextNode(); - - super.createSystem(); - this.setNodes(); + extends neqsim.fluidMechanics.flowSystem.twoPhaseFlowSystem.TwoPhaseFlowSystem { + private static final long serialVersionUID = 1000; + + /** + *

+ * Constructor for TwoPhasePipeFlowSystem. + *

+ */ + public TwoPhasePipeFlowSystem() {} + + /** {@inheritDoc} */ + @Override + public void createSystem() { + // thermoSystem.init(1); + flowLeg = new neqsim.fluidMechanics.flowLeg.pipeLeg.PipeLeg[this.getNumberOfLegs()]; + + for (int i = 0; i < getNumberOfLegs(); i++) { + flowLeg[i] = new neqsim.fluidMechanics.flowLeg.pipeLeg.PipeLeg(); } - /** {@inheritDoc} */ - @Override - public void init() { - for (int j = 0; j < getTotalNumberOfNodes(); j++) { - flowNode[j].initFlowCalc(); - flowNode[j].init(); - } - - for (int j = 0; j < getTotalNumberOfNodes(); j++) { - for (int phase = 0; phase < 2; phase++) { - flowNode[j].setVelocityOut(phase, this.flowNode[j].getVelocity(phase)); - } - } - - for (int k = 1; k < getTotalNumberOfNodes(); k++) { - for (int phase = 0; phase < 2; phase++) { - this.flowNode[k].setVelocityIn(phase, this.flowNode[k - 1].getVelocityOut(phase)); - } - } + flowNode = new neqsim.fluidMechanics.flowNode.FlowNodeInterface[totalNumberOfNodes]; + if (initFlowPattern.equals("stratified")) { + flowNode[0] = + new neqsim.fluidMechanics.flowNode.twoPhaseNode.twoPhasePipeFlowNode.StratifiedFlowNode( + thermoSystem, equipmentGeometry[0]); + } else if (initFlowPattern.equals("annular")) { + flowNode[0] = + new neqsim.fluidMechanics.flowNode.twoPhaseNode.twoPhasePipeFlowNode.AnnularFlow( + thermoSystem, equipmentGeometry[0]); + } else { + flowNode[0] = + new neqsim.fluidMechanics.flowNode.twoPhaseNode.twoPhasePipeFlowNode.StratifiedFlowNode( + thermoSystem, equipmentGeometry[0]); } - - /** {@inheritDoc} */ - @Override - public void solveSteadyState(int solverType) { - double[] times = {0.0}; - display = - new neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowSystemVisualization.twoPhaseFlowVisualization.twoPhasePipeFlowVisualization.TwoPhasePipeFlowVisualization( - this.getTotalNumberOfNodes(), 1); - getTimeSeries().setTimes(times); - neqsim.thermo.system.SystemInterface[] systems = {flowNode[0].getBulkSystem()}; - getTimeSeries().setInletThermoSystems(systems); - getTimeSeries().setNumberOfTimeStepsInInterval(1); - double[] outletFlowRates = {0.0, 0.0}; - getTimeSeries().setOutletMolarFlowRate(outletFlowRates); - - flowSolver = - new neqsim.fluidMechanics.flowSolver.twoPhaseFlowSolver.twoPhasePipeFlowSolver.TwoPhaseFixedStaggeredGridSolver( - this, getSystemLength(), this.getTotalNumberOfNodes(), false); - flowSolver.setSolverType(solverType); - flowSolver.solveTDMA(); - - getTimeSeries().init(this); - display.setNextData(this); + flowNode[totalNumberOfNodes - 1] = flowNode[0].getNextNode(); + + super.createSystem(); + this.setNodes(); + } + + /** {@inheritDoc} */ + @Override + public void init() { + for (int j = 0; j < getTotalNumberOfNodes(); j++) { + flowNode[j].initFlowCalc(); + flowNode[j].init(); } - /** {@inheritDoc} */ - @Override - public void solveTransient(int type) { - // pipeSolver pipeSolve = new pipeSolver(this, getSystemLength(), - // getTotalNumberOfNodes()); - // pipeSolve.solveTDMA(); + for (int j = 0; j < getTotalNumberOfNodes(); j++) { + for (int phase = 0; phase < 2; phase++) { + flowNode[j].setVelocityOut(phase, this.flowNode[j].getVelocity(phase)); + } } - /** - *

main.

- * - * @param args an array of {@link java.lang.String} objects - */ - @SuppressWarnings("unused") - public static void main(String[] args) { - // Initierer et nyt rorsystem - neqsim.fluidMechanics.flowSystem.FlowSystemInterface pipe = new TwoPhasePipeFlowSystem(); - - // Definerer termodyanmikken5 - initierer et system som benytter SRK tilstandsligning - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos(295.3, 5.0); - - // med trykk 305.3 K og 125 bar - // gjor termodynamiske Flash rutiner tilgjengelige - neqsim.thermodynamicOperations.ThermodynamicOperations testOps = - new neqsim.thermodynamicOperations.ThermodynamicOperations(testSystem); - testSystem.addComponent("methane", 0.11152181, 0); - // testSystem.addComponent("ethane", 0.0011152181, 0); - testSystem.addComponent("water", 0.04962204876, 1); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - // benytter klassiske blandingsregler - - pipe.setInletThermoSystem(testSystem); // setter termodyanmikken for rorsystemet - pipe.setNumberOfLegs(5); // deler inn roret i et gitt antall legger - pipe.setNumberOfNodesInLeg(10); // setter antall nodepunkter (beregningspunkter/grid) pr. - // leg - double[] height = {0, 0, 0, 0, 0, 0}; - double[] length = {0.0, 1.7, 3.5, 5.0, 7.5, 10.4}; - double[] outerTemperature = {278.0, 278.0, 278.0, 278.0, 278.0, 278.0};// , 278.0, 275.0, - // 275.0, 275.0, - // 275.0}; - double[] roughness = {1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5}; - double[] outHeatCoef = {5.0, 5.0, 5.0, 5.0, 5.0, 5.0}; - double[] wallHeacCoef = {15.0, 15.0, 15.0, 15.0, 15.0, 15.0}; - - pipe.setLegHeights(height); // setter inn hoyde for hver leg-ende - pipe.setLegPositions(length); // setter avstand til hver leg-ende - pipe.setLegOuterTemperatures(outerTemperature); - pipe.setLegWallHeatTransferCoefficients(wallHeacCoef); - pipe.setLegOuterHeatTransferCoefficients(outHeatCoef); - - // Definerer geometrien for roret - neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface[] pipeGemometry = - new neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData[6]; - double[] pipeDiameter = {0.02588, 0.02588, 0.02588, 0.02588, 0.02588, 0.02588}; - for (int i = 0; i < pipeDiameter.length; i++) { - pipeGemometry[i] = - new neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData(pipeDiameter[i]); - } - pipe.setEquipmentGeometry(pipeGemometry); // setter inn rorgeometrien for hver leg - // utforer bergninger - pipe.createSystem(); - pipe.init(); - - pipe.solveSteadyState(2); - pipe.getNode(30).display(); - // pipe.calcFluxes(); - // pipe.getDisplay().displayResult("temperature"); - // pipe.getDisplay().createNetCdfFile("c:/temp5.nc"); - // pipe.displayResults(); - // testOps.TPflash(); - // testOps.displayResult(); + for (int k = 1; k < getTotalNumberOfNodes(); k++) { + for (int phase = 0; phase < 2; phase++) { + this.flowNode[k].setVelocityIn(phase, this.flowNode[k - 1].getVelocityOut(phase)); + } + } + } + + /** {@inheritDoc} */ + @Override + public void solveSteadyState(int solverType) { + double[] times = {0.0}; + display = + new neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowSystemVisualization.twoPhaseFlowVisualization.twoPhasePipeFlowVisualization.TwoPhasePipeFlowVisualization( + this.getTotalNumberOfNodes(), 1); + getTimeSeries().setTimes(times); + neqsim.thermo.system.SystemInterface[] systems = {flowNode[0].getBulkSystem()}; + getTimeSeries().setInletThermoSystems(systems); + getTimeSeries().setNumberOfTimeStepsInInterval(1); + double[] outletFlowRates = {0.0, 0.0}; + getTimeSeries().setOutletMolarFlowRate(outletFlowRates); + + flowSolver = + new neqsim.fluidMechanics.flowSolver.twoPhaseFlowSolver.twoPhasePipeFlowSolver.TwoPhaseFixedStaggeredGridSolver( + this, getSystemLength(), this.getTotalNumberOfNodes(), false); + flowSolver.setSolverType(solverType); + flowSolver.solveTDMA(); + + getTimeSeries().init(this); + display.setNextData(this); + } + + /** {@inheritDoc} */ + @Override + public void solveTransient(int type) { + // pipeSolver pipeSolve = new pipeSolver(this, getSystemLength(), + // getTotalNumberOfNodes()); + // pipeSolve.solveTDMA(); + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String[] args) { + // Initierer et nyt rorsystem + neqsim.fluidMechanics.flowSystem.FlowSystemInterface pipe = new TwoPhasePipeFlowSystem(); + + // Definerer termodyanmikken5 - initierer et system som benytter SRK tilstandsligning + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos(295.3, 5.0); + + // med trykk 305.3 K og 125 bar - // gjor termodynamiske Flash rutiner tilgjengelige + neqsim.thermodynamicOperations.ThermodynamicOperations testOps = + new neqsim.thermodynamicOperations.ThermodynamicOperations(testSystem); + testSystem.addComponent("methane", 0.11152181, 0); + // testSystem.addComponent("ethane", 0.0011152181, 0); + testSystem.addComponent("water", 0.04962204876, 1); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + // benytter klassiske blandingsregler + + pipe.setInletThermoSystem(testSystem); // setter termodyanmikken for rorsystemet + pipe.setNumberOfLegs(5); // deler inn roret i et gitt antall legger + pipe.setNumberOfNodesInLeg(10); // setter antall nodepunkter (beregningspunkter/grid) pr. + // leg + double[] height = {0, 0, 0, 0, 0, 0}; + double[] length = {0.0, 1.7, 3.5, 5.0, 7.5, 10.4}; + double[] outerTemperature = {278.0, 278.0, 278.0, 278.0, 278.0, 278.0};// , 278.0, 275.0, + // 275.0, 275.0, + // 275.0}; + double[] roughness = {1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5}; + double[] outHeatCoef = {5.0, 5.0, 5.0, 5.0, 5.0, 5.0}; + double[] wallHeacCoef = {15.0, 15.0, 15.0, 15.0, 15.0, 15.0}; + + pipe.setLegHeights(height); // setter inn hoyde for hver leg-ende + pipe.setLegPositions(length); // setter avstand til hver leg-ende + pipe.setLegOuterTemperatures(outerTemperature); + pipe.setLegWallHeatTransferCoefficients(wallHeacCoef); + pipe.setLegOuterHeatTransferCoefficients(outHeatCoef); + + // Definerer geometrien for roret + neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface[] pipeGemometry = + new neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData[6]; + double[] pipeDiameter = {0.02588, 0.02588, 0.02588, 0.02588, 0.02588, 0.02588}; + for (int i = 0; i < pipeDiameter.length; i++) { + pipeGemometry[i] = + new neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData(pipeDiameter[i]); } + pipe.setEquipmentGeometry(pipeGemometry); // setter inn rorgeometrien for hver leg + // utforer bergninger + pipe.createSystem(); + pipe.init(); + + pipe.solveSteadyState(2); + pipe.getNode(30).display(); + // pipe.calcFluxes(); + // pipe.getDisplay().displayResult("temperature"); + // pipe.displayResults(); + // testOps.TPflash(); + // testOps.displayResult(); + } } diff --git a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhasePipeFlowSystem/TwoPhasePipeFlowSystemReac.java b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhasePipeFlowSystem/TwoPhasePipeFlowSystemReac.java index ac541a3cd2..e0af65a0d6 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhasePipeFlowSystem/TwoPhasePipeFlowSystemReac.java +++ b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhasePipeFlowSystem/TwoPhasePipeFlowSystemReac.java @@ -13,84 +13,81 @@ * @version $Id: $Id */ public class TwoPhasePipeFlowSystemReac extends TwoPhasePipeFlowSystem { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for TwoPhasePipeFlowSystemReac. - *

- */ - public TwoPhasePipeFlowSystemReac() {} + /** + *

+ * Constructor for TwoPhasePipeFlowSystemReac. + *

+ */ + public TwoPhasePipeFlowSystemReac() {} - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - // Initierer et nyt rorsystem - neqsim.fluidMechanics.flowSystem.FlowSystemInterface pipe = - new TwoPhasePipeFlowSystemReac(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + // Initierer et nyt rorsystem + neqsim.fluidMechanics.flowSystem.FlowSystemInterface pipe = new TwoPhasePipeFlowSystemReac(); - SystemInterface testSystem = new SystemFurstElectrolyteEos(295.3, 50.01325); - testSystem.addComponent("methane", 50.11152187, "Nlitre/min", 0); - testSystem.addComponent("CO2", 50.11152181, "Nlitre/min", 0); - testSystem.addComponent("water", 0.5662204876, "kg/min", 1); - testSystem.addComponent("MDEA", 0.5662204876, "kg/min", 1); + SystemInterface testSystem = new SystemFurstElectrolyteEos(295.3, 50.01325); + testSystem.addComponent("methane", 50.11152187, "Nlitre/min", 0); + testSystem.addComponent("CO2", 50.11152181, "Nlitre/min", 0); + testSystem.addComponent("water", 0.5662204876, "kg/min", 1); + testSystem.addComponent("MDEA", 0.5662204876, "kg/min", 1); - testSystem.chemicalReactionInit(); - testSystem.createDatabase(true); - testSystem.setMixingRule(4); - testSystem.setPhysicalPropertyModel(3); - // testOps.TPflash(); - // testSystem.display(); + testSystem.chemicalReactionInit(); + testSystem.createDatabase(true); + testSystem.setMixingRule(4); + testSystem.setPhysicalPropertyModel(3); + // testOps.TPflash(); + // testSystem.display(); - // testSystem.setNumericDerivatives(true); - testSystem.initPhysicalProperties(); + // testSystem.setNumericDerivatives(true); + testSystem.initPhysicalProperties(); - pipe.setInletThermoSystem(testSystem); // setter termodyanmikken for rorsystemet - pipe.setNumberOfLegs(3); // deler inn roret i et gitt antall legger - pipe.setNumberOfNodesInLeg(10); // setter antall nodepunkter (beregningspunkter/grid) pr. - // leg + pipe.setInletThermoSystem(testSystem); // setter termodyanmikken for rorsystemet + pipe.setNumberOfLegs(3); // deler inn roret i et gitt antall legger + pipe.setNumberOfNodesInLeg(10); // setter antall nodepunkter (beregningspunkter/grid) pr. + // leg - double[] height = {0, 0, 0, 0, 0, 0}; - double[] length = {0.0, 0.03, 0.07, 0.13, 2.5, 3.7}; - double[] outerTemperature = - {278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 275.0, 275.0, 275.0, 275.0}; + double[] height = {0, 0, 0, 0, 0, 0}; + double[] length = {0.0, 0.03, 0.07, 0.13, 2.5, 3.7}; + double[] outerTemperature = + {278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 275.0, 275.0, 275.0, 275.0}; - pipe.setLegHeights(height); // setter inn hoyde for hver leg-ende - pipe.setLegPositions(length); // setter avstand til hver leg-ende - pipe.setLegOuterTemperatures(outerTemperature); + pipe.setLegHeights(height); // setter inn hoyde for hver leg-ende + pipe.setLegPositions(length); // setter avstand til hver leg-ende + pipe.setLegOuterTemperatures(outerTemperature); - neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface[] pipeGemometry = - new neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData[5]; // Deffinerer - // geometrien - // for - // roret - double[] pipeDiameter = {0.025, 0.025, 0.025, 0.025, 0.025}; - for (int i = 0; i < pipeDiameter.length; i++) { - pipeGemometry[i] = - new neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData(pipeDiameter[i]); - } - pipe.setEquipmentGeometry(pipeGemometry); // setter inn rorgeometrien for hver leg - // utforer bergninger - pipe.createSystem(); - pipe.setEquilibriumMassTransfer(false); - pipe.setEquilibriumHeatTransfer(false); - pipe.init(); + neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface[] pipeGemometry = + new neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData[5]; // Deffinerer + // geometrien + // for + // roret + double[] pipeDiameter = {0.025, 0.025, 0.025, 0.025, 0.025}; + for (int i = 0; i < pipeDiameter.length; i++) { + pipeGemometry[i] = + new neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData(pipeDiameter[i]); + } + pipe.setEquipmentGeometry(pipeGemometry); // setter inn rorgeometrien for hver leg + // utforer bergninger + pipe.createSystem(); + pipe.setEquilibriumMassTransfer(false); + pipe.setEquilibriumHeatTransfer(false); + pipe.init(); - pipe.solveSteadyState(2); - ThermodynamicOperations testOps = - new ThermodynamicOperations(pipe.getNode(2).getBulkSystem()); - testOps.TPflash(); + pipe.solveSteadyState(2); + ThermodynamicOperations testOps = new ThermodynamicOperations(pipe.getNode(2).getBulkSystem()); + testOps.TPflash(); - // pipe.calcFluxes(); - // pipe.print(); - pipe.getDisplay().createNetCdfFile("c:/temp5.nc"); - // pipe.displayResult(); - // testOps.TPflash(); - // testOps.displayResult(); - } + // pipe.calcFluxes(); + // pipe.print(); + // pipe.displayResult(); + // testOps.TPflash(); + // testOps.displayResult(); + } } diff --git a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhaseReactorFlowSystem/TwoPhaseReactorFlowSystem.java b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhaseReactorFlowSystem/TwoPhaseReactorFlowSystem.java index e405fa2505..4f28059db9 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhaseReactorFlowSystem/TwoPhaseReactorFlowSystem.java +++ b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhaseReactorFlowSystem/TwoPhaseReactorFlowSystem.java @@ -159,7 +159,6 @@ public static void main(String[] args) { pipe.solveSteadyState(2); // pipe.calcFluxes(); // pipe.getDisplay().displayResult("temperature"); - pipe.getDisplay().createNetCdfFile("c:/temp5.nc"); // pipe.displayResults(); // testOps.TPflash(); // testOps.displayResult(); diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/FlowSystemVisualization.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/FlowSystemVisualization.java index a504ca6d3b..104846ebf3 100644 --- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/FlowSystemVisualization.java +++ b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/FlowSystemVisualization.java @@ -13,78 +13,73 @@ * @version $Id: $Id */ public class FlowSystemVisualization implements FlowSystemVisualizationInterface { - protected FlowNodeVisualizationInterface[][] flowNodes; - protected FlowSystemInterface[] flowSystem; - protected int time = 0; - protected double[] absTime; + protected FlowNodeVisualizationInterface[][] flowNodes; + protected FlowSystemInterface[] flowSystem; + protected int time = 0; + protected double[] absTime; - /** - *

- * Constructor for FlowSystemVisualization. - *

- */ - public FlowSystemVisualization() {} + /** + *

+ * Constructor for FlowSystemVisualization. + *

+ */ + public FlowSystemVisualization() {} - /** - *

- * Constructor for FlowSystemVisualization. - *

- * - * @param nodes a int - * @param timeSteps a int - */ - public FlowSystemVisualization(int nodes, int timeSteps) { - flowNodes = new FlowNodeVisualization[timeSteps][nodes]; - flowSystem = new FlowSystemInterface[timeSteps]; - absTime = new double[timeSteps]; - for (int i = 0; i < timeSteps; i++) { - for (int j = 0; j < nodes; j++) { - flowNodes[i][j] = new FlowNodeVisualization(); - } - } - // System.out.println("nodes " + nodes); - // System.out.println("times " + time); + /** + *

+ * Constructor for FlowSystemVisualization. + *

+ * + * @param nodes a int + * @param timeSteps a int + */ + public FlowSystemVisualization(int nodes, int timeSteps) { + flowNodes = new FlowNodeVisualization[timeSteps][nodes]; + flowSystem = new FlowSystemInterface[timeSteps]; + absTime = new double[timeSteps]; + for (int i = 0; i < timeSteps; i++) { + for (int j = 0; j < nodes; j++) { + flowNodes[i][j] = new FlowNodeVisualization(); + } } + // System.out.println("nodes " + nodes); + // System.out.println("times " + time); + } - /** {@inheritDoc} */ - @Override - public void setNextData(FlowSystemInterface system) { - flowSystem[time] = system; - absTime[time] = 0; - for (int i = 0; i < flowNodes[time].length; i++) { - flowNodes[time][i].setData(system.getNode(i)); - } - time++; - // System.out.println("time " + time); + /** {@inheritDoc} */ + @Override + public void setNextData(FlowSystemInterface system) { + flowSystem[time] = system; + absTime[time] = 0; + for (int i = 0; i < flowNodes[time].length; i++) { + flowNodes[time][i].setData(system.getNode(i)); } + time++; + // System.out.println("time " + time); + } - /** {@inheritDoc} */ - @Override - public void setNextData(FlowSystemInterface system, double abstime) { - flowSystem[time] = system; - absTime[time] = abstime; - for (int i = 0; i < flowNodes[time].length; i++) { - flowNodes[time][i].setData(system.getNode(i)); - } - time++; + /** {@inheritDoc} */ + @Override + public void setNextData(FlowSystemInterface system, double abstime) { + flowSystem[time] = system; + absTime[time] = abstime; + for (int i = 0; i < flowNodes[time].length; i++) { + flowNodes[time][i].setData(system.getNode(i)); } + time++; + } - /** {@inheritDoc} */ - @Override - public void createNetCdfFile(String name) { - System.out.println("ok..."); - for (int j = 0; j < time; j++) { - for (int i = 0; i < flowNodes[j].length; i++) { - System.out.println("time " + time + " pres " + flowNodes[j][i].getPressure(0)); - } - } - } + /* + * public void createNetCdfFile(String name) { System.out.println("ok..."); for (int j = 0; j < + * time; j++) { for (int i = 0; i < flowNodes[j].length; i++) { System.out.println("time " + time + * + " pres " + flowNodes[j][i].getPressure(0)); } } } + */ - /** {@inheritDoc} */ - @Override - public void setPoints() {} + /** {@inheritDoc} */ + @Override + public void setPoints() {} - /** {@inheritDoc} */ - @Override - public void displayResult(String name) {} + /** {@inheritDoc} */ + @Override + public void displayResult(String name) {} } diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/FlowSystemVisualizationInterface.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/FlowSystemVisualizationInterface.java index e760598231..5040f13dee 100644 --- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/FlowSystemVisualizationInterface.java +++ b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/FlowSystemVisualizationInterface.java @@ -45,13 +45,4 @@ public interface FlowSystemVisualizationInterface { * @param abstime a double */ public void setNextData(FlowSystemInterface system, double abstime); - - /** - *

- * createNetCdfFile. - *

- * - * @param name a {@link java.lang.String} object - */ - public void createNetCdfFile(String name); } diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/onePhaseFlowVisualization/pipeFlowVisualization/PipeFlowVisualization.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/onePhaseFlowVisualization/pipeFlowVisualization/PipeFlowVisualization.java index ca4759d384..991072c028 100644 --- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/onePhaseFlowVisualization/pipeFlowVisualization/PipeFlowVisualization.java +++ b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/onePhaseFlowVisualization/pipeFlowVisualization/PipeFlowVisualization.java @@ -14,184 +14,153 @@ * @version $Id: $Id */ public class PipeFlowVisualization extends - neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowSystemVisualization.onePhaseFlowVisualization.OnePhaseFlowVisualization { - double[][] pressurePoint = new double[10][10]; - double[][] velocityPoint = new double[10][10]; - double[][] temperaturePoint = new double[10][10]; - public double[][][] bulkComposition; - double[] xPlace = new double[10]; - double[] timeArray = new double[10]; + neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowSystemVisualization.onePhaseFlowVisualization.OnePhaseFlowVisualization { + double[][] pressurePoint = new double[10][10]; + double[][] velocityPoint = new double[10][10]; + double[][] temperaturePoint = new double[10][10]; + public double[][][] bulkComposition; + double[] xPlace = new double[10]; + double[] timeArray = new double[10]; - /** - *

- * Constructor for PipeFlowVisualization. - *

- */ - public PipeFlowVisualization() {} + /** + *

+ * Constructor for PipeFlowVisualization. + *

+ */ + public PipeFlowVisualization() {} - /** - *

- * Constructor for PipeFlowVisualization. - *

- * - * @param nodes a int - * @param timeSteps a int - */ - public PipeFlowVisualization(int nodes, int timeSteps) { - flowSystem = new neqsim.fluidMechanics.flowSystem.FlowSystemInterface[timeSteps]; - flowNodes = - new neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowNodeVisualization.onePhaseFlowNodeVisualization.onePhasePipeFlowNodeVisualization.OnePhasePipeFlowNodeVisualization[timeSteps][nodes]; - absTime = new double[timeSteps]; - for (int i = 0; i < timeSteps; i++) { - for (int j = 0; j < nodes; j++) { - flowNodes[i][j] = - new neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowNodeVisualization.onePhaseFlowNodeVisualization.onePhasePipeFlowNodeVisualization.OnePhasePipeFlowNodeVisualization(); - } - } - // System.out.println("nodes " + nodes); - // System.out.println("times " + time); + /** + *

+ * Constructor for PipeFlowVisualization. + *

+ * + * @param nodes a int + * @param timeSteps a int + */ + public PipeFlowVisualization(int nodes, int timeSteps) { + flowSystem = new neqsim.fluidMechanics.flowSystem.FlowSystemInterface[timeSteps]; + flowNodes = + new neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowNodeVisualization.onePhaseFlowNodeVisualization.onePhasePipeFlowNodeVisualization.OnePhasePipeFlowNodeVisualization[timeSteps][nodes]; + absTime = new double[timeSteps]; + for (int i = 0; i < timeSteps; i++) { + for (int j = 0; j < nodes; j++) { + flowNodes[i][j] = + new neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowNodeVisualization.onePhaseFlowNodeVisualization.onePhasePipeFlowNodeVisualization.OnePhasePipeFlowNodeVisualization(); + } } + // System.out.println("nodes " + nodes); + // System.out.println("times " + time); + } - /** {@inheritDoc} */ - @Override - public void setPoints() { - pressurePoint = new double[time][flowNodes[0].length]; - temperaturePoint = new double[time][flowNodes[0].length]; - velocityPoint = new double[time][flowNodes[0].length]; - xPlace = new double[flowNodes[0].length]; - timeArray = new double[time]; - bulkComposition = - new double[flowNodes[0][0].getNumberOfComponents()][time][flowNodes[0].length]; + /** {@inheritDoc} */ + @Override + public void setPoints() { + pressurePoint = new double[time][flowNodes[0].length]; + temperaturePoint = new double[time][flowNodes[0].length]; + velocityPoint = new double[time][flowNodes[0].length]; + xPlace = new double[flowNodes[0].length]; + timeArray = new double[time]; + bulkComposition = + new double[flowNodes[0][0].getNumberOfComponents()][time][flowNodes[0].length]; - for (int j = 0; j < time; j++) { - timeArray[j] = absTime[j]; - for (int i = 0; i < flowNodes[j].length; i++) { - xPlace[i] = flowNodes[j][i].getDistanceToCenterOfNode(); - pressurePoint[j][i] = flowNodes[j][i].getPressure(0); - temperaturePoint[j][i] = flowNodes[j][i].getTemperature(0); - velocityPoint[j][i] = flowNodes[j][i].getVelocity(0); - for (int p = 0; p < flowNodes[0][0].getNumberOfComponents(); p++) { - bulkComposition[p][j][i] = flowNodes[j][i].getBulkComposition(p, 0); - } - } + for (int j = 0; j < time; j++) { + timeArray[j] = absTime[j]; + for (int i = 0; i < flowNodes[j].length; i++) { + xPlace[i] = flowNodes[j][i].getDistanceToCenterOfNode(); + pressurePoint[j][i] = flowNodes[j][i].getPressure(0); + temperaturePoint[j][i] = flowNodes[j][i].getTemperature(0); + velocityPoint[j][i] = flowNodes[j][i].getVelocity(0); + for (int p = 0; p < flowNodes[0][0].getNumberOfComponents(); p++) { + bulkComposition[p][j][i] = flowNodes[j][i].getBulkComposition(p, 0); } + } } + } - /** - *

- * calcPoints. - *

- * - * @param name a {@link java.lang.String} object - */ - public void calcPoints(String name) { - double[][] points = new double[1][1]; - setPoints(); - - if (name.equals("pressure")) { - points = pressurePoint; - } - if (name.equals("temperature")) { - points = temperaturePoint; - } - if (name.equals("velocity")) { - points = velocityPoint; - } - if (name.equals("composition")) { - points = bulkComposition[0]; - } -/* - try { - System.out.println("points: " + points.length); + /** + *

+ * calcPoints. + *

+ * + * @param name a {@link java.lang.String} object + */ + public void calcPoints(String name) { + double[][] points = new double[1][1]; + setPoints(); - if (pressurePoint.length > 1) { - System.out.println("3D plot "); - plot = new neqsim.dataPresentation.visAD.visAd3D.visAd3DPlot("title[0]", "title[1]", - "title[2]"); - ((neqsim.dataPresentation.visAD.visAd3D.visAd3DPlot) plot).setXYvals(150, 160, - points[0].length, 10, 20, points.length); - ((neqsim.dataPresentation.visAD.visAd3D.visAd3DPlot) plot).setZvals(points); - } else { - System.out.println("2D plot "); - plot = new neqsim.dataPresentation.visAD.visAd2D.visAd2dBaseClass("title[1]", - "title[2]"); - ((neqsim.dataPresentation.visAD.visAd2D.visAd2dBaseClass) plot) - .setLineXYVals(xPlace, points[0]); - ((neqsim.dataPresentation.visAD.visAd2D.visAd2dBaseClass) plot).setXYVals(xPlace, - points[0]); - } - } catch (Exception e) { - System.out.println(e.toString()); - System.out.println("plotting failed"); - } - */ + if (name.equals("pressure")) { + points = pressurePoint; } + if (name.equals("temperature")) { + points = temperaturePoint; + } + if (name.equals("velocity")) { + points = velocityPoint; + } + if (name.equals("composition")) { + points = bulkComposition[0]; + } + /* + * try { System.out.println("points: " + points.length); + * + * if (pressurePoint.length > 1) { System.out.println("3D plot "); plot = new + * neqsim.dataPresentation.visAD.visAd3D.visAd3DPlot("title[0]", "title[1]", "title[2]"); + * ((neqsim.dataPresentation.visAD.visAd3D.visAd3DPlot) plot).setXYvals(150, 160, + * points[0].length, 10, 20, points.length); + * ((neqsim.dataPresentation.visAD.visAd3D.visAd3DPlot) plot).setZvals(points); } else { + * System.out.println("2D plot "); plot = new + * neqsim.dataPresentation.visAD.visAd2D.visAd2dBaseClass("title[1]", "title[2]"); + * ((neqsim.dataPresentation.visAD.visAd2D.visAd2dBaseClass) plot) .setLineXYVals(xPlace, + * points[0]); ((neqsim.dataPresentation.visAD.visAd2D.visAd2dBaseClass) plot).setXYVals(xPlace, + * points[0]); } } catch (Exception e) { System.out.println(e.toString()); + * System.out.println("plotting failed"); } + */ + } - /** {@inheritDoc} */ - @Override - public void displayResult(String name) { - double[][] points = new double[1][1]; - setPoints(); - - if (name.equals("pressure")) { - points = pressurePoint; - } - if (name.equals("temperature")) { - points = temperaturePoint; - } - if (name.equals("velocity")) { - points = velocityPoint; - } - if (name.equals("composition")) { - points = bulkComposition[0]; - } -/* - try { - System.out.println("points: " + points.length); + /** {@inheritDoc} */ + @Override + public void displayResult(String name) { + double[][] points = new double[1][1]; + setPoints(); - if (pressurePoint.length > 1) { - System.out.println("3D plot "); - plot = new neqsim.dataPresentation.visAD.visAd3D.visAd3DPlot("title[0]", "title[1]", - "title[2]"); - ((neqsim.dataPresentation.visAD.visAd3D.visAd3DPlot) plot).setXYvals(150, 160, - points[0].length, 10, 20, points.length); - ((neqsim.dataPresentation.visAD.visAd3D.visAd3DPlot) plot).setZvals(points); - } else { - System.out.println("2D plot "); - plot = new neqsim.dataPresentation.visAD.visAd2D.visAd2dBaseClass("title[1]", - "title[2]"); - ((neqsim.dataPresentation.visAD.visAd2D.visAd2dBaseClass) plot) - .setLineXYVals(xPlace, points[0]); - ((neqsim.dataPresentation.visAD.visAd2D.visAd2dBaseClass) plot).setXYVals(xPlace, - points[0]); - } - plot.init(); - } catch (Exception e) { - System.out.println(e.toString()); - System.out.println("plotting failed"); - } - */ + if (name.equals("pressure")) { + points = pressurePoint; } - - /** {@inheritDoc} */ - /* - @Override - public void createNetCdfFile(String name) { - calcPoints(name); - neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF3D.NetCdf3D file = - new neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF3D.NetCdf3D(); - file.setOutputFileName(name); - file.setXvalues(timeArray, "time", "sec"); - file.setYvalues(xPlace, "length", "meter"); - file.setZvalues(temperaturePoint, "temperature [K]", "sec"); - file.setZvalues(pressurePoint, "pressure [bar]", "sec"); - file.setZvalues(velocityPoint, "velocity [m/sec]", "sec"); - if (absTime.length > 1) { - for (int p = 0; p < flowNodes[0][0].getNumberOfComponents(); p++) { - file.setZvalues(bulkComposition[p], ("comp " + p), "sec"); - } - } - file.createFile(); + if (name.equals("temperature")) { + points = temperaturePoint; + } + if (name.equals("velocity")) { + points = velocityPoint; + } + if (name.equals("composition")) { + points = bulkComposition[0]; } - */ + /* + * try { System.out.println("points: " + points.length); + * + * if (pressurePoint.length > 1) { System.out.println("3D plot "); plot = new + * neqsim.dataPresentation.visAD.visAd3D.visAd3DPlot("title[0]", "title[1]", "title[2]"); + * ((neqsim.dataPresentation.visAD.visAd3D.visAd3DPlot) plot).setXYvals(150, 160, + * points[0].length, 10, 20, points.length); + * ((neqsim.dataPresentation.visAD.visAd3D.visAd3DPlot) plot).setZvals(points); } else { + * System.out.println("2D plot "); plot = new + * neqsim.dataPresentation.visAD.visAd2D.visAd2dBaseClass("title[1]", "title[2]"); + * ((neqsim.dataPresentation.visAD.visAd2D.visAd2dBaseClass) plot) .setLineXYVals(xPlace, + * points[0]); ((neqsim.dataPresentation.visAD.visAd2D.visAd2dBaseClass) plot).setXYVals(xPlace, + * points[0]); } plot.init(); } catch (Exception e) { System.out.println(e.toString()); + * System.out.println("plotting failed"); } + */ + } + + /* + * public void createNetCdfFile(String name) { calcPoints(name); + * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF3D.NetCdf3D file = new + * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF3D.NetCdf3D(); + * file.setOutputFileName(name); file.setXvalues(timeArray, "time", "sec"); + * file.setYvalues(xPlace, "length", "meter"); file.setZvalues(temperaturePoint, + * "temperature [K]", "sec"); file.setZvalues(pressurePoint, "pressure [bar]", "sec"); + * file.setZvalues(velocityPoint, "velocity [m/sec]", "sec"); if (absTime.length > 1) { for (int p + * = 0; p < flowNodes[0][0].getNumberOfComponents(); p++) { file.setZvalues(bulkComposition[p], + * ("comp " + p), "sec"); } } file.createFile(); } + */ } diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/twoPhaseFlowVisualization/twoPhasePipeFlowVisualization/TwoPhasePipeFlowVisualization.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/twoPhaseFlowVisualization/twoPhasePipeFlowVisualization/TwoPhasePipeFlowVisualization.java index 1a4ec9c527..c3aeeb9529 100644 --- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/twoPhaseFlowVisualization/twoPhasePipeFlowVisualization/TwoPhasePipeFlowVisualization.java +++ b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/twoPhaseFlowVisualization/twoPhasePipeFlowVisualization/TwoPhasePipeFlowVisualization.java @@ -12,199 +12,187 @@ * @version $Id: $Id */ public class TwoPhasePipeFlowVisualization extends - neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowSystemVisualization.twoPhaseFlowVisualization.TwoPhaseFlowVisualization { - double[][][] pressurePoint = new double[2][10][10]; - double[][][] velocityPoint = new double[2][10][10]; - double[][][] reynoldsNumber = new double[2][10][10]; - double[][][] phaseFraction = new double[2][10][10]; - double[][][] temperaturePoint = new double[2][10][10]; - double[][][] interphaseContactLength = new double[2][10][10]; - double[][][] interfaceTemperaturePoint = new double[2][10][10]; - public double[][][][] bulkComposition, interfaceComposition, effectiveMassTransferCoefficient; // phase, - // time, - // component, - // node - public double[][][][] molarFlux, schmidtNumber; - public double[][][][] totalMolarMassTransferRate; - public double[][][][] totalVolumetricMassTransferRate; - double[] xPlace = new double[10]; - double[] timeArray = new double[10]; + neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowSystemVisualization.twoPhaseFlowVisualization.TwoPhaseFlowVisualization { + double[][][] pressurePoint = new double[2][10][10]; + double[][][] velocityPoint = new double[2][10][10]; + double[][][] reynoldsNumber = new double[2][10][10]; + double[][][] phaseFraction = new double[2][10][10]; + double[][][] temperaturePoint = new double[2][10][10]; + double[][][] interphaseContactLength = new double[2][10][10]; + double[][][] interfaceTemperaturePoint = new double[2][10][10]; + public double[][][][] bulkComposition, interfaceComposition, effectiveMassTransferCoefficient; // phase, + // time, + // component, + // node + public double[][][][] molarFlux, schmidtNumber; + public double[][][][] totalMolarMassTransferRate; + public double[][][][] totalVolumetricMassTransferRate; + double[] xPlace = new double[10]; + double[] timeArray = new double[10]; - /** - *

- * Constructor for TwoPhasePipeFlowVisualization. - *

- */ - public TwoPhasePipeFlowVisualization() {} + /** + *

+ * Constructor for TwoPhasePipeFlowVisualization. + *

+ */ + public TwoPhasePipeFlowVisualization() {} - /** - *

- * Constructor for TwoPhasePipeFlowVisualization. - *

- * - * @param nodes a int - * @param timeSteps a int - */ - public TwoPhasePipeFlowVisualization(int nodes, int timeSteps) { - flowNodes = new TwoPhaseFlowNodeVisualization[timeSteps][nodes]; - flowSystem = new FlowSystem[timeSteps]; - absTime = new double[timeSteps]; - for (int i = 0; i < timeSteps; i++) { - for (int j = 0; j < nodes; j++) { - flowNodes[i][j] = new TwoPhaseFlowNodeVisualization(); - } - } - // System.out.println("nodes " + nodes); - // System.out.println("times " + time); + /** + *

+ * Constructor for TwoPhasePipeFlowVisualization. + *

+ * + * @param nodes a int + * @param timeSteps a int + */ + public TwoPhasePipeFlowVisualization(int nodes, int timeSteps) { + flowNodes = new TwoPhaseFlowNodeVisualization[timeSteps][nodes]; + flowSystem = new FlowSystem[timeSteps]; + absTime = new double[timeSteps]; + for (int i = 0; i < timeSteps; i++) { + for (int j = 0; j < nodes; j++) { + flowNodes[i][j] = new TwoPhaseFlowNodeVisualization(); + } } + // System.out.println("nodes " + nodes); + // System.out.println("times " + time); + } - /** {@inheritDoc} */ - @Override - public void setPoints() { - pressurePoint = new double[2][time][flowNodes[0].length]; - temperaturePoint = new double[2][time][flowNodes[0].length]; - interphaseContactLength = new double[2][time][flowNodes[0].length]; - velocityPoint = new double[2][time][flowNodes[0].length]; - reynoldsNumber = new double[2][time][flowNodes[0].length]; - phaseFraction = new double[2][time][flowNodes[0].length]; - interfaceTemperaturePoint = new double[2][time][flowNodes[0].length]; - bulkComposition = - new double[2][flowNodes[0][0].getNumberOfComponents()][time][flowNodes[0].length]; - effectiveMassTransferCoefficient = - new double[2][flowNodes[0][0].getNumberOfComponents()][time][flowNodes[0].length]; - interfaceComposition = - new double[2][flowNodes[0][0].getNumberOfComponents()][time][flowNodes[0].length]; - molarFlux = - new double[2][flowNodes[0][0].getNumberOfComponents()][time][flowNodes[0].length]; - schmidtNumber = - new double[2][flowNodes[0][0].getNumberOfComponents()][time][flowNodes[0].length]; - totalMolarMassTransferRate = - new double[2][flowNodes[0][0].getNumberOfComponents()][time][flowNodes[0].length]; - totalVolumetricMassTransferRate = - new double[2][flowNodes[0][0].getNumberOfComponents()][time][flowNodes[0].length]; - xPlace = new double[flowNodes[0].length]; - timeArray = new double[time]; + /** {@inheritDoc} */ + @Override + public void setPoints() { + pressurePoint = new double[2][time][flowNodes[0].length]; + temperaturePoint = new double[2][time][flowNodes[0].length]; + interphaseContactLength = new double[2][time][flowNodes[0].length]; + velocityPoint = new double[2][time][flowNodes[0].length]; + reynoldsNumber = new double[2][time][flowNodes[0].length]; + phaseFraction = new double[2][time][flowNodes[0].length]; + interfaceTemperaturePoint = new double[2][time][flowNodes[0].length]; + bulkComposition = + new double[2][flowNodes[0][0].getNumberOfComponents()][time][flowNodes[0].length]; + effectiveMassTransferCoefficient = + new double[2][flowNodes[0][0].getNumberOfComponents()][time][flowNodes[0].length]; + interfaceComposition = + new double[2][flowNodes[0][0].getNumberOfComponents()][time][flowNodes[0].length]; + molarFlux = new double[2][flowNodes[0][0].getNumberOfComponents()][time][flowNodes[0].length]; + schmidtNumber = + new double[2][flowNodes[0][0].getNumberOfComponents()][time][flowNodes[0].length]; + totalMolarMassTransferRate = + new double[2][flowNodes[0][0].getNumberOfComponents()][time][flowNodes[0].length]; + totalVolumetricMassTransferRate = + new double[2][flowNodes[0][0].getNumberOfComponents()][time][flowNodes[0].length]; + xPlace = new double[flowNodes[0].length]; + timeArray = new double[time]; - for (int k = 0; k < 2; k++) { - for (int j = 0; j < time; j++) { - timeArray[j] = j; - for (int i = 0; i < flowNodes[j].length; i++) { - xPlace[i] = flowNodes[j][i].getDistanceToCenterOfNode(); - pressurePoint[k][j][i] = flowNodes[j][i].getPressure(k); - interphaseContactLength[k][j][i] = flowNodes[j][i].getInterphaseContactLength(); - temperaturePoint[k][j][i] = flowNodes[j][i].getTemperature(k); - velocityPoint[k][j][i] = flowNodes[j][i].getVelocity(k); - reynoldsNumber[k][j][i] = flowNodes[j][i].getReynoldsNumber(k); - phaseFraction[k][j][i] = flowNodes[j][i].getPhaseFraction(k); - interfaceTemperaturePoint[k][j][i] = flowNodes[j][i].getInterfaceTemperature(k); - for (int p = 0; p < flowNodes[0][0].getNumberOfComponents(); p++) { - effectiveMassTransferCoefficient[k][p][j][i] = - flowNodes[j][i].getEffectiveMassTransferCoefficient(p, k); - bulkComposition[k][p][j][i] = flowNodes[j][i].getBulkComposition(p, k); - interfaceComposition[k][p][j][i] = - flowNodes[j][i].getInterfaceComposition(p, k); - molarFlux[k][p][j][i] = flowNodes[j][i].getEffectiveSchmidtNumber(p, k); - schmidtNumber[k][p][j][i] = flowNodes[j][i].getEffectiveSchmidtNumber(p, k); - totalMolarMassTransferRate[k][p][j][i] = - flowSystem[j].getTotalMolarMassTransferRate(p, i); - totalVolumetricMassTransferRate[k][p][j][i] = - totalMolarMassTransferRate[k][p][j][i] * 60.0 / 40.87631889 - * 1000.0; - } - } - } + for (int k = 0; k < 2; k++) { + for (int j = 0; j < time; j++) { + timeArray[j] = j; + for (int i = 0; i < flowNodes[j].length; i++) { + xPlace[i] = flowNodes[j][i].getDistanceToCenterOfNode(); + pressurePoint[k][j][i] = flowNodes[j][i].getPressure(k); + interphaseContactLength[k][j][i] = flowNodes[j][i].getInterphaseContactLength(); + temperaturePoint[k][j][i] = flowNodes[j][i].getTemperature(k); + velocityPoint[k][j][i] = flowNodes[j][i].getVelocity(k); + reynoldsNumber[k][j][i] = flowNodes[j][i].getReynoldsNumber(k); + phaseFraction[k][j][i] = flowNodes[j][i].getPhaseFraction(k); + interfaceTemperaturePoint[k][j][i] = flowNodes[j][i].getInterfaceTemperature(k); + for (int p = 0; p < flowNodes[0][0].getNumberOfComponents(); p++) { + effectiveMassTransferCoefficient[k][p][j][i] = + flowNodes[j][i].getEffectiveMassTransferCoefficient(p, k); + bulkComposition[k][p][j][i] = flowNodes[j][i].getBulkComposition(p, k); + interfaceComposition[k][p][j][i] = flowNodes[j][i].getInterfaceComposition(p, k); + molarFlux[k][p][j][i] = flowNodes[j][i].getEffectiveSchmidtNumber(p, k); + schmidtNumber[k][p][j][i] = flowNodes[j][i].getEffectiveSchmidtNumber(p, k); + totalMolarMassTransferRate[k][p][j][i] = + flowSystem[j].getTotalMolarMassTransferRate(p, i); + totalVolumetricMassTransferRate[k][p][j][i] = + totalMolarMassTransferRate[k][p][j][i] * 60.0 / 40.87631889 * 1000.0; + } } + } } + } - /** {@inheritDoc} */ - @Override - public void displayResult(String name) { - // double[][] points = new double[1][1]; - setPoints(); - - // if(name.equals("pressure")) points = pressurePoint; - // if(name.equals("temperature")) points = temperaturePoint; - // if(name.equals("velocity")) points = velocityPoint; + /** {@inheritDoc} */ + @Override + public void displayResult(String name) { + // double[][] points = new double[1][1]; + setPoints(); - // try{ - // System.out.println("points: " + points.length); + // if(name.equals("pressure")) points = pressurePoint; + // if(name.equals("temperature")) points = temperaturePoint; + // if(name.equals("velocity")) points = velocityPoint; - // if(pressurePoint.length>1){ - // System.out.println("3D plot "); - // plot = new visAd3DPlot("title[0]", "title[1]", "title[2]"); - // ((visAd3DPlot) plot).setXYvals(150, 160, points[0].length, 10, 20, - // points.length); - // ((visAd3DPlot) plot).setZvals(points); - // } - // else{ - // System.out.println("2D plot "); - // plot = new visAd2dBaseClass("title[1]", "title[2]"); - // ((visAd2dBaseClass) plot).setLineXYVals(xPlace, points[0]); - // ((visAd2dBaseClass) plot).setXYVals(xPlace, points[0]); - // } - // plot.init(); - // } - // catch(Exception e){ - // System.out.println(e.toString()); - // System.out.println("plotting failed"); - // } - } + // try{ + // System.out.println("points: " + points.length); - // public void createNetCdfFile(String name){ - // dataPresentation.fileHandeling.createNetCDF.NetCdf file = new - // dataPresentation.fileHandeling.createNetCDF.NetCdf(); - // file.setOutputFileName(name); - // file.setXvalues(timeArray,"time","sec"); - // file.setYvalues(xPlace, "length","meter"); - // // file.setZvalues(temperaturePoint, "time","sec"); - // file.createFile(); + // if(pressurePoint.length>1){ + // System.out.println("3D plot "); + // plot = new visAd3DPlot("title[0]", "title[1]", "title[2]"); + // ((visAd3DPlot) plot).setXYvals(150, 160, points[0].length, 10, 20, + // points.length); + // ((visAd3DPlot) plot).setZvals(points); + // } + // else{ + // System.out.println("2D plot "); + // plot = new visAd2dBaseClass("title[1]", "title[2]"); + // ((visAd2dBaseClass) plot).setLineXYVals(xPlace, points[0]); + // ((visAd2dBaseClass) plot).setXYVals(xPlace, points[0]); // } + // plot.init(); + // } + // catch(Exception e){ + // System.out.println(e.toString()); + // System.out.println("plotting failed"); + // } + } + // public void createNetCdfFile(String name){ + // dataPresentation.fileHandeling.createNetCDF.NetCdf file = new + // dataPresentation.fileHandeling.createNetCDF.NetCdf(); + // file.setOutputFileName(name); + // file.setXvalues(timeArray,"time","sec"); + // file.setYvalues(xPlace, "length","meter"); + // // file.setZvalues(temperaturePoint, "time","sec"); + // file.createFile(); + // } - /** {@inheritDoc} */ - /* - @Override - public void createNetCdfFile(String name) { - setPoints(); - neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D file = - new neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); - file.setOutputFileName(name); - file.setXvalues(xPlace, "length", "meter"); - file.setYvalues(pressurePoint[0][0], "gas pressure", "sec"); - file.setYvalues(pressurePoint[1][0], "liquid pressure", "sec"); - file.setYvalues(velocityPoint[0][0], "gas velocity", "sec"); - file.setYvalues(velocityPoint[1][0], "liquid velocity", "sec"); - file.setYvalues(reynoldsNumber[0][0], "gas reynolds number", "sec"); - file.setYvalues(reynoldsNumber[1][0], "liquid reynolds number", "sec"); - file.setYvalues(temperaturePoint[0][0], "gas temperature", "sec"); - file.setYvalues(temperaturePoint[1][0], "liquid temperature", "sec"); - file.setYvalues(phaseFraction[0][0], "void fraction", "sec"); - file.setYvalues(phaseFraction[1][0], "holdup", "sec"); - file.setYvalues(interfaceTemperaturePoint[0][0], "gas interface temperature", "sec"); - file.setYvalues(interfaceTemperaturePoint[1][0], "liquid interface temperature", "sec"); - file.setYvalues(interphaseContactLength[0][0], "interphase contact length", "sec"); - for (int p = 0; p < flowNodes[0][0].getNumberOfComponents(); p++) { - String comp = "component molefraction " + p; - file.setYvalues(bulkComposition[0][p][0], ("gas " + comp + p), "sec"); - file.setYvalues(bulkComposition[1][p][0], ("liquid " + comp + p), "sec"); - file.setYvalues(interfaceComposition[0][p][0], ("gas (interphase) " + comp), "sec"); - file.setYvalues(interfaceComposition[1][p][0], ("liquid (interphase) " + comp), "sec"); - file.setYvalues(molarFlux[0][p][0], ("gas molar flux " + comp + p), "sec"); - file.setYvalues(molarFlux[1][p][0], ("liquid molar flux " + comp + p), "sec"); - file.setYvalues(totalVolumetricMassTransferRate[0][p][0], - ("total gas Volumetric Mass Transfer " + comp + p), "sec"); - file.setYvalues(totalVolumetricMassTransferRate[1][p][0], - ("total liq Volumetric Mass Transfer " + comp + p), "sec"); - file.setYvalues(effectiveMassTransferCoefficient[0][p][0], - ("eff. masstransfer coef gas " + comp + p), "sec"); - file.setYvalues(effectiveMassTransferCoefficient[1][p][0], - ("eff. masstransfer coef liq " + comp + p), "sec"); - file.setYvalues(schmidtNumber[0][p][0], ("gas scmidtnumber " + comp + p), "-"); - file.setYvalues(schmidtNumber[1][p][0], ("liquid scmidtnumber " + comp + p), "-"); - } - // file.setYvalues(temperaturePoint[0][0], "time","sec"); - file.createFile(); - } - */ + /* + * public void createNetCdfFile(String name) { setPoints(); + * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D file = new + * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); + * file.setOutputFileName(name); file.setXvalues(xPlace, "length", "meter"); + * file.setYvalues(pressurePoint[0][0], "gas pressure", "sec"); + * file.setYvalues(pressurePoint[1][0], "liquid pressure", "sec"); + * file.setYvalues(velocityPoint[0][0], "gas velocity", "sec"); + * file.setYvalues(velocityPoint[1][0], "liquid velocity", "sec"); + * file.setYvalues(reynoldsNumber[0][0], "gas reynolds number", "sec"); + * file.setYvalues(reynoldsNumber[1][0], "liquid reynolds number", "sec"); + * file.setYvalues(temperaturePoint[0][0], "gas temperature", "sec"); + * file.setYvalues(temperaturePoint[1][0], "liquid temperature", "sec"); + * file.setYvalues(phaseFraction[0][0], "void fraction", "sec"); + * file.setYvalues(phaseFraction[1][0], "holdup", "sec"); + * file.setYvalues(interfaceTemperaturePoint[0][0], "gas interface temperature", "sec"); + * file.setYvalues(interfaceTemperaturePoint[1][0], "liquid interface temperature", "sec"); + * file.setYvalues(interphaseContactLength[0][0], "interphase contact length", "sec"); + * + * for (int p = 0; p < flowNodes[0][0].getNumberOfComponents(); p++) { String comp = + * "component molefraction " + p; file.setYvalues(bulkComposition[0][p][0], ("gas " + comp + p), + * "sec"); file.setYvalues(bulkComposition[1][p][0], ("liquid " + comp + p), "sec"); + * file.setYvalues(interfaceComposition[0][p][0], ("gas (interphase) " + comp), "sec"); + * file.setYvalues(interfaceComposition[1][p][0], ("liquid (interphase) " + comp), "sec"); + * file.setYvalues(molarFlux[0][p][0], ("gas molar flux " + comp + p), "sec"); + * file.setYvalues(molarFlux[1][p][0], ("liquid molar flux " + comp + p), "sec"); + * file.setYvalues(totalVolumetricMassTransferRate[0][p][0], + * ("total gas Volumetric Mass Transfer " + comp + p), "sec"); + * file.setYvalues(totalVolumetricMassTransferRate[1][p][0], + * ("total liq Volumetric Mass Transfer " + comp + p), "sec"); + * file.setYvalues(effectiveMassTransferCoefficient[0][p][0], ("eff. masstransfer coef gas " + + * comp + p), "sec"); file.setYvalues(effectiveMassTransferCoefficient[1][p][0], + * ("eff. masstransfer coef liq " + comp + p), "sec"); file.setYvalues(schmidtNumber[0][p][0], + * ("gas scmidtnumber " + comp + p), "-"); file.setYvalues(schmidtNumber[1][p][0], + * ("liquid scmidtnumber " + comp + p), "-"); } // file.setYvalues(temperaturePoint[0][0], + * "time","sec"); file.createFile(); } + */ } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/OnePhasePipeLine.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/OnePhasePipeLine.java index 21f0ba4626..12d2ad2d7a 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/OnePhasePipeLine.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/OnePhasePipeLine.java @@ -17,69 +17,68 @@ * @version $Id: $Id */ public class OnePhasePipeLine extends Pipeline { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for OnePhasePipeLine. - *

- */ - @Deprecated - public OnePhasePipeLine() { - this("OnePhasePipeLine"); - } + /** + *

+ * Constructor for OnePhasePipeLine. + *

+ */ + @Deprecated + public OnePhasePipeLine() { + this("OnePhasePipeLine"); + } - /** - *

- * Constructor for OnePhasePipeLine. - *

- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - public OnePhasePipeLine(StreamInterface inStream) { - this("OnePhasePipeLine", inStream); - } + /** + *

+ * Constructor for OnePhasePipeLine. + *

+ * + * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + */ + public OnePhasePipeLine(StreamInterface inStream) { + this("OnePhasePipeLine", inStream); + } - /** - * Constructor for OnePhasePipeLine. - * - * @param name name of pipe - */ - public OnePhasePipeLine(String name) { - super(name); - } + /** + * Constructor for OnePhasePipeLine. + * + * @param name name of pipe + */ + public OnePhasePipeLine(String name) { + super(name); + } - /** - * Constructor for OnePhasePipeLine. - * - * @param name name of pipe - * @param inStream input stream - */ - public OnePhasePipeLine(String name, StreamInterface inStream) { - super(name, inStream); - pipe = new PipeFlowSystem(); - } + /** + * Constructor for OnePhasePipeLine. + * + * @param name name of pipe + * @param inStream input stream + */ + public OnePhasePipeLine(String name, StreamInterface inStream) { + super(name, inStream); + pipe = new PipeFlowSystem(); + } - /** - *

- * createSystem. - *

- */ - public void createSystem() {} + /** + *

+ * createSystem. + *

+ */ + public void createSystem() {} - /** {@inheritDoc} */ - @Override - public void run() { - super.run(); - pipe.solveSteadyState(10); - // pipe.print(); - // pipe.getDisplay().createNetCdfFile(fileName); - outStream.setThermoSystem(pipe.getNode(pipe.getTotalNumberOfNodes() - 1).getBulkSystem()); - } + /** {@inheritDoc} */ + @Override + public void run() { + super.run(); + pipe.solveSteadyState(10); + // pipe.print(); + outStream.setThermoSystem(pipe.getNode(pipe.getTotalNumberOfNodes() - 1).getBulkSystem()); + } - /** {@inheritDoc} */ - @Override - public void runTransient(double dt) { - super.runTransient(dt); - } + /** {@inheritDoc} */ + @Override + public void runTransient(double dt) { + super.runTransient(dt); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/Pipeline.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/Pipeline.java index 4b2ab5766a..9daef31934 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/Pipeline.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/Pipeline.java @@ -3,6 +3,7 @@ * * Created on 14. mars 2001, 22:30 */ + package neqsim.processSimulation.processEquipment.pipeline; import neqsim.fluidMechanics.flowSystem.FlowSystemInterface; @@ -22,320 +23,304 @@ * @version $Id: $Id */ public class Pipeline extends TwoPortEquipment implements PipeLineInterface { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - protected String fileName = "c:/test5.nc"; - protected FlowSystemInterface pipe; - protected SystemInterface system; - String flowPattern = "stratified"; - double[] times; - boolean equilibriumHeatTransfer = true, equilibriumMassTransfer = false; - // default variables - int numberOfLegs = 1, numberOfNodesInLeg = 30; - double[] legHeights = {0, 0};// ,0,0,0}; - double[] legPositions = {0.0, 1.0};// 10.0,20.0,30.0,40.0}; - double[] pipeDiameters = {0.1507588, 0.1507588};// , 1.207588, 1.207588, 1.207588}; - double[] outerTemperature = {278.0, 278.0};// , 278.0, 278.0, 278.0}; - double[] pipeWallRoughness = {1e-5, 1e-5};// , 1e-5, 1e-5, 1e-5}; - double[] outerHeatTransferCoeffs = {1e-5, 1e-5};// , 1e-5, 1e-5, 1e-5}; - double[] wallHeatTransferCoeffs = {1e-5, 1e-5};// , 1e-5, 1e-5, 1e-5}; + protected String fileName = "c:/test5.nc"; + protected FlowSystemInterface pipe; + protected SystemInterface system; + String flowPattern = "stratified"; + double[] times; + boolean equilibriumHeatTransfer = true, equilibriumMassTransfer = false; + // default variables + int numberOfLegs = 1, numberOfNodesInLeg = 30; + double[] legHeights = {0, 0}; // ,0,0,0}; + double[] legPositions = {0.0, 1.0}; // 10.0,20.0,30.0,40.0}; + double[] pipeDiameters = {0.1507588, 0.1507588}; // , 1.207588, 1.207588, 1.207588}; + double[] outerTemperature = {278.0, 278.0}; // , 278.0, 278.0, 278.0}; + double[] pipeWallRoughness = {1e-5, 1e-5}; // , 1e-5, 1e-5, 1e-5}; + double[] outerHeatTransferCoeffs = {1e-5, 1e-5}; // , 1e-5, 1e-5, 1e-5}; + double[] wallHeatTransferCoeffs = {1e-5, 1e-5}; // , 1e-5, 1e-5, 1e-5}; - /** - *

- * Constructor for Pipeline. - *

- */ - @Deprecated - public Pipeline() { - this("Pipeline"); - } + /** + *

+ * Constructor for Pipeline. + *

+ */ + @Deprecated + public Pipeline() { + this("Pipeline"); + } - /** - *

- * Constructor for Pipeline. - *

- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public Pipeline(StreamInterface inStream) { - this("Pipeline", inStream); - } + /** + *

+ * Constructor for Pipeline. + *

+ * + * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + @Deprecated + public Pipeline(StreamInterface inStream) { + this("Pipeline", inStream); + } - /** - *

- * Constructor for Pipeline. - *

- * - * @param name a {@link java.lang.String} object - */ - public Pipeline(String name) { - super(name); - } + /** + *

+ * Constructor for Pipeline. + *

+ * + * @param name a {@link java.lang.String} object + */ + public Pipeline(String name) { + super(name); + } - /** - *

- * Constructor for Pipeline. - *

- * - * @param name a {@link java.lang.String} object - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - public Pipeline(String name, StreamInterface inStream) { - super(name, inStream); - } + /** + *

+ * Constructor for Pipeline. + *

+ * + * @param name a {@link java.lang.String} object + * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public Pipeline(String name, StreamInterface inStream) { + super(name, inStream); + } - public PipelineMechanicalDesign getMechanicalDesign() { - return new PipelineMechanicalDesign(this); - } + public PipelineMechanicalDesign getMechanicalDesign() { + return new PipelineMechanicalDesign(this); + } - /** {@inheritDoc} */ - @Override - public void setOutputFileName(String name) { - this.fileName = name; - } + /** {@inheritDoc} */ + @Override + public void setOutputFileName(String name) { + this.fileName = name; + } - /** {@inheritDoc} */ - @Override - public void setNumberOfLegs(int number) { - this.numberOfLegs = number; - } + /** {@inheritDoc} */ + @Override + public void setNumberOfLegs(int number) { + this.numberOfLegs = number; + } - /** {@inheritDoc} */ - @Override - public void setNumberOfNodesInLeg(int number) { - this.numberOfNodesInLeg = number; - } + /** {@inheritDoc} */ + @Override + public void setNumberOfNodesInLeg(int number) { + this.numberOfNodesInLeg = number; + } - /** {@inheritDoc} */ - @Override - public void setHeightProfile(double[] heights) { - if (heights.length != this.numberOfLegs + 1) { - System.out.println("Wrong number of heights specified."); - System.out.println("Number of heights must be number of legs + 1 "); - System.out.println( - "Remember to specify number of legs first (default 5) - than set the leg heights (default 6)."); - return; - } - legHeights = new double[heights.length]; - System.arraycopy(heights, 0, legHeights, 0, legHeights.length); + /** {@inheritDoc} */ + @Override + public void setHeightProfile(double[] heights) { + if (heights.length != this.numberOfLegs + 1) { + System.out.println("Wrong number of heights specified."); + System.out.println("Number of heights must be number of legs + 1 "); + return; } + legHeights = new double[heights.length]; + System.arraycopy(heights, 0, legHeights, 0, legHeights.length); + } - /** {@inheritDoc} */ - @Override - public void setLegPositions(double[] positions) { - if (positions.length != this.numberOfLegs + 1) { - System.out.println("Wrong number of legpositions specified."); - System.out.println("Number of heights must be number of legs + 1 "); - System.out.println( - "Remember to specify number of legs first (default 5) - than set the leg heights (default 6)."); - return; - } - legPositions = new double[positions.length]; - System.arraycopy(positions, 0, legPositions, 0, legPositions.length); + /** {@inheritDoc} */ + @Override + public void setLegPositions(double[] positions) { + if (positions.length != this.numberOfLegs + 1) { + System.out.println("Wrong number of legpositions specified."); + System.out.println("Number of heights must be number of legs + 1 "); + return; } + legPositions = new double[positions.length]; + System.arraycopy(positions, 0, legPositions, 0, legPositions.length); + } - /** {@inheritDoc} */ - @Override - public void setPipeDiameters(double[] diameter) { - if (diameter.length != this.numberOfLegs + 1) { - System.out.println("Wrong number of diameters specified."); - System.out.println("Number of diameters must be number of legs + 1 "); - System.out.println( - "Remember to specify number of legs first (default 5) - than set the leg heights (default 6)."); - return; - } - pipeDiameters = new double[diameter.length]; - System.arraycopy(diameter, 0, pipeDiameters, 0, pipeDiameters.length); + /** {@inheritDoc} */ + @Override + public void setPipeDiameters(double[] diameter) { + if (diameter.length != this.numberOfLegs + 1) { + System.out.println("Wrong number of diameters specified."); + System.out.println("Number of diameters must be number of legs + 1 "); + return; } + pipeDiameters = new double[diameter.length]; + System.arraycopy(diameter, 0, pipeDiameters, 0, pipeDiameters.length); + } - /** - *

- * setPipeOuterHeatTransferCoefficients. - *

- * - * @param heatCoefs an array of {@link double} objects - */ - public void setPipeOuterHeatTransferCoefficients(double[] heatCoefs) { - if (heatCoefs.length != this.numberOfLegs + 1) { - System.out.println("Wrong number of diameters specified."); - System.out.println("Number of diameters must be number of legs + 1 "); - System.out.println( - "Remember to specify number of legs first (default 5) - than set the leg heights (default 6)."); - return; - } - outerHeatTransferCoeffs = new double[heatCoefs.length]; - System.arraycopy(heatCoefs, 0, outerHeatTransferCoeffs, 0, outerHeatTransferCoeffs.length); + /** + *

+ * setPipeOuterHeatTransferCoefficients. + *

+ * + * @param heatCoefs an array of {@link double} objects + */ + public void setPipeOuterHeatTransferCoefficients(double[] heatCoefs) { + if (heatCoefs.length != this.numberOfLegs + 1) { + System.out.println("Wrong number of diameters specified."); + System.out.println("Number of diameters must be number of legs + 1 "); + return; } + outerHeatTransferCoeffs = new double[heatCoefs.length]; + System.arraycopy(heatCoefs, 0, outerHeatTransferCoeffs, 0, outerHeatTransferCoeffs.length); + } - /** - *

- * setPipeWallHeatTransferCoefficients. - *

- * - * @param heatCoefs an array of {@link double} objects - */ - public void setPipeWallHeatTransferCoefficients(double[] heatCoefs) { - if (heatCoefs.length != this.numberOfLegs + 1) { - System.out.println("Wrong number of diameters specified."); - System.out.println("Number of diameters must be number of legs + 1 "); - System.out.println( - "Remember to specify number of legs first (default 5) - than set the leg heights (default 6)."); - return; - } - wallHeatTransferCoeffs = new double[heatCoefs.length]; - System.arraycopy(heatCoefs, 0, wallHeatTransferCoeffs, 0, wallHeatTransferCoeffs.length); + /** + *

+ * setPipeWallHeatTransferCoefficients. + *

+ * + * @param heatCoefs an array of {@link double} objects + */ + public void setPipeWallHeatTransferCoefficients(double[] heatCoefs) { + if (heatCoefs.length != this.numberOfLegs + 1) { + System.out.println("Wrong number of diameters specified."); + System.out.println("Number of diameters must be number of legs + 1 "); + return; } + wallHeatTransferCoeffs = new double[heatCoefs.length]; + System.arraycopy(heatCoefs, 0, wallHeatTransferCoeffs, 0, wallHeatTransferCoeffs.length); + } - /** {@inheritDoc} */ - @Override - public void setPipeWallRoughness(double[] rough) { - if (rough.length != this.numberOfLegs + 1) { - System.out.println("Wrong number of roghuness points specified."); - System.out.println("Number of heights must be number of legs + 1 "); - System.out.println( - "Remember to specify number of legs first (default 5) - than set the leg heights (default 6)."); - return; - } - pipeWallRoughness = new double[rough.length]; - System.arraycopy(rough, 0, pipeWallRoughness, 0, pipeWallRoughness.length); + /** {@inheritDoc} */ + @Override + public void setPipeWallRoughness(double[] rough) { + if (rough.length != this.numberOfLegs + 1) { + System.out.println("Wrong number of roghuness points specified."); + System.out.println("Number of heights must be number of legs + 1 "); + return; } + pipeWallRoughness = new double[rough.length]; + System.arraycopy(rough, 0, pipeWallRoughness, 0, pipeWallRoughness.length); + } - /** {@inheritDoc} */ - @Override - public void setOuterTemperatures(double[] outerTemp) { - if (outerTemp.length != this.numberOfLegs + 1) { - System.out.println("Wrong number of outer temperature points specified."); - System.out.println("Number of heights must be number of legs + 1 "); - System.out.println( - "Remember to specify number of legs first (default 5) - than set the leg heights (default 6)."); - return; - } - outerTemperature = new double[outerTemp.length]; - System.arraycopy(outerTemp, 0, outerTemperature, 0, outerTemperature.length); + /** {@inheritDoc} */ + @Override + public void setOuterTemperatures(double[] outerTemp) { + if (outerTemp.length != this.numberOfLegs + 1) { + System.out.println("Wrong number of outer temperature points specified."); + System.out.println("Number of heights must be number of legs + 1 "); + return; } + outerTemperature = new double[outerTemp.length]; + System.arraycopy(outerTemp, 0, outerTemperature, 0, outerTemperature.length); + } - /** - *

- * Setter for the field equilibriumMassTransfer. - *

- * - * @param test a boolean - */ - public void setEquilibriumMassTransfer(boolean test) { - equilibriumMassTransfer = test; - } + /** + *

+ * Setter for the field equilibriumMassTransfer. + *

+ * + * @param test a boolean + */ + public void setEquilibriumMassTransfer(boolean test) { + equilibriumMassTransfer = test; + } - /** - *

- * Setter for the field equilibriumHeatTransfer. - *

- * - * @param test a boolean - */ - public void setEquilibriumHeatTransfer(boolean test) { - equilibriumHeatTransfer = test; - } + /** + *

+ * Setter for the field equilibriumHeatTransfer. + *

+ * + * @param test a boolean + */ + public void setEquilibriumHeatTransfer(boolean test) { + equilibriumHeatTransfer = test; + } - /** {@inheritDoc} */ - @Override - public void run() { - system = inStream.getThermoSystem(); - GeometryDefinitionInterface[] pipeGemometry = new PipeData[numberOfLegs + 1]; - for (int i = 0; i < pipeDiameters.length; i++) { - pipeGemometry[i] = new PipeData(pipeDiameters[i], pipeWallRoughness[i]); - } - pipe.setInletThermoSystem(system); - pipe.setNumberOfLegs(numberOfLegs); - pipe.setNumberOfNodesInLeg(numberOfNodesInLeg); - pipe.setEquipmentGeometry(pipeGemometry); - pipe.setLegOuterTemperatures(outerTemperature); - pipe.setLegHeights(legHeights); - pipe.setLegOuterHeatTransferCoefficients(outerHeatTransferCoeffs); - pipe.setLegWallHeatTransferCoefficients(wallHeatTransferCoeffs); - pipe.setLegPositions(legPositions); - pipe.setInitialFlowPattern(flowPattern); - pipe.createSystem(); - pipe.setEquilibriumMassTransfer(equilibriumMassTransfer); - pipe.setEquilibriumHeatTransfer(equilibriumHeatTransfer); - pipe.init(); + /** {@inheritDoc} */ + @Override + public void run() { + system = inStream.getThermoSystem(); + GeometryDefinitionInterface[] pipeGemometry = new PipeData[numberOfLegs + 1]; + for (int i = 0; i < pipeDiameters.length; i++) { + pipeGemometry[i] = new PipeData(pipeDiameters[i], pipeWallRoughness[i]); } + pipe.setInletThermoSystem(system); + pipe.setNumberOfLegs(numberOfLegs); + pipe.setNumberOfNodesInLeg(numberOfNodesInLeg); + pipe.setEquipmentGeometry(pipeGemometry); + pipe.setLegOuterTemperatures(outerTemperature); + pipe.setLegHeights(legHeights); + pipe.setLegOuterHeatTransferCoefficients(outerHeatTransferCoeffs); + pipe.setLegWallHeatTransferCoefficients(wallHeatTransferCoeffs); + pipe.setLegPositions(legPositions); + pipe.setInitialFlowPattern(flowPattern); + pipe.createSystem(); + pipe.setEquilibriumMassTransfer(equilibriumMassTransfer); + pipe.setEquilibriumHeatTransfer(equilibriumHeatTransfer); + pipe.init(); + } - /** {@inheritDoc} */ - @Override - public void runTransient(double dt) { - pipe.solveTransient(2); - pipe.getDisplay().createNetCdfFile(fileName); - } + /** {@inheritDoc} */ + @Override + public void runTransient(double dt) { + pipe.solveTransient(2); + } - /** {@inheritDoc} */ - @Override - public void displayResult() {} + /** {@inheritDoc} */ + @Override + public void displayResult() {} - /** {@inheritDoc} */ - @Override - public FlowSystemInterface getPipe() { - return pipe; - } + /** {@inheritDoc} */ + @Override + public FlowSystemInterface getPipe() { + return pipe; + } - /** {@inheritDoc} */ - @Override - public void setInitialFlowPattern(String flowPattern) { - this.flowPattern = flowPattern; - } + /** {@inheritDoc} */ + @Override + public void setInitialFlowPattern(String flowPattern) { + this.flowPattern = flowPattern; + } - /** - * Getter for property times. - * - * @return Value of property times. - */ - public double[] getTimes() { - return this.times; - } + /** + * Getter for property times. + * + * @return Value of property times. + */ + public double[] getTimes() { + return this.times; + } - /** - *

- * getSuperficialVelocity. - *

- * - * @param phase a int - * @param node a int - * @return a double - */ - public double getSuperficialVelocity(int phase, int node) { - try { - return outStream.getThermoSystem().getPhase(phase).getNumberOfMolesInPhase() - * outStream.getThermoSystem().getPhase(phase).getMolarMass() - / outStream.getThermoSystem().getPhase(phase).getPhysicalProperties() - .getDensity() - / (3.14 * pipeDiameters[node] * pipeDiameters[node] / 4.0); - } catch (Exception e) { - e.printStackTrace(); - } finally { - } - return 0.0; + /** + *

+ * getSuperficialVelocity. + *

+ * + * @param phase a int + * @param node a int + * @return a double + */ + public double getSuperficialVelocity(int phase, int node) { + try { + return outStream.getThermoSystem().getPhase(phase).getNumberOfMolesInPhase() + * outStream.getThermoSystem().getPhase(phase).getMolarMass() + / outStream.getThermoSystem().getPhase(phase).getPhysicalProperties().getDensity() + / (3.14 * pipeDiameters[node] * pipeDiameters[node] / 4.0); + } catch (Exception e) { + e.printStackTrace(); + } finally { } + return 0.0; + } - /** - * Setter for property times. - * - * @param times New value of property times. - * @param systems an array of {@link neqsim.thermo.system.SystemInterface} objects - * @param timestepininterval a int - */ - public void setTimeSeries(double[] times, SystemInterface[] systems, int timestepininterval) { - this.times = times; - pipe.getTimeSeries().setTimes(times); - pipe.getTimeSeries().setInletThermoSystems(systems); - pipe.getTimeSeries().setNumberOfTimeStepsInInterval(timestepininterval); - } + /** + * Setter for property times. + * + * @param times New value of property times. + * @param systems an array of {@link neqsim.thermo.system.SystemInterface} objects + * @param timestepininterval a int + */ + public void setTimeSeries(double[] times, SystemInterface[] systems, int timestepininterval) { + this.times = times; + pipe.getTimeSeries().setTimes(times); + pipe.getTimeSeries().setInletThermoSystems(systems); + pipe.getTimeSeries().setNumberOfTimeStepsInInterval(timestepininterval); + } - /** {@inheritDoc} */ - @Override - public double getEntropyProduction(String unit) { - return outStream.getThermoSystem().getEntropy(unit) - - inStream.getThermoSystem().getEntropy(unit); - } + /** {@inheritDoc} */ + @Override + public double getEntropyProduction(String unit) { + return outStream.getThermoSystem().getEntropy(unit) + - inStream.getThermoSystem().getEntropy(unit); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/TwoPhasePipeLine.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/TwoPhasePipeLine.java index 6f4602c9fc..e5baf3cc26 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/TwoPhasePipeLine.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/TwoPhasePipeLine.java @@ -17,65 +17,64 @@ * @version $Id: $Id */ public class TwoPhasePipeLine extends Pipeline { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for TwoPhasePipeLine. - *

- */ - @Deprecated - public TwoPhasePipeLine() { - this("TwoPhasePipeLine"); - } + /** + *

+ * Constructor for TwoPhasePipeLine. + *

+ */ + @Deprecated + public TwoPhasePipeLine() { + this("TwoPhasePipeLine"); + } - /** - *

- * Constructor for TwoPhasePipeLine. - *

- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - @Deprecated - public TwoPhasePipeLine(StreamInterface inStream) { - this("TwoPhasePipeLine", inStream); - } + /** + *

+ * Constructor for TwoPhasePipeLine. + *

+ * + * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + */ + @Deprecated + public TwoPhasePipeLine(StreamInterface inStream) { + this("TwoPhasePipeLine", inStream); + } - /** - * Constructor for TwoPhasePipeLine. - * - * @param name name of pipeline - */ - public TwoPhasePipeLine(String name) { - super(name); - } + /** + * Constructor for TwoPhasePipeLine. + * + * @param name name of pipeline + */ + public TwoPhasePipeLine(String name) { + super(name); + } - /** - *

- * Constructor for TwoPhasePipeLine. - *

- * - * @param name a {@link java.lang.String} object - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - public TwoPhasePipeLine(String name, StreamInterface inStream) { - super(name, inStream); - pipe = new TwoPhasePipeFlowSystem(); - } + /** + *

+ * Constructor for TwoPhasePipeLine. + *

+ * + * @param name a {@link java.lang.String} object + * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + */ + public TwoPhasePipeLine(String name, StreamInterface inStream) { + super(name, inStream); + pipe = new TwoPhasePipeFlowSystem(); + } - /** - *

- * createSystem. - *

- */ - public void createSystem() {} + /** + *

+ * createSystem. + *

+ */ + public void createSystem() {} - /** {@inheritDoc} */ - @Override - public void run() { - super.run(); - pipe.solveSteadyState(2); - pipe.print(); - pipe.getDisplay().createNetCdfFile(fileName); - } + /** {@inheritDoc} */ + @Override + public void run() { + super.run(); + pipe.solveSteadyState(2); + pipe.print(); + } } diff --git a/src/main/java/neqsim/statistics/parameterFitting/StatisticsInterface.java b/src/main/java/neqsim/statistics/parameterFitting/StatisticsInterface.java index ca6ac8f765..d21b3cd739 100644 --- a/src/main/java/neqsim/statistics/parameterFitting/StatisticsInterface.java +++ b/src/main/java/neqsim/statistics/parameterFitting/StatisticsInterface.java @@ -14,94 +14,85 @@ * @version $Id: $Id */ public interface StatisticsInterface { - /** - *

- * createNewRandomClass. - *

- * - * @return a {@link neqsim.statistics.parameterFitting.StatisticsBaseClass} object - */ - public StatisticsBaseClass createNewRandomClass(); + /** + *

+ * createNewRandomClass. + *

+ * + * @return a {@link neqsim.statistics.parameterFitting.StatisticsBaseClass} object + */ + public StatisticsBaseClass createNewRandomClass(); - /** - *

- * solve. - *

- */ - public void solve(); + /** + *

+ * solve. + *

+ */ + public void solve(); - /** - *

- * init. - *

- */ - public void init(); + /** + *

+ * init. + *

+ */ + public void init(); - /** - *

- * getSampleSet. - *

- * - * @return a {@link neqsim.statistics.parameterFitting.SampleSet} object - */ - public SampleSet getSampleSet(); + /** + *

+ * getSampleSet. + *

+ * + * @return a {@link neqsim.statistics.parameterFitting.SampleSet} object + */ + public SampleSet getSampleSet(); - /** - *

- * displayResult. - *

- */ - public void displayResult(); + /** + *

+ * displayResult. + *

+ */ + public void displayResult(); - /** - *

- * displayCurveFit. - *

- */ - public void displayCurveFit(); + /** + *

+ * displayCurveFit. + *

+ */ + public void displayCurveFit(); - /** - *

- * writeToTextFile. - *

- * - * @param name a {@link java.lang.String} object - */ - public void writeToTextFile(String name); + /** + *

+ * writeToTextFile. + *

+ * + * @param name a {@link java.lang.String} object + */ + public void writeToTextFile(String name); - /** - *

- * writeToCdfFile. - *

- * - * @param name a {@link java.lang.String} object - */ - //public void writeToCdfFile(String name); + /** + *

+ * getNumberOfTuningParameters. + *

+ * + * @return a int + */ + public int getNumberOfTuningParameters(); - /** - *

- * getNumberOfTuningParameters. - *

- * - * @return a int - */ - public int getNumberOfTuningParameters(); + /** + *

+ * setNumberOfTuningParameters. + *

+ * + * @param numberOfTuningParameters a int + */ + public void setNumberOfTuningParameters(int numberOfTuningParameters); - /** - *

- * setNumberOfTuningParameters. - *

- * - * @param numberOfTuningParameters a int - */ - public void setNumberOfTuningParameters(int numberOfTuningParameters); - - /** - *

- * runMonteCarloSimulation. - *

- * - * @param numberOfRuns a int - */ - public void runMonteCarloSimulation(int numberOfRuns); + /** + *

+ * runMonteCarloSimulation. + *

+ * + * @param numberOfRuns a int + */ + public void runMonteCarloSimulation(int numberOfRuns); } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/Procede/CH4CO2WaterMDEA/TestIonicInteractionParameterFittingCH4.java b/src/main/java/neqsim/thermo/util/parameterFitting/Procede/CH4CO2WaterMDEA/TestIonicInteractionParameterFittingCH4.java index 6365a16361..b37ddd59ca 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/Procede/CH4CO2WaterMDEA/TestIonicInteractionParameterFittingCH4.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/Procede/CH4CO2WaterMDEA/TestIonicInteractionParameterFittingCH4.java @@ -12,103 +12,105 @@ import neqsim.util.database.NeqSimDataBase; /** - *

TestIonicInteractionParameterFittingCH4 class.

+ *

+ * TestIonicInteractionParameterFittingCH4 class. + *

* * @author Even Solbraa * @version $Id: $Id */ public class TestIonicInteractionParameterFittingCH4 { - static Logger logger = LogManager.getLogger(TestIonicInteractionParameterFittingCH4.class); - - /** - *

main.

- * - * @param args an array of {@link java.lang.String} objects - */ - @SuppressWarnings("unused") - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); - - // inserting samples from database - NeqSimDataBase database = new NeqSimDataBase(); - ResultSet dataSet = database.getResultSet("SELECT * FROM CO2CH4MDEA"); - - double ID, x1, x2, x3, x4, y1, y2, y3, y4, temperature, pressure, loading; - - // double guess[] = {0.0005447481}; //Case I - // double guess[] = {0.0004929757}; //Case II - double guess[] = {0.0004929757, 1e-10}; // Case II and CO2-CH4 parameter also regressed - - try { - int i = 0; - logger.info("adding...."); - while (dataSet.next()) { - i++; - IonicInteractionParameterFittingFunctionCH4 function = - new IonicInteractionParameterFittingFunctionCH4(); - IonicInteractionParameterFittingFunctionCH4 function1 = - new IonicInteractionParameterFittingFunctionCH4(1, 1); - - ID = Integer.parseInt(dataSet.getString("ID")); - pressure = Double.parseDouble(dataSet.getString("Pressure")); - temperature = Double.parseDouble(dataSet.getString("Temperature")); - x1 = Double.parseDouble(dataSet.getString("x1")); - x2 = Double.parseDouble(dataSet.getString("x2")); - x3 = Double.parseDouble(dataSet.getString("x3")); - x4 = Double.parseDouble(dataSet.getString("x4")); - y1 = Double.parseDouble(dataSet.getString("y1")); - y2 = Double.parseDouble(dataSet.getString("y2")); - y3 = Double.parseDouble(dataSet.getString("y3")); - y4 = Double.parseDouble(dataSet.getString("y4")); - - loading = x2 / x4; - - SystemInterface testSystem = new SystemFurstElectrolyteEos(temperature, pressure); - testSystem.addComponent("methane", x1); - testSystem.addComponent("CO2", x2); - testSystem.addComponent("MDEA", x4); - testSystem.addComponent("water", x3); - - testSystem.chemicalReactionInit(); - testSystem.createDatabase(true); - testSystem.setMixingRule(4); - testSystem.init(0); - - double sample1[] = {loading}; - double standardDeviation1[] = {0.01}; - SampleValue sample = - new SampleValue(pressure, pressure / 100.0, sample1, standardDeviation1); - function.setInitialGuess(guess); - sample.setFunction(function); - sample.setReference("addicks"); - sample.setDescription(Double.toString(ID)); - sample.setThermodynamicSystem(testSystem); - sampleList.add(sample); - - double sample2[] = {loading}; - double standardDeviation2[] = {0.01}; - SampleValue sample3 = new SampleValue(pressure * y2, y2 * pressure / 100.0, sample2, - standardDeviation2); - function1.setInitialGuess(guess); - sample3.setFunction(function1); - sample3.setReference("addicks"); - sample3.setDescription(Double.toString(ID)); - sample3.setThermodynamicSystem(testSystem); - sampleList.add(sample3); - } - } catch (Exception e) { - logger.error("database error" + e); - } - - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + static Logger logger = LogManager.getLogger(TestIonicInteractionParameterFittingCH4.class); + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); + + // inserting samples from database + NeqSimDataBase database = new NeqSimDataBase(); + ResultSet dataSet = database.getResultSet("SELECT * FROM CO2CH4MDEA"); + + double ID, x1, x2, x3, x4, y1, y2, y3, y4, temperature, pressure, loading; + + // double guess[] = {0.0005447481}; //Case I + // double guess[] = {0.0004929757}; //Case II + double guess[] = {0.0004929757, 1e-10}; // Case II and CO2-CH4 parameter also regressed + + try { + int i = 0; + logger.info("adding...."); + while (dataSet.next()) { + i++; + IonicInteractionParameterFittingFunctionCH4 function = + new IonicInteractionParameterFittingFunctionCH4(); + IonicInteractionParameterFittingFunctionCH4 function1 = + new IonicInteractionParameterFittingFunctionCH4(1, 1); + + ID = Integer.parseInt(dataSet.getString("ID")); + pressure = Double.parseDouble(dataSet.getString("Pressure")); + temperature = Double.parseDouble(dataSet.getString("Temperature")); + x1 = Double.parseDouble(dataSet.getString("x1")); + x2 = Double.parseDouble(dataSet.getString("x2")); + x3 = Double.parseDouble(dataSet.getString("x3")); + x4 = Double.parseDouble(dataSet.getString("x4")); + y1 = Double.parseDouble(dataSet.getString("y1")); + y2 = Double.parseDouble(dataSet.getString("y2")); + y3 = Double.parseDouble(dataSet.getString("y3")); + y4 = Double.parseDouble(dataSet.getString("y4")); + + loading = x2 / x4; + + SystemInterface testSystem = new SystemFurstElectrolyteEos(temperature, pressure); + testSystem.addComponent("methane", x1); + testSystem.addComponent("CO2", x2); + testSystem.addComponent("MDEA", x4); + testSystem.addComponent("water", x3); + + testSystem.chemicalReactionInit(); + testSystem.createDatabase(true); + testSystem.setMixingRule(4); + testSystem.init(0); + + double sample1[] = {loading}; + double standardDeviation1[] = {0.01}; + SampleValue sample = + new SampleValue(pressure, pressure / 100.0, sample1, standardDeviation1); + function.setInitialGuess(guess); + sample.setFunction(function); + sample.setReference("addicks"); + sample.setDescription(Double.toString(ID)); + sample.setThermodynamicSystem(testSystem); + sampleList.add(sample); + + double sample2[] = {loading}; + double standardDeviation2[] = {0.01}; + SampleValue sample3 = + new SampleValue(pressure * y2, y2 * pressure / 100.0, sample2, standardDeviation2); + function1.setInitialGuess(guess); + sample3.setFunction(function1); + sample3.setReference("addicks"); + sample3.setDescription(Double.toString(ID)); + sample3.setThermodynamicSystem(testSystem); + sampleList.add(sample3); + } + } catch (Exception e) { + logger.error("database error" + e); + } - // do simulations + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); - optim.solve(); - optim.displayCurveFit(); - // optim.writeToCdfFile("c:/testFit.nc"); - // optim.writeToTextFile("c:/testFit.txt"); - } + // do simulations + optim.solve(); + optim.displayCurveFit(); + // optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityData.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityData.java index 0626c45c04..a38f95d3dd 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityData.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityData.java @@ -20,98 +20,96 @@ * @version $Id: $Id */ public class TestCPAParameterFittingToSolubilityData { - static Logger logger = LogManager.getLogger(TestCPAParameterFittingToSolubilityData.class); + static Logger logger = LogManager.getLogger(TestCPAParameterFittingToSolubilityData.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); - // inserting samples from database - NeqSimExperimentDatabase database = new NeqSimExperimentDatabase(); - ResultSet dataSet = database.getResultSet( - "SELECT * FROM binarySolubilityData WHERE ComponentSolute='CO2' AND ComponentSolvent='water' AND Reference='Houghton1957' AND Reference<>'Nighswander1989' AND Temperature>283.15 AND Temperature<373.15 AND Pressure<60.01325 ORDER BY Temperature"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM - // binarysolubilitydata WHERE ComponentSolute='methane' AND - // ComponentSolvent='water' AND Temperature>278.0 AND Temperature<350.0"); - double parameterGuess[] = {-0.27686, 0.001121};// , 0.000117974}; //cpa + // inserting samples from database + NeqSimExperimentDatabase database = new NeqSimExperimentDatabase(); + ResultSet dataSet = database.getResultSet( + "SELECT * FROM binarySolubilityData WHERE ComponentSolute='CO2' AND ComponentSolvent='water' AND Reference='Houghton1957' AND Reference<>'Nighswander1989' AND Temperature>283.15 AND Temperature<373.15 AND Pressure<60.01325 ORDER BY Temperature"); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM + // binarysolubilitydata WHERE ComponentSolute='methane' AND + // ComponentSolvent='water' AND Temperature>278.0 AND Temperature<350.0"); + double parameterGuess[] = {-0.27686, 0.001121};// , 0.000117974}; //cpa - try { - int p = 0; - logger.info("adding...."); - while (dataSet.next() && p < 200) { - p++; - CPAParameterFittingToSolubilityData function = - new CPAParameterFittingToSolubilityData(1, 0); + try { + int p = 0; + logger.info("adding...."); + while (dataSet.next() && p < 200) { + p++; + CPAParameterFittingToSolubilityData function = + new CPAParameterFittingToSolubilityData(1, 0); - SystemInterface testSystem = new SystemSrkCPAstatoil(290, 1.0); - // SystemInterface testSystem = new SystemSrkEos(290, 1.0); - testSystem.addComponent("CO2", 1.0); - testSystem.addComponent("water", 10.0); - testSystem.createDatabase(true); - testSystem.setMixingRule(10); - testSystem.setMultiPhaseCheck(true); - testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); - testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); + SystemInterface testSystem = new SystemSrkCPAstatoil(290, 1.0); + // SystemInterface testSystem = new SystemSrkEos(290, 1.0); + testSystem.addComponent("CO2", 1.0); + testSystem.addComponent("water", 10.0); + testSystem.createDatabase(true); + testSystem.setMixingRule(10); + testSystem.setMultiPhaseCheck(true); + testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); + testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); - testSystem.init(0); - double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; - double standardDeviation1[] = {0.13, 0.12}; - double expVal = Double.parseDouble(dataSet.getString("x1")); - SampleValue sample = new SampleValue(expVal, - Double.parseDouble(dataSet.getString("StandardDeviation")), sample1, - standardDeviation1); - function.setInitialGuess(parameterGuess); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(Double.toString(testSystem.getTemperature())); - // double parameterGuess[] = {-0.130}; //srk - // double parameterGuess[] = {-0.0668706940}; //cpa - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } - /* - * - * dataSet = database.getResultSet( - * "SELECT * FROM BinaryEquilibriumData WHERE Component1='methane' AND Component2='MEG'" ); - * try { int p = 0; logger.info("adding...."); while (!dataSet.next() && p < 0) { p++; - * CPAParameterFittingToSolubilityData function = new - * CPAParameterFittingToSolubilityData(0,1); - * - * SystemInterface testSystem = new SystemSrkCPAstatoil(290, 1.0); //SystemInterface - * testSystem = new SystemSrkEos(290, 1.0); testSystem.addComponent("methane", 1.0); - * testSystem.addComponent("MEG", 1.0); //testSystem.createDatabase(true); - * testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature") )); - * testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); - * testSystem.setMixingRule(10); testSystem.init(0); double sample1[] = - * {testSystem.getPressure(), testSystem.getTemperature()}; double standardDeviation1[] = - * {0.13}; pressure double value = Double.parseDouble(dataSet.getString("y2")); SampleValue - * sample = new SampleValue(value, value/100.0, sample1, standardDeviation1); - * sample.setFunction(function); sample.setThermodynamicSystem(testSystem); - * sample.setReference(Double.toString(testSystem.getTemperature())); //double - * parameterGuess[] = {-0.130}; //srk // double parameterGuess[] = {-0.0668706940}; //cpa - * function.setInitialGuess(parameterGuess); sampleList.add(sample); } } catch (Exception e) - * { logger.error("database error" + e); } - */ + testSystem.init(0); + double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; + double standardDeviation1[] = {0.13, 0.12}; + double expVal = Double.parseDouble(dataSet.getString("x1")); + SampleValue sample = + new SampleValue(expVal, Double.parseDouble(dataSet.getString("StandardDeviation")), + sample1, standardDeviation1); + function.setInitialGuess(parameterGuess); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(Double.toString(testSystem.getTemperature())); + // double parameterGuess[] = {-0.130}; //srk + // double parameterGuess[] = {-0.0668706940}; //cpa + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } + /* + * + * dataSet = database.getResultSet( + * "SELECT * FROM BinaryEquilibriumData WHERE Component1='methane' AND Component2='MEG'" ); try + * { int p = 0; logger.info("adding...."); while (!dataSet.next() && p < 0) { p++; + * CPAParameterFittingToSolubilityData function = new CPAParameterFittingToSolubilityData(0,1); + * + * SystemInterface testSystem = new SystemSrkCPAstatoil(290, 1.0); //SystemInterface testSystem + * = new SystemSrkEos(290, 1.0); testSystem.addComponent("methane", 1.0); + * testSystem.addComponent("MEG", 1.0); //testSystem.createDatabase(true); + * testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature") )); + * testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); + * testSystem.setMixingRule(10); testSystem.init(0); double sample1[] = + * {testSystem.getPressure(), testSystem.getTemperature()}; double standardDeviation1[] = + * {0.13}; pressure double value = Double.parseDouble(dataSet.getString("y2")); SampleValue + * sample = new SampleValue(value, value/100.0, sample1, standardDeviation1); + * sample.setFunction(function); sample.setThermodynamicSystem(testSystem); + * sample.setReference(Double.toString(testSystem.getTemperature())); //double parameterGuess[] + * = {-0.130}; //srk // double parameterGuess[] = {-0.0668706940}; //cpa + * function.setInitialGuess(parameterGuess); sampleList.add(sample); } } catch (Exception e) { + * logger.error("database error" + e); } + */ - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); - // do simulations - // optim.solve(); - // optim.runMonteCarloSimulation(); - optim.calcDeviation(); - optim.displayResult(); - optim.displayCurveFit(); - // optim.writeToCdfFile("c:/testFit.nc"); - // optim.writeToTextFile("c:/testFit.txt"); - } + // do simulations + // optim.solve(); + // optim.runMonteCarloSimulation(); + optim.calcDeviation(); + optim.displayResult(); + optim.displayCurveFit(); + // optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityData_Lucia.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityData_Lucia.java index 6c6af6ab9f..78e2fabf28 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityData_Lucia.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityData_Lucia.java @@ -20,172 +20,169 @@ * @version $Id: $Id */ public class TestCPAParameterFittingToSolubilityData_Lucia { - static Logger logger = - LogManager.getLogger(TestCPAParameterFittingToSolubilityData_Lucia.class); + static Logger logger = LogManager.getLogger(TestCPAParameterFittingToSolubilityData_Lucia.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); - // inserting samples from database - NeqSimDataBase database = new NeqSimDataBase(); - ResultSet dataSet = database.getResultSet( - "SELECT * FROM luciadata8 WHERE Component='methane' AND Temperature>410.15 AND Pressure<100000000 AND L2<>NULL AND L2>0.00000001 ORDER BY Temperature,Pressure");// AND - // Reference='Houghton1957' - // AND - // Reference<>'Nighswander1989' - // AND - // Temperature>278.15 - // AND - // Temperature<383.15 - // AND - // Pressure<60.01325"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE - // Component='nitrogen' AND Temperature<390 AND L2<>NULL AND L2>0.0000000001 - // ORDER BY Temperature,Pressure"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE - // Component='CO2' AND Temperature<390 AND L2<>NULL AND L2>0.0000000001 ORDER BY - // Temperature,Pressure"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE - // Component='ethane' AND Temperature<390 AND Pressure<10000000 AND L2<>NULL AND - // L2>0.0000000001 ORDER BY Temperature,Pressure"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE - // Component='propane' AND Temperature<390 AND Pressure<15000000 AND L2<>NULL - // AND L2>0.0000000001 AND ID>2204 AND ID<2410 ORDER BY Temperature,Pressure"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM - // binarySolubilityData WHERE ComponentSolute='methane' AND - // ComponentSolvent='water'"); + // inserting samples from database + NeqSimDataBase database = new NeqSimDataBase(); + ResultSet dataSet = database.getResultSet( + "SELECT * FROM luciadata8 WHERE Component='methane' AND Temperature>410.15 AND Pressure<100000000 AND L2<>NULL AND L2>0.00000001 ORDER BY Temperature,Pressure");// AND + // Reference='Houghton1957' + // AND + // Reference<>'Nighswander1989' + // AND + // Temperature>278.15 + // AND + // Temperature<383.15 + // AND + // Pressure<60.01325"); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE + // Component='nitrogen' AND Temperature<390 AND L2<>NULL AND L2>0.0000000001 + // ORDER BY Temperature,Pressure"); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE + // Component='CO2' AND Temperature<390 AND L2<>NULL AND L2>0.0000000001 ORDER BY + // Temperature,Pressure"); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE + // Component='ethane' AND Temperature<390 AND Pressure<10000000 AND L2<>NULL AND + // L2>0.0000000001 ORDER BY Temperature,Pressure"); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE + // Component='propane' AND Temperature<390 AND Pressure<15000000 AND L2<>NULL + // AND L2>0.0000000001 AND ID>2204 AND ID<2410 ORDER BY Temperature,Pressure"); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM + // binarySolubilityData WHERE ComponentSolute='methane' AND + // ComponentSolvent='water'"); - try { - int p = 0; - logger.info("adding...."); - while (!dataSet.next() && p < 50) { - p++; - CPAParameterFittingToSolubilityData function = - new CPAParameterFittingToSolubilityData(); + try { + int p = 0; + logger.info("adding...."); + while (!dataSet.next() && p < 50) { + p++; + CPAParameterFittingToSolubilityData function = new CPAParameterFittingToSolubilityData(); - SystemInterface testSystem = - new SystemSrkCPA(Double.parseDouble(dataSet.getString("Temperature")), - Double.parseDouble(dataSet.getString("Pressure")) / 1.0e5); - // SystemInterface testSystem = new - // SystemSrkEos(Double.parseDouble(dataSet.getString("Temperature")), - // Double.parseDouble(dataSet.getString("Pressure"))/1.0e5); - testSystem.addComponent("methane", 1.0); - // testSystem.addComponent("propane", 1.0); - testSystem.addComponent("water", 10.0); - // testSystem.createDatabase(true); - testSystem.setMixingRule(7); - testSystem.init(0); - double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; - double standardDeviation1[] = {0.01}; - double val = Double.parseDouble(dataSet.getString("L2")); - double sdev = val / 100.0; - SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem);// 34.7 - sample.setReference(Double.toString(testSystem.getTemperature())); - // double parameterGuess[] = {0.05155112588}; //srk - double parameterGuess[] = {0.0459393339}; // cpa-srk- metan 23.658199 abs dev bias - // -6.267% - // double parameterGuess[] = {0.1592294845}; //cpa-pr - metan 21.9 - // double parameterGuess[] = {-0.059201934}; //cpa-srk - nitrogen - // double parameterGuess[] = {0.1}; - // double parameterGuess[] = {-0.059201934}; //cpa-pr - nitrogen 29.20534 abs - // bias 23.93392 - // double parameterGuess[] = {-0.0586254634}; //cpa-srk - CO2 abs 18.5043 bias - // -11.3665 - // double parameterGuess[] = {0.0160496243}; //cpa-pr - CO2 - // double parameterGuess[] = {0.13287685}; //srk + SystemInterface testSystem = + new SystemSrkCPA(Double.parseDouble(dataSet.getString("Temperature")), + Double.parseDouble(dataSet.getString("Pressure")) / 1.0e5); + // SystemInterface testSystem = new + // SystemSrkEos(Double.parseDouble(dataSet.getString("Temperature")), + // Double.parseDouble(dataSet.getString("Pressure"))/1.0e5); + testSystem.addComponent("methane", 1.0); + // testSystem.addComponent("propane", 1.0); + testSystem.addComponent("water", 10.0); + // testSystem.createDatabase(true); + testSystem.setMixingRule(7); + testSystem.init(0); + double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; + double standardDeviation1[] = {0.01}; + double val = Double.parseDouble(dataSet.getString("L2")); + double sdev = val / 100.0; + SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem);// 34.7 + sample.setReference(Double.toString(testSystem.getTemperature())); + // double parameterGuess[] = {0.05155112588}; //srk + double parameterGuess[] = {0.0459393339}; // cpa-srk- metan 23.658199 abs dev bias + // -6.267% + // double parameterGuess[] = {0.1592294845}; //cpa-pr - metan 21.9 + // double parameterGuess[] = {-0.059201934}; //cpa-srk - nitrogen + // double parameterGuess[] = {0.1}; + // double parameterGuess[] = {-0.059201934}; //cpa-pr - nitrogen 29.20534 abs + // bias 23.93392 + // double parameterGuess[] = {-0.0586254634}; //cpa-srk - CO2 abs 18.5043 bias + // -11.3665 + // double parameterGuess[] = {0.0160496243}; //cpa-pr - CO2 + // double parameterGuess[] = {0.13287685}; //srk - function.setInitialGuess(parameterGuess); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error", e); - } + function.setInitialGuess(parameterGuess); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error", e); + } - // dataSet = database.getResultSet( "SELECT * FROM LuciaData WHERE - // Component='methane' AND ID<3000 AND Temperature<380 AND Pressure<100000000 - // AND Y<>NULL AND Y>0.00000001 ORDER BY Temperature,Pressure");// AND - // Reference='Houghton1957' AND Reference<>'Nighswander1989' AND - // Temperature>278.15 AND Temperature<383.15 AND Pressure<60.01325"); - dataSet = database.getResultSet( - "SELECT * FROM LuciaData8 WHERE Component='methane' AND Temperature>273.15 AND Pressure<153000000 AND Y<>NULL AND Y>0.000000001 ORDER BY Temperature,Pressure"); - // dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE - // Component='nitrogen' AND Temperature<390 AND Y<>NULL AND Y>0.000000001 ORDER - // BY Temperature,Pressure"); - // dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE - // Component='CO2' AND Temperature>310 AND Y<>NULL AND Y>0.000000001 ORDER BY - // Temperature,Pressure"); - // dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE - // Component='ethane' AND Temperature<390 AND Pressure<10000000 AND Y<>NULL AND - // Y>0.000000001 ORDER BY Temperature,Pressure"); - // dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE - // Component='propane' AND Temperature<390 AND Pressure<15000000 AND Y<>NULL AND - // Y>0.000000001 AND ID>2204 AND ID<2410 ORDER BY Temperature,Pressure"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM - // binarySolubilityData WHERE ComponentSolute='methane' AND - // ComponentSolvent='water'"); - try { - int p = 0; - logger.info("adding...."); - while (dataSet.next() && p < 150) { - p++; - CPAParameterFittingToSolubilityData_Vap function = - new CPAParameterFittingToSolubilityData_Vap(); + // dataSet = database.getResultSet( "SELECT * FROM LuciaData WHERE + // Component='methane' AND ID<3000 AND Temperature<380 AND Pressure<100000000 + // AND Y<>NULL AND Y>0.00000001 ORDER BY Temperature,Pressure");// AND + // Reference='Houghton1957' AND Reference<>'Nighswander1989' AND + // Temperature>278.15 AND Temperature<383.15 AND Pressure<60.01325"); + dataSet = database.getResultSet( + "SELECT * FROM LuciaData8 WHERE Component='methane' AND Temperature>273.15 AND Pressure<153000000 AND Y<>NULL AND Y>0.000000001 ORDER BY Temperature,Pressure"); + // dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE + // Component='nitrogen' AND Temperature<390 AND Y<>NULL AND Y>0.000000001 ORDER + // BY Temperature,Pressure"); + // dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE + // Component='CO2' AND Temperature>310 AND Y<>NULL AND Y>0.000000001 ORDER BY + // Temperature,Pressure"); + // dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE + // Component='ethane' AND Temperature<390 AND Pressure<10000000 AND Y<>NULL AND + // Y>0.000000001 ORDER BY Temperature,Pressure"); + // dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE + // Component='propane' AND Temperature<390 AND Pressure<15000000 AND Y<>NULL AND + // Y>0.000000001 AND ID>2204 AND ID<2410 ORDER BY Temperature,Pressure"); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM + // binarySolubilityData WHERE ComponentSolute='methane' AND + // ComponentSolvent='water'"); + try { + int p = 0; + logger.info("adding...."); + while (dataSet.next() && p < 150) { + p++; + CPAParameterFittingToSolubilityData_Vap function = + new CPAParameterFittingToSolubilityData_Vap(); - SystemInterface testSystem = - new SystemSrkCPA(Double.parseDouble(dataSet.getString("Temperature")), - Double.parseDouble(dataSet.getString("Pressure")) / 1.0e5); - // SystemInterface testSystem = new - // SystemSrkEos(Double.parseDouble(dataSet.getString("Temperature")), - // Double.parseDouble(dataSet.getString("Pressure"))/1.0e5); - testSystem.addComponent("methane", 1.0); - // testSystem.addComponent("propane", 1.0); - testSystem.addComponent("water", 10.0); - // testSystem.createDatabase(true); - testSystem.init(0); - testSystem.setMixingRule(7); + SystemInterface testSystem = + new SystemSrkCPA(Double.parseDouble(dataSet.getString("Temperature")), + Double.parseDouble(dataSet.getString("Pressure")) / 1.0e5); + // SystemInterface testSystem = new + // SystemSrkEos(Double.parseDouble(dataSet.getString("Temperature")), + // Double.parseDouble(dataSet.getString("Pressure"))/1.0e5); + testSystem.addComponent("methane", 1.0); + // testSystem.addComponent("propane", 1.0); + testSystem.addComponent("water", 10.0); + // testSystem.createDatabase(true); + testSystem.init(0); + testSystem.setMixingRule(7); - double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; - double standardDeviation1[] = {0.01}; - double val = 1.0 - Double.parseDouble(dataSet.getString("Y")); - double sdev = val / 100.0; - SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(Double.toString(testSystem.getTemperature())); - // double parameterGuess[] = {0.0459393339}; //cpa-srk- metan 23.658199 abs dev - // bias -6.267% - double parameterGuess[] = {0.0459393339}; // cpa-pr - metan - // double parameterGuess[] = {-0.059201934}; //cpa-srk - nitrogen - // double parameterGuess[] = {0.1}; - // double parameterGuess[] = {0.2413992410}; //cpa-pr - nitrogen - // double parameterGuess[] = {-0.0586254634}; //cpa-srk - CO2 12.0 - // double parameterGuess[] = {0.0160496243}; //cpa-pr - CO2 - function.setInitialGuess(parameterGuess); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error", e); - } + double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; + double standardDeviation1[] = {0.01}; + double val = 1.0 - Double.parseDouble(dataSet.getString("Y")); + double sdev = val / 100.0; + SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(Double.toString(testSystem.getTemperature())); + // double parameterGuess[] = {0.0459393339}; //cpa-srk- metan 23.658199 abs dev + // bias -6.267% + double parameterGuess[] = {0.0459393339}; // cpa-pr - metan + // double parameterGuess[] = {-0.059201934}; //cpa-srk - nitrogen + // double parameterGuess[] = {0.1}; + // double parameterGuess[] = {0.2413992410}; //cpa-pr - nitrogen + // double parameterGuess[] = {-0.0586254634}; //cpa-srk - CO2 12.0 + // double parameterGuess[] = {0.0160496243}; //cpa-pr - CO2 + function.setInitialGuess(parameterGuess); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error", e); + } - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); - // do simulations - // optim.solve(); - // optim.runMonteCarloSimulation(); - // optim.displayResult(); - optim.displayCurveFit(); - //optim.writeToCdfFile("c:/testFit.nc"); - optim.writeToTextFile("c:/testFit.txt"); - } + // do simulations + // optim.solve(); + // optim.runMonteCarloSimulation(); + // optim.displayResult(); + optim.displayCurveFit(); + optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityGlycolHC.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityGlycolHC.java index 9f5ec66852..06db3d4f1e 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityGlycolHC.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityGlycolHC.java @@ -20,120 +20,118 @@ * @version $Id: $Id */ public class TestCPAParameterFittingToSolubilityGlycolHC { - static Logger logger = LogManager.getLogger(TestCPAParameterFittingToSolubilityGlycolHC.class); + static Logger logger = LogManager.getLogger(TestCPAParameterFittingToSolubilityGlycolHC.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); - // inserting samples from database - NeqSimDataBase database = new NeqSimDataBase();// AND reference<>'Lindboe2002' - ResultSet dataSet = database.getResultSet( - "SELECT * FROM hcglycollldata WHERE comp1='n-heptane' AND comp2='MEG' AND reference='Lindboe2002' ORDER BY Temperature,Pressure");// AND - // Reference='Houghton1957' - // AND - // Reference<>'Nighswander1989' - // AND - // Temperature>278.15 - // AND - // Temperature<383.15 - // AND - // Pressure<60.01325"); - // double parameterGuess[] = {0.0471326591, 5.14, 10.819, 0.6744, 0.0141}; - // double parameterGuess[] = {0.0602997387, 5.2137117933, 10.3039876875, - // 0.6714377099, 0.0178639622}; // fitted to all data - double parameterGuess[] = {1924, 4938};// , -1.11, 1.24}; - // double parameterGuess[] = {0.0471326591}; + // inserting samples from database + NeqSimDataBase database = new NeqSimDataBase();// AND reference<>'Lindboe2002' + ResultSet dataSet = database.getResultSet( + "SELECT * FROM hcglycollldata WHERE comp1='n-heptane' AND comp2='MEG' AND reference='Lindboe2002' ORDER BY Temperature,Pressure");// AND + // Reference='Houghton1957' + // AND + // Reference<>'Nighswander1989' + // AND + // Temperature>278.15 + // AND + // Temperature<383.15 + // AND + // Pressure<60.01325"); + // double parameterGuess[] = {0.0471326591, 5.14, 10.819, 0.6744, 0.0141}; + // double parameterGuess[] = {0.0602997387, 5.2137117933, 10.3039876875, + // 0.6714377099, 0.0178639622}; // fitted to all data + double parameterGuess[] = {1924, 4938};// , -1.11, 1.24}; + // double parameterGuess[] = {0.0471326591}; - try { - int p = 0; - logger.info("adding...."); - while (!dataSet.next() && p < 50) { - p++; - CPAParameterFittingToSolubilityData function = - new CPAParameterFittingToSolubilityData(); + try { + int p = 0; + logger.info("adding...."); + while (!dataSet.next() && p < 50) { + p++; + CPAParameterFittingToSolubilityData function = new CPAParameterFittingToSolubilityData(); - // SystemInterface testSystem = new - // SystemSrkCPAs(Double.parseDouble(dataSet.getString("temperature"))+273.15, - // Double.parseDouble(dataSet.getString("pressure"))); - SystemInterface testSystem = new SystemSrkEos( - Double.parseDouble(dataSet.getString("temperature")) + 273.15, - Double.parseDouble(dataSet.getString("pressure"))); + // SystemInterface testSystem = new + // SystemSrkCPAs(Double.parseDouble(dataSet.getString("temperature"))+273.15, + // Double.parseDouble(dataSet.getString("pressure"))); + SystemInterface testSystem = + new SystemSrkEos(Double.parseDouble(dataSet.getString("temperature")) + 273.15, + Double.parseDouble(dataSet.getString("pressure"))); - testSystem.addComponent("n-heptane", 1.0); - testSystem.addComponent("MEG", 10.0); - // testSystem.createDatabase(true); - // testSystem.setMixingRule(7); - testSystem.setMixingRule(4); - testSystem.init(0); - double sample1[] = {testSystem.getTemperature()}; - double standardDeviation1[] = {0.01}; - double val = Double.parseDouble(dataSet.getString("x-glyinhc")); - double sdev = val / 100.0; - SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem);// 34.7 - sample.setReference(Double.toString(testSystem.getTemperature())); - function.setInitialGuess(parameterGuess); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } + testSystem.addComponent("n-heptane", 1.0); + testSystem.addComponent("MEG", 10.0); + // testSystem.createDatabase(true); + // testSystem.setMixingRule(7); + testSystem.setMixingRule(4); + testSystem.init(0); + double sample1[] = {testSystem.getTemperature()}; + double standardDeviation1[] = {0.01}; + double val = Double.parseDouble(dataSet.getString("x-glyinhc")); + double sdev = val / 100.0; + SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem);// 34.7 + sample.setReference(Double.toString(testSystem.getTemperature())); + function.setInitialGuess(parameterGuess); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } - dataSet = database.getResultSet( - "SELECT * FROM HCGlycolLLdata WHERE comp1='n-heptane' AND comp2='MEG' AND reference='Lindboe2002' ORDER BY Temperature,Pressure"); + dataSet = database.getResultSet( + "SELECT * FROM HCGlycolLLdata WHERE comp1='n-heptane' AND comp2='MEG' AND reference='Lindboe2002' ORDER BY Temperature,Pressure"); - try { - int p = 0; - logger.info("adding...."); - while (!dataSet.next() && p < 50) { - p++; - CPAParameterFittingToSolubilityData_Vap function = - new CPAParameterFittingToSolubilityData_Vap(); + try { + int p = 0; + logger.info("adding...."); + while (!dataSet.next() && p < 50) { + p++; + CPAParameterFittingToSolubilityData_Vap function = + new CPAParameterFittingToSolubilityData_Vap(); - // SystemInterface testSystem = new - // SystemSrkCPAs(Double.parseDouble(dataSet.getString("temperature"))+273.15, - // Double.parseDouble(dataSet.getString("pressure"))); - SystemInterface testSystem = new SystemSrkEos( - Double.parseDouble(dataSet.getString("temperature")) + 273.15, - Double.parseDouble(dataSet.getString("pressure"))); + // SystemInterface testSystem = new + // SystemSrkCPAs(Double.parseDouble(dataSet.getString("temperature"))+273.15, + // Double.parseDouble(dataSet.getString("pressure"))); + SystemInterface testSystem = + new SystemSrkEos(Double.parseDouble(dataSet.getString("temperature")) + 273.15, + Double.parseDouble(dataSet.getString("pressure"))); - testSystem.addComponent("n-heptane", 1.00); - testSystem.addComponent("MEG", 10.0); - testSystem.init(0); - testSystem.setMixingRule(4); - double sample1[] = {testSystem.getTemperature()}; - double standardDeviation1[] = {0.01}; - double val = Double.parseDouble(dataSet.getString("x-hcinglyc")); - double sdev = val / 100.0; - SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(Double.toString(testSystem.getTemperature())); - function.setInitialGuess(parameterGuess); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } + testSystem.addComponent("n-heptane", 1.00); + testSystem.addComponent("MEG", 10.0); + testSystem.init(0); + testSystem.setMixingRule(4); + double sample1[] = {testSystem.getTemperature()}; + double standardDeviation1[] = {0.01}; + double val = Double.parseDouble(dataSet.getString("x-hcinglyc")); + double sdev = val / 100.0; + SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(Double.toString(testSystem.getTemperature())); + function.setInitialGuess(parameterGuess); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); - // do simulations - optim.solve(); - // optim.runMonteCarloSimulation(); - // optim.displayResult(); - optim.displayCurveFit(); - //optim.writeToCdfFile("c:/testFit.nc"); - optim.writeToTextFile("c:/testFit.txt"); - } + // do simulations + optim.solve(); + // optim.runMonteCarloSimulation(); + // optim.displayResult(); + optim.displayCurveFit(); + optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestEosParameterFittingToMercurySolubility.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestEosParameterFittingToMercurySolubility.java index 189adba078..e054ba90d8 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestEosParameterFittingToMercurySolubility.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestEosParameterFittingToMercurySolubility.java @@ -20,72 +20,71 @@ * @version $Id: $Id */ public class TestEosParameterFittingToMercurySolubility { - static Logger logger = LogManager.getLogger(TestEosParameterFittingToMercurySolubility.class); + static Logger logger = LogManager.getLogger(TestEosParameterFittingToMercurySolubility.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); - // inserting samples from database - NeqSimExperimentDatabase database = new NeqSimExperimentDatabase(); + // inserting samples from database + NeqSimExperimentDatabase database = new NeqSimExperimentDatabase(); - ResultSet dataSet = database.getResultSet( - "SELECT * FROM binarysolubilitydata WHERE ComponentSolute='mercury' AND ComponentSolvent='n-hexane'"); - // double parameterGuess[] = {0.13}; // mercury-methane - // double parameterGuess[] = {0.0496811275399517}; // mercury-methane - // double parameterGuess[] = {0.0704}; // mercury-ethane - double parameterGuess[] = {-0.03310000498911416}; // mercury-ibutane - // double parameterGuess[] = {0.0674064646735}; // mercury-propane - // double parameterGuess[] = { 0.3674008071}; // mercury-CO2 - // double parameterGuess[] = { 0.016529772608}; // mercury-nitrogen - try { - int p = 0; - logger.info("adding...."); - while (dataSet.next() && p < 40) { - p++; - CPAParameterFittingToSolubilityData function = - new CPAParameterFittingToSolubilityData(0, 0); + ResultSet dataSet = database.getResultSet( + "SELECT * FROM binarysolubilitydata WHERE ComponentSolute='mercury' AND ComponentSolvent='n-hexane'"); + // double parameterGuess[] = {0.13}; // mercury-methane + // double parameterGuess[] = {0.0496811275399517}; // mercury-methane + // double parameterGuess[] = {0.0704}; // mercury-ethane + double parameterGuess[] = {-0.03310000498911416}; // mercury-ibutane + // double parameterGuess[] = {0.0674064646735}; // mercury-propane + // double parameterGuess[] = { 0.3674008071}; // mercury-CO2 + // double parameterGuess[] = { 0.016529772608}; // mercury-nitrogen + try { + int p = 0; + logger.info("adding...."); + while (dataSet.next() && p < 40) { + p++; + CPAParameterFittingToSolubilityData function = + new CPAParameterFittingToSolubilityData(0, 0); - SystemInterface testSystem = new SystemSrkEos(290, 1.0); - testSystem.addComponent("mercury", 10.0); - testSystem.addComponent("n-hexane", 10.0); - testSystem.getPhase(0).getComponent("mercury").setAttractiveTerm(12); - testSystem.getPhase(1).getComponent("mercury").setAttractiveTerm(12); - testSystem.createDatabase(true); - testSystem.setMultiPhaseCheck(true); - testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); - testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure")) + 2); - testSystem.setMixingRule(2); - testSystem.init(0); - double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; - double standardDeviation1[] = {0.13}; - double x1 = Double.parseDouble(dataSet.getString("x1")); - SampleValue sample = new SampleValue(x1, x1 / 100.0, sample1, standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - function.setInitialGuess(parameterGuess); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } + SystemInterface testSystem = new SystemSrkEos(290, 1.0); + testSystem.addComponent("mercury", 10.0); + testSystem.addComponent("n-hexane", 10.0); + testSystem.getPhase(0).getComponent("mercury").setAttractiveTerm(12); + testSystem.getPhase(1).getComponent("mercury").setAttractiveTerm(12); + testSystem.createDatabase(true); + testSystem.setMultiPhaseCheck(true); + testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); + testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure")) + 2); + testSystem.setMixingRule(2); + testSystem.init(0); + double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; + double standardDeviation1[] = {0.13}; + double x1 = Double.parseDouble(dataSet.getString("x1")); + SampleValue sample = new SampleValue(x1, x1 / 100.0, sample1, standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + function.setInitialGuess(parameterGuess); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); - // do simulations - optim.solve(); - // optim.runMonteCarloSimulation(); - // optim.displayResult(); - optim.displayCurveFit(); - // optim.writeToCdfFile("c:/testFit.nc"); - // optim.writeToTextFile("c:/testFit.txt"); - } + // do simulations + optim.solve(); + // optim.runMonteCarloSimulation(); + // optim.displayResult(); + optim.displayCurveFit(); + // optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestParameterFittingToSolubilityDataEinar.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestParameterFittingToSolubilityDataEinar.java index 373f9b843f..5a6633bded 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestParameterFittingToSolubilityDataEinar.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestParameterFittingToSolubilityDataEinar.java @@ -20,67 +20,65 @@ * @version $Id: $Id */ public class TestParameterFittingToSolubilityDataEinar { - static Logger logger = LogManager.getLogger(TestParameterFittingToSolubilityDataEinar.class); + static Logger logger = LogManager.getLogger(TestParameterFittingToSolubilityDataEinar.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); - // inserting samples from database - NeqSimDataBase database = new NeqSimDataBase(); - ResultSet dataSet = database.getResultSet( - "SELECT * FROM binarysolubilitydataeinar WHERE ComponentSolute='methane' AND ComponentSolvent='Water'"); + // inserting samples from database + NeqSimDataBase database = new NeqSimDataBase(); + ResultSet dataSet = database.getResultSet( + "SELECT * FROM binarysolubilitydataeinar WHERE ComponentSolute='methane' AND ComponentSolvent='Water'"); - try { - int p = 0; - logger.info("adding...."); - while (dataSet.next() && p < 4000) { - p++; - CPAParameterFittingToSolubilityData function = - new CPAParameterFittingToSolubilityData(); + try { + int p = 0; + logger.info("adding...."); + while (dataSet.next() && p < 4000) { + p++; + CPAParameterFittingToSolubilityData function = new CPAParameterFittingToSolubilityData(); - SystemInterface testSystem = new SystemPrEos(290, 1.0); - testSystem.addComponent("methane", 1.0); - testSystem.addComponent("water", 10.0); - testSystem.createDatabase(true); - testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); - testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure")) / 1.0e5); - testSystem.setMixingRule(2); - testSystem.init(0); - double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; - double standardDeviation1[] = - {testSystem.getPressure() / 100.0, testSystem.getTemperature() / 100.0}; - SampleValue sample = new SampleValue(Double.parseDouble(dataSet.getString("x1")), - Double.parseDouble(dataSet.getString("StandardDeviation")), sample1, - standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(Double.toString(testSystem.getTemperature())); - // double parameterGuess[] = {-0.130}; //srk - double parameterGuess[] = {0.0000001}; - function.setInitialGuess(parameterGuess); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } + SystemInterface testSystem = new SystemPrEos(290, 1.0); + testSystem.addComponent("methane", 1.0); + testSystem.addComponent("water", 10.0); + testSystem.createDatabase(true); + testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); + testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure")) / 1.0e5); + testSystem.setMixingRule(2); + testSystem.init(0); + double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; + double standardDeviation1[] = + {testSystem.getPressure() / 100.0, testSystem.getTemperature() / 100.0}; + SampleValue sample = new SampleValue(Double.parseDouble(dataSet.getString("x1")), + Double.parseDouble(dataSet.getString("StandardDeviation")), sample1, + standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(Double.toString(testSystem.getTemperature())); + // double parameterGuess[] = {-0.130}; //srk + double parameterGuess[] = {0.0000001}; + function.setInitialGuess(parameterGuess); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); - // do simulations - optim.solve(); - // optim.runMonteCarloSimulation(); - // optim.displayResult(); - optim.displayCurveFit(); - //optim.writeToCdfFile("c:/testFit.nc"); - optim.writeToTextFile("c:/testFit.txt"); - } + // do simulations + optim.solve(); + // optim.runMonteCarloSimulation(); + // optim.displayResult(); + optim.displayCurveFit(); + optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToDewPointData.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToDewPointData.java index 296b0f320b..7544e86cbd 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToDewPointData.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToDewPointData.java @@ -20,98 +20,97 @@ * @version $Id: $Id */ public class TestBinaryHVParameterFittingToDewPointData { - static Logger logger = LogManager.getLogger(TestBinaryHVParameterFittingToDewPointData.class); + static Logger logger = LogManager.getLogger(TestBinaryHVParameterFittingToDewPointData.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); - // inserting samples from database - NeqSimDataBase database = new NeqSimDataBase(); - ResultSet dataSet = database.getResultSet( - "SELECT * FROM dewpointquaternary WHERE temperature>173.1 AND x4>0.0000021 ORDER BY x4,pressure"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM - // activityCoefficientTable WHERE Component1='MDEA' AND Component2='water'"); - // testSystem.addComponent(dataSet.getString("ComponentSolute"), 1.0); - // testSystem.addComponent(dataSet.getString("ComponentSolvent"), 1.0); - try { - int p = 0; - logger.info("adding...."); - while (dataSet.next() && p < 300) { - p++; - BinaryHVParameterFittingToDewPointData function = - new BinaryHVParameterFittingToDewPointData(); + // inserting samples from database + NeqSimDataBase database = new NeqSimDataBase(); + ResultSet dataSet = database.getResultSet( + "SELECT * FROM dewpointquaternary WHERE temperature>173.1 AND x4>0.0000021 ORDER BY x4,pressure"); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM + // activityCoefficientTable WHERE Component1='MDEA' AND Component2='water'"); + // testSystem.addComponent(dataSet.getString("ComponentSolute"), 1.0); + // testSystem.addComponent(dataSet.getString("ComponentSolvent"), 1.0); + try { + int p = 0; + logger.info("adding...."); + while (dataSet.next() && p < 300) { + p++; + BinaryHVParameterFittingToDewPointData function = + new BinaryHVParameterFittingToDewPointData(); - // SystemInterface testSystem = new SystemFurstElectrolyteEos(280, 1.0); - // SystemInterface testSystem = new SystemSrkSchwartzentruberEos(290, 1.0); - SystemInterface testSystem = new SystemPrEos(290, 1.0); - testSystem.addComponent(dataSet.getString("comp1"), - Double.parseDouble(dataSet.getString("x1"))); - testSystem.addComponent(dataSet.getString("comp2"), - Double.parseDouble(dataSet.getString("x2"))); - testSystem.addComponent("ethane", Double.parseDouble(dataSet.getString("x3"))); - testSystem.addComponent(dataSet.getString("comp4"), - Double.parseDouble(dataSet.getString("x4"))); - // testSystem.setSolidPhaseCheck(true); - // testSystem.addComponent("CO2", 1.0); - // testSystem.addComponent("water", 1.0); - // testSystem.addComponent("MDEA", 1.000001); - // testSystem.chemicalReactionInit(); - // testSystem.createDatabase(true); - testSystem.setMixingRule(4); + // SystemInterface testSystem = new SystemFurstElectrolyteEos(280, 1.0); + // SystemInterface testSystem = new SystemSrkSchwartzentruberEos(290, 1.0); + SystemInterface testSystem = new SystemPrEos(290, 1.0); + testSystem.addComponent(dataSet.getString("comp1"), + Double.parseDouble(dataSet.getString("x1"))); + testSystem.addComponent(dataSet.getString("comp2"), + Double.parseDouble(dataSet.getString("x2"))); + testSystem.addComponent("ethane", Double.parseDouble(dataSet.getString("x3"))); + testSystem.addComponent(dataSet.getString("comp4"), + Double.parseDouble(dataSet.getString("x4"))); + // testSystem.setSolidPhaseCheck(true); + // testSystem.addComponent("CO2", 1.0); + // testSystem.addComponent("water", 1.0); + // testSystem.addComponent("MDEA", 1.000001); + // testSystem.chemicalReactionInit(); + // testSystem.createDatabase(true); + testSystem.setMixingRule(4); - // testSystem.getChemicalReactionOperations().solveChemEq(0); - // testSystem.getChemicalReactionOperations().solveChemEq(1); + // testSystem.getChemicalReactionOperations().solveChemEq(0); + // testSystem.getChemicalReactionOperations().solveChemEq(1); - // testSystem.isChemicalSystem(false); + // testSystem.isChemicalSystem(false); - // testSystem.addComponent("NaPlus", 1.0e-10); - // testSystem.addComponent("methane", 1.1); - testSystem.setTemperature(Double.parseDouble(dataSet.getString("temperature"))); - testSystem.setPressure(Double.parseDouble(dataSet.getString("pressure"))); - testSystem.init(0); - double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; - double standardDeviation1[] = {0.01}; - SampleValue sample = new SampleValue(testSystem.getTemperature(), - testSystem.getTemperature() / 100.0, sample1, standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(Double.toString(testSystem.getTemperature())); - double parameterGuess[] = {0.01}; - // double parameterGuess[] = {4799.35, -2772.29, 0.6381, -1.68096}; - // double parameterGuess[] = {3932.0, -4127.0, -5.89, 8.9}; // HV CO2 - // double parameterGuess[] = {5023.6600682957, -136.4306560594, -3.9812435921, - // 1.4579901393}; // HV methane - // double parameterGuess[] = {3204.3057406886, -2753.7379912645, -12.4728330162 - // , 13.0150379323}; // HV - // double parameterGuess[] = {8.992E3, -3.244E3, -8.424E0, -1.824E0}; // HV - // double parameterGuess[] = {-7.132E2, -3.933E2};//, 3.96E0, 9.602E-1}; //, - // 1.239}; //WS - sample.setReference(Double.toString(testSystem.getPressure())); - function.setInitialGuess(parameterGuess); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } + // testSystem.addComponent("NaPlus", 1.0e-10); + // testSystem.addComponent("methane", 1.1); + testSystem.setTemperature(Double.parseDouble(dataSet.getString("temperature"))); + testSystem.setPressure(Double.parseDouble(dataSet.getString("pressure"))); + testSystem.init(0); + double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; + double standardDeviation1[] = {0.01}; + SampleValue sample = new SampleValue(testSystem.getTemperature(), + testSystem.getTemperature() / 100.0, sample1, standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(Double.toString(testSystem.getTemperature())); + double parameterGuess[] = {0.01}; + // double parameterGuess[] = {4799.35, -2772.29, 0.6381, -1.68096}; + // double parameterGuess[] = {3932.0, -4127.0, -5.89, 8.9}; // HV CO2 + // double parameterGuess[] = {5023.6600682957, -136.4306560594, -3.9812435921, + // 1.4579901393}; // HV methane + // double parameterGuess[] = {3204.3057406886, -2753.7379912645, -12.4728330162 + // , 13.0150379323}; // HV + // double parameterGuess[] = {8.992E3, -3.244E3, -8.424E0, -1.824E0}; // HV + // double parameterGuess[] = {-7.132E2, -3.933E2};//, 3.96E0, 9.602E-1}; //, + // 1.239}; //WS + sample.setReference(Double.toString(testSystem.getPressure())); + function.setInitialGuess(parameterGuess); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); - // do simulations - // optim.solve(); - // optim.runMonteCarloSimulation(); - // optim.displayResult(); - optim.displayCurveFit(); - optim.displayResult(); - // optim.writeToCdfFile("c:/testFit.nc"); - // optim.writeToTextFile("c:/testFit.txt"); - } + // do simulations + // optim.solve(); + // optim.runMonteCarloSimulation(); + // optim.displayResult(); + optim.displayCurveFit(); + optim.displayResult(); + // optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData.java index 5cc95c17e2..d98d7547fe 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData.java @@ -20,104 +20,102 @@ * @version $Id: $Id */ public class TestBinaryHVParameterFittingToSolubilityData { - static Logger logger = LogManager.getLogger(TestBinaryHVParameterFittingToSolubilityData.class); + static Logger logger = LogManager.getLogger(TestBinaryHVParameterFittingToSolubilityData.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); - // inserting samples from database - NeqSimExperimentDatabase database = new NeqSimExperimentDatabase(); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM - // binarySolubilityData WHERE ComponentSolute='CO2' AND ComponentSolvent='water' - // AND Reference='Houghton1957' AND Reference<>'Nighswander1989' AND - // Temperature>278.15 AND Temperature<363.15 AND Pressure<60.01325 ORDER BY - // Temperature,Pressure"); - ResultSet dataSet = database.getResultSet( - "SELECT * FROM binarySolubilityData WHERE ComponentSolute='oxygen' AND ComponentSolvent='water' ORDER BY Temperature,Pressure"); + // inserting samples from database + NeqSimExperimentDatabase database = new NeqSimExperimentDatabase(); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM + // binarySolubilityData WHERE ComponentSolute='CO2' AND ComponentSolvent='water' + // AND Reference='Houghton1957' AND Reference<>'Nighswander1989' AND + // Temperature>278.15 AND Temperature<363.15 AND Pressure<60.01325 ORDER BY + // Temperature,Pressure"); + ResultSet dataSet = database.getResultSet( + "SELECT * FROM binarySolubilityData WHERE ComponentSolute='oxygen' AND ComponentSolvent='water' ORDER BY Temperature,Pressure"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM - // activityCoefficientTable WHERE Component1='MDEA' AND Component2='water'"); - // testSystem.addComponent(dataSet.getString("ComponentSolute"), 1.0); - // testSystem.addComponent(dataSet.getString("ComponentSolvent"), 1.0); - try { - int p = 0; - logger.info("adding...."); - while (dataSet.next() && p < 22) { - p++; - BinaryHVParameterFittingToSolubilityData function = - new BinaryHVParameterFittingToSolubilityData(); - // SystemInterface testSystem = new SystemSrkEos(280,1); - // SystemInterface testSystem = new SystemFurstElectrolyteEos(280, 1.0); - SystemInterface testSystem = new SystemSrkSchwartzentruberEos(290, 1.0); - // SystemInterface testSystem = new SystemSrkMathiasCopeman(290, 1.0); - testSystem.addComponent(dataSet.getString("ComponentSolute"), 1.0); - testSystem.addComponent(dataSet.getString("ComponentSolvent"), 100.0); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM + // activityCoefficientTable WHERE Component1='MDEA' AND Component2='water'"); + // testSystem.addComponent(dataSet.getString("ComponentSolute"), 1.0); + // testSystem.addComponent(dataSet.getString("ComponentSolvent"), 1.0); + try { + int p = 0; + logger.info("adding...."); + while (dataSet.next() && p < 22) { + p++; + BinaryHVParameterFittingToSolubilityData function = + new BinaryHVParameterFittingToSolubilityData(); + // SystemInterface testSystem = new SystemSrkEos(280,1); + // SystemInterface testSystem = new SystemFurstElectrolyteEos(280, 1.0); + SystemInterface testSystem = new SystemSrkSchwartzentruberEos(290, 1.0); + // SystemInterface testSystem = new SystemSrkMathiasCopeman(290, 1.0); + testSystem.addComponent(dataSet.getString("ComponentSolute"), 1.0); + testSystem.addComponent(dataSet.getString("ComponentSolvent"), 100.0); - // testSystem.addComponent("CO2", 1.0); - // testSystem.addComponent("water", 1.0); - // testSystem.addComponent("MDEA", 1.000001); - // testSystem.chemicalReactionInit(); - testSystem.createDatabase(true); - testSystem.setMixingRule(4); + // testSystem.addComponent("CO2", 1.0); + // testSystem.addComponent("water", 1.0); + // testSystem.addComponent("MDEA", 1.000001); + // testSystem.chemicalReactionInit(); + testSystem.createDatabase(true); + testSystem.setMixingRule(4); - // testSystem.getChemicalReactionOperations().solveChemEq(0); - // testSystem.getChemicalReactionOperations().solveChemEq(1); + // testSystem.getChemicalReactionOperations().solveChemEq(0); + // testSystem.getChemicalReactionOperations().solveChemEq(1); - // testSystem.isChemicalSystem(false); + // testSystem.isChemicalSystem(false); - // testSystem.addComponent("NaPlus", 1.0e-10); - // testSystem.addComponent("methane", 1.1); - testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); - testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); - logger.error("pressure " + testSystem.getPressure()); - testSystem.init(0); - double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; - double standardDeviation1[] = {0.01}; - SampleValue sample = new SampleValue(Double.parseDouble(dataSet.getString("x1")), - Double.parseDouble(dataSet.getString("StandardDeviation")), sample1, - standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(Double.toString(testSystem.getTemperature())); - // double parameterGuess[] = {4799.35, -2772.29, 0.6381, -1.68096}; - // double parameterGuess[] = {5640.38, -3793.1, -4.42, 2.82}; // HV CO2 - // double parameterGuess[] = {7263.5285887088, -3712.3594920781, -7.1458168635, - // 1.2714576276};//CO2-SRK-MC - // double parameterGuess[] = {5251.7374371982, -3121.2788585048, -0.8420253536, - // -0.5123316046}; // HV CO2 -PVT-sim - double parameterGuess[] = - {2423.6600682957, -2136.4306560594, 1.9812435921, 1.4579901393}; // HV - // methane - // double parameterGuess[] = {3204.3057406886, -2753.7379912645, -12.4728330162 - // , 13.0150379323}; // HV - // double parameterGuess[] = {8.992E3, -3.244E3, -8.424E0, -1.824E0}; // HV - // double parameterGuess[] = {-7.132E2, -3.933E2};//, 3.96E0, 9.602E-1}; //, - // 1.239}; //WS - function.setInitialGuess(parameterGuess); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } + // testSystem.addComponent("NaPlus", 1.0e-10); + // testSystem.addComponent("methane", 1.1); + testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); + testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); + logger.error("pressure " + testSystem.getPressure()); + testSystem.init(0); + double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; + double standardDeviation1[] = {0.01}; + SampleValue sample = new SampleValue(Double.parseDouble(dataSet.getString("x1")), + Double.parseDouble(dataSet.getString("StandardDeviation")), sample1, + standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(Double.toString(testSystem.getTemperature())); + // double parameterGuess[] = {4799.35, -2772.29, 0.6381, -1.68096}; + // double parameterGuess[] = {5640.38, -3793.1, -4.42, 2.82}; // HV CO2 + // double parameterGuess[] = {7263.5285887088, -3712.3594920781, -7.1458168635, + // 1.2714576276};//CO2-SRK-MC + // double parameterGuess[] = {5251.7374371982, -3121.2788585048, -0.8420253536, + // -0.5123316046}; // HV CO2 -PVT-sim + double parameterGuess[] = {2423.6600682957, -2136.4306560594, 1.9812435921, 1.4579901393}; // HV + // methane + // double parameterGuess[] = {3204.3057406886, -2753.7379912645, -12.4728330162 + // , 13.0150379323}; // HV + // double parameterGuess[] = {8.992E3, -3.244E3, -8.424E0, -1.824E0}; // HV + // double parameterGuess[] = {-7.132E2, -3.933E2};//, 3.96E0, 9.602E-1}; //, + // 1.239}; //WS + function.setInitialGuess(parameterGuess); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); - // do simulations - optim.solve(); - // optim.runMonteCarloSimulation(); - // optim.displayResult(); - optim.displayCurveFit(); - // optim.displayResult(); - // optim.writeToCdfFile("c:/testFit.nc"); - // optim.writeToTextFile("c:/testFit.txt"); - } + // do simulations + optim.solve(); + // optim.runMonteCarloSimulation(); + // optim.displayResult(); + optim.displayCurveFit(); + // optim.displayResult(); + // optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData_Lucia.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData_Lucia.java index bb49b345bb..a612bb4023 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData_Lucia.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData_Lucia.java @@ -20,236 +20,235 @@ * @version $Id: $Id */ public class TestBinaryHVParameterFittingToSolubilityData_Lucia { - static Logger logger = - LogManager.getLogger(TestBinaryHVParameterFittingToSolubilityData_Lucia.class); - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); - - // inserting samples from database - NeqSimDataBase database = new NeqSimDataBase(); - ResultSet dataSet = database.getResultSet( - "SELECT * FROM LuciaData8 WHERE Component='methane' AND Temperature<520 AND L2<>NULL AND L2>0.0000000001 ORDER BY Temperature,Pressure");// AND - // Reference='Houghton1957' - // AND - // Reference<>'Nighswander1989' - // AND - // Temperature>278.15 - // AND - // Temperature<383.15 - // AND - // Pressure<60.01325"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE - // Component='CO2' AND Temperature>250 AND Temperature<420 AND - // Pressure<700000000 AND L2 IS NOT NULL AND L2>0.000000001 ORDER BY - // Temperature,Pressure");// AND Reference='Houghton1957' AND - // Reference<>'Nighswander1989' AND Temperature>278.15 AND Temperature<383.15 - // AND Pressure<60.01325"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE - // Component='propane' AND Temperature>250 AND Temperature<420 AND - // Pressure<700000000 AND L2<>NULL AND L2>0.000000001 ORDER BY - // Temperature,Pressure");// AND Reference='Houghton1957' AND - // Reference<>'Nighswander1989' AND Temperature>278.15 AND Temperature<383.15 - // AND Pressure<60.01325"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE - // Component='methane' AND ID1>662 AND ID1<760 AND Temperature<520 AND L2<>NULL - // AND L2>0.0000000001 ORDER BY Temperature,Pressure");// AND - // Reference='Houghton1957' AND Reference<>'Nighswander1989' AND - // Temperature>278.15 AND Temperature<383.15 AND Pressure<60.01325"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE - // Component='H2S' AND Temperature>250 AND Temperature<420 AND Pressure<10000000 - // AND L2<>NULL AND L2>0.000000001 ORDER BY Temperature,Pressure"); - try { - int p = 0; - logger.info("adding...."); - while (dataSet.next() && p < 150) { - p++; - BinaryHVParameterFittingToSolubilityData function = - new BinaryHVParameterFittingToSolubilityData(1, 1); - - // SystemInterface testSystem = new SystemFurstElectrolyteEos(280, 1.0); - // SystemInterface testSystem = new - // SystemPrEos1978(Double.parseDouble(dataSet.getString("Temperature")), - // Double.parseDouble(dataSet.getString("Pressure"))/1e5); - // SystemInterface testSystem = new - // SystemSrkEos(Double.parseDouble(dataSet.getString("Temperature")), - // Double.parseDouble(dataSet.getString("Pressure"))/1e5); - // SystemInterface testSystem = new - // SystemSrkEos(Double.parseDouble(dataSet.getString("Temperature")), - // Double.parseDouble(dataSet.getString("Pressure")) / 1e5); - SystemInterface testSystem = new SystemSrkCPAstatoil( - Double.parseDouble(dataSet.getString("Temperature")), - Double.parseDouble(dataSet.getString("Pressure")) / 1e5); - // testSystem.addComponent("propane", 10.0); - testSystem.addComponent("methane", 10.0); - testSystem.addComponent("water", 100.0); - - // testSystem.addComponent("CO2", 1.0); - // testSystem.addComponent("water", 1.0); - // testSystem.addComponent("MDEA", 1.000001); - // testSystem.chemicalReactionInit(); - // testSystem.createDatabase(true); - testSystem.setMixingRule(4); - // testSystem.getChemicalReactionOperations().solveChemEq(0); - // testSystem.getChemicalReactionOperations().solveChemEq(1); - - // testSystem.isChemicalSystem(false); - - // testSystem.addComponent("NaPlus", 1.0e-10); - // testSystem.addComponent("methane", 1.1); - testSystem.init(0); - double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; - double standardDeviation1[] = {0.01}; - double val = Double.parseDouble(dataSet.getString("L2")); - double sdev = val / 100.0; - SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(Double.toString(testSystem.getTemperature())); - // double parameterGuess[] = {4239.63, -232.924, -5.01417, 2.3761}; - // double parameterGuess[] = {3932.0, -4127.0, -5.89, 8.9}; // HV CO2 - // double parameterGuess[] = {1859.4161214985, -1025.4679064974, -1.5607986741, - // 2.1430069589}; // HV H2S - - // double parameterGuess[] = {1193.8840735911, 69.2494254233, -7.8323508140, - // 4.5299137720}; // H2S MDEA - // double parameterGuess[] ={5251.7374371982, -3121.2788585048, -0.8420253536, - // -0.5123316046};//;//,0.03};//co2 scsrk-ny - // double parameterGuess[] ={-1584, 3517, 3.9121943388, -0.44,-0.1};//propane - // double parameterGuess[] = { 5607, 0.897598343, -123.6011438188, - // -6.5496550381, 2.1378539395}; // HV methan570 - double parameterGuess[] = - {6114.2013874102, -188.264597921, -10.7239107857559, 2.310651690177652}; // HV - // methan570 - // double parameterGuess[] = {3204.3057406886, -2753.7379912645, -12.4728330162 - // , 13.0150379323}; // HV - // double parameterGuess[] = {8.992E3, -3.244E3, -8.424E0, -1.824E0}; // HV - // double parameterGuess[] = {-7.132E2, -3.933E2};//, 3.96E0, 9.602E-1}; //, - // 1.239}; //WS - function.setInitialGuess(parameterGuess); - sampleList.add(sample); - logger.info("liq points " + p); - } - } catch (Exception e) { - logger.error("database error" + e); - } - - dataSet = database.getResultSet( - "SELECT * FROM LuciaData8 WHERE Component='methane' AND ID<3000 AND Temperature<520 AND Y<>NULL AND Y>0.0000000001 ORDER BY Temperature,Pressure");// AND - // Reference='Houghton1957' - // AND - // Reference<>'Nighswander1989' - // AND - // Temperature>278.15 - // AND - // Temperature<383.15 - // AND - // Pressure<60.01325"); - // dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE - // Component='CO2' AND ID<3000 AND Temperature>250 AND Pressure<700000000 AND - // Temperature<420 AND Y IS NOT NULL AND Y>0.0000000001 ORDER BY - // Temperature,Pressure");// AND Reference='Houghton1957' AND - // Reference<>'Nighswander1989' AND Temperature>278.15 AND Temperature<383.15 - // AND Pressure<60.01325"); - // dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE - // Component='methane' AND Temperature>273.15 AND Pressure<153000000 AND Y<>NULL - // AND Y>0.000000001 ORDER BY Temperature,Pressure"); - - // ResultSet dataSet = database.getResultSet( "SELECT * FROM - // activityCoefficientTable WHERE Component1='MDEA' AND Component2='water'"); - // testSystem.addComponent(dataSet.getString("ComponentSolute"), 1.0); - // testSystem.addComponent(dataSet.getString("ComponentSolvent"), 1.0); - try { - int p = 0; - logger.info("adding...."); - while (dataSet.next() && p < 150) { - p++; - BinaryHVParameterFittingToSolubilityData function = - new BinaryHVParameterFittingToSolubilityData(0, 0); - - // SystemInterface testSystem = new - // SystemFurstElectrolyteEos(Double.parseDouble(dataSet.getString("Temperature")), - // Double.parseDouble(dataSet.getString("Pressure"))/1e5); - // SystemInterface testSystem = new - // SystemPrEos1978(Double.parseDouble(dataSet.getString("Temperature")), - // Double.parseDouble(dataSet.getString("Pressure"))/1e5); - // SystemInterface testSystem = new - // SystemSrkEos(Double.parseDouble(dataSet.getString("Temperature")), - // Double.parseDouble(dataSet.getString("Pressure"))/1e5); - // SystemInterface testSystem = new - // SystemSrkEos(Double.parseDouble(dataSet.getString("Temperature")), - // Double.parseDouble(dataSet.getString("Pressure")) / 1e5); - // testSystem.addComponent("CO2", 1.0); - SystemInterface testSystem = new SystemSrkCPAstatoil( - Double.parseDouble(dataSet.getString("Temperature")), - Double.parseDouble(dataSet.getString("Pressure")) / 1e5); - - testSystem.addComponent("methane", 10.0); - testSystem.addComponent("water", 10.0); - - // testSystem.addComponent("CO2", 1.0); - // testSystem.addComponent("water", 1.0); - // testSystem.addComponent("MDEA", 1.000001); - // testSystem.chemicalReactionInit(); - // testSystem.createDatabase(true); - testSystem.setMixingRule(4); - - // testSystem.getChemicalReactionOperations().solveChemEq(0); - // testSystem.getChemicalReactionOperations().solveChemEq(1); - - // testSystem.isChemicalSystem(false); - - // testSystem.addComponent("NaPlus", 1.0e-10); - // testSystem.addComponent("methane", 1.1); - testSystem.init(0); - double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; - double standardDeviation1[] = {0.01}; - double val = 1.0 - Double.parseDouble(dataSet.getString("Y")); - double sdev = val / 100.0; - SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(Double.toString(testSystem.getTemperature())); - // double parameterGuess[] = {4239.63, -232.924, -5.01417, 2.3761}; - // double parameterGuess[] ={3209.3031222305, -2016.3262143626, 4.2211091944, - // -3.3157456878}; - // double parameterGuess[] = {5640.0, -3793.0, -5.89, 8.9}; // HV CO2 - // double parameterGuess[] ={5251.7374371982, -3121.2788585048, -0.8420253536, - // -0.5123316046};//;//,0.03};//co2 scsrk-ny - double parameterGuess[] = - {6114.2013874102, -188.264597921, -10.7239107857559, 2.310651690177652}; // HV - // methane - // double parameterGuess[] = {3204.3057406886, -2753.7379912645, -12.4728330162 - // , 13.0150379323}; // HV - // double parameterGuess[] = {8.992E3, -3.244E3, -8.424E0, -1.824E0}; // HV - // double parameterGuess[] = {-7.132E2, -3.933E2};//, 3.96E0, 9.602E-1}; //, - // 1.239}; //WS - function.setInitialGuess(parameterGuess); - sample.setDescription(Double.toString(testSystem.getTemperature())); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } - - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); - - // do simulations - optim.solve(); - // optim.runMonteCarloSimulation(); - // optim.displayResult(); - optim.displayCurveFit(); - optim.displayResult(); - // optim.writeToCdfFile("c:/testFit.nc"); - // optim.writeToTextFile("c:/testFit.txt"); + static Logger logger = + LogManager.getLogger(TestBinaryHVParameterFittingToSolubilityData_Lucia.class); + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); + + // inserting samples from database + NeqSimDataBase database = new NeqSimDataBase(); + ResultSet dataSet = database.getResultSet( + "SELECT * FROM LuciaData8 WHERE Component='methane' AND Temperature<520 AND L2<>NULL AND L2>0.0000000001 ORDER BY Temperature,Pressure");// AND + // Reference='Houghton1957' + // AND + // Reference<>'Nighswander1989' + // AND + // Temperature>278.15 + // AND + // Temperature<383.15 + // AND + // Pressure<60.01325"); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE + // Component='CO2' AND Temperature>250 AND Temperature<420 AND + // Pressure<700000000 AND L2 IS NOT NULL AND L2>0.000000001 ORDER BY + // Temperature,Pressure");// AND Reference='Houghton1957' AND + // Reference<>'Nighswander1989' AND Temperature>278.15 AND Temperature<383.15 + // AND Pressure<60.01325"); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE + // Component='propane' AND Temperature>250 AND Temperature<420 AND + // Pressure<700000000 AND L2<>NULL AND L2>0.000000001 ORDER BY + // Temperature,Pressure");// AND Reference='Houghton1957' AND + // Reference<>'Nighswander1989' AND Temperature>278.15 AND Temperature<383.15 + // AND Pressure<60.01325"); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE + // Component='methane' AND ID1>662 AND ID1<760 AND Temperature<520 AND L2<>NULL + // AND L2>0.0000000001 ORDER BY Temperature,Pressure");// AND + // Reference='Houghton1957' AND Reference<>'Nighswander1989' AND + // Temperature>278.15 AND Temperature<383.15 AND Pressure<60.01325"); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE + // Component='H2S' AND Temperature>250 AND Temperature<420 AND Pressure<10000000 + // AND L2<>NULL AND L2>0.000000001 ORDER BY Temperature,Pressure"); + try { + int p = 0; + logger.info("adding...."); + while (dataSet.next() && p < 150) { + p++; + BinaryHVParameterFittingToSolubilityData function = + new BinaryHVParameterFittingToSolubilityData(1, 1); + + // SystemInterface testSystem = new SystemFurstElectrolyteEos(280, 1.0); + // SystemInterface testSystem = new + // SystemPrEos1978(Double.parseDouble(dataSet.getString("Temperature")), + // Double.parseDouble(dataSet.getString("Pressure"))/1e5); + // SystemInterface testSystem = new + // SystemSrkEos(Double.parseDouble(dataSet.getString("Temperature")), + // Double.parseDouble(dataSet.getString("Pressure"))/1e5); + // SystemInterface testSystem = new + // SystemSrkEos(Double.parseDouble(dataSet.getString("Temperature")), + // Double.parseDouble(dataSet.getString("Pressure")) / 1e5); + SystemInterface testSystem = + new SystemSrkCPAstatoil(Double.parseDouble(dataSet.getString("Temperature")), + Double.parseDouble(dataSet.getString("Pressure")) / 1e5); + // testSystem.addComponent("propane", 10.0); + testSystem.addComponent("methane", 10.0); + testSystem.addComponent("water", 100.0); + + // testSystem.addComponent("CO2", 1.0); + // testSystem.addComponent("water", 1.0); + // testSystem.addComponent("MDEA", 1.000001); + // testSystem.chemicalReactionInit(); + // testSystem.createDatabase(true); + testSystem.setMixingRule(4); + // testSystem.getChemicalReactionOperations().solveChemEq(0); + // testSystem.getChemicalReactionOperations().solveChemEq(1); + + // testSystem.isChemicalSystem(false); + + // testSystem.addComponent("NaPlus", 1.0e-10); + // testSystem.addComponent("methane", 1.1); + testSystem.init(0); + double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; + double standardDeviation1[] = {0.01}; + double val = Double.parseDouble(dataSet.getString("L2")); + double sdev = val / 100.0; + SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(Double.toString(testSystem.getTemperature())); + // double parameterGuess[] = {4239.63, -232.924, -5.01417, 2.3761}; + // double parameterGuess[] = {3932.0, -4127.0, -5.89, 8.9}; // HV CO2 + // double parameterGuess[] = {1859.4161214985, -1025.4679064974, -1.5607986741, + // 2.1430069589}; // HV H2S + + // double parameterGuess[] = {1193.8840735911, 69.2494254233, -7.8323508140, + // 4.5299137720}; // H2S MDEA + // double parameterGuess[] ={5251.7374371982, -3121.2788585048, -0.8420253536, + // -0.5123316046};//;//,0.03};//co2 scsrk-ny + // double parameterGuess[] ={-1584, 3517, 3.9121943388, -0.44,-0.1};//propane + // double parameterGuess[] = { 5607, 0.897598343, -123.6011438188, + // -6.5496550381, 2.1378539395}; // HV methan570 + double parameterGuess[] = + {6114.2013874102, -188.264597921, -10.7239107857559, 2.310651690177652}; // HV + // methan570 + // double parameterGuess[] = {3204.3057406886, -2753.7379912645, -12.4728330162 + // , 13.0150379323}; // HV + // double parameterGuess[] = {8.992E3, -3.244E3, -8.424E0, -1.824E0}; // HV + // double parameterGuess[] = {-7.132E2, -3.933E2};//, 3.96E0, 9.602E-1}; //, + // 1.239}; //WS + function.setInitialGuess(parameterGuess); + sampleList.add(sample); + logger.info("liq points " + p); + } + } catch (Exception e) { + logger.error("database error" + e); } + + dataSet = database.getResultSet( + "SELECT * FROM LuciaData8 WHERE Component='methane' AND ID<3000 AND Temperature<520 AND Y<>NULL AND Y>0.0000000001 ORDER BY Temperature,Pressure");// AND + // Reference='Houghton1957' + // AND + // Reference<>'Nighswander1989' + // AND + // Temperature>278.15 + // AND + // Temperature<383.15 + // AND + // Pressure<60.01325"); + // dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE + // Component='CO2' AND ID<3000 AND Temperature>250 AND Pressure<700000000 AND + // Temperature<420 AND Y IS NOT NULL AND Y>0.0000000001 ORDER BY + // Temperature,Pressure");// AND Reference='Houghton1957' AND + // Reference<>'Nighswander1989' AND Temperature>278.15 AND Temperature<383.15 + // AND Pressure<60.01325"); + // dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE + // Component='methane' AND Temperature>273.15 AND Pressure<153000000 AND Y<>NULL + // AND Y>0.000000001 ORDER BY Temperature,Pressure"); + + // ResultSet dataSet = database.getResultSet( "SELECT * FROM + // activityCoefficientTable WHERE Component1='MDEA' AND Component2='water'"); + // testSystem.addComponent(dataSet.getString("ComponentSolute"), 1.0); + // testSystem.addComponent(dataSet.getString("ComponentSolvent"), 1.0); + try { + int p = 0; + logger.info("adding...."); + while (dataSet.next() && p < 150) { + p++; + BinaryHVParameterFittingToSolubilityData function = + new BinaryHVParameterFittingToSolubilityData(0, 0); + + // SystemInterface testSystem = new + // SystemFurstElectrolyteEos(Double.parseDouble(dataSet.getString("Temperature")), + // Double.parseDouble(dataSet.getString("Pressure"))/1e5); + // SystemInterface testSystem = new + // SystemPrEos1978(Double.parseDouble(dataSet.getString("Temperature")), + // Double.parseDouble(dataSet.getString("Pressure"))/1e5); + // SystemInterface testSystem = new + // SystemSrkEos(Double.parseDouble(dataSet.getString("Temperature")), + // Double.parseDouble(dataSet.getString("Pressure"))/1e5); + // SystemInterface testSystem = new + // SystemSrkEos(Double.parseDouble(dataSet.getString("Temperature")), + // Double.parseDouble(dataSet.getString("Pressure")) / 1e5); + // testSystem.addComponent("CO2", 1.0); + SystemInterface testSystem = + new SystemSrkCPAstatoil(Double.parseDouble(dataSet.getString("Temperature")), + Double.parseDouble(dataSet.getString("Pressure")) / 1e5); + + testSystem.addComponent("methane", 10.0); + testSystem.addComponent("water", 10.0); + + // testSystem.addComponent("CO2", 1.0); + // testSystem.addComponent("water", 1.0); + // testSystem.addComponent("MDEA", 1.000001); + // testSystem.chemicalReactionInit(); + // testSystem.createDatabase(true); + testSystem.setMixingRule(4); + + // testSystem.getChemicalReactionOperations().solveChemEq(0); + // testSystem.getChemicalReactionOperations().solveChemEq(1); + + // testSystem.isChemicalSystem(false); + + // testSystem.addComponent("NaPlus", 1.0e-10); + // testSystem.addComponent("methane", 1.1); + testSystem.init(0); + double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; + double standardDeviation1[] = {0.01}; + double val = 1.0 - Double.parseDouble(dataSet.getString("Y")); + double sdev = val / 100.0; + SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(Double.toString(testSystem.getTemperature())); + // double parameterGuess[] = {4239.63, -232.924, -5.01417, 2.3761}; + // double parameterGuess[] ={3209.3031222305, -2016.3262143626, 4.2211091944, + // -3.3157456878}; + // double parameterGuess[] = {5640.0, -3793.0, -5.89, 8.9}; // HV CO2 + // double parameterGuess[] ={5251.7374371982, -3121.2788585048, -0.8420253536, + // -0.5123316046};//;//,0.03};//co2 scsrk-ny + double parameterGuess[] = + {6114.2013874102, -188.264597921, -10.7239107857559, 2.310651690177652}; // HV + // methane + // double parameterGuess[] = {3204.3057406886, -2753.7379912645, -12.4728330162 + // , 13.0150379323}; // HV + // double parameterGuess[] = {8.992E3, -3.244E3, -8.424E0, -1.824E0}; // HV + // double parameterGuess[] = {-7.132E2, -3.933E2};//, 3.96E0, 9.602E-1}; //, + // 1.239}; //WS + function.setInitialGuess(parameterGuess); + sample.setDescription(Double.toString(testSystem.getTemperature())); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } + + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); + + // do simulations + optim.solve(); + // optim.runMonteCarloSimulation(); + // optim.displayResult(); + optim.displayCurveFit(); + optim.displayResult(); + // optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData_LuciaPropane.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData_LuciaPropane.java index 4ba0a3b572..ac7f6e8041 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData_LuciaPropane.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData_LuciaPropane.java @@ -20,175 +20,173 @@ * @version $Id: $Id */ public class TestBinaryHVParameterFittingToSolubilityData_LuciaPropane { - static Logger logger = - LogManager.getLogger(TestBinaryHVParameterFittingToSolubilityData_LuciaPropane.class); + static Logger logger = + LogManager.getLogger(TestBinaryHVParameterFittingToSolubilityData_LuciaPropane.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); - - // inserting samples from database - NeqSimExperimentDatabase database = new NeqSimExperimentDatabase(); - ResultSet dataSet = database.getResultSet( - "SELECT * FROM LuciaData8 WHERE Component='nitrogen' AND Temperature>270.0 AND L2>0.000000001");// AND - // Temperature<600 - // AND - // Pressure<7000000000 - // AND - // L2<>NULL - // AND - // L2>0.000000001 - // ORDER - // BY - // Temperature,Pressure");// - // AND - // Reference='Houghton1957' - // AND - // Reference<>'Nighswander1989' - // AND - // Temperature>278.15 - // AND - // Temperature<383.15 - // AND - // Pressure<60.01325"); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); - try { - int p = 0; - logger.info("adding...."); - while (dataSet.next() && p < 80) { - p++; - BinaryHVParameterFittingToSolubilityData function = - new BinaryHVParameterFittingToSolubilityData(); + // inserting samples from database + NeqSimExperimentDatabase database = new NeqSimExperimentDatabase(); + ResultSet dataSet = database.getResultSet( + "SELECT * FROM LuciaData8 WHERE Component='nitrogen' AND Temperature>270.0 AND L2>0.000000001");// AND + // Temperature<600 + // AND + // Pressure<7000000000 + // AND + // L2<>NULL + // AND + // L2>0.000000001 + // ORDER + // BY + // Temperature,Pressure");// + // AND + // Reference='Houghton1957' + // AND + // Reference<>'Nighswander1989' + // AND + // Temperature>278.15 + // AND + // Temperature<383.15 + // AND + // Pressure<60.01325"); - SystemInterface testSystem = new SystemSrkSchwartzentruberEos( - Double.parseDouble(dataSet.getString("Temperature")), - Double.parseDouble(dataSet.getString("Pressure")) / 1e5); + try { + int p = 0; + logger.info("adding...."); + while (dataSet.next() && p < 80) { + p++; + BinaryHVParameterFittingToSolubilityData function = + new BinaryHVParameterFittingToSolubilityData(); - testSystem.addComponent("nitrogen", 10.0); - testSystem.addComponent("water", 10.0); + SystemInterface testSystem = + new SystemSrkSchwartzentruberEos(Double.parseDouble(dataSet.getString("Temperature")), + Double.parseDouble(dataSet.getString("Pressure")) / 1e5); - testSystem.createDatabase(true); - testSystem.setMixingRule("HV"); + testSystem.addComponent("nitrogen", 10.0); + testSystem.addComponent("water", 10.0); - testSystem.init(0); - double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; - double standardDeviation1[] = {0.01}; - double val = Double.parseDouble(dataSet.getString("L2")); - double sdev = val / 100.0; - SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(Double.toString(testSystem.getTemperature())); - double parameterGuess[] = {4898.64, -111.76};// , -0.1, -0.44};//, 0.07};//propane + testSystem.createDatabase(true); + testSystem.setMixingRule("HV"); - function.setInitialGuess(parameterGuess); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } + testSystem.init(0); + double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; + double standardDeviation1[] = {0.01}; + double val = Double.parseDouble(dataSet.getString("L2")); + double sdev = val / 100.0; + SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(Double.toString(testSystem.getTemperature())); + double parameterGuess[] = {4898.64, -111.76};// , -0.1, -0.44};//, 0.07};//propane - dataSet = database.getResultSet( - "SELECT * FROM LuciaData8 WHERE Component='nitrogen' AND ID>=1014 AND ID<=1045 AND Temperature<373.0");// AND - // ID<3000 - // AND - // Temperature>250 - // AND - // Pressure<7000000000 - // AND - // Temperature<600 - // AND - // Y<>NULL - // AND - // Y>0.0000000001 - // ORDER - // BY - // Temperature,Pressure");// - // AND - // Reference='Houghton1957' - // AND - // Reference<>'Nighswander1989' - // AND - // Temperature>278.15 - // AND - // Temperature<383.15 - // AND - // Pressure<60.01325"); - try { - int p = 0; - logger.info("adding...."); - while (dataSet.next() && p < 100) { - p++; - BinaryHVParameterFittingToSolubilityData function = - new BinaryHVParameterFittingToSolubilityData(0, 0); - SystemInterface testSystem = new SystemSrkSchwartzentruberEos( - Double.parseDouble(dataSet.getString("Temperature")), - Double.parseDouble(dataSet.getString("Pressure")) / 1e5); - testSystem.addComponent("nitrogen", 10.0); - testSystem.addComponent("water", 1000.0); - testSystem.setMixingRule("HV"); - testSystem.init(0); - double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; - double standardDeviation1[] = {0.01}; - double val = 1.0 - Double.parseDouble(dataSet.getString("Y")); - double sdev = val / 100.0; - SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(Double.toString(testSystem.getTemperature())); - double parameterGuess[] = {4898.64, -111.76};// , -0.1, -0.44};//, 0.07};//propane - function.setInitialGuess(parameterGuess); - sample.setDescription(Double.toString(testSystem.getTemperature())); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } - /* - * dataSet = database.getResultSet( - * "SELECT * FROM LuciaData8 WHERE Component='propane');// AND Temperature>270 AND Temperature<400 AND Pressure<700000000 AND L1<>NULL ORDER BY Temperature,Pressure" - * );// AND Reference='Houghton1957' AND Reference<>'Nighswander1989' AND Temperature>278.15 - * AND Temperature<383.15 AND Pressure<60.01325"); - * - * try{ int p=0; logger.info("adding...."); while(!dataSet.next() && p<10){ p++; - * BinaryHVParameterFittingToSolubilityData function = new - * BinaryHVParameterFittingToSolubilityData(0,0); - * - * SystemInterface testSystem = new - * SystemSrkSchwartzentruberEos(Double.parseDouble(dataSet.getString( "Temperature")), - * Double.parseDouble(dataSet.getString("Pressure"))/1e5); - * - * testSystem.addComponent("propane", 10.0); testSystem.addComponent("water", 10.0); - * - * //testSystem.createDatabase(true); testSystem.setMixingRule("HV"); - * - * testSystem.init(0); double sample1[] = {testSystem.getPressure(), - * testSystem.getTemperature()}; double standardDeviation1[] = {0.01}; // std.dev - * temperature double val = 1.0-Double.parseDouble(dataSet.getString("L1")); double sdev = - * val/100.0; SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); - * sample.setFunction(function); sample.setThermodynamicSystem(testSystem); - * sample.setReference(Double.toString(testSystem.getTemperature())); double - * parameterGuess[] ={3517,-1584, -0.1, -0.44, 0.07};//propane - * function.setInitialGuess(parameterGuess); sampleList.add(sample); } } catch(Exception e){ - * logger.error("database error" + e); } - */ - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + function.setInitialGuess(parameterGuess); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } - // do simulations - optim.solve(); - // optim.runMonteCarloSimulation(); - // optim.displayResult(); - // optim.displayCurveFit(); - optim.displayResult(); - // optim.writeToCdfFile("c:/testFit.nc"); - // optim.writeToTextFile("c:/testFit.txt"); + dataSet = database.getResultSet( + "SELECT * FROM LuciaData8 WHERE Component='nitrogen' AND ID>=1014 AND ID<=1045 AND Temperature<373.0");// AND + // ID<3000 + // AND + // Temperature>250 + // AND + // Pressure<7000000000 + // AND + // Temperature<600 + // AND + // Y<>NULL + // AND + // Y>0.0000000001 + // ORDER + // BY + // Temperature,Pressure");// + // AND + // Reference='Houghton1957' + // AND + // Reference<>'Nighswander1989' + // AND + // Temperature>278.15 + // AND + // Temperature<383.15 + // AND + // Pressure<60.01325"); + try { + int p = 0; + logger.info("adding...."); + while (dataSet.next() && p < 100) { + p++; + BinaryHVParameterFittingToSolubilityData function = + new BinaryHVParameterFittingToSolubilityData(0, 0); + SystemInterface testSystem = + new SystemSrkSchwartzentruberEos(Double.parseDouble(dataSet.getString("Temperature")), + Double.parseDouble(dataSet.getString("Pressure")) / 1e5); + testSystem.addComponent("nitrogen", 10.0); + testSystem.addComponent("water", 1000.0); + testSystem.setMixingRule("HV"); + testSystem.init(0); + double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; + double standardDeviation1[] = {0.01}; + double val = 1.0 - Double.parseDouble(dataSet.getString("Y")); + double sdev = val / 100.0; + SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(Double.toString(testSystem.getTemperature())); + double parameterGuess[] = {4898.64, -111.76};// , -0.1, -0.44};//, 0.07};//propane + function.setInitialGuess(parameterGuess); + sample.setDescription(Double.toString(testSystem.getTemperature())); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); } + /* + * dataSet = database.getResultSet( + * "SELECT * FROM LuciaData8 WHERE Component='propane');// AND Temperature>270 AND Temperature<400 AND Pressure<700000000 AND L1<>NULL ORDER BY Temperature,Pressure" + * );// AND Reference='Houghton1957' AND Reference<>'Nighswander1989' AND Temperature>278.15 AND + * Temperature<383.15 AND Pressure<60.01325"); + * + * try{ int p=0; logger.info("adding...."); while(!dataSet.next() && p<10){ p++; + * BinaryHVParameterFittingToSolubilityData function = new + * BinaryHVParameterFittingToSolubilityData(0,0); + * + * SystemInterface testSystem = new + * SystemSrkSchwartzentruberEos(Double.parseDouble(dataSet.getString( "Temperature")), + * Double.parseDouble(dataSet.getString("Pressure"))/1e5); + * + * testSystem.addComponent("propane", 10.0); testSystem.addComponent("water", 10.0); + * + * //testSystem.createDatabase(true); testSystem.setMixingRule("HV"); + * + * testSystem.init(0); double sample1[] = {testSystem.getPressure(), + * testSystem.getTemperature()}; double standardDeviation1[] = {0.01}; // std.dev temperature + * double val = 1.0-Double.parseDouble(dataSet.getString("L1")); double sdev = val/100.0; + * SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); + * sample.setFunction(function); sample.setThermodynamicSystem(testSystem); + * sample.setReference(Double.toString(testSystem.getTemperature())); double parameterGuess[] + * ={3517,-1584, -0.1, -0.44, 0.07};//propane function.setInitialGuess(parameterGuess); + * sampleList.add(sample); } } catch(Exception e){ logger.error("database error" + e); } + */ + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); + + // do simulations + optim.solve(); + // optim.runMonteCarloSimulation(); + // optim.displayResult(); + // optim.displayCurveFit(); + optim.displayResult(); + // optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityDatawaterCO2.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityDatawaterCO2.java index 0e001e4dff..878c16d8a2 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityDatawaterCO2.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityDatawaterCO2.java @@ -20,121 +20,119 @@ * @version $Id: $Id */ public class TestBinaryHVParameterFittingToSolubilityDatawaterCO2 { - static Logger logger = - LogManager.getLogger(TestBinaryHVParameterFittingToSolubilityDatawaterCO2.class); + static Logger logger = + LogManager.getLogger(TestBinaryHVParameterFittingToSolubilityDatawaterCO2.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); - // inserting samples from database - NeqSimDataBase database = new NeqSimDataBase(); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM CO2watersolubility - // WHERE pressureMPA<6 AND reference IN ('[18]', '[35]', '[36]', '[37]', '[38]', - // '[39]', '[40]', '[41]','[42]')"); + // inserting samples from database + NeqSimDataBase database = new NeqSimDataBase(); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM CO2watersolubility + // WHERE pressureMPA<6 AND reference IN ('[18]', '[35]', '[36]', '[37]', '[38]', + // '[39]', '[40]', '[41]','[42]')"); - ResultSet dataSet = database.getResultSet( - "SELECT * FROM CO2watersolubility WHERE pressureMPA<5 AND reference IN ('[18]', '[35]', '[36]', '[37]', '[38]', '[39]', '[40]', '[41]','[42]', '[32]', '[33]', '[34]')"); + ResultSet dataSet = database.getResultSet( + "SELECT * FROM CO2watersolubility WHERE pressureMPA<5 AND reference IN ('[18]', '[35]', '[36]', '[37]', '[38]', '[39]', '[40]', '[41]','[42]', '[32]', '[33]', '[34]')"); - try { - int p = 0; - while (dataSet.next() && p < 550) { - p++; - BinaryHVParameterFittingToSolubilityData function = - new BinaryHVParameterFittingToSolubilityData(1, 10); + try { + int p = 0; + while (dataSet.next() && p < 550) { + p++; + BinaryHVParameterFittingToSolubilityData function = + new BinaryHVParameterFittingToSolubilityData(1, 10); - SystemInterface testSystem = new SystemSrkSchwartzentruberEos( - (Double.parseDouble(dataSet.getString("temperatureC")) + 273.15), - 10.0 * Double.parseDouble(dataSet.getString("pressureMPA"))); - // SystemInterface testSystem = new - // SystemSrkEos((Double.parseDouble(dataSet.getString("temperatureC"))+273.15), - // Double.parseDouble(dataSet.getString("pressurebar"))); - double valCO2 = Double.parseDouble(dataSet.getString("xCO2")); - testSystem.addComponent("CO2", valCO2); - testSystem.addComponent("water", 100.0 - valCO2); + SystemInterface testSystem = new SystemSrkSchwartzentruberEos( + (Double.parseDouble(dataSet.getString("temperatureC")) + 273.15), + 10.0 * Double.parseDouble(dataSet.getString("pressureMPA"))); + // SystemInterface testSystem = new + // SystemSrkEos((Double.parseDouble(dataSet.getString("temperatureC"))+273.15), + // Double.parseDouble(dataSet.getString("pressurebar"))); + double valCO2 = Double.parseDouble(dataSet.getString("xCO2")); + testSystem.addComponent("CO2", valCO2); + testSystem.addComponent("water", 100.0 - valCO2); - testSystem.createDatabase(true); - testSystem.setMixingRule("HV"); + testSystem.createDatabase(true); + testSystem.setMixingRule("HV"); - testSystem.init(0); - double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; - double standardDeviation1[] = {0.01}; - double val = testSystem.getPressure(); - double sdev = val / 100.0; - SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(Double.toString(testSystem.getTemperature())); - sample.setDescription(dataSet.getString("reference")); - // double parameterGuess[] = {5601.2391787479, -3170.8329162571, -1.7069851770, - // -0.5058509407}; // HV CO2 - double parameterGuess[] = - {5251.7374371982, -3121.2788585048, -0.8420253536, -0.5123316046}; - // double parameterGuess[] ={13694.7303713825, -807.1129937507, -10.4589547972, - // -10.9746096153}; - function.setInitialGuess(parameterGuess); - sampleList.add(sample); - logger.info("liq points " + p); - } - } catch (Exception e) { - logger.error("database error" + e); - } + testSystem.init(0); + double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; + double standardDeviation1[] = {0.01}; + double val = testSystem.getPressure(); + double sdev = val / 100.0; + SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(Double.toString(testSystem.getTemperature())); + sample.setDescription(dataSet.getString("reference")); + // double parameterGuess[] = {5601.2391787479, -3170.8329162571, -1.7069851770, + // -0.5058509407}; // HV CO2 + double parameterGuess[] = {5251.7374371982, -3121.2788585048, -0.8420253536, -0.5123316046}; + // double parameterGuess[] ={13694.7303713825, -807.1129937507, -10.4589547972, + // -10.9746096153}; + function.setInitialGuess(parameterGuess); + sampleList.add(sample); + logger.info("liq points " + p); + } + } catch (Exception e) { + logger.error("database error" + e); + } - dataSet = database.getResultSet( - "SELECT * FROM LuciaData8 WHERE Component='CO2' AND ID<3000 AND Temperature>250 AND Pressure<700000000 AND Temperature<420 AND Y<>NULL AND Y>0.0000000001 ORDER BY Temperature,Pressure"); + dataSet = database.getResultSet( + "SELECT * FROM LuciaData8 WHERE Component='CO2' AND ID<3000 AND Temperature>250 AND Pressure<700000000 AND Temperature<420 AND Y<>NULL AND Y>0.0000000001 ORDER BY Temperature,Pressure"); - try { - int p = 0; - while (!dataSet.next() && p < 100) { - p++; - BinaryHVParameterFittingToSolubilityData function = - new BinaryHVParameterFittingToSolubilityData(0, 0); + try { + int p = 0; + while (!dataSet.next() && p < 100) { + p++; + BinaryHVParameterFittingToSolubilityData function = + new BinaryHVParameterFittingToSolubilityData(0, 0); - SystemInterface testSystem = new SystemSrkSchwartzentruberEos( - Double.parseDouble(dataSet.getString("Temperature")), - Double.parseDouble(dataSet.getString("Pressure")) / 1e5); - testSystem.addComponent("CO2", 1.0); - testSystem.addComponent("water", 10.0); - testSystem.setMixingRule("HV"); + SystemInterface testSystem = + new SystemSrkSchwartzentruberEos(Double.parseDouble(dataSet.getString("Temperature")), + Double.parseDouble(dataSet.getString("Pressure")) / 1e5); + testSystem.addComponent("CO2", 1.0); + testSystem.addComponent("water", 10.0); + testSystem.setMixingRule("HV"); - testSystem.init(0); - double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; - double standardDeviation1[] = {0.01}; - double val = 1.0 - Double.parseDouble(dataSet.getString("Y")); - double sdev = val / 100.0; - SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(Double.toString(testSystem.getTemperature())); - // double parameterGuess[] = {5601.2391787479, -3170.8329162571, -1.7069851770, - // -0.5058509407}; // HV CO2 - double parameterGuess[] = {3626.0, -2241.0, 3.91, -3.16};// ; // HV CO2 - function.setInitialGuess(parameterGuess); - sample.setDescription(Double.toString(testSystem.getTemperature())); - sampleList.add(sample); - logger.info("gas points " + p); - } - } catch (Exception e) { - logger.error("database error" + e); - } + testSystem.init(0); + double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; + double standardDeviation1[] = {0.01}; + double val = 1.0 - Double.parseDouble(dataSet.getString("Y")); + double sdev = val / 100.0; + SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(Double.toString(testSystem.getTemperature())); + // double parameterGuess[] = {5601.2391787479, -3170.8329162571, -1.7069851770, + // -0.5058509407}; // HV CO2 + double parameterGuess[] = {3626.0, -2241.0, 3.91, -3.16};// ; // HV CO2 + function.setInitialGuess(parameterGuess); + sample.setDescription(Double.toString(testSystem.getTemperature())); + sampleList.add(sample); + logger.info("gas points " + p); + } + } catch (Exception e) { + logger.error("database error" + e); + } - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); - // do simulations - // optim.solve(); - // optim.runMonteCarloSimulation(); - // optim.displayResult(); - optim.displayCurveFit(); - // optim.displayResult(); - // optim.writeToCdfFile("c:/testFit.nc"); - // optim.writeToTextFile("c:/testFit.txt"); - } + // do simulations + // optim.solve(); + // optim.runMonteCarloSimulation(); + // optim.displayResult(); + optim.displayCurveFit(); + // optim.displayResult(); + // optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryUMRPRUFittingToSolubilityData.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryUMRPRUFittingToSolubilityData.java index 1d24765025..12b94111c5 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryUMRPRUFittingToSolubilityData.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryUMRPRUFittingToSolubilityData.java @@ -20,284 +20,283 @@ * @version $Id: $Id */ public class TestBinaryUMRPRUFittingToSolubilityData { - static Logger logger = LogManager.getLogger(TestBinaryUMRPRUFittingToSolubilityData.class); - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); - - NeqSimDataBase database = new NeqSimDataBase(); - ResultSet dataSet = database.getResultSet( - "SELECT * FROM binarySolubilityData WHERE ComponentSolute='Hg' AND ComponentSolvent='n-decane'"); - - double parameterGuess[] = {188.385052774267, -0.84022345};// , 2630.871733876947}; - - try { - int p = 0; - logger.info("adding...."); - while (dataSet.next() && p < 31) { - p++; - UMRPRUFunction function = new UMRPRUFunction(); - SystemInterface testSystem = new SystemUMRPRUMCEos(290, 1.0); - testSystem.addComponent("nC10", 10.0); - testSystem.addComponent("mercury", 1.0); - - testSystem.createDatabase(true); - testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); - - testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); - testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); - logger.info("pressure " + testSystem.getPressure()); - testSystem.init(0); - double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; - double standardDeviation1[] = {0.01}; - - SampleValue sample = new SampleValue(Double.parseDouble(dataSet.getString("x1")), - Double.parseDouble(dataSet.getString("StandardDeviation")), sample1, - standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(Double.toString(testSystem.getTemperature())); - function.setInitialGuess(parameterGuess); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } - - dataSet = database.getResultSet( - "SELECT * FROM binarySolubilityData WHERE ComponentSolute='Hg' AND ComponentSolvent='n-heptane'"); - - try { - int p = 0; - logger.info("adding...."); - while (dataSet.next() && p < 60) { - p++; - UMRPRUFunction function = new UMRPRUFunction(); - SystemInterface testSystem = new SystemUMRPRUMCEos(290, 1.0); - testSystem.addComponent("n-heptane", 10.0); - testSystem.addComponent("mercury", 1.0); - - testSystem.createDatabase(true); - testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); - - testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); - testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); - logger.info("pressure " + testSystem.getPressure()); - testSystem.init(0); - double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; - double standardDeviation1[] = {0.01}; - - SampleValue sample = new SampleValue(Double.parseDouble(dataSet.getString("x1")), - Double.parseDouble(dataSet.getString("StandardDeviation")), sample1, - standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(Double.toString(testSystem.getTemperature())); - function.setInitialGuess(parameterGuess); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } - - dataSet = database.getResultSet( - "SELECT * FROM binarySolubilityData WHERE ComponentSolute='Hg' AND ComponentSolvent='n-octane'"); - - try { - int p = 0; - logger.info("adding...."); - while (dataSet.next() && p < 50) { - p++; - UMRPRUFunction function = new UMRPRUFunction(); - SystemInterface testSystem = new SystemUMRPRUMCEos(290, 1.0); - testSystem.addComponent("n-octane", 10.0); - testSystem.addComponent("mercury", 1.0); - - testSystem.createDatabase(true); - testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); - - testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); - testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); - logger.info("pressure " + testSystem.getPressure()); - testSystem.init(0); - double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; - double standardDeviation1[] = {0.01}; - - SampleValue sample = new SampleValue(Double.parseDouble(dataSet.getString("x1")), - Double.parseDouble(dataSet.getString("StandardDeviation")), sample1, - standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(Double.toString(testSystem.getTemperature())); - function.setInitialGuess(parameterGuess); - sampleList.add(sample); - } - } catch (Exception e) { - logger.info("database error" + e); - } - - dataSet = database.getResultSet( - "SELECT * FROM binarySolubilityData WHERE ComponentSolute='Hg' AND ComponentSolvent='n-hexane'"); - - try { - int p = 0; - logger.error("adding...."); - while (dataSet.next() && p < 30) { - p++; - UMRPRUFunction function = new UMRPRUFunction(); - SystemInterface testSystem = new SystemUMRPRUMCEos(290, 1.0); - testSystem.addComponent("n-hexane", 10.0); - testSystem.addComponent("mercury", 1.0); - - testSystem.createDatabase(true); - testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); - - testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); - testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); - logger.info("pressure " + testSystem.getPressure()); - testSystem.init(0); - double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; - double standardDeviation1[] = {0.01}; - - SampleValue sample = new SampleValue(Double.parseDouble(dataSet.getString("x1")), - Double.parseDouble(dataSet.getString("StandardDeviation")), sample1, - standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(Double.toString(testSystem.getTemperature())); - function.setInitialGuess(parameterGuess); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } - - dataSet = database.getResultSet( - "SELECT * FROM binarySolubilityData WHERE ComponentSolute='Hg' AND ComponentSolvent='n-pentane'"); - - try { - int p = 0; - logger.info("adding...."); - while (dataSet.next() && p < 30) { - p++; - UMRPRUFunction function = new UMRPRUFunction(); - SystemInterface testSystem = new SystemUMRPRUMCEos(290, 1.0); - testSystem.addComponent("n-pentane", 10.0); - testSystem.addComponent("mercury", 1.0); - - testSystem.createDatabase(true); - testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); - - testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); - testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); - logger.info("pressure " + testSystem.getPressure()); - testSystem.init(0); - double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; - double standardDeviation1[] = {0.01}; - - SampleValue sample = new SampleValue(Double.parseDouble(dataSet.getString("x1")), - Double.parseDouble(dataSet.getString("StandardDeviation")), sample1, - standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(Double.toString(testSystem.getTemperature())); - function.setInitialGuess(parameterGuess); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } - - dataSet = database.getResultSet( - "SELECT * FROM binarySolubilityData WHERE ComponentSolute='Hg' AND ComponentSolvent='butane'"); - - try { - int p = 0; - logger.info("adding...."); - while (dataSet.next() && p < 30) { - p++; - UMRPRUFunction function = new UMRPRUFunction(); - SystemInterface testSystem = new SystemUMRPRUMCEos(290, 1.0); - testSystem.addComponent("n-butane", 10.0); - testSystem.addComponent("mercury", 1.0); - - testSystem.createDatabase(true); - testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); - - testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); - testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); - logger.info("pressure " + testSystem.getPressure()); - testSystem.init(0); - double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; - double standardDeviation1[] = {0.01}; - - SampleValue sample = new SampleValue(Double.parseDouble(dataSet.getString("x1")), - Double.parseDouble(dataSet.getString("StandardDeviation")), sample1, - standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(Double.toString(testSystem.getTemperature())); - function.setInitialGuess(parameterGuess); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } - - dataSet = database.getResultSet( - "SELECT * FROM binarySolubilityData WHERE ComponentSolute='Hg' AND ComponentSolvent='propane'"); - - try { - int p = 0; - logger.info("adding...."); - while (dataSet.next() && p < 30) { - p++; - UMRPRUFunction function = new UMRPRUFunction(); - SystemInterface testSystem = new SystemUMRPRUMCEos(290, 1.0); - testSystem.addComponent("propane", 10.0); - testSystem.addComponent("mercury", 1.0); - - testSystem.createDatabase(true); - testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); - - testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); - testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); - logger.info("pressure " + testSystem.getPressure()); - testSystem.init(0); - double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; - double standardDeviation1[] = {0.01}; - - SampleValue sample = new SampleValue(Double.parseDouble(dataSet.getString("x1")), - Double.parseDouble(dataSet.getString("StandardDeviation")), sample1, - standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(Double.toString(testSystem.getTemperature())); - function.setInitialGuess(parameterGuess); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } - - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); - - // do simulations - optim.solve(); - // optim.runMonteCarloSimulation(); - // optim.displayResult(); - optim.displayCurveFit(); - optim.displayResult(); - // optim.writeToCdfFile("c:/testFit.nc"); - // optim.writeToTextFile("c:/testFit.txt"); + static Logger logger = LogManager.getLogger(TestBinaryUMRPRUFittingToSolubilityData.class); + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); + + NeqSimDataBase database = new NeqSimDataBase(); + ResultSet dataSet = database.getResultSet( + "SELECT * FROM binarySolubilityData WHERE ComponentSolute='Hg' AND ComponentSolvent='n-decane'"); + + double parameterGuess[] = {188.385052774267, -0.84022345};// , 2630.871733876947}; + + try { + int p = 0; + logger.info("adding...."); + while (dataSet.next() && p < 31) { + p++; + UMRPRUFunction function = new UMRPRUFunction(); + SystemInterface testSystem = new SystemUMRPRUMCEos(290, 1.0); + testSystem.addComponent("nC10", 10.0); + testSystem.addComponent("mercury", 1.0); + + testSystem.createDatabase(true); + testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); + + testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); + testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); + logger.info("pressure " + testSystem.getPressure()); + testSystem.init(0); + double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; + double standardDeviation1[] = {0.01}; + + SampleValue sample = new SampleValue(Double.parseDouble(dataSet.getString("x1")), + Double.parseDouble(dataSet.getString("StandardDeviation")), sample1, + standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(Double.toString(testSystem.getTemperature())); + function.setInitialGuess(parameterGuess); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); } + + dataSet = database.getResultSet( + "SELECT * FROM binarySolubilityData WHERE ComponentSolute='Hg' AND ComponentSolvent='n-heptane'"); + + try { + int p = 0; + logger.info("adding...."); + while (dataSet.next() && p < 60) { + p++; + UMRPRUFunction function = new UMRPRUFunction(); + SystemInterface testSystem = new SystemUMRPRUMCEos(290, 1.0); + testSystem.addComponent("n-heptane", 10.0); + testSystem.addComponent("mercury", 1.0); + + testSystem.createDatabase(true); + testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); + + testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); + testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); + logger.info("pressure " + testSystem.getPressure()); + testSystem.init(0); + double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; + double standardDeviation1[] = {0.01}; + + SampleValue sample = new SampleValue(Double.parseDouble(dataSet.getString("x1")), + Double.parseDouble(dataSet.getString("StandardDeviation")), sample1, + standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(Double.toString(testSystem.getTemperature())); + function.setInitialGuess(parameterGuess); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } + + dataSet = database.getResultSet( + "SELECT * FROM binarySolubilityData WHERE ComponentSolute='Hg' AND ComponentSolvent='n-octane'"); + + try { + int p = 0; + logger.info("adding...."); + while (dataSet.next() && p < 50) { + p++; + UMRPRUFunction function = new UMRPRUFunction(); + SystemInterface testSystem = new SystemUMRPRUMCEos(290, 1.0); + testSystem.addComponent("n-octane", 10.0); + testSystem.addComponent("mercury", 1.0); + + testSystem.createDatabase(true); + testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); + + testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); + testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); + logger.info("pressure " + testSystem.getPressure()); + testSystem.init(0); + double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; + double standardDeviation1[] = {0.01}; + + SampleValue sample = new SampleValue(Double.parseDouble(dataSet.getString("x1")), + Double.parseDouble(dataSet.getString("StandardDeviation")), sample1, + standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(Double.toString(testSystem.getTemperature())); + function.setInitialGuess(parameterGuess); + sampleList.add(sample); + } + } catch (Exception e) { + logger.info("database error" + e); + } + + dataSet = database.getResultSet( + "SELECT * FROM binarySolubilityData WHERE ComponentSolute='Hg' AND ComponentSolvent='n-hexane'"); + + try { + int p = 0; + logger.error("adding...."); + while (dataSet.next() && p < 30) { + p++; + UMRPRUFunction function = new UMRPRUFunction(); + SystemInterface testSystem = new SystemUMRPRUMCEos(290, 1.0); + testSystem.addComponent("n-hexane", 10.0); + testSystem.addComponent("mercury", 1.0); + + testSystem.createDatabase(true); + testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); + + testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); + testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); + logger.info("pressure " + testSystem.getPressure()); + testSystem.init(0); + double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; + double standardDeviation1[] = {0.01}; + + SampleValue sample = new SampleValue(Double.parseDouble(dataSet.getString("x1")), + Double.parseDouble(dataSet.getString("StandardDeviation")), sample1, + standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(Double.toString(testSystem.getTemperature())); + function.setInitialGuess(parameterGuess); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } + + dataSet = database.getResultSet( + "SELECT * FROM binarySolubilityData WHERE ComponentSolute='Hg' AND ComponentSolvent='n-pentane'"); + + try { + int p = 0; + logger.info("adding...."); + while (dataSet.next() && p < 30) { + p++; + UMRPRUFunction function = new UMRPRUFunction(); + SystemInterface testSystem = new SystemUMRPRUMCEos(290, 1.0); + testSystem.addComponent("n-pentane", 10.0); + testSystem.addComponent("mercury", 1.0); + + testSystem.createDatabase(true); + testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); + + testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); + testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); + logger.info("pressure " + testSystem.getPressure()); + testSystem.init(0); + double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; + double standardDeviation1[] = {0.01}; + + SampleValue sample = new SampleValue(Double.parseDouble(dataSet.getString("x1")), + Double.parseDouble(dataSet.getString("StandardDeviation")), sample1, + standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(Double.toString(testSystem.getTemperature())); + function.setInitialGuess(parameterGuess); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } + + dataSet = database.getResultSet( + "SELECT * FROM binarySolubilityData WHERE ComponentSolute='Hg' AND ComponentSolvent='butane'"); + + try { + int p = 0; + logger.info("adding...."); + while (dataSet.next() && p < 30) { + p++; + UMRPRUFunction function = new UMRPRUFunction(); + SystemInterface testSystem = new SystemUMRPRUMCEos(290, 1.0); + testSystem.addComponent("n-butane", 10.0); + testSystem.addComponent("mercury", 1.0); + + testSystem.createDatabase(true); + testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); + + testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); + testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); + logger.info("pressure " + testSystem.getPressure()); + testSystem.init(0); + double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; + double standardDeviation1[] = {0.01}; + + SampleValue sample = new SampleValue(Double.parseDouble(dataSet.getString("x1")), + Double.parseDouble(dataSet.getString("StandardDeviation")), sample1, + standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(Double.toString(testSystem.getTemperature())); + function.setInitialGuess(parameterGuess); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } + + dataSet = database.getResultSet( + "SELECT * FROM binarySolubilityData WHERE ComponentSolute='Hg' AND ComponentSolvent='propane'"); + + try { + int p = 0; + logger.info("adding...."); + while (dataSet.next() && p < 30) { + p++; + UMRPRUFunction function = new UMRPRUFunction(); + SystemInterface testSystem = new SystemUMRPRUMCEos(290, 1.0); + testSystem.addComponent("propane", 10.0); + testSystem.addComponent("mercury", 1.0); + + testSystem.createDatabase(true); + testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); + + testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); + testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); + logger.info("pressure " + testSystem.getPressure()); + testSystem.init(0); + double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; + double standardDeviation1[] = {0.01}; + + SampleValue sample = new SampleValue(Double.parseDouble(dataSet.getString("x1")), + Double.parseDouble(dataSet.getString("StandardDeviation")), sample1, + standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(Double.toString(testSystem.getTemperature())); + function.setInitialGuess(parameterGuess); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } + + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); + + // do simulations + optim.solve(); + // optim.runMonteCarloSimulation(); + // optim.displayResult(); + optim.displayCurveFit(); + optim.displayResult(); + // optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryWSParameterFittingToSolubilityData_Lucia.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryWSParameterFittingToSolubilityData_Lucia.java index 9dd76cf3be..f3d7b244c1 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryWSParameterFittingToSolubilityData_Lucia.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryWSParameterFittingToSolubilityData_Lucia.java @@ -20,191 +20,192 @@ * @version $Id: $Id */ public class TestBinaryWSParameterFittingToSolubilityData_Lucia { - static Logger logger = - LogManager.getLogger(TestBinaryWSParameterFittingToSolubilityData_Lucia.class); - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); - - // inserting samples from database - NeqSimDataBase database = new NeqSimDataBase(); - ResultSet dataSet = database.getResultSet( - "SELECT * FROM LuciaData WHERE Component='methane' AND Temperature<520 AND L2<>NULL AND L2>0.00000001 ORDER BY Temperature,Pressure");// AND - // Reference='Houghton1957' - // AND - // Reference<>'Nighswander1989' - // AND - // Temperature>278.15 - // AND - // Temperature<383.15 - // AND - // Pressure<60.01325"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM LuciaData WHERE - // Component='CO2' AND Temperature>250 AND Temperature<420 AND L2<>NULL AND - // L2>0.00000001 ORDER BY Temperature,Pressure");// AND Reference='Houghton1957' - // AND Reference<>'Nighswander1989' AND Temperature>278.15 AND - // Temperature<383.15 AND Pressure<60.01325"); - - try { - int p = 0; - while (dataSet.next() && p < 100) { - p++; - BinaryWSParameterFittingToSolubilityData function = - new BinaryWSParameterFittingToSolubilityData(); - - // SystemInterface testSystem = new SystemFurstElectrolyteEos(280, 1.0); - SystemInterface testSystem = new SystemSrkSchwartzentruberEos( - Double.parseDouble(dataSet.getString("Temperature")), - Double.parseDouble(dataSet.getString("Pressure")) / 1e5); - // SystemInterface testSystem = new - // SystemSrkEos(Double.parseDouble(dataSet.getString("Temperature")), - // Double.parseDouble(dataSet.getString("Pressure"))/1e5); - // SystemInterface testSystem = new - // SystemPrEos(Double.parseDouble(dataSet.getString("Temperature")), - // Double.parseDouble(dataSet.getString("Pressure"))/1e5); - - // testSystem.addComponent("CO2", 10.0); - testSystem.addComponent("methane", 10.0); - testSystem.addComponent("water", 10.0); - - // testSystem.addComponent("CO2", 1.0); - // testSystem.addComponent("water", 1.0); - // testSystem.addComponent("MDEA", 1.000001); - // testSystem.chemicalReactionInit(); - // testSystem.createDatabase(true); - testSystem.setMixingRule(5); - - // testSystem.getChemicalReactionOperations().solveChemEq(0); - // testSystem.getChemicalReactionOperations().solveChemEq(1); - - // testSystem.isChemicalSystem(false); - - // testSystem.addComponent("NaPlus", 1.0e-10); - // testSystem.addComponent("methane", 1.1); - testSystem.init(0); - double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; - double standardDeviation1[] = {0.01}; - double val = Double.parseDouble(dataSet.getString("L2")); - double sdev = val / 100.0; - SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(Double.toString(testSystem.getTemperature())); - // double parameterGuess[] = {3932.0, -4127.0, -5.89, 8.9}; // HV CO2 - double parameterGuess[] = {4802.7795779589, -440.6638711230, -7.6109236981, - 4.8742002317, 0.1, -0.0420817811}; // HV methan570 - // double parameterGuess[] = {3204.3057406886, -2753.7379912645, -12.4728330162 - // , 13.0150379323}; // HV - // double parameterGuess[] = {8.992E3, -3.244E3, -8.424E0, -1.824E0}; // HV - // double parameterGuess[] = {-7.132E2, -3.933E2};//, 3.96E0, 9.602E-1}; //, - // 1.239}; //WS - function.setInitialGuess(parameterGuess); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } - - dataSet = database.getResultSet( - "SELECT * FROM LuciaData WHERE Component='methane' AND ID<3000 AND Temperature<520 AND Y<>NULL AND Y>0.00000001 ORDER BY Temperature,Pressure");// AND - // Reference='Houghton1957' - // AND - // Reference<>'Nighswander1989' - // AND - // Temperature>278.15 - // AND - // Temperature<383.15 - // AND - // Pressure<60.01325"); - // dataSet = database.getResultSet( "SELECT * FROM LuciaData WHERE - // Component='CO2' AND ID<3000 AND Temperature>250 AND Temperature<420 AND - // Y<>NULL AND Y>0.00000001 ORDER BY Temperature,Pressure");// AND - // Reference='Houghton1957' AND Reference<>'Nighswander1989' AND - // Temperature>278.15 AND Temperature<383.15 AND Pressure<60.01325"); - - // ResultSet dataSet = database.getResultSet( "SELECT * FROM - // activityCoefficientTable WHERE Component1='MDEA' AND Component2='water'"); - // testSystem.addComponent(dataSet.getString("ComponentSolute"), 1.0); - // testSystem.addComponent(dataSet.getString("ComponentSolvent"), 1.0); - try { - int p = 0; - while (dataSet.next() && p < 100) { - p++; - BinaryWSParameterFittingToSolubilityData function = - new BinaryWSParameterFittingToSolubilityData(0, 0); - - // SystemInterface testSystem = new - // SystemFurstElectrolyteEos(Double.parseDouble(dataSet.getString("Temperature")), - // Double.parseDouble(dataSet.getString("Pressure"))/1e5); - SystemInterface testSystem = new SystemSrkSchwartzentruberEos( - Double.parseDouble(dataSet.getString("Temperature")), - Double.parseDouble(dataSet.getString("Pressure")) / 1e5); - // SystemInterface testSystem = new - // SystemSrkEos(Double.parseDouble(dataSet.getString("Temperature")), - // Double.parseDouble(dataSet.getString("Pressure"))/1e5); - // SystemInterface testSystem = new - // SystemPrEos(Double.parseDouble(dataSet.getString("Temperature")), - // Double.parseDouble(dataSet.getString("Pressure"))/1e5); - // testSystem.addComponent("CO2", 10.0); - testSystem.addComponent("methane", 10.0); - testSystem.addComponent("water", 10.0); - - // testSystem.addComponent("CO2", 1.0); - // testSystem.addComponent("water", 1.0); - // testSystem.addComponent("MDEA", 1.000001); - // testSystem.chemicalReactionInit(); - // testSystem.createDatabase(true); - testSystem.setMixingRule(5); - - // testSystem.getChemicalReactionOperations().solveChemEq(0); - // testSystem.getChemicalReactionOperations().solveChemEq(1); - - // testSystem.isChemicalSystem(false); - - // testSystem.addComponent("NaPlus", 1.0e-10); - // testSystem.addComponent("methane", 1.1); - testSystem.init(0); - double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; - double standardDeviation1[] = {0.01}; - double val = 1.0 - Double.parseDouble(dataSet.getString("Y")); - double sdev = val / 100.0; - SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(Double.toString(testSystem.getTemperature())); - // double parameterGuess[] = {3932.0, -4127.0, -5.89, 8.9}; // HV CO2 - double parameterGuess[] = {4802.7795779589, -440.6638711230, -7.6109236981, - 4.8742002317, 0.1, -0.0420817811}; // HV methan570 - // double parameterGuess[] = {3204.3057406886, -2753.7379912645, -12.4728330162 - // , 13.0150379323}; // HV - // double parameterGuess[] = {8.992E3, -3.244E3, -8.424E0, -1.824E0}; // HV - // double parameterGuess[] = {-7.132E2, -3.933E2};//, 3.96E0, 9.602E-1}; //, - // 1.239}; //WS - function.setInitialGuess(parameterGuess); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } - - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); - - // do simulations - optim.solve(); - // optim.runMonteCarloSimulation(); - // optim.displayResult(); - optim.displayCurveFit(); - optim.displayResult(); - // optim.writeToCdfFile("c:/testFit.nc"); - // optim.writeToTextFile("c:/testFit.txt"); + static Logger logger = + LogManager.getLogger(TestBinaryWSParameterFittingToSolubilityData_Lucia.class); + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); + + // inserting samples from database + NeqSimDataBase database = new NeqSimDataBase(); + ResultSet dataSet = database.getResultSet( + "SELECT * FROM LuciaData WHERE Component='methane' AND Temperature<520 AND L2<>NULL AND L2>0.00000001 ORDER BY Temperature,Pressure");// AND + // Reference='Houghton1957' + // AND + // Reference<>'Nighswander1989' + // AND + // Temperature>278.15 + // AND + // Temperature<383.15 + // AND + // Pressure<60.01325"); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM LuciaData WHERE + // Component='CO2' AND Temperature>250 AND Temperature<420 AND L2<>NULL AND + // L2>0.00000001 ORDER BY Temperature,Pressure");// AND Reference='Houghton1957' + // AND Reference<>'Nighswander1989' AND Temperature>278.15 AND + // Temperature<383.15 AND Pressure<60.01325"); + + try { + int p = 0; + while (dataSet.next() && p < 100) { + p++; + BinaryWSParameterFittingToSolubilityData function = + new BinaryWSParameterFittingToSolubilityData(); + + // SystemInterface testSystem = new SystemFurstElectrolyteEos(280, 1.0); + SystemInterface testSystem = + new SystemSrkSchwartzentruberEos(Double.parseDouble(dataSet.getString("Temperature")), + Double.parseDouble(dataSet.getString("Pressure")) / 1e5); + // SystemInterface testSystem = new + // SystemSrkEos(Double.parseDouble(dataSet.getString("Temperature")), + // Double.parseDouble(dataSet.getString("Pressure"))/1e5); + // SystemInterface testSystem = new + // SystemPrEos(Double.parseDouble(dataSet.getString("Temperature")), + // Double.parseDouble(dataSet.getString("Pressure"))/1e5); + + // testSystem.addComponent("CO2", 10.0); + testSystem.addComponent("methane", 10.0); + testSystem.addComponent("water", 10.0); + + // testSystem.addComponent("CO2", 1.0); + // testSystem.addComponent("water", 1.0); + // testSystem.addComponent("MDEA", 1.000001); + // testSystem.chemicalReactionInit(); + // testSystem.createDatabase(true); + testSystem.setMixingRule(5); + + // testSystem.getChemicalReactionOperations().solveChemEq(0); + // testSystem.getChemicalReactionOperations().solveChemEq(1); + + // testSystem.isChemicalSystem(false); + + // testSystem.addComponent("NaPlus", 1.0e-10); + // testSystem.addComponent("methane", 1.1); + testSystem.init(0); + double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; + double standardDeviation1[] = {0.01}; + double val = Double.parseDouble(dataSet.getString("L2")); + double sdev = val / 100.0; + SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(Double.toString(testSystem.getTemperature())); + // double parameterGuess[] = {3932.0, -4127.0, -5.89, 8.9}; // HV CO2 + double parameterGuess[] = + {4802.7795779589, -440.6638711230, -7.6109236981, 4.8742002317, 0.1, -0.0420817811}; // HV + // methan570 + // double parameterGuess[] = {3204.3057406886, -2753.7379912645, -12.4728330162 + // , 13.0150379323}; // HV + // double parameterGuess[] = {8.992E3, -3.244E3, -8.424E0, -1.824E0}; // HV + // double parameterGuess[] = {-7.132E2, -3.933E2};//, 3.96E0, 9.602E-1}; //, + // 1.239}; //WS + function.setInitialGuess(parameterGuess); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); } + + dataSet = database.getResultSet( + "SELECT * FROM LuciaData WHERE Component='methane' AND ID<3000 AND Temperature<520 AND Y<>NULL AND Y>0.00000001 ORDER BY Temperature,Pressure");// AND + // Reference='Houghton1957' + // AND + // Reference<>'Nighswander1989' + // AND + // Temperature>278.15 + // AND + // Temperature<383.15 + // AND + // Pressure<60.01325"); + // dataSet = database.getResultSet( "SELECT * FROM LuciaData WHERE + // Component='CO2' AND ID<3000 AND Temperature>250 AND Temperature<420 AND + // Y<>NULL AND Y>0.00000001 ORDER BY Temperature,Pressure");// AND + // Reference='Houghton1957' AND Reference<>'Nighswander1989' AND + // Temperature>278.15 AND Temperature<383.15 AND Pressure<60.01325"); + + // ResultSet dataSet = database.getResultSet( "SELECT * FROM + // activityCoefficientTable WHERE Component1='MDEA' AND Component2='water'"); + // testSystem.addComponent(dataSet.getString("ComponentSolute"), 1.0); + // testSystem.addComponent(dataSet.getString("ComponentSolvent"), 1.0); + try { + int p = 0; + while (dataSet.next() && p < 100) { + p++; + BinaryWSParameterFittingToSolubilityData function = + new BinaryWSParameterFittingToSolubilityData(0, 0); + + // SystemInterface testSystem = new + // SystemFurstElectrolyteEos(Double.parseDouble(dataSet.getString("Temperature")), + // Double.parseDouble(dataSet.getString("Pressure"))/1e5); + SystemInterface testSystem = + new SystemSrkSchwartzentruberEos(Double.parseDouble(dataSet.getString("Temperature")), + Double.parseDouble(dataSet.getString("Pressure")) / 1e5); + // SystemInterface testSystem = new + // SystemSrkEos(Double.parseDouble(dataSet.getString("Temperature")), + // Double.parseDouble(dataSet.getString("Pressure"))/1e5); + // SystemInterface testSystem = new + // SystemPrEos(Double.parseDouble(dataSet.getString("Temperature")), + // Double.parseDouble(dataSet.getString("Pressure"))/1e5); + // testSystem.addComponent("CO2", 10.0); + testSystem.addComponent("methane", 10.0); + testSystem.addComponent("water", 10.0); + + // testSystem.addComponent("CO2", 1.0); + // testSystem.addComponent("water", 1.0); + // testSystem.addComponent("MDEA", 1.000001); + // testSystem.chemicalReactionInit(); + // testSystem.createDatabase(true); + testSystem.setMixingRule(5); + + // testSystem.getChemicalReactionOperations().solveChemEq(0); + // testSystem.getChemicalReactionOperations().solveChemEq(1); + + // testSystem.isChemicalSystem(false); + + // testSystem.addComponent("NaPlus", 1.0e-10); + // testSystem.addComponent("methane", 1.1); + testSystem.init(0); + double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; + double standardDeviation1[] = {0.01}; + double val = 1.0 - Double.parseDouble(dataSet.getString("Y")); + double sdev = val / 100.0; + SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(Double.toString(testSystem.getTemperature())); + // double parameterGuess[] = {3932.0, -4127.0, -5.89, 8.9}; // HV CO2 + double parameterGuess[] = + {4802.7795779589, -440.6638711230, -7.6109236981, 4.8742002317, 0.1, -0.0420817811}; // HV + // methan570 + // double parameterGuess[] = {3204.3057406886, -2753.7379912645, -12.4728330162 + // , 13.0150379323}; // HV + // double parameterGuess[] = {8.992E3, -3.244E3, -8.424E0, -1.824E0}; // HV + // double parameterGuess[] = {-7.132E2, -3.933E2};//, 3.96E0, 9.602E-1}; //, + // 1.239}; //WS + function.setInitialGuess(parameterGuess); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } + + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); + + // do simulations + optim.solve(); + // optim.runMonteCarloSimulation(); + // optim.displayResult(); + optim.displayCurveFit(); + optim.displayResult(); + // optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestSolidAntoine.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestSolidAntoine.java index 4cb5d76cf0..ce1fb850f0 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestSolidAntoine.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestSolidAntoine.java @@ -20,62 +20,61 @@ * @version $Id: $Id */ public class TestSolidAntoine { - static Logger logger = LogManager.getLogger(TestSolidAntoine.class); + static Logger logger = LogManager.getLogger(TestSolidAntoine.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); - // inserting samples from database - NeqSimDataBase database = new NeqSimDataBase(); + // inserting samples from database + NeqSimDataBase database = new NeqSimDataBase(); - ResultSet dataSet = database.getResultSet( - "SELECT * FROM BinaryFreezingPointData WHERE ComponentSolvent1='MEG' ORDER BY FreezingTemperature"); + ResultSet dataSet = database.getResultSet( + "SELECT * FROM BinaryFreezingPointData WHERE ComponentSolvent1='MEG' ORDER BY FreezingTemperature"); - try { - while (dataSet.next()) { - FreezeSolidFunction function = new FreezeSolidFunction(); - double guess[] = {-7566.84658558, 17.38710706}; // MEG - function.setInitialGuess(guess); + try { + while (dataSet.next()) { + FreezeSolidFunction function = new FreezeSolidFunction(); + double guess[] = {-7566.84658558, 17.38710706}; // MEG + function.setInitialGuess(guess); - SystemInterface testSystem = new SystemSrkSchwartzentruberEos(280, 1.101); - testSystem.addComponent(dataSet.getString("ComponentSolvent1"), - Double.parseDouble(dataSet.getString("x1"))); - testSystem.addComponent(dataSet.getString("ComponentSolvent2"), - Double.parseDouble(dataSet.getString("x2"))); - // testSystem.createDatabase(true); - testSystem.setSolidPhaseCheck(true); - testSystem.setMixingRule(4); - testSystem.init(0); - double sample1[] = {testSystem.getPhase(0).getComponent(0).getz()}; - double standardDeviation1[] = {0.1, 0.1, 0.1}; - double val = Double.parseDouble(dataSet.getString("FreezingTemperature")); - testSystem.setTemperature(val); - SampleValue sample = new SampleValue(val, val / 100.0, sample1, standardDeviation1); - sample.setFunction(function); - sample.setReference(dataSet.getString("Reference")); - sample.setThermodynamicSystem(testSystem); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } + SystemInterface testSystem = new SystemSrkSchwartzentruberEos(280, 1.101); + testSystem.addComponent(dataSet.getString("ComponentSolvent1"), + Double.parseDouble(dataSet.getString("x1"))); + testSystem.addComponent(dataSet.getString("ComponentSolvent2"), + Double.parseDouble(dataSet.getString("x2"))); + // testSystem.createDatabase(true); + testSystem.setSolidPhaseCheck(true); + testSystem.setMixingRule(4); + testSystem.init(0); + double sample1[] = {testSystem.getPhase(0).getComponent(0).getz()}; + double standardDeviation1[] = {0.1, 0.1, 0.1}; + double val = Double.parseDouble(dataSet.getString("FreezingTemperature")); + testSystem.setTemperature(val); + SampleValue sample = new SampleValue(val, val / 100.0, sample1, standardDeviation1); + sample.setFunction(function); + sample.setReference(dataSet.getString("Reference")); + sample.setThermodynamicSystem(testSystem); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); - // do simulations - optim.solve(); - // optim.runMonteCarloSimulation(); - optim.displayCurveFit(); - //optim.writeToCdfFile("c:/testFit.nc"); - optim.writeToTextFile("c:/testFit.txt"); - } + // do simulations + optim.solve(); + // optim.runMonteCarloSimulation(); + optim.displayCurveFit(); + optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFitting.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFitting.java index 6ec81f20eb..974e105fee 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFitting.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFitting.java @@ -20,265 +20,264 @@ * @version $Id: $Id */ public class TestIonicInteractionParameterFitting { - static Logger logger = LogManager.getLogger(TestIonicInteractionParameterFitting.class); + static Logger logger = LogManager.getLogger(TestIonicInteractionParameterFitting.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); - // inserting samples from database - NeqSimDataBase database = new NeqSimDataBase(); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM CO2KurCor WHERE - // Reference<>'Bahiri1984' AND Temperature<373.15 ORDER BY - // wtMDEA,Temperature,Reference,loading"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM CO2KurCor WHERE - // Reference<>'Bahiri1984' AND Temperature<393.15 AND loading>0.05 AND loading<1.2 AND - // VapourPressure1<15.0 AND wtMDEA>40 AND wtMDEA<60 ORDER BY - // wtMDEA,Temperature,Reference,loading"); + // inserting samples from database + NeqSimDataBase database = new NeqSimDataBase(); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM CO2KurCor WHERE + // Reference<>'Bahiri1984' AND Temperature<373.15 ORDER BY + // wtMDEA,Temperature,Reference,loading"); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM CO2KurCor WHERE + // Reference<>'Bahiri1984' AND Temperature<393.15 AND loading>0.05 AND loading<1.2 AND + // VapourPressure1<15.0 AND wtMDEA>40 AND wtMDEA<60 ORDER BY + // wtMDEA,Temperature,Reference,loading"); - // //ResultSet dataSet = database.getResultSet( "SELECT * FROM CO2KurCor WHERE - // Reference<>'Bahiri1984' AND wtMDEA>40.0 AND Temperature>=280.15 AND Temperature<=470.15 - // AND loading>0.00002 AND VapourPressure1<25.0 ORDER BY wtMDEA,Temperature,Reference"); - // // ResultSet dataSet = database.getResultSet( "SELECT * FROM activityCoefficientTable - // WHERE Component1='MDEA' AND Component2='water'");AND Reference='Lemoine2000' - // //ResultSet dataSet = database.getResultSet( "SELECT * FROM CO2KurCor WHERE - // Reference='Austgen1991' AND loading>0.01"); + // //ResultSet dataSet = database.getResultSet( "SELECT * FROM CO2KurCor WHERE + // Reference<>'Bahiri1984' AND wtMDEA>40.0 AND Temperature>=280.15 AND Temperature<=470.15 + // AND loading>0.00002 AND VapourPressure1<25.0 ORDER BY wtMDEA,Temperature,Reference"); + // // ResultSet dataSet = database.getResultSet( "SELECT * FROM activityCoefficientTable + // WHERE Component1='MDEA' AND Component2='water'");AND Reference='Lemoine2000' + // //ResultSet dataSet = database.getResultSet( "SELECT * FROM CO2KurCor WHERE + // Reference='Austgen1991' AND loading>0.01"); - // try{ - // int i=0; - // while(dataSet.next() && i<450){ - // i++; - // IonicInteractionParameterFittingFunction function = new - // IonicInteractionParameterFittingFunction(); - // //IonicInteractionParameterFittingFunction_CO2 function = new + // try{ + // int i=0; + // while(dataSet.next() && i<450){ + // i++; + // IonicInteractionParameterFittingFunction function = new + // IonicInteractionParameterFittingFunction(); + // //IonicInteractionParameterFittingFunction_CO2 function = new + // IonicInteractionParameterFittingFunction_CO2(); + // //double guess[] = {-0.0005842392, 0.0003621714, 0.0481887797, + // 239.2501170265};//{-0.0000629, 0.00001255, 0.05, 240.8165};//, + // 0.311975E-4};//,0.0001439};//, 0.00000001439};//, -0.0000745697};//, 263.73, + // 466.41,0.1,0.1};//, 1.0,1.0};//;{-2.9222e-6, -7.991E-6, 3.924E-6};//,1.0,1.0};//, + // -7.223e-4}; + // //double bounds[][] = + // {{-0.0055,0.0055}};//,{-0.0055,0.0055},{-10.001,10.001},{-1.0015,1.0015},{-320.0015,320.0015},{-320.901,320.900195},{-1.0,1000},{-0.800001,0.8},{-80000.01,20000.8},{-0.01,10.6},{-0.01,0.0015},{-0.01,0.0015}}; + // //double guess[] = {0.0000231069, 0.0001092540, 0.00001046762};//, -0.0001190554};//, + // 1e-3,1e-3,1e-3,1e-3};//, 1110.0e-8};//, 0.0001052339, -0.0001046940};//,-2753.0e-8, + // 13.01e-8};//, 242.6021196937,-7858.0,-36.7816};//, -2753.0e-4, 13.01e-4};//, + // -0.00002653966};//, -0.000000745697};//,-2753.0e-4, 13.01e-4};//, + // 0.0000152542010};//,4.5};//, -2753.0e-4, 13.01e-4};//, 240.2701596331};// + // -2753.7379912645, 13.0150379323};//, -2.5254669805767994E-6};//,0.78000000000};// + // 241.2701596331, 0.8000000000};//, 3.162827E-4, -2.5254669805767994E-4};//, + // 239.2501170265};//, 3.11975E-5}; + // double guess[] = {0.0000260019, -0.0001172396, 0.0000615323, -0.0001285810};//, + // -0.0004677550, -0.0000389863};//, 2.88281314E-4};// detailed reactions + // // -0,0000186524 -0,0000470206 0,0000816440 -0,0001147055 -0,1422977509 -0,0351820850 + // 0,1531978514 -0,0062978601 + // //double guess[] = {0,0041639953 0,0009961457};, + // //double guess[] = {-2753.0e-4, 13.01e-4};// 263.73, -5.717, 8.6}; + // //SystemInterface testSystem = new SystemElectrolyteCPA((273.15+25.0), 1.0); + // SystemInterface testSystem = new SystemFurstElectrolyteEos((273.15+25.0), 1.0); + // testSystem.addComponent("CO2", Double.parseDouble(dataSet.getString("x1"))); + // testSystem.addComponent("MDEA", Double.parseDouble(dataSet.getString("x2"))); + // testSystem.addComponent("water", Double.parseDouble(dataSet.getString("x3"))); + // double temperature = Double.parseDouble(dataSet.getString("Temperature")); + // double pressure = Double.parseDouble(dataSet.getString("VapourPressure1")); + // testSystem.setTemperature(temperature); + // testSystem.setPressure(pressure+1.0); + // testSystem.chemicalReactionInit(); + // // testSystem.createDatabase(true); + // testSystem.setMixingRule(4); + // testSystem.init(0); + // double sample1[] = + // {testSystem.getPhase(0).getComponent(0).getNumberOfmoles()/testSystem.getPhase(0).getComponent(1).getNumberOfmoles()}; + // + // double standardDeviation1[] = {0.01}; + // double stddev = pressure;//Double.parseDouble(dataSet.getString("StandardDeviation")) + // SampleValue sample = new SampleValue(pressure, stddev, sample1, standardDeviation1); + // function.setInitialGuess(guess); + // //function.setBounds(bounds); + // sample.setFunction(function); + // double wtpr = Double.parseDouble(dataSet.getString("wtMDEA")); + // sample.setReference(dataSet.getString("Reference") + " " + temperature); + // sample.setDescription(Double.toString(wtpr)); + // sample.setThermodynamicSystem(testSystem); + // sampleList.add(sample); + // } + // } + // catch(Exception e){ + // logger.error("database error" + e); + // } + + double guess[] = {-0.0001868490, -0.0006868943, -0.0000210224, -0.0002324934, 0.0005}; + ResultSet dataSet = database.getResultSet( + "SELECT * FROM CO2waterMDEA2 WHERE Temperature<'393.15' AND PressureCO2<'20' AND Reference<>'GPA'"); + + try { + int i = 0; + while (dataSet.next() && i < 25) { + int ID = Integer.parseInt(dataSet.getString("ID")); + if ((ID > 56 && ID < 64) || (ID > 92 && ID < 101) || (ID > 123 && ID < 131)) { // 75 + // wt% + // amine + continue; + } + if (ID == 155) { + continue; // AAD >100 + } + if (ID == 29 || ID == 28 || ID == 258) { + continue; // large values of Pexp/Pcalc + } + + i++; + IonicInteractionParameterFittingFunction function = + new IonicInteractionParameterFittingFunction(); + // IonicInteractionParameterFittingFunction_CO2 function = new // IonicInteractionParameterFittingFunction_CO2(); - // //double guess[] = {-0.0005842392, 0.0003621714, 0.0481887797, + // double guess[] = {-0.0005842392, 0.0003621714, 0.0481887797, // 239.2501170265};//{-0.0000629, 0.00001255, 0.05, 240.8165};//, // 0.311975E-4};//,0.0001439};//, 0.00000001439};//, -0.0000745697};//, 263.73, - // 466.41,0.1,0.1};//, 1.0,1.0};//;{-2.9222e-6, -7.991E-6, 3.924E-6};//,1.0,1.0};//, - // -7.223e-4}; - // //double bounds[][] = + // 466.41,0.1,0.1};//, 1.0,1.0};//;{-2.9222e-6, -7.991E-6, + // 3.924E-6};//,1.0,1.0};//, -7.223e-4}; + // double bounds[][] = // {{-0.0055,0.0055}};//,{-0.0055,0.0055},{-10.001,10.001},{-1.0015,1.0015},{-320.0015,320.0015},{-320.901,320.900195},{-1.0,1000},{-0.800001,0.8},{-80000.01,20000.8},{-0.01,10.6},{-0.01,0.0015},{-0.01,0.0015}}; - // //double guess[] = {0.0000231069, 0.0001092540, 0.00001046762};//, -0.0001190554};//, - // 1e-3,1e-3,1e-3,1e-3};//, 1110.0e-8};//, 0.0001052339, -0.0001046940};//,-2753.0e-8, - // 13.01e-8};//, 242.6021196937,-7858.0,-36.7816};//, -2753.0e-4, 13.01e-4};//, + // double guess[] = {0.0000231069, 0.0001092540, 0.00001046762};//, + // -0.0001190554};//, 1e-3,1e-3,1e-3,1e-3};//, 1110.0e-8};//, 0.0001052339, + // -0.0001046940};//,-2753.0e-8, 13.01e-8};//, + // 242.6021196937,-7858.0,-36.7816};//, -2753.0e-4, 13.01e-4};//, // -0.00002653966};//, -0.000000745697};//,-2753.0e-4, 13.01e-4};//, // 0.0000152542010};//,4.5};//, -2753.0e-4, 13.01e-4};//, 240.2701596331};// - // -2753.7379912645, 13.0150379323};//, -2.5254669805767994E-6};//,0.78000000000};// - // 241.2701596331, 0.8000000000};//, 3.162827E-4, -2.5254669805767994E-4};//, + // -2753.7379912645, 13.0150379323};//, + // -2.5254669805767994E-6};//,0.78000000000};// 241.2701596331, + // 0.8000000000};//, 3.162827E-4, -2.5254669805767994E-4};//, // 239.2501170265};//, 3.11975E-5}; - // double guess[] = {0.0000260019, -0.0001172396, 0.0000615323, -0.0001285810};//, - // -0.0004677550, -0.0000389863};//, 2.88281314E-4};// detailed reactions - // // -0,0000186524 -0,0000470206 0,0000816440 -0,0001147055 -0,1422977509 -0,0351820850 - // 0,1531978514 -0,0062978601 - // //double guess[] = {0,0041639953 0,0009961457};, - // //double guess[] = {-2753.0e-4, 13.01e-4};// 263.73, -5.717, 8.6}; - // //SystemInterface testSystem = new SystemElectrolyteCPA((273.15+25.0), 1.0); - // SystemInterface testSystem = new SystemFurstElectrolyteEos((273.15+25.0), 1.0); - // testSystem.addComponent("CO2", Double.parseDouble(dataSet.getString("x1"))); - // testSystem.addComponent("MDEA", Double.parseDouble(dataSet.getString("x2"))); - // testSystem.addComponent("water", Double.parseDouble(dataSet.getString("x3"))); - // double temperature = Double.parseDouble(dataSet.getString("Temperature")); - // double pressure = Double.parseDouble(dataSet.getString("VapourPressure1")); - // testSystem.setTemperature(temperature); - // testSystem.setPressure(pressure+1.0); - // testSystem.chemicalReactionInit(); - // // testSystem.createDatabase(true); - // testSystem.setMixingRule(4); - // testSystem.init(0); - // double sample1[] = - // {testSystem.getPhase(0).getComponent(0).getNumberOfmoles()/testSystem.getPhase(0).getComponent(1).getNumberOfmoles()}; - // - // double standardDeviation1[] = {0.01}; - // double stddev = pressure;//Double.parseDouble(dataSet.getString("StandardDeviation")) - // SampleValue sample = new SampleValue(pressure, stddev, sample1, standardDeviation1); - // function.setInitialGuess(guess); - // //function.setBounds(bounds); - // sample.setFunction(function); - // double wtpr = Double.parseDouble(dataSet.getString("wtMDEA")); - // sample.setReference(dataSet.getString("Reference") + " " + temperature); - // sample.setDescription(Double.toString(wtpr)); - // sample.setThermodynamicSystem(testSystem); - // sampleList.add(sample); - // } - // } - // catch(Exception e){ - // logger.error("database error" + e); - // } - - double guess[] = {-0.0001868490, -0.0006868943, -0.0000210224, -0.0002324934, 0.0005}; - ResultSet dataSet = database.getResultSet( - "SELECT * FROM CO2waterMDEA2 WHERE Temperature<'393.15' AND PressureCO2<'20' AND Reference<>'GPA'"); + // double guess[] = {0.0000260019, -0.0001172396, 0.0000615323, + // -0.0001285810};//, -0.0004677550, -0.0000389863};//, 2.88281314E-4};// + // detailed reactions + // -0,0000186524 -0,0000470206 0,0000816440 -0,0001147055 -0,1422977509 + // -0,0351820850 0,1531978514 -0,0062978601 + // double guess[] = {0,0041639953 0,0009961457};, + // double guess[] = {-2753.0e-4, 13.01e-4};// 263.73, -5.717, 8.6}; + // SystemInterface testSystem = new SystemElectrolyteCPA((273.15+25.0), 1.0); + SystemInterface testSystem = new SystemFurstElectrolyteEos((273.15 + 25.0), 1.0); + testSystem.addComponent("CO2", Double.parseDouble(dataSet.getString("x1"))); + testSystem.addComponent("MDEA", Double.parseDouble(dataSet.getString("x3"))); + testSystem.addComponent("water", Double.parseDouble(dataSet.getString("x2"))); + double temperature = Double.parseDouble(dataSet.getString("Temperature")); + double pressure = Double.parseDouble(dataSet.getString("PressureCO2")); + testSystem.setTemperature(temperature); + testSystem.setPressure(pressure + 1.0); + testSystem.chemicalReactionInit(); + // testSystem.createDatabase(true); + testSystem.setMixingRule(4); + testSystem.init(0); + double sample1[] = {testSystem.getPhase(0).getComponent(0).getNumberOfmoles() + / testSystem.getPhase(0).getComponent(1).getNumberOfmoles()}; + double standardDeviation1[] = {0.01}; + double stddev = pressure;// Double.parseDouble(dataSet.getString("StandardDeviation")) + SampleValue sample = new SampleValue(pressure, stddev, sample1, standardDeviation1); + function.setInitialGuess(guess); + // function.setBounds(bounds); + sample.setFunction(function); + sample.setReference(dataSet.getString("Reference")); + sample.setThermodynamicSystem(testSystem); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } - try { - int i = 0; - while (dataSet.next() && i < 25) { - int ID = Integer.parseInt(dataSet.getString("ID")); - if ((ID > 56 && ID < 64) || (ID > 92 && ID < 101) || (ID > 123 && ID < 131)) { // 75 - // wt% - // amine - continue; - } - if (ID == 155) { - continue; // AAD >100 - } - if (ID == 29 || ID == 28 || ID == 258) { - continue; // large values of Pexp/Pcalc - } + dataSet = database.getResultSet( + "SELECT * FROM CO2waterMDEA2 WHERE Temperature<'393.15' AND Pressure<'20' AND Reference<>'GPA'"); - i++; - IonicInteractionParameterFittingFunction function = - new IonicInteractionParameterFittingFunction(); - // IonicInteractionParameterFittingFunction_CO2 function = new - // IonicInteractionParameterFittingFunction_CO2(); - // double guess[] = {-0.0005842392, 0.0003621714, 0.0481887797, - // 239.2501170265};//{-0.0000629, 0.00001255, 0.05, 240.8165};//, - // 0.311975E-4};//,0.0001439};//, 0.00000001439};//, -0.0000745697};//, 263.73, - // 466.41,0.1,0.1};//, 1.0,1.0};//;{-2.9222e-6, -7.991E-6, - // 3.924E-6};//,1.0,1.0};//, -7.223e-4}; - // double bounds[][] = - // {{-0.0055,0.0055}};//,{-0.0055,0.0055},{-10.001,10.001},{-1.0015,1.0015},{-320.0015,320.0015},{-320.901,320.900195},{-1.0,1000},{-0.800001,0.8},{-80000.01,20000.8},{-0.01,10.6},{-0.01,0.0015},{-0.01,0.0015}}; - // double guess[] = {0.0000231069, 0.0001092540, 0.00001046762};//, - // -0.0001190554};//, 1e-3,1e-3,1e-3,1e-3};//, 1110.0e-8};//, 0.0001052339, - // -0.0001046940};//,-2753.0e-8, 13.01e-8};//, - // 242.6021196937,-7858.0,-36.7816};//, -2753.0e-4, 13.01e-4};//, - // -0.00002653966};//, -0.000000745697};//,-2753.0e-4, 13.01e-4};//, - // 0.0000152542010};//,4.5};//, -2753.0e-4, 13.01e-4};//, 240.2701596331};// - // -2753.7379912645, 13.0150379323};//, - // -2.5254669805767994E-6};//,0.78000000000};// 241.2701596331, - // 0.8000000000};//, 3.162827E-4, -2.5254669805767994E-4};//, - // 239.2501170265};//, 3.11975E-5}; - // double guess[] = {0.0000260019, -0.0001172396, 0.0000615323, - // -0.0001285810};//, -0.0004677550, -0.0000389863};//, 2.88281314E-4};// - // detailed reactions - // -0,0000186524 -0,0000470206 0,0000816440 -0,0001147055 -0,1422977509 - // -0,0351820850 0,1531978514 -0,0062978601 - // double guess[] = {0,0041639953 0,0009961457};, - // double guess[] = {-2753.0e-4, 13.01e-4};// 263.73, -5.717, 8.6}; - // SystemInterface testSystem = new SystemElectrolyteCPA((273.15+25.0), 1.0); - SystemInterface testSystem = new SystemFurstElectrolyteEos((273.15 + 25.0), 1.0); - testSystem.addComponent("CO2", Double.parseDouble(dataSet.getString("x1"))); - testSystem.addComponent("MDEA", Double.parseDouble(dataSet.getString("x3"))); - testSystem.addComponent("water", Double.parseDouble(dataSet.getString("x2"))); - double temperature = Double.parseDouble(dataSet.getString("Temperature")); - double pressure = Double.parseDouble(dataSet.getString("PressureCO2")); - testSystem.setTemperature(temperature); - testSystem.setPressure(pressure + 1.0); - testSystem.chemicalReactionInit(); - // testSystem.createDatabase(true); - testSystem.setMixingRule(4); - testSystem.init(0); - double sample1[] = {testSystem.getPhase(0).getComponent(0).getNumberOfmoles() - / testSystem.getPhase(0).getComponent(1).getNumberOfmoles()}; - double standardDeviation1[] = {0.01}; - double stddev = pressure;// Double.parseDouble(dataSet.getString("StandardDeviation")) - SampleValue sample = new SampleValue(pressure, stddev, sample1, standardDeviation1); - function.setInitialGuess(guess); - // function.setBounds(bounds); - sample.setFunction(function); - sample.setReference(dataSet.getString("Reference")); - sample.setThermodynamicSystem(testSystem); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); + try { + int i = 0; + while (dataSet.next() && i < 2) { + int ID = Integer.parseInt(dataSet.getString("ID")); + if ((ID > 56 && ID < 64) || (ID > 92 && ID < 101) || (ID > 123 && ID < 131)) { // 75 + // wt% + // amine + continue; } - - dataSet = database.getResultSet( - "SELECT * FROM CO2waterMDEA2 WHERE Temperature<'393.15' AND Pressure<'20' AND Reference<>'GPA'"); - - try { - int i = 0; - while (dataSet.next() && i < 2) { - int ID = Integer.parseInt(dataSet.getString("ID")); - if ((ID > 56 && ID < 64) || (ID > 92 && ID < 101) || (ID > 123 && ID < 131)) { // 75 - // wt% - // amine - continue; - } - if (ID == 155) { - continue; // AAD >100 - } - if (ID == 29 || ID == 28 || ID == 258) { - continue; // large values of Pexp/Pcalc - } - - i++; - IonicInteractionParameterFittingFunction_1 function = - new IonicInteractionParameterFittingFunction_1(); - // IonicInteractionParameterFittingFunction_CO2 function = new - // IonicInteractionParameterFittingFunction_CO2(); - // double guess[] = {-0.0005842392, 0.0003621714, 0.0481887797, - // 239.2501170265};//{-0.0000629, 0.00001255, 0.05, 240.8165};//, - // 0.311975E-4};//,0.0001439};//, 0.00000001439};//, -0.0000745697};//, 263.73, - // 466.41,0.1,0.1};//, 1.0,1.0};//;{-2.9222e-6, -7.991E-6, - // 3.924E-6};//,1.0,1.0};//, -7.223e-4}; - // double bounds[][] = - // {{-0.0055,0.0055}};//,{-0.0055,0.0055},{-10.001,10.001},{-1.0015,1.0015},{-320.0015,320.0015},{-320.901,320.900195},{-1.0,1000},{-0.800001,0.8},{-80000.01,20000.8},{-0.01,10.6},{-0.01,0.0015},{-0.01,0.0015}}; - // double guess[] = {0.0000231069, 0.0001092540, 0.00001046762};//, - // -0.0001190554};//, 1e-3,1e-3,1e-3,1e-3};//, 1110.0e-8};//, 0.0001052339, - // -0.0001046940};//,-2753.0e-8, 13.01e-8};//, - // 242.6021196937,-7858.0,-36.7816};//, -2753.0e-4, 13.01e-4};//, - // -0.00002653966};//, -0.000000745697};//,-2753.0e-4, 13.01e-4};//, - // 0.0000152542010};//,4.5};//, -2753.0e-4, 13.01e-4};//, 240.2701596331};// - // -2753.7379912645, 13.0150379323};//, - // -2.5254669805767994E-6};//,0.78000000000};// 241.2701596331, - // 0.8000000000};//, 3.162827E-4, -2.5254669805767994E-4};//, - // 239.2501170265};//, 3.11975E-5}; - // double guess[] = {0.0000260019, -0.0001172396, 0.0000615323, - // -0.0001285810};//, -0.0004677550, -0.0000389863};//, 2.88281314E-4};// - // detailed reactions - // -0,0000186524 -0,0000470206 0,0000816440 -0,0001147055 -0,1422977509 - // -0,0351820850 0,1531978514 -0,0062978601 - // double guess[] = {0,0041639953 0,0009961457};, - // double guess[] = {-2753.0e-4, 13.01e-4};// 263.73, -5.717, 8.6}; - // SystemInterface testSystem = new SystemElectrolyteCPA((273.15+25.0), 1.0); - SystemInterface testSystem = new SystemFurstElectrolyteEos((273.15 + 25.0), 1.0); - testSystem.addComponent("CO2", Double.parseDouble(dataSet.getString("x1"))); - testSystem.addComponent("MDEA", Double.parseDouble(dataSet.getString("x3"))); - testSystem.addComponent("water", Double.parseDouble(dataSet.getString("x2"))); - double temperature = Double.parseDouble(dataSet.getString("Temperature")); - double pressure = Double.parseDouble(dataSet.getString("Pressure")); - testSystem.setTemperature(temperature); - testSystem.setPressure(pressure); - testSystem.chemicalReactionInit(); - // testSystem.createDatabase(true); - testSystem.setMixingRule(4); - testSystem.init(0); - double sample1[] = {testSystem.getPhase(0).getComponent(0).getNumberOfmoles() - / testSystem.getPhase(0).getComponent(1).getNumberOfmoles()}; - double standardDeviation1[] = {0.01}; - double stddev = pressure;// Double.parseDouble(dataSet.getString("StandardDeviation")) - SampleValue sample = new SampleValue(pressure, stddev, sample1, standardDeviation1); - function.setInitialGuess(guess); - // function.setBounds(bounds); - sample.setFunction(function); - sample.setReference(dataSet.getString("Reference")); - sample.setThermodynamicSystem(testSystem); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); + if (ID == 155) { + continue; // AAD >100 + } + if (ID == 29 || ID == 28 || ID == 258) { + continue; // large values of Pexp/Pcalc } - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + i++; + IonicInteractionParameterFittingFunction_1 function = + new IonicInteractionParameterFittingFunction_1(); + // IonicInteractionParameterFittingFunction_CO2 function = new + // IonicInteractionParameterFittingFunction_CO2(); + // double guess[] = {-0.0005842392, 0.0003621714, 0.0481887797, + // 239.2501170265};//{-0.0000629, 0.00001255, 0.05, 240.8165};//, + // 0.311975E-4};//,0.0001439};//, 0.00000001439};//, -0.0000745697};//, 263.73, + // 466.41,0.1,0.1};//, 1.0,1.0};//;{-2.9222e-6, -7.991E-6, + // 3.924E-6};//,1.0,1.0};//, -7.223e-4}; + // double bounds[][] = + // {{-0.0055,0.0055}};//,{-0.0055,0.0055},{-10.001,10.001},{-1.0015,1.0015},{-320.0015,320.0015},{-320.901,320.900195},{-1.0,1000},{-0.800001,0.8},{-80000.01,20000.8},{-0.01,10.6},{-0.01,0.0015},{-0.01,0.0015}}; + // double guess[] = {0.0000231069, 0.0001092540, 0.00001046762};//, + // -0.0001190554};//, 1e-3,1e-3,1e-3,1e-3};//, 1110.0e-8};//, 0.0001052339, + // -0.0001046940};//,-2753.0e-8, 13.01e-8};//, + // 242.6021196937,-7858.0,-36.7816};//, -2753.0e-4, 13.01e-4};//, + // -0.00002653966};//, -0.000000745697};//,-2753.0e-4, 13.01e-4};//, + // 0.0000152542010};//,4.5};//, -2753.0e-4, 13.01e-4};//, 240.2701596331};// + // -2753.7379912645, 13.0150379323};//, + // -2.5254669805767994E-6};//,0.78000000000};// 241.2701596331, + // 0.8000000000};//, 3.162827E-4, -2.5254669805767994E-4};//, + // 239.2501170265};//, 3.11975E-5}; + // double guess[] = {0.0000260019, -0.0001172396, 0.0000615323, + // -0.0001285810};//, -0.0004677550, -0.0000389863};//, 2.88281314E-4};// + // detailed reactions + // -0,0000186524 -0,0000470206 0,0000816440 -0,0001147055 -0,1422977509 + // -0,0351820850 0,1531978514 -0,0062978601 + // double guess[] = {0,0041639953 0,0009961457};, + // double guess[] = {-2753.0e-4, 13.01e-4};// 263.73, -5.717, 8.6}; + // SystemInterface testSystem = new SystemElectrolyteCPA((273.15+25.0), 1.0); + SystemInterface testSystem = new SystemFurstElectrolyteEos((273.15 + 25.0), 1.0); + testSystem.addComponent("CO2", Double.parseDouble(dataSet.getString("x1"))); + testSystem.addComponent("MDEA", Double.parseDouble(dataSet.getString("x3"))); + testSystem.addComponent("water", Double.parseDouble(dataSet.getString("x2"))); + double temperature = Double.parseDouble(dataSet.getString("Temperature")); + double pressure = Double.parseDouble(dataSet.getString("Pressure")); + testSystem.setTemperature(temperature); + testSystem.setPressure(pressure); + testSystem.chemicalReactionInit(); + // testSystem.createDatabase(true); + testSystem.setMixingRule(4); + testSystem.init(0); + double sample1[] = {testSystem.getPhase(0).getComponent(0).getNumberOfmoles() + / testSystem.getPhase(0).getComponent(1).getNumberOfmoles()}; + double standardDeviation1[] = {0.01}; + double stddev = pressure;// Double.parseDouble(dataSet.getString("StandardDeviation")) + SampleValue sample = new SampleValue(pressure, stddev, sample1, standardDeviation1); + function.setInitialGuess(guess); + // function.setBounds(bounds); + sample.setFunction(function); + sample.setReference(dataSet.getString("Reference")); + sample.setThermodynamicSystem(testSystem); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } - // do simulations + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); - optim.solve(); - // optim.runMonteCarloSimulation(); - // optim.displayCurveFit(); - // optim.displayGraph(); - optim.displayCurveFit(); - //optim.writeToCdfFile("c:/testFit.nc"); - optim.writeToTextFile("c:/testFit.txt"); - } + // do simulations + + optim.solve(); + // optim.runMonteCarloSimulation(); + // optim.displayCurveFit(); + // optim.displayGraph(); + optim.displayCurveFit(); + optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingCH4.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingCH4.java index 1c40cf4dd9..8b13b7e1e6 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingCH4.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingCH4.java @@ -20,141 +20,138 @@ * @version $Id: $Id */ public class TestIonicInteractionParameterFittingCH4 { - static Logger logger = LogManager.getLogger(TestIonicInteractionParameterFittingCH4.class); + static Logger logger = LogManager.getLogger(TestIonicInteractionParameterFittingCH4.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); - // inserting samples from database - NeqSimDataBase database = new NeqSimDataBase(); - ResultSet dataSet = database.getResultSet("SELECT * FROM Co2Ch4MDEA WHERE loading<1.9");// AND - // temperature=313.15 - // AND - // pressure<210 - // AND - // wt=30"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM - // activityCoefficientTable WHERE Component1='MDEA' AND Component2='water'");AND - // Reference='Lemoine2000' - double guess[] = {-0.0001617266, 0.5 * 1e-3};// , -0.0932324951};//, 0.6465043774,}; - // -0,0001550096 0,0007612383 + // inserting samples from database + NeqSimDataBase database = new NeqSimDataBase(); + ResultSet dataSet = database.getResultSet("SELECT * FROM Co2Ch4MDEA WHERE loading<1.9");// AND + // temperature=313.15 + // AND + // pressure<210 + // AND + // wt=30"); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM + // activityCoefficientTable WHERE Component1='MDEA' AND Component2='water'");AND + // Reference='Lemoine2000' + double guess[] = {-0.0001617266, 0.5 * 1e-3};// , -0.0932324951};//, 0.6465043774,}; + // -0,0001550096 0,0007612383 - // double guess[] = {-0.0000309356,-0.1469925592,-0.0272808384}; + // double guess[] = {-0.0000309356,-0.1469925592,-0.0272808384}; - try { - int i = 0; - while (dataSet.next() && i < 100) { - i++; - IonicInteractionParameterFittingFunctionCH4 function = - new IonicInteractionParameterFittingFunctionCH4(); + try { + int i = 0; + while (dataSet.next() && i < 100) { + i++; + IonicInteractionParameterFittingFunctionCH4 function = + new IonicInteractionParameterFittingFunctionCH4(); - SystemInterface testSystem = new SystemFurstElectrolyteEos((273.15 + 25.0), 100.0); - testSystem.addComponent(dataSet.getString("gass2"), - Double.parseDouble(dataSet.getString("molCH4"))); - testSystem.addComponent(dataSet.getString("gass1"), - Double.parseDouble(dataSet.getString("molCO2"))); - testSystem.addComponent(dataSet.getString("liquid1"), - Double.parseDouble(dataSet.getString("molMDEA"))); - testSystem.addComponent(dataSet.getString("liquid2"), - Double.parseDouble(dataSet.getString("molWater"))); + SystemInterface testSystem = new SystemFurstElectrolyteEos((273.15 + 25.0), 100.0); + testSystem.addComponent(dataSet.getString("gass2"), + Double.parseDouble(dataSet.getString("molCH4"))); + testSystem.addComponent(dataSet.getString("gass1"), + Double.parseDouble(dataSet.getString("molCO2"))); + testSystem.addComponent(dataSet.getString("liquid1"), + Double.parseDouble(dataSet.getString("molMDEA"))); + testSystem.addComponent(dataSet.getString("liquid2"), + Double.parseDouble(dataSet.getString("molWater"))); - double temperature = Double.parseDouble(dataSet.getString("Temperature")); - double pressure = Double.parseDouble(dataSet.getString("Pressure")); - testSystem.setPressure(pressure); - testSystem.setTemperature(temperature); - testSystem.chemicalReactionInit(); - // testSystem.createDatabase(true); - testSystem.setMixingRule(4); - testSystem.init(0); - double sample1[] = {testSystem.getPhases()[0].getComponents()[0] - .getNumberOfMolesInPhase() - / testSystem.getPhases()[0].getComponents()[2].getNumberOfMolesInPhase()}; - double standardDeviation1[] = {0.01}; + double temperature = Double.parseDouble(dataSet.getString("Temperature")); + double pressure = Double.parseDouble(dataSet.getString("Pressure")); + testSystem.setPressure(pressure); + testSystem.setTemperature(temperature); + testSystem.chemicalReactionInit(); + // testSystem.createDatabase(true); + testSystem.setMixingRule(4); + testSystem.init(0); + double sample1[] = {testSystem.getPhases()[0].getComponents()[0].getNumberOfMolesInPhase() + / testSystem.getPhases()[0].getComponents()[2].getNumberOfMolesInPhase()}; + double standardDeviation1[] = {0.01}; - SampleValue sample = - new SampleValue(pressure, pressure / 100.0, sample1, standardDeviation1); - function.setInitialGuess(guess); - sample.setFunction(function); - sample.setReference("addicks"); - sample.setDescription(Double.toString(pressure)); - sample.setThermodynamicSystem(testSystem); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } - // dataSet = database.getResultSet( "SELECT * FROM Co2Ch4MDEA WHERE loading<1.9 - // AND temperature<453.15 AND pressure<210 AND wt<70"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM - // activityCoefficientTable WHERE Component1='MDEA' AND Component2='water'");AND - // Reference='Lemoine2000' - dataSet = database.getResultSet("SELECT * FROM Co2Ch4MDEA WHERE loading<1.9");// AND - // temperature=313.15 - // AND - // pressure<210 - // AND - // wt=50"); - try { - int i = 0; - while (!dataSet.next() && i < 100) { - i++; - IonicInteractionParameterFittingFunctionCH4_1 function = - new IonicInteractionParameterFittingFunctionCH4_1(); + SampleValue sample = + new SampleValue(pressure, pressure / 100.0, sample1, standardDeviation1); + function.setInitialGuess(guess); + sample.setFunction(function); + sample.setReference("addicks"); + sample.setDescription(Double.toString(pressure)); + sample.setThermodynamicSystem(testSystem); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } + // dataSet = database.getResultSet( "SELECT * FROM Co2Ch4MDEA WHERE loading<1.9 + // AND temperature<453.15 AND pressure<210 AND wt<70"); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM + // activityCoefficientTable WHERE Component1='MDEA' AND Component2='water'");AND + // Reference='Lemoine2000' + dataSet = database.getResultSet("SELECT * FROM Co2Ch4MDEA WHERE loading<1.9");// AND + // temperature=313.15 + // AND + // pressure<210 + // AND + // wt=50"); + try { + int i = 0; + while (!dataSet.next() && i < 100) { + i++; + IonicInteractionParameterFittingFunctionCH4_1 function = + new IonicInteractionParameterFittingFunctionCH4_1(); - SystemInterface testSystem = new SystemFurstElectrolyteEos((273.15 + 25.0), 100.0); - testSystem.addComponent(dataSet.getString("gass2"), - Double.parseDouble(dataSet.getString("molCH4"))); - testSystem.addComponent(dataSet.getString("gass1"), - Double.parseDouble(dataSet.getString("molCO2"))); - testSystem.addComponent(dataSet.getString("liquid1"), - Double.parseDouble(dataSet.getString("molMDEA"))); - testSystem.addComponent(dataSet.getString("liquid2"), - Double.parseDouble(dataSet.getString("molWater"))); + SystemInterface testSystem = new SystemFurstElectrolyteEos((273.15 + 25.0), 100.0); + testSystem.addComponent(dataSet.getString("gass2"), + Double.parseDouble(dataSet.getString("molCH4"))); + testSystem.addComponent(dataSet.getString("gass1"), + Double.parseDouble(dataSet.getString("molCO2"))); + testSystem.addComponent(dataSet.getString("liquid1"), + Double.parseDouble(dataSet.getString("molMDEA"))); + testSystem.addComponent(dataSet.getString("liquid2"), + Double.parseDouble(dataSet.getString("molWater"))); - double temperature = Double.parseDouble(dataSet.getString("Temperature")); - double pressure = Double.parseDouble(dataSet.getString("Pressure")); - testSystem.setPressure(pressure); - testSystem.setTemperature(temperature); - testSystem.chemicalReactionInit(); - // testSystem.createDatabase(true); - testSystem.setMixingRule(4); - testSystem.init(0); - double sample1[] = {testSystem.getPhases()[0].getComponents()[1] - .getNumberOfMolesInPhase() - / testSystem.getPhases()[0].getComponents()[2].getNumberOfMolesInPhase()}; - double standardDeviation1[] = {0.01}; - double y1 = Double.parseDouble(dataSet.getString("y1")); - SampleValue sample = new SampleValue(pressure * y1, y1 * pressure / 100.0, sample1, - standardDeviation1); - function.setInitialGuess(guess); - sample.setFunction(function); - sample.setReference("addicks"); - sample.setDescription(Double.toString(pressure)); - sample.setThermodynamicSystem(testSystem); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + double temperature = Double.parseDouble(dataSet.getString("Temperature")); + double pressure = Double.parseDouble(dataSet.getString("Pressure")); + testSystem.setPressure(pressure); + testSystem.setTemperature(temperature); + testSystem.chemicalReactionInit(); + // testSystem.createDatabase(true); + testSystem.setMixingRule(4); + testSystem.init(0); + double sample1[] = {testSystem.getPhases()[0].getComponents()[1].getNumberOfMolesInPhase() + / testSystem.getPhases()[0].getComponents()[2].getNumberOfMolesInPhase()}; + double standardDeviation1[] = {0.01}; + double y1 = Double.parseDouble(dataSet.getString("y1")); + SampleValue sample = + new SampleValue(pressure * y1, y1 * pressure / 100.0, sample1, standardDeviation1); + function.setInitialGuess(guess); + sample.setFunction(function); + sample.setReference("addicks"); + sample.setDescription(Double.toString(pressure)); + sample.setThermodynamicSystem(testSystem); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); - // do simulations + // do simulations - optim.solve(); - // optim.runMonteCarloSimulation(); - // optim.displayCurveFit(); - // optim.displayGraph(); - optim.displayCurveFit(); - //optim.writeToCdfFile("c:/testFit.nc"); - optim.writeToTextFile("c:/testFit.txt"); - } + optim.solve(); + // optim.runMonteCarloSimulation(); + // optim.displayCurveFit(); + // optim.displayGraph(); + optim.displayCurveFit(); + optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingCo2nacl.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingCo2nacl.java index 0e64b4c7b5..e4f7f46921 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingCo2nacl.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingCo2nacl.java @@ -20,80 +20,78 @@ * @version $Id: $Id */ public class TestIonicInteractionParameterFittingCo2nacl { - static Logger logger = LogManager.getLogger(TestIonicInteractionParameterFittingCo2nacl.class); + static Logger logger = LogManager.getLogger(TestIonicInteractionParameterFittingCo2nacl.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); - // inserting samples from database - NeqSimDataBase database = new NeqSimDataBase(); - ResultSet dataSet = database.getResultSet( - "SELECT * FROM co2wation WHERE comp3='K+' AND temperature>340 AND pressure<190"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM - // activityCoefficientTable WHERE Component1='MDEA' AND Component2='water'");AND - // Reference='Lemoine2000' - // double guess[] = {-0.0000110329, -0.1238487876};//Na+ - // double guess[] = {0.0000258505};//Na+ all temp - // double guess[] = {0.0000080642};//Na+ 40 - // double guess[] = {0.0000542456};//Na+ 80 - // double guess[] = { -0.0000442947, -0.1933846606};//k+ - // double guess[] = {-0.00000650867};//k+ 40 - double guess[] = {0.0000267226};// k+ 80 + // inserting samples from database + NeqSimDataBase database = new NeqSimDataBase(); + ResultSet dataSet = database.getResultSet( + "SELECT * FROM co2wation WHERE comp3='K+' AND temperature>340 AND pressure<190"); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM + // activityCoefficientTable WHERE Component1='MDEA' AND Component2='water'");AND + // Reference='Lemoine2000' + // double guess[] = {-0.0000110329, -0.1238487876};//Na+ + // double guess[] = {0.0000258505};//Na+ all temp + // double guess[] = {0.0000080642};//Na+ 40 + // double guess[] = {0.0000542456};//Na+ 80 + // double guess[] = { -0.0000442947, -0.1933846606};//k+ + // double guess[] = {-0.00000650867};//k+ 40 + double guess[] = {0.0000267226};// k+ 80 - try { - int i = 0; - while (dataSet.next() && i < 403) { - i++; - IonicInteractionParameterFittingFunctionCo2nacl function = - new IonicInteractionParameterFittingFunctionCo2nacl(); - double temperature = Double.parseDouble(dataSet.getString("temperature")); - double pressure = Double.parseDouble(dataSet.getString("pressure")); - SystemInterface testSystem = new SystemFurstElectrolyteEos(temperature, pressure); - testSystem.addComponent("CO2", 10.1); - testSystem.addComponent("water", 1.0, "kg/sec"); - testSystem.addComponent(dataSet.getString("comp3"), - Double.parseDouble(dataSet.getString("x3-molal"))); - testSystem.addComponent(dataSet.getString("comp4"), - Double.parseDouble(dataSet.getString("x4-molal"))); - // testSystem.createDatabase(true); - testSystem.setPressure(pressure); - testSystem.setTemperature(temperature); - testSystem.setMixingRule(4); - testSystem.init(0); - double sample1[] = {pressure}; - double standardDeviation1[] = {0.01}; - double value = Double.parseDouble(dataSet.getString("x1-molfrac")); - SampleValue sample = - new SampleValue(value, value / 100.0, sample1, standardDeviation1); - function.setInitialGuess(guess); - sample.setFunction(function); - sample.setDescription(Double.toString(pressure)); - sample.setThermodynamicSystem(testSystem); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } + try { + int i = 0; + while (dataSet.next() && i < 403) { + i++; + IonicInteractionParameterFittingFunctionCo2nacl function = + new IonicInteractionParameterFittingFunctionCo2nacl(); + double temperature = Double.parseDouble(dataSet.getString("temperature")); + double pressure = Double.parseDouble(dataSet.getString("pressure")); + SystemInterface testSystem = new SystemFurstElectrolyteEos(temperature, pressure); + testSystem.addComponent("CO2", 10.1); + testSystem.addComponent("water", 1.0, "kg/sec"); + testSystem.addComponent(dataSet.getString("comp3"), + Double.parseDouble(dataSet.getString("x3-molal"))); + testSystem.addComponent(dataSet.getString("comp4"), + Double.parseDouble(dataSet.getString("x4-molal"))); + // testSystem.createDatabase(true); + testSystem.setPressure(pressure); + testSystem.setTemperature(temperature); + testSystem.setMixingRule(4); + testSystem.init(0); + double sample1[] = {pressure}; + double standardDeviation1[] = {0.01}; + double value = Double.parseDouble(dataSet.getString("x1-molfrac")); + SampleValue sample = new SampleValue(value, value / 100.0, sample1, standardDeviation1); + function.setInitialGuess(guess); + sample.setFunction(function); + sample.setDescription(Double.toString(pressure)); + sample.setThermodynamicSystem(testSystem); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); - // do simulations + // do simulations - optim.solve(); - // optim.runMonteCarloSimulation(); - // optim.displayCurveFit(); - // optim.displayGraph(); - optim.displayCurveFit(); - //optim.writeToCdfFile("c:/testFit.nc"); - optim.writeToTextFile("c:/testFit.txt"); - } + optim.solve(); + // optim.runMonteCarloSimulation(); + // optim.displayCurveFit(); + // optim.displayGraph(); + optim.displayCurveFit(); + optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingMDEAPiperazine.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingMDEAPiperazine.java index 7cdc44652e..adf2e7f0b1 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingMDEAPiperazine.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingMDEAPiperazine.java @@ -20,75 +20,74 @@ * @version $Id: $Id */ public class TestIonicInteractionParameterFittingMDEAPiperazine { - static Logger logger = - LogManager.getLogger(TestIonicInteractionParameterFittingMDEAPiperazine.class); + static Logger logger = + LogManager.getLogger(TestIonicInteractionParameterFittingMDEAPiperazine.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); - // inserting samples from database - NeqSimDataBase database = new NeqSimDataBase(); + // inserting samples from database + NeqSimDataBase database = new NeqSimDataBase(); - double guess[] = {0.0007757516};// , -0.00013534324};//, -0.000210224};//, -0.0002324934, - // 0.0005}; - ResultSet dataSet = database.getResultSet("SELECT * FROM CO2waterPZ");// WHERE - // Temperature<393.15 - // AND - // PressureCO2<4"); + double guess[] = {0.0007757516};// , -0.00013534324};//, -0.000210224};//, -0.0002324934, + // 0.0005}; + ResultSet dataSet = database.getResultSet("SELECT * FROM CO2waterPZ");// WHERE + // Temperature<393.15 + // AND + // PressureCO2<4"); - try { - int i = 0; - while (dataSet.next() && i < 25) { - i++; - IonicInteractionParameterFittingFunctionPiperazine function = - new IonicInteractionParameterFittingFunctionPiperazine(); - SystemInterface testSystem = new SystemFurstElectrolyteEos((273.15 + 25.0), 1.0); - testSystem.addComponent("CO2", Double.parseDouble(dataSet.getString("x1"))); - testSystem.addComponent("Piperazine", Double.parseDouble(dataSet.getString("x3"))); - testSystem.addComponent("water", Double.parseDouble(dataSet.getString("x2"))); - double temperature = Double.parseDouble(dataSet.getString("Temperature")); - double pressure = Double.parseDouble(dataSet.getString("PressureCO2")); - testSystem.setTemperature(temperature); - testSystem.setPressure(pressure + 1.0); - testSystem.chemicalReactionInit(); - testSystem.createDatabase(true); - testSystem.setMixingRule(4); - testSystem.init(0); - double sample1[] = {testSystem.getPhase(0).getComponent(0).getNumberOfmoles() - / testSystem.getPhase(0).getComponent(1).getNumberOfmoles()}; - double standardDeviation1[] = {0.01}; - double stddev = pressure;// Double.parseDouble(dataSet.getString("StandardDeviation")) - SampleValue sample = new SampleValue(pressure, stddev, sample1, standardDeviation1); - function.setInitialGuess(guess); - // function.setBounds(bounds); - sample.setFunction(function); - sample.setReference(dataSet.getString("Reference")); - sample.setThermodynamicSystem(testSystem); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } + try { + int i = 0; + while (dataSet.next() && i < 25) { + i++; + IonicInteractionParameterFittingFunctionPiperazine function = + new IonicInteractionParameterFittingFunctionPiperazine(); + SystemInterface testSystem = new SystemFurstElectrolyteEos((273.15 + 25.0), 1.0); + testSystem.addComponent("CO2", Double.parseDouble(dataSet.getString("x1"))); + testSystem.addComponent("Piperazine", Double.parseDouble(dataSet.getString("x3"))); + testSystem.addComponent("water", Double.parseDouble(dataSet.getString("x2"))); + double temperature = Double.parseDouble(dataSet.getString("Temperature")); + double pressure = Double.parseDouble(dataSet.getString("PressureCO2")); + testSystem.setTemperature(temperature); + testSystem.setPressure(pressure + 1.0); + testSystem.chemicalReactionInit(); + testSystem.createDatabase(true); + testSystem.setMixingRule(4); + testSystem.init(0); + double sample1[] = {testSystem.getPhase(0).getComponent(0).getNumberOfmoles() + / testSystem.getPhase(0).getComponent(1).getNumberOfmoles()}; + double standardDeviation1[] = {0.01}; + double stddev = pressure;// Double.parseDouble(dataSet.getString("StandardDeviation")) + SampleValue sample = new SampleValue(pressure, stddev, sample1, standardDeviation1); + function.setInitialGuess(guess); + // function.setBounds(bounds); + sample.setFunction(function); + sample.setReference(dataSet.getString("Reference")); + sample.setThermodynamicSystem(testSystem); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); - // do simulations + // do simulations - optim.solve(); - // optim.runMonteCarloSimulation(); - // optim.displayCurveFit(); - // optim.displayGraph(); - optim.displayCurveFit(); - //optim.writeToCdfFile("c:/testFit.nc"); - optim.writeToTextFile("c:/testFit.txt"); - } + optim.solve(); + // optim.runMonteCarloSimulation(); + // optim.displayCurveFit(); + // optim.displayGraph(); + optim.displayCurveFit(); + optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingPiperazine.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingPiperazine.java index d8cacfb957..7558c1b264 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingPiperazine.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingPiperazine.java @@ -20,75 +20,73 @@ * @version $Id: $Id */ public class TestIonicInteractionParameterFittingPiperazine { - static Logger logger = - LogManager.getLogger(TestIonicInteractionParameterFittingPiperazine.class); + static Logger logger = LogManager.getLogger(TestIonicInteractionParameterFittingPiperazine.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); - // inserting samples from database - NeqSimDataBase database = new NeqSimDataBase(); + // inserting samples from database + NeqSimDataBase database = new NeqSimDataBase(); - double guess[] = {-0.0001868490, -0.0006868943, -0.0000210224, -0.0002324934, 0.0005}; - ResultSet dataSet = database.getResultSet("SELECT * FROM CO2waterMDEAPiperazine");// WHERE - // Temperature<393.15 - // AND - // PressureCO2<4"); + double guess[] = {-0.0001868490, -0.0006868943, -0.0000210224, -0.0002324934, 0.0005}; + ResultSet dataSet = database.getResultSet("SELECT * FROM CO2waterMDEAPiperazine");// WHERE + // Temperature<393.15 + // AND + // PressureCO2<4"); - try { - int i = 0; - while (dataSet.next() && i < 16) { - i++; - IonicInteractionParameterFittingFunction function = - new IonicInteractionParameterFittingFunction(); - SystemInterface testSystem = new SystemFurstElectrolyteEos((273.15 + 25.0), 1.0); - testSystem.addComponent("CO2", Double.parseDouble(dataSet.getString("x1"))); - testSystem.addComponent("MDEA", Double.parseDouble(dataSet.getString("x3"))); - testSystem.addComponent("piperazine", Double.parseDouble(dataSet.getString("x4"))); - testSystem.addComponent("water", Double.parseDouble(dataSet.getString("x2"))); - double temperature = Double.parseDouble(dataSet.getString("Temperature")); - double pressure = Double.parseDouble(dataSet.getString("PressureCO2")); - testSystem.setTemperature(temperature); - testSystem.setPressure(pressure + 1.0); - testSystem.chemicalReactionInit(); - testSystem.createDatabase(true); - testSystem.setMixingRule(4); - testSystem.init(0); - double sample1[] = {testSystem.getPhase(0).getComponent(0).getNumberOfmoles() - / testSystem.getPhase(0).getComponent(1).getNumberOfmoles()}; - double standardDeviation1[] = {0.01}; - double stddev = pressure;// Double.parseDouble(dataSet.getString("StandardDeviation")) - SampleValue sample = new SampleValue(pressure, stddev, sample1, standardDeviation1); - function.setInitialGuess(guess); - // function.setBounds(bounds); - sample.setFunction(function); - sample.setReference(dataSet.getString("Reference")); - sample.setThermodynamicSystem(testSystem); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } + try { + int i = 0; + while (dataSet.next() && i < 16) { + i++; + IonicInteractionParameterFittingFunction function = + new IonicInteractionParameterFittingFunction(); + SystemInterface testSystem = new SystemFurstElectrolyteEos((273.15 + 25.0), 1.0); + testSystem.addComponent("CO2", Double.parseDouble(dataSet.getString("x1"))); + testSystem.addComponent("MDEA", Double.parseDouble(dataSet.getString("x3"))); + testSystem.addComponent("piperazine", Double.parseDouble(dataSet.getString("x4"))); + testSystem.addComponent("water", Double.parseDouble(dataSet.getString("x2"))); + double temperature = Double.parseDouble(dataSet.getString("Temperature")); + double pressure = Double.parseDouble(dataSet.getString("PressureCO2")); + testSystem.setTemperature(temperature); + testSystem.setPressure(pressure + 1.0); + testSystem.chemicalReactionInit(); + testSystem.createDatabase(true); + testSystem.setMixingRule(4); + testSystem.init(0); + double sample1[] = {testSystem.getPhase(0).getComponent(0).getNumberOfmoles() + / testSystem.getPhase(0).getComponent(1).getNumberOfmoles()}; + double standardDeviation1[] = {0.01}; + double stddev = pressure;// Double.parseDouble(dataSet.getString("StandardDeviation")) + SampleValue sample = new SampleValue(pressure, stddev, sample1, standardDeviation1); + function.setInitialGuess(guess); + // function.setBounds(bounds); + sample.setFunction(function); + sample.setReference(dataSet.getString("Reference")); + sample.setThermodynamicSystem(testSystem); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); - // do simulations + // do simulations - // optim.solve(); - // optim.runMonteCarloSimulation(); - // optim.displayCurveFit(); - // optim.displayGraph(); - optim.displayCurveFit(); - //optim.writeToCdfFile("c:/testFit.nc"); - optim.writeToTextFile("c:/testFit.txt"); - } + // optim.solve(); + // optim.runMonteCarloSimulation(); + // optim.displayCurveFit(); + // optim.displayGraph(); + optim.displayCurveFit(); + optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/AntoineParameter/TestSolidAntoine.java b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/AntoineParameter/TestSolidAntoine.java index 34d5798660..faede50677 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/AntoineParameter/TestSolidAntoine.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/AntoineParameter/TestSolidAntoine.java @@ -20,67 +20,66 @@ * @version $Id: $Id */ public class TestSolidAntoine { - static Logger logger = LogManager.getLogger(TestSolidAntoine.class); + static Logger logger = LogManager.getLogger(TestSolidAntoine.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); - // inserting samples from database - NeqSimDataBase database = new NeqSimDataBase(); + // inserting samples from database + NeqSimDataBase database = new NeqSimDataBase(); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM - // BinaryFreezingPointData WHERE ComponentSolvent1='MEG' ORDER BY - // FreezingTemperature"); - ResultSet dataSet = database.getResultSet( - "SELECT * FROM BinaryFreezingPointData WHERE ComponentSolvent1='MEG' ORDER BY FreezingTemperature"); - int i = 0; - try { - while (dataSet.next() && i < 4) { - i++; - AntoineSolidFunction function = new AntoineSolidFunction(); - double guess[] = {-7800.0, 10.09}; // MEG - function.setInitialGuess(guess); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM + // BinaryFreezingPointData WHERE ComponentSolvent1='MEG' ORDER BY + // FreezingTemperature"); + ResultSet dataSet = database.getResultSet( + "SELECT * FROM BinaryFreezingPointData WHERE ComponentSolvent1='MEG' ORDER BY FreezingTemperature"); + int i = 0; + try { + while (dataSet.next() && i < 4) { + i++; + AntoineSolidFunction function = new AntoineSolidFunction(); + double guess[] = {-7800.0, 10.09}; // MEG + function.setInitialGuess(guess); - SystemInterface testSystem = new SystemSrkCPAstatoil(280, 1.101); - testSystem.addComponent(dataSet.getString("ComponentSolvent1"), - Double.parseDouble(dataSet.getString("x1"))); - testSystem.addComponent(dataSet.getString("ComponentSolvent2"), - Double.parseDouble(dataSet.getString("x2"))); - testSystem.createDatabase(true); - testSystem.setMixingRule(7); + SystemInterface testSystem = new SystemSrkCPAstatoil(280, 1.101); + testSystem.addComponent(dataSet.getString("ComponentSolvent1"), + Double.parseDouble(dataSet.getString("x1"))); + testSystem.addComponent(dataSet.getString("ComponentSolvent2"), + Double.parseDouble(dataSet.getString("x2"))); + testSystem.createDatabase(true); + testSystem.setMixingRule(7); - testSystem.setSolidPhaseCheck("MEG"); - testSystem.init(0); - double sample1[] = {testSystem.getPhase(0).getComponent(0).getz()}; - double standardDeviation1[] = {0.1, 0.1, 0.1}; - double val = Double.parseDouble(dataSet.getString("FreezingTemperature")); - testSystem.setTemperature(val); - SampleValue sample = new SampleValue(val, val / 100.0, sample1, standardDeviation1); - sample.setFunction(function); - sample.setReference(dataSet.getString("Reference")); - sample.setThermodynamicSystem(testSystem); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } + testSystem.setSolidPhaseCheck("MEG"); + testSystem.init(0); + double sample1[] = {testSystem.getPhase(0).getComponent(0).getz()}; + double standardDeviation1[] = {0.1, 0.1, 0.1}; + double val = Double.parseDouble(dataSet.getString("FreezingTemperature")); + testSystem.setTemperature(val); + SampleValue sample = new SampleValue(val, val / 100.0, sample1, standardDeviation1); + sample.setFunction(function); + sample.setReference(dataSet.getString("Reference")); + sample.setThermodynamicSystem(testSystem); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); - // do simulations - // optim.solve(); - // optim.runMonteCarloSimulation(); - optim.displayCurveFit(); - //optim.writeToCdfFile("c:/testFit.nc"); - //optim.writeToTextFile("c:/testFit.txt"); - } + // do simulations + // optim.solve(); + // optim.runMonteCarloSimulation(); + optim.displayCurveFit(); + // optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/AntoineParameter/TestSolidAntoine_S8.java b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/AntoineParameter/TestSolidAntoine_S8.java index abf8f636f9..abe8b1c2df 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/AntoineParameter/TestSolidAntoine_S8.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/AntoineParameter/TestSolidAntoine_S8.java @@ -20,59 +20,58 @@ * @version $Id: $Id */ public class TestSolidAntoine_S8 { - static Logger logger = LogManager.getLogger(TestSolidAntoine_S8.class); + static Logger logger = LogManager.getLogger(TestSolidAntoine_S8.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); - // inserting samples from database - NeqSimDataBase database = new NeqSimDataBase(); + // inserting samples from database + NeqSimDataBase database = new NeqSimDataBase(); - ResultSet dataSet = database.getResultSet( - "SELECT * FROM PureComponentVapourPressures WHERE ComponentName='S8' AND VapourPressure<100"); + ResultSet dataSet = database.getResultSet( + "SELECT * FROM PureComponentVapourPressures WHERE ComponentName='S8' AND VapourPressure<100"); - try { - while (dataSet.next()) { - AntoineSolidFunctionS8 function = new AntoineSolidFunctionS8(); - // double guess[] = {8.046, -4600.0, -144.0}; // S8 - double guess[] = {1.181E1, -8.356E3}; // S8 - function.setInitialGuess(guess); + try { + while (dataSet.next()) { + AntoineSolidFunctionS8 function = new AntoineSolidFunctionS8(); + // double guess[] = {8.046, -4600.0, -144.0}; // S8 + double guess[] = {1.181E1, -8.356E3}; // S8 + function.setInitialGuess(guess); - SystemInterface testSystem = new SystemSrkEos(280, 0.001); - testSystem.addComponent(dataSet.getString("ComponentName"), 100.0); + SystemInterface testSystem = new SystemSrkEos(280, 0.001); + testSystem.addComponent(dataSet.getString("ComponentName"), 100.0); - double sample1[] = {Double.parseDouble(dataSet.getString("Temperature"))}; - double vappres = Double.parseDouble(dataSet.getString("VapourPressure")); - double standardDeviation1[] = {0.15}; - SampleValue sample = new SampleValue(vappres, - Double.parseDouble(dataSet.getString("StandardDeviation")), sample1, - standardDeviation1); - sample.setFunction(function); + double sample1[] = {Double.parseDouble(dataSet.getString("Temperature"))}; + double vappres = Double.parseDouble(dataSet.getString("VapourPressure")); + double standardDeviation1[] = {0.15}; + SampleValue sample = + new SampleValue(vappres, Double.parseDouble(dataSet.getString("StandardDeviation")), + sample1, standardDeviation1); + sample.setFunction(function); - function.setInitialGuess(guess); - sample.setThermodynamicSystem(testSystem); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } + function.setInitialGuess(guess); + sample.setThermodynamicSystem(testSystem); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); - // do simulations - optim.solve(); - // optim.runMonteCarloSimulation(); - optim.displayCurveFit(); - //optim.writeToCdfFile("c:/testFit.nc"); - //optim.writeToTextFile("c:/testFit.txt"); - } + // do simulations + optim.solve(); + // optim.runMonteCarloSimulation(); + optim.displayCurveFit(); + // optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestAcentricSchwartzentruber.java b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestAcentricSchwartzentruber.java index 92a6c4c0fe..2258531f7b 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestAcentricSchwartzentruber.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestAcentricSchwartzentruber.java @@ -20,85 +20,84 @@ * @version $Id: $Id */ public class TestAcentricSchwartzentruber { - static Logger logger = LogManager.getLogger(TestAcentricSchwartzentruber.class); + static Logger logger = LogManager.getLogger(TestAcentricSchwartzentruber.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); - // inserting samples from database - NeqSimDataBase database = new NeqSimDataBase(); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM - // PureComponentVapourPressures WHERE ComponentName='water' ORDER BY - // Reference,Temperature"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM - // PureComponentVapourPressures WHERE ComponentName='Piperazine'"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM - // PureComponentVapourPressures WHERE ComponentName='MDEA' ORDER BY - // Reference,Temperature"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM - // PureComponentVapourPressures WHERE ComponentName='MEG' ORDER BY - // Reference,Temperature"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM - // PureComponentVapourPressures WHERE ComponentName='nitrogen' AND - // VapourPressure<20"); - ResultSet dataSet = database.getResultSet( - "SELECT * FROM PureComponentVapourPressures WHERE ComponentName='mercury' AND VapourPressure<40 ORDER BY Reference,Temperature"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM - // PureComponentVapourPressures WHERE ComponentName='TEG' AND VapourPressure<0.5 - // ORDER BY Reference,Temperature"); - try { - while (dataSet.next()) { - // AcentricFunctionScwartzentruber function = new - // AcentricFunctionScwartzentruber(); - TwuCoon function = new TwuCoon(); - // MathiasCopeman function = new MathiasCopeman(); - // double guess[] = {0.0547834254, 0.0946785127, -2.2673294034}; // water - // double guess[] = {0.00492, 0.00492, -0.00626}; // MDEA - // double guess[] = {0.1662109957e-10, -11.5970369560e-10, 13.5388889636e-10}; - // // CO2 - // double guess[] ={0.0685841688, 0.9851816962, 4.2394590417} ; //mercury HYSYS - // - Pc=1608bara + // inserting samples from database + NeqSimDataBase database = new NeqSimDataBase(); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM + // PureComponentVapourPressures WHERE ComponentName='water' ORDER BY + // Reference,Temperature"); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM + // PureComponentVapourPressures WHERE ComponentName='Piperazine'"); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM + // PureComponentVapourPressures WHERE ComponentName='MDEA' ORDER BY + // Reference,Temperature"); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM + // PureComponentVapourPressures WHERE ComponentName='MEG' ORDER BY + // Reference,Temperature"); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM + // PureComponentVapourPressures WHERE ComponentName='nitrogen' AND + // VapourPressure<20"); + ResultSet dataSet = database.getResultSet( + "SELECT * FROM PureComponentVapourPressures WHERE ComponentName='mercury' AND VapourPressure<40 ORDER BY Reference,Temperature"); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM + // PureComponentVapourPressures WHERE ComponentName='TEG' AND VapourPressure<0.5 + // ORDER BY Reference,Temperature"); + try { + while (dataSet.next()) { + // AcentricFunctionScwartzentruber function = new + // AcentricFunctionScwartzentruber(); + TwuCoon function = new TwuCoon(); + // MathiasCopeman function = new MathiasCopeman(); + // double guess[] = {0.0547834254, 0.0946785127, -2.2673294034}; // water + // double guess[] = {0.00492, 0.00492, -0.00626}; // MDEA + // double guess[] = {0.1662109957e-10, -11.5970369560e-10, 13.5388889636e-10}; + // // CO2 + // double guess[] ={0.0685841688, 0.9851816962, 4.2394590417} ; //mercury HYSYS + // - Pc=1608bara - double guess[] = {0.09245, 0.9784, 2.244}; - // double guess[] ={0.1208932305, 0.9580163852, 0.9875864928} ; //mercury PROII - - // double guess[] = {0.4563609446};//, -140.87783836,44.122}; // nitrogen - function.setInitialGuess(guess); + double guess[] = {0.09245, 0.9784, 2.244}; + // double guess[] ={0.1208932305, 0.9580163852, 0.9875864928} ; //mercury PROII - + // double guess[] = {0.4563609446};//, -140.87783836,44.122}; // nitrogen + function.setInitialGuess(guess); - // SystemInterface testSystem = new SystemSrkSchwartzentruberEos(280, 0.101); - SystemInterface testSystem = new SystemSrkTwuCoonParamEos(280, 0.01); - // SystemInterface testSystem = new SystemPrEos1978(280, 0.01); - // testSystem.setAttractiveTerm(13); - testSystem.addComponent(dataSet.getString("ComponentName"), 100.0); - // testSystem.createDatabase(true); - double sample1[] = {Double.parseDouble(dataSet.getString("Temperature"))}; - double standardDeviation1[] = {0.1, 0.1, 0.1}; - double val = Math.log(Double.parseDouble(dataSet.getString("VapourPressure"))); - SampleValue sample = new SampleValue(val, val / 100.0, sample1, standardDeviation1); - sample.setFunction(function); - sample.setReference(dataSet.getString("Reference")); - sample.setThermodynamicSystem(testSystem); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } + // SystemInterface testSystem = new SystemSrkSchwartzentruberEos(280, 0.101); + SystemInterface testSystem = new SystemSrkTwuCoonParamEos(280, 0.01); + // SystemInterface testSystem = new SystemPrEos1978(280, 0.01); + // testSystem.setAttractiveTerm(13); + testSystem.addComponent(dataSet.getString("ComponentName"), 100.0); + // testSystem.createDatabase(true); + double sample1[] = {Double.parseDouble(dataSet.getString("Temperature"))}; + double standardDeviation1[] = {0.1, 0.1, 0.1}; + double val = Math.log(Double.parseDouble(dataSet.getString("VapourPressure"))); + SampleValue sample = new SampleValue(val, val / 100.0, sample1, standardDeviation1); + sample.setFunction(function); + sample.setReference(dataSet.getString("Reference")); + sample.setThermodynamicSystem(testSystem); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); + } - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); - // do simulations - // optim.solve(); - optim.runMonteCarloSimulation(); - optim.displayCurveFit(); - // optim.writeToCdfFile("c:/testFit.nc"); - // optim.writeToTextFile("c:/testFit.txt"); - } + // do simulations + // optim.solve(); + optim.runMonteCarloSimulation(); + optim.displayCurveFit(); + // optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestFitToAntoineVapPres.java b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestFitToAntoineVapPres.java index bcda35d3ef..792041e5e3 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestFitToAntoineVapPres.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestFitToAntoineVapPres.java @@ -18,66 +18,62 @@ * @version $Id: $Id */ public class TestFitToAntoineVapPres { - static Logger logger = LogManager.getLogger(TestFitToAntoineVapPres.class); + static Logger logger = LogManager.getLogger(TestFitToAntoineVapPres.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - @SuppressWarnings("unused") - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); - try { - for (int i = 0; i < 30; i++) { - AcentricFunctionScwartzentruber function = new AcentricFunctionScwartzentruber(); - // double guess[] = {0.5212918734, -1.1520807481, -0.0138898820}; // Piperazine - double guess[] = {0.1032, 0.00365, -2.064}; // AceticAcid - function.setInitialGuess(guess); + try { + for (int i = 0; i < 30; i++) { + AcentricFunctionScwartzentruber function = new AcentricFunctionScwartzentruber(); + // double guess[] = {0.5212918734, -1.1520807481, -0.0138898820}; // Piperazine + double guess[] = {0.1032, 0.00365, -2.064}; // AceticAcid + function.setInitialGuess(guess); - SystemInterface testSystem = - new SystemSrkSchwartzentruberEos(273.15 + i * 5, 1.101); - // testSystem.addComponent("Piperazine", 100.0); - testSystem.addComponent("AceticAcid", 100.0); - testSystem.createDatabase(true); - testSystem.setMixingRule(0); + SystemInterface testSystem = new SystemSrkSchwartzentruberEos(273.15 + i * 5, 1.101); + // testSystem.addComponent("Piperazine", 100.0); + testSystem.addComponent("AceticAcid", 100.0); + testSystem.createDatabase(true); + testSystem.setMixingRule(0); - SystemInterface testSystemAntoine = - new SystemSrkSchwartzentruberEos(273.15 + i * 5, 1.101); - // testSystemAntoine.addComponent("Piperazine", 100.0); - testSystemAntoine.addComponent("AceticAcid", 100.0); - testSystemAntoine.setMixingRule(0); - neqsim.thermodynamicOperations.ThermodynamicOperations opsAntione = - new neqsim.thermodynamicOperations.ThermodynamicOperations( - testSystemAntoine); + SystemInterface testSystemAntoine = new SystemSrkSchwartzentruberEos(273.15 + i * 5, 1.101); + // testSystemAntoine.addComponent("Piperazine", 100.0); + testSystemAntoine.addComponent("AceticAcid", 100.0); + testSystemAntoine.setMixingRule(0); + neqsim.thermodynamicOperations.ThermodynamicOperations opsAntione = + new neqsim.thermodynamicOperations.ThermodynamicOperations(testSystemAntoine); - double sample1[] = {i * 5 + 273.15}; - double standardDeviation1[] = {0.1, 0.1, 0.1}; - double val = Math.log(testSystemAntoine.getPhase(0).getComponent(0) - .getAntoineVaporPressure(273.15 + i * 5)); - // opsAntione.bubblePointPressureFlash(false); - // double val = Math.log(testSystemAntoine.getPressure()); - SampleValue sample = new SampleValue(val, val / 100.0, sample1, standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sampleList.add(sample); - } - } catch (Exception e) { - logger.info("database error" + e); - } + double sample1[] = {i * 5 + 273.15}; + double standardDeviation1[] = {0.1, 0.1, 0.1}; + double val = Math.log( + testSystemAntoine.getPhase(0).getComponent(0).getAntoineVaporPressure(273.15 + i * 5)); + // opsAntione.bubblePointPressureFlash(false); + // double val = Math.log(testSystemAntoine.getPressure()); + SampleValue sample = new SampleValue(val, val / 100.0, sample1, standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sampleList.add(sample); + } + } catch (Exception e) { + logger.info("database error" + e); + } - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); - // do simulations - // optim.solve(); - // optim.runMonteCarloSimulation(); - optim.displayCurveFit(); - // optim.writeToCdfFile("c:/testFit.nc"); - // optim.writeToTextFile("c:/testFit.txt"); - } + // do simulations + // optim.solve(); + // optim.runMonteCarloSimulation(); + optim.displayCurveFit(); + // optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestMathiasCopeman.java b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestMathiasCopeman.java index f00e2d36ea..309c5a1608 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestMathiasCopeman.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestMathiasCopeman.java @@ -20,111 +20,110 @@ * @version $Id: $Id */ public class TestMathiasCopeman { - static Logger logger = LogManager.getLogger(TestMathiasCopeman.class); - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); - - // String ComponentName = "CO2"; - String ComponentName = "methane"; - // String ComponentName = "ethane"; - // String ComponentName = "propane"; - // String ComponentName = "n-butane"; - // String ComponentName = "i-butane"; - // String ComponentName = "i-pentane"; - // String ComponentName = "n-pentane"; - // String ComponentName = "nitrogen"; - // String ComponentName = "neon"; - - try { - // for(int i=0;i<30;i++){ - MathiasCopeman function = new MathiasCopeman(); - // double guess[] = {0.8817389299100502,-0.8562550217314793,3.0949393273488686}; - // // CO2 chi sqr 0.0025 - double guess[] = {0.5379142011507664, -0.3219393792621987, 0.4361033659755846}; // Methane - // chi - // sqr - // 0.1425 - // double guess[] ={0.654848543521529,-0.18438917116800416,0.2601600498810114} ; - // // ethane chi sqr 0.35 - // double guess[] ={0.721211485876844,-0.09921664231818139,0.18182922712791916} - // ; // PROPANE chi sqr 0.2645 - // double guess[] ={0.8080635549718828,-0.21272494485460103,0.36296147537551615} - // ; // n-butane chi sqr 0.2645 - // double guess[] ={0.7803883597786199,-0.27338954339527566,0.6597871185507804} - // ; // i-butane chi sqr 0.166 - // double guess[] ={0.8578874087217438,-0.26763822614020133,0.4586427557929788} - // ; // i-pentane chi sqr 0.699 - // double guess[] ={0.9038611341253704,-0.3585531518594213,0.6638852213604798} ; - // // n-pentane chi sqr 0.827 - // double guess[] ={0.5742583288610631,-0.3225948761079366,0.5906544971686629} ; - // // nitrogen chi sqr 0.05144 - // double guess[] ={0.4844539990236587,-0.5088139220535864,0.7223945129559358} ; - // // neon chi sqr 0.0577 - - function.setInitialGuess(guess); - - // SystemInterface testSystem = new SystemSrkSchwartzentruberEos(40, 1); - // SystemInterface testSystem = new SystemSrkEos(280, 1); - SystemInterface testSystem = new SystemSrkMathiasCopeman(280, 5); - testSystem.addComponent(ComponentName, 100.0); - // testSystem.addComponent(ComponentName2, 100.0); - testSystem.setMixingRule(2); - - testSystem.createDatabase(true); - - // SystemInterface System2 = new SystemSrkSchwartzentruberEos(280, 5); - SystemInterface System2 = new SystemSrkTwuCoonEos(280, 5); - - System2.addComponent(ComponentName, 100.0); - // System2.addComponent(ComponentName2, 100.0); - System2.setMixingRule(2); - ThermodynamicOperations Ops = new ThermodynamicOperations(System2); - - double Ttp = testSystem.getPhase(0).getComponent(0).getTriplePointTemperature(); - double TC = testSystem.getPhase(0).getComponent(0).getTC(); - - for (int i = 0; i < 30; i++) { - double temperature = Ttp + ((TC - Ttp) / 30) * i; - // kan legge inn dewTflash for aa finne avvik til tilsvarende linje med - // schwarzentruber... da ogsaa for flerkomponent blandinger istedenfor antoine - // ligningen. - // double pressure = - // testSystem.getPhase(0).7getComponent(0).getAntoineVaporPressure(temperature); - System2.setTemperature(temperature); - Ops.dewPointPressureFlash(); - double pressure = System2.getPressure(); - - double sample1[] = {temperature}; - double standardDeviation1[] = {0.1, 0.1, 0.1}; - double val = Math.log(pressure); - SampleValue sample = new SampleValue(val, val / 100.0, sample1, standardDeviation1); - sample.setFunction(function); - sample.setReference("NIST"); - sample.setThermodynamicSystem(testSystem); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } - - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); - - // do simulations - - // optim.solve(); - // optim.runMonteCarloSimulation(); - optim.displayCurveFit(); - // optim.writeToCdfFile("c:/testFit.nc"); - // optim.writeToTextFile("c:/testFit.txt"); + static Logger logger = LogManager.getLogger(TestMathiasCopeman.class); + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); + + // String ComponentName = "CO2"; + String ComponentName = "methane"; + // String ComponentName = "ethane"; + // String ComponentName = "propane"; + // String ComponentName = "n-butane"; + // String ComponentName = "i-butane"; + // String ComponentName = "i-pentane"; + // String ComponentName = "n-pentane"; + // String ComponentName = "nitrogen"; + // String ComponentName = "neon"; + + try { + // for(int i=0;i<30;i++){ + MathiasCopeman function = new MathiasCopeman(); + // double guess[] = {0.8817389299100502,-0.8562550217314793,3.0949393273488686}; + // // CO2 chi sqr 0.0025 + double guess[] = {0.5379142011507664, -0.3219393792621987, 0.4361033659755846}; // Methane + // chi + // sqr + // 0.1425 + // double guess[] ={0.654848543521529,-0.18438917116800416,0.2601600498810114} ; + // // ethane chi sqr 0.35 + // double guess[] ={0.721211485876844,-0.09921664231818139,0.18182922712791916} + // ; // PROPANE chi sqr 0.2645 + // double guess[] ={0.8080635549718828,-0.21272494485460103,0.36296147537551615} + // ; // n-butane chi sqr 0.2645 + // double guess[] ={0.7803883597786199,-0.27338954339527566,0.6597871185507804} + // ; // i-butane chi sqr 0.166 + // double guess[] ={0.8578874087217438,-0.26763822614020133,0.4586427557929788} + // ; // i-pentane chi sqr 0.699 + // double guess[] ={0.9038611341253704,-0.3585531518594213,0.6638852213604798} ; + // // n-pentane chi sqr 0.827 + // double guess[] ={0.5742583288610631,-0.3225948761079366,0.5906544971686629} ; + // // nitrogen chi sqr 0.05144 + // double guess[] ={0.4844539990236587,-0.5088139220535864,0.7223945129559358} ; + // // neon chi sqr 0.0577 + + function.setInitialGuess(guess); + + // SystemInterface testSystem = new SystemSrkSchwartzentruberEos(40, 1); + // SystemInterface testSystem = new SystemSrkEos(280, 1); + SystemInterface testSystem = new SystemSrkMathiasCopeman(280, 5); + testSystem.addComponent(ComponentName, 100.0); + // testSystem.addComponent(ComponentName2, 100.0); + testSystem.setMixingRule(2); + + testSystem.createDatabase(true); + + // SystemInterface System2 = new SystemSrkSchwartzentruberEos(280, 5); + SystemInterface System2 = new SystemSrkTwuCoonEos(280, 5); + + System2.addComponent(ComponentName, 100.0); + // System2.addComponent(ComponentName2, 100.0); + System2.setMixingRule(2); + ThermodynamicOperations Ops = new ThermodynamicOperations(System2); + + double Ttp = testSystem.getPhase(0).getComponent(0).getTriplePointTemperature(); + double TC = testSystem.getPhase(0).getComponent(0).getTC(); + + for (int i = 0; i < 30; i++) { + double temperature = Ttp + ((TC - Ttp) / 30) * i; + // kan legge inn dewTflash for aa finne avvik til tilsvarende linje med + // schwarzentruber... da ogsaa for flerkomponent blandinger istedenfor antoine + // ligningen. + // double pressure = + // testSystem.getPhase(0).7getComponent(0).getAntoineVaporPressure(temperature); + System2.setTemperature(temperature); + Ops.dewPointPressureFlash(); + double pressure = System2.getPressure(); + + double sample1[] = {temperature}; + double standardDeviation1[] = {0.1, 0.1, 0.1}; + double val = Math.log(pressure); + SampleValue sample = new SampleValue(val, val / 100.0, sample1, standardDeviation1); + sample.setFunction(function); + sample.setReference("NIST"); + sample.setThermodynamicSystem(testSystem); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); } + + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); + + // do simulations + + // optim.solve(); + // optim.runMonteCarloSimulation(); + optim.displayCurveFit(); + // optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestMathiasCopemanToDewPoint.java b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestMathiasCopemanToDewPoint.java index a51b643a30..79169abba6 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestMathiasCopemanToDewPoint.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestMathiasCopemanToDewPoint.java @@ -20,158 +20,153 @@ * @version $Id: $Id */ public class TestMathiasCopemanToDewPoint { - static Logger logger = LogManager.getLogger(TestMathiasCopemanToDewPoint.class); - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); - - // inserting samples from database - NeqSimDataBase database = new NeqSimDataBase(); - ResultSet dataSet = null; - - // // PVTsim14 values for MC-parameters - // double guess[] ={0.547, -0.399, 0.575, // methane - // 0.685, -0.428, 0.738, //ethane - // 0.773, -0.509, 1.031, // propane - // 0.849, -0.552, 1.077, //n-butane) - // 0.780, -0.273,0.659, //i-butane - // 0.937, -0.766, 1.848, // n-pentane - // 0.547, -0.399, 1.575, //c-hexane - // 0.846, -0.386, 0.884, // benzene - // 1.087, -0.747, 1.577} ; //n-heptane - - // initial guess - // double guess[] ={1.4184728684, -1.6053750221, 0.7429086086, // methane - // 1.6853, -0.4284, 0.7382, //ethane - // 1.8653, -1.4386, 1.3447, // propane - // 1.8080, -0.2127, 1.3629, //n-butane) - // 1.78038835, -1.273389543,0.659787118550, //i-butane - // 0.903861134, -0.3585531518594, 0.66388522, // n-pentane - // 0.547, -1.399, 1.575, //c-hexane - // 0.8457,-1.3856,1.8843, // benzene - // 1.0874, -1.7465, 1.5765} ; //n-heptane - - // optimized chi-square: 21706 abs dev 2.65 - double guess[] = {0.7131945439, 0.4140076386, -2.5691833434, 4.3710359391, -1.1086000763, - 7.3866869416, 1.1183339865, -2.1831081128, 0.9948380388, 1.5665073967, - -5.5636308059, -1.4091055663, 0.8232405436, -0.3922156128, -1.4347079752, - 1.3771397711, -1.2103436623, 0.0028643344, 1.3423413878, -0.3330681068, - -2.1604332713, 1.1554915030, -1.7359747766, 1.1084438340, 1.1800358360, - -1.4810259893, 1.4887592454}; - String nameList[] = {"methane", "ethane", "propane", "n-butane", "i-butane", "n-pentane", - "c-hexane", "benzene", "n-heptane"}; - - for (int compNumb = 0; compNumb < nameList.length; compNumb++) { - dataSet = database - .getResultSet("SELECT * FROM PureComponentVapourPressures WHERE ComponentName='" - + nameList[compNumb] - + "' AND VapourPressure>0 ORDER BY Temperature ASC"); - - try { - long numberOfPoint = 3; - logger.error("point " + numberOfPoint); - int i = 0; - while (dataSet.next()) { - i++; - if (i % numberOfPoint == 0) { - MathiasCopemanToDewPoint function = new MathiasCopemanToDewPoint(); - function.setInitialGuess(guess); - - SystemInterface testSystem = new SystemSrkMathiasCopeman( - Double.parseDouble(dataSet.getString("Temperature")), - Double.parseDouble(dataSet.getString("VapourPressure"))); - testSystem.addComponent(dataSet.getString("ComponentName"), 100.0); - // testSystem.createDatabase(true); - double sample1[] = {testSystem.getPressure()}; - double standardDeviation1[] = {0.1, 0.1, 0.1}; - double val = testSystem.getTemperature(); - double stdErr = 1.0; - SampleValue sample = - new SampleValue(val, stdErr, sample1, standardDeviation1); - sample.setFunction(function); - sample.setReference(dataSet.getString("Reference")); - sample.setThermodynamicSystem(testSystem); - sampleList.add(sample); - } - } - } catch (Exception e) { - logger.error("database error" + e); - } + static Logger logger = LogManager.getLogger(TestMathiasCopemanToDewPoint.class); + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); + + // inserting samples from database + NeqSimDataBase database = new NeqSimDataBase(); + ResultSet dataSet = null; + + // // PVTsim14 values for MC-parameters + // double guess[] ={0.547, -0.399, 0.575, // methane + // 0.685, -0.428, 0.738, //ethane + // 0.773, -0.509, 1.031, // propane + // 0.849, -0.552, 1.077, //n-butane) + // 0.780, -0.273,0.659, //i-butane + // 0.937, -0.766, 1.848, // n-pentane + // 0.547, -0.399, 1.575, //c-hexane + // 0.846, -0.386, 0.884, // benzene + // 1.087, -0.747, 1.577} ; //n-heptane + + // initial guess + // double guess[] ={1.4184728684, -1.6053750221, 0.7429086086, // methane + // 1.6853, -0.4284, 0.7382, //ethane + // 1.8653, -1.4386, 1.3447, // propane + // 1.8080, -0.2127, 1.3629, //n-butane) + // 1.78038835, -1.273389543,0.659787118550, //i-butane + // 0.903861134, -0.3585531518594, 0.66388522, // n-pentane + // 0.547, -1.399, 1.575, //c-hexane + // 0.8457,-1.3856,1.8843, // benzene + // 1.0874, -1.7465, 1.5765} ; //n-heptane + + // optimized chi-square: 21706 abs dev 2.65 + double guess[] = {0.7131945439, 0.4140076386, -2.5691833434, 4.3710359391, -1.1086000763, + 7.3866869416, 1.1183339865, -2.1831081128, 0.9948380388, 1.5665073967, -5.5636308059, + -1.4091055663, 0.8232405436, -0.3922156128, -1.4347079752, 1.3771397711, -1.2103436623, + 0.0028643344, 1.3423413878, -0.3330681068, -2.1604332713, 1.1554915030, -1.7359747766, + 1.1084438340, 1.1800358360, -1.4810259893, 1.4887592454}; + String nameList[] = {"methane", "ethane", "propane", "n-butane", "i-butane", "n-pentane", + "c-hexane", "benzene", "n-heptane"}; + + for (int compNumb = 0; compNumb < nameList.length; compNumb++) { + dataSet = + database.getResultSet("SELECT * FROM PureComponentVapourPressures WHERE ComponentName='" + + nameList[compNumb] + "' AND VapourPressure>0 ORDER BY Temperature ASC"); + + try { + long numberOfPoint = 3; + logger.error("point " + numberOfPoint); + int i = 0; + while (dataSet.next()) { + i++; + if (i % numberOfPoint == 0) { + MathiasCopemanToDewPoint function = new MathiasCopemanToDewPoint(); + function.setInitialGuess(guess); + + SystemInterface testSystem = + new SystemSrkMathiasCopeman(Double.parseDouble(dataSet.getString("Temperature")), + Double.parseDouble(dataSet.getString("VapourPressure"))); + testSystem.addComponent(dataSet.getString("ComponentName"), 100.0); + // testSystem.createDatabase(true); + double sample1[] = {testSystem.getPressure()}; + double standardDeviation1[] = {0.1, 0.1, 0.1}; + double val = testSystem.getTemperature(); + double stdErr = 1.0; + SampleValue sample = new SampleValue(val, stdErr, sample1, standardDeviation1); + sample.setFunction(function); + sample.setReference(dataSet.getString("Reference")); + sample.setThermodynamicSystem(testSystem); + sampleList.add(sample); + } } + } catch (Exception e) { + logger.error("database error" + e); + } + } - dataSet = database - .getResultSet("SELECT * FROM dewPointDataSynthHCStatoil WHERE Pressure<80.0");// "0 - // AND - // reference='Morch2004gas1'"); - - try { - long numberOfPoint = 1; - logger.info("point " + numberOfPoint); - int i = 0; - while (dataSet.next() && i < 100) { - i++; - if (i % numberOfPoint == 0) { - MathiasCopemanToDewPoint function = new MathiasCopemanToDewPoint(); - function.setInitialGuess(guess); - - SystemInterface testSystem = new SystemSrkMathiasCopeman( - Double.parseDouble(dataSet.getString("Temperature")), - Double.parseDouble(dataSet.getString("Pressure"))); - testSystem.addComponent(dataSet.getString("comp1"), - Double.parseDouble(dataSet.getString("x1"))); - testSystem.addComponent(dataSet.getString("comp2"), - Double.parseDouble(dataSet.getString("x2"))); - testSystem.addComponent(dataSet.getString("comp3"), - Double.parseDouble(dataSet.getString("x3"))); - testSystem.addComponent(dataSet.getString("comp4"), - Double.parseDouble(dataSet.getString("x4"))); - testSystem.addComponent(dataSet.getString("comp5"), - Double.parseDouble(dataSet.getString("x5"))); - testSystem.addComponent(dataSet.getString("comp6"), - Double.parseDouble(dataSet.getString("x6"))); - testSystem.addComponent(dataSet.getString("comp7"), - Double.parseDouble(dataSet.getString("x7"))); - testSystem.addComponent(dataSet.getString("comp8"), - Double.parseDouble(dataSet.getString("x8"))); - testSystem.addComponent(dataSet.getString("comp9"), - Double.parseDouble(dataSet.getString("x9"))); - // testSystem.addComponent(dataSet.getString("comp9"), - // Double.parseDouble(dataSet.getString("x9"))); - // testSystem.addComponent(dataSet.getString("comp10"), - // Double.parseDouble(dataSet.getString("x10"))); - // testSystem.createDatabase(true); - double sample1[] = {testSystem.getPressure()}; - double standardDeviation1[] = {0.1, 0.1, 0.1}; - double val = testSystem.getTemperature(); - double stdErr = 1.0; - SampleValue sample = new SampleValue(val, stdErr, sample1, standardDeviation1); - sample.setFunction(function); - sample.setReference(dataSet.getString("reference")); - sample.setThermodynamicSystem(testSystem); - sampleList.add(sample); - } - } - } catch (Exception e) { - logger.error("database error" + e); + dataSet = database.getResultSet("SELECT * FROM dewPointDataSynthHCStatoil WHERE Pressure<80.0");// "0 + // AND + // reference='Morch2004gas1'"); + + try { + long numberOfPoint = 1; + logger.info("point " + numberOfPoint); + int i = 0; + while (dataSet.next() && i < 100) { + i++; + if (i % numberOfPoint == 0) { + MathiasCopemanToDewPoint function = new MathiasCopemanToDewPoint(); + function.setInitialGuess(guess); + + SystemInterface testSystem = + new SystemSrkMathiasCopeman(Double.parseDouble(dataSet.getString("Temperature")), + Double.parseDouble(dataSet.getString("Pressure"))); + testSystem.addComponent(dataSet.getString("comp1"), + Double.parseDouble(dataSet.getString("x1"))); + testSystem.addComponent(dataSet.getString("comp2"), + Double.parseDouble(dataSet.getString("x2"))); + testSystem.addComponent(dataSet.getString("comp3"), + Double.parseDouble(dataSet.getString("x3"))); + testSystem.addComponent(dataSet.getString("comp4"), + Double.parseDouble(dataSet.getString("x4"))); + testSystem.addComponent(dataSet.getString("comp5"), + Double.parseDouble(dataSet.getString("x5"))); + testSystem.addComponent(dataSet.getString("comp6"), + Double.parseDouble(dataSet.getString("x6"))); + testSystem.addComponent(dataSet.getString("comp7"), + Double.parseDouble(dataSet.getString("x7"))); + testSystem.addComponent(dataSet.getString("comp8"), + Double.parseDouble(dataSet.getString("x8"))); + testSystem.addComponent(dataSet.getString("comp9"), + Double.parseDouble(dataSet.getString("x9"))); + // testSystem.addComponent(dataSet.getString("comp9"), + // Double.parseDouble(dataSet.getString("x9"))); + // testSystem.addComponent(dataSet.getString("comp10"), + // Double.parseDouble(dataSet.getString("x10"))); + // testSystem.createDatabase(true); + double sample1[] = {testSystem.getPressure()}; + double standardDeviation1[] = {0.1, 0.1, 0.1}; + double val = testSystem.getTemperature(); + double stdErr = 1.0; + SampleValue sample = new SampleValue(val, stdErr, sample1, standardDeviation1); + sample.setFunction(function); + sample.setReference(dataSet.getString("reference")); + sample.setThermodynamicSystem(testSystem); + sampleList.add(sample); } + } + } catch (Exception e) { + logger.error("database error" + e); + } - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); - // do simulations + // do simulations - // optim.solve(); - // optim.runMonteCarloSimulation(); - optim.displayCurveFit(); - // optim.writeToCdfFile("c:/testFit.nc"); - // optim.writeToTextFile("c:/testFit.txt"); - } + // optim.solve(); + // optim.runMonteCarloSimulation(); + optim.displayCurveFit(); + // optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestTwuCoon.java b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestTwuCoon.java index 494018455e..c577d0f13c 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestTwuCoon.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestTwuCoon.java @@ -20,112 +20,111 @@ * @version $Id: $Id */ public class TestTwuCoon { - static Logger logger = LogManager.getLogger(TestTwuCoon.class); - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); - - // String ComponentName = "CO2"; - // String ComponentName = "methane"; - // String ComponentName = "ethane"; - // String ComponentName = "propane"; - // String ComponentName = "n-butane"; - // String ComponentName = "i-butane"; - // String ComponentName = "i-pentane"; - // String ComponentName = "n-pentane"; - String ComponentName = "mercury"; - // String ComponentName = "neon"; - - try { - // for(int i=0;i<30;i++){ - TwuCoon function = new TwuCoon(); - // double guess[] = {1.4136010682288083,-0.6059654485151583,1.1018149483163808}; - // // CO2 chi sqr 0.45 - // double guess[] ={0.1228415979307727,0.9144707890284266,2.7419786111346327} ; - // // Methane chi sqr 0.1425 - // double guess[] ={0.2996073181440976,0.8766268388933209,1.6792384004871077} ; - // // ethane chi sqr 0.6 - // double guess[] ={0.4358258831879946,0.8661321788747547,1.3954328182729108} ; - // // PROPANE chi sqr 0.57 - // double guess[] ={0.33180058324421624,0.8546927333111055,1.8658288576964368} ; - // // n-butane chi sqr 0.66 - // double guess[] ={0.2179712800665,0.8488910728515817,2.284036968290834}; - // i-butane chi sqr 0.64 - // double guess[] ={0.3426699116420882,0.8518937813463485,1.9218752789862321} ; - // // i-pentane chi sqr 1.71 - // double guess[] ={0.2728761064186051,0.8503101221977485,2.340728864856859} ; - // // n-pentane chi sqr 0.827 - // double guess[] ={0.11262960694190573,0.9021997146737551,2.8749606780260866} ; - // // nitrogen chi sqr 0.063 - // double guess[] ={0.08838047169500897,0.9400222937525736,3.4011901770700264} ; - // // neon chi sqr 0.044 - // double guess[] = {0.0179791, 0.983218, 5.63251}; - double guess[] = {0.068584, 0.9784, 2.244}; - - // SystemInterface testSystem = new SystemSrkSchwartzentruberEos(40, 1); - // SystemInterface testSystem = new SystemSrkEos(280, 1); - SystemInterface testSystem = new SystemSrkTwuCoonParamEos(280, 5); - testSystem.addComponent(ComponentName, 100.0); - testSystem.setMixingRule(2); - - testSystem.createDatabase(true); - - // function.setFittingParams(0, guess[0]); - // function.setFittingParams(1, guess[1]); - // function.setFittingParams(2, guess[2]); - function.setInitialGuess(guess); - - SystemInterface System2 = new SystemSrkSchwartzentruberEos(280, 5); - // SystemInterface System2 = new SystemSrkTwuCoonEos(280, 5); - - System2.addComponent(ComponentName, 100.0); - System2.setMixingRule(2); - ThermodynamicOperations Ops = new ThermodynamicOperations(System2); - - double Ttp = testSystem.getPhase(0).getComponent(0).getTriplePointTemperature(); - double TC = testSystem.getPhase(0).getComponent(0).getTC(); - - for (int i = 0; i < 30; i++) { - double temperature = Ttp + ((TC - Ttp) / 30) * i; - // kan legge inn dewTflash for aa finne avvik til tilsvarende linje med - // schwarzentruber... da ogsaa for flerkomponent blandinger istedenfor antoine - // ligningen. - // double pressure = - // testSystem.getPhase(0).getComponent(0).getAntoineVaporPressure(temperature); - System2.setTemperature(temperature); - Ops.dewPointPressureFlash(); - double pressure = System2.getPressure(); - - double sample1[] = {temperature}; - double standardDeviation1[] = {0.1, 0.1, 0.1}; - double val = Math.log(pressure); - SampleValue sample = new SampleValue(val, val / 100.0, sample1, standardDeviation1); - sample.setFunction(function); - sample.setReference("Perry"); - sample.setThermodynamicSystem(testSystem); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); - } - - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); - - // do simulations - - optim.solve(); - // optim.runMonteCarloSimulation(); - optim.displayCurveFit(); - // optim.writeToCdfFile("c:/testFit.nc"); - // optim.writeToTextFile("c:/testFit.txt"); + static Logger logger = LogManager.getLogger(TestTwuCoon.class); + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); + + // String ComponentName = "CO2"; + // String ComponentName = "methane"; + // String ComponentName = "ethane"; + // String ComponentName = "propane"; + // String ComponentName = "n-butane"; + // String ComponentName = "i-butane"; + // String ComponentName = "i-pentane"; + // String ComponentName = "n-pentane"; + String ComponentName = "mercury"; + // String ComponentName = "neon"; + + try { + // for(int i=0;i<30;i++){ + TwuCoon function = new TwuCoon(); + // double guess[] = {1.4136010682288083,-0.6059654485151583,1.1018149483163808}; + // // CO2 chi sqr 0.45 + // double guess[] ={0.1228415979307727,0.9144707890284266,2.7419786111346327} ; + // // Methane chi sqr 0.1425 + // double guess[] ={0.2996073181440976,0.8766268388933209,1.6792384004871077} ; + // // ethane chi sqr 0.6 + // double guess[] ={0.4358258831879946,0.8661321788747547,1.3954328182729108} ; + // // PROPANE chi sqr 0.57 + // double guess[] ={0.33180058324421624,0.8546927333111055,1.8658288576964368} ; + // // n-butane chi sqr 0.66 + // double guess[] ={0.2179712800665,0.8488910728515817,2.284036968290834}; + // i-butane chi sqr 0.64 + // double guess[] ={0.3426699116420882,0.8518937813463485,1.9218752789862321} ; + // // i-pentane chi sqr 1.71 + // double guess[] ={0.2728761064186051,0.8503101221977485,2.340728864856859} ; + // // n-pentane chi sqr 0.827 + // double guess[] ={0.11262960694190573,0.9021997146737551,2.8749606780260866} ; + // // nitrogen chi sqr 0.063 + // double guess[] ={0.08838047169500897,0.9400222937525736,3.4011901770700264} ; + // // neon chi sqr 0.044 + // double guess[] = {0.0179791, 0.983218, 5.63251}; + double guess[] = {0.068584, 0.9784, 2.244}; + + // SystemInterface testSystem = new SystemSrkSchwartzentruberEos(40, 1); + // SystemInterface testSystem = new SystemSrkEos(280, 1); + SystemInterface testSystem = new SystemSrkTwuCoonParamEos(280, 5); + testSystem.addComponent(ComponentName, 100.0); + testSystem.setMixingRule(2); + + testSystem.createDatabase(true); + + // function.setFittingParams(0, guess[0]); + // function.setFittingParams(1, guess[1]); + // function.setFittingParams(2, guess[2]); + function.setInitialGuess(guess); + + SystemInterface System2 = new SystemSrkSchwartzentruberEos(280, 5); + // SystemInterface System2 = new SystemSrkTwuCoonEos(280, 5); + + System2.addComponent(ComponentName, 100.0); + System2.setMixingRule(2); + ThermodynamicOperations Ops = new ThermodynamicOperations(System2); + + double Ttp = testSystem.getPhase(0).getComponent(0).getTriplePointTemperature(); + double TC = testSystem.getPhase(0).getComponent(0).getTC(); + + for (int i = 0; i < 30; i++) { + double temperature = Ttp + ((TC - Ttp) / 30) * i; + // kan legge inn dewTflash for aa finne avvik til tilsvarende linje med + // schwarzentruber... da ogsaa for flerkomponent blandinger istedenfor antoine + // ligningen. + // double pressure = + // testSystem.getPhase(0).getComponent(0).getAntoineVaporPressure(temperature); + System2.setTemperature(temperature); + Ops.dewPointPressureFlash(); + double pressure = System2.getPressure(); + + double sample1[] = {temperature}; + double standardDeviation1[] = {0.1, 0.1, 0.1}; + double val = Math.log(pressure); + SampleValue sample = new SampleValue(val, val / 100.0, sample1, standardDeviation1); + sample.setFunction(function); + sample.setReference("Perry"); + sample.setThermodynamicSystem(testSystem); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); } + + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); + + // do simulations + + optim.solve(); + // optim.runMonteCarloSimulation(); + optim.displayCurveFit(); + // optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/furstIonicParameters/TestFurstIonicParameterFunction.java b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/furstIonicParameters/TestFurstIonicParameterFunction.java index b7cc5c084e..0f07938f63 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/furstIonicParameters/TestFurstIonicParameterFunction.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/furstIonicParameters/TestFurstIonicParameterFunction.java @@ -20,171 +20,164 @@ * @version $Id: $Id */ public class TestFurstIonicParameterFunction { - static Logger logger = LogManager.getLogger(TestFurstIonicParameterFunction.class); + static Logger logger = LogManager.getLogger(TestFurstIonicParameterFunction.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); - // inserting samples from database - NeqSimDataBase database = new NeqSimDataBase(); - // double[] guess = {0.0000001880, 0.0000014139, 0.0000284666, 0.0000389043, - // -0.0000000451, 0.0000088136}; - // double[] guess = {0.0000250998, 0.0000198635, -0.0000000311, -0.0000006630}; - // double[] guess = { 0.0000001116, 0.0000053822, 0.0000691846, 0.0000049520, - // -0.0000000605, -0.0000216352}; - // double[] guess = {0.0000000640, 0.0000011845 , 0.0000209744, 0.0000089071, - // -0.0000000272, 0.0000019014};//cpa-el - double[] guess = {0.0000000752, 0.0000037242, 0.0000250998, 0.0000198635, -0.0000000311, - -0.0000006630}; - // ResultSet dataSet = database.getResultSet( "SELECT * FROM ionicData WHERE - // Description IN ('NaCl')");//,'LiCl','Sr2Br','Sr2I')"); - ResultSet dataSet = database.getResultSet( - "SELECT * FROM ionicData WHERE ion1<>'H3Oplus2' ORDER BY ion1,ion2,x2"); - // ResultSet dataSet = database.getResultSet( "SELECT * FROM ionicData WHERE - // ion1='Na+' AND ion2='Cl-'"); - int numb = 0; - try { - logger.info("adding...."); - while (dataSet.next() && numb < 22265) { - numb++; + // inserting samples from database + NeqSimDataBase database = new NeqSimDataBase(); + // double[] guess = {0.0000001880, 0.0000014139, 0.0000284666, 0.0000389043, + // -0.0000000451, 0.0000088136}; + // double[] guess = {0.0000250998, 0.0000198635, -0.0000000311, -0.0000006630}; + // double[] guess = { 0.0000001116, 0.0000053822, 0.0000691846, 0.0000049520, + // -0.0000000605, -0.0000216352}; + // double[] guess = {0.0000000640, 0.0000011845 , 0.0000209744, 0.0000089071, + // -0.0000000272, 0.0000019014};//cpa-el + double[] guess = + {0.0000000752, 0.0000037242, 0.0000250998, 0.0000198635, -0.0000000311, -0.0000006630}; + // ResultSet dataSet = database.getResultSet( "SELECT * FROM ionicData WHERE + // Description IN ('NaCl')");//,'LiCl','Sr2Br','Sr2I')"); + ResultSet dataSet = database + .getResultSet("SELECT * FROM ionicData WHERE ion1<>'H3Oplus2' ORDER BY ion1,ion2,x2"); + // ResultSet dataSet = database.getResultSet( "SELECT * FROM ionicData WHERE + // ion1='Na+' AND ion2='Cl-'"); + int numb = 0; + try { + logger.info("adding...."); + while (dataSet.next() && numb < 22265) { + numb++; - FurstIonicParameterFunction function = new FurstIonicParameterFunction(); - function.setInitialGuess(guess); - double x2 = Double.parseDouble(dataSet.getString("x2")); - // SystemInterface testSystem = new SystemFurstElectrolyteEos(280, - // 1.0); - SystemInterface testSystem = new SystemElectrolyteCPAstatoil(280.0, 1.0); - // testSystem.addComponent(dataSet.getString("ComponentSolvent"), - // Double.parseDouble(dataSet.getString("x1"))); - testSystem.addComponent("water", Double.parseDouble(dataSet.getString("x1"))); - testSystem.addComponent(dataSet.getString("Ion1"), x2); - testSystem.addComponent(dataSet.getString("Ion2"), - Double.parseDouble(dataSet.getString("x3"))); - testSystem.createDatabase(true); - testSystem.setMixingRule(10); - testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); - testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); - testSystem.init(0); - double sample1[] = {x2 / 0.01802}; - double standardDeviation1[] = {0.01}; - double osmcoef = Double.parseDouble(dataSet.getString("OsmoticCoefficient")); + FurstIonicParameterFunction function = new FurstIonicParameterFunction(); + function.setInitialGuess(guess); + double x2 = Double.parseDouble(dataSet.getString("x2")); + // SystemInterface testSystem = new SystemFurstElectrolyteEos(280, + // 1.0); + SystemInterface testSystem = new SystemElectrolyteCPAstatoil(280.0, 1.0); + // testSystem.addComponent(dataSet.getString("ComponentSolvent"), + // Double.parseDouble(dataSet.getString("x1"))); + testSystem.addComponent("water", Double.parseDouble(dataSet.getString("x1"))); + testSystem.addComponent(dataSet.getString("Ion1"), x2); + testSystem.addComponent(dataSet.getString("Ion2"), + Double.parseDouble(dataSet.getString("x3"))); + testSystem.createDatabase(true); + testSystem.setMixingRule(10); + testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); + testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); + testSystem.init(0); + double sample1[] = {x2 / 0.01802}; + double standardDeviation1[] = {0.01}; + double osmcoef = Double.parseDouble(dataSet.getString("OsmoticCoefficient")); - testSystem.init(1); + testSystem.init(1); - SampleValue sample = - new SampleValue(osmcoef, osmcoef / 100.0, sample1, standardDeviation1); - // SampleValue sample = new - // SampleValue(Double.parseDouble(dataSet.getString("IonicActivity")), - // Double.parseDouble(dataSet.getString("stddev2")), sample1, - // standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(dataSet.getString("Reference")); - sample.setDescription(dataSet.getString("Description")); - sampleList.add(sample); - } + SampleValue sample = new SampleValue(osmcoef, osmcoef / 100.0, sample1, standardDeviation1); + // SampleValue sample = new + // SampleValue(Double.parseDouble(dataSet.getString("IonicActivity")), + // Double.parseDouble(dataSet.getString("stddev2")), sample1, + // standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(dataSet.getString("Reference")); + sample.setDescription(dataSet.getString("Description")); + sampleList.add(sample); + } - // dataSet = database.getResultSet( "SELECT * FROM ionicData WHERE - // ion1<>'H3Oplus2' AND IonicActivity>=0.01"); - // dataSet = database.getResultSet( "SELECT * FROM ionicData WHERE - // Description - // IN ('NaCl','LiCl','Sr2Br','Sr2I') AND IonicActivity>=0.01"); - dataSet = database - .getResultSet("SELECT * FROM ionicData WHERE ion1='Na+' AND ion2='Cl-'"); - logger.info("setting new for activity"); - while (!dataSet.next()) { - FurstIonicParameterFunction_Activity function = - new FurstIonicParameterFunction_Activity(); - function.setInitialGuess(guess); - double x2 = Double.parseDouble(dataSet.getString("x2")); - // SystemInterface testSystem = new SystemFurstElectrolyteEos(280, - // 1.0); - SystemInterface testSystem = new SystemElectrolyteCPAstatoil(280, 1.0); - testSystem.addComponent(dataSet.getString("ComponentSolvent"), - Double.parseDouble(dataSet.getString("x1"))); - testSystem.addComponent(dataSet.getString("Ion1"), x2); - testSystem.addComponent(dataSet.getString("Ion2"), - Double.parseDouble(dataSet.getString("x3"))); - testSystem.createDatabase(true); - testSystem.setMixingRule(10); - testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); - testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); - testSystem.init(0); - double sample1[] = {x2 / 0.01802}; - double standardDeviation1[] = {0.01}; - // SampleValue sample = new - // SampleValue(Double.parseDouble(dataSet.getString("OsmoticCoefficient")), - // Double.parseDouble(dataSet.getString("stddev1")), sample1, - // standardDeviation1); - double ionact = Double.parseDouble(dataSet.getString("IonicActivity")); - SampleValue sample = new SampleValue(ionact, ionact, sample1, standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(dataSet.getString("Reference")); - sample.setDescription(dataSet.getString("Description")); - sampleList.add(sample); - } + // dataSet = database.getResultSet( "SELECT * FROM ionicData WHERE + // ion1<>'H3Oplus2' AND IonicActivity>=0.01"); + // dataSet = database.getResultSet( "SELECT * FROM ionicData WHERE + // Description + // IN ('NaCl','LiCl','Sr2Br','Sr2I') AND IonicActivity>=0.01"); + dataSet = database.getResultSet("SELECT * FROM ionicData WHERE ion1='Na+' AND ion2='Cl-'"); + logger.info("setting new for activity"); + while (!dataSet.next()) { + FurstIonicParameterFunction_Activity function = new FurstIonicParameterFunction_Activity(); + function.setInitialGuess(guess); + double x2 = Double.parseDouble(dataSet.getString("x2")); + // SystemInterface testSystem = new SystemFurstElectrolyteEos(280, + // 1.0); + SystemInterface testSystem = new SystemElectrolyteCPAstatoil(280, 1.0); + testSystem.addComponent(dataSet.getString("ComponentSolvent"), + Double.parseDouble(dataSet.getString("x1"))); + testSystem.addComponent(dataSet.getString("Ion1"), x2); + testSystem.addComponent(dataSet.getString("Ion2"), + Double.parseDouble(dataSet.getString("x3"))); + testSystem.createDatabase(true); + testSystem.setMixingRule(10); + testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature"))); + testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); + testSystem.init(0); + double sample1[] = {x2 / 0.01802}; + double standardDeviation1[] = {0.01}; + // SampleValue sample = new + // SampleValue(Double.parseDouble(dataSet.getString("OsmoticCoefficient")), + // Double.parseDouble(dataSet.getString("stddev1")), sample1, + // standardDeviation1); + double ionact = Double.parseDouble(dataSet.getString("IonicActivity")); + SampleValue sample = new SampleValue(ionact, ionact, sample1, standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(dataSet.getString("Reference")); + sample.setDescription(dataSet.getString("Description")); + sampleList.add(sample); + } - dataSet = - database.getResultSet("SELECT * FROM saltdens WHERE ion1='Na+' AND ion2='Cl-'"); - logger.info("fitting to ionic density"); - while (!dataSet.next()) { - FurstIonicParameterFunction_Density function = - new FurstIonicParameterFunction_Density(); - function.setInitialGuess(guess); - double x2 = Double.parseDouble(dataSet.getString("molfrac1")); - double x3 = Double.parseDouble(dataSet.getString("molfrac2")); - double x1 = 1.0 - x2 - x3; - SystemInterface testSystem = new SystemElectrolyteCPAstatoil(280, 1.0); - // SystemInterface testSystem = new SystemElectrolyteCPA(280, 1.0); - testSystem.addComponent(dataSet.getString("solvent"), x1); - testSystem.addComponent(dataSet.getString("Ion1"), x2); - testSystem.addComponent(dataSet.getString("Ion2"), x3); - testSystem.setTemperature(Double.parseDouble(dataSet.getString("temperature"))); - testSystem.setPressure(Double.parseDouble(dataSet.getString("pressure"))); - testSystem.createDatabase(true); - testSystem.setMixingRule(7); - testSystem.init(0); - double sample1[] = {x2 / 0.01802}; - double standardDeviation1[] = {0.01}; - // SampleValue sample = new - // SampleValue(Double.parseDouble(dataSet.getString("OsmoticCoefficient")), - // Double.parseDouble(dataSet.getString("stddev1")), sample1, - // standardDeviation1); - double density = Double.parseDouble(dataSet.getString("density")) * 1000.0; - SampleValue sample = - new SampleValue(density, density / 100.0, sample1, standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error: ", e); - } + dataSet = database.getResultSet("SELECT * FROM saltdens WHERE ion1='Na+' AND ion2='Cl-'"); + logger.info("fitting to ionic density"); + while (!dataSet.next()) { + FurstIonicParameterFunction_Density function = new FurstIonicParameterFunction_Density(); + function.setInitialGuess(guess); + double x2 = Double.parseDouble(dataSet.getString("molfrac1")); + double x3 = Double.parseDouble(dataSet.getString("molfrac2")); + double x1 = 1.0 - x2 - x3; + SystemInterface testSystem = new SystemElectrolyteCPAstatoil(280, 1.0); + // SystemInterface testSystem = new SystemElectrolyteCPA(280, 1.0); + testSystem.addComponent(dataSet.getString("solvent"), x1); + testSystem.addComponent(dataSet.getString("Ion1"), x2); + testSystem.addComponent(dataSet.getString("Ion2"), x3); + testSystem.setTemperature(Double.parseDouble(dataSet.getString("temperature"))); + testSystem.setPressure(Double.parseDouble(dataSet.getString("pressure"))); + testSystem.createDatabase(true); + testSystem.setMixingRule(7); + testSystem.init(0); + double sample1[] = {x2 / 0.01802}; + double standardDeviation1[] = {0.01}; + // SampleValue sample = new + // SampleValue(Double.parseDouble(dataSet.getString("OsmoticCoefficient")), + // Double.parseDouble(dataSet.getString("stddev1")), sample1, + // standardDeviation1); + double density = Double.parseDouble(dataSet.getString("density")) * 1000.0; + SampleValue sample = new SampleValue(density, density / 100.0, sample1, standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error: ", e); + } - // double sample1[] = {0.1}; - // for(int i=0;i - * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); - // inserting samples from database - NeqSimDataBase database = new NeqSimDataBase(); + // inserting samples from database + NeqSimDataBase database = new NeqSimDataBase(); - double[] guess = {155.8090060223, 3.1907109417, 0.4069986258};// methane fitted statoil - // sCPA-MC - // double[] guess = { 176.4, 3.2641, 0.5651}; //ethane fitted statoil sCPA-MC - // double[] guess = {126.5783867132, 3.1325067483, 0.3591889027}; // nitrogen - // fitted statoil sCPA-MC - // double[] guess = {205.8859461427, 3.3205773626, 0.6623796853}; // propane - // fitted statoil sCPA-MC - // double[] guess = { 225.1504438988, 3.0810162204, 0.8708186545}; // i-butane - // fitted statoil sCPA-MC + double[] guess = {155.8090060223, 3.1907109417, 0.4069986258};// methane fitted statoil + // sCPA-MC + // double[] guess = { 176.4, 3.2641, 0.5651}; //ethane fitted statoil sCPA-MC + // double[] guess = {126.5783867132, 3.1325067483, 0.3591889027}; // nitrogen + // fitted statoil sCPA-MC + // double[] guess = {205.8859461427, 3.3205773626, 0.6623796853}; // propane + // fitted statoil sCPA-MC + // double[] guess = { 225.1504438988, 3.0810162204, 0.8708186545}; // i-butane + // fitted statoil sCPA-MC - // double[] guess = { 154.7937576383, 3.2008300801, 0.4526279094};//methane - // fitted sCPA - // double[] guess = { 170.1623828321, 3.0372071690, 0.6846338805}; //CO2 - // double[] guess = { 154.0936564578, 3.1720449934, 0.4436459226};//, - // -293247.7186651294};//methane fitted' - // double[] guess = {17.5988597357, -6056.9305919979}; + // double[] guess = { 154.7937576383, 3.2008300801, 0.4526279094};//methane + // fitted sCPA + // double[] guess = { 170.1623828321, 3.0372071690, 0.6846338805}; //CO2 + // double[] guess = { 154.0936564578, 3.1720449934, 0.4436459226};//, + // -293247.7186651294};//methane fitted' + // double[] guess = {17.5988597357, -6056.9305919979}; - // ljeps, ljdiam,a + // ljeps, ljdiam,a - ResultSet dataSet = database.getResultSet( - "SELECT * FROM HydratePureComp WHERE GuestMolecule='methane' AND Type<>'IHV' AND Pressure<57 AND Temperature>273.15"); + ResultSet dataSet = database.getResultSet( + "SELECT * FROM HydratePureComp WHERE GuestMolecule='methane' AND Type<>'IHV' AND Pressure<57 AND Temperature>273.15"); - int numb = 0; - try { - logger.info("adding...."); - while (dataSet.next() && numb < 6) { - numb++; - HydrateFunction function = new HydrateFunction(); - function.setInitialGuess(guess); - double pres = Double.parseDouble(dataSet.getString("Pressure")); - double temp = Double.parseDouble(dataSet.getString("Temperature")); - // SystemInterface testSystem = new SystemSrkSchwartzentruberEos(280, 1.0); - SystemInterface testSystem = new SystemSrkCPAstatoil(280, 1.0); - testSystem.addComponent(dataSet.getString("GuestMolecule"), 1.0); - testSystem.addComponent("water", 1.0); - // testSystem.setSolidPhaseCheck(true); - testSystem.setHydrateCheck(true); - testSystem.createDatabase(true); - testSystem.setMixingRule(7); - testSystem.setTemperature(temp); - testSystem.setPressure(pres); - testSystem.init(0); - double sample1[] = {temp}; - double standardDeviation1[] = {0.1}; - SampleValue sample = new SampleValue(temp, 1.0, sample1, standardDeviation1); - // SampleValue sample = new - // SampleValue(Double.parseDouble(dataSet.getString("IonicActivity")), - // Double.parseDouble(dataSet.getString("stddev2")), sample1, - // standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setDescription(Double.toString(testSystem.getPressure())); - sample.setReference(dataSet.getString("Reference")); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error: ", e); - } + int numb = 0; + try { + logger.info("adding...."); + while (dataSet.next() && numb < 6) { + numb++; + HydrateFunction function = new HydrateFunction(); + function.setInitialGuess(guess); + double pres = Double.parseDouble(dataSet.getString("Pressure")); + double temp = Double.parseDouble(dataSet.getString("Temperature")); + // SystemInterface testSystem = new SystemSrkSchwartzentruberEos(280, 1.0); + SystemInterface testSystem = new SystemSrkCPAstatoil(280, 1.0); + testSystem.addComponent(dataSet.getString("GuestMolecule"), 1.0); + testSystem.addComponent("water", 1.0); + // testSystem.setSolidPhaseCheck(true); + testSystem.setHydrateCheck(true); + testSystem.createDatabase(true); + testSystem.setMixingRule(7); + testSystem.setTemperature(temp); + testSystem.setPressure(pres); + testSystem.init(0); + double sample1[] = {temp}; + double standardDeviation1[] = {0.1}; + SampleValue sample = new SampleValue(temp, 1.0, sample1, standardDeviation1); + // SampleValue sample = new + // SampleValue(Double.parseDouble(dataSet.getString("IonicActivity")), + // Double.parseDouble(dataSet.getString("stddev2")), sample1, + // standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setDescription(Double.toString(testSystem.getPressure())); + sample.setReference(dataSet.getString("Reference")); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error: ", e); + } - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); - // do simulations - optim.solve(); - // optim.runMonteCarloSimulation(); - optim.displayCurveFit(); - // optim.writeToCdfFile("c:/testFit.nc"); - // optim.writeToTextFile("c:/testFit.txt"); - } + // do simulations + optim.solve(); + // optim.runMonteCarloSimulation(); + optim.displayCurveFit(); + // optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/BaseOperation.java b/src/main/java/neqsim/thermodynamicOperations/BaseOperation.java index 918df3a77b..359f67041b 100644 --- a/src/main/java/neqsim/thermodynamicOperations/BaseOperation.java +++ b/src/main/java/neqsim/thermodynamicOperations/BaseOperation.java @@ -16,56 +16,52 @@ * @version $Id: $Id */ public abstract class BaseOperation implements OperationInterface { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - SystemInterface systemThermo = null;; + SystemInterface systemThermo = null;; - /** - *

- * Constructor for BaseOperation. - *

- */ - public BaseOperation() {} + /** + *

+ * Constructor for BaseOperation. + *

+ */ + public BaseOperation() {} - /** {@inheritDoc} */ - @Override - public double[] get(String name) { - return new double[3]; - } + /** {@inheritDoc} */ + @Override + public double[] get(String name) { + return new double[3]; + } - /** {@inheritDoc} */ - @Override - public String[][] getResultTable() { - return new String[10][3]; - } + /** {@inheritDoc} */ + @Override + public String[][] getResultTable() { + return new String[10][3]; + } - /** {@inheritDoc} */ - @Override - public SystemInterface getThermoSystem() { - return null; - } + /** {@inheritDoc} */ + @Override + public SystemInterface getThermoSystem() { + return null; + } - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - return null; - } + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + return null; + } - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} - /** {@inheritDoc} */ - // @Override - // public void createNetCdfFile(String name) {} + /** {@inheritDoc} */ + @Override + public double[][] getPoints(int i) { + return null; + } - /** {@inheritDoc} */ - @Override - public double[][] getPoints(int i) { - return null; - } - - /** {@inheritDoc} */ - @Override - public void addData(String name, double[][] data) {} + /** {@inheritDoc} */ + @Override + public void addData(String name, double[][] data) {} } diff --git a/src/main/java/neqsim/thermodynamicOperations/OperationInterface.java b/src/main/java/neqsim/thermodynamicOperations/OperationInterface.java index 80d9f3a8ba..18a6103b86 100644 --- a/src/main/java/neqsim/thermodynamicOperations/OperationInterface.java +++ b/src/main/java/neqsim/thermodynamicOperations/OperationInterface.java @@ -52,15 +52,6 @@ public interface OperationInterface extends Runnable, java.io.Serializable { */ public String[][] getResultTable(); - /** - *

- * createNetCdfFile. - *

- * - * @param name a {@link java.lang.String} object - */ - //public void createNetCdfFile(String name); - /** *

* printToFile. diff --git a/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java b/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java index 27ed545ab0..1e734d6db5 100644 --- a/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java +++ b/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java @@ -70,1968 +70,1949 @@ * @version $Id: $Id */ public class ThermodynamicOperations implements java.io.Serializable, Cloneable { - private static final long serialVersionUID = 1000; - - private Thread thermoOperationThread = new Thread(); - private OperationInterface operation = null; - SystemInterface system = null; - boolean writeFile = false; - String fileName = null; - private boolean runAsThread = false; - protected String[][] resultTable = null; - static Logger logger = LogManager.getLogger(ThermodynamicOperations.class); - - /** - *

- * Constructor for ThermodynamicOperations. - *

- */ - public ThermodynamicOperations() { - } - - /** - *

- * Constructor for ThermodynamicOperations. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public ThermodynamicOperations(SystemInterface system) { - this.system = system; - } - - /** - *

- * Setter for the field system. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public void setSystem(SystemInterface system) { - this.system = system; - } - - /** - *

- * TPSolidflash. - *

- */ - public void TPSolidflash() { - operation = new SolidFlash1(system); - getOperation().run(); - } - - /** - * Method to perform a flash at given temperature, pressure and specified volume - * The number of - * moles in the system are changed to match the specified volume. - * - * @param volumeSpec is the specified volume - * @param unit Supported units are m3 - */ - public void TPVflash(double volumeSpec, String unit) { - unit = "m3"; - TPflash(); - double startVolume = system.getVolume(unit); - system.setTotalNumberOfMoles(system.getNumberOfMoles() * volumeSpec / startVolume); - system.init(3); - } - - /** - *

- * TPflash. - *

- */ - public void TPflash() { - double flowRate = system.getTotalNumberOfMoles(); - double minimumFlowRate = 1e-50; - if (flowRate < 1e-3) { - system.setTotalNumberOfMoles(1.0); - system.init(1); - } - operation = new neqsim.thermodynamicOperations.flashOps.TPflash(system, - system.doSolidPhaseCheck()); - if (!isRunAsThread()) { - getOperation().run(); - } else { - run(); - } - if (flowRate < 1e-3) { - if (flowRate < minimumFlowRate) { - system.setTotalNumberOfMoles(minimumFlowRate); - } else { - system.setTotalNumberOfMoles(flowRate); - } - system.init(2); - } - } - - /** - *

- * saturateWithWater. - *

- */ - public void saturateWithWater() { - operation = new SaturateWithWater(system); - getOperation().run(); - } - - /** - *

- * TPflash. - *

- * - * @param checkSolids a boolean - */ - public void TPflash(boolean checkSolids) { - operation = new neqsim.thermodynamicOperations.flashOps.TPflash(system, checkSolids); - getOperation().run(); - } - - /** - *

- * TPgradientFlash. - *

- * - * @param height a double - * @param temperature a double - * @return a {@link neqsim.thermo.system.SystemInterface} object - */ - public SystemInterface TPgradientFlash(double height, double temperature) { - operation = new TPgradientFlash(system, height, temperature); - getOperation().run(); - return operation.getThermoSystem(); - } - - /** - *

- * dTPflash. - *

- * - * @param comps an array of {@link java.lang.String} objects - */ - public void dTPflash(String[] comps) { - operation = new dTPflash(system, comps); - getOperation().run(); - } - - /** - *

- * chemicalEquilibrium. - *

- */ - public void chemicalEquilibrium() { - if (system.isChemicalSystem()) { - operation = new neqsim.thermodynamicOperations.chemicalEquilibrium.ChemicalEquilibrium( - system); - getOperation().run(); - } - } - - /** - *

- * PHflash. - *

- * - * @param Hspec a double - * @param type a int - */ - public void PHflash(double Hspec, int type) { - if (system.getPhase(0).getNumberOfComponents() == 1) { - operation = new PHflashSingleComp(system, Hspec, type); - } else { - operation = new PHflash(system, Hspec, type); - } - getOperation().run(); - } - - /** - * Method to perform a PH flash calculation - * - * @param Hspec is the enthalpy in the specified unit - * @param enthalpyUnit Supported units are J, J/mol, J/kg and kJ/kg - */ - public void PHflash(double Hspec, String enthalpyUnit) { - double conversionFactor = 1.0; - switch (enthalpyUnit) { - case "J": - conversionFactor = 1.0; - break; - case "J/mol": - conversionFactor = 1.0 / system.getTotalNumberOfMoles(); - break; - case "J/kg": - conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); - break; - case "kJ/kg": - conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; - break; - } - PHflash(Hspec / conversionFactor); - } - - /** - * Method to perform a PH flash calculation - * - * @param Hspec is the enthalpy in unit Joule to be held constant - */ - public void PHflash(double Hspec) { - this.PHflash(Hspec, 0); - } - - /** - * Method to perform a PH flash calculation based on GERG2008 EoS - * - * @param Hspec is the enthalpy in unit Joule to be held constant - */ - public void PHflashGERG2008(double Hspec) { - operation = new neqsim.thermodynamicOperations.flashOps.PHflashGERG2008(system, Hspec); - getOperation().run(); - } - - /** - *

- * PUflash. - *

- * - * @param Uspec a double - */ - public void PUflash(double Uspec) { - operation = new neqsim.thermodynamicOperations.flashOps.PUflash(system, Uspec); - getOperation().run(); - } - - /** - *

- * PUflash. - *

- * - * @param Pspec a double - * @param Uspec a double - * @param unitPressure a {@link java.lang.String} object - * @param unitEnergy a {@link java.lang.String} object - */ - public void PUflash(double Pspec, double Uspec, String unitPressure, String unitEnergy) { - system.setPressure(Pspec, unitPressure); - PUflash(Uspec, unitEnergy); - } - - /** - *

- * PUflash. - *

- * - * @param Uspec a double - * @param unitEnergy a {@link java.lang.String} object - */ - public void PUflash(double Uspec, String unitEnergy) { - double conversionFactorEntr = 1.0; - switch (unitEnergy) { - case "J": - conversionFactorEntr = 1.0; - break; - case "J/mol": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles(); - break; - case "J/kg": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); - break; - case "kJ/kg": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; - break; - } - PUflash(Uspec / conversionFactorEntr); - } - - /** - *

- * PHflash2. - *

- * - * @param Hspec a double - * @param type a int - */ - public void PHflash2(double Hspec, int type) { - operation = new PHflash(system, Hspec, type); - getOperation().run(); - } - - /** - *

- * criticalPointFlash. - *

- */ - public void criticalPointFlash() { - operation = new CriticalPointFlash(system); - getOperation().run(); - } - - /** - *

- * PHsolidFlash. - *

- * - * @param Hspec a double - */ - public void PHsolidFlash(double Hspec) { - operation = new PHsolidFlash(system, Hspec); - getOperation().run(); - } - - /** - * Method to perform a PS flash calculation for a specified entropy and pressure - * - * @param Sspec is the entropy in the specified unit - * @param unit Supported units are J/K, J/molK, J/kgK and kJ/kgK - */ - public void PSflash(double Sspec, String unit) { - double conversionFactor = 1.0; - switch (unit) { - case "J/K": - conversionFactor = 1.0; - break; - case "J/molK": - conversionFactor = 1.0 / system.getTotalNumberOfMoles(); - break; - case "J/kgK": - conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); - break; - case "kJ/kgK": - conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; - break; - } - PSflash(Sspec / conversionFactor); - } - - /** - * Method to perform a TS flash calculation for a specified entropy and pressure - * - * @param Sspec is the entropy in the specified unit - * @param unit Supported units are J/K, J/molK, J/kgK and kJ/kgK - */ - public void TSflash(double Sspec, String unit) { - double conversionFactor = 1.0; - switch (unit) { - case "J/K": - conversionFactor = 1.0; - break; - case "J/molK": - conversionFactor = 1.0 / system.getTotalNumberOfMoles(); - break; - case "J/kgK": - conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); - break; - case "kJ/kgK": - conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; - break; - } - TSflash(Sspec / conversionFactor); - } - - /** - *

- * PSflash. - *

- * - * @param Sspec a double - */ - public void PSflash(double Sspec) { - if (system.getPhase(0).getNumberOfComponents() == 1) { - operation = new PSflashSingleComp(system, Sspec, 0); - } else { - operation = new PSFlash(system, Sspec, 0); - } - getOperation().run(); - } - - /** - *

- * PSflashGERG2008. - *

- * Run a flash at constant pressure and entropy using the GERG2008 EoS - * - * @param Sspec is the specidfied entropy - */ - public void PSflashGERG2008(double Sspec) { - operation = new PSFlashGERG2008(system, Sspec); - getOperation().run(); - } - - /** - *

- * TSflash. - *

- * - * @param Sspec a double - */ - public void TSflash(double Sspec) { - operation = new TSFlash(system, Sspec); - getOperation().run(); - } - - /** - *

- * PSflash2. - *

- * - * @param Sspec a double - */ - public void PSflash2(double Sspec) { - operation = new PSFlash(system, Sspec, 0); - getOperation().run(); - } - - /** - *

- * VSflash. - *

- * - * @param volume a double - * @param entropy a double - * @param unitVol a {@link java.lang.String} object - * @param unitEntropy a {@link java.lang.String} object - */ - public void VSflash(double volume, double entropy, String unitVol, String unitEntropy) { - double conversionFactorV = 1.0; - double conversionFactorEntr = 1.0; - - switch (unitVol) { - case "m3": - conversionFactorV = 1.0e5; - break; - } - - switch (unitEntropy) { - case "J/K": - conversionFactorEntr = 1.0; - break; - case "J/molK": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles(); - break; - case "J/kgK": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); - break; - case "kJ/kgK": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; - break; - } - VSflash(volume * conversionFactorV, entropy / conversionFactorEntr); - } - - /** - *

- * VSflash. - *

- * - * @param volume a double - * @param entropy a double - */ - public void VSflash(double volume, double entropy) { - operation = new neqsim.thermodynamicOperations.flashOps.VSflash(system, volume, entropy); - getOperation().run(); - } - - /** - *

- * TVflash. - *

- * - * @param Vspec a double - * @param unit a {@link java.lang.String} object - */ - public void TVflash(double Vspec, String unit) { - double conversionFactor = 1.0; - switch (unit) { - case "m3": - conversionFactor = 1.0e5; - break; - } - TVflash(Vspec * conversionFactor); - } - - /** - *

- * TVflash. - *

- * - * @param Vspec a double - */ - public void TVflash(double Vspec) { - operation = new TVflash(system, Vspec); - getOperation().run(); - } - - /** - *

- * PVrefluxFlash. - *

- * - * @param refluxspec a double - * @param refluxPhase a int - */ - public void PVrefluxFlash(double refluxspec, int refluxPhase) { - operation = new PVrefluxflash(system, refluxspec, refluxPhase); - getOperation().run(); - } - - /** - *

- * VHflash. - *

- * - * @param Vspec a double - * @param Hspec a double - */ - public void VHflash(double Vspec, double Hspec) { - operation = new VHflashQfunc(system, Vspec, Hspec); - getOperation().run(); - } - - /** - *

- * VHflash. - *

- * - * @param volume a double - * @param enthalpy a double - * @param unitVol a {@link java.lang.String} object - * @param unitEnthalpy a {@link java.lang.String} object - */ - public void VHflash(double volume, double enthalpy, String unitVol, String unitEnthalpy) { - double conversionFactorV = 1.0; - double conversionFactorEntr = 1.0; - - switch (unitVol) { - case "m3": - conversionFactorV = 1.0e5; - break; - } - - switch (unitEnthalpy) { - case "J/K": - conversionFactorEntr = 1.0; - break; - case "J/mol": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles(); - break; - case "J/kg": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); - break; - case "kJ/kg": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; - break; - } - VHflash(volume * conversionFactorV, enthalpy / conversionFactorEntr); - } - - /** - *

- * VUflash. - *

- * - * @param volume a double - * @param energy a double - * @param unitVol a {@link java.lang.String} object - * @param unitEnergy a {@link java.lang.String} object - */ - public void VUflash(double volume, double energy, String unitVol, String unitEnergy) { - double conversionFactorV = 1.0; - double conversionFactorEntr = 1.0; - - switch (unitVol) { - case "m3": - conversionFactorV = 1.0e5; - break; - } - - switch (unitEnergy) { - case "J/K": - conversionFactorEntr = 1.0; - break; - case "J/mol": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles(); - break; - case "J/kg": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); - break; - case "kJ/kg": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; - break; - } - VUflash(volume * conversionFactorV, energy / conversionFactorEntr); - } - - /** - *

- * VUflash. - *

- * - * @param Vspec a double - * @param Uspec a double - */ - public void VUflash(double Vspec, double Uspec) { - operation = new VUflashQfunc(system, Vspec, Uspec); - getOperation().run(); - } - - /** - *

- * bubblePointTemperatureFlash. - *

- * - * @throws java.lang.Exception if any. - */ - public void bubblePointTemperatureFlash() throws Exception { - constantDutyFlashInterface operation = new bubblePointTemperatureNoDer(system); - operation.run(); - if (Double.isNaN(system.getTemperature()) || operation.isSuperCritical()) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "bubblePointTemperatureFlash", - "Could not find solution - possible no bubble point exists"); - } - } - - /** - *

- * freezingPointTemperatureFlash. - *

- * - * @throws java.lang.Exception if any. - */ - public void freezingPointTemperatureFlash() throws Exception { - operation = new freezingPointTemperatureFlash(system); - getOperation().run(); - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "freezingPointTemperatureFlash", - "Could not find solution - possible no freezing point exists"); - } - } - - /** - *

- * freezingPointTemperatureFlash. - *

- * - * @param phaseName a {@link java.lang.String} object - * @throws java.lang.Exception if any. - */ - public void freezingPointTemperatureFlash(String phaseName) throws Exception { - operation = new freezingPointTemperatureFlash(system); - getOperation().run(); - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "freezingPointTemperatureFlash", - "Could not find solution - possible no freezing point exists"); - } - } - - /** - *

- * waterDewPointTemperatureFlash. - *

- * - * @throws java.lang.Exception if any. - */ - public void waterDewPointTemperatureFlash() throws Exception { - operation = new waterDewPointTemperatureFlash(system); - getOperation().run(); - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "waterDewPointTemperatureFlash", - "Could not find solution - possible no dew point exists"); - } - } - - /** - *

- * waterDewPointTemperatureMultiphaseFlash. - *

- * - * @throws java.lang.Exception if any. - */ - public void waterDewPointTemperatureMultiphaseFlash() throws Exception { - operation = new waterDewPointTemperatureMultiphaseFlash(system); - getOperation().run(); - } - - /** - *

- * waterPrecipitationTemperature. - *

- * - * @throws java.lang.Exception if any. - */ - public void waterPrecipitationTemperature() throws Exception { - double lowTemperature = 0.0; - dewPointTemperatureFlash(); - - if (system.getTemperature() > lowTemperature) { - lowTemperature = system.getTemperature(); - } - - // if(lowTemperature<273.15 && system.doSolidPhaseCheck()){ - // hydrateFormationTemperature(0); - // if(system.getTemperature()>lowTemperature) lowTemperature = - // system.getTemperature(); - // } - - // if(system.doHydrateCheck()){ - // hydrateFormationTemperature(1); - // if(system.getTemperature()>lowTemperature) lowTemperature = - // system.getTemperature(); - // hydrateFormationTemperature(2); - // if(system.getTemperature()>lowTemperature) lowTemperature = - // system.getTemperature(); - // } - - system.setTemperature(lowTemperature); - // TPflash(); - - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "waterPrecipitationTemperature", - "Could not find solution - possible no dew point exists"); - } - } - - /** - *

- * calcSaltSaturation. - *

- * - * @param saltName a {@link java.lang.String} object - * @throws java.lang.Exception if any. - */ - public void calcSaltSaturation(String saltName) throws Exception { - operation = new calcSaltSatauration(system, saltName); - getOperation().run(); - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "calcSaltSaturation", "Could not find solution - possible no dew point exists"); - } - } - - /** - *

- * checkScalePotential. - *

- * - * @param phaseNumber a int - * @throws java.lang.Exception if any. - */ - public void checkScalePotential(int phaseNumber) throws Exception { - operation = new checkScalePotential(system, phaseNumber); - getOperation().run(); - resultTable = getOperation().getResultTable(); - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "checkScalePotential", "Could not find solution - possible no dew point exists"); - } - } - - /** - *

- * addIonToScaleSaturation. - *

- * - * @param phaseNumber a int - * @param scaleSaltName a {@link java.lang.String} object - * @param nameOfIonToBeAdded a {@link java.lang.String} object - * @throws java.lang.Exception if any. - */ - public void addIonToScaleSaturation(int phaseNumber, String scaleSaltName, - String nameOfIonToBeAdded) throws Exception { - operation = new addIonToScaleSaturation(system, phaseNumber, scaleSaltName, nameOfIonToBeAdded); - getOperation().run(); - resultTable = getOperation().getResultTable(); - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "addIonToScaleSaturation", "Could not find solution - possible no dew point exists"); - } - } - - /** - *

- * hydrateFormationPressure. - *

- * - * @throws java.lang.Exception if any. - */ - public void hydrateFormationPressure() throws Exception { - operation = new HydrateFormationPressureFlash(system); - getOperation().run(); - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "hydrateFormationPressure", "Could not find solution - possible no dew point exists"); - } - } - - /** - *

- * calcWAT. - *

- * - * @throws java.lang.Exception if any. - */ - public void calcWAT() throws Exception { - operation = new WATcalc(system); - getOperation().run(); - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), "calcWAT", - "Could not find solution - possible no dew point exists"); - } - } - - /** - *

- * run. - *

- */ - public void run() { - setThermoOperationThread(new Thread(operation)); - getThermoOperationThread().start(); - } - - /** - *

- * waitAndCheckForFinishedCalculation. - *

- * - * @param maxTime a int - * @return a boolean - */ - public boolean waitAndCheckForFinishedCalculation(int maxTime) { - try { - getThermoOperationThread().join(maxTime); - getThermoOperationThread().interrupt(); - } catch (Exception e) { - logger.error("error", e); - } - boolean didFinish = !getThermoOperationThread().isInterrupted(); - // getThermoOperationThread().stop(); - return didFinish; - } - - /** - *

- * waitToFinishCalculation. - *

- */ - public void waitToFinishCalculation() { - try { - getThermoOperationThread().join(); - } catch (Exception e) { - logger.error("error", e); - } - } - - /** - *

- * calcSolidComlexTemperature. - *

- * - * @throws java.lang.Exception if any. - */ - public void calcSolidComlexTemperature() throws Exception { - operation = new SolidComplexTemperatureCalc(system); - getOperation().run(); - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "calcSolidComlexTemperature", - "error in WAT() - could not find solution - possible no dew point exists"); - } - } - - /** - *

- * calcSolidComlexTemperature. - *

- * - * @param comp1 a {@link java.lang.String} object - * @param comp2 a {@link java.lang.String} object - * @throws java.lang.Exception if any. - */ - public void calcSolidComlexTemperature(String comp1, String comp2) throws Exception { - if (operation == null) { - operation = new SolidComplexTemperatureCalc(system, comp1, comp2); - } - getOperation().run(); - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "calcSolidComlexTemperature", - "error in WAT() - could not find solution - possible no dew point exists"); - } - } - - /** - *

- * calcImobilePhaseHydrateTemperature. - *

- * - * @param temperature an array of {@link double} objects - * @param pressure an array of {@link double} objects - * @return an array of {@link double} objects - */ - public double[] calcImobilePhaseHydrateTemperature(double[] temperature, double[] pressure) { - double[] hydTemps = new double[temperature.length]; - SystemInterface systemTemp; - ThermodynamicOperations opsTemp; - systemTemp = system.clone(); - - for (int i = 0; i < temperature.length; i++) { - /* - * opsTemp = new ThermodynamicOperations(systemTemp); - * systemTemp.setTemperature(temperature[i]); - * systemTemp.setPressure(pressure[i]); - * systemTemp.init(0); systemTemp.display(); try { - * opsTemp.hydrateFormationTemperature(); } catch (Exception e) { - * logger.error("error",e); } systemTemp.display(); hydTemps[i] = - * systemTemp.getTemperature(); - * - */ - opsTemp = new ThermodynamicOperations(systemTemp); - systemTemp.setTemperature(temperature[i]); - systemTemp.setPressure(pressure[i]); - - opsTemp.TPflash(); - systemTemp.display(); - systemTemp = systemTemp.phaseToSystem(0); - } - - opsTemp = new ThermodynamicOperations(systemTemp); - systemTemp.setHydrateCheck(true); - systemTemp.setMixingRule(9); - try { - opsTemp.hydrateFormationTemperature(); - } catch (Exception e) { - logger.error("error", e); - } - systemTemp.display(); - return hydTemps; - } - - /** - *

- * calcTOLHydrateFormationTemperature. - *

- * - * @return a double - */ - public double calcTOLHydrateFormationTemperature() { - TPflash(); - - SystemInterface systemTemp = system.phaseToSystem(0); - ThermodynamicOperations opsTemp = new ThermodynamicOperations(systemTemp); - try { - opsTemp.hydrateFormationTemperature(); - } catch (Exception e) { - logger.error("error", e); - } - systemTemp.display(); - system.setTemperature(systemTemp.getTemperature()); - TPflash(); - return system.getTemperature(); - } - - /** - *

- * hydrateInhibitorConcentration. - *

- * - * @param inhibitorName a {@link java.lang.String} object - * @param hydEqTemperature a double - * @throws java.lang.Exception if any. - */ - public void hydrateInhibitorConcentration(String inhibitorName, double hydEqTemperature) - throws Exception { - operation = new HydrateInhibitorConcentrationFlash(system, inhibitorName, hydEqTemperature); - operation.run(); - } - - /** - *

- * hydrateInhibitorConcentrationSet. - *

- * - * @param inhibitorName a {@link java.lang.String} object - * @param wtfrac a double - * @throws java.lang.Exception if any. - */ - public void hydrateInhibitorConcentrationSet(String inhibitorName, double wtfrac) - throws Exception { - operation = new HydrateInhibitorwtFlash(system, inhibitorName, wtfrac); - operation.run(); - } - - /** - *

- * hydrateFormationTemperature. - *

- * - * @param initialTemperatureGuess a double - * @throws java.lang.Exception if any. - */ - public void hydrateFormationTemperature(double initialTemperatureGuess) throws Exception { - system.setTemperature(initialTemperatureGuess); - operation = new HydrateFormationTemperatureFlash(system); - for (int i = 0; i < system.getPhase(4).getNumberOfComponents(); i++) { - ((ComponentHydrate) system.getPhase(4).getComponent(i)).getHydrateStructure(); - } - if (!isRunAsThread()) { - getOperation().run(); - } else { - run(); - } - } - - /** - *

- * hydrateFormationTemperature. - *

- * - * @throws java.lang.Exception if any. - */ - public void hydrateFormationTemperature() throws Exception { - // guessing temperature - double factor = 1.0; - if (system.getPhase(0).hasComponent("methanol")) { - factor -= 2 * system.getPhase(0).getComponent("methanol").getz() - / system.getPhase(0).getComponent("water").getz(); - } - if (system.getPhase(0).hasComponent("MEG")) { - factor -= 2 * system.getPhase(0).getComponent("MEG").getz() - / system.getPhase(0).getComponent("water").getz(); - } - if (factor < 2) { - factor = 2; - } - - system.setTemperature(273.0 + system.getPressure() / 100.0 * 20.0 * factor - 20.0); - if (system.getTemperature() > 298.15) { - system.setTemperature(273.0 + 25.0); - } - // logger.info("guess hydrate temperature " + system.getTemperature()); - operation = new HydrateFormationTemperatureFlash(system); - - for (int i = 0; i < system.getPhase(4).getNumberOfComponents(); i++) { - ((ComponentHydrate) system.getPhase(4).getComponent(i)).getHydrateStructure(); - } - if (!isRunAsThread()) { - getOperation().run(); - } else { - run(); - } - // logger.info("Hydrate structure " + (((ComponentHydrate) - // system.getPhase(4).getComponent("water")).getHydrateStructure() + 1)); - } - - /** - *

- * hydrateEquilibriumLine. - *

- * - * @param minimumPressure a double - * @param maximumPressure a double - * @throws java.lang.Exception if any. - */ - public void hydrateEquilibriumLine(double minimumPressure, double maximumPressure) - throws Exception { - operation = new HydrateEquilibriumLine(system, minimumPressure, maximumPressure); - if (!isRunAsThread()) { - getOperation().run(); - } else { - run(); - } - } - - /** - *

- * calcCricoP. - *

- * - * @param cricondenBar an array of {@link double} objects - * @param cricondenBarX an array of {@link double} objects - * @param cricondenBarY an array of {@link double} objects - */ - public void calcCricoP(double[] cricondenBar, double[] cricondenBarX, double[] cricondenBarY) { - double phasefraction = 1.0 - 1e-10; - - operation = new CricondenBarFlash(system, fileName, phasefraction, cricondenBar, - cricondenBarX, cricondenBarY); - - getOperation().run(); - } - - /** - *

- * calcCricoT. - *

- * - * @param cricondenTherm an array of {@link double} objects - * @param cricondenThermX an array of {@link double} objects - * @param cricondenThermY an array of {@link double} objects - */ - public void calcCricoT(double[] cricondenTherm, double[] cricondenThermX, - double[] cricondenThermY) { - double phasefraction = 1.0 - 1e-10; - - operation = new CricondenThermFlash(system, fileName, phasefraction, cricondenTherm, - cricondenThermX, cricondenThermY); - - getOperation().run(); - } - - /** - *

- * waterDewPointLine. - *

- * - * @param minimumPressure a double - * @param maximumPressure a double - * @throws java.lang.Exception if any. - */ - public void waterDewPointLine(double minimumPressure, double maximumPressure) throws Exception { - operation = new WaterDewPointEquilibriumLine(system, minimumPressure, maximumPressure); - if (!isRunAsThread()) { - getOperation().run(); - } else { - run(); - } - } - - /** - *

- * hydrateFormationTemperature. - *

- * - * @param structure a int - * @throws java.lang.Exception if any. - */ - public void hydrateFormationTemperature(int structure) throws Exception { - system.setTemperature(273.0 + 1.0); - if (structure == 0) { - system.setSolidPhaseCheck("water"); - system.setHydrateCheck(true); - operation = new freezingPointTemperatureFlash(system); - } else { - operation = new HydrateFormationTemperatureFlash(system); - } - - for (int i = 0; i < system.getPhase(4).getNumberOfComponents(); i++) { - ((ComponentHydrate) system.getPhases()[4].getComponent(i)) - .setHydrateStructure(structure - 1); - } - if (!isRunAsThread()) { - getOperation().run(); - } else { - run(); - } - - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "hydrateFormationTemperature", - "Could not find solution - possible no dew point exists"); - } - } - - /** - *

- * calcCricondenBar. - *

- * - * @return a double - */ - public double calcCricondenBar() { - system.init(0); - operation = new cricondebarFlash(system); - // operation = new CricondenBarFlash(system); - - // operation = new cricondenBarTemp1(system); - operation.run(); - return system.getPressure(); - } - - /** - *

- * bubblePointPressureFlash. - *

- * - * @throws java.lang.Exception if any. - */ - public void bubblePointPressureFlash() throws Exception { - system.init(0); - constantDutyFlashInterface operation = new constantDutyPressureFlash(system); - system.setBeta(1, 1.0 - 1e-10); - system.setBeta(0, 1e-10); - operation.run(); - if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "bubblePointPressureFlash", "Could not find solution - possible no dew point exists"); - } - } + private static final long serialVersionUID = 1000; + + private Thread thermoOperationThread = new Thread(); + private OperationInterface operation = null; + SystemInterface system = null; + boolean writeFile = false; + String fileName = null; + private boolean runAsThread = false; + protected String[][] resultTable = null; + static Logger logger = LogManager.getLogger(ThermodynamicOperations.class); + + /** + *

+ * Constructor for ThermodynamicOperations. + *

+ */ + public ThermodynamicOperations() {} + + /** + *

+ * Constructor for ThermodynamicOperations. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public ThermodynamicOperations(SystemInterface system) { + this.system = system; + } + + /** + *

+ * Setter for the field system. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public void setSystem(SystemInterface system) { + this.system = system; + } + + /** + *

+ * TPSolidflash. + *

+ */ + public void TPSolidflash() { + operation = new SolidFlash1(system); + getOperation().run(); + } + + /** + * Method to perform a flash at given temperature, pressure and specified volume The number of + * moles in the system are changed to match the specified volume. + * + * @param volumeSpec is the specified volume + * @param unit Supported units are m3 + */ + public void TPVflash(double volumeSpec, String unit) { + unit = "m3"; + TPflash(); + double startVolume = system.getVolume(unit); + system.setTotalNumberOfMoles(system.getNumberOfMoles() * volumeSpec / startVolume); + system.init(3); + } + + /** + *

+ * TPflash. + *

+ */ + public void TPflash() { + double flowRate = system.getTotalNumberOfMoles(); + double minimumFlowRate = 1e-50; + if (flowRate < 1e-3) { + system.setTotalNumberOfMoles(1.0); + system.init(1); + } + operation = + new neqsim.thermodynamicOperations.flashOps.TPflash(system, system.doSolidPhaseCheck()); + if (!isRunAsThread()) { + getOperation().run(); + } else { + run(); + } + if (flowRate < 1e-3) { + if (flowRate < minimumFlowRate) { + system.setTotalNumberOfMoles(minimumFlowRate); + } else { + system.setTotalNumberOfMoles(flowRate); + } + system.init(2); + } + } + + /** + *

+ * saturateWithWater. + *

+ */ + public void saturateWithWater() { + operation = new SaturateWithWater(system); + getOperation().run(); + } + + /** + *

+ * TPflash. + *

+ * + * @param checkSolids a boolean + */ + public void TPflash(boolean checkSolids) { + operation = new neqsim.thermodynamicOperations.flashOps.TPflash(system, checkSolids); + getOperation().run(); + } + + /** + *

+ * TPgradientFlash. + *

+ * + * @param height a double + * @param temperature a double + * @return a {@link neqsim.thermo.system.SystemInterface} object + */ + public SystemInterface TPgradientFlash(double height, double temperature) { + operation = new TPgradientFlash(system, height, temperature); + getOperation().run(); + return operation.getThermoSystem(); + } + + /** + *

+ * dTPflash. + *

+ * + * @param comps an array of {@link java.lang.String} objects + */ + public void dTPflash(String[] comps) { + operation = new dTPflash(system, comps); + getOperation().run(); + } + + /** + *

+ * chemicalEquilibrium. + *

+ */ + public void chemicalEquilibrium() { + if (system.isChemicalSystem()) { + operation = + new neqsim.thermodynamicOperations.chemicalEquilibrium.ChemicalEquilibrium(system); + getOperation().run(); + } + } + + /** + *

+ * PHflash. + *

+ * + * @param Hspec a double + * @param type a int + */ + public void PHflash(double Hspec, int type) { + if (system.getPhase(0).getNumberOfComponents() == 1) { + operation = new PHflashSingleComp(system, Hspec, type); + } else { + operation = new PHflash(system, Hspec, type); + } + getOperation().run(); + } + + /** + * Method to perform a PH flash calculation + * + * @param Hspec is the enthalpy in the specified unit + * @param enthalpyUnit Supported units are J, J/mol, J/kg and kJ/kg + */ + public void PHflash(double Hspec, String enthalpyUnit) { + double conversionFactor = 1.0; + switch (enthalpyUnit) { + case "J": + conversionFactor = 1.0; + break; + case "J/mol": + conversionFactor = 1.0 / system.getTotalNumberOfMoles(); + break; + case "J/kg": + conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); + break; + case "kJ/kg": + conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; + break; + } + PHflash(Hspec / conversionFactor); + } + + /** + * Method to perform a PH flash calculation + * + * @param Hspec is the enthalpy in unit Joule to be held constant + */ + public void PHflash(double Hspec) { + this.PHflash(Hspec, 0); + } + + /** + * Method to perform a PH flash calculation based on GERG2008 EoS + * + * @param Hspec is the enthalpy in unit Joule to be held constant + */ + public void PHflashGERG2008(double Hspec) { + operation = new neqsim.thermodynamicOperations.flashOps.PHflashGERG2008(system, Hspec); + getOperation().run(); + } + + /** + *

+ * PUflash. + *

+ * + * @param Uspec a double + */ + public void PUflash(double Uspec) { + operation = new neqsim.thermodynamicOperations.flashOps.PUflash(system, Uspec); + getOperation().run(); + } + + /** + *

+ * PUflash. + *

+ * + * @param Pspec a double + * @param Uspec a double + * @param unitPressure a {@link java.lang.String} object + * @param unitEnergy a {@link java.lang.String} object + */ + public void PUflash(double Pspec, double Uspec, String unitPressure, String unitEnergy) { + system.setPressure(Pspec, unitPressure); + PUflash(Uspec, unitEnergy); + } + + /** + *

+ * PUflash. + *

+ * + * @param Uspec a double + * @param unitEnergy a {@link java.lang.String} object + */ + public void PUflash(double Uspec, String unitEnergy) { + double conversionFactorEntr = 1.0; + switch (unitEnergy) { + case "J": + conversionFactorEntr = 1.0; + break; + case "J/mol": + conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles(); + break; + case "J/kg": + conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); + break; + case "kJ/kg": + conversionFactorEntr = + 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; + break; + } + PUflash(Uspec / conversionFactorEntr); + } + + /** + *

+ * PHflash2. + *

+ * + * @param Hspec a double + * @param type a int + */ + public void PHflash2(double Hspec, int type) { + operation = new PHflash(system, Hspec, type); + getOperation().run(); + } + + /** + *

+ * criticalPointFlash. + *

+ */ + public void criticalPointFlash() { + operation = new CriticalPointFlash(system); + getOperation().run(); + } + + /** + *

+ * PHsolidFlash. + *

+ * + * @param Hspec a double + */ + public void PHsolidFlash(double Hspec) { + operation = new PHsolidFlash(system, Hspec); + getOperation().run(); + } + + /** + * Method to perform a PS flash calculation for a specified entropy and pressure + * + * @param Sspec is the entropy in the specified unit + * @param unit Supported units are J/K, J/molK, J/kgK and kJ/kgK + */ + public void PSflash(double Sspec, String unit) { + double conversionFactor = 1.0; + switch (unit) { + case "J/K": + conversionFactor = 1.0; + break; + case "J/molK": + conversionFactor = 1.0 / system.getTotalNumberOfMoles(); + break; + case "J/kgK": + conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); + break; + case "kJ/kgK": + conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; + break; + } + PSflash(Sspec / conversionFactor); + } + + /** + * Method to perform a TS flash calculation for a specified entropy and pressure + * + * @param Sspec is the entropy in the specified unit + * @param unit Supported units are J/K, J/molK, J/kgK and kJ/kgK + */ + public void TSflash(double Sspec, String unit) { + double conversionFactor = 1.0; + switch (unit) { + case "J/K": + conversionFactor = 1.0; + break; + case "J/molK": + conversionFactor = 1.0 / system.getTotalNumberOfMoles(); + break; + case "J/kgK": + conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); + break; + case "kJ/kgK": + conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; + break; + } + TSflash(Sspec / conversionFactor); + } + + /** + *

+ * PSflash. + *

+ * + * @param Sspec a double + */ + public void PSflash(double Sspec) { + if (system.getPhase(0).getNumberOfComponents() == 1) { + operation = new PSflashSingleComp(system, Sspec, 0); + } else { + operation = new PSFlash(system, Sspec, 0); + } + getOperation().run(); + } + + /** + *

+ * PSflashGERG2008. + *

+ * Run a flash at constant pressure and entropy using the GERG2008 EoS + * + * @param Sspec is the specidfied entropy + */ + public void PSflashGERG2008(double Sspec) { + operation = new PSFlashGERG2008(system, Sspec); + getOperation().run(); + } + + /** + *

+ * TSflash. + *

+ * + * @param Sspec a double + */ + public void TSflash(double Sspec) { + operation = new TSFlash(system, Sspec); + getOperation().run(); + } + + /** + *

+ * PSflash2. + *

+ * + * @param Sspec a double + */ + public void PSflash2(double Sspec) { + operation = new PSFlash(system, Sspec, 0); + getOperation().run(); + } + + /** + *

+ * VSflash. + *

+ * + * @param volume a double + * @param entropy a double + * @param unitVol a {@link java.lang.String} object + * @param unitEntropy a {@link java.lang.String} object + */ + public void VSflash(double volume, double entropy, String unitVol, String unitEntropy) { + double conversionFactorV = 1.0; + double conversionFactorEntr = 1.0; + + switch (unitVol) { + case "m3": + conversionFactorV = 1.0e5; + break; + } + + switch (unitEntropy) { + case "J/K": + conversionFactorEntr = 1.0; + break; + case "J/molK": + conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles(); + break; + case "J/kgK": + conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); + break; + case "kJ/kgK": + conversionFactorEntr = + 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; + break; + } + VSflash(volume * conversionFactorV, entropy / conversionFactorEntr); + } + + /** + *

+ * VSflash. + *

+ * + * @param volume a double + * @param entropy a double + */ + public void VSflash(double volume, double entropy) { + operation = new neqsim.thermodynamicOperations.flashOps.VSflash(system, volume, entropy); + getOperation().run(); + } + + /** + *

+ * TVflash. + *

+ * + * @param Vspec a double + * @param unit a {@link java.lang.String} object + */ + public void TVflash(double Vspec, String unit) { + double conversionFactor = 1.0; + switch (unit) { + case "m3": + conversionFactor = 1.0e5; + break; + } + TVflash(Vspec * conversionFactor); + } + + /** + *

+ * TVflash. + *

+ * + * @param Vspec a double + */ + public void TVflash(double Vspec) { + operation = new TVflash(system, Vspec); + getOperation().run(); + } + + /** + *

+ * PVrefluxFlash. + *

+ * + * @param refluxspec a double + * @param refluxPhase a int + */ + public void PVrefluxFlash(double refluxspec, int refluxPhase) { + operation = new PVrefluxflash(system, refluxspec, refluxPhase); + getOperation().run(); + } + + /** + *

+ * VHflash. + *

+ * + * @param Vspec a double + * @param Hspec a double + */ + public void VHflash(double Vspec, double Hspec) { + operation = new VHflashQfunc(system, Vspec, Hspec); + getOperation().run(); + } + + /** + *

+ * VHflash. + *

+ * + * @param volume a double + * @param enthalpy a double + * @param unitVol a {@link java.lang.String} object + * @param unitEnthalpy a {@link java.lang.String} object + */ + public void VHflash(double volume, double enthalpy, String unitVol, String unitEnthalpy) { + double conversionFactorV = 1.0; + double conversionFactorEntr = 1.0; + + switch (unitVol) { + case "m3": + conversionFactorV = 1.0e5; + break; + } + + switch (unitEnthalpy) { + case "J/K": + conversionFactorEntr = 1.0; + break; + case "J/mol": + conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles(); + break; + case "J/kg": + conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); + break; + case "kJ/kg": + conversionFactorEntr = + 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; + break; + } + VHflash(volume * conversionFactorV, enthalpy / conversionFactorEntr); + } + + /** + *

+ * VUflash. + *

+ * + * @param volume a double + * @param energy a double + * @param unitVol a {@link java.lang.String} object + * @param unitEnergy a {@link java.lang.String} object + */ + public void VUflash(double volume, double energy, String unitVol, String unitEnergy) { + double conversionFactorV = 1.0; + double conversionFactorEntr = 1.0; + + switch (unitVol) { + case "m3": + conversionFactorV = 1.0e5; + break; + } + + switch (unitEnergy) { + case "J/K": + conversionFactorEntr = 1.0; + break; + case "J/mol": + conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles(); + break; + case "J/kg": + conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); + break; + case "kJ/kg": + conversionFactorEntr = + 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; + break; + } + VUflash(volume * conversionFactorV, energy / conversionFactorEntr); + } + + /** + *

+ * VUflash. + *

+ * + * @param Vspec a double + * @param Uspec a double + */ + public void VUflash(double Vspec, double Uspec) { + operation = new VUflashQfunc(system, Vspec, Uspec); + getOperation().run(); + } + + /** + *

+ * bubblePointTemperatureFlash. + *

+ * + * @throws java.lang.Exception if any. + */ + public void bubblePointTemperatureFlash() throws Exception { + constantDutyFlashInterface operation = new bubblePointTemperatureNoDer(system); + operation.run(); + if (Double.isNaN(system.getTemperature()) || operation.isSuperCritical()) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "bubblePointTemperatureFlash", + "Could not find solution - possible no bubble point exists"); + } + } + + /** + *

+ * freezingPointTemperatureFlash. + *

+ * + * @throws java.lang.Exception if any. + */ + public void freezingPointTemperatureFlash() throws Exception { + operation = new freezingPointTemperatureFlash(system); + getOperation().run(); + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "freezingPointTemperatureFlash", + "Could not find solution - possible no freezing point exists"); + } + } + + /** + *

+ * freezingPointTemperatureFlash. + *

+ * + * @param phaseName a {@link java.lang.String} object + * @throws java.lang.Exception if any. + */ + public void freezingPointTemperatureFlash(String phaseName) throws Exception { + operation = new freezingPointTemperatureFlash(system); + getOperation().run(); + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "freezingPointTemperatureFlash", + "Could not find solution - possible no freezing point exists"); + } + } + + /** + *

+ * waterDewPointTemperatureFlash. + *

+ * + * @throws java.lang.Exception if any. + */ + public void waterDewPointTemperatureFlash() throws Exception { + operation = new waterDewPointTemperatureFlash(system); + getOperation().run(); + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "waterDewPointTemperatureFlash", + "Could not find solution - possible no dew point exists"); + } + } + + /** + *

+ * waterDewPointTemperatureMultiphaseFlash. + *

+ * + * @throws java.lang.Exception if any. + */ + public void waterDewPointTemperatureMultiphaseFlash() throws Exception { + operation = new waterDewPointTemperatureMultiphaseFlash(system); + getOperation().run(); + } + + /** + *

+ * waterPrecipitationTemperature. + *

+ * + * @throws java.lang.Exception if any. + */ + public void waterPrecipitationTemperature() throws Exception { + double lowTemperature = 0.0; + dewPointTemperatureFlash(); + + if (system.getTemperature() > lowTemperature) { + lowTemperature = system.getTemperature(); + } + + // if(lowTemperature<273.15 && system.doSolidPhaseCheck()){ + // hydrateFormationTemperature(0); + // if(system.getTemperature()>lowTemperature) lowTemperature = + // system.getTemperature(); + // } - /** - *

- * constantPhaseFractionPressureFlash. - *

- * - * @param fraction a double - * @throws java.lang.Exception if any. - */ - public void constantPhaseFractionPressureFlash(double fraction) throws Exception { - system.init(0); - if (fraction < 1e-10) { - fraction = 1e-10; - } - if (fraction > 1.0 - 1e-10) { - fraction = 1.0 - 1.0e-10; - } - constantDutyFlashInterface operation = new constantDutyPressureFlash(system); - system.setBeta(1, 1.0 - fraction); - system.setBeta(0, fraction); - operation.run(); - if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "constantPhaseFractionPressureFlash", - "Could not find solution - possible no dew point exists"); - } - } + // if(system.doHydrateCheck()){ + // hydrateFormationTemperature(1); + // if(system.getTemperature()>lowTemperature) lowTemperature = + // system.getTemperature(); + // hydrateFormationTemperature(2); + // if(system.getTemperature()>lowTemperature) lowTemperature = + // system.getTemperature(); + // } - /** - *

- * constantPhaseFractionTemperatureFlash. - *

- * - * @param fraction a double - * @throws java.lang.Exception if any. - */ - public void constantPhaseFractionTemperatureFlash(double fraction) throws Exception { + system.setTemperature(lowTemperature); + // TPflash(); + + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "waterPrecipitationTemperature", + "Could not find solution - possible no dew point exists"); + } + } + + /** + *

+ * calcSaltSaturation. + *

+ * + * @param saltName a {@link java.lang.String} object + * @throws java.lang.Exception if any. + */ + public void calcSaltSaturation(String saltName) throws Exception { + operation = new calcSaltSatauration(system, saltName); + getOperation().run(); + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "calcSaltSaturation", "Could not find solution - possible no dew point exists"); + } + } + + /** + *

+ * checkScalePotential. + *

+ * + * @param phaseNumber a int + * @throws java.lang.Exception if any. + */ + public void checkScalePotential(int phaseNumber) throws Exception { + operation = new checkScalePotential(system, phaseNumber); + getOperation().run(); + resultTable = getOperation().getResultTable(); + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "checkScalePotential", "Could not find solution - possible no dew point exists"); + } + } + + /** + *

+ * addIonToScaleSaturation. + *

+ * + * @param phaseNumber a int + * @param scaleSaltName a {@link java.lang.String} object + * @param nameOfIonToBeAdded a {@link java.lang.String} object + * @throws java.lang.Exception if any. + */ + public void addIonToScaleSaturation(int phaseNumber, String scaleSaltName, + String nameOfIonToBeAdded) throws Exception { + operation = new addIonToScaleSaturation(system, phaseNumber, scaleSaltName, nameOfIonToBeAdded); + getOperation().run(); + resultTable = getOperation().getResultTable(); + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "addIonToScaleSaturation", "Could not find solution - possible no dew point exists"); + } + } + + /** + *

+ * hydrateFormationPressure. + *

+ * + * @throws java.lang.Exception if any. + */ + public void hydrateFormationPressure() throws Exception { + operation = new HydrateFormationPressureFlash(system); + getOperation().run(); + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "hydrateFormationPressure", "Could not find solution - possible no dew point exists"); + } + } + + /** + *

+ * calcWAT. + *

+ * + * @throws java.lang.Exception if any. + */ + public void calcWAT() throws Exception { + operation = new WATcalc(system); + getOperation().run(); + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), "calcWAT", + "Could not find solution - possible no dew point exists"); + } + } + + /** + *

+ * run. + *

+ */ + public void run() { + setThermoOperationThread(new Thread(operation)); + getThermoOperationThread().start(); + } + + /** + *

+ * waitAndCheckForFinishedCalculation. + *

+ * + * @param maxTime a int + * @return a boolean + */ + public boolean waitAndCheckForFinishedCalculation(int maxTime) { + try { + getThermoOperationThread().join(maxTime); + getThermoOperationThread().interrupt(); + } catch (Exception e) { + logger.error("error", e); + } + boolean didFinish = !getThermoOperationThread().isInterrupted(); + // getThermoOperationThread().stop(); + return didFinish; + } + + /** + *

+ * waitToFinishCalculation. + *

+ */ + public void waitToFinishCalculation() { + try { + getThermoOperationThread().join(); + } catch (Exception e) { + logger.error("error", e); + } + } + + /** + *

+ * calcSolidComlexTemperature. + *

+ * + * @throws java.lang.Exception if any. + */ + public void calcSolidComlexTemperature() throws Exception { + operation = new SolidComplexTemperatureCalc(system); + getOperation().run(); + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "calcSolidComlexTemperature", + "error in WAT() - could not find solution - possible no dew point exists"); + } + } + + /** + *

+ * calcSolidComlexTemperature. + *

+ * + * @param comp1 a {@link java.lang.String} object + * @param comp2 a {@link java.lang.String} object + * @throws java.lang.Exception if any. + */ + public void calcSolidComlexTemperature(String comp1, String comp2) throws Exception { + if (operation == null) { + operation = new SolidComplexTemperatureCalc(system, comp1, comp2); + } + getOperation().run(); + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "calcSolidComlexTemperature", + "error in WAT() - could not find solution - possible no dew point exists"); + } + } + + /** + *

+ * calcImobilePhaseHydrateTemperature. + *

+ * + * @param temperature an array of {@link double} objects + * @param pressure an array of {@link double} objects + * @return an array of {@link double} objects + */ + public double[] calcImobilePhaseHydrateTemperature(double[] temperature, double[] pressure) { + double[] hydTemps = new double[temperature.length]; + SystemInterface systemTemp; + ThermodynamicOperations opsTemp; + systemTemp = system.clone(); + + for (int i = 0; i < temperature.length; i++) { + /* + * opsTemp = new ThermodynamicOperations(systemTemp); + * systemTemp.setTemperature(temperature[i]); systemTemp.setPressure(pressure[i]); + * systemTemp.init(0); systemTemp.display(); try { opsTemp.hydrateFormationTemperature(); } + * catch (Exception e) { logger.error("error",e); } systemTemp.display(); hydTemps[i] = + * systemTemp.getTemperature(); + * + */ + opsTemp = new ThermodynamicOperations(systemTemp); + systemTemp.setTemperature(temperature[i]); + systemTemp.setPressure(pressure[i]); + + opsTemp.TPflash(); + systemTemp.display(); + systemTemp = systemTemp.phaseToSystem(0); + } + + opsTemp = new ThermodynamicOperations(systemTemp); + systemTemp.setHydrateCheck(true); + systemTemp.setMixingRule(9); + try { + opsTemp.hydrateFormationTemperature(); + } catch (Exception e) { + logger.error("error", e); + } + systemTemp.display(); + return hydTemps; + } + + /** + *

+ * calcTOLHydrateFormationTemperature. + *

+ * + * @return a double + */ + public double calcTOLHydrateFormationTemperature() { + TPflash(); + + SystemInterface systemTemp = system.phaseToSystem(0); + ThermodynamicOperations opsTemp = new ThermodynamicOperations(systemTemp); + try { + opsTemp.hydrateFormationTemperature(); + } catch (Exception e) { + logger.error("error", e); + } + systemTemp.display(); + system.setTemperature(systemTemp.getTemperature()); + TPflash(); + return system.getTemperature(); + } + + /** + *

+ * hydrateInhibitorConcentration. + *

+ * + * @param inhibitorName a {@link java.lang.String} object + * @param hydEqTemperature a double + * @throws java.lang.Exception if any. + */ + public void hydrateInhibitorConcentration(String inhibitorName, double hydEqTemperature) + throws Exception { + operation = new HydrateInhibitorConcentrationFlash(system, inhibitorName, hydEqTemperature); + operation.run(); + } + + /** + *

+ * hydrateInhibitorConcentrationSet. + *

+ * + * @param inhibitorName a {@link java.lang.String} object + * @param wtfrac a double + * @throws java.lang.Exception if any. + */ + public void hydrateInhibitorConcentrationSet(String inhibitorName, double wtfrac) + throws Exception { + operation = new HydrateInhibitorwtFlash(system, inhibitorName, wtfrac); + operation.run(); + } + + /** + *

+ * hydrateFormationTemperature. + *

+ * + * @param initialTemperatureGuess a double + * @throws java.lang.Exception if any. + */ + public void hydrateFormationTemperature(double initialTemperatureGuess) throws Exception { + system.setTemperature(initialTemperatureGuess); + operation = new HydrateFormationTemperatureFlash(system); + for (int i = 0; i < system.getPhase(4).getNumberOfComponents(); i++) { + ((ComponentHydrate) system.getPhase(4).getComponent(i)).getHydrateStructure(); + } + if (!isRunAsThread()) { + getOperation().run(); + } else { + run(); + } + } + + /** + *

+ * hydrateFormationTemperature. + *

+ * + * @throws java.lang.Exception if any. + */ + public void hydrateFormationTemperature() throws Exception { + // guessing temperature + double factor = 1.0; + if (system.getPhase(0).hasComponent("methanol")) { + factor -= 2 * system.getPhase(0).getComponent("methanol").getz() + / system.getPhase(0).getComponent("water").getz(); + } + if (system.getPhase(0).hasComponent("MEG")) { + factor -= 2 * system.getPhase(0).getComponent("MEG").getz() + / system.getPhase(0).getComponent("water").getz(); + } + if (factor < 2) { + factor = 2; + } + + system.setTemperature(273.0 + system.getPressure() / 100.0 * 20.0 * factor - 20.0); + if (system.getTemperature() > 298.15) { + system.setTemperature(273.0 + 25.0); + } + // logger.info("guess hydrate temperature " + system.getTemperature()); + operation = new HydrateFormationTemperatureFlash(system); + + for (int i = 0; i < system.getPhase(4).getNumberOfComponents(); i++) { + ((ComponentHydrate) system.getPhase(4).getComponent(i)).getHydrateStructure(); + } + if (!isRunAsThread()) { + getOperation().run(); + } else { + run(); + } + // logger.info("Hydrate structure " + (((ComponentHydrate) + // system.getPhase(4).getComponent("water")).getHydrateStructure() + 1)); + } + + /** + *

+ * hydrateEquilibriumLine. + *

+ * + * @param minimumPressure a double + * @param maximumPressure a double + * @throws java.lang.Exception if any. + */ + public void hydrateEquilibriumLine(double minimumPressure, double maximumPressure) + throws Exception { + operation = new HydrateEquilibriumLine(system, minimumPressure, maximumPressure); + if (!isRunAsThread()) { + getOperation().run(); + } else { + run(); + } + } + + /** + *

+ * calcCricoP. + *

+ * + * @param cricondenBar an array of {@link double} objects + * @param cricondenBarX an array of {@link double} objects + * @param cricondenBarY an array of {@link double} objects + */ + public void calcCricoP(double[] cricondenBar, double[] cricondenBarX, double[] cricondenBarY) { + double phasefraction = 1.0 - 1e-10; + + operation = new CricondenBarFlash(system, fileName, phasefraction, cricondenBar, cricondenBarX, + cricondenBarY); + + getOperation().run(); + } + + /** + *

+ * calcCricoT. + *

+ * + * @param cricondenTherm an array of {@link double} objects + * @param cricondenThermX an array of {@link double} objects + * @param cricondenThermY an array of {@link double} objects + */ + public void calcCricoT(double[] cricondenTherm, double[] cricondenThermX, + double[] cricondenThermY) { + double phasefraction = 1.0 - 1e-10; + + operation = new CricondenThermFlash(system, fileName, phasefraction, cricondenTherm, + cricondenThermX, cricondenThermY); + + getOperation().run(); + } + + /** + *

+ * waterDewPointLine. + *

+ * + * @param minimumPressure a double + * @param maximumPressure a double + * @throws java.lang.Exception if any. + */ + public void waterDewPointLine(double minimumPressure, double maximumPressure) throws Exception { + operation = new WaterDewPointEquilibriumLine(system, minimumPressure, maximumPressure); + if (!isRunAsThread()) { + getOperation().run(); + } else { + run(); + } + } + + /** + *

+ * hydrateFormationTemperature. + *

+ * + * @param structure a int + * @throws java.lang.Exception if any. + */ + public void hydrateFormationTemperature(int structure) throws Exception { + system.setTemperature(273.0 + 1.0); + if (structure == 0) { + system.setSolidPhaseCheck("water"); + system.setHydrateCheck(true); + operation = new freezingPointTemperatureFlash(system); + } else { + operation = new HydrateFormationTemperatureFlash(system); + } + + for (int i = 0; i < system.getPhase(4).getNumberOfComponents(); i++) { + ((ComponentHydrate) system.getPhases()[4].getComponent(i)).setHydrateStructure(structure - 1); + } + if (!isRunAsThread()) { + getOperation().run(); + } else { + run(); + } + + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "hydrateFormationTemperature", "Could not find solution - possible no dew point exists"); + } + } + + /** + *

+ * calcCricondenBar. + *

+ * + * @return a double + */ + public double calcCricondenBar() { + system.init(0); + operation = new cricondebarFlash(system); + // operation = new CricondenBarFlash(system); + + // operation = new cricondenBarTemp1(system); + operation.run(); + return system.getPressure(); + } + + /** + *

+ * bubblePointPressureFlash. + *

+ * + * @throws java.lang.Exception if any. + */ + public void bubblePointPressureFlash() throws Exception { + system.init(0); + constantDutyFlashInterface operation = new constantDutyPressureFlash(system); + system.setBeta(1, 1.0 - 1e-10); + system.setBeta(0, 1e-10); + operation.run(); + if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "bubblePointPressureFlash", "Could not find solution - possible no dew point exists"); + } + } + + /** + *

+ * constantPhaseFractionPressureFlash. + *

+ * + * @param fraction a double + * @throws java.lang.Exception if any. + */ + public void constantPhaseFractionPressureFlash(double fraction) throws Exception { + system.init(0); + if (fraction < 1e-10) { + fraction = 1e-10; + } + if (fraction > 1.0 - 1e-10) { + fraction = 1.0 - 1.0e-10; + } + constantDutyFlashInterface operation = new constantDutyPressureFlash(system); + system.setBeta(1, 1.0 - fraction); + system.setBeta(0, fraction); + operation.run(); + if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "constantPhaseFractionPressureFlash", + "Could not find solution - possible no dew point exists"); + } + } + + /** + *

+ * constantPhaseFractionTemperatureFlash. + *

+ * + * @param fraction a double + * @throws java.lang.Exception if any. + */ + public void constantPhaseFractionTemperatureFlash(double fraction) throws Exception { + system.init(0); + if (fraction < 1e-10) { + fraction = 1e-10; + } + if (fraction > 1.0 - 1e-10) { + fraction = 1.0 - 1.0e-10; + } + constantDutyFlashInterface operation = new constantDutyTemperatureFlash(system); + system.setBeta(1, fraction); + system.setBeta(0, fraction); + operation.run(); + if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "constantPhaseFractionTemperatureFlash", + "Could not find solution - possible no dew point exists"); + } + } + + /** + *

+ * bubblePointPressureFlash. + *

+ * + * @param derivatives a boolean + * @throws java.lang.Exception if any. + */ + public void bubblePointPressureFlash(boolean derivatives) throws Exception { + constantDutyFlashInterface operation = null; + if (derivatives == true) { + operation = new bubblePointPressureFlashDer(system); + } else { + operation = new bubblePointPressureFlash(system); + } + operation.run(); + if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "bubblePointPressureFlash", "Could not find solution - possible no dew point exists"); + } + } + + /** + *

+ * dewPointMach. + *

+ * + * @param componentName a {@link java.lang.String} object + * @param specification a {@link java.lang.String} object + * @param spec a double + * @throws java.lang.Exception if any. + */ + public void dewPointMach(String componentName, String specification, double spec) + throws Exception { + // int componentNumber = + // system.getPhase(0).getComponent(componentName).getComponentNumber(); + + double dn = 0; + if (system.getPhase(0).hasComponent(componentName)) { + dn = system.getNumberOfMoles() / 1.0e6; + system.addComponent(componentName, dn); + } else { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "dewPointMach", "Specified component is not present in mixture: " + componentName); + } + double newTemperature = system.getTemperature(), oldTemperature = newTemperature; + int iterations = 0; + if (specification.equals("dewPointTemperature")) { + // logger.info("new temperature " + newTemperature); + do { + iterations++; system.init(0); - if (fraction < 1e-10) { - fraction = 1e-10; - } - if (fraction > 1.0 - 1e-10) { - fraction = 1.0 - 1.0e-10; - } - constantDutyFlashInterface operation = new constantDutyTemperatureFlash(system); - system.setBeta(1, fraction); - system.setBeta(0, fraction); - operation.run(); - if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "constantPhaseFractionTemperatureFlash", - "Could not find solution - possible no dew point exists"); - } - } - - /** - *

- * bubblePointPressureFlash. - *

- * - * @param derivatives a boolean - * @throws java.lang.Exception if any. - */ - public void bubblePointPressureFlash(boolean derivatives) throws Exception { - constantDutyFlashInterface operation = null; - if (derivatives == true) { - operation = new bubblePointPressureFlashDer(system); - } else { - operation = new bubblePointPressureFlash(system); - } - operation.run(); - if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "bubblePointPressureFlash", "Could not find solution - possible no dew point exists"); - } - } - - /** - *

- * dewPointMach. - *

- * - * @param componentName a {@link java.lang.String} object - * @param specification a {@link java.lang.String} object - * @param spec a double - * @throws java.lang.Exception if any. - */ - public void dewPointMach(String componentName, String specification, double spec) - throws Exception { - // int componentNumber = - // system.getPhase(0).getComponent(componentName).getComponentNumber(); - - double dn = 0; - if (system.getPhase(0).hasComponent(componentName)) { - dn = system.getNumberOfMoles() / 1.0e6; - system.addComponent(componentName, dn); + dewPointTemperatureFlash(); + newTemperature = system.getTemperature(); + // logger.info("new temperature " + newTemperature); + double oldMoles = system.getPhase(0).getComponent(componentName).getNumberOfmoles(); + if (iterations > 1) { + system.addComponent(componentName, -(iterations / (30.0 + iterations)) + * (newTemperature - spec) / ((newTemperature - oldTemperature) / dn)); } else { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "dewPointMach", "Specified component is not present in mixture: " + componentName); - } - double newTemperature = system.getTemperature(), oldTemperature = newTemperature; - int iterations = 0; - if (specification.equals("dewPointTemperature")) { - // logger.info("new temperature " + newTemperature); - do { - iterations++; - system.init(0); - dewPointTemperatureFlash(); - newTemperature = system.getTemperature(); - // logger.info("new temperature " + newTemperature); - double oldMoles = system.getPhase(0).getComponent(componentName).getNumberOfmoles(); - if (iterations > 1) { - system.addComponent(componentName, -(iterations / (30.0 + iterations)) - * (newTemperature - spec) / ((newTemperature - oldTemperature) / dn)); - } else { - system.addComponent(componentName, system.getNumberOfMoles() / 1.0e6); - } - dn = system.getPhase(0).getComponent(componentName).getNumberOfmoles() - oldMoles; - oldTemperature = newTemperature; - } while (Math.abs( - dn / system.getPhase(0).getComponent(componentName).getNumberOfmoles()) > 1e-9 - || iterations < 5 || iterations > 105); - - dewPointTemperatureFlash(); - } - - if (Double.isNaN(system.getPressure())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "dewPointMach", "Could not find solution - possible no dew point exists"); - } - } - - /** - *

- * dewPointTemperatureFlash. - *

- * - * @throws java.lang.Exception if any. - */ - public void dewPointTemperatureFlash() throws Exception { - constantDutyFlashInterface operation = new neqsim.thermodynamicOperations.flashOps.saturationOps.dewPointTemperatureFlash( - system); - operation.run(); - if (Double.isNaN(system.getTemperature()) || operation.isSuperCritical()) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "dewPointTemperatureFlash", "Could not find solution - possible no dew point exists"); - } - } - - /** - *

- * dewPointTemperatureFlash. - *

- * - * @param derivatives a boolean - * @throws java.lang.Exception if any. - */ - public void dewPointTemperatureFlash(boolean derivatives) throws Exception { - constantDutyFlashInterface operation = new neqsim.thermodynamicOperations.flashOps.saturationOps.dewPointTemperatureFlash( - system); - if (derivatives) { - operation = new dewPointTemperatureFlashDer(system); - } - operation.run(); - if (Double.isNaN(system.getTemperature()) || operation.isSuperCritical()) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "dewPointTemperatureFlash", "Could not find solution - possible no dew point exists"); - } + system.addComponent(componentName, system.getNumberOfMoles() / 1.0e6); + } + dn = system.getPhase(0).getComponent(componentName).getNumberOfmoles() - oldMoles; + oldTemperature = newTemperature; + } while (Math + .abs(dn / system.getPhase(0).getComponent(componentName).getNumberOfmoles()) > 1e-9 + || iterations < 5 || iterations > 105); + + dewPointTemperatureFlash(); + } + + if (Double.isNaN(system.getPressure())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "dewPointMach", "Could not find solution - possible no dew point exists"); + } + } + + /** + *

+ * dewPointTemperatureFlash. + *

+ * + * @throws java.lang.Exception if any. + */ + public void dewPointTemperatureFlash() throws Exception { + constantDutyFlashInterface operation = + new neqsim.thermodynamicOperations.flashOps.saturationOps.dewPointTemperatureFlash(system); + operation.run(); + if (Double.isNaN(system.getTemperature()) || operation.isSuperCritical()) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "dewPointTemperatureFlash", "Could not find solution - possible no dew point exists"); + } + } + + /** + *

+ * dewPointTemperatureFlash. + *

+ * + * @param derivatives a boolean + * @throws java.lang.Exception if any. + */ + public void dewPointTemperatureFlash(boolean derivatives) throws Exception { + constantDutyFlashInterface operation = + new neqsim.thermodynamicOperations.flashOps.saturationOps.dewPointTemperatureFlash(system); + if (derivatives) { + operation = new dewPointTemperatureFlashDer(system); + } + operation.run(); + if (Double.isNaN(system.getTemperature()) || operation.isSuperCritical()) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "dewPointTemperatureFlash", "Could not find solution - possible no dew point exists"); + } + } + + /** + *

+ * dewPointPressureFlashHC. + *

+ * + * @throws java.lang.Exception if any. + */ + public void dewPointPressureFlashHC() throws Exception { + // try{ + system.init(0); + constantDutyFlashInterface operation = new HCdewPointPressureFlash(system); + operation.run(); + if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "dewPointPressureFlashHC", "Could not find solution - possible no dew point exists"); } - - /** - *

- * dewPointPressureFlashHC. - *

- * - * @throws java.lang.Exception if any. - */ - public void dewPointPressureFlashHC() throws Exception { - // try{ - system.init(0); - constantDutyFlashInterface operation = new HCdewPointPressureFlash(system); - operation.run(); - if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "dewPointPressureFlashHC", "Could not find solution - possible no dew point exists"); - } - // } - } - - /** - *

- * dewPointPressureFlash. - *

- * - * @throws java.lang.Exception if any. - */ - public void dewPointPressureFlash() throws Exception { - // try{ - system.init(0); - constantDutyFlashInterface operation = new dewPointPressureFlash(system); - operation.run(); - if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "dewPointPressureFlash", "Could not find solution - possible no dew point exists"); - } - // } - } - - // public void dewPointPressureFlash(){ - // constantDutyFlashInterface operation = new constantDutyPressureFlash(system); - // operation.setBeta((1-1e-7)); - // operation.run(); // } - /** - *

- * calcPTphaseEnvelope. - *

- */ - public void calcPTphaseEnvelope() { - operation = new pTphaseEnvelope(system, fileName, (1.0 - 1e-10), 1.0, false); - // thisThread = new Thread(operation); - // thisThread.start(); - getOperation().run(); - } - - /** - *

- * calcPTphaseEnvelope. - *

- * - * @param bubfirst a boolean - * @param lowPres a double - */ - public void calcPTphaseEnvelope(boolean bubfirst, double lowPres) { - double phasefraction = 1.0 - 1e-10; - if (bubfirst) { - phasefraction = 1.0e-10; - } - operation = new pTphaseEnvelope(system, fileName, phasefraction, lowPres, bubfirst); - - // thisThread = new Thread(operation); - // thisThread.start(); - getOperation().run(); - } - - /** - *

- * calcPTphaseEnvelope. - *

- * - * @param lowPres a double - */ - public void calcPTphaseEnvelope(double lowPres) { - operation = new pTphaseEnvelope(system, fileName, 1e-10, lowPres, true); - // thisThread = new Thread(operation); - // thisThread.start(); - getOperation().run(); - } - - /** - *

- * calcPTphaseEnvelope. - *

- * - * @param bubfirst a boolean - */ - public void calcPTphaseEnvelope(boolean bubfirst) { - double phasefraction = 1.0 - 1e-10; - if (bubfirst) { - phasefraction = 1.0e-10; - } - operation = new pTphaseEnvelope(system, fileName, phasefraction, 1.0, bubfirst); - - // thisThread = new Thread(operation); - // thisThread.start(); - if (!isRunAsThread()) { - getOperation().run(); - } else { - run(); - } + } + + /** + *

+ * dewPointPressureFlash. + *

+ * + * @throws java.lang.Exception if any. + */ + public void dewPointPressureFlash() throws Exception { + // try{ + system.init(0); + constantDutyFlashInterface operation = new dewPointPressureFlash(system); + operation.run(); + if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "dewPointPressureFlash", "Could not find solution - possible no dew point exists"); } - - /** - *

- * getJfreeChart. - *

- * - * @return a {@link org.jfree.chart.JFreeChart} object - */ - public org.jfree.chart.JFreeChart getJfreeChart() { - return getOperation().getJFreeChart(""); - } - - /** - *

- * calcPTphaseEnvelopeNew. - *

- */ - public void calcPTphaseEnvelopeNew() { - // double phasefraction = 1.0 - 1e-10; - // operation = new pTphaseEnvelope(system, fileName, phasefraction, 1.0); - getOperation().run(); - } - - /** - *

- * calcPTphaseEnvelope. - *

- * - * @param lowPres a double - * @param phasefraction a double - */ - public void calcPTphaseEnvelope(double lowPres, double phasefraction) { - operation = new pTphaseEnvelope(system, fileName, phasefraction, lowPres, true); - - // thisThread = new Thread(operation); - // thisThread.start(); - getOperation().run(); - } - - /** - *

- * OLGApropTable. - *

- * - * @param minTemp a double - * @param maxTemp a double - * @param temperatureSteps a int - * @param minPres a double - * @param maxPres a double - * @param pressureSteps a int - * @param filename a {@link java.lang.String} object - * @param TABtype a int - */ - public void OLGApropTable(double minTemp, double maxTemp, int temperatureSteps, double minPres, - double maxPres, int pressureSteps, String filename, int TABtype) { - operation = new OLGApropertyTableGeneratorWaterStudents(system); - ((OLGApropertyTableGeneratorWaterStudents) operation).setFileName(filename); - ((OLGApropertyTableGeneratorWaterStudents) operation).setPressureRange(minPres, maxPres, - pressureSteps); - ((OLGApropertyTableGeneratorWaterStudents) operation).setTemperatureRange(minTemp, maxTemp, - temperatureSteps); - getOperation().run(); - } - - /** - *

- * OLGApropTablePH. - *

- * - * @param minEnthalpy a double - * @param maxEnthalpy a double - * @param enthalpySteps a int - * @param minPres a double - * @param maxPres a double - * @param pressureSteps a int - * @param filename a {@link java.lang.String} object - * @param TABtype a int - */ - public void OLGApropTablePH(double minEnthalpy, double maxEnthalpy, int enthalpySteps, - double minPres, double maxPres, int pressureSteps, String filename, int TABtype) { - operation = new OLGApropertyTableGeneratorWaterStudentsPH(system); - ((OLGApropertyTableGeneratorWaterStudentsPH) operation).setFileName(filename); - ((OLGApropertyTableGeneratorWaterStudentsPH) operation).setPressureRange(minPres, maxPres, - pressureSteps); - ((OLGApropertyTableGeneratorWaterStudentsPH) operation).setEnthalpyRange(minEnthalpy, - maxEnthalpy, enthalpySteps); - getOperation().run(); - } - - /** - *

- * calcPloadingCurve. - *

- */ - public void calcPloadingCurve() { - operation = new pLoadingCurve2(system); - // thisThread = new Thread(operation); - // thisThread.start(); - getOperation().run(); - } - - /** - *

- * calcHPTphaseEnvelope. - *

- */ - public void calcHPTphaseEnvelope() { - operation = new HPTphaseEnvelope(system); - // thisThread = new Thread(getOperation()); - // thisThread.start(); - operation.run(); - } - - /** - *

- * printToFile. - *

- * - * @param name a {@link java.lang.String} object - */ - public void printToFile(String name) { - getOperation().printToFile(name); - } - - // public double[] get(String name){ - // return operation.get(name); // } - /** - *

- * getData. - *

- * - * @return an array of {@link double} objects - */ - public double[][] getData() { - return getOperation().getPoints(0); - } - - /** - *

- * getDataPoints. - *

- * - * @return an array of {@link java.lang.String} objects - */ - public String[][] getDataPoints() { - String[][] str = new String[getOperation() - .getPoints(0).length][getOperation().getPoints(0)[0].length]; - for (int i = 0; i < getOperation().getPoints(0).length; i++) { - for (int j = 0; j < getOperation().getPoints(0)[0].length; j++) { - str[i][j] = Double.toString(getOperation().getPoints(0)[i][j]); - } - } - return str; - } - - /** - *

- * Getter for the field resultTable. - *

- * - * @return an array of {@link java.lang.String} objects - */ - public String[][] getResultTable() { - return resultTable; - } - - /** - *

- * dewPointTemperatureCondensationRate. - *

- * - * @return a double - */ - public double dewPointTemperatureCondensationRate() { - double dT = 1.1; - try { - dewPointTemperatureFlash(); - } catch (Exception e) { - logger.error("error", e); + } + + // public void dewPointPressureFlash(){ + // constantDutyFlashInterface operation = new constantDutyPressureFlash(system); + // operation.setBeta((1-1e-7)); + // operation.run(); + // } + /** + *

+ * calcPTphaseEnvelope. + *

+ */ + public void calcPTphaseEnvelope() { + operation = new pTphaseEnvelope(system, fileName, (1.0 - 1e-10), 1.0, false); + // thisThread = new Thread(operation); + // thisThread.start(); + getOperation().run(); + } + + /** + *

+ * calcPTphaseEnvelope. + *

+ * + * @param bubfirst a boolean + * @param lowPres a double + */ + public void calcPTphaseEnvelope(boolean bubfirst, double lowPres) { + double phasefraction = 1.0 - 1e-10; + if (bubfirst) { + phasefraction = 1.0e-10; + } + operation = new pTphaseEnvelope(system, fileName, phasefraction, lowPres, bubfirst); + + // thisThread = new Thread(operation); + // thisThread.start(); + getOperation().run(); + } + + /** + *

+ * calcPTphaseEnvelope. + *

+ * + * @param lowPres a double + */ + public void calcPTphaseEnvelope(double lowPres) { + operation = new pTphaseEnvelope(system, fileName, 1e-10, lowPres, true); + // thisThread = new Thread(operation); + // thisThread.start(); + getOperation().run(); + } + + /** + *

+ * calcPTphaseEnvelope. + *

+ * + * @param bubfirst a boolean + */ + public void calcPTphaseEnvelope(boolean bubfirst) { + double phasefraction = 1.0 - 1e-10; + if (bubfirst) { + phasefraction = 1.0e-10; + } + operation = new pTphaseEnvelope(system, fileName, phasefraction, 1.0, bubfirst); + + // thisThread = new Thread(operation); + // thisThread.start(); + if (!isRunAsThread()) { + getOperation().run(); + } else { + run(); + } + } + + /** + *

+ * getJfreeChart. + *

+ * + * @return a {@link org.jfree.chart.JFreeChart} object + */ + public org.jfree.chart.JFreeChart getJfreeChart() { + return getOperation().getJFreeChart(""); + } + + /** + *

+ * calcPTphaseEnvelopeNew. + *

+ */ + public void calcPTphaseEnvelopeNew() { + // double phasefraction = 1.0 - 1e-10; + // operation = new pTphaseEnvelope(system, fileName, phasefraction, 1.0); + getOperation().run(); + } + + /** + *

+ * calcPTphaseEnvelope. + *

+ * + * @param lowPres a double + * @param phasefraction a double + */ + public void calcPTphaseEnvelope(double lowPres, double phasefraction) { + operation = new pTphaseEnvelope(system, fileName, phasefraction, lowPres, true); + + // thisThread = new Thread(operation); + // thisThread.start(); + getOperation().run(); + } + + /** + *

+ * OLGApropTable. + *

+ * + * @param minTemp a double + * @param maxTemp a double + * @param temperatureSteps a int + * @param minPres a double + * @param maxPres a double + * @param pressureSteps a int + * @param filename a {@link java.lang.String} object + * @param TABtype a int + */ + public void OLGApropTable(double minTemp, double maxTemp, int temperatureSteps, double minPres, + double maxPres, int pressureSteps, String filename, int TABtype) { + operation = new OLGApropertyTableGeneratorWaterStudents(system); + ((OLGApropertyTableGeneratorWaterStudents) operation).setFileName(filename); + ((OLGApropertyTableGeneratorWaterStudents) operation).setPressureRange(minPres, maxPres, + pressureSteps); + ((OLGApropertyTableGeneratorWaterStudents) operation).setTemperatureRange(minTemp, maxTemp, + temperatureSteps); + getOperation().run(); + } + + /** + *

+ * OLGApropTablePH. + *

+ * + * @param minEnthalpy a double + * @param maxEnthalpy a double + * @param enthalpySteps a int + * @param minPres a double + * @param maxPres a double + * @param pressureSteps a int + * @param filename a {@link java.lang.String} object + * @param TABtype a int + */ + public void OLGApropTablePH(double minEnthalpy, double maxEnthalpy, int enthalpySteps, + double minPres, double maxPres, int pressureSteps, String filename, int TABtype) { + operation = new OLGApropertyTableGeneratorWaterStudentsPH(system); + ((OLGApropertyTableGeneratorWaterStudentsPH) operation).setFileName(filename); + ((OLGApropertyTableGeneratorWaterStudentsPH) operation).setPressureRange(minPres, maxPres, + pressureSteps); + ((OLGApropertyTableGeneratorWaterStudentsPH) operation).setEnthalpyRange(minEnthalpy, + maxEnthalpy, enthalpySteps); + getOperation().run(); + } + + /** + *

+ * calcPloadingCurve. + *

+ */ + public void calcPloadingCurve() { + operation = new pLoadingCurve2(system); + // thisThread = new Thread(operation); + // thisThread.start(); + getOperation().run(); + } + + /** + *

+ * calcHPTphaseEnvelope. + *

+ */ + public void calcHPTphaseEnvelope() { + operation = new HPTphaseEnvelope(system); + // thisThread = new Thread(getOperation()); + // thisThread.start(); + operation.run(); + } + + /** + *

+ * printToFile. + *

+ * + * @param name a {@link java.lang.String} object + */ + public void printToFile(String name) { + getOperation().printToFile(name); + } + + // public double[] get(String name){ + // return operation.get(name); + // } + /** + *

+ * getData. + *

+ * + * @return an array of {@link double} objects + */ + public double[][] getData() { + return getOperation().getPoints(0); + } + + /** + *

+ * getDataPoints. + *

+ * + * @return an array of {@link java.lang.String} objects + */ + public String[][] getDataPoints() { + String[][] str = + new String[getOperation().getPoints(0).length][getOperation().getPoints(0)[0].length]; + for (int i = 0; i < getOperation().getPoints(0).length; i++) { + for (int j = 0; j < getOperation().getPoints(0)[0].length; j++) { + str[i][j] = Double.toString(getOperation().getPoints(0)[i][j]); + } + } + return str; + } + + /** + *

+ * Getter for the field resultTable. + *

+ * + * @return an array of {@link java.lang.String} objects + */ + public String[][] getResultTable() { + return resultTable; + } + + /** + *

+ * dewPointTemperatureCondensationRate. + *

+ * + * @return a double + */ + public double dewPointTemperatureCondensationRate() { + double dT = 1.1; + try { + dewPointTemperatureFlash(); + } catch (Exception e) { + logger.error("error", e); + } + system.setTemperature(system.getTemperature() - dT); + TPflash(); + double condensationRate = system.getPhase(1).getMass() / (system.getVolume() * 1.0e-5); + try { + dewPointTemperatureFlash(); + } catch (Exception e) { + logger.error("error", e); + } + return condensationRate / dT; + } + + /** + *

+ * displayResult. + *

+ */ + public void displayResult() { + try { + getThermoOperationThread().join(); + } catch (Exception e) { + logger.error("Thread did not finish"); + } + getOperation().displayResult(); + } + + /** + *

+ * Setter for the field resultTable. + *

+ * + * @param resultTable an array of {@link java.lang.String} objects + */ + public void setResultTable(String[][] resultTable) { + this.resultTable = resultTable; + } + + /** + *

+ * display. + *

+ */ + public void display() { + JFrame dialog = new JFrame("System-Report"); + Container dialogContentPane = dialog.getContentPane(); + dialogContentPane.setLayout(new BorderLayout()); + + String[] names = new String[resultTable[0].length];// {"", "", ""}; + for (int i = 0; i < names.length; i++) { + names[i] = ""; + } + JTable Jtab = new JTable(resultTable, names); + JScrollPane scrollpane = new JScrollPane(Jtab); + dialogContentPane.add(scrollpane); + dialog.pack(); + dialog.setVisible(true); + } + + /** + *

+ * get. + *

+ * + * @param name a {@link java.lang.String} object + * @return an array of {@link double} objects + */ + public double[] get(String name) { + return getOperation().get(name); + } + + /** + *

+ * Getter for the field operation. + *

+ * + * @return the operation + */ + public OperationInterface getOperation() { + return operation; + } + + /** + *

+ * isRunAsThread. + *

+ * + * @return the runAsThread + */ + public boolean isRunAsThread() { + return runAsThread; + } + + /** + *

+ * Setter for the field runAsThread. + *

+ * + * @param runAsThread the runAsThread to set + */ + public void setRunAsThread(boolean runAsThread) { + this.runAsThread = runAsThread; + } + + /** + *

+ * Getter for the field thermoOperationThread. + *

+ * + * @return the thermoOperationThread + */ + public Thread getThermoOperationThread() { + return thermoOperationThread; + } + + /** + *

+ * Setter for the field thermoOperationThread. + *

+ * + * @param thermoOperationThread the thermoOperationThread to set + */ + public void setThermoOperationThread(Thread thermoOperationThread) { + this.thermoOperationThread = thermoOperationThread; + } + + /** + *

+ * addData. + *

+ * + * @param name a {@link java.lang.String} object + * @param data an array of {@link double} objects + */ + public void addData(String name, double[][] data) { + operation.addData(name, data); + } + + /** + *

+ * calcIonComposition. + *

+ * + * @param phaseNumber a int + */ + public void calcIonComposition(int phaseNumber) { + operation = new calcIonicComposition(system, phaseNumber); + getOperation().run(); + resultTable = getOperation().getResultTable(); + } + + /** + *

+ * flash. + *

+ * + * @param flashType a {@link java.lang.String} object + * @param spec1 a double + * @param spec2 a double + * @param unitSpec1 a {@link java.lang.String} object + * @param unitSpec2 a {@link java.lang.String} object + */ + public void flash(String flashType, double spec1, double spec2, String unitSpec1, + String unitSpec2) { + if (flashType.equals("TP")) { + system.setTemperature(spec1, unitSpec1); + system.setPressure(spec2, unitSpec2); + } else if (flashType.equals("TV")) { + system.setTemperature(spec1, unitSpec1); + TVflash(spec2, unitSpec2); + } else if (flashType.equals("PH")) { + system.setPressure(spec1, unitSpec1); + PHflash(spec2, unitSpec2); + } else if (flashType.equals("TS")) { + system.setTemperature(spec1, unitSpec1); + TSflash(spec2, unitSpec2); + } + } + + /** + * Perform flashes and return System properties per set of Spec1 and Spec2. + * + * Possible to specify fractions for each value of Spec1. + * + * + * @param Spec1 Flash pressure in bar absolute. + * @param Spec2 Flash specification. Depends on FlashMode. Temperature in Kelvin, entalphy in + * J/mol or entropy in J/molK. + * @param FlashMode 1 - PT 2 - PH 3 - PS + * @param components Not yet in use. + * @param onlineFractions Specify fractions per sample instance or null to use static composition + * specified in system. + * @return Object CalculationResult object + */ + public CalculationResult propertyFlash(List Spec1, List Spec2, int FlashMode, + List components, List> onlineFractions) { + + Double[][] fluidProperties = new Double[Spec1.size()][SystemProperties.nCols]; + String[] calculationError = new String[Spec1.size()]; + + Double[] sum = new Double[Spec1.size()]; + + if (onlineFractions != null) { + for (int t = 0; t < sum.length; t++) { + sum[t] = 0.0; + for (int comp = 0; comp < onlineFractions.size(); comp++) { + sum[t] = sum[t] + onlineFractions.get(comp).get(t).doubleValue(); + } + } + + if (this.system.getNumberOfMoles() == 0) { + this.system.setTotalNumberOfMoles(1); + } + } else { + double[] fraction = this.system.getMolarComposition(); + sum[0] = 0.0; + for (int comp = 0; comp < fraction.length; comp++) { + sum[0] = sum[0] + fraction[comp]; + } + } + + for (int t = 0; t < Spec1.size(); t++) { + try { + Double Sp1 = Spec1.get(t); + Double Sp2 = Spec2.get(t); + + if (Sp1 == null || Sp2 == null || Double.isNaN(Sp1) || Double.isNaN(Sp2)) { + calculationError[t] = "Sp1 or Sp2 is NaN"; + logger.info("Sp1 or Sp2 is NULL for datapoint {}", t); + continue; } - system.setTemperature(system.getTemperature() - dT); - TPflash(); - double condensationRate = system.getPhase(1).getMass() / (system.getVolume() * 1.0e-5); - try { - dewPointTemperatureFlash(); - } catch (Exception e) { - logger.error("error", e); - } - return condensationRate / dT; - } - - /** - *

- * displayResult. - *

- */ - public void displayResult() { - try { - getThermoOperationThread().join(); - } catch (Exception e) { - logger.error("Thread did not finish"); - } - getOperation().displayResult(); - } - - /** - *

- * writeNetCDF. - *

- * - * @param name a {@link java.lang.String} object - */ - /* - public void writeNetCDF(String name) { - fileName = name; - getOperation().createNetCdfFile(name); - } - */ - - /** - *

- * Setter for the field resultTable. - *

- * - * @param resultTable an array of {@link java.lang.String} objects - */ - public void setResultTable(String[][] resultTable) { - this.resultTable = resultTable; - } - - /** - *

- * display. - *

- */ - public void display() { - JFrame dialog = new JFrame("System-Report"); - Container dialogContentPane = dialog.getContentPane(); - dialogContentPane.setLayout(new BorderLayout()); - - String[] names = new String[resultTable[0].length];// {"", "", ""}; - for (int i = 0; i < names.length; i++) { - names[i] = ""; - } - JTable Jtab = new JTable(resultTable, names); - JScrollPane scrollpane = new JScrollPane(Jtab); - dialogContentPane.add(scrollpane); - dialog.pack(); - dialog.setVisible(true); - } - - /** - *

- * get. - *

- * - * @param name a {@link java.lang.String} object - * @return an array of {@link double} objects - */ - public double[] get(String name) { - return getOperation().get(name); - } - - /** - *

- * Getter for the field operation. - *

- * - * @return the operation - */ - public OperationInterface getOperation() { - return operation; - } - - /** - *

- * isRunAsThread. - *

- * - * @return the runAsThread - */ - public boolean isRunAsThread() { - return runAsThread; - } - - /** - *

- * Setter for the field runAsThread. - *

- * - * @param runAsThread the runAsThread to set - */ - public void setRunAsThread(boolean runAsThread) { - this.runAsThread = runAsThread; - } - - /** - *

- * Getter for the field thermoOperationThread. - *

- * - * @return the thermoOperationThread - */ - public Thread getThermoOperationThread() { - return thermoOperationThread; - } - - /** - *

- * Setter for the field thermoOperationThread. - *

- * - * @param thermoOperationThread the thermoOperationThread to set - */ - public void setThermoOperationThread(Thread thermoOperationThread) { - this.thermoOperationThread = thermoOperationThread; - } - - /** - *

- * addData. - *

- * - * @param name a {@link java.lang.String} object - * @param data an array of {@link double} objects - */ - public void addData(String name, double[][] data) { - operation.addData(name, data); - } - - /** - *

- * calcIonComposition. - *

- * - * @param phaseNumber a int - */ - public void calcIonComposition(int phaseNumber) { - operation = new calcIonicComposition(system, phaseNumber); - getOperation().run(); - resultTable = getOperation().getResultTable(); - } - - /** - *

- * flash. - *

- * - * @param flashType a {@link java.lang.String} object - * @param spec1 a double - * @param spec2 a double - * @param unitSpec1 a {@link java.lang.String} object - * @param unitSpec2 a {@link java.lang.String} object - */ - public void flash(String flashType, double spec1, double spec2, String unitSpec1, - String unitSpec2) { - if (flashType.equals("TP")) { - system.setTemperature(spec1, unitSpec1); - system.setPressure(spec2, unitSpec2); - } else if (flashType.equals("TV")) { - system.setTemperature(spec1, unitSpec1); - TVflash(spec2, unitSpec2); - } else if (flashType.equals("PH")) { - system.setPressure(spec1, unitSpec1); - PHflash(spec2, unitSpec2); - } else if (flashType.equals("TS")) { - system.setTemperature(spec1, unitSpec1); - TSflash(spec2, unitSpec2); - } - } - - /** - * Perform flashes and return System properties per set of Spec1 and Spec2. - * - * Possible to specify fractions for each value of Spec1. - * - * - * @param Spec1 Flash pressure in bar absolute. - * @param Spec2 Flash specification. Depends on FlashMode. Temperature in Kelvin, entalphy in - * J/mol or entropy in J/molK. - * @param FlashMode 1 - PT 2 - PH 3 - PS - * @param components Not yet in use. - * @param onlineFractions Specify fractions per sample instance or null to use static - * composition specified in system. - * @return Object CalculationResult object - */ - public CalculationResult propertyFlash(List Spec1, List Spec2, int FlashMode, - List components, List> onlineFractions) { - - Double[][] fluidProperties = new Double[Spec1.size()][SystemProperties.nCols]; - String[] calculationError = new String[Spec1.size()]; - - Double[] sum = new Double[Spec1.size()]; if (onlineFractions != null) { - for (int t = 0; t < sum.length; t++) { - sum[t] = 0.0; - for (int comp = 0; comp < onlineFractions.size(); comp++) { - sum[t] = sum[t] + onlineFractions.get(comp).get(t).doubleValue(); - } - } - - if (this.system.getNumberOfMoles() == 0) { - this.system.setTotalNumberOfMoles(1); - } - } - else { - double[] fraction = this.system.getMolarComposition(); - sum[0] = 0.0; - for (int comp = 0; comp < fraction.length; comp++) { - sum[0] = sum[0] + fraction[comp]; + double range = 5; + if (!((sum[t] >= 1 - range / 100 && sum[t] <= 1 + range / 100) + || (sum[t] >= 100 - range && sum[t] <= 100 + range))) { + calculationError[t] = "Sum of fractions must be approximately 1 or 100, currently (" + + String.valueOf(sum[t]) + ")"; + logger.info("Online fraction does not sum to approximately 1 or 100 for datapoint {}", + t); + continue; + } else { + // Remaining fractions will be set to 0.0 + double[] fraction = new double[this.system.getNumberOfComponents()]; + + for (int comp = 0; comp < onlineFractions.size(); comp++) { + fraction[comp] = onlineFractions.get(comp).get(t).doubleValue(); } - } - for (int t = 0; t < Spec1.size(); t++) { - try { - Double Sp1 = Spec1.get(t); - Double Sp2 = Spec2.get(t); - - if (Sp1 == null || Sp2 == null || Double.isNaN(Sp1) || Double.isNaN(Sp2)) { - calculationError[t] = "Sp1 or Sp2 is NaN"; - logger.info("Sp1 or Sp2 is NULL for datapoint {}", t); - continue; - } - - if (onlineFractions != null) { - double range = 5; - if (!((sum[t] >= 1 - range / 100 && sum[t] <= 1 + range / 100) - || (sum[t] >= 100 - range && sum[t] <= 100 + range))) { - calculationError[t] = - "Sum of fractions must be approximately 1 or 100, currently (" - + String.valueOf(sum[t]) + ")"; - logger.info("Online fraction does not sum to approximately 1 or 100 for datapoint {}", t); - continue; - } else { - // Remaining fractions will be set to 0.0 - double[] fraction = new double[this.system.getNumberOfComponents()]; - - for (int comp = 0; comp < onlineFractions.size(); comp++) { - fraction[comp] = onlineFractions.get(comp).get(t).doubleValue(); - } - - this.system.setMolarComposition(fraction); - this.system.init(0); - } - } - else { - double range = 1e-8; - if (!((sum[0] >= 1 - range && sum[0] <= 1 + range) - || (sum[0] >= 100 - range && sum[0] <= 100 + range))) { - calculationError[t] = - "Sum of fractions must be equal to 1 or 100, currently (" - + String.valueOf(sum[t]) + ")"; - logger.info("Sum of fractions must be equal to 1 or 100 for datapoint {}", t); - continue; - } - } - - this.system.setPressure(Sp1); - if (FlashMode == 1) { - this.system.setTemperature(Sp2); - this.TPflash(); - } else if (FlashMode == 2) { - this.PHflash(Sp2, "J/mol"); - } else if (FlashMode == 3) { - this.PSflash(Sp2, "J/molK"); - } else { - throw new RuntimeException(new neqsim.util.exception.InvalidInputException( - "ThermodynamicOperations", "propertyFlash", "mode", "must be 1, 2 or 3")); - } - this.system.init(2); - this.system.initPhysicalProperties(); - - fluidProperties[t] = this.system.getProperties().getValues(); - } catch (Exception ex) { - calculationError[t] = ex.getMessage(); - logger.error(ex.getMessage()); - } + this.system.setMolarComposition(fraction); + this.system.init(0); + } + } else { + double range = 1e-8; + if (!((sum[0] >= 1 - range && sum[0] <= 1 + range) + || (sum[0] >= 100 - range && sum[0] <= 100 + range))) { + calculationError[t] = "Sum of fractions must be equal to 1 or 100, currently (" + + String.valueOf(sum[t]) + ")"; + logger.info("Sum of fractions must be equal to 1 or 100 for datapoint {}", t); + continue; + } + } + + this.system.setPressure(Sp1); + if (FlashMode == 1) { + this.system.setTemperature(Sp2); + this.TPflash(); + } else if (FlashMode == 2) { + this.PHflash(Sp2, "J/mol"); + } else if (FlashMode == 3) { + this.PSflash(Sp2, "J/molK"); + } else { + throw new RuntimeException(new neqsim.util.exception.InvalidInputException( + "ThermodynamicOperations", "propertyFlash", "mode", "must be 1, 2 or 3")); } + this.system.init(2); + this.system.initPhysicalProperties(); - return new CalculationResult(fluidProperties, calculationError); + fluidProperties[t] = this.system.getProperties().getValues(); + } catch (Exception ex) { + calculationError[t] = ex.getMessage(); + logger.error(ex.getMessage()); + } } + + return new CalculationResult(fluidProperties, calculationError); + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/chemicalEquilibrium/ChemicalEquilibrium.java b/src/main/java/neqsim/thermodynamicOperations/chemicalEquilibrium/ChemicalEquilibrium.java index 00b5d4168d..52aee0baf9 100644 --- a/src/main/java/neqsim/thermodynamicOperations/chemicalEquilibrium/ChemicalEquilibrium.java +++ b/src/main/java/neqsim/thermodynamicOperations/chemicalEquilibrium/ChemicalEquilibrium.java @@ -19,90 +19,84 @@ * @version $Id: $Id */ public class ChemicalEquilibrium extends BaseOperation { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(ChemicalEquilibrium.class); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(ChemicalEquilibrium.class); - SystemInterface system; + SystemInterface system; - public ChemicalEquilibrium() {} + public ChemicalEquilibrium() {} - /** - *

- * Constructor for ChemicalEquilibrium. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public ChemicalEquilibrium(SystemInterface system) { - this.system = system; - } + /** + *

+ * Constructor for ChemicalEquilibrium. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public ChemicalEquilibrium(SystemInterface system) { + this.system = system; + } - /** {@inheritDoc} */ - @Override - public void run() { - double chemdev = 0; - int iter = 1; - if (system.isChemicalSystem()) { - double oldHeat = system.getChemicalReactionOperations().getReactionList() - .reacHeat(system.getPhase(1), "HCO3-"); - do { - iter++; - for (int phase = 1; phase < system.getNumberOfPhases(); phase++) { - chemdev = 0.0; - double xchem[] = new double[system.getPhases()[phase].getNumberOfComponents()]; + /** {@inheritDoc} */ + @Override + public void run() { + double chemdev = 0; + int iter = 1; + if (system.isChemicalSystem()) { + double oldHeat = system.getChemicalReactionOperations().getReactionList() + .reacHeat(system.getPhase(1), "HCO3-"); + do { + iter++; + for (int phase = 1; phase < system.getNumberOfPhases(); phase++) { + chemdev = 0.0; + double xchem[] = new double[system.getPhases()[phase].getNumberOfComponents()]; - for (int i = 0; i < system.getPhases()[phase].getNumberOfComponents(); i++) { - xchem[i] = system.getPhases()[phase].getComponents()[i].getx(); - } + for (int i = 0; i < system.getPhases()[phase].getNumberOfComponents(); i++) { + xchem[i] = system.getPhases()[phase].getComponents()[i].getx(); + } - system.init(1); - system.getChemicalReactionOperations().solveChemEq(phase); + system.init(1); + system.getChemicalReactionOperations().solveChemEq(phase); - for (int i = 0; i < system.getPhases()[phase].getNumberOfComponents(); i++) { - chemdev += Math.abs( - xchem[i] - system.getPhases()[phase].getComponents()[i].getx()); - } - } - } while (Math.abs(chemdev) > 1e-4 && iter < 100); - double newHeat = system.getChemicalReactionOperations().getReactionList() - .reacHeat(system.getPhase(1), "HCO3-"); - system.getChemicalReactionOperations().setDeltaReactionHeat(newHeat - oldHeat); - } - if (iter > 50) { - logger.info("iter : " + iter + " in chemicalequilibrium"); + for (int i = 0; i < system.getPhases()[phase].getNumberOfComponents(); i++) { + chemdev += Math.abs(xchem[i] - system.getPhases()[phase].getComponents()[i].getx()); + } } + } while (Math.abs(chemdev) > 1e-4 && iter < 100); + double newHeat = system.getChemicalReactionOperations().getReactionList() + .reacHeat(system.getPhase(1), "HCO3-"); + system.getChemicalReactionOperations().setDeltaReactionHeat(newHeat - oldHeat); } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - system.display(); + if (iter > 50) { + logger.info("iter : " + iter + " in chemicalequilibrium"); } + } - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} + /** {@inheritDoc} */ + @Override + public void displayResult() { + system.display(); + } - /** {@inheritDoc} */ - /* - @Override - public void createNetCdfFile(String name) {} -*/ - /** {@inheritDoc} */ - @Override - public double[][] getPoints(int i) { - return null; - } + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - return null; - } + /** {@inheritDoc} */ + @Override + public double[][] getPoints(int i) { + return null; + } - /** {@inheritDoc} */ - @Override - public String[][] getResultTable() { - return null; - } + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + return null; + } + + /** {@inheritDoc} */ + @Override + public String[][] getResultTable() { + return null; + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java index 9c035f516e..ec5b05aad1 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java @@ -15,464 +15,453 @@ * @author Even Solbraa */ abstract class Flash extends BaseOperation { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(Flash.class); - - SystemInterface system; - SystemInterface minimumGibbsEnergySystem; - - public double[] minGibsPhaseLogZ; - public double[] minGibsLogFugCoef; - int i = 0, j = 0, iterations = 0, maxNumberOfIterations = 100; - double gibbsEnergy = 0, gibbsEnergyOld = 0; - double Kold = 0, deviation = 0, g0 = 0, g1 = 0; - double lnOldOldOldK[], lnOldOldK[], lnK[], lnOldK[]; - double oldoldDeltalnK[], oldDeltalnK[], deltalnK[]; - double tm[]; - int lowestGibbsEnergyPhase = 0; - sysNewtonRhapsonTPflash secondOrderSolver; - protected boolean solidCheck = false, stabilityCheck = false; - boolean findLowesGibsPhaseIsChecked = false; - - /** - *

- * Constructor for Flash. - *

- */ - public Flash() {} - - /** - *

- * findLowestGibbsEnergyPhase. - *

- * - * @return a int - */ - public int findLowestGibbsEnergyPhase() { - if (!findLowesGibsPhaseIsChecked) { - minimumGibbsEnergySystem = system.clone(); - minimumGibbsEnergySystem.init(0); - minimumGibbsEnergySystem.init(1); - if ((minimumGibbsEnergySystem.getPhase(0).getGibbsEnergy() - * (1.0 - Math.signum(minimumGibbsEnergySystem.getPhase(0).getGibbsEnergy()) - * 1e-8)) < minimumGibbsEnergySystem.getPhase(1).getGibbsEnergy()) { - lowestGibbsEnergyPhase = 0; - } else { - lowestGibbsEnergyPhase = 1; - } - findLowesGibsPhaseIsChecked = true; - } - return lowestGibbsEnergyPhase; + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(Flash.class); + + SystemInterface system; + SystemInterface minimumGibbsEnergySystem; + + public double[] minGibsPhaseLogZ; + public double[] minGibsLogFugCoef; + int i = 0, j = 0, iterations = 0, maxNumberOfIterations = 100; + double gibbsEnergy = 0, gibbsEnergyOld = 0; + double Kold = 0, deviation = 0, g0 = 0, g1 = 0; + double lnOldOldOldK[], lnOldOldK[], lnK[], lnOldK[]; + double oldoldDeltalnK[], oldDeltalnK[], deltalnK[]; + double tm[]; + int lowestGibbsEnergyPhase = 0; + sysNewtonRhapsonTPflash secondOrderSolver; + protected boolean solidCheck = false, stabilityCheck = false; + boolean findLowesGibsPhaseIsChecked = false; + + /** + *

+ * Constructor for Flash. + *

+ */ + public Flash() {} + + /** + *

+ * findLowestGibbsEnergyPhase. + *

+ * + * @return a int + */ + public int findLowestGibbsEnergyPhase() { + if (!findLowesGibsPhaseIsChecked) { + minimumGibbsEnergySystem = system.clone(); + minimumGibbsEnergySystem.init(0); + minimumGibbsEnergySystem.init(1); + if ((minimumGibbsEnergySystem.getPhase(0).getGibbsEnergy() + * (1.0 - Math.signum(minimumGibbsEnergySystem.getPhase(0).getGibbsEnergy()) + * 1e-8)) < minimumGibbsEnergySystem.getPhase(1).getGibbsEnergy()) { + lowestGibbsEnergyPhase = 0; + } else { + lowestGibbsEnergyPhase = 1; + } + findLowesGibsPhaseIsChecked = true; + } + return lowestGibbsEnergyPhase; + } + + /** + *

+ * stabilityAnalysis. + *

+ * + * @throws neqsim.util.exception.IsNaNException if any. + * @throws neqsim.util.exception.TooManyIterationsException if any. + */ + public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + double[] logWi = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] deltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; + 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()]; + double[] oldoldoldlogw = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] d = new double[system.getPhases()[0].getNumberOfComponents()]; + double[][] x = new double[2][system.getPhases()[0].getNumberOfComponents()]; + double[] error = new double[2]; + tm = new double[system.getPhase(0).getNumberOfComponents()]; + double[] alpha = null; + Matrix f = new Matrix(system.getPhases()[0].getNumberOfComponents(), 1); + Matrix df = null; + int maxiterations = 50; + double fNorm = 1.0e10, fNormOld = 0.0; + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + d[i] = minGibsPhaseLogZ[i] + minGibsLogFugCoef[i]; } - /** - *

- * stabilityAnalysis. - *

- * - * @throws neqsim.util.exception.IsNaNException if any. - * @throws neqsim.util.exception.TooManyIterationsException if any. - */ - public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - double[] logWi = new double[system.getPhases()[0].getNumberOfComponents()]; - double[] deltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; - 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()]; - double[] oldoldoldlogw = new double[system.getPhases()[0].getNumberOfComponents()]; - double[] d = new double[system.getPhases()[0].getNumberOfComponents()]; - double[][] x = new double[2][system.getPhases()[0].getNumberOfComponents()]; - double[] error = new double[2]; - tm = new double[system.getPhase(0).getNumberOfComponents()]; - double[] alpha = null; - Matrix f = new Matrix(system.getPhases()[0].getNumberOfComponents(), 1); - Matrix df = null; - int maxiterations = 50; - double fNorm = 1.0e10, fNormOld = 0.0; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - d[i] = minGibsPhaseLogZ[i] + minGibsLogFugCoef[i]; - } + SystemInterface clonedSystem = minimumGibbsEnergySystem; + clonedSystem.setTotalNumberOfMoles(1.0); + sumw[1] = 0.0; + sumw[0] = 0.0; - SystemInterface clonedSystem = minimumGibbsEnergySystem; - clonedSystem.setTotalNumberOfMoles(1.0); - 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(); + sumw[0] += clonedSystem.getPhase(0).getComponent(i).getK() + * clonedSystem.getPhase(0).getComponent(i).getz(); + } - for (int i = 0; i < clonedSystem.getPhase(0).getNumberOfComponents(); i++) { - sumw[1] += clonedSystem.getPhase(0).getComponent(i).getz() - / clonedSystem.getPhase(0).getComponent(i).getK(); - sumw[0] += clonedSystem.getPhase(0).getComponent(i).getK() - * clonedSystem.getPhase(0).getComponent(i).getz(); - } + // System.out.println("sumw0 " + sumw[0]); + // System.out.println("sumw1 " + sumw[1]); + + int start = 0; + int end = 1;// clonedSystem.getNumberOfPhases()-1; + int mult = 1; + // if (sumw[1] > sumw[0]) { + if (lowestGibbsEnergyPhase == 0) { + start = end; + end = 0; + mult = -1; + } - // System.out.println("sumw0 " + sumw[0]); - // System.out.println("sumw1 " + sumw[1]); - - int start = 0; - int end = 1;// clonedSystem.getNumberOfPhases()-1; - int mult = 1; - // if (sumw[1] > sumw[0]) { - if (lowestGibbsEnergyPhase == 0) { - start = end; - end = 0; - mult = -1; - } + for (int i = 0; i < clonedSystem.getPhase(0).getNumberOfComponents(); i++) { + clonedSystem.getPhase(1).getComponent(i).setx(clonedSystem.getPhase(0).getComponent(i).getz() + / clonedSystem.getPhase(0).getComponent(i).getK() / sumw[1]); + clonedSystem.getPhase(0).getComponent(i).setx(clonedSystem.getPhase(0).getComponent(i).getK() + * clonedSystem.getPhase(0).getComponent(i).getz() / sumw[0]); + } - for (int i = 0; i < clonedSystem.getPhase(0).getNumberOfComponents(); i++) { - clonedSystem.getPhase(1).getComponent(i) - .setx(clonedSystem.getPhase(0).getComponent(i).getz() - / clonedSystem.getPhase(0).getComponent(i).getK() / sumw[1]); - clonedSystem.getPhase(0).getComponent(i) - .setx(clonedSystem.getPhase(0).getComponent(i).getK() - * clonedSystem.getPhase(0).getComponent(i).getz() / sumw[0]); + // for (int j = 0; j < clonedSystem.getNumberOfPhases(); j++) { + for (int j = start; j >= end; j = j + mult) { + for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + Wi[j][i] = clonedSystem.getPhase(j).getComponent(i).getx(); + logWi[i] = Math.log(Wi[j][i]); + } + iterations = 0; + fNorm = 1.0e10; + + do { + iterations++; + error[j] = 0.0; + + for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + oldoldoldlogw[i] = oldoldlogw[i]; + oldoldlogw[i] = oldlogw[i]; + oldlogw[i] = logWi[i]; + + oldoldDeltalogWi[i] = oldoldlogw[i] - oldoldoldlogw[i]; + oldDeltalogWi[i] = oldlogw[i] - oldoldlogw[i]; } - // for (int j = 0; j < clonedSystem.getNumberOfPhases(); j++) { - for (int j = start; j >= end; j = j + mult) { - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { - Wi[j][i] = clonedSystem.getPhase(j).getComponent(i).getx(); - logWi[i] = Math.log(Wi[j][i]); - } - iterations = 0; - fNorm = 1.0e10; - - do { - iterations++; - error[j] = 0.0; - - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { - oldoldoldlogw[i] = oldoldlogw[i]; - oldoldlogw[i] = oldlogw[i]; - oldlogw[i] = logWi[i]; - - oldoldDeltalogWi[i] = oldoldlogw[i] - oldoldoldlogw[i]; - oldDeltalogWi[i] = oldlogw[i] - oldoldlogw[i]; - } - - if ((iterations <= maxiterations - 10) - || !system.isImplementedCompositionDeriativesofFugacity()) { - clonedSystem.init(1, j); - fNormOld = fNorm; - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { - f.set(i, 0, Math.sqrt(Wi[j][i]) * (Math.log(Wi[j][i]) + clonedSystem - .getPhase(j).getComponent(i).getLogFugacityCoefficient() - d[i])); - } - fNorm = f.norm2(); - if (fNorm > fNormOld && iterations > 3 || (iterations + 1) % 7 != 0) { - break; - } - if (iterations % 7 == 0 && fNorm < fNormOld && !secondOrderStabilityAnalysis) { - double vec1 = 0.0, vec2 = 0.0, prod1 = 0.0, prod2 = 0.0; - - for (i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { - vec1 = oldDeltalogWi[i] * oldoldDeltalogWi[i]; - vec2 = Math.pow(oldoldDeltalogWi[i], 2.0); - prod1 += vec1 * vec2; - prod2 += vec2 * vec2; - } - - double lambda = prod1 / prod2; - // logger.info("lambda " + lambda); - for (i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { - logWi[i] += lambda / (1.0 - lambda) * deltalogWi[i]; - error[j] += Math.abs((logWi[i] - oldlogw[i]) / oldlogw[i]); - Wi[j][i] = Math.exp(logWi[i]); - } - } else { - // succsessive substitution - for (int i = 0; i < clonedSystem.getPhases()[0] - .getNumberOfComponents(); i++) { - logWi[i] = d[i] - clonedSystem.getPhase(j).getComponent(i) - .getLogFugacityCoefficient(); - error[j] += Math.abs((logWi[i] - oldlogw[i]) / oldlogw[i]); - Wi[j][i] = Math.exp(logWi[i]); - } - } - } else { - if (!secondOrderStabilityAnalysis) { - alpha = new double[system.getPhases()[0].getNumberOfComponents()]; - df = new Matrix(system.getPhases()[0].getNumberOfComponents(), - system.getPhases()[0].getNumberOfComponents()); - secondOrderStabilityAnalysis = true; - } - - clonedSystem.init(3, j); - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { - alpha[i] = 2.0 * Math.sqrt(Wi[j][i]); - } - - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { - f.set(i, 0, Math.sqrt(Wi[j][i]) * (Math.log(Wi[j][i]) + clonedSystem - .getPhase(j).getComponent(i).getLogFugacityCoefficient() - d[i])); - for (int k = 0; k < clonedSystem.getPhases()[0] - .getNumberOfComponents(); k++) { - double kronDelt = (i == k) ? 1.5 : 0.0; // adding 0.5 to diagonal - df.set(i, k, kronDelt + Math.sqrt(Wi[j][k] * Wi[j][i]) - * clonedSystem.getPhase(j).getComponent(i).getdfugdn(k));// * - // clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); - } - } - - Matrix dx = df.solve(f).times(-1.0); - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { - Wi[j][i] = Math.pow((alpha[i] + dx.get(i, 0)) / 2.0, 2.0); - logWi[i] = Math.log(Wi[j][i]); - error[j] += Math.abs((logWi[i] - oldlogw[i]) / oldlogw[i]); - } - - // logger.info("err newton " + error[j]); - } - - // logger.info("norm f " + f.norm1()); - // clonedSystem.display(); - sumw[j] = 0.0; - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { - sumw[j] += Wi[j][i]; - } - - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { - deltalogWi[i] = logWi[i] - oldlogw[i]; - clonedSystem.getPhase(j).getComponent(i).setx(Wi[j][i] / sumw[j]); - } - // logger.info("fnorm " + f.norm1() + " err " + error[j] + " iterations " + - // iterations + " phase " + j); - } while ((f.norm1() > 1e-6 && iterations < maxiterations) || (iterations % 7) == 0 - || iterations < 3); - // (error[j]= maxiterations) { - logger.error("err staability check " + error[j]); - // throw new util.exception.TooManyIterationsException(); + if ((iterations <= maxiterations - 10) + || !system.isImplementedCompositionDeriativesofFugacity()) { + clonedSystem.init(1, j); + fNormOld = fNorm; + for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + f.set(i, 0, Math.sqrt(Wi[j][i]) * (Math.log(Wi[j][i]) + + clonedSystem.getPhase(j).getComponent(i).getLogFugacityCoefficient() - d[i])); + } + fNorm = f.norm2(); + if (fNorm > fNormOld && iterations > 3 || (iterations + 1) % 7 != 0) { + break; + } + if (iterations % 7 == 0 && fNorm < fNormOld && !secondOrderStabilityAnalysis) { + double vec1 = 0.0, vec2 = 0.0, prod1 = 0.0, prod2 = 0.0; + + for (i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + vec1 = oldDeltalogWi[i] * oldoldDeltalogWi[i]; + vec2 = Math.pow(oldoldDeltalogWi[i], 2.0); + prod1 += vec1 * vec2; + prod2 += vec2 * vec2; } - tm[j] = 1.0; + double lambda = prod1 / prod2; + // logger.info("lambda " + lambda); + for (i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + logWi[i] += lambda / (1.0 - lambda) * deltalogWi[i]; + error[j] += Math.abs((logWi[i] - oldlogw[i]) / oldlogw[i]); + Wi[j][i] = Math.exp(logWi[i]); + } + } else { + // succsessive substitution for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { - tm[j] -= Wi[j][i]; - x[j][i] = clonedSystem.getPhase(j).getComponent(i).getx(); + logWi[i] = + d[i] - clonedSystem.getPhase(j).getComponent(i).getLogFugacityCoefficient(); + error[j] += Math.abs((logWi[i] - oldlogw[i]) / oldlogw[i]); + Wi[j][i] = Math.exp(logWi[i]); } - if (tm[j] < -1e-4 && error[j] < 1e-6) { - break; - } else { - tm[j] = 1.0; + } + } else { + if (!secondOrderStabilityAnalysis) { + alpha = new double[system.getPhases()[0].getNumberOfComponents()]; + df = new Matrix(system.getPhases()[0].getNumberOfComponents(), + system.getPhases()[0].getNumberOfComponents()); + secondOrderStabilityAnalysis = true; + } + + clonedSystem.init(3, j); + for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + alpha[i] = 2.0 * Math.sqrt(Wi[j][i]); + } + + for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + f.set(i, 0, Math.sqrt(Wi[j][i]) * (Math.log(Wi[j][i]) + + clonedSystem.getPhase(j).getComponent(i).getLogFugacityCoefficient() - d[i])); + for (int k = 0; k < clonedSystem.getPhases()[0].getNumberOfComponents(); k++) { + double kronDelt = (i == k) ? 1.5 : 0.0; // adding 0.5 to diagonal + df.set(i, k, kronDelt + Math.sqrt(Wi[j][k] * Wi[j][i]) + * clonedSystem.getPhase(j).getComponent(i).getdfugdn(k));// * + // clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); } - } + } + + Matrix dx = df.solve(f).times(-1.0); + for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + Wi[j][i] = Math.pow((alpha[i] + dx.get(i, 0)) / 2.0, 2.0); + logWi[i] = Math.log(Wi[j][i]); + error[j] += Math.abs((logWi[i] - oldlogw[i]) / oldlogw[i]); + } - // check for trivial solution - double diffx = 0.0; - for (int i = 0; i < clonedSystem.getPhase(0).getNumberOfComponents(); i++) { - diffx += Math.abs(clonedSystem.getPhase(0).getComponent(i).getx() - - clonedSystem.getPhase(1).getComponent(i).getx()); + // logger.info("err newton " + error[j]); } - if (diffx < 1e-10) { - tm[0] = 0.0; - tm[1] = 0.0; + + // logger.info("norm f " + f.norm1()); + // clonedSystem.display(); + sumw[j] = 0.0; + for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + sumw[j] += Wi[j][i]; } - if (((tm[0] < -1e-4) || (tm[1] < -1e-4)) - && !(Double.isNaN(tm[0]) || (Double.isNaN(tm[1])))) { - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { - if (system.getPhases()[1].getComponents()[i].getx() < 1e-100) { - continue; - } - if (tm[0] < -1e-4) { - system.getPhases()[1].getComponents()[i] - .setK((Wi[0][i] / sumw[0]) / (Wi[1][i] / sumw[1])); - system.getPhases()[0].getComponents()[i] - .setK((Wi[0][i] / sumw[0]) / (Wi[1][i] / sumw[1])); - } else if (tm[1] < -1e-4) { - system.getPhases()[1].getComponents()[i] - .setK((Wi[0][i] / sumw[0]) / (Wi[1][i] / sumw[1])); - system.getPhases()[0].getComponents()[i] - .setK((Wi[0][i] / sumw[0]) / (Wi[1][i] / sumw[1])); - } else { - logger.info("error in stability anlysis"); - system.init(0); - } - - if (Double.isNaN(tm[j])) { - tm[j] = 0; - } - } + for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + deltalogWi[i] = logWi[i] - oldlogw[i]; + clonedSystem.getPhase(j).getComponent(i).setx(Wi[j][i] / sumw[j]); } + // logger.info("fnorm " + f.norm1() + " err " + error[j] + " iterations " + + // iterations + " phase " + j); + } while ((f.norm1() > 1e-6 && iterations < maxiterations) || (iterations % 7) == 0 + || iterations < 3); + // (error[j]= maxiterations) { + logger.error("err staability check " + error[j]); + // throw new util.exception.TooManyIterationsException(); + } + + tm[j] = 1.0; + for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + tm[j] -= Wi[j][i]; + x[j][i] = clonedSystem.getPhase(j).getComponent(i).getx(); + } + if (tm[j] < -1e-4 && error[j] < 1e-6) { + break; + } else { + tm[j] = 1.0; + } + } - // logger.info("STABILITY ANALYSIS: "); - // logger.info("tm1: " + tm[0] + " tm2: " + tm[1]); + // check for trivial solution + double diffx = 0.0; + for (int i = 0; i < clonedSystem.getPhase(0).getNumberOfComponents(); i++) { + diffx += Math.abs(clonedSystem.getPhase(0).getComponent(i).getx() + - clonedSystem.getPhase(1).getComponent(i).getx()); + } + if (diffx < 1e-10) { + tm[0] = 0.0; + tm[1] = 0.0; } - /** - *

- * stabilityCheck. - *

- * - * @return a boolean - */ - public boolean stabilityCheck() { - boolean stable = false; - // logger.info("starting stability analysis...."); - lowestGibbsEnergyPhase = findLowestGibbsEnergyPhase(); - if (system.getPhase(lowestGibbsEnergyPhase).getNumberOfComponents() > 1) { - try { - stabilityAnalysis(); - } catch (Exception e) { - logger.error("error ", e); - } + if (((tm[0] < -1e-4) || (tm[1] < -1e-4)) && !(Double.isNaN(tm[0]) || (Double.isNaN(tm[1])))) { + for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + if (system.getPhases()[1].getComponents()[i].getx() < 1e-100) { + continue; } - if (!(tm[0] < -1e-4) && !(tm[1] < -1e-4) - || system.getPhase(0).getNumberOfComponents() == 1) { - stable = true; - system.init(0); - // logger.info("system is stable"); - // logger.info("Stable phase is : " + lowestGibbsEnergyPhase); - system.setNumberOfPhases(1); - - if (lowestGibbsEnergyPhase == 0) { - system.setPhaseType(0, 1); - } else { - system.setPhaseType(0, 0); - } - system.init(1); - if (solidCheck && !system.doMultiPhaseCheck()) { - this.solidPhaseFlash(); - } + if (tm[0] < -1e-4) { + system.getPhases()[1].getComponents()[i] + .setK((Wi[0][i] / sumw[0]) / (Wi[1][i] / sumw[1])); + system.getPhases()[0].getComponents()[i] + .setK((Wi[0][i] / sumw[0]) / (Wi[1][i] / sumw[1])); + } else if (tm[1] < -1e-4) { + system.getPhases()[1].getComponents()[i] + .setK((Wi[0][i] / sumw[0]) / (Wi[1][i] / sumw[1])); + system.getPhases()[0].getComponents()[i] + .setK((Wi[0][i] / sumw[0]) / (Wi[1][i] / sumw[1])); } else { - try { - system.calcBeta(); - } catch (Exception e) { - logger.error("error", e); - } - system.calc_x_y(); - system.init(1); + logger.info("error in stability anlysis"); + system.init(0); } - return stable; + if (Double.isNaN(tm[j])) { + tm[j] = 0; + } + } } - /** {@inheritDoc} */ - @Override - public void displayResult() { - system.display(); + // logger.info("STABILITY ANALYSIS: "); + // logger.info("tm1: " + tm[0] + " tm2: " + tm[1]); + } + + /** + *

+ * stabilityCheck. + *

+ * + * @return a boolean + */ + public boolean stabilityCheck() { + boolean stable = false; + // logger.info("starting stability analysis...."); + lowestGibbsEnergyPhase = findLowestGibbsEnergyPhase(); + if (system.getPhase(lowestGibbsEnergyPhase).getNumberOfComponents() > 1) { + try { + stabilityAnalysis(); + } catch (Exception e) { + logger.error("error ", e); + } + } + if (!(tm[0] < -1e-4) && !(tm[1] < -1e-4) || system.getPhase(0).getNumberOfComponents() == 1) { + stable = true; + system.init(0); + // logger.info("system is stable"); + // logger.info("Stable phase is : " + lowestGibbsEnergyPhase); + system.setNumberOfPhases(1); + + if (lowestGibbsEnergyPhase == 0) { + system.setPhaseType(0, 1); + } else { + system.setPhaseType(0, 0); + } + system.init(1); + if (solidCheck && !system.doMultiPhaseCheck()) { + this.solidPhaseFlash(); + } + } else { + try { + system.calcBeta(); + } catch (Exception e) { + logger.error("error", e); + } + system.calc_x_y(); + system.init(1); } - /** - *

- * solidPhaseFlash. - *

- */ - public void solidPhaseFlash() { - boolean solidPhase = false; - double frac = 0; - int solid = 0; - double[] tempVar = new double[system.getPhases()[0].getNumberOfComponents()]; - - if (!system.hasSolidPhase()) { - system.setNumberOfPhases(system.getNumberOfPhases() + 1); - system.setPhaseIndex(system.getNumberOfPhases() - 1, 3); - } - // logger.info("numb " + system.getNumberOfPhases()); - system.init(1); - - for (int k = 0; k < system.getPhase(0).getNumberOfComponents(); k++) { - if (system.getPhase(0).getComponent(k).doSolidCheck()) { - tempVar[k] = system.getPhase(0).getComponents()[k].getz(); - for (int i = 0; i < system.getNumberOfPhases() - 1; i++) { - tempVar[k] -= system.getBeta(i) - * system.getPhases()[3].getComponent(k).getFugacityCoefficient() - / system.getPhase(i).getComponent(k).getFugacityCoefficient(); - } - - if (tempVar[k] > 0.0 && tempVar[k] > frac) { - solidPhase = true; - solid = k; - frac = tempVar[k]; - for (int p = 0; p < system.getPhases()[0].getNumberOfComponents(); p++) { - system.getPhases()[3].getComponents()[p].setx(1.0e-20); - } - system.getPhases()[3].getComponents()[solid].setx(1.0); - } - // logger.info("tempVar: " + tempVar[k]); - } + return stable; + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + system.display(); + } + + /** + *

+ * solidPhaseFlash. + *

+ */ + public void solidPhaseFlash() { + boolean solidPhase = false; + double frac = 0; + int solid = 0; + double[] tempVar = new double[system.getPhases()[0].getNumberOfComponents()]; + + if (!system.hasSolidPhase()) { + system.setNumberOfPhases(system.getNumberOfPhases() + 1); + system.setPhaseIndex(system.getNumberOfPhases() - 1, 3); + } + // logger.info("numb " + system.getNumberOfPhases()); + system.init(1); + + for (int k = 0; k < system.getPhase(0).getNumberOfComponents(); k++) { + if (system.getPhase(0).getComponent(k).doSolidCheck()) { + tempVar[k] = system.getPhase(0).getComponents()[k].getz(); + for (int i = 0; i < system.getNumberOfPhases() - 1; i++) { + tempVar[k] -= + system.getBeta(i) * system.getPhases()[3].getComponent(k).getFugacityCoefficient() + / system.getPhase(i).getComponent(k).getFugacityCoefficient(); } - if (solidPhase) { - if (frac < system.getPhases()[0].getComponents()[solid].getz() + 1e10) { - for (int i = 0; i < system.getNumberOfPhases() - 1; i++) { - // system.getPhases()[i].getComponents()[solid].setx(1.0e-10); - } - system.init(1); - // logger.info("solid phase will form..." + system.getNumberOfPhases()); - // logger.info("freezing component " + solid); - system.setBeta(system.getNumberOfPhases() - 1, frac); - system.initBeta(); - system.setBeta(system.getNumberOfPhases() - 1, - system.getPhases()[3].getComponent(solid).getNumberOfmoles() - / system.getNumberOfMoles()); - // double phasetot=0.0; - // for(int ph=0;ph 0.0 && tempVar[k] > frac) { + solidPhase = true; + solid = k; + frac = tempVar[k]; + for (int p = 0; p < system.getPhases()[0].getNumberOfComponents(); p++) { + system.getPhases()[3].getComponents()[p].setx(1.0e-20); + } + system.getPhases()[3].getComponents()[solid].setx(1.0); } + // logger.info("tempVar: " + tempVar[k]); + } } - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} - - /** {@inheritDoc} */ - /* - @Override - public void createNetCdfFile(String name) {} -*/ - /** {@inheritDoc} */ - @Override - public double[][] getPoints(int i) { - return null; - } - - /** {@inheritDoc} */ - @Override - public String[][] getResultTable() { - return null; + if (solidPhase) { + if (frac < system.getPhases()[0].getComponents()[solid].getz() + 1e10) { + for (int i = 0; i < system.getNumberOfPhases() - 1; i++) { + // system.getPhases()[i].getComponents()[solid].setx(1.0e-10); + } + system.init(1); + // logger.info("solid phase will form..." + system.getNumberOfPhases()); + // logger.info("freezing component " + solid); + system.setBeta(system.getNumberOfPhases() - 1, frac); + system.initBeta(); + system.setBeta(system.getNumberOfPhases() - 1, + system.getPhases()[3].getComponent(solid).getNumberOfmoles() + / system.getNumberOfMoles()); + // double phasetot=0.0; + // for(int ph=0;ph - * Constructor for constantDutyFlash. - *

- */ - public constantDutyFlash() {} - - /** - *

- * Constructor for constantDutyFlash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public constantDutyFlash(SystemInterface system) { - this.system = system; - lnOldOldK = new double[system.getPhases()[0].getNumberOfComponents()]; - lnOldK = new double[system.getPhases()[0].getNumberOfComponents()]; - lnK = new double[system.getPhases()[0].getNumberOfComponents()]; - oldDeltalnK = new double[system.getPhases()[0].getNumberOfComponents()]; - deltalnK = new double[system.getPhases()[0].getNumberOfComponents()]; - } - - /** {@inheritDoc} */ - @Override - public void setBeta(double beta) { - this.beta = beta; - } - - /** {@inheritDoc} */ - @Override - public void run() { - system.init(0); - system.init(2); - - // int iterations = 0, maxNumberOfIterations = 10000; - // double yold = 0, ytotal = 1; - double deriv = 0, funk = 0, dkidt = 0, dyidt = 0, dxidt = 0, Told = 0; - - do { - // system.setBeta(beta+0.65); - system.init(2); - - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - system.getPhases()[0].getComponents()[i] - .setK(system.getPhases()[0].getComponents()[i].getFugacityCoefficient() - / system.getPhases()[1].getComponents()[i] - .getFugacityCoefficient()); - system.getPhases()[1].getComponents()[i] - .setK(system.getPhases()[0].getComponents()[i].getFugacityCoefficient() - / system.getPhases()[1].getComponents()[i] - .getFugacityCoefficient()); - } - - system.calc_x_y(); - - funk = 0e0; - deriv = 0e0; - - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - dkidt = (system.getPhases()[0].getComponents()[i].getdfugdt() - - system.getPhases()[1].getComponents()[i].getdfugdt()) - * system.getPhases()[0].getComponents()[i].getK(); - dxidt = -system.getPhases()[0].getComponents()[i].getx() - * system.getPhases()[0].getComponents()[i].getx() * 1.0 - / system.getPhases()[0].getComponents()[i].getz() * system.getBeta() - * dkidt; - dyidt = dkidt * system.getPhases()[0].getComponents()[i].getx() - + system.getPhases()[0].getComponents()[i].getK() * dxidt; - funk = funk + system.getPhases()[1].getComponents()[i].getx() - - system.getPhases()[0].getComponents()[i].getx(); - deriv = deriv + dyidt - dxidt; - } - - Told = system.getTemperature(); - system.setTemperature((Told - funk / deriv * 0.9)); - logger.info("Temp: " + system.getTemperature()); - } while (Math.abs((system.getTemperature() - Told) / system.getTemperature()) > 1e-7); - } - - /** {@inheritDoc} */ - /* - @Override - public void createNetCdfFile(String name) {} -*/ - /** {@inheritDoc} */ - @Override - public double[][] getPoints(int i) { - return null; - } - - /** {@inheritDoc} */ - @Override - public double[] get(String name) { - return null; - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - system.display(); - } - - /** {@inheritDoc} */ - @Override - public boolean isSuperCritical() { - return superCritical; - } - - /** - * Setter for property superCritical. - * - * @param superCritical New value of property superCritical. - */ - public void setSuperCritical(boolean superCritical) { - this.superCritical = superCritical; - } - - /** {@inheritDoc} */ - @Override - public String[][] getResultTable() { - return null; - } - - /** {@inheritDoc} */ - @Override - public void addData(String name, double[][] data) {} + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(constantDutyFlash.class); + + SystemInterface system; + protected boolean superCritical = false; + int i, j = 0, nummer = 0, iterations = 0, maxNumberOfIterations = 10000; + double gibbsEnergy = 0, gibbsEnergyOld = 0; + double Kold, deviation = 0, g0 = 0, g1 = 0; + double lnOldOldK[], lnK[]; + double lnOldK[]; + double oldDeltalnK[], deltalnK[]; + double tm[] = {1, 1}; + double beta = 1e-5; + int lowestGibbsEnergyPhase = 0; // lowestGibbsEnergyPhase + + /** + *

+ * Constructor for constantDutyFlash. + *

+ */ + public constantDutyFlash() {} + + /** + *

+ * Constructor for constantDutyFlash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public constantDutyFlash(SystemInterface system) { + this.system = system; + lnOldOldK = new double[system.getPhases()[0].getNumberOfComponents()]; + lnOldK = new double[system.getPhases()[0].getNumberOfComponents()]; + lnK = new double[system.getPhases()[0].getNumberOfComponents()]; + oldDeltalnK = new double[system.getPhases()[0].getNumberOfComponents()]; + deltalnK = new double[system.getPhases()[0].getNumberOfComponents()]; + } + + /** {@inheritDoc} */ + @Override + public void setBeta(double beta) { + this.beta = beta; + } + + /** {@inheritDoc} */ + @Override + public void run() { + system.init(0); + system.init(2); + + // int iterations = 0, maxNumberOfIterations = 10000; + // double yold = 0, ytotal = 1; + double deriv = 0, funk = 0, dkidt = 0, dyidt = 0, dxidt = 0, Told = 0; + + do { + // system.setBeta(beta+0.65); + system.init(2); + + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + system.getPhases()[0].getComponents()[i] + .setK(system.getPhases()[0].getComponents()[i].getFugacityCoefficient() + / system.getPhases()[1].getComponents()[i].getFugacityCoefficient()); + system.getPhases()[1].getComponents()[i] + .setK(system.getPhases()[0].getComponents()[i].getFugacityCoefficient() + / system.getPhases()[1].getComponents()[i].getFugacityCoefficient()); + } + + system.calc_x_y(); + + funk = 0e0; + deriv = 0e0; + + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + dkidt = (system.getPhases()[0].getComponents()[i].getdfugdt() + - system.getPhases()[1].getComponents()[i].getdfugdt()) + * system.getPhases()[0].getComponents()[i].getK(); + dxidt = -system.getPhases()[0].getComponents()[i].getx() + * system.getPhases()[0].getComponents()[i].getx() * 1.0 + / system.getPhases()[0].getComponents()[i].getz() * system.getBeta() * dkidt; + dyidt = dkidt * system.getPhases()[0].getComponents()[i].getx() + + system.getPhases()[0].getComponents()[i].getK() * dxidt; + funk = funk + system.getPhases()[1].getComponents()[i].getx() + - system.getPhases()[0].getComponents()[i].getx(); + deriv = deriv + dyidt - dxidt; + } + + Told = system.getTemperature(); + system.setTemperature((Told - funk / deriv * 0.9)); + logger.info("Temp: " + system.getTemperature()); + } while (Math.abs((system.getTemperature() - Told) / system.getTemperature()) > 1e-7); + } + + /** {@inheritDoc} */ + @Override + public double[][] getPoints(int i) { + return null; + } + + /** {@inheritDoc} */ + @Override + public double[] get(String name) { + return null; + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + system.display(); + } + + /** {@inheritDoc} */ + @Override + public boolean isSuperCritical() { + return superCritical; + } + + /** + * Setter for property superCritical. + * + * @param superCritical New value of property superCritical. + */ + public void setSuperCritical(boolean superCritical) { + this.superCritical = superCritical; + } + + /** {@inheritDoc} */ + @Override + public String[][] getResultTable() { + return null; + } + + /** {@inheritDoc} */ + @Override + public void addData(String name, double[][] data) {} } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp1.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp1.java index da1d4a17e1..8569a03781 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp1.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp1.java @@ -236,15 +236,6 @@ public String[][] getResultTable() { return null; } - /** - *

- * createNetCdfFile. - *

- * - * @param name a {@link java.lang.String} object - */ - public void createNetCdfFile(String name) {} - /** *

* getThermoSystem. diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/HPTphaseEnvelope.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/HPTphaseEnvelope.java index 9cccf27d17..bc8cf04432 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/HPTphaseEnvelope.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/HPTphaseEnvelope.java @@ -24,111 +24,100 @@ * @version $Id: $Id */ public class HPTphaseEnvelope extends BaseOperation { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - double[][] points = new double[10][10]; - SystemInterface system; - ThermodynamicOperations testOps; - JProgressBar monitor; - JFrame mainFrame; - JPanel mainPanel; - double startPressure = 1, endPressure = 0, startTemperature = 160, endTemperature = 0; - static Logger logger = LogManager.getLogger(HPTphaseEnvelope.class); + double[][] points = new double[10][10]; + SystemInterface system; + ThermodynamicOperations testOps; + JProgressBar monitor; + JFrame mainFrame; + JPanel mainPanel; + double startPressure = 1, endPressure = 0, startTemperature = 160, endTemperature = 0; + static Logger logger = LogManager.getLogger(HPTphaseEnvelope.class); - /** - *

- * Constructor for HPTphaseEnvelope. - *

- */ - public HPTphaseEnvelope() {} - - /** - *

- * Constructor for HPTphaseEnvelope. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public HPTphaseEnvelope(SystemInterface system) { - testOps = new ThermodynamicOperations(system); - this.system = system; - mainFrame = new JFrame("Progress Bar"); - mainPanel = new JPanel(); - mainPanel.setSize(200, 100); - mainFrame.getContentPane().setLayout(new FlowLayout()); - mainPanel.setLayout(new FlowLayout()); - mainFrame.setSize(200, 100); - monitor = new JProgressBar(0, 1000); - monitor.setSize(200, 100); - monitor.setStringPainted(true); - mainPanel.add(monitor); - mainFrame.getContentPane().add(mainPanel); - mainFrame.setVisible(true); - } + /** + *

+ * Constructor for HPTphaseEnvelope. + *

+ */ + public HPTphaseEnvelope() {} - /** {@inheritDoc} */ - @Override - public void run() { - int np = 0; + /** + *

+ * Constructor for HPTphaseEnvelope. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public HPTphaseEnvelope(SystemInterface system) { + testOps = new ThermodynamicOperations(system); + this.system = system; + mainFrame = new JFrame("Progress Bar"); + mainPanel = new JPanel(); + mainPanel.setSize(200, 100); + mainFrame.getContentPane().setLayout(new FlowLayout()); + mainPanel.setLayout(new FlowLayout()); + mainFrame.setSize(200, 100); + monitor = new JProgressBar(0, 1000); + monitor.setSize(200, 100); + monitor.setStringPainted(true); + mainPanel.add(monitor); + mainFrame.getContentPane().add(mainPanel); + mainFrame.setVisible(true); + } - for (int i = 0; i < 10; i++) { - system.setPressure(i * 0.5 + startPressure); - for (int j = 0; j < 10; j++) { - np++; - if (np % 2 == 0) { - monitor.setValue(np); - monitor.setString("Calculated points: " + np); - } + /** {@inheritDoc} */ + @Override + public void run() { + int np = 0; - system.setTemperature(startTemperature + j); - testOps.TPflash(); - system.init(3); - points[i][j] = system.getEnthalpy(); - } + for (int i = 0; i < 10; i++) { + system.setPressure(i * 0.5 + startPressure); + for (int j = 0; j < 10; j++) { + np++; + if (np % 2 == 0) { + monitor.setValue(np); + monitor.setString("Calculated points: " + np); } - } - /** {@inheritDoc} */ - @Override - public void displayResult() { - /* - try { - mainFrame.setVisible(false); - visAd3DPlot plot = - new visAd3DPlot("pressure[bar]", "temperature[K]", "enthalpy[J/mol]"); - plot.setXYvals(150, 160, 10, 10, 20, 10); - plot.setZvals(points); - plot.init(); - } catch (Exception e) { - logger.error("plotting failed"); - } - */ + system.setTemperature(startTemperature + j); + testOps.TPflash(); + system.init(3); + points[i][j] = system.getEnthalpy(); + } } + } - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} + /** {@inheritDoc} */ + @Override + public void displayResult() { + /* + * try { mainFrame.setVisible(false); visAd3DPlot plot = new visAd3DPlot("pressure[bar]", + * "temperature[K]", "enthalpy[J/mol]"); plot.setXYvals(150, 160, 10, 10, 20, 10); + * plot.setZvals(points); plot.init(); } catch (Exception e) { logger.error("plotting failed"); + * } + */ + } - /** {@inheritDoc} */ - @Override - public double[][] getPoints(int i) { - return points; - } + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} - /** {@inheritDoc} */ - /* - @Override - public void createNetCdfFile(String name) {} -*/ - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - return null; - } + /** {@inheritDoc} */ + @Override + public double[][] getPoints(int i) { + return points; + } - /** {@inheritDoc} */ - @Override - public String[][] getResultTable() { - return null; - } + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + return null; + } + + /** {@inheritDoc} */ + @Override + public String[][] getResultTable() { + return null; + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope.java index 3d7e7a63ed..d6a116ea16 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope.java @@ -722,14 +722,6 @@ public double[] get(String name) { } } - /** {@inheritDoc} */ - /* - @Override - public void createNetCdfFile(String name) { - fileName = name; - } - */ - /** * Getter for property bubblePointFirst. * diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope1.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope1.java index fc49ed29aa..ce360ac5d3 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope1.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope1.java @@ -21,461 +21,442 @@ * @version $Id: $Id */ public class pTphaseEnvelope1 extends BaseOperation { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(pTphaseEnvelope1.class); - - graph2b graph2 = null; - SystemInterface system; - boolean bubblePointFirst = true; - double[] cricondenTherm = new double[3]; - double[] cricondenBar = new double[3]; - double phaseFraction = 1e-10; - int i, j = 0, nummer = 0, iterations = 0, maxNumberOfIterations = 10000; - double gibbsEnergy = 0, gibbsEnergyOld = 0; - double Kold, deviation = 0, g0 = 0, g1 = 0, lowPres = 1.0; - double lnOldOldK[], lnK[]; - boolean outputToFile = false; - double lnOldK[]; - double oldDeltalnK[], deltalnK[]; - double tm[] = {1, 1}; - double beta = 1e-5; - int lowestGibbsEnergyPhase = 0; // lowestGibbsEnergyPhase - JProgressBar monitor; - JFrame mainFrame; - String fileName = "c:/file"; - JPanel mainPanel; - double temp = 0, pres = 0, startPres = 0; - double[][] points = new double[2][]; - double[] pointsH; - double[][] pointsH2 = new double[4][]; - double[] pointsV; - double[][] pointsV2 = new double[4][]; - double[] pointsS; - double[][] pointsS2 = new double[4][]; - public double[][] points2 = new double[4][]; - double[][] points3 = new double[8][]; - boolean moreLines = false; - int np = 0; - // points[2] = new double[1000]; - int speceq = 0; - - /** - *

- * Constructor for pTphaseEnvelope1. - *

- */ - public pTphaseEnvelope1() {} - - /** - *

- * Constructor for pTphaseEnvelope1. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param name a {@link java.lang.String} object - * @param phaseFraction a double - * @param lowPres a double - * @param bubfirst a boolean - */ - public pTphaseEnvelope1(SystemInterface system, String name, double phaseFraction, - double lowPres, boolean bubfirst) { - this.bubblePointFirst = bubfirst; - if (name != null) { - outputToFile = true; - fileName = name; - } - this.system = system; - this.phaseFraction = phaseFraction; - lnOldOldK = new double[system.getPhase(0).getNumberOfComponents()]; - lnOldK = new double[system.getPhase(0).getNumberOfComponents()]; - lnK = new double[system.getPhase(0).getNumberOfComponents()]; - this.lowPres = lowPres; - oldDeltalnK = new double[system.getPhase(0).getNumberOfComponents()]; - deltalnK = new double[system.getPhase(0).getNumberOfComponents()]; - mainFrame = new JFrame("Progress Bar"); - mainPanel = new JPanel(); - mainPanel.setSize(200, 100); - mainFrame.getContentPane().setLayout(new FlowLayout()); - mainPanel.setLayout(new FlowLayout()); - mainFrame.setSize(200, 100); - monitor = new JProgressBar(0, 00); - monitor.setSize(200, 100); - monitor.setStringPainted(true); - mainPanel.add(monitor); - mainFrame.getContentPane().add(mainPanel); - mainFrame.setVisible(true); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(pTphaseEnvelope1.class); + + graph2b graph2 = null; + SystemInterface system; + boolean bubblePointFirst = true; + double[] cricondenTherm = new double[3]; + double[] cricondenBar = new double[3]; + double phaseFraction = 1e-10; + int i, j = 0, nummer = 0, iterations = 0, maxNumberOfIterations = 10000; + double gibbsEnergy = 0, gibbsEnergyOld = 0; + double Kold, deviation = 0, g0 = 0, g1 = 0, lowPres = 1.0; + double lnOldOldK[], lnK[]; + boolean outputToFile = false; + double lnOldK[]; + double oldDeltalnK[], deltalnK[]; + double tm[] = {1, 1}; + double beta = 1e-5; + int lowestGibbsEnergyPhase = 0; // lowestGibbsEnergyPhase + JProgressBar monitor; + JFrame mainFrame; + String fileName = "c:/file"; + JPanel mainPanel; + double temp = 0, pres = 0, startPres = 0; + double[][] points = new double[2][]; + double[] pointsH; + double[][] pointsH2 = new double[4][]; + double[] pointsV; + double[][] pointsV2 = new double[4][]; + double[] pointsS; + double[][] pointsS2 = new double[4][]; + public double[][] points2 = new double[4][]; + double[][] points3 = new double[8][]; + boolean moreLines = false; + int np = 0; + // points[2] = new double[1000]; + int speceq = 0; + + /** + *

+ * Constructor for pTphaseEnvelope1. + *

+ */ + public pTphaseEnvelope1() {} + + /** + *

+ * Constructor for pTphaseEnvelope1. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param name a {@link java.lang.String} object + * @param phaseFraction a double + * @param lowPres a double + * @param bubfirst a boolean + */ + public pTphaseEnvelope1(SystemInterface system, String name, double phaseFraction, double lowPres, + boolean bubfirst) { + this.bubblePointFirst = bubfirst; + if (name != null) { + outputToFile = true; + fileName = name; } + this.system = system; + this.phaseFraction = phaseFraction; + lnOldOldK = new double[system.getPhase(0).getNumberOfComponents()]; + lnOldK = new double[system.getPhase(0).getNumberOfComponents()]; + lnK = new double[system.getPhase(0).getNumberOfComponents()]; + this.lowPres = lowPres; + oldDeltalnK = new double[system.getPhase(0).getNumberOfComponents()]; + deltalnK = new double[system.getPhase(0).getNumberOfComponents()]; + mainFrame = new JFrame("Progress Bar"); + mainPanel = new JPanel(); + mainPanel.setSize(200, 100); + mainFrame.getContentPane().setLayout(new FlowLayout()); + mainPanel.setLayout(new FlowLayout()); + mainFrame.setSize(200, 100); + monitor = new JProgressBar(0, 00); + monitor.setSize(200, 100); + monitor.setStringPainted(true); + mainPanel.add(monitor); + mainFrame.getContentPane().add(mainPanel); + mainFrame.setVisible(true); + } + + /** {@inheritDoc} */ + @Override + public void run() { + try { + points[0] = new double[10000]; + points[1] = new double[10000]; + + pointsH = new double[10000]; + pointsV = new double[10000]; + pointsS = new double[10000]; + system.init(0); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (system.getPhase(0).getComponent(i).getIonicCharge() == 0) { + if (system.getPhase(0).getComponents()[i].getTC() < system.getPhase(0).getComponents()[i] + .getTC()) { + speceq = system.getPhase(0).getComponent(i).getComponentNumber(); + } + } + } + + pres = lowPres; + temp = system.getPhase(0).getComponent(speceq).getAntoineVaporTemperature(pres); + // temp = system.getTemperature(); + system.setPressure(pres); - /** {@inheritDoc} */ - @Override - public void run() { + system.setBeta(1e-10); + + ThermodynamicOperations testOps = new ThermodynamicOperations(system); + + system.init(0); + for (int i = 0; i < 1000; i++) { + temp += i * 4; + system.setTemperature(temp); try { - points[0] = new double[10000]; - points[1] = new double[10000]; - - pointsH = new double[10000]; - pointsV = new double[10000]; - pointsS = new double[10000]; - system.init(0); - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - if (system.getPhase(0).getComponent(i).getIonicCharge() == 0) { - if (system.getPhase(0).getComponents()[i] - .getTC() < system.getPhase(0).getComponents()[i].getTC()) { - speceq = system.getPhase(0).getComponent(i).getComponentNumber(); - } - } - } - - pres = lowPres; - temp = system.getPhase(0).getComponent(speceq).getAntoineVaporTemperature(pres); - // temp = system.getTemperature(); - system.setPressure(pres); - - system.setBeta(1e-10); - - ThermodynamicOperations testOps = new ThermodynamicOperations(system); - - system.init(0); - for (int i = 0; i < 1000; i++) { - temp += i * 4; - system.setTemperature(temp); - try { - if (bubblePointFirst) { - testOps.bubblePointTemperatureFlash(); - } else { - testOps.dewPointTemperatureFlash(); - } - } catch (Exception e) { - e.toString(); - } - double tempNy = system.getTemperature(); - - if (!Double.isNaN(tempNy)) { - temp = tempNy; - break; - } - } - - system.setPressure(pres); - system.setTemperature(temp); - logger.info("temp: " + system.getTemperature()); - - system.setBeta(phaseFraction); - - sysNewtonRhapsonPhaseEnvelope nonLinSolver = new sysNewtonRhapsonPhaseEnvelope(system, - 2, system.getPhase(0).getNumberOfComponents()); - nonLinSolver.solve(1); - - startPres = system.getPressure(); - - for (np = 1; np < 9500; np++) { - if (np % 5 == 0) { - monitor.setValue(np); - monitor.setString("Calculated points: " + np); - } - - nonLinSolver.calcInc(np); - nonLinSolver.solve(np); - - if (system.getTemperature() > cricondenTherm[0]) { - cricondenTherm[1] = system.getPressure(); - cricondenTherm[0] = system.getTemperature(); - } - if (system.getPressure() > cricondenBar[1]) { - cricondenBar[0] = system.getTemperature(); - cricondenBar[1] = system.getPressure(); - } - - if (Double.isNaN(system.getTemperature()) || Double.isNaN(system.getTemperature()) - || system.getPressure() < startPres) { - points[0][np - 1] = points[0][np - 3]; - points[1][np - 1] = points[1][np - 3]; - pointsH[np - 1] = pointsH[np - 3]; - pointsV[np - 1] = pointsV[np - 3]; - pointsS[np - 1] = pointsS[np - 3]; - - // logger.info("avbryter" + np); - break; - } - // logger.info("Ideal pres: " + getPressure()); - // logger.info("temp: " + system.getTemperature()); - points[0][np - 1] = system.getTemperature(); - points[1][np - 1] = system.getPressure(); - pointsH[np - 1] = system.getPhase(1).getEnthalpy() - / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - pointsV[np - 1] = system.getPhase(1).getDensity(); - pointsS[np - 1] = system.getPhase(1).getEntropy() - / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - } - - int ncr = nonLinSolver.getNpCrit(); - int ncr2 = np - ncr; - - logger.info("ncr: " + ncr + " ncr2 . " + ncr2); - points2[0] = new double[ncr + 1]; - points2[1] = new double[ncr + 1]; - pointsH2[0] = new double[ncr + 1]; - pointsH2[1] = new double[ncr + 1]; - pointsS2[0] = new double[ncr + 1]; - pointsS2[1] = new double[ncr + 1]; - pointsV2[0] = new double[ncr + 1]; - pointsV2[1] = new double[ncr + 1]; - if (ncr2 > 2) { - points2[2] = new double[ncr2 - 2]; - points2[3] = new double[ncr2 - 2]; - pointsH2[2] = new double[ncr2 - 2]; - pointsH2[3] = new double[ncr2 - 2]; - pointsV2[2] = new double[ncr2 - 2]; - pointsV2[3] = new double[ncr2 - 2]; - pointsS2[2] = new double[ncr2 - 2]; - pointsS2[3] = new double[ncr2 - 2]; - } else { - points2[2] = new double[0]; - points2[3] = new double[0]; - pointsH2[2] = new double[0]; - pointsH2[3] = new double[0]; - pointsV2[2] = new double[0]; - pointsV2[3] = new double[0]; - pointsS2[2] = new double[0]; - pointsS2[3] = new double[0]; - } - - for (int i = 0; i < ncr; i++) { - points2[0][i] = points[0][i]; - points2[1][i] = points[1][i]; - - pointsH2[1][i] = points[1][i]; - pointsH2[0][i] = pointsH[i]; - - pointsS2[1][i] = points[1][i]; - pointsS2[0][i] = pointsS[i]; - - pointsV2[1][i] = points[1][i]; - pointsV2[0][i] = pointsV[i]; - } - - system.setTemperature(system.getTC() + 0.001); - system.setPressure(system.getPC() + 0.001); - system.init(3); - - points2[0][ncr] = system.getTC(); - points2[1][ncr] = system.getPC(); - - pointsH2[1][ncr] = system.getPC(); - pointsH2[0][ncr] = - system.getPhase(1).getEnthalpy() / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - - pointsS2[1][ncr] = system.getPC(); - pointsS2[0][ncr] = - system.getPhase(1).getEntropy() / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - - pointsV2[1][ncr] = system.getPC(); - pointsV2[0][ncr] = system.getPhase(1).getDensity(); - - if (ncr2 > 2) { - points2[2][0] = system.getTC(); - points2[3][0] = system.getPC(); - pointsH2[3][0] = system.getPC(); - pointsH2[2][0] = system.getPhase(1).getEnthalpy() - / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - pointsS2[3][0] = system.getPC(); - pointsS2[2][0] = system.getPhase(1).getEntropy() - / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - pointsV2[3][0] = system.getPC(); - pointsV2[2][0] = system.getPhase(1).getDensity(); - - for (int i = 1; i < (ncr2 - 2); i++) { - points2[2][i] = points[0][i + ncr - 1]; - points2[3][i] = points[1][i + ncr - 1]; - - pointsH2[3][i] = points[1][i + ncr - 1]; - pointsH2[2][i] = pointsH[i + ncr - 1]; - - pointsS2[3][i] = points[1][i + ncr - 1]; - pointsS2[2][i] = pointsS[i + ncr - 1]; - - pointsV2[3][i] = points[1][i + ncr - 1]; - pointsV2[2][i] = pointsV[i + ncr - 1]; - } - } - // monitor.close(); - mainFrame.setVisible(false); -/* - if (outputToFile) { - String name1 = new String(); - name1 = fileName + "Dew.nc"; - file1 = new neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); - file1.setOutputFileName(name1); - file1.setXvalues(points2[2], "temp", "sec"); - file1.setYvalues(points2[3], "pres", "meter"); - file1.createFile(); - - String name2 = new String(); - name2 = fileName + "Bub.nc"; - file2 = new neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); - file2.setOutputFileName(name2); - file2.setXvalues(points2[0], "temp", "sec"); - file2.setYvalues(points2[1], "pres", "meter"); - file2.createFile(); - } - */ + if (bubblePointFirst) { + testOps.bubblePointTemperatureFlash(); + } else { + testOps.dewPointTemperatureFlash(); + } } catch (Exception e) { - logger.error("error", e); + e.toString(); } - } + double tempNy = system.getTemperature(); - /** {@inheritDoc} */ - @Override - public void displayResult() { - DecimalFormat nf = new DecimalFormat(); - nf.setMaximumFractionDigits(1); - nf.applyPattern("####.#"); - - double TC = system.getTC(); - double PC = system.getPC(); - logger.info("tc : " + TC + " PC : " + PC); - String[] navn = {"bubble point", "dew point", "bubble point", "dew point"}; - String title = "PT-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - String title3 = "PH-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - String title4 = "Density-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - String title5 = "PS-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - - // logger.info("start flash"); - // logger.info("Tferdig.."); - - graph2b graph3 = new graph2b(pointsH2, navn, title3, "Enthalpy [kJ/kg]", "Pressure [bara]"); - graph3.setVisible(true); - graph3.saveFigure((neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig4.png")); - - graph2b graph4 = new graph2b(pointsV2, navn, title4, "Density [kg/m^3]", "Pressure [bara]"); - graph4.setVisible(true); - graph4.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig2.png"); - - graph2b graph5 = - new graph2b(pointsS2, navn, title5, "Entropy [kJ/kg*K]", "Pressure [bara]"); - graph5.setVisible(true); - graph5.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig3.png"); - - graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); - graph2.setVisible(true); - graph2.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig1.png"); - - /* - * JDialog dialog = new JDialog(); Container dialogContentPane = dialog.getContentPane(); - * dialogContentPane.setLayout(new FlowLayout()); JFreeChartPanel chartPanel = - * graph4.getChartPanel(); dialogContentPane.add(chartPanel); dialog.show(); - */ - } + if (!Double.isNaN(tempNy)) { + temp = tempNy; + break; + } + } - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} - - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - DecimalFormat nf = new DecimalFormat(); - nf.setMaximumFractionDigits(1); - nf.applyPattern("####.#"); - - double TC = system.getTC(); - double PC = system.getPC(); - logger.info("tc : " + TC + " PC : " + PC); - String[] navn = {"bubble point", "dew point", "bubble point", "dew point"}; - String title = "PT-graph. TC=" + String.valueOf(nf.format(TC)) + "K, PC=" - + String.valueOf(nf.format(PC) + " bara"); - graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); - return graph2.getChart(); - } + system.setPressure(pres); + system.setTemperature(temp); + logger.info("temp: " + system.getTemperature()); - /** {@inheritDoc} */ - @Override - public double[][] getPoints(int i) { - return points2; - } + system.setBeta(phaseFraction); - /** {@inheritDoc} */ - @Override - public double[] get(String name) { - if (name.equals("bubT")) { - return points2[0]; - } - if (name.equals("bubP")) { - return points2[1]; - } - if (name.equals("dewT")) { - return points2[2]; - } - if (name.equals("dewP")) { - return points2[3]; - } - if (name.equals("dewH")) { - return pointsH2[2]; - } - if (name.equals("dewDens")) { - return pointsV2[2]; - } - if (name.equals("dewS")) { - return pointsS2[2]; - } - if (name.equals("bubH")) { - return pointsH2[0]; + sysNewtonRhapsonPhaseEnvelope nonLinSolver = + new sysNewtonRhapsonPhaseEnvelope(system, 2, system.getPhase(0).getNumberOfComponents()); + nonLinSolver.solve(1); + + startPres = system.getPressure(); + + for (np = 1; np < 9500; np++) { + if (np % 5 == 0) { + monitor.setValue(np); + monitor.setString("Calculated points: " + np); } - if (name.equals("bubDens")) { - return pointsV2[0]; + + nonLinSolver.calcInc(np); + nonLinSolver.solve(np); + + if (system.getTemperature() > cricondenTherm[0]) { + cricondenTherm[1] = system.getPressure(); + cricondenTherm[0] = system.getTemperature(); } - if (name.equals("bubS")) { - return pointsS2[0]; + if (system.getPressure() > cricondenBar[1]) { + cricondenBar[0] = system.getTemperature(); + cricondenBar[1] = system.getPressure(); } - if (name.equals("cricondentherm")) { - return cricondenTherm; + + if (Double.isNaN(system.getTemperature()) || Double.isNaN(system.getTemperature()) + || system.getPressure() < startPres) { + points[0][np - 1] = points[0][np - 3]; + points[1][np - 1] = points[1][np - 3]; + pointsH[np - 1] = pointsH[np - 3]; + pointsV[np - 1] = pointsV[np - 3]; + pointsS[np - 1] = pointsS[np - 3]; + + // logger.info("avbryter" + np); + break; } - if (name.equals("cricondenbar")) { - return cricondenBar; - } else { - return null; + // logger.info("Ideal pres: " + getPressure()); + // logger.info("temp: " + system.getTemperature()); + points[0][np - 1] = system.getTemperature(); + points[1][np - 1] = system.getPressure(); + pointsH[np - 1] = + system.getPhase(1).getEnthalpy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3; + pointsV[np - 1] = system.getPhase(1).getDensity(); + pointsS[np - 1] = + system.getPhase(1).getEntropy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3; + } + + int ncr = nonLinSolver.getNpCrit(); + int ncr2 = np - ncr; + + logger.info("ncr: " + ncr + " ncr2 . " + ncr2); + points2[0] = new double[ncr + 1]; + points2[1] = new double[ncr + 1]; + pointsH2[0] = new double[ncr + 1]; + pointsH2[1] = new double[ncr + 1]; + pointsS2[0] = new double[ncr + 1]; + pointsS2[1] = new double[ncr + 1]; + pointsV2[0] = new double[ncr + 1]; + pointsV2[1] = new double[ncr + 1]; + if (ncr2 > 2) { + points2[2] = new double[ncr2 - 2]; + points2[3] = new double[ncr2 - 2]; + pointsH2[2] = new double[ncr2 - 2]; + pointsH2[3] = new double[ncr2 - 2]; + pointsV2[2] = new double[ncr2 - 2]; + pointsV2[3] = new double[ncr2 - 2]; + pointsS2[2] = new double[ncr2 - 2]; + pointsS2[3] = new double[ncr2 - 2]; + } else { + points2[2] = new double[0]; + points2[3] = new double[0]; + pointsH2[2] = new double[0]; + pointsH2[3] = new double[0]; + pointsV2[2] = new double[0]; + pointsV2[3] = new double[0]; + pointsS2[2] = new double[0]; + pointsS2[3] = new double[0]; + } + + for (int i = 0; i < ncr; i++) { + points2[0][i] = points[0][i]; + points2[1][i] = points[1][i]; + + pointsH2[1][i] = points[1][i]; + pointsH2[0][i] = pointsH[i]; + + pointsS2[1][i] = points[1][i]; + pointsS2[0][i] = pointsS[i]; + + pointsV2[1][i] = points[1][i]; + pointsV2[0][i] = pointsV[i]; + } + + system.setTemperature(system.getTC() + 0.001); + system.setPressure(system.getPC() + 0.001); + system.init(3); + + points2[0][ncr] = system.getTC(); + points2[1][ncr] = system.getPC(); + + pointsH2[1][ncr] = system.getPC(); + pointsH2[0][ncr] = system.getPhase(1).getEnthalpy() + / system.getPhase(1).getNumberOfMolesInPhase() / system.getPhase(1).getMolarMass() / 1e3; + + pointsS2[1][ncr] = system.getPC(); + pointsS2[0][ncr] = system.getPhase(1).getEntropy() + / system.getPhase(1).getNumberOfMolesInPhase() / system.getPhase(1).getMolarMass() / 1e3; + + pointsV2[1][ncr] = system.getPC(); + pointsV2[0][ncr] = system.getPhase(1).getDensity(); + + if (ncr2 > 2) { + points2[2][0] = system.getTC(); + points2[3][0] = system.getPC(); + pointsH2[3][0] = system.getPC(); + pointsH2[2][0] = + system.getPhase(1).getEnthalpy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3; + pointsS2[3][0] = system.getPC(); + pointsS2[2][0] = + system.getPhase(1).getEntropy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3; + pointsV2[3][0] = system.getPC(); + pointsV2[2][0] = system.getPhase(1).getDensity(); + + for (int i = 1; i < (ncr2 - 2); i++) { + points2[2][i] = points[0][i + ncr - 1]; + points2[3][i] = points[1][i + ncr - 1]; + + pointsH2[3][i] = points[1][i + ncr - 1]; + pointsH2[2][i] = pointsH[i + ncr - 1]; + + pointsS2[3][i] = points[1][i + ncr - 1]; + pointsS2[2][i] = pointsS[i + ncr - 1]; + + pointsV2[3][i] = points[1][i + ncr - 1]; + pointsV2[2][i] = pointsV[i + ncr - 1]; } + } + // monitor.close(); + mainFrame.setVisible(false); + /* + * if (outputToFile) { String name1 = new String(); name1 = fileName + "Dew.nc"; file1 = new + * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); + * file1.setOutputFileName(name1); file1.setXvalues(points2[2], "temp", "sec"); + * file1.setYvalues(points2[3], "pres", "meter"); file1.createFile(); + * + * String name2 = new String(); name2 = fileName + "Bub.nc"; file2 = new + * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); + * file2.setOutputFileName(name2); file2.setXvalues(points2[0], "temp", "sec"); + * file2.setYvalues(points2[1], "pres", "meter"); file2.createFile(); } + */ + } catch (Exception e) { + logger.error("error", e); } + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + DecimalFormat nf = new DecimalFormat(); + nf.setMaximumFractionDigits(1); + nf.applyPattern("####.#"); + + double TC = system.getTC(); + double PC = system.getPC(); + logger.info("tc : " + TC + " PC : " + PC); + String[] navn = {"bubble point", "dew point", "bubble point", "dew point"}; + String title = + "PT-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + String.valueOf(nf.format(PC)); + String title3 = + "PH-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + String.valueOf(nf.format(PC)); + String title4 = "Density-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + + String.valueOf(nf.format(PC)); + String title5 = + "PS-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + String.valueOf(nf.format(PC)); + + // logger.info("start flash"); + // logger.info("Tferdig.."); + + graph2b graph3 = new graph2b(pointsH2, navn, title3, "Enthalpy [kJ/kg]", "Pressure [bara]"); + graph3.setVisible(true); + graph3.saveFigure((neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig4.png")); + + graph2b graph4 = new graph2b(pointsV2, navn, title4, "Density [kg/m^3]", "Pressure [bara]"); + graph4.setVisible(true); + graph4.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig2.png"); + + graph2b graph5 = new graph2b(pointsS2, navn, title5, "Entropy [kJ/kg*K]", "Pressure [bara]"); + graph5.setVisible(true); + graph5.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig3.png"); + + graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); + graph2.setVisible(true); + graph2.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig1.png"); - /** {@inheritDoc} */ /* - @Override - public void createNetCdfFile(String name) { - fileName = name; - } - */ - - /** - * Getter for property bubblePointFirst. - * - * @return Value of property bubblePointFirst. + * JDialog dialog = new JDialog(); Container dialogContentPane = dialog.getContentPane(); + * dialogContentPane.setLayout(new FlowLayout()); JFreeChartPanel chartPanel = + * graph4.getChartPanel(); dialogContentPane.add(chartPanel); dialog.show(); */ - public boolean isBubblePointFirst() { - return bubblePointFirst; + } + + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} + + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + DecimalFormat nf = new DecimalFormat(); + nf.setMaximumFractionDigits(1); + nf.applyPattern("####.#"); + + double TC = system.getTC(); + double PC = system.getPC(); + logger.info("tc : " + TC + " PC : " + PC); + String[] navn = {"bubble point", "dew point", "bubble point", "dew point"}; + String title = "PT-graph. TC=" + String.valueOf(nf.format(TC)) + "K, PC=" + + String.valueOf(nf.format(PC) + " bara"); + graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); + return graph2.getChart(); + } + + /** {@inheritDoc} */ + @Override + public double[][] getPoints(int i) { + return points2; + } + + /** {@inheritDoc} */ + @Override + public double[] get(String name) { + if (name.equals("bubT")) { + return points2[0]; } - - /** - * Setter for property bubblePointFirst. - * - * @param bubblePointFirst New value of property bubblePointFirst. - */ - public void setBubblePointFirst(boolean bubblePointFirst) { - this.bubblePointFirst = bubblePointFirst; + if (name.equals("bubP")) { + return points2[1]; } - - /** {@inheritDoc} */ - @Override - public String[][] getResultTable() { - return null; + if (name.equals("dewT")) { + return points2[2]; + } + if (name.equals("dewP")) { + return points2[3]; + } + if (name.equals("dewH")) { + return pointsH2[2]; + } + if (name.equals("dewDens")) { + return pointsV2[2]; + } + if (name.equals("dewS")) { + return pointsS2[2]; + } + if (name.equals("bubH")) { + return pointsH2[0]; + } + if (name.equals("bubDens")) { + return pointsV2[0]; + } + if (name.equals("bubS")) { + return pointsS2[0]; + } + if (name.equals("cricondentherm")) { + return cricondenTherm; + } + if (name.equals("cricondenbar")) { + return cricondenBar; + } else { + return null; } + } + + /** + * Getter for property bubblePointFirst. + * + * @return Value of property bubblePointFirst. + */ + public boolean isBubblePointFirst() { + return bubblePointFirst; + } + + /** + * Setter for property bubblePointFirst. + * + * @param bubblePointFirst New value of property bubblePointFirst. + */ + public void setBubblePointFirst(boolean bubblePointFirst) { + this.bubblePointFirst = bubblePointFirst; + } + + /** {@inheritDoc} */ + @Override + public String[][] getResultTable() { + return null; + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeMay.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeMay.java index 1724eb7e68..02c54b233c 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeMay.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeMay.java @@ -20,778 +20,756 @@ * @version $Id: $Id */ public class pTphaseEnvelopeMay extends BaseOperation { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(pTphaseEnvelopeMay.class); - - double maxPressure = 1000.0; - double minPressure = 1.0; - double[][] copiedPoints = null; - graph2b graph2 = null; - SystemInterface system; - boolean bubblePointFirst = true; - boolean hascopiedPoints = false; - double[] cricondenTherm = new double[3]; - double[] cricondenBar = new double[3]; - double phaseFraction = 1e-10; - int i, j = 0, nummer = 0, iterations = 0, maxNumberOfIterations = 10000; - double gibbsEnergy = 0, gibbsEnergyOld = 0; - double Kold, deviation = 0, g0 = 0, g1 = 0, lowPres = 1.0; - double lnOldOldK[], lnK[]; - boolean outputToFile = false; - double lnOldK[]; - double lnKwil[]; - double oldDeltalnK[], deltalnK[]; - double tm[] = {1, 1}; - double beta = 1e-5; - int lowestGibbsEnergyPhase = 0; // lowestGibbsEnergyPhase - JProgressBar monitor; - JFrame mainFrame; - String fileName = "c:/file"; - JPanel mainPanel; - double temp = 0, pres = 0, startPres = 0; - double[][] points = new double[2][]; - double[] pointsH; - double[][] pointsH2 = new double[4][]; - double[] pointsV; - double[][] pointsV2 = new double[4][]; - double[] pointsS; - double[][] pointsS2 = new double[4][]; - public double[][] points2 = new double[4][]; - double[][] points3 = new double[8][]; - boolean moreLines = false; - boolean restart = true; - int np = 0; - // points[2] = new double[1000]; - int speceq = 0; - String[] navn = {"bubble point", "dew point", "bubble point", "dew point", "dew points"}; - int npfirst; - int ncrfirst; - double Tcfirst; - double Pcfirst; - double Tmin = 0.0; - - /** - *

- * Constructor for pTphaseEnvelopeMay. - *

- */ - public pTphaseEnvelopeMay() {} - - /** - *

- * Constructor for pTphaseEnvelopeMay. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param name a {@link java.lang.String} object - * @param phaseFraction a double - * @param lowPres a double - * @param bubfirst a boolean - */ - public pTphaseEnvelopeMay(SystemInterface system, String name, double phaseFraction, - double lowPres, boolean bubfirst) { - this.bubblePointFirst = bubfirst; - if (name != null) { - outputToFile = true; - fileName = name; - } - this.system = system; - this.phaseFraction = phaseFraction; - lnOldOldK = new double[system.getPhase(0).getNumberOfComponents()]; - lnOldK = new double[system.getPhase(0).getNumberOfComponents()]; - lnK = new double[system.getPhase(0).getNumberOfComponents()]; - this.lowPres = lowPres; - oldDeltalnK = new double[system.getPhase(0).getNumberOfComponents()]; - deltalnK = new double[system.getPhase(0).getNumberOfComponents()]; + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(pTphaseEnvelopeMay.class); + + double maxPressure = 1000.0; + double minPressure = 1.0; + double[][] copiedPoints = null; + graph2b graph2 = null; + SystemInterface system; + boolean bubblePointFirst = true; + boolean hascopiedPoints = false; + double[] cricondenTherm = new double[3]; + double[] cricondenBar = new double[3]; + double phaseFraction = 1e-10; + int i, j = 0, nummer = 0, iterations = 0, maxNumberOfIterations = 10000; + double gibbsEnergy = 0, gibbsEnergyOld = 0; + double Kold, deviation = 0, g0 = 0, g1 = 0, lowPres = 1.0; + double lnOldOldK[], lnK[]; + boolean outputToFile = false; + double lnOldK[]; + double lnKwil[]; + double oldDeltalnK[], deltalnK[]; + double tm[] = {1, 1}; + double beta = 1e-5; + int lowestGibbsEnergyPhase = 0; // lowestGibbsEnergyPhase + JProgressBar monitor; + JFrame mainFrame; + String fileName = "c:/file"; + JPanel mainPanel; + double temp = 0, pres = 0, startPres = 0; + double[][] points = new double[2][]; + double[] pointsH; + double[][] pointsH2 = new double[4][]; + double[] pointsV; + double[][] pointsV2 = new double[4][]; + double[] pointsS; + double[][] pointsS2 = new double[4][]; + public double[][] points2 = new double[4][]; + double[][] points3 = new double[8][]; + boolean moreLines = false; + boolean restart = true; + int np = 0; + // points[2] = new double[1000]; + int speceq = 0; + String[] navn = {"bubble point", "dew point", "bubble point", "dew point", "dew points"}; + int npfirst; + int ncrfirst; + double Tcfirst; + double Pcfirst; + double Tmin = 0.0; + + /** + *

+ * Constructor for pTphaseEnvelopeMay. + *

+ */ + public pTphaseEnvelopeMay() {} + + /** + *

+ * Constructor for pTphaseEnvelopeMay. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param name a {@link java.lang.String} object + * @param phaseFraction a double + * @param lowPres a double + * @param bubfirst a boolean + */ + public pTphaseEnvelopeMay(SystemInterface system, String name, double phaseFraction, + double lowPres, boolean bubfirst) { + this.bubblePointFirst = bubfirst; + if (name != null) { + outputToFile = true; + fileName = name; } - - /** {@inheritDoc} */ - @Override - public void run() { - speceq = 0; // initialization + this.system = system; + this.phaseFraction = phaseFraction; + lnOldOldK = new double[system.getPhase(0).getNumberOfComponents()]; + lnOldK = new double[system.getPhase(0).getNumberOfComponents()]; + lnK = new double[system.getPhase(0).getNumberOfComponents()]; + this.lowPres = lowPres; + oldDeltalnK = new double[system.getPhase(0).getNumberOfComponents()]; + deltalnK = new double[system.getPhase(0).getNumberOfComponents()]; + } + + /** {@inheritDoc} */ + @Override + public void run() { + speceq = 0; // initialization + try { + points[0] = new double[10000]; // declarations for points + points[1] = new double[10000]; // declarations for points + + pointsH = new double[10000]; // declarations for points + pointsV = new double[10000]; // declarations for points + pointsS = new double[10000]; // declarations for points + system.init(0); // initialization + + // selects the most volatile and least volatile component based on Tc values + // afterwards it uses them to define the speceq of the first point + // based on the desired first point, dew/bubble + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (system.getPhase(0).getComponent(i).getIonicCharge() == 0) { + if (bubblePointFirst == true && system.getPhase(0).getComponents()[speceq] + .getTC() > system.getPhase(0).getComponents()[i].getTC()) { + speceq = system.getPhase(0).getComponent(i).getComponentNumber(); + } + if (bubblePointFirst == false && system.getPhase(0).getComponents()[speceq] + .getTC() < system.getPhase(0).getComponents()[i].getTC()) { + speceq = system.getPhase(0).getComponent(i).getComponentNumber(); + } + } + } + + // initialized the first step of the phase envelope + // pressure is already defined + // temperature is the Antoine vapor pressure of the selected component + // (least or most volatile. + pres = lowPres; + // temp = + // system.getPhase(0).getComponent(speceq).getAntoineVaporTemperature(pres); + temp = tempKWilson(phaseFraction, pres); + + if (Double.isNaN(temp)) { + temp = system.getPhase(0).getComponent(speceq).getTC() - 20.0; + } + system.setTemperature(temp); + system.setPressure(pres); + + ThermodynamicOperations testOps = new ThermodynamicOperations(system); + + // this part converges the first phase envelope point. + // if the phase fraction is more than 0.5 it does a dew point initialization + // else a bubble point initialization + + for (int i = 0; i < 5; i++) { try { - points[0] = new double[10000]; // declarations for points - points[1] = new double[10000]; // declarations for points - - pointsH = new double[10000]; // declarations for points - pointsV = new double[10000]; // declarations for points - pointsS = new double[10000]; // declarations for points - system.init(0); // initialization - - // selects the most volatile and least volatile component based on Tc values - // afterwards it uses them to define the speceq of the first point - // based on the desired first point, dew/bubble - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - if (system.getPhase(0).getComponent(i).getIonicCharge() == 0) { - if (bubblePointFirst == true && system.getPhase(0).getComponents()[speceq] - .getTC() > system.getPhase(0).getComponents()[i].getTC()) { - speceq = system.getPhase(0).getComponent(i).getComponentNumber(); - } - if (bubblePointFirst == false && system.getPhase(0).getComponents()[speceq] - .getTC() < system.getPhase(0).getComponents()[i].getTC()) { - speceq = system.getPhase(0).getComponent(i).getComponentNumber(); - } - } - } - - // initialized the first step of the phase envelope - // pressure is already defined - // temperature is the Antoine vapor pressure of the selected component - // (least or most volatile. - pres = lowPres; - // temp = - // system.getPhase(0).getComponent(speceq).getAntoineVaporTemperature(pres); - temp = tempKWilson(phaseFraction, pres); - - if (Double.isNaN(temp)) { - temp = system.getPhase(0).getComponent(speceq).getTC() - 20.0; - } + if (phaseFraction < 0.5) { + temp += i * 2; system.setTemperature(temp); - system.setPressure(pres); - - ThermodynamicOperations testOps = new ThermodynamicOperations(system); - - // this part converges the first phase envelope point. - // if the phase fraction is more than 0.5 it does a dew point initialization - // else a bubble point initialization - - for (int i = 0; i < 5; i++) { - try { - if (phaseFraction < 0.5) { - temp += i * 2; - system.setTemperature(temp); - testOps.bubblePointTemperatureFlash(); - } else { - temp += i * 2; - system.setTemperature(temp); - testOps.dewPointTemperatureFlash(); - } - } catch (Exception e) { - e.toString(); - } - double tempNy = system.getTemperature(); - - if (!Double.isNaN(tempNy)) { - temp = tempNy; - break; - } - } - - // this part sets the first envelope point into the system - system.setBeta(phaseFraction); - system.setPressure(pres); + testOps.bubblePointTemperatureFlash(); + } else { + temp += i * 2; system.setTemperature(temp); + testOps.dewPointTemperatureFlash(); + } + } catch (Exception e) { + e.toString(); + } + double tempNy = system.getTemperature(); - sysNewtonRhapsonPhaseEnvelope nonLinSolver = new sysNewtonRhapsonPhaseEnvelope(system, - 2, system.getPhase(0).getNumberOfComponents()); - startPres = system.getPressure(); - nonLinSolver.setu(); - for (np = 1; np < 9980; np++) { - try { - // solves the np point of the envelope - nonLinSolver.calcInc(np); - nonLinSolver.solve(np); - - // double TT = system.getPhase(0).getTemperature(); - // double PP = system.getPhase(0).getPressure(); - } catch (Exception e0) { - // the envelope crushed. - // this part keeps the old values - // restarts the envelope from the other side - // and then stops - - if (restart) { - restart = false; - // keep values - Tmin = points[0][np - 2]; - npfirst = np - 1; - ncrfirst = nonLinSolver.getNpCrit(); - if (ncrfirst == 0) { - ncrfirst = npfirst; - } - Tcfirst = system.getTC(); - Pcfirst = system.getPC(); - hascopiedPoints = true; - copiedPoints = new double[5][np - 1]; - for (int i = 0; i < np - 1; i++) { - copiedPoints[0][i] = points[0][i]; - copiedPoints[1][i] = points[1][i]; - copiedPoints[2][i] = pointsH[i]; - copiedPoints[3][i] = pointsS[i]; - copiedPoints[4][i] = pointsV[i]; - } - // new settings - phaseFraction = 1.0 - phaseFraction; - if (bubblePointFirst) { - bubblePointFirst = false; - } else { - bubblePointFirst = true; - } - run(); - break; - } else { - np = np - 1; - break; - } - } - - // check for critical point - double Kvallc = system.getPhase(0).getComponent(nonLinSolver.lc).getx() - / system.getPhase(1).getComponent(nonLinSolver.lc).getx(); - double Kvalhc = system.getPhase(0).getComponent(nonLinSolver.hc).getx() - / system.getPhase(1).getComponent(nonLinSolver.hc).getx(); - // double densV = system.getPhase(0).getDensity(); - // double densL = system.getPhase(1).getDensity(); - - // System.out.println(np + " " + system.getTemperature() + " " + - // system.getPressure() + " " + densV + " " + densL ); - - if ((nonLinSolver.etterCP == false)) { - if (Kvallc < 1.05 && Kvalhc > 0.95) { - // close to the critical point - // invert phase types and find the CP Temp and Press - - // System.out.println("critical point"); - nonLinSolver.npCrit = np; - system.invertPhaseTypes(); - nonLinSolver.etterCP = true; - // the critical point is found from interpolation plynimials based on K=1 of - // the - // most or least volatile component - nonLinSolver.calcCrit(); - } - } - if (nonLinSolver.calcCP) { - nonLinSolver.calcCP = false; - nonLinSolver.npCrit = np; - nonLinSolver.calcCrit(); - } - - // stores cricondenbar and cricondentherm - // HERE the new cricoT and crico P values will be called instead - if (system.getTemperature() > cricondenTherm[0]) { - cricondenTherm[1] = system.getPressure(); - cricondenTherm[0] = system.getTemperature(); - } else { - nonLinSolver.ettercricoT = true; - } - if (system.getPressure() > cricondenBar[1]) { - cricondenBar[0] = system.getTemperature(); - cricondenBar[1] = system.getPressure(); - } - - // Exit criteria - if ((system.getPressure() < minPressure && nonLinSolver.ettercricoT)) { - break; - } - if (system.getPressure() > maxPressure) { - break; - } - if (system.getTemperature() > Tmin && !restart) { - break; - } - - // Keeps the calculated points - points[0][np - 1] = system.getTemperature(); - points[1][np - 1] = system.getPressure(); - pointsH[np - 1] = system.getPhase(1).getEnthalpy() - / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - pointsV[np - 1] = system.getPhase(1).getDensity(); - pointsS[np - 1] = system.getPhase(1).getEntropy() - / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; + if (!Double.isNaN(tempNy)) { + temp = tempNy; + break; + } + } + + // this part sets the first envelope point into the system + system.setBeta(phaseFraction); + system.setPressure(pres); + system.setTemperature(temp); + + sysNewtonRhapsonPhaseEnvelope nonLinSolver = + new sysNewtonRhapsonPhaseEnvelope(system, 2, system.getPhase(0).getNumberOfComponents()); + startPres = system.getPressure(); + nonLinSolver.setu(); + for (np = 1; np < 9980; np++) { + try { + // solves the np point of the envelope + nonLinSolver.calcInc(np); + nonLinSolver.solve(np); + + // double TT = system.getPhase(0).getTemperature(); + // double PP = system.getPhase(0).getPressure(); + } catch (Exception e0) { + // the envelope crushed. + // this part keeps the old values + // restarts the envelope from the other side + // and then stops + + if (restart) { + restart = false; + // keep values + Tmin = points[0][np - 2]; + npfirst = np - 1; + ncrfirst = nonLinSolver.getNpCrit(); + if (ncrfirst == 0) { + ncrfirst = npfirst; } - - try { - int ncr = nonLinSolver.getNpCrit(); - if (ncr == 0) { - ncr = np; - } - int ncr2 = np - ncr; - if (hascopiedPoints) { - // if it enters here the envelope crashed and restarted - // reallocate to have all values - points2 = new double[8][]; - pointsH2 = new double[8][]; - pointsS2 = new double[8][]; - pointsV2 = new double[8][]; - } - - // points2 are plotted - points2[0] = new double[ncr + 1]; - points2[1] = new double[ncr + 1]; - pointsH2[0] = new double[ncr + 1]; - pointsH2[1] = new double[ncr + 1]; - pointsS2[0] = new double[ncr + 1]; - pointsS2[1] = new double[ncr + 1]; - pointsV2[0] = new double[ncr + 1]; - pointsV2[1] = new double[ncr + 1]; - - if (ncr2 > 2) { - points2[2] = new double[ncr2 - 2]; - points2[3] = new double[ncr2 - 2]; - pointsH2[2] = new double[ncr2 - 2]; - pointsH2[3] = new double[ncr2 - 2]; - pointsS2[2] = new double[ncr2 - 2]; - pointsS2[3] = new double[ncr2 - 2]; - pointsV2[2] = new double[ncr2 - 2]; - pointsV2[3] = new double[ncr2 - 2]; - } else { - points2[2] = new double[0]; - points2[3] = new double[0]; - pointsH2[2] = new double[0]; - pointsH2[3] = new double[0]; - pointsS2[2] = new double[0]; - pointsS2[3] = new double[0]; - pointsV2[2] = new double[0]; - pointsV2[3] = new double[0]; - } - - for (int i = 0; i < ncr; i++) { - // second branch up to critical point - points2[0][i] = points[0][i]; - points2[1][i] = points[1][i]; - pointsH2[1][i] = points[1][i]; - pointsH2[0][i] = pointsH[i]; - pointsS2[1][i] = points[1][i]; - pointsS2[0][i] = pointsS[i]; - pointsV2[1][i] = points[1][i]; - pointsV2[0][i] = pointsV[i]; - } - if (ncr2 > 2) { - for (int i = 1; i < (ncr2 - 2); i++) { - // second branch after the critical point - points2[2][i] = points[0][i + ncr - 1]; - points2[3][i] = points[1][i + ncr - 1]; - pointsH2[3][i] = points[1][i + ncr - 1]; - pointsH2[2][i] = pointsH[i + ncr - 1]; - pointsS2[3][i] = points[1][i + ncr - 1]; - pointsS2[2][i] = pointsS[i + ncr - 1]; - pointsV2[3][i] = points[1][i + ncr - 1]; - pointsV2[2][i] = pointsV[i + ncr - 1]; - } - } - - if (hascopiedPoints) { - if (ncrfirst > npfirst) { - ncr = copiedPoints[0].length - 1; - ncr2 = npfirst - ncr; - npfirst = npfirst - 1; - } else { - ncr = ncrfirst; - ncr2 = npfirst - ncr; - } - - points2[4] = new double[ncr + 1]; - points2[5] = new double[ncr + 1]; - pointsH2[4] = new double[ncr + 1]; - pointsH2[5] = new double[ncr + 1]; - pointsS2[4] = new double[ncr + 1]; - pointsS2[5] = new double[ncr + 1]; - pointsV2[4] = new double[ncr + 1]; - pointsV2[5] = new double[ncr + 1]; - - if (ncr2 > 2) { - points2[6] = new double[ncr2 - 2]; - points2[7] = new double[ncr2 - 2]; - pointsH2[6] = new double[ncr2 - 2]; - pointsH2[7] = new double[ncr2 - 2]; - pointsS2[6] = new double[ncr2 - 2]; - pointsS2[7] = new double[ncr2 - 2]; - pointsV2[6] = new double[ncr2 - 2]; - pointsV2[7] = new double[ncr2 - 2]; - } else { - points2[6] = new double[0]; - points2[7] = new double[0]; - pointsH2[6] = new double[0]; - pointsH2[7] = new double[0]; - pointsS2[6] = new double[0]; - pointsS2[7] = new double[0]; - pointsV2[6] = new double[0]; - pointsV2[7] = new double[0]; - } - - for (int i = 0; i < ncr; i++) { - // first branch up to the critical point - points2[4][i] = copiedPoints[0][i]; - points2[5][i] = copiedPoints[1][i]; - pointsH2[5][i] = copiedPoints[1][i]; - pointsH2[4][i] = copiedPoints[2][i]; - pointsS2[5][i] = copiedPoints[1][i]; - pointsS2[4][i] = copiedPoints[3][i]; - pointsV2[5][i] = copiedPoints[1][i]; - pointsV2[4][i] = copiedPoints[4][i]; - } - if (ncr2 > 2) { - for (int i = 1; i < (ncr2 - 2); i++) { - // first branch after the critical point - points2[6][i] = copiedPoints[0][i + ncr - 1]; - points2[7][i] = copiedPoints[1][i + ncr - 1]; - pointsH2[7][i] = copiedPoints[1][i + ncr - 1]; - pointsH2[6][i] = copiedPoints[2][i + ncr - 1]; - pointsS2[7][i] = copiedPoints[1][i + ncr - 1]; - pointsS2[6][i] = copiedPoints[3][i + ncr - 1]; - pointsV2[7][i] = copiedPoints[1][i + ncr - 1]; - pointsV2[6][i] = copiedPoints[4][i + ncr - 1]; - } - } - } - - // critical point - system.setTemperature(system.getTC()); - system.setPressure(system.getPC()); - - system.init(3); - - points2[0][ncr] = system.getTC(); - points2[1][ncr] = system.getPC(); - - if (ncr2 > 2) { - points2[2][0] = system.getTC(); - points2[3][0] = system.getPC(); - } - } catch (Exception e2) { - // double nef = 0.; - logger.error("error", e2); + Tcfirst = system.getTC(); + Pcfirst = system.getPC(); + hascopiedPoints = true; + copiedPoints = new double[5][np - 1]; + for (int i = 0; i < np - 1; i++) { + copiedPoints[0][i] = points[0][i]; + copiedPoints[1][i] = points[1][i]; + copiedPoints[2][i] = pointsH[i]; + copiedPoints[3][i] = pointsS[i]; + copiedPoints[4][i] = pointsV[i]; } -/* - try { - if (outputToFile) { - // update this - String name1 = new String(); - name1 = fileName + "Dew.nc"; - file1 = new neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); - file1.setOutputFileName(name1); - file1.setXvalues(points2[2], "temp", "sec"); - file1.setYvalues(points2[3], "pres", "meter"); - file1.createFile(); - - String name2 = new String(); - name2 = fileName + "Bub.nc"; - file2 = new neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); - file2.setOutputFileName(name2); - file2.setXvalues(points2[0], "temp", "sec"); - file2.setYvalues(points2[1], "pres", "meter"); - file2.createFile(); - } - } catch (Exception e3) { - // double nef = 0.; - logger.error("error", e3); + // new settings + phaseFraction = 1.0 - phaseFraction; + if (bubblePointFirst) { + bubblePointFirst = false; + } else { + bubblePointFirst = true; } - */ - } catch (Exception e4) { - // double nef = 0.; - logger.error("error", e4); + run(); + break; + } else { + np = np - 1; + break; + } } - } - /** - *

- * calcHydrateLine. - *

- */ - public void calcHydrateLine() { - ThermodynamicOperations opsHyd = new ThermodynamicOperations(system); - try { - opsHyd.hydrateEquilibriumLine(10.0, 300.0); - } catch (Exception e) { - logger.error("error", e); + // check for critical point + double Kvallc = system.getPhase(0).getComponent(nonLinSolver.lc).getx() + / system.getPhase(1).getComponent(nonLinSolver.lc).getx(); + double Kvalhc = system.getPhase(0).getComponent(nonLinSolver.hc).getx() + / system.getPhase(1).getComponent(nonLinSolver.hc).getx(); + // double densV = system.getPhase(0).getDensity(); + // double densL = system.getPhase(1).getDensity(); + + // System.out.println(np + " " + system.getTemperature() + " " + + // system.getPressure() + " " + densV + " " + densL ); + + if ((nonLinSolver.etterCP == false)) { + if (Kvallc < 1.05 && Kvalhc > 0.95) { + // close to the critical point + // invert phase types and find the CP Temp and Press + + // System.out.println("critical point"); + nonLinSolver.npCrit = np; + system.invertPhaseTypes(); + nonLinSolver.etterCP = true; + // the critical point is found from interpolation plynimials based on K=1 of + // the + // most or least volatile component + nonLinSolver.calcCrit(); + } } - - // double[][] hydData = opsHyd.getData(); - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - DecimalFormat nf = new DecimalFormat(); - nf.setMaximumFractionDigits(1); - nf.applyPattern("####.#"); - if (bubblePointFirst) { - // bubble point side - navn[0] = "bubble point 2"; - navn[1] = "dew point 2"; - navn[2] = "dew point 1"; - navn[3] = "bubble point 1"; - } else { - // dew point side and does not crash - navn[0] = "dew point"; - navn[1] = "bubble point"; - navn[2] = "dew point"; - navn[3] = "bubbl point"; + if (nonLinSolver.calcCP) { + nonLinSolver.calcCP = false; + nonLinSolver.npCrit = np; + nonLinSolver.calcCrit(); } - double TC = system.getTC(); - double PC = system.getPC(); - - String title = "PT-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - String title3 = "PH-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - String title4 = "Density-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - String title5 = "PS-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - - graph2b graph3 = new graph2b(pointsH2, navn, title3, "Enthalpy [kJ/kg]", "Pressure [bara]"); - graph3.setVisible(true); - // graph3.saveFigure(new String(util.util.FileSystemSettings.tempDir + - // "NeqSimTempFig4.png")); - - graph2b graph4 = new graph2b(pointsV2, navn, title4, "Density [kg/m^3]", "Pressure [bara]"); - graph4.setVisible(true); - // graph4.saveFigure(util.util.FileSystemSettings.tempDir + - // "NeqSimTempFig2.png"); - - graph2b graph5 = - new graph2b(pointsS2, navn, title5, "Entropy [kJ/kg*K]", "Pressure [bara]"); - graph5.setVisible(true); - // graph5.saveFigure(util.util.FileSystemSettings.tempDir + - // "NeqSimTempFig3.png"); - - graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); - graph2.setVisible(true); - // graph2.saveFigure(util.util.FileSystemSettings.tempDir + - // "NeqSimTempFig1.png"); - - /* - * JDialog dialog = new JDialog(); Container dialogContentPane = dialog.getContentPane(); - * dialogContentPane.setLayout(new FlowLayout()); JFreeChartPanel chartPanel = - * graph4.getChartPanel(); dialogContentPane.add(chartPanel); dialog.show(); - */ - } - - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} - - /** {@inheritDoc} */ - @Override - public double[][] getPoints(int i) { - return points2; - } - - /** {@inheritDoc} */ - @Override - public void addData(String name, double[][] data) { - double[][] localPoints = new double[points2.length + data.length][]; - navn[localPoints.length / 2 - 1] = name; - System.arraycopy(points2, 0, localPoints, 0, points2.length); - System.arraycopy(data, 0, localPoints, points2.length, data.length); - points2 = localPoints; - } - - /** {@inheritDoc} */ - @Override - public double[] get(String name) { - if (name.equals("dewT")) { - return points2[0]; - } - if (name.equals("dewP")) { - return points2[1]; - } - if (name.equals("bubT")) { - return points2[2]; - } - if (name.equals("bubP")) { - return points2[3]; - } - if (name.equals("dewT2")) { - return points2[4]; - } - if (name.equals("dewP2")) { - return points2[5]; - } - if (name.equals("bubT2")) { - return points2[6]; + // stores cricondenbar and cricondentherm + // HERE the new cricoT and crico P values will be called instead + if (system.getTemperature() > cricondenTherm[0]) { + cricondenTherm[1] = system.getPressure(); + cricondenTherm[0] = system.getTemperature(); + } else { + nonLinSolver.ettercricoT = true; } - if (name.equals("bubP2")) { - return points2[7]; + if (system.getPressure() > cricondenBar[1]) { + cricondenBar[0] = system.getTemperature(); + cricondenBar[1] = system.getPressure(); } - if (name.equals("dewH")) { - return pointsH2[2]; + + // Exit criteria + if ((system.getPressure() < minPressure && nonLinSolver.ettercricoT)) { + break; } - if (name.equals("dewDens")) { - return pointsV2[2]; + if (system.getPressure() > maxPressure) { + break; } - if (name.equals("dewS")) { - return pointsS2[2]; + if (system.getTemperature() > Tmin && !restart) { + break; } - if (name.equals("bubH")) { - return pointsH2[0]; + + // Keeps the calculated points + points[0][np - 1] = system.getTemperature(); + points[1][np - 1] = system.getPressure(); + pointsH[np - 1] = + system.getPhase(1).getEnthalpy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3; + pointsV[np - 1] = system.getPhase(1).getDensity(); + pointsS[np - 1] = + system.getPhase(1).getEntropy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3; + } + + try { + int ncr = nonLinSolver.getNpCrit(); + if (ncr == 0) { + ncr = np; } - if (name.equals("bubDens")) { - return pointsV2[0]; + int ncr2 = np - ncr; + if (hascopiedPoints) { + // if it enters here the envelope crashed and restarted + // reallocate to have all values + points2 = new double[8][]; + pointsH2 = new double[8][]; + pointsS2 = new double[8][]; + pointsV2 = new double[8][]; } - if (name.equals("bubS")) { - return pointsS2[0]; + + // points2 are plotted + points2[0] = new double[ncr + 1]; + points2[1] = new double[ncr + 1]; + pointsH2[0] = new double[ncr + 1]; + pointsH2[1] = new double[ncr + 1]; + pointsS2[0] = new double[ncr + 1]; + pointsS2[1] = new double[ncr + 1]; + pointsV2[0] = new double[ncr + 1]; + pointsV2[1] = new double[ncr + 1]; + + if (ncr2 > 2) { + points2[2] = new double[ncr2 - 2]; + points2[3] = new double[ncr2 - 2]; + pointsH2[2] = new double[ncr2 - 2]; + pointsH2[3] = new double[ncr2 - 2]; + pointsS2[2] = new double[ncr2 - 2]; + pointsS2[3] = new double[ncr2 - 2]; + pointsV2[2] = new double[ncr2 - 2]; + pointsV2[3] = new double[ncr2 - 2]; + } else { + points2[2] = new double[0]; + points2[3] = new double[0]; + pointsH2[2] = new double[0]; + pointsH2[3] = new double[0]; + pointsS2[2] = new double[0]; + pointsS2[3] = new double[0]; + pointsV2[2] = new double[0]; + pointsV2[3] = new double[0]; } - if (name.equals("cricondentherm")) { - return cricondenTherm; + + for (int i = 0; i < ncr; i++) { + // second branch up to critical point + points2[0][i] = points[0][i]; + points2[1][i] = points[1][i]; + pointsH2[1][i] = points[1][i]; + pointsH2[0][i] = pointsH[i]; + pointsS2[1][i] = points[1][i]; + pointsS2[0][i] = pointsS[i]; + pointsV2[1][i] = points[1][i]; + pointsV2[0][i] = pointsV[i]; } - if (name.equals("cricondenbar")) { - return cricondenBar; + if (ncr2 > 2) { + for (int i = 1; i < (ncr2 - 2); i++) { + // second branch after the critical point + points2[2][i] = points[0][i + ncr - 1]; + points2[3][i] = points[1][i + ncr - 1]; + pointsH2[3][i] = points[1][i + ncr - 1]; + pointsH2[2][i] = pointsH[i + ncr - 1]; + pointsS2[3][i] = points[1][i + ncr - 1]; + pointsS2[2][i] = pointsS[i + ncr - 1]; + pointsV2[3][i] = points[1][i + ncr - 1]; + pointsV2[2][i] = pointsV[i + ncr - 1]; + } } - if (name.equals("criticalPoint1")) { - return new double[] {system.getTC(), system.getPC()}; + + if (hascopiedPoints) { + if (ncrfirst > npfirst) { + ncr = copiedPoints[0].length - 1; + ncr2 = npfirst - ncr; + npfirst = npfirst - 1; + } else { + ncr = ncrfirst; + ncr2 = npfirst - ncr; + } + + points2[4] = new double[ncr + 1]; + points2[5] = new double[ncr + 1]; + pointsH2[4] = new double[ncr + 1]; + pointsH2[5] = new double[ncr + 1]; + pointsS2[4] = new double[ncr + 1]; + pointsS2[5] = new double[ncr + 1]; + pointsV2[4] = new double[ncr + 1]; + pointsV2[5] = new double[ncr + 1]; + + if (ncr2 > 2) { + points2[6] = new double[ncr2 - 2]; + points2[7] = new double[ncr2 - 2]; + pointsH2[6] = new double[ncr2 - 2]; + pointsH2[7] = new double[ncr2 - 2]; + pointsS2[6] = new double[ncr2 - 2]; + pointsS2[7] = new double[ncr2 - 2]; + pointsV2[6] = new double[ncr2 - 2]; + pointsV2[7] = new double[ncr2 - 2]; + } else { + points2[6] = new double[0]; + points2[7] = new double[0]; + pointsH2[6] = new double[0]; + pointsH2[7] = new double[0]; + pointsS2[6] = new double[0]; + pointsS2[7] = new double[0]; + pointsV2[6] = new double[0]; + pointsV2[7] = new double[0]; + } + + for (int i = 0; i < ncr; i++) { + // first branch up to the critical point + points2[4][i] = copiedPoints[0][i]; + points2[5][i] = copiedPoints[1][i]; + pointsH2[5][i] = copiedPoints[1][i]; + pointsH2[4][i] = copiedPoints[2][i]; + pointsS2[5][i] = copiedPoints[1][i]; + pointsS2[4][i] = copiedPoints[3][i]; + pointsV2[5][i] = copiedPoints[1][i]; + pointsV2[4][i] = copiedPoints[4][i]; + } + if (ncr2 > 2) { + for (int i = 1; i < (ncr2 - 2); i++) { + // first branch after the critical point + points2[6][i] = copiedPoints[0][i + ncr - 1]; + points2[7][i] = copiedPoints[1][i + ncr - 1]; + pointsH2[7][i] = copiedPoints[1][i + ncr - 1]; + pointsH2[6][i] = copiedPoints[2][i + ncr - 1]; + pointsS2[7][i] = copiedPoints[1][i + ncr - 1]; + pointsS2[6][i] = copiedPoints[3][i + ncr - 1]; + pointsV2[7][i] = copiedPoints[1][i + ncr - 1]; + pointsV2[6][i] = copiedPoints[4][i + ncr - 1]; + } + } } - if (name.equals("criticalPoint2")) { - return new double[] {0, 0}; - } else { - return null; + + // critical point + system.setTemperature(system.getTC()); + system.setPressure(system.getPC()); + + system.init(3); + + points2[0][ncr] = system.getTC(); + points2[1][ncr] = system.getPC(); + + if (ncr2 > 2) { + points2[2][0] = system.getTC(); + points2[3][0] = system.getPC(); } + } catch (Exception e2) { + // double nef = 0.; + logger.error("error", e2); + } + /* + * try { if (outputToFile) { // update this String name1 = new String(); name1 = fileName + + * "Dew.nc"; file1 = new + * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); + * file1.setOutputFileName(name1); file1.setXvalues(points2[2], "temp", "sec"); + * file1.setYvalues(points2[3], "pres", "meter"); file1.createFile(); + * + * String name2 = new String(); name2 = fileName + "Bub.nc"; file2 = new + * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); + * file2.setOutputFileName(name2); file2.setXvalues(points2[0], "temp", "sec"); + * file2.setYvalues(points2[1], "pres", "meter"); file2.createFile(); } } catch (Exception e3) + * { // double nef = 0.; logger.error("error", e3); } + */ + } catch (Exception e4) { + // double nef = 0.; + logger.error("error", e4); } - - /** {@inheritDoc} */ - /* - @Override - public void createNetCdfFile(String name) { - fileName = name; + } + + /** + *

+ * calcHydrateLine. + *

+ */ + public void calcHydrateLine() { + ThermodynamicOperations opsHyd = new ThermodynamicOperations(system); + try { + opsHyd.hydrateEquilibriumLine(10.0, 300.0); + } catch (Exception e) { + logger.error("error", e); } - */ - /** - * Getter for property bubblePointFirst. - * - * @return Value of property bubblePointFirst. - */ - public boolean isBubblePointFirst() { - return bubblePointFirst; + // double[][] hydData = opsHyd.getData(); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + DecimalFormat nf = new DecimalFormat(); + nf.setMaximumFractionDigits(1); + nf.applyPattern("####.#"); + if (bubblePointFirst) { + // bubble point side + navn[0] = "bubble point 2"; + navn[1] = "dew point 2"; + navn[2] = "dew point 1"; + navn[3] = "bubble point 1"; + } else { + // dew point side and does not crash + navn[0] = "dew point"; + navn[1] = "bubble point"; + navn[2] = "dew point"; + navn[3] = "bubbl point"; } - /** - * Setter for property bubblePointFirst. - * - * @param bubblePointFirst New value of property bubblePointFirst. + double TC = system.getTC(); + double PC = system.getPC(); + + String title = + "PT-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + String.valueOf(nf.format(PC)); + String title3 = + "PH-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + String.valueOf(nf.format(PC)); + String title4 = "Density-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + + String.valueOf(nf.format(PC)); + String title5 = + "PS-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + String.valueOf(nf.format(PC)); + + graph2b graph3 = new graph2b(pointsH2, navn, title3, "Enthalpy [kJ/kg]", "Pressure [bara]"); + graph3.setVisible(true); + // graph3.saveFigure(new String(util.util.FileSystemSettings.tempDir + + // "NeqSimTempFig4.png")); + + graph2b graph4 = new graph2b(pointsV2, navn, title4, "Density [kg/m^3]", "Pressure [bara]"); + graph4.setVisible(true); + // graph4.saveFigure(util.util.FileSystemSettings.tempDir + + // "NeqSimTempFig2.png"); + + graph2b graph5 = new graph2b(pointsS2, navn, title5, "Entropy [kJ/kg*K]", "Pressure [bara]"); + graph5.setVisible(true); + // graph5.saveFigure(util.util.FileSystemSettings.tempDir + + // "NeqSimTempFig3.png"); + + graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); + graph2.setVisible(true); + // graph2.saveFigure(util.util.FileSystemSettings.tempDir + + // "NeqSimTempFig1.png"); + + /* + * JDialog dialog = new JDialog(); Container dialogContentPane = dialog.getContentPane(); + * dialogContentPane.setLayout(new FlowLayout()); JFreeChartPanel chartPanel = + * graph4.getChartPanel(); dialogContentPane.add(chartPanel); dialog.show(); */ - public void setBubblePointFirst(boolean bubblePointFirst) { - this.bubblePointFirst = bubblePointFirst; + } + + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} + + /** {@inheritDoc} */ + @Override + public double[][] getPoints(int i) { + return points2; + } + + /** {@inheritDoc} */ + @Override + public void addData(String name, double[][] data) { + double[][] localPoints = new double[points2.length + data.length][]; + navn[localPoints.length / 2 - 1] = name; + System.arraycopy(points2, 0, localPoints, 0, points2.length); + System.arraycopy(data, 0, localPoints, points2.length, data.length); + points2 = localPoints; + } + + /** {@inheritDoc} */ + @Override + public double[] get(String name) { + if (name.equals("dewT")) { + return points2[0]; } - - /** {@inheritDoc} */ - @Override - public String[][] getResultTable() { - return null; + if (name.equals("dewP")) { + return points2[1]; + } + if (name.equals("bubT")) { + return points2[2]; + } + if (name.equals("bubP")) { + return points2[3]; + } + if (name.equals("dewT2")) { + return points2[4]; + } + if (name.equals("dewP2")) { + return points2[5]; + } + if (name.equals("bubT2")) { + return points2[6]; + } + if (name.equals("bubP2")) { + return points2[7]; + } + if (name.equals("dewH")) { + return pointsH2[2]; + } + if (name.equals("dewDens")) { + return pointsV2[2]; + } + if (name.equals("dewS")) { + return pointsS2[2]; + } + if (name.equals("bubH")) { + return pointsH2[0]; + } + if (name.equals("bubDens")) { + return pointsV2[0]; + } + if (name.equals("bubS")) { + return pointsS2[0]; + } + if (name.equals("cricondentherm")) { + return cricondenTherm; + } + if (name.equals("cricondenbar")) { + return cricondenBar; + } + if (name.equals("criticalPoint1")) { + return new double[] {system.getTC(), system.getPC()}; + } + if (name.equals("criticalPoint2")) { + return new double[] {0, 0}; + } else { + return null; + } + } + + /** + * Getter for property bubblePointFirst. + * + * @return Value of property bubblePointFirst. + */ + public boolean isBubblePointFirst() { + return bubblePointFirst; + } + + /** + * Setter for property bubblePointFirst. + * + * @param bubblePointFirst New value of property bubblePointFirst. + */ + public void setBubblePointFirst(boolean bubblePointFirst) { + this.bubblePointFirst = bubblePointFirst; + } + + /** {@inheritDoc} */ + @Override + public String[][] getResultTable() { + return null; + } + + /** + *

+ * tempKWilson. + *

+ * + * @param beta a double + * @param P a double + * @return a double + */ + public double tempKWilson(double beta, double P) { + // Initiallizes the temperature of a saturation point for given pressure + // based on K values of Wilson + // see Michelsen book thermodynamics & computational aspects + + double initTc = 0.; + double initPc = 0.; + double initAc = 0.; + double Tstart = 0.; + double Tstartold = 0.; + double initT = 0; + double dinitT = 0; + int numberOfComponents = system.getPhase(0).getNumberOfComponents(); + int lc = 0; + int hc = 0; + + double[] Kwil = new double[numberOfComponents]; + + double min = 100000.; + double max = 0.; + + for (int i = 0; i < numberOfComponents; i++) { + if (system.getPhase(0).getComponents()[i].getTC() > max) { + max = system.getPhase(0).getComponents()[i].getTC(); + hc = i; + } + if (system.getPhase(0).getComponents()[i].getTC() < min) { + min = system.getPhase(0).getComponents()[i].getTC(); + lc = i; + } } - /** - *

- * tempKWilson. - *

- * - * @param beta a double - * @param P a double - * @return a double - */ - public double tempKWilson(double beta, double P) { - // Initiallizes the temperature of a saturation point for given pressure - // based on K values of Wilson - // see Michelsen book thermodynamics & computational aspects - - double initTc = 0.; - double initPc = 0.; - double initAc = 0.; - double Tstart = 0.; - double Tstartold = 0.; - double initT = 0; - double dinitT = 0; - int numberOfComponents = system.getPhase(0).getNumberOfComponents(); - int lc = 0; - int hc = 0; - - double[] Kwil = new double[numberOfComponents]; - - double min = 100000.; - double max = 0.; - - for (int i = 0; i < numberOfComponents; i++) { - if (system.getPhase(0).getComponents()[i].getTC() > max) { - max = system.getPhase(0).getComponents()[i].getTC(); - hc = i; - } - if (system.getPhase(0).getComponents()[i].getTC() < min) { - min = system.getPhase(0).getComponents()[i].getTC(); - lc = i; - } - } - - if (beta <= 0.5) { - initTc = system.getPhase(0).getComponents()[lc].getTC(); // closer to bubble point get - // the lightest - // component - initPc = system.getPhase(0).getComponents()[lc].getPC(); - initAc = system.getPhase(0).getComponents()[lc].getAcentricFactor(); - } else if (beta > 0.5) { - initTc = system.getPhase(0).getComponents()[hc].getTC(); // closer to dew point get the - // heaviest component - initPc = system.getPhase(0).getComponents()[hc].getPC(); - initAc = system.getPhase(0).getComponents()[hc].getAcentricFactor(); + if (beta <= 0.5) { + initTc = system.getPhase(0).getComponents()[lc].getTC(); // closer to bubble point get + // the lightest + // component + initPc = system.getPhase(0).getComponents()[lc].getPC(); + initAc = system.getPhase(0).getComponents()[lc].getAcentricFactor(); + } else if (beta > 0.5) { + initTc = system.getPhase(0).getComponents()[hc].getTC(); // closer to dew point get the + // heaviest component + initPc = system.getPhase(0).getComponents()[hc].getPC(); + initAc = system.getPhase(0).getComponents()[hc].getAcentricFactor(); + } + Tstart = initTc * 5.373 * (1 + initAc) / (5.373 * (1 + initAc) - Math.log(P / initPc)); // initial + // T + // based + // on + // the + // lighterst/heaviest + // component + + // solve for Tstart with Newton + for (int i = 0; i < 1000; i++) { + initT = 0.; + dinitT = 0.; + for (int j = 0; j < numberOfComponents; j++) { + Kwil[j] = system.getPhase(0).getComponents()[j].getPC() / P + * Math.exp(5.373 * (1. + system.getPhase(0).getComponents()[j].getAcentricFactor()) + * (1. - system.getPhase(0).getComponents()[j].getTC() / Tstart)); + system.getPhases()[0].getComponents()[j].setK(Math.log(Kwil[j])); + } + + for (int j = 0; j < numberOfComponents; j++) { + if (beta < 0.5) { + initT = initT + system.getPhase(0).getComponents()[j].getz() * Kwil[j]; + dinitT = dinitT + system.getPhase(0).getComponents()[j].getz() * Kwil[j] * 5.373 + * (1 + system.getPhase(0).getComponents()[j].getAcentricFactor()) + * system.getPhase(0).getComponents()[j].getTC() / (Tstart * Tstart); + } else { + initT = initT + system.getPhase(0).getComponents()[j].getz() / Kwil[j]; + dinitT = dinitT - system.getPhase(0).getComponents()[j].getz() / Kwil[j] * 5.373 + * (1 + system.getPhase(0).getComponents()[j].getAcentricFactor()) + * system.getPhase(0).getComponents()[j].getTC() / (Tstart * Tstart); } - Tstart = initTc * 5.373 * (1 + initAc) / (5.373 * (1 + initAc) - Math.log(P / initPc)); // initial - // T - // based - // on - // the - // lighterst/heaviest - // component - - // solve for Tstart with Newton - for (int i = 0; i < 1000; i++) { - initT = 0.; - dinitT = 0.; - for (int j = 0; j < numberOfComponents; j++) { - Kwil[j] = system.getPhase(0).getComponents()[j].getPC() / P - * Math.exp(5.373 - * (1. + system.getPhase(0).getComponents()[j].getAcentricFactor()) - * (1. - system.getPhase(0).getComponents()[j].getTC() / Tstart)); - system.getPhases()[0].getComponents()[j].setK(Math.log(Kwil[j])); - } + } - for (int j = 0; j < numberOfComponents; j++) { - if (beta < 0.5) { - initT = initT + system.getPhase(0).getComponents()[j].getz() * Kwil[j]; - dinitT = dinitT + system.getPhase(0).getComponents()[j].getz() * Kwil[j] * 5.373 - * (1 + system.getPhase(0).getComponents()[j].getAcentricFactor()) - * system.getPhase(0).getComponents()[j].getTC() / (Tstart * Tstart); - } else { - initT = initT + system.getPhase(0).getComponents()[j].getz() / Kwil[j]; - dinitT = dinitT - system.getPhase(0).getComponents()[j].getz() / Kwil[j] * 5.373 - * (1 + system.getPhase(0).getComponents()[j].getAcentricFactor()) - * system.getPhase(0).getComponents()[j].getTC() / (Tstart * Tstart); - } - } - - initT = initT - 1.; - if (Math.abs(initT / dinitT) > 0.1 * Tstart) { - Tstart = Tstart - 0.001 * initT / dinitT; - } else { - Tstart = Tstart - initT / dinitT; - } - - if (Math.abs(Tstart - Tstartold) < 1.e-5) { - return Tstart; - } - Tstartold = Tstart; - } + initT = initT - 1.; + if (Math.abs(initT / dinitT) > 0.1 * Tstart) { + Tstart = Tstart - 0.001 * initT / dinitT; + } else { + Tstart = Tstart - initT / dinitT; + } + if (Math.abs(Tstart - Tstartold) < 1.e-5) { return Tstart; + } + Tstartold = Tstart; } - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - DecimalFormat nf = new DecimalFormat(); - nf.setMaximumFractionDigits(1); - nf.applyPattern("####.#"); - - double TC = system.getTC(); - double PC = system.getPC(); - logger.info("tc : " + TC + " PC : " + PC); - String[] navn = {"bubble point", "dew point", "bubble point", "dew point"}; - String title = "PT-graph. TC=" + String.valueOf(nf.format(TC)) + "K, PC=" - + String.valueOf(nf.format(PC) + " bara"); - graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); - return graph2.getChart(); - } + return Tstart; + } + + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + DecimalFormat nf = new DecimalFormat(); + nf.setMaximumFractionDigits(1); + nf.applyPattern("####.#"); + + double TC = system.getTC(); + double PC = system.getPC(); + logger.info("tc : " + TC + " PC : " + PC); + String[] navn = {"bubble point", "dew point", "bubble point", "dew point"}; + String title = "PT-graph. TC=" + String.valueOf(nf.format(TC)) + "K, PC=" + + String.valueOf(nf.format(PC) + " bara"); + graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); + return graph2.getChart(); + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeNew.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeNew.java index 8bd63f78dc..2e882d5c3f 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeNew.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeNew.java @@ -21,393 +21,374 @@ * @version $Id: $Id */ public class pTphaseEnvelopeNew extends BaseOperation { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(pTphaseEnvelopeNew.class); - - graph2b graph2 = null; - SystemInterface system; - double[] cricondenTherm = new double[3]; - double[] cricondenBar = new double[3]; - double phaseFraction = 1e-10; - int i, j = 0, nummer = 0, iterations = 0, maxNumberOfIterations = 10000; - double lowPres = 1.0; - boolean outputToFile = false; - JProgressBar monitor; - JFrame mainFrame; - String fileName = "c:/file"; - JPanel mainPanel; - double temp = 0, pres = 0; - double[][] points = new double[2][]; - double[] pointsH = new double[10000]; - double[][] pointsH2 = new double[4][]; - double[] pointsV = new double[10000]; - - ; - double[][] pointsV2 = new double[4][]; - double[] pointsS = new double[10000]; - double[][] pointsS2 = new double[4][]; - public double[][] points2 = new double[4][]; - int np = 0; - int speceq = 0; - - /** - *

- * Constructor for pTphaseEnvelopeNew. - *

- */ - public pTphaseEnvelopeNew() {} - - /** - *

- * Constructor for pTphaseEnvelopeNew. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param name a {@link java.lang.String} object - * @param phaseFraction a double - * @param lowPres a double - */ - public pTphaseEnvelopeNew(SystemInterface system, String name, double phaseFraction, - double lowPres) { - this.system = system; - this.phaseFraction = phaseFraction; - - this.lowPres = lowPres; - - if (name != null) { - outputToFile = true; - fileName = name; - } - mainFrame = new JFrame("Progress Bar"); - mainPanel = new JPanel(); - mainPanel.setSize(200, 100); - mainFrame.getContentPane().setLayout(new FlowLayout()); - mainPanel.setLayout(new FlowLayout()); - mainFrame.setSize(200, 100); - monitor = new JProgressBar(0, 00); - monitor.setSize(200, 100); - monitor.setStringPainted(true); - mainPanel.add(monitor); - mainFrame.getContentPane().add(mainPanel); - mainFrame.setVisible(true); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(pTphaseEnvelopeNew.class); + + graph2b graph2 = null; + SystemInterface system; + double[] cricondenTherm = new double[3]; + double[] cricondenBar = new double[3]; + double phaseFraction = 1e-10; + int i, j = 0, nummer = 0, iterations = 0, maxNumberOfIterations = 10000; + double lowPres = 1.0; + boolean outputToFile = false; + JProgressBar monitor; + JFrame mainFrame; + String fileName = "c:/file"; + JPanel mainPanel; + double temp = 0, pres = 0; + double[][] points = new double[2][]; + double[] pointsH = new double[10000]; + double[][] pointsH2 = new double[4][]; + double[] pointsV = new double[10000]; + + ; + double[][] pointsV2 = new double[4][]; + double[] pointsS = new double[10000]; + double[][] pointsS2 = new double[4][]; + public double[][] points2 = new double[4][]; + int np = 0; + int speceq = 0; + + /** + *

+ * Constructor for pTphaseEnvelopeNew. + *

+ */ + public pTphaseEnvelopeNew() {} + + /** + *

+ * Constructor for pTphaseEnvelopeNew. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param name a {@link java.lang.String} object + * @param phaseFraction a double + * @param lowPres a double + */ + public pTphaseEnvelopeNew(SystemInterface system, String name, double phaseFraction, + double lowPres) { + this.system = system; + this.phaseFraction = phaseFraction; + + this.lowPres = lowPres; + + if (name != null) { + outputToFile = true; + fileName = name; } - - /** {@inheritDoc} */ - @Override - public void run() { - try { - points[0] = new double[10000]; - points[1] = new double[10000]; - - system.setPressure(lowPres); - - ThermodynamicOperations testOps = new ThermodynamicOperations(system); - - try { - testOps.bubblePointTemperatureFlash(); - } catch (Exception e) { - e.toString(); - return; - } - logger.info("temperature bubT = " + system.getTemperature()); - - sysNewtonRhapsonPhaseEnvelope2 nonLinSolver = - new sysNewtonRhapsonPhaseEnvelope2(system); - nonLinSolver.solve(1); - nonLinSolver.calcInc(1); - - for (np = 1; np < 5; np++) { - if (np % 5 == 0) { - monitor.setValue(np); - monitor.setString("Calculated points: " + np); - } - - nonLinSolver.calcInc(np); - nonLinSolver.solve(np); - - if (system.getTemperature() > cricondenTherm[0]) { - cricondenTherm[1] = system.getPressure(); - cricondenTherm[0] = system.getTemperature(); - } - if (system.getPressure() > cricondenBar[1]) { - cricondenBar[0] = system.getTemperature(); - cricondenBar[1] = system.getPressure(); - } - - if (Double.isNaN(system.getTemperature()) - || Double.isNaN(system.getTemperature())) {// || - // system.getPressure() - // < lowPres) { - points[0][np - 1] = points[0][np - 3]; - points[1][np - 1] = points[1][np - 3]; - pointsH[np - 1] = pointsH[np - 3]; - pointsV[np - 1] = pointsV[np - 3]; - pointsS[np - 1] = pointsS[np - 3]; - - // logger.info("avbryter" + np); - break; - } - // logger.info("Ideal pres: " + getPressure()); - // logger.info("temp: " + system.getTemperature()); - points[0][np - 1] = system.getTemperature(); - points[1][np - 1] = system.getPressure(); - pointsH[np - 1] = system.getPhase(1).getEnthalpy() - / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - pointsV[np - 1] = system.getPhase(1).getDensity(); - pointsS[np - 1] = system.getPhase(1).getEntropy() - / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - } - - int ncr = nonLinSolver.getNpCrit(); - int ncr2 = np - ncr; - - logger.info("ncr: " + ncr + " ncr2 . " + ncr2); - points2[0] = new double[ncr + 1]; - points2[1] = new double[ncr + 1]; - pointsH2[0] = new double[ncr + 1]; - pointsH2[1] = new double[ncr + 1]; - pointsS2[0] = new double[ncr + 1]; - pointsS2[1] = new double[ncr + 1]; - pointsV2[0] = new double[ncr + 1]; - pointsV2[1] = new double[ncr + 1]; - if (ncr2 > 2) { - points2[2] = new double[ncr2 - 2]; - points2[3] = new double[ncr2 - 2]; - pointsH2[2] = new double[ncr2 - 2]; - pointsH2[3] = new double[ncr2 - 2]; - pointsV2[2] = new double[ncr2 - 2]; - pointsV2[3] = new double[ncr2 - 2]; - pointsS2[2] = new double[ncr2 - 2]; - pointsS2[3] = new double[ncr2 - 2]; - } else { - points2[2] = new double[0]; - points2[3] = new double[0]; - pointsH2[2] = new double[0]; - pointsH2[3] = new double[0]; - pointsV2[2] = new double[0]; - pointsV2[3] = new double[0]; - pointsS2[2] = new double[0]; - pointsS2[3] = new double[0]; - } - - for (int i = 0; i < ncr; i++) { - points2[0][i] = points[0][i]; - points2[1][i] = points[1][i]; - - pointsH2[1][i] = points[1][i]; - pointsH2[0][i] = pointsH[i]; - - pointsS2[1][i] = points[1][i]; - pointsS2[0][i] = pointsS[i]; - - pointsV2[1][i] = points[1][i]; - pointsV2[0][i] = pointsV[i]; - } - - system.setTemperature(system.getTC() + 0.001); - system.setPressure(system.getPC() + 0.001); - system.init(3); - - points2[0][ncr] = system.getTC(); - points2[1][ncr] = system.getPC(); - - pointsH2[1][ncr] = system.getPC(); - pointsH2[0][ncr] = - system.getPhase(1).getEnthalpy() / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - - pointsS2[1][ncr] = system.getPC(); - pointsS2[0][ncr] = - system.getPhase(1).getEntropy() / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - - pointsV2[1][ncr] = system.getPC(); - pointsV2[0][ncr] = system.getPhase(1).getDensity(); - - if (ncr2 > 2) { - points2[2][0] = system.getTC(); - points2[3][0] = system.getPC(); - pointsH2[3][0] = system.getPC(); - pointsH2[2][0] = system.getPhase(1).getEnthalpy() - / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - pointsS2[3][0] = system.getPC(); - pointsS2[2][0] = system.getPhase(1).getEntropy() - / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - pointsV2[3][0] = system.getPC(); - pointsV2[2][0] = system.getPhase(1).getDensity(); - - for (int i = 1; i < (ncr2 - 2); i++) { - points2[2][i] = points[0][i + ncr - 1]; - points2[3][i] = points[1][i + ncr - 1]; - - pointsH2[3][i] = points[1][i + ncr - 1]; - pointsH2[2][i] = pointsH[i + ncr - 1]; - - pointsS2[3][i] = points[1][i + ncr - 1]; - pointsS2[2][i] = pointsS[i + ncr - 1]; - - pointsV2[3][i] = points[1][i + ncr - 1]; - pointsV2[2][i] = pointsV[i + ncr - 1]; - } - } - // monitor.close(); - mainFrame.setVisible(false); -/* - if (outputToFile) { - String name1 = new String(); - name1 = fileName + "Dew.nc"; - file1 = new neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); - file1.setOutputFileName(name1); - file1.setXvalues(points2[2], "temp", "sec"); - file1.setYvalues(points2[3], "pres", "meter"); - file1.createFile(); - - String name2 = new String(); - name2 = fileName + "Bub.nc"; - file2 = new neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); - file2.setOutputFileName(name2); - file2.setXvalues(points2[0], "temp", "sec"); - file2.setYvalues(points2[1], "pres", "meter"); - file2.createFile(); - } - */ - } catch (Exception e) { - logger.error("error", e); + mainFrame = new JFrame("Progress Bar"); + mainPanel = new JPanel(); + mainPanel.setSize(200, 100); + mainFrame.getContentPane().setLayout(new FlowLayout()); + mainPanel.setLayout(new FlowLayout()); + mainFrame.setSize(200, 100); + monitor = new JProgressBar(0, 00); + monitor.setSize(200, 100); + monitor.setStringPainted(true); + mainPanel.add(monitor); + mainFrame.getContentPane().add(mainPanel); + mainFrame.setVisible(true); + } + + /** {@inheritDoc} */ + @Override + public void run() { + try { + points[0] = new double[10000]; + points[1] = new double[10000]; + + system.setPressure(lowPres); + + ThermodynamicOperations testOps = new ThermodynamicOperations(system); + + try { + testOps.bubblePointTemperatureFlash(); + } catch (Exception e) { + e.toString(); + return; + } + logger.info("temperature bubT = " + system.getTemperature()); + + sysNewtonRhapsonPhaseEnvelope2 nonLinSolver = new sysNewtonRhapsonPhaseEnvelope2(system); + nonLinSolver.solve(1); + nonLinSolver.calcInc(1); + + for (np = 1; np < 5; np++) { + if (np % 5 == 0) { + monitor.setValue(np); + monitor.setString("Calculated points: " + np); } - } - /** {@inheritDoc} */ - @Override - public void displayResult() { - DecimalFormat nf = new DecimalFormat(); - nf.setMaximumFractionDigits(1); - nf.applyPattern("####.#"); - - double TC = system.getTC(); - double PC = system.getPC(); - logger.info("tc : " + TC + " PC : " + PC); - String[] navn = {"bubble point", "dew point", "bubble point", "dew point"}; - String title = "PT-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - String title3 = "PH-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - String title4 = "Density-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - String title5 = "PS-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - - // logger.info("start flash"); - // logger.info("Tferdig.."); - - graph2b graph3 = new graph2b(pointsH2, navn, title3, "Enthalpy [kJ/kg]", "Pressure [bara]"); - graph3.setVisible(true); - graph3.saveFigure((neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig4.png")); - - graph2b graph4 = new graph2b(pointsV2, navn, title4, "Density [kg/m^3]", "Pressure [bara]"); - graph4.setVisible(true); - graph4.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig2.png"); - - graph2b graph5 = - new graph2b(pointsS2, navn, title5, "Entropy [kJ/kg*K]", "Pressure [bara]"); - graph5.setVisible(true); - graph5.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig3.png"); - - graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); - graph2.setVisible(true); - graph2.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig1.png"); - - /* - * JDialog dialog = new JDialog(); Container dialogContentPane = dialog.getContentPane(); - * dialogContentPane.setLayout(new FlowLayout()); JFreeChartPanel chartPanel = - * graph4.getChartPanel(); dialogContentPane.add(chartPanel); dialog.show(); - */ - } + nonLinSolver.calcInc(np); + nonLinSolver.solve(np); - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} - - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - DecimalFormat nf = new DecimalFormat(); - nf.setMaximumFractionDigits(1); - nf.applyPattern("####.#"); - - double TC = system.getTC(); - double PC = system.getPC(); - logger.info("tc : " + TC + " PC : " + PC); - String[] navn = {"bubble point", "dew point", "bubble point", "dew point"}; - String title = "PT-graph. TC=" + String.valueOf(nf.format(TC)) + "K, PC=" - + String.valueOf(nf.format(PC) + " bara"); - graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); - return graph2.getChart(); - } - - /** {@inheritDoc} */ - @Override - public double[][] getPoints(int i) { - return points2; - } - - /** {@inheritDoc} */ - @Override - public double[] get(String name) { - if (name.equals("bubT")) { - return points2[0]; - } - if (name.equals("bubP")) { - return points2[1]; - } - if (name.equals("dewT")) { - return points2[2]; - } - if (name.equals("dewP")) { - return points2[3]; - } - if (name.equals("dewH")) { - return pointsH2[2]; - } - if (name.equals("dewDens")) { - return pointsV2[2]; + if (system.getTemperature() > cricondenTherm[0]) { + cricondenTherm[1] = system.getPressure(); + cricondenTherm[0] = system.getTemperature(); } - if (name.equals("dewS")) { - return pointsS2[2]; + if (system.getPressure() > cricondenBar[1]) { + cricondenBar[0] = system.getTemperature(); + cricondenBar[1] = system.getPressure(); } - if (name.equals("bubH")) { - return pointsH2[0]; - } - if (name.equals("bubDens")) { - return pointsV2[0]; - } - if (name.equals("bubS")) { - return pointsS2[0]; - } - if (name.equals("cricondentherm")) { - return cricondenTherm; + + if (Double.isNaN(system.getTemperature()) || Double.isNaN(system.getTemperature())) {// || + // system.getPressure() + // < + // lowPres) + // { + points[0][np - 1] = points[0][np - 3]; + points[1][np - 1] = points[1][np - 3]; + pointsH[np - 1] = pointsH[np - 3]; + pointsV[np - 1] = pointsV[np - 3]; + pointsS[np - 1] = pointsS[np - 3]; + + // logger.info("avbryter" + np); + break; } - if (name.equals("cricondenbar")) { - return cricondenBar; - } else { - return null; + // logger.info("Ideal pres: " + getPressure()); + // logger.info("temp: " + system.getTemperature()); + points[0][np - 1] = system.getTemperature(); + points[1][np - 1] = system.getPressure(); + pointsH[np - 1] = + system.getPhase(1).getEnthalpy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3; + pointsV[np - 1] = system.getPhase(1).getDensity(); + pointsS[np - 1] = + system.getPhase(1).getEntropy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3; + } + + int ncr = nonLinSolver.getNpCrit(); + int ncr2 = np - ncr; + + logger.info("ncr: " + ncr + " ncr2 . " + ncr2); + points2[0] = new double[ncr + 1]; + points2[1] = new double[ncr + 1]; + pointsH2[0] = new double[ncr + 1]; + pointsH2[1] = new double[ncr + 1]; + pointsS2[0] = new double[ncr + 1]; + pointsS2[1] = new double[ncr + 1]; + pointsV2[0] = new double[ncr + 1]; + pointsV2[1] = new double[ncr + 1]; + if (ncr2 > 2) { + points2[2] = new double[ncr2 - 2]; + points2[3] = new double[ncr2 - 2]; + pointsH2[2] = new double[ncr2 - 2]; + pointsH2[3] = new double[ncr2 - 2]; + pointsV2[2] = new double[ncr2 - 2]; + pointsV2[3] = new double[ncr2 - 2]; + pointsS2[2] = new double[ncr2 - 2]; + pointsS2[3] = new double[ncr2 - 2]; + } else { + points2[2] = new double[0]; + points2[3] = new double[0]; + pointsH2[2] = new double[0]; + pointsH2[3] = new double[0]; + pointsV2[2] = new double[0]; + pointsV2[3] = new double[0]; + pointsS2[2] = new double[0]; + pointsS2[3] = new double[0]; + } + + for (int i = 0; i < ncr; i++) { + points2[0][i] = points[0][i]; + points2[1][i] = points[1][i]; + + pointsH2[1][i] = points[1][i]; + pointsH2[0][i] = pointsH[i]; + + pointsS2[1][i] = points[1][i]; + pointsS2[0][i] = pointsS[i]; + + pointsV2[1][i] = points[1][i]; + pointsV2[0][i] = pointsV[i]; + } + + system.setTemperature(system.getTC() + 0.001); + system.setPressure(system.getPC() + 0.001); + system.init(3); + + points2[0][ncr] = system.getTC(); + points2[1][ncr] = system.getPC(); + + pointsH2[1][ncr] = system.getPC(); + pointsH2[0][ncr] = system.getPhase(1).getEnthalpy() + / system.getPhase(1).getNumberOfMolesInPhase() / system.getPhase(1).getMolarMass() / 1e3; + + pointsS2[1][ncr] = system.getPC(); + pointsS2[0][ncr] = system.getPhase(1).getEntropy() + / system.getPhase(1).getNumberOfMolesInPhase() / system.getPhase(1).getMolarMass() / 1e3; + + pointsV2[1][ncr] = system.getPC(); + pointsV2[0][ncr] = system.getPhase(1).getDensity(); + + if (ncr2 > 2) { + points2[2][0] = system.getTC(); + points2[3][0] = system.getPC(); + pointsH2[3][0] = system.getPC(); + pointsH2[2][0] = + system.getPhase(1).getEnthalpy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3; + pointsS2[3][0] = system.getPC(); + pointsS2[2][0] = + system.getPhase(1).getEntropy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3; + pointsV2[3][0] = system.getPC(); + pointsV2[2][0] = system.getPhase(1).getDensity(); + + for (int i = 1; i < (ncr2 - 2); i++) { + points2[2][i] = points[0][i + ncr - 1]; + points2[3][i] = points[1][i + ncr - 1]; + + pointsH2[3][i] = points[1][i + ncr - 1]; + pointsH2[2][i] = pointsH[i + ncr - 1]; + + pointsS2[3][i] = points[1][i + ncr - 1]; + pointsS2[2][i] = pointsS[i + ncr - 1]; + + pointsV2[3][i] = points[1][i + ncr - 1]; + pointsV2[2][i] = pointsV[i + ncr - 1]; } + } + // monitor.close(); + mainFrame.setVisible(false); + /* + * if (outputToFile) { String name1 = new String(); name1 = fileName + "Dew.nc"; file1 = new + * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); + * file1.setOutputFileName(name1); file1.setXvalues(points2[2], "temp", "sec"); + * file1.setYvalues(points2[3], "pres", "meter"); file1.createFile(); + * + * String name2 = new String(); name2 = fileName + "Bub.nc"; file2 = new + * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); + * file2.setOutputFileName(name2); file2.setXvalues(points2[0], "temp", "sec"); + * file2.setYvalues(points2[1], "pres", "meter"); file2.createFile(); } + */ + } catch (Exception e) { + logger.error("error", e); } + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + DecimalFormat nf = new DecimalFormat(); + nf.setMaximumFractionDigits(1); + nf.applyPattern("####.#"); + + double TC = system.getTC(); + double PC = system.getPC(); + logger.info("tc : " + TC + " PC : " + PC); + String[] navn = {"bubble point", "dew point", "bubble point", "dew point"}; + String title = + "PT-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + String.valueOf(nf.format(PC)); + String title3 = + "PH-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + String.valueOf(nf.format(PC)); + String title4 = "Density-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + + String.valueOf(nf.format(PC)); + String title5 = + "PS-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + String.valueOf(nf.format(PC)); + + // logger.info("start flash"); + // logger.info("Tferdig.."); + + graph2b graph3 = new graph2b(pointsH2, navn, title3, "Enthalpy [kJ/kg]", "Pressure [bara]"); + graph3.setVisible(true); + graph3.saveFigure((neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig4.png")); + + graph2b graph4 = new graph2b(pointsV2, navn, title4, "Density [kg/m^3]", "Pressure [bara]"); + graph4.setVisible(true); + graph4.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig2.png"); + + graph2b graph5 = new graph2b(pointsS2, navn, title5, "Entropy [kJ/kg*K]", "Pressure [bara]"); + graph5.setVisible(true); + graph5.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig3.png"); + + graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); + graph2.setVisible(true); + graph2.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig1.png"); - /** {@inheritDoc} */ /* - @Override - public void createNetCdfFile(String name) { - fileName = name; + * JDialog dialog = new JDialog(); Container dialogContentPane = dialog.getContentPane(); + * dialogContentPane.setLayout(new FlowLayout()); JFreeChartPanel chartPanel = + * graph4.getChartPanel(); dialogContentPane.add(chartPanel); dialog.show(); + */ + } + + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} + + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + DecimalFormat nf = new DecimalFormat(); + nf.setMaximumFractionDigits(1); + nf.applyPattern("####.#"); + + double TC = system.getTC(); + double PC = system.getPC(); + logger.info("tc : " + TC + " PC : " + PC); + String[] navn = {"bubble point", "dew point", "bubble point", "dew point"}; + String title = "PT-graph. TC=" + String.valueOf(nf.format(TC)) + "K, PC=" + + String.valueOf(nf.format(PC) + " bara"); + graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); + return graph2.getChart(); + } + + /** {@inheritDoc} */ + @Override + public double[][] getPoints(int i) { + return points2; + } + + /** {@inheritDoc} */ + @Override + public double[] get(String name) { + if (name.equals("bubT")) { + return points2[0]; } - */ - - /** {@inheritDoc} */ - @Override - public String[][] getResultTable() { - return null; + if (name.equals("bubP")) { + return points2[1]; + } + if (name.equals("dewT")) { + return points2[2]; + } + if (name.equals("dewP")) { + return points2[3]; + } + if (name.equals("dewH")) { + return pointsH2[2]; } + if (name.equals("dewDens")) { + return pointsV2[2]; + } + if (name.equals("dewS")) { + return pointsS2[2]; + } + if (name.equals("bubH")) { + return pointsH2[0]; + } + if (name.equals("bubDens")) { + return pointsV2[0]; + } + if (name.equals("bubS")) { + return pointsS2[0]; + } + if (name.equals("cricondentherm")) { + return cricondenTherm; + } + if (name.equals("cricondenbar")) { + return cricondenBar; + } else { + return null; + } + } + + /** {@inheritDoc} */ + @Override + public String[][] getResultTable() { + return null; + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/reactiveCurves/pLoadingCurve2.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/reactiveCurves/pLoadingCurve2.java index 5990112903..aa2372274b 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/reactiveCurves/pLoadingCurve2.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/reactiveCurves/pLoadingCurve2.java @@ -21,182 +21,173 @@ * @version $Id: $Id */ public class pLoadingCurve2 extends BaseOperation { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(pLoadingCurve2.class); - - SystemInterface system; - int i, j = 0, nummer = 0, iterations = 0, maxNumberOfIterations = 10000; - double gibbsEnergy = 0, gibbsEnergyOld = 0; - double Kold, deviation = 0, g0 = 0, g1 = 0; - double lnOldOldK[], lnK[]; - double lnOldK[]; - double oldDeltalnK[], deltalnK[]; - double tm[] = {1, 1}; - double beta = 1e-5; - int lowestGibbsEnergyPhase = 0; // lowestGibbsEnergyPhase - JProgressBar monitor; - JFrame mainFrame; - JPanel mainPanel; - - double temp = 0, pres = 0, startPres = 0; - double[][] points = new double[35][]; - - boolean moreLines = false; - int np = 0; - // points[2] = new double[1000]; - int speceq = 0; - - /** - *

- * Constructor for pLoadingCurve2. - *

- */ - public pLoadingCurve2() {} - - /** - *

- * Constructor for pLoadingCurve2. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public pLoadingCurve2(SystemInterface system) { - this.system = system; - lnOldOldK = new double[system.getPhases()[0].getNumberOfComponents()]; - lnOldK = new double[system.getPhases()[0].getNumberOfComponents()]; - lnK = new double[system.getPhases()[0].getNumberOfComponents()]; - oldDeltalnK = new double[system.getPhases()[0].getNumberOfComponents()]; - deltalnK = new double[system.getPhases()[0].getNumberOfComponents()]; - mainFrame = new JFrame("Progress Bar"); - mainPanel = new JPanel(); - mainPanel.setSize(200, 100); - mainFrame.getContentPane().setLayout(new FlowLayout()); - mainPanel.setLayout(new FlowLayout()); - mainFrame.setSize(200, 100); - monitor = new JProgressBar(0, 1000); - monitor.setSize(200, 100); - monitor.setStringPainted(true); - mainPanel.add(monitor); - mainFrame.getContentPane().add(mainPanel); - mainFrame.setVisible(true); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(pLoadingCurve2.class); + + SystemInterface system; + int i, j = 0, nummer = 0, iterations = 0, maxNumberOfIterations = 10000; + double gibbsEnergy = 0, gibbsEnergyOld = 0; + double Kold, deviation = 0, g0 = 0, g1 = 0; + double lnOldOldK[], lnK[]; + double lnOldK[]; + double oldDeltalnK[], deltalnK[]; + double tm[] = {1, 1}; + double beta = 1e-5; + int lowestGibbsEnergyPhase = 0; // lowestGibbsEnergyPhase + JProgressBar monitor; + JFrame mainFrame; + JPanel mainPanel; + + double temp = 0, pres = 0, startPres = 0; + double[][] points = new double[35][]; + + boolean moreLines = false; + int np = 0; + // points[2] = new double[1000]; + int speceq = 0; + + /** + *

+ * Constructor for pLoadingCurve2. + *

+ */ + public pLoadingCurve2() {} + + /** + *

+ * Constructor for pLoadingCurve2. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public pLoadingCurve2(SystemInterface system) { + this.system = system; + lnOldOldK = new double[system.getPhases()[0].getNumberOfComponents()]; + lnOldK = new double[system.getPhases()[0].getNumberOfComponents()]; + lnK = new double[system.getPhases()[0].getNumberOfComponents()]; + oldDeltalnK = new double[system.getPhases()[0].getNumberOfComponents()]; + deltalnK = new double[system.getPhases()[0].getNumberOfComponents()]; + mainFrame = new JFrame("Progress Bar"); + mainPanel = new JPanel(); + mainPanel.setSize(200, 100); + mainFrame.getContentPane().setLayout(new FlowLayout()); + mainPanel.setLayout(new FlowLayout()); + mainFrame.setSize(200, 100); + monitor = new JProgressBar(0, 1000); + monitor.setSize(200, 100); + monitor.setStringPainted(true); + mainPanel.add(monitor); + mainFrame.getContentPane().add(mainPanel); + mainFrame.setVisible(true); + } + + /** {@inheritDoc} */ + @Override + public void run() { + int numbPoints = 50; + double inscr = 0.2103842275; + points[0] = new double[numbPoints]; + points[1] = new double[numbPoints]; + points[2] = new double[numbPoints]; + ThermodynamicOperations testOps = new ThermodynamicOperations(system); + + for (int k = 0; k < system.getPhases()[1].getNumberOfComponents(); k++) { + points[k + 3] = new double[numbPoints]; + points[k + 3 + system.getPhases()[1].getNumberOfComponents()] = new double[numbPoints]; } - /** {@inheritDoc} */ - @Override - public void run() { - int numbPoints = 50; - double inscr = 0.2103842275; - points[0] = new double[numbPoints]; - points[1] = new double[numbPoints]; - points[2] = new double[numbPoints]; - ThermodynamicOperations testOps = new ThermodynamicOperations(system); - - for (int k = 0; k < system.getPhases()[1].getNumberOfComponents(); k++) { - points[k + 3] = new double[numbPoints]; - points[k + 3 + system.getPhases()[1].getNumberOfComponents()] = new double[numbPoints]; - } - - double molMDEA = system.getPhases()[1].getComponents()[2].getNumberOfMolesInPhase(); - system.getChemicalReactionOperations().solveChemEq(1); - - for (int i = 1; i < points[0].length; i++) { - system.initBeta(); - system.init_x_y(); - try { - testOps.bubblePointPressureFlash(false); - } catch (Exception e) { - logger.info(e.toString()); - } - logger.info("beta " + system.getBeta()); - points[0][i] = (inscr * (i - 1)) / molMDEA; - points[1][i] = (system.getPressure()); - points[2][i] = (system.getPressure() * system.getPhase(0).getComponent(0).getx()); - - for (int k = 0; k < system.getPhases()[1].getNumberOfComponents(); k++) { - points[k + 3][i] = system.getPhases()[1].getComponents()[k].getx(); - points[k + 3 + system.getPhases()[1].getNumberOfComponents()][i] = - system.getPhase(1).getActivityCoefficient(k, 1);// ,1); - } - logger.info("point: " + points[0][i] + " tot pres " + points[1][i] + " CO2 pres " - + points[2][i]); - system.setPressure(points[1][i]); - logger.info("ph: " + system.getPhases()[1].getpH()); - system.addComponent("CO2", inscr); - } - mainFrame.setVisible(false); - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - DecimalFormat nf = new DecimalFormat(); - nf.setMaximumFractionDigits(1); - nf.applyPattern("####.#"); - - double TC = system.getTC(); - double PC = system.getPC(); - logger.info("tc : " + TC + " PC : " + PC); - String[] navn = {"CO2 fugacity", "", "", ""}; - String title = "CO2 vapour pressure"; - - graph2b graph2 = new graph2b(points, navn, title, "loading [-]", "Fugacity CO2 [bar]"); - graph2.setVisible(true); - } - - /** {@inheritDoc} */ - @Override - public void printToFile(String name) { - neqsim.dataPresentation.dataHandeling printDat = - new neqsim.dataPresentation.dataHandeling(); - printDat.printToFile(points, name); - } - - /** {@inheritDoc} */ - @Override - public double[][] getPoints(int i) { - return points; - } - - /** {@inheritDoc} */ - /* - @Override - public void createNetCdfFile(String name) { - NetCdf2D file = new NetCdf2D(); - file.setOutputFileName(name); - file.setXvalues(points[0], "loading", ""); - file.setYvalues(points[1], "total pressure", ""); - file.setYvalues(points[2], " CO2 pressure", ""); - for (int k = 0; k < system.getPhases()[1].getNumberOfComponents(); k++) { - file.setYvalues(points[k + 3], - "mol frac " + system.getPhases()[1].getComponents()[k].getComponentName(), ""); - file.setYvalues(points[k + 3 + system.getPhases()[1].getNumberOfComponents()], - ("activity " + system.getPhases()[1].getComponents()[k].getComponentName()), - ""); - } - file.createFile(); - } -*/ - /** {@inheritDoc} */ - @Override - public double[] get(String name) { - return null; - } - - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - return null; - } - - /** {@inheritDoc} */ - @Override - public String[][] getResultTable() { - return null; - } - - /** {@inheritDoc} */ - @Override - public SystemInterface getThermoSystem() { - return system; + double molMDEA = system.getPhases()[1].getComponents()[2].getNumberOfMolesInPhase(); + system.getChemicalReactionOperations().solveChemEq(1); + + for (int i = 1; i < points[0].length; i++) { + system.initBeta(); + system.init_x_y(); + try { + testOps.bubblePointPressureFlash(false); + } catch (Exception e) { + logger.info(e.toString()); + } + logger.info("beta " + system.getBeta()); + points[0][i] = (inscr * (i - 1)) / molMDEA; + points[1][i] = (system.getPressure()); + points[2][i] = (system.getPressure() * system.getPhase(0).getComponent(0).getx()); + + for (int k = 0; k < system.getPhases()[1].getNumberOfComponents(); k++) { + points[k + 3][i] = system.getPhases()[1].getComponents()[k].getx(); + points[k + 3 + system.getPhases()[1].getNumberOfComponents()][i] = + system.getPhase(1).getActivityCoefficient(k, 1);// ,1); + } + logger.info( + "point: " + points[0][i] + " tot pres " + points[1][i] + " CO2 pres " + points[2][i]); + system.setPressure(points[1][i]); + logger.info("ph: " + system.getPhases()[1].getpH()); + system.addComponent("CO2", inscr); } + mainFrame.setVisible(false); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + DecimalFormat nf = new DecimalFormat(); + nf.setMaximumFractionDigits(1); + nf.applyPattern("####.#"); + + double TC = system.getTC(); + double PC = system.getPC(); + logger.info("tc : " + TC + " PC : " + PC); + String[] navn = {"CO2 fugacity", "", "", ""}; + String title = "CO2 vapour pressure"; + + graph2b graph2 = new graph2b(points, navn, title, "loading [-]", "Fugacity CO2 [bar]"); + graph2.setVisible(true); + } + + /** {@inheritDoc} */ + @Override + public void printToFile(String name) { + neqsim.dataPresentation.dataHandeling printDat = new neqsim.dataPresentation.dataHandeling(); + printDat.printToFile(points, name); + } + + /** {@inheritDoc} */ + @Override + public double[][] getPoints(int i) { + return points; + } + + /* + * public void createNetCdfFile(String name) { NetCdf2D file = new NetCdf2D(); + * file.setOutputFileName(name); file.setXvalues(points[0], "loading", ""); + * file.setYvalues(points[1], "total pressure", ""); file.setYvalues(points[2], " CO2 pressure", + * ""); for (int k = 0; k < system.getPhases()[1].getNumberOfComponents(); k++) { + * file.setYvalues(points[k + 3], "mol frac " + + * system.getPhases()[1].getComponents()[k].getComponentName(), ""); file.setYvalues(points[k + 3 + * + system.getPhases()[1].getNumberOfComponents()], ("activity " + + * system.getPhases()[1].getComponents()[k].getComponentName()), ""); } file.createFile(); } + */ + + /** {@inheritDoc} */ + @Override + public double[] get(String name) { + return null; + } + + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + return null; + } + + /** {@inheritDoc} */ + @Override + public String[][] getResultTable() { + return null; + } + + /** {@inheritDoc} */ + @Override + public SystemInterface getThermoSystem() { + return system; + } } diff --git a/src/test/java/neqsim/fluidMechanics/flowSystem/onePhaseFlowSystem/pipeFlowSystem/PipeFlowSystemTest.java b/src/test/java/neqsim/fluidMechanics/flowSystem/onePhaseFlowSystem/pipeFlowSystem/PipeFlowSystemTest.java index 3fff720421..c5750fb974 100644 --- a/src/test/java/neqsim/fluidMechanics/flowSystem/onePhaseFlowSystem/pipeFlowSystem/PipeFlowSystemTest.java +++ b/src/test/java/neqsim/fluidMechanics/flowSystem/onePhaseFlowSystem/pipeFlowSystem/PipeFlowSystemTest.java @@ -72,7 +72,7 @@ void testSolveSteadyStateConstantFrictionFactor() { pipe.getNode(i).setWallFrictionFactor(0, 0.00725); } pipe.solveSteadyState(10); - //System.out.println("pressure out set friction " + // System.out.println("pressure out set friction " } @Test @@ -80,12 +80,12 @@ void testSolveSteadyState() { testInit(); pipe.solveSteadyState(10); for (int i = 0; i < pipe.getFlowNodes().length; i++) { - //System.out.println("wall friction " + pipe.getNode(i).getWallFrictionFactor(0)); + // System.out.println("wall friction " + pipe.getNode(i).getWallFrictionFactor(0)); } - // System.out.println("pressure out calc friction " - // + pipe.getNode(pipe.getFlowNodes().length - 1).getBulkSystem().getPressure() + " bara"); - + // System.out.println("pressure out calc friction " + // + pipe.getNode(pipe.getFlowNodes().length - 1).getBulkSystem().getPressure() + " bara"); + // pipe.print(); } @@ -126,7 +126,6 @@ void testSolveTransient() { // pipe.getDisplay().displayResult("composition"); // pipe.getDisplay().displayResult("pressure"); // pipe.getDisplay().displayResult("composition"); - // pipe.getDisplay().createNetCdfFile("c:/temp5.nc"); // pipe.getDisplay(1).displayResult(); } } diff --git a/src/test/java/neqsim/thermo/util/example/PressureLoadingCurve.java b/src/test/java/neqsim/thermo/util/example/PressureLoadingCurve.java index 9488fab173..f59e5e74c5 100644 --- a/src/test/java/neqsim/thermo/util/example/PressureLoadingCurve.java +++ b/src/test/java/neqsim/thermo/util/example/PressureLoadingCurve.java @@ -7,68 +7,68 @@ import neqsim.thermodynamicOperations.ThermodynamicOperations; /** - *

PressureLoadingCurve class.

+ *

+ * PressureLoadingCurve class. + *

* * @author asmund * @version $Id: $Id * @since 2.2.3 */ public class PressureLoadingCurve { - static Logger logger = LogManager.getLogger(PressureLoadingCurve.class); + static Logger logger = LogManager.getLogger(PressureLoadingCurve.class); - /** - * This method is just meant to test the thermo package. - * - * @param args an array of {@link java.lang.String} objects - */ - @SuppressWarnings("unused") - public static void main(String args[]) { - double[][] points; - SystemInterface testSystem = new SystemFurstElectrolyteEos((273.15 + 75.0), 1.3); + /** + * This method is just meant to test the thermo package. + * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String args[]) { + double[][] points; + SystemInterface testSystem = new SystemFurstElectrolyteEos((273.15 + 75.0), 1.3); - double loading = 0.65; - double molProsMDEA = 11.21; - testSystem.addComponent("CO2", loading * molProsMDEA); - testSystem.addComponent("water", 100.0 - molProsMDEA - loading * molProsMDEA); - testSystem.addComponent("MDEA", molProsMDEA); - // testSystem.addComponent("Piperazine", loading*molProsMDEA*0.1); - testSystem.chemicalReactionInit(); - testSystem.createDatabase(true); - testSystem.setMixingRule(4); - testSystem.init(0); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - // testOps.calcPloadingCurve(); - long time = System.currentTimeMillis(); + double loading = 0.65; + double molProsMDEA = 11.21; + testSystem.addComponent("CO2", loading * molProsMDEA); + testSystem.addComponent("water", 100.0 - molProsMDEA - loading * molProsMDEA); + testSystem.addComponent("MDEA", molProsMDEA); + // testSystem.addComponent("Piperazine", loading*molProsMDEA*0.1); + testSystem.chemicalReactionInit(); + testSystem.createDatabase(true); + testSystem.setMixingRule(4); + testSystem.init(0); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + // testOps.calcPloadingCurve(); + long time = System.currentTimeMillis(); - try { - testOps.bubblePointPressureFlash(true); - } catch (Exception e) { - logger.error(e.toString()); - } - logger.info("Time taken for benchmark flash = " + (System.currentTimeMillis() - time)); - testSystem.display(); - logger.info("pressure " + testSystem.getPressure()); - int reactionNumber = 0; - logger.info("K " + testSystem.getChemicalReactionOperations().getReactionList() - .getReaction(reactionNumber).calcK(testSystem, 1)); - logger.info("Kx " + testSystem.getChemicalReactionOperations().getReactionList() - .getReaction(reactionNumber).calcKx(testSystem, 1)); - logger.info("Kgamma " + testSystem.getChemicalReactionOperations().getReactionList() - .getReaction(reactionNumber).calcKgamma(testSystem, 1)); - testSystem.setPressure(100.0); - testSystem.getChemicalReactionOperations().solveChemEq(1); - logger.info("K " + testSystem.getChemicalReactionOperations().getReactionList() - .getReaction(reactionNumber).calcK(testSystem, 1)); - logger.info("Kx " + testSystem.getChemicalReactionOperations().getReactionList() - .getReaction(reactionNumber).calcKx(testSystem, 1)); - logger.info("Kgamma " + testSystem.getChemicalReactionOperations().getReactionList() - .getReaction(reactionNumber).calcKgamma(testSystem, 1)); - - testSystem.display(); - // thermo.ThermodynamicModelTest testModel = new - // thermo.ThermodynamicModelTest(testSystem); - // testModel.runTest(); - // write data to netcdf - // testOps.writeNetCDF("c:/testloading.nc"); + try { + testOps.bubblePointPressureFlash(true); + } catch (Exception e) { + logger.error(e.toString()); } + logger.info("Time taken for benchmark flash = " + (System.currentTimeMillis() - time)); + testSystem.display(); + logger.info("pressure " + testSystem.getPressure()); + int reactionNumber = 0; + logger.info("K " + testSystem.getChemicalReactionOperations().getReactionList() + .getReaction(reactionNumber).calcK(testSystem, 1)); + logger.info("Kx " + testSystem.getChemicalReactionOperations().getReactionList() + .getReaction(reactionNumber).calcKx(testSystem, 1)); + logger.info("Kgamma " + testSystem.getChemicalReactionOperations().getReactionList() + .getReaction(reactionNumber).calcKgamma(testSystem, 1)); + testSystem.setPressure(100.0); + testSystem.getChemicalReactionOperations().solveChemEq(1); + logger.info("K " + testSystem.getChemicalReactionOperations().getReactionList() + .getReaction(reactionNumber).calcK(testSystem, 1)); + logger.info("Kx " + testSystem.getChemicalReactionOperations().getReactionList() + .getReaction(reactionNumber).calcKx(testSystem, 1)); + logger.info("Kgamma " + testSystem.getChemicalReactionOperations().getReactionList() + .getReaction(reactionNumber).calcKgamma(testSystem, 1)); + + testSystem.display(); + // thermo.ThermodynamicModelTest testModel = new + // thermo.ThermodynamicModelTest(testSystem); + // testModel.runTest(); + } } From 55adc69b57dab3082e64a20316c48ba90bd55f3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?= <34712686+asmfstatoil@users.noreply.github.com> Date: Thu, 21 Jul 2022 20:55:28 +0200 Subject: [PATCH 2/9] refact: auto format and auto fix snyk (#488) --- .../processEquipment/util/Recycle.java | 862 +++++++++--------- .../util/RecycleController.java | 399 ++++---- 2 files changed, 636 insertions(+), 625 deletions(-) diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java b/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java index 9152150e1d..640b05084c 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java @@ -1,7 +1,6 @@ package neqsim.processSimulation.processEquipment.util; import java.util.ArrayList; - import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; import neqsim.processSimulation.processEquipment.mixer.MixerInterface; import neqsim.processSimulation.processEquipment.stream.Stream; @@ -18,451 +17,452 @@ * @version $Id: $Id */ public class Recycle extends ProcessEquipmentBaseClass implements MixerInterface { - private static final long serialVersionUID = 1000; - - protected ArrayList streams = new ArrayList(0); - private ArrayList downstreamProperty = new ArrayList(0); - protected int numberOfInputStreams = 0; - protected StreamInterface mixedStream; - StreamInterface lastIterationStream = null; - private StreamInterface outletStream = null; - private double tolerance = 1e-4; - private double error = 1e6; - private int priority = 100; - boolean firstTime = true; - int iterations = 0; - int maxIterations = 10; - - /** - *

- * Constructor for Recycle. - *

- */ - @Deprecated - public Recycle() { - this("Recycle"); - } - - /** - *

- * Constructor for Recycle. - *

- * - * @param name a {@link java.lang.String} object - */ - public Recycle(String name) { - super(name); - } - - /** {@inheritDoc} */ - @Override - public SystemInterface getThermoSystem() { - return mixedStream.getThermoSystem(); - } - - /** - *

- * Setter for the field downstreamProperty. - *

- * - * @param property a {@link java.lang.String} object - */ - public void setDownstreamProperty(String property) { - downstreamProperty.add(property); + private static final long serialVersionUID = 1000; + + protected ArrayList streams = new ArrayList(0); + private ArrayList downstreamProperty = new ArrayList(0); + protected int numberOfInputStreams = 0; + protected StreamInterface mixedStream; + StreamInterface lastIterationStream = null; + private StreamInterface outletStream = null; + private double tolerance = 1e-4; + private double error = 1e6; + private int priority = 100; + boolean firstTime = true; + int iterations = 0; + int maxIterations = 10; + + /** + *

+ * Constructor for Recycle. + *

+ */ + @Deprecated + public Recycle() { + this("Recycle"); + } + + /** + *

+ * Constructor for Recycle. + *

+ * + * @param name a {@link java.lang.String} object + */ + public Recycle(String name) { + super(name); + } + + /** {@inheritDoc} */ + @Override + public SystemInterface getThermoSystem() { + return mixedStream.getThermoSystem(); + } + + /** + *

+ * Setter for the field downstreamProperty. + *

+ * + * @param property a {@link java.lang.String} object + */ + public void setDownstreamProperty(String property) { + downstreamProperty.add(property); + } + + /** {@inheritDoc} */ + @Override + public void replaceStream(int i, StreamInterface newStream) { + streams.set(i, newStream); + } + + /** {@inheritDoc} */ + @Override + public void addStream(StreamInterface newStream) { + streams.add(newStream); + + if (numberOfInputStreams == 0) { + mixedStream = streams.get(0).clone(); + // mixedStream.getThermoSystem().setNumberOfPhases(2); + // mixedStream.getThermoSystem().reInitPhaseType(); + // mixedStream.getThermoSystem().init(0); + // mixedStream.getThermoSystem().init(3); } - - /** {@inheritDoc} */ - @Override - public void replaceStream(int i, StreamInterface newStream) { - streams.set(i, newStream); - } - - /** {@inheritDoc} */ - @Override - public void addStream(StreamInterface newStream) { - streams.add(newStream); - - if (numberOfInputStreams == 0) { - mixedStream = streams.get(0).clone(); - // mixedStream.getThermoSystem().setNumberOfPhases(2); - // mixedStream.getThermoSystem().reInitPhaseType(); - // mixedStream.getThermoSystem().init(0); - // mixedStream.getThermoSystem().init(3); + mixedStream.setEmptyThermoSystem(streams.get(0).getThermoSystem()); + numberOfInputStreams++; + lastIterationStream = mixedStream.clone(); + } + + /** + *

+ * getStream. + *

+ * + * @param i a int + * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + public StreamInterface getStream(int i) { + return streams.get(i); + } + + /** + *

+ * mixStream. + *

+ */ + public void mixStream() { + int index = 0; + // String compName = new String(); + + for (int k = 1; k < streams.size(); k++) { + for (int i = 0; i < streams.get(k).getThermoSystem().getPhase(0) + .getNumberOfComponents(); i++) { + boolean gotComponent = false; + String componentName = + streams.get(k).getThermoSystem().getPhase(0).getComponent(i).getName(); + // System.out.println("adding: " + componentName); + // int numberOfPhases = streams.get(k).getThermoSystem().getNumberOfPhases(); + + double moles = + streams.get(k).getThermoSystem().getPhase(0).getComponent(i).getNumberOfmoles(); + // System.out.println("moles: " + moles + " " + + // mixedStream.getThermoSystem().getPhase(0).getNumberOfComponents()); + for (int p = 0; p < mixedStream.getThermoSystem().getPhase(0) + .getNumberOfComponents(); p++) { + if (mixedStream.getThermoSystem().getPhase(0).getComponent(p).getName() + .equals(componentName)) { + gotComponent = true; + index = + streams.get(0).getThermoSystem().getPhase(0).getComponent(p).getComponentNumber(); + // compName = streams.get(0).getThermoSystem().getPhase(0).getComponent(p) + // .getComponentName(); + } } - mixedStream.setEmptyThermoSystem(streams.get(0).getThermoSystem()); - numberOfInputStreams++; - lastIterationStream = mixedStream.clone(); - } - /** - *

- * getStream. - *

- * - * @param i a int - * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ - public StreamInterface getStream(int i) { - return streams.get(i); - } - - /** - *

- * mixStream. - *

- */ - public void mixStream() { - int index = 0; - // String compName = new String(); - - for (int k = 1; k < streams.size(); k++) { - for (int i = 0; i < streams.get(k).getThermoSystem().getPhase(0) - .getNumberOfComponents(); i++) { - boolean gotComponent = false; - String componentName = - streams.get(k).getThermoSystem().getPhase(0).getComponent(i).getName(); - // System.out.println("adding: " + componentName); - // int numberOfPhases = streams.get(k).getThermoSystem().getNumberOfPhases(); - - double moles = streams.get(k).getThermoSystem().getPhase(0).getComponent(i) - .getNumberOfmoles(); - // System.out.println("moles: " + moles + " " + - // mixedStream.getThermoSystem().getPhase(0).getNumberOfComponents()); - for (int p = 0; p < mixedStream.getThermoSystem().getPhase(0) - .getNumberOfComponents(); p++) { - if (mixedStream.getThermoSystem().getPhase(0).getComponent(p).getName() - .equals(componentName)) { - gotComponent = true; - index = streams.get(0).getThermoSystem().getPhase(0).getComponent(p) - .getComponentNumber(); - // compName = streams.get(0).getThermoSystem().getPhase(0).getComponent(p) - // .getComponentName(); - } - } - - if (gotComponent) { - // System.out.println("adding moles starting...."); - mixedStream.getThermoSystem().addComponent(index, moles); - // mixedStream.getThermoSystem().init_x_y(); - // System.out.println("adding moles finished"); - } else { - System.out.println("ikke gaa hit"); - mixedStream.getThermoSystem().addComponent(index, moles); - } - } - } - // mixedStream.getThermoSystem().init_x_y(); - // mixedStream.getThermoSystem().initBeta(); - // mixedStream.getThermoSystem().init(2); - } - - /** - *

- * guessTemperature. - *

- * - * @return a double - */ - public double guessTemperature() { - double gtemp = 0; - for (int k = 0; k < streams.size(); k++) { - gtemp += streams.get(k).getThermoSystem().getTemperature() - * streams.get(k).getThermoSystem().getNumberOfMoles() - / mixedStream.getThermoSystem().getNumberOfMoles(); - } - return gtemp; - } - - /** - *

- * calcMixStreamEnthalpy. - *

- * - * @return a double - */ - public double calcMixStreamEnthalpy() { - double enthalpy = 0; - for (int k = 0; k < streams.size(); k++) { - streams.get(k).getThermoSystem().init(3); - enthalpy += streams.get(k).getThermoSystem().getEnthalpy(); - // System.out.println("total enthalpy k : " + ( ((Stream) - // streams.get(k)).getThermoSystem()).getEnthalpy()); - } - // System.out.println("total enthalpy of streams: " + enthalpy); - return enthalpy; - } - - /** {@inheritDoc} */ - @Deprecated - public StreamInterface getOutStream() { - return mixedStream; - } - - /** - *

- * initiateDownstreamProperties. - *

- * - * @param outstream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - public void initiateDownstreamProperties(StreamInterface outstream) { - lastIterationStream = outstream.clone(); - } - - /** - *

- * setDownstreamProperties. - *

- */ - public void setDownstreamProperties() { - if (downstreamProperty.size() > 0) { - for (int i = 0; i < downstreamProperty.size(); i++) { - if (downstreamProperty.get(i).equals("flow rate")) - mixedStream.setFlowRate(outletStream.getFlowRate("kg/hr"), "kg/hr"); - } - } - } - - /** {@inheritDoc} */ - @Override - public void run() { - iterations++; - /* - * if(firstTime || iterations>maxIterations) { firstTime=false; return; - * - * } - */ - double enthalpy = 0.0; - // System.out.println("flow rate old in recycle " + - // outletStream.getFlowRate("kg/hr")); - // ((Stream) streams.get(0)).getThermoSystem().display(); - SystemInterface thermoSystem2 = streams.get(0).getThermoSystem().clone(); - // System.out.println("total number of moles " + - // thermoSystem2.getTotalNumberOfMoles()); - mixedStream.setThermoSystem(thermoSystem2); - ThermodynamicOperations testOps = new ThermodynamicOperations(thermoSystem2); - if (streams.size() > 1) { - mixedStream.getThermoSystem().setNumberOfPhases(2); - mixedStream.getThermoSystem().reInitPhaseType(); - mixedStream.getThermoSystem().init(0); - - mixStream(); - - setDownstreamProperties(); - try { - enthalpy = calcMixStreamEnthalpy(); - } catch (Exception e) { - // String error = e.getMessage(); - return; - } - // System.out.println("temp guess " + guessTemperature()); - mixedStream.getThermoSystem().setTemperature(guessTemperature()); - testOps.PHflash(enthalpy, 0); - // System.out.println("filan temp " + mixedStream.getTemperature()); + if (gotComponent) { + // System.out.println("adding moles starting...."); + mixedStream.getThermoSystem().addComponent(index, moles); + // mixedStream.getThermoSystem().init_x_y(); + // System.out.println("adding moles finished"); } else { - setDownstreamProperties(); - testOps.TPflash(); + System.out.println("ikke gaa hit"); + mixedStream.getThermoSystem().addComponent(index, moles); } - setError(massBalanceCheck()); - System.out.println(name + " recycle error: " + getError()); - lastIterationStream = (Stream) mixedStream.clone(); - outletStream.setThermoSystem(mixedStream.getThermoSystem()); - // System.out.println("flow rate new in recycle " + - // outletStream.getFlowRate("kg/hr")); - - // System.out.println("enthalpy: " + - // mixedStream.getThermoSystem().getEnthalpy()); - // System.out.println("enthalpy: " + enthalpy); - // System.out.println("temperature: " + - // mixedStream.getThermoSystem().getTemperature()); - - // System.out.println("beta " + mixedStream.getThermoSystem().getBeta()); - // outStream.setThermoSystem(mixedStream.getThermoSystem()); + } } - - /** - *

- * massBalanceCheck. - *

- * - * @return a double - */ - public double massBalanceCheck() { - double error = 0.0; - // System.out.println("flow rate new " + - // mixedStream.getThermoSystem().getFlowRate("kg/hr")); - // System.out.println("temperature " + - // mixedStream.getThermoSystem().getTemperature("C")); - // System.out.println("pressure " + - // mixedStream.getThermoSystem().getPressure("bara")); - if (lastIterationStream.getFluid().getNumberOfComponents() != mixedStream.getFluid() - .getNumberOfComponents()) { - return 10.0; - } - for (int i = 0; i < mixedStream.getThermoSystem().getPhase(0) - .getNumberOfComponents(); i++) { - // System.out.println("x last " + - // lastIterationStream.getThermoSystem().getPhase(0).getComponent(i).getx()); - // System.out.println("x new " + - // mixedStream.getThermoSystem().getPhase(0).getComponent(i).getx()); - error += Math.abs(mixedStream.getThermoSystem().getPhase(0).getComponent(i).getx() - - lastIterationStream.getThermoSystem().getPhase(0).getComponent(i).getx()); - } - return Math.abs(error); + // mixedStream.getThermoSystem().init_x_y(); + // mixedStream.getThermoSystem().initBeta(); + // mixedStream.getThermoSystem().init(2); + } + + /** + *

+ * guessTemperature. + *

+ * + * @return a double + */ + public double guessTemperature() { + double gtemp = 0; + for (int k = 0; k < streams.size(); k++) { + gtemp += streams.get(k).getThermoSystem().getTemperature() + * streams.get(k).getThermoSystem().getNumberOfMoles() + / mixedStream.getThermoSystem().getNumberOfMoles(); } - - /** {@inheritDoc} */ - @Override - public void displayResult() {} - - /** {@inheritDoc} */ - @Override - public void setPressure(double pres) { - for (int k = 0; k < streams.size(); k++) { - streams.get(k).getThermoSystem().setPressure(pres); - } - mixedStream.getThermoSystem().setPressure(pres); + return gtemp; + } + + /** + *

+ * calcMixStreamEnthalpy. + *

+ * + * @return a double + */ + public double calcMixStreamEnthalpy() { + double enthalpy = 0; + for (int k = 0; k < streams.size(); k++) { + streams.get(k).getThermoSystem().init(3); + enthalpy += streams.get(k).getThermoSystem().getEnthalpy(); + // System.out.println("total enthalpy k : " + ( ((Stream) + // streams.get(k)).getThermoSystem()).getEnthalpy()); } - - /** - *

- * setTemperature. - *

- * - * @param temp a double - */ - public void setTemperature(double temp) { - for (int k = 0; k < streams.size(); k++) { - streams.get(k).getThermoSystem().setTemperature(temp); + // System.out.println("total enthalpy of streams: " + enthalpy); + return enthalpy; + } + + /** {@inheritDoc} */ + @Deprecated + public StreamInterface getOutStream() { + return mixedStream; + } + + /** + *

+ * initiateDownstreamProperties. + *

+ * + * @param outstream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public void initiateDownstreamProperties(StreamInterface outstream) { + lastIterationStream = outstream.clone(); + } + + /** + *

+ * setDownstreamProperties. + *

+ */ + public void setDownstreamProperties() { + if (downstreamProperty.size() > 0) { + for (int i = 0; i < downstreamProperty.size(); i++) { + if (downstreamProperty.get(i).equals("flow rate")) { + mixedStream.setFlowRate(outletStream.getFlowRate("kg/hr"), "kg/hr"); } - mixedStream.getThermoSystem().setTemperature(temp); - } - - /** - *

- * Getter for the field tolerance. - *

- * - * @return the tolerance - */ - public double getTolerance() { - return tolerance; - } - - /** - *

- * Setter for the field tolerance. - *

- * - * @param tolerance the tolerance to set - */ - public void setTolerance(double tolerance) { - this.tolerance = tolerance; - } - - /** - *

- * Getter for the field error. - *

- * - * @return the error - */ - public double getError() { - return error; + } } - - /** - *

- * Setter for the field error. - *

- * - * @param error the error to set - */ - public void setError(double error) { - this.error = error; - } - - /** - *

- * Getter for the field priority. - *

- * - * @return a int + } + + /** {@inheritDoc} */ + @Override + public void run() { + iterations++; + /* + * if(firstTime || iterations>maxIterations) { firstTime=false; return; + * + * } */ - public int getPriority() { - return priority; - } - - /** - *

- * Setter for the field priority. - *

- * - * @param priority a int - */ - public void setPriority(int priority) { - this.priority = priority; - } - - /** {@inheritDoc} */ - @Override - public boolean solved() { - if (error < tolerance) - return true; - else - return false; + double enthalpy = 0.0; + // System.out.println("flow rate old in recycle " + + // outletStream.getFlowRate("kg/hr")); + // ((Stream) streams.get(0)).getThermoSystem().display(); + SystemInterface thermoSystem2 = streams.get(0).getThermoSystem().clone(); + // System.out.println("total number of moles " + + // thermoSystem2.getTotalNumberOfMoles()); + mixedStream.setThermoSystem(thermoSystem2); + ThermodynamicOperations testOps = new ThermodynamicOperations(thermoSystem2); + if (streams.size() > 1) { + mixedStream.getThermoSystem().setNumberOfPhases(2); + mixedStream.getThermoSystem().reInitPhaseType(); + mixedStream.getThermoSystem().init(0); + + mixStream(); + + setDownstreamProperties(); + try { + enthalpy = calcMixStreamEnthalpy(); + } catch (Exception e) { + // String error = e.getMessage(); + return; + } + // System.out.println("temp guess " + guessTemperature()); + mixedStream.getThermoSystem().setTemperature(guessTemperature()); + testOps.PHflash(enthalpy, 0); + // System.out.println("filan temp " + mixedStream.getTemperature()); + } else { + setDownstreamProperties(); + testOps.TPflash(); } - - /** - *

- * Getter for the field downstreamProperty. - *

- * - * @return a {@link java.util.ArrayList} object - */ - public ArrayList getDownstreamProperty() { - return downstreamProperty; + setError(massBalanceCheck()); + System.out.println(name + " recycle error: " + getError()); + lastIterationStream = (Stream) mixedStream.clone(); + outletStream.setThermoSystem(mixedStream.getThermoSystem()); + // System.out.println("flow rate new in recycle " + + // outletStream.getFlowRate("kg/hr")); + + // System.out.println("enthalpy: " + + // mixedStream.getThermoSystem().getEnthalpy()); + // System.out.println("enthalpy: " + enthalpy); + // System.out.println("temperature: " + + // mixedStream.getThermoSystem().getTemperature()); + + // System.out.println("beta " + mixedStream.getThermoSystem().getBeta()); + // outStream.setThermoSystem(mixedStream.getThermoSystem()); + } + + /** + *

+ * massBalanceCheck. + *

+ * + * @return a double + */ + public double massBalanceCheck() { + double error = 0.0; + // System.out.println("flow rate new " + + // mixedStream.getThermoSystem().getFlowRate("kg/hr")); + // System.out.println("temperature " + + // mixedStream.getThermoSystem().getTemperature("C")); + // System.out.println("pressure " + + // mixedStream.getThermoSystem().getPressure("bara")); + if (lastIterationStream.getFluid().getNumberOfComponents() != mixedStream.getFluid() + .getNumberOfComponents()) { + return 10.0; } - - /** - *

- * Setter for the field downstreamProperty. - *

- * - * @param upstreamProperty a {@link java.util.ArrayList} object - */ - public void setDownstreamProperty(ArrayList upstreamProperty) { - this.downstreamProperty = upstreamProperty; + for (int i = 0; i < mixedStream.getThermoSystem().getPhase(0).getNumberOfComponents(); i++) { + // System.out.println("x last " + + // lastIterationStream.getThermoSystem().getPhase(0).getComponent(i).getx()); + // System.out.println("x new " + + // mixedStream.getThermoSystem().getPhase(0).getComponent(i).getx()); + error += Math.abs(mixedStream.getThermoSystem().getPhase(0).getComponent(i).getx() + - lastIterationStream.getThermoSystem().getPhase(0).getComponent(i).getx()); } - - /** - *

- * Getter for the field outletStream. - *

- * - * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ - public StreamInterface getOutletStream() { - return outletStream; + return Math.abs(error); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() {} + + /** {@inheritDoc} */ + @Override + public void setPressure(double pres) { + for (int k = 0; k < streams.size(); k++) { + streams.get(k).getThermoSystem().setPressure(pres); } - - /** - *

- * Setter for the field outletStream. - *

- * - * @param outletStream a - * {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ - public void setOutletStream(StreamInterface outletStream) { - this.outletStream = outletStream; - lastIterationStream = this.outletStream.clone(); + mixedStream.getThermoSystem().setPressure(pres); + } + + /** + *

+ * setTemperature. + *

+ * + * @param temp a double + */ + public void setTemperature(double temp) { + for (int k = 0; k < streams.size(); k++) { + streams.get(k).getThermoSystem().setTemperature(temp); } - - /** {@inheritDoc} */ - @Override - public void removeInputStream(int i) { - streams.remove(i); + mixedStream.getThermoSystem().setTemperature(temp); + } + + /** + *

+ * Getter for the field tolerance. + *

+ * + * @return the tolerance + */ + public double getTolerance() { + return tolerance; + } + + /** + *

+ * Setter for the field tolerance. + *

+ * + * @param tolerance the tolerance to set + */ + public void setTolerance(double tolerance) { + this.tolerance = tolerance; + } + + /** + *

+ * Getter for the field error. + *

+ * + * @return the error + */ + public double getError() { + return error; + } + + /** + *

+ * Setter for the field error. + *

+ * + * @param error the error to set + */ + public void setError(double error) { + this.error = error; + } + + /** + *

+ * Getter for the field priority. + *

+ * + * @return a int + */ + public int getPriority() { + return priority; + } + + /** + *

+ * Setter for the field priority. + *

+ * + * @param priority a int + */ + public void setPriority(int priority) { + this.priority = priority; + } + + /** {@inheritDoc} */ + @Override + public boolean solved() { + if (error < tolerance) { + return true; + } else { + return false; } + } + + /** + *

+ * Getter for the field downstreamProperty. + *

+ * + * @return a {@link java.util.ArrayList} object + */ + public ArrayList getDownstreamProperty() { + return downstreamProperty; + } + + /** + *

+ * Setter for the field downstreamProperty. + *

+ * + * @param upstreamProperty a {@link java.util.ArrayList} object + */ + public void setDownstreamProperty(ArrayList upstreamProperty) { + this.downstreamProperty = upstreamProperty; + } + + /** + *

+ * Getter for the field outletStream. + *

+ * + * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + public StreamInterface getOutletStream() { + return outletStream; + } + + /** + *

+ * Setter for the field outletStream. + *

+ * + * @param outletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public void setOutletStream(StreamInterface outletStream) { + this.outletStream = outletStream; + lastIterationStream = this.outletStream.clone(); + } + + /** {@inheritDoc} */ + @Override + public void removeInputStream(int i) { + streams.remove(i); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/RecycleController.java b/src/main/java/neqsim/processSimulation/processEquipment/util/RecycleController.java index a2e7b6d67d..227bf53aed 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/RecycleController.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/RecycleController.java @@ -12,210 +12,221 @@ * @version $Id: $Id */ public class RecycleController implements java.io.Serializable { - private static final long serialVersionUID = 1000; - - ArrayList recycleArray = new ArrayList(); - ArrayList priorityArray = new ArrayList(); - private int currentPriorityLevel = 100; - private int minimumPriorityLevel = 100; - private int maximumPriorityLevel = 100; - - /** - *

- * Constructor for RecycleController. - *

- */ - public RecycleController() {} - - /** - *

- * init. - *

- */ - public void init() { - for (Recycle recyc : recycleArray) { - if (recyc.getPriority() < minimumPriorityLevel) - minimumPriorityLevel = recyc.getPriority(); - if (recyc.getPriority() > maximumPriorityLevel) - maximumPriorityLevel = recyc.getPriority(); - } - - currentPriorityLevel = minimumPriorityLevel; - } - - /** - *

- * resetPriorityLevel. - *

- */ - public void resetPriorityLevel() { - currentPriorityLevel = minimumPriorityLevel; + private static final long serialVersionUID = 1000; + + ArrayList recycleArray = new ArrayList(); + ArrayList priorityArray = new ArrayList(); + private int currentPriorityLevel = 100; + private int minimumPriorityLevel = 100; + private int maximumPriorityLevel = 100; + + /** + *

+ * Constructor for RecycleController. + *

+ */ + public RecycleController() {} + + /** + *

+ * init. + *

+ */ + public void init() { + for (Recycle recyc : recycleArray) { + if (recyc.getPriority() < minimumPriorityLevel) { + minimumPriorityLevel = recyc.getPriority(); + } + if (recyc.getPriority() > maximumPriorityLevel) { + maximumPriorityLevel = recyc.getPriority(); + } } - /** - *

- * addRecycle. - *

- * - * @param recycle a {@link neqsim.processSimulation.processEquipment.util.Recycle} object - */ - public void addRecycle(Recycle recycle) { - recycleArray.add(recycle); - priorityArray.add(recycle.getPriority()); + currentPriorityLevel = minimumPriorityLevel; + } + + /** + *

+ * resetPriorityLevel. + *

+ */ + public void resetPriorityLevel() { + currentPriorityLevel = minimumPriorityLevel; + } + + /** + *

+ * addRecycle. + *

+ * + * @param recycle a {@link neqsim.processSimulation.processEquipment.util.Recycle} object + */ + public void addRecycle(Recycle recycle) { + recycleArray.add(recycle); + priorityArray.add(recycle.getPriority()); + } + + /** + *

+ * doSolveRecycle. + *

+ * + * @param recycle a {@link neqsim.processSimulation.processEquipment.util.Recycle} object + * @return a boolean + */ + public boolean doSolveRecycle(Recycle recycle) { + if (recycle.getPriority() == getCurrentPriorityLevel()) { + return true; + } else { + return false; } - - /** - *

- * doSolveRecycle. - *

- * - * @param recycle a {@link neqsim.processSimulation.processEquipment.util.Recycle} object - * @return a boolean - */ - public boolean doSolveRecycle(Recycle recycle) { - if (recycle.getPriority() == getCurrentPriorityLevel()) - return true; - else - return false; + } + + /** + *

+ * isHighestPriority. + *

+ * + * @param recycle a {@link neqsim.processSimulation.processEquipment.util.Recycle} object + * @return a boolean + */ + public boolean isHighestPriority(Recycle recycle) { + if (recycle.getPriority() == maximumPriorityLevel) { + return true; + } else { + return false; } - - /** - *

- * isHighestPriority. - *

- * - * @param recycle a {@link neqsim.processSimulation.processEquipment.util.Recycle} object - * @return a boolean - */ - public boolean isHighestPriority(Recycle recycle) { - if (recycle.getPriority() == maximumPriorityLevel) - return true; - else - return false; - } - - /** - *

- * solvedCurrentPriorityLevel. - *

- * - * @return a boolean - */ - public boolean solvedCurrentPriorityLevel() { - for (Recycle recyc : recycleArray) { - if (recyc.getPriority() == currentPriorityLevel) { - if (!recyc.solved()) - return false; - } + } + + /** + *

+ * solvedCurrentPriorityLevel. + *

+ * + * @return a boolean + */ + public boolean solvedCurrentPriorityLevel() { + for (Recycle recyc : recycleArray) { + if (recyc.getPriority() == currentPriorityLevel) { + if (!recyc.solved()) { + return false; } - return true; + } } - - /** - *

- * nextPriorityLevel. - *

- */ - public void nextPriorityLevel() { - currentPriorityLevel = maximumPriorityLevel; + return true; + } + + /** + *

+ * nextPriorityLevel. + *

+ */ + public void nextPriorityLevel() { + currentPriorityLevel = maximumPriorityLevel; + } + + /** + *

+ * hasLoverPriorityLevel. + *

+ * + * @return a boolean + */ + public boolean hasLoverPriorityLevel() { + if (currentPriorityLevel > minimumPriorityLevel) { + return true; + } else { + return false; } - - /** - *

- * hasLoverPriorityLevel. - *

- * - * @return a boolean - */ - public boolean hasLoverPriorityLevel() { - if (currentPriorityLevel > minimumPriorityLevel) { - return true; - } else - return false; + } + + /** + *

+ * hasHigherPriorityLevel. + *

+ * + * @return a boolean + */ + public boolean hasHigherPriorityLevel() { + if (currentPriorityLevel < maximumPriorityLevel) { + return true; + } else { + return false; } - - /** - *

- * hasHigherPriorityLevel. - *

- * - * @return a boolean - */ - public boolean hasHigherPriorityLevel() { - if (currentPriorityLevel < maximumPriorityLevel) { - return true; - } else - return false; + } + + /** + *

+ * solvedAll. + *

+ * + * @return a boolean + */ + public boolean solvedAll() { + for (Recycle recyc : recycleArray) { + if (!recyc.solved()) { + return false; + } } - - /** - *

- * solvedAll. - *

- * - * @return a boolean - */ - public boolean solvedAll() { - for (Recycle recyc : recycleArray) { - if (!recyc.solved()) - return false; - } - return true; - } - - /** - *

- * clear. - *

- */ - public void clear() { - recycleArray.clear(); - priorityArray.clear(); - } - - /** - *

- * Getter for the field currentPriorityLevel. - *

- * - * @return a int - */ - public int getCurrentPriorityLevel() { - return currentPriorityLevel; + return true; + } + + /** + *

+ * clear. + *

+ */ + public void clear() { + recycleArray.clear(); + priorityArray.clear(); + } + + /** + *

+ * Getter for the field currentPriorityLevel. + *

+ * + * @return a int + */ + public int getCurrentPriorityLevel() { + return currentPriorityLevel; + } + + /** + *

+ * Setter for the field currentPriorityLevel. + *

+ * + * @param currentPriorityLevel a int + */ + public void setCurrentPriorityLevel(int currentPriorityLevel) { + this.currentPriorityLevel = currentPriorityLevel; + } + + /** {@inheritDoc} */ + @Override + public int hashCode() { + return Objects.hash(currentPriorityLevel, maximumPriorityLevel, minimumPriorityLevel, + priorityArray, recycleArray); + } + + /** {@inheritDoc} */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; } - - /** - *

- * Setter for the field currentPriorityLevel. - *

- * - * @param currentPriorityLevel a int - */ - public void setCurrentPriorityLevel(int currentPriorityLevel) { - this.currentPriorityLevel = currentPriorityLevel; + if (obj == null) { + return false; } - - /** {@inheritDoc} */ - @Override - public int hashCode() { - return Objects.hash(currentPriorityLevel, maximumPriorityLevel, minimumPriorityLevel, - priorityArray, recycleArray); - } - - /** {@inheritDoc} */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - RecycleController other = (RecycleController) obj; - return currentPriorityLevel == other.currentPriorityLevel - && maximumPriorityLevel == other.maximumPriorityLevel - && minimumPriorityLevel == other.minimumPriorityLevel - && Objects.equals(priorityArray, other.priorityArray) - && Objects.equals(recycleArray, other.recycleArray); + if (getClass() != obj.getClass()) { + return false; } + RecycleController other = (RecycleController) obj; + return currentPriorityLevel == other.currentPriorityLevel + && maximumPriorityLevel == other.maximumPriorityLevel + && minimumPriorityLevel == other.minimumPriorityLevel + && Objects.equals(priorityArray, other.priorityArray) + && Objects.equals(recycleArray, other.recycleArray); + } } From a4cf3266e9a68383bdb14ba1bd60743f6d6d89ac Mon Sep 17 00:00:00 2001 From: Snyk bot Date: Fri, 22 Jul 2022 00:59:50 +0200 Subject: [PATCH 3/9] [Snyk] Upgrade org.apache.derby:derby from 10.14.2.0 to 10.16.1.1 (#457) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: upgrade org.apache.derby:derby from 10.14.2.0 to 10.16.1.1 Snyk has created this PR to upgrade org.apache.derby:derby from 10.14.2.0 to 10.16.1.1. See this package in Maven Repository: https://mvnrepository.com/artifact/org.apache.derby/derby/ See this project in Snyk: https://app.snyk.io/org/neqsim/project/86e71bb0-950f-445f-94e7-32e73d92cca3?utm_source=github&utm_medium=referral&page=upgrade-pr * Update pom.xml Try with intermediate version 1.15.2.0, as 10.16.1.1 is not supported for java 11. Co-authored-by: Ã…smund VÃ¥ge Fannemel <34712686+asmfstatoil@users.noreply.github.com> Co-authored-by: Even Solbraa <41290109+EvenSol@users.noreply.github.com> --- pom.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1870184862..207a5ec5b4 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,13 @@ org.apache.derby derby - 10.14.2.0 + 10.15.2.0 + + + org.apache.derby + derbytools + 10.15.2.0 + test org.ejml From 20c2b253e7795cb95cdaede44396fc08553f811c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?= <34712686+asmfstatoil@users.noreply.github.com> Date: Fri, 22 Jul 2022 13:11:24 +0200 Subject: [PATCH 4/9] feat: add calcidentifier to simulation objects (#486) Add unique id showing which call to solve/run that last ran successfully. Also did some refactoring such as autoformatting, reordering of code and moving some code in the class hierarchy. --- .../flowNode/FlowNodeInterface.java | 1 - .../fluidMechanics/flowSystem/FlowSystem.java | 870 +++--- .../flowSystem/FlowSystemInterface.java | 712 ++--- .../pipeFlowSystem/PipeFlowSystem.java | 169 +- .../shipSystem/LNGship.java | 1082 ++++--- .../stirredCellSystem/StirredCellSystem.java | 9 +- .../TwoPhasePipeFlowSystem.java | 10 +- .../TwoPhaseReactorFlowSystem.java | 290 +- .../TwoPhasePipeFlowVisualization.java | 1 - .../SimulationBaseClass.java | 46 +- .../SimulationInterface.java | 100 +- .../ControllerDeviceBaseClass.java | 328 +-- .../ControllerDeviceInterface.java | 196 +- .../measurementDevice/WellAllocator.java | 2 - .../ProcessEquipmentBaseClass.java | 16 +- .../absorber/SimpleAbsorber.java | 750 ++--- .../absorber/SimpleTEGAbsorber.java | 1128 ++++---- .../absorber/WaterStripperColumn.java | 1017 ++++--- .../adsorber/SimpleAdsorber.java | 674 ++--- .../compressor/Compressor.java | 2515 +++++++++-------- .../compressor/CompressorPropertyProfile.java | 1 + .../distillation/Condenser.java | 129 +- .../distillation/DistillationColumn.java | 1280 ++++----- .../distillation/Reboiler.java | 139 +- .../distillation/SimpleTray.java | 399 +-- .../distillation/VLSolidTray.java | 224 +- .../processEquipment/expander/Expander.java | 204 +- .../expander/ExpanderOld.java | 16 +- .../processEquipment/filter/Filter.java | 4 +- .../heatExchanger/HeatExchanger.java | 1175 ++++---- .../heatExchanger/Heater.java | 12 +- .../heatExchanger/NeqHeater.java | 142 +- .../heatExchanger/ReBoiler.java | 173 +- .../processEquipment/mixer/Mixer.java | 39 +- .../processEquipment/mixer/StaticMixer.java | 192 +- .../mixer/StaticNeqMixer.java | 199 +- .../mixer/StaticPhaseMixer.java | 192 +- .../pipeline/AdiabaticPipe.java | 746 ++--- .../pipeline/AdiabaticTwoPhasePipe.java | 941 +++--- .../pipeline/IncompressiblePipeFlow.java | 369 +-- .../pipeline/OnePhasePipeLine.java | 21 +- .../processEquipment/pipeline/Pipeline.java | 8 +- .../pipeline/SimpleTPoutPipeline.java | 180 +- .../pipeline/TwoPhasePipeLine.java | 10 +- .../powerGeneration/GasTurbine.java | 27 +- .../processEquipment/pump/Pump.java | 12 +- .../reservoir/SimpleReservoir.java | 1428 +++++----- .../separator/GasScrubber.java | 270 +- .../separator/GasScrubberSimple.java | 286 +- .../separator/Hydrocyclone.java | 31 +- .../separator/NeqGasScrubber.java | 271 +- .../processEquipment/separator/Separator.java | 26 +- .../separator/ThreePhaseSeparator.java | 14 +- .../separator/TwoPhaseSeparator.java | 228 +- .../separator/sectionType/MeshSection.java | 1 - .../splitter/ComponentSplitter.java | 4 +- .../processEquipment/splitter/Splitter.java | 10 +- .../stream/EquilibriumStream.java | 143 +- .../stream/IronIonSaturationStream.java | 215 +- .../processEquipment/stream/NeqStream.java | 175 +- .../stream/ScalePotentialCheckStream.java | 186 +- .../processEquipment/stream/Stream.java | 1069 +++---- .../stream/StreamInterface.java | 26 +- .../subsea/SimpleFlowLine.java | 184 +- .../processEquipment/subsea/SubseaWell.java | 307 +- .../processEquipment/tank/Tank.java | 15 +- .../processEquipment/util/Adjuster.java | 533 ++-- .../processEquipment/util/Calculator.java | 139 +- .../processEquipment/util/GORfitter.java | 22 +- .../util/MoleFractionControllerUtil.java | 4 +- .../processEquipment/util/NeqSimUnit.java | 643 ++--- .../processEquipment/util/Recycle.java | 28 +- .../processEquipment/util/SetPoint.java | 426 +-- .../util/StreamSaturatorUtil.java | 6 +- .../util/StreamTransition.java | 6 +- .../valve/ThrottlingValve.java | 39 +- .../valve/ValveInterface.java | 1 - .../processSystem/ModuleInterface.java | 1 - .../processSystem/ProcessModuleBaseClass.java | 17 +- .../processSystem/ProcessSystem.java | 1808 ++++++------ .../AdsorptionDehydrationlModule.java | 385 +-- .../processModules/CO2RemovalModule.java | 138 +- .../processModules/DPCUModule.java | 533 ++-- .../GlycolDehydrationlModule.java | 957 ++++--- .../processModules/MEGReclaimerModule.java | 292 +- .../MixerGasProcessingModule.java | 456 +-- .../processModules/PropaneCoolingModule.java | 398 +-- .../processModules/SeparationTrainModule.java | 603 ++-- .../SeparationTrainModuleSimple.java | 604 ++-- .../processModules/WellFluidModule.java | 435 +-- .../gasQuality/Standard_ISO6976.java | 1 - .../neqsim/thermo/ThermodynamicModelTest.java | 1 - .../thermo/atomElement/UNIFACgroup.java | 1 - .../thermo/component/ComponentPRvolcor.java | 14 +- .../thermo/component/ComponentUMRCPA.java | 1 - .../AtractiveTermMatCopPRUMRNew.java | 1 - .../neqsim/thermo/phase/PhaseInterface.java | 202 +- .../neqsim/thermo/phase/PhasePrEosvolcor.java | 18 - .../neqsim/thermo/system/SystemInterface.java | 508 ++-- .../neqsim/thermo/system/SystemThermo.java | 288 +- .../neqsim/thermo/system/SystemUMRCPAEoS.java | 1 - .../thermo/system/SystemUMRPRUMCEosNew.java | 1 - .../ThermodynamicOperations.java | 252 +- .../pipeFlowSystem/PipeFlowSystemTest.java | 1 - .../measurementDevice/WellAllocatorTest.java | 2 - .../processSystem/GlycolRigTest.java | 15 - .../ProcessSystemRunTransientTest.java | 370 +-- .../processSystem/ProcessSystemTest.java | 7 - .../neqsim/thermo/system/SystemPrEosTest.java | 2 - .../system/SystemThermoAddComponentTest.java | 1 - .../thermo/system/SystemUMRCPAEoStest.java | 4 - .../system/SystemUMRPRUMCEosNewTest.java | 4 - 112 files changed, 16090 insertions(+), 15718 deletions(-) diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/FlowNodeInterface.java b/src/main/java/neqsim/fluidMechanics/flowNode/FlowNodeInterface.java index 743f0b69f9..242103e4a2 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/FlowNodeInterface.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/FlowNodeInterface.java @@ -716,7 +716,6 @@ default public void display() { display(""); } - /** *

* display. diff --git a/src/main/java/neqsim/fluidMechanics/flowSystem/FlowSystem.java b/src/main/java/neqsim/fluidMechanics/flowSystem/FlowSystem.java index ed296c6566..7814155f82 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSystem/FlowSystem.java +++ b/src/main/java/neqsim/fluidMechanics/flowSystem/FlowSystem.java @@ -1,5 +1,6 @@ package neqsim.fluidMechanics.flowSystem; +import java.util.UUID; import neqsim.fluidMechanics.flowLeg.FlowLegInterface; import neqsim.fluidMechanics.flowNode.FlowNodeInterface; import neqsim.fluidMechanics.flowSolver.FlowSolverInterface; @@ -19,440 +20,437 @@ * @version $Id: $Id */ public abstract class FlowSystem implements FlowSystemInterface, java.io.Serializable { - private static final long serialVersionUID = 1000; - - protected FlowNodeInterface[] flowNode; - protected FlowLegInterface[] flowLeg; - protected FileWriterInterface[] fileWriter; - protected String initFlowPattern = "annular"; - protected FlowSystemVisualizationInterface display; - protected TimeSeries timeSeries = new TimeSeries(); - protected GeometryDefinitionInterface[] equipmentGeometry; - protected SystemInterface thermoSystem; - protected ThermodynamicOperations thermoOperations; - protected double inletTemperature = 0, inletPressure = 0, endPressure = 0, systemLength = 0; - protected int numberOfFlowLegs = 0, totalNumberOfNodes = 25; - int[] numberOfNodesInLeg; - double[] legHeights, legPositions, legOuterTemperatures, legOuterHeatTransferCoefficients, - legWallHeatTransferCoefficients; - protected FlowSolverInterface flowSolver; - double inletMolarLiquidFlowRate = 0, inletMolarGasFlowRate = 0; - boolean equilibriumHeatTransfer = true, equilibriumMassTransfer = false; - - /** - *

- * Constructor for FlowSystem. - *

- */ - public FlowSystem() {} - - /** - *

- * Constructor for FlowSystem. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public FlowSystem(SystemInterface system) { - System.out.println("Hei der"); - } - - /** {@inheritDoc} */ - @Override - public void init() {} - - /** {@inheritDoc} */ - @Override - public void createSystem() { - thermoOperations = new ThermodynamicOperations(thermoSystem); - this.flowLegInit(); - } - - /** {@inheritDoc} */ - @Override - public FlowSolverInterface getSolver() { - return flowSolver; - } - - /** {@inheritDoc} */ - @Override - public TimeSeries getTimeSeries() { - return timeSeries; - } - - /** - *

- * flowLegInit. - *

- */ - public void flowLegInit() { - // TODO: add checks that input arguments have correct size to avoid generic - // IndexOutOfBoundsException - for (int i = 0; i < numberOfFlowLegs; i++) { - this.flowLeg[i].setThermoSystem(thermoSystem); - this.flowLeg[i].setEquipmentGeometry(equipmentGeometry[i]); - this.flowLeg[i].setNumberOfNodes(numberOfNodesInLeg[i]); - this.flowLeg[i].setHeightCoordinates(legHeights[i], legHeights[i + 1]); - this.flowLeg[i].setOuterTemperatures(legOuterTemperatures[i], - legOuterTemperatures[i + 1]); - this.flowLeg[i].setLongitudionalCoordinates(legPositions[i], legPositions[i + 1]); - this.flowLeg[i].setOuterHeatTransferCoefficients(legOuterHeatTransferCoefficients[i], - legOuterHeatTransferCoefficients[i + 1]); - this.flowLeg[i].setWallHeatTransferCoefficients(legWallHeatTransferCoefficients[i], - legWallHeatTransferCoefficients[i + 1]); - this.flowLeg[i].createFlowNodes(flowNode[0]); - } - - totalNumberOfNodes = this.calcTotalNumberOfNodes(); - // System.out.println("total number of nodes : " + totalNumberOfNodes); - } - - /** {@inheritDoc} */ - @Override - public void setNodes() { - flowNode[0].setDistanceToCenterOfNode(0.0); - flowNode[0].setVerticalPositionOfNode(legHeights[0]); - flowNode[0].setLengthOfNode(systemLength / 1000.0); - flowNode[0].init(); - - int k = 1; - for (int i = 0; i < numberOfFlowLegs; i++) { - for (int j = 0; j < getNumberOfNodesInLeg(i); j++) { - this.flowNode[k++] = flowLeg[i].getNode(j); - } - } - flowNode[totalNumberOfNodes - 1] = flowNode[totalNumberOfNodes - 2].getNextNode(); - flowNode[totalNumberOfNodes - 1].setLengthOfNode(systemLength / 1000.0); - flowNode[totalNumberOfNodes - 1].setDistanceToCenterOfNode(legPositions[numberOfFlowLegs] - + flowNode[totalNumberOfNodes - 1].getLengthOfNode() / 2.0); - flowNode[totalNumberOfNodes - 1].setVerticalPositionOfNode(legHeights[numberOfFlowLegs]); - if (endPressure != 0) { - flowNode[totalNumberOfNodes - 1].getBulkSystem().setPressure(endPressure); - } - flowNode[totalNumberOfNodes - 1].init(); - } - - /** {@inheritDoc} */ - @Override - public void setInletThermoSystem(SystemInterface thermoSystem) { - this.thermoSystem = thermoSystem; - this.inletPressure = thermoSystem.getPressure(); - this.inletTemperature = thermoSystem.getTemperature(); - } - - /** {@inheritDoc} */ - @Override - public double getSystemLength() { - return systemLength; - } - - /** - *

- * calcTotalNumberOfNodes. - *

- * - * @return a int - */ - public int calcTotalNumberOfNodes() { - int number = 0; - for (int i = 0; i < this.numberOfFlowLegs; i++) { - number += flowLeg[i].getNumberOfNodes(); - } - this.totalNumberOfNodes = number + 2; - return this.totalNumberOfNodes; - } - - /** {@inheritDoc} */ - @Override - public int getTotalNumberOfNodes() { - return this.totalNumberOfNodes; - } - - /** {@inheritDoc} */ - @Override - public double getInletTemperature() { - return this.inletTemperature; - } - - /** {@inheritDoc} */ - @Override - public void setEquipmentGeometry(GeometryDefinitionInterface[] equipmentGeometry) { - this.equipmentGeometry = equipmentGeometry; - } - - /** {@inheritDoc} */ - @Override - public void setEndPressure(double endPressure) { - this.endPressure = endPressure; - } - - /** {@inheritDoc} */ - @Override - public double getInletPressure() { - return this.inletPressure; - } - - /** {@inheritDoc} */ - @Override - public void setNumberOfLegs(int numberOfFlowLegs) { - this.numberOfFlowLegs = numberOfFlowLegs; - } - - /** {@inheritDoc} */ - @Override - public FlowNodeInterface getNode(int i) { - return this.flowNode[i]; - } - - /** {@inheritDoc} */ - @Override - public FlowNodeInterface[] getFlowNodes() { - return this.flowNode; - } - - /** {@inheritDoc} */ - @Override - public int getNumberOfLegs() { - return this.numberOfFlowLegs; - } - - /** {@inheritDoc} */ - @Override - public FlowSystemVisualizationInterface getDisplay() { - return display; - } - - /** {@inheritDoc} */ - @Override - public FileWriterInterface getFileWriter(int i) { - return fileWriter[i]; - } - - /** {@inheritDoc} */ - @Override - public void setNumberOfNodesInLeg(int numberOfNodesInLeg) { - this.numberOfNodesInLeg = new int[this.getNumberOfLegs()]; - for (int i = 0; i < this.getNumberOfLegs(); i++) { - this.numberOfNodesInLeg[i] = numberOfNodesInLeg; - } - totalNumberOfNodes = numberOfNodesInLeg * this.getNumberOfLegs() + 2; - } - - /** {@inheritDoc} */ - @Override - public int getNumberOfNodesInLeg(int i) { - return this.numberOfNodesInLeg[i]; - } - - /** {@inheritDoc} */ - @Override - public void setLegHeights(double[] legHeights) { - this.legHeights = legHeights; - } - - /** {@inheritDoc} */ - @Override - public void setLegPositions(double[] legPositions) { - this.legPositions = legPositions; - this.systemLength = legPositions[legPositions.length - 1]; - } - - /** {@inheritDoc} */ - @Override - public void setLegOuterTemperatures(double[] temps) { - this.legOuterTemperatures = temps; - } - - /** {@inheritDoc} */ - @Override - public void setLegOuterHeatTransferCoefficients(double[] coefs) { - this.legOuterHeatTransferCoefficients = coefs; - } - - /** {@inheritDoc} */ - @Override - public void setLegWallHeatTransferCoefficients(double[] coefs) { - this.legWallHeatTransferCoefficients = coefs; - } - - /** {@inheritDoc} */ - @Override - public double[] getLegHeights() { - return this.legHeights; - } - - /** {@inheritDoc} */ - @Override - public void print() { - for (int i = 0; i < getTotalNumberOfNodes() - 1; i++) { - System.out.println("node " + flowNode[i].getDistanceToCenterOfNode() + " pressure: " - + flowNode[i].getBulkSystem().getPhases()[0].getPressure() + " temperature: " - + flowNode[i].getBulkSystem().getPhases()[1].getTemperature() + " flow: " - + flowNode[i].getMassFlowRate(0) + " velocity: " + flowNode[i].getVelocity() - + " reynolds number " + flowNode[i].getReynoldsNumber() + " friction : " - + flowNode[i].getWallFrictionFactor() + " x1 : " - + flowNode[i].getBulkSystem().getPhases()[0].getComponents()[1].getx()); - } - } - - /** {@inheritDoc} */ - @Override - public void calcFluxes() {} - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - System.out.println("Hei der!"); - } - - /** - *

- * solveTransient. - *

- */ - public void solveTransient() {} - - /** {@inheritDoc} */ - @Override - public double getTotalMolarMassTransferRate(int component) { - double tot = 0.0; - for (int i = 0; i < getTotalNumberOfNodes() - 1; i++) { - tot += flowNode[i].getFluidBoundary().getInterphaseMolarFlux(component) - * flowNode[i].getInterphaseContactArea(); - } - return tot; - } - - /** {@inheritDoc} */ - @Override - public double getTotalMolarMassTransferRate(int component, int lastNode) { - double tot = 0.0; - for (int i = 0; i < lastNode; i++) { - tot += flowNode[i].getFluidBoundary().getInterphaseMolarFlux(component) - * flowNode[i].getInterphaseContactArea(); - } - return tot; - } - - /** {@inheritDoc} */ - @Override - public double getTotalPressureDrop() { - return flowNode[0].getBulkSystem().getPressure() - - flowNode[getTotalNumberOfNodes() - 1].getBulkSystem().getPressure(); - } - - /** {@inheritDoc} */ - @Override - public double getTotalPressureDrop(int lastNode) { - return flowNode[0].getBulkSystem().getPressure() - - flowNode[lastNode].getBulkSystem().getPressure(); - } - - /** {@inheritDoc} */ - @Override - public void setInitialFlowPattern(String flowPattern) { - this.initFlowPattern = flowPattern; - } - - /** {@inheritDoc} */ - @Override - public void setFlowPattern(String flowPattern) { - this.initFlowPattern = flowPattern; - for (int i = 0; i < this.getNumberOfLegs(); i++) { - flowLeg[i].setFlowPattern(flowPattern); - } - } - - /** - *

- * setEquilibriumMassTransferModel. - *

- * - * @param startNode a int - * @param endNode a int - */ - public void setEquilibriumMassTransferModel(int startNode, int endNode) { - for (int i = startNode; i < endNode; i++) { - if (flowNode[i].getBulkSystem().isChemicalSystem()) { - flowNode[i].setInterphaseModelType(0); - } else { - flowNode[i].setInterphaseModelType(0); - } - flowNode[i].getFluidBoundary().setMassTransferCalc(false); - } - } - - /** - *

- * setNonEquilibriumMassTransferModel. - *

- * - * @param startNode a int - * @param endNode a int - */ - public void setNonEquilibriumMassTransferModel(int startNode, int endNode) { - for (int i = startNode; i < endNode; i++) { - if (flowNode[i].getBulkSystem().isChemicalSystem()) { - flowNode[i].setInterphaseModelType(10); - } else { - flowNode[i].setInterphaseModelType(1); - } - flowNode[i].getFluidBoundary().setMassTransferCalc(true); - } - } - - /** - *

- * setNonEquilibriumHeatTransferModel. - *

- * - * @param startNode a int - * @param endNode a int - */ - public void setNonEquilibriumHeatTransferModel(int startNode, int endNode) { - for (int i = startNode; i < endNode; i++) { - flowNode[i].getFluidBoundary().setHeatTransferCalc(true); - } - } - - /** - *

- * setEquilibriumHeatTransferModel. - *

- * - * @param startNode a int - * @param endNode a int - */ - public void setEquilibriumHeatTransferModel(int startNode, int endNode) { - for (int i = startNode; i < endNode; i++) { - flowNode[i].getFluidBoundary().setHeatTransferCalc(false); - } - } - - /** {@inheritDoc} */ - @Override - public void setEquilibriumMassTransfer(boolean test) { - equilibriumMassTransfer = test; - if (equilibriumMassTransfer) { - setEquilibriumMassTransferModel(0, getTotalNumberOfNodes()); - } else { - setNonEquilibriumMassTransferModel(0, getTotalNumberOfNodes()); - } - } - - /** {@inheritDoc} */ - @Override - public void setEquilibriumHeatTransfer(boolean test) { - equilibriumHeatTransfer = test; - if (equilibriumHeatTransfer) { - setEquilibriumHeatTransferModel(0, getTotalNumberOfNodes()); - } else { - setNonEquilibriumHeatTransferModel(0, getTotalNumberOfNodes()); - } - } + private static final long serialVersionUID = 1000; + + /** + * Unique identifier of which solve/run call was last called successfully. + */ + protected UUID calcIdentifier; + + protected FlowNodeInterface[] flowNode; + protected FlowLegInterface[] flowLeg; + protected FileWriterInterface[] fileWriter; + protected String initFlowPattern = "annular"; + protected FlowSystemVisualizationInterface display; + protected TimeSeries timeSeries = new TimeSeries(); + protected GeometryDefinitionInterface[] equipmentGeometry; + protected SystemInterface thermoSystem; + protected ThermodynamicOperations thermoOperations; + protected double inletTemperature = 0, inletPressure = 0, endPressure = 0, systemLength = 0; + protected int numberOfFlowLegs = 0, totalNumberOfNodes = 25; + int[] numberOfNodesInLeg; + double[] legHeights, legPositions, legOuterTemperatures, legOuterHeatTransferCoefficients, + legWallHeatTransferCoefficients; + protected FlowSolverInterface flowSolver; + double inletMolarLiquidFlowRate = 0, inletMolarGasFlowRate = 0; + boolean equilibriumHeatTransfer = true, equilibriumMassTransfer = false; + + /** + *

+ * Constructor for FlowSystem. + *

+ */ + public FlowSystem() {} + + /** + *

+ * Constructor for FlowSystem. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public FlowSystem(SystemInterface system) { + System.out.println("Hei der"); + } + + /** {@inheritDoc} */ + @Override + public void init() {} + + /** {@inheritDoc} */ + @Override + public void createSystem() { + thermoOperations = new ThermodynamicOperations(thermoSystem); + this.flowLegInit(); + } + + /** {@inheritDoc} */ + @Override + public FlowSolverInterface getSolver() { + return flowSolver; + } + + /** {@inheritDoc} */ + @Override + public TimeSeries getTimeSeries() { + return timeSeries; + } + + /** + *

+ * flowLegInit. + *

+ */ + public void flowLegInit() { + // TODO: add checks that input arguments have correct size to avoid generic + // IndexOutOfBoundsException + for (int i = 0; i < numberOfFlowLegs; i++) { + this.flowLeg[i].setThermoSystem(thermoSystem); + this.flowLeg[i].setEquipmentGeometry(equipmentGeometry[i]); + this.flowLeg[i].setNumberOfNodes(numberOfNodesInLeg[i]); + this.flowLeg[i].setHeightCoordinates(legHeights[i], legHeights[i + 1]); + this.flowLeg[i].setOuterTemperatures(legOuterTemperatures[i], legOuterTemperatures[i + 1]); + this.flowLeg[i].setLongitudionalCoordinates(legPositions[i], legPositions[i + 1]); + this.flowLeg[i].setOuterHeatTransferCoefficients(legOuterHeatTransferCoefficients[i], + legOuterHeatTransferCoefficients[i + 1]); + this.flowLeg[i].setWallHeatTransferCoefficients(legWallHeatTransferCoefficients[i], + legWallHeatTransferCoefficients[i + 1]); + this.flowLeg[i].createFlowNodes(flowNode[0]); + } + + totalNumberOfNodes = this.calcTotalNumberOfNodes(); + // System.out.println("total number of nodes : " + totalNumberOfNodes); + } + + /** {@inheritDoc} */ + @Override + public void setNodes() { + flowNode[0].setDistanceToCenterOfNode(0.0); + flowNode[0].setVerticalPositionOfNode(legHeights[0]); + flowNode[0].setLengthOfNode(systemLength / 1000.0); + flowNode[0].init(); + + int k = 1; + for (int i = 0; i < numberOfFlowLegs; i++) { + for (int j = 0; j < getNumberOfNodesInLeg(i); j++) { + this.flowNode[k++] = flowLeg[i].getNode(j); + } + } + flowNode[totalNumberOfNodes - 1] = flowNode[totalNumberOfNodes - 2].getNextNode(); + flowNode[totalNumberOfNodes - 1].setLengthOfNode(systemLength / 1000.0); + flowNode[totalNumberOfNodes - 1].setDistanceToCenterOfNode( + legPositions[numberOfFlowLegs] + flowNode[totalNumberOfNodes - 1].getLengthOfNode() / 2.0); + flowNode[totalNumberOfNodes - 1].setVerticalPositionOfNode(legHeights[numberOfFlowLegs]); + if (endPressure != 0) { + flowNode[totalNumberOfNodes - 1].getBulkSystem().setPressure(endPressure); + } + flowNode[totalNumberOfNodes - 1].init(); + } + + /** {@inheritDoc} */ + @Override + public void setInletThermoSystem(SystemInterface thermoSystem) { + this.thermoSystem = thermoSystem; + this.inletPressure = thermoSystem.getPressure(); + this.inletTemperature = thermoSystem.getTemperature(); + } + + /** {@inheritDoc} */ + @Override + public double getSystemLength() { + return systemLength; + } + + /** + *

+ * calcTotalNumberOfNodes. + *

+ * + * @return a int + */ + public int calcTotalNumberOfNodes() { + int number = 0; + for (int i = 0; i < this.numberOfFlowLegs; i++) { + number += flowLeg[i].getNumberOfNodes(); + } + this.totalNumberOfNodes = number + 2; + return this.totalNumberOfNodes; + } + + /** {@inheritDoc} */ + @Override + public int getTotalNumberOfNodes() { + return this.totalNumberOfNodes; + } + + /** {@inheritDoc} */ + @Override + public double getInletTemperature() { + return this.inletTemperature; + } + + /** {@inheritDoc} */ + @Override + public void setEquipmentGeometry(GeometryDefinitionInterface[] equipmentGeometry) { + this.equipmentGeometry = equipmentGeometry; + } + + /** {@inheritDoc} */ + @Override + public void setEndPressure(double endPressure) { + this.endPressure = endPressure; + } + + /** {@inheritDoc} */ + @Override + public double getInletPressure() { + return this.inletPressure; + } + + /** {@inheritDoc} */ + @Override + public void setNumberOfLegs(int numberOfFlowLegs) { + this.numberOfFlowLegs = numberOfFlowLegs; + } + + /** {@inheritDoc} */ + @Override + public FlowNodeInterface getNode(int i) { + return this.flowNode[i]; + } + + /** {@inheritDoc} */ + @Override + public FlowNodeInterface[] getFlowNodes() { + return this.flowNode; + } + + /** {@inheritDoc} */ + @Override + public int getNumberOfLegs() { + return this.numberOfFlowLegs; + } + + /** {@inheritDoc} */ + @Override + public FlowSystemVisualizationInterface getDisplay() { + return display; + } + + /** {@inheritDoc} */ + @Override + public FileWriterInterface getFileWriter(int i) { + return fileWriter[i]; + } + + /** {@inheritDoc} */ + @Override + public void setNumberOfNodesInLeg(int numberOfNodesInLeg) { + this.numberOfNodesInLeg = new int[this.getNumberOfLegs()]; + for (int i = 0; i < this.getNumberOfLegs(); i++) { + this.numberOfNodesInLeg[i] = numberOfNodesInLeg; + } + totalNumberOfNodes = numberOfNodesInLeg * this.getNumberOfLegs() + 2; + } + + /** {@inheritDoc} */ + @Override + public int getNumberOfNodesInLeg(int i) { + return this.numberOfNodesInLeg[i]; + } + + /** {@inheritDoc} */ + @Override + public void setLegHeights(double[] legHeights) { + this.legHeights = legHeights; + } + + /** {@inheritDoc} */ + @Override + public void setLegPositions(double[] legPositions) { + this.legPositions = legPositions; + this.systemLength = legPositions[legPositions.length - 1]; + } + + /** {@inheritDoc} */ + @Override + public void setLegOuterTemperatures(double[] temps) { + this.legOuterTemperatures = temps; + } + + /** {@inheritDoc} */ + @Override + public void setLegOuterHeatTransferCoefficients(double[] coefs) { + this.legOuterHeatTransferCoefficients = coefs; + } + + /** {@inheritDoc} */ + @Override + public void setLegWallHeatTransferCoefficients(double[] coefs) { + this.legWallHeatTransferCoefficients = coefs; + } + + /** {@inheritDoc} */ + @Override + public double[] getLegHeights() { + return this.legHeights; + } + + /** {@inheritDoc} */ + @Override + public void print() { + for (int i = 0; i < getTotalNumberOfNodes() - 1; i++) { + System.out.println("node " + flowNode[i].getDistanceToCenterOfNode() + " pressure: " + + flowNode[i].getBulkSystem().getPhases()[0].getPressure() + " temperature: " + + flowNode[i].getBulkSystem().getPhases()[1].getTemperature() + " flow: " + + flowNode[i].getMassFlowRate(0) + " velocity: " + flowNode[i].getVelocity() + + " reynolds number " + flowNode[i].getReynoldsNumber() + " friction : " + + flowNode[i].getWallFrictionFactor() + " x1 : " + + flowNode[i].getBulkSystem().getPhases()[0].getComponents()[1].getx()); + } + } + + /** {@inheritDoc} */ + @Override + public void calcFluxes() {} + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + System.out.println("Hei der!"); + } + + /** {@inheritDoc} */ + @Override + public double getTotalMolarMassTransferRate(int component) { + double tot = 0.0; + for (int i = 0; i < getTotalNumberOfNodes() - 1; i++) { + tot += flowNode[i].getFluidBoundary().getInterphaseMolarFlux(component) + * flowNode[i].getInterphaseContactArea(); + } + return tot; + } + + /** {@inheritDoc} */ + @Override + public double getTotalMolarMassTransferRate(int component, int lastNode) { + double tot = 0.0; + for (int i = 0; i < lastNode; i++) { + tot += flowNode[i].getFluidBoundary().getInterphaseMolarFlux(component) + * flowNode[i].getInterphaseContactArea(); + } + return tot; + } + + /** {@inheritDoc} */ + @Override + public double getTotalPressureDrop() { + return flowNode[0].getBulkSystem().getPressure() + - flowNode[getTotalNumberOfNodes() - 1].getBulkSystem().getPressure(); + } + + /** {@inheritDoc} */ + @Override + public double getTotalPressureDrop(int lastNode) { + return flowNode[0].getBulkSystem().getPressure() + - flowNode[lastNode].getBulkSystem().getPressure(); + } + + /** {@inheritDoc} */ + @Override + public void setInitialFlowPattern(String flowPattern) { + this.initFlowPattern = flowPattern; + } + + /** {@inheritDoc} */ + @Override + public void setFlowPattern(String flowPattern) { + this.initFlowPattern = flowPattern; + for (int i = 0; i < this.getNumberOfLegs(); i++) { + flowLeg[i].setFlowPattern(flowPattern); + } + } + + /** + *

+ * setEquilibriumMassTransferModel. + *

+ * + * @param startNode a int + * @param endNode a int + */ + public void setEquilibriumMassTransferModel(int startNode, int endNode) { + for (int i = startNode; i < endNode; i++) { + if (flowNode[i].getBulkSystem().isChemicalSystem()) { + flowNode[i].setInterphaseModelType(0); + } else { + flowNode[i].setInterphaseModelType(0); + } + flowNode[i].getFluidBoundary().setMassTransferCalc(false); + } + } + + /** + *

+ * setNonEquilibriumMassTransferModel. + *

+ * + * @param startNode a int + * @param endNode a int + */ + public void setNonEquilibriumMassTransferModel(int startNode, int endNode) { + for (int i = startNode; i < endNode; i++) { + if (flowNode[i].getBulkSystem().isChemicalSystem()) { + flowNode[i].setInterphaseModelType(10); + } else { + flowNode[i].setInterphaseModelType(1); + } + flowNode[i].getFluidBoundary().setMassTransferCalc(true); + } + } + + /** + *

+ * setNonEquilibriumHeatTransferModel. + *

+ * + * @param startNode a int + * @param endNode a int + */ + public void setNonEquilibriumHeatTransferModel(int startNode, int endNode) { + for (int i = startNode; i < endNode; i++) { + flowNode[i].getFluidBoundary().setHeatTransferCalc(true); + } + } + + /** + *

+ * setEquilibriumHeatTransferModel. + *

+ * + * @param startNode a int + * @param endNode a int + */ + public void setEquilibriumHeatTransferModel(int startNode, int endNode) { + for (int i = startNode; i < endNode; i++) { + flowNode[i].getFluidBoundary().setHeatTransferCalc(false); + } + } + + /** {@inheritDoc} */ + @Override + public void setEquilibriumMassTransfer(boolean test) { + equilibriumMassTransfer = test; + if (equilibriumMassTransfer) { + setEquilibriumMassTransferModel(0, getTotalNumberOfNodes()); + } else { + setNonEquilibriumMassTransferModel(0, getTotalNumberOfNodes()); + } + } + + /** {@inheritDoc} */ + @Override + public void setEquilibriumHeatTransfer(boolean test) { + equilibriumHeatTransfer = test; + if (equilibriumHeatTransfer) { + setEquilibriumHeatTransferModel(0, getTotalNumberOfNodes()); + } else { + setNonEquilibriumHeatTransferModel(0, getTotalNumberOfNodes()); + } + } } diff --git a/src/main/java/neqsim/fluidMechanics/flowSystem/FlowSystemInterface.java b/src/main/java/neqsim/fluidMechanics/flowSystem/FlowSystemInterface.java index 18356fdaff..e5a5a5f9f0 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSystem/FlowSystemInterface.java +++ b/src/main/java/neqsim/fluidMechanics/flowSystem/FlowSystemInterface.java @@ -3,8 +3,10 @@ * * Created on 11. desember 2000, 17:17 */ + package neqsim.fluidMechanics.flowSystem; +import java.util.UUID; import neqsim.fluidMechanics.flowNode.FlowNodeInterface; import neqsim.fluidMechanics.flowSolver.FlowSolverInterface; import neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface; @@ -22,346 +24,372 @@ * @version $Id: $Id */ public interface FlowSystemInterface { - /** - *

- * init. - *

- */ - public void init(); - - /** - *

- * setNodes. - *

- */ - public void setNodes(); - - /** - *

- * solveTransient. - *

- * - * @param type a int - */ - public void solveTransient(int type); - - /** - *

- * getTimeSeries. - *

- * - * @return a {@link neqsim.fluidMechanics.util.timeSeries.TimeSeries} object - */ - public TimeSeries getTimeSeries(); - - /** - *

- * getDisplay. - *

- * - * @return a - * {@link neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowSystemVisualization.FlowSystemVisualizationInterface} - * object - */ - public FlowSystemVisualizationInterface getDisplay(); - - /** - *

- * getFileWriter. - *

- * - * @param i a int - * @return a {@link neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.FileWriterInterface} - * object - */ - public FileWriterInterface getFileWriter(int i); - - /** - *

- * getSolver. - *

- * - * @return a {@link neqsim.fluidMechanics.flowSolver.FlowSolverInterface} object - */ - public FlowSolverInterface getSolver(); - - /** - *

- * getInletTemperature. - *

- * - * @return a double - */ - public double getInletTemperature(); - - /** - *

- * getInletPressure. - *

- * - * @return a double - */ - public double getInletPressure(); - - /** - *

- * setNumberOfLegs. - *

- * - * @param numberOfLegs a int - */ - public void setNumberOfLegs(int numberOfLegs); - - /** - *

- * getNumberOfLegs. - *

- * - * @return a int - */ - public int getNumberOfLegs(); - - /** - *

- * setNumberOfNodesInLeg. - *

- * - * @param numberOfNodesInLeg a int - */ - public void setNumberOfNodesInLeg(int numberOfNodesInLeg); - - /** - *

- * getNumberOfNodesInLeg. - *

- * - * @param i a int - * @return a int - */ - public int getNumberOfNodesInLeg(int i); - - /** - *

- * setLegHeights. - *

- * - * @param legHeights an array of {@link double} objects - */ - public void setLegHeights(double[] legHeights); - - /** - *

- * getLegHeights. - *

- * - * @return an array of {@link double} objects - */ - public double[] getLegHeights(); - - /** - *

- * setLegPositions. - *

- * - * @param legPositions an array of {@link double} objects - */ - public void setLegPositions(double[] legPositions); - - /** - *

- * createSystem. - *

- */ - public void createSystem(); - - /** - *

- * getNode. - *

- * - * @param i a int - * @return a {@link neqsim.fluidMechanics.flowNode.FlowNodeInterface} object - */ - public FlowNodeInterface getNode(int i); - - /** - *

- * getSystemLength. - *

- * - * @return a double - */ - public double getSystemLength(); - - /** - *

- * setLegOuterHeatTransferCoefficients. - *

- * - * @param coefs an array of {@link double} objects - */ - public void setLegOuterHeatTransferCoefficients(double[] coefs); - - /** - *

- * setLegWallHeatTransferCoefficients. - *

- * - * @param coefs an array of {@link double} objects - */ - public void setLegWallHeatTransferCoefficients(double[] coefs); - - /** - *

- * setEquipmentGeometry. - *

- * - * @param equipmentGeometry an array of - * {@link neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface} objects - */ - public void setEquipmentGeometry(GeometryDefinitionInterface[] equipmentGeometry); - - /** - *

- * getTotalNumberOfNodes. - *

- * - * @return a int - */ - public int getTotalNumberOfNodes(); - - /** - *

- * calcFluxes. - *

- */ - public void calcFluxes(); - - /** - *

- * setEndPressure. - *

- * - * @param inletPressure a double - */ - public void setEndPressure(double inletPressure); - - /** - *

- * setInletThermoSystem. - *

- * - * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - public void setInletThermoSystem(SystemInterface thermoSystem); - - /** - *

- * solveSteadyState. - *

- * - * @param type a int - */ - public void solveSteadyState(int type); - - /** - *

- * getFlowNodes. - *

- * - * @return an array of {@link neqsim.fluidMechanics.flowNode.FlowNodeInterface} objects - */ - public FlowNodeInterface[] getFlowNodes(); - - /** - *

- * print. - *

- */ - public void print(); - - /** - *

- * setLegOuterTemperatures. - *

- * - * @param temps an array of {@link double} objects - */ - public void setLegOuterTemperatures(double[] temps); - - /** - *

- * getTotalMolarMassTransferRate. - *

- * - * @param component a int - * @return a double - */ - public double getTotalMolarMassTransferRate(int component); - - /** - *

- * getTotalMolarMassTransferRate. - *

- * - * @param component a int - * @param lastNode a int - * @return a double - */ - public double getTotalMolarMassTransferRate(int component, int lastNode); - - /** - *

- * getTotalPressureDrop. - *

- * - * @return a double - */ - public double getTotalPressureDrop(); - - /** - *

- * getTotalPressureDrop. - *

- * - * @param lastNode a int - * @return a double - */ - public double getTotalPressureDrop(int lastNode); - - /** - *

- * setInitialFlowPattern. - *

- * - * @param flowPattern a {@link java.lang.String} object - */ - public void setInitialFlowPattern(String flowPattern); - - /** - *

- * setFlowPattern. - *

- * - * @param flowPattern a {@link java.lang.String} object - */ - public void setFlowPattern(String flowPattern); - - /** - *

- * setEquilibriumMassTransfer. - *

- * - * @param test a boolean - */ - public void setEquilibriumMassTransfer(boolean test); - - /** - *

- * setEquilibriumHeatTransfer. - *

- * - * @param test a boolean - */ - public void setEquilibriumHeatTransfer(boolean test); + /** + *

+ * init. + *

+ */ + public void init(); + + /** + *

+ * setNodes. + *

+ */ + public void setNodes(); + + /** + *

+ * solveTransient. + *

+ * + * @param type a int + */ + public default void solveTransient(int type) { + solveTransient(type, UUID.randomUUID()); + } + + /** + *

+ * solveTransient. + *

+ * + * @param type a int + * @param id Calculation identifier + */ + public void solveTransient(int type, UUID id); + + /** + *

+ * getTimeSeries. + *

+ * + * @return a {@link neqsim.fluidMechanics.util.timeSeries.TimeSeries} object + */ + public TimeSeries getTimeSeries(); + + /** + *

+ * getDisplay. + *

+ * + * @return a + * {@link neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowSystemVisualization.FlowSystemVisualizationInterface} + * object + */ + public FlowSystemVisualizationInterface getDisplay(); + + /** + *

+ * getFileWriter. + *

+ * + * @param i a int + * @return a {@link neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.FileWriterInterface} + * object + */ + public FileWriterInterface getFileWriter(int i); + + /** + *

+ * getSolver. + *

+ * + * @return a {@link neqsim.fluidMechanics.flowSolver.FlowSolverInterface} object + */ + public FlowSolverInterface getSolver(); + + /** + *

+ * getInletTemperature. + *

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

+ * getInletPressure. + *

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

+ * setNumberOfLegs. + *

+ * + * @param numberOfLegs a int + */ + public void setNumberOfLegs(int numberOfLegs); + + /** + *

+ * getNumberOfLegs. + *

+ * + * @return a int + */ + public int getNumberOfLegs(); + + /** + *

+ * setNumberOfNodesInLeg. + *

+ * + * @param numberOfNodesInLeg a int + */ + public void setNumberOfNodesInLeg(int numberOfNodesInLeg); + + /** + *

+ * getNumberOfNodesInLeg. + *

+ * + * @param i a int + * @return a int + */ + public int getNumberOfNodesInLeg(int i); + + /** + *

+ * setLegHeights. + *

+ * + * @param legHeights an array of {@link double} objects + */ + public void setLegHeights(double[] legHeights); + + /** + *

+ * getLegHeights. + *

+ * + * @return an array of {@link double} objects + */ + public double[] getLegHeights(); + + /** + *

+ * setLegPositions. + *

+ * + * @param legPositions an array of {@link double} objects + */ + public void setLegPositions(double[] legPositions); + + /** + *

+ * createSystem. + *

+ */ + public void createSystem(); + + /** + *

+ * getNode. + *

+ * + * @param i a int + * @return a {@link neqsim.fluidMechanics.flowNode.FlowNodeInterface} object + */ + public FlowNodeInterface getNode(int i); + + /** + *

+ * getSystemLength. + *

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

+ * setLegOuterHeatTransferCoefficients. + *

+ * + * @param coefs an array of {@link double} objects + */ + public void setLegOuterHeatTransferCoefficients(double[] coefs); + + /** + *

+ * setLegWallHeatTransferCoefficients. + *

+ * + * @param coefs an array of {@link double} objects + */ + public void setLegWallHeatTransferCoefficients(double[] coefs); + + /** + *

+ * setEquipmentGeometry. + *

+ * + * @param equipmentGeometry an array of + * {@link neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface} objects + */ + public void setEquipmentGeometry(GeometryDefinitionInterface[] equipmentGeometry); + + /** + *

+ * getTotalNumberOfNodes. + *

+ * + * @return a int + */ + public int getTotalNumberOfNodes(); + + /** + *

+ * calcFluxes. + *

+ */ + public void calcFluxes(); + + /** + *

+ * setEndPressure. + *

+ * + * @param inletPressure a double + */ + public void setEndPressure(double inletPressure); + + /** + *

+ * setInletThermoSystem. + *

+ * + * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object + */ + public void setInletThermoSystem(SystemInterface thermoSystem); + + /** + *

+ * solveSteadyState. + *

+ * + * @param type a int 1: just mass, 2: mass and energy, 3: mass, energy and energy impulse and + * components + */ + public default void solveSteadyState(int type) { + solveSteadyState(type, UUID.randomUUID()); + } + + /** + *

+ * solveSteadyState. + *

+ * + * @param type a int 1: just mass, 2: mass and energy, 3: mass, energy and energy impulse and + * components + * @param id Calculation identifier + */ + public void solveSteadyState(int type, UUID id); + + /** + *

+ * getFlowNodes. + *

+ * + * @return an array of {@link neqsim.fluidMechanics.flowNode.FlowNodeInterface} objects + */ + public FlowNodeInterface[] getFlowNodes(); + + /** + *

+ * print. + *

+ */ + public void print(); + + /** + *

+ * setLegOuterTemperatures. + *

+ * + * @param temps an array of {@link double} objects + */ + public void setLegOuterTemperatures(double[] temps); + + /** + *

+ * getTotalMolarMassTransferRate. + *

+ * + * @param component a int + * @return a double + */ + public double getTotalMolarMassTransferRate(int component); + + /** + *

+ * getTotalMolarMassTransferRate. + *

+ * + * @param component a int + * @param lastNode a int + * @return a double + */ + public double getTotalMolarMassTransferRate(int component, int lastNode); + + /** + *

+ * getTotalPressureDrop. + *

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

+ * getTotalPressureDrop. + *

+ * + * @param lastNode a int + * @return a double + */ + public double getTotalPressureDrop(int lastNode); + + /** + *

+ * setInitialFlowPattern. + *

+ * + * @param flowPattern a {@link java.lang.String} object + */ + public void setInitialFlowPattern(String flowPattern); + + /** + *

+ * setFlowPattern. + *

+ * + * @param flowPattern a {@link java.lang.String} object + */ + public void setFlowPattern(String flowPattern); + + /** + *

+ * setEquilibriumMassTransfer. + *

+ * + * @param test a boolean + */ + public void setEquilibriumMassTransfer(boolean test); + + /** + *

+ * setEquilibriumHeatTransfer. + *

+ * + * @param test a boolean + */ + public void setEquilibriumHeatTransfer(boolean test); } diff --git a/src/main/java/neqsim/fluidMechanics/flowSystem/onePhaseFlowSystem/pipeFlowSystem/PipeFlowSystem.java b/src/main/java/neqsim/fluidMechanics/flowSystem/onePhaseFlowSystem/pipeFlowSystem/PipeFlowSystem.java index a8534d2d0e..c54558ced2 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSystem/onePhaseFlowSystem/pipeFlowSystem/PipeFlowSystem.java +++ b/src/main/java/neqsim/fluidMechanics/flowSystem/onePhaseFlowSystem/pipeFlowSystem/PipeFlowSystem.java @@ -1,5 +1,6 @@ package neqsim.fluidMechanics.flowSystem.onePhaseFlowSystem.pipeFlowSystem; +import java.util.UUID; import neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowSystemVisualization.onePhaseFlowVisualization.pipeFlowVisualization.PipeFlowVisualization; import neqsim.thermo.system.SystemInterface; @@ -12,99 +13,99 @@ * @version $Id: $Id */ public class PipeFlowSystem - extends neqsim.fluidMechanics.flowSystem.onePhaseFlowSystem.OnePhaseFlowSystem { - private static final long serialVersionUID = 1000; + extends neqsim.fluidMechanics.flowSystem.onePhaseFlowSystem.OnePhaseFlowSystem { + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for PipeFlowSystem. - *

- */ - public PipeFlowSystem() {} + /** + *

+ * Constructor for PipeFlowSystem. + *

+ */ + public PipeFlowSystem() {} - /** {@inheritDoc} */ - @Override - public void createSystem() { - thermoSystem.init(0); - thermoSystem.init(1); - flowLeg = new neqsim.fluidMechanics.flowLeg.pipeLeg.PipeLeg[this.getNumberOfLegs()]; + /** {@inheritDoc} */ + @Override + public void createSystem() { + thermoSystem.init(0); + thermoSystem.init(1); + flowLeg = new neqsim.fluidMechanics.flowLeg.pipeLeg.PipeLeg[this.getNumberOfLegs()]; - for (int i = 0; i < getNumberOfLegs(); i++) { - flowLeg[i] = new neqsim.fluidMechanics.flowLeg.pipeLeg.PipeLeg(); - } - - flowNode = - new neqsim.fluidMechanics.flowNode.onePhaseNode.onePhasePipeFlowNode.onePhasePipeFlowNode[totalNumberOfNodes]; - // System.out.println("nodes: " + totalNumberOfNodes); - flowNode[0] = - new neqsim.fluidMechanics.flowNode.onePhaseNode.onePhasePipeFlowNode.onePhasePipeFlowNode( - thermoSystem, this.equipmentGeometry[0]); - flowNode[0].initFlowCalc(); - super.createSystem(); - this.setNodes(); + for (int i = 0; i < getNumberOfLegs(); i++) { + flowLeg[i] = new neqsim.fluidMechanics.flowLeg.pipeLeg.PipeLeg(); } - /** {@inheritDoc} */ - @Override - public void init() { - for (int j = 0; j < getTotalNumberOfNodes(); j++) { - flowNode[j].initFlowCalc(); - flowNode[j].setVelocityIn(this.flowNode[j].getVelocity()); - } + flowNode = + new neqsim.fluidMechanics.flowNode.onePhaseNode.onePhasePipeFlowNode.onePhasePipeFlowNode[totalNumberOfNodes]; + // System.out.println("nodes: " + totalNumberOfNodes); + flowNode[0] = + new neqsim.fluidMechanics.flowNode.onePhaseNode.onePhasePipeFlowNode.onePhasePipeFlowNode( + thermoSystem, this.equipmentGeometry[0]); + flowNode[0].initFlowCalc(); + super.createSystem(); + this.setNodes(); + } - for (int k = 0; k < getTotalNumberOfNodes() - 1; k++) { - this.flowNode[k].setVelocityOut(this.flowNode[k + 1].getVelocityIn()); - } + /** {@inheritDoc} */ + @Override + public void init() { + for (int j = 0; j < getTotalNumberOfNodes(); j++) { + flowNode[j].initFlowCalc(); + flowNode[j].setVelocityIn(this.flowNode[j].getVelocity()); } - /** {@inheritDoc} */ - @Override - public void solveSteadyState(int solverType) { // should set solve-type: int 1-bare masse og - // impuls 2 energi og - // impuls 3 energi impuls og komponenter - double[] times = {0.0}; - display = new PipeFlowVisualization(this.getTotalNumberOfNodes(), 1); - getTimeSeries().setTimes(times); - SystemInterface[] systems = {flowNode[0].getBulkSystem()}; - getTimeSeries().setInletThermoSystems(systems); - getTimeSeries().setNumberOfTimeStepsInInterval(1); - double[] outletFlowRates = {0.0, 0.0}; // this is not yet implemented - getTimeSeries().setOutletMolarFlowRate(outletFlowRates); - // SteadystateOnePhasePipeFlowSolver pipeSolve = new - // SteadystateOnePhasePipeFlowSolver(this, getSystemLength(), - // getTotalNumberOfNodes()); - flowSolver = - new neqsim.fluidMechanics.flowSolver.onePhaseFlowSolver.onePhasePipeFlowSolver.OnePhaseFixedStaggeredGrid( - this, getSystemLength(), getTotalNumberOfNodes(), false); - flowSolver.setSolverType(solverType); - flowSolver.solveTDMA(); - getTimeSeries().init(this); - display.setNextData(this); + for (int k = 0; k < getTotalNumberOfNodes() - 1; k++) { + this.flowNode[k].setVelocityOut(this.flowNode[k + 1].getVelocityIn()); } + } + + /** {@inheritDoc} */ + @Override + public void solveSteadyState(int type, UUID id) { + double[] times = {0.0}; + display = new PipeFlowVisualization(this.getTotalNumberOfNodes(), 1); + getTimeSeries().setTimes(times); + SystemInterface[] systems = {flowNode[0].getBulkSystem()}; + getTimeSeries().setInletThermoSystems(systems); + getTimeSeries().setNumberOfTimeStepsInInterval(1); + double[] outletFlowRates = {0.0, 0.0}; // this is not yet implemented + getTimeSeries().setOutletMolarFlowRate(outletFlowRates); + // SteadystateOnePhasePipeFlowSolver pipeSolve = new + // SteadystateOnePhasePipeFlowSolver(this, getSystemLength(), + // getTotalNumberOfNodes()); + flowSolver = + new neqsim.fluidMechanics.flowSolver.onePhaseFlowSolver.onePhasePipeFlowSolver.OnePhaseFixedStaggeredGrid( + this, getSystemLength(), getTotalNumberOfNodes(), false); + flowSolver.setSolverType(type); + flowSolver.solveTDMA(); + getTimeSeries().init(this); + display.setNextData(this); + calcIdentifier = id; + } - /** {@inheritDoc} */ - @Override - public void solveTransient(int solverType) { - getTimeSeries().init(this); - display = new PipeFlowVisualization(this.getTotalNumberOfNodes(), - getTimeSeries().getTime().length); - flowSolver.setDynamic(true); - flowSolver.setSolverType(solverType); - for (int i = 0; i < this.getTimeSeries().getTime().length; i++) { - getNode(0).setBulkSystem(this.getTimeSeries().getThermoSystem()[i]); - // getNode(0).getBulkSystem().setPressure(); - getNode(0).initFlowCalc(); - getNode(0).setVelocityIn(getNode(0).getVelocity()); - flowNode[0].setVelocityOut(this.flowNode[0].getVelocity()); - // flowNode[1].setVelocityIn(this.flowNode[0].getVelocity()); - // flowNode[getTotalNumberOfNodes()-1].setVelocity(this.getTimeSeries().getOutletMolarFlowRates()[i]); - System.out.println("vel: " + this.flowNode[0].getVelocity()); - getSolver().setTimeStep(this.getTimeSeries().getTimeStep()[i]); - // System.out.println("time step: " + i + " " + - // this.getTimeSeries().getTimeStep()[i]); - // System.out.println("time: " + i + " " + this.getTimeSeries().getTime()[i]); - // flowSolver.solveTDMA(); - display.setNextData(this, this.getTimeSeries().getTime(i)); - } + /** {@inheritDoc} */ + @Override + public void solveTransient(int type, UUID id) { + getTimeSeries().init(this); + display = + new PipeFlowVisualization(this.getTotalNumberOfNodes(), getTimeSeries().getTime().length); + flowSolver.setDynamic(true); + flowSolver.setSolverType(type); + for (int i = 0; i < this.getTimeSeries().getTime().length; i++) { + getNode(0).setBulkSystem(this.getTimeSeries().getThermoSystem()[i]); + // getNode(0).getBulkSystem().setPressure(); + getNode(0).initFlowCalc(); + getNode(0).setVelocityIn(getNode(0).getVelocity()); + flowNode[0].setVelocityOut(this.flowNode[0].getVelocity()); + // flowNode[1].setVelocityIn(this.flowNode[0].getVelocity()); + // flowNode[getTotalNumberOfNodes()-1].setVelocity(this.getTimeSeries().getOutletMolarFlowRates()[i]); + System.out.println("vel: " + this.flowNode[0].getVelocity()); + getSolver().setTimeStep(this.getTimeSeries().getTimeStep()[i]); + // System.out.println("time step: " + i + " " + + // this.getTimeSeries().getTimeStep()[i]); + // System.out.println("time: " + i + " " + this.getTimeSeries().getTime()[i]); + // flowSolver.solveTDMA(); + display.setNextData(this, this.getTimeSeries().getTime(i)); } + calcIdentifier = id; + } } diff --git a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/shipSystem/LNGship.java b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/shipSystem/LNGship.java index 58aae622a4..bd6d4b4336 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/shipSystem/LNGship.java +++ b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/shipSystem/LNGship.java @@ -1,6 +1,7 @@ package neqsim.fluidMechanics.flowSystem.twoPhaseFlowSystem.shipSystem; import java.text.DecimalFormat; +import java.util.UUID; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.standards.StandardInterface; @@ -19,571 +20,568 @@ * @version $Id: $Id */ public class LNGship - extends neqsim.fluidMechanics.flowSystem.twoPhaseFlowSystem.TwoPhaseFlowSystem { - private static final long serialVersionUID = 1000; - - double[] temperature = null; - double dailyBoilOffRatio = 0.005, totalTankVolume = 140000; - private double liquidDensity = 0.7; - int numberOffTimeSteps = 100; - private double initialTemperature = 111.0; - private boolean setInitialTemperature = false; - private neqsim.thermo.system.SystemInterface thermoSystem = null; - double initialNumberOffMoles; - double molarBoilOffRate = 0.0, dailyBoilOffVolume = 0.0; - private double endTime = 960;// 24.0 * 10; - private Standard_ISO6976 standardISO6976 = null; - StandardInterface standardDensity = null; - double[] WI = null, density = null, volume = null, xmethane, xethane, xpropane, xiC4, xnC4, - xiC5, xnC5, xnC6, xnitrogen; - double[] ymethane, yethane, ypropane, yiC4, ynC4, yiC5, ynC5, ynC6, ynitrogen; - double[] GCV, GCVmass, totalEnergy; - double[] time; - double[] tankTemperature = null; - double timeStep = 0; - private String[][] resultTable = null; - private boolean backCalculate = false; - double endVolume = 0.0; - static Logger logger = LogManager.getLogger(LNGship.class); - - /** - *

- * Constructor for LNGship. - *

- * - * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object - * @param totalTankVolume a double - * @param dailyBoilOffRatio a double - */ - public LNGship(neqsim.thermo.system.SystemInterface thermoSystem, double totalTankVolume, - double dailyBoilOffRatio) { - this.thermoSystem = thermoSystem; - this.totalTankVolume = totalTankVolume; - this.dailyBoilOffRatio = dailyBoilOffRatio; - - setStandardISO6976(new Standard_ISO6976_2016(thermoSystem, 0, 25, "volume")); + extends neqsim.fluidMechanics.flowSystem.twoPhaseFlowSystem.TwoPhaseFlowSystem { + private static final long serialVersionUID = 1000; + + double[] temperature = null; + double dailyBoilOffRatio = 0.005, totalTankVolume = 140000; + private double liquidDensity = 0.7; + int numberOffTimeSteps = 100; + private double initialTemperature = 111.0; + private boolean setInitialTemperature = false; + private neqsim.thermo.system.SystemInterface thermoSystem = null; + double initialNumberOffMoles; + double molarBoilOffRate = 0.0, dailyBoilOffVolume = 0.0; + private double endTime = 960;// 24.0 * 10; + private Standard_ISO6976 standardISO6976 = null; + StandardInterface standardDensity = null; + double[] WI = null, density = null, volume = null, xmethane, xethane, xpropane, xiC4, xnC4, xiC5, + xnC5, xnC6, xnitrogen; + double[] ymethane, yethane, ypropane, yiC4, ynC4, yiC5, ynC5, ynC6, ynitrogen; + double[] GCV, GCVmass, totalEnergy; + double[] time; + double[] tankTemperature = null; + double timeStep = 0; + private String[][] resultTable = null; + private boolean backCalculate = false; + double endVolume = 0.0; + static Logger logger = LogManager.getLogger(LNGship.class); + + /** + *

+ * Constructor for LNGship. + *

+ * + * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object + * @param totalTankVolume a double + * @param dailyBoilOffRatio a double + */ + public LNGship(neqsim.thermo.system.SystemInterface thermoSystem, double totalTankVolume, + double dailyBoilOffRatio) { + this.thermoSystem = thermoSystem; + this.totalTankVolume = totalTankVolume; + this.dailyBoilOffRatio = dailyBoilOffRatio; + + setStandardISO6976(new Standard_ISO6976_2016(thermoSystem, 0, 25, "volume")); + } + + /** + *

+ * useStandardVersion. + *

+ * + * @param isoName a {@link java.lang.String} object + * @param version a {@link java.lang.String} object + */ + public void useStandardVersion(String isoName, String version) { + if (version.equals("2016")) { + setStandardISO6976(new Standard_ISO6976(thermoSystem, getStandardISO6976().getVolRefT(), + getStandardISO6976().getEnergyRefT(), "volume")); + logger.info("using ISO6976 version 2016"); + } else { + setStandardISO6976(new Standard_ISO6976_2016(thermoSystem, getStandardISO6976().getVolRefT(), + getStandardISO6976().getEnergyRefT(), "volume")); + logger.info("using ISO6976 version 1995"); } - - /** - *

- * useStandardVersion. - *

- * - * @param isoName a {@link java.lang.String} object - * @param version a {@link java.lang.String} object - */ - public void useStandardVersion(String isoName, String version) { - if (version.equals("2016")) { - setStandardISO6976(new Standard_ISO6976(thermoSystem, getStandardISO6976().getVolRefT(), - getStandardISO6976().getEnergyRefT(), "volume")); - logger.info("using ISO6976 version 2016"); - } else { - setStandardISO6976( - new Standard_ISO6976_2016(thermoSystem, getStandardISO6976().getVolRefT(), - getStandardISO6976().getEnergyRefT(), "volume")); - logger.info("using ISO6976 version 1995"); - } + } + + /** {@inheritDoc} */ + @Override + public void createSystem() { + getThermoSystem().init(0); + thermoOperations = new ThermodynamicOperations(getThermoSystem()); + try { + if (isSetInitialTemperature()) { + getThermoSystem().setTemperature(getInitialTemperature()); + } else { + thermoOperations.bubblePointTemperatureFlash(); + } + } catch (Exception e) { + e.printStackTrace(); } + getThermoSystem().init(0); - /** {@inheritDoc} */ - @Override - public void createSystem() { - getThermoSystem().init(0); - thermoOperations = new ThermodynamicOperations(getThermoSystem()); - try { - if (isSetInitialTemperature()) { - getThermoSystem().setTemperature(getInitialTemperature()); - } else { - thermoOperations.bubblePointTemperatureFlash(); - } - } catch (Exception e) { - e.printStackTrace(); - } - getThermoSystem().init(0); + standardDensity = new Standard_ISO6578(getThermoSystem()); + standardDensity.calculate(); - standardDensity = new Standard_ISO6578(getThermoSystem()); - standardDensity.calculate(); + liquidDensity = standardDensity.getValue("density"); + logger.info("density start " + standardDensity.getValue("density")); + timeStep = getEndTime() / (numberOffTimeSteps * 1.0 - 1.0); + dailyBoilOffVolume = totalTankVolume * dailyBoilOffRatio; - liquidDensity = standardDensity.getValue("density"); - logger.info("density start " + standardDensity.getValue("density")); - timeStep = getEndTime() / (numberOffTimeSteps * 1.0 - 1.0); - dailyBoilOffVolume = totalTankVolume * dailyBoilOffRatio; + logger.info("daily boiloff volume " + dailyBoilOffVolume); + initialNumberOffMoles = + totalTankVolume * getLiquidDensity() / getThermoSystem().getPhase(1).getMolarMass(); + double oldMoles = getThermoSystem().getTotalNumberOfMoles(); - logger.info("daily boiloff volume " + dailyBoilOffVolume); - initialNumberOffMoles = - totalTankVolume * getLiquidDensity() / getThermoSystem().getPhase(1).getMolarMass(); - double oldMoles = getThermoSystem().getTotalNumberOfMoles(); - - for (int i = 0; i < getThermoSystem().getPhase(0).getNumberOfComponents(); i++) { - getThermoSystem().addComponent(getThermoSystem().getPhase(0).getComponent(i).getName(), - (initialNumberOffMoles - oldMoles) - * getThermoSystem().getPhase(0).getComponent(i).getz()); - } + for (int i = 0; i < getThermoSystem().getPhase(0).getNumberOfComponents(); i++) { + getThermoSystem().addComponent(getThermoSystem().getPhase(0).getComponent(i).getName(), + (initialNumberOffMoles - oldMoles) + * getThermoSystem().getPhase(0).getComponent(i).getz()); } - - /** {@inheritDoc} */ - @Override - public void init() {} - - /** {@inheritDoc} */ - @Override - public void solveSteadyState(int solverType) { - try { - if (!isSetInitialTemperature()) { - thermoOperations.bubblePointTemperatureFlash(); - } - } catch (Exception e) { - e.printStackTrace(); - } - logger.info("temperature start " + getThermoSystem().getTemperature()); + } + + /** {@inheritDoc} */ + @Override + public void init() {} + + /** {@inheritDoc} */ + @Override + public void solveSteadyState(int type, UUID id) { + // todo: double[] times = {0.0}; ? + try { + if (!isSetInitialTemperature()) { + thermoOperations.bubblePointTemperatureFlash(); + } + } catch (Exception e) { + e.printStackTrace(); } - - /** {@inheritDoc} */ - @Override - public void solveTransient(int type) { - SystemInterface tempThermoSystem = getThermoSystem().clone(); - WI = new double[numberOffTimeSteps]; - GCV = new double[numberOffTimeSteps]; - GCVmass = new double[numberOffTimeSteps]; - totalEnergy = new double[numberOffTimeSteps]; - time = new double[numberOffTimeSteps]; - density = new double[numberOffTimeSteps]; - tankTemperature = new double[numberOffTimeSteps]; - volume = new double[numberOffTimeSteps]; - - xnitrogen = new double[numberOffTimeSteps]; - xmethane = new double[numberOffTimeSteps]; - xethane = new double[numberOffTimeSteps]; - xpropane = new double[numberOffTimeSteps]; - xiC4 = new double[numberOffTimeSteps]; - xnC4 = new double[numberOffTimeSteps]; - xiC5 = new double[numberOffTimeSteps]; - xnC5 = new double[numberOffTimeSteps]; - xnC6 = new double[numberOffTimeSteps]; - - ynitrogen = new double[numberOffTimeSteps]; - ymethane = new double[numberOffTimeSteps]; - yethane = new double[numberOffTimeSteps]; - ypropane = new double[numberOffTimeSteps]; - yiC4 = new double[numberOffTimeSteps]; - ynC4 = new double[numberOffTimeSteps]; - yiC5 = new double[numberOffTimeSteps]; - ynC5 = new double[numberOffTimeSteps]; - ynC6 = new double[numberOffTimeSteps]; - - double error = 100.0; - double mulitplicator = 1.0; - if (backCalculate) { - mulitplicator = -1.0; - } - endVolume = totalTankVolume - mulitplicator * dailyBoilOffVolume * getEndTime() / 24.0; - molarBoilOffRate = dailyBoilOffVolume * liquidDensity - / getThermoSystem().getPhase(1).getMolarMass() / 24.0 * timeStep; - if (backCalculate) { - molarBoilOffRate = -molarBoilOffRate; - } - // double orginalMolarBoilOff = molarBoilOffRate; - logger.info("end Volume " + endVolume); - int iterations = 0; - double boilOffCorrection = 0.0; - do { - setThermoSystem(tempThermoSystem.clone()); - thermoOperations = new ThermodynamicOperations(getThermoSystem()); - standardDensity = new Standard_ISO6578(getThermoSystem()); - getStandardISO6976().setThermoSystem(getThermoSystem()); - iterations++; - for (int j = 0; j < numberOffTimeSteps; j++) { - time[j] = j * timeStep; - try { - if (!(j == 0 && isSetInitialTemperature())) { - thermoOperations.bubblePointTemperatureFlash(); - } - } catch (Exception e) { - e.printStackTrace(); - } - double[] xgas = new double[getThermoSystem().getPhase(0).getNumberOfComponents()]; - - for (int kk = 0; kk < getThermoSystem().getPhase(0).getNumberOfComponents(); kk++) { - xgas[kk] = getThermoSystem().getPhase(0).getComponent(kk).getx(); - } - - if (getThermoSystem().getPhase(0).hasComponent("nitrogen")) { - xnitrogen[j] = getThermoSystem().getPhase(1).getComponent("nitrogen").getx(); - ynitrogen[j] = getThermoSystem().getPhase(0).getComponent("nitrogen").getx(); - } - if (getThermoSystem().getPhase(0).hasComponent("methane")) { - xmethane[j] = getThermoSystem().getPhase(1).getComponent("methane").getx(); - ymethane[j] = getThermoSystem().getPhase(0).getComponent("methane").getx(); - } - if (getThermoSystem().getPhase(0).hasComponent("ethane")) { - xethane[j] = getThermoSystem().getPhase(1).getComponent("ethane").getx(); - yethane[j] = getThermoSystem().getPhase(0).getComponent("ethane").getx(); - } - if (getThermoSystem().getPhase(0).hasComponent("propane")) { - xpropane[j] = getThermoSystem().getPhase(1).getComponent("propane").getx(); - ypropane[j] = getThermoSystem().getPhase(0).getComponent("propane").getx(); - } - if (getThermoSystem().getPhase(0).hasComponent("i-butane")) { - xiC4[j] = getThermoSystem().getPhase(1).getComponent("i-butane").getx(); - yiC4[j] = getThermoSystem().getPhase(0).getComponent("i-butane").getx(); - } - if (getThermoSystem().getPhase(0).hasComponent("n-butane")) { - xnC4[j] = getThermoSystem().getPhase(1).getComponent("n-butane").getx(); - ynC4[j] = getThermoSystem().getPhase(0).getComponent("n-butane").getx(); - } - if (getThermoSystem().getPhase(0).hasComponent("i-pentane")) { - xiC5[j] = getThermoSystem().getPhase(1).getComponent("i-pentane").getx(); - yiC5[j] = getThermoSystem().getPhase(0).getComponent("i-pentane").getx(); - } - if (getThermoSystem().getPhase(0).hasComponent("n-pentane")) { - xnC5[j] = getThermoSystem().getPhase(1).getComponent("n-pentane").getx(); - ynC5[j] = getThermoSystem().getPhase(0).getComponent("n-pentane").getx(); - } - if (getThermoSystem().getPhase(0).hasComponent("n-hexane")) { - xnC6[j] = getThermoSystem().getPhase(1).getComponent("n-hexane").getx(); - ynC6[j] = getThermoSystem().getPhase(0).getComponent("n-hexane").getx(); - } - // System.out.println("time " + time[j] + " Superior Wobbe " + - // getStandardISO6976().getValue("SuperiorWobbeIndex") + " temperature " + - // getThermoSystem().getTemperature() + " density " + density[j] + " volume " + - // volume[j] + " total energy " + totalEnergy[j]); - getThermoSystem().init(0); - - standardDensity.calculate(); - density[j] = standardDensity.getValue("density"); - getStandardISO6976().calculate(); - // getStandardISO6976().display(""); - WI[j] = getStandardISO6976().getValue("SuperiorWobbeIndex"); - GCV[j] = getStandardISO6976().getValue("SuperiorCalorificValue"); - - tankTemperature[j] = getThermoSystem().getTemperature(); - volume[j] = getThermoSystem().getNumberOfMoles() - * getThermoSystem().getPhase(1).getMolarMass() / density[j];// density[0]; - - this.standardISO6976.setReferenceType("mass"); - totalEnergy[j] = getStandardISO6976().getValue("SuperiorCalorificValue") * volume[j] - * density[j]; - GCVmass[j] = getStandardISO6976().getValue("SuperiorCalorificValue"); - this.standardISO6976.setReferenceType("volume"); - - for (int i = 0; i < getThermoSystem().getPhase(0).getNumberOfComponents(); i++) { - getThermoSystem().addComponent( - getThermoSystem().getPhase(0).getComponent(i).getName(), - -xgas[i] * molarBoilOffRate); - } - } - double oldVolume = 0; - double oldoldVolume = oldVolume; - oldVolume = volume[0] - volume[numberOffTimeSteps - 1]; - double oldmolarBoilOffRate = 0; - double oldoldmolarBoilOffRate = oldmolarBoilOffRate; - oldmolarBoilOffRate = molarBoilOffRate; - error = volume[numberOffTimeSteps - 1] / endVolume - 1.0; - double derrordn = - (oldVolume - oldoldVolume) / (oldmolarBoilOffRate - oldoldmolarBoilOffRate); - boilOffCorrection = (volume[numberOffTimeSteps - 1] - endVolume) / derrordn; - if (iterations > 1) { - molarBoilOffRate += boilOffCorrection;// (volume[numberOffTimeSteps - 1] - - // endVolume) / derrordn; - } else { - molarBoilOffRate = molarBoilOffRate * volume[numberOffTimeSteps - 1] / endVolume; - } - // logger.info("error " + error + " iteration " + iterations + " molarboiloff " - // + molarBoilOffRate + " endVolume " + endVolume + " orginalMolarBoilOff " + - // orginalMolarBoilOff); - } while (Math.abs(error) > 1e-8 && iterations < 100); + logger.info("temperature start " + getThermoSystem().getTemperature()); + // todo: getTimeSeries().init(this); + calcIdentifier = id; + } + + /** {@inheritDoc} */ + @Override + public void solveTransient(int type, UUID id) { + SystemInterface tempThermoSystem = getThermoSystem().clone(); + WI = new double[numberOffTimeSteps]; + GCV = new double[numberOffTimeSteps]; + GCVmass = new double[numberOffTimeSteps]; + totalEnergy = new double[numberOffTimeSteps]; + time = new double[numberOffTimeSteps]; + density = new double[numberOffTimeSteps]; + tankTemperature = new double[numberOffTimeSteps]; + volume = new double[numberOffTimeSteps]; + + xnitrogen = new double[numberOffTimeSteps]; + xmethane = new double[numberOffTimeSteps]; + xethane = new double[numberOffTimeSteps]; + xpropane = new double[numberOffTimeSteps]; + xiC4 = new double[numberOffTimeSteps]; + xnC4 = new double[numberOffTimeSteps]; + xiC5 = new double[numberOffTimeSteps]; + xnC5 = new double[numberOffTimeSteps]; + xnC6 = new double[numberOffTimeSteps]; + + ynitrogen = new double[numberOffTimeSteps]; + ymethane = new double[numberOffTimeSteps]; + yethane = new double[numberOffTimeSteps]; + ypropane = new double[numberOffTimeSteps]; + yiC4 = new double[numberOffTimeSteps]; + ynC4 = new double[numberOffTimeSteps]; + yiC5 = new double[numberOffTimeSteps]; + ynC5 = new double[numberOffTimeSteps]; + ynC6 = new double[numberOffTimeSteps]; + + double error = 100.0; + double mulitplicator = 1.0; + if (backCalculate) { + mulitplicator = -1.0; + } + endVolume = totalTankVolume - mulitplicator * dailyBoilOffVolume * getEndTime() / 24.0; + molarBoilOffRate = dailyBoilOffVolume * liquidDensity + / getThermoSystem().getPhase(1).getMolarMass() / 24.0 * timeStep; + if (backCalculate) { + molarBoilOffRate = -molarBoilOffRate; + } + // double orginalMolarBoilOff = molarBoilOffRate; + logger.info("end Volume " + endVolume); + int iterations = 0; + double boilOffCorrection = 0.0; + do { + setThermoSystem(tempThermoSystem.clone()); + thermoOperations = new ThermodynamicOperations(getThermoSystem()); + standardDensity = new Standard_ISO6578(getThermoSystem()); + getStandardISO6976().setThermoSystem(getThermoSystem()); + iterations++; + for (int j = 0; j < numberOffTimeSteps; j++) { + time[j] = j * timeStep; try { + if (!(j == 0 && isSetInitialTemperature())) { thermoOperations.bubblePointTemperatureFlash(); + } } catch (Exception e) { - e.printStackTrace(); + e.printStackTrace(); } - } + double[] xgas = new double[getThermoSystem().getPhase(0).getNumberOfComponents()]; - /** - *

- * Getter for the field resultTable. - *

- * - * @return an array of {@link java.lang.String} objects - */ - public String[][] getResultTable() { - return resultTable; - } - - /** - *

- * getResults. - *

- * - * @param name a {@link java.lang.String} object - * @return an array of {@link java.lang.String} objects - */ - public String[][] getResults(String name) { - String[][] table = new String[numberOffTimeSteps + 1][26]; - String[] names = {"Time", "temperature", "WI", "GCV", "density", "volume", "energy"}; - - for (int i = 0; i < 13; i++) { - for (int j = 0; j < numberOffTimeSteps + 1; j++) { - table[j][i] = ""; - } + for (int kk = 0; kk < getThermoSystem().getPhase(0).getNumberOfComponents(); kk++) { + xgas[kk] = getThermoSystem().getPhase(0).getComponent(kk).getx(); } - System.arraycopy(names, 0, table[0], 0, 7); - - DecimalFormat nf = new DecimalFormat(); - nf.setMaximumFractionDigits(5); - - for (int j = 0; j < numberOffTimeSteps; j++) { - table[j + 1][0] = nf.format(time[j]); - table[j + 1][1] = nf.format(tankTemperature[j] - 273.15); - table[j + 1][2] = nf.format(WI[j] / 1000.0); - table[j + 1][3] = nf.format(GCV[j] / 1000.0); - table[j + 1][4] = nf.format(density[j]); - table[j + 1][5] = nf.format(volume[j]); - table[j + 1][15] = nf.format(totalEnergy[j] / 1000.0); - - table[j + 1][6] = nf.format(xmethane[j]); - table[j + 1][7] = nf.format(xethane[j]); - table[j + 1][8] = nf.format(xpropane[j]); - table[j + 1][9] = nf.format(xiC4[j]); - table[j + 1][10] = nf.format(xnC4[j]); - table[j + 1][11] = nf.format(xiC5[j]); - table[j + 1][12] = nf.format(xnC5[j]); - table[j + 1][13] = nf.format(xnC6[j]); - table[j + 1][14] = nf.format(xnitrogen[j]); - - table[j + 1][16] = nf.format(GCVmass[j] / 1000.0); - - table[j + 1][17] = nf.format(ymethane[j]); - table[j + 1][18] = nf.format(yethane[j]); - table[j + 1][19] = nf.format(ypropane[j]); - table[j + 1][20] = nf.format(yiC4[j]); - table[j + 1][21] = nf.format(ynC4[j]); - table[j + 1][22] = nf.format(yiC5[j]); - table[j + 1][23] = nf.format(ynC5[j]); - table[j + 1][24] = nf.format(ynC6[j]); - table[j + 1][25] = nf.format(ynitrogen[j]); + if (getThermoSystem().getPhase(0).hasComponent("nitrogen")) { + xnitrogen[j] = getThermoSystem().getPhase(1).getComponent("nitrogen").getx(); + ynitrogen[j] = getThermoSystem().getPhase(0).getComponent("nitrogen").getx(); } - setResultTable(table); - - /* - * // for (int i = 0; i < 4; i++) { for (int j = 0; j < numberOffTimeSteps + 1; j++) { - * logger.info(resultTable[j][25]); logger.info(resultTable[j][14]); } //// } - */ - return table; - } - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - // thermo.system.SystemInterface testSystem = new - // thermo.system.SystemGERG2004Eos(273.15 - 161.4, 1.0); - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos(273.15 - 161.4, 1.013); - /* - * testSystem.addComponent("nitrogen", 0.0136); testSystem.addComponent("methane", 0.9186); - * testSystem.addComponent("ethane", 0.0526); testSystem.addComponent("propane", 0.0115); - */ - testSystem.addComponent("nitrogen", 0.691);// 0.93041); - testSystem.addComponent("methane", 91.93);// 92.637); - testSystem.addComponent("ethane", 5.651);// 4.876); - testSystem.addComponent("propane", 1.296);// 1.093); - testSystem.addComponent("i-butane", 0.122); - testSystem.addComponent("n-butane", 0.289); - testSystem.addComponent("i-pentane", 0.018); - testSystem.addComponent("n-pentane", 0.003); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - - neqsim.fluidMechanics.flowSystem.twoPhaseFlowSystem.shipSystem.LNGship ship = - new neqsim.fluidMechanics.flowSystem.twoPhaseFlowSystem.shipSystem.LNGship( - testSystem, 140000, 0.0015); - // ship.setInitialTemperature(111.0); - // ship.useStandardVersion("","2016"); - ship.useStandardVersion("", "2016"); - ship.getStandardISO6976().setEnergyRefT(15); - ship.getStandardISO6976().setVolRefT(15); - ship.createSystem(); - ship.init(); - // ship.setBackCalculate(true); - ship.solveSteadyState(0); - ship.solveTransient(0); - ship.getResults("test"); - ship.getThermoSystem().display(); - } - - /** - *

- * Setter for the field resultTable. - *

- * - * @param resultTable the resultTable to set - */ - public void setResultTable(String[][] resultTable) { - this.resultTable = resultTable; - } - - /** - *

- * Getter for the field liquidDensity. - *

- * - * @return the liquidDensity - */ - public double getLiquidDensity() { - return liquidDensity; - } - - /** - *

- * Setter for the field liquidDensity. - *

- * - * @param liquidDensity the liquidDensity to set - */ - public void setLiquidDensity(double liquidDensity) { - this.liquidDensity = liquidDensity; - } - - /** - *

- * Getter for the field endTime. - *

- * - * @return the endTime - */ - public double getEndTime() { - return endTime; - } - - /** - *

- * Setter for the field endTime. - *

- * - * @param endTime the endTime to set - */ - public void setEndTime(double endTime) { - this.endTime = endTime; - } - - /** - *

- * Getter for the field standardISO6976. - *

- * - * @return the standardISO6976 - */ - public Standard_ISO6976 getStandardISO6976() { - return standardISO6976; - } - - /** - *

- * Setter for the field standardISO6976. - *

- * - * @param standardISO6976 the standardISO6976 to set - */ - public void setStandardISO6976(Standard_ISO6976 standardISO6976) { - this.standardISO6976 = standardISO6976; - } - - /** - *

- * isBackCalculate. - *

- * - * @return the backCalculate - */ - public boolean isBackCalculate() { - return backCalculate; - } - - /** - *

- * Setter for the field backCalculate. - *

- * - * @param backCalculate the backCalculate to set - */ - public void setBackCalculate(boolean backCalculate) { - this.backCalculate = backCalculate; - } - - /** - *

- * Getter for the field thermoSystem. - *

- * - * @return the thermoSystem - */ - public neqsim.thermo.system.SystemInterface getThermoSystem() { - return thermoSystem; - } + if (getThermoSystem().getPhase(0).hasComponent("methane")) { + xmethane[j] = getThermoSystem().getPhase(1).getComponent("methane").getx(); + ymethane[j] = getThermoSystem().getPhase(0).getComponent("methane").getx(); + } + if (getThermoSystem().getPhase(0).hasComponent("ethane")) { + xethane[j] = getThermoSystem().getPhase(1).getComponent("ethane").getx(); + yethane[j] = getThermoSystem().getPhase(0).getComponent("ethane").getx(); + } + if (getThermoSystem().getPhase(0).hasComponent("propane")) { + xpropane[j] = getThermoSystem().getPhase(1).getComponent("propane").getx(); + ypropane[j] = getThermoSystem().getPhase(0).getComponent("propane").getx(); + } + if (getThermoSystem().getPhase(0).hasComponent("i-butane")) { + xiC4[j] = getThermoSystem().getPhase(1).getComponent("i-butane").getx(); + yiC4[j] = getThermoSystem().getPhase(0).getComponent("i-butane").getx(); + } + if (getThermoSystem().getPhase(0).hasComponent("n-butane")) { + xnC4[j] = getThermoSystem().getPhase(1).getComponent("n-butane").getx(); + ynC4[j] = getThermoSystem().getPhase(0).getComponent("n-butane").getx(); + } + if (getThermoSystem().getPhase(0).hasComponent("i-pentane")) { + xiC5[j] = getThermoSystem().getPhase(1).getComponent("i-pentane").getx(); + yiC5[j] = getThermoSystem().getPhase(0).getComponent("i-pentane").getx(); + } + if (getThermoSystem().getPhase(0).hasComponent("n-pentane")) { + xnC5[j] = getThermoSystem().getPhase(1).getComponent("n-pentane").getx(); + ynC5[j] = getThermoSystem().getPhase(0).getComponent("n-pentane").getx(); + } + if (getThermoSystem().getPhase(0).hasComponent("n-hexane")) { + xnC6[j] = getThermoSystem().getPhase(1).getComponent("n-hexane").getx(); + ynC6[j] = getThermoSystem().getPhase(0).getComponent("n-hexane").getx(); + } + // System.out.println("time " + time[j] + " Superior Wobbe " + + // getStandardISO6976().getValue("SuperiorWobbeIndex") + " temperature " + + // getThermoSystem().getTemperature() + " density " + density[j] + " volume " + + // volume[j] + " total energy " + totalEnergy[j]); + getThermoSystem().init(0); - /** - *

- * Setter for the field thermoSystem. - *

- * - * @param thermoSystem the thermoSystem to set - */ - public void setThermoSystem(neqsim.thermo.system.SystemInterface thermoSystem) { - this.thermoSystem = thermoSystem; - } + standardDensity.calculate(); + density[j] = standardDensity.getValue("density"); + getStandardISO6976().calculate(); + // getStandardISO6976().display(""); + WI[j] = getStandardISO6976().getValue("SuperiorWobbeIndex"); + GCV[j] = getStandardISO6976().getValue("SuperiorCalorificValue"); + + tankTemperature[j] = getThermoSystem().getTemperature(); + volume[j] = getThermoSystem().getNumberOfMoles() + * getThermoSystem().getPhase(1).getMolarMass() / density[j];// density[0]; + + this.standardISO6976.setReferenceType("mass"); + totalEnergy[j] = + getStandardISO6976().getValue("SuperiorCalorificValue") * volume[j] * density[j]; + GCVmass[j] = getStandardISO6976().getValue("SuperiorCalorificValue"); + this.standardISO6976.setReferenceType("volume"); - /** - *

- * isSetInitialTemperature. - *

- * - * @return the setInitialTemperature - */ - public boolean isSetInitialTemperature() { - return setInitialTemperature; + for (int i = 0; i < getThermoSystem().getPhase(0).getNumberOfComponents(); i++) { + getThermoSystem().addComponent(getThermoSystem().getPhase(0).getComponent(i).getName(), + -xgas[i] * molarBoilOffRate); + } + } + double oldVolume = 0; + double oldoldVolume = oldVolume; + oldVolume = volume[0] - volume[numberOffTimeSteps - 1]; + double oldmolarBoilOffRate = 0; + double oldoldmolarBoilOffRate = oldmolarBoilOffRate; + oldmolarBoilOffRate = molarBoilOffRate; + error = volume[numberOffTimeSteps - 1] / endVolume - 1.0; + double derrordn = (oldVolume - oldoldVolume) / (oldmolarBoilOffRate - oldoldmolarBoilOffRate); + boilOffCorrection = (volume[numberOffTimeSteps - 1] - endVolume) / derrordn; + if (iterations > 1) { + molarBoilOffRate += boilOffCorrection;// (volume[numberOffTimeSteps - 1] - + // endVolume) / derrordn; + } else { + molarBoilOffRate = molarBoilOffRate * volume[numberOffTimeSteps - 1] / endVolume; + } + // logger.info("error " + error + " iteration " + iterations + " molarboiloff " + // + molarBoilOffRate + " endVolume " + endVolume + " orginalMolarBoilOff " + + // orginalMolarBoilOff); + } while (Math.abs(error) > 1e-8 && iterations < 100); + try { + thermoOperations.bubblePointTemperatureFlash(); + calcIdentifier = id; + } catch (Exception e) { + e.printStackTrace(); } - - /** - *

- * Setter for the field initialTemperature. - *

- * - * @param setInitialTemperature the setInitialTemperature to set - */ - public void setInitialTemperature(boolean setInitialTemperature) { - this.setInitialTemperature = setInitialTemperature; + } + + /** + *

+ * Getter for the field resultTable. + *

+ * + * @return an array of {@link java.lang.String} objects + */ + public String[][] getResultTable() { + return resultTable; + } + + /** + *

+ * getResults. + *

+ * + * @param name a {@link java.lang.String} object + * @return an array of {@link java.lang.String} objects + */ + public String[][] getResults(String name) { + String[][] table = new String[numberOffTimeSteps + 1][26]; + String[] names = {"Time", "temperature", "WI", "GCV", "density", "volume", "energy"}; + + for (int i = 0; i < 13; i++) { + for (int j = 0; j < numberOffTimeSteps + 1; j++) { + table[j][i] = ""; + } } - /** - *

- * Getter for the field initialTemperature. - *

- * - * @return the initialTemperature - */ - public double getInitialTemperature() { - return initialTemperature; + System.arraycopy(names, 0, table[0], 0, 7); + + DecimalFormat nf = new DecimalFormat(); + nf.setMaximumFractionDigits(5); + + for (int j = 0; j < numberOffTimeSteps; j++) { + table[j + 1][0] = nf.format(time[j]); + table[j + 1][1] = nf.format(tankTemperature[j] - 273.15); + table[j + 1][2] = nf.format(WI[j] / 1000.0); + table[j + 1][3] = nf.format(GCV[j] / 1000.0); + table[j + 1][4] = nf.format(density[j]); + table[j + 1][5] = nf.format(volume[j]); + table[j + 1][15] = nf.format(totalEnergy[j] / 1000.0); + + table[j + 1][6] = nf.format(xmethane[j]); + table[j + 1][7] = nf.format(xethane[j]); + table[j + 1][8] = nf.format(xpropane[j]); + table[j + 1][9] = nf.format(xiC4[j]); + table[j + 1][10] = nf.format(xnC4[j]); + table[j + 1][11] = nf.format(xiC5[j]); + table[j + 1][12] = nf.format(xnC5[j]); + table[j + 1][13] = nf.format(xnC6[j]); + table[j + 1][14] = nf.format(xnitrogen[j]); + + table[j + 1][16] = nf.format(GCVmass[j] / 1000.0); + + table[j + 1][17] = nf.format(ymethane[j]); + table[j + 1][18] = nf.format(yethane[j]); + table[j + 1][19] = nf.format(ypropane[j]); + table[j + 1][20] = nf.format(yiC4[j]); + table[j + 1][21] = nf.format(ynC4[j]); + table[j + 1][22] = nf.format(yiC5[j]); + table[j + 1][23] = nf.format(ynC5[j]); + table[j + 1][24] = nf.format(ynC6[j]); + table[j + 1][25] = nf.format(ynitrogen[j]); } + setResultTable(table); - /** - *

- * Setter for the field initialTemperature. - *

- * - * @param initialTemperature the initialTemperature to set + /* + * // for (int i = 0; i < 4; i++) { for (int j = 0; j < numberOffTimeSteps + 1; j++) { + * logger.info(resultTable[j][25]); logger.info(resultTable[j][14]); } //// } */ - public void setInitialTemperature(double initialTemperature) { - setInitialTemperature = true; - this.initialTemperature = initialTemperature; - } - - /** - * @return the thermoSystem + return table; + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + // thermo.system.SystemInterface testSystem = new + // thermo.system.SystemGERG2004Eos(273.15 - 161.4, 1.0); + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos(273.15 - 161.4, 1.013); + /* + * testSystem.addComponent("nitrogen", 0.0136); testSystem.addComponent("methane", 0.9186); + * testSystem.addComponent("ethane", 0.0526); testSystem.addComponent("propane", 0.0115); */ + testSystem.addComponent("nitrogen", 0.691);// 0.93041); + testSystem.addComponent("methane", 91.93);// 92.637); + testSystem.addComponent("ethane", 5.651);// 4.876); + testSystem.addComponent("propane", 1.296);// 1.093); + testSystem.addComponent("i-butane", 0.122); + testSystem.addComponent("n-butane", 0.289); + testSystem.addComponent("i-pentane", 0.018); + testSystem.addComponent("n-pentane", 0.003); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + + neqsim.fluidMechanics.flowSystem.twoPhaseFlowSystem.shipSystem.LNGship ship = + new neqsim.fluidMechanics.flowSystem.twoPhaseFlowSystem.shipSystem.LNGship(testSystem, + 140000, 0.0015); + // ship.setInitialTemperature(111.0); + // ship.useStandardVersion("","2016"); + ship.useStandardVersion("", "2016"); + ship.getStandardISO6976().setEnergyRefT(15); + ship.getStandardISO6976().setVolRefT(15); + ship.createSystem(); + ship.init(); + // ship.setBackCalculate(true); + ship.solveSteadyState(0); + ship.solveTransient(0); + ship.getResults("test"); + ship.getThermoSystem().display(); + } + + /** + *

+ * Setter for the field resultTable. + *

+ * + * @param resultTable the resultTable to set + */ + public void setResultTable(String[][] resultTable) { + this.resultTable = resultTable; + } + + /** + *

+ * Getter for the field liquidDensity. + *

+ * + * @return the liquidDensity + */ + public double getLiquidDensity() { + return liquidDensity; + } + + /** + *

+ * Setter for the field liquidDensity. + *

+ * + * @param liquidDensity the liquidDensity to set + */ + public void setLiquidDensity(double liquidDensity) { + this.liquidDensity = liquidDensity; + } + + /** + *

+ * Getter for the field endTime. + *

+ * + * @return the endTime + */ + public double getEndTime() { + return endTime; + } + + /** + *

+ * Setter for the field endTime. + *

+ * + * @param endTime the endTime to set + */ + public void setEndTime(double endTime) { + this.endTime = endTime; + } + + /** + *

+ * Getter for the field standardISO6976. + *

+ * + * @return the standardISO6976 + */ + public Standard_ISO6976 getStandardISO6976() { + return standardISO6976; + } + + /** + *

+ * Setter for the field standardISO6976. + *

+ * + * @param standardISO6976 the standardISO6976 to set + */ + public void setStandardISO6976(Standard_ISO6976 standardISO6976) { + this.standardISO6976 = standardISO6976; + } + + /** + *

+ * isBackCalculate. + *

+ * + * @return the backCalculate + */ + public boolean isBackCalculate() { + return backCalculate; + } + + /** + *

+ * Setter for the field backCalculate. + *

+ * + * @param backCalculate the backCalculate to set + */ + public void setBackCalculate(boolean backCalculate) { + this.backCalculate = backCalculate; + } + + /** + *

+ * Getter for the field thermoSystem. + *

+ * + * @return the thermoSystem + */ + public neqsim.thermo.system.SystemInterface getThermoSystem() { + return thermoSystem; + } + + /** + *

+ * Setter for the field thermoSystem. + *

+ * + * @param thermoSystem the thermoSystem to set + */ + public void setThermoSystem(neqsim.thermo.system.SystemInterface thermoSystem) { + this.thermoSystem = thermoSystem; + } + + /** + *

+ * isSetInitialTemperature. + *

+ * + * @return the setInitialTemperature + */ + public boolean isSetInitialTemperature() { + return setInitialTemperature; + } + + /** + *

+ * Getter for the field initialTemperature. + *

+ * + * @return the initialTemperature + */ + public double getInitialTemperature() { + return initialTemperature; + } + + /** + *

+ * Setter for the field initialTemperature. + *

+ * + * @param initialTemperature the initialTemperature to set + */ + public void setInitialTemperature(double initialTemperature) { + setInitialTemperature = true; + this.initialTemperature = initialTemperature; + } + + /** + *

+ * Setter for the field initialTemperature. + *

+ * + * @param setInitialTemperature the setInitialTemperature to set + */ + public void setInitialTemperature(boolean setInitialTemperature) { + this.setInitialTemperature = setInitialTemperature; + } } diff --git a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/stirredCellSystem/StirredCellSystem.java b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/stirredCellSystem/StirredCellSystem.java index 24bc8c906d..d21fb830ff 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/stirredCellSystem/StirredCellSystem.java +++ b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/stirredCellSystem/StirredCellSystem.java @@ -1,5 +1,6 @@ package neqsim.fluidMechanics.flowSystem.twoPhaseFlowSystem.stirredCellSystem; +import java.util.UUID; import neqsim.thermo.system.SystemInterface; /** @@ -63,15 +64,18 @@ public void init() { /** {@inheritDoc} */ @Override - public void solveSteadyState(int solverType) { + public void solveSteadyState(int type, UUID id) { + // todo: double[] times = {0.0}; ? flowSolver = new neqsim.fluidMechanics.flowSolver.twoPhaseFlowSolver.stirredCellSolver.StirredCellSolver( this, getSystemLength(), getTotalNumberOfNodes(), false); + calcIdentifier = id; + // todo: getTimeSeries().init(this); } /** {@inheritDoc} */ @Override - public void solveTransient(int solverType) { + public void solveTransient(int solverType, UUID id) { getTimeSeries().init(this); display = new neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowSystemVisualization.twoPhaseFlowVisualization.twoPhasePipeFlowVisualization.TwoPhasePipeFlowVisualization( @@ -91,6 +95,7 @@ public void solveTransient(int solverType) { flowSolver.solveTDMA(); display.setNextData(this, this.getTimeSeries().getTime(i)); } + calcIdentifier = id; } /** diff --git a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhasePipeFlowSystem/TwoPhasePipeFlowSystem.java b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhasePipeFlowSystem/TwoPhasePipeFlowSystem.java index 5ffc04a681..e393fd55fb 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhasePipeFlowSystem/TwoPhasePipeFlowSystem.java +++ b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhasePipeFlowSystem/TwoPhasePipeFlowSystem.java @@ -1,5 +1,7 @@ package neqsim.fluidMechanics.flowSystem.twoPhaseFlowSystem.twoPhasePipeFlowSystem; +import java.util.UUID; + /** *

* TwoPhasePipeFlowSystem class. @@ -72,7 +74,7 @@ public void init() { /** {@inheritDoc} */ @Override - public void solveSteadyState(int solverType) { + public void solveSteadyState(int type, UUID id) { double[] times = {0.0}; display = new neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowSystemVisualization.twoPhaseFlowVisualization.twoPhasePipeFlowVisualization.TwoPhasePipeFlowVisualization( @@ -87,8 +89,9 @@ public void solveSteadyState(int solverType) { flowSolver = new neqsim.fluidMechanics.flowSolver.twoPhaseFlowSolver.twoPhasePipeFlowSolver.TwoPhaseFixedStaggeredGridSolver( this, getSystemLength(), this.getTotalNumberOfNodes(), false); - flowSolver.setSolverType(solverType); + flowSolver.setSolverType(type); flowSolver.solveTDMA(); + calcIdentifier = id; getTimeSeries().init(this); display.setNextData(this); @@ -96,10 +99,11 @@ public void solveSteadyState(int solverType) { /** {@inheritDoc} */ @Override - public void solveTransient(int type) { + public void solveTransient(int type, UUID id) { // pipeSolver pipeSolve = new pipeSolver(this, getSystemLength(), // getTotalNumberOfNodes()); // pipeSolve.solveTDMA(); + calcIdentifier = id; } /** diff --git a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhaseReactorFlowSystem/TwoPhaseReactorFlowSystem.java b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhaseReactorFlowSystem/TwoPhaseReactorFlowSystem.java index 4f28059db9..c56bcf52e4 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhaseReactorFlowSystem/TwoPhaseReactorFlowSystem.java +++ b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhaseReactorFlowSystem/TwoPhaseReactorFlowSystem.java @@ -1,5 +1,6 @@ package neqsim.fluidMechanics.flowSystem.twoPhaseFlowSystem.twoPhaseReactorFlowSystem; +import java.util.UUID; import neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowSystemVisualization.twoPhaseFlowVisualization.twoPhasePipeFlowVisualization.TwoPhasePipeFlowVisualization; /** @@ -11,156 +12,157 @@ * @version $Id: $Id */ public class TwoPhaseReactorFlowSystem - extends neqsim.fluidMechanics.flowSystem.twoPhaseFlowSystem.TwoPhaseFlowSystem { - private static final long serialVersionUID = 1000; - - /** - *

- * Constructor for TwoPhaseReactorFlowSystem. - *

- */ - public TwoPhaseReactorFlowSystem() {} - - /** {@inheritDoc} */ - @Override - public void createSystem() { - // thermoSystem.init(1); - flowLeg = new neqsim.fluidMechanics.flowLeg.pipeLeg.PipeLeg[this.getNumberOfLegs()]; - - for (int i = 0; i < getNumberOfLegs(); i++) { - flowLeg[i] = new neqsim.fluidMechanics.flowLeg.pipeLeg.PipeLeg(); - } - - flowNode = new neqsim.fluidMechanics.flowNode.FlowNodeInterface[totalNumberOfNodes]; - flowNode[0] = - new neqsim.fluidMechanics.flowNode.twoPhaseNode.twoPhasePipeFlowNode.StratifiedFlowNode( - thermoSystem, equipmentGeometry[0]); - flowNode[totalNumberOfNodes - 1] = flowNode[0].getNextNode(); - - super.createSystem(); - this.setNodes(); + extends neqsim.fluidMechanics.flowSystem.twoPhaseFlowSystem.TwoPhaseFlowSystem { + private static final long serialVersionUID = 1000; + + /** + *

+ * Constructor for TwoPhaseReactorFlowSystem. + *

+ */ + public TwoPhaseReactorFlowSystem() {} + + /** {@inheritDoc} */ + @Override + public void createSystem() { + // thermoSystem.init(1); + flowLeg = new neqsim.fluidMechanics.flowLeg.pipeLeg.PipeLeg[this.getNumberOfLegs()]; + + for (int i = 0; i < getNumberOfLegs(); i++) { + flowLeg[i] = new neqsim.fluidMechanics.flowLeg.pipeLeg.PipeLeg(); } - /** {@inheritDoc} */ - @Override - public void init() { - for (int j = 0; j < getTotalNumberOfNodes(); j++) { - flowNode[j].setInterphaseModelType(1); - flowNode[j].getGeometry();// setPackingType() - flowNode[j].initFlowCalc(); - flowNode[j].init(); - } - - for (int j = 0; j < getTotalNumberOfNodes(); j++) { - for (int phase = 0; phase < 2; phase++) { - flowNode[j].setVelocityOut(phase, this.flowNode[j].getVelocity(phase)); - } - } - - for (int k = 1; k < getTotalNumberOfNodes(); k++) { - for (int phase = 0; phase < 2; phase++) { - this.flowNode[k].setVelocityIn(phase, this.flowNode[k - 1].getVelocityOut(phase)); - } - } + flowNode = new neqsim.fluidMechanics.flowNode.FlowNodeInterface[totalNumberOfNodes]; + flowNode[0] = + new neqsim.fluidMechanics.flowNode.twoPhaseNode.twoPhasePipeFlowNode.StratifiedFlowNode( + thermoSystem, equipmentGeometry[0]); + flowNode[totalNumberOfNodes - 1] = flowNode[0].getNextNode(); + + super.createSystem(); + this.setNodes(); + } + + /** {@inheritDoc} */ + @Override + public void init() { + for (int j = 0; j < getTotalNumberOfNodes(); j++) { + flowNode[j].setInterphaseModelType(1); + flowNode[j].getGeometry();// setPackingType() + flowNode[j].initFlowCalc(); + flowNode[j].init(); } - /** {@inheritDoc} */ - @Override - public void solveSteadyState(int solverType) { - double[] times = {0.0}; - display = new TwoPhasePipeFlowVisualization(this.getTotalNumberOfNodes(), 1); - getTimeSeries().setTimes(times); - neqsim.thermo.system.SystemInterface[] systems = {flowNode[0].getBulkSystem()}; - getTimeSeries().setInletThermoSystems(systems); - getTimeSeries().setNumberOfTimeStepsInInterval(1); - double[] outletFlowRates = {0.0, 0.0}; - getTimeSeries().setOutletMolarFlowRate(outletFlowRates); - - flowSolver = - new neqsim.fluidMechanics.flowSolver.twoPhaseFlowSolver.twoPhasePipeFlowSolver.TwoPhaseFixedStaggeredGridSolver( - this, getSystemLength(), this.getTotalNumberOfNodes(), false); - flowSolver.setSolverType(solverType); - flowSolver.solveTDMA(); - getTimeSeries().init(this); - display.setNextData(this); + for (int j = 0; j < getTotalNumberOfNodes(); j++) { + for (int phase = 0; phase < 2; phase++) { + flowNode[j].setVelocityOut(phase, this.flowNode[j].getVelocity(phase)); + } } - /** {@inheritDoc} */ - @Override - public void solveTransient(int type) { - // pipeSolver pipeSolve = new pipeSolver(this, getSystemLength(), - // getTotalNumberOfNodes()); - // pipeSolve.solveTDMA(); + for (int k = 1; k < getTotalNumberOfNodes(); k++) { + for (int phase = 0; phase < 2; phase++) { + this.flowNode[k].setVelocityIn(phase, this.flowNode[k - 1].getVelocityOut(phase)); + } } - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - @SuppressWarnings("unused") - public static void main(String[] args) { - // Initierer et nyt rorsystem - neqsim.fluidMechanics.flowSystem.FlowSystemInterface pipe = new TwoPhaseReactorFlowSystem(); - - // Definerer termodyanmikken5 - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos(295.3, 5.0); // initierer - // et - // system - // som - // benytter - // SRK - // tilstandsligning - // med trykk 305.3 K og 125 bar - neqsim.thermodynamicOperations.ThermodynamicOperations testOps = - new neqsim.thermodynamicOperations.ThermodynamicOperations(testSystem); // gjor - // termodyanmiske - // Flash - // rutiner - // tilgjengelige - testSystem.addComponent("methane", 0.11152181, 0); - // testSystem.addComponent("ethane", 0.0011152181, 0); - testSystem.addComponent("water", 0.04962204876, 1); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - // benytter klassiske blandingsregler - - pipe.setInletThermoSystem(testSystem); // setter termodyanmikken for rorsystemet - pipe.setNumberOfLegs(5); // deler inn roret i et gitt antall legger - pipe.setNumberOfNodesInLeg(100); // setter antall nodepunkter (beregningspunkter/grid) pr. - // leg - double[] height = {0, 0, 0, 0, 0, 0}; - double[] length = {0.0, 1.7, 3.5, 5.0, 7.5, 10.4}; - double[] outerTemperature = - {278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 275.0, 275.0, 275.0, 275.0}; - - pipe.setLegHeights(height); // setter inn hoyde for hver leg-ende - pipe.setLegPositions(length); // setter avstand til hver leg-ende - pipe.setLegOuterTemperatures(outerTemperature); - - neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface[] pipeGemometry = - new neqsim.fluidMechanics.geometryDefinitions.reactor.ReactorData[5]; // Deffinerer - // geometrien - // for - // roret - double[] pipeDiameter = {0.02588, 0.02588, 0.02588, 0.02588, 0.02588}; - for (int i = 0; i < pipeDiameter.length; i++) { - pipeGemometry[i] = new neqsim.fluidMechanics.geometryDefinitions.reactor.ReactorData( - pipeDiameter[i], 1); - } - pipe.setEquipmentGeometry(pipeGemometry); // setter inn rorgeometrien for hver leg - // utforer bergninger - pipe.createSystem(); - pipe.init(); - - pipe.solveSteadyState(2); - // pipe.calcFluxes(); - // pipe.getDisplay().displayResult("temperature"); - // pipe.displayResults(); - // testOps.TPflash(); - // testOps.displayResult(); + } + + /** {@inheritDoc} */ + @Override + public void solveSteadyState(int type, UUID id) { + double[] times = {0.0}; + display = new TwoPhasePipeFlowVisualization(this.getTotalNumberOfNodes(), 1); + getTimeSeries().setTimes(times); + neqsim.thermo.system.SystemInterface[] systems = {flowNode[0].getBulkSystem()}; + getTimeSeries().setInletThermoSystems(systems); + getTimeSeries().setNumberOfTimeStepsInInterval(1); + double[] outletFlowRates = {0.0, 0.0}; + getTimeSeries().setOutletMolarFlowRate(outletFlowRates); + + flowSolver = + new neqsim.fluidMechanics.flowSolver.twoPhaseFlowSolver.twoPhasePipeFlowSolver.TwoPhaseFixedStaggeredGridSolver( + this, getSystemLength(), this.getTotalNumberOfNodes(), false); + flowSolver.setSolverType(type); + flowSolver.solveTDMA(); + getTimeSeries().init(this); + display.setNextData(this); + } + + /** {@inheritDoc} */ + @Override + public void solveTransient(int type, UUID id) { + // pipeSolver pipeSolve = new pipeSolver(this, getSystemLength(), + // getTotalNumberOfNodes()); + // pipeSolve.solveTDMA(); + calcIdentifier = id; + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String[] args) { + // Initierer et nyt rorsystem + neqsim.fluidMechanics.flowSystem.FlowSystemInterface pipe = new TwoPhaseReactorFlowSystem(); + + // Definerer termodyanmikken5 + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos(295.3, 5.0); // initierer + // et + // system + // som + // benytter + // SRK + // tilstandsligning + // med trykk 305.3 K og 125 bar + neqsim.thermodynamicOperations.ThermodynamicOperations testOps = + new neqsim.thermodynamicOperations.ThermodynamicOperations(testSystem); // gjor + // termodyanmiske + // Flash + // rutiner + // tilgjengelige + testSystem.addComponent("methane", 0.11152181, 0); + // testSystem.addComponent("ethane", 0.0011152181, 0); + testSystem.addComponent("water", 0.04962204876, 1); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + // benytter klassiske blandingsregler + + pipe.setInletThermoSystem(testSystem); // setter termodyanmikken for rorsystemet + pipe.setNumberOfLegs(5); // deler inn roret i et gitt antall legger + pipe.setNumberOfNodesInLeg(100); // setter antall nodepunkter (beregningspunkter/grid) pr. + // leg + double[] height = {0, 0, 0, 0, 0, 0}; + double[] length = {0.0, 1.7, 3.5, 5.0, 7.5, 10.4}; + double[] outerTemperature = + {278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 275.0, 275.0, 275.0, 275.0}; + + pipe.setLegHeights(height); // setter inn hoyde for hver leg-ende + pipe.setLegPositions(length); // setter avstand til hver leg-ende + pipe.setLegOuterTemperatures(outerTemperature); + + neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface[] pipeGemometry = + new neqsim.fluidMechanics.geometryDefinitions.reactor.ReactorData[5]; // Deffinerer + // geometrien + // for + // roret + double[] pipeDiameter = {0.02588, 0.02588, 0.02588, 0.02588, 0.02588}; + for (int i = 0; i < pipeDiameter.length; i++) { + pipeGemometry[i] = + new neqsim.fluidMechanics.geometryDefinitions.reactor.ReactorData(pipeDiameter[i], 1); } + pipe.setEquipmentGeometry(pipeGemometry); // setter inn rorgeometrien for hver leg + // utforer bergninger + pipe.createSystem(); + pipe.init(); + + pipe.solveSteadyState(2); + // pipe.calcFluxes(); + // pipe.getDisplay().displayResult("temperature"); + // pipe.displayResults(); + // testOps.TPflash(); + // testOps.displayResult(); + } } diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/twoPhaseFlowVisualization/twoPhasePipeFlowVisualization/TwoPhasePipeFlowVisualization.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/twoPhaseFlowVisualization/twoPhasePipeFlowVisualization/TwoPhasePipeFlowVisualization.java index c3aeeb9529..d6cf0b2ce1 100644 --- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/twoPhaseFlowVisualization/twoPhasePipeFlowVisualization/TwoPhasePipeFlowVisualization.java +++ b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/twoPhaseFlowVisualization/twoPhasePipeFlowVisualization/TwoPhasePipeFlowVisualization.java @@ -157,7 +157,6 @@ public void displayResult(String name) { // file.createFile(); // } - /* * public void createNetCdfFile(String name) { setPoints(); * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D file = new diff --git a/src/main/java/neqsim/processSimulation/SimulationBaseClass.java b/src/main/java/neqsim/processSimulation/SimulationBaseClass.java index 2b984bb244..16f11cf8f7 100644 --- a/src/main/java/neqsim/processSimulation/SimulationBaseClass.java +++ b/src/main/java/neqsim/processSimulation/SimulationBaseClass.java @@ -1,24 +1,37 @@ package neqsim.processSimulation; +import java.util.UUID; import neqsim.util.NamedBaseClass; +/** + * Base class for process simulation objects. + */ public abstract class SimulationBaseClass extends NamedBaseClass implements SimulationInterface { private static final long serialVersionUID = 1L; + + /** + * Unique identifier of which solve/run call was last called successfully. + */ + protected UUID calcIdentifier; protected boolean calculateSteadyState = true; + protected double time = 0; public SimulationBaseClass(String name) { super(name); } /** {@inheritDoc} */ - @Override - public void runTransient(double dt) { - if (getCalculateSteadyState()) { - run(); - return; - } + public UUID getCalculationIdentifier() { + return calcIdentifier; + } - throw new UnsupportedOperationException("RunTransient using difference equations is not supported yet."); + /** {@inheritDoc} */ + public void setCalculationIdentifier(UUID value) { + if (this.calcIdentifier == null || this.calcIdentifier != value) { + this.calcIdentifier = value; + } else { + this.calcIdentifier = value; + } } /** {@inheritDoc} */ @@ -32,4 +45,23 @@ public boolean getCalculateSteadyState() { public void setCalculateSteadyState(boolean steady) { this.calculateSteadyState = steady; } + + /** {@inheritDoc} */ + public double getTime() { + return this.time; + } + + /** {@inheritDoc} */ + public void setTime(double value) { + this.time = value; + } + + /** {@inheritDoc} */ + public void increaseTime(double dt) { + if (dt < 0) { + throw new UnsupportedOperationException( + "Input dt is negative - not allowed to go backwards in time."); + } + this.time = this.time + dt; + } } diff --git a/src/main/java/neqsim/processSimulation/SimulationInterface.java b/src/main/java/neqsim/processSimulation/SimulationInterface.java index 46da985592..984245e842 100644 --- a/src/main/java/neqsim/processSimulation/SimulationInterface.java +++ b/src/main/java/neqsim/processSimulation/SimulationInterface.java @@ -1,47 +1,119 @@ package neqsim.processSimulation; +import java.util.UUID; import neqsim.util.NamedInterface; +/** + * Interface for simulation objects. + */ public interface SimulationInterface extends NamedInterface, Runnable { /** - * Get calculateSteadyState - * + * Getter for property calcIdentifier. + * + * @return Value of calcIdentifier. + */ + public UUID getCalculationIdentifier(); + + /** + * Setter for property calcIdentifier. + * + * @param value Value to set. + */ + public void setCalculationIdentifier(UUID value); + + /** + * Getter for property calculateSteadyState. + * * @return Value of property calculateSteadyState */ public boolean getCalculateSteadyState(); /** - * Setter for property calculateSteadyState - * + * Setter for property calculateSteadyState. + * * @param steady Set true to do steady state calculation when calling runTransient. */ public void setCalculateSteadyState(boolean steady); + /** + * Getter for property time. + * + * @return Value of property time. + */ + public double getTime(); + + /** + * Setter for property time. + * + * @param value Value to set. + */ + public void setTime(double value); + + /** + * Method to increase parameter time by a given value. + * + * @param dt Value to increase time by. + */ + public void increaseTime(double dt); + /** *

* run *

* In this method all thermodynamic and unit operations will be calculated in a steady state - * calculation. - * - * + * calculation. Sets calc identifier UUID. */ @Override - public void run(); + public default void run() { + run(UUID.randomUUID()); + } + + /** + *

+ * run + *

+ * In this method all thermodynamic and unit operations will be calculated in a steady state + * calculation. Sets calc identifier UUID. + * + * @param value Calc identifier UUID to set. + */ + public void run(UUID value); /** *

* runTransient *

- * This method calculates thermodynamic and unit operations using - * difference equations if available and calculateSteadyState is true. - * Use setCalculateSteadyState to set the parameter. - * - * @param dt is the delta time step (seconds) + * This method calculates thermodynamic and unit operations using difference equations if + * available and calculateSteadyState is true. Use setCalculateSteadyState to set the parameter. + * Sets calc identifier UUID. * + * @param dt Delta time [s] + */ + public default void runTransient(double dt) { + runTransient(dt, UUID.randomUUID()); + } + + /** + *

+ * runTransient + *

+ * This method calculates thermodynamic and unit operations using difference equations if + * available and calculateSteadyState is true. Use setCalculateSteadyState to set the parameter. + * Sets calc identifier UUID. * + * @param dt Delta time [s] + * @param id Calculation identifier */ - public void runTransient(double dt); + public default void runTransient(double dt, UUID id) { + if (getCalculateSteadyState()) { + run(id); + increaseTime(dt); + return; + } + + throw new UnsupportedOperationException( + "RunTransient using difference equations is not supported yet."); + } /** *

diff --git a/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceBaseClass.java b/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceBaseClass.java index 9f4d2f3bdb..46483e88f7 100644 --- a/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceBaseClass.java +++ b/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceBaseClass.java @@ -3,8 +3,10 @@ * * Created on 10. oktober 2006, 19:59 */ + package neqsim.processSimulation.controllerDevice; +import java.util.UUID; import neqsim.processSimulation.measurementDevice.MeasurementDeviceInterface; import neqsim.util.NamedBaseClass; @@ -17,163 +19,171 @@ * @version $Id: $Id */ public class ControllerDeviceBaseClass extends NamedBaseClass implements ControllerDeviceInterface { - private static final long serialVersionUID = 1000; - - private String unit = "[?]"; - private MeasurementDeviceInterface transmitter = null; - private double controllerSetPoint = 0.0; - private double oldError = 0.0, oldoldError = 0.0; - private double error = 0.0; - private double response = 30.0; - int propConstant = 1; - private boolean reverseActing = false; - private double Ksp = 1.0; - private double Tint = 300.0, TintValue = 0.0; - private double Tderiv = 300.0; - - public ControllerDeviceBaseClass() { - super("controller"); - } - - /** {@inheritDoc} */ - @Override - public void setTransmitter(MeasurementDeviceInterface device) { - this.transmitter = device; - } - - /** {@inheritDoc} */ - @Override - public double getMeasuredValue() { - return this.transmitter.getMeasuredValue(); - } - - /** {@inheritDoc} */ - @Override - public void runTransient(double percentSignal, double dt) { - if (isReverseActing()) { - propConstant = -1; - } - oldoldError = error; - oldError = error; - error = transmitter.getMeasuredPercentValue() - - (controllerSetPoint - transmitter.getMinimumValue()) - / (transmitter.getMaximumValue() - transmitter.getMinimumValue()) * 100; - - TintValue += Ksp / Tint * error * dt; - double TderivValue = Ksp * Tderiv * (error - oldError) / dt; - response = percentSignal + propConstant * (Ksp * error + TintValue + TderivValue); - //System.out.println("error " + error + " %"); - // error = device.getMeasuredPercentValue()-controlValue; - // double regulatorSignal = error*1.0; - } - - /** {@inheritDoc} */ - @Override - public void setControllerSetPoint(double signal) { - this.controllerSetPoint = signal; - } - - /** {@inheritDoc} */ - @Override - public String getUnit() { - return unit; - } - - /** {@inheritDoc} */ - @Override - public void setUnit(String unit) { - this.unit = unit; - } - - /** {@inheritDoc} */ - @Override - public double getResponse() { - return response; - } - - /** {@inheritDoc} */ - @Override - public boolean isReverseActing() { - return reverseActing; - } - - /** {@inheritDoc} */ - @Override - public void setReverseActing(boolean reverseActing) { - this.reverseActing = reverseActing; - } - - /** - *

- * getKsp. - *

- * - * @return a double - */ - public double getKsp() { - return Ksp; - } - - /** - *

- * setKsp. - *

- * - * @param Ksp a double - */ - public void setKsp(double Ksp) { - this.Ksp = Ksp; - } - - /** {@inheritDoc} */ - @Override - public void setControllerParameters(double Ksp, double Ti, double Td) { - this.setKsp(Ksp); - this.setTint(Ti); - this.setTderiv(Td); - } - - /** - *

- * getTint. - *

- * - * @return a double - */ - public double getTint() { - return Tint; - } - - /** - *

- * setTint. - *

- * - * @param Tint a double - */ - public void setTint(double Tint) { - this.Tint = Tint; - } - - /** - *

- * getTderiv. - *

- * - * @return a double - */ - public double getTderiv() { - return Tderiv; - } - - /** - *

- * setTderiv. - *

- * - * @param Tderiv a double - */ - public void setTderiv(double Tderiv) { - this.Tderiv = Tderiv; - } + private static final long serialVersionUID = 1000; + + /** + * Unique identifier of which solve/run call was last called successfully. + */ + protected UUID calcIdentifier; + + private String unit = "[?]"; + private MeasurementDeviceInterface transmitter = null; + private double controllerSetPoint = 0.0; + private double oldError = 0.0; + private double oldoldError = 0.0; + private double error = 0.0; + private double response = 30.0; + int propConstant = 1; + private boolean reverseActing = false; + private double Ksp = 1.0; + private double Tint = 300.0; + private double TintValue = 0.0; + private double Tderiv = 300.0; + + public ControllerDeviceBaseClass() { + super("controller"); + } + + /** {@inheritDoc} */ + @Override + public void setTransmitter(MeasurementDeviceInterface device) { + this.transmitter = device; + } + + /** {@inheritDoc} */ + @Override + public double getMeasuredValue() { + return this.transmitter.getMeasuredValue(); + } + + /** {@inheritDoc} */ + @Override + public void runTransient(double initResponse, double dt, UUID id) { + if (isReverseActing()) { + propConstant = -1; + } + oldoldError = error; + oldError = error; + error = + transmitter.getMeasuredPercentValue() - (controllerSetPoint - transmitter.getMinimumValue()) + / (transmitter.getMaximumValue() - transmitter.getMinimumValue()) * 100; + + TintValue += Ksp / Tint * error * dt; + double TderivValue = Ksp * Tderiv * (error - oldError) / dt; + response = initResponse + propConstant * (Ksp * error + TintValue + TderivValue); + // System.out.println("error " + error + " %"); + // error = device.getMeasuredPercentValue()-controlValue; + // double regulatorSignal = error*1.0; + calcIdentifier = id; + } + + /** {@inheritDoc} */ + @Override + public void setControllerSetPoint(double signal) { + this.controllerSetPoint = signal; + } + + /** {@inheritDoc} */ + @Override + public String getUnit() { + return unit; + } + + /** {@inheritDoc} */ + @Override + public void setUnit(String unit) { + this.unit = unit; + } + + /** {@inheritDoc} */ + @Override + public double getResponse() { + return response; + } + + /** {@inheritDoc} */ + @Override + public boolean isReverseActing() { + return reverseActing; + } + + /** {@inheritDoc} */ + @Override + public void setReverseActing(boolean reverseActing) { + this.reverseActing = reverseActing; + } + + /** + *

+ * getKsp. + *

+ * + * @return a double + */ + public double getKsp() { + return Ksp; + } + + /** + *

+ * setKsp. + *

+ * + * @param Ksp a double + */ + public void setKsp(double Ksp) { + this.Ksp = Ksp; + } + + /** {@inheritDoc} */ + @Override + public void setControllerParameters(double Ksp, double Ti, double Td) { + this.setKsp(Ksp); + this.setTint(Ti); + this.setTderiv(Td); + } + + /** + *

+ * getTint. + *

+ * + * @return a double + */ + public double getTint() { + return Tint; + } + + /** + *

+ * setTint. + *

+ * + * @param Tint a double + */ + public void setTint(double Tint) { + this.Tint = Tint; + } + + /** + *

+ * getTderiv. + *

+ * + * @return a double + */ + public double getTderiv() { + return Tderiv; + } + + /** + *

+ * setTderiv. + *

+ * + * @param Tderiv a double + */ + public void setTderiv(double Tderiv) { + this.Tderiv = Tderiv; + } } diff --git a/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceInterface.java b/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceInterface.java index 0598a82353..daee103281 100644 --- a/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceInterface.java +++ b/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceInterface.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.controllerDevice; +import java.util.UUID; import neqsim.processSimulation.measurementDevice.MeasurementDeviceInterface; /** @@ -11,105 +12,120 @@ * @version $Id: $Id */ public interface ControllerDeviceInterface extends java.io.Serializable { - /** - *

- * getMeasuredValue. - *

- * - * @return a double - */ - public double getMeasuredValue(); + /** + *

+ * getMeasuredValue. + *

+ * + * @return a double + */ + public double getMeasuredValue(); - /** - *

- * setControllerSetPoint. - *

- * - * @param signal a double - */ - public void setControllerSetPoint(double signal); + /** + *

+ * setControllerSetPoint. + *

+ * + * @param signal a double + */ + public void setControllerSetPoint(double signal); - /** - *

- * getUnit. - *

- * - * @return a {@link java.lang.String} object - */ - public String getUnit(); + /** + *

+ * getUnit. + *

+ * + * @return a {@link java.lang.String} object + */ + public String getUnit(); - /** - *

- * setUnit. - *

- * - * @param unit a {@link java.lang.String} object - */ - public void setUnit(String unit); + /** + *

+ * setUnit. + *

+ * + * @param unit a {@link java.lang.String} object + */ + public void setUnit(String unit); - /** - *

- * setTransmitter. - *

- * - * @param device a {@link neqsim.processSimulation.measurementDevice.MeasurementDeviceInterface} - * object - */ - public void setTransmitter(MeasurementDeviceInterface device); + /** + *

+ * setTransmitter. + *

+ * + * @param device a {@link neqsim.processSimulation.measurementDevice.MeasurementDeviceInterface} + * object + */ + public void setTransmitter(MeasurementDeviceInterface device); - /** - *

- * run. - *

- * - * @param signal a double - * @param dt a double - */ - public void runTransient(double signal, double dt); + /** + *

+ * runTransient. + *

+ * Calculates controller output. Sets calc identifier UUID. + * + * @param initResponse Init value for response calculation + * @param dt Delta time [s] + */ + public default void runTransient(double initResponse, double dt) { + runTransient(initResponse, dt, UUID.randomUUID()); + } - /** - *

- * getResponse. - *

- * - * @return a double - */ - public double getResponse(); + /** + *

+ * runTransient. + *

+ * Calculates controller output. Sets calc identifier UUID. + * + * @param initResponse Init value for response calculation + * @param dt Delta time [s] + * @param id Calculation identifier + */ + public void runTransient(double initResponse, double dt, UUID id); - /** - *

- * isReverseActing. - *

- * - * @return a boolean - */ - public boolean isReverseActing(); + /** + *

+ * getResponse. + *

+ * + * @return a double + */ + public double getResponse(); - /** - *

- * setReverseActing. - *

- * - * @param reverseActing a boolean - */ - public void setReverseActing(boolean reverseActing); + /** + *

+ * isReverseActing. + *

+ * + * @return a boolean + */ + public boolean isReverseActing(); - /** - *

- * setControllerParameters. - *

- * - * @param Ksp a double - * @param Ti a double - * @param Td a double - */ - public void setControllerParameters(double Ksp, double Ti, double Td); + /** + *

+ * setReverseActing. + *

+ * + * @param reverseActing a boolean + */ + public void setReverseActing(boolean reverseActing); - /** {@inheritDoc} */ - @Override - public boolean equals(Object o); + /** + *

+ * setControllerParameters. + *

+ * + * @param Ksp a double + * @param Ti a double + * @param Td a double + */ + public void setControllerParameters(double Ksp, double Ti, double Td); - /** {@inheritDoc} */ - @Override - public int hashCode(); + /** {@inheritDoc} */ + @Override + public boolean equals(Object o); + + /** {@inheritDoc} */ + @Override + public int hashCode(); } diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/WellAllocator.java b/src/main/java/neqsim/processSimulation/measurementDevice/WellAllocator.java index 622c87e0c2..e669443628 100644 --- a/src/main/java/neqsim/processSimulation/measurementDevice/WellAllocator.java +++ b/src/main/java/neqsim/processSimulation/measurementDevice/WellAllocator.java @@ -17,7 +17,6 @@ public WellAllocator() { name = "Well Allocator"; } - public WellAllocator(StreamInterface stream) { name = "Well Allocator"; this.wellStream = stream; @@ -28,7 +27,6 @@ public WellAllocator(String streamname, StreamInterface stream) { name = streamname; } - public void setExportGasStream(StreamInterface stream) { this.exportGasStream = stream; } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/ProcessEquipmentBaseClass.java b/src/main/java/neqsim/processSimulation/processEquipment/ProcessEquipmentBaseClass.java index 025ec98e16..9ee3fd21e1 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/ProcessEquipmentBaseClass.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/ProcessEquipmentBaseClass.java @@ -167,24 +167,24 @@ public void setEnergyStream(EnergyStream energyStream) { /** *

- * isSetEnergyStream. + * Setter for the field energyStream. *

* - * @return a boolean + * @param isSetEnergyStream a boolean */ - public boolean isSetEnergyStream() { - return isSetEnergyStream; + public void setEnergyStream(boolean isSetEnergyStream) { + this.isSetEnergyStream = isSetEnergyStream; } /** *

- * Setter for the field energyStream. + * isSetEnergyStream. *

* - * @param isSetEnergyStream a boolean + * @return a boolean */ - public void setEnergyStream(boolean isSetEnergyStream) { - this.isSetEnergyStream = isSetEnergyStream; + public boolean isSetEnergyStream() { + return isSetEnergyStream; } /** {@inheritDoc} */ diff --git a/src/main/java/neqsim/processSimulation/processEquipment/absorber/SimpleAbsorber.java b/src/main/java/neqsim/processSimulation/processEquipment/absorber/SimpleAbsorber.java index e92ecd91ff..818b50b4f2 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/absorber/SimpleAbsorber.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/absorber/SimpleAbsorber.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.absorber; +import java.util.UUID; import neqsim.processSimulation.mechanicalDesign.absorber.AbsorberMechanicalDesign; import neqsim.processSimulation.processEquipment.separator.Separator; import neqsim.processSimulation.processEquipment.stream.Stream; @@ -15,377 +16,380 @@ * @version $Id: $Id */ public class SimpleAbsorber extends Separator implements AbsorberInterface { - private static final long serialVersionUID = 1000; - - boolean setTemperature = false; - StreamInterface[] outStream = new Stream[2]; - StreamInterface[] inStream = new Stream[2]; - SystemInterface system; - protected double temperatureOut = 0, dT = 0.0; - private int numberOfStages = 5; - private double numberOfTheoreticalStages = 3.0; - double absorptionEfficiency = 0.5; - private double HTU = 0.85; - private double NTU = 2.0; - private double stageEfficiency = 0.25; - private double fsFactor = 0.0; - - /** - *

- * Constructor for SimpleAbsorber. - *

- */ - @Deprecated - public SimpleAbsorber() { - this("SimpleAbsorber"); - } - - /** - *

- * Constructor for SimpleAbsorber. - *

- * - * @param inStream1 a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - @Deprecated - public SimpleAbsorber(StreamInterface inStream1) { - this("SimpleAbsorber", inStream1); - } - - /** - * - * @param name name of absorber - */ - public SimpleAbsorber(String name) { - super(name); - } - - /** - *

- * Constructor for SimpleAbsorber. - *

- * - * @param name name of absorber - * @param inStream1 a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - public SimpleAbsorber(String name, StreamInterface inStream1) { - super(name); - this.inStream[0] = inStream1; - this.inStream[1] = inStream1; - outStream[0] = inStream1.clone(); - outStream[1] = inStream1.clone(); - setName(name); - - SystemInterface systemOut1 = inStream1.getThermoSystem().clone(); - outStream[0].setThermoSystem(systemOut1); - - double molCO2 = - inStream1.getThermoSystem().getPhase(0).getComponent("CO2").getNumberOfmoles(); - System.out.println("mol CO2 " + molCO2); - SystemInterface systemOut0 = inStream1.getThermoSystem().clone(); - systemOut0.init(0); - systemOut0.addComponent("MDEA", molCO2 * absorptionEfficiency); - systemOut0.addComponent("water", molCO2 * absorptionEfficiency * 10.0); - systemOut0.chemicalReactionInit(); - systemOut0.createDatabase(true); - systemOut0.setMixingRule(4); - outStream[1].setThermoSystem(systemOut0); - outStream[1].run(); - } - - /** {@inheritDoc} */ - public AbsorberMechanicalDesign getMechanicalDesign() { - return new AbsorberMechanicalDesign(this); - } - - /** {@inheritDoc} */ - @Override - public void setName(String name) { - super.setName(name); - // outStream[0].setName(name + "_Sout1"); - // outStream[1].setName(name + "_Sout2"); - } - - /** - *

- * Setter for the field dT. - *

- * - * @param dT a double - */ - public void setdT(double dT) { - this.dT = dT; - } - - /** - *

- * Getter for the field outStream. - *

- * - * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - public StreamInterface getOutStream() { - return outStream[0]; - } - - /** - *

- * Getter for the field outStream. - *

- * - * @param i a int - * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - public StreamInterface getOutStream(int i) { - return outStream[i]; - } - - /** - *

- * getSolventInStream. - *

- * - * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - public StreamInterface getSolventInStream() { - return inStream[0]; - } - - /** - *

- * Getter for the field inStream. - *

- * - * @param i a int - * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - public StreamInterface getInStream(int i) { - return inStream[i]; - } - - /** - *

- * setOutTemperature. - *

- * - * @param temperature a double - */ - public void setOutTemperature(double temperature) { - this.temperatureOut = temperature; - } - - /** - *

- * getOutTemperature. - *

- * - * @param i a int - */ - public void getOutTemperature(int i) { - outStream[i].getThermoSystem().getTemperature(); - } - - /** - *

- * getInTemperature. - *

- * - * @param i a int - */ - public void getInTemperature(int i) { - inStream[i].getThermoSystem().getTemperature(); - } - - /** {@inheritDoc} */ - @Override - public void run() { - SystemInterface systemOut1 = inStream[1].getThermoSystem().clone(); - outStream[0].setThermoSystem(systemOut1); - outStream[0].run(); - - outStream[1].run(); - - double error = 1e5; - error = absorptionEfficiency - (outStream[1].getThermoSystem().getPhase(1) - .getComponent("CO2").getNumberOfMolesInPhase() - + outStream[1].getThermoSystem().getPhase(1).getComponent("HCO3-") - .getNumberOfMolesInPhase()) - / (outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA") - .getNumberOfMolesInPhase() - + outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA+") - .getNumberOfMolesInPhase()); - int iter = 0; - do { - iter++; - double factor = (outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA") - .getNumberOfMolesInPhase() - + outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA+") - .getNumberOfMolesInPhase()); - // outStream[1].getThermoSystem().addComponent("CO2",(20.0-outStream[1].getThermoSystem().getPhase(0).getComponent("CO2").getNumberOfMolesInPhase()),0); - outStream[1].getThermoSystem().addComponent("MDEA", -error * factor); - outStream[1].getThermoSystem().addComponent("water", -error * 10.0 * factor); - outStream[1].run(); - error = absorptionEfficiency - ((outStream[1].getThermoSystem().getPhase(1) - .getComponent("CO2").getNumberOfMolesInPhase() - + outStream[1].getThermoSystem().getPhase(1).getComponent("HCO3-") - .getNumberOfMolesInPhase()) - / (outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA") - .getNumberOfMolesInPhase() - + outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA+") - .getNumberOfMolesInPhase())); - - System.out.println("error " + error); - } while (Math.abs(error) > 1e-4 && iter < 30 - && outStream[1].getThermoSystem().getPhase(1).getBeta() > 0 - && outStream[0].getThermoSystem().getPhase(1).getBeta() > 0); - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - outStream[0].displayResult(); - outStream[1].displayResult(); - } - - /** {@inheritDoc} */ - @Override - public void setAproachToEquilibrium(double eff) { - this.absorptionEfficiency = eff; - } - - /** - *

- * Getter for the field numberOfTheoreticalStages. - *

- * - * @return a double - */ - public double getNumberOfTheoreticalStages() { - return numberOfTheoreticalStages; - } - - /** - *

- * Setter for the field numberOfTheoreticalStages. - *

- * - * @param numberOfTheoreticalStages a double - */ - public void setNumberOfTheoreticalStages(double numberOfTheoreticalStages) { - this.numberOfTheoreticalStages = numberOfTheoreticalStages; - } - - /** - *

- * Getter for the field numberOfStages. - *

- * - * @return a int - */ - public int getNumberOfStages() { - return numberOfStages; - } - - /** - *

- * Setter for the field numberOfStages. - *

- * - * @param numberOfStages a int - */ - public void setNumberOfStages(int numberOfStages) { - this.numberOfStages = numberOfStages; - } - - /** - *

- * Getter for the field stageEfficiency. - *

- * - * @return a double - */ - public double getStageEfficiency() { - return stageEfficiency; - } - - /** - *

- * Setter for the field stageEfficiency. - *

- * - * @param stageEfficiency a double - */ - public void setStageEfficiency(double stageEfficiency) { - this.stageEfficiency = stageEfficiency; - } - - /** - *

- * getHTU. - *

- * - * @return a double - */ - public double getHTU() { - return HTU; - } - - /** - *

- * setHTU. - *

- * - * @param HTU a double - */ - public void setHTU(double HTU) { - this.HTU = HTU; - } - - /** - *

- * getNTU. - *

- * - * @return a double - */ - public double getNTU() { - return NTU; - } - - /** - *

- * setNTU. - *

- * - * @param NTU a double - */ - public void setNTU(double NTU) { - this.NTU = NTU; - } - - /** - *

- * Getter for the field fsFactor. - *

- * - * @return a double - */ - public double getFsFactor() { - double intArea = 3.14 * getInternalDiameter() * getInternalDiameter() / 4.0; - return getGasOutStream().getThermoSystem().getFlowRate("m3/sec") / intArea - * Math.sqrt(getGasOutStream().getThermoSystem().getDensity("kg/m3")); - } - - /** - *

- * getWettingRate. - *

- * - * @return a double - */ - public double getWettingRate() { - double intArea = 3.14 * getInternalDiameter() * getInternalDiameter() / 4.0; - return getLiquidOutStream().getThermoSystem().getFlowRate("m3/hr") / intArea; - } + private static final long serialVersionUID = 1000; + + boolean setTemperature = false; + StreamInterface[] outStream = new Stream[2]; + StreamInterface[] inStream = new Stream[2]; + SystemInterface system; + protected double temperatureOut = 0; + protected double dT = 0.0; + private int numberOfStages = 5; + private double numberOfTheoreticalStages = 3.0; + double absorptionEfficiency = 0.5; + private double HTU = 0.85; + private double NTU = 2.0; + private double stageEfficiency = 0.25; + private double fsFactor = 0.0; + + /** + *

+ * Constructor for SimpleAbsorber. + *

+ */ + @Deprecated + public SimpleAbsorber() { + this("SimpleAbsorber"); + } + + /** + *

+ * Constructor for SimpleAbsorber. + *

+ * + * @param inStream1 a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + */ + @Deprecated + public SimpleAbsorber(StreamInterface inStream1) { + this("SimpleAbsorber", inStream1); + } + + /** + *

+ * Constructor for SimpleAbsorber. + *

+ * + * @param name name of absorber + */ + public SimpleAbsorber(String name) { + super(name); + } + + /** + *

+ * Constructor for SimpleAbsorber. + *

+ * + * @param name name of absorber + * @param inStream1 a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public SimpleAbsorber(String name, StreamInterface inStream1) { + super(name); + this.inStream[0] = inStream1; + this.inStream[1] = inStream1; + outStream[0] = inStream1.clone(); + outStream[1] = inStream1.clone(); + setName(name); + + SystemInterface systemOut1 = inStream1.getThermoSystem().clone(); + outStream[0].setThermoSystem(systemOut1); + + double molCO2 = inStream1.getThermoSystem().getPhase(0).getComponent("CO2").getNumberOfmoles(); + System.out.println("mol CO2 " + molCO2); + SystemInterface systemOut0 = inStream1.getThermoSystem().clone(); + systemOut0.init(0); + systemOut0.addComponent("MDEA", molCO2 * absorptionEfficiency); + systemOut0.addComponent("water", molCO2 * absorptionEfficiency * 10.0); + systemOut0.chemicalReactionInit(); + systemOut0.createDatabase(true); + systemOut0.setMixingRule(4); + outStream[1].setThermoSystem(systemOut0); + outStream[1].run(); + } + + /** {@inheritDoc} */ + public AbsorberMechanicalDesign getMechanicalDesign() { + return new AbsorberMechanicalDesign(this); + } + + /** {@inheritDoc} */ + @Override + public void setName(String name) { + super.setName(name); + // outStream[0].setName(name + "_Sout1"); + // outStream[1].setName(name + "_Sout2"); + } + + /** + *

+ * Setter for the field dT. + *

+ * + * @param dT a double + */ + public void setdT(double dT) { + this.dT = dT; + } + + /** + *

+ * Getter for the field outStream. + *

+ * + * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + */ + public StreamInterface getOutStream() { + return outStream[0]; + } + + /** + *

+ * Getter for the field outStream. + *

+ * + * @param i a int + * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + */ + public StreamInterface getOutStream(int i) { + return outStream[i]; + } + + /** + *

+ * getSolventInStream. + *

+ * + * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + */ + public StreamInterface getSolventInStream() { + return inStream[0]; + } + + /** + *

+ * Getter for the field inStream. + *

+ * + * @param i a int + * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + */ + public StreamInterface getInStream(int i) { + return inStream[i]; + } + + /** + *

+ * setOutTemperature. + *

+ * + * @param temperature a double + */ + public void setOutTemperature(double temperature) { + this.temperatureOut = temperature; + } + + /** + *

+ * getOutTemperature. + *

+ * + * @param i a int + */ + public void getOutTemperature(int i) { + outStream[i].getThermoSystem().getTemperature(); + } + + /** + *

+ * getInTemperature. + *

+ * + * @param i a int + */ + public void getInTemperature(int i) { + inStream[i].getThermoSystem().getTemperature(); + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + SystemInterface systemOut1 = inStream[1].getThermoSystem().clone(); + outStream[0].setThermoSystem(systemOut1); + outStream[0].run(id); + outStream[1].run(); + + double error = 1e5; + error = absorptionEfficiency - (outStream[1].getThermoSystem().getPhase(1).getComponent("CO2") + .getNumberOfMolesInPhase() + + outStream[1].getThermoSystem().getPhase(1).getComponent("HCO3-") + .getNumberOfMolesInPhase()) + / (outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA").getNumberOfMolesInPhase() + + outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA+") + .getNumberOfMolesInPhase()); + int iter = 0; + do { + iter++; + double factor = + (outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA").getNumberOfMolesInPhase() + + outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA+") + .getNumberOfMolesInPhase()); + // outStream[1].getThermoSystem().addComponent("CO2",(20.0-outStream[1].getThermoSystem().getPhase(0).getComponent("CO2").getNumberOfMolesInPhase()),0); + outStream[1].getThermoSystem().addComponent("MDEA", -error * factor); + outStream[1].getThermoSystem().addComponent("water", -error * 10.0 * factor); + outStream[1].run(); + error = absorptionEfficiency - ((outStream[1].getThermoSystem().getPhase(1) + .getComponent("CO2").getNumberOfMolesInPhase() + + outStream[1].getThermoSystem().getPhase(1).getComponent("HCO3-") + .getNumberOfMolesInPhase()) + / (outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA") + .getNumberOfMolesInPhase() + + outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA+") + .getNumberOfMolesInPhase())); + + System.out.println("error " + error); + } while (Math.abs(error) > 1e-4 && iter < 30 + && outStream[1].getThermoSystem().getPhase(1).getBeta() > 0 + && outStream[0].getThermoSystem().getPhase(1).getBeta() > 0); + outStream[1].setCalculationIdentifier(id); + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + outStream[0].displayResult(); + outStream[1].displayResult(); + } + + /** {@inheritDoc} */ + @Override + public void setAproachToEquilibrium(double eff) { + this.absorptionEfficiency = eff; + } + + /** + *

+ * Getter for the field numberOfTheoreticalStages. + *

+ * + * @return a double + */ + public double getNumberOfTheoreticalStages() { + return numberOfTheoreticalStages; + } + + /** + *

+ * Setter for the field numberOfTheoreticalStages. + *

+ * + * @param numberOfTheoreticalStages a double + */ + public void setNumberOfTheoreticalStages(double numberOfTheoreticalStages) { + this.numberOfTheoreticalStages = numberOfTheoreticalStages; + } + + /** + *

+ * Getter for the field numberOfStages. + *

+ * + * @return a int + */ + public int getNumberOfStages() { + return numberOfStages; + } + + /** + *

+ * Setter for the field numberOfStages. + *

+ * + * @param numberOfStages a int + */ + public void setNumberOfStages(int numberOfStages) { + this.numberOfStages = numberOfStages; + } + + /** + *

+ * Getter for the field stageEfficiency. + *

+ * + * @return a double + */ + public double getStageEfficiency() { + return stageEfficiency; + } + + /** + *

+ * Setter for the field stageEfficiency. + *

+ * + * @param stageEfficiency a double + */ + public void setStageEfficiency(double stageEfficiency) { + this.stageEfficiency = stageEfficiency; + } + + /** + *

+ * getHTU. + *

+ * + * @return a double + */ + public double getHTU() { + return HTU; + } + + /** + *

+ * setHTU. + *

+ * + * @param HTU a double + */ + public void setHTU(double HTU) { + this.HTU = HTU; + } + + /** + *

+ * getNTU. + *

+ * + * @return a double + */ + public double getNTU() { + return NTU; + } + + /** + *

+ * setNTU. + *

+ * + * @param NTU a double + */ + public void setNTU(double NTU) { + this.NTU = NTU; + } + + /** + *

+ * Getter for the field fsFactor. + *

+ * + * @return a double + */ + public double getFsFactor() { + double intArea = 3.14 * getInternalDiameter() * getInternalDiameter() / 4.0; + return getGasOutStream().getThermoSystem().getFlowRate("m3/sec") / intArea + * Math.sqrt(getGasOutStream().getThermoSystem().getDensity("kg/m3")); + } + + /** + *

+ * getWettingRate. + *

+ * + * @return a double + */ + public double getWettingRate() { + double intArea = 3.14 * getInternalDiameter() * getInternalDiameter() / 4.0; + return getLiquidOutStream().getThermoSystem().getFlowRate("m3/hr") / intArea; + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/absorber/SimpleTEGAbsorber.java b/src/main/java/neqsim/processSimulation/processEquipment/absorber/SimpleTEGAbsorber.java index 71fd3be756..875dbbc913 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/absorber/SimpleTEGAbsorber.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/absorber/SimpleTEGAbsorber.java @@ -5,6 +5,7 @@ import java.text.DecimalFormat; import java.text.FieldPosition; import java.util.ArrayList; +import java.util.UUID; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JScrollPane; @@ -24,582 +25,579 @@ * @version $Id: $Id */ public class SimpleTEGAbsorber extends SimpleAbsorber { - private static final long serialVersionUID = 1000; - - protected ArrayList streams = new ArrayList(0); - protected double pressure = 0; - protected int numberOfInputStreams = 0; - protected StreamInterface mixedStream; - protected StreamInterface gasInStream; - protected StreamInterface solventInStream; - private StreamInterface gasOutStream; - private StreamInterface solventOutStream; - protected StreamInterface outStream; - private double kwater = 1e-4; - int solventStreamNumber = 0; - private boolean isSetWaterInDryGas = false; - private double waterInDryGas = 30e-6; - - - /** - *

- * Constructor for SimpleTEGAbsorber. - *

- */ - @Deprecated - public SimpleTEGAbsorber() { + private static final long serialVersionUID = 1000; + + protected ArrayList streams = new ArrayList(0); + protected double pressure = 0; + protected int numberOfInputStreams = 0; + protected StreamInterface mixedStream; + protected StreamInterface gasInStream; + protected StreamInterface solventInStream; + private StreamInterface gasOutStream; + private StreamInterface solventOutStream; + protected StreamInterface outStream; + private double kwater = 1e-4; + int solventStreamNumber = 0; + private boolean isSetWaterInDryGas = false; + private double waterInDryGas = 30e-6; + + /** + *

+ * Constructor for SimpleTEGAbsorber. + *

+ */ + @Deprecated + public SimpleTEGAbsorber() {} + + /** + *

+ * Constructor for SimpleTEGAbsorber. + *

+ * + * @param name a {@link java.lang.String} object + */ + public SimpleTEGAbsorber(String name) { + super(name); + } + + /** {@inheritDoc} */ + @Override + public void addStream(StreamInterface newStream) { + streams.add(newStream); + if (numberOfInputStreams == 0) { + mixedStream = (Stream) streams.get(0).clone(); + mixedStream.getThermoSystem().setNumberOfPhases(2); + mixedStream.getThermoSystem().reInitPhaseType(); + mixedStream.getThermoSystem().init(0); + mixedStream.getThermoSystem().init(3); } - /** - *

- * Constructor for SimpleTEGAbsorber. - *

- * - * @param name a {@link java.lang.String} object - */ - public SimpleTEGAbsorber(String name) { - super(name); - } - - /** {@inheritDoc} */ - @Override - public void addStream(StreamInterface newStream) { - streams.add(newStream); - if (numberOfInputStreams == 0) { - mixedStream = (Stream) streams.get(0).clone(); - mixedStream.getThermoSystem().setNumberOfPhases(2); - mixedStream.getThermoSystem().reInitPhaseType(); - mixedStream.getThermoSystem().init(0); - mixedStream.getThermoSystem().init(3); + numberOfInputStreams++; + } + + /** + *

+ * addGasInStream. + *

+ * + * @param newStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public void addGasInStream(StreamInterface newStream) { + // todo: fail if gasInStream is not null? + gasInStream = (Stream) newStream; + gasOutStream = (Stream) newStream.clone(); + addStream(newStream); + } + + /** + *

+ * addSolventInStream. + *

+ * + * @param newStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public void addSolventInStream(StreamInterface newStream) { + // todo: fail if solventInStream is not null? + solventInStream = (Stream) newStream; + solventOutStream = (Stream) newStream.clone(); + addStream(newStream); + solventStreamNumber = streams.size() - 1; + } + + /** + *

+ * replaceSolventInStream. + *

+ * + * @param newStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public void replaceSolventInStream(StreamInterface newStream) { + // todo: fails if solventStreamNumber is 0, i.e. no solventinstream set? + solventInStream = (Stream) newStream; + streams.set(solventStreamNumber, solventInStream); + } + + /** {@inheritDoc} */ + @Override + public void setPressure(double pressure) { + this.pressure = pressure; + } + + /** + *

+ * mixStream. + *

+ */ + public void mixStream() { + String compName = new String(); + + for (int k = 1; k < streams.size(); k++) { + for (int i = 0; i < streams.get(k).getThermoSystem().getPhases()[0] + .getNumberOfComponents(); i++) { + boolean gotComponent = false; + String componentName = + streams.get(k).getThermoSystem().getPhases()[0].getComponents()[i].getName(); + // System.out.println("adding: " + componentName); + + double moles = + streams.get(k).getThermoSystem().getPhases()[0].getComponents()[i].getNumberOfmoles(); + // System.out.println("moles: " + moles + " " + + // mixedStream.getThermoSystem().getPhases()[0].getNumberOfComponents()); + for (int p = 0; p < mixedStream.getThermoSystem().getPhases()[0] + .getNumberOfComponents(); p++) { + if (mixedStream.getThermoSystem().getPhases()[0].getComponents()[p].getName() + .equals(componentName)) { + gotComponent = true; + compName = streams.get(0).getThermoSystem().getPhases()[0].getComponents()[p] + .getComponentName(); + } } - numberOfInputStreams++; - } - - /** - *

- * addGasInStream. - *

- * - * @param newStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - public void addGasInStream(StreamInterface newStream) { - gasInStream = (Stream) newStream; - gasOutStream = (Stream) newStream.clone(); - addStream(newStream); - } - - /** - *

- * addSolventInStream. - *

- * - * @param newStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - public void addSolventInStream(StreamInterface newStream) { - solventInStream = (Stream) newStream; - solventOutStream = (Stream) newStream.clone(); - addStream(newStream); - solventStreamNumber = streams.size() - 1; - } - - /** - *

- * replaceSolventInStream. - *

- * - * @param newStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - public void replaceSolventInStream(StreamInterface newStream) { - solventInStream = (Stream) newStream; - streams.set(solventStreamNumber, solventInStream); - } - - /** {@inheritDoc} */ - @Override - public void setPressure(double pressure) { - this.pressure = pressure; - } - - /** - *

- * mixStream. - *

- */ - public void mixStream() { - String compName = new String(); - - for (int k = 1; k < streams.size(); k++) { - for (int i = 0; i < streams.get(k).getThermoSystem().getPhases()[0] - .getNumberOfComponents(); i++) { - boolean gotComponent = false; - String componentName = - streams.get(k).getThermoSystem().getPhases()[0].getComponents()[i] - .getName(); - // System.out.println("adding: " + componentName); - - double moles = streams.get(k).getThermoSystem().getPhases()[0].getComponents()[i] - .getNumberOfmoles(); - // System.out.println("moles: " + moles + " " + - // mixedStream.getThermoSystem().getPhases()[0].getNumberOfComponents()); - for (int p = 0; p < mixedStream.getThermoSystem().getPhases()[0] - .getNumberOfComponents(); p++) { - if (mixedStream.getThermoSystem().getPhases()[0].getComponents()[p].getName() - .equals(componentName)) { - gotComponent = true; - compName = - streams.get(0).getThermoSystem().getPhases()[0].getComponents()[p] - .getComponentName(); - } - } - - if (gotComponent) { - // System.out.println("adding moles starting...."); - mixedStream.getThermoSystem().addComponent(compName, moles); - // mixedStream.getThermoSystem().init_x_y(); - // System.out.println("adding moles finished"); - } else { - // System.out.println("ikke gaa hit"); - mixedStream.getThermoSystem().addComponent(compName, moles); - } - } + if (gotComponent) { + // System.out.println("adding moles starting...."); + mixedStream.getThermoSystem().addComponent(compName, moles); + // mixedStream.getThermoSystem().init_x_y(); + // System.out.println("adding moles finished"); + } else { + // System.out.println("ikke gaa hit"); + mixedStream.getThermoSystem().addComponent(compName, moles); } - mixedStream.getThermoSystem().init_x_y(); - mixedStream.getThermoSystem().initBeta(); - mixedStream.getThermoSystem().init(2); + } } - - /** - *

- * guessTemperature. - *

- * - * @return a double - */ - public double guessTemperature() { - double gtemp = 0; - for (int k = 0; k < streams.size(); k++) { - gtemp += streams.get(k).getThermoSystem().getTemperature() - * streams.get(k).getThermoSystem().getNumberOfMoles() - / mixedStream.getThermoSystem().getNumberOfMoles(); - } - return gtemp; + mixedStream.getThermoSystem().init_x_y(); + mixedStream.getThermoSystem().initBeta(); + mixedStream.getThermoSystem().init(2); + } + + /** + *

+ * guessTemperature. + *

+ * + * @return a double + */ + public double guessTemperature() { + double gtemp = 0; + for (int k = 0; k < streams.size(); k++) { + gtemp += streams.get(k).getThermoSystem().getTemperature() + * streams.get(k).getThermoSystem().getNumberOfMoles() + / mixedStream.getThermoSystem().getNumberOfMoles(); } - - /** - *

- * calcMixStreamEnthalpy. - *

- * - * @return a double - */ - public double calcMixStreamEnthalpy() { - double enthalpy = 0; - for (int k = 0; k < streams.size(); k++) { - streams.get(k).getThermoSystem().init(3); - enthalpy += streams.get(k).getThermoSystem().getEnthalpy(); - // System.out.println("total enthalpy k : " + ( - // ((StreamInterface) streams.get(k)).getThermoSystem()).getEnthalpy()); - } - // System.out.println("total enthalpy of streams: " + enthalpy); - return enthalpy; - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getOutStream() { - return mixedStream; + return gtemp; + } + + /** + *

+ * calcMixStreamEnthalpy. + *

+ * + * @return a double + */ + public double calcMixStreamEnthalpy() { + double enthalpy = 0; + for (int k = 0; k < streams.size(); k++) { + streams.get(k).getThermoSystem().init(3); + enthalpy += streams.get(k).getThermoSystem().getEnthalpy(); + // System.out.println("total enthalpy k : " + ( + // ((StreamInterface) streams.get(k)).getThermoSystem()).getEnthalpy()); } + // System.out.println("total enthalpy of streams: " + enthalpy); + return enthalpy; + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getOutStream() { + return mixedStream; + } + + /** + *

+ * getInStream. + *

+ * + * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + */ + public StreamInterface getInStream() { + return gasInStream; + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getGasOutStream() { + return gasOutStream; + } + + /** + *

+ * Getter for the field gasInStream. + *

+ * + * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + */ + public StreamInterface getGasInStream() { + return gasInStream; + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getLiquidOutStream() { + return solventOutStream; + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getSolventInStream() { + return solventInStream; + } + + /** + *

+ * calcEa. + *

+ * + * @return a double + */ + public double calcEa() { + double A = mixedStream.getThermoSystem().getPhase(1).getNumberOfMolesInPhase() + / mixedStream.getThermoSystem().getPhase(0).getNumberOfMolesInPhase() / kwater; + absorptionEfficiency = (Math.pow(A, getNumberOfTheoreticalStages() + 1) - A) + / (Math.pow(A, getNumberOfTheoreticalStages() + 1) - 1.0); + return absorptionEfficiency; + } + + /** + *

+ * calcY0. + *

+ * + * @return a double + */ + public double calcY0() { + // double fugacityWaterLiquid = + // mixedStream.getThermoSystem().getPhase(1).getFugacity("water"); + // double xrel = + // mixedStream.getFluid().getPhase(0).getComponent("water").getx()/solventInStream.getFluid().getPhase(0).getComponent("water").getx(); + // double y0 = + // xrel*fugacityWaterLiquid/(mixedStream.getFluid().getPhase(0).getComponent("water").getFugacityCoefficient()*mixedStream.getFluid().getPressure()); + double fugCoefRef = + mixedStream.getThermoSystem().getPhase(1).getComponent("water").getFugacityCoefficient(); + double y0 = solventInStream.getFluid().getPhase(0).getComponent("water").getx() * fugCoefRef + / (mixedStream.getThermoSystem().getPhase(0).getComponent("water") + .getFugacityCoefficient()); + return y0; + } + + /** + *

+ * calcNumberOfTheoreticalStages. + *

+ * + * @return a double + */ + public double calcNumberOfTheoreticalStages() { + setNumberOfTheoreticalStages(getStageEfficiency() * getNumberOfStages()); + return getNumberOfTheoreticalStages(); + } + + /** + *

+ * calcNTU. + *

+ * + * @param y0 a double + * @param y1 a double + * @param yb a double + * @param ymix a double + * @return a double + */ + public double calcNTU(double y0, double y1, double yb, double ymix) { + return Math.log((yb - ymix) / (y1 - y0)); + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + try { + double y1 = 0.0; + // double yN = gasInStream.getThermoSystem().getPhase(0).getComponent("water").getx(); + mixedStream.setThermoSystem((streams.get(0).getThermoSystem().clone())); + mixedStream.getThermoSystem().setNumberOfPhases(2); + mixedStream.getThermoSystem().reInitPhaseType(); + mixedStream.getThermoSystem().init(0); + mixStream(); + // System.out.println("feed total number of water " + + // mixedStream.getFluid().getPhase(0).getComponent("water").getNumberOfmoles()); + double enthalpy = calcMixStreamEnthalpy(); + //// System.out.println("temp guess " + guessTemperature()); + mixedStream.getThermoSystem().setTemperature(guessTemperature()); + ThermodynamicOperations testOps = new ThermodynamicOperations(mixedStream.getThermoSystem()); + testOps.TPflash(); + testOps.PHflash(enthalpy, 0); + + kwater = mixedStream.getThermoSystem().getPhase(0).getComponent("water").getx() + / mixedStream.getThermoSystem().getPhase(1).getComponent("water").getx(); + + calcNumberOfTheoreticalStages(); + // System.out.println("number of theoretical stages " + + // getNumberOfTheoreticalStages()); + double absorptionEffiency = calcEa(); - /** - *

- * getInStream. - *

- * - * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - public StreamInterface getInStream() { - return gasInStream; - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getGasOutStream() { - return gasOutStream; - } - - /** - *

- * Getter for the field gasInStream. - *

- * - * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - public StreamInterface getGasInStream() { - return gasInStream; - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getLiquidOutStream() { - return solventOutStream; - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getSolventInStream() { - return solventInStream; - } - - /** - *

- * calcEa. - *

- * - * @return a double - */ - public double calcEa() { - double A = mixedStream.getThermoSystem().getPhase(1).getNumberOfMolesInPhase() - / mixedStream.getThermoSystem().getPhase(0).getNumberOfMolesInPhase() / kwater; - absorptionEfficiency = (Math.pow(A, getNumberOfTheoreticalStages() + 1) - A) - / (Math.pow(A, getNumberOfTheoreticalStages() + 1) - 1.0); - return absorptionEfficiency; - } - - /** - *

- * calcY0. - *

- * - * @return a double - */ - public double calcY0() { - // double fugacityWaterLiquid = - // mixedStream.getThermoSystem().getPhase(1).getFugacity("water"); - // double xrel = - // mixedStream.getFluid().getPhase(0).getComponent("water").getx()/solventInStream.getFluid().getPhase(0).getComponent("water").getx(); - // double y0 = - // xrel*fugacityWaterLiquid/(mixedStream.getFluid().getPhase(0).getComponent("water").getFugacityCoefficient()*mixedStream.getFluid().getPressure()); - double fugCoefRef = mixedStream.getThermoSystem().getPhase(1).getComponent("water") - .getFugacityCoefficient(); - double y0 = solventInStream.getFluid().getPhase(0).getComponent("water").getx() * fugCoefRef - / (mixedStream.getThermoSystem().getPhase(0).getComponent("water") - .getFugacityCoefficient()); - return y0; - } - - /** - *

- * calcNumberOfTheoreticalStages. - *

- * - * @return a double - */ - public double calcNumberOfTheoreticalStages() { - setNumberOfTheoreticalStages(getStageEfficiency() * getNumberOfStages()); - return getNumberOfTheoreticalStages(); - } - - /** - *

- * calcNTU. - *

- * - * @param y0 a double - * @param y1 a double - * @param yb a double - * @param ymix a double - * @return a double - */ - public double calcNTU(double y0, double y1, double yb, double ymix) { - double NTU = Math.log((yb - ymix) / (y1 - y0)); - return NTU; - } - - /** {@inheritDoc} */ - @Override - public void run() { - try { - double y0 = 0.0, y1 = 0.0; - // double yN = gasInStream.getThermoSystem().getPhase(0).getComponent("water").getx(); - double absorptionEffiency = 0.0; - mixedStream.setThermoSystem((streams.get(0).getThermoSystem().clone())); - mixedStream.getThermoSystem().setNumberOfPhases(2); - mixedStream.getThermoSystem().reInitPhaseType(); - mixedStream.getThermoSystem().init(0); - mixStream(); - // System.out.println("feed total number of water " + - // mixedStream.getFluid().getPhase(0).getComponent("water").getNumberOfmoles()); - double enthalpy = calcMixStreamEnthalpy(); - //// System.out.println("temp guess " + guessTemperature()); - mixedStream.getThermoSystem().setTemperature(guessTemperature()); - ThermodynamicOperations testOps = - new ThermodynamicOperations(mixedStream.getThermoSystem()); - testOps.TPflash(); - testOps.PHflash(enthalpy, 0); - - kwater = mixedStream.getThermoSystem().getPhase(0).getComponent("water").getx() - / mixedStream.getThermoSystem().getPhase(1).getComponent("water").getx(); - - calcNumberOfTheoreticalStages(); - // System.out.println("number of theoretical stages " + - // getNumberOfTheoreticalStages()); - absorptionEffiency = calcEa(); - - y0 = calcY0(); - if (isSetWaterInDryGas) { - y1 = waterInDryGas; - setNumberOfTheoreticalStages(2.0); - } else { - y1 = gasInStream.getThermoSystem().getPhase(0).getComponent("water").getx() - - absorptionEffiency - * (gasInStream.getThermoSystem().getPhase(0).getComponent("water").getx() - - y0); - } - - double yMean = mixedStream.getThermoSystem().getPhase(0).getComponent("water").getx(); - double molesWaterToMove = (yMean - y1) - * mixedStream.getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); - // System.out.println("Lean TEG to absorber " - // +solventInStream.getFlowRate("kg/hr")); - - // System.out.println("mole water to move " + molesWaterToMove); - // System.out.println("total moles water in gas " + - // mixedStream.getThermoSystem().getPhase(0).getComponent("water").getNumberOfMolesInPhase()); - // System.out.println("total moles water " + - // mixedStream.getThermoSystem().getPhase(0).getComponent("water").getNumberOfmoles()); - StreamInterface stream = mixedStream.clone(); - stream.setName("test"); - stream.getThermoSystem().addComponent("water", -molesWaterToMove, 0); - stream.getThermoSystem().addComponent("water", molesWaterToMove, 1); - stream.getThermoSystem().initBeta(); - stream.getThermoSystem().init_x_y(); - stream.getThermoSystem().init(2); - mixedStream = stream; - - // stream.getThermoSystem().display(); - - SystemInterface tempSystem = mixedStream.getThermoSystem().clone(); - SystemInterface gasTemp = tempSystem.phaseToSystem(tempSystem.getPhases()[0]); - gasTemp.init(2); - gasOutStream.setThermoSystem(gasTemp); - // System.out.println("gas total number of water " + - // gasOutStream.getFluid().getPhase(0).getComponent("water").getNumberOfmoles()); - - tempSystem = mixedStream.getThermoSystem().clone(); - SystemInterface liqTemp = tempSystem.phaseToSystem(tempSystem.getPhases()[1]); - liqTemp.init(2); - solventOutStream.setThermoSystem(liqTemp); - // System.out.println("solvent total number of water " + - // solventOutStream.getFluid().getPhase(0).getComponent("water").getNumberOfmoles()); - - setNTU(calcNTU(y0, y1, - gasInStream.getThermoSystem().getPhase(0).getComponent("water").getx(), yMean)); - // System.out.println("NTU " + getNTU()); - - // double Ks = 0.055; - getSolventOutStream().getThermoSystem().initPhysicalProperties(); - getGasOutStream().getThermoSystem().initPhysicalProperties(); - - // double vtemp = Ks * Math.sqrt((getSolventOutStream().getThermoSystem().getPhase(0) - // .getPhysicalProperties().getDensity() - - // getGasOutStream().getThermoSystem().getPhase(0).getPhysicalProperties() - // .getDensity()) / - // getSolventOutStream().getThermoSystem().getPhase(0).getPhysicalProperties().getDensity()); - - // double d = Math.sqrt(4.0 * getGasOutStream().getMolarRate() * - // getGasOutStream().getThermoSystem().getPhase(0).getMolarMass() / - // getGasOutStream().getThermoSystem().getPhase(0).getPhysicalProperties() - // .getDensity()/ 3.14 / vtemp); - // System.out.println("diameter " + d); - } catch (Exception e) { - e.printStackTrace(); - } - // System.out.println("rich TEG from absorber " + - // getSolventOutStream().getFlowRate("kg/hr")); - } - - /** - *

- * getGasLoadFactor. - *

- * - * @return a double - */ - public double getGasLoadFactor() { - double intArea = 3.14 * getInternalDiameter() * getInternalDiameter() / 4.0; - double vs = getGasOutStream().getThermoSystem().getFlowRate("m3/sec") / intArea; - return vs / Math.sqrt((getSolventOutStream().getThermoSystem().getPhase(0) - .getPhysicalProperties().getDensity() - - getGasOutStream().getThermoSystem().getPhase(0).getPhysicalProperties() - .getDensity()) - / getSolventOutStream().getThermoSystem().getPhase(0).getPhysicalProperties() - .getDensity()); - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - SystemInterface thermoSystem = mixedStream.getThermoSystem(); - DecimalFormat nf = new DecimalFormat(); - nf.setMaximumFractionDigits(5); - nf.applyPattern("#.#####E0"); - - JDialog dialog = new JDialog(new JFrame(), "Results from TPflash"); - Container dialogContentPane = dialog.getContentPane(); - dialogContentPane.setLayout(new FlowLayout()); - - thermoSystem.initPhysicalProperties(); - String[][] table = new String[50][5]; - String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"}; - table[0][0] = ""; - table[0][1] = ""; - table[0][2] = ""; - table[0][3] = ""; - StringBuffer buf = new StringBuffer(); - FieldPosition test = new FieldPosition(0); - - for (int i = 0; i < thermoSystem.getNumberOfPhases(); i++) { - for (int j = 0; j < thermoSystem.getPhases()[0].getNumberOfComponents(); j++) { - table[j + 1][0] = thermoSystem.getPhases()[0].getComponents()[j].getName(); - buf = new StringBuffer(); - table[j + 1][i + 1] = - nf.format(thermoSystem.getPhases()[i].getComponents()[j].getx(), buf, test) - .toString(); - table[j + 1][4] = "[-]"; - } - buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 2][0] = "Density"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 2][i + 1] = - nf.format(thermoSystem.getPhases()[i].getPhysicalProperties().getDensity(), buf, - test).toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 2][4] = "[kg/m^3]"; - - // Double.longValue(thermoSystem.getPhases()[i].getBeta()); - - buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 3][0] = "PhaseFraction"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 3][i + 1] = - nf.format(thermoSystem.getPhases()[i].getBeta(), buf, test).toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 3][4] = "[-]"; - - buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 4][0] = "MolarMass"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 4][i + 1] = - nf.format(thermoSystem.getPhases()[i].getMolarMass() * 1000, buf, test) - .toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 4][4] = "[kg/kmol]"; - - buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 5][0] = "Cp"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 5][i + 1] = nf.format( - (thermoSystem.getPhases()[i].getCp() - / (thermoSystem.getPhases()[i].getNumberOfMolesInPhase() - * thermoSystem.getPhases()[i].getMolarMass() * 1000)), - buf, test).toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 5][4] = "[kJ/kg*K]"; - - buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 7][0] = "Viscosity"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 7][i + 1] = - nf.format((thermoSystem.getPhases()[i].getPhysicalProperties().getViscosity()), - buf, test).toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 7][4] = "[kg/m*sec]"; - - buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 8][0] = "Conductivity"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 8][i + 1] = - nf.format(thermoSystem.getPhases()[i].getPhysicalProperties().getConductivity(), - buf, test).toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 8][4] = "[W/m*K]"; - - buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 10][0] = "Pressure"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 10][i + 1] = - Double.toString(thermoSystem.getPhases()[i].getPressure()); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 10][4] = "[bar]"; - - buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 11][0] = "Temperature"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 11][i + 1] = - Double.toString(thermoSystem.getPhases()[i].getTemperature()); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 11][4] = "[K]"; - Double.toString(thermoSystem.getPhases()[i].getTemperature()); - - buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 13][0] = "Stream"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 13][i + 1] = getName(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 13][4] = "-"; - } - - JTable Jtab = new JTable(table, names); - JScrollPane scrollpane = new JScrollPane(Jtab); - dialogContentPane.add(scrollpane); - dialog.pack(); - dialog.setVisible(true); - } - - /** - *

- * Setter for the field gasOutStream. - *

- * - * @param gasOutStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - public void setGasOutStream(StreamInterface gasOutStream) { - this.gasOutStream = gasOutStream; - } - - /** - *

- * Getter for the field solventOutStream. - *

- * - * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - public StreamInterface getSolventOutStream() { - return solventOutStream; - } - - /** - *

- * Setter for the field solventOutStream. - *

- * - * @param solventOutStream a - * {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ - public void setSolventOutStream(StreamInterface solventOutStream) { - this.solventOutStream = solventOutStream; - } - - /** {@inheritDoc} */ - @Override - public void runConditionAnalysis(ProcessEquipmentInterface refTEGabsorberloc) { - double yin = getGasInStream().getFluid().getPhase("gas").getComponent("water").getx(); - double yout = getGasOutStream().getFluid().getPhase("gas").getComponent("water").getx(); double y0 = calcY0(); - double A = mixedStream.getThermoSystem().getPhase(1).getNumberOfMolesInPhase() - / mixedStream.getThermoSystem().getPhase(0).getNumberOfMolesInPhase() / kwater; - double N = Math.log(((A - 1.0) / A) * ((yin - y0) / (yout - y0)) + (1.0 / A)) / Math.log(A); - setNumberOfTheoreticalStages(N); + if (isSetWaterInDryGas) { + y1 = waterInDryGas; + setNumberOfTheoreticalStages(2.0); + } else { + y1 = gasInStream.getThermoSystem().getPhase(0).getComponent("water").getx() + - absorptionEffiency + * (gasInStream.getThermoSystem().getPhase(0).getComponent("water").getx() - y0); + } + + double yMean = mixedStream.getThermoSystem().getPhase(0).getComponent("water").getx(); + double molesWaterToMove = + (yMean - y1) * mixedStream.getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); + // System.out.println("Lean TEG to absorber " + // +solventInStream.getFlowRate("kg/hr")); + + // System.out.println("mole water to move " + molesWaterToMove); + // System.out.println("total moles water in gas " + + // mixedStream.getThermoSystem().getPhase(0).getComponent("water").getNumberOfMolesInPhase()); + // System.out.println("total moles water " + + // mixedStream.getThermoSystem().getPhase(0).getComponent("water").getNumberOfmoles()); + StreamInterface newMixedStream = mixedStream.clone(); + newMixedStream.setName("test"); + newMixedStream.getThermoSystem().addComponent("water", -molesWaterToMove, 0); + newMixedStream.getThermoSystem().addComponent("water", molesWaterToMove, 1); + newMixedStream.getThermoSystem().initBeta(); + newMixedStream.getThermoSystem().init_x_y(); + newMixedStream.getThermoSystem().init(2); + mixedStream = newMixedStream; + mixedStream.setCalculationIdentifier(id); + + // stream.getThermoSystem().display(); + + SystemInterface tempSystem = mixedStream.getThermoSystem().clone(); + SystemInterface gasTemp = tempSystem.phaseToSystem(tempSystem.getPhases()[0]); + gasTemp.init(2); + gasOutStream.setThermoSystem(gasTemp); + // System.out.println("gas total number of water " + + // gasOutStream.getFluid().getPhase(0).getComponent("water").getNumberOfmoles()); + + tempSystem = mixedStream.getThermoSystem().clone(); + SystemInterface liqTemp = tempSystem.phaseToSystem(tempSystem.getPhases()[1]); + liqTemp.init(2); + solventOutStream.setThermoSystem(liqTemp); + // System.out.println("solvent total number of water " + + // solventOutStream.getFluid().getPhase(0).getComponent("water").getNumberOfmoles()); + + setNTU(calcNTU(y0, y1, gasInStream.getThermoSystem().getPhase(0).getComponent("water").getx(), + yMean)); + // System.out.println("NTU " + getNTU()); + + // double Ks = 0.055; + getSolventOutStream().getThermoSystem().initPhysicalProperties(); + getSolventOutStream().setCalculationIdentifier(id); + getGasOutStream().getThermoSystem().initPhysicalProperties(); + getGasOutStream().setCalculationIdentifier(id); + + // double vtemp = Ks * Math.sqrt((getSolventOutStream().getThermoSystem().getPhase(0) + // .getPhysicalProperties().getDensity() - + // getGasOutStream().getThermoSystem().getPhase(0).getPhysicalProperties() + // .getDensity()) / + // getSolventOutStream().getThermoSystem().getPhase(0).getPhysicalProperties().getDensity()); + + // double d = Math.sqrt(4.0 * getGasOutStream().getMolarRate() * + // getGasOutStream().getThermoSystem().getPhase(0).getMolarMass() / + // getGasOutStream().getThermoSystem().getPhase(0).getPhysicalProperties() + // .getDensity()/ 3.14 / vtemp); + // System.out.println("diameter " + d); + setCalculationIdentifier(id); + } catch (Exception e) { + e.printStackTrace(); } - - /** - *

- * Setter for the field waterInDryGas. - *

- * @param waterInDryGasInput water in dry gas - */ - public void setWaterInDryGas(double waterInDryGasInput) { - waterInDryGas = waterInDryGasInput; - isSetWaterInDryGas = true; + // System.out.println("rich TEG from absorber " + + // getSolventOutStream().getFlowRate("kg/hr")); + } + + /** + *

+ * getGasLoadFactor. + *

+ * + * @return a double + */ + public double getGasLoadFactor() { + double intArea = 3.14 * getInternalDiameter() * getInternalDiameter() / 4.0; + double vs = getGasOutStream().getThermoSystem().getFlowRate("m3/sec") / intArea; + return vs / Math.sqrt( + (getSolventOutStream().getThermoSystem().getPhase(0).getPhysicalProperties().getDensity() + - getGasOutStream().getThermoSystem().getPhase(0).getPhysicalProperties().getDensity()) + / getSolventOutStream().getThermoSystem().getPhase(0).getPhysicalProperties() + .getDensity()); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + SystemInterface thermoSystem = mixedStream.getThermoSystem(); + DecimalFormat nf = new DecimalFormat(); + nf.setMaximumFractionDigits(5); + nf.applyPattern("#.#####E0"); + + JDialog dialog = new JDialog(new JFrame(), "Results from TPflash"); + Container dialogContentPane = dialog.getContentPane(); + dialogContentPane.setLayout(new FlowLayout()); + + thermoSystem.initPhysicalProperties(); + String[][] table = new String[50][5]; + String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"}; + table[0][0] = ""; + table[0][1] = ""; + table[0][2] = ""; + table[0][3] = ""; + StringBuffer buf = new StringBuffer(); + FieldPosition test = new FieldPosition(0); + + for (int i = 0; i < thermoSystem.getNumberOfPhases(); i++) { + for (int j = 0; j < thermoSystem.getPhases()[0].getNumberOfComponents(); j++) { + table[j + 1][0] = thermoSystem.getPhases()[0].getComponents()[j].getName(); + buf = new StringBuffer(); + table[j + 1][i + 1] = + nf.format(thermoSystem.getPhases()[i].getComponents()[j].getx(), buf, test).toString(); + table[j + 1][4] = "[-]"; + } + buf = new StringBuffer(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 2][0] = "Density"; + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 2][i + 1] = + nf.format(thermoSystem.getPhases()[i].getPhysicalProperties().getDensity(), buf, test) + .toString(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 2][4] = "[kg/m^3]"; + + // Double.longValue(thermoSystem.getPhases()[i].getBeta()); + + buf = new StringBuffer(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 3][0] = "PhaseFraction"; + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 3][i + 1] = + nf.format(thermoSystem.getPhases()[i].getBeta(), buf, test).toString(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 3][4] = "[-]"; + + buf = new StringBuffer(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 4][0] = "MolarMass"; + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 4][i + 1] = + nf.format(thermoSystem.getPhases()[i].getMolarMass() * 1000, buf, test).toString(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 4][4] = "[kg/kmol]"; + + buf = new StringBuffer(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 5][0] = "Cp"; + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 5][i + 1] = + nf.format((thermoSystem.getPhases()[i].getCp() + / (thermoSystem.getPhases()[i].getNumberOfMolesInPhase() + * thermoSystem.getPhases()[i].getMolarMass() * 1000)), + buf, test).toString(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 5][4] = "[kJ/kg*K]"; + + buf = new StringBuffer(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 7][0] = "Viscosity"; + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 7][i + 1] = + nf.format((thermoSystem.getPhases()[i].getPhysicalProperties().getViscosity()), buf, test) + .toString(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 7][4] = "[kg/m*sec]"; + + buf = new StringBuffer(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 8][0] = "Conductivity"; + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 8][i + 1] = nf + .format(thermoSystem.getPhases()[i].getPhysicalProperties().getConductivity(), buf, test) + .toString(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 8][4] = "[W/m*K]"; + + buf = new StringBuffer(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 10][0] = "Pressure"; + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 10][i + 1] = + Double.toString(thermoSystem.getPhases()[i].getPressure()); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 10][4] = "[bar]"; + + buf = new StringBuffer(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 11][0] = "Temperature"; + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 11][i + 1] = + Double.toString(thermoSystem.getPhases()[i].getTemperature()); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 11][4] = "[K]"; + Double.toString(thermoSystem.getPhases()[i].getTemperature()); + + buf = new StringBuffer(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 13][0] = "Stream"; + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 13][i + 1] = getName(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 13][4] = "-"; } - public void isSetWaterInDryGas(boolean isSetwaterInDryGas) { - this.isSetWaterInDryGas = isSetwaterInDryGas; - } + JTable Jtab = new JTable(table, names); + JScrollPane scrollpane = new JScrollPane(Jtab); + dialogContentPane.add(scrollpane); + dialog.pack(); + dialog.setVisible(true); + } + + /** + *

+ * Setter for the field gasOutStream. + *

+ * + * @param gasOutStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + */ + public void setGasOutStream(StreamInterface gasOutStream) { + this.gasOutStream = gasOutStream; + } + + /** + *

+ * Getter for the field solventOutStream. + *

+ * + * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + */ + public StreamInterface getSolventOutStream() { + return solventOutStream; + } + + /** + *

+ * Setter for the field solventOutStream. + *

+ * + * @param solventOutStream a + * {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + public void setSolventOutStream(StreamInterface solventOutStream) { + this.solventOutStream = solventOutStream; + } + + /** {@inheritDoc} */ + @Override + public void runConditionAnalysis(ProcessEquipmentInterface refTEGabsorberloc) { + double yin = getGasInStream().getFluid().getPhase("gas").getComponent("water").getx(); + double yout = getGasOutStream().getFluid().getPhase("gas").getComponent("water").getx(); + double y0 = calcY0(); + double A = mixedStream.getThermoSystem().getPhase(1).getNumberOfMolesInPhase() + / mixedStream.getThermoSystem().getPhase(0).getNumberOfMolesInPhase() / kwater; + double N = Math.log(((A - 1.0) / A) * ((yin - y0) / (yout - y0)) + (1.0 / A)) / Math.log(A); + setNumberOfTheoreticalStages(N); + } + + /** + *

+ * Setter for the field waterInDryGas. + *

+ * + * @param waterInDryGasInput water in dry gas + */ + public void setWaterInDryGas(double waterInDryGasInput) { + waterInDryGas = waterInDryGasInput; + isSetWaterInDryGas = true; + } + + public void isSetWaterInDryGas(boolean isSetwaterInDryGas) { + this.isSetWaterInDryGas = isSetwaterInDryGas; + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/absorber/WaterStripperColumn.java b/src/main/java/neqsim/processSimulation/processEquipment/absorber/WaterStripperColumn.java index d0191d12a3..f75e2cf4fe 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/absorber/WaterStripperColumn.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/absorber/WaterStripperColumn.java @@ -5,12 +5,11 @@ import java.text.DecimalFormat; import java.text.FieldPosition; import java.util.ArrayList; - +import java.util.UUID; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; - import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.thermo.system.SystemInterface; @@ -25,524 +24,524 @@ * @version $Id: $Id */ public class WaterStripperColumn extends SimpleAbsorber { - private static final long serialVersionUID = 1000; - - protected ArrayList streams = new ArrayList(0); - protected double pressure = 0; - protected int numberOfInputStreams = 0; - protected StreamInterface mixedStream; - protected StreamInterface gasInStream; - protected StreamInterface solventInStream; - private StreamInterface gasOutStream; - private StreamInterface solventOutStream; - protected String name = "mixer"; - protected StreamInterface outStream; - private double waterDewPointTemperature = 263.15, dewPressure = 70.0, kwater = 1e-4; - int solventStreamNumber = 0; - - /** - *

- * Constructor for WaterStripperColumn. - *

- */ - @Deprecated - public WaterStripperColumn() { - } - - /** - *

- * Constructor for WaterStripperColumn. - *

- * - * @param name a {@link java.lang.String} object - */ - public WaterStripperColumn(String name) { - super(name); - } - - /** {@inheritDoc} */ - @Override - public void addStream(StreamInterface newStream) { - streams.add(newStream); - if (numberOfInputStreams == 0) { - mixedStream = (Stream) streams.get(0).clone(); - mixedStream.getThermoSystem().setNumberOfPhases(2); - mixedStream.getThermoSystem().reInitPhaseType(); - mixedStream.getThermoSystem().init(0); - mixedStream.getThermoSystem().init(3); - } - - numberOfInputStreams++; - } - - /** - *

- * addGasInStream. - *

- * - * @param newStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - public void addGasInStream(StreamInterface newStream) { - gasInStream = (Stream) newStream; - gasOutStream = (Stream) newStream.clone(); - addStream(newStream); - } - - /** - *

- * addSolventInStream. - *

- * - * @param newStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - public void addSolventInStream(StreamInterface newStream) { - solventInStream = (Stream) newStream; - solventOutStream = (Stream) newStream.clone(); - addStream(newStream); - solventStreamNumber = streams.size() - 1; + private static final long serialVersionUID = 1000; + + protected ArrayList streams = new ArrayList(0); + protected double pressure = 0; + protected int numberOfInputStreams = 0; + protected StreamInterface mixedStream; + protected StreamInterface gasInStream; + protected StreamInterface solventInStream; + private StreamInterface gasOutStream; + private StreamInterface solventOutStream; + protected String name = "mixer"; + protected StreamInterface outStream; + private double waterDewPointTemperature = 263.15; + private double dewPressure = 70.0; + + private double kwater = 1e-4; + + int solventStreamNumber = 0; + + /** + *

+ * Constructor for WaterStripperColumn. + *

+ */ + @Deprecated + public WaterStripperColumn() {} + + /** + *

+ * Constructor for WaterStripperColumn. + *

+ * + * @param name a {@link java.lang.String} object + */ + public WaterStripperColumn(String name) { + super(name); + } + + /** {@inheritDoc} */ + @Override + public void addStream(StreamInterface newStream) { + streams.add(newStream); + if (numberOfInputStreams == 0) { + mixedStream = (Stream) streams.get(0).clone(); + mixedStream.getThermoSystem().setNumberOfPhases(2); + mixedStream.getThermoSystem().reInitPhaseType(); + mixedStream.getThermoSystem().init(0); + mixedStream.getThermoSystem().init(3); } - /** - *

- * replaceSolventInStream. - *

- * - * @param newStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - public void replaceSolventInStream(StreamInterface newStream) { - solventInStream = (Stream) newStream; - streams.set(solventStreamNumber, solventInStream); - } - - /** {@inheritDoc} */ - @Override - public void setPressure(double pressure) { - this.pressure = pressure; - } - - /** - *

- * mixStream. - *

- */ - public void mixStream() { - String compName = new String(); - - for (int k = 1; k < streams.size(); k++) { - for (int i = 0; i < streams.get(k).getThermoSystem().getPhases()[0] - .getNumberOfComponents(); i++) { - boolean gotComponent = false; - String componentName = - streams.get(k).getThermoSystem().getPhases()[0].getComponents()[i] - .getName(); - // System.out.println("adding: " + componentName); - - double moles = streams.get(k).getThermoSystem().getPhases()[0].getComponents()[i] - .getNumberOfmoles(); - // System.out.println("moles: " + moles + " " + - // mixedStream.getThermoSystem().getPhases()[0].getNumberOfComponents()); - for (int p = 0; p < mixedStream.getThermoSystem().getPhases()[0] - .getNumberOfComponents(); p++) { - if (mixedStream.getThermoSystem().getPhases()[0].getComponents()[p].getName() - .equals(componentName)) { - gotComponent = true; - - compName = - streams.get(0).getThermoSystem().getPhases()[0].getComponents()[p] - .getComponentName(); - } - } - - if (gotComponent) { - // System.out.println("adding moles starting...."); - mixedStream.getThermoSystem().addComponent(compName, moles); - // mixedStream.getThermoSystem().init_x_y(); - // System.out.println("adding moles finished"); - } else { - // System.out.println("ikke gaa hit"); - mixedStream.getThermoSystem().addComponent(compName, moles); - } - } - } - mixedStream.getThermoSystem().init_x_y(); - mixedStream.getThermoSystem().initBeta(); - mixedStream.getThermoSystem().init(2); - } - - /** - *

- * guessTemperature. - *

- * - * @return a double - */ - public double guessTemperature() { - double gtemp = 0; - for (int k = 0; k < streams.size(); k++) { - gtemp += streams.get(k).getThermoSystem().getTemperature() - * streams.get(k).getThermoSystem().getNumberOfMoles() - / mixedStream.getThermoSystem().getNumberOfMoles(); + numberOfInputStreams++; + } + + /** + *

+ * addGasInStream. + *

+ * + * @param newStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public void addGasInStream(StreamInterface newStream) { + gasInStream = (Stream) newStream; + gasOutStream = (Stream) newStream.clone(); + addStream(newStream); + } + + /** + *

+ * addSolventInStream. + *

+ * + * @param newStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public void addSolventInStream(StreamInterface newStream) { + solventInStream = (Stream) newStream; + solventOutStream = (Stream) newStream.clone(); + addStream(newStream); + solventStreamNumber = streams.size() - 1; + } + + /** + *

+ * replaceSolventInStream. + *

+ * + * @param newStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public void replaceSolventInStream(StreamInterface newStream) { + solventInStream = (Stream) newStream; + streams.set(solventStreamNumber, solventInStream); + } + + /** {@inheritDoc} */ + @Override + public void setPressure(double pressure) { + this.pressure = pressure; + } + + /** + *

+ * mixStream. + *

+ */ + public void mixStream() { + String compName = new String(); + + for (int k = 1; k < streams.size(); k++) { + for (int i = 0; i < streams.get(k).getThermoSystem().getPhases()[0] + .getNumberOfComponents(); i++) { + boolean gotComponent = false; + String componentName = + streams.get(k).getThermoSystem().getPhases()[0].getComponents()[i].getName(); + // System.out.println("adding: " + componentName); + + double moles = + streams.get(k).getThermoSystem().getPhases()[0].getComponents()[i].getNumberOfmoles(); + // System.out.println("moles: " + moles + " " + + // mixedStream.getThermoSystem().getPhases()[0].getNumberOfComponents()); + for (int p = 0; p < mixedStream.getThermoSystem().getPhases()[0] + .getNumberOfComponents(); p++) { + if (mixedStream.getThermoSystem().getPhases()[0].getComponents()[p].getName() + .equals(componentName)) { + gotComponent = true; + + compName = streams.get(0).getThermoSystem().getPhases()[0].getComponents()[p] + .getComponentName(); + } } - return gtemp; - } - /** - *

- * calcMixStreamEnthalpy. - *

- * - * @return a double - */ - public double calcMixStreamEnthalpy() { - double enthalpy = 0; - for (int k = 0; k < streams.size(); k++) { - streams.get(k).getThermoSystem().init(3); - enthalpy += streams.get(k).getThermoSystem().getEnthalpy(); - // System.out.println("total enthalpy k : " + ( - // ((StreamInterface) streams.get(k)).getThermoSystem()).getEnthalpy()); + if (gotComponent) { + // System.out.println("adding moles starting...."); + mixedStream.getThermoSystem().addComponent(compName, moles); + // mixedStream.getThermoSystem().init_x_y(); + // System.out.println("adding moles finished"); + } else { + // System.out.println("ikke gaa hit"); + mixedStream.getThermoSystem().addComponent(compName, moles); } - // System.out.println("total enthalpy of streams: " + enthalpy); - return enthalpy; - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getOutStream() { - return mixedStream; - } - - /** - *

- * getInStream. - *

- * - * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - public StreamInterface getInStream() { - return gasInStream; + } } - - /** {@inheritDoc} */ - @Override - public StreamInterface getGasOutStream() { - return gasOutStream; - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getLiquidOutStream() { - return solventOutStream; - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getSolventInStream() { - return solventInStream; - } - - /** - *

- * calcEa. - *

- * - * @return a double - */ - public double calcEa() { - double A = mixedStream.getThermoSystem().getPhase(1).getNumberOfMolesInPhase() - / mixedStream.getThermoSystem().getPhase(0).getNumberOfMolesInPhase() / kwater; - absorptionEfficiency = (Math.pow(A, getNumberOfTheoreticalStages() + 1) - A) - / (Math.pow(A, getNumberOfTheoreticalStages() + 1) - 1.0); - return absorptionEfficiency; - } - - /** - *

- * calcX0. - *

- * - * @return a double - */ - public double calcX0() { - return 0.0; + mixedStream.getThermoSystem().init_x_y(); + mixedStream.getThermoSystem().initBeta(); + mixedStream.getThermoSystem().init(2); + } + + /** + *

+ * guessTemperature. + *

+ * + * @return a double + */ + public double guessTemperature() { + double gtemp = 0; + for (int k = 0; k < streams.size(); k++) { + gtemp += streams.get(k).getThermoSystem().getTemperature() + * streams.get(k).getThermoSystem().getNumberOfMoles() + / mixedStream.getThermoSystem().getNumberOfMoles(); } - - /** - *

- * calcNumberOfTheoreticalStages. - *

- * - * @return a double - */ - public double calcNumberOfTheoreticalStages() { - setNumberOfTheoreticalStages(getStageEfficiency() * getNumberOfStages()); - return getNumberOfTheoreticalStages(); - } - - /** - *

- * calcNTU. - *

- * - * @param y0 a double - * @param y1 a double - * @param yb a double - * @param ymix a double - * @return a double - */ - public double calcNTU(double y0, double y1, double yb, double ymix) { - double NTU = Math.log((yb - ymix) / (y1 - y0)); - return NTU; + return gtemp; + } + + /** + *

+ * calcMixStreamEnthalpy. + *

+ * + * @return a double + */ + public double calcMixStreamEnthalpy() { + double enthalpy = 0; + for (int k = 0; k < streams.size(); k++) { + streams.get(k).getThermoSystem().init(3); + enthalpy += streams.get(k).getThermoSystem().getEnthalpy(); + // System.out.println("total enthalpy k : " + ( + // ((StreamInterface) streams.get(k)).getThermoSystem()).getEnthalpy()); } - - /** {@inheritDoc} */ - @Override - public void run() { - try { - double x2 = getSolventInStream().getFluid().getPhase(0).getComponent("water").getz(); - double x0 = 0.0; - double absorptionEffiency = 0.0; - mixedStream.setThermoSystem((streams.get(0).getThermoSystem().clone())); - mixedStream.getThermoSystem().setNumberOfPhases(2); - mixedStream.getThermoSystem().reInitPhaseType(); - mixedStream.getThermoSystem().init(0); - mixStream(); - double enthalpy = calcMixStreamEnthalpy(); - //// System.out.println("temp guess " + guessTemperature()); - mixedStream.getThermoSystem().setTemperature(guessTemperature()); - ThermodynamicOperations testOps = - new ThermodynamicOperations(mixedStream.getThermoSystem()); - testOps.TPflash(); - testOps.PHflash(enthalpy, 0); - - if (mixedStream.getThermoSystem().getNumberOfPhases() == 1) { - if (mixedStream.getThermoSystem().getPhase(0).getPhaseTypeName() - .equals("aqueous")) { - SystemInterface tempSystem = mixedStream.getThermoSystem().clone(); - gasOutStream.setEmptyThermoSystem(tempSystem); - gasOutStream.run(); - solventOutStream.setThermoSystem(tempSystem); - solventOutStream.run(); - } - if (mixedStream.getThermoSystem().getPhase(0).getPhaseTypeName().equals("gas")) { - SystemInterface tempSystem = mixedStream.getThermoSystem().clone(); - solventOutStream.setEmptyThermoSystem(tempSystem); - solventOutStream.run(); - gasOutStream.setThermoSystem(tempSystem); - gasOutStream.run(); - } - return; - } - - kwater = mixedStream.getThermoSystem().getPhase(0).getComponent("water").getx() - / mixedStream.getThermoSystem().getPhase(1).getComponent("water").getx(); - - double Ntheoretical = calcNumberOfTheoreticalStages(); - // System.out.println("number of theoretical stages " + - // getNumberOfTheoreticalStages()); - absorptionEffiency = calcEa(); - - x0 = calcX0(); - double revA = 1.0 / absorptionEffiency; - - double x1 = x2 - (Math.pow(revA, Ntheoretical + 1) - revA) - / (Math.pow(revA, Ntheoretical + 1) - 1.0) * (x2 - x0); - - double xMean = mixedStream.getThermoSystem().getPhase(1).getComponent("water").getx(); - double molesWaterToMove = (xMean - x1) - * mixedStream.getThermoSystem().getPhase(1).getNumberOfMolesInPhase(); - // System.out.println("mole water to move " + molesWaterToMove); - - StreamInterface stream = mixedStream.clone(); - stream.setName("test"); - stream.getThermoSystem().addComponent("water", molesWaterToMove, 0); - stream.getThermoSystem().addComponent("water", -molesWaterToMove, 1); - stream.getThermoSystem().initBeta(); - stream.getThermoSystem().init_x_y(); - stream.getThermoSystem().init(2); - mixedStream = stream; - // stream.getThermoSystem().display(); - - SystemInterface tempSystem = mixedStream.getThermoSystem().clone(); - SystemInterface gasTemp = tempSystem.phaseToSystem(tempSystem.getPhases()[0]); - gasTemp.init(2); - gasOutStream.setThermoSystem(gasTemp); - - tempSystem = mixedStream.getThermoSystem().clone(); - SystemInterface liqTemp = tempSystem.phaseToSystem(tempSystem.getPhases()[1]); - liqTemp.init(2); - solventOutStream.setThermoSystem(liqTemp); - solventOutStream.run(); - // System.out.println("Gas from water stripper " + - // gasOutStream.getFlowRate("kg/hr") + " kg/hr"); - - // System.out.println("TEG from water stripper " + - // solventOutStream.getFlowRate("kg/hr") + " kg/hr"); - } catch (Exception e) { - e.printStackTrace(); + // System.out.println("total enthalpy of streams: " + enthalpy); + return enthalpy; + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getOutStream() { + return mixedStream; + } + + /** + *

+ * getInStream. + *

+ * + * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + */ + public StreamInterface getInStream() { + return gasInStream; + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getGasOutStream() { + return gasOutStream; + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getLiquidOutStream() { + return solventOutStream; + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getSolventInStream() { + return solventInStream; + } + + /** + *

+ * calcEa. + *

+ * + * @return a double + */ + public double calcEa() { + double A = mixedStream.getThermoSystem().getPhase(1).getNumberOfMolesInPhase() + / mixedStream.getThermoSystem().getPhase(0).getNumberOfMolesInPhase() / kwater; + absorptionEfficiency = (Math.pow(A, getNumberOfTheoreticalStages() + 1) - A) + / (Math.pow(A, getNumberOfTheoreticalStages() + 1) - 1.0); + return absorptionEfficiency; + } + + /** + *

+ * calcX0. + *

+ * + * @return a double + */ + public double calcX0() { + return 0.0; + } + + /** + *

+ * calcNumberOfTheoreticalStages. + *

+ * + * @return a double + */ + public double calcNumberOfTheoreticalStages() { + setNumberOfTheoreticalStages(getStageEfficiency() * getNumberOfStages()); + return getNumberOfTheoreticalStages(); + } + + /** + *

+ * calcNTU. + *

+ * + * @param y0 a double + * @param y1 a double + * @param yb a double + * @param ymix a double + * @return a double + */ + public double calcNTU(double y0, double y1, double yb, double ymix) { + return Math.log((yb - ymix) / (y1 - y0)); + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + try { + double x2 = getSolventInStream().getFluid().getPhase(0).getComponent("water").getz(); + double x0 = 0.0; + double absorptionEffiency = 0.0; + mixedStream.setThermoSystem((streams.get(0).getThermoSystem().clone())); + mixedStream.getThermoSystem().setNumberOfPhases(2); + mixedStream.getThermoSystem().reInitPhaseType(); + mixedStream.getThermoSystem().init(0); + mixStream(); + double enthalpy = calcMixStreamEnthalpy(); + //// System.out.println("temp guess " + guessTemperature()); + mixedStream.getThermoSystem().setTemperature(guessTemperature()); + ThermodynamicOperations testOps = new ThermodynamicOperations(mixedStream.getThermoSystem()); + testOps.TPflash(); + testOps.PHflash(enthalpy, 0); + + if (mixedStream.getThermoSystem().getNumberOfPhases() == 1) { + if (mixedStream.getThermoSystem().getPhase(0).getPhaseTypeName().equals("aqueous")) { + SystemInterface tempSystem = mixedStream.getThermoSystem().clone(); + gasOutStream.setEmptyThermoSystem(tempSystem); + gasOutStream.run(id); + solventOutStream.setThermoSystem(tempSystem); + solventOutStream.run(id); } - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - SystemInterface thermoSystem = mixedStream.getThermoSystem(); - DecimalFormat nf = new DecimalFormat(); - nf.setMaximumFractionDigits(5); - nf.applyPattern("#.#####E0"); - - JDialog dialog = new JDialog(new JFrame(), "Results from TPflash"); - Container dialogContentPane = dialog.getContentPane(); - dialogContentPane.setLayout(new FlowLayout()); - - thermoSystem.initPhysicalProperties(); - String[][] table = new String[50][5]; - String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"}; - table[0][0] = ""; - table[0][1] = ""; - table[0][2] = ""; - table[0][3] = ""; - StringBuffer buf = new StringBuffer(); - FieldPosition test = new FieldPosition(0); - - for (int i = 0; i < thermoSystem.getNumberOfPhases(); i++) { - for (int j = 0; j < thermoSystem.getPhases()[0].getNumberOfComponents(); j++) { - table[j + 1][0] = thermoSystem.getPhases()[0].getComponents()[j].getName(); - buf = new StringBuffer(); - table[j + 1][i + 1] = - nf.format(thermoSystem.getPhases()[i].getComponents()[j].getx(), buf, test) - .toString(); - table[j + 1][4] = "[-]"; - } - buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 2][0] = "Density"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 2][i + 1] = - nf.format(thermoSystem.getPhases()[i].getPhysicalProperties().getDensity(), buf, - test).toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 2][4] = "[kg/m^3]"; - - // Double.longValue(thermoSystem.getPhases()[i].getBeta()); - - buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 3][0] = "PhaseFraction"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 3][i + 1] = - nf.format(thermoSystem.getPhases()[i].getBeta(), buf, test).toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 3][4] = "[-]"; - - buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 4][0] = "MolarMass"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 4][i + 1] = - nf.format(thermoSystem.getPhases()[i].getMolarMass() * 1000, buf, test) - .toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 4][4] = "[kg/kmol]"; - - buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 5][0] = "Cp"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 5][i + 1] = nf.format( - (thermoSystem.getPhases()[i].getCp() - / (thermoSystem.getPhases()[i].getNumberOfMolesInPhase() - * thermoSystem.getPhases()[i].getMolarMass() * 1000)), - buf, test).toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 5][4] = "[kJ/kg*K]"; - - buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 7][0] = "Viscosity"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 7][i + 1] = - nf.format((thermoSystem.getPhases()[i].getPhysicalProperties().getViscosity()), - buf, test).toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 7][4] = "[kg/m*sec]"; - - buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 8][0] = "Conductivity"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 8][i + 1] = - nf.format(thermoSystem.getPhases()[i].getPhysicalProperties().getConductivity(), - buf, test).toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 8][4] = "[W/m*K]"; - - buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 10][0] = "Pressure"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 10][i + 1] = - Double.toString(thermoSystem.getPhases()[i].getPressure()); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 10][4] = "[bar]"; - - buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 11][0] = "Temperature"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 11][i + 1] = - Double.toString(thermoSystem.getPhases()[i].getTemperature()); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 11][4] = "[K]"; - Double.toString(thermoSystem.getPhases()[i].getTemperature()); - - buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 13][0] = "Stream"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 13][i + 1] = name; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 13][4] = "-"; + if (mixedStream.getThermoSystem().getPhase(0).getPhaseTypeName().equals("gas")) { + SystemInterface tempSystem = mixedStream.getThermoSystem().clone(); + solventOutStream.setEmptyThermoSystem(tempSystem); + solventOutStream.run(id); + gasOutStream.setThermoSystem(tempSystem); + gasOutStream.run(id); } - - JTable Jtab = new JTable(table, names); - JScrollPane scrollpane = new JScrollPane(Jtab); - dialogContentPane.add(scrollpane); - dialog.pack(); - dialog.setVisible(true); - } - - /** - *

- * Getter for the field waterDewPointTemperature. - *

- * - * @return a double - */ - public double getWaterDewPointTemperature() { - return waterDewPointTemperature; + } else { + kwater = mixedStream.getThermoSystem().getPhase(0).getComponent("water").getx() + / mixedStream.getThermoSystem().getPhase(1).getComponent("water").getx(); + + double Ntheoretical = calcNumberOfTheoreticalStages(); + // System.out.println("number of theoretical stages " + + // getNumberOfTheoreticalStages()); + absorptionEffiency = calcEa(); + + x0 = calcX0(); + double revA = 1.0 / absorptionEffiency; + + double x1 = x2 - (Math.pow(revA, Ntheoretical + 1) - revA) + / (Math.pow(revA, Ntheoretical + 1) - 1.0) * (x2 - x0); + + double xMean = mixedStream.getThermoSystem().getPhase(1).getComponent("water").getx(); + double molesWaterToMove = + (xMean - x1) * mixedStream.getThermoSystem().getPhase(1).getNumberOfMolesInPhase(); + // System.out.println("mole water to move " + molesWaterToMove); + + StreamInterface stream = mixedStream.clone(); + stream.setName("test"); + stream.getThermoSystem().addComponent("water", molesWaterToMove, 0); + stream.getThermoSystem().addComponent("water", -molesWaterToMove, 1); + stream.getThermoSystem().initBeta(); + stream.getThermoSystem().init_x_y(); + stream.getThermoSystem().init(2); + mixedStream = stream; + // stream.getThermoSystem().display(); + + SystemInterface tempSystem = mixedStream.getThermoSystem().clone(); + SystemInterface gasTemp = tempSystem.phaseToSystem(tempSystem.getPhases()[0]); + gasTemp.init(2); + gasOutStream.setThermoSystem(gasTemp); + gasOutStream.setCalculationIdentifier(id); + + tempSystem = mixedStream.getThermoSystem().clone(); + SystemInterface liqTemp = tempSystem.phaseToSystem(tempSystem.getPhases()[1]); + liqTemp.init(2); + solventOutStream.setThermoSystem(liqTemp); + solventOutStream.run(id); + + mixedStream.setCalculationIdentifier(id); + + // System.out.println("Gas from water stripper " + + // gasOutStream.getFlowRate("kg/hr") + " kg/hr"); + + // System.out.println("TEG from water stripper " + + // solventOutStream.getFlowRate("kg/hr") + " kg/hr"); + } + setCalculationIdentifier(id); + } catch (Exception e) { + e.printStackTrace(); } - - /** - *

- * Setter for the field waterDewPointTemperature. - *

- * - * @param waterDewPointTemperature a double - * @param dewPressure a double - */ - public void setWaterDewPointTemperature(double waterDewPointTemperature, double dewPressure) { - this.waterDewPointTemperature = waterDewPointTemperature; - this.dewPressure = dewPressure; - } - - /** - *

- * Setter for the field gasOutStream. - *

- * - * @param gasOutStream a - * {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ - public void setGasOutStream(StreamInterface gasOutStream) { - this.gasOutStream = gasOutStream; + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + SystemInterface thermoSystem = mixedStream.getThermoSystem(); + DecimalFormat nf = new DecimalFormat(); + nf.setMaximumFractionDigits(5); + nf.applyPattern("#.#####E0"); + + JDialog dialog = new JDialog(new JFrame(), "Results from TPflash"); + Container dialogContentPane = dialog.getContentPane(); + dialogContentPane.setLayout(new FlowLayout()); + + thermoSystem.initPhysicalProperties(); + String[][] table = new String[50][5]; + String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"}; + table[0][0] = ""; + table[0][1] = ""; + table[0][2] = ""; + table[0][3] = ""; + StringBuffer buf = new StringBuffer(); + FieldPosition test = new FieldPosition(0); + + for (int i = 0; i < thermoSystem.getNumberOfPhases(); i++) { + for (int j = 0; j < thermoSystem.getPhases()[0].getNumberOfComponents(); j++) { + table[j + 1][0] = thermoSystem.getPhases()[0].getComponents()[j].getName(); + buf = new StringBuffer(); + table[j + 1][i + 1] = + nf.format(thermoSystem.getPhases()[i].getComponents()[j].getx(), buf, test).toString(); + table[j + 1][4] = "[-]"; + } + buf = new StringBuffer(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 2][0] = "Density"; + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 2][i + 1] = + nf.format(thermoSystem.getPhases()[i].getPhysicalProperties().getDensity(), buf, test) + .toString(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 2][4] = "[kg/m^3]"; + + // Double.longValue(thermoSystem.getPhases()[i].getBeta()); + + buf = new StringBuffer(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 3][0] = "PhaseFraction"; + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 3][i + 1] = + nf.format(thermoSystem.getPhases()[i].getBeta(), buf, test).toString(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 3][4] = "[-]"; + + buf = new StringBuffer(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 4][0] = "MolarMass"; + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 4][i + 1] = + nf.format(thermoSystem.getPhases()[i].getMolarMass() * 1000, buf, test).toString(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 4][4] = "[kg/kmol]"; + + buf = new StringBuffer(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 5][0] = "Cp"; + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 5][i + 1] = + nf.format((thermoSystem.getPhases()[i].getCp() + / (thermoSystem.getPhases()[i].getNumberOfMolesInPhase() + * thermoSystem.getPhases()[i].getMolarMass() * 1000)), + buf, test).toString(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 5][4] = "[kJ/kg*K]"; + + buf = new StringBuffer(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 7][0] = "Viscosity"; + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 7][i + 1] = + nf.format((thermoSystem.getPhases()[i].getPhysicalProperties().getViscosity()), buf, test) + .toString(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 7][4] = "[kg/m*sec]"; + + buf = new StringBuffer(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 8][0] = "Conductivity"; + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 8][i + 1] = nf + .format(thermoSystem.getPhases()[i].getPhysicalProperties().getConductivity(), buf, test) + .toString(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 8][4] = "[W/m*K]"; + + buf = new StringBuffer(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 10][0] = "Pressure"; + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 10][i + 1] = + Double.toString(thermoSystem.getPhases()[i].getPressure()); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 10][4] = "[bar]"; + + buf = new StringBuffer(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 11][0] = "Temperature"; + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 11][i + 1] = + Double.toString(thermoSystem.getPhases()[i].getTemperature()); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 11][4] = "[K]"; + Double.toString(thermoSystem.getPhases()[i].getTemperature()); + + buf = new StringBuffer(); + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 13][0] = "Stream"; + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 13][i + 1] = name; + table[thermoSystem.getPhases()[0].getNumberOfComponents() + 13][4] = "-"; } - /** - *

- * Getter for the field solventOutStream. - *

- * - * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - public StreamInterface getSolventOutStream() { - return solventOutStream; - } - - /** - *

- * Setter for the field solventOutStream. - *

- * - * @param solventOutStream a - * {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ - public void setSolventOutStream(StreamInterface solventOutStream) { - this.solventOutStream = solventOutStream; - } + JTable Jtab = new JTable(table, names); + JScrollPane scrollpane = new JScrollPane(Jtab); + dialogContentPane.add(scrollpane); + dialog.pack(); + dialog.setVisible(true); + } + + /** + *

+ * Getter for the field waterDewPointTemperature. + *

+ * + * @return a double + */ + public double getWaterDewPointTemperature() { + return waterDewPointTemperature; + } + + /** + *

+ * Setter for the field waterDewPointTemperature. + *

+ * + * @param waterDewPointTemperature a double + * @param dewPressure a double + */ + public void setWaterDewPointTemperature(double waterDewPointTemperature, double dewPressure) { + this.waterDewPointTemperature = waterDewPointTemperature; + this.dewPressure = dewPressure; + } + + /** + *

+ * Setter for the field gasOutStream. + *

+ * + * @param gasOutStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public void setGasOutStream(StreamInterface gasOutStream) { + this.gasOutStream = gasOutStream; + } + + /** + *

+ * Getter for the field solventOutStream. + *

+ * + * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + */ + public StreamInterface getSolventOutStream() { + return solventOutStream; + } + + /** + *

+ * Setter for the field solventOutStream. + *

+ * + * @param solventOutStream a + * {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + public void setSolventOutStream(StreamInterface solventOutStream) { + this.solventOutStream = solventOutStream; + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/adsorber/SimpleAdsorber.java b/src/main/java/neqsim/processSimulation/processEquipment/adsorber/SimpleAdsorber.java index ab76815249..dec850b7c6 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/adsorber/SimpleAdsorber.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/adsorber/SimpleAdsorber.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.adsorber; +import java.util.UUID; import neqsim.processSimulation.mechanicalDesign.adsorber.AdsorberMechanicalDesign; import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; import neqsim.processSimulation.processEquipment.stream.Stream; @@ -15,340 +16,341 @@ * @version $Id: $Id */ public class SimpleAdsorber extends ProcessEquipmentBaseClass { - private static final long serialVersionUID = 1000; - - boolean setTemperature = false; - String name = new String(); - StreamInterface[] outStream = new Stream[2]; - StreamInterface[] inStream = new Stream[2]; - SystemInterface system; - protected double temperatureOut = 0, dT = 0.0; - private int numberOfStages = 5; - private double numberOfTheoreticalStages = 3.0; - double absorptionEfficiency = 0.5; - private double HTU = 0.85; - private double NTU = 2.0; - private double stageEfficiency = 0.25; - - /** - *

- * Constructor for SimpleAdsorber. - *

- */ - @Deprecated - public SimpleAdsorber() { - this("SimpleAdsorber"); - } - - /** - *

- * Constructor for SimpleAdsorber. - *

- * - * @param inStream1 a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public SimpleAdsorber(StreamInterface inStream1) { - this("SimpleAdsorber"); - this.inStream[0] = inStream1; - this.inStream[1] = inStream1; - outStream[0] = (Stream) inStream1.clone(); - outStream[1] = (Stream) inStream1.clone(); - - SystemInterface systemOut1 = inStream1.getThermoSystem().clone(); - outStream[0].setThermoSystem(systemOut1); - - double molCO2 = - inStream1.getThermoSystem().getPhase(0).getComponent("CO2").getNumberOfmoles(); - System.out.println("mol CO2 " + molCO2); - SystemInterface systemOut0 = inStream1.getThermoSystem().clone(); - systemOut0.init(0); - systemOut0.addComponent("MDEA", molCO2 * absorptionEfficiency); - systemOut0.addComponent("water", molCO2 * absorptionEfficiency * 10.0); - systemOut0.chemicalReactionInit(); - systemOut0.createDatabase(true); - systemOut0.setMixingRule(4); - outStream[1].setThermoSystem(systemOut0); - outStream[1].run(); - } - - /** {@inheritDoc} */ - public SimpleAdsorber(String name) { - super(name); - } - - /** - *

- * Constructor for SimpleAdsorber. - *

- * - * @param name name of the unit operation - * @param inStream1 a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - public SimpleAdsorber(String name, StreamInterface inStream1) { - this(name); - this.inStream[0] = inStream1; - this.inStream[1] = inStream1; - outStream[0] = (Stream) inStream1.clone(); - outStream[1] = (Stream) inStream1.clone(); - setName(name); - - SystemInterface systemOut1 = inStream1.getThermoSystem().clone(); - outStream[0].setThermoSystem(systemOut1); - - double molCO2 = - inStream1.getThermoSystem().getPhase(0).getComponent("CO2").getNumberOfmoles(); - System.out.println("mol CO2 " + molCO2); - SystemInterface systemOut0 = inStream1.getThermoSystem().clone(); - systemOut0.init(0); - systemOut0.addComponent("MDEA", molCO2 * absorptionEfficiency); - systemOut0.addComponent("water", molCO2 * absorptionEfficiency * 10.0); - systemOut0.chemicalReactionInit(); - systemOut0.createDatabase(true); - systemOut0.setMixingRule(4); - outStream[1].setThermoSystem(systemOut0); - outStream[1].run(); - } - - public AdsorberMechanicalDesign getMechanicalDesign() { - return new AdsorberMechanicalDesign(this); - } - - /** {@inheritDoc} */ - @Override - public void setName(String name) { - super.setName(name); - outStream[0].setName(name + "_Sout1"); - outStream[1].setName(name + "_Sout2"); - } - - /** - *

- * Setter for the field dT. - *

- * - * @param dT a double - */ - public void setdT(double dT) { - this.dT = dT; - } - - /** - *

- * Getter for the field outStream. - *

- * - * @param i a int - * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ - public StreamInterface getOutStream(int i) { - return outStream[i]; - } - - /** - *

- * setOutTemperature. - *

- * - * @param temperature a double - */ - public void setOutTemperature(double temperature) { - this.temperatureOut = temperature; - } - - /** - *

- * getOutTemperature. - *

- * - * @param i a int - */ - public void getOutTemperature(int i) { - outStream[i].getThermoSystem().getTemperature(); - } - - /** - *

- * getInTemperature. - *

- * - * @param i a int - */ - public void getInTemperature(int i) { - inStream[i].getThermoSystem().getTemperature(); - } - - /** {@inheritDoc} */ - @Override - public void run() { - SystemInterface systemOut1 = inStream[1].getThermoSystem().clone(); - outStream[0].setThermoSystem(systemOut1); - outStream[0].run(); - - outStream[1].run(); - - double error = 1e5; - error = absorptionEfficiency - (outStream[1].getThermoSystem().getPhase(1) - .getComponent("CO2").getNumberOfMolesInPhase() - + outStream[1].getThermoSystem().getPhase(1).getComponent("HCO3-") - .getNumberOfMolesInPhase()) - / (outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA") - .getNumberOfMolesInPhase() - + outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA+") - .getNumberOfMolesInPhase()); - int iter = 0; - do { - iter++; - double factor = (outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA") - .getNumberOfMolesInPhase() - + outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA+") - .getNumberOfMolesInPhase()); - // outStream[1].getThermoSystem().addComponent("CO2",(20.0-outStream[1].getThermoSystem().getPhase(0).getComponent("CO2").getNumberOfMolesInPhase()),0); - outStream[1].getThermoSystem().addComponent("MDEA", -error * factor); - outStream[1].getThermoSystem().addComponent("water", -error * 10.0 * factor); - outStream[1].run(); - error = absorptionEfficiency - ((outStream[1].getThermoSystem().getPhase(1) - .getComponent("CO2").getNumberOfMolesInPhase() - + outStream[1].getThermoSystem().getPhase(1).getComponent("HCO3-") - .getNumberOfMolesInPhase()) - / (outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA") - .getNumberOfMolesInPhase() - + outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA+") - .getNumberOfMolesInPhase())); - - System.out.println("error " + error); - } while (Math.abs(error) > 1e-4 && iter < 30 - && outStream[1].getThermoSystem().getPhase(1).getBeta() > 0 - && outStream[0].getThermoSystem().getPhase(1).getBeta() > 0); - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - outStream[0].displayResult(); - outStream[1].displayResult(); - } - - /** - *

- * setAproachToEquilibrium. - *

- * - * @param eff a double - */ - public void setAproachToEquilibrium(double eff) { - this.absorptionEfficiency = eff; - } - - /** - *

- * Getter for the field numberOfTheoreticalStages. - *

- * - * @return a double - */ - public double getNumberOfTheoreticalStages() { - return numberOfTheoreticalStages; - } - - /** - *

- * Setter for the field numberOfTheoreticalStages. - *

- * - * @param numberOfTheoreticalStages a double - */ - public void setNumberOfTheoreticalStages(double numberOfTheoreticalStages) { - this.numberOfTheoreticalStages = numberOfTheoreticalStages; - } - - /** - *

- * Getter for the field numberOfStages. - *

- * - * @return a int - */ - public int getNumberOfStages() { - return numberOfStages; - } - - /** - *

- * Setter for the field numberOfStages. - *

- * - * @param numberOfStages a int - */ - public void setNumberOfStages(int numberOfStages) { - this.numberOfStages = numberOfStages; - } - - /** - *

- * Getter for the field stageEfficiency. - *

- * - * @return a double - */ - public double getStageEfficiency() { - return stageEfficiency; - } - - /** - *

- * Setter for the field stageEfficiency. - *

- * - * @param stageEfficiency a double - */ - public void setStageEfficiency(double stageEfficiency) { - this.stageEfficiency = stageEfficiency; - } - - /** - *

- * getHTU. - *

- * - * @return a double - */ - public double getHTU() { - return HTU; - } - - /** - *

- * setHTU. - *

- * - * @param HTU a double - */ - public void setHTU(double HTU) { - this.HTU = HTU; - } - - /** - *

- * getNTU. - *

- * - * @return a double - */ - public double getNTU() { - return NTU; - } - - /** - *

- * setNTU. - *

- * - * @param NTU a double - */ - public void setNTU(double NTU) { - this.NTU = NTU; - } + private static final long serialVersionUID = 1000; + + boolean setTemperature = false; + String name = new String(); + StreamInterface[] outStream = new Stream[2]; + StreamInterface[] inStream = new Stream[2]; + SystemInterface system; + protected double temperatureOut = 0; + + protected double dT = 0.0; + + private int numberOfStages = 5; + private double numberOfTheoreticalStages = 3.0; + double absorptionEfficiency = 0.5; + private double HTU = 0.85; + private double NTU = 2.0; + private double stageEfficiency = 0.25; + + /** + *

+ * Constructor for SimpleAdsorber. + *

+ */ + @Deprecated + public SimpleAdsorber() { + this("SimpleAdsorber"); + } + + /** + *

+ * Constructor for SimpleAdsorber. + *

+ * + * @param inStream1 a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + @Deprecated + public SimpleAdsorber(StreamInterface inStream1) { + this("SimpleAdsorber"); + this.inStream[0] = inStream1; + this.inStream[1] = inStream1; + outStream[0] = (Stream) inStream1.clone(); + outStream[1] = (Stream) inStream1.clone(); + + SystemInterface systemOut1 = inStream1.getThermoSystem().clone(); + outStream[0].setThermoSystem(systemOut1); + + double molCO2 = inStream1.getThermoSystem().getPhase(0).getComponent("CO2").getNumberOfmoles(); + System.out.println("mol CO2 " + molCO2); + SystemInterface systemOut0 = inStream1.getThermoSystem().clone(); + systemOut0.init(0); + systemOut0.addComponent("MDEA", molCO2 * absorptionEfficiency); + systemOut0.addComponent("water", molCO2 * absorptionEfficiency * 10.0); + systemOut0.chemicalReactionInit(); + systemOut0.createDatabase(true); + systemOut0.setMixingRule(4); + outStream[1].setThermoSystem(systemOut0); + outStream[1].run(); + } + + /** {@inheritDoc} */ + public SimpleAdsorber(String name) { + super(name); + } + + /** + *

+ * Constructor for SimpleAdsorber. + *

+ * + * @param name name of the unit operation + * @param inStream1 a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public SimpleAdsorber(String name, StreamInterface inStream1) { + this(name); + this.inStream[0] = inStream1; + this.inStream[1] = inStream1; + outStream[0] = (Stream) inStream1.clone(); + outStream[1] = (Stream) inStream1.clone(); + setName(name); + + SystemInterface systemOut1 = inStream1.getThermoSystem().clone(); + outStream[0].setThermoSystem(systemOut1); + + double molCO2 = inStream1.getThermoSystem().getPhase(0).getComponent("CO2").getNumberOfmoles(); + System.out.println("mol CO2 " + molCO2); + SystemInterface systemOut0 = inStream1.getThermoSystem().clone(); + systemOut0.init(0); + systemOut0.addComponent("MDEA", molCO2 * absorptionEfficiency); + systemOut0.addComponent("water", molCO2 * absorptionEfficiency * 10.0); + systemOut0.chemicalReactionInit(); + systemOut0.createDatabase(true); + systemOut0.setMixingRule(4); + outStream[1].setThermoSystem(systemOut0); + outStream[1].run(); + } + + public AdsorberMechanicalDesign getMechanicalDesign() { + return new AdsorberMechanicalDesign(this); + } + + /** {@inheritDoc} */ + @Override + public void setName(String name) { + super.setName(name); + outStream[0].setName(name + "_Sout1"); + outStream[1].setName(name + "_Sout2"); + } + + /** + *

+ * Setter for the field dT. + *

+ * + * @param dT a double + */ + public void setdT(double dT) { + this.dT = dT; + } + + /** + *

+ * Getter for the field outStream. + *

+ * + * @param i a int + * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + public StreamInterface getOutStream(int i) { + return outStream[i]; + } + + /** + *

+ * setOutTemperature. + *

+ * + * @param temperature a double + */ + public void setOutTemperature(double temperature) { + this.temperatureOut = temperature; + } + + /** + *

+ * getOutTemperature. + *

+ * + * @param i a int + */ + public void getOutTemperature(int i) { + outStream[i].getThermoSystem().getTemperature(); + } + + /** + *

+ * getInTemperature. + *

+ * + * @param i a int + */ + public void getInTemperature(int i) { + inStream[i].getThermoSystem().getTemperature(); + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + SystemInterface systemOut1 = inStream[1].getThermoSystem().clone(); + outStream[0].setThermoSystem(systemOut1); + outStream[0].run(id); + outStream[1].run(); + + double error = 1e5; + error = absorptionEfficiency - (outStream[1].getThermoSystem().getPhase(1).getComponent("CO2") + .getNumberOfMolesInPhase() + + outStream[1].getThermoSystem().getPhase(1).getComponent("HCO3-") + .getNumberOfMolesInPhase()) + / (outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA").getNumberOfMolesInPhase() + + outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA+") + .getNumberOfMolesInPhase()); + int iter = 0; + do { + iter++; + double factor = + (outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA").getNumberOfMolesInPhase() + + outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA+") + .getNumberOfMolesInPhase()); + // outStream[1].getThermoSystem().addComponent("CO2",(20.0-outStream[1].getThermoSystem().getPhase(0).getComponent("CO2").getNumberOfMolesInPhase()),0); + outStream[1].getThermoSystem().addComponent("MDEA", -error * factor); + outStream[1].getThermoSystem().addComponent("water", -error * 10.0 * factor); + outStream[1].run(); + error = absorptionEfficiency - ((outStream[1].getThermoSystem().getPhase(1) + .getComponent("CO2").getNumberOfMolesInPhase() + + outStream[1].getThermoSystem().getPhase(1).getComponent("HCO3-") + .getNumberOfMolesInPhase()) + / (outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA") + .getNumberOfMolesInPhase() + + outStream[1].getThermoSystem().getPhase(1).getComponent("MDEA+") + .getNumberOfMolesInPhase())); + + System.out.println("error " + error); + } while (Math.abs(error) > 1e-4 && iter < 30 + && outStream[1].getThermoSystem().getPhase(1).getBeta() > 0 + && outStream[0].getThermoSystem().getPhase(1).getBeta() > 0); + outStream[1].setCalculationIdentifier(id); + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + outStream[0].displayResult(); + outStream[1].displayResult(); + } + + /** + *

+ * setAproachToEquilibrium. + *

+ * + * @param eff a double + */ + public void setAproachToEquilibrium(double eff) { + this.absorptionEfficiency = eff; + } + + /** + *

+ * Getter for the field numberOfTheoreticalStages. + *

+ * + * @return a double + */ + public double getNumberOfTheoreticalStages() { + return numberOfTheoreticalStages; + } + + /** + *

+ * Setter for the field numberOfTheoreticalStages. + *

+ * + * @param numberOfTheoreticalStages a double + */ + public void setNumberOfTheoreticalStages(double numberOfTheoreticalStages) { + this.numberOfTheoreticalStages = numberOfTheoreticalStages; + } + + /** + *

+ * Getter for the field numberOfStages. + *

+ * + * @return a int + */ + public int getNumberOfStages() { + return numberOfStages; + } + + /** + *

+ * Setter for the field numberOfStages. + *

+ * + * @param numberOfStages a int + */ + public void setNumberOfStages(int numberOfStages) { + this.numberOfStages = numberOfStages; + } + + /** + *

+ * Getter for the field stageEfficiency. + *

+ * + * @return a double + */ + public double getStageEfficiency() { + return stageEfficiency; + } + + /** + *

+ * Setter for the field stageEfficiency. + *

+ * + * @param stageEfficiency a double + */ + public void setStageEfficiency(double stageEfficiency) { + this.stageEfficiency = stageEfficiency; + } + + /** + *

+ * getHTU. + *

+ * + * @return a double + */ + public double getHTU() { + return HTU; + } + + /** + *

+ * setHTU. + *

+ * + * @param HTU a double + */ + public void setHTU(double HTU) { + this.HTU = HTU; + } + + /** + *

+ * getNTU. + *

+ * + * @return a double + */ + public double getNTU() { + return NTU; + } + + /** + *

+ * setNTU. + *

+ * + * @param NTU a double + */ + public void setNTU(double NTU) { + this.NTU = NTU; + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/compressor/Compressor.java b/src/main/java/neqsim/processSimulation/processEquipment/compressor/Compressor.java index 9af7506ac8..5d5686452b 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/compressor/Compressor.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/compressor/Compressor.java @@ -5,15 +5,13 @@ import java.text.DecimalFormat; import java.text.FieldPosition; import java.util.Objects; - +import java.util.UUID; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import neqsim.processSimulation.mechanicalDesign.compressor.CompressorMechanicalDesign; import neqsim.processSimulation.processEquipment.TwoPortEquipment; import neqsim.processSimulation.processEquipment.stream.StreamInterface; @@ -30,1286 +28,1289 @@ * @version $Id: $Id */ public class Compressor extends TwoPortEquipment implements CompressorInterface { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(Compressor.class); - public SystemInterface thermoSystem; - private double outTemperature = 298.15; - private boolean useOutTemperature = false; - private CompressorPropertyProfile propertyProfile = new CompressorPropertyProfile(); - public double dH = 0.0; - public double inletEnthalpy = 0; - public double pressure = 0.0; - private int speed = 3000; - public double isentropicEfficiency = 1.0, polytropicEfficiency = 1.0; - public boolean usePolytropicCalc = false; - public boolean powerSet = false; - private CompressorChartInterface compressorChart = new CompressorChart(); - private AntiSurge antiSurge = new AntiSurge(); - private double polytropicHead = 0; - private double polytropicFluidHead = 0, polytropicHeadMeter = 0.0; - private double polytropicExponent = 0; - private int numberOfCompressorCalcSteps = 40; - private boolean useRigorousPolytropicMethod = false; - private boolean useGERG2008 = false; - private String pressureUnit = "bara"; - private String polytropicMethod = "detailed"; - - /** - *

- * Constructor for Compressor. - *

- */ - @Deprecated - public Compressor() { - this("Compressor"); - } - - /** - *

- * Constructor for Compressor. - *

- * - * @param inletStream a - * {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public Compressor(StreamInterface inletStream) { - this(); - setInletStream(inletStream); - } - - /** - *

- * Constructor for Compressor. - *

- * - * @param interpolateMapLookup a boolean - */ - @Deprecated - public Compressor(boolean interpolateMapLookup) { - this("Compressor", interpolateMapLookup); - } - - /** - * Constructor for Compressor. - * - * @param name - */ - public Compressor(String name) { - super(name); - } - - /** - *

- * Constructor for Compressor. - *

- * - * @param name a {@link java.lang.String} object - * @param inletStream a - * {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - public Compressor(String name, StreamInterface inletStream) { - this(name); - setInletStream(inletStream); - } - - /** - *

- * Constructor for Compressor. - *

- * - * @param name - * @param interpolateMapLookup a boolean - */ - public Compressor(String name, boolean interpolateMapLookup) { - this(name); - if (interpolateMapLookup) { - compressorChart = new CompressorChartAlternativeMapLookup(); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(Compressor.class); + public SystemInterface thermoSystem; + private double outTemperature = 298.15; + private boolean useOutTemperature = false; + private CompressorPropertyProfile propertyProfile = new CompressorPropertyProfile(); + public double dH = 0.0; + public double inletEnthalpy = 0; + public double pressure = 0.0; + private int speed = 3000; + public double isentropicEfficiency = 1.0; + public double polytropicEfficiency = 1.0; + public boolean usePolytropicCalc = false; + public boolean powerSet = false; + private CompressorChartInterface compressorChart = new CompressorChart(); + private AntiSurge antiSurge = new AntiSurge(); + private double polytropicHead = 0; + private double polytropicFluidHead = 0; + private double polytropicHeadMeter = 0.0; + private double polytropicExponent = 0; + private int numberOfCompressorCalcSteps = 40; + private boolean useRigorousPolytropicMethod = false; + private boolean useGERG2008 = false; + private String pressureUnit = "bara"; + private String polytropicMethod = "detailed"; + + /** + *

+ * Constructor for Compressor. + *

+ */ + @Deprecated + public Compressor() { + this("Compressor"); + } + + /** + *

+ * Constructor for Compressor. + *

+ * + * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + @Deprecated + public Compressor(StreamInterface inletStream) { + this(); + setInletStream(inletStream); + } + + /** + *

+ * Constructor for Compressor. + *

+ * + * @param interpolateMapLookup a boolean + */ + @Deprecated + public Compressor(boolean interpolateMapLookup) { + this("Compressor", interpolateMapLookup); + } + + /** + * Constructor for Compressor. + * + * @param name + */ + public Compressor(String name) { + super(name); + } + + /** + *

+ * Constructor for Compressor. + *

+ * + * @param name a {@link java.lang.String} object + * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public Compressor(String name, StreamInterface inletStream) { + this(name); + setInletStream(inletStream); + } + + /** + *

+ * Constructor for Compressor. + *

+ * + * @param name + * @param interpolateMapLookup a boolean + */ + public Compressor(String name, boolean interpolateMapLookup) { + this(name); + if (interpolateMapLookup) { + compressorChart = new CompressorChartAlternativeMapLookup(); + } + } + + /** + * {@inheritDoc} + */ + public CompressorMechanicalDesign getMechanicalDesign() { + return new CompressorMechanicalDesign(this); + } + + /** + *

+ * Create deep copy. + *

+ * + * @return a {@link neqsim.processSimulation.processSystem.ProcessSystem} object + */ + public Compressor copy() { + return (Compressor) super.copy(); + } + + /** + * {@inheritDoc} + */ + @Override + public void setInletStream(StreamInterface inletStream) { + this.inStream = inletStream; + try { + this.outStream = inletStream.clone(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + *

+ * solveAntiSurge. + *

+ */ + public void solveAntiSurge() { + if (getAntiSurge().isActive()) { + // .... + } + } + + /** + * {@inheritDoc} + */ + @Override + public void setOutletPressure(double pressure) { + this.pressure = pressure; + } + + /** + *

+ * setOutletPressure. + *

+ * + * @param pressure a double + * @param unit a {@link java.lang.String} object + */ + public void setOutletPressure(double pressure, String unit) { + this.pressure = pressure; + this.pressureUnit = unit; + } + + /** + *

+ * getOutletPressure. + *

+ * + * @return a double + */ + public double getOutletPressure() { + return pressure; + } + + /** + * {@inheritDoc} + */ + @Override + public double getEnergy() { + return getTotalWork(); + } + + /** + *

+ * getPower. + *

+ * + * @return a double + */ + public double getPower() { + return getTotalWork(); + } + + /** + *

+ * getPower. + *

+ * + * @param unit a {@link java.lang.String} object + * @return a double + */ + public double getPower(String unit) { + double conversionFactor = 1.0; + if (unit.equals("MW")) { + conversionFactor = 1.0 / 1.0e6; + } else if (unit.equals("kW")) { + conversionFactor = 1.0 / 1.0e3; + } + return conversionFactor * getPower(); + } + + /** + *

+ * setPower. + *

+ * + * @param p a double + */ + public void setPower(double p) { + powerSet = true; + dH = p; + } + + /** + * Calculates polytropic or isentropic efficiency + * + * @param outTemperature a double + * @return a double + */ + public double solveEfficiency(double outTemperature) { + double funk = 0.0; + double funkOld = 0.0; + double newPoly; + double dfunkdPoly = 100.0; + double dPoly = 100.0; + double oldPoly = outTemperature; + useOutTemperature = false; + run(); + useOutTemperature = true; + int iter = 0; + boolean useOld = usePolytropicCalc; + // usePolytropicCalc = true; + // System.out.println("use polytropic " + usePolytropicCalc); + do { + iter++; + funk = getThermoSystem().getTemperature() - outTemperature; + dfunkdPoly = (funk - funkOld) / dPoly; + newPoly = polytropicEfficiency - funk / dfunkdPoly; + if (iter <= 1) { + newPoly = polytropicEfficiency + 0.01; + } + oldPoly = polytropicEfficiency; + polytropicEfficiency = newPoly; + isentropicEfficiency = newPoly; + dPoly = polytropicEfficiency - oldPoly; + funkOld = funk; + useOutTemperature = false; + run(); + useOutTemperature = true; + // System.out.println("temperature compressor " + + // getThermoSystem().getTemperature() + " funk " + funk + " polytropic " + + // polytropicEfficiency); + } while ((Math.abs((getThermoSystem().getTemperature() - outTemperature)) > 1e-5 || iter < 3) + && (iter < 50)); + usePolytropicCalc = useOld; + return newPoly; + } + + /** + *

+ * findOutPressure. + *

+ * + * @param hinn a double + * @param hout a double + * @param polytropicEfficiency a double + * @return a double + */ + public double findOutPressure(double hinn, double hout, double polytropicEfficiency) { + double entropy = getThermoSystem().getEntropy(); + getThermoSystem().setPressure(getThermoSystem().getPressure() + 1.0, pressureUnit); + + // System.out.println("entropy inn.." + entropy); + ThermodynamicOperations thermoOps = new ThermodynamicOperations(getThermoSystem()); + thermoOps.PSflash(entropy); + + double houtGuess = hinn + dH / polytropicEfficiency; + thermoOps.PHflash(houtGuess, 0); + System.out.println("TEMPERATURE .." + getThermoSystem().getTemperature()); + return getThermoSystem().getPressure(); + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + thermoSystem = inStream.getThermoSystem().clone(); + + if (Math.abs(pressure - thermoSystem.getPressure(pressureUnit)) < 1e-6 + && !compressorChart.isUseCompressorChart()) { + thermoSystem.initProperties(); + outStream.setThermoSystem(getThermoSystem()); + outStream.setCalculationIdentifier(id); + dH = 0.0; + polytropicFluidHead = 0.0; + polytropicHeadMeter = 0.0; + return; + } + + ThermodynamicOperations thermoOps = new ThermodynamicOperations(getThermoSystem()); + thermoOps = new ThermodynamicOperations(getThermoSystem()); + getThermoSystem().init(3); + getThermoSystem().initPhysicalProperties("density"); + double presinn = getThermoSystem().getPressure(); + double hinn = getThermoSystem().getEnthalpy(); + double densInn = getThermoSystem().getDensity(); + double entropy = getThermoSystem().getEntropy(); + + if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { + double[] gergProps; + gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008(); + hinn = gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); + entropy = gergProps[8] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); + densInn = getThermoSystem().getPhase(0).getDensity_GERG2008(); + } + + inletEnthalpy = hinn; + boolean surgeCheck = false; + double orginalMolarFLow = thermoSystem.getTotalNumberOfMoles(); + double fractionAntiSurge = 0.0; + double kappa = 0.0; + if (useOutTemperature) { + if (useRigorousPolytropicMethod) { + solveEfficiency(outTemperature); + polytropicHead = getPower() / getThermoSystem().getFlowRate("kg/sec") / 1000.0 + * getPolytropicEfficiency(); + polytropicFluidHead = polytropicHead; + polytropicHeadMeter = + polytropicFluidHead * 1000.0 / ThermodynamicConstantsInterface.gravity; + return; + } else { + double MW = thermoSystem.getMolarMass(); + thermoSystem.setPressure(getOutletPressure(), pressureUnit); + thermoOps.PSflash(entropy); + if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { + thermoOps.PSflashGERG2008(entropy); } - } - - /** - * {@inheritDoc} - */ - public CompressorMechanicalDesign getMechanicalDesign() { - return new CompressorMechanicalDesign(this); - } - - /** - *

- * Create deep copy. - *

- * - * @return a {@link neqsim.processSimulation.processSystem.ProcessSystem} - * object - */ - public Compressor copy() { - return (Compressor) super.copy(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setInletStream(StreamInterface inletStream) { - this.inStream = inletStream; - try { - this.outStream = inletStream.clone(); - } catch (Exception e) { - e.printStackTrace(); + thermoSystem.initPhysicalProperties("density"); + double densOutIsentropic = thermoSystem.getDensity("kg/m3"); + double enthalpyOutIsentropic = thermoSystem.getEnthalpy(); + if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { + double[] gergProps; + gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008(); + densOutIsentropic = getThermoSystem().getPhase(0).getDensity_GERG2008(); + enthalpyOutIsentropic = + gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); + } + thermoSystem.setTemperature(outTemperature); + thermoOps.TPflash(); + thermoSystem.init(2); + thermoSystem.initPhysicalProperties("density"); + double outEnthalpy = thermoSystem.getEnthalpy(); + double densOut = thermoSystem.getDensity("kg/m3"); + if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { + double[] gergProps; + gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008(); + outEnthalpy = gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); + densOut = getThermoSystem().getPhase(0).getDensity_GERG2008(); + } + dH = outEnthalpy - inletEnthalpy; + // System.out.println("total power " + + // dH/getThermoSystem().getFlowRate("kg/sec")); + + double n = Math.log(getOutletPressure() / presinn) / Math.log(densOut / densInn); + double CF = (enthalpyOutIsentropic - inletEnthalpy) / thermoSystem.getFlowRate("kg/sec") + / (n / (n - 1.0) + * (getOutletPressure() * 1e5 / densOutIsentropic - presinn * 1e5 / densInn)); + + double F1 = thermoSystem.getTotalNumberOfMoles(); + double polytropicPower = F1 * MW * (n / (n - 1.0)) * CF * presinn * 1e5 / densInn + * (Math.pow((getOutletPressure() / presinn), (n - 1.0) / n) - 1.0); + // System.out.println("polytropic power " + + // polytropicPower/getThermoSystem().getFlowRate("kg/sec")); + polytropicEfficiency = polytropicPower / getThermoSystem().getFlowRate("kg/sec") + / (dH / getThermoSystem().getFlowRate("kg/sec")); + isentropicEfficiency = (enthalpyOutIsentropic - inletEnthalpy) / dH; + + // isentropicEfficiency = (getThermoSystem().getEnthalpy() - hinn) / dH; + double k = Math.log(getOutletPressure() / presinn) / Math.log(densOutIsentropic / densInn); + double term1 = Math.pow(getOutletPressure() / presinn, (n - 1.0) / n) - 1.0; + double term2 = n / (n - 1.0) * (k - 1.0) / k; + double term3 = Math.pow(getOutletPressure() / presinn, (k - 1.0) / k) - 1.0; + double polyPow = term1 * term2 / term3 * isentropicEfficiency; + polytropicEfficiency = polyPow; + polytropicPower = dH * polytropicEfficiency; + // System.out.println("polytropic eff " + polytropicEfficiency); + // System.out.println("isentropic eff " + isentropicEfficiency); + polytropicFluidHead = polytropicPower / getThermoSystem().getFlowRate("kg/sec") / 1000.0; + polytropicHeadMeter = polytropicFluidHead * 1000.0 / 9.81; + polytropicHead = polytropicFluidHead; + if (getCompressorChart().isUseCompressorChart()) { + if (getCompressorChart().getHeadUnit().equals("meter")) { + polytropicHead = polytropicHeadMeter; + } else { + polytropicHead = polytropicFluidHead; + } + } + outStream.setThermoSystem(getThermoSystem()); + outStream.setCalculationIdentifier(id); + setCalculationIdentifier(id); + return; + } + } + if (compressorChart.isUseCompressorChart()) { + do { + double actualFlowRate = thermoSystem.getFlowRate("m3/hr"); + double z_inlet = thermoSystem.getZ(); + double MW = thermoSystem.getMolarMass(); + + if (getCompressorChart().useRealKappa()) { + kappa = thermoSystem.getGamma(); + } else { + kappa = thermoSystem.getGamma2(); + } + if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { + double[] gergProps; + gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008(); + actualFlowRate *= gergProps[1] / z_inlet; + kappa = gergProps[14]; + z_inlet = gergProps[1]; } - } - /** - *

- * solveAntiSurge. - *

- */ - public void solveAntiSurge() { + double polytropEff = + getCompressorChart().getPolytropicEfficiency(actualFlowRate, getSpeed()); + setPolytropicEfficiency(polytropEff / 100.0); + polytropicHead = getCompressorChart().getPolytropicHead(actualFlowRate, getSpeed()); + double temperature_inlet = thermoSystem.getTemperature(); + double n = 1.0 / (1.0 - (kappa - 1.0) / kappa * 1.0 / (polytropEff / 100.0)); + polytropicExponent = n; + if (getCompressorChart().getHeadUnit().equals("meter")) { + polytropicFluidHead = polytropicHead / 1000.0 * 9.81; + polytropicHeadMeter = polytropicHead; + } else { + polytropicFluidHead = polytropicHead; + polytropicHeadMeter = polytropicHead * 1000.0 / 9.81; + } + double pressureRatio = Math.pow((polytropicFluidHead * 1000.0 + + (n / (n - 1.0) * z_inlet * 8.314 * (temperature_inlet) / MW)) + / (n / (n - 1.0) * z_inlet * 8.314 * (temperature_inlet) / MW), n / (n - 1.0)); + setOutletPressure(thermoSystem.getPressure() * pressureRatio); if (getAntiSurge().isActive()) { - // .... + logger.info("surge flow " + + getCompressorChart().getSurgeCurve().getSurgeFlow(polytropicHead) + " m3/hr"); + surgeCheck = isSurge(polytropicHead, actualFlowRate); } - } - - /** - * {@inheritDoc} - */ - @Override - public void setOutletPressure(double pressure) { - this.pressure = pressure; - } - - /** - *

- * setOutletPressure. - *

- * - * @param pressure a double - * @param unit a {@link java.lang.String} object - */ - public void setOutletPressure(double pressure, String unit) { - this.pressure = pressure; - this.pressureUnit = unit; - } - - /** - *

- * getOutletPressure. - *

- * - * @return a double - */ - public double getOutletPressure() { - return pressure; - } - - /** - * {@inheritDoc} - */ - @Override - public double getEnergy() { - return getTotalWork(); - } - - /** - *

- * getPower. - *

- * - * @return a double - */ - public double getPower() { - return getTotalWork(); - } - - /** - *

- * getPower. - *

- * - * @param unit a {@link java.lang.String} object - * @return a double - */ - public double getPower(String unit) { - double conversionFactor = 1.0; - if (unit.equals("MW")) { - conversionFactor = 1.0 / 1.0e6; - } else if (unit.equals("kW")) { - conversionFactor = 1.0 / 1.0e3; + if (getCompressorChart().getStoneWallCurve().isActive()) { + // logger.info("stone wall? " + isStoneWall(polytropicHead, + // thermoSystem.getFlowRate("m3/hr"))); + } + if (surgeCheck && getAntiSurge().isActive()) { + thermoSystem.setTotalFlowRate( + getAntiSurge().getSurgeControlFactor() + * getCompressorChart().getSurgeCurve().getSurgeFlow(polytropicFluidHead), + "Am3/hr"); + thermoSystem.init(3); + fractionAntiSurge = thermoSystem.getTotalNumberOfMoles() / orginalMolarFLow - 1.0; + getAntiSurge().setCurrentSurgeFraction(fractionAntiSurge); } - return conversionFactor * getPower(); - } - /** - *

- * setPower. - *

- * - * @param p a double - */ - public void setPower(double p) { powerSet = true; - dH = p; - } - - /** - * Calculates polytropic or isentropic efficiency - * - * @param outTemperature a double - * @return a double - */ - public double solveEfficiency(double outTemperature) { - double funk = 0.0, funkOld = 0.0; - double newPoly; - double dfunkdPoly = 100.0, dPoly = 100.0, oldPoly = outTemperature; - useOutTemperature = false; - run(); - useOutTemperature = true; - int iter = 0; - boolean useOld = usePolytropicCalc; - // usePolytropicCalc = true; - // System.out.println("use polytropic " + usePolytropicCalc); - do { - iter++; - funk = getThermoSystem().getTemperature() - outTemperature; - dfunkdPoly = (funk - funkOld) / dPoly; - newPoly = polytropicEfficiency - funk / dfunkdPoly; - if (iter <= 1) { - newPoly = polytropicEfficiency + 0.01; - } - oldPoly = polytropicEfficiency; - polytropicEfficiency = newPoly; - isentropicEfficiency = newPoly; - dPoly = polytropicEfficiency - oldPoly; - funkOld = funk; - useOutTemperature = false; - run(); - useOutTemperature = true; - // System.out.println("temperature compressor " + - // getThermoSystem().getTemperature() + " funk " + funk + " polytropic " + - // polytropicEfficiency); - } while ((Math.abs((getThermoSystem().getTemperature() - outTemperature)) > 1e-5 || iter < 3) - && (iter < 50)); - usePolytropicCalc = useOld; - return newPoly; - } - - /** - *

- * findOutPressure. - *

- * - * @param hinn a double - * @param hout a double - * @param polytropicEfficiency a double - * @return a double - */ - public double findOutPressure(double hinn, double hout, double polytropicEfficiency) { - double entropy = getThermoSystem().getEntropy(); - getThermoSystem().setPressure(getThermoSystem().getPressure() + 1.0, pressureUnit); - - // System.out.println("entropy inn.." + entropy); - ThermodynamicOperations thermoOps = new ThermodynamicOperations(getThermoSystem()); - thermoOps.PSflash(entropy); - - double houtGuess = hinn + dH / polytropicEfficiency; - thermoOps.PHflash(houtGuess, 0); - System.out.println("TEMPERATURE .." + getThermoSystem().getTemperature()); - return getThermoSystem().getPressure(); + dH = polytropicFluidHead * 1000.0 * thermoSystem.getMolarMass() / getPolytropicEfficiency() + * thermoSystem.getTotalNumberOfMoles(); + } while (surgeCheck && getAntiSurge().isActive()); } - /** - * {@inheritDoc} - */ - @Override - public void run() { - thermoSystem = inStream.getThermoSystem().clone(); - - if (Math.abs(pressure - thermoSystem.getPressure(pressureUnit)) < 1e-6 && !compressorChart.isUseCompressorChart()) { - thermoSystem.initProperties(); - outStream.setThermoSystem(getThermoSystem()); - dH = 0.0; - polytropicFluidHead = 0.0; - polytropicHeadMeter = 0.0; - return; - } - - ThermodynamicOperations thermoOps = new ThermodynamicOperations(getThermoSystem()); + if (usePolytropicCalc) { + if (powerSet) { + double hout = hinn * (1 - 0 + fractionAntiSurge) + dH; + thermoSystem.setPressure(pressure, pressureUnit); thermoOps = new ThermodynamicOperations(getThermoSystem()); - getThermoSystem().init(3); - getThermoSystem().initPhysicalProperties("density"); - double presinn = getThermoSystem().getPressure(); - double hinn = getThermoSystem().getEnthalpy(); - double densInn = getThermoSystem().getDensity(); - double entropy = getThermoSystem().getEntropy(); - + thermoOps.PHflash(hout, 0); if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { - double[] gergProps; - gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008(); - hinn = gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); - entropy = gergProps[8] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); - densInn = getThermoSystem().getPhase(0).getDensity_GERG2008(); - } - - inletEnthalpy = hinn; - boolean surgeCheck = false; - double orginalMolarFLow = thermoSystem.getTotalNumberOfMoles(); - double fractionAntiSurge = 0.0; - double kappa = 0.0; - if (useOutTemperature) { - if (useRigorousPolytropicMethod) { - solveEfficiency(outTemperature); - polytropicHead = getPower() / getThermoSystem().getFlowRate("kg/sec") / 1000.0 - * getPolytropicEfficiency(); - polytropicFluidHead = polytropicHead; - polytropicHeadMeter - = polytropicFluidHead * 1000.0 / ThermodynamicConstantsInterface.gravity; - return; - } else { - double MW = thermoSystem.getMolarMass(); - thermoSystem.setPressure(getOutletPressure(), pressureUnit); - thermoOps.PSflash(entropy); - if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { - thermoOps.PSflashGERG2008(entropy); - } - thermoSystem.initPhysicalProperties("density"); - double densOutIsentropic = thermoSystem.getDensity("kg/m3"); - double enthalpyOutIsentropic = thermoSystem.getEnthalpy(); - if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { - double[] gergProps; - gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008(); - densOutIsentropic = getThermoSystem().getPhase(0).getDensity_GERG2008(); - enthalpyOutIsentropic - = gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); - } - thermoSystem.setTemperature(outTemperature); - thermoOps.TPflash(); - thermoSystem.init(2); - thermoSystem.initPhysicalProperties("density"); - double outEnthalpy = thermoSystem.getEnthalpy(); - double densOut = thermoSystem.getDensity("kg/m3"); - if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { - double[] gergProps; - gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008(); - outEnthalpy = gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); - densOut = getThermoSystem().getPhase(0).getDensity_GERG2008(); - } - dH = outEnthalpy - inletEnthalpy; - // System.out.println("total power " + - // dH/getThermoSystem().getFlowRate("kg/sec")); - - double n = Math.log(getOutletPressure() / presinn) / Math.log(densOut / densInn); - double CF = (enthalpyOutIsentropic - inletEnthalpy) / thermoSystem.getFlowRate("kg/sec") - / (n / (n - 1.0) - * (getOutletPressure() * 1e5 / densOutIsentropic - presinn * 1e5 / densInn)); - - double F1 = thermoSystem.getTotalNumberOfMoles(); - double polytropicPower = F1 * MW * (n / (n - 1.0)) * CF * presinn * 1e5 / densInn - * (Math.pow((getOutletPressure() / presinn), (n - 1.0) / n) - 1.0); - // System.out.println("polytropic power " + - // polytropicPower/getThermoSystem().getFlowRate("kg/sec")); - polytropicEfficiency = polytropicPower / getThermoSystem().getFlowRate("kg/sec") - / (dH / getThermoSystem().getFlowRate("kg/sec")); - isentropicEfficiency = (enthalpyOutIsentropic - inletEnthalpy) / dH; - - // isentropicEfficiency = (getThermoSystem().getEnthalpy() - hinn) / dH; - double k = Math.log(getOutletPressure() / presinn) / Math.log(densOutIsentropic / densInn); - double term1 = Math.pow(getOutletPressure() / presinn, (n - 1.0) / n) - 1.0; - double term2 = n / (n - 1.0) * (k - 1.0) / k; - double term3 = Math.pow(getOutletPressure() / presinn, (k - 1.0) / k) - 1.0; - double polyPow = term1 * term2 / term3 * isentropicEfficiency; - polytropicEfficiency = polyPow; - polytropicPower = dH * polytropicEfficiency; - // System.out.println("polytropic eff " + polytropicEfficiency); - // System.out.println("isentropic eff " + isentropicEfficiency); - polytropicFluidHead = polytropicPower / getThermoSystem().getFlowRate("kg/sec") / 1000.0; - polytropicHeadMeter = polytropicFluidHead * 1000.0 / 9.81; - polytropicHead = polytropicFluidHead; - if (getCompressorChart().isUseCompressorChart()) { - if (getCompressorChart().getHeadUnit().equals("meter")) { - polytropicHead = polytropicHeadMeter; - } else { - polytropicHead = polytropicFluidHead; - } - } - outStream.setThermoSystem(getThermoSystem()); - - return; - } + thermoOps.PHflashGERG2008(hout); } - if (compressorChart.isUseCompressorChart()) { - do { - double actualFlowRate = thermoSystem.getFlowRate("m3/hr"); - double z_inlet = thermoSystem.getZ(); - double MW = thermoSystem.getMolarMass(); - - if (getCompressorChart().useRealKappa()) { - kappa = thermoSystem.getGamma(); - } else { - kappa = thermoSystem.getGamma2(); - } - if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { - double[] gergProps; - gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008(); - actualFlowRate *= gergProps[1] / z_inlet; - kappa = gergProps[14]; - z_inlet = gergProps[1]; - } - - double polytropEff - = getCompressorChart().getPolytropicEfficiency(actualFlowRate, getSpeed()); - setPolytropicEfficiency(polytropEff / 100.0); - polytropicHead = getCompressorChart().getPolytropicHead(actualFlowRate, getSpeed()); - double temperature_inlet = thermoSystem.getTemperature(); - double n = 1.0 / (1.0 - (kappa - 1.0) / kappa * 1.0 / (polytropEff / 100.0)); - polytropicExponent = n; - if (getCompressorChart().getHeadUnit().equals("meter")) { - polytropicFluidHead = polytropicHead / 1000.0 * 9.81; - polytropicHeadMeter = polytropicHead; - } else { - polytropicFluidHead = polytropicHead; - polytropicHeadMeter = polytropicHead * 1000.0 / 9.81; - } - double pressureRatio = Math.pow((polytropicFluidHead * 1000.0 - + (n / (n - 1.0) * z_inlet * 8.314 * (temperature_inlet) / MW)) - / (n / (n - 1.0) * z_inlet * 8.314 * (temperature_inlet) / MW), n / (n - 1.0)); - setOutletPressure(thermoSystem.getPressure() * pressureRatio); - if (getAntiSurge().isActive()) { - logger.info("surge flow " - + getCompressorChart().getSurgeCurve().getSurgeFlow(polytropicHead) + " m3/hr"); - surgeCheck = isSurge(polytropicHead, actualFlowRate); - } - if (getCompressorChart().getStoneWallCurve().isActive()) { - // logger.info("stone wall? " + isStoneWall(polytropicHead, - // thermoSystem.getFlowRate("m3/hr"))); - } - if (surgeCheck && getAntiSurge().isActive()) { - thermoSystem.setTotalFlowRate( - getAntiSurge().getSurgeControlFactor() - * getCompressorChart().getSurgeCurve().getSurgeFlow(polytropicFluidHead), - "Am3/hr"); - thermoSystem.init(3); - fractionAntiSurge = thermoSystem.getTotalNumberOfMoles() / orginalMolarFLow - 1.0; - getAntiSurge().setCurrentSurgeFraction(fractionAntiSurge); - } - - powerSet = true; - dH = polytropicFluidHead * 1000.0 * thermoSystem.getMolarMass() / getPolytropicEfficiency() - * thermoSystem.getTotalNumberOfMoles(); - } while (surgeCheck && getAntiSurge().isActive()); - } - - if (usePolytropicCalc) { - if (powerSet) { - double hout = hinn * (1 - 0 + fractionAntiSurge) + dH; - thermoSystem.setPressure(pressure, pressureUnit); - thermoOps = new ThermodynamicOperations(getThermoSystem()); - thermoOps.PHflash(hout, 0); - if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { - thermoOps.PHflashGERG2008(hout); - } - } else { - if (polytropicMethod.equals("detailed")) { - // todo add detailed output of compressor calculations - int numbersteps = numberOfCompressorCalcSteps; - double dp = (pressure - getThermoSystem().getPressure()) / (1.0 * numbersteps); - for (int i = 0; i < numbersteps; i++) { - entropy = getThermoSystem().getEntropy(); - hinn = getThermoSystem().getEnthalpy(); - if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { - double[] gergProps; - gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008(); - hinn = gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); - entropy = gergProps[8] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); - } - getThermoSystem().setPressure(getThermoSystem().getPressure() + dp, pressureUnit); - thermoOps = new ThermodynamicOperations(getThermoSystem()); - if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { - thermoOps.PSflashGERG2008(entropy); - } else { - double oleTemp = getThermoSystem().getTemperature(); - thermoOps.PSflash(entropy); - if (Math.abs(getThermoSystem().getEntropy() - entropy) > 1e-3) { - getThermoSystem().setTemperature(oleTemp); - thermoOps.TPflash(); - getThermoSystem().init(2); - continue; - } - } - double newEnt = getThermoSystem().getEnthalpy(); - if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { - double[] gergProps; - gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008(); - newEnt = gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); - } - double hout = hinn + (newEnt - hinn) / polytropicEfficiency; - thermoOps.PHflash(hout, 0); - if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { - thermoOps.PHflashGERG2008(hout); - } - if (propertyProfile.isActive()) { - propertyProfile.addFluid(thermoSystem.clone()); - } - } - } else if (polytropicMethod.equals("schultz")) { - double schultzX - = thermoSystem.getTemperature() / thermoSystem.getVolume() * thermoSystem.getdVdTpn() - - 1.0; - double schultzY - = -thermoSystem.getPressure() / thermoSystem.getVolume() * thermoSystem.getdVdPtn(); - thermoSystem.setPressure(getOutletPressure(), pressureUnit); - thermoOps.PSflash(entropy); - thermoSystem.initProperties(); - double densOutIsentropic = thermoSystem.getDensity("kg/m3"); - double enthalpyOutIsentropic = thermoSystem.getEnthalpy(); - if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { - thermoOps.PSflashGERG2008(entropy); - double[] gergProps; - gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008(); - densOutIsentropic = getThermoSystem().getPhase(0).getDensity_GERG2008(); - enthalpyOutIsentropic - = gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); - } - double isenthalpicvolumeexponent - = Math.log(getOutletPressure() / presinn) / Math.log(densOutIsentropic / densInn); - double nV = (1.0 + schultzX) - / (1.0 / isenthalpicvolumeexponent * (1.0 / polytropicEfficiency + schultzX) - - schultzY * (1.0 / polytropicEfficiency - 1.0)); - double term = nV / (nV - 1.0); - double term2 = 1e5 * (getOutletPressure() / densOutIsentropic - presinn / densInn); - double term3 = isenthalpicvolumeexponent / (isenthalpicvolumeexponent - 1.0); - double CF = (enthalpyOutIsentropic - inletEnthalpy) / (term2 * term3); - dH = term * CF * 1e5 * presinn / densInn - * (Math.pow(getOutletPressure() / presinn, 1.0 / term) - 1.0) / polytropicEfficiency; - double hout = hinn + dH; - thermoOps = new ThermodynamicOperations(getThermoSystem()); - thermoOps.PHflash(hout, 0); - if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { - thermoOps.PHflashGERG2008(hout); - } - } else { - thermoSystem.setPressure(getOutletPressure(), pressureUnit); - thermoOps.PSflash(entropy); - thermoSystem.initProperties(); - double densOutIsentropic = thermoSystem.getDensity("kg/m3"); - double enthalpyOutIsentropic = thermoSystem.getEnthalpy(); - if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { - thermoOps.PSflashGERG2008(entropy); - double[] gergProps; - gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008(); - densOutIsentropic = getThermoSystem().getPhase(0).getDensity_GERG2008(); - enthalpyOutIsentropic - = gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); - } - double isenthalpicvolumeexponent - = Math.log(getOutletPressure() / presinn) / Math.log(densOutIsentropic / densInn); - double term = isenthalpicvolumeexponent / (isenthalpicvolumeexponent - 1.0) - * (polytropicEfficiency); - double term2 = 1e5 * (getOutletPressure() / densOutIsentropic - presinn / densInn); - double CF = (enthalpyOutIsentropic - inletEnthalpy) / (term * term2); - dH = term * CF * 1e5 * presinn / densInn - * (Math.pow(getOutletPressure() / presinn, 1.0 / term) - 1.0); - double hout = hinn + dH; - thermoOps = new ThermodynamicOperations(getThermoSystem()); - thermoOps.PHflash(hout, 0); - if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { - thermoOps.PHflashGERG2008(hout); - } - } + } else { + if (polytropicMethod.equals("detailed")) { + // todo add detailed output of compressor calculations + int numbersteps = numberOfCompressorCalcSteps; + double dp = (pressure - getThermoSystem().getPressure()) / (1.0 * numbersteps); + for (int i = 0; i < numbersteps; i++) { + entropy = getThermoSystem().getEntropy(); + hinn = getThermoSystem().getEnthalpy(); + if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { + double[] gergProps; + gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008(); + hinn = gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); + entropy = gergProps[8] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); } - } else { - getThermoSystem().setPressure(pressure, pressureUnit); - // System.out.println("entropy inn.." + entropy); + getThermoSystem().setPressure(getThermoSystem().getPressure() + dp, pressureUnit); thermoOps = new ThermodynamicOperations(getThermoSystem()); - thermoOps.PSflash(entropy); if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { - thermoOps.PSflashGERG2008(entropy); + thermoOps.PSflashGERG2008(entropy); + } else { + double oleTemp = getThermoSystem().getTemperature(); + thermoOps.PSflash(entropy); + if (Math.abs(getThermoSystem().getEntropy() - entropy) > 1e-3) { + getThermoSystem().setTemperature(oleTemp); + thermoOps.TPflash(); + getThermoSystem().init(2); + continue; + } } - // double densOutIdeal = getThermoSystem().getDensity(); double newEnt = getThermoSystem().getEnthalpy(); - if (!powerSet) { - dH = (getThermoSystem().getEnthalpy() - hinn) / isentropicEfficiency; - if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { - double[] gergProps; - gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008(); - newEnt = gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); - dH = (newEnt - hinn) / isentropicEfficiency; - } + if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { + double[] gergProps; + gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008(); + newEnt = gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); } - double hout = hinn + dH; - isentropicEfficiency = (newEnt - hinn) / dH; - dH = hout - hinn; - thermoOps = new ThermodynamicOperations(getThermoSystem()); + double hout = hinn + (newEnt - hinn) / polytropicEfficiency; thermoOps.PHflash(hout, 0); if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { - thermoOps.PHflashGERG2008(hout); + thermoOps.PHflashGERG2008(hout); } - } - // thermoSystem.display(); - - if (getCompressorChart().isUseCompressorChart() && getAntiSurge().isActive()) { - thermoSystem.setTotalNumberOfMoles(orginalMolarFLow); - thermoSystem.init(3); - } - thermoSystem.initProperties(); - outStream.setThermoSystem(getThermoSystem()); - - polytropicFluidHead - = getPower() / getThermoSystem().getFlowRate("kg/sec") / 1000.0 * getPolytropicEfficiency(); - polytropicHeadMeter = polytropicFluidHead * 1000.0 / 9.81; - } - - /** - *

- * generateCompressorCurves. - *

- */ - public void generateCompressorCurves() { - double flowRef = getThermoSystem().getFlowRate("m3/hr"); - double factor = flowRef / 4000.0; - double[] chartConditions = new double[]{0.3, 1.0, 1.0, 1.0}; - double[] speed = new double[]{12913, 12298, 11683, 11098, 10453, 9224, 8609, 8200}; - double[][] flow = new double[][]{ - {2789.1285, 3174.0375, 3689.2288, 4179.4503, 4570.2768, 4954.7728, 5246.0329, 5661.0331}, - {2571.1753, 2943.7254, 3440.2675, 3837.4448, 4253.0898, 4668.6643, 4997.1926, 5387.4952}, - {2415.3793, 2763.0706, 3141.7095, 3594.7436, 4047.6467, 4494.1889, 4853.7353, 5138.7858}, - {2247.2043, 2799.7342, 3178.3428, 3656.1551, 4102.778, 4394.1591, 4648.3224, 4840.4998}, - {2072.8397, 2463.9483, 2836.4078, 3202.5266, 3599.6333, 3978.0203, 4257.0022, 4517.345}, - {1835.9552, 2208.455, 2618.1322, 2940.8034, 3244.7852, 3530.1279, 3753.3738, 3895.9746}, - {1711.3386, 1965.8848, 2356.9431, 2685.9247, 3008.5154, 3337.2855, 3591.5092}, - {1636.5807, 2002.8708, 2338.0319, 2642.1245, 2896.4894, 3113.6264, 3274.8764, 3411.2977}}; - - for (int i = 0; i < flow.length; i++) { - for (int j = 0; j < flow[i].length; j++) { - flow[i][j] *= factor; + if (propertyProfile.isActive()) { + propertyProfile.addFluid(thermoSystem.clone()); } - } - - double[][] head - = new double[][]{{80.0375, 78.8934, 76.2142, 71.8678, 67.0062, 60.6061, 53.0499, 39.728}, - {72.2122, 71.8369, 68.9009, 65.8341, 60.7167, 54.702, 47.2749, 35.7471}, - {65.1576, 64.5253, 62.6118, 59.1619, 54.0455, 47.0059, 39.195, 31.6387}, - {58.6154, 56.9627, 54.6647, 50.4462, 44.4322, 38.4144, 32.9084, 28.8109}, - {52.3295, 51.0573, 49.5283, 46.3326, 42.3685, 37.2502, 31.4884, 25.598}, - {40.6578, 39.6416, 37.6008, 34.6603, 30.9503, 27.1116, 23.2713, 20.4546}, - {35.2705, 34.6359, 32.7228, 31.0645, 27.0985, 22.7482, 18.0113}, - {32.192, 31.1756, 29.1329, 26.833, 23.8909, 21.3324, 18.7726, 16.3403},}; - - for (int i = 0; i < head.length; i++) { - for (int j = 0; j < head[i].length; j++) { - head[i][j] *= factor / 5.0; - } - } - double[][] polyEff = new double[][]{ - {77.2452238409573, 79.4154186459363, 80.737960012489, 80.5229826589649, 79.2210931638144, - 75.4719133864634, 69.6034181197298, 58.7322388482707}, - {77.0107837113504, 79.3069974136389, 80.8941189021135, 80.7190194665918, 79.5313242980328, - 75.5912622896367, 69.6846136362097, 60.0043057990909}, - {77.0043065299874, 79.1690958847856, 80.8038169975675, 80.6543975614197, 78.8532389102705, - 73.6664774270613, 66.2735600426727, 57.671664571658}, - {77.0716623789093, 80.4629750233093, 81.1390811169072, 79.6374242667478, 75.380928428817, - 69.5332969549779, 63.7997587622339, 58.8120614497758}, - {76.9705872525642, 79.8335492585324, 80.9468133671171, 80.5806471927835, 78.0462158225426, - 73.0403707523258, 66.5572286338589, 59.8624822515064}, - {77.5063036680357, 80.2056198362559, 81.0339108025933, 79.6085962687939, 76.3814534404405, - 70.8027503005902, 64.6437367160571, 60.5299349982342}, - {77.8175271586685, 80.065165942218, 81.0631362122632, 79.8955051771299, 76.1983240929369, - 69.289982774309, 60.8567149372229}, - {78.0924334304045, 80.9353551568667, 80.7904437766234, 78.8639325223295, 75.2170936751143, - 70.3105081673411, 65.5507568533569, 61.0391468300337}}; - - getCompressorChart().setCurves(chartConditions, speed, flow, head, polyEff); - getCompressorChart().setHeadUnit("kJ/kg"); - } - - /** - * {@inheritDoc} - */ - @Override - public void displayResult() { - DecimalFormat nf = new DecimalFormat(); - nf.setMaximumFractionDigits(5); - nf.applyPattern("#.#####E0"); - - JDialog dialog = new JDialog(new JFrame(), "Results from TPflash"); - Container dialogContentPane = dialog.getContentPane(); - dialogContentPane.setLayout(new FlowLayout()); - - getThermoSystem().initPhysicalProperties(); - String[][] table = new String[50][5]; - String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"}; - table[0][0] = ""; - table[0][1] = ""; - table[0][2] = ""; - table[0][3] = ""; - StringBuffer buf = new StringBuffer(); - FieldPosition test = new FieldPosition(0); - - for (int i = 0; i < getThermoSystem().getNumberOfPhases(); i++) { - for (int j = 0; j < getThermoSystem().getPhases()[0].getNumberOfComponents(); j++) { - table[j + 1][0] = getThermoSystem().getPhases()[0].getComponents()[j].getName(); - buf = new StringBuffer(); - table[j + 1][i + 1] - = nf.format(getThermoSystem().getPhases()[i].getComponents()[j].getx(), buf, test) - .toString(); - table[j + 1][4] = "[-]"; - } - buf = new StringBuffer(); - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 2][0] = "Density"; - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 2][i + 1] = nf - .format(getThermoSystem().getPhases()[i].getPhysicalProperties().getDensity(), buf, test) - .toString(); - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 2][4] = "[kg/m^3]"; - - // Double.longValue(thermoSystem.getPhases()[i].getBeta()); - buf = new StringBuffer(); - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 3][0] = "PhaseFraction"; - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 3][i + 1] - = nf.format(getThermoSystem().getPhases()[i].getBeta(), buf, test).toString(); - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 3][4] = "[-]"; - - buf = new StringBuffer(); - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 4][0] = "MolarMass"; - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 4][i + 1] - = nf.format(getThermoSystem().getPhases()[i].getMolarMass() * 1000, buf, test).toString(); - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 4][4] = "[kg/kmol]"; - - buf = new StringBuffer(); - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 5][0] = "Cp"; - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 5][i + 1] - = nf.format((getThermoSystem().getPhases()[i].getCp() - / getThermoSystem().getPhases()[i].getNumberOfMolesInPhase() * 1.0 - / getThermoSystem().getPhases()[i].getMolarMass() * 1000), buf, test).toString(); - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 5][4] = "[kJ/kg*K]"; - - buf = new StringBuffer(); - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 7][0] = "Viscosity"; - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 7][i + 1] - = nf.format((getThermoSystem().getPhases()[i].getPhysicalProperties().getViscosity()), buf, - test).toString(); - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 7][4] = "[kg/m*sec]"; - - buf = new StringBuffer(); - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 8][0] = "Conductivity"; - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 8][i + 1] - = nf.format(getThermoSystem().getPhases()[i].getPhysicalProperties().getConductivity(), buf, - test).toString(); - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 8][4] = "[W/m*K]"; - - buf = new StringBuffer(); - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 10][0] = "Pressure"; - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 10][i + 1] - = Double.toString(getThermoSystem().getPhases()[i].getPressure()); - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 10][4] = "[bar]"; - - buf = new StringBuffer(); - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 11][0] = "Temperature"; - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 11][i + 1] - = Double.toString(getThermoSystem().getPhases()[i].getTemperature()); - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 11][4] = "[K]"; - Double.toString(getThermoSystem().getPhases()[i].getTemperature()); - - buf = new StringBuffer(); - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 13][0] = "Stream"; - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 13][i + 1] = name; - table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 13][4] = "-"; - } - - JTable Jtab = new JTable(table, names); - JScrollPane scrollpane = new JScrollPane(Jtab); - dialogContentPane.add(scrollpane); - dialog.pack(); - dialog.setVisible(true); - } - - /** - * {@inheritDoc} - */ - @Override - public String[][] getResultTable() { - return thermoSystem.getResultTable(); - } - - /** - *

- * getTotalWork. - *

- * - * @return a double - */ - public double getTotalWork() { - double multi = 1.0; - if (getAntiSurge().isActive()) { - multi = 1.0 + getAntiSurge().getCurrentSurgeFraction(); - } - if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { + } + } else if (polytropicMethod.equals("schultz")) { + double schultzX = + thermoSystem.getTemperature() / thermoSystem.getVolume() * thermoSystem.getdVdTpn() + - 1.0; + double schultzY = + -thermoSystem.getPressure() / thermoSystem.getVolume() * thermoSystem.getdVdPtn(); + thermoSystem.setPressure(getOutletPressure(), pressureUnit); + thermoOps.PSflash(entropy); + thermoSystem.initProperties(); + double densOutIsentropic = thermoSystem.getDensity("kg/m3"); + double enthalpyOutIsentropic = thermoSystem.getEnthalpy(); + if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { + thermoOps.PSflashGERG2008(entropy); double[] gergProps; gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008(); - double enth = gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); - return (enth - inletEnthalpy) * multi; - } else { - return multi * (getThermoSystem().getEnthalpy() - inletEnthalpy); - } - } - - /** - * {@inheritDoc} - */ - @Override - public double getIsentropicEfficiency() { - return isentropicEfficiency; - } - - /** - * {@inheritDoc} - */ - @Override - public void setIsentropicEfficiency(double isentropicEfficiency) { - this.isentropicEfficiency = isentropicEfficiency; - } - - /** - *

- * usePolytropicCalc. - *

- * - * @return the usePolytropicCalc - */ - public boolean usePolytropicCalc() { - return usePolytropicCalc; - } - - /** - *

- * Setter for the field usePolytropicCalc. - *

- * - * @param usePolytropicCalc the usePolytropicCalc to set - */ - public void setUsePolytropicCalc(boolean usePolytropicCalc) { - this.usePolytropicCalc = usePolytropicCalc; - } - - /** - * {@inheritDoc} - */ - @Override - public double getPolytropicEfficiency() { - return polytropicEfficiency; - } - - /** - * {@inheritDoc} - */ - @Override - public void setPolytropicEfficiency(double polytropicEfficiency) { - this.polytropicEfficiency = polytropicEfficiency; - } - - /** - * {@inheritDoc} - */ - @Override - public SystemInterface getThermoSystem() { - return thermoSystem; - } - - /** - *

- * Getter for the field compressorChart. - *

- * - * @return a - * {@link neqsim.processSimulation.processEquipment.compressor.CompressorChartInterface} - * object - */ - public CompressorChartInterface getCompressorChart() { - return compressorChart; - } - - /** - *

- * Setter for the field compressorChart. - *

- * - * @param compressorChart a - * {@link neqsim.processSimulation.processEquipment.compressor.CompressorChart} - * object - */ - public void setCompressorChart(CompressorChart compressorChart) { - this.compressorChart = compressorChart; - } - - /** - * {@inheritDoc} - */ - @Override - public AntiSurge getAntiSurge() { - return antiSurge; - } - - /** - *

- * isSurge. - *

- * - * @param flow a double - * @param head a double - * @return a boolean - */ - public boolean isSurge(double flow, double head) { - getAntiSurge().setSurge(getCompressorChart().getSurgeCurve().isSurge(flow, head)); - return getAntiSurge().isSurge(); - } - - /** - *

- * isStoneWall. - *

- * - * @param flow a double - * @param head a double - * @return a boolean - */ - public boolean isStoneWall(double flow, double head) { - return getCompressorChart().getStoneWallCurve().isStoneWall(flow, head); - } - - /** - *

- * Setter for the field antiSurge. - *

- * - * @param antiSurge a - * {@link neqsim.processSimulation.processEquipment.compressor.AntiSurge} - * object - */ - public void setAntiSurge(AntiSurge antiSurge) { - this.antiSurge = antiSurge; - } - - /** - *

- * Getter for the field speed. - *

- * - * @return a int - */ - public int getSpeed() { - return speed; - } - - /** - *

- * Setter for the field speed. - *

- * - * @param speed a int - */ - public void setSpeed(int speed) { - this.speed = speed; - } - - /** - *

- * Getter for the field polytropicHead. - *

- * - * @param unit a {@link java.lang.String} object - * @return a double - */ - public double getPolytropicHead(String unit) { - if (unit.equals("kJ/kg")) { - return polytropicFluidHead; - } else if (unit.equals("meter")) { - return polytropicHeadMeter; - } else { - return polytropicHead; - } - } - - /** - *

- * Getter for the field polytropicHead. - *

- * - * @return a double - */ - public double getPolytropicHead() { - return polytropicHead; - } - - /** - *

- * Getter for the field polytropicFluidHead. - *

- * - * @return a double - */ - public double getPolytropicFluidHead() { - return polytropicFluidHead; - } - - /** - *

- * Getter for the field polytropicExponent. - *

- * - * @return a double - */ - public double getPolytropicExponent() { - return polytropicExponent; - } - - /** - *

- * Getter for the field polytropicHeadMeter. - *

- * - * @return a double - */ - public double getPolytropicHeadMeter() { - return polytropicHeadMeter; - } - - /** - *

- * Setter for the field polytropicHeadMeter. - *

- * - * @param polytropicHeadMeter a double - */ - public void setPolytropicHeadMeter(double polytropicHeadMeter) { - this.polytropicHeadMeter = polytropicHeadMeter; - } - - /** - *

- * Getter for the field outTemperature. - *

- * - * @return a double - */ - public double getOutTemperature() { - if (useOutTemperature) { - return outTemperature; + densOutIsentropic = getThermoSystem().getPhase(0).getDensity_GERG2008(); + enthalpyOutIsentropic = + gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); + } + double isenthalpicvolumeexponent = + Math.log(getOutletPressure() / presinn) / Math.log(densOutIsentropic / densInn); + double nV = (1.0 + schultzX) + / (1.0 / isenthalpicvolumeexponent * (1.0 / polytropicEfficiency + schultzX) + - schultzY * (1.0 / polytropicEfficiency - 1.0)); + double term = nV / (nV - 1.0); + double term2 = 1e5 * (getOutletPressure() / densOutIsentropic - presinn / densInn); + double term3 = isenthalpicvolumeexponent / (isenthalpicvolumeexponent - 1.0); + double CF = (enthalpyOutIsentropic - inletEnthalpy) / (term2 * term3); + dH = term * CF * 1e5 * presinn / densInn + * (Math.pow(getOutletPressure() / presinn, 1.0 / term) - 1.0) / polytropicEfficiency; + double hout = hinn + dH; + thermoOps = new ThermodynamicOperations(getThermoSystem()); + thermoOps.PHflash(hout, 0); + if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { + thermoOps.PHflashGERG2008(hout); + } } else { - return getThermoSystem().getTemperature(); - } - } - - /** - *

- * Setter for the field outTemperature. - *

- * - * @param outTemperature a double - */ - public void setOutTemperature(double outTemperature) { - useOutTemperature = true; - this.outTemperature = outTemperature; - } - - /** - *

- * useOutTemperature. - *

- * - * @param useOutTemperature a boolean - */ - public void useOutTemperature(boolean useOutTemperature) { - this.useOutTemperature = useOutTemperature; - } - - /** - *

- * Getter for the field numberOfCompressorCalcSteps. - *

- * - * @return the number of calculation steps in compressor - */ - public int getNumberOfCompressorCalcSteps() { - return numberOfCompressorCalcSteps; - } - - /** - *

- * Setter for the field numberOfCompressorCalcSteps. - *

- * - * @param numberOfCompressorCalcSteps a int - */ - public void setNumberOfCompressorCalcSteps(int numberOfCompressorCalcSteps) { - this.numberOfCompressorCalcSteps = numberOfCompressorCalcSteps; - } - - /** - *

- * isUseRigorousPolytropicMethod. - *

- * - * @return a boolean - */ - public boolean isUseRigorousPolytropicMethod() { - return useRigorousPolytropicMethod; - } - - /** - *

- * Setter for the field useRigorousPolytropicMethod. - *

- * - * @param useRigorousPolytropicMethod a boolean - */ - public void setUseRigorousPolytropicMethod(boolean useRigorousPolytropicMethod) { - this.useRigorousPolytropicMethod = useRigorousPolytropicMethod; - } - - /** - * {@inheritDoc} - */ - @Override - public void setPressure(double pressure) { - setOutletPressure(pressure); - } - - /** - *

- * Setter for the field pressure. - *

- * - * @param pressure a double - * @param unit a {@link java.lang.String} object - */ - public void setPressure(double pressure, String unit) { - setOutletPressure(pressure); - pressureUnit = unit; - } - - /** - * {@inheritDoc} - */ - @Override - public double getEntropyProduction(String unit) { - return outStream.getThermoSystem().getEntropy(unit) - - inStream.getThermoSystem().getEntropy(unit); - } - - /** - * {@inheritDoc} - */ - @Override - public double getExergyChange(String unit, double surroundingTemperature) { - return outStream.getThermoSystem().getExergy(surroundingTemperature, unit) - - inStream.getThermoSystem().getExergy(surroundingTemperature, unit); - } - - /** - *

- * Getter for the field polytropicMethod. - *

- * - * @return a {@link java.lang.String} object - */ - public String getPolytropicMethod() { - return polytropicMethod; - } - - /** - *

- * Setter for the field polytropicMethod. - *

- * - * @param polytropicMethod a {@link java.lang.String} object - */ - public void setPolytropicMethod(String polytropicMethod) { - this.polytropicMethod = polytropicMethod; - } - - /** - * Getter for property useGERG2008 - * - * @return Value - */ - public boolean isUseGERG2008() { - return useGERG2008; - } - - /** - * Setter for property useGERG2008 - * - * @param useGERG2008 Value to set - */ - public void setUseGERG2008(boolean useGERG2008) { - this.useGERG2008 = useGERG2008; - } - - public CompressorPropertyProfile getPropertyProfile() { - return propertyProfile; - } - - public void setPropertyProfile(CompressorPropertyProfile propertyProfile) { - this.propertyProfile = propertyProfile; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + Objects.hash(antiSurge, compressorChart, dH, inletEnthalpy, inStream, - isentropicEfficiency, numberOfCompressorCalcSteps, outStream, outTemperature, - polytropicEfficiency, polytropicExponent, polytropicFluidHead, polytropicHead, - polytropicHeadMeter, polytropicMethod, powerSet, pressure, pressureUnit, speed, - thermoSystem, useGERG2008, useOutTemperature, usePolytropicCalc, - useRigorousPolytropicMethod); - return result; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; + thermoSystem.setPressure(getOutletPressure(), pressureUnit); + thermoOps.PSflash(entropy); + thermoSystem.initProperties(); + double densOutIsentropic = thermoSystem.getDensity("kg/m3"); + double enthalpyOutIsentropic = thermoSystem.getEnthalpy(); + if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { + thermoOps.PSflashGERG2008(entropy); + double[] gergProps; + gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008(); + densOutIsentropic = getThermoSystem().getPhase(0).getDensity_GERG2008(); + enthalpyOutIsentropic = + gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); + } + double isenthalpicvolumeexponent = + Math.log(getOutletPressure() / presinn) / Math.log(densOutIsentropic / densInn); + double term = isenthalpicvolumeexponent / (isenthalpicvolumeexponent - 1.0) + * (polytropicEfficiency); + double term2 = 1e5 * (getOutletPressure() / densOutIsentropic - presinn / densInn); + double CF = (enthalpyOutIsentropic - inletEnthalpy) / (term * term2); + dH = term * CF * 1e5 * presinn / densInn + * (Math.pow(getOutletPressure() / presinn, 1.0 / term) - 1.0); + double hout = hinn + dH; + thermoOps = new ThermodynamicOperations(getThermoSystem()); + thermoOps.PHflash(hout, 0); + if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { + thermoOps.PHflashGERG2008(hout); + } } - if (getClass() != obj.getClass()) { - return false; + } + } else { + getThermoSystem().setPressure(pressure, pressureUnit); + // System.out.println("entropy inn.." + entropy); + thermoOps = new ThermodynamicOperations(getThermoSystem()); + thermoOps.PSflash(entropy); + if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { + thermoOps.PSflashGERG2008(entropy); + } + // double densOutIdeal = getThermoSystem().getDensity(); + double newEnt = getThermoSystem().getEnthalpy(); + if (!powerSet) { + dH = (getThermoSystem().getEnthalpy() - hinn) / isentropicEfficiency; + if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { + double[] gergProps; + gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008(); + newEnt = gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); + dH = (newEnt - hinn) / isentropicEfficiency; } - Compressor other = (Compressor) obj; - return Objects.equals(antiSurge, other.antiSurge) - && Objects.equals(compressorChart, other.compressorChart) - && Double.doubleToLongBits(dH) == Double.doubleToLongBits(other.dH) - && Double.doubleToLongBits(inletEnthalpy) == Double.doubleToLongBits(other.inletEnthalpy) - && Objects.equals(inStream, other.inStream) - && Double.doubleToLongBits(isentropicEfficiency) == Double - .doubleToLongBits(other.isentropicEfficiency) - && numberOfCompressorCalcSteps == other.numberOfCompressorCalcSteps - && Objects.equals(outStream, other.outStream) - && Double.doubleToLongBits(outTemperature) == Double.doubleToLongBits(other.outTemperature) - && Double.doubleToLongBits(polytropicEfficiency) == Double - .doubleToLongBits(other.polytropicEfficiency) - && Double.doubleToLongBits(polytropicExponent) == Double - .doubleToLongBits(other.polytropicExponent) - && Double.doubleToLongBits(polytropicFluidHead) == Double - .doubleToLongBits(other.polytropicFluidHead) - && Double.doubleToLongBits(polytropicHead) == Double.doubleToLongBits(other.polytropicHead) - && Double.doubleToLongBits(polytropicHeadMeter) == Double - .doubleToLongBits(other.polytropicHeadMeter) - && Objects.equals(polytropicMethod, other.polytropicMethod) && powerSet == other.powerSet - && Double.doubleToLongBits(pressure) == Double.doubleToLongBits(other.pressure) - && Objects.equals(pressureUnit, other.pressureUnit) && speed == other.speed - && Objects.equals(thermoSystem, other.thermoSystem) && useGERG2008 == other.useGERG2008 - && useOutTemperature == other.useOutTemperature - && usePolytropicCalc == other.usePolytropicCalc - && useRigorousPolytropicMethod == other.useRigorousPolytropicMethod; - } + } + double hout = hinn + dH; + isentropicEfficiency = (newEnt - hinn) / dH; + dH = hout - hinn; + thermoOps = new ThermodynamicOperations(getThermoSystem()); + thermoOps.PHflash(hout, 0); + if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { + thermoOps.PHflashGERG2008(hout); + } + } + // thermoSystem.display(); + + if (getCompressorChart().isUseCompressorChart() && getAntiSurge().isActive()) { + thermoSystem.setTotalNumberOfMoles(orginalMolarFLow); + thermoSystem.init(3); + } + thermoSystem.initProperties(); + outStream.setThermoSystem(getThermoSystem()); + outStream.setCalculationIdentifier(id); + + polytropicFluidHead = + getPower() / getThermoSystem().getFlowRate("kg/sec") / 1000.0 * getPolytropicEfficiency(); + polytropicHeadMeter = polytropicFluidHead * 1000.0 / 9.81; + + setCalculationIdentifier(id); + } + + /** + *

+ * generateCompressorCurves. + *

+ */ + public void generateCompressorCurves() { + double flowRef = getThermoSystem().getFlowRate("m3/hr"); + double factor = flowRef / 4000.0; + double[] chartConditions = new double[] {0.3, 1.0, 1.0, 1.0}; + double[] speed = new double[] {12913, 12298, 11683, 11098, 10453, 9224, 8609, 8200}; + double[][] flow = new double[][] { + {2789.1285, 3174.0375, 3689.2288, 4179.4503, 4570.2768, 4954.7728, 5246.0329, 5661.0331}, + {2571.1753, 2943.7254, 3440.2675, 3837.4448, 4253.0898, 4668.6643, 4997.1926, 5387.4952}, + {2415.3793, 2763.0706, 3141.7095, 3594.7436, 4047.6467, 4494.1889, 4853.7353, 5138.7858}, + {2247.2043, 2799.7342, 3178.3428, 3656.1551, 4102.778, 4394.1591, 4648.3224, 4840.4998}, + {2072.8397, 2463.9483, 2836.4078, 3202.5266, 3599.6333, 3978.0203, 4257.0022, 4517.345}, + {1835.9552, 2208.455, 2618.1322, 2940.8034, 3244.7852, 3530.1279, 3753.3738, 3895.9746}, + {1711.3386, 1965.8848, 2356.9431, 2685.9247, 3008.5154, 3337.2855, 3591.5092}, + {1636.5807, 2002.8708, 2338.0319, 2642.1245, 2896.4894, 3113.6264, 3274.8764, 3411.2977}}; + + for (int i = 0; i < flow.length; i++) { + for (int j = 0; j < flow[i].length; j++) { + flow[i][j] *= factor; + } + } + + double[][] head = + new double[][] {{80.0375, 78.8934, 76.2142, 71.8678, 67.0062, 60.6061, 53.0499, 39.728}, + {72.2122, 71.8369, 68.9009, 65.8341, 60.7167, 54.702, 47.2749, 35.7471}, + {65.1576, 64.5253, 62.6118, 59.1619, 54.0455, 47.0059, 39.195, 31.6387}, + {58.6154, 56.9627, 54.6647, 50.4462, 44.4322, 38.4144, 32.9084, 28.8109}, + {52.3295, 51.0573, 49.5283, 46.3326, 42.3685, 37.2502, 31.4884, 25.598}, + {40.6578, 39.6416, 37.6008, 34.6603, 30.9503, 27.1116, 23.2713, 20.4546}, + {35.2705, 34.6359, 32.7228, 31.0645, 27.0985, 22.7482, 18.0113}, + {32.192, 31.1756, 29.1329, 26.833, 23.8909, 21.3324, 18.7726, 16.3403},}; + + for (int i = 0; i < head.length; i++) { + for (int j = 0; j < head[i].length; j++) { + head[i][j] *= factor / 5.0; + } + } + double[][] polyEff = new double[][] { + {77.2452238409573, 79.4154186459363, 80.737960012489, 80.5229826589649, 79.2210931638144, + 75.4719133864634, 69.6034181197298, 58.7322388482707}, + {77.0107837113504, 79.3069974136389, 80.8941189021135, 80.7190194665918, 79.5313242980328, + 75.5912622896367, 69.6846136362097, 60.0043057990909}, + {77.0043065299874, 79.1690958847856, 80.8038169975675, 80.6543975614197, 78.8532389102705, + 73.6664774270613, 66.2735600426727, 57.671664571658}, + {77.0716623789093, 80.4629750233093, 81.1390811169072, 79.6374242667478, 75.380928428817, + 69.5332969549779, 63.7997587622339, 58.8120614497758}, + {76.9705872525642, 79.8335492585324, 80.9468133671171, 80.5806471927835, 78.0462158225426, + 73.0403707523258, 66.5572286338589, 59.8624822515064}, + {77.5063036680357, 80.2056198362559, 81.0339108025933, 79.6085962687939, 76.3814534404405, + 70.8027503005902, 64.6437367160571, 60.5299349982342}, + {77.8175271586685, 80.065165942218, 81.0631362122632, 79.8955051771299, 76.1983240929369, + 69.289982774309, 60.8567149372229}, + {78.0924334304045, 80.9353551568667, 80.7904437766234, 78.8639325223295, 75.2170936751143, + 70.3105081673411, 65.5507568533569, 61.0391468300337}}; + + getCompressorChart().setCurves(chartConditions, speed, flow, head, polyEff); + getCompressorChart().setHeadUnit("kJ/kg"); + } + + /** + * {@inheritDoc} + */ + @Override + public void displayResult() { + DecimalFormat nf = new DecimalFormat(); + nf.setMaximumFractionDigits(5); + nf.applyPattern("#.#####E0"); + + JDialog dialog = new JDialog(new JFrame(), "Results from TPflash"); + Container dialogContentPane = dialog.getContentPane(); + dialogContentPane.setLayout(new FlowLayout()); + + getThermoSystem().initPhysicalProperties(); + String[][] table = new String[50][5]; + String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"}; + table[0][0] = ""; + table[0][1] = ""; + table[0][2] = ""; + table[0][3] = ""; + StringBuffer buf = new StringBuffer(); + FieldPosition test = new FieldPosition(0); + + for (int i = 0; i < getThermoSystem().getNumberOfPhases(); i++) { + for (int j = 0; j < getThermoSystem().getPhases()[0].getNumberOfComponents(); j++) { + table[j + 1][0] = getThermoSystem().getPhases()[0].getComponents()[j].getName(); + buf = new StringBuffer(); + table[j + 1][i + 1] = + nf.format(getThermoSystem().getPhases()[i].getComponents()[j].getx(), buf, test) + .toString(); + table[j + 1][4] = "[-]"; + } + buf = new StringBuffer(); + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 2][0] = "Density"; + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 2][i + 1] = nf + .format(getThermoSystem().getPhases()[i].getPhysicalProperties().getDensity(), buf, test) + .toString(); + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 2][4] = "[kg/m^3]"; + + // Double.longValue(thermoSystem.getPhases()[i].getBeta()); + buf = new StringBuffer(); + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 3][0] = "PhaseFraction"; + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 3][i + 1] = + nf.format(getThermoSystem().getPhases()[i].getBeta(), buf, test).toString(); + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 3][4] = "[-]"; + + buf = new StringBuffer(); + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 4][0] = "MolarMass"; + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 4][i + 1] = + nf.format(getThermoSystem().getPhases()[i].getMolarMass() * 1000, buf, test).toString(); + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 4][4] = "[kg/kmol]"; + + buf = new StringBuffer(); + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 5][0] = "Cp"; + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 5][i + 1] = + nf.format((getThermoSystem().getPhases()[i].getCp() + / getThermoSystem().getPhases()[i].getNumberOfMolesInPhase() * 1.0 + / getThermoSystem().getPhases()[i].getMolarMass() * 1000), buf, test).toString(); + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 5][4] = "[kJ/kg*K]"; + + buf = new StringBuffer(); + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 7][0] = "Viscosity"; + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 7][i + 1] = + nf.format((getThermoSystem().getPhases()[i].getPhysicalProperties().getViscosity()), buf, + test).toString(); + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 7][4] = "[kg/m*sec]"; + + buf = new StringBuffer(); + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 8][0] = "Conductivity"; + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 8][i + 1] = + nf.format(getThermoSystem().getPhases()[i].getPhysicalProperties().getConductivity(), buf, + test).toString(); + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 8][4] = "[W/m*K]"; + + buf = new StringBuffer(); + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 10][0] = "Pressure"; + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 10][i + 1] = + Double.toString(getThermoSystem().getPhases()[i].getPressure()); + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 10][4] = "[bar]"; + + buf = new StringBuffer(); + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 11][0] = "Temperature"; + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 11][i + 1] = + Double.toString(getThermoSystem().getPhases()[i].getTemperature()); + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 11][4] = "[K]"; + Double.toString(getThermoSystem().getPhases()[i].getTemperature()); + + buf = new StringBuffer(); + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 13][0] = "Stream"; + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 13][i + 1] = name; + table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 13][4] = "-"; + } + + JTable Jtab = new JTable(table, names); + JScrollPane scrollpane = new JScrollPane(Jtab); + dialogContentPane.add(scrollpane); + dialog.pack(); + dialog.setVisible(true); + } + + /** + * {@inheritDoc} + */ + @Override + public String[][] getResultTable() { + return thermoSystem.getResultTable(); + } + + /** + *

+ * getTotalWork. + *

+ * + * @return a double + */ + public double getTotalWork() { + double multi = 1.0; + if (getAntiSurge().isActive()) { + multi = 1.0 + getAntiSurge().getCurrentSurgeFraction(); + } + if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) { + double[] gergProps; + gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008(); + double enth = gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); + return (enth - inletEnthalpy) * multi; + } else { + return multi * (getThermoSystem().getEnthalpy() - inletEnthalpy); + } + } + + /** + * {@inheritDoc} + */ + @Override + public double getIsentropicEfficiency() { + return isentropicEfficiency; + } + + /** + * {@inheritDoc} + */ + @Override + public void setIsentropicEfficiency(double isentropicEfficiency) { + this.isentropicEfficiency = isentropicEfficiency; + } + + /** + *

+ * usePolytropicCalc. + *

+ * + * @return the usePolytropicCalc + */ + public boolean usePolytropicCalc() { + return usePolytropicCalc; + } + + /** + *

+ * Setter for the field usePolytropicCalc. + *

+ * + * @param usePolytropicCalc the usePolytropicCalc to set + */ + public void setUsePolytropicCalc(boolean usePolytropicCalc) { + this.usePolytropicCalc = usePolytropicCalc; + } + + /** + * {@inheritDoc} + */ + @Override + public double getPolytropicEfficiency() { + return polytropicEfficiency; + } + + /** + * {@inheritDoc} + */ + @Override + public void setPolytropicEfficiency(double polytropicEfficiency) { + this.polytropicEfficiency = polytropicEfficiency; + } + + /** + * {@inheritDoc} + */ + @Override + public SystemInterface getThermoSystem() { + return thermoSystem; + } + + /** + *

+ * Getter for the field compressorChart. + *

+ * + * @return a {@link neqsim.processSimulation.processEquipment.compressor.CompressorChartInterface} + * object + */ + public CompressorChartInterface getCompressorChart() { + return compressorChart; + } + + /** + *

+ * Setter for the field compressorChart. + *

+ * + * @param compressorChart a + * {@link neqsim.processSimulation.processEquipment.compressor.CompressorChart} object + */ + public void setCompressorChart(CompressorChart compressorChart) { + this.compressorChart = compressorChart; + } + + /** + * {@inheritDoc} + */ + @Override + public AntiSurge getAntiSurge() { + return antiSurge; + } + + /** + *

+ * isSurge. + *

+ * + * @param flow a double + * @param head a double + * @return a boolean + */ + public boolean isSurge(double flow, double head) { + getAntiSurge().setSurge(getCompressorChart().getSurgeCurve().isSurge(flow, head)); + return getAntiSurge().isSurge(); + } + + /** + *

+ * isStoneWall. + *

+ * + * @param flow a double + * @param head a double + * @return a boolean + */ + public boolean isStoneWall(double flow, double head) { + return getCompressorChart().getStoneWallCurve().isStoneWall(flow, head); + } + + /** + *

+ * Setter for the field antiSurge. + *

+ * + * @param antiSurge a {@link neqsim.processSimulation.processEquipment.compressor.AntiSurge} + * object + */ + public void setAntiSurge(AntiSurge antiSurge) { + this.antiSurge = antiSurge; + } + + /** + *

+ * Getter for the field speed. + *

+ * + * @return a int + */ + public int getSpeed() { + return speed; + } + + /** + *

+ * Setter for the field speed. + *

+ * + * @param speed a int + */ + public void setSpeed(int speed) { + this.speed = speed; + } + + /** + *

+ * Getter for the field polytropicHead. + *

+ * + * @param unit a {@link java.lang.String} object + * @return a double + */ + public double getPolytropicHead(String unit) { + if (unit.equals("kJ/kg")) { + return polytropicFluidHead; + } else if (unit.equals("meter")) { + return polytropicHeadMeter; + } else { + return polytropicHead; + } + } + + /** + *

+ * Getter for the field polytropicHead. + *

+ * + * @return a double + */ + public double getPolytropicHead() { + return polytropicHead; + } + + /** + *

+ * Getter for the field polytropicFluidHead. + *

+ * + * @return a double + */ + public double getPolytropicFluidHead() { + return polytropicFluidHead; + } + + /** + *

+ * Getter for the field polytropicExponent. + *

+ * + * @return a double + */ + public double getPolytropicExponent() { + return polytropicExponent; + } + + /** + *

+ * Getter for the field polytropicHeadMeter. + *

+ * + * @return a double + */ + public double getPolytropicHeadMeter() { + return polytropicHeadMeter; + } + + /** + *

+ * Setter for the field polytropicHeadMeter. + *

+ * + * @param polytropicHeadMeter a double + */ + public void setPolytropicHeadMeter(double polytropicHeadMeter) { + this.polytropicHeadMeter = polytropicHeadMeter; + } + + /** + *

+ * Getter for the field outTemperature. + *

+ * + * @return a double + */ + public double getOutTemperature() { + if (useOutTemperature) { + return outTemperature; + } else { + return getThermoSystem().getTemperature(); + } + } + + /** + *

+ * Setter for the field outTemperature. + *

+ * + * @param outTemperature a double + */ + public void setOutTemperature(double outTemperature) { + useOutTemperature = true; + this.outTemperature = outTemperature; + } + + /** + *

+ * useOutTemperature. + *

+ * + * @param useOutTemperature a boolean + */ + public void useOutTemperature(boolean useOutTemperature) { + this.useOutTemperature = useOutTemperature; + } + + /** + *

+ * Getter for the field numberOfCompressorCalcSteps. + *

+ * + * @return the number of calculation steps in compressor + */ + public int getNumberOfCompressorCalcSteps() { + return numberOfCompressorCalcSteps; + } + + /** + *

+ * Setter for the field numberOfCompressorCalcSteps. + *

+ * + * @param numberOfCompressorCalcSteps a int + */ + public void setNumberOfCompressorCalcSteps(int numberOfCompressorCalcSteps) { + this.numberOfCompressorCalcSteps = numberOfCompressorCalcSteps; + } + + /** + *

+ * isUseRigorousPolytropicMethod. + *

+ * + * @return a boolean + */ + public boolean isUseRigorousPolytropicMethod() { + return useRigorousPolytropicMethod; + } + + /** + *

+ * Setter for the field useRigorousPolytropicMethod. + *

+ * + * @param useRigorousPolytropicMethod a boolean + */ + public void setUseRigorousPolytropicMethod(boolean useRigorousPolytropicMethod) { + this.useRigorousPolytropicMethod = useRigorousPolytropicMethod; + } + + /** + * {@inheritDoc} + */ + @Override + public void setPressure(double pressure) { + setOutletPressure(pressure); + } + + /** + *

+ * Setter for the field pressure. + *

+ * + * @param pressure a double + * @param unit a {@link java.lang.String} object + */ + public void setPressure(double pressure, String unit) { + setOutletPressure(pressure); + pressureUnit = unit; + } + + /** + * {@inheritDoc} + */ + @Override + public double getEntropyProduction(String unit) { + return outStream.getThermoSystem().getEntropy(unit) + - inStream.getThermoSystem().getEntropy(unit); + } + + /** + * {@inheritDoc} + */ + @Override + public double getExergyChange(String unit, double surroundingTemperature) { + return outStream.getThermoSystem().getExergy(surroundingTemperature, unit) + - inStream.getThermoSystem().getExergy(surroundingTemperature, unit); + } + + /** + *

+ * Getter for the field polytropicMethod. + *

+ * + * @return a {@link java.lang.String} object + */ + public String getPolytropicMethod() { + return polytropicMethod; + } + + /** + *

+ * Setter for the field polytropicMethod. + *

+ * + * @param polytropicMethod a {@link java.lang.String} object + */ + public void setPolytropicMethod(String polytropicMethod) { + this.polytropicMethod = polytropicMethod; + } + + /** + * Getter for property useGERG2008 + * + * @return Value + */ + public boolean isUseGERG2008() { + return useGERG2008; + } + + /** + * Setter for property useGERG2008 + * + * @param useGERG2008 Value to set + */ + public void setUseGERG2008(boolean useGERG2008) { + this.useGERG2008 = useGERG2008; + } + + public CompressorPropertyProfile getPropertyProfile() { + return propertyProfile; + } + + public void setPropertyProfile(CompressorPropertyProfile propertyProfile) { + this.propertyProfile = propertyProfile; + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + Objects.hash(antiSurge, compressorChart, dH, inletEnthalpy, inStream, + isentropicEfficiency, numberOfCompressorCalcSteps, outStream, outTemperature, + polytropicEfficiency, polytropicExponent, polytropicFluidHead, polytropicHead, + polytropicHeadMeter, polytropicMethod, powerSet, pressure, pressureUnit, speed, + thermoSystem, useGERG2008, useOutTemperature, usePolytropicCalc, + useRigorousPolytropicMethod); + return result; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Compressor other = (Compressor) obj; + return Objects.equals(antiSurge, other.antiSurge) + && Objects.equals(compressorChart, other.compressorChart) + && Double.doubleToLongBits(dH) == Double.doubleToLongBits(other.dH) + && Double.doubleToLongBits(inletEnthalpy) == Double.doubleToLongBits(other.inletEnthalpy) + && Objects.equals(inStream, other.inStream) + && Double.doubleToLongBits(isentropicEfficiency) == Double + .doubleToLongBits(other.isentropicEfficiency) + && numberOfCompressorCalcSteps == other.numberOfCompressorCalcSteps + && Objects.equals(outStream, other.outStream) + && Double.doubleToLongBits(outTemperature) == Double.doubleToLongBits(other.outTemperature) + && Double.doubleToLongBits(polytropicEfficiency) == Double + .doubleToLongBits(other.polytropicEfficiency) + && Double.doubleToLongBits(polytropicExponent) == Double + .doubleToLongBits(other.polytropicExponent) + && Double.doubleToLongBits(polytropicFluidHead) == Double + .doubleToLongBits(other.polytropicFluidHead) + && Double.doubleToLongBits(polytropicHead) == Double.doubleToLongBits(other.polytropicHead) + && Double.doubleToLongBits(polytropicHeadMeter) == Double + .doubleToLongBits(other.polytropicHeadMeter) + && Objects.equals(polytropicMethod, other.polytropicMethod) && powerSet == other.powerSet + && Double.doubleToLongBits(pressure) == Double.doubleToLongBits(other.pressure) + && Objects.equals(pressureUnit, other.pressureUnit) && speed == other.speed + && Objects.equals(thermoSystem, other.thermoSystem) && useGERG2008 == other.useGERG2008 + && useOutTemperature == other.useOutTemperature + && usePolytropicCalc == other.usePolytropicCalc + && useRigorousPolytropicMethod == other.useRigorousPolytropicMethod; + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorPropertyProfile.java b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorPropertyProfile.java index 3f405b9289..e28f50b1f9 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorPropertyProfile.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorPropertyProfile.java @@ -10,6 +10,7 @@ */ public class CompressorPropertyProfile implements Serializable { private static final long serialVersionUID = 1L; + private ArrayList fluid = new ArrayList(); private boolean isActive = false; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/distillation/Condenser.java b/src/main/java/neqsim/processSimulation/processEquipment/distillation/Condenser.java index df3f1c5b19..d966e83e98 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/distillation/Condenser.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/distillation/Condenser.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.distillation; +import java.util.UUID; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -12,73 +13,77 @@ * @version $Id: $Id */ public class Condenser extends SimpleTray { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - private double refluxRatio = 0.1; - boolean refluxIsSet = false; - double duty = 0.0; + private double refluxRatio = 0.1; + boolean refluxIsSet = false; + double duty = 0.0; - /** {@inheritDoc} */ - public Condenser(String name) { - super(name); - } + /** {@inheritDoc} */ + public Condenser(String name) { + super(name); + } - /** - *

- * Getter for the field refluxRatio. - *

- * - * @return the refluxRatio - */ - public double getRefluxRatio() { - return refluxRatio; - } + /** + *

+ * Getter for the field refluxRatio. + *

+ * + * @return the refluxRatio + */ + public double getRefluxRatio() { + return refluxRatio; + } - /** - *

- * Setter for the field refluxRatio. - *

- * - * @param refluxRatio the refluxRatio to set - */ - public void setRefluxRatio(double refluxRatio) { - this.refluxRatio = refluxRatio; - refluxIsSet = true; - } + /** + *

+ * Setter for the field refluxRatio. + *

+ * + * @param refluxRatio the refluxRatio to set + */ + public void setRefluxRatio(double refluxRatio) { + this.refluxRatio = refluxRatio; + refluxIsSet = true; + } - /** - *

- * Getter for the field duty. - *

- * - * @return a double - */ - public double getDuty() { - // return calcMixStreamEnthalpy(); - return duty; - } + /** + *

+ * Getter for the field duty. + *

+ * + * @return a double + */ + public double getDuty() { + // return calcMixStreamEnthalpy(); + return duty; + } - /** {@inheritDoc} */ - @Override - public void run() { - // System.out.println("guess temperature " + getTemperature()); - if (!refluxIsSet) { - super.run(); - } else { - SystemInterface thermoSystem2 = streams.get(0).getThermoSystem().clone(); - // System.out.println("total number of moles " + - // thermoSystem2.getTotalNumberOfMoles()); - mixedStream.setThermoSystem(thermoSystem2); - ThermodynamicOperations testOps = new ThermodynamicOperations(thermoSystem2); - testOps.PVrefluxFlash(refluxRatio, 0); - } - // System.out.println("enthalpy: " + - // mixedStream.getThermoSystem().getEnthalpy()); - // System.out.println("enthalpy: " + enthalpy); - // System.out.println("temperature: " + - // mixedStream.getThermoSystem().getTemperature()); - duty = mixedStream.getFluid().getEnthalpy() - calcMixStreamEnthalpy0(); - energyStream.setDuty(duty); - // System.out.println("beta " + mixedStream.getThermoSystem().getBeta()) + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + // System.out.println("guess temperature " + getTemperature()); + if (!refluxIsSet) { + UUID oldID = getCalculationIdentifier(); + super.run(id); + setCalculationIdentifier(oldID); + } else { + SystemInterface thermoSystem2 = streams.get(0).getThermoSystem().clone(); + // System.out.println("total number of moles " + + // thermoSystem2.getTotalNumberOfMoles()); + mixedStream.setThermoSystem(thermoSystem2); + ThermodynamicOperations testOps = new ThermodynamicOperations(thermoSystem2); + testOps.PVrefluxFlash(refluxRatio, 0); } + // System.out.println("enthalpy: " + + // mixedStream.getThermoSystem().getEnthalpy()); + // System.out.println("enthalpy: " + enthalpy); + // System.out.println("temperature: " + + // mixedStream.getThermoSystem().getTemperature()); + duty = mixedStream.getFluid().getEnthalpy() - calcMixStreamEnthalpy0(); + energyStream.setDuty(duty); + // System.out.println("beta " + mixedStream.getThermoSystem().getBeta()) + + setCalculationIdentifier(id); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/distillation/DistillationColumn.java b/src/main/java/neqsim/processSimulation/processEquipment/distillation/DistillationColumn.java index 561e074f52..82bee10b29 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/distillation/DistillationColumn.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/distillation/DistillationColumn.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.Objects; +import java.util.UUID; import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; import neqsim.processSimulation.processEquipment.heatExchanger.Heater; import neqsim.processSimulation.processEquipment.mixer.Mixer; @@ -20,672 +21,685 @@ * @version $Id: $Id */ public class DistillationColumn extends ProcessEquipmentBaseClass implements DistillationInterface { - private static final long serialVersionUID = 1000; - private boolean doInitializion = true; - boolean hasReboiler = false, hasCondenser = false; - protected ArrayList trays = new ArrayList(0); - double condenserCoolingDuty = 10.0; - private double reboilerTemperature = 273.15; - private double condenserTemperature = 270.15; - double topTrayPressure = -1.0, bottomTrayPressure = -1.0; - int numberOfTrays = 1; - private int feedTrayNumber = 1; - StreamInterface stream_3 = new Stream("stream_3"), gasOutStream = new Stream("gasOutStream"), - liquidOutStream = new Stream("liquidOutStream"), feedStream = null; - boolean stream_3isset = false; - private double internalDiameter = 1.0; - neqsim.processSimulation.processSystem.ProcessSystem distoperations; - Heater heater; - Separator separator2; - - - /** - *

- * Constructor for DistillationColumn. - *

- * - * @param numberOfTraysLocal a int - * @param hasReboiler a boolean - * @param hasCondenser a boolean - */ - public DistillationColumn(int numberOfTraysLocal, boolean hasReboiler, boolean hasCondenser) { - super("DistillationColumn"); - this.hasReboiler = hasReboiler; - this.hasCondenser = hasCondenser; - distoperations = new neqsim.processSimulation.processSystem.ProcessSystem(); - this.numberOfTrays = numberOfTraysLocal; - if (hasReboiler) { - trays.add(new Reboiler("Reboiler")); - this.numberOfTrays++; - } - for (int i = 0; i < numberOfTraysLocal; i++) { - trays.add(new SimpleTray("SimpleTray" + i + 1)); - } - if (hasCondenser) { - trays.add(new Condenser("Condenser")); - this.numberOfTrays++; - } - for (int i = 0; i < this.numberOfTrays; i++) { - distoperations.add(trays.get(i)); - } + private static final long serialVersionUID = 1000; + private boolean doInitializion = true; + boolean hasReboiler = false; + boolean hasCondenser = false; + protected ArrayList trays = new ArrayList(0); + double condenserCoolingDuty = 10.0; + private double reboilerTemperature = 273.15; + private double condenserTemperature = 270.15; + double topTrayPressure = -1.0; + double bottomTrayPressure = -1.0; + int numberOfTrays = 1; + private int feedTrayNumber = 1; + StreamInterface stream_3 = new Stream("stream_3"); + StreamInterface gasOutStream = new Stream("gasOutStream"); + StreamInterface liquidOutStream = new Stream("liquidOutStream"); + StreamInterface feedStream = null; + boolean stream_3isset = false; + private double internalDiameter = 1.0; + neqsim.processSimulation.processSystem.ProcessSystem distoperations; + Heater heater; + Separator separator2; + + /** + *

+ * Constructor for DistillationColumn. + *

+ * + * @param numberOfTraysLocal a int + * @param hasReboiler a boolean + * @param hasCondenser a boolean + */ + public DistillationColumn(int numberOfTraysLocal, boolean hasReboiler, boolean hasCondenser) { + super("DistillationColumn"); + this.hasReboiler = hasReboiler; + this.hasCondenser = hasCondenser; + distoperations = new neqsim.processSimulation.processSystem.ProcessSystem(); + this.numberOfTrays = numberOfTraysLocal; + if (hasReboiler) { + trays.add(new Reboiler("Reboiler")); + this.numberOfTrays++; } - - /** - *

- * addFeedStream. - *

- * - * @param inputStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - * @param feedTrayNumber a int - */ - public void addFeedStream(StreamInterface inputStream, int feedTrayNumber) { - feedStream = inputStream; - getTray(feedTrayNumber).addStream(inputStream); - setFeedTrayNumber(feedTrayNumber); - double moles = inputStream.getThermoSystem().getTotalNumberOfMoles(); - gasOutStream.setThermoSystem(inputStream.getThermoSystem().clone()); - gasOutStream.getThermoSystem().setTotalNumberOfMoles(moles / 2.0); - liquidOutStream.setThermoSystem(inputStream.getThermoSystem().clone()); - liquidOutStream.getThermoSystem().setTotalNumberOfMoles(moles / 2.0); + for (int i = 0; i < numberOfTraysLocal; i++) { + trays.add(new SimpleTray("SimpleTray" + i + 1)); } - - /** - *

- * init. - *

- */ - public void init() { - if (!isDoInitializion()) { - return; - } - setDoInitializion(false); - ((Runnable) trays.get(feedTrayNumber)).run(); - - if (getTray(feedTrayNumber).getStream(0).getFluid().getNumberOfPhases() == 1) { - for (int i = 0; i < numberOfTrays; i++) { - if (getTray(i).getNumberOfInputStreams() > 0 && i != feedTrayNumber) { - getTray(feedTrayNumber).addStream(trays.get(i).getStream(0)); - getTray(feedTrayNumber).run(); - getTray(feedTrayNumber).removeInputStream(getTray(feedTrayNumber).getNumberOfInputStreams()-1); - if (getTray(feedTrayNumber).getThermoSystem().getNumberOfPhases() > 1) - break; - } - else if(i == feedTrayNumber && getTray(i).getNumberOfInputStreams() > 1) { - getTray(feedTrayNumber).addStream(trays.get(i).getStream(1)); - ((Runnable) trays.get(feedTrayNumber)).run(); - getTray(feedTrayNumber).removeInputStream(getTray(feedTrayNumber).getNumberOfInputStreams()-1); - if (getTray(feedTrayNumber).getThermoSystem().getNumberOfPhases() > 1) - break; - } - } - } - ((MixerInterface) trays.get(numberOfTrays - 1)) - .addStream(trays.get(feedTrayNumber).getGasOutStream()); - ((Mixer) trays.get(numberOfTrays - 1)).getStream(0).getThermoSystem() - .setTotalNumberOfMoles(((Mixer) trays.get(numberOfTrays - 1)).getStream(0) - .getThermoSystem().getTotalNumberOfMoles() * (1.0e-6)); - ((MixerInterface) trays.get(0)).addStream(trays.get(feedTrayNumber).getLiquidOutStream()); - int streamNumbReboil = (trays.get(0)).getNumberOfInputStreams() - 1; - ((Mixer) trays.get(0)).getStream(streamNumbReboil).getThermoSystem() - .setTotalNumberOfMoles(((Mixer) trays.get(0)).getStream(streamNumbReboil) - .getThermoSystem().getTotalNumberOfMoles() * (1.0e-6)); - - // ((Runnable) trays.get(numberOfTrays - 1)).run(); - ((Runnable) trays.get(0)).run(); - - condenserTemperature = - ((MixerInterface) trays.get(numberOfTrays - 1)).getThermoSystem().getTemperature(); - reboilerTemperature = ((MixerInterface) trays.get(0)).getThermoSystem().getTemperature(); - - // double deltaTemp = (reboilerTemperature - condenserTemperature) / (numberOfTrays * 1.0); - double feedTrayTemperature = - getTray(getFeedTrayNumber()).getThermoSystem().getTemperature(); - - double deltaTempCondenser = (feedTrayTemperature - condenserTemperature) - / (numberOfTrays * 1.0 - feedTrayNumber - 1); - double deltaTempReboiler = - (reboilerTemperature - feedTrayTemperature) / (feedTrayNumber * 1.0); - - double delta = 0; - for (int i = feedTrayNumber + 1; i < numberOfTrays; i++) { - delta += deltaTempCondenser; - ((Mixer) trays.get(i)).setTemperature( - getTray(getFeedTrayNumber()).getThermoSystem().getTemperature() - delta); - } - delta = 0; - for (int i = feedTrayNumber - 1; i >= 0; i--) { - delta += deltaTempReboiler; - ((Mixer) trays.get(i)).setTemperature( - getTray(getFeedTrayNumber()).getThermoSystem().getTemperature() + delta); - } - - for (int i = 1; i < numberOfTrays - 1; i++) { - ((MixerInterface) trays.get(i)).addStream(trays.get(i - 1).getGasOutStream()); - trays.get(i).init(); - ((Runnable) trays.get(i)).run(); - } - - ((MixerInterface) trays.get(numberOfTrays - 1)).replaceStream(0, - trays.get(numberOfTrays - 2).getGasOutStream()); - trays.get(numberOfTrays - 1).init(); - ((Runnable) trays.get(numberOfTrays - 1)).run(); - - for (int i = numberOfTrays - 2; i >= 1; i--) { - ((MixerInterface) trays.get(i)).addStream(trays.get(i + 1).getLiquidOutStream()); - trays.get(i).init(); - ((Runnable) trays.get(i)).run(); - } - int streamNumb = (trays.get(0)).getNumberOfInputStreams() - 1; - ((MixerInterface) trays.get(0)).replaceStream(streamNumb, - trays.get(1).getLiquidOutStream()); - trays.get(0).init(); - ((Runnable) trays.get(0)).run(); + if (hasCondenser) { + trays.add(new Condenser("Condenser")); + this.numberOfTrays++; } - - /** - *

- * Getter for the field gasOutStream. - *

- * - * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ - public StreamInterface getGasOutStream() { - return gasOutStream; + for (int i = 0; i < this.numberOfTrays; i++) { + distoperations.add(trays.get(i)); } - - /** - *

- * Getter for the field liquidOutStream. - *

- * - * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ - public StreamInterface getLiquidOutStream() { - return liquidOutStream; + } + + /** + *

+ * addFeedStream. + *

+ * + * @param inputStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + * @param feedTrayNumber a int + */ + public void addFeedStream(StreamInterface inputStream, int feedTrayNumber) { + feedStream = inputStream; + getTray(feedTrayNumber).addStream(inputStream); + setFeedTrayNumber(feedTrayNumber); + double moles = inputStream.getThermoSystem().getTotalNumberOfMoles(); + gasOutStream.setThermoSystem(inputStream.getThermoSystem().clone()); + gasOutStream.getThermoSystem().setTotalNumberOfMoles(moles / 2.0); + liquidOutStream.setThermoSystem(inputStream.getThermoSystem().clone()); + liquidOutStream.getThermoSystem().setTotalNumberOfMoles(moles / 2.0); + } + + /** + *

+ * init. + *

+ */ + public void init() { + if (!isDoInitializion()) { + return; } - - /** - *

- * getTray. - *

- * - * @param trayNumber a int - * @return a {@link neqsim.processSimulation.processEquipment.distillation.SimpleTray} object - */ - public SimpleTray getTray(int trayNumber) { - return trays.get(trayNumber); - } - - /** {@inheritDoc} */ - @Override - public void setNumberOfTrays(int number) { - int oldNumberOfTrays = numberOfTrays; - - int tempNumberOfTrays = number; - - if (hasReboiler) { - tempNumberOfTrays++; - } - if (hasCondenser) { - tempNumberOfTrays++; + setDoInitializion(false); + ((Runnable) trays.get(feedTrayNumber)).run(); + + if (getTray(feedTrayNumber).getStream(0).getFluid().getNumberOfPhases() == 1) { + for (int i = 0; i < numberOfTrays; i++) { + if (getTray(i).getNumberOfInputStreams() > 0 && i != feedTrayNumber) { + getTray(feedTrayNumber).addStream(trays.get(i).getStream(0)); + getTray(feedTrayNumber).run(); + getTray(feedTrayNumber) + .removeInputStream(getTray(feedTrayNumber).getNumberOfInputStreams() - 1); + if (getTray(feedTrayNumber).getThermoSystem().getNumberOfPhases() > 1) { + break; + } + } else if (i == feedTrayNumber && getTray(i).getNumberOfInputStreams() > 1) { + getTray(feedTrayNumber).addStream(trays.get(i).getStream(1)); + ((Runnable) trays.get(feedTrayNumber)).run(); + getTray(feedTrayNumber) + .removeInputStream(getTray(feedTrayNumber).getNumberOfInputStreams() - 1); + if (getTray(feedTrayNumber).getThermoSystem().getNumberOfPhases() > 1) { + break; + } } - - int change = tempNumberOfTrays - oldNumberOfTrays; - - if (change > 0) { - for (int i = 0; i < change; i++) { - trays.add(1, new SimpleTray("SimpleTray" + oldNumberOfTrays + i + 1)); - } - } else if (change < 0) { - for (int i = 0; i > change; i--) { - trays.remove(1); - } - } - numberOfTrays = tempNumberOfTrays; - - setDoInitializion(true); - init(); + } } - - /** - *

- * setTopCondenserDuty. - *

- * - * @param duty a double - */ - public void setTopCondenserDuty(double duty) { - condenserCoolingDuty = duty; + ((MixerInterface) trays.get(numberOfTrays - 1)) + .addStream(trays.get(feedTrayNumber).getGasOutStream()); + ((Mixer) trays.get(numberOfTrays - 1)).getStream(0).getThermoSystem() + .setTotalNumberOfMoles(((Mixer) trays.get(numberOfTrays - 1)).getStream(0).getThermoSystem() + .getTotalNumberOfMoles() * (1.0e-6)); + ((MixerInterface) trays.get(0)).addStream(trays.get(feedTrayNumber).getLiquidOutStream()); + int streamNumbReboil = (trays.get(0)).getNumberOfInputStreams() - 1; + ((Mixer) trays.get(0)).getStream(streamNumbReboil).getThermoSystem().setTotalNumberOfMoles( + ((Mixer) trays.get(0)).getStream(streamNumbReboil).getThermoSystem().getTotalNumberOfMoles() + * (1.0e-6)); + + // ((Runnable) trays.get(numberOfTrays - 1)).run(); + ((Runnable) trays.get(0)).run(); + + condenserTemperature = + ((MixerInterface) trays.get(numberOfTrays - 1)).getThermoSystem().getTemperature(); + reboilerTemperature = ((MixerInterface) trays.get(0)).getThermoSystem().getTemperature(); + + // double deltaTemp = (reboilerTemperature - condenserTemperature) / (numberOfTrays * 1.0); + double feedTrayTemperature = getTray(getFeedTrayNumber()).getThermoSystem().getTemperature(); + + double deltaTempCondenser = + (feedTrayTemperature - condenserTemperature) / (numberOfTrays * 1.0 - feedTrayNumber - 1); + double deltaTempReboiler = (reboilerTemperature - feedTrayTemperature) / (feedTrayNumber * 1.0); + + double delta = 0; + for (int i = feedTrayNumber + 1; i < numberOfTrays; i++) { + delta += deltaTempCondenser; + ((Mixer) trays.get(i)) + .setTemperature(getTray(getFeedTrayNumber()).getThermoSystem().getTemperature() - delta); } - - /** - *

- * setTopPressure. - *

- * - * @param topPressure a double - */ - public void setTopPressure(double topPressure) { - topTrayPressure = topPressure; + delta = 0; + for (int i = feedTrayNumber - 1; i >= 0; i--) { + delta += deltaTempReboiler; + ((Mixer) trays.get(i)) + .setTemperature(getTray(getFeedTrayNumber()).getThermoSystem().getTemperature() + delta); } - /** - *

- * setBottomPressure. - *

- * - * @param bottomPressure a double - */ - public void setBottomPressure(double bottomPressure) { - bottomTrayPressure = bottomPressure; + for (int i = 1; i < numberOfTrays - 1; i++) { + ((MixerInterface) trays.get(i)).addStream(trays.get(i - 1).getGasOutStream()); + trays.get(i).init(); + ((Runnable) trays.get(i)).run(); } - /** {@inheritDoc} */ - @Override - public void run() { - double dp = 0.0; - if (bottomTrayPressure < 0) { - bottomTrayPressure = getTray(feedTrayNumber).getStream(0).getPressure(); - } - if (topTrayPressure < 0) { - topTrayPressure = getTray(feedTrayNumber).getStream(0).getPressure(); - } - if (numberOfTrays > 1) { - dp = (bottomTrayPressure - topTrayPressure) / (numberOfTrays - 1.0); - } - for (int i = 0; i < numberOfTrays; i++) { - trays.get(i).setPressure(bottomTrayPressure - i * dp); - } - getTray(feedTrayNumber).getStream(0).setThermoSystem(feedStream.getThermoSystem().clone()); - - if (numberOfTrays == 1) { - ((Runnable) trays.get(0)).run(); - gasOutStream.setThermoSystem(trays.get(0).getGasOutStream().getThermoSystem().clone()); - liquidOutStream - .setThermoSystem(trays.get(0).getLiquidOutStream().getThermoSystem().clone()); - return; - } + ((MixerInterface) trays.get(numberOfTrays - 1)).replaceStream(0, + trays.get(numberOfTrays - 2).getGasOutStream()); + trays.get(numberOfTrays - 1).init(); + ((Runnable) trays.get(numberOfTrays - 1)).run(); - if (isDoInitializion()) { - this.init(); - } - double err = 1.0e10, errOld; - int iter = 0; - double[] oldtemps = new double[numberOfTrays]; - ((Runnable) trays.get(feedTrayNumber)).run(); - - do { - iter++; - errOld = err; - err = 0.0; - for (int i = 0; i < numberOfTrays; i++) { - oldtemps[i] = ((MixerInterface) trays.get(i)).getThermoSystem().getTemperature(); - } - - for (int i = feedTrayNumber; i > 1; i--) { - ((Mixer) trays.get(i - 1)).replaceStream(1, trays.get(i).getLiquidOutStream()); - trays.get(i - 1).setPressure(bottomTrayPressure - (i - 1) * dp); - ((Runnable) trays.get(i - 1)).run(); - } - int streamNumb = (trays.get(0)).getNumberOfInputStreams() - 1; - ((Mixer) trays.get(0)).replaceStream(streamNumb, trays.get(1).getLiquidOutStream()); - ((Runnable) trays.get(0)).run(); - - for (int i = 1; i <= numberOfTrays - 1; i++) { - int replaceStream = 0; - if (i == feedTrayNumber) - replaceStream = 1; - ((Mixer) trays.get(i)).replaceStream(replaceStream, - trays.get(i - 1).getGasOutStream()); - ((Runnable) trays.get(i)).run(); - } - - for (int i = numberOfTrays - 2; i == feedTrayNumber; i--) { - int replaceStream = 1; - if (i == feedTrayNumber) - replaceStream = 2; - if (i == feedTrayNumber && i == 0) - replaceStream = 1; - ((Mixer) trays.get(i)).replaceStream(replaceStream, - trays.get(i + 1).getLiquidOutStream()); - ((Runnable) trays.get(i)).run(); - } - for (int i = 0; i < numberOfTrays; i++) { - err += Math.abs(oldtemps[i] - - ((MixerInterface) trays.get(i)).getThermoSystem().getTemperature()); - } - System.out.println("error iter " + err + " iteration " + iter); - // massBalanceCheck(); - } while (err > 1e-4 && err < errOld && iter < 10);// && !massBalanceCheck()); - - // massBalanceCheck(); - gasOutStream.setThermoSystem( - trays.get(numberOfTrays - 1).getGasOutStream().getThermoSystem().clone()); - liquidOutStream - .setThermoSystem(trays.get(0).getLiquidOutStream().getThermoSystem().clone()); - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - distoperations.displayResult(); - } - - /** - *

- * massBalanceCheck. - *

- * - * @return a boolean - */ - public boolean massBalanceCheck() { - double[] massInput = new double[numberOfTrays]; - double[] massOutput = new double[numberOfTrays]; - double[] massBalance = new double[numberOfTrays]; - System.out.println("water in feed " - + feedStream.getFluid().getPhase(0).getComponent("water").getNumberOfmoles()); - System.out.println("water in strip gas feed " + trays.get(0).getStream(0).getFluid() - .getPhase(0).getComponent("water").getNumberOfmoles()); - - for (int i = 0; i < numberOfTrays; i++) { - int numberOfInputStreams = trays.get(i).getNumberOfInputStreams(); - for (int j = 0; j < numberOfInputStreams; j++) { - massInput[i] += trays.get(i).getStream(j).getFluid().getFlowRate("kg/hr"); - } - massOutput[i] += trays.get(i).getGasOutStream().getFlowRate("kg/hr"); - massOutput[i] += trays.get(i).getLiquidOutStream().getFlowRate("kg/hr"); - massBalance[i] = massInput[i] - massOutput[i]; - System.out.println("tray " + i + " number of input streams " + numberOfInputStreams - + " massinput " + massInput[i] + " massoutput " + massOutput[i] - + " massbalance " + massBalance[i] + " gasout " - + trays.get(i).getGasOutStream().getFlowRate("kg/hr") + " liquidout " - + trays.get(i).getLiquidOutStream().getFlowRate("kg/hr") + " pressure " - + trays.get(i).getGasOutStream().getPressure() + " temperature " - + trays.get(i).getGasOutStream().getTemperature("C")); - - System.out - .println("tray " + i + " number of input streams " + numberOfInputStreams - + " water in gasout " - + trays.get(i).getGasOutStream().getFluid().getPhase(0) - .getComponent("water").getNumberOfmoles() - + " water in liquidout " - + trays.get(i).getLiquidOutStream().getFluid().getPhase(0) - .getComponent("water").getNumberOfmoles() - + " pressure " + trays.get(i).getGasOutStream().getPressure() - + " temperature " + trays.get(i).getGasOutStream().getTemperature("C")); - } - - double massError = 0.0; - for (int i = 0; i < numberOfTrays; i++) { - massError += Math.abs(massBalance[i]); - } - if (massError > 1e-6) - return false; - else - return true; + for (int i = numberOfTrays - 2; i >= 1; i--) { + ((MixerInterface) trays.get(i)).addStream(trays.get(i + 1).getLiquidOutStream()); + trays.get(i).init(); + ((Runnable) trays.get(i)).run(); } - - /** - *

- * energyBalanceCheck. - *

- */ - public void energyBalanceCheck() { - double[] energyInput = new double[numberOfTrays]; - double[] energyOutput = new double[numberOfTrays]; - double[] energyBalance = new double[numberOfTrays]; - for (int i = 0; i < numberOfTrays; i++) { - int numberOfInputStreams = trays.get(i).getNumberOfInputStreams(); - for (int j = 0; j < numberOfInputStreams; j++) { - energyInput[i] += trays.get(i).getStream(j).getFluid().getEnthalpy(); - } - energyOutput[i] += trays.get(i).getGasOutStream().getFluid().getEnthalpy(); - energyOutput[i] += trays.get(i).getLiquidOutStream().getFluid().getEnthalpy(); - energyBalance[i] = energyInput[i] - energyOutput[i]; - System.out.println("tray " + i + " number of input streams " + numberOfInputStreams - + " energyinput " + energyInput[i] + " energyoutput " + energyOutput[i] - + " energybalance " + energyBalance[i] + " gasout " - + trays.get(i).getGasOutStream().getFlowRate("kg/hr") + " liquidout " - + trays.get(i).getLiquidOutStream().getFlowRate("kg/hr") + " pressure " - + trays.get(i).getGasOutStream().getPressure() + " temperature " - + trays.get(i).getGasOutStream().getTemperature("C")); - } + int streamNumb = (trays.get(0)).getNumberOfInputStreams() - 1; + ((MixerInterface) trays.get(0)).replaceStream(streamNumb, trays.get(1).getLiquidOutStream()); + trays.get(0).init(); + ((Runnable) trays.get(0)).run(); + } + + /** + *

+ * Getter for the field gasOutStream. + *

+ * + * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + public StreamInterface getGasOutStream() { + return gasOutStream; + } + + /** + *

+ * Getter for the field liquidOutStream. + *

+ * + * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + public StreamInterface getLiquidOutStream() { + return liquidOutStream; + } + + /** + *

+ * getTray. + *

+ * + * @param trayNumber a int + * @return a {@link neqsim.processSimulation.processEquipment.distillation.SimpleTray} object + */ + public SimpleTray getTray(int trayNumber) { + return trays.get(trayNumber); + } + + /** {@inheritDoc} */ + @Override + public void setNumberOfTrays(int number) { + int oldNumberOfTrays = numberOfTrays; + + int tempNumberOfTrays = number; + + if (hasReboiler) { + tempNumberOfTrays++; } - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 - 0.0), 15.000); - // testSystem.addComponent("methane", 10.00); - testSystem.addComponent("ethane", 10.0); - testSystem.addComponent("CO2", 10.0); - testSystem.addComponent("propane", 20.0); - // testSystem.addComponent("i-butane", 5.0); - // testSystem.addComponent("n-hexane", 15.0); - // testSystem.addComponent("n-heptane", 30.0); - // testSystem.addComponent("n-octane", 4.0); - // testSystem.addComponent("n-nonane", 3.0); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - ThermodynamicOperations ops = new ThermodynamicOperations(testSystem); - ops.TPflash(); - testSystem.display(); - Stream stream_1 = new Stream("Stream1", testSystem); - - DistillationColumn column = new DistillationColumn(5, true, true); - column.addFeedStream(stream_1, 3); - // column.getReboiler().setHeatInput(520000.0); - ((Reboiler) column.getReboiler()).setRefluxRatio(0.5); - // column.getCondenser().setHeatInput(-70000.0); - // ((Condenser) column.getCondenser()).setRefluxRatio(0.2); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(stream_1); - operations.add(column); - operations.run(); - - column.displayResult(); - System.out.println("reboiler duty" + ((Reboiler) column.getReboiler()).getDuty()); - System.out.println("condenser duty" + ((Condenser) column.getCondenser()).getDuty()); + if (hasCondenser) { + tempNumberOfTrays++; } - /** - *

- * getReboiler. - *

- * - * @return a {@link neqsim.processSimulation.processEquipment.distillation.SimpleTray} object - */ - public SimpleTray getReboiler() { - return trays.get(0); - } + int change = tempNumberOfTrays - oldNumberOfTrays; - /** - *

- * getCondenser. - *

- * - * @return a {@link neqsim.processSimulation.processEquipment.distillation.SimpleTray} object - */ - public SimpleTray getCondenser() { - return trays.get(trays.size() - 1); + if (change > 0) { + for (int i = 0; i < change; i++) { + trays.add(1, new SimpleTray("SimpleTray" + oldNumberOfTrays + i + 1)); + } + } else if (change < 0) { + for (int i = 0; i > change; i--) { + trays.remove(1); + } } - - /** - *

- * Getter for the field reboilerTemperature. - *

- * - * @return the reboilerTemperature - */ - public double getReboilerTemperature() { - return reboilerTemperature; + numberOfTrays = tempNumberOfTrays; + + setDoInitializion(true); + init(); + } + + /** + *

+ * setTopCondenserDuty. + *

+ * + * @param duty a double + */ + public void setTopCondenserDuty(double duty) { + condenserCoolingDuty = duty; + } + + /** + *

+ * setTopPressure. + *

+ * + * @param topPressure a double + */ + public void setTopPressure(double topPressure) { + topTrayPressure = topPressure; + } + + /** + *

+ * setBottomPressure. + *

+ * + * @param bottomPressure a double + */ + public void setBottomPressure(double bottomPressure) { + bottomTrayPressure = bottomPressure; + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + if (bottomTrayPressure < 0) { + bottomTrayPressure = getTray(feedTrayNumber).getStream(0).getPressure(); } - - /** - *

- * Setter for the field reboilerTemperature. - *

- * - * @param reboilerTemperature the reboilerTemperature to set - */ - public void setReboilerTemperature(double reboilerTemperature) { - this.reboilerTemperature = reboilerTemperature; + if (topTrayPressure < 0) { + topTrayPressure = getTray(feedTrayNumber).getStream(0).getPressure(); } - /** - *

- * getCondenserTemperature. - *

- * - * @return the condenserTemperature - */ - public double getCondenserTemperature() { - return condenserTemperature; + double dp = 0.0; + if (numberOfTrays > 1) { + dp = (bottomTrayPressure - topTrayPressure) / (numberOfTrays - 1.0); } - - /** - *

- * setCondenserTemperature. - *

- * - * @param condenserTemperature the condenserTemperature to set - */ - public void setCondenserTemperature(double condenserTemperature) { - this.condenserTemperature = condenserTemperature; + for (int i = 0; i < numberOfTrays; i++) { + trays.get(i).setPressure(bottomTrayPressure - i * dp); } + getTray(feedTrayNumber).getStream(0).setThermoSystem(feedStream.getThermoSystem().clone()); + + if (numberOfTrays == 1) { + ((SimpleTray) trays.get(0)).run(id); + gasOutStream.setThermoSystem(trays.get(0).getGasOutStream().getThermoSystem().clone()); + liquidOutStream.setThermoSystem(trays.get(0).getLiquidOutStream().getThermoSystem().clone()); + } else { + if (isDoInitializion()) { + this.init(); + } + double err = 1.0e10; + double errOld; + int iter = 0; + double[] oldtemps = new double[numberOfTrays]; + ((SimpleTray) trays.get(feedTrayNumber)).run(); + + do { + iter++; + errOld = err; + err = 0.0; + for (int i = 0; i < numberOfTrays; i++) { + oldtemps[i] = ((MixerInterface) trays.get(i)).getThermoSystem().getTemperature(); + } - /** - *

- * Getter for the field feedTrayNumber. - *

- * - * @return the feedTrayNumber - */ - public int getFeedTrayNumber() { - return feedTrayNumber; - } + for (int i = feedTrayNumber; i > 1; i--) { + ((Mixer) trays.get(i - 1)).replaceStream(1, trays.get(i).getLiquidOutStream()); + trays.get(i - 1).setPressure(bottomTrayPressure - (i - 1) * dp); + ((SimpleTray) trays.get(i - 1)).run(); + } + int streamNumb = (trays.get(0)).getNumberOfInputStreams() - 1; + ((Mixer) trays.get(0)).replaceStream(streamNumb, trays.get(1).getLiquidOutStream()); + ((SimpleTray) trays.get(0)).run(); + + for (int i = 1; i <= numberOfTrays - 1; i++) { + int replaceStream = 0; + if (i == feedTrayNumber) { + replaceStream = 1; + } + ((Mixer) trays.get(i)).replaceStream(replaceStream, trays.get(i - 1).getGasOutStream()); + ((SimpleTray) trays.get(i)).run(); + } - /** - *

- * Setter for the field feedTrayNumber. - *

- * - * @param feedTrayNumber the feedTrayNumber to set - */ - public void setFeedTrayNumber(int feedTrayNumber) { - this.feedTrayNumber = feedTrayNumber; + for (int i = numberOfTrays - 2; i == feedTrayNumber; i--) { + int replaceStream = 1; + if (i == feedTrayNumber) { + replaceStream = 2; + } + if (i == feedTrayNumber && i == 0) { + replaceStream = 1; + } + ((Mixer) trays.get(i)).replaceStream(replaceStream, + trays.get(i + 1).getLiquidOutStream()); + ((SimpleTray) trays.get(i)).run(); + } + for (int i = 0; i < numberOfTrays; i++) { + err += Math.abs( + oldtemps[i] - ((MixerInterface) trays.get(i)).getThermoSystem().getTemperature()); + } + System.out.println("error iter " + err + " iteration " + iter); + // massBalanceCheck(); + } while (err > 1e-4 && err < errOld && iter < 10); // && !massBalanceCheck()); + + // massBalanceCheck(); + gasOutStream.setThermoSystem( + trays.get(numberOfTrays - 1).getGasOutStream().getThermoSystem().clone()); + gasOutStream.setCalculationIdentifier(id); + liquidOutStream.setThermoSystem(trays.get(0).getLiquidOutStream().getThermoSystem().clone()); + liquidOutStream.setCalculationIdentifier(id); + + for (int i = 0; i < numberOfTrays; i++) { + // todo: set calculation ids of child elements of trays + ((SimpleTray) trays.get(i)).setCalculationIdentifier(id); + } } - - /** - *

- * isDoInitializion. - *

- * - * @return a boolean - */ - public boolean isDoInitializion() { - return doInitializion; + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + distoperations.displayResult(); + } + + /** + *

+ * massBalanceCheck. + *

+ * + * @return a boolean + */ + public boolean massBalanceCheck() { + double[] massInput = new double[numberOfTrays]; + double[] massOutput = new double[numberOfTrays]; + double[] massBalance = new double[numberOfTrays]; + System.out.println("water in feed " + + feedStream.getFluid().getPhase(0).getComponent("water").getNumberOfmoles()); + System.out.println("water in strip gas feed " + trays.get(0).getStream(0).getFluid().getPhase(0) + .getComponent("water").getNumberOfmoles()); + + for (int i = 0; i < numberOfTrays; i++) { + int numberOfInputStreams = trays.get(i).getNumberOfInputStreams(); + for (int j = 0; j < numberOfInputStreams; j++) { + massInput[i] += trays.get(i).getStream(j).getFluid().getFlowRate("kg/hr"); + } + massOutput[i] += trays.get(i).getGasOutStream().getFlowRate("kg/hr"); + massOutput[i] += trays.get(i).getLiquidOutStream().getFlowRate("kg/hr"); + massBalance[i] = massInput[i] - massOutput[i]; + System.out.println("tray " + i + " number of input streams " + numberOfInputStreams + + " massinput " + massInput[i] + " massoutput " + massOutput[i] + " massbalance " + + massBalance[i] + " gasout " + trays.get(i).getGasOutStream().getFlowRate("kg/hr") + + " liquidout " + trays.get(i).getLiquidOutStream().getFlowRate("kg/hr") + " pressure " + + trays.get(i).getGasOutStream().getPressure() + " temperature " + + trays.get(i).getGasOutStream().getTemperature("C")); + + System.out.println( + "tray " + i + " number of input streams " + numberOfInputStreams + " water in gasout " + + trays.get(i).getGasOutStream().getFluid().getPhase(0).getComponent("water") + .getNumberOfmoles() + + " water in liquidout " + + trays.get(i).getLiquidOutStream().getFluid().getPhase(0).getComponent("water") + .getNumberOfmoles() + + " pressure " + trays.get(i).getGasOutStream().getPressure() + " temperature " + + trays.get(i).getGasOutStream().getTemperature("C")); } - /** - *

- * Setter for the field doInitializion. - *

- * - * @param doInitializion a boolean - */ - public void setDoInitializion(boolean doInitializion) { - this.doInitializion = doInitializion; + double massError = 0.0; + for (int i = 0; i < numberOfTrays; i++) { + massError += Math.abs(massBalance[i]); } - - /** - *

- * getFsFactor. - *

- * - * @return a double - */ - public double getFsFactor() { - double intArea = 3.14 * getInternalDiameter() * getInternalDiameter() / 4.0; - return getGasOutStream().getThermoSystem().getFlowRate("m3/sec") / intArea - * Math.sqrt(getGasOutStream().getThermoSystem().getDensity("kg/m3")); + if (massError > 1e-6) { + return false; + } else { + return true; } - - /** - *

- * Getter for the field internalDiameter. - *

- * - * @return a double - */ - public double getInternalDiameter() { - return internalDiameter; + } + + /** + *

+ * energyBalanceCheck. + *

+ */ + public void energyBalanceCheck() { + double[] energyInput = new double[numberOfTrays]; + double[] energyOutput = new double[numberOfTrays]; + double[] energyBalance = new double[numberOfTrays]; + for (int i = 0; i < numberOfTrays; i++) { + int numberOfInputStreams = trays.get(i).getNumberOfInputStreams(); + for (int j = 0; j < numberOfInputStreams; j++) { + energyInput[i] += trays.get(i).getStream(j).getFluid().getEnthalpy(); + } + energyOutput[i] += trays.get(i).getGasOutStream().getFluid().getEnthalpy(); + energyOutput[i] += trays.get(i).getLiquidOutStream().getFluid().getEnthalpy(); + energyBalance[i] = energyInput[i] - energyOutput[i]; + System.out.println( + "tray " + i + " number of input streams " + numberOfInputStreams + " energyinput " + + energyInput[i] + " energyoutput " + energyOutput[i] + " energybalance " + + energyBalance[i] + " gasout " + trays.get(i).getGasOutStream().getFlowRate("kg/hr") + + " liquidout " + trays.get(i).getLiquidOutStream().getFlowRate("kg/hr") + + " pressure " + trays.get(i).getGasOutStream().getPressure() + " temperature " + + trays.get(i).getGasOutStream().getTemperature("C")); } - - /** - *

- * Setter for the field internalDiameter. - *

- * - * @param internalDiameter a double - */ - public void setInternalDiameter(double internalDiameter) { - this.internalDiameter = internalDiameter; + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos((273.15 - 0.0), 15.000); + // testSystem.addComponent("methane", 10.00); + testSystem.addComponent("ethane", 10.0); + testSystem.addComponent("CO2", 10.0); + testSystem.addComponent("propane", 20.0); + // testSystem.addComponent("i-butane", 5.0); + // testSystem.addComponent("n-hexane", 15.0); + // testSystem.addComponent("n-heptane", 30.0); + // testSystem.addComponent("n-octane", 4.0); + // testSystem.addComponent("n-nonane", 3.0); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + ThermodynamicOperations ops = new ThermodynamicOperations(testSystem); + ops.TPflash(); + testSystem.display(); + Stream stream_1 = new Stream("Stream1", testSystem); + + DistillationColumn column = new DistillationColumn(5, true, true); + column.addFeedStream(stream_1, 3); + // column.getReboiler().setHeatInput(520000.0); + ((Reboiler) column.getReboiler()).setRefluxRatio(0.5); + // column.getCondenser().setHeatInput(-70000.0); + // ((Condenser) column.getCondenser()).setRefluxRatio(0.2); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(column); + operations.run(); + + column.displayResult(); + System.out.println("reboiler duty" + ((Reboiler) column.getReboiler()).getDuty()); + System.out.println("condenser duty" + ((Condenser) column.getCondenser()).getDuty()); + } + + /** + *

+ * getReboiler. + *

+ * + * @return a {@link neqsim.processSimulation.processEquipment.distillation.SimpleTray} object + */ + public SimpleTray getReboiler() { + return trays.get(0); + } + + /** + *

+ * getCondenser. + *

+ * + * @return a {@link neqsim.processSimulation.processEquipment.distillation.SimpleTray} object + */ + public SimpleTray getCondenser() { + return trays.get(trays.size() - 1); + } + + /** + *

+ * Getter for the field reboilerTemperature. + *

+ * + * @return the reboilerTemperature + */ + public double getReboilerTemperature() { + return reboilerTemperature; + } + + /** + *

+ * Setter for the field reboilerTemperature. + *

+ * + * @param reboilerTemperature the reboilerTemperature to set + */ + public void setReboilerTemperature(double reboilerTemperature) { + this.reboilerTemperature = reboilerTemperature; + } + + /** + *

+ * getCondenserTemperature. + *

+ * + * @return the condenserTemperature + */ + public double getCondenserTemperature() { + return condenserTemperature; + } + + /** + *

+ * setCondenserTemperature. + *

+ * + * @param condenserTemperature the condenserTemperature to set + */ + public void setCondenserTemperature(double condenserTemperature) { + this.condenserTemperature = condenserTemperature; + } + + /** + *

+ * Getter for the field feedTrayNumber. + *

+ * + * @return the feedTrayNumber + */ + public int getFeedTrayNumber() { + return feedTrayNumber; + } + + /** + *

+ * Setter for the field feedTrayNumber. + *

+ * + * @param feedTrayNumber the feedTrayNumber to set + */ + public void setFeedTrayNumber(int feedTrayNumber) { + this.feedTrayNumber = feedTrayNumber; + } + + /** + *

+ * isDoInitializion. + *

+ * + * @return a boolean + */ + public boolean isDoInitializion() { + return doInitializion; + } + + /** + *

+ * Setter for the field doInitializion. + *

+ * + * @param doInitializion a boolean + */ + public void setDoInitializion(boolean doInitializion) { + this.doInitializion = doInitializion; + } + + /** + *

+ * getFsFactor. + *

+ * + * @return a double + */ + public double getFsFactor() { + double intArea = 3.14 * getInternalDiameter() * getInternalDiameter() / 4.0; + return getGasOutStream().getThermoSystem().getFlowRate("m3/sec") / intArea + * Math.sqrt(getGasOutStream().getThermoSystem().getDensity("kg/m3")); + } + + /** + *

+ * Getter for the field internalDiameter. + *

+ * + * @return a double + */ + public double getInternalDiameter() { + return internalDiameter; + } + + /** + *

+ * Setter for the field internalDiameter. + *

+ * + * @param internalDiameter a double + */ + public void setInternalDiameter(double internalDiameter) { + this.internalDiameter = internalDiameter; + } + + /** {@inheritDoc} */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + Objects.hash(bottomTrayPressure, condenserCoolingDuty, + condenserTemperature, + distoperations, doInitializion, feedStream, feedTrayNumber, gasOutStream, hasCondenser, + hasReboiler, heater, internalDiameter, liquidOutStream, numberOfTrays, + reboilerTemperature, separator2, stream_3, stream_3isset, topTrayPressure, trays); + return result; + } + + /** {@inheritDoc} */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; } - - /** {@inheritDoc} */ - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result - + Objects.hash(bottomTrayPressure, condenserCoolingDuty, condenserTemperature, - distoperations, doInitializion, feedStream, feedTrayNumber, gasOutStream, - hasCondenser, hasReboiler, heater, internalDiameter, liquidOutStream, numberOfTrays, - reboilerTemperature, separator2, stream_3, stream_3isset, topTrayPressure, trays); - return result; + if (!super.equals(obj)) { + return false; } - - /** {@inheritDoc} */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - DistillationColumn other = (DistillationColumn) obj; - return Double.doubleToLongBits(bottomTrayPressure) == Double - .doubleToLongBits(other.bottomTrayPressure) - && Double.doubleToLongBits(condenserCoolingDuty) == Double - .doubleToLongBits(other.condenserCoolingDuty) - && Double.doubleToLongBits(condenserTemperature) == Double - .doubleToLongBits(other.condenserTemperature) - && Objects.equals(distoperations, other.distoperations) - && doInitializion == other.doInitializion && Objects.equals(feedStream, other.feedStream) - && feedTrayNumber == other.feedTrayNumber - && Objects.equals(gasOutStream, other.gasOutStream) && hasCondenser == other.hasCondenser - && hasReboiler == other.hasReboiler && Objects.equals(heater, other.heater) - && Double.doubleToLongBits(internalDiameter) == Double - .doubleToLongBits(other.internalDiameter) - && Objects.equals(liquidOutStream, other.liquidOutStream) - && numberOfTrays == other.numberOfTrays - && Double.doubleToLongBits(reboilerTemperature) == Double - .doubleToLongBits(other.reboilerTemperature) - && Objects.equals(separator2, other.separator2) - && Objects.equals(stream_3, other.stream_3) && stream_3isset == other.stream_3isset - && Double.doubleToLongBits(topTrayPressure) == Double - .doubleToLongBits(other.topTrayPressure) - && Objects.equals(trays, other.trays); + if (getClass() != obj.getClass()) { + return false; } + DistillationColumn other = (DistillationColumn) obj; + return Double.doubleToLongBits(bottomTrayPressure) == Double + .doubleToLongBits(other.bottomTrayPressure) + && Double.doubleToLongBits(condenserCoolingDuty) == Double + .doubleToLongBits(other.condenserCoolingDuty) + && Double.doubleToLongBits(condenserTemperature) == Double + .doubleToLongBits(other.condenserTemperature) + && Objects.equals(distoperations, other.distoperations) + && doInitializion == other.doInitializion && Objects.equals(feedStream, other.feedStream) + && feedTrayNumber == other.feedTrayNumber + && Objects.equals(gasOutStream, other.gasOutStream) && hasCondenser == other.hasCondenser + && hasReboiler == other.hasReboiler && Objects.equals(heater, other.heater) + && Double.doubleToLongBits(internalDiameter) == Double + .doubleToLongBits(other.internalDiameter) + && Objects.equals(liquidOutStream, other.liquidOutStream) + && numberOfTrays == other.numberOfTrays + && Double.doubleToLongBits(reboilerTemperature) == Double + .doubleToLongBits(other.reboilerTemperature) + && Objects.equals(separator2, other.separator2) && Objects.equals(stream_3, other.stream_3) + && stream_3isset == other.stream_3isset && Double + .doubleToLongBits(topTrayPressure) == Double.doubleToLongBits(other.topTrayPressure) + && Objects.equals(trays, other.trays); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/distillation/Reboiler.java b/src/main/java/neqsim/processSimulation/processEquipment/distillation/Reboiler.java index 91c12210ea..ac6e45295a 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/distillation/Reboiler.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/distillation/Reboiler.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.distillation; +import java.util.UUID; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -12,78 +13,84 @@ * @version $Id: $Id */ public class Reboiler extends neqsim.processSimulation.processEquipment.distillation.SimpleTray { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - private double refluxRatio = 0.1; - boolean refluxIsSet = false; - double duty = 0.0; + private double refluxRatio = 0.1; + boolean refluxIsSet = false; + double duty = 0.0; - /** - *

- * Constructor for Reboiler. - *

- * - * @param name name of unit operation - */ - public Reboiler(String name) { - super(name); - } + /** + *

+ * Constructor for Reboiler. + *

+ * + * @param name name of unit operation + */ + public Reboiler(String name) { + super(name); + } - /** - *

- * Getter for the field refluxRatio. - *

- * - * @return the refluxRatio - */ - public double getRefluxRatio() { - return refluxRatio; - } + /** + *

+ * Getter for the field refluxRatio. + *

+ * + * @return the refluxRatio + */ + public double getRefluxRatio() { + return refluxRatio; + } - /** - *

- * Setter for the field refluxRatio. - *

- * - * @param refluxRatio the refluxRatio to set - */ - public void setRefluxRatio(double refluxRatio) { - this.refluxRatio = refluxRatio; - refluxIsSet = true; - } + /** + *

+ * Setter for the field refluxRatio. + *

+ * + * @param refluxRatio the refluxRatio to set + */ + public void setRefluxRatio(double refluxRatio) { + this.refluxRatio = refluxRatio; + refluxIsSet = true; + } - /** - *

- * Getter for the field duty. - *

- * - * @return a double - */ - public double getDuty() { - return duty; - // return calcMixStreamEnthalpy(); + /** + *

+ * Getter for the field duty. + *

+ * + * @return a double + */ + public double getDuty() { + return duty; + // return calcMixStreamEnthalpy(); + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + if (!refluxIsSet) { + UUID oldid = getCalculationIdentifier(); + super.run(id); + mixedStream.setCalculationIdentifier(oldid); + setCalculationIdentifier(oldid); + } else { + SystemInterface thermoSystem2 = streams.get(0).getThermoSystem().clone(); + // System.out.println("total number of moles " + + // thermoSystem2.getTotalNumberOfMoles()); + mixedStream.setThermoSystem(thermoSystem2); + ThermodynamicOperations testOps = new ThermodynamicOperations(thermoSystem2); + testOps.PVrefluxFlash(refluxRatio, 1); } + // System.out.println("enthalpy: " + + // mixedStream.getThermoSystem().getEnthalpy()); + // System.out.println("enthalpy: " + enthalpy); + // System.out.println("temperature: " + + // mixedStream.getThermoSystem().getTemperature()); - /** {@inheritDoc} */ - @Override - public void run() { - if (!refluxIsSet) { - super.run(); - } else { - SystemInterface thermoSystem2 = streams.get(0).getThermoSystem().clone(); - // System.out.println("total number of moles " + - // thermoSystem2.getTotalNumberOfMoles()); - mixedStream.setThermoSystem(thermoSystem2); - ThermodynamicOperations testOps = new ThermodynamicOperations(thermoSystem2); - testOps.PVrefluxFlash(refluxRatio, 1); - } - // System.out.println("enthalpy: " + - // mixedStream.getThermoSystem().getEnthalpy()); - // System.out.println("enthalpy: " + enthalpy); - // System.out.println("temperature: " + - // mixedStream.getThermoSystem().getTemperature()); + // System.out.println("beta " + mixedStream.getThermoSystem().getBeta()) + duty = mixedStream.getFluid().getEnthalpy() - calcMixStreamEnthalpy0(); - // System.out.println("beta " + mixedStream.getThermoSystem().getBeta()) - duty = mixedStream.getFluid().getEnthalpy() - calcMixStreamEnthalpy0(); - } + mixedStream.setCalculationIdentifier(id); + setCalculationIdentifier(id); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/distillation/SimpleTray.java b/src/main/java/neqsim/processSimulation/processEquipment/distillation/SimpleTray.java index ff3aa7464f..2c96e6454b 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/distillation/SimpleTray.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/distillation/SimpleTray.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.distillation; +import java.util.UUID; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.thermo.system.SystemInterface; @@ -14,210 +15,218 @@ * @version $Id: $Id */ public class SimpleTray extends neqsim.processSimulation.processEquipment.mixer.Mixer - implements TrayInterface { - private static final long serialVersionUID = 1000; - - double heatInput = 0.0; - private double temperature = Double.NaN, trayPressure = -1.0; - - /** - *

- * Constructor for SimpleTray. - *

- * - * @param name name of tray - */ - public SimpleTray(String name) { - super(name); + implements TrayInterface { + private static final long serialVersionUID = 1000; + + double heatInput = 0.0; + private double temperature = Double.NaN; + + private double trayPressure = -1.0; + + /** + *

+ * Constructor for SimpleTray. + *

+ * + * @param name name of tray + */ + public SimpleTray(String name) { + super(name); + } + + /** + *

+ * init. + *

+ */ + public void init() { + int pp = 0; + if (streams.size() == 3) { + pp = 1; } - - /** - *

- * init. - *

- */ - public void init() { - int pp = 0; - if (streams.size() == 3) { - pp = 1; - } - for (int k = pp; k < streams.size(); k++) { - (streams.get(k).getThermoSystem()).setTemperature(temperature); - } + for (int k = pp; k < streams.size(); k++) { + (streams.get(k).getThermoSystem()).setTemperature(temperature); } - - /** {@inheritDoc} */ - @Override - public void setHeatInput(double heatinp) { - this.heatInput = heatinp; + } + + /** {@inheritDoc} */ + @Override + public void setHeatInput(double heatinp) { + this.heatInput = heatinp; + } + + /** + *

+ * calcMixStreamEnthalpy0. + *

+ * + * @return a double + */ + public double calcMixStreamEnthalpy0() { + double enthalpy = 0; + + for (int k = 0; k < streams.size(); k++) { + streams.get(k).getThermoSystem().init(3); + enthalpy += streams.get(k).getThermoSystem().getEnthalpy(); + // System.out.println("total enthalpy k : " + ( ((Stream) + // streams.get(k)).getThermoSystem()).getEnthalpy()); } - - /** - *

- * calcMixStreamEnthalpy0. - *

- * - * @return a double - */ - public double calcMixStreamEnthalpy0() { - double enthalpy = 0; - - for (int k = 0; k < streams.size(); k++) { - streams.get(k).getThermoSystem().init(3); - enthalpy += streams.get(k).getThermoSystem().getEnthalpy(); - // System.out.println("total enthalpy k : " + ( ((Stream) - // streams.get(k)).getThermoSystem()).getEnthalpy()); - } - // System.out.println("total enthalpy of streams: " + enthalpy); - return enthalpy; + // System.out.println("total enthalpy of streams: " + enthalpy); + return enthalpy; + } + + /** {@inheritDoc} */ + @Override + public double calcMixStreamEnthalpy() { + double enthalpy = heatInput; + if (isSetEnergyStream()) { + enthalpy -= energyStream.getDuty(); } - /** {@inheritDoc} */ - @Override - public double calcMixStreamEnthalpy() { - double enthalpy = heatInput; - if (isSetEnergyStream()) { - enthalpy -= energyStream.getDuty(); - } - - for (int k = 0; k < streams.size(); k++) { - streams.get(k).getThermoSystem().init(3); - enthalpy += streams.get(k).getThermoSystem().getEnthalpy(); - // System.out.println("total enthalpy k : " + ( ((Stream) - // streams.get(k)).getThermoSystem()).getEnthalpy()); - } - // System.out.println("total enthalpy of streams: " + enthalpy); - return enthalpy; + for (int k = 0; k < streams.size(); k++) { + streams.get(k).getThermoSystem().init(3); + enthalpy += streams.get(k).getThermoSystem().getEnthalpy(); + // System.out.println("total enthalpy k : " + ( ((Stream) + // streams.get(k)).getThermoSystem()).getEnthalpy()); } - - /** - *

- * run2. - *

- */ - public void run2() { - super.run(); - temperature = mixedStream.getTemperature(); + // System.out.println("total enthalpy of streams: " + enthalpy); + return enthalpy; + } + + /** + *

+ * run2. + *

+ */ + public void run2() { + super.run(); + temperature = mixedStream.getTemperature(); + } + + /** + *

+ * TPflash. + *

+ */ + public void TPflash() {} + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + double enthalpy = 0.0; + // double flowRate = ((Stream) + // streams.get(0)).getThermoSystem().getFlowRate("kg/hr"); + // ((Stream) streams.get(0)).getThermoSystem().display(); + SystemInterface thermoSystem2 = streams.get(0).getThermoSystem().clone(); + + // System.out.println("total number of moles " + + // thermoSystem2.getTotalNumberOfMoles()); + if (trayPressure > 0) { + thermoSystem2.setPressure(trayPressure); } - - /** - *

- * TPflash. - *

- */ - public void TPflash() {} - - /** {@inheritDoc} */ - @Override - public void run() { - double enthalpy = 0.0; - // double flowRate = ((Stream) - // streams.get(0)).getThermoSystem().getFlowRate("kg/hr"); - // ((Stream) streams.get(0)).getThermoSystem().display(); - SystemInterface thermoSystem2 = streams.get(0).getThermoSystem().clone(); - - // System.out.println("total number of moles " + - // thermoSystem2.getTotalNumberOfMoles()); - if (trayPressure > 0) { - thermoSystem2.setPressure(trayPressure); - } - mixedStream.setThermoSystem(thermoSystem2); - // thermoSystem2.display(); - ThermodynamicOperations testOps = new ThermodynamicOperations(thermoSystem2); - if (streams.size() > 0) { - mixedStream.getThermoSystem().setNumberOfPhases(2); - mixedStream.getThermoSystem().reInitPhaseType(); - mixedStream.getThermoSystem().init(0); - - mixStream(); - if (trayPressure > 0) - mixedStream.setPressure(trayPressure, "bara"); - enthalpy = calcMixStreamEnthalpy(); - // System.out.println("temp guess " + guessTemperature()); - if (!isSetOutTemperature()) { - // mixedStream.getThermoSystem().setTemperature(guessTemperature()); - } else { - mixedStream.setTemperature(getOutTemperature(), "K"); - } - // System.out.println("filan temp " + mixedStream.getTemperature()); - } - if (isSetOutTemperature()) { - if (!Double.isNaN(getOutTemperature())) - mixedStream.getThermoSystem().setTemperature(getOutTemperature()); - testOps.TPflash(); - mixedStream.getThermoSystem().init(2); - } else { - try { - testOps.PHflash(enthalpy, 0); - } catch (Exception e) { - if (!Double.isNaN(getOutTemperature())) - mixedStream.getThermoSystem().setTemperature(getOutTemperature()); - testOps.TPflash(); - } - } - setTemperature(mixedStream.getTemperature()); - } - - /** - *

- * getGasOutStream. - *

- * - * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - public StreamInterface getGasOutStream() { - return new Stream("", mixedStream.getThermoSystem().phaseToSystem(0)); - } - - /** - *

- * getLiquidOutStream. - *

- * - * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - public StreamInterface getLiquidOutStream() { - return new Stream("", mixedStream.getThermoSystem().phaseToSystem(1)); - } - - /** - *

- * Getter for the field temperature. - *

- * - * @return the temperature - */ - public double getTemperature() { - return temperature; - } - - /** {@inheritDoc} */ - @Override - public void setPressure(double pres) { - trayPressure = pres; + mixedStream.setThermoSystem(thermoSystem2); + // thermoSystem2.display(); + ThermodynamicOperations testOps = new ThermodynamicOperations(thermoSystem2); + if (streams.size() > 0) { + mixedStream.getThermoSystem().setNumberOfPhases(2); + mixedStream.getThermoSystem().reInitPhaseType(); + mixedStream.getThermoSystem().init(0); + + mixStream(); + if (trayPressure > 0) { + mixedStream.setPressure(trayPressure, "bara"); + } + enthalpy = calcMixStreamEnthalpy(); + // System.out.println("temp guess " + guessTemperature()); + if (!isSetOutTemperature()) { + // mixedStream.getThermoSystem().setTemperature(guessTemperature()); + } else { + mixedStream.setTemperature(getOutTemperature(), "K"); + } + // System.out.println("filan temp " + mixedStream.getTemperature()); } - - /** {@inheritDoc} */ - @Override - public void setTemperature(double temperature) { - this.temperature = temperature; + if (isSetOutTemperature()) { + if (!Double.isNaN(getOutTemperature())) { + mixedStream.getThermoSystem().setTemperature(getOutTemperature()); + } + testOps.TPflash(); + mixedStream.getThermoSystem().init(2); + } else { + try { + testOps.PHflash(enthalpy, 0); + } catch (Exception e) { + if (!Double.isNaN(getOutTemperature())) { + mixedStream.getThermoSystem().setTemperature(getOutTemperature()); + } + testOps.TPflash(); + } } - /** {@inheritDoc} */ - @Override - public double guessTemperature() { - if (Double.isNaN(temperature)) { - double gtemp = 0; - for (int k = 0; k < streams.size(); k++) { - gtemp += streams.get(k).getThermoSystem().getTemperature() - * streams.get(k).getThermoSystem().getNumberOfMoles() - / mixedStream.getThermoSystem().getNumberOfMoles(); - } - // System.out.println("guess temperature " + gtemp); - return gtemp; - } else { - // System.out.println("temperature " + temperature); - return temperature; - } + setTemperature(mixedStream.getTemperature()); + mixedStream.setCalculationIdentifier(id); + setCalculationIdentifier(id); + } + + /** + *

+ * getGasOutStream. + *

+ * + * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + */ + public StreamInterface getGasOutStream() { + return new Stream("", mixedStream.getThermoSystem().phaseToSystem(0)); + } + + /** + *

+ * getLiquidOutStream. + *

+ * + * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + */ + public StreamInterface getLiquidOutStream() { + return new Stream("", mixedStream.getThermoSystem().phaseToSystem(1)); + } + + /** + *

+ * Getter for the field temperature. + *

+ * + * @return the temperature + */ + public double getTemperature() { + return temperature; + } + + /** {@inheritDoc} */ + @Override + public void setPressure(double pres) { + trayPressure = pres; + } + + /** {@inheritDoc} */ + @Override + public void setTemperature(double temperature) { + this.temperature = temperature; + } + + /** {@inheritDoc} */ + @Override + public double guessTemperature() { + if (Double.isNaN(temperature)) { + double gtemp = 0; + for (int k = 0; k < streams.size(); k++) { + gtemp += streams.get(k).getThermoSystem().getTemperature() + * streams.get(k).getThermoSystem().getNumberOfMoles() + / mixedStream.getThermoSystem().getNumberOfMoles(); + } + // System.out.println("guess temperature " + gtemp); + return gtemp; + } else { + // System.out.println("temperature " + temperature); + return temperature; } + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/distillation/VLSolidTray.java b/src/main/java/neqsim/processSimulation/processEquipment/distillation/VLSolidTray.java index 150b4ae9c6..ec63d62e10 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/distillation/VLSolidTray.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/distillation/VLSolidTray.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.distillation; +import java.util.UUID; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.thermo.system.SystemInterface; @@ -14,119 +15,120 @@ * @version $Id: $Id */ public class VLSolidTray extends SimpleTray { - private static final long serialVersionUID = 1000; - - double heatInput = 0.0; - private double temperature = 273.15; - - /** - *

- * Constructor for VLSolidTray. - *

- * - * @param name name of tray - */ - public VLSolidTray(String name) { - super(name); + private static final long serialVersionUID = 1000; + + double heatInput = 0.0; + private double temperature = 273.15; + + /** + *

+ * Constructor for VLSolidTray. + *

+ * + * @param name name of tray + */ + public VLSolidTray(String name) { + super(name); + } + + /** {@inheritDoc} */ + @Override + public void init() { + int pp = 0; + if (streams.size() == 3) { + pp = 1; } - - /** {@inheritDoc} */ - @Override - public void init() { - int pp = 0; - if (streams.size() == 3) { - pp = 1; - } - for (int k = pp; k < streams.size(); k++) { - (streams.get(k).getThermoSystem()).setTemperature(temperature); - } - } - - /** {@inheritDoc} */ - @Override - public void setHeatInput(double heatinp) { - this.heatInput = heatinp; + for (int k = pp; k < streams.size(); k++) { + (streams.get(k).getThermoSystem()).setTemperature(temperature); } - - /** {@inheritDoc} */ - @Override - public double calcMixStreamEnthalpy() { - double enthalpy = heatInput; - - for (int k = 0; k < streams.size(); k++) { - streams.get(k).getThermoSystem().init(3); - enthalpy += streams.get(k).getThermoSystem().getEnthalpy(); - System.out.println( - "total enthalpy k : " + streams.get(k).getThermoSystem().getEnthalpy()); - } - System.out.println("total enthalpy of streams: " + enthalpy); - return enthalpy; + } + + /** {@inheritDoc} */ + @Override + public void setHeatInput(double heatinp) { + this.heatInput = heatinp; + } + + /** {@inheritDoc} */ + @Override + public double calcMixStreamEnthalpy() { + double enthalpy = heatInput; + + for (int k = 0; k < streams.size(); k++) { + streams.get(k).getThermoSystem().init(3); + enthalpy += streams.get(k).getThermoSystem().getEnthalpy(); + System.out.println("total enthalpy k : " + streams.get(k).getThermoSystem().getEnthalpy()); } - - /** {@inheritDoc} */ - @Override - public void run() { - double enthalpy = 0.0; - - // ((Stream) streams.get(0)).getThermoSystem().display(); - - SystemInterface thermoSystem2 = streams.get(0).getThermoSystem().clone(); - // System.out.println("total number of moles " + - // thermoSystem2.getTotalNumberOfMoles()); - mixedStream.setThermoSystem(thermoSystem2); - // thermoSystem2.display(); - ThermodynamicOperations testOps = new ThermodynamicOperations(thermoSystem2); - if (streams.size() > 0) { - // mixedStream.getThermoSystem().setSolidPhaseCheck("CO2"); - mixedStream.getThermoSystem().setNumberOfPhases(2); - mixedStream.getThermoSystem().reInitPhaseType(); - mixedStream.getThermoSystem().init(0); - - mixStream(); - - enthalpy = calcMixStreamEnthalpy(); - // mixedStream.getThermoSystem().display(); - // System.out.println("temp guess " + guessTemperature()); - mixedStream.getThermoSystem().setSolidPhaseCheck("CO2"); - mixedStream.getThermoSystem().setTemperature(guessTemperature()); - testOps.PHsolidFlash(enthalpy); - mixedStream.getThermoSystem().display(); - // System.out.println("filan temp " + mixedStream.getTemperature()); - } else { - testOps.TPflash(); - } - mixedStream.getThermoSystem().setSolidPhaseCheck(false); - // System.out.println("enthalpy: " + - // mixedStream.getThermoSystem().getEnthalpy()); - // System.out.println("enthalpy: " + enthalpy); - // System.out.println("temperature: " + - // mixedStream.getThermoSystem().getTemperature()); - - // System.out.println("beta " + mixedStream.getThermoSystem().getBeta()); - // outStream.setThermoSystem(mixedStream.getThermoSystem()); - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getGasOutStream() { - return new Stream("", mixedStream.getThermoSystem().phaseToSystem(0)); - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getLiquidOutStream() { - return new Stream("", mixedStream.getThermoSystem().phaseToSystem(1)); - } - - /** {@inheritDoc} */ - @Override - public double getTemperature() { - return temperature; - } - - /** {@inheritDoc} */ - @Override - public void setTemperature(double temperature) { - this.temperature = temperature; + System.out.println("total enthalpy of streams: " + enthalpy); + return enthalpy; + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + double enthalpy = 0.0; + + // ((Stream) streams.get(0)).getThermoSystem().display(); + + SystemInterface thermoSystem2 = streams.get(0).getThermoSystem().clone(); + // System.out.println("total number of moles " + + // thermoSystem2.getTotalNumberOfMoles()); + mixedStream.setThermoSystem(thermoSystem2); + // thermoSystem2.display(); + ThermodynamicOperations testOps = new ThermodynamicOperations(thermoSystem2); + if (streams.size() > 0) { + // mixedStream.getThermoSystem().setSolidPhaseCheck("CO2"); + mixedStream.getThermoSystem().setNumberOfPhases(2); + mixedStream.getThermoSystem().reInitPhaseType(); + mixedStream.getThermoSystem().init(0); + + mixStream(); + + enthalpy = calcMixStreamEnthalpy(); + // mixedStream.getThermoSystem().display(); + // System.out.println("temp guess " + guessTemperature()); + mixedStream.getThermoSystem().setSolidPhaseCheck("CO2"); + mixedStream.getThermoSystem().setTemperature(guessTemperature()); + testOps.PHsolidFlash(enthalpy); + mixedStream.getThermoSystem().display(); + // System.out.println("filan temp " + mixedStream.getTemperature()); + } else { + testOps.TPflash(); } + mixedStream.getThermoSystem().setSolidPhaseCheck(false); + // System.out.println("enthalpy: " + + // mixedStream.getThermoSystem().getEnthalpy()); + // System.out.println("enthalpy: " + enthalpy); + // System.out.println("temperature: " + + // mixedStream.getThermoSystem().getTemperature()); + + // System.out.println("beta " + mixedStream.getThermoSystem().getBeta()); + // outStream.setThermoSystem(mixedStream.getThermoSystem()); + mixedStream.setCalculationIdentifier(id); + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getGasOutStream() { + return new Stream("", mixedStream.getThermoSystem().phaseToSystem(0)); + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getLiquidOutStream() { + return new Stream("", mixedStream.getThermoSystem().phaseToSystem(1)); + } + + /** {@inheritDoc} */ + @Override + public double getTemperature() { + return temperature; + } + + /** {@inheritDoc} */ + @Override + public void setTemperature(double temperature) { + this.temperature = temperature; + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/expander/Expander.java b/src/main/java/neqsim/processSimulation/processEquipment/expander/Expander.java index a773929bda..f54973abe9 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/expander/Expander.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/expander/Expander.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.expander; +import java.util.UUID; import neqsim.processSimulation.processEquipment.compressor.Compressor; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -13,114 +14,113 @@ * @version $Id: $Id */ public class Expander extends Compressor implements ExpanderInterface { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for Expander. - *

- */ - @Deprecated - public Expander() { - super(); - } + /** + *

+ * Constructor for Expander. + *

+ */ + @Deprecated + public Expander() { + super(); + } - /** - *

- * Constructor for Expander. - *

- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public Expander(StreamInterface inletStream) { - super(inletStream); - } + /** + *

+ * Constructor for Expander. + *

+ * + * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + @Deprecated + public Expander(StreamInterface inletStream) { + super(inletStream); + } - /** - * Constructor for Expander. - * - * @param name name of unit operation - */ - public Expander(String name) { - super(name); - } + /** + * Constructor for Expander. + * + * @param name name of unit operation + */ + public Expander(String name) { + super(name); + } - /** - *

- * Constructor for Expander. - *

- * - * @param name a {@link java.lang.String} object - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - public Expander(String name, StreamInterface inletStream) { - super(name, inletStream); - } + /** + *

+ * Constructor for Expander. + *

+ * + * @param name a {@link java.lang.String} object + * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public Expander(String name, StreamInterface inletStream) { + super(name, inletStream); + } - /** {@inheritDoc} */ - @Override - public void run() { - // System.out.println("expander running.."); - thermoSystem = inStream.getThermoSystem().clone(); - ThermodynamicOperations thermoOps = new ThermodynamicOperations(getThermoSystem()); - thermoOps = new ThermodynamicOperations(thermoSystem); - thermoSystem.init(3); - // double presinn = getThermoSystem().getPressure(); - double hinn = getThermoSystem().getEnthalpy(); - // double densInn = getThermoSystem().getDensity(); - double entropy = getThermoSystem().getEntropy(); - inletEnthalpy = hinn; + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + // System.out.println("expander running.."); + thermoSystem = inStream.getThermoSystem().clone(); + ThermodynamicOperations thermoOps = new ThermodynamicOperations(getThermoSystem()); + thermoOps = new ThermodynamicOperations(thermoSystem); + thermoSystem.init(3); + // double presinn = getThermoSystem().getPressure(); + double hinn = getThermoSystem().getEnthalpy(); + // double densInn = getThermoSystem().getDensity(); + double entropy = getThermoSystem().getEntropy(); + inletEnthalpy = hinn; - if (usePolytropicCalc) { - int numbersteps = 40; - double dp = (pressure - getThermoSystem().getPressure()) / (1.0 * numbersteps); - for (int i = 0; i < numbersteps; i++) { - entropy = getThermoSystem().getEntropy(); - hinn = getThermoSystem().getEnthalpy(); - getThermoSystem().setPressure(getThermoSystem().getPressure() + dp); - thermoOps.PSflash(entropy); - double hout = - hinn + (getThermoSystem().getEnthalpy() - hinn) * polytropicEfficiency; - thermoOps.PHflash(hout, 0); - } - /* - * HYSYS method double oldPolyt = 10.5; int iter = 0; do { - * - * - * iter++; double n = Math.log(thermoSystem.getPressure() / presinn) / - * Math.log(thermoSystem.getDensity() / densInn); double k = - * Math.log(thermoSystem.getPressure() / presinn) / Math.log(densOutIdeal / densInn); - * double factor = ((Math.pow(thermoSystem.getPressure() / presinn, (n - 1.0) / n) - - * 1.0) * (n / (n - 1.0)) * (k - 1) / k) / (Math.pow(thermoSystem.getPressure() / - * presinn, (k - 1.0) / k) - 1.0); oldPolyt = polytropicEfficiency; polytropicEfficiency - * = factor * isentropicEfficiency; dH = thermoSystem.getEnthalpy() - hinn; hout = hinn - * + dH / polytropicEfficiency; thermoOps.PHflash(hout, 0); - * System.out.println(" factor " + factor + " n " + n + " k " + k + - * " polytropic effici " + polytropicEfficiency + " iter " + iter); - * - * } while (Math.abs((oldPolyt - polytropicEfficiency) / oldPolyt) > 1e-5 && iter < - * 500); // polytropicEfficiency = isentropicEfficiency * (); - * - */ - } else { - getThermoSystem().setPressure(pressure); + if (usePolytropicCalc) { + int numbersteps = 40; + double dp = (pressure - getThermoSystem().getPressure()) / (1.0 * numbersteps); + for (int i = 0; i < numbersteps; i++) { + entropy = getThermoSystem().getEntropy(); + hinn = getThermoSystem().getEnthalpy(); + getThermoSystem().setPressure(getThermoSystem().getPressure() + dp); + thermoOps.PSflash(entropy); + double hout = hinn + (getThermoSystem().getEnthalpy() - hinn) * polytropicEfficiency; + thermoOps.PHflash(hout, 0); + } + /* + * HYSYS method double oldPolyt = 10.5; int iter = 0; do { + * + * + * iter++; double n = Math.log(thermoSystem.getPressure() / presinn) / + * Math.log(thermoSystem.getDensity() / densInn); double k = + * Math.log(thermoSystem.getPressure() / presinn) / Math.log(densOutIdeal / densInn); double + * factor = ((Math.pow(thermoSystem.getPressure() / presinn, (n - 1.0) / n) - 1.0) * (n / (n - + * 1.0)) * (k - 1) / k) / (Math.pow(thermoSystem.getPressure() / presinn, (k - 1.0) / k) - + * 1.0); oldPolyt = polytropicEfficiency; polytropicEfficiency = factor * + * isentropicEfficiency; dH = thermoSystem.getEnthalpy() - hinn; hout = hinn + dH / + * polytropicEfficiency; thermoOps.PHflash(hout, 0); System.out.println(" factor " + factor + + * " n " + n + " k " + k + " polytropic effici " + polytropicEfficiency + " iter " + iter); + * + * } while (Math.abs((oldPolyt - polytropicEfficiency) / oldPolyt) > 1e-5 && iter < 500); // + * polytropicEfficiency = isentropicEfficiency * (); + * + */ + } else { + getThermoSystem().setPressure(pressure); - // System.out.println("entropy inn.." + entropy); - thermoOps.PSflash(entropy); - // double densOutIdeal = getThermoSystem().getDensity(); - if (!powerSet) { - dH = (getThermoSystem().getEnthalpy() - hinn) * isentropicEfficiency; - } - double hout = hinn + dH; - isentropicEfficiency = dH / (getThermoSystem().getEnthalpy() - hinn); - // System.out.println("isentropicEfficiency.. " + isentropicEfficiency); - dH = hout - hinn; - thermoOps.PHflash(hout, 0); - } - // thermoSystem.display(); - outStream.setThermoSystem(getThermoSystem()); + // System.out.println("entropy inn.." + entropy); + thermoOps.PSflash(entropy); + // double densOutIdeal = getThermoSystem().getDensity(); + if (!powerSet) { + dH = (getThermoSystem().getEnthalpy() - hinn) * isentropicEfficiency; + } + double hout = hinn + dH; + isentropicEfficiency = dH / (getThermoSystem().getEnthalpy() - hinn); + // System.out.println("isentropicEfficiency.. " + isentropicEfficiency); + dH = hout - hinn; + thermoOps.PHflash(hout, 0); } + // thermoSystem.display(); + outStream.setThermoSystem(getThermoSystem()); + setCalculationIdentifier(id); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/expander/ExpanderOld.java b/src/main/java/neqsim/processSimulation/processEquipment/expander/ExpanderOld.java index 53a294893d..b7b7257e2e 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/expander/ExpanderOld.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/expander/ExpanderOld.java @@ -4,6 +4,7 @@ import java.awt.FlowLayout; import java.text.DecimalFormat; import java.text.FieldPosition; +import java.util.UUID; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JScrollPane; @@ -56,7 +57,7 @@ public ExpanderOld(StreamInterface inletStream) { /** * Constructor for ExpanderOld. - * + * * @param name name of expander */ public ExpanderOld(String name) { @@ -68,7 +69,7 @@ public ExpanderOld(String name) { * Constructor for ExpanderOld. *

* - * @param name a {@link java.lang.String} object + * @param name name of expander * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} * object */ @@ -100,22 +101,21 @@ public double getEnergy() { /** {@inheritDoc} */ @Override - public void run() { + public void run(UUID id) { System.out.println("expander running.."); thermoSystem = inStream.getThermoSystem().clone(); thermoOps = new ThermodynamicOperations(thermoSystem); thermoSystem.init(3); - double hinn = thermoSystem.getEnthalpy(); double entropy = thermoSystem.getEntropy(); - thermoSystem.setPressure(pressure); System.out.println("entropy inn.." + entropy); + double hinn = thermoSystem.getEnthalpy(); + thermoSystem.setPressure(pressure); thermoOps.PSflash(entropy); dH = thermoSystem.getEnthalpy() - hinn; outStream.setThermoSystem(thermoSystem); + setCalculationIdentifier(id); } - - /** {@inheritDoc} */ @Override public void displayResult() { @@ -129,7 +129,6 @@ public void displayResult() { thermoSystem.initPhysicalProperties(); String[][] table = new String[20][5]; - String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"}; table[0][0] = ""; table[0][1] = ""; table[0][2] = ""; @@ -206,6 +205,7 @@ public void displayResult() { table[thermoSystem.getPhases()[0].getNumberOfComponents() + 13][4] = "-"; } + String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"}; JTable Jtab = new JTable(table, names); JScrollPane scrollpane = new JScrollPane(Jtab); dialogContentPane.add(scrollpane); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/filter/Filter.java b/src/main/java/neqsim/processSimulation/processEquipment/filter/Filter.java index 57f11bb14b..e78af11329 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/filter/Filter.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/filter/Filter.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.filter; +import java.util.UUID; import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface; import neqsim.processSimulation.processEquipment.TwoPortEquipment; import neqsim.processSimulation.processEquipment.stream.StreamInterface; @@ -48,7 +49,7 @@ public Filter(String name, StreamInterface inStream) { /** {@inheritDoc} */ @Override - public void run() { + public void run(UUID id) { SystemInterface system = inStream.getThermoSystem().clone(); if (Math.abs(getDeltaP()) > 1e-10) { system.setPressure(inStream.getPressure() - getDeltaP()); @@ -58,6 +59,7 @@ public void run() { system.initProperties(); outStream.setThermoSystem(system); Cv = Math.sqrt(deltaP) / inStream.getFlowRate("kg/hr"); + setCalculationIdentifier(id); } /** diff --git a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchanger.java b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchanger.java index 1b13b9331d..0e19295d06 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchanger.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchanger.java @@ -5,6 +5,7 @@ */ package neqsim.processSimulation.processEquipment.heatExchanger; +import java.util.UUID; import neqsim.processSimulation.conditionMonitor.ConditionMonitorSpecifications; import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface; import neqsim.processSimulation.processEquipment.stream.Stream; @@ -21,589 +22,593 @@ * @version $Id: $Id */ public class HeatExchanger extends Heater implements HeatExchangerInterface { - private static final long serialVersionUID = 1000; - - boolean setTemperature = false; - StreamInterface[] outStream = new Stream[2]; - StreamInterface[] inStream = new Stream[2]; - SystemInterface system; - double NTU; - protected double temperatureOut = 0, dT = 0.0; - double dH = 0.0; - private double UAvalue = 500.0; - double duty = 0.0; - private double hotColdDutyBalance = 1.0; - boolean firstTime = true; - public double guessOutTemperature = 273.15 + 130.0; - int outStreamSpecificationNumber = 0; - public double thermalEffectiveness = 0.0; - private String flowArrangement = "concentric tube counterflow"; - - /** - *

- * Constructor for HeatExchanger. - *

- */ - @Deprecated - public HeatExchanger() { - this("HeatExchanger"); - } - - /** - *

- * Constructor for HeatExchanger. - *

- * - * @param inStream1 a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public HeatExchanger(StreamInterface inStream1) { - this("HeatExchanger", inStream1); - } - - /** - *

- * Constructor for HeatExchanger. - *

- * - * @param inStream1 a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - * @param inStream2 a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public HeatExchanger(StreamInterface inStream1, StreamInterface inStream2) { - this("HeatExchanger", inStream1, inStream2); - } - - /** - * Constructor for HeatExchanger. - * - * @param name name of heat exchanger - */ - public HeatExchanger(String name) { - super(name); - } - - /** - * Constructor for HeatExchanger. - * - * @param name name of heat exchanger - * @param inStream1 input stream - */ - public HeatExchanger(String name, StreamInterface inStream1) { - this(name); - this.inStream[0] = inStream1; - this.inStream[1] = inStream1; - outStream[0] = inStream1.clone(); - outStream[1] = inStream1.clone(); - } - - /** - * Constructor for HeatExchanger. - * - * @param name name of heat exchanger - * @param inStream1 input stream 1 - * @param inStream2 input stream 2 - */ - public HeatExchanger(String name, StreamInterface inStream1, StreamInterface inStream2) { - this(name); - this.inStream[0] = inStream1; - this.inStream[1] = inStream2; - outStream[0] = inStream1.clone(); - outStream[1] = inStream2.clone(); - } - - /** - *

- * addInStream. - *

- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - public void addInStream(StreamInterface inStream) { - this.inStream[1] = inStream; - } - - /** - *

- * setFeedStream. - *

- * - * @param number a int - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - public void setFeedStream(int number, StreamInterface inStream) { - this.inStream[number] = inStream; - outStream[number] = inStream.clone(); - } - - /** {@inheritDoc} */ - @Override - public void setName(String name) { - super.setName(name); - outStream[0].setName(name + "_Sout1"); - outStream[1].setName(name + "_Sout2"); - } - - /** {@inheritDoc} */ - @Override - public void setdT(double dT) { - this.dT = dT; - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getOutStream(int i) { - return outStream[i]; - } - - /** - *

- * Getter for the field inStream. - *

- * - * @param i a int - * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ - public StreamInterface getInStream(int i) { - return inStream[i]; - } - - /** {@inheritDoc} */ - @Override - public void setOutTemperature(double temperature) { - this.temperatureOut = temperature; - } - - /** - *

- * getOutTemperature. - *

- * - * @param i a int - */ - public void getOutTemperature(int i) { - outStream[i].getThermoSystem().getTemperature(); - } - - /** - *

- * getInTemperature. - *

- * - * @param i a int - */ - public void getInTemperature(int i) { - inStream[i].getThermoSystem().getTemperature(); - } - - /** - *

- * Setter for the field outStream. - *

- * - * @param outStream the outStream to set - * @param streamNumber a int - */ - public void setOutStream(int streamNumber, StreamInterface outStream) { - this.outStream[streamNumber] = outStream; - outStreamSpecificationNumber = streamNumber; - } - - /** - *

- * runSpecifiedStream. - *

- */ - public void runSpecifiedStream() { - int nonOutStreamSpecifiedStreamNumber = 0; - if (outStreamSpecificationNumber == 0) { - nonOutStreamSpecifiedStreamNumber = 1; - } - - SystemInterface systemOut0 = - inStream[nonOutStreamSpecifiedStreamNumber].getThermoSystem().clone(); - // SystemInterface systemOut1 = - // inStream[outStreamSpecificationNumber].getThermoSystem().clone(); - - if (getSpecification().equals("out stream")) { - outStream[outStreamSpecificationNumber].setFlowRate( - getInStream(outStreamSpecificationNumber).getFlowRate("kg/sec"), "kg/sec"); - outStream[outStreamSpecificationNumber].run(); - temperatureOut = outStream[outStreamSpecificationNumber].getTemperature(); - // system = - // outStream[outStreamSpecificationNumber].getThermoSystem().clone(); - } - - double deltaEnthalpy = outStream[outStreamSpecificationNumber].getFluid().getEnthalpy() - - inStream[outStreamSpecificationNumber].getFluid().getEnthalpy(); - double enthalpyOutRef = inStream[nonOutStreamSpecifiedStreamNumber].getFluid().getEnthalpy() - - deltaEnthalpy; - - ThermodynamicOperations testOps = new ThermodynamicOperations(systemOut0); - testOps.PHflash(enthalpyOutRef); - System.out.println("out temperature " + systemOut0.getTemperature("C")); - outStream[nonOutStreamSpecifiedStreamNumber].setFluid(systemOut0); - } - - /** {@inheritDoc} */ - @Override - public void run() { - if (getSpecification().equals("out stream")) { - runSpecifiedStream(); - return; - } - - // inStream[0].run(); - // inStream[1].displayResult(); - if (firstTime) { - firstTime = false; - SystemInterface systemOut0 = inStream[0].getThermoSystem().clone(); - outStream[0].setThermoSystem(systemOut0); - outStream[0].getThermoSystem().setTemperature(guessOutTemperature); - outStream[0].run(); - run(); - return; - } - - double cP0 = inStream[0].getThermoSystem().getCp(); - double cP1 = inStream[1].getThermoSystem().getCp(); - int streamToCalculate = 0, streamToSet = 1; - - if (cP0 < cP1) { - // streamToCalculate = 1; - // streamToSet = 0; - } - SystemInterface systemOut0 = inStream[streamToSet].getThermoSystem().clone(); - SystemInterface systemOut1 = inStream[streamToCalculate].getThermoSystem().clone(); - - // systemOut1.setTemperature(inTemp1); - outStream[streamToSet].setThermoSystem(systemOut0); - outStream[streamToCalculate].setThermoSystem(systemOut1); - outStream[streamToSet].setTemperature( - inStream[streamToCalculate].getThermoSystem().getTemperature(), "K"); - outStream[streamToSet].getThermoSystem() - .setTemperature(inStream[streamToCalculate].getThermoSystem().getTemperature()); - if (!outStream[streamToSet].getSpecification().equals("TP")) { - outStream[streamToSet].runTPflash(); - } - outStream[streamToSet].run(); - double dEntalphy1 = outStream[streamToSet].getThermoSystem().getEnthalpy() - - inStream[streamToSet].getThermoSystem().getEnthalpy(); - double C1 = Math.abs(dEntalphy1) - / Math.abs((outStream[streamToSet].getThermoSystem().getTemperature() - - inStream[streamToSet].getThermoSystem().getTemperature())); - - outStream[streamToCalculate] - .setTemperature(inStream[streamToSet].getThermoSystem().getTemperature(), "K"); - outStream[streamToCalculate].getThermoSystem() - .setTemperature(inStream[streamToSet].getThermoSystem().getTemperature()); - if (!outStream[streamToCalculate].getSpecification().equals("TP")) { - outStream[streamToCalculate].runTPflash(); - } - outStream[streamToCalculate].run(); - double dEntalphy2 = outStream[streamToCalculate].getThermoSystem().getEnthalpy() - - inStream[streamToCalculate].getThermoSystem().getEnthalpy(); - double C2 = Math.abs(dEntalphy2) - / Math.abs(outStream[streamToCalculate].getThermoSystem().getTemperature() - - inStream[streamToCalculate].getThermoSystem().getTemperature()); - double Cmin = C1; - double Cmax = C2; - if (C2 < C1) { - Cmin = C2; - Cmax = C1; - } - double Cr = Cmin / Cmax; - if (Math.abs(dEntalphy1) > Math.abs(dEntalphy2)) { - int streamCHange = streamToCalculate; - streamToCalculate = streamToSet; - streamToSet = streamCHange; - } - - double dEntalphy = outStream[streamToSet].getThermoSystem().getEnthalpy() - - inStream[streamToSet].getThermoSystem().getEnthalpy(); - NTU = UAvalue / Cmin; - - thermalEffectiveness = calcThermalEffectivenes(NTU, Cr); - // double corrected_Entalphy = dEntalphy;// * - // inStream[1].getThermoSystem().getNumberOfMoles() / - // inStream[0].getThermoSystem().getNumberOfMoles(); - dEntalphy = thermalEffectiveness * dEntalphy; - // System.out.println("dent " + dEntalphy); - ThermodynamicOperations testOps = - new ThermodynamicOperations(outStream[streamToCalculate].getThermoSystem()); - testOps.PHflash(inStream[streamToCalculate].getThermoSystem().getEnthalpy() - dEntalphy, 0); - - if (Math.abs(thermalEffectiveness - 1.0) > 1e-10) { - testOps = new ThermodynamicOperations(outStream[streamToSet].getThermoSystem()); - testOps.PHflash(inStream[streamToSet].getThermoSystem().getEnthalpy() + dEntalphy, 0); - } - duty = dEntalphy; - hotColdDutyBalance = 1.0; - // outStream[0].displayResult(); - // outStream[1].displayResult(); - // System.out.println("temperatur Stream 1 out " + - // outStream[0].getTemperature()); - // System.out.println("temperatur Stream 0 out " + - // outStream[1].getTemperature()); - // outStream[0].setThermoSystem(systemOut0); - // System.out.println("temperature out " + - // outStream[streamToCalculate].getTemperature()); - /* - * if (systemOut0.getTemperature() <= inTemp1 - dT) { systemOut0.setTemperature(inTemp1); - * outStream[0].setThermoSystem(systemOut0); outStream[0].run(); //inStream[0].run(); - * - * dEntalphy = outStream[0].getThermoSystem().getEnthalpy() - - * inStream[0].getThermoSystem().getEnthalpy(); corrected_Entalphy = dEntalphy * - * inStream[0].getThermoSystem().getNumberOfMoles() / - * inStream[1].getThermoSystem().getNumberOfMoles(); - * - * systemOut1 = inStream[1].getThermoSystem().clone(); System.out.println("dent " + - * dEntalphy); testOps = new ThermodynamicOperations(systemOut1); - * testOps.PHflash(systemOut1.getEnthalpy() - corrected_Entalphy, 0); - * outStream[1].setThermoSystem(systemOut1); System.out.println("temperatur out " + - * outStream[1].getTemperature()); } - */ - } - - /** {@inheritDoc} */ - @Override - public double getDuty() { - return duty; - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - outStream[0].displayResult(); - outStream[1].displayResult(); - } - - /** - *

- * getUAvalue. - *

- * - * @return the UAvalue - */ - public double getUAvalue() { - return UAvalue; - } - - /** - *

- * setUAvalue. - *

- * - * @param UAvalue the UAvalue to set - */ - public void setUAvalue(double UAvalue) { - this.UAvalue = UAvalue; - } - - /** - *

- * Getter for the field guessOutTemperature. - *

- * - * @return a double - */ - public double getGuessOutTemperature() { - return guessOutTemperature; - } - - /** - *

- * Setter for the field guessOutTemperature. - *

- * - * @param guessOutTemperature a double - */ - public void setGuessOutTemperature(double guessOutTemperature) { - this.guessOutTemperature = guessOutTemperature; - } - - /** {@inheritDoc} */ - @Override - public double getEntropyProduction(String unit) { - double entrop = 0.0; - - for (int i = 0; i < 2; i++) { - inStream[i].run(); - inStream[i].getFluid().init(3); - outStream[i].run(); - outStream[i].getFluid().init(3); - entrop += outStream[i].getThermoSystem().getEntropy(unit) - - inStream[i].getThermoSystem().getEntropy(unit); - } - - int stream1 = 0; - int stream2 = 1; - if (inStream[0].getTemperature() < inStream[1].getTemperature()) { - stream2 = 0; - stream1 = 1; - } - double heatTransferEntropyProd = - Math.abs(getDuty()) * (1.0 / inStream[stream2].getTemperature() - - 1.0 / (inStream[stream1].getTemperature())); - // System.out.println("heat entropy " + heatTransferEntropyProd); - - return entrop + heatTransferEntropyProd; - } - - /** {@inheritDoc} */ - @Override - public double getMassBalance(String unit) { - double mass = 0.0; - - for (int i = 0; i < 2; i++) { - inStream[i].run(); - inStream[i].getFluid().init(3); - outStream[i].run(); - outStream[i].getFluid().init(3); - mass += outStream[i].getThermoSystem().getFlowRate(unit) - - inStream[i].getThermoSystem().getFlowRate(unit); - } - return mass; - } - - /** {@inheritDoc} */ - @Override - public void runConditionAnalysis(ProcessEquipmentInterface refExchanger) { - double heatBalanceError = 0.0; - conditionAnalysisMessage += name + " condition analysis started/"; - HeatExchanger refEx = (HeatExchanger) refExchanger; - for (int i = 0; i < 2; i++) { - inStream[i].getFluid().initProperties(); - outStream[i].getFluid().initProperties(); - heatBalanceError += outStream[i].getThermoSystem().getEnthalpy() - - inStream[i].getThermoSystem().getEnthalpy(); - - if (Math.abs(refEx.getInStream(i).getTemperature("C") - getInStream(i) - .getTemperature("C")) > ConditionMonitorSpecifications.HXmaxDeltaT) { - conditionAnalysisMessage += ConditionMonitorSpecifications.HXmaxDeltaT_ErrorMsg; - } else if (Math.abs(refEx.getOutStream(i).getTemperature("C") - getOutStream(i) - .getTemperature("C")) > ConditionMonitorSpecifications.HXmaxDeltaT) { - conditionAnalysisMessage += ConditionMonitorSpecifications.HXmaxDeltaT_ErrorMsg; - } - } - heatBalanceError = heatBalanceError / (outStream[0].getThermoSystem().getEnthalpy() - - inStream[0].getThermoSystem().getEnthalpy()) * 100.0; - if (Math.abs(heatBalanceError) > 10.0) { - String error = "Heat balance not fulfilled. Error: " + heatBalanceError + " "; - conditionAnalysisMessage += error; - } else { - String error = - "Heat balance ok. Enthalpy balance deviation: " + heatBalanceError + " %"; - conditionAnalysisMessage += error; - } - - conditionAnalysisMessage += name + "/analysis ended/"; - - // this.run(); - double duty1 = Math.abs(outStream[0].getThermoSystem().getEnthalpy() - - inStream[0].getThermoSystem().getEnthalpy()); - double duty2 = Math.abs(outStream[1].getThermoSystem().getEnthalpy() - - inStream[1].getThermoSystem().getEnthalpy()); - thermalEffectiveness = ((HeatExchanger) refExchanger).getThermalEffectiveness() - * (duty1 + duty2) / 2.0 / Math.abs(((HeatExchanger) refExchanger).getDuty()); - hotColdDutyBalance = duty1 / duty2; - } - - /** - *

- * runConditionAnalysis. - *

- */ - public void runConditionAnalysis() { - runConditionAnalysis(this); - } - - /** - *

- * Getter for the field thermalEffectiveness. - *

- * - * @return a double - */ - public double getThermalEffectiveness() { - return thermalEffectiveness; - } - - /** - *

- * Setter for the field thermalEffectiveness. - *

- * - * @param thermalEffectiveness a double - */ - public void setThermalEffectiveness(double thermalEffectiveness) { - this.thermalEffectiveness = thermalEffectiveness; - } - - /** - * @return String - */ - String getFlowArrangement() { - return flowArrangement; - } - - /** - * @param flowArrangement name of flow arrangement - */ - void setFlowArrangement(String flowArrangement) { - this.flowArrangement = flowArrangement; - } - - /** - *

- * calcThermalEffectivenes. - *

- * - * @param NTU a double - * @param Cr a double - * @return a double - */ - public double calcThermalEffectivenes(double NTU, double Cr) { - if (Cr == 0.0) { - return 1.0 - Math.exp(-NTU); - } - if (flowArrangement.equals("concentric tube counterflow")) { - if (Cr == 1.0) - return NTU / (1.0 + NTU); - else - return (1.0 - Math.exp(-NTU * (1 - Cr))) / (1.0 - Cr * Math.exp(-NTU * (1 - Cr))); - } else if (flowArrangement.equals("concentric tube paralellflow")) { - return (1.0 - Math.exp(-NTU * (1 + Cr))) / ((1 + Cr)); - } else if (flowArrangement.equals("shell and tube")) { - return (1.0 - Math.exp(-NTU * (1 - Cr))) / (1.0 - Cr * Math.exp(-NTU * (1 - Cr))); - } else - return (1.0 - Math.exp(-NTU * (1 - Cr))) / (1.0 - Cr * Math.exp(-NTU * (1 - Cr))); - } - - /** - *

- * Getter for the field hotColdDutyBalance. - *

- * - * @return a double - */ - public double getHotColdDutyBalance() { - return hotColdDutyBalance; - } - - /** - *

- * Setter for the field hotColdDutyBalance. - *

- * - * @param hotColdDutyBalance a double - */ - public void setHotColdDutyBalance(double hotColdDutyBalance) { - this.hotColdDutyBalance = hotColdDutyBalance; - } + private static final long serialVersionUID = 1000; + + boolean setTemperature = false; + StreamInterface[] outStream = new Stream[2]; + StreamInterface[] inStream = new Stream[2]; + SystemInterface system; + double NTU; + protected double temperatureOut = 0; + + protected double dT = 0.0; + + double dH = 0.0; + private double UAvalue = 500.0; + double duty = 0.0; + private double hotColdDutyBalance = 1.0; + boolean firstTime = true; + public double guessOutTemperature = 273.15 + 130.0; + int outStreamSpecificationNumber = 0; + public double thermalEffectiveness = 0.0; + private String flowArrangement = "concentric tube counterflow"; + + /** + *

+ * Constructor for HeatExchanger. + *

+ */ + @Deprecated + public HeatExchanger() { + this("HeatExchanger"); + } + + /** + *

+ * Constructor for HeatExchanger. + *

+ * + * @param inStream1 a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + @Deprecated + public HeatExchanger(StreamInterface inStream1) { + this("HeatExchanger", inStream1); + } + + /** + *

+ * Constructor for HeatExchanger. + *

+ * + * @param inStream1 a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + * @param inStream2 a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + @Deprecated + public HeatExchanger(StreamInterface inStream1, StreamInterface inStream2) { + this("HeatExchanger", inStream1, inStream2); + } + + /** + * Constructor for HeatExchanger. + * + * @param name name of heat exchanger + */ + public HeatExchanger(String name) { + super(name); + } + + /** + * Constructor for HeatExchanger. + * + * @param name name of heat exchanger + * @param inStream1 input stream + */ + public HeatExchanger(String name, StreamInterface inStream1) { + this(name); + this.inStream[0] = inStream1; + this.inStream[1] = inStream1; + outStream[0] = inStream1.clone(); + outStream[1] = inStream1.clone(); + } + + /** + * Constructor for HeatExchanger. + * + * @param name name of heat exchanger + * @param inStream1 input stream 1 + * @param inStream2 input stream 2 + */ + public HeatExchanger(String name, StreamInterface inStream1, StreamInterface inStream2) { + this(name); + this.inStream[0] = inStream1; + this.inStream[1] = inStream2; + outStream[0] = inStream1.clone(); + outStream[1] = inStream2.clone(); + } + + /** + *

+ * addInStream. + *

+ * + * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public void addInStream(StreamInterface inStream) { + this.inStream[1] = inStream; + } + + /** + *

+ * setFeedStream. + *

+ * + * @param number a int + * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public void setFeedStream(int number, StreamInterface inStream) { + this.inStream[number] = inStream; + outStream[number] = inStream.clone(); + } + + /** {@inheritDoc} */ + @Override + public void setName(String name) { + super.setName(name); + outStream[0].setName(name + "_Sout1"); + outStream[1].setName(name + "_Sout2"); + } + + /** {@inheritDoc} */ + @Override + public void setdT(double dT) { + this.dT = dT; + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getOutStream(int i) { + return outStream[i]; + } + + /** + *

+ * Getter for the field inStream. + *

+ * + * @param i a int + * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + public StreamInterface getInStream(int i) { + return inStream[i]; + } + + /** {@inheritDoc} */ + @Override + public void setOutTemperature(double temperature) { + this.temperatureOut = temperature; + } + + /** + *

+ * getOutTemperature. + *

+ * + * @param i a int + */ + public void getOutTemperature(int i) { + outStream[i].getThermoSystem().getTemperature(); + } + + /** + *

+ * getInTemperature. + *

+ * + * @param i a int + */ + public void getInTemperature(int i) { + inStream[i].getThermoSystem().getTemperature(); + } + + /** + *

+ * Setter for the field outStream. + *

+ * + * @param outStream the outStream to set + * @param streamNumber a int + */ + public void setOutStream(int streamNumber, StreamInterface outStream) { + this.outStream[streamNumber] = outStream; + outStreamSpecificationNumber = streamNumber; + } + + /** + *

+ * runSpecifiedStream. + *

+ */ + public void runSpecifiedStream(UUID id) { + int nonOutStreamSpecifiedStreamNumber = 0; + if (outStreamSpecificationNumber == 0) { + nonOutStreamSpecifiedStreamNumber = 1; + } + + SystemInterface systemOut0 = + inStream[nonOutStreamSpecifiedStreamNumber].getThermoSystem().clone(); + // SystemInterface systemOut1 = + // inStream[outStreamSpecificationNumber].getThermoSystem().clone(); + + if (getSpecification().equals("out stream")) { + outStream[outStreamSpecificationNumber] + .setFlowRate(getInStream(outStreamSpecificationNumber).getFlowRate("kg/sec"), "kg/sec"); + outStream[outStreamSpecificationNumber].run(id); + temperatureOut = outStream[outStreamSpecificationNumber].getTemperature(); + // system = + // outStream[outStreamSpecificationNumber].getThermoSystem().clone(); + } + + double deltaEnthalpy = outStream[outStreamSpecificationNumber].getFluid().getEnthalpy() + - inStream[outStreamSpecificationNumber].getFluid().getEnthalpy(); + double enthalpyOutRef = + inStream[nonOutStreamSpecifiedStreamNumber].getFluid().getEnthalpy() - deltaEnthalpy; + + ThermodynamicOperations testOps = new ThermodynamicOperations(systemOut0); + testOps.PHflash(enthalpyOutRef); + System.out.println("out temperature " + systemOut0.getTemperature("C")); + outStream[nonOutStreamSpecifiedStreamNumber].setFluid(systemOut0); + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + if (getSpecification().equals("out stream")) { + runSpecifiedStream(id); + } + // inStream[0].run(id); + // inStream[1].displayResult(); + else if (firstTime) { + firstTime = false; + SystemInterface systemOut0 = inStream[0].getThermoSystem().clone(); + outStream[0].setThermoSystem(systemOut0); + outStream[0].getThermoSystem().setTemperature(guessOutTemperature); + outStream[0].run(id); + run(id); + } else { + double cP0 = inStream[0].getThermoSystem().getCp(); + double cP1 = inStream[1].getThermoSystem().getCp(); + int streamToCalculate = 0; + + // if (cP0 < cP1) { + // streamToCalculate = 1; + // streamToSet = 0; + // } + + int streamToSet = 1; + SystemInterface systemOut0 = inStream[streamToSet].getThermoSystem().clone(); + SystemInterface systemOut1 = inStream[streamToCalculate].getThermoSystem().clone(); + + // systemOut1.setTemperature(inTemp1); + outStream[streamToSet].setThermoSystem(systemOut0); + outStream[streamToCalculate].setThermoSystem(systemOut1); + outStream[streamToSet] + .setTemperature(inStream[streamToCalculate].getThermoSystem().getTemperature(), "K"); + outStream[streamToSet].getThermoSystem() + .setTemperature(inStream[streamToCalculate].getThermoSystem().getTemperature()); + if (!outStream[streamToSet].getSpecification().equals("TP")) { + outStream[streamToSet].runTPflash(); + } + outStream[streamToSet].run(id); + double dEntalphy1 = outStream[streamToSet].getThermoSystem().getEnthalpy() + - inStream[streamToSet].getThermoSystem().getEnthalpy(); + double C1 = + Math.abs(dEntalphy1) / Math.abs((outStream[streamToSet].getThermoSystem().getTemperature() + - inStream[streamToSet].getThermoSystem().getTemperature())); + + outStream[streamToCalculate] + .setTemperature(inStream[streamToSet].getThermoSystem().getTemperature(), "K"); + outStream[streamToCalculate].getThermoSystem() + .setTemperature(inStream[streamToSet].getThermoSystem().getTemperature()); + if (!outStream[streamToCalculate].getSpecification().equals("TP")) { + outStream[streamToCalculate].runTPflash(); + } + outStream[streamToCalculate].run(id); + double dEntalphy2 = outStream[streamToCalculate].getThermoSystem().getEnthalpy() + - inStream[streamToCalculate].getThermoSystem().getEnthalpy(); + double C2 = Math.abs(dEntalphy2) + / Math.abs(outStream[streamToCalculate].getThermoSystem().getTemperature() + - inStream[streamToCalculate].getThermoSystem().getTemperature()); + double Cmin = C1; + double Cmax = C2; + if (C2 < C1) { + Cmin = C2; + Cmax = C1; + } + double Cr = Cmin / Cmax; + if (Math.abs(dEntalphy1) > Math.abs(dEntalphy2)) { + int streamCHange = streamToCalculate; + streamToCalculate = streamToSet; + streamToSet = streamCHange; + } + + double dEntalphy = outStream[streamToSet].getThermoSystem().getEnthalpy() + - inStream[streamToSet].getThermoSystem().getEnthalpy(); + NTU = UAvalue / Cmin; + + thermalEffectiveness = calcThermalEffectivenes(NTU, Cr); + // double corrected_Entalphy = dEntalphy;// * + // inStream[1].getThermoSystem().getNumberOfMoles() / + // inStream[0].getThermoSystem().getNumberOfMoles(); + dEntalphy = thermalEffectiveness * dEntalphy; + // System.out.println("dent " + dEntalphy); + ThermodynamicOperations testOps = + new ThermodynamicOperations(outStream[streamToCalculate].getThermoSystem()); + testOps.PHflash(inStream[streamToCalculate].getThermoSystem().getEnthalpy() - dEntalphy, 0); + + if (Math.abs(thermalEffectiveness - 1.0) > 1e-10) { + testOps = new ThermodynamicOperations(outStream[streamToSet].getThermoSystem()); + testOps.PHflash(inStream[streamToSet].getThermoSystem().getEnthalpy() + dEntalphy, 0); + } + duty = dEntalphy; + hotColdDutyBalance = 1.0; + // outStream[0].displayResult(); + // outStream[1].displayResult(); + // System.out.println("temperatur Stream 1 out " + + // outStream[0].getTemperature()); + // System.out.println("temperatur Stream 0 out " + + // outStream[1].getTemperature()); + // outStream[0].setThermoSystem(systemOut0); + // System.out.println("temperature out " + + // outStream[streamToCalculate].getTemperature()); + /* + * if (systemOut0.getTemperature() <= inTemp1 - dT) { systemOut0.setTemperature(inTemp1); + * outStream[0].setThermoSystem(systemOut0); outStream[0].run(); //inStream[0].run(); + * + * dEntalphy = outStream[0].getThermoSystem().getEnthalpy() - + * inStream[0].getThermoSystem().getEnthalpy(); corrected_Entalphy = dEntalphy * + * inStream[0].getThermoSystem().getNumberOfMoles() / + * inStream[1].getThermoSystem().getNumberOfMoles(); + * + * systemOut1 = inStream[1].getThermoSystem().clone(); System.out.println("dent " + + * dEntalphy); testOps = new ThermodynamicOperations(systemOut1); + * testOps.PHflash(systemOut1.getEnthalpy() - corrected_Entalphy, 0); + * outStream[1].setThermoSystem(systemOut1); System.out.println("temperatur out " + + * outStream[1].getTemperature()); } + */ + } + + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public double getDuty() { + return duty; + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + outStream[0].displayResult(); + outStream[1].displayResult(); + } + + /** + *

+ * getUAvalue. + *

+ * + * @return the UAvalue + */ + public double getUAvalue() { + return UAvalue; + } + + /** + *

+ * setUAvalue. + *

+ * + * @param UAvalue the UAvalue to set + */ + public void setUAvalue(double UAvalue) { + this.UAvalue = UAvalue; + } + + /** + *

+ * Getter for the field guessOutTemperature. + *

+ * + * @return a double + */ + public double getGuessOutTemperature() { + return guessOutTemperature; + } + + /** + *

+ * Setter for the field guessOutTemperature. + *

+ * + * @param guessOutTemperature a double + */ + public void setGuessOutTemperature(double guessOutTemperature) { + this.guessOutTemperature = guessOutTemperature; + } + + /** {@inheritDoc} */ + @Override + public double getEntropyProduction(String unit) { + double entrop = 0.0; + + for (int i = 0; i < 2; i++) { + inStream[i].run(); + inStream[i].getFluid().init(3); + outStream[i].run(); + outStream[i].getFluid().init(3); + entrop += outStream[i].getThermoSystem().getEntropy(unit) + - inStream[i].getThermoSystem().getEntropy(unit); + } + + int stream1 = 0; + int stream2 = 1; + if (inStream[0].getTemperature() < inStream[1].getTemperature()) { + stream2 = 0; + stream1 = 1; + } + double heatTransferEntropyProd = Math.abs(getDuty()) + * (1.0 / inStream[stream2].getTemperature() - 1.0 / (inStream[stream1].getTemperature())); + // System.out.println("heat entropy " + heatTransferEntropyProd); + + return entrop + heatTransferEntropyProd; + } + + /** {@inheritDoc} */ + @Override + public double getMassBalance(String unit) { + double mass = 0.0; + + for (int i = 0; i < 2; i++) { + inStream[i].run(); + inStream[i].getFluid().init(3); + outStream[i].run(); + outStream[i].getFluid().init(3); + mass += outStream[i].getThermoSystem().getFlowRate(unit) + - inStream[i].getThermoSystem().getFlowRate(unit); + } + return mass; + } + + /** {@inheritDoc} */ + @Override + public void runConditionAnalysis(ProcessEquipmentInterface refExchanger) { + double heatBalanceError = 0.0; + conditionAnalysisMessage += name + " condition analysis started/"; + HeatExchanger refEx = (HeatExchanger) refExchanger; + for (int i = 0; i < 2; i++) { + inStream[i].getFluid().initProperties(); + outStream[i].getFluid().initProperties(); + heatBalanceError += outStream[i].getThermoSystem().getEnthalpy() + - inStream[i].getThermoSystem().getEnthalpy(); + + if (Math.abs(refEx.getInStream(i).getTemperature("C") + - getInStream(i).getTemperature("C")) > ConditionMonitorSpecifications.HXmaxDeltaT) { + conditionAnalysisMessage += ConditionMonitorSpecifications.HXmaxDeltaT_ErrorMsg; + } else if (Math.abs(refEx.getOutStream(i).getTemperature("C") + - getOutStream(i).getTemperature("C")) > ConditionMonitorSpecifications.HXmaxDeltaT) { + conditionAnalysisMessage += ConditionMonitorSpecifications.HXmaxDeltaT_ErrorMsg; + } + } + heatBalanceError = heatBalanceError / (outStream[0].getThermoSystem().getEnthalpy() + - inStream[0].getThermoSystem().getEnthalpy()) * 100.0; + if (Math.abs(heatBalanceError) > 10.0) { + String error = "Heat balance not fulfilled. Error: " + heatBalanceError + " "; + conditionAnalysisMessage += error; + } else { + String error = "Heat balance ok. Enthalpy balance deviation: " + heatBalanceError + " %"; + conditionAnalysisMessage += error; + } + + conditionAnalysisMessage += name + "/analysis ended/"; + + // this.run(); + double duty1 = Math.abs( + outStream[0].getThermoSystem().getEnthalpy() - inStream[0].getThermoSystem().getEnthalpy()); + double duty2 = Math.abs( + outStream[1].getThermoSystem().getEnthalpy() - inStream[1].getThermoSystem().getEnthalpy()); + thermalEffectiveness = ((HeatExchanger) refExchanger).getThermalEffectiveness() + * (duty1 + duty2) / 2.0 / Math.abs(((HeatExchanger) refExchanger).getDuty()); + hotColdDutyBalance = duty1 / duty2; + } + + /** + *

+ * runConditionAnalysis. + *

+ */ + public void runConditionAnalysis() { + runConditionAnalysis(this); + } + + /** + *

+ * Getter for the field thermalEffectiveness. + *

+ * + * @return a double + */ + public double getThermalEffectiveness() { + return thermalEffectiveness; + } + + /** + *

+ * Setter for the field thermalEffectiveness. + *

+ * + * @param thermalEffectiveness a double + */ + public void setThermalEffectiveness(double thermalEffectiveness) { + this.thermalEffectiveness = thermalEffectiveness; + } + + /** + * @return String + */ + String getFlowArrangement() { + return flowArrangement; + } + + /** + * @param flowArrangement name of flow arrangement + */ + void setFlowArrangement(String flowArrangement) { + this.flowArrangement = flowArrangement; + } + + /** + *

+ * calcThermalEffectivenes. + *

+ * + * @param NTU a double + * @param Cr a double + * @return a double + */ + public double calcThermalEffectivenes(double NTU, double Cr) { + if (Cr == 0.0) { + return 1.0 - Math.exp(-NTU); + } + if (flowArrangement.equals("concentric tube counterflow")) { + if (Cr == 1.0) { + return NTU / (1.0 + NTU); + } else { + return (1.0 - Math.exp(-NTU * (1 - Cr))) / (1.0 - Cr * Math.exp(-NTU * (1 - Cr))); + } + } else if (flowArrangement.equals("concentric tube paralellflow")) { + return (1.0 - Math.exp(-NTU * (1 + Cr))) / ((1 + Cr)); + } else if (flowArrangement.equals("shell and tube")) { + return (1.0 - Math.exp(-NTU * (1 - Cr))) / (1.0 - Cr * Math.exp(-NTU * (1 - Cr))); + } else { + return (1.0 - Math.exp(-NTU * (1 - Cr))) / (1.0 - Cr * Math.exp(-NTU * (1 - Cr))); + } + } + + /** + *

+ * Getter for the field hotColdDutyBalance. + *

+ * + * @return a double + */ + public double getHotColdDutyBalance() { + return hotColdDutyBalance; + } + + /** + *

+ * Setter for the field hotColdDutyBalance. + *

+ * + * @param hotColdDutyBalance a double + */ + public void setHotColdDutyBalance(double hotColdDutyBalance) { + this.hotColdDutyBalance = hotColdDutyBalance; + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/Heater.java b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/Heater.java index 3a4805f33c..869d81e652 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/Heater.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/Heater.java @@ -5,6 +5,7 @@ */ package neqsim.processSimulation.processEquipment.heatExchanger; +import java.util.UUID; import neqsim.processSimulation.processEquipment.TwoPortEquipment; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; @@ -140,7 +141,7 @@ public void setOutTP(double temperature, double pressure) { /** {@inheritDoc} */ @Override - public void run() { + public void run(UUID id) { system = inStream.getThermoSystem().clone(); system.init(3); double oldH = system.getEnthalpy(); @@ -155,7 +156,7 @@ public void run() { ThermodynamicOperations testOps = new ThermodynamicOperations(system); if (getSpecification().equals("out stream")) { getOutletStream().setFlowRate(getInletStream().getFlowRate("kg/sec"), "kg/sec"); - getOutletStream().run(); + getOutletStream().run(id); temperatureOut = getOutletStream().getTemperature(); system = getOutletStream().getThermoSystem().clone(); } else if (setTemperature) { @@ -180,6 +181,7 @@ public void run() { // testOps.TPflash(); // system.setTemperature(temperatureOut); getOutletStream().setThermoSystem(system); + setCalculationIdentifier(id); } /** {@inheritDoc} */ @@ -310,16 +312,12 @@ public double getEntropyProduction(String unit) { /** {@inheritDoc} */ @Override public double getExergyChange(String unit, double surroundingTemperature) { - double entrop = 0.0; - inStream.run(); inStream.getFluid().init(3); outStream.run(); outStream.getFluid().init(3); - entrop += outStream.getThermoSystem().getExergy(surroundingTemperature, unit) + return outStream.getThermoSystem().getExergy(surroundingTemperature, unit) - inStream.getThermoSystem().getExergy(surroundingTemperature, unit); - - return entrop; } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/NeqHeater.java b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/NeqHeater.java index 3393c02231..afba049428 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/NeqHeater.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/NeqHeater.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.heatExchanger; +import java.util.UUID; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.thermo.system.SystemInterface; @@ -12,82 +13,85 @@ * @version $Id: $Id */ public class NeqHeater extends Heater { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - SystemInterface system; - double dH = 0.0; + SystemInterface system; + double dH = 0.0; - /** - *

- * Constructor for NeqHeater. - *

- */ - @Deprecated - public NeqHeater() { - this("NeqHeater"); - } + /** + *

+ * Constructor for NeqHeater. + *

+ */ + @Deprecated + public NeqHeater() { + this("NeqHeater"); + } - /** - *

- * Constructor for NeqHeater. - *

- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public NeqHeater(StreamInterface inStream) { - this("NeqHeater", inStream); - } + /** + *

+ * Constructor for NeqHeater. + *

+ * + * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + @Deprecated + public NeqHeater(StreamInterface inStream) { + this("NeqHeater", inStream); + } - /** - * Constructor for NeqHeater. - * - * @param name name of heater - */ - public NeqHeater(String name) { - super(name); - } + /** + * Constructor for NeqHeater. + * + * @param name name of heater + */ + public NeqHeater(String name) { + super(name); + } - /** - * Constructor for NeqHeater. - * - * @param name name of heater - * @param inStream input stream - */ - public NeqHeater(String name, StreamInterface inStream) { - super(name, inStream); - } + /** + * Constructor for NeqHeater. + * + * @param name name of heater + * @param inStream input stream + */ + public NeqHeater(String name, StreamInterface inStream) { + super(name, inStream); + } - /** {@inheritDoc} */ - @Override - public void setOutTemperature(double temperature) { - this.setTemperature = true; - this.temperatureOut = temperature; - } + /** {@inheritDoc} */ + @Override + public void setOutTemperature(double temperature) { + this.setTemperature = true; + this.temperatureOut = temperature; + } - /** {@inheritDoc} */ - @Override - public void run() { - system = inStream.getThermoSystem().clone(); - double oldH = system.getEnthalpy(); - if (setTemperature) { - system.setTemperature(temperatureOut); - } else { - system.setTemperature(system.getTemperature() + dT); - } - system.init(3); - double newH = system.getEnthalpy(); - dH = newH - oldH; - // system.setTemperature(temperatureOut); - // testOps.TPflash(); - // system.setTemperature(temperatureOut); - outStream.setThermoSystem(system); + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + system = inStream.getThermoSystem().clone(); + double oldH = system.getEnthalpy(); + if (setTemperature) { + system.setTemperature(temperatureOut); + } else { + system.setTemperature(system.getTemperature() + dT); } + system.init(3); + double newH = system.getEnthalpy(); + dH = newH - oldH; + // system.setTemperature(temperatureOut); + // testOps.TPflash(); + // system.setTemperature(temperatureOut); + outStream.setThermoSystem(system); - /** {@inheritDoc} */ - @Override - public void displayResult() { - System.out.println("heater dH: " + dH); - } + outStream.setCalculationIdentifier(id); + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + System.out.println("heater dH: " + dH); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/ReBoiler.java b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/ReBoiler.java index 7ba44b74d4..e07f86cf22 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/ReBoiler.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/ReBoiler.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.heatExchanger; +import java.util.UUID; import neqsim.processSimulation.processEquipment.TwoPortEquipment; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.thermo.system.SystemInterface; @@ -14,97 +15,99 @@ * @version $Id: $Id */ public class ReBoiler extends TwoPortEquipment { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - boolean setTemperature = false; - SystemInterface system; - private double reboilerDuty = 0.0; + boolean setTemperature = false; + SystemInterface system; + private double reboilerDuty = 0.0; - /** - *

- * Constructor for ReBoiler. - *

- */ - @Deprecated - public ReBoiler() { - super("ReBoiler"); - } + /** + *

+ * Constructor for ReBoiler. + *

+ */ + @Deprecated + public ReBoiler() { + super("ReBoiler"); + } - /** - *

- * Constructor for ReBoiler. - *

- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public ReBoiler(StreamInterface inStream) { - this("ReBoiler", inStream); - } + /** + *

+ * Constructor for ReBoiler. + *

+ * + * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + @Deprecated + public ReBoiler(StreamInterface inStream) { + this("ReBoiler", inStream); + } - /** - *

- * Constructor for ReBoiler. - *

- * - * @param name name of reboiler - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - public ReBoiler(String name, StreamInterface inStream) { - super(name, inStream); - } + /** + *

+ * Constructor for ReBoiler. + *

+ * + * @param name name of reboiler + * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public ReBoiler(String name, StreamInterface inStream) { + super(name, inStream); + } - /** {@inheritDoc} */ - @Override - public void run() { - system = inStream.getThermoSystem().clone(); - ThermodynamicOperations testOps = new ThermodynamicOperations(system); - testOps.TPflash(); - double oldH = system.getEnthalpy(); - testOps = new ThermodynamicOperations(system); - testOps.TPflash(); - testOps.PHflash(oldH + reboilerDuty, 0); - outStream.setThermoSystem(system); - // if(setTemperature) system.setTemperature(temperatureOut); - // else system.setTemperature(system.getTemperature()+dT); - // testOps = new ThermodynamicOperations(system); - // system.setTemperat ure(temperatureOut); - // testOps.TPflash(); - // double newH = system.getEnthalpy(); - // dH = newH - oldH; - // // system.setTemperature(temperatureOut); - // // testOps.TPflash(); - // // system.setTemperature(temperatureOut); - // outStream.setThermoSystem(system); - } + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + system = inStream.getThermoSystem().clone(); + ThermodynamicOperations testOps = new ThermodynamicOperations(system); + testOps.TPflash(); + double oldH = system.getEnthalpy(); + testOps = new ThermodynamicOperations(system); + testOps.TPflash(); + testOps.PHflash(oldH + reboilerDuty, 0); + outStream.setThermoSystem(system); + // if(setTemperature) system.setTemperature(temperatureOut); + // else system.setTemperature(system.getTemperature()+dT); + // testOps = new ThermodynamicOperations(system); + // system.setTemperat ure(temperatureOut); + // testOps.TPflash(); + // double newH = system.getEnthalpy(); + // dH = newH - oldH; + // // system.setTemperature(temperatureOut); + // // testOps.TPflash(); + // // system.setTemperature(temperatureOut); + // outStream.setThermoSystem(system); + outStream.setCalculationIdentifier(id); + setCalculationIdentifier(id); + } - /** {@inheritDoc} */ - @Override - public void displayResult() { - System.out.println("out Temperature " + reboilerDuty); - } + /** {@inheritDoc} */ + @Override + public void displayResult() { + System.out.println("out Temperature " + reboilerDuty); + } - /** - *

- * Getter for the field reboilerDuty. - *

- * - * @return a double - */ - public double getReboilerDuty() { - return reboilerDuty; - } + /** + *

+ * Getter for the field reboilerDuty. + *

+ * + * @return a double + */ + public double getReboilerDuty() { + return reboilerDuty; + } - /** - *

- * Setter for the field reboilerDuty. - *

- * - * @param reboilerDuty a double - */ - public void setReboilerDuty(double reboilerDuty) { - this.reboilerDuty = reboilerDuty; - } + /** + *

+ * Setter for the field reboilerDuty. + *

+ * + * @param reboilerDuty a double + */ + public void setReboilerDuty(double reboilerDuty) { + this.reboilerDuty = reboilerDuty; + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/mixer/Mixer.java b/src/main/java/neqsim/processSimulation/processEquipment/mixer/Mixer.java index 6b38d88a3b..ab4c34c4ac 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/mixer/Mixer.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/mixer/Mixer.java @@ -6,6 +6,7 @@ import java.text.FieldPosition; import java.util.ArrayList; import java.util.Objects; +import java.util.UUID; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JScrollPane; @@ -157,11 +158,12 @@ public void mixStream() { } } } - if (hasAddedNewComponent) + if (hasAddedNewComponent) { mixedStream.getThermoSystem().setMixingRule(mixedStream.getThermoSystem().getMixingRule()); - // mixedStream.getThermoSystem().init_x_y(); - // mixedStream.getThermoSystem().initBeta(); - // mixedStream.getThermoSystem().init(2); + // mixedStream.getThermoSystem().init_x_y(); + // mixedStream.getThermoSystem().initBeta(); + // mixedStream.getThermoSystem().init(2); + } } /** @@ -208,7 +210,7 @@ public StreamInterface getOutletStream() { /** {@inheritDoc} */ @Override - public void run() { + public void run(UUID id) { double enthalpy = 0.0; // ((Stream) streams.get(0)).getThermoSystem().display(); SystemInterface thermoSystem2 = streams.get(0).getThermoSystem().clone(); @@ -227,16 +229,17 @@ public void run() { enthalpy = calcMixStreamEnthalpy(); // System.out.println("temp guess " + guessTemperature()); - if (!isSetOutTemperature) { - mixedStream.getThermoSystem().setTemperature(guessTemperature()); - } else { + if (isSetOutTemperature) { mixedStream.setTemperature(outTemperature, "K"); + } else { + mixedStream.getThermoSystem().setTemperature(guessTemperature()); } // System.out.println("filan temp " + mixedStream.getTemperature()); } if (isSetOutTemperature) { - if (!Double.isNaN(getOutTemperature())) + if (!Double.isNaN(getOutTemperature())) { mixedStream.getThermoSystem().setTemperature(getOutTemperature()); + } testOps.TPflash(); mixedStream.getThermoSystem().init(2); } else { @@ -244,11 +247,13 @@ public void run() { testOps.PHflash(enthalpy, 0); } catch (Exception e) { logger.error(e.getMessage()); - if (!Double.isNaN(getOutTemperature())) + if (!Double.isNaN(getOutTemperature())) { mixedStream.getThermoSystem().setTemperature(getOutTemperature()); + } testOps.TPflash(); } } + mixedStream.setCalculationIdentifier(id); // System.out.println("enthalpy: " + // mixedStream.getThermoSystem().getEnthalpy()); @@ -258,12 +263,12 @@ public void run() { // System.out.println("beta " + mixedStream.getThermoSystem().getBeta()); // outStream.setThermoSystem(mixedStream.getThermoSystem()); + setCalculationIdentifier(id); } /** {@inheritDoc} */ @Override public void displayResult() { - SystemInterface thermoSystem = mixedStream.getThermoSystem(); DecimalFormat nf = new DecimalFormat(); nf.setMaximumFractionDigits(5); nf.applyPattern("#.#####E0"); @@ -272,9 +277,9 @@ public void displayResult() { Container dialogContentPane = dialog.getContentPane(); dialogContentPane.setLayout(new FlowLayout()); + SystemInterface thermoSystem = mixedStream.getThermoSystem(); thermoSystem.initPhysicalProperties(); String[][] table = new String[50][5]; - String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"}; table[0][0] = ""; table[0][1] = ""; table[0][2] = ""; @@ -353,6 +358,7 @@ public void displayResult() { table[thermoSystem.getPhases()[0].getNumberOfComponents() + 13][4] = "-"; } + String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"}; JTable Jtab = new JTable(table, names); JScrollPane scrollpane = new JScrollPane(Jtab); dialogContentPane.add(scrollpane); @@ -465,12 +471,15 @@ public int hashCode() { /** {@inheritDoc} */ @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (!super.equals(obj)) + } + if (!super.equals(obj)) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } Mixer other = (Mixer) obj; return isSetOutTemperature == other.isSetOutTemperature && Objects.equals(mixedStream, other.mixedStream) diff --git a/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticMixer.java b/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticMixer.java index 6122cdac1b..af834ff215 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticMixer.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticMixer.java @@ -5,6 +5,7 @@ */ package neqsim.processSimulation.processEquipment.mixer; +import java.util.UUID; import neqsim.thermodynamicOperations.ThermodynamicOperations; /** @@ -16,112 +17,109 @@ * @version $Id: $Id */ public class StaticMixer extends Mixer { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for StaticMixer. - *

- */ - @Deprecated - public StaticMixer() {} + /** + *

+ * Constructor for StaticMixer. + *

+ */ + @Deprecated + public StaticMixer() {} - /** - *

- * Constructor for StaticMixer. - *

- * - * @param name a {@link java.lang.String} object - */ - public StaticMixer(String name) { - super(name); - } + /** + *

+ * Constructor for StaticMixer. + *

+ * + * @param name a {@link java.lang.String} object + */ + public StaticMixer(String name) { + super(name); + } - /** {@inheritDoc} */ - @Override - public void mixStream() { - int index = 0; - String compName = new String(); - for (int k = 1; k < streams.size(); k++) { - for (int i = 0; i < streams.get(k).getThermoSystem().getPhases()[0] - .getNumberOfComponents(); i++) { - boolean gotComponent = false; - String componentName = - streams.get(k).getThermoSystem().getPhases()[0].getComponents()[i] - .getName(); - // System.out.println("adding: " + componentName); - double moles = streams.get(k).getThermoSystem().getPhases()[0].getComponents()[i] - .getNumberOfmoles(); - // System.out.println("moles: " + moles + " " + - // mixedStream.getThermoSystem().getPhases()[0].getNumberOfComponents()); - for (int p = 0; p < mixedStream.getThermoSystem().getPhases()[0] - .getNumberOfComponents(); p++) { - if (mixedStream.getThermoSystem().getPhases()[0].getComponents()[p].getName() - .equals(componentName)) { - gotComponent = true; - index = streams.get(0).getThermoSystem().getPhases()[0].getComponents()[p] - .getComponentNumber(); - compName = - streams.get(0).getThermoSystem().getPhases()[0].getComponents()[p] - .getComponentName(); - } - } + /** {@inheritDoc} */ + @Override + public void mixStream() { + int index = 0; + String compName = new String(); + for (int k = 1; k < streams.size(); k++) { + for (int i = 0; i < streams.get(k).getThermoSystem().getPhases()[0] + .getNumberOfComponents(); i++) { + boolean gotComponent = false; + String componentName = + streams.get(k).getThermoSystem().getPhases()[0].getComponents()[i].getName(); + // System.out.println("adding: " + componentName); + double moles = + streams.get(k).getThermoSystem().getPhases()[0].getComponents()[i].getNumberOfmoles(); + // System.out.println("moles: " + moles + " " + + // mixedStream.getThermoSystem().getPhases()[0].getNumberOfComponents()); + for (int p = 0; p < mixedStream.getThermoSystem().getPhases()[0] + .getNumberOfComponents(); p++) { + if (mixedStream.getThermoSystem().getPhases()[0].getComponents()[p].getName() + .equals(componentName)) { + gotComponent = true; + index = streams.get(0).getThermoSystem().getPhases()[0].getComponents()[p] + .getComponentNumber(); + compName = streams.get(0).getThermoSystem().getPhases()[0].getComponents()[p] + .getComponentName(); + } + } - if (gotComponent) { - // System.out.println("adding moles starting...."); - mixedStream.getThermoSystem().addComponent(index, moles, 0); - // mixedStream.getThermoSystem().init_x_y(); - // System.out.println("adding moles finished"); - } else { - // System.out.println("ikke gaa hit"); - mixedStream.getThermoSystem().addComponent(compName, moles, 0); - } - } + if (gotComponent) { + // System.out.println("adding moles starting...."); + mixedStream.getThermoSystem().addComponent(index, moles, 0); + // mixedStream.getThermoSystem().init_x_y(); + // System.out.println("adding moles finished"); + } else { + // System.out.println("ikke gaa hit"); + mixedStream.getThermoSystem().addComponent(compName, moles, 0); } + } } + } - /** {@inheritDoc} */ - @Override - public double guessTemperature() { - double gtemp = 0; - for (int k = 0; k < streams.size(); k++) { - gtemp += streams.get(k).getThermoSystem().getTemperature() - * streams.get(k).getThermoSystem().getNumberOfMoles() - / mixedStream.getThermoSystem().getNumberOfMoles(); - } - return gtemp; + /** {@inheritDoc} */ + @Override + public double guessTemperature() { + double gtemp = 0; + for (int k = 0; k < streams.size(); k++) { + gtemp += streams.get(k).getThermoSystem().getTemperature() + * streams.get(k).getThermoSystem().getNumberOfMoles() + / mixedStream.getThermoSystem().getNumberOfMoles(); } + return gtemp; + } - /** {@inheritDoc} */ - @Override - public double calcMixStreamEnthalpy() { - double enthalpy = 0; - for (int k = 0; k < streams.size(); k++) { - streams.get(k).getThermoSystem().init(3); - enthalpy += streams.get(k).getThermoSystem().getEnthalpy(); - System.out.println( - "total enthalpy k : " + streams.get(k).getThermoSystem().getEnthalpy()); - } - System.out.println("total enthalpy of streams: " + enthalpy); - return enthalpy; + /** {@inheritDoc} */ + @Override + public double calcMixStreamEnthalpy() { + double enthalpy = 0; + for (int k = 0; k < streams.size(); k++) { + streams.get(k).getThermoSystem().init(3); + enthalpy += streams.get(k).getThermoSystem().getEnthalpy(); + System.out.println("total enthalpy k : " + streams.get(k).getThermoSystem().getEnthalpy()); } + System.out.println("total enthalpy of streams: " + enthalpy); + return enthalpy; + } - /** {@inheritDoc} */ - @Override - public void run() { - double enthalpy = 0.0; - for (int k = 0; k < streams.size(); k++) { - streams.get(k).getThermoSystem().init(3); - enthalpy += streams.get(k).getThermoSystem().getEnthalpy(); - } - mixedStream.setThermoSystem((streams.get(0).getThermoSystem().clone())); - mixedStream.getThermoSystem().setNumberOfPhases(2); - mixedStream.getThermoSystem().reInitPhaseType(); - mixStream(); - ThermodynamicOperations testOps = - new ThermodynamicOperations(mixedStream.getThermoSystem()); - testOps.PHflash(enthalpy, 0); - // System.out.println("temp " + mixedStream.getThermoSystem().getTemperature()); - mixedStream.getThermoSystem().init(3); - } + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + double enthalpy = 0.0; + for (int k = 0; k < streams.size(); k++) { + streams.get(k).getThermoSystem().init(3); + enthalpy += streams.get(k).getThermoSystem().getEnthalpy(); + } + mixedStream.setThermoSystem((streams.get(0).getThermoSystem().clone())); + mixedStream.getThermoSystem().setNumberOfPhases(2); + mixedStream.getThermoSystem().reInitPhaseType(); + mixStream(); + ThermodynamicOperations testOps = new ThermodynamicOperations(mixedStream.getThermoSystem()); + testOps.PHflash(enthalpy, 0); + // System.out.println("temp " + mixedStream.getThermoSystem().getTemperature()); + mixedStream.getThermoSystem().init(3); + setCalculationIdentifier(id); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticNeqMixer.java b/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticNeqMixer.java index af9c953841..a8c027319e 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticNeqMixer.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticNeqMixer.java @@ -5,6 +5,7 @@ */ package neqsim.processSimulation.processEquipment.mixer; +import java.util.UUID; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -17,113 +18,113 @@ * @version $Id: $Id */ public class StaticNeqMixer extends StaticMixer { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for StaticNeqMixer. - *

- */ - @Deprecated - public StaticNeqMixer() {} + /** + *

+ * Constructor for StaticNeqMixer. + *

+ */ + @Deprecated + public StaticNeqMixer() {} - /** - *

- * Constructor for StaticNeqMixer. - *

- * - * @param name a {@link java.lang.String} object - */ - public StaticNeqMixer(String name) { - super(name); - } + /** + *

+ * Constructor for StaticNeqMixer. + *

+ * + * @param name a {@link java.lang.String} object + */ + public StaticNeqMixer(String name) { + super(name); + } - /** {@inheritDoc} */ - @Override - public void mixStream() { - int index = 0; - String compName = new String(); + /** {@inheritDoc} */ + @Override + public void mixStream() { + int index = 0; + String compName = new String(); - for (int k = 1; k < streams.size(); k++) { - for (int i = 0; i < streams.get(k).getThermoSystem().getPhases()[0] - .getNumberOfComponents(); i++) { - boolean gotComponent = false; - String componentName = - streams.get(k).getThermoSystem().getPhases()[0].getComponents()[i] - .getName(); - System.out.println("adding: " + componentName); - int numberOfPhases = streams.get(k).getThermoSystem().getNumberOfPhases(); - double[] moles = new double[numberOfPhases]; - // her maa man egentlig sjekke at phase typen er den samme !!! antar at begge er - // to fase elle gass - tofase - for (int p = 0; p < numberOfPhases; p++) { - moles[p] = streams.get(k).getThermoSystem().getPhases()[p].getComponents()[i] - .getNumberOfMolesInPhase(); - } - for (int p = 0; p < mixedStream.getThermoSystem().getPhases()[0] - .getNumberOfComponents(); p++) { - if (mixedStream.getThermoSystem().getPhases()[0].getComponents()[p].getName() - .equals(componentName)) { - gotComponent = true; - index = streams.get(0).getThermoSystem().getPhases()[0].getComponents()[p] - .getComponentNumber(); - compName = - streams.get(0).getThermoSystem().getPhases()[0].getComponents()[p] - .getComponentName(); - } - } + for (int k = 1; k < streams.size(); k++) { + for (int i = 0; i < streams.get(k).getThermoSystem().getPhases()[0] + .getNumberOfComponents(); i++) { + boolean gotComponent = false; + String componentName = + streams.get(k).getThermoSystem().getPhases()[0].getComponents()[i].getName(); + System.out.println("adding: " + componentName); + int numberOfPhases = streams.get(k).getThermoSystem().getNumberOfPhases(); + double[] moles = new double[numberOfPhases]; + // her maa man egentlig sjekke at phase typen er den samme !!! antar at begge er + // to fase elle gass - tofase + for (int p = 0; p < numberOfPhases; p++) { + moles[p] = streams.get(k).getThermoSystem().getPhases()[p].getComponents()[i] + .getNumberOfMolesInPhase(); + } + for (int p = 0; p < mixedStream.getThermoSystem().getPhases()[0] + .getNumberOfComponents(); p++) { + if (mixedStream.getThermoSystem().getPhases()[0].getComponents()[p].getName() + .equals(componentName)) { + gotComponent = true; + index = streams.get(0).getThermoSystem().getPhases()[0].getComponents()[p] + .getComponentNumber(); + compName = streams.get(0).getThermoSystem().getPhases()[0].getComponents()[p] + .getComponentName(); + } + } - if (gotComponent) { - System.out.println("adding moles starting...."); - for (int p = 0; p < numberOfPhases; p++) { - mixedStream.getThermoSystem().addComponent(index, moles[p], p); - } - System.out.println("adding moles finished"); - } else { - System.out.println("ikke gaa hit"); - for (int p = 0; p < numberOfPhases; p++) { - mixedStream.getThermoSystem().addComponent(compName, moles[p], p); - } - } - } + if (gotComponent) { + System.out.println("adding moles starting...."); + for (int p = 0; p < numberOfPhases; p++) { + mixedStream.getThermoSystem().addComponent(index, moles[p], p); + } + System.out.println("adding moles finished"); + } else { + System.out.println("ikke gaa hit"); + for (int p = 0; p < numberOfPhases; p++) { + mixedStream.getThermoSystem().addComponent(compName, moles[p], p); + } } - mixedStream.getThermoSystem().init_x_y(); - mixedStream.getThermoSystem().initBeta(); - mixedStream.getThermoSystem().init(2); + } } + mixedStream.getThermoSystem().init_x_y(); + mixedStream.getThermoSystem().initBeta(); + mixedStream.getThermoSystem().init(2); + } - /** {@inheritDoc} */ - @Override - public void run() { - double enthalpy = 0.0; - for (int k = 0; k < streams.size(); k++) { - streams.get(k).getThermoSystem().init(3); - enthalpy += streams.get(k).getThermoSystem().getEnthalpy(); - } + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + double enthalpy = 0.0; + for (int k = 0; k < streams.size(); k++) { + streams.get(k).getThermoSystem().init(3); + enthalpy += streams.get(k).getThermoSystem().getEnthalpy(); + } - mixedStream.setThermoSystem((streams.get(0).getThermoSystem().clone())); - mixedStream.getThermoSystem().setNumberOfPhases(2); - mixedStream.getThermoSystem().reInitPhaseType(); - mixStream(); + mixedStream.setThermoSystem((streams.get(0).getThermoSystem().clone())); + mixedStream.getThermoSystem().setNumberOfPhases(2); + mixedStream.getThermoSystem().reInitPhaseType(); + mixStream(); - SystemInterface syst = mixedStream.getThermoSystem().clone(); - syst.setTemperature(streams.get(0).getThermoSystem().getTemperature()); - syst.setPressure(streams.get(0).getThermoSystem().getPressure()); - ThermodynamicOperations testOps = new ThermodynamicOperations(syst); - testOps.PHflash(enthalpy, 0); - System.out.println("temp " + syst.getTemperature()); - mixedStream.getThermoSystem().setTemperature(syst.getTemperature()); - mixedStream.getThermoSystem().init(3); - // double enthalpy = calcMixStreamEnthalpy(); - // System.out.println("temp guess " + guessTemperature()); - // mixedStream.getThermoSystem().setTemperature(guessTemperature()); - // testOps = new ThermodynamicOperations(mixedStream.getThermoSystem()); - // testOps.TPflash(); - // testOps.PHflash(enthalpy, 0); - // System.out.println("enthalpy: " + - // mixedStream.getThermoSystem().getEnthalpy()); - // System.out.println("enthalpy: " + enthalpy); - // System.out.println("temperature: " + - // mixedStream.getThermoSystem().getTemperature()); - } + SystemInterface syst = mixedStream.getThermoSystem().clone(); + syst.setTemperature(streams.get(0).getThermoSystem().getTemperature()); + syst.setPressure(streams.get(0).getThermoSystem().getPressure()); + ThermodynamicOperations testOps = new ThermodynamicOperations(syst); + testOps.PHflash(enthalpy, 0); + System.out.println("temp " + syst.getTemperature()); + mixedStream.getThermoSystem().setTemperature(syst.getTemperature()); + mixedStream.getThermoSystem().init(3); + // double enthalpy = calcMixStreamEnthalpy(); + // System.out.println("temp guess " + guessTemperature()); + // mixedStream.getThermoSystem().setTemperature(guessTemperature()); + // testOps = new ThermodynamicOperations(mixedStream.getThermoSystem()); + // testOps.TPflash(); + // testOps.PHflash(enthalpy, 0); + // System.out.println("enthalpy: " + + // mixedStream.getThermoSystem().getEnthalpy()); + // System.out.println("enthalpy: " + enthalpy); + // System.out.println("temperature: " + + // mixedStream.getThermoSystem().getTemperature()); + mixedStream.setCalculationIdentifier(id); + setCalculationIdentifier(id); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticPhaseMixer.java b/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticPhaseMixer.java index e816cd93b0..0c8700e65d 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticPhaseMixer.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticPhaseMixer.java @@ -1,5 +1,7 @@ package neqsim.processSimulation.processEquipment.mixer; +import java.util.UUID; + /** *

* StaticPhaseMixer class. @@ -9,113 +11,113 @@ * @version $Id: $Id */ public class StaticPhaseMixer extends StaticMixer { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for StaticPhaseMixer. - *

- */ - @Deprecated - public StaticPhaseMixer() {} + /** + *

+ * Constructor for StaticPhaseMixer. + *

+ */ + @Deprecated + public StaticPhaseMixer() {} - /** - *

- * Constructor for StaticPhaseMixer. - *

- * - * @param name a {@link java.lang.String} object - */ - public StaticPhaseMixer(String name) { - super(name); - } + /** + *

+ * Constructor for StaticPhaseMixer. + *

+ * + * @param name a {@link java.lang.String} object + */ + public StaticPhaseMixer(String name) { + super(name); + } - /** {@inheritDoc} */ - @Override - public void mixStream() { - int index = 0; - String compName = new String(); + /** {@inheritDoc} */ + @Override + public void mixStream() { + int index = 0; + String compName = new String(); - for (int k = 1; k < streams.size(); k++) { - for (int i = 0; i < streams.get(k).getThermoSystem().getPhases()[0] - .getNumberOfComponents(); i++) { - boolean gotComponent = false; - String componentName = - streams.get(k).getThermoSystem().getPhases()[0].getComponents()[i] - .getName(); - System.out.println("adding: " + componentName); - int numberOfPhases = streams.get(k).getThermoSystem().getNumberOfPhases(); - double[] moles = new double[numberOfPhases]; - int[] phaseType = new int[numberOfPhases]; + for (int k = 1; k < streams.size(); k++) { + for (int i = 0; i < streams.get(k).getThermoSystem().getPhases()[0] + .getNumberOfComponents(); i++) { + boolean gotComponent = false; + String componentName = + streams.get(k).getThermoSystem().getPhases()[0].getComponents()[i].getName(); + System.out.println("adding: " + componentName); + int numberOfPhases = streams.get(k).getThermoSystem().getNumberOfPhases(); + double[] moles = new double[numberOfPhases]; + int[] phaseType = new int[numberOfPhases]; - // her maa man egentlig sjekke at phase typen er den samme !!! antar at begge er - // to fase elle gass - tofase - for (int p = 0; p < numberOfPhases; p++) { - moles[p] = streams.get(k).getThermoSystem().getPhase(p).getComponents()[i] - .getNumberOfMolesInPhase(); - phaseType[p] = streams.get(k).getThermoSystem().getPhase(p).getPhaseType(); - } - if (k == 1) { - phaseType[0] = 0; - mixedStream.getThermoSystem().getPhase(1) - .setTemperature(streams.get(k).getThermoSystem().getTemperature()); - } + // her maa man egentlig sjekke at phase typen er den samme !!! antar at begge er + // to fase elle gass - tofase + for (int p = 0; p < numberOfPhases; p++) { + moles[p] = streams.get(k).getThermoSystem().getPhase(p).getComponents()[i] + .getNumberOfMolesInPhase(); + phaseType[p] = streams.get(k).getThermoSystem().getPhase(p).getPhaseType(); + } + if (k == 1) { + phaseType[0] = 0; + mixedStream.getThermoSystem().getPhase(1) + .setTemperature(streams.get(k).getThermoSystem().getTemperature()); + } - for (int p = 0; p < mixedStream.getThermoSystem().getPhases()[0] - .getNumberOfComponents(); p++) { - if (mixedStream.getThermoSystem().getPhases()[0].getComponents()[p].getName() - .equals(componentName)) { - gotComponent = true; - index = streams.get(0).getThermoSystem().getPhases()[0].getComponents()[p] - .getComponentNumber(); - compName = - streams.get(0).getThermoSystem().getPhases()[0].getComponents()[p] - .getComponentName(); - } - } + for (int p = 0; p < mixedStream.getThermoSystem().getPhases()[0] + .getNumberOfComponents(); p++) { + if (mixedStream.getThermoSystem().getPhases()[0].getComponents()[p].getName() + .equals(componentName)) { + gotComponent = true; + index = streams.get(0).getThermoSystem().getPhases()[0].getComponents()[p] + .getComponentNumber(); + compName = streams.get(0).getThermoSystem().getPhases()[0].getComponents()[p] + .getComponentName(); + } + } - if (gotComponent) { - System.out.println("adding moles starting...."); - for (int p = 0; p < numberOfPhases; p++) { - if (phaseType[p] == 0) { - System.out.println("adding liq"); - mixedStream.getThermoSystem().addComponent(index, moles[p], 1); - } else if (phaseType[p] == 1) { - System.out.println("adding gas"); - mixedStream.getThermoSystem().addComponent(index, moles[p], 0); - } else { - System.out.println("not here...."); - } - } - System.out.println("adding moles finished"); - } else { - System.out.println("ikke gaa hit"); - for (int p = 0; p < numberOfPhases; p++) { - mixedStream.getThermoSystem().addComponent(compName, moles[p], p); - } - } + if (gotComponent) { + System.out.println("adding moles starting...."); + for (int p = 0; p < numberOfPhases; p++) { + if (phaseType[p] == 0) { + System.out.println("adding liq"); + mixedStream.getThermoSystem().addComponent(index, moles[p], 1); + } else if (phaseType[p] == 1) { + System.out.println("adding gas"); + mixedStream.getThermoSystem().addComponent(index, moles[p], 0); + } else { + System.out.println("not here...."); } + } + System.out.println("adding moles finished"); + } else { + System.out.println("ikke gaa hit"); + for (int p = 0; p < numberOfPhases; p++) { + mixedStream.getThermoSystem().addComponent(compName, moles[p], p); + } } - mixedStream.getThermoSystem().init_x_y(); - mixedStream.getThermoSystem().initBeta(); - mixedStream.getThermoSystem().init(2); + } } + mixedStream.getThermoSystem().init_x_y(); + mixedStream.getThermoSystem().initBeta(); + mixedStream.getThermoSystem().init(2); + } - /** {@inheritDoc} */ - @Override - public void run() { - for (int k = 0; k < streams.size(); k++) { - streams.get(k).getThermoSystem().init(3); - } + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + for (int k = 0; k < streams.size(); k++) { + streams.get(k).getThermoSystem().init(3); + } - mixedStream.setThermoSystem((streams.get(0).getThermoSystem().clone())); - mixedStream.getThermoSystem().init(0); - mixedStream.getThermoSystem().setBeta(1, 1e-10); - mixedStream.getThermoSystem().init(2); - mixedStream.getThermoSystem().reInitPhaseType(); + mixedStream.setThermoSystem((streams.get(0).getThermoSystem().clone())); + mixedStream.getThermoSystem().init(0); + mixedStream.getThermoSystem().setBeta(1, 1e-10); + mixedStream.getThermoSystem().init(2); + mixedStream.getThermoSystem().reInitPhaseType(); - mixStream(); + mixStream(); - mixedStream.getThermoSystem().init(3); - } + mixedStream.getThermoSystem().init(3); + mixedStream.setCalculationIdentifier(id); + setCalculationIdentifier(id); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticPipe.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticPipe.java index 336f463232..8e16bdeeac 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticPipe.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticPipe.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.pipeline; +import java.util.UUID; import neqsim.fluidMechanics.flowSystem.FlowSystemInterface; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; @@ -14,380 +15,385 @@ * @version $Id: $Id */ public class AdiabaticPipe extends Pipeline { - private static final long serialVersionUID = 1000; - - double inletPressure = 0; - boolean setTemperature = false, setPressureOut = false; - protected double temperatureOut = 270, pressureOut = 0.0; - double length = 100.0; - double insideDiameter = 0.1; - double velocity = 1.0; - double pipeWallRoughness = 1e-5; - private double inletElevation = 0; - private double outletElevation = 0; - double dH = 0.0; - String flowPattern = "unknown"; - String pipeSpecification = "AP02"; - - /** - *

- * Constructor for AdiabaticPipe. - *

- */ - @Deprecated - public AdiabaticPipe() { - this("AdiabaticPipe"); + private static final long serialVersionUID = 1000; + + double inletPressure = 0; + boolean setTemperature = false; + + boolean setPressureOut = false; + + protected double temperatureOut = 270; + + protected double pressureOut = 0.0; + + double length = 100.0; + double insideDiameter = 0.1; + double velocity = 1.0; + double pipeWallRoughness = 1e-5; + private double inletElevation = 0; + private double outletElevation = 0; + double dH = 0.0; + String flowPattern = "unknown"; + String pipeSpecification = "AP02"; + + /** + *

+ * Constructor for AdiabaticPipe. + *

+ */ + @Deprecated + public AdiabaticPipe() { + this("AdiabaticPipe"); + } + + /** + *

+ * Constructor for AdiabaticPipe. + *

+ * + * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + @Deprecated + public AdiabaticPipe(StreamInterface inStream) { + this("AdiabaticPipe", inStream); + } + + /** + * Constructor for AdiabaticPipe. + * + * @param name name of pipe + */ + public AdiabaticPipe(String name) { + super(name); + } + + /** + * Constructor for AdiabaticPipe. + * + * @param name name of pipe + * @param inStream input stream + */ + public AdiabaticPipe(String name, StreamInterface inStream) { + this(name); + this.inStream = inStream; + outStream = (Stream) inStream.clone(); + } + + /** + *

+ * Setter for the field pipeSpecification. + *

+ * + * @param nominalDiameter a double + * @param pipeSec a {@link java.lang.String} object + */ + public void setPipeSpecification(double nominalDiameter, String pipeSec) { + pipeSpecification = pipeSec; + insideDiameter = nominalDiameter / 1000.0; + } + + /** + *

+ * setOutTemperature. + *

+ * + * @param temperature a double + */ + public void setOutTemperature(double temperature) { + setTemperature = true; + this.temperatureOut = temperature; + } + + /** + *

+ * setOutPressure. + *

+ * + * @param pressure a double + */ + public void setOutPressure(double pressure) { + setPressureOut = true; + this.pressureOut = pressure; + } + + /** + *

+ * calcWallFrictionFactor. + *

+ * + * @param reynoldsNumber a double + * @return a double + */ + public double calcWallFrictionFactor(double reynoldsNumber) { + double relativeRoughnes = getPipeWallRoughness() / insideDiameter; + if (Math.abs(reynoldsNumber) < 2000) { + flowPattern = "laminar"; + return 64.0 / reynoldsNumber; + } else { + flowPattern = "turbulent"; + return Math.pow((1.0 + / (-1.8 * Math.log10(6.9 / reynoldsNumber + Math.pow(relativeRoughnes / 3.7, 1.11)))), + 2.0); } - - /** - *

- * Constructor for AdiabaticPipe. - *

- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public AdiabaticPipe(StreamInterface inStream) { - this("AdiabaticPipe", inStream); - } - - /** - * Constructor for AdiabaticPipe. - * - * @param name name of pipe - */ - public AdiabaticPipe(String name) { - super(name); - } - - /** - * Constructor for AdiabaticPipe. - * - * @param name name of pipe - * @param inStream input stream - */ - public AdiabaticPipe(String name, StreamInterface inStream) { - this(name); - this.inStream = inStream; - outStream = (Stream) inStream.clone(); - } - - /** - *

- * Setter for the field pipeSpecification. - *

- * - * @param nominalDiameter a double - * @param pipeSec a {@link java.lang.String} object - */ - public void setPipeSpecification(double nominalDiameter, String pipeSec) { - pipeSpecification = pipeSec; - insideDiameter = nominalDiameter / 1000.0; - } - - /** - *

- * setOutTemperature. - *

- * - * @param temperature a double - */ - public void setOutTemperature(double temperature) { - setTemperature = true; - this.temperatureOut = temperature; - } - - /** - *

- * setOutPressure. - *

- * - * @param pressure a double - */ - public void setOutPressure(double pressure) { - setPressureOut = true; - this.pressureOut = pressure; + } + + /** + *

+ * calcPressureOut. + *

+ * + * @return a double + */ + public double calcPressureOut() { + double area = Math.PI / 4.0 * Math.pow(insideDiameter, 2.0); + velocity = system.getPhase(0).getTotalVolume() / area / 1.0e5; + double reynoldsNumber = velocity * insideDiameter + / system.getPhase(0).getPhysicalProperties().getKinematicViscosity(); + double frictionFactor = calcWallFrictionFactor(reynoldsNumber); + double dp = Math + .pow(4.0 * system.getPhase(0).getNumberOfMolesInPhase() * system.getPhase(0).getMolarMass() + / neqsim.thermo.ThermodynamicConstantsInterface.pi, 2.0) + * frictionFactor * length * system.getPhase(0).getZ() + * neqsim.thermo.ThermodynamicConstantsInterface.R / system.getPhase(0).getMolarMass() + * system.getTemperature() / Math.pow(insideDiameter, 5.0); + // \\System.out.println("friction fact" + frictionFactor + " velocity " + + // velocity + " reynolds number " + reynoldsNumber); + System.out.println("dp gravity " + + system.getDensity("kg/m3") * neqsim.thermo.ThermodynamicConstantsInterface.gravity + * (inletElevation - outletElevation) / 1.0e5); + double dp_gravity = + system.getDensity("kg/m3") * neqsim.thermo.ThermodynamicConstantsInterface.gravity + * (inletElevation - outletElevation); + return Math.sqrt(Math.pow(inletPressure * 1e5, 2.0) - dp) / 1.0e5 + dp_gravity / 1.0e5; + } + + /** + *

+ * calcFlow. + *

+ * + * @return a double + */ + public double calcFlow() { + double averagePressue = (inletPressure + pressureOut) / 2.0; + system.setPressure(averagePressue); + system.init(1); + system.initPhysicalProperties(); + + double area = Math.PI / 4.0 * Math.pow(insideDiameter, 2.0); + double presdrop2 = Math.pow(inletPressure * 1e2, 2.0) - Math.pow(pressureOut * 1e2, 2.0); + double gasGravity = system.getMolarMass() / 0.028; + double oldReynold = 0; + double reynoldsNumber = -1000.0; + double flow = 0; + do { + oldReynold = reynoldsNumber; + velocity = system.getPhase(0).getTotalVolume() / area / 1.0e5; + reynoldsNumber = velocity * insideDiameter + / system.getPhase(0).getPhysicalProperties().getKinematicViscosity(); + double frictionFactor = calcWallFrictionFactor(reynoldsNumber) * 4.0; + double temp = Math.sqrt(presdrop2 * Math.pow(insideDiameter * 1000.0, 5.0) + / (gasGravity * system.getPhase(0).getZ() * system.getTemperature() * frictionFactor + * length / 1000.0)); + flow = 1.1494e-3 * 288.15 / (system.getPressure() * 100) * temp; + system.setTotalFlowRate(flow / 1e6, "MSm^3/day"); + system.init(1); + // System.out.println("flow " + flow + " velocity " + velocity); + } while (Math.abs(reynoldsNumber - oldReynold) / reynoldsNumber > 1e-3); + return flow; + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + system = inStream.getThermoSystem().clone(); + inletPressure = system.getPressure(); + // system.setMultiPhaseCheck(true); + if (setTemperature) { + system.setTemperature(this.temperatureOut); } - /** - *

- * calcWallFrictionFactor. - *

- * - * @param reynoldsNumber a double - * @return a double - */ - public double calcWallFrictionFactor(double reynoldsNumber) { - double relativeRoughnes = getPipeWallRoughness() / insideDiameter; - if (Math.abs(reynoldsNumber) < 2000) { - flowPattern = "laminar"; - return 64.0 / reynoldsNumber; - } else { - flowPattern = "turbulent"; - return Math.pow( - (1.0 / (-1.8 * Math - .log10(6.9 / reynoldsNumber + Math.pow(relativeRoughnes / 3.7, 1.11)))), - 2.0); - } - } - - /** - *

- * calcPressureOut. - *

- * - * @return a double - */ - public double calcPressureOut() { - double area = Math.PI / 4.0 * Math.pow(insideDiameter, 2.0); - velocity = system.getPhase(0).getTotalVolume() / area / 1.0e5; - double reynoldsNumber = velocity * insideDiameter - / system.getPhase(0).getPhysicalProperties().getKinematicViscosity(); - double frictionFactor = calcWallFrictionFactor(reynoldsNumber); - double dp = Math - .pow(4.0 * system.getPhase(0).getNumberOfMolesInPhase() - * system.getPhase(0).getMolarMass() - / neqsim.thermo.ThermodynamicConstantsInterface.pi, 2.0) - * frictionFactor * length * system.getPhase(0).getZ() - * neqsim.thermo.ThermodynamicConstantsInterface.R - / system.getPhase(0).getMolarMass() * system.getTemperature() - / Math.pow(insideDiameter, 5.0); - // \\System.out.println("friction fact" + frictionFactor + " velocity " + - // velocity + " reynolds number " + reynoldsNumber); - System.out.println("dp gravity " - + system.getDensity("kg/m3") * neqsim.thermo.ThermodynamicConstantsInterface.gravity - * (inletElevation - outletElevation) / 1.0e5); - double dp_gravity = - system.getDensity("kg/m3") * neqsim.thermo.ThermodynamicConstantsInterface.gravity - * (inletElevation - outletElevation); - return Math.sqrt(Math.pow(inletPressure * 1e5, 2.0) - dp) / 1.0e5 + dp_gravity / 1.0e5; - } - - /** - *

- * calcFlow. - *

- * - * @return a double - */ - public double calcFlow() { - double averagePressue = (inletPressure + pressureOut) / 2.0; - system.setPressure(averagePressue); - system.init(1); + double oldPressure = 0.0; + int iter = 0; + if (!setPressureOut) { + do { + iter++; + oldPressure = system.getPressure(); + system.init(3); system.initPhysicalProperties(); - - double area = Math.PI / 4.0 * Math.pow(insideDiameter, 2.0); - double presdrop2 = Math.pow(inletPressure * 1e2, 2.0) - Math.pow(pressureOut * 1e2, 2.0); - double gasGravity = system.getMolarMass() / 0.028; - double oldReynold = 0; - double reynoldsNumber = -1000.0; - double flow = 0; - do { - oldReynold = reynoldsNumber; - velocity = system.getPhase(0).getTotalVolume() / area / 1.0e5; - reynoldsNumber = velocity * insideDiameter - / system.getPhase(0).getPhysicalProperties().getKinematicViscosity(); - double frictionFactor = calcWallFrictionFactor(reynoldsNumber) * 4.0; - double temp = Math.sqrt(presdrop2 * Math.pow(insideDiameter * 1000.0, 5.0) - / (gasGravity * system.getPhase(0).getZ() * system.getTemperature() - * frictionFactor * length / 1000.0)); - flow = 1.1494e-3 * 288.15 / (system.getPressure() * 100) * temp; - system.setTotalFlowRate(flow / 1e6, "MSm^3/day"); - system.init(1); - // System.out.println("flow " + flow + " velocity " + velocity); - } while (Math.abs(reynoldsNumber - oldReynold) / reynoldsNumber > 1e-3); - return flow; - } - - /** {@inheritDoc} */ - @Override - public void run() { - system = inStream.getThermoSystem().clone(); - inletPressure = system.getPressure(); - // system.setMultiPhaseCheck(true); - if (setTemperature) { - system.setTemperature(this.temperatureOut); - } - - double oldPressure = 0.0; - int iter = 0; - if (!setPressureOut) { - do { - iter++; - oldPressure = system.getPressure(); - system.init(3); - system.initPhysicalProperties(); - system.setPressure(calcPressureOut()); - } while (Math.abs(system.getPressure() - oldPressure) > 1e-2 && iter < 25); - } else { - calcFlow(); - system.setPressure(pressureOut); - system.init(3); - } - ThermodynamicOperations testOps = new ThermodynamicOperations(system); - testOps.TPflash(); - if (setPressureOut) { - inStream.getThermoSystem().setTotalFlowRate(system.getFlowRate("kg/sec"), "kg/sec"); - } - // system.setMultiPhaseCheck(false); - outStream.setThermoSystem(system); - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - system.display(); - } - - /** {@inheritDoc} */ - @Override - public FlowSystemInterface getPipe() { - return null; + system.setPressure(calcPressureOut()); + } while (Math.abs(system.getPressure() - oldPressure) > 1e-2 && iter < 25); + } else { + calcFlow(); + system.setPressure(pressureOut); + system.init(3); } - - /** {@inheritDoc} */ - @Override - public void setInitialFlowPattern(String flowPattern) {} - - /** - *

- * Getter for the field length. - *

- * - * @return the length - */ - public double getLength() { - return length; - } - - /** - *

- * Setter for the field length. - *

- * - * @param length the length to set - */ - public void setLength(double length) { - this.length = length; - } - - /** - *

- * getDiameter. - *

- * - * @return the diameter - */ - public double getDiameter() { - return insideDiameter; - } - - /** - *

- * setDiameter. - *

- * - * @param diameter the diameter to set - */ - public void setDiameter(double diameter) { - this.insideDiameter = diameter; - } - - /** - *

- * Getter for the field pipeWallRoughness. - *

- * - * @return the pipeWallRoughness - */ - public double getPipeWallRoughness() { - return pipeWallRoughness; - } - - /** - *

- * Setter for the field pipeWallRoughness. - *

- * - * @param pipeWallRoughness the pipeWallRoughness to set - */ - public void setPipeWallRoughness(double pipeWallRoughness) { - this.pipeWallRoughness = pipeWallRoughness; - } - - /** - *

- * Getter for the field inletElevation. - *

- * - * @return the inletElevation - */ - public double getInletElevation() { - return inletElevation; - } - - /** - *

- * Setter for the field inletElevation. - *

- * - * @param inletElevation the inletElevation to set - */ - public void setInletElevation(double inletElevation) { - this.inletElevation = inletElevation; - } - - /** - *

- * Getter for the field outletElevation. - *

- * - * @return the outletElevation - */ - public double getOutletElevation() { - return outletElevation; - } - - /** - *

- * Setter for the field outletElevation. - *

- * - * @param outletElevation the outletElevation to set - */ - public void setOutletElevation(double outletElevation) { - this.outletElevation = outletElevation; - } - - /** - *

- * main. - *

- * - * @param name an array of {@link java.lang.String} objects - */ - public static void main(String[] name) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 5.0), 220.00); - testSystem.addComponent("methane", 24.0, "MSm^3/day"); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - testSystem.init(0); - - Stream stream_1 = new Stream("Stream1", testSystem); - - AdiabaticPipe pipe = new AdiabaticPipe(stream_1); - pipe.setLength(700000.0); - pipe.setDiameter(0.7112); - pipe.setPipeWallRoughness(5e-6); - pipe.setOutPressure(112.0); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(stream_1); - operations.add(pipe); - operations.run(); - pipe.displayResult(); + ThermodynamicOperations testOps = new ThermodynamicOperations(system); + testOps.TPflash(); + if (setPressureOut) { + inStream.getThermoSystem().setTotalFlowRate(system.getFlowRate("kg/sec"), "kg/sec"); } + // system.setMultiPhaseCheck(false); + outStream.setThermoSystem(system); + outStream.setCalculationIdentifier(id); + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + system.display(); + } + + /** {@inheritDoc} */ + @Override + public FlowSystemInterface getPipe() { + return null; + } + + /** {@inheritDoc} */ + @Override + public void setInitialFlowPattern(String flowPattern) {} + + /** + *

+ * Getter for the field length. + *

+ * + * @return the length + */ + public double getLength() { + return length; + } + + /** + *

+ * Setter for the field length. + *

+ * + * @param length the length to set + */ + public void setLength(double length) { + this.length = length; + } + + /** + *

+ * getDiameter. + *

+ * + * @return the diameter + */ + public double getDiameter() { + return insideDiameter; + } + + /** + *

+ * setDiameter. + *

+ * + * @param diameter the diameter to set + */ + public void setDiameter(double diameter) { + this.insideDiameter = diameter; + } + + /** + *

+ * Getter for the field pipeWallRoughness. + *

+ * + * @return the pipeWallRoughness + */ + public double getPipeWallRoughness() { + return pipeWallRoughness; + } + + /** + *

+ * Setter for the field pipeWallRoughness. + *

+ * + * @param pipeWallRoughness the pipeWallRoughness to set + */ + public void setPipeWallRoughness(double pipeWallRoughness) { + this.pipeWallRoughness = pipeWallRoughness; + } + + /** + *

+ * Getter for the field inletElevation. + *

+ * + * @return the inletElevation + */ + public double getInletElevation() { + return inletElevation; + } + + /** + *

+ * Setter for the field inletElevation. + *

+ * + * @param inletElevation the inletElevation to set + */ + public void setInletElevation(double inletElevation) { + this.inletElevation = inletElevation; + } + + /** + *

+ * Getter for the field outletElevation. + *

+ * + * @return the outletElevation + */ + public double getOutletElevation() { + return outletElevation; + } + + /** + *

+ * Setter for the field outletElevation. + *

+ * + * @param outletElevation the outletElevation to set + */ + public void setOutletElevation(double outletElevation) { + this.outletElevation = outletElevation; + } + + /** + *

+ * main. + *

+ * + * @param name an array of {@link java.lang.String} objects + */ + public static void main(String[] name) { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos((273.15 + 5.0), 220.00); + testSystem.addComponent("methane", 24.0, "MSm^3/day"); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + testSystem.init(0); + + Stream stream_1 = new Stream("Stream1", testSystem); + + AdiabaticPipe pipe = new AdiabaticPipe(stream_1); + pipe.setLength(700000.0); + pipe.setDiameter(0.7112); + pipe.setPipeWallRoughness(5e-6); + pipe.setOutPressure(112.0); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(pipe); + operations.run(); + pipe.displayResult(); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticTwoPhasePipe.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticTwoPhasePipe.java index 92353a409a..0a136025ae 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticTwoPhasePipe.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticTwoPhasePipe.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.pipeline; +import java.util.UUID; import neqsim.fluidMechanics.flowSystem.FlowSystemInterface; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; @@ -15,480 +16,488 @@ * @version $Id: $Id */ public class AdiabaticTwoPhasePipe extends Pipeline { - private static final long serialVersionUID = 1000; - - double inletPressure = 0; - boolean setTemperature = false, setPressureOut = false; - protected double temperatureOut = 270, pressureOut = 0.0; - - private double pressureOutLimit = 0.0; - double length = 100.0, flowLimit = 1e20; - String maxflowunit = "kg/hr"; - double insideDiameter = 0.1; - double velocity = 1.0; - double pipeWallRoughness = 1e-5; - private double inletElevation = 0; - private double outletElevation = 0; - double dH = 0.0; - String flowPattern = "unknown"; - String pipeSpecification = "AP02"; - - /** - *

- * Constructor for AdiabaticTwoPhasePipe. - *

- */ - @Deprecated - public AdiabaticTwoPhasePipe() { + private static final long serialVersionUID = 1000; + + double inletPressure = 0; + boolean setTemperature = false; + + boolean setPressureOut = false; + + protected double temperatureOut = 270; + + protected double pressureOut = 0.0; + + private double pressureOutLimit = 0.0; + double length = 100.0; + + double flowLimit = 1e20; + + String maxflowunit = "kg/hr"; + double insideDiameter = 0.1; + double velocity = 1.0; + double pipeWallRoughness = 1e-5; + private double inletElevation = 0; + private double outletElevation = 0; + double dH = 0.0; + String flowPattern = "unknown"; + String pipeSpecification = "AP02"; + + /** + *

+ * Constructor for AdiabaticTwoPhasePipe. + *

+ */ + @Deprecated + public AdiabaticTwoPhasePipe() {} + + /** + *

+ * Constructor for AdiabaticTwoPhasePipe. + *

+ * + * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + @Deprecated + public AdiabaticTwoPhasePipe(StreamInterface inStream) { + this("AdiabaticTwoPhasePipe", inStream); + } + + /** + * Constructor for AdiabaticTwoPhasePipe. + * + * @param name name of pipe + */ + public AdiabaticTwoPhasePipe(String name) { + super(name); + } + + /** + * Constructor for AdiabaticTwoPhasePipe. + * + * @param name name of pipe + * @param inStream input stream + */ + public AdiabaticTwoPhasePipe(String name, StreamInterface inStream) { + super(name, inStream); + } + + /** + *

+ * Setter for the field pipeSpecification. + *

+ * + * @param nominalDiameter a double + * @param pipeSec a {@link java.lang.String} object + */ + public void setPipeSpecification(double nominalDiameter, String pipeSec) { + pipeSpecification = pipeSec; + insideDiameter = nominalDiameter / 1000.0; + } + + /** {@inheritDoc} */ + @Override + public SystemInterface getThermoSystem() { + return outStream.getThermoSystem(); + } + + /** + *

+ * setOutTemperature. + *

+ * + * @param temperature a double + */ + public void setOutTemperature(double temperature) { + setTemperature = true; + this.temperatureOut = temperature; + } + + /** + *

+ * setOutPressure. + *

+ * + * @param pressure a double + */ + public void setOutPressure(double pressure) { + setPressureOut = true; + this.pressureOut = pressure; + } + + /** + *

+ * calcWallFrictionFactor. + *

+ * + * @param reynoldsNumber a double + * @return a double + */ + public double calcWallFrictionFactor(double reynoldsNumber) { + double relativeRoughnes = getPipeWallRoughness() / insideDiameter; + if (Math.abs(reynoldsNumber) < 2000) { + flowPattern = "laminar"; + return 64.0 / reynoldsNumber; + } else { + flowPattern = "turbulent"; + return Math.pow((1.0 + / (-1.8 * Math.log10(6.9 / reynoldsNumber + Math.pow(relativeRoughnes / 3.7, 1.11)))), + 2.0); } - - /** - *

- * Constructor for AdiabaticTwoPhasePipe. - *

- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public AdiabaticTwoPhasePipe(StreamInterface inStream) { - this("AdiabaticTwoPhasePipe", inStream); - } - - /** - * Constructor for AdiabaticTwoPhasePipe. - * - * @param name name of pipe - */ - public AdiabaticTwoPhasePipe(String name) { - super(name); - } - - /** - * Constructor for AdiabaticTwoPhasePipe. - * - * @param name name of pipe - * @param inStream input stream - */ - public AdiabaticTwoPhasePipe(String name, StreamInterface inStream) { - super(name, inStream); - } - - /** - *

- * Setter for the field pipeSpecification. - *

- * - * @param nominalDiameter a double - * @param pipeSec a {@link java.lang.String} object - */ - public void setPipeSpecification(double nominalDiameter, String pipeSec) { - pipeSpecification = pipeSec; - insideDiameter = nominalDiameter / 1000.0; - } - - /** {@inheritDoc} */ - @Override - public SystemInterface getThermoSystem() { - return outStream.getThermoSystem(); - } - - /** - *

- * setOutTemperature. - *

- * - * @param temperature a double - */ - public void setOutTemperature(double temperature) { - setTemperature = true; - this.temperatureOut = temperature; - } - - /** - *

- * setOutPressure. - *

- * - * @param pressure a double - */ - public void setOutPressure(double pressure) { - setPressureOut = true; - this.pressureOut = pressure; - } - - /** - *

- * calcWallFrictionFactor. - *

- * - * @param reynoldsNumber a double - * @return a double - */ - public double calcWallFrictionFactor(double reynoldsNumber) { - double relativeRoughnes = getPipeWallRoughness() / insideDiameter; - if (Math.abs(reynoldsNumber) < 2000) { - flowPattern = "laminar"; - return 64.0 / reynoldsNumber; - } else { - flowPattern = "turbulent"; - return Math.pow( - (1.0 / (-1.8 * Math - .log10(6.9 / reynoldsNumber + Math.pow(relativeRoughnes / 3.7, 1.11)))), - 2.0); - } + } + + /** + *

+ * calcPressureOut. + *

+ * + * @return a double + */ + public double calcPressureOut() { + double area = Math.PI / 4.0 * Math.pow(insideDiameter, 2.0); + velocity = system.getFlowRate("m3/sec") / area; + double reynoldsNumber = velocity * insideDiameter / system.getKinematicViscosity("m2/sec"); + double frictionFactor = calcWallFrictionFactor(reynoldsNumber); + double dp = 2.0 * frictionFactor * length * Math.pow(system.getFlowRate("kg/sec"), 2.0) + / insideDiameter / system.getDensity("kg/m3");// * () * + // neqsim.thermo.ThermodynamicConstantsInterface.R + // / system.getMolarMass() * system.getTemperature() / Math.pow(insideDiameter, + // 5.0); + // \\System.out.println("friction fact" + frictionFactor + " velocity " + + // velocity + " reynolds number " + reynoldsNumber); + // System.out.println("dp gravity " + + // system.getDensity("kg/m3")*neqsim.thermo.ThermodynamicConstantsInterface.gravity*(inletElevation-outletElevation)/1.0e5); + double dp_gravity = + system.getDensity("kg/m3") * neqsim.thermo.ThermodynamicConstantsInterface.gravity + * (inletElevation - outletElevation); + return (inletPressure * 1e5 - dp) / 1.0e5 + dp_gravity / 1.0e5; + } + + /** + *

+ * calcFlow. + *

+ * + * @param pressureOut a double + * @return a double + */ + public double calcFlow(double pressureOut) { + double averagePressue = (pressureOut + pressureOut) / 2.0; + system.setPressure(averagePressue); + ThermodynamicOperations testOps = new ThermodynamicOperations(system); + testOps.TPflash(); + system.initProperties(); + + double area = Math.PI / 4.0 * Math.pow(insideDiameter, 2.0); + double presdrop2 = Math.pow(inletPressure * 1e2, 2.0) - Math.pow(pressureOut * 1e2, 2.0); + double gasGravity = system.getMolarMass() / 0.028; + double oldReynold = 0; + double reynoldsNumber = -1000.0; + double flow = 0; + do { + oldReynold = reynoldsNumber; + velocity = system.getVolume("m3") / area; + reynoldsNumber = velocity * insideDiameter / system.getKinematicViscosity(); + double frictionFactor = calcWallFrictionFactor(reynoldsNumber) * 4.0; + double temp = Math.sqrt(presdrop2 * Math.pow(insideDiameter * 1000.0, 5.0) / (gasGravity + * system.getZ() * system.getTemperature() * frictionFactor * length / 1000.0)); + flow = 1.1494e-3 * 288.15 / (system.getPressure() * 100) * temp; + system.setTotalFlowRate(flow / 1e6, "MSm^3/day"); + testOps.TPflash(); + system.initProperties(); + // System.out.println("flow " + flow + " velocity " + velocity); + } while (Math.abs(reynoldsNumber - oldReynold) / reynoldsNumber > 1e-3); + return flow; + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + system = inStream.getThermoSystem().clone(); + inletPressure = system.getPressure(); + // system.setMultiPhaseCheck(true); + if (setTemperature) { + system.setTemperature(this.temperatureOut); } - /** - *

- * calcPressureOut. - *

- * - * @return a double - */ - public double calcPressureOut() { - double area = Math.PI / 4.0 * Math.pow(insideDiameter, 2.0); - velocity = system.getFlowRate("m3/sec") / area; - double reynoldsNumber = velocity * insideDiameter / system.getKinematicViscosity("m2/sec"); - double frictionFactor = calcWallFrictionFactor(reynoldsNumber); - double dp = 2.0 * frictionFactor * length * Math.pow(system.getFlowRate("kg/sec"), 2.0) - / insideDiameter / system.getDensity("kg/m3");// * () * - // neqsim.thermo.ThermodynamicConstantsInterface.R - // / system.getMolarMass() * system.getTemperature() / Math.pow(insideDiameter, - // 5.0); - // \\System.out.println("friction fact" + frictionFactor + " velocity " + - // velocity + " reynolds number " + reynoldsNumber); - // System.out.println("dp gravity " + - // system.getDensity("kg/m3")*neqsim.thermo.ThermodynamicConstantsInterface.gravity*(inletElevation-outletElevation)/1.0e5); - double dp_gravity = - system.getDensity("kg/m3") * neqsim.thermo.ThermodynamicConstantsInterface.gravity - * (inletElevation - outletElevation); - return (inletPressure * 1e5 - dp) / 1.0e5 + dp_gravity / 1.0e5; - } + ThermodynamicOperations testOps = new ThermodynamicOperations(system); + testOps.TPflash(); - /** - *

- * calcFlow. - *

- * - * @param pressureOut a double - * @return a double - */ - public double calcFlow(double pressureOut) { - double averagePressue = (pressureOut + pressureOut) / 2.0; - system.setPressure(averagePressue); - ThermodynamicOperations testOps = new ThermodynamicOperations(system); + double oldPressure = 0.0; + int iter = 0; + if (!setPressureOut) { + if (system.getFlowRate(maxflowunit) > flowLimit) { + system.setTotalFlowRate(flowLimit, maxflowunit); + testOps = new ThermodynamicOperations(system); testOps.TPflash(); + } + do { + iter++; + oldPressure = system.getPressure(); system.initProperties(); - - double area = Math.PI / 4.0 * Math.pow(insideDiameter, 2.0); - double presdrop2 = Math.pow(inletPressure * 1e2, 2.0) - Math.pow(pressureOut * 1e2, 2.0); - double gasGravity = system.getMolarMass() / 0.028; - double oldReynold = 0; - double reynoldsNumber = -1000.0; - double flow = 0; - do { - oldReynold = reynoldsNumber; - velocity = system.getVolume("m3") / area; - reynoldsNumber = velocity * insideDiameter / system.getKinematicViscosity(); - double frictionFactor = calcWallFrictionFactor(reynoldsNumber) * 4.0; - double temp = Math.sqrt(presdrop2 * Math.pow(insideDiameter * 1000.0, 5.0) / (gasGravity - * system.getZ() * system.getTemperature() * frictionFactor * length / 1000.0)); - flow = 1.1494e-3 * 288.15 / (system.getPressure() * 100) * temp; - system.setTotalFlowRate(flow / 1e6, "MSm^3/day"); - testOps.TPflash(); - system.initProperties(); - // System.out.println("flow " + flow + " velocity " + velocity); - } while (Math.abs(reynoldsNumber - oldReynold) / reynoldsNumber > 1e-3); - return flow; - } - - /** {@inheritDoc} */ - @Override - public void run() { - system = inStream.getThermoSystem().clone(); - inletPressure = system.getPressure(); - // system.setMultiPhaseCheck(true); - if (setTemperature) { - system.setTemperature(this.temperatureOut); - } - - ThermodynamicOperations testOps = new ThermodynamicOperations(system); - testOps.TPflash(); - - double oldPressure = 0.0; - int iter = 0; - if (!setPressureOut) { - if (system.getFlowRate(maxflowunit) > flowLimit) { - system.setTotalFlowRate(flowLimit, maxflowunit); - testOps = new ThermodynamicOperations(system); - testOps.TPflash(); - } - do { - iter++; - oldPressure = system.getPressure(); - system.initProperties(); - double outP = calcPressureOut(); - if (outP < 1e-10 || Double.isNaN(outP)) - break; - system.setPressure(outP); - testOps = new ThermodynamicOperations(system); - testOps.TPflash(); - } while (Math.abs(system.getPressure() - oldPressure) > 1e-2 && iter < 25); - if (system.getPressure() < pressureOutLimit) { - iter = 0; - double outP = system.getPressure(); - do { - iter++; - oldPressure = system.getNumberOfMoles(); - system.setTotalNumberOfMoles( - system.getNumberOfMoles() * outP / pressureOutLimit); - - // System.out.println("new moles " + - // system.getNumberOfMoles() + " outP "+ outP); - // outP = calcPressureOut(); - // System.out.println("out P " + outP + " oldP " + oldPressure); - testOps = new ThermodynamicOperations(system); - testOps.TPflash(); - system.initProperties(); - - outP = calcPressureOut(); - system.setPressure(outP); - - if (outP < 1e-10 || Double.isNaN(outP)) - break; - } while (Math.abs(system.getNumberOfMoles() - oldPressure) / oldPressure > 1e-3 - && iter < 3); - // calcFlow(pressureOutLimit); - // System.out.println("new moles " + - // system.getNumberOfMoles()*system.getPressure()/pressureOutLimit); - // System.out.println("flow " + system.getFlowRate(maxflowunit)); - } - if (system.getFlowRate(maxflowunit) > flowLimit) { - system.setTotalFlowRate(flowLimit, maxflowunit); - system.init(1); - } - inStream.getThermoSystem().setTotalFlowRate(system.getFlowRate(maxflowunit), - maxflowunit); - inStream.run(); - } else { - calcFlow(pressureOut); - inStream.getThermoSystem().setTotalFlowRate(system.getFlowRate("kg/sec"), "kg/sec"); - system.setPressure(pressureOut); - system.init(3); - if (system.getFlowRate(maxflowunit) > flowLimit) { - system.setTotalFlowRate(flowLimit, maxflowunit); - inStream.getThermoSystem().setTotalFlowRate(flowLimit, maxflowunit); - iter = 0; - do { - iter++; - oldPressure = system.getPressure(); - system.init(3); - system.initPhysicalProperties(); - system.setPressure(calcPressureOut()); - testOps = new ThermodynamicOperations(system); - testOps.TPflash(); - } while (Math.abs(system.getPressure() - oldPressure) > 1e-2 && iter < 25); - } + double outP = calcPressureOut(); + if (outP < 1e-10 || Double.isNaN(outP)) { + break; } + system.setPressure(outP); testOps = new ThermodynamicOperations(system); testOps.TPflash(); - System.out.println("flow rate " + system.getFlowRate(maxflowunit)); - // system.setMultiPhaseCheck(false); - outStream.setThermoSystem(system); - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - system.display(); - } - - /** {@inheritDoc} */ - @Override - public FlowSystemInterface getPipe() { - return null; - } - - /** {@inheritDoc} */ - @Override - public void setInitialFlowPattern(String flowPattern) {} - - /** - *

- * Getter for the field length. - *

- * - * @return the length - */ - public double getLength() { - return length; - } - - /** - *

- * Setter for the field length. - *

- * - * @param length the length to set - */ - public void setLength(double length) { - this.length = length; - } - - /** - *

- * getDiameter. - *

- * - * @return the diameter - */ - public double getDiameter() { - return insideDiameter; - } - - /** - *

- * setDiameter. - *

- * - * @param diameter the diameter to set - */ - public void setDiameter(double diameter) { - this.insideDiameter = diameter; - } - - /** - *

- * Getter for the field pipeWallRoughness. - *

- * - * @return the pipeWallRoughness - */ - public double getPipeWallRoughness() { - return pipeWallRoughness; - } - - /** - *

- * Setter for the field pipeWallRoughness. - *

- * - * @param pipeWallRoughness the pipeWallRoughness to set - */ - public void setPipeWallRoughness(double pipeWallRoughness) { - this.pipeWallRoughness = pipeWallRoughness; - } - - /** - *

- * Getter for the field inletElevation. - *

- * - * @return the inletElevation - */ - public double getInletElevation() { - return inletElevation; - } - - /** - *

- * Setter for the field inletElevation. - *

- * - * @param inletElevation the inletElevation to set - */ - public void setInletElevation(double inletElevation) { - this.inletElevation = inletElevation; - } - - /** - *

- * Getter for the field outletElevation. - *

- * - * @return the outletElevation - */ - public double getOutletElevation() { - return outletElevation; - } - - /** - *

- * Setter for the field outletElevation. - *

- * - * @param outletElevation the outletElevation to set - */ - public void setOutletElevation(double outletElevation) { - this.outletElevation = outletElevation; - } - - /** - *

- * main. - *

- * - * @param name an array of {@link java.lang.String} objects - */ - public static void main(String[] name) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 5.0), 100.00); - testSystem.addComponent("methane", 10.0, "MSm^3/day"); - testSystem.addComponent("n-heptane", 5.0, "MSm^3/day"); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - testSystem.init(0); - - Stream stream_1 = new Stream("Stream1", testSystem); - - AdiabaticTwoPhasePipe pipe = new AdiabaticTwoPhasePipe(stream_1); - pipe.setLength(100000.0); - pipe.setDiameter(0.5017112); - pipe.setPipeWallRoughness(10e-6); - // pipe.setOutPressure(112.0); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(stream_1); - operations.add(pipe); - operations.run(); - pipe.displayResult(); - System.out.println("flow " + pipe.getOutletStream().getFluid().getFlowRate("MSm3/day")); - } - - /** - *

- * Getter for the field pressureOutLimit. - *

- * - * @return a double - */ - public double getPressureOutLimit() { - return pressureOutLimit; - } - - /** - *

- * Setter for the field pressureOutLimit. - *

- * - * @param pressureOutLimit a double - */ - public void setPressureOutLimit(double pressureOutLimit) { - this.pressureOutLimit = pressureOutLimit; - } - - /** - *

- * Setter for the field flowLimit. - *

- * - * @param flowLimit a double - * @param unit a {@link java.lang.String} object - */ - public void setFlowLimit(double flowLimit, String unit) { - this.flowLimit = flowLimit; - maxflowunit = unit; + } while (Math.abs(system.getPressure() - oldPressure) > 1e-2 && iter < 25); + if (system.getPressure() < pressureOutLimit) { + iter = 0; + double outP = system.getPressure(); + do { + iter++; + oldPressure = system.getNumberOfMoles(); + system.setTotalNumberOfMoles(system.getNumberOfMoles() * outP / pressureOutLimit); + + // System.out.println("new moles " + + // system.getNumberOfMoles() + " outP "+ outP); + // outP = calcPressureOut(); + // System.out.println("out P " + outP + " oldP " + oldPressure); + testOps = new ThermodynamicOperations(system); + testOps.TPflash(); + system.initProperties(); + + outP = calcPressureOut(); + system.setPressure(outP); + + if (outP < 1e-10 || Double.isNaN(outP)) { + break; + } + } while (Math.abs(system.getNumberOfMoles() - oldPressure) / oldPressure > 1e-3 + && iter < 3); + // calcFlow(pressureOutLimit); + // System.out.println("new moles " + + // system.getNumberOfMoles()*system.getPressure()/pressureOutLimit); + // System.out.println("flow " + system.getFlowRate(maxflowunit)); + } + if (system.getFlowRate(maxflowunit) > flowLimit) { + system.setTotalFlowRate(flowLimit, maxflowunit); + system.init(1); + } + inStream.getThermoSystem().setTotalFlowRate(system.getFlowRate(maxflowunit), maxflowunit); + inStream.run(id); + } else { + calcFlow(pressureOut); + inStream.getThermoSystem().setTotalFlowRate(system.getFlowRate("kg/sec"), "kg/sec"); + system.setPressure(pressureOut); + system.init(3); + if (system.getFlowRate(maxflowunit) > flowLimit) { + system.setTotalFlowRate(flowLimit, maxflowunit); + inStream.getThermoSystem().setTotalFlowRate(flowLimit, maxflowunit); + iter = 0; + do { + iter++; + oldPressure = system.getPressure(); + system.init(3); + system.initPhysicalProperties(); + system.setPressure(calcPressureOut()); + testOps = new ThermodynamicOperations(system); + testOps.TPflash(); + } while (Math.abs(system.getPressure() - oldPressure) > 1e-2 && iter < 25); + } } + testOps = new ThermodynamicOperations(system); + testOps.TPflash(); + System.out.println("flow rate " + system.getFlowRate(maxflowunit)); + // system.setMultiPhaseCheck(false); + outStream.setThermoSystem(system); + outStream.setCalculationIdentifier(id); + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + system.display(); + } + + /** {@inheritDoc} */ + @Override + public FlowSystemInterface getPipe() { + return null; + } + + /** {@inheritDoc} */ + @Override + public void setInitialFlowPattern(String flowPattern) {} + + /** + *

+ * Getter for the field length. + *

+ * + * @return the length + */ + public double getLength() { + return length; + } + + /** + *

+ * Setter for the field length. + *

+ * + * @param length the length to set + */ + public void setLength(double length) { + this.length = length; + } + + /** + *

+ * getDiameter. + *

+ * + * @return the diameter + */ + public double getDiameter() { + return insideDiameter; + } + + /** + *

+ * setDiameter. + *

+ * + * @param diameter the diameter to set + */ + public void setDiameter(double diameter) { + this.insideDiameter = diameter; + } + + /** + *

+ * Getter for the field pipeWallRoughness. + *

+ * + * @return the pipeWallRoughness + */ + public double getPipeWallRoughness() { + return pipeWallRoughness; + } + + /** + *

+ * Setter for the field pipeWallRoughness. + *

+ * + * @param pipeWallRoughness the pipeWallRoughness to set + */ + public void setPipeWallRoughness(double pipeWallRoughness) { + this.pipeWallRoughness = pipeWallRoughness; + } + + /** + *

+ * Getter for the field inletElevation. + *

+ * + * @return the inletElevation + */ + public double getInletElevation() { + return inletElevation; + } + + /** + *

+ * Setter for the field inletElevation. + *

+ * + * @param inletElevation the inletElevation to set + */ + public void setInletElevation(double inletElevation) { + this.inletElevation = inletElevation; + } + + /** + *

+ * Getter for the field outletElevation. + *

+ * + * @return the outletElevation + */ + public double getOutletElevation() { + return outletElevation; + } + + /** + *

+ * Setter for the field outletElevation. + *

+ * + * @param outletElevation the outletElevation to set + */ + public void setOutletElevation(double outletElevation) { + this.outletElevation = outletElevation; + } + + /** + *

+ * main. + *

+ * + * @param name an array of {@link java.lang.String} objects + */ + public static void main(String[] name) { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos((273.15 + 5.0), 100.00); + testSystem.addComponent("methane", 10.0, "MSm^3/day"); + testSystem.addComponent("n-heptane", 5.0, "MSm^3/day"); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + testSystem.init(0); + + Stream stream_1 = new Stream("Stream1", testSystem); + + AdiabaticTwoPhasePipe pipe = new AdiabaticTwoPhasePipe(stream_1); + pipe.setLength(100000.0); + pipe.setDiameter(0.5017112); + pipe.setPipeWallRoughness(10e-6); + // pipe.setOutPressure(112.0); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(pipe); + operations.run(); + pipe.displayResult(); + System.out.println("flow " + pipe.getOutletStream().getFluid().getFlowRate("MSm3/day")); + } + + /** + *

+ * Getter for the field pressureOutLimit. + *

+ * + * @return a double + */ + public double getPressureOutLimit() { + return pressureOutLimit; + } + + /** + *

+ * Setter for the field pressureOutLimit. + *

+ * + * @param pressureOutLimit a double + */ + public void setPressureOutLimit(double pressureOutLimit) { + this.pressureOutLimit = pressureOutLimit; + } + + /** + *

+ * Setter for the field flowLimit. + *

+ * + * @param flowLimit a double + * @param unit a {@link java.lang.String} object + */ + public void setFlowLimit(double flowLimit, String unit) { + this.flowLimit = flowLimit; + maxflowunit = unit; + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/IncompressiblePipeFlow.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/IncompressiblePipeFlow.java index 3d3c7b1f75..ea33e69752 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/IncompressiblePipeFlow.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/IncompressiblePipeFlow.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.pipeline; +import java.util.UUID; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -13,190 +14,192 @@ * @version $Id: $Id */ public class IncompressiblePipeFlow extends AdiabaticPipe { - private static final long serialVersionUID = 1000; - - Fittings fittings = new Fittings(); - private double totalEqLenth = 0; - double momentum = 0; - - /** - *

- * Constructor for IncompressiblePipeFlow. - *

- */ - @Deprecated - public IncompressiblePipeFlow() { - super("IncompressiblePipeFlow"); + private static final long serialVersionUID = 1000; + + Fittings fittings = new Fittings(); + private double totalEqLenth = 0; + double momentum = 0; + + /** + *

+ * Constructor for IncompressiblePipeFlow. + *

+ */ + @Deprecated + public IncompressiblePipeFlow() { + super("IncompressiblePipeFlow"); + } + + /** + *

+ * Constructor for IncompressiblePipeFlow. + *

+ * + * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + @Deprecated + public IncompressiblePipeFlow(StreamInterface inStream) { + this("IncompressiblePipeFlow", inStream); + } + + /** + * Constructor for IncompressiblePipeFlow. + * + * @param name name of pipeline + */ + public IncompressiblePipeFlow(String name) { + super(name); + } + + /** + * * Constructor for IncompressiblePipeFlow. + * + * @param name name of pipe + * @param inStream input stream + */ + public IncompressiblePipeFlow(String name, StreamInterface inStream) { + super(name, inStream); + } + + /** + *

+ * addFittingFromDatabase. + *

+ * + * @param name a {@link java.lang.String} object + */ + public void addFittingFromDatabase(String name) { + fittings.add(name); + } + + /** + *

+ * addFitting. + *

+ * + * @param name a {@link java.lang.String} object + * @param LdivD a double + */ + public void addFitting(String name, double LdivD) { + fittings.add(name, LdivD); + } + + /** {@inheritDoc} */ + @Override + public double calcPressureOut() { + setTotalEqLenth(length); + + for (int i = 0; i < fittings.fittingList.size(); i++) { + setTotalEqLenth(getTotalEqLenth() + fittings.getFittingsList().get(i).getLtoD()); } - /** - *

- * Constructor for IncompressiblePipeFlow. - *

- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public IncompressiblePipeFlow(StreamInterface inStream) { - this("IncompressiblePipeFlow", inStream); - } - - /** - * Constructor for IncompressiblePipeFlow. - * - * @param name name of pipeline - */ - public IncompressiblePipeFlow(String name) { - super(name); - } - - /** - * * Constructor for IncompressiblePipeFlow. - * - * @param name name of pipe - * @param inStream input stream - */ - public IncompressiblePipeFlow(String name, StreamInterface inStream) { - super(name, inStream); - } - - /** - *

- * addFittingFromDatabase. - *

- * - * @param name a {@link java.lang.String} object - */ - public void addFittingFromDatabase(String name) { - fittings.add(name); - } - - /** - *

- * addFitting. - *

- * - * @param name a {@link java.lang.String} object - * @param LdivD a double - */ - public void addFitting(String name, double LdivD) { - fittings.add(name, LdivD); - } - - /** {@inheritDoc} */ - @Override - public double calcPressureOut() { - setTotalEqLenth(length); - - for (int i = 0; i < fittings.fittingList.size(); i++) { - setTotalEqLenth(getTotalEqLenth() + fittings.getFittingsList().get(i).getLtoD()); - } - - double area = 3.14 / 4.0 * Math.pow(insideDiameter, 2.0); - double velocity = 1.0 / system.getPhase(0).getPhysicalProperties().getDensity() - / (system.getPhase(0).getNumberOfMolesInPhase() - * (system.getPhase(0).getMolarVolume() / 1e5)) - / area; - - momentum = system.getPhase(0).getPhysicalProperties().getDensity() * velocity * velocity; - double reynoldsNumber = velocity * insideDiameter - / system.getPhase(0).getPhysicalProperties().getKinematicViscosity(); - double frictionFactor = calcWallFrictionFactor(reynoldsNumber); - - double dp = -momentum * frictionFactor * getTotalEqLenth() / (2.0 * insideDiameter); - dp += (getInletElevation() - getOutletElevation()) - * system.getPhase(0).getPhysicalProperties().getDensity() - * neqsim.thermo.ThermodynamicConstantsInterface.gravity; - - // double dp = Math.pow(4.0 * system.getPhase(0).getNumberOfMolesInPhase() * - // system.getPhase(0).getMolarMass()/thermo.ThermodynamicConstantsInterface.pi, - // 2.0) * frictionFactor * length * system.getPhase(0).getZ() * - // thermo.ThermodynamicConstantsInterface.R/system.getPhase(0).getMolarMass() * - // system.getTemperature() / Math.pow(insideDiameter, 5.0); - System.out.println("outpres " + ((system.getPressure() * 1e5 + dp) / 1.0e5) + " dp " + dp - + " friction fact" + frictionFactor + " velocity " + velocity + " reynolds number " - + reynoldsNumber + " equivalentLength " + getTotalEqLenth()); - - return (system.getPressure() * 1e5 + dp) / 1.0e5; - } - - /** {@inheritDoc} */ - @Override - public void run() { - system = inStream.getThermoSystem().clone(); - // system.setMultiPhaseCheck(true); - if (setTemperature) { - system.setTemperature(this.temperatureOut); - } - system.init(3); - system.initPhysicalProperties(); - calcPressureOut(); - system.setPressure(calcPressureOut()); - - ThermodynamicOperations testOps = new ThermodynamicOperations(system); - testOps.TPflash(); - // system.setMultiPhaseCheck(false); - outStream.setThermoSystem(system); - } - - /** - *

- * main. - *

- * - * @param name an array of {@link java.lang.String} objects - */ - public static void main(String[] name) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); - testSystem.addComponent("water", 100.0 * 1e3, "kg/hr"); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - testSystem.initPhysicalProperties(); - Stream stream_1 = new Stream("Stream1", testSystem); - - IncompressiblePipeFlow pipe = new IncompressiblePipeFlow(stream_1); - pipe.setLength(1000.0); - pipe.setDiameter(0.25); - pipe.setPipeWallRoughness(2e-5); - pipe.addFittingFromDatabase("Standard elbow (R=1.5D), 90deg"); - - IncompressiblePipeFlow pipe2 = new IncompressiblePipeFlow(pipe.getOutletStream()); - pipe2.setLength(1000.0); - pipe2.setDiameter(0.25); - pipe2.setPipeWallRoughness(2e-5); - pipe2.setInletElevation(10); - pipe2.setOutletElevation(0); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(stream_1); - operations.add(pipe); - operations.add(pipe2); - operations.run(); - pipe.displayResult(); - } - - /** - *

- * Getter for the field totalEqLenth. - *

- * - * @return the totalEqLenth - */ - public double getTotalEqLenth() { - return totalEqLenth; - } - - /** - *

- * Setter for the field totalEqLenth. - *

- * - * @param totalEqLenth the totalEqLenth to set - */ - public void setTotalEqLenth(double totalEqLenth) { - this.totalEqLenth = totalEqLenth; + double area = 3.14 / 4.0 * Math.pow(insideDiameter, 2.0); + double velocity = 1.0 / system.getPhase(0).getPhysicalProperties().getDensity() + / (system.getPhase(0).getNumberOfMolesInPhase() + * (system.getPhase(0).getMolarVolume() / 1e5)) + / area; + + momentum = system.getPhase(0).getPhysicalProperties().getDensity() * velocity * velocity; + double reynoldsNumber = velocity * insideDiameter + / system.getPhase(0).getPhysicalProperties().getKinematicViscosity(); + double frictionFactor = calcWallFrictionFactor(reynoldsNumber); + + double dp = -momentum * frictionFactor * getTotalEqLenth() / (2.0 * insideDiameter); + dp += (getInletElevation() - getOutletElevation()) + * system.getPhase(0).getPhysicalProperties().getDensity() + * neqsim.thermo.ThermodynamicConstantsInterface.gravity; + + // double dp = Math.pow(4.0 * system.getPhase(0).getNumberOfMolesInPhase() * + // system.getPhase(0).getMolarMass()/thermo.ThermodynamicConstantsInterface.pi, + // 2.0) * frictionFactor * length * system.getPhase(0).getZ() * + // thermo.ThermodynamicConstantsInterface.R/system.getPhase(0).getMolarMass() * + // system.getTemperature() / Math.pow(insideDiameter, 5.0); + System.out.println("outpres " + ((system.getPressure() * 1e5 + dp) / 1.0e5) + " dp " + dp + + " friction fact" + frictionFactor + " velocity " + velocity + " reynolds number " + + reynoldsNumber + " equivalentLength " + getTotalEqLenth()); + + return (system.getPressure() * 1e5 + dp) / 1.0e5; + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + system = inStream.getThermoSystem().clone(); + // system.setMultiPhaseCheck(true); + if (setTemperature) { + system.setTemperature(this.temperatureOut); } + system.init(3); + system.initPhysicalProperties(); + calcPressureOut(); + system.setPressure(calcPressureOut()); + + ThermodynamicOperations testOps = new ThermodynamicOperations(system); + testOps.TPflash(); + // system.setMultiPhaseCheck(false); + outStream.setThermoSystem(system); + outStream.setCalculationIdentifier(id); + setCalculationIdentifier(id); + } + + /** + *

+ * main. + *

+ * + * @param name an array of {@link java.lang.String} objects + */ + public static void main(String[] name) { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); + testSystem.addComponent("water", 100.0 * 1e3, "kg/hr"); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + testSystem.initPhysicalProperties(); + Stream stream_1 = new Stream("Stream1", testSystem); + + IncompressiblePipeFlow pipe = new IncompressiblePipeFlow(stream_1); + pipe.setLength(1000.0); + pipe.setDiameter(0.25); + pipe.setPipeWallRoughness(2e-5); + pipe.addFittingFromDatabase("Standard elbow (R=1.5D), 90deg"); + + IncompressiblePipeFlow pipe2 = new IncompressiblePipeFlow(pipe.getOutletStream()); + pipe2.setLength(1000.0); + pipe2.setDiameter(0.25); + pipe2.setPipeWallRoughness(2e-5); + pipe2.setInletElevation(10); + pipe2.setOutletElevation(0); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(pipe); + operations.add(pipe2); + operations.run(); + pipe.displayResult(); + } + + /** + *

+ * Getter for the field totalEqLenth. + *

+ * + * @return the totalEqLenth + */ + public double getTotalEqLenth() { + return totalEqLenth; + } + + /** + *

+ * Setter for the field totalEqLenth. + *

+ * + * @param totalEqLenth the totalEqLenth to set + */ + public void setTotalEqLenth(double totalEqLenth) { + this.totalEqLenth = totalEqLenth; + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/OnePhasePipeLine.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/OnePhasePipeLine.java index 12d2ad2d7a..62d3fdcb05 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/OnePhasePipeLine.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/OnePhasePipeLine.java @@ -3,8 +3,10 @@ * * Created on 21. august 2001, 20:44 */ + package neqsim.processSimulation.processEquipment.pipeline; +import java.util.UUID; import neqsim.fluidMechanics.flowSystem.onePhaseFlowSystem.pipeFlowSystem.PipeFlowSystem; import neqsim.processSimulation.processEquipment.stream.StreamInterface; @@ -42,7 +44,7 @@ public OnePhasePipeLine(StreamInterface inStream) { /** * Constructor for OnePhasePipeLine. - * + * * @param name name of pipe */ public OnePhasePipeLine(String name) { @@ -51,7 +53,7 @@ public OnePhasePipeLine(String name) { /** * Constructor for OnePhasePipeLine. - * + * * @param name name of pipe * @param inStream input stream */ @@ -69,16 +71,15 @@ public void createSystem() {} /** {@inheritDoc} */ @Override - public void run() { - super.run(); - pipe.solveSteadyState(10); + public void run(UUID id) { + UUID oldid = getCalculationIdentifier(); + super.run(id); + setCalculationIdentifier(oldid); + pipe.solveSteadyState(10, id); // pipe.print(); outStream.setThermoSystem(pipe.getNode(pipe.getTotalNumberOfNodes() - 1).getBulkSystem()); - } - /** {@inheritDoc} */ - @Override - public void runTransient(double dt) { - super.runTransient(dt); + outStream.setCalculationIdentifier(id); + setCalculationIdentifier(id); } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/Pipeline.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/Pipeline.java index 9daef31934..022b58823a 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/Pipeline.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/Pipeline.java @@ -6,6 +6,7 @@ package neqsim.processSimulation.processEquipment.pipeline; +import java.util.UUID; import neqsim.fluidMechanics.flowSystem.FlowSystemInterface; import neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface; import neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData; @@ -228,7 +229,7 @@ public void setEquilibriumHeatTransfer(boolean test) { /** {@inheritDoc} */ @Override - public void run() { + public void run(UUID id) { system = inStream.getThermoSystem(); GeometryDefinitionInterface[] pipeGemometry = new PipeData[numberOfLegs + 1]; for (int i = 0; i < pipeDiameters.length; i++) { @@ -248,12 +249,13 @@ public void run() { pipe.setEquilibriumMassTransfer(equilibriumMassTransfer); pipe.setEquilibriumHeatTransfer(equilibriumHeatTransfer); pipe.init(); + setCalculationIdentifier(id); } /** {@inheritDoc} */ @Override - public void runTransient(double dt) { - pipe.solveTransient(2); + public void runTransient(double dt, UUID id) { + pipe.solveTransient(2, id); } /** {@inheritDoc} */ diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/SimpleTPoutPipeline.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/SimpleTPoutPipeline.java index 4101358aeb..29b2e7432c 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/SimpleTPoutPipeline.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/SimpleTPoutPipeline.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.pipeline; +import java.util.UUID; import neqsim.fluidMechanics.flowSystem.FlowSystemInterface; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -13,104 +14,105 @@ * @version $Id: $Id */ public class SimpleTPoutPipeline extends Pipeline { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - boolean setTemperature = false; - protected double temperatureOut = 0, pressureOut = 0.0; - double dH = 0.0; + boolean setTemperature = false; + protected double temperatureOut = 0, pressureOut = 0.0; + double dH = 0.0; - /** - *

- * Constructor for SimpleTPoutPipeline. - *

- */ - @Deprecated - public SimpleTPoutPipeline() {} + /** + *

+ * Constructor for SimpleTPoutPipeline. + *

+ */ + @Deprecated + public SimpleTPoutPipeline() {} - /** - *

- * Constructor for SimpleTPoutPipeline. - *

- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public SimpleTPoutPipeline(StreamInterface inStream) { - this("SimpleTPoutPipeline", inStream); - } + /** + *

+ * Constructor for SimpleTPoutPipeline. + *

+ * + * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + @Deprecated + public SimpleTPoutPipeline(StreamInterface inStream) { + this("SimpleTPoutPipeline", inStream); + } - /** - * Constructor for SimpleTPoutPipeline. - * - * @param name name of pipeline - */ - public SimpleTPoutPipeline(String name) { - super(name); - } + /** + * Constructor for SimpleTPoutPipeline. + * + * @param name name of pipeline + */ + public SimpleTPoutPipeline(String name) { + super(name); + } - /** - * Constructor for SimpleTPoutPipeline. - * - * @param name name of pipeline - * @param inStream the inlet stream - */ - public SimpleTPoutPipeline(String name, StreamInterface inStream) { - super(name, inStream); - } + /** + * Constructor for SimpleTPoutPipeline. + * + * @param name name of pipeline + * @param inStream the inlet stream + */ + public SimpleTPoutPipeline(String name, StreamInterface inStream) { + super(name, inStream); + } - /** - *

- * setOutTemperature. - *

- * - * @param temperature a double - */ - public void setOutTemperature(double temperature) { - this.temperatureOut = temperature; - } + /** + *

+ * setOutTemperature. + *

+ * + * @param temperature a double + */ + public void setOutTemperature(double temperature) { + this.temperatureOut = temperature; + } - /** - *

- * setOutPressure. - *

- * - * @param pressure a double - */ - public void setOutPressure(double pressure) { - this.pressureOut = pressure; - } + /** + *

+ * setOutPressure. + *

+ * + * @param pressure a double + */ + public void setOutPressure(double pressure) { + this.pressureOut = pressure; + } - /** {@inheritDoc} */ - @Override - public void run() { - system = inStream.getThermoSystem().clone(); - // system.setMultiPhaseCheck(true); - system.setTemperature(this.temperatureOut); - system.setPressure(this.pressureOut); - ThermodynamicOperations testOps = new ThermodynamicOperations(system); - testOps.TPflash(); - // system.setMultiPhaseCheck(false); - outStream.setThermoSystem(system); - } + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + system = inStream.getThermoSystem().clone(); + // system.setMultiPhaseCheck(true); + system.setTemperature(this.temperatureOut); + system.setPressure(this.pressureOut); + ThermodynamicOperations testOps = new ThermodynamicOperations(system); + testOps.TPflash(); + // system.setMultiPhaseCheck(false); + outStream.setThermoSystem(system); + setCalculationIdentifier(id); + } - /** {@inheritDoc} */ - @Override - public void displayResult() { - outStream.getThermoSystem().display(name); - outStream.getThermoSystem().initPhysicalProperties(); - System.out.println("Superficial velocity out gas : " + getSuperficialVelocity(0, 1)); - System.out.println("Superficial velocity out condensate : " + getSuperficialVelocity(1, 1)); - System.out.println("Superficial velocity out MEG/water : " + getSuperficialVelocity(2, 1)); - } + /** {@inheritDoc} */ + @Override + public void displayResult() { + outStream.getThermoSystem().display(name); + outStream.getThermoSystem().initPhysicalProperties(); + System.out.println("Superficial velocity out gas : " + getSuperficialVelocity(0, 1)); + System.out.println("Superficial velocity out condensate : " + getSuperficialVelocity(1, 1)); + System.out.println("Superficial velocity out MEG/water : " + getSuperficialVelocity(2, 1)); + } - /** {@inheritDoc} */ - @Override - public FlowSystemInterface getPipe() { - return null; - } + /** {@inheritDoc} */ + @Override + public FlowSystemInterface getPipe() { + return null; + } - /** {@inheritDoc} */ - @Override - public void setInitialFlowPattern(String flowPattern) {} + /** {@inheritDoc} */ + @Override + public void setInitialFlowPattern(String flowPattern) {} } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/TwoPhasePipeLine.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/TwoPhasePipeLine.java index e5baf3cc26..d3653d2356 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/TwoPhasePipeLine.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/TwoPhasePipeLine.java @@ -5,6 +5,7 @@ */ package neqsim.processSimulation.processEquipment.pipeline; +import java.util.UUID; import neqsim.fluidMechanics.flowSystem.twoPhaseFlowSystem.twoPhasePipeFlowSystem.TwoPhasePipeFlowSystem; import neqsim.processSimulation.processEquipment.stream.StreamInterface; @@ -72,9 +73,12 @@ public void createSystem() {} /** {@inheritDoc} */ @Override - public void run() { - super.run(); - pipe.solveSteadyState(2); + public void run(UUID id) { + UUID oldid = getCalculationIdentifier(); + super.run(id); + setCalculationIdentifier(oldid); + pipe.solveSteadyState(2, id); + setCalculationIdentifier(id); pipe.print(); } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/powerGeneration/GasTurbine.java b/src/main/java/neqsim/processSimulation/processEquipment/powerGeneration/GasTurbine.java index 6990602866..f9fa1ee59f 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/powerGeneration/GasTurbine.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/powerGeneration/GasTurbine.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.powerGeneration; +import java.util.UUID; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.processSimulation.mechanicalDesign.compressor.CompressorMechanicalDesign; @@ -128,30 +129,31 @@ public void setInletStream(StreamInterface inletStream) { /** {@inheritDoc} */ @Override - public void run() { - double heatOfCombustion = inStream.LCV() * inStream.getFlowRate("mole/sec"); + public void run(UUID id) { thermoSystem = inStream.getThermoSystem().clone(); airStream.setFlowRate(thermoSystem.getFlowRate("mole/sec") * airGasRatio, "mole/sec"); airStream.setPressure(1.01325); - airStream.run(); + airStream.run(id); airCompressor.setInletStream(airStream); airCompressor.setOutletPressure(combustionpressure); - airCompressor.run(); + airCompressor.run(id); compressorPower = airCompressor.getPower(); StreamInterface outStreamAir = airCompressor.getOutletStream().clone(); outStreamAir.getFluid().addFluid(thermoSystem); // outStreamAir.getFluid().setTemperature(800.0); // outStreamAir.getFluid().createDatabase(true); - double moleMethane = outStreamAir.getFluid().getComponent("methane").getNumberOfmoles(); - // double moleEthane = outStreamAir.getFluid().getComponent("ethane").getNumberOfmoles(); - // double molePropane = outStreamAir.getFluid().getComponent("propane").getNumberOfmoles(); - outStreamAir.run(); + outStreamAir.run(id); + + double heatOfCombustion = inStream.LCV() * inStream.getFlowRate("mole/sec"); Heater locHeater = new Heater("locHeater", outStreamAir); locHeater.setEnergyInput(heatOfCombustion); - locHeater.run(); + locHeater.run(id); + double moleMethane = outStreamAir.getFluid().getComponent("methane").getNumberOfmoles(); + // double moleEthane = outStreamAir.getFluid().getComponent("ethane").getNumberOfmoles(); + // double molePropane = outStreamAir.getFluid().getComponent("propane").getNumberOfmoles(); locHeater.getOutletStream().getFluid().addComponent("CO2", moleMethane); locHeater.getOutletStream().getFluid().addComponent("water", moleMethane * 2.0); locHeater.getOutletStream().getFluid().addComponent("methane", -moleMethane); @@ -159,20 +161,21 @@ public void run() { // todo: Init fails because there is less than moleMethane of oxygen locHeater.getOutletStream().getFluid().init(3); - // locHeater.getOutStream().run(); + // locHeater.getOutStream().run(id); locHeater.displayResult(); Expander expander = new Expander("expander", locHeater.getOutletStream()); expander.setOutletPressure(1.01325); - expander.run(); + expander.run(id); Cooler cooler1 = new Cooler("cooler1", expander.getOutletStream()); cooler1.setOutTemperature(288.15); - cooler1.run(); + cooler1.run(id); expanderPower = expander.getPower(); power = expanderPower - compressorPower; this.heat = cooler1.getDuty(); + setCalculationIdentifier(id); } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pump/Pump.java b/src/main/java/neqsim/processSimulation/processEquipment/pump/Pump.java index ddf23756ec..75eb44f744 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pump/Pump.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pump/Pump.java @@ -4,6 +4,7 @@ import java.awt.FlowLayout; import java.text.DecimalFormat; import java.text.FieldPosition; +import java.util.UUID; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JScrollPane; @@ -153,7 +154,7 @@ public void calculateAsCompressor(boolean setPumpCalcType) { /** {@inheritDoc} */ @Override - public void run() { + public void run(UUID id) { // System.out.println("pump running.."); inStream.getThermoSystem().init(3); double hinn = inStream.getThermoSystem().getEnthalpy(); @@ -217,8 +218,10 @@ public void run() { // thermoOps.PSflash(entropy); dH = thermoSystem.getEnthalpy() - hinn; outStream.setThermoSystem(thermoSystem); + outStream.setCalculationIdentifier(id); + setCalculationIdentifier(id); - // outStream.run(); + // outStream.run(id); } /** {@inheritDoc} */ @@ -376,10 +379,11 @@ public void setIsentropicEfficiency(double isentropicEfficiency) { * @return a double */ public double getOutTemperature() { - if (useOutTemperature) + if (useOutTemperature) { return outTemperature; - else + } else { return getThermoSystem().getTemperature(); + } } /** diff --git a/src/main/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoir.java b/src/main/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoir.java index 5d3127f2df..f455db05c4 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoir.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoir.java @@ -6,6 +6,7 @@ package neqsim.processSimulation.processEquipment.reservoir; import java.util.ArrayList; +import java.util.UUID; import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; import neqsim.processSimulation.processEquipment.pipeline.AdiabaticTwoPhasePipe; import neqsim.processSimulation.processEquipment.stream.Stream; @@ -22,746 +23,751 @@ * @version $Id: $Id */ public class SimpleReservoir extends ProcessEquipmentBaseClass { - private static final long serialVersionUID = 1000; - - SystemInterface thermoSystem; - - double oilVolume = 0.0, gasVolume = 0.0, waterVolume = 0.0; - ArrayList gasProducer = new ArrayList(); - ArrayList oilProducer = new ArrayList(); - ArrayList gasInjector = new ArrayList(); - ArrayList waterInjector = new ArrayList(); - - double gasProductionTotal = 0.0; - double oilProductionTotal = 0.0; - double OOIP = 0.0; - double OGIP = 0.0; - - // StreamInterface gasOutStream; - // StreamInterface oilOutStream; - double reservoirVolume = 0.0; - double lowPressureLimit = 50.0; - double time = 0.0; - - /** - *

- * Constructor for SimpleReservoir. - *

- */ - @Deprecated - public SimpleReservoir() { - this("SimpleReservoir"); + private static final long serialVersionUID = 1000; + + SystemInterface thermoSystem; + + double oilVolume = 0.0; + double gasVolume = 0.0; + double waterVolume = 0.0; + + ArrayList gasProducer = new ArrayList(); + ArrayList oilProducer = new ArrayList(); + ArrayList gasInjector = new ArrayList(); + ArrayList waterInjector = new ArrayList(); + + double gasProductionTotal = 0.0; + double oilProductionTotal = 0.0; + double OOIP = 0.0; + double OGIP = 0.0; + + // StreamInterface gasOutStream; + // StreamInterface oilOutStream; + double reservoirVolume = 0.0; + double lowPressureLimit = 50.0; + + /** + *

+ * Constructor for SimpleReservoir. + *

+ */ + @Deprecated + public SimpleReservoir() { + this("SimpleReservoir"); + } + + /** + *

+ * Constructor for SimpleReservoir. + *

+ * + * @param name a {@link java.lang.String} object + */ + public SimpleReservoir(String name) { + super(name); + } + + /** + *

+ * getReservoirFluid. + *

+ * + * @return a {@link neqsim.thermo.system.SystemInterface} object + */ + public SystemInterface getReservoirFluid() { + return thermoSystem; + } + + /* + * public StreamInterface getGasOutStream() { return gasOutStream; } + * + * + * + * public StreamInterface getOilOutStream() { return oilOutStream; } + */ + + /** + *

+ * addGasProducer. + *

+ * + * @param name a {@link java.lang.String} object + * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + public StreamInterface addGasProducer(String name) { + Well newWell = new Well(name); + gasProducer.add(newWell); + StreamInterface gasOutStream = new Stream("gasOutStream"); + gasOutStream.setFluid(thermoSystem.phaseToSystem("gas")); + gasOutStream.getFluid().setTotalFlowRate(1.0e-1, "kg/sec"); + newWell.setStream(gasOutStream); + return newWell.getStream(); + } + + /** + *

+ * addOilProducer. + *

+ * + * @param name a {@link java.lang.String} object + * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + public StreamInterface addOilProducer(String name) { + Well newWell = new Well(name); + oilProducer.add(newWell); + StreamInterface oilOutStream = new Stream("oilOutStream"); + oilOutStream.setFluid(thermoSystem.phaseToSystem("oil")); + oilOutStream.getFluid().setTotalFlowRate(1.0e-1, "kg/sec"); + newWell.setStream(oilOutStream); + return newWell.getStream(); + } + + /** + *

+ * addWaterInjector. + *

+ * + * @param name a {@link java.lang.String} object + * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + public StreamInterface addWaterInjector(String name) { + Well newWell = new Well(name); + waterInjector.add(newWell); + StreamInterface waterInStream = new Stream("waterInStream"); + waterInStream.setFluid(thermoSystem.phaseToSystem("aqueous")); + // waterInStream.init(0); + waterInStream.getFluid().setTotalFlowRate(1.0e-1, "kg/sec"); + newWell.setStream(waterInStream); + return newWell.getStream(); + } + + /** + *

+ * addGasInjector. + *

+ * + * @param name a {@link java.lang.String} object + * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + public StreamInterface addGasInjector(String name) { + Well newWell = new Well(name); + gasInjector.add(newWell); + StreamInterface gasInStream = new Stream("gasInStream"); + gasInStream.setFluid(thermoSystem.phaseToSystem("gas")); + gasInStream.getFluid().setTotalFlowRate(1.0e-1, "kg/sec"); + newWell.setStream(gasInStream); + return newWell.getStream(); + } + + /** + *

+ * getGasInPlace. + *

+ * + * @param unit a {@link java.lang.String} object + * @return a double + */ + public double getGasInPlace(String unit) { + SystemInterface locStream = (thermoSystem).clone(); + locStream.setTemperature(288.15); + locStream.setPressure(1.01325); + ThermodynamicOperations ops = new ThermodynamicOperations(locStream); + ops.TPflash(); + locStream.initProperties(); + double volume = Double.NaN; + if (locStream.hasPhaseType("gas")) { + volume = locStream.getPhase("gas").getVolume("m3"); } - - /** - *

- * Constructor for SimpleReservoir. - *

- * - * @param name a {@link java.lang.String} object - */ - public SimpleReservoir(String name) { - super(name); + if (unit.equals("GSm3")) { + return volume / 1.0e9; } - - /** - *

- * getReservoirFluid. - *

- * - * @return a {@link neqsim.thermo.system.SystemInterface} object - */ - public SystemInterface getReservoirFluid() { - return thermoSystem; + return volume; + } + + /** + *

+ * getOilInPlace. + *

+ * + * @param unit a {@link java.lang.String} object + * @return a double + */ + public double getOilInPlace(String unit) { + SystemInterface locStream = (thermoSystem).clone(); + locStream.setTemperature(288.15); + locStream.setPressure(1.01325); + ThermodynamicOperations ops = new ThermodynamicOperations(locStream); + ops.TPflash(); + locStream.initProperties(); + double volume = Double.NaN; + if (locStream.hasPhaseType("oil")) { + volume = locStream.getPhase("oil").getVolume("m3"); } - - /* - * public StreamInterface getGasOutStream() { return gasOutStream; } - * - * - * - * public StreamInterface getOilOutStream() { return oilOutStream; } - */ - - /** - *

- * addGasProducer. - *

- * - * @param name a {@link java.lang.String} object - * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ - public StreamInterface addGasProducer(String name) { - Well newWell = new Well(name); - gasProducer.add(newWell); - StreamInterface gasOutStream = new Stream("gasOutStream"); - gasOutStream.setFluid(thermoSystem.phaseToSystem("gas")); - gasOutStream.getFluid().setTotalFlowRate(1.0e-1, "kg/sec"); - newWell.setStream(gasOutStream); - return newWell.getStream(); - } - - /** - *

- * addOilProducer. - *

- * - * @param name a {@link java.lang.String} object - * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ - public StreamInterface addOilProducer(String name) { - Well newWell = new Well(name); - oilProducer.add(newWell); - StreamInterface oilOutStream = new Stream("oilOutStream"); - oilOutStream.setFluid(thermoSystem.phaseToSystem("oil")); - oilOutStream.getFluid().setTotalFlowRate(1.0e-1, "kg/sec"); - newWell.setStream(oilOutStream); - return newWell.getStream(); - } - - /** - *

- * addWaterInjector. - *

- * - * @param name a {@link java.lang.String} object - * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ - public StreamInterface addWaterInjector(String name) { - Well newWell = new Well(name); - waterInjector.add(newWell); - StreamInterface waterInStream = new Stream("waterInStream"); - waterInStream.setFluid(thermoSystem.phaseToSystem("aqueous")); - // waterInStream.init(0); - waterInStream.getFluid().setTotalFlowRate(1.0e-1, "kg/sec"); - newWell.setStream(waterInStream); - return newWell.getStream(); - } - - /** - *

- * addGasInjector. - *

- * - * @param name a {@link java.lang.String} object - * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ - public StreamInterface addGasInjector(String name) { - Well newWell = new Well(name); - gasInjector.add(newWell); - StreamInterface gasInStream = new Stream("gasInStream"); - gasInStream.setFluid(thermoSystem.phaseToSystem("gas")); - gasInStream.getFluid().setTotalFlowRate(1.0e-1, "kg/sec"); - newWell.setStream(gasInStream); - return newWell.getStream(); - } - - /** - *

- * getGasInPlace. - *

- * - * @param unit a {@link java.lang.String} object - * @return a double - */ - public double getGasInPlace(String unit) { - SystemInterface locStream = (thermoSystem).clone(); - locStream.setTemperature(288.15); - locStream.setPressure(1.01325); - ThermodynamicOperations ops = new ThermodynamicOperations(locStream); - ops.TPflash(); - locStream.initProperties(); - double volume = Double.NaN; - if (locStream.hasPhaseType("gas")) { - volume = locStream.getPhase("gas").getVolume("m3"); - } - if (unit.equals("GSm3")) { - return volume / 1.0e9; - } - return volume; + if (unit.equals("MSm3")) { + return volume / 1.0e6; } - - /** - *

- * getOilInPlace. - *

- * - * @param unit a {@link java.lang.String} object - * @return a double - */ - public double getOilInPlace(String unit) { - SystemInterface locStream = (thermoSystem).clone(); - locStream.setTemperature(288.15); - locStream.setPressure(1.01325); - ThermodynamicOperations ops = new ThermodynamicOperations(locStream); - ops.TPflash(); - locStream.initProperties(); - double volume = Double.NaN; - if (locStream.hasPhaseType("oil")) { - volume = locStream.getPhase("oil").getVolume("m3"); - } - if (unit.equals("MSm3")) { - return volume / 1.0e6; + return volume; + } + + /** + *

+ * Getter for the field gasProducer. + *

+ * + * @param i a int + * @return a {@link neqsim.processSimulation.processEquipment.reservoir.Well} object + */ + public Well getGasProducer(int i) { + return gasProducer.get(i); + } + + /** + *

+ * Getter for the field oilProducer. + *

+ * + * @param i a int + * @return a {@link neqsim.processSimulation.processEquipment.reservoir.Well} object + */ + public Well getOilProducer(int i) { + return oilProducer.get(i); + } + + /** + *

+ * Getter for the field oilProducer. + *

+ * + * @param name a {@link java.lang.String} object + * @return a {@link neqsim.processSimulation.processEquipment.reservoir.Well} object + */ + public Well getOilProducer(String name) { + for (int i = 0; i < oilProducer.size(); i++) { + if (oilProducer.get(i).getName().equals(name)) { + return oilProducer.get(i); + } + } + return null; + } + + /** + *

+ * Getter for the field waterInjector. + *

+ * + * @param i a int + * @return a {@link neqsim.processSimulation.processEquipment.reservoir.Well} object + */ + public Well getWaterInjector(int i) { + return waterInjector.get(i); + } + + /** + *

+ * Getter for the field gasInjector. + *

+ * + * @param i a int + * @return a {@link neqsim.processSimulation.processEquipment.reservoir.Well} object + */ + public Well getGasInjector(int i) { + return gasInjector.get(i); + } + + /** + *

+ * setReservoirFluid. + *

+ * + * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object + * @param gasVolume a double + * @param oilVolume a double + * @param waterVolume a double + */ + public void setReservoirFluid(SystemInterface thermoSystem, double gasVolume, double oilVolume, + double waterVolume) { + this.thermoSystem = thermoSystem; + this.oilVolume = oilVolume; + this.gasVolume = gasVolume; + this.waterVolume = waterVolume; + ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem); + ops.TPflash(); + + // thermoSystem.display(); + SystemInterface thermoSystem2 = thermoSystem.clone(); + + thermoSystem.setEmptyFluid(); // (1.0e-10); + // thermoSystem.init(1); + // thermoSystem.display(); + // System.out.println("number of phases " + thermoSystem.getNumberOfPhases()); + // double totalliquidVolume = 0.0; + for (int j = 0; j < thermoSystem.getNumberOfPhases(); j++) { + double relFact = gasVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); + if (j >= 1) { + if (j == 1) { + relFact = oilVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); + // totalliquidVolume += oilVolume / thermoSystem2.getPhase(j).getMolarVolume(); + } else if (j == 2) { + relFact = waterVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); + // totalliquidVolume += waterVolume / + // thermoSystem2.getPhase(j).getMolarVolume(); } - return volume; + } + for (int i = 0; i < thermoSystem.getPhase(j).getNumberOfComponents(); i++) { + thermoSystem.addComponent(thermoSystem.getPhase(j).getComponent(i).getComponentNumber(), + relFact * thermoSystem2.getPhase(j).getComponent(i).getNumberOfMolesInPhase(), j); + } } - - /** - *

- * Getter for the field gasProducer. - *

- * - * @param i a int - * @return a {@link neqsim.processSimulation.processEquipment.reservoir.Well} object + /* + * if (thermoSystem.hasPhaseType("gas")) { thermoSystem.setBeta(gasVolume / + * thermoSystem2.getPhase(0).getMolarVolume() / (gasVolume / + * thermoSystem2.getPhase(0).getMolarVolume() + oilVolume / + * thermoSystem2.getPhase(1).getMolarVolume())); } */ - public Well getGasProducer(int i) { - return gasProducer.get(i); + ThermodynamicOperations ops2 = new ThermodynamicOperations(thermoSystem); + ops2.TPflash(); + thermoSystem.initProperties(); + // thermoSystem.display(); + // gasOutStream = new Stream(); + // gasOutStream.setFluid(thermoSystem.phaseToSystem("gas")); + reservoirVolume = gasVolume + oilVolume + waterVolume; + + OOIP = getOilInPlace("Sm3"); + OGIP = getGasInPlace("Sm3"); + // oilOutStream = new Stream(); + // oilOutStream.setFluid(thermoSystem.phaseToSystem("oil")); + + lowPressureLimit = 50.0; + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + System.out.println("gas volume " + thermoSystem.getPhase("gas").getVolume("m3")); + System.out.println("oil volume " + thermoSystem.getPhase("oil").getVolume("m3")); + System.out.println("water volume " + thermoSystem.getPhase("aqueous").getVolume("m3")); + + for (int i = 0; i < gasProducer.size(); i++) { + gasProducer.get(i).getStream().run(id); } - - /** - *

- * Getter for the field oilProducer. - *

- * - * @param i a int - * @return a {@link neqsim.processSimulation.processEquipment.reservoir.Well} object - */ - public Well getOilProducer(int i) { - return oilProducer.get(i); + for (int i = 0; i < oilProducer.size(); i++) { + oilProducer.get(i).getStream().run(id); + } + for (int i = 0; i < waterInjector.size(); i++) { + waterInjector.get(i).getStream().run(id); + } + for (int i = 0; i < gasInjector.size(); i++) { + gasInjector.get(i).getStream().run(id); } - /** - *

- * Getter for the field waterInjector. - *

- * - * @param i a int - * @return a {@link neqsim.processSimulation.processEquipment.reservoir.Well} object - */ - public Well getWaterInjector(int i) { - return waterInjector.get(i); + // gasOutStream.setFluid(thermoSystem.phaseToSystem("gas")); + // gasOutStream.run(id); + + setCalculationIdentifier(id); + } + + /** + *

+ * GORprodution. + *

+ * + * @return a double + */ + public double GORprodution() { + double GOR = 0.0; + double flow = 0.0; + for (int i = 0; i < gasProducer.size(); i++) { + flow += gasProducer.get(i).getStream().getFluid().getNumberOfMoles(); + GOR += gasProducer.get(i).getGOR() + * gasProducer.get(i).getStream().getFluid().getNumberOfMoles(); + } + for (int i = 0; i < oilProducer.size(); i++) { + flow += oilProducer.get(i).getStream().getFluid().getNumberOfMoles(); + GOR += oilProducer.get(i).getGOR() + * oilProducer.get(i).getStream().getFluid().getNumberOfMoles(); + } + return GOR / flow; + } + + /** + *

+ * getGasProdution. + *

+ * + * @param unit a {@link java.lang.String} object + * @return a double + */ + public double getGasProdution(String unit) { + double volume = 0.0; + for (int i = 0; i < gasProducer.size(); i++) { + volume += gasProducer.get(i).getStdGasProduction(); + } + for (int i = 0; i < oilProducer.size(); i++) { + volume += oilProducer.get(i).getStdGasProduction(); + } + if (unit.equals("Sm3/sec")) { + } else if (unit.equals("Sm3/day")) { + volume = volume * 60.0 * 60 * 24; + } + return volume; + } + + /** + *

+ * getOilProdution. + *

+ * + * @param unit a {@link java.lang.String} object + * @return a double + */ + public double getOilProdution(String unit) { + double volume = 0.0; + for (int i = 0; i < gasProducer.size(); i++) { + volume += gasProducer.get(i).getStdOilProduction(); + } + for (int i = 0; i < oilProducer.size(); i++) { + volume += oilProducer.get(i).getStdOilProduction(); + } + if (unit.equals("Sm3/sec")) { + } else if (unit.equals("Sm3/day")) { + volume = volume * 60.0 * 60 * 24; } + return volume; + } + + /** {@inheritDoc} */ + @Override + public void runTransient(double dt, UUID id) { + increaseTime(dt); + if (thermoSystem.getPressure("bara") < lowPressureLimit) { + System.out.println("low pressure reservoir limit reached"); + setCalculationIdentifier(id); + return; + } + gasProductionTotal += getGasProdution("Sm3/sec") * dt; + oilProductionTotal += getOilProdution("Sm3/sec") * dt; + thermoSystem.init(0); + for (int i = 0; i < thermoSystem.getPhase(0).getNumberOfComponents(); i++) { + // thermoSystem.addComponent(i, -10000000000.001); + for (int k = 0; k < gasProducer.size(); k++) { + thermoSystem.addComponent(i, + -gasProducer.get(k).getStream().getFluid().getComponent(i).getNumberOfmoles() * dt); + } + + for (int k = 0; k < oilProducer.size(); k++) { + thermoSystem.addComponent(i, + -oilProducer.get(k).getStream().getFluid().getComponent(i).getNumberOfmoles() * dt); + } + + for (int k = 0; k < waterInjector.size(); k++) { + thermoSystem.addComponent(i, + waterInjector.get(k).getStream().getFluid().getComponent(i).getNumberOfmoles() * dt); + } + for (int k = 0; k < gasInjector.size(); k++) { + thermoSystem.addComponent(i, + gasInjector.get(k).getStream().getFluid().getComponent(i).getNumberOfmoles() * dt); + } + } + + ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem); + ops.TVflash(reservoirVolume, "m3"); + thermoSystem.initProperties(); - /** - *

- * Getter for the field gasInjector. - *

- * - * @param i a int - * @return a {@link neqsim.processSimulation.processEquipment.reservoir.Well} object + /* + * if (thermoSystem.hasPhaseType("gas")) System.out.println("gas volume " + + * thermoSystem.getPhase("gas").getVolume("m3")); if (thermoSystem.hasPhaseType("oil")) + * System.out.println("oil volume " + thermoSystem.getPhase("oil").getVolume("m3")); if + * (thermoSystem.hasPhaseType("aqueous")) System.out.println("water volume " + + * thermoSystem.getPhase("aqueous").getVolume("m3")); */ - public Well getGasInjector(int i) { - return gasInjector.get(i); + // System.out.println("pressure " + thermoSystem.getPressure("bara")); + + if (thermoSystem.hasPhaseType("gas")) { + for (int k = 0; k < gasProducer.size(); k++) { + gasProducer.get(k).getStream().getFluid() + .setMolarComposition(thermoSystem.getPhase("gas").getMolarComposition()); + gasProducer.get(k).getStream().run(id); + } } - - /** - *

- * Getter for the field oilProducer. - *

- * - * @param name a {@link java.lang.String} object - * @return a {@link neqsim.processSimulation.processEquipment.reservoir.Well} object + if (thermoSystem.hasPhaseType("oil")) { + for (int k = 0; k < oilProducer.size(); k++) { + oilProducer.get(k).getStream().getFluid() + .setMolarComposition(thermoSystem.getPhase("oil").getMolarComposition()); + oilProducer.get(k).getStream().run(id); + } + } + /* + * if(thermoSystem.hasPhaseType("aqueous")) { for (int k = 0; k < waterInjector.size(); k++) { + * waterInjector.get(k).getStream().getFluid() + * .setMolarComposition(thermoSystem.getPhase("aqueous").getMolarComposition()); + * waterInjector.get(k).getStream().run(); } */ - public Well getOilProducer(String name) { - for (int i = 0; i < oilProducer.size(); i++) { - if (oilProducer.get(i).getName().equals(name)) { - return oilProducer.get(i); - } - } - return null; - } - - /** - *

- * setReservoirFluid. - *

- * - * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object - * @param gasVolume a double - * @param oilVolume a double - * @param waterVolume a double + for (int k = 0; k < waterInjector.size(); k++) { + waterInjector.get(k).getStream().run(id); + } + for (int k = 0; k < gasInjector.size(); k++) { + gasInjector.get(k).getStream().run(id); + } + /* + * double totalVolume = 0; for (int i = 0; i < getReservoirFluid().getNumberOfPhases(); i++) { + * totalVolume += getReservoirFluid().getPhase(i).getVolume("m3"); } + * System.out.println("tot volume " + totalVolume/1.0e6 + " gas volume "+ */ - public void setReservoirFluid(SystemInterface thermoSystem, double gasVolume, double oilVolume, - double waterVolume) { - this.thermoSystem = thermoSystem; - this.oilVolume = oilVolume; - this.gasVolume = gasVolume; - this.waterVolume = waterVolume; - ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem); - ops.TPflash(); - - // thermoSystem.display(); - SystemInterface thermoSystem2 = thermoSystem.clone(); - - thermoSystem.setEmptyFluid();// (1.0e-10); - // thermoSystem.init(1); - // thermoSystem.display(); - // System.out.println("number of phases " + thermoSystem.getNumberOfPhases()); - // double totalliquidVolume = 0.0; - for (int j = 0; j < thermoSystem.getNumberOfPhases(); j++) { - double relFact = gasVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); - if (j >= 1) { - if (j == 1) { - relFact = oilVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); - // totalliquidVolume += oilVolume / thermoSystem2.getPhase(j).getMolarVolume(); - } else if (j == 2) { - relFact = waterVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); - // totalliquidVolume += waterVolume / - // thermoSystem2.getPhase(j).getMolarVolume(); - } - } - for (int i = 0; i < thermoSystem.getPhase(j).getNumberOfComponents(); i++) { - thermoSystem.addComponent( - thermoSystem.getPhase(j).getComponent(i).getComponentNumber(), - relFact * thermoSystem2.getPhase(j).getComponent(i) - .getNumberOfMolesInPhase(), - j); - } - } - /* - * if (thermoSystem.hasPhaseType("gas")) { thermoSystem.setBeta(gasVolume / - * thermoSystem2.getPhase(0).getMolarVolume() / (gasVolume / - * thermoSystem2.getPhase(0).getMolarVolume() + oilVolume / - * thermoSystem2.getPhase(1).getMolarVolume())); } - */ - ThermodynamicOperations ops2 = new ThermodynamicOperations(thermoSystem); - ops2.TPflash(); - thermoSystem.initProperties(); - // thermoSystem.display(); - // gasOutStream = new Stream(); - // gasOutStream.setFluid(thermoSystem.phaseToSystem("gas")); - reservoirVolume = gasVolume + oilVolume + waterVolume; - - OOIP = getOilInPlace("Sm3"); - OGIP = getGasInPlace("Sm3"); - // oilOutStream = new Stream(); - // oilOutStream.setFluid(thermoSystem.phaseToSystem("oil")); - - lowPressureLimit = 50.0; - } - - /** {@inheritDoc} */ - @Override - public void run() { - System.out.println("gas volume " + thermoSystem.getPhase("gas").getVolume("m3")); - System.out.println("oil volume " + thermoSystem.getPhase("oil").getVolume("m3")); - System.out.println("water volume " + thermoSystem.getPhase("aqueous").getVolume("m3")); - - for (int i = 0; i < gasProducer.size(); i++) { - gasProducer.get(i).getStream().run(); - } - for (int i = 0; i < oilProducer.size(); i++) { - oilProducer.get(i).getStream().run(); - } - for (int i = 0; i < waterInjector.size(); i++) { - waterInjector.get(i).getStream().run(); - } - for (int i = 0; i < gasInjector.size(); i++) { - gasInjector.get(i).getStream().run(); - } - // gasOutStream.setFluid(thermoSystem.phaseToSystem("gas")); - // gasOutStream.run(); - } + // getReservoirFluid().getPhase("gas").getVolume("m3")/1.0e6 + " oil volume "+ + // getReservoirFluid().getPhase("oil").getVolume("m3")/1.0e6 + " water volume "+ + // getReservoirFluid().getPhase("aqueous").getVolume("m3")/1.0e6); + // oilOutStream.getFluid().setMolarComposition(thermoSystem.getPhase("oil").getMolarComposition()); + // oilOutStream.run(id); - /** - *

- * GORprodution. - *

- * - * @return a double - */ - public double GORprodution() { - double GOR = 0.0; - double flow = 0.0; - for (int i = 0; i < gasProducer.size(); i++) { - flow += gasProducer.get(i).getStream().getFluid().getNumberOfMoles(); - GOR += gasProducer.get(i).getGOR() - * gasProducer.get(i).getStream().getFluid().getNumberOfMoles(); - } - for (int i = 0; i < oilProducer.size(); i++) { - flow += oilProducer.get(i).getStream().getFluid().getNumberOfMoles(); - GOR += oilProducer.get(i).getGOR() - * oilProducer.get(i).getStream().getFluid().getNumberOfMoles(); - } - return GOR / flow; + // thermoSystem.display(); + for (int k = 0; k < gasProducer.size(); k++) { + gasProducer.get(k).getStream().getFluid().setPressure(thermoSystem.getPressure()); } - /** - *

- * getGasProdution. - *

- * - * @param unit a {@link java.lang.String} object - * @return a double - */ - public double getGasProdution(String unit) { - double volume = 0.0; - for (int i = 0; i < gasProducer.size(); i++) { - volume += gasProducer.get(i).getStdGasProduction(); - } - for (int i = 0; i < oilProducer.size(); i++) { - volume += oilProducer.get(i).getStdGasProduction(); - } - if (unit.equals("Sm3/sec")) { - } else if (unit.equals("Sm3/day")) { - volume = volume * 60.0 * 60 * 24; - } - return volume; + for (int k = 0; k < oilProducer.size(); k++) { + oilProducer.get(k).getStream().getFluid().setPressure(thermoSystem.getPressure()); } - /** - *

- * getOilProdution. - *

- * - * @param unit a {@link java.lang.String} object - * @return a double - */ - public double getOilProdution(String unit) { - double volume = 0.0; - for (int i = 0; i < gasProducer.size(); i++) { - volume += gasProducer.get(i).getStdOilProduction(); - } - for (int i = 0; i < oilProducer.size(); i++) { - volume += oilProducer.get(i).getStdOilProduction(); - } - if (unit.equals("Sm3/sec")) { - } else if (unit.equals("Sm3/day")) { - volume = volume * 60.0 * 60 * 24; - } - return volume; + for (int k = 0; k < waterInjector.size(); k++) { + waterInjector.get(k).getStream().setPressure(thermoSystem.getPressure()); + } + for (int k = 0; k < gasInjector.size(); k++) { + gasInjector.get(k).getStream().setPressure(thermoSystem.getPressure()); + } + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + thermoSystem.display(); + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos((273.15 + 100.0), 200.00); + testSystem.addComponent("nitrogen", 0.100); + testSystem.addComponent("methane", 30.00); + testSystem.addComponent("ethane", 1.0); + testSystem.addComponent("propane", 1.0); + testSystem.addComponent("i-butane", 1.0); + testSystem.addComponent("n-butane", 1.0); + testSystem.addComponent("n-hexane", 0.1); + testSystem.addComponent("n-heptane", 0.1); + testSystem.addComponent("n-nonane", 1.0); + testSystem.addComponent("nC10", 1.0); + testSystem.addComponent("nC12", 3.0); + testSystem.addComponent("nC15", 3.0); + testSystem.addComponent("nC20", 3.0); + testSystem.addComponent("water", 11.0); + testSystem.setMixingRule(2); + testSystem.setMultiPhaseCheck(true); + + SimpleReservoir reservoirOps = new SimpleReservoir("Well 1 reservoir"); + reservoirOps.setReservoirFluid(testSystem, 5.0 * 1e7, 552.0 * 1e6, 10.0e6); + + StreamInterface producedOilStream = reservoirOps.addOilProducer("oilproducer_1"); + StreamInterface injectorGasStream = reservoirOps.addGasInjector("gasproducer_1"); + StreamInterface producedGasStream = reservoirOps.addGasProducer("SLP_A32562G"); + StreamInterface waterInjectorStream = reservoirOps.addWaterInjector("SLP_WI32562O"); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(reservoirOps); + operations.save("c:/temp/resmode1.neqsim"); + + System.out.println("gas in place (GIP) " + reservoirOps.getGasInPlace("GSm3") + " GSm3"); + System.out.println("oil in place (OIP) " + reservoirOps.getOilInPlace("MSm3") + " MSm3"); + + // StreamInterface producedGasStream = + // reservoirOps.addGasProducer("SLP_A32562G"); + producedGasStream.setFlowRate(0.01, "MSm3/day"); + + // StreamInterface injectorGasStream = + // reservoirOps.addGasInjector("SLP_A32562GI"); + injectorGasStream.setFlowRate(0.01, "MSm3/day"); + // injectorGasStream.getFluid().setMolarComposition(.new double[0.1, 0.1]); + + // StreamInterface producedGasStream2 = + // reservoirOps.addGasProducer("SLP_A32562G2"); + // producedGasStream2.setFlowRate(0.011, "MSm3/hr"); + + producedOilStream.setFlowRate(50000000.0, "kg/day"); + + waterInjectorStream.setFlowRate(12100000.0, "kg/day"); + + // StreamInterface producedGasStream = reservoirOps.getGasOutStream(); + // producedGasStream.setFlowRate(1.0e-3, "MSm3/day"); + + // StreamInterface producedOilStream = reservoirOps.getOilOutStream(); + // producedOilStream.setFlowRate(1500000.0, "kg/hr"); + + reservoirOps.run(); + + reservoirOps.runTransient(60 * 60 * 24 * 3); + for (int i = 0; i < 1; i++) { + reservoirOps.runTransient(60 * 60 * 24 * 15); + System.out.println("water volume" + + reservoirOps.getReservoirFluid().getPhase("aqueous").getVolume("m3") / 1.0e6); + System.out + .println("oil production total" + reservoirOps.getOilProductionTotal("Sm3") + " Sm3"); + System.out + .println("total produced " + reservoirOps.getProductionTotal("MSm3 oe") + " MSm3 oe"); + if (reservoirOps.getFluid().getPressure() < 50.0) { + break; + } } + System.out.println("GOR gas " + reservoirOps.getGasProducer(0).getGOR()); + // System.out.println("GOR oil " + reservoirOps.getOilProducer(0).getGOR()); + System.out.println("GOR production " + reservoirOps.GORprodution()); - /** {@inheritDoc} */ - @Override - public void runTransient(double dt) { - time = getTime() + dt; - if (thermoSystem.getPressure("bara") < lowPressureLimit) { - System.out.println("low pressure reservoir limit reached"); - return; - } - gasProductionTotal += getGasProdution("Sm3/sec") * dt; - oilProductionTotal += getOilProdution("Sm3/sec") * dt; - thermoSystem.init(0); - for (int i = 0; i < thermoSystem.getPhase(0).getNumberOfComponents(); i++) { - // thermoSystem.addComponent(i, -10000000000.001); - for (int k = 0; k < gasProducer.size(); k++) { - thermoSystem.addComponent(i, -gasProducer.get(k).getStream().getFluid() - .getComponent(i).getNumberOfmoles() * dt); - } - - for (int k = 0; k < oilProducer.size(); k++) { - thermoSystem.addComponent(i, -oilProducer.get(k).getStream().getFluid() - .getComponent(i).getNumberOfmoles() * dt); - } - - for (int k = 0; k < waterInjector.size(); k++) { - thermoSystem.addComponent(i, waterInjector.get(k).getStream().getFluid() - .getComponent(i).getNumberOfmoles() * dt); - } - for (int k = 0; k < gasInjector.size(); k++) { - thermoSystem.addComponent(i, - gasInjector.get(k).getStream().getFluid().getComponent(i).getNumberOfmoles() - * dt); - } - } + // System.out.println("GOR oil " + reservoirOps.getOilProducer(0).getGOR()); - ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem); - ops.TVflash(reservoirVolume, "m3"); - thermoSystem.initProperties(); - - /* - * if (thermoSystem.hasPhaseType("gas")) System.out.println("gas volume " + - * thermoSystem.getPhase("gas").getVolume("m3")); if (thermoSystem.hasPhaseType("oil")) - * System.out.println("oil volume " + thermoSystem.getPhase("oil").getVolume("m3")); if - * (thermoSystem.hasPhaseType("aqueous")) System.out.println("water volume " + - * thermoSystem.getPhase("aqueous").getVolume("m3")); - */ - // System.out.println("pressure " + thermoSystem.getPressure("bara")); - - if (thermoSystem.hasPhaseType("gas")) { - for (int k = 0; k < gasProducer.size(); k++) { - gasProducer.get(k).getStream().getFluid() - .setMolarComposition(thermoSystem.getPhase("gas").getMolarComposition()); - gasProducer.get(k).getStream().run(); - } - } - if (thermoSystem.hasPhaseType("oil")) { - for (int k = 0; k < oilProducer.size(); k++) { - oilProducer.get(k).getStream().getFluid() - .setMolarComposition(thermoSystem.getPhase("oil").getMolarComposition()); - oilProducer.get(k).getStream().run(); - } - } - /* - * if(thermoSystem.hasPhaseType("aqueous")) { for (int k = 0; k < waterInjector.size(); k++) - * { waterInjector.get(k).getStream().getFluid() - * .setMolarComposition(thermoSystem.getPhase("aqueous").getMolarComposition()); - * waterInjector.get(k).getStream().run(); } - */ - for (int k = 0; k < waterInjector.size(); k++) { - waterInjector.get(k).getStream().run(); - } - for (int k = 0; k < gasInjector.size(); k++) { - gasInjector.get(k).getStream().run(); - } - /* - * double totalVolume = 0; for (int i = 0; i < getReservoirFluid().getNumberOfPhases(); i++) - * { totalVolume += getReservoirFluid().getPhase(i).getVolume("m3"); } - * System.out.println("tot volume " + totalVolume/1.0e6 + " gas volume "+ - */ - - // getReservoirFluid().getPhase("gas").getVolume("m3")/1.0e6 + " oil volume "+ - // getReservoirFluid().getPhase("oil").getVolume("m3")/1.0e6 + " water volume "+ - // getReservoirFluid().getPhase("aqueous").getVolume("m3")/1.0e6); - // oilOutStream.getFluid().setMolarComposition(thermoSystem.getPhase("oil").getMolarComposition()); - // oilOutStream.run(); - - // thermoSystem.display(); - for (int k = 0; k < gasProducer.size(); k++) { - gasProducer.get(k).getStream().getFluid().setPressure(thermoSystem.getPressure()); - } + System.out.println("gas production " + reservoirOps.getGasProdution("Sm3/day") + " Sm3/day"); + System.out.println("oil production " + reservoirOps.getOilProdution("Sm3/day") + " Sm3/day"); - for (int k = 0; k < oilProducer.size(); k++) { - oilProducer.get(k).getStream().getFluid().setPressure(thermoSystem.getPressure()); - } + System.out + .println("oil production total" + reservoirOps.getOilProductionTotal("Sm3") + " Sm3"); - for (int k = 0; k < waterInjector.size(); k++) { - waterInjector.get(k).getStream().setPressure(thermoSystem.getPressure()); - } - for (int k = 0; k < gasInjector.size(); k++) { - gasInjector.get(k).getStream().setPressure(thermoSystem.getPressure()); - } - } + // reservoirOps.runTransient(60 * 60 * 24 * 365); + // reservoirOps.runTransient(60 * 60 * 24 * 365); + // reservoirOps.runTransient(60 * 60 * 24 * 365); + System.out + .println("gas production total" + reservoirOps.getGasProductionTotal("GSm3") + " GSm3"); - /** {@inheritDoc} */ - @Override - public void displayResult() { - thermoSystem.display(); - } + System.out + .println("oil production total" + reservoirOps.getOilProductionTotal("MSm3") + " MSm3"); + System.out.println("gas in place (GIP) " + reservoirOps.getGasInPlace("GSm3") + " GSm3"); + System.out.println("oil in place (OIP) " + reservoirOps.getOilInPlace("MSm3") + " MSm3"); + System.out.println("original oil in place (OOIP) " + reservoirOps.getOOIP("MSm3") + " MSm3"); + System.out.println("original gas in place (OGIP) " + reservoirOps.getOGIP("GSm3") + " GSm3"); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 100.0), 200.00); - testSystem.addComponent("nitrogen", 0.100); - testSystem.addComponent("methane", 30.00); - testSystem.addComponent("ethane", 1.0); - testSystem.addComponent("propane", 1.0); - testSystem.addComponent("i-butane", 1.0); - testSystem.addComponent("n-butane", 1.0); - testSystem.addComponent("n-hexane", 0.1); - testSystem.addComponent("n-heptane", 0.1); - testSystem.addComponent("n-nonane", 1.0); - testSystem.addComponent("nC10", 1.0); - testSystem.addComponent("nC12", 3.0); - testSystem.addComponent("nC15", 3.0); - testSystem.addComponent("nC20", 3.0); - testSystem.addComponent("water", 11.0); - testSystem.setMixingRule(2); - testSystem.setMultiPhaseCheck(true); - - SimpleReservoir reservoirOps = new SimpleReservoir("Well 1 reservoir"); - reservoirOps.setReservoirFluid(testSystem, 5.0 * 1e7, 552.0 * 1e6, 10.0e6); - - StreamInterface producedOilStream = reservoirOps.addOilProducer("oilproducer_1"); - StreamInterface injectorGasStream = reservoirOps.addGasInjector("gasproducer_1"); - StreamInterface producedGasStream = reservoirOps.addGasProducer("SLP_A32562G"); - StreamInterface waterInjectorStream = reservoirOps.addWaterInjector("SLP_WI32562O"); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(reservoirOps); - operations.save("c:/temp/resmode1.neqsim"); - - System.out.println("gas in place (GIP) " + reservoirOps.getGasInPlace("GSm3") + " GSm3"); - System.out.println("oil in place (OIP) " + reservoirOps.getOilInPlace("MSm3") + " MSm3"); - - // StreamInterface producedGasStream = - // reservoirOps.addGasProducer("SLP_A32562G"); - producedGasStream.setFlowRate(0.01, "MSm3/day"); - - // StreamInterface injectorGasStream = - // reservoirOps.addGasInjector("SLP_A32562GI"); - injectorGasStream.setFlowRate(0.01, "MSm3/day"); - // injectorGasStream.getFluid().setMolarComposition(.new double[0.1, 0.1]); - - // StreamInterface producedGasStream2 = - // reservoirOps.addGasProducer("SLP_A32562G2"); - // producedGasStream2.setFlowRate(0.011, "MSm3/hr"); - - producedOilStream.setFlowRate(50000000.0, "kg/day"); - - waterInjectorStream.setFlowRate(12100000.0, "kg/day"); - - // StreamInterface producedGasStream = reservoirOps.getGasOutStream(); - // producedGasStream.setFlowRate(1.0e-3, "MSm3/day"); - - // StreamInterface producedOilStream = reservoirOps.getOilOutStream(); - // producedOilStream.setFlowRate(1500000.0, "kg/hr"); - - reservoirOps.run(); - - reservoirOps.runTransient(60 * 60 * 24 * 3); - for (int i = 0; i < 1; i++) { - reservoirOps.runTransient(60 * 60 * 24 * 15); - System.out.println("water volume" - + reservoirOps.getReservoirFluid().getPhase("aqueous").getVolume("m3") / 1.0e6); - System.out.println( - "oil production total" + reservoirOps.getOilProductionTotal("Sm3") + " Sm3"); - System.out.println( - "total produced " + reservoirOps.getProductionTotal("MSm3 oe") + " MSm3 oe"); - if (reservoirOps.getFluid().getPressure() < 50.0) - break; - } - System.out.println("GOR gas " + reservoirOps.getGasProducer(0).getGOR()); - // System.out.println("GOR oil " + reservoirOps.getOilProducer(0).getGOR()); - System.out.println("GOR production " + reservoirOps.GORprodution()); - - // System.out.println("GOR oil " + reservoirOps.getOilProducer(0).getGOR()); - - System.out - .println("gas production " + reservoirOps.getGasProdution("Sm3/day") + " Sm3/day"); - System.out - .println("oil production " + reservoirOps.getOilProdution("Sm3/day") + " Sm3/day"); - - System.out.println( - "oil production total" + reservoirOps.getOilProductionTotal("Sm3") + " Sm3"); - - // reservoirOps.runTransient(60 * 60 * 24 * 365); - // reservoirOps.runTransient(60 * 60 * 24 * 365); - // reservoirOps.runTransient(60 * 60 * 24 * 365); - System.out.println( - "gas production total" + reservoirOps.getGasProductionTotal("GSm3") + " GSm3"); - - System.out.println( - "oil production total" + reservoirOps.getOilProductionTotal("MSm3") + " MSm3"); - System.out.println("gas in place (GIP) " + reservoirOps.getGasInPlace("GSm3") + " GSm3"); - System.out.println("oil in place (OIP) " + reservoirOps.getOilInPlace("MSm3") + " MSm3"); - System.out - .println("original oil in place (OOIP) " + reservoirOps.getOOIP("MSm3") + " MSm3"); - System.out - .println("original gas in place (OGIP) " + reservoirOps.getOGIP("GSm3") + " GSm3"); - - // reservoirOps.runTransient(60 * 60 * 24 * 365); - // producedGasStream.setFlowRate(4.0, "MSm3/day"); - // producedOilStream.setFlowRate(1.0, "kg/hr"); - - for (int i = 0; i < 300; i++) { - // reservoirOps.runTransient(60 * 60 * 24 * 365); - } - System.out.println("oil flow " + producedOilStream.getFlowRate("kg/hr")); - - AdiabaticTwoPhasePipe testPipe = new AdiabaticTwoPhasePipe("testPipe", producedOilStream); - testPipe.setLength(3300.0); - testPipe.setInletElevation(0.0); - testPipe.setOutletElevation(2200.0); - testPipe.setDiameter(2.69); - testPipe.setPressureOutLimit(80.0); - testPipe.setFlowLimit(producedOilStream.getFlowRate("kg/hr") * 0.4, "kg/hr"); - testPipe.setOutTemperature(273.15 + 50.0); - testPipe.run(); - System.out.println(" flow limit " + producedOilStream.getFlowRate("kg/hr") * 0.4); - System.out.println("oil flow " + producedOilStream.getFlowRate("kg/hr")); - // testPipe.getOutStream().displayResult(); - - for (int i = 0; i < 60; i++) { - reservoirOps.runTransient(60 * 60 * 24 * 25); - testPipe.run(); - System.out.println("oil flow " + producedOilStream.getFlowRate("kg/hr") + " pressure " - + producedOilStream.getPressure("bara") + " pipe out pres " - + testPipe.getOutletStream().getFluid().getPressure()); - } - } + // reservoirOps.runTransient(60 * 60 * 24 * 365); + // producedGasStream.setFlowRate(4.0, "MSm3/day"); + // producedOilStream.setFlowRate(1.0, "kg/hr"); - /** - *

- * Getter for the field gasProductionTotal. - *

- * - * @param unit a {@link java.lang.String} object - * @return a double - */ - public double getGasProductionTotal(String unit) { - if (unit.equals("MSm3")) - return gasProductionTotal / 1e6; - if (unit.equals("GSm3")) - return gasProductionTotal / 1e9; - return gasProductionTotal; - } - - /** - *

- * Getter for the field oilProductionTotal. - *

- * - * @param unit a {@link java.lang.String} object - * @return a double - */ - public double getOilProductionTotal(String unit) { - if (unit.equals("MSm3")) - return oilProductionTotal / 1e6; - return oilProductionTotal; - } - - /** - *

- * getProductionTotal. - *

- * - * @param unit a {@link java.lang.String} object - * @return a double - */ - public double getProductionTotal(String unit) { - double prod = getOilProductionTotal("Sm3") + getGasProductionTotal("Sm3") / 1.0e3; - if (unit.equals("MSm3 oe")) - return prod / 1e6; - return prod; - } - - /** - *

- * getOOIP. - *

- * - * @param unit a {@link java.lang.String} object - * @return a double - */ - public double getOOIP(String unit) { - if (unit.equals("MSm3")) - return OOIP / 1.0e6; - return OOIP; - } - - /** - *

- * getOGIP. - *

- * - * @param unit a {@link java.lang.String} object - * @return a double - */ - public double getOGIP(String unit) { - if (unit.equals("GSm3")) - return OGIP / 1.0e9; - return OGIP; - } - - /** - *

- * Getter for the field time. - *

- * - * @return a double - */ - public double getTime() { - return time; + for (int i = 0; i < 300; i++) { + // reservoirOps.runTransient(60 * 60 * 24 * 365); + } + System.out.println("oil flow " + producedOilStream.getFlowRate("kg/hr")); + + AdiabaticTwoPhasePipe testPipe = new AdiabaticTwoPhasePipe("testPipe", producedOilStream); + testPipe.setLength(3300.0); + testPipe.setInletElevation(0.0); + testPipe.setOutletElevation(2200.0); + testPipe.setDiameter(2.69); + testPipe.setPressureOutLimit(80.0); + testPipe.setFlowLimit(producedOilStream.getFlowRate("kg/hr") * 0.4, "kg/hr"); + testPipe.setOutTemperature(273.15 + 50.0); + testPipe.run(); + System.out.println(" flow limit " + producedOilStream.getFlowRate("kg/hr") * 0.4); + System.out.println("oil flow " + producedOilStream.getFlowRate("kg/hr")); + // testPipe.getOutStream().displayResult(); + + for (int i = 0; i < 60; i++) { + reservoirOps.runTransient(60 * 60 * 24 * 25); + testPipe.run(); + System.out.println("oil flow " + producedOilStream.getFlowRate("kg/hr") + " pressure " + + producedOilStream.getPressure("bara") + " pipe out pres " + + testPipe.getOutletStream().getFluid().getPressure()); + } + } + + /** + *

+ * Getter for the field gasProductionTotal. + *

+ * + * @param unit a {@link java.lang.String} object + * @return a double + */ + public double getGasProductionTotal(String unit) { + if (unit.equals("MSm3")) { + return gasProductionTotal / 1e6; + } + if (unit.equals("GSm3")) { + return gasProductionTotal / 1e9; + } + return gasProductionTotal; + } + + /** + *

+ * Getter for the field oilProductionTotal. + *

+ * + * @param unit a {@link java.lang.String} object + * @return a double + */ + public double getOilProductionTotal(String unit) { + if (unit.equals("MSm3")) { + return oilProductionTotal / 1e6; + } + return oilProductionTotal; + } + + /** + *

+ * getProductionTotal. + *

+ * + * @param unit a {@link java.lang.String} object + * @return a double + */ + public double getProductionTotal(String unit) { + double prod = getOilProductionTotal("Sm3") + getGasProductionTotal("Sm3") / 1.0e3; + if (unit.equals("MSm3 oe")) { + return prod / 1e6; + } + return prod; + } + + /** + *

+ * getOOIP. + *

+ * + * @param unit a {@link java.lang.String} object + * @return a double + */ + public double getOOIP(String unit) { + if (unit.equals("MSm3")) { + return OOIP / 1.0e6; + } + return OOIP; + } + + /** + *

+ * getOGIP. + *

+ * + * @param unit a {@link java.lang.String} object + * @return a double + */ + public double getOGIP(String unit) { + if (unit.equals("GSm3")) { + return OGIP / 1.0e9; } + return OGIP; + } + + /** + *

+ * Getter for the field time. + *

+ * + * @return a double + */ + public double getTime() { + return time; + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubber.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubber.java index 26ee860718..2043a6c150 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubber.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubber.java @@ -6,6 +6,7 @@ package neqsim.processSimulation.processEquipment.separator; import java.util.ArrayList; +import java.util.UUID; import neqsim.processSimulation.mechanicalDesign.separator.GasScrubberMechanicalDesign; import neqsim.processSimulation.processEquipment.separator.sectionType.SeparatorSection; import neqsim.processSimulation.processEquipment.stream.Stream; @@ -21,134 +22,143 @@ * @version $Id: $Id */ public class GasScrubber extends Separator { - private static final long serialVersionUID = 1000; - - SystemInterface thermoSystem, gasSystem, waterSystem, liquidSystem, thermoSystemCloned; - ArrayList scrubberSection = null; - StreamInterface inletStream; - StreamInterface gasOutStream; - StreamInterface liquidOutStream; - String name = new String(); - - /** - *

- * Constructor for GasScrubber. - *

- */ - @Deprecated - public GasScrubber() { - this("GasScrubber"); - } - - /** - *

- * Constructor for GasScrubber. - *

- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - @Deprecated - public GasScrubber(StreamInterface inletStream) { - this("GasScrubber", inletStream); - } - - /** - * Constructor for GasScrubber. - * - * @param name name of gas scrubber - */ - public GasScrubber(String name) { - super(name); - this.setOrientation("vertical"); - } - - /** - *

- * Constructor for GasScrubber. - *

- * - * @param name a {@link java.lang.String} object - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - public GasScrubber(String name, StreamInterface inletStream) { - super(name, inletStream); - this.setOrientation("vertical"); - } - - public GasScrubberMechanicalDesign getMechanicalDesign() { - return new GasScrubberMechanicalDesign(this); - } - - /** - *

- * Setter for the field inletStream. - *

- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - public void setInletStream(StreamInterface inletStream) { - this.inletStream = inletStream; - - thermoSystem = inletStream.getThermoSystem().clone(); - gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[0]); - gasOutStream = new Stream("gasOutStream", gasSystem); - - thermoSystem = inletStream.getThermoSystem().clone(); - liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]); - liquidOutStream = new Stream("liquidOutStream", liquidSystem); - } - - /** - *

- * addScrubberSection. - *

- * - * @param type a {@link java.lang.String} object - */ - public void addScrubberSection(String type) { - scrubberSection.add(new SeparatorSection("section" + scrubberSection.size() + 1, type, this)); - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getLiquidOutStream() { - return liquidOutStream; - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getGasOutStream() { - return gasOutStream; - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getGas() { - return getGasOutStream(); - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getLiquid() { - return getLiquidOutStream(); - } - - /** {@inheritDoc} */ - @Override - public void run() { - thermoSystem = inletStream.getThermoSystem().clone(); - gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[0]); - gasSystem.setNumberOfPhases(1); - gasOutStream.setThermoSystem(gasSystem); - - thermoSystem = inletStream.getThermoSystem().clone(); - liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]); - liquidSystem.setNumberOfPhases(1); - liquidOutStream.setThermoSystem(liquidSystem); - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - } + private static final long serialVersionUID = 1000; + + SystemInterface thermoSystem; + + SystemInterface gasSystem; + + SystemInterface waterSystem; + + SystemInterface liquidSystem; + + SystemInterface thermoSystemCloned; + + ArrayList scrubberSection = null; + StreamInterface inletStream; + StreamInterface gasOutStream; + StreamInterface liquidOutStream; + String name = new String(); + + /** + *

+ * Constructor for GasScrubber. + *

+ */ + @Deprecated + public GasScrubber() { + this("GasScrubber"); + } + + /** + *

+ * Constructor for GasScrubber. + *

+ * + * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + */ + @Deprecated + public GasScrubber(StreamInterface inletStream) { + this("GasScrubber", inletStream); + } + + /** + * Constructor for GasScrubber. + * + * @param name name of gas scrubber + */ + public GasScrubber(String name) { + super(name); + this.setOrientation("vertical"); + } + + /** + *

+ * Constructor for GasScrubber. + *

+ * + * @param name a {@link java.lang.String} object + * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + */ + public GasScrubber(String name, StreamInterface inletStream) { + super(name, inletStream); + this.setOrientation("vertical"); + } + + public GasScrubberMechanicalDesign getMechanicalDesign() { + return new GasScrubberMechanicalDesign(this); + } + + /** + *

+ * Setter for the field inletStream. + *

+ * + * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + */ + public void setInletStream(StreamInterface inletStream) { + this.inletStream = inletStream; + + thermoSystem = inletStream.getThermoSystem().clone(); + gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[0]); + gasOutStream = new Stream("gasOutStream", gasSystem); + + thermoSystem = inletStream.getThermoSystem().clone(); + liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]); + liquidOutStream = new Stream("liquidOutStream", liquidSystem); + } + + /** + *

+ * addScrubberSection. + *

+ * + * @param type a {@link java.lang.String} object + */ + public void addScrubberSection(String type) { + scrubberSection.add(new SeparatorSection("section" + scrubberSection.size() + 1, type, this)); + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getLiquidOutStream() { + return liquidOutStream; + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getGasOutStream() { + return gasOutStream; + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getGas() { + return getGasOutStream(); + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getLiquid() { + return getLiquidOutStream(); + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + thermoSystem = inletStream.getThermoSystem().clone(); + gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[0]); + gasSystem.setNumberOfPhases(1); + gasOutStream.setThermoSystem(gasSystem); + + thermoSystem = inletStream.getThermoSystem().clone(); + liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]); + liquidSystem.setNumberOfPhases(1); + liquidOutStream.setThermoSystem(liquidSystem); + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() {} } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubberSimple.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubberSimple.java index f67e17695b..dfff09ec42 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubberSimple.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubberSimple.java @@ -5,6 +5,7 @@ */ package neqsim.processSimulation.processEquipment.separator; +import java.util.UUID; import neqsim.processSimulation.mechanicalDesign.separator.GasScrubberMechanicalDesign; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; @@ -20,147 +21,152 @@ * @version $Id: $Id */ public class GasScrubberSimple extends Separator { - private static final long serialVersionUID = 1000; - - SystemInterface gasSystem, waterSystem, liquidSystem, thermoSystemCloned; - StreamInterface inletStream; - StreamInterface gasOutStream; - StreamInterface liquidOutStream; - String name = new String(); - - /** - *

- * Constructor for GasScrubberSimple. - *

- */ - @Deprecated - public GasScrubberSimple() { - this("GasScrubberSimple"); + private static final long serialVersionUID = 1000; + + SystemInterface gasSystem; + SystemInterface waterSystem; + SystemInterface liquidSystem; + SystemInterface thermoSystemCloned; + + StreamInterface inletStream; + StreamInterface gasOutStream; + StreamInterface liquidOutStream; + String name = new String(); + + /** + *

+ * Constructor for GasScrubberSimple. + *

+ */ + @Deprecated + public GasScrubberSimple() { + this("GasScrubberSimple"); + } + + /** + *

+ * Constructor for GasScrubberSimple. + *

+ * + * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + */ + @Deprecated + public GasScrubberSimple(StreamInterface inletStream) { + this("GasScrubberSimple", inletStream); + } + + /** + * Constructor for GasScrubberSimple. + * + * @param name name of scrubber + */ + public GasScrubberSimple(String name) { + super(name); + this.setOrientation("vertical"); + } + + /** + *

+ * Constructor for GasScrubberSimple. + *

+ * + * @param name a {@link java.lang.String} object + * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + */ + public GasScrubberSimple(String name, StreamInterface inletStream) { + super(name, inletStream); + this.setOrientation("vertical"); + } + + public GasScrubberMechanicalDesign getMechanicalDesign() { + return new GasScrubberMechanicalDesign(this); + } + + /** + *

+ * Setter for the field inletStream. + *

+ * + * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + */ + public void setInletStream(StreamInterface inletStream) { + this.inletStream = inletStream; + + thermoSystem = inletStream.getThermoSystem().clone(); + gasSystem = thermoSystem.phaseToSystem(0); + gasOutStream = new Stream("gasOutStream", gasSystem); + + thermoSystem = inletStream.getThermoSystem().clone(); + liquidSystem = thermoSystem.phaseToSystem(1); + liquidOutStream = new Stream("liquidOutStream", liquidSystem); + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getLiquidOutStream() { + return liquidOutStream; + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getGasOutStream() { + return gasOutStream; + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getGas() { + return getGasOutStream(); + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getLiquid() { + return getLiquidOutStream(); + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + thermoSystem = inletStream.getThermoSystem().clone(); + ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem); + thermoOps.TPflash(); + if (separatorSection.size() > 0) { + calcLiquidCarryoverFraction(); + thermoSystem.addLiquidToGas(getLiquidCarryoverFraction()); } - - /** - *

- * Constructor for GasScrubberSimple. - *

- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - @Deprecated - public GasScrubberSimple(StreamInterface inletStream) { - this("GasScrubberSimple", inletStream); - } - - /** - * Constructor for GasScrubberSimple. - * - * @param name name of scrubber - */ - public GasScrubberSimple(String name) { - super(name); - this.setOrientation("vertical"); - } - - /** - *

- * Constructor for GasScrubberSimple. - *

- * - * @param name a {@link java.lang.String} object - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - public GasScrubberSimple(String name, StreamInterface inletStream) { - super(name, inletStream); - this.setOrientation("vertical"); + gasSystem = thermoSystem.phaseToSystem(0); + gasSystem.setNumberOfPhases(1); + gasOutStream.setThermoSystem(gasSystem); + + thermoSystem = inletStream.getThermoSystem().clone(); + if (separatorSection.size() > 0) { + thermoSystem.addGasToLiquid(getGasCarryunderFraction()); + liquidSystem = thermoSystem.phaseToSystem(1); } - - public GasScrubberMechanicalDesign getMechanicalDesign() { - return new GasScrubberMechanicalDesign(this); - } - - /** - *

- * Setter for the field inletStream. - *

- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - public void setInletStream(StreamInterface inletStream) { - this.inletStream = inletStream; - - thermoSystem = inletStream.getThermoSystem().clone(); - gasSystem = thermoSystem.phaseToSystem(0); - gasOutStream = new Stream("gasOutStream", gasSystem); - - thermoSystem = inletStream.getThermoSystem().clone(); - liquidSystem = thermoSystem.phaseToSystem(1); - liquidOutStream = new Stream("liquidOutStream", liquidSystem); - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getLiquidOutStream() { - return liquidOutStream; + liquidSystem.setNumberOfPhases(1); + liquidOutStream.setThermoSystem(liquidSystem); + setCalculationIdentifier(id); + } + + /** + *

+ * calcLiquidCarryoverFraction. + *

+ * + * @return a double + */ + public double calcLiquidCarryoverFraction() { + double ktotal = 1.0; + + for (int i = 0; i < separatorSection.size(); i++) { + ktotal *= (1.0 - separatorSection.get(i).getEfficiency()); } - - /** {@inheritDoc} */ - @Override - public StreamInterface getGasOutStream() { - return gasOutStream; - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getGas() { - return getGasOutStream(); - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getLiquid() { - return getLiquidOutStream(); - } - - /** {@inheritDoc} */ - @Override - public void run() { - thermoSystem = inletStream.getThermoSystem().clone(); - ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem); - thermoOps.TPflash(); - if (separatorSection.size() > 0) { - calcLiquidCarryoverFraction(); - thermoSystem.addLiquidToGas(getLiquidCarryoverFraction()); - } - gasSystem = thermoSystem.phaseToSystem(0); - gasSystem.setNumberOfPhases(1); - gasOutStream.setThermoSystem(gasSystem); - - thermoSystem = inletStream.getThermoSystem().clone(); - if (separatorSection.size() > 0) { - thermoSystem.addGasToLiquid(getGasCarryunderFraction()); - liquidSystem = thermoSystem.phaseToSystem(1); - } - liquidSystem.setNumberOfPhases(1); - liquidOutStream.setThermoSystem(liquidSystem); - } - - /** - *

- * calcLiquidCarryoverFraction. - *

- * - * @return a double - */ - public double calcLiquidCarryoverFraction() { - double Ktot = 1.0; - - for (int i = 0; i < separatorSection.size(); i++) { - Ktot *= (1.0 - separatorSection.get(i).getEfficiency()); - } - System.out.println("Ktot " + (1.0 - Ktot)); - double area = getInternalDiameter() * getInternalDiameter() / 4.0 * 3.14; - double gasVel = - thermoSystem.getTotalNumberOfMoles() * thermoSystem.getMolarVolume() / 1e5 / area; - setLiquidCarryoverFraction(Ktot); - return gasVel; - } + System.out.println("Ktot " + (1.0 - ktotal)); + double area = getInternalDiameter() * getInternalDiameter() / 4.0 * 3.14; + double gasVel = + thermoSystem.getTotalNumberOfMoles() * thermoSystem.getMolarVolume() / 1e5 / area; + setLiquidCarryoverFraction(ktotal); + return gasVel; + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/Hydrocyclone.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/Hydrocyclone.java index efa4d92bc9..54fefd2e04 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/Hydrocyclone.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/Hydrocyclone.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.separator; +import java.util.UUID; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -38,9 +39,8 @@ public Hydrocyclone() { * Constructor for Hydrocyclone. *

* - * @param inletStream a - * {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object + * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object */ @Deprecated public Hydrocyclone(StreamInterface inletStream) { @@ -61,10 +61,9 @@ public Hydrocyclone(String name) { * Constructor for Hydrocyclone. *

* - * @param name a {@link java.lang.String} object - * @param inletStream a - * {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object + * @param name a {@link java.lang.String} object + * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object */ public Hydrocyclone(String name, StreamInterface inletStream) { super(name, inletStream); @@ -85,9 +84,7 @@ public void setInletStream(StreamInterface inletStream) { * Getter for the field waterOutStream. *

* - * @return a - * {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object + * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object */ public StreamInterface getWaterOutStream() { return waterOutStream; @@ -98,9 +95,7 @@ public StreamInterface getWaterOutStream() { * getOilOutStream. *

* - * @return a - * {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object + * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object */ public StreamInterface getOilOutStream() { return liquidOutStream; @@ -108,8 +103,8 @@ public StreamInterface getOilOutStream() { /** {@inheritDoc} */ @Override - public void run() { - inletStreamMixer.run(); + public void run(UUID id) { + inletStreamMixer.run(id); thermoSystem = inletStreamMixer.getOutletStream().getThermoSystem().clone(); // double oilInWaterIn = 0.0001; // @@ -137,7 +132,6 @@ public void run() { } else { gasOutStream.setThermoSystem(thermoSystem.getEmptySystemClone()); } - // //gasOutStream.run(); //// liquidSystem = thermoSystem.phaseToSystem(1); //// liquidOutStream.setThermoSystem(liquidSystem); @@ -148,8 +142,9 @@ public void run() { liquidOutStream.setThermoSystem(thermoSystem.getEmptySystemClone()); } // sOutStream.setPressure(overflowPressure, "bara"); - gasOutStream.run(); - liquidOutStream.run(); + gasOutStream.run(id); + liquidOutStream.run(id); + setCalculationIdentifier(id); } /** {@inheritDoc} */ diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/NeqGasScrubber.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/NeqGasScrubber.java index 6efa19914c..77ecee1357 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/NeqGasScrubber.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/NeqGasScrubber.java @@ -1,6 +1,7 @@ package neqsim.processSimulation.processEquipment.separator; import java.util.ArrayList; +import java.util.UUID; import neqsim.processSimulation.mechanicalDesign.separator.GasScrubberMechanicalDesign; import neqsim.processSimulation.processEquipment.separator.sectionType.SeparatorSection; import neqsim.processSimulation.processEquipment.stream.Stream; @@ -16,137 +17,141 @@ * @version $Id: $Id */ public class NeqGasScrubber extends Separator { - private static final long serialVersionUID = 1000; - - SystemInterface thermoSystem, gasSystem, waterSystem, liquidSystem, thermoSystemCloned; - ArrayList scrubberSection = null; - StreamInterface inletStream; - StreamInterface gasOutStream; - StreamInterface liquidOutStream; - String name = new String(); - - /** - *

- * Constructor for NeqGasScrubber. - *

- */ - @Deprecated - public NeqGasScrubber() { - this("NeqGasScrubber"); - } - - /** - *

- * Constructor for NeqGasScrubber. - *

- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public NeqGasScrubber(StreamInterface inletStream) { - this("NeqGasScrubber", inletStream); - } - - /** - * Constructor for NeqGasScrubber. - * - * @param name name of unit operation - */ - public NeqGasScrubber(String name) { - super(name); - this.setOrientation("vertical"); - } - - /** - *

- * Constructor for NeqGasScrubber. - *

- * - * @param name a {@link java.lang.String} object - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - public NeqGasScrubber(String name, StreamInterface inletStream) { - super(name, inletStream); - this.setOrientation("vertical"); - } - - public GasScrubberMechanicalDesign getMechanicalDesign() { - return new GasScrubberMechanicalDesign(this); - } - - /** - *

- * Setter for the field inletStream. - *

- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - public void setInletStream(StreamInterface inletStream) { - this.inletStream = inletStream; - - thermoSystem = inletStream.getThermoSystem().clone(); - gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[0]); - gasOutStream = new Stream("gasOutStream", gasSystem); - - thermoSystem = inletStream.getThermoSystem().clone(); - liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]); - liquidOutStream = new Stream("liquidOutStream", liquidSystem); - } - - /** - *

- * addScrubberSection. - *

- * - * @param type a {@link java.lang.String} object - */ - public void addScrubberSection(String type) { - scrubberSection.add(new SeparatorSection("section" + scrubberSection.size() + 1, type, this)); - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getLiquidOutStream() { - return liquidOutStream; - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getGasOutStream() { - return gasOutStream; - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getGas() { - return getGasOutStream(); - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getLiquid() { - return getLiquidOutStream(); - } - - /** {@inheritDoc} */ - @Override - public void run() { - thermoSystem = inletStream.getThermoSystem().clone(); - gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[0]); - gasSystem.setNumberOfPhases(1); - gasOutStream.setThermoSystem(gasSystem); - - thermoSystem = inletStream.getThermoSystem().clone(); - liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]); - liquidSystem.setNumberOfPhases(1); - liquidOutStream.setThermoSystem(liquidSystem); - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - } + private static final long serialVersionUID = 1000; + + SystemInterface thermoSystem; + SystemInterface gasSystem; + SystemInterface waterSystem; + SystemInterface liquidSystem; + SystemInterface thermoSystemCloned; + ArrayList scrubberSection = null; + StreamInterface inletStream; + StreamInterface gasOutStream; + StreamInterface liquidOutStream; + String name = new String(); + + /** + *

+ * Constructor for NeqGasScrubber. + *

+ */ + @Deprecated + public NeqGasScrubber() { + this("NeqGasScrubber"); + } + + /** + *

+ * Constructor for NeqGasScrubber. + *

+ * + * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + @Deprecated + public NeqGasScrubber(StreamInterface inletStream) { + this("NeqGasScrubber", inletStream); + } + + /** + * Constructor for NeqGasScrubber. + * + * @param name name of unit operation + */ + public NeqGasScrubber(String name) { + super(name); + this.setOrientation("vertical"); + } + + /** + *

+ * Constructor for NeqGasScrubber. + *

+ * + * @param name a {@link java.lang.String} object + * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public NeqGasScrubber(String name, StreamInterface inletStream) { + super(name, inletStream); + this.setOrientation("vertical"); + } + + public GasScrubberMechanicalDesign getMechanicalDesign() { + return new GasScrubberMechanicalDesign(this); + } + + /** + *

+ * Setter for the field inletStream. + *

+ * + * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public void setInletStream(StreamInterface inletStream) { + this.inletStream = inletStream; + + thermoSystem = inletStream.getThermoSystem().clone(); + gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[0]); + gasOutStream = new Stream("gasOutStream", gasSystem); + + thermoSystem = inletStream.getThermoSystem().clone(); + liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]); + liquidOutStream = new Stream("liquidOutStream", liquidSystem); + } + + /** + *

+ * addScrubberSection. + *

+ * + * @param type a {@link java.lang.String} object + */ + public void addScrubberSection(String type) { + scrubberSection.add(new SeparatorSection("section" + scrubberSection.size() + 1, type, this)); + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getLiquidOutStream() { + return liquidOutStream; + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getGasOutStream() { + return gasOutStream; + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getGas() { + return getGasOutStream(); + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getLiquid() { + return getLiquidOutStream(); + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + thermoSystem = inletStream.getThermoSystem().clone(); + gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[0]); + gasSystem.setNumberOfPhases(1); + gasOutStream.setThermoSystem(gasSystem); + + thermoSystem = inletStream.getThermoSystem().clone(); + liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]); + liquidSystem.setNumberOfPhases(1); + liquidOutStream.setThermoSystem(liquidSystem); + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() {} } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java index deddf5ec0a..e500cb95c4 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java @@ -7,6 +7,7 @@ import java.util.ArrayList; import java.util.Objects; +import java.util.UUID; import neqsim.processSimulation.mechanicalDesign.separator.SeparatorMechanicalDesign; import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; import neqsim.processSimulation.processEquipment.mixer.Mixer; @@ -194,8 +195,8 @@ public SystemInterface getThermoSystem() { /** {@inheritDoc} */ @Override - public void run() { - inletStreamMixer.run(); + public void run(UUID id) { + inletStreamMixer.run(id); thermoSystem2 = inletStreamMixer.getOutletStream().getThermoSystem().clone(); thermoSystem2.setPressure(thermoSystem2.getPressure() - pressureDrop); @@ -212,12 +213,12 @@ public void run() { liquidOutStream.setThermoSystem(thermoSystem2.getEmptySystemClone()); } if (thermoSystem2.hasPhaseType("gas")) { - gasOutStream.run(); + gasOutStream.run(id); } else { gasOutStream.getFluid().init(3); } if (thermoSystem2.hasPhaseType("aqueous") || thermoSystem2.hasPhaseType("oil")) { - liquidOutStream.run(); + liquidOutStream.run(id); } else { liquidOutStream.getFluid().init(3); } @@ -263,6 +264,7 @@ public void run() { e.printStackTrace(); } thermoSystem = thermoSystem2; + setCalculationIdentifier(id); } /** {@inheritDoc} */ @@ -279,13 +281,14 @@ public String[][] getResultTable() { /** {@inheritDoc} */ @Override - public void runTransient(double dt) { + public void runTransient(double dt, UUID id) { if (getCalculateSteadyState()) { - run(); + run(id); + increaseTime(dt); return; } - inletStreamMixer.run(); + inletStreamMixer.run(id); // System.out.println("moles out" + // liquidOutStream.getThermoSystem().getTotalNumberOfMoles()); @@ -325,6 +328,7 @@ public void runTransient(double dt) { * getSeparatorLength(); gasVolume = (1.0 - getLiquidLevel()) * 3.14 / 4.0 * getInternalDiameter() * getInternalDiameter() * getSeparatorLength(); + setCalculationIdentifier(id); } /** @@ -343,9 +347,11 @@ public void setTempPres(double temp, double pres) { gasOutStream.getThermoSystem().setPressure(pres); liquidOutStream.getThermoSystem().setPressure(pres); - inletStreamMixer.run(); - gasOutStream.run(); - liquidOutStream.run(); + UUID id = UUID.randomUUID(); + + inletStreamMixer.run(id); + gasOutStream.run(id); + liquidOutStream.run(id); } /** diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/ThreePhaseSeparator.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/ThreePhaseSeparator.java index edecc81807..3bde197351 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/ThreePhaseSeparator.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/ThreePhaseSeparator.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.separator; +import java.util.UUID; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -155,8 +156,8 @@ public StreamInterface getOilOutStream() { /** {@inheritDoc} */ @Override - public void run() { - inletStreamMixer.run(); + public void run(UUID id) { + inletStreamMixer.run(id); thermoSystem = inletStreamMixer.getOutletStream().getThermoSystem().clone(); thermoSystem.setMultiPhaseCheck(true); @@ -182,32 +183,31 @@ public void run() { // //gasOutStream.setThermoSystem(gasSystem); if (thermoSystem.hasPhaseType("gas")) { gasOutStream.setThermoSystemFromPhase(thermoSystem, "gas"); - gasOutStream.run(); + gasOutStream.run(id); } else { gasOutStream.setThermoSystem(thermoSystem.getEmptySystemClone()); } - // //gasOutStream.run(); //// liquidSystem = thermoSystem.phaseToSystem(1); //// liquidOutStream.setThermoSystem(liquidSystem); if (thermoSystem.hasPhaseType("oil")) { // thermoSystem.display(); liquidOutStream.setThermoSystemFromPhase(thermoSystem, "oil"); - liquidOutStream.run(); + liquidOutStream.run(id); // thermoSystem.display(); } else { liquidOutStream.setThermoSystem(thermoSystem.getEmptySystemClone()); } - // //liquidOutStream.run(); //// waterSystem = thermoSystem.phaseToSystem(2); //// waterOutStream.setThermoSystem(waterSystem); if (thermoSystem.hasPhaseType("aqueous")) { waterOutStream.setThermoSystemFromPhase(thermoSystem, "aqueous"); - waterOutStream.run(); + waterOutStream.run(id); } else { waterOutStream.setThermoSystem(thermoSystem.getEmptySystemClone()); } + setCalculationIdentifier(id); } /** {@inheritDoc} */ diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/TwoPhaseSeparator.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/TwoPhaseSeparator.java index 226595cb01..266ee842a8 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/TwoPhaseSeparator.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/TwoPhaseSeparator.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.separator; +import java.util.UUID; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.thermo.system.SystemInterface; @@ -13,113 +14,122 @@ * @version $Id: $Id */ public class TwoPhaseSeparator extends Separator { - private static final long serialVersionUID = 1000; - - SystemInterface thermoSystem, gasSystem, waterSystem, liquidSystem, thermoSystemCloned; - StreamInterface inletStream; - StreamInterface gasOutStream; - StreamInterface liquidOutStream; - String name = new String(); - - /** - *

- * Constructor for TwoPhaseSeparator. - *

- */ - @Deprecated - public TwoPhaseSeparator() { - this("TwoPhaseSeparator"); - } - - /** - *

- * Constructor for TwoPhaseSeparator. - *

- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public TwoPhaseSeparator(StreamInterface inletStream) { - this("TwoPhaseSeparator", inletStream); - } - - /** - * Constructor for TwoPhaseSeparator. - * - * @param name name of separator - */ - public TwoPhaseSeparator(String name) { - super(name); - } - - /** - *

- * Constructor for TwoPhaseSeparator. - *

- * - * @param name a {@link java.lang.String} object - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - public TwoPhaseSeparator(String name, StreamInterface inletStream) { - super(name, inletStream); - } - - /** {@inheritDoc} */ - @Override - public void setInletStream(StreamInterface inletStream) { - this.inletStream = inletStream; - - thermoSystem = inletStream.getThermoSystem().clone(); - gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[0]); - gasOutStream = new Stream("gasOutStream", gasSystem); - - thermoSystem = inletStream.getThermoSystem().clone(); - liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]); - liquidOutStream = new Stream("liquidOutStream", liquidSystem); - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getLiquidOutStream() { - return liquidOutStream; - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getGasOutStream() { - return gasOutStream; - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getGas() { - return getGasOutStream(); - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getLiquid() { - return getLiquidOutStream(); - } - - /** {@inheritDoc} */ - @Override - public void run() { - thermoSystem = inletStream.getThermoSystem().clone(); - gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[0]); - gasSystem.setNumberOfPhases(1); - gasOutStream.setThermoSystem(gasSystem); - - thermoSystem = inletStream.getThermoSystem().clone(); - liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]); - liquidSystem.setNumberOfPhases(1); - liquidOutStream.setThermoSystem(liquidSystem); - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - } + private static final long serialVersionUID = 1000; + + SystemInterface thermoSystem; + + SystemInterface gasSystem; + + SystemInterface waterSystem; + + SystemInterface liquidSystem; + + SystemInterface thermoSystemCloned; + + StreamInterface inletStream; + StreamInterface gasOutStream; + StreamInterface liquidOutStream; + String name = new String(); + + /** + *

+ * Constructor for TwoPhaseSeparator. + *

+ */ + @Deprecated + public TwoPhaseSeparator() { + this("TwoPhaseSeparator"); + } + + /** + *

+ * Constructor for TwoPhaseSeparator. + *

+ * + * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + @Deprecated + public TwoPhaseSeparator(StreamInterface inletStream) { + this("TwoPhaseSeparator", inletStream); + } + + /** + * Constructor for TwoPhaseSeparator. + * + * @param name name of separator + */ + public TwoPhaseSeparator(String name) { + super(name); + } + + /** + *

+ * Constructor for TwoPhaseSeparator. + *

+ * + * @param name a {@link java.lang.String} object + * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public TwoPhaseSeparator(String name, StreamInterface inletStream) { + super(name, inletStream); + } + + /** {@inheritDoc} */ + @Override + public void setInletStream(StreamInterface inletStream) { + this.inletStream = inletStream; + + thermoSystem = inletStream.getThermoSystem().clone(); + gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[0]); + gasOutStream = new Stream("gasOutStream", gasSystem); + + thermoSystem = inletStream.getThermoSystem().clone(); + liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]); + liquidOutStream = new Stream("liquidOutStream", liquidSystem); + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getLiquidOutStream() { + return liquidOutStream; + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getGasOutStream() { + return gasOutStream; + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getGas() { + return getGasOutStream(); + } + + /** {@inheritDoc} */ + @Override + public StreamInterface getLiquid() { + return getLiquidOutStream(); + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + thermoSystem = inletStream.getThermoSystem().clone(); + gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[0]); + gasSystem.setNumberOfPhases(1); + gasOutStream.setThermoSystem(gasSystem); + + thermoSystem = inletStream.getThermoSystem().clone(); + liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]); + liquidSystem.setNumberOfPhases(1); + liquidOutStream.setThermoSystem(liquidSystem); + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() {} } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/MeshSection.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/MeshSection.java index c9f6a7273f..c78c5f31e5 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/MeshSection.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/MeshSection.java @@ -14,7 +14,6 @@ public class MeshSection extends SeparatorSection { private static final long serialVersionUID = 1000; - /** *

* Constructor for MeshSection. diff --git a/src/main/java/neqsim/processSimulation/processEquipment/splitter/ComponentSplitter.java b/src/main/java/neqsim/processSimulation/processEquipment/splitter/ComponentSplitter.java index b09b6637e5..8800528881 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/splitter/ComponentSplitter.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/splitter/ComponentSplitter.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.splitter; +import java.util.UUID; import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; @@ -78,7 +79,7 @@ public StreamInterface getSplitStream(int i) { /** {@inheritDoc} */ @Override - public void run() { + public void run(UUID id) { for (int i = 0; i < 2; i++) { thermoSystem = inletStream.getThermoSystem().clone(); thermoSystem.setEmptyFluid(); @@ -101,6 +102,7 @@ public void run() { new ThermodynamicOperations(splitStream[i].getThermoSystem()); thermoOps.TPflash(); } + setCalculationIdentifier(id); } /** {@inheritDoc} */ diff --git a/src/main/java/neqsim/processSimulation/processEquipment/splitter/Splitter.java b/src/main/java/neqsim/processSimulation/processEquipment/splitter/Splitter.java index 2bf790a6d1..51f9822098 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/splitter/Splitter.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/splitter/Splitter.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.splitter; +import java.util.UUID; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; @@ -138,21 +139,21 @@ public StreamInterface getSplitStream(int i) { /** {@inheritDoc} */ @Override - public void run() { + public void run(UUID id) { double totSplit = 0.0; for (int i = 0; i < splitNumber; i++) { - if(splitFactor[i]<0) { + if (splitFactor[i] < 0) { logger.debug("split factor negative = " + splitFactor[i]); splitFactor[i] = 0.0; } totSplit += splitFactor[i]; } - if(Math.abs(totSplit-1.0)>1e-10) { + if (Math.abs(totSplit - 1.0) > 1e-10) { logger.debug("total split factor different from 0 in splitter - totsplit = " + totSplit); logger.debug("setting first split to = " + (1.0 - totSplit)); splitFactor[0] = 1.0 - totSplit; } - + for (int i = 0; i < splitNumber; i++) { thermoSystem = inletStream.getThermoSystem().clone(); thermoSystem.init(0); @@ -166,6 +167,7 @@ public void run() { new ThermodynamicOperations(splitStream[i].getThermoSystem()); thermoOps.TPflash(); } + setCalculationIdentifier(id); } /** {@inheritDoc} */ diff --git a/src/main/java/neqsim/processSimulation/processEquipment/stream/EquilibriumStream.java b/src/main/java/neqsim/processSimulation/processEquipment/stream/EquilibriumStream.java index ea73e80a5f..c46c1bfeef 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/stream/EquilibriumStream.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/stream/EquilibriumStream.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.stream; +import java.util.UUID; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -12,84 +13,84 @@ * @version $Id: $Id */ public class EquilibriumStream extends Stream { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for EquilibriumStream. - *

- */ - @Deprecated - public EquilibriumStream() {} + /** + *

+ * Constructor for EquilibriumStream. + *

+ */ + @Deprecated + public EquilibriumStream() {} - /** - *

- * Constructor for EquilibriumStream. - *

- * - * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - @Deprecated - public EquilibriumStream(SystemInterface thermoSystem) { - super(thermoSystem); - } + /** + *

+ * Constructor for EquilibriumStream. + *

+ * + * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object + */ + @Deprecated + public EquilibriumStream(SystemInterface thermoSystem) { + super(thermoSystem); + } - /** - *

- * Constructor for EquilibriumStream. - *

- * - * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public EquilibriumStream(StreamInterface stream) { - this("EquilibriumStream", stream.getThermoSystem()); - } + /** + *

+ * Constructor for EquilibriumStream. + *

+ * + * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + @Deprecated + public EquilibriumStream(StreamInterface stream) { + this("EquilibriumStream", stream.getThermoSystem()); + } - /** - * Constructor for EquilibriumStream. - * - * @param name name of stream - */ - public EquilibriumStream(String name) { - super(name); - } + /** + * Constructor for EquilibriumStream. + * + * @param name name of stream + */ + public EquilibriumStream(String name) { + super(name); + } - /** - *

- * Constructor for EquilibriumStream. - *

- * - * @param name a {@link java.lang.String} object - * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - public EquilibriumStream(String name, SystemInterface thermoSystem) { - super(name, thermoSystem); - } + /** + *

+ * Constructor for EquilibriumStream. + *

+ * + * @param name a {@link java.lang.String} object + * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object + */ + public EquilibriumStream(String name, SystemInterface thermoSystem) { + super(name, thermoSystem); + } - /** {@inheritDoc} */ - @Override - public EquilibriumStream clone() { - EquilibriumStream clonedStream = null; + /** {@inheritDoc} */ + @Override + public EquilibriumStream clone() { + EquilibriumStream clonedStream = null; - try { - clonedStream = (EquilibriumStream) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); - } - - thermoSystem = thermoSystem.clone(); - return clonedStream; + try { + clonedStream = (EquilibriumStream) super.clone(); + } catch (Exception e) { + e.printStackTrace(System.err); } - /** {@inheritDoc} */ - @Override - public void run() { - System.out.println("start flashing stream... " + streamNumber); - ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem); - thermoOps.TPflash(); - System.out.println("number of phases: " + thermoSystem.getNumberOfPhases()); - System.out.println("beta: " + thermoSystem.getBeta()); - } + thermoSystem = thermoSystem.clone(); + return clonedStream; + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + System.out.println("start flashing stream... " + streamNumber); + ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem); + thermoOps.TPflash(); + System.out.println("number of phases: " + thermoSystem.getNumberOfPhases()); + System.out.println("beta: " + thermoSystem.getBeta()); + setCalculationIdentifier(id); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/stream/IronIonSaturationStream.java b/src/main/java/neqsim/processSimulation/processEquipment/stream/IronIonSaturationStream.java index 468d250cb8..da6cfdbd76 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/stream/IronIonSaturationStream.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/stream/IronIonSaturationStream.java @@ -3,8 +3,10 @@ * * Created on 12. mars 2001, 13:11 */ + package neqsim.processSimulation.processEquipment.stream; +import java.util.UUID; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -17,123 +19,122 @@ * @version $Id: $Id */ public class IronIonSaturationStream extends Stream { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - protected SystemInterface reactiveThermoSystem; + protected SystemInterface reactiveThermoSystem; - /** - *

- * Constructor for IronIonSaturationStream. - *

- */ - @Deprecated - public IronIonSaturationStream() { - this("IronIonSaturationStream"); - } + /** + *

+ * Constructor for IronIonSaturationStream. + *

+ */ + @Deprecated + public IronIonSaturationStream() { + this("IronIonSaturationStream"); + } - /** - *

- * Constructor for IronIonSaturationStream. - *

- * - * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - @Deprecated - public IronIonSaturationStream(SystemInterface thermoSystem) { - this("IronIonSaturationStream", thermoSystem); - } + /** + *

+ * Constructor for IronIonSaturationStream. + *

+ * + * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object + */ + @Deprecated + public IronIonSaturationStream(SystemInterface thermoSystem) { + this("IronIonSaturationStream", thermoSystem); + } - /** - *

- * Constructor for IronIonSaturationStream. - *

- * - * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public IronIonSaturationStream(StreamInterface stream) { - this("IronIonSaturationStream", stream); - } + /** + *

+ * Constructor for IronIonSaturationStream. + *

+ * + * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + @Deprecated + public IronIonSaturationStream(StreamInterface stream) { + this("IronIonSaturationStream", stream); + } - /** - * Constructor for IronIonSaturationStream. - * - * @param name name of stream - */ - public IronIonSaturationStream(String name) { - super(name); - } + /** + * Constructor for IronIonSaturationStream. + * + * @param name name of stream + */ + public IronIonSaturationStream(String name) { + super(name); + } - /** - * Constructor for IronIonSaturationStream. - * - * @param name name of stream - * @param stream input stream - */ - public IronIonSaturationStream(String name, StreamInterface stream) { - super(name, stream); - } + /** + * Constructor for IronIonSaturationStream. + * + * @param name name of stream + * @param stream input stream + */ + public IronIonSaturationStream(String name, StreamInterface stream) { + super(name, stream); + } - /** - *

- * Constructor for IronIonSaturationStream. - *

- * - * @param name a {@link java.lang.String} object - * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - public IronIonSaturationStream(String name, SystemInterface thermoSystem) { - super(name, thermoSystem); - } + /** + *

+ * Constructor for IronIonSaturationStream. + *

+ * + * @param name a {@link java.lang.String} object + * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object + */ + public IronIonSaturationStream(String name, SystemInterface thermoSystem) { + super(name, thermoSystem); + } - /** {@inheritDoc} */ - @Override - public IronIonSaturationStream clone() { - IronIonSaturationStream clonedSystem = null; - try { - clonedSystem = (IronIonSaturationStream) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); - } - return clonedSystem; + /** {@inheritDoc} */ + @Override + public IronIonSaturationStream clone() { + IronIonSaturationStream clonedSystem = null; + try { + clonedSystem = (IronIonSaturationStream) super.clone(); + } catch (Exception e) { + e.printStackTrace(System.err); } + return clonedSystem; + } - /** {@inheritDoc} */ - @Override - public void run() { - System.out.println("start flashing stream... " + streamNumber); - if (stream != null) { - thermoSystem = this.stream.getThermoSystem().clone(); - } - if (stream != null) { - reactiveThermoSystem = - this.stream.getThermoSystem().setModel("Electrolyte-CPA-EOS-statoil"); - } - reactiveThermoSystem.addComponent("Fe++", 1e-6); - // reactiveThermoSystem.chemicalReactionInit(); - // reactiveThermoSystem.createDatabase(true); - // reactiveThermoSystem.addComponent("water", - // reactiveThermoSystem.getPhase(0).getComponent("MEG").getNumberOfmoles()); - ThermodynamicOperations thermoOps = new ThermodynamicOperations(reactiveThermoSystem); - thermoOps.TPflash(); - reactiveThermoSystem.display(); - try { - System.out.println("aqueous phase number " - + reactiveThermoSystem.getPhaseNumberOfPhase("aqueous")); - thermoOps.addIonToScaleSaturation(reactiveThermoSystem.getPhaseNumberOfPhase("aqueous"), - "FeCO3", "Fe++"); - } catch (Exception ex) { - ex.printStackTrace(); - } - reactiveThermoSystem.display(); - System.out.println("number of phases: " + reactiveThermoSystem.getNumberOfPhases()); - System.out.println("beta: " + reactiveThermoSystem.getBeta()); + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + System.out.println("start flashing stream... " + streamNumber); + if (stream != null) { + thermoSystem = this.stream.getThermoSystem().clone(); } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - reactiveThermoSystem.display(name); + if (stream != null) { + reactiveThermoSystem = this.stream.getThermoSystem().setModel("Electrolyte-CPA-EOS-statoil"); } + reactiveThermoSystem.addComponent("Fe++", 1e-6); + // reactiveThermoSystem.chemicalReactionInit(); + // reactiveThermoSystem.createDatabase(true); + // reactiveThermoSystem.addComponent("water", + // reactiveThermoSystem.getPhase(0).getComponent("MEG").getNumberOfmoles()); + ThermodynamicOperations thermoOps = new ThermodynamicOperations(reactiveThermoSystem); + thermoOps.TPflash(); + reactiveThermoSystem.display(); + try { + System.out + .println("aqueous phase number " + reactiveThermoSystem.getPhaseNumberOfPhase("aqueous")); + thermoOps.addIonToScaleSaturation(reactiveThermoSystem.getPhaseNumberOfPhase("aqueous"), + "FeCO3", "Fe++"); + } catch (Exception ex) { + ex.printStackTrace(); + } + reactiveThermoSystem.display(); + System.out.println("number of phases: " + reactiveThermoSystem.getNumberOfPhases()); + System.out.println("beta: " + reactiveThermoSystem.getBeta()); + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + reactiveThermoSystem.display(name); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/stream/NeqStream.java b/src/main/java/neqsim/processSimulation/processEquipment/stream/NeqStream.java index b4197b1cd8..89697acb75 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/stream/NeqStream.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/stream/NeqStream.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.stream; +import java.util.UUID; import neqsim.thermo.system.SystemInterface; /** @@ -11,103 +12,103 @@ * @version $Id: $Id */ public class NeqStream extends Stream { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for NeqStream. - *

- */ - @Deprecated - public NeqStream() { - super("NeqStream"); - } + /** + *

+ * Constructor for NeqStream. + *

+ */ + @Deprecated + public NeqStream() { + super("NeqStream"); + } - /** - *

- * Constructor for NeqStream. - *

- * - * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - @Deprecated - public NeqStream(SystemInterface thermoSystem) { - super(thermoSystem); - } + /** + *

+ * Constructor for NeqStream. + *

+ * + * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object + */ + @Deprecated + public NeqStream(SystemInterface thermoSystem) { + super(thermoSystem); + } - /** - *

- * Constructor for NeqStream. - *

- * - * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public NeqStream(StreamInterface stream) { - super(stream); - } + /** + *

+ * Constructor for NeqStream. + *

+ * + * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + @Deprecated + public NeqStream(StreamInterface stream) { + super(stream); + } - /** - * Constructor for NeqStream. - * - * @param name name of stream - */ - public NeqStream(String name) { - super(name); - } + /** + * Constructor for NeqStream. + * + * @param name name of stream + */ + public NeqStream(String name) { + super(name); + } - /** - * Constructor for NeqStream. - * - * @param name name of stream - * @param stream input stream - */ - public NeqStream(String name, StreamInterface stream) { - super(name, stream); - } + /** + * Constructor for NeqStream. + * + * @param name name of stream + * @param stream input stream + */ + public NeqStream(String name, StreamInterface stream) { + super(name, stream); + } - /** - *

- * Constructor for NeqStream. - *

- * - * @param name a {@link java.lang.String} object - * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - public NeqStream(String name, SystemInterface thermoSystem) { - super(name, thermoSystem); - } + /** + *

+ * Constructor for NeqStream. + *

+ * + * @param name a {@link java.lang.String} object + * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object + */ + public NeqStream(String name, SystemInterface thermoSystem) { + super(name, thermoSystem); + } - /** {@inheritDoc} */ - @Override - public NeqStream clone() { - NeqStream clonedStream = null; + /** {@inheritDoc} */ + @Override + public NeqStream clone() { + NeqStream clonedStream = null; - try { - clonedStream = (NeqStream) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); - } + try { + clonedStream = (NeqStream) super.clone(); + } catch (Exception e) { + e.printStackTrace(System.err); + } - thermoSystem = thermoSystem.clone(); + thermoSystem = thermoSystem.clone(); - return clonedStream; - } + return clonedStream; + } - /** {@inheritDoc} */ - @Override - public void run() { - System.out.println("start flashing stream... " + streamNumber); - if (stream != null) { - thermoSystem = this.stream.getThermoSystem().clone(); - } - this.thermoSystem.init_x_y(); - this.thermoSystem.initBeta(); - this.thermoSystem.init(3); - // thermoOps = new ThermodynamicOperations(thermoSystem); - // thermoOps.TPflash(); - System.out.println("number of phases: " + thermoSystem.getNumberOfPhases()); - System.out.println("beta: " + thermoSystem.getBeta()); + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + System.out.println("start flashing stream... " + streamNumber); + if (stream != null) { + thermoSystem = this.stream.getThermoSystem().clone(); } + this.thermoSystem.init_x_y(); + this.thermoSystem.initBeta(); + this.thermoSystem.init(3); + // thermoOps = new ThermodynamicOperations(thermoSystem); + // thermoOps.TPflash(); + System.out.println("number of phases: " + thermoSystem.getNumberOfPhases()); + System.out.println("beta: " + thermoSystem.getBeta()); + setCalculationIdentifier(id); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/stream/ScalePotentialCheckStream.java b/src/main/java/neqsim/processSimulation/processEquipment/stream/ScalePotentialCheckStream.java index aa87aac852..bb9d91d137 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/stream/ScalePotentialCheckStream.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/stream/ScalePotentialCheckStream.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.stream; +import java.util.UUID; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -12,110 +13,109 @@ * @version $Id: $Id */ public class ScalePotentialCheckStream extends Stream { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - protected SystemInterface reactiveThermoSystem; + protected SystemInterface reactiveThermoSystem; - /** - *

- * Constructor for ScalePotentialCheckStream. - *

- */ - @Deprecated - public ScalePotentialCheckStream() { - super("ScalePotentialCheckStream"); - } + /** + *

+ * Constructor for ScalePotentialCheckStream. + *

+ */ + @Deprecated + public ScalePotentialCheckStream() { + super("ScalePotentialCheckStream"); + } - /** - *

- * Constructor for ScalePotentialCheckStream. - *

- * - * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - public ScalePotentialCheckStream(SystemInterface thermoSystem) { - super("ScalePotentialCheckStream", thermoSystem); - } + /** + *

+ * Constructor for ScalePotentialCheckStream. + *

+ * + * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object + */ + public ScalePotentialCheckStream(SystemInterface thermoSystem) { + super("ScalePotentialCheckStream", thermoSystem); + } - /** - *

- * Constructor for ScalePotentialCheckStream. - *

- * - * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public ScalePotentialCheckStream(StreamInterface stream) { - super("ScalePotentialCheckStream", stream); - } + /** + *

+ * Constructor for ScalePotentialCheckStream. + *

+ * + * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + @Deprecated + public ScalePotentialCheckStream(StreamInterface stream) { + super("ScalePotentialCheckStream", stream); + } - /** - * Constructor for ScalePotentialCheckStream. - * - * @param name name of unit operation - */ - public ScalePotentialCheckStream(String name) { - super(name); - } + /** + * Constructor for ScalePotentialCheckStream. + * + * @param name name of unit operation + */ + public ScalePotentialCheckStream(String name) { + super(name); + } - /** - * Constructor for ScalePotentialCheckStream. - * - * @param name name of stream - * @param stream input stream - */ - public ScalePotentialCheckStream(String name, StreamInterface stream) { - super(name, stream); - } + /** + * Constructor for ScalePotentialCheckStream. + * + * @param name name of stream + * @param stream input stream + */ + public ScalePotentialCheckStream(String name, StreamInterface stream) { + super(name, stream); + } - /** - *

- * Constructor for ScalePotentialCheckStream. - *

- * - * @param name a {@link java.lang.String} object - * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - public ScalePotentialCheckStream(String name, SystemInterface thermoSystem) { - super(name, thermoSystem); + /** + *

+ * Constructor for ScalePotentialCheckStream. + *

+ * + * @param name a {@link java.lang.String} object + * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object + */ + public ScalePotentialCheckStream(String name, SystemInterface thermoSystem) { + super(name, thermoSystem); + } + + /** {@inheritDoc} */ + @Override + public ScalePotentialCheckStream clone() { + ScalePotentialCheckStream clonedSystem = null; + try { + clonedSystem = (ScalePotentialCheckStream) super.clone(); + } catch (Exception e) { + e.printStackTrace(System.err); } + return clonedSystem; + } - /** {@inheritDoc} */ - @Override - public ScalePotentialCheckStream clone() { - ScalePotentialCheckStream clonedSystem = null; - try { - clonedSystem = (ScalePotentialCheckStream) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); - } - return clonedSystem; + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + System.out.println("start flashing stream... " + streamNumber); + if (stream != null) { + thermoSystem = this.stream.getThermoSystem().clone(); + } + if (stream != null) { + reactiveThermoSystem = this.stream.getThermoSystem().setModel("Electrolyte-CPA-EOS-statoil"); } - /** {@inheritDoc} */ - @Override - public void run() { - System.out.println("start flashing stream... " + streamNumber); - if (stream != null) { - thermoSystem = this.stream.getThermoSystem().clone(); - } - if (stream != null) { - reactiveThermoSystem = - this.stream.getThermoSystem().setModel("Electrolyte-CPA-EOS-statoil"); - } + ThermodynamicOperations thermoOps = new ThermodynamicOperations(reactiveThermoSystem); + thermoOps.TPflash(); + reactiveThermoSystem.init(3); - ThermodynamicOperations thermoOps = new ThermodynamicOperations(reactiveThermoSystem); - thermoOps.TPflash(); - reactiveThermoSystem.init(3); + System.out.println("number of phases: " + reactiveThermoSystem.getNumberOfPhases()); + System.out.println("beta: " + reactiveThermoSystem.getBeta()); + setCalculationIdentifier(id); + } - System.out.println("number of phases: " + reactiveThermoSystem.getNumberOfPhases()); - System.out.println("beta: " + reactiveThermoSystem.getBeta()); - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - reactiveThermoSystem.display(name); - } + /** {@inheritDoc} */ + @Override + public void displayResult() { + reactiveThermoSystem.display(name); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java b/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java index d6a1602a29..3ff8f484d1 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java @@ -5,6 +5,7 @@ */ package neqsim.processSimulation.processEquipment.stream; +import java.util.UUID; import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; import neqsim.standards.gasQuality.Standard_ISO6976; import neqsim.thermo.system.SystemInterface; @@ -19,541 +20,543 @@ * @version $Id: $Id */ public class Stream extends ProcessEquipmentBaseClass implements StreamInterface, Cloneable { - private static final long serialVersionUID = 1000; - - protected SystemInterface thermoSystem; - - protected int streamNumber = 0; - /** Constant numberOfStreams=0 */ - protected static int numberOfStreams = 0; - private double gasQuality = 0.5; - protected StreamInterface stream = null; - - /** - *

- * Constructor for Stream. - *

- */ - @Deprecated - public Stream() { - super("Stream"); - } - - /** - *

- * Constructor for Stream. - *

- * - * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public Stream(StreamInterface stream) { - this("Stream", stream); - } - - /** - *

- * Constructor for Stream. - *

- * - * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - @Deprecated - public Stream(SystemInterface thermoSystem) { - this("Stream", thermoSystem); - } - - /** - * Constructor for Stream. - * - * @param name name of stream - */ - public Stream(String name) { - super(name); - } - - /** - * Constructor for Stream. - * - * @param name name of stream - * @param stream input stream - */ - public Stream(String name, StreamInterface stream) { - super(name); - this.setStream(stream); - thermoSystem = stream.getThermoSystem(); - numberOfStreams++; - streamNumber = numberOfStreams; - } - - /** - *

- * Constructor for Stream. - *

- * - * @param name a {@link java.lang.String} object - * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - public Stream(String name, SystemInterface thermoSystem) { - super(name); - this.thermoSystem = thermoSystem; - numberOfStreams++; - streamNumber = numberOfStreams; - } - - /** - *

- * Getter for the field gasQuality. - *

- * - * @return the gasQuality - */ - public double getGasQuality() { - return gasQuality; - } - - /** - *

- * Setter for the field gasQuality. - *

- * - * @param gasQuality the gasQuality to set - */ - public void setGasQuality(double gasQuality) { - this.gasQuality = gasQuality; - } - - /** {@inheritDoc} */ - @Override - public double getHydrateEquilibriumTemperature() { - if (!thermoSystem.getPhase(0).hasComponent("water")) { - System.out.println("ny hydrate: no water in stream: " + name); - return 0.0; - } - try { - SystemInterface copySystem = thermoSystem.clone(); - copySystem.setHydrateCheck(true); - ThermodynamicOperations thermoOps = new ThermodynamicOperations(copySystem); - thermoOps.hydrateFormationTemperature(); - return copySystem.getTemperature(); - } catch (Exception e) { - e.printStackTrace(); - } - return 0.0; - } - - /** - *

- * getSolidFormationTemperature. - *

- * - * @param solidName a {@link java.lang.String} object - * @return a double - */ - public double getSolidFormationTemperature(String solidName) { - SystemInterface copySystem = thermoSystem.clone(); - - try { - if (solidName.equals("hydrate")) { - copySystem.setHydrateCheck(true); - ThermodynamicOperations thermoOps = new ThermodynamicOperations(copySystem); - thermoOps.hydrateFormationTemperature(); - } else { - copySystem.setSolidPhaseCheck(false); - copySystem.setSolidPhaseCheck(solidName); - ThermodynamicOperations thermoOps = new ThermodynamicOperations(copySystem); - thermoOps.freezingPointTemperatureFlash(); - } - return copySystem.getTemperature(); - } catch (Exception e) { - e.printStackTrace(); - } - return 0.0; - } - - /** {@inheritDoc} */ - @Override - public Stream clone() { - Stream clonedSystem = null; - try { - clonedSystem = (Stream) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); - } - if (stream != null) - clonedSystem.setStream((Stream) stream.clone());; - clonedSystem.thermoSystem = getThermoSystem().clone(); - return clonedSystem; - } - - /** {@inheritDoc} */ - @Override - public double getTemperature() { - return thermoSystem.getTemperature(); - } - - /** {@inheritDoc} */ - @Override - public double getPressure() { - return thermoSystem.getPressure(); - } - - /** {@inheritDoc} */ - @Override - public double getMolarRate() { - return thermoSystem.getTotalNumberOfMoles(); - } - - /** {@inheritDoc} */ - @Override - public void setThermoSystem(SystemInterface thermoSystem) { - this.thermoSystem = thermoSystem; - if (stream != null) { - stream.setThermoSystem(thermoSystem); - } - } - - /** {@inheritDoc} */ - @Override - public void setFluid(SystemInterface fluid) { - this.setThermoSystem(fluid); - } - - /** {@inheritDoc} */ - @Override - public void setThermoSystemFromPhase(SystemInterface thermoSystem, String phaseTypeName) { - if (phaseTypeName.equals("liquid")) { - if (thermoSystem.hasPhaseType("oil") && thermoSystem.hasPhaseType("aqueous")) { - this.thermoSystem = - thermoSystem.phaseToSystem(thermoSystem.getPhaseNumberOfPhase("oil"), - thermoSystem.getPhaseNumberOfPhase("aqueous")); - } else if (thermoSystem.hasPhaseType("oil")) { - this.thermoSystem = - thermoSystem.phaseToSystem(thermoSystem.getPhaseNumberOfPhase("oil")); - } else if (thermoSystem.hasPhaseType("aqueous")) { - this.thermoSystem = - thermoSystem.phaseToSystem(thermoSystem.getPhaseNumberOfPhase("aqueous")); - } else { - System.out.println("no phase of type " + phaseTypeName); - System.out.println("...returning empty system "); - setEmptyThermoSystem(thermoSystem); - } - return; - } - if (thermoSystem.hasPhaseType(phaseTypeName)) { - this.thermoSystem = thermoSystem.phaseToSystem(phaseTypeName); - } else { - System.out.println("no phase of type " + phaseTypeName); - System.out.println("...returning empty system "); - setEmptyThermoSystem(thermoSystem); - } - } - - /** {@inheritDoc} */ - @Override - public void setEmptyThermoSystem(SystemInterface thermoSystem) { - this.thermoSystem = thermoSystem.getEmptySystemClone(); - this.thermoSystem.setNumberOfPhases(0); - } - - /** {@inheritDoc} */ - @Override - public SystemInterface getThermoSystem() { - return this.thermoSystem; - } - - /** {@inheritDoc} */ - @Override - public void setFlowRate(double flowrate, String unit) { - this.getFluid().setTotalFlowRate(flowrate, unit); - } - - /** {@inheritDoc} */ - @Override - public void setPressure(double pressure, String unit) { - getFluid().setPressure(pressure, unit); - } - - /** {@inheritDoc} */ - @Override - public void setTemperature(double temperature, String unit) { - getFluid().setTemperature(temperature, unit); - } - - /** {@inheritDoc} */ - @Override - public double getFlowRate(String unit) { - return this.getFluid().getFlowRate(unit); - } - - /** {@inheritDoc} */ - @Override - public double getPressure(String unit) { - return getFluid().getPressure(unit); - } - - /** {@inheritDoc} */ - @Override - public double getTemperature(String unit) { - return getFluid().getTemperature(unit); - } - - /** {@inheritDoc} */ - @Override - public void runTPflash() { - if (stream != null) { - thermoSystem = this.stream.getThermoSystem().clone(); - } - - ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem); + private static final long serialVersionUID = 1000; + + protected SystemInterface thermoSystem; + + protected int streamNumber = 0; + /** Constant numberOfStreams=0 */ + protected static int numberOfStreams = 0; + private double gasQuality = 0.5; + protected StreamInterface stream = null; + + /** + *

+ * Constructor for Stream. + *

+ */ + @Deprecated + public Stream() { + super("Stream"); + } + + /** + *

+ * Constructor for Stream. + *

+ * + * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + @Deprecated + public Stream(StreamInterface stream) { + this("Stream", stream); + } + + /** + *

+ * Constructor for Stream. + *

+ * + * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object + */ + @Deprecated + public Stream(SystemInterface thermoSystem) { + this("Stream", thermoSystem); + } + + /** + * Constructor for Stream. + * + * @param name name of stream + */ + public Stream(String name) { + super(name); + } + + /** + * Constructor for Stream. + * + * @param name name of stream + * @param stream input stream + */ + public Stream(String name, StreamInterface stream) { + super(name); + this.setStream(stream); + thermoSystem = stream.getThermoSystem(); + numberOfStreams++; + streamNumber = numberOfStreams; + } + + /** + *

+ * Constructor for Stream. + *

+ * + * @param name a {@link java.lang.String} object + * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object + */ + public Stream(String name, SystemInterface thermoSystem) { + super(name); + this.thermoSystem = thermoSystem; + numberOfStreams++; + streamNumber = numberOfStreams; + } + + /** + *

+ * Getter for the field gasQuality. + *

+ * + * @return the gasQuality + */ + public double getGasQuality() { + return gasQuality; + } + + /** + *

+ * Setter for the field gasQuality. + *

+ * + * @param gasQuality the gasQuality to set + */ + public void setGasQuality(double gasQuality) { + this.gasQuality = gasQuality; + } + + /** {@inheritDoc} */ + @Override + public double getHydrateEquilibriumTemperature() { + if (!thermoSystem.getPhase(0).hasComponent("water")) { + System.out.println("ny hydrate: no water in stream: " + name); + return 0.0; + } + try { + SystemInterface copySystem = thermoSystem.clone(); + copySystem.setHydrateCheck(true); + ThermodynamicOperations thermoOps = new ThermodynamicOperations(copySystem); + thermoOps.hydrateFormationTemperature(); + return copySystem.getTemperature(); + } catch (Exception e) { + e.printStackTrace(); + } + return 0.0; + } + + /** + *

+ * getSolidFormationTemperature. + *

+ * + * @param solidName a {@link java.lang.String} object + * @return a double + */ + public double getSolidFormationTemperature(String solidName) { + SystemInterface copySystem = thermoSystem.clone(); + + try { + if (solidName.equals("hydrate")) { + copySystem.setHydrateCheck(true); + ThermodynamicOperations thermoOps = new ThermodynamicOperations(copySystem); + thermoOps.hydrateFormationTemperature(); + } else { + copySystem.setSolidPhaseCheck(false); + copySystem.setSolidPhaseCheck(solidName); + ThermodynamicOperations thermoOps = new ThermodynamicOperations(copySystem); + thermoOps.freezingPointTemperatureFlash(); + } + return copySystem.getTemperature(); + } catch (Exception e) { + e.printStackTrace(); + } + return 0.0; + } + + /** {@inheritDoc} */ + @Override + public Stream clone() { + Stream clonedSystem = null; + try { + clonedSystem = (Stream) super.clone(); + } catch (Exception e) { + e.printStackTrace(System.err); + } + if (stream != null) { + clonedSystem.setStream((Stream) stream.clone()); + } + clonedSystem.thermoSystem = getThermoSystem().clone(); + return clonedSystem; + } + + /** {@inheritDoc} */ + @Override + public double getTemperature() { + return thermoSystem.getTemperature(); + } + + /** {@inheritDoc} */ + @Override + public double getTemperature(String unit) { + return getFluid().getTemperature(unit); + } + + /** {@inheritDoc} */ + @Override + public double getPressure() { + return thermoSystem.getPressure(); + } + + /** {@inheritDoc} */ + @Override + public double getPressure(String unit) { + return getFluid().getPressure(unit); + } + + /** {@inheritDoc} */ + @Override + public double getMolarRate() { + return thermoSystem.getTotalNumberOfMoles(); + } + + /** {@inheritDoc} */ + @Override + public void setThermoSystem(SystemInterface thermoSystem) { + this.thermoSystem = thermoSystem; + // todo: when is stream not null? + if (stream != null) { + stream.setThermoSystem(thermoSystem); + } + } + + /** {@inheritDoc} */ + @Override + public void setFluid(SystemInterface fluid) { + this.setThermoSystem(fluid); + } + + /** {@inheritDoc} */ + @Override + public void setThermoSystemFromPhase(SystemInterface thermoSystem, String phaseTypeName) { + if (phaseTypeName.equals("liquid")) { + if (thermoSystem.hasPhaseType("oil") && thermoSystem.hasPhaseType("aqueous")) { + this.thermoSystem = thermoSystem.phaseToSystem(thermoSystem.getPhaseNumberOfPhase("oil"), + thermoSystem.getPhaseNumberOfPhase("aqueous")); + } else if (thermoSystem.hasPhaseType("oil")) { + this.thermoSystem = thermoSystem.phaseToSystem(thermoSystem.getPhaseNumberOfPhase("oil")); + } else if (thermoSystem.hasPhaseType("aqueous")) { + this.thermoSystem = + thermoSystem.phaseToSystem(thermoSystem.getPhaseNumberOfPhase("aqueous")); + } else { + System.out.println("no phase of type " + phaseTypeName); + System.out.println("...returning empty system "); + setEmptyThermoSystem(thermoSystem); + } + return; + } + if (thermoSystem.hasPhaseType(phaseTypeName)) { + this.thermoSystem = thermoSystem.phaseToSystem(phaseTypeName); + } else { + System.out.println("no phase of type " + phaseTypeName); + System.out.println("...returning empty system "); + setEmptyThermoSystem(thermoSystem); + } + } + + /** {@inheritDoc} */ + @Override + public void setEmptyThermoSystem(SystemInterface thermoSystem) { + this.thermoSystem = thermoSystem.getEmptySystemClone(); + this.thermoSystem.setNumberOfPhases(0); + } + + /** {@inheritDoc} */ + @Override + public SystemInterface getThermoSystem() { + return this.thermoSystem; + } + + /** {@inheritDoc} */ + @Override + public void setFlowRate(double flowrate, String unit) { + this.getFluid().setTotalFlowRate(flowrate, unit); + } + + /** {@inheritDoc} */ + @Override + public void setPressure(double pressure, String unit) { + getFluid().setPressure(pressure, unit); + } + + /** {@inheritDoc} */ + @Override + public void setTemperature(double temperature, String unit) { + getFluid().setTemperature(temperature, unit); + } + + /** {@inheritDoc} */ + @Override + public double getFlowRate(String unit) { + return this.getFluid().getFlowRate(unit); + } + + /** {@inheritDoc} */ + @Override + public void runTPflash() { + if (stream != null) { + thermoSystem = this.stream.getThermoSystem().clone(); + } + + ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem); + thermoOps.TPflash(); + thermoSystem.initProperties(); + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + // System.out.println("start flashing stream... " + streamNumber); + if (stream != null) { + thermoSystem = this.stream.getThermoSystem().clone(); + } + ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem); + + if (stream != null && getThermoSystem().getNumberOfComponents() == 1 + && getSpecification().equals("TP")) { + setSpecification("PH"); + } + if (getSpecification().equals("TP")) { + thermoOps.TPflash(); + } else if (getSpecification().equals("dewP")) { + try { + thermoOps.dewPointTemperatureFlash(); + } catch (Exception e) { + e.printStackTrace(); thermoOps.TPflash(); - thermoSystem.initProperties(); - } - - /** {@inheritDoc} */ - @Override - public void run() { - // System.out.println("start flashing stream... " + streamNumber); - if (stream != null) { - thermoSystem = this.stream.getThermoSystem().clone(); - } - ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem); - - if (stream != null && getThermoSystem().getNumberOfComponents() == 1 - && getSpecification().equals("TP")) { - setSpecification("PH"); - } - if (getSpecification().equals("TP")) { - thermoOps.TPflash(); - } else if (getSpecification().equals("dewP")) { - try { - thermoOps.dewPointTemperatureFlash(); - } catch (Exception e) { - e.printStackTrace(); - thermoOps.TPflash(); - } - } else if (getSpecification().equals("dewT")) { - try { - thermoOps.dewPointPressureFlash(); - } catch (Exception e) { - e.printStackTrace(); - thermoOps.TPflash(); - } - } else if (getSpecification().equals("gas quality")) { - try { - thermoSystem.init(0); - thermoSystem.init(2); - double gasEnthalpy = thermoSystem.getPhase(0).getEnthalpy(); - double liquidEnthalpy = thermoSystem.getPhase(1).getEnthalpy(); - - double enthalpySpec = - getGasQuality() * gasEnthalpy + (1.0 - getGasQuality()) * liquidEnthalpy; - thermoOps.PHflash(enthalpySpec); - } catch (Exception e) { - e.printStackTrace(); - thermoOps.TPflash(); - } - } else if (getSpecification().equals("bubP")) { - try { - thermoOps.bubblePointTemperatureFlash(); - } catch (Exception e) { - e.printStackTrace(); - thermoOps.TPflash(); - } - } else if (getSpecification().equals("bubT")) { - try { - thermoOps.bubblePointPressureFlash(false); - } catch (Exception e) { - e.printStackTrace(); - thermoOps.TPflash(); - } - } else if (getSpecification().equals("PH")) { - try { - thermoOps.PHflash(getThermoSystem().getEnthalpy(), 0); - } catch (Exception e) { - e.printStackTrace(); - thermoOps.TPflash(); - } - } else { - thermoOps.TPflash(); - } - - thermoSystem.initProperties(); - // System.out.println("number of phases: " + thermoSystem.getNumberOfPhases()); - // System.out.println("beta: " + thermoSystem.getBeta()); - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - thermoSystem.display(name); - } - - /** - *

- * getResultTable. - *

- * - * @return an array of {@link java.lang.String} objects - */ - public String[][] getResultTable() { - return thermoSystem.getResultTable(); - } - - /** {@inheritDoc} */ - @Override - public void runTransient(double dt) { - if (hasController) { - // This adjusts the flow rate through this stream. - // Typically used to match/manipulate mass balance. - runController(dt); - this.setFlowRate(getController().getResponse(), "kg/hr"); } - - run(); - } - - /** - *

- * runController. - *

- * - * @param dt a double - */ - public void runController(double dt) { - if (hasController) { - getController().runTransient(this.getFlowRate("kg/hr"), dt); - } - } - - /** {@inheritDoc} */ - @Override - public void flashStream() { - ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem); - ops.TPflash(); - } - - /** - *

- * phaseEnvelope. - *

- */ - public void phaseEnvelope() { - SystemInterface localSyst = thermoSystem.clone(); - ThermodynamicOperations ops = new ThermodynamicOperations(localSyst); - ops.setRunAsThread(true); - ops.calcPTphaseEnvelope(true); - ops.waitAndCheckForFinishedCalculation(10000); - ops.displayResult(); - // ops.getJfreeChart(); - } - - /** {@inheritDoc} */ - @Override - public double CCB(String unit) { - SystemInterface localSyst = thermoSystem.clone(); - ThermodynamicOperations ops = new ThermodynamicOperations(localSyst); - ops.setRunAsThread(true); - ops.calcPTphaseEnvelope(true); - ops.waitAndCheckForFinishedCalculation(10000); - if (unit.equals("bara") || unit.equals("bar")) { - return ops.get("cricondenbar")[1]; - } else { - if (unit.equals("C")) - return ops.get("cricondenbar")[0] - 273.15; - else - return ops.get("cricondenbar")[0]; - } - // return ops.get - // ops.getJfreeChart(); - } - - /** {@inheritDoc} */ - @Override - public double CCT(String unit) { - SystemInterface localSyst = thermoSystem.clone(); - ThermodynamicOperations ops = new ThermodynamicOperations(localSyst); - ops.setRunAsThread(true); - ops.calcPTphaseEnvelope(true); - ops.waitAndCheckForFinishedCalculation(10000); - if (unit.equals("bara") || unit.equals("bar")) { - return ops.get("cricondentherm")[1]; - } else { - if (unit.equals("C")) - return ops.get("cricondentherm")[0] - 273.15; - else - return ops.get("cricondentherm")[0]; - } - // return ops.get - // ops.getJfreeChart(); - } - - /** {@inheritDoc} */ - @Override - public double TVP(double temperature, String unit) { - SystemInterface localSyst = thermoSystem.clone(); - localSyst.setTemperature(temperature, unit); - ThermodynamicOperations ops = new ThermodynamicOperations(localSyst); - try { - ops.bubblePointPressureFlash(false); - } catch (Exception e) { - } - return localSyst.getPressure(unit); - } - - /** {@inheritDoc} */ - @Override - public String[][] reportResults() { - return thermoSystem.getResultTable(); - } - - /** - *

- * getProperty. - *

- * - * @param propertyName a {@link java.lang.String} object - * @param unit a {@link java.lang.String} object - * @param phase a {@link java.lang.String} object - * @param component a {@link java.lang.String} object - * @return a {@link java.lang.Object} object - */ - public Object getProperty(String propertyName, String unit, String phase, String component) { - // getFluid().getProperties.containsKey(propertyName)) { - // if(properties.containsKey(propertyName)) { - // } - // else - return null; - } - - /** {@inheritDoc} */ - @Override - public double GCV() { - Standard_ISO6976 standard = new Standard_ISO6976(thermoSystem.clone(), 0, 15.55, "volume"); - standard.setReferenceState("real"); - standard.calculate(); - return standard.getValue("GCV") * 1.0e3; - } - - /** {@inheritDoc} */ - @Override - public double LCV() { - Standard_ISO6976 standard = new Standard_ISO6976(thermoSystem.clone(), 0, 15.55, "volume"); - standard.setReferenceState("real"); - standard.calculate(); - return standard.getValue("InferiorCalorificValue") * 1.0e3; + } else if (getSpecification().equals("dewT")) { + try { + thermoOps.dewPointPressureFlash(); + } catch (Exception e) { + e.printStackTrace(); + thermoOps.TPflash(); + } + } else if (getSpecification().equals("gas quality")) { + try { + thermoSystem.init(0); + thermoSystem.init(2); + double gasEnthalpy = thermoSystem.getPhase(0).getEnthalpy(); + double liquidEnthalpy = thermoSystem.getPhase(1).getEnthalpy(); + + double enthalpySpec = + getGasQuality() * gasEnthalpy + (1.0 - getGasQuality()) * liquidEnthalpy; + thermoOps.PHflash(enthalpySpec); + } catch (Exception e) { + e.printStackTrace(); + thermoOps.TPflash(); + } + } else if (getSpecification().equals("bubP")) { + try { + thermoOps.bubblePointTemperatureFlash(); + } catch (Exception e) { + e.printStackTrace(); + thermoOps.TPflash(); + } + } else if (getSpecification().equals("bubT")) { + try { + thermoOps.bubblePointPressureFlash(false); + } catch (Exception e) { + e.printStackTrace(); + thermoOps.TPflash(); + } + } else if (getSpecification().equals("PH")) { + try { + thermoOps.PHflash(getThermoSystem().getEnthalpy(), 0); + } catch (Exception e) { + e.printStackTrace(); + thermoOps.TPflash(); + } + } else { + thermoOps.TPflash(); + } + + thermoSystem.initProperties(); + // System.out.println("number of phases: " + thermoSystem.getNumberOfPhases()); + // System.out.println("beta: " + thermoSystem.getBeta()); + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + thermoSystem.display(name); + } + + /** + *

+ * getResultTable. + *

+ * + * @return an array of {@link java.lang.String} objects + */ + public String[][] getResultTable() { + return thermoSystem.getResultTable(); + } + + /** {@inheritDoc} */ + @Override + public void runTransient(double dt, UUID id) { + if (hasController) { + // This adjusts the flow rate through this stream. + // Typically used to match/manipulate mass balance. + runController(dt, id); + this.setFlowRate(getController().getResponse(), "kg/hr"); + } + + run(id); + increaseTime(dt); + } + + /** + *

+ * runController. + *

+ * + * @param dt a double + */ + public void runController(double dt, UUID id) { + if (hasController) { + getController().runTransient(this.getFlowRate("kg/hr"), dt, id); + } + } + + /** {@inheritDoc} */ + @Override + public void flashStream() { + ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem); + ops.TPflash(); + } + + /** + *

+ * phaseEnvelope. + *

+ */ + public void phaseEnvelope() { + SystemInterface localSyst = thermoSystem.clone(); + ThermodynamicOperations ops = new ThermodynamicOperations(localSyst); + ops.setRunAsThread(true); + ops.calcPTphaseEnvelope(true); + ops.waitAndCheckForFinishedCalculation(10000); + ops.displayResult(); + // ops.getJfreeChart(); + } + + /** {@inheritDoc} */ + @Override + public double CCB(String unit) { + SystemInterface localSyst = thermoSystem.clone(); + ThermodynamicOperations ops = new ThermodynamicOperations(localSyst); + ops.setRunAsThread(true); + ops.calcPTphaseEnvelope(true); + ops.waitAndCheckForFinishedCalculation(10000); + if (unit.equals("bara") || unit.equals("bar")) { + return ops.get("cricondenbar")[1]; + } else { + if (unit.equals("C")) { + return ops.get("cricondenbar")[0] - 273.15; + } else { + return ops.get("cricondenbar")[0]; + } } - - /** - *

- * Setter for the field stream. - *

- * - * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - public void setStream(StreamInterface stream) { - this.stream = stream; + // return ops.get + // ops.getJfreeChart(); + } + + /** {@inheritDoc} */ + @Override + public double CCT(String unit) { + SystemInterface localSyst = thermoSystem.clone(); + ThermodynamicOperations ops = new ThermodynamicOperations(localSyst); + ops.setRunAsThread(true); + ops.calcPTphaseEnvelope(true); + ops.waitAndCheckForFinishedCalculation(10000); + if (unit.equals("bara") || unit.equals("bar")) { + return ops.get("cricondentherm")[1]; + } else { + if (unit.equals("C")) { + return ops.get("cricondentherm")[0] - 273.15; + } else { + return ops.get("cricondentherm")[0]; + } } + // return ops.get + // ops.getJfreeChart(); + } + + /** {@inheritDoc} */ + @Override + public double TVP(double temperature, String unit) { + SystemInterface localSyst = thermoSystem.clone(); + localSyst.setTemperature(temperature, unit); + ThermodynamicOperations ops = new ThermodynamicOperations(localSyst); + try { + ops.bubblePointPressureFlash(false); + } catch (Exception e) { + } + return localSyst.getPressure(unit); + } + + /** {@inheritDoc} */ + @Override + public String[][] reportResults() { + return thermoSystem.getResultTable(); + } + + /** + *

+ * getProperty. + *

+ * + * @param propertyName a {@link java.lang.String} object + * @param unit a {@link java.lang.String} object + * @param phase a {@link java.lang.String} object + * @param component a {@link java.lang.String} object + * @return a {@link java.lang.Object} object + */ + public Object getProperty(String propertyName, String unit, String phase, String component) { + // getFluid().getProperties.containsKey(propertyName)) { + // if(properties.containsKey(propertyName)) { + // } + // else + return null; + } + + /** {@inheritDoc} */ + @Override + public double GCV() { + Standard_ISO6976 standard = new Standard_ISO6976(thermoSystem.clone(), 0, 15.55, "volume"); + standard.setReferenceState("real"); + standard.calculate(); + return standard.getValue("GCV") * 1.0e3; + } + + /** {@inheritDoc} */ + @Override + public double LCV() { + Standard_ISO6976 standard = new Standard_ISO6976(thermoSystem.clone(), 0, 15.55, "volume"); + standard.setReferenceState("real"); + standard.calculate(); + return standard.getValue("InferiorCalorificValue") * 1.0e3; + } + + /** + *

+ * Setter for the field stream. + *

+ * + * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + public void setStream(StreamInterface stream) { + this.stream = stream; + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/stream/StreamInterface.java b/src/main/java/neqsim/processSimulation/processEquipment/stream/StreamInterface.java index 3d7ee55cab..0d7137bc3e 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/stream/StreamInterface.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/stream/StreamInterface.java @@ -50,6 +50,10 @@ public interface StreamInterface extends ProcessEquipmentInterface { */ public double getPressure(String unit); + /** {@inheritDoc} */ + @Override + public double getPressure(); + /** *

* runTPflash. @@ -67,28 +71,28 @@ public interface StreamInterface extends ProcessEquipmentInterface { */ public double getTemperature(String unit); - /** {@inheritDoc} */ - @Override - public void setName(String name); - /** *

- * CCT. + * getTemperature. *

* - * @param unit a {@link java.lang.String} object * @return a double */ - public double CCT(String unit); + public double getTemperature(); + + /** {@inheritDoc} */ + @Override + public void setName(String name); /** *

- * getTemperature. + * CCT. *

* + * @param unit a {@link java.lang.String} object * @return a double */ - public double getTemperature(); + public double CCT(String unit); /** *

@@ -139,10 +143,6 @@ public interface StreamInterface extends ProcessEquipmentInterface { */ public double getMolarRate(); - /** {@inheritDoc} */ - @Override - public double getPressure(); - /** *

* clone. diff --git a/src/main/java/neqsim/processSimulation/processEquipment/subsea/SimpleFlowLine.java b/src/main/java/neqsim/processSimulation/processEquipment/subsea/SimpleFlowLine.java index b6432f764e..2de19abcd8 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/subsea/SimpleFlowLine.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/subsea/SimpleFlowLine.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.subsea; +import java.util.UUID; import neqsim.processSimulation.processEquipment.TwoPortEquipment; import neqsim.processSimulation.processEquipment.pipeline.AdiabaticTwoPhasePipe; import neqsim.processSimulation.processEquipment.stream.StreamInterface; @@ -14,105 +15,106 @@ * @version $Id: $Id */ public class SimpleFlowLine extends TwoPortEquipment { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - private double height = 100.0; - public double length = 520.0; - double outletTemperature = 313.15; - AdiabaticTwoPhasePipe pipeline; + private double height = 100.0; + public double length = 520.0; + double outletTemperature = 313.15; + AdiabaticTwoPhasePipe pipeline; - /** - *

- * Constructor for SimpleFlowLine. - *

- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public SimpleFlowLine(StreamInterface inStream) { - this("SimpleFlowLine", inStream); + /** + *

+ * Constructor for SimpleFlowLine. + *

+ * + * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + @Deprecated + public SimpleFlowLine(StreamInterface inStream) { + this("SimpleFlowLine", inStream); - } + } - /** - * Constructor for SimpleFlowLine. - * - * @param name Name of SimpleFlowLine object - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - public SimpleFlowLine(String name, StreamInterface inStream) { - super(name); - this.inStream = inStream; - setOutletStream(inStream.clone()); - pipeline = new AdiabaticTwoPhasePipe("pipeline", inStream); - } + /** + * Constructor for SimpleFlowLine. + * + * @param name Name of SimpleFlowLine object + * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public SimpleFlowLine(String name, StreamInterface inStream) { + super(name); + this.inStream = inStream; + setOutletStream(inStream.clone()); + pipeline = new AdiabaticTwoPhasePipe("pipeline", inStream); + } - /** - *

- * Getter for the field pipeline. - *

- * - * @return a {@link neqsim.processSimulation.processEquipment.pipeline.AdiabaticTwoPhasePipe} - * object - */ - public AdiabaticTwoPhasePipe getPipeline() { - return pipeline; - } + /** + *

+ * Getter for the field pipeline. + *

+ * + * @return a {@link neqsim.processSimulation.processEquipment.pipeline.AdiabaticTwoPhasePipe} + * object + */ + public AdiabaticTwoPhasePipe getPipeline() { + return pipeline; + } - /** {@inheritDoc} */ - @Override - public SystemInterface getThermoSystem() { - return getOutletStream().getThermoSystem(); - } + /** {@inheritDoc} */ + @Override + public SystemInterface getThermoSystem() { + return getOutletStream().getThermoSystem(); + } - /** {@inheritDoc} */ - @Override - public void run() { - pipeline.run(); - getOutletStream().setFluid(pipeline.getOutletStream().getFluid()); + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + pipeline.run(id); + getOutletStream().setFluid(pipeline.getOutletStream().getFluid()); - /* - * System.out.println("stary P " ); - * - * SystemInterface fluidIn = (inStream.getFluid()).clone(); fluidIn.initProperties(); - * - * double density = fluidIn.getDensity("kg/m3"); - * - * double deltaP = - * density*getHeight()*neqsim.thermo.ThermodynamicConstantsInterface.gravity/1. 0e5; - * - * System.out.println("density " +density + " delta P " + deltaP); - * - * fluidIn.setPressure(fluidIn.getPressure("bara")-deltaP); - * fluidIn.setTemperature(outletTemperature); - * - * ThermodynamicOperations ops = new ThermodynamicOperations(fluidIn); ops.TPflash(); - * - * getOutletStream().setFluid(fluidIn); - */ - } - - /** - *

- * Getter for the field height. - *

- * - * @return a double + /* + * System.out.println("stary P " ); + * + * SystemInterface fluidIn = (inStream.getFluid()).clone(); fluidIn.initProperties(); + * + * double density = fluidIn.getDensity("kg/m3"); + * + * double deltaP = density*getHeight()*neqsim.thermo.ThermodynamicConstantsInterface.gravity/1. + * 0e5; + * + * System.out.println("density " +density + " delta P " + deltaP); + * + * fluidIn.setPressure(fluidIn.getPressure("bara")-deltaP); + * fluidIn.setTemperature(outletTemperature); + * + * ThermodynamicOperations ops = new ThermodynamicOperations(fluidIn); ops.TPflash(); + * + * getOutletStream().setFluid(fluidIn); */ - public double getHeight() { - return height; - } + setCalculationIdentifier(id); + } - /** - *

- * Setter for the field height. - *

- * - * @param height a double - */ - public void setHeight(double height) { - this.height = height; - } + /** + *

+ * Getter for the field height. + *

+ * + * @return a double + */ + public double getHeight() { + return height; + } + + /** + *

+ * Setter for the field height. + *

+ * + * @param height a double + */ + public void setHeight(double height) { + this.height = height; + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/subsea/SubseaWell.java b/src/main/java/neqsim/processSimulation/processEquipment/subsea/SubseaWell.java index 13273b308a..46d5581746 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/subsea/SubseaWell.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/subsea/SubseaWell.java @@ -1,6 +1,7 @@ package neqsim.processSimulation.processEquipment.subsea; import java.util.ArrayList; +import java.util.UUID; import neqsim.processSimulation.processEquipment.TwoPortEquipment; import neqsim.processSimulation.processEquipment.pipeline.AdiabaticTwoPhasePipe; import neqsim.processSimulation.processEquipment.reservoir.SimpleReservoir; @@ -18,160 +19,158 @@ * @version $Id: $Id */ public class SubseaWell extends TwoPortEquipment { - private static final long serialVersionUID = 1000; - - public double height = 1000.0, length = 1200.0; - AdiabaticTwoPhasePipe pipeline; - - /** - *

- * Constructor for SubseaWell. - *

- * - * @param instream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object + private static final long serialVersionUID = 1000; + + public double height = 1000.0, length = 1200.0; + AdiabaticTwoPhasePipe pipeline; + + /** + *

+ * Constructor for SubseaWell. + *

+ * + * @param instream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + @Deprecated + public SubseaWell(StreamInterface instream) { + super("SubseaWell"); + this.inStream = instream; + setOutletStream(instream.clone()); + pipeline = new AdiabaticTwoPhasePipe("pipeline", instream); + } + + /** + *

+ * Getter for the field pipeline. + *

+ * + * @return a {@link neqsim.processSimulation.processEquipment.pipeline.AdiabaticTwoPhasePipe} + * object + */ + public AdiabaticTwoPhasePipe getPipeline() { + return pipeline; + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + pipeline.run(id); + getOutletStream().setFluid(pipeline.getOutletStream().getFluid()); + + /* + * System.out.println("stary P " ); SystemInterface fluidIn = (inStream.getFluid()).clone(); + * fluidIn.initProperties(); + * + * double density = fluidIn.getDensity("kg/m3"); + * + * double deltaP = density*height*neqsim.thermo.ThermodynamicConstantsInterface.gravity/1.0e5; + * + * System.out.println("density " +density + " delta P " + deltaP); + * + * fluidIn.setPressure(fluidIn.getPressure("bara")-deltaP); + * + * ThermodynamicOperations ops = new ThermodynamicOperations(fluidIn); ops.TPflash(); + * + * getOutStream().setFluid(fluidIn); */ - @Deprecated - public SubseaWell(StreamInterface instream) { - super("SubseaWell"); - this.inStream = instream; - setOutletStream(instream.clone()); - pipeline = new AdiabaticTwoPhasePipe("pipeline", instream); + setCalculationIdentifier(id); + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos((273.15 + 100.0), 250.00); + testSystem.addComponent("nitrogen", 0.100); + testSystem.addComponent("methane", 70.00); + testSystem.addComponent("ethane", 1.0); + testSystem.addComponent("propane", 1.0); + testSystem.addComponent("i-butane", 1.0); + testSystem.addComponent("n-butane", 1.0); + testSystem.addComponent("n-hexane", 0.1); + testSystem.addComponent("n-heptane", 0.1); + testSystem.addComponent("n-nonane", 1.0); + testSystem.addComponent("nC10", 1.0); + testSystem.addComponent("nC12", 3.0); + testSystem.addComponent("nC15", 13.0); + testSystem.addComponent("nC20", 13.0); + testSystem.addComponent("water", 11.0); + testSystem.setMixingRule(2); + testSystem.setMultiPhaseCheck(true); + + SimpleReservoir reservoirOps = new SimpleReservoir("Well 1 reservoir"); + reservoirOps.setReservoirFluid(testSystem, 5.0 * 1e7, 552.0 * 1e6, 10.0e6); + StreamInterface producedOilStream = reservoirOps.addOilProducer("oilproducer_1"); + producedOilStream.setFlowRate(3500.0 * 24.0 * 600.0, "kg/day"); + + reservoirOps.run(); + + System.out.println("water volume" + + reservoirOps.getReservoirFluid().getPhase("aqueous").getVolume("m3") / 1.0e6); + System.out + .println("oil production total" + reservoirOps.getOilProductionTotal("Sm3") + " Sm3"); + System.out + .println("total produced " + reservoirOps.getProductionTotal("MSm3 oe") + " MSm3 oe"); + + SubseaWell well1 = new SubseaWell(reservoirOps.getOilProducer("oilproducer_1").getStream()); + well1.getPipeline().setDiameter(0.3); + well1.getPipeline().setLength(5500.0); + well1.getPipeline().setInletElevation(-1000.0); + well1.getPipeline().setOutletElevation(-100.0); + ThrottlingValve subseaChoke = new ThrottlingValve("subseaChoke", well1.getOutletStream()); + subseaChoke.setOutletPressure(90.0); + subseaChoke.setAcceptNegativeDP(false); + SimpleFlowLine flowLine = new SimpleFlowLine("flowLine", subseaChoke.getOutletStream()); + flowLine.getPipeline().setDiameter(0.4); + flowLine.getPipeline().setLength(2000.0); + flowLine.getPipeline().setInletElevation(-100.0); + // flowLine.set + ThrottlingValve topsideChoke = new ThrottlingValve("topsideChoke", flowLine.getOutletStream()); + topsideChoke.setOutletPressure(50.0, "bara"); + topsideChoke.setAcceptNegativeDP(false); + + Adjuster adjust = new Adjuster("adjust"); + adjust.setActivateWhenLess(true); + adjust.setTargetVariable(flowLine.getOutletStream(), "pressure", 70.0, "bara"); + adjust.setAdjustedVariable(producedOilStream, "flow rate"); + + ProcessSystem ops = new ProcessSystem(); + ops.add(well1); + ops.add(subseaChoke); + ops.add(flowLine); + ops.add(topsideChoke); + ops.add(adjust); + + ArrayList res = new ArrayList(); + // for(int i=0;i<152;i++) { + // do { + reservoirOps.runTransient(60 * 60 * 24 * 1); + ops.run(); + res.add(new double[] {reservoirOps.getTime(), producedOilStream.getFluid().getFlowRate("kg/hr"), + reservoirOps.getOilProductionTotal("MSm3 oe")}); + System.out.println("subsea choke DP " + subseaChoke.getDeltaPressure("bara")); + System.out.println("topside choke DP " + topsideChoke.getDeltaPressure("bara")); + System.out.println("oil production " + producedOilStream.getFluid().getFlowRate("kg/hr")); + // } + // while(producedOilStream.getFluid().getFlowRate("kg/hr")>1.0e5); + + ProcessSystem GasOilProcess = ProcessSystem.open("c:/temp/offshorePro.neqsim"); + ((StreamInterface) GasOilProcess.getUnit("well stream")) + .setThermoSystem(topsideChoke.getOutletStream().getFluid()); + ((StreamInterface) GasOilProcess.getUnit("well stream")).setPressure(70.0, "bara"); + ((StreamInterface) GasOilProcess.getUnit("well stream")).setTemperature(65.0, "C"); + GasOilProcess.run(); + + System.out.println("power " + GasOilProcess.getPower("MW")); + for (int i = 0; i < res.size(); i++) { + System.out.println("time " + res.get(i)[0] + " oil production " + res.get(i)[1] + + " total production MSm3 oe " + res.get(i)[2]); } - - /** - *

- * Getter for the field pipeline. - *

- * - * @return a {@link neqsim.processSimulation.processEquipment.pipeline.AdiabaticTwoPhasePipe} - * object - */ - public AdiabaticTwoPhasePipe getPipeline() { - return pipeline; - } - - /** {@inheritDoc} */ - @Override - public void run() { - pipeline.run(); - getOutletStream().setFluid(pipeline.getOutletStream().getFluid()); - - /* - * System.out.println("stary P " ); SystemInterface fluidIn = (inStream.getFluid()).clone(); - * fluidIn.initProperties(); - * - * double density = fluidIn.getDensity("kg/m3"); - * - * double deltaP = - * density*height*neqsim.thermo.ThermodynamicConstantsInterface.gravity/1.0e5; - * - * System.out.println("density " +density + " delta P " + deltaP); - * - * fluidIn.setPressure(fluidIn.getPressure("bara")-deltaP); - * - * ThermodynamicOperations ops = new ThermodynamicOperations(fluidIn); ops.TPflash(); - * - * getOutStream().setFluid(fluidIn); - */ - } - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 100.0), 250.00); - testSystem.addComponent("nitrogen", 0.100); - testSystem.addComponent("methane", 70.00); - testSystem.addComponent("ethane", 1.0); - testSystem.addComponent("propane", 1.0); - testSystem.addComponent("i-butane", 1.0); - testSystem.addComponent("n-butane", 1.0); - testSystem.addComponent("n-hexane", 0.1); - testSystem.addComponent("n-heptane", 0.1); - testSystem.addComponent("n-nonane", 1.0); - testSystem.addComponent("nC10", 1.0); - testSystem.addComponent("nC12", 3.0); - testSystem.addComponent("nC15", 13.0); - testSystem.addComponent("nC20", 13.0); - testSystem.addComponent("water", 11.0); - testSystem.setMixingRule(2); - testSystem.setMultiPhaseCheck(true); - - SimpleReservoir reservoirOps = new SimpleReservoir("Well 1 reservoir"); - reservoirOps.setReservoirFluid(testSystem, 5.0 * 1e7, 552.0 * 1e6, 10.0e6); - StreamInterface producedOilStream = reservoirOps.addOilProducer("oilproducer_1"); - producedOilStream.setFlowRate(3500.0 * 24.0 * 600.0, "kg/day"); - - reservoirOps.run(); - - System.out.println("water volume" - + reservoirOps.getReservoirFluid().getPhase("aqueous").getVolume("m3") / 1.0e6); - System.out.println( - "oil production total" + reservoirOps.getOilProductionTotal("Sm3") + " Sm3"); - System.out.println( - "total produced " + reservoirOps.getProductionTotal("MSm3 oe") + " MSm3 oe"); - - SubseaWell well1 = new SubseaWell(reservoirOps.getOilProducer("oilproducer_1").getStream()); - well1.getPipeline().setDiameter(0.3); - well1.getPipeline().setLength(5500.0); - well1.getPipeline().setInletElevation(-1000.0); - well1.getPipeline().setOutletElevation(-100.0); - ThrottlingValve subseaChoke = new ThrottlingValve("subseaChoke", well1.getOutletStream()); - subseaChoke.setOutletPressure(90.0); - subseaChoke.setAcceptNegativeDP(false); - SimpleFlowLine flowLine = new SimpleFlowLine("flowLine", subseaChoke.getOutletStream()); - flowLine.getPipeline().setDiameter(0.4); - flowLine.getPipeline().setLength(2000.0); - flowLine.getPipeline().setInletElevation(-100.0); - // flowLine.set - ThrottlingValve topsideChoke = - new ThrottlingValve("topsideChoke", flowLine.getOutletStream()); - topsideChoke.setOutletPressure(50.0, "bara"); - topsideChoke.setAcceptNegativeDP(false); - - Adjuster adjust = new Adjuster("adjust"); - adjust.setActivateWhenLess(true); - adjust.setTargetVariable(flowLine.getOutletStream(), "pressure", 70.0, "bara"); - adjust.setAdjustedVariable(producedOilStream, "flow rate"); - - ProcessSystem ops = new ProcessSystem(); - ops.add(well1); - ops.add(subseaChoke); - ops.add(flowLine); - ops.add(topsideChoke); - ops.add(adjust); - - ArrayList res = new ArrayList(); - // for(int i=0;i<152;i++) { - // do { - reservoirOps.runTransient(60 * 60 * 24 * 1); - ops.run(); - res.add(new double[] {reservoirOps.getTime(), - producedOilStream.getFluid().getFlowRate("kg/hr"), - reservoirOps.getOilProductionTotal("MSm3 oe")}); - System.out.println("subsea choke DP " + subseaChoke.getDeltaPressure("bara")); - System.out.println("topside choke DP " + topsideChoke.getDeltaPressure("bara")); - System.out.println("oil production " + producedOilStream.getFluid().getFlowRate("kg/hr")); - // } - // while(producedOilStream.getFluid().getFlowRate("kg/hr")>1.0e5); - - ProcessSystem GasOilProcess = ProcessSystem.open("c:/temp/offshorePro.neqsim"); - ((StreamInterface) GasOilProcess.getUnit("well stream")) - .setThermoSystem(topsideChoke.getOutletStream().getFluid()); - ((StreamInterface) GasOilProcess.getUnit("well stream")).setPressure(70.0, "bara"); - ((StreamInterface) GasOilProcess.getUnit("well stream")).setTemperature(65.0, "C"); - GasOilProcess.run(); - - System.out.println("power " + GasOilProcess.getPower("MW")); - for (int i = 0; i < res.size(); i++) { - System.out.println("time " + res.get(i)[0] + " oil production " + res.get(i)[1] - + " total production MSm3 oe " + res.get(i)[2]); - } - } + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/tank/Tank.java b/src/main/java/neqsim/processSimulation/processEquipment/tank/Tank.java index 5cb8be75dd..bc02ac61dd 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/tank/Tank.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/tank/Tank.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.tank; +import java.util.UUID; import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; import neqsim.processSimulation.processEquipment.mixer.Mixer; import neqsim.processSimulation.processEquipment.stream.Stream; @@ -170,8 +171,8 @@ public StreamInterface getLiquid() { /** {@inheritDoc} */ @Override - public void run() { - inletStreamMixer.run(); + public void run(UUID id) { + inletStreamMixer.run(id); SystemInterface thermoSystem2 = inletStreamMixer.getOutletStream().getThermoSystem().clone(); ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem2); ops.VUflash(thermoSystem2.getVolume(), thermoSystem2.getInternalEnergy()); @@ -229,6 +230,8 @@ public void run() { gasVolume = (1.0 - getLiquidLevel()) * 3.14 / 4.0 * separatorDiameter * separatorDiameter * separatorLength; System.out.println("moles out" + liquidOutStream.getThermoSystem().getTotalNumberOfMoles()); + + setCalculationIdentifier(id); } /** {@inheritDoc} */ @@ -239,13 +242,14 @@ public void displayResult() { /** {@inheritDoc} */ @Override - public void runTransient(double dt) { + public void runTransient(double dt, UUID id) { if (getCalculateSteadyState()) { - run(); + run(id); + increaseTime(dt); return; } - inletStreamMixer.run(); + inletStreamMixer.run(id); System.out.println("moles out" + liquidOutStream.getThermoSystem().getTotalNumberOfMoles()); // double inMoles = @@ -306,6 +310,7 @@ public void runTransient(double dt) { * separatorLength; gasVolume = (1.0 - getLiquidLevel()) * 3.14 / 4.0 * separatorDiameter * separatorDiameter * separatorLength; + setCalculationIdentifier(id); } /** diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/Adjuster.java b/src/main/java/neqsim/processSimulation/processEquipment/util/Adjuster.java index 1569f95a26..f903503f76 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/Adjuster.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/Adjuster.java @@ -1,8 +1,8 @@ package neqsim.processSimulation.processEquipment.util; +import java.util.UUID; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface; import neqsim.processSimulation.processEquipment.stream.Stream; @@ -16,283 +16,294 @@ * @version $Id: $Id */ public class Adjuster extends ProcessEquipmentBaseClass { - private static final long serialVersionUID = 1000; - - ProcessEquipmentInterface adjustedEquipment = null, targetEquipment = null; - String adjustedVarialble = "", targetVariable = "", targetPhase = "", targetComponent = ""; - double targetValue = 0.0; - String targetUnit = ""; - private double tolerance = 1e-6; - double inputValue = 0.0, oldInputValue = 0.0; - private double error = 1e6, oldError = 1.0e6; - int iterations = 0; - private boolean activateWhenLess = false; - - static Logger logger = LogManager.getLogger(Adjuster.class); - - /** - *

- * Constructor for Adjuster. - *

- */ - @Deprecated - public Adjuster() { - this("Adjuster"); - } + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for Adjuster. - *

- * - * @param name a {@link java.lang.String} object - */ - public Adjuster(String name) { - super(name); - } + ProcessEquipmentInterface adjustedEquipment = null; + ProcessEquipmentInterface targetEquipment = null; - /** - *

- * setAdjustedVariable. - *

- * - * @param adjustedEquipment a - * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object - * @param adjstedVariable a {@link java.lang.String} object - */ - public void setAdjustedVariable(ProcessEquipmentInterface adjustedEquipment, - String adjstedVariable) { - this.adjustedEquipment = adjustedEquipment; - this.adjustedVarialble = adjstedVariable; - } + String adjustedVarialble = ""; + String targetVariable = ""; + String targetPhase = ""; + String targetComponent = ""; - /** - *

- * Setter for the field targetVariable. - *

- * - * @param targetEquipment a - * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object - * @param targetVariable a {@link java.lang.String} object - * @param targetValue a double - * @param targetUnit a {@link java.lang.String} object - */ - public void setTargetVariable(ProcessEquipmentInterface targetEquipment, String targetVariable, - double targetValue, String targetUnit) { - this.targetEquipment = targetEquipment; - this.targetVariable = targetVariable; - this.targetValue = targetValue; - this.targetUnit = targetUnit; - } + double targetValue = 0.0; + String targetUnit = ""; + private double tolerance = 1e-6; + double inputValue = 0.0; + double oldInputValue = 0.0; + private double error = 1e6; + private double oldError = 1.0e6; - /** - *

- * Setter for the field targetVariable. - *

- * - * @param targetEquipment a - * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object - * @param targetVariable a {@link java.lang.String} object - * @param targetValue a double - * @param targetUnit a {@link java.lang.String} object - * @param targetPhase a {@link java.lang.String} object - */ - public void setTargetVariable(ProcessEquipmentInterface targetEquipment, String targetVariable, - double targetValue, String targetUnit, String targetPhase) { - this.targetEquipment = targetEquipment; - this.targetVariable = targetVariable; - this.targetValue = targetValue; - this.targetUnit = targetUnit; - this.targetPhase = targetPhase; - } + int iterations = 0; + private boolean activateWhenLess = false; - /** - *

- * Setter for the field targetVariable. - *

- * - * @param targetEquipment a - * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object - * @param targetVariable a {@link java.lang.String} object - * @param targetValue a double - * @param targetUnit a {@link java.lang.String} object - * @param targetPhase a {@link java.lang.String} object - * @param targetComponent a {@link java.lang.String} object - */ - public void setTargetVariable(ProcessEquipmentInterface targetEquipment, String targetVariable, - double targetValue, String targetUnit, String targetPhase, String targetComponent) { - this.targetEquipment = targetEquipment; - this.targetVariable = targetVariable; - this.targetValue = targetValue; - this.targetUnit = targetUnit; - this.targetPhase = targetPhase; - this.targetComponent = targetComponent; - } + static Logger logger = LogManager.getLogger(Adjuster.class); - /** {@inheritDoc} */ - @Override - public void run() { - oldError = error; - - if (adjustedVarialble.equals("mass flow")) { - inputValue = ((Stream) adjustedEquipment).getThermoSystem().getFlowRate("kg/hr"); - } else { - inputValue = ((Stream) adjustedEquipment).getThermoSystem().getNumberOfMoles(); - } - - double targetValueCurrent = 0.0; - if (targetVariable.equals("mass fraction") && !targetPhase.equals("") - && !targetComponent.equals("")) { - targetValueCurrent = ((Stream) targetEquipment).getThermoSystem().getPhase(targetPhase) - .getWtFrac(targetComponent); - } else if (targetVariable.equals("gasVolumeFlow")) { - targetValueCurrent = - ((Stream) targetEquipment).getThermoSystem().getFlowRate(targetUnit); - } else if (targetVariable.equals("pressure")) { - targetValueCurrent = - ((Stream) targetEquipment).getThermoSystem().getPressure(targetUnit); - } else { - targetValueCurrent = ((Stream) targetEquipment).getThermoSystem().getVolume(targetUnit); - } - - if (activateWhenLess && targetValueCurrent > targetValue) { - error = 0.0; - activateWhenLess = true; - return; - } - - iterations++; - double deviation = targetValue - targetValueCurrent; - - error = deviation; - logger.info("adjuster deviation " + deviation + " inputValue " + inputValue); - if (iterations < 2) { - if (adjustedVarialble.equals("mass flow")) { - ((Stream) adjustedEquipment).getThermoSystem() - .setTotalFlowRate(inputValue + deviation, "kg/hr"); - } else { - ((Stream) adjustedEquipment).getThermoSystem() - .setTotalFlowRate(inputValue + deviation, "mol/sec"); - } - } else { - double derivate = (error - oldError) / (inputValue - oldInputValue); - double newVal = error / derivate; - if (adjustedVarialble.equals("mass flow")) { - ((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate(inputValue - newVal, - "kg/hr"); - } else { - ((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate(inputValue - newVal, - "mol/sec"); - } - } - - oldInputValue = inputValue; - } + /** + *

+ * Constructor for Adjuster. + *

+ */ + @Deprecated + public Adjuster() { + this("Adjuster"); + } - /** {@inheritDoc} */ - @Override - public boolean solved() { - if (Math.abs(error) < tolerance) - return true; - else - return false; - } + /** + *

+ * Constructor for Adjuster. + *

+ * + * @param name a {@link java.lang.String} object + */ + public Adjuster(String name) { + super(name); + } - /** {@inheritDoc} */ - @Override - public void displayResult() {} - - /** - *

- * Getter for the field tolerance. - *

- * - * @return a double - */ - public double getTolerance() { - return tolerance; - } + /** + *

+ * setAdjustedVariable. + *

+ * + * @param adjustedEquipment a + * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object + * @param adjstedVariable a {@link java.lang.String} object + */ + public void setAdjustedVariable(ProcessEquipmentInterface adjustedEquipment, + String adjstedVariable) { + this.adjustedEquipment = adjustedEquipment; + this.adjustedVarialble = adjstedVariable; + } - /** - *

- * Setter for the field tolerance. - *

- * - * @param tolerance the tolerance to set - */ - public void setTolerance(double tolerance) { - this.tolerance = tolerance; - } + /** + *

+ * Setter for the field targetVariable. + *

+ * + * @param targetEquipment a + * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object + * @param targetVariable a {@link java.lang.String} object + * @param targetValue a double + * @param targetUnit a {@link java.lang.String} object + */ + public void setTargetVariable(ProcessEquipmentInterface targetEquipment, String targetVariable, + double targetValue, String targetUnit) { + this.targetEquipment = targetEquipment; + this.targetVariable = targetVariable; + this.targetValue = targetValue; + this.targetUnit = targetUnit; + } + + /** + *

+ * Setter for the field targetVariable. + *

+ * + * @param targetEquipment a + * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object + * @param targetVariable a {@link java.lang.String} object + * @param targetValue a double + * @param targetUnit a {@link java.lang.String} object + * @param targetPhase a {@link java.lang.String} object + */ + public void setTargetVariable(ProcessEquipmentInterface targetEquipment, String targetVariable, + double targetValue, String targetUnit, String targetPhase) { + this.targetEquipment = targetEquipment; + this.targetVariable = targetVariable; + this.targetValue = targetValue; + this.targetUnit = targetUnit; + this.targetPhase = targetPhase; + } + + /** + *

+ * Setter for the field targetVariable. + *

+ * + * @param targetEquipment a + * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object + * @param targetVariable a {@link java.lang.String} object + * @param targetValue a double + * @param targetUnit a {@link java.lang.String} object + * @param targetPhase a {@link java.lang.String} object + * @param targetComponent a {@link java.lang.String} object + */ + public void setTargetVariable(ProcessEquipmentInterface targetEquipment, String targetVariable, + double targetValue, String targetUnit, String targetPhase, String targetComponent) { + this.targetEquipment = targetEquipment; + this.targetVariable = targetVariable; + this.targetValue = targetValue; + this.targetUnit = targetUnit; + this.targetPhase = targetPhase; + this.targetComponent = targetComponent; + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + oldError = error; - /** - *

- * Getter for the field error. - *

- * - * @return the error - */ - public double getError() { - return error; + if (adjustedVarialble.equals("mass flow")) { + inputValue = ((Stream) adjustedEquipment).getThermoSystem().getFlowRate("kg/hr"); + } else { + inputValue = ((Stream) adjustedEquipment).getThermoSystem().getNumberOfMoles(); } - /** - *

- * Setter for the field error. - *

- * - * @param error the error to set - */ - public void setError(double error) { - this.error = error; + double targetValueCurrent = 0.0; + if (targetVariable.equals("mass fraction") && !targetPhase.equals("") + && !targetComponent.equals("")) { + targetValueCurrent = ((Stream) targetEquipment).getThermoSystem().getPhase(targetPhase) + .getWtFrac(targetComponent); + } else if (targetVariable.equals("gasVolumeFlow")) { + targetValueCurrent = ((Stream) targetEquipment).getThermoSystem().getFlowRate(targetUnit); + } else if (targetVariable.equals("pressure")) { + targetValueCurrent = ((Stream) targetEquipment).getThermoSystem().getPressure(targetUnit); + } else { + targetValueCurrent = ((Stream) targetEquipment).getThermoSystem().getVolume(targetUnit); } - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - // test code for adjuster... - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 20.00); - testSystem.addComponent("methane", 1000.00); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - - Stream stream_1 = new Stream("Stream1", testSystem); - Adjuster adjuster1 = new Adjuster(); - adjuster1.setAdjustedVariable(stream_1, "molarFlow"); - adjuster1.setTargetVariable(stream_1, "gasVolumeFlow", 10.0, "MSm3/day", ""); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(stream_1); - operations.add(adjuster1); - - operations.run(); + if (activateWhenLess && targetValueCurrent > targetValue) { + error = 0.0; + activateWhenLess = true; + setCalculationIdentifier(id); + return; } - /** - *

- * isActivateWhenLess. - *

- * - * @return a boolean - */ - public boolean isActivateWhenLess() { - return activateWhenLess; + iterations++; + double deviation = targetValue - targetValueCurrent; + + error = deviation; + logger.info("adjuster deviation " + deviation + " inputValue " + inputValue); + if (iterations < 2) { + if (adjustedVarialble.equals("mass flow")) { + ((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate(inputValue + deviation, + "kg/hr"); + } else { + ((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate(inputValue + deviation, + "mol/sec"); + } + } else { + double derivate = (error - oldError) / (inputValue - oldInputValue); + double newVal = error / derivate; + if (adjustedVarialble.equals("mass flow")) { + ((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate(inputValue - newVal, + "kg/hr"); + } else { + ((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate(inputValue - newVal, + "mol/sec"); + } } - /** - *

- * Setter for the field activateWhenLess. - *

- * - * @param activateWhenLess a boolean - */ - public void setActivateWhenLess(boolean activateWhenLess) { - this.activateWhenLess = activateWhenLess; + oldInputValue = inputValue; + + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public boolean solved() { + if (Math.abs(error) < tolerance) { + return true; + } else { + return false; } + } + + /** {@inheritDoc} */ + @Override + public void displayResult() {} + + /** + *

+ * Getter for the field tolerance. + *

+ * + * @return a double + */ + public double getTolerance() { + return tolerance; + } + + /** + *

+ * Setter for the field tolerance. + *

+ * + * @param tolerance the tolerance to set + */ + public void setTolerance(double tolerance) { + this.tolerance = tolerance; + } + + /** + *

+ * Getter for the field error. + *

+ * + * @return the error + */ + public double getError() { + return error; + } + + /** + *

+ * Setter for the field error. + *

+ * + * @param error the error to set + */ + public void setError(double error) { + this.error = error; + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + // test code for adjuster... + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 20.00); + testSystem.addComponent("methane", 1000.00); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + + Stream stream_1 = new Stream("Stream1", testSystem); + Adjuster adjuster1 = new Adjuster(); + adjuster1.setAdjustedVariable(stream_1, "molarFlow"); + adjuster1.setTargetVariable(stream_1, "gasVolumeFlow", 10.0, "MSm3/day", ""); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(adjuster1); + + operations.run(); + } + + /** + *

+ * isActivateWhenLess. + *

+ * + * @return a boolean + */ + public boolean isActivateWhenLess() { + return activateWhenLess; + } + + /** + *

+ * Setter for the field activateWhenLess. + *

+ * + * @param activateWhenLess a boolean + */ + public void setActivateWhenLess(boolean activateWhenLess) { + this.activateWhenLess = activateWhenLess; + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/Calculator.java b/src/main/java/neqsim/processSimulation/processEquipment/util/Calculator.java index cc8c5f6dce..93974db80b 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/Calculator.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/Calculator.java @@ -1,6 +1,7 @@ package neqsim.processSimulation.processEquipment.util; import java.util.ArrayList; +import java.util.UUID; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; @@ -16,81 +17,81 @@ * @version $Id: $Id */ public class Calculator extends ProcessEquipmentBaseClass { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(Calculator.class); - ArrayList inputVariable = new ArrayList(); - private ProcessEquipmentInterface outputVariable; - String type = "sumTEG"; + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(Calculator.class); + ArrayList inputVariable = new ArrayList(); + private ProcessEquipmentInterface outputVariable; + String type = "sumTEG"; - /** - *

- * Constructor for Calculator. - *

- * - * @param name a {@link java.lang.String} object - */ - public Calculator(String name) { - super(name); - } + /** + *

+ * Constructor for Calculator. + *

+ * + * @param name a {@link java.lang.String} object + */ + public Calculator(String name) { + super(name); + } - /** - *

- * addInputVariable. - *

- * - * @param unit a {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} - * object - */ - public void addInputVariable(ProcessEquipmentInterface unit) { - inputVariable.add(unit); - } + /** + *

+ * addInputVariable. + *

+ * + * @param unit a {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} + * object + */ + public void addInputVariable(ProcessEquipmentInterface unit) { + inputVariable.add(unit); + } - /** - *

- * Getter for the field outputVariable. - *

- * - * @return a {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object - */ - public ProcessEquipmentInterface getOutputVariable() { - return outputVariable; - } + /** + *

+ * Getter for the field outputVariable. + *

+ * + * @return a {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object + */ + public ProcessEquipmentInterface getOutputVariable() { + return outputVariable; + } - /** {@inheritDoc} */ - @Override - public void run() { - double sum = 0.0; + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + double sum = 0.0; - if (name.equals("MEG makeup calculator")) { - for (int i = 0; i < inputVariable.size(); i++) { - sum += inputVariable.get(i).getFluid().getPhase(0).getComponent("MEG") - .getFlowRate("kg/hr"); - } - } else { - for (int i = 0; i < inputVariable.size(); i++) { - sum += inputVariable.get(i).getFluid().getPhase(0).getComponent("TEG") - .getFlowRate("kg/hr"); - } - } - - // System.out.println("make up MEG " + sum); - outputVariable.getFluid().setTotalFlowRate(sum, "kg/hr"); - try { - ((Stream) outputVariable).setFlowRate(sum, "kg/hr"); - } catch (Exception e) { - logger.error("error", e.getMessage()); - } + if (name.equals("MEG makeup calculator")) { + for (int i = 0; i < inputVariable.size(); i++) { + sum += inputVariable.get(i).getFluid().getPhase(0).getComponent("MEG").getFlowRate("kg/hr"); + } + } else { + for (int i = 0; i < inputVariable.size(); i++) { + sum += inputVariable.get(i).getFluid().getPhase(0).getComponent("TEG").getFlowRate("kg/hr"); + } } - /** - *

- * Setter for the field outputVariable. - *

- * - * @param outputVariable a - * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object - */ - public void setOutputVariable(ProcessEquipmentInterface outputVariable) { - this.outputVariable = outputVariable; + // System.out.println("make up MEG " + sum); + outputVariable.getFluid().setTotalFlowRate(sum, "kg/hr"); + try { + ((Stream) outputVariable).setFlowRate(sum, "kg/hr"); + outputVariable.setCalculationIdentifier(id); + } catch (Exception e) { + logger.error("error", e.getMessage()); } + setCalculationIdentifier(id); + } + + /** + *

+ * Setter for the field outputVariable. + *

+ * + * @param outputVariable a + * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object + */ + public void setOutputVariable(ProcessEquipmentInterface outputVariable) { + this.outputVariable = outputVariable; + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/GORfitter.java b/src/main/java/neqsim/processSimulation/processEquipment/util/GORfitter.java index f2a7b10a26..b21bf78b04 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/GORfitter.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/GORfitter.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.util; +import java.util.UUID; import neqsim.processSimulation.measurementDevice.MultiPhaseMeter; import neqsim.processSimulation.processEquipment.TwoPortEquipment; import neqsim.processSimulation.processEquipment.stream.Stream; @@ -126,7 +127,7 @@ public void setTemperature(double temperature, String unitT) { /** {@inheritDoc} */ @Override - public void run() { + public void run(UUID id) { SystemInterface tempFluid = inStream.getThermoSystem().clone(); double flow = tempFluid.getFlowRate("kg/sec"); @@ -200,20 +201,19 @@ public void run() { e.printStackTrace(); } outStream.setThermoSystem(tempFluid); - if(!tempFluid.hasPhaseType("gas")) { + if (!tempFluid.hasPhaseType("gas")) { GVF = 0.0; - } - else if(tempFluid.hasPhaseType("gas") && tempFluid.hasPhaseType("oil")) { - GVF = tempFluid.getPhase("gas").getCorrectedVolume() - / (tempFluid.getPhase("oil").getCorrectedVolume() - + tempFluid.getPhase("gas").getCorrectedVolume()); - } - else { + } else if (tempFluid.hasPhaseType("gas") && tempFluid.hasPhaseType("oil")) { + GVF = tempFluid.getPhase("gas").getCorrectedVolume() + / (tempFluid.getPhase("oil").getCorrectedVolume() + + tempFluid.getPhase("gas").getCorrectedVolume()); + } else { GVF = Double.NaN; } - return; - } + outStream.setCalculationIdentifier(id); + setCalculationIdentifier(id); + } /** *

diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/MoleFractionControllerUtil.java b/src/main/java/neqsim/processSimulation/processEquipment/util/MoleFractionControllerUtil.java index 6994e26d90..8890c03d75 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/MoleFractionControllerUtil.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/MoleFractionControllerUtil.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.util; +import java.util.UUID; import neqsim.processSimulation.processEquipment.TwoPortEquipment; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; @@ -116,7 +117,7 @@ public void setRelativeMoleFractionReduction(String compName, double moleFracRat /** {@inheritDoc} */ @Override - public void run() { + public void run(UUID id) { // System.out.println("MoleFractionContollerUtil running.."); thermoSystem = inStream.getThermoSystem().clone(); if (thermoSystem.getPhase(0).hasComponent(compName)) { @@ -132,6 +133,7 @@ public void run() { thermoOps.TPflash(); } outStream.setThermoSystem(thermoSystem); + setCalculationIdentifier(id); } /** {@inheritDoc} */ diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/NeqSimUnit.java b/src/main/java/neqsim/processSimulation/processEquipment/util/NeqSimUnit.java index 8a7bf3fc12..a937c06a3d 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/NeqSimUnit.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/NeqSimUnit.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.util; +import java.util.UUID; import neqsim.fluidMechanics.flowNode.FlowNodeInterface; import neqsim.fluidMechanics.flowNode.twoPhaseNode.twoPhasePipeFlowNode.AnnularFlow; import neqsim.fluidMechanics.flowNode.twoPhaseNode.twoPhasePipeFlowNode.DropletFlowNode; @@ -19,337 +20,339 @@ * @version $Id: $Id */ public class NeqSimUnit extends TwoPortEquipment { - private static final long serialVersionUID = 1000; - - SystemInterface thermoSystem; - private String equipment = "pipeline"; - String flowPattern = "stratified"; - private double length = 1.0; - public int numberOfNodes = 100; - private double ID = 0.5; - private double outerTemperature = 283.15; - public double interfacialArea = 0.0; - - /** - *

- * Constructor for NeqSimUnit. - *

- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - * @param equipment a {@link java.lang.String} object - * @param flowPattern a {@link java.lang.String} object - */ - public NeqSimUnit(StreamInterface inletStream, String equipment, String flowPattern) { - super("NeqSimUnit"); - this.flowPattern = flowPattern; - this.setEquipment(equipment); - setInletStream(inletStream); - } - - /** - *

- * Setter for the field inletStream. - *

- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - public void setInletStream(StreamInterface inletStream) { - this.inStream = inletStream; - - thermoSystem = inletStream.getThermoSystem().clone(); - outStream = new Stream("outStream", thermoSystem); + private static final long serialVersionUID = 1000; + + SystemInterface thermoSystem; + private String equipment = "pipeline"; + String flowPattern = "stratified"; + private double length = 1.0; + public int numberOfNodes = 100; + private double ID = 0.5; + private double outerTemperature = 283.15; + public double interfacialArea = 0.0; + + /** + *

+ * Constructor for NeqSimUnit. + *

+ * + * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + * @param equipment a {@link java.lang.String} object + * @param flowPattern a {@link java.lang.String} object + */ + public NeqSimUnit(StreamInterface inletStream, String equipment, String flowPattern) { + super("NeqSimUnit"); + this.flowPattern = flowPattern; + this.setEquipment(equipment); + setInletStream(inletStream); + } + + /** + *

+ * Setter for the field inletStream. + *

+ * + * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object + */ + public void setInletStream(StreamInterface inletStream) { + this.inStream = inletStream; + + thermoSystem = inletStream.getThermoSystem().clone(); + outStream = new Stream("outStream", thermoSystem); + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + thermoSystem = inStream.getThermoSystem().clone(); + if (equipment.equals("pipeline") && flowPattern.equals("stratified")) { + runStratified(); + } else if (equipment.equals("pipeline") && flowPattern.equals("annular")) { + runAnnular(); + } else if (equipment.equals("pipeline") && flowPattern.equals("droplet")) { + runDroplet(); + } else { + runStratified(); } - - /** {@inheritDoc} */ - @Override - public void run() { - thermoSystem = inStream.getThermoSystem().clone(); - if (equipment.equals("pipeline") && flowPattern.equals("stratified")) { - runStratified(); - } else if (equipment.equals("pipeline") && flowPattern.equals("annular")) { - runAnnular(); - } else if (equipment.equals("pipeline") && flowPattern.equals("droplet")) { - runDroplet(); - } else { - runStratified(); - } - // outStream.setThermoSystem(thermoSystem); - } - - /** - *

- * runDroplet. - *

- */ - public void runDroplet() { - PipeData pipe1 = new PipeData(getID(), 0.00025); - FlowNodeInterface test = new DropletFlowNode(thermoSystem, pipe1); - test.setInterphaseModelType(1); - test.setLengthOfNode(getLength() / (numberOfNodes * 1.0)); - test.getGeometry().getSurroundingEnvironment().setTemperature(getOuterTemperature()); - - test.getFluidBoundary().setHeatTransferCalc(false); - test.getFluidBoundary().setMassTransferCalc(true); - double length = 0; - test.initFlowCalc(); - double[][] temperatures2 = new double[3][1000]; - int k = 0; - interfacialArea = 0.0; - for (int i = 0; i < numberOfNodes; i++) { - interfacialArea = getInterfacialArea() + test.getInterphaseContactArea(); - length += test.getLengthOfNode(); - test.initFlowCalc(); - test.calcFluxes(); - if (i > 1 && (i % 1) == 0) { - k++; - // test.display("length " + length); - // test.getBulkSystem().display("length " + length); - // test.getInterphaseSystem().display("length " + length); - // test.getFluidBounsdary().display("length " + length); - // test.setLengthOfNode(0.000005 + test.getLengthOfNode() / 2.0); - temperatures2[0][k] = length; - temperatures2[1][k] = test.getGeometry().getInnerWallTemperature(); - // test.getFluidBoundary().display("test"); - } - - // test.getBulkSystem().display(); - test.update(); - // test.getFluidBoundary().display("length " + length); - // test.getInterphaseSystem().display("length " + length); - - // test.getFluidBoundary().display("test"); - } - - /* - * for (int i = 0; i < k; i++) { System.out.println("len temp " + temperatures2[0][i] + " " - * + temperatures2[1][i]); } - */ + // outStream.setThermoSystem(thermoSystem); + outStream.setCalculationIdentifier(id); + setCalculationIdentifier(id); + } + + /** + *

+ * runDroplet. + *

+ */ + public void runDroplet() { + PipeData pipe1 = new PipeData(getID(), 0.00025); + FlowNodeInterface test = new DropletFlowNode(thermoSystem, pipe1); + test.setInterphaseModelType(1); + test.setLengthOfNode(getLength() / (numberOfNodes * 1.0)); + test.getGeometry().getSurroundingEnvironment().setTemperature(getOuterTemperature()); + + test.getFluidBoundary().setHeatTransferCalc(false); + test.getFluidBoundary().setMassTransferCalc(true); + double length = 0; + test.initFlowCalc(); + double[][] temperatures2 = new double[3][1000]; + int k = 0; + interfacialArea = 0.0; + for (int i = 0; i < numberOfNodes; i++) { + interfacialArea = getInterfacialArea() + test.getInterphaseContactArea(); + length += test.getLengthOfNode(); + test.initFlowCalc(); + test.calcFluxes(); + if (i > 1 && (i % 1) == 0) { + k++; // test.display("length " + length); - outStream.setThermoSystem(test.getBulkSystem()); + // test.getBulkSystem().display("length " + length); + // test.getInterphaseSystem().display("length " + length); + // test.getFluidBounsdary().display("length " + length); + // test.setLengthOfNode(0.000005 + test.getLengthOfNode() / 2.0); + temperatures2[0][k] = length; + temperatures2[1][k] = test.getGeometry().getInnerWallTemperature(); + // test.getFluidBoundary().display("test"); + } + + // test.getBulkSystem().display(); + test.update(); + // test.getFluidBoundary().display("length " + length); + // test.getInterphaseSystem().display("length " + length); + + // test.getFluidBoundary().display("test"); } - /** - *

- * runStratified. - *

+ /* + * for (int i = 0; i < k; i++) { System.out.println("len temp " + temperatures2[0][i] + " " + + * temperatures2[1][i]); } */ - public void runStratified() { - PipeData pipe1 = new PipeData(getID(), 0.00025); - FlowNodeInterface test = new StratifiedFlowNode(thermoSystem, pipe1); - test.setInterphaseModelType(1); - test.setLengthOfNode(getLength() / (numberOfNodes * 1.0)); - test.getGeometry().getSurroundingEnvironment().setTemperature(getOuterTemperature()); - - test.getFluidBoundary().setHeatTransferCalc(false); - test.getFluidBoundary().setMassTransferCalc(true); - double length = 0; - test.initFlowCalc(); - double[][] temperatures2 = new double[3][1000]; - int k = 0; - interfacialArea = 0.0; - for (int i = 0; i < numberOfNodes; i++) { - interfacialArea = getInterfacialArea() + test.getInterphaseContactArea(); - length += test.getLengthOfNode(); - test.initFlowCalc(); - test.calcFluxes(); - if (i > 1 && (i % 1) == 0) { - k++; - // test.display("length " + length); - // test.getBulkSystem().display("length " + length); - // test.getInterphaseSystem().display("length " + length); - // test.getFluidBounsdary().display("length " + length); - // test.setLengthOfNode(0.000005 + test.getLengthOfNode() / 2.0); - temperatures2[0][k] = length; - temperatures2[1][k] = test.getGeometry().getInnerWallTemperature(); - // test.getFluidBoundary().display("test"); - } - - // test.getBulkSystem().display(); - test.update(); - // test.getFluidBoundary().display("length " + length); - // test.getInterphaseSystem().display("length " + length); - - // test.getFluidBoundary().display("test"); - } - - /* - * for (int i = 0; i < k; i++) { System.out.println("len temp " + temperatures2[0][i] + " " - * + temperatures2[1][i]); } - */ + // test.display("length " + length); + outStream.setThermoSystem(test.getBulkSystem()); + } + + /** + *

+ * runStratified. + *

+ */ + public void runStratified() { + PipeData pipe1 = new PipeData(getID(), 0.00025); + FlowNodeInterface test = new StratifiedFlowNode(thermoSystem, pipe1); + test.setInterphaseModelType(1); + test.setLengthOfNode(getLength() / (numberOfNodes * 1.0)); + test.getGeometry().getSurroundingEnvironment().setTemperature(getOuterTemperature()); + + test.getFluidBoundary().setHeatTransferCalc(false); + test.getFluidBoundary().setMassTransferCalc(true); + double length = 0; + test.initFlowCalc(); + double[][] temperatures2 = new double[3][1000]; + int k = 0; + interfacialArea = 0.0; + for (int i = 0; i < numberOfNodes; i++) { + interfacialArea = getInterfacialArea() + test.getInterphaseContactArea(); + length += test.getLengthOfNode(); + test.initFlowCalc(); + test.calcFluxes(); + if (i > 1 && (i % 1) == 0) { + k++; // test.display("length " + length); - outStream.setThermoSystem(test.getBulkSystem()); + // test.getBulkSystem().display("length " + length); + // test.getInterphaseSystem().display("length " + length); + // test.getFluidBounsdary().display("length " + length); + // test.setLengthOfNode(0.000005 + test.getLengthOfNode() / 2.0); + temperatures2[0][k] = length; + temperatures2[1][k] = test.getGeometry().getInnerWallTemperature(); + // test.getFluidBoundary().display("test"); + } + + // test.getBulkSystem().display(); + test.update(); + // test.getFluidBoundary().display("length " + length); + // test.getInterphaseSystem().display("length " + length); + + // test.getFluidBoundary().display("test"); } - /** - *

- * runAnnular. - *

+ /* + * for (int i = 0; i < k; i++) { System.out.println("len temp " + temperatures2[0][i] + " " + + * temperatures2[1][i]); } */ - public void runAnnular() { - PipeData pipe1 = new PipeData(getID(), 0.00025); - FlowNodeInterface test = new AnnularFlow(thermoSystem, pipe1); - test.setInterphaseModelType(1); - test.setLengthOfNode(getLength() / (numberOfNodes * 1.0)); - test.getGeometry().getSurroundingEnvironment().setTemperature(getOuterTemperature()); - - test.getFluidBoundary().setHeatTransferCalc(false); - test.getFluidBoundary().setMassTransferCalc(true); - double length = 0; - test.initFlowCalc(); - double[][] temperatures2 = new double[3][1000]; - int k = 0; - interfacialArea = 0.0; - for (int i = 0; i < numberOfNodes; i++) { - interfacialArea = getInterfacialArea() + test.getInterphaseContactArea(); - length += test.getLengthOfNode(); - test.initFlowCalc(); - test.calcFluxes(); - if (i > 1 && (i % 1) == 0) { - k++; - // test.display("length " + length); - // test.getBulkSystem().display("length " + length); - // test.getInterphaseSystem().display("length " + length); - // test.getFluidBounsdary().display("length " + length); - // test.setLengthOfNode(0.000005 + test.getLengthOfNode() / 2.0); - temperatures2[0][k] = length; - temperatures2[1][k] = test.getGeometry().getInnerWallTemperature(); - // test.getFluidBoundary().display("test"); - } - - // test.getBulkSystem().display(); - test.update(); - // test.getFluidBoundary().display("length " + length); - // test.getInterphaseSystem().display("length " + length); - - // test.getFluidBoundary().display("test"); - } - - /* - * for (int i = 0; i < k; i++) { System.out.println("len temp " + temperatures2[0][i] + " " - * + temperatures2[1][i]); } - */ + // test.display("length " + length); + outStream.setThermoSystem(test.getBulkSystem()); + } + + /** + *

+ * runAnnular. + *

+ */ + public void runAnnular() { + PipeData pipe1 = new PipeData(getID(), 0.00025); + FlowNodeInterface test = new AnnularFlow(thermoSystem, pipe1); + test.setInterphaseModelType(1); + test.setLengthOfNode(getLength() / (numberOfNodes * 1.0)); + test.getGeometry().getSurroundingEnvironment().setTemperature(getOuterTemperature()); + + test.getFluidBoundary().setHeatTransferCalc(false); + test.getFluidBoundary().setMassTransferCalc(true); + double length = 0; + test.initFlowCalc(); + double[][] temperatures2 = new double[3][1000]; + int k = 0; + interfacialArea = 0.0; + for (int i = 0; i < numberOfNodes; i++) { + interfacialArea = getInterfacialArea() + test.getInterphaseContactArea(); + length += test.getLengthOfNode(); + test.initFlowCalc(); + test.calcFluxes(); + if (i > 1 && (i % 1) == 0) { + k++; // test.display("length " + length); - outStream.setThermoSystem(test.getBulkSystem()); - } - - /** - *

- * Getter for the field length. - *

- * - * @return a double - */ - public double getLength() { - return length; - } - - /** - *

- * Setter for the field length. - *

- * - * @param length a double - */ - public void setLength(double length) { - this.length = length; - } - - /** - *

- * getID. - *

- * - * @return a double - */ - public double getID() { - return ID; - } - - /** - *

- * setID. - *

- * - * @param iD a double - */ - public void setID(double iD) { - ID = iD; - } - - /** - *

- * Getter for the field outerTemperature. - *

- * - * @return a double - */ - public double getOuterTemperature() { - return outerTemperature; - } - - /** - *

- * Setter for the field outerTemperature. - *

- * - * @param outerTemperature a double - */ - public void setOuterTemperature(double outerTemperature) { - this.outerTemperature = outerTemperature; - } - - /** - *

- * Getter for the field equipment. - *

- * - * @return a {@link java.lang.String} object - */ - public String getEquipment() { - return equipment; + // test.getBulkSystem().display("length " + length); + // test.getInterphaseSystem().display("length " + length); + // test.getFluidBounsdary().display("length " + length); + // test.setLengthOfNode(0.000005 + test.getLengthOfNode() / 2.0); + temperatures2[0][k] = length; + temperatures2[1][k] = test.getGeometry().getInnerWallTemperature(); + // test.getFluidBoundary().display("test"); + } + + // test.getBulkSystem().display(); + test.update(); + // test.getFluidBoundary().display("length " + length); + // test.getInterphaseSystem().display("length " + length); + + // test.getFluidBoundary().display("test"); } - /** - *

- * Setter for the field equipment. - *

- * - * @param equipment a {@link java.lang.String} object + /* + * for (int i = 0; i < k; i++) { System.out.println("len temp " + temperatures2[0][i] + " " + + * temperatures2[1][i]); } */ - public void setEquipment(String equipment) { - this.equipment = equipment; - } - - /** - *

- * Getter for the field interfacialArea. - *

- * - * @return a double - */ - public double getInterfacialArea() { - return interfacialArea; - } - - /** - *

- * Getter for the field numberOfNodes. - *

- * - * @return a int - */ - public int getNumberOfNodes() { - return numberOfNodes; - } - - /** - *

- * Setter for the field numberOfNodes. - *

- * - * @param numberOfNodes a int - */ - public void setNumberOfNodes(int numberOfNodes) { - this.numberOfNodes = numberOfNodes; - } + // test.display("length " + length); + outStream.setThermoSystem(test.getBulkSystem()); + } + + /** + *

+ * Getter for the field length. + *

+ * + * @return a double + */ + public double getLength() { + return length; + } + + /** + *

+ * Setter for the field length. + *

+ * + * @param length a double + */ + public void setLength(double length) { + this.length = length; + } + + /** + *

+ * getID. + *

+ * + * @return a double + */ + public double getID() { + return ID; + } + + /** + *

+ * setID. + *

+ * + * @param iD a double + */ + public void setID(double iD) { + ID = iD; + } + + /** + *

+ * Getter for the field outerTemperature. + *

+ * + * @return a double + */ + public double getOuterTemperature() { + return outerTemperature; + } + + /** + *

+ * Setter for the field outerTemperature. + *

+ * + * @param outerTemperature a double + */ + public void setOuterTemperature(double outerTemperature) { + this.outerTemperature = outerTemperature; + } + + /** + *

+ * Getter for the field equipment. + *

+ * + * @return a {@link java.lang.String} object + */ + public String getEquipment() { + return equipment; + } + + /** + *

+ * Setter for the field equipment. + *

+ * + * @param equipment a {@link java.lang.String} object + */ + public void setEquipment(String equipment) { + this.equipment = equipment; + } + + /** + *

+ * Getter for the field interfacialArea. + *

+ * + * @return a double + */ + public double getInterfacialArea() { + return interfacialArea; + } + + /** + *

+ * Getter for the field numberOfNodes. + *

+ * + * @return a int + */ + public int getNumberOfNodes() { + return numberOfNodes; + } + + /** + *

+ * Setter for the field numberOfNodes. + *

+ * + * @param numberOfNodes a int + */ + public void setNumberOfNodes(int numberOfNodes) { + this.numberOfNodes = numberOfNodes; + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java b/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java index 640b05084c..24a9747825 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java @@ -1,6 +1,7 @@ package neqsim.processSimulation.processEquipment.util; import java.util.ArrayList; +import java.util.UUID; import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; import neqsim.processSimulation.processEquipment.mixer.MixerInterface; import neqsim.processSimulation.processEquipment.stream.Stream; @@ -59,6 +60,17 @@ public SystemInterface getThermoSystem() { return mixedStream.getThermoSystem(); } + /** + *

+ * Setter for the field downstreamProperty. + *

+ * + * @param property a {@link java.util.ArrayList} object + */ + public void setDownstreamProperty(ArrayList property) { + this.downstreamProperty = property; + } + /** *

* Setter for the field downstreamProperty. @@ -226,7 +238,7 @@ public void setDownstreamProperties() { /** {@inheritDoc} */ @Override - public void run() { + public void run(UUID id) { iterations++; /* * if(firstTime || iterations>maxIterations) { firstTime=false; return; @@ -264,10 +276,12 @@ public void run() { setDownstreamProperties(); testOps.TPflash(); } + mixedStream.setCalculationIdentifier(id); setError(massBalanceCheck()); System.out.println(name + " recycle error: " + getError()); lastIterationStream = (Stream) mixedStream.clone(); outletStream.setThermoSystem(mixedStream.getThermoSystem()); + outletStream.setCalculationIdentifier(id); // System.out.println("flow rate new in recycle " + // outletStream.getFlowRate("kg/hr")); @@ -279,6 +293,7 @@ public void run() { // System.out.println("beta " + mixedStream.getThermoSystem().getBeta()); // outStream.setThermoSystem(mixedStream.getThermoSystem()); + setCalculationIdentifier(id); } /** @@ -425,17 +440,6 @@ public ArrayList getDownstreamProperty() { return downstreamProperty; } - /** - *

- * Setter for the field downstreamProperty. - *

- * - * @param upstreamProperty a {@link java.util.ArrayList} object - */ - public void setDownstreamProperty(ArrayList upstreamProperty) { - this.downstreamProperty = upstreamProperty; - } - /** *

* Getter for the field outletStream. diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/SetPoint.java b/src/main/java/neqsim/processSimulation/processEquipment/util/SetPoint.java index 38af1984a3..e9228a777a 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/SetPoint.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/SetPoint.java @@ -1,8 +1,8 @@ package neqsim.processSimulation.processEquipment.util; +import java.util.UUID; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface; import neqsim.processSimulation.processEquipment.stream.Stream; @@ -16,211 +16,223 @@ * @version $Id: $Id */ public class SetPoint extends ProcessEquipmentBaseClass { - private static final long serialVersionUID = 1000; - - ProcessEquipmentInterface sourceEquipment = null, targetEquipment = null; - String sourceVarialble = "", targetVariable = "", targetPhase = "", targetComponent = ""; - double targetValue = 0.0; - String targetUnit = ""; - double inputValue = 0.0, oldInputValue = 0.0; - - static Logger logger = LogManager.getLogger(SetPoint.class); - - /** - *

- * Constructor for SetPoint. - *

- */ - @Deprecated - public SetPoint() { - this("SetPoint"); - } - - /** - *

- * Constructor for SetPoint. - *

- * - * @param name a {@link java.lang.String} object - */ - public SetPoint(String name) { - super(name); - } - - /** - *

- * Constructor for SetPoint. - *

- * - * @param name a {@link java.lang.String} object - * @param targetEquipment a - * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object - * @param targetVariable a {@link java.lang.String} object - * @param sourceEquipment a - * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object - */ - public SetPoint(String name, ProcessEquipmentInterface targetEquipment, String targetVariable, - ProcessEquipmentInterface sourceEquipment) { - this(name); - this.targetEquipment = targetEquipment; - this.targetVariable = targetVariable; - this.sourceEquipment = sourceEquipment; - run(); - } - - /** - *

- * setSourceVariable. - *

- * - * @param adjustedEquipment a - * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object - * @param adjstedVariable a {@link java.lang.String} object - */ - public void setSourceVariable(ProcessEquipmentInterface adjustedEquipment, - String adjstedVariable) { - this.sourceEquipment = adjustedEquipment; - this.sourceVarialble = adjstedVariable; - } - - /** - *

- * setSourceVariable. - *

- * - * @param adjustedEquipment a - * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object - */ - public void setSourceVariable(ProcessEquipmentInterface adjustedEquipment) { - this.sourceEquipment = adjustedEquipment; - } - - /** - *

- * Setter for the field targetVariable. - *

- * - * @param targetEquipment a - * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object - * @param targetVariable a {@link java.lang.String} object - * @param targetValue a double - * @param targetUnit a {@link java.lang.String} object - */ - public void setTargetVariable(ProcessEquipmentInterface targetEquipment, String targetVariable, - double targetValue, String targetUnit) { - this.targetEquipment = targetEquipment; - this.targetVariable = targetVariable; - this.targetValue = targetValue; - this.targetUnit = targetUnit; - } - - /** - *

- * Setter for the field targetVariable. - *

- * - * @param targetEquipment a - * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object - * @param targetVariable a {@link java.lang.String} object - */ - public void setTargetVariable(ProcessEquipmentInterface targetEquipment, - String targetVariable) { - this.targetEquipment = targetEquipment; - this.targetVariable = targetVariable; - } - - /** - *

- * Setter for the field targetVariable. - *

- * - * @param targetEquipment a - * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object - * @param targetVariable a {@link java.lang.String} object - * @param targetValue a double - * @param targetUnit a {@link java.lang.String} object - * @param targetPhase a {@link java.lang.String} object - */ - public void setTargetVariable(ProcessEquipmentInterface targetEquipment, String targetVariable, - double targetValue, String targetUnit, String targetPhase) { - this.targetEquipment = targetEquipment; - this.targetVariable = targetVariable; - this.targetValue = targetValue; - this.targetUnit = targetUnit; - this.targetPhase = targetPhase; - } - - /** - *

- * Setter for the field targetVariable. - *

- * - * @param targetEquipment a - * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object - * @param targetVariable a {@link java.lang.String} object - * @param targetValue a double - * @param targetUnit a {@link java.lang.String} object - * @param targetPhase a {@link java.lang.String} object - * @param targetComponent a {@link java.lang.String} object - */ - public void setTargetVariable(ProcessEquipmentInterface targetEquipment, String targetVariable, - double targetValue, String targetUnit, String targetPhase, String targetComponent) { - this.targetEquipment = targetEquipment; - this.targetVariable = targetVariable; - this.targetValue = targetValue; - this.targetUnit = targetUnit; - this.targetPhase = targetPhase; - this.targetComponent = targetComponent; - } - - /** {@inheritDoc} */ - @Override - public void run() { - if (targetVariable.equals("pressure")) { - targetEquipment.setPressure(sourceEquipment.getPressure()); - } else { - inputValue = ((Stream) sourceEquipment).getThermoSystem().getNumberOfMoles(); - - double targetValueCurrent = - ((Stream) targetEquipment).getThermoSystem().getVolume(targetUnit); - - double deviation = targetValue - targetValueCurrent; - - logger.info("adjuster deviation " + deviation + " inputValue " + inputValue); - - oldInputValue = inputValue; - } - } - - /** {@inheritDoc} */ - @Override - public void displayResult() {} - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - // test code for adjuster... - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 20.00); - testSystem.addComponent("methane", 1000.00); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - - Stream stream_1 = new Stream("Stream1", testSystem); - SetPoint adjuster1 = new SetPoint(); - adjuster1.setSourceVariable(stream_1, "molarFlow"); - adjuster1.setTargetVariable(stream_1, "gasVolumeFlow", 10.0, "", "MSm3/day"); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(stream_1); - operations.add(adjuster1); - - operations.run(); + private static final long serialVersionUID = 1000; + + ProcessEquipmentInterface sourceEquipment = null; + + ProcessEquipmentInterface targetEquipment = null; + + String sourceVarialble = ""; + + String targetVariable = ""; + + String targetPhase = ""; + + String targetComponent = ""; + + double targetValue = 0.0; + String targetUnit = ""; + double inputValue = 0.0; + + double oldInputValue = 0.0; + + static Logger logger = LogManager.getLogger(SetPoint.class); + + /** + *

+ * Constructor for SetPoint. + *

+ */ + @Deprecated + public SetPoint() { + this("SetPoint"); + } + + /** + *

+ * Constructor for SetPoint. + *

+ * + * @param name a {@link java.lang.String} object + */ + public SetPoint(String name) { + super(name); + } + + /** + *

+ * Constructor for SetPoint. + *

+ * + * @param name a {@link java.lang.String} object + * @param targetEquipment a + * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object + * @param targetVariable a {@link java.lang.String} object + * @param sourceEquipment a + * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object + */ + public SetPoint(String name, ProcessEquipmentInterface targetEquipment, String targetVariable, + ProcessEquipmentInterface sourceEquipment) { + this(name); + this.targetEquipment = targetEquipment; + this.targetVariable = targetVariable; + this.sourceEquipment = sourceEquipment; + run(); + } + + /** + *

+ * setSourceVariable. + *

+ * + * @param adjustedEquipment a + * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object + * @param adjstedVariable a {@link java.lang.String} object + */ + public void setSourceVariable(ProcessEquipmentInterface adjustedEquipment, + String adjstedVariable) { + this.sourceEquipment = adjustedEquipment; + this.sourceVarialble = adjstedVariable; + } + + /** + *

+ * setSourceVariable. + *

+ * + * @param adjustedEquipment a + * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object + */ + public void setSourceVariable(ProcessEquipmentInterface adjustedEquipment) { + this.sourceEquipment = adjustedEquipment; + } + + /** + *

+ * Setter for the field targetVariable. + *

+ * + * @param targetEquipment a + * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object + * @param targetVariable a {@link java.lang.String} object + * @param targetValue a double + * @param targetUnit a {@link java.lang.String} object + */ + public void setTargetVariable(ProcessEquipmentInterface targetEquipment, String targetVariable, + double targetValue, String targetUnit) { + this.targetEquipment = targetEquipment; + this.targetVariable = targetVariable; + this.targetValue = targetValue; + this.targetUnit = targetUnit; + } + + /** + *

+ * Setter for the field targetVariable. + *

+ * + * @param targetEquipment a + * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object + * @param targetVariable a {@link java.lang.String} object + */ + public void setTargetVariable(ProcessEquipmentInterface targetEquipment, String targetVariable) { + this.targetEquipment = targetEquipment; + this.targetVariable = targetVariable; + } + + /** + *

+ * Setter for the field targetVariable. + *

+ * + * @param targetEquipment a + * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object + * @param targetVariable a {@link java.lang.String} object + * @param targetValue a double + * @param targetUnit a {@link java.lang.String} object + * @param targetPhase a {@link java.lang.String} object + */ + public void setTargetVariable(ProcessEquipmentInterface targetEquipment, String targetVariable, + double targetValue, String targetUnit, String targetPhase) { + this.targetEquipment = targetEquipment; + this.targetVariable = targetVariable; + this.targetValue = targetValue; + this.targetUnit = targetUnit; + this.targetPhase = targetPhase; + } + + /** + *

+ * Setter for the field targetVariable. + *

+ * + * @param targetEquipment a + * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object + * @param targetVariable a {@link java.lang.String} object + * @param targetValue a double + * @param targetUnit a {@link java.lang.String} object + * @param targetPhase a {@link java.lang.String} object + * @param targetComponent a {@link java.lang.String} object + */ + public void setTargetVariable(ProcessEquipmentInterface targetEquipment, String targetVariable, + double targetValue, String targetUnit, String targetPhase, String targetComponent) { + this.targetEquipment = targetEquipment; + this.targetVariable = targetVariable; + this.targetValue = targetValue; + this.targetUnit = targetUnit; + this.targetPhase = targetPhase; + this.targetComponent = targetComponent; + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + if (targetVariable.equals("pressure")) { + targetEquipment.setPressure(sourceEquipment.getPressure()); + } else { + inputValue = ((Stream) sourceEquipment).getThermoSystem().getNumberOfMoles(); + + double targetValueCurrent = + ((Stream) targetEquipment).getThermoSystem().getVolume(targetUnit); + + double deviation = targetValue - targetValueCurrent; + + logger.info("adjuster deviation " + deviation + " inputValue " + inputValue); + + oldInputValue = inputValue; } + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() {} + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + // test code for adjuster... + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 20.00); + testSystem.addComponent("methane", 1000.00); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + + Stream stream_1 = new Stream("Stream1", testSystem); + SetPoint adjuster1 = new SetPoint(); + adjuster1.setSourceVariable(stream_1, "molarFlow"); + adjuster1.setTargetVariable(stream_1, "gasVolumeFlow", 10.0, "", "MSm3/day"); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(adjuster1); + + operations.run(); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/StreamSaturatorUtil.java b/src/main/java/neqsim/processSimulation/processEquipment/util/StreamSaturatorUtil.java index ddc8e6cfd3..914ac4c563 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/StreamSaturatorUtil.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/StreamSaturatorUtil.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.util; +import java.util.UUID; import neqsim.processSimulation.processEquipment.TwoPortEquipment; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; @@ -35,7 +36,7 @@ public StreamSaturatorUtil(StreamInterface inletStream) { /** * Constructor for StreamSaturatorUtil. - * + * * @param name name of unit opeation * @param inStream input stream */ @@ -61,7 +62,7 @@ public void setInletStream(StreamInterface inletStream) { /** {@inheritDoc} */ @Override - public void run() { + public void run(UUID id) { boolean changeBack = false; thermoSystem = inStream.getThermoSystem().clone(); if (multiPhase && !thermoSystem.doMultiPhaseCheck()) { @@ -75,6 +76,7 @@ public void run() { thermoSystem.setMultiPhaseCheck(false); } outStream.setThermoSystem(thermoSystem); + setCalculationIdentifier(id); } /** diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/StreamTransition.java b/src/main/java/neqsim/processSimulation/processEquipment/util/StreamTransition.java index f135fd68ad..e324fbe9a1 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/StreamTransition.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/StreamTransition.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.util; +import java.util.UUID; import neqsim.processSimulation.processEquipment.TwoPortEquipment; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.processSimulation.processSystem.ProcessSystem; @@ -60,7 +61,7 @@ public StreamTransition(String name, StreamInterface inletStream, StreamInterfac /** {@inheritDoc} */ @Override - public void run() { + public void run(UUID id) { SystemInterface outThermoSystem = null; if (outStream != null) { outThermoSystem = outStream.getFluid().clone(); @@ -82,7 +83,8 @@ public void run() { // fluid1.setTemperature(fluid2.getTemperature()); // fluid1.setPressure(fluid2.getPressure()); outStream.setThermoSystem(outThermoSystem); - outStream.run(); + outStream.run(id); + setCalculationIdentifier(id); } /** {@inheritDoc} */ diff --git a/src/main/java/neqsim/processSimulation/processEquipment/valve/ThrottlingValve.java b/src/main/java/neqsim/processSimulation/processEquipment/valve/ThrottlingValve.java index e3a0c71a9b..790f5d9cdc 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/valve/ThrottlingValve.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/valve/ThrottlingValve.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.valve; +import java.util.UUID; import neqsim.processSimulation.processEquipment.TwoPortEquipment; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.thermo.system.SystemInterface; @@ -17,7 +18,10 @@ public class ThrottlingValve extends TwoPortEquipment implements ValveInterface private static final long serialVersionUID = 1000; protected String name = new String(); - private boolean valveCvSet = false, isoThermal = false; + private boolean valveCvSet = false; + + private boolean isoThermal = false; + SystemInterface thermoSystem; double pressure = 0.0; private double Cv = 1.0; @@ -154,7 +158,7 @@ public void setOutletPressure(double pressure, String unit) { /** {@inheritDoc} */ @Override - public void run() { + public void run(UUID id) { // System.out.println("valve running.."); // outStream.setSpecification(inletStream.getSpecification()); thermoSystem = getInletStream().getThermoSystem().clone(); @@ -162,8 +166,9 @@ public void run() { thermoSystem.init(3); double enthalpy = thermoSystem.getEnthalpy(); if ((thermoSystem.getPressure(pressureUnit) - pressure) < 0) { - if (isAcceptNegativeDP()) + if (isAcceptNegativeDP()) { thermoSystem.setPressure(pressure, pressureUnit); + } } else { thermoSystem.setPressure(pressure, pressureUnit); } @@ -201,15 +206,17 @@ public void run() { inStream.getThermoSystem().setTotalNumberOfMoles(molarFlow); inStream.getThermoSystem().init(3); - // inletStream.run(); + // inletStream.run(id); outStream.setThermoSystem(thermoSystem.clone()); outStream.getThermoSystem().setTotalNumberOfMoles(molarFlow); outStream.getThermoSystem().init(3); - // outStream.run(); + // outStream.run(id); // Cv = // inletStream.getThermoSystem().getTotalNumberOfMoles()/Math.sqrt(inletStream.getPressure()-outStream.getPressure()); // molarFlow = inletStream.getThermoSystem().getTotalNumberOfMoles(); + outStream.setCalculationIdentifier(id); + setCalculationIdentifier(id); } /** {@inheritDoc} */ @@ -226,13 +233,14 @@ public String[][] getResultTable() { /** {@inheritDoc} */ @Override - public void runTransient(double dt) { + public void runTransient(double dt, UUID id) { if (getCalculateSteadyState()) { - run(); + run(id); + increaseTime(dt); return; } - runController(dt); + runController(dt, id); thermoSystem = inStream.getThermoSystem().clone(); ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem); @@ -263,11 +271,11 @@ public void runTransient(double dt) { inStream.getThermoSystem().setTotalNumberOfMoles(molarFlow); inStream.getThermoSystem().init(1); - inStream.run(); + inStream.run(id); outStream.getThermoSystem().setTotalNumberOfMoles(molarFlow); outStream.getThermoSystem().init(1); - outStream.run(); + outStream.run(id); // System.out.println("delta p valve " + // (inletStream.getThermoSystem().getPressure() - @@ -275,6 +283,7 @@ public void runTransient(double dt) { // System.out.println("total molar flow out " + molarFlow); // System.out.println("Total volume flow " + // outStream.getThermoSystem().getVolume()); + setCalculationIdentifier(id); } /** @@ -283,10 +292,11 @@ public void runTransient(double dt) { *

* * @param dt a double + * @param id Calculation identifier */ - public void runController(double dt) { + public void runController(double dt, UUID id) { if (hasController) { - getController().runTransient(this.percentValveOpening, dt); + getController().runTransient(this.percentValveOpening, dt, id); this.percentValveOpening = getController().getResponse(); if (this.percentValveOpening > 100) { this.percentValveOpening = 100; @@ -296,6 +306,7 @@ public void runController(double dt) { } // System.out.println("valve opening " + this.percentValveOpening + " %"); } + setCalculationIdentifier(id); } /** {@inheritDoc} */ @@ -306,8 +317,8 @@ public double getCv() { /** {@inheritDoc} */ @Override - public void setCv(double Cv) { - this.Cv = Cv; + public void setCv(double cv) { + this.Cv = cv; valveCvSet = true; } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/valve/ValveInterface.java b/src/main/java/neqsim/processSimulation/processEquipment/valve/ValveInterface.java index b2a6b8e42e..a3b62a3f4c 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/valve/ValveInterface.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/valve/ValveInterface.java @@ -72,7 +72,6 @@ public interface ValveInterface extends ProcessEquipmentInterface, TwoPortInterf */ public void setCv(double Cv); - /** {@inheritDoc} */ @Override public SystemInterface getThermoSystem(); diff --git a/src/main/java/neqsim/processSimulation/processSystem/ModuleInterface.java b/src/main/java/neqsim/processSimulation/processSystem/ModuleInterface.java index 90f6b9b0c2..86e071bccb 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/ModuleInterface.java +++ b/src/main/java/neqsim/processSimulation/processSystem/ModuleInterface.java @@ -65,7 +65,6 @@ public interface ModuleInterface extends ProcessEquipmentInterface { */ public void setPreferedThermodynamicModel(String preferedThermodynamicModel); - /** *

* initializeStreams. diff --git a/src/main/java/neqsim/processSimulation/processSystem/ProcessModuleBaseClass.java b/src/main/java/neqsim/processSimulation/processSystem/ProcessModuleBaseClass.java index ca3360a858..8fd5d4ac22 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/ProcessModuleBaseClass.java +++ b/src/main/java/neqsim/processSimulation/processSystem/ProcessModuleBaseClass.java @@ -5,6 +5,7 @@ */ package neqsim.processSimulation.processSystem; +import java.util.UUID; import neqsim.processSimulation.SimulationBaseClass; import neqsim.processSimulation.controllerDevice.ControllerDeviceInterface; import neqsim.processSimulation.mechanicalDesign.MechanicalDesign; @@ -111,8 +112,8 @@ public neqsim.processSimulation.processSystem.ProcessSystem getOperations() { /** {@inheritDoc} */ @Override - public void runTransient(double dt) { - getOperations().runTransient(dt); + public void runTransient(double dt, UUID id) { + getOperations().runTransient(dt, id); } // TODO: Check if all the equipment is solved correctly @@ -128,6 +129,12 @@ public SystemInterface getThermoSystem() { return null; } + /** {@inheritDoc} */ + @Override + public String getSpecification() { + return null; + } + /** *

* setSpecification. @@ -138,12 +145,6 @@ public SystemInterface getThermoSystem() { */ public void setSpecification(String specificationName, double value) {} - /** {@inheritDoc} */ - @Override - public String getSpecification() { - return null; - } - /** {@inheritDoc} */ @Override public void setSpecification(String specification) {} diff --git a/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java b/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java index bfa98b1a47..ff14811b2c 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java +++ b/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java @@ -7,6 +7,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Objects; +import java.util.UUID; import org.apache.commons.lang.SerializationUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -30,920 +31,923 @@ * @version $Id: $Id */ public class ProcessSystem extends SimulationBaseClass { - private static final long serialVersionUID = 1000; - - transient Thread thisThread; - String[][] signalDB = new String[1000][100]; - private double time = 0; - private double surroundingTemperature = 288.15; - private int timeStepNumber = 0; - private ArrayList unitOperations = - new ArrayList(0); - ArrayList measurementDevices = - new ArrayList(0); - RecycleController recycleController = new RecycleController(); - private double timeStep = 1.0; - static Logger logger = LogManager.getLogger(ProcessSystem.class); - - /** - *

- * Constructor for ProcessSystem. - *

- */ - public ProcessSystem() { - this("Process system"); - } - - /** - * Constructor for ProcessSystem. - * - * @param name name of process - */ - public ProcessSystem(String name) { - super(name); - } - - /** - *

- * add. - *

- * - * @param operation a - * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object - */ - public void add(ProcessEquipmentInterface operation) { - ArrayList units = this.getUnitOperations(); - - for (ProcessEquipmentInterface unit : units) { - if (unit == operation) { - return; - } - } - - if (getAllUnitNames().contains(operation.getName())) { - String currClass = operation.getClass().getSimpleName(); - int num = 1; - for (ProcessEquipmentInterface unit : units) { - if (unit.getClass().getSimpleName().equals(currClass)) { - num++; - } - } - operation.setName(currClass + Integer.toString(num)); - } - - getUnitOperations().add(operation); - if (operation instanceof ModuleInterface) { - ((ModuleInterface) operation).initializeModule(); - } - } - - /** - *

- * add. - *

- * - * @param measurementDevice a - * {@link neqsim.processSimulation.measurementDevice.MeasurementDeviceInterface} object - */ - public void add(MeasurementDeviceInterface measurementDevice) { - measurementDevices.add(measurementDevice); - } - - /** - *

- * add. - *

- * - * @param operations an array of - * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} objects - */ - public void add(ProcessEquipmentInterface[] operations) { - getUnitOperations().addAll(Arrays.asList(operations)); - } - - /** - *

- * getUnit. - *

- * - * @param name a {@link java.lang.String} object - * @return a {@link java.lang.Object} object - */ - public Object getUnit(String name) { - for (int i = 0; i < getUnitOperations().size(); i++) { - if (getUnitOperations().get(i) instanceof ModuleInterface) { - for (int j = 0; j < ((ModuleInterface) getUnitOperations().get(i)).getOperations() - .getUnitOperations().size(); j++) { - if (((ModuleInterface) getUnitOperations().get(i)).getOperations() - .getUnitOperations().get(j).getName().equals(name)) { - return ((ModuleInterface) getUnitOperations().get(i)).getOperations() - .getUnitOperations().get(j); - } - } - } else if (getUnitOperations().get(i).getName().equals(name)) { - return getUnitOperations().get(i); - } - } - return null; - } - - /** - *

- * hasUnitName. - *

- * - * @param name a {@link java.lang.String} object - * @return a boolean - */ - public boolean hasUnitName(String name) { - if (getUnit(name) == null) { - return false; - } else { - return true; - } - } - - /** - *

- * getMeasurementDevice. - *

- * - * @param name a {@link java.lang.String} object - * @return a {@link java.lang.Object} object - */ - public Object getMeasurementDevice(String name) { - for (int i = 0; i < measurementDevices.size(); i++) { - if (measurementDevices.get(i).getName().equals(name)) { - return measurementDevices.get(i); - } - } - return null; - } - - /** - *

- * getUnitNumber. - *

- * - * @param name a {@link java.lang.String} object - * @return a int - */ - public int getUnitNumber(String name) { - for (int i = 0; i < getUnitOperations().size(); i++) { - if (getUnitOperations().get(i) instanceof ModuleInterface) { - for (int j = 0; j < ((ModuleInterface) getUnitOperations().get(i)).getOperations() - .getUnitOperations().size(); j++) { - if (((ModuleInterface) getUnitOperations().get(i)).getOperations() - .getUnitOperations().get(j).getName().equals(name)) { - return j; - } - } - } else if (getUnitOperations().get(i).getName().equals(name)) { - return i; - } + private static final long serialVersionUID = 1000; + + transient Thread thisThread; + String[][] signalDB = new String[1000][100]; + private double surroundingTemperature = 288.15; + private int timeStepNumber = 0; + private ArrayList unitOperations = + new ArrayList(0); + ArrayList measurementDevices = + new ArrayList(0); + RecycleController recycleController = new RecycleController(); + private double timeStep = 1.0; + static Logger logger = LogManager.getLogger(ProcessSystem.class); + + /** + *

+ * Constructor for ProcessSystem. + *

+ */ + public ProcessSystem() { + this("Process system"); + } + + /** + * Constructor for ProcessSystem. + * + * @param name name of process + */ + public ProcessSystem(String name) { + super(name); + } + + /** + *

+ * add. + *

+ * + * @param operation a {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} + * object + */ + public void add(ProcessEquipmentInterface operation) { + ArrayList units = this.getUnitOperations(); + + for (ProcessEquipmentInterface unit : units) { + if (unit == operation) { + return; + } + } + + if (getAllUnitNames().contains(operation.getName())) { + String currClass = operation.getClass().getSimpleName(); + int num = 1; + for (ProcessEquipmentInterface unit : units) { + if (unit.getClass().getSimpleName().equals(currClass)) { + num++; } - return 0; - } - - /** - *

- * replaceObject. - *

- * - * @param unitName a {@link java.lang.String} object - * @param operation a - * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass} object - */ - public void replaceObject(String unitName, ProcessEquipmentBaseClass operation) { - unitOperations.set(getUnitNumber(name), operation); - } - - /** - *

- * getAllUnitNames. - *

- * - * @return a {@link java.util.ArrayList} object - */ - public ArrayList getAllUnitNames() { - ArrayList unitNames = new ArrayList(); - for (int i = 0; i < getUnitOperations().size(); i++) { - if (getUnitOperations().get(i) instanceof ModuleInterface) { - for (int j = 0; j < ((ModuleInterface) getUnitOperations().get(i)).getOperations() - .getUnitOperations().size(); j++) { - unitNames.add(((ModuleInterface) getUnitOperations().get(i)).getOperations() - .getUnitOperations().get(j).getName()); - } - } - unitNames.add(unitOperations.get(i).getName()); - } - return unitNames; - } - - /** - *

- * Getter for the field unitOperations. - *

- * - * @return the unitOperations - */ - public ArrayList getUnitOperations() { - return unitOperations; - } - - /** - *

- * removeUnit. - *

- * - * @param name a {@link java.lang.String} object - */ - public void removeUnit(String name) { - for (int i = 0; i < unitOperations.size(); i++) { - if (unitOperations.get(i).getName().equals(name)) { - unitOperations.remove(i); - } - } - } - - /** - *

- * clearAll. - *

- */ - public void clearAll() { - unitOperations = new ArrayList(0); - } - - /** - *

- * clear. - *

- */ - public void clear() { - unitOperations = new ArrayList(0); - } - - /** - *

- * setFluid. - *

- * - * @param fluid1 a {@link neqsim.thermo.system.SystemInterface} object - * @param fluid2 a {@link neqsim.thermo.system.SystemInterface} object - * @param addNewComponents a boolean - */ - public void setFluid(SystemInterface fluid1, SystemInterface fluid2, boolean addNewComponents) { - fluid1.setEmptyFluid(); - boolean addedComps = false; - for (int i = 0; i < fluid2.getNumberOfComponents(); i++) { - if (fluid1.getPhase(0).hasComponent(fluid2.getComponent(i).getName())) { - fluid1.addComponent(fluid2.getComponent(i).getName(), - fluid2.getComponent(i).getNumberOfmoles()); - } else { - if (addNewComponents) { - addedComps = true; - if (fluid2.getComponent(i).isIsTBPfraction() - || fluid2.getComponent(i).isIsPlusFraction()) { - fluid1.addTBPfraction(fluid2.getComponent(i).getName(), - fluid2.getComponent(i).getNumberOfmoles(), - fluid2.getComponent(i).getMolarMass(), - fluid2.getComponent(i).getNormalLiquidDensity()); - } else { - fluid1.addComponent(fluid2.getComponent(i).getName(), - fluid2.getComponent(i).getNumberOfmoles()); - } - } - } - } - if (addedComps) { - fluid1.createDatabase(true); - } - fluid1.init(0); - fluid1.setTemperature(fluid2.getTemperature()); - fluid1.setPressure(fluid2.getPressure()); - } - - /** - *

- * setFluid. - *

- * - * @param fluid1 a {@link neqsim.thermo.system.SystemInterface} object - * @param fluid2 a {@link neqsim.thermo.system.SystemInterface} object - */ - public void setFluid(SystemInterface fluid1, SystemInterface fluid2) { - fluid1.setEmptyFluid(); - boolean addedComps = false; - for (int i = 0; i < fluid2.getNumberOfComponents(); i++) { - if (fluid1.getPhase(0).hasComponent(fluid2.getComponent(i).getName())) { - fluid1.addComponent(fluid2.getComponent(i).getName(), - fluid2.getComponent(i).getNumberOfmoles()); - } else { - addedComps = true; - if (fluid2.getComponent(i).isIsTBPfraction() - || fluid2.getComponent(i).isIsPlusFraction()) { - fluid1.addTBPfraction(fluid2.getComponent(i).getName(), - fluid2.getComponent(i).getNumberOfmoles(), - fluid2.getComponent(i).getMolarMass(), - fluid2.getComponent(i).getNormalLiquidDensity()); - } else { - fluid1.addComponent(fluid2.getComponent(i).getName(), - fluid2.getComponent(i).getNumberOfmoles()); - } - } - } - if (addedComps) { - fluid1.createDatabase(true); - } - fluid1.init(0); - fluid1.setTemperature(fluid2.getTemperature()); - fluid1.setPressure(fluid2.getPressure()); - } - - /** - *

- * runAsThread. - *

- * - * @return a {@link java.lang.Thread} object - */ - public Thread runAsThread() { - Thread processThread = new Thread(this); - processThread.start(); - return processThread; - } - - /** {@inheritDoc} */ - @Override - public void run() { - boolean isConverged = true; - boolean hasResycle = false; - // boolean hasAdjuster = false; - int iter = 0; - - // Initializing recycle controller - recycleController.clear(); - for (int i = 0; i < unitOperations.size(); i++) { - if (unitOperations.get(i).getClass().getSimpleName().equals("Recycle")) { - hasResycle = true; - recycleController.addRecycle((Recycle) unitOperations.get(i)); - } - if (unitOperations.get(i).getClass().getSimpleName().equals("Adjuster")) { - // hasAdjuster = true; - } - } - recycleController.init(); - - do { - iter++; - isConverged = true; - for (int i = 0; i < unitOperations.size(); i++) { - if (!unitOperations.get(i).getClass().getSimpleName().equals("Recycle")) - try { - ((Runnable) unitOperations.get(i)).run(); - } catch (Exception e) { - // String error = e.getMessage(); - e.printStackTrace(); - } - if (unitOperations.get(i).getClass().getSimpleName().equals("Recycle") - && recycleController.doSolveRecycle((Recycle) unitOperations.get(i))) { - try { - ((Runnable) unitOperations.get(i)).run(); - } catch (Exception e) { - // String error = e.getMessage(); - e.printStackTrace(); - } - } - } - if (!recycleController.solvedAll() || recycleController.hasHigherPriorityLevel()) { - isConverged = false; - } - if (recycleController.solvedCurrentPriorityLevel()) { - recycleController.nextPriorityLevel(); - } else if (recycleController.hasLoverPriorityLevel() - && !recycleController.solvedAll()) { - recycleController.resetPriorityLevel(); - // isConverged=true; - } - - for (int i = 0; i < unitOperations.size(); i++) { - if (unitOperations.get(i).getClass().getSimpleName().equals("Adjuster")) { - if (!((neqsim.processSimulation.processEquipment.util.Adjuster) unitOperations - .get(i)).solved()) { - isConverged = false; - } - } - } - - /* - * signalDB = new String[1000][1 + 3 * measurementDevices.size()]; - * - * signalDB[timeStepNumber] = new String[1 + 3 * measurementDevices.size()]; for (int i - * = 0; i < measurementDevices.size(); i++) { signalDB[timeStepNumber][0] = - * Double.toString(time); signalDB[timeStepNumber][3 * i + 1] = - * ((MeasurementDeviceInterface) measurementDevices.get(i)) .getName(); - * signalDB[timeStepNumber][3 * i + 2] = Double .toString(((MeasurementDeviceInterface) - * measurementDevices.get(i)).getMeasuredValue()); signalDB[timeStepNumber][3 * i + 3] = - * ((MeasurementDeviceInterface) measurementDevices.get(i)) .getUnit(); - * - * } - */ - } while ((!isConverged || (iter < 2 && hasResycle)) && iter < 100); - - for (int i = 0; i < unitOperations.size(); i++) { - if (unitOperations.get(i).getClass().getSimpleName().equals("Adjuster")) { - if (!((neqsim.processSimulation.processEquipment.util.Adjuster) unitOperations - .get(i)).solved()) { - isConverged = false; - } - } - } - } - - /** - *

- * runTransient. - *

- * - * @param dt differential temperature - */ - @Override - public void runTransient(double dt) { - setTimeStep(dt); - time += dt; - - for (int i = 0; i < unitOperations.size(); i++) { - unitOperations.get(i).runTransient(dt); - } - timeStepNumber++; - signalDB[timeStepNumber] = new String[1 + 3 * measurementDevices.size()]; - for (int i = 0; i < measurementDevices.size(); i++) { - signalDB[timeStepNumber][0] = Double.toString(time); - signalDB[timeStepNumber][3 * i + 1] = measurementDevices.get(i).getName(); - signalDB[timeStepNumber][3 * i + 2] = - Double.toString(measurementDevices.get(i).getMeasuredValue()); - signalDB[timeStepNumber][3 * i + 3] = measurementDevices.get(i).getUnit(); - } - } - - @Override - public boolean solved() { - return true; - } - - /** - *

- * Getter for the field time. - *

- * - * @return a double - */ - public double getTime() { - return time; - } - - /** - *

- * Getter for the field time. - *

- * - * @param unit a {@link java.lang.String} object - * @return a double - */ - public double getTime(String unit) { - if (unit.equals("sec")) { - return time; - } else if (unit.equals("hr")) { - return time / 3600.0; - } else if (unit.equals("day")) { - return time / (3600.0 * 24); - } else if (unit.equals("year")) { - return time / (3600.0 * 24 * 365); + } + operation.setName(currClass + Integer.toString(num)); + } + + getUnitOperations().add(operation); + if (operation instanceof ModuleInterface) { + ((ModuleInterface) operation).initializeModule(); + } + } + + /** + *

+ * add. + *

+ * + * @param measurementDevice a + * {@link neqsim.processSimulation.measurementDevice.MeasurementDeviceInterface} object + */ + public void add(MeasurementDeviceInterface measurementDevice) { + measurementDevices.add(measurementDevice); + } + + /** + *

+ * add. + *

+ * + * @param operations an array of + * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} objects + */ + public void add(ProcessEquipmentInterface[] operations) { + getUnitOperations().addAll(Arrays.asList(operations)); + } + + /** + *

+ * getUnit. + *

+ * + * @param name a {@link java.lang.String} object + * @return a {@link java.lang.Object} object + */ + public Object getUnit(String name) { + for (int i = 0; i < getUnitOperations().size(); i++) { + if (getUnitOperations().get(i) instanceof ModuleInterface) { + for (int j = 0; j < ((ModuleInterface) getUnitOperations().get(i)).getOperations() + .getUnitOperations().size(); j++) { + if (((ModuleInterface) getUnitOperations().get(i)).getOperations().getUnitOperations() + .get(j).getName().equals(name)) { + return ((ModuleInterface) getUnitOperations().get(i)).getOperations() + .getUnitOperations().get(j); + } } - return time; - } - - /** - *

- * runTransient. - *

- */ - public void runTransient() { - runTransient(getTimeStep()); - } - - /** - *

- * size. - *

- * - * @return a int - */ - public int size() { - return unitOperations.size(); - } - - /** - *

- * view. - *

- */ - public void view() { - this.displayResult(); - } - - /** - *

- * displayResult. - *

- */ - public void displayResult() { - try { - thisThread.join(); - } catch (Exception e) { - System.out.println("Thread did not finish"); + } else if (getUnitOperations().get(i).getName().equals(name)) { + return getUnitOperations().get(i); + } + } + return null; + } + + /** + *

+ * hasUnitName. + *

+ * + * @param name a {@link java.lang.String} object + * @return a boolean + */ + public boolean hasUnitName(String name) { + if (getUnit(name) == null) { + return false; + } else { + return true; + } + } + + /** + *

+ * getMeasurementDevice. + *

+ * + * @param name a {@link java.lang.String} object + * @return a {@link java.lang.Object} object + */ + public Object getMeasurementDevice(String name) { + for (int i = 0; i < measurementDevices.size(); i++) { + if (measurementDevices.get(i).getName().equals(name)) { + return measurementDevices.get(i); + } + } + return null; + } + + /** + *

+ * getUnitNumber. + *

+ * + * @param name a {@link java.lang.String} object + * @return a int + */ + public int getUnitNumber(String name) { + for (int i = 0; i < getUnitOperations().size(); i++) { + if (getUnitOperations().get(i) instanceof ModuleInterface) { + for (int j = 0; j < ((ModuleInterface) getUnitOperations().get(i)).getOperations() + .getUnitOperations().size(); j++) { + if (((ModuleInterface) getUnitOperations().get(i)).getOperations().getUnitOperations() + .get(j).getName().equals(name)) { + return j; + } } - for (int i = 0; i < unitOperations.size(); i++) { - unitOperations.get(i).displayResult(); + } else if (getUnitOperations().get(i).getName().equals(name)) { + return i; + } + } + return 0; + } + + /** + *

+ * replaceObject. + *

+ * + * @param unitName a {@link java.lang.String} object + * @param operation a {@link neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass} + * object + */ + public void replaceObject(String unitName, ProcessEquipmentBaseClass operation) { + unitOperations.set(getUnitNumber(name), operation); + } + + /** + *

+ * getAllUnitNames. + *

+ * + * @return a {@link java.util.ArrayList} object + */ + public ArrayList getAllUnitNames() { + ArrayList unitNames = new ArrayList(); + for (int i = 0; i < getUnitOperations().size(); i++) { + if (getUnitOperations().get(i) instanceof ModuleInterface) { + for (int j = 0; j < ((ModuleInterface) getUnitOperations().get(i)).getOperations() + .getUnitOperations().size(); j++) { + unitNames.add(((ModuleInterface) getUnitOperations().get(i)).getOperations() + .getUnitOperations().get(j).getName()); } - - /* - * JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - * frame.setLayout(new GridLayout(1, 0, 5, 5)); JTextArea area1 = new JTextArea(10, 10); - * JTable Jtab = new JTable(reportResults(), reportResults()[0]); frame.add(area1); - * frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); - */ - } - - /** - *

- * reportMeasuredValues. - *

- */ - public void reportMeasuredValues() { - try { - thisThread.join(); - } catch (Exception e) { - System.out.println("Thread did not finish"); + } + unitNames.add(unitOperations.get(i).getName()); + } + return unitNames; + } + + /** + *

+ * Getter for the field unitOperations. + *

+ * + * @return the unitOperations + */ + public ArrayList getUnitOperations() { + return unitOperations; + } + + /** + *

+ * removeUnit. + *

+ * + * @param name a {@link java.lang.String} object + */ + public void removeUnit(String name) { + for (int i = 0; i < unitOperations.size(); i++) { + if (unitOperations.get(i).getName().equals(name)) { + unitOperations.remove(i); + } + } + } + + /** + *

+ * clearAll. + *

+ */ + public void clearAll() { + unitOperations = new ArrayList(0); + } + + /** + *

+ * clear. + *

+ */ + public void clear() { + unitOperations = new ArrayList(0); + } + + /** + *

+ * setFluid. + *

+ * + * @param fluid1 a {@link neqsim.thermo.system.SystemInterface} object + * @param fluid2 a {@link neqsim.thermo.system.SystemInterface} object + * @param addNewComponents a boolean + */ + public void setFluid(SystemInterface fluid1, SystemInterface fluid2, boolean addNewComponents) { + fluid1.setEmptyFluid(); + boolean addedComps = false; + for (int i = 0; i < fluid2.getNumberOfComponents(); i++) { + if (fluid1.getPhase(0).hasComponent(fluid2.getComponent(i).getName())) { + fluid1.addComponent(fluid2.getComponent(i).getName(), + fluid2.getComponent(i).getNumberOfmoles()); + } else { + if (addNewComponents) { + addedComps = true; + if (fluid2.getComponent(i).isIsTBPfraction() + || fluid2.getComponent(i).isIsPlusFraction()) { + fluid1.addTBPfraction(fluid2.getComponent(i).getName(), + fluid2.getComponent(i).getNumberOfmoles(), fluid2.getComponent(i).getMolarMass(), + fluid2.getComponent(i).getNormalLiquidDensity()); + } else { + fluid1.addComponent(fluid2.getComponent(i).getName(), + fluid2.getComponent(i).getNumberOfmoles()); + } } - for (int i = 0; i < measurementDevices.size(); i++) { - System.out.println("Measurements Device Name: " + measurementDevices.get(i).getName()); - System.out.println("Value: " + measurementDevices.get(i).getMeasuredValue() + " " - + measurementDevices.get(i).getUnit()); - if (measurementDevices.get(i).isOnlineSignal()) - System.out.println( - "Online value: " + measurementDevices.get(i).getOnlineSignal().getValue() - + " " + measurementDevices.get(i).getOnlineSignal().getUnit()); + } + } + if (addedComps) { + fluid1.createDatabase(true); + } + fluid1.init(0); + fluid1.setTemperature(fluid2.getTemperature()); + fluid1.setPressure(fluid2.getPressure()); + } + + /** + *

+ * setFluid. + *

+ * + * @param fluid1 a {@link neqsim.thermo.system.SystemInterface} object + * @param fluid2 a {@link neqsim.thermo.system.SystemInterface} object + */ + public void setFluid(SystemInterface fluid1, SystemInterface fluid2) { + fluid1.setEmptyFluid(); + boolean addedComps = false; + for (int i = 0; i < fluid2.getNumberOfComponents(); i++) { + if (fluid1.getPhase(0).hasComponent(fluid2.getComponent(i).getName())) { + fluid1.addComponent(fluid2.getComponent(i).getName(), + fluid2.getComponent(i).getNumberOfmoles()); + } else { + addedComps = true; + if (fluid2.getComponent(i).isIsTBPfraction() || fluid2.getComponent(i).isIsPlusFraction()) { + fluid1.addTBPfraction(fluid2.getComponent(i).getName(), + fluid2.getComponent(i).getNumberOfmoles(), fluid2.getComponent(i).getMolarMass(), + fluid2.getComponent(i).getNormalLiquidDensity()); + } else { + fluid1.addComponent(fluid2.getComponent(i).getName(), + fluid2.getComponent(i).getNumberOfmoles()); } - } - - /** - *

- * save. - *

- * - * @param filePath a {@link java.lang.String} object - */ - public void save(String filePath) { - try (ObjectOutputStream out = - new ObjectOutputStream(new FileOutputStream(filePath, false))) { - out.writeObject(this); - logger.info("process file saved to: " + filePath); - } catch (Exception e) { - logger.error(e.toString()); + } + } + if (addedComps) { + fluid1.createDatabase(true); + } + fluid1.init(0); + fluid1.setTemperature(fluid2.getTemperature()); + fluid1.setPressure(fluid2.getPressure()); + } + + /** + *

+ * runAsThread. + *

+ * + * @return a {@link java.lang.Thread} object + */ + public Thread runAsThread() { + Thread processThread = new Thread(this); + processThread.start(); + return processThread; + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + boolean hasResycle = false; + // boolean hasAdjuster = false; + + // Initializing recycle controller + recycleController.clear(); + for (int i = 0; i < unitOperations.size(); i++) { + if (unitOperations.get(i).getClass().getSimpleName().equals("Recycle")) { + hasResycle = true; + recycleController.addRecycle((Recycle) unitOperations.get(i)); + } + if (unitOperations.get(i).getClass().getSimpleName().equals("Adjuster")) { + // hasAdjuster = true; + } + } + recycleController.init(); + + boolean isConverged = true; + int iter = 0; + do { + iter++; + isConverged = true; + for (int i = 0; i < unitOperations.size(); i++) { + if (!unitOperations.get(i).getClass().getSimpleName().equals("Recycle")) { + try { + ((ProcessEquipmentInterface) unitOperations.get(i)).run(); + } catch (Exception e) { + // String error = e.getMessage(); e.printStackTrace(); + } } - } - - /** - *

- * open. - *

- * - * @param filePath a {@link java.lang.String} object - * @return a {@link neqsim.processSimulation.processSystem.ProcessSystem} object - */ - public static ProcessSystem open(String filePath) { - try (ObjectInputStream objectinputstream = - new ObjectInputStream(new FileInputStream(filePath))) { - return (ProcessSystem) objectinputstream.readObject(); - // logger.info("process file open ok: " + filePath); - } catch (Exception e) { - // logger.error(e.toString()); + if (unitOperations.get(i).getClass().getSimpleName().equals("Recycle") + && recycleController.doSolveRecycle((Recycle) unitOperations.get(i))) { + try { + ((ProcessEquipmentInterface) unitOperations.get(i)).run(); + } catch (Exception e) { + // String error = e.getMessage(); e.printStackTrace(); + } } - return null; - } - - /** - *

- * reportResults. - *

- * - * @return an array of {@link java.lang.String} objects - */ - public String[][] reportResults() { - String[][] text = new String[200][]; - - int numb = 0; - for (int i = 0; i < unitOperations.size(); i++) { - for (int k = 0; k < unitOperations.get(i).reportResults().length; k++) { - text[numb++] = unitOperations.get(i).reportResults()[k]; - } + } + if (!recycleController.solvedAll() || recycleController.hasHigherPriorityLevel()) { + isConverged = false; + } + + if (recycleController.solvedCurrentPriorityLevel()) { + recycleController.nextPriorityLevel(); + } else if (recycleController.hasLoverPriorityLevel() && !recycleController.solvedAll()) { + recycleController.resetPriorityLevel(); + // isConverged=true; + } + + for (int i = 0; i < unitOperations.size(); i++) { + if (unitOperations.get(i).getClass().getSimpleName().equals("Adjuster")) { + if (!((neqsim.processSimulation.processEquipment.util.Adjuster) unitOperations.get(i)) + .solved()) { + isConverged = false; + break; + } } - return text; - } - - /** - *

- * printLogFile. - *

- * - * @param filename a {@link java.lang.String} object - */ - public void printLogFile(String filename) { - neqsim.dataPresentation.fileHandeling.createTextFile.TextFile tempFile = - new neqsim.dataPresentation.fileHandeling.createTextFile.TextFile(); - tempFile.setOutputFileName(filename); - tempFile.setValues(signalDB); - tempFile.createFile(); - } - - /** - *

- * Getter for the field timeStep. - *

- * - * @return a double - */ - public double getTimeStep() { - return timeStep; - } - - /** - *

- * Setter for the field timeStep. - *

- * - * @param timeStep a double - */ - public void setTimeStep(double timeStep) { - this.timeStep = timeStep; - } - - /** - *

- * Getter for the field name. - *

- * - * @return the name - */ - public String getName() { - return name; - } - - /** - *

- * Setter for the field name. - *

- * - * @param name the name to set - */ - public void setName(String name) { - this.name = name; - } - - /** - *

- * Get a SystemMechanicalDesign object from processSystem. - *

- * - * @return a new SystemMechanicalDesign object - */ - public SystemMechanicalDesign getSystemMechanicalDesign() { - return new SystemMechanicalDesign(this); - } - - /** - *

- * Get a CostEstimateBaseClass object from processSystem. - *

- * - * @return a new CostEstimateBaseClass object - */ - public CostEstimateBaseClass getCostEstimator() { - return new CostEstimateBaseClass(this); - } - - /** - *

- * getEntropyProduction. - *

- * - * @param unit a {@link java.lang.String} object - * @return a double - */ - public double getEntropyProduction(String unit) { - double entropyProduction = 0.0; - for (int i = 0; i < unitOperations.size(); i++) { - entropyProduction += unitOperations.get(i).getEntropyProduction(unit); - System.out.println("unit " + unitOperations.get(i).getName() + " entropy production " - + unitOperations.get(i).getEntropyProduction(unit)); - } - return entropyProduction; - } - - /** - *

- * getExergyChange. - *

- * - * @param unit a {@link java.lang.String} object - * @return a double - */ - public double getExergyChange(String unit) { - double exergyChange = 0.0; - for (int i = 0; i < unitOperations.size(); i++) { - exergyChange += unitOperations.get(i).getExergyChange("J", getSurroundingTemperature()); - System.out.println("unit " + unitOperations.get(i).getName() + " exergy change " - + unitOperations.get(i).getExergyChange("J", getSurroundingTemperature())); - } - return exergyChange; - } - - /** - *

- * getPower. - *

- * - * @param unit a {@link java.lang.String} object - * @return a double - */ - public double getPower(String unit) { - double power = 0.0; - for (int i = 0; i < unitOperations.size(); i++) { - if (unitOperations.get(i).getClass().getSimpleName().equals("Compressor")) { - power += ((neqsim.processSimulation.processEquipment.compressor.Compressor) unitOperations - .get(i)).getPower(); - } else if (unitOperations.get(i).getClass().getSimpleName().equals("Pump")) { - power += ((neqsim.processSimulation.processEquipment.pump.Pump) unitOperations - .get(i)).getPower(); - } - } - if (unit.equals("MW")) { - return power / 1.0e6; - } else if (unit.equals("kW")) { - return power / 1.0e3; - } else - return power; - } - - /** - *

- * getCoolerDuty. - *

- * - * @param unit a {@link java.lang.String} object - * @return a double - */ - public double getCoolerDuty(String unit) { - double heat = 0.0; - for (int i = 0; i < unitOperations.size(); i++) { - if (unitOperations.get(i).getClass().getSimpleName().equals("Cooler")) { - heat += ((neqsim.processSimulation.processEquipment.heatExchanger.Cooler) unitOperations - .get(i)).getDuty(); - } - } - return heat; - } - - /** - *

- * getHeaterDuty. - *

- * - * @param unit a {@link java.lang.String} object - * @return a double - */ - public double getHeaterDuty(String unit) { - double heat = 0.0; - for (int i = 0; i < unitOperations.size(); i++) { - if (unitOperations.get(i).getClass().getSimpleName().equals("Heater")) { - heat += ((neqsim.processSimulation.processEquipment.heatExchanger.Heater) unitOperations - .get(i)).getDuty(); - } - } - return heat; - } - - /** - *

- * getMechanicalWeight. - *

- * - * @param unit a {@link java.lang.String} object - * @return a double - */ - public double getMechanicalWeight(String unit) { - double weight = 0.0; - for (int i = 0; i < unitOperations.size(); i++) { - unitOperations.get(i).getMechanicalDesign().calcDesign(); - System.out.println("Name " + unitOperations.get(i).getName() + " weight " - + unitOperations.get(i).getMechanicalDesign().getWeightTotal()); - weight += unitOperations.get(i).getMechanicalDesign().getWeightTotal(); - } - return weight; - } - - /** - *

- * Getter for the field surroundingTemperature. - *

- * - * @return a double - */ - public double getSurroundingTemperature() { - return surroundingTemperature; - } - - /** - *

- * Setter for the field surroundingTemperature. - *

- * - * @param surroundingTemperature a double - */ - public void setSurroundingTemperature(double surroundingTemperature) { - this.surroundingTemperature = surroundingTemperature; - } - - /** - *

- * Create deep copy. - *

- * - * @return a {@link neqsim.processSimulation.processSystem.ProcessSystem} object - */ - public ProcessSystem copy() { - byte[] bytes = SerializationUtils.serialize(this); - ProcessSystem copyOperation = (ProcessSystem) SerializationUtils.deserialize(bytes); - return copyOperation; - } - - /** - *

- * getConditionMonitor. - *

- * - * @return a {@link neqsim.processSimulation.conditionMonitor.ConditionMonitor} object - */ - public ConditionMonitor getConditionMonitor() { - return new ConditionMonitor(this); - } - - /** {@inheritDoc} */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Arrays.deepHashCode(signalDB); - result = prime * result + Objects.hash(measurementDevices, name, recycleController, - surroundingTemperature, time, timeStep, timeStepNumber, unitOperations); - return result; - } - - /** {@inheritDoc} */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ProcessSystem other = (ProcessSystem) obj; - return Objects.equals(measurementDevices, other.measurementDevices) - && Objects.equals(name, other.name) - && Objects.equals(recycleController, other.recycleController) - && Arrays.deepEquals(signalDB, other.signalDB) - && Double.doubleToLongBits(surroundingTemperature) == Double - .doubleToLongBits(other.surroundingTemperature) - && Double.doubleToLongBits(time) == Double.doubleToLongBits(other.time) - && Double.doubleToLongBits(timeStep) == Double.doubleToLongBits(other.timeStep) - && timeStepNumber == other.timeStepNumber - && Objects.equals(unitOperations, other.unitOperations); + } + + /* + * signalDB = new String[1000][1 + 3 * measurementDevices.size()]; + * + * signalDB[timeStepNumber] = new String[1 + 3 * measurementDevices.size()]; for (int i = 0; i + * < measurementDevices.size(); i++) { signalDB[timeStepNumber][0] = Double.toString(time); + * signalDB[timeStepNumber][3 * i + 1] = ((MeasurementDeviceInterface) + * measurementDevices.get(i)) .getName(); signalDB[timeStepNumber][3 * i + 2] = Double + * .toString(((MeasurementDeviceInterface) measurementDevices.get(i)).getMeasuredValue()); + * signalDB[timeStepNumber][3 * i + 3] = ((MeasurementDeviceInterface) + * measurementDevices.get(i)) .getUnit(); + * + * } + */ + } while ((!isConverged || (iter < 2 && hasResycle)) && iter < 100); + + for (int i = 0; i < unitOperations.size(); i++) { + ((ProcessEquipmentInterface) unitOperations.get(i)).setCalculationIdentifier(id); + } + + setCalculationIdentifier(id); + } + + /** + *

+ * runTransient. + *

+ */ + public void runTransient() { + runTransient(getTimeStep(), UUID.randomUUID()); + } + + /** + *

+ * runTransient. + *

+ * + * @param dt Delta time [s] + * @param id Calculation identifier + */ + @Override + public void runTransient(double dt, UUID id) { + setTimeStep(dt); + increaseTime(dt); + + for (int i = 0; i < unitOperations.size(); i++) { + unitOperations.get(i).runTransient(dt, id); + } + + timeStepNumber++; + signalDB[timeStepNumber] = new String[1 + 3 * measurementDevices.size()]; + for (int i = 0; i < measurementDevices.size(); i++) { + signalDB[timeStepNumber][0] = Double.toString(time); + signalDB[timeStepNumber][3 * i + 1] = measurementDevices.get(i).getName(); + signalDB[timeStepNumber][3 * i + 2] = + Double.toString(measurementDevices.get(i).getMeasuredValue()); + signalDB[timeStepNumber][3 * i + 3] = measurementDevices.get(i).getUnit(); + } + setCalculationIdentifier(id); + } + + @Override + public boolean solved() { + return true; + } + + /** + *

+ * Getter for the field time. + *

+ * + * @return a double + */ + public double getTime() { + return time; + } + + /** + *

+ * Getter for the field time. + *

+ * + * @param unit a {@link java.lang.String} object + * @return a double + */ + public double getTime(String unit) { + if (unit.equals("sec")) { + return time; + } else if (unit.equals("hr")) { + return time / 3600.0; + } else if (unit.equals("day")) { + return time / (3600.0 * 24); + } else if (unit.equals("year")) { + return time / (3600.0 * 24 * 365); + } + return time; + } + + /** + *

+ * size. + *

+ * + * @return a int + */ + public int size() { + return unitOperations.size(); + } + + /** + *

+ * view. + *

+ */ + public void view() { + this.displayResult(); + } + + /** + *

+ * displayResult. + *

+ */ + public void displayResult() { + try { + thisThread.join(); + } catch (Exception e) { + System.out.println("Thread did not finish"); + } + for (int i = 0; i < unitOperations.size(); i++) { + unitOperations.get(i).displayResult(); } /* - * @XmlRootElement private class Report extends Object{ public Double name; public - * ArrayList unitOperationsReports = new ArrayList(); - * - * Report(){ name= getName(); - * - * for (int i = 0; i < unitOperations.size(); i++) { - * unitOperationsReports.add(unitOperations.getReport()); } } } - * - * public Report getReport(){ return this.new Report(); } - */ + * JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + * frame.setLayout(new GridLayout(1, 0, 5, 5)); JTextArea area1 = new JTextArea(10, 10); JTable + * Jtab = new JTable(reportResults(), reportResults()[0]); frame.add(area1); frame.pack(); + * frame.setLocationRelativeTo(null); frame.setVisible(true); + */ + } + + /** + *

+ * reportMeasuredValues. + *

+ */ + public void reportMeasuredValues() { + try { + thisThread.join(); + } catch (Exception e) { + System.out.println("Thread did not finish"); + } + for (int i = 0; i < measurementDevices.size(); i++) { + System.out.println("Measurements Device Name: " + measurementDevices.get(i).getName()); + System.out.println("Value: " + measurementDevices.get(i).getMeasuredValue() + " " + + measurementDevices.get(i).getUnit()); + if (measurementDevices.get(i).isOnlineSignal()) { + System.out.println("Online value: " + measurementDevices.get(i).getOnlineSignal().getValue() + + " " + measurementDevices.get(i).getOnlineSignal().getUnit()); + } + } + } + + /** + *

+ * save. + *

+ * + * @param filePath a {@link java.lang.String} object + */ + public void save(String filePath) { + try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(filePath, false))) { + out.writeObject(this); + logger.info("process file saved to: " + filePath); + } catch (Exception e) { + logger.error(e.toString()); + e.printStackTrace(); + } + } + + /** + *

+ * open. + *

+ * + * @param filePath a {@link java.lang.String} object + * @return a {@link neqsim.processSimulation.processSystem.ProcessSystem} object + */ + public static ProcessSystem open(String filePath) { + try (ObjectInputStream objectinputstream = + new ObjectInputStream(new FileInputStream(filePath))) { + return (ProcessSystem) objectinputstream.readObject(); + // logger.info("process file open ok: " + filePath); + } catch (Exception e) { + // logger.error(e.toString()); + e.printStackTrace(); + } + return null; + } + + /** + *

+ * reportResults. + *

+ * + * @return an array of {@link java.lang.String} objects + */ + public String[][] reportResults() { + String[][] text = new String[200][]; + + int numb = 0; + for (int i = 0; i < unitOperations.size(); i++) { + for (int k = 0; k < unitOperations.get(i).reportResults().length; k++) { + text[numb++] = unitOperations.get(i).reportResults()[k]; + } + } + return text; + } + + /** + *

+ * printLogFile. + *

+ * + * @param filename a {@link java.lang.String} object + */ + public void printLogFile(String filename) { + neqsim.dataPresentation.fileHandeling.createTextFile.TextFile tempFile = + new neqsim.dataPresentation.fileHandeling.createTextFile.TextFile(); + tempFile.setOutputFileName(filename); + tempFile.setValues(signalDB); + tempFile.createFile(); + } + + /** + *

+ * Getter for the field timeStep. + *

+ * + * @return a double + */ + public double getTimeStep() { + return timeStep; + } + + /** + *

+ * Setter for the field timeStep. + *

+ * + * @param timeStep a double + */ + public void setTimeStep(double timeStep) { + this.timeStep = timeStep; + } + + /** + *

+ * Getter for the field name. + *

+ * + * @return the name + */ + public String getName() { + return name; + } + + /** + *

+ * Setter for the field name. + *

+ * + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + *

+ * Get a SystemMechanicalDesign object from processSystem. + *

+ * + * @return a new SystemMechanicalDesign object + */ + public SystemMechanicalDesign getSystemMechanicalDesign() { + return new SystemMechanicalDesign(this); + } + + /** + *

+ * Get a CostEstimateBaseClass object from processSystem. + *

+ * + * @return a new CostEstimateBaseClass object + */ + public CostEstimateBaseClass getCostEstimator() { + return new CostEstimateBaseClass(this); + } + + /** + *

+ * getEntropyProduction. + *

+ * + * @param unit a {@link java.lang.String} object + * @return a double + */ + public double getEntropyProduction(String unit) { + double entropyProduction = 0.0; + for (int i = 0; i < unitOperations.size(); i++) { + entropyProduction += unitOperations.get(i).getEntropyProduction(unit); + System.out.println("unit " + unitOperations.get(i).getName() + " entropy production " + + unitOperations.get(i).getEntropyProduction(unit)); + } + return entropyProduction; + } + + /** + *

+ * getExergyChange. + *

+ * + * @param unit a {@link java.lang.String} object + * @return a double + */ + public double getExergyChange(String unit) { + double exergyChange = 0.0; + for (int i = 0; i < unitOperations.size(); i++) { + exergyChange += unitOperations.get(i).getExergyChange("J", getSurroundingTemperature()); + System.out.println("unit " + unitOperations.get(i).getName() + " exergy change " + + unitOperations.get(i).getExergyChange("J", getSurroundingTemperature())); + } + return exergyChange; + } + + /** + *

+ * getPower. + *

+ * + * @param unit a {@link java.lang.String} object + * @return a double + */ + public double getPower(String unit) { + double power = 0.0; + for (int i = 0; i < unitOperations.size(); i++) { + if (unitOperations.get(i).getClass().getSimpleName().equals("Compressor")) { + power += ((neqsim.processSimulation.processEquipment.compressor.Compressor) unitOperations + .get(i)).getPower(); + } else if (unitOperations.get(i).getClass().getSimpleName().equals("Pump")) { + power += ((neqsim.processSimulation.processEquipment.pump.Pump) unitOperations.get(i)) + .getPower(); + } + } + if (unit.equals("MW")) { + return power / 1.0e6; + } else if (unit.equals("kW")) { + return power / 1.0e3; + } else { + return power; + } + } + + /** + *

+ * getCoolerDuty. + *

+ * + * @param unit a {@link java.lang.String} object + * @return a double + */ + public double getCoolerDuty(String unit) { + double heat = 0.0; + for (int i = 0; i < unitOperations.size(); i++) { + if (unitOperations.get(i).getClass().getSimpleName().equals("Cooler")) { + heat += + ((neqsim.processSimulation.processEquipment.heatExchanger.Cooler) unitOperations.get(i)) + .getDuty(); + } + } + return heat; + } + + /** + *

+ * getHeaterDuty. + *

+ * + * @param unit a {@link java.lang.String} object + * @return a double + */ + public double getHeaterDuty(String unit) { + double heat = 0.0; + for (int i = 0; i < unitOperations.size(); i++) { + if (unitOperations.get(i).getClass().getSimpleName().equals("Heater")) { + heat += + ((neqsim.processSimulation.processEquipment.heatExchanger.Heater) unitOperations.get(i)) + .getDuty(); + } + } + return heat; + } + + /** + *

+ * getMechanicalWeight. + *

+ * + * @param unit a {@link java.lang.String} object + * @return a double + */ + public double getMechanicalWeight(String unit) { + double weight = 0.0; + for (int i = 0; i < unitOperations.size(); i++) { + unitOperations.get(i).getMechanicalDesign().calcDesign(); + System.out.println("Name " + unitOperations.get(i).getName() + " weight " + + unitOperations.get(i).getMechanicalDesign().getWeightTotal()); + weight += unitOperations.get(i).getMechanicalDesign().getWeightTotal(); + } + return weight; + } + + /** + *

+ * Getter for the field surroundingTemperature. + *

+ * + * @return a double + */ + public double getSurroundingTemperature() { + return surroundingTemperature; + } + + /** + *

+ * Setter for the field surroundingTemperature. + *

+ * + * @param surroundingTemperature a double + */ + public void setSurroundingTemperature(double surroundingTemperature) { + this.surroundingTemperature = surroundingTemperature; + } + + /** + *

+ * Create deep copy. + *

+ * + * @return a {@link neqsim.processSimulation.processSystem.ProcessSystem} object + */ + public ProcessSystem copy() { + byte[] bytes = SerializationUtils.serialize(this); + ProcessSystem copyOperation = (ProcessSystem) SerializationUtils.deserialize(bytes); + return copyOperation; + } + + /** + *

+ * getConditionMonitor. + *

+ * + * @return a {@link neqsim.processSimulation.conditionMonitor.ConditionMonitor} object + */ + public ConditionMonitor getConditionMonitor() { + return new ConditionMonitor(this); + } + + /** {@inheritDoc} */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + Arrays.deepHashCode(signalDB); + result = prime * result + Objects.hash(measurementDevices, name, recycleController, + surroundingTemperature, time, timeStep, timeStepNumber, unitOperations); + return result; + } + + /** {@inheritDoc} */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ProcessSystem other = (ProcessSystem) obj; + return Objects.equals(measurementDevices, other.measurementDevices) + && Objects.equals(name, other.name) + && Objects.equals(recycleController, other.recycleController) + && Arrays.deepEquals(signalDB, other.signalDB) + && Double.doubleToLongBits(surroundingTemperature) == Double + .doubleToLongBits(other.surroundingTemperature) + && Double.doubleToLongBits(time) == Double.doubleToLongBits(other.time) + && Double.doubleToLongBits(timeStep) == Double.doubleToLongBits(other.timeStep) + && timeStepNumber == other.timeStepNumber + && Objects.equals(unitOperations, other.unitOperations); + } + + /* + * @XmlRootElement private class Report extends Object{ public Double name; public + * ArrayList unitOperationsReports = new ArrayList(); + * + * Report(){ name= getName(); + * + * for (int i = 0; i < unitOperations.size(); i++) { + * unitOperationsReports.add(unitOperations.getReport()); } } } + * + * public Report getReport(){ return this.new Report(); } + */ } diff --git a/src/main/java/neqsim/processSimulation/processSystem/processModules/AdsorptionDehydrationlModule.java b/src/main/java/neqsim/processSimulation/processSystem/processModules/AdsorptionDehydrationlModule.java index 59e644f732..7d682061a2 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/processModules/AdsorptionDehydrationlModule.java +++ b/src/main/java/neqsim/processSimulation/processSystem/processModules/AdsorptionDehydrationlModule.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processSystem.processModules; +import java.util.UUID; import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface; import neqsim.processSimulation.processEquipment.adsorber.SimpleAdsorber; import neqsim.processSimulation.processEquipment.separator.Separator; @@ -16,211 +17,213 @@ * @version $Id: $Id */ public class AdsorptionDehydrationlModule extends ProcessModuleBaseClass { - private static final long serialVersionUID = 1000; - - protected StreamInterface gasStreamToAdsorber = null, gasStreamFromAdsorber = null; - protected SimpleAdsorber[] adsorber = null; - double regenerationCycleTime = 1.0, waterDewPontTemperature = 273.15 - 10.0, designFlow = 1.0, - designAdsorptionTemperature = 298.0, designRegenerationTemperature = 440.0, - designAdsorptionPressure = 60.0; - int numberOfAdorptionBeds = 3; - double adsorberInternalDiameter = 1.0; - double adsorbentFillingHeight = 3.0; - - public AdsorptionDehydrationlModule(String name) { - super(name); + private static final long serialVersionUID = 1000; + + protected StreamInterface gasStreamToAdsorber = null, gasStreamFromAdsorber = null; + protected SimpleAdsorber[] adsorber = null; + double regenerationCycleTime = 1.0, waterDewPontTemperature = 273.15 - 10.0, designFlow = 1.0, + designAdsorptionTemperature = 298.0, designRegenerationTemperature = 440.0, + designAdsorptionPressure = 60.0; + int numberOfAdorptionBeds = 3; + double adsorberInternalDiameter = 1.0; + double adsorbentFillingHeight = 3.0; + + public AdsorptionDehydrationlModule(String name) { + super(name); + } + + /** {@inheritDoc} */ + @Override + public void addInputStream(String streamName, StreamInterface stream) { + if (streamName.equals("gasStreamToAdsorber")) { + this.gasStreamToAdsorber = stream; } + } - /** {@inheritDoc} */ - @Override - public void addInputStream(String streamName, StreamInterface stream) { - if (streamName.equals("gasStreamToAdsorber")) { - this.gasStreamToAdsorber = stream; - } + /** {@inheritDoc} */ + @Override + public StreamInterface getOutputStream(String streamName) { + if (!isInitializedStreams) { + initializeStreams(); } - - /** {@inheritDoc} */ - @Override - public StreamInterface getOutputStream(String streamName) { - if (!isInitializedStreams) { - initializeStreams(); - } - if (streamName.equals("gasStreamFromAdsorber")) { - return this.gasStreamFromAdsorber; - } else { - return null; - } + if (streamName.equals("gasStreamFromAdsorber")) { + return this.gasStreamFromAdsorber; + } else { + return null; } - - /** {@inheritDoc} */ - @Override - public ProcessEquipmentInterface getUnit(String unitName) { - if (unitName.equals("adorber_0")) { - return adsorber[0]; - } else if (unitName.equals("adorber_1")) { - return adsorber[1]; - } else if (unitName.equals("adorber_2")) { - return adsorber[2]; - } else { - return null; - } + } + + /** {@inheritDoc} */ + @Override + public ProcessEquipmentInterface getUnit(String unitName) { + if (unitName.equals("adorber_0")) { + return adsorber[0]; + } else if (unitName.equals("adorber_1")) { + return adsorber[1]; + } else if (unitName.equals("adorber_2")) { + return adsorber[2]; + } else { + return null; } + } - /** {@inheritDoc} */ - @Override - public void run() { - if (!isInitializedModule) { - initializeModule(); - } - gasStreamToAdsorber.run(); - - getOperations().run(); - - // gasStreamFromAdsorber = (Stream) inletSeparator.getGasOutStream().clone(); - // gasStreamFromAdsorber.getThermoSystem().addComponent("water", - // -gasStreamFromAdsorber.getThermoSystem().getPhase(0).getComponent("water").getNumberOfMolesInPhase() - // * 0.99); - // gasStreamFromAdsorber.getThermoSystem().addComponent("TEG", 1e-10); - // gasStreamFromAdsorber.getThermoSystem().init(1); + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + if (!isInitializedModule) { + initializeModule(); } - - /** {@inheritDoc} */ - @Override - public void initializeStreams() { - isInitializedStreams = true; - try { - adsorber = new SimpleAdsorber[numberOfAdorptionBeds]; - for (int i = 0; i < numberOfAdorptionBeds; i++) { - adsorber[i] = new SimpleAdsorber("SimpleAdsorber_" + i + 1, gasStreamToAdsorber); - } - this.gasStreamFromAdsorber = (Stream) this.gasStreamToAdsorber.clone(); - this.gasStreamFromAdsorber.setName("Stream from Adsorber"); - } catch (Exception e) { - e.printStackTrace(); - } + gasStreamToAdsorber.run(id); + + getOperations().run(id); + + // gasStreamFromAdsorber = (Stream) inletSeparator.getGasOutStream().clone(); + // gasStreamFromAdsorber.getThermoSystem().addComponent("water", + // -gasStreamFromAdsorber.getThermoSystem().getPhase(0).getComponent("water").getNumberOfMolesInPhase() + // * 0.99); + // gasStreamFromAdsorber.getThermoSystem().addComponent("TEG", 1e-10); + // gasStreamFromAdsorber.getThermoSystem().init(1); + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public void initializeStreams() { + isInitializedStreams = true; + try { + adsorber = new SimpleAdsorber[numberOfAdorptionBeds]; + for (int i = 0; i < numberOfAdorptionBeds; i++) { + adsorber[i] = new SimpleAdsorber("SimpleAdsorber_" + i + 1, gasStreamToAdsorber); + } + this.gasStreamFromAdsorber = (Stream) this.gasStreamToAdsorber.clone(); + this.gasStreamFromAdsorber.setName("Stream from Adsorber"); + } catch (Exception e) { + e.printStackTrace(); } + } - /** {@inheritDoc} */ - @Override - public void initializeModule() { - isInitializedModule = true; + /** {@inheritDoc} */ + @Override + public void initializeModule() { + isInitializedModule = true; - getOperations().add(gasStreamToAdsorber); - } + getOperations().add(gasStreamToAdsorber); + } - /** {@inheritDoc} */ - @Override - public void setSpecification(String specificationName, double value) { - if (specificationName.equals("water dew point temperature")) { - waterDewPontTemperature = value; - } - if (specificationName.equals("designFlow")) { - designFlow = value; - } - if (specificationName.equals("designAdsorptionTemperature")) { - designAdsorptionTemperature = value; - } - if (specificationName.equals("designRegenerationTemperature")) { - designRegenerationTemperature = value; - } - if (specificationName.equals("designAdsorptionPressure")) { - designAdsorptionPressure = value; - } - - if (specificationName.equals("regenerationCycleTime")) { - regenerationCycleTime = value; - } + /** {@inheritDoc} */ + @Override + public void setSpecification(String specificationName, double value) { + if (specificationName.equals("water dew point temperature")) { + waterDewPontTemperature = value; } - - /** {@inheritDoc} */ - @Override - public void calcDesign() { - Stream tempStream = (Stream) gasStreamToAdsorber.clone(); - tempStream.getThermoSystem().setPressure(designAdsorptionPressure); - tempStream.getThermoSystem().setTemperature(designAdsorptionTemperature); - tempStream.run(); - tempStream.getThermoSystem().initPhysicalProperties(); - double gasDensity = - tempStream.getThermoSystem().getPhase(0).getPhysicalProperties().getDensity(); - - double gasVelocity = 67.0 / Math.sqrt(gasDensity); - - double qa = designFlow / (numberOfAdorptionBeds - 1.0) / 1440.0 - * (1.01325 / designAdsorptionPressure) * (designAdsorptionTemperature / 288.15) - * tempStream.getThermoSystem().getPhase(0).getZ(); - adsorberInternalDiameter = Math.sqrt(4.0 * qa / Math.PI / gasVelocity); - - double waterLoadingCycle = regenerationCycleTime * designFlow * 42.29489667 - * tempStream.getThermoSystem().getPhase(0).getComponent("water").getx() - * tempStream.getThermoSystem().getPhase(0).getComponent("water").getMolarMass();// 360.0; - // // - // kg/cycle - // this - // needs - // to - // be - // calculated - double usefulDesiccantCapacity = 10.0; // 10% - double bulkDensityDesiccant = 750.0; // 10% - - adsorbentFillingHeight = 400.0 * waterLoadingCycle / (Math.PI * usefulDesiccantCapacity - * bulkDensityDesiccant * adsorberInternalDiameter * adsorberInternalDiameter); - - // double lenghtDiameterRatio = adsorbentFillingHeight / adsorberInternalDiameter; - // design is done here + if (specificationName.equals("designFlow")) { + designFlow = value; } - - /** {@inheritDoc} */ - @Override - public void setDesign() { - for (int i = 0; i < numberOfAdorptionBeds; i++) { - adsorber[i].getMechanicalDesign().setInnerDiameter(adsorberInternalDiameter); - adsorber[i].getMechanicalDesign().setTantanLength(adsorbentFillingHeight * 1.5); - } - // set design is done here + if (specificationName.equals("designAdsorptionTemperature")) { + designAdsorptionTemperature = value; + } + if (specificationName.equals("designRegenerationTemperature")) { + designRegenerationTemperature = value; + } + if (specificationName.equals("designAdsorptionPressure")) { + designAdsorptionPressure = value; } - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 30.0), 10.0); - - testSystem.addComponent("methane", 1.0); - testSystem.addComponent("water", 1.0); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - - Stream inletStream = new Stream("inletStream", testSystem); - Separator separator = new Separator("Separator 1", inletStream); - - neqsim.processSimulation.processSystem.processModules.AdsorptionDehydrationlModule adsorptionPlant = - new neqsim.processSimulation.processSystem.processModules.AdsorptionDehydrationlModule("absPlant"); - adsorptionPlant.addInputStream("gasStreamToAdsorber", separator.getGasOutStream()); - adsorptionPlant.setSpecification("water dew point temperature", 273.15 - 100.0); - adsorptionPlant.setSpecification("designFlow", 20.0e6); // MSm^3/day - adsorptionPlant.setSpecification("designAdsorptionTemperature", 273.15 + 30); - adsorptionPlant.setSpecification("designRegenerationTemperature", 273.15 + 250.0); - adsorptionPlant.setSpecification("designAdsorptionPressure", 60.0); - adsorptionPlant.setSpecification("regenerationCycleTime", 1.0); // days per cycle - adsorptionPlant.setSpecification("maxDesignPressure", 100.0); - adsorptionPlant.setSpecification("maxDesignTemperature", 100.0); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(inletStream); - operations.add(separator); - operations.add(adsorptionPlant); - - operations.run(); - - adsorptionPlant.calcDesign(); - - // TEGplant.getOutputStream("gasStreamFromAdsorber").displayResult(); + if (specificationName.equals("regenerationCycleTime")) { + regenerationCycleTime = value; + } + } + + /** {@inheritDoc} */ + @Override + public void calcDesign() { + Stream tempStream = (Stream) gasStreamToAdsorber.clone(); + tempStream.getThermoSystem().setPressure(designAdsorptionPressure); + tempStream.getThermoSystem().setTemperature(designAdsorptionTemperature); + tempStream.run(); + tempStream.getThermoSystem().initPhysicalProperties(); + double gasDensity = + tempStream.getThermoSystem().getPhase(0).getPhysicalProperties().getDensity(); + + double gasVelocity = 67.0 / Math.sqrt(gasDensity); + + double qa = designFlow / (numberOfAdorptionBeds - 1.0) / 1440.0 + * (1.01325 / designAdsorptionPressure) * (designAdsorptionTemperature / 288.15) + * tempStream.getThermoSystem().getPhase(0).getZ(); + adsorberInternalDiameter = Math.sqrt(4.0 * qa / Math.PI / gasVelocity); + + double waterLoadingCycle = regenerationCycleTime * designFlow * 42.29489667 + * tempStream.getThermoSystem().getPhase(0).getComponent("water").getx() + * tempStream.getThermoSystem().getPhase(0).getComponent("water").getMolarMass();// 360.0; + // // + // kg/cycle + // this + // needs + // to + // be + // calculated + double usefulDesiccantCapacity = 10.0; // 10% + double bulkDensityDesiccant = 750.0; // 10% + + adsorbentFillingHeight = 400.0 * waterLoadingCycle / (Math.PI * usefulDesiccantCapacity + * bulkDensityDesiccant * adsorberInternalDiameter * adsorberInternalDiameter); + + // double lenghtDiameterRatio = adsorbentFillingHeight / adsorberInternalDiameter; + // design is done here + } + + /** {@inheritDoc} */ + @Override + public void setDesign() { + for (int i = 0; i < numberOfAdorptionBeds; i++) { + adsorber[i].getMechanicalDesign().setInnerDiameter(adsorberInternalDiameter); + adsorber[i].getMechanicalDesign().setTantanLength(adsorbentFillingHeight * 1.5); } + // set design is done here + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos((273.15 + 30.0), 10.0); + + testSystem.addComponent("methane", 1.0); + testSystem.addComponent("water", 1.0); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + + Stream inletStream = new Stream("inletStream", testSystem); + Separator separator = new Separator("Separator 1", inletStream); + + neqsim.processSimulation.processSystem.processModules.AdsorptionDehydrationlModule adsorptionPlant = + new neqsim.processSimulation.processSystem.processModules.AdsorptionDehydrationlModule( + "absPlant"); + adsorptionPlant.addInputStream("gasStreamToAdsorber", separator.getGasOutStream()); + adsorptionPlant.setSpecification("water dew point temperature", 273.15 - 100.0); + adsorptionPlant.setSpecification("designFlow", 20.0e6); // MSm^3/day + adsorptionPlant.setSpecification("designAdsorptionTemperature", 273.15 + 30); + adsorptionPlant.setSpecification("designRegenerationTemperature", 273.15 + 250.0); + adsorptionPlant.setSpecification("designAdsorptionPressure", 60.0); + adsorptionPlant.setSpecification("regenerationCycleTime", 1.0); // days per cycle + adsorptionPlant.setSpecification("maxDesignPressure", 100.0); + adsorptionPlant.setSpecification("maxDesignTemperature", 100.0); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(inletStream); + operations.add(separator); + operations.add(adsorptionPlant); + + operations.run(); + + adsorptionPlant.calcDesign(); + + // TEGplant.getOutputStream("gasStreamFromAdsorber").displayResult(); + } } diff --git a/src/main/java/neqsim/processSimulation/processSystem/processModules/CO2RemovalModule.java b/src/main/java/neqsim/processSimulation/processSystem/processModules/CO2RemovalModule.java index cb8ca8520e..88029ef0d5 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/processModules/CO2RemovalModule.java +++ b/src/main/java/neqsim/processSimulation/processSystem/processModules/CO2RemovalModule.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processSystem.processModules; +import java.util.UUID; import neqsim.processSimulation.processEquipment.separator.Separator; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; @@ -14,89 +15,88 @@ * @version $Id: $Id */ public class CO2RemovalModule extends ProcessModuleBaseClass { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - protected StreamInterface streamToAbsorber = null, streamFromAbsorber = null, - gasFromCO2Stripper = null; + protected StreamInterface streamToAbsorber = null, streamFromAbsorber = null, + gasFromCO2Stripper = null; - protected Separator inletSeparator = null; + protected Separator inletSeparator = null; - public CO2RemovalModule(String name) { - super(name); - } + public CO2RemovalModule(String name) { + super(name); + } - /** {@inheritDoc} */ - @Override - public void addInputStream(String streamName, StreamInterface stream) { - if (streamName.equals("streamToAbsorber")) { - this.streamToAbsorber = stream; - } + /** {@inheritDoc} */ + @Override + public void addInputStream(String streamName, StreamInterface stream) { + if (streamName.equals("streamToAbsorber")) { + this.streamToAbsorber = stream; } + } - /** {@inheritDoc} */ - @Override - public StreamInterface getOutputStream(String streamName) { - if (!isInitializedStreams) { - initializeStreams(); - } - if (streamName.equals("streamFromAbsorber")) { - return this.streamFromAbsorber; - } else { - return null; - } + /** {@inheritDoc} */ + @Override + public StreamInterface getOutputStream(String streamName) { + if (!isInitializedStreams) { + initializeStreams(); } + if (streamName.equals("streamFromAbsorber")) { + return this.streamFromAbsorber; + } else { + return null; + } + } - /** {@inheritDoc} */ - @Override - public void run() { - if (!isInitializedModule) { - initializeModule(); - } - getOperations().run(); - - streamFromAbsorber = (Stream) inletSeparator.getGasOutStream().clone(); - streamFromAbsorber.getThermoSystem().addComponent("CO2", - -streamFromAbsorber.getThermoSystem().getPhase(0).getComponent("CO2") - .getNumberOfMolesInPhase() * 0.99); - streamFromAbsorber.getThermoSystem().addComponent("MEG", - -streamFromAbsorber.getThermoSystem().getPhase(0).getComponent("MEG") - .getNumberOfMolesInPhase() * 0.99); - streamFromAbsorber.getThermoSystem().init(1); + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + if (!isInitializedModule) { + initializeModule(); } + getOperations().run(id); + + streamFromAbsorber = (Stream) inletSeparator.getGasOutStream().clone(); + streamFromAbsorber.getThermoSystem().addComponent("CO2", -streamFromAbsorber.getThermoSystem() + .getPhase(0).getComponent("CO2").getNumberOfMolesInPhase() * 0.99); + streamFromAbsorber.getThermoSystem().addComponent("MEG", -streamFromAbsorber.getThermoSystem() + .getPhase(0).getComponent("MEG").getNumberOfMolesInPhase() * 0.99); + streamFromAbsorber.getThermoSystem().init(1); + setCalculationIdentifier(id); + } - /** {@inheritDoc} */ - @Override - public void initializeStreams() { - isInitializedStreams = true; - try { - this.streamFromAbsorber = (Stream) this.streamToAbsorber.clone(); - this.streamFromAbsorber.setName("Stream from ABsorber"); + /** {@inheritDoc} */ + @Override + public void initializeStreams() { + isInitializedStreams = true; + try { + this.streamFromAbsorber = (Stream) this.streamToAbsorber.clone(); + this.streamFromAbsorber.setName("Stream from ABsorber"); - this.gasFromCO2Stripper = (Stream) this.streamToAbsorber.clone(); - this.gasFromCO2Stripper.setName("Gas stream from Stripper"); - } catch (Exception e) { - e.printStackTrace(); - } + this.gasFromCO2Stripper = (Stream) this.streamToAbsorber.clone(); + this.gasFromCO2Stripper.setName("Gas stream from Stripper"); + } catch (Exception e) { + e.printStackTrace(); } + } - /** {@inheritDoc} */ - @Override - public void initializeModule() { - isInitializedModule = true; - inletSeparator = new Separator("inletSeparator", streamToAbsorber); + /** {@inheritDoc} */ + @Override + public void initializeModule() { + isInitializedModule = true; + inletSeparator = new Separator("inletSeparator", streamToAbsorber); - getOperations().add(inletSeparator); - } + getOperations().add(inletSeparator); + } - /** {@inheritDoc} */ - @Override - public void calcDesign() { - // design is done here - } + /** {@inheritDoc} */ + @Override + public void calcDesign() { + // design is done here + } - /** {@inheritDoc} */ - @Override - public void setDesign() { - // set design is done here - } + /** {@inheritDoc} */ + @Override + public void setDesign() { + // set design is done here + } } diff --git a/src/main/java/neqsim/processSimulation/processSystem/processModules/DPCUModule.java b/src/main/java/neqsim/processSimulation/processSystem/processModules/DPCUModule.java index c696a49542..bf62818697 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/processModules/DPCUModule.java +++ b/src/main/java/neqsim/processSimulation/processSystem/processModules/DPCUModule.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processSystem.processModules; +import java.util.UUID; import neqsim.processSimulation.processEquipment.compressor.Compressor; import neqsim.processSimulation.processEquipment.distillation.Condenser; import neqsim.processSimulation.processEquipment.distillation.DistillationColumn; @@ -26,274 +27,282 @@ * @version $Id: $Id */ public class DPCUModule extends ProcessModuleBaseClass { - private static final long serialVersionUID = 1000; - - StreamInterface ethaneOvhComp, gasDistColumnExit, liquidDistColumnExit, feedStream, - gasExitStream, oilExitStream, glycolFeedStream, glycolExitStream; - Separator glycolScrubber; - Separator inletSeparator; - double inletSepTemperature = 50.00, pressureAfterRedValve = 55.0; // bar' - double gasScrubberTemperature = 30.00, firstStageOutPressure = 110.0, - glycolScrubberTemperature = 20.0, secondStageOutPressure = 200.0; // bar - double glycolInjectionRate = 10.0, exportGasTemperature = 273.15 + 30.0, - liquidPumpPressure = 150.0; // m^3/hr - Separator LTseparator; - HeatExchanger heatExchanger1; - ThrottlingValve valve1; - Expander expander; - Compressor compressor1; - Mixer mixer; - DistillationColumn distColumn; - - public DPCUModule(String name) { - super(name); + private static final long serialVersionUID = 1000; + + StreamInterface ethaneOvhComp, gasDistColumnExit, liquidDistColumnExit, feedStream, gasExitStream, + oilExitStream, glycolFeedStream, glycolExitStream; + Separator glycolScrubber; + Separator inletSeparator; + double inletSepTemperature = 50.00, pressureAfterRedValve = 55.0; // bar' + double gasScrubberTemperature = 30.00, firstStageOutPressure = 110.0, + glycolScrubberTemperature = 20.0, secondStageOutPressure = 200.0; // bar + double glycolInjectionRate = 10.0, exportGasTemperature = 273.15 + 30.0, + liquidPumpPressure = 150.0; // m^3/hr + Separator LTseparator; + HeatExchanger heatExchanger1; + ThrottlingValve valve1; + Expander expander; + Compressor compressor1; + Mixer mixer; + DistillationColumn distColumn; + + public DPCUModule(String name) { + super(name); + } + + /** {@inheritDoc} */ + @Override + public void addInputStream(String streamName, StreamInterface stream) { + if (streamName.equals("feed stream")) { + this.feedStream = stream; } - - /** {@inheritDoc} */ - @Override - public void addInputStream(String streamName, StreamInterface stream) { - if (streamName.equals("feed stream")) { - this.feedStream = stream; - } - if (streamName.equals("glycol feed stream")) { - this.glycolFeedStream = stream; - } - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getOutputStream(String streamName) { - if (!isInitializedStreams) { - initializeStreams(); - } - if (streamName.equals("gas exit stream")) { - return this.gasExitStream; - } else if (streamName.equals("oil exit stream")) { - return this.oilExitStream; - } else if (streamName.equals("gas from dist column")) { - return this.gasDistColumnExit; - } else if (streamName.equals("liquid from dist column")) { - return this.liquidDistColumnExit; - } else { - return null; - } - } - - /** {@inheritDoc} */ - @Override - public void initializeModule() { - isInitializedModule = true; - // double inletPressure = feedStream.getPressure(); - - ValveInterface inletValve = new ThrottlingValve("inlet valve", feedStream); - inletValve.setOutletPressure(pressureAfterRedValve); - - heatExchanger1 = new HeatExchanger("heatExchanger1", inletValve.getOutletStream()); - // heatExchanger1.setOutTemperature(273.15 - 18); - // heatExchanger1.setUAvalue(10000.0); - // heatExchanger1.addInStream(feedStream2); - - Cooler heatExchanger2 = new Cooler("heatExchanger2", heatExchanger1.getOutStream(0)); - // heatExchanger2.setUAvalue(1000.0); - heatExchanger1.setOutTemperature(273.15 - 21.0); - // heatExchanger1.addInStream(feedStream2); - - expander = new Expander("expander", heatExchanger2.getOutletStream()); - expander.setOutletPressure(46.0); - - LTseparator = new Separator("LTseparator", expander.getOutletStream()); - - Splitter splitter = new Splitter("LTsplitter", LTseparator.getGasOutStream(), 2); - splitter.setSplitFactors(new double[] {0.9, 0.1}); - - heatExchanger1.addInStream(splitter.getSplitStream(0)); - - mixer = new Mixer("gasmixer"); - mixer.addStream(heatExchanger1.getOutStream(1)); - mixer.addStream(splitter.getSplitStream(1)); - - compressor1 = new Compressor("Compressor 1", mixer.getOutletStream()); - compressor1.setOutletPressure(65.0); - - Recycle recycl = new Recycle("recycler"); - recycl.addStream(compressor1.getOutletStream()); - - valve1 = new ThrottlingValve("valve1", LTseparator.getLiquidOutStream()); - valve1.setOutletPressure(30.0); - - distColumn = new DistillationColumn(10, true, true); - distColumn.addFeedStream(valve1.getOutletStream(), 2); - // distColumn.setCondenserTemperature(273.15 - 72.0); - // distColumn.setReboilerTemperature(273.0+40.0); - ((Reboiler) distColumn.getReboiler()).setRefluxRatio(10.7); - ((Condenser) distColumn.getCondenser()).setRefluxRatio(10.7); - - // heatExchanger2.addInStream(distColumn.getGasOutStream()); - getOperations().add(inletValve); - getOperations().add(heatExchanger1); - getOperations().add(heatExchanger2); - getOperations().add(expander); - getOperations().add(LTseparator); - getOperations().add(splitter); - getOperations().add(mixer); - getOperations().add(compressor1); - getOperations().add(recycl); - getOperations().add(valve1); - // getOperations().add(distColumn); - - /* - * Cooler inletCooler = new Cooler("inlet well stream cooler", feedStream); - * inletCooler.setOutTemperature(inletSepTemperature + 273.15); - * - * inletSeparator = new Separator("Inlet separator", inletCooler.getOutStream()); - * - * Cooler gasCooler = new Cooler("separator gas cooler", inletSeparator.getGasOutStream()); - * gasCooler.setOutTemperature(gasScrubberTemperature + 273.15); - * - * oilPump = new Pump("liquid pump", inletSeparator.getLiquidOutStream()); - * oilPump.setOutletPressure(liquidPumpPressure); - * - * Separator gasScrubber = new Separator("HC dew point control scrubber", - * gasCooler.getOutStream()); - * - * Recycle HPliquidRecycle = new Recycle("Resycle"); double tolerance = 1e-2; - * HPliquidRecycle.setTolerance(tolerance); - * HPliquidRecycle.addStream(gasScrubber.getLiquidOutStream()); - * inletSeparator.addStream(HPliquidRecycle.getOutStream()); - * - * Compressor firstStageCompressor = new Compressor("1st stage compressor", - * gasScrubber.getGasOutStream()); - * firstStageCompressor.setOutletPressure(firstStageOutPressure); - * - * glycolFeedStream.getThermoSystem().setPressure(firstStageOutPressure); - * - * Mixer glycolMixer = new Mixer("glycol injection mixer"); - * glycolMixer.addStream(firstStageCompressor.getOutStream()); - * glycolMixer.addStream(glycolFeedStream); - * - * Cooler mixerAfterCooler = new Cooler("glycol mixer after cooler", - * glycolMixer.getOutStream()); mixerAfterCooler.setOutTemperature(glycolScrubberTemperature - * + 273.15); - * - * glycolScrubber = new Separator("Water dew point control scrubber", - * mixerAfterCooler.getOutStream()); - * - * secondStageCompressor = new Compressor("2nd stage compressor", - * glycolScrubber.getGasOutStream()); - * secondStageCompressor.setOutletPressure(secondStageOutPressure); - * - * secondStageAfterCooler = new Cooler("second stage after cooler", - * secondStageCompressor.getOutStream()); - * secondStageAfterCooler.setOutTemperature(exportGasTemperature + 273.15); - * - * getOperations().add(inletCooler); getOperations().add(inletSeparator); - * getOperations().add(gasCooler); getOperations().add(oilPump); - * getOperations().add(gasScrubber); getOperations().add(HPliquidRecycle); - * getOperations().add(firstStageCompressor); getOperations().add(glycolMixer); - * getOperations().add(mixerAfterCooler); getOperations().add(glycolScrubber); - * getOperations().add(secondStageCompressor); getOperations().add(secondStageAfterCooler); - * - */ - } - - /** {@inheritDoc} */ - @Override - public void run() { - if (!isInitializedModule) { - initializeModule(); - } - getOperations().run(); - - gasExitStream = compressor1.getOutletStream(); - oilExitStream = LTseparator.getLiquidOutStream(); - gasDistColumnExit = distColumn.getGasOutStream(); - liquidDistColumnExit = distColumn.getLiquidOutStream(); + if (streamName.equals("glycol feed stream")) { + this.glycolFeedStream = stream; } + } - /** {@inheritDoc} */ - @Override - public void initializeStreams() { - isInitializedStreams = true; + /** {@inheritDoc} */ + @Override + public StreamInterface getOutputStream(String streamName) { + if (!isInitializedStreams) { + initializeStreams(); } - - /** {@inheritDoc} */ - @Override - public void calcDesign() { - // design is done here - } - - /** {@inheritDoc} */ - @Override - public void setDesign() { - // set design is done here - } - - /** {@inheritDoc} */ - @Override - public void setSpecification(String specificationName, double value) { - if (specificationName.equals("pressure after reduction valve")) { - pressureAfterRedValve = value; - } else if (specificationName.equals("gas scrubber temperature")) { - gasScrubberTemperature = value; - } + if (streamName.equals("gas exit stream")) { + return this.gasExitStream; + } else if (streamName.equals("oil exit stream")) { + return this.oilExitStream; + } else if (streamName.equals("gas from dist column")) { + return this.gasDistColumnExit; + } else if (streamName.equals("liquid from dist column")) { + return this.liquidDistColumnExit; + } else { + return null; } + } + + /** {@inheritDoc} */ + @Override + public void initializeModule() { + isInitializedModule = true; + // double inletPressure = feedStream.getPressure(); + + ValveInterface inletValve = new ThrottlingValve("inlet valve", feedStream); + inletValve.setOutletPressure(pressureAfterRedValve); + + heatExchanger1 = new HeatExchanger("heatExchanger1", inletValve.getOutletStream()); + // heatExchanger1.setOutTemperature(273.15 - 18); + // heatExchanger1.setUAvalue(10000.0); + // heatExchanger1.addInStream(feedStream2); + + Cooler heatExchanger2 = new Cooler("heatExchanger2", heatExchanger1.getOutStream(0)); + // heatExchanger2.setUAvalue(1000.0); + heatExchanger1.setOutTemperature(273.15 - 21.0); + // heatExchanger1.addInStream(feedStream2); + + expander = new Expander("expander", heatExchanger2.getOutletStream()); + expander.setOutletPressure(46.0); + + LTseparator = new Separator("LTseparator", expander.getOutletStream()); + + Splitter splitter = new Splitter("LTsplitter", LTseparator.getGasOutStream(), 2); + splitter.setSplitFactors(new double[] {0.9, 0.1}); + + heatExchanger1.addInStream(splitter.getSplitStream(0)); + + mixer = new Mixer("gasmixer"); + mixer.addStream(heatExchanger1.getOutStream(1)); + mixer.addStream(splitter.getSplitStream(1)); + + compressor1 = new Compressor("Compressor 1", mixer.getOutletStream()); + compressor1.setOutletPressure(65.0); + + Recycle recycl = new Recycle("recycler"); + recycl.addStream(compressor1.getOutletStream()); + + valve1 = new ThrottlingValve("valve1", LTseparator.getLiquidOutStream()); + valve1.setOutletPressure(30.0); + + distColumn = new DistillationColumn(10, true, true); + distColumn.addFeedStream(valve1.getOutletStream(), 2); + // distColumn.setCondenserTemperature(273.15 - 72.0); + // distColumn.setReboilerTemperature(273.0+40.0); + ((Reboiler) distColumn.getReboiler()).setRefluxRatio(10.7); + ((Condenser) distColumn.getCondenser()).setRefluxRatio(10.7); + + // heatExchanger2.addInStream(distColumn.getGasOutStream()); + getOperations().add(inletValve); + getOperations().add(heatExchanger1); + getOperations().add(heatExchanger2); + getOperations().add(expander); + getOperations().add(LTseparator); + getOperations().add(splitter); + getOperations().add(mixer); + getOperations().add(compressor1); + getOperations().add(recycl); + getOperations().add(valve1); + // getOperations().add(distColumn); + + /* + * Cooler inletCooler = new Cooler("inlet well stream cooler", feedStream); + * inletCooler.setOutTemperature(inletSepTemperature + 273.15); + * + * inletSeparator = new Separator("Inlet separator", inletCooler.getOutStream()); + * + * Cooler gasCooler = new Cooler("separator gas cooler", inletSeparator.getGasOutStream()); + * gasCooler.setOutTemperature(gasScrubberTemperature + 273.15); + * + * oilPump = new Pump("liquid pump", inletSeparator.getLiquidOutStream()); + * oilPump.setOutletPressure(liquidPumpPressure); + * + * Separator gasScrubber = new Separator("HC dew point control scrubber", + * gasCooler.getOutStream()); + * + * Recycle HPliquidRecycle = new Recycle("Resycle"); double tolerance = 1e-2; + * HPliquidRecycle.setTolerance(tolerance); + * HPliquidRecycle.addStream(gasScrubber.getLiquidOutStream()); + * inletSeparator.addStream(HPliquidRecycle.getOutStream()); + * + * Compressor firstStageCompressor = new Compressor("1st stage compressor", + * gasScrubber.getGasOutStream()); + * firstStageCompressor.setOutletPressure(firstStageOutPressure); + * + * glycolFeedStream.getThermoSystem().setPressure(firstStageOutPressure); + * + * Mixer glycolMixer = new Mixer("glycol injection mixer"); + * glycolMixer.addStream(firstStageCompressor.getOutStream()); + * glycolMixer.addStream(glycolFeedStream); + * + * Cooler mixerAfterCooler = new Cooler("glycol mixer after cooler", + * glycolMixer.getOutStream()); mixerAfterCooler.setOutTemperature(glycolScrubberTemperature + + * 273.15); + * + * glycolScrubber = new Separator("Water dew point control scrubber", + * mixerAfterCooler.getOutStream()); + * + * secondStageCompressor = new Compressor("2nd stage compressor", + * glycolScrubber.getGasOutStream()); + * secondStageCompressor.setOutletPressure(secondStageOutPressure); + * + * secondStageAfterCooler = new Cooler("second stage after cooler", + * secondStageCompressor.getOutStream()); + * secondStageAfterCooler.setOutTemperature(exportGasTemperature + 273.15); + * + * getOperations().add(inletCooler); getOperations().add(inletSeparator); + * getOperations().add(gasCooler); getOperations().add(oilPump); + * getOperations().add(gasScrubber); getOperations().add(HPliquidRecycle); + * getOperations().add(firstStageCompressor); getOperations().add(glycolMixer); + * getOperations().add(mixerAfterCooler); getOperations().add(glycolScrubber); + * getOperations().add(secondStageCompressor); getOperations().add(secondStageAfterCooler); + * + */ + } - /** {@inheritDoc} */ - @Override - public void displayResult() { - System.out.println("compressor power " + compressor1.getEnergy()); - System.out.println("expander power " + expander.getEnergy()); - valve1.displayResult(); + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + if (!isInitializedModule) { + initializeModule(); } - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos(273.15 + 7.5, 110.0); - - testSystem.addComponent("CO2", 0.0218295567233988); - testSystem.addComponent("nitrogen", 0.00739237702184805); - testSystem.addComponent("methane", 0.831767017569769); - testSystem.addComponent("ethane", 0.0790893243389708); - testSystem.addComponent("propane", 0.0378546917300062); - testSystem.addComponent("i-butane", 0.00543253464081659); - testSystem.addComponent("n-butane", 0.0095144918510181); - testSystem.addComponent("i-pentane", 0.00207801067169675); - testSystem.addComponent("n-pentane", 0.00211497210679094); - testSystem.addComponent("n-hexane", 0.000512675581812218); - testSystem.addComponent("n-heptane", 0.000205410042894726); - testSystem.addComponent("n-octane", 0.000677697183000435); - - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - - Stream feedStream = new Stream("Well stream", testSystem); - feedStream.getThermoSystem().setTotalFlowRate(5, "MSm^3/hr"); - - // feedStream.addAnalogMeasurement("Name", "type"); - // feedStream.addAlarm("type", );.. - DPCUModule dpcuModule = new DPCUModule("dpcuModule"); - dpcuModule.addInputStream("feed stream", feedStream); - dpcuModule.setSpecification("pressure after reduction valve", 108.0); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(feedStream); - operations.add(dpcuModule); - operations.run(); - - dpcuModule.getOutputStream("gas exit stream").displayResult(); - dpcuModule.getOutputStream("oil exit stream").displayResult(); - dpcuModule.getOutputStream("gas from dist column").displayResult(); - dpcuModule.getOutputStream("liquid from dist column").displayResult(); - - dpcuModule.displayResult(); - // dpcuModule.getOutputStream("gasmixer").displayResult(); + getOperations().run(id); + + gasExitStream = compressor1.getOutletStream(); + gasExitStream.setCalculationIdentifier(id); + + oilExitStream = LTseparator.getLiquidOutStream(); + oilExitStream.setCalculationIdentifier(id); + + gasDistColumnExit = distColumn.getGasOutStream(); + gasDistColumnExit.setCalculationIdentifier(id); + + liquidDistColumnExit = distColumn.getLiquidOutStream(); + liquidDistColumnExit.setCalculationIdentifier(id); + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public void initializeStreams() { + isInitializedStreams = true; + } + + /** {@inheritDoc} */ + @Override + public void calcDesign() { + // design is done here + } + + /** {@inheritDoc} */ + @Override + public void setDesign() { + // set design is done here + } + + /** {@inheritDoc} */ + @Override + public void setSpecification(String specificationName, double value) { + if (specificationName.equals("pressure after reduction valve")) { + pressureAfterRedValve = value; + } else if (specificationName.equals("gas scrubber temperature")) { + gasScrubberTemperature = value; } + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + System.out.println("compressor power " + compressor1.getEnergy()); + System.out.println("expander power " + expander.getEnergy()); + valve1.displayResult(); + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos(273.15 + 7.5, 110.0); + + testSystem.addComponent("CO2", 0.0218295567233988); + testSystem.addComponent("nitrogen", 0.00739237702184805); + testSystem.addComponent("methane", 0.831767017569769); + testSystem.addComponent("ethane", 0.0790893243389708); + testSystem.addComponent("propane", 0.0378546917300062); + testSystem.addComponent("i-butane", 0.00543253464081659); + testSystem.addComponent("n-butane", 0.0095144918510181); + testSystem.addComponent("i-pentane", 0.00207801067169675); + testSystem.addComponent("n-pentane", 0.00211497210679094); + testSystem.addComponent("n-hexane", 0.000512675581812218); + testSystem.addComponent("n-heptane", 0.000205410042894726); + testSystem.addComponent("n-octane", 0.000677697183000435); + + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + + Stream feedStream = new Stream("Well stream", testSystem); + feedStream.getThermoSystem().setTotalFlowRate(5, "MSm^3/hr"); + + // feedStream.addAnalogMeasurement("Name", "type"); + // feedStream.addAlarm("type", );.. + DPCUModule dpcuModule = new DPCUModule("dpcuModule"); + dpcuModule.addInputStream("feed stream", feedStream); + dpcuModule.setSpecification("pressure after reduction valve", 108.0); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(feedStream); + operations.add(dpcuModule); + operations.run(); + + dpcuModule.getOutputStream("gas exit stream").displayResult(); + dpcuModule.getOutputStream("oil exit stream").displayResult(); + dpcuModule.getOutputStream("gas from dist column").displayResult(); + dpcuModule.getOutputStream("liquid from dist column").displayResult(); + + dpcuModule.displayResult(); + // dpcuModule.getOutputStream("gasmixer").displayResult(); + } } diff --git a/src/main/java/neqsim/processSimulation/processSystem/processModules/GlycolDehydrationlModule.java b/src/main/java/neqsim/processSimulation/processSystem/processModules/GlycolDehydrationlModule.java index 38dfa7b550..816a8245a0 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/processModules/GlycolDehydrationlModule.java +++ b/src/main/java/neqsim/processSimulation/processSystem/processModules/GlycolDehydrationlModule.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processSystem.processModules; +import java.util.UUID; import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; import neqsim.processSimulation.processEquipment.absorber.SimpleTEGAbsorber; import neqsim.processSimulation.processEquipment.heatExchanger.Cooler; @@ -21,506 +22,502 @@ * @version $Id: $Id */ public class GlycolDehydrationlModule extends ProcessModuleBaseClass { - private static final long serialVersionUID = 1000; - - protected StreamInterface gasStreamToAbsorber = null, strippingGas = null, - gasStreamFromAbsorber = null, gasFromStripper = null, leanTEGStreamToAbsorber = null; - protected SimpleTEGAbsorber absorbtionColumn = null; - // protected DistillationColumn stripperColumn = null; - protected Separator stripperColumn = null; - Heater reboiler = null; - protected Pump HPpump = null; - protected Separator glycolFlashDrum = null, waterSeparator = null; - protected ThrottlingValve valveHP = null, valveMP = null; - Cooler heatExchanger1 = null, heatExchanger2 = null, heatExchanger3 = null; - double waterDewPontSpecification = 273.15 - 10.0; - double numberOfTheoreticalEquilibriumStages = 2; - private double flashPressure = 5.0; - double designStandardGasFlowRate = 20.0, maxAbsorberDesignPressure = 70.0; - double designGasFeedTemperature = 273.15 + 30.0; - double leanGlycolMolarFraction = 0.95, leanGlycolwtFraction = 0.99, - leanGlycolMolarFlowRate = 1.0, maxglycolFlowRate = 1; - String glycolTypeName = "TEG"; - double reboilerTemperature = 273.15 + 204.0, regenerationPressure = 1.4; - - public GlycolDehydrationlModule(String name) { - super(name); + private static final long serialVersionUID = 1000; + + protected StreamInterface gasStreamToAbsorber = null, strippingGas = null, + gasStreamFromAbsorber = null, gasFromStripper = null, leanTEGStreamToAbsorber = null; + protected SimpleTEGAbsorber absorbtionColumn = null; + // protected DistillationColumn stripperColumn = null; + protected Separator stripperColumn = null; + Heater reboiler = null; + protected Pump HPpump = null; + protected Separator glycolFlashDrum = null, waterSeparator = null; + protected ThrottlingValve valveHP = null, valveMP = null; + Cooler heatExchanger1 = null, heatExchanger2 = null, heatExchanger3 = null; + double waterDewPontSpecification = 273.15 - 10.0; + double numberOfTheoreticalEquilibriumStages = 2; + private double flashPressure = 5.0; + double designStandardGasFlowRate = 20.0, maxAbsorberDesignPressure = 70.0; + double designGasFeedTemperature = 273.15 + 30.0; + double leanGlycolMolarFraction = 0.95, leanGlycolwtFraction = 0.99, leanGlycolMolarFlowRate = 1.0, + maxglycolFlowRate = 1; + String glycolTypeName = "TEG"; + double reboilerTemperature = 273.15 + 204.0, regenerationPressure = 1.4; + + public GlycolDehydrationlModule(String name) { + super(name); + } + + /** {@inheritDoc} */ + @Override + public void addInputStream(String streamName, StreamInterface stream) { + if (streamName.equals("gasStreamToAbsorber")) { + this.gasStreamToAbsorber = stream; + this.strippingGas = stream.clone(); } - - /** {@inheritDoc} */ - @Override - public void addInputStream(String streamName, StreamInterface stream) { - if (streamName.equals("gasStreamToAbsorber")) { - this.gasStreamToAbsorber = stream; - this.strippingGas = stream.clone(); - } - if (streamName.equals("strippingGas")) { - this.strippingGas = stream; - } + if (streamName.equals("strippingGas")) { + this.strippingGas = stream; } + } - /** {@inheritDoc} */ - @Override - public StreamInterface getOutputStream(String streamName) { - if (!isInitializedStreams) { - initializeStreams(); - } - if (streamName.equals("gasStreamFromAbsorber")) { - return this.gasStreamFromAbsorber; - } - if (streamName.equals("liquidFromStripper")) { - return this.stripperColumn.getLiquidOutStream(); - } - if (streamName.equals("liquidFromStripper")) { - return this.stripperColumn.getLiquidOutStream(); - } - if (streamName.equals("condenserStripper")) { - return this.stripperColumn.getGasOutStream(); - } else { - return null; - } + /** {@inheritDoc} */ + @Override + public StreamInterface getOutputStream(String streamName) { + if (!isInitializedStreams) { + initializeStreams(); } - - /** - *

- * solveAbsorptionFactor. - *

- * - * @param Ea a double - * @return a double - */ - public double solveAbsorptionFactor(double Ea) { - double A = 7.0, Aold = 7.0; - double error = 1.0, errorOld = 1.0; - int iter = 0; - do { - iter++; - errorOld = error; - error = (Math.pow(A, numberOfTheoreticalEquilibriumStages + 1.0) - A) - / (Math.pow(A, numberOfTheoreticalEquilibriumStages + 1.0) - 1) - Ea; - - double dErrordA = (error - errorOld) / (A - Aold); - Aold = A; - if (iter > 2) { - A -= error / dErrordA; - } else { - A += error; - } - } while (Math.abs(error) > 1e-6 && iter < 100); - return A; + if (streamName.equals("gasStreamFromAbsorber")) { + return this.gasStreamFromAbsorber; } - - /** {@inheritDoc} */ - @Override - public void run() { - if (!isInitializedStreams) { - initializeStreams(); - } - if (!isInitializedModule) { - initializeModule(); - } - if (!isCalcDesign()) { - calcDesign(); - } - getOperations().run(); + if (streamName.equals("liquidFromStripper")) { + return this.stripperColumn.getLiquidOutStream(); } - - /** {@inheritDoc} */ - @Override - public void initializeStreams() { - isInitializedStreams = true; - try { - this.gasStreamFromAbsorber = this.gasStreamToAbsorber.clone(); - this.gasStreamFromAbsorber.setName("Stream from TEG Absorber"); - - this.gasFromStripper = this.gasStreamToAbsorber.clone(); - this.gasFromStripper.setName("Gas stream from Stripper"); - - this.leanTEGStreamToAbsorber = this.gasStreamToAbsorber.clone(); - this.leanTEGStreamToAbsorber.setName("lean TEG to absorber"); - - this.leanTEGStreamToAbsorber.getThermoSystem().setEmptyFluid(); - this.leanTEGStreamToAbsorber.getThermoSystem().addComponent("water", - leanGlycolMolarFlowRate * (1.0 - leanGlycolMolarFraction)); - this.leanTEGStreamToAbsorber.getThermoSystem().addComponent("TEG", - leanGlycolMolarFlowRate * leanGlycolMolarFraction); - this.leanTEGStreamToAbsorber.getThermoSystem().setTotalFlowRate(maxglycolFlowRate, - "kg/hr"); - } catch (Exception e) { - e.printStackTrace(); - } + if (streamName.equals("liquidFromStripper")) { + return this.stripperColumn.getLiquidOutStream(); } - - /** {@inheritDoc} */ - @Override - public void initializeModule() { - if (!isInitializedStreams) { - initializeStreams(); - } - isInitializedModule = true; - - absorbtionColumn = new SimpleTEGAbsorber("absorbtionColumn"); - absorbtionColumn.addGasInStream(gasStreamToAbsorber); - absorbtionColumn.addSolventInStream(leanTEGStreamToAbsorber); - - valveHP = new ThrottlingValve("valveHP", absorbtionColumn.getLiquidOutStream()); - valveHP.setOutletPressure(flashPressure); - - glycolFlashDrum = new Separator("flash drum", valveHP.getOutletStream()); - - valveMP = new ThrottlingValve("valveMP", glycolFlashDrum.getLiquidOutStream()); - valveMP.setOutletPressure(regenerationPressure); - - /* - * stripperColumn = new DistillationColumn(5, true, false); - * stripperColumn.addFeedStream(valveMP.getOutStream(), 3); - * stripperColumn.setCondenserTemperature(273.15 + 80.0); ((Reboiler) - * stripperColumn.getReboiler()).setRefluxRatio(11.7); - * - */ - - Heater reboiler = new Heater("reboiler", valveMP.getOutletStream()); - reboiler.setOutTemperature(reboilerTemperature); - - strippingGas.setTemperature(reboilerTemperature, "K"); - strippingGas.setPressure(regenerationPressure, "bara"); - stripperColumn = new Separator("stripperColumn", reboiler.getOutletStream()); - stripperColumn.addStream(strippingGas); - - heatExchanger1 = new Cooler("heatExchanger1", stripperColumn.getLiquidOutStream()); - heatExchanger1.setOutTemperature(100.0); - - HPpump = new Pump("HP lean TEG pump", heatExchanger1.getOutletStream()); - HPpump.setOutletPressure(gasStreamToAbsorber.getPressure()); - - heatExchanger2 = new Cooler("heatExchanger2", HPpump.getOutletStream()); - heatExchanger2.setOutTemperature(273.15 + 40.0); - - heatExchanger3 = new Cooler("heatExchanger3", stripperColumn.getGasOutStream()); - heatExchanger3.setOutTemperature(273.15 + 30.0); - - waterSeparator = new Separator("watersep", heatExchanger3.getOutletStream()); - - // leanTEGStreamToAbsorber = heatExchanger2.getOutStream(); - // getOperations().add(gasStreamToAbsorber); - getOperations().add(leanTEGStreamToAbsorber); - getOperations().add(absorbtionColumn); - // getOperations().add(gasStreamFromAbsorber); - getOperations().add(valveHP); - getOperations().add(glycolFlashDrum); - getOperations().add(valveMP); - getOperations().add(reboiler); - getOperations().add(stripperColumn); - - getOperations().add(heatExchanger1); - getOperations().add(HPpump); - getOperations().add(heatExchanger2); - getOperations().add(heatExchanger3); - getOperations().add(waterSeparator); - - // operations.add(leanTEGStreamToAbsorber); + if (streamName.equals("condenserStripper")) { + return this.stripperColumn.getGasOutStream(); + } else { + return null; } - - /** {@inheritDoc} */ - @Override - public void setProperty(String specificationName, double value, String unit) { - if (unit == "") { - setProperty(specificationName, value); - } else { - setProperty(specificationName, value); - } + } + + /** + *

+ * solveAbsorptionFactor. + *

+ * + * @param Ea a double + * @return a double + */ + public double solveAbsorptionFactor(double Ea) { + double A = 7.0, Aold = 7.0; + double error = 1.0, errorOld = 1.0; + int iter = 0; + do { + iter++; + errorOld = error; + error = (Math.pow(A, numberOfTheoreticalEquilibriumStages + 1.0) - A) + / (Math.pow(A, numberOfTheoreticalEquilibriumStages + 1.0) - 1) - Ea; + + double dErrordA = (error - errorOld) / (A - Aold); + Aold = A; + if (iter > 2) { + A -= error / dErrordA; + } else { + A += error; + } + } while (Math.abs(error) > 1e-6 && iter < 100); + return A; + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + if (!isInitializedStreams) { + initializeStreams(); } - - /** {@inheritDoc} */ - @Override - public void setProperty(String specificationName, double value) { - if (specificationName.equals("water dew point specification")) { - waterDewPontSpecification = value; - } - if (specificationName.equals("number of theoretical stages")) { - numberOfTheoreticalEquilibriumStages = value; - } - if (specificationName.equals("designStandardGasFlowRate")) { - designStandardGasFlowRate = value; - } - if (specificationName.equals("designGasFeedTemperature")) { - designGasFeedTemperature = value; - } - if (specificationName.equals("maxAbsorberDesignPressure")) { - maxAbsorberDesignPressure = value; - } - if (specificationName.equals("maxglycolFlowRate")) { - maxglycolFlowRate = value; - } - if (specificationName.equals("flashPressure")) { - flashPressure = value; - } - if (specificationName.equals("reboilerTemperature")) { - reboilerTemperature = value; - } - if (specificationName.equals("regenerationPressure")) { - regenerationPressure = value; - } + if (!isInitializedModule) { + initializeModule(); } - - /** - *

- * calcGlycolConcentration. - *

- * - * @param y0 a double - * @return a double - */ - public double calcGlycolConcentration(double y0) { - Stream tempStream = (Stream) this.gasStreamToAbsorber.clone(); - tempStream.run(); - - double dn = 1.0 * tempStream.getThermoSystem().getPhase(0).getComponent("water") - .getNumberOfMolesInPhase(); - double error = 1.0, oldError = 0.0; - double oldNumberOfMoles = 0.0, numberOfMoles = 0.0; - int iter = 0; - do { - iter++; - oldNumberOfMoles = numberOfMoles; - tempStream.getThermoSystem().addComponent("TEG", dn); - tempStream.run(); - numberOfMoles = - tempStream.getThermoSystem().getPhase(0).getComponent("TEG").getNumberOfmoles(); - oldError = error; - error = (tempStream.getThermoSystem().getPhase(0).getComponent("water").getx() - y0);// / - // y0; - - double derrordn = (error - oldError) / (numberOfMoles - oldNumberOfMoles); - if (iter < 2) { - dn = error; - } else { - dn = -error / derrordn; - } - System.out.println("error " + error); - } while (Math.abs(error) > 1e-8 && iter < 100); - leanGlycolMolarFraction = - tempStream.getThermoSystem().getPhase(1).getComponent("TEG").getx(); - leanGlycolwtFraction = tempStream.getThermoSystem().getPhase(1).getComponent("TEG").getx() - * tempStream.getThermoSystem().getPhase(1).getComponent("TEG").getMolarMass() - / tempStream.getThermoSystem().getPhase(1).getMolarMass(); - - return leanGlycolwtFraction; + if (!isCalcDesign()) { + calcDesign(); } - - /** - *

- * calcKglycol. - *

- * - * @return a double - */ - public double calcKglycol() { - Stream tempStream = (Stream) this.gasStreamToAbsorber.clone(); - tempStream.getThermoSystem().addComponent("TEG", 5.0 * tempStream.getThermoSystem() - .getPhase(0).getComponent("water").getNumberOfMolesInPhase()); - tempStream.run(); - double activityCoefficientTEG = - tempStream.getThermoSystem().getPhase(1).getActivityCoefficient(tempStream - .getThermoSystem().getPhase(1).getComponent("water").getComponentNumber()); - double K = tempStream.getThermoSystem().getPhase(0).getComponent("water").getx() - / (tempStream.getThermoSystem().getPhase(1).getComponent("water").getx() - * activityCoefficientTEG); - - return K; + getOperations().run(id); + + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public void initializeStreams() { + isInitializedStreams = true; + try { + this.gasStreamFromAbsorber = this.gasStreamToAbsorber.clone(); + this.gasStreamFromAbsorber.setName("Stream from TEG Absorber"); + + this.gasFromStripper = this.gasStreamToAbsorber.clone(); + this.gasFromStripper.setName("Gas stream from Stripper"); + + this.leanTEGStreamToAbsorber = this.gasStreamToAbsorber.clone(); + this.leanTEGStreamToAbsorber.setName("lean TEG to absorber"); + + this.leanTEGStreamToAbsorber.getThermoSystem().setEmptyFluid(); + this.leanTEGStreamToAbsorber.getThermoSystem().addComponent("water", + leanGlycolMolarFlowRate * (1.0 - leanGlycolMolarFraction)); + this.leanTEGStreamToAbsorber.getThermoSystem().addComponent("TEG", + leanGlycolMolarFlowRate * leanGlycolMolarFraction); + this.leanTEGStreamToAbsorber.getThermoSystem().setTotalFlowRate(maxglycolFlowRate, "kg/hr"); + } catch (Exception e) { + e.printStackTrace(); } + } - /** {@inheritDoc} */ - @Override - public void displayResult() { - gasStreamFromAbsorber.getThermoSystem().display(); - leanTEGStreamToAbsorber.displayResult(); - glycolFlashDrum.displayResult(); - heatExchanger2.displayResult(); - waterSeparator.displayResult(); + /** {@inheritDoc} */ + @Override + public void initializeModule() { + if (!isInitializedStreams) { + initializeStreams(); } + isInitializedModule = true; - /** {@inheritDoc} */ - @Override - public void calcDesign() { - setIsCalcDesign(true); - double yN = gasStreamToAbsorber.getThermoSystem().getPhase(0).getComponent("water").getx(); - - // Estimates K value - double K = calcKglycol();// gasStreamToAbsorber.getThermoSystem().getPhase(1).getComponent("water").getFugacityCoefficient() - // / - // gasStreamToAbsorber.getThermoSystem().getPhase(0).getComponent("water").getFugacityCoefficient(); - gasStreamFromAbsorber = gasStreamToAbsorber.clone(); - // gasStreamFromAbsorber.getThermoSystem().addComponent("water", 1.0); - gasStreamFromAbsorber.getThermoSystem().setTemperature(waterDewPontSpecification); - gasStreamFromAbsorber.run(); - double y1 = - gasStreamFromAbsorber.getThermoSystem().getPhase(0).getComponent("water").getx(); - gasStreamFromAbsorber.getThermoSystem().setTemperature(waterDewPontSpecification - 10.0); - gasStreamFromAbsorber.run(); - double y0 = - gasStreamFromAbsorber.getThermoSystem().getPhase(0).getComponent("water").getx(); - gasStreamFromAbsorber.run(); - calcGlycolConcentration(y0); - - double Ea = (yN - y1) / (yN - y0); - - double absorptionFactor = solveAbsorptionFactor(Ea); - leanGlycolMolarFlowRate = - absorptionFactor * K * designStandardGasFlowRate * 42.28981 / 24.0 / 3600; // kg - // TEG/hr - // gasStreamFromAbsorber.displayResult(); - // double kgWater = - // gasStreamToAbsorber.getThermoSystem().getPhase(0).getComponent("water").getx() - // * designStandardGasFlowRate*1e6 * 42.28981 / 24.0 /3600 * - // gasStreamFromAbsorber.getThermoSystem().getPhase(0).getComponent("water").getMolarMass(); - // double kgTEGperkgWater = leanGlycolMolarFlowRate / kgWater; - - gasStreamFromAbsorber.getThermoSystem().removePhase(1); - gasStreamFromAbsorber.getThermoSystem().setTemperature(designGasFeedTemperature); - gasStreamFromAbsorber.run(); - /* - * absorbtionColumn.setNumberOfTheoreticalStages( numberOfTheoreticalEquilibriumStages); - * absorbtionColumn.getMechanicalDesign().setMaxDesignGassVolumeFlow( - * designStandardGasFlowRate); - * absorbtionColumn.getMechanicalDesign().setMaxDesignVolumeFlow( - * designStandardGasFlowRate); - * absorbtionColumn.getMechanicalDesign().setMaxOperationPressure( - * maxAbsorberDesignPressure); absorbtionColumn.getMechanicalDesign().calcDesign(); - */ - this.leanTEGStreamToAbsorber.getThermoSystem().setEmptyFluid(); - this.leanTEGStreamToAbsorber.getThermoSystem().addComponent("methane", 1e-15); - this.leanTEGStreamToAbsorber.getThermoSystem().addComponent("water", - leanGlycolMolarFlowRate * (1.0 - leanGlycolMolarFraction)); - this.leanTEGStreamToAbsorber.getThermoSystem().addComponent("TEG", - leanGlycolMolarFlowRate * leanGlycolMolarFraction); - this.leanTEGStreamToAbsorber.run(); - } + absorbtionColumn = new SimpleTEGAbsorber("absorbtionColumn"); + absorbtionColumn.addGasInStream(gasStreamToAbsorber); + absorbtionColumn.addSolventInStream(leanTEGStreamToAbsorber); - /** {@inheritDoc} */ - @Override - public void setDesign() { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkCPAstatoil((273.15 + 40.0), 1.0); - testSystem.addComponent("water", leanGlycolMolarFlowRate * (1.0 - leanGlycolMolarFraction)); - testSystem.addComponent("TEG", leanGlycolMolarFlowRate * leanGlycolMolarFraction); - testSystem.setMixingRule(9); - this.leanTEGStreamToAbsorber.setThermoSystem(testSystem); - this.leanTEGStreamToAbsorber.run(); - // this.leanTEGStreamToAbsorber.displayResult(); - - absorbtionColumn.getMechanicalDesign().setDesign(); - } + valveHP = new ThrottlingValve("valveHP", absorbtionColumn.getLiquidOutStream()); + valveHP.setOutletPressure(flashPressure); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkCPAstatoil((273.15 + 40.0), 70.0); - - testSystem.addComponent("methane", 100.0); - testSystem.addComponent("water", 0.1); - testSystem.addComponent("TEG", 0.0); - - testSystem.createDatabase(true); - testSystem.setMultiPhaseCheck(true); - testSystem.setMixingRule(10); - testSystem.setTotalFlowRate(5, "MSm^3/day"); - - Stream gasinletStream = new Stream("gasinletStream", testSystem); - - neqsim.thermo.system.SystemInterface strippingGasSystem = - new neqsim.thermo.system.SystemSrkCPAstatoil((273.15 + 40.0), 70.0); - - strippingGasSystem.addComponent("methane", 1.0); - strippingGasSystem.addComponent("water", 0); - strippingGasSystem.addComponent("TEG", 0); - - strippingGasSystem.createDatabase(true); - strippingGasSystem.setMultiPhaseCheck(true); - strippingGasSystem.setMixingRule(10); - strippingGasSystem.setTotalFlowRate(0.005, "MSm^3/day"); - - Stream strippingGasStream = new Stream("strippingGasStream", strippingGasSystem); - - StreamSaturatorUtil saturator = new StreamSaturatorUtil("saturator", gasinletStream); - - Separator separator = new Separator("Separator 1", saturator.getOutletStream()); - - neqsim.processSimulation.processSystem.processModules.GlycolDehydrationlModule TEGplant = - new neqsim.processSimulation.processSystem.processModules.GlycolDehydrationlModule("TEGplant"); - TEGplant.addInputStream("gasStreamToAbsorber", saturator.getOutletStream()); - TEGplant.addInputStream("strippingGas", strippingGasStream); - TEGplant.setSpecification("water dew point specification", 273.15 - 10.0); - TEGplant.setSpecification("number of theoretical stages", 1.5); - TEGplant.setSpecification("maxAbsorberDesignPressure", 70.0); - TEGplant.setSpecification("designStandardGasFlowRate", 5.0e6); - TEGplant.setSpecification("maxglycolFlowRate", 10.0); - TEGplant.setSpecification("designGasFeedTemperature", 273.15 + 30); - TEGplant.setSpecification("flashPressure", 5.0); - TEGplant.setSpecification("regenerationPressure", 1.21325); - TEGplant.setSpecification("reboilerTemperature", 273.15 + 205.0); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(gasinletStream); - operations.add(saturator); - // operations.add(separator); - operations.add(TEGplant); - - operations.run(); - saturator.getOutletStream().displayResult(); - separator.getThermoSystem().display(); - ((ProcessEquipmentBaseClass) operations.getUnit("reboiler")).run(); - // separator.getGasOutStream().displayResult(); - // TEGplant.displayResult(); - // TEGplant.calcDesign(); - // TEGplant.setDesign(); - TEGplant.getOutputStream("gasStreamFromAbsorber").displayResult(); - - TEGplant.getOutputStream("liquidFromStripper").run(); - TEGplant.getOutputStream("liquidFromStripper").displayResult(); - System.out.println("wt TEG " + TEGplant.getOutputStream("liquidFromStripper").getFluid() - .getPhase(0).getWtFrac("TEG")); - System.out.println("reboiler duty " - + ((Heater) operations.getUnit("reboiler")).getDuty() / 1000.0 + " kW"); - System.out.println("Lean TEG flow " - + ((Pump) operations.getUnit("HP lean TEG pump")).getFluid().getFlowRate("kg/hr") - + " kg/hr"); - System.out.println("Lean TEG pump power " - + ((Pump) operations.getUnit("HP lean TEG pump")).getPower() / 1000.0 + " kW"); - - ((Separator) operations.getUnit("flash drum")).displayResult(); - ((Separator) operations.getUnit("watersep")).displayResult(); - ((ProcessEquipmentBaseClass) operations.getUnit("reboiler")).run(); - ((ProcessEquipmentBaseClass) operations.getUnit("reboiler")).displayResult(); - // TEGplant.getOutputStream("condenserStripper").displayResult(); - } + glycolFlashDrum = new Separator("flash drum", valveHP.getOutletStream()); - /** - *

- * Getter for the field flashPressure. - *

- * - * @return a double + valveMP = new ThrottlingValve("valveMP", glycolFlashDrum.getLiquidOutStream()); + valveMP.setOutletPressure(regenerationPressure); + + /* + * stripperColumn = new DistillationColumn(5, true, false); + * stripperColumn.addFeedStream(valveMP.getOutStream(), 3); + * stripperColumn.setCondenserTemperature(273.15 + 80.0); ((Reboiler) + * stripperColumn.getReboiler()).setRefluxRatio(11.7); + * */ - public double getFlashPressure() { - return flashPressure; + + Heater reboiler = new Heater("reboiler", valveMP.getOutletStream()); + reboiler.setOutTemperature(reboilerTemperature); + + strippingGas.setTemperature(reboilerTemperature, "K"); + strippingGas.setPressure(regenerationPressure, "bara"); + stripperColumn = new Separator("stripperColumn", reboiler.getOutletStream()); + stripperColumn.addStream(strippingGas); + + heatExchanger1 = new Cooler("heatExchanger1", stripperColumn.getLiquidOutStream()); + heatExchanger1.setOutTemperature(100.0); + + HPpump = new Pump("HP lean TEG pump", heatExchanger1.getOutletStream()); + HPpump.setOutletPressure(gasStreamToAbsorber.getPressure()); + + heatExchanger2 = new Cooler("heatExchanger2", HPpump.getOutletStream()); + heatExchanger2.setOutTemperature(273.15 + 40.0); + + heatExchanger3 = new Cooler("heatExchanger3", stripperColumn.getGasOutStream()); + heatExchanger3.setOutTemperature(273.15 + 30.0); + + waterSeparator = new Separator("watersep", heatExchanger3.getOutletStream()); + + // leanTEGStreamToAbsorber = heatExchanger2.getOutStream(); + // getOperations().add(gasStreamToAbsorber); + getOperations().add(leanTEGStreamToAbsorber); + getOperations().add(absorbtionColumn); + // getOperations().add(gasStreamFromAbsorber); + getOperations().add(valveHP); + getOperations().add(glycolFlashDrum); + getOperations().add(valveMP); + getOperations().add(reboiler); + getOperations().add(stripperColumn); + + getOperations().add(heatExchanger1); + getOperations().add(HPpump); + getOperations().add(heatExchanger2); + getOperations().add(heatExchanger3); + getOperations().add(waterSeparator); + + // operations.add(leanTEGStreamToAbsorber); + } + + /** {@inheritDoc} */ + @Override + public void setProperty(String specificationName, double value, String unit) { + if (unit == "") { + setProperty(specificationName, value); + } else { + setProperty(specificationName, value); } + } - /** - *

- * Setter for the field flashPressure. - *

- * - * @param flashPressure a double - */ - public void setFlashPressure(double flashPressure) { - this.flashPressure = flashPressure; + /** {@inheritDoc} */ + @Override + public void setProperty(String specificationName, double value) { + if (specificationName.equals("water dew point specification")) { + waterDewPontSpecification = value; + } + if (specificationName.equals("number of theoretical stages")) { + numberOfTheoreticalEquilibriumStages = value; + } + if (specificationName.equals("designStandardGasFlowRate")) { + designStandardGasFlowRate = value; } + if (specificationName.equals("designGasFeedTemperature")) { + designGasFeedTemperature = value; + } + if (specificationName.equals("maxAbsorberDesignPressure")) { + maxAbsorberDesignPressure = value; + } + if (specificationName.equals("maxglycolFlowRate")) { + maxglycolFlowRate = value; + } + if (specificationName.equals("flashPressure")) { + flashPressure = value; + } + if (specificationName.equals("reboilerTemperature")) { + reboilerTemperature = value; + } + if (specificationName.equals("regenerationPressure")) { + regenerationPressure = value; + } + } + + /** + *

+ * calcGlycolConcentration. + *

+ * + * @param y0 a double + * @return a double + */ + public double calcGlycolConcentration(double y0) { + Stream tempStream = (Stream) this.gasStreamToAbsorber.clone(); + tempStream.run(); + + double dn = 1.0 + * tempStream.getThermoSystem().getPhase(0).getComponent("water").getNumberOfMolesInPhase(); + double error = 1.0, oldError = 0.0; + double oldNumberOfMoles = 0.0, numberOfMoles = 0.0; + int iter = 0; + do { + iter++; + oldNumberOfMoles = numberOfMoles; + tempStream.getThermoSystem().addComponent("TEG", dn); + tempStream.run(); + numberOfMoles = + tempStream.getThermoSystem().getPhase(0).getComponent("TEG").getNumberOfmoles(); + oldError = error; + error = (tempStream.getThermoSystem().getPhase(0).getComponent("water").getx() - y0);// / + // y0; + + double derrordn = (error - oldError) / (numberOfMoles - oldNumberOfMoles); + if (iter < 2) { + dn = error; + } else { + dn = -error / derrordn; + } + System.out.println("error " + error); + } while (Math.abs(error) > 1e-8 && iter < 100); + leanGlycolMolarFraction = tempStream.getThermoSystem().getPhase(1).getComponent("TEG").getx(); + leanGlycolwtFraction = tempStream.getThermoSystem().getPhase(1).getComponent("TEG").getx() + * tempStream.getThermoSystem().getPhase(1).getComponent("TEG").getMolarMass() + / tempStream.getThermoSystem().getPhase(1).getMolarMass(); + + return leanGlycolwtFraction; + } + + /** + *

+ * calcKglycol. + *

+ * + * @return a double + */ + public double calcKglycol() { + Stream tempStream = (Stream) this.gasStreamToAbsorber.clone(); + tempStream.getThermoSystem().addComponent("TEG", 5.0 + * tempStream.getThermoSystem().getPhase(0).getComponent("water").getNumberOfMolesInPhase()); + tempStream.run(); + double activityCoefficientTEG = tempStream.getThermoSystem().getPhase(1).getActivityCoefficient( + tempStream.getThermoSystem().getPhase(1).getComponent("water").getComponentNumber()); + double K = tempStream.getThermoSystem().getPhase(0).getComponent("water").getx() + / (tempStream.getThermoSystem().getPhase(1).getComponent("water").getx() + * activityCoefficientTEG); + + return K; + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + gasStreamFromAbsorber.getThermoSystem().display(); + leanTEGStreamToAbsorber.displayResult(); + glycolFlashDrum.displayResult(); + heatExchanger2.displayResult(); + waterSeparator.displayResult(); + } + + /** {@inheritDoc} */ + @Override + public void calcDesign() { + setIsCalcDesign(true); + double yN = gasStreamToAbsorber.getThermoSystem().getPhase(0).getComponent("water").getx(); + + // Estimates K value + double K = calcKglycol();// gasStreamToAbsorber.getThermoSystem().getPhase(1).getComponent("water").getFugacityCoefficient() + // / + // gasStreamToAbsorber.getThermoSystem().getPhase(0).getComponent("water").getFugacityCoefficient(); + gasStreamFromAbsorber = gasStreamToAbsorber.clone(); + // gasStreamFromAbsorber.getThermoSystem().addComponent("water", 1.0); + gasStreamFromAbsorber.getThermoSystem().setTemperature(waterDewPontSpecification); + gasStreamFromAbsorber.run(); + double y1 = gasStreamFromAbsorber.getThermoSystem().getPhase(0).getComponent("water").getx(); + gasStreamFromAbsorber.getThermoSystem().setTemperature(waterDewPontSpecification - 10.0); + gasStreamFromAbsorber.run(); + double y0 = gasStreamFromAbsorber.getThermoSystem().getPhase(0).getComponent("water").getx(); + gasStreamFromAbsorber.run(); + calcGlycolConcentration(y0); + + double Ea = (yN - y1) / (yN - y0); + + double absorptionFactor = solveAbsorptionFactor(Ea); + leanGlycolMolarFlowRate = + absorptionFactor * K * designStandardGasFlowRate * 42.28981 / 24.0 / 3600; // kg + // TEG/hr + // gasStreamFromAbsorber.displayResult(); + // double kgWater = + // gasStreamToAbsorber.getThermoSystem().getPhase(0).getComponent("water").getx() + // * designStandardGasFlowRate*1e6 * 42.28981 / 24.0 /3600 * + // gasStreamFromAbsorber.getThermoSystem().getPhase(0).getComponent("water").getMolarMass(); + // double kgTEGperkgWater = leanGlycolMolarFlowRate / kgWater; + + gasStreamFromAbsorber.getThermoSystem().removePhase(1); + gasStreamFromAbsorber.getThermoSystem().setTemperature(designGasFeedTemperature); + gasStreamFromAbsorber.run(); + /* + * absorbtionColumn.setNumberOfTheoreticalStages( numberOfTheoreticalEquilibriumStages); + * absorbtionColumn.getMechanicalDesign().setMaxDesignGassVolumeFlow( + * designStandardGasFlowRate); absorbtionColumn.getMechanicalDesign().setMaxDesignVolumeFlow( + * designStandardGasFlowRate); absorbtionColumn.getMechanicalDesign().setMaxOperationPressure( + * maxAbsorberDesignPressure); absorbtionColumn.getMechanicalDesign().calcDesign(); + */ + this.leanTEGStreamToAbsorber.getThermoSystem().setEmptyFluid(); + this.leanTEGStreamToAbsorber.getThermoSystem().addComponent("methane", 1e-15); + this.leanTEGStreamToAbsorber.getThermoSystem().addComponent("water", + leanGlycolMolarFlowRate * (1.0 - leanGlycolMolarFraction)); + this.leanTEGStreamToAbsorber.getThermoSystem().addComponent("TEG", + leanGlycolMolarFlowRate * leanGlycolMolarFraction); + this.leanTEGStreamToAbsorber.run(); + } + + /** {@inheritDoc} */ + @Override + public void setDesign() { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkCPAstatoil((273.15 + 40.0), 1.0); + testSystem.addComponent("water", leanGlycolMolarFlowRate * (1.0 - leanGlycolMolarFraction)); + testSystem.addComponent("TEG", leanGlycolMolarFlowRate * leanGlycolMolarFraction); + testSystem.setMixingRule(9); + this.leanTEGStreamToAbsorber.setThermoSystem(testSystem); + this.leanTEGStreamToAbsorber.run(); + // this.leanTEGStreamToAbsorber.displayResult(); + + absorbtionColumn.getMechanicalDesign().setDesign(); + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkCPAstatoil((273.15 + 40.0), 70.0); + + testSystem.addComponent("methane", 100.0); + testSystem.addComponent("water", 0.1); + testSystem.addComponent("TEG", 0.0); + + testSystem.createDatabase(true); + testSystem.setMultiPhaseCheck(true); + testSystem.setMixingRule(10); + testSystem.setTotalFlowRate(5, "MSm^3/day"); + + Stream gasinletStream = new Stream("gasinletStream", testSystem); + + neqsim.thermo.system.SystemInterface strippingGasSystem = + new neqsim.thermo.system.SystemSrkCPAstatoil((273.15 + 40.0), 70.0); + + strippingGasSystem.addComponent("methane", 1.0); + strippingGasSystem.addComponent("water", 0); + strippingGasSystem.addComponent("TEG", 0); + + strippingGasSystem.createDatabase(true); + strippingGasSystem.setMultiPhaseCheck(true); + strippingGasSystem.setMixingRule(10); + strippingGasSystem.setTotalFlowRate(0.005, "MSm^3/day"); + + Stream strippingGasStream = new Stream("strippingGasStream", strippingGasSystem); + + StreamSaturatorUtil saturator = new StreamSaturatorUtil("saturator", gasinletStream); + + Separator separator = new Separator("Separator 1", saturator.getOutletStream()); + + neqsim.processSimulation.processSystem.processModules.GlycolDehydrationlModule TEGplant = + new neqsim.processSimulation.processSystem.processModules.GlycolDehydrationlModule( + "TEGplant"); + TEGplant.addInputStream("gasStreamToAbsorber", saturator.getOutletStream()); + TEGplant.addInputStream("strippingGas", strippingGasStream); + TEGplant.setSpecification("water dew point specification", 273.15 - 10.0); + TEGplant.setSpecification("number of theoretical stages", 1.5); + TEGplant.setSpecification("maxAbsorberDesignPressure", 70.0); + TEGplant.setSpecification("designStandardGasFlowRate", 5.0e6); + TEGplant.setSpecification("maxglycolFlowRate", 10.0); + TEGplant.setSpecification("designGasFeedTemperature", 273.15 + 30); + TEGplant.setSpecification("flashPressure", 5.0); + TEGplant.setSpecification("regenerationPressure", 1.21325); + TEGplant.setSpecification("reboilerTemperature", 273.15 + 205.0); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(gasinletStream); + operations.add(saturator); + // operations.add(separator); + operations.add(TEGplant); + + operations.run(); + saturator.getOutletStream().displayResult(); + separator.getThermoSystem().display(); + ((ProcessEquipmentBaseClass) operations.getUnit("reboiler")).run(); + // separator.getGasOutStream().displayResult(); + // TEGplant.displayResult(); + // TEGplant.calcDesign(); + // TEGplant.setDesign(); + TEGplant.getOutputStream("gasStreamFromAbsorber").displayResult(); + + TEGplant.getOutputStream("liquidFromStripper").run(); + TEGplant.getOutputStream("liquidFromStripper").displayResult(); + System.out.println("wt TEG " + + TEGplant.getOutputStream("liquidFromStripper").getFluid().getPhase(0).getWtFrac("TEG")); + System.out.println( + "reboiler duty " + ((Heater) operations.getUnit("reboiler")).getDuty() / 1000.0 + " kW"); + System.out.println("Lean TEG flow " + + ((Pump) operations.getUnit("HP lean TEG pump")).getFluid().getFlowRate("kg/hr") + + " kg/hr"); + System.out.println("Lean TEG pump power " + + ((Pump) operations.getUnit("HP lean TEG pump")).getPower() / 1000.0 + " kW"); + + ((Separator) operations.getUnit("flash drum")).displayResult(); + ((Separator) operations.getUnit("watersep")).displayResult(); + ((ProcessEquipmentBaseClass) operations.getUnit("reboiler")).run(); + ((ProcessEquipmentBaseClass) operations.getUnit("reboiler")).displayResult(); + // TEGplant.getOutputStream("condenserStripper").displayResult(); + } + + /** + *

+ * Getter for the field flashPressure. + *

+ * + * @return a double + */ + public double getFlashPressure() { + return flashPressure; + } + + /** + *

+ * Setter for the field flashPressure. + *

+ * + * @param flashPressure a double + */ + public void setFlashPressure(double flashPressure) { + this.flashPressure = flashPressure; + } } diff --git a/src/main/java/neqsim/processSimulation/processSystem/processModules/MEGReclaimerModule.java b/src/main/java/neqsim/processSimulation/processSystem/processModules/MEGReclaimerModule.java index 5f34cb272a..141772fb9b 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/processModules/MEGReclaimerModule.java +++ b/src/main/java/neqsim/processSimulation/processSystem/processModules/MEGReclaimerModule.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processSystem.processModules; +import java.util.UUID; import neqsim.processSimulation.processEquipment.heatExchanger.Heater; import neqsim.processSimulation.processEquipment.mixer.Mixer; import neqsim.processSimulation.processEquipment.pump.Pump; @@ -18,168 +19,169 @@ * @version $Id: $Id */ public class MEGReclaimerModule extends ProcessModuleBaseClass { - private static final long serialVersionUID = 1000; - - protected StreamInterface streamToReclaimer = null, streamToWaterRemoval = null, - streamFromBoosterCompressor = null, streamWithWaste = null; - - ThrottlingValve inletValve = null; - Mixer inletMixer = null; - protected Separator flashSeparator = null; - Pump MEGRecircPump = null; - Heater MEGrecircHeater = null; - ThrottlingValve recircValve = null; - Heater vacumCooler = null; - - double reclaimerPressure = 0.17; - - public MEGReclaimerModule(String name) { - super(name); + private static final long serialVersionUID = 1000; + + protected StreamInterface streamToReclaimer = null, streamToWaterRemoval = null, + streamFromBoosterCompressor = null, streamWithWaste = null; + + ThrottlingValve inletValve = null; + Mixer inletMixer = null; + protected Separator flashSeparator = null; + Pump MEGRecircPump = null; + Heater MEGrecircHeater = null; + ThrottlingValve recircValve = null; + Heater vacumCooler = null; + + double reclaimerPressure = 0.17; + + public MEGReclaimerModule(String name) { + super(name); + } + + /** {@inheritDoc} */ + @Override + public void addInputStream(String streamName, StreamInterface stream) { + if (streamName.equals("streamToReclaimer")) { + this.streamToReclaimer = stream; } + } - /** {@inheritDoc} */ - @Override - public void addInputStream(String streamName, StreamInterface stream) { - if (streamName.equals("streamToReclaimer")) { - this.streamToReclaimer = stream; - } + /** {@inheritDoc} */ + @Override + public StreamInterface getOutputStream(String streamName) { + if (!isInitializedStreams) { + initializeStreams(); } - - /** {@inheritDoc} */ - @Override - public StreamInterface getOutputStream(String streamName) { - if (!isInitializedStreams) { - initializeStreams(); - } - if (streamName.equals("streamToWaterRemoval")) { - return this.streamToWaterRemoval; - } else { - return null; - } + if (streamName.equals("streamToWaterRemoval")) { + return this.streamToWaterRemoval; + } else { + return null; } - - /** {@inheritDoc} */ - @Override - public void initializeStreams() { - isInitializedStreams = true; - try { - this.streamToWaterRemoval = (Stream) this.streamToReclaimer.clone(); - this.streamToWaterRemoval.setName("Desalted MEG stream"); - - this.streamFromBoosterCompressor = (Stream) this.streamToReclaimer.clone(); - this.streamFromBoosterCompressor.setName("Stream from Booster Compressor"); - - this.streamWithWaste = (Stream) this.streamToReclaimer.clone(); - this.streamWithWaste.setName("Reclaimer Waste Stream"); - } catch (Exception e) { - e.printStackTrace(); - } + } + + /** {@inheritDoc} */ + @Override + public void initializeStreams() { + isInitializedStreams = true; + try { + this.streamToWaterRemoval = (Stream) this.streamToReclaimer.clone(); + this.streamToWaterRemoval.setName("Desalted MEG stream"); + + this.streamFromBoosterCompressor = (Stream) this.streamToReclaimer.clone(); + this.streamFromBoosterCompressor.setName("Stream from Booster Compressor"); + + this.streamWithWaste = (Stream) this.streamToReclaimer.clone(); + this.streamWithWaste.setName("Reclaimer Waste Stream"); + } catch (Exception e) { + e.printStackTrace(); } + } - /** {@inheritDoc} */ - @Override - public void initializeModule() { - isInitializedModule = true; + /** {@inheritDoc} */ + @Override + public void initializeModule() { + isInitializedModule = true; - inletValve = new ThrottlingValve("inletValve", streamToReclaimer); - inletValve.setOutletPressure(reclaimerPressure); - inletValve.setIsoThermal(true); + inletValve = new ThrottlingValve("inletValve", streamToReclaimer); + inletValve.setOutletPressure(reclaimerPressure); + inletValve.setIsoThermal(true); - inletMixer = new Mixer("inletMixer"); - inletMixer.addStream(inletValve.getOutletStream()); + inletMixer = new Mixer("inletMixer"); + inletMixer.addStream(inletValve.getOutletStream()); - flashSeparator = new Separator("flashSeparator", inletMixer.getOutletStream()); + flashSeparator = new Separator("flashSeparator", inletMixer.getOutletStream()); - MEGRecircPump = new Pump("MEGRecircPump", flashSeparator.getLiquidOutStream()); - MEGRecircPump.setMolarFlow(50.0); - MEGRecircPump.setOutletPressure(5.0); + MEGRecircPump = new Pump("MEGRecircPump", flashSeparator.getLiquidOutStream()); + MEGRecircPump.setMolarFlow(50.0); + MEGRecircPump.setOutletPressure(5.0); - MEGrecircHeater = new Heater("MEGrecircHeater", MEGRecircPump.getOutletStream()); - // MEGrecircHeater.setEnergyInput(5000.0); - MEGrecircHeater.setOutTemperature(273 + 68.9); + MEGrecircHeater = new Heater("MEGrecircHeater", MEGRecircPump.getOutletStream()); + // MEGrecircHeater.setEnergyInput(5000.0); + MEGrecircHeater.setOutTemperature(273 + 68.9); - recircValve = new ThrottlingValve("recircValve", MEGrecircHeater.getOutletStream()); - recircValve.setOutletPressure(reclaimerPressure); - recircValve.setIsoThermal(true); + recircValve = new ThrottlingValve("recircValve", MEGrecircHeater.getOutletStream()); + recircValve.setOutletPressure(reclaimerPressure); + recircValve.setIsoThermal(true); - inletMixer.addStream(recircValve.getOutletStream()); + inletMixer.addStream(recircValve.getOutletStream()); - vacumCooler = new Heater("vacumCooler", flashSeparator.getGasOutStream()); + vacumCooler = new Heater("vacumCooler", flashSeparator.getGasOutStream()); - getOperations().add(streamToReclaimer); - getOperations().add(inletValve); - getOperations().add(inletMixer); - getOperations().add(flashSeparator); - getOperations().add(MEGRecircPump); - getOperations().add(MEGrecircHeater); - getOperations().add(recircValve); - } + getOperations().add(streamToReclaimer); + getOperations().add(inletValve); + getOperations().add(inletMixer); + getOperations().add(flashSeparator); + getOperations().add(MEGRecircPump); + getOperations().add(MEGrecircHeater); + getOperations().add(recircValve); + } - /** {@inheritDoc} */ - @Override - public void run() { - if (!isInitializedModule) { - initializeModule(); - } - for (int i = 0; i < 2; i++) { - getOperations().run(); - flashSeparator.displayResult(); - System.out.println("flow to vacum separator " - + inletMixer.getOutletStream().getThermoSystem().getTotalNumberOfMoles()); - } - - streamToWaterRemoval = flashSeparator.getGasOutStream(); + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + if (!isInitializedModule) { + initializeModule(); } - - /** - *

- * setOperationPressure. - *

- * - * @param pressure a double - */ - public void setOperationPressure(double pressure) { - reclaimerPressure = pressure; - } - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 30.0), 10.0); - - testSystem.addComponent("methane", 0.001); - testSystem.addComponent("CO2", 0.001); - testSystem.addComponent("MEG", 0.3); - testSystem.addComponent("water", 0.7); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - - Stream inletStream = new Stream("inletStream", testSystem); - inletStream.run(); - inletStream.displayResult(); - MEGReclaimerModule reclaimer = new MEGReclaimerModule("reclaimer"); - reclaimer.addInputStream("streamToReclaimer", inletStream); - reclaimer.setOperationPressure(0.17); - - reclaimer.run(); - // reclaimer.displayResult(); + for (int i = 0; i < 2; i++) { + getOperations().run(id); + flashSeparator.displayResult(); + System.out.println("flow to vacuum separator " + + inletMixer.getOutletStream().getThermoSystem().getTotalNumberOfMoles()); } - /** {@inheritDoc} */ - @Override - public void calcDesign() { - // design is done here - } - - /** {@inheritDoc} */ - @Override - public void setDesign() { - // set design is done here - } + streamToWaterRemoval = flashSeparator.getGasOutStream(); + setCalculationIdentifier(id); + } + + /** + *

+ * setOperationPressure. + *

+ * + * @param pressure a double + */ + public void setOperationPressure(double pressure) { + reclaimerPressure = pressure; + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos((273.15 + 30.0), 10.0); + + testSystem.addComponent("methane", 0.001); + testSystem.addComponent("CO2", 0.001); + testSystem.addComponent("MEG", 0.3); + testSystem.addComponent("water", 0.7); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + + Stream inletStream = new Stream("inletStream", testSystem); + inletStream.run(); + inletStream.displayResult(); + MEGReclaimerModule reclaimer = new MEGReclaimerModule("reclaimer"); + reclaimer.addInputStream("streamToReclaimer", inletStream); + reclaimer.setOperationPressure(0.17); + + reclaimer.run(); + // reclaimer.displayResult(); + } + + /** {@inheritDoc} */ + @Override + public void calcDesign() { + // design is done here + } + + /** {@inheritDoc} */ + @Override + public void setDesign() { + // set design is done here + } } diff --git a/src/main/java/neqsim/processSimulation/processSystem/processModules/MixerGasProcessingModule.java b/src/main/java/neqsim/processSimulation/processSystem/processModules/MixerGasProcessingModule.java index 7565caa41b..dec0112a4b 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/processModules/MixerGasProcessingModule.java +++ b/src/main/java/neqsim/processSimulation/processSystem/processModules/MixerGasProcessingModule.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processSystem.processModules; +import java.util.UUID; import neqsim.processSimulation.processEquipment.compressor.Compressor; import neqsim.processSimulation.processEquipment.heatExchanger.Cooler; import neqsim.processSimulation.processEquipment.mixer.Mixer; @@ -20,236 +21,241 @@ * @version $Id: $Id */ public class MixerGasProcessingModule extends ProcessModuleBaseClass { - private static final long serialVersionUID = 1000; - - StreamInterface feedStream, gasExitStream, oilExitStream, glycolFeedStream, glycolExitStream; - Separator glycolScrubber; - Separator inletSeparator; - double inletSepTemperature = 50.00; // bar' - double gasScrubberTemperature = 30.00, firstStageOutPressure = 110.0, - glycolScrubberTemperature = 20.0, secondStageOutPressure = 200.0; // bar - double glycolInjectionRate = 10.0, exportGasTemperature = 273.15 + 30.0, - liquidPumpPressure = 150.0; // m^3/hr - Compressor secondStageCompressor; - Pump oilPump; - Cooler secondStageAfterCooler; - - public MixerGasProcessingModule(String name) { - super(name); + private static final long serialVersionUID = 1000; + + StreamInterface feedStream, gasExitStream, oilExitStream, glycolFeedStream, glycolExitStream; + Separator glycolScrubber; + Separator inletSeparator; + double inletSepTemperature = 50.00; // bar' + double gasScrubberTemperature = 30.00, firstStageOutPressure = 110.0, + glycolScrubberTemperature = 20.0, secondStageOutPressure = 200.0; // bar + double glycolInjectionRate = 10.0, exportGasTemperature = 273.15 + 30.0, + liquidPumpPressure = 150.0; // m^3/hr + Compressor secondStageCompressor; + Pump oilPump; + Cooler secondStageAfterCooler; + + public MixerGasProcessingModule(String name) { + super(name); + } + + /** {@inheritDoc} */ + @Override + public void addInputStream(String streamName, StreamInterface stream) { + if (streamName.equals("feed stream")) { + this.feedStream = stream; } - - /** {@inheritDoc} */ - @Override - public void addInputStream(String streamName, StreamInterface stream) { - if (streamName.equals("feed stream")) { - this.feedStream = stream; - } - if (streamName.equals("glycol feed stream")) { - this.glycolFeedStream = stream; - } - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getOutputStream(String streamName) { - if (!isInitializedStreams) { - initializeStreams(); - } - if (streamName.equals("gas exit stream")) { - return this.gasExitStream; - } else if (streamName.equals("oil exit stream")) { - return this.oilExitStream; - } else if (streamName.equals("glycol exit stream")) { - return this.glycolExitStream; - } else if (streamName.equals("glycol feed stream")) { - return this.glycolFeedStream; - } else { - return null; - } - } - - /** {@inheritDoc} */ - @Override - public void initializeModule() { - isInitializedModule = true; - // double inletPressure = feedStream.getPressure(); - - Cooler inletCooler = new Cooler("inlet well stream cooler", feedStream); - inletCooler.setOutTemperature(inletSepTemperature + 273.15); - - inletSeparator = new Separator("Inlet separator", inletCooler.getOutletStream()); - - Cooler gasCooler = new Cooler("separator gas cooler", inletSeparator.getGasOutStream()); - gasCooler.setOutTemperature(gasScrubberTemperature + 273.15); - - oilPump = new Pump("liquid pump", inletSeparator.getLiquidOutStream()); - oilPump.setOutletPressure(liquidPumpPressure); - - Separator gasScrubber = - new Separator("HC dew point control scrubber", gasCooler.getOutletStream()); - - Recycle HPliquidRecycle = new Recycle("Resycle"); - double tolerance = 1e-2; - HPliquidRecycle.setTolerance(tolerance); - HPliquidRecycle.addStream(gasScrubber.getLiquidOutStream()); - inletSeparator.addStream(HPliquidRecycle.getOutStream()); - - Compressor firstStageCompressor = - new Compressor("1st stage compressor", gasScrubber.getGasOutStream()); - firstStageCompressor.setOutletPressure(firstStageOutPressure); - - glycolFeedStream.getThermoSystem().setPressure(firstStageOutPressure); - - Mixer glycolMixer = new Mixer("glycol injection mixer"); - glycolMixer.addStream(firstStageCompressor.getOutletStream()); - glycolMixer.addStream(glycolFeedStream); - - Cooler mixerAfterCooler = - new Cooler("glycol mixer after cooler", glycolMixer.getOutletStream()); - mixerAfterCooler.setOutTemperature(glycolScrubberTemperature + 273.15); - - glycolScrubber = - new Separator("Water dew point control scrubber", mixerAfterCooler.getOutletStream()); - - secondStageCompressor = - new Compressor("2nd stage compressor", glycolScrubber.getGasOutStream()); - secondStageCompressor.setOutletPressure(secondStageOutPressure); - - secondStageAfterCooler = - new Cooler("second stage after cooler", secondStageCompressor.getOutletStream()); - secondStageAfterCooler.setOutTemperature(exportGasTemperature + 273.15); - - getOperations().add(inletCooler); - getOperations().add(inletSeparator); - getOperations().add(gasCooler); - getOperations().add(oilPump); - getOperations().add(gasScrubber); - getOperations().add(HPliquidRecycle); - getOperations().add(firstStageCompressor); - getOperations().add(glycolMixer); - getOperations().add(mixerAfterCooler); - getOperations().add(glycolScrubber); - getOperations().add(secondStageCompressor); - getOperations().add(secondStageAfterCooler); - } - - /** {@inheritDoc} */ - @Override - public void initializeStreams() { - isInitializedStreams = true; - } - - /** {@inheritDoc} */ - @Override - public void run() { - if (!isInitializedModule) { - initializeModule(); - } - getOperations().run(); - - gasExitStream = secondStageAfterCooler.getOutletStream(); - oilExitStream = oilPump.getOutletStream(); - glycolExitStream = glycolScrubber.getLiquidOutStream(); + if (streamName.equals("glycol feed stream")) { + this.glycolFeedStream = stream; } + } - /** {@inheritDoc} */ - @Override - public void calcDesign() { - // design is done here + /** {@inheritDoc} */ + @Override + public StreamInterface getOutputStream(String streamName) { + if (!isInitializedStreams) { + initializeStreams(); } - - /** {@inheritDoc} */ - @Override - public void setDesign() { - // set design is done here + if (streamName.equals("gas exit stream")) { + return this.gasExitStream; + } else if (streamName.equals("oil exit stream")) { + return this.oilExitStream; + } else if (streamName.equals("glycol exit stream")) { + return this.glycolExitStream; + } else if (streamName.equals("glycol feed stream")) { + return this.glycolFeedStream; + } else { + return null; } - - /** {@inheritDoc} */ - @Override - public void setSpecification(String specificationName, double value) { - if (specificationName.equals("inlet separation temperature")) { - inletSepTemperature = value; - } else if (specificationName.equals("gas scrubber temperature")) { - gasScrubberTemperature = value; - } else if (specificationName.equals("first stage out pressure")) { - firstStageOutPressure = value; - } else if (specificationName.equals("glycol scrubber temperature")) { - glycolScrubberTemperature = value; - } else if (specificationName.equals("second stage out pressure")) { - secondStageOutPressure = value; - } else if (specificationName.equals("export gas temperature")) { - exportGasTemperature = value; - } else if (specificationName.equals("liquid pump out pressure")) { - liquidPumpPressure = value; - } + } + + /** {@inheritDoc} */ + @Override + public void initializeModule() { + isInitializedModule = true; + // double inletPressure = feedStream.getPressure(); + + Cooler inletCooler = new Cooler("inlet well stream cooler", feedStream); + inletCooler.setOutTemperature(inletSepTemperature + 273.15); + + inletSeparator = new Separator("Inlet separator", inletCooler.getOutletStream()); + + Cooler gasCooler = new Cooler("separator gas cooler", inletSeparator.getGasOutStream()); + gasCooler.setOutTemperature(gasScrubberTemperature + 273.15); + + oilPump = new Pump("liquid pump", inletSeparator.getLiquidOutStream()); + oilPump.setOutletPressure(liquidPumpPressure); + + Separator gasScrubber = + new Separator("HC dew point control scrubber", gasCooler.getOutletStream()); + + Recycle HPliquidRecycle = new Recycle("Resycle"); + double tolerance = 1e-2; + HPliquidRecycle.setTolerance(tolerance); + HPliquidRecycle.addStream(gasScrubber.getLiquidOutStream()); + inletSeparator.addStream(HPliquidRecycle.getOutStream()); + + Compressor firstStageCompressor = + new Compressor("1st stage compressor", gasScrubber.getGasOutStream()); + firstStageCompressor.setOutletPressure(firstStageOutPressure); + + glycolFeedStream.getThermoSystem().setPressure(firstStageOutPressure); + + Mixer glycolMixer = new Mixer("glycol injection mixer"); + glycolMixer.addStream(firstStageCompressor.getOutletStream()); + glycolMixer.addStream(glycolFeedStream); + + Cooler mixerAfterCooler = + new Cooler("glycol mixer after cooler", glycolMixer.getOutletStream()); + mixerAfterCooler.setOutTemperature(glycolScrubberTemperature + 273.15); + + glycolScrubber = + new Separator("Water dew point control scrubber", mixerAfterCooler.getOutletStream()); + + secondStageCompressor = + new Compressor("2nd stage compressor", glycolScrubber.getGasOutStream()); + secondStageCompressor.setOutletPressure(secondStageOutPressure); + + secondStageAfterCooler = + new Cooler("second stage after cooler", secondStageCompressor.getOutletStream()); + secondStageAfterCooler.setOutTemperature(exportGasTemperature + 273.15); + + getOperations().add(inletCooler); + getOperations().add(inletSeparator); + getOperations().add(gasCooler); + getOperations().add(oilPump); + getOperations().add(gasScrubber); + getOperations().add(HPliquidRecycle); + getOperations().add(firstStageCompressor); + getOperations().add(glycolMixer); + getOperations().add(mixerAfterCooler); + getOperations().add(glycolScrubber); + getOperations().add(secondStageCompressor); + getOperations().add(secondStageAfterCooler); + } + + /** {@inheritDoc} */ + @Override + public void initializeStreams() { + isInitializedStreams = true; + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + if (!isInitializedModule) { + initializeModule(); } - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - @SuppressWarnings("unused") - public static void main(String[] args) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 50, 65); - - testSystem.addComponent("methane", 50); - testSystem.addComponent("propane", 0.15); - testSystem.addComponent("nC10", 2); - testSystem.addComponent("water", 5); - testSystem.addComponent("TEG", 5e-9); - testSystem.createDatabase(true); - testSystem.setMixingRule(10); - testSystem.setMultiPhaseCheck(true); - - neqsim.thermo.system.SystemInterface glycolTestSystem = - new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 15, 50); - glycolTestSystem.addComponent("methane", 0); - glycolTestSystem.addComponent("propane", 0); - glycolTestSystem.addComponent("nC10", 0); - glycolTestSystem.addComponent("water", 1e-4); - glycolTestSystem.addComponent("TEG", 0.8); - - glycolTestSystem.createDatabase(true); - glycolTestSystem.setMixingRule(10); - glycolTestSystem.setMultiPhaseCheck(true); - glycolTestSystem.init(0); - Stream wellStream = new Stream("Well stream", testSystem); - wellStream.getThermoSystem().setTotalFlowRate(5.0, "MSm^3/day"); - - Stream glycolFeedStream = new Stream("Glycol feed stream", glycolTestSystem); - glycolFeedStream.getThermoSystem().setTotalFlowRate(4.0 * 1e3, "kg/hr"); - - MixerGasProcessingModule separationModule = new MixerGasProcessingModule("GasMixer"); - separationModule.addInputStream("feed stream", wellStream); - separationModule.addInputStream("glycol feed stream", glycolFeedStream); - separationModule.setSpecification("inlet separation temperature", 55.0); - separationModule.setSpecification("gas scrubber temperature", 35.0); - separationModule.setSpecification("glycol scrubber temperature", 25.0); - separationModule.setSpecification("first stage out pressure", 110.0); - separationModule.setSpecification("second stage out pressure", 200.0); - separationModule.setSpecification("export gas temperature", 30.0); - separationModule.setSpecification("liquid pump out pressure", 150.0); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(wellStream); - operations.add(glycolFeedStream); - operations.add(separationModule); - operations.run(); - // glycolFeedStream.displayResult(); - // separationModule.getOutputStream("gas exit stream").displayResult(); - // separationModule.getOutputStream("oil exit stream").displayResult(); - // separationModule.getOutputStream("liquid pump").displayResult(); - double en = ((PumpInterface) separationModule.getOperations().getUnit("liquid pump")) - .getPower(); - // separationModule.getOutputStream("glycol feed stream").displayResult(); - // separationModule.getOutputStream("glycol exit stream").displayResult(); - - // ((Separator) operations.getUnit("Water dew point control - // scrubber")).displayResult(); + getOperations().run(id); + + gasExitStream = secondStageAfterCooler.getOutletStream(); + gasExitStream.setCalculationIdentifier(id); + oilExitStream = oilPump.getOutletStream(); + oilExitStream.setCalculationIdentifier(id); + glycolExitStream = glycolScrubber.getLiquidOutStream(); + glycolExitStream.setCalculationIdentifier(id); + + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public void calcDesign() { + // design is done here + } + + /** {@inheritDoc} */ + @Override + public void setDesign() { + // set design is done here + } + + /** {@inheritDoc} */ + @Override + public void setSpecification(String specificationName, double value) { + if (specificationName.equals("inlet separation temperature")) { + inletSepTemperature = value; + } else if (specificationName.equals("gas scrubber temperature")) { + gasScrubberTemperature = value; + } else if (specificationName.equals("first stage out pressure")) { + firstStageOutPressure = value; + } else if (specificationName.equals("glycol scrubber temperature")) { + glycolScrubberTemperature = value; + } else if (specificationName.equals("second stage out pressure")) { + secondStageOutPressure = value; + } else if (specificationName.equals("export gas temperature")) { + exportGasTemperature = value; + } else if (specificationName.equals("liquid pump out pressure")) { + liquidPumpPressure = value; } + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String[] args) { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 50, 65); + + testSystem.addComponent("methane", 50); + testSystem.addComponent("propane", 0.15); + testSystem.addComponent("nC10", 2); + testSystem.addComponent("water", 5); + testSystem.addComponent("TEG", 5e-9); + testSystem.createDatabase(true); + testSystem.setMixingRule(10); + testSystem.setMultiPhaseCheck(true); + + neqsim.thermo.system.SystemInterface glycolTestSystem = + new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 15, 50); + glycolTestSystem.addComponent("methane", 0); + glycolTestSystem.addComponent("propane", 0); + glycolTestSystem.addComponent("nC10", 0); + glycolTestSystem.addComponent("water", 1e-4); + glycolTestSystem.addComponent("TEG", 0.8); + + glycolTestSystem.createDatabase(true); + glycolTestSystem.setMixingRule(10); + glycolTestSystem.setMultiPhaseCheck(true); + glycolTestSystem.init(0); + Stream wellStream = new Stream("Well stream", testSystem); + wellStream.getThermoSystem().setTotalFlowRate(5.0, "MSm^3/day"); + + Stream glycolFeedStream = new Stream("Glycol feed stream", glycolTestSystem); + glycolFeedStream.getThermoSystem().setTotalFlowRate(4.0 * 1e3, "kg/hr"); + + MixerGasProcessingModule separationModule = new MixerGasProcessingModule("GasMixer"); + separationModule.addInputStream("feed stream", wellStream); + separationModule.addInputStream("glycol feed stream", glycolFeedStream); + separationModule.setSpecification("inlet separation temperature", 55.0); + separationModule.setSpecification("gas scrubber temperature", 35.0); + separationModule.setSpecification("glycol scrubber temperature", 25.0); + separationModule.setSpecification("first stage out pressure", 110.0); + separationModule.setSpecification("second stage out pressure", 200.0); + separationModule.setSpecification("export gas temperature", 30.0); + separationModule.setSpecification("liquid pump out pressure", 150.0); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(wellStream); + operations.add(glycolFeedStream); + operations.add(separationModule); + operations.run(); + // glycolFeedStream.displayResult(); + // separationModule.getOutputStream("gas exit stream").displayResult(); + // separationModule.getOutputStream("oil exit stream").displayResult(); + // separationModule.getOutputStream("liquid pump").displayResult(); + double en = + ((PumpInterface) separationModule.getOperations().getUnit("liquid pump")).getPower(); + // separationModule.getOutputStream("glycol feed stream").displayResult(); + // separationModule.getOutputStream("glycol exit stream").displayResult(); + + // ((Separator) operations.getUnit("Water dew point control + // scrubber")).displayResult(); + } } diff --git a/src/main/java/neqsim/processSimulation/processSystem/processModules/PropaneCoolingModule.java b/src/main/java/neqsim/processSimulation/processSystem/processModules/PropaneCoolingModule.java index 0834685918..7f2065a424 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/processModules/PropaneCoolingModule.java +++ b/src/main/java/neqsim/processSimulation/processSystem/processModules/PropaneCoolingModule.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processSystem.processModules; +import java.util.UUID; import neqsim.processSimulation.processEquipment.compressor.Compressor; import neqsim.processSimulation.processEquipment.compressor.CompressorInterface; import neqsim.processSimulation.processEquipment.heatExchanger.Cooler; @@ -19,208 +20,209 @@ */ public class PropaneCoolingModule extends ProcessModuleBaseClass { - public PropaneCoolingModule(String name) { - super(name); + public PropaneCoolingModule(String name) { + super(name); + } + + /** + *

+ * Setter for the field condenserTemperature. + *

+ * + * @param condenserTemperature the condenserTemperature to set + */ + public void setCondenserTemperature(double condenserTemperature) { + this.condenserTemperature = condenserTemperature; + } + + /** + *

+ * Setter for the field vaporizerTemperature. + *

+ * + * @param vaporizerTemperature the vaporizerTemperature to set + */ + public void setVaporizerTemperature(double vaporizerTemperature) { + this.vaporizerTemperature = vaporizerTemperature; + } + + private static final long serialVersionUID = 1000; + + StreamInterface refrigerantStream; + private double condenserTemperature = 273.15 + 30.0; // Kelvin + private double vaporizerTemperature = 273.15 - 40.0; // Kelvin + + /** {@inheritDoc} */ + @Override + public void addInputStream(String streamName, StreamInterface stream) { + if (streamName.equals("refrigerant")) { + this.refrigerantStream = stream; } - /** - *

- * Setter for the field condenserTemperature. - *

- * - * @param condenserTemperature the condenserTemperature to set - */ - public void setCondenserTemperature(double condenserTemperature) { - this.condenserTemperature = condenserTemperature; - } - - /** - *

- * Setter for the field vaporizerTemperature. - *

- * - * @param vaporizerTemperature the vaporizerTemperature to set - */ - public void setVaporizerTemperature(double vaporizerTemperature) { - this.vaporizerTemperature = vaporizerTemperature; - } - - private static final long serialVersionUID = 1000; - - StreamInterface refrigerantStream; - private double condenserTemperature = 273.15 + 30.0; // Kelvin - private double vaporizerTemperature = 273.15 - 40.0; // Kelvin + } - /** {@inheritDoc} */ - @Override - public void addInputStream(String streamName, StreamInterface stream) { - if (streamName.equals("refrigerant")) { - this.refrigerantStream = stream; - } + /** {@inheritDoc} */ + @Override + public StreamInterface getOutputStream(String streamName) { + if (!isInitializedStreams) { + initializeStreams(); } - - /** {@inheritDoc} */ - @Override - public StreamInterface getOutputStream(String streamName) { - if (!isInitializedStreams) { - initializeStreams(); - } - if (streamName.equals("refrigerant")) { - return this.refrigerantStream; - } else if (streamName.equals("refrigerant...")) { - return this.refrigerantStream; - } else { - return null; - } - } - - /** {@inheritDoc} */ - @Override - public void initializeModule() { - isInitializedModule = true; - - refrigerantStream.getThermoSystem().setTemperature(condenserTemperature); - ((Stream) refrigerantStream).setSpecification("bubT"); - refrigerantStream.run(); - - ThrottlingValve JTvalve = new ThrottlingValve("JTvalve", refrigerantStream); - - Cooler cooler = new Cooler("propane evaporator", JTvalve.getOutletStream()); - cooler.setPressureDrop(0.35); - cooler.setSpecification("out stream"); - - Stream stream_2 = new Stream("stream_2", cooler.getOutletStream()); - stream_2.setSpecification("dewT"); - stream_2.getThermoSystem().setTemperature(vaporizerTemperature); - stream_2.run(); - - cooler.setOutletStream(stream_2); - JTvalve.setOutletPressure(stream_2.getPressure()); - - Compressor compressor1 = new Compressor("propane compressor", stream_2); - // compressor1.setIsentropicEfficiency(0.75); - // compressor1.setPower(180000); - compressor1.setOutletPressure(refrigerantStream.getPressure()); - - Heater condenser = new Heater("propane condenser", compressor1.getOutletStream()); - condenser.setPressureDrop(0.07); - condenser.setSpecification("out stream"); - condenser.setOutletStream((Stream) refrigerantStream); - - System.out.println("adding operations...."); - getOperations().add(refrigerantStream); - getOperations().add(JTvalve); - getOperations().add(cooler); - getOperations().add(stream_2); - getOperations().add(compressor1); - getOperations().add(condenser); - System.out.println("finished adding operations...."); + if (streamName.equals("refrigerant")) { + return this.refrigerantStream; + } else if (streamName.equals("refrigerant...")) { + return this.refrigerantStream; + } else { + return null; } - - /** {@inheritDoc} */ - @Override - public void run() { - if (!isInitializedModule) { - initializeModule(); - } - System.out.println("running model...."); - getOperations().run(); - - // gasExitStream = secondStageAfterCooler.getOutStream(); + } + + /** {@inheritDoc} */ + @Override + public void initializeModule() { + UUID id = UUID.randomUUID(); + isInitializedModule = true; + + refrigerantStream.getThermoSystem().setTemperature(condenserTemperature); + ((Stream) refrigerantStream).setSpecification("bubT"); + refrigerantStream.run(id); + + ThrottlingValve JTvalve = new ThrottlingValve("JTvalve", refrigerantStream); + + Cooler cooler = new Cooler("propane evaporator", JTvalve.getOutletStream()); + cooler.setPressureDrop(0.35); + cooler.setSpecification("out stream"); + + Stream stream_2 = new Stream("stream_2", cooler.getOutletStream()); + stream_2.setSpecification("dewT"); + stream_2.getThermoSystem().setTemperature(vaporizerTemperature); + stream_2.run(id); + + cooler.setOutletStream(stream_2); + JTvalve.setOutletPressure(stream_2.getPressure()); + + Compressor compressor1 = new Compressor("propane compressor", stream_2); + // compressor1.setIsentropicEfficiency(0.75); + // compressor1.setPower(180000); + compressor1.setOutletPressure(refrigerantStream.getPressure()); + + Heater condenser = new Heater("propane condenser", compressor1.getOutletStream()); + condenser.setPressureDrop(0.07); + condenser.setSpecification("out stream"); + condenser.setOutletStream((Stream) refrigerantStream); + + System.out.println("adding operations...."); + getOperations().add(refrigerantStream); + getOperations().add(JTvalve); + getOperations().add(cooler); + getOperations().add(stream_2); + getOperations().add(compressor1); + getOperations().add(condenser); + System.out.println("finished adding operations...."); + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + if (!isInitializedModule) { + initializeModule(); } - - /** {@inheritDoc} */ - @Override - public void initializeStreams() { - isInitializedStreams = true; - } - - /** {@inheritDoc} */ - @Override - public void calcDesign() { - // design is done here - } - - /** {@inheritDoc} */ - @Override - public void setDesign() { - // set design is done here - } - - /** {@inheritDoc} */ - @Override - public void setSpecification(String specificationName, double value) { - if (specificationName.equals("vaporizerTemperature")) { - setVaporizerTemperature(value); - } else if (specificationName.equals("condenserTemperature")) { - setCondenserTemperature(value); - } - } - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos(273.15 - 20, 1); - testSystem.addComponent("propane", 0.30); - testSystem.createDatabase(true); - - Stream porpane = new Stream("porpane", testSystem); - PropaneCoolingModule propaneModule = new PropaneCoolingModule("propaneModule"); - propaneModule.setCondenserTemperature(273.15 + 30); - propaneModule.setVaporizerTemperature(273.15 - 40); - - propaneModule.addInputStream("refrigerant", porpane); - propaneModule.run(); - - double compressorWork = - ((CompressorInterface) propaneModule.getOperations().getUnit("propane compressor")) - .getEnergy(); - - double evaporatorDuty = - ((Cooler) propaneModule.getOperations().getUnit("propane evaporator")) - .getEnergyInput(); - double evaporatorPressure = - ((Cooler) propaneModule.getOperations().getUnit("propane evaporator")) - .getOutletStream().getPressure(); - double evaporatorTemperature = - ((Cooler) propaneModule.getOperations().getUnit("propane evaporator")) - .getOutletStream().getTemperature(); - - double condenserDuty = ((Heater) propaneModule.getOperations().getUnit("propane condenser")) - .getEnergyInput(); - double condenserPressure = - ((Heater) propaneModule.getOperations().getUnit("propane condenser")).getOutletStream() - .getPressure(); - double condenserTemperature = - ((Heater) propaneModule.getOperations().getUnit("propane condenser")).getOutletStream() - .getTemperature(); - - System.out.println("Compressor work " + compressorWork + " W"); - - System.out.println("evaporator duty " + evaporatorDuty + " W"); - System.out.println("evaporator temperature " + (evaporatorTemperature - 273.15) + " C"); - System.out.println("evaporator pressure " + evaporatorPressure + " bara"); - - System.out.println("condenser duty " + condenserDuty + " W"); - System.out.println("condenser temperature " + (condenserTemperature - 273.15) + " C"); - System.out.println("condenser pressure " + condenserPressure + " bara"); - // ((Cooler) propaneModule.getOperations().getUnit("propane - // evaporator")).getInStream().displayResult(); - // ((Cooler) propaneModule.getOperations().getUnit("propane - // evaporator")).getOutStream().displayResult(); - - // TT ((CompressorInterface) propaneModule.getOperations().getUnit("propane - // compressor")).displayResult(); - // ((CompressorInterface) propaneModule.getOperations().getUnit("propane - // compressor")).getOutStream().displayResult(); - // ((Heater) propaneModule.getOperations().getUnit("propane - // condenser")).getInStream().displayResult(); - // ((Heater) propaneModule.getOperations().getUnit("propane - // condenser")).getOutStream().displayResult(); + System.out.println("running model...."); + getOperations().run(id); + + // gasExitStream = secondStageAfterCooler.getOutStream(); + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public void initializeStreams() { + isInitializedStreams = true; + } + + /** {@inheritDoc} */ + @Override + public void calcDesign() { + // design is done here + } + + /** {@inheritDoc} */ + @Override + public void setDesign() { + // set design is done here + } + + /** {@inheritDoc} */ + @Override + public void setSpecification(String specificationName, double value) { + if (specificationName.equals("vaporizerTemperature")) { + setVaporizerTemperature(value); + } else if (specificationName.equals("condenserTemperature")) { + setCondenserTemperature(value); } + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos(273.15 - 20, 1); + testSystem.addComponent("propane", 0.30); + testSystem.createDatabase(true); + + Stream porpane = new Stream("porpane", testSystem); + PropaneCoolingModule propaneModule = new PropaneCoolingModule("propaneModule"); + propaneModule.setCondenserTemperature(273.15 + 30); + propaneModule.setVaporizerTemperature(273.15 - 40); + + propaneModule.addInputStream("refrigerant", porpane); + propaneModule.run(); + + double compressorWork = + ((CompressorInterface) propaneModule.getOperations().getUnit("propane compressor")) + .getEnergy(); + + double evaporatorDuty = + ((Cooler) propaneModule.getOperations().getUnit("propane evaporator")).getEnergyInput(); + double evaporatorPressure = + ((Cooler) propaneModule.getOperations().getUnit("propane evaporator")).getOutletStream() + .getPressure(); + double evaporatorTemperature = + ((Cooler) propaneModule.getOperations().getUnit("propane evaporator")).getOutletStream() + .getTemperature(); + + double condenserDuty = + ((Heater) propaneModule.getOperations().getUnit("propane condenser")).getEnergyInput(); + double condenserPressure = ((Heater) propaneModule.getOperations().getUnit("propane condenser")) + .getOutletStream().getPressure(); + double condenserTemperature = + ((Heater) propaneModule.getOperations().getUnit("propane condenser")).getOutletStream() + .getTemperature(); + + System.out.println("Compressor work " + compressorWork + " W"); + + System.out.println("evaporator duty " + evaporatorDuty + " W"); + System.out.println("evaporator temperature " + (evaporatorTemperature - 273.15) + " C"); + System.out.println("evaporator pressure " + evaporatorPressure + " bara"); + + System.out.println("condenser duty " + condenserDuty + " W"); + System.out.println("condenser temperature " + (condenserTemperature - 273.15) + " C"); + System.out.println("condenser pressure " + condenserPressure + " bara"); + // ((Cooler) propaneModule.getOperations().getUnit("propane + // evaporator")).getInStream().displayResult(); + // ((Cooler) propaneModule.getOperations().getUnit("propane + // evaporator")).getOutStream().displayResult(); + + // TT ((CompressorInterface) propaneModule.getOperations().getUnit("propane + // compressor")).displayResult(); + // ((CompressorInterface) propaneModule.getOperations().getUnit("propane + // compressor")).getOutStream().displayResult(); + // ((Heater) propaneModule.getOperations().getUnit("propane + // condenser")).getInStream().displayResult(); + // ((Heater) propaneModule.getOperations().getUnit("propane + // condenser")).getOutStream().displayResult(); + } } diff --git a/src/main/java/neqsim/processSimulation/processSystem/processModules/SeparationTrainModule.java b/src/main/java/neqsim/processSimulation/processSystem/processModules/SeparationTrainModule.java index 54fd229ff2..d30e74c431 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/processModules/SeparationTrainModule.java +++ b/src/main/java/neqsim/processSimulation/processSystem/processModules/SeparationTrainModule.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processSystem.processModules; +import java.util.UUID; import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface; import neqsim.processSimulation.processEquipment.compressor.Compressor; import neqsim.processSimulation.processEquipment.heatExchanger.Cooler; @@ -14,319 +15,325 @@ import neqsim.processSimulation.processSystem.ProcessModuleBaseClass; /** - *

SeparationTrainModule class.

+ *

+ * SeparationTrainModule class. + *

* * @author esol * @version $Id: $Id */ public class SeparationTrainModule extends ProcessModuleBaseClass { - private static final long serialVersionUID = 1000; - - protected StreamInterface feedStream = null, gasExitStream = null, oilExitStream = null; - // ThreePhaseSeparator thirdStageSeparator = null; - Separator gasInletScrubber = null; - Cooler oilCooler; - double secondstagePressure = 15.00; // bar' - double thirdstagePressure = 1.50; // bar - double heatedOilTemperature = 273.15 + 50; - double exitGasScrubberTemperature = 273.15 + 30; - double firstStageCompressorAfterCoolerTemperature = 273.15 + 30; - double exportOilTemperature = 273.15 + 30; - - public SeparationTrainModule(String name) { - super(name); + private static final long serialVersionUID = 1000; + + protected StreamInterface feedStream = null, gasExitStream = null, oilExitStream = null; + // ThreePhaseSeparator thirdStageSeparator = null; + Separator gasInletScrubber = null; + Cooler oilCooler; + double secondstagePressure = 15.00; // bar' + double thirdstagePressure = 1.50; // bar + double heatedOilTemperature = 273.15 + 50; + double exitGasScrubberTemperature = 273.15 + 30; + double firstStageCompressorAfterCoolerTemperature = 273.15 + 30; + double exportOilTemperature = 273.15 + 30; + + public SeparationTrainModule(String name) { + super(name); + } + + /** {@inheritDoc} */ + @Override + public void addInputStream(String streamName, StreamInterface stream) { + if (streamName.equals("feed stream")) { + this.feedStream = stream; } + } - /** {@inheritDoc} */ - @Override - public void addInputStream(String streamName, StreamInterface stream) { - if (streamName.equals("feed stream")) { - this.feedStream = stream; - } + /** {@inheritDoc} */ + @Override + public StreamInterface getOutputStream(String streamName) { + if (!isInitializedStreams) { + initializeStreams(); } - - /** {@inheritDoc} */ - @Override - public StreamInterface getOutputStream(String streamName) { - if (!isInitializedStreams) { - initializeStreams(); - } - if (streamName.equals("gas exit stream")) { - return this.gasExitStream; - } else if (streamName.equals("oil exit stream")) { - return this.oilExitStream; - } else { - return null; - } + if (streamName.equals("gas exit stream")) { + return this.gasExitStream; + } else if (streamName.equals("oil exit stream")) { + return this.oilExitStream; + } else { + return null; } + } - /** {@inheritDoc} */ - @Override - public void run() { - if (!isInitializedModule) { - initializeModule(); - } - getOperations().run(); - - gasExitStream = gasInletScrubber.getGasOutStream(); - oilExitStream = oilCooler.getOutletStream(); + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + if (!isInitializedModule) { + initializeModule(); } - - /** {@inheritDoc} */ - @Override - public void initializeModule() { - isInitializedModule = true; - double inletPressure = feedStream.getPressure(); - Separator inletSeparator = new Separator("Inlet separator", feedStream); - - Heater liquidOutHeater = - new Heater("oil/water heater", inletSeparator.getLiquidOutStream()); - liquidOutHeater.setOutTemperature(heatedOilTemperature); - - ThreePhaseSeparator firstStageSeparator = - new ThreePhaseSeparator("1st stage separator", liquidOutHeater.getOutletStream()); - - ThrottlingValve valve1 = - new ThrottlingValve("1stTo2ndStageOilValve", firstStageSeparator.getOilOutStream()); - valve1.setOutletPressure(secondstagePressure); - - ThreePhaseSeparator secondStageSeparator = - new ThreePhaseSeparator("2nd stage Separator", valve1.getOutletStream()); - - ThrottlingValve thirdStageValve = - new ThrottlingValve("2-3stageOilValve", secondStageSeparator.getLiquidOutStream()); - thirdStageValve.setOutletPressure(thirdstagePressure); - - ThreePhaseSeparator thirdStageSeparator = - new ThreePhaseSeparator("3rd stage Separator", thirdStageValve.getOutletStream()); - - oilCooler = new Cooler("export oil cooler", thirdStageSeparator.getLiquidOutStream()); - oilCooler.setOutTemperature(exportOilTemperature); - - Compressor thirdStageCompressor = - new Compressor("3rd stage recompressor", thirdStageSeparator.getGasOutStream()); - thirdStageCompressor.setOutletPressure(secondstagePressure); - - Cooler thirdSstageCoooler = - new Cooler("3rd stage cooler", thirdStageCompressor.getOutletStream()); - thirdSstageCoooler.setOutTemperature(firstStageCompressorAfterCoolerTemperature); - - Mixer thirdStageMixer = new Mixer("1st and 2nd stage gas mixer"); - thirdStageMixer.addStream(thirdSstageCoooler.getOutletStream()); - thirdStageMixer.addStream(secondStageSeparator.getGasOutStream()); - - Separator thirdStageScrubber = - new Separator("recompression scrubber", thirdStageMixer.getOutletStream()); - secondStageSeparator.addStream(thirdStageScrubber.getLiquidOutStream()); - - Compressor secondStageCompressor = - new Compressor("2nd stage recompressor", thirdStageScrubber.getGasOutStream()); - secondStageCompressor.setOutletPressure(inletPressure); - - Mixer HPgasMixer = new Mixer("HPgas mixer"); - HPgasMixer.addStream(firstStageSeparator.getGasOutStream()); - HPgasMixer.addStream(secondStageCompressor.getOutletStream()); - HPgasMixer.addStream(inletSeparator.getGasOutStream()); - - Cooler inletGasCooler = new Cooler("HP gas cooler", HPgasMixer.getOutletStream()); - inletGasCooler.setOutTemperature(exitGasScrubberTemperature); - - gasInletScrubber = new Separator("HP gas scrubber", inletGasCooler.getOutletStream()); - - Recycle HPliquidRecycle = new Recycle("Resycle"); - double tolerance = 1e-10; - HPliquidRecycle.setTolerance(tolerance); - HPliquidRecycle.addStream(gasInletScrubber.getLiquidOutStream()); - inletSeparator.addStream(HPliquidRecycle.getOutStream()); - - getOperations().add(inletSeparator); - getOperations().add(liquidOutHeater); - getOperations().add(firstStageSeparator); - getOperations().add(valve1); - getOperations().add(secondStageSeparator); - getOperations().add(thirdStageValve); - getOperations().add(thirdStageSeparator); - getOperations().add(thirdStageCompressor); - getOperations().add(thirdStageMixer); - getOperations().add(thirdSstageCoooler); - getOperations().add(thirdStageScrubber); - getOperations().add(HPliquidRecycle); - getOperations().add(secondStageCompressor); - getOperations().add(oilCooler); - getOperations().add(HPgasMixer); - getOperations().add(inletGasCooler); - getOperations().add(gasInletScrubber); - - // gasExitStream = gasInletScrubber.getGasOutStream(); - // oilExitStream = thirdStageSeparator.getOilOutStream(); + getOperations().run(id); + + gasExitStream = gasInletScrubber.getGasOutStream(); + gasExitStream.setCalculationIdentifier(id); + oilExitStream = oilCooler.getOutletStream(); + oilExitStream.setCalculationIdentifier(id); + + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public void initializeModule() { + isInitializedModule = true; + double inletPressure = feedStream.getPressure(); + Separator inletSeparator = new Separator("Inlet separator", feedStream); + + Heater liquidOutHeater = new Heater("oil/water heater", inletSeparator.getLiquidOutStream()); + liquidOutHeater.setOutTemperature(heatedOilTemperature); + + ThreePhaseSeparator firstStageSeparator = + new ThreePhaseSeparator("1st stage separator", liquidOutHeater.getOutletStream()); + + ThrottlingValve valve1 = + new ThrottlingValve("1stTo2ndStageOilValve", firstStageSeparator.getOilOutStream()); + valve1.setOutletPressure(secondstagePressure); + + ThreePhaseSeparator secondStageSeparator = + new ThreePhaseSeparator("2nd stage Separator", valve1.getOutletStream()); + + ThrottlingValve thirdStageValve = + new ThrottlingValve("2-3stageOilValve", secondStageSeparator.getLiquidOutStream()); + thirdStageValve.setOutletPressure(thirdstagePressure); + + ThreePhaseSeparator thirdStageSeparator = + new ThreePhaseSeparator("3rd stage Separator", thirdStageValve.getOutletStream()); + + oilCooler = new Cooler("export oil cooler", thirdStageSeparator.getLiquidOutStream()); + oilCooler.setOutTemperature(exportOilTemperature); + + Compressor thirdStageCompressor = + new Compressor("3rd stage recompressor", thirdStageSeparator.getGasOutStream()); + thirdStageCompressor.setOutletPressure(secondstagePressure); + + Cooler thirdSstageCoooler = + new Cooler("3rd stage cooler", thirdStageCompressor.getOutletStream()); + thirdSstageCoooler.setOutTemperature(firstStageCompressorAfterCoolerTemperature); + + Mixer thirdStageMixer = new Mixer("1st and 2nd stage gas mixer"); + thirdStageMixer.addStream(thirdSstageCoooler.getOutletStream()); + thirdStageMixer.addStream(secondStageSeparator.getGasOutStream()); + + Separator thirdStageScrubber = + new Separator("recompression scrubber", thirdStageMixer.getOutletStream()); + secondStageSeparator.addStream(thirdStageScrubber.getLiquidOutStream()); + + Compressor secondStageCompressor = + new Compressor("2nd stage recompressor", thirdStageScrubber.getGasOutStream()); + secondStageCompressor.setOutletPressure(inletPressure); + + Mixer HPgasMixer = new Mixer("HPgas mixer"); + HPgasMixer.addStream(firstStageSeparator.getGasOutStream()); + HPgasMixer.addStream(secondStageCompressor.getOutletStream()); + HPgasMixer.addStream(inletSeparator.getGasOutStream()); + + Cooler inletGasCooler = new Cooler("HP gas cooler", HPgasMixer.getOutletStream()); + inletGasCooler.setOutTemperature(exitGasScrubberTemperature); + + gasInletScrubber = new Separator("HP gas scrubber", inletGasCooler.getOutletStream()); + + Recycle HPliquidRecycle = new Recycle("Resycle"); + double tolerance = 1e-10; + HPliquidRecycle.setTolerance(tolerance); + HPliquidRecycle.addStream(gasInletScrubber.getLiquidOutStream()); + inletSeparator.addStream(HPliquidRecycle.getOutStream()); + + getOperations().add(inletSeparator); + getOperations().add(liquidOutHeater); + getOperations().add(firstStageSeparator); + getOperations().add(valve1); + getOperations().add(secondStageSeparator); + getOperations().add(thirdStageValve); + getOperations().add(thirdStageSeparator); + getOperations().add(thirdStageCompressor); + getOperations().add(thirdStageMixer); + getOperations().add(thirdSstageCoooler); + getOperations().add(thirdStageScrubber); + getOperations().add(HPliquidRecycle); + getOperations().add(secondStageCompressor); + getOperations().add(oilCooler); + getOperations().add(HPgasMixer); + getOperations().add(inletGasCooler); + getOperations().add(gasInletScrubber); + + // gasExitStream = gasInletScrubber.getGasOutStream(); + // oilExitStream = thirdStageSeparator.getOilOutStream(); + } + + /** {@inheritDoc} */ + @Override + public void initializeStreams() { + isInitializedStreams = true; + } + + /** {@inheritDoc} */ + @Override + public void calcDesign() { + // design is done here + } + + /** {@inheritDoc} */ + @Override + public void setDesign() { + // set design is done here + } + + /** {@inheritDoc} */ + @Override + public void setSpecification(String specificationName, double value) { + if (specificationName.equals("Second stage pressure")) { + secondstagePressure = value; } - - /** {@inheritDoc} */ - @Override - public void initializeStreams() { - isInitializedStreams = true; + if (specificationName.equals("heated oil temperature")) { + heatedOilTemperature = value; } - - /** {@inheritDoc} */ - @Override - public void calcDesign() { - // design is done here + if (specificationName.equals("Third stage pressure")) { + thirdstagePressure = value; } - - /** {@inheritDoc} */ - @Override - public void setDesign() { - // set design is done here + if (specificationName.equals("Gas exit temperature")) { + exitGasScrubberTemperature = value; } - - /** {@inheritDoc} */ - @Override - public void setSpecification(String specificationName, double value) { - if (specificationName.equals("Second stage pressure")) { - secondstagePressure = value; - } - if (specificationName.equals("heated oil temperature")) { - heatedOilTemperature = value; - } - if (specificationName.equals("Third stage pressure")) { - thirdstagePressure = value; - } - if (specificationName.equals("Gas exit temperature")) { - exitGasScrubberTemperature = value; - } - if (specificationName.equals("First stage compressor after cooler temperature")) { - firstStageCompressorAfterCoolerTemperature = value; - } - if (specificationName.equals("Export oil temperature")) { - exportOilTemperature = value; - } + if (specificationName.equals("First stage compressor after cooler temperature")) { + firstStageCompressorAfterCoolerTemperature = value; } - - /** - *

main.

- * - * @param args an array of {@link java.lang.String} objects - */ - @SuppressWarnings("unused") - public static void main(String[] args) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos(273.15 + 50, 65); - - // testSystem.addComponent("CO2", 1); - // testSystem.addComponent("nitrogen", 1); - testSystem.addComponent("methane", 95); - // testSystem.addComponent("ethane", 1); - // testSystem.addTBPfraction("C7", 1.0, 187.0 / 1000.0, 0.84738); - - // testSystem.addComponent("propane", 5); - // testSystem.addComponent("n-octane", 2); - testSystem.addComponent("nC10", 6); - // testSystem.setHeavyTBPfractionAsPlusFraction(); - // testSystem.getCharacterization().characterisePlusFraction(); - - testSystem.addComponent("water", 12); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - testSystem.setMultiPhaseCheck(true); - testSystem.init(0); - testSystem.init(3); - double a = testSystem.getTotalNumberOfMoles(); - - Stream wellStream = new Stream("Well stream", testSystem); - // wellStream.getThermoSystem().setTotalFlowRate(5.0, "MSm^3/day"); - - SeparationTrainModule separationModule = new SeparationTrainModule("separationModule"); - separationModule.addInputStream("feed stream", wellStream); - separationModule.setSpecification("Second stage pressure", 15.0); - separationModule.setSpecification("heated oil temperature", 273.15 + 55.0); - separationModule.setSpecification("Third stage pressure", 1.0); - separationModule.setSpecification("Gas exit temperature", 273.15 + 25.0); - separationModule.setSpecification("First stage compressor after cooler temperature", - 273.15 + 25.0); - separationModule.setSpecification("Export oil temperature", 273.15 + 25.0); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - - operations.add(wellStream); - operations.add(separationModule); - // separationModule.getUnit("") - // ((Recycle) operations.getUnit("Resycle")).setTolerance(1e-9); - - operations.run(); - - // ArrayList names2 = operations.getAllUnitNames(); - // processSimulation.processEquipment.ProcessEquipmentInterface tempStr = - // (ProcessEquipmentBaseClass) operations.getUnit("2nd stage recompressor"); - // tempStr.displayResult(); - // wellStream.displayResult(); - ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("Inlet separator")) - .getMechanicalDesign().calcDesign(); - ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("Inlet separator")) - .getMechanicalDesign().displayResults(); - - ((ProcessEquipmentInterface) separationModule.getOperations() - .getUnit("1st stage separator")).getMechanicalDesign().calcDesign(); - ((ProcessEquipmentInterface) separationModule.getOperations() - .getUnit("1st stage separator")).getMechanicalDesign().displayResults(); - - ((ProcessEquipmentInterface) separationModule.getOperations() - .getUnit("2nd stage Separator")).getMechanicalDesign().calcDesign(); - ((ProcessEquipmentInterface) separationModule.getOperations() - .getUnit("2nd stage Separator")).getMechanicalDesign().displayResults(); - - ((ProcessEquipmentInterface) separationModule.getOperations() - .getUnit("3rd stage Separator")).getMechanicalDesign().calcDesign(); - ((ProcessEquipmentInterface) separationModule.getOperations() - .getUnit("3rd stage Separator")).getMechanicalDesign().displayResults(); - - ((ProcessEquipmentInterface) separationModule.getOperations() - .getUnit("2nd stage recompressor")).getMechanicalDesign().calcDesign(); - ((ProcessEquipmentInterface) separationModule.getOperations() - .getUnit("2nd stage recompressor")).getMechanicalDesign().displayResults(); - - operations.getSystemMechanicalDesign().runDesignCalculation(); - operations.getSystemMechanicalDesign().getTotalPlotSpace(); - System.out.println("Modules " + operations.getSystemMechanicalDesign().getTotalVolume()); - - System.out.println( - "Modules " + operations.getSystemMechanicalDesign().getTotalNumberOfModules()); - System.out.println("Weight " + operations.getSystemMechanicalDesign().getTotalWeight()); - System.out.println( - "Plot space " + operations.getSystemMechanicalDesign().getTotalPlotSpace()); - System.out.println("CAPEX " + operations.getCostEstimator().getWeightBasedCAPEXEstimate()); - System.out.println("CAPEX " + operations.getCostEstimator().getCAPEXestimate()); - - /* - * separationModule.getOutputStream("Inlet separator").displayResult(); - * separationModule.getOutputStream("oil exit stream").displayResult(); - * System.out.println("third stage compressor power " + ((Compressor) - * separationModule.getOperations().getUnit("3rd stage recompressor")).getPower( ) + " W"); - * System.out.println("secondstage compressor power " + ((Compressor) - * separationModule.getOperations().getUnit("2nd stage recompressor")).getPower( ) + " W"); - * System.out.println("third stage cooler duty " + ((Cooler) - * separationModule.getOperations().getUnit("3rd stage cooler")).getEnergyInput( ) + " W"); - * System.out.println("HP gas cooler duty " + ((Cooler) - * separationModule.getOperations().getUnit("HP gas cooler")).getEnergyInput() + " W"); - * System.out.println("Export oil flow " + - * separationModule.getOutputStream("oil exit stream").getThermoSystem(). - * getTotalNumberOfMoles() * - * separationModule.getOutputStream("oil exit stream").getThermoSystem(). getMolarMass() / - * separationModule.getOutputStream("oil exit stream").getThermoSystem(). - * getPhase(0).getPhysicalProperties().getDensity() * 3600.0 + " m^3/hr"); - * System.out.println("Export gas flow " + - * separationModule.getOutputStream("gas exit stream").getThermoSystem(). - * getTotalNumberOfMoles() * - * separationModule.getOutputStream("gas exit stream").getThermoSystem(). getMolarMass() / - * separationModule.getOutputStream("gas exit stream").getThermoSystem(). - * getPhase(0).getPhysicalProperties().getDensity() * 3600.0 + " m^3/hr"); - * System.out.println("Export gas flow " + - * separationModule.getOutputStream("gas exit stream").getThermoSystem(). - * getTotalNumberOfMoles() * 8.314 * (273.15 + 15.0) / 101325.0 * 3600.0 * 24 / 1.0e6 + - * " MSm^3/day"); System.out.println("oil/water heater duty " + ((Heater) - * separationModule.getOperations().getUnit("oil/water heater")).getEnergyInput( ) + " W"); - * System.out.println("Export oil cooler duty " + ((Cooler) - * separationModule.getOperations().getUnit("export oil cooler")).getEnergyInput () + " W"); - */ + if (specificationName.equals("Export oil temperature")) { + exportOilTemperature = value; } + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String[] args) { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos(273.15 + 50, 65); + + // testSystem.addComponent("CO2", 1); + // testSystem.addComponent("nitrogen", 1); + testSystem.addComponent("methane", 95); + // testSystem.addComponent("ethane", 1); + // testSystem.addTBPfraction("C7", 1.0, 187.0 / 1000.0, 0.84738); + + // testSystem.addComponent("propane", 5); + // testSystem.addComponent("n-octane", 2); + testSystem.addComponent("nC10", 6); + // testSystem.setHeavyTBPfractionAsPlusFraction(); + // testSystem.getCharacterization().characterisePlusFraction(); + + testSystem.addComponent("water", 12); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + testSystem.setMultiPhaseCheck(true); + testSystem.init(0); + testSystem.init(3); + double a = testSystem.getTotalNumberOfMoles(); + + Stream wellStream = new Stream("Well stream", testSystem); + // wellStream.getThermoSystem().setTotalFlowRate(5.0, "MSm^3/day"); + + SeparationTrainModule separationModule = new SeparationTrainModule("separationModule"); + separationModule.addInputStream("feed stream", wellStream); + separationModule.setSpecification("Second stage pressure", 15.0); + separationModule.setSpecification("heated oil temperature", 273.15 + 55.0); + separationModule.setSpecification("Third stage pressure", 1.0); + separationModule.setSpecification("Gas exit temperature", 273.15 + 25.0); + separationModule.setSpecification("First stage compressor after cooler temperature", + 273.15 + 25.0); + separationModule.setSpecification("Export oil temperature", 273.15 + 25.0); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + + operations.add(wellStream); + operations.add(separationModule); + // separationModule.getUnit("") + // ((Recycle) operations.getUnit("Resycle")).setTolerance(1e-9); + + operations.run(); + + // ArrayList names2 = operations.getAllUnitNames(); + // processSimulation.processEquipment.ProcessEquipmentInterface tempStr = + // (ProcessEquipmentBaseClass) operations.getUnit("2nd stage recompressor"); + // tempStr.displayResult(); + // wellStream.displayResult(); + ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("Inlet separator")) + .getMechanicalDesign().calcDesign(); + ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("Inlet separator")) + .getMechanicalDesign().displayResults(); + + ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("1st stage separator")) + .getMechanicalDesign().calcDesign(); + ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("1st stage separator")) + .getMechanicalDesign().displayResults(); + + ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("2nd stage Separator")) + .getMechanicalDesign().calcDesign(); + ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("2nd stage Separator")) + .getMechanicalDesign().displayResults(); + + ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("3rd stage Separator")) + .getMechanicalDesign().calcDesign(); + ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("3rd stage Separator")) + .getMechanicalDesign().displayResults(); + + ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("2nd stage recompressor")) + .getMechanicalDesign().calcDesign(); + ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("2nd stage recompressor")) + .getMechanicalDesign().displayResults(); + + operations.getSystemMechanicalDesign().runDesignCalculation(); + operations.getSystemMechanicalDesign().getTotalPlotSpace(); + System.out.println("Modules " + operations.getSystemMechanicalDesign().getTotalVolume()); + + System.out + .println("Modules " + operations.getSystemMechanicalDesign().getTotalNumberOfModules()); + System.out.println("Weight " + operations.getSystemMechanicalDesign().getTotalWeight()); + System.out.println("Plot space " + operations.getSystemMechanicalDesign().getTotalPlotSpace()); + System.out.println("CAPEX " + operations.getCostEstimator().getWeightBasedCAPEXEstimate()); + System.out.println("CAPEX " + operations.getCostEstimator().getCAPEXestimate()); + + /* + * separationModule.getOutputStream("Inlet separator").displayResult(); + * separationModule.getOutputStream("oil exit stream").displayResult(); + * System.out.println("third stage compressor power " + ((Compressor) + * separationModule.getOperations().getUnit("3rd stage recompressor")).getPower( ) + " W"); + * System.out.println("secondstage compressor power " + ((Compressor) + * separationModule.getOperations().getUnit("2nd stage recompressor")).getPower( ) + " W"); + * System.out.println("third stage cooler duty " + ((Cooler) + * separationModule.getOperations().getUnit("3rd stage cooler")).getEnergyInput( ) + " W"); + * System.out.println("HP gas cooler duty " + ((Cooler) + * separationModule.getOperations().getUnit("HP gas cooler")).getEnergyInput() + " W"); + * System.out.println("Export oil flow " + + * separationModule.getOutputStream("oil exit stream").getThermoSystem(). + * getTotalNumberOfMoles() * + * separationModule.getOutputStream("oil exit stream").getThermoSystem(). getMolarMass() / + * separationModule.getOutputStream("oil exit stream").getThermoSystem(). + * getPhase(0).getPhysicalProperties().getDensity() * 3600.0 + " m^3/hr"); + * System.out.println("Export gas flow " + + * separationModule.getOutputStream("gas exit stream").getThermoSystem(). + * getTotalNumberOfMoles() * + * separationModule.getOutputStream("gas exit stream").getThermoSystem(). getMolarMass() / + * separationModule.getOutputStream("gas exit stream").getThermoSystem(). + * getPhase(0).getPhysicalProperties().getDensity() * 3600.0 + " m^3/hr"); + * System.out.println("Export gas flow " + + * separationModule.getOutputStream("gas exit stream").getThermoSystem(). + * getTotalNumberOfMoles() * 8.314 * (273.15 + 15.0) / 101325.0 * 3600.0 * 24 / 1.0e6 + + * " MSm^3/day"); System.out.println("oil/water heater duty " + ((Heater) + * separationModule.getOperations().getUnit("oil/water heater")).getEnergyInput( ) + " W"); + * System.out.println("Export oil cooler duty " + ((Cooler) + * separationModule.getOperations().getUnit("export oil cooler")).getEnergyInput () + " W"); + */ + } } diff --git a/src/main/java/neqsim/processSimulation/processSystem/processModules/SeparationTrainModuleSimple.java b/src/main/java/neqsim/processSimulation/processSystem/processModules/SeparationTrainModuleSimple.java index 37b0068353..96388e6952 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/processModules/SeparationTrainModuleSimple.java +++ b/src/main/java/neqsim/processSimulation/processSystem/processModules/SeparationTrainModuleSimple.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processSystem.processModules; +import java.util.UUID; import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface; import neqsim.processSimulation.processEquipment.compressor.Compressor; import neqsim.processSimulation.processEquipment.heatExchanger.Cooler; @@ -14,319 +15,326 @@ import neqsim.processSimulation.processSystem.ProcessModuleBaseClass; /** - *

SeparationTrainModuleSimple class.

+ *

+ * SeparationTrainModuleSimple class. + *

* * @author esol * @version $Id: $Id */ public class SeparationTrainModuleSimple extends ProcessModuleBaseClass { - private static final long serialVersionUID = 1000; - - protected StreamInterface feedStream = null, gasExitStream = null, oilExitStream = null; - // ThreePhaseSeparator thirdStageSeparator = null; - Separator gasInletScrubber = null; - Cooler oilCooler; - double secondstagePressure = 15.00; // bar' - double thirdstagePressure = 1.50; // bar - double heatedOilTemperature = 273.15 + 50; - double exitGasScrubberTemperature = 273.15 + 30; - double firstStageCompressorAfterCoolerTemperature = 273.15 + 30; - double exportOilTemperature = 273.15 + 30; - - public SeparationTrainModuleSimple(String name) { - super(name); + private static final long serialVersionUID = 1000; + + protected StreamInterface feedStream = null; + protected StreamInterface gasExitStream = null; + protected StreamInterface oilExitStream = null; + + // ThreePhaseSeparator thirdStageSeparator = null; + Separator gasInletScrubber = null; + Cooler oilCooler; + double secondstagePressure = 15.00; // bar' + double thirdstagePressure = 1.50; // bar + double heatedOilTemperature = 273.15 + 50; + double exitGasScrubberTemperature = 273.15 + 30; + double firstStageCompressorAfterCoolerTemperature = 273.15 + 30; + double exportOilTemperature = 273.15 + 30; + + public SeparationTrainModuleSimple(String name) { + super(name); + } + + /** {@inheritDoc} */ + @Override + public void addInputStream(String streamName, StreamInterface stream) { + if (streamName.equals("feed stream")) { + this.feedStream = stream; } + } - /** {@inheritDoc} */ - @Override - public void addInputStream(String streamName, StreamInterface stream) { - if (streamName.equals("feed stream")) { - this.feedStream = stream; - } + /** {@inheritDoc} */ + @Override + public StreamInterface getOutputStream(String streamName) { + if (!isInitializedStreams) { + initializeStreams(); } - - /** {@inheritDoc} */ - @Override - public StreamInterface getOutputStream(String streamName) { - if (!isInitializedStreams) { - initializeStreams(); - } - if (streamName.equals("gas exit stream")) { - return this.gasExitStream; - } else if (streamName.equals("oil exit stream")) { - return this.oilExitStream; - } else { - return null; - } + if (streamName.equals("gas exit stream")) { + return this.gasExitStream; + } else if (streamName.equals("oil exit stream")) { + return this.oilExitStream; + } else { + return null; } + } - /** {@inheritDoc} */ - @Override - public void run() { - if (!isInitializedModule) { - initializeModule(); - } - getOperations().run(); - - gasExitStream = gasInletScrubber.getGasOutStream(); - oilExitStream = oilCooler.getOutletStream(); + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + if (!isInitializedModule) { + initializeModule(); } - - /** {@inheritDoc} */ - @Override - public void initializeModule() { - isInitializedModule = true; - double inletPressure = feedStream.getPressure(); - Separator inletSeparator = new Separator("Inlet separator", feedStream); - - Heater liquidOutHeater = - new Heater("oil/water heater", inletSeparator.getLiquidOutStream()); - liquidOutHeater.setOutTemperature(heatedOilTemperature); - - ThreePhaseSeparator firstStageSeparator = - new ThreePhaseSeparator("1st stage separator", liquidOutHeater.getOutletStream()); - - ThrottlingValve valve1 = - new ThrottlingValve("1stTo2ndStageOilValve", firstStageSeparator.getOilOutStream()); - valve1.setOutletPressure(secondstagePressure); - - ThreePhaseSeparator secondStageSeparator = - new ThreePhaseSeparator("2nd stage Separator", valve1.getOutletStream()); - - ThrottlingValve thirdStageValve = - new ThrottlingValve("2-3stageOilValve", secondStageSeparator.getLiquidOutStream()); - thirdStageValve.setOutletPressure(thirdstagePressure); - - ThreePhaseSeparator thirdStageSeparator = - new ThreePhaseSeparator("3rd stage Separator", thirdStageValve.getOutletStream()); - - oilCooler = new Cooler("export oil cooler", thirdStageSeparator.getLiquidOutStream()); - oilCooler.setOutTemperature(exportOilTemperature); - - Compressor thirdStageCompressor = - new Compressor("3rd stage recompressor", thirdStageSeparator.getGasOutStream()); - thirdStageCompressor.setOutletPressure(secondstagePressure); - - Cooler thirdSstageCoooler = - new Cooler("3rd stage cooler", thirdStageCompressor.getOutletStream()); - thirdSstageCoooler.setOutTemperature(firstStageCompressorAfterCoolerTemperature); - - Mixer thirdStageMixer = new Mixer("1st and 2nd stage gas mixer"); - thirdStageMixer.addStream(thirdSstageCoooler.getOutletStream()); - thirdStageMixer.addStream(secondStageSeparator.getGasOutStream()); - - Separator thirdStageScrubber = - new Separator("recompression scrubber", thirdStageMixer.getOutletStream()); - secondStageSeparator.addStream(thirdStageScrubber.getLiquidOutStream()); - - Compressor secondStageCompressor = - new Compressor("2nd stage recompressor", thirdStageScrubber.getGasOutStream()); - secondStageCompressor.setOutletPressure(inletPressure); - - Mixer HPgasMixer = new Mixer("HPgas mixer"); - HPgasMixer.addStream(firstStageSeparator.getGasOutStream()); - HPgasMixer.addStream(secondStageCompressor.getOutletStream()); - HPgasMixer.addStream(inletSeparator.getGasOutStream()); - - Cooler inletGasCooler = new Cooler("HP gas cooler", HPgasMixer.getOutletStream()); - inletGasCooler.setOutTemperature(exitGasScrubberTemperature); - - gasInletScrubber = new Separator("HP gas scrubber", inletGasCooler.getOutletStream()); - - Recycle HPliquidRecycle = new Recycle("Resycle"); - double tolerance = 1e-10; - HPliquidRecycle.setTolerance(tolerance); - HPliquidRecycle.addStream(gasInletScrubber.getLiquidOutStream()); - inletSeparator.addStream(HPliquidRecycle.getOutStream()); - - getOperations().add(inletSeparator); - getOperations().add(liquidOutHeater); - getOperations().add(firstStageSeparator); - getOperations().add(valve1); - getOperations().add(secondStageSeparator); - getOperations().add(thirdStageValve); - getOperations().add(thirdStageSeparator); - getOperations().add(thirdStageCompressor); - getOperations().add(thirdStageMixer); - getOperations().add(thirdSstageCoooler); - getOperations().add(thirdStageScrubber); - getOperations().add(HPliquidRecycle); - getOperations().add(secondStageCompressor); - getOperations().add(oilCooler); - getOperations().add(HPgasMixer); - getOperations().add(inletGasCooler); - getOperations().add(gasInletScrubber); - - // gasExitStream = gasInletScrubber.getGasOutStream(); - // oilExitStream = thirdStageSeparator.getOilOutStream(); + getOperations().run(id); + + gasExitStream = gasInletScrubber.getGasOutStream(); + oilExitStream = oilCooler.getOutletStream(); + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public void initializeModule() { + isInitializedModule = true; + double inletPressure = feedStream.getPressure(); + Separator inletSeparator = new Separator("Inlet separator", feedStream); + + Heater liquidOutHeater = new Heater("oil/water heater", inletSeparator.getLiquidOutStream()); + liquidOutHeater.setOutTemperature(heatedOilTemperature); + + ThreePhaseSeparator firstStageSeparator = + new ThreePhaseSeparator("1st stage separator", liquidOutHeater.getOutletStream()); + + ThrottlingValve valve1 = + new ThrottlingValve("1stTo2ndStageOilValve", firstStageSeparator.getOilOutStream()); + valve1.setOutletPressure(secondstagePressure); + + ThreePhaseSeparator secondStageSeparator = + new ThreePhaseSeparator("2nd stage Separator", valve1.getOutletStream()); + + ThrottlingValve thirdStageValve = + new ThrottlingValve("2-3stageOilValve", secondStageSeparator.getLiquidOutStream()); + thirdStageValve.setOutletPressure(thirdstagePressure); + + ThreePhaseSeparator thirdStageSeparator = + new ThreePhaseSeparator("3rd stage Separator", thirdStageValve.getOutletStream()); + + oilCooler = new Cooler("export oil cooler", thirdStageSeparator.getLiquidOutStream()); + oilCooler.setOutTemperature(exportOilTemperature); + + Compressor thirdStageCompressor = + new Compressor("3rd stage recompressor", thirdStageSeparator.getGasOutStream()); + thirdStageCompressor.setOutletPressure(secondstagePressure); + + Cooler thirdSstageCoooler = + new Cooler("3rd stage cooler", thirdStageCompressor.getOutletStream()); + thirdSstageCoooler.setOutTemperature(firstStageCompressorAfterCoolerTemperature); + + Mixer thirdStageMixer = new Mixer("1st and 2nd stage gas mixer"); + thirdStageMixer.addStream(thirdSstageCoooler.getOutletStream()); + thirdStageMixer.addStream(secondStageSeparator.getGasOutStream()); + + Separator thirdStageScrubber = + new Separator("recompression scrubber", thirdStageMixer.getOutletStream()); + secondStageSeparator.addStream(thirdStageScrubber.getLiquidOutStream()); + + Compressor secondStageCompressor = + new Compressor("2nd stage recompressor", thirdStageScrubber.getGasOutStream()); + secondStageCompressor.setOutletPressure(inletPressure); + + Mixer HPgasMixer = new Mixer("HPgas mixer"); + HPgasMixer.addStream(firstStageSeparator.getGasOutStream()); + HPgasMixer.addStream(secondStageCompressor.getOutletStream()); + HPgasMixer.addStream(inletSeparator.getGasOutStream()); + + Cooler inletGasCooler = new Cooler("HP gas cooler", HPgasMixer.getOutletStream()); + inletGasCooler.setOutTemperature(exitGasScrubberTemperature); + + gasInletScrubber = new Separator("HP gas scrubber", inletGasCooler.getOutletStream()); + + Recycle HPliquidRecycle = new Recycle("Resycle"); + double tolerance = 1e-10; + HPliquidRecycle.setTolerance(tolerance); + HPliquidRecycle.addStream(gasInletScrubber.getLiquidOutStream()); + inletSeparator.addStream(HPliquidRecycle.getOutStream()); + + getOperations().add(inletSeparator); + getOperations().add(liquidOutHeater); + getOperations().add(firstStageSeparator); + getOperations().add(valve1); + getOperations().add(secondStageSeparator); + getOperations().add(thirdStageValve); + getOperations().add(thirdStageSeparator); + getOperations().add(thirdStageCompressor); + getOperations().add(thirdStageMixer); + getOperations().add(thirdSstageCoooler); + getOperations().add(thirdStageScrubber); + getOperations().add(HPliquidRecycle); + getOperations().add(secondStageCompressor); + getOperations().add(oilCooler); + getOperations().add(HPgasMixer); + getOperations().add(inletGasCooler); + getOperations().add(gasInletScrubber); + + // gasExitStream = gasInletScrubber.getGasOutStream(); + // oilExitStream = thirdStageSeparator.getOilOutStream(); + } + + /** {@inheritDoc} */ + @Override + public void initializeStreams() { + isInitializedStreams = true; + } + + /** {@inheritDoc} */ + @Override + public void calcDesign() { + // design is done here + } + + /** {@inheritDoc} */ + @Override + public void setDesign() { + // set design is done here + } + + /** {@inheritDoc} */ + @Override + public void setSpecification(String specificationName, double value) { + if (specificationName.equals("Second stage pressure")) { + secondstagePressure = value; } - - /** {@inheritDoc} */ - @Override - public void initializeStreams() { - isInitializedStreams = true; + if (specificationName.equals("heated oil temperature")) { + heatedOilTemperature = value; } - - /** {@inheritDoc} */ - @Override - public void calcDesign() { - // design is done here + if (specificationName.equals("Third stage pressure")) { + thirdstagePressure = value; } - - /** {@inheritDoc} */ - @Override - public void setDesign() { - // set design is done here + if (specificationName.equals("Gas exit temperature")) { + exitGasScrubberTemperature = value; } - - /** {@inheritDoc} */ - @Override - public void setSpecification(String specificationName, double value) { - if (specificationName.equals("Second stage pressure")) { - secondstagePressure = value; - } - if (specificationName.equals("heated oil temperature")) { - heatedOilTemperature = value; - } - if (specificationName.equals("Third stage pressure")) { - thirdstagePressure = value; - } - if (specificationName.equals("Gas exit temperature")) { - exitGasScrubberTemperature = value; - } - if (specificationName.equals("First stage compressor after cooler temperature")) { - firstStageCompressorAfterCoolerTemperature = value; - } - if (specificationName.equals("Export oil temperature")) { - exportOilTemperature = value; - } + if (specificationName.equals("First stage compressor after cooler temperature")) { + firstStageCompressorAfterCoolerTemperature = value; } - - /** - *

main.

- * - * @param args an array of {@link java.lang.String} objects - */ - @SuppressWarnings("unused") - public static void main(String[] args) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos(273.15 + 50, 65); - - // testSystem.addComponent("CO2", 1); - // testSystem.addComponent("nitrogen", 1); - testSystem.addComponent("methane", 95); - // testSystem.addComponent("ethane", 1); - // testSystem.addTBPfraction("C7", 1.0, 187.0 / 1000.0, 0.84738); - - // testSystem.addComponent("propane", 5); - // testSystem.addComponent("n-octane", 2); - testSystem.addComponent("nC10", 6); - // testSystem.setHeavyTBPfractionAsPlusFraction(); - // testSystem.getCharacterization().characterisePlusFraction(); - - testSystem.addComponent("water", 12); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - testSystem.setMultiPhaseCheck(true); - testSystem.init(0); - testSystem.init(3); - double a = testSystem.getTotalNumberOfMoles(); - - Stream wellStream = new Stream("Well stream", testSystem); - // wellStream.getThermoSystem().setTotalFlowRate(5.0, "MSm^3/day"); - - SeparationTrainModuleSimple separationModule = new SeparationTrainModuleSimple("simpleSepTrain"); - separationModule.addInputStream("feed stream", wellStream); - separationModule.setSpecification("Second stage pressure", 15.0); - separationModule.setSpecification("heated oil temperature", 273.15 + 55.0); - separationModule.setSpecification("Third stage pressure", 1.0); - separationModule.setSpecification("Gas exit temperature", 273.15 + 25.0); - separationModule.setSpecification("First stage compressor after cooler temperature", - 273.15 + 25.0); - separationModule.setSpecification("Export oil temperature", 273.15 + 25.0); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - - operations.add(wellStream); - operations.add(separationModule); - // separationModule.getUnit("") - // ((Recycle) operations.getUnit("Resycle")).setTolerance(1e-9); - - operations.run(); - - // ArrayList names2 = operations.getAllUnitNames(); - // processSimulation.processEquipment.ProcessEquipmentInterface tempStr = - // (ProcessEquipmentBaseClass) operations.getUnit("2nd stage recompressor"); - // tempStr.displayResult(); - // wellStream.displayResult(); - ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("Inlet separator")) - .getMechanicalDesign().calcDesign(); - ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("Inlet separator")) - .getMechanicalDesign().displayResults(); - - ((ProcessEquipmentInterface) separationModule.getOperations() - .getUnit("1st stage separator")).getMechanicalDesign().calcDesign(); - ((ProcessEquipmentInterface) separationModule.getOperations() - .getUnit("1st stage separator")).getMechanicalDesign().displayResults(); - - ((ProcessEquipmentInterface) separationModule.getOperations() - .getUnit("2nd stage Separator")).getMechanicalDesign().calcDesign(); - ((ProcessEquipmentInterface) separationModule.getOperations() - .getUnit("2nd stage Separator")).getMechanicalDesign().displayResults(); - - ((ProcessEquipmentInterface) separationModule.getOperations() - .getUnit("3rd stage Separator")).getMechanicalDesign().calcDesign(); - ((ProcessEquipmentInterface) separationModule.getOperations() - .getUnit("3rd stage Separator")).getMechanicalDesign().displayResults(); - - ((ProcessEquipmentInterface) separationModule.getOperations() - .getUnit("2nd stage recompressor")).getMechanicalDesign().calcDesign(); - ((ProcessEquipmentInterface) separationModule.getOperations() - .getUnit("2nd stage recompressor")).getMechanicalDesign().displayResults(); - - operations.getSystemMechanicalDesign().runDesignCalculation(); - operations.getSystemMechanicalDesign().getTotalPlotSpace(); - System.out.println("Modules " + operations.getSystemMechanicalDesign().getTotalVolume()); - - System.out.println( - "Modules " + operations.getSystemMechanicalDesign().getTotalNumberOfModules()); - System.out.println("Weight " + operations.getSystemMechanicalDesign().getTotalWeight()); - System.out.println( - "Plot space " + operations.getSystemMechanicalDesign().getTotalPlotSpace()); - System.out.println("CAPEX " + operations.getCostEstimator().getWeightBasedCAPEXEstimate()); - System.out.println("CAPEX " + operations.getCostEstimator().getCAPEXestimate()); - - /* - * separationModule.getOutputStream("Inlet separator").displayResult(); - * separationModule.getOutputStream("oil exit stream").displayResult(); - * System.out.println("third stage compressor power " + ((Compressor) - * separationModule.getOperations().getUnit("3rd stage recompressor")).getPower( ) + " W"); - * System.out.println("secondstage compressor power " + ((Compressor) - * separationModule.getOperations().getUnit("2nd stage recompressor")).getPower( ) + " W"); - * System.out.println("third stage cooler duty " + ((Cooler) - * separationModule.getOperations().getUnit("3rd stage cooler")).getEnergyInput( ) + " W"); - * System.out.println("HP gas cooler duty " + ((Cooler) - * separationModule.getOperations().getUnit("HP gas cooler")).getEnergyInput() + " W"); - * System.out.println("Export oil flow " + - * separationModule.getOutputStream("oil exit stream").getThermoSystem(). - * getTotalNumberOfMoles() * - * separationModule.getOutputStream("oil exit stream").getThermoSystem(). getMolarMass() / - * separationModule.getOutputStream("oil exit stream").getThermoSystem(). - * getPhase(0).getPhysicalProperties().getDensity() * 3600.0 + " m^3/hr"); - * System.out.println("Export gas flow " + - * separationModule.getOutputStream("gas exit stream").getThermoSystem(). - * getTotalNumberOfMoles() * - * separationModule.getOutputStream("gas exit stream").getThermoSystem(). getMolarMass() / - * separationModule.getOutputStream("gas exit stream").getThermoSystem(). - * getPhase(0).getPhysicalProperties().getDensity() * 3600.0 + " m^3/hr"); - * System.out.println("Export gas flow " + - * separationModule.getOutputStream("gas exit stream").getThermoSystem(). - * getTotalNumberOfMoles() * 8.314 * (273.15 + 15.0) / 101325.0 * 3600.0 * 24 / 1.0e6 + - * " MSm^3/day"); System.out.println("oil/water heater duty " + ((Heater) - * separationModule.getOperations().getUnit("oil/water heater")).getEnergyInput( ) + " W"); - * System.out.println("Export oil cooler duty " + ((Cooler) - * separationModule.getOperations().getUnit("export oil cooler")).getEnergyInput () + " W"); - */ + if (specificationName.equals("Export oil temperature")) { + exportOilTemperature = value; } + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String[] args) { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos(273.15 + 50, 65); + + // testSystem.addComponent("CO2", 1); + // testSystem.addComponent("nitrogen", 1); + testSystem.addComponent("methane", 95); + // testSystem.addComponent("ethane", 1); + // testSystem.addTBPfraction("C7", 1.0, 187.0 / 1000.0, 0.84738); + + // testSystem.addComponent("propane", 5); + // testSystem.addComponent("n-octane", 2); + testSystem.addComponent("nC10", 6); + // testSystem.setHeavyTBPfractionAsPlusFraction(); + // testSystem.getCharacterization().characterisePlusFraction(); + + testSystem.addComponent("water", 12); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + testSystem.setMultiPhaseCheck(true); + testSystem.init(0); + testSystem.init(3); + double a = testSystem.getTotalNumberOfMoles(); + + Stream wellStream = new Stream("Well stream", testSystem); + // wellStream.getThermoSystem().setTotalFlowRate(5.0, "MSm^3/day"); + + SeparationTrainModuleSimple separationModule = + new SeparationTrainModuleSimple("simpleSepTrain"); + separationModule.addInputStream("feed stream", wellStream); + separationModule.setSpecification("Second stage pressure", 15.0); + separationModule.setSpecification("heated oil temperature", 273.15 + 55.0); + separationModule.setSpecification("Third stage pressure", 1.0); + separationModule.setSpecification("Gas exit temperature", 273.15 + 25.0); + separationModule.setSpecification("First stage compressor after cooler temperature", + 273.15 + 25.0); + separationModule.setSpecification("Export oil temperature", 273.15 + 25.0); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + + operations.add(wellStream); + operations.add(separationModule); + // separationModule.getUnit("") + // ((Recycle) operations.getUnit("Resycle")).setTolerance(1e-9); + + operations.run(); + + // ArrayList names2 = operations.getAllUnitNames(); + // processSimulation.processEquipment.ProcessEquipmentInterface tempStr = + // (ProcessEquipmentBaseClass) operations.getUnit("2nd stage recompressor"); + // tempStr.displayResult(); + // wellStream.displayResult(); + ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("Inlet separator")) + .getMechanicalDesign().calcDesign(); + ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("Inlet separator")) + .getMechanicalDesign().displayResults(); + + ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("1st stage separator")) + .getMechanicalDesign().calcDesign(); + ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("1st stage separator")) + .getMechanicalDesign().displayResults(); + + ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("2nd stage Separator")) + .getMechanicalDesign().calcDesign(); + ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("2nd stage Separator")) + .getMechanicalDesign().displayResults(); + + ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("3rd stage Separator")) + .getMechanicalDesign().calcDesign(); + ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("3rd stage Separator")) + .getMechanicalDesign().displayResults(); + + ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("2nd stage recompressor")) + .getMechanicalDesign().calcDesign(); + ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("2nd stage recompressor")) + .getMechanicalDesign().displayResults(); + + operations.getSystemMechanicalDesign().runDesignCalculation(); + operations.getSystemMechanicalDesign().getTotalPlotSpace(); + System.out.println("Modules " + operations.getSystemMechanicalDesign().getTotalVolume()); + + System.out + .println("Modules " + operations.getSystemMechanicalDesign().getTotalNumberOfModules()); + System.out.println("Weight " + operations.getSystemMechanicalDesign().getTotalWeight()); + System.out.println("Plot space " + operations.getSystemMechanicalDesign().getTotalPlotSpace()); + System.out.println("CAPEX " + operations.getCostEstimator().getWeightBasedCAPEXEstimate()); + System.out.println("CAPEX " + operations.getCostEstimator().getCAPEXestimate()); + + /* + * separationModule.getOutputStream("Inlet separator").displayResult(); + * separationModule.getOutputStream("oil exit stream").displayResult(); + * System.out.println("third stage compressor power " + ((Compressor) + * separationModule.getOperations().getUnit("3rd stage recompressor")).getPower( ) + " W"); + * System.out.println("secondstage compressor power " + ((Compressor) + * separationModule.getOperations().getUnit("2nd stage recompressor")).getPower( ) + " W"); + * System.out.println("third stage cooler duty " + ((Cooler) + * separationModule.getOperations().getUnit("3rd stage cooler")).getEnergyInput( ) + " W"); + * System.out.println("HP gas cooler duty " + ((Cooler) + * separationModule.getOperations().getUnit("HP gas cooler")).getEnergyInput() + " W"); + * System.out.println("Export oil flow " + + * separationModule.getOutputStream("oil exit stream").getThermoSystem(). + * getTotalNumberOfMoles() * + * separationModule.getOutputStream("oil exit stream").getThermoSystem(). getMolarMass() / + * separationModule.getOutputStream("oil exit stream").getThermoSystem(). + * getPhase(0).getPhysicalProperties().getDensity() * 3600.0 + " m^3/hr"); + * System.out.println("Export gas flow " + + * separationModule.getOutputStream("gas exit stream").getThermoSystem(). + * getTotalNumberOfMoles() * + * separationModule.getOutputStream("gas exit stream").getThermoSystem(). getMolarMass() / + * separationModule.getOutputStream("gas exit stream").getThermoSystem(). + * getPhase(0).getPhysicalProperties().getDensity() * 3600.0 + " m^3/hr"); + * System.out.println("Export gas flow " + + * separationModule.getOutputStream("gas exit stream").getThermoSystem(). + * getTotalNumberOfMoles() * 8.314 * (273.15 + 15.0) / 101325.0 * 3600.0 * 24 / 1.0e6 + + * " MSm^3/day"); System.out.println("oil/water heater duty " + ((Heater) + * separationModule.getOperations().getUnit("oil/water heater")).getEnergyInput( ) + " W"); + * System.out.println("Export oil cooler duty " + ((Cooler) + * separationModule.getOperations().getUnit("export oil cooler")).getEnergyInput () + " W"); + */ + } } diff --git a/src/main/java/neqsim/processSimulation/processSystem/processModules/WellFluidModule.java b/src/main/java/neqsim/processSimulation/processSystem/processModules/WellFluidModule.java index 095034d208..fd82e3fcd2 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/processModules/WellFluidModule.java +++ b/src/main/java/neqsim/processSimulation/processSystem/processModules/WellFluidModule.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processSystem.processModules; +import java.util.UUID; import neqsim.processSimulation.processEquipment.heatExchanger.Cooler; import neqsim.processSimulation.processEquipment.heatExchanger.Heater; import neqsim.processSimulation.processEquipment.mixer.Mixer; @@ -11,232 +12,242 @@ import neqsim.processSimulation.processSystem.ProcessModuleBaseClass; /** - *

WellFluidModule class.

+ *

+ * WellFluidModule class. + *

* * @author esol * @version $Id: $Id */ public class WellFluidModule extends ProcessModuleBaseClass { - private static final long serialVersionUID = 1000; - - protected StreamInterface feedStream = null, outStream = null; - // ThreePhaseSeparator thirdStageSeparator = null; - Cooler oilCooler; - double secondstagePressure = 15.00; // bar' - double inletPressure = 55.0, gasfactor = 0.1; - double thirdstagePressure = 1.01325; - double separationTemperature = 273.15 + 15; - double exitGasScrubberTemperature = 273.15 + 30; - double firstStageCompressorAfterCoolerTemperature = 273.15 + 30; - double exportOilTemperature = 273.15 + 30; - - public WellFluidModule(String name) { - super(name); - } + private static final long serialVersionUID = 1000; - /** {@inheritDoc} */ - @Override - public void addInputStream(String streamName, StreamInterface stream) { - if (streamName.equals("feed stream")) { - this.feedStream = stream; - } - } + protected StreamInterface feedStream = null; + protected StreamInterface outStream = null; - /** {@inheritDoc} */ - @Override - public StreamInterface getOutputStream(String streamName) { - if (!isInitializedStreams) { - initializeStreams(); - } - return this.outStream; - } + // ThreePhaseSeparator thirdStageSeparator = null; + Cooler oilCooler; + double secondstagePressure = 15.00; // bar' + double inletPressure = 55.0; - /** {@inheritDoc} */ - @Override - public void run() { - if (!isInitializedModule) { - initializeModule(); - } - getOperations().run(); - - double volGas = ((Mixer) getOperations().getUnit("gas mixer")).getOutletStream() - .getThermoSystem().getVolume(); - double volOil = ((ThreePhaseSeparator) getOperations().getUnit("3rd stage Separator")) - .getOilOutStream().getThermoSystem().getVolume(); - - double GOR = volGas / volOil; - System.out.println("GOR " + GOR); - outStream = ((Mixer) getOperations().getUnit("well mixer")).getOutletStream(); - - // ((Heater) getOperations().getUnit("gas heater")).displayResult(); - - Stream gasStream = - (Stream) ((Heater) getOperations().getUnit("gas heater")).getOutletStream().clone(); - gasStream.getThermoSystem().setPressure(inletPressure); - Stream oilStream = - (Stream) ((ThreePhaseSeparator) getOperations().getUnit("3rd stage Separator")) - .getOilOutStream().clone(); - oilStream.getThermoSystem().setPressure(inletPressure); - - ((Separator) getOperations().getUnit("Inlet separator")).addStream(gasStream); - ((Separator) getOperations().getUnit("Inlet separator")).addStream(oilStream); - getOperations().run(); - - volGas = ((Mixer) getOperations().getUnit("gas mixer")).getOutletStream().getThermoSystem() - .getVolume(); - volOil = ((ThreePhaseSeparator) getOperations().getUnit("3rd stage Separator")) - .getOilOutStream().getThermoSystem().getVolume(); - - GOR = volGas / volOil; - System.out.println("GOR " + GOR); - outStream = ((Mixer) getOperations().getUnit("well mixer")).getOutletStream(); - } + double gasfactor = 0.1; - /** {@inheritDoc} */ - @Override - public void initializeModule() { - isInitializedModule = true; - inletPressure = feedStream.getPressure(); - Separator inletSeparator = new Separator("Inlet separator", feedStream); - - Heater liquidOutHeater = - new Heater("oil/water heater", inletSeparator.getLiquidOutStream()); - liquidOutHeater.setOutTemperature(separationTemperature); - - ThreePhaseSeparator firstStageSeparator = - new ThreePhaseSeparator("1st stage separator", liquidOutHeater.getOutletStream()); - - ThrottlingValve valve1 = - new ThrottlingValve("1stTo2ndStageOilValve", firstStageSeparator.getOilOutStream()); - valve1.setOutletPressure(secondstagePressure); - - Heater liquidOutHeater2 = new Heater("oil/water heater2", valve1.getOutletStream()); - liquidOutHeater2.setOutTemperature(separationTemperature); - - ThreePhaseSeparator secondStageSeparator = - new ThreePhaseSeparator("2nd stage Separator", liquidOutHeater2.getOutletStream()); - - ThrottlingValve thirdStageValve = - new ThrottlingValve("2-3stageOilValve", secondStageSeparator.getLiquidOutStream()); - thirdStageValve.setOutletPressure(thirdstagePressure); - - Heater liquidOutHeater3 = - new Heater("oil/water heater3", thirdStageValve.getOutletStream()); - liquidOutHeater3.setOutTemperature(separationTemperature); - - ThreePhaseSeparator thirdStageSeparator = - new ThreePhaseSeparator("3rd stage Separator", liquidOutHeater3.getOutletStream()); - - Mixer gasMixer = new Mixer("gas mixer"); - - gasMixer.addStream(inletSeparator.getGasOutStream()); - gasMixer.addStream(firstStageSeparator.getGasOutStream()); - gasMixer.addStream(secondStageSeparator.getGasOutStream()); - gasMixer.addStream(thirdStageSeparator.getGasOutStream()); - - Heater gasHeater = new Heater("gas heater", gasMixer.getOutletStream()); - gasHeater.setOutTemperature(separationTemperature); - - Mixer wellStreamMixer = new Mixer("well mixer"); - wellStreamMixer.addStream(thirdStageSeparator.getOilOutStream()); - wellStreamMixer.addStream(gasHeater.getOutletStream()); - - getOperations().add(inletSeparator); - getOperations().add(liquidOutHeater); - getOperations().add(firstStageSeparator); - getOperations().add(valve1); - getOperations().add(liquidOutHeater2); - getOperations().add(secondStageSeparator); - getOperations().add(thirdStageValve); - getOperations().add(liquidOutHeater3); - getOperations().add(thirdStageSeparator); - getOperations().add(gasMixer); - getOperations().add(gasHeater); - getOperations().add(wellStreamMixer); - - // gasExitStream = gasInletScrubber.getGasOutStream(); - // oilExitStream = thirdStageSeparator.getOilOutStream(); - } + double thirdstagePressure = 1.01325; + double separationTemperature = 273.15 + 15; + double exitGasScrubberTemperature = 273.15 + 30; + double firstStageCompressorAfterCoolerTemperature = 273.15 + 30; + double exportOilTemperature = 273.15 + 30; - /** {@inheritDoc} */ - @Override - public void initializeStreams() { - isInitializedStreams = true; - } + public WellFluidModule(String name) { + super(name); + } - /** {@inheritDoc} */ - @Override - public void calcDesign() { - // design is done here + /** {@inheritDoc} */ + @Override + public void addInputStream(String streamName, StreamInterface stream) { + if (streamName.equals("feed stream")) { + this.feedStream = stream; } + } - /** {@inheritDoc} */ - @Override - public void setDesign() { - // set design is done here + /** {@inheritDoc} */ + @Override + public StreamInterface getOutputStream(String streamName) { + if (!isInitializedStreams) { + initializeStreams(); } - - /** {@inheritDoc} */ - @Override - public void setSpecification(String specificationName, double value) { - if (specificationName.equals("Second stage pressure")) { - secondstagePressure = value; - } - if (specificationName.equals("separation temperature")) { - separationTemperature = value; - } - if (specificationName.equals("Third stage pressure")) { - thirdstagePressure = value; - } + return this.outStream; + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + if (!isInitializedModule) { + initializeModule(); } - - /** - *

main.

- * - * @param args an array of {@link java.lang.String} objects - */ - @SuppressWarnings("unused") - public static void main(String[] args) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos(273.15 + 50, 65); - - // testSystem.addComponent("CO2", 1); - // testSystem.addComponent("nitrogen", 1); - testSystem.addComponent("methane", 195); - // testSystem.addComponent("ethane", 1); - // testSystem.addTBPfraction("C7", 1.0, 187.0 / 1000.0, 0.84738); - - // testSystem.addComponent("propane", 5); - // testSystem.addComponent("n-octane", 2); - testSystem.addComponent("nC10", 6); - // testSystem.setHeavyTBPfractionAsPlusFraction(); - // testSystem.getCharacterization().characterisePlusFraction(); - - testSystem.addComponent("water", 12); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - testSystem.setMultiPhaseCheck(true); - testSystem.init(0); - testSystem.init(3); - double a = testSystem.getTotalNumberOfMoles(); - - Stream wellStream = new Stream("Well stream", testSystem); - // wellStream.getThermoSystem().setTotalFlowRate(5.0, "MSm^3/day"); - - WellFluidModule separationModule = new WellFluidModule("separationModule"); - separationModule.addInputStream("feed stream", wellStream); - separationModule.setSpecification("Second stage pressure", 15.0); - separationModule.setSpecification("separation temperature", 273.15 + 15.0); - separationModule.setSpecification("Third stage pressure", 1.01325); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - - operations.add(wellStream); - operations.add(separationModule); - // separationModule.getUnit("") - // ((Recycle) operations.getUnit("Resycle")).setTolerance(1e-9); - - operations.run(); + getOperations().run(id); + + double volGas = ((Mixer) getOperations().getUnit("gas mixer")).getOutletStream() + .getThermoSystem().getVolume(); + double volOil = ((ThreePhaseSeparator) getOperations().getUnit("3rd stage Separator")) + .getOilOutStream().getThermoSystem().getVolume(); + + double GOR = volGas / volOil; + System.out.println("GOR " + GOR); + outStream = ((Mixer) getOperations().getUnit("well mixer")).getOutletStream(); + + // ((Heater) getOperations().getUnit("gas heater")).displayResult(); + + Stream gasStream = + (Stream) ((Heater) getOperations().getUnit("gas heater")).getOutletStream().clone(); + gasStream.getThermoSystem().setPressure(inletPressure); + Stream oilStream = + (Stream) ((ThreePhaseSeparator) getOperations().getUnit("3rd stage Separator")) + .getOilOutStream().clone(); + oilStream.getThermoSystem().setPressure(inletPressure); + + ((Separator) getOperations().getUnit("Inlet separator")).addStream(gasStream); + ((Separator) getOperations().getUnit("Inlet separator")).addStream(oilStream); + getOperations().run(id); + + volGas = ((Mixer) getOperations().getUnit("gas mixer")).getOutletStream().getThermoSystem() + .getVolume(); + volOil = ((ThreePhaseSeparator) getOperations().getUnit("3rd stage Separator")) + .getOilOutStream().getThermoSystem().getVolume(); + + GOR = volGas / volOil; + System.out.println("GOR " + GOR); + outStream = ((Mixer) getOperations().getUnit("well mixer")).getOutletStream(); + + outStream.setCalculationIdentifier(id); + setCalculationIdentifier(id); + } + + /** {@inheritDoc} */ + @Override + public void initializeModule() { + isInitializedModule = true; + inletPressure = feedStream.getPressure(); + Separator inletSeparator = new Separator("Inlet separator", feedStream); + + Heater liquidOutHeater = new Heater("oil/water heater", inletSeparator.getLiquidOutStream()); + liquidOutHeater.setOutTemperature(separationTemperature); + + ThreePhaseSeparator firstStageSeparator = + new ThreePhaseSeparator("1st stage separator", liquidOutHeater.getOutletStream()); + + ThrottlingValve valve1 = + new ThrottlingValve("1stTo2ndStageOilValve", firstStageSeparator.getOilOutStream()); + valve1.setOutletPressure(secondstagePressure); + + Heater liquidOutHeater2 = new Heater("oil/water heater2", valve1.getOutletStream()); + liquidOutHeater2.setOutTemperature(separationTemperature); + + ThreePhaseSeparator secondStageSeparator = + new ThreePhaseSeparator("2nd stage Separator", liquidOutHeater2.getOutletStream()); + + ThrottlingValve thirdStageValve = + new ThrottlingValve("2-3stageOilValve", secondStageSeparator.getLiquidOutStream()); + thirdStageValve.setOutletPressure(thirdstagePressure); + + Heater liquidOutHeater3 = new Heater("oil/water heater3", thirdStageValve.getOutletStream()); + liquidOutHeater3.setOutTemperature(separationTemperature); + + ThreePhaseSeparator thirdStageSeparator = + new ThreePhaseSeparator("3rd stage Separator", liquidOutHeater3.getOutletStream()); + + Mixer gasMixer = new Mixer("gas mixer"); + + gasMixer.addStream(inletSeparator.getGasOutStream()); + gasMixer.addStream(firstStageSeparator.getGasOutStream()); + gasMixer.addStream(secondStageSeparator.getGasOutStream()); + gasMixer.addStream(thirdStageSeparator.getGasOutStream()); + + Heater gasHeater = new Heater("gas heater", gasMixer.getOutletStream()); + gasHeater.setOutTemperature(separationTemperature); + + Mixer wellStreamMixer = new Mixer("well mixer"); + wellStreamMixer.addStream(thirdStageSeparator.getOilOutStream()); + wellStreamMixer.addStream(gasHeater.getOutletStream()); + + getOperations().add(inletSeparator); + getOperations().add(liquidOutHeater); + getOperations().add(firstStageSeparator); + getOperations().add(valve1); + getOperations().add(liquidOutHeater2); + getOperations().add(secondStageSeparator); + getOperations().add(thirdStageValve); + getOperations().add(liquidOutHeater3); + getOperations().add(thirdStageSeparator); + getOperations().add(gasMixer); + getOperations().add(gasHeater); + getOperations().add(wellStreamMixer); + + // gasExitStream = gasInletScrubber.getGasOutStream(); + // oilExitStream = thirdStageSeparator.getOilOutStream(); + } + + /** {@inheritDoc} */ + @Override + public void initializeStreams() { + isInitializedStreams = true; + } + + /** {@inheritDoc} */ + @Override + public void calcDesign() { + // design is done here + } + + /** {@inheritDoc} */ + @Override + public void setDesign() { + // set design is done here + } + + /** {@inheritDoc} */ + @Override + public void setSpecification(String specificationName, double value) { + if (specificationName.equals("Second stage pressure")) { + secondstagePressure = value; + } + if (specificationName.equals("separation temperature")) { + separationTemperature = value; + } + if (specificationName.equals("Third stage pressure")) { + thirdstagePressure = value; } + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String[] args) { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos(273.15 + 50, 65); + + // testSystem.addComponent("CO2", 1); + // testSystem.addComponent("nitrogen", 1); + testSystem.addComponent("methane", 195); + // testSystem.addComponent("ethane", 1); + // testSystem.addTBPfraction("C7", 1.0, 187.0 / 1000.0, 0.84738); + + // testSystem.addComponent("propane", 5); + // testSystem.addComponent("n-octane", 2); + testSystem.addComponent("nC10", 6); + // testSystem.setHeavyTBPfractionAsPlusFraction(); + // testSystem.getCharacterization().characterisePlusFraction(); + + testSystem.addComponent("water", 12); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + testSystem.setMultiPhaseCheck(true); + testSystem.init(0); + testSystem.init(3); + double a = testSystem.getTotalNumberOfMoles(); + + Stream wellStream = new Stream("Well stream", testSystem); + // wellStream.getThermoSystem().setTotalFlowRate(5.0, "MSm^3/day"); + + WellFluidModule separationModule = new WellFluidModule("separationModule"); + separationModule.addInputStream("feed stream", wellStream); + separationModule.setSpecification("Second stage pressure", 15.0); + separationModule.setSpecification("separation temperature", 273.15 + 15.0); + separationModule.setSpecification("Third stage pressure", 1.01325); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + + operations.add(wellStream); + operations.add(separationModule); + // separationModule.getUnit("") + // ((Recycle) operations.getUnit("Resycle")).setTolerance(1e-9); + + operations.run(); + } } diff --git a/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976.java b/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976.java index 1ef3954191..3d30b9855c 100644 --- a/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976.java +++ b/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976.java @@ -242,7 +242,6 @@ public double getValue(String returnParameter, java.lang.String returnUnit) { returnValue = Zmix15; } - if (returnParameter.equals("CompressionFactor")) { return returnValue; } diff --git a/src/main/java/neqsim/thermo/ThermodynamicModelTest.java b/src/main/java/neqsim/thermo/ThermodynamicModelTest.java index ff7dba0307..babbd3d846 100644 --- a/src/main/java/neqsim/thermo/ThermodynamicModelTest.java +++ b/src/main/java/neqsim/thermo/ThermodynamicModelTest.java @@ -149,7 +149,6 @@ public boolean checkFugacityCoefficientsDn() { return Math.abs(sum) < 1e-10; } - /** *

* checkFugacityCoefficientsDn2. diff --git a/src/main/java/neqsim/thermo/atomElement/UNIFACgroup.java b/src/main/java/neqsim/thermo/atomElement/UNIFACgroup.java index 23cceb4ab6..676c82259e 100644 --- a/src/main/java/neqsim/thermo/atomElement/UNIFACgroup.java +++ b/src/main/java/neqsim/thermo/atomElement/UNIFACgroup.java @@ -268,7 +268,6 @@ public boolean equals(Object obj) { */ } - /** * Getter for property xComp. * diff --git a/src/main/java/neqsim/thermo/component/ComponentPRvolcor.java b/src/main/java/neqsim/thermo/component/ComponentPRvolcor.java index 634ade1330..78c76de4e4 100644 --- a/src/main/java/neqsim/thermo/component/ComponentPRvolcor.java +++ b/src/main/java/neqsim/thermo/component/ComponentPRvolcor.java @@ -41,7 +41,6 @@ public double calccTT() { return 0.; } - public ComponentPRvolcor(String component_name, double moles, double molesInPhase, int compnumber) { super(component_name, moles, molesInPhase, compnumber); @@ -57,7 +56,6 @@ public void init(double temp, double pres, double totMoles, double beta, int typ c = calcc(); } - /** {@inheritDoc} */ // @Override public double getc() { @@ -89,12 +87,10 @@ public void Finit(PhaseInterface phase, double temp, double pres, double totMole } } - public double getCi() { return Ci; } - public double getCij(int j) { return Cij[j]; } @@ -102,7 +98,6 @@ public double getCij(int j) { // depending on the type of the volume translation (T-dependent or not) these sould be properly // modified - // second derivative of C with regards to mole fraction and temperature public double getCiT() { return 0; @@ -112,9 +107,7 @@ public double getcTT() { return 0; } - - - /// ** {@inheritDoc} */ do I need this inheritDoc thing? + /** {@inheritDoc} */ @Override public double dFdN(PhaseInterface phase, int numberOfComponents, double temperature, double pressure) { @@ -127,7 +120,6 @@ public double getFC(PhaseInterface phase, int numberOfComponents, double tempera return ((PhasePrEosvolcor) phase).FC(); } - /** {@inheritDoc} */ @Override public double dFdNdT(PhaseInterface phase, int numberOfComponents, double temperature, @@ -173,7 +165,6 @@ public double dFdNdN(int j, PhaseInterface phase, int numberOfComponents, double + phase.FD() * getAij(j); } - /** {@inheritDoc} */ @Override public double dFdNdV(PhaseInterface phase, int numberOfComponents, double temperature, @@ -182,10 +173,7 @@ public double dFdNdV(PhaseInterface phase, int numberOfComponents, double temper return phase.FnV() + phase.FBV() * getBi() + phase.FDV() * getAi() + loc_FCV * getCi(); } - - // Remember this trick above that professor showed to you...you can call whichever new F // expression // you need by first specifying the type "PhasePrEosvolcor" - } diff --git a/src/main/java/neqsim/thermo/component/ComponentUMRCPA.java b/src/main/java/neqsim/thermo/component/ComponentUMRCPA.java index 2528010acb..837550442b 100644 --- a/src/main/java/neqsim/thermo/component/ComponentUMRCPA.java +++ b/src/main/java/neqsim/thermo/component/ComponentUMRCPA.java @@ -155,7 +155,6 @@ public void createComponent(String component_name, double moles, double molesInP } - /** {@inheritDoc} */ @Override public void init(double temperature, double pressure, double totalNumberOfMoles, double beta, diff --git a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AtractiveTermMatCopPRUMRNew.java b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AtractiveTermMatCopPRUMRNew.java index a2d85c4a08..df593acb50 100644 --- a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AtractiveTermMatCopPRUMRNew.java +++ b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AtractiveTermMatCopPRUMRNew.java @@ -164,7 +164,6 @@ public double diffdiffalphaT(double temperature) { + 5.0 / 4.0 * parameters[4] * Math.pow(1.0 - Math.sqrt(Tr), 4.0) / Tc2Trpower32); } - @Override public double diffaT(double temperature) { if (useStandardAlphaForSupercritical && temperature / getComponent().getTC() > 1.0 diff --git a/src/main/java/neqsim/thermo/phase/PhaseInterface.java b/src/main/java/neqsim/thermo/phase/PhaseInterface.java index 15a4317548..30165c4f0f 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseInterface.java +++ b/src/main/java/neqsim/thermo/phase/PhaseInterface.java @@ -74,6 +74,13 @@ public interface PhaseInterface extends ThermodynamicConstantsInterface, Cloneab */ public double getDensity_AGA8(); + /** + * method to get the Joule Thomson Coefficient of a phase note: implemented in phaseEos. + * + * @return Joule Thomson coefficient in K/bar + */ + public double getJouleThomsonCoefficient(); + /** * method to get the Joule Thomson Coefficient of a phase note: implemented in phaseEos. * @@ -96,6 +103,13 @@ public interface PhaseInterface extends ThermodynamicConstantsInterface, Cloneab */ public void resetPhysicalProperties(); + /** + * method to return phase volume note: without Peneloux volume correction. + * + * @return volume in unit m3*1e5 + */ + public double getVolume(); + /** * method to return fluid volume. * @@ -140,6 +154,38 @@ public default double getGamma2() { */ public double getWtFractionOfWaxFormingComponents(); + /** + *

+ * getdrhodN. + *

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

+ * setInitType. + *

+ * + * @param initType a int + */ + public void setInitType(int initType); + + /** + *

+ * init. + *

+ * + * @param totalNumberOfMoles a double + * @param numberOfComponents a int + * @param type a int. Use 0 to init, and 1 to reset. + * @param phase a int + * @param beta a double + */ + public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, + double beta); + /** *

* init. @@ -149,12 +195,10 @@ public default double getGamma2() { /** *

- * getdrhodN. + * initPhysicalProperties. *

- * - * @return a double */ - public double getdrhodN(); + public void initPhysicalProperties(); /** *

@@ -228,36 +272,6 @@ public default double getGamma2() { */ public double getMoleFraction(); - /** - *

- * init. - *

- * - * @param totalNumberOfMoles a double - * @param numberOfComponents a int - * @param type a int. Use 0 to init, and 1 to reset. - * @param phase a int - * @param beta a double - */ - public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, - double beta); - - /** - *

- * initPhysicalProperties. - *

- */ - public void initPhysicalProperties(); - - /** - *

- * setInitType. - *

- * - * @param initType a int - */ - public void setInitType(int initType); - /** *

* getcomponentArray. @@ -365,6 +379,16 @@ public void removeComponent(String componentName, double moles, double molesInPh */ public double getFugacity(int compNumb); + /** + *

+ * getFugacity. + *

+ * + * @param compName a {@link java.lang.String} object + * @return a double + */ + public double getFugacity(String compName); + /** * method to return phase volume note: without Peneloux volume correction. * @@ -454,13 +478,6 @@ public void removeComponent(String componentName, double moles, double molesInPh */ public void setBeta(double beta); - /** - * method to return phase volume note: without Peneloux volume correction. - * - * @return volume in unit m3*1e5 - */ - public double getVolume(); - /** *

* setProperties. @@ -526,6 +543,16 @@ public void removeComponent(String componentName, double moles, double molesInPh */ public void setMixingRuleGEModel(String name); + /** + *

+ * getComponent. + *

+ * + * @param name a {@link java.lang.String} object + * @return a {@link neqsim.thermo.component.ComponentInterface} object + */ + public ComponentInterface getComponent(String name); + /** *

* getComponent. @@ -536,6 +563,16 @@ public void removeComponent(String componentName, double moles, double molesInPh */ public ComponentInterface getComponent(int i); + /** + *

+ * getActivityCoefficient. + *

+ * + * @param k a int + * @return a double + */ + public double getActivityCoefficient(int k); + /** *

* getActivityCoefficient. @@ -582,6 +619,16 @@ public void removeComponent(String componentName, double moles, double molesInPh */ public double getLogPureComponentFugacity(int k); + /** + *

+ * getPureComponentFugacity. + *

+ * + * @param k a int + * @return a double + */ + public double getPureComponentFugacity(int k); + /** *

* getPureComponentFugacity. @@ -593,6 +640,16 @@ public void removeComponent(String componentName, double moles, double molesInPh */ public double getPureComponentFugacity(int k, boolean pure); + /** + *

+ * addMolesChemReac. + *

+ * + * @param component a int + * @param dn a double + */ + public void addMolesChemReac(int component, double dn); + /** *

* addMolesChemReac. @@ -620,13 +677,13 @@ public void removeComponent(String componentName, double moles, double molesInPh /** *

- * getComponent. + * specify the type model for the physical properties you want to use. Type: 0 Orginal/default 1 + * Water 2 Glycol 3 Amine *

* - * @param name a {@link java.lang.String} object - * @return a {@link neqsim.thermo.component.ComponentInterface} object + * @param type a int */ - public ComponentInterface getComponent(String name); + public void setPhysicalProperties(int type); /** *

@@ -662,16 +719,6 @@ public void removeComponent(String componentName, double moles, double molesInPh */ public void setTemperature(double temperature); - /** - *

- * addMolesChemReac. - *

- * - * @param component a int - * @param dn a double - */ - public void addMolesChemReac(int component, double dn); - /** *

* getPhysicalProperties. @@ -1038,16 +1085,6 @@ public void removeComponent(String componentName, double moles, double molesInPh */ public double getZ(); - /** - *

- * specify the type model for the physical properties you want to use. Type: 0 Orginal/default 1 - * Water 2 Glycol 3 Amine - *

- * - * @param type a int - */ - public void setPhysicalProperties(int type); - /** *

* getPseudoCriticalPressure. @@ -1093,13 +1130,6 @@ public void removeComponent(String componentName, double moles, double molesInPh */ public void setNumberOfComponents(int k); - /** - * method to get the Joule Thomson Coefficient of a phase note: implemented in phaseEos. - * - * @return Joule Thomson coefficient in K/bar - */ - public double getJouleThomsonCoefficient(); - /** *

* setMixingRule. @@ -1163,15 +1193,6 @@ public void removeComponent(String componentName, double moles, double molesInPh */ public void setMolarVolume(double molarVolume); - /** - *

- * getPureComponentFugacity. - *

- * - * @param k a int - * @return a double - */ - public double getPureComponentFugacity(int k); // public double getInfiniteDiluteFugacity(int k); /** @@ -1212,15 +1233,6 @@ public void removeComponent(String componentName, double moles, double molesInPh */ public int getNumberOfIonicComponents(); - /** - *

- * getFugacity. - *

- * - * @param compName a {@link java.lang.String} object - * @return a double - */ - public double getFugacity(String compName); // double calcA2(PhaseInterface phase, double temperature, double pressure, int // numbcomp); // double calcB2(PhaseInterface phase, double temperature, double pressure, int @@ -1677,16 +1689,6 @@ public void removeComponent(String componentName, double moles, double molesInPh */ public double getLogInfiniteDiluteFugacity(int k); - /** - *

- * getActivityCoefficient. - *

- * - * @param k a int - * @return a double - */ - public double getActivityCoefficient(int k); - /** *

* Getter for property mixingRuleNumber. diff --git a/src/main/java/neqsim/thermo/phase/PhasePrEosvolcor.java b/src/main/java/neqsim/thermo/phase/PhasePrEosvolcor.java index bdd6f15222..c1b853da90 100644 --- a/src/main/java/neqsim/thermo/phase/PhasePrEosvolcor.java +++ b/src/main/java/neqsim/thermo/phase/PhasePrEosvolcor.java @@ -38,12 +38,10 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int type, in } - public double getCT() { return CT; } - public double getCTT() { return 0; } @@ -69,8 +67,6 @@ public double dFdV() { // note that in future the next thre lines should be modified to handle various mixing rules for // the translation - - public double getcij(ComponentEosInterface compArray, ComponentEosInterface compArray2) { return ((((ComponentPRvolcor) compArray).getc()) + (((ComponentPRvolcor) compArray2).getc())) * 0.5; @@ -86,7 +82,6 @@ public double getcijTT(ComponentPRvolcor compi, ComponentPRvolcor compj) { return 0; } - // @Override public double calcCi(int compNumb, PhaseInterface phase, double temperature, double pressure, int numbcomp) { @@ -102,7 +97,6 @@ public double calcCi(int compNumb, PhaseInterface phase, double temperature, dou return Ci; } - public double calcCij(int compNumb, int compNumbj, PhaseInterface phase, double temperature, double pressure, int numbcomp) { double cij = 0.0; @@ -113,8 +107,6 @@ public double calcCij(int compNumb, int compNumbj, PhaseInterface phase, double - ((ComponentPRvolcor) compArray[compNumbj]).getCi()) / phase.getNumberOfMolesInPhase(); } - - public double calcCiT(int compNumb, PhaseInterface phase, double temperature, double pressure, int numbcomp) { double CiT = 0.0; @@ -129,8 +121,6 @@ public double calcCiT(int compNumb, PhaseInterface phase, double temperature, do return CiT; } - - public double calcCT(PhaseInterface phase, double temperature, double pressure, int numbcomp) { return 0.0; } @@ -152,8 +142,6 @@ public double calcC(PhaseInterface phase, double temperature, double pressure, return C; } - - private double loc_C() { return calcC(this, temperature, pressure, numberOfComponents) ; } @@ -166,8 +154,6 @@ public double getC() { return loc_C(); } - - @Override public double gV() { return (getb() - getc()) @@ -228,8 +214,6 @@ public double fVVV() { // val2 * val2)); } - - // derivative of small g with regards to b // problem with the loc_b in gb(),gc()-->it says that it is not visible and I think this is // because loc_B is marked as private @@ -317,7 +301,6 @@ public double gCC() { return -1.0 / (val * val); } - // Below are the partial derivatives of F with regards to model parameters @Override @@ -383,7 +366,6 @@ public double dFdTdT() { + FCC() * getCT() * getCT() + FC() * getCTT() + 2 * FCD() * getCT() * getAT(); } - @Override public PhasePrEosvolcor clone() { PhasePrEosvolcor clonedPhase = null; diff --git a/src/main/java/neqsim/thermo/system/SystemInterface.java b/src/main/java/neqsim/thermo/system/SystemInterface.java index 866f701dba..bfa0c7fc1d 100644 --- a/src/main/java/neqsim/thermo/system/SystemInterface.java +++ b/src/main/java/neqsim/thermo/system/SystemInterface.java @@ -25,6 +25,16 @@ public interface SystemInterface extends Cloneable, java.io.Serializable { */ public void saveFluid(int id); + /** + *

+ * saveFluid. + *

+ * + * @param id a int + * @param text a {@link java.lang.String} object + */ + public void saveFluid(int id, String text); + /** *

* getComponentNameTag. @@ -101,7 +111,6 @@ public default void addComponents(String[] names) { } } - /** * Add named components to a System with a number of moles. If component already exists, the moles * will be added to the component. @@ -127,6 +136,15 @@ public default String[][] calcResultTable() { return createTable(""); } + /** + *

+ * getKinematicViscosity. + *

+ * + * @return a double + */ + public double getKinematicViscosity(); + /** * method to return kinematic viscosity in a specified unit. * @@ -144,14 +162,6 @@ public default String[][] calcResultTable() { */ public int getNumberOfComponents(); - /** - * method to get molar mass of a fluid phase. - * - * @param unit Supported units are kg/mol, gr/mol - * @return molar mass in specified unit - */ - public double getMolarMass(String unit); - /** * This method is used to set the total molar composition of a plus fluid. The total flow rate * will be kept constant. The input mole fractions will be normalized. @@ -161,16 +171,6 @@ public default String[][] calcResultTable() { */ public void setMolarCompositionPlus(double[] molefractions); - /** - *

- * saveFluid. - *

- * - * @param id a int - * @param text a {@link java.lang.String} object - */ - public void saveFluid(int id, String text); - /** * This method is used to set the total molar composition of a characterized fluid. The total flow * rate will be kept constant. The input mole fractions will be normalized. @@ -181,15 +181,6 @@ public default String[][] calcResultTable() { */ public void setMolarCompositionOfPlusFluid(double[] molefractions); - /** - * method to get the Joule Thomson Coefficient of a system. Based on a phase mole fraction basis - * average. - * - * @param unit Supported units are K/bar, C/bar - * @return Joule Thomson coefficient in specified unit - */ - public double getJouleThomsonCoefficient(String unit); - /** * method to return exergy in a specified unit. * @@ -215,6 +206,15 @@ public default String[][] calcResultTable() { */ public double getJouleThomsonCoefficient(); + /** + * method to get the Joule Thomson Coefficient of a system. Based on a phase mole fraction basis + * average. + * + * @param unit Supported units are K/bar, C/bar + * @return Joule Thomson coefficient in specified unit + */ + public double getJouleThomsonCoefficient(String unit); + /** * method to return mass of fluid. * @@ -258,6 +258,18 @@ public default String[][] calcResultTable() { */ public void removePhaseKeepTotalComposition(int specPhase); + /** + * Init physical properties for all phases and interfaces. + */ + public void initPhysicalProperties(); + + /** + * Calculates physical properties of type propertyName. + * + * @param propertyName a {@link java.lang.String} object + */ + public void initPhysicalProperties(String propertyName); + /** * Calculates thermodynamic and physical properties of a fluid using initThermoProperties() and * initPhysicalProperties(). @@ -277,6 +289,25 @@ public static SystemInterface addFluids(SystemInterface addFluid1, SystemInterfa return newFluid; } + /** + * method to return interfacial tension between two phases. + * + * @param phase1 phase type of phase1 as string (valid phases are gas, oil, aqueous) + * @param phase2 phase type of phase2 as string (valid phases are gas, oil, aqueous) + * @return interfacial tension with unit N/m. If one or both phases does not exist - the method + * will return NaN + */ + public double getInterfacialTension(String phase1, String phase2); + + /** + * method to return interfacial tension between two phases. + * + * @param phase1 phase number of phase1 + * @param phase2 phase number of phase2 + * @return interfacial tension with unit N/m + */ + public double getInterfacialTension(int phase1, int phase2); + /** *

* getInterfacialTension. @@ -289,13 +320,6 @@ public static SystemInterface addFluids(SystemInterface addFluid1, SystemInterfa */ public double getInterfacialTension(int phase1, int phase2, String unit); - /** - * Calculates physical properties of type propertyName. - * - * @param propertyName a {@link java.lang.String} object - */ - public void initPhysicalProperties(String propertyName); - /** * method to return heat capacity ratio calculated as Cp/(Cp-R). * @@ -312,6 +336,13 @@ public default double getGamma2() { */ public double getGamma(); + /** + * method to return fluid volume. + * + * @return volume in unit m3*1e5 + */ + public double getVolume(); + /** * method to return fluid volume. * @@ -329,6 +360,13 @@ public default double getGamma2() { */ public double getFlowRate(String flowunit); + /** + * method to set the pressure of a fluid (same pressure for all phases). + * + * @param pres pressure in unit bara (absolute pressure in bar) + */ + public void setPressure(double pres); + /** * method to set the pressure of a fluid (same pressure for all phases). * @@ -337,6 +375,25 @@ public default double getGamma2() { */ public void setPressure(double newPressure, String unit); + /** + *

+ * method to set the temperature of a fluid (same temperature for all phases). + *

+ * + * @param temp a double + */ + public void setTemperature(double temp); + + /** + *

+ * setTemperature. + *

+ * + * @param newTemperature a double + * @param phaseNumber a int + */ + public void setTemperature(double newTemperature, int phaseNumber); + /** * method to set the temperature of a fluid (same temperature for all phases). * @@ -371,12 +428,11 @@ public default double getGamma2() { public double getHeatOfVaporization(); /** - * method to return total enthalpy in a specified unit. + * method to return internal energy (U) in unit J. * - * @param unit Supported units are 'J', 'J/mol', 'J/kg' and 'kJ/kg' - * @return enthalpy in specified unit + * @return internal energy in unit Joule (J) */ - public double getEnthalpy(String unit); + public double getInternalEnergy(); /** * method to return internal energy (U) in a specified unit. @@ -481,6 +537,36 @@ public default void removeMoles() { */ public void resetPhysicalProperties(); + /** + *

+ * phaseToSystem. + *

+ * + * @param phaseNumber a int + * @return a {@link neqsim.thermo.system.SystemInterface} object + */ + public SystemInterface phaseToSystem(int phaseNumber); + + /** + *

+ * phaseToSystem. + *

+ * + * @param newPhase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a {@link neqsim.thermo.system.SystemInterface} object + */ + public SystemInterface phaseToSystem(PhaseInterface newPhase); + + /** + *

+ * phaseToSystem. + *

+ * + * @param phaseName a {@link java.lang.String} object + * @return a {@link neqsim.thermo.system.SystemInterface} object + */ + public SystemInterface phaseToSystem(String phaseName); + /** *

* phaseToSystem. @@ -520,16 +606,6 @@ public default void removeMoles() { */ public neqsim.thermo.characterization.WaxCharacterise getWaxCharacterisation(); - /** - *

- * phaseToSystem. - *

- * - * @param phaseName a {@link java.lang.String} object - * @return a {@link neqsim.thermo.system.SystemInterface} object - */ - public SystemInterface phaseToSystem(String phaseName); - /** * method to get the total molar flow rate of individual components in a fluid. * @@ -537,7 +613,6 @@ public default void removeMoles() { */ public double[] getMolarRate(); - /** * Returns true if phase exists and is not null. * @@ -546,6 +621,13 @@ public default void removeMoles() { */ public boolean IsPhase(int i); + /** + * Get phase number i from SystemInterface object. + * + * @param i a int + * @return a {@link neqsim.thermo.phase.PhaseInterface} object + */ + public PhaseInterface getPhase(int i); /** *

@@ -720,15 +802,6 @@ public default void removeMoles() { */ public String[] getCompIDs(); - /** - *

- * isImplementedCompositionDeriativesofFugacity. - *

- * - * @param isImpl a boolean - */ - public void isImplementedCompositionDeriativesofFugacity(boolean isImpl); - /** *

* saveObject. @@ -1071,6 +1144,15 @@ public void addPlusFraction(String componentName, double numberOfMoles, double m */ public void addComponent(int index, double moles, int phaseNumber); + /** + *

+ * getBeta. + *

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

* getBeta. @@ -1119,6 +1201,26 @@ public void addPlusFraction(String componentName, double numberOfMoles, double m */ public void setMixingRule(String typename, String GEmodel); + /** + * method to set mixing rule used for the fluid. + * + * @param type The type of mixing rule to be used for the fluid. 1 - classic mixing rule with all + * kij set to zero 2 -classic mixing rule with kij from NeqSim database 3- classic mixing + * rule with temperature dependent kij 4- Huron Vidal mixing rule with parameters from + * NeqSim database 7 -classic mixing rule with kij of CPA from NeqSim Database 9 + * -classicmixing rule with temperature dependent kij of CPA from NeqSim database + * 10-classic mixing rule with temperature and composition dependent kij of CPA from NeqSim + * database + */ + public void setMixingRule(int type); + + /** + * method to set the mixing rule for the fluid. + * + * @param typename a {@link java.lang.String} object + */ + public void setMixingRule(String typename); + /** *

* normalizeBeta. @@ -1150,27 +1252,27 @@ public void addPlusFraction(String componentName, double numberOfMoles, double m * checkStability. *

* - * @param val a boolean + * @return a boolean */ - public void checkStability(boolean val); + public boolean checkStability(); /** *

- * hasPlusFraction. + * checkStability. *

* - * @return a boolean + * @param val a boolean */ - public boolean hasPlusFraction(); + public void checkStability(boolean val); /** *

- * checkStability. + * hasPlusFraction. *

* * @return a boolean */ - public boolean checkStability(); + public boolean hasPlusFraction(); /** *

@@ -1233,13 +1335,6 @@ public void addPlusFraction(String componentName, double numberOfMoles, double m */ public void useVolumeCorrection(boolean volcor); - /** - * method to set the mixing rule for the fluid. - * - * @param typename a {@link java.lang.String} object - */ - public void setMixingRule(String typename); - /** *

* Getter for property numericDerivatives. @@ -1327,6 +1422,15 @@ public void addPlusFraction(String componentName, double numberOfMoles, double m */ public void setSolidPhaseCheck(boolean test); + /** + *

+ * setSolidPhaseCheck. + *

+ * + * @param solidComponent a {@link java.lang.String} object + */ + public void setSolidPhaseCheck(String solidComponent); + /** *

* doSolidPhaseCheck. @@ -1387,7 +1491,6 @@ public default void init() { */ public void init(int number, int phase); - /** * Calculates thermodynamic properties of a fluid using the init(2) method. */ @@ -1409,22 +1512,22 @@ public default void initThermoProperties() { /** *

- * addFluid. + * display. *

* - * @param addSystem a {@link neqsim.thermo.system.SystemInterface} object - * @return SystemInterface + * @param name a {@link java.lang.String} object */ - public SystemInterface addFluid(SystemInterface addSystem); + public void display(String name); /** *

- * display. + * addFluid. *

* - * @param name a {@link java.lang.String} object + * @param addSystem a {@link neqsim.thermo.system.SystemInterface} object + * @return SystemInterface */ - public void display(String name); + public SystemInterface addFluid(SystemInterface addSystem); /** *

@@ -1501,14 +1604,6 @@ public double calcBeta() */ public void calc_x_y(); - /** - * Get phase number i from SystemInterface object. - * - * @param i a int - * @return a {@link neqsim.thermo.phase.PhaseInterface} object - */ - public PhaseInterface getPhase(int i); - /** *

* reset_x_y. @@ -1516,15 +1611,6 @@ public double calcBeta() */ public void reset_x_y(); - /** - *

- * isChemicalSystem. - *

- * - * @param temp a boolean - */ - public void isChemicalSystem(boolean temp); - /** * Add phase to SystemInterface object. */ @@ -1544,63 +1630,47 @@ public double calcBeta() * setBeta. *

* - * @param phase a int * @param b a double */ - public void setBeta(int phase, double b); + public void setBeta(double b); /** *

- * removePhase. + * setBeta. *

* - * @param specPhase a int + * @param phase a int + * @param b a double */ - public void removePhase(int specPhase); + public void setBeta(int phase, double b); /** *

- * phaseToSystem. + * removePhase. *

* - * @param newPhase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a {@link neqsim.thermo.system.SystemInterface} object + * @param specPhase a int */ - public SystemInterface phaseToSystem(PhaseInterface newPhase); + public void removePhase(int specPhase); + + // public void setPressure(double newPressure, int phaseNumber); /** - *

- * method to set the temperature of a fluid (same temperature for all phases). - *

+ * method to return pressure. * - * @param temp a double + * @return pressure in unit bara */ - public void setTemperature(double temp); + public double getPressure(); /** *

- * setTemperature. + * method to return pressure of phase. *

* - * @param newTemperature a double * @param phaseNumber a int + * @return a double */ - public void setTemperature(double newTemperature, int phaseNumber); - // public void setPressure(double newPressure, int phaseNumber); - - /** - * method to set the pressure of a fluid (same pressure for all phases). - * - * @param pres pressure in unit bara (absolute pressure in bar) - */ - public void setPressure(double pres); - - /** - * method to return pressure. - * - * @return pressure in unit bara - */ - public double getPressure(); + public double getPressure(int phaseNumber); /** * method to return pressure in a specified unit. @@ -1632,16 +1702,6 @@ public double calcBeta() */ public void clearAll(); - /** - *

- * method to return pressure of phase. - *

- * - * @param phaseNumber a int - * @return a double - */ - public double getPressure(int phaseNumber); - /** * method to get density of a fluid note: without Peneloux volume correction. * @@ -1657,13 +1717,6 @@ public double calcBeta() */ public double getDensity(String unit); - /** - * method to return fluid volume. - * - * @return volume in unit m3*1e5 - */ - public double getVolume(); - /** *

* getChemicalReactionOperations. @@ -1682,6 +1735,15 @@ public double calcBeta() */ public boolean isChemicalSystem(); + /** + *

+ * isChemicalSystem. + *

+ * + * @param temp a boolean + */ + public void isChemicalSystem(boolean temp); + /** * method to return molar volume of the fluid note: without Peneloux volume correction. * @@ -1696,6 +1758,14 @@ public double calcBeta() */ public double getMolarMass(); + /** + * method to get molar mass of a fluid phase. + * + * @param unit Supported units are kg/mol, gr/mol + * @return molar mass in specified unit + */ + public double getMolarMass(String unit); + /** * method to get the total enthalpy of a fluid. * @@ -1703,6 +1773,14 @@ public double calcBeta() */ public double getEnthalpy(); + /** + * method to return total enthalpy in a specified unit. + * + * @param unit Supported units are 'J', 'J/mol', 'J/kg' and 'kJ/kg' + * @return enthalpy in specified unit + */ + public double getEnthalpy(String unit); + /** *

* calcInterfaceProperties. @@ -1776,15 +1854,6 @@ public double calcBeta() */ public double getTemperature(int phaseNumber); - /** - *

- * getBeta. - *

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

* chemicalReactionInit. @@ -1792,30 +1861,35 @@ public double calcBeta() */ public void chemicalReactionInit(); - /** - * Init physical properties for all phases and interfaces. - */ - public void initPhysicalProperties(); + // public double getdfugdt(int i, int j); /** *

- * setBeta. + * method to set the phase type of a given phase. *

* - * @param b a double + * @param phaseToChange a int + * @param newPhaseType a int */ - public void setBeta(double b); - // public double getdfugdt(int i, int j); + public void setPhaseType(int phaseToChange, int newPhaseType); /** *

- * method to set the phase type of a given phase. + * setPhaseType. *

* - * @param phaseToChange a int + * @param phases a {@link java.lang.String} object * @param newPhaseType a int */ - public void setPhaseType(int phaseToChange, int newPhaseType); + public void setPhaseType(String phases, int newPhaseType); + + /** + * method to set the phase type of a given phase. + * + * @param phaseToChange the phase number of the phase to set phase type + * @param phaseTypeName the phase type name (valid names are gas or liquid) + */ + public void setPhaseType(int phaseToChange, String phaseTypeName); /** *

@@ -1889,13 +1963,6 @@ public double calcBeta() */ public double getGibbsEnergy(); - /** - * method to return internal energy (U) in unit J. - * - * @return internal energy in unit Joule (J) - */ - public double getInternalEnergy(); - /** *

* getHelmholtzEnergy. @@ -1943,19 +2010,6 @@ public double calcBeta() */ public SystemInterface clone(); - /** - * method to set mixing rule used for the fluid. - * - * @param type The type of mixing rule to be used for the fluid. 1 - classic mixing rule with all - * kij set to zero 2 -classic mixing rule with kij from NeqSim database 3- classic mixing - * rule with temperature dependent kij 4- Huron Vidal mixing rule with parameters from - * NeqSim database 7 -classic mixing rule with kij of CPA from NeqSim Database 9 - * -classicmixing rule with temperature dependent kij of CPA from NeqSim database - * 10-classic mixing rule with temperature and composition dependent kij of CPA from NeqSim - * database - */ - public void setMixingRule(int type); - /** *

* getComponentNames. @@ -2001,8 +2055,9 @@ public double calcBeta() /** * method to return heat capacity ratio/adiabatic index/Poisson constant. * - * @return kappa */ - + * @return kappa + */ + public double getKappa(); /** @@ -2090,34 +2145,6 @@ public double calcBeta() */ public double getThermalConductivity(String unit); - /** - * method to return interfacial tension between two phases. - * - * @param phase1 phase type of phase1 as string (valid phases are gas, oil, aqueous) - * @param phase2 phase type of phase2 as string (valid phases are gas, oil, aqueous) - * @return interfacial tension with unit N/m. If one or both phases does not exist - the method - * will return NaN - */ - public double getInterfacialTension(String phase1, String phase2); - - /** - * method to return interfacial tension between two phases. - * - * @param phase1 phase number of phase1 - * @param phase2 phase number of phase2 - * @return interfacial tension with unit N/m - */ - public double getInterfacialTension(int phase1, int phase2); - - /** - *

- * getKinematicViscosity. - *

- * - * @return a double - */ - public double getKinematicViscosity(); - /** *

* initRefPhases. @@ -2143,15 +2170,6 @@ public double calcBeta() */ public void setFluidName(java.lang.String fluidName); - /** - *

- * setSolidPhaseCheck. - *

- * - * @param solidComponent a {@link java.lang.String} object - */ - public void setSolidPhaseCheck(String solidComponent); - /** *

* Getter for property allowPhaseShift. @@ -2179,25 +2197,6 @@ public double calcBeta() */ public double getPhaseFraction(String phaseTypeName, String unit); - /** - *

- * setPhaseType. - *

- * - * @param phases a {@link java.lang.String} object - * @param newPhaseType a int - */ - public void setPhaseType(String phases, int newPhaseType); - - /** - * method to set the phase type of a given phase. - * - * @param phaseToChange the phase number of the phase to set phase type - * @param phaseTypeName the phase type name (valid names are gas or liquid) - */ - public void setPhaseType(int phaseToChange, String phaseTypeName); - - /** *

* getProperty. @@ -2339,16 +2338,6 @@ public double calcBeta() */ public void setTotalNumberOfMoles(double totalNumberOfMoles); - /** - *

- * phaseToSystem. - *

- * - * @param phaseNumber a int - * @return a {@link neqsim.thermo.system.SystemInterface} object - */ - public SystemInterface phaseToSystem(int phaseNumber); - /** *

* hasPhaseType. @@ -2435,6 +2424,15 @@ public void setImplementedPressureDeriativesofFugacity( */ public boolean isImplementedCompositionDeriativesofFugacity(); + /** + *

+ * isImplementedCompositionDeriativesofFugacity. + *

+ * + * @param isImpl a boolean + */ + public void isImplementedCompositionDeriativesofFugacity(boolean isImpl); + /** *

* setImplementedCompositionDeriativesofFugacity. diff --git a/src/main/java/neqsim/thermo/system/SystemThermo.java b/src/main/java/neqsim/thermo/system/SystemThermo.java index e83c22c909..511cad5d22 100644 --- a/src/main/java/neqsim/thermo/system/SystemThermo.java +++ b/src/main/java/neqsim/thermo/system/SystemThermo.java @@ -14,14 +14,11 @@ import java.sql.ResultSet; import java.text.FieldPosition; import java.util.ArrayList; - import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import neqsim.chemicalReactions.ChemicalReactionOperations; import neqsim.physicalProperties.interfaceProperties.InterfaceProperties; import neqsim.physicalProperties.interfaceProperties.InterphasePropertiesInterface; @@ -549,28 +546,6 @@ public void replacePhase(int repPhase, PhaseInterface newPhase) { setTotalNumberOfMoles(newPhase.getNumberOfMolesInPhase()); } - /** {@inheritDoc} */ - @Override - public SystemInterface phaseToSystem(PhaseInterface newPhase) { - for (int i = 0; i < newPhase.getNumberOfComponents(); i++) { - newPhase.getComponents()[i] - .setNumberOfmoles(newPhase.getComponents()[i].getNumberOfMolesInPhase()); - } - - for (int i = 0; i < getMaxNumberOfPhases(); i++) { - phaseArray[i] = newPhase.clone(); - } - - setTotalNumberOfMoles(newPhase.getNumberOfMolesInPhase()); - this.init(0); - setNumberOfPhases(1); - setPhaseType(0, newPhase.getPhaseType()); - initBeta(); - init_x_y(); - this.init(1); - return this; - } - /** {@inheritDoc} */ @Override public SystemInterface getEmptySystemClone() { @@ -595,6 +570,28 @@ public SystemInterface getEmptySystemClone() { return newSystem; } + /** {@inheritDoc} */ + @Override + public SystemInterface phaseToSystem(PhaseInterface newPhase) { + for (int i = 0; i < newPhase.getNumberOfComponents(); i++) { + newPhase.getComponents()[i] + .setNumberOfmoles(newPhase.getComponents()[i].getNumberOfMolesInPhase()); + } + + for (int i = 0; i < getMaxNumberOfPhases(); i++) { + phaseArray[i] = newPhase.clone(); + } + + setTotalNumberOfMoles(newPhase.getNumberOfMolesInPhase()); + this.init(0); + setNumberOfPhases(1); + setPhaseType(0, newPhase.getPhaseType()); + initBeta(); + init_x_y(); + this.init(1); + return this; + } + /** {@inheritDoc} */ @Override public SystemInterface phaseToSystem(String phaseName) { @@ -1738,17 +1735,6 @@ public void init(int type) { } } - /** {@inheritDoc} */ - @Override - public void initProperties() { - if (!isInitialized) { - init(0); - setNumberOfPhases(1); - } - initThermoProperties(); - initPhysicalProperties(); - } - /** {@inheritDoc} */ @Override public void init(int type, int phase) { @@ -2148,6 +2134,17 @@ public void initNumeric() { } } + /** {@inheritDoc} */ + @Override + public void initProperties() { + if (!isInitialized) { + init(0); + setNumberOfPhases(1); + } + initThermoProperties(); + initPhysicalProperties(); + } + /** {@inheritDoc} */ @Override public void initPhysicalProperties() { @@ -2229,9 +2226,6 @@ public final PhaseInterface getLiquidPhase() { } /** @{inheritdoc} */ - /** - * @return IsPhase true or false - */ @Override public boolean IsPhase(int i) { if (i > phaseArray.length) { @@ -2252,6 +2246,50 @@ public final PhaseInterface getPhase(int i) { return phaseArray[phaseIndex[i]]; } + /** {@inheritDoc} */ + @Override + public PhaseInterface getPhase(String phaseTypeName) { + for (int i = 0; i < numberOfPhases; i++) { + if (getPhase(i).getPhaseTypeName().equals(phaseTypeName)) { + return getPhase(i); + } + } + throw new RuntimeException(); + } + + /** {@inheritDoc} */ + @Override + public int getPhaseNumberOfPhase(String phaseTypeName) { + for (int i = 0; i < numberOfPhases; i++) { + if (getPhase(i).getPhaseTypeName().equals(phaseTypeName)) { + return i; + } + } + return 0; + } + + /** {@inheritDoc} */ + @Override + public int getPhaseIndexOfPhase(String phaseTypeName) { + for (int i = 0; i < numberOfPhases; i++) { + if (getPhase(i).getPhaseTypeName().equals(phaseTypeName)) { + return phaseIndex[i]; + } + } + return phaseIndex[0]; + } + + /** {@inheritDoc} */ + @Override + public PhaseInterface getPhaseOfType(String phaseName) { + for (int i = 0; i < numberOfPhases; i++) { + if (getPhase(i).getPhaseTypeName().equals(phaseName)) { + return getPhase(i); + } + } + return null; + } + /** {@inheritDoc} */ @Override public final boolean isChemicalSystem() { @@ -2300,6 +2338,21 @@ public final void setPC(double PC) { criticalPressure = PC; } + /** + *

+ * setMixingRuleGEmodel. + *

+ * + * @param name a {@link java.lang.String} object + */ + public void setMixingRuleGEmodel(String name) { + for (PhaseInterface tmpPhase : phaseArray) { + if (tmpPhase != null) { + tmpPhase.setMixingRuleGEModel(name); + } + } + } + /** {@inheritDoc} */ @Override public final void setMixingRule(int type) { @@ -2316,21 +2369,6 @@ public final void setMixingRule(int type) { } } - /** - *

- * setMixingRuleGEmodel. - *

- * - * @param name a {@link java.lang.String} object - */ - public void setMixingRuleGEmodel(String name) { - for (PhaseInterface tmpPhase : phaseArray) { - if (tmpPhase != null) { - tmpPhase.setMixingRuleGEModel(name); - } - } - } - /** {@inheritDoc} */ @Override public void setMixingRule(String typename, String GEmodel) { @@ -2765,6 +2803,12 @@ public void setTemperature(double newTemperature) { } } + /** {@inheritDoc} */ + @Override + public final void setTemperature(double newTemperature, int phase) { + getPhase(phaseIndex[phase]).setTemperature(newTemperature); + } + /** {@inheritDoc} */ @Override public void setTemperature(double newTemperature, String unit) { @@ -2887,12 +2931,6 @@ public final void setPressure(double newPressure, String unit) { } } - /** {@inheritDoc} */ - @Override - public final void setTemperature(double newPressure, int phase) { - getPhase(phaseIndex[phase]).setTemperature(newPressure); - } - /** {@inheritDoc} */ @Override public final double getTemperature() { @@ -2902,7 +2940,8 @@ public final double getTemperature() { /** {@inheritDoc} */ @Override public final double getTemperature(String unit) { - neqsim.util.unit.TemperatureUnit tempConversion = new neqsim.util.unit.TemperatureUnit(getTemperature(), "K"); + neqsim.util.unit.TemperatureUnit tempConversion = + new neqsim.util.unit.TemperatureUnit(getTemperature(), "K"); return tempConversion.getValue(unit); } @@ -2921,7 +2960,8 @@ public final double getPressure() { /** {@inheritDoc} */ @Override public final double getPressure(String unit) { - neqsim.util.unit.PressureUnit presConversion = new neqsim.util.unit.PressureUnit(getPressure(), "bara"); + neqsim.util.unit.PressureUnit presConversion = + new neqsim.util.unit.PressureUnit(getPressure(), "bara"); return presConversion.getValue(unit); } @@ -3207,18 +3247,6 @@ public double getInterfacialTension(String phase1, String phase2) { } } - /** - *

- * write. - *

- * - * @return a {@link java.lang.String} object - */ - public String write() { - // create a String description of the system - return ""; - } - /** {@inheritDoc} */ @Override public void normalizeBeta() { @@ -3231,12 +3259,6 @@ public void normalizeBeta() { } } - /** {@inheritDoc} */ - @Override - public void display() { - display(this.getFluidName()); - } - /** {@inheritDoc} */ @Override public String[][] createTable(String name) { @@ -3451,6 +3473,12 @@ public String[][] createTable(String name) { return table; } + /** {@inheritDoc} */ + @Override + public void display() { + display(this.getFluidName()); + } + /** {@inheritDoc} */ @Override public void display(String name) { @@ -3475,6 +3503,18 @@ public void display(String name) { dialog.setVisible(true); } + /** + *

+ * write. + *

+ * + * @return a {@link java.lang.String} object + */ + public String write() { + // create a String description of the system + return ""; + } + /** {@inheritDoc} */ @Override public void write(String name, String filename, boolean newfile) { @@ -4569,50 +4609,6 @@ public boolean hasPhaseType(String phaseTypeName) { return false; } - /** {@inheritDoc} */ - @Override - public PhaseInterface getPhase(String phaseTypeName) { - for (int i = 0; i < numberOfPhases; i++) { - if (getPhase(i).getPhaseTypeName().equals(phaseTypeName)) { - return getPhase(i); - } - } - throw new RuntimeException(); - } - - /** {@inheritDoc} */ - @Override - public int getPhaseNumberOfPhase(String phaseTypeName) { - for (int i = 0; i < numberOfPhases; i++) { - if (getPhase(i).getPhaseTypeName().equals(phaseTypeName)) { - return i; - } - } - return 0; - } - - /** {@inheritDoc} */ - @Override - public int getPhaseIndexOfPhase(String phaseTypeName) { - for (int i = 0; i < numberOfPhases; i++) { - if (getPhase(i).getPhaseTypeName().equals(phaseTypeName)) { - return phaseIndex[i]; - } - } - return phaseIndex[0]; - } - - /** {@inheritDoc} */ - @Override - public PhaseInterface getPhaseOfType(String phaseName) { - for (int i = 0; i < numberOfPhases; i++) { - if (getPhase(i).getPhaseTypeName().equals(phaseName)) { - return getPhase(i); - } - } - return null; - } - /** {@inheritDoc} */ @Override public double calcHenrysConstant(String component) { @@ -4659,21 +4655,21 @@ public void setBmixType(int bmixType) { /** {@inheritDoc} */ @Override - public boolean isImplementedTemperatureDeriativesofFugacity() { - return implementedTemperatureDeriativesofFugacity; + public boolean isImplementedCompositionDeriativesofFugacity() { + return implementedCompositionDeriativesofFugacity; } /** {@inheritDoc} */ @Override - public void setImplementedTemperatureDeriativesofFugacity( - boolean implementedTemperatureDeriativesofFugacity) { - this.implementedTemperatureDeriativesofFugacity = implementedTemperatureDeriativesofFugacity; + public void isImplementedCompositionDeriativesofFugacity(boolean isImpl) { + this.implementedCompositionDeriativesofFugacity = isImpl; } /** {@inheritDoc} */ @Override - public boolean isImplementedPressureDeriativesofFugacity() { - return implementedPressureDeriativesofFugacity; + public void setImplementedCompositionDeriativesofFugacity( + boolean implementedCompositionDeriativesofFugacity) { + this.implementedCompositionDeriativesofFugacity = implementedCompositionDeriativesofFugacity; } /** {@inheritDoc} */ @@ -4685,15 +4681,21 @@ public void setImplementedPressureDeriativesofFugacity( /** {@inheritDoc} */ @Override - public boolean isImplementedCompositionDeriativesofFugacity() { - return implementedCompositionDeriativesofFugacity; + public boolean isImplementedPressureDeriativesofFugacity() { + return implementedPressureDeriativesofFugacity; } /** {@inheritDoc} */ @Override - public void setImplementedCompositionDeriativesofFugacity( - boolean implementedCompositionDeriativesofFugacity) { - this.implementedCompositionDeriativesofFugacity = implementedCompositionDeriativesofFugacity; + public boolean isImplementedTemperatureDeriativesofFugacity() { + return implementedTemperatureDeriativesofFugacity; + } + + /** {@inheritDoc} */ + @Override + public void setImplementedTemperatureDeriativesofFugacity( + boolean implementedTemperatureDeriativesofFugacity) { + this.implementedTemperatureDeriativesofFugacity = implementedTemperatureDeriativesofFugacity; } /** {@inheritDoc} */ @@ -4720,19 +4722,19 @@ public void setMaxNumberOfPhases(int maxNumberOfPhases) { /** {@inheritDoc} */ @Override public void setMolarComposition(double[] molefractions) { - setMolarComposition(molefractions, ""); + setMolarFractions(molefractions, ""); } /** {@inheritDoc} */ @Override public void setMolarCompositionPlus(double[] molefractions) { - setMolarComposition(molefractions, "Plus"); + setMolarFractions(molefractions, "Plus"); } /** {@inheritDoc} */ @Override public void setMolarCompositionOfPlusFluid(double[] molefractions) { - setMolarComposition(molefractions, "PlusFluid"); + setMolarFractions(molefractions, "PlusFluid"); } /** {@inheritDoc} */ @@ -5001,12 +5003,6 @@ public double getMoleFraction(int phaseNumber) { return getPhase(phaseNumber).getBeta(); } - /** {@inheritDoc} */ - @Override - public void isImplementedCompositionDeriativesofFugacity(boolean isImpl) { - implementedCompositionDeriativesofFugacity = isImpl; - } - /** {@inheritDoc} */ @Override public void addCapeOpenProperty(String propertyName) { @@ -5074,7 +5070,7 @@ public SystemProperties getProperties() { return new SystemProperties(this); } - private void setMolarComposition(double[] molefractions, String type) { + private void setMolarFractions(double[] molefractions, String type) { double totalFlow = getTotalNumberOfMoles(); if (totalFlow < 1e-100) { String msg = "must be larger than 0 (1e-100) when setting molar composition"; diff --git a/src/main/java/neqsim/thermo/system/SystemUMRCPAEoS.java b/src/main/java/neqsim/thermo/system/SystemUMRCPAEoS.java index 6698fdf7da..f61f10ab41 100644 --- a/src/main/java/neqsim/thermo/system/SystemUMRCPAEoS.java +++ b/src/main/java/neqsim/thermo/system/SystemUMRCPAEoS.java @@ -19,7 +19,6 @@ */ public class SystemUMRCPAEoS extends SystemPrEos { - public SystemUMRCPAEoS() { super(); modelName = "UMR-CPA"; diff --git a/src/main/java/neqsim/thermo/system/SystemUMRPRUMCEosNew.java b/src/main/java/neqsim/thermo/system/SystemUMRPRUMCEosNew.java index 837bd691ee..698c9276d7 100644 --- a/src/main/java/neqsim/thermo/system/SystemUMRPRUMCEosNew.java +++ b/src/main/java/neqsim/thermo/system/SystemUMRPRUMCEosNew.java @@ -19,7 +19,6 @@ */ public class SystemUMRPRUMCEosNew extends SystemUMRPRUMCEos { - public SystemUMRPRUMCEosNew() { super(); modelName = "UMR-PRU-MC-EoS-New"; diff --git a/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java b/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java index 1e734d6db5..0b4c4aaeb6 100644 --- a/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java +++ b/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java @@ -164,16 +164,6 @@ public void TPflash() { } } - /** - *

- * saturateWithWater. - *

- */ - public void saturateWithWater() { - operation = new SaturateWithWater(system); - getOperation().run(); - } - /** *

* TPflash. @@ -213,6 +203,16 @@ public void dTPflash(String[] comps) { getOperation().run(); } + /** + *

+ * saturateWithWater. + *

+ */ + public void saturateWithWater() { + operation = new SaturateWithWater(system); + getOperation().run(); + } + /** *

* chemicalEquilibrium. @@ -264,6 +264,8 @@ public void PHflash(double Hspec, String enthalpyUnit) { case "kJ/kg": conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; break; + default: + break; } PHflash(Hspec / conversionFactor); } @@ -338,6 +340,8 @@ public void PUflash(double Uspec, String unitEnergy) { conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; break; + default: + break; } PUflash(Uspec / conversionFactorEntr); } @@ -377,6 +381,22 @@ public void PHsolidFlash(double Hspec) { getOperation().run(); } + /** + *

+ * PSflash. + *

+ * + * @param Sspec a double + */ + public void PSflash(double Sspec) { + if (system.getPhase(0).getNumberOfComponents() == 1) { + operation = new PSflashSingleComp(system, Sspec, 0); + } else { + operation = new PSFlash(system, Sspec, 0); + } + getOperation().run(); + } + /** * Method to perform a PS flash calculation for a specified entropy and pressure * @@ -387,7 +407,6 @@ public void PSflash(double Sspec, String unit) { double conversionFactor = 1.0; switch (unit) { case "J/K": - conversionFactor = 1.0; break; case "J/molK": conversionFactor = 1.0 / system.getTotalNumberOfMoles(); @@ -398,10 +417,24 @@ public void PSflash(double Sspec, String unit) { case "kJ/kgK": conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; break; + default: + break; } PSflash(Sspec / conversionFactor); } + /** + *

+ * TSflash. + *

+ * + * @param Sspec a double + */ + public void TSflash(double Sspec) { + operation = new TSFlash(system, Sspec); + getOperation().run(); + } + /** * Method to perform a TS flash calculation for a specified entropy and pressure * @@ -423,26 +456,12 @@ public void TSflash(double Sspec, String unit) { case "kJ/kgK": conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; break; + default: + break; } TSflash(Sspec / conversionFactor); } - /** - *

- * PSflash. - *

- * - * @param Sspec a double - */ - public void PSflash(double Sspec) { - if (system.getPhase(0).getNumberOfComponents() == 1) { - operation = new PSflashSingleComp(system, Sspec, 0); - } else { - operation = new PSFlash(system, Sspec, 0); - } - getOperation().run(); - } - /** *

* PSflashGERG2008. @@ -456,18 +475,6 @@ public void PSflashGERG2008(double Sspec) { getOperation().run(); } - /** - *

- * TSflash. - *

- * - * @param Sspec a double - */ - public void TSflash(double Sspec) { - operation = new TSFlash(system, Sspec); - getOperation().run(); - } - /** *

* PSflash2. @@ -498,6 +505,8 @@ public void VSflash(double volume, double entropy, String unitVol, String unitEn case "m3": conversionFactorV = 1.0e5; break; + default: + break; } switch (unitEntropy) { @@ -514,6 +523,8 @@ public void VSflash(double volume, double entropy, String unitVol, String unitEn conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; break; + default: + break; } VSflash(volume * conversionFactorV, entropy / conversionFactorEntr); } @@ -545,6 +556,8 @@ public void TVflash(double Vspec, String unit) { case "m3": conversionFactor = 1.0e5; break; + default: + break; } TVflash(Vspec * conversionFactor); } @@ -605,6 +618,8 @@ public void VHflash(double volume, double enthalpy, String unitVol, String unitE case "m3": conversionFactorV = 1.0e5; break; + default: + break; } switch (unitEnthalpy) { @@ -621,6 +636,8 @@ public void VHflash(double volume, double enthalpy, String unitVol, String unitE conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; break; + default: + break; } VHflash(volume * conversionFactorV, enthalpy / conversionFactorEntr); } @@ -643,6 +660,8 @@ public void VUflash(double volume, double energy, String unitVol, String unitEne case "m3": conversionFactorV = 1.0e5; break; + default: + break; } switch (unitEnergy) { @@ -659,6 +678,8 @@ public void VUflash(double volume, double energy, String unitVol, String unitEne conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; break; + default: + break; } VUflash(volume * conversionFactorV, energy / conversionFactorEntr); } @@ -1126,6 +1147,39 @@ public void hydrateFormationTemperature() throws Exception { // system.getPhase(4).getComponent("water")).getHydrateStructure() + 1)); } + /** + *

+ * hydrateFormationTemperature. + *

+ * + * @param structure a int + * @throws java.lang.Exception if any. + */ + public void hydrateFormationTemperature(int structure) throws Exception { + system.setTemperature(273.0 + 1.0); + if (structure == 0) { + system.setSolidPhaseCheck("water"); + system.setHydrateCheck(true); + operation = new freezingPointTemperatureFlash(system); + } else { + operation = new HydrateFormationTemperatureFlash(system); + } + + for (int i = 0; i < system.getPhase(4).getNumberOfComponents(); i++) { + ((ComponentHydrate) system.getPhases()[4].getComponent(i)).setHydrateStructure(structure - 1); + } + if (!isRunAsThread()) { + getOperation().run(); + } else { + run(); + } + + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "hydrateFormationTemperature", "Could not find solution - possible no dew point exists"); + } + } + /** *

* hydrateEquilibriumLine. @@ -1200,39 +1254,6 @@ public void waterDewPointLine(double minimumPressure, double maximumPressure) th } } - /** - *

- * hydrateFormationTemperature. - *

- * - * @param structure a int - * @throws java.lang.Exception if any. - */ - public void hydrateFormationTemperature(int structure) throws Exception { - system.setTemperature(273.0 + 1.0); - if (structure == 0) { - system.setSolidPhaseCheck("water"); - system.setHydrateCheck(true); - operation = new freezingPointTemperatureFlash(system); - } else { - operation = new HydrateFormationTemperatureFlash(system); - } - - for (int i = 0; i < system.getPhase(4).getNumberOfComponents(); i++) { - ((ComponentHydrate) system.getPhases()[4].getComponent(i)).setHydrateStructure(structure - 1); - } - if (!isRunAsThread()) { - getOperation().run(); - } else { - run(); - } - - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "hydrateFormationTemperature", "Could not find solution - possible no dew point exists"); - } - } - /** *

* calcCricondenBar. @@ -1269,6 +1290,28 @@ public void bubblePointPressureFlash() throws Exception { } } + /** + *

+ * bubblePointPressureFlash. + *

+ * + * @param derivatives a boolean + * @throws java.lang.Exception if any. + */ + public void bubblePointPressureFlash(boolean derivatives) throws Exception { + constantDutyFlashInterface operation = null; + if (derivatives == true) { + operation = new bubblePointPressureFlashDer(system); + } else { + operation = new bubblePointPressureFlash(system); + } + operation.run(); + if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "bubblePointPressureFlash", "Could not find solution - possible no dew point exists"); + } + } + /** *

* constantPhaseFractionPressureFlash. @@ -1323,28 +1366,6 @@ public void constantPhaseFractionTemperatureFlash(double fraction) throws Except } } - /** - *

- * bubblePointPressureFlash. - *

- * - * @param derivatives a boolean - * @throws java.lang.Exception if any. - */ - public void bubblePointPressureFlash(boolean derivatives) throws Exception { - constantDutyFlashInterface operation = null; - if (derivatives == true) { - operation = new bubblePointPressureFlashDer(system); - } else { - operation = new bubblePointPressureFlash(system); - } - operation.run(); - if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "bubblePointPressureFlash", "Could not find solution - possible no dew point exists"); - } - } - /** *

* dewPointMach. @@ -1368,7 +1389,8 @@ public void dewPointMach(String componentName, String specification, double spec throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), "dewPointMach", "Specified component is not present in mixture: " + componentName); } - double newTemperature = system.getTemperature(), oldTemperature = newTemperature; + double newTemperature = system.getTemperature(); + double oldTemperature = newTemperature; int iterations = 0; if (specification.equals("dewPointTemperature")) { // logger.info("new temperature " + newTemperature); @@ -1476,6 +1498,17 @@ public void dewPointPressureFlash() throws Exception { // } } + /** + *

+ * getJfreeChart. + *

+ * + * @return a {@link org.jfree.chart.JFreeChart} object + */ + public org.jfree.chart.JFreeChart getJfreeChart() { + return getOperation().getJFreeChart(""); + } + // public void dewPointPressureFlash(){ // constantDutyFlashInterface operation = new constantDutyPressureFlash(system); // operation.setBeta((1-1e-7)); @@ -1552,13 +1585,18 @@ public void calcPTphaseEnvelope(boolean bubfirst) { /** *

- * getJfreeChart. + * calcPTphaseEnvelope. *

* - * @return a {@link org.jfree.chart.JFreeChart} object + * @param lowPres a double + * @param phasefraction a double */ - public org.jfree.chart.JFreeChart getJfreeChart() { - return getOperation().getJFreeChart(""); + public void calcPTphaseEnvelope(double lowPres, double phasefraction) { + operation = new pTphaseEnvelope(system, fileName, phasefraction, lowPres, true); + + // thisThread = new Thread(operation); + // thisThread.start(); + getOperation().run(); } /** @@ -1572,22 +1610,6 @@ public void calcPTphaseEnvelopeNew() { getOperation().run(); } - /** - *

- * calcPTphaseEnvelope. - *

- * - * @param lowPres a double - * @param phasefraction a double - */ - public void calcPTphaseEnvelope(double lowPres, double phasefraction) { - operation = new pTphaseEnvelope(system, fileName, phasefraction, lowPres, true); - - // thisThread = new Thread(operation); - // thisThread.start(); - getOperation().run(); - } - /** *

* OLGApropTable. diff --git a/src/test/java/neqsim/fluidMechanics/flowSystem/onePhaseFlowSystem/pipeFlowSystem/PipeFlowSystemTest.java b/src/test/java/neqsim/fluidMechanics/flowSystem/onePhaseFlowSystem/pipeFlowSystem/PipeFlowSystemTest.java index c5750fb974..8cc0da7b39 100644 --- a/src/test/java/neqsim/fluidMechanics/flowSystem/onePhaseFlowSystem/pipeFlowSystem/PipeFlowSystemTest.java +++ b/src/test/java/neqsim/fluidMechanics/flowSystem/onePhaseFlowSystem/pipeFlowSystem/PipeFlowSystemTest.java @@ -6,7 +6,6 @@ import neqsim.fluidMechanics.flowSystem.FlowSystemInterface; import neqsim.thermo.system.SystemInterface; - public class PipeFlowSystemTest extends neqsim.NeqSimTest { FlowSystemInterface pipe; diff --git a/src/test/java/neqsim/processSimulation/measurementDevice/WellAllocatorTest.java b/src/test/java/neqsim/processSimulation/measurementDevice/WellAllocatorTest.java index 07d3470d6d..cb925ffaaf 100644 --- a/src/test/java/neqsim/processSimulation/measurementDevice/WellAllocatorTest.java +++ b/src/test/java/neqsim/processSimulation/measurementDevice/WellAllocatorTest.java @@ -45,10 +45,8 @@ void testGetMeasuredValueString() { testFluid.setPressure(48.0, "bara"); testFluid.setTotalFlowRate(2500.0, "kg/hr"); - SystemInterface testFluid2 = testFluid.clone(); - testFluid.setTemperature(24.0, "C"); testFluid.setPressure(48.0, "bara"); testFluid.setTotalFlowRate(2500.0, "kg/hr"); diff --git a/src/test/java/neqsim/processSimulation/processSystem/GlycolRigTest.java b/src/test/java/neqsim/processSimulation/processSystem/GlycolRigTest.java index 500cf8ef75..d8ba2ac96b 100644 --- a/src/test/java/neqsim/processSimulation/processSystem/GlycolRigTest.java +++ b/src/test/java/neqsim/processSimulation/processSystem/GlycolRigTest.java @@ -1,42 +1,27 @@ package neqsim.processSimulation.processSystem; -import java.util.ArrayList; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import neqsim.processSimulation.measurementDevice.HydrateEquilibriumTemperatureAnalyser; -import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface; -import neqsim.processSimulation.processEquipment.absorber.SimpleTEGAbsorber; import neqsim.processSimulation.processEquipment.absorber.WaterStripperColumn; import neqsim.processSimulation.processEquipment.compressor.Compressor; import neqsim.processSimulation.processEquipment.distillation.DistillationColumn; -import neqsim.processSimulation.processEquipment.filter.Filter; -import neqsim.processSimulation.processEquipment.heatExchanger.HeatExchanger; import neqsim.processSimulation.processEquipment.heatExchanger.Heater; import neqsim.processSimulation.processEquipment.mixer.Mixer; -import neqsim.processSimulation.processEquipment.mixer.StaticMixer; -import neqsim.processSimulation.processEquipment.pump.Pump; import neqsim.processSimulation.processEquipment.separator.Separator; import neqsim.processSimulation.processEquipment.stream.Stream; -import neqsim.processSimulation.processEquipment.util.Calculator; import neqsim.processSimulation.processEquipment.util.Recycle; -import neqsim.processSimulation.processEquipment.util.SetPoint; -import neqsim.processSimulation.processEquipment.util.StreamSaturatorUtil; -import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; -import neqsim.thermodynamicOperations.ThermodynamicOperations; public class GlycolRigTest extends neqsim.NeqSimTest { ProcessSystem p; String _name = "TestProcess"; - @BeforeEach public void setUp() { p = new ProcessSystem(); p.setName(_name); } - @Test public void runTEGProcessTest() { neqsim.thermo.system.SystemInterface feedTEG = diff --git a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemRunTransientTest.java b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemRunTransientTest.java index e8d07020b5..2d0e9699ca 100644 --- a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemRunTransientTest.java +++ b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemRunTransientTest.java @@ -1,8 +1,10 @@ package neqsim.processSimulation.processSystem; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import neqsim.processSimulation.SimulationInterface; import neqsim.processSimulation.controllerDevice.ControllerDeviceBaseClass; import neqsim.processSimulation.controllerDevice.ControllerDeviceInterface; import neqsim.processSimulation.measurementDevice.LevelTransmitter; @@ -13,187 +15,203 @@ import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; import neqsim.thermo.system.SystemInterface; -public class ProcessSystemRunTransientTest extends neqsim.NeqSimTest{ - ProcessSystem p; - - @BeforeEach - public void setUp() { - p = new ProcessSystem(); +public class ProcessSystemRunTransientTest extends neqsim.NeqSimTest { + ProcessSystem p; + + @BeforeEach + public void setUp() { + p = new ProcessSystem(); + } + + @Test + public void testGetName() { + String name = "TestProsess"; + p.setName(name); + Assertions.assertEquals(name, p.getName()); + } + + @Test + void testGetTime() { + + } + + @Test + void testGetTimeStep() { + + } + + private SystemInterface getTestSystem() { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); + testSystem.addComponent("methane", 0.900); + testSystem.addComponent("ethane", 0.100); + testSystem.addComponent("n-heptane", 1.00); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + return testSystem; + } + + // @Test + public void testDynamicCalculation() { + neqsim.thermo.system.SystemInterface testSystem = getTestSystem(); + + Stream stream1 = new Stream("Stream1", testSystem); + stream1.setFlowRate(50.0, "kg/hr"); + stream1.setPressure(10.0, "bara"); + + ThrottlingValve valve1 = new ThrottlingValve("valve_1", stream1); + valve1.setOutletPressure(5.0); + valve1.setPercentValveOpening(50); + + Separator separator1 = new Separator("sep 1"); + separator1.addStream(valve1.getOutletStream()); + + ThrottlingValve valve2 = new ThrottlingValve("valve_2", separator1.getLiquidOutStream()); + valve2.setOutletPressure(1.0); + valve2.setPercentValveOpening(50); + + ThrottlingValve valve3 = new ThrottlingValve("valve_3", separator1.getGasOutStream()); + valve3.setOutletPressure(1.0); + valve3.setPercentValveOpening(50); + + VolumeFlowTransmitter flowTransmitter = new VolumeFlowTransmitter(stream1); + flowTransmitter.setUnit("kg/hr"); + flowTransmitter.setMaximumValue(100.0); + flowTransmitter.setMinimumValue(1.0); + + ControllerDeviceInterface flowController = new ControllerDeviceBaseClass(); + flowController.setTransmitter(flowTransmitter); + flowController.setReverseActing(true); + flowController.setControllerSetPoint(63.5); + flowController.setControllerParameters(0.1, 0.10, 0.0); + + p.add(stream1); + p.add(valve1); + p.add(separator1); + p.add(valve2); + p.add(valve3); + p.add(flowTransmitter); + valve1.setController(flowController); + + p.run(); + + // transient behaviour + p.setTimeStep(1.0); + for (int i = 0; i < 5; i++) { + // System.out.println("volume flow " + flowTransmitter.getMeasuredValue() + // + " valve opening " + valve_1.getPercentValveOpening() + " pressure " + // + separator_1.getGasOutStream().getPressure()); + p.runTransient(); + for (SimulationInterface sim : p.getUnitOperations()) { + assertEquals(sim.getCalculationIdentifier(), p.getCalculationIdentifier()); + } } - - @Test - public void testGetName() { - String name = "TestProsess"; - p.setName(name); - Assertions.assertEquals(name, p.getName()); + } + + @Test + public void testDynamicCalculation2() { + neqsim.thermo.system.SystemInterface testSystem2 = + new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); + testSystem2.addComponent("methane", 1.1); + testSystem2.addComponent("ethane", 0.10001); + testSystem2.addComponent("n-heptane", 1.001); + testSystem2.setMixingRule(2); + + Stream purgeStream = new Stream("Purge Stream", testSystem2); + ThrottlingValve purgeValve = new ThrottlingValve("purgeValve", purgeStream); + purgeValve.setOutletPressure(7.0); + purgeValve.setPercentValveOpening(50.0); + + neqsim.thermo.system.SystemInterface testSystem = getTestSystem(); + Stream stream1 = new Stream("Stream1", testSystem); + stream1.setCalculateSteadyState(false); + ThrottlingValve valve1 = new ThrottlingValve("valve_1", stream1); + valve1.setOutletPressure(7.0); + valve1.setPercentValveOpening(50); + + Separator separator1 = new Separator("separator_1"); + separator1.addStream(valve1.getOutletStream()); + separator1.addStream(purgeValve.getOutletStream()); + separator1.setCalculateSteadyState(true); + + ThrottlingValve valve2 = new ThrottlingValve("valve_2", separator1.getLiquidOutStream()); + valve2.setOutletPressure(5.0); + valve2.setPercentValveOpening(50); + valve2.setCalculateSteadyState(true); + // valve_2.setCv(10.0); + + ThrottlingValve valve3 = new ThrottlingValve("valve_3", separator1.getGasOutStream()); + valve3.setOutletPressure(5.0); + valve3.setPercentValveOpening(50); + valve3.setCalculateSteadyState(true); + // valve_3.setCv(10.0); + + LevelTransmitter separatorLevelTransmitter = new LevelTransmitter(separator1); + separatorLevelTransmitter.setName("separatorLevelTransmitter1"); + separatorLevelTransmitter.setUnit("meter"); + separatorLevelTransmitter.setMaximumValue(1.0); + separatorLevelTransmitter.setMinimumValue(0.0); + + ControllerDeviceInterface separatorLevelController = new ControllerDeviceBaseClass(); + separatorLevelController.setReverseActing(true); + separatorLevelController.setTransmitter(separatorLevelTransmitter); + separatorLevelController.setControllerSetPoint(0.3); + separatorLevelController.setControllerParameters(1, 1000.0, 0.0); + + PressureTransmitter separatorPressureTransmitter = + new PressureTransmitter(separator1.getGasOutStream()); + separatorPressureTransmitter.setUnit("bar"); + separatorPressureTransmitter.setMaximumValue(10.0); + separatorPressureTransmitter.setMinimumValue(1.0); + + ControllerDeviceInterface separatorPressureController = new ControllerDeviceBaseClass(); + separatorPressureController.setTransmitter(separatorPressureTransmitter); + separatorPressureController.setReverseActing(false); + separatorPressureController.setControllerSetPoint(7.0); + separatorPressureController.setControllerParameters(0.5, 10.0, 0.0); + + p.add(stream1); + p.add(valve1); + + p.add(purgeStream); + p.add(purgeValve); + p.add(separator1); + p.add(valve2); + p.add(valve3); + + // add transmitters + p.add(separatorLevelTransmitter); + valve2.setController(separatorLevelController); + + p.add(separatorPressureTransmitter); + valve3.setController(separatorPressureController); + + p.run(); + for (SimulationInterface sim : p.getUnitOperations()) { + assertEquals(sim.getCalculationIdentifier(), p.getCalculationIdentifier()); } - @Test - void testGetTime() { - + // p.displayResult(); + p.setTimeStep(0.01); + for (int i = 0; i < 500; i++) { + // System.out.println("pressure "+separator_1.getGasOutStream().getPressure()+ " flow "+ + // separator_1.getGasOutStream().getFlowRate("kg/hr") + " sepr height + // "+separatorLevelTransmitter.getMeasuredValue()); + p.runTransient(); + for (SimulationInterface sim : p.getUnitOperations()) { + assertEquals(p.getCalculationIdentifier(), sim.getCalculationIdentifier()); + } } - @Test - void testGetTimeStep() { - - } - - private SystemInterface getTestSystem() { - neqsim.thermo.system.SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); - testSystem.addComponent("methane", 0.900); - testSystem.addComponent("ethane", 0.100); - testSystem.addComponent("n-heptane", 1.00); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - return testSystem; - } - - // @Test - public void testDynamicCalculation() { - neqsim.thermo.system.SystemInterface testSystem = getTestSystem(); - - Stream stream_1 = new Stream("Stream1", testSystem); - stream_1.setFlowRate(50.0, "kg/hr"); - stream_1.setPressure(10.0, "bara"); - - ThrottlingValve valve_1 = new ThrottlingValve("valve_1", stream_1); - valve_1.setOutletPressure(5.0); - valve_1.setPercentValveOpening(50); - - Separator separator_1 = new Separator("sep 1"); - separator_1.addStream(valve_1.getOutletStream()); - - ThrottlingValve valve_2 = new ThrottlingValve("valve_2", separator_1.getLiquidOutStream()); - valve_2.setOutletPressure(1.0); - valve_2.setPercentValveOpening(50); - - ThrottlingValve valve_3 = new ThrottlingValve("valve_3", separator_1.getGasOutStream()); - valve_3.setOutletPressure(1.0); - valve_3.setPercentValveOpening(50); - - VolumeFlowTransmitter flowTransmitter = new VolumeFlowTransmitter(stream_1); - flowTransmitter.setUnit("kg/hr"); - flowTransmitter.setMaximumValue(100.0); - flowTransmitter.setMinimumValue(1.0); - - ControllerDeviceInterface flowController = new ControllerDeviceBaseClass(); - flowController.setTransmitter(flowTransmitter); - flowController.setReverseActing(true); - flowController.setControllerSetPoint(63.5); - flowController.setControllerParameters(0.1, 0.10, 0.0); - - p.add(stream_1); - p.add(valve_1); - p.add(separator_1); - p.add(valve_2); - p.add(valve_3); - p.add(flowTransmitter); - valve_1.setController(flowController); - - p.run(); - - // transient behaviour - p.setTimeStep(1.0); - for (int i = 0; i < 5; i++) { - // System.out.println("volume flow " + flowTransmitter.getMeasuredValue() - // + " valve opening " + valve_1.getPercentValveOpening() + " pressure " - // + separator_1.getGasOutStream().getPressure()); - p.runTransient(); - } - } + valve1.setPercentValveOpening(60); - @Test - public void testDynamicCalculation2() { - - neqsim.thermo.system.SystemInterface testSystem = getTestSystem(); - - neqsim.thermo.system.SystemInterface testSystem2 = new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), - 10.00); - testSystem2.addComponent("methane", 1.1); - testSystem2.addComponent("ethane", 0.10001); - testSystem2.addComponent("n-heptane", 1.001); - testSystem2.setMixingRule(2); - - Stream purgeStream = new Stream("Purge Stream", testSystem2); - ThrottlingValve purgeValve = new ThrottlingValve("purgeValve", purgeStream); - purgeValve.setOutletPressure(7.0); - purgeValve.setPercentValveOpening(50.0); - - Stream stream_1 = new Stream("Stream1", testSystem); - stream_1.setCalculateSteadyState(false); - ThrottlingValve valve_1 = new ThrottlingValve("valve_1", stream_1); - valve_1.setOutletPressure(7.0); - valve_1.setPercentValveOpening(50); - - Separator separator_1 = new Separator("separator_1"); - separator_1.addStream(valve_1.getOutletStream()); - separator_1.addStream(purgeValve.getOutletStream()); - separator_1.setCalculateSteadyState(true); - - ThrottlingValve valve_2 = new ThrottlingValve("valve_2", separator_1.getLiquidOutStream()); - valve_2.setOutletPressure(5.0); - valve_2.setPercentValveOpening(50); - valve_2.setCalculateSteadyState(true); - // valve_2.setCv(10.0); - - ThrottlingValve valve_3 = new ThrottlingValve("valve_3", separator_1.getGasOutStream()); - valve_3.setOutletPressure(5.0); - valve_3.setPercentValveOpening(50); - valve_3.setCalculateSteadyState(true); - // valve_3.setCv(10.0); - - LevelTransmitter separatorLevelTransmitter = new LevelTransmitter(separator_1); - separatorLevelTransmitter.setName("separatorLevelTransmitter1"); - separatorLevelTransmitter.setUnit("meter"); - separatorLevelTransmitter.setMaximumValue(1.0); - separatorLevelTransmitter.setMinimumValue(0.0); - - ControllerDeviceInterface separatorLevelController = new ControllerDeviceBaseClass(); - separatorLevelController.setReverseActing(true); - separatorLevelController.setTransmitter(separatorLevelTransmitter); - separatorLevelController.setControllerSetPoint(0.3); - separatorLevelController.setControllerParameters(1, 1000.0, 0.0); - - PressureTransmitter separatorPressureTransmitter = new PressureTransmitter(separator_1.getGasOutStream()); - separatorPressureTransmitter.setUnit("bar"); - separatorPressureTransmitter.setMaximumValue(10.0); - separatorPressureTransmitter.setMinimumValue(1.0); - - ControllerDeviceInterface separatorPressureController = new ControllerDeviceBaseClass(); - separatorPressureController.setTransmitter(separatorPressureTransmitter); - separatorPressureController.setReverseActing(false); - separatorPressureController.setControllerSetPoint(7.0); - separatorPressureController.setControllerParameters(0.5, 10.0, 0.0); - - p.add(stream_1); - p.add(valve_1); - - p.add(purgeStream); - p.add(purgeValve); - p.add(separator_1); - p.add(valve_2); - p.add(valve_3); - - // add transmitters - p.add(separatorLevelTransmitter); - valve_2.setController(separatorLevelController); - - p.add(separatorPressureTransmitter); - valve_3.setController(separatorPressureController); - - p.run(); - // p.displayResult(); - p.setTimeStep(0.01); - for(int i=0;i<500;i++) { - //System.out.println("pressure "+separator_1.getGasOutStream().getPressure()+ " flow "+ separator_1.getGasOutStream().getFlowRate("kg/hr") + " sepr height "+separatorLevelTransmitter.getMeasuredValue()); - p.runTransient(); - } - - valve_1.setPercentValveOpening(60); - - for(int i=0;i<10;i++) { - // System.out.println("pressure "+separator_1.getGasOutStream().getPressure()+ " flow "+ separator_1.getGasOutStream().getFlowRate("kg/hr")); - p.runTransient(); - } + for (int i = 0; i < 10; i++) { + // System.out.println("pressure "+separator_1.getGasOutStream().getPressure()+ " flow "+ + // separator_1.getGasOutStream().getFlowRate("kg/hr")); + p.runTransient(); + for (SimulationInterface sim : p.getUnitOperations()) { + assertEquals(p.getCalculationIdentifier(), sim.getCalculationIdentifier()); + } } + } } diff --git a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemTest.java b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemTest.java index ecc312dac3..f2e9d09bb7 100644 --- a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemTest.java +++ b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemTest.java @@ -26,7 +26,6 @@ public class ProcessSystemTest extends neqsim.NeqSimTest { ProcessSystem p; String _name = "TestProcess"; - @BeforeEach public void setUp() { p = new ProcessSystem(); @@ -111,7 +110,6 @@ public void testRemoveUnit() { Assertions.assertEquals(0, p.size()); } - @Test @SuppressWarnings("deprecation") public void testAddUnitsWithNoName() { @@ -215,8 +213,6 @@ void testGetMechanicalWeight() { } - - @Test void testGetPower() { @@ -237,13 +233,11 @@ void testGetUnit() { } - @Test void testGetUnitOperations() { } - @Test void testOpen() { @@ -254,7 +248,6 @@ void testPrintLogFile() { } - @Test void testReplaceObject() { diff --git a/src/test/java/neqsim/thermo/system/SystemPrEosTest.java b/src/test/java/neqsim/thermo/system/SystemPrEosTest.java index 22e5a818ff..8d30856733 100644 --- a/src/test/java/neqsim/thermo/system/SystemPrEosTest.java +++ b/src/test/java/neqsim/thermo/system/SystemPrEosTest.java @@ -40,8 +40,6 @@ public static void setUp() { @DisplayName("test a TPflash2") public void testTPflash2() { - - assertEquals(2, testSystem.getNumberOfPhases()); } diff --git a/src/test/java/neqsim/thermo/system/SystemThermoAddComponentTest.java b/src/test/java/neqsim/thermo/system/SystemThermoAddComponentTest.java index ae6c459dbe..7f5ffab634 100644 --- a/src/test/java/neqsim/thermo/system/SystemThermoAddComponentTest.java +++ b/src/test/java/neqsim/thermo/system/SystemThermoAddComponentTest.java @@ -20,7 +20,6 @@ void setup() { */ } - @Test void testAddComponent() { // Assure that System contains no components diff --git a/src/test/java/neqsim/thermo/system/SystemUMRCPAEoStest.java b/src/test/java/neqsim/thermo/system/SystemUMRCPAEoStest.java index 4a43afb9ff..920a9bbfbc 100644 --- a/src/test/java/neqsim/thermo/system/SystemUMRCPAEoStest.java +++ b/src/test/java/neqsim/thermo/system/SystemUMRCPAEoStest.java @@ -43,8 +43,6 @@ public static void setUp() { // testSystem.i } - - /** *

* testFugasities. @@ -61,7 +59,6 @@ public void testFugasities() { assertEquals(-0.002884922, fucoef, 1e-6); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); testOps.TPflash(); testSystem.initProperties(); @@ -199,7 +196,6 @@ public void checkFugacityCoefficientsDn2() { assertTrue(testModel.checkFugacityCoefficientsDn2()); } - /** *

* checkPhaseEnvelope. diff --git a/src/test/java/neqsim/thermo/system/SystemUMRPRUMCEosNewTest.java b/src/test/java/neqsim/thermo/system/SystemUMRPRUMCEosNewTest.java index 07c42ca571..8501bb81bb 100644 --- a/src/test/java/neqsim/thermo/system/SystemUMRPRUMCEosNewTest.java +++ b/src/test/java/neqsim/thermo/system/SystemUMRPRUMCEosNewTest.java @@ -41,8 +41,6 @@ public static void setUp() { // testSystem.i } - - /** *

* testFugasities. @@ -59,7 +57,6 @@ public void testFugasities() { assertEquals(-0.002884922, fucoef, 1e-6); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); testOps.TPflash(); testSystem.initProperties(); @@ -184,7 +181,6 @@ public void checkFugacityCoefficientsDn2() { assertTrue(testModel.checkFugacityCoefficientsDn2()); } - /** *

* checkPhaseEnvelope. From 45e96af16332bc24e1521378469d27c8d32905f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?= <34712686+asmfstatoil@users.noreply.github.com> Date: Fri, 22 Jul 2022 14:17:52 +0200 Subject: [PATCH 5/9] refact: autoformat and autofix (#489) --- .../shipSystem/LNGship.java | 35 +- .../thermo/phase/PhaseElectrolyteCPA.java | 2683 +++++++++-------- .../freezingFit/TestSolidComplexFunction.java | 94 +- ...teractionParameterFittingFunction_CO2.java | 612 ++-- .../flashOps/PSFlash.java | 241 +- .../flashOps/PVrefluxflash.java | 130 +- .../flashOps/TPmultiflash.java | 1856 ++++++------ .../flashOps/TPmultiflash_1.java | 555 ++-- .../flashOps/TSFlash.java | 220 +- .../bubblePointTemperatureNoDer.java | 279 +- .../constantDutyPressureFlash.java | 183 +- .../constantDutyTemperatureFlash.java | 158 +- .../saturationOps/cricondebarFlash.java | 499 +-- .../saturationOps/cricondenBarTemp.java | 272 +- .../dewPointTemperatureFlashDer.java | 288 +- .../flashOps/sysNewtonRhapsonPHflash.java | 466 +-- .../flashOps/sysNewtonRhapsonTPflash.java | 276 +- .../pTphaseEnvelope.java | 1565 +++++----- .../util/database/AspenIP21Database.java | 244 +- 19 files changed, 5327 insertions(+), 5329 deletions(-) diff --git a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/shipSystem/LNGship.java b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/shipSystem/LNGship.java index bd6d4b4336..53e92c37cd 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/shipSystem/LNGship.java +++ b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/shipSystem/LNGship.java @@ -24,21 +24,43 @@ public class LNGship private static final long serialVersionUID = 1000; double[] temperature = null; - double dailyBoilOffRatio = 0.005, totalTankVolume = 140000; + double dailyBoilOffRatio = 0.005; + double totalTankVolume = 140000; private double liquidDensity = 0.7; int numberOffTimeSteps = 100; private double initialTemperature = 111.0; private boolean setInitialTemperature = false; private neqsim.thermo.system.SystemInterface thermoSystem = null; double initialNumberOffMoles; - double molarBoilOffRate = 0.0, dailyBoilOffVolume = 0.0; + double molarBoilOffRate = 0.0; + double dailyBoilOffVolume = 0.0; private double endTime = 960;// 24.0 * 10; private Standard_ISO6976 standardISO6976 = null; StandardInterface standardDensity = null; - double[] WI = null, density = null, volume = null, xmethane, xethane, xpropane, xiC4, xnC4, xiC5, - xnC5, xnC6, xnitrogen; - double[] ymethane, yethane, ypropane, yiC4, ynC4, yiC5, ynC5, ynC6, ynitrogen; - double[] GCV, GCVmass, totalEnergy; + double[] WI = null; + double[] density = null; + double[] volume = null; + double[] xmethane; + double[] xethane; + double[] xpropane; + double[] xiC4; + double[] xnC4; + double[] xiC5; + double[] xnC5; + double[] xnC6; + double[] xnitrogen; + double[] ymethane; + double[] yethane; + double[] ypropane; + double[] yiC4; + double[] ynC4; + double[] yiC5; + double[] ynC5; + double[] ynC6; + double[] ynitrogen; + double[] GCV; + double[] GCVmass; + double[] totalEnergy; double[] time; double[] tankTemperature = null; double timeStep = 0; @@ -185,7 +207,6 @@ public void solveTransient(int type, UUID id) { if (backCalculate) { molarBoilOffRate = -molarBoilOffRate; } - // double orginalMolarBoilOff = molarBoilOffRate; logger.info("end Volume " + endVolume); int iterations = 0; double boilOffCorrection = 0.0; diff --git a/src/main/java/neqsim/thermo/phase/PhaseElectrolyteCPA.java b/src/main/java/neqsim/thermo/phase/PhaseElectrolyteCPA.java index 3060764b45..48b9a4c21a 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseElectrolyteCPA.java +++ b/src/main/java/neqsim/thermo/phase/PhaseElectrolyteCPA.java @@ -20,1429 +20,1444 @@ * @version $Id: $Id */ public class PhaseElectrolyteCPA extends PhaseModifiedFurstElectrolyteEos - implements PhaseCPAInterface { - private static final long serialVersionUID = 1000; - - public CPAMixing cpaSelect = new CPAMixing(); - public CPAMixingInterface cpamix; - double gcpavv = 0.0, gcpavvv = 0.0, gcpa = 0.0, hcpatot = 1.0, FCPA = 0.0, dFCPAdTdV, - dFCPAdTdT = 0.0, dFCPAdT = 0, dFCPAdV = 0, dFCPAdVdV = 0.0, dFCPAdVdVdV = 0.0; - private double gcpav = 0.0; - int cpaon = 1, oldTotalNumberOfAccociationSites = 0; - private int totalNumberOfAccociationSites = 0; - int[][][] selfAccociationScheme = null; - int[][][][] crossAccociationScheme = null; - int[] moleculeNumber = null, assSiteNumber = null; - private double[][] gvector = null, delta = null, deltaNog = null, deltadT = null, - deltadTdT = null; - private double[][][] Klkni = null; - private SimpleMatrix KlkTVMatrix = null, KlkTTMatrix = null, KlkTMatrix = null, - udotTimesmMatrix = null, mVector = null, udotMatrix = null, uMatrix = null, - QMatksiksiksi = null, KlkVVVMatrix = null, KlkVVMatrix = null, udotTimesmiMatrix = null, - ksiMatrix = null, KlkMatrix = null, hessianMatrix = null, hessianInvers = null, - KlkVMatrix = null; - DMatrixRMaj corr2Matrix = null, corr3Matrix = null, corr4Matrix = null;// new - // DenseMatrix64F(getTotalNumberOfAccociationSites(), - // 1); - - static Logger logger = LogManager.getLogger(PhaseElectrolyteCPA.class); - - /** - *

- * Constructor for PhaseElectrolyteCPA. - *

- */ - public PhaseElectrolyteCPA() { - super(); + implements PhaseCPAInterface { + private static final long serialVersionUID = 1000; + + public CPAMixing cpaSelect = new CPAMixing(); + public CPAMixingInterface cpamix; + double gcpavv = 0.0; + double gcpavvv = 0.0; + double gcpa = 0.0; + double hcpatot = 1.0; + double FCPA = 0.0; + double dFCPAdTdV; + double dFCPAdTdT = 0.0; + double dFCPAdT = 0; + double dFCPAdV = 0; + double dFCPAdVdV = 0.0; + double dFCPAdVdVdV = 0.0; + private double gcpav = 0.0; + int cpaon = 1; + int oldTotalNumberOfAccociationSites = 0; + private int totalNumberOfAccociationSites = 0; + int[][][] selfAccociationScheme = null; + int[][][][] crossAccociationScheme = null; + int[] moleculeNumber = null; + int[] assSiteNumber = null; + private double[][] gvector = null; + private double[][] delta = null; + private double[][] deltaNog = null; + private double[][] deltadT = null; + private double[][] deltadTdT = null; + private double[][][] Klkni = null; + private SimpleMatrix KlkTVMatrix = null; + private SimpleMatrix KlkTTMatrix = null; + private SimpleMatrix KlkTMatrix = null; + private SimpleMatrix udotTimesmMatrix = null; + private SimpleMatrix mVector = null; + private SimpleMatrix udotMatrix = null; + private SimpleMatrix uMatrix = null; + private SimpleMatrix QMatksiksiksi = null; + private SimpleMatrix KlkVVVMatrix = null; + private SimpleMatrix KlkVVMatrix = null; + private SimpleMatrix udotTimesmiMatrix = null; + private SimpleMatrix ksiMatrix = null; + private SimpleMatrix KlkMatrix = null; + private SimpleMatrix hessianMatrix = null; + private SimpleMatrix hessianInvers = null; + private SimpleMatrix KlkVMatrix = null; + DMatrixRMaj corr2Matrix = null; + DMatrixRMaj corr3Matrix = null; + DMatrixRMaj corr4Matrix = null; + + static Logger logger = LogManager.getLogger(PhaseElectrolyteCPA.class); + + /** + *

+ * Constructor for PhaseElectrolyteCPA. + *

+ */ + public PhaseElectrolyteCPA() { + super(); + } + + /** {@inheritDoc} */ + @Override + public PhaseElectrolyteCPA clone() { + PhaseElectrolyteCPA clonedPhase = null; + try { + clonedPhase = (PhaseElectrolyteCPA) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); } - - /** {@inheritDoc} */ - @Override - public PhaseElectrolyteCPA clone() { - PhaseElectrolyteCPA clonedPhase = null; - try { - clonedPhase = (PhaseElectrolyteCPA) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); + // clonedPhase.cpaSelect = (CPAMixing) cpaSelect.clone(); + // clonedPhase.cpamix = (CPAMixingInterface) cpamix.clone(); + + return clonedPhase; + } + + /** {@inheritDoc} */ + @Override + public void setMixingRule(int type) { + super.setMixingRule(type); + cpamix = cpaSelect.getMixingRule(1, this); + } + + /** {@inheritDoc} */ + @Override + public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, + double beta) { + if (type == 0) { + setTotalNumberOfAccociationSites(0); + selfAccociationScheme = new int[numberOfComponents][0][0]; + crossAccociationScheme = new int[numberOfComponents][numberOfComponents][0][0]; + for (int i = 0; i < numberOfComponents; i++) { + if (getComponent(i).getNumberOfmoles() < 1e-100) { + getComponent(i).setNumberOfAssociationSites(0); + } else { + getComponent(i) + .setNumberOfAssociationSites(getComponent(i).getOrginalNumberOfAssociationSites()); + setTotalNumberOfAccociationSites( + getTotalNumberOfAccociationSites() + getComponent(i).getNumberOfAssociationSites()); + selfAccociationScheme[i] = cpaSelect.setAssociationScheme(i, this); + for (int j = 0; j < numberOfComponents; j++) { + crossAccociationScheme[i][j] = cpaSelect.setCrossAssociationScheme(i, j, this); + } } - // clonedPhase.cpaSelect = (CPAMixing) cpaSelect.clone(); - // clonedPhase.cpamix = (CPAMixingInterface) cpamix.clone(); - - return clonedPhase; + } + + if (getTotalNumberOfAccociationSites() != oldTotalNumberOfAccociationSites) { + mVector = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + KlkMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkVVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkVVVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + hessianMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkTMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkTTMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkTVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + corr2Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + corr3Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + corr4Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + Klkni = + new double[numberOfComponents][getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + ksiMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + uMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + udotMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + moleculeNumber = new int[getTotalNumberOfAccociationSites()]; + assSiteNumber = new int[getTotalNumberOfAccociationSites()]; + gvector = new double[getTotalNumberOfAccociationSites()][1]; + udotTimesmMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + udotTimesmiMatrix = + new SimpleMatrix(getNumberOfComponents(), getTotalNumberOfAccociationSites()); + delta = new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + deltaNog = + new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + deltadT = + new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + deltadTdT = + new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + QMatksiksiksi = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + } + oldTotalNumberOfAccociationSites = getTotalNumberOfAccociationSites(); + + int temp = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + moleculeNumber[temp + j] = i; + assSiteNumber[temp + j] = j; + } + temp += getComponent(i).getNumberOfAssociationSites(); + } } - /** {@inheritDoc} */ - @Override - public void setMixingRule(int type) { - super.setMixingRule(type); - cpamix = cpaSelect.getMixingRule(1, this); + if (cpamix == null) { + cpamix = cpaSelect.getMixingRule(1, this); } - /** {@inheritDoc} */ - @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, - double beta) { - if (type == 0) { - setTotalNumberOfAccociationSites(0); - selfAccociationScheme = new int[numberOfComponents][0][0]; - crossAccociationScheme = new int[numberOfComponents][numberOfComponents][0][0]; - for (int i = 0; i < numberOfComponents; i++) { - if (getComponent(i).getNumberOfmoles() < 1e-100) { - getComponent(i).setNumberOfAssociationSites(0); - } else { - getComponent(i).setNumberOfAssociationSites( - getComponent(i).getOrginalNumberOfAssociationSites()); - setTotalNumberOfAccociationSites(getTotalNumberOfAccociationSites() - + getComponent(i).getNumberOfAssociationSites()); - selfAccociationScheme[i] = cpaSelect.setAssociationScheme(i, this); - for (int j = 0; j < numberOfComponents; j++) { - crossAccociationScheme[i][j] = - cpaSelect.setCrossAssociationScheme(i, j, this); - } - } - } - - if (getTotalNumberOfAccociationSites() != oldTotalNumberOfAccociationSites) { - mVector = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - KlkMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkVVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkVVVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - hessianMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkTMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkTTMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkTVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - corr2Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - corr3Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - corr4Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - Klkni = new double[numberOfComponents][getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - ksiMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - uMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - udotMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - moleculeNumber = new int[getTotalNumberOfAccociationSites()]; - assSiteNumber = new int[getTotalNumberOfAccociationSites()]; - gvector = new double[getTotalNumberOfAccociationSites()][1]; - udotTimesmMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - udotTimesmiMatrix = new SimpleMatrix(getNumberOfComponents(), - getTotalNumberOfAccociationSites()); - delta = new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - deltaNog = - new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - deltadT = - new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - deltadTdT = - new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - QMatksiksiksi = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - } - oldTotalNumberOfAccociationSites = getTotalNumberOfAccociationSites(); - - int temp = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - moleculeNumber[temp + j] = i; - assSiteNumber[temp + j] = j; - } - temp += getComponent(i).getNumberOfAssociationSites(); - } - } - - if (cpamix == null) { - cpamix = cpaSelect.getMixingRule(1, this); - } - - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - if (type > 0 && isConstantPhaseVolume()) { - volInit(); - calcDelta(); - solveX(); - super.init(totalNumberOfMoles, numberOfComponents, 1, phase, beta); - gcpa = calc_g(); - // lngcpa = Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - } - - if (type > 0) { - hcpatot = calc_hCPA(); - } + super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + if (type > 0 && isConstantPhaseVolume()) { + volInit(); + calcDelta(); + solveX(); + super.init(totalNumberOfMoles, numberOfComponents, 1, phase, beta); + gcpa = calc_g(); + // lngcpa = Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); + } - if (type > 1) { - volInit(); - initCPAMatrix(type); - // hcpatotdT = calc_hCPAdT(); - // super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - } - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + if (type > 0) { + hcpatot = calc_hCPA(); } - /** - *

- * calcDelta. - *

- */ - public void calcDelta() { - for (int i = 0; i < totalNumberOfAccociationSites; i++) { - for (int j = i; j < totalNumberOfAccociationSites; j++) { - deltaNog[i][j] = cpamix.calcDeltaNog(assSiteNumber[i], assSiteNumber[j], - moleculeNumber[i], moleculeNumber[j], this, getTemperature(), getPressure(), - numberOfComponents); - deltaNog[j][i] = delta[i][j]; - } - } + if (type > 1) { + volInit(); + initCPAMatrix(type); + // hcpatotdT = calc_hCPAdT(); + // super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + } + super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + } + + /** + *

+ * calcDelta. + *

+ */ + public void calcDelta() { + for (int i = 0; i < totalNumberOfAccociationSites; i++) { + for (int j = i; j < totalNumberOfAccociationSites; j++) { + deltaNog[i][j] = cpamix.calcDeltaNog(assSiteNumber[i], assSiteNumber[j], moleculeNumber[i], + moleculeNumber[j], this, getTemperature(), getPressure(), numberOfComponents); + deltaNog[j][i] = delta[i][j]; + } + } + } + + /** + *

+ * initCPAMatrix. + *

+ * + * @param type a int + */ + public void initCPAMatrix(int type) { + if (getTotalNumberOfAccociationSites() == 0) { + FCPA = 0.0; + dFCPAdTdV = 0.0; + dFCPAdTdT = 0.0; + dFCPAdT = 0; + dFCPAdV = 0; + dFCPAdVdV = 0.0; + dFCPAdVdVdV = 0.0; + + return; } - /** - *

- * initCPAMatrix. - *

- * - * @param type a int - */ - public void initCPAMatrix(int type) { - if (getTotalNumberOfAccociationSites() == 0) { - FCPA = 0.0; - dFCPAdTdV = 0.0; - dFCPAdTdT = 0.0; - dFCPAdT = 0; - dFCPAdV = 0; - dFCPAdVdV = 0.0; - dFCPAdVdVdV = 0.0; - - return; + int temp = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + uMatrix.set(temp + j, 0, + Math.log(ksiMatrix.get(temp + j, 0)) - ksiMatrix.get(temp + j, 0) + 1.0); + gvector[temp + j][0] = mVector.get(temp + j, 0) * udotMatrix.get(temp + j, 0); + } + temp += getComponent(i).getNumberOfAssociationSites(); + } + for (int i = 0; i < getNumberOfComponents(); i++) { + for (int j = 0; j < getTotalNumberOfAccociationSites(); j++) { + if (moleculeNumber[j] == i) { + udotTimesmiMatrix.set(i, j, udotMatrix.get(j, 0)); + } else { + udotTimesmiMatrix.set(i, j, 0.0); } + } + } - int temp = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - uMatrix.set(temp + j, 0, - Math.log(ksiMatrix.get(temp + j, 0)) - ksiMatrix.get(temp + j, 0) + 1.0); - gvector[temp + j][0] = mVector.get(temp + j, 0) * udotMatrix.get(temp + j, 0); - } - temp += getComponent(i).getNumberOfAssociationSites(); - } - for (int i = 0; i < getNumberOfComponents(); i++) { - for (int j = 0; j < getTotalNumberOfAccociationSites(); j++) { - if (moleculeNumber[j] == i) { - udotTimesmiMatrix.set(i, j, udotMatrix.get(j, 0)); - } else { - udotTimesmiMatrix.set(i, j, 0.0); - } - } + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + delta[i][j] = deltaNog[i][j] * getGcpa(); + delta[j][i] = delta[i][j]; + if (type > 1) { + deltadT[i][j] = cpamix.calcDeltadT(assSiteNumber[i], assSiteNumber[j], moleculeNumber[i], + moleculeNumber[j], this, getTemperature(), getPressure(), numberOfComponents); + deltadT[j][i] = deltadT[i][j]; + + deltadTdT[i][j] = + cpamix.calcDeltadTdT(assSiteNumber[i], assSiteNumber[j], moleculeNumber[i], + moleculeNumber[j], this, getTemperature(), getPressure(), numberOfComponents); + deltadTdT[j][i] = deltadTdT[i][j]; } + } + } - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - delta[i][j] = deltaNog[i][j] * getGcpa(); - delta[j][i] = delta[i][j]; - if (type > 1) { - deltadT[i][j] = cpamix.calcDeltadT(assSiteNumber[i], assSiteNumber[j], - moleculeNumber[i], moleculeNumber[j], this, getTemperature(), - getPressure(), numberOfComponents); - deltadT[j][i] = deltadT[i][j]; - - deltadTdT[i][j] = cpamix.calcDeltadTdT(assSiteNumber[i], assSiteNumber[j], - moleculeNumber[i], moleculeNumber[j], this, getTemperature(), - getPressure(), numberOfComponents); - deltadTdT[j][i] = deltadTdT[i][j]; - } - } - } + double gdv1 = getGcpav() - 1.0 / getTotalVolume(); + double gdv2 = gdv1 * gdv1; + double gdv3 = gdv2 * gdv1; + double totVol = getTotalVolume(); + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + KlkVMatrix.set(i, j, KlkMatrix.get(i, j) * gdv1); + KlkVMatrix.set(j, i, KlkVMatrix.get(i, j)); + + KlkVVMatrix.set(i, j, KlkMatrix.get(i, j) * gdv2 + + KlkMatrix.get(i, j) * (gcpavv + 1.0 / getTotalVolume() / getTotalVolume())); + KlkVVMatrix.set(j, i, KlkVVMatrix.get(i, j)); + + KlkVVVMatrix.set(i, j, + KlkMatrix.get(i, j) * gdv3 + + 3.0 * KlkMatrix.get(i, j) * (getGcpav() - 1.0 / getTotalVolume()) + * (gcpavv + 1.0 / (totVol * totVol)) + + KlkMatrix.get(i, j) * (gcpavvv - 2.0 / (totVol * totVol * totVol))); + KlkVVVMatrix.set(j, i, KlkVVVMatrix.get(i, j)); - double gdv1 = getGcpav() - 1.0 / getTotalVolume(); - double gdv2 = gdv1 * gdv1; - double gdv3 = gdv2 * gdv1; - double totVol = getTotalVolume(); - // double Klk = 0.0; - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - KlkVMatrix.set(i, j, KlkMatrix.get(i, j) * gdv1); - KlkVMatrix.set(j, i, KlkVMatrix.get(i, j)); - - KlkVVMatrix.set(i, j, KlkMatrix.get(i, j) * gdv2 + KlkMatrix.get(i, j) - * (gcpavv + 1.0 / getTotalVolume() / getTotalVolume())); - KlkVVMatrix.set(j, i, KlkVVMatrix.get(i, j)); - - KlkVVVMatrix.set(i, j, KlkMatrix.get(i, j) * gdv3 - + 3.0 * KlkMatrix.get(i, j) * (getGcpav() - 1.0 / getTotalVolume()) - * (gcpavv + 1.0 / (totVol * totVol)) - + KlkMatrix.get(i, j) * (gcpavvv - 2.0 / (totVol * totVol * totVol))); - KlkVVVMatrix.set(j, i, KlkVVVMatrix.get(i, j)); - - if (type > 1) { - double tempVar = deltadT[i][j] / delta[i][j]; - double tempVardT = deltadTdT[i][j] / delta[i][j] - - (deltadT[i][j] * deltadT[i][j]) / (delta[i][j] * delta[i][j]); - - if (!Double.isNaN(tempVar)) { - // KlkdT[i][j] = KlkMatrix.getMatrix().unsafe_get(i, j) * tempVar; - // KlkdT[j][i] = KlkdT[i][j]; - - KlkTMatrix.set(i, j, KlkMatrix.get(i, j) * tempVar); - KlkTMatrix.set(j, i, KlkTMatrix.get(i, j)); - - KlkTVMatrix.set(i, j, - KlkMatrix.get(i, j) * tempVar * (gcpav - 1.0 / getTotalVolume())); - KlkTVMatrix.set(j, i, KlkTVMatrix.get(i, j)); - - KlkTTMatrix.set(i, j, - KlkMatrix.get(i, j) * (tempVar * tempVar + tempVardT)); - KlkTTMatrix.set(j, i, KlkTTMatrix.get(i, j)); - } - - if (type > 2) { - for (int p = 0; p < numberOfComponents; p++) { - double t1 = 0.0, t2 = 0.0; - if (moleculeNumber[i] == p) { - t1 = 1.0 / mVector.get(i, 0); - } - if (moleculeNumber[j] == p) { - t2 = 1.0 / mVector.get(j, 0); - } - Klkni[p][i][j] = KlkMatrix.get(i, j) * (t1 + t2 - + ((ComponentElectrolyteCPA) getComponent(p)).calc_lngi(this)); - Klkni[p][j][i] = Klkni[p][i][j]; - } - } - } + if (type > 1) { + double tempVar = deltadT[i][j] / delta[i][j]; + double tempVardT = deltadTdT[i][j] / delta[i][j] + - (deltadT[i][j] * deltadT[i][j]) / (delta[i][j] * delta[i][j]); + + if (!Double.isNaN(tempVar)) { + // KlkdT[i][j] = KlkMatrix.getMatrix().unsafe_get(i, j) * tempVar; + // KlkdT[j][i] = KlkdT[i][j]; + + KlkTMatrix.set(i, j, KlkMatrix.get(i, j) * tempVar); + KlkTMatrix.set(j, i, KlkTMatrix.get(i, j)); + + KlkTVMatrix.set(i, j, KlkMatrix.get(i, j) * tempVar * (gcpav - 1.0 / getTotalVolume())); + KlkTVMatrix.set(j, i, KlkTVMatrix.get(i, j)); + + KlkTTMatrix.set(i, j, KlkMatrix.get(i, j) * (tempVar * tempVar + tempVardT)); + KlkTTMatrix.set(j, i, KlkTTMatrix.get(i, j)); + } + + if (type > 2) { + for (int p = 0; p < numberOfComponents; p++) { + double t1 = 0.0; + double t2 = 0.0; + if (moleculeNumber[i] == p) { + t1 = 1.0 / mVector.get(i, 0); + } + if (moleculeNumber[j] == p) { + t2 = 1.0 / mVector.get(j, 0); + } + Klkni[p][i][j] = KlkMatrix.get(i, j) + * (t1 + t2 + ((ComponentElectrolyteCPA) getComponent(p)).calc_lngi(this)); + Klkni[p][j][i] = Klkni[p][i][j]; } - QMatksiksiksi.set(i, 0, 2.0 * mVector.get(i, 0) - / (ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0))); + } } + } + QMatksiksiksi.set(i, 0, 2.0 * mVector.get(i, 0) + / (ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0))); + } - SimpleMatrix ksiMatrixTranspose = ksiMatrix.transpose(); + SimpleMatrix ksiMatrixTranspose = ksiMatrix.transpose(); - // dXdV - SimpleMatrix KlkVMatrixksi = KlkVMatrix.mult(ksiMatrix); - SimpleMatrix XV = hessianInvers.mult(KlkVMatrixksi); - SimpleMatrix XVtranspose = XV.transpose(); + // dXdV + SimpleMatrix KlkVMatrixksi = KlkVMatrix.mult(ksiMatrix); + SimpleMatrix XV = hessianInvers.mult(KlkVMatrixksi); + SimpleMatrix XVtranspose = XV.transpose(); - SimpleMatrix QCPA = mVector.transpose() - .mult(uMatrix.minus(ksiMatrix.elementMult(udotMatrix).scale(0.5))); - FCPA = QCPA.get(0, 0); + SimpleMatrix QCPA = + mVector.transpose().mult(uMatrix.minus(ksiMatrix.elementMult(udotMatrix).scale(0.5))); + FCPA = QCPA.get(0, 0); - SimpleMatrix tempMatrix = ksiMatrixTranspose.mult(KlkVMatrixksi).scale(-0.5); - dFCPAdV = tempMatrix.get(0, 0); - SimpleMatrix KlkVVMatrixTImesKsi = KlkVVMatrix.mult(ksiMatrix); - SimpleMatrix tempMatrixVV = ksiMatrixTranspose.mult(KlkVVMatrixTImesKsi).scale(-0.5) - .minus(KlkVMatrixksi.transpose().mult(XV)); - dFCPAdVdV = tempMatrixVV.get(0, 0); + SimpleMatrix tempMatrix = ksiMatrixTranspose.mult(KlkVMatrixksi).scale(-0.5); + dFCPAdV = tempMatrix.get(0, 0); + SimpleMatrix KlkVVMatrixTImesKsi = KlkVVMatrix.mult(ksiMatrix); + SimpleMatrix tempMatrixVV = ksiMatrixTranspose.mult(KlkVVMatrixTImesKsi).scale(-0.5) + .minus(KlkVMatrixksi.transpose().mult(XV)); + dFCPAdVdV = tempMatrixVV.get(0, 0); - SimpleMatrix QVVV = ksiMatrixTranspose.mult(KlkVVVMatrix.mult(ksiMatrix)).scale(-0.5); - SimpleMatrix QVVksi = KlkVVMatrixTImesKsi.scale(-1.0); - SimpleMatrix QksiVksi = KlkVMatrix.scale(-1.0); + SimpleMatrix QVVV = ksiMatrixTranspose.mult(KlkVVVMatrix.mult(ksiMatrix)).scale(-0.5); + SimpleMatrix QVVksi = KlkVVMatrixTImesKsi.scale(-1.0); + SimpleMatrix QksiVksi = KlkVMatrix.scale(-1.0); - SimpleMatrix mat1 = QVVksi.transpose().mult(XV).scale(3.0); - SimpleMatrix mat2 = XVtranspose.mult(QksiVksi.mult(XV)).scale(3.0); - SimpleMatrix mat4 = XVtranspose.mult(QMatksiksiksi.mult(XVtranspose)).mult(XV); + SimpleMatrix mat1 = QVVksi.transpose().mult(XV).scale(3.0); + SimpleMatrix mat2 = XVtranspose.mult(QksiVksi.mult(XV)).scale(3.0); + SimpleMatrix mat4 = XVtranspose.mult(QMatksiksiksi.mult(XVtranspose)).mult(XV); - SimpleMatrix dFCPAdVdVdVMatrix = QVVV.plus(mat1).plus(mat2).plus(mat2).plus(mat4); - dFCPAdVdVdV = dFCPAdVdVdVMatrix.get(0, 0); - temp = 0; + SimpleMatrix dFCPAdVdVdVMatrix = QVVV.plus(mat1).plus(mat2).plus(mat2).plus(mat4); + dFCPAdVdVdV = dFCPAdVdVdVMatrix.get(0, 0); + temp = 0; - if (type == 1) { - return; - } - for (int p = 0; p < numberOfComponents; p++) { - for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { - ((ComponentCPAInterface) getComponent(p)).setXsitedV(kk, XV.get(temp + kk, 0)); - } - temp += getComponent(p).getNumberOfAssociationSites(); - } - - // KlkTMatrix = new SimpleMatrix(KlkdT); - SimpleMatrix KlkTMatrixTImesKsi = KlkTMatrix.mult(ksiMatrix); - // dQdT - SimpleMatrix tempMatrix2 = ksiMatrixTranspose.mult(KlkTMatrixTImesKsi).scale(-0.5); - dFCPAdT = tempMatrix2.get(0, 0); - - // SimpleMatrix KlkTVMatrix = new SimpleMatrix(KlkdTdV); - // SimpleMatrix tempMatrixTV = - // ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5).minus(KlkTMatrixTImesKsi.transpose().mult(XV)); - // dFCPAdTdV = tempMatrixTV.get(0, 0); - // dXdT - SimpleMatrix XT = hessianInvers.mult(KlkTMatrixTImesKsi); - // dQdTdT - SimpleMatrix tempMatrixTT = ksiMatrixTranspose.mult(KlkTTMatrix.mult(ksiMatrix)).scale(-0.5) - .minus(KlkTMatrixTImesKsi.transpose().mult(XT)); - dFCPAdTdT = tempMatrixTT.get(0, 0); - - SimpleMatrix tempMatrixTV = ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5) - .minus(KlkTMatrixTImesKsi.transpose().mult(XV)); - dFCPAdTdV = tempMatrixTV.get(0, 0); - - temp = 0; - for (int p = 0; p < numberOfComponents; p++) { - for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { - ((ComponentCPAInterface) getComponent(p)).setXsitedT(kk, XT.get(temp + kk, 0)); - } - temp += getComponent(p).getNumberOfAssociationSites(); - } - - if (type == 2) { - return; - } - - // int assSites = 0; - // if(true) return; - for (int p = 0; p < numberOfComponents; p++) { - SimpleMatrix KiMatrix = new SimpleMatrix(Klkni[p]); - // KiMatrix.print(10,10); - // Matrix dQdniMatrix = - // (ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5)); // this - // methods misses one part of .... - // dQdniMatrix.print(10,10); - // KiMatrix.print(10, 10); - // miMatrix.getMatrix(assSites, assSites, 0, totalNumberOfAccociationSites - - // 1).print(10, 10); - // Matrix tempMatrix20 = miMatrix.getMatrix(assSites, assSites, 0, - // totalNumberOfAccociationSites - - // 1).times(uMatrix).minus(ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5));// - // ksiMatrix.transpose().times(KlkTMatrix.times(ksiMatrix)).times(-0.5); - // System.out.println("dQdn "); - // tempMatrix20.print(10, 10); - SimpleMatrix tempMatrix4 = KiMatrix.mult(ksiMatrix); - // udotTimesmiMatrix.getMatrix(assSites, assSites, 0, - // totalNumberOfAccociationSites - 1).print(10, 10); - SimpleMatrix tempMatrix5 = - udotTimesmiMatrix.extractVector(true, p).transpose().minus(tempMatrix4); - // tempMki[0] = mki[p]; - // Matrix amatrix = new Matrix(croeneckerProduct(tempMki, - // udotMatrix.getArray())); - // System.out.println("aMatrix "); - // amatrix.transpose().print(10, 10); - // System.out.println("temp4 matrix"); - // tempMatrix4.print(10, 10); - // Matrix tempMatrix5 = amatrix.minus(tempMatrix4); - SimpleMatrix tempMatrix6 = hessianInvers.mult(tempMatrix5);// .scale(-1.0); - // System.out.println("dXdni"); - // tempMatrix4.print(10, 10); - // tempMatrix5.print(10, 10); - // System.out.println("dXdn "); - // tempMatrix6.print(10, 10); - int temp2 = 0; - for (int compp = 0; compp < numberOfComponents; compp++) { - for (int kk = 0; kk < getComponent(compp).getNumberOfAssociationSites(); kk++) { - ((ComponentCPAInterface) getComponent(compp)).setXsitedni(kk, p, - -1.0 * tempMatrix6.get(temp2 + kk, 0)); - } - temp2 += getComponent(compp).getNumberOfAssociationSites(); - } - // assSites += getComponent(p).getNumberOfAssociationSites(); - } - } - - /** {@inheritDoc} */ - @Override - public void addcomponent(String componentName, double moles, double molesInPhase, - int compNumber) { - super.addcomponent(componentName, moles, molesInPhase, compNumber); - componentArray[compNumber] = - new ComponentElectrolyteCPA(componentName, moles, molesInPhase, compNumber); - } - - /** {@inheritDoc} */ - @Override - public double getF() { - return super.getF() + cpaon * FCPA(); - } - - /** {@inheritDoc} */ - @Override - public double dFdT() { - return super.dFdT() + cpaon * dFCPAdT(); - } - - /** {@inheritDoc} */ - @Override - public double dFdTdV() { - return super.dFdTdV() + cpaon * dFCPAdTdV(); + if (type == 1) { + return; } - - /** {@inheritDoc} */ - @Override - public double dFdV() { - double dv2 = dFCPAdV(); - return super.dFdV() + cpaon * dv2; + for (int p = 0; p < numberOfComponents; p++) { + for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { + ((ComponentCPAInterface) getComponent(p)).setXsitedV(kk, XV.get(temp + kk, 0)); + } + temp += getComponent(p).getNumberOfAssociationSites(); } - /** {@inheritDoc} */ - @Override - public double dFdVdV() { - return super.dFdVdV() + cpaon * dFCPAdVdV(); + // KlkTMatrix = new SimpleMatrix(KlkdT); + SimpleMatrix KlkTMatrixTImesKsi = KlkTMatrix.mult(ksiMatrix); + // dQdT + SimpleMatrix tempMatrix2 = ksiMatrixTranspose.mult(KlkTMatrixTImesKsi).scale(-0.5); + dFCPAdT = tempMatrix2.get(0, 0); + + // SimpleMatrix KlkTVMatrix = new SimpleMatrix(KlkdTdV); + // SimpleMatrix tempMatrixTV = + // ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5).minus(KlkTMatrixTImesKsi.transpose().mult(XV)); + // dFCPAdTdV = tempMatrixTV.get(0, 0); + // dXdT + SimpleMatrix XT = hessianInvers.mult(KlkTMatrixTImesKsi); + // dQdTdT + SimpleMatrix tempMatrixTT = ksiMatrixTranspose.mult(KlkTTMatrix.mult(ksiMatrix)).scale(-0.5) + .minus(KlkTMatrixTImesKsi.transpose().mult(XT)); + dFCPAdTdT = tempMatrixTT.get(0, 0); + + SimpleMatrix tempMatrixTV = ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5) + .minus(KlkTMatrixTImesKsi.transpose().mult(XV)); + dFCPAdTdV = tempMatrixTV.get(0, 0); + + temp = 0; + for (int p = 0; p < numberOfComponents; p++) { + for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { + ((ComponentCPAInterface) getComponent(p)).setXsitedT(kk, XT.get(temp + kk, 0)); + } + temp += getComponent(p).getNumberOfAssociationSites(); } - /** {@inheritDoc} */ - @Override - public double dFdVdVdV() { - return super.dFdVdVdV() + cpaon * dFCPAdVdVdV(); + if (type == 2) { + return; } - /** {@inheritDoc} */ - @Override - public double dFdTdT() { - return super.dFdTdT() + cpaon * dFCPAdTdT(); + // if(true) return; + for (int p = 0; p < numberOfComponents; p++) { + SimpleMatrix KiMatrix = new SimpleMatrix(Klkni[p]); + // KiMatrix.print(10,10); + // Matrix dQdniMatrix = + // (ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5)); // this + // methods misses one part of .... + // dQdniMatrix.print(10,10); + // KiMatrix.print(10, 10); + // miMatrix.getMatrix(assSites, assSites, 0, totalNumberOfAccociationSites - + // 1).print(10, 10); + // Matrix tempMatrix20 = miMatrix.getMatrix(assSites, assSites, 0, + // totalNumberOfAccociationSites - + // 1).times(uMatrix).minus(ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5));// + // ksiMatrix.transpose().times(KlkTMatrix.times(ksiMatrix)).times(-0.5); + // System.out.println("dQdn "); + // tempMatrix20.print(10, 10); + SimpleMatrix tempMatrix4 = KiMatrix.mult(ksiMatrix); + // udotTimesmiMatrix.getMatrix(assSites, assSites, 0, + // totalNumberOfAccociationSites - 1).print(10, 10); + SimpleMatrix tempMatrix5 = + udotTimesmiMatrix.extractVector(true, p).transpose().minus(tempMatrix4); + // tempMki[0] = mki[p]; + // Matrix amatrix = new Matrix(croeneckerProduct(tempMki, + // udotMatrix.getArray())); + // System.out.println("aMatrix "); + // amatrix.transpose().print(10, 10); + // System.out.println("temp4 matrix"); + // tempMatrix4.print(10, 10); + // Matrix tempMatrix5 = amatrix.minus(tempMatrix4); + SimpleMatrix tempMatrix6 = hessianInvers.mult(tempMatrix5);// .scale(-1.0); + // System.out.println("dXdni"); + // tempMatrix4.print(10, 10); + // tempMatrix5.print(10, 10); + // System.out.println("dXdn "); + // tempMatrix6.print(10, 10); + int temp2 = 0; + for (int compp = 0; compp < numberOfComponents; compp++) { + for (int kk = 0; kk < getComponent(compp).getNumberOfAssociationSites(); kk++) { + ((ComponentCPAInterface) getComponent(compp)).setXsitedni(kk, p, + -1.0 * tempMatrix6.get(temp2 + kk, 0)); + } + temp2 += getComponent(compp).getNumberOfAssociationSites(); + } + // assSites += getComponent(p).getNumberOfAssociationSites(); } - - /** - *

- * FCPA. - *

- * - * @return a double + } + + /** {@inheritDoc} */ + @Override + public void addcomponent(String componentName, double moles, double molesInPhase, + int compNumber) { + super.addcomponent(componentName, moles, molesInPhase, compNumber); + componentArray[compNumber] = + new ComponentElectrolyteCPA(componentName, moles, molesInPhase, compNumber); + } + + /** {@inheritDoc} */ + @Override + public double getF() { + return super.getF() + cpaon * FCPA(); + } + + /** {@inheritDoc} */ + @Override + public double dFdT() { + return super.dFdT() + cpaon * dFCPAdT(); + } + + /** {@inheritDoc} */ + @Override + public double dFdTdV() { + return super.dFdTdV() + cpaon * dFCPAdTdV(); + } + + /** {@inheritDoc} */ + @Override + public double dFdV() { + double dv2 = dFCPAdV(); + return super.dFdV() + cpaon * dv2; + } + + /** {@inheritDoc} */ + @Override + public double dFdVdV() { + return super.dFdVdV() + cpaon * dFCPAdVdV(); + } + + /** {@inheritDoc} */ + @Override + public double dFdVdVdV() { + return super.dFdVdVdV() + cpaon * dFCPAdVdVdV(); + } + + /** {@inheritDoc} */ + @Override + public double dFdTdT() { + return super.dFdTdT() + cpaon * dFCPAdTdT(); + } + + /** + *

+ * FCPA. + *

+ * + * @return a double + */ + public double FCPA() { + /* + * double tot = 0.0; double ans = 0.0; for (int i = 0; i < numberOfComponents; i++) { tot = 0.0; + * for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { double xai = + * ((ComponentSrkCPA) getComponent(i)).getXsite()[j]; tot += (Math.log(xai) - 1.0 / 2.0 * xai + + * 1.0 / 2.0); } ans += getComponent(i).getNumberOfMolesInPhase() * tot; } return ans; */ - public double FCPA() { - /* - * double tot = 0.0; double ans = 0.0; for (int i = 0; i < numberOfComponents; i++) { tot = - * 0.0; for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { double xai - * = ((ComponentSrkCPA) getComponent(i)).getXsite()[j]; tot += (Math.log(xai) - 1.0 / 2.0 * - * xai + 1.0 / 2.0); } ans += getComponent(i).getNumberOfMolesInPhase() * tot; } return ans; - */ - return FCPA; - } - - /** - *

- * dFCPAdV. - *

- * - * @return a double + return FCPA; + } + + /** + *

+ * dFCPAdV. + *

+ * + * @return a double + */ + public double dFCPAdV() { + // return 1.0 / (2.0 * getTotalVolume()) * (1.0 - getTotalVolume() * getGcpav()) + // * hcpatot; + return dFCPAdV; + } + + /** + *

+ * dFCPAdVdV. + *

+ * + * @return a double + */ + public double dFCPAdVdV() { + // double sum1 = -1.0 / 2.0 * gcpavv * hcpatot; + // return -1.0 / getTotalVolume() * dFCPAdV() + sum1; + return dFCPAdVdV; + } + + /** + *

+ * dFCPAdVdVdV. + *

+ * + * @return a double + */ + public double dFCPAdVdVdV() { + return dFCPAdVdVdV; + // return -1.0 / getTotalVolume() * dFCPAdVdV() + 1.0 / + // Math.pow(getTotalVolume(), 2.0) * dFCPAdV() - hcpatot / (2.0 * + // Math.pow(getTotalVolume(), 2.0)) * (-getGcpav() - getTotalVolume() * gcpavv) + // + hcpatot / (2.0 * getTotalVolume()) * (-gcpavv - getTotalVolume() * gcpavvv + // - gcpavv); + } + + /** + *

+ * dFCPAdT. + *

+ * + * @return a double + */ + public double dFCPAdT() { + /* + * double tot = 0.0; double ans = 0.0; for (int i = 0; i < numberOfComponents; i++) { tot = 0.0; + * for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { double xai = + * ((ComponentSrkCPA) getComponent(i)).getXsite()[j]; double xaidT = ((ComponentSrkCPA) + * getComponent(i)).getXsitedT()[j]; tot += 1.0 / xai * xaidT - 0.5 * xaidT;// - 1.0 / 2.0 * xai + * + 1.0 / 2.0); } ans += getComponent(i).getNumberOfMolesInPhase() * tot; } + * System.out.println("dFCPAdT1 " + ans + " dfcpa2 " +dFCPAdT); return ans; */ - public double dFCPAdV() { - // return 1.0 / (2.0 * getTotalVolume()) * (1.0 - getTotalVolume() * getGcpav()) - // * hcpatot; - return dFCPAdV; - } - - /** - *

- * dFCPAdVdV. - *

- * - * @return a double + return dFCPAdT; + } + + /** + *

+ * dFCPAdTdT. + *

+ * + * @return a double + */ + public double dFCPAdTdT() { + return dFCPAdTdT; + } + + /** + *

+ * dFCPAdTdV. + *

+ * + * @return a double + */ + public double dFCPAdTdV() { + // System.out.println("dFCPAdTdV1 " + dFCPAdTdV + " dFCPAdTdV " +( 1.0 / (2.0 * + // getTotalVolume()) * (1.0 - getTotalVolume() * getGcpav()) * hcpatotdT)); + return dFCPAdTdV; + /* + * if (totalNumberOfAccociationSites > 0) { return 1.0 / (2.0 * getTotalVolume()) * (1.0 - + * getTotalVolume() * getGcpav()) * hcpatotdT; } else { return 0; } */ - public double dFCPAdVdV() { - // double sum1 = -1.0 / 2.0 * gcpavv * hcpatot; - // return -1.0 / getTotalVolume() * dFCPAdV() + sum1; - return dFCPAdVdV; + } + + /** + *

+ * calc_hCPA. + *

+ * + * @return a double + */ + public double calc_hCPA() { + double htot = 0.0; + double tot = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + htot = 0.0; + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + htot += (1.0 - ((ComponentCPAInterface) getComponent(i)).getXsite()[j]); + } + tot += getComponent(i).getNumberOfMolesInPhase() * htot; } - - /** - *

- * dFCPAdVdVdV. - *

- * - * @return a double - */ - public double dFCPAdVdVdV() { - return dFCPAdVdVdV; - // return -1.0 / getTotalVolume() * dFCPAdVdV() + 1.0 / - // Math.pow(getTotalVolume(), 2.0) * dFCPAdV() - hcpatot / (2.0 * - // Math.pow(getTotalVolume(), 2.0)) * (-getGcpav() - getTotalVolume() * gcpavv) - // + hcpatot / (2.0 * getTotalVolume()) * (-gcpavv - getTotalVolume() * gcpavvv - // - gcpavv); + return tot; + } + + /** + *

+ * calcXsitedV. + *

+ */ + public void calcXsitedV() { + if (totalNumberOfAccociationSites > 0) { + initCPAMatrix(1); } - - /** - *

- * dFCPAdT. - *

- * - * @return a double - */ - public double dFCPAdT() { - /* - * double tot = 0.0; double ans = 0.0; for (int i = 0; i < numberOfComponents; i++) { tot = - * 0.0; for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { double xai - * = ((ComponentSrkCPA) getComponent(i)).getXsite()[j]; double xaidT = ((ComponentSrkCPA) - * getComponent(i)).getXsitedT()[j]; tot += 1.0 / xai * xaidT - 0.5 * xaidT;// - 1.0 / 2.0 * - * xai + 1.0 / 2.0); } ans += getComponent(i).getNumberOfMolesInPhase() * tot; } - * System.out.println("dFCPAdT1 " + ans + " dfcpa2 " +dFCPAdT); return ans; - */ - return dFCPAdT; + } + + /** + *

+ * solveX. + *

+ * + * @return a boolean + */ + public boolean solveX() { + if (getTotalNumberOfAccociationSites() == 0) { + return true; } - /** - *

- * dFCPAdTdT. - *

- * - * @return a double - */ - public double dFCPAdTdT() { - return dFCPAdTdT; + boolean solvedX = solveX2(5); + if (solvedX) { + // return true; } - /** - *

- * dFCPAdTdV. - *

- * - * @return a double - */ - public double dFCPAdTdV() { - // System.out.println("dFCPAdTdV1 " + dFCPAdTdV + " dFCPAdTdV " +( 1.0 / (2.0 * - // getTotalVolume()) * (1.0 - getTotalVolume() * getGcpav()) * hcpatotdT)); - return dFCPAdTdV; - /* - * if (totalNumberOfAccociationSites > 0) { return 1.0 / (2.0 * getTotalVolume()) * (1.0 - - * getTotalVolume() * getGcpav()) * hcpatotdT; } else { return 0; } - */ + DMatrixRMaj mat1 = KlkMatrix.getMatrix(); + DMatrixRMaj mat2 = ksiMatrix.getMatrix(); + // second order method not working correctly and not used t the moment b ecause of numerical + // stability + int temp = 0; + int iter = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + mVector.set(temp + j, 0, getComponent(i).getNumberOfMolesInPhase()); + } + temp += getComponent(i).getNumberOfAssociationSites(); } - - /** - *

- * calc_hCPA. - *

- * - * @return a double - */ - public double calc_hCPA() { - double htot = 0.0; - double tot = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - htot = 0.0; - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - htot += (1.0 - ((ComponentCPAInterface) getComponent(i)).getXsite()[j]); - } - tot += getComponent(i).getNumberOfMolesInPhase() * htot; - } - return tot; + double Klk = 0.0; + double totvolume = getTotalVolume(); + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + Klk = mVector.get(i, 0) * mVector.get(j, 0) / totvolume * delta[i][j]; + KlkMatrix.set(i, j, Klk); + KlkMatrix.set(j, i, Klk); + } } - - /** - *

- * calcXsitedV. - *

- */ - public void calcXsitedV() { - if (totalNumberOfAccociationSites > 0) { - initCPAMatrix(1); + boolean solved = true; + // SimpleMatrix corrMatrix = null; + do { + solved = true; + iter++; + temp = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + ksiMatrix.set(temp + j, 0, ((ComponentCPAInterface) getComponent(i)).getXsite()[j]); + // ksiMatrix.getMatrix().unsafe_set(temp + j, 0, + // ksiMatrix.getMatrix().unsafe_get(temp + j, 0)); + udotMatrix.set(temp + j, 0, 1.0 / ksiMatrix.get(temp + j, 0) - 1.0); + udotTimesmMatrix.set(temp + j, 0, mVector.get(temp + j, 0) * udotMatrix.get(temp + j, 0)); } - } - - /** - *

- * solveX. - *

- * - * @return a boolean - */ - public boolean solveX() { - if (getTotalNumberOfAccociationSites() == 0) { - return true; + temp += getComponent(i).getNumberOfAssociationSites(); + } + + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + int krondelt = 0; + if (i == j) { + krondelt = 1; + } + hessianMatrix.set(i, j, + -mVector.get(i, 0) / (ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0)) * krondelt + - KlkMatrix.get(i, j)); + hessianMatrix.set(j, i, hessianMatrix.get(i, j)); } - - boolean solvedX = solveX2(5); - if (solvedX) { - // return true; + } + + // ksiMatrix = new SimpleMatrix(ksi); + // SimpleMatrix hessianMatrix = new SimpleMatrix(hessian); + try { + hessianInvers = hessianMatrix.invert(); + } catch (Exception e) { + logger.error("error", e); + return false; + } + + CommonOps_DDRM.mult(mat1, mat2, corr2Matrix); + CommonOps_DDRM.subtract(udotTimesmMatrix.getDDRM(), corr2Matrix, corr3Matrix); + CommonOps_DDRM.mult(hessianInvers.getDDRM(), corr3Matrix, corr4Matrix); + // SimpleMatrix gMatrix = udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)); + // corrMatrix = + // hessianInvers.mult(udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)));//.scale(-1.0); + temp = 0; + // System.out.println("print SimpleMatrix ..."); + // corrMatrix.print(10, 10); + // SimpleMatrix simp = new SimpleMatrix(corr4Matrix); + // System.out.println("print CommonOps ..."); + // simp.print(10,10); + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + double newX = ksiMatrix.get(temp + j, 0) - corr4Matrix.unsafe_get((temp + j), 0); + if (newX < 0) { + newX = 1e-10; + solved = false; + } + ((ComponentCPAInterface) getComponent(i)).setXsite(j, newX); } - - DMatrixRMaj mat1 = KlkMatrix.getMatrix(); - DMatrixRMaj mat2 = ksiMatrix.getMatrix(); - // second order method not working correctly and not used t the moment b ecause of numerical - // stability - int temp = 0, iter = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - mVector.set(temp + j, 0, getComponent(i).getNumberOfMolesInPhase()); - } - temp += getComponent(i).getNumberOfAssociationSites(); + temp += getComponent(i).getNumberOfAssociationSites(); + } + // System.out.println("corrmatrix error " ); + // System.out.println("error " + corrMatrix.norm1()); + } while ((NormOps_DDRM.normF(corr4Matrix) > 1e-12 || !solved) && iter < 100); + + // System.out.println("iter " + iter + " error " + NormOps.normF(corr4Matrix)); + // // corrMatrix.print(10, 10); + // ksiMatrix.print(10, 10); + return true; + } + + /** + *

+ * solveX2. + *

+ * + * @param maxIter a int + * @return a boolean + */ + public boolean solveX2(int maxIter) { + double err = .0; + int iter = 0; + // if (delta == null) { + // initCPAMatrix(1); + double old = 0.0; + double neeval = 0.0; + // } + do { + iter++; + err = 0.0; + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + old = + ((ComponentCPAInterface) getComponent(moleculeNumber[i])).getXsite()[assSiteNumber[i]]; + neeval = 0; + for (int j = 0; j < getTotalNumberOfAccociationSites(); j++) { + neeval += getComponent(moleculeNumber[j]).getNumberOfMolesInPhase() * delta[i][j] + * ((ComponentCPAInterface) getComponent(moleculeNumber[j])) + .getXsite()[assSiteNumber[j]]; } - double Klk = 0.0; - double totvolume = getTotalVolume(); - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - Klk = mVector.get(i, 0) * mVector.get(j, 0) / totvolume * delta[i][j]; - KlkMatrix.set(i, j, Klk); - KlkMatrix.set(j, i, Klk); - } + neeval = 1.0 / (1.0 + 1.0 / getTotalVolume() * neeval); + ((ComponentCPAInterface) getComponent(moleculeNumber[i])).setXsite(assSiteNumber[i], + neeval); + err += Math.abs((old - neeval) / neeval); + } + } while (Math.abs(err) > 1e-10 && iter < maxIter); + // System.out.println("iter " + iter); + // if (Math.abs(err) + // < 1e-12) { + // return true; + // } else { + // System.out.println("did not solve for Xi in iterations: " + iter); + // System.out.println("error: " + err); + return false; + } + + /** {@inheritDoc} */ + @Override + public double getHcpatot() { + return hcpatot; + } + + /** + * Setter for property hcpatot. + * + * @param hcpatot New value of property hcpatot. + */ + public void setHcpatot(double hcpatot) { + this.hcpatot = hcpatot; + } + + /** {@inheritDoc} */ + @Override + public double getGcpa() { + return gcpa; + } + + /** + *

+ * calcRootVolFinder. + *

+ * + * @param phase a int + * @return a double + */ + public double calcRootVolFinder(int phase) { + double solvedBonVHigh = 0.0; + double solvedBonVlow = 1.0; + double oldh = 1; + // double[][] matrix = new double[2][2000]; + double BonV = 1.0 - 1e-10; + try { + // molarVolume(pressure, temperature, A, B, phaseType); + } catch (Exception e) { + logger.error("error", e); + } + double BonVold = BonV; + double Btemp = 0; + double h = 1; + Btemp = getB(); + getA(); + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + for (int i = 0; i < 2000; i++) { + BonVold = BonV; + BonV = 1.0 - (i + 1e-6) * 1.0 / 2000.0; + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); + gcpa = calc_g(); + // lngcpa = + // Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); + volInit(); + do { + } while (!solveX()); + + h = BonV - Btemp / numberOfMolesInPhase * dFdV() + - pressure * Btemp / (numberOfMolesInPhase * R * temperature); + + if (Math.signum(h) * Math.signum(oldh) < 0 && i > 2) { + if (solvedBonVlow < 1e-3) { + solvedBonVlow = (BonV + BonVold) / 2.0; + if (phase == 1) { + break; + } + } else { + solvedBonVHigh = (BonV + BonVold) / 2.0; + if (phase == 0) { + break; + } } - boolean solved = true; - // SimpleMatrix corrMatrix = null; - do { - solved = true; - iter++; - temp = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - ksiMatrix.set(temp + j, 0, - ((ComponentCPAInterface) getComponent(i)).getXsite()[j]); - // ksiMatrix.getMatrix().unsafe_set(temp + j, 0, - // ksiMatrix.getMatrix().unsafe_get(temp + j, 0)); - udotMatrix.set(temp + j, 0, 1.0 / ksiMatrix.get(temp + j, 0) - 1.0); - udotTimesmMatrix.set(temp + j, 0, - mVector.get(temp + j, 0) * udotMatrix.get(temp + j, 0)); - } - temp += getComponent(i).getNumberOfAssociationSites(); - } - - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - int krondelt = 0; - if (i == j) { - krondelt = 1; - } - hessianMatrix.set(i, j, - -mVector.get(i, 0) / (ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0)) - * krondelt - KlkMatrix.get(i, j)); - hessianMatrix.set(j, i, hessianMatrix.get(i, j)); - } - } - - // ksiMatrix = new SimpleMatrix(ksi); - // SimpleMatrix hessianMatrix = new SimpleMatrix(hessian); - try { - hessianInvers = hessianMatrix.invert(); - } catch (Exception e) { - logger.error("error", e); - return false; - } - - CommonOps_DDRM.mult(mat1, mat2, corr2Matrix); - CommonOps_DDRM.subtract(udotTimesmMatrix.getDDRM(), corr2Matrix, corr3Matrix); - CommonOps_DDRM.mult(hessianInvers.getDDRM(), corr3Matrix, corr4Matrix); - // SimpleMatrix gMatrix = udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)); - // corrMatrix = - // hessianInvers.mult(udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)));//.scale(-1.0); - temp = 0; - // System.out.println("print SimpleMatrix ..."); - // corrMatrix.print(10, 10); - // SimpleMatrix simp = new SimpleMatrix(corr4Matrix); - // System.out.println("print CommonOps ..."); - // simp.print(10,10); - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - double newX = - ksiMatrix.get(temp + j, 0) - corr4Matrix.unsafe_get((temp + j), 0); - if (newX < 0) { - newX = 1e-10; - solved = false; - } - ((ComponentCPAInterface) getComponent(i)).setXsite(j, newX); - } - temp += getComponent(i).getNumberOfAssociationSites(); - } - // System.out.println("corrmatrix error " ); - // System.out.println("error " + corrMatrix.norm1()); - } while ((NormOps_DDRM.normF(corr4Matrix) > 1e-12 || !solved) && iter < 100); - - // System.out.println("iter " + iter + " error " + NormOps.normF(corr4Matrix)); - // // corrMatrix.print(10, 10); - // ksiMatrix.print(10, 10); - return true; + } + solvedBonVHigh = (BonV + BonVold) / 2.0; + oldh = h; + // matrix[0][i] = BonV; + // matrix[1][i] = h; } - - /** - *

- * solveX2. - *

- * - * @param maxIter a int - * @return a boolean - */ - public boolean solveX2(int maxIter) { - double err = .0; - int iter = 0; - // if (delta == null) { - // initCPAMatrix(1); - double old = 0.0, neeval = 0.0; - // } - do { - iter++; - err = 0.0; - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - old = ((ComponentCPAInterface) getComponent(moleculeNumber[i])) - .getXsite()[assSiteNumber[i]]; - neeval = 0; - for (int j = 0; j < getTotalNumberOfAccociationSites(); j++) { - neeval += - getComponent(moleculeNumber[j]).getNumberOfMolesInPhase() * delta[i][j] - * ((ComponentCPAInterface) getComponent(moleculeNumber[j])) - .getXsite()[assSiteNumber[j]]; - } - neeval = 1.0 / (1.0 + 1.0 / getTotalVolume() * neeval); - ((ComponentCPAInterface) getComponent(moleculeNumber[i])).setXsite(assSiteNumber[i], - neeval); - err += Math.abs((old - neeval) / neeval); - } - } while (Math.abs(err) > 1e-10 && iter < maxIter); - // System.out.println("iter " + iter); - // if (Math.abs(err) - // < 1e-12) { - // return true; - // } else { - // System.out.println("did not solve for Xi in iterations: " + iter); - // System.out.println("error: " + err); - return false; + if (solvedBonVlow < 1e-3) { + solvedBonVlow = solvedBonVHigh; } - - /** {@inheritDoc} */ - @Override - public double getHcpatot() { - return hcpatot; + // dataPresentation.fileHandeling.createTextFile.TextFile file = new + // dataPresentation.fileHandeling.createTextFile.TextFile(); + // file.setValues(matrix); + // file.setOutputFileName("D:/temp/temp2.txt"); + // file.createFile(); + if (phase == 1) { + return solvedBonVlow; + } else { + return solvedBonVHigh; } - - /** - * Setter for property hcpatot. - * - * @param hcpatot New value of property hcpatot. - */ - public void setHcpatot(double hcpatot) { - this.hcpatot = hcpatot; + } + + /** {@inheritDoc} */ + @Override + public double molarVolume2(double pressure, double temperature, double A, double B, int phasetype) + throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + if (BonV < 0) { + BonV = 1.0e-8; } - /** {@inheritDoc} */ - @Override - public double getGcpa() { - return gcpa; + if (BonV > 1.1) { + BonV = 1.1; } - - /** - *

- * calcRootVolFinder. - *

- * - * @param phase a int - * @return a double - */ - public double calcRootVolFinder(int phase) { - double solvedBonVHigh = 0.0; - double solvedBonVlow = 1.0; - double oldh = 1; - // double[][] matrix = new double[2][2000]; - double BonV = 1.0 - 1e-10; - try { - // molarVolume(pressure, temperature, A, B, phaseType); - } catch (Exception e) { - logger.error("error", e); - } - double BonVold = BonV; - double Btemp = 0, h = 1; - // double Dtemp = 0, dh = 0, gvvv = 0, fvvv = 0, dhh = 0; - // double d1 = 0, d2 = 0; - Btemp = getB(); - // Dtemp = getA(); - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - for (int i = 0; i < 2000; i++) { - BonVold = BonV; - BonV = 1.0 - (i + 1e-6) * 1.0 / 2000.0; - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - gcpa = calc_g(); - // lngcpa = - // Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - volInit(); - do { - } while (!solveX()); - - h = BonV - Btemp / numberOfMolesInPhase * dFdV() - - pressure * Btemp / (numberOfMolesInPhase * R * temperature); - - if (Math.signum(h) * Math.signum(oldh) < 0 && i > 2) { - if (solvedBonVlow < 1e-3) { - solvedBonVlow = (BonV + BonVold) / 2.0; - if (phase == 1) { - break; - } - } else { - solvedBonVHigh = (BonV + BonVold) / 2.0; - if (phase == 0) { - break; - } - } - } - solvedBonVHigh = (BonV + BonVold) / 2.0; - oldh = h; - // matrix[0][i] = BonV; - // matrix[1][i] = h; - } - if (solvedBonVlow < 1e-3) { - solvedBonVlow = solvedBonVHigh; - } - // dataPresentation.fileHandeling.createTextFile.TextFile file = new - // dataPresentation.fileHandeling.createTextFile.TextFile(); - // file.setValues(matrix); - // file.setOutputFileName("D:/temp/temp2.txt"); - // file.createFile(); - if (phase == 1) { - return solvedBonVlow; - } else { - return solvedBonVHigh; - } + double BonVold = BonV; + double Btemp = 0; + double h = 0; + double dh = 0; + double dhh = 0; + double d1 = 0; + double d2 = 0; + Btemp = getB(); + if (Btemp < 0) { + logger.info("b negative in volume calc"); } + calcDelta(); - /** {@inheritDoc} */ - @Override - public double molarVolume2(double pressure, double temperature, double A, double B, - int phasetype) throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - // double[][] calcRootVolFinder = calcRootVolFinder(); - // double BonVInit = BonV; - if (BonV < 0) { - BonV = 1.0e-8; - } + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + int iterations = 0; - if (BonV > 1.1) { - BonV = 1.1; + do { + volInit(); + iterations++; + gcpa = calc_g(); + if (gcpa < 0) { + setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); + gcpa = calc_g(); + } + + // double lngcpa = Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); + + solveX(); + + hcpatot = calc_hCPA(); + + initCPAMatrix(1); + volInit(); + double BonV2 = BonV * BonV; + BonVold = BonV; + h = BonV - Btemp / numberOfMolesInPhase * dFdV() + - pressure * Btemp / (numberOfMolesInPhase * R * temperature); + dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); + dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) + - (Btemp * Btemp) / (BonV2 * BonV2) * (Btemp / numberOfMolesInPhase * dFdVdVdV()); + + d1 = -h / dh; + d2 = -dh / dhh; + // System.out.println("d1" + d1 + " d2 " + d2 + " d1 / d2 " + (d1 / d2)); + if (Math.abs(d1 / d2) <= 1.0) { + BonV += d1 * (1.0 + 0.5 * d1 / d2); + } else if (d1 / d2 < -1) { + BonV += 0.5 * d1; + } else if (d1 > d2) { + BonV += d2; + double hnew = h + d2 * dh; + if (Math.abs(hnew) > Math.abs(h)) { + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); } - double BonVold = BonV; - double Btemp = 0, h = 0, dh = 0, dhh = 0; - // double gvvv = 0, fvvv = 0; - double d1 = 0, d2 = 0; - Btemp = getB(); - if (Btemp < 0) { - logger.info("b negative in volume calc"); + } else { + BonV += 0.5 * d1; + } + if (Math.abs((BonV - BonVold) / BonVold) > 0.1) { + BonV = BonVold + 0.1 * (BonV - BonVold); + } + + if (BonV > 1.1) { + if (iterations < 3) { + BonV = (BonVold + BonV) / 2.0; + } else { + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); } - calcDelta(); - - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - int iterations = 0; - - do { - volInit(); - iterations++; - gcpa = calc_g(); - if (gcpa < 0) { - setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); - gcpa = calc_g(); - } - - // double lngcpa = Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - - solveX(); - - hcpatot = calc_hCPA(); - - initCPAMatrix(1); - volInit(); - double BonV2 = BonV * BonV; - BonVold = BonV; - h = BonV - Btemp / numberOfMolesInPhase * dFdV() - - pressure * Btemp / (numberOfMolesInPhase * R * temperature); - dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); - dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) - - (Btemp * Btemp) / (BonV2 * BonV2) - * (Btemp / numberOfMolesInPhase * dFdVdVdV()); - - d1 = -h / dh; - d2 = -dh / dhh; - // System.out.println("d1" + d1 + " d2 " + d2 + " d1 / d2 " + (d1 / d2)); - if (Math.abs(d1 / d2) <= 1.0) { - BonV += d1 * (1.0 + 0.5 * d1 / d2); - } else if (d1 / d2 < -1) { - BonV += 0.5 * d1; - } else if (d1 > d2) { - BonV += d2; - double hnew = h + d2 * dh; - if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } else { - BonV += 0.5 * d1; - } - if (Math.abs((BonV - BonVold) / BonVold) > 0.1) { - BonV = BonVold + 0.1 * (BonV - BonVold); - } + } - if (BonV > 1.1) { - if (iterations < 3) { - BonV = (BonVold + BonV) / 2.0; - } else { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } - - if (BonV < 0) { - if (iterations < 3) { - BonV = Math.abs(BonVold + BonV) / 2.0; - } else { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } - - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - - // System.out.println("Z" + Z); - } while (Math.abs((BonV - BonVold) / BonV) > 1.0e-10 && iterations < 100); - // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); - // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); - // System.out.println("volume " + getTotalVolume() + " molar volume " + - // getMolarVolume()); - // if(iterations>=100) throw new util.exception.TooManyIterationsException(); - // System.out.println("error in volume " + - // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " - // firstterm " + (R*temperature/molarVolume) + " second " + - // R*temperature*dFdV()); - - if (Double.isNaN(getMolarVolume())) { - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " - // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" - // + fVV()); - throw new neqsim.util.exception.IsNaNException(this, "molarVolume2", "Molar volume"); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " - // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" - // + fVV()); + if (BonV < 0) { + if (iterations < 3) { + BonV = Math.abs(BonVold + BonV) / 2.0; + } else { + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); } - - return getMolarVolume(); + } + + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); + + // System.out.println("Z" + Z); + } while (Math.abs((BonV - BonVold) / BonV) > 1.0e-10 && iterations < 100); + // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); + // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); + // System.out.println("volume " + getTotalVolume() + " molar volume " + + // getMolarVolume()); + // if(iterations>=100) throw new util.exception.TooManyIterationsException(); + // System.out.println("error in volume " + + // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " + // firstterm " + (R*temperature/molarVolume) + " second " + + // R*temperature*dFdV()); + + if (Double.isNaN(getMolarVolume())) { + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " + // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + // + fVV()); + throw new neqsim.util.exception.IsNaNException(this, "molarVolume2", "Molar volume"); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " + // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + // + fVV()); } - /** {@inheritDoc} */ - @Override - public double molarVolume(double pressure, double temperature, double A, double B, - int phasetype) throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - // if (pressure > 1000) { - // BonV = 0.9999; - // } - - // double calcRooBonVtVolFinder = calcRootVolFinder(phasetype); - // BonV = calcRooBonVtVolFinder; - // double BonVInit = BonV; - if (BonV <= 0) { - BonV = 1.0e-8; - } - else if (BonV >= 1.0) { - BonV = 0.9999; - } - double BonVold; - double h = 0, dh = 0, dhh = 0; - double d1 = 0, d2 = 0; - double Btemp = getB(); - if (Btemp < 0) { - logger.info("b negative in volume calc"); - } - calcDelta(); - - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - int iterations = 0; - - do { - iterations++; - volInit(); - gcpa = calc_g(); - if (gcpa < 0) { - setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); - gcpa = calc_g(); - } - - // lngcpa = - // Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - - if (getTotalNumberOfAccociationSites() > 0) { - solveX(); - } + return getMolarVolume(); + } + + /** {@inheritDoc} */ + @Override + public double molarVolume(double pressure, double temperature, double A, double B, int phasetype) + throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + // if (pressure > 1000) { + // BonV = 0.9999; + // } + + // double calcRooBonVtVolFinder = calcRootVolFinder(phasetype); + // BonV = calcRooBonVtVolFinder; + // double BonVInit = BonV; + if (BonV <= 0) { + BonV = 1.0e-8; + } else if (BonV >= 1.0) { + BonV = 0.9999; + } + double BonVold; + double h = 0; + double dh = 0; + double dhh = 0; + double d1 = 0; + double d2 = 0; + double Btemp = getB(); + if (Btemp < 0) { + logger.info("b negative in volume calc"); + } + calcDelta(); - initCPAMatrix(1); - double BonV2 = BonV * BonV; - BonVold = BonV; - h = BonV - Btemp / numberOfMolesInPhase * dFdV() - - pressure * Btemp / (numberOfMolesInPhase * R * temperature); - dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); - dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) - - (Btemp * Btemp) / (BonV2 * BonV2) - * (Btemp / numberOfMolesInPhase * dFdVdVdV()); - - d1 = -h / dh; - d2 = -dh / dhh; - // System.out.println("h " + h + " iter " + iterations + " " + d1 + " d2 " + d2 - // + " d1 / d2 " + (d1 / d2)); - if (Math.abs(d1 / d2) <= 1.0) { - BonV += d1 * (1.0 + 0.5 * d1 / d2); - } else if (d1 / d2 < -1) { - BonV += 0.5 * d1; - } else if (d1 > d2) { - BonV += d2; - double hnew = h + d2 * dh; - if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } else { - BonV += 0.5 * d1; - } - if (Math.abs((BonV - BonVold) / BonVold) > 0.1) { - BonV = BonVold + 0.1 * (BonV - BonVold); - } + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + int iterations = 0; - if (BonV > 0.9999) { - if (iterations < 3) { - BonV = (BonVold + BonV) / 2.0; - } else { - return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - // BonV = 0.9999; - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / - // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * - // temperature * R); - } - } else if (BonV < 0) { - if (iterations < 3) { - BonV = Math.abs(BonVold + BonV) / 2.0; - } else { - return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / - // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * - // temperature * R); - } - } - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10 || Math.abs(h) > 1e-9) - && iterations < 100); - - if (Math.abs(h) > 1e-9) { - // System.out.println("h failed " + "Z" + Z + " iterations " + iterations + " - // BonV " + BonV); - return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - } - // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); - // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); - // System.out.println("volume " + getTotalVolume() + " molar volume " + - // getMolarVolume()); - // if(iterations>=100) throw new util.exception.TooManyIterationsException(); - // System.out.println("error in volume " + - // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " - // firstterm " + (R*temperature/molarVolume) + " second " + - // R*temperature*dFdV()); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + " B - // " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); - - if (Double.isNaN(getMolarVolume())) { - throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " - // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" - // + fVV()); - } - return getMolarVolume(); - } + do { + iterations++; + volInit(); + gcpa = calc_g(); + if (gcpa < 0) { + setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); + gcpa = calc_g(); + } - /** - *

- * molarVolumeChangePhase. - *

- * - * @param pressure a double - * @param temperature a double - * @param A a double - * @param B a double - * @param phasetype a int - * @return a double - * @throws neqsim.util.exception.IsNaNException if any. - * @throws neqsim.util.exception.TooManyIterationsException if any. - */ - public double molarVolumeChangePhase(double pressure, double temperature, double A, double B, - int phasetype) throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - // double BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / - // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * - // temperature * R); - double BonV = calcRootVolFinder(phasetype); - // double BonVInit = BonV; - if (BonV < 0) { - BonV = 1.0e-8; - } + // lngcpa = + // Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); - if (BonV >= 1.0) { - BonV = 0.9999; + if (getTotalNumberOfAccociationSites() > 0) { + solveX(); + } + + initCPAMatrix(1); + double BonV2 = BonV * BonV; + BonVold = BonV; + h = BonV - Btemp / numberOfMolesInPhase * dFdV() + - pressure * Btemp / (numberOfMolesInPhase * R * temperature); + dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); + dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) + - (Btemp * Btemp) / (BonV2 * BonV2) * (Btemp / numberOfMolesInPhase * dFdVdVdV()); + + d1 = -h / dh; + d2 = -dh / dhh; + // System.out.println("h " + h + " iter " + iterations + " " + d1 + " d2 " + d2 + // + " d1 / d2 " + (d1 / d2)); + if (Math.abs(d1 / d2) <= 1.0) { + BonV += d1 * (1.0 + 0.5 * d1 / d2); + } else if (d1 / d2 < -1) { + BonV += 0.5 * d1; + } else if (d1 > d2) { + BonV += d2; + double hnew = h + d2 * dh; + if (Math.abs(hnew) > Math.abs(h)) { + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); } - double BonVold = BonV; - double Btemp = 0, h = 0, dh = 0, dhh = 0; - // double gvvv = 0, fvvv = 0; - double d1 = 0, d2 = 0; - Btemp = getB(); - if (Btemp < 0) { - logger.info("b negative in volume calc"); + } else { + BonV += 0.5 * d1; + } + if (Math.abs((BonV - BonVold) / BonVold) > 0.1) { + BonV = BonVold + 0.1 * (BonV - BonVold); + } + + if (BonV > 0.9999) { + if (iterations < 3) { + BonV = (BonVold + BonV) / 2.0; + } else { + return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // BonV = 0.9999; + // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * + // temperature * R); } - calcDelta(); - - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - int iterations = 0; - - do { - volInit(); - iterations++; - gcpa = calc_g(); - if (gcpa < 0) { - setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); - gcpa = calc_g(); - } - - // lngcpa = - // Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - - solveX(); - - initCPAMatrix(1); - double BonV2 = BonV * BonV; - BonVold = BonV; - h = BonV - Btemp / numberOfMolesInPhase * dFdV() - - pressure * Btemp / (numberOfMolesInPhase * R * temperature); - dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); - dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) - - (Btemp * Btemp) / (BonV2 * BonV2) - * (Btemp / numberOfMolesInPhase * dFdVdVdV()); - - d1 = -h / dh; - d2 = -dh / dhh; - // System.out.println("d1" + d1 + " d2 " + d2 + " d1 / d2 " + (d1 / d2)); - if (Math.abs(d1 / d2) <= 1.0) { - BonV += d1 * (1.0 + 0.5 * d1 / d2); - } else if (d1 / d2 < -1) { - BonV += 0.5 * d1; - } else if (d1 > d2) { - BonV += d2; - double hnew = h + d2 * dh; - if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } else { - BonV += 0.5 * d1; - } - if (Math.abs((BonV - BonVold) / BonVold) > 0.1) { - BonV = BonVold + 0.1 * (BonV - BonVold); - } - - if (BonV > 1.1) { - if (iterations < 3) { - BonV = (BonVold + BonV) / 2.0; - } else { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } - - if (BonV < 0) { - if (iterations < 3) { - BonV = Math.abs(BonVold + BonV) / 2.0; - } else { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } - - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - - // System.out.println("Z " + Z + "h " + h + " BONV " + (Math.abs((BonV - - // BonVold) / BonV))); - } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10) && iterations < 100); - - /* - * if (Math.abs(h) > 1e-8) { if (phasetype == 0) { molarVolume(pressure, temperature, A, B, - * 1); } else { molarVolume(pressure, temperature, A, B, 0); } return getMolarVolume(); } - */ - // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); - // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); - // System.out.println("volume " + getTotalVolume() + " molar volume " + - // getMolarVolume()); - // if(iterations>=100) throw new util.exception.TooManyIterationsException(); - // System.out.println("error in volume " + - // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " - // firstterm " + (R*temperature/molarVolume) + " second " + - // R*temperature*dFdV()); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + " B - // " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); - if (Double.isNaN(getMolarVolume())) { - throw new neqsim.util.exception.IsNaNException(this, "molarVolumeChangePhase", - "Molar volume"); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " - // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" - // + fVV()); + } else if (BonV < 0) { + if (iterations < 3) { + BonV = Math.abs(BonVold + BonV) / 2.0; + } else { + return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * + // temperature * R); } - - return getMolarVolume(); + } + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); + } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10 || Math.abs(h) > 1e-9) + && iterations < 100); + + if (Math.abs(h) > 1e-9) { + // System.out.println("h failed " + "Z" + Z + " iterations " + iterations + " + // BonV " + BonV); + return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); } - - /** {@inheritDoc} */ - @Override - public double getGcpav() { - return gcpav; + // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); + // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); + // System.out.println("volume " + getTotalVolume() + " molar volume " + + // getMolarVolume()); + // if(iterations>=100) throw new util.exception.TooManyIterationsException(); + // System.out.println("error in volume " + + // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " + // firstterm " + (R*temperature/molarVolume) + " second " + + // R*temperature*dFdV()); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + " B + // " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); + + if (Double.isNaN(getMolarVolume())) { + throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " + // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + // + fVV()); } - - /** - *

- * Setter for the field gcpav. - *

- * - * @param gcpav a double - */ - public void setGcpav(double gcpav) { - this.gcpav = gcpav; + return getMolarVolume(); + } + + /** + *

+ * molarVolumeChangePhase. + *

+ * + * @param pressure a double + * @param temperature a double + * @param A a double + * @param B a double + * @param phasetype a int + * @return a double + * @throws neqsim.util.exception.IsNaNException if any. + * @throws neqsim.util.exception.TooManyIterationsException if any. + */ + public double molarVolumeChangePhase(double pressure, double temperature, double A, double B, + int phasetype) throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + // double BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * + // temperature * R); + double BonV = calcRootVolFinder(phasetype); + // double BonVInit = BonV; + if (BonV < 0) { + BonV = 1.0e-8; } - /** {@inheritDoc} */ - @Override - public CPAMixingInterface getCpamix() { - return cpamix; + if (BonV >= 1.0) { + BonV = 0.9999; } - - /** {@inheritDoc} */ - @Override - public double calcPressure() { - gcpa = calc_g(); - // lngcpa = - // Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - solveX(); - hcpatot = calc_hCPA(); - - initCPAMatrix(1); - return super.calcPressure(); + double BonVold = BonV; + double Btemp = 0; + double h = 0; + double dh = 0; + double dhh = 0; + double d1 = 0; + double d2 = 0; + Btemp = getB(); + if (Btemp < 0) { + logger.info("b negative in volume calc"); } + calcDelta(); + + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + int iterations = 0; - /** {@inheritDoc} */ - @Override - public int getCrossAssosiationScheme(int comp1, int comp2, int site1, int site2) { - if (comp1 == comp2) { - return selfAccociationScheme[comp1][site1][site2]; + do { + volInit(); + iterations++; + gcpa = calc_g(); + if (gcpa < 0) { + setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); + gcpa = calc_g(); + } + + // lngcpa = + // Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); + + solveX(); + + initCPAMatrix(1); + double BonV2 = BonV * BonV; + BonVold = BonV; + h = BonV - Btemp / numberOfMolesInPhase * dFdV() + - pressure * Btemp / (numberOfMolesInPhase * R * temperature); + dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); + dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) + - (Btemp * Btemp) / (BonV2 * BonV2) * (Btemp / numberOfMolesInPhase * dFdVdVdV()); + + d1 = -h / dh; + d2 = -dh / dhh; + // System.out.println("d1" + d1 + " d2 " + d2 + " d1 / d2 " + (d1 / d2)); + if (Math.abs(d1 / d2) <= 1.0) { + BonV += d1 * (1.0 + 0.5 * d1 / d2); + } else if (d1 / d2 < -1) { + BonV += 0.5 * d1; + } else if (d1 > d2) { + BonV += d2; + double hnew = h + d2 * dh; + if (Math.abs(hnew) > Math.abs(h)) { + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + } + } else { + BonV += 0.5 * d1; + } + if (Math.abs((BonV - BonVold) / BonVold) > 0.1) { + BonV = BonVold + 0.1 * (BonV - BonVold); + } + + if (BonV > 1.1) { + if (iterations < 3) { + BonV = (BonVold + BonV) / 2.0; } else { - return crossAccociationScheme[comp1][comp2][site1][site2]; + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); } - } + } - /** - *

- * croeneckerProduct. - *

- * - * @param a an array of {@link double} objects - * @param b an array of {@link double} objects - * @return an array of {@link double} objects - */ - public double[][] croeneckerProduct(double[][] a, double[][] b) { - int aLength = a.length; - int aCols = a[0].length; - int bLength = b.length; - int bCols = b[0].length; - double[][] result = new double[aLength * bLength][(aCols) * (bCols)]; - for (int z = 0; z < aLength; z++) { - for (int i = 0; i < aCols; i++) { - for (int j = 0; j < bLength; j++) { - for (int k = 0; k < bCols; k++) { - result[j + (z * bLength)][k + (i * bCols)] = a[z][i] * b[j][k]; - } - } - } + if (BonV < 0) { + if (iterations < 3) { + BonV = Math.abs(BonVold + BonV) / 2.0; + } else { + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); } - return result; - } + } - /** {@inheritDoc} */ - @Override - public int getTotalNumberOfAccociationSites() { - return totalNumberOfAccociationSites; - } + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); - /** {@inheritDoc} */ - @Override - public void setTotalNumberOfAccociationSites(int totalNumberOfAccociationSites) { - this.totalNumberOfAccociationSites = totalNumberOfAccociationSites; - } + // System.out.println("Z " + Z + "h " + h + " BONV " + (Math.abs((BonV - + // BonVold) / BonV))); + } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10) && iterations < 100); - /** - *

- * calc_g. - *

- * - * @return a double + /* + * if (Math.abs(h) > 1e-8) { if (phasetype == 0) { molarVolume(pressure, temperature, A, B, 1); + * } else { molarVolume(pressure, temperature, A, B, 0); } return getMolarVolume(); } */ - public double calc_g() { - double x = 1.9 / 4.0 * getB() / getTotalVolume(); - double g = 1.0 / (1.0 - x); - // System.out.println("g " + g); - return g; + // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); + // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); + // System.out.println("volume " + getTotalVolume() + " molar volume " + + // getMolarVolume()); + // if(iterations>=100) throw new util.exception.TooManyIterationsException(); + // System.out.println("error in volume " + + // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " + // firstterm " + (R*temperature/molarVolume) + " second " + + // R*temperature*dFdV()); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + " B + // " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); + if (Double.isNaN(getMolarVolume())) { + throw new neqsim.util.exception.IsNaNException(this, "molarVolumeChangePhase", + "Molar volume"); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " + // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + // + fVV()); } - /** - *

- * calc_lngV. - *

- * - * @return a double - */ - public double calc_lngV() { - double x = 1.9 / 4.0 * getB() / getTotalVolume(); - double gv = (x / getTotalVolume()) / (1.0 - x); - return -gv; + return getMolarVolume(); + } + + /** {@inheritDoc} */ + @Override + public double getGcpav() { + return gcpav; + } + + /** + *

+ * Setter for the field gcpav. + *

+ * + * @param gcpav a double + */ + public void setGcpav(double gcpav) { + this.gcpav = gcpav; + } + + /** {@inheritDoc} */ + @Override + public CPAMixingInterface getCpamix() { + return cpamix; + } + + /** {@inheritDoc} */ + @Override + public double calcPressure() { + gcpa = calc_g(); + // lngcpa = + // Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); + solveX(); + hcpatot = calc_hCPA(); + + initCPAMatrix(1); + return super.calcPressure(); + } + + /** {@inheritDoc} */ + @Override + public int getCrossAssosiationScheme(int comp1, int comp2, int site1, int site2) { + if (comp1 == comp2) { + return selfAccociationScheme[comp1][site1][site2]; + } else { + return crossAccociationScheme[comp1][comp2][site1][site2]; } - - /** - *

- * calc_lngVV. - *

- * - * @return a double - */ - public double calc_lngVV() { - double x = 1.9 / 4.0 * getB() / getTotalVolume(); - double xV = -1.9 / 4.0 * getB() / (getTotalVolume() * getTotalVolume()); - double u = 1.0 - x; - - double val = -x / (getTotalVolume() * getTotalVolume() * u) + xV / (getTotalVolume() * u) - - x / (getTotalVolume() * u * u) * (-1.0) * xV; - return -val; - - // double gvv - // =0.225625/Math.pow(1.0-0.475*getB()/getTotalVolume(),2.0)*Math.pow(getB(),2.0)/(Math.pow(getTotalVolume(),4.0))+0.95/(1.0-0.475*getB()/getTotalVolume())*getB()/(Math.pow(getTotalVolume(),3.0)); - // System.out.println("val2 " + gvv); - // return gvv; - } - - /** - *

- * calc_lngVVV. - *

- * - * @return a double - */ - public double calc_lngVVV() { - double totVol = getTotalVolume(); - double totVol4 = totVol * totVol * totVol * totVol; - double totVol5 = totVol4 * totVol; - - double temp1 = 1.0 - 0.475 * getB() / getTotalVolume(); - double gvv = -0.21434375 / (temp1 * temp1 * temp1) * getB() * getB() * getB() - / (totVol5 * totVol) - 0.135375E1 / (temp1 * temp1) * getB() * getB() / (totVol5) - - 0.285E1 / (temp1) * getB() / (totVol4); - return gvv; + } + + /** + *

+ * croeneckerProduct. + *

+ * + * @param a an array of {@link double} objects + * @param b an array of {@link double} objects + * @return an array of {@link double} objects + */ + public double[][] croeneckerProduct(double[][] a, double[][] b) { + int aLength = a.length; + int aCols = a[0].length; + int bLength = b.length; + int bCols = b[0].length; + double[][] result = new double[aLength * bLength][(aCols) * (bCols)]; + for (int z = 0; z < aLength; z++) { + for (int i = 0; i < aCols; i++) { + for (int j = 0; j < bLength; j++) { + for (int k = 0; k < bCols; k++) { + result[j + (z * bLength)][k + (i * bCols)] = a[z][i] * b[j][k]; + } + } + } } + return result; + } + + /** {@inheritDoc} */ + @Override + public int getTotalNumberOfAccociationSites() { + return totalNumberOfAccociationSites; + } + + /** {@inheritDoc} */ + @Override + public void setTotalNumberOfAccociationSites(int totalNumberOfAccociationSites) { + this.totalNumberOfAccociationSites = totalNumberOfAccociationSites; + } + + /** + *

+ * calc_g. + *

+ * + * @return a double + */ + public double calc_g() { + double x = 1.9 / 4.0 * getB() / getTotalVolume(); + double g = 1.0 / (1.0 - x); + // System.out.println("g " + g); + return g; + } + + /** + *

+ * calc_lngV. + *

+ * + * @return a double + */ + public double calc_lngV() { + double x = 1.9 / 4.0 * getB() / getTotalVolume(); + double gv = (x / getTotalVolume()) / (1.0 - x); + return -gv; + } + + /** + *

+ * calc_lngVV. + *

+ * + * @return a double + */ + public double calc_lngVV() { + double x = 1.9 / 4.0 * getB() / getTotalVolume(); + double xV = -1.9 / 4.0 * getB() / (getTotalVolume() * getTotalVolume()); + double u = 1.0 - x; + + double val = -x / (getTotalVolume() * getTotalVolume() * u) + xV / (getTotalVolume() * u) + - x / (getTotalVolume() * u * u) * (-1.0) * xV; + return -val; + + // double gvv + // =0.225625/Math.pow(1.0-0.475*getB()/getTotalVolume(),2.0)*Math.pow(getB(),2.0)/(Math.pow(getTotalVolume(),4.0))+0.95/(1.0-0.475*getB()/getTotalVolume())*getB()/(Math.pow(getTotalVolume(),3.0)); + // System.out.println("val2 " + gvv); + // return gvv; + } + + /** + *

+ * calc_lngVVV. + *

+ * + * @return a double + */ + public double calc_lngVVV() { + double totVol = getTotalVolume(); + double totVol4 = totVol * totVol * totVol * totVol; + double totVol5 = totVol4 * totVol; + + double temp1 = 1.0 - 0.475 * getB() / getTotalVolume(); + double gvv = + -0.21434375 / (temp1 * temp1 * temp1) * getB() * getB() * getB() / (totVol5 * totVol) + - 0.135375E1 / (temp1 * temp1) * getB() * getB() / (totVol5) + - 0.285E1 / (temp1) * getB() / (totVol4); + return gvv; + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/freezingFit/TestSolidComplexFunction.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/freezingFit/TestSolidComplexFunction.java index 3878c7228c..b7e1a820ab 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/freezingFit/TestSolidComplexFunction.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/freezingFit/TestSolidComplexFunction.java @@ -20,58 +20,58 @@ * @version $Id: $Id */ public class TestSolidComplexFunction { - static Logger logger = LogManager.getLogger(TestSolidComplexFunction.class); + static Logger logger = LogManager.getLogger(TestSolidComplexFunction.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); - NeqSimDataBase database = new NeqSimDataBase(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); + NeqSimDataBase database = new NeqSimDataBase(); - ResultSet dataSet = database.getResultSet( - "SELECT * FROM comlexsolidfreezingdata WHERE Component1='TEG' AND Component2='water'"); - // double parameterGuess[] = {0.1640550024};//, 7578.080};//, 245.0}; - double parameterGuess[] = {0.119803125, 4482.0}; + ResultSet dataSet = database.getResultSet( + "SELECT * FROM comlexsolidfreezingdata WHERE Component1='TEG' AND Component2='water'"); + // double parameterGuess[] = {0.1640550024};//, 7578.080};//, 245.0}; + double parameterGuess[] = {0.119803125, 4482.0}; - try { - while (dataSet.next()) { - SolidComplexFunction function = new SolidComplexFunction(); + try { + while (dataSet.next()) { + SolidComplexFunction function = new SolidComplexFunction(); - double x1 = Double.parseDouble(dataSet.getString("x1")) * 100; - double x2 = Double.parseDouble(dataSet.getString("x2")) * 100; - double val = Double.parseDouble(dataSet.getString("temperature")); + double x1 = Double.parseDouble(dataSet.getString("x1")) * 100; + double x2 = Double.parseDouble(dataSet.getString("x2")) * 100; + double val = Double.parseDouble(dataSet.getString("temperature")); - SystemInterface testSystem = new SystemSrkCPAstatoil(val, - Double.parseDouble(dataSet.getString("pressure"))); - testSystem.addComponent(dataSet.getString("Component1"), x1); - testSystem.addComponent(dataSet.getString("Component2"), x2); - // testSystem.createDatabase(true); - testSystem.setMixingRule(10); - testSystem.init(0); - double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; - double standardDeviation1[] = {0.13, 0.1}; + SystemInterface testSystem = + new SystemSrkCPAstatoil(val, Double.parseDouble(dataSet.getString("pressure"))); + testSystem.addComponent(dataSet.getString("Component1"), x1); + testSystem.addComponent(dataSet.getString("Component2"), x2); + // testSystem.createDatabase(true); + testSystem.setMixingRule(10); + testSystem.init(0); + double sample1[] = {testSystem.getPressure(), testSystem.getTemperature()}; + double standardDeviation1[] = {0.13, 0.1}; - SampleValue sample = new SampleValue(val, - Double.parseDouble(dataSet.getString("StandardDeviation")), sample1, - standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(Double.toString(testSystem.getTemperature())); - function.setInitialGuess(parameterGuess); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("error", e); - } - - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); - optim.solve(); + SampleValue sample = + new SampleValue(val, Double.parseDouble(dataSet.getString("StandardDeviation")), + sample1, standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(Double.toString(testSystem.getTemperature())); + function.setInitialGuess(parameterGuess); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("error", e); } + + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); + optim.solve(); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/IonicInteractionParameterFittingFunction_CO2.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/IonicInteractionParameterFittingFunction_CO2.java index 50f335744f..eb0a1f9772 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/IonicInteractionParameterFittingFunction_CO2.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/IonicInteractionParameterFittingFunction_CO2.java @@ -16,337 +16,331 @@ * @version $Id: $Id */ public class IonicInteractionParameterFittingFunction_CO2 extends LevenbergMarquardtFunction { - static Logger logger = LogManager.getLogger(IonicInteractionParameterFittingFunction_CO2.class); + static Logger logger = LogManager.getLogger(IonicInteractionParameterFittingFunction_CO2.class); - /** - *

- * Constructor for IonicInteractionParameterFittingFunction_CO2. - *

- */ - public IonicInteractionParameterFittingFunction_CO2() {} + /** + *

+ * Constructor for IonicInteractionParameterFittingFunction_CO2. + *

+ */ + public IonicInteractionParameterFittingFunction_CO2() {} - /** {@inheritDoc} */ - @Override - public double calcValue(double[] dependentValues) { - try { - thermoOps.bubblePointPressureFlash(false); - } catch (Exception e) { - logger.error(e.toString()); - } - return system.getPressure() * system.getPhases()[0].getComponent(0).getx(); + /** {@inheritDoc} */ + @Override + public double calcValue(double[] dependentValues) { + try { + thermoOps.bubblePointPressureFlash(false); + } catch (Exception e) { + logger.error(e.toString()); } + return system.getPressure() * system.getPhases()[0].getComponent(0).getx(); + } - /** {@inheritDoc} */ - @Override - public double calcTrueValue(double val) { - return val; - } + /** {@inheritDoc} */ + @Override + public double calcTrueValue(double val) { + return val; + } - /** {@inheritDoc} */ - @Override - public void setFittingParams(int i, double value) { - params[i] = value; - int MDEAplusNumb = 0, MDEANumb = 0, CO2Numb = 0, HCO3numb = 0, Waternumb = 0; - int j = 0; - do { - MDEAplusNumb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("MDEA+")); - j = 0; + /** {@inheritDoc} */ + @Override + public void setFittingParams(int i, double value) { + params[i] = value; + int MDEAplusNumb = 0, MDEANumb = 0, CO2Numb = 0, HCO3numb = 0, Waternumb = 0; + int j = 0; + do { + MDEAplusNumb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("MDEA+")); + j = 0; - do { - MDEANumb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("MDEA")); - j = 0; - do { - CO2Numb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("CO2")); - j = 0; + do { + MDEANumb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("MDEA")); + j = 0; + do { + CO2Numb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("CO2")); + j = 0; - do { - HCO3numb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("HCO3-")); - j = 0; - do { - Waternumb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("water")); + do { + HCO3numb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("HCO3-")); + j = 0; + do { + Waternumb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("water")); - if (i == 1) { - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) - .setHVDijParameter(CO2Numb, MDEANumb, value); - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) - .setHVDijParameter(CO2Numb, MDEANumb, value); - } - if (i == 0) { - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) - .setHVDijParameter(MDEANumb, CO2Numb, value); - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) - .setHVDijParameter(MDEANumb, CO2Numb, value); - } - if (i == 2) { - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) - .setHVDijTParameter(CO2Numb, MDEANumb, value); - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) - .setHVDijTParameter(CO2Numb, MDEANumb, value); - } - if (i == 3) { - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) - .setHVDijTParameter(MDEANumb, CO2Numb, value); - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) - .setHVDijTParameter(MDEANumb, CO2Numb, value); - } - if (i == 4) { - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) - .setHValphaParameter(CO2Numb, MDEANumb, value); - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) - .setHValphaParameter(CO2Numb, MDEANumb, value); - } - if (i == 5) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijParameter(MDEAplusNumb, CO2Numb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijParameter(MDEAplusNumb, CO2Numb, value); - } - // if(i==2){ - // ((HVmixingRuleInterface) - // ((PhaseEosInterface)system.getPhases()[0]).getMixingRule()).setHVDijTParameter(CO2Numb,MDEANumb, - // value); - // ((HVmixingRuleInterface) - // ((PhaseEosInterface)system.getPhases()[1]).getMixingRule()).setHVDijTParameter(CO2Numb,MDEANumb, - // value); - // } - // if(i==3){ - // ((HVmixingRuleInterface) - // ((PhaseEosInterface)system.getPhases()[0]).getMixingRule()).setHVDijTParameter(MDEANumb, - // CO2Numb, value); - // ((HVmixingRuleInterface) - // ((PhaseEosInterface)system.getPhases()[1]).getMixingRule()).setHVDijTParameter(MDEANumb, - // CO2Numb, value); - // } + if (i == 1) { + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) + .setHVDijParameter(CO2Numb, MDEANumb, value); + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) + .setHVDijParameter(CO2Numb, MDEANumb, value); + } + if (i == 0) { + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) + .setHVDijParameter(MDEANumb, CO2Numb, value); + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) + .setHVDijParameter(MDEANumb, CO2Numb, value); + } + if (i == 2) { + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) + .setHVDijTParameter(CO2Numb, MDEANumb, value); + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) + .setHVDijTParameter(CO2Numb, MDEANumb, value); + } + if (i == 3) { + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) + .setHVDijTParameter(MDEANumb, CO2Numb, value); + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) + .setHVDijTParameter(MDEANumb, CO2Numb, value); + } + if (i == 4) { + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) + .setHValphaParameter(CO2Numb, MDEANumb, value); + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) + .setHValphaParameter(CO2Numb, MDEANumb, value); + } + if (i == 5) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijParameter(MDEAplusNumb, CO2Numb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijParameter(MDEAplusNumb, CO2Numb, value); + } + // if(i==2){ + // ((HVmixingRuleInterface) + // ((PhaseEosInterface)system.getPhases()[0]).getMixingRule()).setHVDijTParameter(CO2Numb,MDEANumb, + // value); + // ((HVmixingRuleInterface) + // ((PhaseEosInterface)system.getPhases()[1]).getMixingRule()).setHVDijTParameter(CO2Numb,MDEANumb, + // value); + // } + // if(i==3){ + // ((HVmixingRuleInterface) + // ((PhaseEosInterface)system.getPhases()[0]).getMixingRule()).setHVDijTParameter(MDEANumb, + // CO2Numb, value); + // ((HVmixingRuleInterface) + // ((PhaseEosInterface)system.getPhases()[1]).getMixingRule()).setHVDijTParameter(MDEANumb, + // CO2Numb, value); + // } - if (i == 30) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijParameter(MDEAplusNumb, MDEANumb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijParameter(MDEAplusNumb, MDEANumb, value); - } - if (i == 20) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijParameter(MDEAplusNumb, CO2Numb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijParameter(MDEAplusNumb, CO2Numb, value); - } - if (i == 66) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijParameter(MDEAplusNumb, HCO3numb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijParameter(MDEAplusNumb, HCO3numb, value); - } - if (i == 56) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijParameter(MDEAplusNumb, Waternumb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijParameter(MDEAplusNumb, Waternumb, value); - } + if (i == 30) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijParameter(MDEAplusNumb, MDEANumb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijParameter(MDEAplusNumb, MDEANumb, value); + } + if (i == 20) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijParameter(MDEAplusNumb, CO2Numb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijParameter(MDEAplusNumb, CO2Numb, value); + } + if (i == 66) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijParameter(MDEAplusNumb, HCO3numb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijParameter(MDEAplusNumb, HCO3numb, value); + } + if (i == 56) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijParameter(MDEAplusNumb, Waternumb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijParameter(MDEAplusNumb, Waternumb, value); + } - // Temp der 1 - if (i == 30) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, MDEANumb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, MDEANumb, value); - } - if (i == 20) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, CO2Numb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, CO2Numb, value); - } - if (i == 40) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, HCO3numb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, HCO3numb, value); - } - if (i == 50) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, Waternumb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, Waternumb, value); - } + // Temp der 1 + if (i == 30) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, MDEANumb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, MDEANumb, value); + } + if (i == 20) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, CO2Numb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, CO2Numb, value); + } + if (i == 40) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, HCO3numb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, HCO3numb, value); + } + if (i == 50) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, Waternumb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, Waternumb, value); + } - // Temp der 2 - if (i == 60) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, MDEANumb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, MDEANumb, value); - } - if (i == 20) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, CO2Numb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, CO2Numb, value); - } - if (i == 7) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, HCO3numb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, HCO3numb, value); - } - if (i == 8) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, Waternumb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, Waternumb, value); - } + // Temp der 2 + if (i == 60) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, MDEANumb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, MDEANumb, value); + } + if (i == 20) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, CO2Numb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, CO2Numb, value); + } + if (i == 7) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, HCO3numb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, HCO3numb, value); + } + if (i == 8) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, Waternumb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, Waternumb, value); } + } - /** - *

- * setFittingParams5. - *

- * - * @param i a int - * @param value a double - */ - public void setFittingParams5(int i, double value) { - params[i] = value; - int MDEAplusNumb = 0, MDEANumb = 0, CO2Numb = 0, HCO3numb = 0, Waternumb = 0; - int j = 0; - do { - MDEAplusNumb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName() - .equals("MDEAplus")); - j = 0; + /** + *

+ * setFittingParams5. + *

+ * + * @param i a int + * @param value a double + */ + public void setFittingParams5(int i, double value) { + params[i] = value; + int MDEAplusNumb = 0, MDEANumb = 0, CO2Numb = 0, HCO3numb = 0, Waternumb = 0; + int j = 0; + do { + MDEAplusNumb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("MDEAplus")); + j = 0; - do { - MDEANumb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("MDEA")); - j = 0; - do { - CO2Numb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("CO2")); - j = 0; + do { + MDEANumb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("MDEA")); + j = 0; + do { + CO2Numb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("CO2")); + j = 0; - do { - HCO3numb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName() - .equals("HCO3minus")); - j = 0; - do { - Waternumb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("water")); + do { + HCO3numb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("HCO3minus")); + j = 0; + do { + Waternumb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("water")); - // Temp der 1 - if (i == 0) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, MDEANumb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, MDEANumb, value); - } - if (i == 3) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, CO2Numb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, CO2Numb, value); - } - if (i == 1) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, HCO3numb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, HCO3numb, value); - } - if (i == 2) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, Waternumb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, Waternumb, value); - } + // Temp der 1 + if (i == 0) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, MDEANumb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, MDEANumb, value); + } + if (i == 3) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, CO2Numb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, CO2Numb, value); + } + if (i == 1) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, HCO3numb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, HCO3numb, value); + } + if (i == 2) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, Waternumb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, Waternumb, value); + } - // Temp der 2 - if (i == 23) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, MDEANumb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, MDEANumb, value); - } - if (i == 20) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, CO2Numb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, CO2Numb, value); - } - if (i == 4) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, HCO3numb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, HCO3numb, value); - } - if (i == 5) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, Waternumb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, Waternumb, value); - } + // Temp der 2 + if (i == 23) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, MDEANumb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, MDEANumb, value); + } + if (i == 20) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, CO2Numb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, CO2Numb, value); + } + if (i == 4) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, HCO3numb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, HCO3numb, value); } + if (i == 5) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, Waternumb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, Waternumb, value); + } + } - /** - *

- * setFittingParams3. - *

- * - * @param i a int - * @param value a double - */ - public void setFittingParams3(int i, double value) { - params[i] = value; - int MDEAplusNumb = 0, CO2Numb = 0; - // double MDEANumb = 0, HCO3numb = 0, Waternumb = 0; - int j = 0; - do { - MDEAplusNumb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName() - .equals("MDEAplus")); - j = 0; + /** + *

+ * setFittingParams3. + *

+ * + * @param i a int + * @param value a double + */ + public void setFittingParams3(int i, double value) { + params[i] = value; + int MDEAplusNumb = 0, CO2Numb = 0; + int j = 0; + do { + MDEAplusNumb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("MDEAplus")); + j = 0; - do { - // MDEANumb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("MDEA")); - j = 0; - do { - CO2Numb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("CO2")); - j = 0; + do { + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("MDEA")); + j = 0; + do { + CO2Numb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("CO2")); + j = 0; - do { - // HCO3numb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName() - .equals("HCO3minus")); + do { + // HCO3numb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("HCO3minus")); - /* - * j = 0; do { Waternumb = j; j++; } while (!system.getPhases()[0].getComponents()[j - - * 1].getComponentName().equals("water")); - */ + /* + * j = 0; do { Waternumb = j; j++; } while (!system.getPhases()[0].getComponents()[j - + * 1].getComponentName().equals("water")); + */ - if (i == 0) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijParameter(MDEAplusNumb, CO2Numb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijParameter(MDEAplusNumb, CO2Numb, value); - } + if (i == 0) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijParameter(MDEAplusNumb, CO2Numb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijParameter(MDEAplusNumb, CO2Numb, value); } + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/PSFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/PSFlash.java index 553835ecb9..106c041b1f 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/PSFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/PSFlash.java @@ -11,130 +11,127 @@ * @version $Id: $Id */ public class PSFlash extends QfuncFlash { - private static final long serialVersionUID = 1000; - - double Sspec = 0; - Flash tpFlash; - int type = 0; - - /** - *

- * Constructor for PSFlash. - *

- */ - public PSFlash() {} - - /** - *

- * Constructor for PSFlash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param Sspec a double - * @param type a int - */ - public PSFlash(SystemInterface system, double Sspec, int type) { - this.system = system; - this.tpFlash = new TPflash(system); - this.Sspec = Sspec; - this.type = type; + private static final long serialVersionUID = 1000; + + double Sspec = 0; + Flash tpFlash; + int type = 0; + + /** + *

+ * Constructor for PSFlash. + *

+ */ + public PSFlash() {} + + /** + *

+ * Constructor for PSFlash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param Sspec a double + * @param type a int + */ + public PSFlash(SystemInterface system, double Sspec, int type) { + this.system = system; + this.tpFlash = new TPflash(system); + this.Sspec = Sspec; + this.type = type; + } + + /** {@inheritDoc} */ + @Override + public double calcdQdTT() { + if (system.getNumberOfPhases() == 1) { + return -system.getPhase(0).getCp() / system.getTemperature(); } - /** {@inheritDoc} */ - @Override - public double calcdQdTT() { - // double cP1 = 0.0, cP2 = 0.0; - - if (system.getNumberOfPhases() == 1) { - return -system.getPhase(0).getCp() / system.getTemperature(); - } - - double dQdTT = 0.0; - for (int i = 0; i < system.getNumberOfPhases(); i++) { - dQdTT -= system.getPhase(i).getCp() / system.getPhase(i).getTemperature(); - } - return dQdTT; - } - - /** {@inheritDoc} */ - @Override - public double calcdQdT() { - double dQ = -system.getEntropy() + Sspec; - return dQ; + double dQdTT = 0.0; + for (int i = 0; i < system.getNumberOfPhases(); i++) { + dQdTT -= system.getPhase(i).getCp() / system.getPhase(i).getTemperature(); } - - /** {@inheritDoc} */ - @Override - public double solveQ() { - double oldTemp = system.getTemperature(), nyTemp = system.getTemperature(); - int iterations = 1; - double error = 1.0, erorOld = 10.0e10; - double factor = 0.8; - - boolean correctFactor = true; - double newCorr = 1.0; - system.init(2); - - do { - if (error > erorOld && factor > 0.1 && correctFactor) { - factor *= 0.5; - } else if (error < erorOld && correctFactor) { - factor = 1.0; - } - - iterations++; - oldTemp = system.getTemperature(); - - newCorr = factor * calcdQdT() / calcdQdTT(); - nyTemp = oldTemp - newCorr; - if (Math.abs(system.getTemperature() - nyTemp) > 10.0) { - nyTemp = system.getTemperature() - - Math.signum(system.getTemperature() - nyTemp) * 10.0; - correctFactor = false; - } else if (nyTemp < 0) { - nyTemp = Math.abs(system.getTemperature() - 10.0); - correctFactor = false; - } else if (Double.isNaN(nyTemp)) { - nyTemp = oldTemp + 1.0; - correctFactor = false; - } else { - correctFactor = true; - } - - system.setTemperature(nyTemp); - tpFlash.run(); - system.init(2); - erorOld = error; - error = Math.abs(calcdQdT());// Math.abs((nyTemp - oldTemp) / (nyTemp)); - // if(error>erorOld) factor *= -1.0; - // System.out.println("temp " + system.getTemperature() + " iter "+ iterations + - // " error "+ error + " correction " + newCorr + " factor "+ factor); - // newCorr = Math.abs(factor * calcdQdT() / calcdQdTT()); - } while (((error + erorOld) > 1e-8 || iterations < 3) && iterations < 200); - return nyTemp; - } - - /** - *

- * onPhaseSolve. - *

- */ - public void onPhaseSolve() {} - - /** {@inheritDoc} */ - @Override - public void run() { - tpFlash.run(); - - if (type == 0) { - solveQ(); - } else { - sysNewtonRhapsonPHflash secondOrderSolver = new sysNewtonRhapsonPHflash(system, 2, - system.getPhases()[0].getNumberOfComponents(), 1); - secondOrderSolver.setSpec(Sspec); - secondOrderSolver.solve(1); - } - // System.out.println("Entropy: " + system.getEntropy()); - // System.out.println("Temperature: " + system.getTemperature()); + return dQdTT; + } + + /** {@inheritDoc} */ + @Override + public double calcdQdT() { + double dQ = -system.getEntropy() + Sspec; + return dQ; + } + + /** {@inheritDoc} */ + @Override + public double solveQ() { + double oldTemp = system.getTemperature(), nyTemp = system.getTemperature(); + int iterations = 1; + double error = 1.0, erorOld = 10.0e10; + double factor = 0.8; + + boolean correctFactor = true; + double newCorr = 1.0; + system.init(2); + + do { + if (error > erorOld && factor > 0.1 && correctFactor) { + factor *= 0.5; + } else if (error < erorOld && correctFactor) { + factor = 1.0; + } + + iterations++; + oldTemp = system.getTemperature(); + + newCorr = factor * calcdQdT() / calcdQdTT(); + nyTemp = oldTemp - newCorr; + if (Math.abs(system.getTemperature() - nyTemp) > 10.0) { + nyTemp = system.getTemperature() - Math.signum(system.getTemperature() - nyTemp) * 10.0; + correctFactor = false; + } else if (nyTemp < 0) { + nyTemp = Math.abs(system.getTemperature() - 10.0); + correctFactor = false; + } else if (Double.isNaN(nyTemp)) { + nyTemp = oldTemp + 1.0; + correctFactor = false; + } else { + correctFactor = true; + } + + system.setTemperature(nyTemp); + tpFlash.run(); + system.init(2); + erorOld = error; + error = Math.abs(calcdQdT());// Math.abs((nyTemp - oldTemp) / (nyTemp)); + // if(error>erorOld) factor *= -1.0; + // System.out.println("temp " + system.getTemperature() + " iter "+ iterations + + // " error "+ error + " correction " + newCorr + " factor "+ factor); + // newCorr = Math.abs(factor * calcdQdT() / calcdQdTT()); + } while (((error + erorOld) > 1e-8 || iterations < 3) && iterations < 200); + return nyTemp; + } + + /** + *

+ * onPhaseSolve. + *

+ */ + public void onPhaseSolve() {} + + /** {@inheritDoc} */ + @Override + public void run() { + tpFlash.run(); + + if (type == 0) { + solveQ(); + } else { + sysNewtonRhapsonPHflash secondOrderSolver = + new sysNewtonRhapsonPHflash(system, 2, system.getPhases()[0].getNumberOfComponents(), 1); + secondOrderSolver.setSpec(Sspec); + secondOrderSolver.solve(1); } + // System.out.println("Entropy: " + system.getEntropy()); + // System.out.println("Temperature: " + system.getTemperature()); + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/PVrefluxflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/PVrefluxflash.java index 6eb1387996..d1ef332044 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/PVrefluxflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/PVrefluxflash.java @@ -11,81 +11,79 @@ * @version $Id: $Id */ public class PVrefluxflash extends Flash { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - Flash tpFlash; - int refluxPhase = 0; - double refluxSpec = 0.5; + Flash tpFlash; + int refluxPhase = 0; + double refluxSpec = 0.5; - /** - *

- * Constructor for PVrefluxflash. - *

- */ - public PVrefluxflash() {} + /** + *

+ * Constructor for PVrefluxflash. + *

+ */ + public PVrefluxflash() {} - /** - *

- * Constructor for PVrefluxflash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param refluxSpec a double - * @param refluxPhase a int - */ - public PVrefluxflash(SystemInterface system, double refluxSpec, int refluxPhase) { - this.system = system; - this.tpFlash = new TPflash(system); - this.refluxSpec = refluxSpec; - this.refluxPhase = refluxPhase; - } + /** + *

+ * Constructor for PVrefluxflash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param refluxSpec a double + * @param refluxPhase a int + */ + public PVrefluxflash(SystemInterface system, double refluxSpec, int refluxPhase) { + this.system = system; + this.tpFlash = new TPflash(system); + this.refluxSpec = refluxSpec; + this.refluxPhase = refluxPhase; + } - /** {@inheritDoc} */ - @Override - public void run() { - // System.out.println("enthalpy: " + system.getEnthalpy()); - // double err = 0; - int iter = 0; - double f_func = 0.0, f_func_old = 0.0, df_func_dt = 0, t_old = 0, t_oldold = 0.0; - tpFlash.run(); - double dt = 1.0; - do { - iter++; + /** {@inheritDoc} */ + @Override + public void run() { + int iter = 0; + double f_func = 0.0, f_func_old = 0.0, df_func_dt = 0, t_old = 0, t_oldold = 0.0; + tpFlash.run(); + double dt = 1.0; + do { + iter++; - f_func_old = f_func; - t_oldold = t_old; - t_old = system.getTemperature(); + f_func_old = f_func; + t_oldold = t_old; + t_old = system.getTemperature(); - f_func = refluxSpec - (1.0 / system.getBeta(refluxPhase) - 1.0);// system.getPhase(refluxPhase).getVolume() - // / system.getVolume(); - df_func_dt = (f_func - f_func_old) / (t_old - t_oldold); + f_func = refluxSpec - (1.0 / system.getBeta(refluxPhase) - 1.0);// system.getPhase(refluxPhase).getVolume() + // / system.getVolume(); + df_func_dt = (f_func - f_func_old) / (t_old - t_oldold); - // err = Math.abs(f_func); + // err = Math.abs(f_func); - if (iter < 4) { - if (f_func > 0) { - system.setTemperature(system.getTemperature() + 0.1); - } else if (f_func < 0) { - system.setTemperature(system.getTemperature() - 0.1); - } - } else { - dt = f_func / df_func_dt; - if (Math.abs(dt) > 2.0) { - dt = Math.signum(dt) * 2.0; - } + if (iter < 4) { + if (f_func > 0) { + system.setTemperature(system.getTemperature() + 0.1); + } else if (f_func < 0) { + system.setTemperature(system.getTemperature() - 0.1); + } + } else { + dt = f_func / df_func_dt; + if (Math.abs(dt) > 2.0) { + dt = Math.signum(dt) * 2.0; + } - system.setTemperature(system.getTemperature() - dt * (1.0 * iter) / (iter + 50.0)); - } - tpFlash.run(); + system.setTemperature(system.getTemperature() - dt * (1.0 * iter) / (iter + 50.0)); + } + tpFlash.run(); - // System.out.println("temp " + system.getTemperature() + " err " + err + " - // volfor " + system.getPhase(refluxPhase).getVolume() / system.getVolume()); - } while (Math.abs(dt) > 1e-8 && Math.abs(f_func) > 1e-6 && iter < 1000); - } + // System.out.println("temp " + system.getTemperature() + " err " + err + " + // volfor " + system.getPhase(refluxPhase).getVolume() / system.getVolume()); + } while (Math.abs(dt) > 1e-8 && Math.abs(f_func) > 1e-6 && iter < 1000); + } - /** {@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/TPmultiflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash.java index ee93f6edcc..aa1444a405 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash.java @@ -24,1012 +24,998 @@ * @version $Id: $Id */ public class TPmultiflash extends TPflash { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(TPmultiflash.class); - - // SystemInterface clonedSystem; - boolean multiPhaseTest = false; - double dQdbeta[][]; - double Qmatrix[][]; - double Erow[]; - double Q = 0; - boolean doStabilityAnalysis = true; - boolean removePhase = false, checkOneRemove = false; - boolean secondTime = false; - - double[] multTerm, multTerm2; - - /** - *

- * Constructor for TPmultiflash. - *

- */ - public TPmultiflash() {} - - /** - *

- * Constructor for TPmultiflash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public TPmultiflash(SystemInterface system) { - super(system); - Erow = new double[system.getPhase(0).getNumberOfComponents()]; - } + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(TPmultiflash.class); + + // SystemInterface clonedSystem; + boolean multiPhaseTest = false; + double dQdbeta[][]; + double Qmatrix[][]; + double[] Erow; + double Q = 0; + boolean doStabilityAnalysis = true; + boolean removePhase = false; + boolean checkOneRemove = false; + boolean secondTime = false; + + double[] multTerm; + double[] multTerm2; + + /** + *

+ * Constructor for TPmultiflash. + *

+ */ + public TPmultiflash() {} + + /** + *

+ * Constructor for TPmultiflash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public TPmultiflash(SystemInterface system) { + super(system); + Erow = new double[system.getPhase(0).getNumberOfComponents()]; + } + + /** + *

+ * Constructor for TPmultiflash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param check a boolean + */ + public TPmultiflash(SystemInterface system, boolean check) { + super(system, check); + Erow = new double[system.getPhase(0).getNumberOfComponents()]; + multTerm = new double[system.getPhase(0).getNumberOfComponents()]; + multTerm2 = new double[system.getPhase(0).getNumberOfComponents()]; + } + + /** + *

+ * calcMultiPhaseBeta. + *

+ */ + public void calcMultiPhaseBeta() {} + + /** + *

+ * setDoubleArrays. + *

+ */ + public void setDoubleArrays() { + dQdbeta = new double[system.getNumberOfPhases()][1]; + Qmatrix = new double[system.getNumberOfPhases()][system.getNumberOfPhases()]; + } + + /** + *

+ * setXY. + *

+ */ + public void setXY() { + for (int k = 0; k < system.getNumberOfPhases(); k++) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (system.getPhase(0).getComponent(i).getz() > 1e-100) { + system.getPhase(k).getComponents()[i].setx(system.getPhase(0).getComponents()[i].getz() + / Erow[i] / system.getPhase(k).getComponent(i).getFugacityCoefficient()); + } + if (system.getPhase(0).getComponent(i).getIonicCharge() != 0 + && !system.getPhase(k).getPhaseTypeName().equals("aqueous")) { + system.getPhase(k).getComponents()[i].setx(1e-50); + } + if (system.getPhase(0).getComponent(i).getIonicCharge() != 0 + && system.getPhase(k).getPhaseTypeName().equals("aqueous")) { + system.getPhase(k).getComponents()[i] + .setx(system.getPhase(k).getComponents()[i].getNumberOfmoles() + / system.getPhase(k).getNumberOfMolesInPhase()); + } + } - /** - *

- * Constructor for TPmultiflash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param check a boolean - */ - public TPmultiflash(SystemInterface system, boolean check) { - super(system, check); - Erow = new double[system.getPhase(0).getNumberOfComponents()]; - multTerm = new double[system.getPhase(0).getNumberOfComponents()]; - multTerm2 = new double[system.getPhase(0).getNumberOfComponents()]; + system.getPhase(k).normalize(); } - - /** - *

- * calcMultiPhaseBeta. - *

+ } + + /** + *

+ * calcE. + *

+ */ + public void calcE() { + // E = new double[system.getPhase(0).getNumberOfComponents()]; + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + Erow[i] = 0.0; + for (int k = 0; k < system.getNumberOfPhases(); k++) { + Erow[i] += system.getPhase(k).getBeta() + / system.getPhase(k).getComponent(i).getFugacityCoefficient(); + } + } + } + + /** + *

+ * calcQ. + *

+ * + * @return a double + */ + public double calcQ() { + /* + * double betaTotal = 0; for (int k = 0; k < system.getNumberOfPhases(); k++) { betaTotal += + * system.getPhase(k).getBeta(); } Q = betaTotal; */ - public void calcMultiPhaseBeta() {} - - /** - *

- * setDoubleArrays. - *

+ this.calcE(); + /* + * for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { Q -= Math.log(E[i]) * + * system.getPhase(0).getComponent(i).getz(); } */ - public void setDoubleArrays() { - dQdbeta = new double[system.getNumberOfPhases()][1]; - Qmatrix = new double[system.getNumberOfPhases()][system.getNumberOfPhases()]; - } - /** - *

- * setXY. - *

- */ - public void setXY() { - for (int k = 0; k < system.getNumberOfPhases(); k++) { - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - if (system.getPhase(0).getComponent(i).getz() > 1e-100) { - system.getPhase(k).getComponents()[i] - .setx(system.getPhase(0).getComponents()[i].getz() / Erow[i] - / system.getPhase(k).getComponent(i).getFugacityCoefficient()); - } - if (system.getPhase(0).getComponent(i).getIonicCharge() != 0 - && !system.getPhase(k).getPhaseTypeName().equals("aqueous")) { - system.getPhase(k).getComponents()[i].setx(1e-50); - } - if (system.getPhase(0).getComponent(i).getIonicCharge() != 0 - && system.getPhase(k).getPhaseTypeName().equals("aqueous")) { - system.getPhase(k).getComponents()[i] - .setx(system.getPhase(k).getComponents()[i].getNumberOfmoles() - / system.getPhase(k).getNumberOfMolesInPhase()); - } - } + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + multTerm[i] = system.getPhase(0).getComponent(i).getz() / Erow[i]; + multTerm2[i] = system.getPhase(0).getComponent(i).getz() / (Erow[i] * Erow[i]); + } - system.getPhase(k).normalize(); - } + for (int k = 0; k < system.getNumberOfPhases(); k++) { + dQdbeta[k][0] = 1.0; + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + dQdbeta[k][0] -= multTerm[i] / system.getPhase(k).getComponent(i).getFugacityCoefficient(); + } } - /** - *

- * calcE. - *

- */ - public void calcE() { - // E = new double[system.getPhase(0).getNumberOfComponents()]; - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - Erow[i] = 0.0; - for (int k = 0; k < system.getNumberOfPhases(); k++) { - Erow[i] += system.getPhase(k).getBeta() - / system.getPhase(k).getComponent(i).getFugacityCoefficient(); - } + for (int i = 0; i < system.getNumberOfPhases(); i++) { + for (int j = 0; j < system.getNumberOfPhases(); j++) { + Qmatrix[i][j] = 0.0; + for (int k = 0; k < system.getPhase(0).getNumberOfComponents(); k++) { + Qmatrix[i][j] += + multTerm2[k] / (system.getPhase(j).getComponent(k).getFugacityCoefficient() + * system.getPhase(i).getComponent(k).getFugacityCoefficient()); + } + if (i == j) { + Qmatrix[i][j] += 1.0e-3; } + } } + return Q; + } + + /** + *

+ * solveBeta. + *

+ * + * @return a double + */ + public double solveBeta() { + SimpleMatrix betaMatrix = new SimpleMatrix(1, system.getNumberOfPhases()); + SimpleMatrix ans = null; + double err = 1.0; + int iter = 1; + do { + iter++; + for (int k = 0; k < system.getNumberOfPhases(); k++) { + betaMatrix.set(0, k, system.getPhase(k).getBeta()); + } + + calcQ(); + SimpleMatrix dQM = new SimpleMatrix(dQdbeta); + SimpleMatrix dQdBM = new SimpleMatrix(Qmatrix); + try { + ans = dQdBM.solve(dQM).transpose(); + } catch (Exception e) { + } + betaMatrix = betaMatrix.minus(ans.scale(iter / (iter + 3.0))); + removePhase = false; + for (int k = 0; k < system.getNumberOfPhases(); k++) { + system.setBeta(k, betaMatrix.get(0, k)); + if (betaMatrix.get(0, k) < phaseFractionMinimumLimit) { + system.setBeta(k, phaseFractionMinimumLimit); + if (checkOneRemove) { + checkOneRemove = false; + removePhase = true; + } + checkOneRemove = true; + } else if (betaMatrix.get(0, k) > (1.0 - phaseFractionMinimumLimit)) { + system.setBeta(k, 1.0 - phaseFractionMinimumLimit); + } + } + system.normalizeBeta(); + system.init(1); + calcE(); + setXY(); + system.init(1); + err = ans.normF(); + } while ((err > 1e-12 && iter < 50) || iter < 3); + // logger.info("iterations " + iter); + return err; + } + + /** {@inheritDoc} */ + @Override + public void stabilityAnalysis() { + double[] logWi = new double[system.getPhase(0).getNumberOfComponents()]; + double[][] Wi = new double[system.getPhase(0).getNumberOfComponents()][system.getPhase(0) + .getNumberOfComponents()]; + + double[] deltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] oldDeltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] oldoldDeltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] sumw = new double[system.getPhase(0).getNumberOfComponents()]; + double err = 0; + double[] oldlogw = new double[system.getPhase(0).getNumberOfComponents()]; + double[] oldoldlogw = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] oldoldoldlogw = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] d = new double[system.getPhase(0).getNumberOfComponents()]; + double[][] x = new double[system.getPhase(0).getNumberOfComponents()][system.getPhase(0) + .getNumberOfComponents()]; + tm = new double[system.getPhase(0).getNumberOfComponents()]; + + double[] alpha = null; + // SystemInterface minimumGibbsEnergySystem; + ArrayList clonedSystem = new ArrayList(1); + // if (minimumGibbsEnergySystem == null) { + // minimumGibbsEnergySystem = system.clone(); + // } + minimumGibbsEnergySystem = system; + clonedSystem.add(system.clone()); + /* + * for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { if + * (system.getPhase(0).getComponent(i).getx() < 1e-100) { clonedSystem.add(null); continue; } + * double numb = 0; clonedSystem.add(system.clone()); + * + * // (clonedSystem.get(i)).init(0); commented out sept 2005, Even S. for (int j = 0; j < + * system.getPhase(0).getNumberOfComponents(); j++) { numb = i == j ? 1.0 : 1.0e-12; // set to 0 + * by Even Solbraa 23.01.2013 - chaged back to 1.0e-12 27.04.13 if + * (system.getPhase(0).getComponent(j).getz() < 1e-100) { numb = 0; } ( + * clonedSystem.get(i)).getPhase(1).getComponents()[j].setx(numb); } if + * (system.getPhase(0).getComponent(i).getIonicCharge() == 0) { ( clonedSystem.get(i)).init(1); + * } } + */ - /** - *

- * calcQ. - *

- * - * @return a double + lowestGibbsEnergyPhase = 0; + /* + * // logger.info("low gibbs phase " + lowestGibbsEnergyPhase); for (int k = 0; k < + * minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); k++) { for (int i = 0; i < + * minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); i++) { if (!(( + * clonedSystem.get(k)) == null)) { sumw[k] += ( + * clonedSystem.get(k)).getPhase(1).getComponents()[i].getx(); } } } + * + * for (int k = 0; k < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); k++) { for + * (int i = 0; i < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); i++) { if (!(( + * clonedSystem.get(k)) == null) && system.getPhase(0).getComponent(k).getx() > 1e-100) { ( + * clonedSystem.get(k)).getPhase(1).getComponents()[i].setx(( + * clonedSystem.get(k)).getPhase(1).getComponents()[i].getx() / sumw[0]); } logger.info("x: " + + * ( clonedSystem.get(k)).getPhase(0).getComponents()[i].getx()); } if + * (system.getPhase(0).getComponent(k).getx() > 1e-100) { d[k] = + * Math.log(system.getPhase(0).getComponents()[k].getx()) + + * system.getPhase(0).getComponents()[k].getLogFugacityCoefficient(); + * if(minimumGibbsEnergySystem.getPhases()[lowestGibbsEnergyPhase].getComponents + * ()[k].getIonicCharge()!=0) d[k]=0; } //logger.info("dk: " + d[k]); } */ - public double calcQ() { - /* - * double betaTotal = 0; for (int k = 0; k < system.getNumberOfPhases(); k++) { betaTotal += - * system.getPhase(k).getBeta(); } Q = betaTotal; - */ - this.calcE(); - /* - * for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { Q -= - * Math.log(E[i]) * system.getPhase(0).getComponent(i).getz(); } - */ + for (int k = 0; k < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); k++) { + if (system.getPhase(0).getComponent(k).getx() > 1e-100) { + d[k] = Math.log(system.getPhase(0).getComponents()[k].getx()) + + system.getPhase(0).getComponents()[k].getLogFugacityCoefficient(); + // if(minimumGibbsEnergySystem.getPhases()[lowestGibbsEnergyPhase].getComponents()[k].getIonicCharge()!=0) + // d[k]=0; + } + } - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - multTerm[i] = system.getPhase(0).getComponent(i).getz() / Erow[i]; - multTerm2[i] = system.getPhase(0).getComponent(i).getz() / (Erow[i] * Erow[i]); - } + for (int j = 0; j < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); j++) { + if (system.getPhase(0).getComponent(j).getz() > 1e-100) { + logWi[j] = 1.0; + } else { + logWi[j] = -10000.0; + } + } - for (int k = 0; k < system.getNumberOfPhases(); k++) { - dQdbeta[k][0] = 1.0; - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - dQdbeta[k][0] -= - multTerm[i] / system.getPhase(k).getComponent(i).getFugacityCoefficient(); - } + int hydrocarbonTestCompNumb = 0; + int lightTestCompNumb = 0; + double Mmax = 0; + double Mmin = 1e10; + for (int i = 0; i < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); i++) { + if (minimumGibbsEnergySystem.getPhase(0).getComponent(i).isHydrocarbon()) { + if ((minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass()) > Mmax) { + Mmax = minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass(); } - - for (int i = 0; i < system.getNumberOfPhases(); i++) { - for (int j = 0; j < system.getNumberOfPhases(); j++) { - Qmatrix[i][j] = 0.0; - for (int k = 0; k < system.getPhase(0).getNumberOfComponents(); k++) { - Qmatrix[i][j] += multTerm2[k] - / (system.getPhase(j).getComponent(k).getFugacityCoefficient() - * system.getPhase(i).getComponent(k).getFugacityCoefficient()); - } - if (i == j) { - Qmatrix[i][j] += 1.0e-3; - } - } + if ((minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass()) < Mmin) { + Mmin = minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass(); } - return Q; + } } - /** - *

- * solveBeta. - *

- * - * @return a double - */ - public double solveBeta() { - SimpleMatrix betaMatrix = new SimpleMatrix(1, system.getNumberOfPhases()); - SimpleMatrix ans = null; - double err = 1.0; - int iter = 1; - do { - iter++; - for (int k = 0; k < system.getNumberOfPhases(); k++) { - betaMatrix.set(0, k, system.getPhase(k).getBeta()); - } - - calcQ(); - SimpleMatrix dQM = new SimpleMatrix(dQdbeta); - SimpleMatrix dQdBM = new SimpleMatrix(Qmatrix); - try { - ans = dQdBM.solve(dQM).transpose(); - } catch (Exception e) { - } - betaMatrix = betaMatrix.minus(ans.scale(iter / (iter + 3.0))); - removePhase = false; - for (int k = 0; k < system.getNumberOfPhases(); k++) { - system.setBeta(k, betaMatrix.get(0, k)); - if (betaMatrix.get(0, k) < phaseFractionMinimumLimit) { - system.setBeta(k, phaseFractionMinimumLimit); - if (checkOneRemove) { - checkOneRemove = false; - removePhase = true; - } - checkOneRemove = true; - } else if (betaMatrix.get(0, k) > (1.0 - phaseFractionMinimumLimit)) { - system.setBeta(k, 1.0 - phaseFractionMinimumLimit); - } - } - system.normalizeBeta(); - system.init(1); - calcE(); - setXY(); - system.init(1); - err = ans.normF(); - } while ((err > 1e-12 && iter < 50) || iter < 3); - // logger.info("iterations " + iter); - return err; + for (int i = 0; i < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); i++) { + if (minimumGibbsEnergySystem.getPhase(0).getComponent(i).isHydrocarbon() + && minimumGibbsEnergySystem.getPhase(0).getComponent(i).getz() > 1e-50) { + if (Math.abs( + (minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass()) - Mmax) < 1e-5) { + hydrocarbonTestCompNumb = i; + // logger.info("CHECKING heavy component " + hydrocarbonTestCompNumb); + } + } + + if (minimumGibbsEnergySystem.getPhase(0).getComponent(i).isHydrocarbon() + && minimumGibbsEnergySystem.getPhase(0).getComponent(i).getz() > 1e-50) { + if (Math.abs( + (minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass()) - Mmin) < 1e-5) { + lightTestCompNumb = i; + // logger.info("CHECKING light component " + lightTestCompNumb); + } + } } - /** {@inheritDoc} */ - @Override - public void stabilityAnalysis() { - double[] logWi = new double[system.getPhase(0).getNumberOfComponents()]; - double[][] Wi = new double[system.getPhase(0).getNumberOfComponents()][system.getPhase(0) - .getNumberOfComponents()]; - - double[] deltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; - double[] oldDeltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; - double[] oldoldDeltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; - double[] sumw = new double[system.getPhase(0).getNumberOfComponents()]; - double err = 0; - double[] oldlogw = new double[system.getPhase(0).getNumberOfComponents()]; - double[] oldoldlogw = new double[system.getPhases()[0].getNumberOfComponents()]; - double[] oldoldoldlogw = new double[system.getPhases()[0].getNumberOfComponents()]; - double[] d = new double[system.getPhase(0).getNumberOfComponents()]; - double[][] x = new double[system.getPhase(0).getNumberOfComponents()][system.getPhase(0) - .getNumberOfComponents()]; - tm = new double[system.getPhase(0).getNumberOfComponents()]; - - double[] alpha = null; - // SystemInterface minimumGibbsEnergySystem; - ArrayList clonedSystem = new ArrayList(1); - // if (minimumGibbsEnergySystem == null) { - // minimumGibbsEnergySystem = system.clone(); - // } - minimumGibbsEnergySystem = system; - clonedSystem.add(system.clone()); - /* - * for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { if - * (system.getPhase(0).getComponent(i).getx() < 1e-100) { clonedSystem.add(null); continue; - * } double numb = 0; clonedSystem.add(system.clone()); - * - * // (clonedSystem.get(i)).init(0); commented out sept 2005, Even S. for (int j = 0; j < - * system.getPhase(0).getNumberOfComponents(); j++) { numb = i == j ? 1.0 : 1.0e-12; // set - * to 0 by Even Solbraa 23.01.2013 - chaged back to 1.0e-12 27.04.13 if - * (system.getPhase(0).getComponent(j).getz() < 1e-100) { numb = 0; } ( - * clonedSystem.get(i)).getPhase(1).getComponents()[j].setx(numb); } if - * (system.getPhase(0).getComponent(i).getIonicCharge() == 0) { ( - * clonedSystem.get(i)).init(1); } } - */ - - lowestGibbsEnergyPhase = 0; - /* - * // logger.info("low gibbs phase " + lowestGibbsEnergyPhase); for (int k = 0; k < - * minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); k++) { for (int i = 0; i < - * minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); i++) { if (!(( - * clonedSystem.get(k)) == null)) { sumw[k] += ( - * clonedSystem.get(k)).getPhase(1).getComponents()[i].getx(); } } } - * - * for (int k = 0; k < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); k++) { - * for (int i = 0; i < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); i++) { - * if (!(( clonedSystem.get(k)) == null) && system.getPhase(0).getComponent(k).getx() > - * 1e-100) { ( clonedSystem.get(k)).getPhase(1).getComponents()[i].setx(( - * clonedSystem.get(k)).getPhase(1).getComponents()[i].getx() / sumw[0]); } - * logger.info("x: " + ( clonedSystem.get(k)).getPhase(0).getComponents()[i].getx()); } if - * (system.getPhase(0).getComponent(k).getx() > 1e-100) { d[k] = - * Math.log(system.getPhase(0).getComponents()[k].getx()) + - * system.getPhase(0).getComponents()[k].getLogFugacityCoefficient(); - * if(minimumGibbsEnergySystem.getPhases()[lowestGibbsEnergyPhase].getComponents - * ()[k].getIonicCharge()!=0) d[k]=0; } //logger.info("dk: " + d[k]); } - */ - for (int k = 0; k < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); k++) { - if (system.getPhase(0).getComponent(k).getx() > 1e-100) { - d[k] = Math.log(system.getPhase(0).getComponents()[k].getx()) - + system.getPhase(0).getComponents()[k].getLogFugacityCoefficient(); - // if(minimumGibbsEnergySystem.getPhases()[lowestGibbsEnergyPhase].getComponents()[k].getIonicCharge()!=0) - // d[k]=0; - } + for (int j = system.getPhase(0).getNumberOfComponents() - 1; j >= 0; j--) { + if (minimumGibbsEnergySystem.getPhase(0).getComponent(j).getx() < 1e-100 + || (minimumGibbsEnergySystem.getPhase(0).getComponent(j).getIonicCharge() != 0) + || (minimumGibbsEnergySystem.getPhase(0).getComponent(j).isHydrocarbon() + && j != hydrocarbonTestCompNumb && j != lightTestCompNumb)) { + continue; + } + + double nomb = 0.0; + for (int cc = 0; cc < system.getPhase(0).getNumberOfComponents(); cc++) { + nomb = cc == j ? 1.0 : 1.0e-12; // set to 0 by Even Solbraa 23.01.2013 - chaged back + // to 1.0e-12 27.04.13 + if (system.getPhase(0).getComponent(cc).getz() < 1e-100) { + nomb = 0.0; } - for (int j = 0; j < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); j++) { - if (system.getPhase(0).getComponent(j).getz() > 1e-100) { - logWi[j] = 1.0; - } else { - logWi[j] = -10000.0; - } + if (clonedSystem.get(0).IsPhase(1)) { + try { + clonedSystem.get(0).getPhase(1).getComponents()[cc].setx(nomb); + } catch (Exception e) { + System.out.println(e.getMessage()); + } } - - int hydrocarbonTestCompNumb = 0, lightTestCompNumb = 0; - double Mmax = 0, Mmin = 1e10; - for (int i = 0; i < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); i++) { - if (minimumGibbsEnergySystem.getPhase(0).getComponent(i).isHydrocarbon()) { - if ((minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass()) > Mmax) { - Mmax = minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass(); - } - if ((minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass()) < Mmin) { - Mmin = minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass(); - } + } + // if(minimumGibbsEnergySystem.getPhase(0).getComponent(j).getName().equals("water") + // && minimumGibbsEnergySystem.isChemicalSystem()) continue; + // logger.info("STAB CHECK COMP " + + // system.getPhase(0).getComponent(j).getComponentName()); + // if(minimumGibbsEnergySystem.getPhase(0).getComponent(j).isInert()) break; + int iter = 0; + double errOld = 1.0e100; + do { + errOld = err; + iter++; + err = 0; + + if (iter <= 150 || !system.isImplementedCompositionDeriativesofFugacity()) { + if (iter % 7 == 0) { + double vec1 = 0.0; + + double vec2 = 0.0; + double prod1 = 0.0; + double prod2 = 0.0; + for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + vec1 = oldDeltalogWi[i] * oldoldDeltalogWi[i]; + vec2 = Math.pow(oldoldDeltalogWi[i], 2.0); + prod1 += vec1 * vec2; + prod2 += vec2 * vec2; + } + + double lambda = prod1 / prod2; + // logger.info("lambda " + lambda); + for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + logWi[i] += lambda / (1.0 - lambda) * deltalogWi[i]; + err += Math.abs((logWi[i] - oldlogw[i]) / oldlogw[i]); + Wi[j][i] = Math.exp(logWi[i]); + } + } else { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + oldoldoldlogw[i] = oldoldlogw[i]; + oldoldlogw[i] = oldlogw[i]; + oldlogw[i] = logWi[i]; + oldoldDeltalogWi[i] = oldoldlogw[i] - oldoldoldlogw[i]; + oldDeltalogWi[i] = oldlogw[i] - oldoldlogw[i]; } + clonedSystem.get(0).init(1, 1); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + // oldlogw[i] = logWi[i]; + if (!Double.isInfinite( + clonedSystem.get(0).getPhase(1).getComponents()[i].getLogFugacityCoefficient()) + && system.getPhase(0).getComponent(i).getx() > 1e-100) { + logWi[i] = d[i] - clonedSystem.get(0).getPhase(1).getComponents()[i] + .getLogFugacityCoefficient(); + if (clonedSystem.get(0).getPhase(1).getComponents()[i].getIonicCharge() != 0) { + logWi[i] = -1000.0; + } + } + deltalogWi[i] = logWi[i] - oldlogw[i]; + err += Math.abs(logWi[i] - oldlogw[i]); + Wi[j][i] = Math.exp(logWi[i]); + } + } + } else { + SimpleMatrix f = new SimpleMatrix(system.getPhases()[0].getNumberOfComponents(), 1); + SimpleMatrix df = null; + SimpleMatrix identitytimesConst = null; + // if (!secondOrderStabilityAnalysis) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + oldoldoldlogw[i] = oldoldlogw[i]; + oldoldlogw[i] = oldlogw[i]; + oldlogw[i] = logWi[i]; + oldoldDeltalogWi[i] = oldoldlogw[i] - oldoldoldlogw[i]; + oldDeltalogWi[i] = oldlogw[i] - oldoldlogw[i]; + } + clonedSystem.get(0).init(3, 1); + alpha = new double[clonedSystem.get(0).getPhases()[0].getNumberOfComponents()]; + df = new SimpleMatrix(system.getPhases()[0].getNumberOfComponents(), + system.getPhases()[0].getNumberOfComponents()); + identitytimesConst = SimpleMatrix.identity(system.getPhases()[0].getNumberOfComponents());// , + // system.getPhases()[0].getNumberOfComponents()); + // secondOrderStabilityAnalysis = true; + // } + + for (int i = 0; i < clonedSystem.get(0).getPhases()[0].getNumberOfComponents(); i++) { + alpha[i] = 2.0 * Math.sqrt(Wi[j][i]); + } + + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (system.getPhase(0).getComponent(i).getz() > 1e-100) { + f.set(i, 0, + Math.sqrt(Wi[j][i]) + * (Math.log(Wi[j][i]) + clonedSystem.get(0).getPhases()[1].getComponents()[i] + .getLogFugacityCoefficient() - d[i])); + } + for (int k = 0; k < clonedSystem.get(0).getPhases()[0].getNumberOfComponents(); k++) { + double kronDelt = (i == k) ? 1.0 : 0.0; + if (system.getPhase(0).getComponent(i).getz() > 1e-100) { + df.set(i, k, kronDelt + Math.sqrt(Wi[j][k] * Wi[j][i]) + * clonedSystem.get(0).getPhases()[1].getComponents()[i].getdfugdn(k));// * + // clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); + } else { + df.set(i, k, 0);// * + // clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); + } + } + } + + // f.print(10, 10); + // df.print(10, 10); + SimpleMatrix dx = df.plus(identitytimesConst).solve(f).negative(); + // dx.print(10, 10); + + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + double alphaNew = alpha[i] + dx.get(i, 0); + Wi[j][i] = Math.pow(alphaNew / 2.0, 2.0); + if (system.getPhase(0).getComponent(i).getz() > 1e-100) { + logWi[i] = Math.log(Wi[j][i]); + } + if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { + logWi[i] = -1000.0; + } + err += Math.abs((logWi[i] - oldlogw[i]) / oldlogw[i]); + } + + // logger.info("err newton " + err); } + // logger.info("err: " + err); + sumw[j] = 0; - for (int i = 0; i < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); i++) { - if (minimumGibbsEnergySystem.getPhase(0).getComponent(i).isHydrocarbon() - && minimumGibbsEnergySystem.getPhase(0).getComponent(i).getz() > 1e-50) { - if (Math.abs((minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass()) - - Mmax) < 1e-5) { - hydrocarbonTestCompNumb = i; - // logger.info("CHECKING heavy component " + hydrocarbonTestCompNumb); - } - } - - if (minimumGibbsEnergySystem.getPhase(0).getComponent(i).isHydrocarbon() - && minimumGibbsEnergySystem.getPhase(0).getComponent(i).getz() > 1e-50) { - if (Math.abs((minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass()) - - Mmin) < 1e-5) { - lightTestCompNumb = i; - // logger.info("CHECKING light component " + lightTestCompNumb); - } - } + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + sumw[j] += Math.exp(logWi[i]); } - for (int j = system.getPhase(0).getNumberOfComponents() - 1; j >= 0; j--) { - if (minimumGibbsEnergySystem.getPhase(0).getComponent(j).getx() < 1e-100 - || (minimumGibbsEnergySystem.getPhase(0).getComponent(j).getIonicCharge() != 0) - || (minimumGibbsEnergySystem.getPhase(0).getComponent(j).isHydrocarbon() - && j != hydrocarbonTestCompNumb && j != lightTestCompNumb)) { - continue; - } - - double nomb = 0.0; - for (int cc = 0; cc < system.getPhase(0).getNumberOfComponents(); cc++) { - nomb = cc == j ? 1.0 : 1.0e-12; // set to 0 by Even Solbraa 23.01.2013 - chaged back - // to 1.0e-12 27.04.13 - if (system.getPhase(0).getComponent(cc).getz() < 1e-100) { - nomb = 0.0; - } - - if (clonedSystem.get(0).IsPhase(1)) { - try { - clonedSystem.get(0).getPhase(1).getComponents()[cc].setx(nomb); - } catch (Exception e) { - System.out.println(e.getMessage()); - } - } - } - // if(minimumGibbsEnergySystem.getPhase(0).getComponent(j).getName().equals("water") - // && minimumGibbsEnergySystem.isChemicalSystem()) continue; - // logger.info("STAB CHECK COMP " + - // system.getPhase(0).getComponent(j).getComponentName()); - // if(minimumGibbsEnergySystem.getPhase(0).getComponent(j).isInert()) break; - int iter = 0; - double errOld = 1.0e100; - do { - errOld = err; - iter++; - err = 0; - - if (iter <= 150 || !system.isImplementedCompositionDeriativesofFugacity()) { - if (iter % 7 == 0) { - double vec1 = 0.0, vec2 = 0.0, prod1 = 0.0, prod2 = 0.0; - - for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - vec1 = oldDeltalogWi[i] * oldoldDeltalogWi[i]; - vec2 = Math.pow(oldoldDeltalogWi[i], 2.0); - prod1 += vec1 * vec2; - prod2 += vec2 * vec2; - } - - double lambda = prod1 / prod2; - // logger.info("lambda " + lambda); - for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - logWi[i] += lambda / (1.0 - lambda) * deltalogWi[i]; - err += Math.abs((logWi[i] - oldlogw[i]) / oldlogw[i]); - Wi[j][i] = Math.exp(logWi[i]); - } - } else { - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - oldoldoldlogw[i] = oldoldlogw[i]; - oldoldlogw[i] = oldlogw[i]; - oldlogw[i] = logWi[i]; - oldoldDeltalogWi[i] = oldoldlogw[i] - oldoldoldlogw[i]; - oldDeltalogWi[i] = oldlogw[i] - oldoldlogw[i]; - } - clonedSystem.get(0).init(1, 1); - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - // oldlogw[i] = logWi[i]; - if (!Double - .isInfinite(clonedSystem.get(0).getPhase(1).getComponents()[i] - .getLogFugacityCoefficient()) - && system.getPhase(0).getComponent(i).getx() > 1e-100) { - logWi[i] = d[i] - clonedSystem.get(0).getPhase(1).getComponents()[i] - .getLogFugacityCoefficient(); - if (clonedSystem.get(0).getPhase(1).getComponents()[i] - .getIonicCharge() != 0) { - logWi[i] = -1000.0; - } - } - deltalogWi[i] = logWi[i] - oldlogw[i]; - err += Math.abs(logWi[i] - oldlogw[i]); - Wi[j][i] = Math.exp(logWi[i]); - } - } - } else { - SimpleMatrix f = - new SimpleMatrix(system.getPhases()[0].getNumberOfComponents(), 1); - SimpleMatrix df = null; - SimpleMatrix identitytimesConst = null; - // if (!secondOrderStabilityAnalysis) { - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - oldoldoldlogw[i] = oldoldlogw[i]; - oldoldlogw[i] = oldlogw[i]; - oldlogw[i] = logWi[i]; - oldoldDeltalogWi[i] = oldoldlogw[i] - oldoldoldlogw[i]; - oldDeltalogWi[i] = oldlogw[i] - oldoldlogw[i]; - } - clonedSystem.get(0).init(3, 1); - alpha = new double[clonedSystem.get(0).getPhases()[0].getNumberOfComponents()]; - df = new SimpleMatrix(system.getPhases()[0].getNumberOfComponents(), - system.getPhases()[0].getNumberOfComponents()); - identitytimesConst = - SimpleMatrix.identity(system.getPhases()[0].getNumberOfComponents());// , - // system.getPhases()[0].getNumberOfComponents()); - // secondOrderStabilityAnalysis = true; - // } - - for (int i = 0; i < clonedSystem.get(0).getPhases()[0] - .getNumberOfComponents(); i++) { - alpha[i] = 2.0 * Math.sqrt(Wi[j][i]); - } - - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - if (system.getPhase(0).getComponent(i).getz() > 1e-100) { - f.set(i, 0, - Math.sqrt(Wi[j][i]) * (Math.log(Wi[j][i]) - + clonedSystem.get(0).getPhases()[1].getComponents()[i] - .getLogFugacityCoefficient() - - d[i])); - } - for (int k = 0; k < clonedSystem.get(0).getPhases()[0] - .getNumberOfComponents(); k++) { - double kronDelt = (i == k) ? 1.0 : 0.0; - if (system.getPhase(0).getComponent(i).getz() > 1e-100) { - df.set(i, k, kronDelt + Math.sqrt(Wi[j][k] * Wi[j][i]) - * clonedSystem.get(0).getPhases()[1].getComponents()[i] - .getdfugdn(k));// * - // clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); - } else { - df.set(i, k, 0);// * - // clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); - } - } - } - - // f.print(10, 10); - // df.print(10, 10); - SimpleMatrix dx = df.plus(identitytimesConst).solve(f).negative(); - // dx.print(10, 10); - - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - double alphaNew = alpha[i] + dx.get(i, 0); - Wi[j][i] = Math.pow(alphaNew / 2.0, 2.0); - if (system.getPhase(0).getComponent(i).getz() > 1e-100) { - logWi[i] = Math.log(Wi[j][i]); - } - if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { - logWi[i] = -1000.0; - } - err += Math.abs((logWi[i] - oldlogw[i]) / oldlogw[i]); - } - - // logger.info("err newton " + err); - } - // logger.info("err: " + err); - sumw[j] = 0; - - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - sumw[j] += Math.exp(logWi[i]); - } - - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - if (system.getPhase(0).getComponent(i).getx() > 1e-100) { - clonedSystem.get(0).getPhase(1).getComponents()[i] - .setx(Math.exp(logWi[i]) / sumw[j]); - } - if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { - clonedSystem.get(0).getPhase(1).getComponents()[i].setx(1e-50); - } - } - } while ((Math.abs(err) > 1e-9 || err > errOld) && iter < 600); - // logger.info("err: " + err + " ITER " + iter); - double xTrivialCheck0 = 0.0; - double xTrivialCheck1 = 0.0; - - tm[j] = 1.0; - - for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { - if (system.getPhase(0).getComponent(i).getx() > 1e-100) { - tm[j] -= Math.exp(logWi[i]); - } - x[j][i] = clonedSystem.get(0).getPhase(1).getComponents()[i].getx(); - // logger.info("txji: " + x[j][i]); - - xTrivialCheck0 += Math.abs(x[j][i] - system.getPhase(0).getComponent(i).getx()); - xTrivialCheck1 += Math.abs(x[j][i] - system.getPhase(1).getComponent(i).getx()); - } - if (iter >= 599) { - // logger.info("iter > maxiter multiphase stability "); - // logger.info("error " + Math.abs(err)); - // logger.info("tm: " + tm[j]); - } + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (system.getPhase(0).getComponent(i).getx() > 1e-100) { + clonedSystem.get(0).getPhase(1).getComponents()[i].setx(Math.exp(logWi[i]) / sumw[j]); + } + if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { + clonedSystem.get(0).getPhase(1).getComponents()[i].setx(1e-50); + } + } + } while ((Math.abs(err) > 1e-9 || err > errOld) && iter < 600); + // logger.info("err: " + err + " ITER " + iter); + double xTrivialCheck0 = 0.0; + double xTrivialCheck1 = 0.0; - if (Math.abs(xTrivialCheck0) < 1e-4 || Math.abs(xTrivialCheck1) < 1e-4) { - tm[j] = 10.0; - } + tm[j] = 1.0; - if (tm[j] < -1e-8) { - break; - } + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + if (system.getPhase(0).getComponent(i).getx() > 1e-100) { + tm[j] -= Math.exp(logWi[i]); } + x[j][i] = clonedSystem.get(0).getPhase(1).getComponents()[i].getx(); + // logger.info("txji: " + x[j][i]); + + xTrivialCheck0 += Math.abs(x[j][i] - system.getPhase(0).getComponent(i).getx()); + xTrivialCheck1 += Math.abs(x[j][i] - system.getPhase(1).getComponent(i).getx()); + } + if (iter >= 599) { + // logger.info("iter > maxiter multiphase stability "); + // logger.info("error " + Math.abs(err)); + // logger.info("tm: " + tm[j]); + } + + if (Math.abs(xTrivialCheck0) < 1e-4 || Math.abs(xTrivialCheck1) < 1e-4) { + tm[j] = 10.0; + } + + if (tm[j] < -1e-8) { + break; + } + } - int unstabcomp = 0; - for (int k = system.getPhase(0).getNumberOfComponents() - 1; k >= 0; k--) { - if (tm[k] < -1e-8 && !(Double.isNaN(tm[k]))) { - system.addPhase(); - unstabcomp = k; - for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { - system.getPhase(system.getNumberOfPhases() - 1).getComponents()[i] - .setx(x[k][i]); - } - system.getPhases()[system.getNumberOfPhases() - 1].normalize(); - multiPhaseTest = true; - system.setBeta(system.getNumberOfPhases() - 1, - system.getPhase(0).getComponent(unstabcomp).getz()); - system.init(1); - system.normalizeBeta(); - - // logger.info("STABILITY ANALYSIS: "); - // logger.info("tm1: " + k + " "+ tm[k]); - // system.display(); - return; - } + int unstabcomp = 0; + for (int k = system.getPhase(0).getNumberOfComponents() - 1; k >= 0; k--) { + if (tm[k] < -1e-8 && !(Double.isNaN(tm[k]))) { + system.addPhase(); + unstabcomp = k; + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + system.getPhase(system.getNumberOfPhases() - 1).getComponents()[i].setx(x[k][i]); } - + system.getPhases()[system.getNumberOfPhases() - 1].normalize(); + multiPhaseTest = true; + system.setBeta(system.getNumberOfPhases() - 1, + system.getPhase(0).getComponent(unstabcomp).getz()); + system.init(1); system.normalizeBeta(); + // logger.info("STABILITY ANALYSIS: "); - // logger.info("tm1: " + tm[0] + " tm2: " + tm[1]); + // logger.info("tm1: " + k + " "+ tm[k]); // system.display(); + return; + } } - /** - *

- * stabilityAnalysis2. - *

- */ - public void stabilityAnalysis2() { - double[] logWi = new double[system.getPhase(0).getNumberOfComponents()]; - double[][] Wi = new double[system.getPhase(0).getNumberOfComponents()][system.getPhase(0) - .getNumberOfComponents()]; - - double[] deltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; - double[] oldDeltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; - double[] oldoldDeltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; - double[] sumw = new double[system.getPhase(0).getNumberOfComponents()]; - double err = 0; - double[] oldlogw = new double[system.getPhase(0).getNumberOfComponents()]; - double[] oldoldlogw = new double[system.getPhases()[0].getNumberOfComponents()]; - double[] oldoldoldlogw = new double[system.getPhases()[0].getNumberOfComponents()]; - double[] d = new double[system.getPhase(0).getNumberOfComponents()]; - double[][] x = new double[system.getPhase(0).getNumberOfComponents()][system.getPhase(0) - .getNumberOfComponents()]; - tm = new double[system.getPhase(0).getNumberOfComponents()]; - - double[] alpha = null; - // SystemInterface minimumGibbsEnergySystem; - ArrayList clonedSystem = new ArrayList(1); - // if (minimumGibbsEnergySystem == null) { - // minimumGibbsEnergySystem = system.clone(); - // } - minimumGibbsEnergySystem = system; - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - if (system.getPhase(0).getComponent(i).getx() < 1e-100) { - clonedSystem.add(null); - continue; - } - double numb = 0; - clonedSystem.add(system.clone()); - // (clonedSystem.get(i)).init(0); commented out sept 2005, Even - // S. - for (int j = 0; j < system.getPhase(0).getNumberOfComponents(); j++) { - numb = i == j ? 1.0 : 1.0e-12; // set to 0 by Even Solbraa 23.01.2013 - chaged back - // to 1.0e-12 27.04.13 - if (system.getPhase(0).getComponent(j).getz() < 1e-100) { - numb = 0; - } - (clonedSystem.get(i)).getPhase(1).getComponents()[j].setx(numb); - } - if (system.getPhase(0).getComponent(i).getIonicCharge() == 0) { - (clonedSystem.get(i)).init(1); - } + system.normalizeBeta(); + // logger.info("STABILITY ANALYSIS: "); + // logger.info("tm1: " + tm[0] + " tm2: " + tm[1]); + // system.display(); + } + + /** + *

+ * stabilityAnalysis2. + *

+ */ + public void stabilityAnalysis2() { + double[] logWi = new double[system.getPhase(0).getNumberOfComponents()]; + double[][] Wi = new double[system.getPhase(0).getNumberOfComponents()][system.getPhase(0) + .getNumberOfComponents()]; + + double[] deltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] oldDeltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] oldoldDeltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] sumw = new double[system.getPhase(0).getNumberOfComponents()]; + double err = 0; + double[] oldlogw = new double[system.getPhase(0).getNumberOfComponents()]; + double[] oldoldlogw = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] oldoldoldlogw = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] d = new double[system.getPhase(0).getNumberOfComponents()]; + double[][] x = new double[system.getPhase(0).getNumberOfComponents()][system.getPhase(0) + .getNumberOfComponents()]; + tm = new double[system.getPhase(0).getNumberOfComponents()]; + + double[] alpha = null; + // SystemInterface minimumGibbsEnergySystem; + ArrayList clonedSystem = new ArrayList(1); + // if (minimumGibbsEnergySystem == null) { + // minimumGibbsEnergySystem = system.clone(); + // } + minimumGibbsEnergySystem = system; + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (system.getPhase(0).getComponent(i).getx() < 1e-100) { + clonedSystem.add(null); + continue; + } + double numb = 0; + clonedSystem.add(system.clone()); + // (clonedSystem.get(i)).init(0); commented out sept 2005, Even + // S. + for (int j = 0; j < system.getPhase(0).getNumberOfComponents(); j++) { + numb = i == j ? 1.0 : 1.0e-12; // set to 0 by Even Solbraa 23.01.2013 - chaged back + // to 1.0e-12 27.04.13 + if (system.getPhase(0).getComponent(j).getz() < 1e-100) { + numb = 0; } + (clonedSystem.get(i)).getPhase(1).getComponents()[j].setx(numb); + } + if (system.getPhase(0).getComponent(i).getIonicCharge() == 0) { + (clonedSystem.get(i)).init(1); + } + } - lowestGibbsEnergyPhase = 0; + lowestGibbsEnergyPhase = 0; - // logger.info("low gibbs phase " + lowestGibbsEnergyPhase); - for (int k = 0; k < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); k++) { - for (int i = 0; i < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); i++) { - if (!((clonedSystem.get(k)) == null)) { - sumw[k] += (clonedSystem.get(k)).getPhase(1).getComponents()[i].getx(); - } - } + // logger.info("low gibbs phase " + lowestGibbsEnergyPhase); + for (int k = 0; k < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); k++) { + for (int i = 0; i < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); i++) { + if (!((clonedSystem.get(k)) == null)) { + sumw[k] += (clonedSystem.get(k)).getPhase(1).getComponents()[i].getx(); } + } + } - for (int k = 0; k < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); k++) { - for (int i = 0; i < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); i++) { - if (!((clonedSystem.get(k)) == null) - && system.getPhase(0).getComponent(k).getx() > 1e-100) { - (clonedSystem.get(k)).getPhase(1).getComponents()[i].setx( - (clonedSystem.get(k)).getPhase(1).getComponents()[i].getx() / sumw[0]); - } - // logger.info("x: " + ( - // clonedSystem.get(k)).getPhase(0).getComponents()[i].getx()); - } - if (system.getPhase(0).getComponent(k).getx() > 1e-100) { - d[k] = Math.log(system.getPhase(0).getComponents()[k].getx()) - + system.getPhase(0).getComponents()[k].getLogFugacityCoefficient(); - // if(minimumGibbsEnergySystem.getPhases()[lowestGibbsEnergyPhase].getComponents()[k].getIonicCharge()!=0) - // d[k]=0; - } - // logger.info("dk: " + d[k]); + for (int k = 0; k < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); k++) { + for (int i = 0; i < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); i++) { + if (!((clonedSystem.get(k)) == null) + && system.getPhase(0).getComponent(k).getx() > 1e-100) { + (clonedSystem.get(k)).getPhase(1).getComponents()[i] + .setx((clonedSystem.get(k)).getPhase(1).getComponents()[i].getx() / sumw[0]); } + // logger.info("x: " + ( + // clonedSystem.get(k)).getPhase(0).getComponents()[i].getx()); + } + if (system.getPhase(0).getComponent(k).getx() > 1e-100) { + d[k] = Math.log(system.getPhase(0).getComponents()[k].getx()) + + system.getPhase(0).getComponents()[k].getLogFugacityCoefficient(); + // if(minimumGibbsEnergySystem.getPhases()[lowestGibbsEnergyPhase].getComponents()[k].getIonicCharge()!=0) + // d[k]=0; + } + // logger.info("dk: " + d[k]); + } - for (int j = 0; j < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); j++) { - if (system.getPhase(0).getComponent(j).getz() > 1e-100) { - logWi[j] = 1.0; - } else { - logWi[j] = -10000.0; - } - } + for (int j = 0; j < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); j++) { + if (system.getPhase(0).getComponent(j).getz() > 1e-100) { + logWi[j] = 1.0; + } else { + logWi[j] = -10000.0; + } + } - int hydrocarbonTestCompNumb = 0, lightTestCompNumb = 0; - double Mmax = 0, Mmin = 1e10; - for (int i = 0; i < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); i++) { - if (minimumGibbsEnergySystem.getPhase(0).getComponent(i).isHydrocarbon()) { - if ((minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass()) > Mmax) { - Mmax = minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass(); - } - if ((minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass()) < Mmin) { - Mmin = minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass(); - } - } + int hydrocarbonTestCompNumb = 0; + int lightTestCompNumb = 0; + double Mmax = 0; + double Mmin = 1e10; + for (int i = 0; i < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); i++) { + if (minimumGibbsEnergySystem.getPhase(0).getComponent(i).isHydrocarbon()) { + if ((minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass()) > Mmax) { + Mmax = minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass(); } - for (int i = 0; i < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); i++) { - if (minimumGibbsEnergySystem.getPhase(0).getComponent(i).isHydrocarbon() - && minimumGibbsEnergySystem.getPhase(0).getComponent(i).getz() > 1e-50) { - if (Math.abs((minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass()) - - Mmax) < 1e-5) { - hydrocarbonTestCompNumb = i; - // logger.info("CHECKING heavy component " + hydrocarbonTestCompNumb); - } - } - - if (minimumGibbsEnergySystem.getPhase(0).getComponent(i).isHydrocarbon() - && minimumGibbsEnergySystem.getPhase(0).getComponent(i).getz() > 1e-50) { - if (Math.abs((minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass()) - - Mmin) < 1e-5) { - lightTestCompNumb = i; - // logger.info("CHECKING light component " + lightTestCompNumb); - } - } + if ((minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass()) < Mmin) { + Mmin = minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass(); + } + } + } + for (int i = 0; i < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); i++) { + if (minimumGibbsEnergySystem.getPhase(0).getComponent(i).isHydrocarbon() + && minimumGibbsEnergySystem.getPhase(0).getComponent(i).getz() > 1e-50) { + if (Math.abs( + (minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass()) - Mmax) < 1e-5) { + hydrocarbonTestCompNumb = i; + // logger.info("CHECKING heavy component " + hydrocarbonTestCompNumb); + } + } + + if (minimumGibbsEnergySystem.getPhase(0).getComponent(i).isHydrocarbon() + && minimumGibbsEnergySystem.getPhase(0).getComponent(i).getz() > 1e-50) { + if (Math.abs( + (minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass()) - Mmin) < 1e-5) { + lightTestCompNumb = i; + // logger.info("CHECKING light component " + lightTestCompNumb); } + } + } - for (int j = system.getPhase(0).getNumberOfComponents() - 1; j >= 0; j--) { - if (minimumGibbsEnergySystem.getPhase(0).getComponent(j).getx() < 1e-100 - || (minimumGibbsEnergySystem.getPhase(0).getComponent(j).getIonicCharge() != 0) - || (minimumGibbsEnergySystem.getPhase(0).getComponent(j).isHydrocarbon() - && j != hydrocarbonTestCompNumb && j != lightTestCompNumb)) { - continue; + for (int j = system.getPhase(0).getNumberOfComponents() - 1; j >= 0; j--) { + if (minimumGibbsEnergySystem.getPhase(0).getComponent(j).getx() < 1e-100 + || (minimumGibbsEnergySystem.getPhase(0).getComponent(j).getIonicCharge() != 0) + || (minimumGibbsEnergySystem.getPhase(0).getComponent(j).isHydrocarbon() + && j != hydrocarbonTestCompNumb && j != lightTestCompNumb)) { + continue; + } + // if(minimumGibbsEnergySystem.getPhase(0).getComponent(j).getName().equals("water") + // && minimumGibbsEnergySystem.isChemicalSystem()) continue; + // logger.info("STAB CHECK COMP " + + // system.getPhase(0).getComponent(j).getComponentName()); + // if(minimumGibbsEnergySystem.getPhase(0).getComponent(j).isInert()) break; + int iter = 0; + double errOld = 1.0e100; + do { + errOld = err; + iter++; + err = 0; + + if (iter <= 20 || !system.isImplementedCompositionDeriativesofFugacity()) { + if (iter % 7 == 0) { + double vec1 = 0.0; + + double vec2 = 0.0; + double prod1 = 0.0; + double prod2 = 0.0; + for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + vec1 = oldDeltalogWi[i] * oldoldDeltalogWi[i]; + vec2 = Math.pow(oldoldDeltalogWi[i], 2.0); + prod1 += vec1 * vec2; + prod2 += vec2 * vec2; + } + + double lambda = prod1 / prod2; + // logger.info("lambda " + lambda); + for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + logWi[i] += lambda / (1.0 - lambda) * deltalogWi[i]; + err += Math.abs((logWi[i] - oldlogw[i]) / oldlogw[i]); + Wi[j][i] = Math.exp(logWi[i]); + } + } else { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + oldoldoldlogw[i] = oldoldlogw[i]; + oldoldlogw[i] = oldlogw[i]; + oldlogw[i] = logWi[i]; + oldoldDeltalogWi[i] = oldoldlogw[i] - oldoldoldlogw[i]; + oldDeltalogWi[i] = oldlogw[i] - oldoldlogw[i]; } - // if(minimumGibbsEnergySystem.getPhase(0).getComponent(j).getName().equals("water") - // && minimumGibbsEnergySystem.isChemicalSystem()) continue; - // logger.info("STAB CHECK COMP " + - // system.getPhase(0).getComponent(j).getComponentName()); - // if(minimumGibbsEnergySystem.getPhase(0).getComponent(j).isInert()) break; - int iter = 0; - double errOld = 1.0e100; - do { - errOld = err; - iter++; - err = 0; - - if (iter <= 20 || !system.isImplementedCompositionDeriativesofFugacity()) { - if (iter % 7 == 0) { - double vec1 = 0.0, vec2 = 0.0, prod1 = 0.0, prod2 = 0.0; - - for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - vec1 = oldDeltalogWi[i] * oldoldDeltalogWi[i]; - vec2 = Math.pow(oldoldDeltalogWi[i], 2.0); - prod1 += vec1 * vec2; - prod2 += vec2 * vec2; - } - - double lambda = prod1 / prod2; - // logger.info("lambda " + lambda); - for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - logWi[i] += lambda / (1.0 - lambda) * deltalogWi[i]; - err += Math.abs((logWi[i] - oldlogw[i]) / oldlogw[i]); - Wi[j][i] = Math.exp(logWi[i]); - } - } else { - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - oldoldoldlogw[i] = oldoldlogw[i]; - oldoldlogw[i] = oldlogw[i]; - oldlogw[i] = logWi[i]; - oldoldDeltalogWi[i] = oldoldlogw[i] - oldoldoldlogw[i]; - oldDeltalogWi[i] = oldlogw[i] - oldoldlogw[i]; - } - (clonedSystem.get(j)).init(1, 1); - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - // oldlogw[i] = logWi[i]; - if (!Double - .isInfinite((clonedSystem.get(j)).getPhase(1).getComponents()[i] - .getLogFugacityCoefficient()) - && system.getPhase(0).getComponent(i).getx() > 1e-100) { - logWi[i] = - d[i] - (clonedSystem.get(j)).getPhase(1).getComponents()[i] - .getLogFugacityCoefficient(); - if ((clonedSystem.get(j)).getPhase(1).getComponents()[i] - .getIonicCharge() != 0) { - logWi[i] = -1000.0; - } - } - deltalogWi[i] = logWi[i] - oldlogw[i]; - err += Math.abs(logWi[i] - oldlogw[i]); - Wi[j][i] = Math.exp(logWi[i]); - } - } - } else { - SimpleMatrix f = - new SimpleMatrix(system.getPhases()[0].getNumberOfComponents(), 1); - SimpleMatrix df = null; - SimpleMatrix identitytimesConst = null; - // if (!secondOrderStabilityAnalysis) { - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - oldoldoldlogw[i] = oldoldlogw[i]; - oldoldlogw[i] = oldlogw[i]; - oldlogw[i] = logWi[i]; - oldoldDeltalogWi[i] = oldoldlogw[i] - oldoldoldlogw[i]; - oldDeltalogWi[i] = oldlogw[i] - oldoldlogw[i]; - } - (clonedSystem.get(j)).init(3, 1); - alpha = new double[(clonedSystem.get(j)).getPhases()[0] - .getNumberOfComponents()]; - df = new SimpleMatrix(system.getPhases()[0].getNumberOfComponents(), - system.getPhases()[0].getNumberOfComponents()); - identitytimesConst = - SimpleMatrix.identity(system.getPhases()[0].getNumberOfComponents());// , - // system.getPhases()[0].getNumberOfComponents()); - // secondOrderStabilityAnalysis = true; - // } - - for (int i = 0; i < (clonedSystem.get(j)).getPhases()[0] - .getNumberOfComponents(); i++) { - alpha[i] = 2.0 * Math.sqrt(Wi[j][i]); - } - - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - if (system.getPhase(0).getComponent(i).getz() > 1e-100) { - f.set(i, 0, Math.sqrt(Wi[j][i]) * (Math.log(Wi[j][i]) - + (clonedSystem.get(j)).getPhases()[1].getComponents()[i] - .getLogFugacityCoefficient() - - d[i])); - } - for (int k = 0; k < (clonedSystem.get(j)).getPhases()[0] - .getNumberOfComponents(); k++) { - double kronDelt = (i == k) ? 1.0 : 0.0; - if (system.getPhase(0).getComponent(i).getz() > 1e-100) { - df.set(i, k, kronDelt + Math.sqrt(Wi[j][k] * Wi[j][i]) - * (clonedSystem.get(j)).getPhases()[1].getComponents()[i] - .getdfugdn(k));// * - // clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); - } else { - df.set(i, k, 0);// * - // clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); - } - } - } - // f.print(10, 10); - // df.print(10, 10); - SimpleMatrix dx = df.plus(identitytimesConst).solve(f).negative(); - // dx.print(10, 10); - - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - double alphaNew = alpha[i] + dx.get(i, 0); - Wi[j][i] = Math.pow(alphaNew / 2.0, 2.0); - if (system.getPhase(0).getComponent(i).getz() > 1e-100) { - logWi[i] = Math.log(Wi[j][i]); - } - if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { - logWi[i] = -1000.0; - } - err += Math.abs((logWi[i] - oldlogw[i]) / oldlogw[i]); - } - - // logger.info("err newton " + err); - } - // logger.info("err: " + err); - sumw[j] = 0; - - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - sumw[j] += Math.exp(logWi[i]); - } - - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - if (system.getPhase(0).getComponent(i).getx() > 1e-100) { - (clonedSystem.get(j)).getPhase(1).getComponents()[i] - .setx(Math.exp(logWi[i]) / sumw[j]); - } - if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { - (clonedSystem.get(j)).getPhase(1).getComponents()[i].setx(1e-50); - } - } - } while ((Math.abs(err) > 1e-9 || err > errOld) && iter < 200); - // logger.info("err: " + err + " ITER " + iter); - double xTrivialCheck0 = 0.0; - double xTrivialCheck1 = 0.0; - - tm[j] = 1.0; + (clonedSystem.get(j)).init(1, 1); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + // oldlogw[i] = logWi[i]; + if (!Double.isInfinite( + (clonedSystem.get(j)).getPhase(1).getComponents()[i].getLogFugacityCoefficient()) + && system.getPhase(0).getComponent(i).getx() > 1e-100) { + logWi[i] = d[i] - (clonedSystem.get(j)).getPhase(1).getComponents()[i] + .getLogFugacityCoefficient(); + if ((clonedSystem.get(j)).getPhase(1).getComponents()[i].getIonicCharge() != 0) { + logWi[i] = -1000.0; + } + } + deltalogWi[i] = logWi[i] - oldlogw[i]; + err += Math.abs(logWi[i] - oldlogw[i]); + Wi[j][i] = Math.exp(logWi[i]); + } + } + } else { + SimpleMatrix f = new SimpleMatrix(system.getPhases()[0].getNumberOfComponents(), 1); + SimpleMatrix df = null; + SimpleMatrix identitytimesConst = null; + // if (!secondOrderStabilityAnalysis) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + oldoldoldlogw[i] = oldoldlogw[i]; + oldoldlogw[i] = oldlogw[i]; + oldlogw[i] = logWi[i]; + oldoldDeltalogWi[i] = oldoldlogw[i] - oldoldoldlogw[i]; + oldDeltalogWi[i] = oldlogw[i] - oldoldlogw[i]; + } + (clonedSystem.get(j)).init(3, 1); + alpha = new double[(clonedSystem.get(j)).getPhases()[0].getNumberOfComponents()]; + df = new SimpleMatrix(system.getPhases()[0].getNumberOfComponents(), + system.getPhases()[0].getNumberOfComponents()); + identitytimesConst = SimpleMatrix.identity(system.getPhases()[0].getNumberOfComponents());// , + // system.getPhases()[0].getNumberOfComponents()); + // secondOrderStabilityAnalysis = true; + // } + + for (int i = 0; i < (clonedSystem.get(j)).getPhases()[0].getNumberOfComponents(); i++) { + alpha[i] = 2.0 * Math.sqrt(Wi[j][i]); + } + + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (system.getPhase(0).getComponent(i).getz() > 1e-100) { + f.set(i, 0, Math.sqrt(Wi[j][i]) + * (Math.log(Wi[j][i]) + (clonedSystem.get(j)).getPhases()[1].getComponents()[i] + .getLogFugacityCoefficient() - d[i])); + } + for (int k = 0; k < (clonedSystem.get(j)).getPhases()[0].getNumberOfComponents(); k++) { + double kronDelt = (i == k) ? 1.0 : 0.0; + if (system.getPhase(0).getComponent(i).getz() > 1e-100) { + df.set(i, k, kronDelt + Math.sqrt(Wi[j][k] * Wi[j][i]) + * (clonedSystem.get(j)).getPhases()[1].getComponents()[i].getdfugdn(k));// * + // clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); + } else { + df.set(i, k, 0);// * + // clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); + } + } + } + // f.print(10, 10); + // df.print(10, 10); + SimpleMatrix dx = df.plus(identitytimesConst).solve(f).negative(); + // dx.print(10, 10); + + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + double alphaNew = alpha[i] + dx.get(i, 0); + Wi[j][i] = Math.pow(alphaNew / 2.0, 2.0); + if (system.getPhase(0).getComponent(i).getz() > 1e-100) { + logWi[i] = Math.log(Wi[j][i]); + } + if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { + logWi[i] = -1000.0; + } + err += Math.abs((logWi[i] - oldlogw[i]) / oldlogw[i]); + } + + // logger.info("err newton " + err); + } + // logger.info("err: " + err); + sumw[j] = 0; - for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { - if (system.getPhase(0).getComponent(i).getx() > 1e-100) { - tm[j] -= Math.exp(logWi[i]); - } - x[j][i] = (clonedSystem.get(j)).getPhase(1).getComponents()[i].getx(); - // logger.info("txji: " + x[j][i]); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + sumw[j] += Math.exp(logWi[i]); + } - xTrivialCheck0 += Math.abs(x[j][i] - system.getPhase(0).getComponent(i).getx()); - xTrivialCheck1 += Math.abs(x[j][i] - system.getPhase(1).getComponent(i).getx()); - } - if (iter >= 199) { - logger.info("iter > maxiter multiphase stability "); - logger.info("error " + Math.abs(err)); - logger.info("tm: " + tm[j]); - } + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (system.getPhase(0).getComponent(i).getx() > 1e-100) { + (clonedSystem.get(j)).getPhase(1).getComponents()[i].setx(Math.exp(logWi[i]) / sumw[j]); + } + if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { + (clonedSystem.get(j)).getPhase(1).getComponents()[i].setx(1e-50); + } + } + } while ((Math.abs(err) > 1e-9 || err > errOld) && iter < 200); + // logger.info("err: " + err + " ITER " + iter); + double xTrivialCheck0 = 0.0; + double xTrivialCheck1 = 0.0; - if (Math.abs(xTrivialCheck0) < 1e-6 || Math.abs(xTrivialCheck1) < 1e-6) { - tm[j] = 10.0; - } + tm[j] = 1.0; - if (tm[j] < -1e-8) { - break; - } + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + if (system.getPhase(0).getComponent(i).getx() > 1e-100) { + tm[j] -= Math.exp(logWi[i]); } + x[j][i] = (clonedSystem.get(j)).getPhase(1).getComponents()[i].getx(); + // logger.info("txji: " + x[j][i]); + + xTrivialCheck0 += Math.abs(x[j][i] - system.getPhase(0).getComponent(i).getx()); + xTrivialCheck1 += Math.abs(x[j][i] - system.getPhase(1).getComponent(i).getx()); + } + if (iter >= 199) { + logger.info("iter > maxiter multiphase stability "); + logger.info("error " + Math.abs(err)); + logger.info("tm: " + tm[j]); + } + + if (Math.abs(xTrivialCheck0) < 1e-6 || Math.abs(xTrivialCheck1) < 1e-6) { + tm[j] = 10.0; + } + + if (tm[j] < -1e-8) { + break; + } + } - int unstabcomp = 0; - for (int k = system.getPhase(0).getNumberOfComponents() - 1; k >= 0; k--) { - if (tm[k] < -1e-8 && !(Double.isNaN(tm[k]))) { - system.addPhase(); - unstabcomp = k; - for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { - system.getPhase(system.getNumberOfPhases() - 1).getComponents()[i] - .setx(x[k][i]); - } - system.getPhases()[system.getNumberOfPhases() - 1].normalize(); - multiPhaseTest = true; - system.setBeta(system.getNumberOfPhases() - 1, - system.getPhase(0).getComponent(unstabcomp).getz()); - system.init(1); - system.normalizeBeta(); - - // logger.info("STABILITY ANALYSIS: "); - // logger.info("tm1: " + k + " "+ tm[k]); - // system.display(); - return; - } + int unstabcomp = 0; + for (int k = system.getPhase(0).getNumberOfComponents() - 1; k >= 0; k--) { + if (tm[k] < -1e-8 && !(Double.isNaN(tm[k]))) { + system.addPhase(); + unstabcomp = k; + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + system.getPhase(system.getNumberOfPhases() - 1).getComponents()[i].setx(x[k][i]); } + system.getPhases()[system.getNumberOfPhases() - 1].normalize(); + multiPhaseTest = true; + system.setBeta(system.getNumberOfPhases() - 1, + system.getPhase(0).getComponent(unstabcomp).getz()); + system.init(1); system.normalizeBeta(); + // logger.info("STABILITY ANALYSIS: "); - // logger.info("tm1: " + tm[0] + " tm2: " + tm[1]); + // logger.info("tm1: " + k + " "+ tm[k]); // system.display(); + return; + } + } + system.normalizeBeta(); + // logger.info("STABILITY ANALYSIS: "); + // logger.info("tm1: " + tm[0] + " tm2: " + tm[1]); + // system.display(); + } + + /** {@inheritDoc} */ + @Override + public void run() { + int aqueousPhaseNumber = 0; + // logger.info("Starting multiphase-flash...."); + + // system.setNumberOfPhases(system.getNumberOfPhases()+1); + if (doStabilityAnalysis) { + stabilityAnalysis(); + } + // system.orderByDensity(); + doStabilityAnalysis = true; + // system.init(1); + // system.display(); + aqueousPhaseNumber = system.getPhaseNumberOfPhase("aqueous"); + if (system.isChemicalSystem()) { + system.getChemicalReactionOperations().solveChemEq(system.getPhaseNumberOfPhase("aqueous"), + 0); + system.getChemicalReactionOperations().solveChemEq(system.getPhaseNumberOfPhase("aqueous"), + 1); } - /** {@inheritDoc} */ - @Override - public void run() { - int aqueousPhaseNumber = 0; - // logger.info("Starting multiphase-flash...."); + int iterations = 0; + if (multiPhaseTest) {// && !system.isChemicalSystem()) { + double diff = 1.0e10; - // system.setNumberOfPhases(system.getNumberOfPhases()+1); - if (doStabilityAnalysis) { - stabilityAnalysis(); - } - // system.orderByDensity(); - doStabilityAnalysis = true; - // system.init(1); - // system.display(); - aqueousPhaseNumber = system.getPhaseNumberOfPhase("aqueous"); + double oldDiff = 1.0e10; + double chemdev = 0; + int iterOut = 0; + do { + iterOut++; if (system.isChemicalSystem()) { + if (system.getPhaseNumberOfPhase("aqueous") != aqueousPhaseNumber) { + aqueousPhaseNumber = system.getPhaseNumberOfPhase("aqueous"); system.getChemicalReactionOperations() - .solveChemEq(system.getPhaseNumberOfPhase("aqueous"), 0); - system.getChemicalReactionOperations() - .solveChemEq(system.getPhaseNumberOfPhase("aqueous"), 1); - } + .solveChemEq(system.getPhaseNumberOfPhase("aqueous"), 0); + // system.getChemicalReactionOperations().solveChemEq(system.getPhaseNumberOfPhase("aqueous"), + // 1); + } - int iterations = 0; - if (multiPhaseTest) {// && !system.isChemicalSystem()) { - // double oldBeta = 1.0; - double diff = 1.0e10, oldDiff = 1.0e10; - - double chemdev = 0; - int iterOut = 0; - do { - iterOut++; - if (system.isChemicalSystem()) { - if (system.getPhaseNumberOfPhase("aqueous") != aqueousPhaseNumber) { - aqueousPhaseNumber = system.getPhaseNumberOfPhase("aqueous"); - system.getChemicalReactionOperations() - .solveChemEq(system.getPhaseNumberOfPhase("aqueous"), 0); - // system.getChemicalReactionOperations().solveChemEq(system.getPhaseNumberOfPhase("aqueous"), - // 1); - } - - for (int phase = system.getPhaseNumberOfPhase("aqueous"); phase < system - .getPhaseNumberOfPhase("aqueous") + 1; phase++) { - chemdev = 0.0; - double xchem[] = new double[system.getPhase(phase).getNumberOfComponents()]; - - for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - xchem[i] = system.getPhase(phase).getComponents()[i].getx(); - } - - system.init(1); - system.getChemicalReactionOperations() - .solveChemEq(system.getPhaseNumberOfPhase("aqueous"), 1); - - for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - chemdev += Math.abs( - xchem[i] - system.getPhase(phase).getComponents()[i].getx()); - } - // logger.info("chemdev: " + chemdev); - } - } - setDoubleArrays(); - iterations = 0; - do { - iterations++; - // oldBeta = system.getBeta(system.getNumberOfPhases() - 1); - // system.init(1); - oldDiff = diff; - diff = this.solveBeta(); - // diff = Math.abs((system.getBeta(system.getNumberOfPhases() - 1) - oldBeta) / - // oldBeta); - // logger.info("diff multiphase " + diff); - } while (diff > 1e-12 && !removePhase && (diff < oldDiff || iterations < 50) - && iterations < 200); - // this.solveBeta(true); - if (iterations >= 199) { - logger.error("error in multiphase flash..did not solve in 200 iterations"); - diff = this.solveBeta(); - } - } while ((Math.abs(chemdev) > 1e-10 && iterOut < 100) - || (iterOut < 3 && system.isChemicalSystem())); - - boolean hasRemovedPhase = false; - for (int i = 0; i < system.getNumberOfPhases(); i++) { - if (system.getBeta(i) < ThermodynamicModelSettings.phaseFractionMinimumLimit - * 1.1) { - system.removePhaseKeepTotalComposition(i); - doStabilityAnalysis = false; - hasRemovedPhase = true; - } - } + for (int phase = system.getPhaseNumberOfPhase("aqueous"); phase < system + .getPhaseNumberOfPhase("aqueous") + 1; phase++) { + chemdev = 0.0; + double[] xchem = new double[system.getPhase(phase).getNumberOfComponents()]; - boolean trivialSolution = false; - for (int i = 0; i < system.getNumberOfPhases() - 1; i++) { - for (int j = 0; j < system.getPhase(i).getNumberOfComponents(); j++) { - if (Math.abs(system.getPhase(i).getDensity() - - system.getPhase(i + 1).getDensity()) < 1.1e-5) { - trivialSolution = true; - } - } + for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + xchem[i] = system.getPhase(phase).getComponents()[i].getx(); } - if (trivialSolution && !hasRemovedPhase) { - for (int i = 0; i < system.getNumberOfPhases() - 1; i++) { - if (Math.abs(system.getPhase(i).getDensity() - - system.getPhase(i + 1).getDensity()) < 1.1e-5) { - system.removePhaseKeepTotalComposition(i + 1); - doStabilityAnalysis = false; - hasRemovedPhase = true; - } - } - } + system.init(1); + system.getChemicalReactionOperations() + .solveChemEq(system.getPhaseNumberOfPhase("aqueous"), 1); - /* - * for (int i = 0; i < system.getNumberOfPhases()-1; i++) { if - * (Math.abs(system.getPhase(i).getDensity()-system.getPhase(i+1).getDensity())< 1e-6 && - * !hasRemovedPhase) { system.removePhase(i+1); doStabilityAnalysis=false; - * hasRemovedPhase = true; } } - */ - if (hasRemovedPhase && !secondTime) { - secondTime = true; - run(); + for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + chemdev += Math.abs(xchem[i] - system.getPhase(phase).getComponents()[i].getx()); } - /* - * if (!secondTime) { secondTime = true; doStabilityAnalysis = false; run(); } - */ + // logger.info("chemdev: " + chemdev); + } + } + setDoubleArrays(); + iterations = 0; + do { + iterations++; + // oldBeta = system.getBeta(system.getNumberOfPhases() - 1); + // system.init(1); + oldDiff = diff; + diff = this.solveBeta(); + // diff = Math.abs((system.getBeta(system.getNumberOfPhases() - 1) - oldBeta) / + // oldBeta); + // logger.info("diff multiphase " + diff); + } while (diff > 1e-12 && !removePhase && (diff < oldDiff || iterations < 50) + && iterations < 200); + // this.solveBeta(true); + if (iterations >= 199) { + logger.error("error in multiphase flash..did not solve in 200 iterations"); + diff = this.solveBeta(); + } + } while ((Math.abs(chemdev) > 1e-10 && iterOut < 100) + || (iterOut < 3 && system.isChemicalSystem())); + + boolean hasRemovedPhase = false; + for (int i = 0; i < system.getNumberOfPhases(); i++) { + if (system.getBeta(i) < ThermodynamicModelSettings.phaseFractionMinimumLimit * 1.1) { + system.removePhaseKeepTotalComposition(i); + doStabilityAnalysis = false; + hasRemovedPhase = true; + } + } + + boolean trivialSolution = false; + for (int i = 0; i < system.getNumberOfPhases() - 1; i++) { + for (int j = 0; j < system.getPhase(i).getNumberOfComponents(); j++) { + if (Math.abs( + system.getPhase(i).getDensity() - system.getPhase(i + 1).getDensity()) < 1.1e-5) { + trivialSolution = true; + } + } + } + + if (trivialSolution && !hasRemovedPhase) { + for (int i = 0; i < system.getNumberOfPhases() - 1; i++) { + if (Math.abs( + system.getPhase(i).getDensity() - system.getPhase(i + 1).getDensity()) < 1.1e-5) { + system.removePhaseKeepTotalComposition(i + 1); + doStabilityAnalysis = false; + hasRemovedPhase = true; + } } + } + + /* + * for (int i = 0; i < system.getNumberOfPhases()-1; i++) { if + * (Math.abs(system.getPhase(i).getDensity()-system.getPhase(i+1).getDensity())< 1e-6 && + * !hasRemovedPhase) { system.removePhase(i+1); doStabilityAnalysis=false; hasRemovedPhase = + * true; } } + */ + if (hasRemovedPhase && !secondTime) { + secondTime = true; + run(); + } + /* + * if (!secondTime) { secondTime = true; doStabilityAnalysis = false; run(); } + */ } + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash_1.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash_1.java index b1c187b258..bbee1336a9 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash_1.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash_1.java @@ -20,319 +20,312 @@ * @version $Id: $Id */ public class TPmultiflash_1 extends TPflash { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(TPmultiflash_1.class); - - // SystemInterface clonedSystem; - boolean multiPhaseTest = false; - double dQdbeta[]; - double Qmatrix[][]; - double E[]; - double Q = 0; - - /** - *

- * Constructor for TPmultiflash_1. - *

- */ - public TPmultiflash_1() {} - - /** - *

- * Constructor for TPmultiflash_1. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public TPmultiflash_1(SystemInterface system) { - super(system); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(TPmultiflash_1.class); + + // SystemInterface clonedSystem; + boolean multiPhaseTest = false; + double[] dQdbeta; + double Qmatrix[][]; + double[] E; + double Q = 0; + + /** + *

+ * Constructor for TPmultiflash_1. + *

+ */ + public TPmultiflash_1() {} + + /** + *

+ * Constructor for TPmultiflash_1. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public TPmultiflash_1(SystemInterface system) { + super(system); + } + + /** + *

+ * Constructor for TPmultiflash_1. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param check a boolean + */ + public TPmultiflash_1(SystemInterface system, boolean check) { + super(system, check); + } + + /** + *

+ * calcMultiPhaseBeta. + *

+ */ + public void calcMultiPhaseBeta() {} + + /** + *

+ * setXY. + *

+ */ + public void setXY() { + for (int k = 0; k < system.getNumberOfPhases(); k++) { + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + system.getPhases()[k].getComponents()[i] + .setx(system.getPhases()[k].getComponents()[i].getz() / E[i] + / system.getPhases()[k].getComponents()[i].getFugacityCoefficient()); + } + } + } + + /** + *

+ * calcE. + *

+ */ + public void calcE() { + E = new double[system.getPhases()[0].getNumberOfComponents()]; + + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + for (int k = 0; k < system.getNumberOfPhases(); k++) { + E[i] += system.getPhases()[k].getBeta() + / system.getPhases()[k].getComponents()[i].getFugacityCoefficient(); + } + } + } + + /** + *

+ * calcQ. + *

+ * + * @return a double + */ + public double calcQ() { + Q = 0; + double betaTotal = 0; + dQdbeta = new double[system.getNumberOfPhases()]; + Qmatrix = new double[system.getNumberOfPhases()][system.getNumberOfPhases()]; + + for (int k = 0; k < system.getNumberOfPhases(); k++) { + betaTotal += system.getPhases()[k].getBeta(); } - /** - *

- * Constructor for TPmultiflash_1. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param check a boolean - */ - public TPmultiflash_1(SystemInterface system, boolean check) { - super(system, check); + Q = betaTotal; + this.calcE(); + + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + Q -= Math.log(E[i]) * system.getPhases()[0].getComponents()[i].getz(); } - /** - *

- * calcMultiPhaseBeta. - *

- */ - public void calcMultiPhaseBeta() {} - - /** - *

- * setXY. - *

- */ - public void setXY() { - for (int k = 0; k < system.getNumberOfPhases(); k++) { - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - system.getPhases()[k].getComponents()[i] - .setx(system.getPhases()[k].getComponents()[i].getz() / E[i] - / system.getPhases()[k].getComponents()[i] - .getFugacityCoefficient()); - } - } + for (int k = 0; k < system.getNumberOfPhases(); k++) { + dQdbeta[k] = 1.0; + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + dQdbeta[k] -= system.getPhases()[0].getComponents()[i].getz() * 1.0 / E[i] + / system.getPhases()[k].getComponents()[i].getFugacityCoefficient(); + } } - /** - *

- * calcE. - *

- */ - public void calcE() { - E = new double[system.getPhases()[0].getNumberOfComponents()]; - - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - for (int k = 0; k < system.getNumberOfPhases(); k++) { - E[i] += system.getPhases()[k].getBeta() - / system.getPhases()[k].getComponents()[i].getFugacityCoefficient(); - } + for (int i = 0; i < system.getNumberOfPhases(); i++) { + for (int j = 0; j < system.getNumberOfPhases(); j++) { + Qmatrix[i][j] = 0; + for (int k = 0; k < system.getPhases()[0].getNumberOfComponents(); k++) { + Qmatrix[i][j] += system.getPhases()[0].getComponents()[k].getz() + / (E[k] * E[k] * system.getPhases()[j].getComponents()[k].getFugacityCoefficient() + * system.getPhases()[i].getComponents()[k].getFugacityCoefficient()); } + } } - - /** - *

- * calcQ. - *

- * - * @return a double - */ - public double calcQ() { - Q = 0; - double betaTotal = 0; - dQdbeta = new double[system.getNumberOfPhases()]; - Qmatrix = new double[system.getNumberOfPhases()][system.getNumberOfPhases()]; - - for (int k = 0; k < system.getNumberOfPhases(); k++) { - betaTotal += system.getPhases()[k].getBeta(); + return Q; + } + + /** + *

+ * solveBeta. + *

+ */ + public void solveBeta() { + double[] oldBeta = new double[system.getNumberOfPhases()]; + // double newBeta[] = new double[system.getNumberOfPhases()]; + + Matrix ans; + int iter = 1; + do { + iter++; + for (int k = 0; k < system.getNumberOfPhases(); k++) { + oldBeta[k] = system.getPhases()[k].getBeta(); + } + + calcQ(); + + Matrix betaMatrix = new Matrix(oldBeta, 1).transpose(); + Matrix dQM = new Matrix(dQdbeta, 1); + Matrix dQdBM = new Matrix(Qmatrix); + + ans = dQdBM.solve(dQM.transpose()); + betaMatrix.minusEquals(ans.times(iter / (iter + 20.0))); + // ans.print(10,2); + betaMatrix.print(10, 2); + + for (int k = 0; k < system.getNumberOfPhases(); k++) { + system.setBeta(k, betaMatrix.get(k, 0)); + if (betaMatrix.get(k, 0) < 0) { + system.setBeta(k, 1.0e-9); } - - Q = betaTotal; - this.calcE(); - - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - Q -= Math.log(E[i]) * system.getPhases()[0].getComponents()[i].getz(); + if (betaMatrix.get(k, 0) > 1) { + system.setBeta(k, 1.0 - 1e-9); } + } + + calcE(); + setXY(); + system.init(1); + } while (ans.norm2() > 1e-6); + } + + /** {@inheritDoc} */ + @Override + public void stabilityAnalysis() { + double[] logWi = new double[system.getPhases()[1].getNumberOfComponents()]; + double[][] Wi = new double[system.getPhases()[1].getNumberOfComponents()][system.getPhases()[0] + .getNumberOfComponents()]; + double[] sumw = new double[system.getPhases()[1].getNumberOfComponents()]; + double err = 0; + double[] oldlogw = new double[system.getPhases()[1].getNumberOfComponents()]; + double[] d = new double[system.getPhases()[1].getNumberOfComponents()]; + double[][] x = new double[system.getPhases()[1].getNumberOfComponents()][system.getPhases()[0] + .getNumberOfComponents()]; + + SystemInterface minimumGibbsEnergySystem; + ArrayList clonedSystem = new ArrayList(1); + + minimumGibbsEnergySystem = system.clone(); + + for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + double numb = 0; + clonedSystem.add(system.clone()); + (clonedSystem.get(i)).init(0); + for (int j = 0; j < system.getPhases()[1].getNumberOfComponents(); j++) { + numb = i == j ? 1.0 : 1.0e-3; + (clonedSystem.get(i)).getPhases()[1].getComponents()[j].setx(numb); + } + (clonedSystem.get(i)).init(1); + } - for (int k = 0; k < system.getNumberOfPhases(); k++) { - dQdbeta[k] = 1.0; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - dQdbeta[k] -= system.getPhases()[0].getComponents()[i].getz() * 1.0 / E[i] - / system.getPhases()[k].getComponents()[i].getFugacityCoefficient(); - } - } + lowestGibbsEnergyPhase = 0; - for (int i = 0; i < system.getNumberOfPhases(); i++) { - for (int j = 0; j < system.getNumberOfPhases(); j++) { - Qmatrix[i][j] = 0; - for (int k = 0; k < system.getPhases()[0].getNumberOfComponents(); k++) { - Qmatrix[i][j] += system.getPhases()[0].getComponents()[k].getz() / (E[k] * E[k] - * system.getPhases()[j].getComponents()[k].getFugacityCoefficient() - * system.getPhases()[i].getComponents()[k].getFugacityCoefficient()); - } - } - } - return Q; + // logger.info("low gibbs phase " + lowestGibbsEnergyPhase); + + for (int k = 0; k < minimumGibbsEnergySystem.getPhases()[1].getNumberOfComponents(); k++) { + // sumz += minimumGibbsEnergySystem.getPhases()[1].getComponents()[k].getz(); + for (int i = 0; i < minimumGibbsEnergySystem.getPhases()[1].getNumberOfComponents(); i++) { + sumw[k] += (clonedSystem.get(k)).getPhases()[1].getComponents()[i].getx(); + } } - /** - *

- * solveBeta. - *

- */ - public void solveBeta() { - double oldBeta[] = new double[system.getNumberOfPhases()]; - // double newBeta[] = new double[system.getNumberOfPhases()]; - - Matrix ans; - int iter = 1; - do { - iter++; - for (int k = 0; k < system.getNumberOfPhases(); k++) { - oldBeta[k] = system.getPhases()[k].getBeta(); - } - - calcQ(); - - Matrix betaMatrix = new Matrix(oldBeta, 1).transpose(); - Matrix dQM = new Matrix(dQdbeta, 1); - Matrix dQdBM = new Matrix(Qmatrix); - - ans = dQdBM.solve(dQM.transpose()); - betaMatrix.minusEquals(ans.times(iter / (iter + 20.0))); - // ans.print(10,2); - betaMatrix.print(10, 2); - - for (int k = 0; k < system.getNumberOfPhases(); k++) { - system.setBeta(k, betaMatrix.get(k, 0)); - if (betaMatrix.get(k, 0) < 0) { - system.setBeta(k, 1.0e-9); - } - if (betaMatrix.get(k, 0) > 1) { - system.setBeta(k, 1.0 - 1e-9); - } - } - - calcE(); - setXY(); - system.init(1); - } while (ans.norm2() > 1e-6); + for (int k = 0; k < minimumGibbsEnergySystem.getPhases()[1].getNumberOfComponents(); k++) { + for (int i = 0; i < minimumGibbsEnergySystem.getPhases()[1].getNumberOfComponents(); i++) { + (clonedSystem.get(k)).getPhases()[1].getComponents()[i] + .setx((clonedSystem.get(k)).getPhases()[1].getComponents()[i].getx() / sumw[0]); + // logger.info("x: " + ( + // clonedSystem.get(k)).getPhases()[0].getComponents()[i].getx()); + } + d[k] = Math.log( + minimumGibbsEnergySystem.getPhases()[lowestGibbsEnergyPhase].getComponents()[k].getx()) + + Math.log(minimumGibbsEnergySystem.getPhases()[lowestGibbsEnergyPhase].getComponents()[k] + .getFugacityCoefficient()); + // logger.info("dk: " + d[k]); } - /** {@inheritDoc} */ - @Override - public void stabilityAnalysis() { - double[] logWi = new double[system.getPhases()[1].getNumberOfComponents()]; - double[][] Wi = new double[system.getPhases()[1] - .getNumberOfComponents()][system.getPhases()[0].getNumberOfComponents()]; - double[] sumw = new double[system.getPhases()[1].getNumberOfComponents()]; - // double sumz = 0; - double err = 0; - double[] oldlogw = new double[system.getPhases()[1].getNumberOfComponents()]; - double[] d = new double[system.getPhases()[1].getNumberOfComponents()]; - double[][] x = new double[system.getPhases()[1] - .getNumberOfComponents()][system.getPhases()[0].getNumberOfComponents()]; - - SystemInterface minimumGibbsEnergySystem; - ArrayList clonedSystem = new ArrayList(1); - - minimumGibbsEnergySystem = system.clone(); + for (int j = 0; j < minimumGibbsEnergySystem.getPhases()[1].getNumberOfComponents(); j++) { + logWi[j] = 1; + } + for (int j = 0; j < system.getPhases()[1].getNumberOfComponents(); j++) { + do { + err = 0; + (clonedSystem.get(j)).init(1); for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - double numb = 0; - clonedSystem.add(system.clone()); - (clonedSystem.get(i)).init(0); - for (int j = 0; j < system.getPhases()[1].getNumberOfComponents(); j++) { - numb = i == j ? 1.0 : 1.0e-3; - (clonedSystem.get(i)).getPhases()[1].getComponents()[j].setx(numb); - } - (clonedSystem.get(i)).init(1); + oldlogw[i] = logWi[i]; + logWi[i] = d[i] - Math.log( + (clonedSystem.get(j)).getPhases()[1].getComponents()[i].getFugacityCoefficient()); + err += Math.abs(logWi[i] - oldlogw[i]); + Wi[j][i] = Math.exp(logWi[i]); } + // logger.info("err: " + err); + sumw[j] = 0; - lowestGibbsEnergyPhase = 0; - - // logger.info("low gibbs phase " + lowestGibbsEnergyPhase); - - for (int k = 0; k < minimumGibbsEnergySystem.getPhases()[1].getNumberOfComponents(); k++) { - // sumz += minimumGibbsEnergySystem.getPhases()[1].getComponents()[k].getz(); - for (int i = 0; i < minimumGibbsEnergySystem.getPhases()[1] - .getNumberOfComponents(); i++) { - sumw[k] += (clonedSystem.get(k)).getPhases()[1].getComponents()[i].getx(); - } + for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + sumw[j] += Math.exp(logWi[i]); } - for (int k = 0; k < minimumGibbsEnergySystem.getPhases()[1].getNumberOfComponents(); k++) { - for (int i = 0; i < minimumGibbsEnergySystem.getPhases()[1] - .getNumberOfComponents(); i++) { - (clonedSystem.get(k)).getPhases()[1].getComponents()[i].setx( - (clonedSystem.get(k)).getPhases()[1].getComponents()[i].getx() / sumw[0]); - // logger.info("x: " + ( - // clonedSystem.get(k)).getPhases()[0].getComponents()[i].getx()); - } - d[k] = Math.log( - minimumGibbsEnergySystem.getPhases()[lowestGibbsEnergyPhase].getComponents()[k] - .getx()) - + Math.log(minimumGibbsEnergySystem.getPhases()[lowestGibbsEnergyPhase] - .getComponents()[k].getFugacityCoefficient()); - // logger.info("dk: " + d[k]); + for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + (clonedSystem.get(j)).getPhases()[1].getComponents()[i] + .setx(Math.exp(logWi[i]) / sumw[j]); } + } while (Math.abs(err) > 1e-9); - for (int j = 0; j < minimumGibbsEnergySystem.getPhases()[1].getNumberOfComponents(); j++) { - logWi[j] = 1; - } + tm[j] = 1.0; - for (int j = 0; j < system.getPhases()[1].getNumberOfComponents(); j++) { - do { - err = 0; - (clonedSystem.get(j)).init(1); - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - oldlogw[i] = logWi[i]; - logWi[i] = - d[i] - Math.log((clonedSystem.get(j)).getPhases()[1].getComponents()[i] - .getFugacityCoefficient()); - err += Math.abs(logWi[i] - oldlogw[i]); - Wi[j][i] = Math.exp(logWi[i]); - } - // logger.info("err: " + err); - sumw[j] = 0; - - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - sumw[j] += Math.exp(logWi[i]); - } - - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - (clonedSystem.get(j)).getPhases()[1].getComponents()[i] - .setx(Math.exp(logWi[i]) / sumw[j]); - } - } while (Math.abs(err) > 1e-9); - - tm[j] = 1.0; - - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - tm[j] -= Math.exp(logWi[i]); - x[j][i] = (clonedSystem.get(j)).getPhases()[1].getComponents()[i].getx(); - // logger.info("txji: " + x[j][i]); - } - logger.info("tm: " + tm[j]); - } - int unstabcomp = 0; - for (int k = 0; k < system.getPhases()[1].getNumberOfComponents(); k++) { - if (tm[k] < -1e-8 && !(Double.isNaN(tm[k]))) { - system.addPhase(); - unstabcomp = k; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - system.getPhases()[2].getComponents()[i].setx(x[k][i]); - } - multiPhaseTest = true; - system.setBeta(system.getNumberOfPhases() - 1, - system.getPhase(0).getComponent(unstabcomp).getz()); - return; - } + for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + tm[j] -= Math.exp(logWi[i]); + x[j][i] = (clonedSystem.get(j)).getPhases()[1].getComponents()[i].getx(); + // logger.info("txji: " + x[j][i]); + } + logger.info("tm: " + tm[j]); + } + int unstabcomp = 0; + for (int k = 0; k < system.getPhases()[1].getNumberOfComponents(); k++) { + if (tm[k] < -1e-8 && !(Double.isNaN(tm[k]))) { + system.addPhase(); + unstabcomp = k; + for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + system.getPhases()[2].getComponents()[i].setx(x[k][i]); } + multiPhaseTest = true; + system.setBeta(system.getNumberOfPhases() - 1, + system.getPhase(0).getComponent(unstabcomp).getz()); + return; + } + } + + // logger.info("STABILITY ANALYSIS: "); + // logger.info("tm1: " + tm[0] + " tm2: " + tm[1]);*/ + } + + /** {@inheritDoc} */ + @Override + public void run() { + logger.info("Starting multiphase-flash...."); + stabilityAnalysis(); + system.init(1); - // logger.info("STABILITY ANALYSIS: "); - // logger.info("tm1: " + tm[0] + " tm2: " + tm[1]);*/ + if (multiPhaseTest && !system.isChemicalSystem()) { + this.solveBeta(); } - /** {@inheritDoc} */ - @Override - public void run() { - logger.info("Starting multiphase-flash...."); - stabilityAnalysis(); - system.init(1); + double chemdev = 0; + if (system.isChemicalSystem()) { + for (int phase = 0; phase < system.getNumberOfPhases(); phase++) { + chemdev = 0.0; + double[] xchem = new double[system.getPhases()[phase].getNumberOfComponents()]; - if (multiPhaseTest && !system.isChemicalSystem()) { - this.solveBeta(); + for (i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + xchem[i] = system.getPhases()[phase].getComponents()[i].getx(); } - double chemdev = 0; - if (system.isChemicalSystem()) { - for (int phase = 0; phase < system.getNumberOfPhases(); phase++) { - chemdev = 0.0; - double xchem[] = new double[system.getPhases()[phase].getNumberOfComponents()]; - - for (i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - xchem[i] = system.getPhases()[phase].getComponents()[i].getx(); - } - - system.init(1); - system.getChemicalReactionOperations().solveChemEq(phase, 1); - - for (i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - chemdev += Math - .abs(xchem[i] - system.getPhases()[phase].getComponents()[i].getx()); - } - logger.info("chemdev: " + chemdev); - } + system.init(1); + system.getChemicalReactionOperations().solveChemEq(phase, 1); + + for (i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + chemdev += Math.abs(xchem[i] - system.getPhases()[phase].getComponents()[i].getx()); } + logger.info("chemdev: " + chemdev); + } } + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/TSFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/TSFlash.java index 021708ba1b..f106977a5e 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/TSFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/TSFlash.java @@ -18,121 +18,115 @@ * @version $Id: $Id */ public class TSFlash extends QfuncFlash { - private static final long serialVersionUID = 1000; - - double Sspec = 0; - Flash tpFlash; - - /** - *

- * Constructor for TSFlash. - *

- */ - public TSFlash() {} - - /** - *

- * Constructor for TSFlash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param Sspec a double - */ - public TSFlash(SystemInterface system, double Sspec) { - this.system = system; - this.tpFlash = new TPflash(system); - this.Sspec = Sspec; + private static final long serialVersionUID = 1000; + + double Sspec = 0; + Flash tpFlash; + + /** + *

+ * Constructor for TSFlash. + *

+ */ + public TSFlash() {} + + /** + *

+ * Constructor for TSFlash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param Sspec a double + */ + public TSFlash(SystemInterface system, double Sspec) { + this.system = system; + this.tpFlash = new TPflash(system); + this.Sspec = Sspec; + } + + /** {@inheritDoc} */ + @Override + public double calcdQdTT() { + if (system.getNumberOfPhases() == 1) { + return -system.getPhase(0).getCp() / system.getTemperature(); } - /** {@inheritDoc} */ - @Override - public double calcdQdTT() { - // double cP1 = 0.0, cP2 = 0.0; - - if (system.getNumberOfPhases() == 1) { - return -system.getPhase(0).getCp() / system.getTemperature(); - } - - double dQdTT = 0.0; - for (int i = 0; i < system.getNumberOfPhases(); i++) { - dQdTT -= system.getPhase(i).getCp() / system.getPhase(i).getTemperature(); - } - return dQdTT; + double dQdTT = 0.0; + for (int i = 0; i < system.getNumberOfPhases(); i++) { + dQdTT -= system.getPhase(i).getCp() / system.getPhase(i).getTemperature(); } - - /** {@inheritDoc} */ - @Override - public double calcdQdT() { - double dQ = -system.getEntropy() + Sspec; - return dQ; - } - - /** {@inheritDoc} */ - @Override - public double solveQ() { - // this method is not yet implemented - double oldTemp = system.getPressure(), nyTemp = system.getPressure(); - int iterations = 1; - double error = 1.0, erorOld = 10.0e10; - // double factor = 0.8; - - // boolean correctFactor = true; - // double newCorr = 1.0; - do { - iterations++; - oldTemp = system.getPressure(); - system.init(2); - - nyTemp = oldTemp - calcdQdT() / 10.0; - - system.setPressure(nyTemp); - tpFlash.run(); - erorOld = error; - error = Math.abs(calcdQdT()); - } while (((error + erorOld) > 1e-8 || iterations < 3) && iterations < 200); - return nyTemp; - } - - /** - *

- * onPhaseSolve. - *

- */ - public void onPhaseSolve() {} - - /** {@inheritDoc} */ - @Override - public void run() { - tpFlash.run(); - solveQ(); - } - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - SystemInterface testSystem = new SystemSrkEos(373.15, 45.551793); - - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - testSystem.addComponent("methane", 9.4935); - testSystem.addComponent("ethane", 5.06499); - testSystem.addComponent("n-heptane", 0.2); - testSystem.init(0); - try { - testOps.TPflash(); - testSystem.display(); - - double Sspec = testSystem.getEntropy("kJ/kgK"); - System.out.println("S spec " + Sspec); - testSystem.setTemperature(293.15); - testOps.TSflash(Sspec, "kJ/kgK"); - testSystem.display(); - } catch (Exception e) { - logger.error(e.toString()); - } + return dQdTT; + } + + /** {@inheritDoc} */ + @Override + public double calcdQdT() { + double dQ = -system.getEntropy() + Sspec; + return dQ; + } + + /** {@inheritDoc} */ + @Override + public double solveQ() { + // this method is not yet implemented + double oldTemp = system.getPressure(), nyTemp = system.getPressure(); + int iterations = 1; + double error = 1.0, erorOld = 10.0e10; + do { + iterations++; + oldTemp = system.getPressure(); + system.init(2); + + nyTemp = oldTemp - calcdQdT() / 10.0; + + system.setPressure(nyTemp); + tpFlash.run(); + erorOld = error; + error = Math.abs(calcdQdT()); + } while (((error + erorOld) > 1e-8 || iterations < 3) && iterations < 200); + return nyTemp; + } + + /** + *

+ * onPhaseSolve. + *

+ */ + public void onPhaseSolve() {} + + /** {@inheritDoc} */ + @Override + public void run() { + tpFlash.run(); + solveQ(); + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + SystemInterface testSystem = new SystemSrkEos(373.15, 45.551793); + + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testSystem.addComponent("methane", 9.4935); + testSystem.addComponent("ethane", 5.06499); + testSystem.addComponent("n-heptane", 0.2); + testSystem.init(0); + try { + testOps.TPflash(); + testSystem.display(); + + double Sspec = testSystem.getEntropy("kJ/kgK"); + System.out.println("S spec " + Sspec); + testSystem.setTemperature(293.15); + testOps.TSflash(Sspec, "kJ/kgK"); + testSystem.display(); + } catch (Exception e) { + logger.error(e.toString()); } + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointTemperatureNoDer.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointTemperatureNoDer.java index 10f4ab06aa..444146ce5c 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointTemperatureNoDer.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointTemperatureNoDer.java @@ -13,158 +13,153 @@ * @version $Id: $Id */ public class bubblePointTemperatureNoDer extends constantDutyTemperatureFlash { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(bubblePointTemperatureNoDer.class); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(bubblePointTemperatureNoDer.class); - /** - *

- * Constructor for bubblePointTemperatureNoDer. - *

- */ - public bubblePointTemperatureNoDer() {} + /** + *

+ * Constructor for bubblePointTemperatureNoDer. + *

+ */ + public bubblePointTemperatureNoDer() {} - /** - *

- * Constructor for bubblePointTemperatureNoDer. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public bubblePointTemperatureNoDer(SystemInterface system) { - super(system); - } - - /** {@inheritDoc} */ - @Override - public void run() { - if (system.getPhase(0).getNumberOfComponents() == 1 - && system.getPressure() > system.getPhase(0).getComponent(0).getPC()) { - setSuperCritical(true); - } + /** + *

+ * Constructor for bubblePointTemperatureNoDer. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public bubblePointTemperatureNoDer(SystemInterface system) { + super(system); + } - int iterations = 0, maxNumberOfIterations = 1000; - double yold = 0, ytotal = 1; - // double deriv = 0, funk = 0; - // logger.info("starting"); + /** {@inheritDoc} */ + @Override + public void run() { + if (system.getPhase(0).getNumberOfComponents() == 1 + && system.getPressure() > system.getPhase(0).getComponent(0).getPC()) { + setSuperCritical(true); + } - system.init(0); - system.setNumberOfPhases(2); - system.setBeta(1, 1.0 - 1e-10); - system.setBeta(0, 1e-10); - // need to fix this close to critical point - if (system.getPhase(0).getNumberOfComponents() == 1) { - double oldTemp = system.getTemperature(); - if (system.getPressure() > system.getPhase(0).getComponent(0).getPC()) { - setSuperCritical(true); - return; - } - if (system.getPressure() < system.getPhase(0).getComponent(0).getPC()) { - system.setTemperature(system.getPhase(0).getComponent(0) - .getAntoineVaporTemperature(system.getPressure())); - } - if (system.getTemperature() > system.getPhase(0).getComponent(0).getTC() - || system.getTemperature() < system.getPhase(0).getComponent(0) - .getTriplePointTemperature()) { - system.setTemperature(oldTemp); - } - } + int iterations = 0; + int maxNumberOfIterations = 1000; + double yold = 0; + double ytotal = 1; + system.init(0); + system.setNumberOfPhases(2); + system.setBeta(1, 1.0 - 1e-10); + system.setBeta(0, 1e-10); + // need to fix this close to critical point + if (system.getPhase(0).getNumberOfComponents() == 1) { + double oldTemp = system.getTemperature(); + if (system.getPressure() > system.getPhase(0).getComponent(0).getPC()) { + setSuperCritical(true); + return; + } + if (system.getPressure() < system.getPhase(0).getComponent(0).getPC()) { + system.setTemperature( + system.getPhase(0).getComponent(0).getAntoineVaporTemperature(system.getPressure())); + } + if (system.getTemperature() > system.getPhase(0).getComponent(0).getTC() || system + .getTemperature() < system.getPhase(0).getComponent(0).getTriplePointTemperature()) { + system.setTemperature(oldTemp); + } + } - // double oldPres = 0; - if (system.isChemicalSystem()) { - system.getChemicalReactionOperations().solveChemEq(0); - system.getChemicalReactionOperations().solveChemEq(1); - } + if (system.isChemicalSystem()) { + system.getChemicalReactionOperations().solveChemEq(0); + system.getChemicalReactionOperations().solveChemEq(1); + } - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - system.getPhases()[1].getComponents()[i] - .setx(system.getPhases()[0].getComponents()[i].getz()); - if (system.getPhases()[0].getComponents()[i].getIonicCharge() != 0) { - system.getPhases()[0].getComponents()[i].setx(1e-40); - } else { - system.getPhases()[0].getComponents()[i] - .setx(system.getPhases()[0].getComponents()[i].getK() - * system.getPhases()[1].getComponents()[i].getz()); - } - } - ytotal = 0.0; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - ytotal += system.getPhases()[0].getComponents()[i].getx(); - } - double oldTemp = 10.0; + for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + system.getPhases()[1].getComponents()[i] + .setx(system.getPhases()[0].getComponents()[i].getz()); + if (system.getPhases()[0].getComponents()[i].getIonicCharge() != 0) { + system.getPhases()[0].getComponents()[i].setx(1e-40); + } else { + system.getPhases()[0].getComponents()[i] + .setx(system.getPhases()[0].getComponents()[i].getK() + * system.getPhases()[1].getComponents()[i].getz()); + } + } + ytotal = 0.0; + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + ytotal += system.getPhases()[0].getComponents()[i].getx(); + } + double oldTemp = 10.0; - double ktot = 0.0; + double ktot = 0.0; + do { + iterations++; + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + system.getPhases()[0].getComponents()[i] + .setx(system.getPhases()[0].getComponents()[i].getx() / ytotal); + } + if (system.isChemicalSystem() && (iterations % 2) == 0) { + system.getChemicalReactionOperations().solveChemEq(1); + } + system.init(1); + oldTemp = system.getTemperature(); + ktot = 0.0; + for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { do { - iterations++; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - system.getPhases()[0].getComponents()[i] - .setx(system.getPhases()[0].getComponents()[i].getx() / ytotal); - } - if (system.isChemicalSystem() && (iterations % 2) == 0) { - system.getChemicalReactionOperations().solveChemEq(1); - } - system.init(1); - oldTemp = system.getTemperature(); - ktot = 0.0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - do { - yold = system.getPhases()[0].getComponents()[i].getx(); - if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { - system.getPhases()[0].getComponents()[i].setK(1e-40); - } else { - system.getPhases()[0].getComponents()[i].setK(Math.exp(Math.log( - system.getPhases()[1].getComponents()[i].getFugacityCoefficient()) - - Math.log(system.getPhases()[0].getComponents()[i] - .getFugacityCoefficient()))); - } - system.getPhases()[1].getComponents()[i] - .setK(system.getPhases()[0].getComponents()[i].getK()); - system.getPhases()[0].getComponents()[i] - .setx(system.getPhases()[0].getComponents()[i].getK() - * system.getPhases()[1].getComponents()[i].getz()); - // logger.info("y err " + - // Math.abs(system.getPhases()[0].getComponents()[i].getx()-yold)); - } while (Math.abs(system.getPhases()[0].getComponents()[i].getx() - yold) > 1e-4); + yold = system.getPhases()[0].getComponents()[i].getx(); + if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { + system.getPhases()[0].getComponents()[i].setK(1e-40); + } else { + system.getPhases()[0].getComponents()[i].setK( + Math.exp(Math.log(system.getPhases()[1].getComponents()[i].getFugacityCoefficient()) + - Math.log(system.getPhases()[0].getComponents()[i].getFugacityCoefficient()))); + } + system.getPhases()[1].getComponents()[i] + .setK(system.getPhases()[0].getComponents()[i].getK()); + system.getPhases()[0].getComponents()[i] + .setx(system.getPhases()[0].getComponents()[i].getK() + * system.getPhases()[1].getComponents()[i].getz()); + // logger.info("y err " + + // Math.abs(system.getPhases()[0].getComponents()[i].getx()-yold)); + } while (Math.abs(system.getPhases()[0].getComponents()[i].getx() - yold) > 1e-4); - ktot += Math.abs(system.getPhases()[1].getComponents()[i].getK() - 1.0); - } - ytotal = 0.0; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - ytotal += system.getPhases()[0].getComponents()[i].getx(); - } - if (ytotal > 1.2) { - ytotal = 1.2; - } - if (ytotal < 0.8) { - ytotal = 0.8; - } - // logger.info("y tot " + ytotal); + ktot += Math.abs(system.getPhases()[1].getComponents()[i].getK() - 1.0); + } + ytotal = 0.0; + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + ytotal += system.getPhases()[0].getComponents()[i].getx(); + } + if (ytotal > 1.2) { + ytotal = 1.2; + } + if (ytotal < 0.8) { + ytotal = 0.8; + } + // logger.info("y tot " + ytotal); - // system.setTemperature(system.getTemperature() + - // 0.05*(1.0/ytotal*system.getTemperature()-system.getTemperature())); - system.setTemperature( - system.getTemperature() + 0.1 * system.getTemperature() * (1.0 - ytotal)); - // for (int i=0;i 1e-9) - || Math.abs(oldTemp - system.getTemperature()) / oldTemp > 1e-8) - && (iterations < maxNumberOfIterations)); - // logger.info("iter " + iterations + " ktot " + ktot); - if (Math.abs(ytotal - 1.0) >= 1e-5 - || ktot < 1e-3 && system.getPhase(0).getNumberOfComponents() > 1) { - setSuperCritical(true); - } - if (system.getPhase(0).getNumberOfComponents() == 1 - && Math.abs(system.getPhases()[1].getComponents()[0].getFugacityCoefficient() - / system.getPhases()[0].getComponents()[0].getFugacityCoefficient() - - 1.0) < 1e-20) { - setSuperCritical(true); - return; - } + // system.setTemperature(system.getTemperature() + + // 0.05*(1.0/ytotal*system.getTemperature()-system.getTemperature())); + system + .setTemperature(system.getTemperature() + 0.1 * system.getTemperature() * (1.0 - ytotal)); + // for (int i=0;i 1e-9) + || Math.abs(oldTemp - system.getTemperature()) / oldTemp > 1e-8) + && (iterations < maxNumberOfIterations)); + // logger.info("iter " + iterations + " ktot " + ktot); + if (Math.abs(ytotal - 1.0) >= 1e-5 + || ktot < 1e-3 && system.getPhase(0).getNumberOfComponents() > 1) { + setSuperCritical(true); + } + if (system.getPhase(0).getNumberOfComponents() == 1 + && Math.abs(system.getPhases()[1].getComponents()[0].getFugacityCoefficient() + / system.getPhases()[0].getComponents()[0].getFugacityCoefficient() - 1.0) < 1e-20) { + setSuperCritical(true); + return; } + } - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/constantDutyPressureFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/constantDutyPressureFlash.java index 42759fbe40..579d7760ea 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/constantDutyPressureFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/constantDutyPressureFlash.java @@ -11,98 +11,97 @@ * @version $Id: $Id */ public class constantDutyPressureFlash extends constantDutyFlash { - private static final long serialVersionUID = 1000; - - /** - *

- * Constructor for constantDutyPressureFlash. - *

- */ - public constantDutyPressureFlash() {} - - /** - *

- * Constructor for constantDutyPressureFlash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public constantDutyPressureFlash(SystemInterface system) { - super(system); + private static final long serialVersionUID = 1000; + + /** + *

+ * Constructor for constantDutyPressureFlash. + *

+ */ + public constantDutyPressureFlash() {} + + /** + *

+ * Constructor for constantDutyPressureFlash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public constantDutyPressureFlash(SystemInterface system) { + super(system); + } + + /** {@inheritDoc} */ + @Override + public void run() { + // system.calc_x_y(); + // system.init(2); + + if (system.isChemicalSystem()) { + system.getChemicalReactionOperations().solveChemEq(0); } - /** {@inheritDoc} */ - @Override - public void run() { - // system.calc_x_y(); - // system.init(2); - - if (system.isChemicalSystem()) { - system.getChemicalReactionOperations().solveChemEq(0); - } - - int iterations = 0; - // int maxNumberOfIterations = 10000; - // double yold = 0, ytotal = 1; - double deriv = 0, funk = 0, dkidp = 0, dyidp = 0, dxidp = 0, Pold = 0; - - do { - // system.setBeta(beta+0.65); - system.init(2); - iterations++; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - system.getPhases()[0].getComponents()[i] - .setK(system.getPhases()[1].getComponents()[i].getFugacityCoefficient() - / system.getPhases()[0].getComponents()[i] - .getFugacityCoefficient()); - system.getPhases()[1].getComponents()[i] - .setK(system.getPhases()[0].getComponents()[i].getK()); - } - - system.calc_x_y_nonorm(); - - funk = 0.0; - deriv = 0.0; - - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - dkidp = (system.getPhases()[1].getComponents()[i].getdfugdp() - - system.getPhases()[0].getComponents()[i].getdfugdp()) - * system.getPhases()[1].getComponents()[i].getK(); - dxidp = -system.getPhases()[1].getComponents()[i].getz() * system.getBeta() * dkidp - / Math.pow( - 1.0 - system.getBeta() - + system.getBeta() - * system.getPhases()[1].getComponents()[i].getK(), - 2.0); - dyidp = dkidp * system.getPhases()[1].getComponents()[i].getx() - + system.getPhases()[1].getComponents()[i].getK() * dxidp; - funk += system.getPhases()[0].getComponents()[i].getx() - - system.getPhases()[1].getComponents()[i].getx(); - deriv += dyidp - dxidp; - } - - // System.out.println("Pressure: " + system.getPressure() + " funk " + funk); - - Pold = system.getPressure(); - double pres = Math.abs(Pold - 0.5 * funk / deriv); - system.setPressure(pres); - } while ((Math.abs((system.getPressure() - Pold) / system.getPressure()) > 1e-10 - && iterations < 300) || iterations < 3); - } - - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} - - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - return null; - } - - /** {@inheritDoc} */ - @Override - public SystemInterface getThermoSystem() { - return system; - } + int iterations = 0; + double deriv = 0; + + double funk = 0; + double dkidp = 0; + double dyidp = 0; + double dxidp = 0; + double Pold = 0; + do { + // system.setBeta(beta+0.65); + system.init(2); + iterations++; + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + system.getPhases()[0].getComponents()[i] + .setK(system.getPhases()[1].getComponents()[i].getFugacityCoefficient() + / system.getPhases()[0].getComponents()[i].getFugacityCoefficient()); + system.getPhases()[1].getComponents()[i] + .setK(system.getPhases()[0].getComponents()[i].getK()); + } + + system.calc_x_y_nonorm(); + + funk = 0.0; + deriv = 0.0; + + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + dkidp = (system.getPhases()[1].getComponents()[i].getdfugdp() + - system.getPhases()[0].getComponents()[i].getdfugdp()) + * system.getPhases()[1].getComponents()[i].getK(); + dxidp = -system.getPhases()[1].getComponents()[i].getz() * system.getBeta() * dkidp + / Math.pow(1.0 - system.getBeta() + + system.getBeta() * system.getPhases()[1].getComponents()[i].getK(), 2.0); + dyidp = dkidp * system.getPhases()[1].getComponents()[i].getx() + + system.getPhases()[1].getComponents()[i].getK() * dxidp; + funk += system.getPhases()[0].getComponents()[i].getx() + - system.getPhases()[1].getComponents()[i].getx(); + deriv += dyidp - dxidp; + } + + // System.out.println("Pressure: " + system.getPressure() + " funk " + funk); + + Pold = system.getPressure(); + double pres = Math.abs(Pold - 0.5 * funk / deriv); + system.setPressure(pres); + } while ((Math.abs((system.getPressure() - Pold) / system.getPressure()) > 1e-10 + && iterations < 300) || iterations < 3); + } + + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} + + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + return null; + } + + /** {@inheritDoc} */ + @Override + public SystemInterface getThermoSystem() { + return system; + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/constantDutyTemperatureFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/constantDutyTemperatureFlash.java index c62025c4ad..9152a21f86 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/constantDutyTemperatureFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/constantDutyTemperatureFlash.java @@ -11,97 +11,95 @@ * @version $Id: $Id */ public class constantDutyTemperatureFlash extends constantDutyFlash { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for constantDutyTemperatureFlash. - *

- */ - public constantDutyTemperatureFlash() {} + /** + *

+ * Constructor for constantDutyTemperatureFlash. + *

+ */ + public constantDutyTemperatureFlash() {} - /** - *

- * Constructor for constantDutyTemperatureFlash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public constantDutyTemperatureFlash(SystemInterface system) { - super(system); - } + /** + *

+ * Constructor for constantDutyTemperatureFlash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public constantDutyTemperatureFlash(SystemInterface system) { + super(system); + } - /** {@inheritDoc} */ - @Override - public void run() { - system.init(0); - system.init(2); + /** {@inheritDoc} */ + @Override + public void run() { + system.init(0); + system.init(2); - int iterations = 0; - // int maxNumberOfIterations = 10000; - // double yold = 0, ytotal = 1; - double deriv = 0, funk = 0, dkidt = 0, dyidt = 0, dxidt = 0, Told = 0; + int iterations = 0; + double deriv = 0; - do { - iterations++; - // system.setBeta(beta+0.65); - system.init(2); + double funk = 0; + double dkidt = 0; + double dyidt = 0; + double dxidt = 0; + double Told = 0; + do { + iterations++; + // system.setBeta(beta+0.65); + system.init(2); - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - system.getPhases()[0].getComponents()[i] - .setK(system.getPhases()[0].getComponents()[i].getFugacityCoefficient() - / system.getPhases()[1].getComponents()[i] - .getFugacityCoefficient()); - system.getPhases()[1].getComponents()[i] - .setK(system.getPhases()[0].getComponents()[i].getFugacityCoefficient() - / system.getPhases()[1].getComponents()[i] - .getFugacityCoefficient()); - } + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + system.getPhases()[0].getComponents()[i] + .setK(system.getPhases()[0].getComponents()[i].getFugacityCoefficient() + / system.getPhases()[1].getComponents()[i].getFugacityCoefficient()); + system.getPhases()[1].getComponents()[i] + .setK(system.getPhases()[0].getComponents()[i].getFugacityCoefficient() + / system.getPhases()[1].getComponents()[i].getFugacityCoefficient()); + } - system.calc_x_y_nonorm(); + system.calc_x_y_nonorm(); - funk = 0e0; - deriv = 0e0; + funk = 0e0; + deriv = 0e0; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - dkidt = (system.getPhases()[0].getComponents()[i].getdfugdt() - - system.getPhases()[1].getComponents()[i].getdfugdt()) - * system.getPhases()[0].getComponents()[i].getK(); - // dxidt=-system.getPhases()[0].getComponents()[i].getx() * - // system.getPhases()[0].getComponents()[i].getx()*1.0/system.getPhases()[0].getComponents()[i].getz()*system.getBeta()*dkidt; - dxidt = -system.getPhases()[0].getComponents()[i].getz() * system.getBeta() * dkidt - / Math.pow( - 1.0 - system.getBeta() - + system.getBeta() - * system.getPhases()[0].getComponents()[i].getK(), - 2); - dyidt = dkidt * system.getPhases()[0].getComponents()[i].getx() - + system.getPhases()[0].getComponents()[i].getK() * dxidt; - funk = funk + system.getPhases()[1].getComponents()[i].getx() - - system.getPhases()[0].getComponents()[i].getx(); - deriv = deriv + dyidt - dxidt; - } + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + dkidt = (system.getPhases()[0].getComponents()[i].getdfugdt() + - system.getPhases()[1].getComponents()[i].getdfugdt()) + * system.getPhases()[0].getComponents()[i].getK(); + // dxidt=-system.getPhases()[0].getComponents()[i].getx() * + // system.getPhases()[0].getComponents()[i].getx()*1.0/system.getPhases()[0].getComponents()[i].getz()*system.getBeta()*dkidt; + dxidt = -system.getPhases()[0].getComponents()[i].getz() * system.getBeta() * dkidt + / Math.pow(1.0 - system.getBeta() + + system.getBeta() * system.getPhases()[0].getComponents()[i].getK(), 2); + dyidt = dkidt * system.getPhases()[0].getComponents()[i].getx() + + system.getPhases()[0].getComponents()[i].getK() * dxidt; + funk = funk + system.getPhases()[1].getComponents()[i].getx() + - system.getPhases()[0].getComponents()[i].getx(); + deriv = deriv + dyidt - dxidt; + } - Told = system.getTemperature(); - system.setTemperature((Told - funk / deriv * 0.7)); - // System.out.println("Temp: " + system.getTemperature() + " funk " + funk); - } while ((Math.abs((system.getTemperature() - Told) / system.getTemperature()) > 1e-7 - && iterations < 300) || iterations < 3); - } + Told = system.getTemperature(); + system.setTemperature((Told - funk / deriv * 0.7)); + // System.out.println("Temp: " + system.getTemperature() + " funk " + funk); + } while ((Math.abs((system.getTemperature() - Told) / system.getTemperature()) > 1e-7 + && iterations < 300) || iterations < 3); + } - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - return null; - } + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + return null; + } - /** {@inheritDoc} */ - @Override - public SystemInterface getThermoSystem() { - return system; - } + /** {@inheritDoc} */ + @Override + public SystemInterface getThermoSystem() { + return system; + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondebarFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondebarFlash.java index f2becd57eb..74464c0564 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondebarFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondebarFlash.java @@ -15,288 +15,289 @@ * @version $Id: $Id */ public class cricondebarFlash extends constantDutyPressureFlash { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(constantDutyFlash.class); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(constantDutyFlash.class); - Matrix Jac, fvec; + Matrix Jac; + Matrix fvec; - /** - *

- * Constructor for cricondebarFlash. - *

- */ - public cricondebarFlash() {} + /** + *

+ * Constructor for cricondebarFlash. + *

+ */ + public cricondebarFlash() {} - /** - *

- * Constructor for cricondebarFlash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public cricondebarFlash(SystemInterface system) { - super(system); - Jac = new Matrix(system.getPhase(0).getNumberOfComponents() + 1, - system.getPhase(0).getNumberOfComponents() + 1); - fvec = new Matrix(system.getPhase(0).getNumberOfComponents() + 1, 1); - } + /** + *

+ * Constructor for cricondebarFlash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public cricondebarFlash(SystemInterface system) { + super(system); + Jac = new Matrix(system.getPhase(0).getNumberOfComponents() + 1, + system.getPhase(0).getNumberOfComponents() + 1); + fvec = new Matrix(system.getPhase(0).getNumberOfComponents() + 1, 1); + } - /** - *

- * calcx. - *

- * - * @return a double - */ - public double calcx() { - // double ktot = 0; - double xtotal = 0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - system.getPhases()[0].getComponents()[i].setK( - Math.exp(system.getPhases()[1].getComponents()[i].getLogFugacityCoefficient() - - system.getPhases()[0].getComponents()[i] - .getLogFugacityCoefficient())); + /** + *

+ * calcx. + *

+ * + * @return a double + */ + public double calcx() { + double xtotal = 0; + for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + system.getPhases()[0].getComponents()[i] + .setK(Math.exp(system.getPhases()[1].getComponents()[i].getLogFugacityCoefficient() + - system.getPhases()[0].getComponents()[i].getLogFugacityCoefficient())); - system.getPhases()[1].getComponents()[i] - .setK(system.getPhases()[0].getComponents()[i].getK()); - system.getPhases()[1].getComponents()[i] - .setx(1.0 / system.getPhases()[0].getComponents()[i].getK() - * system.getPhases()[1].getComponents()[i].getz()); - // ktot += Math.abs(system.getPhases()[1].getComponents()[i].getK() - 1.0); - } - xtotal = 0.0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - xtotal += system.getPhases()[1].getComponents()[i].getx(); - } - return xtotal; + system.getPhases()[1].getComponents()[i] + .setK(system.getPhases()[0].getComponents()[i].getK()); + system.getPhases()[1].getComponents()[i] + .setx(1.0 / system.getPhases()[0].getComponents()[i].getK() + * system.getPhases()[1].getComponents()[i].getz()); + // ktot += Math.abs(system.getPhases()[1].getComponents()[i].getK() - 1.0); + } + xtotal = 0.0; + for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + xtotal += system.getPhases()[1].getComponents()[i].getx(); + } + return xtotal; + } + + /** + *

+ * initMoleFraction. + *

+ * + * @return a double + */ + public double initMoleFraction() { + double[] XI = new double[system.getPhase(0).getNumberOfComponents()]; + // double sumX = 0.0; + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + XI[i] = Math.exp(Math.log(system.getPhase(0).getComponent(i).getz()) + + system.getPhase(0).getComponent(i).getLogFugacityCoefficient() + - system.getPhase(1).getComponent(i).getLogFugacityCoefficient()); + // sumX += XI[i]; + } + double tempSumXI = 1.0;// sumX; + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + system.getPhase(1).getComponent(i).setx(XI[i] / tempSumXI); } + return tempSumXI; + } + + /** + *

+ * run2. + *

+ */ + public void run2() { + ThermodynamicOperations localOperation = new ThermodynamicOperations(system); - /** - *

- * initMoleFraction. - *

- * - * @return a double - */ - public double initMoleFraction() { - double[] XI = new double[system.getPhase(0).getNumberOfComponents()]; - // double sumX = 0.0; + system.init(0); + system.setTemperature(system.getPhase(0).getPseudoCriticalTemperature() + 20); + system.setPressure(system.getPhase(0).getPseudoCriticalPressure()); + system.init(3); + int iterations = 0; + + int maxNumberOfIterations = 300; + try { + localOperation.dewPointTemperatureFlash(); + } catch (Exception e) { + logger.error("error", e); + } + system.setNumberOfPhases(2); + system.setBeta(0.5); + system.setTemperature(system.getTemperature() - 20); + system.init(3); + system.display(); + double Q1 = 0; + double Qold = 0.0; + double dQ1dT = 0; + double oldTemperature = 0; + double oldIterTemp = 0; + do { + oldIterTemp = system.getTemperature(); + iterations = 0; + do { + iterations++; + initMoleFraction(); + system.init(3); + Qold = Q1; + Q1 = 0.0; for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - XI[i] = Math.exp(Math.log(system.getPhase(0).getComponent(i).getz()) - + system.getPhase(0).getComponent(i).getLogFugacityCoefficient() - - system.getPhase(1).getComponent(i).getLogFugacityCoefficient()); - // sumX += XI[i]; + Q1 -= system.getPhase(1).getComponent(i).getx() + * (system.getPhase(0).getComponent(i).getdfugdt() + - system.getPhase(1).getComponent(i).getdfugdt()); } - double tempSumXI = 1.0;// sumX; - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - system.getPhase(1).getComponent(i).setx(XI[i] / tempSumXI); + if (iterations > 1) { + dQ1dT = (Q1 - Qold) / (system.getTemperature() - oldTemperature); + } else { + dQ1dT = Q1 * 100.0; } - return tempSumXI; - } - /** - *

- * run2. - *

- */ - public void run2() { - ThermodynamicOperations localOperation = new ThermodynamicOperations(system); + oldTemperature = system.getTemperature(); + system.setTemperature(system.getTemperature() - 0.5 * Q1 / dQ1dT); - system.init(0); - system.setTemperature(system.getPhase(0).getPseudoCriticalTemperature() + 20); - system.setPressure(system.getPhase(0).getPseudoCriticalPressure()); system.init(3); - int iterations = 0, maxNumberOfIterations = 300; + logger.info( + "temp " + system.getTemperature() + " Q1 " + Q1 + " pressure " + system.getPressure()); + } while (Math.abs(Q1) > 1e-10 && iterations < maxNumberOfIterations); + iterations = 0; + double presOld = system.getPressure(); + do { + logger.info( + "temp " + system.getTemperature() + " Q1 " + Q1 + " pressure " + system.getPressure()); + Matrix dx = null; + + iterations++; try { - localOperation.dewPointTemperatureFlash(); + system.init(3); + setfvec(); + setJac(); + dx = Jac.solve(fvec); } catch (Exception e) { - logger.error("error", e); + logger.error("error", e); } - system.setNumberOfPhases(2); - system.setBeta(0.5); - system.setTemperature(system.getTemperature() - 20); - system.init(3); - system.display(); - double Q1 = 0, Qold = 0.0, dQ1dT = 0, oldTemperature = 0, oldIterTemp = 0; - do { - oldIterTemp = system.getTemperature(); - iterations = 0; - do { - iterations++; - initMoleFraction(); - system.init(3); - Qold = Q1; - Q1 = 0.0; - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - Q1 -= system.getPhase(1).getComponent(i).getx() - * (system.getPhase(0).getComponent(i).getdfugdt() - - system.getPhase(1).getComponent(i).getdfugdt()); - } - if (iterations > 1) { - dQ1dT = (Q1 - Qold) / (system.getTemperature() - oldTemperature); - } else { - dQ1dT = Q1 * 100.0; - } - - oldTemperature = system.getTemperature(); - system.setTemperature(system.getTemperature() - 0.5 * Q1 / dQ1dT); + double damping = iterations * 1.0 / (10.0 + iterations); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + double xlocal = system.getPhase(1).getComponent(i).getx() - damping * dx.get(i, 0); + if (xlocal < 1e-30) { + xlocal = 1e-30; + } + if (xlocal > 1.0 - 1e-30) { + xlocal = 1.0 - 1e-30; + } + logger.info("x" + (xlocal) + " press " + system.getPressure() + " fvec " + fvec.norm2()); + system.getPhase(1).getComponent(i).setx(xlocal); + } + system.setPressure( + system.getPressure() - damping * dx.get(system.getPhase(0).getNumberOfComponents(), 0)); + } while (Math.abs(fvec.norm2()) > 1.0e-12 && iterations < maxNumberOfIterations + && Math.abs(presOld - system.getPressure()) < 10.0); + } while (Math.abs(oldIterTemp - system.getTemperature()) > 1e-3); + } - system.init(3); - logger.info("temp " + system.getTemperature() + " Q1 " + Q1 + " pressure " - + system.getPressure()); - } while (Math.abs(Q1) > 1e-10 && iterations < maxNumberOfIterations); + /** {@inheritDoc} */ + @Override + public void run() { + ThermodynamicOperations localOperation = new ThermodynamicOperations(system); - iterations = 0; - double presOld = system.getPressure(); - do { - logger.info("temp " + system.getTemperature() + " Q1 " + Q1 + " pressure " - + system.getPressure()); - Matrix dx = null; + system.init(0); + // system.setTemperature(system.getPhase(0).getPseudoCriticalTemperature() + 7); + // system.setPressure(system.getPhase(0).getPseudoCriticalPressure() / 2.0); + system.init(3); - iterations++; - try { - system.init(3); - setfvec(); - setJac(); - dx = Jac.solve(fvec); - } catch (Exception e) { - logger.error("error", e); - } - double damping = iterations * 1.0 / (10.0 + iterations); - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - double xlocal = - system.getPhase(1).getComponent(i).getx() - damping * dx.get(i, 0); - if (xlocal < 1e-30) { - xlocal = 1e-30; - } - if (xlocal > 1.0 - 1e-30) { - xlocal = 1.0 - 1e-30; - } - logger.info("x" + (xlocal) + " press " + system.getPressure() + " fvec " - + fvec.norm2()); - system.getPhase(1).getComponent(i).setx(xlocal); - } - system.setPressure(system.getPressure() - - damping * dx.get(system.getPhase(0).getNumberOfComponents(), 0)); - } while (Math.abs(fvec.norm2()) > 1.0e-12 && iterations < maxNumberOfIterations - && Math.abs(presOld - system.getPressure()) < 10.0); - } while (Math.abs(oldIterTemp - system.getTemperature()) > 1e-3); - } + int iterations = 0; + localOperation.TPflash(); + double Q1 = 0; + double Qold = 0.0; + double dQ1dT = 1.0; + double oldTemperature = 0; + double dewTemp = 0; - /** {@inheritDoc} */ - @Override - public void run() { - ThermodynamicOperations localOperation = new ThermodynamicOperations(system); + for (int ii = 0; ii < 45; ii++) { + system.setPressure(system.getPressure() + 1.0); + try { + // if(ii<2) localOperation.dewPointTemperatureFlash(); + // else localOperation.dewPointPressureFlash(); + dewTemp = system.getTemperature(); + system.getPressure(); + } catch (Exception e) { + logger.error("error", e); + } - system.init(0); - // system.setTemperature(system.getPhase(0).getPseudoCriticalTemperature() + 7); - // system.setPressure(system.getPhase(0).getPseudoCriticalPressure() / 2.0); + iterations = 0; + do { + iterations++; system.init(3); - - int iterations = 0; + // initMoleFraction(); localOperation.TPflash(); - double Q1 = 0, Qold = 0.0, dQ1dT = 1.0, oldTemperature = 0; - double dewTemp = 0; - // double dewPres = 0; - - for (int ii = 0; ii < 45; ii++) { - system.setPressure(system.getPressure() + 1.0); - try { - // if(ii<2) localOperation.dewPointTemperatureFlash(); - // else localOperation.dewPointPressureFlash(); - dewTemp = system.getTemperature(); - // dewPres = system.getPressure(); - // system.display(); - } catch (Exception e) { - logger.error("error", e); - } - - iterations = 0; - do { - iterations++; - system.init(3); - // initMoleFraction(); - localOperation.TPflash(); - system.display(); - Qold = Q1; - Q1 = 0.0; - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - Q1 -= system.getPhase(1).getComponent(i).getx() - * (system.getPhase(0).getComponent(i).getdfugdt() - - system.getPhase(1).getComponent(i).getdfugdt()); - } - if (iterations > 3) { - dQ1dT = (Q1 - Qold) / (system.getTemperature() - oldTemperature); - } else { - dQ1dT = -Q1 * 100.0; - } + system.display(); + Qold = Q1; + Q1 = 0.0; + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + Q1 -= system.getPhase(1).getComponent(i).getx() + * (system.getPhase(0).getComponent(i).getdfugdt() + - system.getPhase(1).getComponent(i).getdfugdt()); + } + if (iterations > 3) { + dQ1dT = (Q1 - Qold) / (system.getTemperature() - oldTemperature); + } else { + dQ1dT = -Q1 * 100.0; + } - oldTemperature = system.getTemperature(); - system.setTemperature(system.getTemperature() - - iterations * 1.0 / (iterations + 10.0) * Q1 / dQ1dT); + oldTemperature = system.getTemperature(); + system.setTemperature( + system.getTemperature() - iterations * 1.0 / (iterations + 10.0) * Q1 / dQ1dT); - logger.info("temp " + system.getTemperature() + "dewTemp " + dewTemp + " Q1 " + Q1 - + " pressure " + system.getPressure()); - } while (Math.abs(Q1) > 1e-10 && iterations < 15);// maxNumberOfIterations); - logger.info("temp " + system.getTemperature() + " Q1 " + Q1); - // if(ii<2) system.setTemperature(dewTemp-); - logger.info("fvec " + fvec.norm2() + " pressure " + system.getPressure()); - } + logger.info("temp " + system.getTemperature() + "dewTemp " + dewTemp + " Q1 " + Q1 + + " pressure " + system.getPressure()); + } while (Math.abs(Q1) > 1e-10 && iterations < 15);// maxNumberOfIterations); + logger.info("temp " + system.getTemperature() + " Q1 " + Q1); + // if(ii<2) system.setTemperature(dewTemp-); + logger.info("fvec " + fvec.norm2() + " pressure " + system.getPressure()); } + } - /** - *

- * Setter for the field fvec. - *

- */ - public void setfvec() { - double sumxx = 0; - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - sumxx += system.getPhases()[1].getComponents()[i].getx(); - fvec.set(i, 0, Math - .log(system.getPhases()[0].getComponents()[i].getFugacityCoefficient() - * system.getPhases()[0].getComponents()[i].getz() - * system.getPressure()) - - Math.log(system.getPhases()[1].getComponents()[i].getFugacityCoefficient() - * system.getPhases()[1].getComponents()[i].getx() - * system.getPressure())); - } - fvec.set(system.getPhase(0).getNumberOfComponents(), 0, 1.0 - sumxx); - // logger.info("sumx" + sumxx); + /** + *

+ * Setter for the field fvec. + *

+ */ + public void setfvec() { + double sumxx = 0; + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + sumxx += system.getPhases()[1].getComponents()[i].getx(); + fvec.set(i, 0, + Math.log(system.getPhases()[0].getComponents()[i].getFugacityCoefficient() + * system.getPhases()[0].getComponents()[i].getz() * system.getPressure()) + - Math.log(system.getPhases()[1].getComponents()[i].getFugacityCoefficient() + * system.getPhases()[1].getComponents()[i].getx() * system.getPressure())); } + fvec.set(system.getPhase(0).getNumberOfComponents(), 0, 1.0 - sumxx); + // logger.info("sumx" + sumxx); + } - /** - *

- * setJac. - *

- */ - public void setJac() { - Jac.timesEquals(0.0); - double dij = 0.0; + /** + *

+ * setJac. + *

+ */ + public void setJac() { + Jac.timesEquals(0.0); + double dij = 0.0; - double tempJ = 0.0; + double tempJ = 0.0; - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - for (int j = 0; j < system.getPhase(0).getNumberOfComponents(); j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta - tempJ = -dij * 1.0 / system.getPhases()[1].getComponents()[i].getx() - - system.getPhases()[1].getComponents()[i].getdfugdx(j); - Jac.set(i, j, tempJ); - } - } + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + for (int j = 0; j < system.getPhase(0).getNumberOfComponents(); j++) { + dij = i == j ? 1.0 : 0.0;// Kroneckers delta + tempJ = -dij * 1.0 / system.getPhases()[1].getComponents()[i].getx() + - system.getPhases()[1].getComponents()[i].getdfugdx(j); + Jac.set(i, j, tempJ); + } + } - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - Jac.set(system.getPhase(0).getNumberOfComponents(), i, -1.0); - } - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - Jac.set(i, system.getPhase(0).getNumberOfComponents(), - system.getPhases()[0].getComponents()[i].getdfugdp() - - system.getPhases()[1].getComponents()[i].getdfugdp()); - } + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + Jac.set(system.getPhase(0).getNumberOfComponents(), i, -1.0); + } + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + Jac.set(i, system.getPhase(0).getNumberOfComponents(), + system.getPhases()[0].getComponents()[i].getdfugdp() + - system.getPhases()[1].getComponents()[i].getdfugdp()); } + } - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp.java index 157af018f8..9f74564a56 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp.java @@ -12,150 +12,156 @@ * @version $Id: $Id */ public class cricondenBarTemp implements java.io.Serializable { - private static final long serialVersionUID = 1000; - int neq = 0, iter = 0; - int ic02p = -100, ic03p = -100, testcrit = 0, npCrit = 0; - double beta = 0, ds = 0, dTmax = 1, dPmax = 1, avscp = 0.1, TC1 = 0, TC2 = 0, PC1 = 0, PC2 = 0; - Matrix Jac; - Matrix fvec; - Matrix u; - Matrix uold; - Matrix Xgij; - SystemInterface system; - int numberOfComponents; - int speceq = 0; - Matrix a = new Matrix(4, 4); - Matrix s = new Matrix(1, 4); - Matrix xg; - Matrix dx; - Matrix xcoef; + private static final long serialVersionUID = 1000; + int neq = 0; + int iter = 0; + int ic02p = -100; + int ic03p = -100; + int testcrit = 0; + int npCrit = 0; + double beta = 0; + double ds = 0; + double dTmax = 1; + double dPmax = 1; + double avscp = 0.1; + double TC1 = 0; + double TC2 = 0; + double PC1 = 0; + double PC2 = 0; + Matrix Jac; + Matrix fvec; + Matrix u; + Matrix uold; + Matrix Xgij; + SystemInterface system; + int numberOfComponents; + int speceq = 0; + Matrix a = new Matrix(4, 4); + Matrix s = new Matrix(1, 4); + Matrix xg; + Matrix dx; + Matrix xcoef; - /** - *

- * Constructor for cricondenBarTemp. - *

- */ - public cricondenBarTemp() {} + /** + *

+ * Constructor for cricondenBarTemp. + *

+ */ + public cricondenBarTemp() {} - /** - *

- * Constructor for cricondenBarTemp. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param numberOfPhases a int - * @param numberOfComponents a int - */ - public cricondenBarTemp(SystemInterface system, int numberOfPhases, int numberOfComponents) { - this.system = system; - this.numberOfComponents = numberOfComponents; - neq = numberOfComponents; - Jac = new Matrix(neq, neq); - fvec = new Matrix(neq, 1); - u = new Matrix(neq, 1); - Xgij = new Matrix(neq, 4); - setu(); - uold = u.copy(); - // System.out.println("Spec : " +speceq); - } + /** + *

+ * Constructor for cricondenBarTemp. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param numberOfPhases a int + * @param numberOfComponents a int + */ + public cricondenBarTemp(SystemInterface system, int numberOfPhases, int numberOfComponents) { + this.system = system; + this.numberOfComponents = numberOfComponents; + neq = numberOfComponents; + Jac = new Matrix(neq, neq); + fvec = new Matrix(neq, 1); + u = new Matrix(neq, 1); + Xgij = new Matrix(neq, 4); + setu(); + uold = u.copy(); + // System.out.println("Spec : " +speceq); + } - /** - *

- * Setter for the field fvec. - *

- */ - public void setfvec() { - for (int i = 0; i < numberOfComponents; i++) { - fvec.set(i, 0, Math - .log(system.getPhases()[0].getComponents()[i].getFugacityCoefficient() - * system.getPhases()[0].getComponents()[i].getx() - * system.getPressure()) - - Math.log(system.getPhases()[1].getComponents()[i].getFugacityCoefficient() - * system.getPhases()[1].getComponents()[i].getx() - * system.getPressure())); - } + /** + *

+ * Setter for the field fvec. + *

+ */ + public void setfvec() { + for (int i = 0; i < numberOfComponents; i++) { + fvec.set(i, 0, + Math.log(system.getPhases()[0].getComponents()[i].getFugacityCoefficient() + * system.getPhases()[0].getComponents()[i].getx() * system.getPressure()) + - Math.log(system.getPhases()[1].getComponents()[i].getFugacityCoefficient() + * system.getPhases()[1].getComponents()[i].getx() * system.getPressure())); } + } - /** - *

- * setJac. - *

- */ - public void setJac() { - Jac.timesEquals(0.0); - double dij = 0.0; - - double tempJ = 0.0; - // double sumdyidbeta = 0, sumdxidbeta = 0; - // int nofc = numberOfComponents; + /** + *

+ * setJac. + *

+ */ + public void setJac() { + Jac.timesEquals(0.0); + double dij = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < numberOfComponents; j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta - tempJ = 1.0 / system.getBeta() - * (dij / system.getPhases()[0].getComponents()[i].getx() - 1.0 - + system.getPhases()[0].getComponents()[i].getdfugdx(j)) - + 1.0 / (1.0 - system.getBeta()) - * (dij / system.getPhases()[1].getComponents()[i].getx() - 1.0 - + system.getPhases()[1].getComponents()[i].getdfugdx(j)); - Jac.set(i, j, tempJ); - } - } + double tempJ = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < numberOfComponents; j++) { + dij = i == j ? 1.0 : 0.0;// Kroneckers delta + tempJ = 1.0 / system.getBeta() + * (dij / system.getPhases()[0].getComponents()[i].getx() - 1.0 + + system.getPhases()[0].getComponents()[i].getdfugdx(j)) + + 1.0 / (1.0 - system.getBeta()) + * (dij / system.getPhases()[1].getComponents()[i].getx() - 1.0 + + system.getPhases()[1].getComponents()[i].getdfugdx(j)); + Jac.set(i, j, tempJ); + } } + } - /** - *

- * Setter for the field u. - *

- */ - public void setu() { - for (int i = 0; i < numberOfComponents; i++) { - u.set(i, 0, system.getBeta() * system.getPhases()[0].getComponents()[i].getx()); - } + /** + *

+ * Setter for the field u. + *

+ */ + public void setu() { + for (int i = 0; i < numberOfComponents; i++) { + u.set(i, 0, system.getBeta() * system.getPhases()[0].getComponents()[i].getx()); } + } - /** - *

- * init. - *

- */ - public void init() { - double temp = 0; - - for (int i = 0; i < numberOfComponents; i++) { - temp += u.get(i, 0); - } - system.setBeta(temp); - for (int i = 0; i < numberOfComponents; i++) { - system.getPhases()[0].getComponents()[i].setx(u.get(i, 0) / system.getBeta()); - system.getPhases()[1].getComponents()[i] - .setx((system.getPhases()[0].getComponents()[i].getz() - u.get(i, 0)) - / (1.0 - system.getBeta())); - system.getPhases()[0].getComponents()[i] - .setK(system.getPhases()[0].getComponents()[i].getx() - / system.getPhases()[1].getComponents()[i].getx()); - system.getPhases()[1].getComponents()[i] - .setK(system.getPhases()[0].getComponents()[i].getK()); - } + /** + *

+ * init. + *

+ */ + public void init() { + double temp = 0; - system.init(3); + for (int i = 0; i < numberOfComponents; i++) { + temp += u.get(i, 0); } - - /** - *

- * solve. - *

- * - * @return a double - */ - public double solve() { - iter++; - init(); - setfvec(); - setJac(); - dx = Jac.solve(fvec); - // dx.print(10,10); - u.minusEquals(dx); - return (dx.norm2() / u.norm2()); + system.setBeta(temp); + for (int i = 0; i < numberOfComponents; i++) { + system.getPhases()[0].getComponents()[i].setx(u.get(i, 0) / system.getBeta()); + system.getPhases()[1].getComponents()[i] + .setx((system.getPhases()[0].getComponents()[i].getz() - u.get(i, 0)) + / (1.0 - system.getBeta())); + system.getPhases()[0].getComponents()[i].setK(system.getPhases()[0].getComponents()[i].getx() + / system.getPhases()[1].getComponents()[i].getx()); + system.getPhases()[1].getComponents()[i] + .setK(system.getPhases()[0].getComponents()[i].getK()); } + + system.init(3); + } + + /** + *

+ * solve. + *

+ * + * @return a double + */ + public double solve() { + iter++; + init(); + setfvec(); + setJac(); + dx = Jac.solve(fvec); + // dx.print(10,10); + u.minusEquals(dx); + return (dx.norm2() / u.norm2()); + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/dewPointTemperatureFlashDer.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/dewPointTemperatureFlashDer.java index 3c0c5ca149..e0c9e412a3 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/dewPointTemperatureFlashDer.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/dewPointTemperatureFlashDer.java @@ -11,158 +11,156 @@ * @version $Id: $Id */ public class dewPointTemperatureFlashDer extends constantDutyTemperatureFlash { - private static final long serialVersionUID = 1000; - - /** - *

- * Constructor for dewPointTemperatureFlashDer. - *

- */ - public dewPointTemperatureFlashDer() {} - - /** - *

- * Constructor for dewPointTemperatureFlashDer. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public dewPointTemperatureFlashDer(SystemInterface system) { - super(system); + private static final long serialVersionUID = 1000; + + /** + *

+ * Constructor for dewPointTemperatureFlashDer. + *

+ */ + public dewPointTemperatureFlashDer() {} + + /** + *

+ * Constructor for dewPointTemperatureFlashDer. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public dewPointTemperatureFlashDer(SystemInterface system) { + super(system); + } + + /** {@inheritDoc} */ + @Override + public void run() { + if (system.getPhase(0).getNumberOfComponents() == 1 + && system.getPressure() > system.getPhase(0).getComponent(0).getPC()) { + setSuperCritical(true); } - /** {@inheritDoc} */ - @Override - public void run() { - if (system.getPhase(0).getNumberOfComponents() == 1 - && system.getPressure() > system.getPhase(0).getComponent(0).getPC()) { - setSuperCritical(true); - } + // System.out.println("starting"); + system.init(0); + system.setBeta(0, 1.0 - 1e-15); + system.setBeta(1, 1e-15); + system.init(1); + system.setNumberOfPhases(2); + + double oldTemp = 0; + if (system.isChemicalSystem()) { + system.getChemicalReactionOperations().solveChemEq(0); + system.getChemicalReactionOperations().solveChemEq(1); + } - int iterations = 0, maxNumberOfIterations = 1000; - double xtotal = 1; - // double deriv = 0, funk = 0; - // System.out.println("starting"); - system.init(0); - system.setBeta(0, 1.0 - 1e-15); - system.setBeta(1, 1e-15); - system.init(1); - system.setNumberOfPhases(2); - - double oldTemp = 0; - if (system.isChemicalSystem()) { - system.getChemicalReactionOperations().solveChemEq(0); - system.getChemicalReactionOperations().solveChemEq(1); + for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + system.getPhases()[0].getComponents()[i] + .setx(system.getPhases()[0].getComponents()[i].getz()); + if (system.getPhases()[0].getComponents()[i].getIonicCharge() != 0) { + system.getPhases()[0].getComponents()[i].setx(1e-40); + } else { + if (system.getPhases()[1].getComponents()[i].getName().equals("water")) { + system.getPhases()[1].getComponents()[i].setx(1.0); + } else if (system.getPhases()[1].hasComponent("water")) { + system.getPhases()[1].getComponents()[i].setx(1.0e-10); + } else { + system.getPhases()[1].getComponents()[i] + .setx(1.0 / system.getPhases()[0].getComponents()[i].getK() + * system.getPhases()[1].getComponents()[i].getz()); } + } + } - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - system.getPhases()[0].getComponents()[i] - .setx(system.getPhases()[0].getComponents()[i].getz()); - if (system.getPhases()[0].getComponents()[i].getIonicCharge() != 0) { - system.getPhases()[0].getComponents()[i].setx(1e-40); - } else { - if (system.getPhases()[1].getComponents()[i].getName().equals("water")) { - system.getPhases()[1].getComponents()[i].setx(1.0); - } else if (system.getPhases()[1].hasComponent("water")) { - system.getPhases()[1].getComponents()[i].setx(1.0e-10); - } else { - system.getPhases()[1].getComponents()[i] - .setx(1.0 / system.getPhases()[0].getComponents()[i].getK() - * system.getPhases()[1].getComponents()[i].getz()); - } - } - } - // system.setPressure(system.getPhases()[0].getAntoineVaporPressure(system.getTemperature())); - xtotal = 0.0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - xtotal += system.getPhases()[1].getComponents()[i].getx(); - } - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - system.getPhases()[1].getComponents()[i] - .setx(system.getPhases()[1].getComponents()[i].getx() / xtotal); - } + // system.setPressure(system.getPhases()[0].getAntoineVaporPressure(system.getTemperature())); + double xtotal = 0.0; + for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + xtotal += system.getPhases()[1].getComponents()[i].getx(); + } + for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + system.getPhases()[1].getComponents()[i] + .setx(system.getPhases()[1].getComponents()[i].getx() / xtotal); + } - double ktot = 0.0; - // double = 0.0, fold = 0; - do { - oldTemp = system.getTemperature(); - iterations++; - system.init(2); - - xtotal = 0.0; - double dfdT = 0.0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - xtotal += 1.0 / system.getPhases()[0].getComponents()[i].getK() - * system.getPhases()[1].getComponents()[i].getz(); - dfdT -= 1.0 / system.getPhases()[0].getComponents()[i].getK() - * system.getPhases()[1].getComponents()[i].getz() - * (system.getPhases()[1].getComponents()[i].getdfugdt() - - system.getPhases()[0].getComponents()[i].getdfugdt()); - } - double f = xtotal - 1.0; - // fold = f; - - // System.out.println("x" + xtotal); - // oldTemperature = system.getTemperature(); - - if (iterations < 5) { - system.setTemperature(system.getTemperature() + iterations / (iterations + 100.0) - * (xtotal * system.getTemperature() - system.getTemperature())); - } else { - system.setTemperature( - system.getTemperature() - iterations / (10.0 + iterations) * f / dfdT); - } - // System.out.println("temperature " + system.getTemperature()); - - system.init(1); - - ktot = 0.0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { - system.getPhases()[0].getComponents()[i].setK(1e-40); - } else { - system.getPhases()[0].getComponents()[i].setK(Math.exp( - system.getPhases()[1].getComponents()[i].getLogFugacityCoefficient() - - system.getPhases()[0].getComponents()[i] - .getLogFugacityCoefficient())); - } - system.getPhases()[1].getComponents()[i] - .setK(system.getPhases()[0].getComponents()[i].getK()); - system.getPhases()[1].getComponents()[i] - .setx(1.0 / system.getPhases()[0].getComponents()[i].getK() - * system.getPhases()[1].getComponents()[i].getz()); - ktot += Math.abs(system.getPhases()[1].getComponents()[i].getK() - 1.0); - } - // system.init_x_y(); - - xtotal = 0.0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - xtotal += system.getPhases()[1].getComponents()[i].getx(); - } - // System.out.println("xtotal " + xtotal); - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - system.getPhases()[1].getComponents()[i] - .setx(system.getPhases()[1].getComponents()[i].getx() / xtotal); - } - } while (((Math.abs(xtotal - 1.0) > 1e-6) - || Math.abs(oldTemp - system.getTemperature()) / oldTemp > 1e-4) - || iterations < 3 && (iterations < maxNumberOfIterations)); - if (Math.abs(xtotal - 1.0) > 1e-5 - || ktot < 1.0e-3 && system.getPhase(0).getNumberOfComponents() > 1) { - setSuperCritical(true); - } - if (ktot < 1.0e-3) { - if (system.getTemperature() < 90.0) { - setSuperCritical(true); - } else { - setSuperCritical(false); - // system.setTemperature(system.getTemperature() - 10.0); - // run(); - } + int iterations = 0; + int maxNumberOfIterations = 1000; + double ktot = 0.0; + do { + oldTemp = system.getTemperature(); + iterations++; + system.init(2); + + xtotal = 0.0; + double dfdT = 0.0; + for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + xtotal += 1.0 / system.getPhases()[0].getComponents()[i].getK() + * system.getPhases()[1].getComponents()[i].getz(); + dfdT -= 1.0 / system.getPhases()[0].getComponents()[i].getK() + * system.getPhases()[1].getComponents()[i].getz() + * (system.getPhases()[1].getComponents()[i].getdfugdt() + - system.getPhases()[0].getComponents()[i].getdfugdt()); + } + double f = xtotal - 1.0; + // fold = f; + + // System.out.println("x" + xtotal); + // oldTemperature = system.getTemperature(); + + if (iterations < 5) { + system.setTemperature(system.getTemperature() + iterations / (iterations + 100.0) + * (xtotal * system.getTemperature() - system.getTemperature())); + } else { + system + .setTemperature(system.getTemperature() - iterations / (10.0 + iterations) * f / dfdT); + } + // System.out.println("temperature " + system.getTemperature()); + + system.init(1); + + ktot = 0.0; + for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { + system.getPhases()[0].getComponents()[i].setK(1e-40); + } else { + system.getPhases()[0].getComponents()[i] + .setK(Math.exp(system.getPhases()[1].getComponents()[i].getLogFugacityCoefficient() + - system.getPhases()[0].getComponents()[i].getLogFugacityCoefficient())); } + system.getPhases()[1].getComponents()[i] + .setK(system.getPhases()[0].getComponents()[i].getK()); + system.getPhases()[1].getComponents()[i] + .setx(1.0 / system.getPhases()[0].getComponents()[i].getK() + * system.getPhases()[1].getComponents()[i].getz()); + ktot += Math.abs(system.getPhases()[1].getComponents()[i].getK() - 1.0); + } + // system.init_x_y(); + + xtotal = 0.0; + for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + xtotal += system.getPhases()[1].getComponents()[i].getx(); + } + // System.out.println("xtotal " + xtotal); + for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + system.getPhases()[1].getComponents()[i] + .setx(system.getPhases()[1].getComponents()[i].getx() / xtotal); + } + } while (((Math.abs(xtotal - 1.0) > 1e-6) + || Math.abs(oldTemp - system.getTemperature()) / oldTemp > 1e-4) + || iterations < 3 && (iterations < maxNumberOfIterations)); + if (Math.abs(xtotal - 1.0) > 1e-5 + || ktot < 1.0e-3 && system.getPhase(0).getNumberOfComponents() > 1) { + setSuperCritical(true); + } + if (ktot < 1.0e-3) { + if (system.getTemperature() < 90.0) { + setSuperCritical(true); + } else { + setSuperCritical(false); + // system.setTemperature(system.getTemperature() - 10.0); + // run(); + } } + } - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/sysNewtonRhapsonPHflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/sysNewtonRhapsonPHflash.java index c85af0c9de..d5d4a11b8e 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/sysNewtonRhapsonPHflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/sysNewtonRhapsonPHflash.java @@ -2,7 +2,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import Jama.Matrix; import neqsim.MathLib.nonLinearSolver.newtonRhapson; import neqsim.thermo.ThermodynamicConstantsInterface; @@ -17,255 +16,262 @@ * @version $Id: $Id */ public class sysNewtonRhapsonPHflash implements ThermodynamicConstantsInterface { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(sysNewtonRhapsonPHflash.class); - int neq = 0, iter = 0; - int ic02p = -100, ic03p = -100, testcrit = 0, npCrit = 0; - double beta = 0, ds = 0, dTmax = 1, dPmax = 1, avscp = 0.1, TC1 = 0, TC2 = 0, PC1 = 0, PC2 = 0; - double specVar = 0; - Matrix Jac; - Matrix fvec; - Matrix gTvec; - Matrix gPvec; - Matrix u; - Matrix uold; - Matrix Xgij; - SystemInterface system; - int numberOfComponents; - int speceq = 0; - Matrix a = new Matrix(4, 4); - Matrix s = new Matrix(1, 4); - Matrix xg; - Matrix xcoef; - newtonRhapson solver; - boolean etterCP = false; - boolean etterCP2 = false; - double dVdT = 0; - int type = 0; - double dPdT = 0; + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(sysNewtonRhapsonPHflash.class); + int neq = 0; + int iter = 0; + int ic02p = -100; + int ic03p = -100; + int testcrit = 0; + int npCrit = 0; + double beta = 0; + double ds = 0; + double dTmax = 1; + double dPmax = 1; + double avscp = 0.1; + double TC1 = 0; + double TC2 = 0; + double PC1 = 0; + double PC2 = 0; + double specVar = 0; + Matrix Jac; + Matrix fvec; + Matrix gTvec; + Matrix gPvec; + Matrix u; + Matrix uold; + Matrix Xgij; + SystemInterface system; + int numberOfComponents; + int speceq = 0; + Matrix a = new Matrix(4, 4); + Matrix s = new Matrix(1, 4); + Matrix xg; + Matrix xcoef; + newtonRhapson solver; + boolean etterCP = false; + boolean etterCP2 = false; + double dVdT = 0; + int type = 0; + double dPdT = 0; - /** - *

- * Constructor for sysNewtonRhapsonPHflash. - *

- */ - public sysNewtonRhapsonPHflash() {} + /** + *

+ * Constructor for sysNewtonRhapsonPHflash. + *

+ */ + public sysNewtonRhapsonPHflash() {} - /** - *

- * Constructor for sysNewtonRhapsonPHflash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param numberOfPhases a int - * @param numberOfComponents a int - */ - public sysNewtonRhapsonPHflash(SystemInterface system, int numberOfPhases, - int numberOfComponents) { - this.system = system; - this.numberOfComponents = numberOfComponents; - neq = numberOfComponents; - Jac = new Matrix(neq + 2, neq + 2); - fvec = new Matrix(neq + 2, 1); - gTvec = new Matrix(neq, 1); - gPvec = new Matrix(neq, 1); - u = new Matrix(neq + 2, 1); - Xgij = new Matrix(neq + 2, 4); - setu(); - uold = u.copy(); - // logger.info("Spec : " +speceq); - solver = new newtonRhapson(); - solver.setOrder(3); - } + /** + *

+ * Constructor for sysNewtonRhapsonPHflash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param numberOfPhases a int + * @param numberOfComponents a int + */ + public sysNewtonRhapsonPHflash(SystemInterface system, int numberOfPhases, + int numberOfComponents) { + this.system = system; + this.numberOfComponents = numberOfComponents; + neq = numberOfComponents; + Jac = new Matrix(neq + 2, neq + 2); + fvec = new Matrix(neq + 2, 1); + gTvec = new Matrix(neq, 1); + gPvec = new Matrix(neq, 1); + u = new Matrix(neq + 2, 1); + Xgij = new Matrix(neq + 2, 4); + setu(); + uold = u.copy(); + // logger.info("Spec : " +speceq); + solver = new newtonRhapson(); + solver.setOrder(3); + } - /** - *

- * Constructor for sysNewtonRhapsonPHflash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param numberOfPhases a int - * @param numberOfComponents a int - * @param type a int - */ - public sysNewtonRhapsonPHflash(SystemInterface system, int numberOfPhases, - int numberOfComponents, int type) { - this(system, numberOfPhases, numberOfComponents); - this.type = type; - } + /** + *

+ * Constructor for sysNewtonRhapsonPHflash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param numberOfPhases a int + * @param numberOfComponents a int + * @param type a int + */ + public sysNewtonRhapsonPHflash(SystemInterface system, int numberOfPhases, int numberOfComponents, + int type) { + this(system, numberOfPhases, numberOfComponents); + this.type = type; + } - /** - *

- * setSpec. - *

- * - * @param spec a double - */ - public void setSpec(double spec) { - this.specVar = spec; - } + /** + *

+ * setSpec. + *

+ * + * @param spec a double + */ + public void setSpec(double spec) { + this.specVar = spec; + } - /** - *

- * Setter for the field fvec. - *

- */ - public void setfvec() { - for (int i = 0; i < numberOfComponents; i++) { - fvec.set(i, 0, - Math.log(system.getPhases()[0].getComponents()[i].getFugacityCoefficient()) - + Math.log(system.getPhases()[0].getComponents()[i].getx()) - - Math.log(system.getPhases()[1].getComponents()[i] - .getFugacityCoefficient()) - - Math.log(system.getPhases()[1].getComponents()[i].getx())); - } - double rP = 0.0, rT = 0.0; - if (type == 0) { - rT = 1.0 / (R * system.getTemperature()) * (specVar - system.getEnthalpy()); - rP = 0.0; - } - if (type == 1) { - rT = 1.0 / R * (specVar - system.getEntropy()); - rP = 0.0; - } - - fvec.set(numberOfComponents, 0, rT); - fvec.set(numberOfComponents + 1, 0, rP); + /** + *

+ * Setter for the field fvec. + *

+ */ + public void setfvec() { + for (int i = 0; i < numberOfComponents; i++) { + fvec.set(i, 0, Math.log(system.getPhases()[0].getComponents()[i].getFugacityCoefficient()) + + Math.log(system.getPhases()[0].getComponents()[i].getx()) + - Math.log(system.getPhases()[1].getComponents()[i].getFugacityCoefficient()) + - Math.log(system.getPhases()[1].getComponents()[i].getx())); + } + double rP = 0.0; + double rT = 0.0; + if (type == 0) { + rT = 1.0 / (R * system.getTemperature()) * (specVar - system.getEnthalpy()); + rP = 0.0; + } + if (type == 1) { + rT = 1.0 / R * (specVar - system.getEntropy()); + rP = 0.0; } - /** - *

- * setJac. - *

- */ - public void setJac() { - Jac.timesEquals(0.0); - double dij = 0.0; - - double tempJ = 0.0; - // int nofc = numberOfComponents; + fvec.set(numberOfComponents, 0, rT); + fvec.set(numberOfComponents + 1, 0, rP); + } - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < numberOfComponents; j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta - tempJ = 1.0 / system.getBeta() - * (dij / system.getPhases()[0].getComponents()[i].getx() - 1.0 - + system.getPhases()[0].getComponents()[i].getdfugdx(j)) - + 1.0 / (1.0 - system.getBeta()) - * (dij / system.getPhases()[1].getComponents()[i].getx() - 1.0 - + system.getPhases()[1].getComponents()[i].getdfugdx(j)); - Jac.set(i, j, tempJ); - } - } + /** + *

+ * setJac. + *

+ */ + public void setJac() { + Jac.timesEquals(0.0); + double dij = 0.0; - double[] gT = new double[numberOfComponents]; - double[] gP = new double[numberOfComponents]; + double tempJ = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < numberOfComponents; j++) { + dij = i == j ? 1.0 : 0.0;// Kroneckers delta + tempJ = 1.0 / system.getBeta() + * (dij / system.getPhases()[0].getComponents()[i].getx() - 1.0 + + system.getPhases()[0].getComponents()[i].getdfugdx(j)) + + 1.0 / (1.0 - system.getBeta()) + * (dij / system.getPhases()[1].getComponents()[i].getx() - 1.0 + + system.getPhases()[1].getComponents()[i].getdfugdx(j)); + Jac.set(i, j, tempJ); + } + } - for (int i = 0; i < numberOfComponents; i++) { - gT[i] = system.getTemperature() * (system.getPhases()[0].getComponents()[i].getdfugdt() - - system.getPhases()[1].getComponents()[i].getdfugdt()); - gP[i] = system.getPressure() * (system.getPhases()[0].getComponents()[i].getdfugdp() - - system.getPhases()[1].getComponents()[i].getdfugdp()); + double[] gT = new double[numberOfComponents]; + double[] gP = new double[numberOfComponents]; - Jac.set(numberOfComponents, i, gT[i]); - Jac.set(i, numberOfComponents, gT[i]); + for (int i = 0; i < numberOfComponents; i++) { + gT[i] = system.getTemperature() * (system.getPhases()[0].getComponents()[i].getdfugdt() + - system.getPhases()[1].getComponents()[i].getdfugdt()); + gP[i] = system.getPressure() * (system.getPhases()[0].getComponents()[i].getdfugdp() + - system.getPhases()[1].getComponents()[i].getdfugdp()); - Jac.set(numberOfComponents + 1, i, gP[i]); - Jac.set(i, numberOfComponents + 1, gP[i]); - } + Jac.set(numberOfComponents, i, gT[i]); + Jac.set(i, numberOfComponents, gT[i]); - double Ett = -system.getCp() / R; - Jac.set(numberOfComponents, numberOfComponents, Ett); - double Etp = system.getPressure() / R * system.getdVdTpn(); - Jac.set(numberOfComponents, numberOfComponents + 1, Etp); - Jac.set(numberOfComponents + 1, numberOfComponents, Etp); - double Epp = Math.pow(system.getPressure(), 2.0) / (R * system.getTemperature()) - * system.getdVdPtn(); - Jac.set(numberOfComponents + 1, numberOfComponents + 1, Epp); + Jac.set(numberOfComponents + 1, i, gP[i]); + Jac.set(i, numberOfComponents + 1, gP[i]); } - /** - *

- * Setter for the field u. - *

- */ - public void setu() { - for (int i = 0; i < numberOfComponents; i++) { - u.set(i, 0, 0.0); - } - u.set(numberOfComponents, 0, 0.0); - u.set(numberOfComponents + 1, 0, 0.0); + double Ett = -system.getCp() / R; + Jac.set(numberOfComponents, numberOfComponents, Ett); + double Etp = system.getPressure() / R * system.getdVdTpn(); + Jac.set(numberOfComponents, numberOfComponents + 1, Etp); + Jac.set(numberOfComponents + 1, numberOfComponents, Etp); + double Epp = + Math.pow(system.getPressure(), 2.0) / (R * system.getTemperature()) * system.getdVdPtn(); + Jac.set(numberOfComponents + 1, numberOfComponents + 1, Epp); + } + + /** + *

+ * Setter for the field u. + *

+ */ + public void setu() { + for (int i = 0; i < numberOfComponents; i++) { + u.set(i, 0, 0.0); } + u.set(numberOfComponents, 0, 0.0); + u.set(numberOfComponents + 1, 0, 0.0); + } - /** - *

- * init. - *

- */ - public void init() { - double temp = system.getBeta(); + /** + *

+ * init. + *

+ */ + public void init() { + double temp = system.getBeta(); - for (int i = 0; i < numberOfComponents; i++) { - temp += u.get(i, 0); - } - system.setBeta(temp); + for (int i = 0; i < numberOfComponents; i++) { + temp += u.get(i, 0); + } + system.setBeta(temp); - for (int i = 0; i < numberOfComponents; i++) { - double v = 0.0, l = 0.0; - v = system.getPhases()[0].getComponents()[i].getx() * system.getBeta() + u.get(i, 0); - l = system.getPhases()[0].getComponents()[i].getz() - v; - system.getPhases()[0].getComponents()[i].setx(v / system.getBeta()); - system.getPhases()[1].getComponents()[i].setx(l / (1.0 - system.getBeta())); - system.getPhases()[1].getComponents()[i] - .setK(system.getPhases()[0].getComponents()[i].getx() - / system.getPhases()[1].getComponents()[i].getx()); - system.getPhases()[0].getComponents()[i] - .setK(system.getPhases()[1].getComponents()[i].getK()); - } + for (int i = 0; i < numberOfComponents; i++) { + double v = 0.0; + double l = 0.0; + v = system.getPhases()[0].getComponents()[i].getx() * system.getBeta() + u.get(i, 0); + l = system.getPhases()[0].getComponents()[i].getz() - v; + system.getPhases()[0].getComponents()[i].setx(v / system.getBeta()); + system.getPhases()[1].getComponents()[i].setx(l / (1.0 - system.getBeta())); + system.getPhases()[1].getComponents()[i].setK(system.getPhases()[0].getComponents()[i].getx() + / system.getPhases()[1].getComponents()[i].getx()); + system.getPhases()[0].getComponents()[i] + .setK(system.getPhases()[1].getComponents()[i].getK()); + } - // dt = Math.exp(u.get(numberOfComponents+1,0)) - system.getTemperature(); - // logger.info("temperature: " + system.getTemperature()); - // logger.info("pressure: " + system.getPressure()); - // system.init(1); - // v1 = system.getVolume(); - // system.setPressure(Math.exp(u.get(numberOfComponents+1,0))); - logger.info("temperature: " + system.getTemperature()); - system.setTemperature( - Math.exp(u.get(numberOfComponents, 0) + Math.log(system.getTemperature()))); - system.setPressure( - Math.exp(u.get(numberOfComponents + 1, 0) + Math.log(system.getPressure()))); - logger.info("etter temperature: " + system.getTemperature()); + // dt = Math.exp(u.get(numberOfComponents+1,0)) - system.getTemperature(); + // logger.info("temperature: " + system.getTemperature()); + // logger.info("pressure: " + system.getPressure()); + // system.init(1); + // v1 = system.getVolume(); + // system.setPressure(Math.exp(u.get(numberOfComponents+1,0))); + logger.info("temperature: " + system.getTemperature()); + system + .setTemperature(Math.exp(u.get(numberOfComponents, 0) + Math.log(system.getTemperature()))); + system.setPressure(Math.exp(u.get(numberOfComponents + 1, 0) + Math.log(system.getPressure()))); + logger.info("etter temperature: " + system.getTemperature()); - system.init(3); - } + system.init(3); + } - /** - *

- * solve. - *

- * - * @param np a int - * @return a int - */ - public int solve(int np) { - // Matrix dx; - iter = 1; - do { - iter++; - init(); - setfvec(); - setJac(); - fvec.print(10, 10); - Jac.print(10, 10); - u = Jac.solve(fvec.times(-1.0)); - // u.equals(dx.timesEquals(1.0)); - fvec.print(10, 10); - logger.info("iter: " + iter); - } while (fvec.norm2() > 1.e-10 && iter < 1000);// && Double.isNaN(dx.norm2())); - logger.info("iter: " + iter); - logger.info("temperature: " + system.getTemperature()); - logger.info("pressure: " + system.getPressure()); - init(); - return iter; - } + /** + *

+ * solve. + *

+ * + * @param np a int + * @return a int + */ + public int solve(int np) { + iter = 1; + do { + iter++; + init(); + setfvec(); + setJac(); + fvec.print(10, 10); + Jac.print(10, 10); + u = Jac.solve(fvec.times(-1.0)); + // u.equals(dx.timesEquals(1.0)); + fvec.print(10, 10); + logger.info("iter: " + iter); + } while (fvec.norm2() > 1.e-10 && iter < 1000);// && Double.isNaN(dx.norm2())); + logger.info("iter: " + iter); + logger.info("temperature: " + system.getTemperature()); + logger.info("pressure: " + system.getPressure()); + init(); + return iter; + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/sysNewtonRhapsonTPflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/sysNewtonRhapsonTPflash.java index 445fb8ed05..7190082673 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/sysNewtonRhapsonTPflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/sysNewtonRhapsonTPflash.java @@ -12,154 +12,160 @@ * @version $Id: $Id */ public class sysNewtonRhapsonTPflash implements java.io.Serializable { - private static final long serialVersionUID = 1000; - int neq = 0, iter = 0; - int ic02p = -100, ic03p = -100, testcrit = 0, npCrit = 0; - double beta = 0, ds = 0, dTmax = 1, dPmax = 1, avscp = 0.1, TC1 = 0, TC2 = 0, PC1 = 0, PC2 = 0; - Matrix Jac; - Matrix fvec; - Matrix u; - Matrix uold; - Matrix Xgij; - SystemInterface system; - int numberOfComponents; - int speceq = 0; - Matrix a = new Matrix(4, 4); - Matrix s = new Matrix(1, 4); - Matrix xg; - Matrix dx; - Matrix xcoef; + private static final long serialVersionUID = 1000; + int neq = 0; + int iter = 0; + int ic02p = -100; + int ic03p = -100; + int testcrit = 0; + int npCrit = 0; + double beta = 0; + double ds = 0; + double dTmax = 1; + double dPmax = 1; + double avscp = 0.1; + double TC1 = 0; + double TC2 = 0; + double PC1 = 0; + double PC2 = 0; + Matrix Jac; + Matrix fvec; + Matrix u; + Matrix uold; + Matrix Xgij; + SystemInterface system; + int numberOfComponents; + int speceq = 0; + Matrix a = new Matrix(4, 4); + Matrix s = new Matrix(1, 4); + Matrix xg; + Matrix dx; + Matrix xcoef; - /** - *

- * Constructor for sysNewtonRhapsonTPflash. - *

- */ - public sysNewtonRhapsonTPflash() {} + /** + *

+ * Constructor for sysNewtonRhapsonTPflash. + *

+ */ + public sysNewtonRhapsonTPflash() {} - /** - *

- * Constructor for sysNewtonRhapsonTPflash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param numberOfPhases a int - * @param numberOfComponents a int - */ - public sysNewtonRhapsonTPflash(SystemInterface system, int numberOfPhases, - int numberOfComponents) { - this.system = system; - this.numberOfComponents = numberOfComponents; - neq = numberOfComponents; - Jac = new Matrix(neq, neq); - fvec = new Matrix(neq, 1); - u = new Matrix(neq, 1); - Xgij = new Matrix(neq, 4); - setu(); - uold = u.copy(); - // System.out.println("Spec : " +speceq); - } + /** + *

+ * Constructor for sysNewtonRhapsonTPflash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param numberOfPhases a int + * @param numberOfComponents a int + */ + public sysNewtonRhapsonTPflash(SystemInterface system, int numberOfPhases, + int numberOfComponents) { + this.system = system; + this.numberOfComponents = numberOfComponents; + neq = numberOfComponents; + Jac = new Matrix(neq, neq); + fvec = new Matrix(neq, 1); + u = new Matrix(neq, 1); + Xgij = new Matrix(neq, 4); + setu(); + uold = u.copy(); + // System.out.println("Spec : " +speceq); + } - /** - *

- * Setter for the field fvec. - *

- */ - public void setfvec() { - for (int i = 0; i < numberOfComponents; i++) { - fvec.set(i, 0, Math - .log(system.getPhase(0).getComponents()[i].getFugacityCoefficient() - * system.getPhase(0).getComponents()[i].getx() * system.getPressure()) - - Math.log(system.getPhase(1).getComponents()[i].getFugacityCoefficient() - * system.getPhase(1).getComponents()[i].getx() * system.getPressure())); - } + /** + *

+ * Setter for the field fvec. + *

+ */ + public void setfvec() { + for (int i = 0; i < numberOfComponents; i++) { + fvec.set(i, 0, + Math.log(system.getPhase(0).getComponents()[i].getFugacityCoefficient() + * system.getPhase(0).getComponents()[i].getx() * system.getPressure()) + - Math.log(system.getPhase(1).getComponents()[i].getFugacityCoefficient() + * system.getPhase(1).getComponents()[i].getx() * system.getPressure())); } + } - /** - *

- * setJac. - *

- */ - public void setJac() { - Jac.timesEquals(0.0); - double dij = 0.0; - - double tempJ = 0.0; - // double sumdyidbeta = 0, sumdxidbeta = 0; - // int nofc = numberOfComponents; + /** + *

+ * setJac. + *

+ */ + public void setJac() { + Jac.timesEquals(0.0); + double dij = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < numberOfComponents; j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta - tempJ = 1.0 / system.getBeta() - * (dij / system.getPhase(0).getComponents()[i].getx() - 1.0 - + system.getPhase(0).getComponents()[i].getdfugdx(j)) - + 1.0 / (1.0 - system.getBeta()) - * (dij / system.getPhase(1).getComponents()[i].getx() - 1.0 - + system.getPhase(1).getComponents()[i].getdfugdx(j)); - Jac.set(i, j, tempJ); - } - } + double tempJ = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < numberOfComponents; j++) { + dij = i == j ? 1.0 : 0.0;// Kroneckers delta + tempJ = 1.0 / system.getBeta() + * (dij / system.getPhase(0).getComponents()[i].getx() - 1.0 + + system.getPhase(0).getComponents()[i].getdfugdx(j)) + + 1.0 / (1.0 - system.getBeta()) * (dij / system.getPhase(1).getComponents()[i].getx() + - 1.0 + system.getPhase(1).getComponents()[i].getdfugdx(j)); + Jac.set(i, j, tempJ); + } } + } - /** - *

- * Setter for the field u. - *

- */ - public void setu() { - for (int i = 0; i < numberOfComponents; i++) { - u.set(i, 0, system.getBeta() * system.getPhase(0).getComponents()[i].getx()); - } + /** + *

+ * Setter for the field u. + *

+ */ + public void setu() { + for (int i = 0; i < numberOfComponents; i++) { + u.set(i, 0, system.getBeta() * system.getPhase(0).getComponents()[i].getx()); } + } - /** - *

- * init. - *

- */ - public void init() { - double temp = 0; - - for (int i = 0; i < numberOfComponents; i++) { - temp += u.get(i, 0); - } + /** + *

+ * init. + *

+ */ + public void init() { + double temp = 0; - system.setBeta(temp); - for (int i = 0; i < numberOfComponents; i++) { - system.getPhase(0).getComponents()[i].setx(u.get(i, 0) / system.getBeta()); - system.getPhase(1).getComponents()[i] - .setx((system.getPhase(0).getComponents()[i].getz() - u.get(i, 0)) - / (1.0 - system.getBeta())); - system.getPhase(0).getComponents()[i].setK(system.getPhase(0).getComponents()[i].getx() - / system.getPhase(1).getComponents()[i].getx()); - system.getPhase(1).getComponents()[i] - .setK(system.getPhase(0).getComponents()[i].getK()); - } + for (int i = 0; i < numberOfComponents; i++) { + temp += u.get(i, 0); + } - system.init(3); + system.setBeta(temp); + for (int i = 0; i < numberOfComponents; i++) { + system.getPhase(0).getComponents()[i].setx(u.get(i, 0) / system.getBeta()); + system.getPhase(1).getComponents()[i].setx( + (system.getPhase(0).getComponents()[i].getz() - u.get(i, 0)) / (1.0 - system.getBeta())); + system.getPhase(0).getComponents()[i].setK(system.getPhase(0).getComponents()[i].getx() + / system.getPhase(1).getComponents()[i].getx()); + system.getPhase(1).getComponents()[i].setK(system.getPhase(0).getComponents()[i].getK()); } - /** - *

- * solve. - *

- * - * @return a double - * @throws java.lang.Exception if any. - */ - public double solve() throws Exception { - try { - iter++; - init(); - setfvec(); - setJac(); - dx = Jac.solve(fvec); - // dx.print(10,10); - u.minusEquals(dx); - return (dx.norm2() / u.norm2()); - } catch (Exception e) { - throw e; - } + system.init(3); + } + + /** + *

+ * solve. + *

+ * + * @return a double + * @throws java.lang.Exception if any. + */ + public double solve() throws Exception { + try { + iter++; + init(); + setfvec(); + setJac(); + dx = Jac.solve(fvec); + // dx.print(10,10); + u.minusEquals(dx); + return (dx.norm2() / u.norm2()); + } catch (Exception e) { + throw e; } + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope.java index d6a116ea16..f65e1ba130 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope.java @@ -25,830 +25,825 @@ * @version $Id: $Id */ public class pTphaseEnvelope extends BaseOperation { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(pTphaseEnvelope.class); - - double maxPressure = 1000.0; - double minPressure = 1.0; - double[][] copiedPoints = null; - graph2b graph2 = null; - SystemInterface system; - boolean bubblePointFirst = true; - boolean hascopiedPoints = false; - double[] cricondenTherm = new double[3]; - double[] cricondenBar = new double[3]; - double[] cricondenThermX = new double[100]; - double[] cricondenThermY = new double[100]; - double[] cricondenBarX = new double[100]; - double[] cricondenBarY = new double[100]; - double phaseFraction = 1e-10; - int i, j = 0, nummer = 0, iterations = 0, maxNumberOfIterations = 10000; - double gibbsEnergy = 0, gibbsEnergyOld = 0; - double Kold, deviation = 0, g0 = 0, g1 = 0, lowPres = 1.0; - double lnOldOldK[], lnK[]; - boolean outputToFile = false; - double lnOldK[]; - double lnKwil[]; - double oldDeltalnK[], deltalnK[]; - double tm[] = {1, 1}; - double beta = 1e-5; - int lowestGibbsEnergyPhase = 0; // lowestGibbsEnergyPhase - JProgressBar monitor; - JFrame mainFrame; - String fileName = "c:/file"; - JPanel mainPanel; - double temp = 0, pres = 0, startPres = 0; - double[][] points = new double[2][]; - double[] pointsH; - double[][] pointsH2 = new double[4][]; - double[] pointsV; - double[][] pointsV2 = new double[4][]; - double[] pointsS; - double[][] pointsS2 = new double[4][]; - public double[][] points2 = new double[4][]; - double[][] points3 = new double[8][]; - boolean moreLines = false; - boolean restart = true; - int np = 0; - // points[2] = new double[1000]; - int speceq = 0; - String[] navn = {"bubble point", "dew point", "bubble point", "dew point", "dew points"}; - int npfirst; - int ncrfirst; - double Tcfirst; - double Pcfirst; - double Tmin = 0.0; - - double[] cricondenThermfirst = new double[3]; - double[] cricondenBarfirst = new double[3]; - double[] cricondenThermXfirst = new double[100]; - double[] cricondenThermYfirst = new double[100]; - double[] cricondenBarXfirst = new double[100]; - double[] cricondenBarYfirst = new double[100]; - - /** - *

- * Constructor for pTphaseEnvelope. - *

- */ - public pTphaseEnvelope() {} - - /** - *

- * Constructor for pTphaseEnvelope. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param name a {@link java.lang.String} object - * @param phaseFraction a double - * @param lowPres a double - * @param bubfirst a boolean - */ - public pTphaseEnvelope(SystemInterface system, String name, double phaseFraction, - double lowPres, boolean bubfirst) { - this.bubblePointFirst = bubfirst; - if (name != null) { - outputToFile = true; - fileName = name; - } - this.system = system; - this.phaseFraction = phaseFraction; - lnOldOldK = new double[system.getPhase(0).getNumberOfComponents()]; - lnOldK = new double[system.getPhase(0).getNumberOfComponents()]; - lnK = new double[system.getPhase(0).getNumberOfComponents()]; - this.lowPres = lowPres; - oldDeltalnK = new double[system.getPhase(0).getNumberOfComponents()]; - deltalnK = new double[system.getPhase(0).getNumberOfComponents()]; + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(pTphaseEnvelope.class); + + double maxPressure = 1000.0; + double minPressure = 1.0; + double[][] copiedPoints = null; + graph2b graph2 = null; + SystemInterface system; + boolean bubblePointFirst = true; + boolean hascopiedPoints = false; + double[] cricondenTherm = new double[3]; + double[] cricondenBar = new double[3]; + double[] cricondenThermX = new double[100]; + double[] cricondenThermY = new double[100]; + double[] cricondenBarX = new double[100]; + double[] cricondenBarY = new double[100]; + double phaseFraction = 1e-10; + int i; + int j = 0; + int nummer = 0; + int iterations = 0; + int maxNumberOfIterations = 10000; + double gibbsEnergy = 0; + double gibbsEnergyOld = 0; + double Kold; + double deviation = 0; + double g0 = 0; + double g1 = 0; + double lowPres = 1.0; + double[] lnOldOldK; + double[] lnK; + boolean outputToFile = false; + double[] lnOldK; + double[] lnKwil; + double[] oldDeltalnK; + double[] deltalnK; + double[] tm = {1, 1}; + double beta = 1e-5; + int lowestGibbsEnergyPhase = 0; // lowestGibbsEnergyPhase + JProgressBar monitor; + JFrame mainFrame; + String fileName = "c:/file"; + JPanel mainPanel; + double temp = 0; + double pres = 0; + double startPres = 0; + double[][] points = new double[2][]; + double[] pointsH; + double[][] pointsH2 = new double[4][]; + double[] pointsV; + double[][] pointsV2 = new double[4][]; + double[] pointsS; + double[][] pointsS2 = new double[4][]; + public double[][] points2 = new double[4][]; + double[][] points3 = new double[8][]; + boolean moreLines = false; + boolean restart = true; + int np = 0; + // points[2] = new double[1000]; + int speceq = 0; + String[] navn = {"bubble point", "dew point", "bubble point", "dew point", "dew points"}; + int npfirst; + int ncrfirst; + double Tcfirst; + double Pcfirst; + double Tmin = 0.0; + + double[] cricondenThermfirst = new double[3]; + double[] cricondenBarfirst = new double[3]; + double[] cricondenThermXfirst = new double[100]; + double[] cricondenThermYfirst = new double[100]; + double[] cricondenBarXfirst = new double[100]; + double[] cricondenBarYfirst = new double[100]; + + /** + *

+ * Constructor for pTphaseEnvelope. + *

+ */ + public pTphaseEnvelope() {} + + /** + *

+ * Constructor for pTphaseEnvelope. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param name a {@link java.lang.String} object + * @param phaseFraction a double + * @param lowPres a double + * @param bubfirst a boolean + */ + public pTphaseEnvelope(SystemInterface system, String name, double phaseFraction, double lowPres, + boolean bubfirst) { + this.bubblePointFirst = bubfirst; + if (name != null) { + outputToFile = true; + fileName = name; } - - /** {@inheritDoc} */ - @Override - public void run() { - speceq = 0; // initialization + this.system = system; + this.phaseFraction = phaseFraction; + lnOldOldK = new double[system.getPhase(0).getNumberOfComponents()]; + lnOldK = new double[system.getPhase(0).getNumberOfComponents()]; + lnK = new double[system.getPhase(0).getNumberOfComponents()]; + this.lowPres = lowPres; + oldDeltalnK = new double[system.getPhase(0).getNumberOfComponents()]; + deltalnK = new double[system.getPhase(0).getNumberOfComponents()]; + } + + /** {@inheritDoc} */ + @Override + public void run() { + speceq = 0; // initialization + try { + points[0] = new double[10000]; // declarations for points + points[1] = new double[10000]; // declarations for points + + pointsH = new double[10000]; // declarations for points + pointsV = new double[10000]; // declarations for points + pointsS = new double[10000]; // declarations for points + system.init(0); // initialization + + // selects the most volatile and least volatile component based on Tc values + // afterwards it uses them to define the speceq of the first point + // based on the desired first point, dew/bubble + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (system.getComponent(i).getz() < 1e-10) { + continue; + } + if (system.getPhase(0).getComponent(i).getIonicCharge() == 0) { + if (bubblePointFirst == true && system.getPhase(0).getComponents()[speceq] + .getTC() > system.getPhase(0).getComponents()[i].getTC()) { + speceq = system.getPhase(0).getComponent(i).getComponentNumber(); + } + if (bubblePointFirst == false && system.getPhase(0).getComponents()[speceq] + .getTC() < system.getPhase(0).getComponents()[i].getTC()) { + speceq = system.getPhase(0).getComponent(i).getComponentNumber(); + } + } + } + + // initialized the first step of the phase envelope + // pressure is already defined + // temperature is the antoine vapor pressure of the selected component + // (least or most volatile. + pres = lowPres; + // temp = + // system.getPhase(0).getComponent(speceq).getAntoineVaporTemperature(pres); + temp = tempKWilson(phaseFraction, pres); + + if (Double.isNaN(temp)) { + temp = system.getPhase(0).getComponent(speceq).getTC() - 20.0; + } + system.setTemperature(temp); + system.setPressure(pres); + + ThermodynamicOperations testOps = new ThermodynamicOperations(system); + + // this part converges the first phase envelope point. + // if the plasefraction is more than 0.5 it does a dew point initiallization + // else a bubble point initiallization + + for (int i = 0; i < 5; i++) { try { - points[0] = new double[10000]; // declarations for points - points[1] = new double[10000]; // declarations for points - - pointsH = new double[10000]; // declarations for points - pointsV = new double[10000]; // declarations for points - pointsS = new double[10000]; // declarations for points - system.init(0); // initialization - - // selects the most volatile and least volatile component based on Tc values - // afterwards it uses them to define the speceq of the first point - // based on the desired first point, dew/bubble - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - if (system.getComponent(i).getz() < 1e-10) { - continue; - } - if (system.getPhase(0).getComponent(i).getIonicCharge() == 0) { - if (bubblePointFirst == true && system.getPhase(0).getComponents()[speceq] - .getTC() > system.getPhase(0).getComponents()[i].getTC()) { - speceq = system.getPhase(0).getComponent(i).getComponentNumber(); - } - if (bubblePointFirst == false && system.getPhase(0).getComponents()[speceq] - .getTC() < system.getPhase(0).getComponents()[i].getTC()) { - speceq = system.getPhase(0).getComponent(i).getComponentNumber(); - } - } - } - - // initialized the first step of the phase envelope - // pressure is already defined - // temperature is the antoine vapor pressure of the selected component - // (least or most volatile. - pres = lowPres; - // temp = - // system.getPhase(0).getComponent(speceq).getAntoineVaporTemperature(pres); - temp = tempKWilson(phaseFraction, pres); - - if (Double.isNaN(temp)) { - temp = system.getPhase(0).getComponent(speceq).getTC() - 20.0; - } + if (phaseFraction < 0.5) { + temp += i * 2; system.setTemperature(temp); - system.setPressure(pres); - - ThermodynamicOperations testOps = new ThermodynamicOperations(system); - - // this part converges the first phase envelope point. - // if the plasefraction is more than 0.5 it does a dew point initiallization - // else a bubble point initiallization - - for (int i = 0; i < 5; i++) { - try { - if (phaseFraction < 0.5) { - temp += i * 2; - system.setTemperature(temp); - testOps.bubblePointTemperatureFlash(); - } else { - temp += i * 2; - system.setTemperature(temp); - testOps.dewPointTemperatureFlash(); - } - } catch (Exception e) { - e.toString(); - } - double tempNy = system.getTemperature(); - - if (!Double.isNaN(tempNy)) { - temp = tempNy; - break; - } - } - - // this part sets the first envelope point into the system - system.setBeta(phaseFraction); - system.setPressure(pres); + testOps.bubblePointTemperatureFlash(); + } else { + temp += i * 2; system.setTemperature(temp); + testOps.dewPointTemperatureFlash(); + } + } catch (Exception e) { + // e.toString(); + } + double tempNy = system.getTemperature(); - sysNewtonRhapsonPhaseEnvelope nonLinSolver = new sysNewtonRhapsonPhaseEnvelope(system, - 2, system.getPhase(0).getNumberOfComponents()); - startPres = system.getPressure(); - nonLinSolver.setu(); - for (np = 1; np < 9980; np++) { - try { - // solves the np point of the envelope - nonLinSolver.calcInc(np); - nonLinSolver.solve(np); - - // this catches the exceptions - // double TT = system.getPhase(0).getTemperature(); - // double PP = system.getPhase(0).getPressure(); - } catch (Exception e0) { - // the envelope crushed. - // this part keeps the old values - // restarts the envelope from the other side - // and then stops - - if (restart) { - restart = false; - // keep values - Tmin = points[0][np - 2]; - npfirst = np - 1; - ncrfirst = nonLinSolver.getNpCrit(); - if (ncrfirst == 0) { - ncrfirst = npfirst; - } - Tcfirst = system.getTC(); - Pcfirst = system.getPC(); - - cricondenBarfirst = cricondenBar; - cricondenBarXfirst = cricondenBarX; - cricondenBarYfirst = cricondenBarY; - - cricondenThermfirst = cricondenTherm; - cricondenThermXfirst = cricondenThermX; - cricondenThermYfirst = cricondenThermY; - - hascopiedPoints = true; - copiedPoints = new double[5][np - 1]; - for (int i = 0; i < np - 1; i++) { - copiedPoints[0][i] = points[0][i]; - copiedPoints[1][i] = points[1][i]; - copiedPoints[2][i] = pointsH[i]; - copiedPoints[3][i] = pointsS[i]; - copiedPoints[4][i] = pointsV[i]; - } - - // new settings - phaseFraction = 1.0 - phaseFraction; - if (bubblePointFirst) { - bubblePointFirst = false; - } else { - bubblePointFirst = true; - } - run(); - /**/ - break; - } else { - np = np - 1; - break; - } - } - - // check for critical point - double Kvallc = system.getPhase(0).getComponent(nonLinSolver.lc).getx() - / system.getPhase(1).getComponent(nonLinSolver.lc).getx(); - double Kvalhc = system.getPhase(0).getComponent(nonLinSolver.hc).getx() - / system.getPhase(1).getComponent(nonLinSolver.hc).getx(); - // double densV = system.getPhase(0).getDensity(); - // double densL = system.getPhase(1).getDensity(); - - // System.out.println(np + " " + system.getTemperature() + " " + - // system.getPressure() + " " + densV + " " + densL ); - - if ((nonLinSolver.etterCP == false)) { - if (Kvallc < 1.05 && Kvalhc > 0.95) { - // close to the critical point - // invert phase types and find the CP Temp and Press - - // System.out.println("critical point"); - nonLinSolver.npCrit = np; - system.invertPhaseTypes(); - nonLinSolver.etterCP = true; - // the critical point is found from interpolation plynimials based on K=1 of - // the - // most or least volatile component - nonLinSolver.calcCrit(); - } - } - if (nonLinSolver.calcCP) { - nonLinSolver.calcCP = false; - nonLinSolver.npCrit = np; - nonLinSolver.calcCrit(); - } - - // stores critondenbar and cricondentherm - // HERE the new cricoT and crico P values will be called instead - if (system.getTemperature() > cricondenTherm[0]) { - cricondenTherm[1] = system.getPressure(); - cricondenTherm[0] = system.getTemperature(); - for (int ii = 0; ii < nonLinSolver.numberOfComponents; ii++) { - cricondenThermX[ii] = system.getPhase(1).getComponent(ii).getx(); - cricondenThermY[ii] = system.getPhase(0).getComponent(ii).getx(); - } - } else { - nonLinSolver.ettercricoT = true; - } - if (system.getPressure() > cricondenBar[1]) { - cricondenBar[0] = system.getTemperature(); - cricondenBar[1] = system.getPressure(); - for (int ii = 0; ii < nonLinSolver.numberOfComponents; ii++) { - cricondenBarX[ii] = system.getPhase(1).getComponent(ii).getx(); - cricondenBarY[ii] = system.getPhase(0).getComponent(ii).getx(); - } - } - - // Exit criteria - if ((system.getPressure() < minPressure && nonLinSolver.ettercricoT)) { - break; - } - if (system.getPressure() > maxPressure) { - break; - } - if (system.getTemperature() > Tmin && !restart) { - break; - } - - // Keeps the calculated points - points[0][np - 1] = system.getTemperature(); - points[1][np - 1] = system.getPressure(); - pointsH[np - 1] = system.getPhase(1).getEnthalpy() - / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - pointsV[np - 1] = system.getPhase(1).getDensity(); - pointsS[np - 1] = system.getPhase(1).getEntropy() - / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; + if (!Double.isNaN(tempNy)) { + temp = tempNy; + break; + } + } + + // this part sets the first envelope point into the system + system.setBeta(phaseFraction); + system.setPressure(pres); + system.setTemperature(temp); + + sysNewtonRhapsonPhaseEnvelope nonLinSolver = + new sysNewtonRhapsonPhaseEnvelope(system, 2, system.getPhase(0).getNumberOfComponents()); + startPres = system.getPressure(); + nonLinSolver.setu(); + for (np = 1; np < 9980; np++) { + try { + // solves the np point of the envelope + nonLinSolver.calcInc(np); + nonLinSolver.solve(np); + + // this catches the exceptions + // double TT = system.getPhase(0).getTemperature(); + // double PP = system.getPhase(0).getPressure(); + } catch (Exception e0) { + // the envelope crushed. + // this part keeps the old values + // restarts the envelope from the other side + // and then stops + + if (restart) { + restart = false; + // keep values + Tmin = points[0][np - 2]; + npfirst = np - 1; + ncrfirst = nonLinSolver.getNpCrit(); + if (ncrfirst == 0) { + ncrfirst = npfirst; } - - try { - int ncr = nonLinSolver.getNpCrit(); - if (ncr == 0) { - ncr = np; - } - int ncr2 = np - ncr; - if (hascopiedPoints) { - // if it enters here the envelope crashed and restarted - // reallocate to have all values - points2 = new double[8][]; - pointsH2 = new double[8][]; - pointsS2 = new double[8][]; - pointsV2 = new double[8][]; - } - - // points2 are plotted - points2[0] = new double[ncr + 1]; - points2[1] = new double[ncr + 1]; - pointsH2[0] = new double[ncr + 1]; - pointsH2[1] = new double[ncr + 1]; - pointsS2[0] = new double[ncr + 1]; - pointsS2[1] = new double[ncr + 1]; - pointsV2[0] = new double[ncr + 1]; - pointsV2[1] = new double[ncr + 1]; - - if (ncr2 > 2) { - points2[2] = new double[ncr2 - 2]; - points2[3] = new double[ncr2 - 2]; - pointsH2[2] = new double[ncr2 - 2]; - pointsH2[3] = new double[ncr2 - 2]; - pointsS2[2] = new double[ncr2 - 2]; - pointsS2[3] = new double[ncr2 - 2]; - pointsV2[2] = new double[ncr2 - 2]; - pointsV2[3] = new double[ncr2 - 2]; - } else { - points2[2] = new double[0]; - points2[3] = new double[0]; - pointsH2[2] = new double[0]; - pointsH2[3] = new double[0]; - pointsS2[2] = new double[0]; - pointsS2[3] = new double[0]; - pointsV2[2] = new double[0]; - pointsV2[3] = new double[0]; - } - - for (int i = 0; i < ncr; i++) { - // second branch up to critical point - points2[0][i] = points[0][i]; - points2[1][i] = points[1][i]; - pointsH2[1][i] = points[1][i]; - pointsH2[0][i] = pointsH[i]; - pointsS2[1][i] = points[1][i]; - pointsS2[0][i] = pointsS[i]; - pointsV2[1][i] = points[1][i]; - pointsV2[0][i] = pointsV[i]; - } - if (ncr2 > 2) { - for (int i = 1; i < (ncr2 - 2); i++) { - // second branch after the critical point - points2[2][i] = points[0][i + ncr - 1]; - points2[3][i] = points[1][i + ncr - 1]; - pointsH2[3][i] = points[1][i + ncr - 1]; - pointsH2[2][i] = pointsH[i + ncr - 1]; - pointsS2[3][i] = points[1][i + ncr - 1]; - pointsS2[2][i] = pointsS[i + ncr - 1]; - pointsV2[3][i] = points[1][i + ncr - 1]; - pointsV2[2][i] = pointsV[i + ncr - 1]; - } - } - - if (hascopiedPoints) { - if (ncrfirst > npfirst) { - ncr = copiedPoints[0].length - 1; - ncr2 = npfirst - ncr; - npfirst = npfirst - 1; - } else { - ncr = ncrfirst; - ncr2 = npfirst - ncr; - } - - points2[4] = new double[ncr + 1]; - points2[5] = new double[ncr + 1]; - pointsH2[4] = new double[ncr + 1]; - pointsH2[5] = new double[ncr + 1]; - pointsS2[4] = new double[ncr + 1]; - pointsS2[5] = new double[ncr + 1]; - pointsV2[4] = new double[ncr + 1]; - pointsV2[5] = new double[ncr + 1]; - - if (ncr2 > 2) { - points2[6] = new double[ncr2 - 2]; - points2[7] = new double[ncr2 - 2]; - pointsH2[6] = new double[ncr2 - 2]; - pointsH2[7] = new double[ncr2 - 2]; - pointsS2[6] = new double[ncr2 - 2]; - pointsS2[7] = new double[ncr2 - 2]; - pointsV2[6] = new double[ncr2 - 2]; - pointsV2[7] = new double[ncr2 - 2]; - } else { - points2[6] = new double[0]; - points2[7] = new double[0]; - pointsH2[6] = new double[0]; - pointsH2[7] = new double[0]; - pointsS2[6] = new double[0]; - pointsS2[7] = new double[0]; - pointsV2[6] = new double[0]; - pointsV2[7] = new double[0]; - } - - for (int i = 0; i < ncr; i++) { - // first branch up to the critical point - points2[4][i] = copiedPoints[0][i]; - points2[5][i] = copiedPoints[1][i]; - pointsH2[5][i] = copiedPoints[1][i]; - pointsH2[4][i] = copiedPoints[2][i]; - pointsS2[5][i] = copiedPoints[1][i]; - pointsS2[4][i] = copiedPoints[3][i]; - pointsV2[5][i] = copiedPoints[1][i]; - pointsV2[4][i] = copiedPoints[4][i]; - } - if (ncr2 > 2) { - for (int i = 1; i < (ncr2 - 2); i++) { - // first branch after the critical point - points2[6][i] = copiedPoints[0][i + ncr - 1]; - points2[7][i] = copiedPoints[1][i + ncr - 1]; - pointsH2[7][i] = copiedPoints[1][i + ncr - 1]; - pointsH2[6][i] = copiedPoints[2][i + ncr - 1]; - pointsS2[7][i] = copiedPoints[1][i + ncr - 1]; - pointsS2[6][i] = copiedPoints[3][i + ncr - 1]; - pointsV2[7][i] = copiedPoints[1][i + ncr - 1]; - pointsV2[6][i] = copiedPoints[4][i + ncr - 1]; - } - } - } - - // critical point - system.setTemperature(system.getTC()); - system.setPressure(system.getPC()); - - points2[0][ncr] = system.getTC(); - points2[1][ncr] = system.getPC(); - if (ncr2 > 2) { - points2[2][0] = system.getTC(); - points2[3][0] = system.getPC(); - } - } catch (Exception e2) { - // double nef = 0.; - // logger.error("error", e2); + Tcfirst = system.getTC(); + Pcfirst = system.getPC(); + + cricondenBarfirst = cricondenBar; + cricondenBarXfirst = cricondenBarX; + cricondenBarYfirst = cricondenBarY; + + cricondenThermfirst = cricondenTherm; + cricondenThermXfirst = cricondenThermX; + cricondenThermYfirst = cricondenThermY; + + hascopiedPoints = true; + copiedPoints = new double[5][np - 1]; + for (int i = 0; i < np - 1; i++) { + copiedPoints[0][i] = points[0][i]; + copiedPoints[1][i] = points[1][i]; + copiedPoints[2][i] = pointsH[i]; + copiedPoints[3][i] = pointsS[i]; + copiedPoints[4][i] = pointsV[i]; } -/* - try { - if (outputToFile) { - // update this - String name1 = new String(); - name1 = fileName + "Dew.nc"; - file1 = new neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); - file1.setOutputFileName(name1); - file1.setXvalues(points2[2], "temp", "sec"); - file1.setYvalues(points2[3], "pres", "meter"); - file1.createFile(); - - String name2 = new String(); - name2 = fileName + "Bub.nc"; - file2 = new neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); - file2.setOutputFileName(name2); - file2.setXvalues(points2[0], "temp", "sec"); - file2.setYvalues(points2[1], "pres", "meter"); - file2.createFile(); - } - } catch (Exception e3) { - // double nef = 0.; - logger.error("error", e3); + + // new settings + phaseFraction = 1.0 - phaseFraction; + if (bubblePointFirst) { + bubblePointFirst = false; + } else { + bubblePointFirst = true; } - */ - } catch (Exception e4) { - // double nef = 0.; - logger.error("error", e4); + run(); + /**/ + break; + } else { + np = np - 1; + break; + } } - } - /** - *

- * calcHydrateLine. - *

- */ - public void calcHydrateLine() { - ThermodynamicOperations opsHyd = new ThermodynamicOperations(system); - try { - opsHyd.hydrateEquilibriumLine(10.0, 300.0); - } catch (Exception e) { - logger.error("error", e); + // check for critical point + double Kvallc = system.getPhase(0).getComponent(nonLinSolver.lc).getx() + / system.getPhase(1).getComponent(nonLinSolver.lc).getx(); + double Kvalhc = system.getPhase(0).getComponent(nonLinSolver.hc).getx() + / system.getPhase(1).getComponent(nonLinSolver.hc).getx(); + // double densV = system.getPhase(0).getDensity(); + // double densL = system.getPhase(1).getDensity(); + + // System.out.println(np + " " + system.getTemperature() + " " + + // system.getPressure() + " " + densV + " " + densL ); + + if ((nonLinSolver.etterCP == false)) { + if (Kvallc < 1.05 && Kvalhc > 0.95) { + // close to the critical point + // invert phase types and find the CP Temp and Press + + // System.out.println("critical point"); + nonLinSolver.npCrit = np; + system.invertPhaseTypes(); + nonLinSolver.etterCP = true; + // the critical point is found from interpolation plynimials based on K=1 of + // the + // most or least volatile component + nonLinSolver.calcCrit(); + } } - - // double[][] hydData = opsHyd.getData(); - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - DecimalFormat nf = new DecimalFormat(); - nf.setMaximumFractionDigits(1); - nf.applyPattern("####.#"); - if (bubblePointFirst) { - // bubble point side - navn[0] = "bubble point 2"; - navn[1] = "dew point 2"; - navn[2] = "dew point 1"; - navn[3] = "bubble point 1"; - } else { - // dew point side and does not crash - navn[0] = "dew point 2"; - navn[1] = "bubble point 2"; - navn[2] = "dew point 1"; - navn[3] = "bubbl point 1"; + if (nonLinSolver.calcCP) { + nonLinSolver.calcCP = false; + nonLinSolver.npCrit = np; + nonLinSolver.calcCrit(); } - double TC = system.getTC(); - double PC = system.getPC(); - - String title = "PT-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - String title3 = "PH-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - String title4 = "Density-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - String title5 = "PS-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - - graph2b graph3 = new graph2b(pointsH2, navn, title3, "Enthalpy [kJ/kg]", "Pressure [bara]"); - graph3.setVisible(true); - // graph3.saveFigure(new String(util.util.FileSystemSettings.tempDir + - // "NeqSimTempFig4.png")); - - graph2b graph4 = new graph2b(pointsV2, navn, title4, "Density [kg/m^3]", "Pressure [bara]"); - graph4.setVisible(true); - // graph4.saveFigure(util.util.FileSystemSettings.tempDir + - // "NeqSimTempFig2.png"); - - graph2b graph5 = - new graph2b(pointsS2, navn, title5, "Entropy [kJ/kg*K]", "Pressure [bara]"); - graph5.setVisible(true); - // graph5.saveFigure(util.util.FileSystemSettings.tempDir + - // "NeqSimTempFig3.png"); - - graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); - graph2.setVisible(true); - // graph2.saveFigure(util.util.FileSystemSettings.tempDir + - // "NeqSimTempFig1.png"); - - /* - * JDialog dialog = new JDialog(); Container dialogContentPane = dialog.getContentPane(); - * dialogContentPane.setLayout(new FlowLayout()); JFreeChartPanel chartPanel = - * graph4.getChartPanel(); dialogContentPane.add(chartPanel); dialog.show(); - */ - } - - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} - - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - DecimalFormat nf = new DecimalFormat(); - nf.setMaximumFractionDigits(1); - nf.applyPattern("####.#"); - if (bubblePointFirst) { - // bubble point side - navn[0] = "bubble point 2"; - navn[1] = "dew point 2"; - navn[2] = "dew point 1"; - navn[3] = "bubble point 1"; + // stores critondenbar and cricondentherm + // HERE the new cricoT and crico P values will be called instead + if (system.getTemperature() > cricondenTherm[0]) { + cricondenTherm[1] = system.getPressure(); + cricondenTherm[0] = system.getTemperature(); + for (int ii = 0; ii < nonLinSolver.numberOfComponents; ii++) { + cricondenThermX[ii] = system.getPhase(1).getComponent(ii).getx(); + cricondenThermY[ii] = system.getPhase(0).getComponent(ii).getx(); + } } else { - // dew point side and does not crash - navn[0] = "dew point"; - navn[1] = "bubble point"; - navn[2] = "dew point"; - navn[3] = "bubbl point"; - } - - double TC = system.getTC(); - double PC = system.getPC(); - - String title = "PT-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - - graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); - return graph2.getChart(); - } - - /** {@inheritDoc} */ - @Override - public double[][] getPoints(int i) { - return points2; - } - - /** {@inheritDoc} */ - @Override - public void addData(String name, double[][] data) { - double[][] localPoints = new double[points2.length + data.length][]; - navn[localPoints.length / 2 - 1] = name; - System.arraycopy(points2, 0, localPoints, 0, points2.length); - System.arraycopy(data, 0, localPoints, points2.length, data.length); - points2 = localPoints; - } - - /** {@inheritDoc} */ - @Override - public double[] get(String name) { - if (name.equals("dewT")) { - return points2[0]; - } - if (name.equals("dewP")) { - return points2[1]; - } - if (name.equals("bubT")) { - return points2[2]; - } - if (name.equals("bubP")) { - return points2[3]; - } - // return points2[3]; - if (name.equals("dewT2")) { - return points2[4]; - } - if (name.equals("dewP2")) { - return points2[5]; - } - if (name.equals("bubT2")) { - return points2[6]; - } - if (name.equals("bubP2")) { - return points2[7]; - } - if (name.equals("dewH")) { - return pointsH2[2]; + nonLinSolver.ettercricoT = true; } - if (name.equals("dewDens")) { - return pointsV2[2]; + if (system.getPressure() > cricondenBar[1]) { + cricondenBar[0] = system.getTemperature(); + cricondenBar[1] = system.getPressure(); + for (int ii = 0; ii < nonLinSolver.numberOfComponents; ii++) { + cricondenBarX[ii] = system.getPhase(1).getComponent(ii).getx(); + cricondenBarY[ii] = system.getPhase(0).getComponent(ii).getx(); + } } - if (name.equals("dewS")) { - return pointsS2[2]; - } - if (name.equals("bubH")) { - return pointsH2[0]; - } - if (name.equals("bubDens")) { - return pointsV2[0]; + + // Exit criteria + if ((system.getPressure() < minPressure && nonLinSolver.ettercricoT)) { + break; } - if (name.equals("bubS")) { - return pointsS2[0]; + if (system.getPressure() > maxPressure) { + break; } - if (name.equals("cricondentherm")) { - return cricondenTherm; + if (system.getTemperature() > Tmin && !restart) { + break; } - if (name.equals("cricondenthermX")) { - return cricondenThermX; + + // Keeps the calculated points + points[0][np - 1] = system.getTemperature(); + points[1][np - 1] = system.getPressure(); + pointsH[np - 1] = + system.getPhase(1).getEnthalpy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3; + pointsV[np - 1] = system.getPhase(1).getDensity(); + pointsS[np - 1] = + system.getPhase(1).getEntropy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3; + } + + try { + int ncr = nonLinSolver.getNpCrit(); + if (ncr == 0) { + ncr = np; } - if (name.equals("cricondenthermY")) { - return cricondenThermY; + int ncr2 = np - ncr; + if (hascopiedPoints) { + // if it enters here the envelope crashed and restarted + // reallocate to have all values + points2 = new double[8][]; + pointsH2 = new double[8][]; + pointsS2 = new double[8][]; + pointsV2 = new double[8][]; } - if (name.equals("cricondenbar")) { - return cricondenBar; + + // points2 are plotted + points2[0] = new double[ncr + 1]; + points2[1] = new double[ncr + 1]; + pointsH2[0] = new double[ncr + 1]; + pointsH2[1] = new double[ncr + 1]; + pointsS2[0] = new double[ncr + 1]; + pointsS2[1] = new double[ncr + 1]; + pointsV2[0] = new double[ncr + 1]; + pointsV2[1] = new double[ncr + 1]; + + if (ncr2 > 2) { + points2[2] = new double[ncr2 - 2]; + points2[3] = new double[ncr2 - 2]; + pointsH2[2] = new double[ncr2 - 2]; + pointsH2[3] = new double[ncr2 - 2]; + pointsS2[2] = new double[ncr2 - 2]; + pointsS2[3] = new double[ncr2 - 2]; + pointsV2[2] = new double[ncr2 - 2]; + pointsV2[3] = new double[ncr2 - 2]; + } else { + points2[2] = new double[0]; + points2[3] = new double[0]; + pointsH2[2] = new double[0]; + pointsH2[3] = new double[0]; + pointsS2[2] = new double[0]; + pointsS2[3] = new double[0]; + pointsV2[2] = new double[0]; + pointsV2[3] = new double[0]; } - if (name.equals("cricondenbarX")) { - return cricondenBarX; + + for (int i = 0; i < ncr; i++) { + // second branch up to critical point + points2[0][i] = points[0][i]; + points2[1][i] = points[1][i]; + pointsH2[1][i] = points[1][i]; + pointsH2[0][i] = pointsH[i]; + pointsS2[1][i] = points[1][i]; + pointsS2[0][i] = pointsS[i]; + pointsV2[1][i] = points[1][i]; + pointsV2[0][i] = pointsV[i]; } - if (name.equals("cricondenbarY")) { - return cricondenBarY; + if (ncr2 > 2) { + for (int i = 1; i < (ncr2 - 2); i++) { + // second branch after the critical point + points2[2][i] = points[0][i + ncr - 1]; + points2[3][i] = points[1][i + ncr - 1]; + pointsH2[3][i] = points[1][i + ncr - 1]; + pointsH2[2][i] = pointsH[i + ncr - 1]; + pointsS2[3][i] = points[1][i + ncr - 1]; + pointsS2[2][i] = pointsS[i + ncr - 1]; + pointsV2[3][i] = points[1][i + ncr - 1]; + pointsV2[2][i] = pointsV[i + ncr - 1]; + } } - if (name.equals("criticalPoint1")) { - return new double[] {system.getTC(), system.getPC()}; + + if (hascopiedPoints) { + if (ncrfirst > npfirst) { + ncr = copiedPoints[0].length - 1; + ncr2 = npfirst - ncr; + npfirst = npfirst - 1; + } else { + ncr = ncrfirst; + ncr2 = npfirst - ncr; + } + + points2[4] = new double[ncr + 1]; + points2[5] = new double[ncr + 1]; + pointsH2[4] = new double[ncr + 1]; + pointsH2[5] = new double[ncr + 1]; + pointsS2[4] = new double[ncr + 1]; + pointsS2[5] = new double[ncr + 1]; + pointsV2[4] = new double[ncr + 1]; + pointsV2[5] = new double[ncr + 1]; + + if (ncr2 > 2) { + points2[6] = new double[ncr2 - 2]; + points2[7] = new double[ncr2 - 2]; + pointsH2[6] = new double[ncr2 - 2]; + pointsH2[7] = new double[ncr2 - 2]; + pointsS2[6] = new double[ncr2 - 2]; + pointsS2[7] = new double[ncr2 - 2]; + pointsV2[6] = new double[ncr2 - 2]; + pointsV2[7] = new double[ncr2 - 2]; + } else { + points2[6] = new double[0]; + points2[7] = new double[0]; + pointsH2[6] = new double[0]; + pointsH2[7] = new double[0]; + pointsS2[6] = new double[0]; + pointsS2[7] = new double[0]; + pointsV2[6] = new double[0]; + pointsV2[7] = new double[0]; + } + + for (int i = 0; i < ncr; i++) { + // first branch up to the critical point + points2[4][i] = copiedPoints[0][i]; + points2[5][i] = copiedPoints[1][i]; + pointsH2[5][i] = copiedPoints[1][i]; + pointsH2[4][i] = copiedPoints[2][i]; + pointsS2[5][i] = copiedPoints[1][i]; + pointsS2[4][i] = copiedPoints[3][i]; + pointsV2[5][i] = copiedPoints[1][i]; + pointsV2[4][i] = copiedPoints[4][i]; + } + if (ncr2 > 2) { + for (int i = 1; i < (ncr2 - 2); i++) { + // first branch after the critical point + points2[6][i] = copiedPoints[0][i + ncr - 1]; + points2[7][i] = copiedPoints[1][i + ncr - 1]; + pointsH2[7][i] = copiedPoints[1][i + ncr - 1]; + pointsH2[6][i] = copiedPoints[2][i + ncr - 1]; + pointsS2[7][i] = copiedPoints[1][i + ncr - 1]; + pointsS2[6][i] = copiedPoints[3][i + ncr - 1]; + pointsV2[7][i] = copiedPoints[1][i + ncr - 1]; + pointsV2[6][i] = copiedPoints[4][i + ncr - 1]; + } + } } - if (name.equals("criticalPoint2")) { - return new double[] {0, 0}; - } else { - return null; + + // critical point + system.setTemperature(system.getTC()); + system.setPressure(system.getPC()); + + points2[0][ncr] = system.getTC(); + points2[1][ncr] = system.getPC(); + if (ncr2 > 2) { + points2[2][0] = system.getTC(); + points2[3][0] = system.getPC(); } + } catch (Exception e2) { + } + /* + * try { if (outputToFile) { // update this String name1 = new String(); name1 = fileName + + * "Dew.nc"; file1 = new + * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); + * file1.setOutputFileName(name1); file1.setXvalues(points2[2], "temp", "sec"); + * file1.setYvalues(points2[3], "pres", "meter"); file1.createFile(); + * + * String name2 = new String(); name2 = fileName + "Bub.nc"; file2 = new + * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); + * file2.setOutputFileName(name2); file2.setXvalues(points2[0], "temp", "sec"); + * file2.setYvalues(points2[1], "pres", "meter"); file2.createFile(); } } catch (Exception e3) + * { logger.error("error", e3); } + */ + } catch (Exception e4) { + logger.error("error", e4); + } + } + + /** + *

+ * calcHydrateLine. + *

+ */ + public void calcHydrateLine() { + ThermodynamicOperations opsHyd = new ThermodynamicOperations(system); + try { + opsHyd.hydrateEquilibriumLine(10.0, 300.0); + } catch (Exception e) { + logger.error("error", e); } - /** - * Getter for property bubblePointFirst. - * - * @return Value of property bubblePointFirst. - */ - public boolean isBubblePointFirst() { - return bubblePointFirst; + // double[][] hydData = opsHyd.getData(); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + DecimalFormat nf = new DecimalFormat(); + nf.setMaximumFractionDigits(1); + nf.applyPattern("####.#"); + if (bubblePointFirst) { + // bubble point side + navn[0] = "bubble point 2"; + navn[1] = "dew point 2"; + navn[2] = "dew point 1"; + navn[3] = "bubble point 1"; + } else { + // dew point side and does not crash + navn[0] = "dew point 2"; + navn[1] = "bubble point 2"; + navn[2] = "dew point 1"; + navn[3] = "bubbl point 1"; } - /** - * Setter for property bubblePointFirst. - * - * @param bubblePointFirst New value of property bubblePointFirst. + double TC = system.getTC(); + double PC = system.getPC(); + + String title = + "PT-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + String.valueOf(nf.format(PC)); + String title3 = + "PH-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + String.valueOf(nf.format(PC)); + String title4 = "Density-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + + String.valueOf(nf.format(PC)); + String title5 = + "PS-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + String.valueOf(nf.format(PC)); + + graph2b graph3 = new graph2b(pointsH2, navn, title3, "Enthalpy [kJ/kg]", "Pressure [bara]"); + graph3.setVisible(true); + // graph3.saveFigure(new String(util.util.FileSystemSettings.tempDir + + // "NeqSimTempFig4.png")); + + graph2b graph4 = new graph2b(pointsV2, navn, title4, "Density [kg/m^3]", "Pressure [bara]"); + graph4.setVisible(true); + // graph4.saveFigure(util.util.FileSystemSettings.tempDir + + // "NeqSimTempFig2.png"); + + graph2b graph5 = new graph2b(pointsS2, navn, title5, "Entropy [kJ/kg*K]", "Pressure [bara]"); + graph5.setVisible(true); + // graph5.saveFigure(util.util.FileSystemSettings.tempDir + + // "NeqSimTempFig3.png"); + + graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); + graph2.setVisible(true); + // graph2.saveFigure(util.util.FileSystemSettings.tempDir + + // "NeqSimTempFig1.png"); + + /* + * JDialog dialog = new JDialog(); Container dialogContentPane = dialog.getContentPane(); + * dialogContentPane.setLayout(new FlowLayout()); JFreeChartPanel chartPanel = + * graph4.getChartPanel(); dialogContentPane.add(chartPanel); dialog.show(); */ - public void setBubblePointFirst(boolean bubblePointFirst) { - this.bubblePointFirst = bubblePointFirst; + } + + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} + + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + DecimalFormat nf = new DecimalFormat(); + nf.setMaximumFractionDigits(1); + nf.applyPattern("####.#"); + if (bubblePointFirst) { + // bubble point side + navn[0] = "bubble point 2"; + navn[1] = "dew point 2"; + navn[2] = "dew point 1"; + navn[3] = "bubble point 1"; + } else { + // dew point side and does not crash + navn[0] = "dew point"; + navn[1] = "bubble point"; + navn[2] = "dew point"; + navn[3] = "bubbl point"; } - /** {@inheritDoc} */ - @Override - public String[][] getResultTable() { - return null; + double TC = system.getTC(); + double PC = system.getPC(); + + String title = + "PT-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + String.valueOf(nf.format(PC)); + + graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); + return graph2.getChart(); + } + + /** {@inheritDoc} */ + @Override + public double[][] getPoints(int i) { + return points2; + } + + /** {@inheritDoc} */ + @Override + public void addData(String name, double[][] data) { + double[][] localPoints = new double[points2.length + data.length][]; + navn[localPoints.length / 2 - 1] = name; + System.arraycopy(points2, 0, localPoints, 0, points2.length); + System.arraycopy(data, 0, localPoints, points2.length, data.length); + points2 = localPoints; + } + + /** {@inheritDoc} */ + @Override + public double[] get(String name) { + if (name.equals("dewT")) { + return points2[0]; + } + if (name.equals("dewP")) { + return points2[1]; + } + if (name.equals("bubT")) { + return points2[2]; + } + if (name.equals("bubP")) { + return points2[3]; + } + // return points2[3]; + if (name.equals("dewT2")) { + return points2[4]; + } + if (name.equals("dewP2")) { + return points2[5]; + } + if (name.equals("bubT2")) { + return points2[6]; + } + if (name.equals("bubP2")) { + return points2[7]; + } + if (name.equals("dewH")) { + return pointsH2[2]; + } + if (name.equals("dewDens")) { + return pointsV2[2]; + } + if (name.equals("dewS")) { + return pointsS2[2]; + } + if (name.equals("bubH")) { + return pointsH2[0]; + } + if (name.equals("bubDens")) { + return pointsV2[0]; + } + if (name.equals("bubS")) { + return pointsS2[0]; + } + if (name.equals("cricondentherm")) { + return cricondenTherm; + } + if (name.equals("cricondenthermX")) { + return cricondenThermX; + } + if (name.equals("cricondenthermY")) { + return cricondenThermY; + } + if (name.equals("cricondenbar")) { + return cricondenBar; + } + if (name.equals("cricondenbarX")) { + return cricondenBarX; + } + if (name.equals("cricondenbarY")) { + return cricondenBarY; + } + if (name.equals("criticalPoint1")) { + return new double[] {system.getTC(), system.getPC()}; + } + if (name.equals("criticalPoint2")) { + return new double[] {0, 0}; + } else { + return null; + } + } + + /** + * Getter for property bubblePointFirst. + * + * @return Value of property bubblePointFirst. + */ + public boolean isBubblePointFirst() { + return bubblePointFirst; + } + + /** + * Setter for property bubblePointFirst. + * + * @param bubblePointFirst New value of property bubblePointFirst. + */ + public void setBubblePointFirst(boolean bubblePointFirst) { + this.bubblePointFirst = bubblePointFirst; + } + + /** {@inheritDoc} */ + @Override + public String[][] getResultTable() { + return null; + } + + /** + *

+ * tempKWilson. + *

+ * + * @param beta a double + * @param P a double + * @return a double + */ + public double tempKWilson(double beta, double P) { + // Initiallizes the temperature of a saturation point for given pressure + // based on K values of Wilson + // see Michelsen book thermodynamics & computational aspects + + double initTc = 0.; + double initPc = 0.; + double initAc = 0.; + double Tstart = 0.; + double Tstartold = 0.; + double initT = 0; + double dinitT = 0; + int numberOfComponents = system.getPhase(0).getNumberOfComponents(); + int lc = 0; + int hc = 0; + + double[] Kwil = new double[numberOfComponents]; + + double min = 100000.; + double max = 0.; + + for (int i = 0; i < numberOfComponents; i++) { + if (system.getPhase(0).getComponents()[i].getTC() > max) { + max = system.getPhase(0).getComponents()[i].getTC(); + hc = i; + } + if (system.getPhase(0).getComponents()[i].getTC() < min) { + min = system.getPhase(0).getComponents()[i].getTC(); + lc = i; + } } - /** - *

- * tempKWilson. - *

- * - * @param beta a double - * @param P a double - * @return a double - */ - public double tempKWilson(double beta, double P) { - // Initiallizes the temperature of a saturation point for given pressure - // based on K values of Wilson - // see Michelsen book thermodynamics & computational aspects - - double initTc = 0.; - double initPc = 0.; - double initAc = 0.; - double Tstart = 0.; - double Tstartold = 0.; - double initT = 0; - double dinitT = 0; - int numberOfComponents = system.getPhase(0).getNumberOfComponents(); - int lc = 0; - int hc = 0; - - double[] Kwil = new double[numberOfComponents]; - - double min = 100000.; - double max = 0.; - - for (int i = 0; i < numberOfComponents; i++) { - if (system.getPhase(0).getComponents()[i].getTC() > max) { - max = system.getPhase(0).getComponents()[i].getTC(); - hc = i; - } - if (system.getPhase(0).getComponents()[i].getTC() < min) { - min = system.getPhase(0).getComponents()[i].getTC(); - lc = i; - } + try { + if (beta <= 0.5) { + initTc = system.getPhase(0).getComponents()[lc].getTC(); // closer to bubble point + // get the lightest + // component + initPc = system.getPhase(0).getComponents()[lc].getPC(); + initAc = system.getPhase(0).getComponents()[lc].getAcentricFactor(); + } else if (beta > 0.5) { + initTc = system.getPhase(0).getComponents()[hc].getTC(); // closer to dew point get + // the heaviest + // component + initPc = system.getPhase(0).getComponents()[hc].getPC(); + initAc = system.getPhase(0).getComponents()[hc].getAcentricFactor(); + } + + // initial T based on the lightest/heaviest component + Tstart = initTc * 5.373 * (1 + initAc) / (5.373 * (1 + initAc) - Math.log(P / initPc)); + + // solve for Tstart with Newton + for (int i = 0; i < 1000; i++) { + initT = 0.; + dinitT = 0.; + for (int j = 0; j < numberOfComponents; j++) { + Kwil[j] = system.getPhase(0).getComponents()[j].getPC() / P + * Math.exp(5.373 * (1. + system.getPhase(0).getComponents()[j].getAcentricFactor()) + * (1. - system.getPhase(0).getComponents()[j].getTC() / Tstart)); + // system.getPhases()[0].getComponents()[j].setK(Kwil[j]); } - try { - if (beta <= 0.5) { - initTc = system.getPhase(0).getComponents()[lc].getTC(); // closer to bubble point - // get the lightest - // component - initPc = system.getPhase(0).getComponents()[lc].getPC(); - initAc = system.getPhase(0).getComponents()[lc].getAcentricFactor(); - } else if (beta > 0.5) { - initTc = system.getPhase(0).getComponents()[hc].getTC(); // closer to dew point get - // the heaviest - // component - initPc = system.getPhase(0).getComponents()[hc].getPC(); - initAc = system.getPhase(0).getComponents()[hc].getAcentricFactor(); - } + for (int j = 0; j < numberOfComponents; j++) { + if (beta < 0.5) { + initT = initT + system.getPhase(0).getComponents()[j].getz() * Kwil[j]; + dinitT = dinitT + system.getPhase(0).getComponents()[j].getz() * Kwil[j] * 5.373 + * (1 + system.getPhase(0).getComponents()[j].getAcentricFactor()) + * system.getPhase(0).getComponents()[j].getTC() / (Tstart * Tstart); + } else { + initT = initT + system.getPhase(0).getComponents()[j].getz() / Kwil[j]; + dinitT = dinitT - system.getPhase(0).getComponents()[j].getz() / Kwil[j] * 5.373 + * (1 + system.getPhase(0).getComponents()[j].getAcentricFactor()) + * system.getPhase(0).getComponents()[j].getTC() / (Tstart * Tstart); + } + } - // initial T based on the lightest/heaviest component - Tstart = initTc * 5.373 * (1 + initAc) / (5.373 * (1 + initAc) - Math.log(P / initPc)); - - // solve for Tstart with Newton - for (int i = 0; i < 1000; i++) { - initT = 0.; - dinitT = 0.; - for (int j = 0; j < numberOfComponents; j++) { - Kwil[j] = system.getPhase(0).getComponents()[j].getPC() / P * Math.exp(5.373 - * (1. + system.getPhase(0).getComponents()[j].getAcentricFactor()) - * (1. - system.getPhase(0).getComponents()[j].getTC() / Tstart)); - // system.getPhases()[0].getComponents()[j].setK(Kwil[j]); - } - - for (int j = 0; j < numberOfComponents; j++) { - if (beta < 0.5) { - initT = initT + system.getPhase(0).getComponents()[j].getz() * Kwil[j]; - dinitT = dinitT + system.getPhase(0).getComponents()[j].getz() * Kwil[j] - * 5.373 - * (1 + system.getPhase(0).getComponents()[j].getAcentricFactor()) - * system.getPhase(0).getComponents()[j].getTC() / (Tstart * Tstart); - } else { - initT = initT + system.getPhase(0).getComponents()[j].getz() / Kwil[j]; - dinitT = dinitT - system.getPhase(0).getComponents()[j].getz() / Kwil[j] - * 5.373 - * (1 + system.getPhase(0).getComponents()[j].getAcentricFactor()) - * system.getPhase(0).getComponents()[j].getTC() / (Tstart * Tstart); - } - } - - initT = initT - 1.; - if (Math.abs(initT / dinitT) > 0.1 * Tstart) { - Tstart = Tstart - 0.001 * initT / dinitT; - } else { - Tstart = Tstart - initT / dinitT; - } - if (Math.abs(Tstart - Tstartold) < 1.e-5) { - return Tstart; - } - Tstartold = Tstart; - } - } catch (Exception e) { - Tstart = initTc * 5.373 * (1 + initAc) / (5.373 * (1 + initAc) - Math.log(P / initPc)); + initT = initT - 1.; + if (Math.abs(initT / dinitT) > 0.1 * Tstart) { + Tstart = Tstart - 0.001 * initT / dinitT; + } else { + Tstart = Tstart - initT / dinitT; } - if (Double.isNaN(Tstart) || Double.isInfinite(Tstart)) { - Tstart = initTc * 5.373 * (1 + initAc) / (5.373 * (1 + initAc) - Math.log(P / initPc)); + if (Math.abs(Tstart - Tstartold) < 1.e-5) { + return Tstart; } - return Tstart; + Tstartold = Tstart; + } + } catch (Exception e) { + Tstart = initTc * 5.373 * (1 + initAc) / (5.373 * (1 + initAc) - Math.log(P / initPc)); + } + if (Double.isNaN(Tstart) || Double.isInfinite(Tstart)) { + Tstart = initTc * 5.373 * (1 + initAc) / (5.373 * (1 + initAc) - Math.log(P / initPc)); } + return Tstart; + } } diff --git a/src/main/java/neqsim/util/database/AspenIP21Database.java b/src/main/java/neqsim/util/database/AspenIP21Database.java index cd0e4755cc..906be04a7d 100644 --- a/src/main/java/neqsim/util/database/AspenIP21Database.java +++ b/src/main/java/neqsim/util/database/AspenIP21Database.java @@ -15,142 +15,138 @@ * @version $Id: $Id */ public class AspenIP21Database - implements neqsim.util.util.FileSystemSettings, java.io.Serializable { - private static final long serialVersionUID = 1000; + implements neqsim.util.util.FileSystemSettings, java.io.Serializable { + private static final long serialVersionUID = 1000; - protected Connection databaseConnection = null; - private static String dataBaseType = "Karsto"; - private Statement statement = null; + protected Connection databaseConnection = null; + private static String dataBaseType = "Karsto"; + private Statement statement = null; - /** - *

- * Constructor for AspenIP21Database. - *

- */ - public AspenIP21Database() { - try { - if (dataBaseType.equals("Karsto")) { - Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").getDeclaredConstructor() - .newInstance(); - } - } catch (Exception ex) { - System.out.println("error in Online Karsto " + ex.toString()); - System.out.println("The database must be registered on the local DBMS to work."); - } - - try { - databaseConnection = this.openConnection("Karsto"); - setStatement(databaseConnection.createStatement()); - } catch (Exception ex) { - System.out.println("SQLException " + ex.getMessage()); - } + /** + *

+ * Constructor for AspenIP21Database. + *

+ */ + public AspenIP21Database() { + try { + if (dataBaseType.equals("Karsto")) { + Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").getDeclaredConstructor().newInstance(); + } + } catch (Exception ex) { + System.out.println("error in Online Karsto " + ex.toString()); + System.out.println("The database must be registered on the local DBMS to work."); } - /** - *

- * openConnection. - *

- * - * @param database a {@link java.lang.String} object - * @return a Connection object - * @throws java.sql.SQLException if any. - * @throws java.lang.ClassNotFoundException if any. - */ - public Connection openConnection(String database) throws SQLException, ClassNotFoundException { - javax.naming.InitialContext ctx = null; - // javax.sql.DataSource ds = null; + try { + databaseConnection = this.openConnection("Karsto"); + setStatement(databaseConnection.createStatement()); + } catch (Exception ex) { + System.out.println("SQLException " + ex.getMessage()); + } + } - try { - return DriverManager.getConnection("....."); - } catch (Exception ex) { - System.out.println("SQLException " + ex.getMessage()); - System.out.println("error in Kaarsto DB " + ex.toString()); - System.out - .println("The Kaarsto database must be registered on the local DBMS to work."); - } finally { - try { - if (ctx != null) { - ctx.close(); - } - } catch (Exception e) { - e.printStackTrace(); - } + /** + *

+ * openConnection. + *

+ * + * @param database a {@link java.lang.String} object + * @return a Connection object + * @throws java.sql.SQLException if any. + * @throws java.lang.ClassNotFoundException if any. + */ + public Connection openConnection(String database) throws SQLException, ClassNotFoundException { + javax.naming.InitialContext ctx = null; + try { + return DriverManager.getConnection("....."); + } catch (Exception ex) { + System.out.println("SQLException " + ex.getMessage()); + System.out.println("error in Kaarsto DB " + ex.toString()); + System.out.println("The Kaarsto database must be registered on the local DBMS to work."); + } finally { + try { + if (ctx != null) { + ctx.close(); } - return null; + } catch (Exception e) { + e.printStackTrace(); + } } + return null; + } - /** - *

- * Setter for the field statement. - *

- * - * @param statement a Statement object - */ - public void setStatement(Statement statement) { - this.statement = statement; - } + /** + *

+ * Setter for the field statement. + *

+ * + * @param statement a Statement object + */ + public void setStatement(Statement statement) { + this.statement = statement; + } - /** - *

- * getResultSet. - *

- * - * @param sqlString a {@link java.lang.String} object - * @return a ResultSet object - */ - public ResultSet getResultSet(String sqlString) { - return this.getResultSet("Karsto", sqlString); - } + /** + *

+ * getResultSet. + *

+ * + * @param sqlString a {@link java.lang.String} object + * @return a ResultSet object + */ + public ResultSet getResultSet(String sqlString) { + return this.getResultSet("Karsto", sqlString); + } - /** - *

- * getResultSet. - *

- * - * @param database a {@link java.lang.String} object - * @param sqlString a {@link java.lang.String} object - * @return a ResultSet object - */ - public ResultSet getResultSet(String database, String sqlString) { - try { - ResultSet result = getStatement().executeQuery(sqlString); - return result; - } catch (Exception e) { - System.out.println("error in DB " + e.toString()); - System.out.println("The database must be rgistered on the local DBMS to work."); - } - return null; + /** + *

+ * getResultSet. + *

+ * + * @param database a {@link java.lang.String} object + * @param sqlString a {@link java.lang.String} object + * @return a ResultSet object + */ + public ResultSet getResultSet(String database, String sqlString) { + try { + ResultSet result = getStatement().executeQuery(sqlString); + return result; + } catch (Exception e) { + System.out.println("error in DB " + e.toString()); + System.out.println("The database must be rgistered on the local DBMS to work."); } + return null; + } - /** - *

- * Getter for the field statement. - *

- * - * @return a Statement object - */ - public Statement getStatement() { - return statement; - } + /** + *

+ * Getter for the field statement. + *

+ * + * @return a Statement object + */ + public Statement getStatement() { + return statement; + } - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - AspenIP21Database database = new AspenIP21Database(); - ResultSet dataSet = database.getResultSet("Karsto", "....'"); - try { - while (dataSet.next()) { - System.out.println("dataset " + dataSet.getString(4)); - System.out.println("dataset value " + dataSet.getDouble("...")); - } - } catch (Exception e) { - System.out.println("failed " + e.toString()); - } - System.out.println("ok"); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + AspenIP21Database database = new AspenIP21Database(); + try (ResultSet dataSet = database.getResultSet("Karsto", "....'")) { + while (dataSet.next()) { + System.out.println("dataset " + dataSet.getString(4)); + System.out.println("dataset value " + dataSet.getDouble("...")); + } + } catch (Exception e) { + System.out.println("failed " + e.toString()); } + + System.out.println("ok"); + } } From b7d9b70ea3b059c9f384ab966deab35eae391e0d Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Fri, 22 Jul 2022 15:07:34 +0200 Subject: [PATCH 6/9] NeqSimMSAccessDatabase The NeqSim parameter database in MS Access format. --- docs/wiki/NeqSimDatabase.mdb | Bin 0 -> 4055040 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 docs/wiki/NeqSimDatabase.mdb diff --git a/docs/wiki/NeqSimDatabase.mdb b/docs/wiki/NeqSimDatabase.mdb new file mode 100644 index 0000000000000000000000000000000000000000..f28e10020efbd8af607df2066665600a7599951c GIT binary patch literal 4055040 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

bT)<{d` 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 z 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

J7*dof1F%4XccQW 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 literal 0 HcmV?d00001 From a64c287ad46baff0c86ea8dfc9a7010cf55b45b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?= <34712686+asmfstatoil@users.noreply.github.com> Date: Fri, 22 Jul 2022 17:39:55 +0200 Subject: [PATCH 7/9] format (#491) * format --- .../neqsim/MathLib/generalMath/TDMAsolve.java | 55 +- .../nonLinearSolver/NumericalDerivative.java | 1 + .../nonLinearSolver/NumericalIntegration.java | 1 + .../nonLinearSolver/newtonRhapson.java | 382 +- .../ChemicalReactionOperations.java | 964 +++-- .../LinearProgrammingChemicalEquilibrium.java | 675 ++-- .../ReferencePotComparator.java | 21 +- .../chemicalReaction/ChemicalReaction.java | 888 ++--- .../ChemicalReactionFactory.java | 117 +- .../ChemicalReactionList.java | 941 +++-- .../chemicalReactions/kinetics/Kinetics.java | 245 +- .../dataPresentation/JFreeChart/graph2b.java | 594 +-- .../dataPresentation/SampleXYDataSource.java | 159 +- .../dataPresentation/userInterface.java | 15 +- .../fluidMechanics/flowLeg/FlowLeg.java | 353 +- .../flowLeg/FlowLegInterface.java | 267 +- .../flowLeg/pipeLeg/PipeLeg.java | 65 +- .../FluidBoundaryInterface.java | 455 +-- .../fluidBoundaryNode/FluidBoundaryNode.java | 45 +- .../FluidBoundaryNodeInterface.java | 17 +- .../FluidBoundaryNodeReactive.java | 33 +- .../FluidBoundarySolver.java | 471 ++- .../FluidBoundarySolverInterface.java | 31 +- .../FluidBoundaryReactiveSolver.java | 13 +- .../FluidBoundarySystemReactive.java | 115 +- .../ReactiveKrishnaStandartFilmModel.java | 125 +- .../enhancementFactor/EnhancementFactor.java | 226 +- .../EnhancementFactorInterface.java | 53 +- .../fluidMechanics/flowSolver/FlowSolver.java | 79 +- .../flowSolver/FlowSolverInterface.java | 89 +- .../OnePhaseFlowSolver.java | 15 +- .../OnePhaseFixedStaggeredGrid.java | 1505 ++++---- .../OnePhasePipeFlowSolver.java | 118 +- .../GeometryDefinition.java | 437 +-- .../GeometryDefinitionInterface.java | 428 +-- .../internalGeometry/packings/Packing.java | 1 + .../packings/PackingInterface.java | 65 +- .../packings/PallRingPacking.java | 1 + .../OnePhaseFileWriter.java | 15 +- .../PipeFlowFileWriter.java | 15 +- .../FlowNodeVisualization.java | 255 +- .../FlowNodeVisualizationInterface.java | 321 +- .../OnePhaseFlowNodeVisualization.java | 13 +- .../OnePhasePipeFlowNodeVisualization.java | 30 +- .../OnePhaseFlowVisualization.java | 37 +- .../PipeFlowVisualization.java | 1 + .../util/timeSeries/TimeSeries.java | 269 +- .../InterfaceProperties.java | 1 + .../InterphasePropertiesInterface.java | 1 + .../surfaceTension/GTSurfaceTension.java | 1 + .../surfaceTension/SurfaceTension.java | 1 + .../SurfaceTensionInterface.java | 1 + .../PhysicalPropertyMixingRule.java | 1 + .../PhysicalPropertyMixingRuleInterface.java | 1 + .../PhysicalPropertyMethod.java | 1 + .../PhysicalPropertyMethodInterface.java | 1 + .../viscosity/PFCTViscosityMethod.java | 1 + .../conductivity/Conductivity.java | 1 + .../density/Density.java | 1 + .../viscosity/ChungViscosityMethod.java | 1 + .../conductivity/Conductivity.java | 1 + .../density/Costald.java | 1 + .../density/Density.java | 1 + .../conductivity/Conductivity.java | 1 + .../density/Density.java | 1 + .../PhysicalProperties.java | 1 + .../PhysicalPropertiesInterface.java | 1 + .../AirPhysicalProperties.java | 1 + .../GasPhysicalProperties.java | 1 + .../NaturalGasPhysicalProperties.java | 1 + .../AminePhysicalProperties.java | 1 + .../GlycolPhysicalProperties.java | 1 + .../LiquidPhysicalProperties.java | 1 + .../WaterPhysicalProperties.java | 1 + .../linearLiquidModel/ViscosityFunction.java | 1 + .../TemperatureTransmitter.java | 1 + .../ProcessEquipmentBaseClass.java | 1 + .../compressor/CompressorInterface.java | 1 + .../heatExchanger/HeatExchanger.java | 1 + .../heatExchanger/Heater.java | 1 + .../mixer/MixerInterface.java | 1 + .../processEquipment/mixer/StaticMixer.java | 1 + .../mixer/StaticNeqMixer.java | 1 + .../pipeline/PipeLineInterface.java | 1 + .../pipeline/TwoPhasePipeLine.java | 1 + .../reservoir/SimpleReservoir.java | 1 + .../separator/GasScrubber.java | 1 + .../separator/GasScrubberSimple.java | 1 + .../processEquipment/separator/Separator.java | 1 + .../separator/SeparatorInterface.java | 1 + .../processEquipment/stream/Stream.java | 1 + .../stream/StreamInterface.java | 1 + .../valve/ValveInterface.java | 1 + .../processSystem/ModuleInterface.java | 1 + .../processSystem/ProcessModuleBaseClass.java | 1 + src/main/java/neqsim/standards/Standard.java | 1 + .../neqsim/standards/StandardInterface.java | 1 + .../standards/salesContract/BaseContract.java | 1 + .../salesContract/ContractInterface.java | 1 + .../salesContract/ContractSpecification.java | 1 + .../dataSmoothing/DataSmoothor.java | 1 + .../ExperimentalEquipmentData.java | 1 + .../WettedWallColumnData.java | 1 + .../readDataFromFile/DataObjectInterface.java | 1 + .../readDataFromFile/DataReader.java | 1 + .../readDataFromFile/DataReaderInterface.java | 1 + .../WettedWallColumnDataObject.java | 463 +-- .../WettedWallDataReader.java | 1 + .../sampleCreator/SampleCreator.java | 1 + .../WettedWallColumnSampleCreator.java | 1 + .../MonteCarloSimulation.java | 1 + .../parameterFitting/FunctionInterface.java | 1 + .../parameterFitting/NumericalDerivative.java | 1 + .../parameterFitting/SampleSet.java | 1 + .../parameterFitting/SampleValue.java | 1 + .../parameterFitting/StatisticsBaseClass.java | 1 + .../parameterFitting/StatisticsInterface.java | 1 + .../LevenbergMarquardt.java | 1 + .../LevenbergMarquardtAbsDev.java | 1 + .../LevenbergMarquardtBiasDev.java | 1 + src/main/java/neqsim/thermo/Fluid.java | 742 ++-- .../ThermodynamicConstantsInterface.java | 1 + .../neqsim/thermo/ThermodynamicModelTest.java | 1 + .../neqsim/thermo/atomElement/Element.java | 1 + .../characterization/TBPCharacterize.java | 1 + .../neqsim/thermo/component/Component.java | 2 +- .../neqsim/thermo/component/ComponentEos.java | 1 + .../component/ComponentEosInterface.java | 1 + .../neqsim/thermo/component/ComponentGE.java | 1 + .../component/ComponentGEInterface.java | 1 + .../component/ComponentGENRTLmodifiedHV.java | 1 + .../thermo/component/ComponentGEUnifac.java | 1 + .../thermo/component/ComponentGEUniquac.java | 1 + .../ComponentGEUniquacmodifiedHV.java | 1 + .../thermo/component/ComponentInterface.java | 2 +- .../ComponentModifiedFurstElectrolyteEos.java | 1 + ...entModifiedFurstElectrolyteEosMod2004.java | 1 + .../thermo/component/ComponentPRvolcor.java | 1 + .../thermo/component/ComponentSolid.java | 1 + .../neqsim/thermo/component/ComponentWax.java | 1 + .../thermo/component/ComponentWaxWilson.java | 1 + .../AttractiveTermBaseClass.java | 1 + .../AttractiveTermInterface.java | 1 + .../neqsim/thermo/mixingRule/CPAMixing.java | 1 + .../thermo/mixingRule/CPAMixingInterface.java | 1 + .../ElectrolyteMixingRulesInterface.java | 1 + .../thermo/mixingRule/EosMixingRules.java | 1 + .../mixingRule/EosMixingRulesInterface.java | 1 + .../mixingRule/HVmixingRuleInterface.java | 1 + src/main/java/neqsim/thermo/phase/Phase.java | 43 +- .../phase/PhaseElectrolyteCPAstatoil.java | 135 +- .../java/neqsim/thermo/phase/PhaseEos.java | 2486 ++++++------ .../thermo/phase/PhaseEosInterface.java | 289 +- .../java/neqsim/thermo/phase/PhaseGE.java | 584 ++- .../neqsim/thermo/phase/PhaseGEInterface.java | 29 +- .../java/neqsim/thermo/phase/PhaseGENRTL.java | 189 +- .../thermo/phase/PhaseGENRTLmodifiedHV.java | 257 +- .../neqsim/thermo/phase/PhaseGEUniquac.java | 169 +- .../phase/PhaseGEUniquacmodifiedHV.java | 63 +- .../neqsim/thermo/phase/PhaseHydrate.java | 191 +- .../neqsim/thermo/phase/PhaseInterface.java | 1 + .../PhaseModifiedFurstElectrolyteEos.java | 3413 +++++++++-------- ...aseModifiedFurstElectrolyteEosMod2004.java | 63 +- .../thermo/phase/PhasePureComponentSolid.java | 55 +- .../java/neqsim/thermo/phase/PhaseSolid.java | 136 +- .../thermo/phase/PhaseSrkCPAojAlgo.java | 2592 ++++++------- .../java/neqsim/thermo/phase/PhaseSrkEos.java | 70 +- .../neqsim/thermo/util/JNI/GERG2004EOS.java | 988 ++--- .../constants/FurstElectrolyteConstants.java | 167 +- ...ParameterFittingToEquilibriumData_N2O.java | 161 +- ...icInteractionParameterFittingFunction.java | 657 ++-- .../acentricFactorFitting/TestAcentric.java | 119 +- .../BaseOperation.java | 1 + .../OperationInterface.java | 133 +- .../ChemicalEquilibrium.java | 1 + .../flashOps/Flash.java | 36 +- .../flashOps/PHflash.java | 380 +- .../flashOps/PHflashGERG2008.java | 403 +- .../flashOps/PHsolidFlash.java | 133 +- .../flashOps/SolidFlash12.java | 733 ++-- .../flashOps/TPflash.java | 4 +- .../flashOps/TPgradientFlash.java | 290 +- .../flashOps/TPmultiflash.java | 3 +- .../flashOps/TPmultiflash_1.java | 1 + .../flashOps/TSFlash.java | 1 + .../flashOps/TVflash.java | 173 +- .../flashOps/VUflash.java | 151 +- .../flashOps/VUflashQfunc.java | 324 +- .../flashOps/calcIonicComposition.java | 142 +- .../flashOps/dTPflash.java | 135 +- .../HPTphaseEnvelope.java | 1 + .../pTphaseEnvelope.java | 1 + .../util/exception/ThermoException.java | 39 +- .../serialization/SerializationManager.java | 61 +- .../java/neqsim/util/unit/LengthUnit.java | 15 +- src/main/java/neqsim/util/unit/RateUnit.java | 173 +- src/main/java/neqsim/util/unit/TimeUnit.java | 15 +- src/main/java/neqsim/util/unit/Unit.java | 57 +- .../neqsim/util/util/DoubleCloneable.java | 95 +- .../neqsim/util/util/FileSystemSettings.java | 30 +- .../processEquipment/mixer/MixerTest.java | 8 +- .../util/example/LNGfilling.java | 76 +- .../util/example/TestSlugcatcher.java | 97 +- .../util/example/TestTransientFlow.java | 214 +- .../gasQuality/Standard_ISO6976Test.java | 3 - .../component/ComponentHydrateGFTest.java | 63 +- .../thermo/util/example/ActivityCalc.java | 59 +- .../util/example/ScalePotentialCheck.java | 121 +- .../neqsim/thermo/util/example/TPflash.java | 100 +- .../thermo/util/example/TestISO1982.java | 39 +- .../readwrite/EclipseFluidReadWriteTest.java | 129 +- .../flashOps/PHFlashGERG2008Test.java | 80 +- .../flashOps/PHFlashTest.java | 75 +- .../flashOps/PSFlashGERG2008Test.java | 69 +- .../flashOps/TPFlashTest.java | 3 - .../flashOps/TPFlashTestWellFluid.java | 3 - .../flashOps/TVFlashTest.java | 22 +- .../flashOps/WaxFlashTest.java | 17 +- 218 files changed, 15046 insertions(+), 14848 deletions(-) diff --git a/src/main/java/neqsim/MathLib/generalMath/TDMAsolve.java b/src/main/java/neqsim/MathLib/generalMath/TDMAsolve.java index 6e31208d68..dcccd42058 100644 --- a/src/main/java/neqsim/MathLib/generalMath/TDMAsolve.java +++ b/src/main/java/neqsim/MathLib/generalMath/TDMAsolve.java @@ -3,6 +3,7 @@ * * Created on 4. desember 2000, 22:34 */ + package neqsim.MathLib.generalMath; /** @@ -14,35 +15,35 @@ * @version $Id: $Id */ public class TDMAsolve { - /** - *

- * solve. - *

- * - * @param a an array of {@link double} objects - * @param b an array of {@link double} objects - * @param c an array of {@link double} objects - * @param r an array of {@link double} objects - * @return an array of {@link double} objects - */ - public static double[] solve(double a[], double b[], double c[], double r[]) { - int length = a.length; - double[] u = new double[length]; - double bet = 0; - double gam[] = new double[length]; + /** + *

+ * solve. + *

+ * + * @param a an array of {@link double} objects + * @param b an array of {@link double} objects + * @param c an array of {@link double} objects + * @param r an array of {@link double} objects + * @return an array of {@link double} objects + */ + public static double[] solve(double a[], double b[], double c[], double r[]) { + int length = a.length; + double[] u = new double[length]; + double bet = 0; + double gam[] = new double[length]; - bet = b[0]; - u[0] = r[0] / bet; + bet = b[0]; + u[0] = r[0] / bet; - for (int j = 1; j < length; j++) { - gam[j] = c[j - 1] / bet; - bet = b[j] - a[j] * gam[j]; - u[j] = (r[j] - a[j] * u[j - 1]) / bet; - } + for (int j = 1; j < length; j++) { + gam[j] = c[j - 1] / bet; + bet = b[j] - a[j] * gam[j]; + u[j] = (r[j] - a[j] * u[j - 1]) / bet; + } - for (int j = (length - 2); j >= 0; j--) { - u[j] -= gam[j + 1] * u[j + 1]; - } - return u; + for (int j = (length - 2); j >= 0; j--) { + u[j] -= gam[j + 1] * u[j + 1]; } + return u; + } } diff --git a/src/main/java/neqsim/MathLib/nonLinearSolver/NumericalDerivative.java b/src/main/java/neqsim/MathLib/nonLinearSolver/NumericalDerivative.java index 03858b98fc..045935f77b 100644 --- a/src/main/java/neqsim/MathLib/nonLinearSolver/NumericalDerivative.java +++ b/src/main/java/neqsim/MathLib/nonLinearSolver/NumericalDerivative.java @@ -3,6 +3,7 @@ * * Created on 28. juli 2000, 15:39 */ + package neqsim.MathLib.nonLinearSolver; import neqsim.thermo.component.ComponentInterface; diff --git a/src/main/java/neqsim/MathLib/nonLinearSolver/NumericalIntegration.java b/src/main/java/neqsim/MathLib/nonLinearSolver/NumericalIntegration.java index 6e212ea121..5b9e8167af 100644 --- a/src/main/java/neqsim/MathLib/nonLinearSolver/NumericalIntegration.java +++ b/src/main/java/neqsim/MathLib/nonLinearSolver/NumericalIntegration.java @@ -3,6 +3,7 @@ * * Created on 6. september 2002, 21:49 */ + package neqsim.MathLib.nonLinearSolver; /** diff --git a/src/main/java/neqsim/MathLib/nonLinearSolver/newtonRhapson.java b/src/main/java/neqsim/MathLib/nonLinearSolver/newtonRhapson.java index 0293499229..e2dfecfc62 100644 --- a/src/main/java/neqsim/MathLib/nonLinearSolver/newtonRhapson.java +++ b/src/main/java/neqsim/MathLib/nonLinearSolver/newtonRhapson.java @@ -3,6 +3,7 @@ * * Created on 15. juli 2000, 17:43 */ + package neqsim.MathLib.nonLinearSolver; /** @@ -14,203 +15,200 @@ * @version $Id: $Id */ public class newtonRhapson implements java.io.Serializable { - private static final long serialVersionUID = 1000; - - int order; - double[] polyConstants; - double funkVal = 0, derivVal = 0, dubDerivVal = 0; - private int maxIterations = 500; - double xNew = 0, xNew2, x = 0; - - /** - *

- * Constructor for newtonRhapson. - *

- */ - public newtonRhapson() {} - - /** - *

- * Setter for the field order. - *

- * - * @param o a int - */ - public void setOrder(int o) { - order = o; - polyConstants = new double[order + 1]; + private static final long serialVersionUID = 1000; + + int order; + double[] polyConstants; + double funkVal = 0, derivVal = 0, dubDerivVal = 0; + private int maxIterations = 500; + double xNew = 0, xNew2, x = 0; + + /** + *

+ * Constructor for newtonRhapson. + *

+ */ + public newtonRhapson() {} + + /** + *

+ * Setter for the field order. + *

+ * + * @param o a int + */ + public void setOrder(int o) { + order = o; + polyConstants = new double[order + 1]; + } + + /** + *

+ * setConstants. + *

+ * + * @param constants an array of {@link double} objects + */ + public void setConstants(double[] constants) { + System.arraycopy(constants, 0, polyConstants, 0, constants.length); + } + + /** + *

+ * funkValue. + *

+ * + * @param x a double + * @return a double + */ + public double funkValue(double x) { + funkVal = 0; + + for (int i = 0; i < polyConstants.length; i++) { + funkVal += polyConstants[i] * Math.pow(x, order - i); } - - /** - *

- * setConstants. - *

- * - * @param constants an array of {@link double} objects - */ - public void setConstants(double[] constants) { - System.arraycopy(constants, 0, polyConstants, 0, constants.length); + return funkVal; + } + + /** + *

+ * derivValue. + *

+ * + * @param x a double + * @return a double + */ + public double derivValue(double x) { + derivVal = 0; + + for (int i = 0; i < polyConstants.length - 1; i++) { + derivVal += (order - i) * polyConstants[i] * Math.pow(x, order - 1 - i); } - /** - *

- * funkValue. - *

- * - * @param x a double - * @return a double - */ - public double funkValue(double x) { - funkVal = 0; - - for (int i = 0; i < polyConstants.length; i++) { - funkVal += polyConstants[i] * Math.pow(x, order - i); - } - return funkVal; + return derivVal; + } + + /** + *

+ * dubDerivValue. + *

+ * + * @param x a double + * @return a double + */ + public double dubDerivValue(double x) { + dubDerivVal = 0; + + for (int i = 0; i < polyConstants.length - 2; i++) { + dubDerivVal += (order - 1 - i) * (order - i) * polyConstants[i] * Math.pow(x, order - 2 - i); } - /** - *

- * derivValue. - *

- * - * @param x a double - * @return a double - */ - public double derivValue(double x) { - derivVal = 0; - - for (int i = 0; i < polyConstants.length - 1; i++) { - derivVal += (order - i) * polyConstants[i] * Math.pow(x, order - 1 - i); - } - - return derivVal; + return dubDerivVal; + } + + /** + *

+ * solve. + *

+ * + * @param xin a double + * @return a double + */ + public double solve(double xin) { + int iterations = 0; + + x = xin; + xNew = x; + xNew2 = x; + + do { + // System.out.println("x " + xNew); + iterations++; + + // System.out.println("Z : " + x); + if (Math.abs(funkValue(xNew)) < Math.abs(funkValue(xNew2))) { + x = xNew; + } else { + x = xNew2; + } + if (derivValue(x) * derivValue(x) - 2.0 * funkValue(x) * dubDerivValue(x) > 0) { + xNew = x - derivValue(x) / dubDerivValue(x) + + Math.sqrt(derivValue(x) * derivValue(x) - 2 * funkValue(x) * dubDerivValue(x)) + / dubDerivValue(x); + xNew2 = x - derivValue(x) / dubDerivValue(x) + - Math.sqrt(derivValue(x) * derivValue(x) - 2 * funkValue(x) * dubDerivValue(x)) + / dubDerivValue(x); + } else { + // System.out.println("using first order newton-rhapson..........."); + xNew = x - funkValue(x) / derivValue(x); + xNew2 = xNew; + } + + if (xNew < 0) { + xNew = 0; + // System.out.println("x++..........."); + } + if (xNew > 1.5) { + xNew = 1; + // System.out.println("x--..........."); + } + } while (Math.abs(funkValue(x)) > 1e-10 && iterations <= maxIterations); + + if (iterations == maxIterations) { + System.out.println("Too many iterations..."); } - - /** - *

- * dubDerivValue. - *

- * - * @param x a double - * @return a double - */ - public double dubDerivValue(double x) { - dubDerivVal = 0; - - for (int i = 0; i < polyConstants.length - 2; i++) { - dubDerivVal += - (order - 1 - i) * (order - i) * polyConstants[i] * Math.pow(x, order - 2 - i); - } - - return dubDerivVal; - } - - /** - *

- * solve. - *

- * - * @param xin a double - * @return a double - */ - public double solve(double xin) { - int iterations = 0; - - x = xin; - xNew = x; - xNew2 = x; - - do { - // System.out.println("x " + xNew); - iterations++; - - // System.out.println("Z : " + x); - if (Math.abs(funkValue(xNew)) < Math.abs(funkValue(xNew2))) { - x = xNew; - } else { - x = xNew2; - } - if (derivValue(x) * derivValue(x) - 2.0 * funkValue(x) * dubDerivValue(x) > 0) { - xNew = x - derivValue(x) / dubDerivValue(x) - + Math.sqrt( - derivValue(x) * derivValue(x) - 2 * funkValue(x) * dubDerivValue(x)) - / dubDerivValue(x); - xNew2 = x - derivValue(x) / dubDerivValue(x) - - Math.sqrt( - derivValue(x) * derivValue(x) - 2 * funkValue(x) * dubDerivValue(x)) - / dubDerivValue(x); - } else { - // System.out.println("using first order newton-rhapson..........."); - xNew = x - funkValue(x) / derivValue(x); - xNew2 = xNew; - } - - if (xNew < 0) { - xNew = 0; - // System.out.println("x++..........."); - } - if (xNew > 1.5) { - xNew = 1; - // System.out.println("x--..........."); - } - } while (Math.abs(funkValue(x)) > 1e-10 && iterations <= maxIterations); - - if (iterations == maxIterations) { - System.out.println("Too many iterations..."); - } - // System.out.println("iterations in newton-rhapson = " + iterations ); - - return xNew; - } - - /** - *

- * solve1order. - *

- * - * @param xin a double - * @return a double - */ - public double solve1order(double xin) { - int iterations = 0; - - x = xin; - xNew = x; - xNew2 = x; - - do { - iterations++; - x = xNew; - xNew = x - funkValue(x) / derivValue(x); - xNew2 = xNew; - } while (Math.abs(funkValue(x)) > 1e-10 && iterations <= maxIterations); - - if (iterations == maxIterations) { - System.out.println("Too many iterations..."); - } - // System.out.println("iterations in newton-rhapson = " + iterations ); - - return xNew; - } - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - newtonRhapson test = new newtonRhapson(); - test.setOrder(3); - - double[] constants = new double[] {-0.003058, -0.01806, -0.266, -0.2999}; - test.setConstants(constants); - - System.out.println("val : " + test.funkValue(-0.0)); - System.out.println("val : " + test.dubDerivValue(-0.3)); - System.out.println("val : " + test.derivValue(-0.3)); - // System.out.println("val : " + test.solve(-0.3)); + // System.out.println("iterations in newton-rhapson = " + iterations ); + + return xNew; + } + + /** + *

+ * solve1order. + *

+ * + * @param xin a double + * @return a double + */ + public double solve1order(double xin) { + int iterations = 0; + + x = xin; + xNew = x; + xNew2 = x; + + do { + iterations++; + x = xNew; + xNew = x - funkValue(x) / derivValue(x); + xNew2 = xNew; + } while (Math.abs(funkValue(x)) > 1e-10 && iterations <= maxIterations); + + if (iterations == maxIterations) { + System.out.println("Too many iterations..."); } + // System.out.println("iterations in newton-rhapson = " + iterations ); + + return xNew; + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + newtonRhapson test = new newtonRhapson(); + test.setOrder(3); + + double[] constants = new double[] {-0.003058, -0.01806, -0.266, -0.2999}; + test.setConstants(constants); + + System.out.println("val : " + test.funkValue(-0.0)); + System.out.println("val : " + test.dubDerivValue(-0.3)); + System.out.println("val : " + test.derivValue(-0.3)); + // System.out.println("val : " + test.solve(-0.3)); + } } diff --git a/src/main/java/neqsim/chemicalReactions/ChemicalReactionOperations.java b/src/main/java/neqsim/chemicalReactions/ChemicalReactionOperations.java index dabcf6c490..ee78177baa 100644 --- a/src/main/java/neqsim/chemicalReactions/ChemicalReactionOperations.java +++ b/src/main/java/neqsim/chemicalReactions/ChemicalReactionOperations.java @@ -3,6 +3,7 @@ * * Created on 4. februar 2001, 20:06 */ + package neqsim.chemicalReactions; import java.util.HashSet; @@ -25,511 +26,508 @@ * @version $Id: $Id */ public class ChemicalReactionOperations - implements neqsim.thermo.ThermodynamicConstantsInterface, Cloneable { - private static final long serialVersionUID = 1000; - - SystemInterface system; - ComponentInterface[] components; - ChemicalReactionList reactionList = new ChemicalReactionList(); - String[] componentNames; - String[] allComponentNames; - String[] elements; - double[][] Amatrix; - double[] nVector; - int iter = 0; - double[] bVector; - int phase = 1; - double[] chemRefPot; - double[] newMoles; - double inertMoles = 0.0; - ChemicalEquilibrium solver; - double deltaReactionHeat = 0.0; - boolean firsttime = false; - Kinetics kineticsSolver; - LinearProgrammingChemicalEquilibrium initCalc; - - /** - *

- * Constructor for ChemicalReactionOperations. - *

- */ - public ChemicalReactionOperations() {} - - /** - *

- * Constructor for ChemicalReactionOperations. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public ChemicalReactionOperations(SystemInterface system) { - initCalc = new LinearProgrammingChemicalEquilibrium(); - boolean newcomps = true; - int old = system.getPhase(0).getNumberOfComponents(); - this.system = system; - - do { - // if statement added by Procede - if (!newcomps) { - break; - } - componentNames = system.getComponentNames(); - reactionList.readReactions(system); - reactionList.removeJunkReactions(componentNames); - allComponentNames = reactionList.getAllComponents(); - this.addNewComponents(); - if (system.getPhase(0).getNumberOfComponents() == old) { - newcomps = false; - } - old = system.getPhase(0).getNumberOfComponents(); - } while (newcomps); - - components = new ComponentInterface[allComponentNames.length]; - if (components.length > 0) { - setReactiveComponents(); - reactionList.checkReactions(system.getPhase(1)); - chemRefPot = calcChemRefPot(1); - elements = getAllElements(); - - try { - initCalc = new LinearProgrammingChemicalEquilibrium(chemRefPot, components, - elements, this, 1); - } catch (Exception e) { - e.printStackTrace(); - } - setComponents(); - Amatrix = initCalc.getA(); - nVector = calcNVector(); - bVector = calcBVector(); - } else { - system.isChemicalSystem(false); - } - kineticsSolver = new Kinetics(this); + implements neqsim.thermo.ThermodynamicConstantsInterface, Cloneable { + private static final long serialVersionUID = 1000; + + SystemInterface system; + ComponentInterface[] components; + ChemicalReactionList reactionList = new ChemicalReactionList(); + String[] componentNames; + String[] allComponentNames; + String[] elements; + double[][] Amatrix; + double[] nVector; + int iter = 0; + double[] bVector; + int phase = 1; + double[] chemRefPot; + double[] newMoles; + double inertMoles = 0.0; + ChemicalEquilibrium solver; + double deltaReactionHeat = 0.0; + boolean firsttime = false; + Kinetics kineticsSolver; + LinearProgrammingChemicalEquilibrium initCalc; + + /** + *

+ * Constructor for ChemicalReactionOperations. + *

+ */ + public ChemicalReactionOperations() {} + + /** + *

+ * Constructor for ChemicalReactionOperations. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public ChemicalReactionOperations(SystemInterface system) { + initCalc = new LinearProgrammingChemicalEquilibrium(); + boolean newcomps = true; + int old = system.getPhase(0).getNumberOfComponents(); + this.system = system; + + do { + // if statement added by Procede + if (!newcomps) { + break; + } + componentNames = system.getComponentNames(); + reactionList.readReactions(system); + reactionList.removeJunkReactions(componentNames); + allComponentNames = reactionList.getAllComponents(); + this.addNewComponents(); + if (system.getPhase(0).getNumberOfComponents() == old) { + newcomps = false; + } + old = system.getPhase(0).getNumberOfComponents(); + } while (newcomps); + + components = new ComponentInterface[allComponentNames.length]; + if (components.length > 0) { + setReactiveComponents(); + reactionList.checkReactions(system.getPhase(1)); + chemRefPot = calcChemRefPot(1); + elements = getAllElements(); + + try { + initCalc = + new LinearProgrammingChemicalEquilibrium(chemRefPot, components, elements, this, 1); + } catch (Exception e) { + e.printStackTrace(); + } + setComponents(); + Amatrix = initCalc.getA(); + nVector = calcNVector(); + bVector = calcBVector(); + } else { + system.isChemicalSystem(false); } - - /** - *

- * Setter for the field system. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public void setSystem(SystemInterface system) { - this.system = system; + kineticsSolver = new Kinetics(this); + } + + /** + *

+ * Setter for the field system. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public void setSystem(SystemInterface system) { + this.system = system; + } + + /** {@inheritDoc} */ + @Override + public ChemicalReactionOperations clone() { + ChemicalReactionOperations clonedSystem = null; + try { + clonedSystem = (ChemicalReactionOperations) super.clone(); + } catch (Exception e) { + e.printStackTrace(System.err); } - - /** {@inheritDoc} */ - @Override - public ChemicalReactionOperations clone() { - ChemicalReactionOperations clonedSystem = null; - try { - clonedSystem = (ChemicalReactionOperations) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); - } - return clonedSystem; + return clonedSystem; + } + + /** + *

+ * Setter for the field components. + *

+ */ + public void setComponents() { + for (int j = 0; j < components.length; j++) { + system.getPhase(phase).getComponents()[components[j].getComponentNumber()] = components[j]; } - - /** - *

- * Setter for the field components. - *

- */ - public void setComponents() { - for (int j = 0; j < components.length; j++) { - system.getPhase(phase).getComponents()[components[j].getComponentNumber()] = - components[j]; - } + } + + /** + *

+ * Setter for the field components. + *

+ * + * @param phase a int + */ + public void setComponents(int phase) { + for (int j = 0; j < components.length; j++) { + system.getPhase(phase).getComponents()[components[j].getComponentNumber()] = components[j]; } - - /** - *

- * Setter for the field components. - *

- * - * @param phase a int - */ - public void setComponents(int phase) { - for (int j = 0; j < components.length; j++) { - system.getPhase(phase).getComponents()[components[j].getComponentNumber()] = - components[j]; - } + } + + /** + *

+ * setReactiveComponents. + *

+ * + * @param phase a int + */ + public void setReactiveComponents(int phase) { + for (int j = 0; j < components.length; j++) { + // System.out.println("comp " + components[j].getComponentNumber()); + components[j] = system.getPhase(phase).getComponent(components[j].getComponentNumber()); } - - /** - *

- * setReactiveComponents. - *

- * - * @param phase a int - */ - public void setReactiveComponents(int phase) { - for (int j = 0; j < components.length; j++) { - // System.out.println("comp " + components[j].getComponentNumber()); - components[j] = system.getPhase(phase).getComponent(components[j].getComponentNumber()); + } + + /** + *

+ * setReactiveComponents. + *

+ */ + public void setReactiveComponents() { + int k = 0; + for (int j = 0; j < componentNames.length; j++) { + // System.out.println("component " + componentNames[j]); + String name = componentNames[j]; + for (int i = 0; i < allComponentNames.length; i++) { + if (name.equals(allComponentNames[i])) { + components[k++] = system.getPhase(phase).getComponents()[j]; + // System.out.println("reactive comp " + + // system.getPhases()[1].getComponents()[j].getName()); } + } } - - /** - *

- * setReactiveComponents. - *

- */ - public void setReactiveComponents() { - int k = 0; - for (int j = 0; j < componentNames.length; j++) { - // System.out.println("component " + componentNames[j]); - String name = componentNames[j]; - for (int i = 0; i < allComponentNames.length; i++) { - if (name.equals(allComponentNames[i])) { - components[k++] = system.getPhase(phase).getComponents()[j]; - // System.out.println("reactive comp " + - // system.getPhases()[1].getComponents()[j].getName()); - } - } - } + } + + /** + *

+ * calcInertMoles. + *

+ * + * @param phase a int + * @return a double + */ + public double calcInertMoles(int phase) { + double reactiveMoles = 0; + for (int j = 0; j < components.length; j++) { + reactiveMoles += components[j].getNumberOfMolesInPhase(); } - - /** - *

- * calcInertMoles. - *

- * - * @param phase a int - * @return a double - */ - public double calcInertMoles(int phase) { - double reactiveMoles = 0; - for (int j = 0; j < components.length; j++) { - reactiveMoles += components[j].getNumberOfMolesInPhase(); - } - inertMoles = system.getPhase(phase).getNumberOfMolesInPhase() - reactiveMoles; - // System.out.println("inertmoles = " + inertMoles); - if (inertMoles < 0) { - inertMoles = 1.0e-30; - } - return inertMoles; + inertMoles = system.getPhase(phase).getNumberOfMolesInPhase() - reactiveMoles; + // System.out.println("inertmoles = " + inertMoles); + if (inertMoles < 0) { + inertMoles = 1.0e-30; } - - /** - *

- * sortReactiveComponents. - *

- */ - public void sortReactiveComponents() { - ComponentInterface tempComp; - for (int i = 0; i < components.length; i++) { - for (int j = i + 1; j < components.length; j++) { - if (components[j].getGibbsEnergyOfFormation() < components[i] - .getGibbsEnergyOfFormation()) { - tempComp = components[i]; - components[i] = components[j]; - components[j] = tempComp; - // System.out.println("swich : " + i + " " + j); - } - } + return inertMoles; + } + + /** + *

+ * sortReactiveComponents. + *

+ */ + public void sortReactiveComponents() { + ComponentInterface tempComp; + for (int i = 0; i < components.length; i++) { + for (int j = i + 1; j < components.length; j++) { + if (components[j].getGibbsEnergyOfFormation() < components[i].getGibbsEnergyOfFormation()) { + tempComp = components[i]; + components[i] = components[j]; + components[j] = tempComp; + // System.out.println("swich : " + i + " " + j); } + } } - - /** - *

- * addNewComponents. - *

- */ - public void addNewComponents() { - boolean newComp; - - for (int i = 0; i < allComponentNames.length; i++) { - String name = allComponentNames[i]; - newComp = true; - - for (int j = 0; j < componentNames.length; j++) { - if (name.equals(componentNames[j])) { - newComp = false; - break; - } - } - if (newComp) { - system.addComponent(name, 1.0e-40); - // System.out.println("new component added: " + name); - } + } + + /** + *

+ * addNewComponents. + *

+ */ + public void addNewComponents() { + boolean newComp; + + for (int i = 0; i < allComponentNames.length; i++) { + String name = allComponentNames[i]; + newComp = true; + + for (int j = 0; j < componentNames.length; j++) { + if (name.equals(componentNames[j])) { + newComp = false; + break; } + } + if (newComp) { + system.addComponent(name, 1.0e-40); + // System.out.println("new component added: " + name); + } } - - /** - *

- * getAllElements. - *

- * - * @return an array of {@link java.lang.String} objects - */ - public String[] getAllElements() { - HashSet elementsLocal = new HashSet(); - for (int j = 0; j < components.length; j++) { - for (int i = 0; i < components[j].getElements().getElementNames().length; i++) { - // System.out.println("elements: " + - // components[j].getElements().getElementNames()[i]); - elementsLocal.add(components[j].getElements().getElementNames()[i]); - } - } - - String[] elementList = new String[elementsLocal.size()]; - int k = 0; - Iterator newe = elementsLocal.iterator(); - while (newe.hasNext()) { - elementList[k++] = newe.next(); - } - /* - * for(int j=0;j + * getAllElements. + *

+ * + * @return an array of {@link java.lang.String} objects + */ + public String[] getAllElements() { + HashSet elementsLocal = new HashSet(); + for (int j = 0; j < components.length; j++) { + for (int i = 0; i < components[j].getElements().getElementNames().length; i++) { + // System.out.println("elements: " + + // components[j].getElements().getElementNames()[i]); + elementsLocal.add(components[j].getElements().getElementNames()[i]); + } } - /** - *

- * hasRections. - *

- * - * @return a boolean - */ - public boolean hasRections() { - return components.length > 0; + String[] elementList = new String[elementsLocal.size()]; + int k = 0; + Iterator newe = elementsLocal.iterator(); + while (newe.hasNext()) { + elementList[k++] = newe.next(); } - - /** - *

- * calcNVector. - *

- * - * @return an array of {@link double} objects + /* + * for(int j=0;j + * hasRections. + *

+ * + * @return a boolean + */ + public boolean hasRections() { + return components.length > 0; + } + + /** + *

+ * calcNVector. + *

+ * + * @return an array of {@link double} objects + */ + public double[] calcNVector() { + double[] nvec = new double[components.length]; + for (int i = 0; i < components.length; i++) { + nvec[i] = components[i].getNumberOfMolesInPhase(); + // System.out.println("nvec: " + nvec[i]); } - - /** - *

- * calcBVector. - *

- * - * @return an array of {@link double} objects - */ - public double[] calcBVector() { - Matrix tempA = new Matrix(Amatrix); - Matrix tempB = new Matrix(nVector, 1); - Matrix tempN = tempA.times(tempB.transpose()).transpose(); - // print added by Neeraj - // System.out.println("b matrix: "); - // tempN.print(10,2); - - return tempN.getArray()[0]; - } - - /** - *

- * calcChemRefPot. - *

- * - * @param phase a int - * @return an array of {@link double} objects - */ - public double[] calcChemRefPot(int phase) { - double[] referencePotentials = new double[components.length]; - reactionList.createReactionMatrix(system.getPhase(phase), components); - double[] newreferencePotentials = - reactionList.updateReferencePotentials(system.getPhase(phase), components); - if (newreferencePotentials != null) { - for (int i = 0; i < newreferencePotentials.length; i++) { - referencePotentials[i] = newreferencePotentials[i]; - components[i].setReferencePotential(referencePotentials[i]); - } - return referencePotentials; - } else { - return null; - } - } - - /** - *

- * updateMoles. - *

- * - * @param phase a int - */ - public void updateMoles(int phase) { - double changeMoles = 0.0; - for (int i = 0; i < components.length; i++) { - if (Math.abs(newMoles[i]) > 1e-45) { - changeMoles += (newMoles[i] - - system.getPhase(phase).getComponents()[components[i].getComponentNumber()] - .getNumberOfMolesInPhase()); - // System.out.println("update moles first " + (components[i].getComponentName() - // + " moles " + components[i].getNumberOfMolesInPhase())); - system.getPhase(phase).addMolesChemReac(components[i].getComponentNumber(), - (newMoles[i] - system.getPhase(phase).getComponents()[components[i] - .getComponentNumber()].getNumberOfMolesInPhase())); - // System.out.println("update moles after " + (components[i].getComponentName() - // + " moles " + components[i].getNumberOfMolesInPhase())); - } - } - // System.out.println("change " + changeMoles); - system.initTotalNumberOfMoles(changeMoles);// x_solve.get(NELE,0)*n_t); - system.initBeta(); // this was added for mass trans calc - system.init_x_y(); - system.init(1); - } - - /** - *

- * solveChemEq. - *

- * - * @param type a int - * @return a boolean - */ - public boolean solveChemEq(int type) { - return solveChemEq(1, type); - } - - /** - *

- * solveChemEq. - *

- * - * @param phase a int - * @param type a int - * @return a boolean - */ - public boolean solveChemEq(int phase, int type) { - if (this.phase != phase) { - setReactiveComponents(phase); - chemRefPot = calcChemRefPot(phase); - } - this.phase = phase; - if (!system.isChemicalSystem()) { - System.out.println("no chemical reactions will occur...continue"); - return false; - } - - // System.out.println("pressure1"); - calcChemRefPot(phase); - // System.out.println("pressure2"); - if (firsttime == true || type == 0) { - try { - // System.out.println("Calculating initial estimates"); - nVector = calcNVector(); - bVector = calcBVector(); - calcInertMoles(phase); - newMoles = initCalc.generateInitialEstimates(system, bVector, inertMoles, phase); - // Print statement added by Neeraj - // for (i=0;i<5;i++) - // System.out.println("new moles "+newMoles[i]); - updateMoles(phase); - // System.out.println("finished iniT estimtes "); - // system.display(); - firsttime = false; - return true; - } catch (Exception e) { - System.out.println("error in chem eq"); - solver = new ChemicalEquilibrium(Amatrix, bVector, system, components, phase); - return solver.solve(); - } - } else { - nVector = calcNVector(); - bVector = calcBVector(); - try { - solver = new ChemicalEquilibrium(Amatrix, bVector, system, components, phase); - } catch (Exception e) { - e.printStackTrace(); - } - return solver.solve(); - } + return nvec; + } + + /** + *

+ * calcBVector. + *

+ * + * @return an array of {@link double} objects + */ + public double[] calcBVector() { + Matrix tempA = new Matrix(Amatrix); + Matrix tempB = new Matrix(nVector, 1); + Matrix tempN = tempA.times(tempB.transpose()).transpose(); + // print added by Neeraj + // System.out.println("b matrix: "); + // tempN.print(10,2); + + return tempN.getArray()[0]; + } + + /** + *

+ * calcChemRefPot. + *

+ * + * @param phase a int + * @return an array of {@link double} objects + */ + public double[] calcChemRefPot(int phase) { + double[] referencePotentials = new double[components.length]; + reactionList.createReactionMatrix(system.getPhase(phase), components); + double[] newreferencePotentials = + reactionList.updateReferencePotentials(system.getPhase(phase), components); + if (newreferencePotentials != null) { + for (int i = 0; i < newreferencePotentials.length; i++) { + referencePotentials[i] = newreferencePotentials[i]; + components[i].setReferencePotential(referencePotentials[i]); + } + return referencePotentials; + } else { + return null; } - - /** - *

- * solveKinetics. - *

- * - * @param phase a int - * @param interPhase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param component a int - * @return a double - */ - public double solveKinetics(int phase, PhaseInterface interPhase, int component) { - return kineticsSolver.calcReacMatrix(system.getPhase(phase), interPhase, component); + } + + /** + *

+ * updateMoles. + *

+ * + * @param phase a int + */ + public void updateMoles(int phase) { + double changeMoles = 0.0; + for (int i = 0; i < components.length; i++) { + if (Math.abs(newMoles[i]) > 1e-45) { + changeMoles += (newMoles[i] + - system.getPhase(phase).getComponents()[components[i].getComponentNumber()] + .getNumberOfMolesInPhase()); + // System.out.println("update moles first " + (components[i].getComponentName() + // + " moles " + components[i].getNumberOfMolesInPhase())); + system.getPhase(phase).addMolesChemReac(components[i].getComponentNumber(), + (newMoles[i] + - system.getPhase(phase).getComponents()[components[i].getComponentNumber()] + .getNumberOfMolesInPhase())); + // System.out.println("update moles after " + (components[i].getComponentName() + // + " moles " + components[i].getNumberOfMolesInPhase())); + } } - - /** - *

- * getKinetics. - *

- * - * @return a {@link neqsim.chemicalReactions.kinetics.Kinetics} object - */ - public Kinetics getKinetics() { - return kineticsSolver; + // System.out.println("change " + changeMoles); + system.initTotalNumberOfMoles(changeMoles);// x_solve.get(NELE,0)*n_t); + system.initBeta(); // this was added for mass trans calc + system.init_x_y(); + system.init(1); + } + + /** + *

+ * solveChemEq. + *

+ * + * @param type a int + * @return a boolean + */ + public boolean solveChemEq(int type) { + return solveChemEq(1, type); + } + + /** + *

+ * solveChemEq. + *

+ * + * @param phase a int + * @param type a int + * @return a boolean + */ + public boolean solveChemEq(int phase, int type) { + if (this.phase != phase) { + setReactiveComponents(phase); + chemRefPot = calcChemRefPot(phase); } - - /** - *

- * Getter for the field reactionList. - *

- * - * @return a {@link neqsim.chemicalReactions.chemicalReaction.ChemicalReactionList} object - */ - public ChemicalReactionList getReactionList() { - return reactionList; + this.phase = phase; + if (!system.isChemicalSystem()) { + System.out.println("no chemical reactions will occur...continue"); + return false; } - /** - *

- * reacHeat. - *

- * - * @param phase a int - * @param component a {@link java.lang.String} object - * @return a double - */ - public double reacHeat(int phase, String component) { - return reactionList.reacHeat(system.getPhase(phase), component); - } - - /** - * Getter for property deltaReactionHeat. - * - * @return Value of property deltaReactionHeat. - */ - public double getDeltaReactionHeat() { - return deltaReactionHeat; + // System.out.println("pressure1"); + calcChemRefPot(phase); + // System.out.println("pressure2"); + if (firsttime == true || type == 0) { + try { + // System.out.println("Calculating initial estimates"); + nVector = calcNVector(); + bVector = calcBVector(); + calcInertMoles(phase); + newMoles = initCalc.generateInitialEstimates(system, bVector, inertMoles, phase); + // Print statement added by Neeraj + // for (i=0;i<5;i++) + // System.out.println("new moles "+newMoles[i]); + updateMoles(phase); + // System.out.println("finished iniT estimtes "); + // system.display(); + firsttime = false; + return true; + } catch (Exception e) { + System.out.println("error in chem eq"); + solver = new ChemicalEquilibrium(Amatrix, bVector, system, components, phase); + return solver.solve(); + } + } else { + nVector = calcNVector(); + bVector = calcBVector(); + try { + solver = new ChemicalEquilibrium(Amatrix, bVector, system, components, phase); + } catch (Exception e) { + e.printStackTrace(); + } + return solver.solve(); } - - /** - * Setter for property deltaReactionHeat. - * - * @param deltaReactionHeat New value of property deltaReactionHeat. - */ - public void setDeltaReactionHeat(double deltaReactionHeat) { - this.deltaReactionHeat = deltaReactionHeat; - } - - // public Matrix calcReacRates(int phase){ - // // System.out.println(" vol " + system.getPhases()[0].getMolarVolume()); - // return getReactionList().calcReacRates(system.getPhase(phase), components); - // } - - // /** Setter for property reactionList. - // * @param reactionList New value of property reactionList. - // */ - // public void - // setReactionList(chemicalReactions.chemicalReaction.ChemicalReactionList - // reactionList) { - // this.reactionList = reactionList; - // } + } + + /** + *

+ * solveKinetics. + *

+ * + * @param phase a int + * @param interPhase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param component a int + * @return a double + */ + public double solveKinetics(int phase, PhaseInterface interPhase, int component) { + return kineticsSolver.calcReacMatrix(system.getPhase(phase), interPhase, component); + } + + /** + *

+ * getKinetics. + *

+ * + * @return a {@link neqsim.chemicalReactions.kinetics.Kinetics} object + */ + public Kinetics getKinetics() { + return kineticsSolver; + } + + /** + *

+ * Getter for the field reactionList. + *

+ * + * @return a {@link neqsim.chemicalReactions.chemicalReaction.ChemicalReactionList} object + */ + public ChemicalReactionList getReactionList() { + return reactionList; + } + + /** + *

+ * reacHeat. + *

+ * + * @param phase a int + * @param component a {@link java.lang.String} object + * @return a double + */ + public double reacHeat(int phase, String component) { + return reactionList.reacHeat(system.getPhase(phase), component); + } + + /** + * Getter for property deltaReactionHeat. + * + * @return Value of property deltaReactionHeat. + */ + public double getDeltaReactionHeat() { + return deltaReactionHeat; + } + + /** + * Setter for property deltaReactionHeat. + * + * @param deltaReactionHeat New value of property deltaReactionHeat. + */ + public void setDeltaReactionHeat(double deltaReactionHeat) { + this.deltaReactionHeat = deltaReactionHeat; + } + + // public Matrix calcReacRates(int phase){ + // // System.out.println(" vol " + system.getPhases()[0].getMolarVolume()); + // return getReactionList().calcReacRates(system.getPhase(phase), components); + // } + + // /** Setter for property reactionList. + // * @param reactionList New value of property reactionList. + // */ + // public void + // setReactionList(chemicalReactions.chemicalReaction.ChemicalReactionList + // reactionList) { + // this.reactionList = reactionList; + // } } diff --git a/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/LinearProgrammingChemicalEquilibrium.java b/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/LinearProgrammingChemicalEquilibrium.java index 17f64a1b31..88768e46e7 100644 --- a/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/LinearProgrammingChemicalEquilibrium.java +++ b/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/LinearProgrammingChemicalEquilibrium.java @@ -3,6 +3,7 @@ * * Created on 11. april 2001, 10:04 */ + package neqsim.chemicalReactions.chemicalEquilibriaum; import java.util.ArrayList; @@ -32,367 +33,365 @@ * @version $Id: $Id */ public class LinearProgrammingChemicalEquilibrium - implements neqsim.thermo.ThermodynamicConstantsInterface { - private static final long serialVersionUID = 1000; - - double[] xEts = null; - double[][] Amatrix; - double[] chemRefPot; - ComponentInterface[] components; - double[] numbering; - String[] elements; - int changes = 0, minChanges = 0, maxChanges = 0; - ChemicalReactionOperations operations; - - /** - *

- * Constructor for LinearProgrammingChemicalEquilibrium. - *

- */ - public LinearProgrammingChemicalEquilibrium() {} + implements neqsim.thermo.ThermodynamicConstantsInterface { + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for LinearProgrammingChemicalEquilibrium. - *

- * - * @param chemRefPot an array of {@link double} objects - * @param components an array of {@link neqsim.thermo.component.ComponentInterface} objects - * @param elements an array of {@link java.lang.String} objects - * @param operations a {@link neqsim.chemicalReactions.ChemicalReactionOperations} object - * @param phase a int - */ - public LinearProgrammingChemicalEquilibrium(double[] chemRefPot, - ComponentInterface[] components, String[] elements, - ChemicalReactionOperations operations, int phase) { - this.operations = operations; - this.chemRefPot = chemRefPot; - this.components = components; - this.elements = elements; - changes = elements.length; - minChanges = elements.length; - maxChanges = components.length; - // System.out.println("max: " + maxChanges + " MIN: " +minChanges); - for (int i = 0; i < components.length; i++) { - components[i].setReferencePotential(chemRefPot[i]); - } + double[] xEts = null; + double[][] Amatrix; + double[] chemRefPot; + ComponentInterface[] components; + double[] numbering; + String[] elements; + int changes = 0, minChanges = 0, maxChanges = 0; + ChemicalReactionOperations operations; - // Commented out by Neeraj - // Arrays.sort(components,new ReferencePotComparator()); - // this.changePrimaryComponents(); - if (operations.calcChemRefPot(phase) != null) { - System.arraycopy(operations.calcChemRefPot(phase), 0, this.chemRefPot, 0, - this.chemRefPot.length); - for (int i = 0; i < components.length; i++) { - components[i].setReferencePotential(chemRefPot[i]); - // System.out.println("sorting....." + components[i].getComponentNumber()); - } - } else { - do { - System.out.println("shifting primary components....."); - this.changePrimaryComponents(); - } while (operations.calcChemRefPot(phase) == null); - // System.out.println("shifting components....." ); - System.arraycopy(operations.calcChemRefPot(phase), 0, this.chemRefPot, 0, - this.chemRefPot.length); - for (int i = 0; i < components.length; i++) { - components[i].setReferencePotential(chemRefPot[i]); - } - Arrays.sort(components, new ReferencePotComparator()); - for (int i = 0; i < components.length; i++) { - chemRefPot[i] = components[i].getReferencePotential(); - } - } + /** + *

+ * Constructor for LinearProgrammingChemicalEquilibrium. + *

+ */ + public LinearProgrammingChemicalEquilibrium() {} - this.Amatrix = calcA(); + /** + *

+ * Constructor for LinearProgrammingChemicalEquilibrium. + *

+ * + * @param chemRefPot an array of {@link double} objects + * @param components an array of {@link neqsim.thermo.component.ComponentInterface} objects + * @param elements an array of {@link java.lang.String} objects + * @param operations a {@link neqsim.chemicalReactions.ChemicalReactionOperations} object + * @param phase a int + */ + public LinearProgrammingChemicalEquilibrium(double[] chemRefPot, ComponentInterface[] components, + String[] elements, ChemicalReactionOperations operations, int phase) { + this.operations = operations; + this.chemRefPot = chemRefPot; + this.components = components; + this.elements = elements; + changes = elements.length; + minChanges = elements.length; + maxChanges = components.length; + // System.out.println("max: " + maxChanges + " MIN: " +minChanges); + for (int i = 0; i < components.length; i++) { + components[i].setReferencePotential(chemRefPot[i]); } - // Modified method by Procede - /** - *

- * calcA. - *

- * - * @return an array of {@link double} objects - */ - public double[][] calcA() { - int A_size = - components.length - operations.getReactionList().getChemicalReactionList().size(); - if (elements.length < (components.length - - operations.getReactionList().getChemicalReactionList().size())) { - A_size = elements.length; - } - A_size = elements.length; - double[][] A = new double[A_size + 1][components.length]; - double[][] Am = new double[A_size][components.length]; - - for (int k = 0; k < A_size; k++) { - for (int i = 0; i < components.length; i++) { - for (int j = 0; j < components[i].getElements().getElementNames().length; j++) { - if (components[i].getElements().getElementNames()[j].equals(elements[k])) { - A[k][i] = components[i].getElements().getElementCoefs()[j]; - Am[k][i] = components[i].getElements().getElementCoefs()[j]; - } - } - } - } - - for (int i = 0; i < components.length; i++) { - A[A_size][i] = components[i].getIonicCharge(); - } - /* - * //Added By Neeraj Matrix A_matrix = new Matrix(A); A_matrix.print(10, 10); if - * (A_matrix.rank() < (elements.length)) { Amatrix = Am; return Am; } else { Amatrix = A; - * return A; } - */ - return A; + // Commented out by Neeraj + // Arrays.sort(components,new ReferencePotComparator()); + // this.changePrimaryComponents(); + if (operations.calcChemRefPot(phase) != null) { + System.arraycopy(operations.calcChemRefPot(phase), 0, this.chemRefPot, 0, + this.chemRefPot.length); + for (int i = 0; i < components.length; i++) { + components[i].setReferencePotential(chemRefPot[i]); + // System.out.println("sorting....." + components[i].getComponentNumber()); + } + } else { + do { + System.out.println("shifting primary components....."); + this.changePrimaryComponents(); + } while (operations.calcChemRefPot(phase) == null); + // System.out.println("shifting components....." ); + System.arraycopy(operations.calcChemRefPot(phase), 0, this.chemRefPot, 0, + this.chemRefPot.length); + for (int i = 0; i < components.length; i++) { + components[i].setReferencePotential(chemRefPot[i]); + } + Arrays.sort(components, new ReferencePotComparator()); + for (int i = 0; i < components.length; i++) { + chemRefPot[i] = components[i].getReferencePotential(); + } } - /** - *

- * getA. - *

- * - * @return an array of {@link double} objects - */ - public double[][] getA() { - return Amatrix; - } + this.Amatrix = calcA(); + } - /** - *

- * getRefPot. - *

- * - * @return an array of {@link double} objects - */ - public double[] getRefPot() { - return chemRefPot; + // Modified method by Procede + /** + *

+ * calcA. + *

+ * + * @return an array of {@link double} objects + */ + public double[][] calcA() { + int A_size = components.length - operations.getReactionList().getChemicalReactionList().size(); + if (elements.length < (components.length + - operations.getReactionList().getChemicalReactionList().size())) { + A_size = elements.length; } + A_size = elements.length; + double[][] A = new double[A_size + 1][components.length]; + double[][] Am = new double[A_size][components.length]; - /** - *

- * changePrimaryComponents. - *

- */ - public void changePrimaryComponents() { - if (changes == maxChanges && minChanges >= 0) { - changes = minChanges; - minChanges--; + for (int k = 0; k < A_size; k++) { + for (int i = 0; i < components.length; i++) { + for (int j = 0; j < components[i].getElements().getElementNames().length; j++) { + if (components[i].getElements().getElementNames()[j].equals(elements[k])) { + A[k][i] = components[i].getElements().getElementCoefs()[j]; + Am[k][i] = components[i].getElements().getElementCoefs()[j]; + } } - ComponentInterface tempComp; - tempComp = components[minChanges - 1].clone(); - components[minChanges - 1] = components[changes].clone(); - components[changes] = tempComp; - changes++; - // chemRefPot = operations.calcChemRefPot(); - /* - * this.Amatrix = calcA(); Matrix temp = ((Matrix) (new Matrix(Amatrix))).getMatrix(0, - * elements.length-1, 0, elements.length-1); System.out.println("rank....." +temp.rank()); - */ + } } - // Method commented out by Neeraj + for (int i = 0; i < components.length; i++) { + A[A_size][i] = components[i].getIonicCharge(); + } /* - * public double[] generateInitialEstimates(SystemInterface system, double[] bVector, double - * inertMoles, int phase){ Matrix solved; Matrix atemp = new - * Matrix(Amatrix).getMatrix(0,Amatrix.length-1,0,Amatrix[0].length-1).copy(); Matrix mutemp = - * new Matrix(chemRefPot,1).times(1.0/(R*system.getPhase(phase).getTemperature())). copy(); - * Matrix lagrangeTemp = atemp.transpose().solve(mutemp.transpose()).copy(); //bmatrix and Ans - * Added by Neeraj //bmatrix = new Matrix(bVector,1); //int rank = atemp.rank(); - * //System.out.println("Rank of A "+rank); //Ans = atemp.solve(bmatrix.transpose()); - * //System.out.println("Ans"); //Ans.print(10,8); //Print statements added by Neeraj - * System.out.println("lagranges: "); lagrangeTemp.print(10,2); System.out.println("refpot: "); - * mutemp.print(10,2); System.out.println("A: "); atemp.print(10,2); - * - * - * Matrix rTemp = new Matrix(atemp.getRowDimension(),1); rTemp.set(0,0,inertMoles/bVector[0]); - * for(int i=1;i1e-10); - * - * double temp=1.0; for(int i=1;i - * calcx. - *

- * - * @param atemp a {@link Jama.Matrix} object - * @param lagrangeTemp a {@link Jama.Matrix} object - */ - public void calcx(Matrix atemp, Matrix lagrangeTemp) { - /* - * xEts = new double[atemp.getColumnDimension()]; for(int - * k=0;k200) { - * this.changePrimaryComponents(); return this.generateInitialEstimates(system, bVector, - * inertMoles); } } xEts = new double[Amatrix[0].length]; for(int i=0;i + * getA. + *

+ * + * @return an array of {@link double} objects + */ + public double[][] getA() { + return Amatrix; + } + + /** + *

+ * getRefPot. + *

+ * + * @return an array of {@link double} objects + */ + public double[] getRefPot() { + return chemRefPot; + } + + /** + *

+ * changePrimaryComponents. + *

+ */ + public void changePrimaryComponents() { + if (changes == maxChanges && minChanges >= 0) { + changes = minChanges; + minChanges--; } - // Method added by Neeraj + ComponentInterface tempComp; + tempComp = components[minChanges - 1].clone(); + components[minChanges - 1] = components[changes].clone(); + components[changes] = tempComp; + changes++; + // chemRefPot = operations.calcChemRefPot(); /* - * public double[] generateInitialEstimates(SystemInterface system, double[] bVector, double - * inertMoles, int phase){ int i,j; double[] n = new double[components.length]; Matrix atemp, - * btemp; Matrix mutemp = new - * Matrix(chemRefPot,1).times(1.0/(R*system.getPhase(phase).getTemperature())). copy(); Matrix - * ntemp; atemp = new Matrix(7,7); btemp = new Matrix(1,7); //for (i=0;i<4;i++) for - * (i=0;i<5;i++) { for (j=0;j<7;j++) atemp.set(i,j,Amatrix[i][j]); btemp.set(0,i,bVector[i]); - * - * } atemp.set(5,4,1); atemp.set(6,5,1); //atemp.set(4,4,1); //atemp.set(5,5,1); - * //atemp.set(6,1,1); //atemp.print(5,1); //btemp.print(5,5); //mutemp.print(5,5); ntemp = - * atemp.solve(btemp.transpose()); ntemp.print(5,5); for (i=0;i<7;i++) n[i] = ntemp.get(i,0); - * int rank = atemp.rank(); return n; - * - * - * } + * this.Amatrix = calcA(); Matrix temp = ((Matrix) (new Matrix(Amatrix))).getMatrix(0, + * elements.length-1, 0, elements.length-1); System.out.println("rank....." +temp.rank()); */ + } + + // Method commented out by Neeraj + /* + * public double[] generateInitialEstimates(SystemInterface system, double[] bVector, double + * inertMoles, int phase){ Matrix solved; Matrix atemp = new + * Matrix(Amatrix).getMatrix(0,Amatrix.length-1,0,Amatrix[0].length-1).copy(); Matrix mutemp = new + * Matrix(chemRefPot,1).times(1.0/(R*system.getPhase(phase).getTemperature())). copy(); Matrix + * lagrangeTemp = atemp.transpose().solve(mutemp.transpose()).copy(); //bmatrix and Ans Added by + * Neeraj //bmatrix = new Matrix(bVector,1); //int rank = atemp.rank(); + * //System.out.println("Rank of A "+rank); //Ans = atemp.solve(bmatrix.transpose()); + * //System.out.println("Ans"); //Ans.print(10,8); //Print statements added by Neeraj + * System.out.println("lagranges: "); lagrangeTemp.print(10,2); System.out.println("refpot: "); + * mutemp.print(10,2); System.out.println("A: "); atemp.print(10,2); + * + * + * Matrix rTemp = new Matrix(atemp.getRowDimension(),1); rTemp.set(0,0,inertMoles/bVector[0]); + * for(int i=1;i1e-10); + * + * double temp=1.0; for(int i=1;i - * generateInitialEstimates. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param bVector an array of {@link double} objects - * @param inertMoles a double - * @param phase a int - * @return an array of {@link double} objects + /** + *

+ * calcx. + *

+ * + * @param atemp a {@link Jama.Matrix} object + * @param lagrangeTemp a {@link Jama.Matrix} object + */ + public void calcx(Matrix atemp, Matrix lagrangeTemp) { + /* + * xEts = new double[atemp.getColumnDimension()]; for(int k=0;k200) { + * this.changePrimaryComponents(); return this.generateInitialEstimates(system, bVector, + * inertMoles); } } xEts = new double[Amatrix[0].length]; for(int i=0;i cons = new ArrayList(); - for (j = 0; j < bVector.length; j++) { - for (i = 0; i < components.length; i++) { - v[i + 1] = Amatrix[j][i]; - } - rhs = bVector[j]; - cons.add(new LinearConstraint(v, Relationship.EQ, rhs)); - } + } + // Method added by Neeraj + /* + * public double[] generateInitialEstimates(SystemInterface system, double[] bVector, double + * inertMoles, int phase){ int i,j; double[] n = new double[components.length]; Matrix atemp, + * btemp; Matrix mutemp = new + * Matrix(chemRefPot,1).times(1.0/(R*system.getPhase(phase).getTemperature())). copy(); Matrix + * ntemp; atemp = new Matrix(7,7); btemp = new Matrix(1,7); //for (i=0;i<4;i++) for (i=0;i<5;i++) + * { for (j=0;j<7;j++) atemp.set(i,j,Amatrix[i][j]); btemp.set(0,i,bVector[i]); + * + * } atemp.set(5,4,1); atemp.set(6,5,1); //atemp.set(4,4,1); //atemp.set(5,5,1); + * //atemp.set(6,1,1); //atemp.print(5,1); //btemp.print(5,5); //mutemp.print(5,5); ntemp = + * atemp.solve(btemp.transpose()); ntemp.print(5,5); for (i=0;i<7;i++) n[i] = ntemp.get(i,0); int + * rank = atemp.rank(); return n; + * + * + * } + */ - NonNegativeConstraint nonneg = new NonNegativeConstraint(true); - LinearConstraintSet consSet = new LinearConstraintSet(cons); - SimplexSolver solver = new SimplexSolver(); - PointValuePair optimal = null; - try { - optimal = solver.optimize(new MaxIter(1000), f, consSet, GoalType.MINIMIZE, nonneg); - } catch (NoFeasibleSolutionException exp) { - System.out.println("no feasible solution"); - return null; - } catch (Exception exp) { - System.out.println("linear optimization failed"); - return null; - } + // Method updated to use Apache Commons Math 3 by Marlene 07.12.18 + /** + *

+ * generateInitialEstimates. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param bVector an array of {@link double} objects + * @param inertMoles a double + * @param phase a int + * @return an array of {@link double} objects + */ + public double[] generateInitialEstimates(SystemInterface system, double[] bVector, + double inertMoles, int phase) { + int i, j; + double rhs = 0.0; + Matrix mutemp = + new Matrix(chemRefPot, 1).times(1.0 / (R * system.getPhase(phase).getTemperature())).copy(); + double v[] = new double[components.length + 1]; + for (i = 0; i < components.length; i++) { + v[i + 1] = mutemp.get(0, i); + } + LinearObjectiveFunction f = new LinearObjectiveFunction(v, 0.0); + List cons = new ArrayList(); + for (j = 0; j < bVector.length; j++) { + for (i = 0; i < components.length; i++) { + v[i + 1] = Amatrix[j][i]; + } + rhs = bVector[j]; + cons.add(new LinearConstraint(v, Relationship.EQ, rhs)); + } - int compNumb = system.getPhase(phase).getNumberOfComponents(); - double lp_solution[] = new double[compNumb]; - double[] temp = optimal.getPoint(); - for (i = 0; i < compNumb - (compNumb - components.length); i++) { - lp_solution[i] = temp[i + 1]; - } + NonNegativeConstraint nonneg = new NonNegativeConstraint(true); + LinearConstraintSet consSet = new LinearConstraintSet(cons); + SimplexSolver solver = new SimplexSolver(); + PointValuePair optimal = null; + try { + optimal = solver.optimize(new MaxIter(1000), f, consSet, GoalType.MINIMIZE, nonneg); + } catch (NoFeasibleSolutionException exp) { + System.out.println("no feasible solution"); + return null; + } catch (Exception exp) { + System.out.println("linear optimization failed"); + return null; + } - return lp_solution; + int compNumb = system.getPhase(phase).getNumberOfComponents(); + double lp_solution[] = new double[compNumb]; + double[] temp = optimal.getPoint(); + for (i = 0; i < compNumb - (compNumb - components.length); i++) { + lp_solution[i] = temp[i + 1]; } + + return lp_solution; + } } diff --git a/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/ReferencePotComparator.java b/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/ReferencePotComparator.java index 743ff63e0d..8fad021378 100644 --- a/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/ReferencePotComparator.java +++ b/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/ReferencePotComparator.java @@ -3,6 +3,7 @@ * * Created on 11. april 2001, 20:21 */ + package neqsim.chemicalReactions.chemicalEquilibriaum; import java.util.Comparator; @@ -17,17 +18,17 @@ * @version $Id: $Id */ public class ReferencePotComparator - implements Comparator, java.io.Serializable { - private static final long serialVersionUID = 1000; + implements Comparator, java.io.Serializable { + private static final long serialVersionUID = 1000; - /** {@inheritDoc} */ - @Override - public int compare(ComponentInterface o1, ComponentInterface o2) { - double v1 = o1.getReferencePotential(); - double v2 = o2.getReferencePotential(); + /** {@inheritDoc} */ + @Override + public int compare(ComponentInterface o1, ComponentInterface o2) { + double v1 = o1.getReferencePotential(); + double v2 = o2.getReferencePotential(); - int ans = v1 >= v2 ? 1 : 0; + int ans = v1 >= v2 ? 1 : 0; - return ans; - } + return ans; + } } diff --git a/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReaction.java b/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReaction.java index 9a98e757b2..dc1af8e95c 100644 --- a/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReaction.java +++ b/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReaction.java @@ -3,6 +3,7 @@ * * Created on 4. februar 2001, 15:32 */ + package neqsim.chemicalReactions.chemicalReaction; import Jama.Matrix; @@ -20,478 +21,485 @@ * @version $Id: $Id */ public class ChemicalReaction extends NamedBaseClass - implements neqsim.thermo.ThermodynamicConstantsInterface { - private static final long serialVersionUID = 1000; - - String[] names, reactantNames, productNames; - double[] stocCoefs = new double[4]; - double[] reacCoefs, prodCoefs, moles; - boolean shiftSignK = false; - double[] K = new double[4]; - double rateFactor = 0, activationEnergy, refT; - double G = 0, lnK = 0; - int numberOfReactants = 0; - - /** - *

- * Constructor for ChemicalReaction. - *

+ implements neqsim.thermo.ThermodynamicConstantsInterface { + private static final long serialVersionUID = 1000; + + String[] names; + String[] reactantNames; + String[] productNames; + double[] stocCoefs = new double[4]; + double[] reacCoefs; + double[] prodCoefs; + double[] moles; + boolean shiftSignK = false; + double[] K = new double[4]; + double rateFactor = 0; + double activationEnergy; + double refT; + double G = 0; + double lnK = 0; + int numberOfReactants = 0; + + /** + *

+ * Constructor for ChemicalReaction. + *

+ * + * @deprecated use + * {@link #ChemicalReaction(String, String[], double[], double[], double, double, double)} + * instead + */ + @Deprecated + public ChemicalReaction() { + super("ChemicalReaction"); + } + + /** + *

+ * Constructor for ChemicalReaction. + *

+ * + * @param name a {@link java.lang.String} object + * @param names an array of {@link java.lang.String} objects + * @param stocCoefs an array of {@link double} objects + * @param K an array of {@link double} objects + * @param r a double + * @param activationEnergy a double + * @param refT a double + */ + public ChemicalReaction(String name, String[] names, double[] stocCoefs, double[] K, double r, + double activationEnergy, double refT) { + /* + * this.names = names; this.stocCoefs = stocCoefs; this.K = K; * - * @deprecated use - * {@link #ChemicalReaction(String, String[], double[], double[], double, double, double)} - * instead */ - @Deprecated - public ChemicalReaction() { - super("ChemicalReaction"); + super(name); + this.names = new String[names.length]; + this.moles = new double[names.length]; + this.stocCoefs = new double[stocCoefs.length]; + this.K = new double[K.length]; + this.rateFactor = r; + this.refT = refT; + this.activationEnergy = activationEnergy; + + System.arraycopy(names, 0, this.names, 0, names.length); + System.arraycopy(stocCoefs, 0, this.stocCoefs, 0, stocCoefs.length); + System.arraycopy(K, 0, this.K, 0, K.length); + numberOfReactants = 0; + + for (int i = 0; i < names.length; i++) { + // System.out.println("stoc coef: " + this.stocCoefs[i]); + if (stocCoefs[i] < 0) { + numberOfReactants++; + } } - /** - *

- * Constructor for ChemicalReaction. - *

- * - * @param name a {@link java.lang.String} object - * @param names an array of {@link java.lang.String} objects - * @param stocCoefs an array of {@link double} objects - * @param K an array of {@link double} objects - * @param r a double - * @param activationEnergy a double - * @param refT a double - */ - public ChemicalReaction(String name, String[] names, double[] stocCoefs, double[] K, double r, - double activationEnergy, double refT) { - /* - * this.names = names; this.stocCoefs = stocCoefs; this.K = K; - * - */ - super(name); - this.names = new String[names.length]; - this.moles = new double[names.length]; - this.stocCoefs = new double[stocCoefs.length]; - this.K = new double[K.length]; - this.rateFactor = r; - this.refT = refT; - this.activationEnergy = activationEnergy; - - System.arraycopy(names, 0, this.names, 0, names.length); - System.arraycopy(stocCoefs, 0, this.stocCoefs, 0, stocCoefs.length); - System.arraycopy(K, 0, this.K, 0, K.length); - numberOfReactants = 0; - - for (int i = 0; i < names.length; i++) { - // System.out.println("stoc coef: " + this.stocCoefs[i]); - if (stocCoefs[i] < 0) { - numberOfReactants++; - } - } - - reactantNames = new String[numberOfReactants]; - productNames = new String[names.length - numberOfReactants]; - // this.reacCoefs = new double[numberOfReactants]; - // this.prodCoefs = new double[names.length - numberOfReactants]; - int k = 0, l = 0; - for (int i = 0; i < names.length; i++) { - if (stocCoefs[i] < 0) { - // reacCoefs[k] = stocCoefs[i]; - reactantNames[k++] = this.names[i]; - } else { - // prodCoefs[l] = stocCoefs[i]; - productNames[l++] = this.names[i]; - } - } + reactantNames = new String[numberOfReactants]; + productNames = new String[names.length - numberOfReactants]; + // this.reacCoefs = new double[numberOfReactants]; + // this.prodCoefs = new double[names.length - numberOfReactants]; + int k = 0; + int l = 0; + for (int i = 0; i < names.length; i++) { + if (stocCoefs[i] < 0) { + // reacCoefs[k] = stocCoefs[i]; + reactantNames[k++] = this.names[i]; + } else { + // prodCoefs[l] = stocCoefs[i]; + productNames[l++] = this.names[i]; + } } - - /** - *

- * Getter for the field reactantNames. - *

- * - * @return an array of {@link java.lang.String} objects - */ - public String[] getReactantNames() { - return reactantNames; + } + + /** + *

+ * Getter for the field reactantNames. + *

+ * + * @return an array of {@link java.lang.String} objects + */ + public String[] getReactantNames() { + return reactantNames; + } + + /** + * reaction constant at reference temperature + * + * @return a double + */ + public double getRateFactor() { + return rateFactor; + } + + /** + *

+ * Getter for the field rateFactor. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double getRateFactor(PhaseInterface phase) { + // return rateFactor * Math.exp(-activationEnergy/R*(1.0/phase.getTemperature() + // - 1.0/refT)); + return 2.576e9 * Math.exp(-6024.0 / phase.getTemperature()) / 1000.0; + } + + /** + *

+ * getK. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double getK(PhaseInterface phase) { + double temperature = phase.getTemperature(); + lnK = K[0] + K[1] / (temperature) + K[2] * Math.log(temperature) + K[3] * temperature; + if (shiftSignK) { + lnK = -lnK; } - - /** - * reaction constant at reference temperature - * - * @return a double - */ - public double getRateFactor() { - return rateFactor; + // System.out.println("K " + Math.exp(lnK)); + return Math.exp(lnK); + } + + /** + *

+ * Getter for the field stocCoefs. + *

+ * + * @return an array of {@link double} objects + */ + public double[] getStocCoefs() { + return this.stocCoefs; + } + + /** + *

+ * Getter for the field productNames. + *

+ * + * @return an array of {@link java.lang.String} objects + */ + public String[] getProductNames() { + return productNames; + } + + /** + *

+ * Getter for the field names. + *

+ * + * @return an array of {@link java.lang.String} objects + */ + public String[] getNames() { + return names; + } + + /** + *

+ * calcKx. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param phaseNumb a int + * @return a double + */ + public double calcKx(neqsim.thermo.system.SystemInterface system, int phaseNumb) { + double kx = 1.0; + for (int i = 0; i < names.length; i++) { + // System.out.println("name " + names[i] + " stcoc " + stocCoefs[i]); + kx *= Math.pow(system.getPhase(phaseNumb).getComponent(names[i]).getx(), stocCoefs[i]); } - - /** - *

- * Getter for the field rateFactor. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double getRateFactor(PhaseInterface phase) { - // return rateFactor * Math.exp(-activationEnergy/R*(1.0/phase.getTemperature() - // - 1.0/refT)); - return 2.576e9 * Math.exp(-6024.0 / phase.getTemperature()) / 1000.0; + return kx; + } + + /** + *

+ * calcKgamma. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param phaseNumb a int + * @return a double + */ + public double calcKgamma(neqsim.thermo.system.SystemInterface system, int phaseNumb) { + double kgamma = 1.0; + for (int i = 0; i < names.length; i++) { + // System.out.println("name " + names[i] + " stcoc " + stocCoefs[i]); + if (system.getPhase(phaseNumb).getComponent(names[i]).calcActivity()) { + kgamma *= Math.pow( + system.getPhase(phaseNumb).getActivityCoefficient( + system.getPhase(phaseNumb).getComponent(names[i]).getComponentNumber(), + system.getPhase(phaseNumb).getComponent("water").getComponentNumber()), + stocCoefs[i]); + } } - - /** - *

- * getK. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double getK(PhaseInterface phase) { - double temperature = phase.getTemperature(); - lnK = K[0] + K[1] / (temperature) + K[2] * Math.log(temperature) + K[3] * temperature; - if (shiftSignK) { - lnK = -lnK; + return kgamma; + } + + /** + *

+ * getSaturationRatio. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param phaseNumb a int + * @return a double + */ + public double getSaturationRatio(neqsim.thermo.system.SystemInterface system, int phaseNumb) { + double ksp = 1.0; + for (int i = 0; i < names.length; i++) { + // System.out.println("name " + names[i] + " stcoc " + stocCoefs[i]); + if (stocCoefs[i] < 0) { + ksp *= Math.pow(system.getPhase(phaseNumb).getComponent(names[i]).getx(), -stocCoefs[i]); + } + } + ksp /= (getK(system.getPhase(phaseNumb))); + return ksp; + } + + /** + *

+ * calcK. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param phaseNumb a int + * @return a double + */ + public double calcK(neqsim.thermo.system.SystemInterface system, int phaseNumb) { + return calcKx(system, phaseNumb) * calcKgamma(system, phaseNumb); + } + + /** + * Generaters initial estimates for the molenumbers + * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param components an array of {@link neqsim.thermo.component.ComponentInterface} objects + * @param Amatrix an array of {@link double} objects + * @param chemRefPot an array of {@link double} objects + */ + public void initMoleNumbers(PhaseInterface phase, ComponentInterface[] components, + double[][] Amatrix, double[] chemRefPot) { + Matrix tempAmatrix = new Matrix(Amatrix.length, names.length); + Matrix tempNmatrix = new Matrix(names.length, 1); + Matrix tempRefPotmatrix = new Matrix(names.length, 1); + + for (int i = 0; i < names.length; i++) { + for (int j = 0; j < components.length; j++) { + // System.out.println("names: " + names[i] + " " + + // system.getPhases()[0].getComponents()[j].getName()); + if (this.names[i].equals(components[j].getName())) { + for (int k = 0; k < Amatrix.length; k++) { + tempAmatrix.set(k, i, Amatrix[k][j]); + } + tempNmatrix.set(i, 0, components[j].getNumberOfMolesInPhase()); + tempRefPotmatrix.set(i, 0, chemRefPot[j]); } - // System.out.println("K " + Math.exp(lnK)); - return Math.exp(lnK); + } } - /** - *

- * Getter for the field stocCoefs. - *

- * - * @return an array of {@link double} objects - */ - public double[] getStocCoefs() { - return this.stocCoefs; - } + // Matrix tempBmatrix = tempAmatrix.times(tempNmatrix); - /** - *

- * Getter for the field productNames. - *

- * - * @return an array of {@link java.lang.String} objects - */ - public String[] getProductNames() { - return productNames; - } + // System.out.println("atemp: "); + // tempAmatrix.print(10,2); + // tempNmatrix.print(10,2); + // tempBmatrix.print(10,2); + // tempRefPotmatrix.print(10,2); - /** - *

- * Getter for the field names. - *

- * - * @return an array of {@link java.lang.String} objects - */ - public String[] getNames() { - return names; - } + // set AprodMetrix and setAreacMatrix - /** - *

- * calcKx. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param phaseNumb a int - * @return a double - */ - public double calcKx(neqsim.thermo.system.SystemInterface system, int phaseNumb) { - double kx = 1.0; - for (int i = 0; i < names.length; i++) { - // System.out.println("name " + names[i] + " stcoc " + stocCoefs[i]); - kx *= Math.pow(system.getPhase(phaseNumb).getComponent(names[i]).getx(), stocCoefs[i]); - } - return kx; + Matrix tempAProdmatrix = new Matrix(Amatrix.length, productNames.length); + Matrix tempAReacmatrix = new Matrix(Amatrix.length, reactantNames.length); + // Matrix tempNProdmatrix = new Matrix(Amatrix.length, 1); + // Matrix tempNReacmatrix = new Matrix(Amatrix.length, 1); + + for (int i = 0; i < Amatrix.length; i++) { + for (int k = 0; k < reactantNames.length; k++) { + tempAReacmatrix.set(i, k, tempAmatrix.get(i, k)); + } } - /** - *

- * calcKgamma. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param phaseNumb a int - * @return a double - */ - public double calcKgamma(neqsim.thermo.system.SystemInterface system, int phaseNumb) { - double kgamma = 1.0; - for (int i = 0; i < names.length; i++) { - // System.out.println("name " + names[i] + " stcoc " + stocCoefs[i]); - if (system.getPhase(phaseNumb).getComponent(names[i]).calcActivity()) { - kgamma *= Math.pow(system.getPhase(phaseNumb).getActivityCoefficient( - system.getPhase(phaseNumb).getComponent(names[i]).getComponentNumber(), - system.getPhase(phaseNumb).getComponent("water").getComponentNumber()), - stocCoefs[i]); - } - } - return kgamma; + for (int i = 0; i < Amatrix.length; i++) { + for (int k = 0; k < productNames.length; k++) { + tempAProdmatrix.set(i, k, tempAmatrix.get(i, names.length - 1 - k)); + } } - /** - *

- * getSaturationRatio. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param phaseNumb a int - * @return a double - */ - public double getSaturationRatio(neqsim.thermo.system.SystemInterface system, int phaseNumb) { - double ksp = 1.0; - for (int i = 0; i < names.length; i++) { - // System.out.println("name " + names[i] + " stcoc " + stocCoefs[i]); - if (stocCoefs[i] < 0) { - ksp *= Math.pow(system.getPhase(phaseNumb).getComponent(names[i]).getx(), - -stocCoefs[i]); - } + // Matrix tempNProdmatrix = tempAProdmatrix.solve(tempBmatrix); + // Matrix tempNReacmatrix = tempAReacmatrix.solve(tempBmatrix); + + // System.out.println("btemp: "); + // tempNProdmatrix.print(10,2); + // tempNReacmatrix.print(10,2); + // tempAProdmatrix.print(10,2); + // tempAReacmatrix.print(10,2); + } + + /** + *

+ * init. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + */ + public void init(PhaseInterface phase) { + double temperature = phase.getTemperature(); + lnK = K[0] + K[1] / (temperature) + K[2] * Math.log(temperature) + K[3] * temperature; + // System.out.println("K: " + Math.exp(lnK)); + for (int i = 0; i < names.length; i++) { + for (int j = 0; j < phase.getNumberOfComponents(); j++) { + if (this.names[i].equals(phase.getComponent(j).getName())) { + moles[i] = phase.getComponent(j).getNumberOfMolesInPhase(); } - ksp /= (getK(system.getPhase(phaseNumb))); - return ksp; + } } - /** - *

- * calcK. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param phaseNumb a int - * @return a double - */ - public double calcK(neqsim.thermo.system.SystemInterface system, int phaseNumb) { - return calcKx(system, phaseNumb) * calcKgamma(system, phaseNumb); + double cK = lnK; + for (int i = 0; i < names.length; i++) { + cK -= Math.log(moles[i] / phase.getNumberOfMolesInPhase()) * stocCoefs[i]; } - /** - * Generaters initial estimates for the molenumbers - * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param components an array of {@link neqsim.thermo.component.ComponentInterface} objects - * @param Amatrix an array of {@link double} objects - * @param chemRefPot an array of {@link double} objects - */ - public void initMoleNumbers(PhaseInterface phase, ComponentInterface[] components, - double[][] Amatrix, double[] chemRefPot) { - Matrix tempAmatrix = new Matrix(Amatrix.length, names.length); - Matrix tempNmatrix = new Matrix(names.length, 1); - Matrix tempRefPotmatrix = new Matrix(names.length, 1); - - for (int i = 0; i < names.length; i++) { - for (int j = 0; j < components.length; j++) { - // System.out.println("names: " + names[i] + " " + - // system.getPhases()[0].getComponents()[j].getName()); - if (this.names[i].equals(components[j].getName())) { - for (int k = 0; k < Amatrix.length; k++) { - tempAmatrix.set(k, i, Amatrix[k][j]); - } - tempNmatrix.set(i, 0, components[j].getNumberOfMolesInPhase()); - tempRefPotmatrix.set(i, 0, chemRefPot[j]); - } - } - } - - // Matrix tempBmatrix = tempAmatrix.times(tempNmatrix); - - // System.out.println("atemp: "); - // tempAmatrix.print(10,2); - // tempNmatrix.print(10,2); - // tempBmatrix.print(10,2); - // tempRefPotmatrix.print(10,2); - - // set AprodMetrix and setAreacMatrix - - Matrix tempAProdmatrix = new Matrix(Amatrix.length, productNames.length); - Matrix tempAReacmatrix = new Matrix(Amatrix.length, reactantNames.length); - // Matrix tempNProdmatrix = new Matrix(Amatrix.length, 1); - // Matrix tempNReacmatrix = new Matrix(Amatrix.length, 1); - - for (int i = 0; i < Amatrix.length; i++) { - for (int k = 0; k < reactantNames.length; k++) { - tempAReacmatrix.set(i, k, tempAmatrix.get(i, k)); - } - } - - for (int i = 0; i < Amatrix.length; i++) { - for (int k = 0; k < productNames.length; k++) { - tempAProdmatrix.set(i, k, tempAmatrix.get(i, names.length - 1 - k)); - } - } - - // Matrix tempNProdmatrix = tempAProdmatrix.solve(tempBmatrix); - // Matrix tempNReacmatrix = tempAReacmatrix.solve(tempBmatrix); - - // System.out.println("btemp: "); - // tempNProdmatrix.print(10,2); - // tempNReacmatrix.print(10,2); - // tempAProdmatrix.print(10,2); - // tempAReacmatrix.print(10,2); + if (Math.exp(cK) > 1) { + for (int i = 0; i < stocCoefs.length; i++) { + stocCoefs[i] = -stocCoefs[i]; + } + lnK = -lnK; + shiftSignK = !shiftSignK; } - - /** - *

- * init. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + } + + /** + *

+ * checkK. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public void checkK(SystemInterface system) { + // double cK=Math.log(getK(system.getTemperature())); + // for(int i=0;i + * reactantsContains. + *

+ * + * @param names an array of {@link java.lang.String} objects + * @return a boolean + */ + public boolean reactantsContains(String[] names) { + boolean test = false; + /* + * if(reactantNames.length>names.length || productNames.length>names.length ){ return false; } */ - public void init(PhaseInterface phase) { - double temperature = phase.getTemperature(); - lnK = K[0] + K[1] / (temperature) + K[2] * Math.log(temperature) + K[3] * temperature; - // System.out.println("K: " + Math.exp(lnK)); - for (int i = 0; i < names.length; i++) { - for (int j = 0; j < phase.getNumberOfComponents(); j++) { - if (this.names[i].equals(phase.getComponent(j).getName())) { - moles[i] = phase.getComponent(j).getNumberOfMolesInPhase(); - } - } - } - double cK = lnK; - for (int i = 0; i < names.length; i++) { - cK -= Math.log(moles[i] / phase.getNumberOfMolesInPhase()) * stocCoefs[i]; - } - - if (Math.exp(cK) > 1) { - for (int i = 0; i < stocCoefs.length; i++) { - stocCoefs[i] = -stocCoefs[i]; - } - lnK = -lnK; - shiftSignK = !shiftSignK; + for (int j = 0; j < reactantNames.length; j++) { + for (int i = 0; i < names.length; i++) { + if (names[i].equals(reactantNames[j])) { + test = true; + break; + } else { + test = false; } + } + if (test == false) { + break; + } } - /** - *

- * checkK. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public void checkK(SystemInterface system) { - // double cK=Math.log(getK(system.getTemperature())); - // for(int i=0;i - * reactantsContains. - *

- * - * @param names an array of {@link java.lang.String} objects - * @return a boolean - */ - public boolean reactantsContains(String[] names) { - boolean test = false; - /* - * if(reactantNames.length>names.length || productNames.length>names.length ){ return false; - * } - */ - - for (int j = 0; j < reactantNames.length; j++) { - for (int i = 0; i < names.length; i++) { - if (names[i].equals(reactantNames[j])) { - test = true; - break; - } else { - test = false; - } - } - if (test == false) { - break; - } + if (test == false) { + for (int j = 0; j < productNames.length; j++) { + for (int i = 0; i < names.length; i++) { + if (names[i].equals(productNames[j])) { + test = true; + break; + } else { + test = false; + } } - if (test == false) { - for (int j = 0; j < productNames.length; j++) { - for (int i = 0; i < names.length; i++) { - if (names[i].equals(productNames[j])) { - test = true; - break; - } else { - test = false; - } - } - if (test == false) { - break; - } - } + break; } - - return test; + } } - /** - * Setter for property rateFactor. - * - * @param rateFactor New value of property rateFactor. - */ - public void setRateFactor(double rateFactor) { - this.rateFactor = rateFactor; - } - - /** - * Getter for property activationEnergy. - * - * @return Value of property activationEnergy. - */ - public double getActivationEnergy() { - return activationEnergy; - } - - /** - * Setter for property activationEnergy. - * - * @param activationEnergy New value of property activationEnergy. - */ - public void setActivationEnergy(double activationEnergy) { - this.activationEnergy = activationEnergy; - } - - /** - * Getter for property reactionHeat. Van't HOffs equation dh = d lnK/dT * R * T^2 - * - * @return Value of property reactionHeat. - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - */ - public double getReactionHeat(PhaseInterface phase) { - double diffKt = -K[1] / Math.pow(phase.getTemperature(), 2.0) - + K[2] / phase.getTemperature() + K[3]; - double sign = (shiftSignK = true) ? -1.0 : 1.0; - return sign * diffKt * Math.pow(phase.getTemperature(), 2.0) * R; - } - - /** - * Getter for property k. - * - * @return Value of property k. - */ - public double[] getK() { - return this.K; - } - - /** - * Setter for property k. - * - * @param k New value of property k. - */ - public void setK(double[] k) { - this.K = k; - } - - /** - *

- * setK. - *

- * - * @param i a int - * @param Kd a double - */ - public void setK(int i, double Kd) { - this.K[i] = Kd; - } + return test; + } + + /** + * Setter for property rateFactor. + * + * @param rateFactor New value of property rateFactor. + */ + public void setRateFactor(double rateFactor) { + this.rateFactor = rateFactor; + } + + /** + * Getter for property activationEnergy. + * + * @return Value of property activationEnergy. + */ + public double getActivationEnergy() { + return activationEnergy; + } + + /** + * Setter for property activationEnergy. + * + * @param activationEnergy New value of property activationEnergy. + */ + public void setActivationEnergy(double activationEnergy) { + this.activationEnergy = activationEnergy; + } + + /** + * Getter for property reactionHeat. Van't HOffs equation dh = d lnK/dT * R * T^2 + * + * @return Value of property reactionHeat. + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + */ + public double getReactionHeat(PhaseInterface phase) { + double diffKt = + -K[1] / Math.pow(phase.getTemperature(), 2.0) + K[2] / phase.getTemperature() + K[3]; + double sign = (shiftSignK = true) ? -1.0 : 1.0; + return sign * diffKt * Math.pow(phase.getTemperature(), 2.0) * R; + } + + /** + * Getter for property k. + * + * @return Value of property k. + */ + public double[] getK() { + return this.K; + } + + /** + * Setter for property k. + * + * @param k New value of property k. + */ + public void setK(double[] k) { + this.K = k; + } + + /** + *

+ * setK. + *

+ * + * @param i a int + * @param Kd a double + */ + public void setK(int i, double Kd) { + this.K[i] = Kd; + } } diff --git a/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReactionFactory.java b/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReactionFactory.java index 37acb03872..2af0c47977 100644 --- a/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReactionFactory.java +++ b/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReactionFactory.java @@ -3,6 +3,7 @@ * * Created on 20. september 2004, 22:40 */ + package neqsim.chemicalReactions.chemicalReaction; import java.util.ArrayList; @@ -16,69 +17,67 @@ * @version $Id: $Id */ public class ChemicalReactionFactory { - public ChemicalReactionFactory() {} + public ChemicalReactionFactory() {} - /** - *

- * getChemicalReaction. - *

- * - * @param name a {@link java.lang.String} object - * @return a {@link neqsim.chemicalReactions.chemicalReaction.ChemicalReaction} object - */ - public static ChemicalReaction getChemicalReaction(String name) { - ArrayList names = new ArrayList(); - ArrayList stocCoef = new ArrayList(); - double[] K = new double[4]; - double refT = 0; - double rateFactor = 0; - double activationEnergy = 0; - neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); + /** + *

+ * getChemicalReaction. + *

+ * + * @param name a {@link java.lang.String} object + * @return a {@link neqsim.chemicalReactions.chemicalReaction.ChemicalReaction} object + */ + public static ChemicalReaction getChemicalReaction(String name) { + ArrayList names = new ArrayList(); + ArrayList stocCoef = new ArrayList(); + double[] K = new double[4]; + double refT = 0; + double rateFactor = 0; + double activationEnergy = 0; + neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); - try { - java.sql.ResultSet dataSet = null; - dataSet = database - .getResultSet("SELECT * FROM reactionkspdata where name='" + name + "'"); + try { + java.sql.ResultSet dataSet = null; + dataSet = database.getResultSet("SELECT * FROM reactionkspdata where name='" + name + "'"); - dataSet.next(); - String reacname = dataSet.getString("name"); - K[0] = Double.parseDouble(dataSet.getString("K1")); - K[1] = Double.parseDouble(dataSet.getString("K2")); - K[2] = Double.parseDouble(dataSet.getString("K3")); - K[3] = Double.parseDouble(dataSet.getString("K4")); - refT = Double.parseDouble(dataSet.getString("Tref")); - rateFactor = Double.parseDouble(dataSet.getString("r")); + dataSet.next(); + String reacname = dataSet.getString("name"); + K[0] = Double.parseDouble(dataSet.getString("K1")); + K[1] = Double.parseDouble(dataSet.getString("K2")); + K[2] = Double.parseDouble(dataSet.getString("K3")); + K[3] = Double.parseDouble(dataSet.getString("K4")); + refT = Double.parseDouble(dataSet.getString("Tref")); + rateFactor = Double.parseDouble(dataSet.getString("r")); - activationEnergy = Double.parseDouble(dataSet.getString("ACTENERGY")); - neqsim.util.database.NeqSimDataBase database2 = - new neqsim.util.database.NeqSimDataBase(); - java.sql.ResultSet dataSet2 = database2 - .getResultSet("SELECT * FROM stoccoefdata where reacname='" + reacname + "'"); - dataSet2.next(); - do { - names.add(dataSet2.getString("compname").trim()); - stocCoef.add((dataSet2.getString("stoccoef")).trim()); - } while (dataSet2.next()); + activationEnergy = Double.parseDouble(dataSet.getString("ACTENERGY")); + neqsim.util.database.NeqSimDataBase database2 = new neqsim.util.database.NeqSimDataBase(); + java.sql.ResultSet dataSet2 = + database2.getResultSet("SELECT * FROM stoccoefdata where reacname='" + reacname + "'"); + dataSet2.next(); + do { + names.add(dataSet2.getString("compname").trim()); + stocCoef.add((dataSet2.getString("stoccoef")).trim()); + } while (dataSet2.next()); - // System.out.println("reaction added ok..."); - dataSet.close(); - } catch (Exception e) { - e.printStackTrace(); - String err = e.toString(); - System.out.println("could not add reacton: " + err); - } - try { - database.getConnection().close(); - } catch (Exception e) { - System.out.println("err closing database"); - } - String[] nameArray = new String[names.size()]; - double[] stocCoefArray = new double[names.size()]; - for (int i = 0; i < names.size(); i++) { - nameArray[i] = names.get(i); - stocCoefArray[i] = Double.parseDouble(stocCoef.get(i)); - } - return new ChemicalReaction(name, nameArray, stocCoefArray, K, rateFactor, activationEnergy, - refT); + // System.out.println("reaction added ok..."); + dataSet.close(); + } catch (Exception e) { + e.printStackTrace(); + String err = e.toString(); + System.out.println("could not add reacton: " + err); + } + try { + database.getConnection().close(); + } catch (Exception e) { + System.out.println("err closing database"); + } + String[] nameArray = new String[names.size()]; + double[] stocCoefArray = new double[names.size()]; + for (int i = 0; i < names.size(); i++) { + nameArray[i] = names.get(i); + stocCoefArray[i] = Double.parseDouble(stocCoef.get(i)); } + return new ChemicalReaction(name, nameArray, stocCoefArray, K, rateFactor, activationEnergy, + refT); + } } diff --git a/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReactionList.java b/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReactionList.java index ababeee788..e78663fba8 100644 --- a/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReactionList.java +++ b/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReactionList.java @@ -3,6 +3,7 @@ * * Created on 4. februar 2001, 15:32 */ + package neqsim.chemicalReactions.chemicalReaction; import java.util.ArrayList; @@ -24,511 +25,509 @@ * @version $Id: $Id */ public class ChemicalReactionList implements ThermodynamicConstantsInterface { - private static final long serialVersionUID = 1000; - - ArrayList chemicalReactionList = new ArrayList(); - String[] reactiveComponentList; - double[][] reacMatrix; - double[][] reacGMatrix; - double[][] tempReacMatrix; - double[][] tempStocMatrix; - - /** - *

- * Constructor for ChemicalReactionList. - *

- */ - public ChemicalReactionList() {} - - /** - *

- * readReactions. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public void readReactions(SystemInterface system) { - chemicalReactionList.clear(); - ArrayList names = new ArrayList(); - ArrayList stocCoef = new ArrayList(); - double r = 0, refT = 0, actH; - double[] K = new double[4]; - boolean useReaction = false; - neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); - java.sql.ResultSet dataSet = null; - try { - if (system.getModelName().equals("Kent Eisenberg-model")) { - // System.out.println("selecting Kent-Eisenberg reaction set"); - dataSet = database.getResultSet("SELECT * FROM reactiondatakenteisenberg"); - } else { - // System.out.println("selecting standard reaction set"); - dataSet = database.getResultSet("SELECT * FROM reactiondata"); - } - - double[] coefArray; - String[] nameArray; - dataSet.next(); + private static final long serialVersionUID = 1000; + + ArrayList chemicalReactionList = new ArrayList(); + String[] reactiveComponentList; + double[][] reacMatrix; + double[][] reacGMatrix; + double[][] tempReacMatrix; + double[][] tempStocMatrix; + + /** + *

+ * Constructor for ChemicalReactionList. + *

+ */ + public ChemicalReactionList() {} + + /** + *

+ * readReactions. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public void readReactions(SystemInterface system) { + chemicalReactionList.clear(); + ArrayList names = new ArrayList(); + ArrayList stocCoef = new ArrayList(); + double r = 0, refT = 0, actH; + double[] K = new double[4]; + boolean useReaction = false; + neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); + java.sql.ResultSet dataSet = null; + try { + if (system.getModelName().equals("Kent Eisenberg-model")) { + // System.out.println("selecting Kent-Eisenberg reaction set"); + dataSet = database.getResultSet("SELECT * FROM reactiondatakenteisenberg"); + } else { + // System.out.println("selecting standard reaction set"); + dataSet = database.getResultSet("SELECT * FROM reactiondata"); + } + + double[] coefArray; + String[] nameArray; + dataSet.next(); + do { + useReaction = Integer.parseInt(dataSet.getString("usereaction")) == 1; + if (useReaction) { + names.clear(); + stocCoef.clear(); + String reacname = dataSet.getString("NAME"); + // System.out.println("name " +reacname ); + K[0] = Double.parseDouble(dataSet.getString("K1")); + K[1] = Double.parseDouble(dataSet.getString("K2")); + K[2] = Double.parseDouble(dataSet.getString("K3")); + K[3] = Double.parseDouble(dataSet.getString("K4")); + refT = Double.parseDouble(dataSet.getString("Tref")); + r = Double.parseDouble(dataSet.getString("r")); + actH = Double.parseDouble(dataSet.getString("ACTENERGY")); + + java.sql.ResultSet dataSet2 = null; + try { + neqsim.util.database.NeqSimDataBase database2 = + new neqsim.util.database.NeqSimDataBase(); + dataSet2 = database2 + .getResultSet("SELECT * FROM stoccoefdata where REACNAME='" + reacname + "'"); + dataSet2.next(); do { - useReaction = Integer.parseInt(dataSet.getString("usereaction")) == 1; - if (useReaction) { - names.clear(); - stocCoef.clear(); - String reacname = dataSet.getString("NAME"); - // System.out.println("name " +reacname ); - K[0] = Double.parseDouble(dataSet.getString("K1")); - K[1] = Double.parseDouble(dataSet.getString("K2")); - K[2] = Double.parseDouble(dataSet.getString("K3")); - K[3] = Double.parseDouble(dataSet.getString("K4")); - refT = Double.parseDouble(dataSet.getString("Tref")); - r = Double.parseDouble(dataSet.getString("r")); - actH = Double.parseDouble(dataSet.getString("ACTENERGY")); - - java.sql.ResultSet dataSet2 = null; - try { - neqsim.util.database.NeqSimDataBase database2 = - new neqsim.util.database.NeqSimDataBase(); - dataSet2 = database2.getResultSet( - "SELECT * FROM stoccoefdata where REACNAME='" + reacname + "'"); - dataSet2.next(); - do { - // System.out.println("name of cop " - // +dataSet2.getString("compname").trim()); - names.add(dataSet2.getString("compname").trim()); - stocCoef.add((dataSet2.getString("stoccoef")).trim()); - } while (dataSet2.next()); - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - dataSet2.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - // System.out.println(names); - // System.out.println(stocCoef); - nameArray = new String[names.size()]; - coefArray = new double[nameArray.length]; - for (int i = 0; i < nameArray.length; i++) { - coefArray[i] = Double.parseDouble(stocCoef.get(i)); - nameArray[i] = names.get(i); - } - - ChemicalReaction reaction = - new ChemicalReaction(reacname, nameArray, coefArray, K, r, actH, refT); - chemicalReactionList.add(reaction); - // System.out.println("reaction added ok..."); - } - } while (dataSet.next()); - } catch (Exception e) { - String err = e.toString(); - System.out.println("could not add reacton: " + err); - } finally { + // System.out.println("name of cop " + // +dataSet2.getString("compname").trim()); + names.add(dataSet2.getString("compname").trim()); + stocCoef.add((dataSet2.getString("stoccoef")).trim()); + } while (dataSet2.next()); + } catch (Exception e) { + e.printStackTrace(); + } finally { try { - dataSet.close(); + dataSet2.close(); } catch (Exception e) { - e.printStackTrace(); + e.printStackTrace(); } + } + // System.out.println(names); + // System.out.println(stocCoef); + nameArray = new String[names.size()]; + coefArray = new double[nameArray.length]; + for (int i = 0; i < nameArray.length; i++) { + coefArray[i] = Double.parseDouble(stocCoef.get(i)); + nameArray[i] = names.get(i); + } + + ChemicalReaction reaction = + new ChemicalReaction(reacname, nameArray, coefArray, K, r, actH, refT); + chemicalReactionList.add(reaction); + // System.out.println("reaction added ok..."); } - try { - database.getConnection().close(); - } catch (Exception e) { - System.out.println("err closing database"); - } + } while (dataSet.next()); + } catch (Exception e) { + String err = e.toString(); + System.out.println("could not add reacton: " + err); + } finally { + try { + dataSet.close(); + } catch (Exception e) { + e.printStackTrace(); + } } - - /** - *

- * getReaction. - *

- * - * @param i a int - * @return a {@link neqsim.chemicalReactions.chemicalReaction.ChemicalReaction} object - */ - public ChemicalReaction getReaction(int i) { + try { + database.getConnection().close(); + } catch (Exception e) { + System.out.println("err closing database"); + } + } + + /** + *

+ * getReaction. + *

+ * + * @param i a int + * @return a {@link neqsim.chemicalReactions.chemicalReaction.ChemicalReaction} object + */ + public ChemicalReaction getReaction(int i) { + return chemicalReactionList.get(i); + } + + /** + *

+ * getReaction. + *

+ * + * @param name a {@link java.lang.String} object + * @return a {@link neqsim.chemicalReactions.chemicalReaction.ChemicalReaction} object + */ + public ChemicalReaction getReaction(String name) { + for (int i = 0; i < chemicalReactionList.size(); i++) { + if ((chemicalReactionList.get(i)).getName().equals(name)) { return chemicalReactionList.get(i); + } } - - /** - *

- * getReaction. - *

- * - * @param name a {@link java.lang.String} object - * @return a {@link neqsim.chemicalReactions.chemicalReaction.ChemicalReaction} object - */ - public ChemicalReaction getReaction(String name) { - for (int i = 0; i < chemicalReactionList.size(); i++) { - if ((chemicalReactionList.get(i)).getName().equals(name)) { - return chemicalReactionList.get(i); - } - } - System.out.println("did not find reaction: " + name); - return null; + System.out.println("did not find reaction: " + name); + return null; + } + + /** + *

+ * removeJunkReactions. + *

+ * + * @param names an array of {@link java.lang.String} objects + */ + public void removeJunkReactions(String[] names) { + Iterator e = chemicalReactionList.iterator(); + while (e.hasNext()) { + // System.out.println("reaction name " +((ChemicalReaction) + // e.next()).getName()); + if (!(e.next()).reactantsContains(names)) { + e.remove(); + } } - - /** - *

- * removeJunkReactions. - *

- * - * @param names an array of {@link java.lang.String} objects - */ - public void removeJunkReactions(String[] names) { - Iterator e = chemicalReactionList.iterator(); - while (e.hasNext()) { - // System.out.println("reaction name " +((ChemicalReaction) - // e.next()).getName()); - if (!(e.next()).reactantsContains(names)) { - e.remove(); - } - } + } + + /** + *

+ * checkReactions. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + */ + public void checkReactions(PhaseInterface phase) { + Iterator e = chemicalReactionList.iterator(); + while (e.hasNext()) { + (e.next()).init(phase); } - - /** - *

- * checkReactions. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - */ - public void checkReactions(PhaseInterface phase) { - Iterator e = chemicalReactionList.iterator(); - while (e.hasNext()) { - (e.next()).init(phase); - } + } + + /** + *

+ * initMoleNumbers. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param components an array of {@link neqsim.thermo.component.ComponentInterface} objects + * @param Amatrix an array of {@link double} objects + * @param chemRefPot an array of {@link double} objects + */ + public void initMoleNumbers(PhaseInterface phase, ComponentInterface[] components, + double[][] Amatrix, double[] chemRefPot) { + Iterator e = chemicalReactionList.iterator(); + while (e.hasNext()) { + (e.next()).initMoleNumbers(phase, components, Amatrix, chemRefPot); + // ((ChemicalReaction)e).checkK(system); } - - /** - *

- * initMoleNumbers. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param components an array of {@link neqsim.thermo.component.ComponentInterface} objects - * @param Amatrix an array of {@link double} objects - * @param chemRefPot an array of {@link double} objects - */ - public void initMoleNumbers(PhaseInterface phase, ComponentInterface[] components, - double[][] Amatrix, double[] chemRefPot) { - Iterator e = chemicalReactionList.iterator(); - while (e.hasNext()) { - (e.next()).initMoleNumbers(phase, components, Amatrix, chemRefPot); - // ((ChemicalReaction)e).checkK(system); - } + } + + /** + *

+ * getAllComponents. + *

+ * + * @return an array of {@link java.lang.String} objects + */ + public String[] getAllComponents() { + HashSet components = new HashSet(); + Iterator e = chemicalReactionList.iterator(); + ChemicalReaction reaction; + while (e.hasNext()) { + reaction = e.next(); + components.addAll(Arrays.asList(reaction.getNames())); } - - /** - *

- * getAllComponents. - *

- * - * @return an array of {@link java.lang.String} objects - */ - public String[] getAllComponents() { - HashSet components = new HashSet(); - Iterator e = chemicalReactionList.iterator(); - ChemicalReaction reaction; - while (e.hasNext()) { - reaction = e.next(); - components.addAll(Arrays.asList(reaction.getNames())); - } - String[] componentList = new String[components.size()]; - int k = 0; - Iterator newe = components.iterator(); - while (newe.hasNext()) { - componentList[k++] = newe.next(); - } - reactiveComponentList = componentList; - return componentList; + String[] componentList = new String[components.size()]; + int k = 0; + Iterator newe = components.iterator(); + while (newe.hasNext()) { + componentList[k++] = newe.next(); } - - /** - *

- * createReactionMatrix. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param components an array of {@link neqsim.thermo.component.ComponentInterface} objects - * @return an array of {@link double} objects - */ - public double[][] createReactionMatrix(PhaseInterface phase, ComponentInterface[] components) { - Iterator e = chemicalReactionList.iterator(); - ChemicalReaction reaction; - int reactionNumber = 0; - reacMatrix = new double[chemicalReactionList.size()][reactiveComponentList.length]; - reacGMatrix = new double[chemicalReactionList.size()][reactiveComponentList.length + 1]; - try { - while (e.hasNext()) { - reaction = e.next(); - for (int i = 0; i < components.length; i++) { - reacMatrix[reactionNumber][i] = 0; - // System.out.println("Component List loop "+components[i].getComponentName()); - for (int j = 0; j < reaction.getNames().length; j++) { - if (components[i].getName().equals(reaction.getNames()[j])) { - reacMatrix[reactionNumber][i] = reaction.getStocCoefs()[j]; - reacGMatrix[reactionNumber][i] = reaction.getStocCoefs()[j]; - } - } - } - reacGMatrix[reactionNumber][components.length] = - R * phase.getTemperature() * Math.log(reaction.getK(phase)); - reactionNumber++; + reactiveComponentList = componentList; + return componentList; + } + + /** + *

+ * createReactionMatrix. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param components an array of {@link neqsim.thermo.component.ComponentInterface} objects + * @return an array of {@link double} objects + */ + public double[][] createReactionMatrix(PhaseInterface phase, ComponentInterface[] components) { + Iterator e = chemicalReactionList.iterator(); + ChemicalReaction reaction; + int reactionNumber = 0; + reacMatrix = new double[chemicalReactionList.size()][reactiveComponentList.length]; + reacGMatrix = new double[chemicalReactionList.size()][reactiveComponentList.length + 1]; + try { + while (e.hasNext()) { + reaction = e.next(); + for (int i = 0; i < components.length; i++) { + reacMatrix[reactionNumber][i] = 0; + // System.out.println("Component List loop "+components[i].getComponentName()); + for (int j = 0; j < reaction.getNames().length; j++) { + if (components[i].getName().equals(reaction.getNames()[j])) { + reacMatrix[reactionNumber][i] = reaction.getStocCoefs()[j]; + reacGMatrix[reactionNumber][i] = reaction.getStocCoefs()[j]; } - } catch (Exception er) { - er.printStackTrace(); + } } - - /* - * Matrix reacMatr; if (reacGMatrix.length > 0) { reacMatr = new Matrix(reacGMatrix); } - * System.out.println("reac matrix: "); reacMatr.print(10,3); - */ - return reacMatrix; + reacGMatrix[reactionNumber][components.length] = + R * phase.getTemperature() * Math.log(reaction.getK(phase)); + reactionNumber++; + } + } catch (Exception er) { + er.printStackTrace(); } - /** - *

- * updateReferencePotentials. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param components an array of {@link neqsim.thermo.component.ComponentInterface} objects - * @return an array of {@link double} objects + /* + * Matrix reacMatr; if (reacGMatrix.length > 0) { reacMatr = new Matrix(reacGMatrix); } + * System.out.println("reac matrix: "); reacMatr.print(10,3); */ - public double[] updateReferencePotentials(PhaseInterface phase, - ComponentInterface[] components) { - for (int i = 0; i < chemicalReactionList.size(); i++) { - reacGMatrix[i][components.length] = R * phase.getTemperature() - * Math.log((chemicalReactionList.get(i)).getK(phase)); - } - return calcReferencePotentials(); + return reacMatrix; + } + + /** + *

+ * updateReferencePotentials. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param components an array of {@link neqsim.thermo.component.ComponentInterface} objects + * @return an array of {@link double} objects + */ + public double[] updateReferencePotentials(PhaseInterface phase, ComponentInterface[] components) { + for (int i = 0; i < chemicalReactionList.size(); i++) { + reacGMatrix[i][components.length] = + R * phase.getTemperature() * Math.log((chemicalReactionList.get(i)).getK(phase)); } - - /** - *

- * getReactionGMatrix. - *

- * - * @return an array of {@link double} objects - */ - public double[][] getReactionGMatrix() { - return reacGMatrix; + return calcReferencePotentials(); + } + + /** + *

+ * getReactionGMatrix. + *

+ * + * @return an array of {@link double} objects + */ + public double[][] getReactionGMatrix() { + return reacGMatrix; + } + + /** + *

+ * getReactionMatrix. + *

+ * + * @return an array of {@link double} objects + */ + public double[][] getReactionMatrix() { + return reacMatrix; + } + + /** + *

+ * calcReferencePotentials. + *

+ * + * @return an array of {@link double} objects + */ + public double[] calcReferencePotentials() { + Matrix reacMatr = new Matrix(reacGMatrix); + Matrix Amatrix = reacMatr.copy().getMatrix(0, chemicalReactionList.size() - 1, 0, + chemicalReactionList.size() - 1);// new Matrix(reacGMatrix); + Matrix Bmatrix = reacMatr.copy().getMatrix(0, chemicalReactionList.size() - 1, + reacGMatrix[0].length - 1, reacGMatrix[0].length - 1);// new Matrix(reacGMatrix); + + if (Amatrix.rank() < chemicalReactionList.size()) { + System.out.println("rank of A matrix too low !!" + Amatrix.rank()); + return null; + } else { + Matrix solv = Amatrix.solve(Bmatrix.timesEquals(-1.0)); // Solves for A*X = -B + // System.out.println("ref pots"); + // solv.print(10,3); + return solv.transpose().getArrayCopy()[0]; } - - /** - *

- * getReactionMatrix. - *

- * - * @return an array of {@link double} objects - */ - public double[][] getReactionMatrix() { - return reacMatrix; - } - - /** - *

- * calcReferencePotentials. - *

- * - * @return an array of {@link double} objects - */ - public double[] calcReferencePotentials() { - Matrix reacMatr = new Matrix(reacGMatrix); - Matrix Amatrix = reacMatr.copy().getMatrix(0, chemicalReactionList.size() - 1, 0, - chemicalReactionList.size() - 1);// new Matrix(reacGMatrix); - Matrix Bmatrix = reacMatr.copy().getMatrix(0, chemicalReactionList.size() - 1, - reacGMatrix[0].length - 1, reacGMatrix[0].length - 1);// new Matrix(reacGMatrix); - - if (Amatrix.rank() < chemicalReactionList.size()) { - System.out.println("rank of A matrix too low !!" + Amatrix.rank()); - return null; - } else { - Matrix solv = Amatrix.solve(Bmatrix.timesEquals(-1.0)); // Solves for A*X = -B - // System.out.println("ref pots"); - // solv.print(10,3); - return solv.transpose().getArrayCopy()[0]; - } - } - - /** - *

- * calcReacMatrix. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - */ - public void calcReacMatrix(PhaseInterface phase) { - tempReacMatrix = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; - tempStocMatrix = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; - ChemicalReaction reaction; - - for (int i = 0; i < phase.getNumberOfComponents(); i++) { - Iterator e = chemicalReactionList.iterator(); - while (e.hasNext()) { - reaction = e.next(); - for (int j = 0; j < reaction.getNames().length; j++) { - if (phase.getComponents()[i].getName().equals(reaction.getNames()[j])) { - for (int k = 0; k < phase.getNumberOfComponents(); k++) { - for (int o = 0; o < reaction.getNames().length; o++) { - if (phase.getComponents()[k].getName() - .equals(reaction.getNames()[o])) { - // System.out.println("comp1 " + - // system.getPhases()[1].getComponents()[i].getComponentName() + - // " comp2 " - // +system.getPhases()[1].getComponents()[k].getComponentName() - // ); - tempReacMatrix[i][k] = reaction.getRateFactor(phase); - tempStocMatrix[i][k] = -reaction.getStocCoefs()[o]; - } - } - } - } + } + + /** + *

+ * calcReacMatrix. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + */ + public void calcReacMatrix(PhaseInterface phase) { + tempReacMatrix = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; + tempStocMatrix = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; + ChemicalReaction reaction; + + for (int i = 0; i < phase.getNumberOfComponents(); i++) { + Iterator e = chemicalReactionList.iterator(); + while (e.hasNext()) { + reaction = e.next(); + for (int j = 0; j < reaction.getNames().length; j++) { + if (phase.getComponents()[i].getName().equals(reaction.getNames()[j])) { + for (int k = 0; k < phase.getNumberOfComponents(); k++) { + for (int o = 0; o < reaction.getNames().length; o++) { + if (phase.getComponents()[k].getName().equals(reaction.getNames()[o])) { + // System.out.println("comp1 " + + // system.getPhases()[1].getComponents()[i].getComponentName() + + // " comp2 " + // +system.getPhases()[1].getComponents()[k].getComponentName() + // ); + tempReacMatrix[i][k] = reaction.getRateFactor(phase); + tempStocMatrix[i][k] = -reaction.getStocCoefs()[o]; } + } } + } } - - // Matrix temp = new Matrix(tempReacMatrix); - // Matrix temp2 = new Matrix(tempStocMatrix); - // temp.print(10,10); - // temp2.print(10,10); - } - - /** - *

- * Getter for the field reacMatrix. - *

- * - * @return an array of {@link double} objects - */ - public double[][] getReacMatrix() { - return tempReacMatrix; + } } - /** - *

- * getStocMatrix. - *

- * - * @return an array of {@link double} objects - */ - public double[][] getStocMatrix() { - return tempStocMatrix; + // Matrix temp = new Matrix(tempReacMatrix); + // Matrix temp2 = new Matrix(tempStocMatrix); + // temp.print(10,10); + // temp2.print(10,10); + } + + /** + *

+ * Getter for the field reacMatrix. + *

+ * + * @return an array of {@link double} objects + */ + public double[][] getReacMatrix() { + return tempReacMatrix; + } + + /** + *

+ * getStocMatrix. + *

+ * + * @return an array of {@link double} objects + */ + public double[][] getStocMatrix() { + return tempStocMatrix; + } + + /** + *

+ * calcReacRates. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param components an array of {@link neqsim.thermo.component.ComponentInterface} objects + * @return a {@link Jama.Matrix} object + */ + public Matrix calcReacRates(PhaseInterface phase, ComponentInterface[] components) { + Matrix modReacMatrix = new Matrix(reacMatrix).copy(); + // System.out.println(" vol " + system.getPhases()[1].getMolarVolume()); + + for (int i = 0; i < chemicalReactionList.size(); i++) { + for (int j = 0; j < components.length; j++) { + // System.out.println("mol cons " + + // components[j].getx()/system.getPhases()[1].getMolarMass()); + modReacMatrix.set(i, j, + Math.pow(components[j].getx() * phase.getDensity() / phase.getMolarMass(), + Math.abs(reacMatrix[i][j]))); + } } - - /** - *

- * calcReacRates. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param components an array of {@link neqsim.thermo.component.ComponentInterface} objects - * @return a {@link Jama.Matrix} object - */ - public Matrix calcReacRates(PhaseInterface phase, ComponentInterface[] components) { - Matrix modReacMatrix = new Matrix(reacMatrix).copy(); - // System.out.println(" vol " + system.getPhases()[1].getMolarVolume()); - - for (int i = 0; i < chemicalReactionList.size(); i++) { - for (int j = 0; j < components.length; j++) { - // System.out.println("mol cons " + - // components[j].getx()/system.getPhases()[1].getMolarMass()); - modReacMatrix.set(i, j, - Math.pow(components[j].getx() * phase.getDensity() / phase.getMolarMass(), - Math.abs(reacMatrix[i][j]))); - } - } - // modReacMatrix.print(10,10); - double[] tempForward = new double[chemicalReactionList.size()]; - double[] tempBackward = new double[chemicalReactionList.size()]; - double[] reacVec = new double[chemicalReactionList.size()]; - - for (int i = 0; i < chemicalReactionList.size(); i++) { - tempForward[i] = (chemicalReactionList.get(i)).getRateFactor(); - tempBackward[i] = (chemicalReactionList.get(i)).getK(phase) - / (chemicalReactionList.get(i)).getRateFactor(); - for (int j = 0; j < components.length; j++) { - if (reacMatrix[i][j] > 0) { - tempForward[i] *= modReacMatrix.get(i, j); - } - if (reacMatrix[i][j] < 0) { - tempBackward[i] *= modReacMatrix.get(i, j); - } - } - reacVec[i] = tempForward[i] - tempBackward[i]; - } - - Matrix reacMatVec = new Matrix(reacVec, 1); - Matrix reacMat = new Matrix(reacMatrix).transpose().times(reacMatVec); - - double[] reactRates = new double[phase.getComponents().length]; - for (int j = 0; j < components.length; j++) { - reactRates[components[j].getComponentNumber()] = reacMat.get(j, 0); + // modReacMatrix.print(10,10); + double[] tempForward = new double[chemicalReactionList.size()]; + double[] tempBackward = new double[chemicalReactionList.size()]; + double[] reacVec = new double[chemicalReactionList.size()]; + + for (int i = 0; i < chemicalReactionList.size(); i++) { + tempForward[i] = (chemicalReactionList.get(i)).getRateFactor(); + tempBackward[i] = + (chemicalReactionList.get(i)).getK(phase) / (chemicalReactionList.get(i)).getRateFactor(); + for (int j = 0; j < components.length; j++) { + if (reacMatrix[i][j] > 0) { + tempForward[i] *= modReacMatrix.get(i, j); } - - for (int j = 0; j < phase.getNumberOfComponents(); j++) { - // System.out.println("reac " +j + " " + reactRates[j] ); + if (reacMatrix[i][j] < 0) { + tempBackward[i] *= modReacMatrix.get(i, j); } - - // System.out.println("reac matrix "); - // reacMat.print(10,10); - return reacMat; + } + reacVec[i] = tempForward[i] - tempBackward[i]; } - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - @SuppressWarnings("unused") - public static void main(String[] args) { - ChemicalReactionList test = new ChemicalReactionList(); - // test.readReactions(); - // String[] test2 = {"water","MDEA"}; - // test.removeJunkReactions(test2); - // String[] comp = test.getAllComponents(); - // System.out.println("components: " + comp.length); - } + Matrix reacMatVec = new Matrix(reacVec, 1); + Matrix reacMat = new Matrix(reacMatrix).transpose().times(reacMatVec); - /** - * Getter for property chemicalReactionList. - * - * @return Value of property chemicalReactionList. - */ - public ArrayList getChemicalReactionList() { - return chemicalReactionList; + double[] reactRates = new double[phase.getComponents().length]; + for (int j = 0; j < components.length; j++) { + reactRates[components[j].getComponentNumber()] = reacMat.get(j, 0); } - /** - * Setter for property chemicalReactionList. - * - * @param chemicalReactionList New value of property chemicalReactionList. - */ - public void setChemicalReactionList(ArrayList chemicalReactionList) { - this.chemicalReactionList = chemicalReactionList; + for (int j = 0; j < phase.getNumberOfComponents(); j++) { + // System.out.println("reac " +j + " " + reactRates[j] ); } - /** - *

- * reacHeat. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param comp a {@link java.lang.String} object - * @return a double - */ - public double reacHeat(PhaseInterface phase, String comp) { - ChemicalReaction reaction; - double heat = 0.0; - Iterator e = chemicalReactionList.iterator(); - while (e.hasNext()) { - reaction = e.next(); - heat += phase.getComponent(comp).getNumberOfmoles() * reaction.getReactionHeat(phase); - // System.out.println("moles " + phase.getComponent(comp).getNumberOfmoles()); - // System.out.println("reac heat 2 " + heat); - } - return heat; + // System.out.println("reac matrix "); + // reacMat.print(10,10); + return reacMat; + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String[] args) { + ChemicalReactionList test = new ChemicalReactionList(); + // test.readReactions(); + // String[] test2 = {"water","MDEA"}; + // test.removeJunkReactions(test2); + // String[] comp = test.getAllComponents(); + // System.out.println("components: " + comp.length); + } + + /** + * Getter for property chemicalReactionList. + * + * @return Value of property chemicalReactionList. + */ + public ArrayList getChemicalReactionList() { + return chemicalReactionList; + } + + /** + * Setter for property chemicalReactionList. + * + * @param chemicalReactionList New value of property chemicalReactionList. + */ + public void setChemicalReactionList(ArrayList chemicalReactionList) { + this.chemicalReactionList = chemicalReactionList; + } + + /** + *

+ * reacHeat. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param comp a {@link java.lang.String} object + * @return a double + */ + public double reacHeat(PhaseInterface phase, String comp) { + ChemicalReaction reaction; + double heat = 0.0; + Iterator e = chemicalReactionList.iterator(); + while (e.hasNext()) { + reaction = e.next(); + heat += phase.getComponent(comp).getNumberOfmoles() * reaction.getReactionHeat(phase); + // System.out.println("moles " + phase.getComponent(comp).getNumberOfmoles()); + // System.out.println("reac heat 2 " + heat); } + return heat; + } } diff --git a/src/main/java/neqsim/chemicalReactions/kinetics/Kinetics.java b/src/main/java/neqsim/chemicalReactions/kinetics/Kinetics.java index 77785b0f9d..ecc03c6f67 100644 --- a/src/main/java/neqsim/chemicalReactions/kinetics/Kinetics.java +++ b/src/main/java/neqsim/chemicalReactions/kinetics/Kinetics.java @@ -3,6 +3,7 @@ * * Created on 3. august 2001, 23:05 */ + package neqsim.chemicalReactions.kinetics; import java.util.Iterator; @@ -19,141 +20,133 @@ * @version $Id: $Id */ public class Kinetics implements java.io.Serializable { - private static final long serialVersionUID = 1000; - protected ChemicalReactionOperations operations; - double phiInfinite = 0.0; - boolean isIrreversible; + private static final long serialVersionUID = 1000; + protected ChemicalReactionOperations operations; + double phiInfinite = 0.0; + boolean isIrreversible; - /** - *

- * Constructor for Kinetics. - *

- */ - public Kinetics() {} + /** + *

+ * Constructor for Kinetics. + *

+ */ + public Kinetics() {} - /** - *

- * Constructor for Kinetics. - *

- * - * @param operations a {@link neqsim.chemicalReactions.ChemicalReactionOperations} object - */ - public Kinetics(ChemicalReactionOperations operations) { - this.operations = operations; - } + /** + *

+ * Constructor for Kinetics. + *

+ * + * @param operations a {@link neqsim.chemicalReactions.ChemicalReactionOperations} object + */ + public Kinetics(ChemicalReactionOperations operations) { + this.operations = operations; + } - /** - *

- * calcKinetics. - *

- */ - public void calcKinetics() {} + /** + *

+ * calcKinetics. + *

+ */ + public void calcKinetics() {} - /** - *

- * calcReacMatrix. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param interPhase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param comp a int - * @return a double - */ - public double calcReacMatrix(PhaseInterface phase, PhaseInterface interPhase, int comp) { - ChemicalReaction reaction; - double reacCoef = 0.0, irr = 0.0, ktemp = 0.0, exponent = 0.0; - Iterator e = - operations.getReactionList().getChemicalReactionList().iterator(); - phase.getPhysicalProperties().calcEffectiveDiffusionCoefficients(); + /** + *

+ * calcReacMatrix. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param interPhase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param comp a int + * @return a double + */ + public double calcReacMatrix(PhaseInterface phase, PhaseInterface interPhase, int comp) { + ChemicalReaction reaction; + double reacCoef = 0.0, irr = 0.0, ktemp = 0.0, exponent = 0.0; + Iterator e = + operations.getReactionList().getChemicalReactionList().iterator(); + phase.getPhysicalProperties().calcEffectiveDiffusionCoefficients(); - while (e.hasNext()) { - reaction = e.next(); - ktemp = reaction.getRateFactor(interPhase); - irr = 1.0 / reaction.getK(phase); - // System.out.println("reaction heat " + reaction.getReactionHeat(phase)); - for (int j = 0; j < reaction.getNames().length; j++) { - irr *= Math.pow( - interPhase.getComponent(reaction.getNames()[j]).getx() - * phase.getPhysicalProperties().getDensity() - / phase.getComponent(reaction.getNames()[j]).getMolarMass(), - -reaction.getStocCoefs()[j]); - // System.out.println("reac names " + reaction.getNames()[j]); - // System.out.println("stoc coefs " + reaction.getStocCoefs()[j]); - if (phase.getComponents()[comp].getName().equals(reaction.getNames()[j])) { - for (int k = 0; k < reaction.getNames().length; k++) { - if (reaction.getStocCoefs()[k] * reaction.getStocCoefs()[j] > 0 && !(k == j) - && !(phase.getComponent(reaction.getNames()[k]).getName() - .equals("water"))) { - exponent = reaction.getStocCoefs()[k] / reaction.getStocCoefs()[j]; - double molConsAint = interPhase.getComponent(comp).getx() - * interPhase.getPhysicalProperties().getDensity() - / phase.getComponent(comp).getMolarMass(); - double molConsB = phase.getComponent(reaction.getNames()[k]).getx() - * phase.getPhysicalProperties().getDensity() - / phase.getComponent(reaction.getNames()[k]).getMolarMass(); - ktemp *= Math.pow(molConsB, exponent); - phiInfinite = Math - .sqrt(phase.getPhysicalProperties() - .getEffectiveDiffusionCoefficient(comp) - / phase.getPhysicalProperties() - .getEffectiveDiffusionCoefficient(phase - .getComponent(reaction.getNames()[k]) - .getComponentNumber())) - + Math.sqrt( - phase.getPhysicalProperties() - .getEffectiveDiffusionCoefficient(phase - .getComponent(reaction.getNames()[k]) - .getComponentNumber()) - / phase.getPhysicalProperties() - .getEffectiveDiffusionCoefficient(comp)) - * molConsB / (exponent * molConsAint); - // System.out.println("reac names " + reaction.getNames()[k]); - // System.out.println("phi inf " + phiInfinite); - } - } - } - } - reacCoef += ktemp; - // System.out.println("irr " + irr); - if (Math.abs(irr) < 1e-3) { - isIrreversible = true; + while (e.hasNext()) { + reaction = e.next(); + ktemp = reaction.getRateFactor(interPhase); + irr = 1.0 / reaction.getK(phase); + // System.out.println("reaction heat " + reaction.getReactionHeat(phase)); + for (int j = 0; j < reaction.getNames().length; j++) { + irr *= Math.pow( + interPhase.getComponent(reaction.getNames()[j]).getx() + * phase.getPhysicalProperties().getDensity() + / phase.getComponent(reaction.getNames()[j]).getMolarMass(), + -reaction.getStocCoefs()[j]); + // System.out.println("reac names " + reaction.getNames()[j]); + // System.out.println("stoc coefs " + reaction.getStocCoefs()[j]); + if (phase.getComponents()[comp].getName().equals(reaction.getNames()[j])) { + for (int k = 0; k < reaction.getNames().length; k++) { + if (reaction.getStocCoefs()[k] * reaction.getStocCoefs()[j] > 0 && !(k == j) + && !(phase.getComponent(reaction.getNames()[k]).getName().equals("water"))) { + exponent = reaction.getStocCoefs()[k] / reaction.getStocCoefs()[j]; + double molConsAint = interPhase.getComponent(comp).getx() + * interPhase.getPhysicalProperties().getDensity() + / phase.getComponent(comp).getMolarMass(); + double molConsB = phase.getComponent(reaction.getNames()[k]).getx() + * phase.getPhysicalProperties().getDensity() + / phase.getComponent(reaction.getNames()[k]).getMolarMass(); + ktemp *= Math.pow(molConsB, exponent); + phiInfinite = Math + .sqrt(phase.getPhysicalProperties().getEffectiveDiffusionCoefficient(comp) + / phase.getPhysicalProperties().getEffectiveDiffusionCoefficient( + phase.getComponent(reaction.getNames()[k]).getComponentNumber())) + + Math + .sqrt(phase.getPhysicalProperties().getEffectiveDiffusionCoefficient( + phase.getComponent(reaction.getNames()[k]).getComponentNumber()) + / phase.getPhysicalProperties().getEffectiveDiffusionCoefficient(comp)) + * molConsB / (exponent * molConsAint); + // System.out.println("reac names " + reaction.getNames()[k]); + // System.out.println("phi inf " + phiInfinite); } + } } - return reacCoef; + } + reacCoef += ktemp; + // System.out.println("irr " + irr); + if (Math.abs(irr) < 1e-3) { + isIrreversible = true; + } } + return reacCoef; + } - /** - *

- * Getter for the field phiInfinite. - *

- * - * @return a double - */ - public double getPhiInfinite() { - return phiInfinite; - } + /** + *

+ * Getter for the field phiInfinite. + *

+ * + * @return a double + */ + public double getPhiInfinite() { + return phiInfinite; + } - /** - *

- * getPseudoFirstOrderCoef. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param interPhase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param comp a int - * @return a double - */ - public double getPseudoFirstOrderCoef(PhaseInterface phase, PhaseInterface interPhase, - int comp) { - return calcReacMatrix(phase, interPhase, comp); - } + /** + *

+ * getPseudoFirstOrderCoef. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param interPhase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param comp a int + * @return a double + */ + public double getPseudoFirstOrderCoef(PhaseInterface phase, PhaseInterface interPhase, int comp) { + return calcReacMatrix(phase, interPhase, comp); + } - /** - * Getter for property isIrreversible. - * - * @return Value of property isIrreversible. - */ - public boolean isIrreversible() { - return isIrreversible; - } + /** + * Getter for property isIrreversible. + * + * @return Value of property isIrreversible. + */ + public boolean isIrreversible() { + return isIrreversible; + } } diff --git a/src/main/java/neqsim/dataPresentation/JFreeChart/graph2b.java b/src/main/java/neqsim/dataPresentation/JFreeChart/graph2b.java index e8dce94c1e..cddbce4d66 100644 --- a/src/main/java/neqsim/dataPresentation/JFreeChart/graph2b.java +++ b/src/main/java/neqsim/dataPresentation/JFreeChart/graph2b.java @@ -3,6 +3,7 @@ * * Created on 17. juni 2000, 17:16 */ + package neqsim.dataPresentation.JFreeChart; import java.awt.Color; @@ -25,308 +26,307 @@ * @version $Id: $Id */ public class graph2b extends javax.swing.JFrame { - private static final long serialVersionUID = 1000; - - XYDataset xyData; - String titl, xaxtitle, yaxtitle; - - /** - *

- * Constructor for graph2b. - *

- */ - public graph2b() { - initComponents(); - pack(); - } - - /** - *

- * Constructor for graph2b. - *

- * - * @param points an array of {@link double} objects - */ - public graph2b(double[][] points) { - String[] seriesNames = new String[points.length]; - for (int i = 0; i < points.length; i++) - seriesNames[i] = ""; - String tit = ""; - String xaxis = ""; - String yaxis = ""; - titl = tit; - xaxtitle = xaxis; - yaxtitle = yaxis; - - XYSeriesCollection seriesCol = new XYSeriesCollection(); - - for (int serLen = 0; serLen < points.length / 2; serLen++) { - XYSeries series = new XYSeries(seriesNames[serLen]); - for (int i = 0; i < points[2 * serLen].length; i++) { - series.add(points[2 * serLen][i], points[2 * serLen + 1][i]); - } - seriesCol.addSeries(series); - } - - chart = ChartFactory.createScatterPlot(tit, xaxtitle, yaxtitle, seriesCol, - org.jfree.chart.plot.PlotOrientation.VERTICAL, true, false, false); - // StandardTitle title = (StandardTitle)chart.getTitle(); - // title.setTitle(titl); - // chart.setBackgroundPaint(java.awt.P)ackgroundPaint(new GradientPaint(0, 0, - // Color.white,0, 1000, Color.white)); - // org.jfree.chart.plot.Plot myPlot = chart.getPlot(); - - chartPanel4 = new ChartPanel(chart); - chartPanel4.setBorder( - BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), - BorderFactory.createLineBorder(Color.darkGray, 1))); - initComponents(); - getContentPane().add(chartPanel4, java.awt.BorderLayout.WEST); - pack(); - } - - /** - *

- * Constructor for graph2b. - *

- * - * @param points an array of {@link double} objects - * @param seriesNames an array of {@link java.lang.String} objects - * @param tit a {@link java.lang.String} object - * @param xaxis a {@link java.lang.String} object - * @param yaxis a {@link java.lang.String} object - */ - public graph2b(double[][] points, String[] seriesNames, String tit, String xaxis, - String yaxis) { - XYSeriesCollection seriesCol = new XYSeriesCollection(); - - for (int serLen = 0; serLen < points.length / 2; serLen++) { - XYSeries series = new XYSeries(seriesNames[serLen]); - for (int i = 0; i < points[2 * serLen].length; i++) { - series.add(points[2 * serLen][i], points[2 * serLen + 1][i]); - // System.out.println(points[2*serLen][i]+" "+points[2*serLen+1][i]); - } - seriesCol.addSeries(series); - } - chart = ChartFactory.createScatterPlot(tit, xaxis, yaxis, seriesCol, - org.jfree.chart.plot.PlotOrientation.VERTICAL, true, false, false); - - // StandardTitle title = (StandardTitle)chart.getTitle(); - // title.setTitle(titl); - chart.setBackgroundPaint(Color.white); - // ChartBackgroundPaint(new GradientPaint(0, 0, Color.white,0, 1000, - // Color.blue)); - // org.jfree.chart.plot.Plot myPlot = chart.getPlot(); - - chartPanel4 = new ChartPanel(chart); - chartPanel4.setBorder( - BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), - BorderFactory.createLineBorder(Color.darkGray, 1))); - chartPanel4.setBackground(Color.white); - initComponents(); - getContentPane().add(chartPanel4, java.awt.BorderLayout.WEST); - pack(); - } - - /** - *

- * Constructor for graph2b. - *

- * - * @param xpoints an array of {@link double} objects - * @param points an array of {@link double} objects - * @param seriesNames an array of {@link java.lang.String} objects - * @param tit a {@link java.lang.String} object - * @param xaxis a {@link java.lang.String} object - * @param yaxis a {@link java.lang.String} object - */ - public graph2b(double[][] xpoints, double[][] points, String[] seriesNames, String tit, - String xaxis, String yaxis) { - XYSeriesCollection seriesCol = new XYSeriesCollection(); - - for (int serLen = 0; serLen < points.length; serLen++) { - XYSeries series = new XYSeries(seriesNames[serLen]); - for (int i = 0; i < points[serLen].length; i++) { - series.add(xpoints[serLen][i], points[serLen][i]); - // System.out.println(points[2*serLen][i]+" "+points[2*serLen+1][i]); - } - seriesCol.addSeries(series); - } - chart = ChartFactory.createScatterPlot(tit, xaxis, yaxis, seriesCol, - org.jfree.chart.plot.PlotOrientation.VERTICAL, true, false, false); - - // StandardTitle title = (StandardTitle)chart.getTitle(); - // title.setTitle(titl); - chart.setBackgroundPaint(Color.white); - // ChartBackgroundPaint(new GradientPaint(0, 0, Color.white,0, 1000, - // Color.blue)); - // org.jfree.chart.plot.Plot myPlot = chart.getPlot(); - - chartPanel4 = new ChartPanel(chart); - chartPanel4.setBorder( - BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), - BorderFactory.createLineBorder(Color.darkGray, 1))); - chartPanel4.setBackground(Color.white); - initComponents(); - getContentPane().add(chartPanel4, java.awt.BorderLayout.WEST); - pack(); - } - - /** - *

- * saveFigure. - *

- * - * @param fileName a {@link java.lang.String} object - */ - public void saveFigure(String fileName) { - try { - System.out.println("start creating png figure..."); - java.io.File temp = new java.io.File(fileName); - org.jfree.chart.ChartUtils.saveChartAsPNG(temp, chart, 500, 500); - System.out.println("figure png created in " - + neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig.png"); - } catch (Exception e) { - e.printStackTrace(); - } + private static final long serialVersionUID = 1000; + + XYDataset xyData; + String titl, xaxtitle, yaxtitle; + + /** + *

+ * Constructor for graph2b. + *

+ */ + public graph2b() { + initComponents(); + pack(); + } + + /** + *

+ * Constructor for graph2b. + *

+ * + * @param points an array of {@link double} objects + */ + public graph2b(double[][] points) { + String[] seriesNames = new String[points.length]; + for (int i = 0; i < points.length; i++) + seriesNames[i] = ""; + String tit = ""; + String xaxis = ""; + String yaxis = ""; + titl = tit; + xaxtitle = xaxis; + yaxtitle = yaxis; + + XYSeriesCollection seriesCol = new XYSeriesCollection(); + + for (int serLen = 0; serLen < points.length / 2; serLen++) { + XYSeries series = new XYSeries(seriesNames[serLen]); + for (int i = 0; i < points[2 * serLen].length; i++) { + series.add(points[2 * serLen][i], points[2 * serLen + 1][i]); + } + seriesCol.addSeries(series); } - /** - *

- * getBufferedImage. - *

- * - * @return a {@link java.awt.image.BufferedImage} object - */ - public BufferedImage getBufferedImage() { - BufferedImage buf = null; - try { - System.out.println("start creating png figure..."); - buf = chart.createBufferedImage(640, 400, null); - } catch (Exception e) { - e.printStackTrace(); - } - return buf; - } - - /** - * This method is called from within the constructor to initialize the form. WARNING: Do NOT - * modify this code. The content of this method is always regenerated by the FormEditor. - */ - private void initComponents() {// GEN-BEGIN:initComponents - jTextPane1 = new javax.swing.JTextPane(); - jPanel1 = new javax.swing.JPanel(); - - addWindowListener(new java.awt.event.WindowAdapter() { - @Override - public void windowClosing(java.awt.event.WindowEvent evt) { - exitForm(evt); - } - - @Override - public void windowClosed(java.awt.event.WindowEvent evt) { - exit(evt); - } - }); - - jTextPane1.setFont(new java.awt.Font("Arial", 1, 16)); - jTextPane1.setText("2D-plot"); - jTextPane1.setSelectedTextColor(java.awt.Color.red); - getContentPane().add(jTextPane1, java.awt.BorderLayout.NORTH); - - getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); - }// GEN-END:initComponents - - private void exit(java.awt.event.WindowEvent evt) {// GEN-FIRST:event_exit - // Add your handling code here: - }// GEN-LAST:event_exit - - private void buttonclick(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_buttonclick - // Add your handling code here: - this.setVisible(false); - }// GEN-LAST:event_buttonclick - - /** - *

- * createCategoryDataSource. - *

- * - * @return a {@link org.jfree.data.category.CategoryDataset} object - */ - public CategoryDataset createCategoryDataSource() { - /* - * Number[][] data = new Integer[][] { { Integer.valueOf(10), Integer.valueOf(4), - * Integer.valueOf(15), Integer.valueOf(14) }, { Integer.valueOf(5), Integer.valueOf(7), - * Integer.valueOf(14), Integer.valueOf(3) }, { Integer.valueOf(6), Integer.valueOf(17), - * Integer.valueOf(12), Integer.valueOf(7) }, { Integer.valueOf(7), Integer.valueOf(15), - * Integer.valueOf(11), Integer.valueOf(0) }, { Integer.valueOf(8), Integer.valueOf(6), - * Integer.valueOf(10), Integer.valueOf(9) }, { Integer.valueOf(9), Integer.valueOf(8), - * Integer.valueOf(8), Integer.valueOf(6) }, { Integer.valueOf(10), Integer.valueOf(9), - * Integer.valueOf(7), Integer.valueOf(7) }, { Integer.valueOf(11), Integer.valueOf(13), - * Integer.valueOf(9), Integer.valueOf(9) }, { Integer.valueOf(3), Integer.valueOf(7), - * Integer.valueOf(11), Integer.valueOf(10) } }; - */ - return null;// new DefaultCategoryDataset(data); + chart = ChartFactory.createScatterPlot(tit, xaxtitle, yaxtitle, seriesCol, + org.jfree.chart.plot.PlotOrientation.VERTICAL, true, false, false); + // StandardTitle title = (StandardTitle)chart.getTitle(); + // title.setTitle(titl); + // chart.setBackgroundPaint(java.awt.P)ackgroundPaint(new GradientPaint(0, 0, + // Color.white,0, 1000, Color.white)); + // org.jfree.chart.plot.Plot myPlot = chart.getPlot(); + + chartPanel4 = new ChartPanel(chart); + chartPanel4 + .setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), + BorderFactory.createLineBorder(Color.darkGray, 1))); + initComponents(); + getContentPane().add(chartPanel4, java.awt.BorderLayout.WEST); + pack(); + } + + /** + *

+ * Constructor for graph2b. + *

+ * + * @param points an array of {@link double} objects + * @param seriesNames an array of {@link java.lang.String} objects + * @param tit a {@link java.lang.String} object + * @param xaxis a {@link java.lang.String} object + * @param yaxis a {@link java.lang.String} object + */ + public graph2b(double[][] points, String[] seriesNames, String tit, String xaxis, String yaxis) { + XYSeriesCollection seriesCol = new XYSeriesCollection(); + + for (int serLen = 0; serLen < points.length / 2; serLen++) { + XYSeries series = new XYSeries(seriesNames[serLen]); + for (int i = 0; i < points[2 * serLen].length; i++) { + series.add(points[2 * serLen][i], points[2 * serLen + 1][i]); + // System.out.println(points[2*serLen][i]+" "+points[2*serLen+1][i]); + } + seriesCol.addSeries(series); } - - private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButton1ActionPerformed - // Add your handling code here: - }// GEN-LAST:event_jButton1ActionPerformed - - /** - * Exit the Application - * - * @param evt The event to exit the form - */ - private void exitForm(java.awt.event.WindowEvent evt) {// GEN-FIRST:event_exitForm - this.removeAll(); - }// GEN-LAST:event_exitForm - - /** - *

- * getChartPanel. - *

- * - * @return a {@link org.jfree.chart.ChartPanel} object - */ - public ChartPanel getChartPanel() { - return chartPanel4; + chart = ChartFactory.createScatterPlot(tit, xaxis, yaxis, seriesCol, + org.jfree.chart.plot.PlotOrientation.VERTICAL, true, false, false); + + // StandardTitle title = (StandardTitle)chart.getTitle(); + // title.setTitle(titl); + chart.setBackgroundPaint(Color.white); + // ChartBackgroundPaint(new GradientPaint(0, 0, Color.white,0, 1000, + // Color.blue)); + // org.jfree.chart.plot.Plot myPlot = chart.getPlot(); + + chartPanel4 = new ChartPanel(chart); + chartPanel4 + .setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), + BorderFactory.createLineBorder(Color.darkGray, 1))); + chartPanel4.setBackground(Color.white); + initComponents(); + getContentPane().add(chartPanel4, java.awt.BorderLayout.WEST); + pack(); + } + + /** + *

+ * Constructor for graph2b. + *

+ * + * @param xpoints an array of {@link double} objects + * @param points an array of {@link double} objects + * @param seriesNames an array of {@link java.lang.String} objects + * @param tit a {@link java.lang.String} object + * @param xaxis a {@link java.lang.String} object + * @param yaxis a {@link java.lang.String} object + */ + public graph2b(double[][] xpoints, double[][] points, String[] seriesNames, String tit, + String xaxis, String yaxis) { + XYSeriesCollection seriesCol = new XYSeriesCollection(); + + for (int serLen = 0; serLen < points.length; serLen++) { + XYSeries series = new XYSeries(seriesNames[serLen]); + for (int i = 0; i < points[serLen].length; i++) { + series.add(xpoints[serLen][i], points[serLen][i]); + // System.out.println(points[2*serLen][i]+" "+points[2*serLen+1][i]); + } + seriesCol.addSeries(series); } - - /** - *

- * main. - *

- * - * @param args the command line arguments - */ - public static void main(String args[]) { - new graph2b().setVisible(true); + chart = ChartFactory.createScatterPlot(tit, xaxis, yaxis, seriesCol, + org.jfree.chart.plot.PlotOrientation.VERTICAL, true, false, false); + + // StandardTitle title = (StandardTitle)chart.getTitle(); + // title.setTitle(titl); + chart.setBackgroundPaint(Color.white); + // ChartBackgroundPaint(new GradientPaint(0, 0, Color.white,0, 1000, + // Color.blue)); + // org.jfree.chart.plot.Plot myPlot = chart.getPlot(); + + chartPanel4 = new ChartPanel(chart); + chartPanel4 + .setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), + BorderFactory.createLineBorder(Color.darkGray, 1))); + chartPanel4.setBackground(Color.white); + initComponents(); + getContentPane().add(chartPanel4, java.awt.BorderLayout.WEST); + pack(); + } + + /** + *

+ * saveFigure. + *

+ * + * @param fileName a {@link java.lang.String} object + */ + public void saveFigure(String fileName) { + try { + System.out.println("start creating png figure..."); + java.io.File temp = new java.io.File(fileName); + org.jfree.chart.ChartUtils.saveChartAsPNG(temp, chart, 500, 500); + System.out.println("figure png created in " + neqsim.util.util.FileSystemSettings.tempDir + + "NeqSimTempFig.png"); + } catch (Exception e) { + e.printStackTrace(); } - - /** - * Getter for property chart. - * - * @return Value of property chart. - */ - public JFreeChart getChart() { - return chart; + } + + /** + *

+ * getBufferedImage. + *

+ * + * @return a {@link java.awt.image.BufferedImage} object + */ + public BufferedImage getBufferedImage() { + BufferedImage buf = null; + try { + System.out.println("start creating png figure..."); + buf = chart.createBufferedImage(640, 400, null); + } catch (Exception e) { + e.printStackTrace(); } - - /** - * Setter for property chart. - * - * @param chart New value of property chart. + return buf; + } + + /** + * This method is called from within the constructor to initialize the form. WARNING: Do NOT + * modify this code. The content of this method is always regenerated by the FormEditor. + */ + private void initComponents() {// GEN-BEGIN:initComponents + jTextPane1 = new javax.swing.JTextPane(); + jPanel1 = new javax.swing.JPanel(); + + addWindowListener(new java.awt.event.WindowAdapter() { + @Override + public void windowClosing(java.awt.event.WindowEvent evt) { + exitForm(evt); + } + + @Override + public void windowClosed(java.awt.event.WindowEvent evt) { + exit(evt); + } + }); + + jTextPane1.setFont(new java.awt.Font("Arial", 1, 16)); + jTextPane1.setText("2D-plot"); + jTextPane1.setSelectedTextColor(java.awt.Color.red); + getContentPane().add(jTextPane1, java.awt.BorderLayout.NORTH); + + getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); + }// GEN-END:initComponents + + private void exit(java.awt.event.WindowEvent evt) {// GEN-FIRST:event_exit + // Add your handling code here: + }// GEN-LAST:event_exit + + private void buttonclick(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_buttonclick + // Add your handling code here: + this.setVisible(false); + }// GEN-LAST:event_buttonclick + + /** + *

+ * createCategoryDataSource. + *

+ * + * @return a {@link org.jfree.data.category.CategoryDataset} object + */ + public CategoryDataset createCategoryDataSource() { + /* + * Number[][] data = new Integer[][] { { Integer.valueOf(10), Integer.valueOf(4), + * Integer.valueOf(15), Integer.valueOf(14) }, { Integer.valueOf(5), Integer.valueOf(7), + * Integer.valueOf(14), Integer.valueOf(3) }, { Integer.valueOf(6), Integer.valueOf(17), + * Integer.valueOf(12), Integer.valueOf(7) }, { Integer.valueOf(7), Integer.valueOf(15), + * Integer.valueOf(11), Integer.valueOf(0) }, { Integer.valueOf(8), Integer.valueOf(6), + * Integer.valueOf(10), Integer.valueOf(9) }, { Integer.valueOf(9), Integer.valueOf(8), + * Integer.valueOf(8), Integer.valueOf(6) }, { Integer.valueOf(10), Integer.valueOf(9), + * Integer.valueOf(7), Integer.valueOf(7) }, { Integer.valueOf(11), Integer.valueOf(13), + * Integer.valueOf(9), Integer.valueOf(9) }, { Integer.valueOf(3), Integer.valueOf(7), + * Integer.valueOf(11), Integer.valueOf(10) } }; */ - public void setChart(JFreeChart chart) { - this.chart = chart; - } - - private CategoryDataset categoryData; - private JFreeChart chart; - private ChartPanel chartPanel4; - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JTextPane jTextPane1; - private javax.swing.JPanel jPanel1; - // End of variables declaration//GEN-END:variables + return null;// new DefaultCategoryDataset(data); + } + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButton1ActionPerformed + // Add your handling code here: + }// GEN-LAST:event_jButton1ActionPerformed + + /** + * Exit the Application + * + * @param evt The event to exit the form + */ + private void exitForm(java.awt.event.WindowEvent evt) {// GEN-FIRST:event_exitForm + this.removeAll(); + }// GEN-LAST:event_exitForm + + /** + *

+ * getChartPanel. + *

+ * + * @return a {@link org.jfree.chart.ChartPanel} object + */ + public ChartPanel getChartPanel() { + return chartPanel4; + } + + /** + *

+ * main. + *

+ * + * @param args the command line arguments + */ + public static void main(String args[]) { + new graph2b().setVisible(true); + } + + /** + * Getter for property chart. + * + * @return Value of property chart. + */ + public JFreeChart getChart() { + return chart; + } + + /** + * Setter for property chart. + * + * @param chart New value of property chart. + */ + public void setChart(JFreeChart chart) { + this.chart = chart; + } + + private CategoryDataset categoryData; + private JFreeChart chart; + private ChartPanel chartPanel4; + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JTextPane jTextPane1; + private javax.swing.JPanel jPanel1; + // End of variables declaration//GEN-END:variables } diff --git a/src/main/java/neqsim/dataPresentation/SampleXYDataSource.java b/src/main/java/neqsim/dataPresentation/SampleXYDataSource.java index 7415371411..d3f36ad31d 100644 --- a/src/main/java/neqsim/dataPresentation/SampleXYDataSource.java +++ b/src/main/java/neqsim/dataPresentation/SampleXYDataSource.java @@ -14,6 +14,7 @@ * not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307, USA. */ + package neqsim.dataPresentation; /** @@ -26,93 +27,93 @@ * @version $Id: $Id */ public class SampleXYDataSource { - double[][] points; - int numberOfSeries; - int[] items = new int[10]; - String[] seriesName; - - /** - * Default constructor. - */ - public SampleXYDataSource() { - // items=0; - } + double[][] points; + int numberOfSeries; + int[] items = new int[10]; + String[] seriesName; - /** - *

- * Constructor for SampleXYDataSource. - *

- * - * @param p an array of {@link double} objects - * @param name an array of {@link java.lang.String} objects - * @param title a {@link java.lang.String} object - * @param xaxis a {@link java.lang.String} object - * @param yaxsis a {@link java.lang.String} object - */ - public SampleXYDataSource(double[][] p, String[] name, String title, String xaxis, - String yaxsis) { - // items = p[0].length; - numberOfSeries = p.length / 2; + /** + * Default constructor. + */ + public SampleXYDataSource() { + // items=0; + } - for (int i = 0; i < numberOfSeries; i++) { - items[i] = p[i * 2].length; + /** + *

+ * Constructor for SampleXYDataSource. + *

+ * + * @param p an array of {@link double} objects + * @param name an array of {@link java.lang.String} objects + * @param title a {@link java.lang.String} object + * @param xaxis a {@link java.lang.String} object + * @param yaxsis a {@link java.lang.String} object + */ + public SampleXYDataSource(double[][] p, String[] name, String title, String xaxis, + String yaxsis) { + // items = p[0].length; + numberOfSeries = p.length / 2; - System.out.println("items =" + items[i]); - } + for (int i = 0; i < numberOfSeries; i++) { + items[i] = p[i * 2].length; - System.out.println("series =" + numberOfSeries); - seriesName = name; - points = p; + System.out.println("items =" + items[i]); } - /** - * Returns the x-value for the specified series and item. Series are numbered 0, 1, ... - * - * @param series The index (zero-based) of the series; - * @param item The index (zero-based) of the required item; - * @return The x-value for the specified series and item. - */ - public Number getXValue(int series, int item) { - return (Double.valueOf(points[2 * series][item])); - } + System.out.println("series =" + numberOfSeries); + seriesName = name; + points = p; + } - /** - * Returns the y-value for the specified series and item. Series are numbered 0, 1, ... - * - * @param series The index (zero-based) of the series; - * @param item The index (zero-based) of the required item; - * @return The y-value for the specified series and item. - */ - public Number getYValue(int series, int item) { - return (Double.valueOf(points[(series * 2 + 1)][item])); - } + /** + * Returns the x-value for the specified series and item. Series are numbered 0, 1, ... + * + * @param series The index (zero-based) of the series; + * @param item The index (zero-based) of the required item; + * @return The x-value for the specified series and item. + */ + public Number getXValue(int series, int item) { + return (Double.valueOf(points[2 * series][item])); + } - /** - * Returns the number of series in the data source. - * - * @return The number of series in the data source. - */ - public int getSeriesCount() { - return numberOfSeries; - } + /** + * Returns the y-value for the specified series and item. Series are numbered 0, 1, ... + * + * @param series The index (zero-based) of the series; + * @param item The index (zero-based) of the required item; + * @return The y-value for the specified series and item. + */ + public Number getYValue(int series, int item) { + return (Double.valueOf(points[(series * 2 + 1)][item])); + } - /** - * Returns the name of the series. - * - * @param series The index (zero-based) of the series; - * @return The name of the series. - */ - public String getSeriesName(int series) { - return seriesName[series]; - } + /** + * Returns the number of series in the data source. + * + * @return The number of series in the data source. + */ + public int getSeriesCount() { + return numberOfSeries; + } - /** - * Returns the number of items in the specified series. - * - * @param series The index (zero-based) of the series; - * @return The number of items in the specified series. - */ - public int getItemCount(int series) { - return items[series]; - } + /** + * Returns the name of the series. + * + * @param series The index (zero-based) of the series; + * @return The name of the series. + */ + public String getSeriesName(int series) { + return seriesName[series]; + } + + /** + * Returns the number of items in the specified series. + * + * @param series The index (zero-based) of the series; + * @return The number of items in the specified series. + */ + public int getItemCount(int series) { + return items[series]; + } } diff --git a/src/main/java/neqsim/dataPresentation/userInterface.java b/src/main/java/neqsim/dataPresentation/userInterface.java index 7a4e514aa5..e3a8a71000 100644 --- a/src/main/java/neqsim/dataPresentation/userInterface.java +++ b/src/main/java/neqsim/dataPresentation/userInterface.java @@ -3,6 +3,7 @@ * * Created on 15. juni 2000, 18:28 */ + package neqsim.dataPresentation; /** @@ -14,12 +15,12 @@ * @version $Id: $Id */ public class userInterface implements java.io.Serializable { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for userInterface. - *

- */ - public userInterface() {} + /** + *

+ * Constructor for userInterface. + *

+ */ + public userInterface() {} } diff --git a/src/main/java/neqsim/fluidMechanics/flowLeg/FlowLeg.java b/src/main/java/neqsim/fluidMechanics/flowLeg/FlowLeg.java index 4b6835e93a..bd2fefb4ef 100644 --- a/src/main/java/neqsim/fluidMechanics/flowLeg/FlowLeg.java +++ b/src/main/java/neqsim/fluidMechanics/flowLeg/FlowLeg.java @@ -3,6 +3,7 @@ * * Created on 8. desember 2000, 19:30 */ + package neqsim.fluidMechanics.flowLeg; import neqsim.fluidMechanics.flowNode.FlowNodeInterface; @@ -19,184 +20,182 @@ * @version $Id: $Id */ public abstract class FlowLeg implements FlowLegInterface, java.io.Serializable { - private static final long serialVersionUID = 1000; - - protected FlowNodeInterface[] flowNode; - protected int numberOfNodes = 0; - protected double startLongitudionalCoordinate, endLongitudionalCoordinate; - protected double startHeightCoordinate, endHeightCoordinate; - protected double startOuterTemperature, endOuterTemperature, startOuterHeatTransferCoefficient, - endOuterHeatTransferCoefficient, startWallHeatTransferCOefficients, - endWallHeatTransferCOefficients; - protected SystemInterface thermoSystem; - protected GeometryDefinitionInterface equipmentGeometry; - protected double heightChangePerNode = 0, longitudionalChangePerNode = 0, - temperatureChangePerNode = 0; - protected FlowNodeSelector nodeSelector = new FlowNodeSelector(); - - /** - *

- * Constructor for FlowLeg. - *

- */ - public FlowLeg() { - flowNode = new FlowNodeInterface[this.getNumberOfNodes()]; - } - - /** {@inheritDoc} */ - @Override - public void createFlowNodes() { - temperatureChangePerNode = - (endOuterTemperature - startOuterTemperature) / (1.0 * getNumberOfNodes()); - longitudionalChangePerNode = (endLongitudionalCoordinate - startLongitudionalCoordinate) - / (1.0 * getNumberOfNodes()); - heightChangePerNode = - (endHeightCoordinate - startHeightCoordinate) / (1.0 * getNumberOfNodes()); - - flowNode[0].setDistanceToCenterOfNode( - this.startLongitudionalCoordinate + 0.5 * longitudionalChangePerNode); - flowNode[0].setLengthOfNode(longitudionalChangePerNode); - flowNode[0].setVerticalPositionOfNode(startHeightCoordinate + 0.5 * heightChangePerNode); - flowNode[0].getGeometry().getSurroundingEnvironment() - .setTemperature(startOuterTemperature + 0.5 * temperatureChangePerNode); - flowNode[0].init(); - - for (int i = 0; i < getNumberOfNodes() - 1; i++) { - flowNode[i + 1] = flowNode[i].getNextNode(); - flowNode[i + 1].setDistanceToCenterOfNode( - flowNode[0].getDistanceToCenterOfNode() + (i + 1) * longitudionalChangePerNode); - flowNode[i + 1].setVerticalPositionOfNode( - flowNode[0].getVerticalPositionOfNode() + (i + 1) * heightChangePerNode); - flowNode[i + 1].setLengthOfNode(longitudionalChangePerNode); - flowNode[i].getGeometry().getSurroundingEnvironment() - .setTemperature(startOuterTemperature + (i + 1) * temperatureChangePerNode); - flowNode[i].getGeometry().getSurroundingEnvironment() - .setHeatTransferCoefficient(startOuterHeatTransferCoefficient + (i + 1) * 1.0 - / (getNumberOfNodes() * 1.0) * (endOuterHeatTransferCoefficient - - startOuterHeatTransferCoefficient)); - flowNode[i].getGeometry() - .setWallHeatTransferCoefficient(startWallHeatTransferCOefficients + (i + 1) - * 1.0 / (getNumberOfNodes() * 1.0) * (endWallHeatTransferCOefficients - - startWallHeatTransferCOefficients)); - flowNode[i + 1].init(); - } - } - - /** - *

- * setFlowNodeTypes. - *

- */ - public void setFlowNodeTypes() { - nodeSelector.getFlowNodeType(flowNode); - - for (int i = 0; i < getNumberOfNodes(); i++) { - flowNode[i].setDistanceToCenterOfNode( - flowNode[0].getDistanceToCenterOfNode() + (i) * longitudionalChangePerNode); - flowNode[i].setLengthOfNode(longitudionalChangePerNode); - flowNode[i].setVerticalPositionOfNode( - flowNode[0].getVerticalPositionOfNode() + (i) * heightChangePerNode); - flowNode[i].getGeometry().getSurroundingEnvironment() - .setTemperature(startOuterTemperature + (i) * temperatureChangePerNode); - flowNode[i].init(); - } - } - - /** {@inheritDoc} */ - @Override - public void setFlowPattern(String flowPattern) { - nodeSelector.setFlowPattern(flowNode, flowPattern); - flowNode[0].init(); - flowNode[0].setDistanceToCenterOfNode( - this.startLongitudionalCoordinate + 0.5 * longitudionalChangePerNode); - flowNode[0].setLengthOfNode(longitudionalChangePerNode); - flowNode[0].setVerticalPositionOfNode(startHeightCoordinate + 0.5 * heightChangePerNode); - - for (int i = 0; i < getNumberOfNodes() - 1; i++) { - flowNode[i + 1] = flowNode[i].getNextNode(); - flowNode[i + 1].setDistanceToCenterOfNode( - flowNode[0].getDistanceToCenterOfNode() + (i + 1) * longitudionalChangePerNode); - flowNode[i + 1].setVerticalPositionOfNode( - flowNode[0].getVerticalPositionOfNode() + (i + 1) * heightChangePerNode); - flowNode[i + 1].setLengthOfNode(longitudionalChangePerNode); - flowNode[i].getGeometry().getSurroundingEnvironment() - .setTemperature(startOuterTemperature + (i) * temperatureChangePerNode); - - flowNode[i + 1].init(); - } + private static final long serialVersionUID = 1000; + + protected FlowNodeInterface[] flowNode; + protected int numberOfNodes = 0; + protected double startLongitudionalCoordinate, endLongitudionalCoordinate; + protected double startHeightCoordinate, endHeightCoordinate; + protected double startOuterTemperature, endOuterTemperature, startOuterHeatTransferCoefficient, + endOuterHeatTransferCoefficient, startWallHeatTransferCOefficients, + endWallHeatTransferCOefficients; + protected SystemInterface thermoSystem; + protected GeometryDefinitionInterface equipmentGeometry; + protected double heightChangePerNode = 0, longitudionalChangePerNode = 0, + temperatureChangePerNode = 0; + protected FlowNodeSelector nodeSelector = new FlowNodeSelector(); + + /** + *

+ * Constructor for FlowLeg. + *

+ */ + public FlowLeg() { + flowNode = new FlowNodeInterface[this.getNumberOfNodes()]; + } + + /** {@inheritDoc} */ + @Override + public void createFlowNodes() { + temperatureChangePerNode = + (endOuterTemperature - startOuterTemperature) / (1.0 * getNumberOfNodes()); + longitudionalChangePerNode = + (endLongitudionalCoordinate - startLongitudionalCoordinate) / (1.0 * getNumberOfNodes()); + heightChangePerNode = + (endHeightCoordinate - startHeightCoordinate) / (1.0 * getNumberOfNodes()); + + flowNode[0].setDistanceToCenterOfNode( + this.startLongitudionalCoordinate + 0.5 * longitudionalChangePerNode); + flowNode[0].setLengthOfNode(longitudionalChangePerNode); + flowNode[0].setVerticalPositionOfNode(startHeightCoordinate + 0.5 * heightChangePerNode); + flowNode[0].getGeometry().getSurroundingEnvironment() + .setTemperature(startOuterTemperature + 0.5 * temperatureChangePerNode); + flowNode[0].init(); + + for (int i = 0; i < getNumberOfNodes() - 1; i++) { + flowNode[i + 1] = flowNode[i].getNextNode(); + flowNode[i + 1].setDistanceToCenterOfNode( + flowNode[0].getDistanceToCenterOfNode() + (i + 1) * longitudionalChangePerNode); + flowNode[i + 1].setVerticalPositionOfNode( + flowNode[0].getVerticalPositionOfNode() + (i + 1) * heightChangePerNode); + flowNode[i + 1].setLengthOfNode(longitudionalChangePerNode); + flowNode[i].getGeometry().getSurroundingEnvironment() + .setTemperature(startOuterTemperature + (i + 1) * temperatureChangePerNode); + flowNode[i].getGeometry().getSurroundingEnvironment().setHeatTransferCoefficient( + startOuterHeatTransferCoefficient + (i + 1) * 1.0 / (getNumberOfNodes() * 1.0) + * (endOuterHeatTransferCoefficient - startOuterHeatTransferCoefficient)); + flowNode[i].getGeometry().setWallHeatTransferCoefficient( + startWallHeatTransferCOefficients + (i + 1) * 1.0 / (getNumberOfNodes() * 1.0) + * (endWallHeatTransferCOefficients - startWallHeatTransferCOefficients)); + flowNode[i + 1].init(); } - - /** {@inheritDoc} */ - @Override - public void setThermoSystem(SystemInterface thermoSystem) { - this.thermoSystem = thermoSystem.clone(); - } - - /** {@inheritDoc} */ - @Override - public void setEquipmentGeometry(GeometryDefinitionInterface equipmentGeometry) { - this.equipmentGeometry = equipmentGeometry.clone(); - } - - /** {@inheritDoc} */ - @Override - public void setNumberOfNodes(int numberOfNodes) { - this.numberOfNodes = numberOfNodes; - } - - /** {@inheritDoc} */ - @Override - public int getNumberOfNodes() { - return this.numberOfNodes; + } + + /** + *

+ * setFlowNodeTypes. + *

+ */ + public void setFlowNodeTypes() { + nodeSelector.getFlowNodeType(flowNode); + + for (int i = 0; i < getNumberOfNodes(); i++) { + flowNode[i].setDistanceToCenterOfNode( + flowNode[0].getDistanceToCenterOfNode() + (i) * longitudionalChangePerNode); + flowNode[i].setLengthOfNode(longitudionalChangePerNode); + flowNode[i].setVerticalPositionOfNode( + flowNode[0].getVerticalPositionOfNode() + (i) * heightChangePerNode); + flowNode[i].getGeometry().getSurroundingEnvironment() + .setTemperature(startOuterTemperature + (i) * temperatureChangePerNode); + flowNode[i].init(); } - - /** {@inheritDoc} */ - @Override - public void setHeightCoordinates(double startHeightCoordinate, double endHeightCoordinate) { - this.startHeightCoordinate = startHeightCoordinate; - this.endHeightCoordinate = endHeightCoordinate; - } - - /** {@inheritDoc} */ - @Override - public void setOuterHeatTransferCoefficients(double startHeatTransferCoefficient, - double endHeatTransferCoefficient) { - this.startOuterHeatTransferCoefficient = startHeatTransferCoefficient; - this.endOuterHeatTransferCoefficient = endHeatTransferCoefficient; - } - - /** {@inheritDoc} */ - @Override - public void setWallHeatTransferCoefficients(double startHeatTransferCoefficient, - double endHeatTransferCoefficient) { - this.startWallHeatTransferCOefficients = startHeatTransferCoefficient; - this.endWallHeatTransferCOefficients = endHeatTransferCoefficient; - } - - /** {@inheritDoc} */ - @Override - public void setLongitudionalCoordinates(double startLongitudionalCoordinate, - double endLongitudionalCoordinate) { - this.startLongitudionalCoordinate = startLongitudionalCoordinate; - this.endLongitudionalCoordinate = endLongitudionalCoordinate; - } - - /** {@inheritDoc} */ - @Override - public void setOuterTemperatures(double startTemperature, double endTemperature) { - this.startOuterTemperature = startTemperature; - this.endOuterTemperature = endTemperature; - } - - /** {@inheritDoc} */ - @Override - public FlowNodeInterface[] getFlowNodes() { - return flowNode; - } - - /** {@inheritDoc} */ - @Override - public FlowNodeInterface getNode(int i) { - return flowNode[i]; + } + + /** {@inheritDoc} */ + @Override + public void setFlowPattern(String flowPattern) { + nodeSelector.setFlowPattern(flowNode, flowPattern); + flowNode[0].init(); + flowNode[0].setDistanceToCenterOfNode( + this.startLongitudionalCoordinate + 0.5 * longitudionalChangePerNode); + flowNode[0].setLengthOfNode(longitudionalChangePerNode); + flowNode[0].setVerticalPositionOfNode(startHeightCoordinate + 0.5 * heightChangePerNode); + + for (int i = 0; i < getNumberOfNodes() - 1; i++) { + flowNode[i + 1] = flowNode[i].getNextNode(); + flowNode[i + 1].setDistanceToCenterOfNode( + flowNode[0].getDistanceToCenterOfNode() + (i + 1) * longitudionalChangePerNode); + flowNode[i + 1].setVerticalPositionOfNode( + flowNode[0].getVerticalPositionOfNode() + (i + 1) * heightChangePerNode); + flowNode[i + 1].setLengthOfNode(longitudionalChangePerNode); + flowNode[i].getGeometry().getSurroundingEnvironment() + .setTemperature(startOuterTemperature + (i) * temperatureChangePerNode); + + flowNode[i + 1].init(); } + } + + /** {@inheritDoc} */ + @Override + public void setThermoSystem(SystemInterface thermoSystem) { + this.thermoSystem = thermoSystem.clone(); + } + + /** {@inheritDoc} */ + @Override + public void setEquipmentGeometry(GeometryDefinitionInterface equipmentGeometry) { + this.equipmentGeometry = equipmentGeometry.clone(); + } + + /** {@inheritDoc} */ + @Override + public void setNumberOfNodes(int numberOfNodes) { + this.numberOfNodes = numberOfNodes; + } + + /** {@inheritDoc} */ + @Override + public int getNumberOfNodes() { + return this.numberOfNodes; + } + + /** {@inheritDoc} */ + @Override + public void setHeightCoordinates(double startHeightCoordinate, double endHeightCoordinate) { + this.startHeightCoordinate = startHeightCoordinate; + this.endHeightCoordinate = endHeightCoordinate; + } + + /** {@inheritDoc} */ + @Override + public void setOuterHeatTransferCoefficients(double startHeatTransferCoefficient, + double endHeatTransferCoefficient) { + this.startOuterHeatTransferCoefficient = startHeatTransferCoefficient; + this.endOuterHeatTransferCoefficient = endHeatTransferCoefficient; + } + + /** {@inheritDoc} */ + @Override + public void setWallHeatTransferCoefficients(double startHeatTransferCoefficient, + double endHeatTransferCoefficient) { + this.startWallHeatTransferCOefficients = startHeatTransferCoefficient; + this.endWallHeatTransferCOefficients = endHeatTransferCoefficient; + } + + /** {@inheritDoc} */ + @Override + public void setLongitudionalCoordinates(double startLongitudionalCoordinate, + double endLongitudionalCoordinate) { + this.startLongitudionalCoordinate = startLongitudionalCoordinate; + this.endLongitudionalCoordinate = endLongitudionalCoordinate; + } + + /** {@inheritDoc} */ + @Override + public void setOuterTemperatures(double startTemperature, double endTemperature) { + this.startOuterTemperature = startTemperature; + this.endOuterTemperature = endTemperature; + } + + /** {@inheritDoc} */ + @Override + public FlowNodeInterface[] getFlowNodes() { + return flowNode; + } + + /** {@inheritDoc} */ + @Override + public FlowNodeInterface getNode(int i) { + return flowNode[i]; + } } diff --git a/src/main/java/neqsim/fluidMechanics/flowLeg/FlowLegInterface.java b/src/main/java/neqsim/fluidMechanics/flowLeg/FlowLegInterface.java index 1430dccc9b..9fa1d19ad5 100644 --- a/src/main/java/neqsim/fluidMechanics/flowLeg/FlowLegInterface.java +++ b/src/main/java/neqsim/fluidMechanics/flowLeg/FlowLegInterface.java @@ -3,6 +3,7 @@ * * Created on 11. desember 2000, 17:47 */ + package neqsim.fluidMechanics.flowLeg; import neqsim.fluidMechanics.flowNode.FlowNodeInterface; @@ -18,137 +19,137 @@ * @version $Id: $Id */ public interface FlowLegInterface { - /** - *

- * setThermoSystem. - *

- * - * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - public void setThermoSystem(SystemInterface thermoSystem); - - /** - *

- * setEquipmentGeometry. - *

- * - * @param equipmentGeometry a - * {@link neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface} object - */ - public void setEquipmentGeometry(GeometryDefinitionInterface equipmentGeometry); - - /** - *

- * setNumberOfNodes. - *

- * - * @param numberOfNodes a int - */ - public void setNumberOfNodes(int numberOfNodes); - - /** - *

- * setHeightCoordinates. - *

- * - * @param startHeightCoordinate a double - * @param endHeightCoordinate a double - */ - public void setHeightCoordinates(double startHeightCoordinate, double endHeightCoordinate); - - /** - *

- * setOuterTemperatures. - *

- * - * @param temp1 a double - * @param temp2 a double - */ - public void setOuterTemperatures(double temp1, double temp2); - - /** - *

- * setLongitudionalCoordinates. - *

- * - * @param startLongitudionalCoordinate a double - * @param endLongitudionalCoordinate a double - */ - public void setLongitudionalCoordinates(double startLongitudionalCoordinate, - double endLongitudionalCoordinate); - - /** - *

- * createFlowNodes. - *

- * - * @param node a {@link neqsim.fluidMechanics.flowNode.FlowNodeInterface} object - */ - public void createFlowNodes(FlowNodeInterface node); - - /** - *

- * createFlowNodes. - *

- */ - public void createFlowNodes(); - - /** - *

- * getNumberOfNodes. - *

- * - * @return a int - */ - public int getNumberOfNodes(); - - /** - *

- * getNode. - *

- * - * @param i a int - * @return a {@link neqsim.fluidMechanics.flowNode.FlowNodeInterface} object - */ - public FlowNodeInterface getNode(int i); - - /** - *

- * getFlowNodes. - *

- * - * @return an array of {@link neqsim.fluidMechanics.flowNode.FlowNodeInterface} objects - */ - public FlowNodeInterface[] getFlowNodes(); - - /** - *

- * setOuterHeatTransferCoefficients. - *

- * - * @param startHeatTransferCoefficient a double - * @param endHeatTransferCoefficient a double - */ - public void setOuterHeatTransferCoefficients(double startHeatTransferCoefficient, - double endHeatTransferCoefficient); - - /** - *

- * setWallHeatTransferCoefficients. - *

- * - * @param startHeatTransferCoefficient a double - * @param endHeatTransferCoefficient a double - */ - public void setWallHeatTransferCoefficients(double startHeatTransferCoefficient, - double endHeatTransferCoefficient); - - /** - *

- * setFlowPattern. - *

- * - * @param flowPattern a {@link java.lang.String} object - */ - public void setFlowPattern(String flowPattern); + /** + *

+ * setThermoSystem. + *

+ * + * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object + */ + public void setThermoSystem(SystemInterface thermoSystem); + + /** + *

+ * setEquipmentGeometry. + *

+ * + * @param equipmentGeometry a + * {@link neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface} object + */ + public void setEquipmentGeometry(GeometryDefinitionInterface equipmentGeometry); + + /** + *

+ * setNumberOfNodes. + *

+ * + * @param numberOfNodes a int + */ + public void setNumberOfNodes(int numberOfNodes); + + /** + *

+ * setHeightCoordinates. + *

+ * + * @param startHeightCoordinate a double + * @param endHeightCoordinate a double + */ + public void setHeightCoordinates(double startHeightCoordinate, double endHeightCoordinate); + + /** + *

+ * setOuterTemperatures. + *

+ * + * @param temp1 a double + * @param temp2 a double + */ + public void setOuterTemperatures(double temp1, double temp2); + + /** + *

+ * setLongitudionalCoordinates. + *

+ * + * @param startLongitudionalCoordinate a double + * @param endLongitudionalCoordinate a double + */ + public void setLongitudionalCoordinates(double startLongitudionalCoordinate, + double endLongitudionalCoordinate); + + /** + *

+ * createFlowNodes. + *

+ * + * @param node a {@link neqsim.fluidMechanics.flowNode.FlowNodeInterface} object + */ + public void createFlowNodes(FlowNodeInterface node); + + /** + *

+ * createFlowNodes. + *

+ */ + public void createFlowNodes(); + + /** + *

+ * getNumberOfNodes. + *

+ * + * @return a int + */ + public int getNumberOfNodes(); + + /** + *

+ * getNode. + *

+ * + * @param i a int + * @return a {@link neqsim.fluidMechanics.flowNode.FlowNodeInterface} object + */ + public FlowNodeInterface getNode(int i); + + /** + *

+ * getFlowNodes. + *

+ * + * @return an array of {@link neqsim.fluidMechanics.flowNode.FlowNodeInterface} objects + */ + public FlowNodeInterface[] getFlowNodes(); + + /** + *

+ * setOuterHeatTransferCoefficients. + *

+ * + * @param startHeatTransferCoefficient a double + * @param endHeatTransferCoefficient a double + */ + public void setOuterHeatTransferCoefficients(double startHeatTransferCoefficient, + double endHeatTransferCoefficient); + + /** + *

+ * setWallHeatTransferCoefficients. + *

+ * + * @param startHeatTransferCoefficient a double + * @param endHeatTransferCoefficient a double + */ + public void setWallHeatTransferCoefficients(double startHeatTransferCoefficient, + double endHeatTransferCoefficient); + + /** + *

+ * setFlowPattern. + *

+ * + * @param flowPattern a {@link java.lang.String} object + */ + public void setFlowPattern(String flowPattern); } diff --git a/src/main/java/neqsim/fluidMechanics/flowLeg/pipeLeg/PipeLeg.java b/src/main/java/neqsim/fluidMechanics/flowLeg/pipeLeg/PipeLeg.java index e2c9a6d47a..555d5619ba 100644 --- a/src/main/java/neqsim/fluidMechanics/flowLeg/pipeLeg/PipeLeg.java +++ b/src/main/java/neqsim/fluidMechanics/flowLeg/pipeLeg/PipeLeg.java @@ -3,6 +3,7 @@ * * Created on 8. desember 2000, 19:32 */ + package neqsim.fluidMechanics.flowLeg.pipeLeg; import neqsim.fluidMechanics.flowLeg.FlowLeg; @@ -17,40 +18,40 @@ * @version $Id: $Id */ public class PipeLeg extends FlowLeg { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - // FlowNodeInterface[] node; + // FlowNodeInterface[] node; - /** - *

- * Constructor for PipeLeg. - *

- */ - public PipeLeg() { - super(); - } + /** + *

+ * Constructor for PipeLeg. + *

+ */ + public PipeLeg() { + super(); + } - /** {@inheritDoc} */ - @Override - public void createFlowNodes(FlowNodeInterface initNode) { - heightChangePerNode = - (this.endHeightCoordinate - this.startHeightCoordinate) / this.getNumberOfNodes(); - longitudionalChangePerNode = - (this.endLongitudionalCoordinate - this.startLongitudionalCoordinate) - / (this.getNumberOfNodes() * 1.0); - temperatureChangePerNode = (this.endOuterTemperature - this.startOuterTemperature) - / (this.getNumberOfNodes() * 1.0); + /** {@inheritDoc} */ + @Override + public void createFlowNodes(FlowNodeInterface initNode) { + heightChangePerNode = + (this.endHeightCoordinate - this.startHeightCoordinate) / this.getNumberOfNodes(); + longitudionalChangePerNode = + (this.endLongitudionalCoordinate - this.startLongitudionalCoordinate) + / (this.getNumberOfNodes() * 1.0); + temperatureChangePerNode = + (this.endOuterTemperature - this.startOuterTemperature) / (this.getNumberOfNodes() * 1.0); - flowNode = new FlowNodeInterface[this.getNumberOfNodes()]; - this.flowNode[0] = initNode.getNextNode(); - this.equipmentGeometry.setNodeLength(longitudionalChangePerNode); - this.equipmentGeometry.init(); - flowNode[0].setGeometryDefinitionInterface(this.equipmentGeometry); - // flowNode = new onePhasePipeFlowNode[this.getNumberOfNodes()]; - // flowNode[0] = new onePhasePipeFlowNode(thermoSystem, this.equipmentGeometry, - // inletTotalNormalVolumetricFlowRate); - // flowNode[0] = new AnnularFlow(thermoSystem, this.equipmentGeometry, - // inletTotalNormalVolumetricFlowRate); - super.createFlowNodes(); - } + flowNode = new FlowNodeInterface[this.getNumberOfNodes()]; + this.flowNode[0] = initNode.getNextNode(); + this.equipmentGeometry.setNodeLength(longitudionalChangePerNode); + this.equipmentGeometry.init(); + flowNode[0].setGeometryDefinitionInterface(this.equipmentGeometry); + // flowNode = new onePhasePipeFlowNode[this.getNumberOfNodes()]; + // flowNode[0] = new onePhasePipeFlowNode(thermoSystem, this.equipmentGeometry, + // inletTotalNormalVolumetricFlowRate); + // flowNode[0] = new AnnularFlow(thermoSystem, this.equipmentGeometry, + // inletTotalNormalVolumetricFlowRate); + super.createFlowNodes(); + } } diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/FluidBoundaryInterface.java b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/FluidBoundaryInterface.java index 9e254457a2..ef8788fd52 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/FluidBoundaryInterface.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/FluidBoundaryInterface.java @@ -3,6 +3,7 @@ * * Created on 11. desember 2000, 17:17 */ + package neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc; import Jama.Matrix; @@ -19,257 +20,257 @@ * @version $Id: $Id */ public interface FluidBoundaryInterface extends Cloneable { - /** - *

- * getInterphaseSystem. - *

- * - * @return a {@link neqsim.thermo.system.SystemInterface} object - */ - public SystemInterface getInterphaseSystem(); + /** + *

+ * getInterphaseSystem. + *

+ * + * @return a {@link neqsim.thermo.system.SystemInterface} object + */ + public SystemInterface getInterphaseSystem(); - /** - *

- * setInterphaseSystem. - *

- * - * @param interphaseSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - public void setInterphaseSystem(SystemInterface interphaseSystem); + /** + *

+ * setInterphaseSystem. + *

+ * + * @param interphaseSystem a {@link neqsim.thermo.system.SystemInterface} object + */ + public void setInterphaseSystem(SystemInterface interphaseSystem); - /** - *

- * solve. - *

- */ - public void solve(); + /** + *

+ * solve. + *

+ */ + public void solve(); - /** - *

- * massTransSolve. - *

- */ - public void massTransSolve(); + /** + *

+ * massTransSolve. + *

+ */ + public void massTransSolve(); - /** - *

- * write. - *

- * - * @param name a {@link java.lang.String} object - * @param filename a {@link java.lang.String} object - * @param newfile a boolean - */ - public void write(String name, String filename, boolean newfile); + /** + *

+ * write. + *

+ * + * @param name a {@link java.lang.String} object + * @param filename a {@link java.lang.String} object + * @param newfile a boolean + */ + public void write(String name, String filename, boolean newfile); - /** - *

- * display. - *

- * - * @param name a {@link java.lang.String} object - */ - public void display(String name); + /** + *

+ * display. + *

+ * + * @param name a {@link java.lang.String} object + */ + public void display(String name); - /** - *

- * heatTransSolve. - *

- */ - public void heatTransSolve(); + /** + *

+ * heatTransSolve. + *

+ */ + public void heatTransSolve(); - /** - *

- * setEnhancementType. - *

- * - * @param type a int - */ - public void setEnhancementType(int type); + /** + *

+ * setEnhancementType. + *

+ * + * @param type a int + */ + public void setEnhancementType(int type); - /** - *

- * getEnhancementFactor. - *

- * - * @return a - * {@link neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.nonEquilibriumFluidBoundary.filmModelBoundary.reactiveFilmModel.enhancementFactor.EnhancementFactor} - * object - */ - public EnhancementFactor getEnhancementFactor(); + /** + *

+ * getEnhancementFactor. + *

+ * + * @return a + * {@link neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.nonEquilibriumFluidBoundary.filmModelBoundary.reactiveFilmModel.enhancementFactor.EnhancementFactor} + * object + */ + public EnhancementFactor getEnhancementFactor(); - /** - *

- * getInterphaseHeatFlux. - *

- * - * @param phase a int - * @return a double - */ - public double getInterphaseHeatFlux(int phase); + /** + *

+ * getInterphaseHeatFlux. + *

+ * + * @param phase a int + * @return a double + */ + public double getInterphaseHeatFlux(int phase); - /** - *

- * getBulkSystemOpertions. - *

- * - * @return a {@link neqsim.thermodynamicOperations.ThermodynamicOperations} object - */ - public ThermodynamicOperations getBulkSystemOpertions(); + /** + *

+ * getBulkSystemOpertions. + *

+ * + * @return a {@link neqsim.thermodynamicOperations.ThermodynamicOperations} object + */ + public ThermodynamicOperations getBulkSystemOpertions(); - /** - *

- * calcFluxes. - *

- * - * @return an array of {@link double} objects - */ - public double[] calcFluxes(); + /** + *

+ * calcFluxes. + *

+ * + * @return an array of {@link double} objects + */ + public double[] calcFluxes(); - /** - *

- * getMassTransferCoefficientMatrix. - *

- * - * @return an array of {@link Jama.Matrix} objects - */ - public Matrix[] getMassTransferCoefficientMatrix(); + /** + *

+ * getMassTransferCoefficientMatrix. + *

+ * + * @return an array of {@link Jama.Matrix} objects + */ + public Matrix[] getMassTransferCoefficientMatrix(); - /** - *

- * getBinaryMassTransferCoefficient. - *

- * - * @param phase a int - * @param i a int - * @param j a int - * @return a double - */ - public double getBinaryMassTransferCoefficient(int phase, int i, int j); + /** + *

+ * getBinaryMassTransferCoefficient. + *

+ * + * @param phase a int + * @param i a int + * @param j a int + * @return a double + */ + public double getBinaryMassTransferCoefficient(int phase, int i, int j); - /** - *

- * getBulkSystem. - *

- * - * @return a {@link neqsim.thermo.system.SystemInterface} object - */ - public SystemInterface getBulkSystem(); + /** + *

+ * getBulkSystem. + *

+ * + * @return a {@link neqsim.thermo.system.SystemInterface} object + */ + public SystemInterface getBulkSystem(); - /** - *

- * isHeatTransferCalc. - *

- * - * @return a boolean - */ - public boolean isHeatTransferCalc(); + /** + *

+ * isHeatTransferCalc. + *

+ * + * @return a boolean + */ + public boolean isHeatTransferCalc(); - /** - *

- * setHeatTransferCalc. - *

- * - * @param heatTransferCalc a boolean - */ - public void setHeatTransferCalc(boolean heatTransferCalc); + /** + *

+ * setHeatTransferCalc. + *

+ * + * @param heatTransferCalc a boolean + */ + public void setHeatTransferCalc(boolean heatTransferCalc); - /** - *

- * setMassTransferCalc. - *

- * - * @param heatTransferCalc a boolean - */ - public void setMassTransferCalc(boolean heatTransferCalc); + /** + *

+ * setMassTransferCalc. + *

+ * + * @param heatTransferCalc a boolean + */ + public void setMassTransferCalc(boolean heatTransferCalc); - /** - *

- * getInterphaseMolarFlux. - *

- * - * @param component a int - * @return a double - */ - public double getInterphaseMolarFlux(int component); + /** + *

+ * getInterphaseMolarFlux. + *

+ * + * @param component a int + * @return a double + */ + public double getInterphaseMolarFlux(int component); - /** - *

- * getEffectiveMassTransferCoefficient. - *

- * - * @param phase a int - * @param i a int - * @return a double - */ - public double getEffectiveMassTransferCoefficient(int phase, int i); + /** + *

+ * getEffectiveMassTransferCoefficient. + *

+ * + * @param phase a int + * @param i a int + * @return a double + */ + public double getEffectiveMassTransferCoefficient(int phase, int i); - /** - *

- * clone. - *

- * - * @return a - * {@link neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.FluidBoundaryInterface} - * object - */ - public FluidBoundaryInterface clone(); + /** + *

+ * clone. + *

+ * + * @return a + * {@link neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.FluidBoundaryInterface} + * object + */ + public FluidBoundaryInterface clone(); - /** - *

- * useThermodynamicCorrections. - *

- * - * @param phase a int - * @return a boolean - */ - public boolean useThermodynamicCorrections(int phase); + /** + *

+ * useThermodynamicCorrections. + *

+ * + * @param phase a int + * @return a boolean + */ + public boolean useThermodynamicCorrections(int phase); - /** - *

- * useThermodynamicCorrections. - *

- * - * @param thermodynamicCorrections a boolean - */ - public void useThermodynamicCorrections(boolean thermodynamicCorrections); + /** + *

+ * useThermodynamicCorrections. + *

+ * + * @param thermodynamicCorrections a boolean + */ + public void useThermodynamicCorrections(boolean thermodynamicCorrections); - /** - *

- * useThermodynamicCorrections. - *

- * - * @param thermodynamicCorrections a boolean - * @param phase a int - */ - public void useThermodynamicCorrections(boolean thermodynamicCorrections, int phase); + /** + *

+ * useThermodynamicCorrections. + *

+ * + * @param thermodynamicCorrections a boolean + * @param phase a int + */ + public void useThermodynamicCorrections(boolean thermodynamicCorrections, int phase); - /** - *

- * useFiniteFluxCorrection. - *

- * - * @param phase a int - * @return a boolean - */ - public boolean useFiniteFluxCorrection(int phase); + /** + *

+ * useFiniteFluxCorrection. + *

+ * + * @param phase a int + * @return a boolean + */ + public boolean useFiniteFluxCorrection(int phase); - /** - *

- * useFiniteFluxCorrection. - *

- * - * @param finiteFluxCorrection a boolean - */ - public void useFiniteFluxCorrection(boolean finiteFluxCorrection); + /** + *

+ * useFiniteFluxCorrection. + *

+ * + * @param finiteFluxCorrection a boolean + */ + public void useFiniteFluxCorrection(boolean finiteFluxCorrection); - /** - *

- * useFiniteFluxCorrection. - *

- * - * @param finiteFluxCorrection a boolean - * @param phase a int - */ - public void useFiniteFluxCorrection(boolean finiteFluxCorrection, int phase); + /** + *

+ * useFiniteFluxCorrection. + *

+ * + * @param finiteFluxCorrection a boolean + * @param phase a int + */ + public void useFiniteFluxCorrection(boolean finiteFluxCorrection, int phase); } diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundaryNode/FluidBoundaryNode.java b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundaryNode/FluidBoundaryNode.java index c956e3fc5f..ee83c6a868 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundaryNode/FluidBoundaryNode.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundaryNode/FluidBoundaryNode.java @@ -3,6 +3,7 @@ * * Created on 8. august 2001, 14:49 */ + package neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.finiteVolumeBoundary.fluidBoundaryNode; import neqsim.thermo.system.SystemInterface; @@ -16,29 +17,29 @@ * @version $Id: $Id */ public class FluidBoundaryNode implements FluidBoundaryNodeInterface { - protected SystemInterface system; + protected SystemInterface system; - /** - *

- * Constructor for FluidBoundaryNode. - *

- */ - public FluidBoundaryNode() {} + /** + *

+ * Constructor for FluidBoundaryNode. + *

+ */ + public FluidBoundaryNode() {} - /** - *

- * Constructor for FluidBoundaryNode. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public FluidBoundaryNode(SystemInterface system) { - this.system = system.clone(); - } + /** + *

+ * Constructor for FluidBoundaryNode. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public FluidBoundaryNode(SystemInterface system) { + this.system = system.clone(); + } - /** {@inheritDoc} */ - @Override - public SystemInterface getBulkSystem() { - return system; - } + /** {@inheritDoc} */ + @Override + public SystemInterface getBulkSystem() { + return system; + } } diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundaryNode/FluidBoundaryNodeInterface.java b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundaryNode/FluidBoundaryNodeInterface.java index e5dd2b8379..94fec6beda 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundaryNode/FluidBoundaryNodeInterface.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundaryNode/FluidBoundaryNodeInterface.java @@ -3,6 +3,7 @@ * * Created on 8. august 2001, 14:49 */ + package neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.finiteVolumeBoundary.fluidBoundaryNode; import neqsim.thermo.system.SystemInterface; @@ -16,12 +17,12 @@ * @version $Id: $Id */ public interface FluidBoundaryNodeInterface { - /** - *

- * getBulkSystem. - *

- * - * @return a {@link neqsim.thermo.system.SystemInterface} object - */ - public SystemInterface getBulkSystem(); + /** + *

+ * getBulkSystem. + *

+ * + * @return a {@link neqsim.thermo.system.SystemInterface} object + */ + public SystemInterface getBulkSystem(); } diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundaryNode/fluidBoundaryReactiveNode/FluidBoundaryNodeReactive.java b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundaryNode/fluidBoundaryReactiveNode/FluidBoundaryNodeReactive.java index ef1fe03880..e85e79ef57 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundaryNode/fluidBoundaryReactiveNode/FluidBoundaryNodeReactive.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundaryNode/fluidBoundaryReactiveNode/FluidBoundaryNodeReactive.java @@ -3,6 +3,7 @@ * * Created on 8. august 2001, 14:50 */ + package neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.finiteVolumeBoundary.fluidBoundaryNode.fluidBoundaryReactiveNode; import neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.finiteVolumeBoundary.fluidBoundaryNode.FluidBoundaryNode; @@ -17,21 +18,21 @@ * @version $Id: $Id */ public class FluidBoundaryNodeReactive extends FluidBoundaryNode { - /** - *

- * Constructor for FluidBoundaryNodeReactive. - *

- */ - public FluidBoundaryNodeReactive() {} + /** + *

+ * Constructor for FluidBoundaryNodeReactive. + *

+ */ + public FluidBoundaryNodeReactive() {} - /** - *

- * Constructor for FluidBoundaryNodeReactive. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public FluidBoundaryNodeReactive(SystemInterface system) { - super(system); - } + /** + *

+ * Constructor for FluidBoundaryNodeReactive. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public FluidBoundaryNodeReactive(SystemInterface system) { + super(system); + } } diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySolver/FluidBoundarySolver.java b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySolver/FluidBoundarySolver.java index 09971aff31..223d9c1a2e 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySolver/FluidBoundarySolver.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySolver/FluidBoundarySolver.java @@ -3,6 +3,7 @@ * * Created on 8. august 2001, 14:51 */ + package neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.finiteVolumeBoundary.fluidBoundarySolver; import Jama.Matrix; @@ -18,267 +19,263 @@ * @version $Id: $Id */ public class FluidBoundarySolver implements FluidBoundarySolverInterface { - FluidBoundarySystemInterface boundary; - double xNew[][]; - protected Matrix[] solMatrix, diffMatrix; - protected double a[]; - protected double b[]; - protected double c[]; - protected double r[]; - boolean reactive = false; + FluidBoundarySystemInterface boundary; + double xNew[][]; + protected Matrix[] solMatrix, diffMatrix; + protected double a[]; + protected double b[]; + protected double c[]; + protected double r[]; + boolean reactive = false; - /** - *

- * Constructor for FluidBoundarySolver. - *

- */ - public FluidBoundarySolver() {} + /** + *

+ * Constructor for FluidBoundarySolver. + *

+ */ + public FluidBoundarySolver() {} - /** - *

- * Constructor for FluidBoundarySolver. - *

- * - * @param boundary a - * {@link neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.finiteVolumeBoundary.fluidBoundarySystem.FluidBoundarySystemInterface} - * object - */ - public FluidBoundarySolver(FluidBoundarySystemInterface boundary) { - this.boundary = boundary; - this.initProfiles(); - a = new double[boundary.getNumberOfNodes()]; - b = new double[boundary.getNumberOfNodes()]; - c = new double[boundary.getNumberOfNodes()]; - r = new double[boundary.getNumberOfNodes()]; + /** + *

+ * Constructor for FluidBoundarySolver. + *

+ * + * @param boundary a + * {@link neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.finiteVolumeBoundary.fluidBoundarySystem.FluidBoundarySystemInterface} + * object + */ + public FluidBoundarySolver(FluidBoundarySystemInterface boundary) { + this.boundary = boundary; + this.initProfiles(); + a = new double[boundary.getNumberOfNodes()]; + b = new double[boundary.getNumberOfNodes()]; + c = new double[boundary.getNumberOfNodes()]; + r = new double[boundary.getNumberOfNodes()]; - solMatrix = new Matrix[boundary.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents()]; - diffMatrix = new Matrix[boundary.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents()]; - for (int k = 0; k < boundary.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents(); k++) { - diffMatrix[k] = new Matrix(a, 1).transpose(); - solMatrix[k] = new Matrix(a, 1).transpose(); - } + solMatrix = + new Matrix[boundary.getNode(0).getBulkSystem().getPhases()[0].getNumberOfComponents()]; + diffMatrix = + new Matrix[boundary.getNode(0).getBulkSystem().getPhases()[0].getNumberOfComponents()]; + for (int k = 0; k < boundary.getNode(0).getBulkSystem().getPhases()[0] + .getNumberOfComponents(); k++) { + diffMatrix[k] = new Matrix(a, 1).transpose(); + solMatrix[k] = new Matrix(a, 1).transpose(); } + } - /** - *

- * Constructor for FluidBoundarySolver. - *

- * - * @param boundary a - * {@link neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.finiteVolumeBoundary.fluidBoundarySystem.FluidBoundarySystemInterface} - * object - * @param reactive a boolean - */ - public FluidBoundarySolver(FluidBoundarySystemInterface boundary, boolean reactive) { - this(boundary); - this.reactive = reactive; - } + /** + *

+ * Constructor for FluidBoundarySolver. + *

+ * + * @param boundary a + * {@link neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.finiteVolumeBoundary.fluidBoundarySystem.FluidBoundarySystemInterface} + * object + * @param reactive a boolean + */ + public FluidBoundarySolver(FluidBoundarySystemInterface boundary, boolean reactive) { + this(boundary); + this.reactive = reactive; + } - /** - *

- * initProfiles. - *

- */ - public void initProfiles() { - Matrix reacRates = new Matrix(1, 1); - for (int i = 0; i < boundary.getNumberOfNodes() - 1; i++) { - boundary.getNode(i).getBulkSystem().init(3); - boundary.getNode(i).getBulkSystem().getPhases()[1].initPhysicalProperties(); - boundary.getNode(i).getBulkSystem().getPhases()[1].getPhysicalProperties() - .calcEffectiveDiffusionCoefficients(); - // if(reactive) reacRates = - // boundary.getNode(i).getBulkSystem().getChemicalReactionOperations().calcReacRates(1); + /** + *

+ * initProfiles. + *

+ */ + public void initProfiles() { + Matrix reacRates = new Matrix(1, 1); + for (int i = 0; i < boundary.getNumberOfNodes() - 1; i++) { + boundary.getNode(i).getBulkSystem().init(3); + boundary.getNode(i).getBulkSystem().getPhases()[1].initPhysicalProperties(); + boundary.getNode(i).getBulkSystem().getPhases()[1].getPhysicalProperties() + .calcEffectiveDiffusionCoefficients(); + // if(reactive) reacRates = + // boundary.getNode(i).getBulkSystem().getChemicalReactionOperations().calcReacRates(1); - for (int j = 0; j < boundary.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents(); j++) { - double xbulk = boundary.getFluidBoundary().getBulkSystem().getPhases()[1] - .getComponents()[j].getx(); - double xinterphase = - boundary.getFluidBoundary().getInterphaseSystem().getPhases()[1] - .getComponents()[j].getx(); - double dx = xinterphase - xbulk; - double last = boundary.getNode(i).getBulkSystem().getPhases()[1].getComponents()[j] - .getx(); - if (reactive) { - boundary.getNode(i + 1).getBulkSystem().getPhases()[1].getComponents()[j] - .setx(last - dx - - reacRates.get(j, 0) - / boundary.getNode(i).getBulkSystem().getPhases()[1] - .getPhysicalProperties() - .getEffectiveDiffusionCoefficient(j) - * Math.pow(boundary.getNodeLength(), 2.0)); - } else { - boundary.getNode(i + 1).getBulkSystem().getPhases()[1].getComponents()[j].setx( - xinterphase - dx * ((double) (i + 1) / boundary.getNumberOfNodes())); - } - System.out.println("x comp " + reactive + " " - + boundary.getNode(i).getBulkSystem().getPhases()[1].getComponents()[j] - .getx()); - } + for (int j = 0; j < boundary.getNode(0).getBulkSystem().getPhases()[0] + .getNumberOfComponents(); j++) { + double xbulk = + boundary.getFluidBoundary().getBulkSystem().getPhases()[1].getComponents()[j].getx(); + double xinterphase = + boundary.getFluidBoundary().getInterphaseSystem().getPhases()[1].getComponents()[j] + .getx(); + double dx = xinterphase - xbulk; + double last = boundary.getNode(i).getBulkSystem().getPhases()[1].getComponents()[j].getx(); + if (reactive) { + boundary.getNode(i + 1).getBulkSystem().getPhases()[1].getComponents()[j] + .setx(last - dx + - reacRates.get(j, 0) + / boundary.getNode(i).getBulkSystem().getPhases()[1].getPhysicalProperties() + .getEffectiveDiffusionCoefficient(j) + * Math.pow(boundary.getNodeLength(), 2.0)); + } else { + boundary.getNode(i + 1).getBulkSystem().getPhases()[1].getComponents()[j] + .setx(xinterphase - dx * ((double) (i + 1) / boundary.getNumberOfNodes())); } + System.out.println("x comp " + reactive + " " + + boundary.getNode(i).getBulkSystem().getPhases()[1].getComponents()[j].getx()); + } } + } - /** - *

- * initMatrix. - *

- */ - public void initMatrix() { - for (int j = 0; j < boundary.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents(); j++) { - // pipe.getNode(i).init(); - for (int i = 0; i < boundary.getNumberOfNodes(); i++) { - solMatrix[j].set(i, 0, - boundary.getNode(i).getBulkSystem().getPhases()[1].getComponents()[j] - .getx()); - } - } + /** + *

+ * initMatrix. + *

+ */ + public void initMatrix() { + for (int j = 0; j < boundary.getNode(0).getBulkSystem().getPhases()[0] + .getNumberOfComponents(); j++) { + // pipe.getNode(i).init(); + for (int i = 0; i < boundary.getNumberOfNodes(); i++) { + solMatrix[j].set(i, 0, + boundary.getNode(i).getBulkSystem().getPhases()[1].getComponents()[j].getx()); + } } + } - /** - *

- * initComposition. - *

- * - * @param iter a int - */ - public void initComposition(int iter) { - for (int j = 0; j < boundary.getNumberOfNodes(); j++) { - for (int p = 0; p < boundary.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents(); p++) { - boundary.getNode(j).getBulkSystem().getPhases()[1].getComponents()[p] - .setx(solMatrix[p].get(j, 0)); - } - boundary.getNode(j).getBulkSystem().getPhases()[0].normalize(); - boundary.getNode(j).getBulkSystem().init(3); - } + /** + *

+ * initComposition. + *

+ * + * @param iter a int + */ + public void initComposition(int iter) { + for (int j = 0; j < boundary.getNumberOfNodes(); j++) { + for (int p = 0; p < boundary.getNode(0).getBulkSystem().getPhases()[0] + .getNumberOfComponents(); p++) { + boundary.getNode(j).getBulkSystem().getPhases()[1].getComponents()[p] + .setx(solMatrix[p].get(j, 0)); + } + boundary.getNode(j).getBulkSystem().getPhases()[0].normalize(); + boundary.getNode(j).getBulkSystem().init(3); } + } - /** - *

- * setComponentConservationMatrix. - *

- * - * @param componentNumber a int - */ - public void setComponentConservationMatrix(int componentNumber) { - for (int i = 0; i < boundary.getNumberOfNodes(); i++) { - boundary.getNode(i).getBulkSystem().getPhases()[1].initPhysicalProperties(); - boundary.getNode(i).getBulkSystem().getPhases()[1].getPhysicalProperties() - .calcEffectiveDiffusionCoefficients(); - /// if(reactive) - /// boundary.getNode(i).getBulkSystem().getChemicalReactionOperations().calcReacRates(1); - } - - a[0] = 0.0; - c[0] = 0.0; - b[0] = 1.0;// boundary.getNode(0).getBulkSystem().getPhases()[1].getComponents()[componentNumber].getx(); - r[0] = boundary.getNode(0).getBulkSystem().getPhases()[1].getComponents()[componentNumber] - .getx(); - System.out.println("b0 :" + b[0]); - // setter ligningen paa rett form - a[0] = -a[0]; - c[0] = -c[0]; + /** + *

+ * setComponentConservationMatrix. + *

+ * + * @param componentNumber a int + */ + public void setComponentConservationMatrix(int componentNumber) { + for (int i = 0; i < boundary.getNumberOfNodes(); i++) { + boundary.getNode(i).getBulkSystem().getPhases()[1].initPhysicalProperties(); + boundary.getNode(i).getBulkSystem().getPhases()[1].getPhysicalProperties() + .calcEffectiveDiffusionCoefficients(); + /// if(reactive) + /// boundary.getNode(i).getBulkSystem().getChemicalReactionOperations().calcReacRates(1); + } - for (int i = 1; i < boundary.getNumberOfNodes() - 1; i++) { - double Dw = (boundary.getNode(i - 1).getBulkSystem().getPhases()[1] - .getPhysicalProperties().getEffectiveDiffusionCoefficient(componentNumber) - + boundary.getNode(i).getBulkSystem().getPhases()[1].getPhysicalProperties() - .getEffectiveDiffusionCoefficient(componentNumber)) - / 2.0; - double De = (boundary.getNode(i).getBulkSystem().getPhases()[1].getPhysicalProperties() - .getEffectiveDiffusionCoefficient(componentNumber) - + boundary.getNode(i + 1).getBulkSystem().getPhases()[1].getPhysicalProperties() - .getEffectiveDiffusionCoefficient(componentNumber)) - / 2.0; + a[0] = 0.0; + c[0] = 0.0; + b[0] = 1.0;// boundary.getNode(0).getBulkSystem().getPhases()[1].getComponents()[componentNumber].getx(); + r[0] = + boundary.getNode(0).getBulkSystem().getPhases()[1].getComponents()[componentNumber].getx(); + System.out.println("b0 :" + b[0]); + // setter ligningen paa rett form + a[0] = -a[0]; + c[0] = -c[0]; - a[i] = Dw / boundary.getNodeLength(); - c[i] = De / boundary.getNodeLength(); - b[i] = a[i] + c[i]; - r[i] = 0.0; + for (int i = 1; i < boundary.getNumberOfNodes() - 1; i++) { + double Dw = (boundary.getNode(i - 1).getBulkSystem().getPhases()[1].getPhysicalProperties() + .getEffectiveDiffusionCoefficient(componentNumber) + + boundary.getNode(i).getBulkSystem().getPhases()[1].getPhysicalProperties() + .getEffectiveDiffusionCoefficient(componentNumber)) + / 2.0; + double De = (boundary.getNode(i).getBulkSystem().getPhases()[1].getPhysicalProperties() + .getEffectiveDiffusionCoefficient(componentNumber) + + boundary.getNode(i + 1).getBulkSystem().getPhases()[1].getPhysicalProperties() + .getEffectiveDiffusionCoefficient(componentNumber)) + / 2.0; - // setter ligningen paa rett form - a[i] = -a[i]; - c[i] = -c[i]; - } + a[i] = Dw / boundary.getNodeLength(); + c[i] = De / boundary.getNodeLength(); + b[i] = a[i] + c[i]; + r[i] = 0.0; - int i = boundary.getNumberOfNodes() - 1; - a[i] = 0.0; - c[i] = 0.0; - b[i] = 1.0;// boundary.getNode(i).getBulkSystem().getPhases()[1].getComponents()[componentNumber].getx(); - r[i] = boundary.getNode(i).getBulkSystem().getPhases()[1].getComponents()[componentNumber] - .getx(); - System.out.println("bn :" + b[i]); - // setter ligningen paa rett form - a[i] = -a[i]; - c[i] = -c[i]; + // setter ligningen paa rett form + a[i] = -a[i]; + c[i] = -c[i]; } - /** {@inheritDoc} */ - @Override - public double getMolarFlux(int componentNumber) { - double temp = 1.0; - if (reactive) { - temp = 2.1; - } - return temp - * boundary.getNode(0).getBulkSystem().getPhases()[1].getPhysicalProperties() - .getEffectiveDiffusionCoefficient(componentNumber) - * (boundary.getNode(0).getBulkSystem().getPhases()[1] - .getComponents()[componentNumber].getx() - - boundary.getNode(1).getBulkSystem().getPhases()[1] - .getComponents()[componentNumber].getx()) - / boundary.getNodeLength(); + int i = boundary.getNumberOfNodes() - 1; + a[i] = 0.0; + c[i] = 0.0; + b[i] = 1.0;// boundary.getNode(i).getBulkSystem().getPhases()[1].getComponents()[componentNumber].getx(); + r[i] = + boundary.getNode(i).getBulkSystem().getPhases()[1].getComponents()[componentNumber].getx(); + System.out.println("bn :" + b[i]); + // setter ligningen paa rett form + a[i] = -a[i]; + c[i] = -c[i]; + } + + /** {@inheritDoc} */ + @Override + public double getMolarFlux(int componentNumber) { + double temp = 1.0; + if (reactive) { + temp = 2.1; } + return temp + * boundary.getNode(0).getBulkSystem().getPhases()[1].getPhysicalProperties() + .getEffectiveDiffusionCoefficient(componentNumber) + * (boundary.getNode(0).getBulkSystem().getPhases()[1].getComponents()[componentNumber] + .getx() + - boundary.getNode(1).getBulkSystem().getPhases()[1].getComponents()[componentNumber] + .getx()) + / boundary.getNodeLength(); + } - /** {@inheritDoc} */ - @Override - public void solve() { - // double d[]; - int iter = 0, iterTop = 0; - double maxDiff = 0; - // double maxDiffOld = 0; - double diff = 0; - xNew = new double[boundary.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents()][boundary.getNumberOfNodes()]; + /** {@inheritDoc} */ + @Override + public void solve() { + // double d[]; + int iter = 0, iterTop = 0; + double maxDiff = 0; + // double maxDiffOld = 0; + double diff = 0; + xNew = new double[boundary.getNode(0).getBulkSystem().getPhases()[0] + .getNumberOfComponents()][boundary.getNumberOfNodes()]; - initProfiles(); - initMatrix(); - initComposition(1); - System.out.println( - " vol " + boundary.getNode(2).getBulkSystem().getPhases()[0].getMolarVolume()); + initProfiles(); + initMatrix(); + initComposition(1); + System.out + .println(" vol " + boundary.getNode(2).getBulkSystem().getPhases()[0].getMolarVolume()); - do { - // maxDiffOld = maxDiff; - maxDiff = 0; - iterTop++; - iter = 0; + do { + // maxDiffOld = maxDiff; + maxDiff = 0; + iterTop++; + iter = 0; - do { - iter++; - for (int p = 0; p < boundary.getNode(0).getBulkSystem().getPhases()[1] - .getNumberOfComponents(); p++) { - setComponentConservationMatrix(p); - Matrix solOld = solMatrix[p].copy(); - solOld.print(20, 20); - xNew[p] = TDMAsolve.solve(a, b, c, r); - solMatrix[p] = new Matrix(xNew[p], 1).transpose(); - solMatrix[p].print(20, 20); - diffMatrix[p] = solMatrix[p].minus(solOld); - diff = Math.abs(diffMatrix[p].norm1() / (solMatrix[p].norm1())); - if (diff > maxDiff) { - maxDiff = diff; - } - } - // initComposition(iter); - // solMatrix.print(10,10); - } while (diff > 1e-15 && iter < 100); + do { + iter++; + for (int p = 0; p < boundary.getNode(0).getBulkSystem().getPhases()[1] + .getNumberOfComponents(); p++) { + setComponentConservationMatrix(p); + Matrix solOld = solMatrix[p].copy(); + solOld.print(20, 20); + xNew[p] = TDMAsolve.solve(a, b, c, r); + solMatrix[p] = new Matrix(xNew[p], 1).transpose(); + solMatrix[p].print(20, 20); + diffMatrix[p] = solMatrix[p].minus(solOld); + diff = Math.abs(diffMatrix[p].norm1() / (solMatrix[p].norm1())); + if (diff > maxDiff) { + maxDiff = diff; + } + } + // initComposition(iter); + // solMatrix.print(10,10); + } while (diff > 1e-15 && iter < 100); - System.out.println("maxDiff " + maxDiff); - } while (Math.abs(maxDiff) > 1e-10 && iterTop < 10); - // diffMatrix.norm2()/sol2Matrix.norm2())>0.1); - } + System.out.println("maxDiff " + maxDiff); + } while (Math.abs(maxDiff) > 1e-10 && iterTop < 10); + // diffMatrix.norm2()/sol2Matrix.norm2())>0.1); + } } diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySolver/FluidBoundarySolverInterface.java b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySolver/FluidBoundarySolverInterface.java index 6e08ce7f9a..c4810afa10 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySolver/FluidBoundarySolverInterface.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySolver/FluidBoundarySolverInterface.java @@ -3,6 +3,7 @@ * * Created on 8. august 2001, 14:51 */ + package neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.finiteVolumeBoundary.fluidBoundarySolver; /** @@ -14,20 +15,20 @@ * @version $Id: $Id */ public interface FluidBoundarySolverInterface { - /** - *

- * solve. - *

- */ - public void solve(); + /** + *

+ * solve. + *

+ */ + public void solve(); - /** - *

- * getMolarFlux. - *

- * - * @param componentNumber a int - * @return a double - */ - public double getMolarFlux(int componentNumber); + /** + *

+ * getMolarFlux. + *

+ * + * @param componentNumber a int + * @return a double + */ + public double getMolarFlux(int componentNumber); } diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySolver/fluidBoundaryReactiveSolver/FluidBoundaryReactiveSolver.java b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySolver/fluidBoundaryReactiveSolver/FluidBoundaryReactiveSolver.java index bdcdcbe69f..475be6bca1 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySolver/fluidBoundaryReactiveSolver/FluidBoundaryReactiveSolver.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySolver/fluidBoundaryReactiveSolver/FluidBoundaryReactiveSolver.java @@ -3,6 +3,7 @@ * * Created on 8. august 2001, 14:52 */ + package neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.finiteVolumeBoundary.fluidBoundarySolver.fluidBoundaryReactiveSolver; import neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.finiteVolumeBoundary.fluidBoundarySolver.FluidBoundarySolver; @@ -16,10 +17,10 @@ * @version $Id: $Id */ public class FluidBoundaryReactiveSolver extends FluidBoundarySolver { - /** - *

- * Constructor for FluidBoundaryReactiveSolver. - *

- */ - public FluidBoundaryReactiveSolver() {} + /** + *

+ * Constructor for FluidBoundaryReactiveSolver. + *

+ */ + public FluidBoundaryReactiveSolver() {} } diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySystem/fluidBoundarySystemReactive/FluidBoundarySystemReactive.java b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySystem/fluidBoundarySystemReactive/FluidBoundarySystemReactive.java index 9e05b2d238..f46d9886ae 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySystem/fluidBoundarySystemReactive/FluidBoundarySystemReactive.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySystem/fluidBoundarySystemReactive/FluidBoundarySystemReactive.java @@ -3,6 +3,7 @@ * * Created on 8. august 2001, 13:56 */ + package neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.finiteVolumeBoundary.fluidBoundarySystem.fluidBoundarySystemReactive; import neqsim.fluidMechanics.flowNode.FlowNodeInterface; @@ -23,70 +24,70 @@ * @version $Id: $Id */ public class FluidBoundarySystemReactive extends FluidBoundarySystem { - /** - *

- * Constructor for FluidBoundarySystemReactive. - *

- */ - public FluidBoundarySystemReactive() {} + /** + *

+ * Constructor for FluidBoundarySystemReactive. + *

+ */ + public FluidBoundarySystemReactive() {} - /** - *

- * Constructor for FluidBoundarySystemReactive. - *

- * - * @param boundary a - * {@link neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.FluidBoundaryInterface} - * object - */ - public FluidBoundarySystemReactive(FluidBoundaryInterface boundary) { - super(boundary); - reactive = true; - } + /** + *

+ * Constructor for FluidBoundarySystemReactive. + *

+ * + * @param boundary a + * {@link neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.FluidBoundaryInterface} + * object + */ + public FluidBoundarySystemReactive(FluidBoundaryInterface boundary) { + super(boundary); + reactive = true; + } - /** {@inheritDoc} */ - @Override - public void createSystem() { - nodes = new FluidBoundaryNodeReactive[numberOfNodes]; - super.createSystem(); + /** {@inheritDoc} */ + @Override + public void createSystem() { + nodes = new FluidBoundaryNodeReactive[numberOfNodes]; + super.createSystem(); - for (int i = 0; i < numberOfNodes; i++) { - nodes[i] = new FluidBoundaryNodeReactive(boundary.getInterphaseSystem()); - } - System.out.println("system created..."); + for (int i = 0; i < numberOfNodes; i++) { + nodes[i] = new FluidBoundaryNodeReactive(boundary.getInterphaseSystem()); } + System.out.println("system created..."); + } - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - SystemInterface testSystem = new SystemFurstElectrolyteEos(275.3, 1.01325); - PipeData pipe1 = new PipeData(10.0, 0.025); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + SystemInterface testSystem = new SystemFurstElectrolyteEos(275.3, 1.01325); + PipeData pipe1 = new PipeData(10.0, 0.025); - testSystem.addComponent("methane", 0.061152181, 0); - testSystem.addComponent("water", 0.1862204876, 1); - testSystem.chemicalReactionInit(); - testSystem.setMixingRule(2); - testSystem.init_x_y(); + testSystem.addComponent("methane", 0.061152181, 0); + testSystem.addComponent("water", 0.1862204876, 1); + testSystem.chemicalReactionInit(); + testSystem.setMixingRule(2); + testSystem.init_x_y(); - FlowNodeInterface test = new StratifiedFlowNode(testSystem, pipe1); - test.setInterphaseModelType(10); + FlowNodeInterface test = new StratifiedFlowNode(testSystem, pipe1); + test.setInterphaseModelType(10); - test.initFlowCalc(); - test.calcFluxes(); + test.initFlowCalc(); + test.calcFluxes(); - test.getFluidBoundary().setEnhancementType(0); - test.calcFluxes(); - /* - * test.getFluidBoundary().getEnhancementFactor().getNumericInterface(). createSystem(); - * test.getFluidBoundary().getEnhancementFactor().getNumericInterface().solve(); - * System.out.println("enhancement " + - * test.getFluidBoundary().getEnhancementFactor().getNumericInterface(). - * getEnhancementFactor(0)); - **/ - } + test.getFluidBoundary().setEnhancementType(0); + test.calcFluxes(); + /* + * test.getFluidBoundary().getEnhancementFactor().getNumericInterface(). createSystem(); + * test.getFluidBoundary().getEnhancementFactor().getNumericInterface().solve(); + * System.out.println("enhancement " + + * test.getFluidBoundary().getEnhancementFactor().getNumericInterface(). + * getEnhancementFactor(0)); + **/ + } } diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/reactiveFilmModel/ReactiveKrishnaStandartFilmModel.java b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/reactiveFilmModel/ReactiveKrishnaStandartFilmModel.java index 51e2c1f20b..b65f1e4f94 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/reactiveFilmModel/ReactiveKrishnaStandartFilmModel.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/reactiveFilmModel/ReactiveKrishnaStandartFilmModel.java @@ -3,6 +3,7 @@ * * Created on 3. august 2001, 12:15 */ + package neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.nonEquilibriumFluidBoundary.filmModelBoundary.reactiveFilmModel; import Jama.Matrix; @@ -21,74 +22,74 @@ * @version $Id: $Id */ public class ReactiveKrishnaStandartFilmModel extends KrishnaStandartFilmModel { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - int enhancementType = 1; + int enhancementType = 1; - /** - *

- * Constructor for ReactiveKrishnaStandartFilmModel. - *

- */ - public ReactiveKrishnaStandartFilmModel() {} + /** + *

+ * Constructor for ReactiveKrishnaStandartFilmModel. + *

+ */ + public ReactiveKrishnaStandartFilmModel() {} - /** - *

- * Constructor for ReactiveKrishnaStandartFilmModel. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public ReactiveKrishnaStandartFilmModel(SystemInterface system) { - super(system); - enhancementFactor = new EnhancementFactorAlg(this); - } + /** + *

+ * Constructor for ReactiveKrishnaStandartFilmModel. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public ReactiveKrishnaStandartFilmModel(SystemInterface system) { + super(system); + enhancementFactor = new EnhancementFactorAlg(this); + } - /** - *

- * Constructor for ReactiveKrishnaStandartFilmModel. - *

- * - * @param flowNode a {@link neqsim.fluidMechanics.flowNode.FlowNodeInterface} object - */ - public ReactiveKrishnaStandartFilmModel(FlowNodeInterface flowNode) { - super(flowNode); - enhancementFactor = new EnhancementFactorAlg(this); - } + /** + *

+ * Constructor for ReactiveKrishnaStandartFilmModel. + *

+ * + * @param flowNode a {@link neqsim.fluidMechanics.flowNode.FlowNodeInterface} object + */ + public ReactiveKrishnaStandartFilmModel(FlowNodeInterface flowNode) { + super(flowNode); + enhancementFactor = new EnhancementFactorAlg(this); + } - // public double calcBinaryMassTransferCoefficients(int phase){ - // super.calcBinaryMassTransferCoefficients(phase); - // enhancementFactor.calcEnhancementVec(phase); - // Matrix enhancementvec = new Matrix(enhancementFactor.getEnhancementVec(),1); - // //System.out.println("phase " + phase); - // //enhancementvec.print(10,10); - // for(int i=0;i - * Constructor for EnhancementFactor. - *

- */ - public EnhancementFactor() {} - - /** - *

- * Constructor for EnhancementFactor. - *

- * - * @param fluidBoundary a - * {@link neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.FluidBoundaryInterface} - * object - */ - public EnhancementFactor(FluidBoundaryInterface fluidBoundary) { - this(); - this.fluidBoundary = fluidBoundary; - enhancementVec = - new double[fluidBoundary.getBulkSystem().getPhases()[0].getNumberOfComponents()]; - hattaNumber = - new double[fluidBoundary.getBulkSystem().getPhases()[0].getNumberOfComponents()]; - } + protected double[] enhancementVec = null; + protected double[] hattaNumber = null; + protected FluidBoundaryInterface fluidBoundary; + protected FluidBoundarySystemInterface nonReactiveInterface, reactiveInterface; + + /** + *

+ * Constructor for EnhancementFactor. + *

+ */ + public EnhancementFactor() {} - /** - *

- * calcEnhancementVec. - *

- * - * @param phase a int - * @param enhancementType a int - */ - public void calcEnhancementVec(int phase, int enhancementType) { - if (phase == 1) { - this.calcEnhancementVec(phase); - } - if (phase == 0) { - this.setOnesVec(phase); - } + /** + *

+ * Constructor for EnhancementFactor. + *

+ * + * @param fluidBoundary a + * {@link neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.FluidBoundaryInterface} + * object + */ + public EnhancementFactor(FluidBoundaryInterface fluidBoundary) { + this(); + this.fluidBoundary = fluidBoundary; + enhancementVec = + new double[fluidBoundary.getBulkSystem().getPhases()[0].getNumberOfComponents()]; + hattaNumber = new double[fluidBoundary.getBulkSystem().getPhases()[0].getNumberOfComponents()]; + } + + /** + *

+ * calcEnhancementVec. + *

+ * + * @param phase a int + * @param enhancementType a int + */ + public void calcEnhancementVec(int phase, int enhancementType) { + if (phase == 1) { + this.calcEnhancementVec(phase); + } + if (phase == 0) { + this.setOnesVec(phase); } + } - /** - *

- * setOnesVec. - *

- * - * @param phase a int - */ - public void setOnesVec(int phase) { - for (int j = 0; j < fluidBoundary.getBulkSystem().getPhases()[phase] - .getNumberOfComponents(); j++) { - enhancementVec[j] = 1.0; - } + /** + *

+ * setOnesVec. + *

+ * + * @param phase a int + */ + public void setOnesVec(int phase) { + for (int j = 0; j < fluidBoundary.getBulkSystem().getPhases()[phase] + .getNumberOfComponents(); j++) { + enhancementVec[j] = 1.0; } + } - /** {@inheritDoc} */ - @Override - public void calcEnhancementVec(int phase) {} + /** {@inheritDoc} */ + @Override + public void calcEnhancementVec(int phase) {} - /** {@inheritDoc} */ - @Override - public double getEnhancementVec(int index) { - return enhancementVec[index]; - } + /** {@inheritDoc} */ + @Override + public double getEnhancementVec(int index) { + return enhancementVec[index]; + } - /** - * Getter for property enhancementVec. - * - * @return Value of property enhancementVec. - */ - public double[] getEnhancementVec() { - return enhancementVec; - } + /** + * Getter for property enhancementVec. + * + * @return Value of property enhancementVec. + */ + public double[] getEnhancementVec() { + return enhancementVec; + } - /** - * Indexed setter for property enhancementVec. - * - * @param index Index of the property. - * @param enhancementVec New value of the property at index. - */ - public void setEnhancementVec(int index, double enhancementVec) { - this.enhancementVec[index] = enhancementVec; - } + /** + * Indexed setter for property enhancementVec. + * + * @param index Index of the property. + * @param enhancementVec New value of the property at index. + */ + public void setEnhancementVec(int index, double enhancementVec) { + this.enhancementVec[index] = enhancementVec; + } - /** - * Setter for property enhancementVec. - * - * @param enhancementVec New value of property enhancementVec. - */ - public void setEnhancementVec(double[] enhancementVec) { - this.enhancementVec = enhancementVec; - } + /** + * Setter for property enhancementVec. + * + * @param enhancementVec New value of property enhancementVec. + */ + public void setEnhancementVec(double[] enhancementVec) { + this.enhancementVec = enhancementVec; + } - /** - * Getter for property hattaNumber. - * - * @return Value of property hattaNumber. - */ - public double[] getHattaNumber() { - return this.hattaNumber; - } + /** + * Getter for property hattaNumber. + * + * @return Value of property hattaNumber. + */ + public double[] getHattaNumber() { + return this.hattaNumber; + } - /** {@inheritDoc} */ - @Override - public double getHattaNumber(int i) { - return this.hattaNumber[i]; - } + /** {@inheritDoc} */ + @Override + public double getHattaNumber(int i) { + return this.hattaNumber[i]; + } - /** - * Setter for property hattaNumber. - * - * @param hattaNumber New value of property hattaNumber. - */ - public void setHattaNumber(double[] hattaNumber) { - this.hattaNumber = hattaNumber; - } + /** + * Setter for property hattaNumber. + * + * @param hattaNumber New value of property hattaNumber. + */ + public void setHattaNumber(double[] hattaNumber) { + this.hattaNumber = hattaNumber; + } - /* - * public FluidBoundarySystemInterface getNumericInterface(){ return numericInterface; } - */ + /* + * public FluidBoundarySystemInterface getNumericInterface(){ return numericInterface; } + */ } diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/reactiveFilmModel/enhancementFactor/EnhancementFactorInterface.java b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/reactiveFilmModel/enhancementFactor/EnhancementFactorInterface.java index 757422c359..3af9a0116d 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/reactiveFilmModel/enhancementFactor/EnhancementFactorInterface.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/reactiveFilmModel/enhancementFactor/EnhancementFactorInterface.java @@ -3,6 +3,7 @@ * * Created on 3. august 2001, 11:58 */ + package neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.nonEquilibriumFluidBoundary.filmModelBoundary.reactiveFilmModel.enhancementFactor; /** @@ -14,32 +15,32 @@ * @version $Id: $Id */ public interface EnhancementFactorInterface { - /** - *

- * calcEnhancementVec. - *

- * - * @param phase a int - */ - public void calcEnhancementVec(int phase); + /** + *

+ * calcEnhancementVec. + *

+ * + * @param phase a int + */ + public void calcEnhancementVec(int phase); - /** - *

- * getEnhancementVec. - *

- * - * @param index a int - * @return a double - */ - public double getEnhancementVec(int index); + /** + *

+ * getEnhancementVec. + *

+ * + * @param index a int + * @return a double + */ + public double getEnhancementVec(int index); - /** - *

- * getHattaNumber. - *

- * - * @param i a int - * @return a double - */ - public double getHattaNumber(int i); + /** + *

+ * getHattaNumber. + *

+ * + * @param i a int + * @return a double + */ + public double getHattaNumber(int i); } diff --git a/src/main/java/neqsim/fluidMechanics/flowSolver/FlowSolver.java b/src/main/java/neqsim/fluidMechanics/flowSolver/FlowSolver.java index 68638200b7..d22fa9d027 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSolver/FlowSolver.java +++ b/src/main/java/neqsim/fluidMechanics/flowSolver/FlowSolver.java @@ -3,6 +3,7 @@ * * Created on 17. januar 2001, 20:58 */ + package neqsim.fluidMechanics.flowSolver; /** @@ -14,52 +15,52 @@ * @version $Id: $Id */ public abstract class FlowSolver implements FlowSolverInterface, java.io.Serializable { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - protected int numberOfVelocityNodes = 0; - protected int numberOfNodes; - protected boolean dynamic = false; - protected double timeStep = 100; - protected int solverType = 0; + protected int numberOfVelocityNodes = 0; + protected int numberOfNodes; + protected boolean dynamic = false; + protected double timeStep = 100; + protected int solverType = 0; - /** - *

- * Constructor for FlowSolver. - *

- */ - public FlowSolver() {} + /** + *

+ * Constructor for FlowSolver. + *

+ */ + public FlowSolver() {} - /** {@inheritDoc} */ - @Override - public void solve() {} + /** {@inheritDoc} */ + @Override + public void solve() {} - /** {@inheritDoc} */ - @Override - public void setDynamic(boolean ans) { - dynamic = ans; - } + /** {@inheritDoc} */ + @Override + public void setDynamic(boolean ans) { + dynamic = ans; + } - /** {@inheritDoc} */ - @Override - public void setSolverType(int type) { - solverType = type; - } + /** {@inheritDoc} */ + @Override + public void setSolverType(int type) { + solverType = type; + } - /** {@inheritDoc} */ - @Override - public void setTimeStep(double timeStep) { - this.timeStep = timeStep; - } + /** {@inheritDoc} */ + @Override + public void setTimeStep(double timeStep) { + this.timeStep = timeStep; + } - /** {@inheritDoc} */ - @Override - public void setBoundarySpecificationType(int type) { - if (type == 0) { - numberOfVelocityNodes = numberOfNodes - 2; - } + /** {@inheritDoc} */ + @Override + public void setBoundarySpecificationType(int type) { + if (type == 0) { + numberOfVelocityNodes = numberOfNodes - 2; } + } - /** {@inheritDoc} */ - @Override - public void solveTDMA() {} + /** {@inheritDoc} */ + @Override + public void solveTDMA() {} } diff --git a/src/main/java/neqsim/fluidMechanics/flowSolver/FlowSolverInterface.java b/src/main/java/neqsim/fluidMechanics/flowSolver/FlowSolverInterface.java index c2d6f378d6..a9349fc2b4 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSolver/FlowSolverInterface.java +++ b/src/main/java/neqsim/fluidMechanics/flowSolver/FlowSolverInterface.java @@ -3,6 +3,7 @@ * * Created on 17. januar 2001, 20:56 */ + package neqsim.fluidMechanics.flowSolver; /** @@ -14,53 +15,53 @@ * @version $Id: $Id */ public interface FlowSolverInterface { - /** - *

- * solve. - *

- */ - public void solve(); + /** + *

+ * solve. + *

+ */ + public void solve(); - /** - *

- * setBoundarySpecificationType. - *

- * - * @param type a int - */ - public void setBoundarySpecificationType(int type); + /** + *

+ * setBoundarySpecificationType. + *

+ * + * @param type a int + */ + public void setBoundarySpecificationType(int type); - /** - *

- * solveTDMA. - *

- */ - public void solveTDMA(); + /** + *

+ * solveTDMA. + *

+ */ + public void solveTDMA(); - /** - *

- * setDynamic. - *

- * - * @param type a boolean - */ - public void setDynamic(boolean type); + /** + *

+ * setDynamic. + *

+ * + * @param type a boolean + */ + public void setDynamic(boolean type); - /** - *

- * setTimeStep. - *

- * - * @param timeStep a double - */ - public void setTimeStep(double timeStep); + /** + *

+ * setTimeStep. + *

+ * + * @param timeStep a double + */ + public void setTimeStep(double timeStep); - /** - *

- * setSolverType. - *

- * - * @param type a int - */ - public void setSolverType(int type); + /** + *

+ * setSolverType. + *

+ * + * @param type a int + */ + public void setSolverType(int type); } diff --git a/src/main/java/neqsim/fluidMechanics/flowSolver/onePhaseFlowSolver/OnePhaseFlowSolver.java b/src/main/java/neqsim/fluidMechanics/flowSolver/onePhaseFlowSolver/OnePhaseFlowSolver.java index 225d29cd22..2fc6936810 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSolver/onePhaseFlowSolver/OnePhaseFlowSolver.java +++ b/src/main/java/neqsim/fluidMechanics/flowSolver/onePhaseFlowSolver/OnePhaseFlowSolver.java @@ -3,6 +3,7 @@ * * Created on 17. januar 2001, 21:03 */ + package neqsim.fluidMechanics.flowSolver.onePhaseFlowSolver; /** @@ -14,12 +15,12 @@ * @version $Id: $Id */ public abstract class OnePhaseFlowSolver extends neqsim.fluidMechanics.flowSolver.FlowSolver { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for OnePhaseFlowSolver. - *

- */ - public OnePhaseFlowSolver() {} + /** + *

+ * Constructor for OnePhaseFlowSolver. + *

+ */ + public OnePhaseFlowSolver() {} } diff --git a/src/main/java/neqsim/fluidMechanics/flowSolver/onePhaseFlowSolver/onePhasePipeFlowSolver/OnePhaseFixedStaggeredGrid.java b/src/main/java/neqsim/fluidMechanics/flowSolver/onePhaseFlowSolver/onePhasePipeFlowSolver/OnePhaseFixedStaggeredGrid.java index 8d0026829f..2e9e36644c 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSolver/onePhaseFlowSolver/onePhasePipeFlowSolver/OnePhaseFixedStaggeredGrid.java +++ b/src/main/java/neqsim/fluidMechanics/flowSolver/onePhaseFlowSolver/onePhasePipeFlowSolver/OnePhaseFixedStaggeredGrid.java @@ -3,6 +3,7 @@ * * Created on 17. januar 2001, 21:10 */ + package neqsim.fluidMechanics.flowSolver.onePhaseFlowSolver.onePhasePipeFlowSolver; import Jama.Matrix; @@ -17,799 +18,783 @@ * @version $Id: $Id */ public class OnePhaseFixedStaggeredGrid extends OnePhasePipeFlowSolver - implements neqsim.thermo.ThermodynamicConstantsInterface { - private static final long serialVersionUID = 1000; - - Matrix diffMatrix; - int iter = 0; - Matrix[] diff4Matrix; - double xNew[][]; - protected double oldMass[]; - protected double oldComp[]; - protected double oldDensity[]; - protected double oldVelocity[]; - protected double oldComposition[][]; - protected double oldInternalEnergy[]; - protected double oldImpuls[]; - protected double oldEnergy[]; - - /** - *

- * Constructor for OnePhaseFixedStaggeredGrid. - *

- */ - public OnePhaseFixedStaggeredGrid() {} - - /** - *

- * Constructor for OnePhaseFixedStaggeredGrid. - *

- * - * @param pipe a - * {@link neqsim.fluidMechanics.flowSystem.onePhaseFlowSystem.pipeFlowSystem.PipeFlowSystem} - * object - * @param length a double - * @param nodes a int - * @param dynamic a boolean - */ - public OnePhaseFixedStaggeredGrid( - neqsim.fluidMechanics.flowSystem.onePhaseFlowSystem.pipeFlowSystem.PipeFlowSystem pipe, - double length, int nodes, boolean dynamic) { - super(pipe, length, nodes); - this.dynamic = dynamic; - oldMass = new double[nodes]; - oldComp = new double[nodes]; - oldImpuls = new double[nodes]; - diff4Matrix = - new Matrix[pipe.getNode(0).getBulkSystem().getPhases()[0].getNumberOfComponents()]; - oldEnergy = new double[nodes]; - oldVelocity = new double[nodes]; - oldDensity = new double[nodes]; - oldInternalEnergy = new double[nodes]; - oldComposition = new double[pipe.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents()][nodes]; - numberOfVelocityNodes = nodes; + implements neqsim.thermo.ThermodynamicConstantsInterface { + private static final long serialVersionUID = 1000; + + Matrix diffMatrix; + int iter = 0; + Matrix[] diff4Matrix; + double xNew[][]; + protected double oldMass[]; + protected double oldComp[]; + protected double oldDensity[]; + protected double oldVelocity[]; + protected double oldComposition[][]; + protected double oldInternalEnergy[]; + protected double oldImpuls[]; + protected double oldEnergy[]; + + /** + *

+ * Constructor for OnePhaseFixedStaggeredGrid. + *

+ */ + public OnePhaseFixedStaggeredGrid() {} + + /** + *

+ * Constructor for OnePhaseFixedStaggeredGrid. + *

+ * + * @param pipe a + * {@link neqsim.fluidMechanics.flowSystem.onePhaseFlowSystem.pipeFlowSystem.PipeFlowSystem} + * object + * @param length a double + * @param nodes a int + * @param dynamic a boolean + */ + public OnePhaseFixedStaggeredGrid( + neqsim.fluidMechanics.flowSystem.onePhaseFlowSystem.pipeFlowSystem.PipeFlowSystem pipe, + double length, int nodes, boolean dynamic) { + super(pipe, length, nodes); + this.dynamic = dynamic; + oldMass = new double[nodes]; + oldComp = new double[nodes]; + oldImpuls = new double[nodes]; + diff4Matrix = + new Matrix[pipe.getNode(0).getBulkSystem().getPhases()[0].getNumberOfComponents()]; + oldEnergy = new double[nodes]; + oldVelocity = new double[nodes]; + oldDensity = new double[nodes]; + oldInternalEnergy = new double[nodes]; + oldComposition = + new double[pipe.getNode(0).getBulkSystem().getPhases()[0].getNumberOfComponents()][nodes]; + numberOfVelocityNodes = nodes; + } + + /** {@inheritDoc} */ + @Override + public OnePhaseFixedStaggeredGrid clone() { + OnePhaseFixedStaggeredGrid clonedSystem = null; + try { + clonedSystem = (OnePhaseFixedStaggeredGrid) super.clone(); + } catch (Exception e) { + e.printStackTrace(System.err); } - /** {@inheritDoc} */ - @Override - public OnePhaseFixedStaggeredGrid clone() { - OnePhaseFixedStaggeredGrid clonedSystem = null; - try { - clonedSystem = (OnePhaseFixedStaggeredGrid) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); + return clonedSystem; + } + + /** + *

+ * initProfiles. + *

+ */ + public void initProfiles() { + double err = 0, oldPres = 0, dpdx = 0; + + do { + // pipe.getNode(0).setVelocityIn(pipe.getNode(0).getVelocity()); + err = 0; + pipe.getNode(0).initFlowCalc(); + pipe.getNode(0).init(); + pipe.getNode(0).setVelocityIn(pipe.getNode(0).getVelocity()); + for (int i = 0; i < numberOfNodes - 1; i++) { + // setting temperatures + pipe.getNode(i).init(); + pipe.getNode(i + 1).getBulkSystem().setTemperature((4.0 + * pipe.getNode(i).calcTotalHeatTransferCoefficient(0) + * (pipe.getNode(i).getGeometry().getSurroundingEnvironment().getTemperature() + - pipe.getNode(i).getBulkSystem().getPhases()[0].getTemperature()) + / (pipe.getNode(i).getBulkSystem().getPhases()[0].getCp() + / pipe.getNode(i).getBulkSystem().getPhases()[0].getNumberOfMolesInPhase() + / pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass() + * pipe.getNode(i + 1).getVelocity() + * pipe.getNode(i + 1).getGeometry().getDiameter() + * pipe.getNode(i + 1).getBulkSystem().getPhases()[0].getDensity()) + + pipe.getNode(i + 1).getBulkSystem().getPhases()[0].getJouleThomsonCoefficient() + * dpdx) + * (pipe.getNode(i + 1).getGeometry().getNodeLength() + + pipe.getNode(i).getGeometry().getNodeLength()) + * 0.5 + pipe.getNode(i).getBulkSystem().getTemperature()); + if (pipe.getNode(i + 1).getBulkSystem().getTemperature() < 10.5) { + pipe.getNode(i + 1).getBulkSystem().setTemperature(10.5); } - - return clonedSystem; + pipe.getNode(i + 1).initFlowCalc(); + pipe.getNode(i + 1).init(); + + // System.out.println("velocity " + pipe.getNode(i).getVelocity()); + // setting pressures + // System.out + // .println("presbef : " + pipe.getNode(i + 1).getBulkSystem().getPressure()); + oldPres = pipe.getNode(i + 1).getBulkSystem().getPressure(); + pipe.getNode(i + 1).getBulkSystem().setPressure(-pipe.getNode(i).getWallFrictionFactor() + * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() + * pipe.getNode(i).getVelocity() * pipe.getNode(i).getVelocity() + / pipe.getNode(i).getGeometry().getDiameter() / 2.0 + * (pipe.getNode(i).getGeometry().getNodeLength()) / 1e5 + - gravity * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() + * (pipe.getNode(i + 1).getVerticalPositionOfNode() + - pipe.getNode(i).getVerticalPositionOfNode()) + / 1e5 + + pipe.getNode(i).getBulkSystem().getPressure()); + // if(pipe.getNode(i+1).getBulkSystem().getPressure()<10.5) + // pipe.getNode(i+1).getBulkSystem().setPressure(1.0); + err += (oldPres - pipe.getNode(i + 1).getBulkSystem().getPressure()); + pipe.getNode(i + 1).initFlowCalc(); + pipe.getNode(i + 1).init(); + dpdx = (pipe.getNode(i + 1).getBulkSystem().getPressure() + - pipe.getNode(i).getBulkSystem().getPressure()) + / ((pipe.getNode(i + 1).getGeometry().getNodeLength() + + pipe.getNode(i).getGeometry().getNodeLength()) * 0.5); + /* + * System.out.println("pres : " + pipe.getNode(i + 1).getBulkSystem().getPressure()); + * System.out .println("temp : " + pipe.getNode(i + 1).getBulkSystem().getTemperature()); + * System.out.println("velocity : " + pipe.getNode(i + 1).getVelocity()); + * System.out.println("dpdx : " + dpdx); System.out .println("JT coeff : " + pipe.getNode(i + * + 1).getBulkSystem().getPhases()[0] .getJouleThomsonCoefficient()); + */ + // setting velocities + pipe.getNode(i + 1).setVelocityIn(pipe.getNode(i + 1).getVelocity()); + pipe.getNode(i + 1).setVelocity((pipe.getNode(i + 1).getVelocityIn().doubleValue())); + pipe.getNode(i + 1).init(); + } + // System.out.println("err: " + err); + } while (Math.abs(err) > 1); + initMatrix(); + } + + /** + *

+ * initMatrix. + *

+ */ + public void initMatrix() { + for (int i = 0; i < numberOfNodes; i++) { + pipe.getNode(i).init(); + double enthalpy = pipe.getNode(i).getBulkSystem().getPhases()[0].getEnthalpy() + / pipe.getNode(i).getBulkSystem().getPhases()[0].getNumberOfMolesInPhase() + / pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass(); + solMatrix.set(i, 0, pipe.getNode(i).getVelocityIn().doubleValue()); + sol3Matrix.set(i, 0, enthalpy); + sol2Matrix.set(i, 0, pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity()); + for (int j = 0; j < pipe.getNode(i).getBulkSystem().getPhases()[0] + .getNumberOfComponents(); j++) { + sol4Matrix[j].set(i, 0, + pipe.getNode(i).getBulkSystem().getPhases()[0].getComponents()[j].getx() + * pipe.getNode(i).getBulkSystem().getPhases()[0].getComponents()[j].getMolarMass() + / pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass()); + } } - - /** - *

- * initProfiles. - *

- */ - public void initProfiles() { - double err = 0, oldPres = 0, dpdx = 0; - - do { - // pipe.getNode(0).setVelocityIn(pipe.getNode(0).getVelocity()); - err = 0; - pipe.getNode(0).initFlowCalc(); - pipe.getNode(0).init(); - pipe.getNode(0).setVelocityIn(pipe.getNode(0).getVelocity()); - for (int i = 0; i < numberOfNodes - 1; i++) { - // setting temperatures - pipe.getNode(i).init(); - pipe.getNode(i + 1).getBulkSystem().setTemperature((4.0 - * pipe.getNode(i).calcTotalHeatTransferCoefficient(0) - * (pipe.getNode(i).getGeometry().getSurroundingEnvironment() - .getTemperature() - - pipe.getNode(i).getBulkSystem().getPhases()[0].getTemperature()) - / (pipe.getNode(i).getBulkSystem().getPhases()[0].getCp() - / pipe.getNode(i).getBulkSystem().getPhases()[0] - .getNumberOfMolesInPhase() - / pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass() - * pipe.getNode(i + 1).getVelocity() - * pipe.getNode(i + 1).getGeometry().getDiameter() - * pipe.getNode(i + 1).getBulkSystem().getPhases()[0].getDensity()) - + pipe.getNode(i + 1).getBulkSystem().getPhases()[0] - .getJouleThomsonCoefficient() * dpdx) - * (pipe.getNode(i + 1).getGeometry().getNodeLength() - + pipe.getNode(i).getGeometry().getNodeLength()) - * 0.5 + pipe.getNode(i).getBulkSystem().getTemperature()); - if (pipe.getNode(i + 1).getBulkSystem().getTemperature() < 10.5) { - pipe.getNode(i + 1).getBulkSystem().setTemperature(10.5); - } - pipe.getNode(i + 1).initFlowCalc(); - pipe.getNode(i + 1).init(); - - // System.out.println("velocity " + pipe.getNode(i).getVelocity()); - // setting pressures - // System.out - // .println("presbef : " + pipe.getNode(i + 1).getBulkSystem().getPressure()); - oldPres = pipe.getNode(i + 1).getBulkSystem().getPressure(); - pipe.getNode(i + 1).getBulkSystem() - .setPressure(-pipe.getNode(i).getWallFrictionFactor() - * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() - * pipe.getNode(i).getVelocity() * pipe.getNode(i).getVelocity() - / pipe.getNode(i).getGeometry().getDiameter() / 2.0 - * (pipe.getNode(i).getGeometry().getNodeLength()) / 1e5 - - gravity - * pipe.getNode(i).getBulkSystem().getPhases()[0] - .getDensity() - * (pipe.getNode(i + 1).getVerticalPositionOfNode() - - pipe.getNode(i).getVerticalPositionOfNode()) - / 1e5 - + pipe.getNode(i).getBulkSystem().getPressure()); - // if(pipe.getNode(i+1).getBulkSystem().getPressure()<10.5) - // pipe.getNode(i+1).getBulkSystem().setPressure(1.0); - err += (oldPres - pipe.getNode(i + 1).getBulkSystem().getPressure()); - pipe.getNode(i + 1).initFlowCalc(); - pipe.getNode(i + 1).init(); - dpdx = (pipe.getNode(i + 1).getBulkSystem().getPressure() - - pipe.getNode(i).getBulkSystem().getPressure()) - / ((pipe.getNode(i + 1).getGeometry().getNodeLength() - + pipe.getNode(i).getGeometry().getNodeLength()) * 0.5); - /* - * System.out.println("pres : " + pipe.getNode(i + - * 1).getBulkSystem().getPressure()); System.out .println("temp : " + pipe.getNode(i - * + 1).getBulkSystem().getTemperature()); System.out.println("velocity : " + - * pipe.getNode(i + 1).getVelocity()); System.out.println("dpdx : " + dpdx); - * System.out .println("JT coeff : " + pipe.getNode(i + - * 1).getBulkSystem().getPhases()[0] .getJouleThomsonCoefficient()); - */ - // setting velocities - pipe.getNode(i + 1).setVelocityIn(pipe.getNode(i + 1).getVelocity()); - pipe.getNode(i + 1) - .setVelocity((pipe.getNode(i + 1).getVelocityIn().doubleValue())); - pipe.getNode(i + 1).init(); - } - // System.out.println("err: " + err); - } while (Math.abs(err) > 1); - initMatrix(); + } + + /** + *

+ * initPressure. + *

+ * + * @param iteration a int + */ + public void initPressure(int iteration) { + for (int i = 0; i < numberOfNodes; i++) { + // if(dynamic) System.out.println(" old pressure " + + // pipe.getNode(i).getBulkSystem().getPressure()); + + pipe.getNode(i).getBulkSystem().setPressure( + pipe.getNode(i).getBulkSystem().getPhases()[0].getdPdrho() * diffMatrix.get(i, 0) * 1e-5 + + pipe.getNode(i).getBulkSystem().getPressure()); + pipe.getNode(i).init(); + // if(dynamic) System.out.println("i " + i +" diff 0 " +(diffMatrix.get(i, + // 0) ) + // + " new pressure " + pipe.getNode(i).getBulkSystem().getPressure()); } - - /** - *

- * initMatrix. - *

- */ - public void initMatrix() { - for (int i = 0; i < numberOfNodes; i++) { - pipe.getNode(i).init(); - double enthalpy = pipe.getNode(i).getBulkSystem().getPhases()[0].getEnthalpy() - / pipe.getNode(i).getBulkSystem().getPhases()[0].getNumberOfMolesInPhase() - / pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass(); - solMatrix.set(i, 0, pipe.getNode(i).getVelocityIn().doubleValue()); - sol3Matrix.set(i, 0, enthalpy); - sol2Matrix.set(i, 0, pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity()); - for (int j = 0; j < pipe.getNode(i).getBulkSystem().getPhases()[0] - .getNumberOfComponents(); j++) { - sol4Matrix[j].set(i, 0, - pipe.getNode(i).getBulkSystem().getPhases()[0].getComponents()[j].getx() - * pipe.getNode(i).getBulkSystem().getPhases()[0].getComponents()[j] - .getMolarMass() - / pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass()); - } - } + } + + /** + *

+ * initVelocity. + *

+ * + * @param iteration a int + */ + public void initVelocity(int iteration) { + for (int i = 0; i < numberOfNodes; i++) { + pipe.getNode(i).setVelocityIn(pipe.getNode(i).getVelocityIn().doubleValue() + + (solMatrix.get(i, 0) - pipe.getNode(i).getVelocityIn().doubleValue())); + // if(dynamic) System.out.println("i " + i +" diffvel 0 " +(solMatrix.get(i, + // 0) + // - pipe.getNode(i).getVelocityIn().doubleValue())); } - /** - *

- * initPressure. - *

- * - * @param iteration a int - */ - public void initPressure(int iteration) { - for (int i = 0; i < numberOfNodes; i++) { - // if(dynamic) System.out.println(" old pressure " + - // pipe.getNode(i).getBulkSystem().getPressure()); - - pipe.getNode(i).getBulkSystem() - .setPressure(pipe.getNode(i).getBulkSystem().getPhases()[0].getdPdrho() - * diffMatrix.get(i, 0) * 1e-5 - + pipe.getNode(i).getBulkSystem().getPressure()); - pipe.getNode(i).init(); - // if(dynamic) System.out.println("i " + i +" diff 0 " +(diffMatrix.get(i, - // 0) ) - // + " new pressure " + pipe.getNode(i).getBulkSystem().getPressure()); - } + for (int i = 0; i < numberOfNodes; i++) { + double meanVelocity = 0.0; + if (i == numberOfNodes - 1) { + meanVelocity = pipe.getNode(i).getVelocityIn().doubleValue(); + } else { + meanVelocity = (pipe.getNode(i).getVelocityIn().doubleValue() + + pipe.getNode(i).getVelocityOut().doubleValue()) / 2.0; + } + pipe.getNode(i).setVelocity(meanVelocity); + pipe.getNode(i).init(); } - /** - *

- * initVelocity. - *

- * - * @param iteration a int - */ - public void initVelocity(int iteration) { - for (int i = 0; i < numberOfNodes; i++) { - pipe.getNode(i).setVelocityIn(pipe.getNode(i).getVelocityIn().doubleValue() - + (solMatrix.get(i, 0) - pipe.getNode(i).getVelocityIn().doubleValue())); - // if(dynamic) System.out.println("i " + i +" diffvel 0 " +(solMatrix.get(i, - // 0) - // - pipe.getNode(i).getVelocityIn().doubleValue())); - } - - for (int i = 0; i < numberOfNodes; i++) { - double meanVelocity = 0.0; - if (i == numberOfNodes - 1) { - meanVelocity = pipe.getNode(i).getVelocityIn().doubleValue(); - } else { - meanVelocity = (pipe.getNode(i).getVelocityIn().doubleValue() - + pipe.getNode(i).getVelocityOut().doubleValue()) / 2.0; - } - pipe.getNode(i).setVelocity(meanVelocity); - pipe.getNode(i).init(); - } - - // if(dynamic){ - // pipe.getNode(numberOfNodes-1).setVelocity(0.001); - // pipe.getNode(numberOfNodes-1).init(); - // } + // if(dynamic){ + // pipe.getNode(numberOfNodes-1).setVelocity(0.001); + // pipe.getNode(numberOfNodes-1).init(); + // } + } + + /** + *

+ * initTemperature. + *

+ * + * @param iteration a int + */ + public void initTemperature(int iteration) { + for (int i = 0; i < numberOfNodes; i++) { + pipe.getNode(i).init(); + pipe.getNode(i).getBulkSystem() + .setTemperature(pipe.getNode(i).getBulkSystem().getTemperature() + + iteration * 1.0 / (10.0 + iteration) * diffMatrix.get(i, 0) + / (pipe.getNode(i).getBulkSystem().getPhases()[0].getCp() + / pipe.getNode(i).getBulkSystem().getPhases()[0].getNumberOfMolesInPhase() + / pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass())); + pipe.getNode(i).init(); + + // System.out.println("cp: " + + // (pipe.getNode(i).getBulkSystem().getPhases()[0].getCp()/pipe.getNode(i).getBulkSystem().getPhases()[0].getNumberOfMolesInPhase()/pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass())); } - - /** - *

- * initTemperature. - *

- * - * @param iteration a int - */ - public void initTemperature(int iteration) { - for (int i = 0; i < numberOfNodes; i++) { - pipe.getNode(i).init(); - pipe.getNode(i).getBulkSystem() - .setTemperature(pipe.getNode(i).getBulkSystem().getTemperature() - + iteration * 1.0 / (10.0 + iteration) * diffMatrix.get(i, 0) - / (pipe.getNode(i).getBulkSystem().getPhases()[0].getCp() - / pipe.getNode(i).getBulkSystem().getPhases()[0] - .getNumberOfMolesInPhase() - / pipe.getNode(i).getBulkSystem().getPhases()[0] - .getMolarMass())); - pipe.getNode(i).init(); - - // System.out.println("cp: " + - // (pipe.getNode(i).getBulkSystem().getPhases()[0].getCp()/pipe.getNode(i).getBulkSystem().getPhases()[0].getNumberOfMolesInPhase()/pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass())); - } + } + + /** + *

+ * initComposition. + *

+ * + * @param iter a int + */ + public void initComposition(int iter) { + for (int j = 1; j < numberOfNodes; j++) { + for (int p = 0; p < pipe.getNode(0).getBulkSystem().getPhases()[0] + .getNumberOfComponents(); p++) { + pipe.getNode(j).getBulkSystem().getPhases()[0].getComponents()[p].setx( + sol4Matrix[p].get(j, 0) * pipe.getNode(j).getBulkSystem().getPhases()[0].getMolarMass() + / pipe.getNode(j).getBulkSystem().getPhases()[0].getComponents()[p].getMolarMass());// pipe.getNode(j).getBulkSystem().getPhases()[0].getComponents()[p].getx() + // + + // 0.5*diff4Matrix[p].get(j,0)); + } + + pipe.getNode(j).getBulkSystem().getPhases()[0].normalize(); + pipe.getNode(j).init(); } - - /** - *

- * initComposition. - *

- * - * @param iter a int - */ - public void initComposition(int iter) { - for (int j = 1; j < numberOfNodes; j++) { - for (int p = 0; p < pipe.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents(); p++) { - pipe.getNode(j).getBulkSystem().getPhases()[0].getComponents()[p] - .setx(sol4Matrix[p].get(j, 0) - * pipe.getNode(j).getBulkSystem().getPhases()[0].getMolarMass() - / pipe.getNode(j).getBulkSystem().getPhases()[0].getComponents()[p] - .getMolarMass());// pipe.getNode(j).getBulkSystem().getPhases()[0].getComponents()[p].getx() - // + - // 0.5*diff4Matrix[p].get(j,0)); - } - - pipe.getNode(j).getBulkSystem().getPhases()[0].normalize(); - pipe.getNode(j).init(); - } + } + + /** + *

+ * setMassConservationMatrixTDMA. + *

+ */ + public void setMassConservationMatrixTDMA() { + if (!dynamic) { + double SU = 0; + a[0] = 0; + b[0] = 1.0; + c[0] = 0; + SU = pipe.getNode(0).getBulkSystem().getPhases()[0].getDensity(); + r[0] = SU; + } else { + double Ae = pipe.getNode(1).getGeometry().getArea(); + double Aw = pipe.getNode(0).getGeometry().getArea(); + double Fw = pipe.getNode(0).getVelocityIn().doubleValue() * Aw; + double Fe = oldVelocity[1] * Ae; + // System.out.println("new- old : " + + // (pipe.getNode(0).getVelocityIn().doubleValue() - oldVelocity[0])); + oldMass[0] = 1.0 / timeStep * pipe.getNode(0).getGeometry().getArea() + * pipe.getNode(0).getGeometry().getNodeLength(); + + a[0] = Math.max(Fw, 0); + c[0] = Math.max(-Fe, 0); + b[0] = a[0] + c[0] + (Fe - Fw) + oldMass[0]; + r[0] = oldMass[0] * oldDensity[0]; + + // setter ligningen paa rett form + // a[0] = - a[0]; + // c[0] = -c[0]; } - /** - *

- * setMassConservationMatrixTDMA. - *

- */ - public void setMassConservationMatrixTDMA() { - if (!dynamic) { - double SU = 0; - a[0] = 0; - b[0] = 1.0; - c[0] = 0; - SU = pipe.getNode(0).getBulkSystem().getPhases()[0].getDensity(); - r[0] = SU; - } else { - double Ae = pipe.getNode(1).getGeometry().getArea(); - double Aw = pipe.getNode(0).getGeometry().getArea(); - double Fw = pipe.getNode(0).getVelocityIn().doubleValue() * Aw; - double Fe = oldVelocity[1] * Ae; - // System.out.println("new- old : " + - // (pipe.getNode(0).getVelocityIn().doubleValue() - oldVelocity[0])); - oldMass[0] = 1.0 / timeStep * pipe.getNode(0).getGeometry().getArea() - * pipe.getNode(0).getGeometry().getNodeLength(); - - a[0] = Math.max(Fw, 0); - c[0] = Math.max(-Fe, 0); - b[0] = a[0] + c[0] + (Fe - Fw) + oldMass[0]; - r[0] = oldMass[0] * oldDensity[0]; - - // setter ligningen paa rett form - // a[0] = - a[0]; - // c[0] = -c[0]; - } - - for (int i = 1; i < numberOfNodes - 1; i++) { - double Ae = pipe.getNode(i).getGeometry().getArea(); - double Aw = pipe.getNode(i - 1).getGeometry().getArea(); - double Fe = pipe.getNode(i).getVelocityOut().doubleValue() * Ae; - double Fw = pipe.getNode(i).getVelocityIn().doubleValue() * Aw; - - if (dynamic) { - oldMass[i] = 1.0 / timeStep * pipe.getNode(i).getGeometry().getArea() - * pipe.getNode(i).getGeometry().getNodeLength(); - } else { - oldMass[i] = 0.0; - } - a[i] = Math.max(Fw, 0); - c[i] = Math.max(-Fe, 0); - b[i] = a[i] + c[i] + (Fe - Fw) + oldMass[i]; - r[i] = oldMass[i] * oldDensity[i]; - - // setter ligningen paa rett form - a[i] = -a[i]; - c[i] = -c[i]; - } + for (int i = 1; i < numberOfNodes - 1; i++) { + double Ae = pipe.getNode(i).getGeometry().getArea(); + double Aw = pipe.getNode(i - 1).getGeometry().getArea(); + double Fe = pipe.getNode(i).getVelocityOut().doubleValue() * Ae; + double Fw = pipe.getNode(i).getVelocityIn().doubleValue() * Aw; + + if (dynamic) { + oldMass[i] = 1.0 / timeStep * pipe.getNode(i).getGeometry().getArea() + * pipe.getNode(i).getGeometry().getNodeLength(); + } else { + oldMass[i] = 0.0; + } + a[i] = Math.max(Fw, 0); + c[i] = Math.max(-Fe, 0); + b[i] = a[i] + c[i] + (Fe - Fw) + oldMass[i]; + r[i] = oldMass[i] * oldDensity[i]; + + // setter ligningen paa rett form + a[i] = -a[i]; + c[i] = -c[i]; + } - int i = numberOfNodes - 1; - double Ae = pipe.getNode(i).getGeometry().getArea(); - double Aw = pipe.getNode(i - 1).getGeometry().getArea(); + int i = numberOfNodes - 1; + double Ae = pipe.getNode(i).getGeometry().getArea(); + double Aw = pipe.getNode(i - 1).getGeometry().getArea(); - double Fe = pipe.getNode(i).getVelocity() * Ae; - double Fw = pipe.getNode(i).getVelocityIn().doubleValue() * Aw; + double Fe = pipe.getNode(i).getVelocity() * Ae; + double Fw = pipe.getNode(i).getVelocityIn().doubleValue() * Aw; - if (dynamic) { - oldMass[i] = 1.0 / timeStep * pipe.getNode(i).getGeometry().getArea() - * pipe.getNode(i).getGeometry().getNodeLength(); - } else { - oldMass[i] = 0.0; - } - a[i] = Math.max(Fw, 0); - c[i] = Math.max(-Fe, 0); - b[i] = a[i] + c[i] + (Fe - Fw) + oldMass[i]; - r[i] = oldMass[i] * oldDensity[i]; - // setter ligningen paa rett form - a[i] = -a[i]; - c[i] = -c[i]; + if (dynamic) { + oldMass[i] = 1.0 / timeStep * pipe.getNode(i).getGeometry().getArea() + * pipe.getNode(i).getGeometry().getNodeLength(); + } else { + oldMass[i] = 0.0; + } + a[i] = Math.max(Fw, 0); + c[i] = Math.max(-Fe, 0); + b[i] = a[i] + c[i] + (Fe - Fw) + oldMass[i]; + r[i] = oldMass[i] * oldDensity[i]; + // setter ligningen paa rett form + a[i] = -a[i]; + c[i] = -c[i]; + } + + /** + *

+ * setImpulsMatrixTDMA. + *

+ */ + public void setImpulsMatrixTDMA() { + double SU = 0.0, SP = 0.0; + double Fw = 0.0, Fe = 0.0; + + // pipe.getNode(0).initFlowCalc(); + // pipe.getNode(0).init(); + // pipe.getNode(0).setVelocityIn(pipe.getNode(0).getVelocity()); + + a[0] = 0; + b[0] = 1.0; + c[0] = 0; + + r[0] = pipe.getNode(0).getVelocityIn().doubleValue(); + + a[1] = 0; + b[1] = 1.0; + c[1] = 0; + + r[1] = pipe.getNode(0).getVelocityIn().doubleValue(); + + for (int i = 2; i < numberOfNodes - 1; i++) { + double Ae = pipe.getNode(i).getGeometry().getArea(); + double Aw = pipe.getNode(i - 1).getGeometry().getArea(); + double Amean = pipe.getNode(i - 1).getGeometry().getArea(); + double meanDiameter = pipe.getNode(i - 1).getGeometry().getDiameter(); + double meanFrik = pipe.getNode(i - 1).getWallFrictionFactor(); + double meanDensity = (pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() + + pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getDensity()) / 2.0; + double oldMeanDensity = (oldDensity[i - 1] + oldDensity[i]) / 2.0; + double meanVelocity = + (pipe.getNode(i - 1).getVelocity() + pipe.getNode(i).getVelocity()) / 2.0; + double vertposchange = pipe.getNode(i).getVerticalPositionOfNode() + - pipe.getNode(i - 1).getVerticalPositionOfNode(); + double nodeLength = pipe.getNode(i - 1).getGeometry().getNodeLength(); + + SU = -Amean + * (pipe.getNode(i).getBulkSystem().getPressure() + - pipe.getNode(i - 1).getBulkSystem().getPressure()) + * 1e5 - Amean * gravity * meanDensity * vertposchange + + Amean * nodeLength * meanDensity * meanFrik / meanDiameter * meanVelocity + * Math.abs(meanVelocity) / 2.0; + SP = -Amean * nodeLength * meanDensity * meanFrik / meanDiameter * meanVelocity; + Fw = Aw * pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getDensity() + * (pipe.getNode(i - 1).getVelocityIn().doubleValue() + + pipe.getNode(i - 1).getVelocityOut().doubleValue()) + / 2.0; + Fe = Ae * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() + * (pipe.getNode(i).getVelocityIn().doubleValue() + + pipe.getNode(i).getVelocityOut().doubleValue()) + / 2.0; + + if (dynamic) { + oldImpuls[i] = 1.0 / timeStep * oldMeanDensity * nodeLength * Amean; + } else { + oldImpuls[i] = 0.0; + } + a[i] = Math.max(Fw, 0); + c[i] = Math.max(-Fe, 0);// - Fe/2.0; + + b[i] = a[i] + c[i] + (Fe - Fw) - SP + oldImpuls[i]; + // System.out.println("Fe-Fw: " +(Fe - Fw) + " Fe: " + Fe); + r[i] = SU + oldImpuls[i] * oldVelocity[i]; + // setter ligningen paa rett form + a[i] = -a[i]; + c[i] = -c[i]; } - /** - *

- * setImpulsMatrixTDMA. - *

- */ - public void setImpulsMatrixTDMA() { - double SU = 0.0, SP = 0.0; - double Fw = 0.0, Fe = 0.0; - - // pipe.getNode(0).initFlowCalc(); - // pipe.getNode(0).init(); - // pipe.getNode(0).setVelocityIn(pipe.getNode(0).getVelocity()); - - a[0] = 0; - b[0] = 1.0; - c[0] = 0; - - r[0] = pipe.getNode(0).getVelocityIn().doubleValue(); - - a[1] = 0; - b[1] = 1.0; - c[1] = 0; - - r[1] = pipe.getNode(0).getVelocityIn().doubleValue(); - - for (int i = 2; i < numberOfNodes - 1; i++) { - double Ae = pipe.getNode(i).getGeometry().getArea(); - double Aw = pipe.getNode(i - 1).getGeometry().getArea(); - double Amean = pipe.getNode(i - 1).getGeometry().getArea(); - double meanDiameter = pipe.getNode(i - 1).getGeometry().getDiameter(); - double meanFrik = pipe.getNode(i - 1).getWallFrictionFactor(); - double meanDensity = (pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() - + pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getDensity()) / 2.0; - double oldMeanDensity = (oldDensity[i - 1] + oldDensity[i]) / 2.0; - double meanVelocity = - (pipe.getNode(i - 1).getVelocity() + pipe.getNode(i).getVelocity()) / 2.0; - double vertposchange = pipe.getNode(i).getVerticalPositionOfNode() - - pipe.getNode(i - 1).getVerticalPositionOfNode(); - double nodeLength = pipe.getNode(i - 1).getGeometry().getNodeLength(); - - SU = -Amean - * (pipe.getNode(i).getBulkSystem().getPressure() - - pipe.getNode(i - 1).getBulkSystem().getPressure()) - * 1e5 - Amean * gravity * meanDensity * vertposchange - + Amean * nodeLength * meanDensity * meanFrik / meanDiameter * meanVelocity - * Math.abs(meanVelocity) / 2.0; - SP = -Amean * nodeLength * meanDensity * meanFrik / meanDiameter * meanVelocity; - Fw = Aw * pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getDensity() - * (pipe.getNode(i - 1).getVelocityIn().doubleValue() - + pipe.getNode(i - 1).getVelocityOut().doubleValue()) - / 2.0; - Fe = Ae * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() - * (pipe.getNode(i).getVelocityIn().doubleValue() - + pipe.getNode(i).getVelocityOut().doubleValue()) - / 2.0; - - if (dynamic) { - oldImpuls[i] = 1.0 / timeStep * oldMeanDensity * nodeLength * Amean; - } else { - oldImpuls[i] = 0.0; - } - a[i] = Math.max(Fw, 0); - c[i] = Math.max(-Fe, 0);// - Fe/2.0; - - b[i] = a[i] + c[i] + (Fe - Fw) - SP + oldImpuls[i]; - // System.out.println("Fe-Fw: " +(Fe - Fw) + " Fe: " + Fe); - r[i] = SU + oldImpuls[i] * oldVelocity[i]; - // setter ligningen paa rett form - a[i] = -a[i]; - c[i] = -c[i]; - } - - int i = numberOfNodes - 1; - double Ae = pipe.getNode(i).getGeometry().getArea(); - double Aw = pipe.getNode(i - 1).getGeometry().getArea(); - double Amean = pipe.getNode(i - 1).getGeometry().getArea(); - double meanDiameter = pipe.getNode(i - 1).getGeometry().getDiameter(); - double meanFrik = pipe.getNode(i - 1).getWallFrictionFactor(); - double meanDensity = pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getDensity(); - double oldMeanDensity = oldDensity[i - 1]; - double meanVelocity = pipe.getNode(i - 1).getVelocity(); - double vertposchange = pipe.getNode(i).getVerticalPositionOfNode() - - pipe.getNode(i - 1).getVerticalPositionOfNode(); - double nodeLength = pipe.getNode(i - 1).getGeometry().getNodeLength(); - - SU = -Amean - * (pipe.getNode(i).getBulkSystem().getPressure() - - pipe.getNode(i - 1).getBulkSystem().getPressure()) - * 1e5 - Amean * gravity * meanDensity * vertposchange - + Amean * nodeLength * meanDensity * meanFrik / meanDiameter * meanVelocity - * Math.abs(meanVelocity) / 2.0; - SP = -Amean * nodeLength * meanDensity * meanFrik / meanDiameter * meanVelocity; - Fw = Aw * pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getDensity() - * (pipe.getNode(i - 1).getVelocityIn().doubleValue() - + pipe.getNode(i - 1).getVelocityOut().doubleValue()) - / 2.0; - Fe = Ae * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() - * (pipe.getNode(i).getVelocityIn().doubleValue() - + pipe.getNode(i).getVelocityOut().doubleValue()) - / 2.0; - - if (dynamic) { - oldImpuls[i] = 1.0 / timeStep * oldMeanDensity * nodeLength * Amean; - } else { - oldImpuls[i] = 0.0; - } - a[i] = Math.max(Fw, 0); - c[i] = Math.max(-Fe, 0); - // if(dynamic){c[i] = - Fe/2.0; a[i] = Fw/2.0; } - b[i] = a[i] + c[i] + (Fe - Fw) - SP + oldImpuls[i]; - r[i] = SU + oldImpuls[i] * oldVelocity[i]; - - // setter ligningen paa rett form - a[numberOfNodes - 1] = -a[numberOfNodes - 1]; - c[numberOfNodes - 1] = -c[numberOfNodes - 1]; + int i = numberOfNodes - 1; + double Ae = pipe.getNode(i).getGeometry().getArea(); + double Aw = pipe.getNode(i - 1).getGeometry().getArea(); + double Amean = pipe.getNode(i - 1).getGeometry().getArea(); + double meanDiameter = pipe.getNode(i - 1).getGeometry().getDiameter(); + double meanFrik = pipe.getNode(i - 1).getWallFrictionFactor(); + double meanDensity = pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getDensity(); + double oldMeanDensity = oldDensity[i - 1]; + double meanVelocity = pipe.getNode(i - 1).getVelocity(); + double vertposchange = pipe.getNode(i).getVerticalPositionOfNode() + - pipe.getNode(i - 1).getVerticalPositionOfNode(); + double nodeLength = pipe.getNode(i - 1).getGeometry().getNodeLength(); + + SU = -Amean + * (pipe.getNode(i).getBulkSystem().getPressure() + - pipe.getNode(i - 1).getBulkSystem().getPressure()) + * 1e5 - Amean * gravity * meanDensity * vertposchange + + Amean * nodeLength * meanDensity * meanFrik / meanDiameter * meanVelocity + * Math.abs(meanVelocity) / 2.0; + SP = -Amean * nodeLength * meanDensity * meanFrik / meanDiameter * meanVelocity; + Fw = Aw * pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getDensity() + * (pipe.getNode(i - 1).getVelocityIn().doubleValue() + + pipe.getNode(i - 1).getVelocityOut().doubleValue()) + / 2.0; + Fe = Ae * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() + * (pipe.getNode(i).getVelocityIn().doubleValue() + + pipe.getNode(i).getVelocityOut().doubleValue()) + / 2.0; + + if (dynamic) { + oldImpuls[i] = 1.0 / timeStep * oldMeanDensity * nodeLength * Amean; + } else { + oldImpuls[i] = 0.0; + } + a[i] = Math.max(Fw, 0); + c[i] = Math.max(-Fe, 0); + // if(dynamic){c[i] = - Fe/2.0; a[i] = Fw/2.0; } + b[i] = a[i] + c[i] + (Fe - Fw) - SP + oldImpuls[i]; + r[i] = SU + oldImpuls[i] * oldVelocity[i]; + + // setter ligningen paa rett form + a[numberOfNodes - 1] = -a[numberOfNodes - 1]; + c[numberOfNodes - 1] = -c[numberOfNodes - 1]; + } + + /** + *

+ * setEnergyMatrixTDMA. + *

+ */ + public void setEnergyMatrixTDMA() { + a[0] = 0; + b[0] = 1.0; + c[0] = 0; + double SU = pipe.getNode(0).getBulkSystem().getPhases()[0].getEnthalpy() + / pipe.getNode(0).getBulkSystem().getPhases()[0].getNumberOfMolesInPhase() + / pipe.getNode(0).getBulkSystem().getPhases()[0].getMolarMass(); + r[0] = SU; + + for (int i = 1; i < numberOfNodes - 1; i++) { + double fe = pipe.getNode(i + 1).getGeometry().getNodeLength() + / (pipe.getNode(i).getGeometry().getNodeLength() + + pipe.getNode(i + 1).getGeometry().getNodeLength()); + double fw = pipe.getNode(i - 1).getGeometry().getNodeLength() + / (pipe.getNode(i).getGeometry().getNodeLength() + + pipe.getNode(i - 1).getGeometry().getNodeLength()); + double Ae = pipe.getNode(i).getGeometry().getArea(); + double Aw = pipe.getNode(i - 1).getGeometry().getArea(); + double vertposchange = (1 - fe) + * (pipe.getNode(i + 1).getVerticalPositionOfNode() + - pipe.getNode(i).getVerticalPositionOfNode()) + + (1 - fw) * (pipe.getNode(i).getVerticalPositionOfNode() + - pipe.getNode(i - 1).getVerticalPositionOfNode()); + + SU = -pipe.getNode(i).getGeometry().getArea() * gravity + * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() + * pipe.getNode(i).getVelocity() * vertposchange + + pipe.getNode(i).getGeometry().getArea() * 4.0 + * pipe.getNode(i).calcTotalHeatTransferCoefficient(0) + * (pipe.getNode(i).getGeometry().getSurroundingEnvironment().getTemperature() + - pipe.getNode(i).getBulkSystem().getTemperature()) + / (pipe.getNode(i).getGeometry().getDiameter()) + * pipe.getNode(i).getGeometry().getNodeLength(); + double SP = 0; + double Fw = Aw * pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getDensity() + * pipe.getNode(i).getVelocityIn().doubleValue(); + double Fe = Ae * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() + * pipe.getNode(i).getVelocityOut().doubleValue(); + + if (dynamic) { + oldEnergy[i] = + 1.0 / timeStep * oldDensity[i] * pipe.getNode(i).getGeometry().getNodeLength() + * pipe.getNode(i).getGeometry().getArea(); + } else { + oldEnergy[i] = 0.0; + } + a[i] = Math.max(Fw, 0); + c[i] = Math.max(-Fe, 0); + b[i] = a[i] + c[i] + (Fe - Fw) - SP + oldEnergy[i]; + r[i] = SU + oldEnergy[i] * oldInternalEnergy[i]; + + // setter ligningen paa rett form + a[i] = -a[i]; + c[i] = -c[i]; } - /** - *

- * setEnergyMatrixTDMA. - *

- */ - public void setEnergyMatrixTDMA() { - a[0] = 0; - b[0] = 1.0; - c[0] = 0; - double SU = pipe.getNode(0).getBulkSystem().getPhases()[0].getEnthalpy() - / pipe.getNode(0).getBulkSystem().getPhases()[0].getNumberOfMolesInPhase() - / pipe.getNode(0).getBulkSystem().getPhases()[0].getMolarMass(); - r[0] = SU; - - for (int i = 1; i < numberOfNodes - 1; i++) { - double fe = pipe.getNode(i + 1).getGeometry().getNodeLength() - / (pipe.getNode(i).getGeometry().getNodeLength() - + pipe.getNode(i + 1).getGeometry().getNodeLength()); - double fw = pipe.getNode(i - 1).getGeometry().getNodeLength() - / (pipe.getNode(i).getGeometry().getNodeLength() - + pipe.getNode(i - 1).getGeometry().getNodeLength()); - double Ae = pipe.getNode(i).getGeometry().getArea(); - double Aw = pipe.getNode(i - 1).getGeometry().getArea(); - double vertposchange = (1 - fe) - * (pipe.getNode(i + 1).getVerticalPositionOfNode() - - pipe.getNode(i).getVerticalPositionOfNode()) - + (1 - fw) * (pipe.getNode(i).getVerticalPositionOfNode() - - pipe.getNode(i - 1).getVerticalPositionOfNode()); - - SU = -pipe.getNode(i).getGeometry().getArea() * gravity - * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() - * pipe.getNode(i).getVelocity() * vertposchange - + pipe.getNode(i).getGeometry().getArea() * 4.0 - * pipe.getNode(i).calcTotalHeatTransferCoefficient(0) - * (pipe.getNode(i).getGeometry().getSurroundingEnvironment() - .getTemperature() - - pipe.getNode(i).getBulkSystem().getTemperature()) - / (pipe.getNode(i).getGeometry().getDiameter()) - * pipe.getNode(i).getGeometry().getNodeLength(); - double SP = 0; - double Fw = Aw * pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getDensity() - * pipe.getNode(i).getVelocityIn().doubleValue(); - double Fe = Ae * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() - * pipe.getNode(i).getVelocityOut().doubleValue(); - - if (dynamic) { - oldEnergy[i] = 1.0 / timeStep * oldDensity[i] - * pipe.getNode(i).getGeometry().getNodeLength() - * pipe.getNode(i).getGeometry().getArea(); - } else { - oldEnergy[i] = 0.0; - } - a[i] = Math.max(Fw, 0); - c[i] = Math.max(-Fe, 0); - b[i] = a[i] + c[i] + (Fe - Fw) - SP + oldEnergy[i]; - r[i] = SU + oldEnergy[i] * oldInternalEnergy[i]; - - // setter ligningen paa rett form - a[i] = -a[i]; - c[i] = -c[i]; - } + int i = numberOfNodes - 1; - int i = numberOfNodes - 1; + double fw = pipe.getNode(i - 1).getGeometry().getNodeLength() + / (pipe.getNode(i).getGeometry().getNodeLength() + + pipe.getNode(i - 1).getGeometry().getNodeLength()); + double Ae = pipe.getNode(i).getGeometry().getArea();// 1.0/((1.0-fe)/pipe.getNode(i).getGeometry().getArea() + // + + // fe/pipe.getNode(i+1).getGeometry().getArea()); - double fw = pipe.getNode(i - 1).getGeometry().getNodeLength() - / (pipe.getNode(i).getGeometry().getNodeLength() - + pipe.getNode(i - 1).getGeometry().getNodeLength()); - double Ae = pipe.getNode(i).getGeometry().getArea();// 1.0/((1.0-fe)/pipe.getNode(i).getGeometry().getArea() + double Aw = pipe.getNode(i - 1).getGeometry().getArea();// 1.0/((1.0-fw)/pipe.getNode(i).getGeometry().getArea() // + - // fe/pipe.getNode(i+1).getGeometry().getArea()); - - double Aw = pipe.getNode(i - 1).getGeometry().getArea();// 1.0/((1.0-fw)/pipe.getNode(i).getGeometry().getArea() - // + - // fw/pipe.getNode(i-1).getGeometry().getArea()); - - double vertposchange = (1 - fw) * (pipe.getNode(i).getVerticalPositionOfNode() - - pipe.getNode(i - 1).getVerticalPositionOfNode()); - - SU = -pipe.getNode(i).getGeometry().getArea() * gravity - * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() - * pipe.getNode(i).getVelocity() * vertposchange - + pipe.getNode(i).getGeometry().getArea() * 4.0 - * pipe.getNode(i).calcTotalHeatTransferCoefficient(0) - * (pipe.getNode(i).getGeometry().getSurroundingEnvironment() - .getTemperature() - - pipe.getNode(i).getBulkSystem().getTemperature()) - / (pipe.getNode(i).getGeometry().getDiameter()) - * pipe.getNode(i).getGeometry().getNodeLength(); - double SP = 0;// -pipe.getNode(i).getGeometry().getArea()*4.0*12.0/(pipe.getNode(i).getGeometry().getDiameter())*pipe.getNode(i).getGeometry().getNodeLength(); - - double Fw = Aw * pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getDensity() - * pipe.getNode(i).getVelocityIn().doubleValue(); - double Fe = Ae * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() - * pipe.getNode(i).getVelocity(); - - if (dynamic) { - oldEnergy[i] = - 1.0 / timeStep * oldDensity[i] * pipe.getNode(i).getGeometry().getNodeLength() - * pipe.getNode(i).getGeometry().getArea(); - } else { - oldEnergy[i] = 0.0; - } - a[i] = Math.max(Fw, 0); - c[i] = Math.max(-Fe, 0); - b[i] = a[i] + c[i] + (Fe - Fw) - SP + oldEnergy[i]; - r[i] = SU + oldEnergy[i] * oldInternalEnergy[i]; - a[i] = -a[i]; - c[i] = -c[i]; + // fw/pipe.getNode(i-1).getGeometry().getArea()); + + double vertposchange = (1 - fw) * (pipe.getNode(i).getVerticalPositionOfNode() + - pipe.getNode(i - 1).getVerticalPositionOfNode()); + + SU = -pipe.getNode(i).getGeometry().getArea() * gravity + * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() + * pipe.getNode(i).getVelocity() * vertposchange + + pipe.getNode(i).getGeometry().getArea() * 4.0 + * pipe.getNode(i).calcTotalHeatTransferCoefficient(0) + * (pipe.getNode(i).getGeometry().getSurroundingEnvironment().getTemperature() + - pipe.getNode(i).getBulkSystem().getTemperature()) + / (pipe.getNode(i).getGeometry().getDiameter()) + * pipe.getNode(i).getGeometry().getNodeLength(); + double SP = 0;// -pipe.getNode(i).getGeometry().getArea()*4.0*12.0/(pipe.getNode(i).getGeometry().getDiameter())*pipe.getNode(i).getGeometry().getNodeLength(); + + double Fw = Aw * pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getDensity() + * pipe.getNode(i).getVelocityIn().doubleValue(); + double Fe = Ae * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() + * pipe.getNode(i).getVelocity(); + + if (dynamic) { + oldEnergy[i] = 1.0 / timeStep * oldDensity[i] * pipe.getNode(i).getGeometry().getNodeLength() + * pipe.getNode(i).getGeometry().getArea(); + } else { + oldEnergy[i] = 0.0; } - - /** - *

- * setComponentConservationMatrix. - *

- * - * @param componentNumber a int - */ - public void setComponentConservationMatrix(int componentNumber) { - double SU = 0; - a[0] = 0; - b[0] = 1.0; - c[0] = 0; - SU = pipe.getNode(0).getBulkSystem().getPhases()[0].getComponents()[componentNumber].getx() - * pipe.getNode(0).getBulkSystem().getPhases()[0].getComponents()[componentNumber] - .getMolarMass() - / pipe.getNode(0).getBulkSystem().getPhases()[0].getMolarMass(); - r[0] = SU; - - for (int i = 1; i < numberOfNodes - 1; i++) { - double Ae = pipe.getNode(i).getGeometry().getArea(); - double Aw = pipe.getNode(i - 1).getGeometry().getArea(); - - double Fe = pipe.getNode(i).getVelocityOut().doubleValue() - * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() * Ae; - double Fw = pipe.getNode(i).getVelocityIn().doubleValue() - * pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getDensity() * Aw; - // System.out.println("vel: " + - // pipe.getNode(i).getVelocityOut(phase).doubleValue() + " fe " + Fe); - if (dynamic) { - oldComp[i] = 1.0 / timeStep * pipe.getNode(i).getGeometry().getArea() - * pipe.getNode(i).getGeometry().getNodeLength() - * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity(); - } else { - oldComp[i] = 0.0; - } - a[i] = Math.max(Fw, 0); - c[i] = Math.max(-Fe, 0); - b[i] = a[i] + c[i] + (Fe - Fw) + oldComp[i]; - r[i] = oldComp[i] * oldComposition[componentNumber][i]; - - // setter ligningen paa rett form - a[i] = -a[i]; - c[i] = -c[i]; - } - - int i = numberOfNodes - 1; - // double fw = - // pipe.getNode(i-1).getGeometry().getNodeLength()/(pipe.getNode(i).getGeometry().getNodeLength()+pipe.getNode(i-1).getGeometry().getNodeLength()); - double Ae = pipe.getNode(i).getGeometry().getArea(); - double Aw = pipe.getNode(i - 1).getGeometry().getArea(); - - double Fe = pipe.getNode(i).getVelocity() - * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() * Ae; - double Fw = pipe.getNode(i).getVelocityIn().doubleValue() - * pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getDensity() * Aw; - - if (dynamic) { - oldComp[i] = 1.0 / timeStep * pipe.getNode(i).getGeometry().getArea() - * pipe.getNode(i).getGeometry().getNodeLength() - * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity(); - } else { - oldComp[i] = 0.0; - } - a[i] = Math.max(Fw, 0); - c[i] = Math.max(-Fe, 0); - b[i] = a[i] + c[i] + (Fe - Fw) + oldComp[i]; - r[i] = oldComp[i] * oldComposition[componentNumber][i]; - // setter ligningen paa rett form - a[i] = -a[i]; - c[i] = -c[i]; + a[i] = Math.max(Fw, 0); + c[i] = Math.max(-Fe, 0); + b[i] = a[i] + c[i] + (Fe - Fw) - SP + oldEnergy[i]; + r[i] = SU + oldEnergy[i] * oldInternalEnergy[i]; + a[i] = -a[i]; + c[i] = -c[i]; + } + + /** + *

+ * setComponentConservationMatrix. + *

+ * + * @param componentNumber a int + */ + public void setComponentConservationMatrix(int componentNumber) { + double SU = 0; + a[0] = 0; + b[0] = 1.0; + c[0] = 0; + SU = pipe.getNode(0).getBulkSystem().getPhases()[0].getComponents()[componentNumber].getx() + * pipe.getNode(0).getBulkSystem().getPhases()[0].getComponents()[componentNumber] + .getMolarMass() + / pipe.getNode(0).getBulkSystem().getPhases()[0].getMolarMass(); + r[0] = SU; + + for (int i = 1; i < numberOfNodes - 1; i++) { + double Ae = pipe.getNode(i).getGeometry().getArea(); + double Aw = pipe.getNode(i - 1).getGeometry().getArea(); + + double Fe = pipe.getNode(i).getVelocityOut().doubleValue() + * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() * Ae; + double Fw = pipe.getNode(i).getVelocityIn().doubleValue() + * pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getDensity() * Aw; + // System.out.println("vel: " + + // pipe.getNode(i).getVelocityOut(phase).doubleValue() + " fe " + Fe); + if (dynamic) { + oldComp[i] = 1.0 / timeStep * pipe.getNode(i).getGeometry().getArea() + * pipe.getNode(i).getGeometry().getNodeLength() + * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity(); + } else { + oldComp[i] = 0.0; + } + a[i] = Math.max(Fw, 0); + c[i] = Math.max(-Fe, 0); + b[i] = a[i] + c[i] + (Fe - Fw) + oldComp[i]; + r[i] = oldComp[i] * oldComposition[componentNumber][i]; + + // setter ligningen paa rett form + a[i] = -a[i]; + c[i] = -c[i]; } - /** - *

- * initFinalResults. - *

- */ - public void initFinalResults() { - for (int i = 0; i < numberOfNodes; i++) { - oldVelocity[i] = pipe.getNode(i).getVelocityIn().doubleValue(); - oldDensity[i] = pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity(); - oldInternalEnergy[i] = pipe.getNode(i).getBulkSystem().getPhases()[0].getEnthalpy() - / pipe.getNode(i).getBulkSystem().getPhases()[0].getNumberOfMolesInPhase() - / pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass(); - - for (int j = 0; j < pipe.getNode(i).getBulkSystem().getPhases()[0] - .getNumberOfComponents(); j++) { - oldComposition[j][i] = sol4Matrix[j].get(i, 0); // pipe.getNode(i).getBulkSystem().getPhases()[0].getComponents()[j].getx() - // * - // pipe.getNode(i).getBulkSystem().getPhases()[0].getComponents()[j].getMolarMass()/pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass(); - } - } + int i = numberOfNodes - 1; + // double fw = + // pipe.getNode(i-1).getGeometry().getNodeLength()/(pipe.getNode(i).getGeometry().getNodeLength()+pipe.getNode(i-1).getGeometry().getNodeLength()); + double Ae = pipe.getNode(i).getGeometry().getArea(); + double Aw = pipe.getNode(i - 1).getGeometry().getArea(); + + double Fe = pipe.getNode(i).getVelocity() + * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() * Ae; + double Fw = pipe.getNode(i).getVelocityIn().doubleValue() + * pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getDensity() * Aw; + + if (dynamic) { + oldComp[i] = 1.0 / timeStep * pipe.getNode(i).getGeometry().getArea() + * pipe.getNode(i).getGeometry().getNodeLength() + * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity(); + } else { + oldComp[i] = 0.0; + } + a[i] = Math.max(Fw, 0); + c[i] = Math.max(-Fe, 0); + b[i] = a[i] + c[i] + (Fe - Fw) + oldComp[i]; + r[i] = oldComp[i] * oldComposition[componentNumber][i]; + // setter ligningen paa rett form + a[i] = -a[i]; + c[i] = -c[i]; + } + + /** + *

+ * initFinalResults. + *

+ */ + public void initFinalResults() { + for (int i = 0; i < numberOfNodes; i++) { + oldVelocity[i] = pipe.getNode(i).getVelocityIn().doubleValue(); + oldDensity[i] = pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity(); + oldInternalEnergy[i] = pipe.getNode(i).getBulkSystem().getPhases()[0].getEnthalpy() + / pipe.getNode(i).getBulkSystem().getPhases()[0].getNumberOfMolesInPhase() + / pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass(); + + for (int j = 0; j < pipe.getNode(i).getBulkSystem().getPhases()[0] + .getNumberOfComponents(); j++) { + oldComposition[j][i] = sol4Matrix[j].get(i, 0); // pipe.getNode(i).getBulkSystem().getPhases()[0].getComponents()[j].getx() + // * + // pipe.getNode(i).getBulkSystem().getPhases()[0].getComponents()[j].getMolarMass()/pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass(); + } + } + } + + /** {@inheritDoc} */ + @Override + public void solveTDMA() { + double d[]; + int iter = 0, iterTop = 0; + double maxDiff = 1.0; + double diff = 0; + xNew = new double[pipe.getNode(0).getBulkSystem().getPhases()[0] + .getNumberOfComponents()][numberOfNodes]; + if (!dynamic) { + initProfiles(); } + initMatrix(); - /** {@inheritDoc} */ - @Override - public void solveTDMA() { - double d[]; - int iter = 0, iterTop = 0; - double maxDiff = 1.0; - double diff = 0; - xNew = new double[pipe.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents()][numberOfNodes]; - if (!dynamic) { - initProfiles(); - } - initMatrix(); + do { + maxDiff = 0; + iterTop++; + iter = 0; + if (this.solverType >= 0) { do { - maxDiff = 0; - iterTop++; - - iter = 0; - if (this.solverType >= 0) { - do { - maxDiff = 0; - do { - iter++; - setImpulsMatrixTDMA(); - Matrix solOld = solMatrix.copy(); - d = TDMAsolve.solve(a, b, c, r); - solMatrix = new Matrix(d, 1).transpose(); - diffMatrix = solMatrix.minus(solOld); - // if(dynamic) solMatrix.print(10,10); - - // System.out.println("diff1: "); - // diffMatrix.print(10,10); - // System.out.println("diff1: "+ - // diffMatrix.norm1()/solMatrix.norm1()); - initVelocity(iter); - - diff = Math.abs(diffMatrix.norm1() / solMatrix.norm1()); - if (diff > maxDiff) { - maxDiff = diff; - } - } while (diff > 1e-15 && iter < 10); - - if (solverType > 0) { - iter = 0; - do { - iter++; - // System.out.println("iter: " +iter); - setMassConservationMatrixTDMA(); - d = TDMAsolve.solve(a, b, c, r); - Matrix sol2Old = sol2Matrix.copy(); - // sol2Matrix.print(10,10); - sol2Matrix = new Matrix(d, 1).transpose(); - diffMatrix = sol2Matrix.minus(sol2Old); - // System.out.println("diff2: - // "+diffMatrix.norm1()/sol2Matrix.norm1()); - initPressure(iter); - diff = Math.abs(diffMatrix.norm1() / sol2Matrix.norm1()); - if (diff > maxDiff) { - maxDiff = diff; - } - } while (diff > 1e-15 && iter < 10); - } - // System.out.println("max diff " + maxDiff); - } while (Math.abs(maxDiff) > 1e-10); + maxDiff = 0; + do { + iter++; + setImpulsMatrixTDMA(); + Matrix solOld = solMatrix.copy(); + d = TDMAsolve.solve(a, b, c, r); + solMatrix = new Matrix(d, 1).transpose(); + diffMatrix = solMatrix.minus(solOld); + // if(dynamic) solMatrix.print(10,10); + + // System.out.println("diff1: "); + // diffMatrix.print(10,10); + // System.out.println("diff1: "+ + // diffMatrix.norm1()/solMatrix.norm1()); + initVelocity(iter); + + diff = Math.abs(diffMatrix.norm1() / solMatrix.norm1()); + if (diff > maxDiff) { + maxDiff = diff; } + } while (diff > 1e-15 && iter < 10); - if (this.solverType >= 10) { - iter = 0; - do { - iter++; - Matrix sol3Old = sol3Matrix.copy(); - setEnergyMatrixTDMA(); - d = TDMAsolve.solve(a, b, c, r); - sol3Matrix = new Matrix(d, 1).transpose(); - diffMatrix = sol3Matrix.minus(sol3Old); - // System.out.println("diff3: " + diffMatrix.norm1() / sol3Matrix.norm1()); - initTemperature(iter); - - diff = Math.abs(diffMatrix.norm1() / sol3Matrix.norm1()); - if (diff > maxDiff) { - maxDiff = diff; - } - } while (diff > 1e-15 && iter < 10); - } - - if (this.solverType >= 20) { - iter = 0; - do { - iter++; - for (int p = 0; p < pipe.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents(); p++) { - setComponentConservationMatrix(p); - Matrix sol4Old = sol4Matrix[p].copy(); - xNew[p] = TDMAsolve.solve(a, b, c, r); - sol4Matrix[p] = new Matrix(xNew[p], 1).transpose(); - diff4Matrix[p] = sol4Matrix[p].minus(sol4Old); - diff = Math.abs(diff4Matrix[p].norm1() / (sol4Matrix[p].norm1())); - if (diff > maxDiff) { - maxDiff = diff; - } - } - initComposition(iter); - // solMatrix.print(10,10); - } while (diff > 1e-15 && iter < 10); + if (solverType > 0) { + iter = 0; + do { + iter++; + // System.out.println("iter: " +iter); + setMassConservationMatrixTDMA(); + d = TDMAsolve.solve(a, b, c, r); + Matrix sol2Old = sol2Matrix.copy(); + // sol2Matrix.print(10,10); + sol2Matrix = new Matrix(d, 1).transpose(); + diffMatrix = sol2Matrix.minus(sol2Old); + // System.out.println("diff2: + // "+diffMatrix.norm1()/sol2Matrix.norm1()); + initPressure(iter); + diff = Math.abs(diffMatrix.norm1() / sol2Matrix.norm1()); + if (diff > maxDiff) { + maxDiff = diff; + } + } while (diff > 1e-15 && iter < 10); + } + // System.out.println("max diff " + maxDiff); + } while (Math.abs(maxDiff) > 1e-10); + } + + if (this.solverType >= 10) { + iter = 0; + do { + iter++; + Matrix sol3Old = sol3Matrix.copy(); + setEnergyMatrixTDMA(); + d = TDMAsolve.solve(a, b, c, r); + sol3Matrix = new Matrix(d, 1).transpose(); + diffMatrix = sol3Matrix.minus(sol3Old); + // System.out.println("diff3: " + diffMatrix.norm1() / sol3Matrix.norm1()); + initTemperature(iter); + + diff = Math.abs(diffMatrix.norm1() / sol3Matrix.norm1()); + if (diff > maxDiff) { + maxDiff = diff; + } + } while (diff > 1e-15 && iter < 10); + } + + if (this.solverType >= 20) { + iter = 0; + do { + iter++; + for (int p = 0; p < pipe.getNode(0).getBulkSystem().getPhases()[0] + .getNumberOfComponents(); p++) { + setComponentConservationMatrix(p); + Matrix sol4Old = sol4Matrix[p].copy(); + xNew[p] = TDMAsolve.solve(a, b, c, r); + sol4Matrix[p] = new Matrix(xNew[p], 1).transpose(); + diff4Matrix[p] = sol4Matrix[p].minus(sol4Old); + diff = Math.abs(diff4Matrix[p].norm1() / (sol4Matrix[p].norm1())); + if (diff > maxDiff) { + maxDiff = diff; } + } + initComposition(iter); + // solMatrix.print(10,10); + } while (diff > 1e-15 && iter < 10); + } - // System.out.println("maxDiff " + maxDiff); - } while (Math.abs(maxDiff) > 1e-10 && iterTop < 100);// diffMatrix.norm2()/sol2Matrix.norm2())>0.1); + // System.out.println("maxDiff " + maxDiff); + } while (Math.abs(maxDiff) > 1e-10 && iterTop < 100);// diffMatrix.norm2()/sol2Matrix.norm2())>0.1); - initFinalResults(); - } + initFinalResults(); + } } diff --git a/src/main/java/neqsim/fluidMechanics/flowSolver/onePhaseFlowSolver/onePhasePipeFlowSolver/OnePhasePipeFlowSolver.java b/src/main/java/neqsim/fluidMechanics/flowSolver/onePhaseFlowSolver/onePhasePipeFlowSolver/OnePhasePipeFlowSolver.java index 2d004b642b..e89f383188 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSolver/onePhaseFlowSolver/onePhasePipeFlowSolver/OnePhasePipeFlowSolver.java +++ b/src/main/java/neqsim/fluidMechanics/flowSolver/onePhaseFlowSolver/onePhasePipeFlowSolver/OnePhasePipeFlowSolver.java @@ -3,6 +3,7 @@ * * Created on 17. januar 2001, 21:05 */ + package neqsim.fluidMechanics.flowSolver.onePhaseFlowSolver.onePhasePipeFlowSolver; import Jama.Matrix; @@ -17,69 +18,68 @@ * @version $Id: $Id */ public class OnePhasePipeFlowSolver - extends neqsim.fluidMechanics.flowSolver.onePhaseFlowSolver.OnePhaseFlowSolver { - private static final long serialVersionUID = 1000; + extends neqsim.fluidMechanics.flowSolver.onePhaseFlowSolver.OnePhaseFlowSolver { + private static final long serialVersionUID = 1000; - protected double[] PbArray; // = new double[100]; - protected Matrix solMatrix; - protected Matrix sol2Matrix; - protected Matrix sol3Matrix; - protected Matrix[] sol4Matrix; - protected double a[]; - protected double b[]; - protected double c[]; - protected double r[]; - protected double length; - protected PipeFlowSystem pipe; + protected double[] PbArray; // = new double[100]; + protected Matrix solMatrix; + protected Matrix sol2Matrix; + protected Matrix sol3Matrix; + protected Matrix[] sol4Matrix; + protected double a[]; + protected double b[]; + protected double c[]; + protected double r[]; + protected double length; + protected PipeFlowSystem pipe; - /** - *

- * Constructor for OnePhasePipeFlowSolver. - *

- */ - public OnePhasePipeFlowSolver() {} + /** + *

+ * Constructor for OnePhasePipeFlowSolver. + *

+ */ + public OnePhasePipeFlowSolver() {} - /** - *

- * Constructor for OnePhasePipeFlowSolver. - *

- * - * @param pipe a - * {@link neqsim.fluidMechanics.flowSystem.onePhaseFlowSystem.pipeFlowSystem.PipeFlowSystem} - * object - * @param length a double - * @param nodes a int - */ - public OnePhasePipeFlowSolver(PipeFlowSystem pipe, double length, int nodes) { - this.pipe = pipe; - this.length = length; - this.numberOfNodes = nodes; - PbArray = new double[nodes]; - solMatrix = new Matrix(PbArray, 1).transpose(); - sol2Matrix = new Matrix(PbArray, 1).transpose(); - sol3Matrix = new Matrix(PbArray, 1).transpose(); - sol4Matrix = - new Matrix[pipe.getNode(0).getBulkSystem().getPhases()[0].getNumberOfComponents()]; - for (int k = 0; k < pipe.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents(); k++) { - sol4Matrix[k] = new Matrix(PbArray, 1).transpose(); - } - a = new double[nodes]; - b = new double[nodes]; - c = new double[nodes]; - r = new double[nodes]; + /** + *

+ * Constructor for OnePhasePipeFlowSolver. + *

+ * + * @param pipe a + * {@link neqsim.fluidMechanics.flowSystem.onePhaseFlowSystem.pipeFlowSystem.PipeFlowSystem} + * object + * @param length a double + * @param nodes a int + */ + public OnePhasePipeFlowSolver(PipeFlowSystem pipe, double length, int nodes) { + this.pipe = pipe; + this.length = length; + this.numberOfNodes = nodes; + PbArray = new double[nodes]; + solMatrix = new Matrix(PbArray, 1).transpose(); + sol2Matrix = new Matrix(PbArray, 1).transpose(); + sol3Matrix = new Matrix(PbArray, 1).transpose(); + sol4Matrix = new Matrix[pipe.getNode(0).getBulkSystem().getPhases()[0].getNumberOfComponents()]; + for (int k = 0; k < pipe.getNode(0).getBulkSystem().getPhases()[0] + .getNumberOfComponents(); k++) { + sol4Matrix[k] = new Matrix(PbArray, 1).transpose(); } + a = new double[nodes]; + b = new double[nodes]; + c = new double[nodes]; + r = new double[nodes]; + } - /** {@inheritDoc} */ - @Override - public OnePhasePipeFlowSolver clone() { - OnePhasePipeFlowSolver clonedSystem = null; - try { - clonedSystem = (OnePhasePipeFlowSolver) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); - } - - return clonedSystem; + /** {@inheritDoc} */ + @Override + public OnePhasePipeFlowSolver clone() { + OnePhasePipeFlowSolver clonedSystem = null; + try { + clonedSystem = (OnePhasePipeFlowSolver) super.clone(); + } catch (Exception e) { + e.printStackTrace(System.err); } + + return clonedSystem; + } } diff --git a/src/main/java/neqsim/fluidMechanics/geometryDefinitions/GeometryDefinition.java b/src/main/java/neqsim/fluidMechanics/geometryDefinitions/GeometryDefinition.java index 8bba40dd37..8b19e21ddc 100644 --- a/src/main/java/neqsim/fluidMechanics/geometryDefinitions/GeometryDefinition.java +++ b/src/main/java/neqsim/fluidMechanics/geometryDefinitions/GeometryDefinition.java @@ -3,6 +3,7 @@ * * Created on 10. desember 2000, 18:47 */ + package neqsim.fluidMechanics.geometryDefinitions; import neqsim.fluidMechanics.geometryDefinitions.internalGeometry.packings.PackingInterface; @@ -19,222 +20,222 @@ * @version $Id: $Id */ public abstract class GeometryDefinition - implements GeometryDefinitionInterface, neqsim.thermo.ThermodynamicConstantsInterface { - private static final long serialVersionUID = 1000; - - /** {@inheritDoc} */ - @Override - public SurroundingEnvironment getSurroundingEnvironment() { - return surroundingEnvironment; - } - - /** {@inheritDoc} */ - @Override - public void setSurroundingEnvironment(SurroundingEnvironment surroundingEnvironment) { - this.surroundingEnvironment = surroundingEnvironment; - } - - /** - *

- * Getter for the field wall. - *

- * - * @return the wall - */ - public Wall getWall() { - return wall; - } - - /** - *

- * Setter for the field wall. - *

- * - * @param wall the wall to set - */ - public void setWall(Wall wall) { - this.wall = wall; - } - - double wallHeatTransferCoefficient = 20.0; - private double innerWallTemperature = 276.5; - protected PackingInterface packing = null; - - public double diameter = 0, radius = 0, innerSurfaceRoughness = 0.000005, nodeLength = 0, - area = 0, relativeRoughnes = 0; - public double[] layerConductivity, layerThickness; - - public Wall wall = new Wall(); - - private SurroundingEnvironment surroundingEnvironment = new SurroundingEnvironmentBaseClass(); - - /** - * * - *

- * Constructor for GeometryDefinition. - *

- */ - public GeometryDefinition() {} - - /** - *

- * Constructor for GeometryDefinition. - *

- * - * @param diameter a double - */ - public GeometryDefinition(double diameter) { - this.diameter = diameter; - this.radius = diameter / 2.0; - this.area = pi * Math.pow(radius, 2); - } - - /** - *

- * Constructor for GeometryDefinition. - *

- * - * @param diameter a double - * @param roughness a double - */ - public GeometryDefinition(double diameter, double roughness) { - this(diameter); - this.relativeRoughnes = roughness / diameter; - this.innerSurfaceRoughness = roughness; - } - - /** {@inheritDoc} */ - @Override - public GeometryDefinitionInterface clone() { - GeometryDefinitionInterface clonedGeometry = null; - try { - clonedGeometry = (GeometryDefinition) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); - } - - return clonedGeometry; - } - - /** {@inheritDoc} */ - @Override - public void setNodeLength(double nodeLength) { - this.nodeLength = nodeLength; - } - - /** {@inheritDoc} */ - @Override - public void setInnerSurfaceRoughness(double innerSurfaceRoughness) { - this.innerSurfaceRoughness = innerSurfaceRoughness; - } - - /** {@inheritDoc} */ - @Override - public void init() { - this.radius = diameter / 2.0; - this.area = pi * Math.pow(radius, 2.0); - this.relativeRoughnes = innerSurfaceRoughness / diameter; - } - - /** {@inheritDoc} */ - @Override - public void setDiameter(double diameter) { - this.diameter = diameter; - this.radius = diameter / 2.0; - this.area = pi * Math.pow(radius, 2); - } - - /** {@inheritDoc} */ - @Override - public double getWallHeatTransferCoefficient() { - return wall.getHeatTransferCoefficient(); - } - - /** {@inheritDoc} */ - @Override - public double getDiameter() { - return diameter; - } - - /** {@inheritDoc} */ - @Override - public double getArea() { - return area; - } - - /** {@inheritDoc} */ - @Override - public double getRadius() { - return radius; - } - - /** {@inheritDoc} */ - @Override - public double getInnerSurfaceRoughness() { - return innerSurfaceRoughness; - } - - /** {@inheritDoc} */ - @Override - public double getRelativeRoughnes() { - return relativeRoughnes; - } - - /** {@inheritDoc} */ - @Override - public double getRelativeRoughnes(double diameter) { - return innerSurfaceRoughness / diameter; - } - - /** {@inheritDoc} */ - @Override - public double getCircumference() { - return 2 * pi * radius; - } - - /** {@inheritDoc} */ - @Override - public double getNodeLength() { - return nodeLength; - } - - /** {@inheritDoc} */ - @Override - public GeometryDefinitionInterface getGeometry() { - return this; - } - - /** {@inheritDoc} */ - @Override - public void setPackingType(int i) {} - - /** {@inheritDoc} */ - @Override - public void setPackingType(String name, String material, int size) { - System.out.println("error - packing set in Geometry definition class"); - } - - /** {@inheritDoc} */ - @Override - public PackingInterface getPacking() { - return packing; - } - - /** {@inheritDoc} */ - @Override - public double getInnerWallTemperature() { - return innerWallTemperature; - } - - /** {@inheritDoc} */ - @Override - public void setInnerWallTemperature(double temperature) { - this.innerWallTemperature = temperature; - } - - /** {@inheritDoc} */ - @Override - public void setWallHeatTransferCoefficient(double wallHeatTransferCoefficient) { - this.wallHeatTransferCoefficient = wallHeatTransferCoefficient; - } + implements GeometryDefinitionInterface, neqsim.thermo.ThermodynamicConstantsInterface { + private static final long serialVersionUID = 1000; + + /** {@inheritDoc} */ + @Override + public SurroundingEnvironment getSurroundingEnvironment() { + return surroundingEnvironment; + } + + /** {@inheritDoc} */ + @Override + public void setSurroundingEnvironment(SurroundingEnvironment surroundingEnvironment) { + this.surroundingEnvironment = surroundingEnvironment; + } + + /** + *

+ * Getter for the field wall. + *

+ * + * @return the wall + */ + public Wall getWall() { + return wall; + } + + /** + *

+ * Setter for the field wall. + *

+ * + * @param wall the wall to set + */ + public void setWall(Wall wall) { + this.wall = wall; + } + + double wallHeatTransferCoefficient = 20.0; + private double innerWallTemperature = 276.5; + protected PackingInterface packing = null; + + public double diameter = 0, radius = 0, innerSurfaceRoughness = 0.000005, nodeLength = 0, + area = 0, relativeRoughnes = 0; + public double[] layerConductivity, layerThickness; + + public Wall wall = new Wall(); + + private SurroundingEnvironment surroundingEnvironment = new SurroundingEnvironmentBaseClass(); + + /** + * * + *

+ * Constructor for GeometryDefinition. + *

+ */ + public GeometryDefinition() {} + + /** + *

+ * Constructor for GeometryDefinition. + *

+ * + * @param diameter a double + */ + public GeometryDefinition(double diameter) { + this.diameter = diameter; + this.radius = diameter / 2.0; + this.area = pi * Math.pow(radius, 2); + } + + /** + *

+ * Constructor for GeometryDefinition. + *

+ * + * @param diameter a double + * @param roughness a double + */ + public GeometryDefinition(double diameter, double roughness) { + this(diameter); + this.relativeRoughnes = roughness / diameter; + this.innerSurfaceRoughness = roughness; + } + + /** {@inheritDoc} */ + @Override + public GeometryDefinitionInterface clone() { + GeometryDefinitionInterface clonedGeometry = null; + try { + clonedGeometry = (GeometryDefinition) super.clone(); + } catch (Exception e) { + e.printStackTrace(System.err); + } + + return clonedGeometry; + } + + /** {@inheritDoc} */ + @Override + public void setNodeLength(double nodeLength) { + this.nodeLength = nodeLength; + } + + /** {@inheritDoc} */ + @Override + public void setInnerSurfaceRoughness(double innerSurfaceRoughness) { + this.innerSurfaceRoughness = innerSurfaceRoughness; + } + + /** {@inheritDoc} */ + @Override + public void init() { + this.radius = diameter / 2.0; + this.area = pi * Math.pow(radius, 2.0); + this.relativeRoughnes = innerSurfaceRoughness / diameter; + } + + /** {@inheritDoc} */ + @Override + public void setDiameter(double diameter) { + this.diameter = diameter; + this.radius = diameter / 2.0; + this.area = pi * Math.pow(radius, 2); + } + + /** {@inheritDoc} */ + @Override + public double getWallHeatTransferCoefficient() { + return wall.getHeatTransferCoefficient(); + } + + /** {@inheritDoc} */ + @Override + public double getDiameter() { + return diameter; + } + + /** {@inheritDoc} */ + @Override + public double getArea() { + return area; + } + + /** {@inheritDoc} */ + @Override + public double getRadius() { + return radius; + } + + /** {@inheritDoc} */ + @Override + public double getInnerSurfaceRoughness() { + return innerSurfaceRoughness; + } + + /** {@inheritDoc} */ + @Override + public double getRelativeRoughnes() { + return relativeRoughnes; + } + + /** {@inheritDoc} */ + @Override + public double getRelativeRoughnes(double diameter) { + return innerSurfaceRoughness / diameter; + } + + /** {@inheritDoc} */ + @Override + public double getCircumference() { + return 2 * pi * radius; + } + + /** {@inheritDoc} */ + @Override + public double getNodeLength() { + return nodeLength; + } + + /** {@inheritDoc} */ + @Override + public GeometryDefinitionInterface getGeometry() { + return this; + } + + /** {@inheritDoc} */ + @Override + public void setPackingType(int i) {} + + /** {@inheritDoc} */ + @Override + public void setPackingType(String name, String material, int size) { + System.out.println("error - packing set in Geometry definition class"); + } + + /** {@inheritDoc} */ + @Override + public PackingInterface getPacking() { + return packing; + } + + /** {@inheritDoc} */ + @Override + public double getInnerWallTemperature() { + return innerWallTemperature; + } + + /** {@inheritDoc} */ + @Override + public void setInnerWallTemperature(double temperature) { + this.innerWallTemperature = temperature; + } + + /** {@inheritDoc} */ + @Override + public void setWallHeatTransferCoefficient(double wallHeatTransferCoefficient) { + this.wallHeatTransferCoefficient = wallHeatTransferCoefficient; + } } diff --git a/src/main/java/neqsim/fluidMechanics/geometryDefinitions/GeometryDefinitionInterface.java b/src/main/java/neqsim/fluidMechanics/geometryDefinitions/GeometryDefinitionInterface.java index 56b9549fd7..0323271093 100644 --- a/src/main/java/neqsim/fluidMechanics/geometryDefinitions/GeometryDefinitionInterface.java +++ b/src/main/java/neqsim/fluidMechanics/geometryDefinitions/GeometryDefinitionInterface.java @@ -3,6 +3,7 @@ * * Created on 10. desember 2000, 18:56 */ + package neqsim.fluidMechanics.geometryDefinitions; import neqsim.fluidMechanics.geometryDefinitions.internalGeometry.packings.PackingInterface; @@ -17,219 +18,216 @@ * @version $Id: $Id */ public interface GeometryDefinitionInterface extends Cloneable { - /** - *

- * setDiameter. - *

- * - * @param diameter a double - */ - public void setDiameter(double diameter); - - /** - *

- * setNodeLength. - *

- * - * @param nodeLength a double - */ - public void setNodeLength(double nodeLength); - - /** - *

- * setInnerSurfaceRoughness. - *

- * - * @param innerSurfaceRoughness a double - */ - public void setInnerSurfaceRoughness(double innerSurfaceRoughness); - - /** - *

- * init. - *

- */ - public void init(); - - /** - *

- * getDiameter. - *

- * - * @return a double - */ - public double getDiameter(); - - /** - *

- * getArea. - *

- * - * @return a double - */ - public double getArea(); - - /** - *

- * getRadius. - *

- * - * @return a double - */ - public double getRadius(); - - /** - *

- * getInnerSurfaceRoughness. - *

- * - * @return a double - */ - public double getInnerSurfaceRoughness(); - - /** - *

- * getCircumference. - *

- * - * @return a double - */ - public double getCircumference(); - - /** - *

- * getRelativeRoughnes. - *

- * - * @return a double - */ - public double getRelativeRoughnes(); - - /** - *

- * getNodeLength. - *

- * - * @return a double - */ - public double getNodeLength(); - - /** - *

- * getRelativeRoughnes. - *

- * - * @param diameter a double - * @return a double - */ - public double getRelativeRoughnes(double diameter); - - /** - *

- * getWallHeatTransferCoefficient. - *

- * - * @return a double - */ - public double getWallHeatTransferCoefficient(); - - /** - *

- * setWallHeatTransferCoefficient. - *

- * - * @param outerHeatTransferCoefficient a double - */ - public void setWallHeatTransferCoefficient(double outerHeatTransferCoefficient); - - /** - *

- * setPackingType. - *

- * - * @param i a int - */ - public void setPackingType(int i); - - /** - *

- * setPackingType. - *

- * - * @param name a {@link java.lang.String} object - * @param material a {@link java.lang.String} object - * @param size a int - */ - public void setPackingType(String name, String material, int size); - - /** - *

- * getPacking. - *

- * - * @return a - * {@link neqsim.fluidMechanics.geometryDefinitions.internalGeometry.packings.PackingInterface} - * object - */ - public PackingInterface getPacking(); - - /** - *

- * getGeometry. - *

- * - * @return a {@link neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface} - * object - */ - public GeometryDefinitionInterface getGeometry(); - - /** - *

- * clone. - *

- * - * @return a {@link neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface} - * object - */ - public GeometryDefinitionInterface clone(); - - /** - *

- * getInnerWallTemperature. - *

- * - * @return a double - */ - public double getInnerWallTemperature(); - - /** - *

- * setInnerWallTemperature. - *

- * - * @param temperature a double - */ - public void setInnerWallTemperature(double temperature); - - /** - *

- * getSurroundingEnvironment. - *

- * - * @return a - * {@link neqsim.fluidMechanics.geometryDefinitions.surrounding.SurroundingEnvironment} - * object - */ - public SurroundingEnvironment getSurroundingEnvironment(); - - /** - *

- * setSurroundingEnvironment. - *

- * - * @param surroundingEnvironment a - * {@link neqsim.fluidMechanics.geometryDefinitions.surrounding.SurroundingEnvironment} - * object - */ - public void setSurroundingEnvironment(SurroundingEnvironment surroundingEnvironment); + /** + *

+ * setDiameter. + *

+ * + * @param diameter a double + */ + public void setDiameter(double diameter); + + /** + *

+ * setNodeLength. + *

+ * + * @param nodeLength a double + */ + public void setNodeLength(double nodeLength); + + /** + *

+ * setInnerSurfaceRoughness. + *

+ * + * @param innerSurfaceRoughness a double + */ + public void setInnerSurfaceRoughness(double innerSurfaceRoughness); + + /** + *

+ * init. + *

+ */ + public void init(); + + /** + *

+ * getDiameter. + *

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

+ * getArea. + *

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

+ * getRadius. + *

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

+ * getInnerSurfaceRoughness. + *

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

+ * getCircumference. + *

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

+ * getRelativeRoughnes. + *

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

+ * getNodeLength. + *

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

+ * getRelativeRoughnes. + *

+ * + * @param diameter a double + * @return a double + */ + public double getRelativeRoughnes(double diameter); + + /** + *

+ * getWallHeatTransferCoefficient. + *

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

+ * setWallHeatTransferCoefficient. + *

+ * + * @param outerHeatTransferCoefficient a double + */ + public void setWallHeatTransferCoefficient(double outerHeatTransferCoefficient); + + /** + *

+ * setPackingType. + *

+ * + * @param i a int + */ + public void setPackingType(int i); + + /** + *

+ * setPackingType. + *

+ * + * @param name a {@link java.lang.String} object + * @param material a {@link java.lang.String} object + * @param size a int + */ + public void setPackingType(String name, String material, int size); + + /** + *

+ * getPacking. + *

+ * + * @return a + * {@link neqsim.fluidMechanics.geometryDefinitions.internalGeometry.packings.PackingInterface} + * object + */ + public PackingInterface getPacking(); + + /** + *

+ * getGeometry. + *

+ * + * @return a {@link neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface} object + */ + public GeometryDefinitionInterface getGeometry(); + + /** + *

+ * clone. + *

+ * + * @return a {@link neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface} object + */ + public GeometryDefinitionInterface clone(); + + /** + *

+ * getInnerWallTemperature. + *

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

+ * setInnerWallTemperature. + *

+ * + * @param temperature a double + */ + public void setInnerWallTemperature(double temperature); + + /** + *

+ * getSurroundingEnvironment. + *

+ * + * @return a {@link neqsim.fluidMechanics.geometryDefinitions.surrounding.SurroundingEnvironment} + * object + */ + public SurroundingEnvironment getSurroundingEnvironment(); + + /** + *

+ * setSurroundingEnvironment. + *

+ * + * @param surroundingEnvironment a + * {@link neqsim.fluidMechanics.geometryDefinitions.surrounding.SurroundingEnvironment} + * object + */ + public void setSurroundingEnvironment(SurroundingEnvironment surroundingEnvironment); } diff --git a/src/main/java/neqsim/fluidMechanics/geometryDefinitions/internalGeometry/packings/Packing.java b/src/main/java/neqsim/fluidMechanics/geometryDefinitions/internalGeometry/packings/Packing.java index 9afad3352d..b7b947fad6 100644 --- a/src/main/java/neqsim/fluidMechanics/geometryDefinitions/internalGeometry/packings/Packing.java +++ b/src/main/java/neqsim/fluidMechanics/geometryDefinitions/internalGeometry/packings/Packing.java @@ -3,6 +3,7 @@ * * Created on 25. august 2001, 23:34 */ + package neqsim.fluidMechanics.geometryDefinitions.internalGeometry.packings; import neqsim.util.NamedBaseClass; diff --git a/src/main/java/neqsim/fluidMechanics/geometryDefinitions/internalGeometry/packings/PackingInterface.java b/src/main/java/neqsim/fluidMechanics/geometryDefinitions/internalGeometry/packings/PackingInterface.java index 6c578aff2c..0db7332d7f 100644 --- a/src/main/java/neqsim/fluidMechanics/geometryDefinitions/internalGeometry/packings/PackingInterface.java +++ b/src/main/java/neqsim/fluidMechanics/geometryDefinitions/internalGeometry/packings/PackingInterface.java @@ -3,6 +3,7 @@ * * Created on 25. august 2001, 23:34 */ + package neqsim.fluidMechanics.geometryDefinitions.internalGeometry.packings; /** @@ -14,39 +15,39 @@ * @version $Id: $Id */ public interface PackingInterface { - /** - *

- * getSize. - *

- * - * @return a double - */ - public double getSize(); + /** + *

+ * getSize. + *

+ * + * @return a double + */ + public double getSize(); - /** - *

- * getSurfaceAreaPrVolume. - *

- * - * @return a double - */ - public double getSurfaceAreaPrVolume(); + /** + *

+ * getSurfaceAreaPrVolume. + *

+ * + * @return a double + */ + public double getSurfaceAreaPrVolume(); - /** - *

- * getVoidFractionPacking. - *

- * - * @return a double - */ - public double getVoidFractionPacking(); + /** + *

+ * getVoidFractionPacking. + *

+ * + * @return a double + */ + public double getVoidFractionPacking(); - /** - *

- * setVoidFractionPacking. - *

- * - * @param voidFractionPacking a double - */ - public void setVoidFractionPacking(double voidFractionPacking); + /** + *

+ * setVoidFractionPacking. + *

+ * + * @param voidFractionPacking a double + */ + public void setVoidFractionPacking(double voidFractionPacking); } diff --git a/src/main/java/neqsim/fluidMechanics/geometryDefinitions/internalGeometry/packings/PallRingPacking.java b/src/main/java/neqsim/fluidMechanics/geometryDefinitions/internalGeometry/packings/PallRingPacking.java index 94887ad748..77eb10bb62 100644 --- a/src/main/java/neqsim/fluidMechanics/geometryDefinitions/internalGeometry/packings/PallRingPacking.java +++ b/src/main/java/neqsim/fluidMechanics/geometryDefinitions/internalGeometry/packings/PallRingPacking.java @@ -3,6 +3,7 @@ * * Created on 25. august 2001, 23:58 */ + package neqsim.fluidMechanics.geometryDefinitions.internalGeometry.packings; /** diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/onePhaseFileWriter/OnePhaseFileWriter.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/onePhaseFileWriter/OnePhaseFileWriter.java index 9bf0e0fee4..8774324987 100644 --- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/onePhaseFileWriter/OnePhaseFileWriter.java +++ b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/onePhaseFileWriter/OnePhaseFileWriter.java @@ -3,6 +3,7 @@ * * Created on 27. oktober 2000, 22:27 */ + package neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.onePhaseFileWriter; import neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.FileWriterBaseClass; @@ -16,12 +17,12 @@ * @version $Id: $Id */ public class OnePhaseFileWriter extends FileWriterBaseClass { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for OnePhaseFileWriter. - *

- */ - public OnePhaseFileWriter() {} + /** + *

+ * Constructor for OnePhaseFileWriter. + *

+ */ + public OnePhaseFileWriter() {} } diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/onePhaseFileWriter/pipeFlowFileWriter/PipeFlowFileWriter.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/onePhaseFileWriter/pipeFlowFileWriter/PipeFlowFileWriter.java index c5a3d96afe..8ec0b7b82d 100644 --- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/onePhaseFileWriter/pipeFlowFileWriter/PipeFlowFileWriter.java +++ b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/onePhaseFileWriter/pipeFlowFileWriter/PipeFlowFileWriter.java @@ -3,6 +3,7 @@ * * Created on 27. oktober 2000, 22:29 */ + package neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.onePhaseFileWriter.pipeFlowFileWriter; import neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.onePhaseFileWriter.OnePhaseFileWriter; @@ -16,12 +17,12 @@ * @version $Id: $Id */ public class PipeFlowFileWriter extends OnePhaseFileWriter { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for PipeFlowFileWriter. - *

- */ - public PipeFlowFileWriter() {} + /** + *

+ * Constructor for PipeFlowFileWriter. + *

+ */ + public PipeFlowFileWriter() {} } diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowNodeVisualization/FlowNodeVisualization.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowNodeVisualization/FlowNodeVisualization.java index ca3cfb75f1..9e52f38beb 100644 --- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowNodeVisualization/FlowNodeVisualization.java +++ b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowNodeVisualization/FlowNodeVisualization.java @@ -3,6 +3,7 @@ * * Created on 5. august 2001, 16:27 */ + package neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowNodeVisualization; import neqsim.fluidMechanics.flowNode.FlowNodeInterface; @@ -16,131 +17,131 @@ * @version $Id: $Id */ public class FlowNodeVisualization implements FlowNodeVisualizationInterface { - public double[] temperature = new double[2]; - public double[] reynoldsNumber = new double[2]; - public double[] interfaceTemperature = new double[2]; - public double[] pressure = new double[2]; - public double[] velocity = new double[2]; - public double[] phaseFraction = new double[2]; - public double[] wallContactLength = new double[2]; - public double[][] bulkComposition, interfaceComposition, effectiveMassTransferCoefficient, - effectiveSchmidtNumber; - public double[][] molarFlux; - public double interphaseContactLength = 0.0; - public double nodeCenter; - public int numberOfComponents = 0; - - /** - *

- * Constructor for FlowNodeVisualization. - *

- */ - public FlowNodeVisualization() {} - - /** {@inheritDoc} */ - @Override - public void setData(FlowNodeInterface node) { - temperature[0] = node.getBulkSystem().getPhases()[0].getTemperature(); - temperature[1] = node.getBulkSystem().getPhases()[1].getTemperature(); - pressure[0] = node.getBulkSystem().getPhases()[0].getPressure(); - pressure[1] = node.getBulkSystem().getPhases()[1].getPressure(); - velocity[0] = node.getVelocity(0); - velocity[1] = node.getVelocity(1); - reynoldsNumber[0] = node.getReynoldsNumber(0); - interphaseContactLength = node.getInterphaseContactLength(0); - wallContactLength[0] = node.getWallContactLength(0); - wallContactLength[1] = node.getWallContactLength(1); - numberOfComponents = node.getBulkSystem().getPhases()[0].getNumberOfComponents(); - nodeCenter = node.getDistanceToCenterOfNode(); - } - - /** {@inheritDoc} */ - @Override - public int getNumberOfComponents() { - return numberOfComponents; - } - - /** {@inheritDoc} */ - @Override - public double getInterphaseContactLength() { - return interphaseContactLength; - } - - /** {@inheritDoc} */ - @Override - public double getWallContactLength(int phase) { - return wallContactLength[phase]; - } - - /** {@inheritDoc} */ - @Override - public double getPressure(int i) { - return pressure[i]; - } - - /** {@inheritDoc} */ - @Override - public double getReynoldsNumber(int i) { - return reynoldsNumber[i]; - } - - /** {@inheritDoc} */ - @Override - public double getDistanceToCenterOfNode() { - return nodeCenter; - } - - /** {@inheritDoc} */ - @Override - public double getTemperature(int i) { - return temperature[i]; - } - - /** {@inheritDoc} */ - @Override - public double getInterfaceTemperature(int i) { - return interfaceTemperature[i]; - } - - /** {@inheritDoc} */ - @Override - public double getVelocity(int i) { - return velocity[i]; - } - - /** {@inheritDoc} */ - @Override - public double getBulkComposition(int i, int phase) { - return bulkComposition[phase][i]; - } - - /** {@inheritDoc} */ - @Override - public double getInterfaceComposition(int i, int phase) { - return interfaceComposition[phase][i]; - } - - /** {@inheritDoc} */ - @Override - public double getMolarFlux(int i, int phase) { - return molarFlux[phase][i]; - } - - /** {@inheritDoc} */ - @Override - public double getEffectiveMassTransferCoefficient(int i, int phase) { - return effectiveMassTransferCoefficient[phase][i]; - } - - /** {@inheritDoc} */ - @Override - public double getEffectiveSchmidtNumber(int i, int phase) { - return effectiveSchmidtNumber[phase][i]; - } - - /** {@inheritDoc} */ - @Override - public double getPhaseFraction(int phase) { - return phaseFraction[phase]; - } + public double[] temperature = new double[2]; + public double[] reynoldsNumber = new double[2]; + public double[] interfaceTemperature = new double[2]; + public double[] pressure = new double[2]; + public double[] velocity = new double[2]; + public double[] phaseFraction = new double[2]; + public double[] wallContactLength = new double[2]; + public double[][] bulkComposition, interfaceComposition, effectiveMassTransferCoefficient, + effectiveSchmidtNumber; + public double[][] molarFlux; + public double interphaseContactLength = 0.0; + public double nodeCenter; + public int numberOfComponents = 0; + + /** + *

+ * Constructor for FlowNodeVisualization. + *

+ */ + public FlowNodeVisualization() {} + + /** {@inheritDoc} */ + @Override + public void setData(FlowNodeInterface node) { + temperature[0] = node.getBulkSystem().getPhases()[0].getTemperature(); + temperature[1] = node.getBulkSystem().getPhases()[1].getTemperature(); + pressure[0] = node.getBulkSystem().getPhases()[0].getPressure(); + pressure[1] = node.getBulkSystem().getPhases()[1].getPressure(); + velocity[0] = node.getVelocity(0); + velocity[1] = node.getVelocity(1); + reynoldsNumber[0] = node.getReynoldsNumber(0); + interphaseContactLength = node.getInterphaseContactLength(0); + wallContactLength[0] = node.getWallContactLength(0); + wallContactLength[1] = node.getWallContactLength(1); + numberOfComponents = node.getBulkSystem().getPhases()[0].getNumberOfComponents(); + nodeCenter = node.getDistanceToCenterOfNode(); + } + + /** {@inheritDoc} */ + @Override + public int getNumberOfComponents() { + return numberOfComponents; + } + + /** {@inheritDoc} */ + @Override + public double getInterphaseContactLength() { + return interphaseContactLength; + } + + /** {@inheritDoc} */ + @Override + public double getWallContactLength(int phase) { + return wallContactLength[phase]; + } + + /** {@inheritDoc} */ + @Override + public double getPressure(int i) { + return pressure[i]; + } + + /** {@inheritDoc} */ + @Override + public double getReynoldsNumber(int i) { + return reynoldsNumber[i]; + } + + /** {@inheritDoc} */ + @Override + public double getDistanceToCenterOfNode() { + return nodeCenter; + } + + /** {@inheritDoc} */ + @Override + public double getTemperature(int i) { + return temperature[i]; + } + + /** {@inheritDoc} */ + @Override + public double getInterfaceTemperature(int i) { + return interfaceTemperature[i]; + } + + /** {@inheritDoc} */ + @Override + public double getVelocity(int i) { + return velocity[i]; + } + + /** {@inheritDoc} */ + @Override + public double getBulkComposition(int i, int phase) { + return bulkComposition[phase][i]; + } + + /** {@inheritDoc} */ + @Override + public double getInterfaceComposition(int i, int phase) { + return interfaceComposition[phase][i]; + } + + /** {@inheritDoc} */ + @Override + public double getMolarFlux(int i, int phase) { + return molarFlux[phase][i]; + } + + /** {@inheritDoc} */ + @Override + public double getEffectiveMassTransferCoefficient(int i, int phase) { + return effectiveMassTransferCoefficient[phase][i]; + } + + /** {@inheritDoc} */ + @Override + public double getEffectiveSchmidtNumber(int i, int phase) { + return effectiveSchmidtNumber[phase][i]; + } + + /** {@inheritDoc} */ + @Override + public double getPhaseFraction(int phase) { + return phaseFraction[phase]; + } } diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowNodeVisualization/FlowNodeVisualizationInterface.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowNodeVisualization/FlowNodeVisualizationInterface.java index 021da712af..308b7321fc 100644 --- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowNodeVisualization/FlowNodeVisualizationInterface.java +++ b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowNodeVisualization/FlowNodeVisualizationInterface.java @@ -3,6 +3,7 @@ * * Created on 5. august 2001, 16:28 */ + package neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowNodeVisualization; import neqsim.fluidMechanics.flowNode.FlowNodeInterface; @@ -16,164 +17,164 @@ * @version $Id: $Id */ public interface FlowNodeVisualizationInterface { - /** - *

- * setData. - *

- * - * @param node a {@link neqsim.fluidMechanics.flowNode.FlowNodeInterface} object - */ - public void setData(FlowNodeInterface node); - - /** - *

- * getPressure. - *

- * - * @param i a int - * @return a double - */ - public double getPressure(int i); - - /** - *

- * getTemperature. - *

- * - * @param i a int - * @return a double - */ - public double getTemperature(int i); - - /** - *

- * getDistanceToCenterOfNode. - *

- * - * @return a double - */ - public double getDistanceToCenterOfNode(); - - /** - *

- * getVelocity. - *

- * - * @param i a int - * @return a double - */ - public double getVelocity(int i); - - /** - *

- * getBulkComposition. - *

- * - * @param i a int - * @param phase a int - * @return a double - */ - public double getBulkComposition(int i, int phase); - - /** - *

- * getInterfaceComposition. - *

- * - * @param i a int - * @param phase a int - * @return a double - */ - public double getInterfaceComposition(int i, int phase); - - /** - *

- * Get number of components added. - *

- * - * @return the number of components. - */ - public int getNumberOfComponents(); - - /** - *

- * getPhaseFraction. - *

- * - * @param phase a int - * @return a double - */ - public double getPhaseFraction(int phase); - - /** - *

- * getMolarFlux. - *

- * - * @param i a int - * @param phase a int - * @return a double - */ - public double getMolarFlux(int i, int phase); - - /** - *

- * getInterfaceTemperature. - *

- * - * @param i a int - * @return a double - */ - public double getInterfaceTemperature(int i); - - /** - *

- * getInterphaseContactLength. - *

- * - * @return a double - */ - public double getInterphaseContactLength(); - - /** - *

- * getWallContactLength. - *

- * - * @param phase a int - * @return a double - */ - public double getWallContactLength(int phase); - - /** - *

- * getReynoldsNumber. - *

- * - * @param i a int - * @return a double - */ - public double getReynoldsNumber(int i); - - /** - *

- * getEffectiveMassTransferCoefficient. - *

- * - * @param i a int - * @param phase a int - * @return a double - */ - public double getEffectiveMassTransferCoefficient(int i, int phase); - - /** - *

- * getEffectiveSchmidtNumber. - *

- * - * @param i a int - * @param phase a int - * @return a double - */ - public double getEffectiveSchmidtNumber(int i, int phase); + /** + *

+ * setData. + *

+ * + * @param node a {@link neqsim.fluidMechanics.flowNode.FlowNodeInterface} object + */ + public void setData(FlowNodeInterface node); + + /** + *

+ * getPressure. + *

+ * + * @param i a int + * @return a double + */ + public double getPressure(int i); + + /** + *

+ * getTemperature. + *

+ * + * @param i a int + * @return a double + */ + public double getTemperature(int i); + + /** + *

+ * getDistanceToCenterOfNode. + *

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

+ * getVelocity. + *

+ * + * @param i a int + * @return a double + */ + public double getVelocity(int i); + + /** + *

+ * getBulkComposition. + *

+ * + * @param i a int + * @param phase a int + * @return a double + */ + public double getBulkComposition(int i, int phase); + + /** + *

+ * getInterfaceComposition. + *

+ * + * @param i a int + * @param phase a int + * @return a double + */ + public double getInterfaceComposition(int i, int phase); + + /** + *

+ * Get number of components added. + *

+ * + * @return the number of components. + */ + public int getNumberOfComponents(); + + /** + *

+ * getPhaseFraction. + *

+ * + * @param phase a int + * @return a double + */ + public double getPhaseFraction(int phase); + + /** + *

+ * getMolarFlux. + *

+ * + * @param i a int + * @param phase a int + * @return a double + */ + public double getMolarFlux(int i, int phase); + + /** + *

+ * getInterfaceTemperature. + *

+ * + * @param i a int + * @return a double + */ + public double getInterfaceTemperature(int i); + + /** + *

+ * getInterphaseContactLength. + *

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

+ * getWallContactLength. + *

+ * + * @param phase a int + * @return a double + */ + public double getWallContactLength(int phase); + + /** + *

+ * getReynoldsNumber. + *

+ * + * @param i a int + * @return a double + */ + public double getReynoldsNumber(int i); + + /** + *

+ * getEffectiveMassTransferCoefficient. + *

+ * + * @param i a int + * @param phase a int + * @return a double + */ + public double getEffectiveMassTransferCoefficient(int i, int phase); + + /** + *

+ * getEffectiveSchmidtNumber. + *

+ * + * @param i a int + * @param phase a int + * @return a double + */ + public double getEffectiveSchmidtNumber(int i, int phase); } diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowNodeVisualization/onePhaseFlowNodeVisualization/OnePhaseFlowNodeVisualization.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowNodeVisualization/onePhaseFlowNodeVisualization/OnePhaseFlowNodeVisualization.java index d588dbd227..ca77187ea5 100644 --- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowNodeVisualization/onePhaseFlowNodeVisualization/OnePhaseFlowNodeVisualization.java +++ b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowNodeVisualization/onePhaseFlowNodeVisualization/OnePhaseFlowNodeVisualization.java @@ -3,6 +3,7 @@ * * Created on 5. august 2001, 16:29 */ + package neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowNodeVisualization.onePhaseFlowNodeVisualization; import neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowNodeVisualization.FlowNodeVisualization; @@ -16,10 +17,10 @@ * @version $Id: $Id */ public class OnePhaseFlowNodeVisualization extends FlowNodeVisualization { - /** - *

- * Constructor for OnePhaseFlowNodeVisualization. - *

- */ - public OnePhaseFlowNodeVisualization() {} + /** + *

+ * Constructor for OnePhaseFlowNodeVisualization. + *

+ */ + public OnePhaseFlowNodeVisualization() {} } diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowNodeVisualization/onePhaseFlowNodeVisualization/onePhasePipeFlowNodeVisualization/OnePhasePipeFlowNodeVisualization.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowNodeVisualization/onePhaseFlowNodeVisualization/onePhasePipeFlowNodeVisualization/OnePhasePipeFlowNodeVisualization.java index 6cbd48082c..a274192a8d 100644 --- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowNodeVisualization/onePhaseFlowNodeVisualization/onePhasePipeFlowNodeVisualization/OnePhasePipeFlowNodeVisualization.java +++ b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowNodeVisualization/onePhaseFlowNodeVisualization/onePhasePipeFlowNodeVisualization/OnePhasePipeFlowNodeVisualization.java @@ -3,6 +3,7 @@ * * Created on 5. august 2001, 16:29 */ + package neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowNodeVisualization.onePhaseFlowNodeVisualization.onePhasePipeFlowNodeVisualization; import neqsim.fluidMechanics.flowNode.FlowNodeInterface; @@ -17,22 +18,21 @@ * @version $Id: $Id */ public class OnePhasePipeFlowNodeVisualization extends OnePhaseFlowNodeVisualization { - /** - *

- * Constructor for OnePhasePipeFlowNodeVisualization. - *

- */ - public OnePhasePipeFlowNodeVisualization() {} + /** + *

+ * Constructor for OnePhasePipeFlowNodeVisualization. + *

+ */ + public OnePhasePipeFlowNodeVisualization() {} - /** {@inheritDoc} */ - @Override - public void setData(FlowNodeInterface node) { - super.setData(node); - bulkComposition = - new double[2][node.getBulkSystem().getPhases()[0].getNumberOfComponents()]; + /** {@inheritDoc} */ + @Override + public void setData(FlowNodeInterface node) { + super.setData(node); + bulkComposition = new double[2][node.getBulkSystem().getPhases()[0].getNumberOfComponents()]; - for (int i = 0; i < node.getBulkSystem().getPhases()[0].getNumberOfComponents(); i++) { - bulkComposition[0][i] = node.getBulkSystem().getPhases()[0].getComponents()[i].getx(); - } + for (int i = 0; i < node.getBulkSystem().getPhases()[0].getNumberOfComponents(); i++) { + bulkComposition[0][i] = node.getBulkSystem().getPhases()[0].getComponents()[i].getx(); } + } } diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/onePhaseFlowVisualization/OnePhaseFlowVisualization.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/onePhaseFlowVisualization/OnePhaseFlowVisualization.java index 8ecf8d6a5c..74922d62f8 100644 --- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/onePhaseFlowVisualization/OnePhaseFlowVisualization.java +++ b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/onePhaseFlowVisualization/OnePhaseFlowVisualization.java @@ -3,6 +3,7 @@ * * Created on 26. oktober 2000, 20:08 */ + package neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowSystemVisualization.onePhaseFlowVisualization; /** @@ -14,23 +15,23 @@ * @version $Id: $Id */ public class OnePhaseFlowVisualization extends - neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowSystemVisualization.FlowSystemVisualization { - /** - *

- * Constructor for OnePhaseFlowVisualization. - *

- */ - public OnePhaseFlowVisualization() {} + neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowSystemVisualization.FlowSystemVisualization { + /** + *

+ * Constructor for OnePhaseFlowVisualization. + *

+ */ + public OnePhaseFlowVisualization() {} - /** - *

- * Constructor for OnePhaseFlowVisualization. - *

- * - * @param nodes a int - * @param timeSteps a int - */ - public OnePhaseFlowVisualization(int nodes, int timeSteps) { - super(nodes, timeSteps); - } + /** + *

+ * Constructor for OnePhaseFlowVisualization. + *

+ * + * @param nodes a int + * @param timeSteps a int + */ + public OnePhaseFlowVisualization(int nodes, int timeSteps) { + super(nodes, timeSteps); + } } diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/onePhaseFlowVisualization/pipeFlowVisualization/PipeFlowVisualization.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/onePhaseFlowVisualization/pipeFlowVisualization/PipeFlowVisualization.java index 991072c028..4d5a567cf7 100644 --- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/onePhaseFlowVisualization/pipeFlowVisualization/PipeFlowVisualization.java +++ b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/onePhaseFlowVisualization/pipeFlowVisualization/PipeFlowVisualization.java @@ -3,6 +3,7 @@ * * Created on 26. oktober 2000, 20:09 */ + package neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowSystemVisualization.onePhaseFlowVisualization.pipeFlowVisualization; /** diff --git a/src/main/java/neqsim/fluidMechanics/util/timeSeries/TimeSeries.java b/src/main/java/neqsim/fluidMechanics/util/timeSeries/TimeSeries.java index 26063cdca6..4469d6c8f6 100644 --- a/src/main/java/neqsim/fluidMechanics/util/timeSeries/TimeSeries.java +++ b/src/main/java/neqsim/fluidMechanics/util/timeSeries/TimeSeries.java @@ -3,6 +3,7 @@ * * Created on 18. juni 2001, 19:24 */ + package neqsim.fluidMechanics.util.timeSeries; import neqsim.fluidMechanics.flowSystem.FlowSystemInterface; @@ -17,150 +18,150 @@ * @version $Id: $Id */ public class TimeSeries implements java.io.Serializable { - private static final long serialVersionUID = 1000; - - protected double[] timeSeries, outletMolarFlowRate, outletMolarFlowRates; - protected SystemInterface[] inletThermoSystem; - protected SystemInterface[] thermoSystems; - protected int numberOfTimeStepsInInterval; - protected double[] times, timeSteps; - - /** - *

- * Constructor for TimeSeries. - *

- */ - public TimeSeries() { - this.timeSeries = new double[1]; - } + private static final long serialVersionUID = 1000; - /** - *

- * Setter for the field times. - *

- * - * @param times an array of {@link double} objects - */ - public void setTimes(double[] times) { - this.timeSeries = times; - } + protected double[] timeSeries, outletMolarFlowRate, outletMolarFlowRates; + protected SystemInterface[] inletThermoSystem; + protected SystemInterface[] thermoSystems; + protected int numberOfTimeStepsInInterval; + protected double[] times, timeSteps; - /** - *

- * setInletThermoSystems. - *

- * - * @param inletThermoSystem an array of {@link neqsim.thermo.system.SystemInterface} objects - */ - public void setInletThermoSystems(SystemInterface[] inletThermoSystem) { - this.inletThermoSystem = inletThermoSystem; - } + /** + *

+ * Constructor for TimeSeries. + *

+ */ + public TimeSeries() { + this.timeSeries = new double[1]; + } - /** - *

- * Setter for the field outletMolarFlowRate. - *

- * - * @param outletMolarFlowRate an array of {@link double} objects - */ - public void setOutletMolarFlowRate(double[] outletMolarFlowRate) { - this.outletMolarFlowRate = outletMolarFlowRate; - } + /** + *

+ * Setter for the field times. + *

+ * + * @param times an array of {@link double} objects + */ + public void setTimes(double[] times) { + this.timeSeries = times; + } - /** - *

- * Getter for the field outletMolarFlowRates. - *

- * - * @return an array of {@link double} objects - */ - public double[] getOutletMolarFlowRates() { - return this.outletMolarFlowRates; - } + /** + *

+ * setInletThermoSystems. + *

+ * + * @param inletThermoSystem an array of {@link neqsim.thermo.system.SystemInterface} objects + */ + public void setInletThermoSystems(SystemInterface[] inletThermoSystem) { + this.inletThermoSystem = inletThermoSystem; + } - /** - *

- * Setter for the field numberOfTimeStepsInInterval. - *

- * - * @param numberOfTimeStepsInInterval a int - */ - public void setNumberOfTimeStepsInInterval(int numberOfTimeStepsInInterval) { - this.numberOfTimeStepsInInterval = numberOfTimeStepsInInterval; - } + /** + *

+ * Setter for the field outletMolarFlowRate. + *

+ * + * @param outletMolarFlowRate an array of {@link double} objects + */ + public void setOutletMolarFlowRate(double[] outletMolarFlowRate) { + this.outletMolarFlowRate = outletMolarFlowRate; + } - /** - *

- * init. - *

- * - * @param flowSystem a {@link neqsim.fluidMechanics.flowSystem.FlowSystemInterface} object - */ - public void init(FlowSystemInterface flowSystem) { - int p = 0; - thermoSystems = new SystemInterface[(timeSeries.length - 1) * numberOfTimeStepsInInterval]; - outletMolarFlowRates = new double[(timeSeries.length - 1) * numberOfTimeStepsInInterval]; - timeSteps = new double[(timeSeries.length - 1) * numberOfTimeStepsInInterval]; - times = new double[(timeSeries.length - 1) * numberOfTimeStepsInInterval]; - - // System.out.println("times " + inletThermoSystem.length); - double temp = 0; - for (int k = 0; k < timeSeries.length - 1; k++) { - double stepLength = (timeSeries[k + 1] - timeSeries[k]) / numberOfTimeStepsInInterval; - for (int i = 0; i < numberOfTimeStepsInInterval; i++) { - timeSteps[p] = stepLength; - temp += stepLength; - times[p] = temp; - if (Double.isNaN(outletMolarFlowRate[0])) { - outletMolarFlowRates[p] = outletMolarFlowRate[k]; - } - thermoSystems[p++] = inletThermoSystem[k].clone(); - } + /** + *

+ * Getter for the field outletMolarFlowRates. + *

+ * + * @return an array of {@link double} objects + */ + public double[] getOutletMolarFlowRates() { + return this.outletMolarFlowRates; + } + + /** + *

+ * Setter for the field numberOfTimeStepsInInterval. + *

+ * + * @param numberOfTimeStepsInInterval a int + */ + public void setNumberOfTimeStepsInInterval(int numberOfTimeStepsInInterval) { + this.numberOfTimeStepsInInterval = numberOfTimeStepsInInterval; + } + + /** + *

+ * init. + *

+ * + * @param flowSystem a {@link neqsim.fluidMechanics.flowSystem.FlowSystemInterface} object + */ + public void init(FlowSystemInterface flowSystem) { + int p = 0; + thermoSystems = new SystemInterface[(timeSeries.length - 1) * numberOfTimeStepsInInterval]; + outletMolarFlowRates = new double[(timeSeries.length - 1) * numberOfTimeStepsInInterval]; + timeSteps = new double[(timeSeries.length - 1) * numberOfTimeStepsInInterval]; + times = new double[(timeSeries.length - 1) * numberOfTimeStepsInInterval]; + + // System.out.println("times " + inletThermoSystem.length); + double temp = 0; + for (int k = 0; k < timeSeries.length - 1; k++) { + double stepLength = (timeSeries[k + 1] - timeSeries[k]) / numberOfTimeStepsInInterval; + for (int i = 0; i < numberOfTimeStepsInInterval; i++) { + timeSteps[p] = stepLength; + temp += stepLength; + times[p] = temp; + if (Double.isNaN(outletMolarFlowRate[0])) { + outletMolarFlowRates[p] = outletMolarFlowRate[k]; } + thermoSystems[p++] = inletThermoSystem[k].clone(); + } } + } - /** - *

- * getThermoSystem. - *

- * - * @return an array of {@link neqsim.thermo.system.SystemInterface} objects - */ - public SystemInterface[] getThermoSystem() { - return thermoSystems; - } + /** + *

+ * getThermoSystem. + *

+ * + * @return an array of {@link neqsim.thermo.system.SystemInterface} objects + */ + public SystemInterface[] getThermoSystem() { + return thermoSystems; + } - /** - *

- * getTimeStep. - *

- * - * @return an array of {@link double} objects - */ - public double[] getTimeStep() { - return timeSteps; - } + /** + *

+ * getTimeStep. + *

+ * + * @return an array of {@link double} objects + */ + public double[] getTimeStep() { + return timeSteps; + } - /** - *

- * getTime. - *

- * - * @return an array of {@link double} objects - */ - public double[] getTime() { - return times; - } + /** + *

+ * getTime. + *

+ * + * @return an array of {@link double} objects + */ + public double[] getTime() { + return times; + } - /** - *

- * getTime. - *

- * - * @param i a int - * @return a double - */ - public double getTime(int i) { - return times[i]; - } + /** + *

+ * getTime. + *

+ * + * @param i a int + * @return a double + */ + public double getTime(int i) { + return times[i]; + } } diff --git a/src/main/java/neqsim/physicalProperties/interfaceProperties/InterfaceProperties.java b/src/main/java/neqsim/physicalProperties/interfaceProperties/InterfaceProperties.java index 7917335ff3..b7736d16b2 100644 --- a/src/main/java/neqsim/physicalProperties/interfaceProperties/InterfaceProperties.java +++ b/src/main/java/neqsim/physicalProperties/interfaceProperties/InterfaceProperties.java @@ -3,6 +3,7 @@ * * Created on 13. august 2001, 13:12 */ + package neqsim.physicalProperties.interfaceProperties; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/neqsim/physicalProperties/interfaceProperties/InterphasePropertiesInterface.java b/src/main/java/neqsim/physicalProperties/interfaceProperties/InterphasePropertiesInterface.java index 4431d13d55..8255923cce 100644 --- a/src/main/java/neqsim/physicalProperties/interfaceProperties/InterphasePropertiesInterface.java +++ b/src/main/java/neqsim/physicalProperties/interfaceProperties/InterphasePropertiesInterface.java @@ -3,6 +3,7 @@ * * Created on 13. august 2001, 13:13 */ + package neqsim.physicalProperties.interfaceProperties; import neqsim.physicalProperties.interfaceProperties.solidAdsorption.AdsorptionInterface; diff --git a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTension.java b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTension.java index ded686ef0c..2b96ae450b 100644 --- a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTension.java +++ b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTension.java @@ -3,6 +3,7 @@ * * Created on 13. august 2001, 13:14 */ + package neqsim.physicalProperties.interfaceProperties.surfaceTension; import org.apache.commons.math3.ode.nonstiff.DormandPrince54Integrator; diff --git a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/SurfaceTension.java b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/SurfaceTension.java index 73622b2ee2..6062c402de 100644 --- a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/SurfaceTension.java +++ b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/SurfaceTension.java @@ -3,6 +3,7 @@ * * Created on 13. august 2001, 13:14 */ + package neqsim.physicalProperties.interfaceProperties.surfaceTension; import neqsim.physicalProperties.interfaceProperties.InterfaceProperties; diff --git a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/SurfaceTensionInterface.java b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/SurfaceTensionInterface.java index 133302fe7b..4381c92b23 100644 --- a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/SurfaceTensionInterface.java +++ b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/SurfaceTensionInterface.java @@ -3,6 +3,7 @@ * * Created on 13. august 2001, 13:14 */ + package neqsim.physicalProperties.interfaceProperties.surfaceTension; /** diff --git a/src/main/java/neqsim/physicalProperties/mixingRule/PhysicalPropertyMixingRule.java b/src/main/java/neqsim/physicalProperties/mixingRule/PhysicalPropertyMixingRule.java index fc08213b60..350d96b8b2 100644 --- a/src/main/java/neqsim/physicalProperties/mixingRule/PhysicalPropertyMixingRule.java +++ b/src/main/java/neqsim/physicalProperties/mixingRule/PhysicalPropertyMixingRule.java @@ -3,6 +3,7 @@ * * Created on 2. august 2001, 13:42 */ + package neqsim.physicalProperties.mixingRule; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/neqsim/physicalProperties/mixingRule/PhysicalPropertyMixingRuleInterface.java b/src/main/java/neqsim/physicalProperties/mixingRule/PhysicalPropertyMixingRuleInterface.java index 9c8e0009b6..b55b6d6933 100644 --- a/src/main/java/neqsim/physicalProperties/mixingRule/PhysicalPropertyMixingRuleInterface.java +++ b/src/main/java/neqsim/physicalProperties/mixingRule/PhysicalPropertyMixingRuleInterface.java @@ -3,6 +3,7 @@ * * Created on 2. august 2001, 13:41 */ + package neqsim.physicalProperties.mixingRule; import neqsim.thermo.phase.PhaseInterface; diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/PhysicalPropertyMethod.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/PhysicalPropertyMethod.java index d67782b613..22d9bfb032 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/PhysicalPropertyMethod.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/PhysicalPropertyMethod.java @@ -3,6 +3,7 @@ * * Created on 3. august 2001, 22:49 */ + package neqsim.physicalProperties.physicalPropertyMethods; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/PhysicalPropertyMethodInterface.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/PhysicalPropertyMethodInterface.java index 4d2baba6d3..7fc3c1ffbb 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/PhysicalPropertyMethodInterface.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/PhysicalPropertyMethodInterface.java @@ -3,6 +3,7 @@ * * Created on 21. august 2001, 13:20 */ + package neqsim.physicalProperties.physicalPropertyMethods; /** diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethod.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethod.java index a77e0b3faf..0c3113fab7 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethod.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethod.java @@ -3,6 +3,7 @@ * * Created on 1. august 2001, 12:44 */ + package neqsim.physicalProperties.physicalPropertyMethods.commonPhasePhysicalProperties.viscosity; import neqsim.thermo.system.SystemInterface; diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/conductivity/Conductivity.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/conductivity/Conductivity.java index 4d6af41724..fc4b853dd3 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/conductivity/Conductivity.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/conductivity/Conductivity.java @@ -3,6 +3,7 @@ * * Created on 1. november 2000, 19:00 */ + package neqsim.physicalProperties.physicalPropertyMethods.gasPhysicalProperties.conductivity; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/density/Density.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/density/Density.java index e6b03ab06e..cf8860a1d2 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/density/Density.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/density/Density.java @@ -3,6 +3,7 @@ * * Created on 24. januar 2001, 19:49 */ + package neqsim.physicalProperties.physicalPropertyMethods.gasPhysicalProperties.density; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/viscosity/ChungViscosityMethod.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/viscosity/ChungViscosityMethod.java index 81443b1e17..6e181f6d97 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/viscosity/ChungViscosityMethod.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/viscosity/ChungViscosityMethod.java @@ -3,6 +3,7 @@ * * Created on 1. august 2001, 12:44 */ + package neqsim.physicalProperties.physicalPropertyMethods.gasPhysicalProperties.viscosity; /** diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/conductivity/Conductivity.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/conductivity/Conductivity.java index 41992e5938..c8b507f0e8 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/conductivity/Conductivity.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/conductivity/Conductivity.java @@ -3,6 +3,7 @@ * * Created on 1. november 2000, 19:00 */ + package neqsim.physicalProperties.physicalPropertyMethods.liquidPhysicalProperties.conductivity; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/density/Costald.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/density/Costald.java index 2ad23b6faf..8f9b3ab46b 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/density/Costald.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/density/Costald.java @@ -3,6 +3,7 @@ * * Created on 13. July 2022 */ + package neqsim.physicalProperties.physicalPropertyMethods.liquidPhysicalProperties.density; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/density/Density.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/density/Density.java index dd15474cb2..7d89823d6d 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/density/Density.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/density/Density.java @@ -3,6 +3,7 @@ * * Created on 24. januar 2001, 19:49 */ + package neqsim.physicalProperties.physicalPropertyMethods.liquidPhysicalProperties.density; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/solidPhysicalProperties/conductivity/Conductivity.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/solidPhysicalProperties/conductivity/Conductivity.java index dbf6fe4baa..707434f58a 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/solidPhysicalProperties/conductivity/Conductivity.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/solidPhysicalProperties/conductivity/Conductivity.java @@ -3,6 +3,7 @@ * * Created on 1. november 2000, 19:00 */ + package neqsim.physicalProperties.physicalPropertyMethods.solidPhysicalProperties.conductivity; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/solidPhysicalProperties/density/Density.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/solidPhysicalProperties/density/Density.java index b194c00bb2..44e842da3b 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/solidPhysicalProperties/density/Density.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/solidPhysicalProperties/density/Density.java @@ -3,6 +3,7 @@ * * Created on 24. januar 2001, 19:49 */ + package neqsim.physicalProperties.physicalPropertyMethods.solidPhysicalProperties.density; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertySystem/PhysicalProperties.java b/src/main/java/neqsim/physicalProperties/physicalPropertySystem/PhysicalProperties.java index 9b8ecac2e6..65ad92d8ab 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertySystem/PhysicalProperties.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertySystem/PhysicalProperties.java @@ -3,6 +3,7 @@ * * Created on 29. oktober 2000, 16:13 */ + package neqsim.physicalProperties.physicalPropertySystem; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertySystem/PhysicalPropertiesInterface.java b/src/main/java/neqsim/physicalProperties/physicalPropertySystem/PhysicalPropertiesInterface.java index 80ff25eaf2..6f24dc6c1f 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertySystem/PhysicalPropertiesInterface.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertySystem/PhysicalPropertiesInterface.java @@ -3,6 +3,7 @@ * * Created on 29. oktober 2000, 16:14 */ + package neqsim.physicalProperties.physicalPropertySystem; import neqsim.thermo.phase.PhaseInterface; diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertySystem/gasPhysicalProperties/AirPhysicalProperties.java b/src/main/java/neqsim/physicalProperties/physicalPropertySystem/gasPhysicalProperties/AirPhysicalProperties.java index a0a856cae6..2ba31be7fa 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertySystem/gasPhysicalProperties/AirPhysicalProperties.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertySystem/gasPhysicalProperties/AirPhysicalProperties.java @@ -3,6 +3,7 @@ * * Created on 13. august 2001, 10:34 */ + package neqsim.physicalProperties.physicalPropertySystem.gasPhysicalProperties; import neqsim.thermo.phase.PhaseInterface; diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertySystem/gasPhysicalProperties/GasPhysicalProperties.java b/src/main/java/neqsim/physicalProperties/physicalPropertySystem/gasPhysicalProperties/GasPhysicalProperties.java index b16f8c1be2..24ef955f9c 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertySystem/gasPhysicalProperties/GasPhysicalProperties.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertySystem/gasPhysicalProperties/GasPhysicalProperties.java @@ -3,6 +3,7 @@ * * Created on 29. oktober 2000, 16:18 */ + package neqsim.physicalProperties.physicalPropertySystem.gasPhysicalProperties; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertySystem/gasPhysicalProperties/NaturalGasPhysicalProperties.java b/src/main/java/neqsim/physicalProperties/physicalPropertySystem/gasPhysicalProperties/NaturalGasPhysicalProperties.java index 98f3ba9f1c..389d41c2a8 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertySystem/gasPhysicalProperties/NaturalGasPhysicalProperties.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertySystem/gasPhysicalProperties/NaturalGasPhysicalProperties.java @@ -3,6 +3,7 @@ * * Created on 13. august 2001, 10:32 */ + package neqsim.physicalProperties.physicalPropertySystem.gasPhysicalProperties; import neqsim.thermo.phase.PhaseInterface; diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertySystem/liquidPhysicalProperties/AminePhysicalProperties.java b/src/main/java/neqsim/physicalProperties/physicalPropertySystem/liquidPhysicalProperties/AminePhysicalProperties.java index 417374ca35..5fb3c6f828 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertySystem/liquidPhysicalProperties/AminePhysicalProperties.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertySystem/liquidPhysicalProperties/AminePhysicalProperties.java @@ -3,6 +3,7 @@ * * Created on 13. august 2001, 10:31 */ + package neqsim.physicalProperties.physicalPropertySystem.liquidPhysicalProperties; import neqsim.physicalProperties.physicalPropertyMethods.gasPhysicalProperties.density.Density; diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertySystem/liquidPhysicalProperties/GlycolPhysicalProperties.java b/src/main/java/neqsim/physicalProperties/physicalPropertySystem/liquidPhysicalProperties/GlycolPhysicalProperties.java index fee6319dbf..7249bb74ca 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertySystem/liquidPhysicalProperties/GlycolPhysicalProperties.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertySystem/liquidPhysicalProperties/GlycolPhysicalProperties.java @@ -3,6 +3,7 @@ * * Created on 13. august 2001, 10:31 */ + package neqsim.physicalProperties.physicalPropertySystem.liquidPhysicalProperties; import neqsim.physicalProperties.physicalPropertyMethods.liquidPhysicalProperties.conductivity.Conductivity; diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertySystem/liquidPhysicalProperties/LiquidPhysicalProperties.java b/src/main/java/neqsim/physicalProperties/physicalPropertySystem/liquidPhysicalProperties/LiquidPhysicalProperties.java index 6a0da03f73..085263fdad 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertySystem/liquidPhysicalProperties/LiquidPhysicalProperties.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertySystem/liquidPhysicalProperties/LiquidPhysicalProperties.java @@ -3,6 +3,7 @@ * * Created on 29. oktober 2000, 16:17 */ + package neqsim.physicalProperties.physicalPropertySystem.liquidPhysicalProperties; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertySystem/liquidPhysicalProperties/WaterPhysicalProperties.java b/src/main/java/neqsim/physicalProperties/physicalPropertySystem/liquidPhysicalProperties/WaterPhysicalProperties.java index 4912c467cc..d18c122e35 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertySystem/liquidPhysicalProperties/WaterPhysicalProperties.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertySystem/liquidPhysicalProperties/WaterPhysicalProperties.java @@ -3,6 +3,7 @@ * * Created on 13. august 2001, 10:34 */ + package neqsim.physicalProperties.physicalPropertySystem.liquidPhysicalProperties; import neqsim.physicalProperties.physicalPropertyMethods.liquidPhysicalProperties.conductivity.Conductivity; diff --git a/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompViscosity/linearLiquidModel/ViscosityFunction.java b/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompViscosity/linearLiquidModel/ViscosityFunction.java index 1709843cfb..612b3bf1e8 100644 --- a/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompViscosity/linearLiquidModel/ViscosityFunction.java +++ b/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompViscosity/linearLiquidModel/ViscosityFunction.java @@ -3,6 +3,7 @@ * * Created on 24. januar 2001, 23:30 */ + package neqsim.physicalProperties.util.parameterFitting.pureComponentParameterFitting.pureCompViscosity.linearLiquidModel; import neqsim.statistics.parameterFitting.nonLinearParameterFitting.LevenbergMarquardtFunction; diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/TemperatureTransmitter.java b/src/main/java/neqsim/processSimulation/measurementDevice/TemperatureTransmitter.java index 178985769f..b415c212b2 100644 --- a/src/main/java/neqsim/processSimulation/measurementDevice/TemperatureTransmitter.java +++ b/src/main/java/neqsim/processSimulation/measurementDevice/TemperatureTransmitter.java @@ -3,6 +3,7 @@ * * Created on 6. juni 2006, 15:24 */ + package neqsim.processSimulation.measurementDevice; import neqsim.processSimulation.processEquipment.stream.StreamInterface; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/ProcessEquipmentBaseClass.java b/src/main/java/neqsim/processSimulation/processEquipment/ProcessEquipmentBaseClass.java index 9ee3fd21e1..dd771d8f63 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/ProcessEquipmentBaseClass.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/ProcessEquipmentBaseClass.java @@ -3,6 +3,7 @@ * * Created on 6. juni 2006, 15:12 */ + package neqsim.processSimulation.processEquipment; import java.util.Arrays; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorInterface.java b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorInterface.java index b70d0fa7ff..1dfb4e04da 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorInterface.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorInterface.java @@ -3,6 +3,7 @@ * * Created on 22. august 2001, 17:20 */ + package neqsim.processSimulation.processEquipment.compressor; import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchanger.java b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchanger.java index 0e19295d06..7754120bf1 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchanger.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchanger.java @@ -3,6 +3,7 @@ * * Created on 15. mars 2001, 14:17 */ + package neqsim.processSimulation.processEquipment.heatExchanger; import java.util.UUID; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/Heater.java b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/Heater.java index 869d81e652..c2a4b1ee3c 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/Heater.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/Heater.java @@ -3,6 +3,7 @@ * * Created on 15. mars 2001, 14:17 */ + package neqsim.processSimulation.processEquipment.heatExchanger; import java.util.UUID; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/mixer/MixerInterface.java b/src/main/java/neqsim/processSimulation/processEquipment/mixer/MixerInterface.java index a756d2507a..9b57f0ec89 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/mixer/MixerInterface.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/mixer/MixerInterface.java @@ -3,6 +3,7 @@ * * Created on 21. august 2001, 22:28 */ + package neqsim.processSimulation.processEquipment.mixer; import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticMixer.java b/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticMixer.java index af834ff215..b4e8b40ac9 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticMixer.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticMixer.java @@ -3,6 +3,7 @@ * * Created on 11. mars 2001, 01:49 */ + package neqsim.processSimulation.processEquipment.mixer; import java.util.UUID; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticNeqMixer.java b/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticNeqMixer.java index a8c027319e..d4c5ca9c46 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticNeqMixer.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticNeqMixer.java @@ -3,6 +3,7 @@ * * Created on 11. mars 2001, 01:49 */ + package neqsim.processSimulation.processEquipment.mixer; import java.util.UUID; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeLineInterface.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeLineInterface.java index cb3eb61373..15920794d0 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeLineInterface.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeLineInterface.java @@ -3,6 +3,7 @@ * * Created on 21. august 2001, 20:44 */ + package neqsim.processSimulation.processEquipment.pipeline; import neqsim.fluidMechanics.flowSystem.FlowSystemInterface; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/TwoPhasePipeLine.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/TwoPhasePipeLine.java index d3653d2356..54df084c10 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/TwoPhasePipeLine.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/TwoPhasePipeLine.java @@ -3,6 +3,7 @@ * * Created on 21. august 2001, 20:45 */ + package neqsim.processSimulation.processEquipment.pipeline; import java.util.UUID; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoir.java b/src/main/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoir.java index f455db05c4..fb8f6c8bfd 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoir.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoir.java @@ -3,6 +3,7 @@ * * Created on 12. mars 2001, 19:48 */ + package neqsim.processSimulation.processEquipment.reservoir; import java.util.ArrayList; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubber.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubber.java index 2043a6c150..c07fdaed4d 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubber.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubber.java @@ -3,6 +3,7 @@ * * Created on 12. mars 2001, 19:48 */ + package neqsim.processSimulation.processEquipment.separator; import java.util.ArrayList; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubberSimple.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubberSimple.java index dfff09ec42..bc788e5258 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubberSimple.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubberSimple.java @@ -3,6 +3,7 @@ * * Created on 12. mars 2001, 19:48 */ + package neqsim.processSimulation.processEquipment.separator; import java.util.UUID; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java index e500cb95c4..954d0e313d 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java @@ -3,6 +3,7 @@ * * Created on 12. mars 2001, 19:48 */ + package neqsim.processSimulation.processEquipment.separator; import java.util.ArrayList; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/SeparatorInterface.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/SeparatorInterface.java index e081d25d1a..7a916c8465 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/SeparatorInterface.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/SeparatorInterface.java @@ -3,6 +3,7 @@ * * Created on 22. august 2001, 17:22 */ + package neqsim.processSimulation.processEquipment.separator; import neqsim.processSimulation.SimulationInterface; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java b/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java index 3ff8f484d1..e807dc450b 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java @@ -3,6 +3,7 @@ * * Created on 12. mars 2001, 13:11 */ + package neqsim.processSimulation.processEquipment.stream; import java.util.UUID; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/stream/StreamInterface.java b/src/main/java/neqsim/processSimulation/processEquipment/stream/StreamInterface.java index 0d7137bc3e..87a2391861 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/stream/StreamInterface.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/stream/StreamInterface.java @@ -3,6 +3,7 @@ * * Created on 21. august 2001, 22:49 */ + package neqsim.processSimulation.processEquipment.stream; import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/valve/ValveInterface.java b/src/main/java/neqsim/processSimulation/processEquipment/valve/ValveInterface.java index a3b62a3f4c..71a50f7d42 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/valve/ValveInterface.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/valve/ValveInterface.java @@ -3,6 +3,7 @@ * * Created on 22. august 2001, 17:20 */ + package neqsim.processSimulation.processEquipment.valve; import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface; diff --git a/src/main/java/neqsim/processSimulation/processSystem/ModuleInterface.java b/src/main/java/neqsim/processSimulation/processSystem/ModuleInterface.java index 86e071bccb..8f4e4d019e 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/ModuleInterface.java +++ b/src/main/java/neqsim/processSimulation/processSystem/ModuleInterface.java @@ -3,6 +3,7 @@ * * Created on 1. november 2006, 21:48 */ + package neqsim.processSimulation.processSystem; import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface; diff --git a/src/main/java/neqsim/processSimulation/processSystem/ProcessModuleBaseClass.java b/src/main/java/neqsim/processSimulation/processSystem/ProcessModuleBaseClass.java index 8fd5d4ac22..124df44d69 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/ProcessModuleBaseClass.java +++ b/src/main/java/neqsim/processSimulation/processSystem/ProcessModuleBaseClass.java @@ -3,6 +3,7 @@ * * Created on 1. november 2006, 22:07 */ + package neqsim.processSimulation.processSystem; import java.util.UUID; diff --git a/src/main/java/neqsim/standards/Standard.java b/src/main/java/neqsim/standards/Standard.java index f12a47199e..43ac359d6a 100644 --- a/src/main/java/neqsim/standards/Standard.java +++ b/src/main/java/neqsim/standards/Standard.java @@ -3,6 +3,7 @@ * * Created on 13. juni 2004, 23:56 */ + package neqsim.standards; import java.awt.BorderLayout; diff --git a/src/main/java/neqsim/standards/StandardInterface.java b/src/main/java/neqsim/standards/StandardInterface.java index 8015e443ca..b8f69e0638 100644 --- a/src/main/java/neqsim/standards/StandardInterface.java +++ b/src/main/java/neqsim/standards/StandardInterface.java @@ -3,6 +3,7 @@ * * Created on 13. juni 2004, 23:29 */ + package neqsim.standards; import neqsim.standards.salesContract.ContractInterface; diff --git a/src/main/java/neqsim/standards/salesContract/BaseContract.java b/src/main/java/neqsim/standards/salesContract/BaseContract.java index 564a9f9431..00df6fb345 100644 --- a/src/main/java/neqsim/standards/salesContract/BaseContract.java +++ b/src/main/java/neqsim/standards/salesContract/BaseContract.java @@ -3,6 +3,7 @@ * * Created on 15. juni 2004, 21:43 */ + package neqsim.standards.salesContract; import java.awt.BorderLayout; diff --git a/src/main/java/neqsim/standards/salesContract/ContractInterface.java b/src/main/java/neqsim/standards/salesContract/ContractInterface.java index 89c3308283..ad088d1840 100644 --- a/src/main/java/neqsim/standards/salesContract/ContractInterface.java +++ b/src/main/java/neqsim/standards/salesContract/ContractInterface.java @@ -3,6 +3,7 @@ * * Created on 15. juni 2004, 21:43 */ + package neqsim.standards.salesContract; /** diff --git a/src/main/java/neqsim/standards/salesContract/ContractSpecification.java b/src/main/java/neqsim/standards/salesContract/ContractSpecification.java index 3251741be9..d75fbb2ea4 100644 --- a/src/main/java/neqsim/standards/salesContract/ContractSpecification.java +++ b/src/main/java/neqsim/standards/salesContract/ContractSpecification.java @@ -3,6 +3,7 @@ * * Created on 15. juni 2004, 22:59 */ + package neqsim.standards.salesContract; import neqsim.standards.StandardInterface; diff --git a/src/main/java/neqsim/statistics/dataAnalysis/dataSmoothing/DataSmoothor.java b/src/main/java/neqsim/statistics/dataAnalysis/dataSmoothing/DataSmoothor.java index 25b7e98642..be02a32184 100644 --- a/src/main/java/neqsim/statistics/dataAnalysis/dataSmoothing/DataSmoothor.java +++ b/src/main/java/neqsim/statistics/dataAnalysis/dataSmoothing/DataSmoothor.java @@ -3,6 +3,7 @@ * * Created on 31. januar 2001, 21:27 */ + package neqsim.statistics.dataAnalysis.dataSmoothing; import Jama.Matrix; diff --git a/src/main/java/neqsim/statistics/experimentalEquipmentData/ExperimentalEquipmentData.java b/src/main/java/neqsim/statistics/experimentalEquipmentData/ExperimentalEquipmentData.java index f1d3defe7a..2efa4b8cb6 100644 --- a/src/main/java/neqsim/statistics/experimentalEquipmentData/ExperimentalEquipmentData.java +++ b/src/main/java/neqsim/statistics/experimentalEquipmentData/ExperimentalEquipmentData.java @@ -3,6 +3,7 @@ * * Created on 9. februar 2001, 10:00 */ + package neqsim.statistics.experimentalEquipmentData; /** diff --git a/src/main/java/neqsim/statistics/experimentalEquipmentData/wettedWallColumnData/WettedWallColumnData.java b/src/main/java/neqsim/statistics/experimentalEquipmentData/wettedWallColumnData/WettedWallColumnData.java index aa823792ea..15f919a456 100644 --- a/src/main/java/neqsim/statistics/experimentalEquipmentData/wettedWallColumnData/WettedWallColumnData.java +++ b/src/main/java/neqsim/statistics/experimentalEquipmentData/wettedWallColumnData/WettedWallColumnData.java @@ -3,6 +3,7 @@ * * Created on 9. februar 2001, 10:01 */ + package neqsim.statistics.experimentalEquipmentData.wettedWallColumnData; import neqsim.statistics.experimentalEquipmentData.ExperimentalEquipmentData; diff --git a/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/DataObjectInterface.java b/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/DataObjectInterface.java index e77decd65d..b83cadc5f2 100644 --- a/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/DataObjectInterface.java +++ b/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/DataObjectInterface.java @@ -3,6 +3,7 @@ * * Created on 1. februar 2001, 13:09 */ + package neqsim.statistics.experimentalSampleCreation.readDataFromFile; /** diff --git a/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/DataReader.java b/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/DataReader.java index 772c5244e4..3e5d9c6d80 100644 --- a/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/DataReader.java +++ b/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/DataReader.java @@ -3,6 +3,7 @@ * * Created on 1. februar 2001, 11:38 */ + package neqsim.statistics.experimentalSampleCreation.readDataFromFile; import java.io.RandomAccessFile; diff --git a/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/DataReaderInterface.java b/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/DataReaderInterface.java index 2e75f0c792..9ed96d5d1a 100644 --- a/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/DataReaderInterface.java +++ b/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/DataReaderInterface.java @@ -3,6 +3,7 @@ * * Created on 1. februar 2001, 11:38 */ + package neqsim.statistics.experimentalSampleCreation.readDataFromFile; /** diff --git a/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/wettedWallColumnReader/WettedWallColumnDataObject.java b/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/wettedWallColumnReader/WettedWallColumnDataObject.java index 2b0cf70cde..78a1b3329f 100644 --- a/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/wettedWallColumnReader/WettedWallColumnDataObject.java +++ b/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/wettedWallColumnReader/WettedWallColumnDataObject.java @@ -3,6 +3,7 @@ * * Created on 1. februar 2001, 12:19 */ + package neqsim.statistics.experimentalSampleCreation.readDataFromFile.wettedWallColumnReader; import java.sql.Time; @@ -17,235 +18,235 @@ * @version $Id: $Id */ public class WettedWallColumnDataObject extends DataObject { - double pressure = 0, inletGasTemperature = 0, outletGasTemperature = 0; - double inletLiquidTemperature = 0, outletLiquidTemperature = 0, columnWallTemperature = 0; - double totalGasFlow = 0, co2SupplyFlow = 0, inletLiquidFlow = 0; - Time time = null; - - /** - *

- * Constructor for WettedWallColumnDataObject. - *

- */ - public WettedWallColumnDataObject() {} - - /** - *

- * Setter for the field time. - *

- * - * @param time a {@link java.lang.String} object - */ - public void setTime(String time) { - this.time = Time.valueOf(time); - } - - /** - *

- * Getter for the field time. - *

- * - * @return a long - */ - public long getTime() { - return this.time.getTime(); - } - - /** - *

- * Setter for the field pressure. - *

- * - * @param pressure a double - */ - public void setPressure(double pressure) { - this.pressure = pressure; - } - - /** - *

- * Getter for the field pressure. - *

- * - * @return a double - */ - public double getPressure() { - return this.pressure; - } - - /** - *

- * Setter for the field inletGasTemperature. - *

- * - * @param temperature a double - */ - public void setInletGasTemperature(double temperature) { - this.inletGasTemperature = temperature; - } - - /** - *

- * Getter for the field inletGasTemperature. - *

- * - * @return a double - */ - public double getInletGasTemperature() { - return this.inletGasTemperature; - } - - /** - *

- * Setter for the field inletLiquidTemperature. - *

- * - * @param temperature a double - */ - public void setInletLiquidTemperature(double temperature) { - this.inletLiquidTemperature = temperature; - } - - /** - *

- * Getter for the field inletLiquidTemperature. - *

- * - * @return a double - */ - public double getInletLiquidTemperature() { - return this.inletLiquidTemperature; - } - - /** - *

- * Setter for the field outletGasTemperature. - *

- * - * @param temperature a double - */ - public void setOutletGasTemperature(double temperature) { - this.outletGasTemperature = temperature; - } - - /** - *

- * Getter for the field outletGasTemperature. - *

- * - * @return a double - */ - public double getOutletGasTemperature() { - return this.outletGasTemperature; - } - - /** - *

- * Setter for the field outletLiquidTemperature. - *

- * - * @param temperature a double - */ - public void setOutletLiquidTemperature(double temperature) { - this.outletLiquidTemperature = temperature; - } - - /** - *

- * Getter for the field outletLiquidTemperature. - *

- * - * @return a double - */ - public double getOutletLiquidTemperature() { - return this.outletLiquidTemperature; - } - - /** - *

- * Setter for the field columnWallTemperature. - *

- * - * @param temperature a double - */ - public void setColumnWallTemperature(double temperature) { - this.columnWallTemperature = temperature; - } - - /** - *

- * Getter for the field columnWallTemperature. - *

- * - * @return a double - */ - public double getColumnWallTemperature() { - return this.columnWallTemperature; - } - - /** - *

- * setInletTotalGasFlow. - *

- * - * @param totalGasFlow a double - */ - public void setInletTotalGasFlow(double totalGasFlow) { - this.totalGasFlow = totalGasFlow; - } - - /** - *

- * getInletTotalGasFlow. - *

- * - * @return a double - */ - public double getInletTotalGasFlow() { - return this.totalGasFlow; - } - - /** - *

- * Setter for the field co2SupplyFlow. - *

- * - * @param co2Flow a double - */ - public void setCo2SupplyFlow(double co2Flow) { - this.co2SupplyFlow = co2Flow; - } - - /** - *

- * Getter for the field co2SupplyFlow. - *

- * - * @return a double - */ - public double getCo2SupplyFlow() { - return this.co2SupplyFlow; - } - - /** - *

- * Setter for the field inletLiquidFlow. - *

- * - * @param inletLiquidFlow a double - */ - public void setInletLiquidFlow(double inletLiquidFlow) { - this.inletLiquidFlow = inletLiquidFlow; - } - - /** - *

- * Getter for the field inletLiquidFlow. - *

- * - * @return a double - */ - public double getInletLiquidFlow() { - return this.inletLiquidFlow; - } + double pressure = 0, inletGasTemperature = 0, outletGasTemperature = 0; + double inletLiquidTemperature = 0, outletLiquidTemperature = 0, columnWallTemperature = 0; + double totalGasFlow = 0, co2SupplyFlow = 0, inletLiquidFlow = 0; + Time time = null; + + /** + *

+ * Constructor for WettedWallColumnDataObject. + *

+ */ + public WettedWallColumnDataObject() {} + + /** + *

+ * Setter for the field time. + *

+ * + * @param time a {@link java.lang.String} object + */ + public void setTime(String time) { + this.time = Time.valueOf(time); + } + + /** + *

+ * Getter for the field time. + *

+ * + * @return a long + */ + public long getTime() { + return this.time.getTime(); + } + + /** + *

+ * Setter for the field pressure. + *

+ * + * @param pressure a double + */ + public void setPressure(double pressure) { + this.pressure = pressure; + } + + /** + *

+ * Getter for the field pressure. + *

+ * + * @return a double + */ + public double getPressure() { + return this.pressure; + } + + /** + *

+ * Setter for the field inletGasTemperature. + *

+ * + * @param temperature a double + */ + public void setInletGasTemperature(double temperature) { + this.inletGasTemperature = temperature; + } + + /** + *

+ * Getter for the field inletGasTemperature. + *

+ * + * @return a double + */ + public double getInletGasTemperature() { + return this.inletGasTemperature; + } + + /** + *

+ * Setter for the field inletLiquidTemperature. + *

+ * + * @param temperature a double + */ + public void setInletLiquidTemperature(double temperature) { + this.inletLiquidTemperature = temperature; + } + + /** + *

+ * Getter for the field inletLiquidTemperature. + *

+ * + * @return a double + */ + public double getInletLiquidTemperature() { + return this.inletLiquidTemperature; + } + + /** + *

+ * Setter for the field outletGasTemperature. + *

+ * + * @param temperature a double + */ + public void setOutletGasTemperature(double temperature) { + this.outletGasTemperature = temperature; + } + + /** + *

+ * Getter for the field outletGasTemperature. + *

+ * + * @return a double + */ + public double getOutletGasTemperature() { + return this.outletGasTemperature; + } + + /** + *

+ * Setter for the field outletLiquidTemperature. + *

+ * + * @param temperature a double + */ + public void setOutletLiquidTemperature(double temperature) { + this.outletLiquidTemperature = temperature; + } + + /** + *

+ * Getter for the field outletLiquidTemperature. + *

+ * + * @return a double + */ + public double getOutletLiquidTemperature() { + return this.outletLiquidTemperature; + } + + /** + *

+ * Setter for the field columnWallTemperature. + *

+ * + * @param temperature a double + */ + public void setColumnWallTemperature(double temperature) { + this.columnWallTemperature = temperature; + } + + /** + *

+ * Getter for the field columnWallTemperature. + *

+ * + * @return a double + */ + public double getColumnWallTemperature() { + return this.columnWallTemperature; + } + + /** + *

+ * setInletTotalGasFlow. + *

+ * + * @param totalGasFlow a double + */ + public void setInletTotalGasFlow(double totalGasFlow) { + this.totalGasFlow = totalGasFlow; + } + + /** + *

+ * getInletTotalGasFlow. + *

+ * + * @return a double + */ + public double getInletTotalGasFlow() { + return this.totalGasFlow; + } + + /** + *

+ * Setter for the field co2SupplyFlow. + *

+ * + * @param co2Flow a double + */ + public void setCo2SupplyFlow(double co2Flow) { + this.co2SupplyFlow = co2Flow; + } + + /** + *

+ * Getter for the field co2SupplyFlow. + *

+ * + * @return a double + */ + public double getCo2SupplyFlow() { + return this.co2SupplyFlow; + } + + /** + *

+ * Setter for the field inletLiquidFlow. + *

+ * + * @param inletLiquidFlow a double + */ + public void setInletLiquidFlow(double inletLiquidFlow) { + this.inletLiquidFlow = inletLiquidFlow; + } + + /** + *

+ * Getter for the field inletLiquidFlow. + *

+ * + * @return a double + */ + public double getInletLiquidFlow() { + return this.inletLiquidFlow; + } } diff --git a/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/wettedWallColumnReader/WettedWallDataReader.java b/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/wettedWallColumnReader/WettedWallDataReader.java index d4d95a6a38..1f7d6b4970 100644 --- a/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/wettedWallColumnReader/WettedWallDataReader.java +++ b/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/wettedWallColumnReader/WettedWallDataReader.java @@ -3,6 +3,7 @@ * * Created on 1. februar 2001, 13:05 */ + package neqsim.statistics.experimentalSampleCreation.readDataFromFile.wettedWallColumnReader; import java.io.RandomAccessFile; diff --git a/src/main/java/neqsim/statistics/experimentalSampleCreation/sampleCreator/SampleCreator.java b/src/main/java/neqsim/statistics/experimentalSampleCreation/sampleCreator/SampleCreator.java index 4bbc174eaf..603bdf7584 100644 --- a/src/main/java/neqsim/statistics/experimentalSampleCreation/sampleCreator/SampleCreator.java +++ b/src/main/java/neqsim/statistics/experimentalSampleCreation/sampleCreator/SampleCreator.java @@ -3,6 +3,7 @@ * * Created on 8. februar 2001, 09:14 */ + package neqsim.statistics.experimentalSampleCreation.sampleCreator; import neqsim.statistics.experimentalEquipmentData.ExperimentalEquipmentData; diff --git a/src/main/java/neqsim/statistics/experimentalSampleCreation/sampleCreator/wettedWallColumnSampleCreator/WettedWallColumnSampleCreator.java b/src/main/java/neqsim/statistics/experimentalSampleCreation/sampleCreator/wettedWallColumnSampleCreator/WettedWallColumnSampleCreator.java index 1ae6b99c47..d084080e8f 100644 --- a/src/main/java/neqsim/statistics/experimentalSampleCreation/sampleCreator/wettedWallColumnSampleCreator/WettedWallColumnSampleCreator.java +++ b/src/main/java/neqsim/statistics/experimentalSampleCreation/sampleCreator/wettedWallColumnSampleCreator/WettedWallColumnSampleCreator.java @@ -3,6 +3,7 @@ * * Created on 8. februar 2001, 09:14 */ + package neqsim.statistics.experimentalSampleCreation.sampleCreator.wettedWallColumnSampleCreator; import Jama.Matrix; diff --git a/src/main/java/neqsim/statistics/monteCarloSimulation/MonteCarloSimulation.java b/src/main/java/neqsim/statistics/monteCarloSimulation/MonteCarloSimulation.java index 777cfa1b74..ae26a789d0 100644 --- a/src/main/java/neqsim/statistics/monteCarloSimulation/MonteCarloSimulation.java +++ b/src/main/java/neqsim/statistics/monteCarloSimulation/MonteCarloSimulation.java @@ -3,6 +3,7 @@ * * Created on 30. januar 2001, 13:06 */ + package neqsim.statistics.monteCarloSimulation; import Jama.Matrix; diff --git a/src/main/java/neqsim/statistics/parameterFitting/FunctionInterface.java b/src/main/java/neqsim/statistics/parameterFitting/FunctionInterface.java index 9273dd9530..a17f0869a1 100644 --- a/src/main/java/neqsim/statistics/parameterFitting/FunctionInterface.java +++ b/src/main/java/neqsim/statistics/parameterFitting/FunctionInterface.java @@ -3,6 +3,7 @@ * * Created on 30. januar 2001, 21:40 */ + package neqsim.statistics.parameterFitting; import neqsim.thermo.system.SystemInterface; diff --git a/src/main/java/neqsim/statistics/parameterFitting/NumericalDerivative.java b/src/main/java/neqsim/statistics/parameterFitting/NumericalDerivative.java index 58efa9c62d..6eb8df61a4 100644 --- a/src/main/java/neqsim/statistics/parameterFitting/NumericalDerivative.java +++ b/src/main/java/neqsim/statistics/parameterFitting/NumericalDerivative.java @@ -3,6 +3,7 @@ * * Created on 28. juli 2000, 15:39 */ + package neqsim.statistics.parameterFitting; /** diff --git a/src/main/java/neqsim/statistics/parameterFitting/SampleSet.java b/src/main/java/neqsim/statistics/parameterFitting/SampleSet.java index 5e838e4d5d..c32502eff3 100644 --- a/src/main/java/neqsim/statistics/parameterFitting/SampleSet.java +++ b/src/main/java/neqsim/statistics/parameterFitting/SampleSet.java @@ -3,6 +3,7 @@ * * Created on 28. januar 2001, 13:17 */ + package neqsim.statistics.parameterFitting; import java.util.ArrayList; diff --git a/src/main/java/neqsim/statistics/parameterFitting/SampleValue.java b/src/main/java/neqsim/statistics/parameterFitting/SampleValue.java index 8557beb91d..ad4c429172 100644 --- a/src/main/java/neqsim/statistics/parameterFitting/SampleValue.java +++ b/src/main/java/neqsim/statistics/parameterFitting/SampleValue.java @@ -3,6 +3,7 @@ * * Created on 22. januar 2001, 23:01 */ + package neqsim.statistics.parameterFitting; import neqsim.thermo.system.SystemInterface; diff --git a/src/main/java/neqsim/statistics/parameterFitting/StatisticsBaseClass.java b/src/main/java/neqsim/statistics/parameterFitting/StatisticsBaseClass.java index 4447f6ad15..a89be1f1fc 100644 --- a/src/main/java/neqsim/statistics/parameterFitting/StatisticsBaseClass.java +++ b/src/main/java/neqsim/statistics/parameterFitting/StatisticsBaseClass.java @@ -3,6 +3,7 @@ * * Created on 22. januar 2001, 23:00 */ + package neqsim.statistics.parameterFitting; import java.awt.Container; diff --git a/src/main/java/neqsim/statistics/parameterFitting/StatisticsInterface.java b/src/main/java/neqsim/statistics/parameterFitting/StatisticsInterface.java index d21b3cd739..6378fd9080 100644 --- a/src/main/java/neqsim/statistics/parameterFitting/StatisticsInterface.java +++ b/src/main/java/neqsim/statistics/parameterFitting/StatisticsInterface.java @@ -3,6 +3,7 @@ * * Created on 30. januar 2001, 18:25 */ + package neqsim.statistics.parameterFitting; /** diff --git a/src/main/java/neqsim/statistics/parameterFitting/nonLinearParameterFitting/LevenbergMarquardt.java b/src/main/java/neqsim/statistics/parameterFitting/nonLinearParameterFitting/LevenbergMarquardt.java index 38a136ee04..653fa4e577 100644 --- a/src/main/java/neqsim/statistics/parameterFitting/nonLinearParameterFitting/LevenbergMarquardt.java +++ b/src/main/java/neqsim/statistics/parameterFitting/nonLinearParameterFitting/LevenbergMarquardt.java @@ -3,6 +3,7 @@ * * Created on 22. januar 2001, 23:00 */ + package neqsim.statistics.parameterFitting.nonLinearParameterFitting; import Jama.Matrix; diff --git a/src/main/java/neqsim/statistics/parameterFitting/nonLinearParameterFitting/LevenbergMarquardtAbsDev.java b/src/main/java/neqsim/statistics/parameterFitting/nonLinearParameterFitting/LevenbergMarquardtAbsDev.java index 2672a8f61b..98191a4e2b 100644 --- a/src/main/java/neqsim/statistics/parameterFitting/nonLinearParameterFitting/LevenbergMarquardtAbsDev.java +++ b/src/main/java/neqsim/statistics/parameterFitting/nonLinearParameterFitting/LevenbergMarquardtAbsDev.java @@ -3,6 +3,7 @@ * * Created on 22. januar 2001, 23:00 */ + package neqsim.statistics.parameterFitting.nonLinearParameterFitting; /** diff --git a/src/main/java/neqsim/statistics/parameterFitting/nonLinearParameterFitting/LevenbergMarquardtBiasDev.java b/src/main/java/neqsim/statistics/parameterFitting/nonLinearParameterFitting/LevenbergMarquardtBiasDev.java index 4a6be6a629..6afe43354a 100644 --- a/src/main/java/neqsim/statistics/parameterFitting/nonLinearParameterFitting/LevenbergMarquardtBiasDev.java +++ b/src/main/java/neqsim/statistics/parameterFitting/nonLinearParameterFitting/LevenbergMarquardtBiasDev.java @@ -3,6 +3,7 @@ * * Created on 22. januar 2001, 23:00 */ + package neqsim.statistics.parameterFitting.nonLinearParameterFitting; /** diff --git a/src/main/java/neqsim/thermo/Fluid.java b/src/main/java/neqsim/thermo/Fluid.java index 212ac16236..9e5b189258 100644 --- a/src/main/java/neqsim/thermo/Fluid.java +++ b/src/main/java/neqsim/thermo/Fluid.java @@ -1,6 +1,3 @@ -/** - * - */ package neqsim.thermo; import org.apache.logging.log4j.LogManager; @@ -15,407 +12,404 @@ * @version $Id: $Id */ public class Fluid { - static Logger logger = LogManager.getLogger(Fluid.class); - static neqsim.thermo.system.SystemInterface fluid = null; - private static boolean hasWater = false; - private static boolean autoSelectModel = false; - private static String thermoModel = "srk"; - private static String thermoMixingRule = "classic"; + static Logger logger = LogManager.getLogger(Fluid.class); + static neqsim.thermo.system.SystemInterface fluid = null; + private static boolean hasWater = false; + private static boolean autoSelectModel = false; + private static String thermoModel = "srk"; + private static String thermoMixingRule = "classic"; - private static void setThermoModel() { - if (thermoModel.equals("srk")) { - fluid = new neqsim.thermo.system.SystemSrkEos(); - } else if (thermoModel.equals("pr")) { - fluid = new neqsim.thermo.system.SystemPrEos(); - } else if (thermoModel.equals("cpa")) { - fluid = new neqsim.thermo.system.SystemSrkCPAstatoil(); - } else { - fluid = new neqsim.thermo.system.SystemSrkEos(); - } + private static void setThermoModel() { + if (thermoModel.equals("srk")) { + fluid = new neqsim.thermo.system.SystemSrkEos(); + } else if (thermoModel.equals("pr")) { + fluid = new neqsim.thermo.system.SystemPrEos(); + } else if (thermoModel.equals("cpa")) { + fluid = new neqsim.thermo.system.SystemSrkCPAstatoil(); + } else { + fluid = new neqsim.thermo.system.SystemSrkEos(); } + } - private static void setMixingRule() { - fluid.setMixingRule(getThermoMixingRule()); - } + private static void setMixingRule() { + fluid.setMixingRule(getThermoMixingRule()); + } - /** - *

- * create2. - *

- * - * @param componentNames an array of {@link java.lang.String} objects - * @return a {@link neqsim.thermo.system.SystemInterface} object - */ - public static neqsim.thermo.system.SystemInterface create2(String[] componentNames) { - double[] comp = new double[componentNames.length]; - for (int i = 0; i < componentNames.length; i++) { - comp[i] = 1.0; - } - return create2(componentNames, comp, "mol/sec"); + /** + *

+ * create2. + *

+ * + * @param componentNames an array of {@link java.lang.String} objects + * @return a {@link neqsim.thermo.system.SystemInterface} object + */ + public static neqsim.thermo.system.SystemInterface create2(String[] componentNames) { + double[] comp = new double[componentNames.length]; + for (int i = 0; i < componentNames.length; i++) { + comp[i] = 1.0; } + return create2(componentNames, comp, "mol/sec"); + } - /** - *

- * create2. - *

- * - * @param componentNames an array of {@link java.lang.String} objects - * @param flowrate an array of {@link double} objects - * @param unit a {@link java.lang.String} object - * @return a {@link neqsim.thermo.system.SystemInterface} object - */ - public static neqsim.thermo.system.SystemInterface create2(String[] componentNames, - double[] flowrate, String unit) { - setThermoModel(); - createFluid(componentNames, flowrate, unit); - if (isHasWater() == true) - fluid.addComponent("water", 0.1); - fluid.createDatabase(true); - setMixingRule(); - if (isHasWater()) { - fluid.setMultiPhaseCheck(true); - } - if (isAutoSelectModel()) { - fluid = fluid.autoSelectModel(); - } - fluid.init(0); - return fluid; + /** + *

+ * create2. + *

+ * + * @param componentNames an array of {@link java.lang.String} objects + * @param flowrate an array of {@link double} objects + * @param unit a {@link java.lang.String} object + * @return a {@link neqsim.thermo.system.SystemInterface} object + */ + public static neqsim.thermo.system.SystemInterface create2(String[] componentNames, + double[] flowrate, String unit) { + setThermoModel(); + createFluid(componentNames, flowrate, unit); + if (isHasWater() == true) + fluid.addComponent("water", 0.1); + fluid.createDatabase(true); + setMixingRule(); + if (isHasWater()) { + fluid.setMultiPhaseCheck(true); } + if (isAutoSelectModel()) { + fluid = fluid.autoSelectModel(); + } + fluid.init(0); + return fluid; + } - /** - *

- * create. - *

- * - * @param fluidType a {@link java.lang.String} object - * @return a {@link neqsim.thermo.system.SystemInterface} object - */ - public static neqsim.thermo.system.SystemInterface create(String fluidType) { - String[] compNames = null; - double[] flowrate = null; - setThermoModel(); - if (fluidType.equals("water")) { - compNames = new String[] {"water"}; - flowrate = new double[] {1.0}; - createFluid(compNames, flowrate, "mole/sec"); - } - if (fluidType.equals("dry gas")) { - compNames = new String[] {"nitrogen", "CO2", "methane", "ethane", "propane", "i-butane", - "n-butane"}; - flowrate = new double[] {0.01, 0.02, 0.82, 0.11, 0.05, 0.01, 0.012}; - createFluid(compNames, flowrate, "mole/sec"); - } else if (fluidType.equals("rich gas")) { - compNames = new String[] {"nitrogen", "CO2", "methane", "ethane", "propane", "i-butane", - "n-butane", "i-pentane", "n-pentane", "n-hexane", "n-heptane", "n-octane", - "n-nonane", "nC10"}; - flowrate = new double[] {0.01, 0.02, 0.82, 0.11, 0.05, 0.01, 0.012, 0.01, 0.01, 0.01, - 0.01, 0.01, 0.01, 0.01}; - createFluid(compNames, flowrate, "mole/sec"); - } else if (fluidType.equals("air")) { - compNames = new String[] {"nitrogen", "oxygen"}; - flowrate = new double[] {0.78, 0.22}; - createFluid(compNames, flowrate, "mole/sec"); - } else if (fluidType.equals("combustion air")) { - compNames = new String[] {"nitrogen", "oxygen", "CO2", "water"}; - flowrate = new double[] {0.78084, 0.20946, 0.033, 0.1}; - createFluid(compNames, flowrate, "mole/sec"); - } else if (fluidType.equals("gas condensate")) { - compNames = new String[] {"nitrogen", "CO2", "methane", "ethane", "propane", "i-butane", - "n-butane", "i-pentane", "n-pentane", "n-hexane", "n-heptane", "n-octane", - "n-nonane", "nC10"}; - flowrate = new double[] {0.01, 0.02, 0.32, 0.05, 0.03, 0.01, 0.012, 0.01, 0.01, 0.01, - 0.01, 0.01, 0.01, 0.01}; - createFluid(compNames, flowrate, "mole/sec"); - String[] charNames = new String[] {"C10-C15", "C16-C19", "C20-C30", "C31-C50"}; - double[] charFlowrate = new double[] {0.1, 0.08, 0.05, 0.01}; - double[] molarMass = new double[] {0.20, 0.3, 0.36, 0.4}; - double[] density = new double[] {700.0e-3, 810.0e-3, 880.0e-3, 920.0e-3}; - addCharacterized(charNames, charFlowrate, molarMass, density); - } else if (fluidType.equals("petrol")) { - compNames = new String[] {"n-pentane", "n-hexane", "n-heptane", "n-octane", "n-nonane", - "nC10", "nC11", "nC12"}; - flowrate = new double[] {0.1, 0.1, 0.1, 0.1, 0.3, 0.1, 0.1, 0.1}; - createFluid(compNames, flowrate, "mole/sec"); - } else if (fluidType.equals("diesel")) { - compNames = new String[] {"n-heptane", "n-octane", "n-nonane", "nC10", "nC11", "nC12", - "nC13", "nC14"}; - flowrate = new double[] {0.1, 0.1, 0.1, 0.3, 0.1, 0.1, 0.1, 0.1}; - createFluid(compNames, flowrate, "mole/sec"); - } else if (fluidType.equals("light oil")) { - compNames = new String[] {"nitrogen", "CO2", "methane", "ethane", "propane", "i-butane", - "n-butane", "i-pentane", "n-pentane", "n-hexane", "n-heptane", "n-octane", - "n-nonane", "nC10"}; - flowrate = new double[] {0.01, 0.02, 0.52, 0.11, 0.05, 0.01, 0.012, 0.01, 0.01, 0.01, - 0.01, 0.01, 0.01, 0.01}; - createFluid(compNames, flowrate, "mole/sec"); - String[] charNames = new String[] {"C10-C15", "C16-C19", "C20-C30", "C31-C50"}; - double[] charFlowrate = new double[] {0.2, 0.1, 0.05, 0.01}; - double[] molarMass = new double[] {0.20, 0.3, 0.36, 0.4}; - double[] density = new double[] {700.0e-3, 810.0e-3, 880.0e-3, 920.0e-3}; - addCharacterized(charNames, charFlowrate, molarMass, density); - } else if (fluidType.equals("black oil")) { - compNames = new String[] {"nitrogen", "CO2", "methane", "ethane", "propane", "i-butane", - "n-butane", "i-pentane", "n-pentane", "n-hexane"}; - flowrate = new double[] {0.01, 0.02, 0.22, 0.11, 0.05, 0.01, 0.012, 0.01, 0.01, 0.01}; - createFluid(compNames, flowrate, "mole/sec"); - String[] charNames = - new String[] {"C10-C15", "C16-C19", "C20-C30", "C31-C50", "C51-C80"}; - double[] charFlowrate = new double[] {0.2, 0.1, 0.1, 0.05, 0.01}; - double[] molarMass = new double[] {0.20, 0.25, 0.3, 0.36, 0.4}; - double[] density = new double[] {700.0e-3, 750.0e-3, 810.0e-3, 880.0e-3, 920.0e-3}; - addCharacterized(charNames, charFlowrate, molarMass, density); - } else if (fluidType.equals("black oil with water")) { - compNames = new String[] {"nitrogen", "CO2", "methane", "ethane", "propane", "i-butane", - "n-butane", "i-pentane", "n-pentane", "n-hexane"}; - flowrate = new double[] {0.01, 0.02, 0.22, 0.11, 0.05, 0.01, 0.012, 0.01, 0.01, 0.01}; - createFluid(compNames, flowrate, "mole/sec"); - String[] charNames = - new String[] {"C10-C15", "C16-C19", "C20-C30", "C31-C50", "C51-C80"}; - double[] charFlowrate = new double[] {0.2, 0.1, 0.1, 0.05, 0.01}; - double[] molarMass = new double[] {0.20, 0.25, 0.3, 0.36, 0.4}; - double[] density = new double[] {700.0e-3, 750.0e-3, 810.0e-3, 880.0e-3, 920.0e-3}; - addCharacterized(charNames, charFlowrate, molarMass, density); - setHasWater(true); - } else if (fluidType.equals("heavy oil")) { - compNames = new String[] {"nitrogen", "CO2", "methane", "ethane", "propane", "i-butane", - "n-butane", "i-pentane", "n-pentane", "n-hexane"}; - flowrate = new double[] {0.01, 0.01, 0.12, 0.11, 0.05, 0.01, 0.012, 0.01, 0.01, 0.01}; - createFluid(compNames, flowrate, "mole/sec"); - String[] charNames = - new String[] {"C10-C15", "C16-C19", "C20-C30", "C31-C50", "C51-C80"}; - double[] charFlowrate = new double[] {0.2, 0.2, 0.2, 0.1, 0.1}; - double[] molarMass = new double[] {0.20, 0.25, 0.3, 0.36, 0.4}; - double[] density = new double[] {700.0e-3, 750.0e-3, 810.0e-3, 880.0e-3, 920.0e-3}; - addCharacterized(charNames, charFlowrate, molarMass, density); - } else if (neqsim.util.database.NeqSimDataBase.hasComponent(fluidType)) { - compNames = new String[] {fluidType}; - flowrate = new double[] {1.0}; - createFluid(compNames, flowrate, "mole/sec"); - } else { - return null; - } - - if (isHasWater() == true) - fluid.addComponent("water", 0.1); - fluid.createDatabase(true); - setMixingRule(); - if (isHasWater()) { - fluid.setMultiPhaseCheck(true); - } - if (isAutoSelectModel()) { - fluid = fluid.autoSelectModel(); - } - fluid.init(0); - return fluid; + /** + *

+ * create. + *

+ * + * @param fluidType a {@link java.lang.String} object + * @return a {@link neqsim.thermo.system.SystemInterface} object + */ + public static neqsim.thermo.system.SystemInterface create(String fluidType) { + String[] compNames = null; + double[] flowrate = null; + setThermoModel(); + if (fluidType.equals("water")) { + compNames = new String[] {"water"}; + flowrate = new double[] {1.0}; + createFluid(compNames, flowrate, "mole/sec"); + } + if (fluidType.equals("dry gas")) { + compNames = + new String[] {"nitrogen", "CO2", "methane", "ethane", "propane", "i-butane", "n-butane"}; + flowrate = new double[] {0.01, 0.02, 0.82, 0.11, 0.05, 0.01, 0.012}; + createFluid(compNames, flowrate, "mole/sec"); + } else if (fluidType.equals("rich gas")) { + compNames = + new String[] {"nitrogen", "CO2", "methane", "ethane", "propane", "i-butane", "n-butane", + "i-pentane", "n-pentane", "n-hexane", "n-heptane", "n-octane", "n-nonane", "nC10"}; + flowrate = new double[] {0.01, 0.02, 0.82, 0.11, 0.05, 0.01, 0.012, 0.01, 0.01, 0.01, 0.01, + 0.01, 0.01, 0.01}; + createFluid(compNames, flowrate, "mole/sec"); + } else if (fluidType.equals("air")) { + compNames = new String[] {"nitrogen", "oxygen"}; + flowrate = new double[] {0.78, 0.22}; + createFluid(compNames, flowrate, "mole/sec"); + } else if (fluidType.equals("combustion air")) { + compNames = new String[] {"nitrogen", "oxygen", "CO2", "water"}; + flowrate = new double[] {0.78084, 0.20946, 0.033, 0.1}; + createFluid(compNames, flowrate, "mole/sec"); + } else if (fluidType.equals("gas condensate")) { + compNames = + new String[] {"nitrogen", "CO2", "methane", "ethane", "propane", "i-butane", "n-butane", + "i-pentane", "n-pentane", "n-hexane", "n-heptane", "n-octane", "n-nonane", "nC10"}; + flowrate = new double[] {0.01, 0.02, 0.32, 0.05, 0.03, 0.01, 0.012, 0.01, 0.01, 0.01, 0.01, + 0.01, 0.01, 0.01}; + createFluid(compNames, flowrate, "mole/sec"); + String[] charNames = new String[] {"C10-C15", "C16-C19", "C20-C30", "C31-C50"}; + double[] charFlowrate = new double[] {0.1, 0.08, 0.05, 0.01}; + double[] molarMass = new double[] {0.20, 0.3, 0.36, 0.4}; + double[] density = new double[] {700.0e-3, 810.0e-3, 880.0e-3, 920.0e-3}; + addCharacterized(charNames, charFlowrate, molarMass, density); + } else if (fluidType.equals("petrol")) { + compNames = new String[] {"n-pentane", "n-hexane", "n-heptane", "n-octane", "n-nonane", + "nC10", "nC11", "nC12"}; + flowrate = new double[] {0.1, 0.1, 0.1, 0.1, 0.3, 0.1, 0.1, 0.1}; + createFluid(compNames, flowrate, "mole/sec"); + } else if (fluidType.equals("diesel")) { + compNames = new String[] {"n-heptane", "n-octane", "n-nonane", "nC10", "nC11", "nC12", "nC13", + "nC14"}; + flowrate = new double[] {0.1, 0.1, 0.1, 0.3, 0.1, 0.1, 0.1, 0.1}; + createFluid(compNames, flowrate, "mole/sec"); + } else if (fluidType.equals("light oil")) { + compNames = + new String[] {"nitrogen", "CO2", "methane", "ethane", "propane", "i-butane", "n-butane", + "i-pentane", "n-pentane", "n-hexane", "n-heptane", "n-octane", "n-nonane", "nC10"}; + flowrate = new double[] {0.01, 0.02, 0.52, 0.11, 0.05, 0.01, 0.012, 0.01, 0.01, 0.01, 0.01, + 0.01, 0.01, 0.01}; + createFluid(compNames, flowrate, "mole/sec"); + String[] charNames = new String[] {"C10-C15", "C16-C19", "C20-C30", "C31-C50"}; + double[] charFlowrate = new double[] {0.2, 0.1, 0.05, 0.01}; + double[] molarMass = new double[] {0.20, 0.3, 0.36, 0.4}; + double[] density = new double[] {700.0e-3, 810.0e-3, 880.0e-3, 920.0e-3}; + addCharacterized(charNames, charFlowrate, molarMass, density); + } else if (fluidType.equals("black oil")) { + compNames = new String[] {"nitrogen", "CO2", "methane", "ethane", "propane", "i-butane", + "n-butane", "i-pentane", "n-pentane", "n-hexane"}; + flowrate = new double[] {0.01, 0.02, 0.22, 0.11, 0.05, 0.01, 0.012, 0.01, 0.01, 0.01}; + createFluid(compNames, flowrate, "mole/sec"); + String[] charNames = new String[] {"C10-C15", "C16-C19", "C20-C30", "C31-C50", "C51-C80"}; + double[] charFlowrate = new double[] {0.2, 0.1, 0.1, 0.05, 0.01}; + double[] molarMass = new double[] {0.20, 0.25, 0.3, 0.36, 0.4}; + double[] density = new double[] {700.0e-3, 750.0e-3, 810.0e-3, 880.0e-3, 920.0e-3}; + addCharacterized(charNames, charFlowrate, molarMass, density); + } else if (fluidType.equals("black oil with water")) { + compNames = new String[] {"nitrogen", "CO2", "methane", "ethane", "propane", "i-butane", + "n-butane", "i-pentane", "n-pentane", "n-hexane"}; + flowrate = new double[] {0.01, 0.02, 0.22, 0.11, 0.05, 0.01, 0.012, 0.01, 0.01, 0.01}; + createFluid(compNames, flowrate, "mole/sec"); + String[] charNames = new String[] {"C10-C15", "C16-C19", "C20-C30", "C31-C50", "C51-C80"}; + double[] charFlowrate = new double[] {0.2, 0.1, 0.1, 0.05, 0.01}; + double[] molarMass = new double[] {0.20, 0.25, 0.3, 0.36, 0.4}; + double[] density = new double[] {700.0e-3, 750.0e-3, 810.0e-3, 880.0e-3, 920.0e-3}; + addCharacterized(charNames, charFlowrate, molarMass, density); + setHasWater(true); + } else if (fluidType.equals("heavy oil")) { + compNames = new String[] {"nitrogen", "CO2", "methane", "ethane", "propane", "i-butane", + "n-butane", "i-pentane", "n-pentane", "n-hexane"}; + flowrate = new double[] {0.01, 0.01, 0.12, 0.11, 0.05, 0.01, 0.012, 0.01, 0.01, 0.01}; + createFluid(compNames, flowrate, "mole/sec"); + String[] charNames = new String[] {"C10-C15", "C16-C19", "C20-C30", "C31-C50", "C51-C80"}; + double[] charFlowrate = new double[] {0.2, 0.2, 0.2, 0.1, 0.1}; + double[] molarMass = new double[] {0.20, 0.25, 0.3, 0.36, 0.4}; + double[] density = new double[] {700.0e-3, 750.0e-3, 810.0e-3, 880.0e-3, 920.0e-3}; + addCharacterized(charNames, charFlowrate, molarMass, density); + } else if (neqsim.util.database.NeqSimDataBase.hasComponent(fluidType)) { + compNames = new String[] {fluidType}; + flowrate = new double[] {1.0}; + createFluid(compNames, flowrate, "mole/sec"); + } else { + return null; } - /** - *

- * addCharacterized. - *

- * - * @param charNames an array of {@link java.lang.String} objects - * @param charFlowrate an array of {@link double} objects - * @param molarMass an array of {@link double} objects - * @param relativedensity an array of {@link double} objects - */ - public static void addCharacterized(String[] charNames, double[] charFlowrate, - double[] molarMass, double[] relativedensity) { - if (charNames.length != charFlowrate.length) { - logger.error("component names and mole fractions need to be same length..."); - } - for (int i = 0; i < charNames.length; i++) { - fluid.addTBPfraction(charNames[i], charFlowrate[i], molarMass[i], relativedensity[i]); - } + if (isHasWater() == true) + fluid.addComponent("water", 0.1); + fluid.createDatabase(true); + setMixingRule(); + if (isHasWater()) { + fluid.setMultiPhaseCheck(true); } + if (isAutoSelectModel()) { + fluid = fluid.autoSelectModel(); + } + fluid.init(0); + return fluid; + } - /** - *

- * addOilFractions. - *

- * - * @param charNames an array of {@link java.lang.String} objects - * @param charFlowrate an array of {@link double} objects - * @param molarMass an array of {@link double} objects - * @param relativedensity an array of {@link double} objects - * @param lastIsPlusFraction a boolean - * @return a {@link neqsim.thermo.system.SystemInterface} object - */ - public static neqsim.thermo.system.SystemInterface addOilFractions(String[] charNames, - double[] charFlowrate, double[] molarMass, double[] relativedensity, - boolean lastIsPlusFraction) { - if (charNames.length != charFlowrate.length) { - logger.error("component names and mole fractions need to be same length..."); - } + /** + *

+ * addCharacterized. + *

+ * + * @param charNames an array of {@link java.lang.String} objects + * @param charFlowrate an array of {@link double} objects + * @param molarMass an array of {@link double} objects + * @param relativedensity an array of {@link double} objects + */ + public static void addCharacterized(String[] charNames, double[] charFlowrate, double[] molarMass, + double[] relativedensity) { + if (charNames.length != charFlowrate.length) { + logger.error("component names and mole fractions need to be same length..."); + } + for (int i = 0; i < charNames.length; i++) { + fluid.addTBPfraction(charNames[i], charFlowrate[i], molarMass[i], relativedensity[i]); + } + } - for (int i = 0; i < charNames.length - 1; i++) { - fluid.addTBPfraction(charNames[i], charFlowrate[i], molarMass[i], relativedensity[i]); - } - int i = charNames.length - 1; - if (lastIsPlusFraction) { - fluid.addPlusFraction(charNames[i], charFlowrate[i], molarMass[i], relativedensity[i]); - } else { - fluid.addTBPfraction(charNames[i], charFlowrate[i], molarMass[i], relativedensity[i]); - } - fluid.createDatabase(true); - if (lastIsPlusFraction) { - fluid.getCharacterization().getLumpingModel().setNumberOfPseudoComponents(12); - fluid.getCharacterization().setLumpingModel("PVTlumpingModel"); - fluid.getCharacterization().characterisePlusFraction(); - } - setMixingRule(); - fluid.setMultiPhaseCheck(true); - fluid.init(0); - return fluid; + /** + *

+ * addOilFractions. + *

+ * + * @param charNames an array of {@link java.lang.String} objects + * @param charFlowrate an array of {@link double} objects + * @param molarMass an array of {@link double} objects + * @param relativedensity an array of {@link double} objects + * @param lastIsPlusFraction a boolean + * @return a {@link neqsim.thermo.system.SystemInterface} object + */ + public static neqsim.thermo.system.SystemInterface addOilFractions(String[] charNames, + double[] charFlowrate, double[] molarMass, double[] relativedensity, + boolean lastIsPlusFraction) { + if (charNames.length != charFlowrate.length) { + logger.error("component names and mole fractions need to be same length..."); } - /** - *

- * createFluid. - *

- * - * @param componentNames an array of {@link java.lang.String} objects - * @param flowrate an array of {@link double} objects - * @param unit a {@link java.lang.String} object - * @return a {@link neqsim.thermo.system.SystemInterface} object - */ - public static neqsim.thermo.system.SystemInterface createFluid(String[] componentNames, - double[] flowrate, String unit) { - if (componentNames.length != flowrate.length) { - logger.error("component names and mole fractions need to be same length..."); - } + for (int i = 0; i < charNames.length - 1; i++) { + fluid.addTBPfraction(charNames[i], charFlowrate[i], molarMass[i], relativedensity[i]); + } + int i = charNames.length - 1; + if (lastIsPlusFraction) { + fluid.addPlusFraction(charNames[i], charFlowrate[i], molarMass[i], relativedensity[i]); + } else { + fluid.addTBPfraction(charNames[i], charFlowrate[i], molarMass[i], relativedensity[i]); + } + fluid.createDatabase(true); + if (lastIsPlusFraction) { + fluid.getCharacterization().getLumpingModel().setNumberOfPseudoComponents(12); + fluid.getCharacterization().setLumpingModel("PVTlumpingModel"); + fluid.getCharacterization().characterisePlusFraction(); + } + setMixingRule(); + fluid.setMultiPhaseCheck(true); + fluid.init(0); + return fluid; + } - for (int i = 0; i < componentNames.length; i++) { - fluid.addComponent(componentNames[i], flowrate[i], unit); - } + /** + *

+ * createFluid. + *

+ * + * @param componentNames an array of {@link java.lang.String} objects + * @param flowrate an array of {@link double} objects + * @param unit a {@link java.lang.String} object + * @return a {@link neqsim.thermo.system.SystemInterface} object + */ + public static neqsim.thermo.system.SystemInterface createFluid(String[] componentNames, + double[] flowrate, String unit) { + if (componentNames.length != flowrate.length) { + logger.error("component names and mole fractions need to be same length..."); + } - return fluid; + for (int i = 0; i < componentNames.length; i++) { + fluid.addComponent(componentNames[i], flowrate[i], unit); } - /** - *

- * addComponment. - *

- * - * @param name a {@link java.lang.String} object - */ - public static void addComponment(String name) { - fluid.addComponent(name, 1.0); - fluid.createDatabase(true); - fluid.setMixingRule(2); + return fluid; + } + + /** + *

+ * addComponment. + *

+ * + * @param name a {@link java.lang.String} object + */ + public static void addComponment(String name) { + fluid.addComponent(name, 1.0); + fluid.createDatabase(true); + fluid.setMixingRule(2); - if (isHasWater()) { - fluid.setMultiPhaseCheck(true); - } + if (isHasWater()) { + fluid.setMultiPhaseCheck(true); } + } - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - neqsim.thermo.Fluid.setHasWater(true); - neqsim.thermo.system.SystemInterface fluid = neqsim.thermo.Fluid.create("petrol"); - fluid.display(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + neqsim.thermo.Fluid.setHasWater(true); + neqsim.thermo.system.SystemInterface fluid = neqsim.thermo.Fluid.create("petrol"); + fluid.display(); - neqsim.thermo.system.SystemInterface fluid2 = neqsim.thermo.Fluid.create("dry gas"); - fluid2.display(); - fluid2.getNumberOfComponents(); + neqsim.thermo.system.SystemInterface fluid2 = neqsim.thermo.Fluid.create("dry gas"); + fluid2.display(); + fluid2.getNumberOfComponents(); - neqsim.thermo.system.SystemInterface fluid3 = - neqsim.thermo.Fluid.create("black oil with water"); - fluid3.display(); - fluid3.getNumberOfComponents(); - } + neqsim.thermo.system.SystemInterface fluid3 = + neqsim.thermo.Fluid.create("black oil with water"); + fluid3.display(); + fluid3.getNumberOfComponents(); + } - /** - *

- * isHasWater. - *

- * - * @return a boolean - */ - public static boolean isHasWater() { - return hasWater; - } + /** + *

+ * isHasWater. + *

+ * + * @return a boolean + */ + public static boolean isHasWater() { + return hasWater; + } - /** - *

- * Setter for the field hasWater. - *

- * - * @param hasWater a boolean - */ - public static void setHasWater(boolean hasWater) { - Fluid.hasWater = hasWater; - } + /** + *

+ * Setter for the field hasWater. + *

+ * + * @param hasWater a boolean + */ + public static void setHasWater(boolean hasWater) { + Fluid.hasWater = hasWater; + } - /** - *

- * isAutoSelectModel. - *

- * - * @return a boolean - */ - public static boolean isAutoSelectModel() { - return autoSelectModel; - } + /** + *

+ * isAutoSelectModel. + *

+ * + * @return a boolean + */ + public static boolean isAutoSelectModel() { + return autoSelectModel; + } - /** - *

- * Setter for the field autoSelectModel. - *

- * - * @param autoSelectModel a boolean - */ - public static void setAutoSelectModel(boolean autoSelectModel) { - Fluid.autoSelectModel = autoSelectModel; - } + /** + *

+ * Setter for the field autoSelectModel. + *

+ * + * @param autoSelectModel a boolean + */ + public static void setAutoSelectModel(boolean autoSelectModel) { + Fluid.autoSelectModel = autoSelectModel; + } - /** - *

- * Getter for the field thermoModel. - *

- * - * @return a {@link java.lang.String} object - */ - public static String getThermoModel() { - return thermoModel; - } + /** + *

+ * Getter for the field thermoModel. + *

+ * + * @return a {@link java.lang.String} object + */ + public static String getThermoModel() { + return thermoModel; + } - /** - *

- * Setter for the field thermoModel. - *

- * - * @param thermoModel a {@link java.lang.String} object - */ - public static void setThermoModel(String thermoModel) { - Fluid.thermoModel = thermoModel; - } + /** + *

+ * Setter for the field thermoModel. + *

+ * + * @param thermoModel a {@link java.lang.String} object + */ + public static void setThermoModel(String thermoModel) { + Fluid.thermoModel = thermoModel; + } - /** - *

- * Getter for the field thermoMixingRule. - *

- * - * @return a {@link java.lang.String} object - */ - public static String getThermoMixingRule() { - return thermoMixingRule; - } + /** + *

+ * Getter for the field thermoMixingRule. + *

+ * + * @return a {@link java.lang.String} object + */ + public static String getThermoMixingRule() { + return thermoMixingRule; + } - /** - *

- * Setter for the field thermoMixingRule. - *

- * - * @param thermoMixingRule a {@link java.lang.String} object - */ - public static void setThermoMixingRule(String thermoMixingRule) { - Fluid.thermoMixingRule = thermoMixingRule; - } + /** + *

+ * Setter for the field thermoMixingRule. + *

+ * + * @param thermoMixingRule a {@link java.lang.String} object + */ + public static void setThermoMixingRule(String thermoMixingRule) { + Fluid.thermoMixingRule = thermoMixingRule; + } } diff --git a/src/main/java/neqsim/thermo/ThermodynamicConstantsInterface.java b/src/main/java/neqsim/thermo/ThermodynamicConstantsInterface.java index c984924b3c..381effc82e 100644 --- a/src/main/java/neqsim/thermo/ThermodynamicConstantsInterface.java +++ b/src/main/java/neqsim/thermo/ThermodynamicConstantsInterface.java @@ -3,6 +3,7 @@ * * Created on 3. juni 2000, 19:07 */ + package neqsim.thermo; /** diff --git a/src/main/java/neqsim/thermo/ThermodynamicModelTest.java b/src/main/java/neqsim/thermo/ThermodynamicModelTest.java index babbd3d846..9c09e13055 100644 --- a/src/main/java/neqsim/thermo/ThermodynamicModelTest.java +++ b/src/main/java/neqsim/thermo/ThermodynamicModelTest.java @@ -3,6 +3,7 @@ * * Created on 7. mai 2001, 19:20 */ + package neqsim.thermo; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/neqsim/thermo/atomElement/Element.java b/src/main/java/neqsim/thermo/atomElement/Element.java index b0197e7bdf..172678e1b9 100644 --- a/src/main/java/neqsim/thermo/atomElement/Element.java +++ b/src/main/java/neqsim/thermo/atomElement/Element.java @@ -3,6 +3,7 @@ * * Created on 4. februar 2001, 22:11 */ + package neqsim.thermo.atomElement; import java.util.ArrayList; diff --git a/src/main/java/neqsim/thermo/characterization/TBPCharacterize.java b/src/main/java/neqsim/thermo/characterization/TBPCharacterize.java index c2f557a4e9..4c195acf04 100644 --- a/src/main/java/neqsim/thermo/characterization/TBPCharacterize.java +++ b/src/main/java/neqsim/thermo/characterization/TBPCharacterize.java @@ -3,6 +3,7 @@ * * Created on 3. januar 2003, 10:03 */ + package neqsim.thermo.characterization; import neqsim.thermo.system.SystemInterface; diff --git a/src/main/java/neqsim/thermo/component/Component.java b/src/main/java/neqsim/thermo/component/Component.java index 311072fb94..a4a3738f4a 100644 --- a/src/main/java/neqsim/thermo/component/Component.java +++ b/src/main/java/neqsim/thermo/component/Component.java @@ -3,11 +3,11 @@ * * Created on 8. april 2000, 23:28 */ + package neqsim.thermo.component; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.atomElement.Element; import neqsim.thermo.component.attractiveEosTerm.AttractiveTermInterface; diff --git a/src/main/java/neqsim/thermo/component/ComponentEos.java b/src/main/java/neqsim/thermo/component/ComponentEos.java index f8f982a259..20e11d2c59 100644 --- a/src/main/java/neqsim/thermo/component/ComponentEos.java +++ b/src/main/java/neqsim/thermo/component/ComponentEos.java @@ -3,6 +3,7 @@ * * Created on 14. mai 2000, 21:27 */ + package neqsim.thermo.component; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/neqsim/thermo/component/ComponentEosInterface.java b/src/main/java/neqsim/thermo/component/ComponentEosInterface.java index 8d8690371b..b6c6f2af8d 100644 --- a/src/main/java/neqsim/thermo/component/ComponentEosInterface.java +++ b/src/main/java/neqsim/thermo/component/ComponentEosInterface.java @@ -3,6 +3,7 @@ * * Created on 4. juni 2000, 13:35 */ + package neqsim.thermo.component; import neqsim.thermo.phase.PhaseInterface; diff --git a/src/main/java/neqsim/thermo/component/ComponentGE.java b/src/main/java/neqsim/thermo/component/ComponentGE.java index f8aa2c92d7..c727459ad1 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGE.java +++ b/src/main/java/neqsim/thermo/component/ComponentGE.java @@ -3,6 +3,7 @@ * * Created on 10. juli 2000, 21:05 */ + package neqsim.thermo.component; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/neqsim/thermo/component/ComponentGEInterface.java b/src/main/java/neqsim/thermo/component/ComponentGEInterface.java index b54ecb6541..0fcd0fca41 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGEInterface.java +++ b/src/main/java/neqsim/thermo/component/ComponentGEInterface.java @@ -3,6 +3,7 @@ * * Created on 11. juli 2000, 19:58 */ + package neqsim.thermo.component; import neqsim.thermo.phase.PhaseInterface; diff --git a/src/main/java/neqsim/thermo/component/ComponentGENRTLmodifiedHV.java b/src/main/java/neqsim/thermo/component/ComponentGENRTLmodifiedHV.java index 9064269e22..0be963182a 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGENRTLmodifiedHV.java +++ b/src/main/java/neqsim/thermo/component/ComponentGENRTLmodifiedHV.java @@ -3,6 +3,7 @@ * * Created on 18. juli 2000, 18:36 */ + package neqsim.thermo.component; import neqsim.thermo.phase.PhaseInterface; diff --git a/src/main/java/neqsim/thermo/component/ComponentGEUnifac.java b/src/main/java/neqsim/thermo/component/ComponentGEUnifac.java index e0453f0a4d..fdf5090dae 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGEUnifac.java +++ b/src/main/java/neqsim/thermo/component/ComponentGEUnifac.java @@ -3,6 +3,7 @@ * * Created on 10. juli 2000, 21:06 */ + package neqsim.thermo.component; import java.util.ArrayList; diff --git a/src/main/java/neqsim/thermo/component/ComponentGEUniquac.java b/src/main/java/neqsim/thermo/component/ComponentGEUniquac.java index 3d3b8269dc..027e23f15a 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGEUniquac.java +++ b/src/main/java/neqsim/thermo/component/ComponentGEUniquac.java @@ -3,6 +3,7 @@ * * Created on 10. juli 2000, 21:06 */ + package neqsim.thermo.component; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/neqsim/thermo/component/ComponentGEUniquacmodifiedHV.java b/src/main/java/neqsim/thermo/component/ComponentGEUniquacmodifiedHV.java index 5f16c197a3..1fa41715ee 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGEUniquacmodifiedHV.java +++ b/src/main/java/neqsim/thermo/component/ComponentGEUniquacmodifiedHV.java @@ -3,6 +3,7 @@ * * Created on 18. juli 2000, 20:24 */ + package neqsim.thermo.component; import neqsim.thermo.phase.PhaseInterface; diff --git a/src/main/java/neqsim/thermo/component/ComponentInterface.java b/src/main/java/neqsim/thermo/component/ComponentInterface.java index fc85180f19..abbd5e36aa 100644 --- a/src/main/java/neqsim/thermo/component/ComponentInterface.java +++ b/src/main/java/neqsim/thermo/component/ComponentInterface.java @@ -3,10 +3,10 @@ * * Created on 8. april 2000, 23:15 */ + package neqsim.thermo.component; import java.util.LinkedHashMap; - import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.atomElement.Element; import neqsim.thermo.component.attractiveEosTerm.AttractiveTermInterface; diff --git a/src/main/java/neqsim/thermo/component/ComponentModifiedFurstElectrolyteEos.java b/src/main/java/neqsim/thermo/component/ComponentModifiedFurstElectrolyteEos.java index d930f586ef..d7dd80d6fc 100644 --- a/src/main/java/neqsim/thermo/component/ComponentModifiedFurstElectrolyteEos.java +++ b/src/main/java/neqsim/thermo/component/ComponentModifiedFurstElectrolyteEos.java @@ -3,6 +3,7 @@ * * Created on 26. februar 2001, 17:59 */ + package neqsim.thermo.component; import neqsim.thermo.phase.PhaseInterface; diff --git a/src/main/java/neqsim/thermo/component/ComponentModifiedFurstElectrolyteEosMod2004.java b/src/main/java/neqsim/thermo/component/ComponentModifiedFurstElectrolyteEosMod2004.java index 5838bfb35d..621fbdd018 100644 --- a/src/main/java/neqsim/thermo/component/ComponentModifiedFurstElectrolyteEosMod2004.java +++ b/src/main/java/neqsim/thermo/component/ComponentModifiedFurstElectrolyteEosMod2004.java @@ -3,6 +3,7 @@ * * Created on 26. februar 2001, 17:59 */ + package neqsim.thermo.component; import neqsim.thermo.phase.PhaseInterface; diff --git a/src/main/java/neqsim/thermo/component/ComponentPRvolcor.java b/src/main/java/neqsim/thermo/component/ComponentPRvolcor.java index 78c76de4e4..b13fc88997 100644 --- a/src/main/java/neqsim/thermo/component/ComponentPRvolcor.java +++ b/src/main/java/neqsim/thermo/component/ComponentPRvolcor.java @@ -3,6 +3,7 @@ * * Created on 8. april 2000, 23:14 */ + package neqsim.thermo.component; import neqsim.thermo.phase.PhaseInterface; diff --git a/src/main/java/neqsim/thermo/component/ComponentSolid.java b/src/main/java/neqsim/thermo/component/ComponentSolid.java index 705e287055..9b6601f6a9 100644 --- a/src/main/java/neqsim/thermo/component/ComponentSolid.java +++ b/src/main/java/neqsim/thermo/component/ComponentSolid.java @@ -3,6 +3,7 @@ * * Created on 18. august 2001, 12:45 */ + package neqsim.thermo.component; import neqsim.thermo.phase.PhaseInterface; diff --git a/src/main/java/neqsim/thermo/component/ComponentWax.java b/src/main/java/neqsim/thermo/component/ComponentWax.java index 851cfb910f..368d871e39 100644 --- a/src/main/java/neqsim/thermo/component/ComponentWax.java +++ b/src/main/java/neqsim/thermo/component/ComponentWax.java @@ -3,6 +3,7 @@ * * Created on 18. august 2001, 12:45 */ + package neqsim.thermo.component; import neqsim.thermo.phase.PhaseInterface; diff --git a/src/main/java/neqsim/thermo/component/ComponentWaxWilson.java b/src/main/java/neqsim/thermo/component/ComponentWaxWilson.java index 0d1475cf0b..c3910088df 100644 --- a/src/main/java/neqsim/thermo/component/ComponentWaxWilson.java +++ b/src/main/java/neqsim/thermo/component/ComponentWaxWilson.java @@ -3,6 +3,7 @@ * * Created on 18. august 2001, 12:45 */ + package neqsim.thermo.component; import neqsim.thermo.ThermodynamicConstantsInterface; diff --git a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermBaseClass.java b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermBaseClass.java index ec0b61d49b..9619408015 100644 --- a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermBaseClass.java +++ b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermBaseClass.java @@ -3,6 +3,7 @@ * * Created on 13. mai 2001, 21:58 */ + package neqsim.thermo.component.attractiveEosTerm; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermInterface.java b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermInterface.java index 94bee07b86..ec4bafa956 100644 --- a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermInterface.java +++ b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermInterface.java @@ -3,6 +3,7 @@ * * Created on 13. mai 2001, 21:54 */ + package neqsim.thermo.component.attractiveEosTerm; /** diff --git a/src/main/java/neqsim/thermo/mixingRule/CPAMixing.java b/src/main/java/neqsim/thermo/mixingRule/CPAMixing.java index 60daa21ee2..35a98f95af 100644 --- a/src/main/java/neqsim/thermo/mixingRule/CPAMixing.java +++ b/src/main/java/neqsim/thermo/mixingRule/CPAMixing.java @@ -3,6 +3,7 @@ * * Created on 4. juni 2000, 12:38 */ + package neqsim.thermo.mixingRule; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/neqsim/thermo/mixingRule/CPAMixingInterface.java b/src/main/java/neqsim/thermo/mixingRule/CPAMixingInterface.java index 8a7441d115..54be13f966 100644 --- a/src/main/java/neqsim/thermo/mixingRule/CPAMixingInterface.java +++ b/src/main/java/neqsim/thermo/mixingRule/CPAMixingInterface.java @@ -3,6 +3,7 @@ * * Created on 26. februar 2001, 19:38 */ + package neqsim.thermo.mixingRule; import neqsim.thermo.phase.PhaseInterface; diff --git a/src/main/java/neqsim/thermo/mixingRule/ElectrolyteMixingRulesInterface.java b/src/main/java/neqsim/thermo/mixingRule/ElectrolyteMixingRulesInterface.java index 171c07a803..6004cd77f1 100644 --- a/src/main/java/neqsim/thermo/mixingRule/ElectrolyteMixingRulesInterface.java +++ b/src/main/java/neqsim/thermo/mixingRule/ElectrolyteMixingRulesInterface.java @@ -3,6 +3,7 @@ * * Created on 26. februar 2001, 19:38 */ + package neqsim.thermo.mixingRule; import neqsim.thermo.phase.PhaseInterface; diff --git a/src/main/java/neqsim/thermo/mixingRule/EosMixingRules.java b/src/main/java/neqsim/thermo/mixingRule/EosMixingRules.java index b55f2a7d86..ccf441caff 100644 --- a/src/main/java/neqsim/thermo/mixingRule/EosMixingRules.java +++ b/src/main/java/neqsim/thermo/mixingRule/EosMixingRules.java @@ -3,6 +3,7 @@ * * Created on 4. juni 2000, 12:38 */ + package neqsim.thermo.mixingRule; import java.awt.BorderLayout; diff --git a/src/main/java/neqsim/thermo/mixingRule/EosMixingRulesInterface.java b/src/main/java/neqsim/thermo/mixingRule/EosMixingRulesInterface.java index af46827335..86c8313947 100644 --- a/src/main/java/neqsim/thermo/mixingRule/EosMixingRulesInterface.java +++ b/src/main/java/neqsim/thermo/mixingRule/EosMixingRulesInterface.java @@ -3,6 +3,7 @@ * * Created on 4. juni 2000, 12:38 */ + package neqsim.thermo.mixingRule; import neqsim.thermo.phase.PhaseInterface; diff --git a/src/main/java/neqsim/thermo/mixingRule/HVmixingRuleInterface.java b/src/main/java/neqsim/thermo/mixingRule/HVmixingRuleInterface.java index 3bc7f84537..182931fd82 100644 --- a/src/main/java/neqsim/thermo/mixingRule/HVmixingRuleInterface.java +++ b/src/main/java/neqsim/thermo/mixingRule/HVmixingRuleInterface.java @@ -3,6 +3,7 @@ * * Created on 5. mai 2001, 17:48 */ + package neqsim.thermo.mixingRule; /** diff --git a/src/main/java/neqsim/thermo/phase/Phase.java b/src/main/java/neqsim/thermo/phase/Phase.java index c1e949e503..24688bcf6a 100644 --- a/src/main/java/neqsim/thermo/phase/Phase.java +++ b/src/main/java/neqsim/thermo/phase/Phase.java @@ -3,13 +3,12 @@ * * Created on 8. april 2000, 23:38 */ + package neqsim.thermo.phase; import java.util.ArrayList; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import neqsim.physicalProperties.PhysicalPropertyHandler; import neqsim.thermo.component.ComponentInterface; import neqsim.thermo.system.SystemInterface; @@ -17,7 +16,6 @@ /** * @author Even Solbraa */ - abstract class Phase implements PhaseInterface { private static final long serialVersionUID = 1000; @@ -70,8 +68,7 @@ public Phase() { * * @param phase a {@link neqsim.thermo.phase.Phase} object */ - public Phase(Phase phase) { - } + public Phase(Phase phase) {} /** {@inheritDoc} */ @Override @@ -169,15 +166,15 @@ public void addMolesChemReac(int component, double dn, double totdn) { if (numberOfMolesInPhase < 0.0 || getComponent(component).getNumberOfMolesInPhase() < 0.0) { String msg = "Negative number of moles in phase."; logger.error(msg); - neqsim.util.exception.InvalidInputException e = new neqsim.util.exception.InvalidInputException(this, - "addMolesChemReac", msg); + neqsim.util.exception.InvalidInputException e = + new neqsim.util.exception.InvalidInputException(this, "addMolesChemReac", msg); throw new RuntimeException(e); } if (getComponent(component).getNumberOfMolesInPhase() < 0.0) { String msg = "Negative number of moles of component " + component; logger.error(msg); - neqsim.util.exception.InvalidInputException e = new neqsim.util.exception.InvalidInputException(this, - "addMolesChemReac", msg); + neqsim.util.exception.InvalidInputException e = + new neqsim.util.exception.InvalidInputException(this, "addMolesChemReac", msg); throw new RuntimeException(e); } } @@ -282,7 +279,8 @@ public double getPressure() { /** {@inheritDoc} */ @Override public final double getPressure(String unit) { - neqsim.util.unit.PressureUnit presConversion = new neqsim.util.unit.PressureUnit(getPressure(), "bara"); + neqsim.util.unit.PressureUnit presConversion = + new neqsim.util.unit.PressureUnit(getPressure(), "bara"); return presConversion.getValue(unit); } @@ -505,11 +503,11 @@ public double getg() { * calcA. *

* - * @param comp a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param comp a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object * @param temperature a double - * @param pressure a double - * @param numbcomp a int + * @param pressure a double + * @param numbcomp a int * @return a double */ public double calcA(int comp, PhaseInterface phase, double temperature, double pressure, @@ -1211,7 +1209,7 @@ public void initRefPhases(boolean onlyPure) { *

* * @param onlyPure a boolean - * @param name a {@link java.lang.String} object + * @param name a {@link java.lang.String} object */ public void initRefPhases(boolean onlyPure, String name) { refPhase = new PhaseInterface[numberOfComponents]; @@ -1265,7 +1263,7 @@ public void initRefPhases(boolean onlyPure, String name) { * getLogPureComponentFugacity. *

* - * @param k a int + * @param k a int * @param pure a boolean * @return a double */ @@ -1453,8 +1451,8 @@ public double getOsmoticCoefficient(int watNumb) { ions += getComponent(j).getx(); } } - return -Math.log(oldFug * getComponent(watNumb).getx() / pureFug) - * getComponent(watNumb).getx() / ions; + return -Math.log(oldFug * getComponent(watNumb).getx() / pureFug) * getComponent(watNumb).getx() + / ions; } // public double getOsmoticCoefficient(int watNumb, String refState){ @@ -1815,8 +1813,7 @@ public void setPhysicalPropertyType(int physicalPropertyType) { /** {@inheritDoc} */ @Override public void setParams(PhaseInterface phase, double[][] alpha, double[][] Dij, double[][] DijT, - String[][] mixRule, double[][] intparam) { - } + String[][] mixRule, double[][] intparam) {} /** {@inheritDoc} */ @Override @@ -1901,8 +1898,7 @@ public final void setBeta(double beta) { /** {@inheritDoc} */ @Override - public void setMixingRuleGEModel(String name) { - } + public void setMixingRuleGEModel(String name) {} /** {@inheritDoc} */ @Override @@ -2093,7 +2089,8 @@ public double[] getProperties_GERG2008() { /** {@inheritDoc} */ @Override public double getDensity_AGA8() { - neqsim.thermo.util.GERG.NeqSimAGA8Detail test = new neqsim.thermo.util.GERG.NeqSimAGA8Detail(this); + neqsim.thermo.util.GERG.NeqSimAGA8Detail test = + new neqsim.thermo.util.GERG.NeqSimAGA8Detail(this); return test.getDensity(); } diff --git a/src/main/java/neqsim/thermo/phase/PhaseElectrolyteCPAstatoil.java b/src/main/java/neqsim/thermo/phase/PhaseElectrolyteCPAstatoil.java index e0499efe71..f040735147 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseElectrolyteCPAstatoil.java +++ b/src/main/java/neqsim/thermo/phase/PhaseElectrolyteCPAstatoil.java @@ -3,6 +3,7 @@ * * Created on 3. juni 2000, 14:38 */ + package neqsim.thermo.phase; import neqsim.thermo.component.ComponentElectrolyteCPAstatoil; @@ -16,81 +17,81 @@ * @version $Id: $Id */ public class PhaseElectrolyteCPAstatoil extends PhaseElectrolyteCPA { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for PhaseElectrolyteCPAstatoil. - *

- */ - public PhaseElectrolyteCPAstatoil() { - super(); - } + /** + *

+ * Constructor for PhaseElectrolyteCPAstatoil. + *

+ */ + public PhaseElectrolyteCPAstatoil() { + super(); + } - /** {@inheritDoc} */ - @Override - public void addcomponent(String componentName, double moles, double molesInPhase, - int compNumber) { - super.addcomponent(componentName, moles, molesInPhase, compNumber); - componentArray[compNumber] = - new ComponentElectrolyteCPAstatoil(componentName, moles, molesInPhase, compNumber); - } + /** {@inheritDoc} */ + @Override + public void addcomponent(String componentName, double moles, double molesInPhase, + int compNumber) { + super.addcomponent(componentName, moles, molesInPhase, compNumber); + componentArray[compNumber] = + new ComponentElectrolyteCPAstatoil(componentName, moles, molesInPhase, compNumber); + } - /** {@inheritDoc} */ - @Override - public PhaseElectrolyteCPAstatoil clone() { - PhaseElectrolyteCPAstatoil clonedPhase = null; - try { - clonedPhase = (PhaseElectrolyteCPAstatoil) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } - return clonedPhase; + /** {@inheritDoc} */ + @Override + public PhaseElectrolyteCPAstatoil clone() { + PhaseElectrolyteCPAstatoil clonedPhase = null; + try { + clonedPhase = (PhaseElectrolyteCPAstatoil) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); } + return clonedPhase; + } - /** {@inheritDoc} */ - @Override - public double calc_g() { - double x = 1.9 / 4.0 * getB() / getTotalVolume(); - double g = 1.0 / (1.0 - x); - // System.out.println("g " + g); - return g; - } + /** {@inheritDoc} */ + @Override + public double calc_g() { + double x = 1.9 / 4.0 * getB() / getTotalVolume(); + double g = 1.0 / (1.0 - x); + // System.out.println("g " + g); + return g; + } - /** {@inheritDoc} */ - @Override - public double calc_lngV() { - double x = 1.9 / 4.0 * getB() / getTotalVolume(); - double gv = (x / getTotalVolume()) / (1.0 - x); - return -gv; - } + /** {@inheritDoc} */ + @Override + public double calc_lngV() { + double x = 1.9 / 4.0 * getB() / getTotalVolume(); + double gv = (x / getTotalVolume()) / (1.0 - x); + return -gv; + } - /** {@inheritDoc} */ - @Override - public double calc_lngVV() { - double x = 1.9 / 4.0 * getB() / getTotalVolume(); - double xV = -1.9 / 4.0 * getB() / Math.pow(getTotalVolume(), 2.0); - double u = 1.0 - x; + /** {@inheritDoc} */ + @Override + public double calc_lngVV() { + double x = 1.9 / 4.0 * getB() / getTotalVolume(); + double xV = -1.9 / 4.0 * getB() / Math.pow(getTotalVolume(), 2.0); + double u = 1.0 - x; - double val = -x / (Math.pow(getTotalVolume(), 2.0) * u) + xV / (getTotalVolume() * u) - - x / (getTotalVolume() * u * u) * (-1.0) * xV; - return -val; + double val = -x / (Math.pow(getTotalVolume(), 2.0) * u) + xV / (getTotalVolume() * u) + - x / (getTotalVolume() * u * u) * (-1.0) * xV; + return -val; - // double gvv - // =0.225625/Math.pow(1.0-0.475*getB()/getTotalVolume(),2.0)*Math.pow(getB(),2.0)/(Math.pow(getTotalVolume(),4.0))+0.95/(1.0-0.475*getB()/getTotalVolume())*getB()/(Math.pow(getTotalVolume(),3.0)); - // System.out.println("val2 " + gvv); - // return gvv; - } + // double gvv + // =0.225625/Math.pow(1.0-0.475*getB()/getTotalVolume(),2.0)*Math.pow(getB(),2.0)/(Math.pow(getTotalVolume(),4.0))+0.95/(1.0-0.475*getB()/getTotalVolume())*getB()/(Math.pow(getTotalVolume(),3.0)); + // System.out.println("val2 " + gvv); + // return gvv; + } - /** {@inheritDoc} */ - @Override - public double calc_lngVVV() { - double gvv = -0.21434375 / Math.pow(1.0 - 0.475 * getB() / getTotalVolume(), 3.0) - * Math.pow(getB(), 3.0) / (Math.pow(getTotalVolume(), 6.0)) - - 0.135375E1 / Math.pow(1.0 - 0.475 * getB() / getTotalVolume(), 2.0) - * Math.pow(getB(), 2.0) / (Math.pow(getTotalVolume(), 5.0)) - - 0.285E1 / (1.0 - 0.475 * getB() / getTotalVolume()) * getB() - / (Math.pow(getTotalVolume(), 4.0)); - return gvv; - } + /** {@inheritDoc} */ + @Override + public double calc_lngVVV() { + double gvv = -0.21434375 / Math.pow(1.0 - 0.475 * getB() / getTotalVolume(), 3.0) + * Math.pow(getB(), 3.0) / (Math.pow(getTotalVolume(), 6.0)) + - 0.135375E1 / Math.pow(1.0 - 0.475 * getB() / getTotalVolume(), 2.0) + * Math.pow(getB(), 2.0) / (Math.pow(getTotalVolume(), 5.0)) + - 0.285E1 / (1.0 - 0.475 * getB() / getTotalVolume()) * getB() + / (Math.pow(getTotalVolume(), 4.0)); + return gvv; + } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseEos.java b/src/main/java/neqsim/thermo/phase/PhaseEos.java index b0a228cf7b..3d7846fabc 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseEos.java +++ b/src/main/java/neqsim/thermo/phase/PhaseEos.java @@ -3,6 +3,7 @@ * * Created on 3. juni 2000, 14:38 */ + package neqsim.thermo.phase; import org.apache.logging.log4j.LogManager; @@ -16,1236 +17,1269 @@ * @author Even Solbraa */ abstract class PhaseEos extends Phase implements PhaseEosInterface { - private static final long serialVersionUID = 1000; - - private double loc_A, loc_AT, loc_ATT, loc_B, f_loc = 0, g = 0; - public double delta1 = 0, delta2 = 0; - protected EosMixingRules mixSelect = null; - protected EosMixingRulesInterface mixRule = null; - double uEOS = 0, wEOS = 0; - static Logger logger = LogManager.getLogger(PhaseEos.class); - // Class methods - - /** {@inheritDoc} */ - @Override - public PhaseEos clone() { - PhaseEos clonedPhase = null; - try { - clonedPhase = (PhaseEos) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(PhaseEos.class); + + private double loc_A; + private double loc_AT; + private double loc_ATT; + private double loc_B; + private double f_loc = 0; + private double g = 0; + public double delta1 = 0; + public double delta2 = 0; + protected EosMixingRules mixSelect = null; + protected EosMixingRulesInterface mixRule = null; + double uEOS = 0; + double wEOS = 0; + // Class methods + + /** {@inheritDoc} */ + @Override + public PhaseEos clone() { + PhaseEos clonedPhase = null; + try { + clonedPhase = (PhaseEos) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); + } + + // clonedPhase.mixSelect = (EosMixingRules) mixSelect.clone(); + // clonedPhase.mixRule = (EosMixingRulesInterface) mixRule.clone(); + return clonedPhase; + } + + /** + *

+ * Constructor for PhaseEos. + *

+ */ + public PhaseEos() { + super(); + mixSelect = new EosMixingRules(); + componentArray = new ComponentEosInterface[MAX_NUMBER_OF_COMPONENTS]; + mixRule = mixSelect.getMixingRule(1); + // solver = new newtonRhapson(); + } + + /** {@inheritDoc} */ + @Override + public EosMixingRulesInterface getMixingRule() { + return mixRule; + } + + /** {@inheritDoc} */ + @Override + public void displayInteractionCoefficients(String intType) { + mixSelect.displayInteractionCoefficients(intType, this); + } + + /** {@inheritDoc} */ + @Override + public void addcomponent(double moles) { + super.addcomponent(moles); + } + + /** {@inheritDoc} */ + @Override + public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, + double beta) { + if (!mixingRuleDefined) { + setMixingRule(1); + } + + super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + + if (type != 0) { + loc_B = calcB(this, temperature, pressure, numberOfComponents); + loc_A = calcA(this, temperature, pressure, numberOfComponents); + } + + if (isConstantPhaseVolume()) { + setMolarVolume(getTotalVolume() / getNumberOfMolesInPhase()); + pressure = calcPressure(); + } + + if (type != 0) { + phaseTypeName = phase == 0 ? "liquid" : "gas"; + try { + if (calcMolarVolume) { + molarVolume = molarVolume(pressure, temperature, + getA() / numberOfMolesInPhase / numberOfMolesInPhase, getB() / numberOfMolesInPhase, + phase); } - - // clonedPhase.mixSelect = (EosMixingRules) mixSelect.clone(); - // clonedPhase.mixRule = (EosMixingRulesInterface) mixRule.clone(); - return clonedPhase; - } - - /** - *

- * Constructor for PhaseEos. - *

- */ - public PhaseEos() { - super(); - mixSelect = new EosMixingRules(); - componentArray = new ComponentEosInterface[MAX_NUMBER_OF_COMPONENTS]; - mixRule = mixSelect.getMixingRule(1); - // solver = new newtonRhapson(); - } - - /** {@inheritDoc} */ - @Override - public EosMixingRulesInterface getMixingRule() { - return mixRule; - } - - /** {@inheritDoc} */ - @Override - public void displayInteractionCoefficients(String intType) { - mixSelect.displayInteractionCoefficients(intType, this); - } - - /** {@inheritDoc} */ - @Override - public void addcomponent(double moles) { - super.addcomponent(moles); - } - - /** {@inheritDoc} */ - @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, - double beta) { - if (!mixingRuleDefined) { - setMixingRule(1); - } - - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - - if (type != 0) { - loc_B = calcB(this, temperature, pressure, numberOfComponents); - loc_A = calcA(this, temperature, pressure, numberOfComponents); + } catch (Exception e) { + logger.error("Failed to solve for molarVolume within the iteration limit."); + throw new RuntimeException(e); + // logger.error("too many iterations in volume calc!", e); + // 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); + for (int i = 0; i < numberOfComponents; i++) { + componentArray[i].Finit(this, temperature, pressure, totalNumberOfMoles, beta, + numberOfComponents, type); + } + + f_loc = calcf(); + g = calcg(); + + if (type >= 2) { + loc_AT = calcAT(this, temperature, pressure, numberOfComponents); + loc_ATT = calcATT(this, temperature, pressure, numberOfComponents); + } + + // logger.info("V/b" + (getVolume()/getB()) + " Z " + getZ()); + double sumHydrocarbons = 0.0; + double sumAqueous = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + if (getComponent(i).isHydrocarbon() || getComponent(i).isInert() + || getComponent(i).isIsTBPfraction()) { + sumHydrocarbons += getComponent(i).getx(); + } else { + sumAqueous += getComponent(i).getx(); } - - if (isConstantPhaseVolume()) { - setMolarVolume(getTotalVolume() / getNumberOfMolesInPhase()); - pressure = calcPressure(); + } + + if (getVolume() / getB() > 1.75) { + phaseTypeName = "gas"; + } else if (sumHydrocarbons > sumAqueous) { + phaseTypeName = "oil"; + } else { + phaseTypeName = "aqueous"; + } + + // if ((hasComponent("water") && getVolume() / getB() < 1.75 && + // getComponent("water").getx() > 0.1) || (hasComponent("MEG") && getVolume() / + // getB() < 1.75 && getComponent("MEG").getx() > 0.1) || (hasComponent("TEG") && + // getComponent("TEG").getx() > 0.1) || (hasComponent("DEG") && + // getComponent("DEG").getx() > 0.1) || (hasComponent("methanol") && + // getComponent("methanol").getx() > 0.5 || (hasComponent("ethanol") && + // getComponent("ethanol").getx() > 0.5))) { + // phaseTypeName = "aqueous"; + // } + } + } + + /** {@inheritDoc} */ + @Override + public void setMixingRule(int type) { + mixingRuleDefined = true; + super.setMixingRule(type); + mixRule = mixSelect.getMixingRule(type, this); + } + + /** {@inheritDoc} */ + @Override + public void setMixingRuleGEModel(String name) { + mixRule.setMixingRuleGEModel(name); + mixSelect.setMixingRuleGEModel(name); + } + + /** {@inheritDoc} */ + @Override + public void resetMixingRule(int type) { + mixingRuleDefined = true; + super.setMixingRule(type); + mixRule = mixSelect.resetMixingRule(type, this); + } + + /** + *

+ * molarVolume2. + *

+ * + * @param pressure a double + * @param temperature a double + * @param A a double + * @param B a double + * @param phase a int + * @return a double + * @throws neqsim.util.exception.IsNaNException if any. + * @throws neqsim.util.exception.TooManyIterationsException if any. + */ + public double molarVolume2(double pressure, double temperature, double A, double B, int phase) + throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + double BonV = phase == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + if (BonV < 0) { + BonV = 0.0; + } + if (BonV > 1.0) { + BonV = 1.0; + } + double BonVold = BonV; + double Btemp = 0; + double Dtemp = 0; + double h = 0; + double dh = 0; + double gvvv = 0; + double fvvv = 0; + double dhh = 0; + double d1 = 0; + double d2 = 0; + Btemp = getB(); + Dtemp = getA(); + + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + int iterations = 0; + int maxIterations = 1000; + + do { + iterations++; + BonVold = BonV; + h = BonV + Btemp * gV() + Btemp * Dtemp / (numberOfMolesInPhase * temperature) * fv() + - pressure * Btemp / (numberOfMolesInPhase * R * temperature); + dh = 1.0 - Btemp / (BonV * BonV) + * (Btemp * gVV() + Btemp * Dtemp * fVV() / (numberOfMolesInPhase * temperature)); + fvvv = 1.0 / (R * Btemp * (delta1 - delta2)) + * (2.0 / Math.pow(numberOfMolesInPhase * getMolarVolume() + Btemp * delta1, 3.0) + - 2.0 / Math.pow(numberOfMolesInPhase * getMolarVolume() + Btemp * delta2, 3.0)); + gvvv = 2.0 / Math.pow(numberOfMolesInPhase * getMolarVolume() - Btemp, 3.0) + - 2.0 / Math.pow(numberOfMolesInPhase * getMolarVolume(), 3.0); + dhh = 2.0 * Btemp / Math.pow(BonV, 3.0) + * (Btemp * gVV() + Btemp * Dtemp / (numberOfMolesInPhase * temperature) * fVV()) + + Btemp * Btemp / Math.pow(BonV, 4.0) + * (Btemp * gvvv + Btemp * Dtemp / (numberOfMolesInPhase * temperature) * fvvv); + + d1 = -h / dh; + d2 = -dh / dhh; + + if (Math.abs(d1 / d2) <= 1.0) { + BonV += d1 * (1.0 + 0.5 * d1 / d2); + } else if (d1 / d2 < -1) { + BonV += d1 * (1.0 + 0.5 * -1.0); + } else if (d1 / d2 > 1) { + BonV += d2; + double hnew = h + d2 * dh; + if (Math.abs(hnew) > Math.abs(h)) { + BonV += 0; } - - if (type != 0) { - phaseTypeName = phase == 0 ? "liquid" : "gas"; - try { - if (calcMolarVolume) { - molarVolume = molarVolume(pressure, temperature, - getA() / numberOfMolesInPhase / numberOfMolesInPhase, - getB() / numberOfMolesInPhase, phase); - } - } catch (Exception e) { - logger.error("Failed to solve for molarVolume within the iteration limit."); - throw new RuntimeException(e); - // logger.error("too many iterations in volume calc!", e); - // 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); - for (int i = 0; i < numberOfComponents; i++) { - componentArray[i].Finit(this, temperature, pressure, totalNumberOfMoles, beta, - numberOfComponents, type); - } - - f_loc = calcf(); - g = calcg(); - - if (type >= 2) { - loc_AT = calcAT(this, temperature, pressure, numberOfComponents); - loc_ATT = calcATT(this, temperature, pressure, numberOfComponents); - } - - // logger.info("V/b" + (getVolume()/getB()) + " Z " + getZ()); - double sumHydrocarbons = 0.0, sumAqueous = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - if (getComponent(i).isHydrocarbon() || getComponent(i).isInert() - || getComponent(i).isIsTBPfraction()) { - sumHydrocarbons += getComponent(i).getx(); - } else { - sumAqueous += getComponent(i).getx(); - } - } - - if (getVolume() / getB() > 1.75) { - phaseTypeName = "gas"; - } else if (sumHydrocarbons > sumAqueous) { - phaseTypeName = "oil"; - } else { - phaseTypeName = "aqueous"; - } - - // if ((hasComponent("water") && getVolume() / getB() < 1.75 && - // getComponent("water").getx() > 0.1) || (hasComponent("MEG") && getVolume() / - // getB() < 1.75 && getComponent("MEG").getx() > 0.1) || (hasComponent("TEG") && - // getComponent("TEG").getx() > 0.1) || (hasComponent("DEG") && - // getComponent("DEG").getx() > 0.1) || (hasComponent("methanol") && - // getComponent("methanol").getx() > 0.5 || (hasComponent("ethanol") && - // getComponent("ethanol").getx() > 0.5))) { - // phaseTypeName = "aqueous"; - // } - } - } - - /** {@inheritDoc} */ - @Override - public void setMixingRule(int type) { - mixingRuleDefined = true; - super.setMixingRule(type); - mixRule = mixSelect.getMixingRule(type, this); - } - - /** {@inheritDoc} */ - @Override - public void setMixingRuleGEModel(String name) { - mixRule.setMixingRuleGEModel(name); - mixSelect.setMixingRuleGEModel(name); - } - - /** {@inheritDoc} */ - @Override - public void resetMixingRule(int type) { - mixingRuleDefined = true; - super.setMixingRule(type); - mixRule = mixSelect.resetMixingRule(type, this); - } - - /** - *

- * molarVolume2. - *

- * - * @param pressure a double - * @param temperature a double - * @param A a double - * @param B a double - * @param phase a int - * @return a double - * @throws neqsim.util.exception.IsNaNException if any. - * @throws neqsim.util.exception.TooManyIterationsException if any. - */ - public double molarVolume2(double pressure, double temperature, double A, double B, int phase) - throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - double BonV = phase == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - if (BonV < 0) { - BonV = 0.0; - } - if (BonV > 1.0) { - BonV = 1.0; - } - double BonVold = BonV; - double Btemp = 0, Dtemp = 0, h = 0, dh = 0, gvvv = 0, fvvv = 0, dhh = 0; - double d1 = 0, d2 = 0; - Btemp = getB(); - Dtemp = getA(); - - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - int iterations = 0; - int maxIterations = 1000; - - do { - iterations++; - BonVold = BonV; - h = BonV + Btemp * gV() + Btemp * Dtemp / (numberOfMolesInPhase * temperature) * fv() - - pressure * Btemp / (numberOfMolesInPhase * R * temperature); - dh = 1.0 - Btemp / (BonV * BonV) * (Btemp * gVV() - + Btemp * Dtemp * fVV() / (numberOfMolesInPhase * temperature)); - fvvv = 1.0 / (R * Btemp * (delta1 - delta2)) - * (2.0 / Math.pow(numberOfMolesInPhase * getMolarVolume() + Btemp * delta1, 3.0) - - 2.0 / Math.pow( - numberOfMolesInPhase * getMolarVolume() + Btemp * delta2, 3.0)); - gvvv = 2.0 / Math.pow(numberOfMolesInPhase * getMolarVolume() - Btemp, 3.0) - - 2.0 / Math.pow(numberOfMolesInPhase * getMolarVolume(), 3.0); - dhh = 2.0 * Btemp / Math.pow(BonV, 3.0) - * (Btemp * gVV() + Btemp * Dtemp / (numberOfMolesInPhase * temperature) * fVV()) - + Btemp * Btemp / Math.pow(BonV, 4.0) * (Btemp * gvvv - + Btemp * Dtemp / (numberOfMolesInPhase * temperature) * fvvv); - - d1 = -h / dh; - d2 = -dh / dhh; - - if (Math.abs(d1 / d2) <= 1.0) { - BonV += d1 * (1.0 + 0.5 * d1 / d2); - } else if (d1 / d2 < -1) { - BonV += d1 * (1.0 + 0.5 * -1.0); - } else if (d1 / d2 > 1) { - BonV += d2; - double hnew = h + d2 * dh; - if (Math.abs(hnew) > Math.abs(h)) { - BonV += 0; - } - } - - if (BonV > 1) { - BonV = 1.0 - 1.0e-16; - BonVold = 10; - } - if (BonV < 0) { - BonV = 1.0e-16; - BonVold = 10; - } - - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - } while (Math.abs(BonV - BonVold) > 1.0e-9 && iterations < maxIterations); - // molarVolume = 1.0/BonV*Btemp/numberOfMolesInPhase; - // Z = pressure*molarVolume/(R*temperature); - // logger.info("BonV: " + BonV + " " + h + " " +dh + " B " + Btemp + " D " + - // Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); - // logger.info("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + - // " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + - // fVV()); - if (iterations >= maxIterations) { - throw new neqsim.util.exception.TooManyIterationsException(this, "molarVolume2", - maxIterations); - } - if (Double.isNaN(getMolarVolume())) { - throw new neqsim.util.exception.IsNaNException(this, "molarVolume2", "Molar volume"); - // logger.info("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + - // " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + - // fVV()); - } - return getMolarVolume(); - } - - /** {@inheritDoc} */ - @Override - public double molarVolume(double pressure, double temperature, double A, double B, int phase) - throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - double BonV = phase == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - - if (BonV < 0) { - BonV = 1.0e-4; + } + + if (BonV > 1) { + BonV = 1.0 - 1.0e-16; + BonVold = 10; + } + if (BonV < 0) { + BonV = 1.0e-16; + BonVold = 10; + } + + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); + } while (Math.abs(BonV - BonVold) > 1.0e-9 && iterations < maxIterations); + // molarVolume = 1.0/BonV*Btemp/numberOfMolesInPhase; + // Z = pressure*molarVolume/(R*temperature); + // logger.info("BonV: " + BonV + " " + h + " " +dh + " B " + Btemp + " D " + + // Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); + // logger.info("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + + // " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + + // fVV()); + if (iterations >= maxIterations) { + throw new neqsim.util.exception.TooManyIterationsException(this, "molarVolume2", + maxIterations); + } + if (Double.isNaN(getMolarVolume())) { + throw new neqsim.util.exception.IsNaNException(this, "molarVolume2", "Molar volume"); + // logger.info("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + + // " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + + // fVV()); + } + return getMolarVolume(); + } + + /** {@inheritDoc} */ + @Override + public double molarVolume(double pressure, double temperature, double A, double B, int phase) + throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + double BonV = phase == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + + if (BonV < 0) { + BonV = 1.0e-4; + } + if (BonV > 1.0) { + BonV = 1.0 - 1.0e-4; + } + + double BonVold = BonV; + + double Btemp = getB(); + double h; + double dh; + double dhh; + double d1; + double d2; + double BonV2; + if (Btemp < 0) { + logger.info("b negative in volume calc"); + } + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + boolean changeFase = false; + double error = 1.0; + double errorOld = 1.0e10; + int iterations = 0; + int maxIterations = 300; + do { + errorOld = error; + iterations++; + BonVold = BonV; + BonV2 = BonV * BonV; + h = BonV - Btemp / numberOfMolesInPhase * dFdV() + - pressure * Btemp / (numberOfMolesInPhase * R * temperature); + dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); + dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) + - Btemp * Btemp / (BonV2 * BonV2) * (Btemp / numberOfMolesInPhase * dFdVdVdV()); + + d1 = -h / dh; + d2 = -dh / dhh; + + if (Math.abs(d1 / d2) <= 1.0) { + BonV += d1 * (1.0 + 0.5 * d1 / d2); + } else if (d1 / d2 < -1) { + BonV += d1 * (1.0 + 0.5 * -1.0); + } else if (d1 > d2) { + BonV += d2; + double hnew = h + d2 * dh; + if (Math.abs(hnew) > Math.abs(h)) { + BonV = phase == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); } - if (BonV > 1.0) { - BonV = 1.0 - 1.0e-4; - } - - double BonVold = BonV, Btemp = getB(), h, dh, dhh, d1, d2, BonV2; - - if (Btemp < 0) { - logger.info("b negative in volume calc"); - } - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - boolean changeFase = false; - double error = 1.0, errorOld = 1.0e10; - int iterations = 0; - int maxIterations = 300; - do { - errorOld = error; - iterations++; - BonVold = BonV; - BonV2 = BonV * BonV; - h = BonV - Btemp / numberOfMolesInPhase * dFdV() - - pressure * Btemp / (numberOfMolesInPhase * R * temperature); - dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); - dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) - - Btemp * Btemp / (BonV2 * BonV2) * (Btemp / numberOfMolesInPhase * dFdVdVdV()); - - d1 = -h / dh; - d2 = -dh / dhh; - - if (Math.abs(d1 / d2) <= 1.0) { - BonV += d1 * (1.0 + 0.5 * d1 / d2); - } else if (d1 / d2 < -1) { - BonV += d1 * (1.0 + 0.5 * -1.0); - } else if (d1 > d2) { - BonV += d2; - double hnew = h + d2 * dh; - if (Math.abs(hnew) > Math.abs(h)) { - BonV = phase == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } else { - BonV += d1 * (0.1); - } - - if (BonV > 1) { - BonV = 1.0 - 1.0e-6; - BonVold = 100; - } - if (BonV < 0) { - // BonV = Math.abs(BonV); - BonV = 1.0e-10; - BonVold = 10; - } - - error = Math.abs((BonV - BonVold) / BonVold); - // logger.info("error " + error); - - if (iterations > 150 && error > errorOld && !changeFase) { - changeFase = true; - BonVold = 10.0; - BonV = phase == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - // logger.info("Math.abs((BonV - BonVold)) " + Math.abs((BonV - BonVold))); - } while (Math.abs((BonV - BonVold) / BonVold) > 1.0e-10 && iterations < maxIterations); - // logger.info("pressure " + Z*R*temperature/molarVolume); - // logger.info("error in volume " + - // (-pressure+R*temperature/molarVolume-R*temperature*dFdV()) + " firstterm " + - // (R*temperature/molarVolume) + " second " + R*temperature*dFdV()); - if (iterations >= maxIterations) { - throw new neqsim.util.exception.TooManyIterationsException(this, "molarVolume", - maxIterations); - } - if (Double.isNaN(getMolarVolume())) { - // A = calcA(this, temperature, pressure, numberOfComponents); - // molarVolume(pressure, temperature, A, B, phase); - throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); - // logger.info("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + - // " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + - // fVV()); - } - return getMolarVolume(); - } - - /** {@inheritDoc} */ - @Override - public double getPressureRepulsive() { - double presrep = R * temperature / (getMolarVolume() - getb()); - return presrep; - } - - /** {@inheritDoc} */ - @Override - public double getPressureAttractive() { - double presrep = R * temperature / (getMolarVolume() - getb()); - double presatr = pressure - presrep; - // presatr = getaT()/((molarVolume+delta1)*(molarVolume+delta2)); - // double prestot = Z*R*temperature/molarVolume; - return presatr; - } - - /** {@inheritDoc} */ - @Override - public java.lang.String getMixingRuleName() { - return mixRule.getMixingRuleName(); - } - - /** {@inheritDoc} */ - @Override - public double calcA(PhaseInterface phase, double temperature, double pressure, int numbcomp) { - loc_A = mixRule.calcA(phase, temperature, pressure, numbcomp); - return loc_A; - } - - /** {@inheritDoc} */ - @Override - public double calcB(PhaseInterface phase, double temperature, double pressure, int numbcomp) { - loc_B = mixRule.calcB(phase, temperature, pressure, numbcomp); - return loc_B; - } - - /** {@inheritDoc} */ - @Override - public double calcAi(int compNumb, PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - return mixRule.calcAi(compNumb, phase, temperature, pressure, numbcomp); - } - - /** - *

- * calcAT. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param temperature a double - * @param pressure a double - * @param numbcomp a int - * @return a double - */ - public double calcAT(PhaseInterface phase, double temperature, double pressure, int numbcomp) { - loc_AT = mixRule.calcAT(phase, temperature, pressure, numbcomp); - return loc_AT; - } - - /** - *

- * calcATT. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param temperature a double - * @param pressure a double - * @param numbcomp a int - * @return a double - */ - public double calcATT(PhaseInterface phase, double temperature, double pressure, int numbcomp) { - loc_ATT = mixRule.calcATT(phase, temperature, pressure, numbcomp); - return loc_ATT; - } - - /** {@inheritDoc} */ - @Override - public double calcAiT(int compNumb, PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - return mixRule.calcAiT(compNumb, phase, temperature, pressure, numbcomp); - } - - /** {@inheritDoc} */ - @Override - public double calcAij(int compNumb, int j, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - return mixRule.calcAij(compNumb, j, phase, temperature, pressure, numbcomp); - } - - /** {@inheritDoc} */ - @Override - public double calcBij(int compNumb, int j, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - return mixRule.calcBij(compNumb, j, phase, temperature, pressure, numbcomp); - } - - /** {@inheritDoc} */ - @Override - public double calcBi(int compNumb, PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - return mixRule.calcBi(compNumb, phase, temperature, pressure, numbcomp); - } - - /** {@inheritDoc} */ - @Override - public double geta(PhaseInterface phase, double temperature, double pressure, int numbcomp) { - return calcA(phase, temperature, pressure, numbcomp) / numberOfMolesInPhase - / numberOfMolesInPhase; - } - - /** {@inheritDoc} */ - @Override - public double getb(PhaseInterface phase, double temperature, double pressure, int numbcomp) { - return calcB(phase, temperature, pressure, numbcomp) / numberOfMolesInPhase; - } - - /** - * @return double - */ - double geta() { - return loc_A / numberOfMolesInPhase / numberOfMolesInPhase; - } - - /** - * @return double - */ - double getb() { - return loc_B / numberOfMolesInPhase; - } - - /** {@inheritDoc} */ - @Override - public double getA() { - return loc_A; - } - - /** {@inheritDoc} */ - @Override - public double getB() { - return loc_B; - } - - /** {@inheritDoc} */ - @Override - public double getAT() { - return loc_AT; - } - - /** {@inheritDoc} */ - @Override - public double getATT() { - return loc_ATT; - } - - /** {@inheritDoc} */ - @Override - public double getAresTV() { - return getF() * R * temperature; - } - - /** {@inheritDoc} */ - @Override - public double getGresTP() { - return getAresTV() + pressure * numberOfMolesInPhase * getMolarVolume() - - numberOfMolesInPhase * R * temperature * (1.0 + Math.log(Z)); - } - - /** {@inheritDoc} */ - @Override - public double getSresTV() { - return (-temperature * dFdT() - getF()) * R; - } - - /** {@inheritDoc} */ - @Override - public double getSresTP() { - return getSresTV() + numberOfMolesInPhase * R * Math.log(Z); - } - - /** {@inheritDoc} */ - @Override - public double getHresTP() { - return getAresTV() + temperature * getSresTV() - + pressure * numberOfMolesInPhase * getMolarVolume() - - numberOfMolesInPhase * R * temperature; - } - - /** {@inheritDoc} */ - @Override - public double getHresdP() { - return getVolume() + temperature * getdPdTVn() / getdPdVTn(); - } - - /** {@inheritDoc} */ - @Override - public double getCvres() { - return (-temperature * temperature * dFdTdT() - 2.0 * temperature * dFdT()) * R; - } - - /** {@inheritDoc} */ - @Override - public double getCpres() { - return getCvres() + R * (-temperature / R * Math.pow(getdPdTVn(), 2.0) / getdPdVTn() - - numberOfMolesInPhase); - } - - /** - * {@inheritDoc} - * - * method to return real gas isentropic exponent (kappa = - Cp/Cv*(v/p)*dp/dv - */ - @Override - public double getKappa() { - return -getCp() / getCv() * getVolume() / pressure * getdPdVTn(); - } - - /** - * {@inheritDoc} - * - * method to get the Joule Thomson Coefficient of a phase - */ - @Override - public double getJouleThomsonCoefficient() { - return -1.0 / getCp() * (getMolarVolume() * numberOfMolesInPhase - + temperature * getdPdTVn() / getdPdVTn()); - } - - /** {@inheritDoc} */ - @Override - public double getdPdTVn() { - return -R * temperature * dFdTdV() + pressure / temperature; - } - - /** {@inheritDoc} */ - @Override - public double getdPdVTn() { - return -R * temperature * dFdVdV() - numberOfMolesInPhase * R * temperature - / Math.pow(numberOfMolesInPhase * getMolarVolume(), 2.0); - } - - /** {@inheritDoc} */ - @Override - public double getdPdrho() { - return getdPdVTn() * getdVdrho() * 1e5; - } - - /** {@inheritDoc} */ - @Override - public double getdrhodP() { - return 1.0 / getdPdrho(); - } - - /** {@inheritDoc} */ - @Override - public double getdrhodT() { - return -getdPdTVn() / getdPdrho(); - } - - /** {@inheritDoc} */ - @Override - public double getdrhodN() { - return this.getMolarMass(); - } - - /** - *

- * getdVdrho. - *

- * - * @return a double - */ - public double getdVdrho() { - return -1.0 * numberOfMolesInPhase * this.getMolarMass() / Math.pow(this.getDensity(), 2.0); - } - - /** {@inheritDoc} */ - @Override - public double getg() { - return g; - } - - /** - *

- * Getter for the field f_loc. - *

- * - * @return a double - */ - public double getf_loc() { - return f_loc; - } - - /** - *

- * calcg. - *

- * - * @return a double - */ - public double calcg() { - return Math.log(1.0 - getb() / molarVolume); - } - - /** - *

- * calcf. - *

- * - * @return a double - */ - public double calcf() { - return (1.0 / (R * loc_B * (delta1 - delta2)) * Math.log( - (1.0 + delta1 * getb() / molarVolume) / (1.0 + delta2 * getb() / (molarVolume)))); - } - - /** - *

- * getF. - *

- * - * @return a double - */ - public double getF() { - return -numberOfMolesInPhase * getg() - getA() / temperature * getf_loc(); - } - - /** {@inheritDoc} */ - @Override - public double F() { - return getF(); - } - - /** {@inheritDoc} */ - @Override - public double Fn() { - return -getg(); - } - - /** {@inheritDoc} */ - @Override - public double FT() { - return getA() * getf_loc() / (temperature * temperature); - } - - /** {@inheritDoc} */ - @Override - public double FV() { - return -numberOfMolesInPhase * gV() - getA() / temperature * fv(); - } - - /** {@inheritDoc} */ - @Override - public double FD() { - return -getf_loc() / temperature; - } - - /** {@inheritDoc} */ - @Override - public double FB() { - return -numberOfMolesInPhase * gb() - getA() / temperature * fb(); - } - - /** {@inheritDoc} */ - @Override - public double gb() { - return -1.0 / (numberOfMolesInPhase * molarVolume - loc_B); - } - - /** {@inheritDoc} */ - @Override - public double fb() { - return -(f_loc + numberOfMolesInPhase * molarVolume * fv()) / loc_B; - } - - /** {@inheritDoc} */ - @Override - public double gV() { - return getb() / (molarVolume * (numberOfMolesInPhase * molarVolume - loc_B)); - // 1/(numberOfMolesInPhase*getMolarVolume()-getB())-1/(numberOfMolesInPhase*getMolarVolume()); - } - - /** {@inheritDoc} */ - @Override - public double fv() { - return -1.0 / (R * (numberOfMolesInPhase * molarVolume + delta1 * loc_B) - * (numberOfMolesInPhase * molarVolume + delta2 * loc_B)); - } - - ////// NYE metoder fredag 25.08.public double dFdN(PhaseInterface phase, int - ////// numberOfComponents, double temperature, double pressure, int phasetype){ - /** {@inheritDoc} */ - @Override - public double FnV() { - return -gV(); - } - - /** {@inheritDoc} */ - @Override - public double FnB() { - return -gb(); - } - - /** {@inheritDoc} */ - @Override - public double FTT() { - return -2.0 / temperature * FT(); - } - - /** {@inheritDoc} */ - @Override - public double FBT() { - return getA() * fb() / temperature / temperature; - } - - /** {@inheritDoc} */ - @Override - public double FDT() { - return getf_loc() / temperature / temperature; - } - - /** {@inheritDoc} */ - @Override - public double FBV() { - return -numberOfMolesInPhase * gBV() - getA() * fBV() / temperature; - } - - /** {@inheritDoc} */ - @Override - public double FBB() { - return -numberOfMolesInPhase * gBB() - getA() * fBB() / temperature; - } - - /** {@inheritDoc} */ - @Override - public double FDV() { - return -fv() / temperature; - } - - /** {@inheritDoc} */ - @Override - public double FBD() { - return -fb() / temperature; - } - - /** {@inheritDoc} */ - @Override - public double FTV() { - return getA() * fv() / temperature / temperature; - } - - /** {@inheritDoc} */ - @Override - public double FVV() { - return -numberOfMolesInPhase * gVV() - getA() * fVV() / temperature; - } - - /** - *

- * FVVV. - *

- * - * @return a double - */ - public double FVVV() { - return -numberOfMolesInPhase * gVVV() - getA() * fVVV() / temperature; - } - - /** {@inheritDoc} */ - @Override - public double gVV() { - double val1 = numberOfMolesInPhase * getMolarVolume(); - double val2 = val1 - getB(); - return -1.0 / (val2 * val2) + 1.0 / (val1 * val1); - } - - /** - *

- * gVVV. - *

- * - * @return a double - */ - public double gVVV() { - double val1 = numberOfMolesInPhase * getMolarVolume(); - double val2 = val1 - getB(); - return 2.0 / (val2 * val2 * val2) - 2.0 / (val1 * val1 * val1); - } - - /** {@inheritDoc} */ - @Override - public double gBV() { - double val = numberOfMolesInPhase * getMolarVolume() - getB(); - return 1.0 / (val * val); - } - - /** {@inheritDoc} */ - @Override - public double gBB() { - double val = numberOfMolesInPhase * getMolarVolume() - getB(); - return -1.0 / (val * val); - } - - /** {@inheritDoc} */ - @Override - public double fVV() { - double val1 = (numberOfMolesInPhase * molarVolume + delta1 * loc_B); - double val2 = (numberOfMolesInPhase * molarVolume + delta2 * loc_B); - return 1.0 / (R * loc_B * (delta1 - delta2)) * (-1.0 / (val1 * val1) + 1.0 / (val2 * val2)); - } - - /** - *

- * fVVV. - *

- * - * @return a double - */ - public double fVVV() { - double val1 = numberOfMolesInPhase * molarVolume + getB() * delta1; - double val2 = numberOfMolesInPhase * molarVolume + getB() * delta2; - return 1.0 / (R * getB() * (delta1 - delta2)) - * (2.0 / (val1 * val1 * val1) - 2.0 / (val2 * val2 * val2)); - } - - /** {@inheritDoc} */ - @Override - public double fBV() { - return -(2.0 * fv() + numberOfMolesInPhase * molarVolume * fVV()) / getB(); - } - - /** {@inheritDoc} */ - @Override - public double fBB() { - return -(2.0 * fb() + numberOfMolesInPhase * molarVolume * fBV()) / getB(); - } - - /** {@inheritDoc} */ - @Override - public double dFdT() { - return FT() + FD() * getAT(); - } - - /** {@inheritDoc} */ - @Override - public double dFdV() { - return FV(); - } - - /** {@inheritDoc} */ - @Override - public double dFdTdV() { - return FTV() + FDV() * getAT(); - } - - /** {@inheritDoc} */ - @Override - public double dFdVdV() { - return FVV(); - } - - /** - *

- * dFdVdVdV. - *

- * - * @return a double - */ - public double dFdVdVdV() { - return FVVV(); - } - - /** {@inheritDoc} */ - @Override - public double dFdTdT() { - return FTT() + 2.0 * FDT() * getAT() + FD() * getATT(); - } - - /** {@inheritDoc} */ - @Override - public double calcPressure() { - return -R * temperature * dFdV() - + getNumberOfMolesInPhase() * R * temperature / getTotalVolume(); - } - - /** {@inheritDoc} */ - @Override - public double calcPressuredV() { - return -R * temperature * dFdVdV() - - getNumberOfMolesInPhase() * R * temperature / Math.pow(getTotalVolume(), 2.0); - } - - /** - * {@inheritDoc} - * - * method to get the speed of sound of a phase - */ - @Override - public double getSoundSpeed() { - double bs = -1.0 / getVolume() * getCv() / getCp() / getdPdVTn(); - double Mw = getNumberOfMolesInPhase() * getMolarMass(); - return Math.sqrt(getVolume() / Mw / bs); - } - - /** - *

- * getdUdSVn. - *

- * - * @return a double - */ - public double getdUdSVn() { - return getTemperature(); - } - - /** - *

- * getdUdVSn. - *

- * - * @return a double - */ - public double getdUdVSn() { - return -getPressure(); - } - - /** - *

- * getdUdSdSVn. - *

- * - * @return a double - */ - public double getdUdSdSVn() { - return 1.0 / (FTT() * R * getTemperature());// noe feil her - } - - /** - *

- * getdUdVdVSn. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double getdUdVdVSn(PhaseInterface phase) { - return -FVV() * 1.0 / FTT(); - } - - /** - *

- * getdUdSdVn. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double getdUdSdVn(PhaseInterface phase) { - return -1.0 / FTT() * FTV(); - } - - // getdTVndSVn() needs to be implemented - /** - *

- * getdTVndSVnJaobiMatrix. - *

- * - * @return an array of {@link double} objects - */ - public double[][] getdTVndSVnJaobiMatrix() { - double[][] jacobiMatrix = new double[2 + numberOfComponents][2 + numberOfComponents]; - - jacobiMatrix[0][0] = FTT(); - jacobiMatrix[1][0] = FTT(); + } else { + BonV += d1 * (0.1); + } + + if (BonV > 1) { + BonV = 1.0 - 1.0e-6; + BonVold = 100; + } + if (BonV < 0) { + // BonV = Math.abs(BonV); + BonV = 1.0e-10; + BonVold = 10; + } + + error = Math.abs((BonV - BonVold) / BonVold); + // logger.info("error " + error); + + if (iterations > 150 && error > errorOld && !changeFase) { + changeFase = true; + BonVold = 10.0; + BonV = phase == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + } + + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); + // logger.info("Math.abs((BonV - BonVold)) " + Math.abs((BonV - BonVold))); + } while (Math.abs((BonV - BonVold) / BonVold) > 1.0e-10 && iterations < maxIterations); + // logger.info("pressure " + Z*R*temperature/molarVolume); + // logger.info("error in volume " + + // (-pressure+R*temperature/molarVolume-R*temperature*dFdV()) + " firstterm " + + // (R*temperature/molarVolume) + " second " + R*temperature*dFdV()); + if (iterations >= maxIterations) { + throw new neqsim.util.exception.TooManyIterationsException(this, "molarVolume", + maxIterations); + } + if (Double.isNaN(getMolarVolume())) { + // A = calcA(this, temperature, pressure, numberOfComponents); + // molarVolume(pressure, temperature, A, B, phase); + throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); + // logger.info("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + + // " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + + // fVV()); + } + return getMolarVolume(); + } + + /** {@inheritDoc} */ + @Override + public double getPressureRepulsive() { + double presrep = R * temperature / (getMolarVolume() - getb()); + return presrep; + } + + /** {@inheritDoc} */ + @Override + public double getPressureAttractive() { + double presrep = R * temperature / (getMolarVolume() - getb()); + double presatr = pressure - presrep; + // presatr = getaT()/((molarVolume+delta1)*(molarVolume+delta2)); + // double prestot = Z*R*temperature/molarVolume; + return presatr; + } + + /** {@inheritDoc} */ + @Override + public java.lang.String getMixingRuleName() { + return mixRule.getMixingRuleName(); + } + + /** {@inheritDoc} */ + @Override + public double calcA(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + loc_A = mixRule.calcA(phase, temperature, pressure, numbcomp); + return loc_A; + } + + /** {@inheritDoc} */ + @Override + public double calcB(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + loc_B = mixRule.calcB(phase, temperature, pressure, numbcomp); + return loc_B; + } + + /** {@inheritDoc} */ + @Override + public double calcAi(int compNumb, PhaseInterface phase, double temperature, double pressure, + int numbcomp) { + return mixRule.calcAi(compNumb, phase, temperature, pressure, numbcomp); + } + + /** + *

+ * calcAT. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param temperature a double + * @param pressure a double + * @param numbcomp a int + * @return a double + */ + public double calcAT(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + loc_AT = mixRule.calcAT(phase, temperature, pressure, numbcomp); + return loc_AT; + } + + /** + *

+ * calcATT. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param temperature a double + * @param pressure a double + * @param numbcomp a int + * @return a double + */ + public double calcATT(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + loc_ATT = mixRule.calcATT(phase, temperature, pressure, numbcomp); + return loc_ATT; + } + + /** {@inheritDoc} */ + @Override + public double calcAiT(int compNumb, PhaseInterface phase, double temperature, double pressure, + int numbcomp) { + return mixRule.calcAiT(compNumb, phase, temperature, pressure, numbcomp); + } + + /** {@inheritDoc} */ + @Override + public double calcAij(int compNumb, int j, PhaseInterface phase, double temperature, + double pressure, int numbcomp) { + return mixRule.calcAij(compNumb, j, phase, temperature, pressure, numbcomp); + } + + /** {@inheritDoc} */ + @Override + public double calcBij(int compNumb, int j, PhaseInterface phase, double temperature, + double pressure, int numbcomp) { + return mixRule.calcBij(compNumb, j, phase, temperature, pressure, numbcomp); + } + + /** {@inheritDoc} */ + @Override + public double calcBi(int compNumb, PhaseInterface phase, double temperature, double pressure, + int numbcomp) { + return mixRule.calcBi(compNumb, phase, temperature, pressure, numbcomp); + } + + /** {@inheritDoc} */ + @Override + public double geta(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + return calcA(phase, temperature, pressure, numbcomp) / numberOfMolesInPhase + / numberOfMolesInPhase; + } + + /** {@inheritDoc} */ + @Override + public double getb(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + return calcB(phase, temperature, pressure, numbcomp) / numberOfMolesInPhase; + } + + /** + * @return double + */ + double geta() { + return loc_A / numberOfMolesInPhase / numberOfMolesInPhase; + } + + /** + * @return double + */ + double getb() { + return loc_B / numberOfMolesInPhase; + } + + /** {@inheritDoc} */ + @Override + public double getA() { + return loc_A; + } + + /** {@inheritDoc} */ + @Override + public double getB() { + return loc_B; + } + + /** {@inheritDoc} */ + @Override + public double getAT() { + return loc_AT; + } + + /** {@inheritDoc} */ + @Override + public double getATT() { + return loc_ATT; + } + + /** {@inheritDoc} */ + @Override + public double getAresTV() { + return getF() * R * temperature; + } + + /** {@inheritDoc} */ + @Override + public double getGresTP() { + return getAresTV() + pressure * numberOfMolesInPhase * getMolarVolume() + - numberOfMolesInPhase * R * temperature * (1.0 + Math.log(Z)); + } + + /** {@inheritDoc} */ + @Override + public double getSresTV() { + return (-temperature * dFdT() - getF()) * R; + } + + /** {@inheritDoc} */ + @Override + public double getSresTP() { + return getSresTV() + numberOfMolesInPhase * R * Math.log(Z); + } + + /** {@inheritDoc} */ + @Override + public double getHresTP() { + return getAresTV() + temperature * getSresTV() + + pressure * numberOfMolesInPhase * getMolarVolume() + - numberOfMolesInPhase * R * temperature; + } + + /** {@inheritDoc} */ + @Override + public double getHresdP() { + return getVolume() + temperature * getdPdTVn() / getdPdVTn(); + } + + /** {@inheritDoc} */ + @Override + public double getCvres() { + return (-temperature * temperature * dFdTdT() - 2.0 * temperature * dFdT()) * R; + } + + /** {@inheritDoc} */ + @Override + public double getCpres() { + return getCvres() + + R * (-temperature / R * Math.pow(getdPdTVn(), 2.0) / getdPdVTn() - numberOfMolesInPhase); + } + + /** + * {@inheritDoc} + * + * method to return real gas isentropic exponent (kappa = - Cp/Cv*(v/p)*dp/dv + */ + @Override + public double getKappa() { + return -getCp() / getCv() * getVolume() / pressure * getdPdVTn(); + } + + /** + * {@inheritDoc} + * + * method to get the Joule Thomson Coefficient of a phase + */ + @Override + public double getJouleThomsonCoefficient() { + return -1.0 / getCp() + * (getMolarVolume() * numberOfMolesInPhase + temperature * getdPdTVn() / getdPdVTn()); + } + + /** {@inheritDoc} */ + @Override + public double getdPdTVn() { + return -R * temperature * dFdTdV() + pressure / temperature; + } + + /** {@inheritDoc} */ + @Override + public double getdPdVTn() { + return -R * temperature * dFdVdV() - numberOfMolesInPhase * R * temperature + / Math.pow(numberOfMolesInPhase * getMolarVolume(), 2.0); + } + + /** {@inheritDoc} */ + @Override + public double getdPdrho() { + return getdPdVTn() * getdVdrho() * 1e5; + } + + /** {@inheritDoc} */ + @Override + public double getdrhodP() { + return 1.0 / getdPdrho(); + } + + /** {@inheritDoc} */ + @Override + public double getdrhodT() { + return -getdPdTVn() / getdPdrho(); + } + + /** {@inheritDoc} */ + @Override + public double getdrhodN() { + return this.getMolarMass(); + } + + /** + *

+ * getdVdrho. + *

+ * + * @return a double + */ + public double getdVdrho() { + return -1.0 * numberOfMolesInPhase * this.getMolarMass() / Math.pow(this.getDensity(), 2.0); + } + + /** {@inheritDoc} */ + @Override + public double getg() { + return g; + } + + /** + *

+ * Getter for the field f_loc. + *

+ * + * @return a double + */ + public double getf_loc() { + return f_loc; + } + + /** + *

+ * calcg. + *

+ * + * @return a double + */ + public double calcg() { + return Math.log(1.0 - getb() / molarVolume); + } + + /** + *

+ * calcf. + *

+ * + * @return a double + */ + public double calcf() { + return (1.0 / (R * loc_B * (delta1 - delta2)) * Math + .log((1.0 + delta1 * getb() / molarVolume) / (1.0 + delta2 * getb() / (molarVolume)))); + } + + /** + *

+ * getF. + *

+ * + * @return a double + */ + public double getF() { + return -numberOfMolesInPhase * getg() - getA() / temperature * getf_loc(); + } + + /** {@inheritDoc} */ + @Override + public double F() { + return getF(); + } + + /** {@inheritDoc} */ + @Override + public double Fn() { + return -getg(); + } + + /** {@inheritDoc} */ + @Override + public double FT() { + return getA() * getf_loc() / (temperature * temperature); + } + + /** {@inheritDoc} */ + @Override + public double FV() { + return -numberOfMolesInPhase * gV() - getA() / temperature * fv(); + } + + /** {@inheritDoc} */ + @Override + public double FD() { + return -getf_loc() / temperature; + } + + /** {@inheritDoc} */ + @Override + public double FB() { + return -numberOfMolesInPhase * gb() - getA() / temperature * fb(); + } + + /** {@inheritDoc} */ + @Override + public double gb() { + return -1.0 / (numberOfMolesInPhase * molarVolume - loc_B); + } + + /** {@inheritDoc} */ + @Override + public double fb() { + return -(f_loc + numberOfMolesInPhase * molarVolume * fv()) / loc_B; + } + + /** {@inheritDoc} */ + @Override + public double gV() { + return getb() / (molarVolume * (numberOfMolesInPhase * molarVolume - loc_B)); + // 1/(numberOfMolesInPhase*getMolarVolume()-getB())-1/(numberOfMolesInPhase*getMolarVolume()); + } + + /** {@inheritDoc} */ + @Override + public double fv() { + return -1.0 / (R * (numberOfMolesInPhase * molarVolume + delta1 * loc_B) + * (numberOfMolesInPhase * molarVolume + delta2 * loc_B)); + } + + ////// NYE metoder fredag 25.08.public double dFdN(PhaseInterface phase, int + ////// numberOfComponents, double temperature, double pressure, int phasetype){ + /** {@inheritDoc} */ + @Override + public double FnV() { + return -gV(); + } + + /** {@inheritDoc} */ + @Override + public double FnB() { + return -gb(); + } + + /** {@inheritDoc} */ + @Override + public double FTT() { + return -2.0 / temperature * FT(); + } + + /** {@inheritDoc} */ + @Override + public double FBT() { + return getA() * fb() / temperature / temperature; + } + + /** {@inheritDoc} */ + @Override + public double FDT() { + return getf_loc() / temperature / temperature; + } + + /** {@inheritDoc} */ + @Override + public double FBV() { + return -numberOfMolesInPhase * gBV() - getA() * fBV() / temperature; + } + + /** {@inheritDoc} */ + @Override + public double FBB() { + return -numberOfMolesInPhase * gBB() - getA() * fBB() / temperature; + } + + /** {@inheritDoc} */ + @Override + public double FDV() { + return -fv() / temperature; + } + + /** {@inheritDoc} */ + @Override + public double FBD() { + return -fb() / temperature; + } + + /** {@inheritDoc} */ + @Override + public double FTV() { + return getA() * fv() / temperature / temperature; + } + + /** {@inheritDoc} */ + @Override + public double FVV() { + return -numberOfMolesInPhase * gVV() - getA() * fVV() / temperature; + } + + /** + *

+ * FVVV. + *

+ * + * @return a double + */ + public double FVVV() { + return -numberOfMolesInPhase * gVVV() - getA() * fVVV() / temperature; + } + + /** {@inheritDoc} */ + @Override + public double gVV() { + double val1 = numberOfMolesInPhase * getMolarVolume(); + double val2 = val1 - getB(); + return -1.0 / (val2 * val2) + 1.0 / (val1 * val1); + } + + /** + *

+ * gVVV. + *

+ * + * @return a double + */ + public double gVVV() { + double val1 = numberOfMolesInPhase * getMolarVolume(); + double val2 = val1 - getB(); + return 2.0 / (val2 * val2 * val2) - 2.0 / (val1 * val1 * val1); + } + + /** {@inheritDoc} */ + @Override + public double gBV() { + double val = numberOfMolesInPhase * getMolarVolume() - getB(); + return 1.0 / (val * val); + } + + /** {@inheritDoc} */ + @Override + public double gBB() { + double val = numberOfMolesInPhase * getMolarVolume() - getB(); + return -1.0 / (val * val); + } + + /** {@inheritDoc} */ + @Override + public double fVV() { + double val1 = (numberOfMolesInPhase * molarVolume + delta1 * loc_B); + double val2 = (numberOfMolesInPhase * molarVolume + delta2 * loc_B); + return 1.0 / (R * loc_B * (delta1 - delta2)) * (-1.0 / (val1 * val1) + 1.0 / (val2 * val2)); + } + + /** + *

+ * fVVV. + *

+ * + * @return a double + */ + public double fVVV() { + double val1 = numberOfMolesInPhase * molarVolume + getB() * delta1; + double val2 = numberOfMolesInPhase * molarVolume + getB() * delta2; + return 1.0 / (R * getB() * (delta1 - delta2)) + * (2.0 / (val1 * val1 * val1) - 2.0 / (val2 * val2 * val2)); + } + + /** {@inheritDoc} */ + @Override + public double fBV() { + return -(2.0 * fv() + numberOfMolesInPhase * molarVolume * fVV()) / getB(); + } + + /** {@inheritDoc} */ + @Override + public double fBB() { + return -(2.0 * fb() + numberOfMolesInPhase * molarVolume * fBV()) / getB(); + } + + /** {@inheritDoc} */ + @Override + public double dFdT() { + return FT() + FD() * getAT(); + } + + /** {@inheritDoc} */ + @Override + public double dFdV() { + return FV(); + } + + /** {@inheritDoc} */ + @Override + public double dFdTdV() { + return FTV() + FDV() * getAT(); + } + + /** {@inheritDoc} */ + @Override + public double dFdVdV() { + return FVV(); + } + + /** + *

+ * dFdVdVdV. + *

+ * + * @return a double + */ + public double dFdVdVdV() { + return FVVV(); + } + + /** {@inheritDoc} */ + @Override + public double dFdTdT() { + return FTT() + 2.0 * FDT() * getAT() + FD() * getATT(); + } + + /** {@inheritDoc} */ + @Override + public double calcPressure() { + return -R * temperature * dFdV() + + getNumberOfMolesInPhase() * R * temperature / getTotalVolume(); + } + + /** {@inheritDoc} */ + @Override + public double calcPressuredV() { + return -R * temperature * dFdVdV() + - getNumberOfMolesInPhase() * R * temperature / Math.pow(getTotalVolume(), 2.0); + } + + /** + * {@inheritDoc} + * + * method to get the speed of sound of a phase + */ + @Override + public double getSoundSpeed() { + double bs = -1.0 / getVolume() * getCv() / getCp() / getdPdVTn(); + double Mw = getNumberOfMolesInPhase() * getMolarMass(); + return Math.sqrt(getVolume() / Mw / bs); + } + + /** + *

+ * getdUdSVn. + *

+ * + * @return a double + */ + public double getdUdSVn() { + return getTemperature(); + } + + /** + *

+ * getdUdVSn. + *

+ * + * @return a double + */ + public double getdUdVSn() { + return -getPressure(); + } + + /** + *

+ * getdUdSdSVn. + *

+ * + * @return a double + */ + public double getdUdSdSVn() { + return 1.0 / (FTT() * R * getTemperature());// noe feil her + } + + /** + *

+ * getdUdVdVSn. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double getdUdVdVSn(PhaseInterface phase) { + return -FVV() * 1.0 / FTT(); + } + + /** + *

+ * getdUdSdVn. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double getdUdSdVn(PhaseInterface phase) { + return -1.0 / FTT() * FTV(); + } + + // getdTVndSVn() needs to be implemented + /** + *

+ * getdTVndSVnJaobiMatrix. + *

+ * + * @return an array of {@link double} objects + */ + public double[][] getdTVndSVnJaobiMatrix() { + double[][] jacobiMatrix = new double[2 + numberOfComponents][2 + numberOfComponents]; + + jacobiMatrix[0][0] = FTT(); + jacobiMatrix[1][0] = FTT(); + jacobiMatrix[2][0] = FTT(); + + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < numberOfComponents; j++) { jacobiMatrix[2][0] = FTT(); - - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < numberOfComponents; j++) { - jacobiMatrix[2][0] = FTT(); - } - } - - return jacobiMatrix; - } - - /** - *

- * getGradientVector. - *

- * - * @return an array of {@link double} objects - */ - public double[] getGradientVector() { - double[] gradientVector = new double[2 + numberOfComponents]; - return gradientVector; - } - - // getdTVndSVn() needs to be implemented - // symetrisk matrise - /** - *

- * getUSVHessianMatrix. - *

- * - * @return an array of {@link double} objects - */ - public double[][] getUSVHessianMatrix() { - double[][] jacobiMatrix = new double[2 + numberOfComponents][2 + numberOfComponents]; - - jacobiMatrix[0][0] = FTT(); - jacobiMatrix[1][0] = FTT(); + } + } + + return jacobiMatrix; + } + + /** + *

+ * getGradientVector. + *

+ * + * @return an array of {@link double} objects + */ + public double[] getGradientVector() { + double[] gradientVector = new double[2 + numberOfComponents]; + return gradientVector; + } + + // getdTVndSVn() needs to be implemented + // symetrisk matrise + /** + *

+ * getUSVHessianMatrix. + *

+ * + * @return an array of {@link double} objects + */ + public double[][] getUSVHessianMatrix() { + double[][] jacobiMatrix = new double[2 + numberOfComponents][2 + numberOfComponents]; + + jacobiMatrix[0][0] = FTT(); + jacobiMatrix[1][0] = FTT(); + jacobiMatrix[2][0] = FTT(); + + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < numberOfComponents; j++) { jacobiMatrix[2][0] = FTT(); - - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < numberOfComponents; j++) { - jacobiMatrix[2][0] = FTT(); - } - } - - return jacobiMatrix; - } - - /** - *

- * dFdxMatrixSimple. - *

- * - * @return an array of {@link double} objects - */ - public double[] dFdxMatrixSimple() { - double[] matrix = new double[numberOfComponents + 2]; - double Fn = Fn(), FB = FB(), FD = FD(); - double[] Bi = new double[numberOfComponents]; - double[] Ai = new double[numberOfComponents]; - ComponentEosInterface[] componentArray = (ComponentEosInterface[]) this.componentArray; - - for (int i = 0; i < numberOfComponents; i++) { - Bi[i] = componentArray[i].getBi(); - Ai[i] = componentArray[i].getAi(); - } - - for (int i = 0; i < numberOfComponents; i++) { - matrix[i] = Fn + FB * Bi[i] + FD * Ai[i]; - } - - matrix[numberOfComponents] = dFdT(); - matrix[numberOfComponents + 1] = dFdV(); - - return matrix; - } - - /** - *

- * dFdxMatrix. - *

- * - * @return an array of {@link double} objects - */ - public double[] dFdxMatrix() { - double[] matrix = new double[numberOfComponents + 2]; - - matrix[0] = dFdT(); - matrix[1] = dFdV(); - - for (int i = 0; i < numberOfComponents; i++) { - matrix[i + 2] = dFdN(i); - } - return matrix; - } - - /** - *

- * dFdxdxMatrixSimple. - *

- * - * @return an array of {@link double} objects - */ - public double[][] dFdxdxMatrixSimple() { - double[][] matrix = new double[numberOfComponents + 2][numberOfComponents + 2]; - - double FDV = FDV(), FBV = FBV(), FnV = FnV(), FnB = FnB(), FBD = FBD(), FB = FB(), - FBB = FBB(), FD = FD(), FBT = FBT(), AT = getAT(), FDT = FDT(); - ComponentEosInterface[] componentArray = (ComponentEosInterface[]) this.componentArray; - - double[] Bi = new double[numberOfComponents]; - double[] Ai = new double[numberOfComponents]; - for (int i = 0; i < numberOfComponents; i++) { - Bi[i] = componentArray[i].getBi(); - Ai[i] = componentArray[i].getAi(); - } - - for (int i = 0; i < numberOfComponents; i++) { - for (int j = i; j < numberOfComponents; j++) { - matrix[i][j] = FnB * (Bi[i] + Bi[j]) + FBD * (Bi[i] * Ai[j] + Bi[j] * Ai[i]) - + FB * componentArray[i].getBij(j) + FBB * Bi[i] * Bi[j] - + FD * componentArray[i].getAij(j); - matrix[j][i] = matrix[i][j]; - } - } - - for (int i = 0; i < numberOfComponents; i++) { - matrix[i][numberOfComponents] = - (FBT + FBD * AT) * Bi[i] + FDT * Ai[i] + FD * componentArray[i].getAiT(); // dFdndT - matrix[numberOfComponents][i] = matrix[i][numberOfComponents]; - - matrix[i][numberOfComponents + 1] = FnV + FBV * Bi[i] + FDV * Ai[i]; // dFdndV - matrix[numberOfComponents + 1][i] = matrix[i][numberOfComponents + 1]; - } - return matrix; - } - - /** - *

- * dFdxdxMatrix. - *

- * - * @return an array of {@link double} objects - */ - public double[][] dFdxdxMatrix() { - double[][] matrix = new double[numberOfComponents + 2][numberOfComponents + 2]; - - matrix[0][0] = dFdTdT(); - matrix[1][0] = dFdTdV(); - matrix[0][1] = matrix[1][0]; - matrix[1][1] = dFdVdV(); - - for (int i = 0; i < numberOfComponents; i++) { - matrix[i + 2][0] = dFdNdT(i); - matrix[0][i + 2] = matrix[i + 2][0]; - } - - for (int i = 0; i < numberOfComponents; i++) { - matrix[i + 2][1] = dFdNdV(i); - matrix[1][i + 2] = matrix[i + 2][1]; - } - - for (int i = 0; i < numberOfComponents; i++) { - for (int j = i; j < numberOfComponents; j++) { - matrix[i + 2][j + 2] = dFdNdN(i, j); - matrix[j + 2][i + 2] = matrix[i + 2][j + 2]; - } - } - return matrix; - } - - /** {@inheritDoc} */ - @Override - public double dFdN(int i) { - return ((ComponentEosInterface) getComponent(i)).dFdN(this, this.getNumberOfComponents(), - temperature, pressure); - } - - /** {@inheritDoc} */ - @Override - public double dFdNdN(int i, int j) { - return ((ComponentEosInterface) getComponent(i)).dFdNdN(j, this, - this.getNumberOfComponents(), temperature, pressure); - } - - /** {@inheritDoc} */ - @Override - public double dFdNdV(int i) { - return ((ComponentEosInterface) getComponent(i)).dFdNdV(this, this.getNumberOfComponents(), - temperature, pressure); - } - - /** {@inheritDoc} */ - @Override - public double dFdNdT(int i) { - return ((ComponentEosInterface) getComponent(i)).dFdNdT(this, this.getNumberOfComponents(), - temperature, pressure); - } + } + } + + return jacobiMatrix; + } + + /** + *

+ * dFdxMatrixSimple. + *

+ * + * @return an array of {@link double} objects + */ + public double[] dFdxMatrixSimple() { + double[] matrix = new double[numberOfComponents + 2]; + double Fn = Fn(); + double FB = FB(); + double FD = FD(); + double[] Bi = new double[numberOfComponents]; + double[] Ai = new double[numberOfComponents]; + ComponentEosInterface[] componentArray = (ComponentEosInterface[]) this.componentArray; + + for (int i = 0; i < numberOfComponents; i++) { + Bi[i] = componentArray[i].getBi(); + Ai[i] = componentArray[i].getAi(); + } + + for (int i = 0; i < numberOfComponents; i++) { + matrix[i] = Fn + FB * Bi[i] + FD * Ai[i]; + } + + matrix[numberOfComponents] = dFdT(); + matrix[numberOfComponents + 1] = dFdV(); + + return matrix; + } + + /** + *

+ * dFdxMatrix. + *

+ * + * @return an array of {@link double} objects + */ + public double[] dFdxMatrix() { + double[] matrix = new double[numberOfComponents + 2]; + + matrix[0] = dFdT(); + matrix[1] = dFdV(); + + for (int i = 0; i < numberOfComponents; i++) { + matrix[i + 2] = dFdN(i); + } + return matrix; + } + + /** + *

+ * dFdxdxMatrixSimple. + *

+ * + * @return an array of {@link double} objects + */ + public double[][] dFdxdxMatrixSimple() { + double[][] matrix = new double[numberOfComponents + 2][numberOfComponents + 2]; + + double FDV = FDV(); + double FBV = FBV(); + double FnV = FnV(); + double FnB = FnB(); + double FBD = FBD(); + double FB = FB(); + double FBB = FBB(); + double FD = FD(); + double FBT = FBT(); + double AT = getAT(); + double FDT = FDT(); + ComponentEosInterface[] componentArray = (ComponentEosInterface[]) this.componentArray; + + double[] Bi = new double[numberOfComponents]; + double[] Ai = new double[numberOfComponents]; + for (int i = 0; i < numberOfComponents; i++) { + Bi[i] = componentArray[i].getBi(); + Ai[i] = componentArray[i].getAi(); + } + + for (int i = 0; i < numberOfComponents; i++) { + for (int j = i; j < numberOfComponents; j++) { + matrix[i][j] = FnB * (Bi[i] + Bi[j]) + FBD * (Bi[i] * Ai[j] + Bi[j] * Ai[i]) + + FB * componentArray[i].getBij(j) + FBB * Bi[i] * Bi[j] + + FD * componentArray[i].getAij(j); + matrix[j][i] = matrix[i][j]; + } + } + + for (int i = 0; i < numberOfComponents; i++) { + matrix[i][numberOfComponents] = + (FBT + FBD * AT) * Bi[i] + FDT * Ai[i] + FD * componentArray[i].getAiT(); // dFdndT + matrix[numberOfComponents][i] = matrix[i][numberOfComponents]; + + matrix[i][numberOfComponents + 1] = FnV + FBV * Bi[i] + FDV * Ai[i]; // dFdndV + matrix[numberOfComponents + 1][i] = matrix[i][numberOfComponents + 1]; + } + return matrix; + } + + /** + *

+ * dFdxdxMatrix. + *

+ * + * @return an array of {@link double} objects + */ + public double[][] dFdxdxMatrix() { + double[][] matrix = new double[numberOfComponents + 2][numberOfComponents + 2]; + + matrix[0][0] = dFdTdT(); + matrix[1][0] = dFdTdV(); + matrix[0][1] = matrix[1][0]; + matrix[1][1] = dFdVdV(); + + for (int i = 0; i < numberOfComponents; i++) { + matrix[i + 2][0] = dFdNdT(i); + matrix[0][i + 2] = matrix[i + 2][0]; + } + + for (int i = 0; i < numberOfComponents; i++) { + matrix[i + 2][1] = dFdNdV(i); + matrix[1][i + 2] = matrix[i + 2][1]; + } + + for (int i = 0; i < numberOfComponents; i++) { + for (int j = i; j < numberOfComponents; j++) { + matrix[i + 2][j + 2] = dFdNdN(i, j); + matrix[j + 2][i + 2] = matrix[i + 2][j + 2]; + } + } + return matrix; + } + + /** {@inheritDoc} */ + @Override + public double dFdN(int i) { + return ((ComponentEosInterface) getComponent(i)).dFdN(this, this.getNumberOfComponents(), + temperature, pressure); + } + + /** {@inheritDoc} */ + @Override + public double dFdNdN(int i, int j) { + return ((ComponentEosInterface) getComponent(i)).dFdNdN(j, this, this.getNumberOfComponents(), + temperature, pressure); + } + + /** {@inheritDoc} */ + @Override + public double dFdNdV(int i) { + return ((ComponentEosInterface) getComponent(i)).dFdNdV(this, this.getNumberOfComponents(), + temperature, pressure); + } + + /** {@inheritDoc} */ + @Override + public double dFdNdT(int i) { + return ((ComponentEosInterface) getComponent(i)).dFdNdT(this, this.getNumberOfComponents(), + temperature, pressure); + } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseEosInterface.java b/src/main/java/neqsim/thermo/phase/PhaseEosInterface.java index 3639c5bd19..6252a29656 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseEosInterface.java +++ b/src/main/java/neqsim/thermo/phase/PhaseEosInterface.java @@ -3,6 +3,7 @@ * * Created on 5. juni 2000, 19:20 */ + package neqsim.thermo.phase; import neqsim.thermo.mixingRule.EosMixingRulesInterface; @@ -16,148 +17,148 @@ * @version $Id: $Id */ public interface PhaseEosInterface extends PhaseInterface { - /** {@inheritDoc} */ - @Override - double getMolarVolume(); - - /** - *

- * getMixingRule. - *

- * - * @return a {@link neqsim.thermo.mixingRule.EosMixingRulesInterface} object - */ - public EosMixingRulesInterface getMixingRule(); - - /** - *

- * getMixingRuleName. - *

- * - * @return a {@link java.lang.String} object - */ - public java.lang.String getMixingRuleName(); - - /** - *

- * calcPressure. - *

- * - * @return a double - */ - public double calcPressure(); - - /** - *

- * calcPressuredV. - *

- * - * @return a double - */ - public double calcPressuredV(); - - /** - *

- * getPressureRepulsive. - *

- * - * @return a double - */ - public double getPressureRepulsive(); - - /** - *

- * getPressureAttractive. - *

- * - * @return a double - */ - public double getPressureAttractive(); - - /** - *

- * displayInteractionCoefficients. - *

- * - * @param intType a {@link java.lang.String} object - */ - public void displayInteractionCoefficients(String intType); - // public double getA(); - // public double getB(); - // double calcA(ComponentEosInterface[] compArray, double temperature, double - // pressure, int numbcomp); - // double calcB(ComponentEosInterface[] compArray, double temperature, double - // pressure, int numbcomp); - // double calcA(ComponentEosInterface[] compArray, double temperature, double - // pressure, int numbcomp); - // double calcB(ComponentEosInterface[] compArray, double temperature, double - // pressure, int numbcomp); - - /** - *

- * F. - *

- * - * @return a double - */ - public double F(); - - /** - *

- * dFdN. - *

- * - * @param i a int - * @return a double - */ - public double dFdN(int i); - - /** - *

- * dFdNdN. - *

- * - * @param i a int - * @param j a int - * @return a double - */ - public double dFdNdN(int i, int j); - - /** - *

- * dFdNdV. - *

- * - * @param i a int - * @return a double - */ - public double dFdNdV(int i); - - /** - *

- * dFdNdT. - *

- * - * @param i a int - * @return a double - */ - public double dFdNdT(int i); - - /** - *

- * getAresTV. - *

- * - * @return a double - */ - public double getAresTV(); - - /** - *

- * getSresTV. - *

- * - * @return a double - */ - public double getSresTV(); + /** {@inheritDoc} */ + @Override + double getMolarVolume(); + + /** + *

+ * getMixingRule. + *

+ * + * @return a {@link neqsim.thermo.mixingRule.EosMixingRulesInterface} object + */ + public EosMixingRulesInterface getMixingRule(); + + /** + *

+ * getMixingRuleName. + *

+ * + * @return a {@link java.lang.String} object + */ + public java.lang.String getMixingRuleName(); + + /** + *

+ * calcPressure. + *

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

+ * calcPressuredV. + *

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

+ * getPressureRepulsive. + *

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

+ * getPressureAttractive. + *

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

+ * displayInteractionCoefficients. + *

+ * + * @param intType a {@link java.lang.String} object + */ + public void displayInteractionCoefficients(String intType); + // public double getA(); + // public double getB(); + // double calcA(ComponentEosInterface[] compArray, double temperature, double + // pressure, int numbcomp); + // double calcB(ComponentEosInterface[] compArray, double temperature, double + // pressure, int numbcomp); + // double calcA(ComponentEosInterface[] compArray, double temperature, double + // pressure, int numbcomp); + // double calcB(ComponentEosInterface[] compArray, double temperature, double + // pressure, int numbcomp); + + /** + *

+ * F. + *

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

+ * dFdN. + *

+ * + * @param i a int + * @return a double + */ + public double dFdN(int i); + + /** + *

+ * dFdNdN. + *

+ * + * @param i a int + * @param j a int + * @return a double + */ + public double dFdNdN(int i, int j); + + /** + *

+ * dFdNdV. + *

+ * + * @param i a int + * @return a double + */ + public double dFdNdV(int i); + + /** + *

+ * dFdNdT. + *

+ * + * @param i a int + * @return a double + */ + public double dFdNdT(int i); + + /** + *

+ * getAresTV. + *

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

+ * getSresTV. + *

+ * + * @return a double + */ + public double getSresTV(); } diff --git a/src/main/java/neqsim/thermo/phase/PhaseGE.java b/src/main/java/neqsim/thermo/phase/PhaseGE.java index 6fe67dca43..4e0d6875a9 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGE.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGE.java @@ -3,6 +3,7 @@ * * Created on 11. juli 2000, 21:00 */ + package neqsim.thermo.phase; import org.apache.logging.log4j.LogManager; @@ -21,312 +22,309 @@ * @version $Id: $Id */ public class PhaseGE extends Phase implements PhaseGEInterface { - private static final long serialVersionUID = 1000; - - EosMixingRules mixSelect = new EosMixingRules(); - EosMixingRulesInterface mixRuleEos; - - static Logger logger = LogManager.getLogger(PhaseGE.class); - - /** - *

- * Constructor for PhaseGE. - *

- */ - public PhaseGE() { - super(); - phaseTypeName = "liquid"; - componentArray = new ComponentGEInterface[MAX_NUMBER_OF_COMPONENTS]; - useVolumeCorrection = false; + private static final long serialVersionUID = 1000; + + EosMixingRules mixSelect = new EosMixingRules(); + EosMixingRulesInterface mixRuleEos; + + static Logger logger = LogManager.getLogger(PhaseGE.class); + + /** + *

+ * Constructor for PhaseGE. + *

+ */ + public PhaseGE() { + super(); + phaseTypeName = "liquid"; + componentArray = new ComponentGEInterface[MAX_NUMBER_OF_COMPONENTS]; + useVolumeCorrection = false; + } + + /** + *

+ * init. + *

+ * + * @param temperature a double + * @param pressure a double + * @param totalNumberOfMoles a double + * @param beta a double + * @param numberOfComponents a int + * @param type a int + * @param phase a int + */ + public void init(double temperature, double pressure, double totalNumberOfMoles, double beta, + int numberOfComponents, int type, int phase) { + if (totalNumberOfMoles <= 0) { + new neqsim.util.exception.InvalidInputException(this, "init", "totalNumberOfMoles", + "must be larger than zero."); } - - /** - *

- * init. - *

- * - * @param temperature a double - * @param pressure a double - * @param totalNumberOfMoles a double - * @param beta a double - * @param numberOfComponents a int - * @param type a int - * @param phase a int - */ - public void init(double temperature, double pressure, double totalNumberOfMoles, double beta, - int numberOfComponents, int type, int phase) { - if (totalNumberOfMoles <= 0) { - new neqsim.util.exception.InvalidInputException(this, "init", "totalNumberOfMoles", - "must be larger than zero."); - } - for (int i = 0; i < numberOfComponents; i++) { - componentArray[i].init(temperature, pressure, totalNumberOfMoles, beta, type); - } - this.getExessGibbsEnergy(this, numberOfComponents, temperature, pressure, type); - - double sumHydrocarbons = 0.0, sumAqueous = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - if (getComponent(i).isHydrocarbon() || getComponent(i).isInert() - || getComponent(i).isIsTBPfraction()) { - sumHydrocarbons += getComponent(i).getx(); - } else { - sumAqueous += getComponent(i).getx(); - } - } - - if (sumHydrocarbons > sumAqueous) { - phaseTypeName = "oil"; - } else { - phaseTypeName = "aqueous"; - } + for (int i = 0; i < numberOfComponents; i++) { + componentArray[i].init(temperature, pressure, totalNumberOfMoles, beta, type); } - - /** {@inheritDoc} */ - @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int initType, int phase, - double beta) { - super.init(totalNumberOfMoles, numberOfComponents, initType, phase, beta); - if (initType != 0) { - getExessGibbsEnergy(this, numberOfComponents, temperature, pressure, phase); - } - - double sumHydrocarbons = 0.0, sumAqueous = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - if (getComponent(i).isHydrocarbon() || getComponent(i).isInert() - || getComponent(i).isIsTBPfraction()) { - sumHydrocarbons += getComponent(i).getx(); - } else { - sumAqueous += getComponent(i).getx(); - } - } - - if (sumHydrocarbons > sumAqueous) { - phaseTypeName = "oil"; - } else { - phaseTypeName = "aqueous"; - } - - // calc liquid density - - if (initType > 1) { - // Calc Cp /Cv - // Calc enthalpy/entropys - } + this.getExessGibbsEnergy(this, numberOfComponents, temperature, pressure, type); + + double sumHydrocarbons = 0.0, sumAqueous = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + if (getComponent(i).isHydrocarbon() || getComponent(i).isInert() + || getComponent(i).isIsTBPfraction()) { + sumHydrocarbons += getComponent(i).getx(); + } else { + sumAqueous += getComponent(i).getx(); + } } - /** {@inheritDoc} */ - @Override - public void setMixingRule(int type) { - mixingRuleDefined = true; - super.setMixingRule(2); - mixRuleEos = mixSelect.getMixingRule(2, this); + if (sumHydrocarbons > sumAqueous) { + phaseTypeName = "oil"; + } else { + phaseTypeName = "aqueous"; } - - /** {@inheritDoc} */ - @Override - public void resetMixingRule(int type) { - mixingRuleDefined = true; - super.setMixingRule(2); - mixRuleEos = mixSelect.resetMixingRule(2, this); + } + + /** {@inheritDoc} */ + @Override + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, int phase, + double beta) { + super.init(totalNumberOfMoles, numberOfComponents, initType, phase, beta); + if (initType != 0) { + getExessGibbsEnergy(this, numberOfComponents, temperature, pressure, phase); } - /** {@inheritDoc} */ - @Override - public double molarVolume(double pressure, double temperature, double A, double B, int phase) { - return 1; + double sumHydrocarbons = 0.0, sumAqueous = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + if (getComponent(i).isHydrocarbon() || getComponent(i).isInert() + || getComponent(i).isIsTBPfraction()) { + sumHydrocarbons += getComponent(i).getx(); + } else { + sumAqueous += getComponent(i).getx(); + } } - /** - *

- * molarVolumeAnalytic. - *

- * - * @param pressure a double - * @param temperature a double - * @param A a double - * @param B a double - * @param phase a int - * @return a double - */ - public double molarVolumeAnalytic(double pressure, double temperature, double A, double B, - int phase) { - return 1; + if (sumHydrocarbons > sumAqueous) { + phaseTypeName = "oil"; + } else { + phaseTypeName = "aqueous"; } - /** {@inheritDoc} */ - @Override - public void addcomponent(String componentName, double moles, double molesInPhase, - int compNumber) { - super.addcomponent(molesInPhase); - } + // calc liquid density - /** - *

- * setAlpha. - *

- * - * @param alpha an array of {@link double} objects - */ - public void setAlpha(double[][] alpha) {} - - /** - *

- * setDij. - *

- * - * @param Dij an array of {@link double} objects - */ - public void setDij(double[][] Dij) {} - - /** {@inheritDoc} */ - @Override - public double getExessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { - logger.error("this getExxess should never be used......."); - return 0; + if (initType > 1) { + // Calc Cp /Cv + // Calc enthalpy/entropys } - - /** {@inheritDoc} */ - @Override - public double getGibbsEnergy() { - return 0; - } - - /** {@inheritDoc} */ - @Override - public double getExessGibbsEnergy() { - logger.error("this getExxess should never be used......."); - return 0; + } + + /** {@inheritDoc} */ + @Override + public void setMixingRule(int type) { + mixingRuleDefined = true; + super.setMixingRule(2); + mixRuleEos = mixSelect.getMixingRule(2, this); + } + + /** {@inheritDoc} */ + @Override + public void resetMixingRule(int type) { + mixingRuleDefined = true; + super.setMixingRule(2); + mixRuleEos = mixSelect.resetMixingRule(2, this); + } + + /** {@inheritDoc} */ + @Override + public double molarVolume(double pressure, double temperature, double A, double B, int phase) { + return 1; + } + + /** + *

+ * molarVolumeAnalytic. + *

+ * + * @param pressure a double + * @param temperature a double + * @param A a double + * @param B a double + * @param phase a int + * @return a double + */ + public double molarVolumeAnalytic(double pressure, double temperature, double A, double B, + int phase) { + return 1; + } + + /** {@inheritDoc} */ + @Override + public void addcomponent(String componentName, double moles, double molesInPhase, + int compNumber) { + super.addcomponent(molesInPhase); + } + + /** + *

+ * setAlpha. + *

+ * + * @param alpha an array of {@link double} objects + */ + public void setAlpha(double[][] alpha) {} + + /** + *

+ * setDij. + *

+ * + * @param Dij an array of {@link double} objects + */ + public void setDij(double[][] Dij) {} + + /** {@inheritDoc} */ + @Override + public double getExessGibbsEnergy(PhaseInterface phase, int numberOfComponents, + double temperature, double pressure, int phasetype) { + logger.error("this getExxess should never be used......."); + return 0; + } + + /** {@inheritDoc} */ + @Override + public double getGibbsEnergy() { + return 0; + } + + /** {@inheritDoc} */ + @Override + public double getExessGibbsEnergy() { + logger.error("this getExxess should never be used......."); + return 0; + } + + /** + *

+ * setDijT. + *

+ * + * @param DijT an array of {@link double} objects + */ + public void setDijT(double[][] DijT) {} + + /** {@inheritDoc} */ + @Override + public double getActivityCoefficientSymetric(int k) { + return ((ComponentGEInterface) getComponent(k)).getGamma(); + } + + /** {@inheritDoc} */ + @Override + public double getActivityCoefficient(int k) { + return ((ComponentGEInterface) getComponent(k)).getGamma(); + } + + /** + *

+ * getActivityCoefficientInfDilWater. + *

+ * + * @param k a int + * @param p a int + * @return a double + */ + public double getActivityCoefficientInfDilWater(int k, int p) { + if (refPhase == null) { + initRefPhases(false, getComponent(p).getName()); } - - /** - *

- * setDijT. - *

- * - * @param DijT an array of {@link double} objects - */ - public void setDijT(double[][] DijT) {} - - /** {@inheritDoc} */ - @Override - public double getActivityCoefficientSymetric(int k) { - return ((ComponentGEInterface) getComponent(k)).getGamma(); - } - - /** {@inheritDoc} */ - @Override - public double getActivityCoefficient(int k) { - return ((ComponentGEInterface) getComponent(k)).getGamma(); - } - - /** - *

- * getActivityCoefficientInfDilWater. - *

- * - * @param k a int - * @param p a int - * @return a double - */ - public double getActivityCoefficientInfDilWater(int k, int p) { - if (refPhase == null) { - initRefPhases(false, getComponent(p).getName()); - } - refPhase[k].setTemperature(temperature); - refPhase[k].setPressure(pressure); - refPhase[k].init(refPhase[k].getNumberOfMolesInPhase(), 2, 1, this.getPhaseType(), 1.0); - ((PhaseGEInterface) refPhase[k]).getExessGibbsEnergy(refPhase[k], 2, - refPhase[k].getTemperature(), refPhase[k].getPressure(), - refPhase[k].getPhaseType()); - return ((ComponentGEInterface) refPhase[k].getComponent(0)).getGamma(); - } - - /** - *

- * getActivityCoefficientInfDil. - *

- * - * @param k a int - * @return a double - */ - public double getActivityCoefficientInfDil(int k) { - PhaseInterface dilphase = (PhaseInterface) this.clone(); - dilphase.addMoles(k, -(1.0 - 1e-10) * dilphase.getComponent(k).getNumberOfMolesInPhase()); - dilphase.getComponent(k).setx(1e-10); - dilphase.init(dilphase.getNumberOfMolesInPhase(), dilphase.getNumberOfComponents(), 1, - dilphase.getPhaseType(), 1.0); - ((PhaseGEInterface) dilphase).getExessGibbsEnergy(dilphase, 2, dilphase.getTemperature(), - dilphase.getPressure(), dilphase.getPhaseType()); - return ((ComponentGEInterface) dilphase.getComponent(0)).getGamma(); - } - - /** {@inheritDoc} */ - @Override - public double getEnthalpy() { - return getCp() * temperature * numberOfMolesInPhase; - } - - /** {@inheritDoc} */ - @Override - public double getEntropy() { - return getCp() - * Math.log(temperature / ThermodynamicConstantsInterface.referenceTemperature); - } - - /** {@inheritDoc} */ - @Override - public double getCp() { - double tempVar = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - tempVar += componentArray[i].getx() - * componentArray[i].getPureComponentCpLiquid(temperature); - } - return tempVar; - } - - /** {@inheritDoc} */ - @Override - public double getCv() { - // Cv is assumed equal to Cp - return getCp(); - } - - // return speed of sound in water constant 1470.0 m/sec - /** {@inheritDoc} */ - @Override - public double getZ() { - double densityIdealGas = pressure * 1e5 / 8.314 / temperature * getMolarMass(); - return densityIdealGas / getDensity("kg/m3"); - } - - // return speed of sound in water constant 1470.0 m/sec - /** {@inheritDoc} */ - @Override - public double getSoundSpeed() { - return 1470.0; - } - - // return speed of JT coefficient of water at K/bar (assumed constant) - /** {@inheritDoc} */ - @Override - public double getJouleThomsonCoefficient() { - return -0.125 / 10.0; - } - - /** - * {@inheritDoc} - * - * note: at the moment return density of water (997 kg/m3) - */ - @Override - public double getDensity() { - return 997.0; - } - - /** {@inheritDoc} */ - @Override - public double getMolarVolume() { - return 1.0 / (getDensity() / getMolarMass()) * 1.0e5; + refPhase[k].setTemperature(temperature); + refPhase[k].setPressure(pressure); + refPhase[k].init(refPhase[k].getNumberOfMolesInPhase(), 2, 1, this.getPhaseType(), 1.0); + ((PhaseGEInterface) refPhase[k]).getExessGibbsEnergy(refPhase[k], 2, + refPhase[k].getTemperature(), refPhase[k].getPressure(), refPhase[k].getPhaseType()); + return ((ComponentGEInterface) refPhase[k].getComponent(0)).getGamma(); + } + + /** + *

+ * getActivityCoefficientInfDil. + *

+ * + * @param k a int + * @return a double + */ + public double getActivityCoefficientInfDil(int k) { + PhaseInterface dilphase = (PhaseInterface) this.clone(); + dilphase.addMoles(k, -(1.0 - 1e-10) * dilphase.getComponent(k).getNumberOfMolesInPhase()); + dilphase.getComponent(k).setx(1e-10); + dilphase.init(dilphase.getNumberOfMolesInPhase(), dilphase.getNumberOfComponents(), 1, + dilphase.getPhaseType(), 1.0); + ((PhaseGEInterface) dilphase).getExessGibbsEnergy(dilphase, 2, dilphase.getTemperature(), + dilphase.getPressure(), dilphase.getPhaseType()); + return ((ComponentGEInterface) dilphase.getComponent(0)).getGamma(); + } + + /** {@inheritDoc} */ + @Override + public double getEnthalpy() { + return getCp() * temperature * numberOfMolesInPhase; + } + + /** {@inheritDoc} */ + @Override + public double getEntropy() { + return getCp() * Math.log(temperature / ThermodynamicConstantsInterface.referenceTemperature); + } + + /** {@inheritDoc} */ + @Override + public double getCp() { + double tempVar = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + tempVar += componentArray[i].getx() * componentArray[i].getPureComponentCpLiquid(temperature); } + return tempVar; + } + + /** {@inheritDoc} */ + @Override + public double getCv() { + // Cv is assumed equal to Cp + return getCp(); + } + + // return speed of sound in water constant 1470.0 m/sec + /** {@inheritDoc} */ + @Override + public double getZ() { + double densityIdealGas = pressure * 1e5 / 8.314 / temperature * getMolarMass(); + return densityIdealGas / getDensity("kg/m3"); + } + + // return speed of sound in water constant 1470.0 m/sec + /** {@inheritDoc} */ + @Override + public double getSoundSpeed() { + return 1470.0; + } + + // return speed of JT coefficient of water at K/bar (assumed constant) + /** {@inheritDoc} */ + @Override + public double getJouleThomsonCoefficient() { + return -0.125 / 10.0; + } + + /** + * {@inheritDoc} + * + * note: at the moment return density of water (997 kg/m3) + */ + @Override + public double getDensity() { + return 997.0; + } + + /** {@inheritDoc} */ + @Override + public double getMolarVolume() { + return 1.0 / (getDensity() / getMolarMass()) * 1.0e5; + } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseGEInterface.java b/src/main/java/neqsim/thermo/phase/PhaseGEInterface.java index fccd1510e9..da58300910 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGEInterface.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGEInterface.java @@ -3,6 +3,7 @@ * * Created on 12. juli 2000, 00:26 */ + package neqsim.thermo.phase; /** @@ -14,18 +15,18 @@ * @version $Id: $Id */ public interface PhaseGEInterface { - /** - *

- * getExessGibbsEnergy. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComponents a int - * @param temperature a double - * @param pressure a double - * @param phasetype a int - * @return a double - */ - public double getExessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype); + /** + *

+ * getExessGibbsEnergy. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComponents a int + * @param temperature a double + * @param pressure a double + * @param phasetype a int + * @return a double + */ + public double getExessGibbsEnergy(PhaseInterface phase, int numberOfComponents, + double temperature, double pressure, int phasetype); } diff --git a/src/main/java/neqsim/thermo/phase/PhaseGENRTL.java b/src/main/java/neqsim/thermo/phase/PhaseGENRTL.java index 9ff8080d03..e7a9007e1a 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGENRTL.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGENRTL.java @@ -3,6 +3,7 @@ * * Created on 17. juli 2000, 20:51 */ + package neqsim.thermo.phase; import neqsim.thermo.component.ComponentGEInterface; @@ -17,112 +18,112 @@ * @version $Id: $Id */ public class PhaseGENRTL extends PhaseGE { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - double[][] alpha; - String[][] mixRule; - double[][] intparam; - double[][] Dij; - double GE = 0.0; + double[][] alpha; + String[][] mixRule; + double[][] intparam; + double[][] Dij; + double GE = 0.0; - /** - *

- * Constructor for PhaseGENRTL. - *

- */ - public PhaseGENRTL() { - super(); - } + /** + *

+ * Constructor for PhaseGENRTL. + *

+ */ + public PhaseGENRTL() { + super(); + } - /** - *

- * Constructor for PhaseGENRTL. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param alpha an array of {@link double} objects - * @param Dij an array of {@link double} objects - * @param mixRule an array of {@link java.lang.String} objects - * @param intparam an array of {@link double} objects - */ - public PhaseGENRTL(PhaseInterface phase, double[][] alpha, double[][] Dij, String[][] mixRule, - double[][] intparam) { - super(); - componentArray = new ComponentGeNRTL[alpha[0].length]; - this.mixRule = mixRule; - this.alpha = alpha; - this.Dij = Dij; - this.intparam = intparam; - for (int i = 0; i < alpha[0].length; i++) { - numberOfComponents++; - componentArray[i] = new ComponentGeNRTL(phase.getComponents()[i].getName(), - phase.getComponents()[i].getNumberOfmoles(), - phase.getComponents()[i].getNumberOfMolesInPhase(), - phase.getComponents()[i].getComponentNumber()); - } - setMixingRule(2); + /** + *

+ * Constructor for PhaseGENRTL. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param alpha an array of {@link double} objects + * @param Dij an array of {@link double} objects + * @param mixRule an array of {@link java.lang.String} objects + * @param intparam an array of {@link double} objects + */ + public PhaseGENRTL(PhaseInterface phase, double[][] alpha, double[][] Dij, String[][] mixRule, + double[][] intparam) { + super(); + componentArray = new ComponentGeNRTL[alpha[0].length]; + this.mixRule = mixRule; + this.alpha = alpha; + this.Dij = Dij; + this.intparam = intparam; + for (int i = 0; i < alpha[0].length; i++) { + numberOfComponents++; + componentArray[i] = new ComponentGeNRTL(phase.getComponents()[i].getName(), + phase.getComponents()[i].getNumberOfmoles(), + phase.getComponents()[i].getNumberOfMolesInPhase(), + phase.getComponents()[i].getComponentNumber()); } + setMixingRule(2); + } - /** {@inheritDoc} */ - @Override - public void addcomponent(String componentName, double moles, double molesInPhase, - int compNumber) { - super.addcomponent(molesInPhase); - componentArray[compNumber] = - new ComponentGeNRTL(componentName, moles, molesInPhase, compNumber); - } + /** {@inheritDoc} */ + @Override + public void addcomponent(String componentName, double moles, double molesInPhase, + int compNumber) { + super.addcomponent(molesInPhase); + componentArray[compNumber] = + new ComponentGeNRTL(componentName, moles, molesInPhase, compNumber); + } - /** {@inheritDoc} */ - @Override - public void setMixingRule(int type) { - super.setMixingRule(type); - this.intparam = mixSelect.getSRKbinaryInteractionParameters(); - this.alpha = mixSelect.getNRTLalpha(); - this.mixRule = mixSelect.getClassicOrHV(); - this.Dij = mixSelect.getNRTLDij(); - } + /** {@inheritDoc} */ + @Override + public void setMixingRule(int type) { + super.setMixingRule(type); + this.intparam = mixSelect.getSRKbinaryInteractionParameters(); + this.alpha = mixSelect.getNRTLalpha(); + this.mixRule = mixSelect.getClassicOrHV(); + this.Dij = mixSelect.getNRTLDij(); + } - /** {@inheritDoc} */ - @Override - public void setAlpha(double[][] alpha) { - for (int i = 0; i < alpha.length; i++) { - System.arraycopy(alpha[i], 0, this.alpha[i], 0, alpha[0].length); - } + /** {@inheritDoc} */ + @Override + public void setAlpha(double[][] alpha) { + for (int i = 0; i < alpha.length; i++) { + System.arraycopy(alpha[i], 0, this.alpha[i], 0, alpha[0].length); } + } - /** {@inheritDoc} */ - @Override - public void setDij(double[][] Dij) { - for (int i = 0; i < Dij.length; i++) { - System.arraycopy(Dij[i], 0, this.Dij[i], 0, Dij[0].length); - } + /** {@inheritDoc} */ + @Override + public void setDij(double[][] Dij) { + for (int i = 0; i < Dij.length; i++) { + System.arraycopy(Dij[i], 0, this.Dij[i], 0, Dij[0].length); } + } - /** {@inheritDoc} */ - @Override - public double getExessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { - GE = 0; - for (int i = 0; i < numberOfComponents; i++) { - GE += phase.getComponents()[i].getx() * Math.log( - ((ComponentGEInterface) componentArray[i]).getGamma(phase, numberOfComponents, - temperature, pressure, phasetype, alpha, Dij, intparam, mixRule)); - } - - return R * temperature * numberOfMolesInPhase * GE;// phase.getNumberOfMolesInPhase()* + /** {@inheritDoc} */ + @Override + public double getExessGibbsEnergy(PhaseInterface phase, int numberOfComponents, + double temperature, double pressure, int phasetype) { + GE = 0; + for (int i = 0; i < numberOfComponents; i++) { + GE += phase.getComponents()[i].getx() + * Math.log(((ComponentGEInterface) componentArray[i]).getGamma(phase, numberOfComponents, + temperature, pressure, phasetype, alpha, Dij, intparam, mixRule)); } - /** {@inheritDoc} */ - @Override - public double getGibbsEnergy() { - return R * temperature * numberOfMolesInPhase * (GE + Math.log(pressure)); - } + return R * temperature * numberOfMolesInPhase * GE;// phase.getNumberOfMolesInPhase()* + } - /** {@inheritDoc} */ - @Override - public double getExessGibbsEnergy() { - // double GE = getExessGibbsEnergy(this, numberOfComponents, temperature, - // pressure, phaseType); - return GE; - } + /** {@inheritDoc} */ + @Override + public double getGibbsEnergy() { + return R * temperature * numberOfMolesInPhase * (GE + Math.log(pressure)); + } + + /** {@inheritDoc} */ + @Override + public double getExessGibbsEnergy() { + // double GE = getExessGibbsEnergy(this, numberOfComponents, temperature, + // pressure, phaseType); + return GE; + } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedHV.java b/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedHV.java index 4a569caa12..2cd4b6f956 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedHV.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedHV.java @@ -3,6 +3,7 @@ * * Created on 18. juli 2000, 18:32 */ + package neqsim.thermo.phase; import neqsim.thermo.component.ComponentGEInterface; @@ -17,150 +18,148 @@ * @version $Id: $Id */ public class PhaseGENRTLmodifiedHV extends PhaseGENRTL { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - double[][] DijT; - int type = 0; + double[][] DijT; + int type = 0; - /** - *

- * Constructor for PhaseGENRTLmodifiedHV. - *

- */ - public PhaseGENRTLmodifiedHV() { - super(); - mixRuleEos = mixSelect.getMixingRule(1); - } + /** + *

+ * Constructor for PhaseGENRTLmodifiedHV. + *

+ */ + public PhaseGENRTLmodifiedHV() { + super(); + mixRuleEos = mixSelect.getMixingRule(1); + } - /** - *

- * Constructor for PhaseGENRTLmodifiedHV. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param alpha an array of {@link double} objects - * @param Dij an array of {@link double} objects - * @param mixRule an array of {@link java.lang.String} objects - * @param intparam an array of {@link double} objects - */ - public PhaseGENRTLmodifiedHV(PhaseInterface phase, double[][] alpha, double[][] Dij, - String[][] mixRule, double[][] intparam) { - super(phase, alpha, Dij, mixRule, intparam); - componentArray = new ComponentGENRTLmodifiedHV[alpha[0].length]; - type = 0; - for (int i = 0; i < alpha[0].length; i++) { - componentArray[i] = new ComponentGENRTLmodifiedHV(phase.getComponents()[i].getName(), - phase.getComponents()[i].getNumberOfmoles(), - phase.getComponents()[i].getNumberOfMolesInPhase(), - phase.getComponents()[i].getComponentNumber()); - } + /** + *

+ * Constructor for PhaseGENRTLmodifiedHV. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param alpha an array of {@link double} objects + * @param Dij an array of {@link double} objects + * @param mixRule an array of {@link java.lang.String} objects + * @param intparam an array of {@link double} objects + */ + public PhaseGENRTLmodifiedHV(PhaseInterface phase, double[][] alpha, double[][] Dij, + String[][] mixRule, double[][] intparam) { + super(phase, alpha, Dij, mixRule, intparam); + componentArray = new ComponentGENRTLmodifiedHV[alpha[0].length]; + type = 0; + for (int i = 0; i < alpha[0].length; i++) { + componentArray[i] = new ComponentGENRTLmodifiedHV(phase.getComponents()[i].getName(), + phase.getComponents()[i].getNumberOfmoles(), + phase.getComponents()[i].getNumberOfMolesInPhase(), + phase.getComponents()[i].getComponentNumber()); } + } - /** - *

- * Constructor for PhaseGENRTLmodifiedHV. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param alpha an array of {@link double} objects - * @param Dij an array of {@link double} objects - * @param DijT an array of {@link double} objects - * @param mixRule an array of {@link java.lang.String} objects - * @param intparam an array of {@link double} objects - */ - public PhaseGENRTLmodifiedHV(PhaseInterface phase, double[][] alpha, double[][] Dij, - double[][] DijT, String[][] mixRule, double[][] intparam) { - super(phase, alpha, Dij, mixRule, intparam); - componentArray = new ComponentGENRTLmodifiedHV[alpha[0].length]; - type = 1; - this.DijT = DijT; - for (int i = 0; i < alpha[0].length; i++) { - componentArray[i] = new ComponentGENRTLmodifiedHV(phase.getComponents()[i].getName(), - phase.getComponents()[i].getNumberOfmoles(), - phase.getComponents()[i].getNumberOfMolesInPhase(), - phase.getComponents()[i].getComponentNumber()); - } + /** + *

+ * Constructor for PhaseGENRTLmodifiedHV. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param alpha an array of {@link double} objects + * @param Dij an array of {@link double} objects + * @param DijT an array of {@link double} objects + * @param mixRule an array of {@link java.lang.String} objects + * @param intparam an array of {@link double} objects + */ + public PhaseGENRTLmodifiedHV(PhaseInterface phase, double[][] alpha, double[][] Dij, + double[][] DijT, String[][] mixRule, double[][] intparam) { + super(phase, alpha, Dij, mixRule, intparam); + componentArray = new ComponentGENRTLmodifiedHV[alpha[0].length]; + type = 1; + this.DijT = DijT; + for (int i = 0; i < alpha[0].length; i++) { + componentArray[i] = new ComponentGENRTLmodifiedHV(phase.getComponents()[i].getName(), + phase.getComponents()[i].getNumberOfmoles(), + phase.getComponents()[i].getNumberOfMolesInPhase(), + phase.getComponents()[i].getComponentNumber()); } + } - /** {@inheritDoc} */ - @Override - public void addcomponent(String componentName, double moles, double molesInPhase, - int compNumber) { - super.addcomponent(molesInPhase); - componentArray[compNumber] = - new ComponentGENRTLmodifiedHV(componentName, moles, molesInPhase, compNumber); - } + /** {@inheritDoc} */ + @Override + public void addcomponent(String componentName, double moles, double molesInPhase, + int compNumber) { + super.addcomponent(molesInPhase); + componentArray[compNumber] = + new ComponentGENRTLmodifiedHV(componentName, moles, molesInPhase, compNumber); + } - /** {@inheritDoc} */ - @Override - public void setMixingRule(int type) { - super.setMixingRule(type); - this.DijT = mixSelect.getHVDijT(); - this.intparam = mixSelect.getSRKbinaryInteractionParameters(); - this.alpha = mixSelect.getHValpha(); - this.mixRule = mixSelect.getClassicOrHV(); - this.Dij = mixSelect.getHVDij(); - } + /** {@inheritDoc} */ + @Override + public void setMixingRule(int type) { + super.setMixingRule(type); + this.DijT = mixSelect.getHVDijT(); + this.intparam = mixSelect.getSRKbinaryInteractionParameters(); + this.alpha = mixSelect.getHValpha(); + this.mixRule = mixSelect.getClassicOrHV(); + this.Dij = mixSelect.getHVDij(); + } - /** {@inheritDoc} */ - @Override - public void setParams(PhaseInterface phase, double[][] alpha, double[][] Dij, double[][] DijT, - String[][] mixRule, double[][] intparam) { - this.mixRule = mixRule; - this.alpha = alpha; - this.Dij = Dij; - type = 1; - this.DijT = DijT; - this.intparam = intparam; - } + /** {@inheritDoc} */ + @Override + public void setParams(PhaseInterface phase, double[][] alpha, double[][] Dij, double[][] DijT, + String[][] mixRule, double[][] intparam) { + this.mixRule = mixRule; + this.alpha = alpha; + this.Dij = Dij; + type = 1; + this.DijT = DijT; + this.intparam = intparam; + } - /** {@inheritDoc} */ - @Override - public void setDijT(double[][] DijT) { - for (int i = 0; i < DijT.length; i++) { - System.arraycopy(DijT[i], 0, this.DijT[i], 0, DijT[0].length); - } + /** {@inheritDoc} */ + @Override + public void setDijT(double[][] DijT) { + for (int i = 0; i < DijT.length; i++) { + System.arraycopy(DijT[i], 0, this.DijT[i], 0, DijT[0].length); } + } - /** {@inheritDoc} */ - @Override - public double getExessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { - GE = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - if (type == 0) { - GE += phase.getComponents()[i].getx() - * Math.log(((ComponentGEInterface) componentArray[i]).getGamma(phase, - numberOfComponents, temperature, pressure, phasetype, alpha, Dij, - intparam, mixRule)); - } else if (type == 1) { - GE += phase.getComponents()[i].getx() - * Math.log(((ComponentGENRTLmodifiedHV) componentArray[i]).getGamma(phase, - numberOfComponents, temperature, pressure, phasetype, alpha, Dij, - DijT, intparam, mixRule)); - } - } - return (R * phase.getTemperature() * GE) * phase.getNumberOfMolesInPhase(); + /** {@inheritDoc} */ + @Override + public double getExessGibbsEnergy(PhaseInterface phase, int numberOfComponents, + double temperature, double pressure, int phasetype) { + GE = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + if (type == 0) { + GE += phase.getComponents()[i].getx() * Math + .log(((ComponentGEInterface) componentArray[i]).getGamma(phase, numberOfComponents, + temperature, pressure, phasetype, alpha, Dij, intparam, mixRule)); + } else if (type == 1) { + GE += phase.getComponents()[i].getx() * Math + .log(((ComponentGENRTLmodifiedHV) componentArray[i]).getGamma(phase, numberOfComponents, + temperature, pressure, phasetype, alpha, Dij, DijT, intparam, mixRule)); + } } + return (R * phase.getTemperature() * GE) * phase.getNumberOfMolesInPhase(); + } - /** {@inheritDoc} */ - @Override - public double getGibbsEnergy() { - double val = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - val += getComponent(i).getNumberOfMolesInPhase() - * (getComponent(i).getLogFugacityCoefficient());// +Math.log(getComponent(i).getx()*getComponent(i).getAntoineVaporPressure(temperature))); - } - return R * temperature * ((val) + Math.log(pressure) * numberOfMolesInPhase); + /** {@inheritDoc} */ + @Override + public double getGibbsEnergy() { + double val = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + val += + getComponent(i).getNumberOfMolesInPhase() * (getComponent(i).getLogFugacityCoefficient());// +Math.log(getComponent(i).getx()*getComponent(i).getAntoineVaporPressure(temperature))); } + return R * temperature * ((val) + Math.log(pressure) * numberOfMolesInPhase); + } - /** {@inheritDoc} */ - @Override - public double getHresTP() { - double val = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - val -= getComponent(i).getNumberOfMolesInPhase() * getComponent(i).getdfugdt(); - } - return R * temperature * temperature * val; + /** {@inheritDoc} */ + @Override + public double getHresTP() { + double val = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + val -= getComponent(i).getNumberOfMolesInPhase() * getComponent(i).getdfugdt(); } + return R * temperature * temperature * val; + } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseGEUniquac.java b/src/main/java/neqsim/thermo/phase/PhaseGEUniquac.java index 7ebe1e6520..9feeebf6ab 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGEUniquac.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGEUniquac.java @@ -3,6 +3,7 @@ * * Created on 11. juli 2000, 21:01 */ + package neqsim.thermo.phase; import neqsim.thermo.component.ComponentGEInterface; @@ -17,99 +18,99 @@ * @version $Id: $Id */ public class PhaseGEUniquac extends PhaseGE { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - double[][] alpha; - String[][] mixRule; - double[][] intparam; - double[][] Dij; - double GE = 0.0; + double[][] alpha; + String[][] mixRule; + double[][] intparam; + double[][] Dij; + double GE = 0.0; - /** - *

- * Constructor for PhaseGEUniquac. - *

- */ - public PhaseGEUniquac() { - super(); - componentArray = new ComponentGEInterface[MAX_NUMBER_OF_COMPONENTS]; - } + /** + *

+ * Constructor for PhaseGEUniquac. + *

+ */ + public PhaseGEUniquac() { + super(); + componentArray = new ComponentGEInterface[MAX_NUMBER_OF_COMPONENTS]; + } - /** - *

- * Constructor for PhaseGEUniquac. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param alpha an array of {@link double} objects - * @param Dij an array of {@link double} objects - * @param mixRule an array of {@link java.lang.String} objects - * @param intparam an array of {@link double} objects - */ - public PhaseGEUniquac(PhaseInterface phase, double[][] alpha, double[][] Dij, - String[][] mixRule, double[][] intparam) { - super(); - componentArray = new ComponentGEUniquac[alpha[0].length]; - this.mixRule = mixRule; - this.alpha = alpha; - this.Dij = Dij; - this.intparam = intparam; - for (int i = 0; i < alpha[0].length; i++) { - numberOfComponents++; - componentArray[i] = new ComponentGEUniquac(phase.getComponents()[i].getName(), - phase.getComponents()[i].getNumberOfmoles(), - phase.getComponents()[i].getNumberOfMolesInPhase(), - phase.getComponents()[i].getComponentNumber()); - } + /** + *

+ * Constructor for PhaseGEUniquac. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param alpha an array of {@link double} objects + * @param Dij an array of {@link double} objects + * @param mixRule an array of {@link java.lang.String} objects + * @param intparam an array of {@link double} objects + */ + public PhaseGEUniquac(PhaseInterface phase, double[][] alpha, double[][] Dij, String[][] mixRule, + double[][] intparam) { + super(); + componentArray = new ComponentGEUniquac[alpha[0].length]; + this.mixRule = mixRule; + this.alpha = alpha; + this.Dij = Dij; + this.intparam = intparam; + for (int i = 0; i < alpha[0].length; i++) { + numberOfComponents++; + componentArray[i] = new ComponentGEUniquac(phase.getComponents()[i].getName(), + phase.getComponents()[i].getNumberOfmoles(), + phase.getComponents()[i].getNumberOfMolesInPhase(), + phase.getComponents()[i].getComponentNumber()); } + } - /** {@inheritDoc} */ - @Override - public void addcomponent(String componentName, double moles, double molesInPhase, - int compNumber) { - super.addcomponent(molesInPhase); - componentArray[compNumber] = - new ComponentGEUniquac(componentName, moles, molesInPhase, compNumber); - } + /** {@inheritDoc} */ + @Override + public void addcomponent(String componentName, double moles, double molesInPhase, + int compNumber) { + super.addcomponent(molesInPhase); + componentArray[compNumber] = + new ComponentGEUniquac(componentName, moles, molesInPhase, compNumber); + } - /** {@inheritDoc} */ - @Override - public void setMixingRule(int type) { - super.setMixingRule(type); - } + /** {@inheritDoc} */ + @Override + public void setMixingRule(int type) { + super.setMixingRule(type); + } - /** {@inheritDoc} */ - @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, - double beta) { - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - } + /** {@inheritDoc} */ + @Override + public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, + double beta) { + super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + } - /** {@inheritDoc} */ - @Override - public double getExessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { - GE = 0; - for (int i = 0; i < numberOfComponents; i++) { - GE += phase.getComponents()[i].getx() * Math.log( - ((ComponentGEInterface) componentArray[i]).getGamma(phase, numberOfComponents, - temperature, pressure, phasetype, alpha, Dij, intparam, mixRule)); - } - - return R * temperature * numberOfMolesInPhase * GE; + /** {@inheritDoc} */ + @Override + public double getExessGibbsEnergy(PhaseInterface phase, int numberOfComponents, + double temperature, double pressure, int phasetype) { + GE = 0; + for (int i = 0; i < numberOfComponents; i++) { + GE += phase.getComponents()[i].getx() + * Math.log(((ComponentGEInterface) componentArray[i]).getGamma(phase, numberOfComponents, + temperature, pressure, phasetype, alpha, Dij, intparam, mixRule)); } - /** {@inheritDoc} */ - @Override - public double getGibbsEnergy() { - return R * temperature * numberOfMolesInPhase * (GE + Math.log(pressure)); - } + return R * temperature * numberOfMolesInPhase * GE; + } - /** {@inheritDoc} */ - @Override - public double getExessGibbsEnergy() { - // GE = getExessGibbsEnergy(this, numberOfComponents, temperature, pressure, - // phaseType); - return GE; - } + /** {@inheritDoc} */ + @Override + public double getGibbsEnergy() { + return R * temperature * numberOfMolesInPhase * (GE + Math.log(pressure)); + } + + /** {@inheritDoc} */ + @Override + public double getExessGibbsEnergy() { + // GE = getExessGibbsEnergy(this, numberOfComponents, temperature, pressure, + // phaseType); + return GE; + } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseGEUniquacmodifiedHV.java b/src/main/java/neqsim/thermo/phase/PhaseGEUniquacmodifiedHV.java index 4134151f82..41f8bbfd4a 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGEUniquacmodifiedHV.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGEUniquacmodifiedHV.java @@ -3,6 +3,7 @@ * * Created on 18. juli 2000, 20:30 */ + package neqsim.thermo.phase; /** @@ -14,40 +15,40 @@ * @version $Id: $Id */ public class PhaseGEUniquacmodifiedHV extends PhaseGEUniquac { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for PhaseGEUniquacmodifiedHV. - *

- */ - public PhaseGEUniquacmodifiedHV() { - super(); - } + /** + *

+ * Constructor for PhaseGEUniquacmodifiedHV. + *

+ */ + public PhaseGEUniquacmodifiedHV() { + super(); + } - /** {@inheritDoc} */ - @Override - public void addcomponent(String componentName, double moles, double molesInPhase, - int compNumber) { - super.addcomponent(molesInPhase); - // componentArray[compNumber] = new ComponentGEUniquacmodifiedHV(componentName, - // moles, molesInPhase, compNumber); - } + /** {@inheritDoc} */ + @Override + public void addcomponent(String componentName, double moles, double molesInPhase, + int compNumber) { + super.addcomponent(molesInPhase); + // componentArray[compNumber] = new ComponentGEUniquacmodifiedHV(componentName, + // moles, molesInPhase, compNumber); + } - /** {@inheritDoc} */ - @Override - public double getExessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { - double GE = 0; + /** {@inheritDoc} */ + @Override + public double getExessGibbsEnergy(PhaseInterface phase, int numberOfComponents, + double temperature, double pressure, int phasetype) { + double GE = 0; - /* - * ComponentGEInterface[] comp_Array = (ComponentGEInterface[]) this.getcomponentArray(); - * - * for (int i = 0; i < numberOfComponents; i++) { GE = GE + comp_Array[i].getx() * - * Math.log(comp_Array[i].getGamma(phase, numberOfComponents, temperature, pressure, - * phasetype)); } - */ + /* + * ComponentGEInterface[] comp_Array = (ComponentGEInterface[]) this.getcomponentArray(); + * + * for (int i = 0; i < numberOfComponents; i++) { GE = GE + comp_Array[i].getx() * + * Math.log(comp_Array[i].getGamma(phase, numberOfComponents, temperature, pressure, + * phasetype)); } + */ - return R * temperature * GE * numberOfMolesInPhase; - } + return R * temperature * GE * numberOfMolesInPhase; + } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseHydrate.java b/src/main/java/neqsim/thermo/phase/PhaseHydrate.java index a7bf23f065..ab9c4688b9 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseHydrate.java +++ b/src/main/java/neqsim/thermo/phase/PhaseHydrate.java @@ -3,6 +3,7 @@ * * Created on 18. august 2001, 12:50 */ + package neqsim.thermo.phase; import neqsim.thermo.component.ComponentHydrate; @@ -18,112 +19,112 @@ * @version $Id: $Id */ public class PhaseHydrate extends Phase { - private static final long serialVersionUID = 1000; - String hydrateModel = "PVTsimHydrateModel"; + private static final long serialVersionUID = 1000; + String hydrateModel = "PVTsimHydrateModel"; - /** - *

- * Constructor for PhaseHydrate. - *

- */ - public PhaseHydrate() { - phaseTypeName = "hydrate"; - } + /** + *

+ * Constructor for PhaseHydrate. + *

+ */ + public PhaseHydrate() { + phaseTypeName = "hydrate"; + } - /** - *

- * Constructor for PhaseHydrate. - *

- * - * @param fluidModel a {@link java.lang.String} object - */ - public PhaseHydrate(String fluidModel) { - if (fluidModel.isEmpty()) { - hydrateModel = "PVTsimHydrateModel"; - } else if (fluidModel.equals("CPAs-SRK-EOS-statoil") || fluidModel.equals("CPAs-SRK-EOS") - || fluidModel.equals("CPA-SRK-EOS")) { - hydrateModel = "CPAHydrateModel"; - } else { - hydrateModel = "PVTsimHydrateModel"; - } + /** + *

+ * Constructor for PhaseHydrate. + *

+ * + * @param fluidModel a {@link java.lang.String} object + */ + public PhaseHydrate(String fluidModel) { + if (fluidModel.isEmpty()) { + hydrateModel = "PVTsimHydrateModel"; + } else if (fluidModel.equals("CPAs-SRK-EOS-statoil") || fluidModel.equals("CPAs-SRK-EOS") + || fluidModel.equals("CPA-SRK-EOS")) { + hydrateModel = "CPAHydrateModel"; + } else { + hydrateModel = "PVTsimHydrateModel"; } + } - /** {@inheritDoc} */ - @Override - public PhaseHydrate clone() { - PhaseHydrate clonedPhase = null; - try { - clonedPhase = (PhaseHydrate) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } - - return clonedPhase; + /** {@inheritDoc} */ + @Override + public PhaseHydrate clone() { + PhaseHydrate clonedPhase = null; + try { + clonedPhase = (PhaseHydrate) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); } - /** {@inheritDoc} */ - @Override - public double molarVolume(double pressure, double temperature, double A, double B, int phase) - throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - double sum = 1.0; - int hydrateStructure = ((ComponentHydrate) getComponent(0)).getHydrateStructure(); - for (int j = 0; j < 2; j++) { - for (int i = 0; i < numberOfComponents; i++) { - sum += ((ComponentHydrate) getComponent(i)).getCavprwat(hydrateStructure, j) - * ((ComponentHydrate) getComponent(i)).calcYKI(hydrateStructure, j, this); - } - } - return sum / (((ComponentHydrate) getComponent(0)).getMolarVolumeHydrate(hydrateStructure, - temperature)); - // return 1.0; - } + return clonedPhase; + } - /** {@inheritDoc} */ - @Override - public void addcomponent(String componentName, double molesInPhase, double moles, - int compNumber) { - super.addcomponent(molesInPhase); - // componentArray[compNumber] = new ComponentHydrateStatoil(componentName, - // moles, molesInPhase, compNumber); - if (hydrateModel.equals("CPAHydrateModel")) { - componentArray[compNumber] = - new ComponentHydrateGF(componentName, moles, molesInPhase, compNumber); - // System.out.println("hydrate model: CPA-EoS hydrate model selected"); - } else { - componentArray[compNumber] = - new ComponentHydratePVTsim(componentName, moles, molesInPhase, compNumber); - // System.out.println("hydrate model: standard PVTsim hydrate model selected"); - } - // componentArray[compNumber] = new ComponentHydrateBallard(componentName, - // moles, molesInPhase, compNumber); - // componentArray[compNumber] = new ComponentHydratePVTsim(componentName, moles, - // molesInPhase, compNumber); + /** {@inheritDoc} */ + @Override + public double molarVolume(double pressure, double temperature, double A, double B, int phase) + throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + double sum = 1.0; + int hydrateStructure = ((ComponentHydrate) getComponent(0)).getHydrateStructure(); + for (int j = 0; j < 2; j++) { + for (int i = 0; i < numberOfComponents; i++) { + sum += ((ComponentHydrate) getComponent(i)).getCavprwat(hydrateStructure, j) + * ((ComponentHydrate) getComponent(i)).calcYKI(hydrateStructure, j, this); + } } + return sum / (((ComponentHydrate) getComponent(0)).getMolarVolumeHydrate(hydrateStructure, + temperature)); + // return 1.0; + } - /** {@inheritDoc} */ - @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, - double beta) { - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + /** {@inheritDoc} */ + @Override + public void addcomponent(String componentName, double molesInPhase, double moles, + int compNumber) { + super.addcomponent(molesInPhase); + // componentArray[compNumber] = new ComponentHydrateStatoil(componentName, + // moles, molesInPhase, compNumber); + if (hydrateModel.equals("CPAHydrateModel")) { + componentArray[compNumber] = + new ComponentHydrateGF(componentName, moles, molesInPhase, compNumber); + // System.out.println("hydrate model: CPA-EoS hydrate model selected"); + } else { + componentArray[compNumber] = + new ComponentHydratePVTsim(componentName, moles, molesInPhase, compNumber); + // System.out.println("hydrate model: standard PVTsim hydrate model selected"); } + // componentArray[compNumber] = new ComponentHydrateBallard(componentName, + // moles, molesInPhase, compNumber); + // componentArray[compNumber] = new ComponentHydratePVTsim(componentName, moles, + // molesInPhase, compNumber); + } + + /** {@inheritDoc} */ + @Override + public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, + double beta) { + super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + } - /** {@inheritDoc} */ - @Override - public void resetMixingRule(int type) {} + /** {@inheritDoc} */ + @Override + public void resetMixingRule(int type) {} - /** - *

- * setSolidRefFluidPhase. - *

- * - * @param refPhase a {@link neqsim.thermo.phase.PhaseInterface} object - */ - public void setSolidRefFluidPhase(PhaseInterface refPhase) { - for (int i = 0; i < numberOfComponents; i++) { - if (componentArray[i].getName().equals("water")) { - ((ComponentHydrate) componentArray[i]).setSolidRefFluidPhase(refPhase); - } - } + /** + *

+ * setSolidRefFluidPhase. + *

+ * + * @param refPhase a {@link neqsim.thermo.phase.PhaseInterface} object + */ + public void setSolidRefFluidPhase(PhaseInterface refPhase) { + for (int i = 0; i < numberOfComponents; i++) { + if (componentArray[i].getName().equals("water")) { + ((ComponentHydrate) componentArray[i]).setSolidRefFluidPhase(refPhase); + } } + } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseInterface.java b/src/main/java/neqsim/thermo/phase/PhaseInterface.java index 30165c4f0f..5fefdddb55 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseInterface.java +++ b/src/main/java/neqsim/thermo/phase/PhaseInterface.java @@ -3,6 +3,7 @@ * * Created on 3. juni 2000, 14:45 */ + package neqsim.thermo.phase; import neqsim.thermo.ThermodynamicConstantsInterface; diff --git a/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEos.java b/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEos.java index a64e76b0c7..7caa1ece92 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEos.java +++ b/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEos.java @@ -3,6 +3,7 @@ * * Created on 26. februar 2001, 17:54 */ + package neqsim.thermo.phase; import org.apache.logging.log4j.LogManager; @@ -18,1708 +19,1718 @@ * @version $Id: $Id */ public class PhaseModifiedFurstElectrolyteEos extends PhaseSrkEos { - private static final long serialVersionUID = 1000; - double gammaold = 0, alphaLRdTdV = 0; - double W = 0, WT = 0, WTT = 0, eps = 0, epsdV = 0, epsdVdV = 0, epsIonic = 0, bornX = 0, - epsIonicdV = 0, epsIonicdVdV = 0, alphaLR2 = 0, alphaLRdT = 0.0, alphaLRdTdT = 0.0, - alphaLRdV = 0.0, XLR = 0, solventDiElectricConstant = 0, - solventDiElectricConstantdT = 0.0, solventDiElectricConstantdTdT = 0, - shieldingParameter = 0; - double gamma = 0, diElectricConstantdV = 0, diElectricConstantdVdV = 0, alphaLRdVdV = 0, - diElectricConstantdT = 0, diElectricConstantdTdT = 0.0, diElectricConstantdTdV = 0; - neqsim.thermo.mixingRule.ElectrolyteMixingRulesInterface electrolyteMixingRule; - double sr2On = 1.0, lrOn = 1.0, bornOn = 1.0; - - static Logger logger = LogManager.getLogger(PhaseModifiedFurstElectrolyteEos.class); - // double gammLRdV=0.0; - // PhaseInterface[] refPhase;// = new PhaseInterface[10]; - - /** - *

- * Constructor for PhaseModifiedFurstElectrolyteEos. - *

- */ - public PhaseModifiedFurstElectrolyteEos() { - super(); - electrolyteMixingRule = mixSelect.getElectrolyteMixingRule(this); - } - - /** - *

- * Getter for the field electrolyteMixingRule. - *

- * - * @return a {@link neqsim.thermo.mixingRule.ElectrolyteMixingRulesInterface} object - */ - public neqsim.thermo.mixingRule.ElectrolyteMixingRulesInterface getElectrolyteMixingRule() { - return electrolyteMixingRule; - } - - /** - *

- * reInitFurstParam. - *

- */ - public void reInitFurstParam() { - for (int k = 0; k < numberOfComponents; k++) { - ((ComponentModifiedFurstElectrolyteEos) componentArray[k]).initFurstParam(); - } - electrolyteMixingRule = mixSelect.getElectrolyteMixingRule(this); - } - - /** {@inheritDoc} */ - @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, - double beta) { - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - if (type == 0) { - electrolyteMixingRule = mixSelect.getElectrolyteMixingRule(this); - } - } - - /** {@inheritDoc} */ - @Override - public PhaseModifiedFurstElectrolyteEos clone() { - PhaseModifiedFurstElectrolyteEos clonedPhase = null; - try { - clonedPhase = (PhaseModifiedFurstElectrolyteEos) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } - // clonedPhase.electrolyteMixingRule = - // (thermo.mixingRule.ElectrolyteMixingRulesInterface) - // electrolyteMixingRule.clone(); - - return clonedPhase; - } - - /** - *

- * volInit. - *

- */ - public void volInit() { - W = electrolyteMixingRule.calcW(this, temperature, pressure, numberOfComponents); - WT = electrolyteMixingRule.calcWT(this, temperature, pressure, numberOfComponents); - WTT = electrolyteMixingRule.calcWTT(this, temperature, pressure, numberOfComponents); - eps = calcEps(); - epsdV = calcEpsV(); - epsdVdV = calcEpsVV(); - epsIonic = calcEpsIonic(); - epsIonicdV = calcEpsIonicdV(); - epsIonicdVdV = calcEpsIonicdVdV(); - solventDiElectricConstant = calcSolventDiElectricConstant(temperature); - solventDiElectricConstantdT = calcSolventDiElectricConstantdT(temperature); - solventDiElectricConstantdTdT = calcSolventDiElectricConstantdTdT(temperature); - diElectricConstant = calcDiElectricConstant(temperature); - diElectricConstantdT = calcDiElectricConstantdT(temperature); - diElectricConstantdTdT = calcDiElectricConstantdTdT(temperature); - diElectricConstantdV = calcDiElectricConstantdV(temperature); - diElectricConstantdVdV = calcDiElectricConstantdVdV(temperature); - diElectricConstantdTdV = calcDiElectricConstantdTdV(temperature); - alphaLR2 = electronCharge * electronCharge * avagadroNumber - / (vacumPermittivity * diElectricConstant * R * temperature); - alphaLRdT = - -electronCharge * electronCharge * avagadroNumber - / (vacumPermittivity * diElectricConstant * R * temperature * temperature) - - electronCharge - * electronCharge * avagadroNumber / (vacumPermittivity - * diElectricConstant * diElectricConstant * R * temperature) - * diElectricConstantdT; - alphaLRdV = -electronCharge * electronCharge * avagadroNumber - / (vacumPermittivity * diElectricConstant * diElectricConstant * R * temperature) - * diElectricConstantdV; - alphaLRdTdT = 2.0 * electronCharge * electronCharge * avagadroNumber - / (vacumPermittivity * diElectricConstant * R * Math.pow(temperature, 3.0)) - + electronCharge * electronCharge * avagadroNumber - / (vacumPermittivity * diElectricConstant * diElectricConstant * R - * temperature * temperature) - * diElectricConstantdT - - electronCharge * electronCharge * avagadroNumber - / (vacumPermittivity * diElectricConstant * diElectricConstant * R - * temperature) - * diElectricConstantdTdT - + electronCharge * electronCharge * avagadroNumber - / (vacumPermittivity * diElectricConstant * diElectricConstant * R - * temperature * temperature) - * diElectricConstantdT - + 2.0 * electronCharge * electronCharge * avagadroNumber - / (vacumPermittivity * Math.pow(diElectricConstant, 3.0) * R * temperature) - * Math.pow(diElectricConstantdT, 2.0); - alphaLRdTdV = - electronCharge * electronCharge * avagadroNumber - / (vacumPermittivity * diElectricConstant * diElectricConstant * R - * temperature * temperature) - * diElectricConstantdV - + 2.0 * electronCharge * electronCharge * avagadroNumber - / (vacumPermittivity * diElectricConstant * diElectricConstant - * diElectricConstant * R * temperature) - * diElectricConstantdT * diElectricConstantdV - - electronCharge - * electronCharge * avagadroNumber / (vacumPermittivity - * diElectricConstant * diElectricConstant * R * temperature) - * diElectricConstantdTdV; - alphaLRdVdV = -electronCharge * electronCharge * avagadroNumber - / (vacumPermittivity * diElectricConstant * diElectricConstant * R * temperature) - * diElectricConstantdVdV - + 2.0 * electronCharge * electronCharge * avagadroNumber - / (vacumPermittivity * Math.pow(diElectricConstant, 3.0) * R * temperature) - * diElectricConstantdV * diElectricConstantdV; - shieldingParameter = calcShieldingParameter(); - // gammLRdV = calcGammaLRdV(); - XLR = calcXLR(); - bornX = calcBornX(); - } - - /** {@inheritDoc} */ - @Override - public void addcomponent(String componentName, double moles, double molesInPhase, - int compNumber) { - super.addcomponent(molesInPhase); - componentArray[compNumber] = - new neqsim.thermo.component.ComponentModifiedFurstElectrolyteEos(componentName, - moles, molesInPhase, compNumber); - } - - /** - *

- * calcSolventDiElectricConstant. - *

- * - * @param temperature a double - * @return a double - */ - public double calcSolventDiElectricConstant(double temperature) { - double ans1 = 0.0, ans2 = 1e-50; - for (int i = 0; i < numberOfComponents; i++) { - if (componentArray[i].getIonicCharge() == 0) { - ans1 += componentArray[i].getNumberOfMolesInPhase() - * componentArray[i].getDiElectricConstant(temperature); - ans2 += componentArray[i].getNumberOfMolesInPhase(); - } - } - return ans1 / ans2; - } - - /** - *

- * calcSolventDiElectricConstantdT. - *

- * - * @param temperature a double - * @return a double - */ - public double calcSolventDiElectricConstantdT(double temperature) { - double ans1 = 0.0, ans2 = 1e-50; - for (int i = 0; i < numberOfComponents; i++) { - if (componentArray[i].getIonicCharge() == 0) { - ans1 += componentArray[i].getNumberOfMolesInPhase() - * componentArray[i].getDiElectricConstantdT(temperature); - ans2 += componentArray[i].getNumberOfMolesInPhase(); - } - } - return ans1 / ans2; - } - - /** - *

- * calcSolventDiElectricConstantdTdT. - *

- * - * @param temperature a double - * @return a double - */ - public double calcSolventDiElectricConstantdTdT(double temperature) { - double ans1 = 0.0, ans2 = 1e-50; - for (int i = 0; i < numberOfComponents; i++) { - if (componentArray[i].getIonicCharge() == 0) { - ans1 += componentArray[i].getNumberOfMolesInPhase() - * componentArray[i].getDiElectricConstantdTdT(temperature); - ans2 += componentArray[i].getNumberOfMolesInPhase(); - } - } - return ans1 / ans2; - } - - /** - *

- * calcEps. - *

- * - * @return a double - */ - public double calcEps() { - double eps = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - eps += avagadroNumber * pi / 6.0 * componentArray[i].getNumberOfMolesInPhase() - * Math.pow(componentArray[i].getLennardJonesMolecularDiameter() * 1e-10, 3.0) - * 1.0 / (numberOfMolesInPhase * getMolarVolume() * 1e-5); - } - return eps; - } - - /** - *

- * calcEpsV. - *

- * - * @return a double - */ - public double calcEpsV() { - return -getEps() / (getMolarVolume() * 1e-5 * numberOfMolesInPhase); - } - - /** - *

- * calcEpsVV. - *

- * - * @return a double - */ - public double calcEpsVV() { - return 2.0 * getEps() / Math.pow(getMolarVolume() * 1e-5 * numberOfMolesInPhase, 2.0); - } - - /** - *

- * calcEpsIonic. - *

- * - * @return a double - */ - public double calcEpsIonic() { - double epsIonicLoc = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - if (componentArray[i].getIonicCharge() != 0) { - epsIonicLoc += - avagadroNumber * pi / 6.0 * componentArray[i].getNumberOfMolesInPhase() - * Math.pow(componentArray[i].getLennardJonesMolecularDiameter() - * 1e-10, 3.0) - / (numberOfMolesInPhase * getMolarVolume() * 1e-5); - } - } - return epsIonicLoc; - } - - /** - *

- * calcEpsIonicdV. - *

- * - * @return a double - */ - public double calcEpsIonicdV() { - return -getEpsIonic() / (getMolarVolume() * 1e-5 * numberOfMolesInPhase); - } - - /** - *

- * calcEpsIonicdVdV. - *

- * - * @return a double - */ - public double calcEpsIonicdVdV() { - return 2.0 * getEpsIonic() / Math.pow(getMolarVolume() * 1e-5 * numberOfMolesInPhase, 2.0); - } - - /** {@inheritDoc} */ - @Override - public double getF() { - return super.getF() + FSR2() * sr2On + FLR() * lrOn + FBorn() * bornOn; - } - - /** {@inheritDoc} */ - @Override - public double dFdT() { - return super.dFdT() + dFSR2dT() * sr2On + dFLRdT() * lrOn + dFBorndT() * bornOn; - } - - /** {@inheritDoc} */ - @Override - public double dFdTdV() { - return super.dFdTdV() + dFSR2dTdV() * sr2On + dFLRdTdV() * lrOn; - } - - /** {@inheritDoc} */ - @Override - public double dFdV() { - return super.dFdV() + dFSR2dV() * sr2On + dFLRdV() * lrOn; - } - - /** {@inheritDoc} */ - @Override - public double dFdVdV() { - return super.dFdVdV() + dFSR2dVdV() * sr2On + dFLRdVdV() * lrOn; - } - - /** {@inheritDoc} */ - @Override - public double dFdVdVdV() { - return super.dFdVdVdV() + dFSR2dVdVdV() * sr2On + dFLRdVdVdV() * lrOn; - } - - /** {@inheritDoc} */ - @Override - public double dFdTdT() { - return super.dFdTdT() + dFSR2dTdT() * sr2On + dFLRdTdT() * lrOn + dFBorndTdT() * bornOn; - } - - /** - *

- * calcXLR. - *

- * - * @return a double - */ - public double calcXLR() { - double ans = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - if (componentArray[i].getIonicCharge() != 0) { - ans += componentArray[i].getNumberOfMolesInPhase() - * Math.pow(componentArray[i].getIonicCharge(), 2.0) - * getShieldingParameter() / (1.0 + getShieldingParameter() - * componentArray[i].getLennardJonesMolecularDiameter() * 1e-10); - } - } - return ans; - } - - /** - *

- * calcGammaLRdV. - *

- * - * @return a double - */ - public double calcGammaLRdV() { - if (phaseType == 1) { - return 0.0; - } - // return 0.0; // problem ved ren komponent - return 1.0 / (8.0 * getShieldingParameter()) - * (4.0 * Math.pow(getShieldingParameter(), 2.0) / getAlphaLR2() * alphaLRdV - + 4.0 * Math.pow(getShieldingParameter(), 2.0) - / (numberOfMolesInPhase * getMolarVolume() * 1e-5)); - // // Math.pow(getIonicCharge()/(1.0+((PhaseModifiedFurstElectrolyteEos) - // phase).getShieldingParameter()*getLennardJonesMolecularDiameter()*1e-10),2.0) - // + alphai*temp) /(8.0*((PhaseModifiedFurstElectrolyteEos) - // phase).getShieldingParameter()); - } - - /** - *

- * calcShieldingParameter. - *

- * - * @return a double - */ - public double calcShieldingParameter() { - // if(phaseType==1) return 0.0; - double df = 0, f = 0; - int ions = 0; - int iterations = 0; - gamma = 1e10; - do { - iterations++; - gammaold = gamma; - ions = 0; - f = 4.0 * Math.pow(gamma, 2) / avagadroNumber; - df = 8.0 * gamma / avagadroNumber; - for (int i = 0; i < numberOfComponents; i++) { - if (componentArray[i].getIonicCharge() != 0) { - ions++; - f += -getAlphaLR2() * componentArray[i].getNumberOfMolesInPhase() - / (getMolarVolume() * numberOfMolesInPhase * 1e-5) - * Math.pow(componentArray[i].getIonicCharge() / (1.0 + gamma - * componentArray[i].getLennardJonesMolecularDiameter() * 1e-10), - 2.0); - df += 2.0 * getAlphaLR2() * componentArray[i].getNumberOfMolesInPhase() - / (getMolarVolume() * numberOfMolesInPhase * 1e-5) - * Math.pow(componentArray[i].getIonicCharge(), 2.0) - * (componentArray[i].getLennardJonesMolecularDiameter() * 1e-10) - / (Math.pow(1.0 + gamma - * componentArray[i].getLennardJonesMolecularDiameter() * 1e-10, - 3.0)); - } - } - gamma = ions > 0 ? gammaold - 0.8 * f / df : 0; - } while ((Math.abs(f) > 1e-10 && iterations < 1000) || iterations < 3); - // gamma = 1e9; - // System.out.println("gamma " +gamma + " iterations " + iterations); - return gamma; - } - - // public double calcShieldingParameter2(){ + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(PhaseModifiedFurstElectrolyteEos.class); + + double gammaold = 0; + double alphaLRdTdV = 0; + double W = 0; + double WT = 0; + double WTT = 0; + double eps = 0; + double epsdV = 0; + double epsdVdV = 0; + double epsIonic = 0; + double bornX = 0; + double epsIonicdV = 0; + double epsIonicdVdV = 0; + double alphaLR2 = 0; + double alphaLRdT = 0.0; + double alphaLRdTdT = 0.0; + double alphaLRdV = 0.0; + double XLR = 0; + double solventDiElectricConstant = 0; + double solventDiElectricConstantdT = 0.0; + double solventDiElectricConstantdTdT = 0; + double shieldingParameter = 0; + double gamma = 0; + double diElectricConstantdV = 0; + double diElectricConstantdVdV = 0; + double alphaLRdVdV = 0; + double diElectricConstantdT = 0; + double diElectricConstantdTdT = 0.0; + double diElectricConstantdTdV = 0; + neqsim.thermo.mixingRule.ElectrolyteMixingRulesInterface electrolyteMixingRule; + double sr2On = 1.0; + double lrOn = 1.0; + double bornOn = 1.0; + // double gammLRdV=0.0; + // PhaseInterface[] refPhase;// = new PhaseInterface[10]; + + /** + *

+ * Constructor for PhaseModifiedFurstElectrolyteEos. + *

+ */ + public PhaseModifiedFurstElectrolyteEos() { + super(); + electrolyteMixingRule = mixSelect.getElectrolyteMixingRule(this); + } + + /** + *

+ * Getter for the field electrolyteMixingRule. + *

+ * + * @return a {@link neqsim.thermo.mixingRule.ElectrolyteMixingRulesInterface} object + */ + public neqsim.thermo.mixingRule.ElectrolyteMixingRulesInterface getElectrolyteMixingRule() { + return electrolyteMixingRule; + } + + /** + *

+ * reInitFurstParam. + *

+ */ + public void reInitFurstParam() { + for (int k = 0; k < numberOfComponents; k++) { + ((ComponentModifiedFurstElectrolyteEos) componentArray[k]).initFurstParam(); + } + electrolyteMixingRule = mixSelect.getElectrolyteMixingRule(this); + } + + /** {@inheritDoc} */ + @Override + public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, + double beta) { + super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + if (type == 0) { + electrolyteMixingRule = mixSelect.getElectrolyteMixingRule(this); + } + } + + /** {@inheritDoc} */ + @Override + public PhaseModifiedFurstElectrolyteEos clone() { + PhaseModifiedFurstElectrolyteEos clonedPhase = null; + try { + clonedPhase = (PhaseModifiedFurstElectrolyteEos) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); + } + // clonedPhase.electrolyteMixingRule = + // (thermo.mixingRule.ElectrolyteMixingRulesInterface) + // electrolyteMixingRule.clone(); + + return clonedPhase; + } + + /** + *

+ * volInit. + *

+ */ + public void volInit() { + W = electrolyteMixingRule.calcW(this, temperature, pressure, numberOfComponents); + WT = electrolyteMixingRule.calcWT(this, temperature, pressure, numberOfComponents); + WTT = electrolyteMixingRule.calcWTT(this, temperature, pressure, numberOfComponents); + eps = calcEps(); + epsdV = calcEpsV(); + epsdVdV = calcEpsVV(); + epsIonic = calcEpsIonic(); + epsIonicdV = calcEpsIonicdV(); + epsIonicdVdV = calcEpsIonicdVdV(); + solventDiElectricConstant = calcSolventDiElectricConstant(temperature); + solventDiElectricConstantdT = calcSolventDiElectricConstantdT(temperature); + solventDiElectricConstantdTdT = calcSolventDiElectricConstantdTdT(temperature); + diElectricConstant = calcDiElectricConstant(temperature); + diElectricConstantdT = calcDiElectricConstantdT(temperature); + diElectricConstantdTdT = calcDiElectricConstantdTdT(temperature); + diElectricConstantdV = calcDiElectricConstantdV(temperature); + diElectricConstantdVdV = calcDiElectricConstantdVdV(temperature); + diElectricConstantdTdV = calcDiElectricConstantdTdV(temperature); + alphaLR2 = electronCharge * electronCharge * avagadroNumber + / (vacumPermittivity * diElectricConstant * R * temperature); + alphaLRdT = -electronCharge * electronCharge * avagadroNumber + / (vacumPermittivity * diElectricConstant * R * temperature * temperature) + - electronCharge * electronCharge * avagadroNumber + / (vacumPermittivity * diElectricConstant * diElectricConstant * R * temperature) + * diElectricConstantdT; + alphaLRdV = -electronCharge * electronCharge * avagadroNumber + / (vacumPermittivity * diElectricConstant * diElectricConstant * R * temperature) + * diElectricConstantdV; + alphaLRdTdT = 2.0 * electronCharge * electronCharge * avagadroNumber + / (vacumPermittivity * diElectricConstant * R * Math.pow(temperature, 3.0)) + + electronCharge * electronCharge * avagadroNumber + / (vacumPermittivity * diElectricConstant * diElectricConstant * R * temperature + * temperature) + * diElectricConstantdT + - electronCharge * electronCharge * avagadroNumber + / (vacumPermittivity * diElectricConstant * diElectricConstant * R * temperature) + * diElectricConstantdTdT + + electronCharge * electronCharge * avagadroNumber + / (vacumPermittivity * diElectricConstant * diElectricConstant * R * temperature + * temperature) + * diElectricConstantdT + + 2.0 * electronCharge * electronCharge * avagadroNumber + / (vacumPermittivity * Math.pow(diElectricConstant, 3.0) * R * temperature) + * Math.pow(diElectricConstantdT, 2.0); + alphaLRdTdV = electronCharge * electronCharge * avagadroNumber + / (vacumPermittivity * diElectricConstant * diElectricConstant * R * temperature + * temperature) + * diElectricConstantdV + + 2.0 * electronCharge * electronCharge * avagadroNumber + / (vacumPermittivity * diElectricConstant * diElectricConstant * diElectricConstant * R + * temperature) + * diElectricConstantdT * diElectricConstantdV + - electronCharge * electronCharge * avagadroNumber + / (vacumPermittivity * diElectricConstant * diElectricConstant * R * temperature) + * diElectricConstantdTdV; + alphaLRdVdV = -electronCharge * electronCharge * avagadroNumber + / (vacumPermittivity * diElectricConstant * diElectricConstant * R * temperature) + * diElectricConstantdVdV + + 2.0 * electronCharge * electronCharge * avagadroNumber + / (vacumPermittivity * Math.pow(diElectricConstant, 3.0) * R * temperature) + * diElectricConstantdV * diElectricConstantdV; + shieldingParameter = calcShieldingParameter(); + // gammLRdV = calcGammaLRdV(); + XLR = calcXLR(); + bornX = calcBornX(); + } + + /** {@inheritDoc} */ + @Override + public void addcomponent(String componentName, double moles, double molesInPhase, + int compNumber) { + super.addcomponent(molesInPhase); + componentArray[compNumber] = new neqsim.thermo.component.ComponentModifiedFurstElectrolyteEos( + componentName, moles, molesInPhase, compNumber); + } + + /** + *

+ * calcSolventDiElectricConstant. + *

+ * + * @param temperature a double + * @return a double + */ + public double calcSolventDiElectricConstant(double temperature) { + double ans1 = 0.0; + double ans2 = 1e-50; + for (int i = 0; i < numberOfComponents; i++) { + if (componentArray[i].getIonicCharge() == 0) { + ans1 += componentArray[i].getNumberOfMolesInPhase() + * componentArray[i].getDiElectricConstant(temperature); + ans2 += componentArray[i].getNumberOfMolesInPhase(); + } + } + return ans1 / ans2; + } + + /** + *

+ * calcSolventDiElectricConstantdT. + *

+ * + * @param temperature a double + * @return a double + */ + public double calcSolventDiElectricConstantdT(double temperature) { + double ans1 = 0.0; + double ans2 = 1e-50; + for (int i = 0; i < numberOfComponents; i++) { + if (componentArray[i].getIonicCharge() == 0) { + ans1 += componentArray[i].getNumberOfMolesInPhase() + * componentArray[i].getDiElectricConstantdT(temperature); + ans2 += componentArray[i].getNumberOfMolesInPhase(); + } + } + return ans1 / ans2; + } + + /** + *

+ * calcSolventDiElectricConstantdTdT. + *

+ * + * @param temperature a double + * @return a double + */ + public double calcSolventDiElectricConstantdTdT(double temperature) { + double ans1 = 0.0; + double ans2 = 1e-50; + for (int i = 0; i < numberOfComponents; i++) { + if (componentArray[i].getIonicCharge() == 0) { + ans1 += componentArray[i].getNumberOfMolesInPhase() + * componentArray[i].getDiElectricConstantdTdT(temperature); + ans2 += componentArray[i].getNumberOfMolesInPhase(); + } + } + return ans1 / ans2; + } + + /** + *

+ * calcEps. + *

+ * + * @return a double + */ + public double calcEps() { + double eps = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + eps += avagadroNumber * pi / 6.0 * componentArray[i].getNumberOfMolesInPhase() + * Math.pow(componentArray[i].getLennardJonesMolecularDiameter() * 1e-10, 3.0) * 1.0 + / (numberOfMolesInPhase * getMolarVolume() * 1e-5); + } + return eps; + } + + /** + *

+ * calcEpsV. + *

+ * + * @return a double + */ + public double calcEpsV() { + return -getEps() / (getMolarVolume() * 1e-5 * numberOfMolesInPhase); + } + + /** + *

+ * calcEpsVV. + *

+ * + * @return a double + */ + public double calcEpsVV() { + return 2.0 * getEps() / Math.pow(getMolarVolume() * 1e-5 * numberOfMolesInPhase, 2.0); + } + + /** + *

+ * calcEpsIonic. + *

+ * + * @return a double + */ + public double calcEpsIonic() { + double epsIonicLoc = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + if (componentArray[i].getIonicCharge() != 0) { + epsIonicLoc += avagadroNumber * pi / 6.0 * componentArray[i].getNumberOfMolesInPhase() + * Math.pow(componentArray[i].getLennardJonesMolecularDiameter() * 1e-10, 3.0) + / (numberOfMolesInPhase * getMolarVolume() * 1e-5); + } + } + return epsIonicLoc; + } + + /** + *

+ * calcEpsIonicdV. + *

+ * + * @return a double + */ + public double calcEpsIonicdV() { + return -getEpsIonic() / (getMolarVolume() * 1e-5 * numberOfMolesInPhase); + } + + /** + *

+ * calcEpsIonicdVdV. + *

+ * + * @return a double + */ + public double calcEpsIonicdVdV() { + return 2.0 * getEpsIonic() / Math.pow(getMolarVolume() * 1e-5 * numberOfMolesInPhase, 2.0); + } + + /** {@inheritDoc} */ + @Override + public double getF() { + return super.getF() + FSR2() * sr2On + FLR() * lrOn + FBorn() * bornOn; + } + + /** {@inheritDoc} */ + @Override + public double dFdT() { + return super.dFdT() + dFSR2dT() * sr2On + dFLRdT() * lrOn + dFBorndT() * bornOn; + } + + /** {@inheritDoc} */ + @Override + public double dFdTdV() { + return super.dFdTdV() + dFSR2dTdV() * sr2On + dFLRdTdV() * lrOn; + } + + /** {@inheritDoc} */ + @Override + public double dFdV() { + return super.dFdV() + dFSR2dV() * sr2On + dFLRdV() * lrOn; + } + + /** {@inheritDoc} */ + @Override + public double dFdVdV() { + return super.dFdVdV() + dFSR2dVdV() * sr2On + dFLRdVdV() * lrOn; + } + + /** {@inheritDoc} */ + @Override + public double dFdVdVdV() { + return super.dFdVdVdV() + dFSR2dVdVdV() * sr2On + dFLRdVdVdV() * lrOn; + } + + /** {@inheritDoc} */ + @Override + public double dFdTdT() { + return super.dFdTdT() + dFSR2dTdT() * sr2On + dFLRdTdT() * lrOn + dFBorndTdT() * bornOn; + } + + /** + *

+ * calcXLR. + *

+ * + * @return a double + */ + public double calcXLR() { + double ans = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + if (componentArray[i].getIonicCharge() != 0) { + ans += componentArray[i].getNumberOfMolesInPhase() + * Math.pow(componentArray[i].getIonicCharge(), 2.0) * getShieldingParameter() + / (1.0 + getShieldingParameter() * componentArray[i].getLennardJonesMolecularDiameter() + * 1e-10); + } + } + return ans; + } + + /** + *

+ * calcGammaLRdV. + *

+ * + * @return a double + */ + public double calcGammaLRdV() { + if (phaseType == 1) { + return 0.0; + } + // return 0.0; // problem ved ren komponent + return 1.0 / (8.0 * getShieldingParameter()) + * (4.0 * Math.pow(getShieldingParameter(), 2.0) / getAlphaLR2() * alphaLRdV + + 4.0 * Math.pow(getShieldingParameter(), 2.0) + / (numberOfMolesInPhase * getMolarVolume() * 1e-5)); + // // Math.pow(getIonicCharge()/(1.0+((PhaseModifiedFurstElectrolyteEos) + // phase).getShieldingParameter()*getLennardJonesMolecularDiameter()*1e-10),2.0) + // + alphai*temp) /(8.0*((PhaseModifiedFurstElectrolyteEos) + // phase).getShieldingParameter()); + } + + /** + *

+ * calcShieldingParameter. + *

+ * + * @return a double + */ + public double calcShieldingParameter() { // if(phaseType==1) return 0.0; - - // double df=0, f=0; - // int ions=0; - // int iterations=0; - // gamma=1e10; - // do{ - // iterations++; - // gammaold = gamma; - // ions=0; - // f = 4.0*Math.pow(gamma,2)/avagadroNumber; - // df = 8.0*gamma/avagadroNumber; - // for(int i=0;i0 ? gammaold - 0.8*f/df : 0; - // } - // while((Math.abs(f)>1e-10 && iterations<1000) || iterations<5); - // //System.out.println("gama " + gamma*1e-10); - // return gamma; - // } - - /** {@inheritDoc} */ - @Override - public double molarVolume(double pressure, double temperature, double A, double B, int phase) - throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - // double BonV = phase== 0 ? - // 2.0/(2.0+temperature/getPseudoCriticalTemperature()):0.1*pressure*getB()/(numberOfMolesInPhase*temperature*R); - double BonV = phase == 0 ? 0.99 : 1e-5; - - if (BonV < 0) { - BonV = 1.0e-6; - } - if (BonV > 1.0) { - BonV = 1.0 - 1.0e-6; + double df = 0; + double f = 0; + int ions = 0; + int iterations = 0; + gamma = 1e10; + do { + iterations++; + gammaold = gamma; + ions = 0; + f = 4.0 * Math.pow(gamma, 2) / avagadroNumber; + df = 8.0 * gamma / avagadroNumber; + for (int i = 0; i < numberOfComponents; i++) { + if (componentArray[i].getIonicCharge() != 0) { + ions++; + f += -getAlphaLR2() * componentArray[i].getNumberOfMolesInPhase() + / (getMolarVolume() * numberOfMolesInPhase * 1e-5) + * Math.pow(componentArray[i].getIonicCharge() + / (1.0 + gamma * componentArray[i].getLennardJonesMolecularDiameter() * 1e-10), + 2.0); + df += 2.0 * getAlphaLR2() * componentArray[i].getNumberOfMolesInPhase() + / (getMolarVolume() * numberOfMolesInPhase * 1e-5) + * Math.pow(componentArray[i].getIonicCharge(), 2.0) + * (componentArray[i].getLennardJonesMolecularDiameter() * 1e-10) / (Math.pow( + 1.0 + gamma * componentArray[i].getLennardJonesMolecularDiameter() * 1e-10, 3.0)); } - double BonVold = BonV; - double Btemp = 0, h = 0, dh = 0, dhh = 0; - double d1 = 0, d2 = 0; - Btemp = getB(); - if (Btemp <= 0) { - logger.info("b negative in volume calc"); + } + gamma = ions > 0 ? gammaold - 0.8 * f / df : 0; + } while ((Math.abs(f) > 1e-10 && iterations < 1000) || iterations < 3); + // gamma = 1e9; + // System.out.println("gamma " +gamma + " iterations " + iterations); + return gamma; + } + + // public double calcShieldingParameter2(){ + // if(phaseType==1) return 0.0; + + // double df=0, f=0; + // int ions=0; + // int iterations=0; + // gamma=1e10; + // do{ + // iterations++; + // gammaold = gamma; + // ions=0; + // f = 4.0*Math.pow(gamma,2)/avagadroNumber; + // df = 8.0*gamma/avagadroNumber; + // for(int i=0;i0 ? gammaold - 0.8*f/df : 0; + // } + // while((Math.abs(f)>1e-10 && iterations<1000) || iterations<5); + // //System.out.println("gama " + gamma*1e-10); + // return gamma; + // } + + /** {@inheritDoc} */ + @Override + public double molarVolume(double pressure, double temperature, double A, double B, int phase) + throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + // double BonV = phase== 0 ? + // 2.0/(2.0+temperature/getPseudoCriticalTemperature()):0.1*pressure*getB()/(numberOfMolesInPhase*temperature*R); + double BonV = phase == 0 ? 0.99 : 1e-5; + + if (BonV < 0) { + BonV = 1.0e-6; + } + if (BonV > 1.0) { + BonV = 1.0 - 1.0e-6; + } + double BonVold = BonV; + double Btemp = 0; + double h = 0; + double dh = 0; + double dhh = 0; + double d1 = 0; + double d2 = 0; + Btemp = getB(); + if (Btemp <= 0) { + logger.info("b negative in volume calc"); + } + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + int iterations = 0; + int maxIterations = 1000; + do { + iterations++; + this.volInit(); + BonVold = BonV; + h = BonV - Btemp / numberOfMolesInPhase * dFdV() + - pressure * Btemp / (numberOfMolesInPhase * R * temperature); + dh = 1.0 + Btemp / Math.pow(BonV, 2.0) * (Btemp / numberOfMolesInPhase * dFdVdV()); + dhh = -2.0 * Btemp / Math.pow(BonV, 3.0) * (Btemp / numberOfMolesInPhase * dFdVdV()) + - Math.pow(Btemp, 2.0) / Math.pow(BonV, 4.0) + * (Btemp / numberOfMolesInPhase * dFdVdVdV()); + + d1 = -h / dh; + d2 = -dh / dhh; + + if (Math.abs(d1 / d2) <= 1.0) { + BonV += d1 * (1.0 + 0.5 * d1 / d2); + } else if (d1 / d2 < -1) { + BonV += d1 * (1.0 + 0.5 * -1.0); + } else if (d1 / d2 > 1) { + BonV += d2; + double hnew = h + d2 * -h / d1; + if (Math.abs(hnew) > Math.abs(h)) { + logger.info("volume correction needed...."); + BonV = phase == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); } - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - int iterations = 0; - int maxIterations = 1000; - do { - iterations++; - this.volInit(); - BonVold = BonV; - h = BonV - Btemp / numberOfMolesInPhase * dFdV() - - pressure * Btemp / (numberOfMolesInPhase * R * temperature); - dh = 1.0 + Btemp / Math.pow(BonV, 2.0) * (Btemp / numberOfMolesInPhase * dFdVdV()); - dhh = -2.0 * Btemp / Math.pow(BonV, 3.0) * (Btemp / numberOfMolesInPhase * dFdVdV()) - - Math.pow(Btemp, 2.0) / Math.pow(BonV, 4.0) - * (Btemp / numberOfMolesInPhase * dFdVdVdV()); - - d1 = -h / dh; - d2 = -dh / dhh; - - if (Math.abs(d1 / d2) <= 1.0) { - BonV += d1 * (1.0 + 0.5 * d1 / d2); - } else if (d1 / d2 < -1) { - BonV += d1 * (1.0 + 0.5 * -1.0); - } else if (d1 / d2 > 1) { - BonV += d2; - double hnew = h + d2 * -h / d1; - if (Math.abs(hnew) > Math.abs(h)) { - logger.info("volume correction needed...."); - BonV = phase == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } - - if (BonV > 1) { - BonV = 1.0 - 1.0e-6; - BonVold = 10; - } - if (BonV < 0) { - BonV = 1.0e-6; - BonVold = 10; - } - - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - } while (Math.abs((BonV - BonVold) / BonV) > 1.0e-10 && iterations < maxIterations); - this.volInit(); - if (iterations >= maxIterations) { - throw new neqsim.util.exception.TooManyIterationsException(this, "molarVolume", - maxIterations); - } - if (Double.isNaN(getMolarVolume())) { - throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); - } - - // if(phaseType==0) System.out.println("density " + getDensity());//"BonV: " + - // BonV + " "+" itert: " + iterations +" " + " phase " + phaseType+ " " + h + " - // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" - // + fVV()); - - return getMolarVolume(); - } - - /** - *

- * calcW. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param temperature a double - * @param pressure a double - * @param numbcomp a int - * @return a double - */ - public double calcW(PhaseInterface phase, double temperature, double pressure, int numbcomp) { - W = electrolyteMixingRule.calcW(phase, temperature, pressure, numbcomp); - return W; - } - - /** - *

- * calcWi. - *

- * - * @param compNumb a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param temperature a double - * @param pressure a double - * @param numbcomp a int - * @return a double - */ - public double calcWi(int compNumb, PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - return electrolyteMixingRule.calcWi(compNumb, phase, temperature, pressure, numbcomp); - } - - /** - *

- * calcWiT. - *

- * - * @param compNumb a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param temperature a double - * @param pressure a double - * @param numbcomp a int - * @return a double - */ - public double calcWiT(int compNumb, PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - return electrolyteMixingRule.calcWiT(compNumb, phase, temperature, pressure, numbcomp); - } - - /** - *

- * calcWij. - *

- * - * @param compNumb a int - * @param compNumbj a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param temperature a double - * @param pressure a double - * @param numbcomp a int - * @return a double - */ - public double calcWij(int compNumb, int compNumbj, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - return electrolyteMixingRule.calcWij(compNumb, compNumbj, phase, temperature, pressure, - numbcomp); - } - - /** {@inheritDoc} */ - @Override - public double calcDiElectricConstant(double temperature) { - return 1.0 + (getSolventDiElectricConstant() - 1.0) * (1.0 - getEpsIonic()) - / (1.0 + getEpsIonic() / 2.0); - } - - /** - *

- * calcDiElectricConstantdV. - *

- * - * @param temperature a double - * @return a double - */ - public double calcDiElectricConstantdV(double temperature) { - double X = (1.0 - getEpsIonic()) / (1.0 + getEpsIonic() / 2.0); - // double Y= getSolventDiElectricConstant(); 10-2002 - double Y = getSolventDiElectricConstant() - 1.0; - double dXdf = getEpsIonicdV() * -3.0 / 2.0 / Math.pow(getEpsIonic() / 2.0 + 1.0, 2.0); - double dYdf = 0; - return dYdf * X + Y * dXdf; - } - - /** - *

- * calcDiElectricConstantdVdV. - *

- * - * @param temperature a double - * @return a double - */ - public double calcDiElectricConstantdVdV(double temperature) { - double Y = getSolventDiElectricConstant() - 1.0; - double dXdf = getEpsIonicdVdV() * -3.0 / 2.0 / Math.pow(getEpsIonic() / 2.0 + 1.0, 2.0) - + getEpsIonicdV() * getEpsIonicdV() * 3.0 / 2.0 - / Math.pow(getEpsIonic() / 2.0 + 1.0, 3.0); - return Y * dXdf;// + Y*dXdf; - } - - /** {@inheritDoc} */ - @Override - public double calcDiElectricConstantdT(double temperature) { - double X = (1.0 - getEpsIonic()) / (1.0 + getEpsIonic() / 2.0); - double Y = getSolventDiElectricConstant() - 1.0; - double dXdf = 0; - double dYdf = getSolventDiElectricConstantdT(); - return dYdf * X + Y * dXdf; - } - - /** {@inheritDoc} */ - @Override - public double calcDiElectricConstantdTdT(double temperature) { - return getSolventDiElectricConstantdTdT() * (1.0 - epsIonic) / (1.0 + epsIonic / 2.0); - } - - /** - *

- * calcDiElectricConstantdTdV. - *

- * - * @param temperature a double - * @return a double - */ - public double calcDiElectricConstantdTdV(double temperature) { - double Y = getSolventDiElectricConstantdT(); - double dXdf = getEpsIonicdV() * -3.0 / 2.0 / Math.pow(getEpsIonic() / 2.0 + 1.0, 2.0); - return Y * dXdf; - } - - /** - *

- * calcBornX. - *

- * - * @return a double - */ - public double calcBornX() { - double ans = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - if (componentArray[i].getLennardJonesMolecularDiameter() > 0) { - ans += componentArray[i].getNumberOfMolesInPhase() - * Math.pow(componentArray[i].getIonicCharge(), 2.0) - / (componentArray[i].getLennardJonesMolecularDiameter() * 1e-10); - } - } - return ans; - } - - // Long Range term equations and derivatives - - /** - *

- * FLR. - *

- * - * @return a double - */ - public double FLR() { - double ans = 0.0; - ans -= (1.0 / (4.0 * pi) * getAlphaLR2() * getXLR()); - return ans + (numberOfMolesInPhase * getMolarVolume() * 1e-5 - * Math.pow(getShieldingParameter(), 3.0)) / (3.0 * pi * avagadroNumber); - } - - /** - *

- * dFLRdT. - *

- * - * @return a double - */ - public double dFLRdT() { - return dFdAlphaLR() * alphaLRdT; - } - - /** - *

- * dFLRdTdV. - *

- * - * @return a double - */ - public double dFLRdTdV() { - return (dFdAlphaLR() * alphaLRdTdV) * 1e-5; - } - - /** - *

- * dFLRdTdT. - *

- * - * @return a double - */ - public double dFLRdTdT() { - return dFdAlphaLR() * alphaLRdTdT; - } - - /** - *

- * dFLRdV. - *

- * - * @return a double - */ - public double dFLRdV() { - return (FLRV() + dFdAlphaLR() * alphaLRdV) * 1e-5;// + FLRGammaLR()*gammLRdV + - // 0*FLRXLR()*XLRdGammaLR()*gammLRdV)*1e-5; - } - - /** - *

- * dFLRdVdV. - *

- * - * @return a double - */ - public double dFLRdVdV() { - return (dFdAlphaLR() * alphaLRdVdV) * 1e-10; - } - - /** - *

- * dFLRdVdVdV. - *

- * - * @return a double - */ - public double dFLRdVdVdV() { - return 0.0; - } - - // first order derivatives - - /** - *

- * FLRXLR. - *

- * - * @return a double - */ - public double FLRXLR() { - return -getAlphaLR2() / (4.0 * pi); - } - - /** - *

- * FLRGammaLR. - *

- * - * @return a double - */ - public double FLRGammaLR() { - return 3.0 * numberOfMolesInPhase * getMolarVolume() * 1e-5 - * Math.pow(getShieldingParameter(), 2.0) / (3.0 * pi * avagadroNumber); - } - - /** - *

- * dFdAlphaLR. - *

- * - * @return a double - */ - public double dFdAlphaLR() { - return -1.0 / (4.0 * pi) * XLR; - } - - /** - *

- * dFdAlphaLRdV. - *

- * - * @return a double - */ - public double dFdAlphaLRdV() { - return 0.0; - } - - /** - *

- * dFdAlphaLRdX. - *

- * - * @return a double - */ - public double dFdAlphaLRdX() { - return -1.0 / (4.0 * pi); - } - - /** - *

- * dFdAlphaLRdGamma. - *

- * - * @return a double - */ - public double dFdAlphaLRdGamma() { - return 0; - } - - /** - *

- * FLRV. - *

- * - * @return a double - */ - public double FLRV() { - return Math.pow(getShieldingParameter(), 3.0) / (3.0 * pi * avagadroNumber); - } - - /** - *

- * FLRVV. - *

- * - * @return a double - */ - public double FLRVV() { - return 0.0; - } - - // second order derivatives - - /** - *

- * dFdAlphaLRdAlphaLR. - *

- * - * @return a double - */ - public double dFdAlphaLRdAlphaLR() { - return 0.0; - } - - /** - *

- * XLRdndn. - *

- * - * @param i a int - * @param j a int - * @return a double - */ - public double XLRdndn(int i, int j) { - return 0.0; - } - - /** - *

- * XLRdGammaLR. - *

- * - * @return a double - */ - public double XLRdGammaLR() { - // if(phaseType==1) return 0.0; - double ans = 0.0; - double ans2 = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - ans -= componentArray[i].getLennardJonesMolecularDiameter() * 1e-10 - * componentArray[i].getNumberOfMolesInPhase() - * Math.pow(componentArray[i].getIonicCharge(), 2.0) * getShieldingParameter() - / Math.pow( - 1.0 + getShieldingParameter() - * componentArray[i].getLennardJonesMolecularDiameter() * 1e-10, - 2.0); - ans2 += componentArray[i].getNumberOfMolesInPhase() - * Math.pow(componentArray[i].getIonicCharge(), 2.0) - / (1.0 + getShieldingParameter() - * componentArray[i].getLennardJonesMolecularDiameter() * 1e-10); - } - return ans2 + ans; - } - - /** - *

- * XBorndndn. - *

- * - * @param i a int - * @param j a int - * @return a double - */ - public double XBorndndn(int i, int j) { - return 0.0; - } - - // Short Range term equations and derivatives - /** - *

- * FSR2. - *

- * - * @return a double - */ - public double FSR2() { - return getW() / (getMolarVolume() * 1e-5 * numberOfMolesInPhase * (1.0 - eps)); - } - - /** - *

- * dFSR2dT. - *

- * - * @return a double - */ - public double dFSR2dT() { - return FSR2W() * WT; - } - - /** - *

- * dFSR2dTdT. - *

- * - * @return a double - */ - public double dFSR2dTdT() { - return FSR2W() * WTT; - } - - /** - *

- * dFSR2dV. - *

- * - * @return a double - */ - public double dFSR2dV() { - return (FSR2V() + FSR2eps() * getEpsdV()) * 1e-5; - } - - /** - *

- * dFSR2dTdV. - *

- * - * @return a double - */ - public double dFSR2dTdV() { - return (FSR2VW() * WT + FSR2epsW() * epsdV * WT) * 1e-5; - } - - /** - *

- * dFSR2dVdV. - *

- * - * @return a double - */ - public double dFSR2dVdV() { - return (FSR2VV() + 2.0 * FSR2epsV() * getEpsdV() + FSR2epseps() * Math.pow(getEpsdV(), 2.0) - + FSR2eps() * getEpsdVdV()) * 1e-10; - } - - /** - *

- * dFSR2dVdVdV. - *

- * - * @return a double - */ - public double dFSR2dVdVdV() { - return (FSR2VVV() + 3 * FSR2epsepsV() * Math.pow(getEpsdV(), 2.0) - + 3 * FSR2VVeps() * getEpsdV() + FSR2epsepseps() * Math.pow(getEpsdV(), 3.0)) - * 1e-15; - } - - // first order derivatives - /** - *

- * FSR2W. - *

- * - * @return a double - */ - public double FSR2W() { - return 1.0 / (getMolarVolume() * 1e-5 * numberOfMolesInPhase * (1.0 - eps)); - } - - /** - *

- * FSR2V. - *

- * - * @return a double - */ - public double FSR2V() { - return -W / (Math.pow(getMolarVolume() * 1e-5 * numberOfMolesInPhase, 2.0) * (1.0 - eps)); - } - - /** - *

- * FSR2T. - *

- * - * @return a double - */ - public double FSR2T() { - return 0.0; - } - - /** - *

- * FSR2n. - *

- * - * @return a double - */ - public double FSR2n() { - return 0; - } - - /** - *

- * FSR2eps. - *

- * - * @return a double - */ - public double FSR2eps() { - return W / ((getMolarVolume() * 1e-5 * numberOfMolesInPhase) * Math.pow(1.0 - eps, 2.0)); - } - - // second order derivatives - - /** - *

- * FSR2nn. - *

- * - * @return a double - */ - public double FSR2nn() { - return 0; - } - - /** - *

- * FSR2nT. - *

- * - * @return a double - */ - public double FSR2nT() { - return 0; - } - - /** - *

- * FSR2nV. - *

- * - * @return a double - */ - public double FSR2nV() { - return 0; - } - - /** - *

- * FSR2neps. - *

- * - * @return a double - */ - public double FSR2neps() { - return 0; - } - - /** - *

- * FSR2nW. - *

- * - * @return a double - */ - public double FSR2nW() { - return 0; - } - - /** - *

- * FSR2Tn. - *

- * - * @return a double - */ - public double FSR2Tn() { - return 0; - } - - /** - *

- * FSR2TT. - *

- * - * @return a double - */ - public double FSR2TT() { - return 0; - } - - /** - *

- * FSR2TV. - *

- * - * @return a double - */ - public double FSR2TV() { - return 0; - } - - /** - *

- * FSR2Teps. - *

- * - * @return a double - */ - public double FSR2Teps() { - return 0; - } - - /** - *

- * FSR2TW. - *

- * - * @return a double - */ - public double FSR2TW() { - return 0; - } - - /** - *

- * FSR2VV. - *

- * - * @return a double - */ - public double FSR2VV() { - return 2.0 * W - / (Math.pow(getMolarVolume() * 1e-5 * numberOfMolesInPhase, 3.0) * (1.0 - eps)); - } - - /** - *

- * FSR2epsV. - *

- * - * @return a double - */ - public double FSR2epsV() { - return -W / (Math.pow(getMolarVolume() * 1e-5 * numberOfMolesInPhase, 2.0) - * Math.pow((1.0 - eps), 2.0)); - } - - /** - *

- * FSR2epsW. - *

- * - * @return a double - */ - public double FSR2epsW() { - return 1.0 / (getMolarVolume() * 1e-5 * numberOfMolesInPhase * Math.pow(1.0 - eps, 2.0)); - } - - /** - *

- * FSR2WW. - *

- * - * @return a double - */ - public double FSR2WW() { - return 0.0; - } - - /** - *

- * FSR2VW. - *

- * - * @return a double - */ - public double FSR2VW() { - return -1.0 / (Math.pow(getMolarVolume() * 1e-5 * numberOfMolesInPhase, 2.0) * (1.0 - eps)); - } - - /** - *

- * FSR2epseps. - *

- * - * @return a double - */ - public double FSR2epseps() { - return 2.0 * W - / ((getMolarVolume() * 1e-5 * numberOfMolesInPhase) * Math.pow(1.0 - eps, 3.0)); - } - - /** - *

- * FSR2VVV. - *

- * - * @return a double - */ - public double FSR2VVV() { - return -6.0 * W - / (Math.pow(getMolarVolume() * 1e-5 * numberOfMolesInPhase, 4.0) * (1.0 - eps)); - } - - // third order derivatives - /** - *

- * FSR2epsepsV. - *

- * - * @return a double - */ - public double FSR2epsepsV() { - return -2.0 * W / (Math.pow(getMolarVolume() * 1e-5 * numberOfMolesInPhase, 2.0) - * Math.pow((1 - eps), 3.0)); - } - - /** - *

- * FSR2VVeps. - *

- * - * @return a double - */ - public double FSR2VVeps() { - return 2.0 * W / (Math.pow(getMolarVolume() * 1e-5 * numberOfMolesInPhase, 3.0) - * Math.pow((1 - eps), 2.0)); - } - - /** - *

- * FSR2epsepseps. - *

- * - * @return a double - */ - public double FSR2epsepseps() { - return 6.0 * W - / ((getMolarVolume() * 1e-5 * numberOfMolesInPhase) * Math.pow(1.0 - eps, 4.0)); - } - - // Born term equations and derivatives - /** - *

- * FBorn. - *

- * - * @return a double - */ - public double FBorn() { - return (avagadroNumber * electronCharge * electronCharge - / (4.0 * pi * vacumPermittivity * R * temperature)) - * (1.0 / getSolventDiElectricConstant() - 1.0) * bornX; - } - - /** - *

- * dFBorndT. - *

- * - * @return a double - */ - public double dFBorndT() { - return FBornT() + FBornD() * solventDiElectricConstantdT; - } - - /** - *

- * dFBorndTdT. - *

- * - * @return a double - */ - public double dFBorndTdT() { - return FBornTT() + FBornTD() * solventDiElectricConstantdT; - } - - // first order derivatives - /** - *

- * FBornT. - *

- * - * @return a double - */ - public double FBornT() { - return -(avagadroNumber * electronCharge * electronCharge - / (4.0 * pi * vacumPermittivity * R * temperature * temperature)) - * (1.0 / getSolventDiElectricConstant() - 1.0) * bornX; - } - - /** - *

- * FBornX. - *

- * - * @return a double - */ - public double FBornX() { - return (avagadroNumber * electronCharge * electronCharge - / (4.0 * pi * vacumPermittivity * R * temperature)) - * (1.0 / getSolventDiElectricConstant() - 1.0); - } - - /** - *

- * FBornD. - *

- * - * @return a double - */ - public double FBornD() { - return -(avagadroNumber * electronCharge * electronCharge - / (4.0 * pi * vacumPermittivity * R * temperature)) * 1.0 - / Math.pow(getSolventDiElectricConstant(), 2.0) * bornX; - } - - // second order derivatives - - /** - *

- * FBornTT. - *

- * - * @return a double - */ - public double FBornTT() { - return 2.0 - * (avagadroNumber * electronCharge * electronCharge - / (4.0 * pi * vacumPermittivity * R * temperature * temperature - * temperature)) - * (1.0 / getSolventDiElectricConstant() - 1.0) * bornX; - } - - /** - *

- * FBornTD. - *

- * - * @return a double - */ - public double FBornTD() { - return (avagadroNumber * electronCharge * electronCharge - / (4.0 * pi * vacumPermittivity * R * temperature * temperature)) * 1.0 - / Math.pow(getSolventDiElectricConstant(), 2.0) * bornX; - } - - /** - *

- * FBornTX. - *

- * - * @return a double - */ - public double FBornTX() { - return -(avagadroNumber * electronCharge * electronCharge - / (4.0 * pi * vacumPermittivity * R * temperature * temperature)) - * (1.0 / getSolventDiElectricConstant() - 1.0); - } - - /** - *

- * FBornDD. - *

- * - * @return a double - */ - public double FBornDD() { - return 2.0 - * (avagadroNumber * electronCharge * electronCharge - / (4.0 * pi * vacumPermittivity * R * temperature)) - * 1.0 / Math.pow(getSolventDiElectricConstant(), 3.0) * bornX; - } - - /** - *

- * FBornDX. - *

- * - * @return a double - */ - public double FBornDX() { - return -(avagadroNumber * electronCharge * electronCharge - / (4.0 * pi * vacumPermittivity * R * temperature)) * 1.0 - / Math.pow(getSolventDiElectricConstant(), 2.0); - } - - /** - *

- * FBornXX. - *

- * - * @return a double - */ - public double FBornXX() { - return 0.0; - } - - /** - *

- * Getter for the field eps. - *

- * - * @return a double - */ - public double getEps() { - return eps; - } - - /** - *

- * Getter for the field epsIonic. - *

- * - * @return a double - */ - public double getEpsIonic() { - return epsIonic; - } - - /** - *

- * Getter for the field epsIonicdV. - *

- * - * @return a double - */ - public double getEpsIonicdV() { - return epsIonicdV; - } - - /** - *

- * Getter for the field epsdV. - *

- * - * @return a double - */ - public double getEpsdV() { - return epsdV; - } - - /** - *

- * Getter for the field epsdVdV. - *

- * - * @return a double - */ - public double getEpsdVdV() { - return epsdVdV; - } - - /** - *

- * Getter for the field solventDiElectricConstant. - *

- * - * @return a double - */ - public double getSolventDiElectricConstant() { - return solventDiElectricConstant; - } - - /** - *

- * Getter for the field solventDiElectricConstantdT. - *

- * - * @return a double - */ - public double getSolventDiElectricConstantdT() { - return solventDiElectricConstantdT; - } - - /** - *

- * Getter for the field solventDiElectricConstantdTdT. - *

- * - * @return a double - */ - public double getSolventDiElectricConstantdTdT() { - return solventDiElectricConstantdTdT; - } - - /** - *

- * Getter for the field alphaLR2. - *

- * - * @return a double - */ - public double getAlphaLR2() { - return alphaLR2; - } - - /** - *

- * getW. - *

- * - * @return a double - */ - public double getW() { - return W; - } - - /** - *

- * getWT. - *

- * - * @return a double - */ - public double getWT() { - return WT; - } - - /** - *

- * Getter for the field diElectricConstantdT. - *

- * - * @return a double - */ - public double getDiElectricConstantdT() { - return diElectricConstantdT; - } - - /** - *

- * Getter for the field diElectricConstantdV. - *

- * - * @return a double - */ - public double getDiElectricConstantdV() { - return diElectricConstantdV; - } - - /** - *

- * getXLR. - *

- * - * @return a double - */ - public double getXLR() { - return XLR; - } - - /** - *

- * Getter for the field shieldingParameter. - *

- * - * @return a double - */ - public double getShieldingParameter() { - return shieldingParameter; - } - - /** - *

- * getAlphaLRT. - *

- * - * @return a double - */ - public double getAlphaLRT() { - return alphaLRdT; - } - - /** - *

- * getAlphaLRV. - *

- * - * @return a double - */ - public double getAlphaLRV() { - return alphaLRdV; - } - - /** - *

- * getDielectricT. - *

- * - * @return a double - */ - public double getDielectricT() { - return diElectricConstantdT; - } - - /** - *

- * getDielectricV. - *

- * - * @return a double - */ - public double getDielectricV() { - return diElectricConstantdV; - } - - /** - *

- * getDielectricConstant. - *

- * - * @return a double - */ - public double getDielectricConstant() { - return diElectricConstant; - } - - /** - *

- * setFurstIonicCoefficient. - *

- * - * @param params an array of {@link double} objects - */ - public void setFurstIonicCoefficient(double[] params) {} - - /** - *

- * Getter for the field epsIonicdVdV. - *

- * - * @return a double - */ - public double getEpsIonicdVdV() { - return epsIonicdVdV; - } + } + + if (BonV > 1) { + BonV = 1.0 - 1.0e-6; + BonVold = 10; + } + if (BonV < 0) { + BonV = 1.0e-6; + BonVold = 10; + } + + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); + } while (Math.abs((BonV - BonVold) / BonV) > 1.0e-10 && iterations < maxIterations); + this.volInit(); + if (iterations >= maxIterations) { + throw new neqsim.util.exception.TooManyIterationsException(this, "molarVolume", + maxIterations); + } + if (Double.isNaN(getMolarVolume())) { + throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); + } + + // if(phaseType==0) System.out.println("density " + getDensity());//"BonV: " + + // BonV + " "+" itert: " + iterations +" " + " phase " + phaseType+ " " + h + " + // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + // + fVV()); + + return getMolarVolume(); + } + + /** + *

+ * calcW. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param temperature a double + * @param pressure a double + * @param numbcomp a int + * @return a double + */ + public double calcW(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + W = electrolyteMixingRule.calcW(phase, temperature, pressure, numbcomp); + return W; + } + + /** + *

+ * calcWi. + *

+ * + * @param compNumb a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param temperature a double + * @param pressure a double + * @param numbcomp a int + * @return a double + */ + public double calcWi(int compNumb, PhaseInterface phase, double temperature, double pressure, + int numbcomp) { + return electrolyteMixingRule.calcWi(compNumb, phase, temperature, pressure, numbcomp); + } + + /** + *

+ * calcWiT. + *

+ * + * @param compNumb a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param temperature a double + * @param pressure a double + * @param numbcomp a int + * @return a double + */ + public double calcWiT(int compNumb, PhaseInterface phase, double temperature, double pressure, + int numbcomp) { + return electrolyteMixingRule.calcWiT(compNumb, phase, temperature, pressure, numbcomp); + } + + /** + *

+ * calcWij. + *

+ * + * @param compNumb a int + * @param compNumbj a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param temperature a double + * @param pressure a double + * @param numbcomp a int + * @return a double + */ + public double calcWij(int compNumb, int compNumbj, PhaseInterface phase, double temperature, + double pressure, int numbcomp) { + return electrolyteMixingRule.calcWij(compNumb, compNumbj, phase, temperature, pressure, + numbcomp); + } + + /** {@inheritDoc} */ + @Override + public double calcDiElectricConstant(double temperature) { + return 1.0 + (getSolventDiElectricConstant() - 1.0) * (1.0 - getEpsIonic()) + / (1.0 + getEpsIonic() / 2.0); + } + + /** + *

+ * calcDiElectricConstantdV. + *

+ * + * @param temperature a double + * @return a double + */ + public double calcDiElectricConstantdV(double temperature) { + double X = (1.0 - getEpsIonic()) / (1.0 + getEpsIonic() / 2.0); + // double Y= getSolventDiElectricConstant(); 10-2002 + double Y = getSolventDiElectricConstant() - 1.0; + double dXdf = getEpsIonicdV() * -3.0 / 2.0 / Math.pow(getEpsIonic() / 2.0 + 1.0, 2.0); + double dYdf = 0; + return dYdf * X + Y * dXdf; + } + + /** + *

+ * calcDiElectricConstantdVdV. + *

+ * + * @param temperature a double + * @return a double + */ + public double calcDiElectricConstantdVdV(double temperature) { + double Y = getSolventDiElectricConstant() - 1.0; + double dXdf = getEpsIonicdVdV() * -3.0 / 2.0 / Math.pow(getEpsIonic() / 2.0 + 1.0, 2.0) + + getEpsIonicdV() * getEpsIonicdV() * 3.0 / 2.0 / Math.pow(getEpsIonic() / 2.0 + 1.0, 3.0); + return Y * dXdf;// + Y*dXdf; + } + + /** {@inheritDoc} */ + @Override + public double calcDiElectricConstantdT(double temperature) { + double X = (1.0 - getEpsIonic()) / (1.0 + getEpsIonic() / 2.0); + double Y = getSolventDiElectricConstant() - 1.0; + double dXdf = 0; + double dYdf = getSolventDiElectricConstantdT(); + return dYdf * X + Y * dXdf; + } + + /** {@inheritDoc} */ + @Override + public double calcDiElectricConstantdTdT(double temperature) { + return getSolventDiElectricConstantdTdT() * (1.0 - epsIonic) / (1.0 + epsIonic / 2.0); + } + + /** + *

+ * calcDiElectricConstantdTdV. + *

+ * + * @param temperature a double + * @return a double + */ + public double calcDiElectricConstantdTdV(double temperature) { + double Y = getSolventDiElectricConstantdT(); + double dXdf = getEpsIonicdV() * -3.0 / 2.0 / Math.pow(getEpsIonic() / 2.0 + 1.0, 2.0); + return Y * dXdf; + } + + /** + *

+ * calcBornX. + *

+ * + * @return a double + */ + public double calcBornX() { + double ans = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + if (componentArray[i].getLennardJonesMolecularDiameter() > 0) { + ans += componentArray[i].getNumberOfMolesInPhase() + * Math.pow(componentArray[i].getIonicCharge(), 2.0) + / (componentArray[i].getLennardJonesMolecularDiameter() * 1e-10); + } + } + return ans; + } + + // Long Range term equations and derivatives + + /** + *

+ * FLR. + *

+ * + * @return a double + */ + public double FLR() { + double ans = 0.0; + ans -= (1.0 / (4.0 * pi) * getAlphaLR2() * getXLR()); + return ans + + (numberOfMolesInPhase * getMolarVolume() * 1e-5 * Math.pow(getShieldingParameter(), 3.0)) + / (3.0 * pi * avagadroNumber); + } + + /** + *

+ * dFLRdT. + *

+ * + * @return a double + */ + public double dFLRdT() { + return dFdAlphaLR() * alphaLRdT; + } + + /** + *

+ * dFLRdTdV. + *

+ * + * @return a double + */ + public double dFLRdTdV() { + return (dFdAlphaLR() * alphaLRdTdV) * 1e-5; + } + + /** + *

+ * dFLRdTdT. + *

+ * + * @return a double + */ + public double dFLRdTdT() { + return dFdAlphaLR() * alphaLRdTdT; + } + + /** + *

+ * dFLRdV. + *

+ * + * @return a double + */ + public double dFLRdV() { + return (FLRV() + dFdAlphaLR() * alphaLRdV) * 1e-5;// + FLRGammaLR()*gammLRdV + + // 0*FLRXLR()*XLRdGammaLR()*gammLRdV)*1e-5; + } + + /** + *

+ * dFLRdVdV. + *

+ * + * @return a double + */ + public double dFLRdVdV() { + return (dFdAlphaLR() * alphaLRdVdV) * 1e-10; + } + + /** + *

+ * dFLRdVdVdV. + *

+ * + * @return a double + */ + public double dFLRdVdVdV() { + return 0.0; + } + + // first order derivatives + + /** + *

+ * FLRXLR. + *

+ * + * @return a double + */ + public double FLRXLR() { + return -getAlphaLR2() / (4.0 * pi); + } + + /** + *

+ * FLRGammaLR. + *

+ * + * @return a double + */ + public double FLRGammaLR() { + return 3.0 * numberOfMolesInPhase * getMolarVolume() * 1e-5 + * Math.pow(getShieldingParameter(), 2.0) / (3.0 * pi * avagadroNumber); + } + + /** + *

+ * dFdAlphaLR. + *

+ * + * @return a double + */ + public double dFdAlphaLR() { + return -1.0 / (4.0 * pi) * XLR; + } + + /** + *

+ * dFdAlphaLRdV. + *

+ * + * @return a double + */ + public double dFdAlphaLRdV() { + return 0.0; + } + + /** + *

+ * dFdAlphaLRdX. + *

+ * + * @return a double + */ + public double dFdAlphaLRdX() { + return -1.0 / (4.0 * pi); + } + + /** + *

+ * dFdAlphaLRdGamma. + *

+ * + * @return a double + */ + public double dFdAlphaLRdGamma() { + return 0; + } + + /** + *

+ * FLRV. + *

+ * + * @return a double + */ + public double FLRV() { + return Math.pow(getShieldingParameter(), 3.0) / (3.0 * pi * avagadroNumber); + } + + /** + *

+ * FLRVV. + *

+ * + * @return a double + */ + public double FLRVV() { + return 0.0; + } + + // second order derivatives + + /** + *

+ * dFdAlphaLRdAlphaLR. + *

+ * + * @return a double + */ + public double dFdAlphaLRdAlphaLR() { + return 0.0; + } + + /** + *

+ * XLRdndn. + *

+ * + * @param i a int + * @param j a int + * @return a double + */ + public double XLRdndn(int i, int j) { + return 0.0; + } + + /** + *

+ * XLRdGammaLR. + *

+ * + * @return a double + */ + public double XLRdGammaLR() { + // if(phaseType==1) return 0.0; + double ans = 0.0; + double ans2 = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + ans -= componentArray[i].getLennardJonesMolecularDiameter() * 1e-10 + * componentArray[i].getNumberOfMolesInPhase() + * Math.pow(componentArray[i].getIonicCharge(), 2.0) * getShieldingParameter() + / Math.pow(1.0 + getShieldingParameter() + * componentArray[i].getLennardJonesMolecularDiameter() * 1e-10, 2.0); + ans2 += componentArray[i].getNumberOfMolesInPhase() + * Math.pow(componentArray[i].getIonicCharge(), 2.0) / (1.0 + getShieldingParameter() + * componentArray[i].getLennardJonesMolecularDiameter() * 1e-10); + } + return ans2 + ans; + } + + /** + *

+ * XBorndndn. + *

+ * + * @param i a int + * @param j a int + * @return a double + */ + public double XBorndndn(int i, int j) { + return 0.0; + } + + // Short Range term equations and derivatives + /** + *

+ * FSR2. + *

+ * + * @return a double + */ + public double FSR2() { + return getW() / (getMolarVolume() * 1e-5 * numberOfMolesInPhase * (1.0 - eps)); + } + + /** + *

+ * dFSR2dT. + *

+ * + * @return a double + */ + public double dFSR2dT() { + return FSR2W() * WT; + } + + /** + *

+ * dFSR2dTdT. + *

+ * + * @return a double + */ + public double dFSR2dTdT() { + return FSR2W() * WTT; + } + + /** + *

+ * dFSR2dV. + *

+ * + * @return a double + */ + public double dFSR2dV() { + return (FSR2V() + FSR2eps() * getEpsdV()) * 1e-5; + } + + /** + *

+ * dFSR2dTdV. + *

+ * + * @return a double + */ + public double dFSR2dTdV() { + return (FSR2VW() * WT + FSR2epsW() * epsdV * WT) * 1e-5; + } + + /** + *

+ * dFSR2dVdV. + *

+ * + * @return a double + */ + public double dFSR2dVdV() { + return (FSR2VV() + 2.0 * FSR2epsV() * getEpsdV() + FSR2epseps() * Math.pow(getEpsdV(), 2.0) + + FSR2eps() * getEpsdVdV()) * 1e-10; + } + + /** + *

+ * dFSR2dVdVdV. + *

+ * + * @return a double + */ + public double dFSR2dVdVdV() { + return (FSR2VVV() + 3 * FSR2epsepsV() * Math.pow(getEpsdV(), 2.0) + 3 * FSR2VVeps() * getEpsdV() + + FSR2epsepseps() * Math.pow(getEpsdV(), 3.0)) * 1e-15; + } + + // first order derivatives + /** + *

+ * FSR2W. + *

+ * + * @return a double + */ + public double FSR2W() { + return 1.0 / (getMolarVolume() * 1e-5 * numberOfMolesInPhase * (1.0 - eps)); + } + + /** + *

+ * FSR2V. + *

+ * + * @return a double + */ + public double FSR2V() { + return -W / (Math.pow(getMolarVolume() * 1e-5 * numberOfMolesInPhase, 2.0) * (1.0 - eps)); + } + + /** + *

+ * FSR2T. + *

+ * + * @return a double + */ + public double FSR2T() { + return 0.0; + } + + /** + *

+ * FSR2n. + *

+ * + * @return a double + */ + public double FSR2n() { + return 0; + } + + /** + *

+ * FSR2eps. + *

+ * + * @return a double + */ + public double FSR2eps() { + return W / ((getMolarVolume() * 1e-5 * numberOfMolesInPhase) * Math.pow(1.0 - eps, 2.0)); + } + + // second order derivatives + + /** + *

+ * FSR2nn. + *

+ * + * @return a double + */ + public double FSR2nn() { + return 0; + } + + /** + *

+ * FSR2nT. + *

+ * + * @return a double + */ + public double FSR2nT() { + return 0; + } + + /** + *

+ * FSR2nV. + *

+ * + * @return a double + */ + public double FSR2nV() { + return 0; + } + + /** + *

+ * FSR2neps. + *

+ * + * @return a double + */ + public double FSR2neps() { + return 0; + } + + /** + *

+ * FSR2nW. + *

+ * + * @return a double + */ + public double FSR2nW() { + return 0; + } + + /** + *

+ * FSR2Tn. + *

+ * + * @return a double + */ + public double FSR2Tn() { + return 0; + } + + /** + *

+ * FSR2TT. + *

+ * + * @return a double + */ + public double FSR2TT() { + return 0; + } + + /** + *

+ * FSR2TV. + *

+ * + * @return a double + */ + public double FSR2TV() { + return 0; + } + + /** + *

+ * FSR2Teps. + *

+ * + * @return a double + */ + public double FSR2Teps() { + return 0; + } + + /** + *

+ * FSR2TW. + *

+ * + * @return a double + */ + public double FSR2TW() { + return 0; + } + + /** + *

+ * FSR2VV. + *

+ * + * @return a double + */ + public double FSR2VV() { + return 2.0 * W / (Math.pow(getMolarVolume() * 1e-5 * numberOfMolesInPhase, 3.0) * (1.0 - eps)); + } + + /** + *

+ * FSR2epsV. + *

+ * + * @return a double + */ + public double FSR2epsV() { + return -W / (Math.pow(getMolarVolume() * 1e-5 * numberOfMolesInPhase, 2.0) + * Math.pow((1.0 - eps), 2.0)); + } + + /** + *

+ * FSR2epsW. + *

+ * + * @return a double + */ + public double FSR2epsW() { + return 1.0 / (getMolarVolume() * 1e-5 * numberOfMolesInPhase * Math.pow(1.0 - eps, 2.0)); + } + + /** + *

+ * FSR2WW. + *

+ * + * @return a double + */ + public double FSR2WW() { + return 0.0; + } + + /** + *

+ * FSR2VW. + *

+ * + * @return a double + */ + public double FSR2VW() { + return -1.0 / (Math.pow(getMolarVolume() * 1e-5 * numberOfMolesInPhase, 2.0) * (1.0 - eps)); + } + + /** + *

+ * FSR2epseps. + *

+ * + * @return a double + */ + public double FSR2epseps() { + return 2.0 * W / ((getMolarVolume() * 1e-5 * numberOfMolesInPhase) * Math.pow(1.0 - eps, 3.0)); + } + + /** + *

+ * FSR2VVV. + *

+ * + * @return a double + */ + public double FSR2VVV() { + return -6.0 * W / (Math.pow(getMolarVolume() * 1e-5 * numberOfMolesInPhase, 4.0) * (1.0 - eps)); + } + + // third order derivatives + /** + *

+ * FSR2epsepsV. + *

+ * + * @return a double + */ + public double FSR2epsepsV() { + return -2.0 * W / (Math.pow(getMolarVolume() * 1e-5 * numberOfMolesInPhase, 2.0) + * Math.pow((1 - eps), 3.0)); + } + + /** + *

+ * FSR2VVeps. + *

+ * + * @return a double + */ + public double FSR2VVeps() { + return 2.0 * W / (Math.pow(getMolarVolume() * 1e-5 * numberOfMolesInPhase, 3.0) + * Math.pow((1 - eps), 2.0)); + } + + /** + *

+ * FSR2epsepseps. + *

+ * + * @return a double + */ + public double FSR2epsepseps() { + return 6.0 * W / ((getMolarVolume() * 1e-5 * numberOfMolesInPhase) * Math.pow(1.0 - eps, 4.0)); + } + + // Born term equations and derivatives + /** + *

+ * FBorn. + *

+ * + * @return a double + */ + public double FBorn() { + return (avagadroNumber * electronCharge * electronCharge + / (4.0 * pi * vacumPermittivity * R * temperature)) + * (1.0 / getSolventDiElectricConstant() - 1.0) * bornX; + } + + /** + *

+ * dFBorndT. + *

+ * + * @return a double + */ + public double dFBorndT() { + return FBornT() + FBornD() * solventDiElectricConstantdT; + } + + /** + *

+ * dFBorndTdT. + *

+ * + * @return a double + */ + public double dFBorndTdT() { + return FBornTT() + FBornTD() * solventDiElectricConstantdT; + } + + // first order derivatives + /** + *

+ * FBornT. + *

+ * + * @return a double + */ + public double FBornT() { + return -(avagadroNumber * electronCharge * electronCharge + / (4.0 * pi * vacumPermittivity * R * temperature * temperature)) + * (1.0 / getSolventDiElectricConstant() - 1.0) * bornX; + } + + /** + *

+ * FBornX. + *

+ * + * @return a double + */ + public double FBornX() { + return (avagadroNumber * electronCharge * electronCharge + / (4.0 * pi * vacumPermittivity * R * temperature)) + * (1.0 / getSolventDiElectricConstant() - 1.0); + } + + /** + *

+ * FBornD. + *

+ * + * @return a double + */ + public double FBornD() { + return -(avagadroNumber * electronCharge * electronCharge + / (4.0 * pi * vacumPermittivity * R * temperature)) * 1.0 + / Math.pow(getSolventDiElectricConstant(), 2.0) * bornX; + } + + // second order derivatives + + /** + *

+ * FBornTT. + *

+ * + * @return a double + */ + public double FBornTT() { + return 2.0 * (avagadroNumber * electronCharge * electronCharge + / (4.0 * pi * vacumPermittivity * R * temperature * temperature * temperature)) + * (1.0 / getSolventDiElectricConstant() - 1.0) * bornX; + } + + /** + *

+ * FBornTD. + *

+ * + * @return a double + */ + public double FBornTD() { + return (avagadroNumber * electronCharge * electronCharge + / (4.0 * pi * vacumPermittivity * R * temperature * temperature)) * 1.0 + / Math.pow(getSolventDiElectricConstant(), 2.0) * bornX; + } + + /** + *

+ * FBornTX. + *

+ * + * @return a double + */ + public double FBornTX() { + return -(avagadroNumber * electronCharge * electronCharge + / (4.0 * pi * vacumPermittivity * R * temperature * temperature)) + * (1.0 / getSolventDiElectricConstant() - 1.0); + } + + /** + *

+ * FBornDD. + *

+ * + * @return a double + */ + public double FBornDD() { + return 2.0 + * (avagadroNumber * electronCharge * electronCharge + / (4.0 * pi * vacumPermittivity * R * temperature)) + * 1.0 / Math.pow(getSolventDiElectricConstant(), 3.0) * bornX; + } + + /** + *

+ * FBornDX. + *

+ * + * @return a double + */ + public double FBornDX() { + return -(avagadroNumber * electronCharge * electronCharge + / (4.0 * pi * vacumPermittivity * R * temperature)) * 1.0 + / Math.pow(getSolventDiElectricConstant(), 2.0); + } + + /** + *

+ * FBornXX. + *

+ * + * @return a double + */ + public double FBornXX() { + return 0.0; + } + + /** + *

+ * Getter for the field eps. + *

+ * + * @return a double + */ + public double getEps() { + return eps; + } + + /** + *

+ * Getter for the field epsIonic. + *

+ * + * @return a double + */ + public double getEpsIonic() { + return epsIonic; + } + + /** + *

+ * Getter for the field epsIonicdV. + *

+ * + * @return a double + */ + public double getEpsIonicdV() { + return epsIonicdV; + } + + /** + *

+ * Getter for the field epsdV. + *

+ * + * @return a double + */ + public double getEpsdV() { + return epsdV; + } + + /** + *

+ * Getter for the field epsdVdV. + *

+ * + * @return a double + */ + public double getEpsdVdV() { + return epsdVdV; + } + + /** + *

+ * Getter for the field solventDiElectricConstant. + *

+ * + * @return a double + */ + public double getSolventDiElectricConstant() { + return solventDiElectricConstant; + } + + /** + *

+ * Getter for the field solventDiElectricConstantdT. + *

+ * + * @return a double + */ + public double getSolventDiElectricConstantdT() { + return solventDiElectricConstantdT; + } + + /** + *

+ * Getter for the field solventDiElectricConstantdTdT. + *

+ * + * @return a double + */ + public double getSolventDiElectricConstantdTdT() { + return solventDiElectricConstantdTdT; + } + + /** + *

+ * Getter for the field alphaLR2. + *

+ * + * @return a double + */ + public double getAlphaLR2() { + return alphaLR2; + } + + /** + *

+ * getW. + *

+ * + * @return a double + */ + public double getW() { + return W; + } + + /** + *

+ * getWT. + *

+ * + * @return a double + */ + public double getWT() { + return WT; + } + + /** + *

+ * Getter for the field diElectricConstantdT. + *

+ * + * @return a double + */ + public double getDiElectricConstantdT() { + return diElectricConstantdT; + } + + /** + *

+ * Getter for the field diElectricConstantdV. + *

+ * + * @return a double + */ + public double getDiElectricConstantdV() { + return diElectricConstantdV; + } + + /** + *

+ * getXLR. + *

+ * + * @return a double + */ + public double getXLR() { + return XLR; + } + + /** + *

+ * Getter for the field shieldingParameter. + *

+ * + * @return a double + */ + public double getShieldingParameter() { + return shieldingParameter; + } + + /** + *

+ * getAlphaLRT. + *

+ * + * @return a double + */ + public double getAlphaLRT() { + return alphaLRdT; + } + + /** + *

+ * getAlphaLRV. + *

+ * + * @return a double + */ + public double getAlphaLRV() { + return alphaLRdV; + } + + /** + *

+ * getDielectricT. + *

+ * + * @return a double + */ + public double getDielectricT() { + return diElectricConstantdT; + } + + /** + *

+ * getDielectricV. + *

+ * + * @return a double + */ + public double getDielectricV() { + return diElectricConstantdV; + } + + /** + *

+ * getDielectricConstant. + *

+ * + * @return a double + */ + public double getDielectricConstant() { + return diElectricConstant; + } + + /** + *

+ * setFurstIonicCoefficient. + *

+ * + * @param params an array of {@link double} objects + */ + public void setFurstIonicCoefficient(double[] params) {} + + /** + *

+ * Getter for the field epsIonicdVdV. + *

+ * + * @return a double + */ + public double getEpsIonicdVdV() { + return epsIonicdVdV; + } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEosMod2004.java b/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEosMod2004.java index 5cdd4741bd..00576928c1 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEosMod2004.java +++ b/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEosMod2004.java @@ -3,6 +3,7 @@ * * Created on 26. februar 2001, 17:54 */ + package neqsim.thermo.phase; import org.apache.logging.log4j.LogManager; @@ -19,16 +20,40 @@ */ public class PhaseModifiedFurstElectrolyteEosMod2004 extends PhaseSrkEos { private static final long serialVersionUID = 1000; - double gammaold = 0, alphaLRdTdV = 0; - double W = 0, WT = 0, WTT = 0, eps = 0, epsdV = 0, epsdVdV = 0, epsIonic = 0, bornX = 0, - epsIonicdV = 0, epsIonicdVdV = 0, alphaLR2 = 0, alphaLRdT = 0.0, alphaLRdTdT = 0.0, - alphaLRdV = 0.0, XLR = 0, solventDiElectricConstant = 0, solventDiElectricConstantdT = 0.0, - solventDiElectricConstantdTdT = 0, shieldingParameter = 0; - double gamma = 0, diElectricConstantdV = 0, diElectricConstantdVdV = 0, alphaLRdVdV = 0, - diElectricConstantdT = 0, diElectricConstantdTdT = 0.0, diElectricConstantdTdV = 0; + static Logger logger = LogManager.getLogger(PhaseModifiedFurstElectrolyteEos.class); + + double gammaold = 0; + double alphaLRdTdV = 0; + double W = 0; + double WT = 0; + double WTT = 0; + double eps = 0; + double epsdV = 0; + double epsdVdV = 0; + double epsIonic = 0; + double bornX = 0; + double epsIonicdV = 0; + double epsIonicdVdV = 0; + double alphaLR2 = 0; + double alphaLRdT = 0.0; + double alphaLRdTdT = 0.0; + double alphaLRdV = 0.0; + double XLR = 0; + double solventDiElectricConstant = 0; + double solventDiElectricConstantdT = 0.0; + double solventDiElectricConstantdTdT = 0; + double shieldingParameter = 0; + double gamma = 0; + double diElectricConstantdV = 0; + double diElectricConstantdVdV = 0; + double alphaLRdVdV = 0; + double diElectricConstantdT = 0; + double diElectricConstantdTdT = 0.0; + double diElectricConstantdTdV = 0; neqsim.thermo.mixingRule.ElectrolyteMixingRulesInterface electrolyteMixingRule; - double sr2On = 1.0, lrOn = 1.0, bornOn = 1.0; - static Logger logger = LogManager.getLogger(PhaseModifiedFurstElectrolyteEosMod2004.class); + double sr2On = 1.0; + double lrOn = 1.0; + double bornOn = 1.0; // double gammLRdV=0.0; // PhaseInterface[] refPhase;// = new PhaseInterface[10]; @@ -183,7 +208,8 @@ public void addcomponent(String componentName, double moles, double molesInPhase * @return a double */ public double calcSolventDiElectricConstant(double temperature) { - double ans1 = 0.0, ans2 = 1e-50; + double ans1 = 0.0; + double ans2 = 1e-50; for (int i = 0; i < numberOfComponents; i++) { if (componentArray[i].getIonicCharge() == 0) { ans1 += componentArray[i].getNumberOfMolesInPhase() @@ -203,7 +229,8 @@ public double calcSolventDiElectricConstant(double temperature) { * @return a double */ public double calcSolventDiElectricConstantdT(double temperature) { - double ans1 = 0.0, ans2 = 1e-50; + double ans1 = 0.0; + double ans2 = 1e-50; for (int i = 0; i < numberOfComponents; i++) { if (componentArray[i].getIonicCharge() == 0) { ans1 += componentArray[i].getNumberOfMolesInPhase() @@ -223,7 +250,8 @@ public double calcSolventDiElectricConstantdT(double temperature) { * @return a double */ public double calcSolventDiElectricConstantdTdT(double temperature) { - double ans1 = 0.0, ans2 = 1e-50; + double ans1 = 0.0; + double ans2 = 1e-50; for (int i = 0; i < numberOfComponents; i++) { if (componentArray[i].getIonicCharge() == 0) { ans1 += componentArray[i].getNumberOfMolesInPhase() @@ -407,7 +435,8 @@ public double calcGammaLRdV() { */ public double calcShieldingParameter() { // if(phaseType==1) return 0.0; - double df = 0, f = 0; + double df = 0; + double f = 0; int ions = 0; int iterations = 0; gamma = 1e10; @@ -484,8 +513,12 @@ public double molarVolume(double pressure, double temperature, double A, double BonV = 1.0 - 1.0e-6; } double BonVold = BonV; - double Btemp = 0, h = 0, dh = 0, dhh = 0; - double d1 = 0, d2 = 0; + double Btemp = 0; + double h = 0; + double dh = 0; + double dhh = 0; + double d1 = 0; + double d2 = 0; Btemp = getB(); if (Btemp <= 0) { logger.info("b negative in volume calc"); diff --git a/src/main/java/neqsim/thermo/phase/PhasePureComponentSolid.java b/src/main/java/neqsim/thermo/phase/PhasePureComponentSolid.java index 42992f0a38..6c8da61cab 100644 --- a/src/main/java/neqsim/thermo/phase/PhasePureComponentSolid.java +++ b/src/main/java/neqsim/thermo/phase/PhasePureComponentSolid.java @@ -3,6 +3,7 @@ * * Created on 18. august 2001, 12:39 */ + package neqsim.thermo.phase; /** @@ -14,35 +15,35 @@ * @version $Id: $Id */ public class PhasePureComponentSolid extends PhaseSolid { - private static final long serialVersionUID = 1000; - - /** - *

- * Constructor for PhasePureComponentSolid. - *

- */ - public PhasePureComponentSolid() { - super(); - } + private static final long serialVersionUID = 1000; - /** {@inheritDoc} */ - @Override - public PhasePureComponentSolid clone() { - PhasePureComponentSolid clonedPhase = null; - try { - clonedPhase = (PhasePureComponentSolid) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } + /** + *

+ * Constructor for PhasePureComponentSolid. + *

+ */ + public PhasePureComponentSolid() { + super(); + } - return clonedPhase; + /** {@inheritDoc} */ + @Override + public PhasePureComponentSolid clone() { + PhasePureComponentSolid clonedPhase = null; + try { + clonedPhase = (PhasePureComponentSolid) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); } - /** {@inheritDoc} */ - @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, - double beta) { - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - phaseTypeName = "solid"; - } + return clonedPhase; + } + + /** {@inheritDoc} */ + @Override + public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, + double beta) { + super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + phaseTypeName = "solid"; + } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseSolid.java b/src/main/java/neqsim/thermo/phase/PhaseSolid.java index a2700e8d75..4b6607390c 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseSolid.java +++ b/src/main/java/neqsim/thermo/phase/PhaseSolid.java @@ -3,6 +3,7 @@ * * Created on 18. august 2001, 12:38 */ + package neqsim.thermo.phase; import neqsim.thermo.component.ComponentSolid; @@ -16,83 +17,82 @@ * @version $Id: $Id */ public abstract class PhaseSolid extends PhaseSrkEos { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for PhaseSolid. - *

- */ - public PhaseSolid() { - super(); - phaseTypeName = "solid"; - } + /** + *

+ * Constructor for PhaseSolid. + *

+ */ + public PhaseSolid() { + super(); + phaseTypeName = "solid"; + } - /** {@inheritDoc} */ - @Override - public PhaseSolid clone() { - PhaseSolid clonedPhase = null; - try { - clonedPhase = (PhaseSolid) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } - return clonedPhase; + /** {@inheritDoc} */ + @Override + public PhaseSolid clone() { + PhaseSolid clonedPhase = null; + try { + clonedPhase = (PhaseSolid) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); } + return clonedPhase; + } - /** {@inheritDoc} */ - @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, - double beta) { - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - phaseTypeName = "solid"; - } + /** {@inheritDoc} */ + @Override + public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, + double beta) { + super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + phaseTypeName = "solid"; + } - /** {@inheritDoc} */ - @Override - public void addcomponent(String componentName, double molesInPhase, double moles, - int compNumber) { - super.addcomponent(molesInPhase); - componentArray[compNumber] = - new ComponentSolid(componentName, moles, molesInPhase, compNumber); - } + /** {@inheritDoc} */ + @Override + public void addcomponent(String componentName, double molesInPhase, double moles, + int compNumber) { + super.addcomponent(molesInPhase); + componentArray[compNumber] = new ComponentSolid(componentName, moles, molesInPhase, compNumber); + } - /** {@inheritDoc} */ - @Override - public double getEnthalpy() { - double fusionHeat = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - fusionHeat += - getComponent(i).getNumberOfMolesInPhase() * getComponent(i).getHeatOfFusion(); - } - return super.getEnthalpy() - fusionHeat; + /** {@inheritDoc} */ + @Override + public double getEnthalpy() { + double fusionHeat = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + fusionHeat += getComponent(i).getNumberOfMolesInPhase() * getComponent(i).getHeatOfFusion(); } + return super.getEnthalpy() - fusionHeat; + } - /** - *

- * setSolidRefFluidPhase. - *

- * - * @param refPhase a {@link neqsim.thermo.phase.PhaseInterface} object - */ - public void setSolidRefFluidPhase(PhaseInterface refPhase) { - for (int i = 0; i < numberOfComponents; i++) { - ((ComponentSolid) componentArray[i]).setSolidRefFluidPhase(refPhase); - } + /** + *

+ * setSolidRefFluidPhase. + *

+ * + * @param refPhase a {@link neqsim.thermo.phase.PhaseInterface} object + */ + public void setSolidRefFluidPhase(PhaseInterface refPhase) { + for (int i = 0; i < numberOfComponents; i++) { + ((ComponentSolid) componentArray[i]).setSolidRefFluidPhase(refPhase); } + } - /** - * method to get density of a phase note: at the moment return density of water (997 kg/m3) - * - * @return density with unit kg/m3 - */ - public double getDensityTemp() { - double density = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - density += getWtFrac(i) * ((ComponentSolid) componentArray[i]) - .getPureComponentSolidDensity(getTemperature()) * 1000.0; - } - molarVolume = density / getMolarMass() * 1e-5; - return density; + /** + * method to get density of a phase note: at the moment return density of water (997 kg/m3) + * + * @return density with unit kg/m3 + */ + public double getDensityTemp() { + double density = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + density += getWtFrac(i) + * ((ComponentSolid) componentArray[i]).getPureComponentSolidDensity(getTemperature()) + * 1000.0; } + molarVolume = density / getMolarMass() * 1e-5; + return density; + } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseSrkCPAojAlgo.java b/src/main/java/neqsim/thermo/phase/PhaseSrkCPAojAlgo.java index 9a1df4731c..cf2deaaa79 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseSrkCPAojAlgo.java +++ b/src/main/java/neqsim/thermo/phase/PhaseSrkCPAojAlgo.java @@ -3,6 +3,7 @@ * * Created on 3. juni 2000, 14:38 */ + package neqsim.thermo.phase; import org.apache.logging.log4j.LogManager; @@ -25,1369 +26,1394 @@ * @version $Id: $Id */ public class PhaseSrkCPAojAlgo extends PhaseSrkEos implements PhaseCPAInterface { - private static final long serialVersionUID = 1000; - - public CPAMixing cpaSelect = new CPAMixing(); - public CPAMixingInterface cpamix; - double gcpavv = 0.0, gcpavvv = 0.0, gcpa = 0.0, hcpatot = 1.0, FCPA = 0.0, dFCPAdTdV, - dFCPAdTdT = 0.0, dFCPAdT = 0, dFCPAdV = 0, dFCPAdVdV = 0.0, dFCPAdVdVdV = 0.0; - private double gcpav = 0.0; - int cpaon = 1, oldTotalNumberOfAccociationSites = 0; - private int totalNumberOfAccociationSites = 0; - int[][][] selfAccociationScheme = null; - int[][][][] crossAccociationScheme = null; - int[] moleculeNumber = null, assSiteNumber = null; - private double[][] gvector = null, delta = null, deltaNog = null, deltadT = null, - deltadTdT = null; - private double[][][] Klkni = null; - - // final PrimitiveDenseStore tmpBody = PrimitiveDenseStore.FACTORY.rows(new - // double[][] { { 4, 2, 3 }, { 3, -5, 2 }, { -2, 3, 8 } }); - private SparseStore KlkTVMatrix2 = null, KlkTTMatrix2 = null, KlkTMatrix2 = null, - udotTimesmMatrix2 = null, mVector2 = null, udotMatrix2 = null, uMatrix2 = null, - QMatksiksiksi2 = null, KlkVVVMatrix2 = null, KlkVVMatrix2 = null, - udotTimesmiMatrix2 = null, ksiMatrix2 = null, KlkMatrix2 = null, hessianMatrix2 = null, - KlkVMatrix2 = null; - SparseStore corr2Matrix2 = null, corr3Matrix2 = null, corr4Matrix2 = null;// new - // DenseMatrix64F(getTotalNumberOfAccociationSites(), - // 1); - MatrixStore hessianInvers2 = null; - final Factory mtrxFactory = Primitive64Matrix.FACTORY; - - static Logger logger = LogManager.getLogger(PhaseSrkCPAojAlgo.class); - - // private transient SimpleMatrix KlkTVMatrix = null, KlkTTMatrix = null, - // KlkTMatrix = null, udotTimesmMatrix = null, mVector = null, udotMatrix = - // null, uMatrix = null, QMatksiksiksi = null, KlkVVVMatrix = null, KlkVVMatrix - // = null, udotTimesmiMatrix = null, ksiMatrix = null, KlkMatrix = null, - // hessianMatrix = null, hessianInvers = null, KlkVMatrix = null; - // DMatrixRMaj corr2Matrix = null, corr3Matrix = null, corr4Matrix = null;//new - // DenseMatrix64F(getTotalNumberOfAccociationSites(), 1); - - /** - *

- * Constructor for PhaseSrkCPAojAlgo. - *

- */ - public PhaseSrkCPAojAlgo() { - super(); + private static final long serialVersionUID = 1000; + + public CPAMixing cpaSelect = new CPAMixing(); + public CPAMixingInterface cpamix; + double gcpavv = 0.0; + double gcpavvv = 0.; + double gcpa = 0.0; + double hcpatot = 1.0; + double FCPA = 0.0; + double dFCPAdTdV; + double dFCPAdTdT = 0.0; + double dFCPAdT = 0; + double dFCPAdV = 0; + double dFCPAdVdV = 0.0; + double dFCPAdVdVdV = 0.0; + private double gcpav = 0.0; + int cpaon = 1; + int oldTotalNumberOfAccociationSites = 0; + private int totalNumberOfAccociationSites = 0; + int[][][] selfAccociationScheme = null; + int[][][][] crossAccociationScheme = null; + int[] moleculeNumber = null; + int[] assSiteNumber = null; + private double[][] gvector = null; + private double[][] delta = null; + private double[][] deltaNog = null; + private double[][] deltadT = null; + private double[][] deltadTdT = null; + private double[][][] Klkni = null; + private SparseStore KlkTVMatrix2 = null; + private SparseStore KlkTTMatrix2 = null; + private SparseStore KlkTMatrix2 = null; + private SparseStore udotTimesmMatrix2 = null; + private SparseStore mVector2 = null; + private SparseStore udotMatrix2 = null; + private SparseStore uMatrix2 = null; + private SparseStore QMatksiksiksi2 = null; + private SparseStore KlkVVVMatrix2 = null; + private SparseStore KlkVVMatrix2 = null; + private SparseStore udotTimesmiMatrix2 = null; + private SparseStore ksiMatrix2 = null; + private SparseStore KlkMatrix2 = null; + private SparseStore hessianMatrix2 = null; + private SparseStore KlkVMatrix2 = null; + SparseStore corr2Matrix2 = null; + SparseStore corr3Matrix2 = null; + SparseStore corr4Matrix2 = null; + + // DenseMatrix64F(getTotalNumberOfAccociationSites(), + // 1); + MatrixStore hessianInvers2 = null; + final Factory mtrxFactory = Primitive64Matrix.FACTORY; + + static Logger logger = LogManager.getLogger(PhaseSrkCPAojAlgo.class); + + // private transient SimpleMatrix KlkTVMatrix = null, KlkTTMatrix = null, + // KlkTMatrix = null, udotTimesmMatrix = null, mVector = null, udotMatrix = + // null, uMatrix = null, QMatksiksiksi = null, KlkVVVMatrix = null, KlkVVMatrix + // = null, udotTimesmiMatrix = null, ksiMatrix = null, KlkMatrix = null, + // hessianMatrix = null, hessianInvers = null, KlkVMatrix = null; + // DMatrixRMaj corr2Matrix = null, corr3Matrix = null, corr4Matrix = null;//new + // DenseMatrix64F(getTotalNumberOfAccociationSites(), 1); + + /** + *

+ * Constructor for PhaseSrkCPAojAlgo. + *

+ */ + public PhaseSrkCPAojAlgo() { + super(); + } + + /** {@inheritDoc} */ + @Override + public PhaseSrkCPAojAlgo clone() { + PhaseSrkCPAojAlgo clonedPhase = null; + try { + clonedPhase = (PhaseSrkCPAojAlgo) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); } - - /** {@inheritDoc} */ - @Override - public PhaseSrkCPAojAlgo clone() { - PhaseSrkCPAojAlgo clonedPhase = null; - try { - clonedPhase = (PhaseSrkCPAojAlgo) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); + // clonedPhase.cpaSelect = (CPAMixing) cpaSelect.clone(); + // clonedPhase.cpamix = (CPAMixingInterface) cpamix.clone(); + // clonedPhase.cpamix = cpaSelect.getMixingRule(1, this); + + return clonedPhase; + } + + /** {@inheritDoc} */ + @Override + public void setMixingRule(int type) { + super.setMixingRule(type); + cpamix = cpaSelect.getMixingRule(1, this); + } + + /** {@inheritDoc} */ + @Override + public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, + double beta) { + if (type == 0) { + setTotalNumberOfAccociationSites(0); + selfAccociationScheme = new int[numberOfComponents][0][0]; + crossAccociationScheme = new int[numberOfComponents][numberOfComponents][0][0]; + for (int i = 0; i < numberOfComponents; i++) { + if (getComponent(i).getNumberOfmoles() < 1e-50) { + getComponent(i).setNumberOfAssociationSites(0); + } else { + getComponent(i) + .setNumberOfAssociationSites(getComponent(i).getOrginalNumberOfAssociationSites()); + setTotalNumberOfAccociationSites( + getTotalNumberOfAccociationSites() + getComponent(i).getNumberOfAssociationSites()); + selfAccociationScheme[i] = cpaSelect.setAssociationScheme(i, this); + for (int j = 0; j < numberOfComponents; j++) { + crossAccociationScheme[i][j] = cpaSelect.setCrossAssociationScheme(i, j, this); + } } - // clonedPhase.cpaSelect = (CPAMixing) cpaSelect.clone(); - // clonedPhase.cpamix = (CPAMixingInterface) cpamix.clone(); - // clonedPhase.cpamix = cpaSelect.getMixingRule(1, this); - - return clonedPhase; + } + + // had to remove if below - dont understand why.. Even + // if (getTotalNumberOfAccociationSites() != oldTotalNumberOfAccociationSites) { + mVector2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), 1); + KlkMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkVMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkVVMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkVVVMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + hessianMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkTMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkTTMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkTVMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + corr2Matrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), 1); + corr3Matrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), 1); + corr4Matrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), 1); + Klkni = + new double[numberOfComponents][getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + ksiMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), 1); + uMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), 1); + udotMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), 1); + moleculeNumber = new int[getTotalNumberOfAccociationSites()]; + assSiteNumber = new int[getTotalNumberOfAccociationSites()]; + gvector = new double[getTotalNumberOfAccociationSites()][1]; + udotTimesmMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), 1); + delta = new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + deltaNog = new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + deltadT = new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + deltadTdT = + new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + QMatksiksiksi2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), 1); + // } + udotTimesmiMatrix2 = + SparseStore.PRIMITIVE64.make(getNumberOfComponents(), getTotalNumberOfAccociationSites()); + + oldTotalNumberOfAccociationSites = getTotalNumberOfAccociationSites(); + + int temp = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + moleculeNumber[temp + j] = i; + assSiteNumber[temp + j] = j; + } + temp += getComponent(i).getNumberOfAssociationSites(); + } } - - /** {@inheritDoc} */ - @Override - public void setMixingRule(int type) { - super.setMixingRule(type); - cpamix = cpaSelect.getMixingRule(1, this); + if (cpamix == null) { + cpamix = cpaSelect.getMixingRule(1, this); } - /** {@inheritDoc} */ - @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, - double beta) { - if (type == 0) { - setTotalNumberOfAccociationSites(0); - selfAccociationScheme = new int[numberOfComponents][0][0]; - crossAccociationScheme = new int[numberOfComponents][numberOfComponents][0][0]; - for (int i = 0; i < numberOfComponents; i++) { - if (getComponent(i).getNumberOfmoles() < 1e-50) { - getComponent(i).setNumberOfAssociationSites(0); - } else { - getComponent(i).setNumberOfAssociationSites( - getComponent(i).getOrginalNumberOfAssociationSites()); - setTotalNumberOfAccociationSites(getTotalNumberOfAccociationSites() - + getComponent(i).getNumberOfAssociationSites()); - selfAccociationScheme[i] = cpaSelect.setAssociationScheme(i, this); - for (int j = 0; j < numberOfComponents; j++) { - crossAccociationScheme[i][j] = - cpaSelect.setCrossAssociationScheme(i, j, this); - } - } - } - - // had to remove if below - dont understand why.. Even - // if (getTotalNumberOfAccociationSites() != oldTotalNumberOfAccociationSites) { - mVector2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), 1); - KlkMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkVMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkVVMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkVVVMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - hessianMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkTMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkTTMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkTVMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - corr2Matrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), 1); - corr3Matrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), 1); - corr4Matrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), 1); - Klkni = new double[numberOfComponents][getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - ksiMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), 1); - uMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), 1); - udotMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), 1); - moleculeNumber = new int[getTotalNumberOfAccociationSites()]; - assSiteNumber = new int[getTotalNumberOfAccociationSites()]; - gvector = new double[getTotalNumberOfAccociationSites()][1]; - udotTimesmMatrix2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), 1); - delta = new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - deltaNog = - new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - deltadT = - new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - deltadTdT = - new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - QMatksiksiksi2 = SparseStore.PRIMITIVE64.make(getTotalNumberOfAccociationSites(), 1); - // } - udotTimesmiMatrix2 = SparseStore.PRIMITIVE64.make(getNumberOfComponents(), - getTotalNumberOfAccociationSites()); - - oldTotalNumberOfAccociationSites = getTotalNumberOfAccociationSites(); - - int temp = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - moleculeNumber[temp + j] = i; - assSiteNumber[temp + j] = j; - } - temp += getComponent(i).getNumberOfAssociationSites(); - } - } - if (cpamix == null) { - cpamix = cpaSelect.getMixingRule(1, this); - } - - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - if (type > 0 && isConstantPhaseVolume()) { - calcDelta(); - solveX(); - super.init(totalNumberOfMoles, numberOfComponents, 1, phase, beta); - gcpa = calc_g(); - // lngcpa = Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - } - - if (type > 0) { - hcpatot = calc_hCPA(); - } - - if (type > 1) { - initCPAMatrix(type); - // hcpatotdT = calc_hCPAdT(); - // super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - } + super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + if (type > 0 && isConstantPhaseVolume()) { + calcDelta(); + solveX(); + super.init(totalNumberOfMoles, numberOfComponents, 1, phase, beta); + gcpa = calc_g(); + // lngcpa = Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); } - /** - *

- * calcDelta. - *

- */ - public void calcDelta() { - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - deltaNog[i][j] = cpamix.calcDeltaNog(assSiteNumber[i], assSiteNumber[j], - moleculeNumber[i], moleculeNumber[j], this, getTemperature(), getPressure(), - numberOfComponents); - deltaNog[j][i] = deltaNog[i][j]; - } - } + if (type > 0) { + hcpatot = calc_hCPA(); } - /** - *

- * initCPAMatrix. - *

- * - * @param type a int - */ - public void initCPAMatrix(int type) { - if (getTotalNumberOfAccociationSites() == 0) { - FCPA = 0.0; - dFCPAdTdV = 0.0; - dFCPAdTdT = 0.0; - dFCPAdT = 0; - dFCPAdV = 0; - dFCPAdVdV = 0.0; - dFCPAdVdVdV = 0.0; - - return; - } - - int temp = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - uMatrix2.set(temp + j, 0, - Math.log(ksiMatrix2.get(temp + j, 0)) - ksiMatrix2.get(temp + j, 0) + 1.0); - gvector[temp + j][0] = mVector2.get(temp + j, 0) * udotMatrix2.get(temp + j, 0); - } - temp += getComponent(i).getNumberOfAssociationSites(); - } - for (int i = 0; i < getNumberOfComponents(); i++) { - for (int j = 0; j < getTotalNumberOfAccociationSites(); j++) { - if (moleculeNumber[j] == i) { - udotTimesmiMatrix2.set(i, j, udotMatrix2.get(j, 0)); - } else { - udotTimesmiMatrix2.set(i, j, 0.0); - } - } - } - - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - delta[i][j] = deltaNog[i][j] * getGcpa(); - delta[j][i] = delta[i][j]; - if (type > 1) { - deltadT[i][j] = cpamix.calcDeltadT(assSiteNumber[i], assSiteNumber[j], - moleculeNumber[i], moleculeNumber[j], this, getTemperature(), - getPressure(), numberOfComponents); - deltadT[j][i] = deltadT[i][j]; - - deltadTdT[i][j] = cpamix.calcDeltadTdT(assSiteNumber[i], assSiteNumber[j], - moleculeNumber[i], moleculeNumber[j], this, getTemperature(), - getPressure(), numberOfComponents); - deltadTdT[j][i] = deltadTdT[i][j]; - } - } - } - - double gdv1 = getGcpav() - 1.0 / getTotalVolume(); - double gdv2 = gdv1 * gdv1; - double gdv3 = gdv2 * gdv1; - double totVol = getTotalVolume(); - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - KlkVMatrix2.set(i, j, KlkMatrix2.get(i, j) * gdv1); - KlkVMatrix2.set(j, i, KlkVMatrix2.get(i, j)); - - KlkVVMatrix2.set(i, j, KlkMatrix2.get(i, j) * gdv2 + KlkMatrix2.get(i, j) - * (gcpavv + 1.0 / getTotalVolume() / getTotalVolume())); - KlkVVMatrix2.set(j, i, KlkVVMatrix2.get(i, j)); - - KlkVVVMatrix2.set(i, j, KlkMatrix2.get(i, j) * gdv3 - + 3.0 * KlkMatrix2.get(i, j) * (getGcpav() - 1.0 / getTotalVolume()) - * (gcpavv + 1.0 / (totVol * totVol)) - + KlkMatrix2.get(i, j) * (gcpavvv - 2.0 / (totVol * totVol * totVol))); - KlkVVVMatrix2.set(j, i, KlkVVVMatrix2.get(i, j)); - - if (type > 1) { - double tempVar = deltadT[i][j] / delta[i][j]; - double tempVardT = deltadTdT[i][j] / delta[i][j] - - (deltadT[i][j] * deltadT[i][j]) / (delta[i][j] * delta[i][j]); - - if (!Double.isNaN(tempVar)) { - // KlkdT[i][j] = KlkMatrix.getMatrix().unsafe_get(i, j) * tempVar; - // KlkdT[j][i] = KlkdT[i][j]; - - KlkTMatrix2.set(i, j, KlkMatrix2.get(i, j) * tempVar); - KlkTMatrix2.set(j, i, KlkTMatrix2.get(i, j)); - - KlkTVMatrix2.set(i, j, - KlkMatrix2.get(i, j) * tempVar * (gcpav - 1.0 / getTotalVolume())); - KlkTVMatrix2.set(j, i, KlkTVMatrix2.get(i, j)); - - KlkTTMatrix2.set(i, j, - KlkMatrix2.get(i, j) * (tempVar * tempVar + tempVardT)); - KlkTTMatrix2.set(j, i, KlkTTMatrix2.get(i, j)); - } - - if (type > 2) { - for (int p = 0; p < numberOfComponents; p++) { - double t1 = 0.0, t2 = 0.0; - if (moleculeNumber[i] == p) { - t1 = 1.0 / mVector2.get(i, 0); - } - if (moleculeNumber[j] == p) { - t2 = 1.0 / mVector2.get(j, 0); - } - Klkni[p][i][j] = KlkMatrix2.get(i, j) * (t1 + t2 - + ((ComponentSrkCPA) getComponent(p)).calc_lngi(this)); - Klkni[p][j][i] = Klkni[p][i][j]; - } - } - } - } - QMatksiksiksi2.set(i, 0, 2.0 * mVector2.get(i, 0) - / (ksiMatrix2.get(i, 0) * ksiMatrix2.get(i, 0) * ksiMatrix2.get(i, 0))); - } - - MatrixStore ksiMatrixTranspose2 = ksiMatrix2.transpose(); - - // dXdV - MatrixStore KlkVMatrixksi = KlkVMatrix2.multiply(ksiMatrix2); - MatrixStore XV = hessianInvers2.multiply(KlkVMatrixksi); - MatrixStore XVtranspose = XV.transpose(); - - MatrixStore QCPA = mVector2.transpose() - .multiply(uMatrix2.subtract(ksiMatrix2.multiply(udotMatrix2).multiply(0.5))); - FCPA = QCPA.get(0, 0); - - MatrixStore tempMatrix = ksiMatrixTranspose2.multiply(KlkVMatrixksi).multiply(-0.5); - dFCPAdV = tempMatrix.get(0, 0); - MatrixStore KlkVVMatrixTImesKsi = KlkVVMatrix2.multiply(ksiMatrix2); - MatrixStore tempMatrixVV = ksiMatrixTranspose2.multiply(KlkVVMatrixTImesKsi) - .multiply(-0.5).subtract(KlkVMatrixksi.transpose().multiply(XV)); - dFCPAdVdV = tempMatrixVV.get(0, 0); - - MatrixStore QVVV = - ksiMatrixTranspose2.multiply(KlkVVVMatrix2.multiply(ksiMatrix2)).multiply(-0.5); - MatrixStore QVVksi = KlkVVMatrixTImesKsi.multiply(-1.0); - MatrixStore QksiVksi = KlkVMatrix2.multiply(-1.0); - - MatrixStore mat1 = QVVksi.transpose().multiply(XV).multiply(3.0); - MatrixStore mat2 = XVtranspose.multiply(QksiVksi.multiply(XV)).multiply(3.0); - MatrixStore mat4 = - XVtranspose.multiply(QMatksiksiksi2.multiply(XVtranspose)).multiply(XV); - - MatrixStore dFCPAdVdVdVMatrix = QVVV.add(mat1).add(mat2).add(mat2).add(mat4); - dFCPAdVdVdV = dFCPAdVdVdVMatrix.get(0, 0); - temp = 0; + if (type > 1) { + initCPAMatrix(type); + // hcpatotdT = calc_hCPAdT(); + // super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + } + } + + /** + *

+ * calcDelta. + *

+ */ + public void calcDelta() { + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + deltaNog[i][j] = cpamix.calcDeltaNog(assSiteNumber[i], assSiteNumber[j], moleculeNumber[i], + moleculeNumber[j], this, getTemperature(), getPressure(), numberOfComponents); + deltaNog[j][i] = deltaNog[i][j]; + } + } + } + + /** + *

+ * initCPAMatrix. + *

+ * + * @param type a int + */ + public void initCPAMatrix(int type) { + if (getTotalNumberOfAccociationSites() == 0) { + FCPA = 0.0; + dFCPAdTdV = 0.0; + dFCPAdTdT = 0.0; + dFCPAdT = 0; + dFCPAdV = 0; + dFCPAdVdV = 0.0; + dFCPAdVdVdV = 0.0; + + return; + } - if (type == 1) { - return; - } - for (int p = 0; p < numberOfComponents; p++) { - for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { - ((ComponentCPAInterface) getComponent(p)).setXsitedV(kk, XV.get(temp + kk, 0)); - } - temp += getComponent(p).getNumberOfAssociationSites(); + int temp = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + uMatrix2.set(temp + j, 0, + Math.log(ksiMatrix2.get(temp + j, 0)) - ksiMatrix2.get(temp + j, 0) + 1.0); + gvector[temp + j][0] = mVector2.get(temp + j, 0) * udotMatrix2.get(temp + j, 0); + } + temp += getComponent(i).getNumberOfAssociationSites(); + } + for (int i = 0; i < getNumberOfComponents(); i++) { + for (int j = 0; j < getTotalNumberOfAccociationSites(); j++) { + if (moleculeNumber[j] == i) { + udotTimesmiMatrix2.set(i, j, udotMatrix2.get(j, 0)); + } else { + udotTimesmiMatrix2.set(i, j, 0.0); } + } + } - // KlkTMatrix = new SimpleMatrix(KlkdT); - MatrixStore KlkTMatrixTImesKsi = KlkTMatrix2.multiply(ksiMatrix2); - // dQdT - MatrixStore tempMatrix2 = - ksiMatrixTranspose2.multiply(KlkTMatrixTImesKsi).multiply(-0.5); - dFCPAdT = tempMatrix2.get(0, 0); - - // SimpleMatrix KlkTVMatrix = new SimpleMatrix(KlkdTdV); - // SimpleMatrix tempMatrixTV = - // ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5).minus(KlkTMatrixTImesKsi.transpose().mult(XV)); - // dFCPAdTdV = tempMatrixTV.get(0, 0); - // dXdT - MatrixStore XT = hessianInvers2.multiply(KlkTMatrixTImesKsi); - // dQdTdT - MatrixStore tempMatrixTT = - ksiMatrixTranspose2.multiply(KlkTTMatrix2.multiply(ksiMatrix2)).multiply(-0.5) - .subtract(KlkTMatrixTImesKsi.transpose().multiply(XT)); - dFCPAdTdT = tempMatrixTT.get(0, 0); - - MatrixStore tempMatrixTV = - ksiMatrixTranspose2.multiply(KlkTVMatrix2.multiply(ksiMatrix2)).multiply(-0.5) - .subtract(KlkTMatrixTImesKsi.transpose().multiply(XV)); - dFCPAdTdV = tempMatrixTV.get(0, 0); - - temp = 0; - for (int p = 0; p < numberOfComponents; p++) { - for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { - ((ComponentCPAInterface) getComponent(p)).setXsitedT(kk, XT.get(temp + kk, 0)); - } - temp += getComponent(p).getNumberOfAssociationSites(); + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + delta[i][j] = deltaNog[i][j] * getGcpa(); + delta[j][i] = delta[i][j]; + if (type > 1) { + deltadT[i][j] = cpamix.calcDeltadT(assSiteNumber[i], assSiteNumber[j], moleculeNumber[i], + moleculeNumber[j], this, getTemperature(), getPressure(), numberOfComponents); + deltadT[j][i] = deltadT[i][j]; + + deltadTdT[i][j] = + cpamix.calcDeltadTdT(assSiteNumber[i], assSiteNumber[j], moleculeNumber[i], + moleculeNumber[j], this, getTemperature(), getPressure(), numberOfComponents); + deltadTdT[j][i] = deltadTdT[i][j]; } + } + } - if (type == 2) { - return; - } + double gdv1 = getGcpav() - 1.0 / getTotalVolume(); + double gdv2 = gdv1 * gdv1; + double gdv3 = gdv2 * gdv1; + double totVol = getTotalVolume(); + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + KlkVMatrix2.set(i, j, KlkMatrix2.get(i, j) * gdv1); + KlkVMatrix2.set(j, i, KlkVMatrix2.get(i, j)); + + KlkVVMatrix2.set(i, j, KlkMatrix2.get(i, j) * gdv2 + + KlkMatrix2.get(i, j) * (gcpavv + 1.0 / getTotalVolume() / getTotalVolume())); + KlkVVMatrix2.set(j, i, KlkVVMatrix2.get(i, j)); + + KlkVVVMatrix2.set(i, j, + KlkMatrix2.get(i, j) * gdv3 + + 3.0 * KlkMatrix2.get(i, j) * (getGcpav() - 1.0 / getTotalVolume()) + * (gcpavv + 1.0 / (totVol * totVol)) + + KlkMatrix2.get(i, j) * (gcpavvv - 2.0 / (totVol * totVol * totVol))); + KlkVVVMatrix2.set(j, i, KlkVVVMatrix2.get(i, j)); - // int assSites = 0; - // if(true) return; - for (int p = 0; p < numberOfComponents; p++) { - // MatrixStore KiMatrix = PrimitiveDenseStore.FACTORY.rows(Klkni[p]); - // MatrixStore KiMatrix = new SimpleMatrix(Klkni[p]); - // KiMatrix.print(10,10); - - // Matrix dQdniMatrix = - // (ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5)); // this - // methods misses one part of .... - // dQdniMatrix.print(10,10); - // KiMatrix.print(10, 10); - // miMatrix.getMatrix(assSites, assSites, 0, totalNumberOfAccociationSites - - // 1).print(10, 10); - // Matrix tempMatrix20 = miMatrix.getMatrix(assSites, assSites, 0, - // totalNumberOfAccociationSites - - // 1).times(uMatrix).minus(ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5));// - // ksiMatrix.transpose().times(KlkTMatrix.times(ksiMatrix)).times(-0.5); - // System.out.println("dQdn "); - // tempMatrix20.print(10, 10); - // SimpleMatrix tempMatrix4 = KiMatrix.multiply(ksiMatrix); - // udotTimesmiMatrix.getMatrix(assSites, assSites, 0, - // totalNumberOfAccociationSites - 1).print(10, 10); - // SimpleMatrix tempMatrix5 = udotTimesmiMatrix2.extractVector(true, - // p).transpose().minus(tempMatrix4); - // tempMki[0] = mki[p]; - // Matrix amatrix = new Matrix(croeneckerProduct(tempMki, - // udotMatrix.getArray())); - // System.out.println("aMatrix "); - // amatrix.transpose().print(10, 10); - // System.out.println("temp4 matrix"); - // tempMatrix4.print(10, 10); - // Matrix tempMatrix5 = amatrix.minus(tempMatrix4); - // SimpleMatrix tempMatrix6 = hessianInvers.mult(tempMatrix5);//.scale(-1.0); - // System.out.println("dXdni"); - // tempMatrix4.print(10, 10); - // tempMatrix5.print(10, 10); - // System.out.println("dXdn "); - // tempMatrix6.print(10, 10); - // int temp2 = 0; - for (int compp = 0; compp < numberOfComponents; compp++) { - for (int kk = 0; kk < getComponent(compp).getNumberOfAssociationSites(); kk++) { - // ((ComponentCPAInterface) getComponent(compp)).setXsitedni(kk, p, -1.0 * - // tempMatrix6.get(temp2 + kk, 0)); - } - // temp2 += getComponent(compp).getNumberOfAssociationSites(); + if (type > 1) { + double tempVar = deltadT[i][j] / delta[i][j]; + double tempVardT = deltadTdT[i][j] / delta[i][j] + - (deltadT[i][j] * deltadT[i][j]) / (delta[i][j] * delta[i][j]); + + if (!Double.isNaN(tempVar)) { + // KlkdT[i][j] = KlkMatrix.getMatrix().unsafe_get(i, j) * tempVar; + // KlkdT[j][i] = KlkdT[i][j]; + + KlkTMatrix2.set(i, j, KlkMatrix2.get(i, j) * tempVar); + KlkTMatrix2.set(j, i, KlkTMatrix2.get(i, j)); + + KlkTVMatrix2.set(i, j, + KlkMatrix2.get(i, j) * tempVar * (gcpav - 1.0 / getTotalVolume())); + KlkTVMatrix2.set(j, i, KlkTVMatrix2.get(i, j)); + + KlkTTMatrix2.set(i, j, KlkMatrix2.get(i, j) * (tempVar * tempVar + tempVardT)); + KlkTTMatrix2.set(j, i, KlkTTMatrix2.get(i, j)); + } + + if (type > 2) { + for (int p = 0; p < numberOfComponents; p++) { + double t1 = 0.0; + double t2 = 0.0; + if (moleculeNumber[i] == p) { + t1 = 1.0 / mVector2.get(i, 0); + } + if (moleculeNumber[j] == p) { + t2 = 1.0 / mVector2.get(j, 0); + } + Klkni[p][i][j] = KlkMatrix2.get(i, j) + * (t1 + t2 + ((ComponentSrkCPA) getComponent(p)).calc_lngi(this)); + Klkni[p][j][i] = Klkni[p][i][j]; } - // assSites += getComponent(p).getNumberOfAssociationSites(); + } } + } + QMatksiksiksi2.set(i, 0, 2.0 * mVector2.get(i, 0) + / (ksiMatrix2.get(i, 0) * ksiMatrix2.get(i, 0) * ksiMatrix2.get(i, 0))); } - /** {@inheritDoc} */ - @Override - public void addcomponent(String componentName, double moles, double molesInPhase, - int compNumber) { - super.addcomponent(componentName, moles, molesInPhase, compNumber); - componentArray[compNumber] = - new ComponentSrkCPA(componentName, moles, molesInPhase, compNumber); - } + MatrixStore ksiMatrixTranspose2 = ksiMatrix2.transpose(); - /** {@inheritDoc} */ - @Override - public double getF() { - return super.getF() + cpaon * FCPA(); - } + // dXdV + MatrixStore KlkVMatrixksi = KlkVMatrix2.multiply(ksiMatrix2); + MatrixStore XV = hessianInvers2.multiply(KlkVMatrixksi); + MatrixStore XVtranspose = XV.transpose(); - /** {@inheritDoc} */ - @Override - public double dFdT() { - return super.dFdT() + cpaon * dFCPAdT(); - } + MatrixStore QCPA = mVector2.transpose() + .multiply(uMatrix2.subtract(ksiMatrix2.multiply(udotMatrix2).multiply(0.5))); + FCPA = QCPA.get(0, 0); - /** {@inheritDoc} */ - @Override - public double dFdTdV() { - return super.dFdTdV() + cpaon * dFCPAdTdV(); - } + MatrixStore tempMatrix = ksiMatrixTranspose2.multiply(KlkVMatrixksi).multiply(-0.5); + dFCPAdV = tempMatrix.get(0, 0); + MatrixStore KlkVVMatrixTImesKsi = KlkVVMatrix2.multiply(ksiMatrix2); + MatrixStore tempMatrixVV = ksiMatrixTranspose2.multiply(KlkVVMatrixTImesKsi) + .multiply(-0.5).subtract(KlkVMatrixksi.transpose().multiply(XV)); + dFCPAdVdV = tempMatrixVV.get(0, 0); - /** {@inheritDoc} */ - @Override - public double dFdV() { - double dv2 = dFCPAdV(); - return super.dFdV() + cpaon * dv2; - } + MatrixStore QVVV = + ksiMatrixTranspose2.multiply(KlkVVVMatrix2.multiply(ksiMatrix2)).multiply(-0.5); + MatrixStore QVVksi = KlkVVMatrixTImesKsi.multiply(-1.0); + MatrixStore QksiVksi = KlkVMatrix2.multiply(-1.0); - // @Override - /** {@inheritDoc} */ - @Override - public double dFdVdV() { - return super.dFdVdV() + cpaon * dFCPAdVdV(); - } + MatrixStore mat1 = QVVksi.transpose().multiply(XV).multiply(3.0); + MatrixStore mat2 = XVtranspose.multiply(QksiVksi.multiply(XV)).multiply(3.0); + MatrixStore mat4 = + XVtranspose.multiply(QMatksiksiksi2.multiply(XVtranspose)).multiply(XV); - /** {@inheritDoc} */ - @Override - public double dFdVdVdV() { - return super.dFdVdVdV() + cpaon * dFCPAdVdVdV(); - } + MatrixStore dFCPAdVdVdVMatrix = QVVV.add(mat1).add(mat2).add(mat2).add(mat4); + dFCPAdVdVdV = dFCPAdVdVdVMatrix.get(0, 0); + temp = 0; - /** {@inheritDoc} */ - @Override - public double dFdTdT() { - return super.dFdTdT() + cpaon * dFCPAdTdT(); + if (type == 1) { + return; } - - /** - *

- * FCPA. - *

- * - * @return a double - */ - public double FCPA() { - /* - * double tot = 0.0; double ans = 0.0; for (int i = 0; i < numberOfComponents; i++) { tot = - * 0.0; for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { double xai - * = ((ComponentSrkCPA) getComponent(i)).getXsite()[j]; tot += (Math.log(xai) - 1.0 / 2.0 * - * xai + 1.0 / 2.0); } ans += getComponent(i).getNumberOfMolesInPhase() * tot; } return ans; - */ - return FCPA; + for (int p = 0; p < numberOfComponents; p++) { + for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { + ((ComponentCPAInterface) getComponent(p)).setXsitedV(kk, XV.get(temp + kk, 0)); + } + temp += getComponent(p).getNumberOfAssociationSites(); } - /** - *

- * dFCPAdV. - *

- * - * @return a double - */ - public double dFCPAdV() { - // return 1.0 / (2.0 * getTotalVolume()) * (1.0 - getTotalVolume() * getGcpav()) - // * hcpatot; - return dFCPAdV; + // KlkTMatrix = new SimpleMatrix(KlkdT); + MatrixStore KlkTMatrixTImesKsi = KlkTMatrix2.multiply(ksiMatrix2); + // dQdT + MatrixStore tempMatrix2 = + ksiMatrixTranspose2.multiply(KlkTMatrixTImesKsi).multiply(-0.5); + dFCPAdT = tempMatrix2.get(0, 0); + + // SimpleMatrix KlkTVMatrix = new SimpleMatrix(KlkdTdV); + // SimpleMatrix tempMatrixTV = + // ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5).minus(KlkTMatrixTImesKsi.transpose().mult(XV)); + // dFCPAdTdV = tempMatrixTV.get(0, 0); + // dXdT + MatrixStore XT = hessianInvers2.multiply(KlkTMatrixTImesKsi); + // dQdTdT + MatrixStore tempMatrixTT = + ksiMatrixTranspose2.multiply(KlkTTMatrix2.multiply(ksiMatrix2)).multiply(-0.5) + .subtract(KlkTMatrixTImesKsi.transpose().multiply(XT)); + dFCPAdTdT = tempMatrixTT.get(0, 0); + + MatrixStore tempMatrixTV = + ksiMatrixTranspose2.multiply(KlkTVMatrix2.multiply(ksiMatrix2)).multiply(-0.5) + .subtract(KlkTMatrixTImesKsi.transpose().multiply(XV)); + dFCPAdTdV = tempMatrixTV.get(0, 0); + + temp = 0; + for (int p = 0; p < numberOfComponents; p++) { + for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { + ((ComponentCPAInterface) getComponent(p)).setXsitedT(kk, XT.get(temp + kk, 0)); + } + temp += getComponent(p).getNumberOfAssociationSites(); } - /** - *

- * dFCPAdVdV. - *

- * - * @return a double - */ - public double dFCPAdVdV() { - // double sum1 = -1.0 / 2.0 * gcpavv * hcpatot; - // return -1.0 / getTotalVolume() * dFCPAdV() + sum1; - return dFCPAdVdV; + if (type == 2) { + return; } - /** - *

- * dFCPAdVdVdV. - *

- * - * @return a double - */ - public double dFCPAdVdVdV() { - return dFCPAdVdVdV; - // return -1.0 / getTotalVolume() * dFCPAdVdV() + 1.0 / - // Math.pow(getTotalVolume(), 2.0) * dFCPAdV() - hcpatot / (2.0 * - // Math.pow(getTotalVolume(), 2.0)) * (-getGcpav() - getTotalVolume() * gcpavv) - // + hcpatot / (2.0 * getTotalVolume()) * (-gcpavv - getTotalVolume() * gcpavvv - // - gcpavv); + // int assSites = 0; + // if(true) return; + for (int p = 0; p < numberOfComponents; p++) { + // MatrixStore KiMatrix = PrimitiveDenseStore.FACTORY.rows(Klkni[p]); + // MatrixStore KiMatrix = new SimpleMatrix(Klkni[p]); + // KiMatrix.print(10,10); + + // Matrix dQdniMatrix = + // (ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5)); // this + // methods misses one part of .... + // dQdniMatrix.print(10,10); + // KiMatrix.print(10, 10); + // miMatrix.getMatrix(assSites, assSites, 0, totalNumberOfAccociationSites - + // 1).print(10, 10); + // Matrix tempMatrix20 = miMatrix.getMatrix(assSites, assSites, 0, + // totalNumberOfAccociationSites - + // 1).times(uMatrix).minus(ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5));// + // ksiMatrix.transpose().times(KlkTMatrix.times(ksiMatrix)).times(-0.5); + // System.out.println("dQdn "); + // tempMatrix20.print(10, 10); + // SimpleMatrix tempMatrix4 = KiMatrix.multiply(ksiMatrix); + // udotTimesmiMatrix.getMatrix(assSites, assSites, 0, + // totalNumberOfAccociationSites - 1).print(10, 10); + // SimpleMatrix tempMatrix5 = udotTimesmiMatrix2.extractVector(true, + // p).transpose().minus(tempMatrix4); + // tempMki[0] = mki[p]; + // Matrix amatrix = new Matrix(croeneckerProduct(tempMki, + // udotMatrix.getArray())); + // System.out.println("aMatrix "); + // amatrix.transpose().print(10, 10); + // System.out.println("temp4 matrix"); + // tempMatrix4.print(10, 10); + // Matrix tempMatrix5 = amatrix.minus(tempMatrix4); + // SimpleMatrix tempMatrix6 = hessianInvers.mult(tempMatrix5);//.scale(-1.0); + // System.out.println("dXdni"); + // tempMatrix4.print(10, 10); + // tempMatrix5.print(10, 10); + // System.out.println("dXdn "); + // tempMatrix6.print(10, 10); + // int temp2 = 0; + for (int compp = 0; compp < numberOfComponents; compp++) { + for (int kk = 0; kk < getComponent(compp).getNumberOfAssociationSites(); kk++) { + // ((ComponentCPAInterface) getComponent(compp)).setXsitedni(kk, p, -1.0 * + // tempMatrix6.get(temp2 + kk, 0)); + } + // temp2 += getComponent(compp).getNumberOfAssociationSites(); + } + // assSites += getComponent(p).getNumberOfAssociationSites(); } - - /** - *

- * dFCPAdT. - *

- * - * @return a double + } + + /** {@inheritDoc} */ + @Override + public void addcomponent(String componentName, double moles, double molesInPhase, + int compNumber) { + super.addcomponent(componentName, moles, molesInPhase, compNumber); + componentArray[compNumber] = + new ComponentSrkCPA(componentName, moles, molesInPhase, compNumber); + } + + /** {@inheritDoc} */ + @Override + public double getF() { + return super.getF() + cpaon * FCPA(); + } + + /** {@inheritDoc} */ + @Override + public double dFdT() { + return super.dFdT() + cpaon * dFCPAdT(); + } + + /** {@inheritDoc} */ + @Override + public double dFdTdV() { + return super.dFdTdV() + cpaon * dFCPAdTdV(); + } + + /** {@inheritDoc} */ + @Override + public double dFdV() { + double dv2 = dFCPAdV(); + return super.dFdV() + cpaon * dv2; + } + + // @Override + /** {@inheritDoc} */ + @Override + public double dFdVdV() { + return super.dFdVdV() + cpaon * dFCPAdVdV(); + } + + /** {@inheritDoc} */ + @Override + public double dFdVdVdV() { + return super.dFdVdVdV() + cpaon * dFCPAdVdVdV(); + } + + /** {@inheritDoc} */ + @Override + public double dFdTdT() { + return super.dFdTdT() + cpaon * dFCPAdTdT(); + } + + /** + *

+ * FCPA. + *

+ * + * @return a double + */ + public double FCPA() { + /* + * double tot = 0.0; double ans = 0.0; for (int i = 0; i < numberOfComponents; i++) { tot = 0.0; + * for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { double xai = + * ((ComponentSrkCPA) getComponent(i)).getXsite()[j]; tot += (Math.log(xai) - 1.0 / 2.0 * xai + + * 1.0 / 2.0); } ans += getComponent(i).getNumberOfMolesInPhase() * tot; } return ans; */ - public double dFCPAdT() { - /* - * double tot = 0.0; double ans = 0.0; for (int i = 0; i < numberOfComponents; i++) { tot = - * 0.0; for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { double xai - * = ((ComponentSrkCPA) getComponent(i)).getXsite()[j]; double xaidT = ((ComponentSrkCPA) - * getComponent(i)).getXsitedT()[j]; tot += 1.0 / xai * xaidT - 0.5 * xaidT;// - 1.0 / 2.0 * - * xai + 1.0 / 2.0); } ans += getComponent(i).getNumberOfMolesInPhase() * tot; } - * System.out.println("dFCPAdT1 " + ans + " dfcpa2 " +dFCPAdT); return ans; - */ - return dFCPAdT; - } - - /** - *

- * dFCPAdTdT. - *

- * - * @return a double + return FCPA; + } + + /** + *

+ * dFCPAdV. + *

+ * + * @return a double + */ + public double dFCPAdV() { + // return 1.0 / (2.0 * getTotalVolume()) * (1.0 - getTotalVolume() * getGcpav()) + // * hcpatot; + return dFCPAdV; + } + + /** + *

+ * dFCPAdVdV. + *

+ * + * @return a double + */ + public double dFCPAdVdV() { + // double sum1 = -1.0 / 2.0 * gcpavv * hcpatot; + // return -1.0 / getTotalVolume() * dFCPAdV() + sum1; + return dFCPAdVdV; + } + + /** + *

+ * dFCPAdVdVdV. + *

+ * + * @return a double + */ + public double dFCPAdVdVdV() { + return dFCPAdVdVdV; + // return -1.0 / getTotalVolume() * dFCPAdVdV() + 1.0 / + // Math.pow(getTotalVolume(), 2.0) * dFCPAdV() - hcpatot / (2.0 * + // Math.pow(getTotalVolume(), 2.0)) * (-getGcpav() - getTotalVolume() * gcpavv) + // + hcpatot / (2.0 * getTotalVolume()) * (-gcpavv - getTotalVolume() * gcpavvv + // - gcpavv); + } + + /** + *

+ * dFCPAdT. + *

+ * + * @return a double + */ + public double dFCPAdT() { + /* + * double tot = 0.0; double ans = 0.0; for (int i = 0; i < numberOfComponents; i++) { tot = 0.0; + * for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { double xai = + * ((ComponentSrkCPA) getComponent(i)).getXsite()[j]; double xaidT = ((ComponentSrkCPA) + * getComponent(i)).getXsitedT()[j]; tot += 1.0 / xai * xaidT - 0.5 * xaidT;// - 1.0 / 2.0 * xai + * + 1.0 / 2.0); } ans += getComponent(i).getNumberOfMolesInPhase() * tot; } + * System.out.println("dFCPAdT1 " + ans + " dfcpa2 " +dFCPAdT); return ans; */ - public double dFCPAdTdT() { - return dFCPAdTdT; - } - - /** - *

- * dFCPAdTdV. - *

- * - * @return a double + return dFCPAdT; + } + + /** + *

+ * dFCPAdTdT. + *

+ * + * @return a double + */ + public double dFCPAdTdT() { + return dFCPAdTdT; + } + + /** + *

+ * dFCPAdTdV. + *

+ * + * @return a double + */ + public double dFCPAdTdV() { + // System.out.println("dFCPAdTdV1 " + dFCPAdTdV + " dFCPAdTdV " +( 1.0 / (2.0 * + // getTotalVolume()) * (1.0 - getTotalVolume() * getGcpav()) * hcpatotdT)); + return dFCPAdTdV; + /* + * if (totalNumberOfAccociationSites > 0) { return 1.0 / (2.0 * getTotalVolume()) * (1.0 - + * getTotalVolume() * getGcpav()) * hcpatotdT; } else { return 0; } */ - public double dFCPAdTdV() { - // System.out.println("dFCPAdTdV1 " + dFCPAdTdV + " dFCPAdTdV " +( 1.0 / (2.0 * - // getTotalVolume()) * (1.0 - getTotalVolume() * getGcpav()) * hcpatotdT)); - return dFCPAdTdV; - /* - * if (totalNumberOfAccociationSites > 0) { return 1.0 / (2.0 * getTotalVolume()) * (1.0 - - * getTotalVolume() * getGcpav()) * hcpatotdT; } else { return 0; } - */ + } + + /** + *

+ * calc_hCPA. + *

+ * + * @return a double + */ + public double calc_hCPA() { + double htot = 0.0; + double tot = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + htot = 0.0; + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + htot += (1.0 - ((ComponentSrkCPA) getComponent(i)).getXsite()[j]); + } + tot += getComponent(i).getNumberOfMolesInPhase() * htot; } - - /** - *

- * calc_hCPA. - *

- * - * @return a double - */ - public double calc_hCPA() { - double htot = 0.0; - double tot = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - htot = 0.0; - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - htot += (1.0 - ((ComponentSrkCPA) getComponent(i)).getXsite()[j]); - } - tot += getComponent(i).getNumberOfMolesInPhase() * htot; - } - return tot; + return tot; + } + + /** + *

+ * calc_g. + *

+ * + * @return a double + */ + public double calc_g() { + double temp = 1.0 - getb() / 4.0 / getMolarVolume(); + double g = (2.0 - getb() / 4.0 / getMolarVolume()) / (2.0 * temp * temp * temp); + return g; + } + + /** + *

+ * calc_lngV. + *

+ * + * @return a double + */ + public double calc_lngV() { + double gv2 = 0.0; + // gv = -2.0 * getB() * (10.0 * getTotalVolume() - getB()) / getTotalVolume() / + // ((8.0 * getTotalVolume() - getB()) * (4.0 * getTotalVolume() - getB())); + + gv2 = 1.0 / (2.0 - getB() / (4.0 * getTotalVolume())) * getB() + / (4.0 * getTotalVolume() * getTotalVolume()) + - 3.0 / (1.0 - getB() / (4.0 * getTotalVolume())) * getB() + / (4.0 * getTotalVolume() * getTotalVolume()); + return gv2; + } + + /** + *

+ * calc_lngVV. + *

+ * + * @return a double + */ + public double calc_lngVV() { + double gvv = 2.0 + * (640.0 * Math.pow(getTotalVolume(), 3.0) + - 216.0 * getB() * getTotalVolume() * getTotalVolume() + + 24.0 * Math.pow(getB(), 2.0) * getTotalVolume() - Math.pow(getB(), 3.0)) + * getB() / (getTotalVolume() * getTotalVolume()) + / Math.pow(8.0 * getTotalVolume() - getB(), 2.0) + / Math.pow(4.0 * getTotalVolume() - getB(), 2.0); + return gvv; + } + + /** + *

+ * calc_lngVVV. + *

+ * + * @return a double + */ + public double calc_lngVVV() { + double gvvv = 4.0 + * (Math.pow(getB(), 5.0) + 17664.0 * Math.pow(getTotalVolume(), 4.0) * getB() + - 4192.0 * Math.pow(getTotalVolume(), 3.0) * Math.pow(getB(), 2.0) + + 528.0 * Math.pow(getB(), 3.0) * getTotalVolume() * getTotalVolume() + - 36.0 * getTotalVolume() * Math.pow(getB(), 4.0) + - 30720.0 * Math.pow(getTotalVolume(), 5.0)) + * getB() / (Math.pow(getTotalVolume(), 3.0)) + / Math.pow(-8.0 * getTotalVolume() + getB(), 3.0) + / Math.pow(-4.0 * getTotalVolume() + getB(), 3.0); + return gvvv; + } + + /** + *

+ * calcXsitedV. + *

+ */ + public void calcXsitedV() { + if (getTotalNumberOfAccociationSites() > 0) { + initCPAMatrix(1); } - - /** - *

- * calc_g. - *

- * - * @return a double - */ - public double calc_g() { - double temp = 1.0 - getb() / 4.0 / getMolarVolume(); - double g = (2.0 - getb() / 4.0 / getMolarVolume()) / (2.0 * temp * temp * temp); - return g; + } + + /** + *

+ * solveX. + *

+ * + * @return a boolean + */ + public boolean solveX() { + if (getTotalNumberOfAccociationSites() == 0) { + return true; } - /** - *

- * calc_lngV. - *

- * - * @return a double - */ - public double calc_lngV() { - double gv2 = 0.0; - // gv = -2.0 * getB() * (10.0 * getTotalVolume() - getB()) / getTotalVolume() / - // ((8.0 * getTotalVolume() - getB()) * (4.0 * getTotalVolume() - getB())); - - gv2 = 1.0 / (2.0 - getB() / (4.0 * getTotalVolume())) * getB() - / (4.0 * getTotalVolume() * getTotalVolume()) - - 3.0 / (1.0 - getB() / (4.0 * getTotalVolume())) * getB() - / (4.0 * getTotalVolume() * getTotalVolume()); - return gv2; + boolean solvedX = solveX2(5); + if (solvedX) { + // return true; } - /** - *

- * calc_lngVV. - *

- * - * @return a double - */ - public double calc_lngVV() { - double gvv = 2.0 - * (640.0 * Math.pow(getTotalVolume(), 3.0) - - 216.0 * getB() * getTotalVolume() * getTotalVolume() - + 24.0 * Math.pow(getB(), 2.0) * getTotalVolume() - Math.pow(getB(), 3.0)) - * getB() / (getTotalVolume() * getTotalVolume()) - / Math.pow(8.0 * getTotalVolume() - getB(), 2.0) - / Math.pow(4.0 * getTotalVolume() - getB(), 2.0); - return gvv; + // SparseStore mat1 = KlkMatrix2; + // SparseStore mat2 = ksiMatrix2; + // second order method not working correctly and not used t the moment b ecause + // of numerical stability + int temp = 0; + int iter = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + mVector2.set(temp + j, 0, getComponent(i).getNumberOfMolesInPhase()); + } + temp += getComponent(i).getNumberOfAssociationSites(); } - - /** - *

- * calc_lngVVV. - *

- * - * @return a double - */ - public double calc_lngVVV() { - double gvvv = 4.0 - * (Math.pow(getB(), 5.0) + 17664.0 * Math.pow(getTotalVolume(), 4.0) * getB() - - 4192.0 * Math.pow(getTotalVolume(), 3.0) * Math.pow(getB(), 2.0) - + 528.0 * Math.pow(getB(), 3.0) * getTotalVolume() * getTotalVolume() - - 36.0 * getTotalVolume() * Math.pow(getB(), 4.0) - - 30720.0 * Math.pow(getTotalVolume(), 5.0)) - * getB() / (Math.pow(getTotalVolume(), 3.0)) - / Math.pow(-8.0 * getTotalVolume() + getB(), 3.0) - / Math.pow(-4.0 * getTotalVolume() + getB(), 3.0); - return gvvv; + double Klk = 0.0; + double totvolume = getTotalVolume(); + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + Klk = mVector2.get(i, 0) * mVector2.get(j, 0) / totvolume * delta[i][j]; + KlkMatrix2.set(i, j, Klk); + KlkMatrix2.set(j, i, Klk); + } } - - /** - *

- * calcXsitedV. - *

- */ - public void calcXsitedV() { - if (getTotalNumberOfAccociationSites() > 0) { - initCPAMatrix(1); + boolean solved = true; + // SimpleMatrix corrMatrix = null; + do { + solved = true; + iter++; + temp = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + ksiMatrix2.set(temp + j, 0, ((ComponentSrkCPA) getComponent(i)).getXsite()[j]); + // ksiMatrix.getMatrix().unsafe_set(temp + j, 0, + // ksiMatrix.getMatrix().unsafe_get(temp + j, 0)); + udotMatrix2.set(temp + j, 0, 1.0 / ksiMatrix2.get(temp + j, 0) - 1.0); + udotTimesmMatrix2.set(temp + j, 0, + mVector2.get(temp + j, 0) * udotMatrix2.get(temp + j, 0)); } - } - - /** - *

- * solveX. - *

- * - * @return a boolean - */ - public boolean solveX() { - if (getTotalNumberOfAccociationSites() == 0) { - return true; + temp += getComponent(i).getNumberOfAssociationSites(); + } + + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + int krondelt = 0; + if (i == j) { + krondelt = 1; + } + hessianMatrix2.set(i, j, + -mVector2.get(i, 0) / (ksiMatrix2.get(i, 0) * ksiMatrix2.get(i, 0)) * krondelt + - KlkMatrix2.get(i, j)); + hessianMatrix2.set(j, i, hessianMatrix2.get(i, j)); } - - boolean solvedX = solveX2(5); - if (solvedX) { - // return true; + } + + // ksiMatrix = new SimpleMatrix(ksi); + // SimpleMatrix hessianMatrix = new SimpleMatrix(hessian); + // PrimitiveMatrix input = PrimitiveMatrix.FACTORY.rows(hessianMatrix2); + // PrimitiveMatrix hessianInvers2; + try { + // hessianInvers2 = input.invert(); + } catch (Exception e) { + logger.error("error", e); + return false; + } + + // MatrixStore corr2Matrix2 = mat1.multiply(mat2); + // corr2Matrix2 = mat1.multiply(mat2);//gcpa)CommonOps_DDRM.mult(mat1, mat2, + // corr2Matrix); + // MatrixStore corr3Matrix = udotTimesmMatrix2.subtract(corr2Matrix2); + // PrimitiveMatrix corr4Matrix = hessianInvers2.multiply(corr3Matrix); + // CommonOps_DDRM.subtract(udotTimesmMatrix.getDDRM(), corr2Matrix, + // corr3Matrix); + // CommonOps_DDRM.mult(hessianInvers.getDDRM(), corr3Matrix, corr4Matrix); + // SimpleMatrix gMatrix = udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)); + // corrMatrix = + // hessianInvers.mult(udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)));//.scale(-1.0); + temp = 0; + // System.out.println("print SimpleMatrix ..."); + // corrMatrix.print(10, 10); + // SimpleMatrix simp = new SimpleMatrix(corr4Matrix); + // System.out.println("print CommonOps ..."); + // simp.print(10,10); + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + double newX = ksiMatrix2.get(temp + j, 0) - corr4Matrix2.get((temp + j), 0); + if (newX < 0) { + newX = 1e-10; + solved = false; + } + ((ComponentCPAInterface) getComponent(i)).setXsite(j, newX); } - - // SparseStore mat1 = KlkMatrix2; - // SparseStore mat2 = ksiMatrix2; - // second order method not working correctly and not used t the moment b ecause - // of numerical stability - int temp = 0, iter = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - mVector2.set(temp + j, 0, getComponent(i).getNumberOfMolesInPhase()); - } - temp += getComponent(i).getNumberOfAssociationSites(); + temp += getComponent(i).getNumberOfAssociationSites(); + } + // System.out.println("corrmatrix error " ); + // System.out.println("error " + corrMatrix.norm1()); + } while ((corr4Matrix2.norm() > 1e-12 || !solved) && iter < 100); + + // System.out.println("iter " + iter + " error " + NormOps.normF(corr4Matrix)); + // // corrMatrix.print(10, 10); + // ksiMatrix.print(10, 10); + return true; + } + + /** + *

+ * solveX2. + *

+ * + * @param maxIter a int + * @return a boolean + */ + public boolean solveX2(int maxIter) { + double err = .0; + int iter = 0; + // if (delta == null) { + // initCPAMatrix(1); + double old = 0.0; + double neeval = 0.0; + // } + do { + iter++; + err = 0.0; + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + old = ((ComponentSrkCPA) getComponent(moleculeNumber[i])).getXsite()[assSiteNumber[i]]; + neeval = 0; + for (int j = 0; j < getTotalNumberOfAccociationSites(); j++) { + neeval += getComponent(moleculeNumber[j]).getNumberOfMolesInPhase() * delta[i][j] + * ((ComponentSrkCPA) getComponent(moleculeNumber[j])).getXsite()[assSiteNumber[j]]; } - double Klk = 0.0; - double totvolume = getTotalVolume(); - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - Klk = mVector2.get(i, 0) * mVector2.get(j, 0) / totvolume * delta[i][j]; - KlkMatrix2.set(i, j, Klk); - KlkMatrix2.set(j, i, Klk); - } + neeval = 1.0 / (1.0 + 1.0 / getTotalVolume() * neeval); + ((ComponentCPAInterface) getComponent(moleculeNumber[i])).setXsite(assSiteNumber[i], + neeval); + err += Math.abs((old - neeval) / neeval); + } + } while (Math.abs(err) > 1e-10 && iter < maxIter); + // System.out.println("iter " + iter); + // if (Math.abs(err) + // < 1e-12) { + // return true; + // } else { + // System.out.println("did not solve for Xi in iterations: " + iter); + // System.out.println("error: " + err); + return false; + } + + /** {@inheritDoc} */ + @Override + public double getHcpatot() { + return hcpatot; + } + + /** + * Setter for property hcpatot. + * + * @param hcpatot New value of property hcpatot. + */ + public void setHcpatot(double hcpatot) { + this.hcpatot = hcpatot; + } + + /** {@inheritDoc} */ + @Override + public double getGcpa() { + return gcpa; + } + + /** + *

+ * calcRootVolFinder. + *

+ * + * @param phase a int + * @return a double + */ + public double calcRootVolFinder(int phase) { + double solvedBonVHigh = 0.0; + double solvedBonVlow = 1.0; + double oldh = 1; + // double[][] matrix = new double[2][2000]; + double BonV = 1.0 - 1e-10; + try { + // molarVolume(pressure, temperature, A, B, phaseType); + } catch (Exception e) { + logger.error("error", e); + } + double BonVold = BonV; + double Btemp = 0; + double h = 1; + // double Dtemp = 0, dh = 0, gvvv = 0, fvvv = 0, dhh = 0, d1 = 0, d2 = 0; + Btemp = getB(); + // Dtemp = getA(); + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + for (int i = 0; i < 2000; i++) { + BonVold = BonV; + BonV = 1.0 - (i + 1e-6) * 1.0 / 2000.0; + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); + gcpa = calc_g(); + // lngcpa = + // Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); + + do { + } while (!solveX()); + + h = BonV - Btemp / numberOfMolesInPhase * dFdV() + - pressure * Btemp / (numberOfMolesInPhase * R * temperature); + + if (Math.signum(h) * Math.signum(oldh) < 0 && i > 2) { + if (solvedBonVlow < 1e-3) { + solvedBonVlow = (BonV + BonVold) / 2.0; + if (phase == 1) { + break; + } + } else { + solvedBonVHigh = (BonV + BonVold) / 2.0; + if (phase == 0) { + break; + } } - boolean solved = true; - // SimpleMatrix corrMatrix = null; - do { - solved = true; - iter++; - temp = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - ksiMatrix2.set(temp + j, 0, ((ComponentSrkCPA) getComponent(i)).getXsite()[j]); - // ksiMatrix.getMatrix().unsafe_set(temp + j, 0, - // ksiMatrix.getMatrix().unsafe_get(temp + j, 0)); - udotMatrix2.set(temp + j, 0, 1.0 / ksiMatrix2.get(temp + j, 0) - 1.0); - udotTimesmMatrix2.set(temp + j, 0, - mVector2.get(temp + j, 0) * udotMatrix2.get(temp + j, 0)); - } - temp += getComponent(i).getNumberOfAssociationSites(); - } - - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - int krondelt = 0; - if (i == j) { - krondelt = 1; - } - hessianMatrix2.set(i, j, - -mVector2.get(i, 0) / (ksiMatrix2.get(i, 0) * ksiMatrix2.get(i, 0)) - * krondelt - KlkMatrix2.get(i, j)); - hessianMatrix2.set(j, i, hessianMatrix2.get(i, j)); - } - } - - // ksiMatrix = new SimpleMatrix(ksi); - // SimpleMatrix hessianMatrix = new SimpleMatrix(hessian); - // PrimitiveMatrix input = PrimitiveMatrix.FACTORY.rows(hessianMatrix2); - // PrimitiveMatrix hessianInvers2; - try { - // hessianInvers2 = input.invert(); - } catch (Exception e) { - logger.error("error", e); - return false; - } - - // MatrixStore corr2Matrix2 = mat1.multiply(mat2); - // corr2Matrix2 = mat1.multiply(mat2);//gcpa)CommonOps_DDRM.mult(mat1, mat2, - // corr2Matrix); - // MatrixStore corr3Matrix = udotTimesmMatrix2.subtract(corr2Matrix2); - // PrimitiveMatrix corr4Matrix = hessianInvers2.multiply(corr3Matrix); - // CommonOps_DDRM.subtract(udotTimesmMatrix.getDDRM(), corr2Matrix, - // corr3Matrix); - // CommonOps_DDRM.mult(hessianInvers.getDDRM(), corr3Matrix, corr4Matrix); - // SimpleMatrix gMatrix = udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)); - // corrMatrix = - // hessianInvers.mult(udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)));//.scale(-1.0); - temp = 0; - // System.out.println("print SimpleMatrix ..."); - // corrMatrix.print(10, 10); - // SimpleMatrix simp = new SimpleMatrix(corr4Matrix); - // System.out.println("print CommonOps ..."); - // simp.print(10,10); - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - double newX = ksiMatrix2.get(temp + j, 0) - corr4Matrix2.get((temp + j), 0); - if (newX < 0) { - newX = 1e-10; - solved = false; - } - ((ComponentCPAInterface) getComponent(i)).setXsite(j, newX); - } - temp += getComponent(i).getNumberOfAssociationSites(); - } - // System.out.println("corrmatrix error " ); - // System.out.println("error " + corrMatrix.norm1()); - } while ((corr4Matrix2.norm() > 1e-12 || !solved) && iter < 100); - - // System.out.println("iter " + iter + " error " + NormOps.normF(corr4Matrix)); - // // corrMatrix.print(10, 10); - // ksiMatrix.print(10, 10); - return true; + } + solvedBonVHigh = (BonV + BonVold) / 2.0; + oldh = h; + // matrix[0][i] = BonV; + // matrix[1][i] = h; } - - /** - *

- * solveX2. - *

- * - * @param maxIter a int - * @return a boolean - */ - public boolean solveX2(int maxIter) { - double err = .0; - int iter = 0; - // if (delta == null) { - // initCPAMatrix(1); - double old = 0.0, neeval = 0.0; - // } - do { - iter++; - err = 0.0; - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - old = ((ComponentSrkCPA) getComponent(moleculeNumber[i])) - .getXsite()[assSiteNumber[i]]; - neeval = 0; - for (int j = 0; j < getTotalNumberOfAccociationSites(); j++) { - neeval += getComponent(moleculeNumber[j]).getNumberOfMolesInPhase() - * delta[i][j] * ((ComponentSrkCPA) getComponent(moleculeNumber[j])) - .getXsite()[assSiteNumber[j]]; - } - neeval = 1.0 / (1.0 + 1.0 / getTotalVolume() * neeval); - ((ComponentCPAInterface) getComponent(moleculeNumber[i])).setXsite(assSiteNumber[i], - neeval); - err += Math.abs((old - neeval) / neeval); - } - } while (Math.abs(err) > 1e-10 && iter < maxIter); - // System.out.println("iter " + iter); - // if (Math.abs(err) - // < 1e-12) { - // return true; - // } else { - // System.out.println("did not solve for Xi in iterations: " + iter); - // System.out.println("error: " + err); - return false; + if (solvedBonVlow < 1e-3) { + solvedBonVlow = solvedBonVHigh; } - - /** {@inheritDoc} */ - @Override - public double getHcpatot() { - return hcpatot; + // dataPresentation.fileHandeling.createTextFile.TextFile file = new + // dataPresentation.fileHandeling.createTextFile.TextFile(); + // file.setValues(matrix); + // file.setOutputFileName("D:/temp/temp2.txt"); + // file.createFile(); + if (phase == 1) { + return solvedBonVlow; + } else { + return solvedBonVHigh; } - - /** - * Setter for property hcpatot. - * - * @param hcpatot New value of property hcpatot. - */ - public void setHcpatot(double hcpatot) { - this.hcpatot = hcpatot; + } + + /** {@inheritDoc} */ + @Override + public double molarVolume(double pressure, double temperature, double A, double B, int phasetype) + throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + // if (pressure > 1000) { + // BonV = 0.9999; + // } + + // double calcRooBonVtVolFinder = calcRootVolFinder(phasetype); + // BonV = calcRooBonVtVolFinder; + // double BonVInit = BonV; + if (BonV < 0) { + BonV = 1.0e-8; } - /** {@inheritDoc} */ - @Override - public double getGcpa() { - return gcpa; + if (BonV >= 1.0) { + BonV = 0.9999; } - - /** - *

- * calcRootVolFinder. - *

- * - * @param phase a int - * @return a double - */ - public double calcRootVolFinder(int phase) { - double solvedBonVHigh = 0.0; - double solvedBonVlow = 1.0; - double oldh = 1; - // double[][] matrix = new double[2][2000]; - double BonV = 1.0 - 1e-10; - try { - // molarVolume(pressure, temperature, A, B, phaseType); - } catch (Exception e) { - logger.error("error", e); - } - double BonVold = BonV; - double Btemp = 0, h = 1; - // double Dtemp = 0, dh = 0, gvvv = 0, fvvv = 0, dhh = 0, d1 = 0, d2 = 0; - Btemp = getB(); - // Dtemp = getA(); - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - for (int i = 0; i < 2000; i++) { - BonVold = BonV; - BonV = 1.0 - (i + 1e-6) * 1.0 / 2000.0; - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - gcpa = calc_g(); - // lngcpa = - // Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - - do { - } while (!solveX()); - - h = BonV - Btemp / numberOfMolesInPhase * dFdV() - - pressure * Btemp / (numberOfMolesInPhase * R * temperature); - - if (Math.signum(h) * Math.signum(oldh) < 0 && i > 2) { - if (solvedBonVlow < 1e-3) { - solvedBonVlow = (BonV + BonVold) / 2.0; - if (phase == 1) { - break; - } - } else { - solvedBonVHigh = (BonV + BonVold) / 2.0; - if (phase == 0) { - break; - } - } - } - solvedBonVHigh = (BonV + BonVold) / 2.0; - oldh = h; - // matrix[0][i] = BonV; - // matrix[1][i] = h; - } - if (solvedBonVlow < 1e-3) { - solvedBonVlow = solvedBonVHigh; - } - // dataPresentation.fileHandeling.createTextFile.TextFile file = new - // dataPresentation.fileHandeling.createTextFile.TextFile(); - // file.setValues(matrix); - // file.setOutputFileName("D:/temp/temp2.txt"); - // file.createFile(); - if (phase == 1) { - return solvedBonVlow; - } else { - return solvedBonVHigh; - } + double BonVold; + double h = 0; + double dh = 0; + double dhh = 0; + double d1 = 0; + double d2 = 0; + double Btemp = getB(); + if (Btemp < 0) { + logger.info("b negative in volume calc"); } + calcDelta(); - /** {@inheritDoc} */ - @Override - public double molarVolume(double pressure, double temperature, double A, double B, - int phasetype) throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - // if (pressure > 1000) { - // BonV = 0.9999; - // } - - // double calcRooBonVtVolFinder = calcRootVolFinder(phasetype); - // BonV = calcRooBonVtVolFinder; - // double BonVInit = BonV; - if (BonV < 0) { - BonV = 1.0e-8; - } - - if (BonV >= 1.0) { - BonV = 0.9999; - } - double BonVold; - double h = 0, dh = 0, dhh = 0; - double d1 = 0, d2 = 0; - double Btemp = getB(); - if (Btemp < 0) { - logger.info("b negative in volume calc"); - } - calcDelta(); - - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - int iterations = 0; - - do { - iterations++; - gcpa = calc_g(); - if (gcpa < 0) { - setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); - gcpa = calc_g(); - } + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + int iterations = 0; - // lngcpa = - // Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); + do { + iterations++; + gcpa = calc_g(); + if (gcpa < 0) { + setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); + gcpa = calc_g(); + } - if (getTotalNumberOfAccociationSites() > 0) { - solveX(); - } + // lngcpa = + // Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); - initCPAMatrix(1); - double BonV2 = BonV * BonV; - BonVold = BonV; - h = BonV - Btemp / numberOfMolesInPhase * dFdV() - - pressure * Btemp / (numberOfMolesInPhase * R * temperature); - dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); - dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) - - (Btemp * Btemp) / (BonV2 * BonV2) - * (Btemp / numberOfMolesInPhase * dFdVdVdV()); - - d1 = -h / dh; - d2 = -dh / dhh; - // System.out.println("h " + h + " iter " + iterations + " " + d1 + " d2 " + d2 - // + " d1 / d2 " + (d1 / d2)); - if (Math.abs(d1 / d2) <= 1.0) { - BonV += d1 * (1.0 + 0.5 * d1 / d2); - } else if (d1 / d2 < -1) { - BonV += 0.5 * d1; - } else if (d1 > d2) { - BonV += d2; - double hnew = h + d2 * dh; - if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } else { - BonV += 0.5 * d1; - } - if (Math.abs((BonV - BonVold) / BonVold) > 0.1) { - BonV = BonVold + 0.1 * (BonV - BonVold); - } - - if (BonV > 0.9999) { - if (iterations < 3) { - BonV = (BonVold + BonV) / 2.0; - } else { - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - // BonV = 0.9999; - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / - // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * - // temperature * R); - } - } else if (BonV < 0) { - if (iterations < 3) { - BonV = Math.abs(BonVold + BonV) / 2.0; - } else { - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / - // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * - // temperature * R); - } - } - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10 || Math.abs(h) > 1e-12) - && iterations < 100); - - if (Math.abs(h) > 1e-12) { - // System.out.println("h failed " + "Z" + Z + " iterations " + iterations + " - // BonV " + BonV); - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + if (getTotalNumberOfAccociationSites() > 0) { + solveX(); + } + + initCPAMatrix(1); + double BonV2 = BonV * BonV; + BonVold = BonV; + h = BonV - Btemp / numberOfMolesInPhase * dFdV() + - pressure * Btemp / (numberOfMolesInPhase * R * temperature); + dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); + dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) + - (Btemp * Btemp) / (BonV2 * BonV2) * (Btemp / numberOfMolesInPhase * dFdVdVdV()); + + d1 = -h / dh; + d2 = -dh / dhh; + // System.out.println("h " + h + " iter " + iterations + " " + d1 + " d2 " + d2 + // + " d1 / d2 " + (d1 / d2)); + if (Math.abs(d1 / d2) <= 1.0) { + BonV += d1 * (1.0 + 0.5 * d1 / d2); + } else if (d1 / d2 < -1) { + BonV += 0.5 * d1; + } else if (d1 > d2) { + BonV += d2; + double hnew = h + d2 * dh; + if (Math.abs(hnew) > Math.abs(h)) { + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); } - // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); - // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); - // System.out.println("volume " + getTotalVolume() + " molar volume " + - // getMolarVolume()); - // if(iterations>=100) throw new util.exception.TooManyIterationsException(); - // System.out.println("error in volume " + - // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " - // firstterm " + (R*temperature/molarVolume) + " second " + - // R*temperature*dFdV()); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " - // " +dh + " B " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); - - if (Double.isNaN(getMolarVolume())) { - throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " - // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" - // + fVV()); + } else { + BonV += 0.5 * d1; + } + if (Math.abs((BonV - BonVold) / BonVold) > 0.1) { + BonV = BonVold + 0.1 * (BonV - BonVold); + } + + if (BonV > 0.9999) { + if (iterations < 3) { + BonV = (BonVold + BonV) / 2.0; + } else { + // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // BonV = 0.9999; + // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * + // temperature * R); } - return getMolarVolume(); + } else if (BonV < 0) { + if (iterations < 3) { + BonV = Math.abs(BonVold + BonV) / 2.0; + } else { + // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * + // temperature * R); + } + } + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); + } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10 || Math.abs(h) > 1e-12) + && iterations < 100); + + if (Math.abs(h) > 1e-12) { + // System.out.println("h failed " + "Z" + Z + " iterations " + iterations + " + // BonV " + BonV); + // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + } + // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); + // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); + // System.out.println("volume " + getTotalVolume() + " molar volume " + + // getMolarVolume()); + // if(iterations>=100) throw new util.exception.TooManyIterationsException(); + // System.out.println("error in volume " + + // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " + // firstterm " + (R*temperature/molarVolume) + " second " + + // R*temperature*dFdV()); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " + // " +dh + " B " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); + + if (Double.isNaN(getMolarVolume())) { + throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " + // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + // + fVV()); + } + return getMolarVolume(); + } + + /** + *

+ * molarVolumeChangePhase. + *

+ * + * @param pressure a double + * @param temperature a double + * @param A a double + * @param B a double + * @param phasetype a int + * @return a double + * @throws neqsim.util.exception.IsNaNException if any. + * @throws neqsim.util.exception.TooManyIterationsException if any. + */ + public double molarVolumeChangePhase(double pressure, double temperature, double A, double B, + int phasetype) throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + // double BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * + // temperature * R); + double BonV = calcRootVolFinder(phasetype); + // double BonVInit = BonV; + if (BonV < 0) { + BonV = 1.0e-8; } - /** - *

- * molarVolumeChangePhase. - *

- * - * @param pressure a double - * @param temperature a double - * @param A a double - * @param B a double - * @param phasetype a int - * @return a double - * @throws neqsim.util.exception.IsNaNException if any. - * @throws neqsim.util.exception.TooManyIterationsException if any. - */ - public double molarVolumeChangePhase(double pressure, double temperature, double A, double B, - int phasetype) throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - // double BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / - // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * - // temperature * R); - double BonV = calcRootVolFinder(phasetype); - // double BonVInit = BonV; - if (BonV < 0) { - BonV = 1.0e-8; - } + if (BonV >= 1.0) { + BonV = 0.9999; + } + double BonVold = BonV; + double Btemp = 0; + double h = 0; + double dh = 0; + double dhh = 0; + // double gvvv = 0, fvvv = 0; + double d1 = 0; + double d2 = 0; + Btemp = getB(); + if (Btemp < 0) { + logger.info("b negative in volume calc"); + } + calcDelta(); + + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + int iterations = 0; - if (BonV >= 1.0) { - BonV = 0.9999; + do { + iterations++; + gcpa = calc_g(); + if (gcpa < 0) { + setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); + gcpa = calc_g(); + } + + // lngcpa = + // Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); + + solveX(); + + initCPAMatrix(1); + double BonV2 = BonV * BonV; + BonVold = BonV; + h = BonV - Btemp / numberOfMolesInPhase * dFdV() + - pressure * Btemp / (numberOfMolesInPhase * R * temperature); + dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); + dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) + - (Btemp * Btemp) / (BonV2 * BonV2) * (Btemp / numberOfMolesInPhase * dFdVdVdV()); + + d1 = -h / dh; + d2 = -dh / dhh; + // System.out.println("d1" + d1 + " d2 " + d2 + " d1 / d2 " + (d1 / d2)); + if (Math.abs(d1 / d2) <= 1.0) { + BonV += d1 * (1.0 + 0.5 * d1 / d2); + } else if (d1 / d2 < -1) { + BonV += 0.5 * d1; + } else if (d1 > d2) { + BonV += d2; + double hnew = h + d2 * dh; + if (Math.abs(hnew) > Math.abs(h)) { + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); } - double BonVold = BonV; - double Btemp = 0, h = 0, dh = 0, dhh = 0; - // double gvvv = 0, fvvv = 0; - double d1 = 0, d2 = 0; - Btemp = getB(); - if (Btemp < 0) { - logger.info("b negative in volume calc"); + } else { + BonV += 0.5 * d1; + } + if (Math.abs((BonV - BonVold) / BonVold) > 0.1) { + BonV = BonVold + 0.1 * (BonV - BonVold); + } + + if (BonV > 1.1) { + if (iterations < 3) { + BonV = (BonVold + BonV) / 2.0; + } else { + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); } - calcDelta(); + } - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - int iterations = 0; - - do { - iterations++; - gcpa = calc_g(); - if (gcpa < 0) { - setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); - gcpa = calc_g(); - } - - // lngcpa = - // Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - - solveX(); - - initCPAMatrix(1); - double BonV2 = BonV * BonV; - BonVold = BonV; - h = BonV - Btemp / numberOfMolesInPhase * dFdV() - - pressure * Btemp / (numberOfMolesInPhase * R * temperature); - dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); - dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) - - (Btemp * Btemp) / (BonV2 * BonV2) - * (Btemp / numberOfMolesInPhase * dFdVdVdV()); - - d1 = -h / dh; - d2 = -dh / dhh; - // System.out.println("d1" + d1 + " d2 " + d2 + " d1 / d2 " + (d1 / d2)); - if (Math.abs(d1 / d2) <= 1.0) { - BonV += d1 * (1.0 + 0.5 * d1 / d2); - } else if (d1 / d2 < -1) { - BonV += 0.5 * d1; - } else if (d1 > d2) { - BonV += d2; - double hnew = h + d2 * dh; - if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } else { - BonV += 0.5 * d1; - } - if (Math.abs((BonV - BonVold) / BonVold) > 0.1) { - BonV = BonVold + 0.1 * (BonV - BonVold); - } - - if (BonV > 1.1) { - if (iterations < 3) { - BonV = (BonVold + BonV) / 2.0; - } else { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } - - if (BonV < 0) { - if (iterations < 3) { - BonV = Math.abs(BonVold + BonV) / 2.0; - } else { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } - - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - - // System.out.println("Z " + Z + "h " + h + " BONV " + (Math.abs((BonV - - // BonVold) / BonV))); - } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10) && iterations < 100); - - /* - * if (Math.abs(h) > 1e-8) { if (phasetype == 0) { molarVolume(pressure, temperature, A, B, - * 1); } else { molarVolume(pressure, temperature, A, B, 0); } return getMolarVolume(); } - */ - // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); - // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); - // System.out.println("volume " + getTotalVolume() + " molar volume " + - // getMolarVolume()); - // if(iterations>=100) throw new util.exception.TooManyIterationsException(); - // System.out.println("error in volume " + - // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " - // firstterm " + (R*temperature/molarVolume) + " second " + - // R*temperature*dFdV()); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " - // " +dh + " B " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); - if (Double.isNaN(getMolarVolume())) { - throw new neqsim.util.exception.IsNaNException(this, "molarVolumeChangePhase", - "Molar volume"); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " - // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" - // + fVV()); + if (BonV < 0) { + if (iterations < 3) { + BonV = Math.abs(BonVold + BonV) / 2.0; + } else { + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); } + } - return getMolarVolume(); - } - - /** {@inheritDoc} */ - @Override - public double molarVolume2(double pressure, double temperature, double A, double B, int phase) - throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - Z = phase == 0 ? 1.0 : 1.0e-5; - setMolarVolume(Z * R * temperature / pressure); - // super.molarVolume(pressure,temperature, A, B, phase); - int iterations = 0; - double err = 0.0, dErrdV = 0.0; - double deltaV = 0; - - do { - A = calcA(this, temperature, pressure, numberOfComponents); - B = calcB(this, temperature, pressure, numberOfComponents); - - double dFdV = dFdV(), dFdVdV = dFdVdV(); - // double dFdVdVdV = dFdVdVdV(); - // double factor1 = 1.0e0, factor2 = 1.0e0; - err = -R * temperature * dFdV + R * temperature / getMolarVolume() - pressure; - - // System.out.println("pressure " + -R * temperature * dFdV + " " + R * - // temperature / getMolarVolume()); - // -pressure; - dErrdV = -R * temperature * dFdVdV - - R * temperature * numberOfMolesInPhase / Math.pow(getVolume(), 2.0); - - // System.out.println("errdV " + dErrdV); - // System.out.println("err " + err); - deltaV = -err / dErrdV; - - setMolarVolume(getMolarVolume() + deltaV / numberOfMolesInPhase); - - Z = pressure * getMolarVolume() / (R * temperature); - if (Z < 0) { - Z = 1e-6; - setMolarVolume(Z * R * temperature / pressure); - } + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); - // System.out.println("Z " + Z); - } while (Math.abs(err) > 1.0e-8 || iterations < 100); - // System.out.println("Z " + Z); - return getMolarVolume(); - } + // System.out.println("Z " + Z + "h " + h + " BONV " + (Math.abs((BonV - + // BonVold) / BonV))); + } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10) && iterations < 100); - /** {@inheritDoc} */ - @Override - public double getGcpav() { - return gcpav; - } - - /** - *

- * Setter for the field gcpav. - *

- * - * @param gcpav a double + /* + * if (Math.abs(h) > 1e-8) { if (phasetype == 0) { molarVolume(pressure, temperature, A, B, 1); + * } else { molarVolume(pressure, temperature, A, B, 0); } return getMolarVolume(); } */ - public void setGcpav(double gcpav) { - this.gcpav = gcpav; - } - - /** {@inheritDoc} */ - @Override - public CPAMixingInterface getCpamix() { - return cpamix; + // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); + // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); + // System.out.println("volume " + getTotalVolume() + " molar volume " + + // getMolarVolume()); + // if(iterations>=100) throw new util.exception.TooManyIterationsException(); + // System.out.println("error in volume " + + // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " + // firstterm " + (R*temperature/molarVolume) + " second " + + // R*temperature*dFdV()); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " + // " +dh + " B " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); + if (Double.isNaN(getMolarVolume())) { + throw new neqsim.util.exception.IsNaNException(this, "molarVolumeChangePhase", + "Molar volume"); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " + // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + // + fVV()); } - /** {@inheritDoc} */ - @Override - public double calcPressure() { - gcpa = calc_g(); - // lngcpa = - // Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - solveX(); - hcpatot = calc_hCPA(); - - initCPAMatrix(1); - return super.calcPressure(); + return getMolarVolume(); + } + + /** {@inheritDoc} */ + @Override + public double molarVolume2(double pressure, double temperature, double A, double B, int phase) + throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + Z = phase == 0 ? 1.0 : 1.0e-5; + setMolarVolume(Z * R * temperature / pressure); + // super.molarVolume(pressure,temperature, A, B, phase); + int iterations = 0; + double err = 0.0; + double dErrdV = 0.0; + double deltaV = 0; + + do { + A = calcA(this, temperature, pressure, numberOfComponents); + B = calcB(this, temperature, pressure, numberOfComponents); + + double dFdV = dFdV(); + double dFdVdV = dFdVdV(); + // double dFdVdVdV = dFdVdVdV(); + // double factor1 = 1.0e0, factor2 = 1.0e0; + err = -R * temperature * dFdV + R * temperature / getMolarVolume() - pressure; + + // System.out.println("pressure " + -R * temperature * dFdV + " " + R * + // temperature / getMolarVolume()); + // -pressure; + dErrdV = -R * temperature * dFdVdV + - R * temperature * numberOfMolesInPhase / Math.pow(getVolume(), 2.0); + + // System.out.println("errdV " + dErrdV); + // System.out.println("err " + err); + deltaV = -err / dErrdV; + + setMolarVolume(getMolarVolume() + deltaV / numberOfMolesInPhase); + + Z = pressure * getMolarVolume() / (R * temperature); + if (Z < 0) { + Z = 1e-6; + setMolarVolume(Z * R * temperature / pressure); + } + + // System.out.println("Z " + Z); + } while (Math.abs(err) > 1.0e-8 || iterations < 100); + // System.out.println("Z " + Z); + return getMolarVolume(); + } + + /** {@inheritDoc} */ + @Override + public double getGcpav() { + return gcpav; + } + + /** + *

+ * Setter for the field gcpav. + *

+ * + * @param gcpav a double + */ + public void setGcpav(double gcpav) { + this.gcpav = gcpav; + } + + /** {@inheritDoc} */ + @Override + public CPAMixingInterface getCpamix() { + return cpamix; + } + + /** {@inheritDoc} */ + @Override + public double calcPressure() { + gcpa = calc_g(); + // lngcpa = + // Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); + solveX(); + hcpatot = calc_hCPA(); + + initCPAMatrix(1); + return super.calcPressure(); + } + + /** {@inheritDoc} */ + @Override + public int getCrossAssosiationScheme(int comp1, int comp2, int site1, int site2) { + if (comp1 == comp2) { + return selfAccociationScheme[comp1][site1][site2]; + } else { + return crossAccociationScheme[comp1][comp2][site1][site2]; } - - /** {@inheritDoc} */ - @Override - public int getCrossAssosiationScheme(int comp1, int comp2, int site1, int site2) { - if (comp1 == comp2) { - return selfAccociationScheme[comp1][site1][site2]; - } else { - return crossAccociationScheme[comp1][comp2][site1][site2]; + } + + /** + *

+ * croeneckerProduct. + *

+ * + * @param a an array of {@link double} objects + * @param b an array of {@link double} objects + * @return an array of {@link double} objects + */ + public double[][] croeneckerProduct(double[][] a, double[][] b) { + int aLength = a.length; + int aCols = a[0].length; + int bLength = b.length; + int bCols = b[0].length; + double[][] result = new double[aLength * bLength][(aCols) * (bCols)]; + for (int z = 0; z < aLength; z++) { + for (int i = 0; i < aCols; i++) { + for (int j = 0; j < bLength; j++) { + for (int k = 0; k < bCols; k++) { + result[j + (z * bLength)][k + (i * bCols)] = a[z][i] * b[j][k]; + } } + } } - /** - *

- * croeneckerProduct. - *

- * - * @param a an array of {@link double} objects - * @param b an array of {@link double} objects - * @return an array of {@link double} objects - */ - public double[][] croeneckerProduct(double[][] a, double[][] b) { - int aLength = a.length; - int aCols = a[0].length; - int bLength = b.length; - int bCols = b[0].length; - double[][] result = new double[aLength * bLength][(aCols) * (bCols)]; - for (int z = 0; z < aLength; z++) { - for (int i = 0; i < aCols; i++) { - for (int j = 0; j < bLength; j++) { - for (int k = 0; k < bCols; k++) { - result[j + (z * bLength)][k + (i * bCols)] = a[z][i] * b[j][k]; - } - } - } - } + return result; + } - return result; - } + /** {@inheritDoc} */ + @Override + public int getTotalNumberOfAccociationSites() { + return totalNumberOfAccociationSites; + } - /** {@inheritDoc} */ - @Override - public int getTotalNumberOfAccociationSites() { - return totalNumberOfAccociationSites; - } - - /** {@inheritDoc} */ - @Override - public void setTotalNumberOfAccociationSites(int totalNumberOfAccociationSites) { - this.totalNumberOfAccociationSites = totalNumberOfAccociationSites; - } + /** {@inheritDoc} */ + @Override + public void setTotalNumberOfAccociationSites(int totalNumberOfAccociationSites) { + this.totalNumberOfAccociationSites = totalNumberOfAccociationSites; + } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseSrkEos.java b/src/main/java/neqsim/thermo/phase/PhaseSrkEos.java index 794a457562..426b972053 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseSrkEos.java +++ b/src/main/java/neqsim/thermo/phase/PhaseSrkEos.java @@ -3,6 +3,7 @@ * * Created on 3. juni 2000, 14:38 */ + package neqsim.thermo.phase; import neqsim.thermo.component.ComponentSrk; @@ -16,43 +17,42 @@ * @version $Id: $Id */ public class PhaseSrkEos extends PhaseEos { - private static final long serialVersionUID = 1000; - - /** - *

- * Constructor for PhaseSrkEos. - *

- */ - public PhaseSrkEos() { - super(); - // mixRule = mixSelect.getMixingRule(2); - thermoPropertyModelName = "SRK-EoS"; - uEOS = 1; - wEOS = 0; - delta1 = 1; - delta2 = 0; - } + private static final long serialVersionUID = 1000; - /** {@inheritDoc} */ - @Override - public PhaseSrkEos clone() { - PhaseSrkEos clonedPhase = null; - try { - clonedPhase = (PhaseSrkEos) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } - - return clonedPhase; - } + /** + *

+ * Constructor for PhaseSrkEos. + *

+ */ + public PhaseSrkEos() { + super(); + // mixRule = mixSelect.getMixingRule(2); + thermoPropertyModelName = "SRK-EoS"; + uEOS = 1; + wEOS = 0; + delta1 = 1; + delta2 = 0; + } - /** {@inheritDoc} */ - @Override - public void addcomponent(String componentName, double moles, double molesInPhase, - int compNumber) { - super.addcomponent(molesInPhase); - componentArray[compNumber] = - new ComponentSrk(componentName, moles, molesInPhase, compNumber); + /** {@inheritDoc} */ + @Override + public PhaseSrkEos clone() { + PhaseSrkEos clonedPhase = null; + try { + clonedPhase = (PhaseSrkEos) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); } + + return clonedPhase; + } + + /** {@inheritDoc} */ + @Override + public void addcomponent(String componentName, double moles, double molesInPhase, + int compNumber) { + super.addcomponent(molesInPhase); + componentArray[compNumber] = new ComponentSrk(componentName, moles, molesInPhase, compNumber); + } } diff --git a/src/main/java/neqsim/thermo/util/JNI/GERG2004EOS.java b/src/main/java/neqsim/thermo/util/JNI/GERG2004EOS.java index 1222958b0e..9b1ce687e5 100644 --- a/src/main/java/neqsim/thermo/util/JNI/GERG2004EOS.java +++ b/src/main/java/neqsim/thermo/util/JNI/GERG2004EOS.java @@ -3,6 +3,7 @@ * * Created on 19. september 2006, 12:18 */ + package neqsim.thermo.util.JNI; /** @@ -14,516 +15,515 @@ * @version $Id: $Id */ public class GERG2004EOS { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * POTDX. - *

- * - * @param c1 a double - * @param c2 a double - * @param c3 a double - * @param c4 a double - * @param c5 a double - * @param c6 a double - * @param c7 a double - * @param c8 a double - * @param c9 a double - * @param c10 a double - * @param c11 a double - * @param c12 a double - * @param c13 a double - * @param c14 a double - * @param c15 a double - * @param c16 a double - * @param c17 a double - * @param c18 a double - * @param c19 a double - * @param c20 a double - * @return a double - */ - public static native double POTDX(double c1, double c2, double c3, double c4, double c5, - double c6, double c7, double c8, double c9, double c10, double c11, double c12, - double c13, double c14, double c15, double c16, double c17, double c18, double c19, - double c20); + /** + *

+ * POTDX. + *

+ * + * @param c1 a double + * @param c2 a double + * @param c3 a double + * @param c4 a double + * @param c5 a double + * @param c6 a double + * @param c7 a double + * @param c8 a double + * @param c9 a double + * @param c10 a double + * @param c11 a double + * @param c12 a double + * @param c13 a double + * @param c14 a double + * @param c15 a double + * @param c16 a double + * @param c17 a double + * @param c18 a double + * @param c19 a double + * @param c20 a double + * @return a double + */ + public static native double POTDX(double c1, double c2, double c3, double c4, double c5, + double c6, double c7, double c8, double c9, double c10, double c11, double c12, double c13, + double c14, double c15, double c16, double c17, double c18, double c19, double c20); - /** - *

- * ZOTPX. - *

- * - * @param c1 a double - * @param c2 a double - * @param c3 a double - * @param c4 a double - * @param c5 a double - * @param c6 a double - * @param c7 a double - * @param c8 a double - * @param c9 a double - * @param c10 a double - * @param c11 a double - * @param c12 a double - * @param c13 a double - * @param c14 a double - * @param c15 a double - * @param c16 a double - * @param c17 a double - * @param c18 a double - * @param c19 a double - * @param c20 a double - * @param IPHASE a int - * @return a double - */ - public static native double ZOTPX(double c1, double c2, double c3, double c4, double c5, - double c6, double c7, double c8, double c9, double c10, double c11, double c12, - double c13, double c14, double c15, double c16, double c17, double c18, double c19, - double c20, int IPHASE); + /** + *

+ * ZOTPX. + *

+ * + * @param c1 a double + * @param c2 a double + * @param c3 a double + * @param c4 a double + * @param c5 a double + * @param c6 a double + * @param c7 a double + * @param c8 a double + * @param c9 a double + * @param c10 a double + * @param c11 a double + * @param c12 a double + * @param c13 a double + * @param c14 a double + * @param c15 a double + * @param c16 a double + * @param c17 a double + * @param c18 a double + * @param c19 a double + * @param c20 a double + * @param IPHASE a int + * @return a double + */ + public static native double ZOTPX(double c1, double c2, double c3, double c4, double c5, + double c6, double c7, double c8, double c9, double c10, double c11, double c12, double c13, + double c14, double c15, double c16, double c17, double c18, double c19, double c20, + int IPHASE); - /** - *

- * HOTPX. - *

- * - * @param c1 a double - * @param c2 a double - * @param c3 a double - * @param c4 a double - * @param c5 a double - * @param c6 a double - * @param c7 a double - * @param c8 a double - * @param c9 a double - * @param c10 a double - * @param c11 a double - * @param c12 a double - * @param c13 a double - * @param c14 a double - * @param c15 a double - * @param c16 a double - * @param c17 a double - * @param c18 a double - * @param c19 a double - * @param c20 a double - * @param IPHASE a int - * @return a double - */ - public static native double HOTPX(double c1, double c2, double c3, double c4, double c5, - double c6, double c7, double c8, double c9, double c10, double c11, double c12, - double c13, double c14, double c15, double c16, double c17, double c18, double c19, - double c20, int IPHASE); + /** + *

+ * HOTPX. + *

+ * + * @param c1 a double + * @param c2 a double + * @param c3 a double + * @param c4 a double + * @param c5 a double + * @param c6 a double + * @param c7 a double + * @param c8 a double + * @param c9 a double + * @param c10 a double + * @param c11 a double + * @param c12 a double + * @param c13 a double + * @param c14 a double + * @param c15 a double + * @param c16 a double + * @param c17 a double + * @param c18 a double + * @param c19 a double + * @param c20 a double + * @param IPHASE a int + * @return a double + */ + public static native double HOTPX(double c1, double c2, double c3, double c4, double c5, + double c6, double c7, double c8, double c9, double c10, double c11, double c12, double c13, + double c14, double c15, double c16, double c17, double c18, double c19, double c20, + int IPHASE); - /** - *

- * SOTPX. - *

- * - * @param c1 a double - * @param c2 a double - * @param c3 a double - * @param c4 a double - * @param c5 a double - * @param c6 a double - * @param c7 a double - * @param c8 a double - * @param c9 a double - * @param c10 a double - * @param c11 a double - * @param c12 a double - * @param c13 a double - * @param c14 a double - * @param c15 a double - * @param c16 a double - * @param c17 a double - * @param c18 a double - * @param c19 a double - * @param c20 a double - * @param IPHASE a int - * @return a double - */ - public static native double SOTPX(double c1, double c2, double c3, double c4, double c5, - double c6, double c7, double c8, double c9, double c10, double c11, double c12, - double c13, double c14, double c15, double c16, double c17, double c18, double c19, - double c20, int IPHASE); + /** + *

+ * SOTPX. + *

+ * + * @param c1 a double + * @param c2 a double + * @param c3 a double + * @param c4 a double + * @param c5 a double + * @param c6 a double + * @param c7 a double + * @param c8 a double + * @param c9 a double + * @param c10 a double + * @param c11 a double + * @param c12 a double + * @param c13 a double + * @param c14 a double + * @param c15 a double + * @param c16 a double + * @param c17 a double + * @param c18 a double + * @param c19 a double + * @param c20 a double + * @param IPHASE a int + * @return a double + */ + public static native double SOTPX(double c1, double c2, double c3, double c4, double c5, + double c6, double c7, double c8, double c9, double c10, double c11, double c12, double c13, + double c14, double c15, double c16, double c17, double c18, double c19, double c20, + int IPHASE); - /** - *

- * CPOTPX. - *

- * - * @param c1 a double - * @param c2 a double - * @param c3 a double - * @param c4 a double - * @param c5 a double - * @param c6 a double - * @param c7 a double - * @param c8 a double - * @param c9 a double - * @param c10 a double - * @param c11 a double - * @param c12 a double - * @param c13 a double - * @param c14 a double - * @param c15 a double - * @param c16 a double - * @param c17 a double - * @param c18 a double - * @param c19 a double - * @param c20 a double - * @param IPHASE a int - * @return a double - */ - public static native double CPOTPX(double c1, double c2, double c3, double c4, double c5, - double c6, double c7, double c8, double c9, double c10, double c11, double c12, - double c13, double c14, double c15, double c16, double c17, double c18, double c19, - double c20, int IPHASE); + /** + *

+ * CPOTPX. + *

+ * + * @param c1 a double + * @param c2 a double + * @param c3 a double + * @param c4 a double + * @param c5 a double + * @param c6 a double + * @param c7 a double + * @param c8 a double + * @param c9 a double + * @param c10 a double + * @param c11 a double + * @param c12 a double + * @param c13 a double + * @param c14 a double + * @param c15 a double + * @param c16 a double + * @param c17 a double + * @param c18 a double + * @param c19 a double + * @param c20 a double + * @param IPHASE a int + * @return a double + */ + public static native double CPOTPX(double c1, double c2, double c3, double c4, double c5, + double c6, double c7, double c8, double c9, double c10, double c11, double c12, double c13, + double c14, double c15, double c16, double c17, double c18, double c19, double c20, + int IPHASE); - /** - *

- * WOTPX. - *

- * - * @param c1 a double - * @param c2 a double - * @param c3 a double - * @param c4 a double - * @param c5 a double - * @param c6 a double - * @param c7 a double - * @param c8 a double - * @param c9 a double - * @param c10 a double - * @param c11 a double - * @param c12 a double - * @param c13 a double - * @param c14 a double - * @param c15 a double - * @param c16 a double - * @param c17 a double - * @param c18 a double - * @param c19 a double - * @param c20 a double - * @param IPHASE a int - * @return a double - */ - public static native double WOTPX(double c1, double c2, double c3, double c4, double c5, - double c6, double c7, double c8, double c9, double c10, double c11, double c12, - double c13, double c14, double c15, double c16, double c17, double c18, double c19, - double c20, int IPHASE); + /** + *

+ * WOTPX. + *

+ * + * @param c1 a double + * @param c2 a double + * @param c3 a double + * @param c4 a double + * @param c5 a double + * @param c6 a double + * @param c7 a double + * @param c8 a double + * @param c9 a double + * @param c10 a double + * @param c11 a double + * @param c12 a double + * @param c13 a double + * @param c14 a double + * @param c15 a double + * @param c16 a double + * @param c17 a double + * @param c18 a double + * @param c19 a double + * @param c20 a double + * @param IPHASE a int + * @return a double + */ + public static native double WOTPX(double c1, double c2, double c3, double c4, double c5, + double c6, double c7, double c8, double c9, double c10, double c11, double c12, double c13, + double c14, double c15, double c16, double c17, double c18, double c19, double c20, + int IPHASE); - /** - *

- * RJTOTPX. - *

- * - * @param c1 a double - * @param c2 a double - * @param c3 a double - * @param c4 a double - * @param c5 a double - * @param c6 a double - * @param c7 a double - * @param c8 a double - * @param c9 a double - * @param c10 a double - * @param c11 a double - * @param c12 a double - * @param c13 a double - * @param c14 a double - * @param c15 a double - * @param c16 a double - * @param c17 a double - * @param c18 a double - * @param c19 a double - * @param c20 a double - * @param IPHASE a int - * @return a double - */ - public static native double RJTOTPX(double c1, double c2, double c3, double c4, double c5, - double c6, double c7, double c8, double c9, double c10, double c11, double c12, - double c13, double c14, double c15, double c16, double c17, double c18, double c19, - double c20, int IPHASE); + /** + *

+ * RJTOTPX. + *

+ * + * @param c1 a double + * @param c2 a double + * @param c3 a double + * @param c4 a double + * @param c5 a double + * @param c6 a double + * @param c7 a double + * @param c8 a double + * @param c9 a double + * @param c10 a double + * @param c11 a double + * @param c12 a double + * @param c13 a double + * @param c14 a double + * @param c15 a double + * @param c16 a double + * @param c17 a double + * @param c18 a double + * @param c19 a double + * @param c20 a double + * @param IPHASE a int + * @return a double + */ + public static native double RJTOTPX(double c1, double c2, double c3, double c4, double c5, + double c6, double c7, double c8, double c9, double c10, double c11, double c12, double c13, + double c14, double c15, double c16, double c17, double c18, double c19, double c20, + int IPHASE); - /** - *

- * GOTPX. - *

- * - * @param c1 a double - * @param c2 a double - * @param c3 a double - * @param c4 a double - * @param c5 a double - * @param c6 a double - * @param c7 a double - * @param c8 a double - * @param c9 a double - * @param c10 a double - * @param c11 a double - * @param c12 a double - * @param c13 a double - * @param c14 a double - * @param c15 a double - * @param c16 a double - * @param c17 a double - * @param c18 a double - * @param c19 a double - * @param c20 a double - * @param IPHASE a int - * @return a double - */ - public static native double GOTPX(double c1, double c2, double c3, double c4, double c5, - double c6, double c7, double c8, double c9, double c10, double c11, double c12, - double c13, double c14, double c15, double c16, double c17, double c18, double c19, - double c20, int IPHASE); + /** + *

+ * GOTPX. + *

+ * + * @param c1 a double + * @param c2 a double + * @param c3 a double + * @param c4 a double + * @param c5 a double + * @param c6 a double + * @param c7 a double + * @param c8 a double + * @param c9 a double + * @param c10 a double + * @param c11 a double + * @param c12 a double + * @param c13 a double + * @param c14 a double + * @param c15 a double + * @param c16 a double + * @param c17 a double + * @param c18 a double + * @param c19 a double + * @param c20 a double + * @param IPHASE a int + * @return a double + */ + public static native double GOTPX(double c1, double c2, double c3, double c4, double c5, + double c6, double c7, double c8, double c9, double c10, double c11, double c12, double c13, + double c14, double c15, double c16, double c17, double c18, double c19, double c20, + int IPHASE); - /** - *

- * UOTPX. - *

- * - * @param c1 a double - * @param c2 a double - * @param c3 a double - * @param c4 a double - * @param c5 a double - * @param c6 a double - * @param c7 a double - * @param c8 a double - * @param c9 a double - * @param c10 a double - * @param c11 a double - * @param c12 a double - * @param c13 a double - * @param c14 a double - * @param c15 a double - * @param c16 a double - * @param c17 a double - * @param c18 a double - * @param c19 a double - * @param c20 a double - * @param IPHASE a int - * @return a double - */ - public static native double UOTPX(double c1, double c2, double c3, double c4, double c5, - double c6, double c7, double c8, double c9, double c10, double c11, double c12, - double c13, double c14, double c15, double c16, double c17, double c18, double c19, - double c20, int IPHASE); + /** + *

+ * UOTPX. + *

+ * + * @param c1 a double + * @param c2 a double + * @param c3 a double + * @param c4 a double + * @param c5 a double + * @param c6 a double + * @param c7 a double + * @param c8 a double + * @param c9 a double + * @param c10 a double + * @param c11 a double + * @param c12 a double + * @param c13 a double + * @param c14 a double + * @param c15 a double + * @param c16 a double + * @param c17 a double + * @param c18 a double + * @param c19 a double + * @param c20 a double + * @param IPHASE a int + * @return a double + */ + public static native double UOTPX(double c1, double c2, double c3, double c4, double c5, + double c6, double c7, double c8, double c9, double c10, double c11, double c12, double c13, + double c14, double c15, double c16, double c17, double c18, double c19, double c20, + int IPHASE); - /** - *

- * AOTPX. - *

- * - * @param c1 a double - * @param c2 a double - * @param c3 a double - * @param c4 a double - * @param c5 a double - * @param c6 a double - * @param c7 a double - * @param c8 a double - * @param c9 a double - * @param c10 a double - * @param c11 a double - * @param c12 a double - * @param c13 a double - * @param c14 a double - * @param c15 a double - * @param c16 a double - * @param c17 a double - * @param c18 a double - * @param c19 a double - * @param c20 a double - * @param IPHASE a int - * @return a double - */ - public static native double AOTPX(double c1, double c2, double c3, double c4, double c5, - double c6, double c7, double c8, double c9, double c10, double c11, double c12, - double c13, double c14, double c15, double c16, double c17, double c18, double c19, - double c20, int IPHASE); + /** + *

+ * AOTPX. + *

+ * + * @param c1 a double + * @param c2 a double + * @param c3 a double + * @param c4 a double + * @param c5 a double + * @param c6 a double + * @param c7 a double + * @param c8 a double + * @param c9 a double + * @param c10 a double + * @param c11 a double + * @param c12 a double + * @param c13 a double + * @param c14 a double + * @param c15 a double + * @param c16 a double + * @param c17 a double + * @param c18 a double + * @param c19 a double + * @param c20 a double + * @param IPHASE a int + * @return a double + */ + public static native double AOTPX(double c1, double c2, double c3, double c4, double c5, + double c6, double c7, double c8, double c9, double c10, double c11, double c12, double c13, + double c14, double c15, double c16, double c17, double c18, double c19, double c20, + int IPHASE); - /** - *

- * SFUGOTPX. - *

- * - * @param c1 a double - * @param c2 a double - * @param c3 a double - * @param c4 a double - * @param c5 a double - * @param c6 a double - * @param c7 a double - * @param c8 a double - * @param c9 a double - * @param c10 a double - * @param c11 a double - * @param c12 a double - * @param c13 a double - * @param c14 a double - * @param c15 a double - * @param c16 a double - * @param c17 a double - * @param c18 a double - * @param c19 a double - * @param c20 a double - * @param IPHASE a int - * @return an array of {@link double} objects - */ - public static native double[] SFUGOTPX(double c1, double c2, double c3, double c4, double c5, - double c6, double c7, double c8, double c9, double c10, double c11, double c12, - double c13, double c14, double c15, double c16, double c17, double c18, double c19, - double c20, int IPHASE); + /** + *

+ * SFUGOTPX. + *

+ * + * @param c1 a double + * @param c2 a double + * @param c3 a double + * @param c4 a double + * @param c5 a double + * @param c6 a double + * @param c7 a double + * @param c8 a double + * @param c9 a double + * @param c10 a double + * @param c11 a double + * @param c12 a double + * @param c13 a double + * @param c14 a double + * @param c15 a double + * @param c16 a double + * @param c17 a double + * @param c18 a double + * @param c19 a double + * @param c20 a double + * @param IPHASE a int + * @return an array of {@link double} objects + */ + public static native double[] SFUGOTPX(double c1, double c2, double c3, double c4, double c5, + double c6, double c7, double c8, double c9, double c10, double c11, double c12, double c13, + double c14, double c15, double c16, double c17, double c18, double c19, double c20, + int IPHASE); - /** - *

- * SPHIOTPX. - *

- * - * @param c1 a double - * @param c2 a double - * @param c3 a double - * @param c4 a double - * @param c5 a double - * @param c6 a double - * @param c7 a double - * @param c8 a double - * @param c9 a double - * @param c10 a double - * @param c11 a double - * @param c12 a double - * @param c13 a double - * @param c14 a double - * @param c15 a double - * @param c16 a double - * @param c17 a double - * @param c18 a double - * @param c19 a double - * @param c20 a double - * @param IPHASE a int - * @return an array of {@link double} objects - */ - public static native double[] SPHIOTPX(double c1, double c2, double c3, double c4, double c5, - double c6, double c7, double c8, double c9, double c10, double c11, double c12, - double c13, double c14, double c15, double c16, double c17, double c18, double c19, - double c20, int IPHASE); + /** + *

+ * SPHIOTPX. + *

+ * + * @param c1 a double + * @param c2 a double + * @param c3 a double + * @param c4 a double + * @param c5 a double + * @param c6 a double + * @param c7 a double + * @param c8 a double + * @param c9 a double + * @param c10 a double + * @param c11 a double + * @param c12 a double + * @param c13 a double + * @param c14 a double + * @param c15 a double + * @param c16 a double + * @param c17 a double + * @param c18 a double + * @param c19 a double + * @param c20 a double + * @param IPHASE a int + * @return an array of {@link double} objects + */ + public static native double[] SPHIOTPX(double c1, double c2, double c3, double c4, double c5, + double c6, double c7, double c8, double c9, double c10, double c11, double c12, double c13, + double c14, double c15, double c16, double c17, double c18, double c19, double c20, + int IPHASE); - /** - *

- * CVOTPX. - *

- * - * @param c1 a double - * @param c2 a double - * @param c3 a double - * @param c4 a double - * @param c5 a double - * @param c6 a double - * @param c7 a double - * @param c8 a double - * @param c9 a double - * @param c10 a double - * @param c11 a double - * @param c12 a double - * @param c13 a double - * @param c14 a double - * @param c15 a double - * @param c16 a double - * @param c17 a double - * @param c18 a double - * @param c19 a double - * @param c20 a double - * @param IPHASE a int - * @return a double - */ - public static native double CVOTPX(double c1, double c2, double c3, double c4, double c5, - double c6, double c7, double c8, double c9, double c10, double c11, double c12, - double c13, double c14, double c15, double c16, double c17, double c18, double c19, - double c20, int IPHASE); + /** + *

+ * CVOTPX. + *

+ * + * @param c1 a double + * @param c2 a double + * @param c3 a double + * @param c4 a double + * @param c5 a double + * @param c6 a double + * @param c7 a double + * @param c8 a double + * @param c9 a double + * @param c10 a double + * @param c11 a double + * @param c12 a double + * @param c13 a double + * @param c14 a double + * @param c15 a double + * @param c16 a double + * @param c17 a double + * @param c18 a double + * @param c19 a double + * @param c20 a double + * @param IPHASE a int + * @return a double + */ + public static native double CVOTPX(double c1, double c2, double c3, double c4, double c5, + double c6, double c7, double c8, double c9, double c10, double c11, double c12, double c13, + double c14, double c15, double c16, double c17, double c18, double c19, double c20, + int IPHASE); - /** - *

- * SALLOTPX. - *

- * - * @param c1 a double - * @param c2 a double - * @param c3 a double - * @param c4 a double - * @param c5 a double - * @param c6 a double - * @param c7 a double - * @param c8 a double - * @param c9 a double - * @param c10 a double - * @param c11 a double - * @param c12 a double - * @param c13 a double - * @param c14 a double - * @param c15 a double - * @param c16 a double - * @param c17 a double - * @param c18 a double - * @param c19 a double - * @param c20 a double - * @param IPHASE a int - * @return an array of {@link double} objects - */ - public static native double[] SALLOTPX(double c1, double c2, double c3, double c4, double c5, - double c6, double c7, double c8, double c9, double c10, double c11, double c12, - double c13, double c14, double c15, double c16, double c17, double c18, double c19, - double c20, int IPHASE); + /** + *

+ * SALLOTPX. + *

+ * + * @param c1 a double + * @param c2 a double + * @param c3 a double + * @param c4 a double + * @param c5 a double + * @param c6 a double + * @param c7 a double + * @param c8 a double + * @param c9 a double + * @param c10 a double + * @param c11 a double + * @param c12 a double + * @param c13 a double + * @param c14 a double + * @param c15 a double + * @param c16 a double + * @param c17 a double + * @param c18 a double + * @param c19 a double + * @param c20 a double + * @param IPHASE a int + * @return an array of {@link double} objects + */ + public static native double[] SALLOTPX(double c1, double c2, double c3, double c4, double c5, + double c6, double c7, double c8, double c9, double c10, double c11, double c12, double c13, + double c14, double c15, double c16, double c17, double c18, double c19, double c20, + int IPHASE); - public String[] nameList = {"methane", "nitrogen", "CO2", "ethane", "propane", "n-butane", - "i-butane", "n-pentane", "i-pentane", "n-hexane", "n-heptane", "n-octane", "hydrogen", - "oxygen", "CO", "water", "helium", "argon"}; + public String[] nameList = {"methane", "nitrogen", "CO2", "ethane", "propane", "n-butane", + "i-butane", "n-pentane", "i-pentane", "n-hexane", "n-heptane", "n-octane", "hydrogen", + "oxygen", "CO", "water", "helium", "argon"}; - /** - *

- * Constructor for GERG2004EOS. - *

- */ - public GERG2004EOS() { - // todo: does not work - System.loadLibrary("test2"); - } + /** + *

+ * Constructor for GERG2004EOS. + *

+ */ + public GERG2004EOS() { + // todo: does not work + System.loadLibrary("test2"); + } - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - @SuppressWarnings("unused") - public static void main(String args[]) { - GERG2004EOS gergEOS = new GERG2004EOS(); - double c1 = 298.0, c2 = 0.1, c3 = 0.90, c4 = 0.1, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0, - c10 = 0, c11 = 0, c12 = 0, c13 = 0, c14 = 0, c15 = 0, c16 = 0, c17 = 0, c18 = 0, - c19 = 0, c20 = 0; - // double a2 = gergEOS.POTDX (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, - // c13, c14, c15, c16, c17, c18, c19, c20); - double a4 = GERG2004EOS.SALLOTPX(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, - c14, c15, c16, c17, c18, c19, c20, 2)[3]; - double a2 = GERG2004EOS.ZOTPX(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, - c15, c16, c17, c18, c19, c20, 2); - double[] a3 = new double[18]; - // a3 = gergEOS.SPHIOTPX(c1, c2, - // c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,-2); - // System.out.println("potdx " + a); - } + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String args[]) { + GERG2004EOS gergEOS = new GERG2004EOS(); + double c1 = 298.0, c2 = 0.1, c3 = 0.90, c4 = 0.1, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0, + c10 = 0, c11 = 0, c12 = 0, c13 = 0, c14 = 0, c15 = 0, c16 = 0, c17 = 0, c18 = 0, c19 = 0, + c20 = 0; + // double a2 = gergEOS.POTDX (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, + // c13, c14, c15, c16, c17, c18, c19, c20); + double a4 = GERG2004EOS.SALLOTPX(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, + c15, c16, c17, c18, c19, c20, 2)[3]; + double a2 = GERG2004EOS.ZOTPX(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, + c16, c17, c18, c19, c20, 2); + double[] a3 = new double[18]; + // a3 = gergEOS.SPHIOTPX(c1, c2, + // c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,-2); + // System.out.println("potdx " + a); + } - /** - *

- * Getter for the field nameList. - *

- * - * @return an array of {@link java.lang.String} objects - */ - public String[] getNameList() { - return nameList; - } + /** + *

+ * Getter for the field nameList. + *

+ * + * @return an array of {@link java.lang.String} objects + */ + public String[] getNameList() { + return nameList; + } } diff --git a/src/main/java/neqsim/thermo/util/constants/FurstElectrolyteConstants.java b/src/main/java/neqsim/thermo/util/constants/FurstElectrolyteConstants.java index 739c5c811d..6047490b19 100644 --- a/src/main/java/neqsim/thermo/util/constants/FurstElectrolyteConstants.java +++ b/src/main/java/neqsim/thermo/util/constants/FurstElectrolyteConstants.java @@ -3,6 +3,7 @@ * * Created on 29. oktober 2001, 14:08 */ + package neqsim.thermo.util.constants; /** @@ -14,94 +15,94 @@ * @version $Id: $Id */ public class FurstElectrolyteConstants implements java.io.Serializable { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - // public static double[] furstParams = {0.0982e-6, 7.003e-6, 77.22e-6, - // -25.314e-6, -0.05813e-6, -44.383e-6}; - /** Constant furstParams */ - public static double[] furstParams = - {0.0000001117, 0.0000053771, 0.0000699219, 0.0000043984, -0.0000000606, -0.0000217950}; - // public static double[] furstParams = {0.0000001018, 0.0000064366, - // 0.0001103447, -0.0001631115, -0.0000000565, -0.0000565052}; - // public static double[] furstParams = {0.10688e-6, 6.5665e-6, 35.09e-6, - // 6.004e-6, -0.04304e-6, -27.510e-6}; - // public static double[] furstParams = {8.806E-8, 6.905E-6, 2.064E-5, 2.285E-4, - // -5.531E-8, -4.321E-5}; - // public static double[] furstParams = {8.806E-8, 6.905E-6, 35.09e-6, 6.004e-6, - // -5.531E-8, -4.321E-5}; - //// public static double[] furstParams = {8.717E-8, 8.309E-6, 2.435E-5, - // 2.024E-4, -5.757E-8, -5.693E-5}; - // public static double[] furstParams = {9.8647e-8, 6.9638e-6, 7.713e-5, - // -2.501e-5, -5.813E-8, -4.447E-5};;//{9.8647e-8, 6.9638e-6, 7.713E-5, - // -2.501E-5, -5.813E-8, -4.447E-5}; - // public static double[] furstParams = {9.463E-8, 6.694E-6, -1.021E-5, - // 4.137E-4, -5.172E-8, -5.832E-5}; - // public static double[] furstParamsCPA = {0.0000000752, 0.0000037242, - // 0.0000250998, 0.0000198635, -0.0000000311, -0.0000006630}; // before fitting - // 2015 - /** Constant furstParamsCPA */ - public static double[] furstParamsCPA = - {0.00000014880379801585537, 0.000005016259143319152, 0.00004614450758742748, - -0.00006428039395924042, -0.000000039695971380410286, -0.000021035816766450363}; - /** Constant furstParamsCPA_MDEA */ - public static double[] furstParamsCPA_MDEA = - {0.0000000752, 0.0000037242, -0.0004725836, 0.0026038239, -0.0000002479, -0.0000082501}; + // public static double[] furstParams = {0.0982e-6, 7.003e-6, 77.22e-6, + // -25.314e-6, -0.05813e-6, -44.383e-6}; + /** Constant furstParams */ + public static double[] furstParams = + {0.0000001117, 0.0000053771, 0.0000699219, 0.0000043984, -0.0000000606, -0.0000217950}; + // public static double[] furstParams = {0.0000001018, 0.0000064366, + // 0.0001103447, -0.0001631115, -0.0000000565, -0.0000565052}; + // public static double[] furstParams = {0.10688e-6, 6.5665e-6, 35.09e-6, + // 6.004e-6, -0.04304e-6, -27.510e-6}; + // public static double[] furstParams = {8.806E-8, 6.905E-6, 2.064E-5, 2.285E-4, + // -5.531E-8, -4.321E-5}; + // public static double[] furstParams = {8.806E-8, 6.905E-6, 35.09e-6, 6.004e-6, + // -5.531E-8, -4.321E-5}; + //// public static double[] furstParams = {8.717E-8, 8.309E-6, 2.435E-5, + // 2.024E-4, -5.757E-8, -5.693E-5}; + // public static double[] furstParams = {9.8647e-8, 6.9638e-6, 7.713e-5, + // -2.501e-5, -5.813E-8, -4.447E-5};;//{9.8647e-8, 6.9638e-6, 7.713E-5, + // -2.501E-5, -5.813E-8, -4.447E-5}; + // public static double[] furstParams = {9.463E-8, 6.694E-6, -1.021E-5, + // 4.137E-4, -5.172E-8, -5.832E-5}; + // public static double[] furstParamsCPA = {0.0000000752, 0.0000037242, + // 0.0000250998, 0.0000198635, -0.0000000311, -0.0000006630}; // before fitting + // 2015 + /** Constant furstParamsCPA */ + public static double[] furstParamsCPA = + {0.00000014880379801585537, 0.000005016259143319152, 0.00004614450758742748, + -0.00006428039395924042, -0.000000039695971380410286, -0.000021035816766450363}; + /** Constant furstParamsCPA_MDEA */ + public static double[] furstParamsCPA_MDEA = + {0.0000000752, 0.0000037242, -0.0004725836, 0.0026038239, -0.0000002479, -0.0000082501}; - // 0.0000001880, 0.0000014139, 0.0000284666, 0.0000389043, -0.0000000451, - // 0.0000088136 - /** - *

- * Constructor for FurstElectrolyteConstants. - *

- */ - public FurstElectrolyteConstants() {} + // 0.0000001880, 0.0000014139, 0.0000284666, 0.0000389043, -0.0000000451, + // 0.0000088136 + /** + *

+ * Constructor for FurstElectrolyteConstants. + *

+ */ + public FurstElectrolyteConstants() {} - /** - *

- * setFurstParam. - *

- * - * @param i a int - * @param value a double - */ - public static void setFurstParam(int i, double value) { - furstParams[i] = value; - } + /** + *

+ * setFurstParam. + *

+ * + * @param i a int + * @param value a double + */ + public static void setFurstParam(int i, double value) { + furstParams[i] = value; + } - /** - *

- * getFurstParam. - *

- * - * @param i a int - * @return a double - */ - public static double getFurstParam(int i) { - return furstParams[i]; - } + /** + *

+ * getFurstParam. + *

+ * + * @param i a int + * @return a double + */ + public static double getFurstParam(int i) { + return furstParams[i]; + } - /** - *

- * getFurstParamMDEA. - *

- * - * @param i a int - * @return a double - */ - public static double getFurstParamMDEA(int i) { - return furstParamsCPA_MDEA[i]; - } + /** + *

+ * getFurstParamMDEA. + *

+ * + * @param i a int + * @return a double + */ + public static double getFurstParamMDEA(int i) { + return furstParamsCPA_MDEA[i]; + } - /** - *

- * Setter for the field furstParams. - *

- * - * @param type a {@link java.lang.String} object - */ - public static void setFurstParams(String type) { - if (type.equals("electrolyteCPA")) { - furstParams = furstParamsCPA; - } + /** + *

+ * Setter for the field furstParams. + *

+ * + * @param type a {@link java.lang.String} object + */ + public static void setFurstParams(String type) { + if (type.equals("electrolyteCPA")) { + furstParams = furstParamsCPA; } + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/Procede/CO2MDEA/TestBinaryHVParameterFittingToEquilibriumData_N2O.java b/src/main/java/neqsim/thermo/util/parameterFitting/Procede/CO2MDEA/TestBinaryHVParameterFittingToEquilibriumData_N2O.java index c61fa8f2e1..3727d895f6 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/Procede/CO2MDEA/TestBinaryHVParameterFittingToEquilibriumData_N2O.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/Procede/CO2MDEA/TestBinaryHVParameterFittingToEquilibriumData_N2O.java @@ -1,4 +1,5 @@ // To find HV parameters for CO2 - MDEA system + package neqsim.thermo.util.parameterFitting.Procede.CO2MDEA; import java.sql.ResultSet; @@ -21,89 +22,87 @@ * @version $Id: $Id */ public class TestBinaryHVParameterFittingToEquilibriumData_N2O { - static Logger logger = - LogManager.getLogger(TestBinaryHVParameterFittingToEquilibriumData_N2O.class); - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); - double error = 5; - - // inserting samples from database - NeqSimDataBase database = new NeqSimDataBase(); - // Reference = 'Versteeg' OR Reference='Al-Ghawas' OR Reference = 'Pawlak' OR - // Reference ='Haimour' Reference='Al-Ghawas' OR - ResultSet dataSet = database.getResultSet( - "SELECT * FROM CO2MDEA WHERE Reference='Jou' OR Reference = 'Pawlak' OR Reference = 'Versteeg' OR Reference ='Haimour'"); - - // double guess[] = {493.2862980752, 265.1993459038, -0.4817235596, - // -0.6827900771, -0.7855706585}; //First one - double guess[] = - {-387.8913684529, -2028.8216959926, 6.1851396710, 3.4677644464, -0.2029288678}; // Second - // one - - try { - while (dataSet.next()) { - BinaryHVParameterFittingFunction_N2O function = - new BinaryHVParameterFittingFunction_N2O(); - - function.setInitialGuess(guess); - - SystemInterface testSystem = new SystemSrkSchwartzentruberEos(280, 1); - - int ID = dataSet.getInt("ID"); - double temperature = Double.parseDouble(dataSet.getString("Temperature")); - double pressure = Double.parseDouble(dataSet.getString("Pressure")); - double x1 = Double.parseDouble(dataSet.getString("x1")); - double x2 = Double.parseDouble(dataSet.getString("x2")); - double x3 = Double.parseDouble(dataSet.getString("x3")); - - if (ID == 96 || ID == 115 || ID == 124) { - continue; // Data points of Versteeg corresponding to high MDEA wt % - } - if (ID == 132) { - continue; - } - - testSystem.setTemperature(temperature); - testSystem.setPressure(pressure); - - testSystem.addComponent("CO2", x1); - testSystem.addComponent("Water", x2); - testSystem.addComponent("MDEA", x3); - - testSystem.createDatabase(true); - testSystem.setMixingRule(4); - testSystem.init(0); - - double sample1[] = {x3, temperature}; - double standardDeviation1[] = {x3 / 100, temperature / 100.0}; - - SampleValue sample = new SampleValue(pressure, error * pressure / 100.0, sample1, - standardDeviation1); - - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sample.setReference(Double.toString(ID)); - sampleList.add(sample); - } - } catch (Exception e) { - logger.error("database error" + e); + static Logger logger = + LogManager.getLogger(TestBinaryHVParameterFittingToEquilibriumData_N2O.class); + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); + double error = 5; + + // inserting samples from database + NeqSimDataBase database = new NeqSimDataBase(); + // Reference = 'Versteeg' OR Reference='Al-Ghawas' OR Reference = 'Pawlak' OR + // Reference ='Haimour' Reference='Al-Ghawas' OR + ResultSet dataSet = database.getResultSet( + "SELECT * FROM CO2MDEA WHERE Reference='Jou' OR Reference = 'Pawlak' OR Reference = 'Versteeg' OR Reference ='Haimour'"); + + // double guess[] = {493.2862980752, 265.1993459038, -0.4817235596, + // -0.6827900771, -0.7855706585}; //First one + double guess[] = {-387.8913684529, -2028.8216959926, 6.1851396710, 3.4677644464, -0.2029288678}; // Second + // one + + try { + while (dataSet.next()) { + BinaryHVParameterFittingFunction_N2O function = new BinaryHVParameterFittingFunction_N2O(); + + function.setInitialGuess(guess); + + SystemInterface testSystem = new SystemSrkSchwartzentruberEos(280, 1); + + int ID = dataSet.getInt("ID"); + double temperature = Double.parseDouble(dataSet.getString("Temperature")); + double pressure = Double.parseDouble(dataSet.getString("Pressure")); + double x1 = Double.parseDouble(dataSet.getString("x1")); + double x2 = Double.parseDouble(dataSet.getString("x2")); + double x3 = Double.parseDouble(dataSet.getString("x3")); + + if (ID == 96 || ID == 115 || ID == 124) { + continue; // Data points of Versteeg corresponding to high MDEA wt % + } + if (ID == 132) { + continue; } - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + testSystem.setTemperature(temperature); + testSystem.setPressure(pressure); + + testSystem.addComponent("CO2", x1); + testSystem.addComponent("Water", x2); + testSystem.addComponent("MDEA", x3); + + testSystem.createDatabase(true); + testSystem.setMixingRule(4); + testSystem.init(0); - // do simulations - // optim.solve(); - optim.displayCurveFit(); - // optim.displayResult(); + double sample1[] = {x3, temperature}; + double standardDeviation1[] = {x3 / 100, temperature / 100.0}; + + SampleValue sample = + new SampleValue(pressure, error * pressure / 100.0, sample1, standardDeviation1); + + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sample.setReference(Double.toString(ID)); + sampleList.add(sample); + } + } catch (Exception e) { + logger.error("database error" + e); } + + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); + + // do simulations + // optim.solve(); + optim.displayCurveFit(); + // optim.displayResult(); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/IonicInteractionParameterFittingFunction.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/IonicInteractionParameterFittingFunction.java index 56c8078971..fde64e4851 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/IonicInteractionParameterFittingFunction.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/IonicInteractionParameterFittingFunction.java @@ -3,11 +3,11 @@ * * Created on 22. januar 2001, 22:59 */ + package neqsim.thermo.util.parameterFitting.binaryInteractionParameterFitting.ionicInteractionCoefficientFitting; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import neqsim.statistics.parameterFitting.nonLinearParameterFitting.LevenbergMarquardtFunction; import neqsim.thermo.mixingRule.HVmixingRuleInterface; import neqsim.thermo.phase.PhaseEosInterface; @@ -22,361 +22,356 @@ * @version $Id: $Id */ public class IonicInteractionParameterFittingFunction extends LevenbergMarquardtFunction { - static Logger logger = LogManager.getLogger(IonicInteractionParameterFittingFunction.class); + static Logger logger = LogManager.getLogger(IonicInteractionParameterFittingFunction.class); - /** - *

- * Constructor for IonicInteractionParameterFittingFunction. - *

- */ - public IonicInteractionParameterFittingFunction() {} + /** + *

+ * Constructor for IonicInteractionParameterFittingFunction. + *

+ */ + public IonicInteractionParameterFittingFunction() {} - /** {@inheritDoc} */ - @Override - public double calcValue(double[] dependentValues) { - try { - thermoOps.bubblePointPressureFlash(false); - // logger.info("pres " + - // system.getPressure()*system.getPhases()[0].getComponent(0).getx()); - } catch (Exception e) { - logger.error(e.toString()); - } - return system.getPressure() * system.getPhases()[0].getComponent(0).getx(); + /** {@inheritDoc} */ + @Override + public double calcValue(double[] dependentValues) { + try { + thermoOps.bubblePointPressureFlash(false); + // logger.info("pres " + + // system.getPressure()*system.getPhases()[0].getComponent(0).getx()); + } catch (Exception e) { + logger.error(e.toString()); } + return system.getPressure() * system.getPhases()[0].getComponent(0).getx(); + } - /** {@inheritDoc} */ - @Override - public double calcTrueValue(double val) { - return val; - } + /** {@inheritDoc} */ + @Override + public double calcTrueValue(double val) { + return val; + } - /** {@inheritDoc} */ - @Override - public void setFittingParams(int i, double value) { - params[i] = value; - int MDEAplusNumb = 0, MDEANumb = 0, CO2Numb = 0, HCO3numb = 0, Waternumb = 0, - H3OplusNumb = 0; - int j = 0; - // do{ - // H3OplusNumb = j; - // j++; - // } - // while(!system.getPhases()[0].getComponents()[j-1].getComponentName().equals("H3O+")); + /** {@inheritDoc} */ + @Override + public void setFittingParams(int i, double value) { + params[i] = value; + int MDEAplusNumb = 0, MDEANumb = 0, CO2Numb = 0, HCO3numb = 0, Waternumb = 0, H3OplusNumb = 0; + int j = 0; + // do{ + // H3OplusNumb = j; + // j++; + // } + // while(!system.getPhases()[0].getComponents()[j-1].getComponentName().equals("H3O+")); - j = 0; - do { - MDEAplusNumb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("MDEA+")); - j = 0; + j = 0; + do { + MDEAplusNumb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("MDEA+")); + j = 0; - do { - MDEANumb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("MDEA")); - j = 0; - do { - CO2Numb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("CO2")); - j = 0; + do { + MDEANumb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("MDEA")); + j = 0; + do { + CO2Numb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("CO2")); + j = 0; - do { - HCO3numb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("HCO3-")); - j = 0; - do { - Waternumb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("water")); - // logger.info("water numb " + Waternumb); - // logger.info("co2 numb " + CO2Numb); - // logger.info("MDEA numb " + MDEANumb); - // logger.info("HCO3numb numb " + HCO3numb); - // logger.info("MDEAplusNumb numb " + MDEAplusNumb); + do { + HCO3numb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("HCO3-")); + j = 0; + do { + Waternumb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("water")); + // logger.info("water numb " + Waternumb); + // logger.info("co2 numb " + CO2Numb); + // logger.info("MDEA numb " + MDEANumb); + // logger.info("HCO3numb numb " + HCO3numb); + // logger.info("MDEAplusNumb numb " + MDEAplusNumb); - if (i == 0) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijParameter(MDEAplusNumb, CO2Numb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijParameter(MDEAplusNumb, CO2Numb, value); - } - if (i == 1) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijParameter(MDEAplusNumb, MDEANumb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijParameter(MDEAplusNumb, MDEANumb, value); - } - if (i == 2) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijParameter(MDEAplusNumb, Waternumb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijParameter(MDEAplusNumb, Waternumb, value); + if (i == 0) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijParameter(MDEAplusNumb, CO2Numb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijParameter(MDEAplusNumb, CO2Numb, value); + } + if (i == 1) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijParameter(MDEAplusNumb, MDEANumb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijParameter(MDEAplusNumb, MDEANumb, value); + } + if (i == 2) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijParameter(MDEAplusNumb, Waternumb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijParameter(MDEAplusNumb, Waternumb, value); - if (((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1].getRefPhase(MDEAplusNumb)) - .getElectrolyteMixingRule() != null) { - // ((ElectrolyteMixingRulesInterface)((PhaseModifiedFurstElectrolyteEos)((PhaseModifiedFurstElectrolyteEos)system.getPhases()[0]).getRefPhase(MDEAplusNumb)).getElectrolyteMixingRule()).setWijParameter(0, - // 1, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1].getRefPhase(MDEAplusNumb)) - .getElectrolyteMixingRule().setWijParameter(0, 1, value); - } - } - if (i == 3) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijParameter(MDEAplusNumb, HCO3numb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijParameter(MDEAplusNumb, HCO3numb, value); - } - if (i == 42) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijParameter(H3OplusNumb, MDEANumb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijParameter(H3OplusNumb, MDEANumb, value); - } + if (((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1].getRefPhase(MDEAplusNumb)) + .getElectrolyteMixingRule() != null) { + // ((ElectrolyteMixingRulesInterface)((PhaseModifiedFurstElectrolyteEos)((PhaseModifiedFurstElectrolyteEos)system.getPhases()[0]).getRefPhase(MDEAplusNumb)).getElectrolyteMixingRule()).setWijParameter(0, + // 1, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1].getRefPhase(MDEAplusNumb)) + .getElectrolyteMixingRule().setWijParameter(0, 1, value); + } + } + if (i == 3) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijParameter(MDEAplusNumb, HCO3numb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijParameter(MDEAplusNumb, HCO3numb, value); + } + if (i == 42) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijParameter(H3OplusNumb, MDEANumb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijParameter(H3OplusNumb, MDEANumb, value); + } - if (i == 4) { - ((PhaseEosInterface) system.getPhases()[0]).getMixingRule() - .setBinaryInteractionParameter(CO2Numb, MDEANumb, value * 1e3); - ((PhaseEosInterface) system.getPhases()[1]).getMixingRule() - .setBinaryInteractionParameter(CO2Numb, MDEANumb, value * 1e3); - } + if (i == 4) { + ((PhaseEosInterface) system.getPhases()[0]).getMixingRule() + .setBinaryInteractionParameter(CO2Numb, MDEANumb, value * 1e3); + ((PhaseEosInterface) system.getPhases()[1]).getMixingRule() + .setBinaryInteractionParameter(CO2Numb, MDEANumb, value * 1e3); + } - if (i == 20) { - system.getPhase(0).getComponent(MDEAplusNumb).setStokesCationicDiameter(value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).reInitFurstParam(); - system.getPhase(1).getComponent(MDEAplusNumb).setStokesCationicDiameter(value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).reInitFurstParam(); - } - if (i == 40) { - system.getChemicalReactionOperations().getReactionList().getReaction(0).setK(0, value); - } - if (i == 50) { - system.getChemicalReactionOperations().getReactionList().getReaction(0).setK(1, value); - } - if (i == 60) { - system.getChemicalReactionOperations().getReactionList().getReaction(0).setK(2, value); - } + if (i == 20) { + system.getPhase(0).getComponent(MDEAplusNumb).setStokesCationicDiameter(value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).reInitFurstParam(); + system.getPhase(1).getComponent(MDEAplusNumb).setStokesCationicDiameter(value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).reInitFurstParam(); + } + if (i == 40) { + system.getChemicalReactionOperations().getReactionList().getReaction(0).setK(0, value); + } + if (i == 50) { + system.getChemicalReactionOperations().getReactionList().getReaction(0).setK(1, value); + } + if (i == 60) { + system.getChemicalReactionOperations().getReactionList().getReaction(0).setK(2, value); + } - if (i == 10) { - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) - .setHVDijParameter(CO2Numb, MDEANumb, value); - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) - .setHVDijParameter(CO2Numb, MDEANumb, value); - } - if (i == 40) { - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) - .setHVDijParameter(MDEANumb, CO2Numb, value * 1e8); - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) - .setHVDijParameter(MDEANumb, CO2Numb, value * 1e8); - } - if (i == 10) { - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) - .setHVDijTParameter(CO2Numb, MDEANumb, value); - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) - .setHVDijTParameter(CO2Numb, MDEANumb, value); - } - if (i == 50) { - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) - .setHVDijTParameter(MDEANumb, CO2Numb, value * 1e8); - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) - .setHVDijTParameter(MDEANumb, CO2Numb, value * 1e8); - } + if (i == 10) { + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) + .setHVDijParameter(CO2Numb, MDEANumb, value); + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) + .setHVDijParameter(CO2Numb, MDEANumb, value); + } + if (i == 40) { + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) + .setHVDijParameter(MDEANumb, CO2Numb, value * 1e8); + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) + .setHVDijParameter(MDEANumb, CO2Numb, value * 1e8); + } + if (i == 10) { + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) + .setHVDijTParameter(CO2Numb, MDEANumb, value); + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) + .setHVDijTParameter(CO2Numb, MDEANumb, value); + } + if (i == 50) { + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) + .setHVDijTParameter(MDEANumb, CO2Numb, value * 1e8); + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) + .setHVDijTParameter(MDEANumb, CO2Numb, value * 1e8); + } - // Temp der 1 - if (i == 50) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, MDEANumb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, MDEANumb, value); - } - if (i == 40) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, CO2Numb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, CO2Numb, value); - } - if (i == 60) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, HCO3numb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, HCO3numb, value); - } - if (i == 7) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, Waternumb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, Waternumb, value); - } + // Temp der 1 + if (i == 50) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, MDEANumb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, MDEANumb, value); + } + if (i == 40) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, CO2Numb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, CO2Numb, value); + } + if (i == 60) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, HCO3numb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, HCO3numb, value); + } + if (i == 7) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, Waternumb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, Waternumb, value); + } - // Temp der 2 - if (i == 66) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, MDEANumb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, MDEANumb, value); - } - if (i == 20) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, CO2Numb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, CO2Numb, value); - } - if (i == 76) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, HCO3numb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, HCO3numb, value); - } - if (i == 86) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, Waternumb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, Waternumb, value); - } + // Temp der 2 + if (i == 66) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, MDEANumb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, MDEANumb, value); + } + if (i == 20) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, CO2Numb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, CO2Numb, value); + } + if (i == 76) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, HCO3numb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, HCO3numb, value); + } + if (i == 86) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, Waternumb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, Waternumb, value); } + } - /** - *

- * setFittingParams5. - *

- * - * @param i a int - * @param value a double - */ - public void setFittingParams5(int i, double value) { - params[i] = value; - int MDEAplusNumb = 0, MDEANumb = 0, CO2Numb = 0, HCO3numb = 0, Waternumb = 0; - int j = 0; - do { - MDEAplusNumb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName() - .equals("MDEAplus")); - j = 0; + /** + *

+ * setFittingParams5. + *

+ * + * @param i a int + * @param value a double + */ + public void setFittingParams5(int i, double value) { + params[i] = value; + int MDEAplusNumb = 0, MDEANumb = 0, CO2Numb = 0, HCO3numb = 0, Waternumb = 0; + int j = 0; + do { + MDEAplusNumb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("MDEAplus")); + j = 0; - do { - MDEANumb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("MDEA")); - j = 0; - do { - CO2Numb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("CO2")); - j = 0; + do { + MDEANumb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("MDEA")); + j = 0; + do { + CO2Numb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("CO2")); + j = 0; - do { - HCO3numb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName() - .equals("HCO3minus")); - j = 0; - do { - Waternumb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("water")); + do { + HCO3numb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("HCO3minus")); + j = 0; + do { + Waternumb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("water")); - // Temp der 1 - if (i == 0) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, MDEANumb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, MDEANumb, value); - } - if (i == 1) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, CO2Numb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, CO2Numb, value); - } - if (i == 10) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, HCO3numb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, HCO3numb, value); - } - if (i == 2) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, Waternumb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT1Parameter(MDEAplusNumb, Waternumb, value); - } + // Temp der 1 + if (i == 0) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, MDEANumb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, MDEANumb, value); + } + if (i == 1) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, CO2Numb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, CO2Numb, value); + } + if (i == 10) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, HCO3numb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, HCO3numb, value); + } + if (i == 2) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, Waternumb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT1Parameter(MDEAplusNumb, Waternumb, value); + } - // Temp der 2 - if (i == 23) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, MDEANumb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, MDEANumb, value); - } - if (i == 20) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, CO2Numb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, CO2Numb, value); - } - if (i == 4) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, HCO3numb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, HCO3numb, value); - } - if (i == 5) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, Waternumb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijT2Parameter(MDEAplusNumb, Waternumb, value); - } + // Temp der 2 + if (i == 23) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, MDEANumb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, MDEANumb, value); + } + if (i == 20) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, CO2Numb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, CO2Numb, value); + } + if (i == 4) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, HCO3numb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, HCO3numb, value); + } + if (i == 5) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, Waternumb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijT2Parameter(MDEAplusNumb, Waternumb, value); } + } - /** - *

- * setFittingParams3. - *

- * - * @param i a int - * @param value a double - */ - @SuppressWarnings("unused") - public void setFittingParams3(int i, double value) { - params[i] = value; - int MDEAplusNumb = 0, MDEANumb = 0, CO2Numb = 0, HCO3numb = 0, Waternumb = 0; - int j = 0; - do { - MDEAplusNumb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName() - .equals("MDEAplus")); - j = 0; + /** + *

+ * setFittingParams3. + *

+ * + * @param i a int + * @param value a double + */ + @SuppressWarnings("unused") + public void setFittingParams3(int i, double value) { + params[i] = value; + int MDEAplusNumb = 0, MDEANumb = 0, CO2Numb = 0, HCO3numb = 0, Waternumb = 0; + int j = 0; + do { + MDEAplusNumb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("MDEAplus")); + j = 0; - do { - MDEANumb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("MDEA")); - j = 0; - do { - CO2Numb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("CO2")); - j = 0; + do { + MDEANumb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("MDEA")); + j = 0; + do { + CO2Numb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("CO2")); + j = 0; - do { - HCO3numb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName() - .equals("HCO3minus")); - j = 0; - do { - Waternumb = j; - j++; - } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("water")); + do { + HCO3numb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("HCO3minus")); + j = 0; + do { + Waternumb = j; + j++; + } while (!system.getPhases()[0].getComponents()[j - 1].getComponentName().equals("water")); - if (i == 0) { - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() - .setWijParameter(MDEAplusNumb, CO2Numb, value); - ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() - .setWijParameter(MDEAplusNumb, CO2Numb, value); - } + if (i == 0) { + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[0]).getElectrolyteMixingRule() + .setWijParameter(MDEAplusNumb, CO2Numb, value); + ((PhaseModifiedFurstElectrolyteEos) system.getPhases()[1]).getElectrolyteMixingRule() + .setWijParameter(MDEAplusNumb, CO2Numb, value); } + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestAcentric.java b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestAcentric.java index 78f4f81a9b..c3ca2243e7 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestAcentric.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestAcentric.java @@ -3,6 +3,7 @@ * * Created on 23. januar 2001, 22:08 */ + package neqsim.thermo.util.parameterFitting.pureComponentParameterFitting.acentricFactorFitting; import neqsim.statistics.parameterFitting.SampleSet; @@ -20,74 +21,74 @@ * @version $Id: $Id */ public class TestAcentric { - /** - *

- * Constructor for TestAcentric. - *

- */ - public TestAcentric() {} + /** + *

+ * Constructor for TestAcentric. + *

+ */ + public TestAcentric() {} - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); - AcentricFunction function = new AcentricFunction(); - double guess[] = {0.001}; - function.setInitialGuess(guess); + AcentricFunction function = new AcentricFunction(); + double guess[] = {0.001}; + function.setInitialGuess(guess); - SystemInterface testSystem1 = new SystemPrEos(140, 2.0); - testSystem1.addComponent("methane", 78.81102); - testSystem1.init(0); - testSystem1.init(1); + SystemInterface testSystem1 = new SystemPrEos(140, 2.0); + testSystem1.addComponent("methane", 78.81102); + testSystem1.init(0); + testSystem1.init(1); - SystemInterface testSystem2 = new SystemPrEos(140, 2.0); - testSystem2.addComponent("methane", 78.81102); - testSystem2.init(0); - testSystem2.init(1); + SystemInterface testSystem2 = new SystemPrEos(140, 2.0); + testSystem2.addComponent("methane", 78.81102); + testSystem2.init(0); + testSystem2.init(1); - SystemInterface testSystem3 = new SystemPrEos(140, 2.0); - testSystem3.addComponent("methane", 78.81102); - testSystem3.init(0); - testSystem3.init(1); + SystemInterface testSystem3 = new SystemPrEos(140, 2.0); + testSystem3.addComponent("methane", 78.81102); + testSystem3.init(0); + testSystem3.init(1); - SampleValue[] sample = new SampleValue[4]; - double sample1[] = {120}; - double standardDeviation1[] = {0.001}; - sample[0] = new SampleValue(1.916, 0.01, sample1, standardDeviation1); - sample[0].setFunction(function); - sample[0].setThermodynamicSystem(testSystem1); + SampleValue[] sample = new SampleValue[4]; + double sample1[] = {120}; + double standardDeviation1[] = {0.001}; + sample[0] = new SampleValue(1.916, 0.01, sample1, standardDeviation1); + sample[0].setFunction(function); + sample[0].setThermodynamicSystem(testSystem1); - // creating the sampleset - double sample2[] = {130}; - double standardDeviation2[] = {0.001}; - sample[1] = new SampleValue(3.676, 0.01, sample2, standardDeviation2); - sample[1].setFunction(function); - sample[1].setThermodynamicSystem(testSystem2); + // creating the sampleset + double sample2[] = {130}; + double standardDeviation2[] = {0.001}; + sample[1] = new SampleValue(3.676, 0.01, sample2, standardDeviation2); + sample[1].setFunction(function); + sample[1].setThermodynamicSystem(testSystem2); - double sample3[] = {140}; - double standardDeviation3[] = {0.001}; - sample[2] = new SampleValue(6.416, 0.01, sample3, standardDeviation3); - sample[2].setFunction(function); - sample[2].setThermodynamicSystem(testSystem3); + double sample3[] = {140}; + double standardDeviation3[] = {0.001}; + sample[2] = new SampleValue(6.416, 0.01, sample3, standardDeviation3); + sample[2].setFunction(function); + sample[2].setThermodynamicSystem(testSystem3); - double sample4[] = {150}; - double standardDeviation4[] = {0.001}; - sample[3] = new SampleValue(10.405, 0.01, sample4, standardDeviation4); - sample[3].setFunction(function); - sample[3].setThermodynamicSystem(testSystem1); + double sample4[] = {150}; + double standardDeviation4[] = {0.001}; + sample[3] = new SampleValue(10.405, 0.01, sample4, standardDeviation4); + sample[3].setFunction(function); + sample[3].setThermodynamicSystem(testSystem1); - SampleSet sampleSet = new SampleSet(sample); - optim.setSampleSet(sampleSet); + SampleSet sampleSet = new SampleSet(sample); + optim.setSampleSet(sampleSet); - // do simulations - optim.solve(); - // optim.runMonteCarloSimulation(); - optim.displayResult(); - } + // do simulations + optim.solve(); + // optim.runMonteCarloSimulation(); + optim.displayResult(); + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/BaseOperation.java b/src/main/java/neqsim/thermodynamicOperations/BaseOperation.java index 359f67041b..8e3c753d87 100644 --- a/src/main/java/neqsim/thermodynamicOperations/BaseOperation.java +++ b/src/main/java/neqsim/thermodynamicOperations/BaseOperation.java @@ -3,6 +3,7 @@ * * Created on 11. august 2001, 20:32 */ + package neqsim.thermodynamicOperations; import neqsim.thermo.system.SystemInterface; diff --git a/src/main/java/neqsim/thermodynamicOperations/OperationInterface.java b/src/main/java/neqsim/thermodynamicOperations/OperationInterface.java index 18a6103b86..d8572ea4a6 100644 --- a/src/main/java/neqsim/thermodynamicOperations/OperationInterface.java +++ b/src/main/java/neqsim/thermodynamicOperations/OperationInterface.java @@ -3,6 +3,7 @@ * * Created on 2. oktober 2000, 22:14 */ + package neqsim.thermodynamicOperations; import neqsim.thermo.system.SystemInterface; @@ -16,77 +17,77 @@ * @version $Id: $Id */ public interface OperationInterface extends Runnable, java.io.Serializable { - /** - *

- * displayResult. - *

- */ - public void displayResult(); + /** + *

+ * displayResult. + *

+ */ + public void displayResult(); - /** - *

- * getPoints. - *

- * - * @param i a int - * @return an array of {@link double} objects - */ - public double[][] getPoints(int i); + /** + *

+ * getPoints. + *

+ * + * @param i a int + * @return an array of {@link double} objects + */ + public double[][] getPoints(int i); - /** - *

- * addData. - *

- * - * @param name a {@link java.lang.String} object - * @param data an array of {@link double} objects - */ - public void addData(String name, double[][] data); + /** + *

+ * addData. + *

+ * + * @param name a {@link java.lang.String} object + * @param data an array of {@link double} objects + */ + public void addData(String name, double[][] data); - /** - *

- * getResultTable. - *

- * - * @return an array of {@link java.lang.String} objects - */ - public String[][] getResultTable(); + /** + *

+ * getResultTable. + *

+ * + * @return an array of {@link java.lang.String} objects + */ + public String[][] getResultTable(); - /** - *

- * printToFile. - *

- * - * @param name a {@link java.lang.String} object - */ - public void printToFile(String name); + /** + *

+ * printToFile. + *

+ * + * @param name a {@link java.lang.String} object + */ + public void printToFile(String name); - /** - *

- * get. - *

- * - * @param name a {@link java.lang.String} object - * @return an array of {@link double} objects - */ - public double[] get(String name); + /** + *

+ * get. + *

+ * + * @param name a {@link java.lang.String} object + * @return an array of {@link double} objects + */ + public double[] get(String name); - /** - *

- * getJFreeChart. - *

- * - * @param name a {@link java.lang.String} object - * @return a {@link org.jfree.chart.JFreeChart} object - */ - public org.jfree.chart.JFreeChart getJFreeChart(String name); + /** + *

+ * getJFreeChart. + *

+ * + * @param name a {@link java.lang.String} object + * @return a {@link org.jfree.chart.JFreeChart} object + */ + public org.jfree.chart.JFreeChart getJFreeChart(String name); - /** - *

- * getThermoSystem. - *

- * - * @return a {@link neqsim.thermo.system.SystemInterface} object - */ - public SystemInterface getThermoSystem(); + /** + *

+ * getThermoSystem. + *

+ * + * @return a {@link neqsim.thermo.system.SystemInterface} object + */ + public SystemInterface getThermoSystem(); } diff --git a/src/main/java/neqsim/thermodynamicOperations/chemicalEquilibrium/ChemicalEquilibrium.java b/src/main/java/neqsim/thermodynamicOperations/chemicalEquilibrium/ChemicalEquilibrium.java index 52aee0baf9..8180cc172d 100644 --- a/src/main/java/neqsim/thermodynamicOperations/chemicalEquilibrium/ChemicalEquilibrium.java +++ b/src/main/java/neqsim/thermodynamicOperations/chemicalEquilibrium/ChemicalEquilibrium.java @@ -3,6 +3,7 @@ * * Created on 5. mai 2002, 20:53 */ + package neqsim.thermodynamicOperations.chemicalEquilibrium; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java index ec5b05aad1..1c4aa245e7 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java @@ -3,6 +3,7 @@ * * Created on 2. oktober 2000, 22:22 */ + package neqsim.thermodynamicOperations.flashOps; import org.apache.logging.log4j.LogManager; @@ -23,15 +24,28 @@ abstract class Flash extends BaseOperation { public double[] minGibsPhaseLogZ; public double[] minGibsLogFugCoef; - int i = 0, j = 0, iterations = 0, maxNumberOfIterations = 100; - double gibbsEnergy = 0, gibbsEnergyOld = 0; - double Kold = 0, deviation = 0, g0 = 0, g1 = 0; - double lnOldOldOldK[], lnOldOldK[], lnK[], lnOldK[]; - double oldoldDeltalnK[], oldDeltalnK[], deltalnK[]; - double tm[]; + int i = 0; + int j = 0; + int iterations = 0; + int maxNumberOfIterations = 100; + double gibbsEnergy = 0; + double gibbsEnergyOld = 0; + double Kold = 0; + double deviation = 0; + double g0 = 0; + double g1 = 0; + double[] lnOldOldOldK; + double[] lnOldOldK; + double[] lnK; + double[] lnOldK; + double[] oldoldDeltalnK; + double[] oldDeltalnK; + double[] deltalnK; + double[] tm; int lowestGibbsEnergyPhase = 0; sysNewtonRhapsonTPflash secondOrderSolver; - protected boolean solidCheck = false, stabilityCheck = false; + protected boolean solidCheck = false; + protected boolean stabilityCheck = false; boolean findLowesGibsPhaseIsChecked = false; /** @@ -93,7 +107,8 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException, Matrix f = new Matrix(system.getPhases()[0].getNumberOfComponents(), 1); Matrix df = null; int maxiterations = 50; - double fNorm = 1.0e10, fNormOld = 0.0; + double fNorm = 1.0e10; + double fNormOld = 0.0; for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { d[i] = minGibsPhaseLogZ[i] + minGibsLogFugCoef[i]; } @@ -165,8 +180,11 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException, break; } if (iterations % 7 == 0 && fNorm < fNormOld && !secondOrderStabilityAnalysis) { - double vec1 = 0.0, vec2 = 0.0, prod1 = 0.0, prod2 = 0.0; + double vec1 = 0.0; + double vec2 = 0.0; + double prod1 = 0.0; + double prod2 = 0.0; for (i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { vec1 = oldDeltalogWi[i] * oldoldDeltalogWi[i]; vec2 = Math.pow(oldoldDeltalogWi[i], 2.0); diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflash.java index f80070f39f..5a3a489d6b 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflash.java @@ -3,6 +3,7 @@ * * Created on 8. mars 2001, 10:56 */ + package neqsim.thermodynamicOperations.flashOps; import neqsim.thermo.system.SystemInterface; @@ -16,202 +17,199 @@ * @version $Id: $Id */ public class PHflash extends Flash { - private static final long serialVersionUID = 1000; - - double Hspec = 0; - Flash tpFlash; - int type = 0; - - /** - *

- * Constructor for PHflash. - *

- */ - public PHflash() {} - - /** - *

- * Constructor for PHflash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param Hspec a double - * @param type a int - */ - public PHflash(SystemInterface system, double Hspec, int type) { - this.system = system; - this.tpFlash = new TPflash(system); - this.Hspec = Hspec; - this.type = type; - } + private static final long serialVersionUID = 1000; - /** - *

- * calcdQdTT. - *

- * - * @return a double - */ - public double calcdQdTT() { - double dQdTT = -system.getTemperature() * system.getTemperature() * system.getCp(); - return dQdTT / Math.abs(Hspec); - } + double Hspec = 0; + Flash tpFlash; + int type = 0; - /** - *

- * calcdQdT. - *

- * - * @return a double - */ - public double calcdQdT() { - double dQ = (system.getEnthalpy() - Hspec) / Math.abs(Hspec); - return dQ; - } + /** + *

+ * Constructor for PHflash. + *

+ */ + public PHflash() {} - /** - *

- * 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 = 1.0e10; - double factor = 0.8; - double newCorr = 1.0; - system.init(2); - boolean correctFactor = true; - - double maxTemperature = 1e10, minTemperature = 0.0; - - do { - if (Math.abs(error) > Math.abs(erorOld) && factor > 0.1 && correctFactor) { - factor *= 0.5; - } else if (Math.abs(error) < Math.abs(erorOld) && correctFactor) { - factor = iterations / (iterations + 1.0) * 1.0; - } - iterations++; - oldTemp = nyTemp; - newCorr = factor * calcdQdT() / calcdQdTT(); - nyTemp = oldTemp - newCorr; - - if (iterations > 150 && Math.abs(error)<10.0) { - nyTemp = 1.0 / (system.getTemperature() - - Math.signum(system.getTemperature() - 1.0 / nyTemp) * Math.abs(error)); - correctFactor = false; - } - else if (Math.abs(system.getTemperature() - 1.0 / nyTemp) > 10.0) { - nyTemp = 1.0 / (system.getTemperature() - - Math.signum(system.getTemperature() - 1.0 / nyTemp) * 10.0); - correctFactor = false; - } - else if (nyTemp < 0) { - nyTemp = Math.abs(1.0 / (system.getTemperature() + 10.0)); - correctFactor = false; - } else if (Double.isNaN(nyTemp)) { - nyTemp = oldTemp + 0.1; - correctFactor = false; - } else { - correctFactor = true; - } - system.setTemperature(1.0 / nyTemp); - if (system.getTemperature() > maxTemperature) { - system.setTemperature(maxTemperature - 0.1); - } else if (system.getTemperature() < minTemperature) { - system.setTemperature(minTemperature + 0.1); - } - tpFlash.run(); - system.init(2); - erorOld = error; - error = calcdQdT(); - - if (error > 0 && system.getTemperature() > maxTemperature) { - maxTemperature = system.getTemperature(); - } else if (error < 0 && system.getTemperature() < minTemperature) { - minTemperature = system.getTemperature(); - } - } while (((Math.abs(error) + Math.abs(erorOld)) > 1e-8 || iterations < 3) - && iterations < 200); - return 1.0 / nyTemp; - } + /** + *

+ * Constructor for PHflash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param Hspec a double + * @param type a int + */ + public PHflash(SystemInterface system, double Hspec, int type) { + this.system = system; + this.tpFlash = new TPflash(system); + this.Hspec = Hspec; + this.type = type; + } - /** - *

- * solveQ2. - *

- * - * @return a double - */ - public double solveQ2() { - double oldTemp = 1.0 / system.getTemperature(), nyTemp = 1.0 / system.getTemperature(); - double iterations = 1; - double error = 1.0, erorOld = 1.0e10; - double factor = 0.8; - double newCorr = 1.0; - system.init(2); - boolean correctFactor = true; - // System.out.println("temp start " + system.getTemperature()); - do { - if (error > erorOld && factor > 0.1 && correctFactor) { - factor *= 0.5; - } else if (error < erorOld && correctFactor) { - factor = iterations / (iterations + 1.0) * 1.0; - } - iterations++; - oldTemp = nyTemp; - newCorr = factor * calcdQdT() / calcdQdTT(); - nyTemp = oldTemp - newCorr; - if (Math.abs(system.getTemperature() - 1.0 / nyTemp) > 10.0) { - nyTemp = 1.0 / (system.getTemperature() - - Math.signum(system.getTemperature() - 1.0 / nyTemp) * 10.0); - correctFactor = false; - } else if (nyTemp < 0) { - nyTemp = Math.abs(1.0 / (system.getTemperature() + 10.0)); - correctFactor = false; - } else if (Double.isNaN(nyTemp)) { - nyTemp = oldTemp + 0.1; - correctFactor = false; - } else { - correctFactor = true; - } - system.setTemperature(1.0 / nyTemp); - tpFlash.run(); - system.init(2); - erorOld = error; - error = Math.abs(calcdQdT()); - // error = Math.abs((1.0 / nyTemp - 1.0 / oldTemp) / (1.0 / oldTemp)); - // if(iterations>100) System.out.println("temp " + system.getTemperature() + " - // iter "+ iterations + " error "+ error + " correction " + newCorr + " factor - // "+ factor); - } while (((error + erorOld) > 1e-8 || iterations < 3) && iterations < 200); - // System.out.println("temp " + system.getTemperature() + " iter "+ iterations + - // " error "+ error ); - return 1.0 / nyTemp; - } + /** + *

+ * calcdQdTT. + *

+ * + * @return a double + */ + public double calcdQdTT() { + double dQdTT = -system.getTemperature() * system.getTemperature() * system.getCp(); + return dQdTT / Math.abs(Hspec); + } - /** {@inheritDoc} */ - @Override - public void run() { - tpFlash.run(); - // System.out.println("enthalpy start: " + system.getEnthalpy()); - if (type == 0) { - solveQ(); - } else { - sysNewtonRhapsonPHflash secondOrderSolver = new sysNewtonRhapsonPHflash(system, 2, - system.getPhases()[0].getNumberOfComponents(), 0); - secondOrderSolver.setSpec(Hspec); - secondOrderSolver.solve(1); - } - // System.out.println("enthalpy: " + system.getEnthalpy()); - // System.out.println("Temperature: " + system.getTemperature()); - } + /** + *

+ * calcdQdT. + *

+ * + * @return a double + */ + public double calcdQdT() { + double dQ = (system.getEnthalpy() - Hspec) / Math.abs(Hspec); + return dQ; + } - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - return null; + /** + *

+ * 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 = 1.0e10; + double factor = 0.8; + double newCorr = 1.0; + system.init(2); + boolean correctFactor = true; + + double maxTemperature = 1e10, minTemperature = 0.0; + + do { + if (Math.abs(error) > Math.abs(erorOld) && factor > 0.1 && correctFactor) { + factor *= 0.5; + } else if (Math.abs(error) < Math.abs(erorOld) && correctFactor) { + factor = iterations / (iterations + 1.0) * 1.0; + } + iterations++; + oldTemp = nyTemp; + newCorr = factor * calcdQdT() / calcdQdTT(); + nyTemp = oldTemp - newCorr; + + if (iterations > 150 && Math.abs(error) < 10.0) { + nyTemp = 1.0 / (system.getTemperature() + - Math.signum(system.getTemperature() - 1.0 / nyTemp) * Math.abs(error)); + correctFactor = false; + } else if (Math.abs(system.getTemperature() - 1.0 / nyTemp) > 10.0) { + nyTemp = 1.0 / (system.getTemperature() + - Math.signum(system.getTemperature() - 1.0 / nyTemp) * 10.0); + correctFactor = false; + } else if (nyTemp < 0) { + nyTemp = Math.abs(1.0 / (system.getTemperature() + 10.0)); + correctFactor = false; + } else if (Double.isNaN(nyTemp)) { + nyTemp = oldTemp + 0.1; + correctFactor = false; + } else { + correctFactor = true; + } + system.setTemperature(1.0 / nyTemp); + if (system.getTemperature() > maxTemperature) { + system.setTemperature(maxTemperature - 0.1); + } else if (system.getTemperature() < minTemperature) { + system.setTemperature(minTemperature + 0.1); + } + tpFlash.run(); + system.init(2); + erorOld = error; + error = calcdQdT(); + + if (error > 0 && system.getTemperature() > maxTemperature) { + maxTemperature = system.getTemperature(); + } else if (error < 0 && system.getTemperature() < minTemperature) { + minTemperature = system.getTemperature(); + } + } while (((Math.abs(error) + Math.abs(erorOld)) > 1e-8 || iterations < 3) && iterations < 200); + return 1.0 / nyTemp; + } + + /** + *

+ * solveQ2. + *

+ * + * @return a double + */ + public double solveQ2() { + double oldTemp = 1.0 / system.getTemperature(), nyTemp = 1.0 / system.getTemperature(); + double iterations = 1; + double error = 1.0, erorOld = 1.0e10; + double factor = 0.8; + double newCorr = 1.0; + system.init(2); + boolean correctFactor = true; + // System.out.println("temp start " + system.getTemperature()); + do { + if (error > erorOld && factor > 0.1 && correctFactor) { + factor *= 0.5; + } else if (error < erorOld && correctFactor) { + factor = iterations / (iterations + 1.0) * 1.0; + } + iterations++; + oldTemp = nyTemp; + newCorr = factor * calcdQdT() / calcdQdTT(); + nyTemp = oldTemp - newCorr; + if (Math.abs(system.getTemperature() - 1.0 / nyTemp) > 10.0) { + nyTemp = 1.0 / (system.getTemperature() + - Math.signum(system.getTemperature() - 1.0 / nyTemp) * 10.0); + correctFactor = false; + } else if (nyTemp < 0) { + nyTemp = Math.abs(1.0 / (system.getTemperature() + 10.0)); + correctFactor = false; + } else if (Double.isNaN(nyTemp)) { + nyTemp = oldTemp + 0.1; + correctFactor = false; + } else { + correctFactor = true; + } + system.setTemperature(1.0 / nyTemp); + tpFlash.run(); + system.init(2); + erorOld = error; + error = Math.abs(calcdQdT()); + // error = Math.abs((1.0 / nyTemp - 1.0 / oldTemp) / (1.0 / oldTemp)); + // if(iterations>100) System.out.println("temp " + system.getTemperature() + " + // iter "+ iterations + " error "+ error + " correction " + newCorr + " factor + // "+ factor); + } while (((error + erorOld) > 1e-8 || iterations < 3) && iterations < 200); + // System.out.println("temp " + system.getTemperature() + " iter "+ iterations + + // " error "+ error ); + return 1.0 / nyTemp; + } + + /** {@inheritDoc} */ + @Override + public void run() { + tpFlash.run(); + // System.out.println("enthalpy start: " + system.getEnthalpy()); + if (type == 0) { + solveQ(); + } else { + sysNewtonRhapsonPHflash secondOrderSolver = + new sysNewtonRhapsonPHflash(system, 2, system.getPhases()[0].getNumberOfComponents(), 0); + secondOrderSolver.setSpec(Hspec); + secondOrderSolver.solve(1); } + // System.out.println("enthalpy: " + system.getEnthalpy()); + // System.out.println("Temperature: " + system.getTemperature()); + } + + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + return null; + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflashGERG2008.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflashGERG2008.java index 500e04b73d..38bd9b2464 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflashGERG2008.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflashGERG2008.java @@ -3,6 +3,7 @@ * * Created on 8. mars 2001, 10:56 */ + package neqsim.thermodynamicOperations.flashOps; import neqsim.thermo.system.SystemInterface; @@ -16,207 +17,205 @@ * @version $Id: $Id */ public class PHflashGERG2008 extends Flash { - private static final long serialVersionUID = 1000; - - double Hspec = 0; - Flash tpFlash; - double enthalpy_GERG2008 = 0.0; - double cP_GERG2008 = 0.0; - - /** - *

- * Constructor for PHflashGERG2008. - *

- */ - public PHflashGERG2008() {} - - /** - *

- * Constructor for PHflash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param Hspec a double - */ - public PHflashGERG2008(SystemInterface system, double Hspec) { - this.system = system; - this.tpFlash = new TPflash(system); - this.Hspec = Hspec; - } - - /** - *

- * calcdQdTT. - *

- * - * @return a double - */ - public double calcdQdTT() { - double dQdTT = -system.getTemperature() * system.getTemperature() * cP_GERG2008; - return dQdTT / Math.abs(Hspec); - } - - /** - *

- * calcdQdT. - *

- * - * @return a double - */ - public double calcdQdT() { - double dQ = (enthalpy_GERG2008 - Hspec) / Math.abs(Hspec); - 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 = 1.0e10; - double factor = 0.8; - double newCorr = 1.0; - system.init(2); - boolean correctFactor = true; - - double maxTemperature = 1e10, minTemperature = 0.0; - - do { - if (Math.abs(error) > Math.abs(erorOld) && factor > 0.1 && correctFactor) { - factor *= 0.5; - } else if (Math.abs(error) < Math.abs(erorOld) && correctFactor) { - factor = iterations / (iterations + 1.0) * 1.0; - } - 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 - newCorr = factor * calcdQdT() / calcdQdTT(); - nyTemp = oldTemp - newCorr; - if (Math.abs(system.getTemperature() - 1.0 / nyTemp) > 10.0) { - nyTemp = 1.0 / (system.getTemperature() - - Math.signum(system.getTemperature() - 1.0 / nyTemp) * 10.0); - correctFactor = false; - } else if (nyTemp < 0) { - nyTemp = Math.abs(1.0 / (system.getTemperature() + 10.0)); - correctFactor = false; - } else if (Double.isNaN(nyTemp)) { - nyTemp = oldTemp + 0.1; - correctFactor = false; - } else { - correctFactor = true; - } - system.setTemperature(1.0 / nyTemp); - if (system.getTemperature() > maxTemperature) { - system.setTemperature(maxTemperature - 0.1); - } else if (system.getTemperature() < minTemperature) { - system.setTemperature(minTemperature + 0.1); - } - erorOld = error; - error = calcdQdT(); - - if (error > 0 && system.getTemperature() > maxTemperature) { - maxTemperature = system.getTemperature(); - } else if (error < 0 && system.getTemperature() < minTemperature) { - 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); - */ - } while (((Math.abs(error) + Math.abs(erorOld)) > 1e-8 || iterations < 3) - && iterations < 200); - // System.out.println("temp " + system.getTemperature() + " iter " + iterations - // + " error " + error); - return 1.0 / nyTemp; - } - - /** - *

- * solveQ2. - *

- * - * @return a double - */ - public double solveQ2() { - double oldTemp = 1.0 / system.getTemperature(), nyTemp = 1.0 / system.getTemperature(); - double iterations = 1; - double error = 1.0, erorOld = 1.0e10; - double factor = 0.8; - double newCorr = 1.0; - system.init(2); - boolean correctFactor = true; - // System.out.println("temp start " + system.getTemperature()); - do { - if (error > erorOld && factor > 0.1 && correctFactor) { - factor *= 0.5; - } else if (error < erorOld && correctFactor) { - factor = iterations / (iterations + 1.0) * 1.0; - } - 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 - - newCorr = factor * calcdQdT() / calcdQdTT(); - nyTemp = oldTemp - newCorr; - if (Math.abs(system.getTemperature() - 1.0 / nyTemp) > 10.0) { - nyTemp = 1.0 / (system.getTemperature() - - Math.signum(system.getTemperature() - 1.0 / nyTemp) * 10.0); - correctFactor = false; - } else if (nyTemp < 0) { - nyTemp = Math.abs(1.0 / (system.getTemperature() + 10.0)); - correctFactor = false; - } else if (Double.isNaN(nyTemp)) { - nyTemp = oldTemp + 0.1; - correctFactor = false; - } else { - correctFactor = true; - } - system.setTemperature(1.0 / nyTemp); - erorOld = error; - error = Math.abs(calcdQdT()); - // error = Math.abs((1.0 / nyTemp - 1.0 / oldTemp) / (1.0 / oldTemp)); - // if(iterations>100) System.out.println("temp " + system.getTemperature() + " - // iter "+ iterations + " error "+ error + " correction " + newCorr + " factor - // "+ factor); - } while (((error + erorOld) > 1e-8 || iterations < 3) && iterations < 200); - // System.out.println("temp " + system.getTemperature() + " iter "+ iterations + - // " error "+ error ); - return 1.0 / nyTemp; - } - - /** {@inheritDoc} */ - @Override - public void run() { - tpFlash.run(); - if (system.getNumberOfPhases() > 1) { - logger.error("PSFlashGERG2008 only support single phase gas calculations"); - return; - } - solveQ(); - system.init(3); - } - - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - return null; + private static final long serialVersionUID = 1000; + + double Hspec = 0; + Flash tpFlash; + double enthalpy_GERG2008 = 0.0; + double cP_GERG2008 = 0.0; + + /** + *

+ * Constructor for PHflashGERG2008. + *

+ */ + public PHflashGERG2008() {} + + /** + *

+ * Constructor for PHflash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param Hspec a double + */ + public PHflashGERG2008(SystemInterface system, double Hspec) { + this.system = system; + this.tpFlash = new TPflash(system); + this.Hspec = Hspec; + } + + /** + *

+ * calcdQdTT. + *

+ * + * @return a double + */ + public double calcdQdTT() { + double dQdTT = -system.getTemperature() * system.getTemperature() * cP_GERG2008; + return dQdTT / Math.abs(Hspec); + } + + /** + *

+ * calcdQdT. + *

+ * + * @return a double + */ + public double calcdQdT() { + double dQ = (enthalpy_GERG2008 - Hspec) / Math.abs(Hspec); + 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 = 1.0e10; + double factor = 0.8; + double newCorr = 1.0; + system.init(2); + boolean correctFactor = true; + + double maxTemperature = 1e10, minTemperature = 0.0; + + do { + if (Math.abs(error) > Math.abs(erorOld) && factor > 0.1 && correctFactor) { + factor *= 0.5; + } else if (Math.abs(error) < Math.abs(erorOld) && correctFactor) { + factor = iterations / (iterations + 1.0) * 1.0; + } + 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 + newCorr = factor * calcdQdT() / calcdQdTT(); + nyTemp = oldTemp - newCorr; + if (Math.abs(system.getTemperature() - 1.0 / nyTemp) > 10.0) { + nyTemp = 1.0 / (system.getTemperature() + - Math.signum(system.getTemperature() - 1.0 / nyTemp) * 10.0); + correctFactor = false; + } else if (nyTemp < 0) { + nyTemp = Math.abs(1.0 / (system.getTemperature() + 10.0)); + correctFactor = false; + } else if (Double.isNaN(nyTemp)) { + nyTemp = oldTemp + 0.1; + correctFactor = false; + } else { + correctFactor = true; + } + system.setTemperature(1.0 / nyTemp); + if (system.getTemperature() > maxTemperature) { + system.setTemperature(maxTemperature - 0.1); + } else if (system.getTemperature() < minTemperature) { + system.setTemperature(minTemperature + 0.1); + } + erorOld = error; + error = calcdQdT(); + + if (error > 0 && system.getTemperature() > maxTemperature) { + maxTemperature = system.getTemperature(); + } else if (error < 0 && system.getTemperature() < minTemperature) { + 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); + */ + } while (((Math.abs(error) + Math.abs(erorOld)) > 1e-8 || iterations < 3) && iterations < 200); + // System.out.println("temp " + system.getTemperature() + " iter " + iterations + // + " error " + error); + return 1.0 / nyTemp; + } + + /** + *

+ * solveQ2. + *

+ * + * @return a double + */ + public double solveQ2() { + double oldTemp = 1.0 / system.getTemperature(), nyTemp = 1.0 / system.getTemperature(); + double iterations = 1; + double error = 1.0, erorOld = 1.0e10; + double factor = 0.8; + double newCorr = 1.0; + system.init(2); + boolean correctFactor = true; + // System.out.println("temp start " + system.getTemperature()); + do { + if (error > erorOld && factor > 0.1 && correctFactor) { + factor *= 0.5; + } else if (error < erorOld && correctFactor) { + factor = iterations / (iterations + 1.0) * 1.0; + } + 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 + + newCorr = factor * calcdQdT() / calcdQdTT(); + nyTemp = oldTemp - newCorr; + if (Math.abs(system.getTemperature() - 1.0 / nyTemp) > 10.0) { + nyTemp = 1.0 / (system.getTemperature() + - Math.signum(system.getTemperature() - 1.0 / nyTemp) * 10.0); + correctFactor = false; + } else if (nyTemp < 0) { + nyTemp = Math.abs(1.0 / (system.getTemperature() + 10.0)); + correctFactor = false; + } else if (Double.isNaN(nyTemp)) { + nyTemp = oldTemp + 0.1; + correctFactor = false; + } else { + correctFactor = true; + } + system.setTemperature(1.0 / nyTemp); + erorOld = error; + error = Math.abs(calcdQdT()); + // error = Math.abs((1.0 / nyTemp - 1.0 / oldTemp) / (1.0 / oldTemp)); + // if(iterations>100) System.out.println("temp " + system.getTemperature() + " + // iter "+ iterations + " error "+ error + " correction " + newCorr + " factor + // "+ factor); + } while (((error + erorOld) > 1e-8 || iterations < 3) && iterations < 200); + // System.out.println("temp " + system.getTemperature() + " iter "+ iterations + + // " error "+ error ); + return 1.0 / nyTemp; + } + + /** {@inheritDoc} */ + @Override + public void run() { + tpFlash.run(); + if (system.getNumberOfPhases() > 1) { + logger.error("PSFlashGERG2008 only support single phase gas calculations"); + return; } + solveQ(); + system.init(3); + } + + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + return null; + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/PHsolidFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/PHsolidFlash.java index 02734ac3f9..acc1c7c23b 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/PHsolidFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/PHsolidFlash.java @@ -3,6 +3,7 @@ * * Created on 8. mars 2001, 10:56 */ + package neqsim.thermodynamicOperations.flashOps; import org.apache.logging.log4j.LogManager; @@ -18,79 +19,79 @@ * @version $Id: $Id */ public class PHsolidFlash extends Flash { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(PHsolidFlash.class); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(PHsolidFlash.class); - Flash tpFlash; - int refluxPhase = 0; - double enthalpyspec = 0.5; + Flash tpFlash; + int refluxPhase = 0; + double enthalpyspec = 0.5; - /** - *

- * Constructor for PHsolidFlash. - *

- */ - public PHsolidFlash() {} + /** + *

+ * Constructor for PHsolidFlash. + *

+ */ + public PHsolidFlash() {} - /** - *

- * Constructor for PHsolidFlash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param ent a double - */ - public PHsolidFlash(SystemInterface system, double ent) { - this.system = system; - this.tpFlash = new TPflash(this.system, true); - this.enthalpyspec = ent; - } + /** + *

+ * Constructor for PHsolidFlash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param ent a double + */ + public PHsolidFlash(SystemInterface system, double ent) { + this.system = system; + this.tpFlash = new TPflash(this.system, true); + this.enthalpyspec = ent; + } - /** {@inheritDoc} */ - @Override - public void run() { - // logger.info("enthalpy: " + system.getEnthalpy()); - double err = 0; - int iter = 0; - double f_func = 0.0, f_func_old = 0.0, df_func_dt = 0, t_old = 0, t_oldold = 0.0; - // ThermodynamicOperations ops = new ThermodynamicOperations(system); - tpFlash.run(); - double dt = 10; - do { - iter++; + /** {@inheritDoc} */ + @Override + public void run() { + // logger.info("enthalpy: " + system.getEnthalpy()); + double err = 0; + int iter = 0; + double f_func = 0.0, f_func_old = 0.0, df_func_dt = 0, t_old = 0, t_oldold = 0.0; + // ThermodynamicOperations ops = new ThermodynamicOperations(system); + tpFlash.run(); + double dt = 10; + do { + iter++; - f_func_old = f_func; - t_oldold = t_old; - t_old = system.getTemperature(); - system.init(3); - f_func = enthalpyspec - system.getEnthalpy(); - logger.info("entalp diff " + f_func); - df_func_dt = (f_func - f_func_old) / (t_old - t_oldold); + f_func_old = f_func; + t_oldold = t_old; + t_old = system.getTemperature(); + system.init(3); + f_func = enthalpyspec - system.getEnthalpy(); + logger.info("entalp diff " + f_func); + df_func_dt = (f_func - f_func_old) / (t_old - t_oldold); - err = Math.abs(f_func); + err = Math.abs(f_func); - if (iter < 2) { - if (f_func > 0) { - system.setTemperature(system.getTemperature() + 0.1); - } else if (f_func < 0) { - system.setTemperature(system.getTemperature() - 0.1); - } - } else { - dt = f_func / df_func_dt; - if (Math.abs(dt) > 2.0) { - dt = Math.signum(dt) * 2.0; - } - system.setTemperature(system.getTemperature() - 0.8 * dt); - } - tpFlash.run(); + if (iter < 2) { + if (f_func > 0) { + system.setTemperature(system.getTemperature() + 0.1); + } else if (f_func < 0) { + system.setTemperature(system.getTemperature() - 0.1); + } + } else { + dt = f_func / df_func_dt; + if (Math.abs(dt) > 2.0) { + dt = Math.signum(dt) * 2.0; + } + system.setTemperature(system.getTemperature() - 0.8 * dt); + } + tpFlash.run(); - logger.info("temp " + system.getTemperature() + " err " + err); - } while (Math.abs(dt) > 1e-8 && iter < 200); - } + logger.info("temp " + system.getTemperature() + " err " + err); + } while (Math.abs(dt) > 1e-8 && iter < 200); + } - /** {@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/SolidFlash12.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/SolidFlash12.java index 1fac6257d7..023ab9ea93 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/SolidFlash12.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/SolidFlash12.java @@ -3,6 +3,7 @@ * * Created on 2. oktober 2000, 22:26 */ + package neqsim.thermodynamicOperations.flashOps; import org.apache.logging.log4j.LogManager; @@ -20,395 +21,391 @@ * @version $Id: $Id */ public class SolidFlash12 extends TPflash { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(SolidFlash12.class); - - // SystemInterface clonedSystem; - boolean multiPhaseTest = false; - double dQdbeta[]; - double Qmatrix[][]; - double E[]; - double Q = 0; - int solidsNumber = 0; - int solidIndex = 0; - - /** - *

- * Constructor for SolidFlash12. - *

- */ - public SolidFlash12() {} - - /** - *

- * Constructor for SolidFlash12. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public SolidFlash12(SystemInterface system) { - super(system); - } - - /** - *

- * calcMultiPhaseBeta. - *

- */ - public void calcMultiPhaseBeta() {} - - /** - *

- * setXY. - *

- */ - public void setXY() { - for (int k = 0; k < system.getNumberOfPhases() - solidsNumber; k++) { - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - if (i != solidIndex) { - system.getPhase(k).getComponent(i) - .setx(system.getPhase(0).getComponent(i).getz() / E[i] - / system.getPhase(k).getComponent(i).getFugacityCoefficient()); - } else { - system.getPhase(k).getComponent(i) - .setx(system.getPhases()[3].getComponent(i).getFugacityCoefficient() - / system.getPhase(k).getComponent(i).getFugacityCoefficient()); - } - } + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(SolidFlash12.class); + + // SystemInterface clonedSystem; + boolean multiPhaseTest = false; + double dQdbeta[]; + double Qmatrix[][]; + double E[]; + double Q = 0; + int solidsNumber = 0; + int solidIndex = 0; + + /** + *

+ * Constructor for SolidFlash12. + *

+ */ + public SolidFlash12() {} + + /** + *

+ * Constructor for SolidFlash12. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public SolidFlash12(SystemInterface system) { + super(system); + } + + /** + *

+ * calcMultiPhaseBeta. + *

+ */ + public void calcMultiPhaseBeta() {} + + /** + *

+ * setXY. + *

+ */ + public void setXY() { + for (int k = 0; k < system.getNumberOfPhases() - solidsNumber; k++) { + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + if (i != solidIndex) { + system.getPhase(k).getComponent(i).setx(system.getPhase(0).getComponent(i).getz() / E[i] + / system.getPhase(k).getComponent(i).getFugacityCoefficient()); + } else { + system.getPhase(k).getComponent(i) + .setx(system.getPhases()[3].getComponent(i).getFugacityCoefficient() + / system.getPhase(k).getComponent(i).getFugacityCoefficient()); } + } } - - /** - *

- * checkX. - *

- */ - public void checkX() { - for (int k = 0; k < system.getNumberOfPhases() - 1; k++) { - double x = 0.0; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - x += system.getPhase(k).getComponent(i).getx(); - } - logger.info("x tot " + x + " PHASE " + k); - if (x < 1.0 - 1e-6) { - // logger.info("removing phase " + k); - system.setBeta(system.getNumberOfPhases() - 2, - system.getBeta(system.getNumberOfPhases() - 1)); - system.setBeta(0, 1.0 - system.getBeta(system.getNumberOfPhases() - 1)); - system.setNumberOfPhases(system.getNumberOfPhases() - 1); - system.setPhaseIndex(system.getNumberOfPhases() - 1, 3); - system.init(1); - calcE(); - setXY(); - return; - } - } + } + + /** + *

+ * checkX. + *

+ */ + public void checkX() { + for (int k = 0; k < system.getNumberOfPhases() - 1; k++) { + double x = 0.0; + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + x += system.getPhase(k).getComponent(i).getx(); + } + logger.info("x tot " + x + " PHASE " + k); + if (x < 1.0 - 1e-6) { + // logger.info("removing phase " + k); + system.setBeta(system.getNumberOfPhases() - 2, + system.getBeta(system.getNumberOfPhases() - 1)); + system.setBeta(0, 1.0 - system.getBeta(system.getNumberOfPhases() - 1)); + system.setNumberOfPhases(system.getNumberOfPhases() - 1); + system.setPhaseIndex(system.getNumberOfPhases() - 1, 3); + system.init(1); + calcE(); + setXY(); + return; + } } - - /** - *

- * calcE. - *

- */ - public void calcE() { - E = new double[system.getPhases()[0].getNumberOfComponents()]; - - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - E[i] = 0.0; - for (int k = 0; k < system.getNumberOfPhases() - solidsNumber; k++) { - E[i] += system.getBeta(k) - / system.getPhase(k).getComponent(i).getFugacityCoefficient(); - } - } + } + + /** + *

+ * calcE. + *

+ */ + public void calcE() { + E = new double[system.getPhases()[0].getNumberOfComponents()]; + + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + E[i] = 0.0; + for (int k = 0; k < system.getNumberOfPhases() - solidsNumber; k++) { + E[i] += system.getBeta(k) / system.getPhase(k).getComponent(i).getFugacityCoefficient(); + } } - - /** - *

- * calcQ. - *

- * - * @return a double - */ - public double calcQ() { - Q = 0; - double betaTotal = 0; - dQdbeta = new double[system.getNumberOfPhases() - solidsNumber]; - Qmatrix = new double[system.getNumberOfPhases() - solidsNumber][system.getNumberOfPhases() - - solidsNumber]; - - for (int k = 0; k < system.getNumberOfPhases() - solidsNumber; k++) { - betaTotal += system.getBeta(k); - } - - Q = betaTotal; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - if (i != solidIndex) { - Q -= Math.log(E[i]) * system.getPhase(0).getComponents()[i].getz(); - } - } - - for (int i = 0; i < solidsNumber; i++) { - Q += system.getPhase(0).getComponent(solidIndex).getz() * (1 - Math - .log(system.getPhase(0).getComponent(solidIndex).getz() / system.getPhases()[3] - .getComponent(solidIndex).getFugacityCoefficient())); - for (int j = 0; j < system.getNumberOfPhases() - solidsNumber; j++) { - Q -= system.getBeta(j) - * system.getPhases()[3].getComponent(solidIndex).getFugacityCoefficient() - / system.getPhase(j).getComponent(solidIndex).getFugacityCoefficient(); - } - } - - for (int k = 0; k < system.getNumberOfPhases() - solidsNumber; k++) { - dQdbeta[k] = 1.0; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - if (i == solidIndex) { - dQdbeta[k] -= system.getPhases()[3].getComponents()[solidIndex] - .getFugacityCoefficient() - / system.getPhase(k).getComponent(solidIndex).getFugacityCoefficient(); - } else { - dQdbeta[k] -= system.getPhase(0).getComponent(i).getz() / E[i] - / system.getPhase(k).getComponent(i).getFugacityCoefficient(); - } - } - } - - for (int i = 0; i < system.getNumberOfPhases() - solidsNumber; i++) { - for (int j = 0; j < system.getNumberOfPhases() - solidsNumber; j++) { - Qmatrix[i][j] = 0.0; - for (int k = 0; k < system.getPhases()[0].getNumberOfComponents(); k++) { - if (k != solidIndex) { - Qmatrix[i][j] += system.getPhase(0).getComponent(k).getz() / (E[k] * E[k] - * system.getPhase(j).getComponent(k).getFugacityCoefficient() - * system.getPhase(i).getComponent(k).getFugacityCoefficient()); - } - } - } - } - return Q; + } + + /** + *

+ * calcQ. + *

+ * + * @return a double + */ + public double calcQ() { + Q = 0; + double betaTotal = 0; + dQdbeta = new double[system.getNumberOfPhases() - solidsNumber]; + Qmatrix = new double[system.getNumberOfPhases() - solidsNumber][system.getNumberOfPhases() + - solidsNumber]; + + for (int k = 0; k < system.getNumberOfPhases() - solidsNumber; k++) { + betaTotal += system.getBeta(k); } - /** - *

- * solveBeta. - *

- */ - public void solveBeta() { - double oldBeta[] = new double[system.getNumberOfPhases() - solidsNumber]; - // double newBeta[] = new double[system.getNumberOfPhases() - solidsNumber]; - int iter = 0; - Matrix ans = new Matrix(system.getNumberOfPhases() - solidsNumber, 1); - do { - system.init(1); - calcE(); - // setXY(); - calcQ(); - - oldBeta = new double[system.getNumberOfPhases() - solidsNumber]; - // newBeta = new double[system.getNumberOfPhases() - solidsNumber]; - iter++; - for (int k = 0; k < system.getNumberOfPhases() - solidsNumber; k++) { - oldBeta[k] = system.getBeta(k); - } - - Matrix betaMatrix = new Matrix(oldBeta, 1).transpose(); - // Matrix betaMatrixTemp = new Matrix(oldBeta, 1).transpose(); - Matrix dQM = new Matrix(dQdbeta, 1); - Matrix dQdBM = new Matrix(Qmatrix); - - try { - ans = dQdBM.solve(dQM.transpose()); - } catch (Exception e) { - // ans = dQdBM.solve(dQM.transpose()); - } - dQM.print(10, 10); - dQdBM.print(10, 10); - ans.print(30, 30); - // double betaReductionFactor = 1.0; - // betaMatrixTemp = betaMatrix.minus(ans.times(betaReductionFactor)); - // betaMatrixTemp.print(10, 2); - - // double minBetaTem = 1000000; - // int minBetaIndex = 0; - - /* - * for (int i = 0; i < system.getNumberOfPhases() - solidsNumber; i++) { if - * (betaMatrixTemp.get(i, 0) < minBetaTem) { minBetaTem = betaMatrixTemp.get(i, 0); - * minBetaIndex = i; } } - */ - - /* - * for (int k = 0; k < system.getNumberOfPhases() - solidsNumber; k++) { if ((minBetaTem - * < -1.0E-10)) { betaReductionFactor = 1 - betaMatrixTemp.get(minBetaIndex, 0) / - * ans.get(minBetaIndex, 0); } } - */ - - betaMatrix.minusEquals(ans.times((iter + 1.0) / (100.0 + iter))); - // betaMatrix.print(10, 2); - - for (int k = 0; k < system.getNumberOfPhases() - solidsNumber; k++) { - system.setBeta(k, betaMatrix.get(k, 0)); - if (betaMatrix.get(k, 0) < 0) { - system.setBeta(k, 1e-9); - } - if (betaMatrix.get(k, 0) > 1) { - system.setBeta(k, 1 - 1e-9); - } - } - calcE(); - setXY(); - calcSolidBeta(); - } while ((ans.norm2() > 1e-8 && iter < 100) || iter < 2); + Q = betaTotal; + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + if (i != solidIndex) { + Q -= Math.log(E[i]) * system.getPhase(0).getComponents()[i].getz(); + } + } - system.init(1); - setXY(); + for (int i = 0; i < solidsNumber; i++) { + Q += system.getPhase(0).getComponent(solidIndex).getz() + * (1 - Math.log(system.getPhase(0).getComponent(solidIndex).getz() + / system.getPhases()[3].getComponent(solidIndex).getFugacityCoefficient())); + for (int j = 0; j < system.getNumberOfPhases() - solidsNumber; j++) { + Q -= system.getBeta(j) + * system.getPhases()[3].getComponent(solidIndex).getFugacityCoefficient() + / system.getPhase(j).getComponent(solidIndex).getFugacityCoefficient(); + } } - /** - *

- * checkGibbs. - *

- */ - public void checkGibbs() { - double gibbs1 = 0, gibbs2 = 0; - for (int i = 0; i < system.getNumberOfPhases() - 1; i++) { - system.setPhaseType(i, 0); - system.init(1); - gibbs1 = system.getPhase(i).getGibbsEnergy(); - system.setPhaseType(i, 1); - system.init(1); - gibbs2 = system.getPhase(i).getGibbsEnergy(); - if (gibbs1 < gibbs2) { - system.setPhaseType(i, 0); - } else { - system.setPhaseType(i, 1); - } - system.init(1); + for (int k = 0; k < system.getNumberOfPhases() - solidsNumber; k++) { + dQdbeta[k] = 1.0; + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + if (i == solidIndex) { + dQdbeta[k] -= system.getPhases()[3].getComponents()[solidIndex].getFugacityCoefficient() + / system.getPhase(k).getComponent(solidIndex).getFugacityCoefficient(); + } else { + dQdbeta[k] -= system.getPhase(0).getComponent(i).getz() / E[i] + / system.getPhase(k).getComponent(i).getFugacityCoefficient(); } + } } - /** - *

- * calcSolidBeta. - *

- */ - public void calcSolidBeta() { - double tempVar = system.getPhase(0).getComponents()[solidIndex].getz(); - // double beta = 1.0; - for (int i = 0; i < system.getNumberOfPhases() - 1; i++) { - tempVar -= system.getBeta(i) - * system.getPhase(3).getComponent(solidIndex).getFugacityCoefficient() - / system.getPhase(i).getComponent(solidIndex).getFugacityCoefficient(); - // beta -= system.getBeta(i); - } - if (tempVar > 0 && tempVar < 1.0) { - system.setBeta(system.getNumberOfPhases() - 1, tempVar); + for (int i = 0; i < system.getNumberOfPhases() - solidsNumber; i++) { + for (int j = 0; j < system.getNumberOfPhases() - solidsNumber; j++) { + Qmatrix[i][j] = 0.0; + for (int k = 0; k < system.getPhases()[0].getNumberOfComponents(); k++) { + if (k != solidIndex) { + Qmatrix[i][j] += system.getPhase(0).getComponent(k).getz() + / (E[k] * E[k] * system.getPhase(j).getComponent(k).getFugacityCoefficient() + * system.getPhase(i).getComponent(k).getFugacityCoefficient()); + } } + } } - - /** {@inheritDoc} */ - @Override - public void run() { - int iter = 0; - - ThermodynamicOperations ops = new ThermodynamicOperations(system); - system.setSolidPhaseCheck(false); - ops.TPflash(); - system.setSolidPhaseCheck(true); - if (checkAndAddSolidPhase() == 0) { - return; + return Q; + } + + /** + *

+ * solveBeta. + *

+ */ + public void solveBeta() { + double oldBeta[] = new double[system.getNumberOfPhases() - solidsNumber]; + // double newBeta[] = new double[system.getNumberOfPhases() - solidsNumber]; + int iter = 0; + Matrix ans = new Matrix(system.getNumberOfPhases() - solidsNumber, 1); + do { + system.init(1); + calcE(); + // setXY(); + calcQ(); + + oldBeta = new double[system.getNumberOfPhases() - solidsNumber]; + // newBeta = new double[system.getNumberOfPhases() - solidsNumber]; + iter++; + for (int k = 0; k < system.getNumberOfPhases() - solidsNumber; k++) { + oldBeta[k] = system.getBeta(k); + } + + Matrix betaMatrix = new Matrix(oldBeta, 1).transpose(); + // Matrix betaMatrixTemp = new Matrix(oldBeta, 1).transpose(); + Matrix dQM = new Matrix(dQdbeta, 1); + Matrix dQdBM = new Matrix(Qmatrix); + + try { + ans = dQdBM.solve(dQM.transpose()); + } catch (Exception e) { + // ans = dQdBM.solve(dQM.transpose()); + } + dQM.print(10, 10); + dQdBM.print(10, 10); + ans.print(30, 30); + // double betaReductionFactor = 1.0; + // betaMatrixTemp = betaMatrix.minus(ans.times(betaReductionFactor)); + // betaMatrixTemp.print(10, 2); + + // double minBetaTem = 1000000; + // int minBetaIndex = 0; + + /* + * for (int i = 0; i < system.getNumberOfPhases() - solidsNumber; i++) { if + * (betaMatrixTemp.get(i, 0) < minBetaTem) { minBetaTem = betaMatrixTemp.get(i, 0); + * minBetaIndex = i; } } + */ + + /* + * for (int k = 0; k < system.getNumberOfPhases() - solidsNumber; k++) { if ((minBetaTem < + * -1.0E-10)) { betaReductionFactor = 1 - betaMatrixTemp.get(minBetaIndex, 0) / + * ans.get(minBetaIndex, 0); } } + */ + + betaMatrix.minusEquals(ans.times((iter + 1.0) / (100.0 + iter))); + // betaMatrix.print(10, 2); + + for (int k = 0; k < system.getNumberOfPhases() - solidsNumber; k++) { + system.setBeta(k, betaMatrix.get(k, 0)); + if (betaMatrix.get(k, 0) < 0) { + system.setBeta(k, 1e-9); } - - if (system.getPhase(0).getNumberOfComponents() <= 2) { - solvebeta1(); + if (betaMatrix.get(k, 0) > 1) { + system.setBeta(k, 1 - 1e-9); } - do { - iter++; - this.solveBeta(); - // checkX(); - } while (iter < 1); + } + calcE(); + setXY(); + calcSolidBeta(); + } while ((ans.norm2() > 1e-8 && iter < 100) || iter < 2); + + system.init(1); + setXY(); + } + + /** + *

+ * checkGibbs. + *

+ */ + public void checkGibbs() { + double gibbs1 = 0, gibbs2 = 0; + for (int i = 0; i < system.getNumberOfPhases() - 1; i++) { + system.setPhaseType(i, 0); + system.init(1); + gibbs1 = system.getPhase(i).getGibbsEnergy(); + system.setPhaseType(i, 1); + system.init(1); + gibbs2 = system.getPhase(i).getGibbsEnergy(); + if (gibbs1 < gibbs2) { + system.setPhaseType(i, 0); + } else { + system.setPhaseType(i, 1); + } + system.init(1); + } + } + + /** + *

+ * calcSolidBeta. + *

+ */ + public void calcSolidBeta() { + double tempVar = system.getPhase(0).getComponents()[solidIndex].getz(); + // double beta = 1.0; + for (int i = 0; i < system.getNumberOfPhases() - 1; i++) { + tempVar -= + system.getBeta(i) * system.getPhase(3).getComponent(solidIndex).getFugacityCoefficient() + / system.getPhase(i).getComponent(solidIndex).getFugacityCoefficient(); + // beta -= system.getBeta(i); + } + if (tempVar > 0 && tempVar < 1.0) { + system.setBeta(system.getNumberOfPhases() - 1, tempVar); + } + } + + /** {@inheritDoc} */ + @Override + public void run() { + int iter = 0; + + ThermodynamicOperations ops = new ThermodynamicOperations(system); + system.setSolidPhaseCheck(false); + ops.TPflash(); + system.setSolidPhaseCheck(true); + if (checkAndAddSolidPhase() == 0) { + return; } - /** - *

- * checkAndAddSolidPhase. - *

- * - * @return a int - */ - public int checkAndAddSolidPhase() { - double[] solidCandidate = new double[system.getPhases()[0].getNumberOfComponents()]; - - for (int k = 0; k < system.getPhase(0).getNumberOfComponents(); k++) { - if (system.getTemperature() > system.getPhase(0).getComponent(k) - .getTriplePointTemperature()) { - solidCandidate[k] = -10; - } else { - solidCandidate[k] = system.getPhase(0).getComponents()[k].getz(); - system.getPhases()[3].getComponent(k).setx(1.0); - - for (int i = 0; i < system.getNumberOfPhases(); i++) { - solidCandidate[k] -= - system.getPhases()[3].getComponent(k).fugcoef(system.getPhases()[3]) - / system.getPhase(i).getComponent(k).getFugacityCoefficient(); - } - } - } - - for (int i = 0; i < solidCandidate.length; i++) { - if (solidCandidate[i] > 0.0) { - system.getPhases()[3].getComponent(i).setx(1.0); - solidIndex = i; - solidsNumber++; - } else { - system.getPhases()[3].getComponent(i).setx(0.0); - } + if (system.getPhase(0).getNumberOfComponents() <= 2) { + solvebeta1(); + } + do { + iter++; + this.solveBeta(); + // checkX(); + } while (iter < 1); + } + + /** + *

+ * checkAndAddSolidPhase. + *

+ * + * @return a int + */ + public int checkAndAddSolidPhase() { + double[] solidCandidate = new double[system.getPhases()[0].getNumberOfComponents()]; + + for (int k = 0; k < system.getPhase(0).getNumberOfComponents(); k++) { + if (system.getTemperature() > system.getPhase(0).getComponent(k) + .getTriplePointTemperature()) { + solidCandidate[k] = -10; + } else { + solidCandidate[k] = system.getPhase(0).getComponents()[k].getz(); + system.getPhases()[3].getComponent(k).setx(1.0); + + for (int i = 0; i < system.getNumberOfPhases(); i++) { + solidCandidate[k] -= system.getPhases()[3].getComponent(k).fugcoef(system.getPhases()[3]) + / system.getPhase(i).getComponent(k).getFugacityCoefficient(); } + } + } - for (int i = 0; i < solidsNumber; i++) { - system.setNumberOfPhases(system.getNumberOfPhases() + 1); - system.setPhaseIndex(system.getNumberOfPhases() - 1, 3); - system.setBeta(system.getNumberOfPhases() - 1, solidCandidate[solidIndex]); - // system.setBeta(system.getNumberOfPhases() - 2, - // system.getBeta(system.getNumberOfPhases() - 2) - solidCandidate[solidIndex]); - } - return solidsNumber; + for (int i = 0; i < solidCandidate.length; i++) { + if (solidCandidate[i] > 0.0) { + system.getPhases()[3].getComponent(i).setx(1.0); + solidIndex = i; + solidsNumber++; + } else { + system.getPhases()[3].getComponent(i).setx(0.0); + } } - /** - *

- * solvebeta1. - *

- * - * @return a double - */ - public double solvebeta1() { - // double numberOfMolesFreeze = - // system.getPhase(0).getComponent(solidIndex).getNumberOfmoles(); - double solidCandidate = 0; - int iter = 0; - double dn = -0.01; - double solidCandidateOld = 0; - do { - solidCandidateOld = solidCandidate; - system.addComponent(system.getPhase(0).getComponent(solidIndex).getComponentName(), dn); - ThermodynamicOperations ops = new ThermodynamicOperations(system); - // system.init(0); - system.setSolidPhaseCheck(false); - ops.TPflash(); - // system.setSolidPhaseCheck(true); - - iter++; - solidCandidate = system.getPhase(0).getComponents()[solidIndex].getz(); - for (int i = 0; i < system.getNumberOfPhases(); i++) { - solidCandidate -= system.getPhases()[3].getComponent(solidIndex) - .fugcoef(system.getPhases()[3]) - / system.getPhase(i).getComponent(solidIndex).getFugacityCoefficient(); - } - double dsoliddn = (solidCandidate - solidCandidateOld) / dn; - dn = -0.5 * solidCandidate / dsoliddn; - logger.info("solid cand " + solidCandidate); - } while (solidCandidate > 1e-5 && iter < 50); - - return 1.0; + for (int i = 0; i < solidsNumber; i++) { + system.setNumberOfPhases(system.getNumberOfPhases() + 1); + system.setPhaseIndex(system.getNumberOfPhases() - 1, 3); + system.setBeta(system.getNumberOfPhases() - 1, solidCandidate[solidIndex]); + // system.setBeta(system.getNumberOfPhases() - 2, + // system.getBeta(system.getNumberOfPhases() - 2) - solidCandidate[solidIndex]); } + return solidsNumber; + } + + /** + *

+ * solvebeta1. + *

+ * + * @return a double + */ + public double solvebeta1() { + // double numberOfMolesFreeze = + // system.getPhase(0).getComponent(solidIndex).getNumberOfmoles(); + double solidCandidate = 0; + int iter = 0; + double dn = -0.01; + double solidCandidateOld = 0; + do { + solidCandidateOld = solidCandidate; + system.addComponent(system.getPhase(0).getComponent(solidIndex).getComponentName(), dn); + ThermodynamicOperations ops = new ThermodynamicOperations(system); + // system.init(0); + system.setSolidPhaseCheck(false); + ops.TPflash(); + // system.setSolidPhaseCheck(true); + + iter++; + solidCandidate = system.getPhase(0).getComponents()[solidIndex].getz(); + for (int i = 0; i < system.getNumberOfPhases(); i++) { + solidCandidate -= + system.getPhases()[3].getComponent(solidIndex).fugcoef(system.getPhases()[3]) + / system.getPhase(i).getComponent(solidIndex).getFugacityCoefficient(); + } + double dsoliddn = (solidCandidate - solidCandidateOld) / dn; + dn = -0.5 * solidCandidate / dsoliddn; + logger.info("solid cand " + solidCandidate); + } while (solidCandidate > 1e-5 && iter < 50); + + return 1.0; + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPflash.java index 016fccd6e6..60987f26b5 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPflash.java @@ -166,7 +166,7 @@ public void setNewK() { *

*/ public void resetK() { - + for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { lnK[i] = lnOldK[i]; system.getPhase(0).getComponents()[i].setK(Math.exp(lnK[i])); @@ -403,7 +403,7 @@ public void run() { gibbsEnergy = system.getGibbsEnergy(); if ((gibbsEnergy - gibbsEnergyOld) / Math.abs(gibbsEnergyOld) > 1e-3 - && !system.isChemicalSystem() && timeFromLastGibbsFail>0) { + && !system.isChemicalSystem() && timeFromLastGibbsFail > 0) { resetK(); timeFromLastGibbsFail = 0; // logger.info("gibbs decrease " + (gibbsEnergy - gibbsEnergyOld) / diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPgradientFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPgradientFlash.java index a30d511f2c..0b8be39025 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPgradientFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPgradientFlash.java @@ -3,6 +3,7 @@ * * Created on 8. mars 2001, 10:56 */ + package neqsim.thermodynamicOperations.flashOps; import Jama.Matrix; @@ -17,155 +18,150 @@ * @version $Id: $Id */ public class TPgradientFlash extends Flash { - private static final long serialVersionUID = 1000; - - SystemInterface localSystem = null, tempSystem = null; - double temperature = 0.0, height = 0.0, deltaHeight = 0.0; - double deltaT = 0.0; - Matrix Jac; - Matrix fvec; - Matrix u; - Matrix dx; - Matrix uold; - - /** - *

- * Constructor for TPgradientFlash. - *

- */ - public TPgradientFlash() {} - - /** - *

- * Constructor for TPgradientFlash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param height a double - * @param temperature a double - */ - public TPgradientFlash(SystemInterface system, double height, double temperature) { - this.system = system; - this.temperature = temperature; - this.height = height; - Jac = new Matrix(system.getPhase(0).getNumberOfComponents(), - system.getPhase(0).getNumberOfComponents()); - fvec = new Matrix(system.getPhase(0).getNumberOfComponents(), 1); - } - - /** - *

- * Setter for the field fvec. - *

- */ - public void setfvec() { - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - fvec.set(i, 0, Math - .log(localSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient() - * localSystem.getPhases()[0].getComponents()[i].getx() - * localSystem.getPressure()) - - Math.log(tempSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient() - * tempSystem.getPhases()[0].getComponents()[i].getx() - * tempSystem.getPressure()) - - tempSystem.getPhases()[0].getComponents()[i].getMolarMass() - * neqsim.thermo.ThermodynamicConstantsInterface.gravity * deltaHeight - / neqsim.thermo.ThermodynamicConstantsInterface.R - / tempSystem.getPhase(0).getTemperature() - + tempSystem.getPhases()[0].getComponents()[i].getMolarMass() - * (tempSystem.getPhases()[0].getEnthalpy() - / tempSystem.getPhases()[0].getNumberOfMolesInPhase() - / tempSystem.getPhase(0).getMolarMass() - - tempSystem.getPhases()[0].getComponents()[i] - .getEnthalpy(tempSystem.getPhase(0).getTemperature()) - / tempSystem.getPhases()[0].getComponent(i) - .getNumberOfMolesInPhase() - / tempSystem.getPhase(0).getComponent(i).getMolarMass()) - * deltaT / tempSystem.getPhase(0).getTemperature() - / neqsim.thermo.ThermodynamicConstantsInterface.R - / tempSystem.getPhase(0).getTemperature()); - } - } - - /** - *

- * setJac. - *

- */ - public void setJac() { - Jac.timesEquals(0.0); - double dij = 0.0; - - double tempJ = 0.0; - - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - for (int j = 0; j < system.getPhase(0).getNumberOfComponents(); j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta - tempJ = 1.0 - / (localSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient() - * localSystem.getPhases()[0].getComponents()[i].getx() - * localSystem.getPressure()) - * (localSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient() - * dij * localSystem.getPressure() - + localSystem.getPhases()[0].getComponents()[i].getdfugdx(j) - * localSystem.getPhases()[0].getComponents()[i].getx() - * localSystem.getPressure()); - Jac.set(i, j, tempJ); - } - } + private static final long serialVersionUID = 1000; + + SystemInterface localSystem = null, tempSystem = null; + double temperature = 0.0, height = 0.0, deltaHeight = 0.0; + double deltaT = 0.0; + Matrix Jac; + Matrix fvec; + Matrix u; + Matrix dx; + Matrix uold; + + /** + *

+ * Constructor for TPgradientFlash. + *

+ */ + public TPgradientFlash() {} + + /** + *

+ * Constructor for TPgradientFlash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param height a double + * @param temperature a double + */ + public TPgradientFlash(SystemInterface system, double height, double temperature) { + this.system = system; + this.temperature = temperature; + this.height = height; + Jac = new Matrix(system.getPhase(0).getNumberOfComponents(), + system.getPhase(0).getNumberOfComponents()); + fvec = new Matrix(system.getPhase(0).getNumberOfComponents(), 1); + } + + /** + *

+ * Setter for the field fvec. + *

+ */ + public void setfvec() { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + fvec.set(i, 0, Math + .log(localSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient() + * localSystem.getPhases()[0].getComponents()[i].getx() * localSystem.getPressure()) + - Math.log(tempSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient() + * tempSystem.getPhases()[0].getComponents()[i].getx() * tempSystem.getPressure()) + - tempSystem.getPhases()[0].getComponents()[i].getMolarMass() + * neqsim.thermo.ThermodynamicConstantsInterface.gravity * deltaHeight + / neqsim.thermo.ThermodynamicConstantsInterface.R + / tempSystem.getPhase(0).getTemperature() + + tempSystem.getPhases()[0].getComponents()[i].getMolarMass() * (tempSystem + .getPhases()[0].getEnthalpy() + / tempSystem.getPhases()[0].getNumberOfMolesInPhase() + / tempSystem.getPhase(0).getMolarMass() + - tempSystem.getPhases()[0].getComponents()[i] + .getEnthalpy(tempSystem.getPhase(0).getTemperature()) + / tempSystem.getPhases()[0].getComponent(i).getNumberOfMolesInPhase() + / tempSystem.getPhase(0).getComponent(i).getMolarMass()) + * deltaT / tempSystem.getPhase(0).getTemperature() + / neqsim.thermo.ThermodynamicConstantsInterface.R + / tempSystem.getPhase(0).getTemperature()); } - - /** - *

- * setNewX. - *

- */ - public void setNewX() { - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - localSystem.getPhase(0).getComponent(i) - .setx(localSystem.getPhase(0).getComponent(i).getx() - 0.5 * dx.get(i, 0)); - } - localSystem.getPhase(0).normalize(); + } + + /** + *

+ * setJac. + *

+ */ + public void setJac() { + Jac.timesEquals(0.0); + double dij = 0.0; + + double tempJ = 0.0; + + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + for (int j = 0; j < system.getPhase(0).getNumberOfComponents(); j++) { + dij = i == j ? 1.0 : 0.0;// Kroneckers delta + tempJ = 1.0 / (localSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient() + * localSystem.getPhases()[0].getComponents()[i].getx() * localSystem.getPressure()) + * (localSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient() * dij + * localSystem.getPressure() + + localSystem.getPhases()[0].getComponents()[i].getdfugdx(j) + * localSystem.getPhases()[0].getComponents()[i].getx() + * localSystem.getPressure()); + Jac.set(i, j, tempJ); + } } - - /** {@inheritDoc} */ - @Override - public void run() { - tempSystem = system.clone(); - tempSystem.init(0); - tempSystem.init(3); - - localSystem = system.clone(); - // localSystem.setPressure(height*9.81*height); - - deltaT = (temperature - system.getTemperature()) / 20.0; - deltaHeight = height / 20.0; - - for (int i = 0; i < 20; i++) { - localSystem.setTemperature(localSystem.getTemperature() + deltaT); - for (int o = 0; o < 15; o++) { - localSystem.init(3); - setfvec(); - setJac(); - dx = Jac.solve(fvec); - dx.print(10, 10); - setNewX(); - } - // localSystem.display(); - - tempSystem = localSystem.clone(); - tempSystem.init(3); - } + } + + /** + *

+ * setNewX. + *

+ */ + public void setNewX() { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + localSystem.getPhase(0).getComponent(i) + .setx(localSystem.getPhase(0).getComponent(i).getx() - 0.5 * dx.get(i, 0)); } - - /** {@inheritDoc} */ - @Override - public SystemInterface getThermoSystem() { - return localSystem; - } - - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - return null; + localSystem.getPhase(0).normalize(); + } + + /** {@inheritDoc} */ + @Override + public void run() { + tempSystem = system.clone(); + tempSystem.init(0); + tempSystem.init(3); + + localSystem = system.clone(); + // localSystem.setPressure(height*9.81*height); + + deltaT = (temperature - system.getTemperature()) / 20.0; + deltaHeight = height / 20.0; + + for (int i = 0; i < 20; i++) { + localSystem.setTemperature(localSystem.getTemperature() + deltaT); + for (int o = 0; o < 15; o++) { + localSystem.init(3); + setfvec(); + setJac(); + dx = Jac.solve(fvec); + dx.print(10, 10); + setNewX(); + } + // localSystem.display(); + + tempSystem = localSystem.clone(); + tempSystem.init(3); } + } + + /** {@inheritDoc} */ + @Override + public SystemInterface getThermoSystem() { + return localSystem; + } + + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + return null; + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash.java index aa1444a405..4121824f4b 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash.java @@ -1,10 +1,9 @@ - - /* * TPmultiflash.java * * Created on 2. oktober 2000, 22:26 */ + package neqsim.thermodynamicOperations.flashOps; import static neqsim.thermo.ThermodynamicModelSettings.phaseFractionMinimumLimit; diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash_1.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash_1.java index bbee1336a9..fbd0ca23f4 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash_1.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash_1.java @@ -3,6 +3,7 @@ * * Created on 2. oktober 2000, 22:26 */ + package neqsim.thermodynamicOperations.flashOps; import java.util.ArrayList; diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/TSFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/TSFlash.java index f106977a5e..81ee133d9a 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/TSFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/TSFlash.java @@ -3,6 +3,7 @@ * * Created on 8. mars 2001, 10:56 */ + package neqsim.thermodynamicOperations.flashOps; import neqsim.thermo.system.SystemInterface; diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/TVflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/TVflash.java index 556d816f73..4e972ce4cf 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/TVflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/TVflash.java @@ -3,6 +3,7 @@ * * Created on 8. mars 2001, 10:56 */ + package neqsim.thermodynamicOperations.flashOps; import neqsim.thermo.system.SystemInterface; @@ -16,100 +17,100 @@ * @version $Id: $Id */ public class TVflash extends Flash { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - double Vspec = 0; - Flash tpFlash; + double Vspec = 0; + Flash tpFlash; - /** - *

- * Constructor for TVflash. - *

- */ - public TVflash() {} + /** + *

+ * Constructor for TVflash. + *

+ */ + public TVflash() {} - /** - *

- * Constructor for TVflash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param Vspec a double - */ - public TVflash(SystemInterface system, double Vspec) { - this.system = system; - this.tpFlash = new TPflash(system); - this.Vspec = Vspec; - } + /** + *

+ * Constructor for TVflash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param Vspec a double + */ + public TVflash(SystemInterface system, double Vspec) { + this.system = system; + this.tpFlash = new TPflash(system); + this.Vspec = Vspec; + } - /** - *

- * calcdQdVV. - *

- * - * @return a double - */ - public double calcdQdVV() { - double dQdVV = 0.0; - for (int i = 0; i < system.getNumberOfPhases(); i++) { - dQdVV += 1.0 / (system.getPhase(i).getVolume() / system.getVolume()) * 1.0 - / system.getPhase(i).getdPdVTn();// *system.getPhase(i).getdVdP();system.getPhase(i).getVolume()/system.getVolume()* - } - return dQdVV; + /** + *

+ * calcdQdVV. + *

+ * + * @return a double + */ + public double calcdQdVV() { + double dQdVV = 0.0; + for (int i = 0; i < system.getNumberOfPhases(); i++) { + dQdVV += 1.0 / (system.getPhase(i).getVolume() / system.getVolume()) * 1.0 + / system.getPhase(i).getdPdVTn();// *system.getPhase(i).getdVdP();system.getPhase(i).getVolume()/system.getVolume()* } + return dQdVV; + } - /** - *

- * calcdQdV. - *

- * - * @return a double - */ - public double calcdQdV() { - double dQ = system.getVolume() - Vspec; - return dQ; - } + /** + *

+ * calcdQdV. + *

+ * + * @return a double + */ + public double calcdQdV() { + double dQ = system.getVolume() - Vspec; + return dQ; + } - /** - *

- * solveQ. - *

- * - * @return a double - */ - public double solveQ() { - double oldPres = system.getPressure(), nyPres = system.getPressure(); - double iterations = 1; - do { - iterations++; - oldPres = nyPres; - system.init(3); - nyPres = oldPres - (iterations) / (iterations + 10.0) * calcdQdV() / calcdQdVV(); - if (nyPres <= 0.0 || Math.abs(oldPres - nyPres) > 10.0) { - nyPres = Math.abs(oldPres - 1.0); - } - system.setPressure(nyPres); - tpFlash.run(); - // System.out.println(" dQdv " + calcdQdV() + " new pressure " + nyPres + " error " + Math.abs((nyPres-oldPres)/(nyPres)) + " numberofphases "+system.getNumberOfPhases()); - } while (Math.abs((nyPres - oldPres) / (nyPres)) > 1e-9 && iterations < 1000 - || iterations < 3); - return nyPres; - } + /** + *

+ * solveQ. + *

+ * + * @return a double + */ + public double solveQ() { + double oldPres = system.getPressure(), nyPres = system.getPressure(); + double iterations = 1; + do { + iterations++; + oldPres = nyPres; + system.init(3); + nyPres = oldPres - (iterations) / (iterations + 10.0) * calcdQdV() / calcdQdVV(); + if (nyPres <= 0.0 || Math.abs(oldPres - nyPres) > 10.0) { + nyPres = Math.abs(oldPres - 1.0); + } + system.setPressure(nyPres); + tpFlash.run(); + // System.out.println(" dQdv " + calcdQdV() + " new pressure " + nyPres + " error " + + // Math.abs((nyPres-oldPres)/(nyPres)) + " numberofphases "+system.getNumberOfPhases()); + } while (Math.abs((nyPres - oldPres) / (nyPres)) > 1e-9 && iterations < 1000 || iterations < 3); + return nyPres; + } - /** {@inheritDoc} */ - @Override - public void run() { - tpFlash.run(); - // System.out.println("enthalpy: " + system.getEnthalpy()); - solveQ(); + /** {@inheritDoc} */ + @Override + public void run() { + tpFlash.run(); + // System.out.println("enthalpy: " + system.getEnthalpy()); + solveQ(); - // System.out.println("volume: " + system.getVolume()); - // System.out.println("Temperature: " + system.getTemperature()); - } + // System.out.println("volume: " + system.getVolume()); + // 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/VUflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/VUflash.java index 02839abab9..1b1668895f 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/VUflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/VUflash.java @@ -3,6 +3,7 @@ * * Created on 8. mars 2001, 10:56 */ + package neqsim.thermodynamicOperations.flashOps; import neqsim.thermo.system.SystemInterface; @@ -16,89 +17,89 @@ * @version $Id: $Id */ public class VUflash extends Flash { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - double Uspec = 0; - double Vspec = 0; - Flash pHFlash; + double Uspec = 0; + double Vspec = 0; + Flash pHFlash; - /** - *

- * Constructor for VUflash. - *

- */ - public VUflash() {} + /** + *

+ * Constructor for VUflash. + *

+ */ + public VUflash() {} - /** - *

- * Constructor for VUflash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param Vspec a double - * @param Uspec a double - */ - public VUflash(SystemInterface system, double Vspec, double Uspec) { - this.system = system; - this.pHFlash = new PHflash(system, Uspec, 0); - this.Uspec = Uspec; - this.Vspec = Vspec; - // System.out.println("enthalpy " + Hspec); - // System.out.println("volume " + Vspec); - } + /** + *

+ * Constructor for VUflash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param Vspec a double + * @param Uspec a double + */ + public VUflash(SystemInterface system, double Vspec, double Uspec) { + this.system = system; + this.pHFlash = new PHflash(system, Uspec, 0); + this.Uspec = Uspec; + this.Vspec = Vspec; + // System.out.println("enthalpy " + Hspec); + // System.out.println("volume " + Vspec); + } - /** {@inheritDoc} */ - @Override - public void run() { - // double oldVol = system.getVolume(); - double newVol = system.getVolume(); - // double pNew = system.getPressure(); - // double pOld = system.getPressure(); - // double pOldOld = 0.0; - double err = 0.0; - int iterations = 0; - // System.out.println("enthalpy start " + system.getEnthalpy()); - // double dPdV = 0.0; - double wallHeat = 0.0; - for (int i = 0; i < 21; i++) { - wallHeat = 0 * i / 20.0 * 400.0 * 1295.0 * 1000.0 * (293.15 - system.getTemperature()); - // System.out.println("Hwall " + wallHeat + " i " + i); - iterations = 1; - do { - iterations++; + /** {@inheritDoc} */ + @Override + public void run() { + // double oldVol = system.getVolume(); + double newVol = system.getVolume(); + // double pNew = system.getPressure(); + // double pOld = system.getPressure(); + // double pOldOld = 0.0; + double err = 0.0; + int iterations = 0; + // System.out.println("enthalpy start " + system.getEnthalpy()); + // double dPdV = 0.0; + double wallHeat = 0.0; + for (int i = 0; i < 21; i++) { + wallHeat = 0 * i / 20.0 * 400.0 * 1295.0 * 1000.0 * (293.15 - system.getTemperature()); + // System.out.println("Hwall " + wallHeat + " i " + i); + iterations = 1; + do { + iterations++; - this.pHFlash = new PHflash(system, - Uspec + wallHeat + system.getPressure() * system.getVolume(), 0); - // System.out.println("Hspec " + Hspec); - this.pHFlash.run(); - // pOldOld = pOld; - // pOld = system.getPressure(); - // oldVol = newVol; - newVol = system.getVolume(); + this.pHFlash = + new PHflash(system, Uspec + wallHeat + system.getPressure() * system.getVolume(), 0); + // System.out.println("Hspec " + Hspec); + this.pHFlash.run(); + // pOldOld = pOld; + // pOld = system.getPressure(); + // oldVol = newVol; + newVol = system.getVolume(); - err = (newVol - Vspec) / Vspec; + err = (newVol - Vspec) / Vspec; - // System.out.println("err................................................................................ - // " + err); - if (iterations < -5) { - system.setPressure(system.getPressure() + err / 10.0); - } else { - // System.out.println("pres " + (system.getPressure()+0.1*dPdV*(newVol-Vspec))); - system.setPressure(system.getPressure() - - 0.6 * 1.0 / system.getdVdPtn() * (newVol - Vspec));// system.getdVdPtn()*(newVol-Vspec));//dPdV*(newVol-Vspec)); - } - // pNew = system.getPressure(); - // dPdV = (pOld - pOldOld) / (newVol - oldVol); - // System.out.println("pressure " + system.getPressure()); - } while ((Math.abs(err) > 1e-10 && iterations < 1000) || iterations < 7); + // System.out.println("err................................................................................ + // " + err); + if (iterations < -5) { + system.setPressure(system.getPressure() + err / 10.0); + } else { + // System.out.println("pres " + (system.getPressure()+0.1*dPdV*(newVol-Vspec))); + system.setPressure( + system.getPressure() - 0.6 * 1.0 / system.getdVdPtn() * (newVol - Vspec));// system.getdVdPtn()*(newVol-Vspec));//dPdV*(newVol-Vspec)); } - // System.out.println("enthalpy end " + system.getEnthalpy()); - // System.out.println("iterations " + iterations); + // pNew = system.getPressure(); + // dPdV = (pOld - pOldOld) / (newVol - oldVol); + // System.out.println("pressure " + system.getPressure()); + } while ((Math.abs(err) > 1e-10 && iterations < 1000) || iterations < 7); } + // System.out.println("enthalpy end " + system.getEnthalpy()); + // System.out.println("iterations " + iterations); + } - /** {@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/VUflashQfunc.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/VUflashQfunc.java index 0f4539329c..60f77d60db 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/VUflashQfunc.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/VUflashQfunc.java @@ -3,6 +3,7 @@ * * Created on 8. mars 2001, 10:56 */ + package neqsim.thermodynamicOperations.flashOps; import org.apache.logging.log4j.LogManager; @@ -20,167 +21,166 @@ * @version $Id: $Id */ public class VUflashQfunc extends Flash { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(VUflashQfunc.class); - - double Vspec = 0, Uspec = 0.0; - Flash tpFlash; - - /** - *

- * Constructor for VUflashQfunc. - *

- */ - public VUflashQfunc() {} - - /** - *

- * Constructor for VUflashQfunc. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param Vspec a double - * @param Uspec a double - */ - public VUflashQfunc(SystemInterface system, double Vspec, double Uspec) { - this.system = system; - this.tpFlash = new TPflash(system); - this.Vspec = Vspec; - this.Uspec = Uspec; - } - - /** - *

- * calcdQdPP. - *

- * - * @return a double - */ - public double calcdQdPP() { - double dQdVV = (system.getVolume() - Vspec) - / (neqsim.thermo.ThermodynamicConstantsInterface.R * system.getTemperature()) - + system.getPressure() * (system.getdVdPtn()) - / (neqsim.thermo.ThermodynamicConstantsInterface.R - * system.getTemperature()); - return dQdVV; - } - - /** - *

- * calcdQdTT. - *

- * - * @return a double - */ - public double calcdQdTT() { - double dQdTT = -system.getCp() - / (system.getTemperature() * neqsim.thermo.ThermodynamicConstantsInterface.R) - - calcdQdT() / system.getTemperature(); - return dQdTT; - } - - /** - *

- * calcdQdT. - *

- * - * @return a double - */ - public double calcdQdT() { - double dQdT = (Uspec + system.getPressure() * Vspec - system.getEnthalpy()) - / (system.getTemperature() * neqsim.thermo.ThermodynamicConstantsInterface.R); - return dQdT; - } - - /** - *

- * calcdQdP. - *

- * - * @return a double - */ - public double calcdQdP() { - double dQdP = system.getPressure() * (system.getVolume() - Vspec) - / (neqsim.thermo.ThermodynamicConstantsInterface.R * system.getTemperature()); - return dQdP; - } - - /** - *

- * solveQ. - *

- * - * @return a double - */ - public double solveQ() { - double oldPres = system.getPressure(), nyPres = system.getPressure(), - nyTemp = system.getTemperature(), oldTemp = system.getTemperature(); - double iterations = 1; - // logger.info("Vspec: " + Vspec); - // logger.info("Uspec: " + Uspec); - do { - iterations++; - oldPres = nyPres; - oldTemp = nyTemp; - system.init(3); - // logger.info("dQdP: " + calcdQdP()); - // logger.info("dQdT: " + calcdQdT()); - nyPres = oldPres - (iterations) / (iterations + 10.0) * calcdQdP() / calcdQdPP(); - nyTemp = oldTemp - (iterations) / (iterations + 10.0) * calcdQdT() / calcdQdTT(); - // logger.info("volume: " + system.getVolume()); - // logger.info("inernaleng: " + system.getInternalEnergy()); - system.setPressure(nyPres); - system.setTemperature(nyTemp); - tpFlash.run(); - // logger.info("error1: " + Math.abs((nyPres - oldPres) / (nyPres))); - // logger.info("error2: " + Math.abs((nyTemp - oldTemp) / (nyTemp))); - // logger.info("inernaleng: " + system.getInternalEnergy()); - } while (Math.abs((nyPres - oldPres) / (nyPres)) - + Math.abs((nyTemp - oldTemp) / (nyTemp)) > 1e-9 && iterations < 1000); - return nyPres; - } - - /** {@inheritDoc} */ - @Override - public void run() { - tpFlash.run(); - // logger.info("internaleng: " + system.getInternalEnergy()); - // logger.info("volume: " + system.getVolume()); - solveQ(); - } - - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - return null; - } - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - SystemInterface testSystem = new SystemSrkEos(273.15 + 55, 50.0); - - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - testSystem.addComponent("methane", 31.0); - testSystem.addComponent("ethane", 4.0); - testSystem.addComponent("n-heptane", 0.2); - testSystem.init(0); - try { - testOps.TPflash(); - testSystem.display(); - - double energy = testSystem.getInternalEnergy() * 1.1; - double volume = testSystem.getVolume() * 1.2; - - testOps.VUflash(volume, energy); - testSystem.display(); - } catch (Exception e) { - logger.error(e.toString()); - } + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(VUflashQfunc.class); + + double Vspec = 0, Uspec = 0.0; + Flash tpFlash; + + /** + *

+ * Constructor for VUflashQfunc. + *

+ */ + public VUflashQfunc() {} + + /** + *

+ * Constructor for VUflashQfunc. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param Vspec a double + * @param Uspec a double + */ + public VUflashQfunc(SystemInterface system, double Vspec, double Uspec) { + this.system = system; + this.tpFlash = new TPflash(system); + this.Vspec = Vspec; + this.Uspec = Uspec; + } + + /** + *

+ * calcdQdPP. + *

+ * + * @return a double + */ + public double calcdQdPP() { + double dQdVV = (system.getVolume() - Vspec) + / (neqsim.thermo.ThermodynamicConstantsInterface.R * system.getTemperature()) + + system.getPressure() * (system.getdVdPtn()) + / (neqsim.thermo.ThermodynamicConstantsInterface.R * system.getTemperature()); + return dQdVV; + } + + /** + *

+ * calcdQdTT. + *

+ * + * @return a double + */ + public double calcdQdTT() { + double dQdTT = -system.getCp() + / (system.getTemperature() * neqsim.thermo.ThermodynamicConstantsInterface.R) + - calcdQdT() / system.getTemperature(); + return dQdTT; + } + + /** + *

+ * calcdQdT. + *

+ * + * @return a double + */ + public double calcdQdT() { + double dQdT = (Uspec + system.getPressure() * Vspec - system.getEnthalpy()) + / (system.getTemperature() * neqsim.thermo.ThermodynamicConstantsInterface.R); + return dQdT; + } + + /** + *

+ * calcdQdP. + *

+ * + * @return a double + */ + public double calcdQdP() { + double dQdP = system.getPressure() * (system.getVolume() - Vspec) + / (neqsim.thermo.ThermodynamicConstantsInterface.R * system.getTemperature()); + return dQdP; + } + + /** + *

+ * solveQ. + *

+ * + * @return a double + */ + public double solveQ() { + double oldPres = system.getPressure(), nyPres = system.getPressure(), + nyTemp = system.getTemperature(), oldTemp = system.getTemperature(); + double iterations = 1; + // logger.info("Vspec: " + Vspec); + // logger.info("Uspec: " + Uspec); + do { + iterations++; + oldPres = nyPres; + oldTemp = nyTemp; + system.init(3); + // logger.info("dQdP: " + calcdQdP()); + // logger.info("dQdT: " + calcdQdT()); + nyPres = oldPres - (iterations) / (iterations + 10.0) * calcdQdP() / calcdQdPP(); + nyTemp = oldTemp - (iterations) / (iterations + 10.0) * calcdQdT() / calcdQdTT(); + // logger.info("volume: " + system.getVolume()); + // logger.info("inernaleng: " + system.getInternalEnergy()); + system.setPressure(nyPres); + system.setTemperature(nyTemp); + tpFlash.run(); + // logger.info("error1: " + Math.abs((nyPres - oldPres) / (nyPres))); + // logger.info("error2: " + Math.abs((nyTemp - oldTemp) / (nyTemp))); + // logger.info("inernaleng: " + system.getInternalEnergy()); + } while (Math.abs((nyPres - oldPres) / (nyPres)) + + Math.abs((nyTemp - oldTemp) / (nyTemp)) > 1e-9 && iterations < 1000); + return nyPres; + } + + /** {@inheritDoc} */ + @Override + public void run() { + tpFlash.run(); + // logger.info("internaleng: " + system.getInternalEnergy()); + // logger.info("volume: " + system.getVolume()); + solveQ(); + } + + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + return null; + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + SystemInterface testSystem = new SystemSrkEos(273.15 + 55, 50.0); + + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testSystem.addComponent("methane", 31.0); + testSystem.addComponent("ethane", 4.0); + testSystem.addComponent("n-heptane", 0.2); + testSystem.init(0); + try { + testOps.TPflash(); + testSystem.display(); + + double energy = testSystem.getInternalEnergy() * 1.1; + double volume = testSystem.getVolume() * 1.2; + + testOps.VUflash(volume, energy); + testSystem.display(); + } catch (Exception e) { + logger.error(e.toString()); } + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/calcIonicComposition.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/calcIonicComposition.java index 46d0b5994b..cf1ac0ad07 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/calcIonicComposition.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/calcIonicComposition.java @@ -3,6 +3,7 @@ * * Created on 8. mars 2001, 10:56 */ + package neqsim.thermodynamicOperations.flashOps; import java.text.DecimalFormat; @@ -18,82 +19,83 @@ * @version $Id: $Id */ public class calcIonicComposition extends Flash { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - int phaseNumber; - String[][] resultTable = null; + int phaseNumber; + String[][] resultTable = null; - /** - *

- * Constructor for calcIonicComposition. - *

- */ - public calcIonicComposition() {} + /** + *

+ * Constructor for calcIonicComposition. + *

+ */ + public calcIonicComposition() {} - /** - *

- * Constructor for calcIonicComposition. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param phase a int - */ - public calcIonicComposition(SystemInterface system, int phase) { - this.system = system; - phaseNumber = phase; - } + /** + *

+ * Constructor for calcIonicComposition. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param phase a int + */ + public calcIonicComposition(SystemInterface system, int phase) { + this.system = system; + phaseNumber = phase; + } - /** {@inheritDoc} */ - @Override - public void run() { - resultTable = new String[system.getPhase(0).getNumberOfComponents() + 2][4]; - resultTable[0][0] = "Component"; - resultTable[0][1] = "mmol/kgSolvent"; - resultTable[0][2] = "mg/kgSolvent"; - resultTable[0][3] = "Act.Coef"; - DecimalFormatSymbols symbols = new DecimalFormatSymbols(); - DecimalFormat nf = new DecimalFormat(); - symbols.setDecimalSeparator('.'); - nf.setDecimalFormatSymbols(symbols); - nf.setMaximumFractionDigits(5); - nf.applyPattern("#.#####E0"); - int ionNumber = 0; - for (int i = 0; i < system.getPhase(phaseNumber).getNumberOfComponents(); i++) { - // if (system.getPhase(phaseNumber).getComponent(i).isIsIon()) { - resultTable[ionNumber + 1][0] = - system.getPhase(phaseNumber).getComponent(i).getComponentName(); - resultTable[ionNumber + 1][1] = Double.valueOf(nf.format(system.getPhase(phaseNumber) - .getComponent(i).getNumberOfMolesInPhase() - / (system.getPhase(phaseNumber).getComponent("water").getNumberOfMolesInPhase() - * system.getPhase(phaseNumber).getComponent("water").getMolarMass()) - * 1000)).toString(); - resultTable[ionNumber + 1][2] = Double.valueOf(nf.format(system.getPhase(phaseNumber) - .getComponent(i).getNumberOfMolesInPhase() - * system.getPhase(phaseNumber).getComponent(i).getMolarMass() - / (system.getPhase(phaseNumber).getComponent("water").getNumberOfMolesInPhase() - * system.getPhase(phaseNumber).getComponent("water").getMolarMass()) - * 1e6)).toString(); - resultTable[ionNumber + 1][3] = Double - .valueOf( - nf.format(system.getPhase(phaseNumber) - .getActivityCoefficient(i, system.getPhase(phaseNumber) - .getComponent("water").getComponentNumber()))) - .toString(); + /** {@inheritDoc} */ + @Override + public void run() { + resultTable = new String[system.getPhase(0).getNumberOfComponents() + 2][4]; + resultTable[0][0] = "Component"; + resultTable[0][1] = "mmol/kgSolvent"; + resultTable[0][2] = "mg/kgSolvent"; + resultTable[0][3] = "Act.Coef"; + DecimalFormatSymbols symbols = new DecimalFormatSymbols(); + DecimalFormat nf = new DecimalFormat(); + symbols.setDecimalSeparator('.'); + nf.setDecimalFormatSymbols(symbols); + nf.setMaximumFractionDigits(5); + nf.applyPattern("#.#####E0"); + int ionNumber = 0; + for (int i = 0; i < system.getPhase(phaseNumber).getNumberOfComponents(); i++) { + // if (system.getPhase(phaseNumber).getComponent(i).isIsIon()) { + resultTable[ionNumber + 1][0] = + system.getPhase(phaseNumber).getComponent(i).getComponentName(); + resultTable[ionNumber + 1][1] = Double + .valueOf(nf.format(system.getPhase(phaseNumber).getComponent(i).getNumberOfMolesInPhase() + / (system.getPhase(phaseNumber).getComponent("water").getNumberOfMolesInPhase() + * system.getPhase(phaseNumber).getComponent("water").getMolarMass()) + * 1000)) + .toString(); + resultTable[ionNumber + 1][2] = Double + .valueOf(nf.format(system.getPhase(phaseNumber).getComponent(i).getNumberOfMolesInPhase() + * system.getPhase(phaseNumber).getComponent(i).getMolarMass() + / (system.getPhase(phaseNumber).getComponent("water").getNumberOfMolesInPhase() + * system.getPhase(phaseNumber).getComponent("water").getMolarMass()) + * 1e6)) + .toString(); + resultTable[ionNumber + 1][3] = + Double + .valueOf(nf.format(system.getPhase(phaseNumber).getActivityCoefficient(i, + system.getPhase(phaseNumber).getComponent("water").getComponentNumber()))) + .toString(); - ionNumber++; - // } - } + ionNumber++; + // } } + } - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - return null; - } + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + return null; + } - /** {@inheritDoc} */ - @Override - public String[][] getResultTable() { - return resultTable; - } + /** {@inheritDoc} */ + @Override + public String[][] getResultTable() { + return resultTable; + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/dTPflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/dTPflash.java index eabd37aa77..cf7f163a5b 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/dTPflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/dTPflash.java @@ -3,6 +3,7 @@ * * Created on 2. oktober 2000, 22:26 */ + package neqsim.thermodynamicOperations.flashOps; import org.apache.logging.log4j.LogManager; @@ -18,83 +19,79 @@ * @version $Id: $Id */ public class dTPflash extends TPflash { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(dTPflash.class); - String[] flashComp = null; + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(dTPflash.class); + String[] flashComp = null; - /** - *

- * Constructor for dTPflash. - *

- */ - public dTPflash() {} + /** + *

+ * Constructor for dTPflash. + *

+ */ + public dTPflash() {} - /** - *

- * Constructor for dTPflash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param comps an array of {@link java.lang.String} objects - */ - public dTPflash(SystemInterface system, String[] comps) { - this.system = system; - this.flashComp = comps; - } + /** + *

+ * Constructor for dTPflash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param comps an array of {@link java.lang.String} objects + */ + public dTPflash(SystemInterface system, String[] comps) { + this.system = system; + this.flashComp = comps; + } - /** {@inheritDoc} */ - @Override - public void run() { - iterations = 0; - double diff = 0.0; - // double fracdiff = 0.0; + /** {@inheritDoc} */ + @Override + public void run() { + iterations = 0; + double diff = 0.0; + // double fracdiff = 0.0; - // system.setBeta(0.5); - do { - diff = 0.0; - // fracdiff = 0.0; - iterations++; - system.init(1); - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - // boolean hasgot = false; - for (int j = 0; j < flashComp.length; j++) { - if (flashComp[j].equals(system.getPhase(0).getComponent(i).getName())) { - diff += Math.abs((system.getPhase(1).getComponent(i).getx() - * system.getPhase(1).getComponent(i).getFugacityCoefficient() - * system.getPhase(1).getPressure()) - - (system.getPhase(0).getComponent(i).getx() - * system.getPhase(0).getComponent(i) - .getFugacityCoefficient() - * system.getPhase(0).getPressure())); - system.getPhase(1).getComponent(i) - .setx(system.getPhase(1).getComponent(i).getx() - * (system.getPhase(0).getComponent(i).getx() - * system.getPhase(0).getComponent(i) - .getFugacityCoefficient() - * system.getPhase(0).getPressure()) - / (system.getPhase(1).getComponent(i).getx() - * system.getPhase(1).getComponent(i) - .getFugacityCoefficient() - * system.getPhase(1).getPressure())); + // system.setBeta(0.5); + do { + diff = 0.0; + // fracdiff = 0.0; + iterations++; + system.init(1); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + // boolean hasgot = false; + for (int j = 0; j < flashComp.length; j++) { + if (flashComp[j].equals(system.getPhase(0).getComponent(i).getName())) { + diff += Math.abs((system.getPhase(1).getComponent(i).getx() + * system.getPhase(1).getComponent(i).getFugacityCoefficient() + * system.getPhase(1).getPressure()) + - (system.getPhase(0).getComponent(i).getx() + * system.getPhase(0).getComponent(i).getFugacityCoefficient() + * system.getPhase(0).getPressure())); + system.getPhase(1).getComponent(i).setx(system.getPhase(1).getComponent(i).getx() + * (system.getPhase(0).getComponent(i).getx() + * system.getPhase(0).getComponent(i).getFugacityCoefficient() + * system.getPhase(0).getPressure()) + / (system.getPhase(1).getComponent(i).getx() + * system.getPhase(1).getComponent(i).getFugacityCoefficient() + * system.getPhase(1).getPressure())); - // fracdiff += system.getPhase(1).getComponent(i).getz() - - // system.getPhase(1).getComponent(i).getx(); + // fracdiff += system.getPhase(1).getComponent(i).getz() - + // system.getPhase(1).getComponent(i).getx(); - // hasgot = true; - // logger.info("x " + system.getPhase(1).getComponent(i).getx()); - } - } - // if(!hasgot) system.getPhase(1).getComponent(i).setx(1e-16); - } + // hasgot = true; + // logger.info("x " + system.getPhase(1).getComponent(i).getx()); + } + } + // if(!hasgot) system.getPhase(1).getComponent(i).setx(1e-16); + } - // system.setBeta(0.5+fracdiff); + // system.setBeta(0.5+fracdiff); - system.getPhase(1).normalize(); - logger.info("diff " + diff); - } while (diff > 1e-10 && iterations < 1000); + system.getPhase(1).normalize(); + logger.info("diff " + diff); + } while (diff > 1e-10 && iterations < 1000); - if (diff > 1e-10) { - logger.error("not able to converge dPflash....continuing...."); - } + if (diff > 1e-10) { + logger.error("not able to converge dPflash....continuing...."); } + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/HPTphaseEnvelope.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/HPTphaseEnvelope.java index bc8cf04432..1b81ee0bba 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/HPTphaseEnvelope.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/HPTphaseEnvelope.java @@ -3,6 +3,7 @@ * * Created on 14. oktober 2000, 21:59 */ + package neqsim.thermodynamicOperations.phaseEnvelopeOps.multicomponentEnvelopeOps; import java.awt.FlowLayout; diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope.java index f65e1ba130..97b6a8d83f 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope.java @@ -3,6 +3,7 @@ * * Created on 14. oktober 2000, 21:59 Updated on May 2019, by Nefeli */ + package neqsim.thermodynamicOperations.phaseEnvelopeOps.multicomponentEnvelopeOps; import java.text.DecimalFormat; diff --git a/src/main/java/neqsim/util/exception/ThermoException.java b/src/main/java/neqsim/util/exception/ThermoException.java index 5c86bdf164..8e47b01019 100644 --- a/src/main/java/neqsim/util/exception/ThermoException.java +++ b/src/main/java/neqsim/util/exception/ThermoException.java @@ -3,6 +3,7 @@ * * Created on 1. mai 2001, 12:47 */ + package neqsim.util.exception; /** @@ -14,25 +15,25 @@ * @version $Id: $Id */ public class ThermoException extends java.lang.Exception { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - * Constructs an ThermoException with the specified detail message. - * - * @param msg the detail message. - */ - public ThermoException(String msg) { - super(msg); - } + /** + * Constructs an ThermoException with the specified detail message. + * + * @param msg the detail message. + */ + public ThermoException(String msg) { + super(msg); + } - /** - * Constructs an ThermoException with the specified detail message. - * - * @param className Class that exception is raised from - * @param methodName Method that exception is raised from - * @param msg specific error message - */ - public ThermoException(String className, String methodName, String msg) { - super(className + ":" + methodName + " - " + msg); - } + /** + * Constructs an ThermoException with the specified detail message. + * + * @param className Class that exception is raised from + * @param methodName Method that exception is raised from + * @param msg specific error message + */ + public ThermoException(String className, String methodName, String msg) { + super(className + ":" + methodName + " - " + msg); + } } diff --git a/src/main/java/neqsim/util/serialization/SerializationManager.java b/src/main/java/neqsim/util/serialization/SerializationManager.java index 2e1320a2d4..f73588ecd9 100644 --- a/src/main/java/neqsim/util/serialization/SerializationManager.java +++ b/src/main/java/neqsim/util/serialization/SerializationManager.java @@ -3,6 +3,7 @@ * * Created on 27. desember 2002, 00:10 */ + package neqsim.util.serialization; import java.io.FileInputStream; @@ -19,38 +20,38 @@ * @version $Id: $Id */ public class SerializationManager { - public SerializationManager() {} + public SerializationManager() {} - /** - *

- * save. - *

- * - * @param obj a {@link java.lang.Object} object - * @param name a {@link java.lang.String} object - */ - public static void save(Object obj, String name) { - try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(name))) { - out.writeObject(obj); - } catch (Exception e) { - System.out.println(e.toString()); - } + /** + *

+ * save. + *

+ * + * @param obj a {@link java.lang.Object} object + * @param name a {@link java.lang.String} object + */ + public static void save(Object obj, String name) { + try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(name))) { + out.writeObject(obj); + } catch (Exception e) { + System.out.println(e.toString()); } + } - /** - *

- * open. - *

- * - * @param name a {@link java.lang.String} object - * @return a {@link java.lang.Object} object - */ - public static Object open(String name) { - try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(name))) { - return in.readObject(); - } catch (Exception e) { - System.out.println(e.toString()); - } - return null; + /** + *

+ * open. + *

+ * + * @param name a {@link java.lang.String} object + * @return a {@link java.lang.Object} object + */ + public static Object open(String name) { + try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(name))) { + return in.readObject(); + } catch (Exception e) { + System.out.println(e.toString()); } + return null; + } } diff --git a/src/main/java/neqsim/util/unit/LengthUnit.java b/src/main/java/neqsim/util/unit/LengthUnit.java index 66906aa00a..8eb5b2538c 100644 --- a/src/main/java/neqsim/util/unit/LengthUnit.java +++ b/src/main/java/neqsim/util/unit/LengthUnit.java @@ -3,6 +3,7 @@ * * Created on 25. januar 2002, 20:23 */ + package neqsim.util.unit; /** @@ -14,12 +15,12 @@ * @version $Id: $Id */ public class LengthUnit extends neqsim.util.unit.BaseUnit { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for LengthUnit. - *

- */ - public LengthUnit() {} + /** + *

+ * Constructor for LengthUnit. + *

+ */ + public LengthUnit() {} } diff --git a/src/main/java/neqsim/util/unit/RateUnit.java b/src/main/java/neqsim/util/unit/RateUnit.java index f12cb342ad..b1695838d5 100644 --- a/src/main/java/neqsim/util/unit/RateUnit.java +++ b/src/main/java/neqsim/util/unit/RateUnit.java @@ -3,6 +3,7 @@ * * Created on 25. januar 2002, 20:22 */ + package neqsim.util.unit; import org.apache.logging.log4j.LogManager; @@ -18,97 +19,97 @@ * @version $Id: $Id */ public class RateUnit extends neqsim.util.unit.BaseUnit { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(RateUnit.class); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(RateUnit.class); - double molarmass = 0.0, stddens = 0.0, boilp = 0.0; + double molarmass = 0.0, stddens = 0.0, boilp = 0.0; - /** - *

- * Constructor for RateUnit. - *

- * - * @param value a double - * @param name a {@link java.lang.String} object - * @param molarmass a double - * @param stddens a double - * @param boilp a double - */ - public RateUnit(double value, String name, double molarmass, double stddens, double boilp) { - super(value, name); - this.molarmass = molarmass; - this.stddens = stddens; - this.boilp = boilp; - } + /** + *

+ * Constructor for RateUnit. + *

+ * + * @param value a double + * @param name a {@link java.lang.String} object + * @param molarmass a double + * @param stddens a double + * @param boilp a double + */ + public RateUnit(double value, String name, double molarmass, double stddens, double boilp) { + super(value, name); + this.molarmass = molarmass; + this.stddens = stddens; + this.boilp = boilp; + } - /** {@inheritDoc} */ - @Override - public double getSIvalue() { - return getConversionFactor(inunit) / getConversionFactor("SI") * invalue; - } + /** {@inheritDoc} */ + @Override + public double getSIvalue() { + return getConversionFactor(inunit) / getConversionFactor("SI") * invalue; + } - /** {@inheritDoc} */ - @Override - public double getValue(String tounit) { - return getConversionFactor(inunit) / getConversionFactor(tounit) * invalue; - } + /** {@inheritDoc} */ + @Override + public double getValue(String tounit) { + return getConversionFactor(inunit) / getConversionFactor(tounit) * invalue; + } - /** - *

- * getConversionFactor. - *

- * - * @param name a {@link java.lang.String} object - * @return a double - */ - public double getConversionFactor(String name) { - double mol_m3 = 0.0; - double mol_Sm3 = 101325.0 / (ThermodynamicConstantsInterface.R * standardStateTemperature); - if (boilp < 25) { - mol_m3 = 101325.0 / (ThermodynamicConstantsInterface.R * standardStateTemperature); - } else { - mol_m3 = 1.0 / (molarmass) * stddens * 1000; - } - - if (name.equals("mole/sec") || name.equals("mol/sec") || name.equals("SI") - || name.equals("mol")) { - factor = 1.0; - } else if (name.equals("Nlitre/min")) { - factor = 1.0 / 60.0 * mol_m3 / 1000.0; - } else if (name.equals("Nlitre/sec")) { - factor = mol_m3 / 1000.0; - } else if (name.equals("Am3/hr")) { - factor = 1.0 / molarmass / 3600.0 * stddens; - } else if (name.equals("Am3/day")) { - factor = 1.0 / molarmass / (3600.0 * 24.0) * stddens; - } else if (name.equals("Am3/min")) { - factor = 1.0 / molarmass / 60.0 * stddens; - } else if (name.equals("Am3/sec")) { - factor = 1.0 / molarmass * stddens; - } else if (name.equals("kg/sec")) { - factor = 1.0 / (molarmass); - } else if (name.equals("kg/min")) { - factor = 1.0 / 60.0 * 1.0 / (molarmass); - } else if (name.equals("kg/hr")) { - factor = 1.0 / molarmass / 3600.0; - } else if (name.equals("kg/day")) { - factor = 1.0 / molarmass / (3600.0 * 24.0); - } else if (name.equals("Sm^3/sec") | name.equals("Sm3/sec")) { - factor = mol_Sm3; - } else if (name.equals("Sm^3/min") | name.equals("Sm3/min")) { - factor = 1.0 / 60.0 * mol_Sm3; - } else if (name.equals("Sm^3/hr") | name.equals("Sm3/hr")) { - factor = 1.0 / 60.0 / 60.0 * mol_Sm3; - } else if (name.equals("Sm^3/day") || name.equals("Sm3/day")) { - factor = 1.0 / 60.0 / 60.0 / 24.0 * mol_Sm3; - } else if (name.equals("MSm^3/day") || name.equals("MSm3/day")) { - factor = 1.0e6 * mol_Sm3 / (3600.0 * 24.0); - } else if (name.equals("MSm^3/hr") || name.equals("MSm3/hr")) { - factor = 1.0e6 * mol_Sm3 / (3600.0); - } else { - logger.error("unit not supported " + name); - } + /** + *

+ * getConversionFactor. + *

+ * + * @param name a {@link java.lang.String} object + * @return a double + */ + public double getConversionFactor(String name) { + double mol_m3 = 0.0; + double mol_Sm3 = 101325.0 / (ThermodynamicConstantsInterface.R * standardStateTemperature); + if (boilp < 25) { + mol_m3 = 101325.0 / (ThermodynamicConstantsInterface.R * standardStateTemperature); + } else { + mol_m3 = 1.0 / (molarmass) * stddens * 1000; + } - return factor; + if (name.equals("mole/sec") || name.equals("mol/sec") || name.equals("SI") + || name.equals("mol")) { + factor = 1.0; + } else if (name.equals("Nlitre/min")) { + factor = 1.0 / 60.0 * mol_m3 / 1000.0; + } else if (name.equals("Nlitre/sec")) { + factor = mol_m3 / 1000.0; + } else if (name.equals("Am3/hr")) { + factor = 1.0 / molarmass / 3600.0 * stddens; + } else if (name.equals("Am3/day")) { + factor = 1.0 / molarmass / (3600.0 * 24.0) * stddens; + } else if (name.equals("Am3/min")) { + factor = 1.0 / molarmass / 60.0 * stddens; + } else if (name.equals("Am3/sec")) { + factor = 1.0 / molarmass * stddens; + } else if (name.equals("kg/sec")) { + factor = 1.0 / (molarmass); + } else if (name.equals("kg/min")) { + factor = 1.0 / 60.0 * 1.0 / (molarmass); + } else if (name.equals("kg/hr")) { + factor = 1.0 / molarmass / 3600.0; + } else if (name.equals("kg/day")) { + factor = 1.0 / molarmass / (3600.0 * 24.0); + } else if (name.equals("Sm^3/sec") | name.equals("Sm3/sec")) { + factor = mol_Sm3; + } else if (name.equals("Sm^3/min") | name.equals("Sm3/min")) { + factor = 1.0 / 60.0 * mol_Sm3; + } else if (name.equals("Sm^3/hr") | name.equals("Sm3/hr")) { + factor = 1.0 / 60.0 / 60.0 * mol_Sm3; + } else if (name.equals("Sm^3/day") || name.equals("Sm3/day")) { + factor = 1.0 / 60.0 / 60.0 / 24.0 * mol_Sm3; + } else if (name.equals("MSm^3/day") || name.equals("MSm3/day")) { + factor = 1.0e6 * mol_Sm3 / (3600.0 * 24.0); + } else if (name.equals("MSm^3/hr") || name.equals("MSm3/hr")) { + factor = 1.0e6 * mol_Sm3 / (3600.0); + } else { + logger.error("unit not supported " + name); } + + return factor; + } } diff --git a/src/main/java/neqsim/util/unit/TimeUnit.java b/src/main/java/neqsim/util/unit/TimeUnit.java index fdd2eb0bd0..f02de44c77 100644 --- a/src/main/java/neqsim/util/unit/TimeUnit.java +++ b/src/main/java/neqsim/util/unit/TimeUnit.java @@ -3,6 +3,7 @@ * * Created on 25. januar 2002, 20:23 */ + package neqsim.util.unit; /** @@ -14,12 +15,12 @@ * @version $Id: $Id */ public class TimeUnit extends neqsim.util.unit.BaseUnit { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for TimeUnit. - *

- */ - public TimeUnit() {} + /** + *

+ * Constructor for TimeUnit. + *

+ */ + public TimeUnit() {} } diff --git a/src/main/java/neqsim/util/unit/Unit.java b/src/main/java/neqsim/util/unit/Unit.java index 4d04e2b28a..77306bd9f9 100644 --- a/src/main/java/neqsim/util/unit/Unit.java +++ b/src/main/java/neqsim/util/unit/Unit.java @@ -3,6 +3,7 @@ * * Created on 25. januar 2002, 20:20 */ + package neqsim.util.unit; /** @@ -14,34 +15,34 @@ * @version $Id: $Id */ public interface Unit { - /** - *

- * getSIvalue. - *

- * - * @return a double - */ - double getSIvalue(); + /** + *

+ * getSIvalue. + *

+ * + * @return a double + */ + double getSIvalue(); - /** - *

- * getValue. - *

- * - * @param tounit a {@link java.lang.String} object - * @return a double - */ - double getValue(String tounit); + /** + *

+ * getValue. + *

+ * + * @param tounit a {@link java.lang.String} object + * @return a double + */ + double getValue(String tounit); - /** - *

- * getValue. - *

- * - * @param val a double - * @param fromunit a {@link java.lang.String} object - * @param tounit a {@link java.lang.String} object - * @return a double - */ - double getValue(double val, String fromunit, String tounit); + /** + *

+ * getValue. + *

+ * + * @param val a double + * @param fromunit a {@link java.lang.String} object + * @param tounit a {@link java.lang.String} object + * @return a double + */ + double getValue(double val, String fromunit, String tounit); } diff --git a/src/main/java/neqsim/util/util/DoubleCloneable.java b/src/main/java/neqsim/util/util/DoubleCloneable.java index d6d88611ca..59e7eae338 100644 --- a/src/main/java/neqsim/util/util/DoubleCloneable.java +++ b/src/main/java/neqsim/util/util/DoubleCloneable.java @@ -3,6 +3,7 @@ * * Created on 3. juni 2001, 20:19 */ + package neqsim.util.util; /** @@ -14,57 +15,57 @@ * @version $Id: $Id */ public class DoubleCloneable implements Cloneable { - double doubleValue; + double doubleValue; - /** - *

- * Constructor for DoubleCloneable. - *

- */ - public DoubleCloneable() {} + /** + *

+ * Constructor for DoubleCloneable. + *

+ */ + public DoubleCloneable() {} - /** - *

- * Constructor for DoubleCloneable. - *

- * - * @param val a double - */ - public DoubleCloneable(double val) { - this.doubleValue = val; - } + /** + *

+ * Constructor for DoubleCloneable. + *

+ * + * @param val a double + */ + public DoubleCloneable(double val) { + this.doubleValue = val; + } - /** {@inheritDoc} */ - @Override - public DoubleCloneable clone() { - DoubleCloneable clonedSystem = null; - try { - clonedSystem = (DoubleCloneable) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); - } - return clonedSystem; + /** {@inheritDoc} */ + @Override + public DoubleCloneable clone() { + DoubleCloneable clonedSystem = null; + try { + clonedSystem = (DoubleCloneable) super.clone(); + } catch (Exception e) { + e.printStackTrace(System.err); } + return clonedSystem; + } - /** - *

- * set. - *

- * - * @param val a double - */ - public void set(double val) { - doubleValue = val; - } + /** + *

+ * set. + *

+ * + * @param val a double + */ + public void set(double val) { + doubleValue = val; + } - /** - *

- * doubleValue. - *

- * - * @return a double - */ - public double doubleValue() { - return doubleValue; - } + /** + *

+ * doubleValue. + *

+ * + * @return a double + */ + public double doubleValue() { + return doubleValue; + } } diff --git a/src/main/java/neqsim/util/util/FileSystemSettings.java b/src/main/java/neqsim/util/util/FileSystemSettings.java index 9593aa5978..7e63421515 100644 --- a/src/main/java/neqsim/util/util/FileSystemSettings.java +++ b/src/main/java/neqsim/util/util/FileSystemSettings.java @@ -3,6 +3,7 @@ * * Created on 3. november 2001, 17:55 */ + package neqsim.util.util; /** @@ -14,18 +15,19 @@ * @version $Id: $Id */ public interface FileSystemSettings { - /** Constant root="c:" */ - String root = "c:"; - /** Constant tempDir="root + /temp/" */ - String tempDir = root + "/temp/"; - /** - * Constant defaultFileTreeRoot="root + /Program Files/NeqSim/pythonScri"{trunked} - */ - String defaultFileTreeRoot = root + "/Program Files/NeqSim/pythonScript/"; - /** Constant defaultDatabaseRootRoot="root + /java/NeqSim/util/database" */ - String defaultDatabaseRootRoot = root + "/java/NeqSim/util/database"; - /** Constant relativeFilePath="root" */ - String relativeFilePath = root; - /** Constant fileExtension=".py" */ - String fileExtension = ".py"; + /** Constant root="c:". */ + String root = "c:"; + /** Constant tempDir="root + /temp/". */ + String tempDir = root + "/temp/"; + + /** + * Constant defaultFileTreeRoot="root + /Program Files/NeqSim/pythonScri"{trunked}. + */ + String defaultFileTreeRoot = root + "/Program Files/NeqSim/pythonScript/"; + /** Constant defaultDatabaseRootRoot="root + /java/NeqSim/util/database". */ + String defaultDatabaseRootRoot = root + "/java/NeqSim/util/database"; + /** Constant relativeFilePath="root". */ + String relativeFilePath = root; + /** Constant fileExtension=".py". */ + String fileExtension = ".py"; } diff --git a/src/test/java/neqsim/processSimulation/processEquipment/mixer/MixerTest.java b/src/test/java/neqsim/processSimulation/processEquipment/mixer/MixerTest.java index 0485747fc1..6cc8847bdc 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/mixer/MixerTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/mixer/MixerTest.java @@ -1,6 +1,3 @@ -/** - * - */ package neqsim.processSimulation.processEquipment.mixer; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -18,6 +15,7 @@ class MixerTest { static neqsim.thermo.system.SystemInterface waterSystem; static Stream gasStream; static Stream waterStream; + /** * @throws java.lang.Exception */ @@ -31,9 +29,9 @@ static void setUpBeforeClass() throws Exception { testSystem.addTBPfraction("C10", 0.01, 0.366, 0.94); testSystem.setMixingRule(2); testSystem.setMultiPhaseCheck(true); - + waterSystem = testSystem.clone(); - waterSystem.setMolarComposition(new double[]{1.0, 0.0, 0.0,0.0, 0.0}); + waterSystem.setMolarComposition(new double[] {1.0, 0.0, 0.0, 0.0, 0.0}); gasStream = new Stream("turbine stream", testSystem); gasStream.setFlowRate(1.0, "MSm3/day"); diff --git a/src/test/java/neqsim/processSimulation/util/example/LNGfilling.java b/src/test/java/neqsim/processSimulation/util/example/LNGfilling.java index ac0c2b8c52..574a3d5c4b 100644 --- a/src/test/java/neqsim/processSimulation/util/example/LNGfilling.java +++ b/src/test/java/neqsim/processSimulation/util/example/LNGfilling.java @@ -3,6 +3,7 @@ * * Created on 6. september 2006, 14:46 */ + package neqsim.processSimulation.util.example; import neqsim.processSimulation.processEquipment.mixer.Mixer; @@ -18,47 +19,46 @@ * @since 2.2.3 */ public class LNGfilling { - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 - 163.0), 1.000); - testSystem.addComponent("methane", 0.6); - testSystem.addComponent("nitrogen", 1.0e-10); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos((273.15 - 163.0), 1.000); + testSystem.addComponent("methane", 0.6); + testSystem.addComponent("nitrogen", 1.0e-10); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); - neqsim.thermo.system.SystemInterface testSystem2 = - new neqsim.thermo.system.SystemSrkEos((273.15 + 20.0), 1.00); - testSystem2.addComponent("methane", 1.0e-10); - testSystem2.addComponent("nitrogen", 1.6e2); - testSystem2.createDatabase(true); - testSystem2.setMixingRule(2); + neqsim.thermo.system.SystemInterface testSystem2 = + new neqsim.thermo.system.SystemSrkEos((273.15 + 20.0), 1.00); + testSystem2.addComponent("methane", 1.0e-10); + testSystem2.addComponent("nitrogen", 1.6e2); + testSystem2.createDatabase(true); + testSystem2.setMixingRule(2); - Stream stream_1 = new Stream("Methane Stream", testSystem); - Stream stream_2 = new Stream("Nitrogen Stream", testSystem2); + Stream stream_1 = new Stream("Methane Stream", testSystem); + Stream stream_2 = new Stream("Nitrogen Stream", testSystem2); - Mixer mixer = - new neqsim.processSimulation.processEquipment.mixer.StaticMixer("LNG Tank Mix"); - mixer.addStream(stream_1); - mixer.addStream(stream_2); + Mixer mixer = new neqsim.processSimulation.processEquipment.mixer.StaticMixer("LNG Tank Mix"); + mixer.addStream(stream_1); + mixer.addStream(stream_2); - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(stream_1); - operations.add(stream_2); - operations.add(mixer); - operations.run(); - operations.displayResult(); + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(stream_2); + operations.add(mixer); + operations.run(); + operations.displayResult(); - System.out.println("Volume Methane " + stream_1.getThermoSystem().getVolume()); - System.out.println("Volume Nitrogen " + stream_2.getThermoSystem().getVolume()); - System.out.println( - "Mixer Cooled Nitrogen " + mixer.getOutletStream().getThermoSystem().getVolume()); - } + System.out.println("Volume Methane " + stream_1.getThermoSystem().getVolume()); + System.out.println("Volume Nitrogen " + stream_2.getThermoSystem().getVolume()); + System.out + .println("Mixer Cooled Nitrogen " + mixer.getOutletStream().getThermoSystem().getVolume()); + } } diff --git a/src/test/java/neqsim/processSimulation/util/example/TestSlugcatcher.java b/src/test/java/neqsim/processSimulation/util/example/TestSlugcatcher.java index dae8ea8707..da9fc4eddc 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TestSlugcatcher.java +++ b/src/test/java/neqsim/processSimulation/util/example/TestSlugcatcher.java @@ -3,6 +3,7 @@ * * Created on 30. juli 2007, 18:49 */ + package neqsim.processSimulation.util.example; import neqsim.processSimulation.measurementDevice.VolumeFlowTransmitter; @@ -20,63 +21,61 @@ * @since 2.2.3 */ public class TestSlugcatcher { - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - double reservoirTemperatureSnohvit = 273.15 + 10.0; // K - double reservoirPressureSnohvit = 5.0; // bar + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + double reservoirTemperatureSnohvit = 273.15 + 10.0; // K + double reservoirPressureSnohvit = 5.0; // bar - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkCPAstatoil(reservoirTemperatureSnohvit, - reservoirPressureSnohvit); + neqsim.thermo.system.SystemInterface testSystem = new neqsim.thermo.system.SystemSrkCPAstatoil( + reservoirTemperatureSnohvit, reservoirPressureSnohvit); - testSystem.addComponent("nitrogen", 40); - testSystem.addComponent("methane", 10); - testSystem.addComponent("CO2", 0.5); - testSystem.addComponent("water", 70); - testSystem.addComponent("MEG", 30); + testSystem.addComponent("nitrogen", 40); + testSystem.addComponent("methane", 10); + testSystem.addComponent("CO2", 0.5); + testSystem.addComponent("water", 70); + testSystem.addComponent("MEG", 30); - testSystem.createDatabase(true); - testSystem.setMixingRule(7); + testSystem.createDatabase(true); + testSystem.setMixingRule(7); - Stream stream_1 = new Stream("Stream1", testSystem); - ThreePhaseSeparator separator = new ThreePhaseSeparator("Separator 1", stream_1); + Stream stream_1 = new Stream("Stream1", testSystem); + ThreePhaseSeparator separator = new ThreePhaseSeparator("Separator 1", stream_1); - ThrottlingValve valve1 = - new ThrottlingValve("snohvit valve", separator.getWaterOutStream()); - valve1.setOutletPressure(1.4); + ThrottlingValve valve1 = new ThrottlingValve("snohvit valve", separator.getWaterOutStream()); + valve1.setOutletPressure(1.4); - ThreePhaseSeparator separator2 = - new ThreePhaseSeparator("Separator 1", valve1.getOutletStream()); - Stream stream_2 = new Stream("stream_2", separator2.getGasOutStream()); + ThreePhaseSeparator separator2 = + new ThreePhaseSeparator("Separator 1", valve1.getOutletStream()); + Stream stream_2 = new Stream("stream_2", separator2.getGasOutStream()); - VolumeFlowTransmitter volumeTransmitter3 = - new VolumeFlowTransmitter(separator2.getGasOutStream()); - volumeTransmitter3.setMeasuredPhaseNumber(0); - volumeTransmitter3.setName("Gas Volume FLow From Slug Catcher"); + VolumeFlowTransmitter volumeTransmitter3 = + new VolumeFlowTransmitter(separator2.getGasOutStream()); + volumeTransmitter3.setMeasuredPhaseNumber(0); + volumeTransmitter3.setName("Gas Volume FLow From Slug Catcher"); - VolumeFlowTransmitter volumeTransmitter4 = - new VolumeFlowTransmitter(separator2.getWaterOutStream()); - volumeTransmitter4.setMeasuredPhaseNumber(0); - volumeTransmitter4.setName("Water Volume FLow From Slug Catcher"); + VolumeFlowTransmitter volumeTransmitter4 = + new VolumeFlowTransmitter(separator2.getWaterOutStream()); + volumeTransmitter4.setMeasuredPhaseNumber(0); + volumeTransmitter4.setName("Water Volume FLow From Slug Catcher"); - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(stream_1); - operations.add(separator); - operations.add(valve1); - operations.add(separator2); - operations.add(stream_2); - operations.add(volumeTransmitter3); - operations.add(volumeTransmitter4); + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(separator); + operations.add(valve1); + operations.add(separator2); + operations.add(stream_2); + operations.add(volumeTransmitter3); + operations.add(volumeTransmitter4); - operations.run(); - operations.displayResult(); - operations.reportMeasuredValues(); - } + operations.run(); + operations.displayResult(); + operations.reportMeasuredValues(); + } } diff --git a/src/test/java/neqsim/processSimulation/util/example/TestTransientFlow.java b/src/test/java/neqsim/processSimulation/util/example/TestTransientFlow.java index d732ffee98..918ccbd179 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TestTransientFlow.java +++ b/src/test/java/neqsim/processSimulation/util/example/TestTransientFlow.java @@ -3,6 +3,7 @@ * * Created on 8. oktober 2006, 13:13 */ + package neqsim.processSimulation.util.example; import neqsim.processSimulation.controllerDevice.ControllerDeviceBaseClass; @@ -23,112 +24,111 @@ * @since 2.2.3 */ public class TestTransientFlow { - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); + testSystem.addComponent("methane", 0.900); + testSystem.addComponent("ethane", 0.100); + testSystem.addComponent("n-heptane", 1.00); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + + neqsim.thermo.system.SystemInterface testSystem2 = + new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); + testSystem2.addComponent("methane", 1.1); + testSystem2.addComponent("ethane", 0.10001); + testSystem2.addComponent("n-heptane", 0.001); + testSystem2.setMixingRule(2); + + Stream purgeStream = new Stream("Purge Stream", testSystem2); + ThrottlingValve purgeValve = new ThrottlingValve("purgeValve", purgeStream); + purgeValve.setOutletPressure(7.0); + purgeValve.setPercentValveOpening(50.0); + + Stream stream_1 = new Stream("Stream1", testSystem); + ThrottlingValve valve_1 = new ThrottlingValve("valve_1", stream_1); + valve_1.setOutletPressure(7.0); + valve_1.setPercentValveOpening(50); + + Separator separator_1 = new Separator("separator_1"); + separator_1.addStream(valve_1.getOutletStream()); + separator_1.addStream(purgeValve.getOutletStream()); + + ThrottlingValve valve_2 = new ThrottlingValve("valve_2", separator_1.getLiquidOutStream()); + valve_2.setOutletPressure(5.0); + valve_2.setPercentValveOpening(50); + // valve_2.setCv(10.0); + + ThrottlingValve valve_3 = new ThrottlingValve("valve_3", separator_1.getGasOutStream()); + valve_3.setOutletPressure(5.0); + valve_3.setPercentValveOpening(50); + // valve_3.setCv(10.0); + + LevelTransmitter separatorLevelTransmitter = new LevelTransmitter(separator_1); + separatorLevelTransmitter.setName("separatorLEvelTransmitter1"); + separatorLevelTransmitter.setUnit("meter"); + separatorLevelTransmitter.setMaximumValue(1.0); + separatorLevelTransmitter.setMinimumValue(0.0); + + ControllerDeviceInterface separatorLevelController = new ControllerDeviceBaseClass(); + separatorLevelController.setReverseActing(false); + separatorLevelController.setTransmitter(separatorLevelTransmitter); + separatorLevelController.setControllerSetPoint(0.3); + separatorLevelController.setControllerParameters(1.0, 300.0, 10.0); + + PressureTransmitter separatorPressureTransmitter = + new PressureTransmitter(separator_1.getGasOutStream()); + separatorPressureTransmitter.setUnit("bar"); + separatorPressureTransmitter.setMaximumValue(10.0); + separatorPressureTransmitter.setMinimumValue(1.0); + + ControllerDeviceInterface separatorPressureController = new ControllerDeviceBaseClass(); + separatorPressureController.setTransmitter(separatorPressureTransmitter); + separatorPressureController.setReverseActing(false); + separatorPressureController.setControllerSetPoint(7.0); + separatorPressureController.setControllerParameters(1.0, 300.0, 10.0); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(valve_1); + + operations.add(purgeStream); + operations.add(purgeValve); + operations.add(separator_1); + operations.add(valve_2); + operations.add(valve_3); + + // add transmitters and controllers + operations.add(separatorLevelTransmitter); + valve_2.setController(separatorLevelController); + + operations.add(separatorPressureTransmitter); + valve_3.setController(separatorPressureController); + + operations.run(); + operations.displayResult(); + operations.setTimeStep(0.001); + operations.runTransient(); + operations.runTransient(); + + /* + * // transient behaviour operations.setTimeStep(1.1); for(int i=0;i<50;i++){ + * operations.runTransient(); System.out.println("liquid level " + separator_1.getLiquidLevel()+ + * " PRESSURE " + separator_1.getGasOutStream().getPressure()); } + * + * operations.setTimeStep(30.0); for(int i=0;i<2000;i++){ operations.runTransient(); + * System.out.println("liquid level " + separator_1.getLiquidLevel()+ " PRESSURE " + + * separator_1.getGasOutStream().getPressure()); } operations.displayResult(); + * + * operations.displayResult(); */ - public static void main(String args[]) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); - testSystem.addComponent("methane", 0.900); - testSystem.addComponent("ethane", 0.100); - testSystem.addComponent("n-heptane", 1.00); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - - neqsim.thermo.system.SystemInterface testSystem2 = - new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); - testSystem2.addComponent("methane", 1.1); - testSystem2.addComponent("ethane", 0.10001); - testSystem2.addComponent("n-heptane", 0.001); - testSystem2.setMixingRule(2); - - Stream purgeStream = new Stream("Purge Stream", testSystem2); - ThrottlingValve purgeValve = new ThrottlingValve("purgeValve", purgeStream); - purgeValve.setOutletPressure(7.0); - purgeValve.setPercentValveOpening(50.0); - - Stream stream_1 = new Stream("Stream1", testSystem); - ThrottlingValve valve_1 = new ThrottlingValve("valve_1", stream_1); - valve_1.setOutletPressure(7.0); - valve_1.setPercentValveOpening(50); - - Separator separator_1 = new Separator("separator_1"); - separator_1.addStream(valve_1.getOutletStream()); - separator_1.addStream(purgeValve.getOutletStream()); - - ThrottlingValve valve_2 = new ThrottlingValve("valve_2", separator_1.getLiquidOutStream()); - valve_2.setOutletPressure(5.0); - valve_2.setPercentValveOpening(50); - // valve_2.setCv(10.0); - - ThrottlingValve valve_3 = new ThrottlingValve("valve_3", separator_1.getGasOutStream()); - valve_3.setOutletPressure(5.0); - valve_3.setPercentValveOpening(50); - // valve_3.setCv(10.0); - - LevelTransmitter separatorLevelTransmitter = new LevelTransmitter(separator_1); - separatorLevelTransmitter.setName("separatorLEvelTransmitter1"); - separatorLevelTransmitter.setUnit("meter"); - separatorLevelTransmitter.setMaximumValue(1.0); - separatorLevelTransmitter.setMinimumValue(0.0); - - ControllerDeviceInterface separatorLevelController = new ControllerDeviceBaseClass(); - separatorLevelController.setReverseActing(false); - separatorLevelController.setTransmitter(separatorLevelTransmitter); - separatorLevelController.setControllerSetPoint(0.3); - separatorLevelController.setControllerParameters(1.0, 300.0, 10.0); - - PressureTransmitter separatorPressureTransmitter = - new PressureTransmitter(separator_1.getGasOutStream()); - separatorPressureTransmitter.setUnit("bar"); - separatorPressureTransmitter.setMaximumValue(10.0); - separatorPressureTransmitter.setMinimumValue(1.0); - - ControllerDeviceInterface separatorPressureController = new ControllerDeviceBaseClass(); - separatorPressureController.setTransmitter(separatorPressureTransmitter); - separatorPressureController.setReverseActing(false); - separatorPressureController.setControllerSetPoint(7.0); - separatorPressureController.setControllerParameters(1.0, 300.0, 10.0); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(stream_1); - operations.add(valve_1); - - operations.add(purgeStream); - operations.add(purgeValve); - operations.add(separator_1); - operations.add(valve_2); - operations.add(valve_3); - - // add transmitters and controllers - operations.add(separatorLevelTransmitter); - valve_2.setController(separatorLevelController); - - operations.add(separatorPressureTransmitter); - valve_3.setController(separatorPressureController); - - operations.run(); - operations.displayResult(); - operations.setTimeStep(0.001); - operations.runTransient(); - operations.runTransient(); - - /* - * // transient behaviour operations.setTimeStep(1.1); for(int i=0;i<50;i++){ - * operations.runTransient(); System.out.println("liquid level " + - * separator_1.getLiquidLevel()+ " PRESSURE " + - * separator_1.getGasOutStream().getPressure()); } - * - * operations.setTimeStep(30.0); for(int i=0;i<2000;i++){ operations.runTransient(); - * System.out.println("liquid level " + separator_1.getLiquidLevel()+ " PRESSURE " + - * separator_1.getGasOutStream().getPressure()); } operations.displayResult(); - * - * operations.displayResult(); - */ - } + } } diff --git a/src/test/java/neqsim/standards/gasQuality/Standard_ISO6976Test.java b/src/test/java/neqsim/standards/gasQuality/Standard_ISO6976Test.java index ca24eaab67..1111156594 100644 --- a/src/test/java/neqsim/standards/gasQuality/Standard_ISO6976Test.java +++ b/src/test/java/neqsim/standards/gasQuality/Standard_ISO6976Test.java @@ -1,6 +1,3 @@ -/** - * - */ package neqsim.standards.gasQuality; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/test/java/neqsim/thermo/component/ComponentHydrateGFTest.java b/src/test/java/neqsim/thermo/component/ComponentHydrateGFTest.java index ce8f536938..30c645bd1e 100644 --- a/src/test/java/neqsim/thermo/component/ComponentHydrateGFTest.java +++ b/src/test/java/neqsim/thermo/component/ComponentHydrateGFTest.java @@ -1,6 +1,3 @@ -/** - * - */ package neqsim.thermo.component; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -15,37 +12,37 @@ * @author ESOL * */ -class ComponentHydrateGFTest extends neqsim.NeqSimTest{ - static SystemInterface thermoSystem = null; +class ComponentHydrateGFTest extends neqsim.NeqSimTest { + static SystemInterface thermoSystem = null; - /** - * @throws java.lang.Exception - */ - @BeforeAll - static void setUpBeforeClass() throws Exception { - thermoSystem = new SystemSrkCPAstatoil(298.0, 100.0); - thermoSystem.addComponent("methane", 11.0); - thermoSystem.addComponent("CO2", 1.0); - thermoSystem.addComponent("water", 11.0); - thermoSystem.setMixingRule(10); - } + /** + * @throws java.lang.Exception + */ + @BeforeAll + static void setUpBeforeClass() throws Exception { + thermoSystem = new SystemSrkCPAstatoil(298.0, 100.0); + thermoSystem.addComponent("methane", 11.0); + thermoSystem.addComponent("CO2", 1.0); + thermoSystem.addComponent("water", 11.0); + thermoSystem.setMixingRule(10); + } - /** - * Test method for {@link neqsim.thermo.component.ComponentHydrateGF#ComponentHydrateGF(java.lang.String, double, double, int)}. - */ - @Test - void testComponentHydrateGFStringDoubleDoubleInt() { - ThermodynamicOperations testOps = new ThermodynamicOperations(thermoSystem); - try { - thermoSystem.setHydrateCheck(true); - testOps.hydrateFormationTemperature(); - } - catch(Exception e) { - e.printStackTrace(); - assertTrue(false); - return; - } - assertEquals(286.4105348944992,thermoSystem.getTemperature("K"), 0.001); - } + /** + * Test method for + * {@link neqsim.thermo.component.ComponentHydrateGF#ComponentHydrateGF(java.lang.String, double, double, int)}. + */ + @Test + void testComponentHydrateGFStringDoubleDoubleInt() { + ThermodynamicOperations testOps = new ThermodynamicOperations(thermoSystem); + try { + thermoSystem.setHydrateCheck(true); + testOps.hydrateFormationTemperature(); + } catch (Exception e) { + e.printStackTrace(); + assertTrue(false); + return; + } + assertEquals(286.4105348944992, thermoSystem.getTemperature("K"), 0.001); + } } diff --git a/src/test/java/neqsim/thermo/util/example/ActivityCalc.java b/src/test/java/neqsim/thermo/util/example/ActivityCalc.java index a1c15e1d87..c22fbb099d 100644 --- a/src/test/java/neqsim/thermo/util/example/ActivityCalc.java +++ b/src/test/java/neqsim/thermo/util/example/ActivityCalc.java @@ -3,6 +3,7 @@ * * Created on 5. mars 2002, 15:17 */ + package neqsim.thermo.util.example; import neqsim.thermo.system.SystemInterface; @@ -10,38 +11,42 @@ import neqsim.thermodynamicOperations.ThermodynamicOperations; /** - *

ActivityCalc class.

+ *

+ * ActivityCalc class. + *

* * @author esol * @since 2.2.3 * @version $Id: $Id */ public class ActivityCalc { - /** - *

main.

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 42, 1.01325); - - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - - testSystem.addComponent("TEG", 0.99); - testSystem.addComponent("water", 0.01); - - testSystem.createDatabase(true); - - testSystem.setMixingRule(10); - testSystem.init(0); - testSystem.init(1); - - try { - testOps.bubblePointPressureFlash(false); - } catch (Exception e) { - } - - //testSystem.display(); - System.out.println("activity water " + testSystem.getPhase(1).getActivityCoefficient(1)); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 42, 1.01325); + + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + + testSystem.addComponent("TEG", 0.99); + testSystem.addComponent("water", 0.01); + + testSystem.createDatabase(true); + + testSystem.setMixingRule(10); + testSystem.init(0); + testSystem.init(1); + + try { + testOps.bubblePointPressureFlash(false); + } catch (Exception e) { } + + // testSystem.display(); + System.out.println("activity water " + testSystem.getPhase(1).getActivityCoefficient(1)); + } } diff --git a/src/test/java/neqsim/thermo/util/example/ScalePotentialCheck.java b/src/test/java/neqsim/thermo/util/example/ScalePotentialCheck.java index 1d795e8751..6c8a75c2ba 100644 --- a/src/test/java/neqsim/thermo/util/example/ScalePotentialCheck.java +++ b/src/test/java/neqsim/thermo/util/example/ScalePotentialCheck.java @@ -3,6 +3,7 @@ * * Created on 19. desember 2005, 14:39 */ + package neqsim.thermo.util.example; import org.apache.logging.log4j.LogManager; @@ -12,72 +13,76 @@ import neqsim.thermodynamicOperations.ThermodynamicOperations; /** - *

ScalePotentialCheck class.

+ *

+ * ScalePotentialCheck class. + *

* * @author ESOL * @version $Id: $Id * @since 2.2.3 */ public class ScalePotentialCheck { - static Logger logger = LogManager.getLogger(ScalePotentialCheck.class); + static Logger logger = LogManager.getLogger(ScalePotentialCheck.class); - /** - *

main.

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - // SystemInterface testSystem = new Ele(273.15+10.0,10.0); - SystemInterface testSystem = new SystemElectrolyteCPAstatoil(273.15 + 25.0, 10.0); - // SystemInterface testSystem = new SystemFurstElectrolyteEosMod2004(273.15 + - // 15.0, 1.0); - // SystemInterface testSystem = new SystemSrkEos(273.15 + 50.0, 10.0); - // testSystem.addComponent("Cl-",0.001); - // testSystem.addComponent("CO3--",0.00000095); - // testSystem.addComponent("HCO3-",0.0001); - testSystem.addComponent("methane", 90); - // testSystem.addComponent("ethane", 10.5); - testSystem.addComponent("CO2", 0.1); - testSystem.addComponent("H2S", 0.01); - // testSystem.addComponent("n-heptane", 15.2); - // testSystem.addComponent("nC10", 0.52); - // testSystem.addComponent("MEG", 0.1); - // testSystem.addComponent("MDEA", 1); - testSystem.addComponent("water", 1, "kg/sec"); - // testSystem.addComponent("Mg++", 0.07);// * 24.31); - testSystem.addComponent("Na+", 4e-5); - testSystem.addComponent("Cl-", 4e-5); - // testSystem.addComponent("Hg++", 4e-7); - testSystem.addComponent("OH-", 220e-5); - testSystem.addComponent("Fe++", 110.1e-5); - // testSystem.addComponent("OH-", 0.07*2);// * 17.001); - // testSystem.addComponent("Cl-", (1000 - 100) * 1e-3); - // testSystem.addComponent("Ca++",0.002); - // testSystem.addComponent("CO3--",14.0E-6); - // testSystem = testSystem.autoSelectModel(); - testSystem.chemicalReactionInit(); - // testSystem.isChemicalSystem(false); - testSystem.createDatabase(true); - testSystem.setMixingRule(10); - testSystem.setMultiPhaseCheck(true); - // testSystem.isChemicalSystem(false); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - try { - testOps.TPflash(); - testSystem.display(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + // SystemInterface testSystem = new Ele(273.15+10.0,10.0); + SystemInterface testSystem = new SystemElectrolyteCPAstatoil(273.15 + 25.0, 10.0); + // SystemInterface testSystem = new SystemFurstElectrolyteEosMod2004(273.15 + + // 15.0, 1.0); + // SystemInterface testSystem = new SystemSrkEos(273.15 + 50.0, 10.0); + // testSystem.addComponent("Cl-",0.001); + // testSystem.addComponent("CO3--",0.00000095); + // testSystem.addComponent("HCO3-",0.0001); + testSystem.addComponent("methane", 90); + // testSystem.addComponent("ethane", 10.5); + testSystem.addComponent("CO2", 0.1); + testSystem.addComponent("H2S", 0.01); + // testSystem.addComponent("n-heptane", 15.2); + // testSystem.addComponent("nC10", 0.52); + // testSystem.addComponent("MEG", 0.1); + // testSystem.addComponent("MDEA", 1); + testSystem.addComponent("water", 1, "kg/sec"); + // testSystem.addComponent("Mg++", 0.07);// * 24.31); + testSystem.addComponent("Na+", 4e-5); + testSystem.addComponent("Cl-", 4e-5); + // testSystem.addComponent("Hg++", 4e-7); + testSystem.addComponent("OH-", 220e-5); + testSystem.addComponent("Fe++", 110.1e-5); + // testSystem.addComponent("OH-", 0.07*2);// * 17.001); + // testSystem.addComponent("Cl-", (1000 - 100) * 1e-3); + // testSystem.addComponent("Ca++",0.002); + // testSystem.addComponent("CO3--",14.0E-6); + // testSystem = testSystem.autoSelectModel(); + testSystem.chemicalReactionInit(); + // testSystem.isChemicalSystem(false); + testSystem.createDatabase(true); + testSystem.setMixingRule(10); + testSystem.setMultiPhaseCheck(true); + // testSystem.isChemicalSystem(false); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + try { + testOps.TPflash(); + testSystem.display(); - testOps.calcIonComposition(testSystem.getPhaseNumberOfPhase("aqueous")); - testOps.display(); + testOps.calcIonComposition(testSystem.getPhaseNumberOfPhase("aqueous")); + testOps.display(); - testOps.checkScalePotential(testSystem.getPhaseNumberOfPhase("aqueous")); - testOps.display(); - // testOps.addIonToScaleSaturation(1,"FeCO3","Fe++"); - // testOps.display(); - logger.info(testOps.getResultTable()); - } catch (Exception e) { - logger.error("error", e); - } - logger.info("pH " + testSystem.getPhase("aqueous").getpH()); - // testSystem.display(); + testOps.checkScalePotential(testSystem.getPhaseNumberOfPhase("aqueous")); + testOps.display(); + // testOps.addIonToScaleSaturation(1,"FeCO3","Fe++"); + // testOps.display(); + logger.info(testOps.getResultTable()); + } catch (Exception e) { + logger.error("error", e); } + logger.info("pH " + testSystem.getPhase("aqueous").getpH()); + // testSystem.display(); + } } diff --git a/src/test/java/neqsim/thermo/util/example/TPflash.java b/src/test/java/neqsim/thermo/util/example/TPflash.java index 9bc24030b8..d6865dd2df 100644 --- a/src/test/java/neqsim/thermo/util/example/TPflash.java +++ b/src/test/java/neqsim/thermo/util/example/TPflash.java @@ -14,59 +14,61 @@ * @since 2.2.3 */ public class TPflash { - /** - *

main.

- * - * @param args an array of {@link java.lang.String} objects + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + SystemInterface testSystem = new SystemSrkEos(273.15 + 42.498, 19.2875); + testSystem.getCharacterization().getLumpingModel().setNumberOfLumpedComponents(5); + testSystem.addComponent("water", 40.0); + testSystem.addComponent("TEG", 40.0); + testSystem.addComponent("nitrogen", 40.0); + testSystem.addComponent("CO2", 40.0); + testSystem.addComponent("methane", 14); + testSystem.addComponent("ethane", 14); + testSystem.addComponent("propane", 14); + testSystem.addComponent("n-butane", 14); + testSystem.addComponent("i-butane", 14); + testSystem.addComponent("ethane", 14); + testSystem.addComponent("n-pentane", 14); + testSystem.addComponent("i-pentane", 14); + /* + * testSystem.addTBPfraction("C6", 1.0, 85.0253 / 1000.0, 0.667229); + * testSystem.addTBPfraction("C7", 1.0, 90.3717 / 1000.0, 746.3681 / 1000.0); + * testSystem.addTBPfraction("C8", 1.0, 102.4695 / 1000.0, 770.9114 / 1000.0); + * testSystem.addTBPfraction("C9", 1.0, 115.6 / 1000.0, 790.1 / 1000.0); + * testSystem.addTBPfraction("C10", 1.0, 225.5046 / 1000.0, 841.1014 / 1000.0); + * testSystem.setMolarComposition(new double[] { 0.829, 0, 0.0007, 0.002, 0.0707, 0.0072, + * 0.0051, 0.0019, 0.0062, 0.0048, 0.006, 0.0074, 0.0109, 0.0109, 0.0062, 0.031 }); + * + * testSystem.setHeavyTBPfractionAsPlusFraction(); + * testSystem.getCharacterization().characterisePlusFraction(); */ - public static void main(String[] args) { - SystemInterface testSystem = new SystemSrkEos(273.15 + 42.498, 19.2875); - testSystem.getCharacterization().getLumpingModel().setNumberOfLumpedComponents(5); - testSystem.addComponent("water", 40.0); - testSystem.addComponent("TEG", 40.0); - testSystem.addComponent("nitrogen", 40.0); - testSystem.addComponent("CO2", 40.0); - testSystem.addComponent("methane", 14); - testSystem.addComponent("ethane", 14); - testSystem.addComponent("propane", 14); - testSystem.addComponent("n-butane", 14); - testSystem.addComponent("i-butane", 14); - testSystem.addComponent("ethane", 14); - testSystem.addComponent("n-pentane", 14); - testSystem.addComponent("i-pentane", 14); - /* - * testSystem.addTBPfraction("C6", 1.0, 85.0253 / 1000.0, 0.667229); - * testSystem.addTBPfraction("C7", 1.0, 90.3717 / 1000.0, 746.3681 / 1000.0); - * testSystem.addTBPfraction("C8", 1.0, 102.4695 / 1000.0, 770.9114 / 1000.0); - * testSystem.addTBPfraction("C9", 1.0, 115.6 / 1000.0, 790.1 / 1000.0); - * testSystem.addTBPfraction("C10", 1.0, 225.5046 / 1000.0, 841.1014 / 1000.0); - * testSystem.setMolarComposition(new double[] { 0.829, 0, 0.0007, 0.002, 0.0707, 0.0072, - * 0.0051, 0.0019, 0.0062, 0.0048, 0.006, 0.0074, 0.0109, 0.0109, 0.0062, 0.031 }); - * - * testSystem.setHeavyTBPfractionAsPlusFraction(); - * testSystem.getCharacterization().characterisePlusFraction(); - */ - testSystem.setMixingRule(2); - testSystem.setMultiPhaseCheck(true); + testSystem.setMixingRule(2); + testSystem.setMultiPhaseCheck(true); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - try { - testOps.TPflash(); - } catch (Exception e) { - } - - // ObjectMapper om = new ObjectMapper(new YAMLFactory()); - // om.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); + try { + testOps.TPflash(); + } catch (Exception e) { + } - try { - // om.writeValue(new File("c:/temp/person2.yaml"), - // testSystem.getPhase(0).getComponent(0)); - } catch (Exception e) { - e.printStackTrace(); - } + // ObjectMapper om = new ObjectMapper(new YAMLFactory()); + // om.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); - testSystem.display(); - // testSystem.displayPDF(); + try { + // om.writeValue(new File("c:/temp/person2.yaml"), + // testSystem.getPhase(0).getComponent(0)); + } catch (Exception e) { + e.printStackTrace(); } + + testSystem.display(); + // testSystem.displayPDF(); + } } diff --git a/src/test/java/neqsim/thermo/util/example/TestISO1982.java b/src/test/java/neqsim/thermo/util/example/TestISO1982.java index ba0e1d8c19..7bbbdfed2c 100644 --- a/src/test/java/neqsim/thermo/util/example/TestISO1982.java +++ b/src/test/java/neqsim/thermo/util/example/TestISO1982.java @@ -3,6 +3,7 @@ * * Created on 13. juni 2004, 23:49 */ + package neqsim.thermo.util.example; import org.apache.logging.log4j.LogManager; @@ -21,27 +22,27 @@ * @since 2.2.3 */ public class TestISO1982 { - static Logger logger = LogManager.getLogger(TestISO1982.class); + static Logger logger = LogManager.getLogger(TestISO1982.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - SystemInterface testSystem = new SystemSrkEos(290.15, 30.00); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + SystemInterface testSystem = new SystemSrkEos(290.15, 30.00); - testSystem.addComponent("methane", 50); - testSystem.addComponent("ethane", 50); - testSystem.addComponent("propane", 50); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); + testSystem.addComponent("methane", 50); + testSystem.addComponent("ethane", 50); + testSystem.addComponent("propane", 50); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - testOps.TPflash(); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); - logger.info("ISO calc: " + testSystem.getStandard("ISO1982").getValue("Energy", "KJ/Sm3")); - } + logger.info("ISO calc: " + testSystem.getStandard("ISO1982").getValue("Energy", "KJ/Sm3")); + } } diff --git a/src/test/java/neqsim/thermo/util/readwrite/EclipseFluidReadWriteTest.java b/src/test/java/neqsim/thermo/util/readwrite/EclipseFluidReadWriteTest.java index 24f8039ef4..4e7891c711 100644 --- a/src/test/java/neqsim/thermo/util/readwrite/EclipseFluidReadWriteTest.java +++ b/src/test/java/neqsim/thermo/util/readwrite/EclipseFluidReadWriteTest.java @@ -1,6 +1,3 @@ -/** - * - */ package neqsim.thermo.util.readwrite; import java.io.File; @@ -15,68 +12,68 @@ */ class EclipseFluidReadWriteTest { - static neqsim.thermo.system.SystemInterface testSystem = null; - - File file = new File("src/test/java/neqsim/thermo/util/readwrite"); - String fileA13 = file.getAbsolutePath() + "/A-13.E300"; - String fileA17 = file.getAbsolutePath() + "/A-17.E300"; - String fileA19 = file.getAbsolutePath() + "/A-19.E300"; - - /** - * @throws java.lang.Exception - */ - @BeforeAll - static void setUpBeforeClass() throws Exception { - - } - - /** - * Test method for - * {@link neqsim.thermo.util.readwrite.EclipseFluidReadWrite#read(java.lang.String)}. - * - * @throws IOException - */ - @Test - void testRead() throws IOException { - EclipseFluidReadWrite.pseudoName = "_A13"; - testSystem = EclipseFluidReadWrite.read(fileA13); - } - - @Test - void testReadAndAddFluids() throws IOException { - EclipseFluidReadWrite.pseudoName = "_A19"; - testSystem = EclipseFluidReadWrite.read(fileA19); - - EclipseFluidReadWrite.pseudoName = "_A17"; - neqsim.thermo.system.SystemInterface testSystem2 = EclipseFluidReadWrite.read(fileA17); - testSystem.addFluid(testSystem2); - - EclipseFluidReadWrite.pseudoName = "_A13"; - neqsim.thermo.system.SystemInterface testSystem3 = EclipseFluidReadWrite.read(fileA13); - testSystem.addFluid(testSystem3); - - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - testOps.TPflash(); - - } - - @Test - void testSetComposition() throws IOException { - EclipseFluidReadWrite.pseudoName = "_A19"; - testSystem = EclipseFluidReadWrite.read(fileA19); - - EclipseFluidReadWrite.pseudoName = "_A17"; - neqsim.thermo.system.SystemInterface testSystem2 = EclipseFluidReadWrite.read(fileA17); - testSystem.addFluid(testSystem2); - - EclipseFluidReadWrite.pseudoName = "_A13"; - neqsim.thermo.system.SystemInterface testSystem3 = EclipseFluidReadWrite.read(fileA13); - testSystem.addFluid(testSystem3); - - EclipseFluidReadWrite.pseudoName = "_A13"; - EclipseFluidReadWrite.setComposition(testSystem, fileA13); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - testOps.TPflash(); - } + static neqsim.thermo.system.SystemInterface testSystem = null; + + File file = new File("src/test/java/neqsim/thermo/util/readwrite"); + String fileA13 = file.getAbsolutePath() + "/A-13.E300"; + String fileA17 = file.getAbsolutePath() + "/A-17.E300"; + String fileA19 = file.getAbsolutePath() + "/A-19.E300"; + + /** + * @throws java.lang.Exception + */ + @BeforeAll + static void setUpBeforeClass() throws Exception { + + } + + /** + * Test method for + * {@link neqsim.thermo.util.readwrite.EclipseFluidReadWrite#read(java.lang.String)}. + * + * @throws IOException + */ + @Test + void testRead() throws IOException { + EclipseFluidReadWrite.pseudoName = "_A13"; + testSystem = EclipseFluidReadWrite.read(fileA13); + } + + @Test + void testReadAndAddFluids() throws IOException { + EclipseFluidReadWrite.pseudoName = "_A19"; + testSystem = EclipseFluidReadWrite.read(fileA19); + + EclipseFluidReadWrite.pseudoName = "_A17"; + neqsim.thermo.system.SystemInterface testSystem2 = EclipseFluidReadWrite.read(fileA17); + testSystem.addFluid(testSystem2); + + EclipseFluidReadWrite.pseudoName = "_A13"; + neqsim.thermo.system.SystemInterface testSystem3 = EclipseFluidReadWrite.read(fileA13); + testSystem.addFluid(testSystem3); + + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + + } + + @Test + void testSetComposition() throws IOException { + EclipseFluidReadWrite.pseudoName = "_A19"; + testSystem = EclipseFluidReadWrite.read(fileA19); + + EclipseFluidReadWrite.pseudoName = "_A17"; + neqsim.thermo.system.SystemInterface testSystem2 = EclipseFluidReadWrite.read(fileA17); + testSystem.addFluid(testSystem2); + + EclipseFluidReadWrite.pseudoName = "_A13"; + neqsim.thermo.system.SystemInterface testSystem3 = EclipseFluidReadWrite.read(fileA13); + testSystem.addFluid(testSystem3); + + EclipseFluidReadWrite.pseudoName = "_A13"; + EclipseFluidReadWrite.setComposition(testSystem, fileA13); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + } } diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashGERG2008Test.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashGERG2008Test.java index a5e0987e89..4b8bb5b4e9 100644 --- a/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashGERG2008Test.java +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashGERG2008Test.java @@ -1,13 +1,8 @@ -/** - * - */ package neqsim.thermodynamicOperations.flashOps; -import static org.junit.jupiter.api.Assertions.*; - +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; - import neqsim.thermodynamicOperations.ThermodynamicOperations; /** @@ -15,42 +10,43 @@ * */ class PHFlashGERG2008Test { - - static neqsim.thermo.system.SystemInterface testSystem = null; - static ThermodynamicOperations testOps = null; - - /** - * @throws java.lang.Exception - */ - @BeforeEach - void setUp() throws Exception { - testSystem = new neqsim.thermo.system.SystemPrEos(298.0, 50.0); - testSystem.addComponent("nitrogen", 0.01); - testSystem.addComponent("CO2", 0.01); - testSystem.addComponent("methane", 0.98); - testSystem.setMixingRule("classic"); - testOps = new ThermodynamicOperations(testSystem); - testOps.TPflash(); - testSystem.initProperties(); - } - /** - * Test method for {@link neqsim.thermodynamicOperations.flashOps.PHFlashGERG2008#run()}. - */ - @Test - void testRun() { - double[] gergProps = testSystem.getPhase(0).getProperties_GERG2008(); - double gergEnthalpy = gergProps[7]*testSystem.getPhase(0).getNumberOfMolesInPhase(); // J/mol K - testSystem.setPressure(10.0); - testOps.PHflashGERG2008(gergEnthalpy); - gergProps = testSystem.getPhase(0).getProperties_GERG2008(); - double gergEnthalpy2 = gergProps[7]*testSystem.getPhase(0).getNumberOfMolesInPhase(); - assertEquals(gergEnthalpy, gergEnthalpy2, Math.abs(gergEnthalpy2)/1000.0); - - testOps.PHflashGERG2008(gergEnthalpy+100.0); - gergProps = testSystem.getPhase(0).getProperties_GERG2008(); - double gergEnthalpy3 = gergProps[7]*testSystem.getPhase(0).getNumberOfMolesInPhase(); - assertEquals(gergEnthalpy3, gergEnthalpy2+100.0, Math.abs(gergEnthalpy2)/1000.0); - } + static neqsim.thermo.system.SystemInterface testSystem = null; + static ThermodynamicOperations testOps = null; + + /** + * @throws java.lang.Exception + */ + @BeforeEach + void setUp() throws Exception { + testSystem = new neqsim.thermo.system.SystemPrEos(298.0, 50.0); + testSystem.addComponent("nitrogen", 0.01); + testSystem.addComponent("CO2", 0.01); + testSystem.addComponent("methane", 0.98); + testSystem.setMixingRule("classic"); + testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + testSystem.initProperties(); + } + + /** + * Test method for {@link neqsim.thermodynamicOperations.flashOps.PHFlashGERG2008#run()}. + */ + @Test + void testRun() { + double[] gergProps = testSystem.getPhase(0).getProperties_GERG2008(); + double gergEnthalpy = gergProps[7] * testSystem.getPhase(0).getNumberOfMolesInPhase(); // J/mol + // K + testSystem.setPressure(10.0); + testOps.PHflashGERG2008(gergEnthalpy); + gergProps = testSystem.getPhase(0).getProperties_GERG2008(); + double gergEnthalpy2 = gergProps[7] * testSystem.getPhase(0).getNumberOfMolesInPhase(); + assertEquals(gergEnthalpy, gergEnthalpy2, Math.abs(gergEnthalpy2) / 1000.0); + + testOps.PHflashGERG2008(gergEnthalpy + 100.0); + gergProps = testSystem.getPhase(0).getProperties_GERG2008(); + double gergEnthalpy3 = gergProps[7] * testSystem.getPhase(0).getNumberOfMolesInPhase(); + assertEquals(gergEnthalpy3, gergEnthalpy2 + 100.0, Math.abs(gergEnthalpy2) / 1000.0); + } } diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashTest.java index ffb12eedcb..32ff134b33 100644 --- a/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashTest.java +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashTest.java @@ -1,13 +1,8 @@ -/** - * - */ package neqsim.thermodynamicOperations.flashOps; -import static org.junit.jupiter.api.Assertions.*; - +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; - import neqsim.thermodynamicOperations.ThermodynamicOperations; /** @@ -15,40 +10,40 @@ * */ class PHFlashTest { - - static neqsim.thermo.system.SystemInterface testSystem = null; - static ThermodynamicOperations testOps = null; - - /** - * @throws java.lang.Exception - */ - @BeforeEach - void setUp() throws Exception { - testSystem = new neqsim.thermo.system.SystemPrEos(243.15, 300.0); - testSystem.addComponent("methane", 90.0); - testSystem.addComponent("ethane", 0.0); - testSystem.addComponent("propane", 0.0); - testSystem.addComponent("i-butane", 0.0); - testSystem.addComponent("n-butane", 0.0); - testSystem.addComponent("i-pentane", 0.0); - testSystem.addComponent("n-pentane", 0.0); - testSystem.addComponent("n-hexane", 0.0); - testSystem.addComponent("nitrogen", 10.0); - testSystem.setMixingRule("classic"); - } - /** - * Test method for {@link neqsim.thermodynamicOperations.flashOps.PHFlash#run()}. - */ - @Test - void testRun() { - testOps = new ThermodynamicOperations(testSystem); - testOps.TPflash(); - testSystem.initProperties(); - double enthalpy = testSystem.getEnthalpy(); - testSystem.setPressure(4.0); - testOps.PHflash(enthalpy); - assertEquals(enthalpy, testSystem.getEnthalpy(), 1e-2); - } + static neqsim.thermo.system.SystemInterface testSystem = null; + static ThermodynamicOperations testOps = null; + + /** + * @throws java.lang.Exception + */ + @BeforeEach + void setUp() throws Exception { + testSystem = new neqsim.thermo.system.SystemPrEos(243.15, 300.0); + testSystem.addComponent("methane", 90.0); + testSystem.addComponent("ethane", 0.0); + testSystem.addComponent("propane", 0.0); + testSystem.addComponent("i-butane", 0.0); + testSystem.addComponent("n-butane", 0.0); + testSystem.addComponent("i-pentane", 0.0); + testSystem.addComponent("n-pentane", 0.0); + testSystem.addComponent("n-hexane", 0.0); + testSystem.addComponent("nitrogen", 10.0); + testSystem.setMixingRule("classic"); + } + + /** + * Test method for {@link neqsim.thermodynamicOperations.flashOps.PHFlash#run()}. + */ + @Test + void testRun() { + testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + testSystem.initProperties(); + double enthalpy = testSystem.getEnthalpy(); + testSystem.setPressure(4.0); + testOps.PHflash(enthalpy); + assertEquals(enthalpy, testSystem.getEnthalpy(), 1e-2); + } } diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/PSFlashGERG2008Test.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/PSFlashGERG2008Test.java index 1794544195..63a157719e 100644 --- a/src/test/java/neqsim/thermodynamicOperations/flashOps/PSFlashGERG2008Test.java +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/PSFlashGERG2008Test.java @@ -1,13 +1,8 @@ -/** - * - */ package neqsim.thermodynamicOperations.flashOps; -import static org.junit.jupiter.api.Assertions.*; - +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; - import neqsim.thermodynamicOperations.ThermodynamicOperations; /** @@ -15,37 +10,37 @@ * */ class PSFlashGERG2008Test { - - static neqsim.thermo.system.SystemInterface testSystem = null; - static ThermodynamicOperations testOps = null; - - /** - * @throws java.lang.Exception - */ - @BeforeEach - void setUp() throws Exception { - testSystem = new neqsim.thermo.system.SystemPrEos(298.0, 10.0); - testSystem.addComponent("nitrogen", 0.01); - testSystem.addComponent("CO2", 0.01); - testSystem.addComponent("methane", 0.98); - testSystem.setMixingRule("classic"); - testOps = new ThermodynamicOperations(testSystem); - testOps.TPflash(); - testSystem.initProperties(); - } - /** - * Test method for {@link neqsim.thermodynamicOperations.flashOps.PSFlashGERG2008#run()}. - */ - @Test - void testRun() { - double[] gergProps = testSystem.getPhase(0).getProperties_GERG2008(); - double gergEntropy = gergProps[8]*testSystem.getPhase(0).getNumberOfMolesInPhase(); // J/mol K - testSystem.setPressure(20.0); - testOps.PSflashGERG2008(gergEntropy); - gergProps = testSystem.getPhase(0).getProperties_GERG2008(); - double gergEntropy2 = gergProps[8]*testSystem.getPhase(0).getNumberOfMolesInPhase(); - assertEquals(gergEntropy, gergEntropy2, Math.abs(gergEntropy2)/1000.0); - } + static neqsim.thermo.system.SystemInterface testSystem = null; + static ThermodynamicOperations testOps = null; + + /** + * @throws java.lang.Exception + */ + @BeforeEach + void setUp() throws Exception { + testSystem = new neqsim.thermo.system.SystemPrEos(298.0, 10.0); + testSystem.addComponent("nitrogen", 0.01); + testSystem.addComponent("CO2", 0.01); + testSystem.addComponent("methane", 0.98); + testSystem.setMixingRule("classic"); + testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + testSystem.initProperties(); + } + + /** + * Test method for {@link neqsim.thermodynamicOperations.flashOps.PSFlashGERG2008#run()}. + */ + @Test + void testRun() { + double[] gergProps = testSystem.getPhase(0).getProperties_GERG2008(); + double gergEntropy = gergProps[8] * testSystem.getPhase(0).getNumberOfMolesInPhase(); // J/mol K + testSystem.setPressure(20.0); + testOps.PSflashGERG2008(gergEntropy); + gergProps = testSystem.getPhase(0).getProperties_GERG2008(); + double gergEntropy2 = gergProps[8] * testSystem.getPhase(0).getNumberOfMolesInPhase(); + assertEquals(gergEntropy, gergEntropy2, Math.abs(gergEntropy2) / 1000.0); + } } diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTest.java index 6ce26e05b3..7e09138d91 100644 --- a/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTest.java +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTest.java @@ -1,6 +1,3 @@ -/** - * - */ package neqsim.thermodynamicOperations.flashOps; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTestWellFluid.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTestWellFluid.java index 3af1b0eeb1..1af66488d2 100644 --- a/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTestWellFluid.java +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTestWellFluid.java @@ -1,6 +1,3 @@ -/** - * - */ package neqsim.thermodynamicOperations.flashOps; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/TVFlashTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/TVFlashTest.java index a396e02a5d..d1d7c5c43c 100644 --- a/src/test/java/neqsim/thermodynamicOperations/flashOps/TVFlashTest.java +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/TVFlashTest.java @@ -1,6 +1,3 @@ -/** - * - */ package neqsim.thermodynamicOperations.flashOps; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -35,7 +32,7 @@ void setUp() throws Exception { testSystem.setTotalFlowRate(1.0, "kg/sec"); testOps.TPflash(); testSystem.initProperties(); - + testSystem2 = new neqsim.thermo.system.SystemUMRPRUMCEos(293.15, 0.1); testSystem2.addComponent("methane", 8.5E-1); testSystem2.addComponent("ethane", 1.5E-1); @@ -49,24 +46,23 @@ void setUp() throws Exception { testOps.TPflash(); testSystem2.initProperties(); } - + @Test void testTVflash() { double total_rig_volume = 0.998; - - for(int i=0;i<50;i++) { + + for (int i = 0; i < 50; i++) { testSystem.addFluid(testSystem2); ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); try { - testOps.TVflash(total_rig_volume, "m3"); - } - catch(Exception e) { + testOps.TVflash(total_rig_volume, "m3"); + } catch (Exception e) { System.out.println("error iterations " + i); e.printStackTrace(); } - } + } assertEquals(235263.80103781424, testSystem.getEnthalpy(), 1e-2); } - - } + +} diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/WaxFlashTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/WaxFlashTest.java index f9b22040c6..eb9cc2a1d3 100644 --- a/src/test/java/neqsim/thermodynamicOperations/flashOps/WaxFlashTest.java +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/WaxFlashTest.java @@ -1,14 +1,8 @@ -/** - * - */ package neqsim.thermodynamicOperations.flashOps; -import static org.junit.jupiter.api.Assertions.*; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; import neqsim.thermodynamicOperations.ThermodynamicOperations; import neqsim.util.database.NeqSimDataBase; @@ -27,7 +21,8 @@ class WaxFlashTest { */ @BeforeEach void setUp() throws Exception { - NeqSimDataBase.setConnectionString("jdbc:derby:C:/Users/esol/OneDrive - Equinor/programming/neqsim/src/main/resources/data/neqsimtestdatabase"); + NeqSimDataBase.setConnectionString( + "jdbc:derby:C:/Users/esol/OneDrive - Equinor/programming/neqsim/src/main/resources/data/neqsimtestdatabase"); NeqSimDataBase.setCreateTemporaryTables(true); testSystem = new SystemSrkEos(273.0 + 30, 50.0); @@ -51,7 +46,7 @@ void setUp() throws Exception { testSystem.setMultiphaseWaxCheck(true); NeqSimDataBase.setConnectionString("jdbc:derby:classpath:data/neqsimthermodatabase"); NeqSimDataBase.setCreateTemporaryTables(false); - //testSystem.display(); + // testSystem.display(); } /** @@ -62,10 +57,10 @@ void setUp() throws Exception { void testRun() { testOps = new ThermodynamicOperations(testSystem); try { - testOps.calcWAT(); - testOps.TPflash(); + testOps.calcWAT(); + testOps.TPflash(); } catch (Exception e) { - e.printStackTrace(); + e.printStackTrace(); } double waxVolumeFrac = 0; if (testSystem.hasPhaseType("wax")) { From da5ce073d1f53efcdba6559c63f2a1764a0c293c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?= <34712686+asmfstatoil@users.noreply.github.com> Date: Fri, 22 Jul 2022 18:24:20 +0200 Subject: [PATCH 8/9] checkstyle fixes (#492) --- .../ChemicalReactionList.java | 8 +- .../OnePhaseFixedStaggeredGrid.java | 104 +++++---- .../diffusivity/Diffusivity.java | 220 +++++++++--------- .../PedersenPlusModelSolver.java | 2 +- .../util/example/shtokman_MEG.java | 86 +++---- 5 files changed, 215 insertions(+), 205 deletions(-) diff --git a/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReactionList.java b/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReactionList.java index e78663fba8..877592b921 100644 --- a/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReactionList.java +++ b/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReactionList.java @@ -52,7 +52,9 @@ public void readReactions(SystemInterface system) { chemicalReactionList.clear(); ArrayList names = new ArrayList(); ArrayList stocCoef = new ArrayList(); - double r = 0, refT = 0, actH; + double r = 0; + double refT = 0; + double actH; double[] K = new double[4]; boolean useReaction = false; neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); @@ -336,9 +338,9 @@ public double[][] getReactionMatrix() { public double[] calcReferencePotentials() { Matrix reacMatr = new Matrix(reacGMatrix); Matrix Amatrix = reacMatr.copy().getMatrix(0, chemicalReactionList.size() - 1, 0, - chemicalReactionList.size() - 1);// new Matrix(reacGMatrix); + chemicalReactionList.size() - 1); // new Matrix(reacGMatrix); Matrix Bmatrix = reacMatr.copy().getMatrix(0, chemicalReactionList.size() - 1, - reacGMatrix[0].length - 1, reacGMatrix[0].length - 1);// new Matrix(reacGMatrix); + reacGMatrix[0].length - 1, reacGMatrix[0].length - 1); // new Matrix(reacGMatrix); if (Amatrix.rank() < chemicalReactionList.size()) { System.out.println("rank of A matrix too low !!" + Amatrix.rank()); diff --git a/src/main/java/neqsim/fluidMechanics/flowSolver/onePhaseFlowSolver/onePhasePipeFlowSolver/OnePhaseFixedStaggeredGrid.java b/src/main/java/neqsim/fluidMechanics/flowSolver/onePhaseFlowSolver/onePhasePipeFlowSolver/OnePhaseFixedStaggeredGrid.java index 2e9e36644c..b831a380ba 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSolver/onePhaseFlowSolver/onePhasePipeFlowSolver/OnePhaseFixedStaggeredGrid.java +++ b/src/main/java/neqsim/fluidMechanics/flowSolver/onePhaseFlowSolver/onePhasePipeFlowSolver/OnePhaseFixedStaggeredGrid.java @@ -25,14 +25,14 @@ public class OnePhaseFixedStaggeredGrid extends OnePhasePipeFlowSolver int iter = 0; Matrix[] diff4Matrix; double xNew[][]; - protected double oldMass[]; - protected double oldComp[]; - protected double oldDensity[]; - protected double oldVelocity[]; + protected double[] oldMass; + protected double[] oldComp; + protected double[] oldDensity; + protected double[] oldVelocity; protected double oldComposition[][]; - protected double oldInternalEnergy[]; - protected double oldImpuls[]; - protected double oldEnergy[]; + protected double[] oldInternalEnergy; + protected double[] oldImpuls; + protected double[] oldEnergy; /** *

@@ -91,8 +91,10 @@ public OnePhaseFixedStaggeredGrid clone() { *

*/ public void initProfiles() { - double err = 0, oldPres = 0, dpdx = 0; + double err = 0; + double oldPres = 0; + double dpdx = 0; do { // pipe.getNode(0).setVelocityIn(pipe.getNode(0).getVelocity()); err = 0; @@ -102,21 +104,21 @@ public void initProfiles() { for (int i = 0; i < numberOfNodes - 1; i++) { // setting temperatures pipe.getNode(i).init(); - pipe.getNode(i + 1).getBulkSystem().setTemperature((4.0 - * pipe.getNode(i).calcTotalHeatTransferCoefficient(0) - * (pipe.getNode(i).getGeometry().getSurroundingEnvironment().getTemperature() - - pipe.getNode(i).getBulkSystem().getPhases()[0].getTemperature()) - / (pipe.getNode(i).getBulkSystem().getPhases()[0].getCp() - / pipe.getNode(i).getBulkSystem().getPhases()[0].getNumberOfMolesInPhase() - / pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass() - * pipe.getNode(i + 1).getVelocity() - * pipe.getNode(i + 1).getGeometry().getDiameter() - * pipe.getNode(i + 1).getBulkSystem().getPhases()[0].getDensity()) - + pipe.getNode(i + 1).getBulkSystem().getPhases()[0].getJouleThomsonCoefficient() - * dpdx) - * (pipe.getNode(i + 1).getGeometry().getNodeLength() - + pipe.getNode(i).getGeometry().getNodeLength()) - * 0.5 + pipe.getNode(i).getBulkSystem().getTemperature()); + pipe.getNode(i + 1).getBulkSystem() + .setTemperature((4.0 * pipe.getNode(i).calcTotalHeatTransferCoefficient(0) + * (pipe.getNode(i).getGeometry().getSurroundingEnvironment().getTemperature() + - pipe.getNode(i).getBulkSystem().getPhases()[0].getTemperature()) + / (pipe.getNode(i).getBulkSystem().getPhases()[0].getCp() + / pipe.getNode(i).getBulkSystem().getPhases()[0].getNumberOfMolesInPhase() + / pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass() + * pipe.getNode(i + 1).getVelocity() + * pipe.getNode(i + 1).getGeometry().getDiameter() + * pipe.getNode(i + 1).getBulkSystem().getPhases()[0].getDensity()) + + pipe.getNode(i + 1).getBulkSystem().getPhases()[0].getJouleThomsonCoefficient() + * dpdx) + * (pipe.getNode(i + 1).getGeometry().getNodeLength() + + pipe.getNode(i).getGeometry().getNodeLength()) + * 0.5 + pipe.getNode(i).getBulkSystem().getTemperature()); if (pipe.getNode(i + 1).getBulkSystem().getTemperature() < 10.5) { pipe.getNode(i + 1).getBulkSystem().setTemperature(10.5); } @@ -128,16 +130,17 @@ public void initProfiles() { // System.out // .println("presbef : " + pipe.getNode(i + 1).getBulkSystem().getPressure()); oldPres = pipe.getNode(i + 1).getBulkSystem().getPressure(); - pipe.getNode(i + 1).getBulkSystem().setPressure(-pipe.getNode(i).getWallFrictionFactor() - * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() - * pipe.getNode(i).getVelocity() * pipe.getNode(i).getVelocity() - / pipe.getNode(i).getGeometry().getDiameter() / 2.0 - * (pipe.getNode(i).getGeometry().getNodeLength()) / 1e5 - - gravity * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() - * (pipe.getNode(i + 1).getVerticalPositionOfNode() - - pipe.getNode(i).getVerticalPositionOfNode()) - / 1e5 - + pipe.getNode(i).getBulkSystem().getPressure()); + pipe.getNode(i + 1).getBulkSystem() + .setPressure(-pipe.getNode(i).getWallFrictionFactor() + * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() + * pipe.getNode(i).getVelocity() * pipe.getNode(i).getVelocity() + / pipe.getNode(i).getGeometry().getDiameter() / 2.0 + * (pipe.getNode(i).getGeometry().getNodeLength()) / 1e5 + - gravity * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() + * (pipe.getNode(i + 1).getVerticalPositionOfNode() + - pipe.getNode(i).getVerticalPositionOfNode()) + / 1e5 + + pipe.getNode(i).getBulkSystem().getPressure()); // if(pipe.getNode(i+1).getBulkSystem().getPressure()<10.5) // pipe.getNode(i+1).getBulkSystem().setPressure(1.0); err += (oldPres - pipe.getNode(i + 1).getBulkSystem().getPressure()); @@ -280,9 +283,9 @@ public void initComposition(int iter) { .getNumberOfComponents(); p++) { pipe.getNode(j).getBulkSystem().getPhases()[0].getComponents()[p].setx( sol4Matrix[p].get(j, 0) * pipe.getNode(j).getBulkSystem().getPhases()[0].getMolarMass() - / pipe.getNode(j).getBulkSystem().getPhases()[0].getComponents()[p].getMolarMass());// pipe.getNode(j).getBulkSystem().getPhases()[0].getComponents()[p].getx() - // + - // 0.5*diff4Matrix[p].get(j,0)); + / pipe.getNode(j).getBulkSystem().getPhases()[0].getComponents()[p].getMolarMass()); // pipe.getNode(j).getBulkSystem().getPhases()[0].getComponents()[p].getx() + // + + // 0.5*diff4Matrix[p].get(j,0)); } pipe.getNode(j).getBulkSystem().getPhases()[0].normalize(); @@ -373,13 +376,15 @@ public void setMassConservationMatrixTDMA() { *

*/ public void setImpulsMatrixTDMA() { - double SU = 0.0, SP = 0.0; - double Fw = 0.0, Fe = 0.0; + double SU = 0.0; + double SP = 0.0; + double Fw = 0.0; // pipe.getNode(0).initFlowCalc(); // pipe.getNode(0).init(); // pipe.getNode(0).setVelocityIn(pipe.getNode(0).getVelocity()); + double Fe = 0.0; a[0] = 0; b[0] = 1.0; c[0] = 0; @@ -429,7 +434,7 @@ public void setImpulsMatrixTDMA() { oldImpuls[i] = 0.0; } a[i] = Math.max(Fw, 0); - c[i] = Math.max(-Fe, 0);// - Fe/2.0; + c[i] = Math.max(-Fe, 0); // - Fe/2.0; b[i] = a[i] + c[i] + (Fe - Fw) - SP + oldImpuls[i]; // System.out.println("Fe-Fw: " +(Fe - Fw) + " Fe: " + Fe); @@ -550,13 +555,13 @@ public void setEnergyMatrixTDMA() { double fw = pipe.getNode(i - 1).getGeometry().getNodeLength() / (pipe.getNode(i).getGeometry().getNodeLength() + pipe.getNode(i - 1).getGeometry().getNodeLength()); - double Ae = pipe.getNode(i).getGeometry().getArea();// 1.0/((1.0-fe)/pipe.getNode(i).getGeometry().getArea() - // + - // fe/pipe.getNode(i+1).getGeometry().getArea()); + double Ae = pipe.getNode(i).getGeometry().getArea(); // 1.0/((1.0-fe)/pipe.getNode(i).getGeometry().getArea() + // + + // fe/pipe.getNode(i+1).getGeometry().getArea()); - double Aw = pipe.getNode(i - 1).getGeometry().getArea();// 1.0/((1.0-fw)/pipe.getNode(i).getGeometry().getArea() - // + - // fw/pipe.getNode(i-1).getGeometry().getArea()); + double Aw = pipe.getNode(i - 1).getGeometry().getArea(); // 1.0/((1.0-fw)/pipe.getNode(i).getGeometry().getArea() + // + + // fw/pipe.getNode(i-1).getGeometry().getArea()); double vertposchange = (1 - fw) * (pipe.getNode(i).getVerticalPositionOfNode() - pipe.getNode(i - 1).getVerticalPositionOfNode()); @@ -570,7 +575,7 @@ public void setEnergyMatrixTDMA() { - pipe.getNode(i).getBulkSystem().getTemperature()) / (pipe.getNode(i).getGeometry().getDiameter()) * pipe.getNode(i).getGeometry().getNodeLength(); - double SP = 0;// -pipe.getNode(i).getGeometry().getArea()*4.0*12.0/(pipe.getNode(i).getGeometry().getDiameter())*pipe.getNode(i).getGeometry().getNodeLength(); + double SP = 0; // -pipe.getNode(i).getGeometry().getArea()*4.0*12.0/(pipe.getNode(i).getGeometry().getDiameter())*pipe.getNode(i).getGeometry().getNodeLength(); double Fw = Aw * pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getDensity() * pipe.getNode(i).getVelocityIn().doubleValue(); @@ -688,8 +693,9 @@ public void initFinalResults() { /** {@inheritDoc} */ @Override public void solveTDMA() { - double d[]; - int iter = 0, iterTop = 0; + double[] d; + int iter = 0; + int iterTop = 0; double maxDiff = 1.0; double diff = 0; xNew = new double[pipe.getNode(0).getBulkSystem().getPhases()[0] @@ -793,7 +799,7 @@ public void solveTDMA() { } // System.out.println("maxDiff " + maxDiff); - } while (Math.abs(maxDiff) > 1e-10 && iterTop < 100);// diffMatrix.norm2()/sol2Matrix.norm2())>0.1); + } while (Math.abs(maxDiff) > 1e-10 && iterTop < 100); // diffMatrix.norm2()/sol2Matrix.norm2())>0.1); initFinalResults(); } diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/diffusivity/Diffusivity.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/diffusivity/Diffusivity.java index 51397de95e..263203869d 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/diffusivity/Diffusivity.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/diffusivity/Diffusivity.java @@ -13,121 +13,121 @@ * @version $Id: $Id */ public class Diffusivity extends CommonPhysicalPropertyMethod implements - neqsim.physicalProperties.physicalPropertyMethods.methodInterface.DiffusivityInterface { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(Diffusivity.class); - - double[][] binaryDiffusionCoefficients, binaryLennardJonesOmega; - double[] effectiveDiffusionCoefficient; - - /** - *

- * Constructor for Diffusivity. - *

- */ - public Diffusivity() {} - - /** - *

- * Constructor for Diffusivity. - *

- * - * @param phase a - * {@link neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface} - * object - */ - public Diffusivity( - neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface phase) { - super(phase); - binaryDiffusionCoefficients = new double[phase.getPhase().getNumberOfComponents()][phase - .getPhase().getNumberOfComponents()]; - binaryLennardJonesOmega = new double[phase.getPhase().getNumberOfComponents()][phase - .getPhase().getNumberOfComponents()]; - effectiveDiffusionCoefficient = new double[phase.getPhase().getNumberOfComponents()]; - } - - /** {@inheritDoc} */ - @Override - public Diffusivity clone() { - Diffusivity properties = null; - - try { - properties = (Diffusivity) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } - - return properties; + neqsim.physicalProperties.physicalPropertyMethods.methodInterface.DiffusivityInterface { + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(Diffusivity.class); + + double[][] binaryDiffusionCoefficients; + double[][] binaryLennardJonesOmega; + double[] effectiveDiffusionCoefficient; + + /** + *

+ * Constructor for Diffusivity. + *

+ */ + public Diffusivity() {} + + /** + *

+ * Constructor for Diffusivity. + *

+ * + * @param phase a + * {@link neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface} + * object + */ + public Diffusivity( + neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface phase) { + super(phase); + binaryDiffusionCoefficients = new double[phase.getPhase().getNumberOfComponents()][phase + .getPhase().getNumberOfComponents()]; + binaryLennardJonesOmega = new double[phase.getPhase().getNumberOfComponents()][phase.getPhase() + .getNumberOfComponents()]; + effectiveDiffusionCoefficient = new double[phase.getPhase().getNumberOfComponents()]; + } + + /** {@inheritDoc} */ + @Override + public Diffusivity clone() { + Diffusivity properties = null; + + try { + properties = (Diffusivity) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); } - /** {@inheritDoc} */ - @Override - public double calcBinaryDiffusionCoefficient(int i, int j, int method) { - return 1.0e-6; + return properties; + } + + /** {@inheritDoc} */ + @Override + public double calcBinaryDiffusionCoefficient(int i, int j, int method) { + return 1.0e-6; + } + + /** {@inheritDoc} */ + @Override + public double[][] calcDiffusionCoefficients(int binaryDiffusionCoefficientMethod, + int multicomponentDiffusionMethod) { + for (int i = 0; i < phase.getPhase().getNumberOfComponents(); i++) { + for (int j = 0; j < phase.getPhase().getNumberOfComponents(); j++) { + binaryDiffusionCoefficients[i][j] = + calcBinaryDiffusionCoefficient(i, j, binaryDiffusionCoefficientMethod); + // System.out.println("diff gas " + binaryDiffusionCoefficients[i][j]); + } } - /** {@inheritDoc} */ - @Override - public double[][] calcDiffusionCoefficients(int binaryDiffusionCoefficientMethod, - int multicomponentDiffusionMethod) { - for (int i = 0; i < phase.getPhase().getNumberOfComponents(); i++) { - for (int j = 0; j < phase.getPhase().getNumberOfComponents(); j++) { - binaryDiffusionCoefficients[i][j] = - calcBinaryDiffusionCoefficient(i, j, binaryDiffusionCoefficientMethod); - // System.out.println("diff gas " + binaryDiffusionCoefficients[i][j]); - } - } - - if (multicomponentDiffusionMethod == 0) { - // ok use full matrix - } else if (multicomponentDiffusionMethod == 0) { - // calcEffectiveDiffusionCoefficients(); - } - return binaryDiffusionCoefficients; + if (multicomponentDiffusionMethod == 0) { + // ok use full matrix + } else if (multicomponentDiffusionMethod == 0) { + // calcEffectiveDiffusionCoefficients(); } - - /** {@inheritDoc} */ - @Override - public void calcEffectiveDiffusionCoefficients() { - double sum = 0; - - for (int i = 0; i < phase.getPhase().getNumberOfComponents(); i++) { - sum = 0; - for (int j = 0; j < phase.getPhase().getNumberOfComponents(); j++) { - if (i == j) { - } else { - sum += phase.getPhase().getComponents()[j].getx() - / binaryDiffusionCoefficients[i][j]; - } - } - effectiveDiffusionCoefficient[i] = - (1.0 - phase.getPhase().getComponents()[i].getx()) / sum; + return binaryDiffusionCoefficients; + } + + /** {@inheritDoc} */ + @Override + public void calcEffectiveDiffusionCoefficients() { + double sum = 0; + + for (int i = 0; i < phase.getPhase().getNumberOfComponents(); i++) { + sum = 0; + for (int j = 0; j < phase.getPhase().getNumberOfComponents(); j++) { + if (i == j) { + continue; + } else { + sum += phase.getPhase().getComponents()[j].getx() / binaryDiffusionCoefficients[i][j]; } + } + effectiveDiffusionCoefficient[i] = (1.0 - phase.getPhase().getComponents()[i].getx()) / sum; } - - /** {@inheritDoc} */ - @Override - public double getFickBinaryDiffusionCoefficient(int i, int j) { - return binaryDiffusionCoefficients[i][j]; - } - - /** {@inheritDoc} */ - @Override - public double getEffectiveDiffusionCoefficient(int i) { - return effectiveDiffusionCoefficient[i]; - } - - /** {@inheritDoc} */ - @Override - public double getMaxwellStefanBinaryDiffusionCoefficient(int i, int j) { - /* - * double temp = (i==j)? 1.0: 0.0; double nonIdealCorrection = temp + - * gasPhase.getPhase().getComponents()[i].getx() * - * gasPhase.getPhase().getComponents()[i].getdfugdn(j) * - * gasPhase.getPhase().getNumberOfMolesInPhase(); if (Double.isNaN(nonIdealCorrection)) - * nonIdealCorrection=1.0; return binaryDiffusionCoefficients[i][j]/nonIdealCorrection; // - * shuld be divided by non ideality factor - */ - return binaryDiffusionCoefficients[i][j]; - } + } + + /** {@inheritDoc} */ + @Override + public double getFickBinaryDiffusionCoefficient(int i, int j) { + return binaryDiffusionCoefficients[i][j]; + } + + /** {@inheritDoc} */ + @Override + public double getEffectiveDiffusionCoefficient(int i) { + return effectiveDiffusionCoefficient[i]; + } + + /** {@inheritDoc} */ + @Override + public double getMaxwellStefanBinaryDiffusionCoefficient(int i, int j) { + /* + * double temp = (i==j)? 1.0: 0.0; double nonIdealCorrection = temp + + * gasPhase.getPhase().getComponents()[i].getx() * + * gasPhase.getPhase().getComponents()[i].getdfugdn(j) * + * gasPhase.getPhase().getNumberOfMolesInPhase(); if (Double.isNaN(nonIdealCorrection)) + * nonIdealCorrection=1.0; return binaryDiffusionCoefficients[i][j]/nonIdealCorrection; // shuld + * be divided by non ideality factor + */ + return binaryDiffusionCoefficients[i][j]; + } } diff --git a/src/main/java/neqsim/thermo/characterization/PedersenPlusModelSolver.java b/src/main/java/neqsim/thermo/characterization/PedersenPlusModelSolver.java index 7243716f9e..2b7755a84d 100644 --- a/src/main/java/neqsim/thermo/characterization/PedersenPlusModelSolver.java +++ b/src/main/java/neqsim/thermo/characterization/PedersenPlusModelSolver.java @@ -135,7 +135,7 @@ public void setJacAB() { */ public void setfvecCD() { double densTBO = - characterizeClass.PVTsimDensities[characterizeClass.getFirstPlusFractionNumber() - 6];// 0.71;//characterizeClass.getDensLastTBP(); + characterizeClass.PVTsimDensities[characterizeClass.getFirstPlusFractionNumber() - 6]; // 0.71;//characterizeClass.getDensLastTBP(); fvecCD.set(0, 0, (characterizeClass.getCoef(2) + characterizeClass.getCoef(3) * Math.log(characterizeClass.getFirstPlusFractionNumber() - 1)) - densTBO); double temp = 0.0, temp2 = 0; diff --git a/src/test/java/neqsim/processSimulation/util/example/shtokman_MEG.java b/src/test/java/neqsim/processSimulation/util/example/shtokman_MEG.java index 8bf0246bc1..66dea4bbaf 100644 --- a/src/test/java/neqsim/processSimulation/util/example/shtokman_MEG.java +++ b/src/test/java/neqsim/processSimulation/util/example/shtokman_MEG.java @@ -6,58 +6,60 @@ import neqsim.thermodynamicOperations.ThermodynamicOperations; /** - *

shtokman_MEG class.

+ *

+ * shtokman_MEG class. + *

* * @author asmund * @version $Id: $Id * @since 2.2.3 */ public class shtokman_MEG { - /** - * This method is just meant to test the thermo package. - * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkCPAstatoil((273.15 + 42.0), 130.00); - testSystem.addComponent("methane", 1.0); - // testSystem.addComponent("ethane", 10.039); - // testSystem.addComponent("propane", 5.858); - testSystem.addComponent("water", 0.7); - testSystem.addComponent("MEG", 0.3); - testSystem.createDatabase(true); - testSystem.setMixingRule(9); + /** + * This method is just meant to test the thermo package. + * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkCPAstatoil((273.15 + 42.0), 130.00); + testSystem.addComponent("methane", 1.0); + // testSystem.addComponent("ethane", 10.039); + // testSystem.addComponent("propane", 5.858); + testSystem.addComponent("water", 0.7); + testSystem.addComponent("MEG", 0.3); + testSystem.createDatabase(true); + testSystem.setMixingRule(9); - Stream stream_1 = new Stream("Stream1", testSystem); + Stream stream_1 = new Stream("Stream1", testSystem); - Separator separator = new Separator("Separator 1", stream_1); - StreamInterface stream_2 = separator.getGasOutStream(); + Separator separator = new Separator("Separator 1", stream_1); + StreamInterface stream_2 = separator.getGasOutStream(); - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(stream_1); - try { - operations.add(separator); - } finally { - } - operations.add(stream_2); + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + try { + operations.add(separator); + } finally { + } + operations.add(stream_2); - operations.run(); + operations.run(); - stream_2.getThermoSystem().setPressure(130.0); - stream_2.getThermoSystem().setTemperature(273.15 + 39.0); - stream_2.getThermoSystem().init(0); - ThermodynamicOperations ops = new ThermodynamicOperations(stream_2.getThermoSystem()); - try { - ops.TPflash(); - // stream_2.getThermoSystem().display(); - // stream_2.getThermoSystem().setTemperature(250.0); - // ops.dewPointTemperatureFlash(); - } catch (Exception ex) { - ex.printStackTrace(); - } - System.out.println("temp " + stream_2.getThermoSystem().getTemperature()); - operations.displayResult(); + stream_2.getThermoSystem().setPressure(130.0); + stream_2.getThermoSystem().setTemperature(273.15 + 39.0); + stream_2.getThermoSystem().init(0); + ThermodynamicOperations ops = new ThermodynamicOperations(stream_2.getThermoSystem()); + try { + ops.TPflash(); + // stream_2.getThermoSystem().display(); + // stream_2.getThermoSystem().setTemperature(250.0); + // ops.dewPointTemperatureFlash(); + } catch (Exception ex) { + ex.printStackTrace(); } + System.out.println("temp " + stream_2.getThermoSystem().getTemperature()); + operations.displayResult(); + } } From b9d5f22d086f7be1f657c2a259d06f05dbba129e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?= <34712686+asmfstatoil@users.noreply.github.com> Date: Sat, 23 Jul 2022 00:17:23 +0200 Subject: [PATCH 9/9] Formatter (#493) * formatting * autofix --- .../nonLinearSolver/sysNewtonRhapson.java | 878 +-- .../simulation/BasePVTsimulation.java | 320 +- .../simulation/ConstantMassExpansion.java | 680 +- .../simulation/ConstantVolumeDepletion.java | 570 +- .../PVTsimulation/simulation/DensitySim.java | 2 +- .../simulation/SaturationPressure.java | 2 +- .../simulation/SaturationTemperature.java | 182 +- .../simulation/ViscositySim.java | 2 +- .../simulation/ViscosityWaxOilSim.java | 434 +- .../simulation/WaxFractionSim.java | 390 +- .../ChemicalReactionOperations.java | 2 +- .../chemicalEquilibriaum/ChemEq.java | 719 +- .../ChemicalEquilibrium.java | 987 +-- .../LinearProgrammingChemicalEquilibrium.java | 16 +- .../dataPresentation/JFreeChart/graph2b.java | 11 +- .../fluidMechanics/flowNode/FlowNode.java | 23 +- .../FluidBoundarySolver.java | 29 +- .../NonEquilibriumFluidBoundary.java | 1168 ++-- .../ReactiveFluidBoundary.java | 1041 ++- .../multiPhaseNode/MultiPhaseFlowNode.java | 646 +- .../twoPhaseNode/TwoPhaseFlowNode.java | 731 +- .../TwoPhasePackedBedFlowNode.java | 420 +- .../stirredCellSolver/StirredCellSolver.java | 699 +- .../TwoPhaseFixedStaggeredGridSolver.java | 2190 +++--- .../shipSystem/LNGship.java | 16 +- .../TwoPhasePipeFlowSystem.java | 6 +- .../TwoPhaseReactorFlowSystem.java | 2 +- .../PotentialTheoryAdsorption.java | 336 +- .../GTSurfaceTensionSimple.java | 784 ++- .../surfaceTension/LGTSurfaceTension.java | 454 +- .../PFCTConductivityMethodMod86.java | 62 +- .../viscosity/PFCTViscosityMethod.java | 318 +- .../PFCTViscosityMethodHeavyOil.java | 419 +- .../viscosity/PFCTViscosityMethodMod86.java | 358 +- .../viscosity/Viscosity.java | 2 +- .../conductivity/Conductivity.java | 4 +- .../viscosity/AmineViscosity.java | 2 +- .../viscosity/Viscosity.java | 276 +- .../diffusivity/DiffusivityFunction.java | 55 +- .../TestInfluenceParamGTFunction.java | 6 +- .../chungMethod/TestChungFit.java | 2 +- .../linearLiquidModel/TestViscosityFit.java | 2 +- .../mechanicalDesign/MechanicalDesign.java | 4 +- .../absorber/AbsorberMechanicalDesign.java | 2 +- .../CompressorMechanicalDesign.java | 19 +- .../separator/SeparatorMechanicalDesign.java | 16 +- .../valve/ValveMechanicalDesign.java | 2 +- .../heatExchanger/HeatExchanger.java | 2 +- .../pipeline/AdiabaticTwoPhasePipe.java | 2 +- .../sectionType/SeparatorSection.java | 2 +- .../util/MoleFractionControllerUtil.java | 6 +- .../AdsorptionDehydrationlModule.java | 28 +- .../GlycolDehydrationlModule.java | 65 +- .../MixerGasProcessingModule.java | 19 +- .../util/monitor/PumpResponse.java | 2 +- src/main/java/neqsim/standards/Standard.java | 2 +- .../standards/gasQuality/Draft_GERG2004.java | 2 +- .../gasQuality/Standard_ISO6578.java | 15 +- .../gasQuality/Standard_ISO6976.java | 54 +- .../gasQuality/UKspecifications_ICF_SI.java | 10 +- .../MonteCarloSimulation.java | 146 +- .../parameterFitting/SampleValue.java | 447 +- .../thermo/atomElement/UNIFACgroup.java | 32 +- .../PedersenPlusModelSolver.java | 32 +- .../characterization/PlusCharacterize.java | 941 +-- .../characterization/PlusFractionModel.java | 19 +- .../characterization/TBPfractionModel.java | 8 +- .../neqsim/thermo/component/Component.java | 226 +- .../thermo/component/ComponentBWRS.java | 919 ++- .../component/ComponentDesmukhMather.java | 2 +- .../neqsim/thermo/component/ComponentEos.java | 1385 ++-- .../neqsim/thermo/component/ComponentGE.java | 263 +- .../component/ComponentGENRTLmodifiedHV.java | 76 +- .../component/ComponentGENRTLmodifiedWS.java | 490 +- .../ComponentGEUniquacmodifiedHV.java | 48 +- .../thermo/component/ComponentGEWilson.java | 2 +- .../thermo/component/ComponentGeDuanSun.java | 1056 +-- .../thermo/component/ComponentGeNRTL.java | 489 +- .../thermo/component/ComponentHydrate.java | 1419 ++-- .../component/ComponentHydrateKluda.java | 689 +- .../thermo/component/ComponentPCSAFT.java | 913 ++- .../thermo/component/ComponentPCSAFTa.java | 2 +- .../neqsim/thermo/component/ComponentPR.java | 288 +- .../thermo/component/ComponentSrkCPA.java | 8 +- .../thermo/component/ComponentUMRCPA.java | 1306 ++-- .../thermo/component/ComponentWaxWilson.java | 2 +- .../AttractiveTermCPAstatoil.java | 2 +- .../thermo/mixingRule/EosMixingRules.java | 4913 +++++++------- src/main/java/neqsim/thermo/phase/Phase.java | 3 +- .../neqsim/thermo/phase/PhaseBWRSEos.java | 1090 ++- .../neqsim/thermo/phase/PhaseDefault.java | 2 +- .../thermo/phase/PhaseDesmukhMather.java | 447 +- .../neqsim/thermo/phase/PhaseDuanSun.java | 175 +- .../thermo/phase/PhaseElectrolyteCPA.java | 16 +- .../thermo/phase/PhaseElectrolyteCPAOld.java | 1563 ++--- .../java/neqsim/thermo/phase/PhaseEos.java | 2 +- .../java/neqsim/thermo/phase/PhaseGENRTL.java | 2 +- .../thermo/phase/PhaseGENRTLmodifiedHV.java | 2 +- .../neqsim/thermo/phase/PhaseGEUnifac.java | 2 +- .../thermo/phase/PhaseGEUnifacPSRK.java | 2 +- .../PhaseModifiedFurstElectrolyteEos.java | 8 +- ...aseModifiedFurstElectrolyteEosMod2004.java | 8 +- .../java/neqsim/thermo/phase/PhasePCSAFT.java | 101 +- .../thermo/phase/PhasePCSAFTRahmat.java | 2865 ++++---- .../neqsim/thermo/phase/PhasePCSAFTa.java | 20 +- .../neqsim/thermo/phase/PhasePrEosvolcor.java | 2 +- .../java/neqsim/thermo/phase/PhaseSrkCPA.java | 3970 +++++------ .../phase/PhaseSrkCPA_proceduralMatrices.java | 2743 ++++---- .../thermo/phase/PhaseSrkCPAojAlgo.java | 19 +- .../java/neqsim/thermo/phase/PhaseUMRCPA.java | 3970 +++++------ .../thermo/system/SystemDesmukhMather.java | 6 +- .../neqsim/thermo/system/SystemDuanSun.java | 196 +- .../thermo/system/SystemKentEisenberg.java | 146 +- .../java/neqsim/thermo/system/SystemNRTL.java | 6 +- .../neqsim/thermo/system/SystemPrEos.java | 2 +- .../neqsim/thermo/system/SystemSrkEos.java | 2 +- .../thermo/system/SystemSrkPenelouxEos.java | 2 +- .../neqsim/thermo/system/SystemThermo.java | 278 +- .../neqsim/thermo/util/GERG/GERG2008.java | 6044 +++++++++-------- .../constants/FurstElectrolyteConstants.java | 2 +- ...tIonicInteractionParameterFitting_CO2.java | 346 +- ...BinaryHVParameterFittingFunction_MDEA.java | 250 +- ...stBinaryCPAfitToActivityCoefficientDB.java | 4 +- ...stCPAParameterFittingToSolubilityData.java | 2 +- ...arameterFittingToSolubilityData_Lucia.java | 6 +- ...AParameterFittingToSolubilityGlycolHC.java | 8 +- ...inaryHVParameterFittingToDewPointData.java | 2 +- ...aryHVParameterFittingToSolubilityData.java | 4 +- ...arameterFittingToSolubilityData_Lucia.java | 22 +- ...rFittingToSolubilityData_LuciaPropane.java | 104 +- ...ameterFittingToSolubilityDatawaterCO2.java | 2 +- .../TestBinaryHVfitToActivityCPA.java | 6 +- .../TestBinaryHVfitToActivityUNIFAC.java | 105 +- ...stBinaryUMRPRUFittingToSolubilityData.java | 2 +- ...arameterFittingToSolubilityData_Lucia.java | 48 +- .../freezingFit/TestSolidComplexFunction.java | 2 +- .../TestIonicInteractionParameterFitting.java | 107 +- ...stIonicInteractionParameterFittingCH4.java | 6 +- ...nicInteractionParameterFittingCo2nacl.java | 14 +- ...ractionParameterFittingMDEAPiperazine.java | 6 +- ...InteractionParameterFittingPiperazine.java | 4 +- .../TestAcentricSchwartzentruber.java | 2 +- .../TestMathiasCopemanToDewPoint.java | 2 +- .../cpaParam/CPAFunctionCp.java | 2 +- .../cpaParam/CPAFunctionDens.java | 2 +- .../cpaParam/TestCPA.java | 6 +- .../cpaParam/TestCPA2.java | 6 +- .../cpaParam/TestCPA2_1.java | 6 +- .../cpaParam/TestCPAStatoil.java | 8 +- .../cpaParam/TestCPA_TEG.java | 8 +- .../TestFurstIonicParameterFunction.java | 4 +- .../hydrate/TestHydrateFunction.java | 8 +- .../ThermodynamicOperations.java | 2 +- .../flashOps/CriticalPointFlash.java | 438 +- .../flashOps/Flash.java | 4 +- .../flashOps/PSFlash.java | 8 +- .../flashOps/PSFlashGERG2008.java | 13 +- .../flashOps/PVrefluxflash.java | 10 +- .../flashOps/TPgradientFlash.java | 15 +- .../flashOps/TPmultiflash.java | 24 +- .../flashOps/TVflash.java | 5 +- .../flashOps/VHflash.java | 145 +- .../flashOps/VUflash.java | 3 +- .../HydrateInhibitorConcentrationFlash.java | 238 +- .../HydrateInhibitorwtFlash.java | 282 +- .../addIonToScaleSaturation.java | 329 +- .../bubblePointPressureFlash.java | 315 +- .../bubblePointPressureFlashDer.java | 347 +- .../saturationOps/calcSaltSatauration.java | 220 +- .../saturationOps/checkScalePotential.java | 393 +- .../saturationOps/cricondebarFlash.java | 6 +- .../saturationOps/cricondenBarTemp.java | 2 +- .../saturationOps/cricondenBarTemp1.java | 450 +- ...terDewPointTemperatureMultiphaseFlash.java | 98 +- .../flashOps/sysNewtonRhapsonPHflash.java | 4 +- .../flashOps/sysNewtonRhapsonTPflash.java | 2 +- .../flashOps/sysNewtonRhapsonTPflashNew.java | 96 +- .../sysNewtonRhapsonPhaseEnvelope.java | 1300 ++-- .../sysNewtonRhapsonPhaseEnvelope2.java | 924 +-- .../reactiveCurves/pLoadingCurve2.java | 30 +- .../OLGApropertyTableGeneratorWater.java | 2841 ++++---- .../OLGApropertyTableGeneratorWaterEven.java | 2513 ++++--- ...GApropertyTableGeneratorWaterStudents.java | 3654 +++++----- ...propertyTableGeneratorWaterStudentsPH.java | 3633 +++++----- .../pipeFlowSystem/PipeFlowSystemTest.java | 6 +- .../util/examples/TPflashTest.java | 154 +- .../util/examples/TestSurfaceTenison.java | 168 +- .../compressor/CompressorCalculationTest.java | 231 +- .../compressor/CompressorTest.java | 4 +- .../heatExchanger/HeatExchangerTest.java | 2 +- .../processSystem/ProcessSystemTest.java | 2 +- .../util/example/OnshoreProcess1.java | 1035 +-- .../TEGdehydrationProcessDistillation.java | 598 +- ...TEGdehydrationProcessDistillationAaHa.java | 869 ++- .../TEGdehydrationProcessDistillationGFA.java | 1085 ++- .../util/example/TestNeqsim.java | 257 +- .../util/example/multiThreadTest.java | 236 +- .../gasQuality/Standard_ISO6578Test.java | 50 +- .../util/example/HeatOfVaporization.java | 46 +- .../thermo/util/example/HydrateFlash.java | 310 +- .../thermo/util/example/PhaseEnvelope.java | 265 +- .../thermo/util/example/ReadFluidData.java | 66 +- .../util/example/ScalePotentialCheck.java | 4 +- .../neqsim/thermo/util/example/TPflash2.java | 72 +- .../thermo/util/example/TPflashDehyd.java | 374 +- .../neqsim/thermo/util/example/TPflashGR.java | 169 +- .../TestCharacterizationCondensate.java | 182 +- .../TestCharacterizationCondensate1.java | 126 +- .../thermo/util/example/TestGEHenry.java | 52 +- .../thermo/util/example/TestPCSAFT1.java | 141 +- .../neqsim/thermo/util/example/TestPSRK.java | 92 +- .../neqsim/thermo/util/example/TestSRKWS.java | 64 +- .../thermo/util/example/TestUMRPRU.java | 162 +- .../thermo/util/example/TestUMRPRUMC.java | 195 +- .../thermo/util/example/TestUniSimsFlash.java | 86 +- .../Problem280809LNGphaseEnvelope.java | 62 +- .../util/example/CompGradientFlash.java | 82 +- 217 files changed, 41340 insertions(+), 40672 deletions(-) diff --git a/src/main/java/neqsim/MathLib/nonLinearSolver/sysNewtonRhapson.java b/src/main/java/neqsim/MathLib/nonLinearSolver/sysNewtonRhapson.java index 1d8267345d..595f46ee0e 100644 --- a/src/main/java/neqsim/MathLib/nonLinearSolver/sysNewtonRhapson.java +++ b/src/main/java/neqsim/MathLib/nonLinearSolver/sysNewtonRhapson.java @@ -12,458 +12,470 @@ * @version $Id: $Id */ public class sysNewtonRhapson implements java.io.Serializable { - private static final long serialVersionUID = 1000; - int neq = 0, iter = 0; - int ic02p = -100, ic03p = -100, testcrit = 0, npCrit = 0; - double beta = 0, ds = 0, dTmax = 1, dPmax = 1, avscp = 0.1, TC1 = 0, TC2 = 0, PC1 = 0, PC2 = 0; - Matrix Jac; - Matrix fvec; - Matrix u; - Matrix uold; - Matrix Xgij; - SystemInterface system; - int numberOfComponents; - int speceq = 0; - Matrix a = new Matrix(4, 4); - Matrix s = new Matrix(1, 4); - Matrix xg; - Matrix xcoef; - newtonRhapson solver; - boolean etterCP = false; - boolean etterCP2 = false; - - /** - *

- * Constructor for sysNewtonRhapson. - *

- */ - public sysNewtonRhapson() {} - - /** - *

- * Constructor for sysNewtonRhapson. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param numberOfPhases a int - * @param numberOfComponents a int - */ - public sysNewtonRhapson(SystemInterface system, int numberOfPhases, int numberOfComponents) { - this.system = system; - this.numberOfComponents = numberOfComponents; - neq = numberOfComponents + 2; - Jac = new Matrix(neq, neq); - fvec = new Matrix(neq, 1); - u = new Matrix(neq, 1); - Xgij = new Matrix(neq, 4); - setu(); - uold = u.copy(); - findSpecEqInit(); - // System.out.println("Spec : " +speceq); - solver = new newtonRhapson(); - solver.setOrder(3); + private static final long serialVersionUID = 1000; + int neq = 0; + int iter = 0; + int ic02p = -100; + int ic03p = -100; + int testcrit = 0; + int npCrit = 0; + double beta = 0; + double ds = 0; + double dTmax = 1; + double dPmax = 1; + double avscp = 0.1; + double TC1 = 0; + double TC2 = 0; + double PC1 = 0; + double PC2 = 0; + Matrix Jac; + Matrix fvec; + Matrix u; + Matrix uold; + Matrix Xgij; + SystemInterface system; + int numberOfComponents; + int speceq = 0; + Matrix a = new Matrix(4, 4); + Matrix s = new Matrix(1, 4); + Matrix xg; + Matrix xcoef; + newtonRhapson solver; + boolean etterCP = false; + boolean etterCP2 = false; + + /** + *

+ * Constructor for sysNewtonRhapson. + *

+ */ + public sysNewtonRhapson() {} + + /** + *

+ * Constructor for sysNewtonRhapson. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param numberOfPhases a int + * @param numberOfComponents a int + */ + public sysNewtonRhapson(SystemInterface system, int numberOfPhases, int numberOfComponents) { + this.system = system; + this.numberOfComponents = numberOfComponents; + neq = numberOfComponents + 2; + Jac = new Matrix(neq, neq); + fvec = new Matrix(neq, 1); + u = new Matrix(neq, 1); + Xgij = new Matrix(neq, 4); + setu(); + uold = u.copy(); + findSpecEqInit(); + // System.out.println("Spec : " +speceq); + solver = new newtonRhapson(); + solver.setOrder(3); + } + + /** + *

+ * Setter for the field fvec. + *

+ */ + public void setfvec() { + for (int i = 0; i < numberOfComponents; i++) { + fvec.set(i, 0, + u.get(i, 0) + Math.log(system.getPhases()[1].getComponents()[i].getFugacityCoefficient() + / system.getPhases()[0].getComponents()[i].getFugacityCoefficient())); } - - /** - *

- * Setter for the field fvec. - *

- */ - public void setfvec() { - for (int i = 0; i < numberOfComponents; i++) { - fvec.set(i, 0, u.get(i, 0) - + Math.log(system.getPhases()[1].getComponents()[i].getFugacityCoefficient() - / system.getPhases()[0].getComponents()[i].getFugacityCoefficient())); - } - double fsum = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - fsum = fsum + system.getPhases()[1].getComponents()[i].getx() - - system.getPhases()[0].getComponents()[i].getx(); - } - fvec.set(numberOfComponents, 0, fsum); - fvec.set(numberOfComponents + 1, 0, 0.0); - // fvec.print(0,10); + double fsum = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + fsum = fsum + system.getPhases()[1].getComponents()[i].getx() + - system.getPhases()[0].getComponents()[i].getx(); } - - /** - *

- * findSpecEqInit. - *

- */ - public void findSpecEqInit() { - speceq = 0; - - int speceqmin = 0; - - for (int i = 0; i < numberOfComponents; i++) { - if (system.getPhases()[0].getComponents()[i] - .getTC() > system.getPhases()[0].getComponents()[speceq].getTC()) { - speceq = system.getPhases()[0].getComponents()[i].getComponentNumber(); - } - if (system.getPhases()[0].getComponents()[i] - .getTC() < system.getPhases()[0].getComponents()[speceq].getTC()) { - speceqmin = system.getPhases()[0].getComponents()[i].getComponentNumber(); - } - } - avscp = (system.getPhases()[0].getComponents()[speceq].getTC() - - system.getPhases()[0].getComponents()[speceqmin].getTC()) / 2000; - System.out.println("avscp: " + avscp); - dTmax = avscp * 3; - dPmax = avscp * 1.5; - System.out.println("dTmax: " + dTmax + " dPmax: " + dPmax); + fvec.set(numberOfComponents, 0, fsum); + fvec.set(numberOfComponents + 1, 0, 0.0); + // fvec.print(0,10); + } + + /** + *

+ * findSpecEqInit. + *

+ */ + public void findSpecEqInit() { + speceq = 0; + + int speceqmin = 0; + + for (int i = 0; i < numberOfComponents; i++) { + if (system.getPhases()[0].getComponents()[i] + .getTC() > system.getPhases()[0].getComponents()[speceq].getTC()) { + speceq = system.getPhases()[0].getComponents()[i].getComponentNumber(); + } + if (system.getPhases()[0].getComponents()[i] + .getTC() < system.getPhases()[0].getComponents()[speceq].getTC()) { + speceqmin = system.getPhases()[0].getComponents()[i].getComponentNumber(); + } } - - /** - *

- * findSpecEq. - *

- */ - public void findSpecEq() { - double max = 0; - for (int i = 0; i < numberOfComponents + 2; i++) { - if (Math.abs(u.get(i, 0) - uold.get(i, 0) / uold.get(i, 0)) > max) { - max = Math.abs(u.get(i, 0) - uold.get(i, 0) / uold.get(i, 0)); - } - } + avscp = (system.getPhases()[0].getComponents()[speceq].getTC() + - system.getPhases()[0].getComponents()[speceqmin].getTC()) / 2000; + System.out.println("avscp: " + avscp); + dTmax = avscp * 3; + dPmax = avscp * 1.5; + System.out.println("dTmax: " + dTmax + " dPmax: " + dPmax); + } + + /** + *

+ * findSpecEq. + *

+ */ + public void findSpecEq() { + double max = 0; + for (int i = 0; i < numberOfComponents + 2; i++) { + if (Math.abs(u.get(i, 0) - uold.get(i, 0) / uold.get(i, 0)) > max) { + max = Math.abs(u.get(i, 0) - uold.get(i, 0) / uold.get(i, 0)); + } } - - /** - *

- * setJac. - *

- */ - public void setJac() { - Jac.timesEquals(0.0); - double dij = 0.0; - double[] dxidlnk = new double[numberOfComponents]; - double[] dyidlnk = new double[numberOfComponents]; - double tempJ = 0.0; - int nofc = numberOfComponents; - for (int i = 0; i < numberOfComponents; i++) { - dxidlnk[i] = -system.getBeta() * system.getPhases()[0].getComponents()[i].getx() - * system.getPhases()[1].getComponents()[i].getx() - / system.getPhases()[0].getComponents()[i].getz(); - dyidlnk[i] = system.getPhases()[1].getComponents()[i].getx() - + system.getPhases()[0].getComponents()[i].getK() * dxidlnk[i]; - // System.out.println("dxidlnk("+i+") "+dxidlnk[i]); - // System.out.println("dyidlnk("+i+") "+dyidlnk[i]); - } - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < numberOfComponents; j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta - tempJ = dij + system.getPhases()[1].getComponents()[i].getdfugdx(j) * dyidlnk[j] - - system.getPhases()[0].getComponents()[i].getdfugdx(j) * dxidlnk[j]; - Jac.set(i, j, tempJ); - } - tempJ = system.getTemperature() * (system.getPhases()[1].getComponents()[i].getdfugdt() - - system.getPhases()[0].getComponents()[i].getdfugdt()); - Jac.set(i, nofc, tempJ); - tempJ = system.getPressure() * (system.getPhases()[1].getComponents()[i].getdfugdp() - - system.getPhases()[0].getComponents()[i].getdfugdp()); - Jac.set(i, nofc + 1, tempJ); - Jac.set(nofc, i, dyidlnk[i] - dxidlnk[i]); - } - Jac.set(nofc + 1, speceq, 1.0); + } + + /** + *

+ * setJac. + *

+ */ + public void setJac() { + Jac.timesEquals(0.0); + double dij = 0.0; + double[] dxidlnk = new double[numberOfComponents]; + double[] dyidlnk = new double[numberOfComponents]; + double tempJ = 0.0; + int nofc = numberOfComponents; + for (int i = 0; i < numberOfComponents; i++) { + dxidlnk[i] = -system.getBeta() * system.getPhases()[0].getComponents()[i].getx() + * system.getPhases()[1].getComponents()[i].getx() + / system.getPhases()[0].getComponents()[i].getz(); + dyidlnk[i] = system.getPhases()[1].getComponents()[i].getx() + + system.getPhases()[0].getComponents()[i].getK() * dxidlnk[i]; + // System.out.println("dxidlnk("+i+") "+dxidlnk[i]); + // System.out.println("dyidlnk("+i+") "+dyidlnk[i]); } - - /** - *

- * Setter for the field u. - *

- */ - public void setu() { - for (int i = 0; i < numberOfComponents; i++) { - u.set(i, 0, Math.log(system.getPhases()[0].getComponents()[i].getK())); - } - u.set(numberOfComponents, 0, Math.log(system.getTemperature())); - u.set(numberOfComponents + 1, 0, Math.log(system.getPressure())); + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < numberOfComponents; j++) { + dij = i == j ? 1.0 : 0.0; // Kroneckers delta + tempJ = dij + system.getPhases()[1].getComponents()[i].getdfugdx(j) * dyidlnk[j] + - system.getPhases()[0].getComponents()[i].getdfugdx(j) * dxidlnk[j]; + Jac.set(i, j, tempJ); + } + tempJ = system.getTemperature() * (system.getPhases()[1].getComponents()[i].getdfugdt() + - system.getPhases()[0].getComponents()[i].getdfugdt()); + Jac.set(i, nofc, tempJ); + tempJ = system.getPressure() * (system.getPhases()[1].getComponents()[i].getdfugdp() + - system.getPhases()[0].getComponents()[i].getdfugdp()); + Jac.set(i, nofc + 1, tempJ); + Jac.set(nofc, i, dyidlnk[i] - dxidlnk[i]); } - - /** - *

- * init. - *

- */ - public void init() { - for (int i = 0; i < numberOfComponents; i++) { - system.getPhases()[0].getComponents()[i].setK(Math.exp(u.get(i, 0))); - system.getPhases()[1].getComponents()[i].setK(Math.exp(u.get(i, 0))); - } - system.setTemperature(Math.exp(u.get(numberOfComponents, 0))); - system.setPressure(Math.exp(u.get(numberOfComponents + 1, 0))); - system.calc_x_y(); - system.init(3); + Jac.set(nofc + 1, speceq, 1.0); + } + + /** + *

+ * Setter for the field u. + *

+ */ + public void setu() { + for (int i = 0; i < numberOfComponents; i++) { + u.set(i, 0, Math.log(system.getPhases()[0].getComponents()[i].getK())); } - - /** - *

- * calcInc. - *

- * - * @param np a int - */ - public void calcInc(int np) { - // u.print(0,10); - // fvec.print(0,10); - // Jac.print(0,10); - - // First we need the sensitivity vector dX/dS - - findSpecEq(); - int nofc = numberOfComponents; - fvec.timesEquals(0.0); - fvec.set(nofc + 1, 0, 1.0); - Matrix dxds = Jac.solve(fvec); - if (np < 5) { - double dp = 0.01; - ds = dp / dxds.get(nofc + 1, 0); - Xgij.setMatrix(0, nofc + 1, np - 1, np - 1, u); - dxds.timesEquals(ds); - // dxds.print(0,10); - u.plusEquals(dxds); - // Xgij.print(0,10); - // u.print(0,10); - } else { - // System.out.println("iter " +iter + " np " + np); - if (iter > 6) { - ds *= 0.5; - System.out.println("ds > 6"); - } - - else { - if (iter < 3) { - ds *= 1.5; - } - if (iter == 3) { - ds *= 1.1; - } - if (iter == 4) { - ds *= 1.0; - } - if (iter > 4) { - ds *= 0.5; - } - - // Now we check wheater this ds is greater than dTmax and dPmax. - if (Math.abs(system.getTemperature() * dxds.get(nofc, 0) * ds) > dTmax) { - // System.out.println("true T"); - ds = sign(dTmax / system.getTemperature() / Math.abs(dxds.get(nofc, 0)), ds); - } - - if (Math.abs(system.getPressure() * dxds.get(nofc + 1, 0) * ds) > dPmax) { - ds = sign(dPmax / system.getPressure() / Math.abs(dxds.get(nofc + 1, 0)), ds); - // System.out.println("true P"); - } - if (etterCP2) { - etterCP2 = false; - ds = 0.5 * ds; - } - - Xgij.setMatrix(0, nofc + 1, 0, 2, Xgij.getMatrix(0, nofc + 1, 1, 3)); - Xgij.setMatrix(0, nofc + 1, 3, 3, u); - s.setMatrix(0, 0, 0, 3, Xgij.getMatrix(speceq, speceq, 0, 3)); - // s.print(0,10); - // System.out.println("ds1 : " + ds); - calcInc2(np); - // System.out.println("ds2 : " + ds); - - // Here we find the next point from the polynomial. - } - } + u.set(numberOfComponents, 0, Math.log(system.getTemperature())); + u.set(numberOfComponents + 1, 0, Math.log(system.getPressure())); + } + + /** + *

+ * init. + *

+ */ + public void init() { + for (int i = 0; i < numberOfComponents; i++) { + system.getPhases()[0].getComponents()[i].setK(Math.exp(u.get(i, 0))); + system.getPhases()[1].getComponents()[i].setK(Math.exp(u.get(i, 0))); } - - /** - *

- * calcInc2. - *

- * - * @param np a int - */ - public void calcInc2(int np) { - for (int j = 0; j < neq; j++) { - xg = Xgij.getMatrix(j, j, 0, 3); - for (int i = 0; i < 4; i++) { - a.set(i, 0, 1.0); - a.set(i, 1, s.get(0, i)); - a.set(i, 2, s.get(0, i) * s.get(0, i)); - a.set(i, 3, a.get(i, 2) * s.get(0, i)); - } - xcoef = a.solve(xg.transpose()); - double sny = ds + s.get(0, 3); - u.set(j, 0, xcoef.get(0, 0) - + sny * (xcoef.get(1, 0) + sny * (xcoef.get(2, 0) + sny * xcoef.get(3, 0)))); + system.setTemperature(Math.exp(u.get(numberOfComponents, 0))); + system.setPressure(Math.exp(u.get(numberOfComponents + 1, 0))); + system.calc_x_y(); + system.init(3); + } + + /** + *

+ * calcInc. + *

+ * + * @param np a int + */ + public void calcInc(int np) { + // u.print(0,10); + // fvec.print(0,10); + // Jac.print(0,10); + + // First we need the sensitivity vector dX/dS + + findSpecEq(); + int nofc = numberOfComponents; + fvec.timesEquals(0.0); + fvec.set(nofc + 1, 0, 1.0); + Matrix dxds = Jac.solve(fvec); + if (np < 5) { + double dp = 0.01; + ds = dp / dxds.get(nofc + 1, 0); + Xgij.setMatrix(0, nofc + 1, np - 1, np - 1, u); + dxds.timesEquals(ds); + // dxds.print(0,10); + u.plusEquals(dxds); + // Xgij.print(0,10); + // u.print(0,10); + } else { + // System.out.println("iter " +iter + " np " + np); + if (iter > 6) { + ds *= 0.5; + System.out.println("ds > 6"); + } + + else { + if (iter < 3) { + ds *= 1.5; } - uold = u.copy(); - // s.print(0,10); - // Xgij.print(0,10); - double xlnkmax = 0; - int numb = 0; - - for (int i = 0; i < numberOfComponents; i++) { - if (Math.abs(u.get(i, 0)) > xlnkmax) { - xlnkmax = Math.abs(u.get(i, 0)); - numb = i; - } + if (iter == 3) { + ds *= 1.1; } - // System.out.println("klnmax: " + u.get(numb,0) + " np " + np + " xlnmax " + - // xlnkmax + "avsxp " + avscp); - // System.out.println("np: " + np + " ico2p: " + ic02p + " ic03p " + ic03p); - - if ((testcrit == -3) && ic03p != np) { - etterCP2 = true; - etterCP = true; - // System.out.println("Etter CP"); - // System.exit(0); - ic03p = np; - testcrit = 0; - xg = Xgij.getMatrix(numb, numb, 0, 3); - - for (int i = 0; i < 4; i++) { - a.set(i, 0, 1.0); - a.set(i, 1, s.get(0, i)); - a.set(i, 2, s.get(0, i) * s.get(0, i)); - a.set(i, 3, a.get(i, 2) * s.get(0, i)); - } - - Matrix xcoef = a.solve(xg.transpose()); - - double[] coefs = new double[4]; - coefs[0] = xcoef.get(3, 0); - coefs[1] = xcoef.get(2, 0); - coefs[2] = xcoef.get(1, 0); - coefs[3] = xcoef.get(0, 0) - sign(avscp, -s.get(0, 3)); - solver.setConstants(coefs); - - // System.out.println("s4: " + s.get(0,3) + " coefs " + coefs[0] +" "+ - // coefs[1]+" " + coefs[2]+" " + coefs[3]); - double nys = solver.solve1order(s.get(0, 3)); - // s = nys - s.get(0,3); - ds = sign(s.get(0, 3) - nys, ds); - // System.out.println("critpoint: " + ds); - - // ds = -nys - s.get(0,3); - calcInc2(np); - - TC2 = Math.exp(u.get(numberOfComponents, 0)); - PC2 = Math.exp(u.get(numberOfComponents + 1, 0)); - system.setTC((TC1 + TC2) * 0.5); - system.setPC((PC1 + PC2) * 0.5); - system.setPhaseType(0, 1); - system.setPhaseType(1, 0); - return; + if (iter == 4) { + ds *= 1.0; + } + if (iter > 4) { + ds *= 0.5; } - else if ((xlnkmax < avscp && testcrit != 1) && (np != ic03p && !etterCP)) { - // System.out.println("hei fra her"); - testcrit = 1; - xg = Xgij.getMatrix(numb, numb, 0, 3); - - for (int i = 0; i < 4; i++) { - a.set(i, 0, 1.0); - a.set(i, 1, s.get(0, i)); - a.set(i, 2, s.get(0, i) * s.get(0, i)); - a.set(i, 3, a.get(i, 2) * s.get(0, i)); - } - // a.print(0,10); - // xg.print(0,10); - - Matrix xcoef = a.solve(xg.transpose()); - // xcoef.print(0,10); - - double[] coefs = new double[4]; - coefs[0] = xcoef.get(3, 0); - coefs[1] = xcoef.get(2, 0); - coefs[2] = xcoef.get(1, 0); - coefs[3] = xcoef.get(0, 0) - sign(avscp, ds); - solver.setConstants(coefs); - - // System.out.println("s4: " + s.get(0,3) + " coefs " + coefs[0] +" "+ - // coefs[1]+" " + coefs[2]+" " + coefs[3]); - double nys = solver.solve1order(s.get(0, 3)); - - ds = -nys - s.get(0, 3); - // System.out.println("critpoint: " + ds); - npCrit = np; - - calcInc2(np); - - TC1 = Math.exp(u.get(numberOfComponents, 0)); - PC1 = Math.exp(u.get(numberOfComponents + 1, 0)); - return; + // Now we check wheater this ds is greater than dTmax and dPmax. + if (Math.abs(system.getTemperature() * dxds.get(nofc, 0) * ds) > dTmax) { + // System.out.println("true T"); + ds = sign(dTmax / system.getTemperature() / Math.abs(dxds.get(nofc, 0)), ds); } - if (testcrit == 1) { - testcrit = -3; + if (Math.abs(system.getPressure() * dxds.get(nofc + 1, 0) * ds) > dPmax) { + ds = sign(dPmax / system.getPressure() / Math.abs(dxds.get(nofc + 1, 0)), ds); + // System.out.println("true P"); + } + if (etterCP2) { + etterCP2 = false; + ds = 0.5 * ds; } - } - /** - *

- * Getter for the field npCrit. - *

- * - * @return a int - */ - public int getNpCrit() { - return npCrit; - } + Xgij.setMatrix(0, nofc + 1, 0, 2, Xgij.getMatrix(0, nofc + 1, 1, 3)); + Xgij.setMatrix(0, nofc + 1, 3, 3, u); + s.setMatrix(0, 0, 0, 3, Xgij.getMatrix(speceq, speceq, 0, 3)); + // s.print(0,10); + // System.out.println("ds1 : " + ds); + calcInc2(np); + // System.out.println("ds2 : " + ds); - /** - *

- * sign. - *

- * - * @param a a double - * @param b a double - * @return a double - */ - public double sign(double a, double b) { - a = Math.abs(a); - b = b >= 0 ? 1.0 : -1.0; - return a * b; + // Here we find the next point from the polynomial. + } + } + } + + /** + *

+ * calcInc2. + *

+ * + * @param np a int + */ + public void calcInc2(int np) { + for (int j = 0; j < neq; j++) { + xg = Xgij.getMatrix(j, j, 0, 3); + for (int i = 0; i < 4; i++) { + a.set(i, 0, 1.0); + a.set(i, 1, s.get(0, i)); + a.set(i, 2, s.get(0, i) * s.get(0, i)); + a.set(i, 3, a.get(i, 2) * s.get(0, i)); + } + xcoef = a.solve(xg.transpose()); + double sny = ds + s.get(0, 3); + u.set(j, 0, xcoef.get(0, 0) + + sny * (xcoef.get(1, 0) + sny * (xcoef.get(2, 0) + sny * xcoef.get(3, 0)))); + } + uold = u.copy(); + // s.print(0,10); + // Xgij.print(0,10); + double xlnkmax = 0; + int numb = 0; + + for (int i = 0; i < numberOfComponents; i++) { + if (Math.abs(u.get(i, 0)) > xlnkmax) { + xlnkmax = Math.abs(u.get(i, 0)); + numb = i; + } + } + // System.out.println("klnmax: " + u.get(numb,0) + " np " + np + " xlnmax " + + // xlnkmax + "avsxp " + avscp); + // System.out.println("np: " + np + " ico2p: " + ic02p + " ic03p " + ic03p); + + if ((testcrit == -3) && ic03p != np) { + etterCP2 = true; + etterCP = true; + // System.out.println("Etter CP"); + // System.exit(0); + ic03p = np; + testcrit = 0; + xg = Xgij.getMatrix(numb, numb, 0, 3); + + for (int i = 0; i < 4; i++) { + a.set(i, 0, 1.0); + a.set(i, 1, s.get(0, i)); + a.set(i, 2, s.get(0, i) * s.get(0, i)); + a.set(i, 3, a.get(i, 2) * s.get(0, i)); + } + + Matrix xcoef = a.solve(xg.transpose()); + + double[] coefs = new double[4]; + coefs[0] = xcoef.get(3, 0); + coefs[1] = xcoef.get(2, 0); + coefs[2] = xcoef.get(1, 0); + coefs[3] = xcoef.get(0, 0) - sign(avscp, -s.get(0, 3)); + solver.setConstants(coefs); + + // System.out.println("s4: " + s.get(0,3) + " coefs " + coefs[0] +" "+ + // coefs[1]+" " + coefs[2]+" " + coefs[3]); + double nys = solver.solve1order(s.get(0, 3)); + // s = nys - s.get(0,3); + ds = sign(s.get(0, 3) - nys, ds); + // System.out.println("critpoint: " + ds); + + // ds = -nys - s.get(0,3); + calcInc2(np); + + TC2 = Math.exp(u.get(numberOfComponents, 0)); + PC2 = Math.exp(u.get(numberOfComponents + 1, 0)); + system.setTC((TC1 + TC2) * 0.5); + system.setPC((PC1 + PC2) * 0.5); + system.setPhaseType(0, 1); + system.setPhaseType(1, 0); + return; } - /** - *

- * solve. - *

- * - * @param np a int - */ - public void solve(int np) { - Matrix dx; - iter = 0; - do { - iter++; - init(); - setfvec(); - setJac(); - dx = Jac.solve(fvec); - u.minusEquals(dx); - if (iter > 6) { - System.out.println("iter > " + iter); - calcInc(np); - solve(np); - break; - } - // System.out.println("feilen: "+dx.norm2()); - } while (dx.norm2() / u.norm2() > 1.e-8 && Double.isNaN(dx.norm2())); - // System.out.println("iter: "+iter); - init(); + else if ((xlnkmax < avscp && testcrit != 1) && (np != ic03p && !etterCP)) { + // System.out.println("hei fra her"); + testcrit = 1; + xg = Xgij.getMatrix(numb, numb, 0, 3); + + for (int i = 0; i < 4; i++) { + a.set(i, 0, 1.0); + a.set(i, 1, s.get(0, i)); + a.set(i, 2, s.get(0, i) * s.get(0, i)); + a.set(i, 3, a.get(i, 2) * s.get(0, i)); + } + // a.print(0,10); + // xg.print(0,10); + + Matrix xcoef = a.solve(xg.transpose()); + // xcoef.print(0,10); + + double[] coefs = new double[4]; + coefs[0] = xcoef.get(3, 0); + coefs[1] = xcoef.get(2, 0); + coefs[2] = xcoef.get(1, 0); + coefs[3] = xcoef.get(0, 0) - sign(avscp, ds); + solver.setConstants(coefs); + + // System.out.println("s4: " + s.get(0,3) + " coefs " + coefs[0] +" "+ + // coefs[1]+" " + coefs[2]+" " + coefs[3]); + double nys = solver.solve1order(s.get(0, 3)); + + ds = -nys - s.get(0, 3); + // System.out.println("critpoint: " + ds); + npCrit = np; + + calcInc2(np); + + TC1 = Math.exp(u.get(numberOfComponents, 0)); + PC1 = Math.exp(u.get(numberOfComponents + 1, 0)); + return; } - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - /* - * sysNewtonRhapson test=new sysNewtonRhapson(); double[] constants = new double[]{0.4,0.4}; - * test.setx(constants); while (test.nonsol()>1.0e-8) { constants=test.getx(); - * System.out.println(constants[0]+" "+constants[1]); } test.nonsol(); - * constants=test.getf(); System.out.println(constants[0]+" "+constants[1]); System.exit(0); - */ } + if (testcrit == 1) { + testcrit = -3; + } + } + + /** + *

+ * Getter for the field npCrit. + *

+ * + * @return a int + */ + public int getNpCrit() { + return npCrit; + } + + /** + *

+ * sign. + *

+ * + * @param a a double + * @param b a double + * @return a double + */ + public double sign(double a, double b) { + a = Math.abs(a); + b = b >= 0 ? 1.0 : -1.0; + return a * b; + } + + /** + *

+ * solve. + *

+ * + * @param np a int + */ + public void solve(int np) { + Matrix dx; + iter = 0; + do { + iter++; + init(); + setfvec(); + setJac(); + dx = Jac.solve(fvec); + u.minusEquals(dx); + if (iter > 6) { + System.out.println("iter > " + iter); + calcInc(np); + solve(np); + break; + } + // System.out.println("feilen: "+dx.norm2()); + } while (dx.norm2() / u.norm2() > 1.e-8 && Double.isNaN(dx.norm2())); + // System.out.println("iter: "+iter); + init(); + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + /* + * sysNewtonRhapson test=new sysNewtonRhapson(); double[] constants = new double[]{0.4,0.4}; + * test.setx(constants); while (test.nonsol()>1.0e-8) { constants=test.getx(); + * System.out.println(constants[0]+" "+constants[1]); } test.nonsol(); constants=test.getf(); + * System.out.println(constants[0]+" "+constants[1]); System.exit(0); + */ } } diff --git a/src/main/java/neqsim/PVTsimulation/simulation/BasePVTsimulation.java b/src/main/java/neqsim/PVTsimulation/simulation/BasePVTsimulation.java index 6ad04d68e2..9807f6b2d6 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/BasePVTsimulation.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/BasePVTsimulation.java @@ -13,163 +13,165 @@ * @version $Id: $Id */ public class BasePVTsimulation implements SimulationInterface { - private SystemInterface thermoSystem = null; - private SystemInterface baseThermoSystem = null; - public ThermodynamicOperations thermoOps = null; - private double pressure; - public double[] pressures = {381.5, 338.9, 290.6, 242.3, 194.1, 145.8, 145.8, 97.5, 49.3}; - public double temperature = 289.0; - double[][] experimentalData = null; - double saturationVolume = 0, saturationPressure = 0, saturationTemperature; - double Zsaturation = 0; - public LevenbergMarquardt optimizer = new LevenbergMarquardt(); - - /** - *

- * Constructor for BasePVTsimulation. - *

- * - * @param tempSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - public BasePVTsimulation(SystemInterface tempSystem) { - thermoSystem = tempSystem;// tempSystem.clone(); - thermoOps = new ThermodynamicOperations(getThermoSystem()); - baseThermoSystem = thermoSystem.clone(); - } - - /** - *

- * Setter for the field experimentalData. - *

- * - * @param expData an array of {@link double} objects - */ - public void setExperimentalData(double[][] expData) { - experimentalData = expData; - } - - /** - *

- * Getter for the field saturationPressure. - *

- * - * @return a double - */ - public double getSaturationPressure() { - return saturationPressure; - } - - /** {@inheritDoc} */ - @Override - public SystemInterface getThermoSystem() { - return thermoSystem; - } - - /** {@inheritDoc} */ - @Override - public void run() { - thermoOps = new ThermodynamicOperations(getThermoSystem()); - } - - /** {@inheritDoc} */ - @Override - public SystemInterface getBaseThermoSystem() { - return baseThermoSystem; - } - - /** {@inheritDoc} */ - @Override - public void setThermoSystem(SystemInterface thermoSystem) { - this.thermoSystem = thermoSystem; - } - - /** - *

- * Getter for the field pressure. - *

- * - * @return the pressure - */ - public double getPressure() { - return pressure; - } - - /** - *

- * Setter for the field pressure. - *

- * - * @param pressure the pressure to set - */ - public void setPressure(double pressure) { - this.pressure = pressure; - } - - /** - *

- * Getter for the field temperature. - *

- * - * @return the temperature - */ - public double getTemperature() { - return temperature; - } - - /** - *

- * Setter for the field temperature. - *

- * - * @param temperature the temperature to set - */ - public void setTemperature(double temperature) { - this.temperature = temperature; - } - - /** - *

- * Getter for the field pressures. - *

- * - * @return the pressures - */ - public double[] getPressures() { - return pressures; - } - - /** - *

- * Setter for the field pressures. - *

- * - * @param pressures the pressures to set - */ - public void setPressures(double[] pressures) { - this.pressures = pressures; - } - - /** {@inheritDoc} */ - @Override - public LevenbergMarquardt getOptimizer() { - return optimizer; - } - - /** - *

- * getZsaturation. - *

- * - * @return the Zsaturation - */ - public double getZsaturation() { - return Zsaturation; - } - - /** - * @return the saturationTemperature - */ - public double getSaturationTemperature() { - return saturationTemperature; - } + private SystemInterface thermoSystem = null; + private SystemInterface baseThermoSystem = null; + public ThermodynamicOperations thermoOps = null; + private double pressure; + public double[] pressures = {381.5, 338.9, 290.6, 242.3, 194.1, 145.8, 145.8, 97.5, 49.3}; + public double temperature = 289.0; + double[][] experimentalData = null; + double saturationVolume = 0; + double saturationPressure = 0; + double saturationTemperature; + double Zsaturation = 0; + public LevenbergMarquardt optimizer = new LevenbergMarquardt(); + + /** + *

+ * Constructor for BasePVTsimulation. + *

+ * + * @param tempSystem a {@link neqsim.thermo.system.SystemInterface} object + */ + public BasePVTsimulation(SystemInterface tempSystem) { + thermoSystem = tempSystem; // tempSystem.clone(); + thermoOps = new ThermodynamicOperations(getThermoSystem()); + baseThermoSystem = thermoSystem.clone(); + } + + /** + *

+ * Setter for the field experimentalData. + *

+ * + * @param expData an array of {@link double} objects + */ + public void setExperimentalData(double[][] expData) { + experimentalData = expData; + } + + /** + *

+ * Getter for the field saturationPressure. + *

+ * + * @return a double + */ + public double getSaturationPressure() { + return saturationPressure; + } + + /** {@inheritDoc} */ + @Override + public SystemInterface getThermoSystem() { + return thermoSystem; + } + + /** {@inheritDoc} */ + @Override + public void run() { + thermoOps = new ThermodynamicOperations(getThermoSystem()); + } + + /** {@inheritDoc} */ + @Override + public SystemInterface getBaseThermoSystem() { + return baseThermoSystem; + } + + /** {@inheritDoc} */ + @Override + public void setThermoSystem(SystemInterface thermoSystem) { + this.thermoSystem = thermoSystem; + } + + /** + *

+ * Getter for the field pressure. + *

+ * + * @return the pressure + */ + public double getPressure() { + return pressure; + } + + /** + *

+ * Setter for the field pressure. + *

+ * + * @param pressure the pressure to set + */ + public void setPressure(double pressure) { + this.pressure = pressure; + } + + /** + *

+ * Getter for the field temperature. + *

+ * + * @return the temperature + */ + public double getTemperature() { + return temperature; + } + + /** + *

+ * Setter for the field temperature. + *

+ * + * @param temperature the temperature to set + */ + public void setTemperature(double temperature) { + this.temperature = temperature; + } + + /** + *

+ * Getter for the field pressures. + *

+ * + * @return the pressures + */ + public double[] getPressures() { + return pressures; + } + + /** + *

+ * Setter for the field pressures. + *

+ * + * @param pressures the pressures to set + */ + public void setPressures(double[] pressures) { + this.pressures = pressures; + } + + /** {@inheritDoc} */ + @Override + public LevenbergMarquardt getOptimizer() { + return optimizer; + } + + /** + *

+ * getZsaturation. + *

+ * + * @return the Zsaturation + */ + public double getZsaturation() { + return Zsaturation; + } + + /** + * @return the saturationTemperature + */ + public double getSaturationTemperature() { + return saturationTemperature; + } } diff --git a/src/main/java/neqsim/PVTsimulation/simulation/ConstantMassExpansion.java b/src/main/java/neqsim/PVTsimulation/simulation/ConstantMassExpansion.java index 06d6171af7..dab22f06b1 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/ConstantMassExpansion.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/ConstantMassExpansion.java @@ -17,373 +17,375 @@ * @version $Id: $Id */ public class ConstantMassExpansion extends BasePVTsimulation { - double[] relativeVolume = null; - double[] totalVolume = null; - private double[] liquidRelativeVolume = null; - private double[] viscosity = null, viscosityOil = null, Zgas = null, density = null, - Yfactor = null, isoThermalCompressibility = null, gasExpensionFactor = null, - gasFormationVolumeFactor = null; - private double[] Bg = null, gasStandardVolume = null, gasVolume = null; - boolean saturationConditionFound = false; - private double saturationIsoThermalCompressibility = 0.0; - double[] temperatures = null; + double[] relativeVolume = null; + double[] totalVolume = null; + private double[] liquidRelativeVolume = null; + private double[] viscosity = null; + private double[] viscosityOil = null; + private double[] Zgas = null; + private double[] density = null; + private double[] Yfactor = null; + private double[] isoThermalCompressibility = null; + private double[] gasExpensionFactor = null; + private double[] gasFormationVolumeFactor = null; + private double[] Bg = null; + private double[] gasStandardVolume = null; + private double[] gasVolume = null; + boolean saturationConditionFound = false; + private double saturationIsoThermalCompressibility = 0.0; + double[] temperatures = null; - /** - *

- * Constructor for ConstantMassExpansion. - *

- * - * @param tempSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - public ConstantMassExpansion(SystemInterface tempSystem) { - super(tempSystem); - } + /** + *

+ * Constructor for ConstantMassExpansion. + *

+ * + * @param tempSystem a {@link neqsim.thermo.system.SystemInterface} object + */ + public ConstantMassExpansion(SystemInterface tempSystem) { + super(tempSystem); + } - /** - *

- * calcSaturationConditions. - *

+ /** + *

+ * calcSaturationConditions. + *

+ */ + public void calcSaturationConditions() { + getThermoSystem().setPressure(1.0); + do { + getThermoSystem().setPressure(getThermoSystem().getPressure() + 10.0); + thermoOps.TPflash(); + // System.out.println("pressure "+ getThermoSystem().getPressure() ); + } while (getThermoSystem().getNumberOfPhases() == 1 + && getThermoSystem().getPressure() < 1000.0); + do { + getThermoSystem().setPressure(getThermoSystem().getPressure() + 10.0); + thermoOps.TPflash(); + } while (getThermoSystem().getNumberOfPhases() > 1 && getThermoSystem().getPressure() < 1000.0); + double minPres = getThermoSystem().getPressure() - 10.0; + double maxPres = getThermoSystem().getPressure(); + do { + getThermoSystem().setPressure((minPres + maxPres) / 2.0); + thermoOps.TPflash(); + if (getThermoSystem().getNumberOfPhases() > 1) { + minPres = getThermoSystem().getPressure(); + } else { + maxPres = getThermoSystem().getPressure(); + } + } while (Math.abs(maxPres - minPres) > 1e-5); + /* + * try { thermoOps.dewPointPressureFlash(); } catch (Exception e) { e.printStackTrace(); } */ - public void calcSaturationConditions() { - getThermoSystem().setPressure(1.0); - do { - getThermoSystem().setPressure(getThermoSystem().getPressure() + 10.0); - thermoOps.TPflash(); - // System.out.println("pressure "+ getThermoSystem().getPressure() ); - } while (getThermoSystem().getNumberOfPhases() == 1 - && getThermoSystem().getPressure() < 1000.0); - do { - getThermoSystem().setPressure(getThermoSystem().getPressure() + 10.0); - thermoOps.TPflash(); - } while (getThermoSystem().getNumberOfPhases() > 1 - && getThermoSystem().getPressure() < 1000.0); - double minPres = getThermoSystem().getPressure() - 10.0; - double maxPres = getThermoSystem().getPressure(); - do { - getThermoSystem().setPressure((minPres + maxPres) / 2.0); - thermoOps.TPflash(); - if (getThermoSystem().getNumberOfPhases() > 1) { - minPres = getThermoSystem().getPressure(); - } else { - maxPres = getThermoSystem().getPressure(); - } - } while (Math.abs(maxPres - minPres) > 1e-5); - /* - * try { thermoOps.dewPointPressureFlash(); } catch (Exception e) { e.printStackTrace(); } - */ - saturationVolume = getThermoSystem().getVolume(); - saturationPressure = getThermoSystem().getPressure(); - Zsaturation = getThermoSystem().getZ(); - saturationConditionFound = true; - } + saturationVolume = getThermoSystem().getVolume(); + saturationPressure = getThermoSystem().getPressure(); + Zsaturation = getThermoSystem().getZ(); + saturationConditionFound = true; + } - /** {@inheritDoc} */ - @Override - public double getSaturationPressure() { - return saturationPressure; + /** {@inheritDoc} */ + @Override + public double getSaturationPressure() { + return saturationPressure; + } + + /** + *

+ * runCalc. + *

+ */ + public void runCalc() { + saturationConditionFound = false; + relativeVolume = new double[pressures.length]; + totalVolume = new double[pressures.length]; + liquidRelativeVolume = new double[pressures.length]; + Zgas = new double[pressures.length]; + Bg = new double[pressures.length]; + gasStandardVolume = new double[pressures.length]; + gasVolume = new double[pressures.length]; + density = new double[pressures.length]; + Yfactor = new double[pressures.length]; + isoThermalCompressibility = new double[pressures.length]; + gasFormationVolumeFactor = new double[pressures.length]; + viscosity = new double[pressures.length]; + viscosityOil = new double[pressures.length]; + gasExpensionFactor = new double[pressures.length]; + getThermoSystem().setTemperature(temperature); + if (!saturationConditionFound) { + calcSaturationConditions(); + try { + thermoOps.TPflash(); + } catch (Exception e) { + e.printStackTrace(); + } + } + try { + // getThermoSystem().setPressure(400); + // thermoOps.bubblePointPressureFlash(false); + } catch (Exception e) { + e.printStackTrace(); } + saturationVolume = getThermoSystem().getVolume(); + saturationPressure = getThermoSystem().getPressure(); + Zsaturation = getThermoSystem().getZ(); + saturationIsoThermalCompressibility = -1.0 / getThermoSystem().getPhase(0).getVolume() + / getThermoSystem().getPhase(0).getdPdVTn(); - /** - *

- * runCalc. - *

- */ - public void runCalc() { - saturationConditionFound = false; - relativeVolume = new double[pressures.length]; - totalVolume = new double[pressures.length]; - liquidRelativeVolume = new double[pressures.length]; - Zgas = new double[pressures.length]; - Bg = new double[pressures.length]; - gasStandardVolume = new double[pressures.length]; - gasVolume = new double[pressures.length]; - density = new double[pressures.length]; - Yfactor = new double[pressures.length]; - isoThermalCompressibility = new double[pressures.length]; - gasFormationVolumeFactor = new double[pressures.length]; - viscosity = new double[pressures.length]; - viscosityOil = new double[pressures.length]; - gasExpensionFactor = new double[pressures.length]; - getThermoSystem().setTemperature(temperature); - if (!saturationConditionFound) { - calcSaturationConditions(); - try { - thermoOps.TPflash(); - } catch (Exception e) { - e.printStackTrace(); - } - } - try { - // getThermoSystem().setPressure(400); - // thermoOps.bubblePointPressureFlash(false); - } catch (Exception e) { - e.printStackTrace(); - } - saturationVolume = getThermoSystem().getVolume(); - saturationPressure = getThermoSystem().getPressure(); - Zsaturation = getThermoSystem().getZ(); - saturationIsoThermalCompressibility = -1.0 / getThermoSystem().getPhase(0).getVolume() - / getThermoSystem().getPhase(0).getdPdVTn(); + for (int i = 0; i < pressures.length; i++) { + // getThermoSystem().init(0); + getThermoSystem().setPressure(pressures[i]); + try { + thermoOps.TPflash(); + } catch (Exception e) { + e.printStackTrace(); + } + getThermoSystem().initPhysicalProperties(); + // getThermoSystem().display(); + totalVolume[i] = getThermoSystem().getVolume(); + relativeVolume[i] = totalVolume[i] / saturationVolume; + density[i] = getThermoSystem().getPhase(0).getDensity("kg/m3"); + gasVolume[i] = getThermoSystem().getPhase(0).getNumberOfMolesInPhase() + * getThermoSystem().getPhase(0).getMolarMass() / density[i]; // getThermoSystem().getPhase(0).getVolume(); + gasStandardVolume[i] = getThermoSystem().getPhase(0).getVolume() + * getThermoSystem().getPhase(0).getPressure() / 1.01325 + / getThermoSystem().getPhase(0).getZ() * 288.15 / getThermoSystem().getTemperature(); + Bg[i] = gasVolume[i] * 1e5 / gasStandardVolume[i]; + Zgas[i] = getThermoSystem().getPhase(0).getZ(); + if (getThermoSystem().getNumberOfPhases() == 1) { + viscosity[i] = getThermoSystem().getPhase(0).getViscosity(); + isoThermalCompressibility[i] = -1.0 / getThermoSystem().getPhase(0).getVolume() + / getThermoSystem().getPhase(0).getdPdVTn(); + Yfactor[i] = Double.NaN; + liquidRelativeVolume[i] = Double.NaN; + } + if (getThermoSystem().getNumberOfPhases() > 1) { + liquidRelativeVolume[i] = + getThermoSystem().getPhase("oil").getVolume() / saturationVolume * 100; + Yfactor[i] = ((saturationPressure - pressures[i]) / pressures[i]) + / ((totalVolume[i] - saturationVolume) / saturationVolume); + viscosity[i] = Double.NaN; + isoThermalCompressibility[i] = Double.NaN; + } + System.out.println("pressure " + getThermoSystem().getPressure() + " relative volume " + + relativeVolume[i] + " liquid rel vol " + liquidRelativeVolume[i] + " Zgas " + Zgas[i] + + " Yfactor " + getYfactor()[i] + " isoCompfactor " + getIsoThermalCompressibility()[i]); + } - for (int i = 0; i < pressures.length; i++) { - // getThermoSystem().init(0); - getThermoSystem().setPressure(pressures[i]); - try { - thermoOps.TPflash(); - } catch (Exception e) { - e.printStackTrace(); - } - getThermoSystem().initPhysicalProperties(); - // getThermoSystem().display(); - totalVolume[i] = getThermoSystem().getVolume(); - relativeVolume[i] = totalVolume[i] / saturationVolume; - density[i] = getThermoSystem().getPhase(0).getDensity("kg/m3"); - gasVolume[i] = getThermoSystem().getPhase(0).getNumberOfMolesInPhase() - * getThermoSystem().getPhase(0).getMolarMass() / density[i];// getThermoSystem().getPhase(0).getVolume(); - gasStandardVolume[i] = getThermoSystem().getPhase(0).getVolume() - * getThermoSystem().getPhase(0).getPressure() / 1.01325 - / getThermoSystem().getPhase(0).getZ() * 288.15 - / getThermoSystem().getTemperature(); - Bg[i] = gasVolume[i] * 1e5 / gasStandardVolume[i]; - Zgas[i] = getThermoSystem().getPhase(0).getZ(); - if (getThermoSystem().getNumberOfPhases() == 1) { - viscosity[i] = getThermoSystem().getPhase(0).getViscosity(); - isoThermalCompressibility[i] = -1.0 / getThermoSystem().getPhase(0).getVolume() - / getThermoSystem().getPhase(0).getdPdVTn(); - Yfactor[i] = Double.NaN; - liquidRelativeVolume[i] = Double.NaN; - } - if (getThermoSystem().getNumberOfPhases() > 1) { - liquidRelativeVolume[i] = - getThermoSystem().getPhase("oil").getVolume() / saturationVolume * 100; - Yfactor[i] = ((saturationPressure - pressures[i]) / pressures[i]) - / ((totalVolume[i] - saturationVolume) / saturationVolume); - viscosity[i] = Double.NaN; - isoThermalCompressibility[i] = Double.NaN; - } - System.out.println("pressure " + getThermoSystem().getPressure() + " relative volume " - + relativeVolume[i] + " liquid rel vol " + liquidRelativeVolume[i] + " Zgas " - + Zgas[i] + " Yfactor " + getYfactor()[i] + " isoCompfactor " - + getIsoThermalCompressibility()[i]); - } + System.out.println("test finished"); + System.out.println("test finished"); + } - System.out.println("test finished"); - System.out.println("test finished"); - } + /** + *

+ * runTuning. + *

+ */ + public void runTuning() { + ArrayList sampleList = new ArrayList(); - /** - *

- * runTuning. - *

- */ - public void runTuning() { - ArrayList sampleList = new ArrayList(); + try { + System.out.println("adding...."); - try { - System.out.println("adding...."); + for (int i = 0; i < experimentalData[0].length; i++) { + CMEFunction function = new CMEFunction(); + double[] guess = new double[] { + getThermoSystem().getCharacterization().getPlusFractionModel().getMPlus() / 1000.0}; + function.setInitialGuess(guess); - for (int i = 0; i < experimentalData[0].length; i++) { - CMEFunction function = new CMEFunction(); - double[] guess = new double[] { - getThermoSystem().getCharacterization().getPlusFractionModel().getMPlus() - / 1000.0}; - function.setInitialGuess(guess); + SystemInterface tempSystem = getThermoSystem(); // getThermoSystem().clone(); - SystemInterface tempSystem = getThermoSystem(); // getThermoSystem().clone(); + tempSystem.setTemperature(temperature); + tempSystem.setPressure(pressures[i]); + // thermoOps.TPflash(); + // tempSystem.display(); + double[] sample1 = {temperature, pressures[i]}; + double relativeVolume = experimentalData[0][i]; + double[] standardDeviation1 = {1.5}; + SampleValue sample = + new SampleValue(relativeVolume, relativeVolume / 50.0, sample1, standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(tempSystem); + sampleList.add(sample); + } + } catch (Exception e) { + System.out.println("database error" + e); + } - tempSystem.setTemperature(temperature); - tempSystem.setPressure(pressures[i]); - // thermoOps.TPflash(); - // tempSystem.display(); - double sample1[] = {temperature, pressures[i]}; - double relativeVolume = experimentalData[0][i]; - double standardDeviation1[] = {1.5}; - SampleValue sample = new SampleValue(relativeVolume, relativeVolume / 50.0, sample1, - standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(tempSystem); - sampleList.add(sample); - } - } catch (Exception e) { - System.out.println("database error" + e); - } + SampleSet sampleSet = new SampleSet(sampleList); - SampleSet sampleSet = new SampleSet(sampleList); + optimizer = new LevenbergMarquardt(); + optimizer.setMaxNumberOfIterations(5); - optimizer = new LevenbergMarquardt(); - optimizer.setMaxNumberOfIterations(5); + optimizer.setSampleSet(sampleSet); + optimizer.solve(); + runCalc(); + // optim.displayCurveFit(); + } - optimizer.setSampleSet(sampleSet); - optimizer.solve(); - runCalc(); - // optim.displayCurveFit(); - } + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + SystemInterface tempSystem = new SystemSrkEos(273.15 + 73.0, 10.0); + tempSystem.addComponent("nitrogen", 0.972); + tempSystem.addComponent("CO2", 0.632); + tempSystem.addComponent("methane", 95.111); + tempSystem.addComponent("ethane", 2.553); + tempSystem.addComponent("propane", 0.104); + tempSystem.addComponent("i-butane", 0.121); + tempSystem.addComponent("n-butane", 0.021); + tempSystem.addComponent("i-pentane", 0.066); + tempSystem.addComponent("n-pentane", 0.02); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects + tempSystem.addTBPfraction("C6", 0.058, 86.18 / 1000.0, 664.0e-3); + tempSystem.addTBPfraction("C7", 0.107, 96.0 / 1000.0, 738.0e-3); + tempSystem.addTBPfraction("C8", 0.073, 107.0 / 1000.0, 765.0e-3); + tempSystem.addTBPfraction("C9", 0.044, 121.0 / 1000.0, 781.0e-3); + tempSystem.addPlusFraction("C10", 0.118, 190.0 / 1000.0, 813.30e-3); + tempSystem.getCharacterization().getLumpingModel().setNumberOfPseudoComponents(12); + tempSystem.getCharacterization().setLumpingModel("PVTlumpingModel"); + tempSystem.getCharacterization().characterisePlusFraction(); + tempSystem.createDatabase(true); + tempSystem.setMixingRule(2); + tempSystem.init(0); + tempSystem.init(1); + /* + * tempSystem.addComponent("nitrogen", 0.6); tempSystem.addComponent("CO2", 3.34); + * tempSystem.addComponent("methane", 74.16); tempSystem.addComponent("ethane", 7.9); + * tempSystem.addComponent("propane", 4.15); tempSystem.addComponent("i-butane", 0.71); + * tempSystem.addComponent("n-butane", 0.71); tempSystem.addComponent("i-pentane", 0.66); + * tempSystem.addComponent("n-pentane", 0.66); tempSystem.addComponent("n-hexane", 0.81); + * tempSystem.addTBPfraction("C7", 1.2, 91.0 / 1000.0, 0.746); tempSystem.addTBPfraction("C8", + * 1.15, 104.0 / 1000.0, 0.770); tempSystem.addTBPfraction("C9", 5.15, 125.0 / 1000.0, 0.8); */ - public static void main(String[] args) { - SystemInterface tempSystem = new SystemSrkEos(273.15 + 73.0, 10.0); - tempSystem.addComponent("nitrogen", 0.972); - tempSystem.addComponent("CO2", 0.632); - tempSystem.addComponent("methane", 95.111); - tempSystem.addComponent("ethane", 2.553); - tempSystem.addComponent("propane", 0.104); - tempSystem.addComponent("i-butane", 0.121); - tempSystem.addComponent("n-butane", 0.021); - tempSystem.addComponent("i-pentane", 0.066); - tempSystem.addComponent("n-pentane", 0.02); - tempSystem.addTBPfraction("C6", 0.058, 86.18 / 1000.0, 664.0e-3); - tempSystem.addTBPfraction("C7", 0.107, 96.0 / 1000.0, 738.0e-3); - tempSystem.addTBPfraction("C8", 0.073, 107.0 / 1000.0, 765.0e-3); - tempSystem.addTBPfraction("C9", 0.044, 121.0 / 1000.0, 781.0e-3); - tempSystem.addPlusFraction("C10", 0.118, 190.0 / 1000.0, 813.30e-3); - tempSystem.getCharacterization().getLumpingModel().setNumberOfPseudoComponents(12); - tempSystem.getCharacterization().setLumpingModel("PVTlumpingModel"); - tempSystem.getCharacterization().characterisePlusFraction(); - tempSystem.createDatabase(true); - tempSystem.setMixingRule(2); - tempSystem.init(0); - tempSystem.init(1); - /* - * tempSystem.addComponent("nitrogen", 0.6); tempSystem.addComponent("CO2", 3.34); - * tempSystem.addComponent("methane", 74.16); tempSystem.addComponent("ethane", 7.9); - * tempSystem.addComponent("propane", 4.15); tempSystem.addComponent("i-butane", 0.71); - * tempSystem.addComponent("n-butane", 0.71); tempSystem.addComponent("i-pentane", 0.66); - * tempSystem.addComponent("n-pentane", 0.66); tempSystem.addComponent("n-hexane", 0.81); - * tempSystem.addTBPfraction("C7", 1.2, 91.0 / 1000.0, 0.746); - * tempSystem.addTBPfraction("C8", 1.15, 104.0 / 1000.0, 0.770); - * tempSystem.addTBPfraction("C9", 5.15, 125.0 / 1000.0, 0.8); - */ + ConstantMassExpansion CMEsim = new ConstantMassExpansion(tempSystem); + // CMEsim.runCalc(); + // double a = CMEsim.getSaturationPressure(); - ConstantMassExpansion CMEsim = new ConstantMassExpansion(tempSystem); - // CMEsim.runCalc(); - // double a = CMEsim.getSaturationPressure(); + CMEsim.setTemperaturesAndPressures( + new double[] {273.15 + 73.9, 273.15 + 73.9, 273.15 + 73.9, 273.15 + 73.9, 273.15 + 73.9}, + new double[] {400, 300.0, 250.0, 200.0, 100.0}); + double[][] expData = {{0.95, 0.99, 1.12, 1.9}}; + CMEsim.setExperimentalData(expData); + // CMEsim.runTuning(); + CMEsim.runCalc(); + } - CMEsim.setTemperaturesAndPressures(new double[] {273.15 + 73.9, 273.15 + 73.9, - 273.15 + 73.9, 273.15 + 73.9, 273.15 + 73.9}, - new double[] {400, 300.0, 250.0, 200.0, 100.0}); - double[][] expData = {{0.95, 0.99, 1.12, 1.9}}; - CMEsim.setExperimentalData(expData); - // CMEsim.runTuning(); - CMEsim.runCalc(); - } + /** + *

+ * Getter for the field relativeVolume. + *

+ * + * @return the relativeVolume + */ + public double[] getRelativeVolume() { + return relativeVolume; + } - /** - *

- * Getter for the field relativeVolume. - *

- * - * @return the relativeVolume - */ - public double[] getRelativeVolume() { - return relativeVolume; - } + /** + *

+ * Getter for the field liquidRelativeVolume. + *

+ * + * @return the liquidRelativeVolume + */ + public double[] getLiquidRelativeVolume() { + return liquidRelativeVolume; + } - /** - *

- * Getter for the field liquidRelativeVolume. - *

- * - * @return the liquidRelativeVolume - */ - public double[] getLiquidRelativeVolume() { - return liquidRelativeVolume; - } + /** + *

+ * getZgas. + *

+ * + * @return the Zgas + */ + public double[] getZgas() { + return Zgas; + } - /** - *

- * getZgas. - *

- * - * @return the Zgas - */ - public double[] getZgas() { - return Zgas; - } - - /** - *

- * getYfactor. - *

- * - * @return the Yfactor - */ - public double[] getYfactor() { - return Yfactor; - } + /** + *

+ * getYfactor. + *

+ * + * @return the Yfactor + */ + public double[] getYfactor() { + return Yfactor; + } - /** - *

- * Getter for the field density. - *

- * - * @return the density - */ - public double[] getDensity() { - return density; - } + /** + *

+ * Getter for the field density. + *

+ * + * @return the density + */ + public double[] getDensity() { + return density; + } - /** - *

- * Getter for the field viscosity. - *

- * - * @return the gas viscosity - */ - public double[] getViscosity() { - return viscosity; - } + /** + *

+ * Getter for the field viscosity. + *

+ * + * @return the gas viscosity + */ + public double[] getViscosity() { + return viscosity; + } - /** - *

- * getBg. - *

- * - * @return the gas volume formation factor - */ - public double[] getBg() { - return Bg; - } + /** + *

+ * getBg. + *

+ * + * @return the gas volume formation factor + */ + public double[] getBg() { + return Bg; + } - /** - *

- * Getter for the field isoThermalCompressibility. - *

- * - * @return the isoThermalCompressibility - */ - public double[] getIsoThermalCompressibility() { - return isoThermalCompressibility; - } + /** + *

+ * Getter for the field isoThermalCompressibility. + *

+ * + * @return the isoThermalCompressibility + */ + public double[] getIsoThermalCompressibility() { + return isoThermalCompressibility; + } - /** - *

- * Getter for the field saturationIsoThermalCompressibility. - *

- * - * @return the saturationIsoThermalCompressibility - */ - public double getSaturationIsoThermalCompressibility() { - return saturationIsoThermalCompressibility; - } + /** + *

+ * Getter for the field saturationIsoThermalCompressibility. + *

+ * + * @return the saturationIsoThermalCompressibility + */ + public double getSaturationIsoThermalCompressibility() { + return saturationIsoThermalCompressibility; + } - /** - *

- * setTemperaturesAndPressures. - *

- * - * @param temperature an array of {@link double} objects - * @param pressure an array of {@link double} objects - */ - public void setTemperaturesAndPressures(double[] temperature, double[] pressure) { - this.pressures = pressure; - this.temperatures = temperature; - experimentalData = new double[temperature.length][1]; - } + /** + *

+ * setTemperaturesAndPressures. + *

+ * + * @param temperature an array of {@link double} objects + * @param pressure an array of {@link double} objects + */ + public void setTemperaturesAndPressures(double[] temperature, double[] pressure) { + this.pressures = pressure; + this.temperatures = temperature; + experimentalData = new double[temperature.length][1]; + } } diff --git a/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java b/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java index 5bf2332633..05dc813ab9 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java @@ -17,319 +17,321 @@ * @version $Id: $Id */ public class ConstantVolumeDepletion extends BasePVTsimulation { - private double[] relativeVolume = null; - double[] totalVolume = null, liquidVolumeRelativeToVsat = null, liquidVolume = null; - boolean saturationConditionFound = false; - private double[] liquidRelativeVolume = null; - private double[] Zmix, Zgas = null, cummulativeMolePercDepleted = null; - double[] temperatures = null; + private double[] relativeVolume = null; + double[] totalVolume = null; + double[] liquidVolumeRelativeToVsat = null; + double[] liquidVolume = null; + boolean saturationConditionFound = false; + private double[] liquidRelativeVolume = null; + private double[] Zmix; + private double[] Zgas = null; + private double[] cummulativeMolePercDepleted = null; + double[] temperatures = null; - double[] pressure = null; + double[] pressure = null; - /** - *

- * Constructor for ConstantVolumeDepletion. - *

- * - * @param tempSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - public ConstantVolumeDepletion(SystemInterface tempSystem) { - super(tempSystem); - } + /** + *

+ * Constructor for ConstantVolumeDepletion. + *

+ * + * @param tempSystem a {@link neqsim.thermo.system.SystemInterface} object + */ + public ConstantVolumeDepletion(SystemInterface tempSystem) { + super(tempSystem); + } - /** - *

- * setTemperaturesAndPressures. - *

- * - * @param temperature an array of {@link double} objects - * @param pressure an array of {@link double} objects - */ - public void setTemperaturesAndPressures(double[] temperature, double[] pressure) { - this.pressure = pressure; - this.temperatures = temperature; - experimentalData = new double[temperature.length][1]; - } + /** + *

+ * setTemperaturesAndPressures. + *

+ * + * @param temperature an array of {@link double} objects + * @param pressure an array of {@link double} objects + */ + public void setTemperaturesAndPressures(double[] temperature, double[] pressure) { + this.pressure = pressure; + this.temperatures = temperature; + experimentalData = new double[temperature.length][1]; + } - /** - *

- * calcSaturationConditions. - *

+ /** + *

+ * calcSaturationConditions. + *

+ */ + public void calcSaturationConditions() { + getThermoSystem().setPressure(1.0); + do { + getThermoSystem().setPressure(getThermoSystem().getPressure() + 10.0); + } while (getThermoSystem().getNumberOfPhases() == 1 + && getThermoSystem().getPressure() < 1000.0); + do { + getThermoSystem().setPressure(getThermoSystem().getPressure() + 10.0); + thermoOps.TPflash(); + } while (getThermoSystem().getNumberOfPhases() > 1 && getThermoSystem().getPressure() < 1000.0); + double minPres = getThermoSystem().getPressure() - 10.0; + double maxPres = getThermoSystem().getPressure(); + do { + getThermoSystem().setPressure((minPres + maxPres) / 2.0); + thermoOps.TPflash(); + if (getThermoSystem().getNumberOfPhases() > 1) { + minPres = getThermoSystem().getPressure(); + } else { + maxPres = getThermoSystem().getPressure(); + } + } while (Math.abs(maxPres - minPres) > 1e-5); + /* + * try { thermoOps.dewPointPressureFlash(); } catch (Exception e) { e.printStackTrace(); } */ - public void calcSaturationConditions() { - getThermoSystem().setPressure(1.0); - do { - getThermoSystem().setPressure(getThermoSystem().getPressure() + 10.0); - } while (getThermoSystem().getNumberOfPhases() == 1 - && getThermoSystem().getPressure() < 1000.0); - do { - getThermoSystem().setPressure(getThermoSystem().getPressure() + 10.0); - thermoOps.TPflash(); - } while (getThermoSystem().getNumberOfPhases() > 1 - && getThermoSystem().getPressure() < 1000.0); - double minPres = getThermoSystem().getPressure() - 10.0; - double maxPres = getThermoSystem().getPressure(); - do { - getThermoSystem().setPressure((minPres + maxPres) / 2.0); - thermoOps.TPflash(); - if (getThermoSystem().getNumberOfPhases() > 1) { - minPres = getThermoSystem().getPressure(); - } else { - maxPres = getThermoSystem().getPressure(); - } - } while (Math.abs(maxPres - minPres) > 1e-5); - /* - * try { thermoOps.dewPointPressureFlash(); } catch (Exception e) { e.printStackTrace(); } - */ - saturationVolume = getThermoSystem().getVolume(); - saturationPressure = getThermoSystem().getPressure(); - Zsaturation = getThermoSystem().getZ(); - saturationConditionFound = true; - } + saturationVolume = getThermoSystem().getVolume(); + saturationPressure = getThermoSystem().getPressure(); + Zsaturation = getThermoSystem().getZ(); + saturationConditionFound = true; + } - /** - *

- * runCalc. - *

- */ - public void runCalc() { - saturationConditionFound = false; - relativeVolume = new double[pressures.length]; - totalVolume = new double[pressures.length]; - liquidVolumeRelativeToVsat = new double[pressures.length]; - liquidVolume = new double[pressures.length]; - Zgas = new double[pressures.length]; - Zmix = new double[pressures.length]; - liquidRelativeVolume = new double[pressures.length]; - cummulativeMolePercDepleted = new double[pressures.length]; - double totalNumberOfMoles = getThermoSystem().getTotalNumberOfMoles(); - getThermoSystem().setTemperature(temperature); + /** + *

+ * runCalc. + *

+ */ + public void runCalc() { + saturationConditionFound = false; + relativeVolume = new double[pressures.length]; + totalVolume = new double[pressures.length]; + liquidVolumeRelativeToVsat = new double[pressures.length]; + liquidVolume = new double[pressures.length]; + Zgas = new double[pressures.length]; + Zmix = new double[pressures.length]; + liquidRelativeVolume = new double[pressures.length]; + cummulativeMolePercDepleted = new double[pressures.length]; + double totalNumberOfMoles = getThermoSystem().getTotalNumberOfMoles(); + getThermoSystem().setTemperature(temperature); - for (int i = 0; i < pressures.length; i++) { - getThermoSystem().setPressure(pressures[i]); - try { - thermoOps.TPflash(); - } catch (Exception e) { - e.printStackTrace(); - } - // getThermoSystem().display(); - totalVolume[i] = getThermoSystem().getVolume(); - System.out.println("volume " + totalVolume[i]); - cummulativeMolePercDepleted[i] = - 100.0 - getThermoSystem().getTotalNumberOfMoles() / totalNumberOfMoles * 100; - if (getThermoSystem().getNumberOfPhases() > 1) { - if (!saturationConditionFound) { - calcSaturationConditions(); - getThermoSystem().setPressure(pressures[i]); - try { - thermoOps.TPflash(); - } catch (Exception e) { - e.printStackTrace(); - } - } + for (int i = 0; i < pressures.length; i++) { + getThermoSystem().setPressure(pressures[i]); + try { + thermoOps.TPflash(); + } catch (Exception e) { + e.printStackTrace(); + } + // getThermoSystem().display(); + totalVolume[i] = getThermoSystem().getVolume(); + System.out.println("volume " + totalVolume[i]); + cummulativeMolePercDepleted[i] = + 100.0 - getThermoSystem().getTotalNumberOfMoles() / totalNumberOfMoles * 100; + if (getThermoSystem().getNumberOfPhases() > 1) { + if (!saturationConditionFound) { + calcSaturationConditions(); + getThermoSystem().setPressure(pressures[i]); + try { + thermoOps.TPflash(); + } catch (Exception e) { + e.printStackTrace(); + } + } - // if (totalVolume[i] > saturationVolume) { - liquidVolume[i] = getThermoSystem().getPhase(1).getVolume(); - liquidVolumeRelativeToVsat[i] = liquidVolume[i] / saturationVolume; - Zgas[i] = getThermoSystem().getPhase(0).getZ(); - Zmix[i] = getThermoSystem().getZ(); - if (getThermoSystem().getNumberOfPhases() > 1) { - liquidRelativeVolume[i] = - getThermoSystem().getPhase("oil").getVolume() / saturationVolume * 100; - } + // if (totalVolume[i] > saturationVolume) { + liquidVolume[i] = getThermoSystem().getPhase(1).getVolume(); + liquidVolumeRelativeToVsat[i] = liquidVolume[i] / saturationVolume; + Zgas[i] = getThermoSystem().getPhase(0).getZ(); + Zmix[i] = getThermoSystem().getZ(); + if (getThermoSystem().getNumberOfPhases() > 1) { + liquidRelativeVolume[i] = + getThermoSystem().getPhase("oil").getVolume() / saturationVolume * 100; + } - double volumeCorrection = getThermoSystem().getVolume() - saturationVolume; - double test = volumeCorrection / getThermoSystem().getPhase(0).getMolarVolume(); + double volumeCorrection = getThermoSystem().getVolume() - saturationVolume; + double test = volumeCorrection / getThermoSystem().getPhase(0).getMolarVolume(); - for (int j = 0; j < getThermoSystem().getPhase(0).getNumberOfComponents(); j++) { - getThermoSystem().addComponent(j, - -test * getThermoSystem().getPhase(0).getComponent(j).getx()); - // } - } - } + for (int j = 0; j < getThermoSystem().getPhase(0).getNumberOfComponents(); j++) { + getThermoSystem().addComponent(j, + -test * getThermoSystem().getPhase(0).getComponent(j).getx()); + // } } + } + } - for (int i = 0; i < pressures.length; i++) { - relativeVolume[i] = totalVolume[i] / saturationVolume; - System.out.println("rel volume " + relativeVolume[i]); - } - System.out.println("test finished"); + for (int i = 0; i < pressures.length; i++) { + relativeVolume[i] = totalVolume[i] / saturationVolume; + System.out.println("rel volume " + relativeVolume[i]); } + System.out.println("test finished"); + } - /** - *

- * runTuning. - *

- */ - public void runTuning() { - ArrayList sampleList = new ArrayList(); + /** + *

+ * runTuning. + *

+ */ + public void runTuning() { + ArrayList sampleList = new ArrayList(); - try { - System.out.println("adding...."); + try { + System.out.println("adding...."); - for (int i = 0; i < experimentalData[0].length; i++) { - CVDFunction function = new CVDFunction(); - double[] guess = new double[] {234.0 / 1000.0};// getThermoSystem().getCharacterization().getPlusFractionModel().getMPlus()/1000.0}; - function.setInitialGuess(guess); + for (int i = 0; i < experimentalData[0].length; i++) { + CVDFunction function = new CVDFunction(); + double[] guess = new double[] {234.0 / 1000.0}; // getThermoSystem().getCharacterization().getPlusFractionModel().getMPlus()/1000.0}; + function.setInitialGuess(guess); - SystemInterface tempSystem = getThermoSystem(); // getThermoSystem().clone(); + SystemInterface tempSystem = getThermoSystem(); // getThermoSystem().clone(); - tempSystem.setTemperature(temperature); - tempSystem.setPressure(pressures[i]); - // thermoOps.TPflash(); - // tempSystem.display(); - double sample1[] = {temperatures[i], pressures[i]}; - double relativeVolume = experimentalData[0][i]; - double standardDeviation1[] = {1.5}; - SampleValue sample = new SampleValue(relativeVolume, relativeVolume / 50.0, sample1, - standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(tempSystem); - sampleList.add(sample); - } - } catch (Exception e) { - System.out.println("database error" + e); - } + tempSystem.setTemperature(temperature); + tempSystem.setPressure(pressures[i]); + // thermoOps.TPflash(); + // tempSystem.display(); + double[] sample1 = {temperatures[i], pressures[i]}; + double relativeVolume = experimentalData[0][i]; + double[] standardDeviation1 = {1.5}; + SampleValue sample = + new SampleValue(relativeVolume, relativeVolume / 50.0, sample1, standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(tempSystem); + sampleList.add(sample); + } + } catch (Exception e) { + System.out.println("database error" + e); + } - SampleSet sampleSet = new SampleSet(sampleList); + SampleSet sampleSet = new SampleSet(sampleList); - optimizer = new LevenbergMarquardt(); - optimizer.setMaxNumberOfIterations(20); + optimizer = new LevenbergMarquardt(); + optimizer.setMaxNumberOfIterations(20); - optimizer.setSampleSet(sampleSet); - optimizer.solve(); - runCalc(); - // optim.displayCurveFit(); - } + optimizer.setSampleSet(sampleSet); + optimizer.solve(); + runCalc(); + // optim.displayCurveFit(); + } - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + SystemInterface tempSystem = new SystemSrkEos(298.0, 211.0); + /* + * tempSystem.addComponent("nitrogen", 0.64); tempSystem.addComponent("CO2", 3.53); + * tempSystem.addComponent("methane", 70.78); tempSystem.addComponent("ethane", 8.94); + * tempSystem.addComponent("propane", 5.05); tempSystem.addComponent("i-butane", 0.85); + * tempSystem.addComponent("n-butane", 1.68); tempSystem.addComponent("iC5", 0.62); + * tempSystem.addComponent("n-pentane", 0.79); tempSystem.addComponent("n-hexane", 0.83); + * tempSystem.addTBPfraction("C7", 1.06, 92.2 / 1000.0, 0.7324); tempSystem.addTBPfraction("C8", + * 1.06, 104.6 / 1000.0, 0.7602); tempSystem.addTBPfraction("C9", 0.79, 119.1 / 1000.0, 0.7677); + * tempSystem.addTBPfraction("C10", 0.57, 133.0 / 1000.0, 0.79); + * tempSystem.addTBPfraction("C11", 0.38, 155.0 / 1000.0, 0.795); + * tempSystem.addTBPfraction("C12", 0.37, 162.0 / 1000.0, 0.806); + * tempSystem.addTBPfraction("C13", 0.32, 177.0 / 1000.0, 0.824); + * tempSystem.addTBPfraction("C14", 0.27, 198.0 / 1000.0, 0.835); + * tempSystem.addTBPfraction("C15", 0.23, 202.0 / 1000.0, 0.84); + * tempSystem.addTBPfraction("C16", 0.19, 215.0 / 1000.0, 0.846); + * tempSystem.addTBPfraction("C17", 0.17, 234.0 / 1000.0, 0.84); + * tempSystem.addTBPfraction("C18", 0.13, 251.0 / 1000.0, 0.844); + * tempSystem.addTBPfraction("C19", 0.13, 270.0 / 1000.0, 0.854); + * tempSystem.addPlusFraction("C20", 0.62, 381.0 / 1000.0, 0.88); + * tempSystem.getCharacterization().getLumpingModel(). setNumberOfLumpedComponents(6); + * tempSystem.getCharacterization().characterisePlusFraction(); */ - public static void main(String[] args) { - SystemInterface tempSystem = new SystemSrkEos(298.0, 211.0); - /* - * tempSystem.addComponent("nitrogen", 0.64); tempSystem.addComponent("CO2", 3.53); - * tempSystem.addComponent("methane", 70.78); tempSystem.addComponent("ethane", 8.94); - * tempSystem.addComponent("propane", 5.05); tempSystem.addComponent("i-butane", 0.85); - * tempSystem.addComponent("n-butane", 1.68); tempSystem.addComponent("iC5", 0.62); - * tempSystem.addComponent("n-pentane", 0.79); tempSystem.addComponent("n-hexane", 0.83); - * tempSystem.addTBPfraction("C7", 1.06, 92.2 / 1000.0, 0.7324); - * tempSystem.addTBPfraction("C8", 1.06, 104.6 / 1000.0, 0.7602); - * tempSystem.addTBPfraction("C9", 0.79, 119.1 / 1000.0, 0.7677); - * tempSystem.addTBPfraction("C10", 0.57, 133.0 / 1000.0, 0.79); - * tempSystem.addTBPfraction("C11", 0.38, 155.0 / 1000.0, 0.795); - * tempSystem.addTBPfraction("C12", 0.37, 162.0 / 1000.0, 0.806); - * tempSystem.addTBPfraction("C13", 0.32, 177.0 / 1000.0, 0.824); - * tempSystem.addTBPfraction("C14", 0.27, 198.0 / 1000.0, 0.835); - * tempSystem.addTBPfraction("C15", 0.23, 202.0 / 1000.0, 0.84); - * tempSystem.addTBPfraction("C16", 0.19, 215.0 / 1000.0, 0.846); - * tempSystem.addTBPfraction("C17", 0.17, 234.0 / 1000.0, 0.84); - * tempSystem.addTBPfraction("C18", 0.13, 251.0 / 1000.0, 0.844); - * tempSystem.addTBPfraction("C19", 0.13, 270.0 / 1000.0, 0.854); - * tempSystem.addPlusFraction("C20", 0.62, 381.0 / 1000.0, 0.88); - * tempSystem.getCharacterization().getLumpingModel(). setNumberOfLumpedComponents(6); - * tempSystem.getCharacterization().characterisePlusFraction(); - */ - // tempSystem.addComponent("methane", 70.78); - // tempSystem.addComponent("nC10", 5.83); - // tempSystem.createDatabase(true); - // tempSystem.setMixingRule(2); + // tempSystem.addComponent("methane", 70.78); + // tempSystem.addComponent("nC10", 5.83); + // tempSystem.createDatabase(true); + // tempSystem.setMixingRule(2); - // SystemInterface tempSystem = new SystemSrkEos(273.15 + 120, 100.0); - tempSystem.addComponent("nitrogen", 0.34); - tempSystem.addComponent("CO2", 3.59); - tempSystem.addComponent("methane", 67.42); - tempSystem.addComponent("ethane", 9.02); - tempSystem.addComponent("propane", 4.31); - tempSystem.addComponent("i-butane", 0.93); - tempSystem.addComponent("n-butane", 1.71); - tempSystem.addComponent("i-pentane", 0.74); - tempSystem.addComponent("n-pentane", 0.85); - tempSystem.addComponent("n-hexane", 1.38); - tempSystem.addTBPfraction("C7", 1.5, 109.00 / 1000.0, 0.6912); - tempSystem.addTBPfraction("C8", 1.69, 120.20 / 1000.0, 0.7255); - tempSystem.addTBPfraction("C9", 1.14, 129.5 / 1000.0, 0.7454); - tempSystem.addTBPfraction("C10", 0.8, 135.3 / 1000.0, 0.7864); - tempSystem.addPlusFraction("C11", 4.58, 256.2 / 1000.0, 0.8398); - // tempSystem.getCharacterization().characterisePlusFraction(); - tempSystem.createDatabase(true); - tempSystem.setMixingRule(2); - tempSystem.init(0); - tempSystem.init(1); + // SystemInterface tempSystem = new SystemSrkEos(273.15 + 120, 100.0); + tempSystem.addComponent("nitrogen", 0.34); + tempSystem.addComponent("CO2", 3.59); + tempSystem.addComponent("methane", 67.42); + tempSystem.addComponent("ethane", 9.02); + tempSystem.addComponent("propane", 4.31); + tempSystem.addComponent("i-butane", 0.93); + tempSystem.addComponent("n-butane", 1.71); + tempSystem.addComponent("i-pentane", 0.74); + tempSystem.addComponent("n-pentane", 0.85); + tempSystem.addComponent("n-hexane", 1.38); + tempSystem.addTBPfraction("C7", 1.5, 109.00 / 1000.0, 0.6912); + tempSystem.addTBPfraction("C8", 1.69, 120.20 / 1000.0, 0.7255); + tempSystem.addTBPfraction("C9", 1.14, 129.5 / 1000.0, 0.7454); + tempSystem.addTBPfraction("C10", 0.8, 135.3 / 1000.0, 0.7864); + tempSystem.addPlusFraction("C11", 4.58, 256.2 / 1000.0, 0.8398); + // tempSystem.getCharacterization().characterisePlusFraction(); + tempSystem.createDatabase(true); + tempSystem.setMixingRule(2); + tempSystem.init(0); + tempSystem.init(1); - ConstantVolumeDepletion CVDsim = new ConstantVolumeDepletion(tempSystem); - CVDsim.setTemperature(315.0); - CVDsim.setPressures(new double[] {400, 300.0, 200.0, 150.0, 100.0, 50.0}); - CVDsim.runCalc(); - CVDsim.setTemperaturesAndPressures(new double[] {313, 313, 313, 313}, - new double[] {400, 300.0, 200.0, 100.0}); - double[][] expData = {{0.95, 0.99, 1.0, 1.1}}; - CVDsim.setExperimentalData(expData); - // CVDsim.runTuning(); - } + ConstantVolumeDepletion CVDsim = new ConstantVolumeDepletion(tempSystem); + CVDsim.setTemperature(315.0); + CVDsim.setPressures(new double[] {400, 300.0, 200.0, 150.0, 100.0, 50.0}); + CVDsim.runCalc(); + CVDsim.setTemperaturesAndPressures(new double[] {313, 313, 313, 313}, + new double[] {400, 300.0, 200.0, 100.0}); + double[][] expData = {{0.95, 0.99, 1.0, 1.1}}; + CVDsim.setExperimentalData(expData); + // CVDsim.runTuning(); + } - /** - *

- * Getter for the field relativeVolume. - *

- * - * @return the relativeVolume - */ - public double[] getRelativeVolume() { - return relativeVolume; - } + /** + *

+ * Getter for the field relativeVolume. + *

+ * + * @return the relativeVolume + */ + public double[] getRelativeVolume() { + return relativeVolume; + } - /** {@inheritDoc} */ - @Override - public double getSaturationPressure() { - return saturationPressure; - } + /** {@inheritDoc} */ + @Override + public double getSaturationPressure() { + return saturationPressure; + } - /** - *

- * getZmix. - *

- * - * @return the Zmix - */ - public double[] getZmix() { - return Zmix; - } + /** + *

+ * getZmix. + *

+ * + * @return the Zmix + */ + public double[] getZmix() { + return Zmix; + } - /** - *

- * getZgas. - *

- * - * @return the Zgas - */ - public double[] getZgas() { - return Zgas; - } + /** + *

+ * getZgas. + *

+ * + * @return the Zgas + */ + public double[] getZgas() { + return Zgas; + } - /** - *

- * Getter for the field liquidRelativeVolume. - *

- * - * @return the liquidRelativeVolume - */ - public double[] getLiquidRelativeVolume() { - return liquidRelativeVolume; - } + /** + *

+ * Getter for the field liquidRelativeVolume. + *

+ * + * @return the liquidRelativeVolume + */ + public double[] getLiquidRelativeVolume() { + return liquidRelativeVolume; + } - /** - *

- * Getter for the field cummulativeMolePercDepleted. - *

- * - * @return the cummulativeMolePercDepleted - */ - public double[] getCummulativeMolePercDepleted() { - return cummulativeMolePercDepleted; - } + /** + *

+ * Getter for the field cummulativeMolePercDepleted. + *

+ * + * @return the cummulativeMolePercDepleted + */ + public double[] getCummulativeMolePercDepleted() { + return cummulativeMolePercDepleted; + } } diff --git a/src/main/java/neqsim/PVTsimulation/simulation/DensitySim.java b/src/main/java/neqsim/PVTsimulation/simulation/DensitySim.java index 24be5c0854..95f809c622 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/DensitySim.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/DensitySim.java @@ -67,7 +67,7 @@ public void runTuning() { for (int i = 0; i < experimentalData[0].length; i++) { ViscosityFunction function = new ViscosityFunction(); - double guess[] = {1.0};// getThermoSystem().getPhase(0).getComponent(0).getCriticalViscosity()}; + double guess[] = {1.0}; // getThermoSystem().getPhase(0).getComponent(0).getCriticalViscosity()}; function.setInitialGuess(guess); SystemInterface tempSystem = getThermoSystem(); // getThermoSystem().clone(); diff --git a/src/main/java/neqsim/PVTsimulation/simulation/SaturationPressure.java b/src/main/java/neqsim/PVTsimulation/simulation/SaturationPressure.java index 94914b1e42..bee0607ef4 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/SaturationPressure.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/SaturationPressure.java @@ -100,7 +100,7 @@ public static void main(String[] args) { tempSystem.addPlusFraction("C11", 4.58, 256.2 / 1000.0, 0.8398); tempSystem.getCharacterization().characterisePlusFraction(); tempSystem.createDatabase(true); - tempSystem.setMixingRule(9);// "HV", "UNIFAC_UMRPRU"); + tempSystem.setMixingRule(9); // "HV", "UNIFAC_UMRPRU"); tempSystem.init(0); tempSystem.init(1); //tempSystem.saveFluid(928); diff --git a/src/main/java/neqsim/PVTsimulation/simulation/SaturationTemperature.java b/src/main/java/neqsim/PVTsimulation/simulation/SaturationTemperature.java index 3e3a430149..fba7c60350 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/SaturationTemperature.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/SaturationTemperature.java @@ -12,99 +12,99 @@ * @version $Id: $Id */ public class SaturationTemperature extends BasePVTsimulation { - /** - *

- * Constructor for SaturationPressure. - *

- * - * @param tempSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - public SaturationTemperature(SystemInterface tempSystem) { - super(tempSystem); - } + /** + *

+ * Constructor for SaturationPressure. + *

+ * + * @param tempSystem a {@link neqsim.thermo.system.SystemInterface} object + */ + public SaturationTemperature(SystemInterface tempSystem) { + super(tempSystem); + } - /** - *

- * calcSaturationPressure. - *

- * - * @return a double - */ - public double calcSaturationTemperature() { - getThermoSystem().isImplementedCompositionDeriativesofFugacity(false); - do { - getThermoSystem().setTemperature(getThermoSystem().getTemperature() - 10.0); - thermoOps.TPflash(); - } while (getThermoSystem().getNumberOfPhases() == 1 - && getThermoSystem().getTemperature() > 30.0); - do { - getThermoSystem().setTemperature(getThermoSystem().getTemperature() + 10.0); - thermoOps.TPflash(); - } while (getThermoSystem().getNumberOfPhases() > 1 - && getThermoSystem().getTemperature() < 1200.0); - double minTemp = getThermoSystem().getTemperature() - 10.0; - double maxTemp = getThermoSystem().getTemperature(); - int iteration = 0; - do { - iteration++; - getThermoSystem().setTemperature((minTemp + maxTemp) / 2.0); - thermoOps.TPflash(); - if (getThermoSystem().getNumberOfPhases() > 1) { - minTemp = getThermoSystem().getTemperature(); - } else { - maxTemp = getThermoSystem().getTemperature(); - } - } while (Math.abs(maxTemp - minTemp) > 1e-5 && iteration < 500); - getThermoSystem().setTemperature(maxTemp); - thermoOps.TPflash(); - return getThermoSystem().getTemperature(); - } + /** + *

+ * calcSaturationPressure. + *

+ * + * @return a double + */ + public double calcSaturationTemperature() { + getThermoSystem().isImplementedCompositionDeriativesofFugacity(false); + do { + getThermoSystem().setTemperature(getThermoSystem().getTemperature() - 10.0); + thermoOps.TPflash(); + } while (getThermoSystem().getNumberOfPhases() == 1 + && getThermoSystem().getTemperature() > 30.0); + do { + getThermoSystem().setTemperature(getThermoSystem().getTemperature() + 10.0); + thermoOps.TPflash(); + } while (getThermoSystem().getNumberOfPhases() > 1 + && getThermoSystem().getTemperature() < 1200.0); + double minTemp = getThermoSystem().getTemperature() - 10.0; + double maxTemp = getThermoSystem().getTemperature(); + int iteration = 0; + do { + iteration++; + getThermoSystem().setTemperature((minTemp + maxTemp) / 2.0); + thermoOps.TPflash(); + if (getThermoSystem().getNumberOfPhases() > 1) { + minTemp = getThermoSystem().getTemperature(); + } else { + maxTemp = getThermoSystem().getTemperature(); + } + } while (Math.abs(maxTemp - minTemp) > 1e-5 && iteration < 500); + getThermoSystem().setTemperature(maxTemp); + thermoOps.TPflash(); + return getThermoSystem().getTemperature(); + } - /** {@inheritDoc} */ - @Override - public void run() { - super.run(); - saturationTemperature = calcSaturationTemperature(); - } + /** {@inheritDoc} */ + @Override + public void run() { + super.run(); + saturationTemperature = calcSaturationTemperature(); + } - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - SystemInterface tempSystem = new SystemSrkEos(273.15 + 20, 60.0); - tempSystem.addComponent("nitrogen", 0.34); - tempSystem.addComponent("CO2", 3.59); - tempSystem.addComponent("methane", 67.42); - tempSystem.addComponent("ethane", 9.02); - tempSystem.addComponent("propane", 4.31); - tempSystem.addComponent("i-butane", 0.93); - tempSystem.addComponent("n-butane", 1.71); - tempSystem.addComponent("i-pentane", 0.74); - tempSystem.addComponent("n-pentane", 0.85); - tempSystem.addComponent("n-hexane", 0.38); - tempSystem.addTBPfraction("C7", 0.5, 109.00 / 1000.0, 0.6912); - tempSystem.addTBPfraction("C8", 0.69, 120.20 / 1000.0, 0.7255); - tempSystem.addTBPfraction("C9", 0.14, 129.5 / 1000.0, 0.7454); - tempSystem.addTBPfraction("C10", 0.08, 135.3 / 1000.0, 0.7864); - //tempSystem.createDatabase(true); - tempSystem.setMixingRule(2);// "HV", "UNIFAC_UMRPRU"); - tempSystem.init(0); - tempSystem.init(1); - // tempSystem.saveFluid(928); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + SystemInterface tempSystem = new SystemSrkEos(273.15 + 20, 60.0); + tempSystem.addComponent("nitrogen", 0.34); + tempSystem.addComponent("CO2", 3.59); + tempSystem.addComponent("methane", 67.42); + tempSystem.addComponent("ethane", 9.02); + tempSystem.addComponent("propane", 4.31); + tempSystem.addComponent("i-butane", 0.93); + tempSystem.addComponent("n-butane", 1.71); + tempSystem.addComponent("i-pentane", 0.74); + tempSystem.addComponent("n-pentane", 0.85); + tempSystem.addComponent("n-hexane", 0.38); + tempSystem.addTBPfraction("C7", 0.5, 109.00 / 1000.0, 0.6912); + tempSystem.addTBPfraction("C8", 0.69, 120.20 / 1000.0, 0.7255); + tempSystem.addTBPfraction("C9", 0.14, 129.5 / 1000.0, 0.7454); + tempSystem.addTBPfraction("C10", 0.08, 135.3 / 1000.0, 0.7864); + // tempSystem.createDatabase(true); + tempSystem.setMixingRule(2); // "HV", "UNIFAC_UMRPRU"); + tempSystem.init(0); + tempSystem.init(1); + // tempSystem.saveFluid(928); - SimulationInterface satPresSim = new SaturationTemperature(tempSystem); - satPresSim.run(); - satPresSim.getThermoSystem().display(); - /* - * double saturationPressure = 350.0; double saturationTemperature = 273.15 + 80; - * - * TuningInterface tuning = new TuneToSaturation(satPresSim); - * tuning.setSaturationConditions(saturationTemperature, saturationPressure); tuning.run(); - * tuning.getSimulation().getThermoSystem().display(); - */ - } + SimulationInterface satPresSim = new SaturationTemperature(tempSystem); + satPresSim.run(); + satPresSim.getThermoSystem().display(); + /* + * double saturationPressure = 350.0; double saturationTemperature = 273.15 + 80; + * + * TuningInterface tuning = new TuneToSaturation(satPresSim); + * tuning.setSaturationConditions(saturationTemperature, saturationPressure); tuning.run(); + * tuning.getSimulation().getThermoSystem().display(); + */ + } } diff --git a/src/main/java/neqsim/PVTsimulation/simulation/ViscositySim.java b/src/main/java/neqsim/PVTsimulation/simulation/ViscositySim.java index 7e7b6e40e1..3c9686b1c0 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/ViscositySim.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/ViscositySim.java @@ -67,7 +67,7 @@ public void runTuning() { for (int i = 0; i < experimentalData[0].length; i++) { ViscosityFunction function = new ViscosityFunction(); - double guess[] = {1.0};// getThermoSystem().getPhase(0).getComponent(0).getCriticalViscosity()}; + double guess[] = {1.0}; // getThermoSystem().getPhase(0).getComponent(0).getCriticalViscosity()}; function.setInitialGuess(guess); SystemInterface tempSystem = getThermoSystem().clone(); diff --git a/src/main/java/neqsim/PVTsimulation/simulation/ViscosityWaxOilSim.java b/src/main/java/neqsim/PVTsimulation/simulation/ViscosityWaxOilSim.java index 4781035202..a72af517d5 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/ViscosityWaxOilSim.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/ViscosityWaxOilSim.java @@ -17,247 +17,247 @@ * @version $Id: $Id */ public class ViscosityWaxOilSim extends BasePVTsimulation { - double[] temperature = null; + double[] temperature = null; - double[] pressure = null; - private double[] waxFraction = null; - private double[] gasViscosity; - private double[] oilViscosity, oilwaxDispersionViscosity; - private double[] aqueousViscosity; - private double[] shareRate; + double[] pressure = null; + private double[] waxFraction = null; + private double[] gasViscosity; + private double[] oilViscosity; - /** - *

- * Constructor for ViscosityWaxOilSim. - *

- * - * @param tempSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - public ViscosityWaxOilSim(SystemInterface tempSystem) { - super(tempSystem); - temperature = new double[1]; - pressure = new double[1]; - temperature[0] = tempSystem.getTemperature(); - pressure[0] = tempSystem.getPressure(); - } - - /** - *

- * setTemperaturesAndPressures. - *

- * - * @param temperature an array of {@link double} objects - * @param pressure an array of {@link double} objects - */ - public void setTemperaturesAndPressures(double[] temperature, double[] pressure) { - this.pressure = pressure; - this.temperature = temperature; - experimentalData = new double[temperature.length][1]; - } + private double[] oilwaxDispersionViscosity; - /** - *

- * runTuning. - *

- */ - public void runTuning() { - ArrayList sampleList = new ArrayList(); + private double[] aqueousViscosity; + private double[] shareRate; - try { - System.out.println("adding...."); + /** + *

+ * Constructor for ViscosityWaxOilSim. + *

+ * + * @param tempSystem a {@link neqsim.thermo.system.SystemInterface} object + */ + public ViscosityWaxOilSim(SystemInterface tempSystem) { + super(tempSystem); + temperature = new double[1]; + pressure = new double[1]; + temperature[0] = tempSystem.getTemperature(); + pressure[0] = tempSystem.getPressure(); + } - for (int i = 0; i < experimentalData[0].length; i++) { - ViscosityFunction function = new ViscosityFunction(); - double guess[] = {1.0};// getThermoSystem().getPhase(0).getComponent(0).getCriticalViscosity()}; - function.setInitialGuess(guess); + /** + *

+ * setTemperaturesAndPressures. + *

+ * + * @param temperature an array of {@link double} objects + * @param pressure an array of {@link double} objects + */ + public void setTemperaturesAndPressures(double[] temperature, double[] pressure) { + this.pressure = pressure; + this.temperature = temperature; + experimentalData = new double[temperature.length][1]; + } - SystemInterface tempSystem = getThermoSystem().clone(); + /** + *

+ * runTuning. + *

+ */ + public void runTuning() { + ArrayList sampleList = new ArrayList(); - tempSystem.setTemperature(temperature[i]); - tempSystem.setPressure(pressure[i]); - thermoOps.TPflash(); - // tempSystem.display(); - double sample1[] = {shareRate[i]}; - double viscosity = experimentalData[0][i]; - double standardDeviation1[] = {1.5}; - SampleValue sample = - new SampleValue(viscosity, viscosity / 50.0, sample1, standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(tempSystem); - sampleList.add(sample); - } - } catch (Exception e) { - System.out.println("database error" + e); - } + try { + System.out.println("adding...."); - SampleSet sampleSet = new SampleSet(sampleList); + for (int i = 0; i < experimentalData[0].length; i++) { + ViscosityFunction function = new ViscosityFunction(); + double[] guess = {1.0}; // getThermoSystem().getPhase(0).getComponent(0).getCriticalViscosity()}; + function.setInitialGuess(guess); - optimizer = new LevenbergMarquardt(); - optimizer.setMaxNumberOfIterations(20); + SystemInterface tempSystem = getThermoSystem().clone(); - optimizer.setSampleSet(sampleSet); - optimizer.solve(); - runCalc(); - optimizer.displayCurveFit(); + tempSystem.setTemperature(temperature[i]); + tempSystem.setPressure(pressure[i]); + thermoOps.TPflash(); + // tempSystem.display(); + double[] sample1 = {shareRate[i]}; + double viscosity = experimentalData[0][i]; + double[] standardDeviation1 = {1.5}; + SampleValue sample = + new SampleValue(viscosity, viscosity / 50.0, sample1, standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(tempSystem); + sampleList.add(sample); + } + } catch (Exception e) { + System.out.println("database error" + e); } - /** - *

- * runCalc. - *

- */ - public void runCalc() { - gasViscosity = new double[pressure.length]; - oilViscosity = new double[pressure.length]; - aqueousViscosity = new double[pressure.length]; - waxFraction = new double[pressure.length]; - oilwaxDispersionViscosity = new double[pressure.length]; + SampleSet sampleSet = new SampleSet(sampleList); + + optimizer = new LevenbergMarquardt(); + optimizer.setMaxNumberOfIterations(20); - for (int i = 0; i < pressure.length; i++) { - // thermoOps.setSystem(getThermoSystem()); - getThermoSystem().setPressure(pressure[i]); - getThermoSystem().setTemperature(temperature[i]); - thermoOps.TPflash(); - getThermoSystem().initPhysicalProperties(); - waxFraction[i] = 0.0; - if (getThermoSystem().hasPhaseType("wax") && getThermoSystem().hasPhaseType("oil")) { - waxFraction[i] = getThermoSystem() - .getWtFraction(getThermoSystem().getPhaseNumberOfPhase("wax")); - oilwaxDispersionViscosity[i] = - getThermoSystem().getPhase("oil").getPhysicalProperties() - .getViscosityOfWaxyOil(waxFraction[i], getShareRate()[i]); - } - if (getThermoSystem().hasPhaseType("gas")) { - gasViscosity[i] = - getThermoSystem().getPhase("gas").getPhysicalProperties().getViscosity(); - } - if (getThermoSystem().hasPhaseType("oil")) { - oilViscosity[i] = - getThermoSystem().getPhase("oil").getPhysicalProperties().getViscosity(); - } - if (getThermoSystem().hasPhaseType("aqueous")) { - aqueousViscosity[i] = getThermoSystem().getPhase("aqueous").getPhysicalProperties() - .getViscosity(); - } - } + optimizer.setSampleSet(sampleSet); + optimizer.solve(); + runCalc(); + optimizer.displayCurveFit(); + } + + /** + *

+ * runCalc. + *

+ */ + public void runCalc() { + gasViscosity = new double[pressure.length]; + oilViscosity = new double[pressure.length]; + aqueousViscosity = new double[pressure.length]; + waxFraction = new double[pressure.length]; + oilwaxDispersionViscosity = new double[pressure.length]; + + for (int i = 0; i < pressure.length; i++) { + // thermoOps.setSystem(getThermoSystem()); + getThermoSystem().setPressure(pressure[i]); + getThermoSystem().setTemperature(temperature[i]); + thermoOps.TPflash(); + getThermoSystem().initPhysicalProperties(); + waxFraction[i] = 0.0; + if (getThermoSystem().hasPhaseType("wax") && getThermoSystem().hasPhaseType("oil")) { + waxFraction[i] = + getThermoSystem().getWtFraction(getThermoSystem().getPhaseNumberOfPhase("wax")); + oilwaxDispersionViscosity[i] = getThermoSystem().getPhase("oil").getPhysicalProperties() + .getViscosityOfWaxyOil(waxFraction[i], getShareRate()[i]); + } + if (getThermoSystem().hasPhaseType("gas")) { + gasViscosity[i] = getThermoSystem().getPhase("gas").getPhysicalProperties().getViscosity(); + } + if (getThermoSystem().hasPhaseType("oil")) { + oilViscosity[i] = getThermoSystem().getPhase("oil").getPhysicalProperties().getViscosity(); + } + if (getThermoSystem().hasPhaseType("aqueous")) { + aqueousViscosity[i] = + getThermoSystem().getPhase("aqueous").getPhysicalProperties().getViscosity(); + } } + } - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - @SuppressWarnings("unused") - public static void main(String[] args) { - SystemInterface tempSystem = new SystemSrkEos(298.0, 10.0); - // tempSystem.addComponent("n-heptane", 6.78); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String[] args) { + SystemInterface tempSystem = new SystemSrkEos(298.0, 10.0); + // tempSystem.addComponent("n-heptane", 6.78); - tempSystem.addTBPfraction("C19", 10.13, 270.0 / 1000.0, 0.814); - tempSystem.addPlusFraction("C20", 10.62, 330.0 / 1000.0, 0.83); + tempSystem.addTBPfraction("C19", 10.13, 270.0 / 1000.0, 0.814); + tempSystem.addPlusFraction("C20", 10.62, 330.0 / 1000.0, 0.83); - tempSystem.getCharacterization().characterisePlusFraction(); - tempSystem.getWaxModel().addTBPWax(); - tempSystem.createDatabase(true); - tempSystem.setMixingRule(2); - // tempSystem.addSolidComplexPhase("wax"); - // tempSystem.setMultiphaseWaxCheck(true); - // tempSystem.setMultiPhaseCheck(true); - tempSystem.init(0); - tempSystem.init(1); + tempSystem.getCharacterization().characterisePlusFraction(); + tempSystem.getWaxModel().addTBPWax(); + tempSystem.createDatabase(true); + tempSystem.setMixingRule(2); + // tempSystem.addSolidComplexPhase("wax"); + // tempSystem.setMultiphaseWaxCheck(true); + // tempSystem.setMultiPhaseCheck(true); + tempSystem.init(0); + tempSystem.init(1); - ViscosityWaxOilSim sepSim = new ViscosityWaxOilSim(tempSystem); - double[] temps = {300.15, 293.15, 283.15, 273.15, 264.15}; - double[] pres = {5, 5, 5, 5.0, 5.0}; - sepSim.setTemperaturesAndPressures(temps, pres); - sepSim.setShareRate(new double[] {0, 0, 0, 100, 100}); - sepSim.runCalc(); + ViscosityWaxOilSim sepSim = new ViscosityWaxOilSim(tempSystem); + double[] temps = {300.15, 293.15, 283.15, 273.15, 264.15}; + double[] pres = {5, 5, 5, 5.0, 5.0}; + sepSim.setTemperaturesAndPressures(temps, pres); + sepSim.setShareRate(new double[] {0, 0, 0, 100, 100}); + sepSim.runCalc(); - double[][] expData = {{2e-4, 3e-4, 4e-4, 5e-4, 6e-4},}; - sepSim.setExperimentalData(expData); - sepSim.runTuning(); - // sepSim.runCalc(); - double a = sepSim.getGasViscosity()[0]; - double a2 = sepSim.getOilViscosity()[0]; - sepSim.getThermoSystem().display(); - // sepSim.tuneModel(exptemperatures, exppressures, expwaxFrations); - } + double[][] expData = {{2e-4, 3e-4, 4e-4, 5e-4, 6e-4},}; + sepSim.setExperimentalData(expData); + sepSim.runTuning(); + // sepSim.runCalc(); + double a = sepSim.getGasViscosity()[0]; + double a2 = sepSim.getOilViscosity()[0]; + sepSim.getThermoSystem().display(); + // sepSim.tuneModel(exptemperatures, exppressures, expwaxFrations); + } - /** - *

- * Getter for the field waxFraction. - *

- * - * @return the waxFraction - */ - public double[] getWaxFraction() { - return waxFraction; - } + /** + *

+ * Getter for the field waxFraction. + *

+ * + * @return the waxFraction + */ + public double[] getWaxFraction() { + return waxFraction; + } - /** - *

- * Getter for the field gasViscosity. - *

- * - * @return the gasViscosity - */ - public double[] getGasViscosity() { - return gasViscosity; - } + /** + *

+ * Getter for the field gasViscosity. + *

+ * + * @return the gasViscosity + */ + public double[] getGasViscosity() { + return gasViscosity; + } - /** - *

- * Getter for the field oilViscosity. - *

- * - * @return the oilViscosity - */ - public double[] getOilViscosity() { - return oilViscosity; - } + /** + *

+ * Getter for the field oilViscosity. + *

+ * + * @return the oilViscosity + */ + public double[] getOilViscosity() { + return oilViscosity; + } - /** - *

- * Getter for the field aqueousViscosity. - *

- * - * @return the aqueousViscosity - */ - public double[] getAqueousViscosity() { - return aqueousViscosity; - } + /** + *

+ * Getter for the field aqueousViscosity. + *

+ * + * @return the aqueousViscosity + */ + public double[] getAqueousViscosity() { + return aqueousViscosity; + } - /** - *

- * Getter for the field shareRate. - *

- * - * @return the shareRate - */ - public double[] getShareRate() { - return shareRate; - } + /** + *

+ * Getter for the field shareRate. + *

+ * + * @return the shareRate + */ + public double[] getShareRate() { + return shareRate; + } - /** - *

- * Setter for the field shareRate. - *

- * - * @param shareRate the shareRate to set - */ - public void setShareRate(double[] shareRate) { - this.shareRate = shareRate; - } + /** + *

+ * Setter for the field shareRate. + *

+ * + * @param shareRate the shareRate to set + */ + public void setShareRate(double[] shareRate) { + this.shareRate = shareRate; + } - /** - *

- * Getter for the field oilwaxDispersionViscosity. - *

- * - * @return the oilwaxDispersionViscosity - */ - public double[] getOilwaxDispersionViscosity() { - return oilwaxDispersionViscosity; - } + /** + *

+ * Getter for the field oilwaxDispersionViscosity. + *

+ * + * @return the oilwaxDispersionViscosity + */ + public double[] getOilwaxDispersionViscosity() { + return oilwaxDispersionViscosity; + } } diff --git a/src/main/java/neqsim/PVTsimulation/simulation/WaxFractionSim.java b/src/main/java/neqsim/PVTsimulation/simulation/WaxFractionSim.java index 12f2491752..9314f58f16 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/WaxFractionSim.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/WaxFractionSim.java @@ -17,204 +17,206 @@ * @version $Id: $Id */ public class WaxFractionSim extends BasePVTsimulation { - double[] temperature = null; - - double[] pressure = null; - private double[] waxFraction = null; - double[] Sm3gas, m3oil; - private double[] Bofactor; - private double[] GOR = null; - double oilVolumeStdCond = 0; - - /** - *

- * Constructor for WaxFractionSim. - *

- * - * @param tempSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - public WaxFractionSim(SystemInterface tempSystem) { - super(tempSystem); - temperature = new double[1]; - pressure = new double[1]; - temperature[0] = tempSystem.getTemperature(); - pressure[0] = tempSystem.getPressure(); - } - - /** - *

- * setTemperaturesAndPressures. - *

- * - * @param temperature an array of {@link double} objects - * @param pressure an array of {@link double} objects - */ - public void setTemperaturesAndPressures(double[] temperature, double[] pressure) { - this.pressure = pressure; - this.temperature = temperature; - experimentalData = new double[temperature.length][1]; - } - - /** - *

- * runTuning. - *

- */ - public void runTuning() { - ArrayList sampleList = new ArrayList(); - - try { - System.out.println("adding...."); - - for (int i = 0; i < experimentalData[0].length; i++) { - WaxFunction function = new WaxFunction(); - double guess[] = new double[optimizer.getNumberOfTuningParameters()];// getThermoSystem().getWaxModel().getWaxParameters(); - - ArrayList guessArray = new ArrayList(); - for (int p = 0; p < 3; p++) { - guessArray.add(getThermoSystem().getWaxModel().getWaxParameters()[p]); - } - guessArray.add(getThermoSystem().getWaxModel().getParameterWaxHeatOfFusion()[0]); - guessArray.add( - getThermoSystem().getWaxModel().getParameterWaxTriplePointTemperature()[0]); - - for (int o = 0; o < guess.length; o++) { - guess[o] = guessArray.get(o); - } - // guess = guessArray.subList(0, optimizer.getNumberOfTuningParameters()-1); - - function.setInitialGuess(guess); - - SystemInterface tempSystem = getThermoSystem(); // getThermoSystem().clone(); - - tempSystem.setTemperature(temperature[i]); - tempSystem.setPressure(pressure[i]); - thermoOps.TPflash(); - // tempSystem.display(); - double sample1[] = {temperature[i]}; - double waxContent = experimentalData[0][i]; - double standardDeviation1[] = {1.5}; - SampleValue sample = new SampleValue(waxContent, waxContent / 10.0 + 0.1, sample1, - standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(tempSystem); - sampleList.add(sample); - } - } catch (Exception e) { - System.out.println("database error" + e); + double[] temperature = null; + + double[] pressure = null; + private double[] waxFraction = null; + double[] Sm3gas; + + double[] m3oil; + + private double[] Bofactor; + private double[] GOR = null; + double oilVolumeStdCond = 0; + + /** + *

+ * Constructor for WaxFractionSim. + *

+ * + * @param tempSystem a {@link neqsim.thermo.system.SystemInterface} object + */ + public WaxFractionSim(SystemInterface tempSystem) { + super(tempSystem); + temperature = new double[1]; + pressure = new double[1]; + temperature[0] = tempSystem.getTemperature(); + pressure[0] = tempSystem.getPressure(); + } + + /** + *

+ * setTemperaturesAndPressures. + *

+ * + * @param temperature an array of {@link double} objects + * @param pressure an array of {@link double} objects + */ + public void setTemperaturesAndPressures(double[] temperature, double[] pressure) { + this.pressure = pressure; + this.temperature = temperature; + experimentalData = new double[temperature.length][1]; + } + + /** + *

+ * runTuning. + *

+ */ + public void runTuning() { + ArrayList sampleList = new ArrayList(); + + try { + System.out.println("adding...."); + + for (int i = 0; i < experimentalData[0].length; i++) { + WaxFunction function = new WaxFunction(); + double[] guess = new double[optimizer.getNumberOfTuningParameters()]; // getThermoSystem().getWaxModel().getWaxParameters(); + + ArrayList guessArray = new ArrayList(); + for (int p = 0; p < 3; p++) { + guessArray.add(getThermoSystem().getWaxModel().getWaxParameters()[p]); } + guessArray.add(getThermoSystem().getWaxModel().getParameterWaxHeatOfFusion()[0]); + guessArray.add(getThermoSystem().getWaxModel().getParameterWaxTriplePointTemperature()[0]); - SampleSet sampleSet = new SampleSet(sampleList); - - optimizer.setSampleSet(sampleSet); - optimizer.solve(); - // runCalc(); - // optim.displayCurveFit(); - } - - /** - *

- * runCalc. - *

- */ - public void runCalc() { - Sm3gas = new double[pressure.length]; - m3oil = new double[pressure.length]; - GOR = new double[pressure.length]; - waxFraction = new double[pressure.length]; - Bofactor = new double[pressure.length]; - for (int i = 0; i < pressure.length; i++) { - // thermoOps.setSystem(getThermoSystem()); - getThermoSystem().setPressure(pressure[i]); - getThermoSystem().setTemperature(temperature[i]); - thermoOps.TPflash(); - waxFraction[i] = 0.0; - if (getThermoSystem().hasPhaseType("wax")) { - waxFraction[i] = getThermoSystem() - .getWtFraction(getThermoSystem().getPhaseNumberOfPhase("wax")); - } - // System.out.println("wax fraction " + waxFraction[i]); + for (int o = 0; o < guess.length; o++) { + guess[o] = guessArray.get(o); } + // guess = guessArray.subList(0, optimizer.getNumberOfTuningParameters()-1); + + function.setInitialGuess(guess); + + SystemInterface tempSystem = getThermoSystem(); // getThermoSystem().clone(); + + tempSystem.setTemperature(temperature[i]); + tempSystem.setPressure(pressure[i]); + thermoOps.TPflash(); + // tempSystem.display(); + double[] sample1 = {temperature[i]}; + double waxContent = experimentalData[0][i]; + double[] standardDeviation1 = {1.5}; + SampleValue sample = + new SampleValue(waxContent, waxContent / 10.0 + 0.1, sample1, standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(tempSystem); + sampleList.add(sample); + } + } catch (Exception e) { + System.out.println("database error" + e); } - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - NeqSimDataBase.setConnectionString( - "jdbc:derby:C:/Users/esol/OneDrive - Equinor/temp/neqsimthermodatabase"); - NeqSimDataBase.setCreateTemporaryTables(true); - - SystemInterface tempSystem = new SystemSrkEos(298.0, 10.0); - tempSystem.addComponent("methane", 6.78); - - tempSystem.addTBPfraction("C19", 10.13, 170.0 / 1000.0, 0.7814); - tempSystem.addPlusFraction("C20", 10.62, 381.0 / 1000.0, 0.850871882888); - - tempSystem.getCharacterization().characterisePlusFraction(); - tempSystem.getWaxModel().addTBPWax(); - tempSystem.createDatabase(true); - tempSystem.setMixingRule(2); - tempSystem.addSolidComplexPhase("wax"); - tempSystem.setMultiphaseWaxCheck(true); - tempSystem.setMultiPhaseCheck(true); - tempSystem.init(0); - tempSystem.init(1); - - WaxFractionSim sepSim = new WaxFractionSim(tempSystem); - double[] temps = {293.15, 283.15, 273.15, 264.15, 263, 262, 261}; - double[] pres = {5, 5, 5.0, 5.0, 5.0, 5.0, 5.0}; - sepSim.setTemperaturesAndPressures(temps, pres); - - sepSim.runCalc(); - sepSim.getThermoSystem().display(); - double[][] expData = {{4, 7, 9, 10, 11, 12, 13}}; - sepSim.setExperimentalData(expData); - // String[] params = {"Mplus", "waxParam1", "waxParam2"}; - // sepSim.getOptimizer().setTuningParameters("") - sepSim.getOptimizer().setNumberOfTuningParameters(3); - sepSim.getOptimizer().setMaxNumberOfIterations(20); - sepSim.runTuning(); - sepSim.runCalc(); - // double a = sepSim.getWaxFraction()[0]; - - // sepSim.tuneModel(exptemperatures, exppressures, expwaxFrations); - } - - /** - *

- * getGOR. - *

- * - * @return the GOR - */ - public double[] getGOR() { - return GOR; - } - - /** - *

- * getBofactor. - *

- * - * @return the Bofactor - */ - public double[] getBofactor() { - return Bofactor; - } - - /** - *

- * Getter for the field waxFraction. - *

- * - * @return the waxFraction - */ - public double[] getWaxFraction() { - return waxFraction; + SampleSet sampleSet = new SampleSet(sampleList); + + optimizer.setSampleSet(sampleSet); + optimizer.solve(); + // runCalc(); + // optim.displayCurveFit(); + } + + /** + *

+ * runCalc. + *

+ */ + public void runCalc() { + Sm3gas = new double[pressure.length]; + m3oil = new double[pressure.length]; + GOR = new double[pressure.length]; + waxFraction = new double[pressure.length]; + Bofactor = new double[pressure.length]; + for (int i = 0; i < pressure.length; i++) { + // thermoOps.setSystem(getThermoSystem()); + getThermoSystem().setPressure(pressure[i]); + getThermoSystem().setTemperature(temperature[i]); + thermoOps.TPflash(); + waxFraction[i] = 0.0; + if (getThermoSystem().hasPhaseType("wax")) { + waxFraction[i] = + getThermoSystem().getWtFraction(getThermoSystem().getPhaseNumberOfPhase("wax")); + } + // System.out.println("wax fraction " + waxFraction[i]); } + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + NeqSimDataBase.setConnectionString( + "jdbc:derby:C:/Users/esol/OneDrive - Equinor/temp/neqsimthermodatabase"); + NeqSimDataBase.setCreateTemporaryTables(true); + + SystemInterface tempSystem = new SystemSrkEos(298.0, 10.0); + tempSystem.addComponent("methane", 6.78); + + tempSystem.addTBPfraction("C19", 10.13, 170.0 / 1000.0, 0.7814); + tempSystem.addPlusFraction("C20", 10.62, 381.0 / 1000.0, 0.850871882888); + + tempSystem.getCharacterization().characterisePlusFraction(); + tempSystem.getWaxModel().addTBPWax(); + tempSystem.createDatabase(true); + tempSystem.setMixingRule(2); + tempSystem.addSolidComplexPhase("wax"); + tempSystem.setMultiphaseWaxCheck(true); + tempSystem.setMultiPhaseCheck(true); + tempSystem.init(0); + tempSystem.init(1); + + WaxFractionSim sepSim = new WaxFractionSim(tempSystem); + double[] temps = {293.15, 283.15, 273.15, 264.15, 263, 262, 261}; + double[] pres = {5, 5, 5.0, 5.0, 5.0, 5.0, 5.0}; + sepSim.setTemperaturesAndPressures(temps, pres); + + sepSim.runCalc(); + sepSim.getThermoSystem().display(); + double[][] expData = {{4, 7, 9, 10, 11, 12, 13}}; + sepSim.setExperimentalData(expData); + // String[] params = {"Mplus", "waxParam1", "waxParam2"}; + // sepSim.getOptimizer().setTuningParameters("") + sepSim.getOptimizer().setNumberOfTuningParameters(3); + sepSim.getOptimizer().setMaxNumberOfIterations(20); + sepSim.runTuning(); + sepSim.runCalc(); + // double a = sepSim.getWaxFraction()[0]; + + // sepSim.tuneModel(exptemperatures, exppressures, expwaxFrations); + } + + /** + *

+ * getGOR. + *

+ * + * @return the GOR + */ + public double[] getGOR() { + return GOR; + } + + /** + *

+ * getBofactor. + *

+ * + * @return the Bofactor + */ + public double[] getBofactor() { + return Bofactor; + } + + /** + *

+ * Getter for the field waxFraction. + *

+ * + * @return the waxFraction + */ + public double[] getWaxFraction() { + return waxFraction; + } } diff --git a/src/main/java/neqsim/chemicalReactions/ChemicalReactionOperations.java b/src/main/java/neqsim/chemicalReactions/ChemicalReactionOperations.java index ee78177baa..04a1521b81 100644 --- a/src/main/java/neqsim/chemicalReactions/ChemicalReactionOperations.java +++ b/src/main/java/neqsim/chemicalReactions/ChemicalReactionOperations.java @@ -377,7 +377,7 @@ public void updateMoles(int phase) { } } // System.out.println("change " + changeMoles); - system.initTotalNumberOfMoles(changeMoles);// x_solve.get(NELE,0)*n_t); + system.initTotalNumberOfMoles(changeMoles); // x_solve.get(NELE,0)*n_t); system.initBeta(); // this was added for mass trans calc system.init_x_y(); system.init(1); diff --git a/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/ChemEq.java b/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/ChemEq.java index ba2bb42e1f..f254477b6a 100644 --- a/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/ChemEq.java +++ b/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/ChemEq.java @@ -11,406 +11,415 @@ * @version $Id: $Id */ public class ChemEq implements java.io.Serializable { - private static final long serialVersionUID = 1000; - int NSPEC = 10, NELE = 3; - double R = 8.3143, G_min = 0; - - double T = 3500, P = 51, n_t, agemo = 0; - // double [][] A_matrix = new double[NSPEC][NELE]; - // double n_mol[] = new double[NSPEC]; - // double chem_ref[] = new double[NSPEC]; - double d_n[]; - double phi[] = new double[3]; - // double b_element[] = new double[NELE]; - - double[][] A_matrix; - double n_mol[]; - double chem_ref[]; - double b_element[]; - - int NNOT = 4; - int i, j, k; - // int zeile_matrix, spalte_matrix, zeile_b, spalte_b; - double[] b_cal; - double[] b_vector; - double[] second_term; - double[] chem_pot; - double u_u, sum, step; - double[][] matrix; - - /** - *

- * Constructor for ChemEq. - *

- */ - public ChemEq() { - for (int i = 0; i < 10; i++) { - chem_ref[i] += Math.log(P); - } + private static final long serialVersionUID = 1000; + int NSPEC = 10; + int NELE = 3; + double R = 8.3143; + double G_min = 0; + double T = 3500; + double P = 51; + double n_t; + double agemo = 0; + // double [][] A_matrix = new double[NSPEC][NELE]; + // double n_mol[] = new double[NSPEC]; + // double chem_ref[] = new double[NSPEC]; + double[] d_n; + double[] phi = new double[3]; + // double b_element[] = new double[NELE]; + + double[][] A_matrix; + double[] n_mol; + double[] chem_ref; + double[] b_element; + + int NNOT = 4; + int i; + int j; + int k; + // int zeile_matrix, spalte_matrix, zeile_b, spalte_b; + double[] b_cal; + double[] b_vector; + double[] second_term; + double[] chem_pot; + double u_u; + double sum; + double step; + double[][] matrix; + + /** + *

+ * Constructor for ChemEq. + *

+ */ + public ChemEq() { + for (int i = 0; i < 10; i++) { + chem_ref[i] += Math.log(P); + } - phi = new double[3]; - phi[0] = -9.7851; - phi[1] = -12.969; - phi[2] = -15.222; + phi = new double[3]; + phi[0] = -9.7851; + phi[1] = -12.969; + phi[2] = -15.222; - for (j = 0; j < NSPEC; j++) { - d_n[j] = 0; - } + for (j = 0; j < NSPEC; j++) { + d_n[j] = 0; + } + } + + /** + *

+ * Constructor for ChemEq. + *

+ * + * @param T a double + * @param P a double + * @param A_matrix an array of {@link double} objects + * @param n_mol an array of {@link double} objects + * @param chem_ref an array of {@link double} objects + * @param b_element an array of {@link double} objects + */ + public ChemEq(double T, double P, double[][] A_matrix, double[] n_mol, double[] chem_ref, + double[] b_element) { + this.T = T; + this.P = P; + this.A_matrix = A_matrix; + this.n_mol = n_mol; + this.chem_ref = chem_ref; + this.b_element = b_element; + + NSPEC = n_mol.length; + NELE = b_element.length; + + NNOT = 4; + b_cal = new double[NELE]; + b_vector = new double[NNOT]; + second_term = new double[NELE]; + chem_pot = new double[NSPEC]; + matrix = new double[NNOT][NNOT]; + d_n = new double[NSPEC]; + for (int i = 0; i < n_mol.length; i++) { + chem_ref[i] += Math.log(P); } - /** - *

- * Constructor for ChemEq. - *

- * - * @param T a double - * @param P a double - * @param A_matrix an array of {@link double} objects - * @param n_mol an array of {@link double} objects - * @param chem_ref an array of {@link double} objects - * @param b_element an array of {@link double} objects - */ - public ChemEq(double T, double P, double[][] A_matrix, double n_mol[], double chem_ref[], - double b_element[]) { - this.T = T; - this.P = P; - this.A_matrix = A_matrix; - this.n_mol = n_mol; - this.chem_ref = chem_ref; - this.b_element = b_element; - - NSPEC = n_mol.length; - NELE = b_element.length; - - NNOT = 4; - b_cal = new double[NELE]; - b_vector = new double[NNOT]; - second_term = new double[NELE]; - chem_pot = new double[NSPEC]; - matrix = new double[NNOT][NNOT]; - d_n = new double[NSPEC]; - for (int i = 0; i < n_mol.length; i++) { - chem_ref[i] += Math.log(P); - } - - phi[0] = -9.7851; - phi[1] = -12.969; - phi[2] = -15.222; + phi[0] = -9.7851; + phi[1] = -12.969; + phi[2] = -15.222; - for (j = 0; j < NSPEC; j++) { - d_n[j] = 0; - } + for (j = 0; j < NSPEC; j++) { + d_n[j] = 0; } + } + + /** + *

+ * Constructor for ChemEq. + *

+ * + * @param A_matrix an array of {@link double} objects + */ + public ChemEq(double[][] A_matrix) { + this.A_matrix = A_matrix; + } + + /** + *

+ * Constructor for ChemEq. + *

+ * + * @param T a double + * @param P a double + * @param A_matrix an array of {@link double} objects + */ + public ChemEq(double T, double P, double[][] A_matrix) { + this.T = T; + this.P = P; + this.A_matrix = A_matrix; + } + + /** + *

+ * chemSolve. + *

+ */ + public void chemSolve() { + n_t = 0; + + for (k = 0; k < NSPEC; k++) { + n_t += n_mol[k]; + } + System.out.println("n_total: " + n_t); - /** - *

- * Constructor for ChemEq. - *

- * - * @param A_matrix an array of {@link double} objects - */ - public ChemEq(double[][] A_matrix) { - this.A_matrix = A_matrix; + for (i = 0; i < NELE; i++) { + second_term[i] = 0; + b_cal[i] = 0; } - /** - *

- * Constructor for ChemEq. - *

- * - * @param T a double - * @param P a double - * @param A_matrix an array of {@link double} objects - */ - public ChemEq(double T, double P, double[][] A_matrix) { - this.T = T; - this.P = P; - this.A_matrix = A_matrix; + for (i = 0; i < NSPEC; i++) { + chem_pot[i] = chem_ref[i] + Math.log(Math.abs(n_mol[i] / n_t)); + System.out.println("chempot: " + i + " = " + chem_pot[i]); } - /** - *

- * chemSolve. - *

- */ - public void chemSolve() { - n_t = 0; + sum = 0; + for (j = 0; j < NELE; j++) { + for (i = 0; i < NELE; i++) { for (k = 0; k < NSPEC; k++) { - n_t += n_mol[k]; - } - System.out.println("n_total: " + n_t); - - for (i = 0; i < NELE; i++) { - second_term[i] = 0; - b_cal[i] = 0; - } - - for (i = 0; i < NSPEC; i++) { - chem_pot[i] = chem_ref[i] + Math.log(Math.abs(n_mol[i] / n_t)); - System.out.println("chempot: " + i + " = " + chem_pot[i]); + sum += A_matrix[i][k] * A_matrix[j][k] * n_mol[k]; } + matrix[j][i] = sum; sum = 0; + } - for (j = 0; j < NELE; j++) { - for (i = 0; i < NELE; i++) { - for (k = 0; k < NSPEC; k++) { - sum += A_matrix[i][k] * A_matrix[j][k] * n_mol[k]; - } - - matrix[j][i] = sum; - sum = 0; - } - - for (k = 0; k < NSPEC; k++) { - second_term[j] += A_matrix[j][k] * n_mol[k] * chem_pot[k]; - } - - for (i = 0; i < NSPEC; i++) { - b_cal[j] += A_matrix[j][i] * n_mol[i]; - } - matrix[j][NELE] = b_cal[j]; - b_vector[j] = second_term[j] + b_element[j] - b_cal[j]; - } + for (k = 0; k < NSPEC; k++) { + second_term[j] += A_matrix[j][k] * n_mol[k] * chem_pot[k]; + } - for (j = 0; j < NELE; j++) { - matrix[NELE][j] = b_cal[j]; - } - - matrix[NELE][NELE] = 0; - b_vector[NNOT - 1] = 0; - - for (i = 0; i < NSPEC; i++) { - b_vector[NNOT - 1] += n_mol[i] * chem_pot[i]; - } - - double[][] btest = new double[NNOT][1]; - - for (i = 0; i < NNOT; i++) { - btest[i][0] = b_vector[i]; - - for (j = 0; j < NNOT; j++) { - System.out.println("matrix: " + i + " " + j + " " + matrix[i][j]); - } - } - - Matrix matrixA = new Matrix(matrix); - Matrix matrixb = new Matrix(btest); - Matrix solved = matrixA.solve(matrixb); - solved.print(5, 3); + for (i = 0; i < NSPEC; i++) { + b_cal[j] += A_matrix[j][i] * n_mol[i]; + } + matrix[j][NELE] = b_cal[j]; + b_vector[j] = second_term[j] + b_element[j] - b_cal[j]; + } - for (j = 0; j < NELE; j++) { - b_vector[j] = solved.get(j, 0); - phi[j] = solved.get(j, 0); - } - u_u = solved.get(NELE, 0); + for (j = 0; j < NELE; j++) { + matrix[NELE][j] = b_cal[j]; + } - sum = 0; + matrix[NELE][NELE] = 0; + b_vector[NNOT - 1] = 0; - for (j = 0; j < NSPEC; j++) { - for (k = 0; k < NELE; k++) { - sum += A_matrix[k][j] * phi[k]; - } - // System.out.println("j : " +j); - d_n[j] = n_mol[j] * (sum + u_u - chem_pot[j]); - System.out.println("nj " + j + " " + d_n[j]); - sum = 0; - } + for (i = 0; i < NSPEC; i++) { + b_vector[NNOT - 1] += n_mol[i] * chem_pot[i]; } - /** - *

- * step. - *

- * - * @return a double - */ - public double step() { - double step; - - int i, check; - double[] n_omega = new double[NSPEC]; - double[] chem_pot_omega = new double[NSPEC]; - double[] chem_pot = new double[NSPEC]; - double G_1, G_0; - - check = 0; - step = 1; + double[][] btest = new double[NNOT][1]; - for (i = 0; i < NSPEC; i++) { - n_omega[i] = n_mol[i] + d_n[i]; - if (n_omega[i] < 0) { - check = i; - step = innerStep(n_omega, check, step); - System.out.println("step2 ... " + step); - return step; - } else { - chem_pot_omega[i] = R * T * (chem_ref[i] + Math.log(n_omega[i] / n_t)); - chem_pot[i] = R * T * (chem_ref[i] + Math.log(n_mol[i] / n_t)); - } - } + for (i = 0; i < NNOT; i++) { + btest[i][0] = b_vector[i]; - G_1 = 0; + for (j = 0; j < NNOT; j++) { + System.out.println("matrix: " + i + " " + j + " " + matrix[i][j]); + } + } - for (i = 0; i < NSPEC; i++) { - G_1 += chem_pot_omega[i] * d_n[i]; - } - - if (G_1 > 0) { - G_0 = 0; - for (i = 0; i < NSPEC; i++) { - G_0 += chem_pot[i] * d_n[i]; - } - step = G_0 / (G_0 - G_1); - // System.out.println("step4 ... " + step); - } + Matrix matrixA = new Matrix(matrix); + Matrix matrixb = new Matrix(btest); + Matrix solved = matrixA.solve(matrixb); + solved.print(5, 3); + for (j = 0; j < NELE; j++) { + b_vector[j] = solved.get(j, 0); + phi[j] = solved.get(j, 0); + } + u_u = solved.get(NELE, 0); + + sum = 0; + + for (j = 0; j < NSPEC; j++) { + for (k = 0; k < NELE; k++) { + sum += A_matrix[k][j] * phi[k]; + } + // System.out.println("j : " +j); + d_n[j] = n_mol[j] * (sum + u_u - chem_pot[j]); + System.out.println("nj " + j + " " + d_n[j]); + sum = 0; + } + } + + /** + *

+ * step. + *

+ * + * @return a double + */ + public double step() { + double step; + + int i; + int check; + double[] n_omega = new double[NSPEC]; + double[] chem_pot_omega = new double[NSPEC]; + double[] chem_pot = new double[NSPEC]; + double G_1; + + double G_0; + check = 0; + step = 1; + + for (i = 0; i < NSPEC; i++) { + n_omega[i] = n_mol[i] + d_n[i]; + if (n_omega[i] < 0) { + check = i; step = innerStep(n_omega, check, step); - System.out.println("step ... " + step); - + System.out.println("step2 ... " + step); return step; + } else { + chem_pot_omega[i] = R * T * (chem_ref[i] + Math.log(n_omega[i] / n_t)); + chem_pot[i] = R * T * (chem_ref[i] + Math.log(n_mol[i] / n_t)); + } } - /** - *

- * innerStep. - *

- * - * @param n_omega an array of {@link double} objects - * @param check a int - * @param step a double - * @return a double - */ - public double innerStep(double[] n_omega, int check, double step) { - if (check > 0) { - agemo = (-n_mol[i] / d_n[i]) * (1 - 0.01); - for (i = check; i < NSPEC; i++) { - n_omega[i] = n_mol[i] + d_n[i]; - - if (n_omega[i] < 0) { - step = (-n_mol[i] / d_n[i]) * (1 - 0.01); - if (step < agemo) { - agemo = step; - } - } - } - - step = agemo; - - if (step > 1) { - step = 1; - } - } - // System.out.println("step5 ... " + step); - return step; + G_1 = 0; + + for (i = 0; i < NSPEC; i++) { + G_1 += chem_pot_omega[i] * d_n[i]; + } + + if (G_1 > 0) { + G_0 = 0; + for (i = 0; i < NSPEC; i++) { + G_0 += chem_pot[i] * d_n[i]; + } + step = G_0 / (G_0 - G_1); + // System.out.println("step4 ... " + step); } - /** - *

- * solve. - *

- * - * @param T a double - * @param P a double - * @param n_mol an array of {@link double} objects - * @param chem_ref an array of {@link double} objects - */ - public void solve(double T, double P, double n_mol[], double chem_ref[]) { - this.T = T; - this.P = P; - - for (i = 0; i < n_mol.length; i++) { - System.out.println(n_mol[i]); - this.n_mol[i] = n_mol[i]; - this.chem_ref[i] = chem_ref[i]; + step = innerStep(n_omega, check, step); + System.out.println("step ... " + step); + + return step; + } + + /** + *

+ * innerStep. + *

+ * + * @param n_omega an array of {@link double} objects + * @param check a int + * @param step a double + * @return a double + */ + public double innerStep(double[] n_omega, int check, double step) { + if (check > 0) { + agemo = (-n_mol[i] / d_n[i]) * (1 - 0.01); + for (i = check; i < NSPEC; i++) { + n_omega[i] = n_mol[i] + d_n[i]; + + if (n_omega[i] < 0) { + step = (-n_mol[i] / d_n[i]) * (1 - 0.01); + if (step < agemo) { + agemo = step; + } } + } - // beregner b - double[][] nAr = new double[n_mol.length][1]; + step = agemo; - for (i = 0; i < n_mol.length; i++) { - nAr[i][0] = n_mol[i]; - } + if (step > 1) { + step = 1; + } + } + // System.out.println("step5 ... " + step); + return step; + } + + /** + *

+ * solve. + *

+ * + * @param T a double + * @param P a double + * @param n_mol an array of {@link double} objects + * @param chem_ref an array of {@link double} objects + */ + public void solve(double T, double P, double[] n_mol, double[] chem_ref) { + this.T = T; + this.P = P; + + for (i = 0; i < n_mol.length; i++) { + System.out.println(n_mol[i]); + this.n_mol[i] = n_mol[i]; + this.chem_ref[i] = chem_ref[i]; + } - Matrix matrixA = new Matrix(A_matrix); - Matrix matrixnAr = new Matrix(nAr); - Matrix solved = matrixA.times(matrixnAr); + // beregner b + double[][] nAr = new double[n_mol.length][1]; - this.b_element = solved.transpose().getArrayCopy()[0]; + for (i = 0; i < n_mol.length; i++) { + nAr[i][0] = n_mol[i]; + } - NSPEC = n_mol.length; - NELE = A_matrix.length; + Matrix matrixA = new Matrix(A_matrix); + Matrix matrixnAr = new Matrix(nAr); + Matrix solved = matrixA.times(matrixnAr); - NNOT = NELE + 1;// 4; - b_cal = new double[NELE]; - b_vector = new double[NNOT]; - second_term = new double[NELE]; - chem_pot = new double[NSPEC]; - matrix = new double[NNOT][NNOT]; + this.b_element = solved.transpose().getArrayCopy()[0]; - for (int i = 0; i < 10; i++) { - // chem_ref[i] = chem_ref[i]+Math.log(this.P); - } + NSPEC = n_mol.length; + NELE = A_matrix.length; - phi = new double[NELE]; - phi[0] = -9.7851; - phi[1] = -12.969; - phi[2] = -15.222; - phi[3] = -10; - phi[4] = -10; - - for (j = 0; j < NSPEC; j++) { - d_n[j] = 0; - // System.out.println("HEI" + b_element[j]); - // b_element[4] = 0.5; - } - System.out.println("HEI" + b_element[0]); - System.out.println("HEI" + b_element[1]); - System.out.println("HEI" + b_element[2]); - System.out.println("HEI" + b_element[3]); - System.out.println("HEI" + b_element[4]); + NNOT = NELE + 1; // 4; + b_cal = new double[NELE]; + b_vector = new double[NNOT]; + second_term = new double[NELE]; + chem_pot = new double[NSPEC]; + matrix = new double[NNOT][NNOT]; - solve(); + for (int i = 0; i < 10; i++) { + // chem_ref[i] = chem_ref[i]+Math.log(this.P); } - /** - *

- * solve. - *

- */ - public void solve() { - double error = 0; - double Gibbs = 0; - - do { - error = 0; - chemSolve(); - - for (i = 0; i < NSPEC; i++) { - System.out.println(n_mol[i] + " prove korreksjon " + step * d_n[i]); - - error += d_n[i] / n_mol[i]; - - if (Math.abs(d_n[i] / n_mol[i]) > 0.00001) { - step = step(); - // n_mol[i] = n_mol[i] + step*d_n[i]; - // System.out.println("mol: " + n_mol[i]); - Gibbs = 0; - for (i = 0; i < NSPEC; i++) { - n_mol[i] += step * d_n[i]; - Gibbs += n_mol[i] * chem_pot[i]; - } - System.out.println("Gibbs: " + Gibbs); - solve(); - return; - } - } - } while (error > 0.00005); - - for (j = 0; j < NSPEC; j++) { - System.out.println( - " SVAR : " + n_mol[j] + " " + (d_n[j] / n_mol[j]) + " GIBBS : " + Gibbs); + phi = new double[NELE]; + phi[0] = -9.7851; + phi[1] = -12.969; + phi[2] = -15.222; + phi[3] = -10; + phi[4] = -10; + + for (j = 0; j < NSPEC; j++) { + d_n[j] = 0; + // System.out.println("HEI" + b_element[j]); + // b_element[4] = 0.5; + } + System.out.println("HEI" + b_element[0]); + System.out.println("HEI" + b_element[1]); + System.out.println("HEI" + b_element[2]); + System.out.println("HEI" + b_element[3]); + System.out.println("HEI" + b_element[4]); + + solve(); + } + + /** + *

+ * solve. + *

+ */ + public void solve() { + double error = 0; + double Gibbs = 0; + + do { + error = 0; + chemSolve(); + + for (i = 0; i < NSPEC; i++) { + System.out.println(n_mol[i] + " prove korreksjon " + step * d_n[i]); + + error += d_n[i] / n_mol[i]; + + if (Math.abs(d_n[i] / n_mol[i]) > 0.00001) { + step = step(); + // n_mol[i] = n_mol[i] + step*d_n[i]; + // System.out.println("mol: " + n_mol[i]); + Gibbs = 0; + for (i = 0; i < NSPEC; i++) { + n_mol[i] += step * d_n[i]; + Gibbs += n_mol[i] * chem_pot[i]; + } + System.out.println("Gibbs: " + Gibbs); + solve(); + return; } + } + } while (error > 0.00005); + + for (j = 0; j < NSPEC; j++) { + System.out.println(" SVAR : " + n_mol[j] + " " + (d_n[j] / n_mol[j]) + " GIBBS : " + Gibbs); } + } } diff --git a/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/ChemicalEquilibrium.java b/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/ChemicalEquilibrium.java index 9f2b6f3017..b432d8d56c 100644 --- a/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/ChemicalEquilibrium.java +++ b/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/ChemicalEquilibrium.java @@ -13,518 +13,523 @@ * @version $Id: $Id */ public class ChemicalEquilibrium implements java.io.Serializable { - private static final long serialVersionUID = 1000; - - SystemInterface system; - double[] nVector; - double[] n_mol; - double d_n_t = 0; - int NSPEC = 2, NELE = 2; - double R = 8.314; - Matrix x_solve; - double y_solve; - double n_t = 0.0, agemo = 0, kronDelt = 0; - ComponentInterface[] components; - double[][] M_matrix = new double[NSPEC][NSPEC]; - Matrix M_Jama_matrix; - Matrix A_Jama_matrix; - Matrix nmu; - Matrix AMA_matrix; // = new double[NELE][NELE]; - Matrix dn_matrix; - Matrix AMU_matrix; - Matrix Alambda_matrix; - double d_n[] = new double[NSPEC]; - double logactivityVec[] = new double[NSPEC]; - double[] n0; - double[][] A_matrix; - double chem_ref[]; - int waterNumb = 0; - int upMoles = 0; - // double chem_pot_dilute[]; - /// double chem_pot_pure[]; - double b_element[]; - Matrix b_matrix; - - Matrix A_solve; - Matrix b_solve; - double[] chem_pot; - Matrix chem_pot_Jama_Matrix; - int phasenumb = 1; - - /** - *

- * Constructor for ChemicalEquilibrium. - *

- * - * @param A_matrix an array of {@link double} objects - * @param b_element an array of {@link double} objects - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param components an array of {@link neqsim.thermo.component.ComponentInterface} objects - * @param phase a int - */ - public ChemicalEquilibrium(double[][] A_matrix, double b_element[], SystemInterface system, - ComponentInterface[] components, int phase) { - this.system = system; - phasenumb = phase; - this.A_matrix = A_matrix; - this.b_element = b_element; - this.components = components; - NSPEC = components.length; // Number of Species - NELE = b_element.length; // Number of elements - n_mol = new double[components.length]; - logactivityVec = new double[NSPEC]; - this.chem_ref = new double[components.length]; - A_solve = new Matrix(NELE + 1, NELE + 1); - b_solve = new Matrix(NELE + 1, 1); - chem_ref = new double[NSPEC]; - chem_pot = new double[NSPEC]; - // chem_pot_dilute = new double[NSPEC]; - // chem_pot_pure = new double[NSPEC]; - M_matrix = new double[NSPEC][NSPEC]; - d_n = new double[NSPEC]; - - for (int i = 0; i < components.length; i++) { - if (components[i].getComponentName().equals("water")) { - waterNumb = i; - break; - } - } - system.init(1, phasenumb); - calcRefPot(); - for (int j = 0; j < NSPEC; j++) { - d_n[j] = 0; - } + private static final long serialVersionUID = 1000; + + SystemInterface system; + double[] nVector; + double[] n_mol; + double d_n_t = 0; + int NSPEC = 2; + int NELE = 2; + double R = 8.314; + Matrix x_solve; + double y_solve; + double n_t = 0.0; + double agemo = 0; + double kronDelt = 0; + + ComponentInterface[] components; + double[][] M_matrix = new double[NSPEC][NSPEC]; + Matrix M_Jama_matrix; + Matrix A_Jama_matrix; + Matrix nmu; + Matrix AMA_matrix; // = new double[NELE][NELE]; + Matrix dn_matrix; + Matrix AMU_matrix; + Matrix Alambda_matrix; + double[] d_n = new double[NSPEC]; + double[] logactivityVec = new double[NSPEC]; + double[] n0; + double[][] A_matrix; + double[] chem_ref; + int waterNumb = 0; + int upMoles = 0; + // double chem_pot_dilute[]; + /// double chem_pot_pure[]; + double[] b_element; + Matrix b_matrix; + + Matrix A_solve; + Matrix b_solve; + double[] chem_pot; + Matrix chem_pot_Jama_Matrix; + int phasenumb = 1; + + /** + *

+ * Constructor for ChemicalEquilibrium. + *

+ * + * @param A_matrix an array of {@link double} objects + * @param b_element an array of {@link double} objects + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param components an array of {@link neqsim.thermo.component.ComponentInterface} objects + * @param phase a int + */ + public ChemicalEquilibrium(double[][] A_matrix, double[] b_element, SystemInterface system, + ComponentInterface[] components, int phase) { + this.system = system; + phasenumb = phase; + this.A_matrix = A_matrix; + this.b_element = b_element; + this.components = components; + NSPEC = components.length; // Number of Species + NELE = b_element.length; // Number of elements + n_mol = new double[components.length]; + logactivityVec = new double[NSPEC]; + this.chem_ref = new double[components.length]; + A_solve = new Matrix(NELE + 1, NELE + 1); + b_solve = new Matrix(NELE + 1, 1); + chem_ref = new double[NSPEC]; + chem_pot = new double[NSPEC]; + // chem_pot_dilute = new double[NSPEC]; + // chem_pot_pure = new double[NSPEC]; + M_matrix = new double[NSPEC][NSPEC]; + d_n = new double[NSPEC]; + + for (int i = 0; i < components.length; i++) { + if (components[i].getComponentName().equals("water")) { + waterNumb = i; + break; + } } - - /** - *

- * calcRefPot. - *

- */ - public void calcRefPot() { - for (int i = 0; i < components.length; i++) { - // calculates the reduced chemical potential mu/RT - this.chem_ref[i] = components[i].getReferencePotential() - / (R * system.getPhase(phasenumb).getTemperature()); - logactivityVec[i] = 0.0; - if (components[i].calcActivity()) { - logactivityVec[i] = system.getPhase(phasenumb).getLogActivityCoefficient( - components[i].getComponentNumber(), - components[waterNumb].getComponentNumber()); - // System.out.println("activity " + Math.exp(logactivityVec[i]) + " " + - // components[i].getComponentName()); - } + system.init(1, phasenumb); + calcRefPot(); + for (int j = 0; j < NSPEC; j++) { + d_n[j] = 0; + } + } + + /** + *

+ * calcRefPot. + *

+ */ + public void calcRefPot() { + for (int i = 0; i < components.length; i++) { + // calculates the reduced chemical potential mu/RT + this.chem_ref[i] = + components[i].getReferencePotential() / (R * system.getPhase(phasenumb).getTemperature()); + logactivityVec[i] = 0.0; + if (components[i].calcActivity()) { + logactivityVec[i] = system.getPhase(phasenumb).getLogActivityCoefficient( + components[i].getComponentNumber(), components[waterNumb].getComponentNumber()); + // System.out.println("activity " + Math.exp(logactivityVec[i]) + " " + + // components[i].getComponentName()); + } + } + } + + /** + *

+ * chemSolve. + *

+ */ + public void chemSolve() { + n_t = system.getPhase(phasenumb).getNumberOfMolesInPhase(); + + for (int i = 0; i < NSPEC; i++) { + n_mol[i] = system.getPhase(phasenumb).getComponents()[components[i].getComponentNumber()] + .getNumberOfMolesInPhase(); + + for (int k = 0; k < NSPEC; k++) { + if (k == i) { + kronDelt = 1.0; + } else { + kronDelt = 0.0; } + // definition of M_matrix changed by Neeraj. Initially only 1st term was + // included + M_matrix[i][k] = kronDelt + / system.getPhase(phasenumb).getComponents()[components[i].getComponentNumber()] + .getNumberOfMolesInPhase(); // +system.getPhase(phasenumb).getComponent(i).logfugcoefdNi(system.getPhase(phasenumb), + // k); + // System.out.println("dfugdn " + // +system.getPhase(phasenumb).getComponent(i).logfugcoefdNi(this.system.getPhase(phasenumb), + // i)); + // if (i == k) System.out.println("n " + // +system.getPhase(phasenumb).getComponents()[components[i].getComponentNumber()].getNumberOfMolesInPhase() + // ); + } + } + // printComp(); + + M_Jama_matrix = new Matrix(M_matrix); + A_Jama_matrix = new Matrix(A_matrix); + b_matrix = new Matrix(b_element, 1); + + // M_Jama_matrix.print(10, 10); + // Following 5 statements added by Neeraj + // A_Jama_matrix.print(5,2); + // ystem.out.println("rank of A "+A_Jama_matrix.rank()); + // System.out.println("number of rows in A "+A_Jama_matrix.getRowDimension()); + // if(A_Jama_matrix.rank() - * chemSolve. - *

- */ - public void chemSolve() { - n_t = system.getPhase(phasenumb).getNumberOfMolesInPhase(); + chem_pot_Jama_Matrix = new Matrix(chem_pot, 1); + + AMA_matrix = A_Jama_matrix.times(M_Jama_matrix.inverse().times(A_Jama_matrix.transpose())); + AMU_matrix = + A_Jama_matrix.times(M_Jama_matrix.inverse().times(chem_pot_Jama_Matrix.transpose())); + Matrix nmol = new Matrix(n_mol, 1); + nmu = nmol.times(chem_pot_Jama_Matrix.transpose()); + // AMA_matrix.pr + // Added by Neeraj + // Matrix bm_matrix = (A_Jama_matrix.times(nmol.transpose()).transpose()); + // ((b_matrix.minus(bm_matrix)).times(R*system.getTemperature()).transpose()).print(10,10); + // AMU_matrix.print(20,20); + + A_solve.setMatrix(0, NELE - 1, 0, NELE - 1, AMA_matrix); + A_solve.setMatrix(0, NELE - 1, NELE, NELE, b_matrix.transpose()); + A_solve.setMatrix(NELE, NELE, 0, NELE - 1, b_matrix); + A_solve.set(NELE, NELE, 0.0); + + // A_solve.print(10,20); + // System.out.println("Rank of A_solve "+A_solve.rank()); + // Term subtracted from AMU_matrix -- Neeraj + // b_solve.setMatrix(0,NELE-1,0,0, + // AMU_matrix.minus((b_matrix.minus(bm_matrix)).times(R*system.getTemperature()).transpose())); + // Commented out by Neeraj + b_solve.setMatrix(0, NELE - 1, 0, 0, AMU_matrix); + b_solve.setMatrix(NELE, NELE, 0, 0, nmu); + // b_solve.print(10,5); + // System.out.println("det "+A_solve.det()); + + // y_solve added by Neeraj + // M_Jama_matrix.print(5,5); + y_solve = A_solve.det(); + // System.out.println("Determinant "+y_solve); + if ((y_solve < 1e-38 && y_solve > -1e-38) || y_solve < -1e70) { + // A_solve.print(5,5); + y_solve = AMA_matrix.det(); + // System.out.println("AMA det "+y_solve); + y_solve = A_solve.rank(); + // System.out.println("Rank " + y_solve); + // M_Jama_matrix.print(5,5); + // b_solve.print(5,5); + // System.out.println("det A " + A_solve.rank()); + } + // try catch block added by Neeraj + try { + x_solve = A_solve.solve(b_solve); + } catch (Exception e) { + // e.printStackTrace(); + // System.out.println("\nError x " + + // system.getPhase(phasenumb).getComponent(0).getx()); + // System.out.println("Error T " + system.getTemperature()); + } + // d_n_t = x_solve.get(NELE,0)*n_t; + + // Equation 3.115 + dn_matrix = M_Jama_matrix.inverse() + .times((A_Jama_matrix.transpose().times(x_solve.getMatrix(0, NELE - 1, 0, 0))) + .minus(chem_pot_Jama_Matrix.transpose())) + .plus(new Matrix(n_mol, 1).transpose().times(x_solve.get(NELE, 0))); + d_n = dn_matrix.transpose().getArray()[0]; + } + + /** + *

+ * updateMoles. + *

+ */ + public void updateMoles() { + upMoles++; + // double changeMoles = 0.0; + for (int i = 0; i < components.length; i++) { + system.addComponent(components[i].getComponentNumber(), + (n_mol[i] - system.getPhase(phasenumb).getComponents()[components[i].getComponentNumber()] + .getNumberOfMolesInPhase()), + phasenumb); + + // changeMoles += n_mol[i] - + // system.getPhase(phasenumb).getComponents()[components[i].getComponentNumber()] + // .getNumberOfMolesInPhase(); + } + system.initBeta(); // this was added for mass trans calc + system.init_x_y(); + } + + /** + *

+ * solve. + *

+ * + * @return a boolean + */ + public boolean solve() { + double error = 1e10; + double errOld = 1e10; + double thisError = 0; + double p = 1.0; + // boolean negN = false; + double maxError = 1e-8; + upMoles = 0; + // double old = 0; + try { + do { + p++; + errOld = error; + error = 0.0; + this.chemSolve(); + // Commented out by Neeraj + double step1 = step(); + // System.out.println("step " + step1); + // Changed by Neeraj + // double step1 = 1.0; //leads to negative b error for (int i = 0; i < NSPEC; i++) { - n_mol[i] = - system.getPhase(phasenumb).getComponents()[components[i].getComponentNumber()] - .getNumberOfMolesInPhase(); - - for (int k = 0; k < NSPEC; k++) { - if (k == i) { - kronDelt = 1.0; - } else { - kronDelt = 0.0; - } - // definition of M_matrix changed by Neeraj. Initially only 1st term was - // included - M_matrix[i][k] = kronDelt / system.getPhase(phasenumb).getComponents()[components[i] - .getComponentNumber()].getNumberOfMolesInPhase();// +system.getPhase(phasenumb).getComponent(i).logfugcoefdNi(system.getPhase(phasenumb), - // k); - // System.out.println("dfugdn " - // +system.getPhase(phasenumb).getComponent(i).logfugcoefdNi(this.system.getPhase(phasenumb), - // i)); - // if (i == k) System.out.println("n " - // +system.getPhase(phasenumb).getComponents()[components[i].getComponentNumber()].getNumberOfMolesInPhase() - // ); - } - } - // printComp(); - - M_Jama_matrix = new Matrix(M_matrix); - A_Jama_matrix = new Matrix(A_matrix); - b_matrix = new Matrix(b_element, 1); - - // M_Jama_matrix.print(10, 10); - // Following 5 statements added by Neeraj - // A_Jama_matrix.print(5,2); - // ystem.out.println("rank of A "+A_Jama_matrix.rank()); - // System.out.println("number of rows in A "+A_Jama_matrix.getRowDimension()); - // if(A_Jama_matrix.rank() 1e-15) { + thisError = Math.abs(dn_matrix.get(i, 0)) / system.getPhase(phasenumb) + .getComponent(components[i].getComponentNumber()).getNumberOfMolesInPhase(); + error += Math.abs(thisError); + n_mol[i] = dn_matrix.get(i, 0) * step1 + system.getPhase(phasenumb) + .getComponent(components[i].getComponentNumber()).getNumberOfMolesInPhase(); + // n_mol[i] = dn_matrix.get(i,0) + + // system.getPhase(phasenumb).getComponent(components[i].getComponentNumber()).getNumberOfMolesInPhase(); + } } - - chem_pot_Jama_Matrix = new Matrix(chem_pot, 1); - - AMA_matrix = A_Jama_matrix.times(M_Jama_matrix.inverse().times(A_Jama_matrix.transpose())); - AMU_matrix = A_Jama_matrix - .times(M_Jama_matrix.inverse().times(chem_pot_Jama_Matrix.transpose())); - Matrix nmol = new Matrix(n_mol, 1); - nmu = nmol.times(chem_pot_Jama_Matrix.transpose()); - // AMA_matrix.pr - // Added by Neeraj - // Matrix bm_matrix = (A_Jama_matrix.times(nmol.transpose()).transpose()); - // ((b_matrix.minus(bm_matrix)).times(R*system.getTemperature()).transpose()).print(10,10); - // AMU_matrix.print(20,20); - - A_solve.setMatrix(0, NELE - 1, 0, NELE - 1, AMA_matrix); - A_solve.setMatrix(0, NELE - 1, NELE, NELE, b_matrix.transpose()); - A_solve.setMatrix(NELE, NELE, 0, NELE - 1, b_matrix); - A_solve.set(NELE, NELE, 0.0); - - // A_solve.print(10,20); - // System.out.println("Rank of A_solve "+A_solve.rank()); - // Term subtracted from AMU_matrix -- Neeraj - // b_solve.setMatrix(0,NELE-1,0,0, - // AMU_matrix.minus((b_matrix.minus(bm_matrix)).times(R*system.getTemperature()).transpose())); - // Commented out by Neeraj - b_solve.setMatrix(0, NELE - 1, 0, 0, AMU_matrix); - b_solve.setMatrix(NELE, NELE, 0, 0, nmu); - // b_solve.print(10,5); - // System.out.println("det "+A_solve.det()); - - // y_solve added by Neeraj - // M_Jama_matrix.print(5,5); - y_solve = A_solve.det(); - // System.out.println("Determinant "+y_solve); - if ((y_solve < 1e-38 && y_solve > -1e-38) || y_solve < -1e70) { - // A_solve.print(5,5); - y_solve = AMA_matrix.det(); - // System.out.println("AMA det "+y_solve); - y_solve = A_solve.rank(); - // System.out.println("Rank " + y_solve); - // M_Jama_matrix.print(5,5); - // b_solve.print(5,5); - // System.out.println("det A " + A_solve.rank()); + if (error <= errOld) { + updateMoles(); + system.init(1, phasenumb); + calcRefPot(); } - - // try catch block added by Neeraj - try { - x_solve = A_solve.solve(b_solve); - } catch (Exception e) { - // e.printStackTrace(); - // System.out.println("\nError x " + - // system.getPhase(phasenumb).getComponent(0).getx()); - // System.out.println("Error T " + system.getTemperature()); + if (p > 25) { + maxError *= 2; } - // d_n_t = x_solve.get(NELE,0)*n_t; - - // Equation 3.115 - dn_matrix = M_Jama_matrix.inverse() - .times((A_Jama_matrix.transpose().times(x_solve.getMatrix(0, NELE - 1, 0, 0))) - .minus(chem_pot_Jama_Matrix.transpose())) - .plus(new Matrix(n_mol, 1).transpose().times(x_solve.get(NELE, 0))); - d_n = dn_matrix.transpose().getArray()[0]; + // Print statement added by Neeraj + // System.out.println("Error " + error); + } while (((errOld > maxError && Math.abs(error) > maxError) && p < 350) || p < 2); + } catch (Exception e) { + e.printStackTrace(); + return false; } - - /** - *

- * updateMoles. - *

- */ - public void updateMoles() { - upMoles++; - // double changeMoles = 0.0; - for (int i = 0; i < components.length; i++) { - system.addComponent(components[i].getComponentNumber(), (n_mol[i] - - system.getPhase(phasenumb).getComponents()[components[i].getComponentNumber()] - .getNumberOfMolesInPhase()), - phasenumb); - - // changeMoles += n_mol[i] - - // system.getPhase(phasenumb).getComponents()[components[i].getComponentNumber()] - // .getNumberOfMolesInPhase(); - } - system.initBeta(); // this was added for mass trans calc - system.init_x_y(); + // System.out.println("iter " + p); + if (p > 345) { + System.out.println("iter " + p + " err " + error); // return false; } - - /** - *

- * solve. - *

- * - * @return a boolean - */ - public boolean solve() { - double error = 1e10, errOld = 1e10, thisError = 0; - double p = 1.0; - // boolean negN = false; - double maxError = 1e-8; - upMoles = 0; - // double old = 0; - try { - do { - p++; - errOld = error; - error = 0.0; - this.chemSolve(); - // Commented out by Neeraj - double step1 = step(); - // System.out.println("step " + step1); - // Changed by Neeraj - // double step1 = 1.0; //leads to negative b error - for (int i = 0; i < NSPEC; i++) { - if (Math.abs(dn_matrix.get(i, 0)) - / system.getPhase(phasenumb).getComponents()[components[i] - .getComponentNumber()].getNumberOfMolesInPhase() > 1e-15) { - thisError = Math.abs(dn_matrix.get(i, 0)) / system.getPhase(phasenumb) - .getComponent(components[i].getComponentNumber()) - .getNumberOfMolesInPhase(); - error += Math.abs(thisError); - n_mol[i] = dn_matrix.get(i, 0) * step1 + system.getPhase(phasenumb) - .getComponent(components[i].getComponentNumber()) - .getNumberOfMolesInPhase(); - // n_mol[i] = dn_matrix.get(i,0) + - // system.getPhase(phasenumb).getComponent(components[i].getComponentNumber()).getNumberOfMolesInPhase(); - } - } - if (error <= errOld) { - updateMoles(); - system.init(1, phasenumb); - calcRefPot(); - } - if (p > 25) { - maxError *= 2; - } - // Print statement added by Neeraj - // System.out.println("Error " + error); - } while (((errOld > maxError && Math.abs(error) > maxError) && p < 350) || p < 2); - } catch (Exception e) { - e.printStackTrace(); - return false; - } - // System.out.println("iter " + p); - if (p > 345) { - System.out.println("iter " + p + " err " + error); // return false; - } - if (p >= 1000) { - System.out.println("Too many iterations in chemical equilibrium " + error); - System.out.println("P " + system.getPressure()); - System.out.println("T " + system.getTemperature()); - } - if (Double.isNaN(error)) { - System.out.println("error . NaN in chemSolve() "); - System.out.println("pressure " + system.getPressure()); - } - - // Print added by Neeraj - /* - * System.out.println("n[1] "+n_mol[0]); System.out.println("n[2] "+n_mol[1]); - * System.out.println("n[3] "+n_mol[2]); System.out.println("n[4] "+n_mol[3]); - * System.out.println("n[5] "+n_mol[4]); - */ - // system.initBeta(); - system.init(1, phasenumb); - // printComp();//system.init(0) - return error < maxError; + if (p >= 1000) { + System.out.println("Too many iterations in chemical equilibrium " + error); + System.out.println("P " + system.getPressure()); + System.out.println("T " + system.getTemperature()); + } + if (Double.isNaN(error)) { + System.out.println("error . NaN in chemSolve() "); + System.out.println("pressure " + system.getPressure()); } - /** - *

- * printComp. - *

+ // Print added by Neeraj + /* + * System.out.println("n[1] "+n_mol[0]); System.out.println("n[2] "+n_mol[1]); + * System.out.println("n[3] "+n_mol[2]); System.out.println("n[4] "+n_mol[3]); + * System.out.println("n[5] "+n_mol[4]); */ - public void printComp() { - for (int j = 0; j < NSPEC; j++) { - System.out.println(" SVAR : " + n_mol[j]); - double activity = system.getPhase(phasenumb).getActivityCoefficient( - components[j].getComponentNumber(), components[waterNumb].getComponentNumber()); - System.out.println("act " + activity + " comp " + components[j].getComponentName()); + // system.initBeta(); + system.init(1, phasenumb); + // printComp(); //system.init(0) + return error < maxError; + } + + /** + *

+ * printComp. + *

+ */ + public void printComp() { + for (int j = 0; j < NSPEC; j++) { + System.out.println(" SVAR : " + n_mol[j]); + double activity = system.getPhase(phasenumb).getActivityCoefficient( + components[j].getComponentNumber(), components[waterNumb].getComponentNumber()); + System.out.println("act " + activity + " comp " + components[j].getComponentName()); + } + } + + /** + *

+ * getMoles. + *

+ * + * @return an array of {@link double} objects + */ + public double[] getMoles() { + return n_mol; + } + + /** + *

+ * step. + *

+ * + * @return a double + */ + public double step() { + double step = 1.0; + int i; + int check = 0; + double[] n_omega = new double[NSPEC]; + double[] chem_pot_omega = new double[NSPEC]; + double[] chem_pot = new double[NSPEC]; + double G_1 = 0.0; + + double G_0 = 0.0; + for (i = 0; i < NSPEC; i++) { + n_omega[i] = n_mol[i] + d_n[i]; + // System.out.println("nomega " + n_omega[i] ); + if (n_omega[i] < 0) { + check = i; + + step = innerStep(i, n_omega, check, step, true); + // System.out.println("step2 ... " + step); + return step; + } else { + // chem_pot_omega[i] = R*T*(chem_ref[i]+ Math.log(n_omega[i]/n_t) + + // Math.log(system.getPhases()[1].getComponents()[components[i].getComponentNumber()].getFugacityCoefficient()/chem_pot_pure[i])); + // chem_pot[i] = R*T*(chem_ref[i] + Math.log(n_mol[i]/n_t)+ + // Math.log(system.getPhases()[1].getComponents()[components[i].getComponentNumber()].getFugacityCoefficient()/chem_pot_pure[i])); + + if (system.getPhase(phasenumb).getComponents()[components[i].getComponentNumber()] + .getReferenceStateType().equals("solvent")) { + chem_pot[i] = R * system.getPhase(phasenumb).getTemperature() + * (chem_ref[i] + Math.log( + system.getPhase(phasenumb).getComponents()[components[i].getComponentNumber()] + .getNumberOfMolesInPhase()) + - Math.log(n_t) + logactivityVec[i]); // system.getPhase(phasenumb).getActivityCoefficient(components[i].getComponentNumber(),components[waterNumb].getComponentNumber()))); + // System.out.println("solvent activ: "+ i + " " + + // system.getPhases()[1].getComponents()[components[i].getComponentNumber()].getFugacityCoefficient()/chem_pot_pure[i]); + } else { + chem_pot[i] = R * system.getPhase(phasenumb).getTemperature() + * (chem_ref[i] + Math.log( + system.getPhase(phasenumb).getComponents()[components[i].getComponentNumber()] + .getNumberOfMolesInPhase()) + - Math.log(n_t) + logactivityVec[i]); // system.getPhase(phasenumb).getActivityCoefficient(components[i].getComponentNumber(),components[waterNumb].getComponentNumber()))); + // System.out.println("solute activ : " + i + " " + + // system.getPhases()[1].getComponents()[components[i].getComponentNumber()].getFugacityCoefficient()/chem_pot_dilute[i]); } + chem_pot_omega[i] = R * system.getPhase(phasenumb).getTemperature() + * (chem_ref[i] + Math.log(n_omega[i]) - Math.log(n_t) + logactivityVec[i]); + } } - - /** - *

- * getMoles. - *

- * - * @return an array of {@link double} objects - */ - public double[] getMoles() { - return n_mol; + // Added by Neeraj + Alambda_matrix = A_Jama_matrix.transpose().times(x_solve.getMatrix(0, NELE - 1, 0, 0)); + + G_1 = 0.0; + for (i = 0; i < NSPEC; i++) { + // G_1 += chem_pot_omega[i] * d_n[i]; + // Added by Neeraj + G_1 += (chem_pot_omega[i] - Alambda_matrix.get(i, 0)) * d_n[i] * (1 / n_omega[i] - 1 / n_t); } + // System.out.println("G1 " +G_1); - /** - *

- * step. - *

- * - * @return a double - */ - public double step() { - double step = 1.0; - int i, check = 0; - double[] n_omega = new double[NSPEC]; - double[] chem_pot_omega = new double[NSPEC]; - double[] chem_pot = new double[NSPEC]; - double G_1 = 0.0, G_0 = 0.0; - - for (i = 0; i < NSPEC; i++) { - n_omega[i] = n_mol[i] + d_n[i]; - // System.out.println("nomega " + n_omega[i] ); - if (n_omega[i] < 0) { - check = i; - - step = innerStep(i, n_omega, check, step, true); - // System.out.println("step2 ... " + step); - return step; - } else { - // chem_pot_omega[i] = R*T*(chem_ref[i]+ Math.log(n_omega[i]/n_t) + - // Math.log(system.getPhases()[1].getComponents()[components[i].getComponentNumber()].getFugacityCoefficient()/chem_pot_pure[i])); - // chem_pot[i] = R*T*(chem_ref[i] + Math.log(n_mol[i]/n_t)+ - // Math.log(system.getPhases()[1].getComponents()[components[i].getComponentNumber()].getFugacityCoefficient()/chem_pot_pure[i])); - - if (system.getPhase(phasenumb).getComponents()[components[i].getComponentNumber()] - .getReferenceStateType().equals("solvent")) { - chem_pot[i] = R * system.getPhase(phasenumb).getTemperature() * (chem_ref[i] - + Math.log(system.getPhase(phasenumb).getComponents()[components[i] - .getComponentNumber()].getNumberOfMolesInPhase()) - - Math.log(n_t) + logactivityVec[i]);// system.getPhase(phasenumb).getActivityCoefficient(components[i].getComponentNumber(),components[waterNumb].getComponentNumber()))); - // System.out.println("solvent activ: "+ i + " " + - // system.getPhases()[1].getComponents()[components[i].getComponentNumber()].getFugacityCoefficient()/chem_pot_pure[i]); - } else { - chem_pot[i] = R * system.getPhase(phasenumb).getTemperature() * (chem_ref[i] - + Math.log(system.getPhase(phasenumb).getComponents()[components[i] - .getComponentNumber()].getNumberOfMolesInPhase()) - - Math.log(n_t) + logactivityVec[i]);// system.getPhase(phasenumb).getActivityCoefficient(components[i].getComponentNumber(),components[waterNumb].getComponentNumber()))); - // System.out.println("solute activ : " + i + " " + - // system.getPhases()[1].getComponents()[components[i].getComponentNumber()].getFugacityCoefficient()/chem_pot_dilute[i]); - } - chem_pot_omega[i] = R * system.getPhase(phasenumb).getTemperature() - * (chem_ref[i] + Math.log(n_omega[i]) - Math.log(n_t) + logactivityVec[i]); - } - } + if (G_1 > 0) { + G_0 = 0.0; + for (i = 0; i < NSPEC; i++) { + // G_0 += chem_pot[i]*d_n[i]; // Added by Neeraj - Alambda_matrix = A_Jama_matrix.transpose().times(x_solve.getMatrix(0, NELE - 1, 0, 0)); - - G_1 = 0.0; - for (i = 0; i < NSPEC; i++) { - // G_1 += chem_pot_omega[i] * d_n[i]; - // Added by Neeraj - G_1 += (chem_pot_omega[i] - Alambda_matrix.get(i, 0)) * d_n[i] - * (1 / n_omega[i] - 1 / n_t); - } - // System.out.println("G1 " +G_1); - - if (G_1 > 0) { - G_0 = 0.0; - for (i = 0; i < NSPEC; i++) { - // G_0 += chem_pot[i]*d_n[i]; - // Added by Neeraj - G_0 += (chem_pot[i] - Alambda_matrix.get(i, 0)) * d_n[i] - * (1 / system.getPhase(phasenumb).getComponents()[components[i] - .getComponentNumber()].getNumberOfMolesInPhase() - 1 / n_t); - // G_0 += - // (chem_pot[i]-Alambda_matrix.get(i,0))*d_n[i]*(M_Jama_matrix.get(i,i)-1/n_t); - } - step = G_0 / (G_0 - G_1); - // System.out.println("step G " + step); - } - - step = innerStep(i, n_omega, check, step, false); - // System.out.println("step ... " + step); - - // return step; - return 1.0; + G_0 += (chem_pot[i] - Alambda_matrix.get(i, 0)) * d_n[i] + * (1 / system.getPhase(phasenumb).getComponents()[components[i].getComponentNumber()] + .getNumberOfMolesInPhase() - 1 / n_t); + // G_0 += + // (chem_pot[i]-Alambda_matrix.get(i,0))*d_n[i]*(M_Jama_matrix.get(i,i)-1/n_t); + } + step = G_0 / (G_0 - G_1); + // System.out.println("step G " + step); } - /** - *

- * innerStep. - *

- * - * @param i a int - * @param n_omega an array of {@link double} objects - * @param check a int - * @param step a double - * @param test a boolean - * @return a double - */ - public double innerStep(int i, double[] n_omega, int check, double step, boolean test) { - if (test) { - agemo = (-n_mol[i] / d_n[i]) * (1.0 - 0.03); - - for (i = check; i < NSPEC; i++) { - n_omega[i] = n_mol[i] + d_n[i]; - - if (n_omega[i] < 0) { - step = (-n_mol[i] / d_n[i]) * (1.0 - 0.03); - if (step < agemo) { - agemo = step; - } - } - } - - step = agemo; - - if (step > 1) { - step = 1.0; - } + step = innerStep(i, n_omega, check, step, false); + // System.out.println("step ... " + step); + + // return step; + return 1.0; + } + + /** + *

+ * innerStep. + *

+ * + * @param i a int + * @param n_omega an array of {@link double} objects + * @param check a int + * @param step a double + * @param test a boolean + * @return a double + */ + public double innerStep(int i, double[] n_omega, int check, double step, boolean test) { + if (test) { + agemo = (-n_mol[i] / d_n[i]) * (1.0 - 0.03); + + for (i = check; i < NSPEC; i++) { + n_omega[i] = n_mol[i] + d_n[i]; + + if (n_omega[i] < 0) { + step = (-n_mol[i] / d_n[i]) * (1.0 - 0.03); + if (step < agemo) { + agemo = step; + } } - return step; - } + } - // Method added by Neeraj - /* - * public double step(){ double step=1.0; int i, check=0; double[] F = new double[NSPEC]; - * double[] F_omega = new double[NSPEC]; double[] chem_pot = new double[NSPEC]; double[] n_omega - * = new double[NSPEC]; - * - * Matrix F_matrix, F_omega_matrix, fs_matrix, f_matrix, f_omega_matrix; double fs,f,f_omega; - * - * for(i = 0;i 0.5) step = 0.5; return step; } - */ + step = agemo; + + if (step > 1) { + step = 1.0; + } + } + return step; + } + + // Method added by Neeraj + /* + * public double step(){ double step=1.0; int i, check=0; double[] F = new double[NSPEC]; double[] + * F_omega = new double[NSPEC]; double[] chem_pot = new double[NSPEC]; double[] n_omega = new + * double[NSPEC]; + * + * Matrix F_matrix, F_omega_matrix, fs_matrix, f_matrix, f_omega_matrix; double fs,f,f_omega; + * + * for(i = 0;i 0.5) step = 0.5; return step; } + */ } diff --git a/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/LinearProgrammingChemicalEquilibrium.java b/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/LinearProgrammingChemicalEquilibrium.java index 88768e46e7..3ffd9ef4b0 100644 --- a/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/LinearProgrammingChemicalEquilibrium.java +++ b/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/LinearProgrammingChemicalEquilibrium.java @@ -42,7 +42,10 @@ public class LinearProgrammingChemicalEquilibrium ComponentInterface[] components; double[] numbering; String[] elements; - int changes = 0, minChanges = 0, maxChanges = 0; + int changes = 0; + int minChanges = 0; + int maxChanges = 0; + ChemicalReactionOperations operations; /** @@ -291,8 +294,8 @@ public void changePrimaryComponents() { * * * double[] nEts = new double[atemp.getColumnDimension()]; double totm=0.0; for(int - * k=0;k @@ -50,8 +52,9 @@ public graph2b() { */ public graph2b(double[][] points) { String[] seriesNames = new String[points.length]; - for (int i = 0; i < points.length; i++) + for (int i = 0; i < points.length; i++) { seriesNames[i] = ""; + } String tit = ""; String xaxis = ""; String yaxis = ""; @@ -266,7 +269,7 @@ public CategoryDataset createCategoryDataSource() { * Integer.valueOf(9), Integer.valueOf(9) }, { Integer.valueOf(3), Integer.valueOf(7), * Integer.valueOf(11), Integer.valueOf(10) } }; */ - return null;// new DefaultCategoryDataset(data); + return null; // new DefaultCategoryDataset(data); } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButton1ActionPerformed @@ -300,7 +303,7 @@ public ChartPanel getChartPanel() { * * @param args the command line arguments */ - public static void main(String args[]) { + public static void main(String[] args) { new graph2b().setVisible(true); } diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/FlowNode.java b/src/main/java/neqsim/fluidMechanics/flowNode/FlowNode.java index c3bec4f665..4dab9569e6 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/FlowNode.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/FlowNode.java @@ -31,11 +31,19 @@ public abstract class FlowNode implements FlowNodeInterface, ThermodynamicConstantsInterface { private static final long serialVersionUID = 1000; - protected double distanceToCenterOfNode = 0, lengthOfNode = 0, veticalPositionOfNode = 0; - protected double[] hydraulicDiameter, reynoldsNumber; + protected double distanceToCenterOfNode = 0; + protected double lengthOfNode = 0; + protected double veticalPositionOfNode = 0; + protected double[] hydraulicDiameter; + protected double[] reynoldsNumber; protected int[] flowDirection; - protected double[] interphaseContactLength, wallContactLength, phaseFraction; - public double[] molarFlowRate, massFlowRate, volumetricFlowRate; + protected double[] interphaseContactLength; + protected double[] wallContactLength; + protected double[] phaseFraction; + public double[] molarFlowRate; + public double[] massFlowRate; + public double[] volumetricFlowRate; + protected ThermodynamicOperations operations; protected String flowNodeType = null; protected FluidBoundaryInterface fluidBoundary = null; @@ -48,7 +56,10 @@ public abstract class FlowNode implements FlowNodeInterface, ThermodynamicConsta public double[] velocity; public GeometryDefinitionInterface pipe; protected InterphaseTransportCoefficientInterface interphaseTransportCoefficient; - protected double[] wallFrictionFactor, interphaseFrictionFactor; + protected double[] wallFrictionFactor; + + protected double[] interphaseFrictionFactor; + protected Double[] specifiedFrictionFactor = null; protected ThermodynamicOperations phaseOps; @@ -444,7 +455,7 @@ public void calcFluxes() {} /** {@inheritDoc} */ @Override - public void setFluxes(double dn[]) {} + public void setFluxes(double[] dn) {} /** {@inheritDoc} */ @Override diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySolver/FluidBoundarySolver.java b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySolver/FluidBoundarySolver.java index 223d9c1a2e..214a9e5f90 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySolver/FluidBoundarySolver.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySolver/FluidBoundarySolver.java @@ -21,11 +21,12 @@ public class FluidBoundarySolver implements FluidBoundarySolverInterface { FluidBoundarySystemInterface boundary; double xNew[][]; - protected Matrix[] solMatrix, diffMatrix; - protected double a[]; - protected double b[]; - protected double c[]; - protected double r[]; + protected Matrix[] solMatrix; + protected Matrix[] diffMatrix; + protected double[] a; + protected double[] b; + protected double[] c; + protected double[] r; boolean reactive = false; /** @@ -103,12 +104,11 @@ public void initProfiles() { double dx = xinterphase - xbulk; double last = boundary.getNode(i).getBulkSystem().getPhases()[1].getComponents()[j].getx(); if (reactive) { - boundary.getNode(i + 1).getBulkSystem().getPhases()[1].getComponents()[j] - .setx(last - dx - - reacRates.get(j, 0) - / boundary.getNode(i).getBulkSystem().getPhases()[1].getPhysicalProperties() - .getEffectiveDiffusionCoefficient(j) - * Math.pow(boundary.getNodeLength(), 2.0)); + boundary.getNode(i + 1).getBulkSystem().getPhases()[1].getComponents()[j].setx(last - dx + - reacRates.get(j, 0) + / boundary.getNode(i).getBulkSystem().getPhases()[1].getPhysicalProperties() + .getEffectiveDiffusionCoefficient(j) + * Math.pow(boundary.getNodeLength(), 2.0)); } else { boundary.getNode(i + 1).getBulkSystem().getPhases()[1].getComponents()[j] .setx(xinterphase - dx * ((double) (i + 1) / boundary.getNumberOfNodes())); @@ -172,7 +172,7 @@ public void setComponentConservationMatrix(int componentNumber) { a[0] = 0.0; c[0] = 0.0; - b[0] = 1.0;// boundary.getNode(0).getBulkSystem().getPhases()[1].getComponents()[componentNumber].getx(); + b[0] = 1.0; // boundary.getNode(0).getBulkSystem().getPhases()[1].getComponents()[componentNumber].getx(); r[0] = boundary.getNode(0).getBulkSystem().getPhases()[1].getComponents()[componentNumber].getx(); System.out.println("b0 :" + b[0]); @@ -205,7 +205,7 @@ public void setComponentConservationMatrix(int componentNumber) { int i = boundary.getNumberOfNodes() - 1; a[i] = 0.0; c[i] = 0.0; - b[i] = 1.0;// boundary.getNode(i).getBulkSystem().getPhases()[1].getComponents()[componentNumber].getx(); + b[i] = 1.0; // boundary.getNode(i).getBulkSystem().getPhases()[1].getComponents()[componentNumber].getx(); r[i] = boundary.getNode(i).getBulkSystem().getPhases()[1].getComponents()[componentNumber].getx(); System.out.println("bn :" + b[i]); @@ -235,7 +235,8 @@ public double getMolarFlux(int componentNumber) { @Override public void solve() { // double d[]; - int iter = 0, iterTop = 0; + int iter = 0; + int iterTop = 0; double maxDiff = 0; // double maxDiffOld = 0; double diff = 0; diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/NonEquilibriumFluidBoundary.java b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/NonEquilibriumFluidBoundary.java index 300241ebf3..a55656ffe4 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/NonEquilibriumFluidBoundary.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/NonEquilibriumFluidBoundary.java @@ -13,631 +13,625 @@ * @version $Id: $Id */ public abstract class NonEquilibriumFluidBoundary - extends neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.FluidBoundary { - private static final long serialVersionUID = 1000; - - protected int neq = 0; - protected Matrix dx; - protected Matrix Jac; - protected Matrix fvec; - protected Matrix uMassTrans; - protected Matrix uMassTransold; - protected Matrix Xgij; - - public double[][] molFractionDifference; - - /** - *

- * Constructor for NonEquilibriumFluidBoundary. - *

- */ - public NonEquilibriumFluidBoundary() {} - - /** - *

- * Constructor for NonEquilibriumFluidBoundary. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public NonEquilibriumFluidBoundary(SystemInterface system) { - super(system); - neq = 3 * bulkSystem.getPhases()[0].getNumberOfComponents(); - Jac = new Matrix(neq, neq); - fvec = new Matrix(neq, 1); - massTransferCoefficientMatrix[0] = - new Matrix(getBulkSystem().getPhases()[0].getNumberOfComponents() - 1, - getBulkSystem().getPhases()[0].getNumberOfComponents() - 1); - massTransferCoefficientMatrix[1] = - new Matrix(getBulkSystem().getPhases()[0].getNumberOfComponents() - 1, - getBulkSystem().getPhases()[0].getNumberOfComponents() - 1); - totalMassTransferCoefficientMatrix[0] = - new Matrix(getBulkSystem().getPhases()[0].getNumberOfComponents() - 1, - getBulkSystem().getPhases()[0].getNumberOfComponents() - 1); - totalMassTransferCoefficientMatrix[1] = - new Matrix(getBulkSystem().getPhases()[0].getNumberOfComponents() - 1, - getBulkSystem().getPhases()[0].getNumberOfComponents() - 1); - molFractionDifference = - new double[2][getBulkSystem().getPhases()[0].getNumberOfComponents() - 1]; - // interphaseSystem = bulkSystem.clone(); - // interphaseOps = new ThermodynamicOperations(interphaseSystem); - // interphaseOps.TPflash(); - // // interphaseOps.displayResult(); + extends neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.FluidBoundary { + private static final long serialVersionUID = 1000; + + protected int neq = 0; + protected Matrix dx; + protected Matrix Jac; + protected Matrix fvec; + protected Matrix uMassTrans; + protected Matrix uMassTransold; + protected Matrix Xgij; + + public double[][] molFractionDifference; + + /** + *

+ * Constructor for NonEquilibriumFluidBoundary. + *

+ */ + public NonEquilibriumFluidBoundary() {} + + /** + *

+ * Constructor for NonEquilibriumFluidBoundary. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public NonEquilibriumFluidBoundary(SystemInterface system) { + super(system); + neq = 3 * bulkSystem.getPhases()[0].getNumberOfComponents(); + Jac = new Matrix(neq, neq); + fvec = new Matrix(neq, 1); + massTransferCoefficientMatrix[0] = + new Matrix(getBulkSystem().getPhases()[0].getNumberOfComponents() - 1, + getBulkSystem().getPhases()[0].getNumberOfComponents() - 1); + massTransferCoefficientMatrix[1] = + new Matrix(getBulkSystem().getPhases()[0].getNumberOfComponents() - 1, + getBulkSystem().getPhases()[0].getNumberOfComponents() - 1); + totalMassTransferCoefficientMatrix[0] = + new Matrix(getBulkSystem().getPhases()[0].getNumberOfComponents() - 1, + getBulkSystem().getPhases()[0].getNumberOfComponents() - 1); + totalMassTransferCoefficientMatrix[1] = + new Matrix(getBulkSystem().getPhases()[0].getNumberOfComponents() - 1, + getBulkSystem().getPhases()[0].getNumberOfComponents() - 1); + molFractionDifference = + new double[2][getBulkSystem().getPhases()[0].getNumberOfComponents() - 1]; + // interphaseSystem = bulkSystem.clone(); + // interphaseOps = new ThermodynamicOperations(interphaseSystem); + // interphaseOps.TPflash(); + // // interphaseOps.displayResult(); + } + + /** + *

+ * Constructor for NonEquilibriumFluidBoundary. + *

+ * + * @param flowNode a {@link neqsim.fluidMechanics.flowNode.FlowNodeInterface} object + */ + public NonEquilibriumFluidBoundary(FlowNodeInterface flowNode) { + super(flowNode); + neq = 3 * bulkSystem.getPhases()[0].getNumberOfComponents(); + Jac = new Matrix(neq, neq); + fvec = new Matrix(neq, 1); + massTransferCoefficientMatrix[0] = + new Matrix(getBulkSystem().getPhases()[0].getNumberOfComponents() - 1, + getBulkSystem().getPhases()[0].getNumberOfComponents() - 1); + massTransferCoefficientMatrix[1] = + new Matrix(getBulkSystem().getPhases()[0].getNumberOfComponents() - 1, + getBulkSystem().getPhases()[0].getNumberOfComponents() - 1); + totalMassTransferCoefficientMatrix[0] = + new Matrix(getBulkSystem().getPhases()[0].getNumberOfComponents() - 1, + getBulkSystem().getPhases()[0].getNumberOfComponents() - 1); + totalMassTransferCoefficientMatrix[1] = + new Matrix(getBulkSystem().getPhases()[0].getNumberOfComponents() - 1, + getBulkSystem().getPhases()[0].getNumberOfComponents() - 1); + // interphaseSystem = bulkSystem.clone(); + molFractionDifference = + new double[2][getBulkSystem().getPhases()[0].getNumberOfComponents() - 1]; + // interphaseOps = new ThermodynamicOperations(interphaseSystem); + // interphaseOps.TPflash(); + // // interphaseOps.displayResult(); + } + + /** {@inheritDoc} */ + @Override + public NonEquilibriumFluidBoundary clone() { + NonEquilibriumFluidBoundary clonedSystem = null; + + try { + clonedSystem = (NonEquilibriumFluidBoundary) super.clone(); + } catch (Exception e) { + e.printStackTrace(System.err); } - /** - *

- * Constructor for NonEquilibriumFluidBoundary. - *

- * - * @param flowNode a {@link neqsim.fluidMechanics.flowNode.FlowNodeInterface} object - */ - public NonEquilibriumFluidBoundary(FlowNodeInterface flowNode) { - super(flowNode); - neq = 3 * bulkSystem.getPhases()[0].getNumberOfComponents(); - Jac = new Matrix(neq, neq); - fvec = new Matrix(neq, 1); - massTransferCoefficientMatrix[0] = - new Matrix(getBulkSystem().getPhases()[0].getNumberOfComponents() - 1, - getBulkSystem().getPhases()[0].getNumberOfComponents() - 1); - massTransferCoefficientMatrix[1] = - new Matrix(getBulkSystem().getPhases()[0].getNumberOfComponents() - 1, - getBulkSystem().getPhases()[0].getNumberOfComponents() - 1); - totalMassTransferCoefficientMatrix[0] = - new Matrix(getBulkSystem().getPhases()[0].getNumberOfComponents() - 1, - getBulkSystem().getPhases()[0].getNumberOfComponents() - 1); - totalMassTransferCoefficientMatrix[1] = - new Matrix(getBulkSystem().getPhases()[0].getNumberOfComponents() - 1, - getBulkSystem().getPhases()[0].getNumberOfComponents() - 1); - // interphaseSystem = bulkSystem.clone(); - molFractionDifference = - new double[2][getBulkSystem().getPhases()[0].getNumberOfComponents() - 1]; - // interphaseOps = new ThermodynamicOperations(interphaseSystem); - // interphaseOps.TPflash(); - // // interphaseOps.displayResult(); + return clonedSystem; + } + + /** + *

+ * setfvecMassTrans. + *

+ */ + public void setfvecMassTrans() { + double sumx = 0; + double sumy = 0; + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { + fvec.set(i, 0, Math + .log((interphaseSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient() + * interphaseSystem.getPhases()[0].getComponents()[i].getx())) + - Math.log((interphaseSystem.getPhases()[1].getComponents()[i].getFugacityCoefficient() + * interphaseSystem.getPhases()[1].getComponents()[i].getx()))); + sumx += interphaseSystem.getPhases()[0].getComponents()[i].getx(); + sumy += interphaseSystem.getPhases()[1].getComponents()[i].getx(); } - - /** {@inheritDoc} */ - @Override - public NonEquilibriumFluidBoundary clone() { - NonEquilibriumFluidBoundary clonedSystem = null; - - try { - clonedSystem = (NonEquilibriumFluidBoundary) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); - } - - return clonedSystem; + fvec.set(bulkSystem.getPhases()[0].getNumberOfComponents() - 1, 0, 1.0 - sumx); + fvec.set(bulkSystem.getPhases()[0].getNumberOfComponents(), 0, 1.0 - sumy); + + for (int i = bulkSystem.getPhases()[0].getNumberOfComponents() + 1; i < (2 + * bulkSystem.getPhases()[0].getNumberOfComponents()); i++) { + fvec.set(i, 0, + (totalMassTransferCoefficientMatrix[1].get( + i - (bulkSystem.getPhases()[0].getNumberOfComponents() + 1), + i - (bulkSystem.getPhases()[0].getNumberOfComponents() + 1)) + * (bulkSystem.getPhases()[0].getComponents()[i + - (bulkSystem.getPhases()[0].getNumberOfComponents() + 1)].getx() + - interphaseSystem.getPhases()[0].getComponents()[i + - (bulkSystem.getPhases()[0].getNumberOfComponents() + 1)].getx()) + + (totalMassTransferCoefficientMatrix[0].get( + i - (bulkSystem.getPhases()[0].getNumberOfComponents() + 1), + i - (bulkSystem.getPhases()[0].getNumberOfComponents() + 1)) + * (bulkSystem.getPhases()[1].getComponents()[i + - (bulkSystem.getPhases()[0].getNumberOfComponents() + 1)].getx() + - interphaseSystem.getPhases()[1].getComponents()[i + - (bulkSystem.getPhases()[0].getNumberOfComponents() + 1)].getx())))); } - - /** - *

- * setfvecMassTrans. - *

- */ - public void setfvecMassTrans() { - double sumx = 0, sumy = 0; - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { - fvec.set(i, 0, Math.log( - (interphaseSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient() - * interphaseSystem.getPhases()[0].getComponents()[i].getx())) - - Math.log((interphaseSystem.getPhases()[1].getComponents()[i] - .getFugacityCoefficient() - * interphaseSystem.getPhases()[1].getComponents()[i].getx()))); - sumx += interphaseSystem.getPhases()[0].getComponents()[i].getx(); - sumy += interphaseSystem.getPhases()[1].getComponents()[i].getx(); - } - fvec.set(bulkSystem.getPhases()[0].getNumberOfComponents() - 1, 0, 1.0 - sumx); - fvec.set(bulkSystem.getPhases()[0].getNumberOfComponents(), 0, 1.0 - sumy); - - for (int i = bulkSystem.getPhases()[0].getNumberOfComponents() + 1; i < (2 - * bulkSystem.getPhases()[0].getNumberOfComponents()); i++) { - fvec.set(i, 0, (totalMassTransferCoefficientMatrix[1].get( - i - (bulkSystem.getPhases()[0].getNumberOfComponents() + 1), - i - (bulkSystem.getPhases()[0].getNumberOfComponents() + 1)) - * (bulkSystem.getPhases()[0].getComponents()[i - - (bulkSystem.getPhases()[0].getNumberOfComponents() + 1)].getx() - - interphaseSystem.getPhases()[0].getComponents()[i - - (bulkSystem.getPhases()[0].getNumberOfComponents() + 1)] - .getx()) - + (totalMassTransferCoefficientMatrix[0].get( - i - (bulkSystem.getPhases()[0].getNumberOfComponents() + 1), - i - (bulkSystem.getPhases()[0].getNumberOfComponents() + 1)) - * (bulkSystem.getPhases()[1].getComponents()[i - - (bulkSystem.getPhases()[0].getNumberOfComponents() + 1)] - .getx() - - interphaseSystem.getPhases()[1].getComponents()[i - - (bulkSystem.getPhases()[0].getNumberOfComponents() - + 1)].getx())))); - } + } + + /** + *

+ * setfvecMassTrans2. + *

+ */ + public void setfvecMassTrans2() { + double sumx = 0.0; + double sumy = 0.0; + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { + fvec.set(i, 0, Math + .log((interphaseSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient() + * interphaseSystem.getPhases()[0].getComponents()[i].getx())) + - Math.log((interphaseSystem.getPhases()[1].getComponents()[i].getFugacityCoefficient() + * interphaseSystem.getPhases()[1].getComponents()[i].getx()))); + sumx += interphaseSystem.getPhases()[1].getComponents()[i].getx(); + sumy += interphaseSystem.getPhases()[0].getComponents()[i].getx(); } - /** - *

- * setfvecMassTrans2. - *

- */ - public void setfvecMassTrans2() { - double sumx = 0.0, sumy = 0.0; - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { - fvec.set(i, 0, Math.log( - (interphaseSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient() - * interphaseSystem.getPhases()[0].getComponents()[i].getx())) - - Math.log((interphaseSystem.getPhases()[1].getComponents()[i] - .getFugacityCoefficient() - * interphaseSystem.getPhases()[1].getComponents()[i].getx()))); - sumx += interphaseSystem.getPhases()[1].getComponents()[i].getx(); - sumy += interphaseSystem.getPhases()[0].getComponents()[i].getx(); - } - - fvec.set(bulkSystem.getPhases()[0].getNumberOfComponents(), 0, 1.0 - sumx); - fvec.set(bulkSystem.getPhases()[0].getNumberOfComponents() + 1, 0, 1.0 - sumy); - - Matrix dx = new Matrix(1, bulkSystem.getPhases()[0].getNumberOfComponents() - 1); - Matrix dy = new Matrix(1, bulkSystem.getPhases()[0].getNumberOfComponents() - 1); - Matrix x = new Matrix(1, bulkSystem.getPhases()[0].getNumberOfComponents() - 1); - Matrix y = new Matrix(1, bulkSystem.getPhases()[0].getNumberOfComponents() - 1); - - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents() - 1; i++) { - dy.set(0, i, (bulkSystem.getPhases()[0].getComponents()[i].getx() - - interphaseSystem.getPhases()[0].getComponents()[i].getx())); - dx.set(0, i, (bulkSystem.getPhases()[1].getComponents()[i].getx() - - interphaseSystem.getPhases()[1].getComponents()[i].getx())); - y.set(0, i, (bulkSystem.getPhases()[0].getComponents()[i].getx())); - x.set(0, i, (bulkSystem.getPhases()[1].getComponents()[i].getx())); - } - - Matrix fluxX = totalMassTransferCoefficientMatrix[1].times(dx.transpose()) - .times(bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[1].getMolarMass()); - Matrix fluxY = totalMassTransferCoefficientMatrix[0].times(dy.transpose()) - .times(bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[0].getMolarMass()); - - // fluxX.print(10,10); - // fluxY.print(10,10); - // totalMassTransferCoefficientMatrix[0].print(10,10); - - // System.out.println("n flux"); - // nFlux.getMatrix(0,bulkSystem.getPhases()[1].getNumberOfComponents()-2,0,0).print(10,10); - // System.out.println("j gas flux"); - // fluxY.print(10,10); - // System.out.println("j gliq flux"); - // fluxX.print(10,10); - // System.out.println("yn gas flux"); - // y.transpose().times(totalFlux).print(10,10); - // System.out.println("xn gas flux"); - // x.transpose().times(totalFlux).print(10,10); - - Matrix errX = - nFlux.getMatrix(0, bulkSystem.getPhases()[1].getNumberOfComponents() - 2, 0, 0) - .plus(fluxX).minus(x.transpose().times(totalFlux)); - Matrix errY = - nFlux.getMatrix(0, bulkSystem.getPhases()[0].getNumberOfComponents() - 2, 0, 0) - .minus(fluxY).minus(y.transpose().times(totalFlux)); - - for (int i = bulkSystem.getPhases()[0].getNumberOfComponents() - + 2; i < (2 * bulkSystem.getPhases()[0].getNumberOfComponents() + 1); i++) { - fvec.set(i, 0, - errX.get((i - (bulkSystem.getPhases()[0].getNumberOfComponents() + 2)), 0)); - fvec.set((i + (bulkSystem.getPhases()[0].getNumberOfComponents() - 1)), 0, - errY.get((i - (bulkSystem.getPhases()[0].getNumberOfComponents() + 2)), 0)); - } - - /* - * System.out.println("fvec"); fvec.print(30,30); errX.print(10,10); errY.print(10,10); - */ - // fluxX.print(10,10); - // fluxY.print(10,10); - // Matrix fluxY = totalMassTransferCoefficientMatrix[1] + fvec.set(bulkSystem.getPhases()[0].getNumberOfComponents(), 0, 1.0 - sumx); + fvec.set(bulkSystem.getPhases()[0].getNumberOfComponents() + 1, 0, 1.0 - sumy); + + Matrix dx = new Matrix(1, bulkSystem.getPhases()[0].getNumberOfComponents() - 1); + Matrix dy = new Matrix(1, bulkSystem.getPhases()[0].getNumberOfComponents() - 1); + Matrix x = new Matrix(1, bulkSystem.getPhases()[0].getNumberOfComponents() - 1); + Matrix y = new Matrix(1, bulkSystem.getPhases()[0].getNumberOfComponents() - 1); + + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents() - 1; i++) { + dy.set(0, i, (bulkSystem.getPhases()[0].getComponents()[i].getx() + - interphaseSystem.getPhases()[0].getComponents()[i].getx())); + dx.set(0, i, (bulkSystem.getPhases()[1].getComponents()[i].getx() + - interphaseSystem.getPhases()[1].getComponents()[i].getx())); + y.set(0, i, (bulkSystem.getPhases()[0].getComponents()[i].getx())); + x.set(0, i, (bulkSystem.getPhases()[1].getComponents()[i].getx())); } - /** - *

- * setJacMassTrans. - *

- */ - public void setJacMassTrans() { - double dij = 0, tempJ = 0; - Jac.timesEquals(0.0); - - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents() - 1; i++) { - for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfComponents(); j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta - tempJ = dij * 1.0 / interphaseSystem.getPhases()[0].getComponents()[i].getx() - + interphaseSystem.getPhases()[0].getComponents()[i].getdfugdx(j); - - // tempJ= - // dij*interphaseSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient()+interphaseSystem.getPhases()[0].getComponents()[i].getx()*interphaseSystem.getPhases()[0].getComponents()[i].getdfugdx(j); - Jac.set(i, j, tempJ); - } - } - - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { - Jac.set(bulkSystem.getPhases()[0].getNumberOfComponents() - 1, i, -1.0); - Jac.set(bulkSystem.getPhases()[0].getNumberOfComponents() - 1, - bulkSystem.getPhases()[0].getNumberOfComponents() + i, 0.0); - Jac.set(bulkSystem.getPhases()[0].getNumberOfComponents(), i, 0.0); - Jac.set(bulkSystem.getPhases()[0].getNumberOfComponents(), - bulkSystem.getPhases()[0].getNumberOfComponents() + i, -1.0); - } - - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents() - 1; i++) { - for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfComponents(); j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta - tempJ = dij * 1.0 / interphaseSystem.getPhases()[1].getComponents()[i].getx() - + interphaseSystem.getPhases()[1].getComponents()[i].getdfugdx(j); - - // tempJ= - // dij*interphaseSystem.getPhases()[1].getComponents()[i].getFugacityCoefficient()+interphaseSystem.getPhases()[1].getComponents()[i].getx()*interphaseSystem.getPhases()[1].getComponents()[i].getdfugdx(j); - Jac.set(i, j + bulkSystem.getPhases()[0].getNumberOfComponents(), -tempJ); - } - } - - // this must be changed..... - - for (int i = bulkSystem.getPhases()[0].getNumberOfComponents(); i < 2 - * bulkSystem.getPhases()[0].getNumberOfComponents() - 1; i++) { - for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfComponents(); j++) { - dij = i == (j + bulkSystem.getPhases()[0].getNumberOfComponents()) ? 1.0 : 0.0; - tempJ = -dij * (totalMassTransferCoefficientMatrix[1].get( - i - bulkSystem.getPhases()[0].getNumberOfComponents(), - i - bulkSystem.getPhases()[0].getNumberOfComponents())); - Jac.set(i + 1, j, tempJ); - } - } - - for (int i = bulkSystem.getPhases()[0].getNumberOfComponents(); i < 2 - * bulkSystem.getPhases()[0].getNumberOfComponents() - 1; i++) { - for (int j = bulkSystem.getPhases()[0].getNumberOfComponents(); j < 2 - * bulkSystem.getPhases()[0].getNumberOfComponents(); j++) { - dij = i == j ? 1.0 : 0.0; - tempJ = -dij * (totalMassTransferCoefficientMatrix[0].get( - i - bulkSystem.getPhases()[0].getNumberOfComponents(), - i - bulkSystem.getPhases()[0].getNumberOfComponents())); - Jac.set(i + 1, j, tempJ); - } - } + Matrix fluxX = totalMassTransferCoefficientMatrix[1].times(dx.transpose()) + .times(bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() + / bulkSystem.getPhases()[1].getMolarMass()); + Matrix fluxY = totalMassTransferCoefficientMatrix[0].times(dy.transpose()) + .times(bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() + / bulkSystem.getPhases()[0].getMolarMass()); + + // fluxX.print(10,10); + // fluxY.print(10,10); + // totalMassTransferCoefficientMatrix[0].print(10,10); + + // System.out.println("n flux"); + // nFlux.getMatrix(0,bulkSystem.getPhases()[1].getNumberOfComponents()-2,0,0).print(10,10); + // System.out.println("j gas flux"); + // fluxY.print(10,10); + // System.out.println("j gliq flux"); + // fluxX.print(10,10); + // System.out.println("yn gas flux"); + // y.transpose().times(totalFlux).print(10,10); + // System.out.println("xn gas flux"); + // x.transpose().times(totalFlux).print(10,10); + + Matrix errX = nFlux.getMatrix(0, bulkSystem.getPhases()[1].getNumberOfComponents() - 2, 0, 0) + .plus(fluxX).minus(x.transpose().times(totalFlux)); + Matrix errY = nFlux.getMatrix(0, bulkSystem.getPhases()[0].getNumberOfComponents() - 2, 0, 0) + .minus(fluxY).minus(y.transpose().times(totalFlux)); + + for (int i = bulkSystem.getPhases()[0].getNumberOfComponents() + + 2; i < (2 * bulkSystem.getPhases()[0].getNumberOfComponents() + 1); i++) { + fvec.set(i, 0, errX.get((i - (bulkSystem.getPhases()[0].getNumberOfComponents() + 2)), 0)); + fvec.set((i + (bulkSystem.getPhases()[0].getNumberOfComponents() - 1)), 0, + errY.get((i - (bulkSystem.getPhases()[0].getNumberOfComponents() + 2)), 0)); } - /** - *

- * setJacMassTrans2. - *

+ /* + * System.out.println("fvec"); fvec.print(30,30); errX.print(10,10); errY.print(10,10); */ - public void setJacMassTrans2() { - double dij = 0, tempJ = 0; - Jac.timesEquals(0.0); - - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { - for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfComponents(); j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta - tempJ = dij * 1.0 / interphaseSystem.getPhases()[0].getComponents()[i].getx() - + interphaseSystem.getPhases()[0].getComponents()[i].getdfugdx(j); - Jac.set(i, j, tempJ); - } - } + // fluxX.print(10,10); + // fluxY.print(10,10); + // Matrix fluxY = totalMassTransferCoefficientMatrix[1] + } + + /** + *

+ * setJacMassTrans. + *

+ */ + public void setJacMassTrans() { + double dij = 0; + double tempJ = 0; + Jac.timesEquals(0.0); + + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents() - 1; i++) { + for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfComponents(); j++) { + dij = i == j ? 1.0 : 0.0; // Kroneckers delta + tempJ = dij * 1.0 / interphaseSystem.getPhases()[0].getComponents()[i].getx() + + interphaseSystem.getPhases()[0].getComponents()[i].getdfugdx(j); + + // tempJ= + // dij*interphaseSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient()+interphaseSystem.getPhases()[0].getComponents()[i].getx()*interphaseSystem.getPhases()[0].getComponents()[i].getdfugdx(j); + Jac.set(i, j, tempJ); + } + } - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { - Jac.set(bulkSystem.getPhases()[0].getNumberOfComponents(), i, 0.0); - Jac.set(bulkSystem.getPhases()[0].getNumberOfComponents(), - bulkSystem.getPhases()[0].getNumberOfComponents() + i, -1.0); - Jac.set(bulkSystem.getPhases()[0].getNumberOfComponents() + 1, i, -1.0); - Jac.set(bulkSystem.getPhases()[0].getNumberOfComponents() + 1, - bulkSystem.getPhases()[0].getNumberOfComponents() + i, 0.0); - } + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { + Jac.set(bulkSystem.getPhases()[0].getNumberOfComponents() - 1, i, -1.0); + Jac.set(bulkSystem.getPhases()[0].getNumberOfComponents() - 1, + bulkSystem.getPhases()[0].getNumberOfComponents() + i, 0.0); + Jac.set(bulkSystem.getPhases()[0].getNumberOfComponents(), i, 0.0); + Jac.set(bulkSystem.getPhases()[0].getNumberOfComponents(), + bulkSystem.getPhases()[0].getNumberOfComponents() + i, -1.0); + } - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { - for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfComponents(); j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta - tempJ = dij * 1.0 / interphaseSystem.getPhases()[1].getComponents()[i].getx() - + interphaseSystem.getPhases()[1].getComponents()[i].getdfugdx(j); - Jac.set(i, j + bulkSystem.getPhases()[0].getNumberOfComponents(), -tempJ); - } - } + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents() - 1; i++) { + for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfComponents(); j++) { + dij = i == j ? 1.0 : 0.0; // Kroneckers delta + tempJ = dij * 1.0 / interphaseSystem.getPhases()[1].getComponents()[i].getx() + + interphaseSystem.getPhases()[1].getComponents()[i].getdfugdx(j); - // this must be changed..... - - for (int i = bulkSystem.getPhases()[0].getNumberOfComponents(); i < 2 - * bulkSystem.getPhases()[0].getNumberOfComponents() - 1; i++) { - for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfComponents(); j++) { - dij = i == (j + bulkSystem.getPhases()[0].getNumberOfComponents()) ? 1.0 : 0.0; - // tempJ = - // -dij*(totalMassTransferCoefficientMatrix[1].get(i-bulkSystem.getPhases()[0].getNumberOfComponents(), - // i-bulkSystem.getPhases()[0].getNumberOfComponents())); - // tempJ = dij * - // totalMassTransferCoefficientMatrix[0].getRowSum(i-bulkSystem.getPhases()[0].getNumberOfComponents()); - // Jac.set(i+2,j+2*bulkSystem.getPhases()[0].getNumberOfComponents()-1, - - // interphaseSystem.getPhases()[0].getComponents()[i-bulkSystem.getPhases()[0].getNumberOfComponents()].getx()); - if (j != bulkSystem.getPhases()[0].getNumberOfComponents() - 1) { - Jac.set(i + 2, j + bulkSystem.getPhases()[0].getNumberOfComponents(), - -totalMassTransferCoefficientMatrix[1] - .get(i - bulkSystem.getPhases()[0].getNumberOfComponents(), j) - * bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[1].getMolarMass());// tempJ); - } - Jac.set(i + 2, j + 2 * bulkSystem.getPhases()[0].getNumberOfComponents(), - dij - bulkSystem.getPhases()[1].getComponents()[i - - bulkSystem.getPhases()[0].getNumberOfComponents()].getx()); - } - } + // tempJ= + // dij*interphaseSystem.getPhases()[1].getComponents()[i].getFugacityCoefficient()+interphaseSystem.getPhases()[1].getComponents()[i].getx()*interphaseSystem.getPhases()[1].getComponents()[i].getdfugdx(j); + Jac.set(i, j + bulkSystem.getPhases()[0].getNumberOfComponents(), -tempJ); + } + } - for (int i = bulkSystem.getPhases()[0].getNumberOfComponents(); i < 2 - * bulkSystem.getPhases()[0].getNumberOfComponents() - 1; i++) { - for (int j = bulkSystem.getPhases()[0].getNumberOfComponents(); j < 2 - * bulkSystem.getPhases()[0].getNumberOfComponents(); j++) { - dij = i == j ? 1.0 : 0.0; - // tempJ = - // -dij*(totalMassTransferCoefficientMatrix[1].get(i-bulkSystem.getPhases()[0].getNumberOfComponents(), - // i-bulkSystem.getPhases()[0].getNumberOfComponents())); - // tempJ = dij * - // totalMassTransferCoefficientMatrix[1].getRowSum(i-bulkSystem.getPhases()[0].getNumberOfComponents()*1.0/bulkSystem.getPhases()[1].getMolarVolume()); - if (j != 2 * bulkSystem.getPhases()[0].getNumberOfComponents() - 1) { - Jac.set(i + 1 + bulkSystem.getPhases()[0].getNumberOfComponents(), - j - bulkSystem.getPhases()[0].getNumberOfComponents(), - totalMassTransferCoefficientMatrix[0].get( - i - bulkSystem.getPhases()[0].getNumberOfComponents(), - j - bulkSystem.getPhases()[0].getNumberOfComponents()) - * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[0].getMolarMass());// tempJ); - } - Jac.set(i + 1 + bulkSystem.getPhases()[0].getNumberOfComponents(), - j + bulkSystem.getPhases()[0].getNumberOfComponents(), - dij - bulkSystem.getPhases()[0].getComponents()[i - - bulkSystem.getPhases()[0].getNumberOfComponents()].getx()); - } - } - // System.out.println("jac"); - // Jac.print(10,10); - // totalMassTransferCoefficientMatrix[0].print(20,20); - // totalMassTransferCoefficientMatrix[1].print(20,20); + // this must be changed..... + + for (int i = bulkSystem.getPhases()[0].getNumberOfComponents(); i < 2 + * bulkSystem.getPhases()[0].getNumberOfComponents() - 1; i++) { + for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfComponents(); j++) { + dij = i == (j + bulkSystem.getPhases()[0].getNumberOfComponents()) ? 1.0 : 0.0; + tempJ = -dij * (totalMassTransferCoefficientMatrix[1].get( + i - bulkSystem.getPhases()[0].getNumberOfComponents(), + i - bulkSystem.getPhases()[0].getNumberOfComponents())); + Jac.set(i + 1, j, tempJ); + } } - /** - *

- * Setter for the field uMassTrans. - *

- */ - public void setuMassTrans() { - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { - uMassTrans.set(i, 0, interphaseSystem.getPhases()[0].getComponents()[i].getx()); - uMassTrans.set(i + bulkSystem.getPhases()[0].getNumberOfComponents(), 0, - interphaseSystem.getPhases()[1].getComponents()[i].getx()); - } + for (int i = bulkSystem.getPhases()[0].getNumberOfComponents(); i < 2 + * bulkSystem.getPhases()[0].getNumberOfComponents() - 1; i++) { + for (int j = bulkSystem.getPhases()[0].getNumberOfComponents(); j < 2 + * bulkSystem.getPhases()[0].getNumberOfComponents(); j++) { + dij = i == j ? 1.0 : 0.0; + tempJ = -dij * (totalMassTransferCoefficientMatrix[0].get( + i - bulkSystem.getPhases()[0].getNumberOfComponents(), + i - bulkSystem.getPhases()[0].getNumberOfComponents())); + Jac.set(i + 1, j, tempJ); + } + } + } + + /** + *

+ * setJacMassTrans2. + *

+ */ + public void setJacMassTrans2() { + double dij = 0; + double tempJ = 0; + Jac.timesEquals(0.0); + + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { + for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfComponents(); j++) { + dij = i == j ? 1.0 : 0.0; // Kroneckers delta + tempJ = dij * 1.0 / interphaseSystem.getPhases()[0].getComponents()[i].getx() + + interphaseSystem.getPhases()[0].getComponents()[i].getdfugdx(j); + Jac.set(i, j, tempJ); + } + } - for (int i = 2 * bulkSystem.getPhases()[0].getNumberOfComponents(); i < 3 - * bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { - uMassTrans.set(i, 0, - nFlux.get(i - 2 * bulkSystem.getPhases()[0].getNumberOfComponents(), 0)); - } + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { + Jac.set(bulkSystem.getPhases()[0].getNumberOfComponents(), i, 0.0); + Jac.set(bulkSystem.getPhases()[0].getNumberOfComponents(), + bulkSystem.getPhases()[0].getNumberOfComponents() + i, -1.0); + Jac.set(bulkSystem.getPhases()[0].getNumberOfComponents() + 1, i, -1.0); + Jac.set(bulkSystem.getPhases()[0].getNumberOfComponents() + 1, + bulkSystem.getPhases()[0].getNumberOfComponents() + i, 0.0); } - /** - *

- * updateMassTrans. - *

- */ - public void updateMassTrans() { - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { - interphaseSystem.getPhases()[0].getComponents()[i].setx(uMassTrans.get(i, 0)); - interphaseSystem.getPhases()[1].getComponents()[i] - .setx(uMassTrans.get(i + bulkSystem.getPhases()[0].getNumberOfComponents(), 0)); - } + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { + for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfComponents(); j++) { + dij = i == j ? 1.0 : 0.0; // Kroneckers delta + tempJ = dij * 1.0 / interphaseSystem.getPhases()[1].getComponents()[i].getx() + + interphaseSystem.getPhases()[1].getComponents()[i].getdfugdx(j); + Jac.set(i, j + bulkSystem.getPhases()[0].getNumberOfComponents(), -tempJ); + } + } - for (int i = 2 * bulkSystem.getPhases()[0].getNumberOfComponents(); i < 3 - * bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { - nFlux.set(i - 2 * bulkSystem.getPhases()[0].getNumberOfComponents(), 0, - uMassTrans.get(i, 0)); + // this must be changed..... + + for (int i = bulkSystem.getPhases()[0].getNumberOfComponents(); i < 2 + * bulkSystem.getPhases()[0].getNumberOfComponents() - 1; i++) { + for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfComponents(); j++) { + dij = i == (j + bulkSystem.getPhases()[0].getNumberOfComponents()) ? 1.0 : 0.0; + // tempJ = + // -dij*(totalMassTransferCoefficientMatrix[1].get(i-bulkSystem.getPhases()[0].getNumberOfComponents(), + // i-bulkSystem.getPhases()[0].getNumberOfComponents())); + // tempJ = dij * + // totalMassTransferCoefficientMatrix[0].getRowSum(i-bulkSystem.getPhases()[0].getNumberOfComponents()); + // Jac.set(i+2,j+2*bulkSystem.getPhases()[0].getNumberOfComponents()-1, - + // interphaseSystem.getPhases()[0].getComponents()[i-bulkSystem.getPhases()[0].getNumberOfComponents()].getx()); + if (j != bulkSystem.getPhases()[0].getNumberOfComponents() - 1) { + Jac.set(i + 2, j + bulkSystem.getPhases()[0].getNumberOfComponents(), + -totalMassTransferCoefficientMatrix[1] + .get(i - bulkSystem.getPhases()[0].getNumberOfComponents(), j) + * bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() + / bulkSystem.getPhases()[1].getMolarMass()); // tempJ); } + Jac.set(i + 2, j + 2 * bulkSystem.getPhases()[0].getNumberOfComponents(), + dij - bulkSystem.getPhases()[1].getComponents()[i + - bulkSystem.getPhases()[0].getNumberOfComponents()].getx()); + } } - /** - *

- * calcMolFractionDifference. - *

- */ - public void calcMolFractionDifference() { - for (int i = 0; i < getBulkSystem().getPhases()[0].getNumberOfComponents() - 1; i++) { - molFractionDifference[0][i] = bulkSystem.getPhases()[0].getComponents()[i].getx() - - interphaseSystem.getPhases()[0].getComponents()[i].getx(); - molFractionDifference[1][i] = bulkSystem.getPhases()[1].getComponents()[i].getx() - - interphaseSystem.getPhases()[1].getComponents()[i].getx(); + for (int i = bulkSystem.getPhases()[0].getNumberOfComponents(); i < 2 + * bulkSystem.getPhases()[0].getNumberOfComponents() - 1; i++) { + for (int j = bulkSystem.getPhases()[0].getNumberOfComponents(); j < 2 + * bulkSystem.getPhases()[0].getNumberOfComponents(); j++) { + dij = i == j ? 1.0 : 0.0; + // tempJ = + // -dij*(totalMassTransferCoefficientMatrix[1].get(i-bulkSystem.getPhases()[0].getNumberOfComponents(), + // i-bulkSystem.getPhases()[0].getNumberOfComponents())); + // tempJ = dij * + // totalMassTransferCoefficientMatrix[1].getRowSum(i-bulkSystem.getPhases()[0].getNumberOfComponents()*1.0/bulkSystem.getPhases()[1].getMolarVolume()); + if (j != 2 * bulkSystem.getPhases()[0].getNumberOfComponents() - 1) { + Jac.set(i + 1 + bulkSystem.getPhases()[0].getNumberOfComponents(), + j - bulkSystem.getPhases()[0].getNumberOfComponents(), + totalMassTransferCoefficientMatrix[0].get( + i - bulkSystem.getPhases()[0].getNumberOfComponents(), + j - bulkSystem.getPhases()[0].getNumberOfComponents()) + * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() + / bulkSystem.getPhases()[0].getMolarMass()); // tempJ); } + Jac.set(i + 1 + bulkSystem.getPhases()[0].getNumberOfComponents(), + j + bulkSystem.getPhases()[0].getNumberOfComponents(), dij - bulkSystem.getPhases()[0] + .getComponents()[i - bulkSystem.getPhases()[0].getNumberOfComponents()].getx()); + } } - - /** - *

- * calcHeatTransferCoefficients. - *

- * - * @param phase a int - */ - public void calcHeatTransferCoefficients(int phase) { - prandtlNumber[phase] = getBulkSystem().getPhases()[phase].getCp() - / getBulkSystem().getPhases()[phase].getNumberOfMolesInPhase() - * getBulkSystem().getPhases()[phase].getPhysicalProperties().getViscosity() - / getBulkSystem().getPhases()[phase].getPhysicalProperties().getConductivity(); - // System.out.println("prandtlNumber " + prandtlNumber[phase] + " interface " + - // flowNode.getInterphaseTransportCoefficient().calcInterphaseHeatTransferCoefficient(phase, - // prandtlNumber[phase], flowNode)); - heatTransferCoefficient[phase] = flowNode.getInterphaseTransportCoefficient() - .calcInterphaseHeatTransferCoefficient(phase, prandtlNumber[phase], flowNode); + // System.out.println("jac"); + // Jac.print(10,10); + // totalMassTransferCoefficientMatrix[0].print(20,20); + // totalMassTransferCoefficientMatrix[1].print(20,20); + } + + /** + *

+ * Setter for the field uMassTrans. + *

+ */ + public void setuMassTrans() { + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { + uMassTrans.set(i, 0, interphaseSystem.getPhases()[0].getComponents()[i].getx()); + uMassTrans.set(i + bulkSystem.getPhases()[0].getNumberOfComponents(), 0, + interphaseSystem.getPhases()[1].getComponents()[i].getx()); } - /** - *

- * calcHeatTransferCorrection. - *

- * - * @param phase a int - */ - public void calcHeatTransferCorrection(int phase) { - double temp = 1.0e-20; - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { - if (Math.abs(nFlux.get(i, 0)) < 1e-20) { - temp += 0.0; - } else { - temp += nFlux.get(i, 0) * getBulkSystem().getPhases()[phase].getCp() - / getBulkSystem().getPhases()[phase].getNumberOfMolesInPhase() - / heatTransferCoefficient[phase];// bulkSystem.getPhases()[0].getComponents()[i].getNumberOfMolesInPhase()* - } - } - // System.out.println("temp eat " + temp); - // System.out.println("temo " + temp); - if (Math.abs(temp) > 1e-10) { - heatTransferCorrection[phase] = temp / (Math.exp(temp) - 1.0); - } else { - heatTransferCorrection[phase] = 1.0; - } - // System.out.println("heat corr. " + heatTransferCorrection[phase]); + for (int i = 2 * bulkSystem.getPhases()[0].getNumberOfComponents(); i < 3 + * bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { + uMassTrans.set(i, 0, nFlux.get(i - 2 * bulkSystem.getPhases()[0].getNumberOfComponents(), 0)); } - - /** {@inheritDoc} */ - @Override - public void initMassTransferCalc() { - super.initMassTransferCalc(); + } + + /** + *

+ * updateMassTrans. + *

+ */ + public void updateMassTrans() { + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { + interphaseSystem.getPhases()[0].getComponents()[i].setx(uMassTrans.get(i, 0)); + interphaseSystem.getPhases()[1].getComponents()[i] + .setx(uMassTrans.get(i + bulkSystem.getPhases()[0].getNumberOfComponents(), 0)); } - /** {@inheritDoc} */ - @Override - public void initHeatTransferCalc() { - super.initHeatTransferCalc(); + for (int i = 2 * bulkSystem.getPhases()[0].getNumberOfComponents(); i < 3 + * bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { + nFlux.set(i - 2 * bulkSystem.getPhases()[0].getNumberOfComponents(), 0, uMassTrans.get(i, 0)); } - - /** {@inheritDoc} */ - @Override - public void init() { - calcMolFractionDifference(); - super.init(); + } + + /** + *

+ * calcMolFractionDifference. + *

+ */ + public void calcMolFractionDifference() { + for (int i = 0; i < getBulkSystem().getPhases()[0].getNumberOfComponents() - 1; i++) { + molFractionDifference[0][i] = bulkSystem.getPhases()[0].getComponents()[i].getx() + - interphaseSystem.getPhases()[0].getComponents()[i].getx(); + molFractionDifference[1][i] = bulkSystem.getPhases()[1].getComponents()[i].getx() + - interphaseSystem.getPhases()[1].getComponents()[i].getx(); } - - /** {@inheritDoc} */ - @Override - public void heatTransSolve() { - double f = 0; - double df = 0; - double dhtot = 0.0; - int iter = 0; - do { - iter++; - dhtot = 0.0; - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { - dhtot += nFlux.get(i, 0) * (bulkSystem.getPhases()[0].getComponents()[i] - .getEnthalpy(bulkSystem.getPhases()[0].getTemperature()) - / bulkSystem.getPhases()[0].getComponents()[i].getNumberOfMolesInPhase() - - bulkSystem.getPhases()[1].getComponents()[i] - .getEnthalpy(bulkSystem.getPhases()[1].getTemperature()) - / bulkSystem.getPhases()[1].getComponents()[i] - .getNumberOfMolesInPhase()); - } - // System.out.println("dhtot " + dhtot + " heat coef " + - // heatTransferCoefficient[0]); - f = heatTransferCoefficient[0] * heatTransferCorrection[0] - * (bulkSystem.getPhases()[0].getTemperature() - - interphaseSystem.getTemperature()) - + heatTransferCoefficient[1] * heatTransferCorrection[1] - * (bulkSystem.getPhases()[1].getTemperature() - - interphaseSystem.getTemperature()) - + dhtot; - - df = -heatTransferCoefficient[0] * heatTransferCorrection[0] - - heatTransferCoefficient[1] * heatTransferCorrection[1]; - // System.out.println("f " + f + " df " + df); - // if(interphaseSystem.getTemperature() - f/df>0.0) - // interphaseSystem.setTemperature(interphaseSystem.getTemperature() - f/df); - interphaseSystem.setTemperature(interphaseSystem.getTemperature() - f / df); - // System.out.println("new temp " + interphaseSystem.getTemperature()); - } while (Math.abs(f) > 1e-6 && iter < 100); - - interphaseHeatFlux[0] = -heatTransferCoefficient[0] * heatTransferCorrection[0] - * (bulkSystem.getPhases()[0].getTemperature() - interphaseSystem.getTemperature()); - interphaseHeatFlux[1] = -heatTransferCoefficient[1] * heatTransferCorrection[1] - * (bulkSystem.getPhases()[1].getTemperature() - interphaseSystem.getTemperature()); - // System.out.println("heat flox here " + getInterphaseHeatFlux(0) + " heatflux2 - // " + getInterphaseHeatFlux(1)); + } + + /** + *

+ * calcHeatTransferCoefficients. + *

+ * + * @param phase a int + */ + public void calcHeatTransferCoefficients(int phase) { + prandtlNumber[phase] = getBulkSystem().getPhases()[phase].getCp() + / getBulkSystem().getPhases()[phase].getNumberOfMolesInPhase() + * getBulkSystem().getPhases()[phase].getPhysicalProperties().getViscosity() + / getBulkSystem().getPhases()[phase].getPhysicalProperties().getConductivity(); + // System.out.println("prandtlNumber " + prandtlNumber[phase] + " interface " + + // flowNode.getInterphaseTransportCoefficient().calcInterphaseHeatTransferCoefficient(phase, + // prandtlNumber[phase], flowNode)); + heatTransferCoefficient[phase] = flowNode.getInterphaseTransportCoefficient() + .calcInterphaseHeatTransferCoefficient(phase, prandtlNumber[phase], flowNode); + } + + /** + *

+ * calcHeatTransferCorrection. + *

+ * + * @param phase a int + */ + public void calcHeatTransferCorrection(int phase) { + double temp = 1.0e-20; + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { + if (Math.abs(nFlux.get(i, 0)) < 1e-20) { + temp += 0.0; + } else { + temp += nFlux.get(i, 0) * getBulkSystem().getPhases()[phase].getCp() + / getBulkSystem().getPhases()[phase].getNumberOfMolesInPhase() + / heatTransferCoefficient[phase]; // bulkSystem.getPhases()[0].getComponents()[i].getNumberOfMolesInPhase()* + } } - - /** {@inheritDoc} */ - @Override - public void massTransSolve() { - int iter = 1; - double err = 1.0e10; - // double oldErr = 0.0; - double factor = 10.0; - // if(bulkSystem.isChemicalSystem()) factor=100.0; - setuMassTrans(); - do { - // oldErr = err; - iter++; - init(); - setfvecMassTrans2(); - setJacMassTrans2(); - dx = Jac.solve(fvec); - if (!Double.valueOf(dx.norm2()).isNaN()) { - uMassTrans.minusEquals(dx.times(iter / (iter + factor))); - err = Math.abs(dx.norm2() / uMassTrans.norm2()); - updateMassTrans(); - calcFluxes(); - } else { - System.out.println("dx: NaN in mass trans calc"); - err = 10; - } - // System.out.println("err " + err); - } while ((err > 1.e-4 && iter < 100) || iter < 5); + // System.out.println("temp eat " + temp); + // System.out.println("temo " + temp); + if (Math.abs(temp) > 1e-10) { + heatTransferCorrection[phase] = temp / (Math.exp(temp) - 1.0); + } else { + heatTransferCorrection[phase] = 1.0; + } + // System.out.println("heat corr. " + heatTransferCorrection[phase]); + } + + /** {@inheritDoc} */ + @Override + public void initMassTransferCalc() { + super.initMassTransferCalc(); + } + + /** {@inheritDoc} */ + @Override + public void initHeatTransferCalc() { + super.initHeatTransferCalc(); + } + + /** {@inheritDoc} */ + @Override + public void init() { + calcMolFractionDifference(); + super.init(); + } + + /** {@inheritDoc} */ + @Override + public void heatTransSolve() { + double f = 0; + double df = 0; + double dhtot = 0.0; + int iter = 0; + do { + iter++; + dhtot = 0.0; + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { + dhtot += nFlux.get(i, 0) * (bulkSystem.getPhases()[0].getComponents()[i] + .getEnthalpy(bulkSystem.getPhases()[0].getTemperature()) + / bulkSystem.getPhases()[0].getComponents()[i].getNumberOfMolesInPhase() + - bulkSystem.getPhases()[1].getComponents()[i] + .getEnthalpy(bulkSystem.getPhases()[1].getTemperature()) + / bulkSystem.getPhases()[1].getComponents()[i].getNumberOfMolesInPhase()); + } + // System.out.println("dhtot " + dhtot + " heat coef " + + // heatTransferCoefficient[0]); + f = heatTransferCoefficient[0] * heatTransferCorrection[0] + * (bulkSystem.getPhases()[0].getTemperature() - interphaseSystem.getTemperature()) + + heatTransferCoefficient[1] * heatTransferCorrection[1] + * (bulkSystem.getPhases()[1].getTemperature() - interphaseSystem.getTemperature()) + + dhtot; + + df = -heatTransferCoefficient[0] * heatTransferCorrection[0] + - heatTransferCoefficient[1] * heatTransferCorrection[1]; + // System.out.println("f " + f + " df " + df); + // if(interphaseSystem.getTemperature() - f/df>0.0) + // interphaseSystem.setTemperature(interphaseSystem.getTemperature() - f/df); + interphaseSystem.setTemperature(interphaseSystem.getTemperature() - f / df); + // System.out.println("new temp " + interphaseSystem.getTemperature()); + } while (Math.abs(f) > 1e-6 && iter < 100); + + interphaseHeatFlux[0] = -heatTransferCoefficient[0] * heatTransferCorrection[0] + * (bulkSystem.getPhases()[0].getTemperature() - interphaseSystem.getTemperature()); + interphaseHeatFlux[1] = -heatTransferCoefficient[1] * heatTransferCorrection[1] + * (bulkSystem.getPhases()[1].getTemperature() - interphaseSystem.getTemperature()); + // System.out.println("heat flox here " + getInterphaseHeatFlux(0) + " heatflux2 + // " + getInterphaseHeatFlux(1)); + } + + /** {@inheritDoc} */ + @Override + public void massTransSolve() { + int iter = 1; + double err = 1.0e10; + // double oldErr = 0.0; + double factor = 10.0; + // if(bulkSystem.isChemicalSystem()) factor=100.0; + setuMassTrans(); + do { + // oldErr = err; + iter++; + init(); + setfvecMassTrans2(); + setJacMassTrans2(); + dx = Jac.solve(fvec); + if (!Double.valueOf(dx.norm2()).isNaN()) { + uMassTrans.minusEquals(dx.times(iter / (iter + factor))); + err = Math.abs(dx.norm2() / uMassTrans.norm2()); + updateMassTrans(); calcFluxes(); + } else { + System.out.println("dx: NaN in mass trans calc"); + err = 10; + } + // System.out.println("err " + err); + } while ((err > 1.e-4 && iter < 100) || iter < 5); + calcFluxes(); + } + + /** {@inheritDoc} */ + @Override + public double[] calcFluxes() { + double sum = 0.0; + // System.out.println("starter..."); + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { + sum += nFlux.get(i, 0); } - /** {@inheritDoc} */ - @Override - public double[] calcFluxes() { - double sum = 0.0; - // System.out.println("starter..."); - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { - sum += nFlux.get(i, 0); - } - - totalFlux = sum;// tot.get(0,0); - // System.out.println("total flux " + totalFlux); - return nFlux.transpose().getArray()[0]; + totalFlux = sum; // tot.get(0,0); + // System.out.println("total flux " + totalFlux); + return nFlux.transpose().getArray()[0]; + } + + /** {@inheritDoc} */ + @Override + public void solve() { + // interphaseSystem = bulkSystem.clone(); + initInterphaseSystem(); + init(); + int iterOuter = 0; + int iterInner = 0; + double totalFluxOld = totalFlux; + + double heatFlux = 0; + double oldHeatFlux = 0.0; + if (heatTransferCalc) { + this.heatTransSolve(); + heatFlux = this.getInterphaseHeatFlux(0); } - /** {@inheritDoc} */ - @Override - public void solve() { - // interphaseSystem = bulkSystem.clone(); - initInterphaseSystem(); - init(); - int iterOuter = 0, iterInner = 0; - double totalFluxOld = totalFlux, heatFlux = 0, oldHeatFlux = 0.0; - - if (heatTransferCalc) { - this.heatTransSolve(); - heatFlux = this.getInterphaseHeatFlux(0); - } + do { + iterInner++; + iterOuter = 0; + oldHeatFlux = heatFlux; + do { + iterOuter++; + totalFluxOld = totalFlux; - do { - iterInner++; - iterOuter = 0; - oldHeatFlux = heatFlux; - do { - iterOuter++; - totalFluxOld = totalFlux; - - if (massTransferCalc) { - massTransSolve(); - } - } while (Math.abs((totalFluxOld - totalFlux) / totalFlux) > 1e-6 && iterOuter < 50); - - if (heatTransferCalc) { - this.heatTransSolve(); - heatFlux = this.getInterphaseHeatFlux(0); - } - } while (Math.abs((oldHeatFlux - heatFlux) / heatFlux) > 1e-6 && heatTransferCalc - && iterInner < 50); - init(); - // System.out.println("iterInner " +iterInner + " temp gas " + - // interphaseSystem.getTemperature(0)+ " temp liq " + - // interphaseSystem.getTemperature(1)); - } + if (massTransferCalc) { + massTransSolve(); + } + } while (Math.abs((totalFluxOld - totalFlux) / totalFlux) > 1e-6 && iterOuter < 50); + + if (heatTransferCalc) { + this.heatTransSolve(); + heatFlux = this.getInterphaseHeatFlux(0); + } + } while (Math.abs((oldHeatFlux - heatFlux) / heatFlux) > 1e-6 && heatTransferCalc + && iterInner < 50); + init(); + // System.out.println("iterInner " +iterInner + " temp gas " + + // interphaseSystem.getTemperature(0)+ " temp liq " + + // interphaseSystem.getTemperature(1)); + } } diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/reactiveFilmModel/ReactiveFluidBoundary.java b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/reactiveFilmModel/ReactiveFluidBoundary.java index 3052e4ce03..868dbd5f3d 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/reactiveFilmModel/ReactiveFluidBoundary.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/reactiveFilmModel/ReactiveFluidBoundary.java @@ -14,567 +14,556 @@ * @version $Id: $Id */ public abstract class ReactiveFluidBoundary extends KrishnaStandartFilmModel { - private static final long serialVersionUID = 1000; - - protected int neq = 0; - protected Matrix dx; - protected Matrix Jac; - protected Matrix fvec; - protected Matrix uMassTrans; - protected Matrix uMassTransold; - protected Matrix Xgij; - - public double[][] molFractionDifference; - - /** - *

- * Constructor for ReactiveFluidBoundary. - *

- */ - public ReactiveFluidBoundary() {} - - /** - *

- * Constructor for ReactiveFluidBoundary. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public ReactiveFluidBoundary(SystemInterface system) { - super(system); - neq = 3 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); - Jac = new Matrix(neq, neq); - fvec = new Matrix(neq, 1); - - // massTransferCoefficientMatrix[0] = new - // Matrix(getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1,getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1); - // massTransferCoefficientMatrix[1] = new - // Matrix(getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1,getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1); - // totalMassTransferCoefficientMatrix[0] = new - // Matrix(getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1,getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1); - // totalMassTransferCoefficientMatrix[1] = new - // Matrix(getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1,getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1); - // molFractionDifference = new - // double[2][getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1]; + private static final long serialVersionUID = 1000; + + protected int neq = 0; + protected Matrix dx; + protected Matrix Jac; + protected Matrix fvec; + protected Matrix uMassTrans; + protected Matrix uMassTransold; + protected Matrix Xgij; + + public double[][] molFractionDifference; + + /** + *

+ * Constructor for ReactiveFluidBoundary. + *

+ */ + public ReactiveFluidBoundary() {} + + /** + *

+ * Constructor for ReactiveFluidBoundary. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public ReactiveFluidBoundary(SystemInterface system) { + super(system); + neq = 3 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); + Jac = new Matrix(neq, neq); + fvec = new Matrix(neq, 1); + + // massTransferCoefficientMatrix[0] = new + // Matrix(getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1,getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1); + // massTransferCoefficientMatrix[1] = new + // Matrix(getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1,getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1); + // totalMassTransferCoefficientMatrix[0] = new + // Matrix(getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1,getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1); + // totalMassTransferCoefficientMatrix[1] = new + // Matrix(getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1,getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1); + // molFractionDifference = new + // double[2][getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1]; + } + + /** + *

+ * Constructor for ReactiveFluidBoundary. + *

+ * + * @param flowNode a {@link neqsim.fluidMechanics.flowNode.FlowNodeInterface} object + */ + public ReactiveFluidBoundary(FlowNodeInterface flowNode) { + super(flowNode); + neq = 3 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); + Jac = new Matrix(neq, neq); + fvec = new Matrix(neq, 1); + + // massTransferCoefficientMatrix[0] = new + // Matrix(getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1,getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1); + // massTransferCoefficientMatrix[1] = new + // Matrix(getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1,getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1); + // totalMassTransferCoefficientMatrix[0] = new + // Matrix(getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1,getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1); + // totalMassTransferCoefficientMatrix[1] = new + // Matrix(getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1,getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1); + // interphaseSystem = bulkSystem.clone(); + // molFractionDifference = new + // double[2][getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1]; + } + + /** {@inheritDoc} */ + @Override + public ReactiveFluidBoundary clone() { + ReactiveFluidBoundary clonedSystem = null; + + try { + clonedSystem = (ReactiveFluidBoundary) super.clone(); + } catch (Exception e) { + e.printStackTrace(System.err); } - /** - *

- * Constructor for ReactiveFluidBoundary. - *

- * - * @param flowNode a {@link neqsim.fluidMechanics.flowNode.FlowNodeInterface} object - */ - public ReactiveFluidBoundary(FlowNodeInterface flowNode) { - super(flowNode); - neq = 3 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); - Jac = new Matrix(neq, neq); - fvec = new Matrix(neq, 1); - - // massTransferCoefficientMatrix[0] = new - // Matrix(getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1,getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1); - // massTransferCoefficientMatrix[1] = new - // Matrix(getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1,getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1); - // totalMassTransferCoefficientMatrix[0] = new - // Matrix(getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1,getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1); - // totalMassTransferCoefficientMatrix[1] = new - // Matrix(getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1,getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1); - // interphaseSystem = bulkSystem.clone(); - // molFractionDifference = new - // double[2][getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1]; + return clonedSystem; + } + + /** {@inheritDoc} */ + @Override + public void setfvecMassTrans() { + double sumx = 0; + double sumy = 0; + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { + fvec.set(i, 0, Math + .log((interphaseSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient() + * interphaseSystem.getPhases()[0].getComponents()[i].getx())) + - Math.log((interphaseSystem.getPhases()[1].getComponents()[i].getFugacityCoefficient() + * interphaseSystem.getPhases()[1].getComponents()[i].getx()))); + sumx += interphaseSystem.getPhases()[0].getComponents()[i].getx(); + sumy += interphaseSystem.getPhases()[1].getComponents()[i].getx(); } - - /** {@inheritDoc} */ - @Override - public ReactiveFluidBoundary clone() { - ReactiveFluidBoundary clonedSystem = null; - - try { - clonedSystem = (ReactiveFluidBoundary) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); - } - - return clonedSystem; + fvec.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1, 0, 1 - sumx); + fvec.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), 0, 1 - sumy); + + for (int i = bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 1; i < (2 + * bulkSystem.getPhases()[0].getNumberOfMolecularComponents()); i++) { + fvec.set(i, 0, + (totalMassTransferCoefficientMatrix[1].get( + i - (bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 1), + i - (bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 1)) + * (bulkSystem.getPhases()[0].getComponents()[i + - (bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 1)].getx() + - interphaseSystem.getPhases()[0].getComponents()[i + - (bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 1)].getx()) + + (totalMassTransferCoefficientMatrix[0].get( + i - (bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 1), + i - (bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 1)) + * (bulkSystem.getPhases()[1].getComponents()[i + - (bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 1)].getx() + - interphaseSystem.getPhases()[1].getComponents()[i + - (bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 1)] + .getx())))); } - - /** {@inheritDoc} */ - @Override - public void setfvecMassTrans() { - double sumx = 0, sumy = 0; - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { - fvec.set(i, 0, Math.log( - (interphaseSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient() - * interphaseSystem.getPhases()[0].getComponents()[i].getx())) - - Math.log((interphaseSystem.getPhases()[1].getComponents()[i] - .getFugacityCoefficient() - * interphaseSystem.getPhases()[1].getComponents()[i].getx()))); - sumx += interphaseSystem.getPhases()[0].getComponents()[i].getx(); - sumy += interphaseSystem.getPhases()[1].getComponents()[i].getx(); - } - fvec.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1, 0, 1 - sumx); - fvec.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), 0, 1 - sumy); - - for (int i = bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 1; i < (2 - * bulkSystem.getPhases()[0].getNumberOfMolecularComponents()); i++) { - fvec.set(i, 0, (totalMassTransferCoefficientMatrix[1].get( - i - (bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 1), - i - (bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 1)) - * (bulkSystem.getPhases()[0].getComponents()[i - - (bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 1)] - .getx() - - interphaseSystem.getPhases()[0].getComponents()[i - - (bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - + 1)].getx()) - + (totalMassTransferCoefficientMatrix[0].get( - i - (bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 1), - i - (bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 1)) - * (bulkSystem.getPhases()[1].getComponents()[i - - (bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - + 1)].getx() - - interphaseSystem.getPhases()[1].getComponents()[i - - (bulkSystem.getPhases()[0] - .getNumberOfMolecularComponents() + 1)] - .getx())))); - } + } + + /** {@inheritDoc} */ + @Override + public void setfvecMassTrans2() { + double sumx = 0.0; + double sumy = 0.0; + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { + fvec.set(i, 0, Math + .log((interphaseSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient() + * interphaseSystem.getPhases()[0].getComponents()[i].getx())) + - Math.log((interphaseSystem.getPhases()[1].getComponents()[i].getFugacityCoefficient() + * interphaseSystem.getPhases()[1].getComponents()[i].getx()))); + sumx += interphaseSystem.getPhases()[1].getComponents()[i].getx(); + sumy += interphaseSystem.getPhases()[0].getComponents()[i].getx(); } - /** {@inheritDoc} */ - @Override - public void setfvecMassTrans2() { - double sumx = 0.0, sumy = 0.0; - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { - fvec.set(i, 0, Math.log( - (interphaseSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient() - * interphaseSystem.getPhases()[0].getComponents()[i].getx())) - - Math.log((interphaseSystem.getPhases()[1].getComponents()[i] - .getFugacityCoefficient() - * interphaseSystem.getPhases()[1].getComponents()[i].getx()))); - sumx += interphaseSystem.getPhases()[1].getComponents()[i].getx(); - sumy += interphaseSystem.getPhases()[0].getComponents()[i].getx(); - } - - fvec.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), 0, 1.0 - sumx); - fvec.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 1, 0, 1.0 - sumy); - - Matrix dx = new Matrix(1, bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1); - Matrix dy = new Matrix(1, bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1); - Matrix x = new Matrix(1, bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1); - Matrix y = new Matrix(1, bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1); - - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1; i++) { - dy.set(0, i, (bulkSystem.getPhases()[0].getComponents()[i].getx() - - interphaseSystem.getPhases()[0].getComponents()[i].getx())); - dx.set(0, i, (bulkSystem.getPhases()[1].getComponents()[i].getx() - - interphaseSystem.getPhases()[1].getComponents()[i].getx())); - y.set(0, i, (bulkSystem.getPhases()[0].getComponents()[i].getx())); - x.set(0, i, (bulkSystem.getPhases()[1].getComponents()[i].getx())); - } - - Matrix fluxX = totalMassTransferCoefficientMatrix[1].times(dx.transpose()) - .times(bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[1].getMolarMass()); - Matrix fluxY = totalMassTransferCoefficientMatrix[0].times(dy.transpose()) - .times(bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[0].getMolarMass()); - - // fluxX.print(10,10); - // fluxY.print(10,10); - // totalMassTransferCoefficientMatrix[0].print(10,10); - - // System.out.println("n flux"); - // nFlux.getMatrix(0,bulkSystem.getPhases()[1].getNumberOfMolecularComponents()-2,0,0).print(10,10); - // System.out.println("j gas flux"); - // fluxY.print(10,10); - // System.out.println("j gliq flux"); - // fluxX.print(10,10); - // System.out.println("yn gas flux"); - // y.transpose().times(totalFlux).print(10,10); - // System.out.println("xn gas flux"); - // x.transpose().times(totalFlux).print(10,10); - - Matrix errX = nFlux - .getMatrix(0, bulkSystem.getPhases()[1].getNumberOfMolecularComponents() - 2, 0, 0) - .plus(fluxX).minus(x.transpose().times(totalFlux)); - Matrix errY = nFlux - .getMatrix(0, bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 2, 0, 0) - .minus(fluxY).minus(y.transpose().times(totalFlux)); - - for (int i = bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - + 2; i < (2 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - + 1); i++) { - fvec.set(i, 0, errX.get( - (i - (bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 2)), 0)); - fvec.set((i + (bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1)), 0, - errY.get((i - (bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 2)), - 0)); - } - - /* - * System.out.println("fvec"); fvec.print(30,30); errX.print(10,10); errY.print(10,10); - */ - // fluxX.print(10,10); - // fluxY.print(10,10); - // Matrix fluxY = totalMassTransferCoefficientMatrix[1] + fvec.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), 0, 1.0 - sumx); + fvec.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 1, 0, 1.0 - sumy); + + Matrix dx = new Matrix(1, bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1); + Matrix dy = new Matrix(1, bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1); + Matrix x = new Matrix(1, bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1); + Matrix y = new Matrix(1, bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1); + + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1; i++) { + dy.set(0, i, (bulkSystem.getPhases()[0].getComponents()[i].getx() + - interphaseSystem.getPhases()[0].getComponents()[i].getx())); + dx.set(0, i, (bulkSystem.getPhases()[1].getComponents()[i].getx() + - interphaseSystem.getPhases()[1].getComponents()[i].getx())); + y.set(0, i, (bulkSystem.getPhases()[0].getComponents()[i].getx())); + x.set(0, i, (bulkSystem.getPhases()[1].getComponents()[i].getx())); } - /** {@inheritDoc} */ - @Override - public void setJacMassTrans() { - double dij = 0, tempJ = 0; - Jac.timesEquals(0.0); - - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1; i++) { - for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta - tempJ = dij * 1.0 / interphaseSystem.getPhases()[0].getComponents()[i].getx() - + interphaseSystem.getPhases()[0].getComponents()[i].getdfugdx(j); - - // tempJ= - // dij*interphaseSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient()+interphaseSystem.getPhases()[0].getComponents()[i].getx()*interphaseSystem.getPhases()[0].getComponents()[i].getdfugdx(j); - Jac.set(i, j, tempJ); - } - } - - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { - Jac.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1, i, -1.0); - Jac.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1, - bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + i, 0.0); - Jac.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), i, 0.0); - Jac.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), - bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + i, -1.0); - } - - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1; i++) { - for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta - tempJ = dij * 1.0 / interphaseSystem.getPhases()[1].getComponents()[i].getx() - + interphaseSystem.getPhases()[1].getComponents()[i].getdfugdx(j); - - // tempJ= - // dij*interphaseSystem.getPhases()[1].getComponents()[i].getFugacityCoefficient()+interphaseSystem.getPhases()[1].getComponents()[i].getx()*interphaseSystem.getPhases()[1].getComponents()[i].getdfugdx(j); - Jac.set(i, j + bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), -tempJ); - } - } - - // this must be changed..... - - for (int i = bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i < 2 - * bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1; i++) { - for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); j++) { - dij = i == (j + bulkSystem.getPhases()[0].getNumberOfMolecularComponents()) ? 1.0 - : 0.0; - tempJ = -dij * (totalMassTransferCoefficientMatrix[1].get( - i - bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), - i - bulkSystem.getPhases()[0].getNumberOfMolecularComponents())); - Jac.set(i + 1, j, tempJ); - } - } - - for (int i = bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i < 2 - * bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1; i++) { - for (int j = bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); j < 2 - * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); j++) { - dij = i == j ? 1.0 : 0.0; - tempJ = -dij * (totalMassTransferCoefficientMatrix[0].get( - i - bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), - i - bulkSystem.getPhases()[0].getNumberOfMolecularComponents())); - Jac.set(i + 1, j, tempJ); - } - } + Matrix fluxX = totalMassTransferCoefficientMatrix[1].times(dx.transpose()) + .times(bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() + / bulkSystem.getPhases()[1].getMolarMass()); + Matrix fluxY = totalMassTransferCoefficientMatrix[0].times(dy.transpose()) + .times(bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() + / bulkSystem.getPhases()[0].getMolarMass()); + + // fluxX.print(10,10); + // fluxY.print(10,10); + // totalMassTransferCoefficientMatrix[0].print(10,10); + + // System.out.println("n flux"); + // nFlux.getMatrix(0,bulkSystem.getPhases()[1].getNumberOfMolecularComponents()-2,0,0).print(10,10); + // System.out.println("j gas flux"); + // fluxY.print(10,10); + // System.out.println("j gliq flux"); + // fluxX.print(10,10); + // System.out.println("yn gas flux"); + // y.transpose().times(totalFlux).print(10,10); + // System.out.println("xn gas flux"); + // x.transpose().times(totalFlux).print(10,10); + + Matrix errX = + nFlux.getMatrix(0, bulkSystem.getPhases()[1].getNumberOfMolecularComponents() - 2, 0, 0) + .plus(fluxX).minus(x.transpose().times(totalFlux)); + Matrix errY = + nFlux.getMatrix(0, bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 2, 0, 0) + .minus(fluxY).minus(y.transpose().times(totalFlux)); + + for (int i = bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + + 2; i < (2 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 1); i++) { + fvec.set(i, 0, + errX.get((i - (bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 2)), 0)); + fvec.set((i + (bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1)), 0, + errY.get((i - (bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 2)), 0)); } - /** {@inheritDoc} */ - @Override - public void setJacMassTrans2() { - double dij = 0, tempJ = 0; - Jac.timesEquals(0.0); - - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { - for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta - tempJ = dij * 1.0 / interphaseSystem.getPhases()[0].getComponents()[i].getx() - + interphaseSystem.getPhases()[0].getComponents()[i].getdfugdx(j); - Jac.set(i, j, tempJ); - } - } - - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { - Jac.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), i, 0.0); - Jac.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), - bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + i, -1.0); - Jac.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 1, i, -1.0); - Jac.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 1, - bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + i, 0.0); - } - - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { - for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta - tempJ = dij * 1.0 / interphaseSystem.getPhases()[1].getComponents()[i].getx() - + interphaseSystem.getPhases()[1].getComponents()[i].getdfugdx(j); - Jac.set(i, j + bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), -tempJ); - } - } - - // this must be changed..... - - for (int i = bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i < 2 - * bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1; i++) { - for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); j++) { - dij = i == (j + bulkSystem.getPhases()[0].getNumberOfMolecularComponents()) ? 1.0 - : 0.0; - // tempJ = - // -dij*(totalMassTransferCoefficientMatrix[1].get(i-bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), - // i-bulkSystem.getPhases()[0].getNumberOfMolecularComponents())); - // tempJ = dij * - // totalMassTransferCoefficientMatrix[0].getRowSum(i-bulkSystem.getPhases()[0].getNumberOfMolecularComponents()); - // Jac.set(i+2,j+2*bulkSystem.getPhases()[0].getNumberOfMolecularComponents()-1, - // - - // interphaseSystem.getPhases()[0].getComponents()[i-bulkSystem.getPhases()[0].getNumberOfMolecularComponents()].getx()); - if (j != bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1) { - Jac.set(i + 2, j + bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), - -totalMassTransferCoefficientMatrix[1].get( - i - bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), - j) - * bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[1].getMolarMass());// tempJ); - } - Jac.set(i + 2, j + 2 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), - dij - bulkSystem.getPhases()[1].getComponents()[i - - bulkSystem.getPhases()[0].getNumberOfMolecularComponents()] - .getx()); - } - } + /* + * System.out.println("fvec"); fvec.print(30,30); errX.print(10,10); errY.print(10,10); + */ + // fluxX.print(10,10); + // fluxY.print(10,10); + // Matrix fluxY = totalMassTransferCoefficientMatrix[1] + } + + /** {@inheritDoc} */ + @Override + public void setJacMassTrans() { + double dij = 0; + double tempJ = 0; + Jac.timesEquals(0.0); + + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1; i++) { + for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); j++) { + dij = i == j ? 1.0 : 0.0; // Kroneckers delta + tempJ = dij * 1.0 / interphaseSystem.getPhases()[0].getComponents()[i].getx() + + interphaseSystem.getPhases()[0].getComponents()[i].getdfugdx(j); + + // tempJ= + // dij*interphaseSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient()+interphaseSystem.getPhases()[0].getComponents()[i].getx()*interphaseSystem.getPhases()[0].getComponents()[i].getdfugdx(j); + Jac.set(i, j, tempJ); + } + } - for (int i = bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i < 2 - * bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1; i++) { - for (int j = bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); j < 2 - * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); j++) { - dij = i == j ? 1.0 : 0.0; - // tempJ = - // -dij*(totalMassTransferCoefficientMatrix[1].get(i-bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), - // i-bulkSystem.getPhases()[0].getNumberOfMolecularComponents())); - // tempJ = dij * - // totalMassTransferCoefficientMatrix[1].getRowSum(i-bulkSystem.getPhases()[0].getNumberOfMolecularComponents()*1.0/bulkSystem.getPhases()[1].getMolarVolume()); - if (j != 2 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1) { - Jac.set(i + 1 + bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), - j - bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), - totalMassTransferCoefficientMatrix[0].get( - i - bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), - j - bulkSystem.getPhases()[0].getNumberOfMolecularComponents()) - * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[0].getMolarMass());// tempJ); - } - Jac.set(i + 1 + bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), - j + bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), - dij - bulkSystem.getPhases()[0].getComponents()[i - - bulkSystem.getPhases()[0].getNumberOfMolecularComponents()] - .getx()); - } - } - // System.out.println("jac"); - // Jac.print(10,10); - // totalMassTransferCoefficientMatrix[0].print(20,20); + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { + Jac.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1, i, -1.0); + Jac.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1, + bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + i, 0.0); + Jac.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), i, 0.0); + Jac.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), + bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + i, -1.0); } - /** {@inheritDoc} */ - @Override - public void setuMassTrans() { - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { - // System.out.println("i"); - uMassTrans.set(i, 0, interphaseSystem.getPhases()[0].getComponents()[i].getx()); - uMassTrans.set(i + bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), 0, - interphaseSystem.getPhases()[1].getComponents()[i].getx()); - } + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1; i++) { + for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); j++) { + dij = i == j ? 1.0 : 0.0; // Kroneckers delta + tempJ = dij * 1.0 / interphaseSystem.getPhases()[1].getComponents()[i].getx() + + interphaseSystem.getPhases()[1].getComponents()[i].getdfugdx(j); - for (int i = 2 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i < 3 - * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { - uMassTrans.set(i, 0, nFlux - .get(i - 2 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), 0)); - } + // tempJ= + // dij*interphaseSystem.getPhases()[1].getComponents()[i].getFugacityCoefficient()+interphaseSystem.getPhases()[1].getComponents()[i].getx()*interphaseSystem.getPhases()[1].getComponents()[i].getdfugdx(j); + Jac.set(i, j + bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), -tempJ); + } } - /** {@inheritDoc} */ - @Override - public void updateMassTrans() { - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { - interphaseSystem.getPhases()[0].getComponents()[i].setx(uMassTrans.get(i, 0)); - interphaseSystem.getPhases()[1].getComponents()[i].setx(uMassTrans - .get(i + bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), 0)); - } + // this must be changed..... + + for (int i = bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i < 2 + * bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1; i++) { + for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); j++) { + dij = i == (j + bulkSystem.getPhases()[0].getNumberOfMolecularComponents()) ? 1.0 : 0.0; + tempJ = -dij * (totalMassTransferCoefficientMatrix[1].get( + i - bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), + i - bulkSystem.getPhases()[0].getNumberOfMolecularComponents())); + Jac.set(i + 1, j, tempJ); + } + } - for (int i = 2 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i < 3 - * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { - nFlux.set(i - 2 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), 0, - uMassTrans.get(i, 0)); - } + for (int i = bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i < 2 + * bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1; i++) { + for (int j = bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); j < 2 + * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); j++) { + dij = i == j ? 1.0 : 0.0; + tempJ = -dij * (totalMassTransferCoefficientMatrix[0].get( + i - bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), + i - bulkSystem.getPhases()[0].getNumberOfMolecularComponents())); + Jac.set(i + 1, j, tempJ); + } + } + } + + /** {@inheritDoc} */ + @Override + public void setJacMassTrans2() { + double dij = 0; + double tempJ = 0; + Jac.timesEquals(0.0); + + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { + for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); j++) { + dij = i == j ? 1.0 : 0.0; // Kroneckers delta + tempJ = dij * 1.0 / interphaseSystem.getPhases()[0].getComponents()[i].getx() + + interphaseSystem.getPhases()[0].getComponents()[i].getdfugdx(j); + Jac.set(i, j, tempJ); + } } - /** {@inheritDoc} */ - @Override - public void calcMolFractionDifference() { - for (int i = 0; i < getBulkSystem().getPhases()[0].getNumberOfMolecularComponents() - - 1; i++) { - molFractionDifference[0][i] = bulkSystem.getPhases()[0].getComponents()[i].getx() - - interphaseSystem.getPhases()[0].getComponents()[i].getx(); - molFractionDifference[1][i] = bulkSystem.getPhases()[1].getComponents()[i].getx() - - interphaseSystem.getPhases()[1].getComponents()[i].getx(); - } + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { + Jac.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), i, 0.0); + Jac.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), + bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + i, -1.0); + Jac.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 1, i, -1.0); + Jac.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 1, + bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + i, 0.0); } - /** {@inheritDoc} */ - @Override - public void calcHeatTransferCoefficients(int phase) { - prandtlNumber[phase] = getBulkSystem().getPhases()[phase].getCp() - * getBulkSystem().getPhases()[phase].getPhysicalProperties().getViscosity() - / getBulkSystem().getPhases()[phase].getPhysicalProperties().getConductivity(); - heatTransferCoefficient[phase] = flowNode.getInterphaseTransportCoefficient() - .calcInterphaseHeatTransferCoefficient(phase, prandtlNumber[phase], flowNode); + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { + for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); j++) { + dij = i == j ? 1.0 : 0.0; // Kroneckers delta + tempJ = dij * 1.0 / interphaseSystem.getPhases()[1].getComponents()[i].getx() + + interphaseSystem.getPhases()[1].getComponents()[i].getdfugdx(j); + Jac.set(i, j + bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), -tempJ); + } } - /** {@inheritDoc} */ - @Override - public void calcHeatTransferCorrection(int phase) { - double temp = 0; - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { - temp += bulkSystem.getPhases()[0].getComponents()[i].getNumberOfMolesInPhase() - * getBulkSystem().getPhases()[phase].getCp() / heatTransferCoefficient[phase]; + // this must be changed..... + + for (int i = bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i < 2 + * bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1; i++) { + for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); j++) { + dij = i == (j + bulkSystem.getPhases()[0].getNumberOfMolecularComponents()) ? 1.0 : 0.0; + // tempJ = + // -dij*(totalMassTransferCoefficientMatrix[1].get(i-bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), + // i-bulkSystem.getPhases()[0].getNumberOfMolecularComponents())); + // tempJ = dij * + // totalMassTransferCoefficientMatrix[0].getRowSum(i-bulkSystem.getPhases()[0].getNumberOfMolecularComponents()); + // Jac.set(i+2,j+2*bulkSystem.getPhases()[0].getNumberOfMolecularComponents()-1, + // - + // interphaseSystem.getPhases()[0].getComponents()[i-bulkSystem.getPhases()[0].getNumberOfMolecularComponents()].getx()); + if (j != bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1) { + Jac.set(i + 2, j + bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), + -totalMassTransferCoefficientMatrix[1] + .get(i - bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), j) + * bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() + / bulkSystem.getPhases()[1].getMolarMass()); // tempJ); } - heatTransferCorrection[phase] = temp; + Jac.set(i + 2, j + 2 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), + dij - bulkSystem.getPhases()[1].getComponents()[i + - bulkSystem.getPhases()[0].getNumberOfMolecularComponents()].getx()); + } } - /** {@inheritDoc} */ - @Override - public void initMassTransferCalc() { - super.initMassTransferCalc(); + for (int i = bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i < 2 + * bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1; i++) { + for (int j = bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); j < 2 + * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); j++) { + dij = i == j ? 1.0 : 0.0; + // tempJ = + // -dij*(totalMassTransferCoefficientMatrix[1].get(i-bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), + // i-bulkSystem.getPhases()[0].getNumberOfMolecularComponents())); + // tempJ = dij * + // totalMassTransferCoefficientMatrix[1].getRowSum(i-bulkSystem.getPhases()[0].getNumberOfMolecularComponents()*1.0/bulkSystem.getPhases()[1].getMolarVolume()); + if (j != 2 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1) { + Jac.set(i + 1 + bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), + j - bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), + totalMassTransferCoefficientMatrix[0].get( + i - bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), + j - bulkSystem.getPhases()[0].getNumberOfMolecularComponents()) + * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() + / bulkSystem.getPhases()[0].getMolarMass()); // tempJ); + } + Jac.set(i + 1 + bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), + j + bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), + dij - bulkSystem.getPhases()[0].getComponents()[i + - bulkSystem.getPhases()[0].getNumberOfMolecularComponents()].getx()); + } } - - /** {@inheritDoc} */ - @Override - public void initHeatTransferCalc() { - super.initHeatTransferCalc(); + // System.out.println("jac"); + // Jac.print(10,10); + // totalMassTransferCoefficientMatrix[0].print(20,20); + } + + /** {@inheritDoc} */ + @Override + public void setuMassTrans() { + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { + // System.out.println("i"); + uMassTrans.set(i, 0, interphaseSystem.getPhases()[0].getComponents()[i].getx()); + uMassTrans.set(i + bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), 0, + interphaseSystem.getPhases()[1].getComponents()[i].getx()); } - /** {@inheritDoc} */ - @Override - public void init() { - calcMolFractionDifference(); - super.init(); + for (int i = 2 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i < 3 + * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { + uMassTrans.set(i, 0, + nFlux.get(i - 2 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), 0)); } - - /** {@inheritDoc} */ - @Override - public void heatTransSolve() { - double f = 0; - double df = 0; - double dhtot = 0.0; - do { - dhtot = 0.0; - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { - dhtot += nFlux.get(i, 0) * (bulkSystem.getPhases()[0].getComponents()[i] - .getEnthalpy(bulkSystem.getPhases()[0].getTemperature()) - - bulkSystem.getPhases()[1].getComponents()[i] - .getEnthalpy(bulkSystem.getPhases()[1].getTemperature())); - } - - f = heatTransferCoefficient[0] * heatTransferCorrection[0] - * (bulkSystem.getPhases()[0].getTemperature() - - interphaseSystem.getTemperature()) - + heatTransferCoefficient[1] * heatTransferCorrection[1] - * (bulkSystem.getPhases()[1].getTemperature() - - interphaseSystem.getTemperature()) - + dhtot; - - df = -heatTransferCoefficient[0] * heatTransferCorrection[0] - - heatTransferCoefficient[1] * heatTransferCorrection[1]; - interphaseSystem.setTemperature(interphaseSystem.getTemperature() - f / df); - - // System.out.println("f " + f); - // System.out.println("int temp " + interphaseSystem.getTemperature()); - // System.out.println("gas temp " + bulkSystem.getPhases()[0].getTemperature()); - // System.out.println("liq temp " + bulkSystem.getPhases()[1].getTemperature()); - } while (Math.abs(f) > 1e-10); + } + + /** {@inheritDoc} */ + @Override + public void updateMassTrans() { + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { + interphaseSystem.getPhases()[0].getComponents()[i].setx(uMassTrans.get(i, 0)); + interphaseSystem.getPhases()[1].getComponents()[i] + .setx(uMassTrans.get(i + bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), 0)); } - /** {@inheritDoc} */ - @Override - public void massTransSolve() { - int iter = 0; - setuMassTrans(); - - do { - iter++; - init(); - setfvecMassTrans2(); - setJacMassTrans2(); - dx = Jac.solve(fvec); - uMassTrans.minusEquals(dx.times(0.1)); - updateMassTrans(); - calcFluxes(); - // uMassTrans.print(30,30); - dx.print(30, 30); - // System.out.println("err " + Math.abs(dx.norm2()/uMassTrans.norm2())); - } while (Math.abs(dx.norm2() / uMassTrans.norm2()) > 1.e-10 && iter < 50); - // System.out.println("iter " + iter); - - calcFluxes2(); - - // uMassTrans.print(30,30); + for (int i = 2 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i < 3 + * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { + nFlux.set(i - 2 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), 0, + uMassTrans.get(i, 0)); } - - /** {@inheritDoc} */ - @Override - public double[] calcFluxes() { - double sum = 0.0; - // System.out.println("starter..."); - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { - sum += nFlux.get(i, 0); - } - - totalFlux = sum;// tot.get(0,0); - return nFlux.transpose().getArray()[0]; + } + + /** {@inheritDoc} */ + @Override + public void calcMolFractionDifference() { + for (int i = 0; i < getBulkSystem().getPhases()[0].getNumberOfMolecularComponents() - 1; i++) { + molFractionDifference[0][i] = bulkSystem.getPhases()[0].getComponents()[i].getx() + - interphaseSystem.getPhases()[0].getComponents()[i].getx(); + molFractionDifference[1][i] = bulkSystem.getPhases()[1].getComponents()[i].getx() + - interphaseSystem.getPhases()[1].getComponents()[i].getx(); } - - /** - *

- * calcFluxes2. - *

- * - * @return an array of {@link double} objects - */ - public double[] calcFluxes2() { - double sum = 0.0; - // System.out.println("starter..."); - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { - sum += nFlux.get(i, 0); - // System.out.println("n " + nFlux.get(i,0) ); - } - - totalFlux = sum;// tot.get(0,0); - return nFlux.transpose().getArray()[0]; + } + + /** {@inheritDoc} */ + @Override + public void calcHeatTransferCoefficients(int phase) { + prandtlNumber[phase] = getBulkSystem().getPhases()[phase].getCp() + * getBulkSystem().getPhases()[phase].getPhysicalProperties().getViscosity() + / getBulkSystem().getPhases()[phase].getPhysicalProperties().getConductivity(); + heatTransferCoefficient[phase] = flowNode.getInterphaseTransportCoefficient() + .calcInterphaseHeatTransferCoefficient(phase, prandtlNumber[phase], flowNode); + } + + /** {@inheritDoc} */ + @Override + public void calcHeatTransferCorrection(int phase) { + double temp = 0; + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { + temp += bulkSystem.getPhases()[0].getComponents()[i].getNumberOfMolesInPhase() + * getBulkSystem().getPhases()[phase].getCp() / heatTransferCoefficient[phase]; + } + heatTransferCorrection[phase] = temp; + } + + /** {@inheritDoc} */ + @Override + public void initMassTransferCalc() { + super.initMassTransferCalc(); + } + + /** {@inheritDoc} */ + @Override + public void initHeatTransferCalc() { + super.initHeatTransferCalc(); + } + + /** {@inheritDoc} */ + @Override + public void init() { + calcMolFractionDifference(); + super.init(); + } + + /** {@inheritDoc} */ + @Override + public void heatTransSolve() { + double f = 0; + double df = 0; + double dhtot = 0.0; + do { + dhtot = 0.0; + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { + dhtot += nFlux.get(i, 0) * (bulkSystem.getPhases()[0].getComponents()[i] + .getEnthalpy(bulkSystem.getPhases()[0].getTemperature()) + - bulkSystem.getPhases()[1].getComponents()[i] + .getEnthalpy(bulkSystem.getPhases()[1].getTemperature())); + } + + f = heatTransferCoefficient[0] * heatTransferCorrection[0] + * (bulkSystem.getPhases()[0].getTemperature() - interphaseSystem.getTemperature()) + + heatTransferCoefficient[1] * heatTransferCorrection[1] + * (bulkSystem.getPhases()[1].getTemperature() - interphaseSystem.getTemperature()) + + dhtot; + + df = -heatTransferCoefficient[0] * heatTransferCorrection[0] + - heatTransferCoefficient[1] * heatTransferCorrection[1]; + interphaseSystem.setTemperature(interphaseSystem.getTemperature() - f / df); + + // System.out.println("f " + f); + // System.out.println("int temp " + interphaseSystem.getTemperature()); + // System.out.println("gas temp " + bulkSystem.getPhases()[0].getTemperature()); + // System.out.println("liq temp " + bulkSystem.getPhases()[1].getTemperature()); + } while (Math.abs(f) > 1e-10); + } + + /** {@inheritDoc} */ + @Override + public void massTransSolve() { + int iter = 0; + setuMassTrans(); + + do { + iter++; + init(); + setfvecMassTrans2(); + setJacMassTrans2(); + dx = Jac.solve(fvec); + uMassTrans.minusEquals(dx.times(0.1)); + updateMassTrans(); + calcFluxes(); + // uMassTrans.print(30,30); + dx.print(30, 30); + // System.out.println("err " + Math.abs(dx.norm2()/uMassTrans.norm2())); + } while (Math.abs(dx.norm2() / uMassTrans.norm2()) > 1.e-10 && iter < 50); + // System.out.println("iter " + iter); + + calcFluxes2(); + + // uMassTrans.print(30,30); + } + + /** {@inheritDoc} */ + @Override + public double[] calcFluxes() { + double sum = 0.0; + // System.out.println("starter..."); + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { + sum += nFlux.get(i, 0); } - /** {@inheritDoc} */ - @Override - public void solve() { - int iterOuter = 0; - double totalFluxOld = totalFlux; - do { - iterOuter++; - totalFluxOld = totalFlux; - if (massTransferCalc) { - massTransSolve(); - } - - if (heatTransferCalc) { - // System.out.println("heat "); - this.heatTransSolve(); - } - // System.out.println("flux err: " + Math.abs(totalFluxOld-totalFlux)); - } while (Math.abs((totalFluxOld - totalFlux) / totalFlux) > 1e-10 && iterOuter < 55); - - // System.out.println("iterOuter " +iterOuter); - init(); + totalFlux = sum; // tot.get(0,0); + return nFlux.transpose().getArray()[0]; + } + + /** + *

+ * calcFluxes2. + *

+ * + * @return an array of {@link double} objects + */ + public double[] calcFluxes2() { + double sum = 0.0; + // System.out.println("starter..."); + for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { + sum += nFlux.get(i, 0); + // System.out.println("n " + nFlux.get(i,0) ); } + + totalFlux = sum; // tot.get(0,0); + return nFlux.transpose().getArray()[0]; + } + + /** {@inheritDoc} */ + @Override + public void solve() { + int iterOuter = 0; + double totalFluxOld = totalFlux; + do { + iterOuter++; + totalFluxOld = totalFlux; + if (massTransferCalc) { + massTransSolve(); + } + + if (heatTransferCalc) { + // System.out.println("heat "); + this.heatTransSolve(); + } + // System.out.println("flux err: " + Math.abs(totalFluxOld-totalFlux)); + } while (Math.abs((totalFluxOld - totalFlux) / totalFlux) > 1e-10 && iterOuter < 55); + + // System.out.println("iterOuter " +iterOuter); + init(); + } } diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/multiPhaseNode/MultiPhaseFlowNode.java b/src/main/java/neqsim/fluidMechanics/flowNode/multiPhaseNode/MultiPhaseFlowNode.java index 99b4c297b0..5be31a7611 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/multiPhaseNode/MultiPhaseFlowNode.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/multiPhaseNode/MultiPhaseFlowNode.java @@ -14,345 +14,341 @@ * @version $Id: $Id */ public abstract class MultiPhaseFlowNode extends FlowNode { - private static final long serialVersionUID = 1000; - - /** - *

- * Constructor for MultiPhaseFlowNode. - *

- */ - public MultiPhaseFlowNode() {} - - /** - *

- * Constructor for MultiPhaseFlowNode. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param pipe a {@link neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface} - * object - */ - public MultiPhaseFlowNode(SystemInterface system, GeometryDefinitionInterface pipe) { - super(system, pipe); - - getBulkSystem().initBeta(); - getBulkSystem().init_x_y(); + private static final long serialVersionUID = 1000; + + /** + *

+ * Constructor for MultiPhaseFlowNode. + *

+ */ + public MultiPhaseFlowNode() {} + + /** + *

+ * Constructor for MultiPhaseFlowNode. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param pipe a {@link neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface} + * object + */ + public MultiPhaseFlowNode(SystemInterface system, GeometryDefinitionInterface pipe) { + super(system, pipe); + + getBulkSystem().initBeta(); + getBulkSystem().init_x_y(); + } + + /** {@inheritDoc} */ + @Override + public TwoPhaseFlowNode clone() { + TwoPhaseFlowNode clonedSystem = null; + try { + clonedSystem = (TwoPhaseFlowNode) super.clone(); + } catch (Exception e) { + e.printStackTrace(System.err); } - /** {@inheritDoc} */ - @Override - public TwoPhaseFlowNode clone() { - TwoPhaseFlowNode clonedSystem = null; - try { - clonedSystem = (TwoPhaseFlowNode) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); + return clonedSystem; + } + + /** + *

+ * initVelocity. + *

+ * + * @return a double + */ + public double initVelocity() { + getBulkSystem().init(1); + getBulkSystem().initPhysicalProperties(); + molarFlowRate[1] = getBulkSystem().getPhases()[1].getNumberOfMolesInPhase(); + molarFlowRate[0] = getBulkSystem().getPhases()[0].getNumberOfMolesInPhase(); + massFlowRate[1] = molarFlowRate[1] * getBulkSystem().getPhases()[1].getMolarMass(); + massFlowRate[0] = molarFlowRate[0] * getBulkSystem().getPhases()[0].getMolarMass(); + volumetricFlowRate[0] = + massFlowRate[0] / getBulkSystem().getPhases()[0].getPhysicalProperties().getDensity(); + volumetricFlowRate[1] = + massFlowRate[1] / getBulkSystem().getPhases()[1].getPhysicalProperties().getDensity(); + velocity[0] = volumetricFlowRate[0] / (phaseFraction[0] * pipe.getArea()); + velocity[1] = volumetricFlowRate[1] / (phaseFraction[1] * pipe.getArea()); + return velocity[1]; + } + + /** {@inheritDoc} */ + @Override + public void initFlowCalc() { + this.init(); + initVelocity(); + + phaseFraction[0] = 1.0 - 1.0e-10; + phaseFraction[1] = 1.0 - phaseFraction[0]; + double f = 0; + double fOld = 0; + double betaOld = 0; + int iterations = 0; + double step = 100.0; + + // double df + + do { + iterations++; + fOld = f; + + initVelocity(); + init(); + + double Fg = 0.5 * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() + * wallFrictionFactor[0] * Math.pow(velocity[0], 2.0) * wallContactLength[0] + / (pipe.getArea() * 4.0); + double Fl = 0.5 * bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() + * wallFrictionFactor[1] * Math.pow(velocity[1], 2.0) * wallContactLength[1] + / (pipe.getArea() * 4.0); + double Fi = 0.5 * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() + * interphaseFrictionFactor[0] * Math.pow(velocity[0] - velocity[1], 2.0) + * interphaseContactLength[0] / (pipe.getArea() * 4.0); + + f = -phaseFraction[0] * Fl + (1 - phaseFraction[0]) * Fg + Fi + + (1.0 - phaseFraction[0]) * phaseFraction[0] + * (bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() + - bulkSystem.getPhases()[0].getPhysicalProperties().getDensity()) + * gravity * inclination; + /* + * df = -Fl - Fg + (bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - + * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity()) gravity * inclination - + * Math.pow(phaseFraction[0], 2.0) * (bulkSystem.getPhases()[1] + * .getPhysicalProperties().getDensity() - + * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity()) gravity * inclination; + */ + + if (f > 0) { + phaseFraction[0] += (betaOld - phaseFraction[0]); + if (fOld < 0) { + step *= 5.0; } - - return clonedSystem; + } else { + betaOld = phaseFraction[0]; + phaseFraction[0] -= phaseFraction[0] / step; + } + phaseFraction[1] = 1.0 - phaseFraction[0]; + } while (Math.abs(f) > 1e-2 && iterations < 100); + // while(Math.abs((f-fOld)/f)>1e-8 && iterations<10000); + + if (iterations == 100) { + System.out.println("error in void init calc"); } - - /** - *

- * initVelocity. - *

- * - * @return a double - */ - public double initVelocity() { - getBulkSystem().init(1); - getBulkSystem().initPhysicalProperties(); - molarFlowRate[1] = getBulkSystem().getPhases()[1].getNumberOfMolesInPhase(); - molarFlowRate[0] = getBulkSystem().getPhases()[0].getNumberOfMolesInPhase(); - massFlowRate[1] = molarFlowRate[1] * getBulkSystem().getPhases()[1].getMolarMass(); - massFlowRate[0] = molarFlowRate[0] * getBulkSystem().getPhases()[0].getMolarMass(); - volumetricFlowRate[0] = massFlowRate[0] - / getBulkSystem().getPhases()[0].getPhysicalProperties().getDensity(); - volumetricFlowRate[1] = massFlowRate[1] - / getBulkSystem().getPhases()[1].getPhysicalProperties().getDensity(); - velocity[0] = volumetricFlowRate[0] / (phaseFraction[0] * pipe.getArea()); - velocity[1] = volumetricFlowRate[1] / (phaseFraction[1] * pipe.getArea()); - return velocity[1]; + this.init(); + } + + /** + *

+ * calcHydraulicDiameter. + *

+ * + * @return a double + */ + public double calcHydraulicDiameter() { + hydraulicDiameter[0] = 4.0 * phaseFraction[0] * pipe.getArea() + / (wallContactLength[0] + interphaseContactLength[0]); + hydraulicDiameter[1] = 4.0 * phaseFraction[1] * pipe.getArea() / wallContactLength[1]; + return hydraulicDiameter[0]; + } + + /** + *

+ * calcReynoldNumber. + *

+ * + * @return a double + */ + public double calcReynoldNumber() { + reynoldsNumber[1] = velocity[1] * hydraulicDiameter[1] + * bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() + / bulkSystem.getPhases()[1].getPhysicalProperties().getViscosity(); + reynoldsNumber[0] = velocity[0] * hydraulicDiameter[0] + * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() + / bulkSystem.getPhases()[0].getPhysicalProperties().getViscosity(); + return reynoldsNumber[1]; + } + + /** + *

+ * calcWallFrictionFactor. + *

+ * + * @return a double + */ + public double calcWallFrictionFactor() { + for (int i = 0; i < 2; i++) { + wallFrictionFactor[i] = Math.pow( + (1.0 / (-1.8 * Math.log10(6.9 / getReynoldsNumber(i) + * Math.pow(pipe.getRelativeRoughnes(this.getHydraulicDiameter(i)) / 3.7, 1.11)))), + 2.0); } - - /** {@inheritDoc} */ - @Override - public void initFlowCalc() { - this.init(); - initVelocity(); - - phaseFraction[0] = 1.0 - 1.0e-10; - phaseFraction[1] = 1.0 - phaseFraction[0]; - double f = 0, fOld = 0, betaOld = 0; - int iterations = 0; - double step = 100.0; - - // double df - - do { - iterations++; - fOld = f; - - initVelocity(); - init(); - - double Fg = 0.5 * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() - * wallFrictionFactor[0] * Math.pow(velocity[0], 2.0) * wallContactLength[0] - / (pipe.getArea() * 4.0); - double Fl = 0.5 * bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - * wallFrictionFactor[1] * Math.pow(velocity[1], 2.0) * wallContactLength[1] - / (pipe.getArea() * 4.0); - double Fi = 0.5 * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() - * interphaseFrictionFactor[0] * Math.pow(velocity[0] - velocity[1], 2.0) - * interphaseContactLength[0] / (pipe.getArea() * 4.0); - - f = -phaseFraction[0] * Fl + (1 - phaseFraction[0]) * Fg + Fi + (1.0 - phaseFraction[0]) - * phaseFraction[0] - * (bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - - bulkSystem.getPhases()[0].getPhysicalProperties().getDensity()) - * gravity * inclination; - /* - * df = -Fl - Fg + (bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - - * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity()) gravity * inclination - * - Math.pow(phaseFraction[0], 2.0) * (bulkSystem.getPhases()[1] - * .getPhysicalProperties().getDensity() - - * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity()) gravity * - * inclination; - */ - - if (f > 0) { - phaseFraction[0] += (betaOld - phaseFraction[0]); - if (fOld < 0) { - step *= 5.0; - } - } else { - betaOld = phaseFraction[0]; - phaseFraction[0] -= phaseFraction[0] / step; - } - phaseFraction[1] = 1.0 - phaseFraction[0]; - } while (Math.abs(f) > 1e-2 && iterations < 100); - // while(Math.abs((f-fOld)/f)>1e-8 && iterations<10000); - - if (iterations == 100) { - System.out.println("error in void init calc"); - } - this.init(); + return wallFrictionFactor[0]; + } + + /** {@inheritDoc} */ + @Override + public void setFluxes(double[] dn) { + for (int i = 0; i < getBulkSystem().getPhases()[0].getNumberOfComponents(); i++) { + getBulkSystem().getPhases()[0].addMoles(i, -dn[i]); + getBulkSystem().getPhases()[1].addMoles(i, +dn[i]); + + getInterphaseSystem().getPhases()[0].addMoles(i, -dn[i]); + getInterphaseSystem().getPhases()[1].addMoles(i, +dn[i]); } - - /** - *

- * calcHydraulicDiameter. - *

- * - * @return a double - */ - public double calcHydraulicDiameter() { - hydraulicDiameter[0] = 4.0 * phaseFraction[0] * pipe.getArea() - / (wallContactLength[0] + interphaseContactLength[0]); - hydraulicDiameter[1] = 4.0 * phaseFraction[1] * pipe.getArea() / wallContactLength[1]; - return hydraulicDiameter[0]; + } + + /** {@inheritDoc} */ + @Override + public void updateMolarFlow() { + for (int phase = 0; phase < 2; phase++) { + for (int i = 0; i < getBulkSystem().getPhases()[0].getNumberOfComponents(); i++) { + getBulkSystem().getPhases()[phase].addMoles(i, + (getBulkSystem().getPhases()[phase].getComponents()[i].getx() * (molarFlowRate[phase] + - getBulkSystem().getPhases()[phase].getNumberOfMolesInPhase()))); + } } - - /** - *

- * calcReynoldNumber. - *

- * - * @return a double - */ - public double calcReynoldNumber() { - reynoldsNumber[1] = velocity[1] * hydraulicDiameter[1] - * bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[1].getPhysicalProperties().getViscosity(); - reynoldsNumber[0] = velocity[0] * hydraulicDiameter[0] - * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[0].getPhysicalProperties().getViscosity(); - return reynoldsNumber[1]; + getBulkSystem().init(1); + } + + /** + *

+ * calcContactLength. + *

+ * + * @return a double + */ + public double calcContactLength() { + return 0; + } + + /** {@inheritDoc} */ + @Override + public void init() { + super.init(); + massFlowRate[0] = + velocity[0] * getBulkSystem().getPhases()[0].getPhysicalProperties().getDensity() + * pipe.getArea() * phaseFraction[0]; + massFlowRate[1] = + velocity[1] * getBulkSystem().getPhases()[1].getPhysicalProperties().getDensity() + * pipe.getArea() * phaseFraction[1]; + molarFlowRate[0] = massFlowRate[0] / getBulkSystem().getPhases()[0].getMolarMass(); + molarFlowRate[1] = massFlowRate[1] / getBulkSystem().getPhases()[1].getMolarMass(); + superficialVelocity[0] = velocity[0] * phaseFraction[0]; + superficialVelocity[1] = velocity[1] * phaseFraction[1]; + volumetricFlowRate[0] = superficialVelocity[0] * pipe.getArea(); + volumetricFlowRate[1] = superficialVelocity[1] * pipe.getArea(); + this.updateMolarFlow(); + + this.calcHydraulicDiameter(); + this.calcReynoldNumber(); + interphaseContactArea = this.calcGasLiquidContactArea(); + + wallFrictionFactor[0] = interphaseTransportCoefficient.calcWallFrictionFactor(0, this); + wallFrictionFactor[1] = interphaseTransportCoefficient.calcWallFrictionFactor(1, this); + + interphaseFrictionFactor[0] = + interphaseTransportCoefficient.calcInterPhaseFrictionFactor(0, this); + interphaseFrictionFactor[1] = + interphaseTransportCoefficient.calcInterPhaseFrictionFactor(0, this); + } + + /** + *

+ * calcGasLiquidContactArea. + *

+ * + * @return a double + */ + public double calcGasLiquidContactArea() { + interphaseContactArea = pipe.getNodeLength() * interphaseContactLength[0]; + return interphaseContactArea; + } + + /** {@inheritDoc} */ + @Override + public void calcFluxes() { + if (bulkSystem.isChemicalSystem()) { + // getBulkSystem().getChemicalReactionOperations().setSystem(getBulkSystem()); + // getOperations().chemicalEquilibrium(); } - - /** - *

- * calcWallFrictionFactor. - *

- * - * @return a double - */ - public double calcWallFrictionFactor() { - for (int i = 0; i < 2; i++) { - wallFrictionFactor[i] = Math.pow( - (1.0 / (-1.8 * Math.log10(6.9 / getReynoldsNumber(i) * Math.pow( - pipe.getRelativeRoughnes(this.getHydraulicDiameter(i)) / 3.7, 1.11)))), - 2.0); - } - return wallFrictionFactor[0]; - } - - /** {@inheritDoc} */ - @Override - public void setFluxes(double dn[]) { - for (int i = 0; i < getBulkSystem().getPhases()[0].getNumberOfComponents(); i++) { - getBulkSystem().getPhases()[0].addMoles(i, -dn[i]); - getBulkSystem().getPhases()[1].addMoles(i, +dn[i]); - - getInterphaseSystem().getPhases()[0].addMoles(i, -dn[i]); - getInterphaseSystem().getPhases()[1].addMoles(i, +dn[i]); - } - } - - /** {@inheritDoc} */ - @Override - public void updateMolarFlow() { - for (int phase = 0; phase < 2; phase++) { - for (int i = 0; i < getBulkSystem().getPhases()[0].getNumberOfComponents(); i++) { - getBulkSystem().getPhases()[phase].addMoles(i, - (getBulkSystem().getPhases()[phase].getComponents()[i].getx() - * (molarFlowRate[phase] - getBulkSystem().getPhases()[phase] - .getNumberOfMolesInPhase()))); - } - } - getBulkSystem().init(1); - } - - /** - *

- * calcContactLength. - *

- * - * @return a double - */ - public double calcContactLength() { - return 0; - } - - /** {@inheritDoc} */ - @Override - public void init() { - super.init(); - massFlowRate[0] = - velocity[0] * getBulkSystem().getPhases()[0].getPhysicalProperties().getDensity() - * pipe.getArea() * phaseFraction[0]; - massFlowRate[1] = - velocity[1] * getBulkSystem().getPhases()[1].getPhysicalProperties().getDensity() - * pipe.getArea() * phaseFraction[1]; - molarFlowRate[0] = massFlowRate[0] / getBulkSystem().getPhases()[0].getMolarMass(); - molarFlowRate[1] = massFlowRate[1] / getBulkSystem().getPhases()[1].getMolarMass(); - superficialVelocity[0] = velocity[0] * phaseFraction[0]; - superficialVelocity[1] = velocity[1] * phaseFraction[1]; - volumetricFlowRate[0] = superficialVelocity[0] * pipe.getArea(); - volumetricFlowRate[1] = superficialVelocity[1] * pipe.getArea(); - this.updateMolarFlow(); - - this.calcHydraulicDiameter(); - this.calcReynoldNumber(); - interphaseContactArea = this.calcGasLiquidContactArea(); - - wallFrictionFactor[0] = interphaseTransportCoefficient.calcWallFrictionFactor(0, this); - wallFrictionFactor[1] = interphaseTransportCoefficient.calcWallFrictionFactor(1, this); - - interphaseFrictionFactor[0] = - interphaseTransportCoefficient.calcInterPhaseFrictionFactor(0, this); - interphaseFrictionFactor[1] = - interphaseTransportCoefficient.calcInterPhaseFrictionFactor(0, this); - } - - /** - *

- * calcGasLiquidContactArea. - *

- * - * @return a double - */ - public double calcGasLiquidContactArea() { - interphaseContactArea = pipe.getNodeLength() * interphaseContactLength[0]; - return interphaseContactArea; - } - - /** {@inheritDoc} */ - @Override - public void calcFluxes() { - if (bulkSystem.isChemicalSystem()) { - // getBulkSystem().getChemicalReactionOperations().setSystem(getBulkSystem()); - // getOperations().chemicalEquilibrium(); - } - fluidBoundary.solve(); - fluidBoundary.calcFluxes(); - } - - /** {@inheritDoc} */ - @Override - public void update() { - double heatFluxGas = getFluidBoundary().getInterphaseHeatFlux(0);// getInterphaseTransportCoefficient().calcInterphaseHeatTransferCoefficient(0, - // getPrandtlNumber(0), + fluidBoundary.solve(); + fluidBoundary.calcFluxes(); + } + + /** {@inheritDoc} */ + @Override + public void update() { + double heatFluxGas = getFluidBoundary().getInterphaseHeatFlux(0); // getInterphaseTransportCoefficient().calcInterphaseHeatTransferCoefficient(0, + // getPrandtlNumber(0), + // this) * + // (getInterphaseSystem().getPhase(0).getTemperature() + // - + // getBulkSystem().getPhase(0).getTemperature()) + // * + // getInterphaseContactArea(); + + double heatFluxLiquid = getFluidBoundary().getInterphaseHeatFlux(1); // getInterphaseTransportCoefficient().calcInterphaseHeatTransferCoefficient(1, + // getPrandtlNumber(1), // this) * - // (getInterphaseSystem().getPhase(0).getTemperature() + // (getInterphaseSystem().getPhase(1).getTemperature() // - - // getBulkSystem().getPhase(0).getTemperature()) + // getBulkSystem().getPhase(1).getTemperature()) // * // getInterphaseContactArea(); - double heatFluxLiquid = getFluidBoundary().getInterphaseHeatFlux(1);// getInterphaseTransportCoefficient().calcInterphaseHeatTransferCoefficient(1, - // getPrandtlNumber(1), - // this) * - // (getInterphaseSystem().getPhase(1).getTemperature() - // - - // getBulkSystem().getPhase(1).getTemperature()) - // * - // getInterphaseContactArea(); - - double liquid_dT = this.flowDirection[1] * heatFluxLiquid * getGeometry().getNodeLength() - / getVelocity(1) / getBulkSystem().getPhase(1).getCp(); - double gas_dT = this.flowDirection[0] * heatFluxGas * getGeometry().getNodeLength() - / getVelocity(0) / getBulkSystem().getPhase(0).getCp(); - liquid_dT -= getInterphaseTransportCoefficient().calcWallHeatTransferCoefficient(1, this) - * (getBulkSystem().getPhase(1).getTemperature() - pipe.getInnerWallTemperature()) - * getWallContactLength(1) * getGeometry().getNodeLength() - / getBulkSystem().getPhase(1).getCp(); - gas_dT -= getInterphaseTransportCoefficient().calcWallHeatTransferCoefficient(0, this) - * (getBulkSystem().getPhase(0).getTemperature() - pipe.getInnerWallTemperature()) - * getWallContactLength(0) * getGeometry().getNodeLength() - / getBulkSystem().getPhase(0).getCp(); - double fluxwallinternal = getInterphaseTransportCoefficient() - .calcWallHeatTransferCoefficient(1, this) - * (getBulkSystem().getPhase(1).getTemperature() - pipe.getInnerWallTemperature()) - * getWallContactLength(1) * getGeometry().getNodeLength() - + getInterphaseTransportCoefficient().calcWallHeatTransferCoefficient(0, this) - * (getBulkSystem().getPhase(0).getTemperature() - - pipe.getInnerWallTemperature()) - * getWallContactLength(0) * getGeometry().getNodeLength(); - - double JolprK = 3.14 * 0.2032 * 0.0094 * getGeometry().getNodeLength() * 7500 * 500; - double fluxOut = -50.0 * 3.14 * (0.2032 + 0.01) * getGeometry().getNodeLength() - * (pipe.getInnerWallTemperature() - - pipe.getSurroundingEnvironment().getTemperature()); - double dTwall = (fluxOut + fluxwallinternal) / JolprK; - pipe.setInnerWallTemperature(pipe.getInnerWallTemperature() + dTwall); - - getBulkSystem().getPhase(1) - .setTemperature(getBulkSystem().getPhase(1).getTemperature() + liquid_dT); - getBulkSystem().getPhase(0) - .setTemperature(getBulkSystem().getPhase(0).getTemperature() + gas_dT); - - for (int componentNumber = 0; componentNumber < getBulkSystem().getPhases()[0] - .getNumberOfComponents(); componentNumber++) { - double liquidMolarRate = getFluidBoundary().getInterphaseMolarFlux(componentNumber) - * getInterphaseContactArea();// getInterphaseContactLength(0)*getGeometry().getNodeLength(); - - double gasMolarRate = -getFluidBoundary().getInterphaseMolarFlux(componentNumber) - * getInterphaseContactArea();// getInterphaseContactLength(0)*getGeometry().getNodeLength(); - - getBulkSystem().getPhase(0).addMoles(componentNumber, - this.flowDirection[0] * gasMolarRate); - getBulkSystem().getPhase(1).addMoles(componentNumber, - this.flowDirection[1] * liquidMolarRate); - } + double liquid_dT = this.flowDirection[1] * heatFluxLiquid * getGeometry().getNodeLength() + / getVelocity(1) / getBulkSystem().getPhase(1).getCp(); + double gas_dT = this.flowDirection[0] * heatFluxGas * getGeometry().getNodeLength() + / getVelocity(0) / getBulkSystem().getPhase(0).getCp(); + liquid_dT -= getInterphaseTransportCoefficient().calcWallHeatTransferCoefficient(1, this) + * (getBulkSystem().getPhase(1).getTemperature() - pipe.getInnerWallTemperature()) + * getWallContactLength(1) * getGeometry().getNodeLength() + / getBulkSystem().getPhase(1).getCp(); + gas_dT -= getInterphaseTransportCoefficient().calcWallHeatTransferCoefficient(0, this) + * (getBulkSystem().getPhase(0).getTemperature() - pipe.getInnerWallTemperature()) + * getWallContactLength(0) * getGeometry().getNodeLength() + / getBulkSystem().getPhase(0).getCp(); + double fluxwallinternal = getInterphaseTransportCoefficient().calcWallHeatTransferCoefficient(1, + this) * (getBulkSystem().getPhase(1).getTemperature() - pipe.getInnerWallTemperature()) + * getWallContactLength(1) * getGeometry().getNodeLength() + + getInterphaseTransportCoefficient().calcWallHeatTransferCoefficient(0, this) + * (getBulkSystem().getPhase(0).getTemperature() - pipe.getInnerWallTemperature()) + * getWallContactLength(0) * getGeometry().getNodeLength(); + + double JolprK = 3.14 * 0.2032 * 0.0094 * getGeometry().getNodeLength() * 7500 * 500; + double fluxOut = -50.0 * 3.14 * (0.2032 + 0.01) * getGeometry().getNodeLength() + * (pipe.getInnerWallTemperature() - pipe.getSurroundingEnvironment().getTemperature()); + double dTwall = (fluxOut + fluxwallinternal) / JolprK; + pipe.setInnerWallTemperature(pipe.getInnerWallTemperature() + dTwall); + + getBulkSystem().getPhase(1) + .setTemperature(getBulkSystem().getPhase(1).getTemperature() + liquid_dT); + getBulkSystem().getPhase(0) + .setTemperature(getBulkSystem().getPhase(0).getTemperature() + gas_dT); + + for (int componentNumber = 0; componentNumber < getBulkSystem().getPhases()[0] + .getNumberOfComponents(); componentNumber++) { + double liquidMolarRate = + getFluidBoundary().getInterphaseMolarFlux(componentNumber) * getInterphaseContactArea(); // getInterphaseContactLength(0)*getGeometry().getNodeLength(); + + double gasMolarRate = + -getFluidBoundary().getInterphaseMolarFlux(componentNumber) * getInterphaseContactArea(); // getInterphaseContactLength(0)*getGeometry().getNodeLength(); + + getBulkSystem().getPhase(0).addMoles(componentNumber, this.flowDirection[0] * gasMolarRate); + getBulkSystem().getPhase(1).addMoles(componentNumber, + this.flowDirection[1] * liquidMolarRate); + } - getBulkSystem().initBeta(); - getBulkSystem().init_x_y(); - getBulkSystem().init(3); + getBulkSystem().initBeta(); + getBulkSystem().init_x_y(); + getBulkSystem().init(3); - if (bulkSystem.isChemicalSystem()) { - getBulkSystem().getChemicalReactionOperations().setSystem(getBulkSystem()); - getOperations().chemicalEquilibrium(); - } + if (bulkSystem.isChemicalSystem()) { + getBulkSystem().getChemicalReactionOperations().setSystem(getBulkSystem()); + getOperations().chemicalEquilibrium(); } + } } diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/TwoPhaseFlowNode.java b/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/TwoPhaseFlowNode.java index 624bb8e81e..5f76816a84 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/TwoPhaseFlowNode.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/TwoPhaseFlowNode.java @@ -13,388 +13,383 @@ * @version $Id: $Id */ public abstract class TwoPhaseFlowNode extends FlowNode { - private static final long serialVersionUID = 1000; - - // public double[] molarMassTransferFlux; - // public double[] molarMassTransfer; - - /** - *

- * Constructor for TwoPhaseFlowNode. - *

- */ - public TwoPhaseFlowNode() {} - - /** - *

- * Constructor for TwoPhaseFlowNode. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param pipe a {@link neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface} - * object - */ - public TwoPhaseFlowNode(SystemInterface system, GeometryDefinitionInterface pipe) { - super(system, pipe); - - // gasPrandtlNumber = new - // double[getBulkSystem().getPhases()[0].getNumberOfComponents()][getBulkSystem().getPhases()[0].getNumberOfComponents()]; - // liquidPrandtlNumber = new - // double[getBulkSystem().getPhases()[0].getNumberOfComponents()][getBulkSystem().getPhases()[0].getNumberOfComponents()]; - // molarMassTransferFlux = new - // double[getBulkSystem().getPhases()[0].getNumberOfComponents()]; - // molarMassTransfer = new - // double[getBulkSystem().getPhases()[0].getNumberOfComponents()]; - getBulkSystem().initBeta(); - getBulkSystem().init_x_y(); + private static final long serialVersionUID = 1000; + + // public double[] molarMassTransferFlux; + // public double[] molarMassTransfer; + + /** + *

+ * Constructor for TwoPhaseFlowNode. + *

+ */ + public TwoPhaseFlowNode() {} + + /** + *

+ * Constructor for TwoPhaseFlowNode. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param pipe a {@link neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface} + * object + */ + public TwoPhaseFlowNode(SystemInterface system, GeometryDefinitionInterface pipe) { + super(system, pipe); + + // gasPrandtlNumber = new + // double[getBulkSystem().getPhases()[0].getNumberOfComponents()][getBulkSystem().getPhases()[0].getNumberOfComponents()]; + // liquidPrandtlNumber = new + // double[getBulkSystem().getPhases()[0].getNumberOfComponents()][getBulkSystem().getPhases()[0].getNumberOfComponents()]; + // molarMassTransferFlux = new + // double[getBulkSystem().getPhases()[0].getNumberOfComponents()]; + // molarMassTransfer = new + // double[getBulkSystem().getPhases()[0].getNumberOfComponents()]; + getBulkSystem().initBeta(); + getBulkSystem().init_x_y(); + } + + /** {@inheritDoc} */ + @Override + public TwoPhaseFlowNode clone() { + TwoPhaseFlowNode clonedSystem = null; + try { + clonedSystem = (TwoPhaseFlowNode) super.clone(); + } catch (Exception e) { + e.printStackTrace(System.err); } - /** {@inheritDoc} */ - @Override - public TwoPhaseFlowNode clone() { - TwoPhaseFlowNode clonedSystem = null; - try { - clonedSystem = (TwoPhaseFlowNode) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); - } - - // clonedSystem.molarMassTransferFlux = (double[]) - // clonedSystem.molarMassTransferFlux.clone();; - // clonedSystem.molarMassTransfer = (double[]) - // clonedSystem.molarMassTransferFlux.clone(); - clonedSystem.fluidBoundary = fluidBoundary.clone(); - return clonedSystem; - } - - /** - *

- * initVelocity. - *

- * - * @return a double - */ - public double initVelocity() { - getBulkSystem().init(1); - getBulkSystem().initPhysicalProperties(); - molarFlowRate[1] = getBulkSystem().getPhases()[1].getNumberOfMolesInPhase(); - molarFlowRate[0] = getBulkSystem().getPhases()[0].getNumberOfMolesInPhase(); - massFlowRate[1] = molarFlowRate[1] * getBulkSystem().getPhases()[1].getMolarMass(); - massFlowRate[0] = molarFlowRate[0] * getBulkSystem().getPhases()[0].getMolarMass(); - volumetricFlowRate[0] = massFlowRate[0] - / getBulkSystem().getPhases()[0].getPhysicalProperties().getDensity(); - volumetricFlowRate[1] = massFlowRate[1] - / getBulkSystem().getPhases()[1].getPhysicalProperties().getDensity(); - velocity[0] = volumetricFlowRate[0] / (phaseFraction[0] * pipe.getArea()); - velocity[1] = volumetricFlowRate[1] / (phaseFraction[1] * pipe.getArea()); - // System.out.println("velocity " + velocity[0] + " velocity " +velocity[1]); - return velocity[1]; - } - - /** {@inheritDoc} */ - @Override - public void initFlowCalc() { - this.init(); - initVelocity(); - - phaseFraction[0] = 1.0 - 1.0e-10; - phaseFraction[1] = 1.0 - phaseFraction[0]; - double f = 0, fOld = 0, betaOld = 0; - - // double df = 0 - int iterations = 0; - double step = 100.0; - - do { - iterations++; - fOld = f; - - initVelocity(); - init(); - - double Fg = 0.5 * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() - * wallFrictionFactor[0] * Math.pow(velocity[0], 2.0) * wallContactLength[0] - / (pipe.getArea() * 4.0); - double Fl = 0.5 * bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - * wallFrictionFactor[1] * Math.pow(velocity[1], 2.0) * wallContactLength[1] - / (pipe.getArea() * 4.0); - double Fi = 0.5 * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() - * interphaseFrictionFactor[0] * Math.pow(velocity[0] - velocity[1], 2.0) - * interphaseContactLength[0] / (pipe.getArea() * 4.0); - - f = -phaseFraction[0] * Fl + (1 - phaseFraction[0]) * Fg + Fi + (1.0 - phaseFraction[0]) - * phaseFraction[0] - * (bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - - bulkSystem.getPhases()[0].getPhysicalProperties().getDensity()) - * gravity * inclination; - - /* - * df = -Fl - Fg + (bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - - * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity()) * gravity * - * inclination - Math.pow(phaseFraction[0], 2.0) - * (bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - - * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity()) gravity * - * inclination; - */ - - if (f > 0) { - phaseFraction[0] += (betaOld - phaseFraction[0]); - if (fOld < 0) { - step *= 5.0; - } - } else { - betaOld = phaseFraction[0]; - phaseFraction[0] -= phaseFraction[0] / step; - } - phaseFraction[1] = 1.0 - phaseFraction[0]; - // System.out.println("f " + f + " iterations " + iterations + " beta " + - // phaseFraction[0]); - } // while(Math.abs((f-fOld)/f)>1e-8 && iterations<10000); - while (Math.abs(f) > 1e-2 && iterations < 100); - - if (iterations == 10000) { - System.out.println("error in void init calc"); - } - // System.out.println("f " + f + " iterations " + iterations + " beta " + - // phaseFraction[0]); - this.init(); - } - - /** - *

- * calcHydraulicDiameter. - *

- * - * @return a double - */ - public double calcHydraulicDiameter() { - hydraulicDiameter[0] = 4.0 * phaseFraction[0] * pipe.getArea() - / (wallContactLength[0] + interphaseContactLength[0]); - hydraulicDiameter[1] = 4.0 * phaseFraction[1] * pipe.getArea() / wallContactLength[1]; - return hydraulicDiameter[0]; - } - - /** - *

- * calcReynoldNumber. - *

- * - * @return a double - */ - public double calcReynoldNumber() { - reynoldsNumber[1] = velocity[1] * hydraulicDiameter[1] - * bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[1].getPhysicalProperties().getViscosity(); - reynoldsNumber[0] = velocity[0] * hydraulicDiameter[0] - * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[0].getPhysicalProperties().getViscosity(); - return reynoldsNumber[1]; - } - - /** - *

- * calcWallFrictionFactor. - *

- * - * @return a double - */ - public double calcWallFrictionFactor() { - for (int i = 0; i < 2; i++) { - wallFrictionFactor[i] = Math.pow( - (1.0 / (-1.8 * Math.log10(6.9 / getReynoldsNumber(i) * Math.pow( - pipe.getRelativeRoughnes(this.getHydraulicDiameter(i)) / 3.7, 1.11)))), - 2.0); - } - return wallFrictionFactor[0]; - } - - /** {@inheritDoc} */ - @Override - public void setFluxes(double dn[]) { - for (int i = 0; i < getBulkSystem().getPhases()[0].getNumberOfComponents(); i++) { - getBulkSystem().getPhases()[0].addMoles(i, -dn[i]); - getBulkSystem().getPhases()[1].addMoles(i, +dn[i]); - - getInterphaseSystem().getPhases()[0].addMoles(i, -dn[i]); - getInterphaseSystem().getPhases()[1].addMoles(i, +dn[i]); + // clonedSystem.molarMassTransferFlux = (double[]) + // clonedSystem.molarMassTransferFlux.clone();; + // clonedSystem.molarMassTransfer = (double[]) + // clonedSystem.molarMassTransferFlux.clone(); + clonedSystem.fluidBoundary = fluidBoundary.clone(); + return clonedSystem; + } + + /** + *

+ * initVelocity. + *

+ * + * @return a double + */ + public double initVelocity() { + getBulkSystem().init(1); + getBulkSystem().initPhysicalProperties(); + molarFlowRate[1] = getBulkSystem().getPhases()[1].getNumberOfMolesInPhase(); + molarFlowRate[0] = getBulkSystem().getPhases()[0].getNumberOfMolesInPhase(); + massFlowRate[1] = molarFlowRate[1] * getBulkSystem().getPhases()[1].getMolarMass(); + massFlowRate[0] = molarFlowRate[0] * getBulkSystem().getPhases()[0].getMolarMass(); + volumetricFlowRate[0] = + massFlowRate[0] / getBulkSystem().getPhases()[0].getPhysicalProperties().getDensity(); + volumetricFlowRate[1] = + massFlowRate[1] / getBulkSystem().getPhases()[1].getPhysicalProperties().getDensity(); + velocity[0] = volumetricFlowRate[0] / (phaseFraction[0] * pipe.getArea()); + velocity[1] = volumetricFlowRate[1] / (phaseFraction[1] * pipe.getArea()); + // System.out.println("velocity " + velocity[0] + " velocity " +velocity[1]); + return velocity[1]; + } + + /** {@inheritDoc} */ + @Override + public void initFlowCalc() { + this.init(); + initVelocity(); + + phaseFraction[0] = 1.0 - 1.0e-10; + phaseFraction[1] = 1.0 - phaseFraction[0]; + double f = 0; + + double fOld = 0; + double betaOld = 0; + // double df = 0 + int iterations = 0; + double step = 100.0; + + do { + iterations++; + fOld = f; + + initVelocity(); + init(); + + double Fg = 0.5 * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() + * wallFrictionFactor[0] * Math.pow(velocity[0], 2.0) * wallContactLength[0] + / (pipe.getArea() * 4.0); + double Fl = 0.5 * bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() + * wallFrictionFactor[1] * Math.pow(velocity[1], 2.0) * wallContactLength[1] + / (pipe.getArea() * 4.0); + double Fi = 0.5 * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() + * interphaseFrictionFactor[0] * Math.pow(velocity[0] - velocity[1], 2.0) + * interphaseContactLength[0] / (pipe.getArea() * 4.0); + + f = -phaseFraction[0] * Fl + (1 - phaseFraction[0]) * Fg + Fi + + (1.0 - phaseFraction[0]) * phaseFraction[0] + * (bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() + - bulkSystem.getPhases()[0].getPhysicalProperties().getDensity()) + * gravity * inclination; + + /* + * df = -Fl - Fg + (bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - + * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity()) * gravity * inclination - + * Math.pow(phaseFraction[0], 2.0) + * (bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - + * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity()) gravity * inclination; + */ + + if (f > 0) { + phaseFraction[0] += (betaOld - phaseFraction[0]); + if (fOld < 0) { + step *= 5.0; } + } else { + betaOld = phaseFraction[0]; + phaseFraction[0] -= phaseFraction[0] / step; + } + phaseFraction[1] = 1.0 - phaseFraction[0]; + // System.out.println("f " + f + " iterations " + iterations + " beta " + + // phaseFraction[0]); + } // while(Math.abs((f-fOld)/f)>1e-8 && iterations<10000); + while (Math.abs(f) > 1e-2 && iterations < 100); + + if (iterations == 10000) { + System.out.println("error in void init calc"); } - - /** {@inheritDoc} */ - @Override - public void updateMolarFlow() { - for (int phase = 0; phase < 2; phase++) { - for (int i = 0; i < getBulkSystem().getPhases()[0].getNumberOfComponents(); i++) { - getBulkSystem().getPhases()[phase].addMoles(i, - (getBulkSystem().getPhases()[phase].getComponents()[i].getx() - * (molarFlowRate[phase] - getBulkSystem().getPhases()[phase] - .getNumberOfMolesInPhase()))); - } - } - getBulkSystem().init(1); + // System.out.println("f " + f + " iterations " + iterations + " beta " + + // phaseFraction[0]); + this.init(); + } + + /** + *

+ * calcHydraulicDiameter. + *

+ * + * @return a double + */ + public double calcHydraulicDiameter() { + hydraulicDiameter[0] = 4.0 * phaseFraction[0] * pipe.getArea() + / (wallContactLength[0] + interphaseContactLength[0]); + hydraulicDiameter[1] = 4.0 * phaseFraction[1] * pipe.getArea() / wallContactLength[1]; + return hydraulicDiameter[0]; + } + + /** + *

+ * calcReynoldNumber. + *

+ * + * @return a double + */ + public double calcReynoldNumber() { + reynoldsNumber[1] = velocity[1] * hydraulicDiameter[1] + * bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() + / bulkSystem.getPhases()[1].getPhysicalProperties().getViscosity(); + reynoldsNumber[0] = velocity[0] * hydraulicDiameter[0] + * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() + / bulkSystem.getPhases()[0].getPhysicalProperties().getViscosity(); + return reynoldsNumber[1]; + } + + /** + *

+ * calcWallFrictionFactor. + *

+ * + * @return a double + */ + public double calcWallFrictionFactor() { + for (int i = 0; i < 2; i++) { + wallFrictionFactor[i] = Math.pow( + (1.0 / (-1.8 * Math.log10(6.9 / getReynoldsNumber(i) + * Math.pow(pipe.getRelativeRoughnes(this.getHydraulicDiameter(i)) / 3.7, 1.11)))), + 2.0); } - - /** - *

- * calcContactLength. - *

- * - * @return a double - */ - public double calcContactLength() { - return 0; + return wallFrictionFactor[0]; + } + + /** {@inheritDoc} */ + @Override + public void setFluxes(double[] dn) { + for (int i = 0; i < getBulkSystem().getPhases()[0].getNumberOfComponents(); i++) { + getBulkSystem().getPhases()[0].addMoles(i, -dn[i]); + getBulkSystem().getPhases()[1].addMoles(i, +dn[i]); + + getInterphaseSystem().getPhases()[0].addMoles(i, -dn[i]); + getInterphaseSystem().getPhases()[1].addMoles(i, +dn[i]); } - - /** {@inheritDoc} */ - @Override - public void init() { - super.init(); - massFlowRate[0] = - velocity[0] * getBulkSystem().getPhases()[0].getPhysicalProperties().getDensity() - * pipe.getArea() * phaseFraction[0]; - massFlowRate[1] = - velocity[1] * getBulkSystem().getPhases()[1].getPhysicalProperties().getDensity() - * pipe.getArea() * phaseFraction[1]; - molarFlowRate[0] = massFlowRate[0] / getBulkSystem().getPhases()[0].getMolarMass(); - molarFlowRate[1] = massFlowRate[1] / getBulkSystem().getPhases()[1].getMolarMass(); - superficialVelocity[0] = velocity[0] * phaseFraction[0]; - superficialVelocity[1] = velocity[1] * phaseFraction[1]; - volumetricFlowRate[0] = superficialVelocity[0] * pipe.getArea(); - volumetricFlowRate[1] = superficialVelocity[1] * pipe.getArea(); - this.updateMolarFlow(); - - this.calcHydraulicDiameter(); - this.calcReynoldNumber(); - interphaseContactArea = this.calcGasLiquidContactArea(); - - wallFrictionFactor[0] = interphaseTransportCoefficient.calcWallFrictionFactor(0, this); - wallFrictionFactor[1] = interphaseTransportCoefficient.calcWallFrictionFactor(1, this); - - interphaseFrictionFactor[0] = - interphaseTransportCoefficient.calcInterPhaseFrictionFactor(0, this); - interphaseFrictionFactor[1] = - interphaseTransportCoefficient.calcInterPhaseFrictionFactor(0, this); + } + + /** {@inheritDoc} */ + @Override + public void updateMolarFlow() { + for (int phase = 0; phase < 2; phase++) { + for (int i = 0; i < getBulkSystem().getPhases()[0].getNumberOfComponents(); i++) { + getBulkSystem().getPhases()[phase].addMoles(i, + (getBulkSystem().getPhases()[phase].getComponents()[i].getx() * (molarFlowRate[phase] + - getBulkSystem().getPhases()[phase].getNumberOfMolesInPhase()))); + } } - - /** - *

- * calcGasLiquidContactArea. - *

- * - * @return a double - */ - public double calcGasLiquidContactArea() { - interphaseContactArea = pipe.getNodeLength() * interphaseContactLength[0]; - return interphaseContactArea; + getBulkSystem().init(1); + } + + /** + *

+ * calcContactLength. + *

+ * + * @return a double + */ + public double calcContactLength() { + return 0; + } + + /** {@inheritDoc} */ + @Override + public void init() { + super.init(); + massFlowRate[0] = + velocity[0] * getBulkSystem().getPhases()[0].getPhysicalProperties().getDensity() + * pipe.getArea() * phaseFraction[0]; + massFlowRate[1] = + velocity[1] * getBulkSystem().getPhases()[1].getPhysicalProperties().getDensity() + * pipe.getArea() * phaseFraction[1]; + molarFlowRate[0] = massFlowRate[0] / getBulkSystem().getPhases()[0].getMolarMass(); + molarFlowRate[1] = massFlowRate[1] / getBulkSystem().getPhases()[1].getMolarMass(); + superficialVelocity[0] = velocity[0] * phaseFraction[0]; + superficialVelocity[1] = velocity[1] * phaseFraction[1]; + volumetricFlowRate[0] = superficialVelocity[0] * pipe.getArea(); + volumetricFlowRate[1] = superficialVelocity[1] * pipe.getArea(); + this.updateMolarFlow(); + + this.calcHydraulicDiameter(); + this.calcReynoldNumber(); + interphaseContactArea = this.calcGasLiquidContactArea(); + + wallFrictionFactor[0] = interphaseTransportCoefficient.calcWallFrictionFactor(0, this); + wallFrictionFactor[1] = interphaseTransportCoefficient.calcWallFrictionFactor(1, this); + + interphaseFrictionFactor[0] = + interphaseTransportCoefficient.calcInterPhaseFrictionFactor(0, this); + interphaseFrictionFactor[1] = + interphaseTransportCoefficient.calcInterPhaseFrictionFactor(0, this); + } + + /** + *

+ * calcGasLiquidContactArea. + *

+ * + * @return a double + */ + public double calcGasLiquidContactArea() { + interphaseContactArea = pipe.getNodeLength() * interphaseContactLength[0]; + return interphaseContactArea; + } + + /** {@inheritDoc} */ + @Override + public void calcFluxes() { + if (bulkSystem.isChemicalSystem()) { + // getBulkSystem().getChemicalReactionOperations().setSystem(getBulkSystem()); + // getOperations().chemicalEquilibrium(); } - - /** {@inheritDoc} */ - @Override - public void calcFluxes() { - if (bulkSystem.isChemicalSystem()) { - // getBulkSystem().getChemicalReactionOperations().setSystem(getBulkSystem()); - // getOperations().chemicalEquilibrium(); - } - fluidBoundary.solve(); - fluidBoundary.calcFluxes(); - } - - /** {@inheritDoc} */ - @Override - public void update() { - // System.out.println("reac heat " + - // getBulkSystem().getChemicalReactionOperations().getDeltaReactionHeat()); - double heatFluxGas = getFluidBoundary().getInterphaseHeatFlux(0);// getInterphaseTransportCoefficient().calcInterphaseHeatTransferCoefficient(0, - // getPrandtlNumber(0), + fluidBoundary.solve(); + fluidBoundary.calcFluxes(); + } + + /** {@inheritDoc} */ + @Override + public void update() { + // System.out.println("reac heat " + + // getBulkSystem().getChemicalReactionOperations().getDeltaReactionHeat()); + double heatFluxGas = getFluidBoundary().getInterphaseHeatFlux(0); // getInterphaseTransportCoefficient().calcInterphaseHeatTransferCoefficient(0, + // getPrandtlNumber(0), + // this) * + // (getInterphaseSystem().getPhase(0).getTemperature() + // - + // getBulkSystem().getPhase(0).getTemperature()) + // * + // getInterphaseContactArea(); + + double heatFluxLiquid = getFluidBoundary().getInterphaseHeatFlux(1); // getInterphaseTransportCoefficient().calcInterphaseHeatTransferCoefficient(1, + // getPrandtlNumber(1), // this) * - // (getInterphaseSystem().getPhase(0).getTemperature() + // (getInterphaseSystem().getPhase(1).getTemperature() // - - // getBulkSystem().getPhase(0).getTemperature()) + // getBulkSystem().getPhase(1).getTemperature()) // * // getInterphaseContactArea(); - - double heatFluxLiquid = getFluidBoundary().getInterphaseHeatFlux(1);// getInterphaseTransportCoefficient().calcInterphaseHeatTransferCoefficient(1, - // getPrandtlNumber(1), - // this) * - // (getInterphaseSystem().getPhase(1).getTemperature() - // - - // getBulkSystem().getPhase(1).getTemperature()) - // * - // getInterphaseContactArea(); - // System.out.println("heat flux local " + heatFluxLiquid); - // double liquid_dT = - // -this.flowDirection[1]*heatFlux/1000.0/getBulkSystem().getPhase(1).getCp(); - - double liquid_dT = this.flowDirection[1] * heatFluxLiquid * getGeometry().getNodeLength() - / getVelocity(1) / getBulkSystem().getPhase(1).getCp(); - double gas_dT = this.flowDirection[0] * heatFluxGas * getGeometry().getNodeLength() - / getVelocity(0) / getBulkSystem().getPhase(0).getCp(); - liquid_dT -= 0 - * getInterphaseTransportCoefficient().calcWallHeatTransferCoefficient(1, this) - * (getBulkSystem().getPhase(1).getTemperature() - pipe.getInnerWallTemperature()) - * getWallContactLength(1) * getGeometry().getNodeLength() - / getBulkSystem().getPhase(1).getCp(); - gas_dT -= 0 * getInterphaseTransportCoefficient().calcWallHeatTransferCoefficient(0, this) + // System.out.println("heat flux local " + heatFluxLiquid); + // double liquid_dT = + // -this.flowDirection[1]*heatFlux/1000.0/getBulkSystem().getPhase(1).getCp(); + + double liquid_dT = this.flowDirection[1] * heatFluxLiquid * getGeometry().getNodeLength() + / getVelocity(1) / getBulkSystem().getPhase(1).getCp(); + double gas_dT = this.flowDirection[0] * heatFluxGas * getGeometry().getNodeLength() + / getVelocity(0) / getBulkSystem().getPhase(0).getCp(); + liquid_dT -= 0 * getInterphaseTransportCoefficient().calcWallHeatTransferCoefficient(1, this) + * (getBulkSystem().getPhase(1).getTemperature() - pipe.getInnerWallTemperature()) + * getWallContactLength(1) * getGeometry().getNodeLength() + / getBulkSystem().getPhase(1).getCp(); + gas_dT -= 0 * getInterphaseTransportCoefficient().calcWallHeatTransferCoefficient(0, this) + * (getBulkSystem().getPhase(0).getTemperature() - pipe.getInnerWallTemperature()) + * getWallContactLength(0) * getGeometry().getNodeLength() + / getBulkSystem().getPhase(0).getCp(); + // liquid_dT += + // getInterphaseTransportCoefficient().calcWallHeatTransferCoefficient(0, this)* + // (getBulkSystem().getPhase(0).getTemperature()-pipe.getOuterTemperature())* + // getWallContactLength(0) * + // getGeometry().getNodeLength()/getBulkSystem().getPhase(0).getCp(); + // liquid_dT += + // 10*this.flowDirection[1]*getBulkSystem().getChemicalReactionOperations().getDeltaReactionHeat()/getBulkSystem().getPhase(1).getCp(); + // System.out.println("Cp " + getBulkSystem().getPhase(1).getCp()); + // System.out.println("liq dT " + liquid_dT); + // System.out.println("gas dT " + gas_dT); + double fluxwallinternal = getInterphaseTransportCoefficient().calcWallHeatTransferCoefficient(1, + this) * (getBulkSystem().getPhase(1).getTemperature() - pipe.getInnerWallTemperature()) + * getWallContactLength(1) * getGeometry().getNodeLength() + + getInterphaseTransportCoefficient().calcWallHeatTransferCoefficient(0, this) * (getBulkSystem().getPhase(0).getTemperature() - pipe.getInnerWallTemperature()) - * getWallContactLength(0) * getGeometry().getNodeLength() - / getBulkSystem().getPhase(0).getCp(); - // liquid_dT += - // getInterphaseTransportCoefficient().calcWallHeatTransferCoefficient(0, this)* - // (getBulkSystem().getPhase(0).getTemperature()-pipe.getOuterTemperature())* - // getWallContactLength(0) * - // getGeometry().getNodeLength()/getBulkSystem().getPhase(0).getCp(); - // liquid_dT += - // 10*this.flowDirection[1]*getBulkSystem().getChemicalReactionOperations().getDeltaReactionHeat()/getBulkSystem().getPhase(1).getCp(); - // System.out.println("Cp " + getBulkSystem().getPhase(1).getCp()); - // System.out.println("liq dT " + liquid_dT); - // System.out.println("gas dT " + gas_dT); - double fluxwallinternal = getInterphaseTransportCoefficient() - .calcWallHeatTransferCoefficient(1, this) - * (getBulkSystem().getPhase(1).getTemperature() - pipe.getInnerWallTemperature()) - * getWallContactLength(1) * getGeometry().getNodeLength() - + getInterphaseTransportCoefficient().calcWallHeatTransferCoefficient(0, this) - * (getBulkSystem().getPhase(0).getTemperature() - - pipe.getInnerWallTemperature()) - * getWallContactLength(0) * getGeometry().getNodeLength(); - - double JolprK = 3.14 * 0.2032 * 0.0094 * getGeometry().getNodeLength() * 7500 * 500; - double fluxOut = -50.0 * 3.14 * (0.2032 + 0.01) * getGeometry().getNodeLength() - * (pipe.getInnerWallTemperature() - - pipe.getSurroundingEnvironment().getTemperature()); - double dTwall = 0 * (fluxOut + fluxwallinternal) / JolprK; - pipe.setInnerWallTemperature(pipe.getInnerWallTemperature() + dTwall); - - getBulkSystem().getPhase(1) - .setTemperature(getBulkSystem().getPhase(1).getTemperature() + liquid_dT); - getBulkSystem().getPhase(0) - .setTemperature(getBulkSystem().getPhase(0).getTemperature() + gas_dT); - - // System.out.println("pipe wall temperature " + pipe.getTemperature()); - // System.out.println("liquid velocity " + getSuperficialVelocity(1)); - // System.out.println("gas velocity " + getSuperficialVelocity(0)); - - for (int componentNumber = 0; componentNumber < getBulkSystem().getPhases()[0] - .getNumberOfComponents(); componentNumber++) { - double liquidMolarRate = getFluidBoundary().getInterphaseMolarFlux(componentNumber) - * getInterphaseContactArea();// getInterphaseContactLength(0)*getGeometry().getNodeLength(); - - double gasMolarRate = -getFluidBoundary().getInterphaseMolarFlux(componentNumber) - * getInterphaseContactArea();// getInterphaseContactLength(0)*getGeometry().getNodeLength(); - - // System.out.println("liquidMolarRate" + liquidMolarRate); - getBulkSystem().getPhase(0).addMoles(componentNumber, - this.flowDirection[0] * gasMolarRate); - getBulkSystem().getPhase(1).addMoles(componentNumber, - this.flowDirection[1] * liquidMolarRate); - } + * getWallContactLength(0) * getGeometry().getNodeLength(); + + double JolprK = 3.14 * 0.2032 * 0.0094 * getGeometry().getNodeLength() * 7500 * 500; + double fluxOut = -50.0 * 3.14 * (0.2032 + 0.01) * getGeometry().getNodeLength() + * (pipe.getInnerWallTemperature() - pipe.getSurroundingEnvironment().getTemperature()); + double dTwall = 0 * (fluxOut + fluxwallinternal) / JolprK; + pipe.setInnerWallTemperature(pipe.getInnerWallTemperature() + dTwall); + + getBulkSystem().getPhase(1) + .setTemperature(getBulkSystem().getPhase(1).getTemperature() + liquid_dT); + getBulkSystem().getPhase(0) + .setTemperature(getBulkSystem().getPhase(0).getTemperature() + gas_dT); + + // System.out.println("pipe wall temperature " + pipe.getTemperature()); + // System.out.println("liquid velocity " + getSuperficialVelocity(1)); + // System.out.println("gas velocity " + getSuperficialVelocity(0)); + + for (int componentNumber = 0; componentNumber < getBulkSystem().getPhases()[0] + .getNumberOfComponents(); componentNumber++) { + double liquidMolarRate = + getFluidBoundary().getInterphaseMolarFlux(componentNumber) * getInterphaseContactArea(); // getInterphaseContactLength(0)*getGeometry().getNodeLength(); + + double gasMolarRate = + -getFluidBoundary().getInterphaseMolarFlux(componentNumber) * getInterphaseContactArea(); // getInterphaseContactLength(0)*getGeometry().getNodeLength(); + + // System.out.println("liquidMolarRate" + liquidMolarRate); + getBulkSystem().getPhase(0).addMoles(componentNumber, this.flowDirection[0] * gasMolarRate); + getBulkSystem().getPhase(1).addMoles(componentNumber, + this.flowDirection[1] * liquidMolarRate); + } - getBulkSystem().initBeta(); - getBulkSystem().init_x_y(); - getBulkSystem().init(3); + getBulkSystem().initBeta(); + getBulkSystem().init_x_y(); + getBulkSystem().init(3); - if (bulkSystem.isChemicalSystem()) { - getBulkSystem().getChemicalReactionOperations().setSystem(getBulkSystem()); - getOperations().chemicalEquilibrium(); - } + if (bulkSystem.isChemicalSystem()) { + getBulkSystem().getChemicalReactionOperations().setSystem(getBulkSystem()); + getOperations().chemicalEquilibrium(); } + } } diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/twoPhaseReactorFlowNode/TwoPhasePackedBedFlowNode.java b/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/twoPhaseReactorFlowNode/TwoPhasePackedBedFlowNode.java index 7dc9485f5a..0be0d035c1 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/twoPhaseReactorFlowNode/TwoPhasePackedBedFlowNode.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/twoPhaseReactorFlowNode/TwoPhasePackedBedFlowNode.java @@ -18,241 +18,239 @@ * @version $Id: $Id */ public class TwoPhasePackedBedFlowNode extends TwoPhaseFlowNode { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for TwoPhasePackedBedFlowNode. - *

- */ - public TwoPhasePackedBedFlowNode() { - this.flowNodeType = "packed bed"; - } - - /** - *

- * Constructor for TwoPhasePackedBedFlowNode. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param pipe a {@link neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface} - * object - */ - public TwoPhasePackedBedFlowNode(SystemInterface system, GeometryDefinitionInterface pipe) { - super(system, pipe); - this.flowNodeType = "packed bed"; - this.interphaseTransportCoefficient = new InterphasePackedBed(this); - this.fluidBoundary = - new neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.nonEquilibriumFluidBoundary.filmModelBoundary.KrishnaStandartFilmModel( - this); - } + /** + *

+ * Constructor for TwoPhasePackedBedFlowNode. + *

+ */ + public TwoPhasePackedBedFlowNode() { + this.flowNodeType = "packed bed"; + } - /** - *

- * Constructor for TwoPhasePackedBedFlowNode. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param interphaseSystem a {@link neqsim.thermo.system.SystemInterface} object - * @param pipe a {@link neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface} - * object - */ - public TwoPhasePackedBedFlowNode(SystemInterface system, SystemInterface interphaseSystem, - GeometryDefinitionInterface pipe) { - super(system, pipe); - this.flowNodeType = "packed bed"; - this.interphaseTransportCoefficient = new InterphasePackedBed(this); - this.fluidBoundary = - new neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.nonEquilibriumFluidBoundary.filmModelBoundary.KrishnaStandartFilmModel( - this); - } + /** + *

+ * Constructor for TwoPhasePackedBedFlowNode. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param pipe a {@link neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface} + * object + */ + public TwoPhasePackedBedFlowNode(SystemInterface system, GeometryDefinitionInterface pipe) { + super(system, pipe); + this.flowNodeType = "packed bed"; + this.interphaseTransportCoefficient = new InterphasePackedBed(this); + this.fluidBoundary = + new neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.nonEquilibriumFluidBoundary.filmModelBoundary.KrishnaStandartFilmModel( + this); + } - /** {@inheritDoc} */ - @Override - public TwoPhasePackedBedFlowNode clone() { - TwoPhasePackedBedFlowNode clonedSystem = null; - try { - clonedSystem = (TwoPhasePackedBedFlowNode) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); - } + /** + *

+ * Constructor for TwoPhasePackedBedFlowNode. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param interphaseSystem a {@link neqsim.thermo.system.SystemInterface} object + * @param pipe a {@link neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface} + * object + */ + public TwoPhasePackedBedFlowNode(SystemInterface system, SystemInterface interphaseSystem, + GeometryDefinitionInterface pipe) { + super(system, pipe); + this.flowNodeType = "packed bed"; + this.interphaseTransportCoefficient = new InterphasePackedBed(this); + this.fluidBoundary = + new neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.nonEquilibriumFluidBoundary.filmModelBoundary.KrishnaStandartFilmModel( + this); + } - return clonedSystem; + /** {@inheritDoc} */ + @Override + public TwoPhasePackedBedFlowNode clone() { + TwoPhasePackedBedFlowNode clonedSystem = null; + try { + clonedSystem = (TwoPhasePackedBedFlowNode) super.clone(); + } catch (Exception e) { + e.printStackTrace(System.err); } - /** {@inheritDoc} */ - @Override - public void init() { - inclination = 0.0; - this.calcContactLength(); - super.init(); - } + return clonedSystem; + } - /** {@inheritDoc} */ - @Override - public void initFlowCalc() { - phaseFraction[0] = 1.0; - phaseFraction[1] = 1.0; - initVelocity(); - this.init(); - } + /** {@inheritDoc} */ + @Override + public void init() { + inclination = 0.0; + this.calcContactLength(); + super.init(); + } - /** {@inheritDoc} */ - @Override - public double calcHydraulicDiameter() { - return getGeometry().getDiameter(); - } + /** {@inheritDoc} */ + @Override + public void initFlowCalc() { + phaseFraction[0] = 1.0; + phaseFraction[1] = 1.0; + initVelocity(); + this.init(); + } - /** {@inheritDoc} */ - @Override - public double calcReynoldNumber() { - reynoldsNumber[1] = - getSuperficialVelocity(1) / getGeometry().getPacking().getSurfaceAreaPrVolume() - * bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[1].getPhysicalProperties().getViscosity(); - reynoldsNumber[0] = - getSuperficialVelocity(0) / getGeometry().getPacking().getSurfaceAreaPrVolume() - * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[0].getPhysicalProperties().getViscosity(); - System.out.println("rey liq " + reynoldsNumber[1]); - System.out.println("rey gas " + reynoldsNumber[0]); - return reynoldsNumber[1]; - } + /** {@inheritDoc} */ + @Override + public double calcHydraulicDiameter() { + return getGeometry().getDiameter(); + } - /** {@inheritDoc} */ - @Override - public double calcContactLength() { - interphaseContactArea = - pipe.getPacking().getSurfaceAreaPrVolume() * getLengthOfNode() * pipe.getArea(); - return wallContactLength[0]; - } + /** {@inheritDoc} */ + @Override + public double calcReynoldNumber() { + reynoldsNumber[1] = + getSuperficialVelocity(1) / getGeometry().getPacking().getSurfaceAreaPrVolume() + * bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() + / bulkSystem.getPhases()[1].getPhysicalProperties().getViscosity(); + reynoldsNumber[0] = + getSuperficialVelocity(0) / getGeometry().getPacking().getSurfaceAreaPrVolume() + * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() + / bulkSystem.getPhases()[0].getPhysicalProperties().getViscosity(); + System.out.println("rey liq " + reynoldsNumber[1]); + System.out.println("rey gas " + reynoldsNumber[0]); + return reynoldsNumber[1]; + } - /** {@inheritDoc} */ - @Override - public double calcGasLiquidContactArea() { - return pipe.getPacking().getSurfaceAreaPrVolume() * getLengthOfNode() * pipe.getArea() - * 5.0; - } + /** {@inheritDoc} */ + @Override + public double calcContactLength() { + interphaseContactArea = + pipe.getPacking().getSurfaceAreaPrVolume() * getLengthOfNode() * pipe.getArea(); + return wallContactLength[0]; + } - /** {@inheritDoc} */ - @Override - public FlowNodeInterface getNextNode() { - TwoPhasePackedBedFlowNode newNode = this.clone(); + /** {@inheritDoc} */ + @Override + public double calcGasLiquidContactArea() { + return pipe.getPacking().getSurfaceAreaPrVolume() * getLengthOfNode() * pipe.getArea() * 5.0; + } - for (int i = 0; i < getBulkSystem().getPhases()[0].getNumberOfComponents(); i++) { - // newNode.getBulkSystem().getPhases()[0].addMoles(i, -molarMassTransfer[i]); - // newNode.getBulkSystem().getPhases()[1].addMoles(i, +molarMassTransfer[i]); - } + /** {@inheritDoc} */ + @Override + public FlowNodeInterface getNextNode() { + TwoPhasePackedBedFlowNode newNode = this.clone(); - return newNode; + for (int i = 0; i < getBulkSystem().getPhases()[0].getNumberOfComponents(); i++) { + // newNode.getBulkSystem().getPhases()[0].addMoles(i, -molarMassTransfer[i]); + // newNode.getBulkSystem().getPhases()[1].addMoles(i, +molarMassTransfer[i]); } - /** {@inheritDoc} */ - @Override - public void update() { - for (int componentNumber = 0; componentNumber < getBulkSystem().getPhases()[0] - .getNumberOfComponents(); componentNumber++) { - if (componentNumber == 1) { - double liquidMolarRate = getFluidBoundary().getInterphaseMolarFlux(componentNumber) - * getInterphaseContactArea();// getInterphaseContactLength(0)*getGeometry().getNodeLength(); - double gasMolarRate = -getFluidBoundary().getInterphaseMolarFlux(componentNumber) - * getInterphaseContactArea();// getInterphaseContactLength(0)*getGeometry().getNodeLength(); - System.out.println("liquidMolarRate" + liquidMolarRate); - // getBulkSystem().getPhase(0).addMoles(componentNumber, - // this.flowDirection[0]*gasMolarRate); - getBulkSystem().addComponent(componentNumber, this.flowDirection[0] * gasMolarRate, - 0); - getBulkSystem().getPhase(1).addMolesChemReac(componentNumber, - this.flowDirection[1] * liquidMolarRate); - } - } + return newNode; + } - getBulkSystem().initBeta(); - getBulkSystem().init_x_y(); - getBulkSystem().init(1); + /** {@inheritDoc} */ + @Override + public void update() { + for (int componentNumber = 0; componentNumber < getBulkSystem().getPhases()[0] + .getNumberOfComponents(); componentNumber++) { + if (componentNumber == 1) { + double liquidMolarRate = + getFluidBoundary().getInterphaseMolarFlux(componentNumber) * getInterphaseContactArea(); // getInterphaseContactLength(0)*getGeometry().getNodeLength(); + double gasMolarRate = -getFluidBoundary().getInterphaseMolarFlux(componentNumber) + * getInterphaseContactArea(); // getInterphaseContactLength(0)*getGeometry().getNodeLength(); + System.out.println("liquidMolarRate" + liquidMolarRate); + // getBulkSystem().getPhase(0).addMoles(componentNumber, + // this.flowDirection[0]*gasMolarRate); + getBulkSystem().addComponent(componentNumber, this.flowDirection[0] * gasMolarRate, 0); + getBulkSystem().getPhase(1).addMolesChemReac(componentNumber, + this.flowDirection[1] * liquidMolarRate); + } + } - if (bulkSystem.isChemicalSystem()) { - getOperations().chemicalEquilibrium(); - } - getBulkSystem().init(3); - System.out.println("reac heat " - + getBulkSystem().getChemicalReactionOperations().getDeltaReactionHeat()); - double heatFlux = getInterphaseTransportCoefficient() - .calcInterphaseHeatTransferCoefficient(0, getPrandtlNumber(0), this) - * (getBulkSystem().getPhase(1).getTemperature() - - getBulkSystem().getPhase(0).getTemperature()) - * getInterphaseContactArea(); - double liquid_dT = -this.flowDirection[1] * heatFlux / getBulkSystem().getPhase(1).getCp(); - double gas_dT = this.flowDirection[0] * heatFlux / getBulkSystem().getPhase(0).getCp(); - liquid_dT += 0.0;// getInterphaseTransportCoefficient().calcWallHeatTransferCoefficient(1, - // this)*(getBulkSystem().getPhase(1).getTemperature()-pipe.getOuterTemperature()) - // * getWallContactLength(1) * - // getGeometry().getNodeLength()/getBulkSystem().getPhase(1).getCp(); - liquid_dT += 0.0;// getInterphaseTransportCoefficient().calcWallHeatTransferCoefficient(0, - // this)* - // (getBulkSystem().getPhase(0).getTemperature()-pipe.getOuterTemperature())* - // getWallContactLength(0) * - // getGeometry().getNodeLength()/getBulkSystem().getPhase(0).getCp(); - System.out.println("liq dT1 " + liquid_dT); - liquid_dT += this.flowDirection[1] - * getBulkSystem().getChemicalReactionOperations().getDeltaReactionHeat() - / getBulkSystem().getPhase(1).getCp(); - System.out.println("Cp " + getBulkSystem().getPhase(1).getCp()); - System.out.println("liq dT2 " + liquid_dT); - System.out.println("gas dT " + gas_dT); - getBulkSystem().getPhase(1) - .setTemperature(getBulkSystem().getPhase(1).getTemperature() + liquid_dT); - getBulkSystem().getPhase(0) - .setTemperature(getBulkSystem().getPhase(0).getTemperature() + gas_dT); + getBulkSystem().initBeta(); + getBulkSystem().init_x_y(); + getBulkSystem().init(1); - getBulkSystem().init(3); + if (bulkSystem.isChemicalSystem()) { + getOperations().chemicalEquilibrium(); } + getBulkSystem().init(3); + System.out.println( + "reac heat " + getBulkSystem().getChemicalReactionOperations().getDeltaReactionHeat()); + double heatFlux = getInterphaseTransportCoefficient().calcInterphaseHeatTransferCoefficient(0, + getPrandtlNumber(0), this) + * (getBulkSystem().getPhase(1).getTemperature() + - getBulkSystem().getPhase(0).getTemperature()) + * getInterphaseContactArea(); + double liquid_dT = -this.flowDirection[1] * heatFlux / getBulkSystem().getPhase(1).getCp(); + double gas_dT = this.flowDirection[0] * heatFlux / getBulkSystem().getPhase(0).getCp(); + liquid_dT += 0.0; // getInterphaseTransportCoefficient().calcWallHeatTransferCoefficient(1, + // this)*(getBulkSystem().getPhase(1).getTemperature()-pipe.getOuterTemperature()) + // * getWallContactLength(1) * + // getGeometry().getNodeLength()/getBulkSystem().getPhase(1).getCp(); + liquid_dT += 0.0; // getInterphaseTransportCoefficient().calcWallHeatTransferCoefficient(0, + // this)* + // (getBulkSystem().getPhase(0).getTemperature()-pipe.getOuterTemperature())* + // getWallContactLength(0) * + // getGeometry().getNodeLength()/getBulkSystem().getPhase(0).getCp(); + System.out.println("liq dT1 " + liquid_dT); + liquid_dT += this.flowDirection[1] + * getBulkSystem().getChemicalReactionOperations().getDeltaReactionHeat() + / getBulkSystem().getPhase(1).getCp(); + System.out.println("Cp " + getBulkSystem().getPhase(1).getCp()); + System.out.println("liq dT2 " + liquid_dT); + System.out.println("gas dT " + gas_dT); + getBulkSystem().getPhase(1) + .setTemperature(getBulkSystem().getPhase(1).getTemperature() + liquid_dT); + getBulkSystem().getPhase(0) + .setTemperature(getBulkSystem().getPhase(0).getTemperature() + gas_dT); + + getBulkSystem().init(3); + } - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - SystemInterface testSystem = new SystemFurstElectrolyteEos(313.315, 50.01325); - // SystemInterface testSystem = new SystemSrkEos(295.3, 100.01325); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + SystemInterface testSystem = new SystemFurstElectrolyteEos(313.315, 50.01325); + // SystemInterface testSystem = new SystemSrkEos(295.3, 100.01325); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - ReactorData pipe1 = new ReactorData(0.25, 0.025); - pipe1.setPackingType("pallring", "metal", 50); + ReactorData pipe1 = new ReactorData(0.25, 0.025); + pipe1.setPackingType("pallring", "metal", 50); - testSystem.addComponent("methane", 100000.11152187, "Nlitre/min", 0); - testSystem.addComponent("CO2", 3000.511152181, "Nlitre/min", 0); - testSystem.addComponent("water", 100.502204876, "kg/min", 1); - testSystem.addComponent("MDEA", 100.502204876, "kg/min", 1); - testSystem.chemicalReactionInit(); - testSystem.createDatabase(true); - testSystem.setMixingRule(4); - testOps.TPflash(); - testSystem.addComponent("CO2", 2000.11152181, "Nlitre/min", 0); - testSystem.setPhysicalPropertyModel(3); - testSystem.init_x_y(); - testSystem.getPhases()[1].setTemperature(313.0); - testSystem.getPhases()[0].setTemperature(325.0); + testSystem.addComponent("methane", 100000.11152187, "Nlitre/min", 0); + testSystem.addComponent("CO2", 3000.511152181, "Nlitre/min", 0); + testSystem.addComponent("water", 100.502204876, "kg/min", 1); + testSystem.addComponent("MDEA", 100.502204876, "kg/min", 1); + testSystem.chemicalReactionInit(); + testSystem.createDatabase(true); + testSystem.setMixingRule(4); + testOps.TPflash(); + testSystem.addComponent("CO2", 2000.11152181, "Nlitre/min", 0); + testSystem.setPhysicalPropertyModel(3); + testSystem.init_x_y(); + testSystem.getPhases()[1].setTemperature(313.0); + testSystem.getPhases()[0].setTemperature(325.0); - FlowNodeInterface test = new TwoPhasePackedBedFlowNode(testSystem, pipe1); - test.setLengthOfNode(0.1); - test.setInterphaseModelType(1); - test.getFluidBoundary().useFiniteFluxCorrection(false); - test.getFluidBoundary().useThermodynamicCorrections(false); - test.setFlowDirection(-1, 0); - test.initFlowCalc(); - test.initFlowCalc(); + FlowNodeInterface test = new TwoPhasePackedBedFlowNode(testSystem, pipe1); + test.setLengthOfNode(0.1); + test.setInterphaseModelType(1); + test.getFluidBoundary().useFiniteFluxCorrection(false); + test.getFluidBoundary().useThermodynamicCorrections(false); + test.setFlowDirection(-1, 0); + test.initFlowCalc(); + test.initFlowCalc(); - String fileName = "c:/labsim/exp-abs-heat.txt"; - test.write("node 0", fileName, true); - for (int i = 0; i < 120; i++) { - test.calcFluxes(); - test.update(); - test.display(); - test.write(("node " + i), fileName, false); - } + String fileName = "c:/labsim/exp-abs-heat.txt"; + test.write("node 0", fileName, true); + for (int i = 0; i < 120; i++) { + test.calcFluxes(); + test.update(); + test.display(); + test.write(("node " + i), fileName, false); } + } } diff --git a/src/main/java/neqsim/fluidMechanics/flowSolver/twoPhaseFlowSolver/stirredCellSolver/StirredCellSolver.java b/src/main/java/neqsim/fluidMechanics/flowSolver/twoPhaseFlowSolver/stirredCellSolver/StirredCellSolver.java index 20afd71ed6..e0b4064a2b 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSolver/twoPhaseFlowSolver/stirredCellSolver/StirredCellSolver.java +++ b/src/main/java/neqsim/fluidMechanics/flowSolver/twoPhaseFlowSolver/stirredCellSolver/StirredCellSolver.java @@ -16,379 +16,358 @@ * @version $Id: $Id */ public class StirredCellSolver extends TwoPhasePipeFlowSolver - implements neqsim.thermo.ThermodynamicConstantsInterface { - private static final long serialVersionUID = 1000; - Matrix diffMatrix; - double dn[][]; - int iter = 0; - Matrix[] diff4Matrix; - double xNew[][][]; - protected double oldMass[][]; - protected double oldComp[][]; - protected double oldDensity[][]; - protected double oldVelocity[][]; - protected double oldComposition[][][]; - protected double oldInternalEnergy[][]; - protected double oldImpuls[][]; - protected double oldEnergy[][]; - - /** - *

- * Constructor for StirredCellSolver. - *

- */ - public StirredCellSolver() {} - - /** - *

- * Constructor for StirredCellSolver. - *

- * - * @param pipe a {@link neqsim.fluidMechanics.flowSystem.FlowSystemInterface} object - * @param length a double - * @param nodes a int - */ - public StirredCellSolver(FlowSystemInterface pipe, double length, int nodes) { - super(pipe, length, nodes); + implements neqsim.thermo.ThermodynamicConstantsInterface { + private static final long serialVersionUID = 1000; + Matrix diffMatrix; + double dn[][]; + int iter = 0; + Matrix[] diff4Matrix; + double xNew[][][]; + protected double oldMass[][]; + protected double oldComp[][]; + protected double oldDensity[][]; + protected double oldVelocity[][]; + protected double oldComposition[][][]; + protected double oldInternalEnergy[][]; + protected double oldImpuls[][]; + protected double oldEnergy[][]; + + /** + *

+ * Constructor for StirredCellSolver. + *

+ */ + public StirredCellSolver() {} + + /** + *

+ * Constructor for StirredCellSolver. + *

+ * + * @param pipe a {@link neqsim.fluidMechanics.flowSystem.FlowSystemInterface} object + * @param length a double + * @param nodes a int + */ + public StirredCellSolver(FlowSystemInterface pipe, double length, int nodes) { + super(pipe, length, nodes); + } + + /** + *

+ * Constructor for StirredCellSolver. + *

+ * + * @param pipe a {@link neqsim.fluidMechanics.flowSystem.FlowSystemInterface} object + * @param length a double + * @param nodes a int + * @param dynamic a boolean + */ + public StirredCellSolver(FlowSystemInterface pipe, double length, int nodes, boolean dynamic) { + super(pipe, length, nodes); + this.dynamic = dynamic; + oldMass = new double[2][nodes]; + oldComp = new double[2][nodes]; + oldImpuls = new double[2][nodes]; + diff4Matrix = + new Matrix[pipe.getNode(0).getBulkSystem().getPhases()[0].getNumberOfComponents()]; + oldEnergy = new double[2][nodes]; + oldVelocity = new double[2][nodes]; + oldDensity = new double[2][nodes]; + oldInternalEnergy = new double[2][nodes]; + oldComposition = new double[2][pipe.getNode(0).getBulkSystem().getPhases()[0] + .getNumberOfComponents()][nodes]; + numberOfVelocityNodes = nodes; + } + + /** {@inheritDoc} */ + @Override + public TwoPhaseFixedStaggeredGridSolver clone() { + TwoPhaseFixedStaggeredGridSolver clonedSystem = null; + try { + clonedSystem = (TwoPhaseFixedStaggeredGridSolver) super.clone(); + } catch (Exception e) { + e.printStackTrace(System.err); } - - /** - *

- * Constructor for StirredCellSolver. - *

- * - * @param pipe a {@link neqsim.fluidMechanics.flowSystem.FlowSystemInterface} object - * @param length a double - * @param nodes a int - * @param dynamic a boolean - */ - public StirredCellSolver(FlowSystemInterface pipe, double length, int nodes, boolean dynamic) { - super(pipe, length, nodes); - this.dynamic = dynamic; - oldMass = new double[2][nodes]; - oldComp = new double[2][nodes]; - oldImpuls = new double[2][nodes]; - diff4Matrix = - new Matrix[pipe.getNode(0).getBulkSystem().getPhases()[0].getNumberOfComponents()]; - oldEnergy = new double[2][nodes]; - oldVelocity = new double[2][nodes]; - oldDensity = new double[2][nodes]; - oldInternalEnergy = new double[2][nodes]; - oldComposition = new double[2][pipe.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents()][nodes]; - numberOfVelocityNodes = nodes; + return clonedSystem; + } + + /** + *

+ * initProfiles. + *

+ */ + public void initProfiles() { + SystemInterface tempSyst = pipe.getNode(0).getBulkSystem().clone(); + ThermodynamicOperations testOps = new ThermodynamicOperations(tempSyst); + testOps.TPflash(); + testOps.displayResult(); + + double[][][] molDiff = + new double[numberOfNodes][2][pipe.getNode(0).getBulkSystem().getPhases()[0] + .getNumberOfComponents()]; + pipe.getNode(0).init(); + pipe.getNode(0).calcFluxes(); + + for (int i = 1; i < numberOfNodes - 1; i++) { + pipe.getNode(i).init(); + pipe.getNode(i).calcFluxes(); + + for (int componentNumber = 0; componentNumber < pipe.getNode(0).getBulkSystem().getPhases()[0] + .getNumberOfComponents(); componentNumber++) { + double liquidMolarRate = + pipe.getNode(i).getFluidBoundary().getInterphaseMolarFlux(componentNumber) + * pipe.getNode(i).getInterphaseContactLength(0) + * pipe.getNode(i).getGeometry().getNodeLength(); + double gasMolarRate = + -pipe.getNode(i).getFluidBoundary().getInterphaseMolarFlux(componentNumber) + * pipe.getNode(i).getInterphaseContactLength(0) + * pipe.getNode(i).getGeometry().getNodeLength(); + double liquidHeatRate = pipe.getNode(i).getFluidBoundary().getInterphaseHeatFlux(1) + * pipe.getNode(i).getInterphaseContactLength(0) + * pipe.getNode(i).getGeometry().getNodeLength(); + double gasHeatRate = -pipe.getNode(i).getFluidBoundary().getInterphaseHeatFlux(0) + * pipe.getNode(i).getInterphaseContactLength(0) + * pipe.getNode(i).getGeometry().getNodeLength(); + + double liquid_dT = -liquidHeatRate / pipe.getNode(i).getBulkSystem().getPhase(1).getCp(); + double gas_dT = gasHeatRate / pipe.getNode(i).getBulkSystem().getPhase(0).getCp(); + + molDiff[i][0][componentNumber] = molDiff[i - 1][0][componentNumber] + gasMolarRate; + molDiff[i][1][componentNumber] = molDiff[i - 1][1][componentNumber] + liquidMolarRate; + + pipe.getNode(i + 1).getBulkSystem().getPhases()[0].addMoles(componentNumber, + molDiff[i][0][componentNumber]); + pipe.getNode(i + 1).getBulkSystem().getPhases()[1].addMoles(componentNumber, + molDiff[i][1][componentNumber]); + + pipe.getNode(i + 1).getBulkSystem().getPhase(0) + .setTemperature(pipe.getNode(i).getBulkSystem().getPhase(0).getTemperature() + gas_dT); + pipe.getNode(i + 1).getBulkSystem().getPhase(1).setTemperature( + pipe.getNode(i).getBulkSystem().getPhase(1).getTemperature() + liquid_dT); + } + + pipe.getNode(i + 1).getBulkSystem().initBeta(); + pipe.getNode(i + 1).getBulkSystem().init_x_y(); + pipe.getNode(i + 1).initFlowCalc(); + + System.out.println( + "x " + pipe.getNode(i - 1).getBulkSystem().getPhases()[1].getComponents()[0].getx()); + System.out.println( + "x " + pipe.getNode(i - 1).getBulkSystem().getPhases()[1].getComponents()[1].getx()); + System.out.println( + "y " + pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getComponents()[0].getx()); + System.out.println( + "y " + pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getComponents()[1].getx()); } - - /** {@inheritDoc} */ - @Override - public TwoPhaseFixedStaggeredGridSolver clone() { - TwoPhaseFixedStaggeredGridSolver clonedSystem = null; - try { - clonedSystem = (TwoPhaseFixedStaggeredGridSolver) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); + pipe.getNode(numberOfNodes - 1).init(); + pipe.getNode(numberOfNodes - 1).calcFluxes(); + this.initNodes(); + System.out.println("finisched initializing...."); + } + + /** + *

+ * initMatrix. + *

+ */ + public void initMatrix() { + for (int i = 0; i < numberOfNodes; i++) { + pipe.getNode(i).init(); + double enthalpy0 = pipe.getNode(i).getBulkSystem().getPhases()[0].getEnthalpy() + / pipe.getNode(i).getBulkSystem().getPhases()[0].getNumberOfMolesInPhase() + / pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass(); + double enthalpy1 = pipe.getNode(i).getBulkSystem().getPhases()[1].getEnthalpy() + / pipe.getNode(i).getBulkSystem().getPhases()[1].getNumberOfMolesInPhase() + / pipe.getNode(i).getBulkSystem().getPhases()[1].getMolarMass(); + + solMatrix[0].set(i, 0, pipe.getNode(i).getVelocityIn(0).doubleValue()); + solMatrix[1].set(i, 0, pipe.getNode(i).getVelocityIn(1).doubleValue()); + + sol3Matrix[0].set(i, 0, enthalpy0); + sol3Matrix[1].set(i, 0, enthalpy1); + + solPhaseConsMatrix[0].set(i, 0, + pipe.getNode(i).getBulkSystem().getPhases()[0].getPhysicalProperties().getDensity()); + solPhaseConsMatrix[1].set(i, 0, pipe.getNode(i).getPhaseFraction(1)); + + for (int phase = 0; phase < 2; phase++) { + for (int j = 0; j < pipe.getNode(i).getBulkSystem().getPhases()[0] + .getNumberOfComponents(); j++) { + solMolFracMatrix[phase][j].set(i, 0, + pipe.getNode(i).getBulkSystem().getPhases()[phase].getComponents()[j].getx() + * pipe.getNode(i).getBulkSystem().getPhases()[phase].getComponents()[j] + .getMolarMass() + / pipe.getNode(i).getBulkSystem().getPhases()[phase].getMolarMass()); } - return clonedSystem; + } } - - /** - *

- * initProfiles. - *

- */ - public void initProfiles() { - SystemInterface tempSyst = pipe.getNode(0).getBulkSystem().clone(); - ThermodynamicOperations testOps = new ThermodynamicOperations(tempSyst); - testOps.TPflash(); - testOps.displayResult(); - - double[][][] molDiff = - new double[numberOfNodes][2][pipe.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents()]; - pipe.getNode(0).init(); - pipe.getNode(0).calcFluxes(); - - for (int i = 1; i < numberOfNodes - 1; i++) { - pipe.getNode(i).init(); - pipe.getNode(i).calcFluxes(); - - for (int componentNumber = - 0; componentNumber < pipe.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents(); componentNumber++) { - double liquidMolarRate = - pipe.getNode(i).getFluidBoundary().getInterphaseMolarFlux(componentNumber) - * pipe.getNode(i).getInterphaseContactLength(0) - * pipe.getNode(i).getGeometry().getNodeLength(); - double gasMolarRate = - -pipe.getNode(i).getFluidBoundary().getInterphaseMolarFlux(componentNumber) - * pipe.getNode(i).getInterphaseContactLength(0) - * pipe.getNode(i).getGeometry().getNodeLength(); - double liquidHeatRate = pipe.getNode(i).getFluidBoundary().getInterphaseHeatFlux(1) - * pipe.getNode(i).getInterphaseContactLength(0) - * pipe.getNode(i).getGeometry().getNodeLength(); - double gasHeatRate = -pipe.getNode(i).getFluidBoundary().getInterphaseHeatFlux(0) - * pipe.getNode(i).getInterphaseContactLength(0) - * pipe.getNode(i).getGeometry().getNodeLength(); - - double liquid_dT = - -liquidHeatRate / pipe.getNode(i).getBulkSystem().getPhase(1).getCp(); - double gas_dT = gasHeatRate / pipe.getNode(i).getBulkSystem().getPhase(0).getCp(); - - molDiff[i][0][componentNumber] = molDiff[i - 1][0][componentNumber] + gasMolarRate; - molDiff[i][1][componentNumber] = - molDiff[i - 1][1][componentNumber] + liquidMolarRate; - - pipe.getNode(i + 1).getBulkSystem().getPhases()[0].addMoles(componentNumber, - molDiff[i][0][componentNumber]); - pipe.getNode(i + 1).getBulkSystem().getPhases()[1].addMoles(componentNumber, - molDiff[i][1][componentNumber]); - - pipe.getNode(i + 1).getBulkSystem().getPhase(0).setTemperature( - pipe.getNode(i).getBulkSystem().getPhase(0).getTemperature() + gas_dT); - pipe.getNode(i + 1).getBulkSystem().getPhase(1).setTemperature( - pipe.getNode(i).getBulkSystem().getPhase(1).getTemperature() + liquid_dT); - } - - pipe.getNode(i + 1).getBulkSystem().initBeta(); - pipe.getNode(i + 1).getBulkSystem().init_x_y(); - pipe.getNode(i + 1).initFlowCalc(); - - System.out.println("x " - + pipe.getNode(i - 1).getBulkSystem().getPhases()[1].getComponents()[0].getx()); - System.out.println("x " - + pipe.getNode(i - 1).getBulkSystem().getPhases()[1].getComponents()[1].getx()); - System.out.println("y " - + pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getComponents()[0].getx()); - System.out.println("y " - + pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getComponents()[1].getx()); - } - pipe.getNode(numberOfNodes - 1).init(); - pipe.getNode(numberOfNodes - 1).calcFluxes(); - this.initNodes(); - System.out.println("finisched initializing...."); + } + + /** + *

+ * initPressure. + *

+ * + * @param phase a int + */ + public void initPressure(int phase) { + for (int i = 0; i < numberOfNodes; i++) { + pipe.getNode(i).init(); + pipe.getNode(i).getBulkSystem() + .setPressure(0.8 * pipe.getNode(i).getBulkSystem().getPhases()[phase].getdPdrho() + * diffMatrix.get(i, 0) * 1e-5 + pipe.getNode(i).getBulkSystem().getPressure()); + pipe.getNode(i).init(); } - - /** - *

- * initMatrix. - *

- */ - public void initMatrix() { - for (int i = 0; i < numberOfNodes; i++) { - pipe.getNode(i).init(); - double enthalpy0 = pipe.getNode(i).getBulkSystem().getPhases()[0].getEnthalpy() - / pipe.getNode(i).getBulkSystem().getPhases()[0].getNumberOfMolesInPhase() - / pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass(); - double enthalpy1 = pipe.getNode(i).getBulkSystem().getPhases()[1].getEnthalpy() - / pipe.getNode(i).getBulkSystem().getPhases()[1].getNumberOfMolesInPhase() - / pipe.getNode(i).getBulkSystem().getPhases()[1].getMolarMass(); - - solMatrix[0].set(i, 0, pipe.getNode(i).getVelocityIn(0).doubleValue()); - solMatrix[1].set(i, 0, pipe.getNode(i).getVelocityIn(1).doubleValue()); - - sol3Matrix[0].set(i, 0, enthalpy0); - sol3Matrix[1].set(i, 0, enthalpy1); - - solPhaseConsMatrix[0].set(i, 0, pipe.getNode(i).getBulkSystem().getPhases()[0] - .getPhysicalProperties().getDensity()); - solPhaseConsMatrix[1].set(i, 0, pipe.getNode(i).getPhaseFraction(1)); - - for (int phase = 0; phase < 2; phase++) { - for (int j = 0; j < pipe.getNode(i).getBulkSystem().getPhases()[0] - .getNumberOfComponents(); j++) { - solMolFracMatrix[phase][j].set(i, 0, - pipe.getNode(i).getBulkSystem().getPhases()[phase].getComponents()[j] - .getx() - * pipe.getNode(i).getBulkSystem().getPhases()[phase] - .getComponents()[j].getMolarMass() - / pipe.getNode(i).getBulkSystem().getPhases()[phase] - .getMolarMass()); - } - } - } + } + + /** + *

+ * initVelocity. + *

+ * + * @param phase a int + */ + public void initVelocity(int phase) { + for (int i = 0; i < numberOfNodes; i++) { + pipe.getNode(i).setVelocityIn(phase, pipe.getNode(i).getVelocityIn(phase).doubleValue() + 0.8 + * (solMatrix[phase].get(i, 0) - pipe.getNode(i).getVelocityIn(phase).doubleValue())); } - /** - *

- * initPressure. - *

- * - * @param phase a int - */ - public void initPressure(int phase) { - for (int i = 0; i < numberOfNodes; i++) { - pipe.getNode(i).init(); - pipe.getNode(i).getBulkSystem().setPressure( - 0.8 * pipe.getNode(i).getBulkSystem().getPhases()[phase].getdPdrho() - * diffMatrix.get(i, 0) * 1e-5 - + pipe.getNode(i).getBulkSystem().getPressure()); - pipe.getNode(i).init(); - } + for (int i = 0; i < numberOfNodes; i++) { + double meanVelocity = pipe.getNode(i).getVelocityIn(phase).doubleValue(); + pipe.getNode(i).setVelocity(phase, meanVelocity); + pipe.getNode(i).init(); } - - /** - *

- * initVelocity. - *

- * - * @param phase a int - */ - public void initVelocity(int phase) { - for (int i = 0; i < numberOfNodes; i++) { - pipe.getNode(i).setVelocityIn(phase, - pipe.getNode(i).getVelocityIn(phase).doubleValue() - + 0.8 * (solMatrix[phase].get(i, 0) - - pipe.getNode(i).getVelocityIn(phase).doubleValue())); - } - - for (int i = 0; i < numberOfNodes; i++) { - double meanVelocity = pipe.getNode(i).getVelocityIn(phase).doubleValue(); - pipe.getNode(i).setVelocity(phase, meanVelocity); - pipe.getNode(i).init(); - } + } + + /** + *

+ * initTemperature. + *

+ * + * @param phase a int + */ + public void initTemperature(int phase) { + for (int i = 0; i < numberOfNodes; i++) { + pipe.getNode(i).init(); + pipe.getNode(i).getBulkSystem().setTemperature(pipe.getNode(i).getBulkSystem() + .getTemperature(phase) + + 0.8 * diffMatrix.get(i, 0) / (pipe.getNode(i).getBulkSystem().getPhases()[phase].getCp() + / pipe.getNode(i).getBulkSystem().getPhases()[phase].getNumberOfMolesInPhase() + / pipe.getNode(i).getBulkSystem().getPhases()[phase].getMolarMass()), + phase); + pipe.getNode(i).init(); } - - /** - *

- * initTemperature. - *

- * - * @param phase a int - */ - public void initTemperature(int phase) { - for (int i = 0; i < numberOfNodes; i++) { - pipe.getNode(i).init(); - pipe.getNode(i).getBulkSystem() - .setTemperature(pipe.getNode(i).getBulkSystem().getTemperature(phase) - + 0.8 * diffMatrix.get(i, 0) - / (pipe.getNode(i).getBulkSystem().getPhases()[phase].getCp() - / pipe.getNode(i).getBulkSystem().getPhases()[phase] - .getNumberOfMolesInPhase() - / pipe.getNode(i).getBulkSystem().getPhases()[phase] - .getMolarMass()), - phase); - pipe.getNode(i).init(); - } + } + + /** + *

+ * initPhaseFraction. + *

+ * + * @param phase a int + */ + public void initPhaseFraction(int phase) { + for (int i = 0; i < numberOfNodes; i++) { + pipe.getNode(i).setPhaseFraction(phase, + pipe.getNode(i).getPhaseFraction(phase) + 0.8 * diffMatrix.get(i, 0)); + pipe.getNode(i).setPhaseFraction(0, 1.0 - pipe.getNode(i).getPhaseFraction(phase)); + pipe.getNode(i).init(); } - - /** - *

- * initPhaseFraction. - *

- * - * @param phase a int - */ - public void initPhaseFraction(int phase) { - for (int i = 0; i < numberOfNodes; i++) { - pipe.getNode(i).setPhaseFraction(phase, - pipe.getNode(i).getPhaseFraction(phase) + 0.8 * diffMatrix.get(i, 0)); - pipe.getNode(i).setPhaseFraction(0, 1.0 - pipe.getNode(i).getPhaseFraction(phase)); - pipe.getNode(i).init(); - } - } - - /** - *

- * initComposition. - *

- * - * @param phase a int - * @param comp a int - */ - public void initComposition(int phase, int comp) { - for (int j = 0; j < numberOfNodes; j++) { - if ((pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp].getx() - + diffMatrix.get(j, 0) - * pipe.getNode(j).getBulkSystem().getPhases()[phase].getMolarMass() - / pipe.getNode(j).getBulkSystem().getPhases()[phase] - .getComponents()[comp].getMolarMass()) > 1.0) { - pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp] - .setx(1.0 - 1e-30); - } else if (pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp] - .getx() - + diffMatrix.get(j, 0) - * pipe.getNode(j).getBulkSystem().getPhases()[phase].getMolarMass() - / pipe.getNode(j).getBulkSystem().getPhases()[phase] - .getComponents()[comp].getMolarMass() < 0.0) { - pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp] - .setx(1e-30); - } else { - pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp].setx( - pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp] - .getx() - + diffMatrix.get(j, 0) - * pipe.getNode(j).getBulkSystem().getPhases()[phase] - .getMolarMass() - / pipe.getNode(j).getBulkSystem().getPhases()[phase] - .getComponents()[comp].getMolarMass());// pipe.getNode(j).getBulkSystem().getPhases()[0].getComponents()[p].getx() - // + - // 0.5*diff4Matrix[p].get(j,0)); - } - - double xSum = 0.0; - for (int i = 0; i < pipe.getNode(j).getBulkSystem().getPhases()[phase] - .getNumberOfComponents() - 1; i++) { - xSum += pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[i] - .getx(); - } - - pipe.getNode(j).getBulkSystem().getPhases()[phase] - .getComponents()[pipe.getNode(j).getBulkSystem().getPhases()[phase] - .getNumberOfComponents() - 1].setx(1.0 - xSum); - pipe.getNode(j).init(); - } + } + + /** + *

+ * initComposition. + *

+ * + * @param phase a int + * @param comp a int + */ + public void initComposition(int phase, int comp) { + for (int j = 0; j < numberOfNodes; j++) { + if ((pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp].getx() + + diffMatrix.get(j, 0) * pipe.getNode(j).getBulkSystem().getPhases()[phase].getMolarMass() + / pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp] + .getMolarMass()) > 1.0) { + pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp].setx(1.0 - 1e-30); + } else if (pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp].getx() + + diffMatrix.get(j, 0) * pipe.getNode(j).getBulkSystem().getPhases()[phase].getMolarMass() + / pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp] + .getMolarMass() < 0.0) { + pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp].setx(1e-30); + } else { + pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp] + .setx(pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp].getx() + + diffMatrix.get(j, 0) + * pipe.getNode(j).getBulkSystem().getPhases()[phase].getMolarMass() + / pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp] + .getMolarMass()); // pipe.getNode(j).getBulkSystem().getPhases()[0].getComponents()[p].getx() + // + + // 0.5*diff4Matrix[p].get(j,0)); + } + + double xSum = 0.0; + for (int i = 0; i < pipe.getNode(j).getBulkSystem().getPhases()[phase].getNumberOfComponents() + - 1; i++) { + xSum += pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[i].getx(); + } + + pipe.getNode(j).getBulkSystem().getPhases()[phase] + .getComponents()[pipe.getNode(j).getBulkSystem().getPhases()[phase] + .getNumberOfComponents() - 1].setx(1.0 - xSum); + pipe.getNode(j).init(); } - - /** - *

- * initFinalResults. - *

- * - * @param phase a int - */ - public void initFinalResults(int phase) { - for (int i = 0; i < numberOfNodes; i++) { - oldVelocity[phase][i] = pipe.getNode(i).getVelocityIn().doubleValue(); - oldDensity[phase][i] = pipe.getNode(i).getBulkSystem().getPhases()[0] - .getPhysicalProperties().getDensity(); - oldInternalEnergy[phase][i] = - pipe.getNode(i).getBulkSystem().getPhases()[0].getEnthalpy() - / pipe.getNode(i).getBulkSystem().getPhases()[0] - .getNumberOfMolesInPhase() - / pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass(); - - for (int j = 0; j < pipe.getNode(i).getBulkSystem().getPhases()[0] - .getNumberOfComponents(); j++) { - oldComposition[phase][j][i] = xNew[phase][j][i]; - } - } + } + + /** + *

+ * initFinalResults. + *

+ * + * @param phase a int + */ + public void initFinalResults(int phase) { + for (int i = 0; i < numberOfNodes; i++) { + oldVelocity[phase][i] = pipe.getNode(i).getVelocityIn().doubleValue(); + oldDensity[phase][i] = + pipe.getNode(i).getBulkSystem().getPhases()[0].getPhysicalProperties().getDensity(); + oldInternalEnergy[phase][i] = pipe.getNode(i).getBulkSystem().getPhases()[0].getEnthalpy() + / pipe.getNode(i).getBulkSystem().getPhases()[0].getNumberOfMolesInPhase() + / pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass(); + + for (int j = 0; j < pipe.getNode(i).getBulkSystem().getPhases()[0] + .getNumberOfComponents(); j++) { + oldComposition[phase][j][i] = xNew[phase][j][i]; + } } - - /** - *

- * calcFluxes. - *

- */ - public void calcFluxes() { - for (int i = 0; i < numberOfNodes; i++) { - pipe.getNode(i).calcFluxes(); - } + } + + /** + *

+ * calcFluxes. + *

+ */ + public void calcFluxes() { + for (int i = 0; i < numberOfNodes; i++) { + pipe.getNode(i).calcFluxes(); } - - /** - *

- * initNodes. - *

- */ - public void initNodes() { - for (int i = 0; i < numberOfNodes; i++) { - pipe.getNode(i).init(); - } + } + + /** + *

+ * initNodes. + *

+ */ + public void initNodes() { + for (int i = 0; i < numberOfNodes; i++) { + pipe.getNode(i).init(); } + } - /** {@inheritDoc} */ - @Override - public void solveTDMA() { - initProfiles(); - } + /** {@inheritDoc} */ + @Override + public void solveTDMA() { + initProfiles(); + } } diff --git a/src/main/java/neqsim/fluidMechanics/flowSolver/twoPhaseFlowSolver/twoPhasePipeFlowSolver/TwoPhaseFixedStaggeredGridSolver.java b/src/main/java/neqsim/fluidMechanics/flowSolver/twoPhaseFlowSolver/twoPhasePipeFlowSolver/TwoPhaseFixedStaggeredGridSolver.java index e1da6a8cd3..91d81bd80d 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSolver/twoPhaseFlowSolver/twoPhasePipeFlowSolver/TwoPhaseFixedStaggeredGridSolver.java +++ b/src/main/java/neqsim/fluidMechanics/flowSolver/twoPhaseFlowSolver/twoPhasePipeFlowSolver/TwoPhaseFixedStaggeredGridSolver.java @@ -13,1164 +13,1126 @@ * @version $Id: $Id */ public class TwoPhaseFixedStaggeredGridSolver extends TwoPhasePipeFlowSolver - implements neqsim.thermo.ThermodynamicConstantsInterface { - private static final long serialVersionUID = 1000; - Matrix diffMatrix; - double dn[][]; - int iter = 0; - Matrix[] diff4Matrix; - double xNew[][][]; - protected double oldMass[][]; - protected double oldComp[][]; - protected double oldDensity[][]; - protected double oldVelocity[][]; - protected double oldComposition[][][]; - protected double oldInternalEnergy[][]; - protected double oldImpuls[][]; - protected double oldEnergy[][]; - - /** - *

- * Constructor for TwoPhaseFixedStaggeredGridSolver. - *

- */ - public TwoPhaseFixedStaggeredGridSolver() {} - - /** - *

- * Constructor for TwoPhaseFixedStaggeredGridSolver. - *

- * - * @param pipe a {@link neqsim.fluidMechanics.flowSystem.FlowSystemInterface} object - * @param length a double - * @param nodes a int - */ - public TwoPhaseFixedStaggeredGridSolver(FlowSystemInterface pipe, double length, int nodes) { - super(pipe, length, nodes); - } - - /** - *

- * Constructor for TwoPhaseFixedStaggeredGridSolver. - *

- * - * @param pipe a {@link neqsim.fluidMechanics.flowSystem.FlowSystemInterface} object - * @param length a double - * @param nodes a int - * @param dynamic a boolean - */ - public TwoPhaseFixedStaggeredGridSolver(FlowSystemInterface pipe, double length, int nodes, - boolean dynamic) { - super(pipe, length, nodes); - this.dynamic = dynamic; - oldMass = new double[2][nodes]; - oldComp = new double[2][nodes]; - oldImpuls = new double[2][nodes]; - diff4Matrix = - new Matrix[pipe.getNode(0).getBulkSystem().getPhases()[0].getNumberOfComponents()]; - oldEnergy = new double[2][nodes]; - oldVelocity = new double[2][nodes]; - oldDensity = new double[2][nodes]; - oldInternalEnergy = new double[2][nodes]; - oldComposition = new double[2][pipe.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents()][nodes]; - numberOfVelocityNodes = nodes; + implements neqsim.thermo.ThermodynamicConstantsInterface { + private static final long serialVersionUID = 1000; + Matrix diffMatrix; + double dn[][]; + int iter = 0; + Matrix[] diff4Matrix; + double[][][] xNew; + protected double oldMass[][]; + protected double oldComp[][]; + protected double oldDensity[][]; + protected double oldVelocity[][]; + protected double[][][] oldComposition; + protected double oldInternalEnergy[][]; + protected double oldImpuls[][]; + protected double oldEnergy[][]; + + /** + *

+ * Constructor for TwoPhaseFixedStaggeredGridSolver. + *

+ */ + public TwoPhaseFixedStaggeredGridSolver() {} + + /** + *

+ * Constructor for TwoPhaseFixedStaggeredGridSolver. + *

+ * + * @param pipe a {@link neqsim.fluidMechanics.flowSystem.FlowSystemInterface} object + * @param length a double + * @param nodes a int + */ + public TwoPhaseFixedStaggeredGridSolver(FlowSystemInterface pipe, double length, int nodes) { + super(pipe, length, nodes); + } + + /** + *

+ * Constructor for TwoPhaseFixedStaggeredGridSolver. + *

+ * + * @param pipe a {@link neqsim.fluidMechanics.flowSystem.FlowSystemInterface} object + * @param length a double + * @param nodes a int + * @param dynamic a boolean + */ + public TwoPhaseFixedStaggeredGridSolver(FlowSystemInterface pipe, double length, int nodes, + boolean dynamic) { + super(pipe, length, nodes); + this.dynamic = dynamic; + oldMass = new double[2][nodes]; + oldComp = new double[2][nodes]; + oldImpuls = new double[2][nodes]; + diff4Matrix = + new Matrix[pipe.getNode(0).getBulkSystem().getPhases()[0].getNumberOfComponents()]; + oldEnergy = new double[2][nodes]; + oldVelocity = new double[2][nodes]; + oldDensity = new double[2][nodes]; + oldInternalEnergy = new double[2][nodes]; + oldComposition = new double[2][pipe.getNode(0).getBulkSystem().getPhases()[0] + .getNumberOfComponents()][nodes]; + numberOfVelocityNodes = nodes; + } + + /** {@inheritDoc} */ + @Override + public TwoPhaseFixedStaggeredGridSolver clone() { + TwoPhaseFixedStaggeredGridSolver clonedSystem = null; + try { + clonedSystem = (TwoPhaseFixedStaggeredGridSolver) super.clone(); + } catch (Exception e) { + e.printStackTrace(System.err); } - - /** {@inheritDoc} */ - @Override - public TwoPhaseFixedStaggeredGridSolver clone() { - TwoPhaseFixedStaggeredGridSolver clonedSystem = null; - try { - clonedSystem = (TwoPhaseFixedStaggeredGridSolver) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); - } - return clonedSystem; + return clonedSystem; + } + + /** + *

+ * initProfiles. + *

+ */ + public void initProfiles() { + // double err = 0, oldPres = 0, oldTemp = 0, dpdx = 0; + + double[][][] molDiff = + new double[numberOfNodes][2][pipe.getNode(0).getBulkSystem().getPhases()[0] + .getNumberOfComponents()]; + pipe.getNode(0).getBulkSystem().initBeta(); + pipe.getNode(0).getBulkSystem().init_x_y(); + pipe.getNode(0).initFlowCalc(); + pipe.getNode(0).calcFluxes(); + + for (int i = 1; i < numberOfNodes - 1; i++) { + pipe.getNode(i).getBulkSystem().initBeta(); + pipe.getNode(i).getBulkSystem().init_x_y(); + pipe.getNode(i).initFlowCalc(); + pipe.getNode(i).calcFluxes(); + + double liquidHeatRate = pipe.getNode(i).getFluidBoundary().getInterphaseHeatFlux(1) + * pipe.getNode(i).getInterphaseContactArea() + * (pipe.getNode(i).getGeometry().getNodeLength() / pipe.getNode(i).getVelocity(1)); + double gasHeatRate = -pipe.getNode(i).getFluidBoundary().getInterphaseHeatFlux(0) + * pipe.getNode(i).getInterphaseContactArea() + * (pipe.getNode(i).getGeometry().getNodeLength() / pipe.getNode(i).getVelocity(0)); + + double liquid_dT = liquidHeatRate / pipe.getNode(i).getBulkSystem().getPhase(1).getCp(); + double gas_dT = gasHeatRate / pipe.getNode(i).getBulkSystem().getPhase(0).getCp(); + + pipe.getNode(i + 1).getBulkSystem().getPhase(0) + .setTemperature(pipe.getNode(i).getBulkSystem().getPhase(0).getTemperature() + gas_dT); + pipe.getNode(i + 1).getBulkSystem().getPhase(1) + .setTemperature(pipe.getNode(i).getBulkSystem().getPhase(1).getTemperature() + liquid_dT); + + for (int componentNumber = 0; componentNumber < pipe.getNode(0).getBulkSystem().getPhases()[0] + .getNumberOfComponents(); componentNumber++) { + double liquidMolarRate = + pipe.getNode(i).getFluidBoundary().getInterphaseMolarFlux(componentNumber) + * pipe.getNode(i).getInterphaseContactArea() + * (pipe.getNode(i).getGeometry().getNodeLength() / pipe.getNode(i).getVelocity(1)); + double gasMolarRate = + -pipe.getNode(i).getFluidBoundary().getInterphaseMolarFlux(componentNumber) + * pipe.getNode(i).getInterphaseContactArea() + * (pipe.getNode(i).getGeometry().getNodeLength() / pipe.getNode(i).getVelocity(0)); + + molDiff[i][0][componentNumber] = molDiff[i - 1][0][componentNumber] + gasMolarRate; + molDiff[i][1][componentNumber] = molDiff[i - 1][1][componentNumber] + liquidMolarRate; + + pipe.getNode(i + 1).getBulkSystem().getPhases()[0].addMoles(componentNumber, + molDiff[i - 1][0][componentNumber]); + pipe.getNode(i + 1).getBulkSystem().getPhases()[1].addMoles(componentNumber, + molDiff[i - 1][1][componentNumber]); + } } - - /** - *

- * initProfiles. - *

+ pipe.getNode(numberOfNodes - 1).init(); + pipe.getNode(numberOfNodes - 1).calcFluxes(); + pipe.getNode(numberOfNodes - 1).getBulkSystem().initBeta(); + pipe.getNode(numberOfNodes - 1).getBulkSystem().init_x_y(); + this.initNodes(); + System.out.println("finisched initializing...."); + + /* + * do{ err=0; pipe.getNode(0).init(); for(int i = 0;i1); + * initTemperatureMatrix(); */ - public void initProfiles() { - // double err = 0, oldPres = 0, oldTemp = 0, dpdx = 0; - - double[][][] molDiff = - new double[numberOfNodes][2][pipe.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents()]; - pipe.getNode(0).getBulkSystem().initBeta(); - pipe.getNode(0).getBulkSystem().init_x_y(); - pipe.getNode(0).initFlowCalc(); - pipe.getNode(0).calcFluxes(); - - for (int i = 1; i < numberOfNodes - 1; i++) { - pipe.getNode(i).getBulkSystem().initBeta(); - pipe.getNode(i).getBulkSystem().init_x_y(); - pipe.getNode(i).initFlowCalc(); - pipe.getNode(i).calcFluxes(); - - double liquidHeatRate = pipe.getNode(i).getFluidBoundary().getInterphaseHeatFlux(1) - * pipe.getNode(i).getInterphaseContactArea() - * (pipe.getNode(i).getGeometry().getNodeLength() - / pipe.getNode(i).getVelocity(1)); - double gasHeatRate = -pipe.getNode(i).getFluidBoundary().getInterphaseHeatFlux(0) - * pipe.getNode(i).getInterphaseContactArea() - * (pipe.getNode(i).getGeometry().getNodeLength() - / pipe.getNode(i).getVelocity(0)); - - double liquid_dT = liquidHeatRate / pipe.getNode(i).getBulkSystem().getPhase(1).getCp(); - double gas_dT = gasHeatRate / pipe.getNode(i).getBulkSystem().getPhase(0).getCp(); - - pipe.getNode(i + 1).getBulkSystem().getPhase(0).setTemperature( - pipe.getNode(i).getBulkSystem().getPhase(0).getTemperature() + gas_dT); - pipe.getNode(i + 1).getBulkSystem().getPhase(1).setTemperature( - pipe.getNode(i).getBulkSystem().getPhase(1).getTemperature() + liquid_dT); - - for (int componentNumber = - 0; componentNumber < pipe.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents(); componentNumber++) { - double liquidMolarRate = - pipe.getNode(i).getFluidBoundary().getInterphaseMolarFlux(componentNumber) - * pipe.getNode(i).getInterphaseContactArea() - * (pipe.getNode(i).getGeometry().getNodeLength() - / pipe.getNode(i).getVelocity(1)); - double gasMolarRate = - -pipe.getNode(i).getFluidBoundary().getInterphaseMolarFlux(componentNumber) - * pipe.getNode(i).getInterphaseContactArea() - * (pipe.getNode(i).getGeometry().getNodeLength() - / pipe.getNode(i).getVelocity(0)); - - molDiff[i][0][componentNumber] = molDiff[i - 1][0][componentNumber] + gasMolarRate; - molDiff[i][1][componentNumber] = - molDiff[i - 1][1][componentNumber] + liquidMolarRate; - - pipe.getNode(i + 1).getBulkSystem().getPhases()[0].addMoles(componentNumber, - molDiff[i - 1][0][componentNumber]); - pipe.getNode(i + 1).getBulkSystem().getPhases()[1].addMoles(componentNumber, - molDiff[i - 1][1][componentNumber]); - } + } + + /** + *

+ * initMatrix. + *

+ */ + public void initMatrix() { + for (int i = 0; i < numberOfNodes; i++) { + pipe.getNode(i).init(); + double enthalpy0 = pipe.getNode(i).getBulkSystem().getPhases()[0].getEnthalpy() + / pipe.getNode(i).getBulkSystem().getPhases()[0].getNumberOfMolesInPhase() + / pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass(); + double enthalpy1 = pipe.getNode(i).getBulkSystem().getPhases()[1].getEnthalpy() + / pipe.getNode(i).getBulkSystem().getPhases()[1].getNumberOfMolesInPhase() + / pipe.getNode(i).getBulkSystem().getPhases()[1].getMolarMass(); + + solMatrix[0].set(i, 0, pipe.getNode(i).getVelocityIn(0).doubleValue()); + solMatrix[1].set(i, 0, pipe.getNode(i).getVelocityIn(1).doubleValue()); + + sol3Matrix[0].set(i, 0, enthalpy0); + sol3Matrix[1].set(i, 0, enthalpy1); + + solPhaseConsMatrix[0].set(i, 0, + pipe.getNode(i).getBulkSystem().getPhases()[0].getPhysicalProperties().getDensity()); + solPhaseConsMatrix[1].set(i, 0, pipe.getNode(i).getPhaseFraction(1)); + + for (int phase = 0; phase < 2; phase++) { + for (int j = 0; j < pipe.getNode(i).getBulkSystem().getPhases()[0] + .getNumberOfComponents(); j++) { + solMolFracMatrix[phase][j].set(i, 0, + pipe.getNode(i).getBulkSystem().getPhases()[phase].getComponents()[j].getx() + * pipe.getNode(i).getBulkSystem().getPhases()[phase].getComponents()[j] + .getMolarMass() + / pipe.getNode(i).getBulkSystem().getPhases()[phase].getMolarMass()); } - pipe.getNode(numberOfNodes - 1).init(); - pipe.getNode(numberOfNodes - 1).calcFluxes(); - pipe.getNode(numberOfNodes - 1).getBulkSystem().initBeta(); - pipe.getNode(numberOfNodes - 1).getBulkSystem().init_x_y(); - this.initNodes(); - System.out.println("finisched initializing...."); - - /* - * do{ err=0; pipe.getNode(0).init(); for(int i = 0;i1); - * initTemperatureMatrix(); - */ + } } - - /** - *

- * initMatrix. - *

- */ - public void initMatrix() { - for (int i = 0; i < numberOfNodes; i++) { - pipe.getNode(i).init(); - double enthalpy0 = pipe.getNode(i).getBulkSystem().getPhases()[0].getEnthalpy() - / pipe.getNode(i).getBulkSystem().getPhases()[0].getNumberOfMolesInPhase() - / pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass(); - double enthalpy1 = pipe.getNode(i).getBulkSystem().getPhases()[1].getEnthalpy() - / pipe.getNode(i).getBulkSystem().getPhases()[1].getNumberOfMolesInPhase() - / pipe.getNode(i).getBulkSystem().getPhases()[1].getMolarMass(); - - solMatrix[0].set(i, 0, pipe.getNode(i).getVelocityIn(0).doubleValue()); - solMatrix[1].set(i, 0, pipe.getNode(i).getVelocityIn(1).doubleValue()); - - sol3Matrix[0].set(i, 0, enthalpy0); - sol3Matrix[1].set(i, 0, enthalpy1); - - solPhaseConsMatrix[0].set(i, 0, pipe.getNode(i).getBulkSystem().getPhases()[0] - .getPhysicalProperties().getDensity()); - solPhaseConsMatrix[1].set(i, 0, pipe.getNode(i).getPhaseFraction(1)); - - for (int phase = 0; phase < 2; phase++) { - for (int j = 0; j < pipe.getNode(i).getBulkSystem().getPhases()[0] - .getNumberOfComponents(); j++) { - solMolFracMatrix[phase][j].set(i, 0, - pipe.getNode(i).getBulkSystem().getPhases()[phase].getComponents()[j] - .getx() - * pipe.getNode(i).getBulkSystem().getPhases()[phase] - .getComponents()[j].getMolarMass() - / pipe.getNode(i).getBulkSystem().getPhases()[phase] - .getMolarMass()); - } - } - } + } + + /** + *

+ * initPressure. + *

+ * + * @param phase a int + */ + public void initPressure(int phase) { + for (int i = 0; i < numberOfNodes; i++) { + pipe.getNode(i).init(); + pipe.getNode(i).getBulkSystem() + .setPressure(0.8 * pipe.getNode(i).getBulkSystem().getPhases()[phase].getdPdrho() + * diffMatrix.get(i, 0) * 1e-5 + pipe.getNode(i).getBulkSystem().getPressure()); + pipe.getNode(i).init(); } - - /** - *

- * initPressure. - *

- * - * @param phase a int - */ - public void initPressure(int phase) { - for (int i = 0; i < numberOfNodes; i++) { - pipe.getNode(i).init(); - pipe.getNode(i).getBulkSystem().setPressure( - 0.8 * pipe.getNode(i).getBulkSystem().getPhases()[phase].getdPdrho() - * diffMatrix.get(i, 0) * 1e-5 - + pipe.getNode(i).getBulkSystem().getPressure()); - pipe.getNode(i).init(); - } + } + + /** + *

+ * initVelocity. + *

+ * + * @param phase a int + */ + public void initVelocity(int phase) { + for (int i = 0; i < numberOfNodes; i++) { + pipe.getNode(i).setVelocityIn(phase, pipe.getNode(i).getVelocityIn(phase).doubleValue() + 0.8 + * (solMatrix[phase].get(i, 0) - pipe.getNode(i).getVelocityIn(phase).doubleValue())); } - /** - *

- * initVelocity. - *

- * - * @param phase a int - */ - public void initVelocity(int phase) { - for (int i = 0; i < numberOfNodes; i++) { - pipe.getNode(i).setVelocityIn(phase, - pipe.getNode(i).getVelocityIn(phase).doubleValue() - + 0.8 * (solMatrix[phase].get(i, 0) - - pipe.getNode(i).getVelocityIn(phase).doubleValue())); - } - - for (int i = 0; i < numberOfNodes; i++) { - double meanVelocity = pipe.getNode(i).getVelocityIn(phase).doubleValue(); - pipe.getNode(i).setVelocity(phase, meanVelocity); - pipe.getNode(i).init(); - } + for (int i = 0; i < numberOfNodes; i++) { + double meanVelocity = pipe.getNode(i).getVelocityIn(phase).doubleValue(); + pipe.getNode(i).setVelocity(phase, meanVelocity); + pipe.getNode(i).init(); } - - /** - *

- * initTemperature. - *

- * - * @param phase a int - */ - public void initTemperature(int phase) { - for (int i = 0; i < numberOfNodes; i++) { - pipe.getNode(i).init(); - pipe.getNode(i).getBulkSystem() - .setTemperature(pipe.getNode(i).getBulkSystem().getTemperature(phase) - + 0.8 * diffMatrix.get(i, 0) - / (pipe.getNode(i).getBulkSystem().getPhases()[phase].getCp() - / pipe.getNode(i).getBulkSystem().getPhases()[phase] - .getNumberOfMolesInPhase() - / pipe.getNode(i).getBulkSystem().getPhases()[phase] - .getMolarMass()), - phase); - pipe.getNode(i).init(); - } + } + + /** + *

+ * initTemperature. + *

+ * + * @param phase a int + */ + public void initTemperature(int phase) { + for (int i = 0; i < numberOfNodes; i++) { + pipe.getNode(i).init(); + pipe.getNode(i).getBulkSystem().setTemperature(pipe.getNode(i).getBulkSystem() + .getTemperature(phase) + + 0.8 * diffMatrix.get(i, 0) / (pipe.getNode(i).getBulkSystem().getPhases()[phase].getCp() + / pipe.getNode(i).getBulkSystem().getPhases()[phase].getNumberOfMolesInPhase() + / pipe.getNode(i).getBulkSystem().getPhases()[phase].getMolarMass()), + phase); + pipe.getNode(i).init(); } - - /** - *

- * initPhaseFraction. - *

- * - * @param phase a int - */ - public void initPhaseFraction(int phase) { - for (int i = 0; i < numberOfNodes; i++) { - pipe.getNode(i).setPhaseFraction(phase, - pipe.getNode(i).getPhaseFraction(phase) + 0.8 * diffMatrix.get(i, 0)); - pipe.getNode(i).setPhaseFraction(0, 1.0 - pipe.getNode(i).getPhaseFraction(phase)); - pipe.getNode(i).init(); - } + } + + /** + *

+ * initPhaseFraction. + *

+ * + * @param phase a int + */ + public void initPhaseFraction(int phase) { + for (int i = 0; i < numberOfNodes; i++) { + pipe.getNode(i).setPhaseFraction(phase, + pipe.getNode(i).getPhaseFraction(phase) + 0.8 * diffMatrix.get(i, 0)); + pipe.getNode(i).setPhaseFraction(0, 1.0 - pipe.getNode(i).getPhaseFraction(phase)); + pipe.getNode(i).init(); } - - /** - *

- * initComposition. - *

- * - * @param phase a int - * @param comp a int - */ - public void initComposition(int phase, int comp) { - for (int j = 0; j < numberOfNodes; j++) { - if ((pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp].getx() - + diffMatrix.get(j, 0) - * pipe.getNode(j).getBulkSystem().getPhases()[phase].getMolarMass() - / pipe.getNode(j).getBulkSystem().getPhases()[phase] - .getComponents()[comp].getMolarMass()) > 1.0) { - pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp] - .setx(1.0 - 1e-30); - } else if (pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp] - .getx() - + diffMatrix.get(j, 0) - * pipe.getNode(j).getBulkSystem().getPhases()[phase].getMolarMass() - / pipe.getNode(j).getBulkSystem().getPhases()[phase] - .getComponents()[comp].getMolarMass() < 0.0) { - pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp] - .setx(1e-30); - } else { - pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp].setx( - pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp] - .getx() - + diffMatrix.get(j, 0) - * pipe.getNode(j).getBulkSystem().getPhases()[phase] - .getMolarMass() - / pipe.getNode(j).getBulkSystem().getPhases()[phase] - .getComponents()[comp].getMolarMass());// pipe.getNode(j).getBulkSystem().getPhases()[0].getComponents()[p].getx() - // + - // 0.5*diff4Matrix[p].get(j,0)); - } - - double xSum = 0.0; - for (int i = 0; i < pipe.getNode(j).getBulkSystem().getPhases()[phase] - .getNumberOfComponents() - 1; i++) { - xSum += pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[i] - .getx(); - } - - pipe.getNode(j).getBulkSystem().getPhases()[phase] - .getComponents()[pipe.getNode(j).getBulkSystem().getPhases()[phase] - .getNumberOfComponents() - 1].setx(1.0 - xSum); - pipe.getNode(j).init(); - } + } + + /** + *

+ * initComposition. + *

+ * + * @param phase a int + * @param comp a int + */ + public void initComposition(int phase, int comp) { + for (int j = 0; j < numberOfNodes; j++) { + if ((pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp].getx() + + diffMatrix.get(j, 0) * pipe.getNode(j).getBulkSystem().getPhases()[phase].getMolarMass() + / pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp] + .getMolarMass()) > 1.0) { + pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp].setx(1.0 - 1e-30); + } else if (pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp].getx() + + diffMatrix.get(j, 0) * pipe.getNode(j).getBulkSystem().getPhases()[phase].getMolarMass() + / pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp] + .getMolarMass() < 0.0) { + pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp].setx(1e-30); + } else { + pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp] + .setx(pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp].getx() + + diffMatrix.get(j, 0) + * pipe.getNode(j).getBulkSystem().getPhases()[phase].getMolarMass() + / pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[comp] + .getMolarMass()); // pipe.getNode(j).getBulkSystem().getPhases()[0].getComponents()[p].getx() + // + + // 0.5*diff4Matrix[p].get(j,0)); + } + + double xSum = 0.0; + for (int i = 0; i < pipe.getNode(j).getBulkSystem().getPhases()[phase].getNumberOfComponents() + - 1; i++) { + xSum += pipe.getNode(j).getBulkSystem().getPhases()[phase].getComponents()[i].getx(); + } + + pipe.getNode(j).getBulkSystem().getPhases()[phase] + .getComponents()[pipe.getNode(j).getBulkSystem().getPhases()[phase] + .getNumberOfComponents() - 1].setx(1.0 - xSum); + pipe.getNode(j).init(); } - - /** - *

- * setMassConservationMatrix. - *

- * - * @param phase a int - */ - public void setMassConservationMatrix(int phase) { - if (!dynamic) { - double SU = 0; - a[0] = 0; - b[0] = 1.0; - c[0] = 0; - SU = pipe.getNode(0).getBulkSystem().getPhases()[phase].getPhysicalProperties() - .getDensity(); - r[0] = SU; - } else { - // double Ae = pipe.getNode(0).getArea(phase); - // double Aw = pipe.getNode(0).getArea(phase); - // double Fw = pipe.getNode(0).getVelocityIn(phase).doubleValue() * Aw; - // double Fe = oldVelocity[phase][0] * Ae; - // System.out.println("new- old : " + - // (pipe.getNode(0).getVelocityIn().doubleValue() - oldVelocity[0])); - oldMass[phase][0] = 1.0 / timeStep * pipe.getNode(0).getGeometry().getArea() - * pipe.getNode(0).getGeometry().getNodeLength(); - - a[0] = 0.0;// Math.max(Fw,0); - c[0] = 1.0;// Math.max(-Fe,0); - b[0] = 1.0;// a[0] + c[0] + (Fe - Fw) + oldMass[0]; - r[0] = 0.0;// oldMass[0]*oldDensity[0]; - - // setter ligningen paa rett form - a[0] = -a[0]; - c[0] = -c[0]; - } - - for (int i = 1; i < numberOfNodes - 1; i++) { - double Ae = pipe.getNode(i).getArea(phase); - double Aw = pipe.getNode(i - 1).getArea(phase); - double Fe = pipe.getNode(i).getVelocityOut(phase).doubleValue() * Ae; - double Fw = pipe.getNode(i).getVelocityIn(phase).doubleValue() * Aw; - - if (dynamic) { - oldMass[phase][i] = 1.0 / timeStep * pipe.getNode(i).getArea(phase) - * pipe.getNode(i).getGeometry().getNodeLength(); - } else { - oldMass[phase][i] = 0.0; - } - - a[i] = Math.max(Fw, 0); - c[i] = Math.max(-Fe, 0); - b[i] = a[i] + c[i] + (Fe - Fw) + oldMass[phase][i]; - r[i] = oldMass[phase][i] * oldDensity[phase][i]; - - // setter ligningen paa rett form - a[i] = -a[i]; - c[i] = -c[i]; - } - - int i = numberOfNodes - 1; - // double Ae = pipe.getNode(i).getArea(phase); - // double Aw = pipe.getNode(i - 1).getArea(phase); - - // double Fe = pipe.getNode(i).getVelocity(phase) * Ae; - // double Fw = pipe.getNode(i).getVelocityIn(phase).doubleValue() * Aw; - - if (dynamic) { - oldMass[phase][i] = 1.0 / timeStep * pipe.getNode(i).getArea(phase) - * pipe.getNode(i).getGeometry().getNodeLength(); - } else { - oldMass[phase][i] = 0.0; - } - - a[i] = 1;// Math.max(Fw,0); - c[i] = 0;// Math.max(-Fe,0); - b[i] = 1;// a[i] + c[i] + (Fe - Fw) + oldMass[phase][i]; - r[i] = 0;// oldMass[phase][i]*oldDensity[phase][i]; - // setter ligningen paa rett form - a[i] = -a[i]; - c[i] = -c[i]; + } + + /** + *

+ * setMassConservationMatrix. + *

+ * + * @param phase a int + */ + public void setMassConservationMatrix(int phase) { + if (!dynamic) { + double SU = 0; + a[0] = 0; + b[0] = 1.0; + c[0] = 0; + SU = pipe.getNode(0).getBulkSystem().getPhases()[phase].getPhysicalProperties().getDensity(); + r[0] = SU; + } else { + // double Ae = pipe.getNode(0).getArea(phase); + // double Aw = pipe.getNode(0).getArea(phase); + // double Fw = pipe.getNode(0).getVelocityIn(phase).doubleValue() * Aw; + // double Fe = oldVelocity[phase][0] * Ae; + // System.out.println("new- old : " + + // (pipe.getNode(0).getVelocityIn().doubleValue() - oldVelocity[0])); + oldMass[phase][0] = 1.0 / timeStep * pipe.getNode(0).getGeometry().getArea() + * pipe.getNode(0).getGeometry().getNodeLength(); + + a[0] = 0.0; // Math.max(Fw,0); + c[0] = 1.0; // Math.max(-Fe,0); + b[0] = 1.0; // a[0] + c[0] + (Fe - Fw) + oldMass[0]; + r[0] = 0.0; // oldMass[0]*oldDensity[0]; + + // setter ligningen paa rett form + a[0] = -a[0]; + c[0] = -c[0]; } - /** - *

- * setPhaseFractionMatrix. - *

- * - * @param phase a int - */ - public void setPhaseFractionMatrix(int phase) { - if (!dynamic) { - double SU = 0; - a[0] = 0; - b[0] = 1.0; - c[0] = 0; - SU = pipe.getNode(0).getPhaseFraction(phase); - r[0] = SU; - } else { - // double Ae = pipe.getNode(0).getGeometry().getArea(); - // double Aw = pipe.getNode(0).getGeometry().getArea(); - // double Fw = pipe.getNode(0).getVelocityIn(phase).doubleValue() * Aw; - // double Fe = oldVelocity[phase][0] * Ae; - // System.out.println("new- old : " + - // (pipe.getNode(0).getVelocityIn().doubleValue() - oldVelocity[0])); - oldMass[phase][0] = 1.0 / timeStep * pipe.getNode(0).getGeometry().getArea() - * pipe.getNode(0).getGeometry().getNodeLength(); - - a[0] = 0.0;// Math.max(Fw,0); - c[0] = 1.0;// Math.max(-Fe,0); - b[0] = 1.0;// a[0] + c[0] + (Fe - Fw) + oldMass[0]; - r[0] = 0.0;// oldMass[0]*oldDensity[0]; - - // setter ligningen paa rett form - a[0] = -a[0]; - c[0] = -c[0]; - } - - for (int i = 1; i < numberOfNodes - 1; i++) { - double Ae = pipe.getNode(i).getGeometry().getArea(); - double Aw = pipe.getNode(i - 1).getGeometry().getArea(); - double Fe = pipe.getNode(i).getVelocityOut(phase).doubleValue() * Ae - * pipe.getNode(i).getBulkSystem().getPhases()[phase].getPhysicalProperties() - .getDensity(); - double Fw = pipe.getNode(i).getVelocityIn(phase).doubleValue() * Aw - * pipe.getNode(i - 1).getBulkSystem().getPhases()[phase].getPhysicalProperties() - .getDensity(); - - if (dynamic) { - oldMass[phase][i] = 1.0 / timeStep * pipe.getNode(i).getGeometry().getArea() - * pipe.getNode(i).getGeometry().getNodeLength(); - } else { - oldMass[phase][i] = 0.0; - } - - a[i] = Math.max(Fw, 0); - c[i] = Math.max(-Fe, 0); - b[i] = a[i] + c[i] + (Fe - Fw) + oldMass[phase][i]; - r[i] = oldMass[phase][i] * oldDensity[phase][i]; - - // setter ligningen paa rett form - a[i] = -a[i]; - c[i] = -c[i]; - } - - int i = numberOfNodes - 1; - double Ae = pipe.getNode(i).getGeometry().getArea(); - double Aw = pipe.getNode(i - 1).getGeometry().getArea(); - - double Fe = pipe.getNode(i).getVelocity(phase) * Ae - * pipe.getNode(i).getBulkSystem().getPhases()[phase].getPhysicalProperties() - .getDensity(); - double Fw = pipe.getNode(i).getVelocityIn(phase).doubleValue() * Aw - * pipe.getNode(i - 1).getBulkSystem().getPhases()[phase].getPhysicalProperties() - .getDensity(); - - if (dynamic) { - oldMass[phase][i] = 1.0 / timeStep * pipe.getNode(i).getGeometry().getArea() - * pipe.getNode(i).getGeometry().getNodeLength(); - } else { - oldMass[phase][i] = 0.0; - } - - a[i] = Math.max(Fw, 0); - c[i] = Math.max(-Fe, 0); - b[i] = a[i] + c[i] + (Fe - Fw) + oldMass[phase][i]; - r[i] = oldMass[phase][i] * oldDensity[phase][i]; - // setter ligningen paa rett form - a[i] = -a[i]; - c[i] = -c[i]; + for (int i = 1; i < numberOfNodes - 1; i++) { + double Ae = pipe.getNode(i).getArea(phase); + double Aw = pipe.getNode(i - 1).getArea(phase); + double Fe = pipe.getNode(i).getVelocityOut(phase).doubleValue() * Ae; + double Fw = pipe.getNode(i).getVelocityIn(phase).doubleValue() * Aw; + + if (dynamic) { + oldMass[phase][i] = 1.0 / timeStep * pipe.getNode(i).getArea(phase) + * pipe.getNode(i).getGeometry().getNodeLength(); + } else { + oldMass[phase][i] = 0.0; + } + + a[i] = Math.max(Fw, 0); + c[i] = Math.max(-Fe, 0); + b[i] = a[i] + c[i] + (Fe - Fw) + oldMass[phase][i]; + r[i] = oldMass[phase][i] * oldDensity[phase][i]; + + // setter ligningen paa rett form + a[i] = -a[i]; + c[i] = -c[i]; } - /** - *

- * setImpulsMatrixTDMA. - *

- * - * @param phase a int - */ - public void setImpulsMatrixTDMA(int phase) { - double sign = (phase == 0) ? 1.0 : -1.0; - double SU = 0.0, SP = 0.0; - double Fw = 0.0, Fe = 0.0; - - pipe.getNode(0).initFlowCalc(); - pipe.getNode(0).init(); - pipe.getNode(0).setVelocityIn(phase, pipe.getNode(0).getVelocity(phase)); - - a[0] = 0; - b[0] = 1.0; - c[0] = 0; - - r[0] = pipe.getNode(0).getVelocityIn(phase).doubleValue(); - - a[1] = 0; - b[1] = 1.0; - c[1] = 0; - - r[1] = pipe.getNode(0).getVelocityIn(phase).doubleValue(); - - for (int i = 2; i < numberOfNodes - 1; i++) { - double Ae = pipe.getNode(i).getArea(phase); - double Aw = pipe.getNode(i - 1).getArea(phase); - double Amean = pipe.getNode(i - 1).getArea(phase); - double meanFrik = pipe.getNode(i - 1).getWallFrictionFactor(phase); - double meanDensity = pipe.getNode(i - 1).getBulkSystem().getPhases()[phase] - .getPhysicalProperties().getDensity(); - double oldMeanDensity = oldDensity[phase][i]; - double meanVelocity = pipe.getNode(i - 1).getVelocity(phase); - double vertposchange = pipe.getNode(i).getVerticalPositionOfNode() - - pipe.getNode(i - 1).getVerticalPositionOfNode(); - double nodeLength = pipe.getNode(i - 1).getGeometry().getNodeLength(); - double interfaceFricition = pipe.getNode(i - 1).getInterPhaseFrictionFactor(); - // System.out.println(" dif: " + - // (-pipe.getNode(i-1).getWallContactLength(phase) - // * nodeLength* meanDensity * - // meanFrik*Math.abs(meanVelocity)*meanVelocity/8.0 - // - pipe.getNode(i-1).getInterphaseContactLength(0)*nodeLength* meanDensity - // * - // interfaceFricition*Math.abs(pipe.getNode(i).getVelocity(0) - - // pipe.getNode(i).getVelocity(1))*(pipe.getNode(i).getVelocity(0) - - // pipe.getNode(i).getVelocity(1))/8.0*sign)); - SU = -Amean - * (pipe.getNode(i).getBulkSystem().getPressure() - - pipe.getNode(i - 1).getBulkSystem().getPressure()) - * 1e5 - + Amean * gravity * meanDensity * vertposchange - + pipe.getNode(i - 1).getWallContactLength(phase) * nodeLength * meanDensity - * meanFrik * Math.abs(meanVelocity) * meanVelocity / 8.0 - - pipe.getNode(i - 1).getInterphaseContactLength(0) * nodeLength * meanDensity - * interfaceFricition - * Math.abs( - pipe.getNode(i).getVelocity(0) - pipe.getNode(i).getVelocity(1)) - * (pipe.getNode(i).getVelocity(0) - pipe.getNode(i).getVelocity(1)) - / 8.0 * sign; - // System.out.println("su " + SU); - SP = -pipe.getNode(i - 1).getWallContactLength(phase) * nodeLength * meanDensity - * meanFrik * meanVelocity / 4.0; - Fw = Aw * pipe.getNode(i - 1).getBulkSystem().getPhases()[phase].getPhysicalProperties() - .getDensity() * pipe.getNode(i - 1).getVelocity(phase); - Fe = Ae * pipe.getNode(i).getBulkSystem().getPhases()[phase].getPhysicalProperties() - .getDensity() * pipe.getNode(i).getVelocity(phase); - - if (dynamic) { - oldImpuls[phase][i] = 1.0 / timeStep * oldMeanDensity * nodeLength * Amean; - } else { - oldImpuls[phase][i] = 0.0; - } - - a[i] = Math.max(Fw, 0); - c[i] = Math.max(-Fe, 0);// - Fe/2.0; - b[i] = a[i] + c[i] + (Fe - Fw) - SP + oldImpuls[phase][i]; - r[i] = SU + oldImpuls[phase][i] * oldVelocity[phase][i]; - // setter ligningen paa rett form - a[i] = -a[i]; - c[i] = -c[i]; - } + int i = numberOfNodes - 1; + // double Ae = pipe.getNode(i).getArea(phase); + // double Aw = pipe.getNode(i - 1).getArea(phase); - int i = numberOfNodes - 1; - double Ae = pipe.getNode(i - 1).getArea(phase); - double Aw = pipe.getNode(i - 1).getArea(phase); - double Amean = pipe.getNode(i - 1).getArea(phase); - // double meanDiameter = pipe.getNode(i - 1).getGeometry().getDiameter(); - double meanFrik = pipe.getNode(i - 1).getWallFrictionFactor(phase); - double meanDensity = pipe.getNode(i - 1).getBulkSystem().getPhases()[phase] - .getPhysicalProperties().getDensity(); - double oldMeanDensity = oldDensity[phase][i]; - double meanVelocity = pipe.getNode(i - 1).getVelocity(phase); - double vertposchange = pipe.getNode(i).getVerticalPositionOfNode() - - pipe.getNode(i - 1).getVerticalPositionOfNode(); - double nodeLength = pipe.getNode(i - 1).getGeometry().getNodeLength(); - double interfaceFricition = pipe.getNode(i - 1).getInterPhaseFrictionFactor(); - - SU = -Amean - * (pipe.getNode(i).getBulkSystem().getPressure() - - pipe.getNode(i - 1).getBulkSystem().getPressure()) - * 1e5 - - Amean * gravity * meanDensity * vertposchange - + pipe.getNode(i - 1).getWallContactLength(phase) * nodeLength * meanDensity - * meanFrik * Math.abs(meanVelocity) * meanVelocity / 8.0 - - pipe.getNode(i - 1).getInterphaseContactLength(0) * nodeLength * meanDensity - * interfaceFricition - * Math.abs(pipe.getNode(i).getVelocity(0) - pipe.getNode(i).getVelocity(1)) - * (pipe.getNode(i).getVelocity(0) - pipe.getNode(i).getVelocity(1)) / 8.0 - * sign; - SP = -pipe.getNode(i - 1).getWallContactLength(phase) * nodeLength * meanDensity * meanFrik - * meanVelocity / 4.0; - Fw = Aw * pipe.getNode(i - 1).getBulkSystem().getPhases()[phase].getPhysicalProperties() - .getDensity() * pipe.getNode(i).getVelocityIn(phase).doubleValue(); - Fe = Ae * pipe.getNode(i).getBulkSystem().getPhases()[phase].getPhysicalProperties() - .getDensity() * pipe.getNode(i).getVelocity(phase); - - if (dynamic) { - oldImpuls[phase][i] = 1.0 / timeStep * oldMeanDensity * nodeLength * Amean; - } else { - oldImpuls[phase][i] = 0.0; - } - - a[i] = Math.max(Fw, 0); - c[i] = Math.max(-Fe, 0); - // if(dynamic){c[i] = - Fe/2.0; a[i] = Fw/2.0; } - b[i] = a[i] + c[i] + (Fe - Fw) - SP + oldImpuls[phase][i]; - r[i] = SU + oldImpuls[phase][i] * oldVelocity[phase][i]; + // double Fe = pipe.getNode(i).getVelocity(phase) * Ae; + // double Fw = pipe.getNode(i).getVelocityIn(phase).doubleValue() * Aw; - // setter ligningen paa rett form - a[numberOfNodes - 1] = -a[numberOfNodes - 1]; - c[numberOfNodes - 1] = -c[numberOfNodes - 1]; + if (dynamic) { + oldMass[phase][i] = 1.0 / timeStep * pipe.getNode(i).getArea(phase) + * pipe.getNode(i).getGeometry().getNodeLength(); + } else { + oldMass[phase][i] = 0.0; } - /** - *

- * setEnergyMatrixTDMA. - *

- * - * @param phase a int - */ - public void setEnergyMatrixTDMA(int phase) { - double sign = (phase == 0) ? 1.0 : -1.0; - - a[0] = 0; - b[0] = 1.0; - c[0] = 0; - double SU = pipe.getNode(0).getBulkSystem().getPhases()[phase].getEnthalpy() - / pipe.getNode(0).getBulkSystem().getPhases()[phase].getNumberOfMolesInPhase() - / pipe.getNode(0).getBulkSystem().getPhases()[phase].getMolarMass(); - r[0] = SU; - - for (int i = 1; i < numberOfNodes - 1; i++) { - double fe = pipe.getNode(i + 1).getGeometry().getNodeLength() - / (pipe.getNode(i).getGeometry().getNodeLength() - + pipe.getNode(i + 1).getGeometry().getNodeLength()); - double fw = pipe.getNode(i - 1).getGeometry().getNodeLength() - / (pipe.getNode(i).getGeometry().getNodeLength() - + pipe.getNode(i - 1).getGeometry().getNodeLength()); - double Ae = pipe.getNode(i).getArea(phase); - double Aw = pipe.getNode(i - 1).getArea(phase); - double vertposchange = (1 - fe) - * (pipe.getNode(i + 1).getVerticalPositionOfNode() - - pipe.getNode(i).getVerticalPositionOfNode()) - + (1 - fw) * (pipe.getNode(i).getVerticalPositionOfNode() - - pipe.getNode(i - 1).getVerticalPositionOfNode()); - - SU = -pipe.getNode(i).getArea(phase) * gravity - * pipe.getNode(i).getBulkSystem().getPhases()[phase].getDensity() - * pipe.getNode(i).getVelocity(phase) * vertposchange - + pipe.getNode(i).getArea(phase) * 4.0 * 0.02 - * (278.0 - pipe.getNode(i).getBulkSystem().getPhases()[phase] - .getTemperature()) - / (pipe.getNode(i).getGeometry().getDiameter()) - * pipe.getNode(i).getGeometry().getNodeLength() - + sign * pipe.getNode(i).getFluidBoundary().getInterphaseHeatFlux(phase) - * pipe.getNode(i).getGeometry().getNodeLength() - * pipe.getNode(i).getInterphaseContactLength(phase) - * (pipe.getNode(i).getGeometry().getNodeLength() - / pipe.getNode(i).getVelocity(phase)); - double SP = 0; - - double Fw = Aw * pipe.getNode(i - 1).getBulkSystem().getPhases()[phase] - .getPhysicalProperties().getDensity() - * pipe.getNode(i).getVelocityIn(phase).doubleValue(); - double Fe = - Ae * pipe.getNode(i).getBulkSystem().getPhases()[phase].getPhysicalProperties() - .getDensity() * pipe.getNode(i).getVelocityOut(phase).doubleValue(); - - if (dynamic) { - oldEnergy[phase][i] = 1.0 / timeStep * oldDensity[phase][i] - * pipe.getNode(i).getGeometry().getNodeLength() - * pipe.getNode(i).getArea(phase); - } else { - oldEnergy[phase][i] = 0.0; - } - - a[i] = Math.max(Fw, 0); - c[i] = Math.max(-Fe, 0); - b[i] = a[i] + c[i] + (Fe - Fw) - SP + oldEnergy[phase][i]; - r[i] = SU + oldEnergy[phase][i] * oldInternalEnergy[phase][i]; - - // setter ligningen paa rett form - a[i] = -a[i]; - c[i] = -c[i]; - } - - int i = numberOfNodes - 1; - - double fw = pipe.getNode(i - 1).getGeometry().getNodeLength() - / (pipe.getNode(i).getGeometry().getNodeLength() - + pipe.getNode(i - 1).getGeometry().getNodeLength()); - double Ae = pipe.getNode(i).getArea(phase);// 1.0/((1.0-fe)/pipe.getNode(i).getGeometry().getArea() - // + - // fe/pipe.getNode(i+1).getGeometry().getArea()); - double Aw = pipe.getNode(i - 1).getArea(phase);// 1.0/((1.0-fw)/pipe.getNode(i).getGeometry().getArea() - // + - // fw/pipe.getNode(i-1).getGeometry().getArea()); - double vertposchange = (1 - fw) * (pipe.getNode(i).getVerticalPositionOfNode() - - pipe.getNode(i - 1).getVerticalPositionOfNode()); - - SU = -pipe.getNode(i).getArea(phase) * gravity - * pipe.getNode(i).getBulkSystem().getPhases()[phase].getDensity() - * pipe.getNode(i).getVelocity(phase) * vertposchange - + pipe.getNode(i).getWallContactLength(phase) - / pipe.getNode(i).getGeometry().getCircumference() - * pipe.getNode(i).getArea(phase) * 4.0 * 0.02 - * (278.0 - pipe.getNode(i).getBulkSystem().getPhases()[phase] - .getTemperature()) - / (pipe.getNode(i).getGeometry().getDiameter()) - * pipe.getNode(i).getGeometry().getNodeLength() - + sign * pipe.getNode(i).getFluidBoundary().getInterphaseHeatFlux(phase) - * pipe.getNode(i).getGeometry().getNodeLength() - * pipe.getNode(i).getInterphaseContactLength(phase) - * (pipe.getNode(i).getGeometry().getNodeLength() - / pipe.getNode(i).getVelocity(phase)); - double SP = 0;// -pipe.getNode(i).getGeometry().getArea()*4.0*12.0/(pipe.getNode(i).getGeometry().getDiameter())*pipe.getNode(i).getGeometry().getNodeLength(); - - double Fw = - Aw * pipe.getNode(i - 1).getBulkSystem().getPhases()[phase].getPhysicalProperties() - .getDensity() * pipe.getNode(i).getVelocityIn(phase).doubleValue(); - double Fe = Ae * pipe.getNode(i).getBulkSystem().getPhases()[phase].getPhysicalProperties() - .getDensity() * pipe.getNode(i).getVelocity(phase); - - if (dynamic) { - oldEnergy[phase][i] = 1.0 / timeStep * oldDensity[phase][i] - * pipe.getNode(i).getGeometry().getNodeLength() - * pipe.getNode(i).getArea(phase); - } else { - oldEnergy[phase][i] = 0.0; - } + a[i] = 1; // Math.max(Fw,0); + c[i] = 0; // Math.max(-Fe,0); + b[i] = 1; // a[i] + c[i] + (Fe - Fw) + oldMass[phase][i]; + r[i] = 0; // oldMass[phase][i]*oldDensity[phase][i]; + // setter ligningen paa rett form + a[i] = -a[i]; + c[i] = -c[i]; + } + + /** + *

+ * setPhaseFractionMatrix. + *

+ * + * @param phase a int + */ + public void setPhaseFractionMatrix(int phase) { + if (!dynamic) { + double SU = 0; + a[0] = 0; + b[0] = 1.0; + c[0] = 0; + SU = pipe.getNode(0).getPhaseFraction(phase); + r[0] = SU; + } else { + // double Ae = pipe.getNode(0).getGeometry().getArea(); + // double Aw = pipe.getNode(0).getGeometry().getArea(); + // double Fw = pipe.getNode(0).getVelocityIn(phase).doubleValue() * Aw; + // double Fe = oldVelocity[phase][0] * Ae; + // System.out.println("new- old : " + + // (pipe.getNode(0).getVelocityIn().doubleValue() - oldVelocity[0])); + oldMass[phase][0] = 1.0 / timeStep * pipe.getNode(0).getGeometry().getArea() + * pipe.getNode(0).getGeometry().getNodeLength(); + + a[0] = 0.0; // Math.max(Fw,0); + c[0] = 1.0; // Math.max(-Fe,0); + b[0] = 1.0; // a[0] + c[0] + (Fe - Fw) + oldMass[0]; + r[0] = 0.0; // oldMass[0]*oldDensity[0]; + + // setter ligningen paa rett form + a[0] = -a[0]; + c[0] = -c[0]; + } - a[i] = Math.max(Fw, 0); - c[i] = Math.max(-Fe, 0); - b[i] = a[i] + c[i] + (Fe - Fw) - SP + oldEnergy[phase][i]; - r[i] = SU + oldEnergy[phase][i] * oldInternalEnergy[phase][i]; - a[i] = -a[i]; - c[i] = -c[i]; + for (int i = 1; i < numberOfNodes - 1; i++) { + double Ae = pipe.getNode(i).getGeometry().getArea(); + double Aw = pipe.getNode(i - 1).getGeometry().getArea(); + double Fe = pipe.getNode(i).getVelocityOut(phase).doubleValue() * Ae + * pipe.getNode(i).getBulkSystem().getPhases()[phase].getPhysicalProperties().getDensity(); + double Fw = pipe.getNode(i).getVelocityIn(phase).doubleValue() * Aw + * pipe.getNode(i - 1).getBulkSystem().getPhases()[phase].getPhysicalProperties() + .getDensity(); + + if (dynamic) { + oldMass[phase][i] = 1.0 / timeStep * pipe.getNode(i).getGeometry().getArea() + * pipe.getNode(i).getGeometry().getNodeLength(); + } else { + oldMass[phase][i] = 0.0; + } + + a[i] = Math.max(Fw, 0); + c[i] = Math.max(-Fe, 0); + b[i] = a[i] + c[i] + (Fe - Fw) + oldMass[phase][i]; + r[i] = oldMass[phase][i] * oldDensity[phase][i]; + + // setter ligningen paa rett form + a[i] = -a[i]; + c[i] = -c[i]; } - /** - *

- * setComponentConservationMatrix2. - *

- * - * @param phase a int - * @param componentNumber a int - */ - public void setComponentConservationMatrix2(int phase, int componentNumber) { - double SU = 0; - double sign = (phase == 0) ? 1.0 : 1.0; - a[0] = 0; - b[0] = 1.0; - c[0] = 0; - SU = pipe.getNode(0).getBulkSystem().getPhases()[phase].getComponents()[componentNumber] - .getx(); - // System.out.println("phase x0: " - // +pipe.getNode(0).getBulkSystem().getPhases()[0].getComponents()[componentNumber].getx()); - // System.out.println("phase x1: " - // +pipe.getNode(0).getBulkSystem().getPhases()[1].getComponents()[componentNumber].getx()); - r[0] = SU; - - for (int i = 1; i < numberOfNodes - 1; i++) { - double fe = pipe.getNode(i + 1).getGeometry().getNodeLength() - / (pipe.getNode(i).getGeometry().getNodeLength() - + pipe.getNode(i + 1).getGeometry().getNodeLength()); - double fw = pipe.getNode(i - 1).getGeometry().getNodeLength() - / (pipe.getNode(i).getGeometry().getNodeLength() - + pipe.getNode(i - 1).getGeometry().getNodeLength()); - double Ae = 1.0 / ((1.0 - fe) / pipe.getNode(i).getArea(phase) - + fe / pipe.getNode(i + 1).getArea(phase)); - double Aw = 1.0 / ((1.0 - fw) / pipe.getNode(i).getArea(phase) - + fw / pipe.getNode(i - 1).getArea(phase)); - - double Fe = pipe.getNode(i).getVelocityOut(phase).doubleValue() - * pipe.getNode(i).getBulkSystem().getPhases()[phase].getPhysicalProperties() - .getDensity() - * pipe.getNode(i).getBulkSystem().getPhases()[phase] - .getComponents()[componentNumber].getMolarMass() - / pipe.getNode(i).getBulkSystem().getPhases()[phase].getMolarMass() * Ae; - double Fw = pipe.getNode(i).getVelocityIn(phase).doubleValue() - * pipe.getNode(i - 1).getBulkSystem().getPhases()[phase].getPhysicalProperties() - .getDensity() - * pipe.getNode(i).getBulkSystem().getPhases()[phase] - .getComponents()[componentNumber].getMolarMass() - / pipe.getNode(i).getBulkSystem().getPhases()[phase].getMolarMass() * Aw; - - // System.out.println("vel: " + - // pipe.getNode(i).getVelocityOut(phase).doubleValue() + " fe " + Fe); - a[i] = Math.max(Fw, 0); - c[i] = Math.max(-Fe, 0);// - Fe/2.0; - b[i] = a[i] + c[i] + (Fe - Fw) - sign * pipe.getNode(i).getArea(phase) - * pipe.getNode(i).getFluidBoundary().getInterphaseMolarFlux(componentNumber) - / pipe.getNode(i).getVelocity() * pipe.getNode(i).getGeometry().getNodeLength(); - r[i] = 0; - // setter ligningen paa rett form - a[i] = -a[i]; - c[i] = -c[i]; - } + int i = numberOfNodes - 1; + double Ae = pipe.getNode(i).getGeometry().getArea(); + double Aw = pipe.getNode(i - 1).getGeometry().getArea(); + + double Fe = pipe.getNode(i).getVelocity(phase) * Ae + * pipe.getNode(i).getBulkSystem().getPhases()[phase].getPhysicalProperties().getDensity(); + double Fw = pipe.getNode(i).getVelocityIn(phase).doubleValue() * Aw + * pipe.getNode(i - 1).getBulkSystem().getPhases()[phase].getPhysicalProperties() + .getDensity(); + + if (dynamic) { + oldMass[phase][i] = 1.0 / timeStep * pipe.getNode(i).getGeometry().getArea() + * pipe.getNode(i).getGeometry().getNodeLength(); + } else { + oldMass[phase][i] = 0.0; + } - a[numberOfNodes - 1] = -1.0;// -1.0; - b[numberOfNodes - 1] = 1.0; - c[numberOfNodes - 1] = 0; - SU = pipe.getNode(numberOfNodes - 2).getBulkSystem().getPhases()[phase] - .getPhysicalProperties().getDensity() - * pipe.getNode(numberOfNodes - 2).getVelocityIn(phase).doubleValue() - * pipe.getNode(numberOfNodes - 2).getBulkSystem().getPhases()[phase] - .getComponents()[componentNumber].getx() - / (pipe.getNode(numberOfNodes - 1).getBulkSystem().getPhases()[phase] - .getPhysicalProperties().getDensity() - * pipe.getNode(numberOfNodes - 1).getVelocityIn(phase).doubleValue()); - r[numberOfNodes - 1] = 0;// SU; + a[i] = Math.max(Fw, 0); + c[i] = Math.max(-Fe, 0); + b[i] = a[i] + c[i] + (Fe - Fw) + oldMass[phase][i]; + r[i] = oldMass[phase][i] * oldDensity[phase][i]; + // setter ligningen paa rett form + a[i] = -a[i]; + c[i] = -c[i]; + } + + /** + *

+ * setImpulsMatrixTDMA. + *

+ * + * @param phase a int + */ + public void setImpulsMatrixTDMA(int phase) { + double sign = (phase == 0) ? 1.0 : -1.0; + double SU = 0.0; + double SP = 0.0; + double Fw = 0.0; + + double Fe = 0.0; + pipe.getNode(0).initFlowCalc(); + pipe.getNode(0).init(); + pipe.getNode(0).setVelocityIn(phase, pipe.getNode(0).getVelocity(phase)); + + a[0] = 0; + b[0] = 1.0; + c[0] = 0; + + r[0] = pipe.getNode(0).getVelocityIn(phase).doubleValue(); + + a[1] = 0; + b[1] = 1.0; + c[1] = 0; + + r[1] = pipe.getNode(0).getVelocityIn(phase).doubleValue(); + + for (int i = 2; i < numberOfNodes - 1; i++) { + double Ae = pipe.getNode(i).getArea(phase); + double Aw = pipe.getNode(i - 1).getArea(phase); + double Amean = pipe.getNode(i - 1).getArea(phase); + double meanFrik = pipe.getNode(i - 1).getWallFrictionFactor(phase); + double meanDensity = pipe.getNode(i - 1).getBulkSystem().getPhases()[phase] + .getPhysicalProperties().getDensity(); + double oldMeanDensity = oldDensity[phase][i]; + double meanVelocity = pipe.getNode(i - 1).getVelocity(phase); + double vertposchange = pipe.getNode(i).getVerticalPositionOfNode() + - pipe.getNode(i - 1).getVerticalPositionOfNode(); + double nodeLength = pipe.getNode(i - 1).getGeometry().getNodeLength(); + double interfaceFricition = pipe.getNode(i - 1).getInterPhaseFrictionFactor(); + // System.out.println(" dif: " + + // (-pipe.getNode(i-1).getWallContactLength(phase) + // * nodeLength* meanDensity * + // meanFrik*Math.abs(meanVelocity)*meanVelocity/8.0 + // - pipe.getNode(i-1).getInterphaseContactLength(0)*nodeLength* meanDensity + // * + // interfaceFricition*Math.abs(pipe.getNode(i).getVelocity(0) - + // pipe.getNode(i).getVelocity(1))*(pipe.getNode(i).getVelocity(0) - + // pipe.getNode(i).getVelocity(1))/8.0*sign)); + SU = -Amean + * (pipe.getNode(i).getBulkSystem().getPressure() + - pipe.getNode(i - 1).getBulkSystem().getPressure()) + * 1e5 + Amean * gravity * meanDensity * vertposchange + + pipe.getNode(i - 1).getWallContactLength(phase) * nodeLength * meanDensity * meanFrik + * Math.abs(meanVelocity) * meanVelocity / 8.0 + - pipe.getNode(i - 1).getInterphaseContactLength(0) * nodeLength * meanDensity + * interfaceFricition + * Math.abs(pipe.getNode(i).getVelocity(0) - pipe.getNode(i).getVelocity(1)) + * (pipe.getNode(i).getVelocity(0) - pipe.getNode(i).getVelocity(1)) / 8.0 * sign; + // System.out.println("su " + SU); + SP = -pipe.getNode(i - 1).getWallContactLength(phase) * nodeLength * meanDensity * meanFrik + * meanVelocity / 4.0; + Fw = Aw * pipe.getNode(i - 1).getBulkSystem().getPhases()[phase].getPhysicalProperties() + .getDensity() * pipe.getNode(i - 1).getVelocity(phase); + Fe = Ae + * pipe.getNode(i).getBulkSystem().getPhases()[phase].getPhysicalProperties().getDensity() + * pipe.getNode(i).getVelocity(phase); + + if (dynamic) { + oldImpuls[phase][i] = 1.0 / timeStep * oldMeanDensity * nodeLength * Amean; + } else { + oldImpuls[phase][i] = 0.0; + } + + a[i] = Math.max(Fw, 0); + c[i] = Math.max(-Fe, 0); // - Fe/2.0; + b[i] = a[i] + c[i] + (Fe - Fw) - SP + oldImpuls[phase][i]; + r[i] = SU + oldImpuls[phase][i] * oldVelocity[phase][i]; + // setter ligningen paa rett form + a[i] = -a[i]; + c[i] = -c[i]; } - /** - *

- * setComponentConservationMatrix. - *

- * - * @param phase a int - * @param componentNumber a int - */ - public void setComponentConservationMatrix(int phase, int componentNumber) { - double sign = (phase == 0) ? -1.0 : 1.0; - double SU = 0; - a[0] = 0; - b[0] = 1.0; - c[0] = 0; - SU = pipe.getNode(0).getBulkSystem().getPhases()[phase].getComponents()[componentNumber] - .getx() - * pipe.getNode(0).getBulkSystem().getPhases()[phase] - .getComponents()[componentNumber].getMolarMass() - / pipe.getNode(0).getBulkSystem().getPhases()[phase].getMolarMass(); - r[0] = SU; - - for (int i = 1; i < numberOfNodes - 1; i++) { - double Ae = pipe.getNode(i).getArea(phase); - double Aw = pipe.getNode(i - 1).getArea(phase); - - double Fe = pipe.getNode(i).getVelocityOut(phase).doubleValue() - * pipe.getNode(i).getBulkSystem().getPhases()[phase].getDensity() * Ae; - double Fw = pipe.getNode(i).getVelocityIn(phase).doubleValue() - * pipe.getNode(i - 1).getBulkSystem().getPhases()[phase].getDensity() * Aw; - // System.out.println("vel: " + - // pipe.getNode(i).getVelocityOut(phase).doubleValue() + " fe " + Fe); - if (dynamic) { - oldComp[phase][i] = 1.0 / timeStep * pipe.getNode(i).getArea(phase) - * pipe.getNode(i).getGeometry().getNodeLength() - * pipe.getNode(i).getBulkSystem().getPhases()[phase].getDensity(); - } else { - oldComp[phase][i] = 0.0; - } + int i = numberOfNodes - 1; + double Ae = pipe.getNode(i - 1).getArea(phase); + double Aw = pipe.getNode(i - 1).getArea(phase); + double Amean = pipe.getNode(i - 1).getArea(phase); + // double meanDiameter = pipe.getNode(i - 1).getGeometry().getDiameter(); + double meanFrik = pipe.getNode(i - 1).getWallFrictionFactor(phase); + double meanDensity = + pipe.getNode(i - 1).getBulkSystem().getPhases()[phase].getPhysicalProperties().getDensity(); + double oldMeanDensity = oldDensity[phase][i]; + double meanVelocity = pipe.getNode(i - 1).getVelocity(phase); + double vertposchange = pipe.getNode(i).getVerticalPositionOfNode() + - pipe.getNode(i - 1).getVerticalPositionOfNode(); + double nodeLength = pipe.getNode(i - 1).getGeometry().getNodeLength(); + double interfaceFricition = pipe.getNode(i - 1).getInterPhaseFrictionFactor(); + + SU = -Amean + * (pipe.getNode(i).getBulkSystem().getPressure() + - pipe.getNode(i - 1).getBulkSystem().getPressure()) + * 1e5 - Amean * gravity * meanDensity * vertposchange + + pipe.getNode(i - 1).getWallContactLength(phase) * nodeLength * meanDensity * meanFrik + * Math.abs(meanVelocity) * meanVelocity / 8.0 + - pipe.getNode(i - 1).getInterphaseContactLength(0) * nodeLength * meanDensity + * interfaceFricition + * Math.abs(pipe.getNode(i).getVelocity(0) - pipe.getNode(i).getVelocity(1)) + * (pipe.getNode(i).getVelocity(0) - pipe.getNode(i).getVelocity(1)) / 8.0 * sign; + SP = -pipe.getNode(i - 1).getWallContactLength(phase) * nodeLength * meanDensity * meanFrik + * meanVelocity / 4.0; + Fw = Aw * pipe.getNode(i - 1).getBulkSystem().getPhases()[phase].getPhysicalProperties() + .getDensity() * pipe.getNode(i).getVelocityIn(phase).doubleValue(); + Fe = Ae + * pipe.getNode(i).getBulkSystem().getPhases()[phase].getPhysicalProperties().getDensity() + * pipe.getNode(i).getVelocity(phase); + + if (dynamic) { + oldImpuls[phase][i] = 1.0 / timeStep * oldMeanDensity * nodeLength * Amean; + } else { + oldImpuls[phase][i] = 0.0; + } - SU = +sign * pipe.getNode(i).getFluidBoundary().getInterphaseMolarFlux(componentNumber) - * pipe.getNode(i).getBulkSystem().getPhases()[phase] - .getComponents()[componentNumber].getMolarMass() - * pipe.getNode(i).getGeometry().getNodeLength() - * pipe.getNode(i).getInterphaseContactLength(phase) - * (pipe.getNode(i).getGeometry().getNodeLength() - / pipe.getNode(i).getVelocity(phase)); - // double SP = 0;// - // -pipe.getNode(i).getGeometry().getArea()*4.0*12.0/(pipe.getNode(i).getGeometry().getDiameter())*pipe.getNode(i).getGeometry().getNodeLength(); - - a[i] = Math.max(Fw, 0); - c[i] = Math.max(-Fe, 0); - b[i] = a[i] + c[i] + (Fe - Fw) + oldComp[phase][i]; - r[i] = SU + oldComp[phase][i] * oldComposition[phase][componentNumber][i]; - - // setter ligningen paa rett form - a[i] = -a[i]; - c[i] = -c[i]; - } + a[i] = Math.max(Fw, 0); + c[i] = Math.max(-Fe, 0); + // if(dynamic){c[i] = - Fe/2.0; a[i] = Fw/2.0; } + b[i] = a[i] + c[i] + (Fe - Fw) - SP + oldImpuls[phase][i]; + r[i] = SU + oldImpuls[phase][i] * oldVelocity[phase][i]; + + // setter ligningen paa rett form + a[numberOfNodes - 1] = -a[numberOfNodes - 1]; + c[numberOfNodes - 1] = -c[numberOfNodes - 1]; + } + + /** + *

+ * setEnergyMatrixTDMA. + *

+ * + * @param phase a int + */ + public void setEnergyMatrixTDMA(int phase) { + double sign = (phase == 0) ? 1.0 : -1.0; + + a[0] = 0; + b[0] = 1.0; + c[0] = 0; + double SU = pipe.getNode(0).getBulkSystem().getPhases()[phase].getEnthalpy() + / pipe.getNode(0).getBulkSystem().getPhases()[phase].getNumberOfMolesInPhase() + / pipe.getNode(0).getBulkSystem().getPhases()[phase].getMolarMass(); + r[0] = SU; + + for (int i = 1; i < numberOfNodes - 1; i++) { + double fe = pipe.getNode(i + 1).getGeometry().getNodeLength() + / (pipe.getNode(i).getGeometry().getNodeLength() + + pipe.getNode(i + 1).getGeometry().getNodeLength()); + double fw = pipe.getNode(i - 1).getGeometry().getNodeLength() + / (pipe.getNode(i).getGeometry().getNodeLength() + + pipe.getNode(i - 1).getGeometry().getNodeLength()); + double Ae = pipe.getNode(i).getArea(phase); + double Aw = pipe.getNode(i - 1).getArea(phase); + double vertposchange = (1 - fe) + * (pipe.getNode(i + 1).getVerticalPositionOfNode() + - pipe.getNode(i).getVerticalPositionOfNode()) + + (1 - fw) * (pipe.getNode(i).getVerticalPositionOfNode() + - pipe.getNode(i - 1).getVerticalPositionOfNode()); + + SU = -pipe.getNode(i).getArea(phase) * gravity + * pipe.getNode(i).getBulkSystem().getPhases()[phase].getDensity() + * pipe.getNode(i).getVelocity(phase) * vertposchange + + pipe.getNode(i).getArea(phase) * 4.0 * 0.02 + * (278.0 - pipe.getNode(i).getBulkSystem().getPhases()[phase].getTemperature()) + / (pipe.getNode(i).getGeometry().getDiameter()) + * pipe.getNode(i).getGeometry().getNodeLength() + + sign * pipe.getNode(i).getFluidBoundary().getInterphaseHeatFlux(phase) + * pipe.getNode(i).getGeometry().getNodeLength() + * pipe.getNode(i).getInterphaseContactLength(phase) + * (pipe.getNode(i).getGeometry().getNodeLength() + / pipe.getNode(i).getVelocity(phase)); + double SP = 0; + + double Fw = + Aw * pipe.getNode(i - 1).getBulkSystem().getPhases()[phase].getPhysicalProperties() + .getDensity() * pipe.getNode(i).getVelocityIn(phase).doubleValue(); + double Fe = Ae + * pipe.getNode(i).getBulkSystem().getPhases()[phase].getPhysicalProperties().getDensity() + * pipe.getNode(i).getVelocityOut(phase).doubleValue(); + + if (dynamic) { + oldEnergy[phase][i] = 1.0 / timeStep * oldDensity[phase][i] + * pipe.getNode(i).getGeometry().getNodeLength() * pipe.getNode(i).getArea(phase); + } else { + oldEnergy[phase][i] = 0.0; + } + + a[i] = Math.max(Fw, 0); + c[i] = Math.max(-Fe, 0); + b[i] = a[i] + c[i] + (Fe - Fw) - SP + oldEnergy[phase][i]; + r[i] = SU + oldEnergy[phase][i] * oldInternalEnergy[phase][i]; + + // setter ligningen paa rett form + a[i] = -a[i]; + c[i] = -c[i]; + } - int i = numberOfNodes - 1; - // double fw = - // pipe.getNode(i-1).getGeometry().getNodeLength()/(pipe.getNode(i).getGeometry().getNodeLength()+pipe.getNode(i-1).getGeometry().getNodeLength()); - // double Ae = pipe.getNode(i).getArea(phase); - // double Aw = pipe.getNode(i - 1).getArea(phase); - - // double Fe = pipe.getNode(i).getVelocity(phase) * - // pipe.getNode(i).getBulkSystem().getPhases()[phase].getDensity() * Ae; - // double Fw = pipe.getNode(i).getVelocityIn(phase).doubleValue() * pipe.getNode(i - - // 1).getBulkSystem().getPhases()[phase].getDensity() * Aw; - - SU = +sign * pipe.getNode(i).getFluidBoundary().getInterphaseMolarFlux(componentNumber) - * pipe.getNode(i).getBulkSystem().getPhases()[phase] - .getComponents()[componentNumber].getMolarMass() - * pipe.getNode(i).getGeometry().getNodeLength() - * pipe.getNode(i).getInterphaseContactLength(phase) - * (pipe.getNode(i).getGeometry().getNodeLength() - / pipe.getNode(i).getVelocity(phase)); - // double SP = 0;// - // -pipe.getNode(i).getGeometry().getArea()*4.0*12.0/(pipe.getNode(i).getGeometry().getDiameter())*pipe.getNode(i).getGeometry().getNodeLength(); - - if (dynamic) { - oldComp[phase][i] = 1.0 / timeStep * pipe.getNode(i).getArea(phase) - * pipe.getNode(i).getGeometry().getNodeLength() - * pipe.getNode(i).getBulkSystem().getPhases()[phase].getDensity(); - } else { - oldComp[phase][i] = 0.0; - } + int i = numberOfNodes - 1; + + double fw = pipe.getNode(i - 1).getGeometry().getNodeLength() + / (pipe.getNode(i).getGeometry().getNodeLength() + + pipe.getNode(i - 1).getGeometry().getNodeLength()); + double Ae = pipe.getNode(i).getArea(phase); // 1.0/((1.0-fe)/pipe.getNode(i).getGeometry().getArea() + // + + // fe/pipe.getNode(i+1).getGeometry().getArea()); + double Aw = pipe.getNode(i - 1).getArea(phase); // 1.0/((1.0-fw)/pipe.getNode(i).getGeometry().getArea() + // + + // fw/pipe.getNode(i-1).getGeometry().getArea()); + double vertposchange = (1 - fw) * (pipe.getNode(i).getVerticalPositionOfNode() + - pipe.getNode(i - 1).getVerticalPositionOfNode()); + + SU = -pipe.getNode(i).getArea(phase) * gravity + * pipe.getNode(i).getBulkSystem().getPhases()[phase].getDensity() + * pipe.getNode(i).getVelocity(phase) * vertposchange + + pipe.getNode(i).getWallContactLength(phase) + / pipe.getNode(i).getGeometry().getCircumference() * pipe.getNode(i).getArea(phase) + * 4.0 * 0.02 + * (278.0 - pipe.getNode(i).getBulkSystem().getPhases()[phase].getTemperature()) + / (pipe.getNode(i).getGeometry().getDiameter()) + * pipe.getNode(i).getGeometry().getNodeLength() + + sign * pipe.getNode(i).getFluidBoundary().getInterphaseHeatFlux(phase) + * pipe.getNode(i).getGeometry().getNodeLength() + * pipe.getNode(i).getInterphaseContactLength(phase) + * (pipe.getNode(i).getGeometry().getNodeLength() / pipe.getNode(i).getVelocity(phase)); + double SP = 0; // -pipe.getNode(i).getGeometry().getArea()*4.0*12.0/(pipe.getNode(i).getGeometry().getDiameter())*pipe.getNode(i).getGeometry().getNodeLength(); + + double Fw = Aw * pipe.getNode(i - 1).getBulkSystem().getPhases()[phase].getPhysicalProperties() + .getDensity() * pipe.getNode(i).getVelocityIn(phase).doubleValue(); + double Fe = + Ae * pipe.getNode(i).getBulkSystem().getPhases()[phase].getPhysicalProperties().getDensity() + * pipe.getNode(i).getVelocity(phase); + + if (dynamic) { + oldEnergy[phase][i] = 1.0 / timeStep * oldDensity[phase][i] + * pipe.getNode(i).getGeometry().getNodeLength() * pipe.getNode(i).getArea(phase); + } else { + oldEnergy[phase][i] = 0.0; + } - a[i] = 1.0;// Math.max(Fw,0); - c[i] = 0.0;// Math.max(-Fe,0); - b[i] = 1.0;// a[i] + c[i] + (Fe - Fw) + oldComp[phase][i]; - r[i] = 0.0;// SU + oldComp[phase][i]*oldComposition[phase][componentNumber][i]; - // setter ligningen paa rett form - a[i] = -a[i]; - c[i] = -c[i]; + a[i] = Math.max(Fw, 0); + c[i] = Math.max(-Fe, 0); + b[i] = a[i] + c[i] + (Fe - Fw) - SP + oldEnergy[phase][i]; + r[i] = SU + oldEnergy[phase][i] * oldInternalEnergy[phase][i]; + a[i] = -a[i]; + c[i] = -c[i]; + } + + /** + *

+ * setComponentConservationMatrix2. + *

+ * + * @param phase a int + * @param componentNumber a int + */ + public void setComponentConservationMatrix2(int phase, int componentNumber) { + double SU = 0; + double sign = (phase == 0) ? 1.0 : 1.0; + a[0] = 0; + b[0] = 1.0; + c[0] = 0; + SU = pipe.getNode(0).getBulkSystem().getPhases()[phase].getComponents()[componentNumber].getx(); + // System.out.println("phase x0: " + // +pipe.getNode(0).getBulkSystem().getPhases()[0].getComponents()[componentNumber].getx()); + // System.out.println("phase x1: " + // +pipe.getNode(0).getBulkSystem().getPhases()[1].getComponents()[componentNumber].getx()); + r[0] = SU; + + for (int i = 1; i < numberOfNodes - 1; i++) { + double fe = pipe.getNode(i + 1).getGeometry().getNodeLength() + / (pipe.getNode(i).getGeometry().getNodeLength() + + pipe.getNode(i + 1).getGeometry().getNodeLength()); + double fw = pipe.getNode(i - 1).getGeometry().getNodeLength() + / (pipe.getNode(i).getGeometry().getNodeLength() + + pipe.getNode(i - 1).getGeometry().getNodeLength()); + double Ae = 1.0 + / ((1.0 - fe) / pipe.getNode(i).getArea(phase) + fe / pipe.getNode(i + 1).getArea(phase)); + double Aw = 1.0 + / ((1.0 - fw) / pipe.getNode(i).getArea(phase) + fw / pipe.getNode(i - 1).getArea(phase)); + + double Fe = pipe.getNode(i).getVelocityOut(phase).doubleValue() + * pipe.getNode(i).getBulkSystem().getPhases()[phase].getPhysicalProperties().getDensity() + * pipe.getNode(i).getBulkSystem().getPhases()[phase].getComponents()[componentNumber] + .getMolarMass() + / pipe.getNode(i).getBulkSystem().getPhases()[phase].getMolarMass() * Ae; + double Fw = pipe.getNode(i).getVelocityIn(phase).doubleValue() + * pipe.getNode(i - 1).getBulkSystem().getPhases()[phase].getPhysicalProperties() + .getDensity() + * pipe.getNode(i).getBulkSystem().getPhases()[phase].getComponents()[componentNumber] + .getMolarMass() + / pipe.getNode(i).getBulkSystem().getPhases()[phase].getMolarMass() * Aw; + + // System.out.println("vel: " + + // pipe.getNode(i).getVelocityOut(phase).doubleValue() + " fe " + Fe); + a[i] = Math.max(Fw, 0); + c[i] = Math.max(-Fe, 0); // - Fe/2.0; + b[i] = a[i] + c[i] + (Fe - Fw) + - sign * pipe.getNode(i).getArea(phase) + * pipe.getNode(i).getFluidBoundary().getInterphaseMolarFlux(componentNumber) + / pipe.getNode(i).getVelocity() * pipe.getNode(i).getGeometry().getNodeLength(); + r[i] = 0; + // setter ligningen paa rett form + a[i] = -a[i]; + c[i] = -c[i]; } - /** - *

- * initFinalResults. - *

- * - * @param phase a int - */ - public void initFinalResults(int phase) { - for (int i = 0; i < numberOfNodes; i++) { - oldVelocity[phase][i] = pipe.getNode(i).getVelocityIn().doubleValue(); - oldDensity[phase][i] = pipe.getNode(i).getBulkSystem().getPhases()[0] - .getPhysicalProperties().getDensity(); - oldInternalEnergy[phase][i] = - pipe.getNode(i).getBulkSystem().getPhases()[0].getEnthalpy() - / pipe.getNode(i).getBulkSystem().getPhases()[0] - .getNumberOfMolesInPhase() - / pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass(); - - for (int j = 0; j < pipe.getNode(i).getBulkSystem().getPhases()[0] - .getNumberOfComponents(); j++) { - oldComposition[phase][j][i] = xNew[phase][j][i]; // pipe.getNode(i).getBulkSystem().getPhases()[0].getComponents()[j].getx() - // * - // pipe.getNode(i).getBulkSystem().getPhases()[0].getComponents()[j].getMolarMass()/pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass(); - } - } + a[numberOfNodes - 1] = -1.0; // -1.0; + b[numberOfNodes - 1] = 1.0; + c[numberOfNodes - 1] = 0; + SU = pipe.getNode(numberOfNodes - 2).getBulkSystem().getPhases()[phase].getPhysicalProperties() + .getDensity() + * pipe.getNode(numberOfNodes - 2).getVelocityIn(phase).doubleValue() + * pipe.getNode(numberOfNodes - 2).getBulkSystem().getPhases()[phase] + .getComponents()[componentNumber].getx() + / (pipe.getNode(numberOfNodes - 1).getBulkSystem().getPhases()[phase] + .getPhysicalProperties().getDensity() + * pipe.getNode(numberOfNodes - 1).getVelocityIn(phase).doubleValue()); + r[numberOfNodes - 1] = 0; // SU; + } + + /** + *

+ * setComponentConservationMatrix. + *

+ * + * @param phase a int + * @param componentNumber a int + */ + public void setComponentConservationMatrix(int phase, int componentNumber) { + double sign = (phase == 0) ? -1.0 : 1.0; + double SU = 0; + a[0] = 0; + b[0] = 1.0; + c[0] = 0; + SU = pipe.getNode(0).getBulkSystem().getPhases()[phase].getComponents()[componentNumber].getx() + * pipe.getNode(0).getBulkSystem().getPhases()[phase].getComponents()[componentNumber] + .getMolarMass() + / pipe.getNode(0).getBulkSystem().getPhases()[phase].getMolarMass(); + r[0] = SU; + + for (int i = 1; i < numberOfNodes - 1; i++) { + double Ae = pipe.getNode(i).getArea(phase); + double Aw = pipe.getNode(i - 1).getArea(phase); + + double Fe = pipe.getNode(i).getVelocityOut(phase).doubleValue() + * pipe.getNode(i).getBulkSystem().getPhases()[phase].getDensity() * Ae; + double Fw = pipe.getNode(i).getVelocityIn(phase).doubleValue() + * pipe.getNode(i - 1).getBulkSystem().getPhases()[phase].getDensity() * Aw; + // System.out.println("vel: " + + // pipe.getNode(i).getVelocityOut(phase).doubleValue() + " fe " + Fe); + if (dynamic) { + oldComp[phase][i] = 1.0 / timeStep * pipe.getNode(i).getArea(phase) + * pipe.getNode(i).getGeometry().getNodeLength() + * pipe.getNode(i).getBulkSystem().getPhases()[phase].getDensity(); + } else { + oldComp[phase][i] = 0.0; + } + + SU = +sign * pipe.getNode(i).getFluidBoundary().getInterphaseMolarFlux(componentNumber) + * pipe.getNode(i).getBulkSystem().getPhases()[phase].getComponents()[componentNumber] + .getMolarMass() + * pipe.getNode(i).getGeometry().getNodeLength() + * pipe.getNode(i).getInterphaseContactLength(phase) + * (pipe.getNode(i).getGeometry().getNodeLength() / pipe.getNode(i).getVelocity(phase)); + // double SP = 0; + // -pipe.getNode(i).getGeometry().getArea()*4.0*12.0/(pipe.getNode(i).getGeometry().getDiameter())*pipe.getNode(i).getGeometry().getNodeLength(); + + a[i] = Math.max(Fw, 0); + c[i] = Math.max(-Fe, 0); + b[i] = a[i] + c[i] + (Fe - Fw) + oldComp[phase][i]; + r[i] = SU + oldComp[phase][i] * oldComposition[phase][componentNumber][i]; + + // setter ligningen paa rett form + a[i] = -a[i]; + c[i] = -c[i]; } - /** - *

- * calcFluxes. - *

- */ - public void calcFluxes() { - for (int i = 0; i < numberOfNodes; i++) { - pipe.getNode(i).calcFluxes(); - } + int i = numberOfNodes - 1; + // double fw = + // pipe.getNode(i-1).getGeometry().getNodeLength()/(pipe.getNode(i).getGeometry().getNodeLength()+pipe.getNode(i-1).getGeometry().getNodeLength()); + // double Ae = pipe.getNode(i).getArea(phase); + // double Aw = pipe.getNode(i - 1).getArea(phase); + + // double Fe = pipe.getNode(i).getVelocity(phase) * + // pipe.getNode(i).getBulkSystem().getPhases()[phase].getDensity() * Ae; + // double Fw = pipe.getNode(i).getVelocityIn(phase).doubleValue() * pipe.getNode(i - + // 1).getBulkSystem().getPhases()[phase].getDensity() * Aw; + + SU = +sign * pipe.getNode(i).getFluidBoundary().getInterphaseMolarFlux(componentNumber) + * pipe.getNode(i).getBulkSystem().getPhases()[phase].getComponents()[componentNumber] + .getMolarMass() + * pipe.getNode(i).getGeometry().getNodeLength() + * pipe.getNode(i).getInterphaseContactLength(phase) + * (pipe.getNode(i).getGeometry().getNodeLength() / pipe.getNode(i).getVelocity(phase)); + // double SP = 0; + // -pipe.getNode(i).getGeometry().getArea()*4.0*12.0/(pipe.getNode(i).getGeometry().getDiameter())*pipe.getNode(i).getGeometry().getNodeLength(); + + if (dynamic) { + oldComp[phase][i] = 1.0 / timeStep * pipe.getNode(i).getArea(phase) + * pipe.getNode(i).getGeometry().getNodeLength() + * pipe.getNode(i).getBulkSystem().getPhases()[phase].getDensity(); + } else { + oldComp[phase][i] = 0.0; } - /** - *

- * initNodes. - *

- */ - public void initNodes() { - for (int i = 0; i < numberOfNodes; i++) { - pipe.getNode(i).init(); - } + a[i] = 1.0; // Math.max(Fw,0); + c[i] = 0.0; // Math.max(-Fe,0); + b[i] = 1.0; // a[i] + c[i] + (Fe - Fw) + oldComp[phase][i]; + r[i] = 0.0; // SU + oldComp[phase][i]*oldComposition[phase][componentNumber][i]; + // setter ligningen paa rett form + a[i] = -a[i]; + c[i] = -c[i]; + } + + /** + *

+ * initFinalResults. + *

+ * + * @param phase a int + */ + public void initFinalResults(int phase) { + for (int i = 0; i < numberOfNodes; i++) { + oldVelocity[phase][i] = pipe.getNode(i).getVelocityIn().doubleValue(); + oldDensity[phase][i] = + pipe.getNode(i).getBulkSystem().getPhases()[0].getPhysicalProperties().getDensity(); + oldInternalEnergy[phase][i] = pipe.getNode(i).getBulkSystem().getPhases()[0].getEnthalpy() + / pipe.getNode(i).getBulkSystem().getPhases()[0].getNumberOfMolesInPhase() + / pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass(); + + for (int j = 0; j < pipe.getNode(i).getBulkSystem().getPhases()[0] + .getNumberOfComponents(); j++) { + oldComposition[phase][j][i] = xNew[phase][j][i]; // pipe.getNode(i).getBulkSystem().getPhases()[0].getComponents()[j].getx() + // * + // pipe.getNode(i).getBulkSystem().getPhases()[0].getComponents()[j].getMolarMass()/pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass(); + } + } + } + + /** + *

+ * calcFluxes. + *

+ */ + public void calcFluxes() { + for (int i = 0; i < numberOfNodes; i++) { + pipe.getNode(i).calcFluxes(); + } + } + + /** + *

+ * initNodes. + *

+ */ + public void initNodes() { + for (int i = 0; i < numberOfNodes; i++) { + pipe.getNode(i).init(); } + } - /** {@inheritDoc} */ - @Override - public void solveTDMA() { - double d[]; - int iter = 0, iterTop = 0; - double maxDiff = 1e10; - // double maxDiffOld = 1e10; - double diff = 0; - System.out.println("starting...:"); - initProfiles(); - dn = new double[numberOfNodes][pipe.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents()]; - xNew = new double[2][pipe.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents()][numberOfNodes]; - initMatrix(); + /** {@inheritDoc} */ + @Override + public void solveTDMA() { + double[] d; + int iter = 0; + int iterTop = 0; + double maxDiff = 1e10; + // double maxDiffOld = 1e10; + double diff = 0; + System.out.println("starting...:"); + initProfiles(); + dn = new double[numberOfNodes][pipe.getNode(0).getBulkSystem().getPhases()[0] + .getNumberOfComponents()]; + xNew = new double[2][pipe.getNode(0).getBulkSystem().getPhases()[0] + .getNumberOfComponents()][numberOfNodes]; + initMatrix(); + + do { + // maxDiffOld = maxDiff; + maxDiff = 0; + iterTop++; + + iter = 0; + if (this.solverType >= 5) { + for (int phase = 0; phase < 2; phase++) { + do { + iter++; + setImpulsMatrixTDMA(phase); + Matrix solOld = solMatrix[phase].copy(); + d = TDMAsolve.solve(a, b, c, r); + solMatrix[phase] = new Matrix(d, 1).transpose(); + solMatrix[phase].print(10, 10); + diffMatrix = solMatrix[phase].minus(solOld); + // System.out.println("diff impuls: "+ + // diffMatrix.norm2()/solMatrix[phase].norm2()); + diff = Math.abs(diffMatrix.norm1() / solMatrix[phase].norm1()); + if (diff > maxDiff) { + maxDiff = diff; + } + initVelocity(phase); + } while (diff > 1e-10 && iter < 100); + } + } + + iter = 0; + if (this.solverType >= 5) { + for (int phase = 1; phase < 2; phase++) { + do { + iter++; + setPhaseFractionMatrix(phase); + Matrix solOld = solPhaseConsMatrix[phase].copy(); + d = TDMAsolve.solve(a, b, c, r); + solPhaseConsMatrix[phase] = new Matrix(d, 1).transpose(); + // solPhaseConsMatrix[phase].print(10,10); + diffMatrix = solPhaseConsMatrix[phase].minus(solOld); + // System.out.println("diff phase frac: "+ + // diffMatrix.norm2()/solPhaseConsMatrix[phase].norm2()); + diff = Math.abs(diffMatrix.norm1() / solPhaseConsMatrix[phase].norm1()); + if (diff > maxDiff) { + maxDiff = diff; + } + initPhaseFraction(phase); + } while (diff > 1e-15 && iter < 100); + } + int phase = 0; do { - // maxDiffOld = maxDiff; - maxDiff = 0; - iterTop++; - - iter = 0; - if (this.solverType >= 5) { - for (int phase = 0; phase < 2; phase++) { - do { - iter++; - setImpulsMatrixTDMA(phase); - Matrix solOld = solMatrix[phase].copy(); - d = TDMAsolve.solve(a, b, c, r); - solMatrix[phase] = new Matrix(d, 1).transpose(); - solMatrix[phase].print(10, 10); - diffMatrix = solMatrix[phase].minus(solOld); - // System.out.println("diff impuls: "+ - // diffMatrix.norm2()/solMatrix[phase].norm2()); - diff = Math.abs(diffMatrix.norm1() / solMatrix[phase].norm1()); - if (diff > maxDiff) { - maxDiff = diff; - } - initVelocity(phase); - } while (diff > 1e-10 && iter < 100); - } + iter++; + setMassConservationMatrix(phase); + Matrix solOld = solPhaseConsMatrix[phase].copy(); + d = TDMAsolve.solve(a, b, c, r); + solPhaseConsMatrix[phase] = new Matrix(d, 1).transpose(); + // solPhaseConsMatrix[phase].print(10,10); + diffMatrix = solPhaseConsMatrix[phase].minus(solOld); + // System.out.println("diff mass: "+ + // diffMatrix.norm2()/solPhaseConsMatrix[phase].norm2()); + diff = Math.abs(diffMatrix.norm1() / solPhaseConsMatrix[phase].norm1()); + if (diff > maxDiff) { + maxDiff = diff; + } + initPressure(phase); + } while (diff > 1e-15 && iter < 100); + } + + if (this.solverType >= 5) { + for (int phase = 0; phase < 2; phase++) { + iter = 0; + do { + iter++; + Matrix sol3Old = sol3Matrix[phase].copy(); + setEnergyMatrixTDMA(phase); + d = TDMAsolve.solve(a, b, c, r); + sol3Matrix[phase] = new Matrix(d, 1).transpose(); + diffMatrix = sol3Matrix[phase].minus(sol3Old); + // System.out.println("diff energy: " + + // diffMatrix.norm2()/sol3Matrix[phase].norm2()); + // diffMatrix.print(10,10); + diff = Math.abs(diffMatrix.norm1() / sol3Matrix[phase].norm1()); + if (diff > maxDiff) { + maxDiff = diff; } + initTemperature(phase); + } while (diff > 1e-15 && iter < 100); + } + } + if (this.solverType >= 5) { + double compDiff = 0.0; + int compIter = 0; + do { + calcFluxes(); + compIter++; + for (int phase = 0; phase < 2; phase++) { iter = 0; - if (this.solverType >= 5) { - for (int phase = 1; phase < 2; phase++) { - do { - iter++; - setPhaseFractionMatrix(phase); - Matrix solOld = solPhaseConsMatrix[phase].copy(); - d = TDMAsolve.solve(a, b, c, r); - solPhaseConsMatrix[phase] = new Matrix(d, 1).transpose(); - // solPhaseConsMatrix[phase].print(10,10); - diffMatrix = solPhaseConsMatrix[phase].minus(solOld); - // System.out.println("diff phase frac: "+ - // diffMatrix.norm2()/solPhaseConsMatrix[phase].norm2()); - diff = Math.abs(diffMatrix.norm1() / solPhaseConsMatrix[phase].norm1()); - if (diff > maxDiff) { - maxDiff = diff; - } - initPhaseFraction(phase); - } while (diff > 1e-15 && iter < 100); + for (int p = 0; p < pipe.getNode(0).getBulkSystem().getPhases()[0] + .getNumberOfComponents() - 1; p++) { + do { + iter++; + setComponentConservationMatrix(phase, p); + Matrix solOld = solMolFracMatrix[phase][p].copy(); + xNew[phase][p] = TDMAsolve.solve(a, b, c, r); + solMolFracMatrix[phase][p] = new Matrix(xNew[phase][p], 1).transpose(); + diffMatrix = solMolFracMatrix[phase][p].minus(solOld); + diff = Math.abs(diffMatrix.norm2() / solMolFracMatrix[phase][p].norm2()); + if (diff > maxDiff) { + maxDiff = diff; } - - int phase = 0; - do { - iter++; - setMassConservationMatrix(phase); - Matrix solOld = solPhaseConsMatrix[phase].copy(); - d = TDMAsolve.solve(a, b, c, r); - solPhaseConsMatrix[phase] = new Matrix(d, 1).transpose(); - // solPhaseConsMatrix[phase].print(10,10); - diffMatrix = solPhaseConsMatrix[phase].minus(solOld); - // System.out.println("diff mass: "+ - // diffMatrix.norm2()/solPhaseConsMatrix[phase].norm2()); - diff = Math.abs(diffMatrix.norm1() / solPhaseConsMatrix[phase].norm1()); - if (diff > maxDiff) { - maxDiff = diff; - } - initPressure(phase); - } while (diff > 1e-15 && iter < 100); - } - - if (this.solverType >= 5) { - for (int phase = 0; phase < 2; phase++) { - iter = 0; - do { - iter++; - Matrix sol3Old = sol3Matrix[phase].copy(); - setEnergyMatrixTDMA(phase); - d = TDMAsolve.solve(a, b, c, r); - sol3Matrix[phase] = new Matrix(d, 1).transpose(); - diffMatrix = sol3Matrix[phase].minus(sol3Old); - // System.out.println("diff energy: " + - // diffMatrix.norm2()/sol3Matrix[phase].norm2()); - // diffMatrix.print(10,10); - diff = Math.abs(diffMatrix.norm1() / sol3Matrix[phase].norm1()); - if (diff > maxDiff) { - maxDiff = diff; - } - initTemperature(phase); - } while (diff > 1e-15 && iter < 100); + if (diff > compDiff) { + compDiff = diff; } + System.out.println( + "diff molfrac: " + diffMatrix.norm2() / solMolFracMatrix[phase][p].norm2()); + // Matrix dmat = new Matrix(xNew[phase][p], 1); + // dmat.print(10,10); + initComposition(phase, p); + } while (diff > 1e-12 && iter < 10); } - - if (this.solverType >= 5) { - double compDiff = 0.0; - int compIter = 0; - do { - calcFluxes(); - compIter++; - for (int phase = 0; phase < 2; phase++) { - iter = 0; - for (int p = 0; p < pipe.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents() - 1; p++) { - do { - iter++; - setComponentConservationMatrix(phase, p); - Matrix solOld = solMolFracMatrix[phase][p].copy(); - xNew[phase][p] = TDMAsolve.solve(a, b, c, r); - solMolFracMatrix[phase][p] = - new Matrix(xNew[phase][p], 1).transpose(); - diffMatrix = solMolFracMatrix[phase][p].minus(solOld); - diff = Math.abs( - diffMatrix.norm2() / solMolFracMatrix[phase][p].norm2()); - if (diff > maxDiff) { - maxDiff = diff; - } - if (diff > compDiff) { - compDiff = diff; - } - System.out.println("diff molfrac: " - + diffMatrix.norm2() / solMolFracMatrix[phase][p].norm2()); - // Matrix dmat = new Matrix(xNew[phase][p], 1); - // dmat.print(10,10); - initComposition(phase, p); - } while (diff > 1e-12 && iter < 10); - } - } - } while (compDiff > 1e-10 && compIter < 10); - initNodes(); - } - - // initVelocity(); - // this.setVelocities();*/ - System.out.println("iter: " + iterTop + " maxdiff " + maxDiff); - } while (Math.abs(maxDiff) > 1e-7 && iterTop < 1);// diffMatrix.norm2()/sol2Matrix.norm2())>0.1); - - for (int phase = 0; phase < 2; phase++) { - for (int p = 0; p < pipe.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents() - 1; p++) { - Matrix dmat = new Matrix(xNew[phase][p], 1); - dmat.print(10, 10); - } - } + } + } while (compDiff > 1e-10 && compIter < 10); + initNodes(); + } + + // initVelocity(); + // this.setVelocities();*/ + System.out.println("iter: " + iterTop + " maxdiff " + maxDiff); + } while (Math.abs(maxDiff) > 1e-7 && iterTop < 1); // diffMatrix.norm2()/sol2Matrix.norm2())>0.1); + + for (int phase = 0; phase < 2; phase++) { + for (int p = 0; p < pipe.getNode(0).getBulkSystem().getPhases()[0].getNumberOfComponents() + - 1; p++) { + Matrix dmat = new Matrix(xNew[phase][p], 1); + dmat.print(10, 10); + } } + } } diff --git a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/shipSystem/LNGship.java b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/shipSystem/LNGship.java index 53e92c37cd..7fdaacf0c3 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/shipSystem/LNGship.java +++ b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/shipSystem/LNGship.java @@ -34,7 +34,7 @@ public class LNGship double initialNumberOffMoles; double molarBoilOffRate = 0.0; double dailyBoilOffVolume = 0.0; - private double endTime = 960;// 24.0 * 10; + private double endTime = 960; // 24.0 * 10; private Standard_ISO6976 standardISO6976 = null; StandardInterface standardDensity = null; double[] WI = null; @@ -282,7 +282,7 @@ public void solveTransient(int type, UUID id) { tankTemperature[j] = getThermoSystem().getTemperature(); volume[j] = getThermoSystem().getNumberOfMoles() - * getThermoSystem().getPhase(1).getMolarMass() / density[j];// density[0]; + * getThermoSystem().getPhase(1).getMolarMass() / density[j]; // density[0]; this.standardISO6976.setReferenceType("mass"); totalEnergy[j] = @@ -305,8 +305,8 @@ public void solveTransient(int type, UUID id) { double derrordn = (oldVolume - oldoldVolume) / (oldmolarBoilOffRate - oldoldmolarBoilOffRate); boilOffCorrection = (volume[numberOffTimeSteps - 1] - endVolume) / derrordn; if (iterations > 1) { - molarBoilOffRate += boilOffCorrection;// (volume[numberOffTimeSteps - 1] - - // endVolume) / derrordn; + molarBoilOffRate += boilOffCorrection; // (volume[numberOffTimeSteps - 1] - + // endVolume) / derrordn; } else { molarBoilOffRate = molarBoilOffRate * volume[numberOffTimeSteps - 1] / endVolume; } @@ -412,10 +412,10 @@ public static void main(String[] args) { * testSystem.addComponent("nitrogen", 0.0136); testSystem.addComponent("methane", 0.9186); * testSystem.addComponent("ethane", 0.0526); testSystem.addComponent("propane", 0.0115); */ - testSystem.addComponent("nitrogen", 0.691);// 0.93041); - testSystem.addComponent("methane", 91.93);// 92.637); - testSystem.addComponent("ethane", 5.651);// 4.876); - testSystem.addComponent("propane", 1.296);// 1.093); + testSystem.addComponent("nitrogen", 0.691); // 0.93041); + testSystem.addComponent("methane", 91.93); // 92.637); + testSystem.addComponent("ethane", 5.651); // 4.876); + testSystem.addComponent("propane", 1.296); // 1.093); testSystem.addComponent("i-butane", 0.122); testSystem.addComponent("n-butane", 0.289); testSystem.addComponent("i-pentane", 0.018); diff --git a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhasePipeFlowSystem/TwoPhasePipeFlowSystem.java b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhasePipeFlowSystem/TwoPhasePipeFlowSystem.java index e393fd55fb..8cc61db8f8 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhasePipeFlowSystem/TwoPhasePipeFlowSystem.java +++ b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhasePipeFlowSystem/TwoPhasePipeFlowSystem.java @@ -138,9 +138,9 @@ public static void main(String[] args) { // leg double[] height = {0, 0, 0, 0, 0, 0}; double[] length = {0.0, 1.7, 3.5, 5.0, 7.5, 10.4}; - double[] outerTemperature = {278.0, 278.0, 278.0, 278.0, 278.0, 278.0};// , 278.0, 275.0, - // 275.0, 275.0, - // 275.0}; + double[] outerTemperature = {278.0, 278.0, 278.0, 278.0, 278.0, 278.0}; // , 278.0, 275.0, + // 275.0, 275.0, + // 275.0}; double[] roughness = {1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5}; double[] outHeatCoef = {5.0, 5.0, 5.0, 5.0, 5.0, 5.0}; double[] wallHeacCoef = {15.0, 15.0, 15.0, 15.0, 15.0, 15.0}; diff --git a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhaseReactorFlowSystem/TwoPhaseReactorFlowSystem.java b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhaseReactorFlowSystem/TwoPhaseReactorFlowSystem.java index c56bcf52e4..61053a7e77 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhaseReactorFlowSystem/TwoPhaseReactorFlowSystem.java +++ b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/twoPhaseReactorFlowSystem/TwoPhaseReactorFlowSystem.java @@ -47,7 +47,7 @@ public void createSystem() { public void init() { for (int j = 0; j < getTotalNumberOfNodes(); j++) { flowNode[j].setInterphaseModelType(1); - flowNode[j].getGeometry();// setPackingType() + flowNode[j].getGeometry(); // setPackingType() flowNode[j].initFlowCalc(); flowNode[j].init(); } diff --git a/src/main/java/neqsim/physicalProperties/interfaceProperties/solidAdsorption/PotentialTheoryAdsorption.java b/src/main/java/neqsim/physicalProperties/interfaceProperties/solidAdsorption/PotentialTheoryAdsorption.java index 3fcde2e56a..a861a5a7f9 100644 --- a/src/main/java/neqsim/physicalProperties/interfaceProperties/solidAdsorption/PotentialTheoryAdsorption.java +++ b/src/main/java/neqsim/physicalProperties/interfaceProperties/solidAdsorption/PotentialTheoryAdsorption.java @@ -13,182 +13,184 @@ * @version $Id: $Id */ public class PotentialTheoryAdsorption implements AdsorptionInterface { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(PotentialTheoryAdsorption.class); - - SystemInterface system; - double[] eps0;// = 7.458;//7.630; // J/mol - double[] z0;// = 3.284;// * 1e-3; // m^3/kg - double[] beta;// = 2.0; - int integrationSteps = 500; - double totalSurfaceExcess; - double[][] compositionSurface, fugacityField; - double[][] zField, epsField; - double[] pressureField, surfaceExcess, surfaceExcessMolFraction, deltaz; - String solidMaterial = "AC"; - - /** - *

- * Constructor for PotentialTheoryAdsorption. - *

- */ - public PotentialTheoryAdsorption() {} - - /** - *

- * Constructor for PotentialTheoryAdsorption. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public PotentialTheoryAdsorption(SystemInterface system) { - this.system = system; - compositionSurface = - new double[integrationSteps][system.getPhase(0).getNumberOfComponents()]; - pressureField = new double[integrationSteps]; - zField = new double[system.getPhase(0).getNumberOfComponents()][integrationSteps]; - epsField = new double[system.getPhase(0).getNumberOfComponents()][integrationSteps]; - fugacityField = new double[system.getPhase(0).getNumberOfComponents()][integrationSteps]; - deltaz = new double[system.getPhase(0).getNumberOfComponents()]; + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(PotentialTheoryAdsorption.class); + + SystemInterface system; + double[] eps0; // = 7.458; //7.630; // J/mol + double[] z0; // = 3.284; // * 1e-3; // m^3/kg + double[] beta; // = 2.0; + int integrationSteps = 500; + double totalSurfaceExcess; + double[][] compositionSurface; + double[][] fugacityField; + double[][] zField; + double[][] epsField; + double[] pressureField; + double[] surfaceExcess; + double[] surfaceExcessMolFraction; + double[] deltaz; + String solidMaterial = "AC"; + + /** + *

+ * Constructor for PotentialTheoryAdsorption. + *

+ */ + public PotentialTheoryAdsorption() {} + + /** + *

+ * Constructor for PotentialTheoryAdsorption. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public PotentialTheoryAdsorption(SystemInterface system) { + this.system = system; + compositionSurface = new double[integrationSteps][system.getPhase(0).getNumberOfComponents()]; + pressureField = new double[integrationSteps]; + zField = new double[system.getPhase(0).getNumberOfComponents()][integrationSteps]; + epsField = new double[system.getPhase(0).getNumberOfComponents()][integrationSteps]; + fugacityField = new double[system.getPhase(0).getNumberOfComponents()][integrationSteps]; + deltaz = new double[system.getPhase(0).getNumberOfComponents()]; + } + + /** {@inheritDoc} */ + @Override + public void setSolidMaterial(String solidM) { + solidMaterial = solidM; + } + + /** {@inheritDoc} */ + @Override + public void calcAdorption(int phase) { + SystemInterface tempSystem = system.clone(); + tempSystem.init(3); + double[] bulkFug = new double[system.getPhase(phase).getNumberOfComponents()]; + double[] corrx = new double[system.getPhase(phase).getNumberOfComponents()]; + surfaceExcess = new double[system.getPhase(phase).getNumberOfComponents()]; + surfaceExcessMolFraction = new double[system.getPhase(phase).getNumberOfComponents()]; + + eps0 = new double[system.getPhase(phase).getNumberOfComponents()]; + z0 = new double[system.getPhase(phase).getNumberOfComponents()]; + beta = new double[system.getPhase(phase).getNumberOfComponents()]; + + readDBParameters(); + + for (int comp = 0; comp < system.getPhase(phase).getNumberOfComponents(); comp++) { + bulkFug[comp] = system.getPhase(phase).getComponent(comp).getx() + * system.getPhase(phase).getComponent(comp).getFugacityCoefficient() + * system.getPhase(phase).getPressure(); + deltaz[comp] = z0[comp] / (integrationSteps * 1.0); + zField[comp][0] = z0[comp]; + for (int i = 0; i < integrationSteps; i++) { + zField[comp][i] = zField[comp][0] - deltaz[comp] * i; + epsField[comp][i] = + eps0[comp] * Math.pow(Math.log(z0[comp] / zField[comp][i]), 1.0 / beta[comp]); + } } - - /** {@inheritDoc} */ - @Override - public void setSolidMaterial(String solidM) { - solidMaterial = solidM; - } - - /** {@inheritDoc} */ - @Override - public void calcAdorption(int phase) { - SystemInterface tempSystem = system.clone(); - tempSystem.init(3); - double[] bulkFug = new double[system.getPhase(phase).getNumberOfComponents()]; - double[] corrx = new double[system.getPhase(phase).getNumberOfComponents()]; - surfaceExcess = new double[system.getPhase(phase).getNumberOfComponents()]; - surfaceExcessMolFraction = new double[system.getPhase(phase).getNumberOfComponents()]; - - eps0 = new double[system.getPhase(phase).getNumberOfComponents()]; - z0 = new double[system.getPhase(phase).getNumberOfComponents()]; - beta = new double[system.getPhase(phase).getNumberOfComponents()]; - - readDBParameters(); - + for (int i = 0; i < integrationSteps; i++) { + int iter = 0; + double sumx = 0; + double pressure = 0; + do { + iter++; + sumx = 0.0; + pressure = 0.0; for (int comp = 0; comp < system.getPhase(phase).getNumberOfComponents(); comp++) { - bulkFug[comp] = system.getPhase(phase).getComponent(comp).getx() - * system.getPhase(phase).getComponent(comp).getFugacityCoefficient() - * system.getPhase(phase).getPressure(); - deltaz[comp] = z0[comp] / (integrationSteps * 1.0); - zField[comp][0] = z0[comp]; - for (int i = 0; i < integrationSteps; i++) { - zField[comp][i] = zField[comp][0] - deltaz[comp] * i; - epsField[comp][i] = eps0[comp] - * Math.pow(Math.log(z0[comp] / zField[comp][i]), 1.0 / beta[comp]); - } - } - for (int i = 0; i < integrationSteps; i++) { - int iter = 0; - double sumx = 0, pressure = 0; - do { - iter++; - sumx = 0.0; - pressure = 0.0; - for (int comp = 0; comp < system.getPhase(phase).getNumberOfComponents(); comp++) { - double correction = Math - .exp(epsField[comp][i] / R / system.getPhase(phase).getTemperature()); - fugacityField[comp][i] = correction * bulkFug[comp]; - double fugComp = - tempSystem.getPhase(phase).getComponent(comp).getFugacityCoefficient() - * tempSystem.getPhase(phase).getPressure(); - corrx[comp] = fugacityField[comp][i] / fugComp; - pressure += fugacityField[comp][i] / tempSystem.getPhase(phase) - .getComponent(comp).getFugacityCoefficient(); - } - for (int comp = 0; comp < system.getPhase(phase).getNumberOfComponents(); comp++) { - tempSystem.getPhase(phase).getComponent(comp).setx(corrx[comp]); - sumx += corrx[comp]; - } - tempSystem.setPressure(pressure); - // tempSystem.getPhase(phase).normalize(); - // tempSystem.calc_x_y(); - tempSystem.init(1); - // System.out.println("pressure " + tempSystem.getPressure() + " error " + - // Math.abs(sumx - 1.0)); - } while (Math.abs(sumx - 1.0) > 1e-12 && iter < 100); - - for (int comp = 0; comp < system.getPhase(phase).getNumberOfComponents(); comp++) { - surfaceExcess[comp] += - deltaz[comp] * (1.0e5 / tempSystem.getPhase(phase).getMolarVolume() - * tempSystem.getPhase(phase).getComponent(comp).getx() - - 1.0e5 / system.getPhase(phase).getMolarVolume() - * system.getPhase(phase).getComponent(comp).getx()); - } - } - - totalSurfaceExcess = 0.0; - for (int comp = 0; comp < system.getPhase(phase).getNumberOfComponents(); comp++) { - totalSurfaceExcess += surfaceExcess[comp]; + double correction = + Math.exp(epsField[comp][i] / R / system.getPhase(phase).getTemperature()); + fugacityField[comp][i] = correction * bulkFug[comp]; + double fugComp = tempSystem.getPhase(phase).getComponent(comp).getFugacityCoefficient() + * tempSystem.getPhase(phase).getPressure(); + corrx[comp] = fugacityField[comp][i] / fugComp; + pressure += fugacityField[comp][i] + / tempSystem.getPhase(phase).getComponent(comp).getFugacityCoefficient(); } for (int comp = 0; comp < system.getPhase(phase).getNumberOfComponents(); comp++) { - surfaceExcessMolFraction[comp] = surfaceExcess[comp] / totalSurfaceExcess; - // logger.info("surface excess molfrac " + surfaceExcessMolFraction[comp] + " - // mol/kg adsorbent " + surfaceExcess[comp]); + tempSystem.getPhase(phase).getComponent(comp).setx(corrx[comp]); + sumx += corrx[comp]; } + tempSystem.setPressure(pressure); + // tempSystem.getPhase(phase).normalize(); + // tempSystem.calc_x_y(); + tempSystem.init(1); + // System.out.println("pressure " + tempSystem.getPressure() + " error " + + // Math.abs(sumx - 1.0)); + } while (Math.abs(sumx - 1.0) > 1e-12 && iter < 100); + + for (int comp = 0; comp < system.getPhase(phase).getNumberOfComponents(); comp++) { + surfaceExcess[comp] += deltaz[comp] * (1.0e5 / tempSystem.getPhase(phase).getMolarVolume() + * tempSystem.getPhase(phase).getComponent(comp).getx() + - 1.0e5 / system.getPhase(phase).getMolarVolume() + * system.getPhase(phase).getComponent(comp).getx()); + } } - /** {@inheritDoc} */ - @Override - public double getSurfaceExcess(String componentName) { - int componentNumber = system.getPhase(0).getComponent(componentName).getComponentNumber(); - return surfaceExcess[componentNumber]; + totalSurfaceExcess = 0.0; + for (int comp = 0; comp < system.getPhase(phase).getNumberOfComponents(); comp++) { + totalSurfaceExcess += surfaceExcess[comp]; } - - /** - *

- * readDBParameters. - *

- */ - public void readDBParameters() { - neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); - java.sql.ResultSet dataSet = null; - for (int comp = 0; comp < system.getPhase(0).getNumberOfComponents(); comp++) { - try { - dataSet = database.getResultSet(("SELECT * FROM adsorptionparameters WHERE name='" - + system.getPhase(0).getComponent(comp).getComponentName() + "' AND Solid='" - + solidMaterial + "'")); - dataSet.next(); - - eps0[comp] = Double.parseDouble(dataSet.getString("eps")); - beta[comp] = Double.parseDouble(dataSet.getString("z0")); - z0[comp] = Double.parseDouble(dataSet.getString("beta")); - - logger.info("adsorption parameters read ok for " - + system.getPhase(0).getComponent(comp).getComponentName() + " eps " - + eps0[comp]); - } catch (Exception e) { - logger.info("Component not found in adsorption DB " - + system.getPhase(0).getComponent(comp).getComponentName() + " on solid " - + solidMaterial); - logger.info("using default parameters"); - eps0[comp] = 7.2; - beta[comp] = 2.0; - z0[comp] = 3.2; - // e.printStackTrace(); - } finally { - try { - if (dataSet != null) { - dataSet.close(); - } - } catch (Exception e) { - logger.error("error closing adsorption database.....", e); - } - } + for (int comp = 0; comp < system.getPhase(phase).getNumberOfComponents(); comp++) { + surfaceExcessMolFraction[comp] = surfaceExcess[comp] / totalSurfaceExcess; + // logger.info("surface excess molfrac " + surfaceExcessMolFraction[comp] + " + // mol/kg adsorbent " + surfaceExcess[comp]); + } + } + + /** {@inheritDoc} */ + @Override + public double getSurfaceExcess(String componentName) { + int componentNumber = system.getPhase(0).getComponent(componentName).getComponentNumber(); + return surfaceExcess[componentNumber]; + } + + /** + *

+ * readDBParameters. + *

+ */ + public void readDBParameters() { + neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); + java.sql.ResultSet dataSet = null; + for (int comp = 0; comp < system.getPhase(0).getNumberOfComponents(); comp++) { + try { + dataSet = database.getResultSet(("SELECT * FROM adsorptionparameters WHERE name='" + + system.getPhase(0).getComponent(comp).getComponentName() + "' AND Solid='" + + solidMaterial + "'")); + dataSet.next(); + + eps0[comp] = Double.parseDouble(dataSet.getString("eps")); + beta[comp] = Double.parseDouble(dataSet.getString("z0")); + z0[comp] = Double.parseDouble(dataSet.getString("beta")); + + logger.info("adsorption parameters read ok for " + + system.getPhase(0).getComponent(comp).getComponentName() + " eps " + eps0[comp]); + } catch (Exception e) { + logger.info("Component not found in adsorption DB " + + system.getPhase(0).getComponent(comp).getComponentName() + " on solid " + + solidMaterial); + logger.info("using default parameters"); + eps0[comp] = 7.2; + beta[comp] = 2.0; + z0[comp] = 3.2; + // e.printStackTrace(); + } finally { + try { + if (dataSet != null) { + dataSet.close(); + } + } catch (Exception e) { + logger.error("error closing adsorption database.....", e); } + } } + } - /** {@inheritDoc} */ - @Override - public double getSurfaceExess(int component) { - return 1.0; - } + /** {@inheritDoc} */ + @Override + public double getSurfaceExess(int component) { + return 1.0; + } } diff --git a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTensionSimple.java b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTensionSimple.java index 550fd004be..1f22f3d5ae 100644 --- a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTensionSimple.java +++ b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTensionSimple.java @@ -17,426 +17,422 @@ * @version $Id: $Id */ public class GTSurfaceTensionSimple extends SurfaceTension { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(GTSurfaceTensionSimple.class); - - int ite_step = 200; - SystemInterface localSystem = null; - double[][] den_interface = null; - double[] z_step = null; - double[] pressure_interface = null; - boolean calcInfluenceParameter = true; - double[] influenceParam; - private double[][][] dmudn2 = null; - - /** - *

- * Constructor for GTSurfaceTensionSimple. - *

- */ - public GTSurfaceTensionSimple() {} - - /** - *

- * Constructor for GTSurfaceTensionSimple. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public GTSurfaceTensionSimple(SystemInterface system) { - super(system); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(GTSurfaceTensionSimple.class); + + int ite_step = 200; + SystemInterface localSystem = null; + double[][] den_interface = null; + double[] z_step = null; + double[] pressure_interface = null; + boolean calcInfluenceParameter = true; + double[] influenceParam; + private double[][][] dmudn2 = null; + + /** + *

+ * Constructor for GTSurfaceTensionSimple. + *

+ */ + public GTSurfaceTensionSimple() {} + + /** + *

+ * Constructor for GTSurfaceTensionSimple. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public GTSurfaceTensionSimple(SystemInterface system) { + super(system); + } + + /** + *

+ * calcInfluenceParameters. + *

+ */ + public void calcInfluenceParameters() { + influenceParam = new double[localSystem.getPhase(0).getNumberOfComponents()]; + for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { + influenceParam[i] = localSystem.getPhase(0).getComponent(i) + .getSurfaceTenisionInfluenceParameter(localSystem.getPhase(0).getTemperature()); + } + } + + /** + * {@inheritDoc} + * + * Calculates the surfacetension using the Gradient Theory for mixtures Units: N/m + */ + @Override + public double calcSurfaceTension(int interface1, int interface2) { + localSystem = system.clone(); + + double surdenstemp = 0.0; + int referenceComponentNumber = getComponentWithHighestBoilingpoint(); // 2; + // //localSystem.getPhase(0).getNumberOfComponents() + // - 1; + double[] del_den_interface = new double[localSystem.getPhase(0).getNumberOfComponents()]; + double[] del_den_interface_old = new double[localSystem.getPhase(0).getNumberOfComponents()]; + double[] mu_equi = new double[localSystem.getPhase(0).getNumberOfComponents()]; + double[][][] dmudn = new double[ite_step][localSystem.getPhase(0) + .getNumberOfComponents()][localSystem.getPhase(0).getNumberOfComponents()]; + dmudn2 = new double[ite_step][localSystem.getPhase(0).getNumberOfComponents()][localSystem + .getPhase(0).getNumberOfComponents()]; + double[][] mu_inter = new double[ite_step][localSystem.getPhase(0).getNumberOfComponents()]; + double[] mu_times_den = new double[ite_step]; + double[][] fmatrix = new double[localSystem.getPhase(0).getNumberOfComponents() + - 1][localSystem.getPhase(0).getNumberOfComponents() - 1]; + double[] bmatrix = new double[localSystem.getPhase(0).getNumberOfComponents() - 1]; + Matrix ans = null; + z_step = new double[ite_step]; + den_interface = new double[ite_step][localSystem.getPhase(0).getNumberOfComponents()]; + pressure_interface = new double[ite_step]; + pressure_interface[0] = 1e5 * system.getPressure(); + + if (calcInfluenceParameter) { + calcInfluenceParameters(); } - /** - *

- * calcInfluenceParameters. - *

- */ - public void calcInfluenceParameters() { - influenceParam = new double[localSystem.getPhase(0).getNumberOfComponents()]; - for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { - influenceParam[i] = localSystem.getPhase(0).getComponent(i) - .getSurfaceTenisionInfluenceParameter(localSystem.getPhase(0).getTemperature()); - } + for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { + mu_equi[i] = system.getPhase(interface1).getComponent(i) + .getChemicalPotential(system.getPhase(interface1)); + den_interface[0][i] = 1e5 * system.getPhase(interface1).getComponent(i).getx() + / system.getPhase(interface1).getMolarVolume(); + localSystem.addComponent(localSystem.getPhase(0).getComponent(i).getName(), + -system.getPhase(0).getComponent(i).getNumberOfmoles()); + localSystem.addComponent(localSystem.getPhase(0).getComponent(i).getName(), + system.getPhase(interface1).getComponent(i).getx() + / system.getPhase(interface1).getMolarVolume()); } - /** - * {@inheritDoc} + del_den_interface[referenceComponentNumber] = + (1e5 * system.getPhase(interface2).getComponent(referenceComponentNumber).getx() + / system.getPhase(interface2).getMolarVolume() + - 1e5 * system.getPhase(interface1).getComponent(referenceComponentNumber).getx() + / system.getPhase(interface1).getMolarVolume()) + / (ite_step * 1.0); + /* + * System.out.println("del den ref " + system.getPhase(interface1).getComponent(0).getx() / + * system.getPhase(interface1).getMolarVolume()); System.out.println("del den ref2 " + + * system.getPhase(interface2).getComponent(0).getx() / + * system.getPhase(interface2).getMolarVolume()); * - * Calculates the surfacetension using the Gradient Theory for mixtures Units: N/m + * System.out.println("del den ref " + system.getPhase(interface1).getComponent(1).getx() / + * system.getPhase(interface1).getMolarVolume()); System.out.println("del den ref2 " + + * system.getPhase(interface2).getComponent(1).getx() / + * system.getPhase(interface2).getMolarVolume()); */ - @Override - public double calcSurfaceTension(int interface1, int interface2) { - localSystem = system.clone(); - - double surdenstemp = 0.0; - int referenceComponentNumber = getComponentWithHighestBoilingpoint();// 2;//localSystem.getPhase(0).getNumberOfComponents() - // - 1; - double[] del_den_interface = new double[localSystem.getPhase(0).getNumberOfComponents()]; - double[] del_den_interface_old = - new double[localSystem.getPhase(0).getNumberOfComponents()]; - double[] mu_equi = new double[localSystem.getPhase(0).getNumberOfComponents()]; - double[][][] dmudn = new double[ite_step][localSystem.getPhase(0) - .getNumberOfComponents()][localSystem.getPhase(0).getNumberOfComponents()]; - dmudn2 = new double[ite_step][localSystem.getPhase(0).getNumberOfComponents()][localSystem - .getPhase(0).getNumberOfComponents()]; - double[][] mu_inter = new double[ite_step][localSystem.getPhase(0).getNumberOfComponents()]; - double[] mu_times_den = new double[ite_step]; - double[][] fmatrix = new double[localSystem.getPhase(0).getNumberOfComponents() - - 1][localSystem.getPhase(0).getNumberOfComponents() - 1]; - double[] bmatrix = new double[localSystem.getPhase(0).getNumberOfComponents() - 1]; - Matrix ans = null; - z_step = new double[ite_step]; - den_interface = new double[ite_step][localSystem.getPhase(0).getNumberOfComponents()]; - pressure_interface = new double[ite_step]; - pressure_interface[0] = 1e5 * system.getPressure(); - - if (calcInfluenceParameter) { - calcInfluenceParameters(); + + localSystem.init(0); + localSystem.setUseTVasIndependentVariables(true); + localSystem.setNumberOfPhases(1); + localSystem.getPhase(0).setTotalVolume(1.0); + localSystem.useVolumeCorrection(false); + localSystem.init_x_y(); + localSystem.init(3); + for (int j = 1; j < ite_step; j++) { + for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { + mu_inter[j][i] = + localSystem.getPhase(0).getComponent(i).getChemicalPotential(localSystem.getPhase(0)); + /* + * if (java.lang.Double.isNaN(mu_inter[j][i])) { double chemicalPotential = + * localSystem.getPhase(0).getComponent(i) .getChemicalPotential(localSystem.getPhase(0)); } + */ + + for (int k = 0; k < localSystem.getPhase(0).getNumberOfComponents(); k++) { + dmudn[j][i][k] = localSystem.getPhase(0).getComponent(i).getChemicalPotentialdNTV(k, + localSystem.getPhase(0)); } + } + int ii = 0; + int kk = 0; + for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { + if (i == referenceComponentNumber) { + continue; + } + bmatrix[ii] = Math.sqrt(influenceParam[referenceComponentNumber]) + * dmudn[j][i][referenceComponentNumber] + - Math.sqrt(influenceParam[i]) + * dmudn[j][referenceComponentNumber][referenceComponentNumber]; + kk = 0; + for (int k = 0; k < localSystem.getPhase(0).getNumberOfComponents(); k++) { + if (k == referenceComponentNumber) { + continue; + } + fmatrix[ii][kk] = Math.sqrt(influenceParam[i]) * dmudn[j][referenceComponentNumber][k] + - Math.sqrt(influenceParam[referenceComponentNumber]) * dmudn[j][i][k]; + kk++; + } + ii++; + } + + if (localSystem.getPhase(0).getNumberOfComponents() > 1) { + Matrix fmatrixJama = new Matrix(fmatrix); + Matrix bmatrixJama = + new Matrix(bmatrix, localSystem.getPhase(0).getNumberOfComponents() - 1); + try { + ans = fmatrixJama.solveTranspose(bmatrixJama.transpose()); + } catch (Exception e) { + logger.error("error", e); + } + } + + int pp = 0; + for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { + if (i != referenceComponentNumber) { + del_den_interface[i] = ans.get(pp, 0) * del_den_interface[referenceComponentNumber]; + if (Math.abs(ans.get(pp, 0)) * del_den_interface[referenceComponentNumber] + / den_interface[j - 1][i] > 0.1) { + del_den_interface[i] = Math.signum(ans.get(pp, 0)) * den_interface[j - 1][i]; + } + pp++; + } + del_den_interface_old[i] = 0; + } + double interact = 1.0; + double err = 1.0; + int iterations = 0; + while (err > 1e-15 && iterations < 1200) { + iterations++; + double totalDens = 0.0; for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { - mu_equi[i] = system.getPhase(interface1).getComponent(i) - .getChemicalPotential(system.getPhase(interface1)); - den_interface[0][i] = 1e5 * system.getPhase(interface1).getComponent(i).getx() - / system.getPhase(interface1).getMolarVolume(); - localSystem.addComponent(localSystem.getPhase(0).getComponent(i).getName(), - -system.getPhase(0).getComponent(i).getNumberOfmoles()); - localSystem.addComponent(localSystem.getPhase(0).getComponent(i).getName(), - system.getPhase(interface1).getComponent(i).getx() - / system.getPhase(interface1).getMolarVolume()); + den_interface[j][i] = den_interface[j - 1][i] + del_den_interface[i]; + totalDens += den_interface[j][i]; + localSystem.addComponent(localSystem.getPhase(0).getComponent(i).getName(), + (del_den_interface[i] - del_den_interface_old[i]) / 1.0e5); + del_den_interface_old[i] = del_den_interface[i]; } - del_den_interface[referenceComponentNumber] = (1e5 - * system.getPhase(interface2).getComponent(referenceComponentNumber).getx() - / system.getPhase(interface2).getMolarVolume() - - 1e5 * system.getPhase(interface1).getComponent(referenceComponentNumber).getx() - / system.getPhase(interface1).getMolarVolume()) - / (ite_step * 1.0); - /* - * System.out.println("del den ref " + system.getPhase(interface1).getComponent(0).getx() / - * system.getPhase(interface1).getMolarVolume()); System.out.println("del den ref2 " + - * system.getPhase(interface2).getComponent(0).getx() / - * system.getPhase(interface2).getMolarVolume()); - * - * System.out.println("del den ref " + system.getPhase(interface1).getComponent(1).getx() / - * system.getPhase(interface1).getMolarVolume()); System.out.println("del den ref2 " + - * system.getPhase(interface2).getComponent(1).getx() / - * system.getPhase(interface2).getMolarVolume()); - */ - - localSystem.init(0); - localSystem.setUseTVasIndependentVariables(true); - localSystem.setNumberOfPhases(1); - localSystem.getPhase(0).setTotalVolume(1.0); - localSystem.useVolumeCorrection(false); localSystem.init_x_y(); localSystem.init(3); - for (int j = 1; j < ite_step; j++) { - for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { - mu_inter[j][i] = localSystem.getPhase(0).getComponent(i) - .getChemicalPotential(localSystem.getPhase(0)); - /* - * if (java.lang.Double.isNaN(mu_inter[j][i])) { double chemicalPotential = - * localSystem.getPhase(0).getComponent(i) - * .getChemicalPotential(localSystem.getPhase(0)); } - */ - - for (int k = 0; k < localSystem.getPhase(0).getNumberOfComponents(); k++) { - dmudn[j][i][k] = localSystem.getPhase(0).getComponent(i) - .getChemicalPotentialdNTV(k, localSystem.getPhase(0)); - } - } - - int ii = 0, kk = 0; - for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { - if (i == referenceComponentNumber) { - continue; - } - bmatrix[ii] = Math.sqrt(influenceParam[referenceComponentNumber]) - * dmudn[j][i][referenceComponentNumber] - - Math.sqrt(influenceParam[i]) - * dmudn[j][referenceComponentNumber][referenceComponentNumber]; - kk = 0; - for (int k = 0; k < localSystem.getPhase(0).getNumberOfComponents(); k++) { - if (k == referenceComponentNumber) { - continue; - } - fmatrix[ii][kk] = Math.sqrt(influenceParam[i]) - * dmudn[j][referenceComponentNumber][k] - - Math.sqrt(influenceParam[referenceComponentNumber]) * dmudn[j][i][k]; - kk++; - } - ii++; - } - if (localSystem.getPhase(0).getNumberOfComponents() > 1) { - Matrix fmatrixJama = new Matrix(fmatrix); - Matrix bmatrixJama = - new Matrix(bmatrix, localSystem.getPhase(0).getNumberOfComponents() - 1); - try { - ans = fmatrixJama.solveTranspose(bmatrixJama.transpose()); - } catch (Exception e) { - logger.error("error", e); - } - } + for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { + mu_inter[j][i] = + localSystem.getPhase(0).getComponent(i).getChemicalPotential(localSystem.getPhase(0)); + for (int k = 0; k < localSystem.getPhase(0).getNumberOfComponents(); k++) { + dmudn[j][i][k] = localSystem.getPhase(0).getComponent(i).getChemicalPotentialdNTV(k, + localSystem.getPhase(0)); + dmudn2[j][i][k] = dmudn[j][i][k]; + } + } - int pp = 0; - for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { - if (i != referenceComponentNumber) { - del_den_interface[i] = - ans.get(pp, 0) * del_den_interface[referenceComponentNumber]; - if (Math.abs(ans.get(pp, 0)) * del_den_interface[referenceComponentNumber] - / den_interface[j - 1][i] > 0.1) { - del_den_interface[i] = - Math.signum(ans.get(pp, 0)) * den_interface[j - 1][i]; - } - pp++; - } - del_den_interface_old[i] = 0; - } - double interact = 1.0; - double err = 1.0; - int iterations = 0; - while (err > 1e-15 && iterations < 1200) { - iterations++; - double totalDens = 0.0; - for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { - den_interface[j][i] = den_interface[j - 1][i] + del_den_interface[i]; - totalDens += den_interface[j][i]; - localSystem.addComponent(localSystem.getPhase(0).getComponent(i).getName(), - (del_den_interface[i] - del_den_interface_old[i]) / 1.0e5); - del_den_interface_old[i] = del_den_interface[i]; - } - - localSystem.init_x_y(); - localSystem.init(3); - - for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { - mu_inter[j][i] = localSystem.getPhase(0).getComponent(i) - .getChemicalPotential(localSystem.getPhase(0)); - for (int k = 0; k < localSystem.getPhase(0).getNumberOfComponents(); k++) { - dmudn[j][i][k] = localSystem.getPhase(0).getComponent(i) - .getChemicalPotentialdNTV(k, localSystem.getPhase(0)); - dmudn2[j][i][k] = dmudn[j][i][k]; - } - } - - ii = 0; - for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { - if (i == referenceComponentNumber) { - continue; - } - bmatrix[ii] = -Math.sqrt(influenceParam[i]) - * (mu_equi[referenceComponentNumber] - - mu_inter[j][referenceComponentNumber]) - + Math.sqrt(influenceParam[referenceComponentNumber]) - * (mu_equi[i] - mu_inter[j][i]); - kk = 0; - for (int k = 0; k < localSystem.getPhase(0).getNumberOfComponents(); k++) { - if (k == referenceComponentNumber) { - continue; - } - fmatrix[ii][kk] = -Math.sqrt(influenceParam[i]) - * dmudn[j][referenceComponentNumber][k] - + Math.sqrt(influenceParam[referenceComponentNumber]) - * dmudn[j][i][k]; - kk++; - } - ii++; - } - RealMatrix ans2 = null; - RealMatrix bRealMatrix = new Array2DRowRealMatrix(bmatrix); - if (localSystem.getPhase(0).getNumberOfComponents() > 1) { - // BigMatrixImpl fmatrixJama = new BigMatrixImpl(fmatrix); - RealMatrix fmatrixJama = new Array2DRowRealMatrix(fmatrix); - // Matrix fmatrixJama = new Matrix(fmatrix); - // BigMatrixImpl bmatrixJama = new BigMatrixImpl(bmatrix); - // Matrix bmatrixJama = new Matrix(bmatrix, - // localSystem.getPhase(0).getNumberOfComponents() - 1); - try { - // ans = fmatrixJama.solveTranspose(bmatrixJama.transpose()); - // ans2 = new BigMatrixImpl(fmatrixJama.solve(bmatrix)); - DecompositionSolver solver1 = - new org.apache.commons.math3.linear.LUDecomposition(fmatrixJama) - .getSolver(); - ans2 = solver1.solve(bRealMatrix); - } catch (Exception e) { - logger.error("error", e); - } - } - - pp = 0; - err = 0.0; - for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { - if (i != referenceComponentNumber) { - err += Math.abs(ans2.getEntry(pp, 0) * 1e5) / totalDens; - del_den_interface[i] += 1e5 * ans2.getEntry(pp, 0);// * (iterations) / (10.0 - // + iterations); - pp++; - } - } - } - // System.out.println("err " + err); - - pressure_interface[j] = 1e5 * localSystem.getPhase(0).getPressure(); - mu_times_den[j] = 0.0; - double kappa = 0.0, kappai = 0.0, kappak = 0.0; - for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { - double infli = influenceParam[i]; // localSystem.getPhase(0).getComponent(i).getSurfaceTenisionInfluenceParameter(localSystem.getPhase(0).getTemperature()); - kappai = del_den_interface[i] / del_den_interface[referenceComponentNumber]; - mu_times_den[j] += den_interface[j][i] * (mu_inter[j][i] - mu_equi[i]); - for (int k = 0; k < localSystem.getPhase(0).getNumberOfComponents(); k++) { - if ((localSystem.getPhase(0).getComponent(i).getName().equals("water") - || localSystem.getPhase(0).getComponent(k).getName().equals("water")) - && i != k) { - interact = 0.0; - } else { - interact = 0.0; - } - double inflk = influenceParam[k]; // localSystem.getPhase(0).getComponent(k).getSurfaceTenisionInfluenceParameter(localSystem.getPhase(0).getTemperature()); - kappak = del_den_interface[k] / del_den_interface[referenceComponentNumber]; - kappa += Math.sqrt(infli * inflk) * kappai * kappak * (1.0 - interact); - } - } - mu_times_den[j] += -(pressure_interface[j] - pressure_interface[0]); - z_step[j] = z_step[j - 1] + Math.sqrt(kappa / (2.0 * mu_times_den[j])) - * del_den_interface[referenceComponentNumber]; - if (Double.isNaN(z_step[j])) { - break; + ii = 0; + for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { + if (i == referenceComponentNumber) { + continue; + } + bmatrix[ii] = -Math.sqrt(influenceParam[i]) + * (mu_equi[referenceComponentNumber] - mu_inter[j][referenceComponentNumber]) + + Math.sqrt(influenceParam[referenceComponentNumber]) * (mu_equi[i] - mu_inter[j][i]); + kk = 0; + for (int k = 0; k < localSystem.getPhase(0).getNumberOfComponents(); k++) { + if (k == referenceComponentNumber) { + continue; } - surdenstemp += Math.sqrt(2.0 * kappa * mu_times_den[j]) - * del_den_interface[referenceComponentNumber];// * - // thermo.ThermodynamicConstantsInterface.avagadroNumber; + fmatrix[ii][kk] = -Math.sqrt(influenceParam[i]) * dmudn[j][referenceComponentNumber][k] + + Math.sqrt(influenceParam[referenceComponentNumber]) * dmudn[j][i][k]; + kk++; + } + ii++; } - - // System.out.println("del den ref " + - // localSystem.getPhase(interface1).getComponent(0).getx() / - // localSystem.getPhase(interface1).getMolarVolume() ); - - for (int j = 0; j < ite_step; j++) { - // System.out.println("z " + z_step[j] + " density " + j + " " + - // den_interface[j][0] + " mu_times_den[j] " + mu_times_den[j]+ " - // pressure_interface[j] " + pressure_interface[j] + " "+ - // pressure_interface[0]);// + " " + den_interface[j][1] + " " + - // den_interface[j][0] / den_interface[j][1]); + RealMatrix ans2 = null; + RealMatrix bRealMatrix = new Array2DRowRealMatrix(bmatrix); + if (localSystem.getPhase(0).getNumberOfComponents() > 1) { + // BigMatrixImpl fmatrixJama = new BigMatrixImpl(fmatrix); + RealMatrix fmatrixJama = new Array2DRowRealMatrix(fmatrix); + // Matrix fmatrixJama = new Matrix(fmatrix); + // BigMatrixImpl bmatrixJama = new BigMatrixImpl(bmatrix); + // Matrix bmatrixJama = new Matrix(bmatrix, + // localSystem.getPhase(0).getNumberOfComponents() - 1); + try { + // ans = fmatrixJama.solveTranspose(bmatrixJama.transpose()); + // ans2 = new BigMatrixImpl(fmatrixJama.solve(bmatrix)); + DecompositionSolver solver1 = + new org.apache.commons.math3.linear.LUDecomposition(fmatrixJama).getSolver(); + ans2 = solver1.solve(bRealMatrix); + } catch (Exception e) { + logger.error("error", e); + } } - // System.out.println("end "); - return Math.abs(surdenstemp); - } - - /** - *

- * getMolarDensity. - *

- * - * @param compnum a int - * @return an array of {@link double} objects - */ - public double[] getMolarDensity(int compnum) { - double[] temp = new double[ite_step]; - for (int i = 0; i < ite_step; i++) { - temp[i] = den_interface[i][compnum]; + pp = 0; + err = 0.0; + for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { + if (i != referenceComponentNumber) { + err += Math.abs(ans2.getEntry(pp, 0) * 1e5) / totalDens; + del_den_interface[i] += 1e5 * ans2.getEntry(pp, 0); // * (iterations) / + // (10.0 + // + iterations); + pp++; + } } - return temp; - } - - /** - *

- * getMolarDensityTotal. - *

- * - * @return an array of {@link double} objects - */ - public double[] getMolarDensityTotal() { - double[] temp = new double[ite_step]; - for (int i = 0; i < ite_step; i++) { - for (int j = 0; j < system.getPhase(0).getNumberOfComponents(); j++) { - temp[i] += den_interface[i][j]; - } + } + // System.out.println("err " + err); + + pressure_interface[j] = 1e5 * localSystem.getPhase(0).getPressure(); + mu_times_den[j] = 0.0; + double kappa = 0.0; + double kappai = 0.0; + double kappak = 0.0; + for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { + double infli = influenceParam[i]; // localSystem.getPhase(0).getComponent(i).getSurfaceTenisionInfluenceParameter(localSystem.getPhase(0).getTemperature()); + kappai = del_den_interface[i] / del_den_interface[referenceComponentNumber]; + mu_times_den[j] += den_interface[j][i] * (mu_inter[j][i] - mu_equi[i]); + for (int k = 0; k < localSystem.getPhase(0).getNumberOfComponents(); k++) { + if ((localSystem.getPhase(0).getComponent(i).getName().equals("water") + || localSystem.getPhase(0).getComponent(k).getName().equals("water")) && i != k) { + interact = 0.0; + } else { + interact = 0.0; + } + double inflk = influenceParam[k]; // localSystem.getPhase(0).getComponent(k).getSurfaceTenisionInfluenceParameter(localSystem.getPhase(0).getTemperature()); + kappak = del_den_interface[k] / del_den_interface[referenceComponentNumber]; + kappa += Math.sqrt(infli * inflk) * kappai * kappak * (1.0 - interact); } - return temp; - } - - /** - *

- * getz. - *

- * - * @return an array of {@link double} objects - */ - public double[] getz() { - return z_step; + } + mu_times_den[j] += -(pressure_interface[j] - pressure_interface[0]); + z_step[j] = z_step[j - 1] + Math.sqrt(kappa / (2.0 * mu_times_den[j])) + * del_den_interface[referenceComponentNumber]; + if (Double.isNaN(z_step[j])) { + break; + } + surdenstemp += + Math.sqrt(2.0 * kappa * mu_times_den[j]) * del_den_interface[referenceComponentNumber]; // * + // thermo.ThermodynamicConstantsInterface.avagadroNumber; } - /** - *

- * getPressure. - *

- * - * @return an array of {@link double} objects - */ - public double[] getPressure() { - return pressure_interface; - } + // System.out.println("del den ref " + + // localSystem.getPhase(interface1).getComponent(0).getx() / + // localSystem.getPhase(interface1).getMolarVolume() ); - /** - *

- * getInfluenceParameter. - *

- * - * @param interfaceTension a double - * @param componentNumber a int - * @return a double - */ - public double getInfluenceParameter(double interfaceTension, int componentNumber) { - // double startGuess = calcSurfaceTension(0, 1); - double oldInfluenceParameter = influenceParam[componentNumber]; - double calcVal = 0.0, oldCalcVal = 0.0, dSurfTensdinfluence = 0.0; - int iter = 0; - calcInfluenceParameter = true; - calcVal = calcSurfaceTension(0, 1) - interfaceTension; - do { - iter++; - oldCalcVal = calcVal; - // System.out.println("surface tenison " + calcSurfaceTension(0, 1) + " error " - // + calcVal + " influenceParam " + influenceParam[componentNumber]); - calcInfluenceParameter = false; - if (iter > 1) { - influenceParam[componentNumber] -= (calcVal) / dSurfTensdinfluence; - } else { - influenceParam[componentNumber] *= 1.01; - } - calcVal = calcSurfaceTension(0, 1) - interfaceTension; - - dSurfTensdinfluence = (calcVal - oldCalcVal) - / (influenceParam[componentNumber] - oldInfluenceParameter); - oldInfluenceParameter = influenceParam[componentNumber]; - } while (Math.abs(calcVal / interfaceTension) > 1e-8 && iter < 100); - calcInfluenceParameter = true; - return influenceParam[componentNumber]; + for (int j = 0; j < ite_step; j++) { + // System.out.println("z " + z_step[j] + " density " + j + " " + + // den_interface[j][0] + " mu_times_den[j] " + mu_times_den[j]+ " + // pressure_interface[j] " + pressure_interface[j] + " "+ + // pressure_interface[0]); // + " " + den_interface[j][1] + " " + + // den_interface[j][0] / den_interface[j][1]); } - /** - *

- * Getter for the field dmudn2. - *

- * - * @return the dmudn2 - */ - public double[][][] getDmudn2() { - return dmudn2; + // System.out.println("end "); + return Math.abs(surdenstemp); + } + + /** + *

+ * getMolarDensity. + *

+ * + * @param compnum a int + * @return an array of {@link double} objects + */ + public double[] getMolarDensity(int compnum) { + double[] temp = new double[ite_step]; + for (int i = 0; i < ite_step; i++) { + temp[i] = den_interface[i][compnum]; } - - /** - *

- * Setter for the field dmudn2. - *

- * - * @param dmudn2 the dmudn2 to set - */ - public void setDmudn2(double[][][] dmudn2) { - this.dmudn2 = dmudn2; + return temp; + } + + /** + *

+ * getMolarDensityTotal. + *

+ * + * @return an array of {@link double} objects + */ + public double[] getMolarDensityTotal() { + double[] temp = new double[ite_step]; + for (int i = 0; i < ite_step; i++) { + for (int j = 0; j < system.getPhase(0).getNumberOfComponents(); j++) { + temp[i] += den_interface[i][j]; + } } + return temp; + } + + /** + *

+ * getz. + *

+ * + * @return an array of {@link double} objects + */ + public double[] getz() { + return z_step; + } + + /** + *

+ * getPressure. + *

+ * + * @return an array of {@link double} objects + */ + public double[] getPressure() { + return pressure_interface; + } + + /** + *

+ * getInfluenceParameter. + *

+ * + * @param interfaceTension a double + * @param componentNumber a int + * @return a double + */ + public double getInfluenceParameter(double interfaceTension, int componentNumber) { + // double startGuess = calcSurfaceTension(0, 1); + double oldInfluenceParameter = influenceParam[componentNumber]; + double calcVal = 0.0; + double oldCalcVal = 0.0; + double dSurfTensdinfluence = 0.0; + int iter = 0; + calcInfluenceParameter = true; + calcVal = calcSurfaceTension(0, 1) - interfaceTension; + do { + iter++; + oldCalcVal = calcVal; + // System.out.println("surface tenison " + calcSurfaceTension(0, 1) + " error " + // + calcVal + " influenceParam " + influenceParam[componentNumber]); + calcInfluenceParameter = false; + if (iter > 1) { + influenceParam[componentNumber] -= (calcVal) / dSurfTensdinfluence; + } else { + influenceParam[componentNumber] *= 1.01; + } + calcVal = calcSurfaceTension(0, 1) - interfaceTension; + + dSurfTensdinfluence = + (calcVal - oldCalcVal) / (influenceParam[componentNumber] - oldInfluenceParameter); + oldInfluenceParameter = influenceParam[componentNumber]; + } while (Math.abs(calcVal / interfaceTension) > 1e-8 && iter < 100); + calcInfluenceParameter = true; + return influenceParam[componentNumber]; + } + + /** + *

+ * Getter for the field dmudn2. + *

+ * + * @return the dmudn2 + */ + public double[][][] getDmudn2() { + return dmudn2; + } + + /** + *

+ * Setter for the field dmudn2. + *

+ * + * @param dmudn2 the dmudn2 to set + */ + public void setDmudn2(double[][][] dmudn2) { + this.dmudn2 = dmudn2; + } } diff --git a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/LGTSurfaceTension.java b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/LGTSurfaceTension.java index e718750ff2..d31acf512d 100644 --- a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/LGTSurfaceTension.java +++ b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/LGTSurfaceTension.java @@ -11,248 +11,244 @@ * @version $Id: $Id */ public class LGTSurfaceTension extends SurfaceTension { - private static final long serialVersionUID = 1000; - - int ite_step = 200; - SystemInterface localSystem = null; - double[][] den_interface = null; - double[] z_step = null; - double[] pressure_interface = null; - - /** - *

- * Constructor for LGTSurfaceTension. - *

- */ - public LGTSurfaceTension() {} - - /** - *

- * Constructor for LGTSurfaceTension. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public LGTSurfaceTension(SystemInterface system) { - super(system); + private static final long serialVersionUID = 1000; + + int ite_step = 200; + SystemInterface localSystem = null; + double[][] den_interface = null; + double[] z_step = null; + double[] pressure_interface = null; + + /** + *

+ * Constructor for LGTSurfaceTension. + *

+ */ + public LGTSurfaceTension() {} + + /** + *

+ * Constructor for LGTSurfaceTension. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public LGTSurfaceTension(SystemInterface system) { + super(system); + } + + /** + * {@inheritDoc} + * + * Calculates the surfacetension using the Gradient Theory for mixtures Units: N/m + */ + @Override + public double calcSurfaceTension(int interface1, int interface2) { + double surdenstemp = 0.0; + localSystem = system.clone(); + + int referenceComponentNumber = getComponentWithHighestBoilingpoint(); + // double influenceParamReferenceComponent = + // localSystem.getPhase(0).getComponent(referenceComponentNumber).getSurfaceTenisionInfluenceParameter(localSystem.getPhase(0).getTemperature()); + double pressure_equi = 1e5 * system.getPressure(); + + den_interface = new double[ite_step][localSystem.getPhase(0).getNumberOfComponents()]; + pressure_interface = new double[ite_step]; + pressure_interface[0] = pressure_equi; + double[] del_den_interface = new double[localSystem.getPhase(0).getNumberOfComponents()]; + double[] del_den_interface_old = new double[localSystem.getPhase(0).getNumberOfComponents()]; + + double[] mu_equi = new double[localSystem.getPhase(0).getNumberOfComponents()]; + double[][][] dmudn = new double[ite_step][localSystem.getPhase(0) + .getNumberOfComponents()][localSystem.getPhase(0).getNumberOfComponents()]; + + double[][] mu_inter = new double[ite_step][localSystem.getPhase(0).getNumberOfComponents()]; + // double[][][] dmudn_equi = new + // double[ite_step][localSystem.getPhase(0).getNumberOfComponents()][localSystem.getPhase(0).getNumberOfComponents()]; + + double[] mu_times_den = new double[ite_step]; + z_step = new double[ite_step]; + + for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { + mu_equi[i] = system.getPhase(interface1).getComponent(i) + .getChemicalPotential(system.getPhase(interface1)); + den_interface[0][i] = 1e5 * system.getPhase(interface1).getComponent(i).getx() + / system.getPhase(interface1).getMolarVolume(); + den_interface[ite_step - 1][i] = 1e5 * system.getPhase(interface2).getComponent(i).getx() + / system.getPhase(interface2).getMolarVolume(); + del_den_interface[i] = (1e5 * system.getPhase(interface2).getComponent(i).getx() + / system.getPhase(interface2).getMolarVolume() + - 1e5 * system.getPhase(interface1).getComponent(i).getx() + / system.getPhase(interface1).getMolarVolume()) + / (ite_step * 1.0); + del_den_interface_old[i] = 0.0; + localSystem.addComponent(localSystem.getPhase(0).getComponent(i).getName(), + -system.getPhase(0).getComponent(i).getNumberOfmoles()); + localSystem.addComponent(localSystem.getPhase(0).getComponent(i).getName(), + system.getPhase(interface1).getComponent(i).getx() + / system.getPhase(interface1).getMolarVolume()); } - /** - * {@inheritDoc} - * - * Calculates the surfacetension using the Gradient Theory for mixtures Units: N/m - */ - @Override - public double calcSurfaceTension(int interface1, int interface2) { - double surdenstemp = 0.0; - localSystem = system.clone(); - - int referenceComponentNumber = getComponentWithHighestBoilingpoint(); - // double influenceParamReferenceComponent = - // localSystem.getPhase(0).getComponent(referenceComponentNumber).getSurfaceTenisionInfluenceParameter(localSystem.getPhase(0).getTemperature()); - double pressure_equi = 1e5 * system.getPressure(); - - den_interface = new double[ite_step][localSystem.getPhase(0).getNumberOfComponents()]; - pressure_interface = new double[ite_step]; - pressure_interface[0] = pressure_equi; - double[] del_den_interface = new double[localSystem.getPhase(0).getNumberOfComponents()]; - double[] del_den_interface_old = - new double[localSystem.getPhase(0).getNumberOfComponents()]; - - double[] mu_equi = new double[localSystem.getPhase(0).getNumberOfComponents()]; - double[][][] dmudn = new double[ite_step][localSystem.getPhase(0) - .getNumberOfComponents()][localSystem.getPhase(0).getNumberOfComponents()]; - - double[][] mu_inter = new double[ite_step][localSystem.getPhase(0).getNumberOfComponents()]; - // double[][][] dmudn_equi = new - // double[ite_step][localSystem.getPhase(0).getNumberOfComponents()][localSystem.getPhase(0).getNumberOfComponents()]; - - double[] mu_times_den = new double[ite_step]; - z_step = new double[ite_step]; - - for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { - mu_equi[i] = system.getPhase(interface1).getComponent(i) - .getChemicalPotential(system.getPhase(interface1)); - den_interface[0][i] = 1e5 * system.getPhase(interface1).getComponent(i).getx() - / system.getPhase(interface1).getMolarVolume(); - den_interface[ite_step - 1][i] = - 1e5 * system.getPhase(interface2).getComponent(i).getx() - / system.getPhase(interface2).getMolarVolume(); - del_den_interface[i] = (1e5 * system.getPhase(interface2).getComponent(i).getx() - / system.getPhase(interface2).getMolarVolume() - - 1e5 * system.getPhase(interface1).getComponent(i).getx() - / system.getPhase(interface1).getMolarVolume()) - / (ite_step * 1.0); - del_den_interface_old[i] = 0.0; - localSystem.addComponent(localSystem.getPhase(0).getComponent(i).getName(), - -system.getPhase(0).getComponent(i).getNumberOfmoles()); - localSystem.addComponent(localSystem.getPhase(0).getComponent(i).getName(), - system.getPhase(interface1).getComponent(i).getx() - / system.getPhase(interface1).getMolarVolume()); + localSystem.init(0); + localSystem.setUseTVasIndependentVariables(true); + localSystem.setNumberOfPhases(1); + localSystem.getPhase(0).setTotalVolume(1.0); + localSystem.useVolumeCorrection(false); + localSystem.initBeta(); + localSystem.init_x_y(); + localSystem.init(3); + + // localSystem.display(); + // System.out.println("inerface1 + " + interface1 + " pressure " + + // localSystem.getPressure()); + + for (int j = 1; j < ite_step; j++) { + for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { + del_den_interface[i] = (1e5 * system.getPhase(interface2).getComponent(i).getx() + / system.getPhase(interface2).getMolarVolume() + - 1e5 * system.getPhase(interface1).getComponent(i).getx() + / system.getPhase(interface1).getMolarVolume()) + / (ite_step * 1.0); + del_den_interface_old[i] = 0.0; + } + + for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { + den_interface[j][i] = den_interface[j - 1][i] + del_den_interface[i]; + localSystem.addComponent(localSystem.getPhase(0).getComponent(i).getName(), + (del_den_interface[i] - del_den_interface_old[i]) / 1.0e5); + del_den_interface_old[i] = del_den_interface[i]; + } + + localSystem.init_x_y(); + localSystem.init(3); + // localSystem.init(3); //need to be fixed + // System.out.println("pressure " + localSystem.getPressure()); + for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { + mu_inter[j][i] = + localSystem.getPhase(0).getComponent(i).getChemicalPotential(localSystem.getPhase(0)); + for (int k = 0; k < localSystem.getPhase(0).getNumberOfComponents(); k++) { + dmudn[j][i][k] = localSystem.getPhase(0).getComponent(i).getChemicalPotentialdNTV(k, + localSystem.getPhase(0)); + } + } + + pressure_interface[j] = 1e5 * localSystem.getPhase(0).getPressure(); + + mu_times_den[j] = 0.0; + double kappa = 0.0; + double kappai = 0.0; + double kappak = 0.0; + double interact = 1.0; + for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { + double infli = localSystem.getPhase(0).getComponent(i) + .getSurfaceTenisionInfluenceParameter(localSystem.getPhase(0).getTemperature()); + + if (i == referenceComponentNumber) { + kappai = 1.0; + } else { + kappai = del_den_interface[i] / del_den_interface[referenceComponentNumber]; } - localSystem.init(0); - localSystem.setUseTVasIndependentVariables(true); - localSystem.setNumberOfPhases(1); - localSystem.getPhase(0).setTotalVolume(1.0); - localSystem.useVolumeCorrection(false); - localSystem.initBeta(); - localSystem.init_x_y(); - localSystem.init(3); - - // localSystem.display(); - // System.out.println("inerface1 + " + interface1 + " pressure " + - // localSystem.getPressure()); - - for (int j = 1; j < ite_step; j++) { - for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { - del_den_interface[i] = (1e5 * system.getPhase(interface2).getComponent(i).getx() - / system.getPhase(interface2).getMolarVolume() - - 1e5 * system.getPhase(interface1).getComponent(i).getx() - / system.getPhase(interface1).getMolarVolume()) - / (ite_step * 1.0); - del_den_interface_old[i] = 0.0; - } - - for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { - den_interface[j][i] = den_interface[j - 1][i] + del_den_interface[i]; - localSystem.addComponent(localSystem.getPhase(0).getComponent(i).getName(), - (del_den_interface[i] - del_den_interface_old[i]) / 1.0e5); - del_den_interface_old[i] = del_den_interface[i]; - } - - localSystem.init_x_y(); - localSystem.init(3); - // localSystem.init(3);//need to be fixed - // System.out.println("pressure " + localSystem.getPressure()); - for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { - mu_inter[j][i] = localSystem.getPhase(0).getComponent(i) - .getChemicalPotential(localSystem.getPhase(0)); - for (int k = 0; k < localSystem.getPhase(0).getNumberOfComponents(); k++) { - dmudn[j][i][k] = localSystem.getPhase(0).getComponent(i) - .getChemicalPotentialdNTV(k, localSystem.getPhase(0)); - } - } - - pressure_interface[j] = 1e5 * localSystem.getPhase(0).getPressure(); - - mu_times_den[j] = 0.0; - double kappa = 0.0, kappai = 0.0, kappak = 0.0; - double interact = 1.0; - for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) { - double infli = localSystem.getPhase(0).getComponent(i) - .getSurfaceTenisionInfluenceParameter( - localSystem.getPhase(0).getTemperature()); - - if (i == referenceComponentNumber) { - kappai = 1.0; - } else { - kappai = del_den_interface[i] / del_den_interface[referenceComponentNumber]; - } - - mu_times_den[j] += den_interface[j][i] * (mu_inter[j][i] - mu_equi[i]); - for (int k = 0; k < localSystem.getPhase(0).getNumberOfComponents(); k++) { - if ((localSystem.getPhase(0).getComponent(i).getName().equals("water") - || localSystem.getPhase(0).getComponent(k).getName().equals("water")) - && i != k) { - if ((localSystem.getPhase(0).getComponent(i).getName().equals("MEG") - || localSystem.getPhase(0).getComponent(k).getName().equals("MEG")) - && i != k) { - interact = 0.2; - } else { - interact = 0.35; - } - } else { - interact = 0.0; - } - - double inflk = localSystem.getPhase(0).getComponent(k) - .getSurfaceTenisionInfluenceParameter( - localSystem.getPhase(0).getTemperature()); - - if (k == referenceComponentNumber) { - kappak = 1.0; - } else { - kappak = del_den_interface[k] / del_den_interface[referenceComponentNumber]; - } - - kappa += Math.sqrt(infli * inflk) * kappai * kappak * (1.0 - interact); - } + mu_times_den[j] += den_interface[j][i] * (mu_inter[j][i] - mu_equi[i]); + for (int k = 0; k < localSystem.getPhase(0).getNumberOfComponents(); k++) { + if ((localSystem.getPhase(0).getComponent(i).getName().equals("water") + || localSystem.getPhase(0).getComponent(k).getName().equals("water")) && i != k) { + if ((localSystem.getPhase(0).getComponent(i).getName().equals("MEG") + || localSystem.getPhase(0).getComponent(k).getName().equals("MEG")) && i != k) { + interact = 0.2; + } else { + interact = 0.35; } - mu_times_den[j] += -(pressure_interface[j] - pressure_equi); - z_step[j] = z_step[j - 1] + Math.sqrt(kappa / (2.0 * mu_times_den[j])) - * del_den_interface[referenceComponentNumber]; - if (Double.isNaN(z_step[j])) { - break; - } - surdenstemp += Math.sqrt(2.0 * kappa * mu_times_den[j]) - * del_den_interface[referenceComponentNumber];// * - // thermo.ThermodynamicConstantsInterface.avagadroNumber; - // System.out.println("surdenstemp " + surdenstemp + " kappa " + kappa + " - // mu_times_den[j] " + mu_times_den[j] + " z " + z_step[j]); - } + } else { + interact = 0.0; + } - for (int j = 0; j < ite_step; j++) { - // System.out.println("z " + z_step[j] + " density " + j + " " + - // den_interface[j][0] + " " + den_interface[j][1] + " " + den_interface[j][0] / - // den_interface[j][1]); - } + double inflk = localSystem.getPhase(0).getComponent(k) + .getSurfaceTenisionInfluenceParameter(localSystem.getPhase(0).getTemperature()); - return Math.abs(surdenstemp); - } + if (k == referenceComponentNumber) { + kappak = 1.0; + } else { + kappak = del_den_interface[k] / del_den_interface[referenceComponentNumber]; + } - /** - *

- * getMolarDensity. - *

- * - * @param compnum a int - * @return an array of {@link double} objects - */ - public double[] getMolarDensity(int compnum) { - double[] temp = new double[ite_step]; - for (int i = 0; i < ite_step; i++) { - temp[i] = den_interface[i][compnum]; + kappa += Math.sqrt(infli * inflk) * kappai * kappak * (1.0 - interact); } - return temp; + } + mu_times_den[j] += -(pressure_interface[j] - pressure_equi); + z_step[j] = z_step[j - 1] + Math.sqrt(kappa / (2.0 * mu_times_den[j])) + * del_den_interface[referenceComponentNumber]; + if (Double.isNaN(z_step[j])) { + break; + } + surdenstemp += + Math.sqrt(2.0 * kappa * mu_times_den[j]) * del_den_interface[referenceComponentNumber]; // * + // thermo.ThermodynamicConstantsInterface.avagadroNumber; + // System.out.println("surdenstemp " + surdenstemp + " kappa " + kappa + " + // mu_times_den[j] " + mu_times_den[j] + " z " + z_step[j]); } - /** - *

- * getMolarDensityTotal. - *

- * - * @return an array of {@link double} objects - */ - public double[] getMolarDensityTotal() { - double[] temp = new double[ite_step]; - for (int i = 0; i < ite_step; i++) { - for (int j = 0; j < system.getPhase(0).getNumberOfComponents(); j++) { - temp[i] += den_interface[i][j]; - } - } - return temp; + for (int j = 0; j < ite_step; j++) { + // System.out.println("z " + z_step[j] + " density " + j + " " + + // den_interface[j][0] + " " + den_interface[j][1] + " " + den_interface[j][0] / + // den_interface[j][1]); } - /** - *

- * getz. - *

- * - * @return an array of {@link double} objects - */ - public double[] getz() { - return z_step; + return Math.abs(surdenstemp); + } + + /** + *

+ * getMolarDensity. + *

+ * + * @param compnum a int + * @return an array of {@link double} objects + */ + public double[] getMolarDensity(int compnum) { + double[] temp = new double[ite_step]; + for (int i = 0; i < ite_step; i++) { + temp[i] = den_interface[i][compnum]; } - - /** - *

- * getPressure. - *

- * - * @return an array of {@link double} objects - */ - public double[] getPressure() { - return pressure_interface; + return temp; + } + + /** + *

+ * getMolarDensityTotal. + *

+ * + * @return an array of {@link double} objects + */ + public double[] getMolarDensityTotal() { + double[] temp = new double[ite_step]; + for (int i = 0; i < ite_step; i++) { + for (int j = 0; j < system.getPhase(0).getNumberOfComponents(); j++) { + temp[i] += den_interface[i][j]; + } } + return temp; + } + + /** + *

+ * getz. + *

+ * + * @return an array of {@link double} objects + */ + public double[] getz() { + return z_step; + } + + /** + *

+ * getPressure. + *

+ * + * @return an array of {@link double} objects + */ + public double[] getPressure() { + return pressure_interface; + } } diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/conductivity/PFCTConductivityMethodMod86.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/conductivity/PFCTConductivityMethodMod86.java index 506b2e9164..209b97fa49 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/conductivity/PFCTConductivityMethodMod86.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/conductivity/PFCTConductivityMethodMod86.java @@ -18,12 +18,26 @@ public class PFCTConductivityMethodMod86 extends Conductivity { public static SystemInterface referenceSystem = new SystemSrkEos(273.0, 1.01325); double[] GVcoef = {-2.147621e5, 2.190461e5, -8.618097e4, 1.496099e4, -4.730660e2, -2.331178e2, 3.778439e1, -2.320481, 5.311764e-2}; - double condRefA = -0.25276292, condRefB = 0.33432859, condRefC = 1.12, condRefF = 168.0, - condRefE = 1.0, condRefG = 0.0; - double condRefJ[] = {-7.04036339907, 12.319512908, -8.8525979933e2, 72.835897919, 0.74421462902, + double condRefA = -0.25276292; + + double condRefB = 0.33432859; + + double condRefC = 1.12; + + double condRefF = 168.0; + + double condRefE = 1.0; + + double condRefG = 0.0; + + double[] condRefJ = {-7.04036339907, 12.319512908, -8.8525979933e2, 72.835897919, 0.74421462902, -2.9706914540, 2.2209758501e3}; - double condRefK[] = {-8.55109, 12.5539, -1020.85, 238.394, 1.31563, -72.5759, 1411.6}; - double PCmix = 0.0, TCmix = 0.0, Mmix = 0.0; + double[] condRefK = {-8.55109, 12.5539, -1020.85, 238.394, 1.31563, -72.5759, 1411.6}; + double PCmix = 0.0; + + double TCmix = 0.0; + + double Mmix = 0.0; /** *

@@ -53,15 +67,19 @@ public PFCTConductivityMethodMod86( /** {@inheritDoc} */ @Override public double calcConductivity() { - double Pc0 = referenceSystem.getPhase(0).getComponent(0).getPC(), - Tc0 = referenceSystem.getPhase(0).getComponent(0).getTC(), - M0 = referenceSystem.getPhase(0).getComponent(0).getMolarMass() * 1e3; + double Pc0 = referenceSystem.getPhase(0).getComponent(0).getPC(); - double alfa0 = 1.0, alfaMix = 1.0; - double tempTC1 = 0.0, tempTC2 = 0.0; - double tempPC1 = 0.0, tempPC2 = 0.0; - double Mwtemp = 0.0, Mmtemp = 0.0; + double Tc0 = referenceSystem.getPhase(0).getComponent(0).getTC(); + double M0 = referenceSystem.getPhase(0).getComponent(0).getMolarMass() * 1e3; + double alfa0 = 1.0; + double alfaMix = 1.0; + double tempTC1 = 0.0; + double tempTC2 = 0.0; + double tempPC1 = 0.0; + double tempPC2 = 0.0; + double Mwtemp = 0.0; + double Mmtemp = 0.0; for (int i = 0; i < phase.getPhase().getNumberOfComponents(); i++) { for (int j = 0; j < phase.getPhase().getNumberOfComponents(); j++) { double tempVar = @@ -134,9 +152,10 @@ public double calcConductivity() { * Math.sqrt(alphai[i] * alphai[j]); } } - if (alfaMix < 1e-10) + if (alfaMix < 1e-10) { return 0.0; // this can happen befor init is doen on system - // alfaMix= alfaMix*2; + // alfaMix= alfaMix*2; + } double T0 = phase.getPhase().getTemperature() * referenceSystem.getPhase(0).getComponent(0).getTC() / TCmix * alfa0 / alfaMix; @@ -154,7 +173,7 @@ public double calcConductivity() { - 0.029725 * redDens * redDens * redDens; double condIntRef = (1.18653 * nstarRef * (CpID - 2.5 * neqsim.thermo.ThermodynamicConstantsInterface.R) - * Ffunc) / (referenceSystem.getMolarMass());// *1e3; + * Ffunc) / (referenceSystem.getMolarMass()); // *1e3; double nstarMix = calcMixLPViscosity(); double FfuncMix = 1.0 + 0.053432 * redDens - 0.030182 * redDens * redDens @@ -162,7 +181,7 @@ public double calcConductivity() { double CpIDmix = phase.getPhase().getCp0(); double condIntMix = (1.18653 * nstarMix * (CpIDmix - 2.5 * neqsim.thermo.ThermodynamicConstantsInterface.R) - * FfuncMix) / (Mmix / 1.0e3);// *1e3; + * FfuncMix) / (Mmix / 1.0e3); // *1e3; double refConductivity = getRefComponentConductivity(T0, P0); @@ -238,7 +257,7 @@ public double getRefComponentViscosity(double temp, double pres) { double[] GVcoef = {-2.090975e5, 2.647269e5, -1.472818e5, 4.716740e4, -9.491872e3, 1.219979e3, -9.627993e1, 4.274152, -8.141531e-2}; double visRefE = 1.0; - double viscRefJ[] = {-1.035060586e1, 1.7571599671e1, -3.0193918656e3, 1.8873011594e2, + double[] viscRefJ = {-1.035060586e1, 1.7571599671e1, -3.0193918656e3, 1.8873011594e2, 4.2903609488e-2, 1.4529023444e2, 6.1276818706e3}; // double viscRefK[] = {-9.74602, 18.0834, -4126.66, 44.6055, 0.9676544, 81.8134, 15649.9}; @@ -276,10 +295,10 @@ public double getRefComponentViscosity(double temp, double pres) { * @return a double */ public double calcMixLPViscosity() { - double Pc0 = referenceSystem.getPhase(0).getComponent(0).getPC(), - Tc0 = referenceSystem.getPhase(0).getComponent(0).getTC(), - M0 = referenceSystem.getPhase(0).getComponent(0).getMolarMass() * 1e3; + double Pc0 = referenceSystem.getPhase(0).getComponent(0).getPC(); + double Tc0 = referenceSystem.getPhase(0).getComponent(0).getTC(); + double M0 = referenceSystem.getPhase(0).getComponent(0).getMolarMass() * 1e3; // double PCmix = 0.0, TCmix = 0.0, Mmix = 0.0; /* * for (int i = 0; i < phase.getPhase().getNumberOfComponents(); i++) { for (int j = 0; j < @@ -301,7 +320,8 @@ public double calcMixLPViscosity() { * //phase.getPhase().getMolarMass(); */ double redDens = 101325 / 8.315 / phase.getPhase().getTemperature() / 1.0e3 / 10.15; - double alfa0 = 0.0, alfaMix = 0.0; + double alfa0 = 0.0; + double alfaMix = 0.0; double[] alphai = new double[phase.getPhase().getNumberOfComponents()]; for (int i = 0; i < phase.getPhase().getNumberOfComponents(); i++) { alphai[i] = 1.0 + 6.004e-4 * Math.pow(redDens, 2.043) diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethod.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethod.java index 0c3113fab7..e814dc981a 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethod.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethod.java @@ -18,160 +18,170 @@ * @version Method was checked on 2.8.2001 - seems to be correct - Even Solbraa */ public class PFCTViscosityMethod extends Viscosity { - private static final long serialVersionUID = 1000; - - int phaseTypeNumb = 1; - SystemInterface referenceSystem = new SystemSrkEos(273.0, 1.01325); - double[] GVcoef = {-2.090975e5, 2.647269e5, -1.472818e5, 4.716740e4, -9.491872e3, 1.219979e3, - -9.627993e1, 4.274152, -8.141531e-2}; - double visRefA = 1.696985927, visRefB = -0.133372346, visRefC = 1.4, visRefF = 168.0, - visRefE = 1.0; - double viscRefJ[] = {-1.035060586e1, 1.7571599671e1, -3.0193918656e3, 1.8873011594e2, - 4.2903609488e-2, 1.4529023444e2, 6.1276818706e3}; - - /** - *

- * Constructor for PFCTViscosityMethod. - *

- */ - public PFCTViscosityMethod() {} - - /** - *

- * Constructor for PFCTViscosityMethod. - *

- * - * @param phase a - * {@link neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface} - * object - */ - public PFCTViscosityMethod( - neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface phase) { - super(phase); - referenceSystem.addComponent("methane", 10.0); - referenceSystem.init(0); + private static final long serialVersionUID = 1000; + + int phaseTypeNumb = 1; + SystemInterface referenceSystem = new SystemSrkEos(273.0, 1.01325); + double[] GVcoef = {-2.090975e5, 2.647269e5, -1.472818e5, 4.716740e4, -9.491872e3, 1.219979e3, + -9.627993e1, 4.274152, -8.141531e-2}; + double visRefA = 1.696985927; + + double visRefB = -0.133372346; + + double visRefC = 1.4; + + double visRefF = 168.0; + + double visRefE = 1.0; + + double[] viscRefJ = {-1.035060586e1, 1.7571599671e1, -3.0193918656e3, 1.8873011594e2, + 4.2903609488e-2, 1.4529023444e2, 6.1276818706e3}; + + /** + *

+ * Constructor for PFCTViscosityMethod. + *

+ */ + public PFCTViscosityMethod() {} + + /** + *

+ * Constructor for PFCTViscosityMethod. + *

+ * + * @param phase a + * {@link neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface} + * object + */ + public PFCTViscosityMethod( + neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface phase) { + super(phase); + referenceSystem.addComponent("methane", 10.0); + referenceSystem.init(0); + } + + /** {@inheritDoc} */ + @Override + public double calcViscosity() { + int phaseTypeNumb = 0; + // if(phase.getPhase().getPhaseType()==0) phaseTypeNumb=1; + + double Pc0 = referenceSystem.getPhase(0).getComponent(0).getPC(); + + double Tc0 = referenceSystem.getPhase(0).getComponent(0).getTC(); + double M0 = referenceSystem.getPhase(0).getComponent(0).getMolarMass() * 1e3; + double PCmix = 0.0; + double TCmix = 0.0; + double Mmix = 0.0; + double alfa0 = 1.0; + double alfaMix = 1.0; + double tempTC1 = 0.0; + double tempTC2 = 0.0; + double tempPC1 = 0.0; + double tempPC2 = 0.0; + double Mwtemp = 0.0; + + double Mmtemp = 0.0; + for (int i = 0; i < phase.getPhase().getNumberOfComponents(); i++) { + for (int j = 0; j < phase.getPhase().getNumberOfComponents(); j++) { + double tempVar = phase.getPhase().getComponent(i).getx() + * phase.getPhase().getComponent(j).getx() + * Math.pow(Math + .pow(phase.getPhase().getComponent(i).getTC() + / phase.getPhase().getComponent(i).getPC(), 1.0 / 3.0) + + Math.pow(phase.getPhase().getComponent(j).getTC() + / phase.getPhase().getComponent(j).getPC(), 1.0 / 3.0), + 3.0); + tempTC1 += tempVar * Math.sqrt( + phase.getPhase().getComponent(i).getTC() * phase.getPhase().getComponent(j).getTC()); + tempTC2 += tempVar; + tempPC1 += tempVar * Math.sqrt( + phase.getPhase().getComponent(i).getTC() * phase.getPhase().getComponent(j).getTC()); + tempPC2 += tempVar; + } + Mwtemp += phase.getPhase().getComponent(i).getx() + * Math.pow(phase.getPhase().getComponent(i).getMolarMass(), 2.0); + Mmtemp += + phase.getPhase().getComponent(i).getx() * phase.getPhase().getComponent(i).getMolarMass(); } - /** {@inheritDoc} */ - @Override - public double calcViscosity() { - int phaseTypeNumb = 0; - // if(phase.getPhase().getPhaseType()==0) phaseTypeNumb=1; - - double Pc0 = referenceSystem.getPhase(0).getComponent(0).getPC(), - Tc0 = referenceSystem.getPhase(0).getComponent(0).getTC(), - M0 = referenceSystem.getPhase(0).getComponent(0).getMolarMass() * 1e3; - - double PCmix = 0.0, TCmix = 0.0, Mmix = 0.0; - double alfa0 = 1.0, alfaMix = 1.0; - double tempTC1 = 0.0, tempTC2 = 0.0; - double tempPC1 = 0.0, tempPC2 = 0.0; - double Mwtemp = 0.0, Mmtemp = 0.0; - - for (int i = 0; i < phase.getPhase().getNumberOfComponents(); i++) { - for (int j = 0; j < phase.getPhase().getNumberOfComponents(); j++) { - double tempVar = phase.getPhase().getComponent(i).getx() - * phase.getPhase().getComponent(j).getx() - * Math.pow(Math - .pow(phase.getPhase().getComponent(i).getTC() - / phase.getPhase().getComponent(i).getPC(), 1.0 / 3.0) - + Math.pow( - phase.getPhase().getComponent(j).getTC() - / phase.getPhase().getComponent(j).getPC(), - 1.0 / 3.0), - 3.0); - tempTC1 += tempVar * Math.sqrt(phase.getPhase().getComponent(i).getTC() - * phase.getPhase().getComponent(j).getTC()); - tempTC2 += tempVar; - tempPC1 += tempVar * Math.sqrt(phase.getPhase().getComponent(i).getTC() - * phase.getPhase().getComponent(j).getTC()); - tempPC2 += tempVar; - } - Mwtemp += phase.getPhase().getComponent(i).getx() - * Math.pow(phase.getPhase().getComponent(i).getMolarMass(), 2.0); - Mmtemp += phase.getPhase().getComponent(i).getx() - * phase.getPhase().getComponent(i).getMolarMass(); - } - - PCmix = 8.0 * tempPC1 / (tempPC2 * tempPC2); - TCmix = tempTC1 / tempTC2; - Mmix = (Mmtemp + 0.291 * (Mwtemp / Mmtemp - Mmtemp)) * 1e3; // phase.getPhase().getMolarMass(); - - referenceSystem.setTemperature(phase.getPhase().getTemperature() - * referenceSystem.getPhase(0).getComponent(0).getTC() / TCmix); - referenceSystem.setPressure(phase.getPhase().getPressure() - * referenceSystem.getPhase(0).getComponent(0).getPC() / PCmix); - referenceSystem.init(1); - double molDens = 1.0 / referenceSystem.getPhase(phaseTypeNumb).getMolarVolume() * 100.0; - double critMolDens = 10.15;// 1.0/referenceSystem.getPhase(0).getComponent(0).getCriticalVolume(); - double redDens = molDens / critMolDens; - - alfaMix = 1.0 + 7.475e-5 * Math.pow(redDens, 4.265) * Math.pow(Mmix, 0.8579); - alfa0 = 1.0 + 8.374e-4 * Math.pow(redDens, 4.265); - // System.out.println("func " + 7.475e-5*Math.pow(16.043, 0.8579)); - double T0 = phase.getPhase().getTemperature() - * referenceSystem.getPhase(0).getComponent(0).getTC() / TCmix * alfa0 / alfaMix; - double P0 = phase.getPhase().getPressure() - * referenceSystem.getPhase(0).getComponent(0).getPC() / PCmix * alfa0 / alfaMix; - - double refVisosity = getRefComponentViscosity(T0, P0); - // System.out.println("m/mix " + Mmix/M0); - // System.out.println("a/amix " + alfaMix/alfa0); - double viscosity = refVisosity * Math.pow(TCmix / Tc0, -1.0 / 6.0) - * Math.pow(PCmix / Pc0, 2.0 / 3.0) * Math.pow(Mmix / M0, 0.5) * alfaMix / alfa0; - return viscosity; - } - - /** {@inheritDoc} */ - @Override - public double getPureComponentViscosity(int i) { - return 0; - } - - /** - *

- * getRefComponentViscosity. - *

- * - * @param temp a double - * @param pres a double - * @return a double - */ - public double getRefComponentViscosity(double temp, double pres) { - referenceSystem.setTemperature(temp); - // System.out.println("ref temp " + temp); - referenceSystem.setPressure(pres); - // System.out.println("ref pres " + pres); - referenceSystem.init(1); - double molDens = 1.0 / referenceSystem.getPhase(phaseTypeNumb).getMolarVolume() * 100.0; - // System.out.println("mol dens " + molDens); - double critMolDens = 10.15;// 1.0/referenceSystem.getPhase(0).getComponent(0).getCriticalVolume(); - double redMolDens = (molDens - critMolDens) / critMolDens; - // System.out.println("gv1 " +GVcoef[0]); - - molDens = referenceSystem.getPhase(phaseTypeNumb).getDensity() * 1e-3; - - double viscRefO = GVcoef[0] * Math.pow(temp, -1.0) + GVcoef[1] * Math.pow(temp, -2.0 / 3.0) - + GVcoef[2] * Math.pow(temp, -1.0 / 3.0) + GVcoef[3] - + GVcoef[4] * Math.pow(temp, 1.0 / 3.0) + GVcoef[5] * Math.pow(temp, 2.0 / 3.0) - + GVcoef[6] * temp + GVcoef[7] * Math.pow(temp, 4.0 / 3.0) - + GVcoef[8] * Math.pow(temp, 5.0 / 3.0); - - // System.out.println("ref visc0 " + viscRefO); - - double viscRef1 = - (visRefA + visRefB * Math.pow(visRefC - Math.log(temp / visRefF), 2.0)) * molDens; - // System.out.println("ref visc1 " + viscRef1); - - double temp1 = - Math.pow(molDens, 0.1) * (viscRefJ[1] + viscRefJ[2] / Math.pow(temp, 3.0 / 2.0)); - double temp2 = redMolDens * Math.pow(molDens, 0.5) - * (viscRefJ[4] + viscRefJ[5] / temp + viscRefJ[6] / Math.pow(temp, 2.0)); - double temp3 = Math.exp(temp1 + temp2); - double viscRef2 = visRefE * Math.exp(viscRefJ[0] + viscRefJ[3] / temp) * (temp3 - 1.0); - // System.out.println("ref visc2 " + viscRef2); - double refVisc = (viscRefO + viscRef1 + viscRef2) / 1.0e7; - // System.out.println("ref visc " + refVisc); - return refVisc; - } + PCmix = 8.0 * tempPC1 / (tempPC2 * tempPC2); + TCmix = tempTC1 / tempTC2; + Mmix = (Mmtemp + 0.291 * (Mwtemp / Mmtemp - Mmtemp)) * 1e3; // phase.getPhase().getMolarMass(); + + referenceSystem.setTemperature(phase.getPhase().getTemperature() + * referenceSystem.getPhase(0).getComponent(0).getTC() / TCmix); + referenceSystem.setPressure(phase.getPhase().getPressure() + * referenceSystem.getPhase(0).getComponent(0).getPC() / PCmix); + referenceSystem.init(1); + double molDens = 1.0 / referenceSystem.getPhase(phaseTypeNumb).getMolarVolume() * 100.0; + double critMolDens = 10.15; // 1.0/referenceSystem.getPhase(0).getComponent(0).getCriticalVolume(); + double redDens = molDens / critMolDens; + + alfaMix = 1.0 + 7.475e-5 * Math.pow(redDens, 4.265) * Math.pow(Mmix, 0.8579); + alfa0 = 1.0 + 8.374e-4 * Math.pow(redDens, 4.265); + // System.out.println("func " + 7.475e-5*Math.pow(16.043, 0.8579)); + double T0 = phase.getPhase().getTemperature() + * referenceSystem.getPhase(0).getComponent(0).getTC() / TCmix * alfa0 / alfaMix; + double P0 = phase.getPhase().getPressure() * referenceSystem.getPhase(0).getComponent(0).getPC() + / PCmix * alfa0 / alfaMix; + + double refVisosity = getRefComponentViscosity(T0, P0); + // System.out.println("m/mix " + Mmix/M0); + // System.out.println("a/amix " + alfaMix/alfa0); + double viscosity = refVisosity * Math.pow(TCmix / Tc0, -1.0 / 6.0) + * Math.pow(PCmix / Pc0, 2.0 / 3.0) * Math.pow(Mmix / M0, 0.5) * alfaMix / alfa0; + return viscosity; + } + + /** {@inheritDoc} */ + @Override + public double getPureComponentViscosity(int i) { + return 0; + } + + /** + *

+ * getRefComponentViscosity. + *

+ * + * @param temp a double + * @param pres a double + * @return a double + */ + public double getRefComponentViscosity(double temp, double pres) { + referenceSystem.setTemperature(temp); + // System.out.println("ref temp " + temp); + referenceSystem.setPressure(pres); + // System.out.println("ref pres " + pres); + referenceSystem.init(1); + double molDens = 1.0 / referenceSystem.getPhase(phaseTypeNumb).getMolarVolume() * 100.0; + // System.out.println("mol dens " + molDens); + double critMolDens = 10.15; // 1.0/referenceSystem.getPhase(0).getComponent(0).getCriticalVolume(); + double redMolDens = (molDens - critMolDens) / critMolDens; + // System.out.println("gv1 " +GVcoef[0]); + + molDens = referenceSystem.getPhase(phaseTypeNumb).getDensity() * 1e-3; + + double viscRefO = GVcoef[0] * Math.pow(temp, -1.0) + GVcoef[1] * Math.pow(temp, -2.0 / 3.0) + + GVcoef[2] * Math.pow(temp, -1.0 / 3.0) + GVcoef[3] + GVcoef[4] * Math.pow(temp, 1.0 / 3.0) + + GVcoef[5] * Math.pow(temp, 2.0 / 3.0) + GVcoef[6] * temp + + GVcoef[7] * Math.pow(temp, 4.0 / 3.0) + GVcoef[8] * Math.pow(temp, 5.0 / 3.0); + + // System.out.println("ref visc0 " + viscRefO); + + double viscRef1 = + (visRefA + visRefB * Math.pow(visRefC - Math.log(temp / visRefF), 2.0)) * molDens; + // System.out.println("ref visc1 " + viscRef1); + + double temp1 = Math.pow(molDens, 0.1) * (viscRefJ[1] + viscRefJ[2] / Math.pow(temp, 3.0 / 2.0)); + double temp2 = redMolDens * Math.pow(molDens, 0.5) + * (viscRefJ[4] + viscRefJ[5] / temp + viscRefJ[6] / Math.pow(temp, 2.0)); + double temp3 = Math.exp(temp1 + temp2); + double viscRef2 = visRefE * Math.exp(viscRefJ[0] + viscRefJ[3] / temp) * (temp3 - 1.0); + // System.out.println("ref visc2 " + viscRef2); + double refVisc = (viscRefO + viscRef1 + viscRef2) / 1.0e7; + // System.out.println("ref visc " + refVisc); + return refVisc; + } } diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethodHeavyOil.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethodHeavyOil.java index 5c471711b5..3525602c57 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethodHeavyOil.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethodHeavyOil.java @@ -12,212 +12,221 @@ * @version Method was checked on 2.8.2001 - seems to be correct - Even Solbraa */ public class PFCTViscosityMethodHeavyOil extends Viscosity { - private static final long serialVersionUID = 1000; - - // SystemInterface referenceSystem = new SystemBWRSEos(273.15, 1.01325); - SystemInterface referenceSystem = new SystemSrkEos(273.0, 1.01325); - int phaseTypeNumb = 1; - double[] GVcoef = {-2.090975e5, 2.647269e5, -1.472818e5, 4.716740e4, -9.491872e3, 1.219979e3, - -9.627993e1, 4.274152, -8.141531e-2}; - double visRefA = 1.696985927, visRefB = -0.133372346, visRefC = 1.4, visRefF = 168.0, - visRefE = 1.0, visRefG = 0.0; - double viscRefJ[] = {-1.035060586e1, 1.7571599671e1, -3.0193918656e3, 1.8873011594e2, - 4.2903609488e-2, 1.4529023444e2, 6.1276818706e3}; - double viscRefK[] = {-9.74602, 18.0834, -4126.66, 44.6055, 0.976544, 81.8134, 15649.9}; - - /** - *

- * Constructor for PFCTViscosityMethodHeavyOil. - *

- */ - public PFCTViscosityMethodHeavyOil() {} - - /** - *

- * Constructor for PFCTViscosityMethodHeavyOil. - *

- * - * @param phase a - * {@link neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface} - * object - */ - public PFCTViscosityMethodHeavyOil( - neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface phase) { - super(phase); - if (referenceSystem.getNumberOfMoles() < 1e-10) { - referenceSystem.addComponent("methane", 10.0); - referenceSystem.init(0); - } + private static final long serialVersionUID = 1000; + + // SystemInterface referenceSystem = new SystemBWRSEos(273.15, 1.01325); + SystemInterface referenceSystem = new SystemSrkEos(273.0, 1.01325); + int phaseTypeNumb = 1; + double[] GVcoef = {-2.090975e5, 2.647269e5, -1.472818e5, 4.716740e4, -9.491872e3, 1.219979e3, + -9.627993e1, 4.274152, -8.141531e-2}; + double visRefA = 1.696985927; + + double visRefB = -0.133372346; + + double visRefC = 1.4; + + double visRefF = 168.0; + + double visRefE = 1.0; + + double visRefG = 0.0; + + double[] viscRefJ = {-1.035060586e1, 1.7571599671e1, -3.0193918656e3, 1.8873011594e2, + 4.2903609488e-2, 1.4529023444e2, 6.1276818706e3}; + double[] viscRefK = {-9.74602, 18.0834, -4126.66, 44.6055, 0.976544, 81.8134, 15649.9}; + + /** + *

+ * Constructor for PFCTViscosityMethodHeavyOil. + *

+ */ + public PFCTViscosityMethodHeavyOil() {} + + /** + *

+ * Constructor for PFCTViscosityMethodHeavyOil. + *

+ * + * @param phase a + * {@link neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface} + * object + */ + public PFCTViscosityMethodHeavyOil( + neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface phase) { + super(phase); + if (referenceSystem.getNumberOfMoles() < 1e-10) { + referenceSystem.addComponent("methane", 10.0); + referenceSystem.init(0); } - - /** {@inheritDoc} */ - @Override - public double calcViscosity() { - this.calcPureComponentViscosity(); - - double Pc0 = referenceSystem.getPhase(0).getComponent(0).getPC(), - Tc0 = referenceSystem.getPhase(0).getComponent(0).getTC(), - M0 = referenceSystem.getPhase(0).getComponent(0).getMolarMass() * 1e3; - - double PCmix = 0.0, TCmix = 0.0, Mmix = 0.0; - double alfa0 = 1.0, alfaMix = 1.0; - double tempTC1 = 0.0, tempTC2 = 0.0; - double tempPC1 = 0.0, tempPC2 = 0.0; - double Mwtemp = 0.0, Mmtemp = 0.0; - - for (int i = 0; i < phase.getPhase().getNumberOfComponents(); i++) { - for (int j = 0; j < phase.getPhase().getNumberOfComponents(); j++) { - double tempVar = phase.getPhase().getComponent(i).getx() - * phase.getPhase().getComponent(j).getx() - * Math.pow(Math - .pow(phase.getPhase().getComponent(i).getTC() - / phase.getPhase().getComponent(i).getPC(), 1.0 / 3.0) - + Math.pow( - phase.getPhase().getComponent(j).getTC() - / phase.getPhase().getComponent(j).getPC(), - 1.0 / 3.0), - 3.0); - tempTC1 += tempVar * Math.sqrt(phase.getPhase().getComponent(i).getTC() - * phase.getPhase().getComponent(j).getTC()); - tempTC2 += tempVar; - tempPC1 += tempVar * Math.sqrt(phase.getPhase().getComponent(i).getTC() - * phase.getPhase().getComponent(j).getTC()); - tempPC2 += tempVar; - } - Mwtemp += phase.getPhase().getComponent(i).getx() - * Math.pow(phase.getPhase().getComponent(i).getMolarMass(), 2.0); - Mmtemp += phase.getPhase().getComponent(i).getx() - * phase.getPhase().getComponent(i).getMolarMass(); - } - if (tempTC2 < 1e-10) { - return 0.0; - } - PCmix = 8.0 * tempPC1 / (tempPC2 * tempPC2); - TCmix = tempTC1 / tempTC2; - Mmix = (Mmtemp + 1.304e-4 * (Math.pow(Mwtemp / Mmtemp, 2.303) - Math.pow(Mmtemp, 2.303))) - * 1e3; // phase.getPhase().getMolarMass(); - - referenceSystem.setTemperature(phase.getPhase().getTemperature() - * referenceSystem.getPhase(0).getComponent(0).getTC() / TCmix); - referenceSystem.setPressure(phase.getPhase().getPressure() - * referenceSystem.getPhase(0).getComponent(0).getPC() / PCmix); - referenceSystem.init(1); - // double molDens = 1.0 / - // referenceSystem.getPhase(phaseTypeNumb).getMolarVolume() * 100.0; - double molDens = 1.0 / referenceSystem.getLowestGibbsEnergyPhase().getMolarVolume() * 100.0; - double critMolDens = 10.15;// 1.0/referenceSystem.getPhase(0).getComponent(0).getCriticalVolume(); - double redDens = molDens / critMolDens; - - alfaMix = 1.0 + 7.378e-3 * Math.pow(redDens, 1.847) * Math.pow(Mmix, 0.5173); - alfa0 = 1.0 + 7.378e-3 * Math.pow(redDens, 1.847) - * Math.pow(referenceSystem.getMolarMass() * 1.0e3, 0.5173); - // alfa0 = 1.0 + 8.374e-4 * Math.pow(redDens, 4.265); - // System.out.println("func " + 7.475e-5*Math.pow(16.043, 0.8579)); - double T0 = phase.getPhase().getTemperature() - * referenceSystem.getPhase(0).getComponent(0).getTC() / TCmix * alfa0 / alfaMix; - double P0 = phase.getPhase().getPressure() - * referenceSystem.getPhase(0).getComponent(0).getPC() / PCmix * alfa0 / alfaMix; - double refVisosity = 0.0; - if (T0 < 75.0) { - double molM = 0.0; - if (Mwtemp / Mmtemp / Mmtemp <= 1.5) { - molM = Mmtemp * 1e3; - } else { - molM = Mmtemp * Math.pow(Mwtemp / Mmtemp / (1.5 * Mmtemp), 0.5) * 1e3; - } - double sign = 1.0; - if (phase.getPhase().getTemperature() > 564.49) { - sign = -1.0; - } - double termm = - -0.07955 - sign * 0.01101 * molM - 371.8 / phase.getPhase().getTemperature() - + 6.215 * molM / phase.getPhase().getTemperature(); - double HOviscosity = Math.pow(10.0, termm) * 1.0e-3; - HOviscosity += HOviscosity * 0.008 * (phase.getPhase().getPressure() - 1.0); - // refVisosity = refVisosity * Math.exp(0.00384 * - // (Math.pow(phase.getPhase().getPressure(),0.8226) - 1.0) / 0.8226); - - if (T0 < 65) { - return HOviscosity; - } - - refVisosity = getRefComponentViscosity(T0, P0); - double LOviscosity = refVisosity * Math.pow(TCmix / Tc0, -1.0 / 6.0) - * Math.pow(PCmix / Pc0, 2.0 / 3.0) * Math.pow(Mmix / M0, 0.5) * alfaMix / alfa0; - return LOviscosity * (1.0 - (75 - T0) / 10.0) + HOviscosity * (75.0 - T0) / 10.0; - } - // System.out.println("m/mix " + Mmix/M0); - // System.out.println("a/amix " + alfaMix/alfa0); - refVisosity = getRefComponentViscosity(T0, P0); - double viscosity = refVisosity * Math.pow(TCmix / Tc0, -1.0 / 6.0) - * Math.pow(PCmix / Pc0, 2.0 / 3.0) * Math.pow(Mmix / M0, 0.5) * alfaMix / alfa0; - // System.out.println("viscosityLO " + viscosity); - - return viscosity; + } + + /** {@inheritDoc} */ + @Override + public double calcViscosity() { + this.calcPureComponentViscosity(); + + double Pc0 = referenceSystem.getPhase(0).getComponent(0).getPC(); + + double Tc0 = referenceSystem.getPhase(0).getComponent(0).getTC(); + double M0 = referenceSystem.getPhase(0).getComponent(0).getMolarMass() * 1e3; + double PCmix = 0.0; + double TCmix = 0.0; + double Mmix = 0.0; + double alfa0 = 1.0; + double alfaMix = 1.0; + double tempTC1 = 0.0; + double tempTC2 = 0.0; + double tempPC1 = 0.0; + double tempPC2 = 0.0; + double Mwtemp = 0.0; + + double Mmtemp = 0.0; + for (int i = 0; i < phase.getPhase().getNumberOfComponents(); i++) { + for (int j = 0; j < phase.getPhase().getNumberOfComponents(); j++) { + double tempVar = phase.getPhase().getComponent(i).getx() + * phase.getPhase().getComponent(j).getx() + * Math.pow(Math + .pow(phase.getPhase().getComponent(i).getTC() + / phase.getPhase().getComponent(i).getPC(), 1.0 / 3.0) + + Math.pow(phase.getPhase().getComponent(j).getTC() + / phase.getPhase().getComponent(j).getPC(), 1.0 / 3.0), + 3.0); + tempTC1 += tempVar * Math.sqrt( + phase.getPhase().getComponent(i).getTC() * phase.getPhase().getComponent(j).getTC()); + tempTC2 += tempVar; + tempPC1 += tempVar * Math.sqrt( + phase.getPhase().getComponent(i).getTC() * phase.getPhase().getComponent(j).getTC()); + tempPC2 += tempVar; + } + Mwtemp += phase.getPhase().getComponent(i).getx() + * Math.pow(phase.getPhase().getComponent(i).getMolarMass(), 2.0); + Mmtemp += + phase.getPhase().getComponent(i).getx() * phase.getPhase().getComponent(i).getMolarMass(); } - - /** - *

- * getRefComponentViscosity. - *

- * - * @param temp a double - * @param pres a double - * @return a double - */ - public double getRefComponentViscosity(double temp, double pres) { - referenceSystem.setTemperature(temp); - // System.out.println("ref temp " + temp); - referenceSystem.setPressure(pres); - // System.out.println("ref pres " + pres); - referenceSystem.init(1); - // referenceSystem.display(); - // double molDens = 1.0 / - // referenceSystem.getPhase(phaseTypeNumb).getMolarVolume() * 100.0; - double molDens = 1.0 / referenceSystem.getLowestGibbsEnergyPhase().getMolarVolume() * 100.0; // mol/dm^3 - // System.out.println("mol dens " + molDens); - double critMolDens = 10.15;// 1.0/referenceSystem.getPhase(0).getComponent(0).getCriticalVolume(); - double redMolDens = (molDens - critMolDens) / critMolDens; - // System.out.println("gv1 " +GVcoef[0]); - - molDens = referenceSystem.getLowestGibbsEnergyPhase().getDensity() * 1e-3; - - double viscRefO = GVcoef[0] * Math.pow(temp, -1.0) + GVcoef[1] * Math.pow(temp, -2.0 / 3.0) - + GVcoef[2] * Math.pow(temp, -1.0 / 3.0) + GVcoef[3] - + GVcoef[4] * Math.pow(temp, 1.0 / 3.0) + GVcoef[5] * Math.pow(temp, 2.0 / 3.0) - + GVcoef[6] * temp + GVcoef[7] * Math.pow(temp, 4.0 / 3.0) - + GVcoef[8] * Math.pow(temp, 5.0 / 3.0); - - // System.out.println("ref visc0 " + viscRefO); - double viscRef1 = - (visRefA + visRefB * Math.pow(visRefC - Math.log(temp / visRefF), 2.0)) * molDens; - // System.out.println("ref visc1 " + viscRef1); - - double temp1 = - Math.pow(molDens, 0.1) * (viscRefJ[1] + viscRefJ[2] / Math.pow(temp, 3.0 / 2.0)); - double temp2 = redMolDens * Math.pow(molDens, 0.5) - * (viscRefJ[4] + viscRefJ[5] / temp + viscRefJ[6] / Math.pow(temp, 2.0)); - double temp3 = Math.exp(temp1 + temp2); - - double dTfreeze = temp - 90.69; - double HTAN = (Math.exp(dTfreeze) - Math.exp(-dTfreeze)) - / (Math.exp(dTfreeze) + Math.exp(-dTfreeze)); - visRefE = (HTAN + 1.0) / 2.0; - - double viscRef2 = visRefE * Math.exp(viscRefJ[0] + viscRefJ[3] / temp) * (temp3 - 1.0); - - double temp4 = - Math.pow(molDens, 0.1) * (viscRefK[1] + viscRefK[2] / Math.pow(temp, 3.0 / 2.0)); - double temp5 = redMolDens * Math.pow(molDens, 0.5) - * (viscRefK[4] + viscRefK[5] / temp + viscRefK[6] / Math.pow(temp, 2.0)); - double temp6 = Math.exp(temp4 + temp5); - visRefG = (1.0 - HTAN) / 2.0; - double viscRef3 = visRefG * Math.exp(viscRefK[0] + viscRefK[3] / temp) * (temp6 - 1.0); - - // System.out.println("ref visc2 " + viscRef2); - // System.out.println("ref visc3 " + viscRef3); - double refVisc = (viscRefO + viscRef1 + viscRef2 + viscRef3) / 1.0e7; - // System.out.println("ref visc " + refVisc); - return refVisc; + if (tempTC2 < 1e-10) { + return 0.0; + } + PCmix = 8.0 * tempPC1 / (tempPC2 * tempPC2); + TCmix = tempTC1 / tempTC2; + Mmix = (Mmtemp + 1.304e-4 * (Math.pow(Mwtemp / Mmtemp, 2.303) - Math.pow(Mmtemp, 2.303))) * 1e3; // phase.getPhase().getMolarMass(); + + referenceSystem.setTemperature(phase.getPhase().getTemperature() + * referenceSystem.getPhase(0).getComponent(0).getTC() / TCmix); + referenceSystem.setPressure(phase.getPhase().getPressure() + * referenceSystem.getPhase(0).getComponent(0).getPC() / PCmix); + referenceSystem.init(1); + // double molDens = 1.0 / + // referenceSystem.getPhase(phaseTypeNumb).getMolarVolume() * 100.0; + double molDens = 1.0 / referenceSystem.getLowestGibbsEnergyPhase().getMolarVolume() * 100.0; + double critMolDens = 10.15; // 1.0/referenceSystem.getPhase(0).getComponent(0).getCriticalVolume(); + double redDens = molDens / critMolDens; + + alfaMix = 1.0 + 7.378e-3 * Math.pow(redDens, 1.847) * Math.pow(Mmix, 0.5173); + alfa0 = 1.0 + 7.378e-3 * Math.pow(redDens, 1.847) + * Math.pow(referenceSystem.getMolarMass() * 1.0e3, 0.5173); + // alfa0 = 1.0 + 8.374e-4 * Math.pow(redDens, 4.265); + // System.out.println("func " + 7.475e-5*Math.pow(16.043, 0.8579)); + double T0 = phase.getPhase().getTemperature() + * referenceSystem.getPhase(0).getComponent(0).getTC() / TCmix * alfa0 / alfaMix; + double P0 = phase.getPhase().getPressure() * referenceSystem.getPhase(0).getComponent(0).getPC() + / PCmix * alfa0 / alfaMix; + double refVisosity = 0.0; + if (T0 < 75.0) { + double molM = 0.0; + if (Mwtemp / Mmtemp / Mmtemp <= 1.5) { + molM = Mmtemp * 1e3; + } else { + molM = Mmtemp * Math.pow(Mwtemp / Mmtemp / (1.5 * Mmtemp), 0.5) * 1e3; + } + double sign = 1.0; + if (phase.getPhase().getTemperature() > 564.49) { + sign = -1.0; + } + double termm = -0.07955 - sign * 0.01101 * molM - 371.8 / phase.getPhase().getTemperature() + + 6.215 * molM / phase.getPhase().getTemperature(); + double HOviscosity = Math.pow(10.0, termm) * 1.0e-3; + HOviscosity += HOviscosity * 0.008 * (phase.getPhase().getPressure() - 1.0); + // refVisosity = refVisosity * Math.exp(0.00384 * + // (Math.pow(phase.getPhase().getPressure(),0.8226) - 1.0) / 0.8226); + + if (T0 < 65) { + return HOviscosity; + } + + refVisosity = getRefComponentViscosity(T0, P0); + double LOviscosity = refVisosity * Math.pow(TCmix / Tc0, -1.0 / 6.0) + * Math.pow(PCmix / Pc0, 2.0 / 3.0) * Math.pow(Mmix / M0, 0.5) * alfaMix / alfa0; + return LOviscosity * (1.0 - (75 - T0) / 10.0) + HOviscosity * (75.0 - T0) / 10.0; } + // System.out.println("m/mix " + Mmix/M0); + // System.out.println("a/amix " + alfaMix/alfa0); + refVisosity = getRefComponentViscosity(T0, P0); + double viscosity = refVisosity * Math.pow(TCmix / Tc0, -1.0 / 6.0) + * Math.pow(PCmix / Pc0, 2.0 / 3.0) * Math.pow(Mmix / M0, 0.5) * alfaMix / alfa0; + // System.out.println("viscosityLO " + viscosity); + + return viscosity; + } + + /** + *

+ * getRefComponentViscosity. + *

+ * + * @param temp a double + * @param pres a double + * @return a double + */ + public double getRefComponentViscosity(double temp, double pres) { + referenceSystem.setTemperature(temp); + // System.out.println("ref temp " + temp); + referenceSystem.setPressure(pres); + // System.out.println("ref pres " + pres); + referenceSystem.init(1); + // referenceSystem.display(); + // double molDens = 1.0 / + // referenceSystem.getPhase(phaseTypeNumb).getMolarVolume() * 100.0; + double molDens = 1.0 / referenceSystem.getLowestGibbsEnergyPhase().getMolarVolume() * 100.0; // mol/dm^3 + // System.out.println("mol dens " + molDens); + double critMolDens = 10.15; // 1.0/referenceSystem.getPhase(0).getComponent(0).getCriticalVolume(); + double redMolDens = (molDens - critMolDens) / critMolDens; + // System.out.println("gv1 " +GVcoef[0]); + + molDens = referenceSystem.getLowestGibbsEnergyPhase().getDensity() * 1e-3; + + double viscRefO = GVcoef[0] * Math.pow(temp, -1.0) + GVcoef[1] * Math.pow(temp, -2.0 / 3.0) + + GVcoef[2] * Math.pow(temp, -1.0 / 3.0) + GVcoef[3] + GVcoef[4] * Math.pow(temp, 1.0 / 3.0) + + GVcoef[5] * Math.pow(temp, 2.0 / 3.0) + GVcoef[6] * temp + + GVcoef[7] * Math.pow(temp, 4.0 / 3.0) + GVcoef[8] * Math.pow(temp, 5.0 / 3.0); + + // System.out.println("ref visc0 " + viscRefO); + double viscRef1 = + (visRefA + visRefB * Math.pow(visRefC - Math.log(temp / visRefF), 2.0)) * molDens; + // System.out.println("ref visc1 " + viscRef1); + + double temp1 = Math.pow(molDens, 0.1) * (viscRefJ[1] + viscRefJ[2] / Math.pow(temp, 3.0 / 2.0)); + double temp2 = redMolDens * Math.pow(molDens, 0.5) + * (viscRefJ[4] + viscRefJ[5] / temp + viscRefJ[6] / Math.pow(temp, 2.0)); + double temp3 = Math.exp(temp1 + temp2); + + double dTfreeze = temp - 90.69; + double HTAN = + (Math.exp(dTfreeze) - Math.exp(-dTfreeze)) / (Math.exp(dTfreeze) + Math.exp(-dTfreeze)); + visRefE = (HTAN + 1.0) / 2.0; + + double viscRef2 = visRefE * Math.exp(viscRefJ[0] + viscRefJ[3] / temp) * (temp3 - 1.0); + + double temp4 = Math.pow(molDens, 0.1) * (viscRefK[1] + viscRefK[2] / Math.pow(temp, 3.0 / 2.0)); + double temp5 = redMolDens * Math.pow(molDens, 0.5) + * (viscRefK[4] + viscRefK[5] / temp + viscRefK[6] / Math.pow(temp, 2.0)); + double temp6 = Math.exp(temp4 + temp5); + visRefG = (1.0 - HTAN) / 2.0; + double viscRef3 = visRefG * Math.exp(viscRefK[0] + viscRefK[3] / temp) * (temp6 - 1.0); + + // System.out.println("ref visc2 " + viscRef2); + // System.out.println("ref visc3 " + viscRef3); + double refVisc = (viscRefO + viscRef1 + viscRef2 + viscRef3) / 1.0e7; + // System.out.println("ref visc " + refVisc); + return refVisc; + } } diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethodMod86.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethodMod86.java index dfc9a16e45..fdb574af22 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethodMod86.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethodMod86.java @@ -12,181 +12,191 @@ * @version Method was checked on 2.8.2001 - seems to be correct - Even Solbraa */ public class PFCTViscosityMethodMod86 extends Viscosity { - private static final long serialVersionUID = 1000; - - // SystemInterface referenceSystem = new SystemBWRSEos(273.15, 1.01325); - SystemInterface referenceSystem = new SystemSrkEos(273.0, 1.01325); - int phaseTypeNumb = 1; - double[] GVcoef = {-2.090975e5, 2.647269e5, -1.472818e5, 4.716740e4, -9.491872e3, 1.219979e3, - -9.627993e1, 4.274152, -8.141531e-2}; - double visRefA = 1.696985927, visRefB = -0.133372346, visRefC = 1.4, visRefF = 168.0, - visRefE = 1.0, visRefG = 0.0; - double viscRefJ[] = {-1.035060586e1, 1.7571599671e1, -3.0193918656e3, 1.8873011594e2, - 4.2903609488e-2, 1.4529023444e2, 6.1276818706e3}; - double viscRefK[] = {-9.74602, 18.0834, -4126.66, 44.6055, 0.976544, 81.8134, 15649.9}; - - /** - *

- * Constructor for PFCTViscosityMethodMod86. - *

- */ - public PFCTViscosityMethodMod86() {} - - /** - *

- * Constructor for PFCTViscosityMethodMod86. - *

- * - * @param phase a - * {@link neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface} - * object - */ - public PFCTViscosityMethodMod86( - neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface phase) { - super(phase); - if (referenceSystem.getNumberOfMoles() < 1e-10) { - referenceSystem.addComponent("methane", 10.0); - referenceSystem.init(0); - } + private static final long serialVersionUID = 1000; + + // SystemInterface referenceSystem = new SystemBWRSEos(273.15, 1.01325); + SystemInterface referenceSystem = new SystemSrkEos(273.0, 1.01325); + int phaseTypeNumb = 1; + double[] GVcoef = {-2.090975e5, 2.647269e5, -1.472818e5, 4.716740e4, -9.491872e3, 1.219979e3, + -9.627993e1, 4.274152, -8.141531e-2}; + double visRefA = 1.696985927; + + double visRefB = -0.133372346; + + double visRefC = 1.4; + + double visRefF = 168.0; + + double visRefE = 1.0; + + double visRefG = 0.0; + + double[] viscRefJ = {-1.035060586e1, 1.7571599671e1, -3.0193918656e3, 1.8873011594e2, + 4.2903609488e-2, 1.4529023444e2, 6.1276818706e3}; + double[] viscRefK = {-9.74602, 18.0834, -4126.66, 44.6055, 0.976544, 81.8134, 15649.9}; + + /** + *

+ * Constructor for PFCTViscosityMethodMod86. + *

+ */ + public PFCTViscosityMethodMod86() {} + + /** + *

+ * Constructor for PFCTViscosityMethodMod86. + *

+ * + * @param phase a + * {@link neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface} + * object + */ + public PFCTViscosityMethodMod86( + neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface phase) { + super(phase); + if (referenceSystem.getNumberOfMoles() < 1e-10) { + referenceSystem.addComponent("methane", 10.0); + referenceSystem.init(0); } - - /** {@inheritDoc} */ - @Override - public double calcViscosity() { - double Pc0 = referenceSystem.getPhase(0).getComponent(0).getPC(), - Tc0 = referenceSystem.getPhase(0).getComponent(0).getTC(), - M0 = referenceSystem.getPhase(0).getComponent(0).getMolarMass() * 1e3; - - double PCmix = 0.0, TCmix = 0.0, Mmix = 0.0; - double alfa0 = 1.0, alfaMix = 1.0; - double tempTC1 = 0.0, tempTC2 = 0.0; - double tempPC1 = 0.0, tempPC2 = 0.0; - double Mwtemp = 0.0, Mmtemp = 0.0; - - for (int i = 0; i < phase.getPhase().getNumberOfComponents(); i++) { - for (int j = 0; j < phase.getPhase().getNumberOfComponents(); j++) { - double tempVar = phase.getPhase().getComponent(i).getx() - * phase.getPhase().getComponent(j).getx() - * Math.pow(Math - .pow(phase.getPhase().getComponent(i).getTC() - / phase.getPhase().getComponent(i).getPC(), 1.0 / 3.0) - + Math.pow( - phase.getPhase().getComponent(j).getTC() - / phase.getPhase().getComponent(j).getPC(), - 1.0 / 3.0), - 3.0); - tempTC1 += tempVar * Math.sqrt(phase.getPhase().getComponent(i).getTC() - * phase.getPhase().getComponent(j).getTC()); - tempTC2 += tempVar; - tempPC1 += tempVar * Math.sqrt(phase.getPhase().getComponent(i).getTC() - * phase.getPhase().getComponent(j).getTC()); - tempPC2 += tempVar; - } - Mwtemp += phase.getPhase().getComponent(i).getx() - * Math.pow(phase.getPhase().getComponent(i).getMolarMass(), 2.0); - Mmtemp += phase.getPhase().getComponent(i).getx() - * phase.getPhase().getComponent(i).getMolarMass(); - } - if (tempTC2 < 1e-10) { - return 0.0; - } - PCmix = 8.0 * tempPC1 / (tempPC2 * tempPC2); - TCmix = tempTC1 / tempTC2; - Mmix = (Mmtemp + 1.304e-4 * (Math.pow(Mwtemp / Mmtemp, 2.303) - Math.pow(Mmtemp, 2.303))) - * 1e3; // phase.getPhase().getMolarMass(); - - referenceSystem.setTemperature(phase.getPhase().getTemperature() - * referenceSystem.getPhase(0).getComponent(0).getTC() / TCmix); - referenceSystem.setPressure(phase.getPhase().getPressure() - * referenceSystem.getPhase(0).getComponent(0).getPC() / PCmix); - referenceSystem.init(1); - // double molDens = 1.0 / - // referenceSystem.getPhase(phaseTypeNumb).getMolarVolume() * 100.0; - double molDens = 1.0 / referenceSystem.getLowestGibbsEnergyPhase().getMolarVolume() * 100.0; - double critMolDens = 10.15;// 1.0/referenceSystem.getPhase(0).getComponent(0).getCriticalVolume(); - double redDens = molDens / critMolDens; - - alfaMix = 1.0 + 7.378e-3 * Math.pow(redDens, 1.847) * Math.pow(Mmix, 0.5173); - alfa0 = 1.0 + 7.378e-3 * Math.pow(redDens, 1.847) - * Math.pow(referenceSystem.getMolarMass() * 1.0e3, 0.5173); - // alfa0 = 1.0 + 8.374e-4 * Math.pow(redDens, 4.265); - // System.out.println("func " + 7.475e-5*Math.pow(16.043, 0.8579)); - double T0 = phase.getPhase().getTemperature() - * referenceSystem.getPhase(0).getComponent(0).getTC() / TCmix * alfa0 / alfaMix; - double P0 = phase.getPhase().getPressure() - * referenceSystem.getPhase(0).getComponent(0).getPC() / PCmix * alfa0 / alfaMix; - - double refVisosity = getRefComponentViscosity(T0, P0); - // System.out.println("m/mix " + Mmix/M0); - // System.out.println("a/amix " + alfaMix/alfa0); - double viscosity = refVisosity * Math.pow(TCmix / Tc0, -1.0 / 6.0) - * Math.pow(PCmix / Pc0, 2.0 / 3.0) * Math.pow(Mmix / M0, 0.5) * alfaMix / alfa0; - // System.out.println("viscosity " + refVisosity); - return viscosity; + } + + /** {@inheritDoc} */ + @Override + public double calcViscosity() { + double Pc0 = referenceSystem.getPhase(0).getComponent(0).getPC(); + + double Tc0 = referenceSystem.getPhase(0).getComponent(0).getTC(); + double M0 = referenceSystem.getPhase(0).getComponent(0).getMolarMass() * 1e3; + double PCmix = 0.0; + double TCmix = 0.0; + double Mmix = 0.0; + double alfa0 = 1.0; + double alfaMix = 1.0; + double tempTC1 = 0.0; + double tempTC2 = 0.0; + double tempPC1 = 0.0; + double tempPC2 = 0.0; + double Mwtemp = 0.0; + + double Mmtemp = 0.0; + for (int i = 0; i < phase.getPhase().getNumberOfComponents(); i++) { + for (int j = 0; j < phase.getPhase().getNumberOfComponents(); j++) { + double tempVar = phase.getPhase().getComponent(i).getx() + * phase.getPhase().getComponent(j).getx() + * Math.pow(Math + .pow(phase.getPhase().getComponent(i).getTC() + / phase.getPhase().getComponent(i).getPC(), 1.0 / 3.0) + + Math.pow(phase.getPhase().getComponent(j).getTC() + / phase.getPhase().getComponent(j).getPC(), 1.0 / 3.0), + 3.0); + tempTC1 += tempVar * Math.sqrt( + phase.getPhase().getComponent(i).getTC() * phase.getPhase().getComponent(j).getTC()); + tempTC2 += tempVar; + tempPC1 += tempVar * Math.sqrt( + phase.getPhase().getComponent(i).getTC() * phase.getPhase().getComponent(j).getTC()); + tempPC2 += tempVar; + } + Mwtemp += phase.getPhase().getComponent(i).getx() + * Math.pow(phase.getPhase().getComponent(i).getMolarMass(), 2.0); + Mmtemp += + phase.getPhase().getComponent(i).getx() * phase.getPhase().getComponent(i).getMolarMass(); } - - /** - *

- * getRefComponentViscosity. - *

- * - * @param temp a double - * @param pres a double - * @return a double - */ - public double getRefComponentViscosity(double temp, double pres) { - referenceSystem.setTemperature(temp); - // System.out.println("ref temp " + temp); - referenceSystem.setPressure(pres); - // System.out.println("ref pres " + pres); - referenceSystem.init(1); - // referenceSystem.display(); - // double molDens = 1.0 / - // referenceSystem.getPhase(phaseTypeNumb).getMolarVolume() * 100.0; - double molDens = 1.0 / referenceSystem.getLowestGibbsEnergyPhase().getMolarVolume() * 100.0; // mol/dm^3 - // System.out.println("mol dens " + molDens); - double critMolDens = 10.15;// 1.0/referenceSystem.getPhase(0).getComponent(0).getCriticalVolume(); - double redMolDens = (molDens - critMolDens) / critMolDens; - // System.out.println("gv1 " +GVcoef[0]); - - molDens = referenceSystem.getLowestGibbsEnergyPhase().getDensity() * 1e-3; - - double viscRefO = GVcoef[0] * Math.pow(temp, -1.0) + GVcoef[1] * Math.pow(temp, -2.0 / 3.0) - + GVcoef[2] * Math.pow(temp, -1.0 / 3.0) + GVcoef[3] - + GVcoef[4] * Math.pow(temp, 1.0 / 3.0) + GVcoef[5] * Math.pow(temp, 2.0 / 3.0) - + GVcoef[6] * temp + GVcoef[7] * Math.pow(temp, 4.0 / 3.0) - + GVcoef[8] * Math.pow(temp, 5.0 / 3.0); - - // System.out.println("ref visc0 " + viscRefO); - double viscRef1 = - (visRefA + visRefB * Math.pow(visRefC - Math.log(temp / visRefF), 2.0)) * molDens; - // System.out.println("ref visc1 " + viscRef1); - - double temp1 = - Math.pow(molDens, 0.1) * (viscRefJ[1] + viscRefJ[2] / Math.pow(temp, 3.0 / 2.0)); - double temp2 = redMolDens * Math.pow(molDens, 0.5) - * (viscRefJ[4] + viscRefJ[5] / temp + viscRefJ[6] / Math.pow(temp, 2.0)); - double temp3 = Math.exp(temp1 + temp2); - - double dTfreeze = temp - 90.69; - double HTAN = (Math.exp(dTfreeze) - Math.exp(-dTfreeze)) - / (Math.exp(dTfreeze) + Math.exp(-dTfreeze)); - visRefE = (HTAN + 1.0) / 2.0; - - double viscRef2 = visRefE * Math.exp(viscRefJ[0] + viscRefJ[3] / temp) * (temp3 - 1.0); - - double temp4 = - Math.pow(molDens, 0.1) * (viscRefK[1] + viscRefK[2] / Math.pow(temp, 3.0 / 2.0)); - double temp5 = redMolDens * Math.pow(molDens, 0.5) - * (viscRefK[4] + viscRefK[5] / temp + viscRefK[6] / Math.pow(temp, 2.0)); - double temp6 = Math.exp(temp4 + temp5); - visRefG = (1.0 - HTAN) / 2.0; - double viscRef3 = visRefG * Math.exp(viscRefK[0] + viscRefK[3] / temp) * (temp6 - 1.0); - - System.out.println("ref visc2 " + viscRef2); - System.out.println("ref visc3 " + viscRef3); - double refVisc = (viscRefO + viscRef1 + viscRef2 + viscRef3) / 1.0e7; - // System.out.println("ref visc " + refVisc); - return refVisc; + if (tempTC2 < 1e-10) { + return 0.0; } + PCmix = 8.0 * tempPC1 / (tempPC2 * tempPC2); + TCmix = tempTC1 / tempTC2; + Mmix = (Mmtemp + 1.304e-4 * (Math.pow(Mwtemp / Mmtemp, 2.303) - Math.pow(Mmtemp, 2.303))) * 1e3; // phase.getPhase().getMolarMass(); + + referenceSystem.setTemperature(phase.getPhase().getTemperature() + * referenceSystem.getPhase(0).getComponent(0).getTC() / TCmix); + referenceSystem.setPressure(phase.getPhase().getPressure() + * referenceSystem.getPhase(0).getComponent(0).getPC() / PCmix); + referenceSystem.init(1); + // double molDens = 1.0 / + // referenceSystem.getPhase(phaseTypeNumb).getMolarVolume() * 100.0; + double molDens = 1.0 / referenceSystem.getLowestGibbsEnergyPhase().getMolarVolume() * 100.0; + double critMolDens = 10.15; // 1.0/referenceSystem.getPhase(0).getComponent(0).getCriticalVolume(); + double redDens = molDens / critMolDens; + + alfaMix = 1.0 + 7.378e-3 * Math.pow(redDens, 1.847) * Math.pow(Mmix, 0.5173); + alfa0 = 1.0 + 7.378e-3 * Math.pow(redDens, 1.847) + * Math.pow(referenceSystem.getMolarMass() * 1.0e3, 0.5173); + // alfa0 = 1.0 + 8.374e-4 * Math.pow(redDens, 4.265); + // System.out.println("func " + 7.475e-5*Math.pow(16.043, 0.8579)); + double T0 = phase.getPhase().getTemperature() + * referenceSystem.getPhase(0).getComponent(0).getTC() / TCmix * alfa0 / alfaMix; + double P0 = phase.getPhase().getPressure() * referenceSystem.getPhase(0).getComponent(0).getPC() + / PCmix * alfa0 / alfaMix; + + double refVisosity = getRefComponentViscosity(T0, P0); + // System.out.println("m/mix " + Mmix/M0); + // System.out.println("a/amix " + alfaMix/alfa0); + double viscosity = refVisosity * Math.pow(TCmix / Tc0, -1.0 / 6.0) + * Math.pow(PCmix / Pc0, 2.0 / 3.0) * Math.pow(Mmix / M0, 0.5) * alfaMix / alfa0; + // System.out.println("viscosity " + refVisosity); + return viscosity; + } + + /** + *

+ * getRefComponentViscosity. + *

+ * + * @param temp a double + * @param pres a double + * @return a double + */ + public double getRefComponentViscosity(double temp, double pres) { + referenceSystem.setTemperature(temp); + // System.out.println("ref temp " + temp); + referenceSystem.setPressure(pres); + // System.out.println("ref pres " + pres); + referenceSystem.init(1); + // referenceSystem.display(); + // double molDens = 1.0 / + // referenceSystem.getPhase(phaseTypeNumb).getMolarVolume() * 100.0; + double molDens = 1.0 / referenceSystem.getLowestGibbsEnergyPhase().getMolarVolume() * 100.0; // mol/dm^3 + // System.out.println("mol dens " + molDens); + double critMolDens = 10.15; // 1.0/referenceSystem.getPhase(0).getComponent(0).getCriticalVolume(); + double redMolDens = (molDens - critMolDens) / critMolDens; + // System.out.println("gv1 " +GVcoef[0]); + + molDens = referenceSystem.getLowestGibbsEnergyPhase().getDensity() * 1e-3; + + double viscRefO = GVcoef[0] * Math.pow(temp, -1.0) + GVcoef[1] * Math.pow(temp, -2.0 / 3.0) + + GVcoef[2] * Math.pow(temp, -1.0 / 3.0) + GVcoef[3] + GVcoef[4] * Math.pow(temp, 1.0 / 3.0) + + GVcoef[5] * Math.pow(temp, 2.0 / 3.0) + GVcoef[6] * temp + + GVcoef[7] * Math.pow(temp, 4.0 / 3.0) + GVcoef[8] * Math.pow(temp, 5.0 / 3.0); + + // System.out.println("ref visc0 " + viscRefO); + double viscRef1 = + (visRefA + visRefB * Math.pow(visRefC - Math.log(temp / visRefF), 2.0)) * molDens; + // System.out.println("ref visc1 " + viscRef1); + + double temp1 = Math.pow(molDens, 0.1) * (viscRefJ[1] + viscRefJ[2] / Math.pow(temp, 3.0 / 2.0)); + double temp2 = redMolDens * Math.pow(molDens, 0.5) + * (viscRefJ[4] + viscRefJ[5] / temp + viscRefJ[6] / Math.pow(temp, 2.0)); + double temp3 = Math.exp(temp1 + temp2); + + double dTfreeze = temp - 90.69; + double HTAN = + (Math.exp(dTfreeze) - Math.exp(-dTfreeze)) / (Math.exp(dTfreeze) + Math.exp(-dTfreeze)); + visRefE = (HTAN + 1.0) / 2.0; + + double viscRef2 = visRefE * Math.exp(viscRefJ[0] + viscRefJ[3] / temp) * (temp3 - 1.0); + + double temp4 = Math.pow(molDens, 0.1) * (viscRefK[1] + viscRefK[2] / Math.pow(temp, 3.0 / 2.0)); + double temp5 = redMolDens * Math.pow(molDens, 0.5) + * (viscRefK[4] + viscRefK[5] / temp + viscRefK[6] / Math.pow(temp, 2.0)); + double temp6 = Math.exp(temp4 + temp5); + visRefG = (1.0 - HTAN) / 2.0; + double viscRef3 = visRefG * Math.exp(viscRefK[0] + viscRefK[3] / temp) * (temp6 - 1.0); + + System.out.println("ref visc2 " + viscRef2); + System.out.println("ref visc3 " + viscRef3); + double refVisc = (viscRefO + viscRef1 + viscRef2 + viscRef3) / 1.0e7; + // System.out.println("ref visc " + refVisc); + return refVisc; + } } diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/Viscosity.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/Viscosity.java index 4f99f07525..663c2c845b 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/Viscosity.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/Viscosity.java @@ -67,7 +67,7 @@ public void calcPureComponentViscosity() { phase.getPhase().getComponents()[i].getLiquidViscosityParameter(0) * (1.0 / phase.getPhase().getTemperature() - 1.0 / phase.getPhase().getComponents()[i] - .getLiquidViscosityParameter(1)));// phase.getPhase().getComponents()[i].getLiquidViscosityParameter(2)*phase.getPhase().getTemperature()+phase.getPhase().getComponents()[i].getLiquidViscosityParameter(3)/phase.getPhase().getTemperature()+phase.getPhase().getComponents()[i].getLiquidViscosityParameter(3)*Math.pow(phase.getPhase().getTemperature(),2)); + .getLiquidViscosityParameter(1))); // phase.getPhase().getComponents()[i].getLiquidViscosityParameter(2)*phase.getPhase().getTemperature()+phase.getPhase().getComponents()[i].getLiquidViscosityParameter(3)/phase.getPhase().getTemperature()+phase.getPhase().getComponents()[i].getLiquidViscosityParameter(3)*Math.pow(phase.getPhase().getTemperature(),2)); } else { // System.out.println("no pure component viscosity model defined for component " // + phase.getPhase().getComponents()[i].getComponentName()); diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/conductivity/Conductivity.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/conductivity/Conductivity.java index c8b507f0e8..9b4e01d71b 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/conductivity/Conductivity.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/conductivity/Conductivity.java @@ -82,10 +82,10 @@ public double calcConductivity() { */ } double wigthFraci = liquidPhase.getPhase().getWtFrac(i); - conductivity += wigthFraci * pureComponentConductivity[i];/// tempVar; + conductivity += wigthFraci * pureComponentConductivity[i]; /// tempVar; // conductivity = conductivity + // liquidPhase.getPhase().getComponents()[i].getx() * - // pureComponentConductivity[i];///tempVar; + // pureComponentConductivity[i]; ///tempVar; } return conductivity; diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/viscosity/AmineViscosity.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/viscosity/AmineViscosity.java index 32267238fa..e44810d121 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/viscosity/AmineViscosity.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/viscosity/AmineViscosity.java @@ -44,7 +44,7 @@ public double calcViscosity() { / liquidPhase.getPhase().getMolarMass(); double viscA = -12.197 - 8.905 * wtFracA; double viscB = 1438.717 + 4218.749 * wtFracA; - double logviscosity = viscA + viscB / liquidPhase.getPhase().getTemperature();// //N-sek/m2 + double logviscosity = viscA + viscB / liquidPhase.getPhase().getTemperature(); // //N-sek/m2 // System.out.println("visc " + Math.exp(logviscosity)); return Math.exp(logviscosity); } diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/viscosity/Viscosity.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/viscosity/Viscosity.java index ccc814a49f..d0e083e80f 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/viscosity/Viscosity.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/viscosity/Viscosity.java @@ -12,159 +12,157 @@ * @version Method was checked on 2.8.2001 - seems to be correct - Even Solbraa */ public class Viscosity extends - neqsim.physicalProperties.physicalPropertyMethods.liquidPhysicalProperties.LiquidPhysicalPropertyMethod - implements - neqsim.physicalProperties.physicalPropertyMethods.methodInterface.ViscosityInterface { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(Viscosity.class); + neqsim.physicalProperties.physicalPropertyMethods.liquidPhysicalProperties.LiquidPhysicalPropertyMethod + implements + neqsim.physicalProperties.physicalPropertyMethods.methodInterface.ViscosityInterface { + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(Viscosity.class); - public double[] pureComponentViscosity; + public double[] pureComponentViscosity; - /** - *

- * Constructor for Viscosity. - *

- */ - public Viscosity() {} + /** + *

+ * Constructor for Viscosity. + *

+ */ + public Viscosity() {} - /** - *

- * Constructor for Viscosity. - *

- * - * @param liquidPhase a - * {@link neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface} - * object - */ - public Viscosity( - neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface liquidPhase) { - super(liquidPhase); - pureComponentViscosity = new double[liquidPhase.getPhase().getNumberOfComponents()]; - } - - /** {@inheritDoc} */ - @Override - public Viscosity clone() { - Viscosity properties = null; + /** + *

+ * Constructor for Viscosity. + *

+ * + * @param liquidPhase a + * {@link neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface} + * object + */ + public Viscosity( + neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface liquidPhase) { + super(liquidPhase); + pureComponentViscosity = new double[liquidPhase.getPhase().getNumberOfComponents()]; + } - try { - properties = (Viscosity) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } + /** {@inheritDoc} */ + @Override + public Viscosity clone() { + Viscosity properties = null; - return properties; + try { + properties = (Viscosity) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); } - /** {@inheritDoc} */ - @Override - public double calcViscosity() { - double tempVar = 0, tempVar2 = 0; - double viscosity = 0; - this.calcPureComponentViscosity(); + return properties; + } - // method og Grunberg and Nissan [87] - for (int i = 0; i < liquidPhase.getPhase().getNumberOfComponents(); i++) { - tempVar += liquidPhase.getPhase().getWtFrac(i) * Math.log(pureComponentViscosity[i]); - // tempVar += liquidPhase.getPhase().getComponents()[i].getx() * - // Math.log(pureComponentViscosity[i]); - } - tempVar2 = 0; - for (int i = 0; i < liquidPhase.getPhase().getNumberOfComponents(); i++) { - double wigthFraci = liquidPhase.getPhase().getWtFrac(i); - for (int j = 0; j < liquidPhase.getPhase().getNumberOfComponents(); j++) { - double wigthFracj = liquidPhase.getPhase().getWtFrac(j); - if (i != j) { - tempVar2 += wigthFraci * wigthFracj - * liquidPhase.getMixingRule().getViscosityGij(i, j); - // System.out.println("gij " + liquidPhase.getMixingRule().getViscosityGij(i, - // j)); - } + /** {@inheritDoc} */ + @Override + public double calcViscosity() { + double tempVar = 0; + double tempVar2 = 0; + double viscosity = 0; + this.calcPureComponentViscosity(); - // if(i!=j) tempVar2 += - // liquidPhase.getPhase().getComponents()[i].getx()*liquidPhase.getPhase().getComponents()[j].getx()*liquidPhase.getMixingRule().getViscosityGij(i,j); - } - } - viscosity = Math.exp(tempVar + tempVar2) / 1.0e3; // N-sek/m2 - return viscosity; + // method og Grunberg and Nissan [87] + for (int i = 0; i < liquidPhase.getPhase().getNumberOfComponents(); i++) { + tempVar += liquidPhase.getPhase().getWtFrac(i) * Math.log(pureComponentViscosity[i]); + // tempVar += liquidPhase.getPhase().getComponents()[i].getx() * + // Math.log(pureComponentViscosity[i]); } - - /** - *

- * calcPureComponentViscosity. - *

- */ - public void calcPureComponentViscosity() { - pureComponentViscosity = new double[liquidPhase.getPhase().getNumberOfComponents()]; - for (int i = 0; i < liquidPhase.getPhase().getNumberOfComponents(); i++) { - if (liquidPhase.getPhase().getTemperature() > liquidPhase.getPhase().getComponents()[i] - .getTC()) { - pureComponentViscosity[i] = 5.0e-1; - } else if (liquidPhase.getPhase().getComponents()[i].getLiquidViscosityModel() == 1) { - pureComponentViscosity[i] = - liquidPhase.getPhase().getComponents()[i].getLiquidViscosityParameter(0) - * Math.pow(liquidPhase.getPhase().getTemperature(), - liquidPhase.getPhase().getComponents()[i] - .getLiquidViscosityParameter(1)); - } else if (liquidPhase.getPhase().getComponents()[i].getLiquidViscosityModel() == 2) { - pureComponentViscosity[i] = Math.exp(liquidPhase.getPhase().getComponents()[i] - .getLiquidViscosityParameter(0) - + liquidPhase.getPhase().getComponents()[i].getLiquidViscosityParameter(1) - / liquidPhase.getPhase().getTemperature()); - } else if (liquidPhase.getPhase().getComponents()[i].getLiquidViscosityModel() == 3) { - pureComponentViscosity[i] = Math.exp(liquidPhase.getPhase().getComponents()[i] - .getLiquidViscosityParameter(0) - + liquidPhase.getPhase().getComponents()[i].getLiquidViscosityParameter(1) - / liquidPhase.getPhase().getTemperature() - + liquidPhase.getPhase().getComponents()[i].getLiquidViscosityParameter(2) - * liquidPhase.getPhase().getTemperature() - + liquidPhase.getPhase().getComponents()[i].getLiquidViscosityParameter(3) - * Math.pow(liquidPhase.getPhase().getTemperature(), 2)); - } else if (liquidPhase.getPhase().getComponents()[i].getLiquidViscosityModel() == 4) { - pureComponentViscosity[i] = Math.pow(10, - liquidPhase.getPhase().getComponents()[i].getLiquidViscosityParameter(0) - * (1.0 / liquidPhase.getPhase().getTemperature() - - 1.0 / liquidPhase.getPhase().getComponents()[i] - .getLiquidViscosityParameter(1)));// liquidPhase.getPhase().getComponents()[i].getLiquidViscosityParameter(2)*liquidPhase.getPhase().getTemperature()+liquidPhase.getPhase().getComponents()[i].getLiquidViscosityParameter(3)/liquidPhase.getPhase().getTemperature()+liquidPhase.getPhase().getComponents()[i].getLiquidViscosityParameter(3)*Math.pow(liquidPhase.getPhase().getTemperature(),2)); - } else { - // System.out.println("no pure component viscosity model defined for component " - // + liquidPhase.getPhase().getComponents()[i].getComponentName()); - pureComponentViscosity[i] = 7.0e-1; - } - pureComponentViscosity[i] *= ((getViscosityPressureCorrection(i) + 1.0) / 2.0); - // System.out.println("pure comp viscosity " + pureComponentViscosity[i] + " - // pressure cor " + getViscosityPressureCorrection(i)); + tempVar2 = 0; + for (int i = 0; i < liquidPhase.getPhase().getNumberOfComponents(); i++) { + double wigthFraci = liquidPhase.getPhase().getWtFrac(i); + for (int j = 0; j < liquidPhase.getPhase().getNumberOfComponents(); j++) { + double wigthFracj = liquidPhase.getPhase().getWtFrac(j); + if (i != j) { + tempVar2 += wigthFraci * wigthFracj * liquidPhase.getMixingRule().getViscosityGij(i, j); + // System.out.println("gij " + liquidPhase.getMixingRule().getViscosityGij(i, + // j)); } + + // if(i!=j) tempVar2 += + // liquidPhase.getPhase().getComponents()[i].getx()*liquidPhase.getPhase().getComponents()[j].getx()*liquidPhase.getMixingRule().getViscosityGij(i,j); + } } + viscosity = Math.exp(tempVar + tempVar2) / 1.0e3; // N-sek/m2 + return viscosity; + } - /** {@inheritDoc} */ - @Override - public double getPureComponentViscosity(int i) { - return pureComponentViscosity[i]; + /** + *

+ * calcPureComponentViscosity. + *

+ */ + public void calcPureComponentViscosity() { + pureComponentViscosity = new double[liquidPhase.getPhase().getNumberOfComponents()]; + for (int i = 0; i < liquidPhase.getPhase().getNumberOfComponents(); i++) { + if (liquidPhase.getPhase().getTemperature() > liquidPhase.getPhase().getComponents()[i] + .getTC()) { + pureComponentViscosity[i] = 5.0e-1; + } else if (liquidPhase.getPhase().getComponents()[i].getLiquidViscosityModel() == 1) { + pureComponentViscosity[i] = + liquidPhase.getPhase().getComponents()[i].getLiquidViscosityParameter(0) + * Math.pow(liquidPhase.getPhase().getTemperature(), + liquidPhase.getPhase().getComponents()[i].getLiquidViscosityParameter(1)); + } else if (liquidPhase.getPhase().getComponents()[i].getLiquidViscosityModel() == 2) { + pureComponentViscosity[i] = + Math.exp(liquidPhase.getPhase().getComponents()[i].getLiquidViscosityParameter(0) + + liquidPhase.getPhase().getComponents()[i].getLiquidViscosityParameter(1) + / liquidPhase.getPhase().getTemperature()); + } else if (liquidPhase.getPhase().getComponents()[i].getLiquidViscosityModel() == 3) { + pureComponentViscosity[i] = + Math.exp(liquidPhase.getPhase().getComponents()[i].getLiquidViscosityParameter(0) + + liquidPhase.getPhase().getComponents()[i].getLiquidViscosityParameter(1) + / liquidPhase.getPhase().getTemperature() + + liquidPhase.getPhase().getComponents()[i].getLiquidViscosityParameter(2) + * liquidPhase.getPhase().getTemperature() + + liquidPhase.getPhase().getComponents()[i].getLiquidViscosityParameter(3) + * Math.pow(liquidPhase.getPhase().getTemperature(), 2)); + } else if (liquidPhase.getPhase().getComponents()[i].getLiquidViscosityModel() == 4) { + pureComponentViscosity[i] = Math.pow(10, + liquidPhase.getPhase().getComponents()[i].getLiquidViscosityParameter(0) * (1.0 + / liquidPhase.getPhase().getTemperature() + - 1.0 / liquidPhase.getPhase().getComponents()[i].getLiquidViscosityParameter(1))); // liquidPhase.getPhase().getComponents()[i].getLiquidViscosityParameter(2)*liquidPhase.getPhase().getTemperature()+liquidPhase.getPhase().getComponents()[i].getLiquidViscosityParameter(3)/liquidPhase.getPhase().getTemperature()+liquidPhase.getPhase().getComponents()[i].getLiquidViscosityParameter(3)*Math.pow(liquidPhase.getPhase().getTemperature(),2)); + } else { + // System.out.println("no pure component viscosity model defined for component " + // + liquidPhase.getPhase().getComponents()[i].getComponentName()); + pureComponentViscosity[i] = 7.0e-1; + } + pureComponentViscosity[i] *= ((getViscosityPressureCorrection(i) + 1.0) / 2.0); + // System.out.println("pure comp viscosity " + pureComponentViscosity[i] + " + // pressure cor " + getViscosityPressureCorrection(i)); } + } - /** - *

- * getViscosityPressureCorrection. - *

- * - * @param i a int - * @return a double - */ - public double getViscosityPressureCorrection(int i) { - double TR = liquidPhase.getPhase().getTemperature() - / liquidPhase.getPhase().getComponent(i).getTC(); - if (TR > 1) { - return 1.0; - } - double deltaPr = (liquidPhase.getPhase().getPressure() - 0.0) - / liquidPhase.getPhase().getComponent(i).getPC(); - double A = 0.9991 - (4.674 * 1e-4 / (1.0523 * Math.pow(TR, -0.03877) - 1.0513)); - double D = (0.3257 / Math.pow((1.0039 - Math.pow(TR, 2.573)), 0.2906)) - 0.2086; - double C = -0.07921 + 2.1616 * TR - 13.4040 * TR * TR + 44.1706 * Math.pow(TR, 3) - - 84.8291 * Math.pow(TR, 4) + 96.1209 * Math.pow(TR, 5) - 59.8127 * Math.pow(TR, 6) - + 15.6719 * Math.pow(TR, 7); - return (1.0 + D * Math.pow(deltaPr / 2.118, A)) - / (1.0 + C * liquidPhase.getPhase().getComponent(i).getAcentricFactor() * deltaPr); + /** {@inheritDoc} */ + @Override + public double getPureComponentViscosity(int i) { + return pureComponentViscosity[i]; + } + + /** + *

+ * getViscosityPressureCorrection. + *

+ * + * @param i a int + * @return a double + */ + public double getViscosityPressureCorrection(int i) { + double TR = + liquidPhase.getPhase().getTemperature() / liquidPhase.getPhase().getComponent(i).getTC(); + if (TR > 1) { + return 1.0; } + double deltaPr = (liquidPhase.getPhase().getPressure() - 0.0) + / liquidPhase.getPhase().getComponent(i).getPC(); + double A = 0.9991 - (4.674 * 1e-4 / (1.0523 * Math.pow(TR, -0.03877) - 1.0513)); + double D = (0.3257 / Math.pow((1.0039 - Math.pow(TR, 2.573)), 0.2906)) - 0.2086; + double C = -0.07921 + 2.1616 * TR - 13.4040 * TR * TR + 44.1706 * Math.pow(TR, 3) + - 84.8291 * Math.pow(TR, 4) + 96.1209 * Math.pow(TR, 5) - 59.8127 * Math.pow(TR, 6) + + 15.6719 * Math.pow(TR, 7); + return (1.0 + D * Math.pow(deltaPr / 2.118, A)) + / (1.0 + C * liquidPhase.getPhase().getComponent(i).getAcentricFactor() * deltaPr); + } } diff --git a/src/main/java/neqsim/physicalProperties/util/parameterFitting/binaryComponentParameterFitting/diffusivity/DiffusivityFunction.java b/src/main/java/neqsim/physicalProperties/util/parameterFitting/binaryComponentParameterFitting/diffusivity/DiffusivityFunction.java index feab43e190..def4474c7e 100644 --- a/src/main/java/neqsim/physicalProperties/util/parameterFitting/binaryComponentParameterFitting/diffusivity/DiffusivityFunction.java +++ b/src/main/java/neqsim/physicalProperties/util/parameterFitting/binaryComponentParameterFitting/diffusivity/DiffusivityFunction.java @@ -11,32 +11,35 @@ * @version $Id: $Id */ public class DiffusivityFunction extends LevenbergMarquardtFunction { - /** - *

- * Constructor for DiffusivityFunction. - *

- */ - public DiffusivityFunction() {} + /** + *

+ * Constructor for DiffusivityFunction. + *

+ */ + public DiffusivityFunction() {} - /** {@inheritDoc} */ - @Override - public double calcValue(double[] dependentValues) { - system.init(1); - system.initPhysicalProperties(); - return system.getPhase(1).getPhysicalProperties().getDiffusionCoefficient(0, 1) * 1e9; - } + /** {@inheritDoc} */ + @Override + public double calcValue(double[] dependentValues) { + system.init(1); + system.initPhysicalProperties(); + return system.getPhase(1).getPhysicalProperties().getDiffusionCoefficient(0, 1) * 1e9; + } - /** {@inheritDoc} */ - @Override - public void setFittingParams(int i, double value) { - params[i] = value; - // system.getPhases()[0].getPhysicalProperties().getMixingRule().setViscosityGij(value, 0, - // 1); - // system.getPhases()[0].getPhysicalProperties().getMixingRule().setViscosityGij(value, 1, - // 0); - // system.getPhase(1).getComponent(0).setLiquidViscosityModel(i);//system.getPhases()[1].getComponent(0).setMolarMass(i);//getPhysicalProperties().getMixingRule().setViscosityGij(value, - // 1, 0); - // system.getPhase(0).getComponent(0).setLiquidViscosityModel(i);//MolarMass(i);//system.getPhase(1).getPhysicalProperties().getMixingRule().setViscosityGij(value, - // 0, 1); - } + /** {@inheritDoc} */ + @Override + public void setFittingParams(int i, double value) { + params[i] = value; + // system.getPhases()[0].getPhysicalProperties().getMixingRule().setViscosityGij(value, 0, + // 1); + // system.getPhases()[0].getPhysicalProperties().getMixingRule().setViscosityGij(value, 1, + // 0); + // system.getPhase(1).getComponent(0).setLiquidViscosityModel(i); + // //system.getPhases()[1].getComponent(0).setMolarMass(i); + // //getPhysicalProperties().getMixingRule().setViscosityGij(value, + // 1, 0); + // system.getPhase(0).getComponent(0).setLiquidViscosityModel(i); //MolarMass(i); + // //system.getPhase(1).getPhysicalProperties().getMixingRule().setViscosityGij(value, + // 0, 1); + } } diff --git a/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompInterfaceTension/TestInfluenceParamGTFunction.java b/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompInterfaceTension/TestInfluenceParamGTFunction.java index b123381976..bef1e8427c 100644 --- a/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompInterfaceTension/TestInfluenceParamGTFunction.java +++ b/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompInterfaceTension/TestInfluenceParamGTFunction.java @@ -35,7 +35,7 @@ public static void main(String[] args) { NeqSimDataBase database = new NeqSimDataBase(); ResultSet dataSet = database.getResultSet( - "SELECT * FROM purecomponentsurfacetension2 WHERE ComponentName IN ('n-pentane','ethane','methane', 'propane','CO2', 'c-hexane','M-cy-C5', 'n-pentane','n-hexane', 'n-nonane','nC10')");// AND + "SELECT * FROM purecomponentsurfacetension2 WHERE ComponentName IN ('n-pentane','ethane','methane', 'propane','CO2', 'c-hexane','M-cy-C5', 'n-pentane','n-hexane', 'n-nonane','nC10')"); // AND // ComponentName<>'nC10' // AND // ComponentName<>'nC11' @@ -52,7 +52,7 @@ public static void main(String[] args) { // param // double guess[] = {1.9286440937, -8.7271963910, 1.2495334818, -1.8975206092}; - // double guess[] = {-5.2897559010400935E-17, 7.103588505598196E-17};//, + // double guess[] = {-5.2897559010400935E-17, 7.103588505598196E-17}; //, // 1.1161368619, 0.8363538313}; // PR param try { @@ -101,7 +101,7 @@ public static void main(String[] args) { /* * dataSet = database.getResultSet("NeqSimDataBase", - * "SELECT * FROM BinaryComponentSurfaceTension WHERE Include=1");// AND + * "SELECT * FROM BinaryComponentSurfaceTension WHERE Include=1"); // AND * ComponentName<>'nC12' AND ComponentName<>'nC13'"); boolean includeBinaryData = false; * * try { logger.error("adding...."); while (dataSet.next() && includeBinaryData) { diff --git a/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompViscosity/chungMethod/TestChungFit.java b/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompViscosity/chungMethod/TestChungFit.java index 73823cef23..4dbadbfa16 100644 --- a/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompViscosity/chungMethod/TestChungFit.java +++ b/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompViscosity/chungMethod/TestChungFit.java @@ -35,7 +35,7 @@ public static void main(String[] args) { // inserting samples from database NeqSimDataBase database = new NeqSimDataBase(); - ResultSet dataSet = database.getResultSet("SELECT * FROM purecomponentviscosity");// WHERE + ResultSet dataSet = database.getResultSet("SELECT * FROM purecomponentviscosity"); // WHERE // ComponentName='MDEA*'"); try { diff --git a/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompViscosity/linearLiquidModel/TestViscosityFit.java b/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompViscosity/linearLiquidModel/TestViscosityFit.java index c882521e13..2cfbfc4870 100644 --- a/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompViscosity/linearLiquidModel/TestViscosityFit.java +++ b/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompViscosity/linearLiquidModel/TestViscosityFit.java @@ -43,7 +43,7 @@ public static void main(String[] args) { ViscosityFunction function = new ViscosityFunction(); // double guess[] = {-66.2, 11810, 0.1331, -0.0000983}; //mdea // double guess[] = {-5.771E1, 7.647E3, 1.442E-1, -1.357E-4}; //water - double guess[] = {-10.14, 3868.803, -0.00550507};// ,0.000001};//,0.001}; //MEG + double guess[] = {-10.14, 3868.803, -0.00550507}; // ,0.000001}; //,0.001}; //MEG // double guess[] = { -53.92523097004079, 9741.992308,0,0.106066223998382}; // //TEG function.setInitialGuess(guess); diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/MechanicalDesign.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/MechanicalDesign.java index 94450a4524..fdb0dd535b 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/MechanicalDesign.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/MechanicalDesign.java @@ -424,7 +424,7 @@ public void setPressureMarginFactor(double pressureMarginFactor) { * @return a double */ public double getOuterDiameter() { - return 1.0;// processEquipment.getInternalDiameter(); + return 1.0; // processEquipment.getInternalDiameter(); } /** @@ -1024,7 +1024,7 @@ public void displayResults() { dialogContentPane.setLayout(new BorderLayout()); String[] names = {"", "Volume", "Weight"}; - String[][] table = new String[3][3];// createTable(getProcessEquipment().getName()); + String[][] table = new String[3][3]; // createTable(getProcessEquipment().getName()); table[1][0] = getProcessEquipment().getName(); table[1][1] = Double.toString(getWeightTotal()); table[1][2] = Double.toString(getVolumeTotal()); diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/absorber/AbsorberMechanicalDesign.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/absorber/AbsorberMechanicalDesign.java index 045a494e14..26b0fd221c 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/absorber/AbsorberMechanicalDesign.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/absorber/AbsorberMechanicalDesign.java @@ -100,7 +100,7 @@ public void calcDesign() { double gasDensity = ((Separator) getProcessEquipment()).getGasOutStream().getThermoSystem() .getPhase(0).getPhysicalProperties().getDensity(); - double liqDensity = 1000.0;// ((SimpleTEGAbsorber) + double liqDensity = 1000.0; // ((SimpleTEGAbsorber) // getProcessEquipment()).getLiquidOutStream().getThermoSystem().getPhase(1).getPhysicalProperties().getDensity(); // maxDesignVolumeFlow = volumeSafetyFactor * ((Separator) diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/compressor/CompressorMechanicalDesign.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/compressor/CompressorMechanicalDesign.java index c7dfadfc9c..227b83b53d 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/compressor/CompressorMechanicalDesign.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/compressor/CompressorMechanicalDesign.java @@ -63,7 +63,7 @@ public void displayResults() { dialogContentPane.setLayout(new BorderLayout()); String[] names = {"Name", "Value", "Unit"}; - String[][] table = new String[16][3];// createTable(getProcessEquipment().getName()); + String[][] table = new String[16][3]; // createTable(getProcessEquipment().getName()); table[1][0] = "Separator Inner Diameter"; table[1][1] = Double.toString(getInnerDiameter()); @@ -119,8 +119,12 @@ public void calcDesign() { Compressor compressor = (Compressor) getProcessEquipment(); double Fg = 1.0; - double emptyVesselWeight = 0.0, internalsWeight = 0.0, externalNozzelsWeight = 0.0; - double pipingWeight = 0.0, structualWeight = 0.0, electricalWeight = 0.0; + double emptyVesselWeight = 0.0; + double internalsWeight = 0.0; + double externalNozzelsWeight = 0.0; + double pipingWeight = 0.0; + double structualWeight = 0.0; + double electricalWeight = 0.0; double totalSkidWeight = 0.0; // double moduleWidth = 0.0, moduleHeight = 0.0, moduleLength = 0.0; @@ -140,7 +144,7 @@ public void calcDesign() { // maxDesignVolumeFlow = ((Compressor) // getProcessEquipment()).getThermoSystem().getPhase(0).getVolume() / 1e5; - double maxGasVelocity = 1;// Math.sqrt((liqDensity - gasDensity) / gasDensity); + double maxGasVelocity = 1; // Math.sqrt((liqDensity - gasDensity) / gasDensity); innerDiameter = Math.sqrt(4.0 * getMaxDesignVolumeFlow() / (neqsim.thermo.ThermodynamicConstantsInterface.pi * maxGasVelocity * Fg)); tantanLength = innerDiameter * 5.0; @@ -148,9 +152,10 @@ public void calcDesign() { // alternative design // double bubbleDiameter = 250.0e-6; - // double bubVelocity = 1;// 9.82 * Math.pow(bubbleDiameter, 2.0) * (liqDensity - double Ar = 1.0;// ((Separator) getProcessEquipment()).getThermoSystem().getPhase(1).getVolume() - // / 1e5 / bubVelocity; + // double bubVelocity = 1; // 9.82 * Math.pow(bubbleDiameter, 2.0) * (liqDensity + double Ar = 1.0; // ((Separator) + // getProcessEquipment()).getThermoSystem().getPhase(1).getVolume() + // / 1e5 / bubVelocity; double Daim = Math.sqrt(Ar / 4.0); double Length2 = 4.0 * Daim; diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/SeparatorMechanicalDesign.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/SeparatorMechanicalDesign.java index 14f6f1fb3b..ee3e75fd69 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/SeparatorMechanicalDesign.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/SeparatorMechanicalDesign.java @@ -76,9 +76,9 @@ public void readDesignSpecifications() { volumeSafetyFactor = ((SeparatorDesignStandard) getDesignStandard().get("separator process design")) .getVolumetricDesignFactor(); - retentionTime = 120.0;// ((SeparatorDesignStandard) - // getDesignStandard().get("separator process - // design")).getLiquidRetentionTime("API12J", this); + retentionTime = 120.0; // ((SeparatorDesignStandard) + // getDesignStandard().get("separator process + // design")).getLiquidRetentionTime("API12J", this); } else { System.out.println("no separator process design specified......"); return; @@ -93,7 +93,7 @@ public void displayResults() { dialogContentPane.setLayout(new BorderLayout()); String[] names = {"Name", "Value", "Unit"}; - String[][] table = new String[16][3];// createTable(getProcessEquipment().getName()); + String[][] table = new String[16][3]; // createTable(getProcessEquipment().getName()); table[1][0] = "Separator Inner Diameter"; table[1][1] = Double.toString(getInnerDiameter()); @@ -151,8 +151,12 @@ public void calcDesign() { separator.getThermoSystem().initPhysicalProperties(); separator.setDesignLiquidLevelFraction(Fg); - double emptyVesselWeight = 0.0, internalsWeight = 0.0, externalNozzelsWeight = 0.0; - double pipingWeight = 0.0, structualWeight = 0.0, electricalWeight = 0.0; + double emptyVesselWeight = 0.0; + double internalsWeight = 0.0; + double externalNozzelsWeight = 0.0; + double pipingWeight = 0.0; + double structualWeight = 0.0; + double electricalWeight = 0.0; double totalSkidWeight = 0.0; // double moduleWidth = 0.0, moduleHeight = 0.0, moduleLength = 0.0; diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/valve/ValveMechanicalDesign.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/valve/ValveMechanicalDesign.java index d7919dd15c..cb4e74f6c5 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/valve/ValveMechanicalDesign.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/valve/ValveMechanicalDesign.java @@ -79,7 +79,7 @@ public void displayResults() { String[] names = {"Name", "Value", "Unit"}; - String[][] table = new String[16][3];// createTable(getProcessEquipment().getName()); + String[][] table = new String[16][3]; // createTable(getProcessEquipment().getName()); table[1][0] = "Valve weight [kg]"; table[1][1] = Double.toString(valveWeight); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchanger.java b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchanger.java index 7754120bf1..fd491f2d05 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchanger.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchanger.java @@ -332,7 +332,7 @@ else if (firstTime) { NTU = UAvalue / Cmin; thermalEffectiveness = calcThermalEffectivenes(NTU, Cr); - // double corrected_Entalphy = dEntalphy;// * + // double corrected_Entalphy = dEntalphy; // * // inStream[1].getThermoSystem().getNumberOfMoles() / // inStream[0].getThermoSystem().getNumberOfMoles(); dEntalphy = thermalEffectiveness * dEntalphy; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticTwoPhasePipe.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticTwoPhasePipe.java index 0a136025ae..c8e0e2adb7 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticTwoPhasePipe.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticTwoPhasePipe.java @@ -159,7 +159,7 @@ public double calcPressureOut() { double reynoldsNumber = velocity * insideDiameter / system.getKinematicViscosity("m2/sec"); double frictionFactor = calcWallFrictionFactor(reynoldsNumber); double dp = 2.0 * frictionFactor * length * Math.pow(system.getFlowRate("kg/sec"), 2.0) - / insideDiameter / system.getDensity("kg/m3");// * () * + / insideDiameter / system.getDensity("kg/m3"); // * () * // neqsim.thermo.ThermodynamicConstantsInterface.R // / system.getMolarMass() * system.getTemperature() / Math.pow(insideDiameter, // 5.0); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/SeparatorSection.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/SeparatorSection.java index 56f3647965..1b744cfdff 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/SeparatorSection.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/SeparatorSection.java @@ -18,7 +18,7 @@ public class SeparatorSection extends NamedBaseClass { private double efficiency = 0.95; public Separator separator = null; private boolean calcEfficiency = false; - private double pressureDrop = 33 / 5.0 * 1e-3;// bar + private double pressureDrop = 33 / 5.0 * 1e-3; // bar String type; public double outerDiameter = 1.0; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/MoleFractionControllerUtil.java b/src/main/java/neqsim/processSimulation/processEquipment/util/MoleFractionControllerUtil.java index 8890c03d75..844fde692d 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/MoleFractionControllerUtil.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/MoleFractionControllerUtil.java @@ -21,7 +21,9 @@ public class MoleFractionControllerUtil extends TwoPortEquipment { SystemInterface thermoSystem; ThermodynamicOperations thermoOps; String compName = null; - double moleFrac = 1.0, molesChange = 0.0, moleFractionReductionRatio = 0.0; + double moleFrac = 1.0; + double molesChange = 0.0; + double moleFractionReductionRatio = 0.0; boolean moleFractionReduction = false; /** @@ -129,7 +131,7 @@ public void run(UUID id) { (moleFractionReductionRatio) * thermoSystem.getPhase(0).getComponent(compName).getz(); } double molesChange = deltaFrac * thermoSystem.getTotalNumberOfMoles(); - thermoSystem.addComponent(compName, molesChange);// deltaFrac*thermoSystem.getTotalNumberOfMoles()); + thermoSystem.addComponent(compName, molesChange); // deltaFrac*thermoSystem.getTotalNumberOfMoles()); thermoOps.TPflash(); } outStream.setThermoSystem(thermoSystem); diff --git a/src/main/java/neqsim/processSimulation/processSystem/processModules/AdsorptionDehydrationlModule.java b/src/main/java/neqsim/processSimulation/processSystem/processModules/AdsorptionDehydrationlModule.java index 7d682061a2..34333bb6ff 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/processModules/AdsorptionDehydrationlModule.java +++ b/src/main/java/neqsim/processSimulation/processSystem/processModules/AdsorptionDehydrationlModule.java @@ -19,11 +19,15 @@ public class AdsorptionDehydrationlModule extends ProcessModuleBaseClass { private static final long serialVersionUID = 1000; - protected StreamInterface gasStreamToAdsorber = null, gasStreamFromAdsorber = null; + protected StreamInterface gasStreamToAdsorber = null; + protected StreamInterface gasStreamFromAdsorber = null; protected SimpleAdsorber[] adsorber = null; - double regenerationCycleTime = 1.0, waterDewPontTemperature = 273.15 - 10.0, designFlow = 1.0, - designAdsorptionTemperature = 298.0, designRegenerationTemperature = 440.0, - designAdsorptionPressure = 60.0; + double regenerationCycleTime = 1.0; + double waterDewPontTemperature = 273.15 - 10.0; + double designFlow = 1.0; + double designAdsorptionTemperature = 298.0; + double designRegenerationTemperature = 440.0; + double designAdsorptionPressure = 60.0; int numberOfAdorptionBeds = 3; double adsorberInternalDiameter = 1.0; double adsorbentFillingHeight = 3.0; @@ -154,14 +158,14 @@ public void calcDesign() { double waterLoadingCycle = regenerationCycleTime * designFlow * 42.29489667 * tempStream.getThermoSystem().getPhase(0).getComponent("water").getx() - * tempStream.getThermoSystem().getPhase(0).getComponent("water").getMolarMass();// 360.0; - // // - // kg/cycle - // this - // needs - // to - // be - // calculated + * tempStream.getThermoSystem().getPhase(0).getComponent("water").getMolarMass(); // 360.0; + // // + // kg/cycle + // this + // needs + // to + // be + // calculated double usefulDesiccantCapacity = 10.0; // 10% double bulkDensityDesiccant = 750.0; // 10% diff --git a/src/main/java/neqsim/processSimulation/processSystem/processModules/GlycolDehydrationlModule.java b/src/main/java/neqsim/processSimulation/processSystem/processModules/GlycolDehydrationlModule.java index 816a8245a0..d0ab2b1ddd 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/processModules/GlycolDehydrationlModule.java +++ b/src/main/java/neqsim/processSimulation/processSystem/processModules/GlycolDehydrationlModule.java @@ -24,25 +24,50 @@ public class GlycolDehydrationlModule extends ProcessModuleBaseClass { private static final long serialVersionUID = 1000; - protected StreamInterface gasStreamToAbsorber = null, strippingGas = null, - gasStreamFromAbsorber = null, gasFromStripper = null, leanTEGStreamToAbsorber = null; + protected StreamInterface gasStreamToAbsorber = null; + + protected StreamInterface strippingGas = null; + + protected StreamInterface gasStreamFromAbsorber = null; + + protected StreamInterface gasFromStripper = null; + + protected StreamInterface leanTEGStreamToAbsorber = null; + protected SimpleTEGAbsorber absorbtionColumn = null; // protected DistillationColumn stripperColumn = null; protected Separator stripperColumn = null; Heater reboiler = null; protected Pump HPpump = null; - protected Separator glycolFlashDrum = null, waterSeparator = null; - protected ThrottlingValve valveHP = null, valveMP = null; - Cooler heatExchanger1 = null, heatExchanger2 = null, heatExchanger3 = null; + protected Separator glycolFlashDrum = null; + protected Separator waterSeparator = null; + protected ThrottlingValve valveHP = null; + protected ThrottlingValve valveMP = null; + + Cooler heatExchanger1 = null; + Cooler heatExchanger2 = null; + Cooler heatExchanger3 = null; + double waterDewPontSpecification = 273.15 - 10.0; double numberOfTheoreticalEquilibriumStages = 2; private double flashPressure = 5.0; - double designStandardGasFlowRate = 20.0, maxAbsorberDesignPressure = 70.0; + double designStandardGasFlowRate = 20.0; + + double maxAbsorberDesignPressure = 70.0; + double designGasFeedTemperature = 273.15 + 30.0; - double leanGlycolMolarFraction = 0.95, leanGlycolwtFraction = 0.99, leanGlycolMolarFlowRate = 1.0, - maxglycolFlowRate = 1; + double leanGlycolMolarFraction = 0.95; + + double leanGlycolwtFraction = 0.99; + + double leanGlycolMolarFlowRate = 1.0; + + double maxglycolFlowRate = 1; + String glycolTypeName = "TEG"; - double reboilerTemperature = 273.15 + 204.0, regenerationPressure = 1.4; + double reboilerTemperature = 273.15 + 204.0; + + double regenerationPressure = 1.4; public GlycolDehydrationlModule(String name) { super(name); @@ -91,8 +116,10 @@ public StreamInterface getOutputStream(String streamName) { * @return a double */ public double solveAbsorptionFactor(double Ea) { - double A = 7.0, Aold = 7.0; - double error = 1.0, errorOld = 1.0; + double A = 7.0; + double Aold = 7.0; + double error = 1.0; + double errorOld = 1.0; int iter = 0; do { iter++; @@ -279,8 +306,10 @@ public double calcGlycolConcentration(double y0) { double dn = 1.0 * tempStream.getThermoSystem().getPhase(0).getComponent("water").getNumberOfMolesInPhase(); - double error = 1.0, oldError = 0.0; - double oldNumberOfMoles = 0.0, numberOfMoles = 0.0; + double error = 1.0; + double oldError = 0.0; + double oldNumberOfMoles = 0.0; + double numberOfMoles = 0.0; int iter = 0; do { iter++; @@ -290,8 +319,8 @@ public double calcGlycolConcentration(double y0) { numberOfMoles = tempStream.getThermoSystem().getPhase(0).getComponent("TEG").getNumberOfmoles(); oldError = error; - error = (tempStream.getThermoSystem().getPhase(0).getComponent("water").getx() - y0);// / - // y0; + error = (tempStream.getThermoSystem().getPhase(0).getComponent("water").getx() - y0); // / + // y0; double derrordn = (error - oldError) / (numberOfMoles - oldNumberOfMoles); if (iter < 2) { @@ -347,9 +376,9 @@ public void calcDesign() { double yN = gasStreamToAbsorber.getThermoSystem().getPhase(0).getComponent("water").getx(); // Estimates K value - double K = calcKglycol();// gasStreamToAbsorber.getThermoSystem().getPhase(1).getComponent("water").getFugacityCoefficient() - // / - // gasStreamToAbsorber.getThermoSystem().getPhase(0).getComponent("water").getFugacityCoefficient(); + double K = calcKglycol(); // gasStreamToAbsorber.getThermoSystem().getPhase(1).getComponent("water").getFugacityCoefficient() + // / + // gasStreamToAbsorber.getThermoSystem().getPhase(0).getComponent("water").getFugacityCoefficient(); gasStreamFromAbsorber = gasStreamToAbsorber.clone(); // gasStreamFromAbsorber.getThermoSystem().addComponent("water", 1.0); gasStreamFromAbsorber.getThermoSystem().setTemperature(waterDewPontSpecification); diff --git a/src/main/java/neqsim/processSimulation/processSystem/processModules/MixerGasProcessingModule.java b/src/main/java/neqsim/processSimulation/processSystem/processModules/MixerGasProcessingModule.java index dec0112a4b..c9ec106d65 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/processModules/MixerGasProcessingModule.java +++ b/src/main/java/neqsim/processSimulation/processSystem/processModules/MixerGasProcessingModule.java @@ -23,14 +23,23 @@ public class MixerGasProcessingModule extends ProcessModuleBaseClass { private static final long serialVersionUID = 1000; - StreamInterface feedStream, gasExitStream, oilExitStream, glycolFeedStream, glycolExitStream; + StreamInterface feedStream; + StreamInterface gasExitStream; + StreamInterface oilExitStream; + StreamInterface glycolFeedStream; + StreamInterface glycolExitStream; + Separator glycolScrubber; Separator inletSeparator; double inletSepTemperature = 50.00; // bar' - double gasScrubberTemperature = 30.00, firstStageOutPressure = 110.0, - glycolScrubberTemperature = 20.0, secondStageOutPressure = 200.0; // bar - double glycolInjectionRate = 10.0, exportGasTemperature = 273.15 + 30.0, - liquidPumpPressure = 150.0; // m^3/hr + double gasScrubberTemperature = 30.00; + double firstStageOutPressure = 110.0; + double glycolScrubberTemperature = 20.0; + double secondStageOutPressure = 200.0; + double glycolInjectionRate = 10.0; + double exportGasTemperature = 273.15 + 30.0; + double liquidPumpPressure = 150.0; + Compressor secondStageCompressor; Pump oilPump; Cooler secondStageAfterCooler; diff --git a/src/main/java/neqsim/processSimulation/util/monitor/PumpResponse.java b/src/main/java/neqsim/processSimulation/util/monitor/PumpResponse.java index 3deaf18f37..6778269202 100644 --- a/src/main/java/neqsim/processSimulation/util/monitor/PumpResponse.java +++ b/src/main/java/neqsim/processSimulation/util/monitor/PumpResponse.java @@ -58,7 +58,7 @@ public PumpResponse(Pump inputPump) { // polytropicHead = inputCompressor.getPolytropicFluidHead(); // polytropicEfficiency =inputCompressor.getPolytropicEfficiency(); - power = inputPump.getPower("W");// "kW"); + power = inputPump.getPower("W"); // "kW"); // speed = inputPump.getSpeed(); // if(inputCompressor.getAntiSurge().isActive()){ // internalVolumeFlow = diff --git a/src/main/java/neqsim/standards/Standard.java b/src/main/java/neqsim/standards/Standard.java index 43ac359d6a..da13b20ceb 100644 --- a/src/main/java/neqsim/standards/Standard.java +++ b/src/main/java/neqsim/standards/Standard.java @@ -119,7 +119,7 @@ public String[][] createTable(String name) { nf.applyPattern("#.#####E0"); String[][] table = new String[thermoSystem.getPhases()[0].getNumberOfComponents() + 30][6]; // String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"}; - table[0][0] = "";// getPhases()[0].getPhaseTypeName();//""; + table[0][0] = ""; // getPhases()[0].getPhaseTypeName(); //""; for (int i = 0; i < thermoSystem.getPhases()[0].getNumberOfComponents() + 30; i++) { for (int j = 0; j < 6; j++) { diff --git a/src/main/java/neqsim/standards/gasQuality/Draft_GERG2004.java b/src/main/java/neqsim/standards/gasQuality/Draft_GERG2004.java index 9c2d92b7f6..6e141b63c0 100644 --- a/src/main/java/neqsim/standards/gasQuality/Draft_GERG2004.java +++ b/src/main/java/neqsim/standards/gasQuality/Draft_GERG2004.java @@ -109,7 +109,7 @@ public String[][] createTable(String name) { nf.applyPattern("#.#####E0"); String[][] table = new String[thermoSystem.getPhases()[0].getNumberOfComponents() + 30][6]; // String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"}; - table[0][0] = "";// getPhases()[0].getPhaseTypeName();//""; + table[0][0] = ""; // getPhases()[0].getPhaseTypeName(); //""; for (int i = 0; i < thermoSystem.getPhases()[0].getNumberOfComponents() + 30; i++) { for (int j = 0; j < 6; j++) { diff --git a/src/main/java/neqsim/standards/gasQuality/Standard_ISO6578.java b/src/main/java/neqsim/standards/gasQuality/Standard_ISO6578.java index eaf4e634c7..b5e4ffc70d 100644 --- a/src/main/java/neqsim/standards/gasQuality/Standard_ISO6578.java +++ b/src/main/java/neqsim/standards/gasQuality/Standard_ISO6578.java @@ -18,7 +18,8 @@ public class Standard_ISO6578 extends neqsim.standards.Standard { private static final long serialVersionUID = 1L; double LNGdensity = 0.0; String densityUnit = "kg/m^3"; - double KMcorrectionFactor1 = 0.0, KMcorrectionFactor2 = 0.0; + double KMcorrectionFactor1 = 0.0; + double KMcorrectionFactor2 = 0.0; double[] Vi = null; boolean use6578volumeCorrectionFactors = true; double[] temperatures = {105.0, 110.0, 115.0, 120.0, 125.0, 130.0, 135.0}; @@ -71,11 +72,12 @@ public class Standard_ISO6578 extends neqsim.standards.Standard { {1.31, 1.5, 1.72, 1.99, 2.33, 2.77, 3.31, 3.95, 4.74}, {1.38, 1.59, 1.83, 2.12, 2.48, 2.95, 3.51, 4.19, 5.03}, {1.47, 1.68, 1.93, 2.24, 2.63, 3.12, 3.72, 4.45, 5.34}}; - BicubicInterpolatingFunction pcs1 = null, pcs2 = null; + BicubicInterpolatingFunction pcs1 = null; + BicubicInterpolatingFunction pcs2 = null; LinearInterpolator liearInterpol = new LinearInterpolator(); - double[] Vitemperatures = ISO6578temperatures;// {-180.0, -175.0, -170.0, -165.0, -160.0, - // -155.0, -150.0, -145.0, - // -140.0}; + double[] Vitemperatures = ISO6578temperatures; // {-180.0, -175.0, -170.0, -165.0, -160.0, + // -155.0, -150.0, -145.0, + // -140.0}; double[] Vimethane = {0.035771, 0.036315, 0.036891, 0.037500, 0.038149, 0.038839, 0.039580, 0.040375, 0.041237}; double[] Viethane = @@ -211,7 +213,8 @@ public void calculate() { Vmix += thermoSystem.getPhase(0).getComponent(i).getx() * Vi[i]; } - double xn2 = 0.0, xch4 = 0.0; + double xn2 = 0.0; + double xch4 = 0.0; try { KMcorrectionFactor1 = pcs1.value(thermoSystem.getPhase(0).getMolarMass() * 1000.0, thermoSystem.getTemperature()); diff --git a/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976.java b/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976.java index 3d30b9855c..e37c32c606 100644 --- a/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976.java +++ b/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976.java @@ -31,23 +31,49 @@ public class Standard_ISO6976 extends neqsim.standards.Standard String referenceType = "volume"; // mass volume molar String energyUnit = "KJ/Nm3"; double energy = 1.0; - double Zmix0 = 1.0, Zmix15 = 1.0, Zmix20 = 1.0; - double Zair0 = 0.99941, Zair15 = 0.99958, Zair20 = 0.99963; + double Zmix0 = 1.0; + double Zmix15 = 1.0; + double Zmix20 = 1.0; + double Zair0 = 0.99941; + double Zair15 = 0.99958; + double Zair20 = 0.99963; double averageCarbonNumber = 0.0; int[] carbonNumber; double[] M; - double[] Z0, Z15, Z20; - double[] bsqrt0, bsqrt15, bsqrt20; - double[] Hsup0, Hsup15, Hsup20, Hsup25, Hsup60F; - double[] Hinf0, Hinf15, Hinf20, Hinf25, Hinf60F; + double[] Z0; + double[] Z15; + double[] Z20; + double[] bsqrt0; + double[] bsqrt15; + double[] bsqrt20; + double[] Hsup0; + double[] Hsup15; + double[] Hsup20; + double[] Hsup25; + double[] Hsup60F; + double[] Hinf0; + double[] Hinf15; + double[] Hinf20; + double[] Hinf25; + double[] Hinf60F; double Mmix = 0.0; - double HsupIdeal0 = 0.0, HsupIdeal15 = 0.0, HsupIdeal20 = 0.0, HsupIdeal25 = 0.0, - HsupIdeal60F = 0.0; - double HinfIdeal0 = 0.0, HinfIdeal15 = 0.0, HinfIdeal20 = 0.0, HinfIdeal25 = 0.0, - HinfIdeal60F = 0.0; - double wobbeIdeal = 0.0, wobbeReal = 0.0; - double relDensIdeal = 0.0, relDensReal = 0.0; - double densIdeal = 0.0, densReal = 0.0; + double HsupIdeal0 = 0.0; + double HsupIdeal15 = 0.0; + double HsupIdeal20 = 0.0; + double HsupIdeal25 = 0.0; + double HsupIdeal60F = 0.0; + double HinfIdeal0 = 0.0; + double HinfIdeal15 = 0.0; + double HinfIdeal20 = 0.0; + double HinfIdeal25 = 0.0; + double HinfIdeal60F = 0.0; + double wobbeIdeal = 0.0; + double wobbeReal = 0.0; + double relDensIdeal = 0.0; + double relDensReal = 0.0; + double densIdeal = 0.0; + double densReal = 0.0; + static Logger logger = LogManager.getLogger(Standard_ISO6976.class); public Standard_ISO6976(SystemInterface thermoSystem) { @@ -386,7 +412,7 @@ public String[][] createTable(String name) { nf.applyPattern("#.#####E0"); String[][] table = new String[thermoSystem.getPhases()[0].getNumberOfComponents() + 30][6]; // String[] names = { "", "Phase 1", "Phase 2", "Phase 3", "Unit" }; - table[0][0] = "";// getPhases()[0].getPhaseTypeName();//""; + table[0][0] = ""; // getPhases()[0].getPhaseTypeName(); //""; for (int i = 0; i < thermoSystem.getPhases()[0].getNumberOfComponents() + 30; i++) { for (int j = 0; j < 6; j++) { diff --git a/src/main/java/neqsim/standards/gasQuality/UKspecifications_ICF_SI.java b/src/main/java/neqsim/standards/gasQuality/UKspecifications_ICF_SI.java index 1043de78bd..b545053302 100644 --- a/src/main/java/neqsim/standards/gasQuality/UKspecifications_ICF_SI.java +++ b/src/main/java/neqsim/standards/gasQuality/UKspecifications_ICF_SI.java @@ -15,7 +15,8 @@ */ public class UKspecifications_ICF_SI extends neqsim.standards.Standard { private static final long serialVersionUID = 1L; - String componentName = "", unit = "-"; + String componentName = ""; + String unit = "-"; Standard_ISO6976 iso6976 = null; double propaneNumber = 0.0; @@ -84,8 +85,8 @@ public boolean isOnSpec() { public double calcPropaneNumber() { double avgCarbon = iso6976.getAverageCarbonNumber(); - double[][] Amatrix = {{1.0, 1.0}, {1.0, 3.0}};// {thermoSystem.getNumberOfMoles(), - // thermoSystem.getNumberOfMoles()*iso6976.getAverageCarbonNumber()}}; + double[][] Amatrix = {{1.0, 1.0}, {1.0, 3.0}}; // {thermoSystem.getNumberOfMoles(), + // thermoSystem.getNumberOfMoles()*iso6976.getAverageCarbonNumber()}}; double[] bmatrix = {(thermoSystem.getTotalNumberOfMoles() - iso6976.getTotalMolesOfInerts()), avgCarbon * (thermoSystem.getTotalNumberOfMoles() - iso6976.getTotalMolesOfInerts())}; @@ -129,7 +130,8 @@ public double calcWithNitrogenAsInert() { } localIso6976.removeInertsButNitrogen(); - double newWI = targetWI / 1.01, oldWI = 0.0; + double newWI = targetWI / 1.01; + double oldWI = 0.0; double dn2 = 0.1; // double dWIdN2; int iter = 0; diff --git a/src/main/java/neqsim/statistics/monteCarloSimulation/MonteCarloSimulation.java b/src/main/java/neqsim/statistics/monteCarloSimulation/MonteCarloSimulation.java index ae26a789d0..1361d354ca 100644 --- a/src/main/java/neqsim/statistics/monteCarloSimulation/MonteCarloSimulation.java +++ b/src/main/java/neqsim/statistics/monteCarloSimulation/MonteCarloSimulation.java @@ -19,86 +19,86 @@ * @version $Id: $Id */ public class MonteCarloSimulation { - StatisticsInterface baseStatClass; - StatisticsInterface[] statClasses; - double[][] reportMatrix; - int numberOfRuns = 50; + StatisticsInterface baseStatClass; + StatisticsInterface[] statClasses; + double[][] reportMatrix; + int numberOfRuns = 50; - /** - *

- * Constructor for MonteCarloSimulation. - *

- */ - public MonteCarloSimulation() {} + /** + *

+ * Constructor for MonteCarloSimulation. + *

+ */ + public MonteCarloSimulation() {} - /** - *

- * Constructor for MonteCarloSimulation. - *

- * - * @param baseStatClass a {@link neqsim.statistics.parameterFitting.StatisticsInterface} object - */ - public MonteCarloSimulation(StatisticsInterface baseStatClass) { - this.baseStatClass = baseStatClass; - } + /** + *

+ * Constructor for MonteCarloSimulation. + *

+ * + * @param baseStatClass a {@link neqsim.statistics.parameterFitting.StatisticsInterface} object + */ + public MonteCarloSimulation(StatisticsInterface baseStatClass) { + this.baseStatClass = baseStatClass; + } - /** - *

- * Constructor for MonteCarloSimulation. - *

- * - * @param baseStatClass a {@link neqsim.statistics.parameterFitting.StatisticsBaseClass} object - * @param numberOfRuns a int - */ - public MonteCarloSimulation(StatisticsBaseClass baseStatClass, int numberOfRuns) { - this.baseStatClass = baseStatClass; - this.numberOfRuns = numberOfRuns; - } + /** + *

+ * Constructor for MonteCarloSimulation. + *

+ * + * @param baseStatClass a {@link neqsim.statistics.parameterFitting.StatisticsBaseClass} object + * @param numberOfRuns a int + */ + public MonteCarloSimulation(StatisticsBaseClass baseStatClass, int numberOfRuns) { + this.baseStatClass = baseStatClass; + this.numberOfRuns = numberOfRuns; + } - /** - *

- * Setter for the field numberOfRuns. - *

- * - * @param numberOfRuns a int - */ - public void setNumberOfRuns(int numberOfRuns) { - this.numberOfRuns = numberOfRuns; - } + /** + *

+ * Setter for the field numberOfRuns. + *

+ * + * @param numberOfRuns a int + */ + public void setNumberOfRuns(int numberOfRuns) { + this.numberOfRuns = numberOfRuns; + } - /** - *

- * runSimulation. - *

- */ - public void runSimulation() { - baseStatClass.init(); - statClasses = new StatisticsInterface[numberOfRuns]; - for (int i = 0; i < numberOfRuns; i++) { - statClasses[i] = baseStatClass.createNewRandomClass(); - statClasses[i].solve(); - } - createReportMatrix(); + /** + *

+ * runSimulation. + *

+ */ + public void runSimulation() { + baseStatClass.init(); + statClasses = new StatisticsInterface[numberOfRuns]; + for (int i = 0; i < numberOfRuns; i++) { + statClasses[i] = baseStatClass.createNewRandomClass(); + statClasses[i].solve(); } + createReportMatrix(); + } - /** - *

- * createReportMatrix. - *

- */ - public void createReportMatrix() { - reportMatrix = new double[10][numberOfRuns]; - for (int i = 0; i < numberOfRuns; i++) { - reportMatrix[0][i] = i; + /** + *

+ * createReportMatrix. + *

+ */ + public void createReportMatrix() { + reportMatrix = new double[10][numberOfRuns]; + for (int i = 0; i < numberOfRuns; i++) { + reportMatrix[0][i] = i; - for (int j = 0; j < statClasses[0].getSampleSet().getSample(0).getFunction() - .getNumberOfFittingParams(); j++) { - reportMatrix[j + 1][i] = statClasses[i].getSampleSet().getSample(0).getFunction() - .getFittingParams(j); - } - } - - Matrix report = new Matrix(reportMatrix);// .print(10,2); - report.print(10, 17); + for (int j = 0; j < statClasses[0].getSampleSet().getSample(0).getFunction() + .getNumberOfFittingParams(); j++) { + reportMatrix[j + 1][i] = + statClasses[i].getSampleSet().getSample(0).getFunction().getFittingParams(j); + } } + + Matrix report = new Matrix(reportMatrix); // .print(10,2); + report.print(10, 17); + } } diff --git a/src/main/java/neqsim/statistics/parameterFitting/SampleValue.java b/src/main/java/neqsim/statistics/parameterFitting/SampleValue.java index ad4c429172..18209a5eee 100644 --- a/src/main/java/neqsim/statistics/parameterFitting/SampleValue.java +++ b/src/main/java/neqsim/statistics/parameterFitting/SampleValue.java @@ -18,228 +18,227 @@ * @version $Id: $Id */ public class SampleValue implements Cloneable { - protected FunctionInterface testFunction; - double sampleValue = 0; - double[] dependentValues; - String reference = "unknown"; - String description = "unknown"; - /** - * Standard deviation of function value - */ - double standardDeviation = 0.0001; - public SystemInterface system; - public ThermodynamicOperations thermoOps; - /** - * Standard deviation of dependent variables - */ - double[] standardDeviations; - - /** - *

- * Constructor for SampleValue. - *

- */ - public SampleValue() {} - - /** - *

- * Constructor for SampleValue. - *

- * - * @param sampleValue a double - * @param standardDeviation a double - * @param dependentValues an array of {@link double} objects - */ - public SampleValue(double sampleValue, double standardDeviation, double[] dependentValues) { - this.dependentValues = new double[dependentValues.length]; - this.sampleValue = sampleValue; - this.standardDeviation = standardDeviation; - System.arraycopy(dependentValues, 0, this.dependentValues, 0, dependentValues.length); - } - - /** - *

- * Constructor for SampleValue. - *

- * - * @param sampleValue a double - * @param standardDeviation a double - * @param dependentValues an array of {@link double} objects - * @param standardDeviations an array of {@link double} objects - */ - public SampleValue(double sampleValue, double standardDeviation, double[] dependentValues, - double[] standardDeviations) { - this(sampleValue, standardDeviation, dependentValues); - this.standardDeviations = standardDeviations; - } - - /** {@inheritDoc} */ - @Override - public SampleValue clone() { - SampleValue clonedValue = null; - try { - clonedValue = (SampleValue) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); - } - // this was modified 20.05.2002 - // clonedValue.system = system.clone(); - clonedValue.testFunction = testFunction.clone(); - clonedValue.dependentValues = this.dependentValues.clone(); - System.arraycopy(dependentValues, 0, clonedValue.dependentValues, 0, - dependentValues.length); - - return clonedValue; - } - - /** - *

- * setThermodynamicSystem. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public void setThermodynamicSystem(SystemInterface system) { - this.system = system;// system.clone(); - thermoOps = new ThermodynamicOperations(system); - this.getFunction().setThermodynamicSystem(this.system); - } - - /** - *

- * setFunction. - *

- * - * @param function a {@link neqsim.statistics.parameterFitting.BaseFunction} object - */ - public void setFunction(BaseFunction function) { - testFunction = function; - } - - /** - *

- * getFunction. - *

- * - * @return a {@link neqsim.statistics.parameterFitting.FunctionInterface} object - */ - public FunctionInterface getFunction() { - return testFunction; - } - - /** - *

- * Getter for the field standardDeviation. - *

- * - * @return a double - */ - public double getStandardDeviation() { - return standardDeviation; - } - - /** - *

- * Getter for the field standardDeviation. - *

- * - * @param i a int - * @return a double - */ - public double getStandardDeviation(int i) { - return standardDeviations[i]; - } - - /** - *

- * Getter for the field sampleValue. - *

- * - * @return a double - */ - public double getSampleValue() { - return sampleValue; - } - - /** - *

- * Getter for the field dependentValues. - *

- * - * @return an array of {@link double} objects - */ - public double[] getDependentValues() { - return dependentValues; - } - - /** - *

- * getDependentValue. - *

- * - * @param i a int - * @return a double - */ - public double getDependentValue(int i) { - return dependentValues[i]; - } - - /** - *

- * Setter for the field dependentValues. - *

- * - * @param vals an array of {@link double} objects - */ - public void setDependentValues(double[] vals) { - System.arraycopy(vals, 0, this.dependentValues, 0, dependentValues.length); - } - - /** - *

- * setDependentValue. - *

- * - * @param i a int - * @param val a double - */ - public void setDependentValue(int i, double val) { - this.dependentValues[i] = val; - } - - /** - * Getter for property reference. - * - * @return Value of property reference. - */ - public java.lang.String getReference() { - return reference; - } - - /** - * Setter for property reference. - * - * @param reference New value of property reference. - */ - public void setReference(java.lang.String reference) { - this.reference = reference; - } - - /** - * Getter for property description. - * - * @return Value of property description. - */ - public java.lang.String getDescription() { - return description; - } - - /** - * Setter for property description. - * - * @param description New value of property description. - */ - public void setDescription(java.lang.String description) { - this.description = description; - } + protected FunctionInterface testFunction; + double sampleValue = 0; + double[] dependentValues; + String reference = "unknown"; + String description = "unknown"; + /** + * Standard deviation of function value + */ + double standardDeviation = 0.0001; + public SystemInterface system; + public ThermodynamicOperations thermoOps; + /** + * Standard deviation of dependent variables + */ + double[] standardDeviations; + + /** + *

+ * Constructor for SampleValue. + *

+ */ + public SampleValue() {} + + /** + *

+ * Constructor for SampleValue. + *

+ * + * @param sampleValue a double + * @param standardDeviation a double + * @param dependentValues an array of {@link double} objects + */ + public SampleValue(double sampleValue, double standardDeviation, double[] dependentValues) { + this.dependentValues = new double[dependentValues.length]; + this.sampleValue = sampleValue; + this.standardDeviation = standardDeviation; + System.arraycopy(dependentValues, 0, this.dependentValues, 0, dependentValues.length); + } + + /** + *

+ * Constructor for SampleValue. + *

+ * + * @param sampleValue a double + * @param standardDeviation a double + * @param dependentValues an array of {@link double} objects + * @param standardDeviations an array of {@link double} objects + */ + public SampleValue(double sampleValue, double standardDeviation, double[] dependentValues, + double[] standardDeviations) { + this(sampleValue, standardDeviation, dependentValues); + this.standardDeviations = standardDeviations; + } + + /** {@inheritDoc} */ + @Override + public SampleValue clone() { + SampleValue clonedValue = null; + try { + clonedValue = (SampleValue) super.clone(); + } catch (Exception e) { + e.printStackTrace(System.err); + } + // this was modified 20.05.2002 + // clonedValue.system = system.clone(); + clonedValue.testFunction = testFunction.clone(); + clonedValue.dependentValues = this.dependentValues.clone(); + System.arraycopy(dependentValues, 0, clonedValue.dependentValues, 0, dependentValues.length); + + return clonedValue; + } + + /** + *

+ * setThermodynamicSystem. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public void setThermodynamicSystem(SystemInterface system) { + this.system = system; // system.clone(); + thermoOps = new ThermodynamicOperations(system); + this.getFunction().setThermodynamicSystem(this.system); + } + + /** + *

+ * setFunction. + *

+ * + * @param function a {@link neqsim.statistics.parameterFitting.BaseFunction} object + */ + public void setFunction(BaseFunction function) { + testFunction = function; + } + + /** + *

+ * getFunction. + *

+ * + * @return a {@link neqsim.statistics.parameterFitting.FunctionInterface} object + */ + public FunctionInterface getFunction() { + return testFunction; + } + + /** + *

+ * Getter for the field standardDeviation. + *

+ * + * @return a double + */ + public double getStandardDeviation() { + return standardDeviation; + } + + /** + *

+ * Getter for the field standardDeviation. + *

+ * + * @param i a int + * @return a double + */ + public double getStandardDeviation(int i) { + return standardDeviations[i]; + } + + /** + *

+ * Getter for the field sampleValue. + *

+ * + * @return a double + */ + public double getSampleValue() { + return sampleValue; + } + + /** + *

+ * Getter for the field dependentValues. + *

+ * + * @return an array of {@link double} objects + */ + public double[] getDependentValues() { + return dependentValues; + } + + /** + *

+ * getDependentValue. + *

+ * + * @param i a int + * @return a double + */ + public double getDependentValue(int i) { + return dependentValues[i]; + } + + /** + *

+ * Setter for the field dependentValues. + *

+ * + * @param vals an array of {@link double} objects + */ + public void setDependentValues(double[] vals) { + System.arraycopy(vals, 0, this.dependentValues, 0, dependentValues.length); + } + + /** + *

+ * setDependentValue. + *

+ * + * @param i a int + * @param val a double + */ + public void setDependentValue(int i, double val) { + this.dependentValues[i] = val; + } + + /** + * Getter for property reference. + * + * @return Value of property reference. + */ + public java.lang.String getReference() { + return reference; + } + + /** + * Setter for property reference. + * + * @param reference New value of property reference. + */ + public void setReference(java.lang.String reference) { + this.reference = reference; + } + + /** + * Getter for property description. + * + * @return Value of property description. + */ + public java.lang.String getDescription() { + return description; + } + + /** + * Setter for property description. + * + * @param description New value of property description. + */ + public void setDescription(java.lang.String description) { + this.description = description; + } } diff --git a/src/main/java/neqsim/thermo/atomElement/UNIFACgroup.java b/src/main/java/neqsim/thermo/atomElement/UNIFACgroup.java index 676c82259e..0778d9cae2 100644 --- a/src/main/java/neqsim/thermo/atomElement/UNIFACgroup.java +++ b/src/main/java/neqsim/thermo/atomElement/UNIFACgroup.java @@ -22,11 +22,14 @@ public class UNIFACgroup implements ThermodynamicConstantsInterface, Comparable< double Q = 0.0; int n = 0; double xComp = 0.0; - double QComp = 0.0, QMix = 0.0; - public double[] QMixdN = null;// , xMixdN = null; + double QComp = 0.0; + double QMix = 0.0; + public double[] QMixdN = null; // , xMixdN = null; double[] lnGammaMixdn = new double[MAX_NUMBER_OF_COMPONENTS]; - double lnGammaComp = 0.0, lnGammaMix = 0.0; - double lnGammaCompdT = 0.0, lnGammaMixdT = 0.0; + double lnGammaComp = 0.0; + double lnGammaMix = 0.0; + double lnGammaCompdT = 0.0; + double lnGammaMixdT = 0.0; private double lnGammaCompdTdT = 0.0; private double lnGammaMixdTdT = 0.0; int groupIndex = 0; @@ -242,12 +245,15 @@ public int hashCode() { /** {@inheritDoc} */ // @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } UNIFACgroup other = (UNIFACgroup) obj; return subGroup == other.subGroup; /* @@ -325,7 +331,10 @@ public double calcQComp(ComponentGEUnifac component) { */ public double calcQMix(PhaseGEUnifac phase) { ComponentGEUnifac component; - double temp = 0.0, temp2 = 0.0, tempVar, numberOfMoles; + double temp = 0.0; + double temp2 = 0.0; + double tempVar; + double numberOfMoles; UNIFACgroup unifacGroup; int numberOfGrups = 0; for (int j = 0; j < phase.getNumberOfComponents(); j++) { @@ -359,7 +368,12 @@ public double[] calcQMixdN(PhaseGEUnifac phase) { ComponentGEUnifac component; UNIFACgroup unifacGroup; // calcXMixdN(phase); - double temp, temp2, tempVar, tempdn, temp2dn, tempVardn = 0.0; + double temp; + double temp2; + double tempVar; + double tempdn; + double temp2dn; + double tempVardn = 0.0; for (int k = 0; k < phase.getNumberOfComponents(); k++) { temp = 0.0; temp2 = 0.0; diff --git a/src/main/java/neqsim/thermo/characterization/PedersenPlusModelSolver.java b/src/main/java/neqsim/thermo/characterization/PedersenPlusModelSolver.java index 2b7755a84d..9b03d8e67a 100644 --- a/src/main/java/neqsim/thermo/characterization/PedersenPlusModelSolver.java +++ b/src/main/java/neqsim/thermo/characterization/PedersenPlusModelSolver.java @@ -16,9 +16,13 @@ public class PedersenPlusModelSolver implements java.io.Serializable { private static final long serialVersionUID = 1000; int iter = 0; - Matrix JacAB, JacCD; - Matrix fvecAB, fvecCD; - Matrix solAB, solCD, dx; + Matrix JacAB; + Matrix JacCD; + Matrix fvecAB; + Matrix fvecCD; + Matrix solAB; + Matrix solCD; + Matrix dx; int numberOfComponents = 0; PlusFractionModel.PedersenPlusModel characterizeClass; SystemInterface system = null; @@ -65,7 +69,8 @@ public PedersenPlusModelSolver(SystemInterface system, *

*/ public void setfvecAB() { - double zSum = 0.0, mSum = 0.0; + double zSum = 0.0; + double mSum = 0.0; for (int i = characterizeClass.getFirstPlusFractionNumber(); i < characterizeClass .getLastPlusFractionNumber(); i++) { double ztemp = Math.exp(characterizeClass.getCoef(0) + characterizeClass.getCoef(1) * (i)); @@ -92,7 +97,8 @@ public void setJacAB() { double tempJ = 0.0; for (int j = 0; j < 2; j++) { - double nTot = 0.0, nTot2 = 0.0; + double nTot = 0.0; + double nTot2 = 0.0; for (int i = characterizeClass.getFirstPlusFractionNumber(); i < characterizeClass .getLastPlusFractionNumber(); i++) { nTot += Math.exp(characterizeClass.getCoef(0) + characterizeClass.getCoef(1) * i); @@ -107,7 +113,11 @@ public void setJacAB() { } for (int j = 0; j < 2; j++) { - double mTot1 = 0.0, mTot2 = 0.0, zSum2 = 0.0, zSum = 0.0, zSum3 = 0.0; + double mTot1 = 0.0; + double mTot2 = 0.0; + double zSum2 = 0.0; + double zSum = 0.0; + double zSum3 = 0.0; for (int i = characterizeClass.getFirstPlusFractionNumber(); i < characterizeClass .getLastPlusFractionNumber(); i++) { mTot1 += (characterizeClass.PVTsimMolarMass[i - 6] / 1000.0) @@ -135,10 +145,12 @@ public void setJacAB() { */ public void setfvecCD() { double densTBO = - characterizeClass.PVTsimDensities[characterizeClass.getFirstPlusFractionNumber() - 6]; // 0.71;//characterizeClass.getDensLastTBP(); + characterizeClass.PVTsimDensities[characterizeClass.getFirstPlusFractionNumber() - 6]; // 0.71; + // //characterizeClass.getDensLastTBP(); fvecCD.set(0, 0, (characterizeClass.getCoef(2) + characterizeClass.getCoef(3) * Math.log(characterizeClass.getFirstPlusFractionNumber() - 1)) - densTBO); - double temp = 0.0, temp2 = 0; + double temp = 0.0; + double temp2 = 0; for (int i = characterizeClass.getFirstPlusFractionNumber(); i < characterizeClass .getLastPlusFractionNumber(); i++) { temp += Math.exp(characterizeClass.getCoef(0) + characterizeClass.getCoef(1) * (i)) @@ -161,7 +173,9 @@ public void setJacCD() { JacCD.set(0, 0, 1); JacCD.set(0, 1, Math.log(characterizeClass.getFirstPlusFractionNumber() - 1)); - double temp = 0.0, temp2 = 0, temp3 = 0; + double temp = 0.0; + double temp2 = 0; + double temp3 = 0; // double deriv = 0; for (int i = characterizeClass.getFirstPlusFractionNumber(); i < characterizeClass .getLastPlusFractionNumber(); i++) { diff --git a/src/main/java/neqsim/thermo/characterization/PlusCharacterize.java b/src/main/java/neqsim/thermo/characterization/PlusCharacterize.java index d7a303b4a3..2abff86018 100644 --- a/src/main/java/neqsim/thermo/characterization/PlusCharacterize.java +++ b/src/main/java/neqsim/thermo/characterization/PlusCharacterize.java @@ -14,478 +14,479 @@ * @version $Id: $Id */ public class PlusCharacterize implements java.io.Serializable, CharacteriseInterface { - private static final long serialVersionUID = 1000; - double TBPfractions[] = null; - boolean firsttime = true; - double MPlus = 300.0, zPlus = 0.3, densPlus = 0.98; - private double densLastTBP = 0.78; - int carbonNumberVector[] = null; - protected boolean pseudocomponents = true; - int firstPlusFractionNumber = 1; - int lastPlusFractionNumber = 80; - int numberOfPseudocomponents = 5;// (lastPlusFractionNumber-firstPlusFractionNumber)*50; - int length = 0; - double[] coefs = {4.4660105006, -1.1266303727, 0.80, 0.0408709562}; - double[] SRKcoefs = {4.4660105006, -1.1266303727, 8.1927423578, -3.4668277785}; - double[] PRcoefs = {4.4660105006, -1.1266303727, 8.1927423578, -3.4668277785}; - double[] plusCoefs = {0.0007774204804, -0.02390179}; - SystemInterface system = null; - static Logger logger = LogManager.getLogger(PlusCharacterize.class); - - public PlusCharacterize() {} - - /** - *

- * Constructor for PlusCharacterize. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public PlusCharacterize(SystemInterface system) { - this.system = system; - } - - /** {@inheritDoc} */ - @Override - public boolean hasPlusFraction() { - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - if (system.getPhase(0).getComponent(i).isIsPlusFraction()) { - return true; - } - } - return false; - } - - /** - *

- * setHeavyTBPtoPlus. - *

- */ - public void setHeavyTBPtoPlus() { - int plusCompNumber = 0, compNumber = 0; - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - try { - if (system.getPhase(0).getComponent(i).isIsTBPfraction()) { - Integer firstPlusNumber = Integer.valueOf(0); - if (system.getPhase(0).getComponent(i).getComponentName().substring(3, 4) - .equals("_")) { - firstPlusNumber = Integer.valueOf(system.getPhase(0).getComponent(i) - .getComponentName().substring(1, 3)); - } else { - firstPlusNumber = Integer.valueOf(system.getPhase(0).getComponent(i) - .getComponentName().substring(1, 2)); - } - if (plusCompNumber < firstPlusNumber.intValue()) { - plusCompNumber = firstPlusNumber.intValue(); - compNumber = i; - } - } - } catch (Exception e) { - e.toString(); - } - } - for (int i = 0; i < system.getNumberOfPhases(); i++) { - system.getPhase(i).getComponent(compNumber).setIsTBPfraction(false); - system.getPhase(i).getComponent(compNumber).setIsPlusFraction(true); - - MPlus = system.getPhase(i).getComponent(compNumber).getMolarMass(); - zPlus = system.getPhase(i).getComponent(compNumber).getz(); - densPlus = system.getPhase(i).getComponent(compNumber).getNormalLiquidDensity(); - } - coefs[2] = system.getPhase(0).getComponent(compNumber - 1).getNormalLiquidDensity() + 0.03; - densLastTBP = system.getPhase(0).getComponent(compNumber - 1).getNormalLiquidDensity(); - } - - /** {@inheritDoc} */ - @Override - public void solve() { - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - try { - if (system.getPhase(0).getComponent(i).isIsPlusFraction()) { - Integer firstPlusNumber = Integer.valueOf(0); - if (system.getPhase(0).getComponent(i).getComponentName().substring(3, 4) - .equals("_")) { - firstPlusNumber = Integer.valueOf(system.getPhase(0).getComponent(i) - .getComponentName().substring(1, 3)); - } else { - firstPlusNumber = Integer.valueOf(system.getPhase(0).getComponent(i) - .getComponentName().substring(1, 2)); - } - if (firstPlusFractionNumber < firstPlusNumber.intValue()) { - firstPlusFractionNumber = firstPlusNumber.intValue(); - } - } - } catch (Exception e) { - e.toString(); - } - } - logger.info("first plus fraction number " + firstPlusFractionNumber); - - // NewtonSolveABCDplus solver = new NewtonSolveABCDplus(system, this); - // NewtonSolveCDplus solver2 = new NewtonSolveCDplus(system, this); - // solver.solve(); - // solver2.solve(); - - // NewtonSolveABCD2 solver3 = new NewtonSolveABCD2(system, this); - // solver3.solve(); - } - - /** {@inheritDoc} */ - @Override - public double[] getCoefs() { - return this.coefs; - } - - /** {@inheritDoc} */ - @Override - public double getCoef(int i) { - return this.coefs[i]; - } - - /** {@inheritDoc} */ - @Override - public void setCoefs(double[] coefs) { - System.arraycopy(coefs, 0, this.coefs, 0, coefs.length); - - if (firsttime) { - if (coefs.length == 3) { - double Dtot = 0.0; - for (int i = getFirstPlusFractionNumber(); i < getLastPlusFractionNumber(); i++) { - Dtot += (getDensPlus() - this.getCoef(2)) / Math.log(i);// (this.getCoef(2)+this.getCoef(3)*Math.log(i)-this.getCoef(2))/Math.log(i); - } - double lengthPlus = - this.getLastPlusFractionNumber() - this.getFirstPlusFractionNumber(); - logger.info("length plus " + lengthPlus); - Dtot /= lengthPlus; - logger.info("D " + Dtot); - this.coefs[3] = Dtot; - } - firsttime = false; - } - - double mSum = 0.0, densSum = 0.0; - int iter = 0; - do { - iter++; - mSum = 0.0; - densSum = 0.0; - for (int i = this.getFirstPlusFractionNumber(); i < this - .getLastPlusFractionNumber(); i++) { - double ztemp = Math.exp(this.getCoef(0) + this.getCoef(1) * (i)); - double M = PVTsimMolarMass[i - 6] / 1000.0; - double dens = this.getCoef(2) + this.getCoef(3) * Math.log(i); - mSum += ztemp * M; - densSum += (ztemp * M / dens); - } - densSum = mSum / densSum; - - this.coefs[3] += 1.0 * (densPlus - densSum) / densSum * this.coefs[3]; - // System.out.println("coef " + this.coefs[3]); - } while (Math.abs(densPlus - densSum) > 1e-6 && iter < 1000); - } - - /** {@inheritDoc} */ - @Override - public void setCoefs(double coef, int i) { - this.coefs[i] = coef; - } - - /** - * Getter for property length. - * - * @return Value of property length. - */ - public int getLength() { - return length; - } - - /** {@inheritDoc} */ - @Override - public void generatePlusFractions(int start, int end, double zplus, double Mplus) {} - - /** {@inheritDoc} */ - @Override - public void addHeavyEnd() {} - - /** {@inheritDoc} */ - @Override - public void generateTBPFractions() {} - - /** {@inheritDoc} */ - @Override - public void addCharacterizedPlusFraction() { - if (!pseudocomponents) { - numberOfPseudocomponents = - getLastPlusFractionNumber() - getFirstPlusFractionNumber() + 1; - } - - double[] zPlus = new double[numberOfPseudocomponents]; - double[] MPlus = new double[numberOfPseudocomponents]; - - double weightFrac = 0.0; - double weightTot = 0.0; - - for (int i = getFirstPlusFractionNumber(); i < getLastPlusFractionNumber(); i++) { - weightTot += Math.exp(getCoef(0) + getCoef(1) * i) * PVTsimMolarMass[i - 6] / 1000.0; - } - - double meanWeightFrac = weightTot / (numberOfPseudocomponents + 0.000001); - zPlus = new double[numberOfPseudocomponents]; - MPlus = new double[numberOfPseudocomponents]; - int k = 0; - int firstPS = firstPlusFractionNumber; - double Maverage = 0.0, denstemp1 = 0.0, denstemp2 = 0.0; - - double totalNumberOfMoles = system.getNumberOfMoles(); - - for (int i = getFirstPlusFractionNumber(); i < getLastPlusFractionNumber(); i++) { - zPlus[k] += Math.exp(getCoef(0) + getCoef(1) * i); - MPlus[k] += PVTsimMolarMass[i - 6] / 1000.0; - denstemp1 += Math.exp(getCoef(0) + getCoef(1) * i) * PVTsimMolarMass[i - 6] / 1000.0; - denstemp2 += Math.exp(getCoef(0) + getCoef(1) * i) * PVTsimMolarMass[i - 6] / 1000.0 - / (getCoef(2) + getCoef(3) * Math.log(i)); - // System.out.println("dens " + denstemp1/denstemp2); - Maverage += Math.exp(getCoef(0) + getCoef(1) * i) * PVTsimMolarMass[i - 6] / 1000.0; - weightFrac += Math.exp(getCoef(0) + getCoef(1) * i) * PVTsimMolarMass[i - 6] / 1000.0; - // System.out.println("weigth " + weightFrac + " i" + i); - if (weightFrac >= meanWeightFrac || !pseudocomponents - || i == getLastPlusFractionNumber() - 1) { - String name = (i == firstPS) ? "PC" + Integer.toString(firstPS) - : "PC" + Integer.toString(firstPS) + "-" + Integer.toString(i); - system.addTBPfraction(name, totalNumberOfMoles * zPlus[k], Maverage / zPlus[k], - denstemp1 / denstemp2); - denstemp1 = 0.0; - denstemp2 = 0.0; - weightFrac = 0.0; - Maverage = 0.0; - k++; - firstPS = i + 1; - } - } - - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - if (system.getPhase(0).getComponent(i).isIsPlusFraction()) { - system.removeComponent(system.getPhase(0).getComponent(i).getName()); - break; - } - } - } - - /** - *

- * addPseudoTBPfraction. - *

- * - * @param start a int - * @param end a int - */ - public void addPseudoTBPfraction(int start, int end) {} - - /** - * Getter for property carbonNumberVector. - * - * @return Value of property carbonNumberVector. - */ - public int[] getCarbonNumberVector() { - return this.carbonNumberVector; - } - - /** - * Setter for property carbonNumberVector. - * - * @param carbonNumberVector New value of property carbonNumberVector. - */ - public void setCarbonNumberVector(int[] carbonNumberVector) { - this.carbonNumberVector = carbonNumberVector; - } - - /** {@inheritDoc} */ - @Override - public int getFirstPlusFractionNumber() { - return firstPlusFractionNumber; - } - - /** {@inheritDoc} */ - @Override - public int getLastPlusFractionNumber() { - return lastPlusFractionNumber; - } - - /** - * Setter for property firstPlusFractionNumber. - * - * @param firstPlusFractionNumber New value of property firstPlusFractionNumber. - */ - public void setFirstPlusFractionNumber(int firstPlusFractionNumber) { - this.firstPlusFractionNumber = firstPlusFractionNumber; - } - - /** - * Getter for property startPlus. - * - * @return Value of property startPlus. - */ - public int getStartPlus() { - return firstPlusFractionNumber; - } - - /** - * Setter for property firstPlusFractionNumber. - * - * @param startPlus New value of property firstPlusFractionNumber. - * @deprecated use {@link #setFirstPlusFractionNumber(int firstPlusFractionNumber)} instead. - * - */ - @Deprecated - public void setStartPlus(int startPlus) { - setFirstPlusFractionNumber(startPlus); - } - - /** {@inheritDoc} */ - @Override - public double getMPlus() { - return MPlus; - } - - /** {@inheritDoc} */ - @Override - public void setMPlus(double MPlus) { - this.MPlus = MPlus; - } - - /** {@inheritDoc} */ - @Override - public double getZPlus() { - return zPlus; - } - - /** {@inheritDoc} */ - @Override - public void setZPlus(double zPlus) { - this.zPlus = zPlus; - } - - /** {@inheritDoc} */ - @Override - public double[] getPlusCoefs() { - return this.plusCoefs; - } - - /** {@inheritDoc} */ - @Override - public double getPlusCoefs(int i) { - return this.plusCoefs[i]; - } - - /** {@inheritDoc} */ - @Override - public void setPlusCoefs(double[] plusCoefs) { - this.plusCoefs = plusCoefs; - } - - /** {@inheritDoc} */ - @Override - public double getDensPlus() { - return densPlus; - } - - /** - * Setter for property densPlus. - * - * @param densPlus New value of property densPlus. - */ - public void setDensPlus(double densPlus) { - this.densPlus = densPlus; - } - - /** {@inheritDoc} */ - @Override - public boolean groupTBPfractions() { + private static final long serialVersionUID = 1000; + double[] TBPfractions = null; + boolean firsttime = true; + double MPlus = 300.0; + double zPlus = 0.3; + double densPlus = 0.98; + private double densLastTBP = 0.78; + int[] carbonNumberVector = null; + protected boolean pseudocomponents = true; + int firstPlusFractionNumber = 1; + int lastPlusFractionNumber = 80; + int numberOfPseudocomponents = 5; // (lastPlusFractionNumber-firstPlusFractionNumber)*50; + int length = 0; + double[] coefs = {4.4660105006, -1.1266303727, 0.80, 0.0408709562}; + double[] SRKcoefs = {4.4660105006, -1.1266303727, 8.1927423578, -3.4668277785}; + double[] PRcoefs = {4.4660105006, -1.1266303727, 8.1927423578, -3.4668277785}; + double[] plusCoefs = {0.0007774204804, -0.02390179}; + SystemInterface system = null; + static Logger logger = LogManager.getLogger(PlusCharacterize.class); + + public PlusCharacterize() {} + + /** + *

+ * Constructor for PlusCharacterize. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public PlusCharacterize(SystemInterface system) { + this.system = system; + } + + /** {@inheritDoc} */ + @Override + public boolean hasPlusFraction() { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (system.getPhase(0).getComponent(i).isIsPlusFraction()) { return true; - } - - /** - * Getter for property numberOfPseudocomponents. - * - * @return Value of property numberOfPseudocomponents. - */ - public int getNumberOfPseudocomponents() { - return numberOfPseudocomponents; - } - - /** {@inheritDoc} */ - @Override - public void setNumberOfPseudocomponents(int numberOfPseudocomponents) { - this.numberOfPseudocomponents = numberOfPseudocomponents; - } - - /** {@inheritDoc} */ - @Override - public boolean isPseudocomponents() { - return pseudocomponents; - } - - /** {@inheritDoc} */ - @Override - public void setPseudocomponents(boolean pseudocomponents) { - this.pseudocomponents = pseudocomponents; - } - - /** {@inheritDoc} */ - @Override - public void removeTBPfraction() { - ArrayList list = new ArrayList(); - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - double boilpoint = system.getPhase(0).getComponent(i).getNormalBoilingPoint(); - if (boilpoint >= 69.0) { - list.add(system.getPhase(0).getComponent(i).getName()); - } + } + } + return false; + } + + /** + *

+ * setHeavyTBPtoPlus. + *

+ */ + public void setHeavyTBPtoPlus() { + int plusCompNumber = 0; + int compNumber = 0; + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + try { + if (system.getPhase(0).getComponent(i).isIsTBPfraction()) { + Integer firstPlusNumber = Integer.valueOf(0); + if (system.getPhase(0).getComponent(i).getComponentName().substring(3, 4).equals("_")) { + firstPlusNumber = Integer + .valueOf(system.getPhase(0).getComponent(i).getComponentName().substring(1, 3)); + } else { + firstPlusNumber = Integer + .valueOf(system.getPhase(0).getComponent(i).getComponentName().substring(1, 2)); + } + if (plusCompNumber < firstPlusNumber.intValue()) { + plusCompNumber = firstPlusNumber.intValue(); + compNumber = i; + } } - - for (int i = 0; i < list.size(); i++) { - try { - system.removeComponent(list.get(i)); - logger.info("removing " + list.get(i)); - } catch (Exception e) { - logger.error("not able to remove " + list.get(i)); - // return; - } + } catch (Exception e) { + e.toString(); + } + } + for (int i = 0; i < system.getNumberOfPhases(); i++) { + system.getPhase(i).getComponent(compNumber).setIsTBPfraction(false); + system.getPhase(i).getComponent(compNumber).setIsPlusFraction(true); + + MPlus = system.getPhase(i).getComponent(compNumber).getMolarMass(); + zPlus = system.getPhase(i).getComponent(compNumber).getz(); + densPlus = system.getPhase(i).getComponent(compNumber).getNormalLiquidDensity(); + } + coefs[2] = system.getPhase(0).getComponent(compNumber - 1).getNormalLiquidDensity() + 0.03; + densLastTBP = system.getPhase(0).getComponent(compNumber - 1).getNormalLiquidDensity(); + } + + /** {@inheritDoc} */ + @Override + public void solve() { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + try { + if (system.getPhase(0).getComponent(i).isIsPlusFraction()) { + Integer firstPlusNumber = Integer.valueOf(0); + if (system.getPhase(0).getComponent(i).getComponentName().substring(3, 4).equals("_")) { + firstPlusNumber = Integer + .valueOf(system.getPhase(0).getComponent(i).getComponentName().substring(1, 3)); + } else { + firstPlusNumber = Integer + .valueOf(system.getPhase(0).getComponent(i).getComponentName().substring(1, 2)); + } + if (firstPlusFractionNumber < firstPlusNumber.intValue()) { + firstPlusFractionNumber = firstPlusNumber.intValue(); + } } - } - - /** {@inheritDoc} */ - @Override - public void addTBPFractions() {} - - /** {@inheritDoc} */ - @Override - public double getDensLastTBP() { - return densLastTBP; - } - - /** {@inheritDoc} */ - @Override - public void setDensLastTBP(double densLastTBP) { - this.densLastTBP = densLastTBP; - } - - /** - *

- * characterizePlusFraction. - *

- */ - public void characterizePlusFraction() { - system.init(0); - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - if (system.getPhase(0).getComponent(i).isIsPlusFraction()) { - MPlus = system.getPhase(0).getComponent(i).getMolarMass(); - zPlus = system.getPhase(0).getComponent(i).getz(); - densPlus = system.getPhase(0).getComponent(i).getNormalLiquidDensity(); - } + } catch (Exception e) { + e.toString(); + } + } + logger.info("first plus fraction number " + firstPlusFractionNumber); + + // NewtonSolveABCDplus solver = new NewtonSolveABCDplus(system, this); + // NewtonSolveCDplus solver2 = new NewtonSolveCDplus(system, this); + // solver.solve(); + // solver2.solve(); + + // NewtonSolveABCD2 solver3 = new NewtonSolveABCD2(system, this); + // solver3.solve(); + } + + /** {@inheritDoc} */ + @Override + public double[] getCoefs() { + return this.coefs; + } + + /** {@inheritDoc} */ + @Override + public double getCoef(int i) { + return this.coefs[i]; + } + + /** {@inheritDoc} */ + @Override + public void setCoefs(double[] coefs) { + System.arraycopy(coefs, 0, this.coefs, 0, coefs.length); + + if (firsttime) { + if (coefs.length == 3) { + double Dtot = 0.0; + for (int i = getFirstPlusFractionNumber(); i < getLastPlusFractionNumber(); i++) { + Dtot += (getDensPlus() - this.getCoef(2)) / Math.log(i); // (this.getCoef(2)+this.getCoef(3)*Math.log(i)-this.getCoef(2))/Math.log(i); } - - coefs[0] = 0.1; - coefs[1] = Math.log(zPlus) / getFirstPlusFractionNumber(); - solve(); - } + double lengthPlus = this.getLastPlusFractionNumber() - this.getFirstPlusFractionNumber(); + logger.info("length plus " + lengthPlus); + Dtot /= lengthPlus; + logger.info("D " + Dtot); + this.coefs[3] = Dtot; + } + firsttime = false; + } + + double mSum = 0.0; + double densSum = 0.0; + int iter = 0; + do { + iter++; + mSum = 0.0; + densSum = 0.0; + for (int i = this.getFirstPlusFractionNumber(); i < this.getLastPlusFractionNumber(); i++) { + double ztemp = Math.exp(this.getCoef(0) + this.getCoef(1) * (i)); + double M = PVTsimMolarMass[i - 6] / 1000.0; + double dens = this.getCoef(2) + this.getCoef(3) * Math.log(i); + mSum += ztemp * M; + densSum += (ztemp * M / dens); + } + densSum = mSum / densSum; + + this.coefs[3] += 1.0 * (densPlus - densSum) / densSum * this.coefs[3]; + // System.out.println("coef " + this.coefs[3]); + } while (Math.abs(densPlus - densSum) > 1e-6 && iter < 1000); + } + + /** {@inheritDoc} */ + @Override + public void setCoefs(double coef, int i) { + this.coefs[i] = coef; + } + + /** + * Getter for property length. + * + * @return Value of property length. + */ + public int getLength() { + return length; + } + + /** {@inheritDoc} */ + @Override + public void generatePlusFractions(int start, int end, double zplus, double Mplus) {} + + /** {@inheritDoc} */ + @Override + public void addHeavyEnd() {} + + /** {@inheritDoc} */ + @Override + public void generateTBPFractions() {} + + /** {@inheritDoc} */ + @Override + public void addCharacterizedPlusFraction() { + if (!pseudocomponents) { + numberOfPseudocomponents = getLastPlusFractionNumber() - getFirstPlusFractionNumber() + 1; + } + + double[] zPlus = new double[numberOfPseudocomponents]; + double[] MPlus = new double[numberOfPseudocomponents]; + + double weightFrac = 0.0; + double weightTot = 0.0; + + for (int i = getFirstPlusFractionNumber(); i < getLastPlusFractionNumber(); i++) { + weightTot += Math.exp(getCoef(0) + getCoef(1) * i) * PVTsimMolarMass[i - 6] / 1000.0; + } + + double meanWeightFrac = weightTot / (numberOfPseudocomponents + 0.000001); + zPlus = new double[numberOfPseudocomponents]; + MPlus = new double[numberOfPseudocomponents]; + int k = 0; + int firstPS = firstPlusFractionNumber; + double Maverage = 0.0; + + double denstemp1 = 0.0; + double denstemp2 = 0.0; + double totalNumberOfMoles = system.getNumberOfMoles(); + + for (int i = getFirstPlusFractionNumber(); i < getLastPlusFractionNumber(); i++) { + zPlus[k] += Math.exp(getCoef(0) + getCoef(1) * i); + MPlus[k] += PVTsimMolarMass[i - 6] / 1000.0; + denstemp1 += Math.exp(getCoef(0) + getCoef(1) * i) * PVTsimMolarMass[i - 6] / 1000.0; + denstemp2 += Math.exp(getCoef(0) + getCoef(1) * i) * PVTsimMolarMass[i - 6] / 1000.0 + / (getCoef(2) + getCoef(3) * Math.log(i)); + // System.out.println("dens " + denstemp1/denstemp2); + Maverage += Math.exp(getCoef(0) + getCoef(1) * i) * PVTsimMolarMass[i - 6] / 1000.0; + weightFrac += Math.exp(getCoef(0) + getCoef(1) * i) * PVTsimMolarMass[i - 6] / 1000.0; + // System.out.println("weigth " + weightFrac + " i" + i); + if (weightFrac >= meanWeightFrac || !pseudocomponents + || i == getLastPlusFractionNumber() - 1) { + String name = (i == firstPS) ? "PC" + Integer.toString(firstPS) + : "PC" + Integer.toString(firstPS) + "-" + Integer.toString(i); + system.addTBPfraction(name, totalNumberOfMoles * zPlus[k], Maverage / zPlus[k], + denstemp1 / denstemp2); + denstemp1 = 0.0; + denstemp2 = 0.0; + weightFrac = 0.0; + Maverage = 0.0; + k++; + firstPS = i + 1; + } + } + + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (system.getPhase(0).getComponent(i).isIsPlusFraction()) { + system.removeComponent(system.getPhase(0).getComponent(i).getName()); + break; + } + } + } + + /** + *

+ * addPseudoTBPfraction. + *

+ * + * @param start a int + * @param end a int + */ + public void addPseudoTBPfraction(int start, int end) {} + + /** + * Getter for property carbonNumberVector. + * + * @return Value of property carbonNumberVector. + */ + public int[] getCarbonNumberVector() { + return this.carbonNumberVector; + } + + /** + * Setter for property carbonNumberVector. + * + * @param carbonNumberVector New value of property carbonNumberVector. + */ + public void setCarbonNumberVector(int[] carbonNumberVector) { + this.carbonNumberVector = carbonNumberVector; + } + + /** {@inheritDoc} */ + @Override + public int getFirstPlusFractionNumber() { + return firstPlusFractionNumber; + } + + /** {@inheritDoc} */ + @Override + public int getLastPlusFractionNumber() { + return lastPlusFractionNumber; + } + + /** + * Setter for property firstPlusFractionNumber. + * + * @param firstPlusFractionNumber New value of property firstPlusFractionNumber. + */ + public void setFirstPlusFractionNumber(int firstPlusFractionNumber) { + this.firstPlusFractionNumber = firstPlusFractionNumber; + } + + /** + * Getter for property startPlus. + * + * @return Value of property startPlus. + */ + public int getStartPlus() { + return firstPlusFractionNumber; + } + + /** + * Setter for property firstPlusFractionNumber. + * + * @param startPlus New value of property firstPlusFractionNumber. + * @deprecated use {@link #setFirstPlusFractionNumber(int firstPlusFractionNumber)} instead. + * + */ + @Deprecated + public void setStartPlus(int startPlus) { + setFirstPlusFractionNumber(startPlus); + } + + /** {@inheritDoc} */ + @Override + public double getMPlus() { + return MPlus; + } + + /** {@inheritDoc} */ + @Override + public void setMPlus(double MPlus) { + this.MPlus = MPlus; + } + + /** {@inheritDoc} */ + @Override + public double getZPlus() { + return zPlus; + } + + /** {@inheritDoc} */ + @Override + public void setZPlus(double zPlus) { + this.zPlus = zPlus; + } + + /** {@inheritDoc} */ + @Override + public double[] getPlusCoefs() { + return this.plusCoefs; + } + + /** {@inheritDoc} */ + @Override + public double getPlusCoefs(int i) { + return this.plusCoefs[i]; + } + + /** {@inheritDoc} */ + @Override + public void setPlusCoefs(double[] plusCoefs) { + this.plusCoefs = plusCoefs; + } + + /** {@inheritDoc} */ + @Override + public double getDensPlus() { + return densPlus; + } + + /** + * Setter for property densPlus. + * + * @param densPlus New value of property densPlus. + */ + public void setDensPlus(double densPlus) { + this.densPlus = densPlus; + } + + /** {@inheritDoc} */ + @Override + public boolean groupTBPfractions() { + return true; + } + + /** + * Getter for property numberOfPseudocomponents. + * + * @return Value of property numberOfPseudocomponents. + */ + public int getNumberOfPseudocomponents() { + return numberOfPseudocomponents; + } + + /** {@inheritDoc} */ + @Override + public void setNumberOfPseudocomponents(int numberOfPseudocomponents) { + this.numberOfPseudocomponents = numberOfPseudocomponents; + } + + /** {@inheritDoc} */ + @Override + public boolean isPseudocomponents() { + return pseudocomponents; + } + + /** {@inheritDoc} */ + @Override + public void setPseudocomponents(boolean pseudocomponents) { + this.pseudocomponents = pseudocomponents; + } + + /** {@inheritDoc} */ + @Override + public void removeTBPfraction() { + ArrayList list = new ArrayList(); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + double boilpoint = system.getPhase(0).getComponent(i).getNormalBoilingPoint(); + if (boilpoint >= 69.0) { + list.add(system.getPhase(0).getComponent(i).getName()); + } + } + + for (int i = 0; i < list.size(); i++) { + try { + system.removeComponent(list.get(i)); + logger.info("removing " + list.get(i)); + } catch (Exception e) { + logger.error("not able to remove " + list.get(i)); + // return; + } + } + } + + /** {@inheritDoc} */ + @Override + public void addTBPFractions() {} + + /** {@inheritDoc} */ + @Override + public double getDensLastTBP() { + return densLastTBP; + } + + /** {@inheritDoc} */ + @Override + public void setDensLastTBP(double densLastTBP) { + this.densLastTBP = densLastTBP; + } + + /** + *

+ * characterizePlusFraction. + *

+ */ + public void characterizePlusFraction() { + system.init(0); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (system.getPhase(0).getComponent(i).isIsPlusFraction()) { + MPlus = system.getPhase(0).getComponent(i).getMolarMass(); + zPlus = system.getPhase(0).getComponent(i).getz(); + densPlus = system.getPhase(0).getComponent(i).getNormalLiquidDensity(); + } + } + + coefs[0] = 0.1; + coefs[1] = Math.log(zPlus) / getFirstPlusFractionNumber(); + solve(); + } } diff --git a/src/main/java/neqsim/thermo/characterization/PlusFractionModel.java b/src/main/java/neqsim/thermo/characterization/PlusFractionModel.java index 786ff8492d..ee80b8d32d 100644 --- a/src/main/java/neqsim/thermo/characterization/PlusFractionModel.java +++ b/src/main/java/neqsim/thermo/characterization/PlusFractionModel.java @@ -14,12 +14,19 @@ public class PlusFractionModel implements java.io.Serializable { private static final long serialVersionUID = 1000; private String name = ""; private SystemInterface system = null; - double MPlus = 0.0, zPlus = 0.0, densPlus = 0.0; + double MPlus = 0.0; + double zPlus = 0.0; + double densPlus = 0.0; int firstPlusFractionNumber = 1; int lastPlusFractionNumber = 80; int plusComponentNumber = 0; private double maxPlusMolarMass = 1000.0; - double[] z, M, dens, TC, PC, acs; + double[] z; + double[] M; + double[] dens; + double[] TC; + double[] PC; + double[] acs; /** *

@@ -139,7 +146,8 @@ public int getFirstPlusFractionNumber() { @Override public int getFirstTBPFractionNumber() { int firstTBPNumber = 0; - double M = 1e10, Mmin = 1e10; + double M = 1e10; + double Mmin = 1e10; for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { if (system.getPhase(0).getComponent(i).isIsTBPfraction()) { M = system.getPhase(0).getComponent(i).getMolarMass(); @@ -241,7 +249,7 @@ public void setCoefs(double[] coefs) { if (coefs.length == 3) { double Dtot = 0.0; for (int i = firstPlusFractionNumber; i < lastPlusFractionNumber; i++) { - Dtot += (densPlus - this.getCoef(2)) / Math.log(i);// (this.getCoef(2)+this.getCoef(3)*Math.log(i)-this.getCoef(2))/Math.log(i); + Dtot += (densPlus - this.getCoef(2)) / Math.log(i); // (this.getCoef(2)+this.getCoef(3)*Math.log(i)-this.getCoef(2))/Math.log(i); } double lengthPlus = lastPlusFractionNumber - firstPlusFractionNumber; // System.out.println("length plus " + lengthPlus); @@ -253,7 +261,8 @@ public void setCoefs(double[] coefs) { } // double zSum = 0.0; - double mSum = 0.0, densSum = 0.0; + double mSum = 0.0; + double densSum = 0.0; int iter = 0; do { iter++; diff --git a/src/main/java/neqsim/thermo/characterization/TBPfractionModel.java b/src/main/java/neqsim/thermo/characterization/TBPfractionModel.java index dcc6b906ae..98ac3bbe3e 100644 --- a/src/main/java/neqsim/thermo/characterization/TBPfractionModel.java +++ b/src/main/java/neqsim/thermo/characterization/TBPfractionModel.java @@ -77,7 +77,7 @@ public double calcAcentricFactor(double molarMass, double density) { public double calcCriticalVolume(double molarMass, double density) { double TC = calcTC(molarMass, density); double PC = calcPC(molarMass, density); - double acs = calcAcentricFactor(molarMass, density);// thermoSystem.getPhase(thermoSystem.getPhaseIndex(0)).getComponent(0).getAcentricFactor(); + double acs = calcAcentricFactor(molarMass, density); // thermoSystem.getPhase(thermoSystem.getPhaseIndex(0)).getComponent(0).getAcentricFactor(); double criticaVol = (0.2918 - 0.0928 * acs) * 8.314 * TC / PC * 10.0; if (criticaVol < 0) { // logger.info("acentric factor in calc critVol " + acs); @@ -262,7 +262,7 @@ public double calcTC(double molarMass, double density) { return 5.0 / 9.0 * 554.4 * Math.exp( -1.3478e-4 * molarMass - 0.61641 * density + 0.0 * molarMass * density) - * Math.pow(molarMass, 0.2998) * Math.pow(density, 1.0555);// Math.pow(sig1, b) * + * Math.pow(molarMass, 0.2998) * Math.pow(density, 1.0555); // Math.pow(sig1, b) * // Math.pow(sig2, c); } @@ -274,7 +274,7 @@ public double calcPC(double molarMass, double density) { return 0.068947 * 4.5203e4 * Math.exp( -1.8078e-3 * molarMass + -0.3084 * density + 0.0 * molarMass * density) - * Math.pow(molarMass, -0.8063) * Math.pow(density, 1.6015);// Math.pow(sig1, b) + * Math.pow(molarMass, -0.8063) * Math.pow(density, 1.6015); // Math.pow(sig1, b) // * Math.pow(sig2, // c); } @@ -292,7 +292,7 @@ public double calcTB(double molarMass, double density) { return 5.0 / 9.0 * (1928.3 - 1.695e5 * Math.pow(molarMass, -0.03522) * Math.pow(density, 3.266) * Math.exp(-4.922e-3 * molarMass - 4.7685 * density - + 3.462e-3 * molarMass * density));// 97.58*Math.pow(molarMass,0.3323)*Math.pow(density,0.04609); + + 3.462e-3 * molarMass * density)); // 97.58*Math.pow(molarMass,0.3323)*Math.pow(density,0.04609); } @Override diff --git a/src/main/java/neqsim/thermo/component/Component.java b/src/main/java/neqsim/thermo/component/Component.java index a4a3738f4a..eba9051138 100644 --- a/src/main/java/neqsim/thermo/component/Component.java +++ b/src/main/java/neqsim/thermo/component/Component.java @@ -17,53 +17,99 @@ abstract class Component implements ComponentInterface { private static final long serialVersionUID = 1000; - double[] surfTensInfluenceParam = { 0.28367, -0.05164, -0.81594, 1.06810, -1.1147 }; - protected int index, componentNumber, attractiveTermNumber = 0, numberOfAssociationSites = 0; - protected double logFugacityCoefficient = 0.0, associationVolume = 0.0, associationEnergy = 0.0, - aCPA = 0.0, bCPA = 0.0, mCPA = 0.0, srkacentricFactor = 0.0; - protected String componentName = "default", referenceStateType = "solvent", - associationScheme = "0", antoineLiqVapPresType = null; - private String formulae = "", CASnumber = ""; + double[] surfTensInfluenceParam = {0.28367, -0.05164, -0.81594, 1.06810, -1.1147}; + protected int index; + protected int componentNumber; + protected int attractiveTermNumber = 0; + protected int numberOfAssociationSites = 0; + protected double logFugacityCoefficient = 0.0; + protected double associationVolume = 0.0; + protected double associationEnergy = 0.0; + protected double aCPA = 0.0; + protected double bCPA = 0.0; + protected double mCPA = 0.0; + protected double srkacentricFactor = 0.0; + protected String componentName = "default"; + protected String referenceStateType = "solvent"; + protected String associationScheme = "0"; + protected String antoineLiqVapPresType = null; + private String formulae = ""; + private String CASnumber = ""; protected Element elements = null; - protected boolean isTBPfraction = false, isPlusFraction = false, isNormalComponent = true, - isIon = false; + protected boolean isTBPfraction = false; + protected boolean isPlusFraction = false; + protected boolean isNormalComponent = true; + protected boolean isIon = false; private boolean isHydrateFormer = false; private boolean waxFormer = false; private String componentType = "Component"; - protected double qPure = 0, voli = 1.0; + protected double qPure = 0; + protected double voli = 1.0; protected int calcActivity = 1; protected boolean solidCheck = false; - protected double dqPuredT = 0, dqPuredTdT = 0; + protected double dqPuredT = 0; + protected double dqPuredTdT = 0; private double racketZCPA = 0; private double criticalCompressibilityFactor = 0.0; - private double volumeCorrectionConst = 0.0, volumeCorrectionT = 0.0, volumeCorrectionT_CPA = 0.0; - protected double criticalPressure, criticalTemperature, molarMass, acentricFactor, - numberOfMoles = 0.0, numberOfMolesInPhase = 0.0, normalLiquidDensity = 0; - protected double reducedPressure, reducedTemperature, fugacityCoefficient, debyeDipoleMoment = 0, - viscosityCorrectionFactor = 0, criticalVolume = 0, racketZ = 0; - protected double gibbsEnergyOfFormation = 0, criticalViscosity = 0.0; - protected double referencePotential = 0, viscosityFrictionK = 1.0; + private double volumeCorrectionConst = 0.0; + private double volumeCorrectionT = 0.0; + private double volumeCorrectionT_CPA = 0.0; + protected double criticalPressure; + protected double criticalTemperature; + protected double molarMass; + protected double acentricFactor; + protected double numberOfMoles = 0.0; + protected double numberOfMolesInPhase = 0.0; + protected double normalLiquidDensity = 0; + protected double reducedPressure; + protected double reducedTemperature; + protected double fugacityCoefficient; + protected double debyeDipoleMoment = 0; + protected double viscosityCorrectionFactor = 0; + protected double criticalVolume = 0; + protected double racketZ = 0; + protected double gibbsEnergyOfFormation = 0; + protected double criticalViscosity = 0.0; + protected double referencePotential = 0; + protected double viscosityFrictionK = 1.0; protected int liquidViscosityModel = 0; protected int ionicCharge = 0; private double referenceEnthalpy = 0.0; - protected double parachorParameter = 0.0, normalBoilingPoint = 0, sphericalCoreRadius = 0.384, - standardDensity = 0, AntoineASolid = 0.0, AntoineBSolid = 0.0, AntoineCSolid = 0.0; + protected double parachorParameter = 0.0; + protected double normalBoilingPoint = 0; + protected double sphericalCoreRadius = 0.384; + protected double standardDensity = 0; + protected double AntoineASolid = 0.0; + protected double AntoineBSolid = 0.0; + protected double AntoineCSolid = 0.0; protected double[] liquidViscosityParameter = new double[4]; protected double[] liquidConductivityParameter = new double[3]; protected double[] henryCoefParameter = new double[4]; protected double[] dielectricParameter = new double[5]; - protected double[] schwartzentruberParams = new double[3], matiascopemanParams = new double[3], - matiascopemanParamsPR = new double[3], TwuCoonParams = new double[3], - matiascopemanSolidParams = new double[3], matiascopemanParamsUMRPRU = new double[5]; - protected double lennardJonesMolecularDiameter = 0, lennardJonesEnergyParameter = 0, - stokesCationicDiameter = 0, paulingAnionicDiameter = 0; - protected double K, z; + protected double[] schwartzentruberParams = new double[3]; + protected double[] matiascopemanParams = new double[3]; + protected double[] matiascopemanParamsPR = new double[3]; + protected double[] TwuCoonParams = new double[3]; + protected double[] matiascopemanSolidParams = new double[3]; + protected double[] matiascopemanParamsUMRPRU = new double[5]; + protected double lennardJonesMolecularDiameter = 0; + protected double lennardJonesEnergyParameter = 0; + protected double stokesCationicDiameter = 0; + protected double paulingAnionicDiameter = 0; + protected double K; + protected double z; protected double x = 0; private int orginalNumberOfAssociationSites = 0; - protected double dfugdt = 0.1, dfugdp = 0.1; + protected double dfugdt = 0.1; + protected double dfugdp = 0.1; protected double[] dfugdn = new double[MAX_NUMBER_OF_COMPONENTS]; public double[] dfugdx = new double[MAX_NUMBER_OF_COMPONENTS]; - double AntoineA = 0, AntoineB = 0, AntoineC = 0, AntoineD = 0, AntoineE = 0; + double AntoineA = 0; + double AntoineB = 0; + double AntoineC = 0; + double AntoineD = 0; + double AntoineE = 0; + private double CpA = 100.0; private double CpB = 0; private double CpC = 0; @@ -72,11 +118,16 @@ abstract class Component implements ComponentInterface { private double[] CpSolid = new double[5]; private double[] CpLiquid = new double[5]; private double heatOfFusion = 0.0; - double triplePointDensity = 10.0, triplePointPressure = 0.0; + double triplePointDensity = 10.0; + double triplePointPressure = 0.0; + private double triplePointTemperature = 1000.0; double meltingPointTemperature = 110.0; private double idealGasEnthalpyOfFormation = 0.0; - double idealGasGibsEnergyOfFormation = 0.0, idealGasAbsoluteEntropy = 0.0; + double idealGasGibsEnergyOfFormation = 0.0; + + double idealGasAbsoluteEntropy = 0.0; + double Hsub = 0.0; double[] solidDensityCoefs = new double[5]; double[] liquidDensityCoefs = new double[5]; @@ -94,11 +145,11 @@ abstract class Component implements ComponentInterface { *

* * @param number a int - * @param TC a double - * @param PC a double - * @param M a double - * @param a a double - * @param moles a double + * @param TC a double + * @param PC a double + * @param M a double + * @param a a double + * @param moles a double */ public Component(int number, double TC, double PC, double M, double a, double moles) { criticalPressure = PC; @@ -114,9 +165,9 @@ public Component(int number, double TC, double PC, double M, double a, double mo *

* * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param moles a double + * @param molesInPhase a double + * @param compnumber a int */ public Component(String component_name, double moles, double molesInPhase, int compnumber) { createComponent(component_name, moles, molesInPhase, compnumber); @@ -182,7 +233,8 @@ public void createComponent(String component_name, double moles, double molesInP dataSet = database .getResultSet(("SELECT * FROM comptemp WHERE name='" + component_name + "'")); } else { - dataSet = database.getResultSet(("SELECT * FROM comp WHERE name='" + component_name + "'")); + dataSet = + database.getResultSet(("SELECT * FROM comp WHERE name='" + component_name + "'")); } dataSet.next(); dataSet.getString("ID"); @@ -192,7 +244,8 @@ public void createComponent(String component_name, double moles, double molesInP dataSet.close(); // logger.info("no parameters in tempcomp -- trying comp.. " + // component_name); - dataSet = database.getResultSet(("SELECT * FROM comp WHERE name='" + component_name + "'")); + dataSet = + database.getResultSet(("SELECT * FROM comp WHERE name='" + component_name + "'")); dataSet.next(); } catch (Exception e2) { throw new RuntimeException(e2); @@ -301,9 +354,12 @@ public void createComponent(String component_name, double moles, double molesInP TwuCoonParams[1] = Double.parseDouble(dataSet.getString("TwuCoon2")); TwuCoonParams[2] = Double.parseDouble(dataSet.getString("TwuCoon3")); - liquidConductivityParameter[0] = Double.parseDouble(dataSet.getString("liquidConductivity1")); - liquidConductivityParameter[1] = Double.parseDouble(dataSet.getString("liquidConductivity2")); - liquidConductivityParameter[2] = Double.parseDouble(dataSet.getString("liquidConductivity3")); + liquidConductivityParameter[0] = + Double.parseDouble(dataSet.getString("liquidConductivity1")); + liquidConductivityParameter[1] = + Double.parseDouble(dataSet.getString("liquidConductivity2")); + liquidConductivityParameter[2] = + Double.parseDouble(dataSet.getString("liquidConductivity3")); if (this.getClass().getName().equals("neqsim.thermo.component.ComponentSrkCPA") || this.getClass().getName().equals("neqsim.thermo.component.ComponentSrkCPAs")) { @@ -327,13 +383,16 @@ public void createComponent(String component_name, double moles, double molesInP idealGasAbsoluteEntropy = Double.parseDouble(dataSet.getString("AbsoluteEntropy")); for (int i = 0; i < 5; i++) { - solidDensityCoefs[i] = Double.parseDouble((dataSet.getString("solidDensityCoefs" + (i + 1)))); + solidDensityCoefs[i] = + Double.parseDouble((dataSet.getString("solidDensityCoefs" + (i + 1)))); } for (int i = 0; i < 5; i++) { - liquidDensityCoefs[i] = Double.parseDouble((dataSet.getString("liquidDensityCoefs" + (i + 1)))); + liquidDensityCoefs[i] = + Double.parseDouble((dataSet.getString("liquidDensityCoefs" + (i + 1)))); } for (int i = 0; i < 5; i++) { - heatOfVaporizationCoefs[i] = Double.parseDouble((dataSet.getString("heatOfVaporizationCoefs" + (i + 1)))); + heatOfVaporizationCoefs[i] = + Double.parseDouble((dataSet.getString("heatOfVaporizationCoefs" + (i + 1)))); } // disse maa settes inn fra database ssociationsites numberOfAssociationSites = Integer.parseInt(dataSet.getString("associationsites")); @@ -355,7 +414,8 @@ public void createComponent(String component_name, double moles, double molesInP mCPA = Double.parseDouble(dataSet.getString("mCPA_PR")); } else { // System.out.println("srk-cpa"); - associationVolume = Double.parseDouble(dataSet.getString("associationboundingvolume_SRK")); + associationVolume = + Double.parseDouble(dataSet.getString("associationboundingvolume_SRK")); aCPA = Double.parseDouble(dataSet.getString("aCPA_SRK")); bCPA = Double.parseDouble(dataSet.getString("bCPA_SRK")); mCPA = Double.parseDouble(dataSet.getString("mCPA_SRK")); @@ -363,8 +423,9 @@ public void createComponent(String component_name, double moles, double molesInP criticalViscosity = Double.parseDouble(dataSet.getString("criticalViscosity")); if (criticalViscosity < 1e-20) { - criticalViscosity = 7.94830 * Math.sqrt(1e3 * molarMass) * Math.pow(criticalPressure, 2.0 / 3.0) - / Math.pow(criticalTemperature, 1.0 / 6.0) * 1e-7; + criticalViscosity = + 7.94830 * Math.sqrt(1e3 * molarMass) * Math.pow(criticalPressure, 2.0 / 3.0) + / Math.pow(criticalTemperature, 1.0 / 6.0) * 1e-7; } mSAFTi = Double.parseDouble(dataSet.getString("mSAFT")); sigmaSAFTi = Double.parseDouble(dataSet.getString("sigmaSAFT")) / 1.0e10; @@ -373,8 +434,9 @@ public void createComponent(String component_name, double moles, double molesInP Double.parseDouble(dataSet.getString("associationboundingvolume_PCSAFT"))); setAssociationEnergySAFT(Double.parseDouble(dataSet.getString("associationenergy_PCSAFT"))); if (Math.abs(criticalViscosity) < 1e-12) { - criticalViscosity = 7.94830 * Math.sqrt(molarMass * 1e3) * Math.pow(criticalPressure, 2.0 / 3.0) - / Math.pow(criticalTemperature, 1.0 / 6.0) * 1e-7; + criticalViscosity = + 7.94830 * Math.sqrt(molarMass * 1e3) * Math.pow(criticalPressure, 2.0 / 3.0) + / Math.pow(criticalTemperature, 1.0 / 6.0) * 1e-7; } // System.out.println("crit visc " + criticalViscosity); if (normalLiquidDensity == 0) { @@ -506,8 +568,7 @@ public Element getElements() { /** {@inheritDoc} */ @Override public void Finit(PhaseInterface phase, double temp, double pres, double totMoles, double beta, - int numberOfComponents, int type) { - } + int numberOfComponents, int type) {} /** {@inheritDoc} */ @Override @@ -791,10 +852,8 @@ public double getHsub() { /** * {@inheritDoc} * - * Calculates the pure comonent solid vapor pressure (bar) with the C-C - * equation, based on Hsub - * Should only be used in the valid temperature range below the triple point - * (specified in + * Calculates the pure comonent solid vapor pressure (bar) with the C-C equation, based on Hsub + * Should only be used in the valid temperature range below the triple point (specified in * component database). */ @Override @@ -806,10 +865,8 @@ public double getCCsolidVaporPressure(double temperature) { /** * {@inheritDoc} * - * Calculates the DT of pure comonent solid vapor pressure (bar) with the C-C - * equation, based on - * Hsub Should only be used in the valid temperature range below the triple - * point (specified in + * Calculates the DT of pure comonent solid vapor pressure (bar) with the C-C equation, based on + * Hsub Should only be used in the valid temperature range below the triple point (specified in * component database). */ @Override @@ -821,8 +878,7 @@ public double getCCsolidVaporPressuredT(double temperature) { /** * {@inheritDoc} * - * Calculates the pure component solid density in kg/liter Should only be used - * in the valid + * Calculates the pure component solid density in kg/liter Should only be used in the valid * temperature range (specified in component database). */ @Override @@ -837,10 +893,8 @@ public double getPureComponentSolidDensity(double temperature) { /** * {@inheritDoc} * - * Calculates the pure component liquid density in kg/liter Should only be used - * in the valid - * temperature range (specified in component database). This method seems to - * give bad results at + * Calculates the pure component liquid density in kg/liter Should only be used in the valid + * temperature range (specified in component database). This method seems to give bad results at * the moment */ @Override @@ -939,9 +993,9 @@ public final double getFugacityCoefficient() { /** {@inheritDoc} */ @Override public double fugcoef(PhaseInterface phase) { - fugacityCoefficient = 1.0;// this.fugcoef(phase, phase.getNumberOfComponents(), - // phase.getTemperature(), - // phase.getPressure()); + fugacityCoefficient = 1.0; // this.fugcoef(phase, phase.getNumberOfComponents(), + // phase.getTemperature(), + // phase.getPressure()); logFugacityCoefficient = Math.log(fugacityCoefficient); return fugacityCoefficient; } @@ -949,16 +1003,16 @@ public double fugcoef(PhaseInterface phase) { /** {@inheritDoc} */ @Override public double logfugcoefdT(PhaseInterface phase) { - dfugdt = 0.0;// this.fugcoefDiffTemp(phase, phase.getNumberOfComponents(), - // phase.getTemperature(), phase.getPressure()); + dfugdt = 0.0; // this.fugcoefDiffTemp(phase, phase.getNumberOfComponents(), + // phase.getTemperature(), phase.getPressure()); return dfugdt; } /** {@inheritDoc} */ @Override public double logfugcoefdP(PhaseInterface phase) { - dfugdp = 0.0;// this.fugcoefDiffPres(phase, phase.getNumberOfComponents(), - // phase.getTemperature(), phase.getPressure()); + dfugdp = 0.0; // this.fugcoefDiffPres(phase, phase.getNumberOfComponents(), + // phase.getTemperature(), phase.getPressure()); return dfugdp; } @@ -1073,7 +1127,7 @@ public double getChemicalPotential(PhaseInterface phase) { * getFugacitydN. *

* - * @param i a int + * @param i a int * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object * @return a double */ @@ -1121,7 +1175,7 @@ public final double getChemicalPotentialdV(PhaseInterface phase) { * getChemicalPotentialdP. *

* - * @param i a int + * @param i a int * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object * @return a double */ @@ -1185,7 +1239,8 @@ public double getAntoineVaporPressuredT(double temp) { /** {@inheritDoc} */ @Override public double getAntoineVaporTemperature(double pres) { - double nyPres = 0, nyTemp = criticalTemperature * 0.7; + double nyPres = 0; + double nyTemp = criticalTemperature * 0.7; int iter = 0; do { iter++; @@ -1340,7 +1395,8 @@ public final void setTwuCoonParams(int i, double param) { @Override public double fugcoefDiffPresNumeric(PhaseInterface phase, int numberOfComponents, double temperature, double pressure) { - double temp1 = 0.0, temp2 = 0.0; + double temp1 = 0.0; + double temp2 = 0.0; double dp = phase.getPressure() / 1.0e5; temp1 = phase.getComponents()[componentNumber].getFugacityCoefficient(); phase.setPressure(phase.getPressure() - dp); @@ -1358,7 +1414,8 @@ public double fugcoefDiffPresNumeric(PhaseInterface phase, int numberOfComponent @Override public double fugcoefDiffTempNumeric(PhaseInterface phase, int numberOfComponents, double temperature, double pressure) { - double temp1 = 0.0, temp2 = 0.0; + double temp1 = 0.0; + double temp2 = 0.0; double dt = phase.getTemperature() / 1.0e6; temp1 = phase.getComponents()[componentNumber].getFugacityCoefficient(); phase.setTemperature(phase.getTemperature() - dt); @@ -1480,7 +1537,7 @@ public final double[] getMatiascopemanParamsPR() { * Setter for the field matiascopemanParamsPR. *

* - * @param index a int + * @param index a int * @param matiascopemanParams a double */ public void setMatiascopemanParamsPR(int index, double matiascopemanParams) { @@ -1745,8 +1802,9 @@ public void setIsNormalComponent(boolean isNormalComponent) { /** {@inheritDoc} */ @Override public boolean isIsIon() { - if (componentType.equals("ion")) + if (componentType.equals("ion")) { setIsIon(true); + } return isIon; } @@ -1811,8 +1869,7 @@ public java.lang.String getComponentType() { /** * {@inheritDoc} * - * Getter for property Henrys Coefficient. Unit is bar. ln H = C1 + C2/T + C3lnT - * + C4*T + * Getter for property Henrys Coefficient. Unit is bar. ln H = C1 + C2/T + C3lnT + C4*T */ @Override public double getHenryCoef(double temperature) { @@ -1852,8 +1909,7 @@ public double[] getMatiascopemanSolidParams() { /** * Setter for property matiascopemanSolidParams. * - * @param matiascopemanSolidParams New value of property - * matiascopemanSolidParams. + * @param matiascopemanSolidParams New value of property matiascopemanSolidParams. */ public void setMatiascopemanSolidParams(double[] matiascopemanSolidParams) { this.matiascopemanSolidParams = matiascopemanSolidParams; diff --git a/src/main/java/neqsim/thermo/component/ComponentBWRS.java b/src/main/java/neqsim/thermo/component/ComponentBWRS.java index 7384ee4bf4..0da2b3d433 100644 --- a/src/main/java/neqsim/thermo/component/ComponentBWRS.java +++ b/src/main/java/neqsim/thermo/component/ComponentBWRS.java @@ -14,473 +14,470 @@ * @version $Id: $Id */ public class ComponentBWRS extends ComponentSrk { - private static final long serialVersionUID = 1000; - - int OP = 9; - int OE = 6; - private double[] aBWRS = new double[32]; - private double[] BP = new double[OP]; - private double[] BE = new double[OE]; - - private double[] BPdT = new double[OP]; - private double[] BEdT = new double[OE]; - - private double[] BPdTdT = new double[OP]; - private double[] BEdTdT = new double[OE]; - - double rhoc = 0.0; - double gammaBWRS = 0.0; - - PhaseBWRSEos refPhaseBWRS = null; - - static Logger logger = LogManager.getLogger(ComponentBWRS.class); - - /** - *

- * Constructor for ComponentBWRS. - *

- * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int - */ - public ComponentBWRS(String component_name, double moles, double molesInPhase, int compnumber) { - super(component_name, moles, molesInPhase, compnumber); - - try { - neqsim.util.database.NeqSimDataBase database = - new neqsim.util.database.NeqSimDataBase(); - java.sql.ResultSet dataSet = null; - try { - dataSet = database.getResultSet( - ("SELECT * FROM mbwr32param WHERE name='" + component_name + "'")); - dataSet.next(); - dataSet.getClob("name"); - } catch (Exception e) { - dataSet.close(); - dataSet = database.getResultSet( - ("SELECT * FROM mbwr32param WHERE name='" + component_name + "'")); - dataSet.next(); - } - - for (int i = 0; i < 32; i++) { - aBWRS[i] = Double.parseDouble(dataSet.getString("a" + i)); - // System.out.println(aBWRS[i]); - } - rhoc = Double.parseDouble(dataSet.getString("rhoc")); - gammaBWRS = 1.0 / (rhoc * rhoc); - // logger.info("gamma " + gammaBWRS); - dataSet.close(); - database.getConnection().close(); - } - - catch (Exception e) { - String err = e.toString(); - logger.error(err); - } + private static final long serialVersionUID = 1000; + + int OP = 9; + int OE = 6; + private double[] aBWRS = new double[32]; + private double[] BP = new double[OP]; + private double[] BE = new double[OE]; + + private double[] BPdT = new double[OP]; + private double[] BEdT = new double[OE]; + + private double[] BPdTdT = new double[OP]; + private double[] BEdTdT = new double[OE]; + + double rhoc = 0.0; + double gammaBWRS = 0.0; + + PhaseBWRSEos refPhaseBWRS = null; + + static Logger logger = LogManager.getLogger(ComponentBWRS.class); + + /** + *

+ * Constructor for ComponentBWRS. + *

+ * + * @param component_name a {@link java.lang.String} object + * @param moles a double + * @param molesInPhase a double + * @param compnumber a int + */ + public ComponentBWRS(String component_name, double moles, double molesInPhase, int compnumber) { + super(component_name, moles, molesInPhase, compnumber); + + try { + neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); + java.sql.ResultSet dataSet = null; + try { + dataSet = database + .getResultSet(("SELECT * FROM mbwr32param WHERE name='" + component_name + "'")); + dataSet.next(); + dataSet.getClob("name"); + } catch (Exception e) { + dataSet.close(); + dataSet = database + .getResultSet(("SELECT * FROM mbwr32param WHERE name='" + component_name + "'")); + dataSet.next(); + } + + for (int i = 0; i < 32; i++) { + aBWRS[i] = Double.parseDouble(dataSet.getString("a" + i)); + // System.out.println(aBWRS[i]); + } + rhoc = Double.parseDouble(dataSet.getString("rhoc")); + gammaBWRS = 1.0 / (rhoc * rhoc); + // logger.info("gamma " + gammaBWRS); + dataSet.close(); + database.getConnection().close(); } - /** - *

- * Constructor for ComponentBWRS. - *

- * - * @param number a int - * @param TC a double - * @param PC a double - * @param M a double - * @param a a double - * @param moles a double - */ - public ComponentBWRS(int number, double TC, double PC, double M, double a, double moles) { - super(number, TC, PC, M, a, moles); + catch (Exception e) { + String err = e.toString(); + logger.error(err); } - - /** {@inheritDoc} */ - @Override - public ComponentBWRS clone() { - ComponentBWRS clonedComponent = null; - try { - clonedComponent = (ComponentBWRS) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } - - return clonedComponent; - } - - /** {@inheritDoc} */ - @Override - public void init(double temperature, double pressure, double totalNumberOfMoles, double beta, - int type) { - super.init(temperature, pressure, totalNumberOfMoles, beta, type); - - BP[0] = R * temperature; - BP[1] = aBWRS[0] * temperature + aBWRS[1] * Math.sqrt(temperature) + aBWRS[2] - + aBWRS[3] / temperature + aBWRS[4] / Math.pow(temperature, 2.0); - BP[2] = aBWRS[5] * temperature + aBWRS[6] + aBWRS[7] / temperature - + aBWRS[8] / Math.pow(temperature, 2.0); - BP[3] = aBWRS[9] * temperature + aBWRS[10] + aBWRS[11] / temperature; - BP[4] = aBWRS[12]; - BP[5] = aBWRS[13] / temperature + aBWRS[14] / Math.pow(temperature, 2.0); - BP[6] = aBWRS[15] / temperature; - BP[7] = aBWRS[16] / temperature + aBWRS[17] / Math.pow(temperature, 2.0); - BP[8] = aBWRS[18] / Math.pow(temperature, 2.0); - - BE[0] = (aBWRS[19] / Math.pow(temperature, 2.0) + aBWRS[20] / Math.pow(temperature, 3.0));// *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); - BE[1] = (aBWRS[21] / Math.pow(temperature, 2.0) + aBWRS[22] / Math.pow(temperature, 4.0));// *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); - BE[2] = (aBWRS[23] / Math.pow(temperature, 2.0) + aBWRS[24] / Math.pow(temperature, 3.0));// *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); - BE[3] = (aBWRS[25] / Math.pow(temperature, 2.0) + aBWRS[26] / Math.pow(temperature, 4.0));// *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); - BE[4] = (aBWRS[27] / Math.pow(temperature, 2.0) + aBWRS[28] / Math.pow(temperature, 3.0));// *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); - BE[5] = (aBWRS[29] / Math.pow(temperature, 2.0) + aBWRS[30] / Math.pow(temperature, 3.0) - + aBWRS[31] / Math.pow(temperature, 4.0));// *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); - - BPdT[0] = R; - BPdT[1] = aBWRS[0] + aBWRS[1] / (2.0 * Math.sqrt(temperature)) - - aBWRS[3] / Math.pow(temperature, 2.0) - - 2.0 * aBWRS[4] / Math.pow(temperature, 3.0); - BPdT[2] = aBWRS[5] - aBWRS[7] / Math.pow(temperature, 2.0) - - 2.0 * aBWRS[8] / Math.pow(temperature, 3.0); - BPdT[3] = aBWRS[9] - aBWRS[11] / Math.pow(temperature, 2.0); - BPdT[4] = 0.0; - BPdT[5] = -aBWRS[13] / Math.pow(temperature, 2.0) - - 2.0 * aBWRS[14] / Math.pow(temperature, 3.0); - BPdT[6] = -aBWRS[15] / Math.pow(temperature, 2.0); - BPdT[7] = -aBWRS[16] / Math.pow(temperature, 2.0) - - 2.0 * aBWRS[17] / Math.pow(temperature, 3.0); - BPdT[8] = -2.0 * aBWRS[18] / Math.pow(temperature, 3.0); - - BEdT[0] = (-2.0 * aBWRS[19] / Math.pow(temperature, 3.0) - - 3.0 * aBWRS[20] / Math.pow(temperature, 4.0));// *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); - BEdT[1] = (-2.0 * aBWRS[21] / Math.pow(temperature, 3.0) - - 4.0 * aBWRS[22] / Math.pow(temperature, 5.0));// *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); - BEdT[2] = (-2.0 * aBWRS[23] / Math.pow(temperature, 3.0) - - 3.0 * aBWRS[24] / Math.pow(temperature, 4.0));// *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); - BEdT[3] = (-2.0 * aBWRS[25] / Math.pow(temperature, 3.0) - - 4.0 * aBWRS[26] / Math.pow(temperature, 5.0));// *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); - BEdT[4] = (-2.0 * aBWRS[27] / Math.pow(temperature, 3.0) - - 3.0 * aBWRS[28] / Math.pow(temperature, 4.0));// *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); - BEdT[5] = (-2.0 * aBWRS[29] / Math.pow(temperature, 3.0) - - 3.0 * aBWRS[30] / Math.pow(temperature, 4.0) - - 4.0 * aBWRS[31] / Math.pow(temperature, 5.0));// *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); - - // disse deriverte er ennaa ikke satt inn (finnes i Odvar's avhandling) - BPdTdT[0] = 0; - BPdTdT[1] = 0; - BPdTdT[2] = 0; - BPdTdT[3] = 0; - BPdTdT[4] = 0; - BPdTdT[5] = 0; - BPdTdT[6] = 0; - BPdTdT[7] = 0; - BPdTdT[8] = 0; - - BEdTdT[0] = 0.0; - BEdTdT[1] = 0.0; - BEdTdT[2] = 0.0; - BEdTdT[3] = 0.0; - BEdTdT[4] = 0.0; - BEdTdT[5] = 0.0; - } - - /** {@inheritDoc} */ - @Override - public double dFdN(PhaseInterface phase, int numberOfComponentphases, double temperature, - double pressure) { - // System.out.println("Fref " + - // refPhaseBWRS.getF()/phase.getNumberOfMolesInPhase()); - // System.out.println("Fref2 " + 1e3*(getFpoldn(phase, numberOfComponentphases, - // temperature, pressure) + getFexpdn(phase, numberOfComponentphases, - // temperature, pressure))); - // System.out.println("Fref3 " + refPhaseBWRS.getdFdN()); - return refPhaseBWRS.getF() / phase.getNumberOfMolesInPhase(); - // return refPhaseBWRS.getdFdN(); - // System.out.println("dFdN super " + - // super.dFdN(phase,numberOfComponentphases,temperature,pressure)); - // System.out.println("this dFdN " + 1e3*(getFpoldn(phase, numberOfComponentphases, - // temperature, pressure) + getFexpdn(phase, numberOfComponentphases, temperature, - // pressure))); - // return 1e3*(getFpoldn(phase, numberOfComponentphases, temperature, pressure) - // + getFexpdn(phase, numberOfComponentphases, temperature, pressure)); - } - - /** - *

- * getFpoldn. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComponentphases a int - * @param temperature a double - * @param pressure a double - * @return a double - */ - public double getFpoldn(PhaseInterface phase, int numberOfComponentphases, double temperature, - double pressure) { - double temp = 0.0; - for (int i = 1; i < OP; i++) { - temp += i * getBP(i) / (i - 0.0) - * Math.pow(((PhaseBWRSEos) phase).getMolarDensity(), i - 1.0) - * getdRhodn(phase, numberOfComponentphases, temperature, pressure); - } - return phase.getNumberOfMolesInPhase() / (R * temperature) * temp - + ((PhaseBWRSEos) phase).getFpol() / phase.getNumberOfMolesInPhase(); - } - - /** - *

- * getdRhodn. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComponentphases a int - * @param temperature a double - * @param pressure a double - * @return a double - */ - public double getdRhodn(PhaseInterface phase, int numberOfComponentphases, double temperature, - double pressure) { - return ((PhaseBWRSEos) phase).getMolarDensity() / phase.getNumberOfMolesInPhase(); - } - - /** - *

- * getELdn. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComponentphases a int - * @param temperature a double - * @param pressure a double - * @return a double - */ - public double getELdn(PhaseInterface phase, int numberOfComponentphases, double temperature, - double pressure) { - return -2.0 * ((PhaseBWRSEos) phase).getMolarDensity() * getGammaBWRS() - * Math.exp( - -getGammaBWRS() * Math.pow(((PhaseBWRSEos) phase).getMolarDensity(), 2.0)) - * getdRhodn(phase, numberOfComponentphases, temperature, pressure); - } - - /** - *

- * getFexpdn. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComponentphases a int - * @param temperature a double - * @param pressure a double - * @return a double - */ - public double getFexpdn(PhaseInterface phase, int numberOfComponentphases, double temperature, - double pressure) { - double oldTemp = 0.0, temp = 0.0; - oldTemp = -getBE(0) / (2.0 * getGammaBWRS()) - * getELdn(phase, numberOfComponentphases, temperature, pressure); - - temp += oldTemp; - for (int i = 1; i < OE; i++) { - oldTemp = -getBE(i) / (2.0 * getGammaBWRS()) - * Math.pow(((PhaseBWRSEos) phase).getMolarDensity(), 2 * i) - * getELdn(phase, numberOfComponentphases, temperature, pressure) - - - (2.0 * i) * getBE(i) / (2.0 * getGammaBWRS()) * ((PhaseBWRSEos) phase).getEL() - * Math.pow(((PhaseBWRSEos) phase).getMolarDensity(), 2.0 * i - 1.0) - - + getBE(i) / (2.0 * getGammaBWRS()) * (2.0 * i) / getBE(i - 1) * oldTemp; - - temp += oldTemp; - } - - return phase.getNumberOfMolesInPhase() / (R * temperature) * temp - + ((PhaseBWRSEos) phase).getFexp() / phase.getNumberOfMolesInPhase(); - } - - /** - * Getter for property aBWRS. - * - * @return Value of property aBWRS. - */ - public double[] getABWRS() { - return this.aBWRS; - } - - /** - *

- * Getter for the field aBWRS. - *

- * - * @param i a int - * @return a double - */ - public double getABWRS(int i) { - return this.aBWRS[i]; - } - - /** - * Setter for property aBWRS. - * - * @param aBWRS New value of property aBWRS. - */ - public void setABWRS(double[] aBWRS) { - this.aBWRS = aBWRS; - } - - /** - * Getter for property BP. - * - * @return Value of property BP. public double[] getBPdT() { return this.BPdT; } - * @param i a int - */ - public double getBP(int i) { - return this.BP[i]; + } + + /** + *

+ * Constructor for ComponentBWRS. + *

+ * + * @param number a int + * @param TC a double + * @param PC a double + * @param M a double + * @param a a double + * @param moles a double + */ + public ComponentBWRS(int number, double TC, double PC, double M, double a, double moles) { + super(number, TC, PC, M, a, moles); + } + + /** {@inheritDoc} */ + @Override + public ComponentBWRS clone() { + ComponentBWRS clonedComponent = null; + try { + clonedComponent = (ComponentBWRS) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); } - /** - * Setter for property BP. - * - * @param BP New value of property BP. - */ - public void setBP(double[] BP) { - this.BP = BP; + return clonedComponent; + } + + /** {@inheritDoc} */ + @Override + public void init(double temperature, double pressure, double totalNumberOfMoles, double beta, + int type) { + super.init(temperature, pressure, totalNumberOfMoles, beta, type); + + BP[0] = R * temperature; + BP[1] = aBWRS[0] * temperature + aBWRS[1] * Math.sqrt(temperature) + aBWRS[2] + + aBWRS[3] / temperature + aBWRS[4] / Math.pow(temperature, 2.0); + BP[2] = aBWRS[5] * temperature + aBWRS[6] + aBWRS[7] / temperature + + aBWRS[8] / Math.pow(temperature, 2.0); + BP[3] = aBWRS[9] * temperature + aBWRS[10] + aBWRS[11] / temperature; + BP[4] = aBWRS[12]; + BP[5] = aBWRS[13] / temperature + aBWRS[14] / Math.pow(temperature, 2.0); + BP[6] = aBWRS[15] / temperature; + BP[7] = aBWRS[16] / temperature + aBWRS[17] / Math.pow(temperature, 2.0); + BP[8] = aBWRS[18] / Math.pow(temperature, 2.0); + + BE[0] = (aBWRS[19] / Math.pow(temperature, 2.0) + aBWRS[20] / Math.pow(temperature, 3.0)); // *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); + BE[1] = (aBWRS[21] / Math.pow(temperature, 2.0) + aBWRS[22] / Math.pow(temperature, 4.0)); // *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); + BE[2] = (aBWRS[23] / Math.pow(temperature, 2.0) + aBWRS[24] / Math.pow(temperature, 3.0)); // *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); + BE[3] = (aBWRS[25] / Math.pow(temperature, 2.0) + aBWRS[26] / Math.pow(temperature, 4.0)); // *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); + BE[4] = (aBWRS[27] / Math.pow(temperature, 2.0) + aBWRS[28] / Math.pow(temperature, 3.0)); // *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); + BE[5] = (aBWRS[29] / Math.pow(temperature, 2.0) + aBWRS[30] / Math.pow(temperature, 3.0) + + aBWRS[31] / Math.pow(temperature, 4.0)); // *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); + + BPdT[0] = R; + BPdT[1] = aBWRS[0] + aBWRS[1] / (2.0 * Math.sqrt(temperature)) + - aBWRS[3] / Math.pow(temperature, 2.0) - 2.0 * aBWRS[4] / Math.pow(temperature, 3.0); + BPdT[2] = aBWRS[5] - aBWRS[7] / Math.pow(temperature, 2.0) + - 2.0 * aBWRS[8] / Math.pow(temperature, 3.0); + BPdT[3] = aBWRS[9] - aBWRS[11] / Math.pow(temperature, 2.0); + BPdT[4] = 0.0; + BPdT[5] = + -aBWRS[13] / Math.pow(temperature, 2.0) - 2.0 * aBWRS[14] / Math.pow(temperature, 3.0); + BPdT[6] = -aBWRS[15] / Math.pow(temperature, 2.0); + BPdT[7] = + -aBWRS[16] / Math.pow(temperature, 2.0) - 2.0 * aBWRS[17] / Math.pow(temperature, 3.0); + BPdT[8] = -2.0 * aBWRS[18] / Math.pow(temperature, 3.0); + + BEdT[0] = (-2.0 * aBWRS[19] / Math.pow(temperature, 3.0) + - 3.0 * aBWRS[20] / Math.pow(temperature, 4.0)); // *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); + BEdT[1] = (-2.0 * aBWRS[21] / Math.pow(temperature, 3.0) + - 4.0 * aBWRS[22] / Math.pow(temperature, 5.0)); // *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); + BEdT[2] = (-2.0 * aBWRS[23] / Math.pow(temperature, 3.0) + - 3.0 * aBWRS[24] / Math.pow(temperature, 4.0)); // *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); + BEdT[3] = (-2.0 * aBWRS[25] / Math.pow(temperature, 3.0) + - 4.0 * aBWRS[26] / Math.pow(temperature, 5.0)); // *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); + BEdT[4] = (-2.0 * aBWRS[27] / Math.pow(temperature, 3.0) + - 3.0 * aBWRS[28] / Math.pow(temperature, 4.0)); // *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); + BEdT[5] = (-2.0 * aBWRS[29] / Math.pow(temperature, 3.0) + - 3.0 * aBWRS[30] / Math.pow(temperature, 4.0) + - 4.0 * aBWRS[31] / Math.pow(temperature, 5.0)); // *Math.exp(-gammaBWRS*Math.pow(getMolarDensity(),2.0)); + + // disse deriverte er ennaa ikke satt inn (finnes i Odvar's avhandling) + BPdTdT[0] = 0; + BPdTdT[1] = 0; + BPdTdT[2] = 0; + BPdTdT[3] = 0; + BPdTdT[4] = 0; + BPdTdT[5] = 0; + BPdTdT[6] = 0; + BPdTdT[7] = 0; + BPdTdT[8] = 0; + + BEdTdT[0] = 0.0; + BEdTdT[1] = 0.0; + BEdTdT[2] = 0.0; + BEdTdT[3] = 0.0; + BEdTdT[4] = 0.0; + BEdTdT[5] = 0.0; + } + + /** {@inheritDoc} */ + @Override + public double dFdN(PhaseInterface phase, int numberOfComponentphases, double temperature, + double pressure) { + // System.out.println("Fref " + + // refPhaseBWRS.getF()/phase.getNumberOfMolesInPhase()); + // System.out.println("Fref2 " + 1e3*(getFpoldn(phase, numberOfComponentphases, + // temperature, pressure) + getFexpdn(phase, numberOfComponentphases, + // temperature, pressure))); + // System.out.println("Fref3 " + refPhaseBWRS.getdFdN()); + return refPhaseBWRS.getF() / phase.getNumberOfMolesInPhase(); + // return refPhaseBWRS.getdFdN(); + // System.out.println("dFdN super " + + // super.dFdN(phase,numberOfComponentphases,temperature,pressure)); + // System.out.println("this dFdN " + 1e3*(getFpoldn(phase, numberOfComponentphases, + // temperature, pressure) + getFexpdn(phase, numberOfComponentphases, temperature, + // pressure))); + // return 1e3*(getFpoldn(phase, numberOfComponentphases, temperature, pressure) + // + getFexpdn(phase, numberOfComponentphases, temperature, pressure)); + } + + /** + *

+ * getFpoldn. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComponentphases a int + * @param temperature a double + * @param pressure a double + * @return a double + */ + public double getFpoldn(PhaseInterface phase, int numberOfComponentphases, double temperature, + double pressure) { + double temp = 0.0; + for (int i = 1; i < OP; i++) { + temp += i * getBP(i) / (i - 0.0) * Math.pow(((PhaseBWRSEos) phase).getMolarDensity(), i - 1.0) + * getdRhodn(phase, numberOfComponentphases, temperature, pressure); } - - /** - * Getter for property BE. - * - * @return Value of property BE. - */ - public double[] getBE() { - return this.BE; - } - - /** - *

- * getBE. - *

- * - * @param i a int - * @return a double - */ - public double getBE(int i) { - return this.BE[i]; + return phase.getNumberOfMolesInPhase() / (R * temperature) * temp + + ((PhaseBWRSEos) phase).getFpol() / phase.getNumberOfMolesInPhase(); + } + + /** + *

+ * getdRhodn. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComponentphases a int + * @param temperature a double + * @param pressure a double + * @return a double + */ + public double getdRhodn(PhaseInterface phase, int numberOfComponentphases, double temperature, + double pressure) { + return ((PhaseBWRSEos) phase).getMolarDensity() / phase.getNumberOfMolesInPhase(); + } + + /** + *

+ * getELdn. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComponentphases a int + * @param temperature a double + * @param pressure a double + * @return a double + */ + public double getELdn(PhaseInterface phase, int numberOfComponentphases, double temperature, + double pressure) { + return -2.0 * ((PhaseBWRSEos) phase).getMolarDensity() * getGammaBWRS() + * Math.exp(-getGammaBWRS() * Math.pow(((PhaseBWRSEos) phase).getMolarDensity(), 2.0)) + * getdRhodn(phase, numberOfComponentphases, temperature, pressure); + } + + /** + *

+ * getFexpdn. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComponentphases a int + * @param temperature a double + * @param pressure a double + * @return a double + */ + public double getFexpdn(PhaseInterface phase, int numberOfComponentphases, double temperature, + double pressure) { + double oldTemp = 0.0; + double temp = 0.0; + oldTemp = -getBE(0) / (2.0 * getGammaBWRS()) + * getELdn(phase, numberOfComponentphases, temperature, pressure); + + temp += oldTemp; + for (int i = 1; i < OE; i++) { + oldTemp = -getBE(i) / (2.0 * getGammaBWRS()) + * Math.pow(((PhaseBWRSEos) phase).getMolarDensity(), 2 * i) + * getELdn(phase, numberOfComponentphases, temperature, pressure) + + - (2.0 * i) * getBE(i) / (2.0 * getGammaBWRS()) * ((PhaseBWRSEos) phase).getEL() + * Math.pow(((PhaseBWRSEos) phase).getMolarDensity(), 2.0 * i - 1.0) + + + getBE(i) / (2.0 * getGammaBWRS()) * (2.0 * i) / getBE(i - 1) * oldTemp; + + temp += oldTemp; } - /** - * Setter for property BE. - * - * @param BE New value of property BE. - */ - public void setBE(double[] BE) { - this.BE = BE; - } - - /** - *

- * Setter for the field refPhaseBWRS. - *

- * - * @param refPhaseBWRS a {@link neqsim.thermo.phase.PhaseBWRSEos} object - */ - public void setRefPhaseBWRS(neqsim.thermo.phase.PhaseBWRSEos refPhaseBWRS) { - this.refPhaseBWRS = refPhaseBWRS; - } - - /** - * Getter for property gammaBWRS. - * - * @return Value of property gammaBWRS. - */ - public double getGammaBWRS() { - return gammaBWRS; - } - - /** - * Setter for property gammaBWRS. - * - * @param gammaBWRS New value of property gammaBWRS. - */ - public void setGammaBWRS(double gammaBWRS) { - this.gammaBWRS = gammaBWRS; - } - - /** - * Getter for property BPdT. - * - * @return Value of property BPdT. - */ - public double[] getBPdT() { - return this.BPdT; - } - - /** - *

- * getBPdT. - *

- * - * @param i a int - * @return a double - */ - public double getBPdT(int i) { - return this.BPdT[i]; - } - - /** - * Setter for property BPdT. - * - * @param BPdT New value of property BPdT. - */ - public void setBPdT(double[] BPdT) { - this.BPdT = BPdT; - } - - /** - * Getter for property BEdT. - * - * @return Value of property BEdT. - */ - public double[] getBEdT() { - return this.BEdT; - } - - /** - *

- * getBEdT. - *

- * - * @param i a int - * @return a double - */ - public double getBEdT(int i) { - return this.BEdT[i]; - } - - /** - * Setter for property BEdT. - * - * @param BEdT New value of property BEdT. - */ - public void setBEdT(double[] BEdT) { - this.BEdT = BEdT; - } - - /** - * Getter for property rhoc. - * - * @return Value of property rhoc. - */ - public double getRhoc() { - return rhoc; - } - - /** - * Setter for property rhoc. - * - * @param rhoc New value of property rhoc. - */ - public void setRhoc(double rhoc) { - this.rhoc = rhoc; - } + return phase.getNumberOfMolesInPhase() / (R * temperature) * temp + + ((PhaseBWRSEos) phase).getFexp() / phase.getNumberOfMolesInPhase(); + } + + /** + * Getter for property aBWRS. + * + * @return Value of property aBWRS. + */ + public double[] getABWRS() { + return this.aBWRS; + } + + /** + *

+ * Getter for the field aBWRS. + *

+ * + * @param i a int + * @return a double + */ + public double getABWRS(int i) { + return this.aBWRS[i]; + } + + /** + * Setter for property aBWRS. + * + * @param aBWRS New value of property aBWRS. + */ + public void setABWRS(double[] aBWRS) { + this.aBWRS = aBWRS; + } + + /** + * Getter for property BP. + * + * @return Value of property BP. public double[] getBPdT() { return this.BPdT; } + * @param i a int + */ + public double getBP(int i) { + return this.BP[i]; + } + + /** + * Setter for property BP. + * + * @param BP New value of property BP. + */ + public void setBP(double[] BP) { + this.BP = BP; + } + + /** + * Getter for property BE. + * + * @return Value of property BE. + */ + public double[] getBE() { + return this.BE; + } + + /** + *

+ * getBE. + *

+ * + * @param i a int + * @return a double + */ + public double getBE(int i) { + return this.BE[i]; + } + + /** + * Setter for property BE. + * + * @param BE New value of property BE. + */ + public void setBE(double[] BE) { + this.BE = BE; + } + + /** + *

+ * Setter for the field refPhaseBWRS. + *

+ * + * @param refPhaseBWRS a {@link neqsim.thermo.phase.PhaseBWRSEos} object + */ + public void setRefPhaseBWRS(neqsim.thermo.phase.PhaseBWRSEos refPhaseBWRS) { + this.refPhaseBWRS = refPhaseBWRS; + } + + /** + * Getter for property gammaBWRS. + * + * @return Value of property gammaBWRS. + */ + public double getGammaBWRS() { + return gammaBWRS; + } + + /** + * Setter for property gammaBWRS. + * + * @param gammaBWRS New value of property gammaBWRS. + */ + public void setGammaBWRS(double gammaBWRS) { + this.gammaBWRS = gammaBWRS; + } + + /** + * Getter for property BPdT. + * + * @return Value of property BPdT. + */ + public double[] getBPdT() { + return this.BPdT; + } + + /** + *

+ * getBPdT. + *

+ * + * @param i a int + * @return a double + */ + public double getBPdT(int i) { + return this.BPdT[i]; + } + + /** + * Setter for property BPdT. + * + * @param BPdT New value of property BPdT. + */ + public void setBPdT(double[] BPdT) { + this.BPdT = BPdT; + } + + /** + * Getter for property BEdT. + * + * @return Value of property BEdT. + */ + public double[] getBEdT() { + return this.BEdT; + } + + /** + *

+ * getBEdT. + *

+ * + * @param i a int + * @return a double + */ + public double getBEdT(int i) { + return this.BEdT[i]; + } + + /** + * Setter for property BEdT. + * + * @param BEdT New value of property BEdT. + */ + public void setBEdT(double[] BEdT) { + this.BEdT = BEdT; + } + + /** + * Getter for property rhoc. + * + * @return Value of property rhoc. + */ + public double getRhoc() { + return rhoc; + } + + /** + * Setter for property rhoc. + * + * @param rhoc New value of property rhoc. + */ + public void setRhoc(double rhoc) { + this.rhoc = rhoc; + } } diff --git a/src/main/java/neqsim/thermo/component/ComponentDesmukhMather.java b/src/main/java/neqsim/thermo/component/ComponentDesmukhMather.java index a57ce5bfc5..a6db2db264 100644 --- a/src/main/java/neqsim/thermo/component/ComponentDesmukhMather.java +++ b/src/main/java/neqsim/thermo/component/ComponentDesmukhMather.java @@ -102,7 +102,7 @@ public double getGamma(PhaseInterface phase, int numberOfComponents, double temp for (int i = 0; i < phase.getNumberOfComponents(); i++) { if (!phase.getComponent(i).getComponentName().equals("water")) { temp += 2.0 * ((PhaseDesmukhMather) phase).getBetaDesMatij(i, getComponentNumber()) - * phase.getComponent(i).getMolality(phase);// phase.getComponent(i).getMolarity(phase); + * phase.getComponent(i).getMolality(phase); // phase.getComponent(i).getMolarity(phase); } } // System.out.println("molality MDEA "+ diff --git a/src/main/java/neqsim/thermo/component/ComponentEos.java b/src/main/java/neqsim/thermo/component/ComponentEos.java index 20e11d2c59..ae25803b50 100644 --- a/src/main/java/neqsim/thermo/component/ComponentEos.java +++ b/src/main/java/neqsim/thermo/component/ComponentEos.java @@ -35,694 +35,731 @@ * @author Even Solbraa */ abstract class ComponentEos extends Component implements ComponentEosInterface { - private static final long serialVersionUID = 1000; - - public double a = 1, b = 1, m = 0, alpha = 0, aT = 1, aDiffT = 0, Bi = 0, Ai = 0, AiT = 0, - aDiffDiffT = 0; - public double[] Aij = new double[MAX_NUMBER_OF_COMPONENTS]; - public double[] Bij = new double[MAX_NUMBER_OF_COMPONENTS]; - protected double delta1 = 0, delta2 = 0; - protected double aDern = 0, aDerT = 0, aDerTT = 0, aDerTn = 0, bDern = 0, bDerTn = 0; - protected double dAdndn[] = new double[MAX_NUMBER_OF_COMPONENTS]; - protected double dBdndn[] = new double[MAX_NUMBER_OF_COMPONENTS]; - private AttractiveTermInterface attractiveParameter; - static Logger logger = LogManager.getLogger(ComponentEos.class); - - /** - *

- * Constructor for ComponentEos. - *

- * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int - */ - public ComponentEos(String component_name, double moles, double molesInPhase, int compnumber) { - super(component_name, moles, molesInPhase, compnumber); - } + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for ComponentEos. - *

- * - * @param number a int - * @param TC a double - * @param PC a double - * @param M a double - * @param a a double - * @param moles a double - */ - public ComponentEos(int number, double TC, double PC, double M, double a, double moles) { - super(number, TC, PC, M, a, moles); - } + public double a = 1; - /** {@inheritDoc} */ - @Override - public ComponentEos clone() { - ComponentEos clonedComponent = null; - try { - clonedComponent = (ComponentEos) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } + public double b = 1; - clonedComponent.setAttractiveParameter(this.getAttractiveParameter().clone()); + public double m = 0; - return clonedComponent; - } + public double alpha = 0; - /** {@inheritDoc} */ - @Override - public void init(double temp, double pres, double totMoles, double beta, int type) { - super.init(temp, pres, totMoles, beta, type); - a = calca(); - b = calcb(); - reducedTemperature = reducedTemperature(temp); - reducedPressure = reducedPressure(pres); - aT = a * alpha(temp); - if (type >= 2) { - aDiffT = diffaT(temp); - aDiffDiffT = diffdiffaT(temp); - } - } + public double aT = 1; - /** {@inheritDoc} */ - @Override - public void Finit(PhaseInterface phase, double temp, double pres, double totMoles, double beta, - int numberOfComponents, int type) { - Bi = phase.calcBi(componentNumber, phase, temp, pres, numberOfComponents); - Ai = phase.calcAi(componentNumber, phase, temp, pres, numberOfComponents); - if (type >= 2) { - AiT = phase.calcAiT(componentNumber, phase, temp, pres, numberOfComponents); - } - double totVol = phase.getMolarVolume() * phase.getNumberOfMolesInPhase(); - voli = -(-R * temp * dFdNdV(phase, numberOfComponents, temp, pres) - + R * temp / (phase.getMolarVolume() * phase.getNumberOfMolesInPhase())) - / (-R * temp * phase.dFdVdV() - - phase.getNumberOfMolesInPhase() * R * temp / (totVol * totVol)); - - if (type >= 3) { - for (int j = 0; j < numberOfComponents; j++) { - Aij[j] = phase.calcAij(componentNumber, j, phase, temp, pres, numberOfComponents); - Bij[j] = phase.calcBij(componentNumber, j, phase, temp, pres, numberOfComponents); - } - } - } + public double aDiffT = 0; - /** {@inheritDoc} */ - @Override - public void setAttractiveTerm(int i) { - attractiveTermNumber = i; - if (i == 0) { - setAttractiveParameter(new AttractiveTermSrk(this)); - } else if (i == 1) { - setAttractiveParameter(new AttractiveTermPr(this)); - } else if (i == 2) { - setAttractiveParameter( - new AttractiveTermSchwartzentruber(this, getSchwartzentruberParams())); - } else if (i == 3) { - setAttractiveParameter(new AttractiveTermMollerup(this, getSchwartzentruberParams())); - } else if (i == 4) { - setAttractiveParameter(new AttractiveTermMatCop(this, getMatiascopemanParams())); - } else if (i == 5) { - setAttractiveParameter(new AttractiveTermRk(this)); - } else if (i == 6) { - setAttractiveParameter(new AttractiveTermPr1978(this)); - } else if (i == 7) { - setAttractiveParameter(new AttractiveTermPrDelft1998(this)); - } else if (i == 8) { - setAttractiveParameter(new AttractiveTermPrGassem2001(this)); - } else if (i == 9) { - setAttractiveParameter(new AttractiveTermPrDanesh(this)); - } else if (i == 10) { - setAttractiveParameter(new AttractiveTermGERG(this)); - } else if (i == 11) { - setAttractiveParameter(new AttractiveTermTwuCoon(this)); - } else if (i == 12) { - setAttractiveParameter(new AttractiveTermTwuCoonParam(this, getTwuCoonParams())); - } else if (i == 13) { - setAttractiveParameter(new AttractiveTermMatCopPR(this, getMatiascopemanParamsPR())); - } else if (i == 14) { - setAttractiveParameter(new AttractiveTermTwu(this)); - } else if (i == 15) { - setAttractiveParameter(new AttractiveTermCPAstatoil(this)); - } else if (i == 16) { - setAttractiveParameter(new AttractiveTermUMRPRU(this)); - } else if (i == 17) { - setAttractiveParameter(new AttractiveTermMatCopPRUMR(this)); - } else if (i == 18) { - if (componentName.equals("mercury")) { - setAttractiveParameter(new AttractiveTermTwuCoonStatoil(this, getTwuCoonParams())); - } else { - setAttractiveParameter(new AttractiveTermSrk(this)); - } - } else if (i == 19) { - setAttractiveParameter( - new AtractiveTermMatCopPRUMRNew(this, getMatiascopemanParamsUMRPRU())); - } else { - logger.error("error selecting an alpha formultaion term"); - logger.info("ok setting alpha function"); - } - } + public double Bi = 0; - /** {@inheritDoc} */ - @Override - public AttractiveTermInterface getAttractiveTerm() { - return this.getAttractiveParameter(); - } + public double Ai = 0; - /** - * @param temperature temperature of fluid - * @return double reduced temperature T/TC - */ - double reducedTemperature(double temperature) { - return temperature / criticalTemperature; - } + public double AiT = 0; - /** - * @param pressure pressure in unit bara - * @return double - */ - double reducedPressure(double pressure) { - return pressure / criticalPressure; - } + public double aDiffDiffT = 0; - /** {@inheritDoc} */ - @Override - public double geta() { - return a; - } + public double[] Aij = new double[MAX_NUMBER_OF_COMPONENTS]; + public double[] Bij = new double[MAX_NUMBER_OF_COMPONENTS]; + protected double delta1 = 0; - /** {@inheritDoc} */ - @Override - public double getb() { - return b; - } + protected double delta2 = 0; - /** {@inheritDoc} */ - @Override - public double dFdN(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure) { - return phase.Fn() + phase.FB() * getBi() + phase.FD() * getAi(); - } + protected double aDern = 0; - /** {@inheritDoc} */ - @Override - public double dFdNdT(PhaseInterface phase, int numberOfComponents, double temperature, double pressure) { - return (phase.FBT() + phase.FBD() * phase.getAT()) * getBi() + phase.FDT() * getAi() + phase.FD() * getAiT(); - } - - /** {@inheritDoc} */ - @Override - public double dFdNdV(PhaseInterface phase, int numberOfComponents, double temperature, double pressure) { - return phase.FnV() + phase.FBV() * getBi() + phase.FDV() * getAi(); - } - - /** {@inheritDoc} */ - @Override - public double dFdNdN(int j, PhaseInterface phase, int numberOfComponents, double temperature, double pressure) { - ComponentEosInterface[] comp_Array = (ComponentEosInterface[]) phase.getcomponentArray(); - return phase.FnB() * (getBi() + comp_Array[j].getBi()) - + phase.FBD() * (getBi() * comp_Array[j].getAi() + comp_Array[j].getBi() * getAi()) - + phase.FB() * getBij(j) + phase.FBB() * getBi() * comp_Array[j].getBi() - + phase.FD() * getAij(j); - } - - /** {@inheritDoc} */ - @Override - public double getAi() { - return Ai; - } - - /** {@inheritDoc} */ - @Override - public double getAiT() { - return AiT; - } - - /** {@inheritDoc} */ - @Override - public double getBi() { - return Bi; - } - - /** {@inheritDoc} */ - @Override - public double getBij(int j) { - return Bij[j]; - } - - /** {@inheritDoc} */ - @Override - public double getAij(int j) { - return Aij[j]; - } - - /** {@inheritDoc} */ - @Override - public double getaDiffT() { - return aDiffT; - } - - /** {@inheritDoc} */ - @Override - public double getaDiffDiffT() { - return aDiffDiffT; - } - - /** {@inheritDoc} */ - @Override - public double getaT() { - return aT; - } - - /** {@inheritDoc} */ - @Override - public double fugcoef(PhaseInterface phase) { - double temperature = phase.getTemperature(), pressure = phase.getPressure(); - logFugacityCoefficient = dFdN(phase, phase.getNumberOfComponents(), temperature, pressure) - - Math.log(pressure * phase.getMolarVolume() / (R * temperature)); - fugacityCoefficient = Math.exp(logFugacityCoefficient); - return fugacityCoefficient; - } - - /** {@inheritDoc} */ - @Override - public double logfugcoefdP(PhaseInterface phase) { - double temperature = phase.getTemperature(), pressure = phase.getPressure(); - dfugdp = getVoli() / R / temperature - 1.0 / pressure; - return dfugdp; - } - - /** {@inheritDoc} */ - @Override - public double logfugcoefdT(PhaseInterface phase) { - double temperature = phase.getTemperature(), pressure = phase.getPressure(); - int numberOfComponents = phase.getNumberOfComponents(); - dfugdt = (this.dFdNdT(phase, numberOfComponents, temperature, pressure) + 1.0 / temperature - - getVoli() / R / temperature - * (-R * temperature * phase.dFdTdV() + pressure / temperature)); - return dfugdt; - } - - /** {@inheritDoc} */ - @Override - public double[] logfugcoefdN(PhaseInterface phase) { - double temperature = phase.getTemperature(), pressure = phase.getPressure(); - int numberOfComponents = phase.getNumberOfComponents(); - ComponentEosInterface[] comp_Array = (ComponentEosInterface[]) phase.getComponents(); - - for (int i = 0; i < numberOfComponents; i++) { - // System.out.println("dfdndn " + dFdNdN(i, phase, numberOfComponents, - // temperature, pressure) + " n " + phase.getNumberOfMolesInPhase() + " voli " + - // getVoli()/R/temperature + " dFdNdV " + comp_Array[i].dFdNdV(phase, - // numberOfComponents, temperature, pressure)); - dfugdn[i] = (this.dFdNdN(i, phase, numberOfComponents, temperature, pressure) - + 1.0 / phase.getNumberOfMolesInPhase() - - getVoli() / R / temperature - * (-R * temperature * comp_Array[i].dFdNdV(phase, numberOfComponents, - temperature, pressure) - + R * temperature / phase.getTotalVolume())); - // System.out.println("dfugdn " + dfugdn[i]); - // System.out.println("dFdndn " + dFdNdN(i, phase, numberOfComponents, - // temperature, pressure) + " voli " + voli + " dFdvdn " + - // comp_Array[i].dFdNdV(phase, numberOfComponents, temperature, pressure) + " - // dfugdn " + dfugdn[i]); - dfugdx[i] = dfugdn[i] * phase.getNumberOfMolesInPhase(); - } - // System.out.println("diffN: " + 1 + dfugdn[0]); - return dfugdn; - } - - // Method added by Neeraj + protected double aDerT = 0; + + protected double aDerTT = 0; + + protected double aDerTn = 0; + + protected double bDern = 0; + + protected double bDerTn = 0; + + protected double[] dAdndn = new double[MAX_NUMBER_OF_COMPONENTS]; + protected double[] dBdndn = new double[MAX_NUMBER_OF_COMPONENTS]; + private AttractiveTermInterface attractiveParameter; + static Logger logger = LogManager.getLogger(ComponentEos.class); + + /** + *

+ * Constructor for ComponentEos. + *

+ * + * @param component_name a {@link java.lang.String} object + * @param moles a double + * @param molesInPhase a double + * @param compnumber a int + */ + public ComponentEos(String component_name, double moles, double molesInPhase, int compnumber) { + super(component_name, moles, molesInPhase, compnumber); + } + + /** + *

+ * Constructor for ComponentEos. + *

+ * + * @param number a int + * @param TC a double + * @param PC a double + * @param M a double + * @param a a double + * @param moles a double + */ + public ComponentEos(int number, double TC, double PC, double M, double a, double moles) { + super(number, TC, PC, M, a, moles); + } + + /** {@inheritDoc} */ + @Override + public ComponentEos clone() { + ComponentEos clonedComponent = null; + try { + clonedComponent = (ComponentEos) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); + } + + clonedComponent.setAttractiveParameter(this.getAttractiveParameter().clone()); + + return clonedComponent; + } + + /** {@inheritDoc} */ + @Override + public void init(double temp, double pres, double totMoles, double beta, int type) { + super.init(temp, pres, totMoles, beta, type); + a = calca(); + b = calcb(); + reducedTemperature = reducedTemperature(temp); + reducedPressure = reducedPressure(pres); + aT = a * alpha(temp); + if (type >= 2) { + aDiffT = diffaT(temp); + aDiffDiffT = diffdiffaT(temp); + } + } + + /** {@inheritDoc} */ + @Override + public void Finit(PhaseInterface phase, double temp, double pres, double totMoles, double beta, + int numberOfComponents, int type) { + Bi = phase.calcBi(componentNumber, phase, temp, pres, numberOfComponents); + Ai = phase.calcAi(componentNumber, phase, temp, pres, numberOfComponents); + if (type >= 2) { + AiT = phase.calcAiT(componentNumber, phase, temp, pres, numberOfComponents); + } + double totVol = phase.getMolarVolume() * phase.getNumberOfMolesInPhase(); + voli = -(-R * temp * dFdNdV(phase, numberOfComponents, temp, pres) + + R * temp / (phase.getMolarVolume() * phase.getNumberOfMolesInPhase())) + / (-R * temp * phase.dFdVdV() + - phase.getNumberOfMolesInPhase() * R * temp / (totVol * totVol)); + + if (type >= 3) { + for (int j = 0; j < numberOfComponents; j++) { + Aij[j] = phase.calcAij(componentNumber, j, phase, temp, pres, numberOfComponents); + Bij[j] = phase.calcBij(componentNumber, j, phase, temp, pres, numberOfComponents); + } + } + } + + /** {@inheritDoc} */ + @Override + public void setAttractiveTerm(int i) { + attractiveTermNumber = i; + if (i == 0) { + setAttractiveParameter(new AttractiveTermSrk(this)); + } else if (i == 1) { + setAttractiveParameter(new AttractiveTermPr(this)); + } else if (i == 2) { + setAttractiveParameter(new AttractiveTermSchwartzentruber(this, getSchwartzentruberParams())); + } else if (i == 3) { + setAttractiveParameter(new AttractiveTermMollerup(this, getSchwartzentruberParams())); + } else if (i == 4) { + setAttractiveParameter(new AttractiveTermMatCop(this, getMatiascopemanParams())); + } else if (i == 5) { + setAttractiveParameter(new AttractiveTermRk(this)); + } else if (i == 6) { + setAttractiveParameter(new AttractiveTermPr1978(this)); + } else if (i == 7) { + setAttractiveParameter(new AttractiveTermPrDelft1998(this)); + } else if (i == 8) { + setAttractiveParameter(new AttractiveTermPrGassem2001(this)); + } else if (i == 9) { + setAttractiveParameter(new AttractiveTermPrDanesh(this)); + } else if (i == 10) { + setAttractiveParameter(new AttractiveTermGERG(this)); + } else if (i == 11) { + setAttractiveParameter(new AttractiveTermTwuCoon(this)); + } else if (i == 12) { + setAttractiveParameter(new AttractiveTermTwuCoonParam(this, getTwuCoonParams())); + } else if (i == 13) { + setAttractiveParameter(new AttractiveTermMatCopPR(this, getMatiascopemanParamsPR())); + } else if (i == 14) { + setAttractiveParameter(new AttractiveTermTwu(this)); + } else if (i == 15) { + setAttractiveParameter(new AttractiveTermCPAstatoil(this)); + } else if (i == 16) { + setAttractiveParameter(new AttractiveTermUMRPRU(this)); + } else if (i == 17) { + setAttractiveParameter(new AttractiveTermMatCopPRUMR(this)); + } else if (i == 18) { + if (componentName.equals("mercury")) { + setAttractiveParameter(new AttractiveTermTwuCoonStatoil(this, getTwuCoonParams())); + } else { + setAttractiveParameter(new AttractiveTermSrk(this)); + } + } else if (i == 19) { + setAttractiveParameter(new AtractiveTermMatCopPRUMRNew(this, getMatiascopemanParamsUMRPRU())); + } else { + logger.error("error selecting an alpha formultaion term"); + logger.info("ok setting alpha function"); + } + } + + /** {@inheritDoc} */ + @Override + public AttractiveTermInterface getAttractiveTerm() { + return this.getAttractiveParameter(); + } + + /** + * @param temperature temperature of fluid + * @return double reduced temperature T/TC + */ + double reducedTemperature(double temperature) { + return temperature / criticalTemperature; + } + + /** + * @param pressure pressure in unit bara + * @return double + */ + double reducedPressure(double pressure) { + return pressure / criticalPressure; + } + + /** {@inheritDoc} */ + @Override + public double geta() { + return a; + } + + /** {@inheritDoc} */ + @Override + public double getb() { + return b; + } + + /** {@inheritDoc} */ + @Override + public double dFdN(PhaseInterface phase, int numberOfComponents, double temperature, + double pressure) { + return phase.Fn() + phase.FB() * getBi() + phase.FD() * getAi(); + } + + /** {@inheritDoc} */ + @Override + public double dFdNdT(PhaseInterface phase, int numberOfComponents, double temperature, + double pressure) { + return (phase.FBT() + phase.FBD() * phase.getAT()) * getBi() + phase.FDT() * getAi() + + phase.FD() * getAiT(); + } + + /** {@inheritDoc} */ + @Override + public double dFdNdV(PhaseInterface phase, int numberOfComponents, double temperature, + double pressure) { + return phase.FnV() + phase.FBV() * getBi() + phase.FDV() * getAi(); + } + + /** {@inheritDoc} */ + @Override + public double dFdNdN(int j, PhaseInterface phase, int numberOfComponents, double temperature, + double pressure) { + ComponentEosInterface[] comp_Array = (ComponentEosInterface[]) phase.getcomponentArray(); + return phase.FnB() * (getBi() + comp_Array[j].getBi()) + + phase.FBD() * (getBi() * comp_Array[j].getAi() + comp_Array[j].getBi() * getAi()) + + phase.FB() * getBij(j) + phase.FBB() * getBi() * comp_Array[j].getBi() + + phase.FD() * getAij(j); + } + + /** {@inheritDoc} */ + @Override + public double getAi() { + return Ai; + } + + /** {@inheritDoc} */ + @Override + public double getAiT() { + return AiT; + } + + /** {@inheritDoc} */ + @Override + public double getBi() { + return Bi; + } + + /** {@inheritDoc} */ + @Override + public double getBij(int j) { + return Bij[j]; + } + + /** {@inheritDoc} */ + @Override + public double getAij(int j) { + return Aij[j]; + } + + /** {@inheritDoc} */ + @Override + public double getaDiffT() { + return aDiffT; + } + + /** {@inheritDoc} */ + @Override + public double getaDiffDiffT() { + return aDiffDiffT; + } + + /** {@inheritDoc} */ + @Override + public double getaT() { + return aT; + } + + /** {@inheritDoc} */ + @Override + public double fugcoef(PhaseInterface phase) { + double temperature = phase.getTemperature(); + double pressure = phase.getPressure(); + logFugacityCoefficient = dFdN(phase, phase.getNumberOfComponents(), temperature, pressure) + - Math.log(pressure * phase.getMolarVolume() / (R * temperature)); + fugacityCoefficient = Math.exp(logFugacityCoefficient); + return fugacityCoefficient; + } + + /** {@inheritDoc} */ + @Override + public double logfugcoefdP(PhaseInterface phase) { + double temperature = phase.getTemperature(); + double pressure = phase.getPressure(); + dfugdp = getVoli() / R / temperature - 1.0 / pressure; + return dfugdp; + } + + /** {@inheritDoc} */ + @Override + public double logfugcoefdT(PhaseInterface phase) { + double temperature = phase.getTemperature(); + double pressure = phase.getPressure(); + int numberOfComponents = phase.getNumberOfComponents(); + dfugdt = (this.dFdNdT(phase, numberOfComponents, temperature, pressure) + 1.0 / temperature + - getVoli() / R / temperature + * (-R * temperature * phase.dFdTdV() + pressure / temperature)); + return dfugdt; + } + + /** {@inheritDoc} */ + @Override + public double[] logfugcoefdN(PhaseInterface phase) { + double temperature = phase.getTemperature(); + double pressure = phase.getPressure(); + int numberOfComponents = phase.getNumberOfComponents(); + ComponentEosInterface[] comp_Array = (ComponentEosInterface[]) phase.getComponents(); + + for (int i = 0; i < numberOfComponents; i++) { + // System.out.println("dfdndn " + dFdNdN(i, phase, numberOfComponents, + // temperature, pressure) + " n " + phase.getNumberOfMolesInPhase() + " voli " + + // getVoli()/R/temperature + " dFdNdV " + comp_Array[i].dFdNdV(phase, + // numberOfComponents, temperature, pressure)); + dfugdn[i] = (this.dFdNdN(i, phase, numberOfComponents, temperature, pressure) + + 1.0 / phase.getNumberOfMolesInPhase() - getVoli() / R / temperature + * (-R * temperature + * comp_Array[i].dFdNdV(phase, numberOfComponents, temperature, pressure) + + R * temperature / phase.getTotalVolume())); + // System.out.println("dfugdn " + dfugdn[i]); + // System.out.println("dFdndn " + dFdNdN(i, phase, numberOfComponents, + // temperature, pressure) + " voli " + voli + " dFdvdn " + + // comp_Array[i].dFdNdV(phase, numberOfComponents, temperature, pressure) + " + // dfugdn " + dfugdn[i]); + dfugdx[i] = dfugdn[i] * phase.getNumberOfMolesInPhase(); + } + // System.out.println("diffN: " + 1 + dfugdn[0]); + return dfugdn; + } + + // Method added by Neeraj + /* + * public double getdfugdn(int i){ double[] dfugdnv = this.logfugcoefdN(phase); //return 0.0001; + * return dfugdnv[i]; } + */ + // Added By Neeraj + /** {@inheritDoc} */ + @Override + public double logfugcoefdNi(PhaseInterface phase, int k) { + double temperature = phase.getTemperature(); + double pressure = phase.getPressure(); + int numberOfComponents = phase.getNumberOfComponents(); + double vol; + double voli; + ComponentEosInterface[] comp_Array = (ComponentEosInterface[]) phase.getcomponentArray(); + vol = phase.getMolarVolume(); + voli = getVoli(); + + dfugdn[k] = (this.dFdNdN(k, phase, numberOfComponents, temperature, pressure) + + 1.0 / phase.getNumberOfMolesInPhase() + - voli / R / temperature + * (-R * temperature + * comp_Array[k].dFdNdV(phase, numberOfComponents, temperature, pressure) + + R * temperature / (vol * phase.getNumberOfMolesInPhase()))); + dfugdx[k] = dfugdn[k] * (phase.getNumberOfMolesInPhase()); + // System.out.println("Main dfugdn "+dfugdn[k]); + return dfugdn[k]; + } + + /** {@inheritDoc} */ + @Override + public double getAder() { + return aDern; + } + + /** {@inheritDoc} */ + @Override + public void setAder(double val) { + aDern = val; + } + + /** {@inheritDoc} */ + @Override + public double getdAdndn(int j) { + return dAdndn[j]; + } + + /** {@inheritDoc} */ + @Override + public void setdAdndn(int jComp, double val) { + dAdndn[jComp] = val; + } + + /** {@inheritDoc} */ + @Override + public void setdAdT(double val) { + aDerT = val; + } + + /** {@inheritDoc} */ + @Override + public double getdAdT() { + return aDerT; + } + + /** {@inheritDoc} */ + @Override + public void setdAdTdn(double val) { + aDerTn = val; + } + + /** {@inheritDoc} */ + @Override + public double getdAdTdn() { + return aDerTn; + } + + /** + *

+ * getdAdTdT. + *

+ * + * @return a double + */ + public double getdAdTdT() { + return aDerT; + } + + /** {@inheritDoc} */ + @Override + public void setdAdTdT(double val) { + aDerTT = val; + } + + /** {@inheritDoc} */ + @Override + public double getBder() { + return bDern; + } + + /** {@inheritDoc} */ + @Override + public void setBder(double val) { + bDern = val; + } + + /** {@inheritDoc} */ + @Override + public double getdBdndn(int j) { + return dBdndn[j]; + } + + /** {@inheritDoc} */ + @Override + public void setdBdndn(int jComp, double val) { + dBdndn[jComp] = val; + } + + /** {@inheritDoc} */ + @Override + public double getdBdT() { + return 1; + } + + /** {@inheritDoc} */ + @Override + public void setdBdTdT(double val) {} + + /** {@inheritDoc} */ + @Override + public double getdBdndT() { + return bDerTn; + } + + /** {@inheritDoc} */ + @Override + public void setdBdndT(double val) { + bDerTn = val; + } + + /** + *

+ * alpha. + *

+ * + * @param temperature a double + * @return a double + */ + public double alpha(double temperature) { + return getAttractiveParameter().alpha(temperature); + } + + /** {@inheritDoc} */ + @Override + public double aT(double temperature) { + return getAttractiveParameter().aT(temperature); + } + + /** + *

+ * diffalphaT. + *

+ * + * @param temperature a double + * @return a double + */ + public double diffalphaT(double temperature) { + return getAttractiveParameter().diffalphaT(temperature); + } + + /** + *

+ * diffdiffalphaT. + *

+ * + * @param temperature a double + * @return a double + */ + public double diffdiffalphaT(double temperature) { + return getAttractiveParameter().diffdiffalphaT(temperature); + } + + /** {@inheritDoc} */ + @Override + public double diffaT(double temperature) { + return getAttractiveParameter().diffaT(temperature); + } + + /** {@inheritDoc} */ + @Override + public double diffdiffaT(double temperature) { + return getAttractiveParameter().diffdiffaT(temperature); + } + + /** {@inheritDoc} */ + @Override + public double[] getDeltaEosParameters() { + double[] param = {delta1, delta2}; + return param; + } + + /** {@inheritDoc} */ + @Override + public void seta(double a) { + this.a = a; + } + + /** {@inheritDoc} */ + @Override + public void setb(double b) { + this.b = b; + } + + /** {@inheritDoc} */ + @Override + public abstract double calca(); + + /** {@inheritDoc} */ + @Override + public abstract double calcb(); + + /** {@inheritDoc} */ + @Override + public double getSurfaceTenisionInfluenceParameter(double temperature) { /* - * public double getdfugdn(int i){ double[] dfugdnv = this.logfugcoefdN(phase); //return 0.0001; - * return dfugdnv[i]; } - */ - // Added By Neeraj - /** {@inheritDoc} */ - @Override - public double logfugcoefdNi(PhaseInterface phase, int k) { - double temperature = phase.getTemperature(), pressure = phase.getPressure(); - int numberOfComponents = phase.getNumberOfComponents(); - double vol, voli; - ComponentEosInterface[] comp_Array = (ComponentEosInterface[]) phase.getcomponentArray(); - vol = phase.getMolarVolume(); - voli = getVoli(); - - dfugdn[k] = - (this.dFdNdN(k, phase, numberOfComponents, temperature, pressure) - + 1.0 / phase.getNumberOfMolesInPhase() - - voli / R / temperature * (-R * temperature - * comp_Array[k].dFdNdV(phase, numberOfComponents, temperature, - pressure) - + R * temperature / (vol * phase.getNumberOfMolesInPhase()))); - dfugdx[k] = dfugdn[k] * (phase.getNumberOfMolesInPhase()); - // System.out.println("Main dfugdn "+dfugdn[k]); - return dfugdn[k]; - } - - /** {@inheritDoc} */ - @Override - public double getAder() { - return aDern; - } - - /** {@inheritDoc} */ - @Override - public void setAder(double val) { - aDern = val; - } - - /** {@inheritDoc} */ - @Override - public double getdAdndn(int j) { - return dAdndn[j]; - } - - /** {@inheritDoc} */ - @Override - public void setdAdndn(int jComp, double val) { - dAdndn[jComp] = val; - } - - /** {@inheritDoc} */ - @Override - public void setdAdT(double val) { - aDerT = val; - } - - /** {@inheritDoc} */ - @Override - public double getdAdT() { - return aDerT; - } - - /** {@inheritDoc} */ - @Override - public void setdAdTdn(double val) { - aDerTn = val; - } - - /** {@inheritDoc} */ - @Override - public double getdAdTdn() { - return aDerTn; - } - - /** - *

- * getdAdTdT. - *

- * - * @return a double + * double a_inf = -3.471 + 4.927 * getCriticalCompressibilityFactor() + 13.085 * + * Math.pow(getCriticalCompressibilityFactor(), 2.0) - 2.067 * getAcentricFactor() + 1.891 * + * Math.pow(getAcentricFactor(), 2.0); double b_inf = -1.690 + 2.311 * + * getCriticalCompressibilityFactor() + 5.644 * Math.pow(getCriticalCompressibilityFactor(), + * 2.0) - 1.027 * getAcentricFactor() + 1.424 * Math.pow(getAcentricFactor(), 2.0); double c_inf + * = -0.318 + 0.299 * getCriticalCompressibilityFactor() + 1.710 * + * Math.pow(getCriticalCompressibilityFactor(), 2.0) - 0.174 * getAcentricFactor() + 0.157 * + * Math.pow(getAcentricFactor(), 2.0); */ - public double getdAdTdT() { - return aDerT; - } - - /** {@inheritDoc} */ - @Override - public void setdAdTdT(double val) { - aDerTT = val; - } - - /** {@inheritDoc} */ - @Override - public double getBder() { - return bDern; - } - - /** {@inheritDoc} */ - @Override - public void setBder(double val) { - bDern = val; - } - - /** {@inheritDoc} */ - @Override - public double getdBdndn(int j) { - return dBdndn[j]; - } - - /** {@inheritDoc} */ - @Override - public void setdBdndn(int jComp, double val) { - dBdndn[jComp] = val; - } - - /** {@inheritDoc} */ - @Override - public double getdBdT() { - return 1; - } - - /** {@inheritDoc} */ - @Override - public void setdBdTdT(double val) {} - - /** {@inheritDoc} */ - @Override - public double getdBdndT() { - return bDerTn; - } - - /** {@inheritDoc} */ - @Override - public void setdBdndT(double val) { - bDerTn = val; - } - - /** - *

- * alpha. - *

- * - * @param temperature a double - * @return a double - */ - public double alpha(double temperature) { - return getAttractiveParameter().alpha(temperature); - } - - /** {@inheritDoc} */ - @Override - public double aT(double temperature) { - return getAttractiveParameter().aT(temperature); - } - - /** - *

- * diffalphaT. - *

- * - * @param temperature a double - * @return a double - */ - public double diffalphaT(double temperature) { - return getAttractiveParameter().diffalphaT(temperature); - } - - /** - *

- * diffdiffalphaT. - *

- * - * @param temperature a double - * @return a double - */ - public double diffdiffalphaT(double temperature) { - return getAttractiveParameter().diffdiffalphaT(temperature); - } - - /** {@inheritDoc} */ - @Override - public double diffaT(double temperature) { - return getAttractiveParameter().diffaT(temperature); - } - - /** {@inheritDoc} */ - @Override - public double diffdiffaT(double temperature) { - return getAttractiveParameter().diffdiffaT(temperature); - } - - /** {@inheritDoc} */ - @Override - public double[] getDeltaEosParameters() { - double[] param = {delta1, delta2}; - return param; - } - - /** {@inheritDoc} */ - @Override - public void seta(double a) { - this.a = a; - } - - /** {@inheritDoc} */ - @Override - public void setb(double b) { - this.b = b; - } - - /** {@inheritDoc} */ - @Override - public abstract double calca(); - - /** {@inheritDoc} */ - @Override - public abstract double calcb(); - - /** {@inheritDoc} */ - @Override - public double getSurfaceTenisionInfluenceParameter(double temperature) { - /* - * double a_inf = -3.471 + 4.927 * getCriticalCompressibilityFactor() + 13.085 * - * Math.pow(getCriticalCompressibilityFactor(), 2.0) - 2.067 * getAcentricFactor() + 1.891 * - * Math.pow(getAcentricFactor(), 2.0); double b_inf = -1.690 + 2.311 * - * getCriticalCompressibilityFactor() + 5.644 * Math.pow(getCriticalCompressibilityFactor(), - * 2.0) - 1.027 * getAcentricFactor() + 1.424 * Math.pow(getAcentricFactor(), 2.0); double - * c_inf = -0.318 + 0.299 * getCriticalCompressibilityFactor() + 1.710 * - * Math.pow(getCriticalCompressibilityFactor(), 2.0) - 0.174 * getAcentricFactor() + 0.157 * - * Math.pow(getAcentricFactor(), 2.0); - */ - double TR = 1.0 - temperature / getTC(); - if (TR < 1) { - TR = 0.5; - } - - // double scale1 = aT * 1e-5 * Math.pow(b * 1e-5, 2.0 / 3.0) * Math.exp(a_inf + b_inf * - // Math.log(TR) + c_inf * (Math.pow(Math.log(TR), 2.0))) / - // Math.pow(ThermodynamicConstantsInterface.avagadroNumber, 8.0 / 3.0); - - // System.out.println("scale1 " + scale1); - // return scale1; - // getAttractiveTerm().alpha(temperature)*1e-5 * Math.pow(b*1e-5, 2.0 / 3.0) * - // Math.exp(a_inf + b_inf * Math.log(TR) + c_inf * (Math.pow(Math.log(TR), - // 2.0)))/ Math.pow(ThermodynamicConstantsInterface.avagadroNumber, 8.0 / 3.0); - - double AA = -1.0e-16 / (1.2326 + 1.3757 * getAcentricFactor()); - double BB = 1.0e-16 / (0.9051 + 1.541 * getAcentricFactor()); - - // double scale2 = getAttractiveTerm().alpha(temperature) * 1e-5 * Math.pow(b * 1e-5, 2.0 / - // 3.0) * (AA * TR + BB); - // System.out.println("scale2 " + scale2); - return aT * 1e-5 * Math.pow(b * 1e-5, 2.0 / 3.0) * (AA * TR + BB);/// Math.pow(ThermodynamicConstantsInterface.avagadroNumber, - /// 2.0 / 3.0); - } - - /** - *

- * getAresnTV. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double getAresnTV(PhaseInterface phase) { - return R * phase.getTemperature() * dFdN(phase, phase.getNumberOfComponents(), - phase.getTemperature(), phase.getPressure()); - } - - /** {@inheritDoc} */ - @Override - public double getChemicalPotential(PhaseInterface phase) { - double entalp = getHID(phase.getTemperature()) * numberOfMolesInPhase; - double entrop = numberOfMolesInPhase * getIdEntropy(phase.getTemperature()); - // double chempot = ((entalp - phase.getTemperature() * entrop) + numberOfMolesInPhase * R * - // phase.getTemperature() * Math.log(numberOfMolesInPhase * R * phase.getTemperature() / - // phase.getVolume() / referencePressure) + getAresnTV(phase) * numberOfMolesInPhase) / - // numberOfMolesInPhase; - - // double chempot2 = super.getChemicalPotential(phase); - // System.out.println("d " + chempot + " " + chempot2); - return ((entalp - phase.getTemperature() * entrop) - + numberOfMolesInPhase * R * phase.getTemperature() - * Math.log(numberOfMolesInPhase * R * phase.getTemperature() - / phase.getVolume() / referencePressure) - + getAresnTV(phase) * numberOfMolesInPhase) / numberOfMolesInPhase; - // return dF; - } - - /** - *

- * getdUdnSV. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double getdUdnSV(PhaseInterface phase) { - return getChemicalPotential(phase); - } - - /** - *

- * getdUdSdnV. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double getdUdSdnV(PhaseInterface phase) { - return -1.0 / phase.FTT() * dFdNdT(phase, phase.getNumberOfComponents(), - phase.getTemperature(), phase.getPressure()); - } - - /** - *

- * getdUdVdnS. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double getdUdVdnS(PhaseInterface phase) { - return 1.0 / phase.FTT() * dFdNdV(phase, phase.getNumberOfComponents(), - phase.getTemperature(), phase.getPressure()); - } - - /** - *

- * getdUdndnSV. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param compNumb1 a int - * @param compNumb2 a int - * @return a double - */ - public double getdUdndnSV(PhaseInterface phase, int compNumb1, int compNumb2) { - return dFdNdN(compNumb2, phase, phase.getNumberOfComponents(), phase.getTemperature(), - phase.getPressure()) - - dFdNdT(phase, phase.getNumberOfComponents(), phase.getTemperature(), - phase.getPressure()) * 1.0 / phase.FTT();// * - // phase.getComponent(compNumb2).getF; - } - - /** - *

- * Getter for the field attractiveParameter. - *

- * - * @return a {@link neqsim.thermo.component.attractiveEosTerm.AttractiveTermInterface} object - */ - public AttractiveTermInterface getAttractiveParameter() { - return attractiveParameter; - } - - /** - *

- * Setter for the field attractiveParameter. - *

- * - * @param attractiveParameter a - * {@link neqsim.thermo.component.attractiveEosTerm.AttractiveTermInterface} object - */ - public void setAttractiveParameter(AttractiveTermInterface attractiveParameter) { - this.attractiveParameter = attractiveParameter; - } + double TR = 1.0 - temperature / getTC(); + if (TR < 1) { + TR = 0.5; + } + + // double scale1 = aT * 1e-5 * Math.pow(b * 1e-5, 2.0 / 3.0) * Math.exp(a_inf + b_inf * + // Math.log(TR) + c_inf * (Math.pow(Math.log(TR), 2.0))) / + // Math.pow(ThermodynamicConstantsInterface.avagadroNumber, 8.0 / 3.0); + + // System.out.println("scale1 " + scale1); + // return scale1; + // getAttractiveTerm().alpha(temperature)*1e-5 * Math.pow(b*1e-5, 2.0 / 3.0) * + // Math.exp(a_inf + b_inf * Math.log(TR) + c_inf * (Math.pow(Math.log(TR), + // 2.0)))/ Math.pow(ThermodynamicConstantsInterface.avagadroNumber, 8.0 / 3.0); + + double AA = -1.0e-16 / (1.2326 + 1.3757 * getAcentricFactor()); + double BB = 1.0e-16 / (0.9051 + 1.541 * getAcentricFactor()); + + // double scale2 = getAttractiveTerm().alpha(temperature) * 1e-5 * Math.pow(b * 1e-5, 2.0 / + // 3.0) * (AA * TR + BB); + // System.out.println("scale2 " + scale2); + return aT * 1e-5 * Math.pow(b * 1e-5, 2.0 / 3.0) * (AA * TR + BB); /// Math.pow(ThermodynamicConstantsInterface.avagadroNumber, + /// 2.0 / 3.0); + } + + /** + *

+ * getAresnTV. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double getAresnTV(PhaseInterface phase) { + return R * phase.getTemperature() + * dFdN(phase, phase.getNumberOfComponents(), phase.getTemperature(), phase.getPressure()); + } + + /** {@inheritDoc} */ + @Override + public double getChemicalPotential(PhaseInterface phase) { + double entalp = getHID(phase.getTemperature()) * numberOfMolesInPhase; + double entrop = numberOfMolesInPhase * getIdEntropy(phase.getTemperature()); + // double chempot = ((entalp - phase.getTemperature() * entrop) + numberOfMolesInPhase * R * + // phase.getTemperature() * Math.log(numberOfMolesInPhase * R * phase.getTemperature() / + // phase.getVolume() / referencePressure) + getAresnTV(phase) * numberOfMolesInPhase) / + // numberOfMolesInPhase; + + // double chempot2 = super.getChemicalPotential(phase); + // System.out.println("d " + chempot + " " + chempot2); + return ((entalp - phase.getTemperature() * entrop) + numberOfMolesInPhase * R + * phase.getTemperature() * Math.log(numberOfMolesInPhase * R * phase.getTemperature() + / phase.getVolume() / referencePressure) + + getAresnTV(phase) * numberOfMolesInPhase) / numberOfMolesInPhase; + // return dF; + } + + /** + *

+ * getdUdnSV. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double getdUdnSV(PhaseInterface phase) { + return getChemicalPotential(phase); + } + + /** + *

+ * getdUdSdnV. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double getdUdSdnV(PhaseInterface phase) { + return -1.0 / phase.FTT() + * dFdNdT(phase, phase.getNumberOfComponents(), phase.getTemperature(), phase.getPressure()); + } + + /** + *

+ * getdUdVdnS. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double getdUdVdnS(PhaseInterface phase) { + return 1.0 / phase.FTT() + * dFdNdV(phase, phase.getNumberOfComponents(), phase.getTemperature(), phase.getPressure()); + } + + /** + *

+ * getdUdndnSV. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param compNumb1 a int + * @param compNumb2 a int + * @return a double + */ + public double getdUdndnSV(PhaseInterface phase, int compNumb1, int compNumb2) { + return dFdNdN(compNumb2, phase, phase.getNumberOfComponents(), phase.getTemperature(), + phase.getPressure()) + - dFdNdT(phase, phase.getNumberOfComponents(), phase.getTemperature(), phase.getPressure()) + * 1.0 / phase.FTT(); // * + // phase.getComponent(compNumb2).getF; + } + + /** + *

+ * Getter for the field attractiveParameter. + *

+ * + * @return a {@link neqsim.thermo.component.attractiveEosTerm.AttractiveTermInterface} object + */ + public AttractiveTermInterface getAttractiveParameter() { + return attractiveParameter; + } + + /** + *

+ * Setter for the field attractiveParameter. + *

+ * + * @param attractiveParameter a + * {@link neqsim.thermo.component.attractiveEosTerm.AttractiveTermInterface} object + */ + public void setAttractiveParameter(AttractiveTermInterface attractiveParameter) { + this.attractiveParameter = attractiveParameter; + } } diff --git a/src/main/java/neqsim/thermo/component/ComponentGE.java b/src/main/java/neqsim/thermo/component/ComponentGE.java index c727459ad1..80be04b868 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGE.java +++ b/src/main/java/neqsim/thermo/component/ComponentGE.java @@ -16,137 +16,140 @@ * @author Even Solbraa */ abstract class ComponentGE extends Component implements ComponentGEInterface { - private static final long serialVersionUID = 1000; - - protected double gamma = 0, gammaRefCor = 0; - protected double lngamma = 0, dlngammadt = 0, dlngammadp = 0, dlngammadtdt = 0.0; - protected double[] dlngammadn; - static Logger logger = LogManager.getLogger(ComponentGE.class); - - /** - *

- * Constructor for ComponentGE. - *

- * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int - */ - public ComponentGE(String component_name, double moles, double molesInPhase, int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + private static final long serialVersionUID = 1000; + + protected double gamma = 0; + protected double gammaRefCor = 0; + protected double lngamma = 0; + protected double dlngammadt = 0; + protected double dlngammadp = 0; + protected double dlngammadtdt = 0.0; + protected double[] dlngammadn; + static Logger logger = LogManager.getLogger(ComponentGE.class); + + /** + *

+ * Constructor for ComponentGE. + *

+ * + * @param component_name a {@link java.lang.String} object + * @param moles a double + * @param molesInPhase a double + * @param compnumber a int + */ + public ComponentGE(String component_name, double moles, double molesInPhase, int compnumber) { + super(component_name, moles, molesInPhase, compnumber); + } + + /** {@inheritDoc} */ + @Override + public double fugcoef(PhaseInterface phase) { + logger.info("fug coef " + + gamma * getAntoineVaporPressure(phase.getTemperature()) / phase.getPressure()); + if (referenceStateType.equals("solvent")) { + fugacityCoefficient = + gamma * getAntoineVaporPressure(phase.getTemperature()) / phase.getPressure(); + gammaRefCor = gamma; + } else { + double activinf = 1.0; + if (phase.hasComponent("water")) { + int waternumb = phase.getComponent("water").getComponentNumber(); + activinf = + gamma / ((PhaseGE) phase).getActivityCoefficientInfDilWater(componentNumber, waternumb); + } else { + activinf = gamma / ((PhaseGE) phase).getActivityCoefficientInfDil(componentNumber); + } + fugacityCoefficient = activinf * getHenryCoef(phase.getTemperature()) / phase.getPressure(); // gamma* + // benyttes + // ikke + gammaRefCor = activinf; } - - /** {@inheritDoc} */ - @Override - public double fugcoef(PhaseInterface phase) { - logger.info("fug coef " - + gamma * getAntoineVaporPressure(phase.getTemperature()) / phase.getPressure()); - if (referenceStateType.equals("solvent")) { - fugacityCoefficient = - gamma * getAntoineVaporPressure(phase.getTemperature()) / phase.getPressure(); - gammaRefCor = gamma; - } else { - double activinf = 1.0; - if (phase.hasComponent("water")) { - int waternumb = phase.getComponent("water").getComponentNumber(); - activinf = gamma / ((PhaseGE) phase) - .getActivityCoefficientInfDilWater(componentNumber, waternumb); - } else { - activinf = gamma / ((PhaseGE) phase).getActivityCoefficientInfDil(componentNumber); - } - fugacityCoefficient = - activinf * getHenryCoef(phase.getTemperature()) / phase.getPressure();// gamma* - // benyttes - // ikke - gammaRefCor = activinf; - } - logFugacityCoefficient = Math.log(fugacityCoefficient); - - return fugacityCoefficient; - } - - /** - *

- * fugcoefDiffPres. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double fugcoefDiffPres(PhaseInterface phase) { - // double temperature = phase.getTemperature(), pressure = phase.getPressure(); - // int numberOfComponents = phase.getNumberOfComponents(); - if (referenceStateType.equals("solvent")) { - dfugdp = 0.0; // forelopig uten pointing - } else { - dfugdp = 0.0; // forelopig uten pointing - } - return dfugdp; - } - - /** - *

- * fugcoefDiffTemp. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double fugcoefDiffTemp(PhaseInterface phase) { - double temperature = phase.getTemperature(); - // double pressure = phase.getPressure(); - // int numberOfComponents = phase.getNumberOfComponents(); - - if (referenceStateType.equals("solvent")) { - dfugdt = dlngammadt + 1.0 / getAntoineVaporPressure(temperature) - * getAntoineVaporPressuredT(temperature); - logger.info("check this dfug dt - antoine"); - } else { - dfugdt = dlngammadt + getHenryCoefdT(temperature); - } - return dfugdt; - } - - /** {@inheritDoc} */ - @Override - public double getGamma() { - return gamma; - } - - /** {@inheritDoc} */ - @Override - public double getlnGamma() { - return lngamma; + logFugacityCoefficient = Math.log(fugacityCoefficient); + + return fugacityCoefficient; + } + + /** + *

+ * fugcoefDiffPres. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double fugcoefDiffPres(PhaseInterface phase) { + // double temperature = phase.getTemperature(), pressure = phase.getPressure(); + // int numberOfComponents = phase.getNumberOfComponents(); + if (referenceStateType.equals("solvent")) { + dfugdp = 0.0; // forelopig uten pointing + } else { + dfugdp = 0.0; // forelopig uten pointing } - - /** {@inheritDoc} */ - @Override - public double getlnGammadt() { - return dlngammadt; - } - - /** {@inheritDoc} */ - @Override - public double getlnGammadtdt() { - return dlngammadtdt; - } - - /** {@inheritDoc} */ - @Override - public double getlnGammadn(int k) { - return dlngammadn[k]; - } - - /** {@inheritDoc} */ - @Override - public void setlnGammadn(int k, double val) { - dlngammadn[k] = val; - } - - /** {@inheritDoc} */ - @Override - public double getGammaRefCor() { - return gammaRefCor; + return dfugdp; + } + + /** + *

+ * fugcoefDiffTemp. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double fugcoefDiffTemp(PhaseInterface phase) { + double temperature = phase.getTemperature(); + // double pressure = phase.getPressure(); + // int numberOfComponents = phase.getNumberOfComponents(); + + if (referenceStateType.equals("solvent")) { + dfugdt = dlngammadt + + 1.0 / getAntoineVaporPressure(temperature) * getAntoineVaporPressuredT(temperature); + logger.info("check this dfug dt - antoine"); + } else { + dfugdt = dlngammadt + getHenryCoefdT(temperature); } + return dfugdt; + } + + /** {@inheritDoc} */ + @Override + public double getGamma() { + return gamma; + } + + /** {@inheritDoc} */ + @Override + public double getlnGamma() { + return lngamma; + } + + /** {@inheritDoc} */ + @Override + public double getlnGammadt() { + return dlngammadt; + } + + /** {@inheritDoc} */ + @Override + public double getlnGammadtdt() { + return dlngammadtdt; + } + + /** {@inheritDoc} */ + @Override + public double getlnGammadn(int k) { + return dlngammadn[k]; + } + + /** {@inheritDoc} */ + @Override + public void setlnGammadn(int k, double val) { + dlngammadn[k] = val; + } + + /** {@inheritDoc} */ + @Override + public double getGammaRefCor() { + return gammaRefCor; + } } diff --git a/src/main/java/neqsim/thermo/component/ComponentGENRTLmodifiedHV.java b/src/main/java/neqsim/thermo/component/ComponentGENRTLmodifiedHV.java index 0be963182a..a2d34d2da7 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGENRTLmodifiedHV.java +++ b/src/main/java/neqsim/thermo/component/ComponentGENRTLmodifiedHV.java @@ -65,20 +65,58 @@ public double getGamma(PhaseInterface phase, int numberOfComponents, double temp double pressure, int phasetype, double[][] HValpha, double[][] HVgij, double[][] HVgijT, double[][] intparam, String[][] mixRule) { int type = phase.getInitType(); - double A = 0, B = 0, C = 0, D = 0, E = 0, F = 0, tau = 0, tau2 = 0, G = 0, G2 = 0, alpha = 0, - Dij = 0, Dji = 0, DijT = 0, DjiT = 0, gij = 0, gjj = 0, gji = 0, gii = 0; - int j, l; - double dAdT = 0, dBdT = 0, dCdT = 0, dCdTdT = 0, dDdT = 0, dDdTdT = 0, dBdTdT = 0; + double A = 0; + double B = 0; + double C = 0; + double D = 0; + double E = 0; + double F = 0; + double tau = 0; + double tau2 = 0; + double G = 0; + double G2 = 0; + double alpha = 0; + double Dij = 0; + double Dji = 0; + double DijT = 0; + double DjiT = 0; + double gij = 0; + double gjj = 0; + double gji = 0; + double gii = 0; + int j; + int l; + double dAdT = 0; + double dBdT = 0; + double dCdT = 0; + double dCdTdT = 0; + double dDdT = 0; + double dDdTdT = 0; + double dBdTdT = 0; // double dEdT; double dAdTdT = 0; - double dtaudt = 0, dtaudtdt = 0.0, dtau2dt = 0, dtau2dtdt = 0.0, dGdt = 0, dG2dt = 0, - dGdtdt = 0, dG2dtdt = 0.0; + double dtaudt = 0; + double dtaudtdt = 0.0; + double dtau2dt = 0; + double dtau2dtdt = 0.0; + double dGdt = 0; + double dG2dt = 0; + double dGdtdt = 0; + double dG2dtdt = 0.0; double[][] Gmatrix = new double[numberOfComponents][numberOfComponents]; double[][] tauMatrix = new double[numberOfComponents][numberOfComponents]; dlngammadn = new double[numberOfComponents]; ComponentEosInterface[] comp_Array = (ComponentEosInterface[]) phase.getcomponentArray(); - double dA2dTetter = 0, dA2dTdTetter = 0, dA3dTetter = 0, dA3dTdTetter = 0.0, dA4dTetter = 0, - dA4dTdTetter = 0, dA5dTetter = 0, dA5dTdTetter = 0, dA6dTetter = 0, dA6dTdTetter = 0; + double dA2dTetter = 0; + double dA2dTdTetter = 0; + double dA3dTetter = 0; + double dA3dTdTetter = 0.0; + double dA4dTetter = 0; + double dA4dTdTetter = 0; + double dA5dTetter = 0; + double dA5dTdTetter = 0; + double dA6dTetter = 0; + double dA6dTdTetter = 0; // for(int w=0;w<3;w++){ F = 0; // double dFdT = 0; @@ -93,8 +131,16 @@ public double getGamma(PhaseInterface phase, int numberOfComponents, double temp dA4dTetter = 0; dA5dTetter = 0; dA6dTetter = 0; - double dA2dT = 0, dA2dTdT = 0.0, dA3dT = 0, dA3dTdT = 0, dA4dT = 0, dA4dTdT = 0, dA5dT = 0, - dA5dTdT = 0, dA6dT = 0, dA6dTdT = 0.0; + double dA2dT = 0; + double dA2dTdT = 0.0; + double dA3dT = 0; + double dA3dTdT = 0; + double dA4dT = 0; + double dA4dTdT = 0; + double dA5dT = 0; + double dA5dTdT = 0; + double dA6dT = 0; + double dA6dTdT = 0.0; double deltaEOS = 1.0 / (comp_Array[0].getDeltaEosParameters()[1] - comp_Array[0].getDeltaEosParameters()[0]) * Math.log((1.0 + comp_Array[0].getDeltaEosParameters()[1]) @@ -395,11 +441,11 @@ public double getGamma(PhaseInterface phase, int numberOfComponents, double temp * Gmatrix[componentNumber][f] / (sum * sum); } dlngammadn[p] = (dAdn / B - A / (B * B) * dBdn) + dEdn / Ctemp - Dtemp - - Etemp * Gmatrix[componentNumber][p] / (Ctemp * Ctemp) + 2.0 * Ftemp - Gtemp;// E/(C*C)*dCdn[p]*(tau2-D/C) - // + - // E/C*(-dDdn[p]/C - // + - // D/(C*C)*dCdn[p]); + - Etemp * Gmatrix[componentNumber][p] / (Ctemp * Ctemp) + 2.0 * Ftemp - Gtemp; // E/(C*C)*dCdn[p]*(tau2-D/C) + // + + // E/C*(-dDdn[p]/C + // + + // D/(C*C)*dCdn[p]); dlngammadn[p] /= (nt); } // System.out.println("Dlngamdn: " + dlngammadn[p] + " x: " + diff --git a/src/main/java/neqsim/thermo/component/ComponentGENRTLmodifiedWS.java b/src/main/java/neqsim/thermo/component/ComponentGENRTLmodifiedWS.java index 6bf82f1636..b3437d97b6 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGENRTLmodifiedWS.java +++ b/src/main/java/neqsim/thermo/component/ComponentGENRTLmodifiedWS.java @@ -11,253 +11,293 @@ * @version $Id: $Id */ public class ComponentGENRTLmodifiedWS extends ComponentGeNRTL { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for ComponentGENRTLmodifiedWS. - *

- * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int - */ - public ComponentGENRTLmodifiedWS(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); - } + /** + *

+ * Constructor for ComponentGENRTLmodifiedWS. + *

+ * + * @param component_name a {@link java.lang.String} object + * @param moles a double + * @param molesInPhase a double + * @param compnumber a int + */ + public ComponentGENRTLmodifiedWS(String component_name, double moles, double molesInPhase, + int compnumber) { + super(component_name, moles, molesInPhase, compnumber); + } - /** {@inheritDoc} */ - @Override - public double getlnGammadt() { - return dlngammadt; - } + /** {@inheritDoc} */ + @Override + public double getlnGammadt() { + return dlngammadt; + } - /** {@inheritDoc} */ - @Override - public double getlnGammadn(int k) { - return dlngammadn[k]; - } + /** {@inheritDoc} */ + @Override + public double getlnGammadn(int k) { + return dlngammadn[k]; + } - /** {@inheritDoc} */ - @Override - public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype, double[][] WSalpha, double[][] WSgij, - double[][] intparam, String[][] mixRule) { - double[][] WSgijT = new double[numberOfComponents][numberOfComponents]; - return getGamma(phase, numberOfComponents, temperature, pressure, phasetype, WSalpha, WSgij, - WSgijT, intparam, mixRule); - } + /** {@inheritDoc} */ + @Override + public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, + double pressure, int phasetype, double[][] WSalpha, double[][] WSgij, double[][] intparam, + String[][] mixRule) { + double[][] WSgijT = new double[numberOfComponents][numberOfComponents]; + return getGamma(phase, numberOfComponents, temperature, pressure, phasetype, WSalpha, WSgij, + WSgijT, intparam, mixRule); + } - /** - *

- * getGamma. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComponents a int - * @param temperature a double - * @param pressure a double - * @param phasetype a int - * @param WSalpha an array of {@link double} objects - * @param WSgij an array of {@link double} objects - * @param WSgijT an array of {@link double} objects - * @param intparam an array of {@link double} objects - * @param mixRule an array of {@link java.lang.String} objects - * @return a double - */ - @SuppressWarnings("unused") - public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype, double[][] WSalpha, double[][] WSgij, double[][] WSgijT, - double[][] intparam, String[][] mixRule) { - double type = phase.getInitType(); - double A = 0, B = 0, C = 0, D = 0, E = 0, F = 0, ny = 0, tau = 0, tau2 = 0, G = 0, G2 = 0, - alpha = 0, Dij = 0, Djj = 0, Dji = 0, Dii = 0, DijT = 0, DjjT = 0, DjiT = 0, - DiiT = 0, gij = 0, gjj = 0, gji = 0, gii = 0, F2T = 0, tot2 = 0; - int i, j, l, k, delta = 0; - double dAdT = 0, dBdT = 0, dEdT, dCdT = 0, dFdT = 0, dDdT = 0; - double dtaudt = 0, dtau2dt = 0, dGdt = 0, dG2dt = 0; - double[][] Gmatrix = new double[numberOfComponents][numberOfComponents]; - double[][] tauMatrix = new double[numberOfComponents][numberOfComponents]; - dlngammadn = new double[numberOfComponents]; - ComponentInterface[] comp_Array = phase.getcomponentArray(); - double lngammaold = 0, dlngammadtold = 0, dA2dTetter = 0, dA3dTetter = 0, dA4dTetter = 0, - dA5dTetter = 0, dA6dTetter = 0; - // for(int w=0;w<3;w++){ - F = 0; - dFdT = 0; - dBdT = 0; - dAdT = 0; - dDdT = 0; - A = 0; - B = 0; - dlngammadt = 0.0; - dA2dTetter = 0; - dA3dTetter = 0; - dA4dTetter = 0; - dA5dTetter = 0; - dA6dTetter = 0; - double dA2dT = 0, dA3dT = 0, dA4dT = 0, dA5dT = 0, dA6dT = 0; + /** + *

+ * getGamma. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComponents a int + * @param temperature a double + * @param pressure a double + * @param phasetype a int + * @param WSalpha an array of {@link double} objects + * @param WSgij an array of {@link double} objects + * @param WSgijT an array of {@link double} objects + * @param intparam an array of {@link double} objects + * @param mixRule an array of {@link java.lang.String} objects + * @return a double + */ + @SuppressWarnings("unused") + public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, + double pressure, int phasetype, double[][] WSalpha, double[][] WSgij, double[][] WSgijT, + double[][] intparam, String[][] mixRule) { + double type = phase.getInitType(); + double A = 0; + double B = 0; + double C = 0; + double D = 0; + double E = 0; + double F = 0; + double ny = 0; + double tau = 0; + double tau2 = 0; + double G = 0; + double G2 = 0; + double alpha = 0; + double Dij = 0; + double Djj = 0; + double Dji = 0; + double Dii = 0; + double DijT = 0; + double DjjT = 0; + double DjiT = 0; + double DiiT = 0; + double gij = 0; + double gjj = 0; + double gji = 0; + double gii = 0; + double F2T = 0; + double tot2 = 0; + int i; + int j; + int l; + int k; + int delta = 0; + double dAdT = 0; + double dBdT = 0; + double dEdT; + double dCdT = 0; + double dFdT = 0; + double dDdT = 0; + double dtaudt = 0; + double dtau2dt = 0; + double dGdt = 0; + double dG2dt = 0; + double[][] Gmatrix = new double[numberOfComponents][numberOfComponents]; + double[][] tauMatrix = new double[numberOfComponents][numberOfComponents]; + dlngammadn = new double[numberOfComponents]; + ComponentInterface[] comp_Array = phase.getcomponentArray(); + double lngammaold = 0; + double dlngammadtold = 0; + double dA2dTetter = 0; + double dA3dTetter = 0; + double dA4dTetter = 0; + double dA5dTetter = 0; + double dA6dTetter = 0; + // for(int w=0;w<3;w++){ + F = 0; + dFdT = 0; + dBdT = 0; + dAdT = 0; + dDdT = 0; + A = 0; + B = 0; + dlngammadt = 0.0; + dA2dTetter = 0; + dA3dTetter = 0; + dA4dTetter = 0; + dA5dTetter = 0; + dA6dTetter = 0; + double dA2dT = 0; - // PhaseGEEosInterface phaseny = (PhaseGEEosInterface) phase.getPhase(); - // PhaseGEInterface GEPhase = phaseny.getGEphase(); + // PhaseGEEosInterface phaseny = (PhaseGEEosInterface) phase.getPhase(); + // PhaseGEInterface GEPhase = phaseny.getGEphase(); - // ComponentGeNRTLInterface[] compArray = (ComponentGeNRTLInterface[]) - // GEPhase.getcomponentArray(); - // PhaseGEInterface GEphase = new PhaseGEInterface(); - // PhaseGEInterface phaseny = (PhaseGEInterface) phase.getPhase(); + // ComponentGeNRTLInterface[] compArray = (ComponentGeNRTLInterface[]) + // GEPhase.getcomponentArray(); + // PhaseGEInterface GEphase = new PhaseGEInterface(); + // PhaseGEInterface phaseny = (PhaseGEInterface) phase.getPhase(); - for (j = 0; j < numberOfComponents; j++) { - Dij = WSgij[this.getComponentNumber()][j]; - // System.out.println("Dij" + Dij); - Dji = WSgij[j][this.getComponentNumber()]; - // System.out.println("Dji" + Dji); - DijT = WSgijT[this.getComponentNumber()][j]; - DjiT = WSgijT[j][this.getComponentNumber()]; - // gji = HVgij[j][this.getComponentNumber()]; - // gjj = HVgii[j][j]; - alpha = WSalpha[j][this.getComponentNumber()]; // new HV + T*(gji-gii) - tau = Dji / (temperature) + DjiT; // + Math.pow(gji, b) - tau2 = Dij / (temperature) + DijT; - dtaudt = -tau / temperature + DjiT / temperature; - dtau2dt = -tau2 / temperature + DijT / temperature; - // System.out.println("method GE1" + tau); + double dA3dT = 0; + double dA4dT = 0; + double dA5dT = 0; + double dA6dT = 0; + for (j = 0; j < numberOfComponents; j++) { + Dij = WSgij[this.getComponentNumber()][j]; + // System.out.println("Dij" + Dij); + Dji = WSgij[j][this.getComponentNumber()]; + // System.out.println("Dji" + Dji); + DijT = WSgijT[this.getComponentNumber()][j]; + DjiT = WSgijT[j][this.getComponentNumber()]; + // gji = HVgij[j][this.getComponentNumber()]; + // gjj = HVgii[j][j]; + alpha = WSalpha[j][this.getComponentNumber()]; // new HV + T*(gji-gii) + tau = Dji / (temperature) + DjiT; // + Math.pow(gji, b) + tau2 = Dij / (temperature) + DijT; + dtaudt = -tau / temperature + DjiT / temperature; + dtau2dt = -tau2 / temperature + DijT / temperature; + // System.out.println("method GE1" + tau); - G = Math.exp(-alpha * tau); - dGdt = dtaudt * -alpha * G; - G2 = Math.exp(-alpha * tau2); - dG2dt = dtau2dt * -alpha * G2; + G = Math.exp(-alpha * tau); + dGdt = dtaudt * -alpha * G; + G2 = Math.exp(-alpha * tau2); + dG2dt = dtau2dt * -alpha * G2; - A += tau * G * comp_Array[j].getx(); - dAdT = dAdT + comp_Array[j].getx() * dGdt * tau + comp_Array[j].getx() * G * dtaudt; - dA2dT = comp_Array[j].getx() * dG2dt * tau2 + comp_Array[j].getx() * G2 * dtau2dt; - dA3dT = tau2 * G2 * comp_Array[j].getx(); - dA4dT = 2 * comp_Array[j].getx() * G2; - dA5dT = comp_Array[j].getx() * dG2dt; - dA6dT = comp_Array[j].getx() * G2; - B += G * comp_Array[j].getx(); - dBdT += dGdt * comp_Array[j].getx(); - E = G2 * comp_Array[j].getx(); - dEdT = dG2dt * comp_Array[j].getx(); + A += tau * G * comp_Array[j].getx(); + dAdT = dAdT + comp_Array[j].getx() * dGdt * tau + comp_Array[j].getx() * G * dtaudt; + dA2dT = comp_Array[j].getx() * dG2dt * tau2 + comp_Array[j].getx() * G2 * dtau2dt; + dA3dT = tau2 * G2 * comp_Array[j].getx(); + dA4dT = 2 * comp_Array[j].getx() * G2; + dA5dT = comp_Array[j].getx() * dG2dt; + dA6dT = comp_Array[j].getx() * G2; + B += G * comp_Array[j].getx(); + dBdT += dGdt * comp_Array[j].getx(); + E = G2 * comp_Array[j].getx(); + dEdT = dG2dt * comp_Array[j].getx(); - C = 0; - D = 0; - dCdT = 0; - dDdT = 0; - // System.out.println("hei"); + C = 0; + D = 0; + dCdT = 0; + dDdT = 0; + // System.out.println("hei"); - for (l = 0; l < numberOfComponents; l++) { - Dij = WSgij[l][j]; - DijT = WSgijT[l][j]; - alpha = WSalpha[l][j]; - tau = Dij / (temperature) + DijT; - dtaudt = -tau / temperature + DijT / temperature; + for (l = 0; l < numberOfComponents; l++) { + Dij = WSgij[l][j]; + DijT = WSgijT[l][j]; + alpha = WSalpha[l][j]; + tau = Dij / (temperature) + DijT; + dtaudt = -tau / temperature + DijT / temperature; - G = Math.exp(-alpha * tau); - dGdt = dtaudt * -alpha * G; - Gmatrix[l][j] = G; - tauMatrix[l][j] = tau; + G = Math.exp(-alpha * tau); + dGdt = dtaudt * -alpha * G; + Gmatrix[l][j] = G; + tauMatrix[l][j] = tau; - C += G * comp_Array[l].getx(); - dCdT += dGdt * comp_Array[l].getx(); - D += G * tau * comp_Array[l].getx(); - dDdT += comp_Array[l].getx() * dGdt * tau + comp_Array[l].getx() * G * dtaudt; - } - dA2dTetter += dA2dT / C; - dA3dTetter += dA3dT * dCdT / (C * C); + C += G * comp_Array[l].getx(); + dCdT += dGdt * comp_Array[l].getx(); + D += G * tau * comp_Array[l].getx(); + dDdT += comp_Array[l].getx() * dGdt * tau + comp_Array[l].getx() * G * dtaudt; + } + dA2dTetter += dA2dT / C; + dA3dTetter += dA3dT * dCdT / (C * C); - dA4dTetter += dA4dT * dCdT * D / (C * C * C); - dA5dTetter += dA5dT * D / (C * C); - dA6dTetter += dA6dT * dDdT / (C * C); + dA4dTetter += dA4dT * dCdT * D / (C * C * C); + dA5dTetter += dA5dT * D / (C * C); + dA6dTetter += dA6dT * dDdT / (C * C); - if (mixRule[this.getComponentNumber()][j].equals("WS")) { - tau2 = WSgij[this.getComponentNumber()][j] / (temperature) - + WSgijT[this.getComponentNumber()][j]; - } - dtau2dt = -tau2 / temperature + WSgijT[this.getComponentNumber()][j] / temperature; + if (mixRule[this.getComponentNumber()][j].equals("WS")) { + tau2 = WSgij[this.getComponentNumber()][j] / (temperature) + + WSgijT[this.getComponentNumber()][j]; + } + dtau2dt = -tau2 / temperature + WSgijT[this.getComponentNumber()][j] / temperature; - F += E / C * (tau2 - D / C); - dFdT += (dEdT / C - E / (C * C) * dCdT) * (tau2 - D / C) - + E / C * (dtau2dt - (dDdT / C - D / (C * C) * dCdT)); - // F2T = F2T - 2*2*A/Math.pow(C,2) + 2*2*E*D/Math.pow(C,3); // A til A2; - } + F += E / C * (tau2 - D / C); + dFdT += (dEdT / C - E / (C * C) * dCdT) * (tau2 - D / C) + + E / C * (dtau2dt - (dDdT / C - D / (C * C) * dCdT)); + // F2T = F2T - 2*2*A/Math.pow(C,2) + 2*2*E*D/Math.pow(C,3); // A til A2; + } - lngamma = A / B + F; - // dlngammadt = dAdT/B - A/(B*B)*dBdT + dFdT; - dlngammadt = (dAdT / B - A / (B * B) * dBdT + dA2dTetter - dA3dTetter + dA4dTetter - - dA5dTetter - dA6dTetter); - /* - * if(w==0){ dlngammadtold = dlngammadt; temperature +=0.0001; } - * - * if(w==1){ lngammaold = lngamma; temperature -=0.0002; } } - */ - // System.out.println("deriv: " + lngammaold + " " + lngamma + " " + - // ((lngammaold-lngamma)/0.0002) + " " + dlngammadtold); - // System.out.println("deriv t : " +dlngammadt); + lngamma = A / B + F; + // dlngammadt = dAdT/B - A/(B*B)*dBdT + dFdT; + dlngammadt = (dAdT / B - A / (B * B) * dBdT + dA2dTetter - dA3dTetter + dA4dTetter - dA5dTetter + - dA6dTetter); + /* + * if(w==0){ dlngammadtold = dlngammadt; temperature +=0.0001; } + * + * if(w==1){ lngammaold = lngamma; temperature -=0.0002; } } + */ + // System.out.println("deriv: " + lngammaold + " " + lngamma + " " + + // ((lngammaold-lngamma)/0.0002) + " " + dlngammadtold); + // System.out.println("deriv t : " +dlngammadt); - // tot2 = -2*A/B/B + F2T; - // dlngammadt = (lngammaold-lngamma)/0.002; + // tot2 = -2*A/B/B + F2T; + // dlngammadt = (lngammaold-lngamma)/0.002; - // phaseny.getExessGibbsEnergy(numberOfComponents, temperature, pressure, - // phasetype) - gamma = Math.exp(lngamma); + // phaseny.getExessGibbsEnergy(numberOfComponents, temperature, pressure, + // phasetype) + gamma = Math.exp(lngamma); - // if derivates.... - if (type == 3) { - double dAdn = 0; - double dBdn = 0; - double Etemp = 0; - double dEdn = 0; - double Ctemp = 0; - double Dtemp = 0; - double Ftemp = 0; - double Gtemp = 0; + // if derivates.... + if (type == 3) { + double dAdn = 0; + double dBdn = 0; + double Etemp = 0; + double dEdn = 0; + double Ctemp = 0; + double Dtemp = 0; + double Ftemp = 0; + double Gtemp = 0; - for (int p = 0; p < numberOfComponents; p++) { - dAdn = tauMatrix[p][this.getComponentNumber()] - * Gmatrix[p][this.getComponentNumber()]; - dBdn = Gmatrix[p][this.getComponentNumber()]; - dEdn = Gmatrix[this.getComponentNumber()][p] - * tauMatrix[this.getComponentNumber()][p]; - // dFdn = Gmatrix[this.getComponentNumber()][p]; - Dtemp = 0; - Ctemp = 0; - Etemp = 0; - Ftemp = 0; - Gtemp = 0; - double nt = 0; - for (int f = 0; f < numberOfComponents; f++) { - nt += comp_Array[f].getNumberOfMolesInPhase(); - Ctemp += comp_Array[f].getx() * Gmatrix[f][p]; - Etemp += comp_Array[f].getx() * Gmatrix[f][p] * tauMatrix[f][p]; - double sum = 0.0; - double sum2 = 0.0; - for (int g = 0; g < numberOfComponents; g++) { - sum += comp_Array[g].getx() * Gmatrix[g][f]; - sum2 += comp_Array[g].getx() * Gmatrix[g][f] * tauMatrix[g][f]; - } - Dtemp += Gmatrix[p][f] * Gmatrix[this.getComponentNumber()][f] - * tauMatrix[this.getComponentNumber()][f] * comp_Array[f].getx() - / (sum * sum); - Ftemp += comp_Array[f].getx() * Gmatrix[p][f] * sum2 - * Gmatrix[this.getComponentNumber()][f] / (sum * sum * sum); - Gtemp += comp_Array[f].getx() * Gmatrix[p][f] * tauMatrix[p][f] - * Gmatrix[this.getComponentNumber()][f] / (sum * sum); - } - dlngammadn[p] = (dAdn / B - A / (B * B) * dBdn) + dEdn / Ctemp - Dtemp - - Etemp * Gmatrix[this.getComponentNumber()][p] / (Ctemp * Ctemp) - + 2.0 * Ftemp - Gtemp;// E/(C*C)*dCdn[p]*(tau2-D/C) - // + - // E/C*(-dDdn[p]/C - // + - // D/(C*C)*dCdn[p]); - dlngammadn[p] /= (nt); - } - // System.out.println("Dlngamdn: " + dlngammadn[p] + " x: " + - // comp_Array[p].getx()+ " length: "); + for (int p = 0; p < numberOfComponents; p++) { + dAdn = tauMatrix[p][this.getComponentNumber()] * Gmatrix[p][this.getComponentNumber()]; + dBdn = Gmatrix[p][this.getComponentNumber()]; + dEdn = Gmatrix[this.getComponentNumber()][p] * tauMatrix[this.getComponentNumber()][p]; + // dFdn = Gmatrix[this.getComponentNumber()][p]; + Dtemp = 0; + Ctemp = 0; + Etemp = 0; + Ftemp = 0; + Gtemp = 0; + double nt = 0; + for (int f = 0; f < numberOfComponents; f++) { + nt += comp_Array[f].getNumberOfMolesInPhase(); + Ctemp += comp_Array[f].getx() * Gmatrix[f][p]; + Etemp += comp_Array[f].getx() * Gmatrix[f][p] * tauMatrix[f][p]; + double sum = 0.0; + double sum2 = 0.0; + for (int g = 0; g < numberOfComponents; g++) { + sum += comp_Array[g].getx() * Gmatrix[g][f]; + sum2 += comp_Array[g].getx() * Gmatrix[g][f] * tauMatrix[g][f]; + } + Dtemp += Gmatrix[p][f] * Gmatrix[this.getComponentNumber()][f] + * tauMatrix[this.getComponentNumber()][f] * comp_Array[f].getx() / (sum * sum); + Ftemp += comp_Array[f].getx() * Gmatrix[p][f] * sum2 + * Gmatrix[this.getComponentNumber()][f] / (sum * sum * sum); + Gtemp += comp_Array[f].getx() * Gmatrix[p][f] * tauMatrix[p][f] + * Gmatrix[this.getComponentNumber()][f] / (sum * sum); } - - return gamma; + dlngammadn[p] = (dAdn / B - A / (B * B) * dBdn) + dEdn / Ctemp - Dtemp + - Etemp * Gmatrix[this.getComponentNumber()][p] / (Ctemp * Ctemp) + 2.0 * Ftemp - Gtemp; // E/(C*C)*dCdn[p]*(tau2-D/C) + // + + // E/C*(-dDdn[p]/C + // + + // D/(C*C)*dCdn[p]); + dlngammadn[p] /= (nt); + } + // System.out.println("Dlngamdn: " + dlngammadn[p] + " x: " + + // comp_Array[p].getx()+ " length: "); } + + return gamma; + } } diff --git a/src/main/java/neqsim/thermo/component/ComponentGEUniquacmodifiedHV.java b/src/main/java/neqsim/thermo/component/ComponentGEUniquacmodifiedHV.java index 1fa41715ee..0e8a70beb0 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGEUniquacmodifiedHV.java +++ b/src/main/java/neqsim/thermo/component/ComponentGEUniquacmodifiedHV.java @@ -13,32 +13,32 @@ * @author Even Solbraa */ abstract class ComponentGEUniquacmodifiedHV extends ComponentGEUniquac { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * Constructor for ComponentGEUniquacmodifiedHV. - *

- * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int - */ - public ComponentGEUniquacmodifiedHV(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); - } + /** + *

+ * Constructor for ComponentGEUniquacmodifiedHV. + *

+ * + * @param component_name a {@link java.lang.String} object + * @param moles a double + * @param molesInPhase a double + * @param compnumber a int + */ + public ComponentGEUniquacmodifiedHV(String component_name, double moles, double molesInPhase, + int compnumber) { + super(component_name, moles, molesInPhase, compnumber); + } - /** {@inheritDoc} */ - @Override - public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype) { + /** {@inheritDoc} */ + @Override + public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, + double pressure, int phasetype) { - // PhaseGEInterface phaseny = (PhaseGEInterface) phase.getPhase(); - // PhaseGEInterface GEPhase = phaseny.getGEphase(); + // PhaseGEInterface phaseny = (PhaseGEInterface) phase.getPhase(); + // PhaseGEInterface GEPhase = phaseny.getGEphase(); - return 1;// super.getGamma(GEPhase, numberOfComponents, temperature, pressure, - // phasetype); - } + return 1; // super.getGamma(GEPhase, numberOfComponents, temperature, pressure, + // phasetype); + } } diff --git a/src/main/java/neqsim/thermo/component/ComponentGEWilson.java b/src/main/java/neqsim/thermo/component/ComponentGEWilson.java index 814cf2ec87..e02cc8276d 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGEWilson.java +++ b/src/main/java/neqsim/thermo/component/ComponentGEWilson.java @@ -114,7 +114,7 @@ public double getWilsonActivityCoefficient(PhaseInterface phase1) { public double getCharEnergyParamter(PhaseInterface phase1, int comp1, int comp2) { double param1 = 0.0; // ((ComponentWaxWilson) // phase1.getComponent(comp1)).getWilsonInteractionEnergy(phase1); - double param2 = 0.0;// ((ComponentWaxWilson) + double param2 = 0.0; // ((ComponentWaxWilson) // phase1.getComponent(comp2)).getWilsonInteractionEnergy(phase1); if (comp1 == comp2) { return 1.0; diff --git a/src/main/java/neqsim/thermo/component/ComponentGeDuanSun.java b/src/main/java/neqsim/thermo/component/ComponentGeDuanSun.java index f83f9ce9f4..7cbe28c8df 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGeDuanSun.java +++ b/src/main/java/neqsim/thermo/component/ComponentGeDuanSun.java @@ -12,536 +12,552 @@ * @version $Id: $Id */ public class ComponentGeDuanSun extends ComponentGE { - private static final long serialVersionUID = 1000; - - double r = 0, q = 0; - - /** - *

- * Constructor for ComponentGeDuanSun. - *

- * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int - */ - public ComponentGeDuanSun(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); - } - - /** {@inheritDoc} */ - @Override - public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype, double[][] HValpha, double[][] HVgij, - double[][] intparam, String[][] mixRule) { - return getGamma(phase, numberOfComponents, temperature, pressure, phasetype, HValpha, - HVgij); - } - - /** - *

- * getGammaNRTL. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComponents a int - * @param temperature a double - * @param pressure a double - * @param phasetype a int - * @param HValpha an array of {@link double} objects - * @param HVgij an array of {@link double} objects - * @return a double - */ - public double getGammaNRTL(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype, double[][] HValpha, double[][] HVgij) { - double type = phase.getInitType(); - // double ny = 0, Djj = 0, Dii = 0, gij = 0, gjj = 0, gji = 0, gii = 0, F2T = 0, tot2 = 0; - double A = 0, B = 0, C = 0, D = 0, E = 0, F = 0, tau = 0, tau2 = 0, G = 0, G2 = 0, - alpha = 0, Dij = 0, Dji = 0; - // int i, k, delta = 0; - int j, l = 0; - - double dAdT = 0, dBdT = 0, dCdT = 0, dDdT = 0; - // double dEdT, dFdT = 0; - double dtaudt = 0, dtau2dt = 0, dGdt = 0, dG2dt = 0; - double[][] Gmatrix = new double[numberOfComponents][numberOfComponents]; - double[][] tauMatrix = new double[numberOfComponents][numberOfComponents]; - dlngammadn = new double[numberOfComponents]; - ComponentInterface[] comp_Array = phase.getcomponentArray(); - // double lngammaold = 0, dlngammadtold = 0; - double dA2dTetter = 0, dA3dTetter = 0, dA4dTetter = 0, dA5dTetter = 0, dA6dTetter = 0; - // for(int w=0;w<3;w++){ - F = 0; - dBdT = 0; - dAdT = 0; - dDdT = 0; - A = 0; - B = 0; - dlngammadt = 0.0; - dA2dTetter = 0; - dA3dTetter = 0; - dA4dTetter = 0; - dA5dTetter = 0; - dA6dTetter = 0; - double dA2dT = 0, dA3dT = 0, dA4dT = 0, dA5dT = 0, dA6dT = 0; - - // PhaseGEEosInterface phaseny = (PhaseGEEosInterface) phase.getPhase(); - // PhaseGEInterface GEPhase = phaseny.getGEphase(); - - // ComponentGeNRTLInterface[] compArray = (ComponentGeNRTLInterface[]) - // GEPhase.getcomponentArray(); - // PhaseGEInterface GEphase = new PhaseGEInterface(); - // PhaseGEInterface phaseny = (PhaseGEInterface) phase.getPhase(); - - for (j = 0; j < numberOfComponents; j++) { - Dij = HVgij[this.getComponentNumber()][j]; - Dji = HVgij[j][this.getComponentNumber()]; - // gji = HVgij[j][this.getComponentNumber()]; - // gjj = HVgii[j][j]; - alpha = HValpha[j][this.getComponentNumber()]; - tau = Dji / (temperature); - tau2 = Dij / (temperature); - dtaudt = -tau / temperature; - dtau2dt = -tau2 / temperature; - // System.out.println("method GE1" + tau); - - // System.out.println("error in NRTL here ......"); - G = Math.exp(-alpha * tau);// comp_Array[j].getb()*Math.exp(-alpha*tau); - dGdt = dtaudt * -alpha * G; - G2 = Math.exp(-alpha * tau2);// comp_Array[this.getComponentNumber()].getb()*Math.exp(-alpha*tau2); - dG2dt = dtau2dt * -alpha * G2; - - A += tau * G * comp_Array[j].getx(); - dAdT = dAdT + comp_Array[j].getx() * dGdt * tau + comp_Array[j].getx() * G * dtaudt; - dA2dT = comp_Array[j].getx() * dG2dt * tau2 + comp_Array[j].getx() * G2 * dtau2dt; - dA3dT = tau2 * G2 * comp_Array[j].getx(); - dA4dT = 2 * comp_Array[j].getx() * G2; - dA5dT = comp_Array[j].getx() * dG2dt; - dA6dT = comp_Array[j].getx() * G2; - B += G * comp_Array[j].getx(); - dBdT += dGdt * comp_Array[j].getx(); - E = G2 * comp_Array[j].getx(); - // dEdT = dG2dt * comp_Array[j].getx(); - - C = 0; - D = 0; - dCdT = 0; - dDdT = 0; - // System.out.println("hei"); - - for (l = 0; l < numberOfComponents; l++) { - Dij = HVgij[l][j]; - alpha = HValpha[l][j]; - tau = Dij / (temperature); - dtaudt = -tau / temperature; - - // System.out.println("error in NRTL comp here...."); - G = Math.exp(-alpha * tau);// comp_Array[l].getb()*Math.exp(-alpha*tau); - dGdt = dtaudt * -alpha * G; - Gmatrix[l][j] = G; - tauMatrix[l][j] = tau; - - C += G * comp_Array[l].getx(); - dCdT += dGdt * comp_Array[l].getx(); - D += G * tau * comp_Array[l].getx(); - dDdT += comp_Array[l].getx() * dGdt * tau + comp_Array[l].getx() * G * dtaudt; - } - dA2dTetter += dA2dT / C; - dA3dTetter += dA3dT * dCdT / (C * C); - - dA4dTetter += dA4dT * dCdT * D / (C * C * C); - dA5dTetter += dA5dT * D / (C * C); - dA6dTetter += dA6dT * dDdT / (C * C); - - tau2 = HVgij[this.getComponentNumber()][j] / (temperature); - dtau2dt = -tau2 / temperature; - - F += E / C * (tau2 - D / C); - // dFdT += (dEdT / C - E / (C * C) * dCdT) * (tau2 - D / C) + E / C * (dtau2dt - (dDdT / - // C - D / (C * C) * dCdT)); - // F2T = F2T - 2*2*A/Math.pow(C,2) + 2*2*E*D/Math.pow(C,3); // A til A2; - } - - lngamma = A / B + F; - // dlngammadt = dAdT/B - A/(B*B)*dBdT + dFdT; - dlngammadt = (dAdT / B - A / (B * B) * dBdT + dA2dTetter - dA3dTetter + dA4dTetter - - dA5dTetter - dA6dTetter); - /* - * if(w==0){ dlngammadtold = dlngammadt; temperature +=0.0001; } - * - * if(w==1){ lngammaold = lngamma; temperature -=0.0002; } } - */ - // System.out.println("deriv: " + lngammaold + " " + lngamma + " " + - // ((lngammaold-lngamma)/0.0002) + " " + dlngammadtold); - // System.out.println("deriv t : " +dlngammadt); - - // tot2 = -2*A/B/B + F2T; - // dlngammadt = (lngammaold-lngamma)/0.002; - - // phaseny.getExessGibbsEnergy(numberOfComponents, temperature, pressure, - // phasetype) - gamma = Math.exp(lngamma); - // System.out.println("gamma " +gamma); - // if derivates.... - if (type == 3) { - double dAdn = 0; - double dBdn = 0; - double Etemp = 0; - double dEdn = 0; - double Ctemp = 0; - double Dtemp = 0; - double Ftemp = 0; - double Gtemp = 0; - - for (int p = 0; p < numberOfComponents; p++) { - dAdn = tauMatrix[p][this.getComponentNumber()] - * Gmatrix[p][this.getComponentNumber()]; - dBdn = Gmatrix[p][this.getComponentNumber()]; - dEdn = Gmatrix[this.getComponentNumber()][p] - * tauMatrix[this.getComponentNumber()][p]; - // dFdn = Gmatrix[this.getComponentNumber()][p]; - Dtemp = 0; - Ctemp = 0; - Etemp = 0; - Ftemp = 0; - Gtemp = 0; - double nt = 0; - for (int f = 0; f < numberOfComponents; f++) { - nt += comp_Array[f].getNumberOfMolesInPhase(); - Ctemp += comp_Array[f].getx() * Gmatrix[f][p]; - Etemp += comp_Array[f].getx() * Gmatrix[f][p] * tauMatrix[f][p]; - double sum = 0.0; - double sum2 = 0.0; - for (int g = 0; g < numberOfComponents; g++) { - sum += comp_Array[g].getx() * Gmatrix[g][f]; - sum2 += comp_Array[g].getx() * Gmatrix[g][f] * tauMatrix[g][f]; - } - Dtemp += Gmatrix[p][f] * Gmatrix[this.getComponentNumber()][f] - * tauMatrix[this.getComponentNumber()][f] * comp_Array[f].getx() - / (sum * sum); - Ftemp += comp_Array[f].getx() * Gmatrix[p][f] * sum2 - * Gmatrix[this.getComponentNumber()][f] / (sum * sum * sum); - Gtemp += comp_Array[f].getx() * Gmatrix[p][f] * tauMatrix[p][f] - * Gmatrix[this.getComponentNumber()][f] / (sum * sum); - } - dlngammadn[p] = (dAdn / B - A / (B * B) * dBdn) + dEdn / Ctemp - Dtemp - - Etemp * Gmatrix[this.getComponentNumber()][p] / (Ctemp * Ctemp) - + 2.0 * Ftemp - Gtemp;// E/(C*C)*dCdn[p]*(tau2-D/C) - // + - // E/C*(-dDdn[p]/C - // + - // D/(C*C)*dCdn[p]); - dlngammadn[p] /= (nt); - } - // System.out.println("Dlngamdn: " + dlngammadn[p] + " x: " + - // comp_Array[p].getx()+ " length: "); - } - - return gamma; - } - - /** - *

- * getGamma. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComponents a int - * @param temperature a double - * @param pressure a double - * @param phasetype a int - * @param HValpha an array of {@link double} objects - * @param HVgij an array of {@link double} objects - * @return a double - */ - public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype, double[][] HValpha, double[][] HVgij) { - if (componentName.equals("CO2")) { - return 0.9; - } else if (componentName.equals("water")) { - return 1.0; - } else { - return 1.0; - } + private static final long serialVersionUID = 1000; + + double r = 0; + + double q = 0; + + /** + *

+ * Constructor for ComponentGeDuanSun. + *

+ * + * @param component_name a {@link java.lang.String} object + * @param moles a double + * @param molesInPhase a double + * @param compnumber a int + */ + public ComponentGeDuanSun(String component_name, double moles, double molesInPhase, + int compnumber) { + super(component_name, moles, molesInPhase, compnumber); + } + + /** {@inheritDoc} */ + @Override + public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, + double pressure, int phasetype, double[][] HValpha, double[][] HVgij, double[][] intparam, + String[][] mixRule) { + return getGamma(phase, numberOfComponents, temperature, pressure, phasetype, HValpha, HVgij); + } + + /** + *

+ * getGammaNRTL. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComponents a int + * @param temperature a double + * @param pressure a double + * @param phasetype a int + * @param HValpha an array of {@link double} objects + * @param HVgij an array of {@link double} objects + * @return a double + */ + public double getGammaNRTL(PhaseInterface phase, int numberOfComponents, double temperature, + double pressure, int phasetype, double[][] HValpha, double[][] HVgij) { + double type = phase.getInitType(); + // double ny = 0, Djj = 0, Dii = 0, gij = 0, gjj = 0, gji = 0, gii = 0, F2T = 0, tot2 = 0; + double A = 0; + double B = 0; + double C = 0; + double D = 0; + double E = 0; + double F = 0; + double tau = 0; + double tau2 = 0; + double G = 0; + double G2 = 0; + double alpha = 0; + double Dij = 0; + double Dji = 0; + // int i, k, delta = 0; + int j; + + int l = 0; + double dAdT = 0; + double dBdT = 0; + double dCdT = 0; + double dDdT = 0; + // double dEdT, dFdT = 0; + double dtaudt = 0; + double dtau2dt = 0; + double dGdt = 0; + double dG2dt = 0; + double[][] Gmatrix = new double[numberOfComponents][numberOfComponents]; + double[][] tauMatrix = new double[numberOfComponents][numberOfComponents]; + dlngammadn = new double[numberOfComponents]; + ComponentInterface[] comp_Array = phase.getcomponentArray(); + // double lngammaold = 0, dlngammadtold = 0; + double dA2dTetter = 0; + double dA3dTetter = 0; + double dA4dTetter = 0; + double dA5dTetter = 0; + double dA6dTetter = 0; + // for(int w=0;w<3;w++){ + F = 0; + dBdT = 0; + dAdT = 0; + dDdT = 0; + A = 0; + B = 0; + dlngammadt = 0.0; + dA2dTetter = 0; + dA3dTetter = 0; + dA4dTetter = 0; + dA5dTetter = 0; + dA6dTetter = 0; + double dA2dT = 0; + + // PhaseGEEosInterface phaseny = (PhaseGEEosInterface) phase.getPhase(); + // PhaseGEInterface GEPhase = phaseny.getGEphase(); + + // ComponentGeNRTLInterface[] compArray = (ComponentGeNRTLInterface[]) + // GEPhase.getcomponentArray(); + // PhaseGEInterface GEphase = new PhaseGEInterface(); + // PhaseGEInterface phaseny = (PhaseGEInterface) phase.getPhase(); + + double dA3dT = 0; + double dA4dT = 0; + double dA5dT = 0; + double dA6dT = 0; + for (j = 0; j < numberOfComponents; j++) { + Dij = HVgij[this.getComponentNumber()][j]; + Dji = HVgij[j][this.getComponentNumber()]; + // gji = HVgij[j][this.getComponentNumber()]; + // gjj = HVgii[j][j]; + alpha = HValpha[j][this.getComponentNumber()]; + tau = Dji / (temperature); + tau2 = Dij / (temperature); + dtaudt = -tau / temperature; + dtau2dt = -tau2 / temperature; + // System.out.println("method GE1" + tau); + + // System.out.println("error in NRTL here ......"); + G = Math.exp(-alpha * tau); // comp_Array[j].getb()*Math.exp(-alpha*tau); + dGdt = dtaudt * -alpha * G; + G2 = Math.exp(-alpha * tau2); // comp_Array[this.getComponentNumber()].getb()*Math.exp(-alpha*tau2); + dG2dt = dtau2dt * -alpha * G2; + + A += tau * G * comp_Array[j].getx(); + dAdT = dAdT + comp_Array[j].getx() * dGdt * tau + comp_Array[j].getx() * G * dtaudt; + dA2dT = comp_Array[j].getx() * dG2dt * tau2 + comp_Array[j].getx() * G2 * dtau2dt; + dA3dT = tau2 * G2 * comp_Array[j].getx(); + dA4dT = 2 * comp_Array[j].getx() * G2; + dA5dT = comp_Array[j].getx() * dG2dt; + dA6dT = comp_Array[j].getx() * G2; + B += G * comp_Array[j].getx(); + dBdT += dGdt * comp_Array[j].getx(); + E = G2 * comp_Array[j].getx(); + // dEdT = dG2dt * comp_Array[j].getx(); + + C = 0; + D = 0; + dCdT = 0; + dDdT = 0; + // System.out.println("hei"); + + for (l = 0; l < numberOfComponents; l++) { + Dij = HVgij[l][j]; + alpha = HValpha[l][j]; + tau = Dij / (temperature); + dtaudt = -tau / temperature; + + // System.out.println("error in NRTL comp here...."); + G = Math.exp(-alpha * tau); // comp_Array[l].getb()*Math.exp(-alpha*tau); + dGdt = dtaudt * -alpha * G; + Gmatrix[l][j] = G; + tauMatrix[l][j] = tau; + + C += G * comp_Array[l].getx(); + dCdT += dGdt * comp_Array[l].getx(); + D += G * tau * comp_Array[l].getx(); + dDdT += comp_Array[l].getx() * dGdt * tau + comp_Array[l].getx() * G * dtaudt; + } + dA2dTetter += dA2dT / C; + dA3dTetter += dA3dT * dCdT / (C * C); + + dA4dTetter += dA4dT * dCdT * D / (C * C * C); + dA5dTetter += dA5dT * D / (C * C); + dA6dTetter += dA6dT * dDdT / (C * C); + + tau2 = HVgij[this.getComponentNumber()][j] / (temperature); + dtau2dt = -tau2 / temperature; + + F += E / C * (tau2 - D / C); + // dFdT += (dEdT / C - E / (C * C) * dCdT) * (tau2 - D / C) + E / C * (dtau2dt - (dDdT / + // C - D / (C * C) * dCdT)); + // F2T = F2T - 2*2*A/Math.pow(C,2) + 2*2*E*D/Math.pow(C,3); // A til A2; } + lngamma = A / B + F; + // dlngammadt = dAdT/B - A/(B*B)*dBdT + dFdT; + dlngammadt = (dAdT / B - A / (B * B) * dBdT + dA2dTetter - dA3dTetter + dA4dTetter - dA5dTetter + - dA6dTetter); /* - * public double getHenryCoef(double temperature) { // System.out.println("henry " + // - * Math.exp(henryCoefParameter[0]+henryCoefParameter[1]/temperature+ - * henryCoefParameter[2]*Math.log(temperature)+henryCoefParameter[3]*temperature )*100*0.01802); - * if (componentName.equals("CO2")) { // return } return super.getHenryCoef(temperature); + * if(w==0){ dlngammadtold = dlngammadt; temperature +=0.0001; } * - * } + * if(w==1){ lngammaold = lngamma; temperature -=0.0002; } } */ - - /** {@inheritDoc} */ - @Override - public double fugcoef(PhaseInterface phase) { - logger.info("fug coef " - + gamma * getAntoineVaporPressure(phase.getTemperature()) / phase.getPressure()); - if (referenceStateType.equals("solvent")) { - fugacityCoefficient = - gamma * getAntoineVaporPressure(phase.getTemperature()) / phase.getPressure(); - gammaRefCor = gamma; - } else { - double activinf = 1.0; - if (phase.hasComponent("water")) { - int waternumb = phase.getComponent("water").getComponentNumber(); - activinf = gamma / ((PhaseGE) phase) - .getActivityCoefficientInfDilWater(componentNumber, waternumb); - } else { - activinf = gamma / ((PhaseGE) phase).getActivityCoefficientInfDil(componentNumber); - } - // activinf = gamma / ((PhaseGE) phase).getActivityCoefficientInfDil(componentNumber); - - // Born function - double BORN = 0.0; - double EPS = 0.0; - double EPS1000 = 0.0; - double CB = 0.0; - double BB = 0.0; - EPS1000 = 3.4279 * Math.pow(10.0, 2.0) - * Math.exp((-5.0866 * Math.pow(10.0, -3.0) * phase.getTemperature() + 9.469 - * Math.pow(10.0, -7.0) * Math.pow(phase.getTemperature(), 2.0))); - CB = -2.0525 + 3.1159 * Math.pow(10.0, 3.0) - / (phase.getTemperature() - 1.8289 * Math.pow(10.0, 2.0)); - BB = -8.0325 * Math.pow(10.0, -3.0) - + 4.21452 * Math.pow(10.0, 6.0) / phase.getTemperature() - + 2.1417 * phase.getTemperature(); - EPS = EPS1000 + CB * Math.log((BB + phase.getPressure()) / BB + 1000.0); - BORN = (1.0 / EPS) * (CB / ((phase.getPressure() + BB) - * (CB * Math.log((phase.getPressure() + BB) / (BB + 1000.0)) + EPS))); - - // Average partial molar volume - double Vm[] = {0.0, 0.0, 0.0}; - Vm[0] = 41.84 - * (0.1 * 7.29 - + (100 * 0.92) / (2600 + phase.getPressure()) + 2.07 - / (phase.getTemperature() - 288.0) - - 1.23 * Math.pow(10.0, 4.0) / ((2600 + phase.getPressure()) - * (phase.getTemperature() - 288.0)) - + 1.6 * BORN); - Vm[1] = 41.84 * (0.1 * 7.0); - Vm[2] = 41.84 - * (0.1 * 5.7889 - + (100 * 6.3536) / (2600 + phase.getPressure()) + 3.2528 - / (phase.getTemperature() - 288.0) - - 3.0417 * Math.pow(10.0, 4.0) / ((2600 + phase.getPressure()) - * (phase.getTemperature() - 288.0)) - + 0.3943 * BORN); - - double Poynteff[] = {0.0, 0.0, 0.0}; - Poynteff[0] = Vm[0] * (phase.getPressure() - 1.0) - / (1000.0 * (R / 100.0) * phase.getTemperature()); - Poynteff[1] = Vm[1] * (phase.getPressure() - 1.0) - / (1000.0 * (R / 100.0) * phase.getTemperature()); - Poynteff[2] = Vm[2] * (phase.getPressure() - 1.0) - / (1000.0 * (R / 100.0) * phase.getTemperature()); - - double K[] = {0.0, 0.0, 0.0, 0.0}; - double a1 = 0.0; - double a2 = 0.0; - double a3 = 0.0; - double a4 = 0.0; - double a5 = 0.0; - double a6 = 0.0; - double a7 = 0.0; - double ACO20 = -10.52624; - double ACO21 = 2.3547 * Math.pow(10.0, -2.0); - double ACO22 = 3972.8; - double ACO23 = 0.0; - double ACO24 = -5.8746 * Math.pow(10.0, 5.0); - double ACO25 = -1.9194 * Math.pow(10.0, -5.0); - double AN20 = 58.453; - double AN21 = -1.818 * Math.pow(10.0, -3.0); - double AN22 = -3199.0; - double AN23 = -17.909; - double AN24 = 27460.0; - double AN25 = 0.0; - double AO20 = 7.5001; - double AO21 = -7.8981 * Math.pow(10.0, -3.0); - double AO22 = 0.0; - double AO23 = 0.0; - double AO24 = -2.0027 * Math.pow(10.0, 5.0); - double AO25 = 0.0; - - if (phase.getTemperature() <= 373.15) { - a1 = 9.31063597; - a2 = -1.892867005 * Math.pow(10.0, -1.0); - a3 = 1.307135652 * Math.pow(10.0, -3.0); - a4 = -3.800223763 * Math.pow(10.0, -6.0); - a5 = 4.0091369717 * Math.pow(10.0, -9.0); - a6 = 2.2769246863 * Math.pow(10.0, 1.0); - a7 = -1.1291330188 * Math.pow(10.0, -2.0); - } else { - a1 = -9.0283127 * Math.pow(10.0, -1.0); - a2 = 3.6492938 * Math.pow(10.0, -2.0); - a3 = 4.3610019 * Math.pow(10.0, -4.0); - a4 = -3.10936036 * Math.pow(10.0, -6.0); - a5 = 4.592053 * Math.pow(10.0, -9.0); - a6 = 1.62996873 * Math.pow(10.0, 1.0); - a7 = 2.81119409 * Math.pow(10.0, -2.0); - } - - K[0] = Math.pow(10.0, - (ACO20 + ACO21 * phase.getTemperature() + ACO22 / phase.getTemperature() - + ACO23 * Math.log10(phase.getTemperature()) - + ACO24 / (Math.pow(phase.getTemperature(), 2.0)) - + ACO25 * Math.pow(phase.getTemperature(), 2.0))) - * Math.exp(Poynteff[0]); - K[1] = Math.pow(10.0, - (AN20 + AN21 * phase.getTemperature() + AN22 / phase.getTemperature() - + AN23 * Math.log10(phase.getTemperature()) - + AN24 / (Math.pow(phase.getTemperature(), 2.0)) - + AN25 * Math.pow(phase.getTemperature(), 2.0))) - * Math.exp(Poynteff[1]); - K[2] = Math.pow(10.0, - (AO20 + AO21 * phase.getTemperature() + AO22 / phase.getTemperature() - + AO23 * Math.log10(phase.getTemperature()) - + AO24 / (Math.pow(phase.getTemperature(), 2.0)) - + AO25 * Math.pow(phase.getTemperature(), 2.0))) - * Math.exp(Poynteff[2]); - K[3] = (a1 + a2 * phase.getTemperature() + a3 * Math.pow(phase.getTemperature(), 2.0) - + a4 * Math.pow(phase.getTemperature(), 3.0) - + a5 * Math.pow(phase.getTemperature(), 4.0)) - * Math.exp((phase.getPressure() - 1.0) * (a6 + a7 * phase.getTemperature()) - / (1000.0 * (R / 100.0) * phase.getTemperature())); - - if (componentName.equals("CO2")) { - fugacityCoefficient = - activinf * K[0] * gamma * (1000 / 18.02) / phase.getPressure();// +25.689/(gamma*K[0]))/ - // phase.getPressure(); - } else if (componentName.equals("nitrogen")) { - fugacityCoefficient = - activinf * K[1] * gamma * (1000 / 18.02) / phase.getPressure();// +50.585/(gamma*K[1]))/ - // phase.getPressure(); - } else if (componentName.equals("oxygen")) { - fugacityCoefficient = - activinf * K[2] * gamma * (1000 / 18.02) / phase.getPressure();// +46.9157/(gamma*K[2]))/ - // phase.getPressure(); - } else if (componentName.contentEquals("water")) { - fugacityCoefficient = activinf * K[3] * (1000 / 18.02) / phase.getPressure(); - } else { - fugacityCoefficient = activinf * K[3] / phase.getPressure(); - } - // fugacityCoefficient = activinf * getHenryCoef(phase.getTemperature()) / - // phase.getPressure();//gamma* benyttes ikke - gammaRefCor = activinf; + // System.out.println("deriv: " + lngammaold + " " + lngamma + " " + + // ((lngammaold-lngamma)/0.0002) + " " + dlngammadtold); + // System.out.println("deriv t : " +dlngammadt); + + // tot2 = -2*A/B/B + F2T; + // dlngammadt = (lngammaold-lngamma)/0.002; + + // phaseny.getExessGibbsEnergy(numberOfComponents, temperature, pressure, + // phasetype) + gamma = Math.exp(lngamma); + // System.out.println("gamma " +gamma); + // if derivates.... + if (type == 3) { + double dAdn = 0; + double dBdn = 0; + double Etemp = 0; + double dEdn = 0; + double Ctemp = 0; + double Dtemp = 0; + double Ftemp = 0; + double Gtemp = 0; + + for (int p = 0; p < numberOfComponents; p++) { + dAdn = tauMatrix[p][this.getComponentNumber()] * Gmatrix[p][this.getComponentNumber()]; + dBdn = Gmatrix[p][this.getComponentNumber()]; + dEdn = Gmatrix[this.getComponentNumber()][p] * tauMatrix[this.getComponentNumber()][p]; + // dFdn = Gmatrix[this.getComponentNumber()][p]; + Dtemp = 0; + Ctemp = 0; + Etemp = 0; + Ftemp = 0; + Gtemp = 0; + double nt = 0; + for (int f = 0; f < numberOfComponents; f++) { + nt += comp_Array[f].getNumberOfMolesInPhase(); + Ctemp += comp_Array[f].getx() * Gmatrix[f][p]; + Etemp += comp_Array[f].getx() * Gmatrix[f][p] * tauMatrix[f][p]; + double sum = 0.0; + double sum2 = 0.0; + for (int g = 0; g < numberOfComponents; g++) { + sum += comp_Array[g].getx() * Gmatrix[g][f]; + sum2 += comp_Array[g].getx() * Gmatrix[g][f] * tauMatrix[g][f]; + } + Dtemp += Gmatrix[p][f] * Gmatrix[this.getComponentNumber()][f] + * tauMatrix[this.getComponentNumber()][f] * comp_Array[f].getx() / (sum * sum); + Ftemp += comp_Array[f].getx() * Gmatrix[p][f] * sum2 + * Gmatrix[this.getComponentNumber()][f] / (sum * sum * sum); + Gtemp += comp_Array[f].getx() * Gmatrix[p][f] * tauMatrix[p][f] + * Gmatrix[this.getComponentNumber()][f] / (sum * sum); } - logFugacityCoefficient = Math.log(fugacityCoefficient); - return fugacityCoefficient; + dlngammadn[p] = (dAdn / B - A / (B * B) * dBdn) + dEdn / Ctemp - Dtemp + - Etemp * Gmatrix[this.getComponentNumber()][p] / (Ctemp * Ctemp) + 2.0 * Ftemp - Gtemp; // E/(C*C)*dCdn[p]*(tau2-D/C) + // + + // E/C*(-dDdn[p]/C + // + + // D/(C*C)*dCdn[p]); + dlngammadn[p] /= (nt); + } + // System.out.println("Dlngamdn: " + dlngammadn[p] + " x: " + + // comp_Array[p].getx()+ " length: "); } - ///////////////////////////////////////////////////// - /** - *

- * getGammaPitzer. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComponents a int - * @param temperature a double - * @param pressure a double - * @param phasetype a int - * @param salinity a double - * @return a double - */ - public double getGammaPitzer(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype, double salinity) { - double P = pressure; - double T = temperature; - double S = salinity; - // double salinity2=0; - - // if(isIsIon()) { - // salinity2=getNumberOfMolesInPhase()/(phase.getComponent("water").getNumberOfMolesInPhase()*phase.getComponent("water").getMolarMass()); - // } - - // double S=salinity; - double lamdaCO2Na = (-0.411370585 + 0.000607632 * T + 97.5347708 / T - 0.023762247 * P / T - + 0.017065624 * P / (630.0 - T) - + 1.41335834 * Math.pow(10.0, -5.0) * T * Math.log(P)); - double lamdaN2Na = -2.4434074 + 0.0036351795 * T + 447.47364 / T - 0.000013711527 * P - + 0.0000071037217 * Math.pow(P, 2.0) / T; - double lamdaO2Na = 0.19997; - double zetaN2NaCl = -0.58071053 * Math.pow(10.0, -2.0); - double zetaO2NaCl = -1.2793 * Math.pow(10.0, -2.0); - double zetaCO2NaCl = 0.00033639 - 1.9829898 * Math.pow(10.0, -5.0) * T + 0.002122208 * P / T - - 0.005248733 * P / (630. - T); - - if (componentName.equals("CO2")) { - gamma = Math.exp(2.0 * S * lamdaCO2Na + Math.pow(S, 2.0) * zetaCO2NaCl); - } else if (componentName.equals("nitrogen")) { - gamma = Math.exp(2.0 * S * lamdaN2Na + Math.pow(S, 2.0) * zetaN2NaCl); - } else if (componentName.equals("oxygen")) { - gamma = Math.exp(2.0 * S * lamdaO2Na + Math.pow(S, 2.0) * zetaO2NaCl); - } else { - gamma = 1.0; - } - - // double gammaCO2=Math.exp(2.0*S*lamdaCO2Na+Math.pow(S,2.0)*zetaCO2NaCl); - // double gammaN2=Math.exp(2.0*S*lamdaN2Na+Math.pow(S,2.0)*zetaN2NaCl); - // double gammaO2=Math.exp(2.0*S*lamdaO2Na+Math.pow(S,2.0)*zetaO2NaCl); - // gamma=1.0; - - lngamma = Math.log(gamma); - - // System.out.println("gamma CO2 = " + gammaCO2); - // System.out.println("gamma N2 = " + gammaN2); - // System.out.println("gamma O2 = " + gammaO2); - - // if (componentName.equals("CO2")) { - // return gammaCO2; - // }else if (componentName.equals("nitrogen")) { - // return gammaN2; - // }else if (componentName.equals("oxygen")) { - // return gammaO2; - // }else - return gamma; + return gamma; + } + + /** + *

+ * getGamma. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComponents a int + * @param temperature a double + * @param pressure a double + * @param phasetype a int + * @param HValpha an array of {@link double} objects + * @param HVgij an array of {@link double} objects + * @return a double + */ + public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, + double pressure, int phasetype, double[][] HValpha, double[][] HVgij) { + if (componentName.equals("CO2")) { + return 0.9; + } else if (componentName.equals("water")) { + return 1.0; + } else { + return 1.0; } - ///////////////////////////////////////////////////// - /* - * public double fugcoefDiffPres(PhaseInterface phase, int numberOfComponents, double - * temperature, double pressure, int phasetype){ dfugdp = (Math.log(fugcoef(phase, - * numberOfComponents, temperature, pressure+0.01, phasetype))-Math.log(fugcoef(phase, - * numberOfComponents, temperature, pressure-0.01, phasetype)))/0.02; return dfugdp; } - * - * public double fugcoefDiffTemp(PhaseInterface phase, int numberOfComponents, double - * temperature, double pressure, int phasetype){ dfugdt = (Math.log(fugcoef(phase, - * numberOfComponents, temperature+0.01, pressure, phasetype))-Math.log(fugcoef(phase, - * numberOfComponents, temperature-0.01, pressure, phasetype)))/0.02; return dfugdt; } - */ - - /** - *

- * Getter for the field r. - *

- * - * @return a double - */ - public double getr() { - return r; + } + + /* + * public double getHenryCoef(double temperature) { // System.out.println("henry " + // + * Math.exp(henryCoefParameter[0]+henryCoefParameter[1]/temperature+ + * henryCoefParameter[2]*Math.log(temperature)+henryCoefParameter[3]*temperature )*100*0.01802); + * if (componentName.equals("CO2")) { // return } return super.getHenryCoef(temperature); + * + * } + */ + + /** {@inheritDoc} */ + @Override + public double fugcoef(PhaseInterface phase) { + logger.info("fug coef " + + gamma * getAntoineVaporPressure(phase.getTemperature()) / phase.getPressure()); + if (referenceStateType.equals("solvent")) { + fugacityCoefficient = + gamma * getAntoineVaporPressure(phase.getTemperature()) / phase.getPressure(); + gammaRefCor = gamma; + } else { + double activinf = 1.0; + if (phase.hasComponent("water")) { + int waternumb = phase.getComponent("water").getComponentNumber(); + activinf = + gamma / ((PhaseGE) phase).getActivityCoefficientInfDilWater(componentNumber, waternumb); + } else { + activinf = gamma / ((PhaseGE) phase).getActivityCoefficientInfDil(componentNumber); + } + // activinf = gamma / ((PhaseGE) phase).getActivityCoefficientInfDil(componentNumber); + + // Born function + double BORN = 0.0; + double EPS = 0.0; + double EPS1000 = 0.0; + double CB = 0.0; + double BB = 0.0; + EPS1000 = 3.4279 * Math.pow(10.0, 2.0) + * Math.exp((-5.0866 * Math.pow(10.0, -3.0) * phase.getTemperature() + + 9.469 * Math.pow(10.0, -7.0) * Math.pow(phase.getTemperature(), 2.0))); + CB = -2.0525 + + 3.1159 * Math.pow(10.0, 3.0) / (phase.getTemperature() - 1.8289 * Math.pow(10.0, 2.0)); + BB = -8.0325 * Math.pow(10.0, -3.0) + 4.21452 * Math.pow(10.0, 6.0) / phase.getTemperature() + + 2.1417 * phase.getTemperature(); + EPS = EPS1000 + CB * Math.log((BB + phase.getPressure()) / BB + 1000.0); + BORN = (1.0 / EPS) * (CB / ((phase.getPressure() + BB) + * (CB * Math.log((phase.getPressure() + BB) / (BB + 1000.0)) + EPS))); + + // Average partial molar volume + double[] Vm = {0.0, 0.0, 0.0}; + Vm[0] = + 41.84 + * (0.1 * 7.29 + (100 * 0.92) / (2600 + phase.getPressure()) + + 2.07 / (phase.getTemperature() - 288.0) + - 1.23 * Math.pow(10.0, 4.0) + / ((2600 + phase.getPressure()) * (phase.getTemperature() - 288.0)) + + 1.6 * BORN); + Vm[1] = 41.84 * (0.1 * 7.0); + Vm[2] = + 41.84 * (0.1 * 5.7889 + (100 * 6.3536) / (2600 + phase.getPressure()) + + 3.2528 / (phase.getTemperature() - 288.0) + - 3.0417 * Math.pow(10.0, 4.0) + / ((2600 + phase.getPressure()) * (phase.getTemperature() - 288.0)) + + 0.3943 * BORN); + + double[] Poynteff = {0.0, 0.0, 0.0}; + Poynteff[0] = + Vm[0] * (phase.getPressure() - 1.0) / (1000.0 * (R / 100.0) * phase.getTemperature()); + Poynteff[1] = + Vm[1] * (phase.getPressure() - 1.0) / (1000.0 * (R / 100.0) * phase.getTemperature()); + Poynteff[2] = + Vm[2] * (phase.getPressure() - 1.0) / (1000.0 * (R / 100.0) * phase.getTemperature()); + + double[] K = {0.0, 0.0, 0.0, 0.0}; + double a1 = 0.0; + double a2 = 0.0; + double a3 = 0.0; + double a4 = 0.0; + double a5 = 0.0; + double a6 = 0.0; + double a7 = 0.0; + double ACO20 = -10.52624; + double ACO21 = 2.3547 * Math.pow(10.0, -2.0); + double ACO22 = 3972.8; + double ACO23 = 0.0; + double ACO24 = -5.8746 * Math.pow(10.0, 5.0); + double ACO25 = -1.9194 * Math.pow(10.0, -5.0); + double AN20 = 58.453; + double AN21 = -1.818 * Math.pow(10.0, -3.0); + double AN22 = -3199.0; + double AN23 = -17.909; + double AN24 = 27460.0; + double AN25 = 0.0; + double AO20 = 7.5001; + double AO21 = -7.8981 * Math.pow(10.0, -3.0); + double AO22 = 0.0; + double AO23 = 0.0; + double AO24 = -2.0027 * Math.pow(10.0, 5.0); + double AO25 = 0.0; + + if (phase.getTemperature() <= 373.15) { + a1 = 9.31063597; + a2 = -1.892867005 * Math.pow(10.0, -1.0); + a3 = 1.307135652 * Math.pow(10.0, -3.0); + a4 = -3.800223763 * Math.pow(10.0, -6.0); + a5 = 4.0091369717 * Math.pow(10.0, -9.0); + a6 = 2.2769246863 * Math.pow(10.0, 1.0); + a7 = -1.1291330188 * Math.pow(10.0, -2.0); + } else { + a1 = -9.0283127 * Math.pow(10.0, -1.0); + a2 = 3.6492938 * Math.pow(10.0, -2.0); + a3 = 4.3610019 * Math.pow(10.0, -4.0); + a4 = -3.10936036 * Math.pow(10.0, -6.0); + a5 = 4.592053 * Math.pow(10.0, -9.0); + a6 = 1.62996873 * Math.pow(10.0, 1.0); + a7 = 2.81119409 * Math.pow(10.0, -2.0); + } + + K[0] = Math.pow(10.0, + (ACO20 + ACO21 * phase.getTemperature() + ACO22 / phase.getTemperature() + + ACO23 * Math.log10(phase.getTemperature()) + + ACO24 / (Math.pow(phase.getTemperature(), 2.0)) + + ACO25 * Math.pow(phase.getTemperature(), 2.0))) + * Math.exp(Poynteff[0]); + K[1] = Math.pow(10.0, + (AN20 + AN21 * phase.getTemperature() + AN22 / phase.getTemperature() + + AN23 * Math.log10(phase.getTemperature()) + + AN24 / (Math.pow(phase.getTemperature(), 2.0)) + + AN25 * Math.pow(phase.getTemperature(), 2.0))) + * Math.exp(Poynteff[1]); + K[2] = Math.pow(10.0, + (AO20 + AO21 * phase.getTemperature() + AO22 / phase.getTemperature() + + AO23 * Math.log10(phase.getTemperature()) + + AO24 / (Math.pow(phase.getTemperature(), 2.0)) + + AO25 * Math.pow(phase.getTemperature(), 2.0))) + * Math.exp(Poynteff[2]); + K[3] = (a1 + a2 * phase.getTemperature() + a3 * Math.pow(phase.getTemperature(), 2.0) + + a4 * Math.pow(phase.getTemperature(), 3.0) + a5 * Math.pow(phase.getTemperature(), 4.0)) + * Math.exp((phase.getPressure() - 1.0) * (a6 + a7 * phase.getTemperature()) + / (1000.0 * (R / 100.0) * phase.getTemperature())); + + if (componentName.equals("CO2")) { + fugacityCoefficient = activinf * K[0] * gamma * (1000 / 18.02) / phase.getPressure(); // +25.689/(gamma*K[0]))/ + // phase.getPressure(); + } else if (componentName.equals("nitrogen")) { + fugacityCoefficient = activinf * K[1] * gamma * (1000 / 18.02) / phase.getPressure(); // +50.585/(gamma*K[1]))/ + // phase.getPressure(); + } else if (componentName.equals("oxygen")) { + fugacityCoefficient = activinf * K[2] * gamma * (1000 / 18.02) / phase.getPressure(); // +46.9157/(gamma*K[2]))/ + // phase.getPressure(); + } else if (componentName.contentEquals("water")) { + fugacityCoefficient = activinf * K[3] * (1000 / 18.02) / phase.getPressure(); + } else { + fugacityCoefficient = activinf * K[3] / phase.getPressure(); + } + // fugacityCoefficient = activinf * getHenryCoef(phase.getTemperature()) / + // phase.getPressure(); //gamma* benyttes ikke + gammaRefCor = activinf; } - - /** - *

- * Getter for the field q. - *

- * - * @return a double - */ - public double getq() { - return q; + logFugacityCoefficient = Math.log(fugacityCoefficient); + return fugacityCoefficient; + } + + ///////////////////////////////////////////////////// + /** + *

+ * getGammaPitzer. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComponents a int + * @param temperature a double + * @param pressure a double + * @param phasetype a int + * @param salinity a double + * @return a double + */ + public double getGammaPitzer(PhaseInterface phase, int numberOfComponents, double temperature, + double pressure, int phasetype, double salinity) { + double P = pressure; + double T = temperature; + double S = salinity; + // double salinity2=0; + + // if(isIsIon()) { + // salinity2=getNumberOfMolesInPhase()/(phase.getComponent("water").getNumberOfMolesInPhase()*phase.getComponent("water").getMolarMass()); + // } + + // double S=salinity; + double lamdaCO2Na = (-0.411370585 + 0.000607632 * T + 97.5347708 / T - 0.023762247 * P / T + + 0.017065624 * P / (630.0 - T) + 1.41335834 * Math.pow(10.0, -5.0) * T * Math.log(P)); + double lamdaN2Na = -2.4434074 + 0.0036351795 * T + 447.47364 / T - 0.000013711527 * P + + 0.0000071037217 * Math.pow(P, 2.0) / T; + double lamdaO2Na = 0.19997; + double zetaN2NaCl = -0.58071053 * Math.pow(10.0, -2.0); + double zetaO2NaCl = -1.2793 * Math.pow(10.0, -2.0); + double zetaCO2NaCl = 0.00033639 - 1.9829898 * Math.pow(10.0, -5.0) * T + 0.002122208 * P / T + - 0.005248733 * P / (630. - T); + + if (componentName.equals("CO2")) { + gamma = Math.exp(2.0 * S * lamdaCO2Na + Math.pow(S, 2.0) * zetaCO2NaCl); + } else if (componentName.equals("nitrogen")) { + gamma = Math.exp(2.0 * S * lamdaN2Na + Math.pow(S, 2.0) * zetaN2NaCl); + } else if (componentName.equals("oxygen")) { + gamma = Math.exp(2.0 * S * lamdaO2Na + Math.pow(S, 2.0) * zetaO2NaCl); + } else { + gamma = 1.0; } - /** - * Getter for property lngamma. - * - * @return Value of property lngamma. - */ - public double getLngamma() { - return lngamma; - } + // double gammaCO2=Math.exp(2.0*S*lamdaCO2Na+Math.pow(S,2.0)*zetaCO2NaCl); + // double gammaN2=Math.exp(2.0*S*lamdaN2Na+Math.pow(S,2.0)*zetaN2NaCl); + // double gammaO2=Math.exp(2.0*S*lamdaO2Na+Math.pow(S,2.0)*zetaO2NaCl); + // gamma=1.0; + + lngamma = Math.log(gamma); + + // System.out.println("gamma CO2 = " + gammaCO2); + // System.out.println("gamma N2 = " + gammaN2); + // System.out.println("gamma O2 = " + gammaO2); + + // if (componentName.equals("CO2")) { + // return gammaCO2; + // }else if (componentName.equals("nitrogen")) { + // return gammaN2; + // }else if (componentName.equals("oxygen")) { + // return gammaO2; + // }else + return gamma; + } + ///////////////////////////////////////////////////// + /* + * public double fugcoefDiffPres(PhaseInterface phase, int numberOfComponents, double temperature, + * double pressure, int phasetype){ dfugdp = (Math.log(fugcoef(phase, numberOfComponents, + * temperature, pressure+0.01, phasetype))-Math.log(fugcoef(phase, numberOfComponents, + * temperature, pressure-0.01, phasetype)))/0.02; return dfugdp; } + * + * public double fugcoefDiffTemp(PhaseInterface phase, int numberOfComponents, double temperature, + * double pressure, int phasetype){ dfugdt = (Math.log(fugcoef(phase, numberOfComponents, + * temperature+0.01, pressure, phasetype))-Math.log(fugcoef(phase, numberOfComponents, + * temperature-0.01, pressure, phasetype)))/0.02; return dfugdt; } + */ + + /** + *

+ * Getter for the field r. + *

+ * + * @return a double + */ + public double getr() { + return r; + } + + /** + *

+ * Getter for the field q. + *

+ * + * @return a double + */ + public double getq() { + return q; + } + + /** + * Getter for property lngamma. + * + * @return Value of property lngamma. + */ + public double getLngamma() { + return lngamma; + } } diff --git a/src/main/java/neqsim/thermo/component/ComponentGeNRTL.java b/src/main/java/neqsim/thermo/component/ComponentGeNRTL.java index 5fc90541f8..21eb95f8b4 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGeNRTL.java +++ b/src/main/java/neqsim/thermo/component/ComponentGeNRTL.java @@ -11,255 +11,292 @@ * @version $Id: $Id */ public class ComponentGeNRTL extends ComponentGE { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - double r = 0, q = 0; + double r = 0; - /** - *

- * Constructor for ComponentGeNRTL. - *

- * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int - */ - public ComponentGeNRTL(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); - } - - /** {@inheritDoc} */ - @Override - @SuppressWarnings("unused") - public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype, double[][] HValpha, double[][] HVgij, - double[][] intparam, String[][] mixRule) { - double type = phase.getInitType(); - double A = 0, B = 0, C = 0, D = 0, E = 0, F = 0, ny = 0, tau = 0, tau2 = 0, G = 0, G2 = 0, - alpha = 0, Dij = 0, Djj = 0, Dji = 0, Dii = 0, gij = 0, gjj = 0, gji = 0, gii = 0, - F2T = 0, tot2 = 0; - int i, j, l, k, delta = 0; - double dAdT = 0, dBdT = 0, dEdT, dCdT = 0, dFdT = 0, dDdT = 0; - double dtaudt = 0, dtau2dt = 0, dGdt = 0, dG2dt = 0; - double[][] Gmatrix = new double[numberOfComponents][numberOfComponents]; - double[][] tauMatrix = new double[numberOfComponents][numberOfComponents]; - dlngammadn = new double[numberOfComponents]; - ComponentInterface[] comp_Array = phase.getcomponentArray(); - double lngammaold = 0, dlngammadtold = 0, dA2dTetter = 0, dA3dTetter = 0, dA4dTetter = 0, - dA5dTetter = 0, dA6dTetter = 0; - // for(int w=0;w<3;w++){ - F = 0; - dFdT = 0; - dBdT = 0; - dAdT = 0; - dDdT = 0; - A = 0; - B = 0; - dlngammadt = 0.0; - dA2dTetter = 0; - dA3dTetter = 0; - dA4dTetter = 0; - dA5dTetter = 0; - dA6dTetter = 0; - double dA2dT = 0, dA3dT = 0, dA4dT = 0, dA5dT = 0, dA6dT = 0; - - // PhaseGEEosInterface phaseny = (PhaseGEEosInterface) phase.getPhase(); - // PhaseGEInterface GEPhase = phaseny.getGEphase(); - - // ComponentGeNRTLInterface[] compArray = (ComponentGeNRTLInterface[]) - // GEPhase.getcomponentArray(); - // PhaseGEInterface GEphase = new PhaseGEInterface(); - // PhaseGEInterface phaseny = (PhaseGEInterface) phase.getPhase(); + double q = 0; - for (j = 0; j < numberOfComponents; j++) { - Dij = HVgij[this.getComponentNumber()][j]; - Dji = HVgij[j][this.getComponentNumber()]; - // gji = HVgij[j][this.getComponentNumber()]; - // gjj = HVgii[j][j]; - alpha = HValpha[j][this.getComponentNumber()]; - tau = Dji / (temperature); - tau2 = Dij / (temperature); - dtaudt = -tau / temperature; - dtau2dt = -tau2 / temperature; - // System.out.println("method GE1" + tau); + /** + *

+ * Constructor for ComponentGeNRTL. + *

+ * + * @param component_name a {@link java.lang.String} object + * @param moles a double + * @param molesInPhase a double + * @param compnumber a int + */ + public ComponentGeNRTL(String component_name, double moles, double molesInPhase, int compnumber) { + super(component_name, moles, molesInPhase, compnumber); + } - // System.out.println("error in NRTL here ......"); - G = Math.exp(-alpha * tau);// comp_Array[j].getb()*Math.exp(-alpha*tau); - dGdt = dtaudt * -alpha * G; - G2 = Math.exp(-alpha * tau2);// comp_Array[this.getComponentNumber()].getb()*Math.exp(-alpha*tau2); - dG2dt = dtau2dt * -alpha * G2; + /** {@inheritDoc} */ + @Override + @SuppressWarnings("unused") + public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, + double pressure, int phasetype, double[][] HValpha, double[][] HVgij, double[][] intparam, + String[][] mixRule) { + double type = phase.getInitType(); + double A = 0; + double B = 0; + double C = 0; + double D = 0; + double E = 0; + double F = 0; + double ny = 0; + double tau = 0; + double tau2 = 0; + double G = 0; + double G2 = 0; + double alpha = 0; + double Dij = 0; + double Djj = 0; + double Dji = 0; + double Dii = 0; + double gij = 0; + double gjj = 0; + double gji = 0; + double gii = 0; + double F2T = 0; + double tot2 = 0; + int i; + int j; + int l; + int k; + int delta = 0; + double dAdT = 0; + double dBdT = 0; + double dEdT; + double dCdT = 0; + double dFdT = 0; + double dDdT = 0; + double dtaudt = 0; + double dtau2dt = 0; + double dGdt = 0; + double dG2dt = 0; + double[][] Gmatrix = new double[numberOfComponents][numberOfComponents]; + double[][] tauMatrix = new double[numberOfComponents][numberOfComponents]; + dlngammadn = new double[numberOfComponents]; + ComponentInterface[] comp_Array = phase.getcomponentArray(); + double lngammaold = 0; + double dlngammadtold = 0; + double dA2dTetter = 0; + double dA3dTetter = 0; + double dA4dTetter = 0; + double dA5dTetter = 0; + double dA6dTetter = 0; + // for(int w=0;w<3;w++){ + F = 0; + dFdT = 0; + dBdT = 0; + dAdT = 0; + dDdT = 0; + A = 0; + B = 0; + dlngammadt = 0.0; + dA2dTetter = 0; + dA3dTetter = 0; + dA4dTetter = 0; + dA5dTetter = 0; + dA6dTetter = 0; + double dA2dT = 0; - A += tau * G * comp_Array[j].getx(); - dAdT = dAdT + comp_Array[j].getx() * dGdt * tau + comp_Array[j].getx() * G * dtaudt; - dA2dT = comp_Array[j].getx() * dG2dt * tau2 + comp_Array[j].getx() * G2 * dtau2dt; - dA3dT = tau2 * G2 * comp_Array[j].getx(); - dA4dT = 2 * comp_Array[j].getx() * G2; - dA5dT = comp_Array[j].getx() * dG2dt; - dA6dT = comp_Array[j].getx() * G2; - B += G * comp_Array[j].getx(); - dBdT += dGdt * comp_Array[j].getx(); - E = G2 * comp_Array[j].getx(); - dEdT = dG2dt * comp_Array[j].getx(); + // PhaseGEEosInterface phaseny = (PhaseGEEosInterface) phase.getPhase(); + // PhaseGEInterface GEPhase = phaseny.getGEphase(); - C = 0; - D = 0; - dCdT = 0; - dDdT = 0; - // System.out.println("hei"); + // ComponentGeNRTLInterface[] compArray = (ComponentGeNRTLInterface[]) + // GEPhase.getcomponentArray(); + // PhaseGEInterface GEphase = new PhaseGEInterface(); + // PhaseGEInterface phaseny = (PhaseGEInterface) phase.getPhase(); - for (l = 0; l < numberOfComponents; l++) { - Dij = HVgij[l][j]; - alpha = HValpha[l][j]; - tau = Dij / (temperature); - dtaudt = -tau / temperature; + double dA3dT = 0; + double dA4dT = 0; + double dA5dT = 0; + double dA6dT = 0; + for (j = 0; j < numberOfComponents; j++) { + Dij = HVgij[this.getComponentNumber()][j]; + Dji = HVgij[j][this.getComponentNumber()]; + // gji = HVgij[j][this.getComponentNumber()]; + // gjj = HVgii[j][j]; + alpha = HValpha[j][this.getComponentNumber()]; + tau = Dji / (temperature); + tau2 = Dij / (temperature); + dtaudt = -tau / temperature; + dtau2dt = -tau2 / temperature; + // System.out.println("method GE1" + tau); - // System.out.println("error in NRTL comp here...."); - G = Math.exp(-alpha * tau);// comp_Array[l].getb()*Math.exp(-alpha*tau); - dGdt = dtaudt * -alpha * G; - Gmatrix[l][j] = G; - tauMatrix[l][j] = tau; + // System.out.println("error in NRTL here ......"); + G = Math.exp(-alpha * tau); // comp_Array[j].getb()*Math.exp(-alpha*tau); + dGdt = dtaudt * -alpha * G; + G2 = Math.exp(-alpha * tau2); // comp_Array[this.getComponentNumber()].getb()*Math.exp(-alpha*tau2); + dG2dt = dtau2dt * -alpha * G2; - C += G * comp_Array[l].getx(); - dCdT += dGdt * comp_Array[l].getx(); - D += G * tau * comp_Array[l].getx(); - dDdT += comp_Array[l].getx() * dGdt * tau + comp_Array[l].getx() * G * dtaudt; - } - dA2dTetter += dA2dT / C; - dA3dTetter += dA3dT * dCdT / (C * C); + A += tau * G * comp_Array[j].getx(); + dAdT = dAdT + comp_Array[j].getx() * dGdt * tau + comp_Array[j].getx() * G * dtaudt; + dA2dT = comp_Array[j].getx() * dG2dt * tau2 + comp_Array[j].getx() * G2 * dtau2dt; + dA3dT = tau2 * G2 * comp_Array[j].getx(); + dA4dT = 2 * comp_Array[j].getx() * G2; + dA5dT = comp_Array[j].getx() * dG2dt; + dA6dT = comp_Array[j].getx() * G2; + B += G * comp_Array[j].getx(); + dBdT += dGdt * comp_Array[j].getx(); + E = G2 * comp_Array[j].getx(); + dEdT = dG2dt * comp_Array[j].getx(); - dA4dTetter += dA4dT * dCdT * D / (C * C * C); - dA5dTetter += dA5dT * D / (C * C); - dA6dTetter += dA6dT * dDdT / (C * C); + C = 0; + D = 0; + dCdT = 0; + dDdT = 0; + // System.out.println("hei"); - tau2 = HVgij[this.getComponentNumber()][j] / (temperature); - dtau2dt = -tau2 / temperature; + for (l = 0; l < numberOfComponents; l++) { + Dij = HVgij[l][j]; + alpha = HValpha[l][j]; + tau = Dij / (temperature); + dtaudt = -tau / temperature; - F += E / C * (tau2 - D / C); - dFdT += (dEdT / C - E / (C * C) * dCdT) * (tau2 - D / C) - + E / C * (dtau2dt - (dDdT / C - D / (C * C) * dCdT)); - // F2T = F2T - 2*2*A/Math.pow(C,2) + 2*2*E*D/Math.pow(C,3); // A til A2; - } - - lngamma = A / B + F; - // dlngammadt = dAdT/B - A/(B*B)*dBdT + dFdT; - dlngammadt = (dAdT / B - A / (B * B) * dBdT + dA2dTetter - dA3dTetter + dA4dTetter - - dA5dTetter - dA6dTetter); - /* - * if(w==0){ dlngammadtold = dlngammadt; temperature +=0.0001; } - * - * if(w==1){ lngammaold = lngamma; temperature -=0.0002; } } - */ - // System.out.println("deriv: " + lngammaold + " " + lngamma + " " + - // ((lngammaold-lngamma)/0.0002) + " " + dlngammadtold); - // System.out.println("deriv t : " +dlngammadt); + // System.out.println("error in NRTL comp here...."); + G = Math.exp(-alpha * tau); // comp_Array[l].getb()*Math.exp(-alpha*tau); + dGdt = dtaudt * -alpha * G; + Gmatrix[l][j] = G; + tauMatrix[l][j] = tau; - // tot2 = -2*A/B/B + F2T; - // dlngammadt = (lngammaold-lngamma)/0.002; + C += G * comp_Array[l].getx(); + dCdT += dGdt * comp_Array[l].getx(); + D += G * tau * comp_Array[l].getx(); + dDdT += comp_Array[l].getx() * dGdt * tau + comp_Array[l].getx() * G * dtaudt; + } + dA2dTetter += dA2dT / C; + dA3dTetter += dA3dT * dCdT / (C * C); - // phaseny.getExessGibbsEnergy(numberOfComponents, temperature, pressure, - // phasetype) - gamma = Math.exp(lngamma); - // System.out.println("gamma " +gamma); - // if derivates.... - if (type == 3) { - double dAdn = 0; - double dBdn = 0; - double Etemp = 0; - double dEdn = 0; - double Ctemp = 0; - double Dtemp = 0; - double Ftemp = 0; - double Gtemp = 0; + dA4dTetter += dA4dT * dCdT * D / (C * C * C); + dA5dTetter += dA5dT * D / (C * C); + dA6dTetter += dA6dT * dDdT / (C * C); - for (int p = 0; p < numberOfComponents; p++) { - dAdn = tauMatrix[p][this.getComponentNumber()] - * Gmatrix[p][this.getComponentNumber()]; - dBdn = Gmatrix[p][this.getComponentNumber()]; - dEdn = Gmatrix[this.getComponentNumber()][p] - * tauMatrix[this.getComponentNumber()][p]; - // dFdn = Gmatrix[this.getComponentNumber()][p]; - Dtemp = 0; - Ctemp = 0; - Etemp = 0; - Ftemp = 0; - Gtemp = 0; - double nt = 0; - for (int f = 0; f < numberOfComponents; f++) { - nt += comp_Array[f].getNumberOfMolesInPhase(); - Ctemp += comp_Array[f].getx() * Gmatrix[f][p]; - Etemp += comp_Array[f].getx() * Gmatrix[f][p] * tauMatrix[f][p]; - double sum = 0.0; - double sum2 = 0.0; - for (int g = 0; g < numberOfComponents; g++) { - sum += comp_Array[g].getx() * Gmatrix[g][f]; - sum2 += comp_Array[g].getx() * Gmatrix[g][f] * tauMatrix[g][f]; - } - Dtemp += Gmatrix[p][f] * Gmatrix[this.getComponentNumber()][f] - * tauMatrix[this.getComponentNumber()][f] * comp_Array[f].getx() - / (sum * sum); - Ftemp += comp_Array[f].getx() * Gmatrix[p][f] * sum2 - * Gmatrix[this.getComponentNumber()][f] / (sum * sum * sum); - Gtemp += comp_Array[f].getx() * Gmatrix[p][f] * tauMatrix[p][f] - * Gmatrix[this.getComponentNumber()][f] / (sum * sum); - } - dlngammadn[p] = (dAdn / B - A / (B * B) * dBdn) + dEdn / Ctemp - Dtemp - - Etemp * Gmatrix[this.getComponentNumber()][p] / (Ctemp * Ctemp) - + 2.0 * Ftemp - Gtemp;// E/(C*C)*dCdn[p]*(tau2-D/C) - // + - // E/C*(-dDdn[p]/C - // + - // D/(C*C)*dCdn[p]); - dlngammadn[p] /= (nt); - } - // System.out.println("Dlngamdn: " + dlngammadn[p] + " x: " + - // comp_Array[p].getx()+ " length: "); - } + tau2 = HVgij[this.getComponentNumber()][j] / (temperature); + dtau2dt = -tau2 / temperature; - return gamma; + F += E / C * (tau2 - D / C); + dFdT += (dEdT / C - E / (C * C) * dCdT) * (tau2 - D / C) + + E / C * (dtau2dt - (dDdT / C - D / (C * C) * dCdT)); + // F2T = F2T - 2*2*A/Math.pow(C,2) + 2*2*E*D/Math.pow(C,3); // A til A2; } + lngamma = A / B + F; + // dlngammadt = dAdT/B - A/(B*B)*dBdT + dFdT; + dlngammadt = (dAdT / B - A / (B * B) * dBdT + dA2dTetter - dA3dTetter + dA4dTetter - dA5dTetter + - dA6dTetter); /* - * public double fugcoefDiffPres(PhaseInterface phase, int numberOfComponents, double - * temperature, double pressure, int phasetype){ dfugdp = (Math.log(fugcoef(phase, - * numberOfComponents, temperature, pressure+0.01, phasetype))-Math.log(fugcoef(phase, - * numberOfComponents, temperature, pressure-0.01, phasetype)))/0.02; return dfugdp; } + * if(w==0){ dlngammadtold = dlngammadt; temperature +=0.0001; } * - * public double fugcoefDiffTemp(PhaseInterface phase, int numberOfComponents, double - * temperature, double pressure, int phasetype){ dfugdt = (Math.log(fugcoef(phase, - * numberOfComponents, temperature+0.01, pressure, phasetype))-Math.log(fugcoef(phase, - * numberOfComponents, temperature-0.01, pressure, phasetype)))/0.02; return dfugdt; } + * if(w==1){ lngammaold = lngamma; temperature -=0.0002; } } */ + // System.out.println("deriv: " + lngammaold + " " + lngamma + " " + + // ((lngammaold-lngamma)/0.0002) + " " + dlngammadtold); + // System.out.println("deriv t : " +dlngammadt); - /** - *

- * Getter for the field r. - *

- * - * @return a double - */ - public double getr() { - return r; - } + // tot2 = -2*A/B/B + F2T; + // dlngammadt = (lngammaold-lngamma)/0.002; - /** - *

- * Getter for the field q. - *

- * - * @return a double - */ - public double getq() { - return q; - } + // phaseny.getExessGibbsEnergy(numberOfComponents, temperature, pressure, + // phasetype) + gamma = Math.exp(lngamma); + // System.out.println("gamma " +gamma); + // if derivates.... + if (type == 3) { + double dAdn = 0; + double dBdn = 0; + double Etemp = 0; + double dEdn = 0; + double Ctemp = 0; + double Dtemp = 0; + double Ftemp = 0; + double Gtemp = 0; - /** - * Getter for property lngamma. - * - * @return Value of property lngamma. - */ - public double getLngamma() { - return lngamma; + for (int p = 0; p < numberOfComponents; p++) { + dAdn = tauMatrix[p][this.getComponentNumber()] * Gmatrix[p][this.getComponentNumber()]; + dBdn = Gmatrix[p][this.getComponentNumber()]; + dEdn = Gmatrix[this.getComponentNumber()][p] * tauMatrix[this.getComponentNumber()][p]; + // dFdn = Gmatrix[this.getComponentNumber()][p]; + Dtemp = 0; + Ctemp = 0; + Etemp = 0; + Ftemp = 0; + Gtemp = 0; + double nt = 0; + for (int f = 0; f < numberOfComponents; f++) { + nt += comp_Array[f].getNumberOfMolesInPhase(); + Ctemp += comp_Array[f].getx() * Gmatrix[f][p]; + Etemp += comp_Array[f].getx() * Gmatrix[f][p] * tauMatrix[f][p]; + double sum = 0.0; + double sum2 = 0.0; + for (int g = 0; g < numberOfComponents; g++) { + sum += comp_Array[g].getx() * Gmatrix[g][f]; + sum2 += comp_Array[g].getx() * Gmatrix[g][f] * tauMatrix[g][f]; + } + Dtemp += Gmatrix[p][f] * Gmatrix[this.getComponentNumber()][f] + * tauMatrix[this.getComponentNumber()][f] * comp_Array[f].getx() / (sum * sum); + Ftemp += comp_Array[f].getx() * Gmatrix[p][f] * sum2 + * Gmatrix[this.getComponentNumber()][f] / (sum * sum * sum); + Gtemp += comp_Array[f].getx() * Gmatrix[p][f] * tauMatrix[p][f] + * Gmatrix[this.getComponentNumber()][f] / (sum * sum); + } + dlngammadn[p] = (dAdn / B - A / (B * B) * dBdn) + dEdn / Ctemp - Dtemp + - Etemp * Gmatrix[this.getComponentNumber()][p] / (Ctemp * Ctemp) + 2.0 * Ftemp - Gtemp; // E/(C*C)*dCdn[p]*(tau2-D/C) + // + + // E/C*(-dDdn[p]/C + // + + // D/(C*C)*dCdn[p]); + dlngammadn[p] /= (nt); + } + // System.out.println("Dlngamdn: " + dlngammadn[p] + " x: " + + // comp_Array[p].getx()+ " length: "); } + + return gamma; + } + + /* + * public double fugcoefDiffPres(PhaseInterface phase, int numberOfComponents, double temperature, + * double pressure, int phasetype){ dfugdp = (Math.log(fugcoef(phase, numberOfComponents, + * temperature, pressure+0.01, phasetype))-Math.log(fugcoef(phase, numberOfComponents, + * temperature, pressure-0.01, phasetype)))/0.02; return dfugdp; } + * + * public double fugcoefDiffTemp(PhaseInterface phase, int numberOfComponents, double temperature, + * double pressure, int phasetype){ dfugdt = (Math.log(fugcoef(phase, numberOfComponents, + * temperature+0.01, pressure, phasetype))-Math.log(fugcoef(phase, numberOfComponents, + * temperature-0.01, pressure, phasetype)))/0.02; return dfugdt; } + */ + + /** + *

+ * Getter for the field r. + *

+ * + * @return a double + */ + public double getr() { + return r; + } + + /** + *

+ * Getter for the field q. + *

+ * + * @return a double + */ + public double getq() { + return q; + } + + /** + * Getter for property lngamma. + * + * @return Value of property lngamma. + */ + public double getLngamma() { + return lngamma; + } } diff --git a/src/main/java/neqsim/thermo/component/ComponentHydrate.java b/src/main/java/neqsim/thermo/component/ComponentHydrate.java index c7e9d95dfd..ad4cf7f094 100644 --- a/src/main/java/neqsim/thermo/component/ComponentHydrate.java +++ b/src/main/java/neqsim/thermo/component/ComponentHydrate.java @@ -14,719 +14,732 @@ * @version $Id: $Id */ public class ComponentHydrate extends Component { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(ComponentHydrate.class); - - // double emptyHydrateVapourPressureConstant[][] = {{17.6025820786, - // -6056.0650578668},{17.332, -6017.6}}; //fitted - double emptyHydrateVapourPressureConstant[][] = {{17.44, -6003.9}, {17.332, -6017.6}}; // Sloan - // (1990) - // double emptyHydrateVapourPressureConstant[][] = {{ 17.5061457754, - // -6030.6886435166},{17.332, -6017.6}}; //fitted (1990) - int hydrateStructure = 0; - double coordNumb[][] = new double[2][2]; // [structure][cavitytype] - double cavRadius[][] = new double[2][2]; // [structure][cavitytype] - double cavNumb[][] = new double[2][2]; // [structure][cavitytype] - double cavprwat[][] = new double[2][2]; // [structure][cavitytype] - // double[] dGfHydrate = {-236539.2, -235614.0}; - // double[] dHfHydrate = {-292714.5, -292016.0}; - double[] dGfHydrate = {-235557, -235614}; - double[] dHfHydrate = {-291786, -292016}; - double reffug[] = - new double[neqsim.thermo.ThermodynamicConstantsInterface.MAX_NUMBER_OF_COMPONENTS]; - private double sphericalCoreRadiusHydrate = 0.0; - private double lennardJonesEnergyParameterHydrate = 0.0; - private double lennardJonesMolecularDiameterHydrate = 0.0; - PhaseInterface refPhase = null; - - /** - *

- * Constructor for ComponentHydrate. - *

- * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int - */ - public ComponentHydrate(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); - coordNumb[0][0] = 20.0; - coordNumb[0][1] = 24.0; - cavRadius[0][0] = 3.95; - cavRadius[0][1] = 4.33; - cavNumb[0][0] = 2.0; - cavNumb[0][1] = 6.0; - cavprwat[0][0] = 1.0 / 23.0; - cavprwat[0][1] = 3.0 / 23.0; - - coordNumb[1][0] = 20.0; - coordNumb[1][1] = 28.0; - cavRadius[1][0] = 3.91; - cavRadius[1][1] = 4.73; - cavNumb[1][0] = 16.0; - cavNumb[1][1] = 8.0; - cavprwat[1][0] = 2.0 / 17.0; - cavprwat[1][1] = 1.0 / 17.0; - - reffug[0] = 10.0; - reffug[1] = 1.0; - - neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); - java.sql.ResultSet dataSet = null; + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(ComponentHydrate.class); + + // double emptyHydrateVapourPressureConstant[][] = {{17.6025820786, + // -6056.0650578668},{17.332, -6017.6}}; //fitted + double emptyHydrateVapourPressureConstant[][] = {{17.44, -6003.9}, {17.332, -6017.6}}; // Sloan + // (1990) + // double emptyHydrateVapourPressureConstant[][] = {{ 17.5061457754, + // -6030.6886435166},{17.332, -6017.6}}; //fitted (1990) + int hydrateStructure = 0; + double coordNumb[][] = new double[2][2]; // [structure][cavitytype] + double cavRadius[][] = new double[2][2]; // [structure][cavitytype] + double cavNumb[][] = new double[2][2]; // [structure][cavitytype] + double cavprwat[][] = new double[2][2]; // [structure][cavitytype] + // double[] dGfHydrate = {-236539.2, -235614.0}; + // double[] dHfHydrate = {-292714.5, -292016.0}; + double[] dGfHydrate = {-235557, -235614}; + double[] dHfHydrate = {-291786, -292016}; + double[] reffug = + new double[neqsim.thermo.ThermodynamicConstantsInterface.MAX_NUMBER_OF_COMPONENTS]; + private double sphericalCoreRadiusHydrate = 0.0; + private double lennardJonesEnergyParameterHydrate = 0.0; + private double lennardJonesMolecularDiameterHydrate = 0.0; + PhaseInterface refPhase = null; + + /** + *

+ * Constructor for ComponentHydrate. + *

+ * + * @param component_name a {@link java.lang.String} object + * @param moles a double + * @param molesInPhase a double + * @param compnumber a int + */ + public ComponentHydrate(String component_name, double moles, double molesInPhase, + int compnumber) { + super(component_name, moles, molesInPhase, compnumber); + coordNumb[0][0] = 20.0; + coordNumb[0][1] = 24.0; + cavRadius[0][0] = 3.95; + cavRadius[0][1] = 4.33; + cavNumb[0][0] = 2.0; + cavNumb[0][1] = 6.0; + cavprwat[0][0] = 1.0 / 23.0; + cavprwat[0][1] = 3.0 / 23.0; + + coordNumb[1][0] = 20.0; + coordNumb[1][1] = 28.0; + cavRadius[1][0] = 3.91; + cavRadius[1][1] = 4.73; + cavNumb[1][0] = 16.0; + cavNumb[1][1] = 8.0; + cavprwat[1][0] = 2.0 / 17.0; + cavprwat[1][1] = 1.0 / 17.0; + + reffug[0] = 10.0; + reffug[1] = 1.0; + + neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); + java.sql.ResultSet dataSet = null; + try { + if (!component_name.equals("default")) { try { - if (!component_name.equals("default")) { - try { - if (NeqSimDataBase.createTemporaryTables()) { - dataSet = database.getResultSet( - ("SELECT * FROM comptemp WHERE name='" + component_name + "'")); - } else { - dataSet = database.getResultSet( - ("SELECT * FROM comp WHERE name='" + component_name + "'")); - } - dataSet.next(); - dataSet.getString("FORMULA"); - } catch (Exception e) { - dataSet.close(); - logger.info("no parameters in tempcomp -- trying comp.. " + component_name); - dataSet = database.getResultSet( - ("SELECT * FROM comp WHERE name='" + component_name + "'")); - dataSet.next(); - } - lennardJonesMolecularDiameterHydrate = - Double.parseDouble(dataSet.getString("LJdiameterHYDRATE")); // BF - lennardJonesEnergyParameterHydrate = - Double.parseDouble(dataSet.getString("LJepsHYDRATE")); - sphericalCoreRadiusHydrate = - Double.parseDouble(dataSet.getString("SphericalCoreRadiusHYDRATE")); - } + if (NeqSimDataBase.createTemporaryTables()) { + dataSet = database + .getResultSet(("SELECT * FROM comptemp WHERE name='" + component_name + "'")); + } else { + dataSet = + database.getResultSet(("SELECT * FROM comp WHERE name='" + component_name + "'")); + } + dataSet.next(); + dataSet.getString("FORMULA"); } catch (Exception e) { - logger.error("error in comp", e); - } finally { - try { - if (dataSet != null) { - dataSet.close(); - } - if (database.getStatement() != null) { - database.getStatement().close(); - } - if (database.getConnection() != null) { - database.getConnection().close(); - } - } catch (Exception e) { - logger.error("error closing database.....", e); - } + dataSet.close(); + logger.info("no parameters in tempcomp -- trying comp.. " + component_name); + dataSet = + database.getResultSet(("SELECT * FROM comp WHERE name='" + component_name + "'")); + dataSet.next(); } - } - - /** - *

- * readHydrateParameters. - *

- */ - public void readHydrateParameters() {} - - /** {@inheritDoc} */ - @Override - public double fugcoef(PhaseInterface phase) { - return fugcoef(phase, phase.getNumberOfComponents(), phase.getTemperature(), - phase.getPressure()); - } - - /** - *

- * Setter for the field hydrateStructure. - *

- * - * @param structure a int - */ - public void setHydrateStructure(int structure) { - this.hydrateStructure = structure; - } - - /** - *

- * Getter for the field hydrateStructure. - *

- * - * @return a int - */ - public int getHydrateStructure() { - return this.hydrateStructure; - } - - /** - *

- * fugcoef. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComps a int - * @param temp a double - * @param pres a double - * @return a double - */ - public double fugcoef(PhaseInterface phase, int numberOfComps, double temp, double pres) { - if (componentName.equals("water")) { - fugacityCoefficient = -1e50; - double val = 1.0; - double tempy = 1.0; - double fugold = 0.0; - - do { - val = 0; - tempy = 0.0; - fugold = fugacityCoefficient; - if (hydrateStructure >= 0) { - for (int cavType = 0; cavType < 2; cavType++) { - tempy = 0.0; - for (int j = 0; j < phase.getNumberOfComponents(); j++) { - // System.out.println(phase.getComponent(j)); - tempy += ((ComponentHydrate) phase.getComponent(j)) - .calcYKI(hydrateStructure, cavType, phase); - // System.out.println("tempny " +tempy); - // System.out.println("temp ny " + this);//phase.getComponent(j)); - } - val += getCavprwat()[hydrateStructure][cavType] * Math.log(1.0 - tempy); - } - } - // System.out.println("val " +(val)); - // System.out.println("fugacityCoefficient bef " + fugacityCoefficient); - double solvol = 1.0 / 906.0 * getMolarMass(); - fugacityCoefficient = Math.exp(val) - * getEmptyHydrateStructureVapourPressure(hydrateStructure, temp) - * Math.exp(solvol / (R * temp) * ((pres - - getEmptyHydrateStructureVapourPressure(hydrateStructure, temp))) - * 1e5) - / pres; - // System.out.println("struct " + hydrateStruct + " fug " + tempfugcoef + " val - // "+ val); - - // fugacityCoefficient = - // Math.exp(val)*getEmptyHydrateStructureVapourPressure(hydrateStructure,temp)*Math.exp(solvol/(R*temp)*((pres-getEmptyHydrateStructureVapourPressure(hydrateStructure,temp)))*1e5)/pres; - // fugacityCoefficient = getAntoineVaporPressure(temp)/pres; - // logFugacityCoefficient = Math.log(fugacityCoefficient); - // logFugacityCoefficient += val*boltzmannConstant/R; - // fugacityCoefficient = Math.exp(logFugacityCoefficient); - // System.out.println("fugacityCoefficient " + fugacityCoefficient); - } while (Math.abs((fugacityCoefficient - fugold) / fugold) > 1e-6); - } else { - fugacityCoefficient = 1e5; + lennardJonesMolecularDiameterHydrate = + Double.parseDouble(dataSet.getString("LJdiameterHYDRATE")); // BF + lennardJonesEnergyParameterHydrate = Double.parseDouble(dataSet.getString("LJepsHYDRATE")); + sphericalCoreRadiusHydrate = + Double.parseDouble(dataSet.getString("SphericalCoreRadiusHYDRATE")); + } + } catch (Exception e) { + logger.error("error in comp", e); + } finally { + try { + if (dataSet != null) { + dataSet.close(); } - logFugacityCoefficient = Math.log(fugacityCoefficient); - // System.out.println("fug " + fugacityCoefficient); - return fugacityCoefficient; - } - - /** - *

- * getEmptyHydrateStructureVapourPressure. - *

- * - * @param type a int - * @param temperature a double - * @return a double - */ - public double getEmptyHydrateStructureVapourPressure(int type, double temperature) { - if (type == -1) { - return getSolidVaporPressure(temperature); - } else { - return Math - .exp(getEmptyHydrateVapourPressureConstant(type, 0) - + getEmptyHydrateVapourPressureConstant(type, 1) / temperature) - * 1.01325; + if (database.getStatement() != null) { + database.getStatement().close(); } - } - - /** - *

- * Setter for the field emptyHydrateVapourPressureConstant. - *

- * - * @param hydrateStructure a int - * @param parameterNumber a int - * @param value a double - */ - public void setEmptyHydrateVapourPressureConstant(int hydrateStructure, int parameterNumber, - double value) { - emptyHydrateVapourPressureConstant[hydrateStructure][parameterNumber] = value; - } - - /** - *

- * Getter for the field emptyHydrateVapourPressureConstant. - *

- * - * @param hydrateStructure a int - * @param parameterNumber a int - * @return a double - */ - public double getEmptyHydrateVapourPressureConstant(int hydrateStructure, int parameterNumber) { - return emptyHydrateVapourPressureConstant[hydrateStructure][parameterNumber]; - } - - /** - *

- * calcChemPotEmpty. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComps a int - * @param temp a double - * @param pres a double - * @param hydrateStruct a int - * @return a double - */ - public double calcChemPotEmpty(PhaseInterface phase, int numberOfComps, double temp, - double pres, int hydrateStruct) { - double dGf = 0.0, dHf = 0.0, Cpa = getCpA(), Cpb = getCpB(), Cpc = getCpC(), Cpd = getCpD(); - double deltaMolarVolume = 0.0; - if (hydrateStruct == 1) { - dGf = getDGfHydrate()[1]; - dHf = getDHfHydrate()[1]; - deltaMolarVolume = 5.0e-6; - } else { - dGf = getDGfHydrate()[0]; - dHf = getDHfHydrate()[0]; - deltaMolarVolume = 4.6e-6; + if (database.getConnection() != null) { + database.getConnection().close(); } - double T0 = 298.15; - - dHf += Cpa * (temp - T0) + Cpb * Math.log(temp / T0) - Cpc * (1.0 / temp - 1.0 / T0) - - 1.0 / 2.0 * Cpd * (1.0 / (temp * temp) - 1.0 / (T0 * T0)); - - return (dGf / R / T0 + 1.0 * dHf * (1.0 / R / temp - 1.0 / R / T0)) - + deltaMolarVolume / R / ((temp + T0) / 2.0) * (pres * 1e5 - 1e5); - } - - /** - *

- * calcChemPotIdealWater. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComps a int - * @param temp a double - * @param pres a double - * @param hydrateStruct a int - * @return a double - */ - public double calcChemPotIdealWater(PhaseInterface phase, int numberOfComps, double temp, - double pres, int hydrateStruct) { - double dGf = -228700.0, dHf = -242000.0, Cpa = getCpA(), Cpb = getCpB(), Cpc = getCpC(), - Cpd = getCpD(); - // Cpa = 0.7354; - // Cpb = 0.01418; - // Cpc = -1.727e-5; - double T0 = 298.15; - dHf += Cpa * (temp - T0) + Cpb * Math.log(temp / T0) - Cpc * (1.0 / temp - 1.0 / T0) - - 1.0 / 2.0 * Cpd * (1.0 / (temp * temp) - 1.0 / (T0 * T0)); - return (dGf / R / T0 + 1.0 * dHf * (1.0 / R / temp - 1.0 / R / T0)); - } - - /** - *

- * calcYKI. - *

- * - * @param stucture a int - * @param cavityType a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double calcYKI(int stucture, int cavityType, PhaseInterface phase) { - if (componentName.equals("water")) { - return 0.0; - } - // if(componentName.equals("methane")){ - double yki = calcCKI(stucture, cavityType, phase) * reffug[componentNumber]; - double temp = 1.0; - for (int i = 0; i < phase.getNumberOfComponents(); i++) { - if (!phase.getComponent(i).getComponentName().equals("water")) { - if (phase.getComponent(i).isHydrateFormer()) { - temp += ((ComponentHydrate) phase.getComponent(i)).calcCKI(stucture, cavityType, - phase) * reffug[i]; - } + } catch (Exception e) { + logger.error("error closing database.....", e); + } + } + } + + /** + *

+ * readHydrateParameters. + *

+ */ + public void readHydrateParameters() {} + + /** {@inheritDoc} */ + @Override + public double fugcoef(PhaseInterface phase) { + return fugcoef(phase, phase.getNumberOfComponents(), phase.getTemperature(), + phase.getPressure()); + } + + /** + *

+ * Setter for the field hydrateStructure. + *

+ * + * @param structure a int + */ + public void setHydrateStructure(int structure) { + this.hydrateStructure = structure; + } + + /** + *

+ * Getter for the field hydrateStructure. + *

+ * + * @return a int + */ + public int getHydrateStructure() { + return this.hydrateStructure; + } + + /** + *

+ * fugcoef. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComps a int + * @param temp a double + * @param pres a double + * @return a double + */ + public double fugcoef(PhaseInterface phase, int numberOfComps, double temp, double pres) { + if (componentName.equals("water")) { + fugacityCoefficient = -1e50; + double val = 1.0; + double tempy = 1.0; + double fugold = 0.0; + + do { + val = 0; + tempy = 0.0; + fugold = fugacityCoefficient; + if (hydrateStructure >= 0) { + for (int cavType = 0; cavType < 2; cavType++) { + tempy = 0.0; + for (int j = 0; j < phase.getNumberOfComponents(); j++) { + // System.out.println(phase.getComponent(j)); + tempy += ((ComponentHydrate) phase.getComponent(j)).calcYKI(hydrateStructure, cavType, + phase); + // System.out.println("tempny " +tempy); + // System.out.println("temp ny " + this); //phase.getComponent(j)); } + val += getCavprwat()[hydrateStructure][cavType] * Math.log(1.0 - tempy); + } } - return yki / temp; - // } - // else return 0.0; - } - - /** - *

- * calcCKI. - *

- * - * @param stucture a int - * @param cavityType a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double calcCKI(int stucture, int cavityType, PhaseInterface phase) { - double cki = 4.0 * pi / (boltzmannConstant * phase.getTemperature()) - * potIntegral(stucture, cavityType, phase); - // System.out.println("cki " + cki); - return cki; - } - - /** - *

- * setRefFug. - *

- * - * @param compNumbm a int - * @param val a double - */ - public void setRefFug(int compNumbm, double val) { - // System.out.println("ref fug setting " + val); - reffug[compNumbm] = val; - } - - /** - *

- * potIntegral. - *

- * - * @param stucture a int - * @param cavityType a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double potIntegral(int stucture, int cavityType, PhaseInterface phase) { - double val = 0.0; - double endval = cavRadius[stucture][cavityType] - getSphericalCoreRadiusHydrate(); - double x = 0.0, step = endval / 100.0; - x = step; - for (int i = 1; i < 100; i++) { - // System.out.println("x" +x); - // System.out.println("pot " + getPot(x,stucture,cavityType,phase)); - val += step * ((getPot(x, stucture, cavityType, phase) - + 4 * getPot((x + 0.5 * step), stucture, cavityType, phase) - + getPot(x + step, stucture, cavityType, phase)) / 6.0); - x = i * step; - } - return val / 100000.0; - } - - /** - *

- * getPot. - *

- * - * @param radius a double - * @param struccture a int - * @param cavityType a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double getPot(double radius, int struccture, int cavityType, PhaseInterface phase) { - double pot = 2.0 * coordNumb[struccture][cavityType] - * this.getLennardJonesEnergyParameterHydrate() - * ((Math.pow(this.getLennardJonesMolecularDiameterHydrate(), 12.0) - / (Math.pow(cavRadius[struccture][cavityType], 11.0) * radius) - * (delt(10.0, radius, struccture, cavityType, this) - + this.getSphericalCoreRadiusHydrate() - / cavRadius[struccture][cavityType] - * delt(11.0, radius, struccture, cavityType, this))) - - (Math.pow(this.getLennardJonesMolecularDiameterHydrate(), 6.0) - / (Math.pow(cavRadius[struccture][cavityType], 5.0) * radius) - * (delt(4.0, radius, struccture, cavityType, this) - + this.getSphericalCoreRadiusHydrate() - / cavRadius[struccture][cavityType] * delt(5.0, - radius, struccture, cavityType, this)))); - // System.out.println("lenjones " - // +this.getLennardJonesMolecularDiameterHydrate() ); - // System.out.println("pot bef " + pot); - pot = Math.exp(-pot / (phase.getTemperature())) * radius * radius / 1.0e20; - // System.out.println("pot " + pot); - return pot; - } - - /** - *

- * delt. - *

- * - * @param n a double - * @param radius a double - * @param struccture a int - * @param cavityType a int - * @param comp a {@link neqsim.thermo.component.ComponentInterface} object - * @return a double - */ - public double delt(double n, double radius, int struccture, int cavityType, - ComponentInterface comp) { - double delt = 1.0 / n * (Math - .pow(1.0 - radius / cavRadius[struccture][cavityType] - - ((ComponentHydrate) comp).getSphericalCoreRadiusHydrate() - / cavRadius[struccture][cavityType], - -n) - - Math.pow(1.0 + radius / cavRadius[struccture][cavityType] - - ((ComponentHydrate) comp).getSphericalCoreRadiusHydrate() - / cavRadius[struccture][cavityType], - -n)); - - // System.out.println("delt " + delt); - return delt; - } - - /** - *

- * Getter for the field dGfHydrate. - *

- * - * @return an array of {@link double} objects - */ - public double[] getDGfHydrate() { - return dGfHydrate; - } - - /** - *

- * Setter for the field dGfHydrate. - *

- * - * @param dGfHydrate an array of {@link double} objects - */ - public void setDGfHydrate(double[] dGfHydrate) { - this.dGfHydrate = dGfHydrate; - } - - /** - *

- * Setter for the field dGfHydrate. - *

- * - * @param dGfHydrate a double - * @param i a int - */ - public void setDGfHydrate(double dGfHydrate, int i) { - this.dGfHydrate[i] = dGfHydrate; - } - - /** - *

- * Setter for the field dHfHydrate. - *

- * - * @param dHfHydrate a double - * @param i a int - */ - public void setDHfHydrate(double dHfHydrate, int i) { - this.dHfHydrate[i] = dHfHydrate; - } - - /** - *

- * Getter for the field dHfHydrate. - *

- * - * @return an array of {@link double} objects - */ - public double[] getDHfHydrate() { - return dHfHydrate; - } - - /** - *

- * Setter for the field dHfHydrate. - *

- * - * @param dHfHydrate an array of {@link double} objects - */ - public void setDHfHydrate(double[] dHfHydrate) { - this.dHfHydrate = dHfHydrate; - } - - /** - *

- * getMolarVolumeHydrate. - *

- * - * @param structure a int - * @param temperature a double - * @return a double - */ - public double getMolarVolumeHydrate(int structure, double temperature) { - // taken from chem.eng.sci Avlonitis 1994 - double TO = 273.15; - if (structure == 0) { - double v0 = 22.35, k1 = 3.1075e-4, k2 = 5.9537e-7, k3 = 1.3707e-10; - return v0 * (1.0 + k1 * (temperature - TO) + k2 * Math.pow(temperature - TO, 2.0) - + k3 * Math.pow(temperature - TO, 3.0)) / 1.0e6; - } else if (structure == 1) { - double v0 = 22.57, k1 = 1.9335e-4, k2 = 2.1768e-7, k3 = -1.4786e-10; - return v0 * (1.0 + k1 * (temperature - TO) + k2 * Math.pow(temperature - TO, 2.0) - + k3 * Math.pow(temperature - TO, 3.0)) / 1.0e6; - } else if (structure == -1) { - double v0 = 19.6522, k1 = 1.6070e-4, k2 = 3.4619e-7, k3 = -1.4786e-10; - return v0 * (1.0 + k1 * (temperature - TO) + k2 * Math.pow(temperature - TO, 2.0) - + k3 * Math.pow(temperature - TO, 3.0)) / 1.0e6; - } else { - return 0.0; - } - } - - /** - *

- * Getter for the field sphericalCoreRadiusHydrate. - *

- * - * @return a double - */ - public double getSphericalCoreRadiusHydrate() { - return sphericalCoreRadiusHydrate; - } - - /** - *

- * Setter for the field sphericalCoreRadiusHydrate. - *

- * - * @param sphericalCoreRadiusHydrate a double - */ - public void setSphericalCoreRadiusHydrate(double sphericalCoreRadiusHydrate) { - this.sphericalCoreRadiusHydrate = sphericalCoreRadiusHydrate; - } - - /** - *

- * Getter for the field lennardJonesEnergyParameterHydrate. - *

- * - * @return a double - */ - public double getLennardJonesEnergyParameterHydrate() { - return lennardJonesEnergyParameterHydrate; - } - - /** - *

- * Setter for the field lennardJonesEnergyParameterHydrate. - *

- * - * @param lennardJonesEnergyParameterHydrate a double - */ - public void setLennardJonesEnergyParameterHydrate(double lennardJonesEnergyParameterHydrate) { - this.lennardJonesEnergyParameterHydrate = lennardJonesEnergyParameterHydrate; - } - - /** - *

- * Getter for the field lennardJonesMolecularDiameterHydrate. - *

- * - * @return a double - */ - public double getLennardJonesMolecularDiameterHydrate() { - return lennardJonesMolecularDiameterHydrate; - } - - /** - *

- * Setter for the field lennardJonesMolecularDiameterHydrate. - *

- * - * @param lennardJonesMolecularDiameterHydrate a double - */ - public void setLennardJonesMolecularDiameterHydrate( - double lennardJonesMolecularDiameterHydrate) { - this.lennardJonesMolecularDiameterHydrate = lennardJonesMolecularDiameterHydrate; - } - - /** - *

- * setSolidRefFluidPhase. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - */ - public void setSolidRefFluidPhase(PhaseInterface phase) { - try { - refPhase = phase.getClass().getDeclaredConstructor().newInstance(); - refPhase.setTemperature(273.0); - refPhase.setPressure(1.0); - refPhase.addcomponent("water", 10.0, 10.0, 0); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 0, 1, 1.0); - } catch (Exception e) { - logger.error("error occured", e); + // System.out.println("val " +(val)); + // System.out.println("fugacityCoefficient bef " + fugacityCoefficient); + double solvol = 1.0 / 906.0 * getMolarMass(); + fugacityCoefficient = Math.exp(val) + * getEmptyHydrateStructureVapourPressure(hydrateStructure, temp) + * Math.exp(solvol / (R * temp) + * ((pres - getEmptyHydrateStructureVapourPressure(hydrateStructure, temp))) * 1e5) + / pres; + // System.out.println("struct " + hydrateStruct + " fug " + tempfugcoef + " val + // "+ val); + + // fugacityCoefficient = + // Math.exp(val)*getEmptyHydrateStructureVapourPressure(hydrateStructure,temp)*Math.exp(solvol/(R*temp)*((pres-getEmptyHydrateStructureVapourPressure(hydrateStructure,temp)))*1e5)/pres; + // fugacityCoefficient = getAntoineVaporPressure(temp)/pres; + // logFugacityCoefficient = Math.log(fugacityCoefficient); + // logFugacityCoefficient += val*boltzmannConstant/R; + // fugacityCoefficient = Math.exp(logFugacityCoefficient); + // System.out.println("fugacityCoefficient " + fugacityCoefficient); + } while (Math.abs((fugacityCoefficient - fugold) / fugold) > 1e-6); + } else { + fugacityCoefficient = 1e5; + } + logFugacityCoefficient = Math.log(fugacityCoefficient); + // System.out.println("fug " + fugacityCoefficient); + return fugacityCoefficient; + } + + /** + *

+ * getEmptyHydrateStructureVapourPressure. + *

+ * + * @param type a int + * @param temperature a double + * @return a double + */ + public double getEmptyHydrateStructureVapourPressure(int type, double temperature) { + if (type == -1) { + return getSolidVaporPressure(temperature); + } else { + return Math.exp(getEmptyHydrateVapourPressureConstant(type, 0) + + getEmptyHydrateVapourPressureConstant(type, 1) / temperature) * 1.01325; + } + } + + /** + *

+ * Setter for the field emptyHydrateVapourPressureConstant. + *

+ * + * @param hydrateStructure a int + * @param parameterNumber a int + * @param value a double + */ + public void setEmptyHydrateVapourPressureConstant(int hydrateStructure, int parameterNumber, + double value) { + emptyHydrateVapourPressureConstant[hydrateStructure][parameterNumber] = value; + } + + /** + *

+ * Getter for the field emptyHydrateVapourPressureConstant. + *

+ * + * @param hydrateStructure a int + * @param parameterNumber a int + * @return a double + */ + public double getEmptyHydrateVapourPressureConstant(int hydrateStructure, int parameterNumber) { + return emptyHydrateVapourPressureConstant[hydrateStructure][parameterNumber]; + } + + /** + *

+ * calcChemPotEmpty. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComps a int + * @param temp a double + * @param pres a double + * @param hydrateStruct a int + * @return a double + */ + public double calcChemPotEmpty(PhaseInterface phase, int numberOfComps, double temp, double pres, + int hydrateStruct) { + double dGf = 0.0; + double dHf = 0.0; + double Cpa = getCpA(); + double Cpb = getCpB(); + double Cpc = getCpC(); + double Cpd = getCpD(); + double deltaMolarVolume = 0.0; + if (hydrateStruct == 1) { + dGf = getDGfHydrate()[1]; + dHf = getDHfHydrate()[1]; + deltaMolarVolume = 5.0e-6; + } else { + dGf = getDGfHydrate()[0]; + dHf = getDHfHydrate()[0]; + deltaMolarVolume = 4.6e-6; + } + double T0 = 298.15; + + dHf += Cpa * (temp - T0) + Cpb * Math.log(temp / T0) - Cpc * (1.0 / temp - 1.0 / T0) + - 1.0 / 2.0 * Cpd * (1.0 / (temp * temp) - 1.0 / (T0 * T0)); + + return (dGf / R / T0 + 1.0 * dHf * (1.0 / R / temp - 1.0 / R / T0)) + + deltaMolarVolume / R / ((temp + T0) / 2.0) * (pres * 1e5 - 1e5); + } + + /** + *

+ * calcChemPotIdealWater. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComps a int + * @param temp a double + * @param pres a double + * @param hydrateStruct a int + * @return a double + */ + public double calcChemPotIdealWater(PhaseInterface phase, int numberOfComps, double temp, + double pres, int hydrateStruct) { + double dGf = -228700.0; + double dHf = -242000.0; + double Cpa = getCpA(); + double Cpb = getCpB(); + double Cpc = getCpC(); + double Cpd = getCpD(); + // Cpa = 0.7354; + // Cpb = 0.01418; + // Cpc = -1.727e-5; + double T0 = 298.15; + dHf += Cpa * (temp - T0) + Cpb * Math.log(temp / T0) - Cpc * (1.0 / temp - 1.0 / T0) + - 1.0 / 2.0 * Cpd * (1.0 / (temp * temp) - 1.0 / (T0 * T0)); + return (dGf / R / T0 + 1.0 * dHf * (1.0 / R / temp - 1.0 / R / T0)); + } + + /** + *

+ * calcYKI. + *

+ * + * @param stucture a int + * @param cavityType a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double calcYKI(int stucture, int cavityType, PhaseInterface phase) { + if (componentName.equals("water")) { + return 0.0; + } + // if(componentName.equals("methane")){ + double yki = calcCKI(stucture, cavityType, phase) * reffug[componentNumber]; + double temp = 1.0; + for (int i = 0; i < phase.getNumberOfComponents(); i++) { + if (!phase.getComponent(i).getComponentName().equals("water")) { + if (phase.getComponent(i).isHydrateFormer()) { + temp += ((ComponentHydrate) phase.getComponent(i)).calcCKI(stucture, cavityType, phase) + * reffug[i]; } + } } - // public double dfugdt(PhaseInterface phase, int numberOfComps, double temp, - // double pres){ - // if(componentName.equals("water")){ - // double solvol = - // 1.0/getPureComponentSolidDensity(getMeltingPointTemperature())*molarMass; - // dfugdt = - // Math.log((getEmptyHydrateStructureVapourPressuredT(hydrateStructure,temp))/pres); - // } else dfugdt=0; - // return dfugdt; - // } - - // public double getEmptyHydrateStructureVapourPressure2(int type, double - // temperature){ - // double par1_struc1=4.6477; - // double par2_struc1=-5242.979; - // double par3_struc1=2.7789; - // double par4_struc1=-8.7156e-3; - // if(type==0){ - // return - // Math.exp(par1_struc1*Math.log(temperature)+par2_struc1/temperature+par3_struc1+par4_struc1*temperature)/1.0e5; - // } - // if(type==1){ - // return Math.exp(par1_struc2+par2_struc2/temperature)*1.01325; - // } else return 0.0; - // } - - // public double getEmptyHydrateStructureVapourPressure(int type, double - // temperature){ - - // if(type==0){ - // return Math.exp(par1_struc1+par2_struc1/temperature)*1.01325; - // } - // if(type==1){ - // return Math.exp(par1_struc2+par2_struc2/temperature)*1.01325; - // } else return 0.0; - // } - - // public double getEmptyHydrateStructureVapourPressuredT(int type, double - // temperature){ - - // if(type==0){ - // return - // -par2_struc1/(temperature*temperature)*Math.exp(par1_struc1+par2_struc1/temperature); + return yki / temp; // } - // if(type==1){ - // return - // -par2_struc2/(temperature*temperature)*Math.exp(par1_struc2+par2_struc2/temperature); - // } else return 0.0; - // } - - /** - *

- * Getter for the field cavprwat. - *

- * - * @return the cavprwat - * @param structure a int - * @param cavityType a int - */ - public double getCavprwat(int structure, int cavityType) { - return getCavprwat()[structure][cavityType]; - } - - /** - *

- * Getter for the field cavprwat. - *

- * - * @return an array of {@link double} objects - */ - public double[][] getCavprwat() { - return cavprwat; - } + // else return 0.0; + } + + /** + *

+ * calcCKI. + *

+ * + * @param stucture a int + * @param cavityType a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double calcCKI(int stucture, int cavityType, PhaseInterface phase) { + double cki = 4.0 * pi / (boltzmannConstant * phase.getTemperature()) + * potIntegral(stucture, cavityType, phase); + // System.out.println("cki " + cki); + return cki; + } + + /** + *

+ * setRefFug. + *

+ * + * @param compNumbm a int + * @param val a double + */ + public void setRefFug(int compNumbm, double val) { + // System.out.println("ref fug setting " + val); + reffug[compNumbm] = val; + } + + /** + *

+ * potIntegral. + *

+ * + * @param stucture a int + * @param cavityType a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double potIntegral(int stucture, int cavityType, PhaseInterface phase) { + double val = 0.0; + double endval = cavRadius[stucture][cavityType] - getSphericalCoreRadiusHydrate(); + double x = 0.0; + double step = endval / 100.0; + x = step; + for (int i = 1; i < 100; i++) { + // System.out.println("x" +x); + // System.out.println("pot " + getPot(x,stucture,cavityType,phase)); + val += step * ((getPot(x, stucture, cavityType, phase) + + 4 * getPot((x + 0.5 * step), stucture, cavityType, phase) + + getPot(x + step, stucture, cavityType, phase)) / 6.0); + x = i * step; + } + return val / 100000.0; + } + + /** + *

+ * getPot. + *

+ * + * @param radius a double + * @param struccture a int + * @param cavityType a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double getPot(double radius, int struccture, int cavityType, PhaseInterface phase) { + double pot = 2.0 * coordNumb[struccture][cavityType] + * this.getLennardJonesEnergyParameterHydrate() + * ((Math.pow(this.getLennardJonesMolecularDiameterHydrate(), 12.0) + / (Math.pow(cavRadius[struccture][cavityType], 11.0) * radius) + * (delt(10.0, radius, struccture, cavityType, this) + + this.getSphericalCoreRadiusHydrate() / cavRadius[struccture][cavityType] + * delt(11.0, radius, struccture, cavityType, this))) + - (Math.pow(this.getLennardJonesMolecularDiameterHydrate(), 6.0) + / (Math.pow(cavRadius[struccture][cavityType], 5.0) * radius) + * (delt(4.0, radius, struccture, cavityType, this) + + this.getSphericalCoreRadiusHydrate() / cavRadius[struccture][cavityType] + * delt(5.0, radius, struccture, cavityType, this)))); + // System.out.println("lenjones " + // +this.getLennardJonesMolecularDiameterHydrate() ); + // System.out.println("pot bef " + pot); + pot = Math.exp(-pot / (phase.getTemperature())) * radius * radius / 1.0e20; + // System.out.println("pot " + pot); + return pot; + } + + /** + *

+ * delt. + *

+ * + * @param n a double + * @param radius a double + * @param struccture a int + * @param cavityType a int + * @param comp a {@link neqsim.thermo.component.ComponentInterface} object + * @return a double + */ + public double delt(double n, double radius, int struccture, int cavityType, + ComponentInterface comp) { + double delt = 1.0 / n + * (Math + .pow(1.0 - radius / cavRadius[struccture][cavityType] + - ((ComponentHydrate) comp).getSphericalCoreRadiusHydrate() + / cavRadius[struccture][cavityType], + -n) + - Math.pow(1.0 + radius / cavRadius[struccture][cavityType] + - ((ComponentHydrate) comp).getSphericalCoreRadiusHydrate() + / cavRadius[struccture][cavityType], + -n)); + + // System.out.println("delt " + delt); + return delt; + } + + /** + *

+ * Getter for the field dGfHydrate. + *

+ * + * @return an array of {@link double} objects + */ + public double[] getDGfHydrate() { + return dGfHydrate; + } + + /** + *

+ * Setter for the field dGfHydrate. + *

+ * + * @param dGfHydrate an array of {@link double} objects + */ + public void setDGfHydrate(double[] dGfHydrate) { + this.dGfHydrate = dGfHydrate; + } + + /** + *

+ * Setter for the field dGfHydrate. + *

+ * + * @param dGfHydrate a double + * @param i a int + */ + public void setDGfHydrate(double dGfHydrate, int i) { + this.dGfHydrate[i] = dGfHydrate; + } + + /** + *

+ * Setter for the field dHfHydrate. + *

+ * + * @param dHfHydrate a double + * @param i a int + */ + public void setDHfHydrate(double dHfHydrate, int i) { + this.dHfHydrate[i] = dHfHydrate; + } + + /** + *

+ * Getter for the field dHfHydrate. + *

+ * + * @return an array of {@link double} objects + */ + public double[] getDHfHydrate() { + return dHfHydrate; + } + + /** + *

+ * Setter for the field dHfHydrate. + *

+ * + * @param dHfHydrate an array of {@link double} objects + */ + public void setDHfHydrate(double[] dHfHydrate) { + this.dHfHydrate = dHfHydrate; + } + + /** + *

+ * getMolarVolumeHydrate. + *

+ * + * @param structure a int + * @param temperature a double + * @return a double + */ + public double getMolarVolumeHydrate(int structure, double temperature) { + // taken from chem.eng.sci Avlonitis 1994 + double TO = 273.15; + if (structure == 0) { + double v0 = 22.35; + double k1 = 3.1075e-4; + double k2 = 5.9537e-7; + double k3 = 1.3707e-10; + return v0 * (1.0 + k1 * (temperature - TO) + k2 * Math.pow(temperature - TO, 2.0) + + k3 * Math.pow(temperature - TO, 3.0)) / 1.0e6; + } else if (structure == 1) { + double v0 = 22.57; + double k1 = 1.9335e-4; + double k2 = 2.1768e-7; + double k3 = -1.4786e-10; + return v0 * (1.0 + k1 * (temperature - TO) + k2 * Math.pow(temperature - TO, 2.0) + + k3 * Math.pow(temperature - TO, 3.0)) / 1.0e6; + } else if (structure == -1) { + double v0 = 19.6522; + double k1 = 1.6070e-4; + double k2 = 3.4619e-7; + double k3 = -1.4786e-10; + return v0 * (1.0 + k1 * (temperature - TO) + k2 * Math.pow(temperature - TO, 2.0) + + k3 * Math.pow(temperature - TO, 3.0)) / 1.0e6; + } else { + return 0.0; + } + } + + /** + *

+ * Getter for the field sphericalCoreRadiusHydrate. + *

+ * + * @return a double + */ + public double getSphericalCoreRadiusHydrate() { + return sphericalCoreRadiusHydrate; + } + + /** + *

+ * Setter for the field sphericalCoreRadiusHydrate. + *

+ * + * @param sphericalCoreRadiusHydrate a double + */ + public void setSphericalCoreRadiusHydrate(double sphericalCoreRadiusHydrate) { + this.sphericalCoreRadiusHydrate = sphericalCoreRadiusHydrate; + } + + /** + *

+ * Getter for the field lennardJonesEnergyParameterHydrate. + *

+ * + * @return a double + */ + public double getLennardJonesEnergyParameterHydrate() { + return lennardJonesEnergyParameterHydrate; + } + + /** + *

+ * Setter for the field lennardJonesEnergyParameterHydrate. + *

+ * + * @param lennardJonesEnergyParameterHydrate a double + */ + public void setLennardJonesEnergyParameterHydrate(double lennardJonesEnergyParameterHydrate) { + this.lennardJonesEnergyParameterHydrate = lennardJonesEnergyParameterHydrate; + } + + /** + *

+ * Getter for the field lennardJonesMolecularDiameterHydrate. + *

+ * + * @return a double + */ + public double getLennardJonesMolecularDiameterHydrate() { + return lennardJonesMolecularDiameterHydrate; + } + + /** + *

+ * Setter for the field lennardJonesMolecularDiameterHydrate. + *

+ * + * @param lennardJonesMolecularDiameterHydrate a double + */ + public void setLennardJonesMolecularDiameterHydrate(double lennardJonesMolecularDiameterHydrate) { + this.lennardJonesMolecularDiameterHydrate = lennardJonesMolecularDiameterHydrate; + } + + /** + *

+ * setSolidRefFluidPhase. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + */ + public void setSolidRefFluidPhase(PhaseInterface phase) { + try { + refPhase = phase.getClass().getDeclaredConstructor().newInstance(); + refPhase.setTemperature(273.0); + refPhase.setPressure(1.0); + refPhase.addcomponent("water", 10.0, 10.0, 0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 0, 1, 1.0); + } catch (Exception e) { + logger.error("error occured", e); + } + } + // public double dfugdt(PhaseInterface phase, int numberOfComps, double temp, + // double pres){ + // if(componentName.equals("water")){ + // double solvol = + // 1.0/getPureComponentSolidDensity(getMeltingPointTemperature())*molarMass; + // dfugdt = + // Math.log((getEmptyHydrateStructureVapourPressuredT(hydrateStructure,temp))/pres); + // } else dfugdt=0; + // return dfugdt; + // } + + // public double getEmptyHydrateStructureVapourPressure2(int type, double + // temperature){ + // double par1_struc1=4.6477; + // double par2_struc1=-5242.979; + // double par3_struc1=2.7789; + // double par4_struc1=-8.7156e-3; + // if(type==0){ + // return + // Math.exp(par1_struc1*Math.log(temperature)+par2_struc1/temperature+par3_struc1+par4_struc1*temperature)/1.0e5; + // } + // if(type==1){ + // return Math.exp(par1_struc2+par2_struc2/temperature)*1.01325; + // } else return 0.0; + // } + + // public double getEmptyHydrateStructureVapourPressure(int type, double + // temperature){ + + // if(type==0){ + // return Math.exp(par1_struc1+par2_struc1/temperature)*1.01325; + // } + // if(type==1){ + // return Math.exp(par1_struc2+par2_struc2/temperature)*1.01325; + // } else return 0.0; + // } + + // public double getEmptyHydrateStructureVapourPressuredT(int type, double + // temperature){ + + // if(type==0){ + // return + // -par2_struc1/(temperature*temperature)*Math.exp(par1_struc1+par2_struc1/temperature); + // } + // if(type==1){ + // return + // -par2_struc2/(temperature*temperature)*Math.exp(par1_struc2+par2_struc2/temperature); + // } else return 0.0; + // } + + /** + *

+ * Getter for the field cavprwat. + *

+ * + * @return the cavprwat + * @param structure a int + * @param cavityType a int + */ + public double getCavprwat(int structure, int cavityType) { + return getCavprwat()[structure][cavityType]; + } + + /** + *

+ * Getter for the field cavprwat. + *

+ * + * @return an array of {@link double} objects + */ + public double[][] getCavprwat() { + return cavprwat; + } } diff --git a/src/main/java/neqsim/thermo/component/ComponentHydrateKluda.java b/src/main/java/neqsim/thermo/component/ComponentHydrateKluda.java index 5df4c67094..3912a449a9 100644 --- a/src/main/java/neqsim/thermo/component/ComponentHydrateKluda.java +++ b/src/main/java/neqsim/thermo/component/ComponentHydrateKluda.java @@ -13,377 +13,378 @@ * @version $Id: $Id */ public class ComponentHydrateKluda extends Component { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - double par1_struc1 = 17.44; - double par2_struc1 = -6003.9; - double par1_struc2 = 17.332; - double par2_struc2 = -6017.6; - int hydrateStructure = 0; - double coordNumb[][][] = new double[3][2][2]; // [structure][cavitytype] - double cavRadius[][][] = new double[3][2][2]; // [structure][cavitytype] - double cavNumb[][] = new double[2][2]; // [structure][cavitytype] - double cavprwat[][] = new double[2][2]; // [structure][cavitytype] - double reffug[] = new double[20]; - static Logger logger = LogManager.getLogger(ComponentHydrateKluda.class); + double par1_struc1 = 17.44; + double par2_struc1 = -6003.9; + double par1_struc2 = 17.332; + double par2_struc2 = -6017.6; + int hydrateStructure = 0; + double[][][] coordNumb = new double[3][2][2]; // [structure][cavitytype] + double[][][] cavRadius = new double[3][2][2]; // [structure][cavitytype] + double cavNumb[][] = new double[2][2]; // [structure][cavitytype] + double cavprwat[][] = new double[2][2]; // [structure][cavitytype] + double[] reffug = new double[20]; + static Logger logger = LogManager.getLogger(ComponentHydrateKluda.class); - /** - *

- * Constructor for ComponentHydrateKluda. - *

- * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int - */ - public ComponentHydrateKluda(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); - coordNumb[0][0][0] = 20.0; - coordNumb[0][0][1] = 24.0; - cavRadius[0][0][0] = 3.906; - cavRadius[0][0][1] = 4.326; - coordNumb[1][0][0] = 20.0; - coordNumb[1][0][1] = 24.0; - cavRadius[1][0][0] = 6.593; - cavRadius[1][0][1] = 7.078; - coordNumb[2][0][0] = 50.0; - coordNumb[2][0][1] = 50.0; - cavRadius[2][0][0] = 8.086; - cavRadius[2][0][1] = 8.285; - cavNumb[0][0] = 2.0; - cavNumb[0][1] = 6.0; - cavprwat[0][0] = 1.0 / 23.0; - cavprwat[0][1] = 3.0 / 23.0; + /** + *

+ * Constructor for ComponentHydrateKluda. + *

+ * + * @param component_name a {@link java.lang.String} object + * @param moles a double + * @param molesInPhase a double + * @param compnumber a int + */ + public ComponentHydrateKluda(String component_name, double moles, double molesInPhase, + int compnumber) { + super(component_name, moles, molesInPhase, compnumber); + coordNumb[0][0][0] = 20.0; + coordNumb[0][0][1] = 24.0; + cavRadius[0][0][0] = 3.906; + cavRadius[0][0][1] = 4.326; + coordNumb[1][0][0] = 20.0; + coordNumb[1][0][1] = 24.0; + cavRadius[1][0][0] = 6.593; + cavRadius[1][0][1] = 7.078; + coordNumb[2][0][0] = 50.0; + coordNumb[2][0][1] = 50.0; + cavRadius[2][0][0] = 8.086; + cavRadius[2][0][1] = 8.285; + cavNumb[0][0] = 2.0; + cavNumb[0][1] = 6.0; + cavprwat[0][0] = 1.0 / 23.0; + cavprwat[0][1] = 3.0 / 23.0; - coordNumb[0][1][0] = 20.0; - coordNumb[0][1][1] = 28.0; - cavRadius[0][1][0] = 3.902; - cavRadius[0][1][1] = 4.683; - cavNumb[1][0] = 16.0; - cavNumb[1][1] = 8.0; - cavprwat[1][0] = 2.0 / 17.0; - cavprwat[1][1] = 1.0 / 17.0; - } + coordNumb[0][1][0] = 20.0; + coordNumb[0][1][1] = 28.0; + cavRadius[0][1][0] = 3.902; + cavRadius[0][1][1] = 4.683; + cavNumb[1][0] = 16.0; + cavNumb[1][1] = 8.0; + cavprwat[1][0] = 2.0 / 17.0; + cavprwat[1][1] = 1.0 / 17.0; + } - /** {@inheritDoc} */ - @Override - public double fugcoef(PhaseInterface phase) { - return fugcoef(phase, phase.getNumberOfComponents(), phase.getTemperature(), - phase.getPressure()); - } + /** {@inheritDoc} */ + @Override + public double fugcoef(PhaseInterface phase) { + return fugcoef(phase, phase.getNumberOfComponents(), phase.getTemperature(), + phase.getPressure()); + } - /** - *

- * setStructure. - *

- * - * @param structure a int - */ - public void setStructure(int structure) { - this.hydrateStructure = structure; - } + /** + *

+ * setStructure. + *

+ * + * @param structure a int + */ + public void setStructure(int structure) { + this.hydrateStructure = structure; + } - /** - *

- * fugcoef. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComps a int - * @param temp a double - * @param pres a double - * @return a double - */ - public double fugcoef(PhaseInterface phase, int numberOfComps, double temp, double pres) { - if (componentName.equals("water")) { - double val = 1.0; - double tempy = 1.0; - double fugold = 0.0; - do { - val = 0.0; - tempy = 0.0; - fugold = fugacityCoefficient; - for (int cavType = 0; cavType < 2; cavType++) { - tempy = 0.0; - for (int j = 0; j < phase.getNumberOfComponents(); j++) { - // System.out.println(phase.getComponent(j)); - tempy += ((ComponentHydrateKluda) phase.getComponent(j)) - .calcYKI(hydrateStructure, cavType, phase); - logger.info("tempny " + tempy); - // System.out.println("temp ny " + this);//phase.getComponent(j)); - } - val += cavprwat[hydrateStructure][cavType] * Math.log(1.0 - tempy); - } - logger.info("val " + (val)); - logger.info("fugacityCoefficient bef " + fugacityCoefficient); - double solvol = 1.0 / 906.0 * getMolarMass(); - fugacityCoefficient = Math.exp(val) - * getEmptyHydrateStructureVapourPressure(hydrateStructure, temp) - * Math.exp(solvol / (R * temp) * ((pres - - getEmptyHydrateStructureVapourPressure(hydrateStructure, temp))) - * 1e5) - / pres; - // fugacityCoefficient = getAntoineVaporPressure(temp)/pres; - // logFugacityCoefficient = Math.log(fugacityCoefficient); - // logFugacityCoefficient += val*boltzmannConstant/R; - - // fugacityCoefficient = Math.exp(logFugacityCoefficient); - logger.info("fugacityCoefficient " + fugacityCoefficient); - } while (Math.abs((fugacityCoefficient - fugold) / fugold) > 1e-8); - } else { - fugacityCoefficient = 1e5; + /** + *

+ * fugcoef. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComps a int + * @param temp a double + * @param pres a double + * @return a double + */ + public double fugcoef(PhaseInterface phase, int numberOfComps, double temp, double pres) { + if (componentName.equals("water")) { + double val = 1.0; + double tempy = 1.0; + double fugold = 0.0; + do { + val = 0.0; + tempy = 0.0; + fugold = fugacityCoefficient; + for (int cavType = 0; cavType < 2; cavType++) { + tempy = 0.0; + for (int j = 0; j < phase.getNumberOfComponents(); j++) { + // System.out.println(phase.getComponent(j)); + tempy += ((ComponentHydrateKluda) phase.getComponent(j)).calcYKI(hydrateStructure, + cavType, phase); + logger.info("tempny " + tempy); + // System.out.println("temp ny " + this); //phase.getComponent(j)); + } + val += cavprwat[hydrateStructure][cavType] * Math.log(1.0 - tempy); } - // System.out.println("fug " + fugacityCoefficient); - return fugacityCoefficient; + logger.info("val " + (val)); + logger.info("fugacityCoefficient bef " + fugacityCoefficient); + double solvol = 1.0 / 906.0 * getMolarMass(); + fugacityCoefficient = Math.exp(val) + * getEmptyHydrateStructureVapourPressure(hydrateStructure, temp) + * Math.exp(solvol / (R * temp) + * ((pres - getEmptyHydrateStructureVapourPressure(hydrateStructure, temp))) * 1e5) + / pres; + // fugacityCoefficient = getAntoineVaporPressure(temp)/pres; + // logFugacityCoefficient = Math.log(fugacityCoefficient); + // logFugacityCoefficient += val*boltzmannConstant/R; + + // fugacityCoefficient = Math.exp(logFugacityCoefficient); + logger.info("fugacityCoefficient " + fugacityCoefficient); + } while (Math.abs((fugacityCoefficient - fugold) / fugold) > 1e-8); + } else { + fugacityCoefficient = 1e5; } + // System.out.println("fug " + fugacityCoefficient); + return fugacityCoefficient; + } - /** - *

- * dfugdt. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComps a int - * @param temp a double - * @param pres a double - * @return a double - */ - public double dfugdt(PhaseInterface phase, int numberOfComps, double temp, double pres) { - if (componentName.equals("water")) { - // double solvol =1.0 / getPureComponentSolidDensity(getMeltingPointTemperature()) * - // molarMass; - dfugdt = Math - .log((getEmptyHydrateStructureVapourPressuredT(hydrateStructure, temp)) / pres); - } else { - dfugdt = 0; - } - return dfugdt; + /** + *

+ * dfugdt. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComps a int + * @param temp a double + * @param pres a double + * @return a double + */ + public double dfugdt(PhaseInterface phase, int numberOfComps, double temp, double pres) { + if (componentName.equals("water")) { + // double solvol =1.0 / getPureComponentSolidDensity(getMeltingPointTemperature()) * + // molarMass; + dfugdt = Math.log((getEmptyHydrateStructureVapourPressuredT(hydrateStructure, temp)) / pres); + } else { + dfugdt = 0; } + return dfugdt; + } - /** - *

- * getEmptyHydrateStructureVapourPressure. - *

- * - * @param type a int - * @param temperature a double - * @return a double - */ - public double getEmptyHydrateStructureVapourPressure(int type, double temperature) { - double par1_struc1 = 4.6477; - double par2_struc1 = -5242.979; - double par3_struc1 = 2.7789; - double par4_struc1 = -8.7156e-3; - if (type == 0) { - return Math.exp(par1_struc1 * Math.log(temperature) + par2_struc1 / temperature - + par3_struc1 + par4_struc1 * temperature) / 1.0e5; - } - if (type == 1) { - return Math.exp(par1_struc2 + par2_struc2 / temperature) * 1.01325; - } else { - return 0.0; - } + /** + *

+ * getEmptyHydrateStructureVapourPressure. + *

+ * + * @param type a int + * @param temperature a double + * @return a double + */ + public double getEmptyHydrateStructureVapourPressure(int type, double temperature) { + double par1_struc1 = 4.6477; + double par2_struc1 = -5242.979; + double par3_struc1 = 2.7789; + double par4_struc1 = -8.7156e-3; + if (type == 0) { + return Math.exp(par1_struc1 * Math.log(temperature) + par2_struc1 / temperature + par3_struc1 + + par4_struc1 * temperature) / 1.0e5; + } + if (type == 1) { + return Math.exp(par1_struc2 + par2_struc2 / temperature) * 1.01325; + } else { + return 0.0; } + } - /** - *

- * getEmptyHydrateStructureVapourPressuredT. - *

- * - * @param type a int - * @param temperature a double - * @return a double - */ - public double getEmptyHydrateStructureVapourPressuredT(int type, double temperature) { - if (type == 0) { - return -par2_struc1 / (temperature * temperature) - * Math.exp(par1_struc1 + par2_struc1 / temperature); - } - if (type == 1) { - return -par2_struc2 / (temperature * temperature) - * Math.exp(par1_struc2 + par2_struc2 / temperature); - } else { - return 0.0; - } + /** + *

+ * getEmptyHydrateStructureVapourPressuredT. + *

+ * + * @param type a int + * @param temperature a double + * @return a double + */ + public double getEmptyHydrateStructureVapourPressuredT(int type, double temperature) { + if (type == 0) { + return -par2_struc1 / (temperature * temperature) + * Math.exp(par1_struc1 + par2_struc1 / temperature); } + if (type == 1) { + return -par2_struc2 / (temperature * temperature) + * Math.exp(par1_struc2 + par2_struc2 / temperature); + } else { + return 0.0; + } + } - /** - *

- * calcYKI. - *

- * - * @param stucture a int - * @param cavityType a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double calcYKI(int stucture, int cavityType, PhaseInterface phase) { - if (componentName.equals("methane")) { - double yki = calcCKI(stucture, cavityType, phase) * reffug[componentNumber]; - double temp = 1.0; - for (int i = 0; i < phase.getNumberOfComponents(); i++) { - if (phase.getComponent(i).isHydrateFormer()) { - temp += ((ComponentHydrateKluda) phase.getComponent(i)).calcCKI(stucture, - cavityType, phase) * reffug[i]; - } - } - return yki / temp; - } else { - return 0.0; + /** + *

+ * calcYKI. + *

+ * + * @param stucture a int + * @param cavityType a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double calcYKI(int stucture, int cavityType, PhaseInterface phase) { + if (componentName.equals("methane")) { + double yki = calcCKI(stucture, cavityType, phase) * reffug[componentNumber]; + double temp = 1.0; + for (int i = 0; i < phase.getNumberOfComponents(); i++) { + if (phase.getComponent(i).isHydrateFormer()) { + temp += + ((ComponentHydrateKluda) phase.getComponent(i)).calcCKI(stucture, cavityType, phase) + * reffug[i]; } + } + return yki / temp; + } else { + return 0.0; } + } - /** - *

- * calcCKI. - *

- * - * @param stucture a int - * @param cavityType a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double calcCKI(int stucture, int cavityType, PhaseInterface phase) { - double cki = 4.0 * pi / (boltzmannConstant * phase.getTemperature()) - * (potIntegral(0, stucture, cavityType, phase));// +0*potIntegral(1,stucture, - // cavityType,phase)+0*potIntegral(2,stucture, - // cavityType,phase)); - // System.out.println("cki " + cki); - return cki; - } + /** + *

+ * calcCKI. + *

+ * + * @param stucture a int + * @param cavityType a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double calcCKI(int stucture, int cavityType, PhaseInterface phase) { + double cki = 4.0 * pi / (boltzmannConstant * phase.getTemperature()) + * (potIntegral(0, stucture, cavityType, phase)); // +0*potIntegral(1,stucture, + // cavityType,phase)+0*potIntegral(2,stucture, + // cavityType,phase)); + // System.out.println("cki " + cki); + return cki; + } - /** - *

- * setRefFug. - *

- * - * @param compNumbm a int - * @param val a double - */ - public void setRefFug(int compNumbm, double val) { - reffug[compNumbm] = val; - } + /** + *

+ * setRefFug. + *

+ * + * @param compNumbm a int + * @param val a double + */ + public void setRefFug(int compNumbm, double val) { + reffug[compNumbm] = val; + } - /** - *

- * potIntegral. - *

- * - * @param intnumb a int - * @param stucture a int - * @param cavityType a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double potIntegral(int intnumb, int stucture, int cavityType, PhaseInterface phase) { - double val = 0.0; - double endval = cavRadius[intnumb][stucture][cavityType] - getSphericalCoreRadius(); - double x = 0.0, step = endval / 100.0; - x = step; - for (int i = 1; i < 100; i++) { - // System.out.println("x" +x); - // System.out.println("pot " + getPot(x,stucture,cavityType,phase)); - val += step * ((getPot(intnumb, x, stucture, cavityType, phase) - + 4 * getPot(intnumb, (x + 0.5 * step), stucture, cavityType, phase) - + getPot(intnumb, x + step, stucture, cavityType, phase)) / 6.0); - x = i * step; - } - return val / 100000.0; + /** + *

+ * potIntegral. + *

+ * + * @param intnumb a int + * @param stucture a int + * @param cavityType a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double potIntegral(int intnumb, int stucture, int cavityType, PhaseInterface phase) { + double val = 0.0; + double endval = cavRadius[intnumb][stucture][cavityType] - getSphericalCoreRadius(); + double x = 0.0; + double step = endval / 100.0; + x = step; + for (int i = 1; i < 100; i++) { + // System.out.println("x" +x); + // System.out.println("pot " + getPot(x,stucture,cavityType,phase)); + val += step * ((getPot(intnumb, x, stucture, cavityType, phase) + + 4 * getPot(intnumb, (x + 0.5 * step), stucture, cavityType, phase) + + getPot(intnumb, x + step, stucture, cavityType, phase)) / 6.0); + x = i * step; } + return val / 100000.0; + } - /** - *

- * getPot. - *

- * - * @param intnumb a int - * @param radius a double - * @param struccture a int - * @param cavityType a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double getPot(int intnumb, double radius, int struccture, int cavityType, - PhaseInterface phase) { - double lenjonsenergy = Math.sqrt(this.getLennardJonesEnergyParameter() - * phase.getComponent("water").getLennardJonesEnergyParameter()); - double diam = (this.getLennardJonesMolecularDiameter() - + phase.getComponent("water").getLennardJonesMolecularDiameter()) / 2.0; - double corerad = (this.getSphericalCoreRadius() - + phase.getComponent("water").getSphericalCoreRadius()) / 2.0; + /** + *

+ * getPot. + *

+ * + * @param intnumb a int + * @param radius a double + * @param struccture a int + * @param cavityType a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double getPot(int intnumb, double radius, int struccture, int cavityType, + PhaseInterface phase) { + double lenjonsenergy = Math.sqrt(this.getLennardJonesEnergyParameter() + * phase.getComponent("water").getLennardJonesEnergyParameter()); + double diam = (this.getLennardJonesMolecularDiameter() + + phase.getComponent("water").getLennardJonesMolecularDiameter()) / 2.0; + double corerad = + (this.getSphericalCoreRadius() + phase.getComponent("water").getSphericalCoreRadius()) + / 2.0; - double pot = 2.0 * coordNumb[intnumb][struccture][cavityType] * lenjonsenergy * ((Math - .pow(diam, 12.0) - / (Math.pow(cavRadius[intnumb][struccture][cavityType], 11.0) * radius) - * (delt(intnumb, 10.0, radius, struccture, cavityType, phase) - + corerad / cavRadius[intnumb][struccture][cavityType] - * delt(intnumb, 11.0, radius, struccture, cavityType, phase))) - - (Math.pow(diam, 6.0) - / (Math.pow(cavRadius[intnumb][struccture][cavityType], 5.0) * radius) - * (delt(intnumb, 4.0, radius, struccture, cavityType, phase) + corerad - / cavRadius[intnumb][struccture][cavityType] - * delt(intnumb, 5.0, radius, struccture, cavityType, phase)))); + double pot = 2.0 * coordNumb[intnumb][struccture][cavityType] * lenjonsenergy * ((Math.pow(diam, + 12.0) + / (Math.pow(cavRadius[intnumb][struccture][cavityType], 11.0) * radius) + * (delt(intnumb, 10.0, radius, struccture, cavityType, phase) + + corerad / cavRadius[intnumb][struccture][cavityType] + * delt(intnumb, 11.0, radius, struccture, cavityType, phase))) + - (Math.pow(diam, 6.0) + / (Math.pow(cavRadius[intnumb][struccture][cavityType], 5.0) * radius) + * (delt(intnumb, 4.0, radius, struccture, cavityType, phase) + + corerad / cavRadius[intnumb][struccture][cavityType] + * delt(intnumb, 5.0, radius, struccture, cavityType, phase)))); - // intnumb++; - // pot += 2.0*coordNumb[intnumb][struccture][cavityType]*lenjonsenergy*( - // (Math.pow(diam,12.0)/(Math.pow(cavRadius[intnumb][struccture][cavityType],11.0)* - // radius)*(delt(intnumb,10.0,radius,struccture,cavityType,phase)+corerad/cavRadius[intnumb][struccture][cavityType]*delt(intnumb,11.0,radius,struccture,cavityType,phase))) - // - - // (Math.pow(diam,6.0)/(Math.pow(cavRadius[intnumb][struccture][cavityType],5.0)* - // radius)*(delt(intnumb, - // 4.0,radius,struccture,cavityType,phase)+corerad/cavRadius[intnumb][struccture][cavityType]*delt(intnumb,5.0,radius,struccture,cavityType,phase))) - // ); + // intnumb++; + // pot += 2.0*coordNumb[intnumb][struccture][cavityType]*lenjonsenergy*( + // (Math.pow(diam,12.0)/(Math.pow(cavRadius[intnumb][struccture][cavityType],11.0)* + // radius)*(delt(intnumb,10.0,radius,struccture,cavityType,phase)+corerad/cavRadius[intnumb][struccture][cavityType]*delt(intnumb,11.0,radius,struccture,cavityType,phase))) + // - + // (Math.pow(diam,6.0)/(Math.pow(cavRadius[intnumb][struccture][cavityType],5.0)* + // radius)*(delt(intnumb, + // 4.0,radius,struccture,cavityType,phase)+corerad/cavRadius[intnumb][struccture][cavityType]*delt(intnumb,5.0,radius,struccture,cavityType,phase))) + // ); - // intnumb++; - // pot += 2.0*coordNumb[intnumb][struccture][cavityType]*lenjonsenergy*( - // (Math.pow(diam,12.0)/(Math.pow(cavRadius[intnumb][struccture][cavityType],11.0)* - // radius)*(delt(intnumb,10.0,radius,struccture,cavityType,phase)+corerad/cavRadius[intnumb][struccture][cavityType]*delt(intnumb,11.0,radius,struccture,cavityType,phase))) - // - - // (Math.pow(diam,6.0)/(Math.pow(cavRadius[intnumb][struccture][cavityType],5.0)* - // radius)*(delt(intnumb, - // 4.0,radius,struccture,cavityType,phase)+corerad/cavRadius[intnumb][struccture][cavityType]*delt(intnumb,5.0,radius,struccture,cavityType,phase))) - // ); + // intnumb++; + // pot += 2.0*coordNumb[intnumb][struccture][cavityType]*lenjonsenergy*( + // (Math.pow(diam,12.0)/(Math.pow(cavRadius[intnumb][struccture][cavityType],11.0)* + // radius)*(delt(intnumb,10.0,radius,struccture,cavityType,phase)+corerad/cavRadius[intnumb][struccture][cavityType]*delt(intnumb,11.0,radius,struccture,cavityType,phase))) + // - + // (Math.pow(diam,6.0)/(Math.pow(cavRadius[intnumb][struccture][cavityType],5.0)* + // radius)*(delt(intnumb, + // 4.0,radius,struccture,cavityType,phase)+corerad/cavRadius[intnumb][struccture][cavityType]*delt(intnumb,5.0,radius,struccture,cavityType,phase))) + // ); - // System.out.println("lenjones " +this.getLennardJonesMolecularDiameter() ); - // System.out.println("pot bef " + pot); - pot = Math.exp(-pot / (phase.getTemperature())) * radius * radius / 1.0e20; - // System.out.println("pot " + pot); - return pot; - } + // System.out.println("lenjones " +this.getLennardJonesMolecularDiameter() ); + // System.out.println("pot bef " + pot); + pot = Math.exp(-pot / (phase.getTemperature())) * radius * radius / 1.0e20; + // System.out.println("pot " + pot); + return pot; + } - /** - *

- * delt. - *

- * - * @param intnumb a int - * @param n a double - * @param radius a double - * @param struccture a int - * @param cavityType a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double delt(int intnumb, double n, double radius, int struccture, int cavityType, - PhaseInterface phase) { - // double lenjonsenergy = Math.sqrt(this.getLennardJonesEnergyParameter() * - // phase.getComponent("water").getLennardJonesEnergyParameter()); - // double diam = (this.getLennardJonesMolecularDiameter() + - // phase.getComponent("water").getLennardJonesMolecularDiameter()) / 2.0; - double corerad = (this.getSphericalCoreRadius() - + phase.getComponent("water").getSphericalCoreRadius()) / 2.0; + /** + *

+ * delt. + *

+ * + * @param intnumb a int + * @param n a double + * @param radius a double + * @param struccture a int + * @param cavityType a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double delt(int intnumb, double n, double radius, int struccture, int cavityType, + PhaseInterface phase) { + // double lenjonsenergy = Math.sqrt(this.getLennardJonesEnergyParameter() * + // phase.getComponent("water").getLennardJonesEnergyParameter()); + // double diam = (this.getLennardJonesMolecularDiameter() + + // phase.getComponent("water").getLennardJonesMolecularDiameter()) / 2.0; + double corerad = + (this.getSphericalCoreRadius() + phase.getComponent("water").getSphericalCoreRadius()) + / 2.0; - double delt = 1.0 / n - * (Math.pow(1.0 - radius / cavRadius[intnumb][struccture][cavityType] - - corerad / cavRadius[intnumb][struccture][cavityType], -n) - - Math.pow( - 1.0 + radius / cavRadius[intnumb][struccture][cavityType] - - corerad / cavRadius[intnumb][struccture][cavityType], - -n)); + double delt = 1.0 / n + * (Math + .pow(1.0 - radius / cavRadius[intnumb][struccture][cavityType] + - corerad / cavRadius[intnumb][struccture][cavityType], -n) + - Math.pow(1.0 + radius / cavRadius[intnumb][struccture][cavityType] + - corerad / cavRadius[intnumb][struccture][cavityType], -n)); - // System.out.println("delt " + delt); - return delt; - } + // System.out.println("delt " + delt); + return delt; + } } diff --git a/src/main/java/neqsim/thermo/component/ComponentPCSAFT.java b/src/main/java/neqsim/thermo/component/ComponentPCSAFT.java index bc826603e3..c243c2128c 100644 --- a/src/main/java/neqsim/thermo/component/ComponentPCSAFT.java +++ b/src/main/java/neqsim/thermo/component/ComponentPCSAFT.java @@ -14,465 +14,464 @@ * @version $Id: $Id */ public class ComponentPCSAFT extends ComponentSrk { - private static final long serialVersionUID = 1000; - - private double dSAFTi = 1.0, dmSAFTdi = 1.0; - double dghsSAFTdi, dnSAFTdi = 1.0, dahsSAFTdi = 1.0, dlogghsSAFTdi = 1.0; - - private double F1dispVolTermdn = 1.0, F1dispSumTermdn = 1.0, F1dispI1dn = 1.0, F2dispI2dn = 1.0, - F2dispZHCdn = 1.0, F2dispVolTermdn = 1.0, F2dispSumTermdn = 1; - - int useHS = 1, useDISP1 = 1, useDISP2 = 1; - - /** - *

- * Constructor for ComponentPCSAFT. - *

- * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int - */ - public ComponentPCSAFT(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + private static final long serialVersionUID = 1000; + + private double dSAFTi = 1.0; + private double dmSAFTdi = 1.0; + double dghsSAFTdi; + double dnSAFTdi = 1.0; + double dahsSAFTdi = 1.0; + double dlogghsSAFTdi = 1.0; + private double F1dispVolTermdn = 1.0; + private double F1dispSumTermdn = 1.0; + private double F1dispI1dn = 1.0; + private double F2dispI2dn = 1.0; + private double F2dispZHCdn = 1.0; + private double F2dispVolTermdn = 1.0; + private double F2dispSumTermdn = 1; + int useHS = 1; + int useDISP1 = 1; + int useDISP2 = 1; + + /** + *

+ * Constructor for ComponentPCSAFT. + *

+ * + * @param component_name a {@link java.lang.String} object + * @param moles a double + * @param molesInPhase a double + * @param compnumber a int + */ + public ComponentPCSAFT(String component_name, double moles, double molesInPhase, int compnumber) { + super(component_name, moles, molesInPhase, compnumber); + } + + /** + *

+ * Constructor for ComponentPCSAFT. + *

+ * + * @param number a int + * @param TC a double + * @param PC a double + * @param M a double + * @param a a double + * @param moles a double + */ + public ComponentPCSAFT(int number, double TC, double PC, double M, double a, double moles) { + super(number, TC, PC, M, a, moles); + } + + /** {@inheritDoc} */ + @Override + public ComponentPCSAFT clone() { + ComponentPCSAFT clonedComponent = null; + try { + clonedComponent = (ComponentPCSAFT) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); } - /** - *

- * Constructor for ComponentPCSAFT. - *

- * - * @param number a int - * @param TC a double - * @param PC a double - * @param M a double - * @param a a double - * @param moles a double - */ - public ComponentPCSAFT(int number, double TC, double PC, double M, double a, double moles) { - super(number, TC, PC, M, a, moles); + return clonedComponent; + } + + /** {@inheritDoc} */ + @Override + public void init(double temperature, double pressure, double totalNumberOfMoles, double beta, + int type) { + setdSAFTi(getSigmaSAFTi() * (1.0 - 0.12 * Math.exp(-3.0 * getEpsikSAFT() / temperature))); + super.init(temperature, pressure, totalNumberOfMoles, beta, type); + } + + /** {@inheritDoc} */ + @Override + public void Finit(PhaseInterface phase, double temp, double pres, double totMoles, double beta, + int numberOfComponents, int type) { + super.Finit(phase, temp, pres, totMoles, beta, numberOfComponents, type); + setDnSAFTdi(calcdnSAFTdi(phase, numberOfComponents, temp, pres)); + setDghsSAFTdi(calcdghsSAFTdi(phase, numberOfComponents, temp, pres)); + setDlogghsSAFTdi(1.0 / ((PhasePCSAFT) phase).getGhsSAFT() * getDghsSAFTdi()); + setDmSAFTdi(calcdmSAFTdi(phase, numberOfComponents, temp, pres)); + setdahsSAFTdi(calcdahsSAFTdi(phase, numberOfComponents, temp, pres)); + + F1dispVolTermdn = 1.0 * ThermodynamicConstantsInterface.avagadroNumber + / ((PhasePCSAFT) phase).getVolumeSAFT(); + F2dispVolTermdn = F1dispVolTermdn; + F1dispSumTermdn = calcF1dispSumTermdn(phase, numberOfComponents, temp, pres); + F2dispSumTermdn = calcF2dispSumTermdn(phase, numberOfComponents, temp, pres); + F1dispI1dn = ((PhasePCSAFT) phase).calcF1dispI1dN() * getDnSAFTdi() + + ((PhasePCSAFT) phase).calcF1dispI1dm() * getDmSAFTdi(); + F2dispI2dn = ((PhasePCSAFT) phase).calcF2dispI2dN() * getDnSAFTdi() + + ((PhasePCSAFT) phase).calcF2dispI2dm() * getDmSAFTdi(); + + F2dispZHCdn = ((PhasePCSAFT) phase).getF2dispZHCdN() * getDnSAFTdi() + + ((PhasePCSAFT) phase).getF2dispZHCdm() * getDmSAFTdi(); + // System.out.println("fugacity " + getFugacityCoefficient()); + } + + /** {@inheritDoc} */ + @Override + public double dFdN(PhaseInterface phase, int numberOfComponents, double temperature, + double pressure) { + // System.out.println("term getF " + + // ((PhasePCSAFT)phase).getF()/phase.getNumberOfMolesInPhase()); + // System.out.println("term getF21 " + + // dF_HC_SAFTdN(phase,numberOfComponents,temperature,pressure)); + // System.out.println("term getF22 " + + // dF_DISP1_SAFTdN(phase,numberOfComponents,temperature,pressure)); + // System.out.println("term getF23 " + + // dF_DISP2_SAFTdN(phase,numberOfComponents,temperature,pressure)); + + // System.out.println("term furgacity coef " + getFugacityCoefficient()); + return useHS * dF_HC_SAFTdN(phase, numberOfComponents, temperature, pressure) + + useDISP1 * dF_DISP1_SAFTdN(phase, numberOfComponents, temperature, pressure) + + useDISP2 * dF_DISP2_SAFTdN(phase, numberOfComponents, temperature, pressure); + } + + /** + *

+ * dF_HC_SAFTdN. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComponents a int + * @param temperature a double + * @param pressure a double + * @return a double + */ + public double dF_HC_SAFTdN(PhaseInterface phase, int numberOfComponents, double temperature, + double pressure) { + return ((PhasePCSAFT) phase).F_HC_SAFT() / phase.getNumberOfMolesInPhase() + + phase.getNumberOfMolesInPhase() * (getDmSAFTdi() * ((PhasePCSAFT) phase).getAHSSAFT() + + ((PhasePCSAFT) phase).getmSAFT() * getdahsSAFTdi() + - (mSAFTi - 1.0) / phase.getNumberOfMolesInPhase() + * Math.log(((PhasePCSAFT) phase).getGhsSAFT()) + + ((PhasePCSAFT) phase).getMmin1SAFT() / phase.getNumberOfMolesInPhase() + * Math.log(((PhasePCSAFT) phase).getGhsSAFT()) + - ((PhasePCSAFT) phase).getMmin1SAFT() * getDlogghsSAFTdi()); /// (ThermodynamicConstantsInterface.R*temperature); + } + + /** + *

+ * dF_DISP1_SAFTdN. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComponents a int + * @param temperature a double + * @param pressure a double + * @return a double + */ + public double dF_DISP1_SAFTdN(PhaseInterface phase, int numberOfComponents, double temperature, + double pressure) { + return ((PhasePCSAFT) phase).F_DISP1_SAFT() / phase.getNumberOfMolesInPhase() + phase + .getNumberOfMolesInPhase() + * ((-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTermdn + * ((PhasePCSAFT) phase).getF1dispSumTerm() * ((PhasePCSAFT) phase).getF1dispI1() + - 2.0 * ThermodynamicConstantsInterface.pi * ((PhasePCSAFT) phase).getF1dispVolTerm() + * F1dispSumTermdn * ((PhasePCSAFT) phase).getF1dispI1() + - 2.0 * ThermodynamicConstantsInterface.pi * ((PhasePCSAFT) phase).getF1dispVolTerm() + * ((PhasePCSAFT) phase).getF1dispSumTerm() * F1dispI1dn)); /// (ThermodynamicConstantsInterface.R*temperature); + } + + /** + *

+ * calcdmSAFTdi. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param nuberOfComponents a int + * @param temp a double + * @param pres a double + * @return a double + */ + public double calcdmSAFTdi(PhaseInterface phase, int nuberOfComponents, double temp, + double pres) { + return mSAFTi / phase.getNumberOfMolesInPhase() + - ((PhasePCSAFT) phase).getmSAFT() / phase.getNumberOfMolesInPhase(); + } + + /** + *

+ * dF_DISP2_SAFTdN. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComponents a int + * @param temperature a double + * @param pressure a double + * @return a double + */ + public double dF_DISP2_SAFTdN(PhaseInterface phase, int numberOfComponents, double temperature, + double pressure) { + return ((PhasePCSAFT) phase).F_DISP2_SAFT() / phase.getNumberOfMolesInPhase() + + phase.getNumberOfMolesInPhase() * ((-ThermodynamicConstantsInterface.pi * getDmSAFTdi() + * ((PhasePCSAFT) phase).getF1dispVolTerm() * ((PhasePCSAFT) phase).getF2dispSumTerm() + * ((PhasePCSAFT) phase).getF2dispI2() * ((PhasePCSAFT) phase).getF2dispZHC() + - ThermodynamicConstantsInterface.pi * ((PhasePCSAFT) phase).getmSAFT() + * F2dispVolTermdn * ((PhasePCSAFT) phase).getF2dispSumTerm() + * ((PhasePCSAFT) phase).getF2dispI2() * ((PhasePCSAFT) phase).getF2dispZHC() + - ThermodynamicConstantsInterface.pi * ((PhasePCSAFT) phase).getmSAFT() + * ((PhasePCSAFT) phase).getF1dispVolTerm() * F2dispSumTermdn + * ((PhasePCSAFT) phase).getF2dispI2() * ((PhasePCSAFT) phase).getF2dispZHC() + - ThermodynamicConstantsInterface.pi * ((PhasePCSAFT) phase).getmSAFT() + * ((PhasePCSAFT) phase).getF1dispVolTerm() + * ((PhasePCSAFT) phase).getF2dispSumTerm() * F2dispI2dn + * ((PhasePCSAFT) phase).getF2dispZHC() + - ThermodynamicConstantsInterface.pi * ((PhasePCSAFT) phase).getmSAFT() + * ((PhasePCSAFT) phase).getF1dispVolTerm() + * ((PhasePCSAFT) phase).getF2dispSumTerm() * ((PhasePCSAFT) phase).getF2dispI2() + * F2dispZHCdn)); /// (ThermodynamicConstantsInterface.R*temperature); + } + + /** + *

+ * calcF1dispSumTermdn. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComponents a int + * @param temperature a double + * @param pressure a double + * @return a double + */ + public double calcF1dispSumTermdn(PhaseInterface phase, int numberOfComponents, + double temperature, double pressure) { + double temp1 = 0.0; + for (int i = 0; i < phase.getNumberOfComponents(); i++) { + temp1 += phase.getComponent(i).getNumberOfMolesInPhase() * phase.getComponent(i).getmSAFTi() + * getmSAFTi() + * Math.sqrt( + getEpsikSAFT() / temperature * phase.getComponent(i).getEpsikSAFT() / temperature) + * (1.0 - ((PhaseEosInterface) phase).getMixingRule() + .getBinaryInteractionParameter(componentNumber, i)) + * Math.pow(0.5 * (phase.getComponent(i).getSigmaSAFTi() + getSigmaSAFTi()), 3.0); } - - /** {@inheritDoc} */ - @Override - public ComponentPCSAFT clone() { - ComponentPCSAFT clonedComponent = null; - try { - clonedComponent = (ComponentPCSAFT) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } - - return clonedComponent; - } - - /** {@inheritDoc} */ - @Override - public void init(double temperature, double pressure, double totalNumberOfMoles, double beta, - int type) { - setdSAFTi(getSigmaSAFTi() * (1.0 - 0.12 * Math.exp(-3.0 * getEpsikSAFT() / temperature))); - super.init(temperature, pressure, totalNumberOfMoles, beta, type); - } - - /** {@inheritDoc} */ - @Override - public void Finit(PhaseInterface phase, double temp, double pres, double totMoles, double beta, - int numberOfComponents, int type) { - super.Finit(phase, temp, pres, totMoles, beta, numberOfComponents, type); - setDnSAFTdi(calcdnSAFTdi(phase, numberOfComponents, temp, pres)); - setDghsSAFTdi(calcdghsSAFTdi(phase, numberOfComponents, temp, pres)); - setDlogghsSAFTdi(1.0 / ((PhasePCSAFT) phase).getGhsSAFT() * getDghsSAFTdi()); - setDmSAFTdi(calcdmSAFTdi(phase, numberOfComponents, temp, pres)); - setdahsSAFTdi(calcdahsSAFTdi(phase, numberOfComponents, temp, pres)); - - F1dispVolTermdn = 1.0 * ThermodynamicConstantsInterface.avagadroNumber - / ((PhasePCSAFT) phase).getVolumeSAFT(); - F2dispVolTermdn = F1dispVolTermdn; - F1dispSumTermdn = calcF1dispSumTermdn(phase, numberOfComponents, temp, pres); - F2dispSumTermdn = calcF2dispSumTermdn(phase, numberOfComponents, temp, pres); - F1dispI1dn = ((PhasePCSAFT) phase).calcF1dispI1dN() * getDnSAFTdi() - + ((PhasePCSAFT) phase).calcF1dispI1dm() * getDmSAFTdi(); - F2dispI2dn = ((PhasePCSAFT) phase).calcF2dispI2dN() * getDnSAFTdi() - + ((PhasePCSAFT) phase).calcF2dispI2dm() * getDmSAFTdi(); - - F2dispZHCdn = ((PhasePCSAFT) phase).getF2dispZHCdN() * getDnSAFTdi() - + ((PhasePCSAFT) phase).getF2dispZHCdm() * getDmSAFTdi(); - // System.out.println("fugacity " + getFugacityCoefficient()); - } - - /** {@inheritDoc} */ - @Override - public double dFdN(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure) { - // System.out.println("term getF " + - // ((PhasePCSAFT)phase).getF()/phase.getNumberOfMolesInPhase()); - // System.out.println("term getF21 " + - // dF_HC_SAFTdN(phase,numberOfComponents,temperature,pressure)); - // System.out.println("term getF22 " + - // dF_DISP1_SAFTdN(phase,numberOfComponents,temperature,pressure)); - // System.out.println("term getF23 " + - // dF_DISP2_SAFTdN(phase,numberOfComponents,temperature,pressure)); - - // System.out.println("term furgacity coef " + getFugacityCoefficient()); - return useHS * dF_HC_SAFTdN(phase, numberOfComponents, temperature, pressure) - + useDISP1 * dF_DISP1_SAFTdN(phase, numberOfComponents, temperature, pressure) - + useDISP2 * dF_DISP2_SAFTdN(phase, numberOfComponents, temperature, pressure); - } - - /** - *

- * dF_HC_SAFTdN. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComponents a int - * @param temperature a double - * @param pressure a double - * @return a double - */ - public double dF_HC_SAFTdN(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure) { - return ((PhasePCSAFT) phase).F_HC_SAFT() / phase.getNumberOfMolesInPhase() + phase - .getNumberOfMolesInPhase() - * (getDmSAFTdi() * ((PhasePCSAFT) phase).getAHSSAFT() - + ((PhasePCSAFT) phase).getmSAFT() * getdahsSAFTdi() - - (mSAFTi - 1.0) / phase.getNumberOfMolesInPhase() - * Math.log(((PhasePCSAFT) phase).getGhsSAFT()) - + ((PhasePCSAFT) phase).getMmin1SAFT() / phase.getNumberOfMolesInPhase() - * Math.log(((PhasePCSAFT) phase).getGhsSAFT()) - - ((PhasePCSAFT) phase).getMmin1SAFT() * getDlogghsSAFTdi());/// (ThermodynamicConstantsInterface.R*temperature); - } - - /** - *

- * dF_DISP1_SAFTdN. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComponents a int - * @param temperature a double - * @param pressure a double - * @return a double - */ - public double dF_DISP1_SAFTdN(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure) { - return ((PhasePCSAFT) phase).F_DISP1_SAFT() / phase.getNumberOfMolesInPhase() - + phase.getNumberOfMolesInPhase() * ((-2.0 * ThermodynamicConstantsInterface.pi - * F1dispVolTermdn * ((PhasePCSAFT) phase).getF1dispSumTerm() - * ((PhasePCSAFT) phase).getF1dispI1() - - 2.0 * ThermodynamicConstantsInterface.pi - * ((PhasePCSAFT) phase).getF1dispVolTerm() * F1dispSumTermdn - * ((PhasePCSAFT) phase).getF1dispI1() - - 2.0 * ThermodynamicConstantsInterface.pi - * ((PhasePCSAFT) phase).getF1dispVolTerm() - * ((PhasePCSAFT) phase).getF1dispSumTerm() * F1dispI1dn));/// (ThermodynamicConstantsInterface.R*temperature); - } - - /** - *

- * calcdmSAFTdi. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param nuberOfComponents a int - * @param temp a double - * @param pres a double - * @return a double - */ - public double calcdmSAFTdi(PhaseInterface phase, int nuberOfComponents, double temp, - double pres) { - return mSAFTi / phase.getNumberOfMolesInPhase() - - ((PhasePCSAFT) phase).getmSAFT() / phase.getNumberOfMolesInPhase(); - } - - /** - *

- * dF_DISP2_SAFTdN. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComponents a int - * @param temperature a double - * @param pressure a double - * @return a double - */ - public double dF_DISP2_SAFTdN(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure) { - return ((PhasePCSAFT) phase).F_DISP2_SAFT() / phase.getNumberOfMolesInPhase() - + phase.getNumberOfMolesInPhase() * ((-ThermodynamicConstantsInterface.pi - * getDmSAFTdi() * ((PhasePCSAFT) phase).getF1dispVolTerm() - * ((PhasePCSAFT) phase).getF2dispSumTerm() - * ((PhasePCSAFT) phase).getF2dispI2() * ((PhasePCSAFT) phase).getF2dispZHC() - - ThermodynamicConstantsInterface.pi * ((PhasePCSAFT) phase).getmSAFT() - * F2dispVolTermdn * ((PhasePCSAFT) phase).getF2dispSumTerm() - * ((PhasePCSAFT) phase).getF2dispI2() - * ((PhasePCSAFT) phase).getF2dispZHC() - - ThermodynamicConstantsInterface.pi * ((PhasePCSAFT) phase).getmSAFT() - * ((PhasePCSAFT) phase).getF1dispVolTerm() * F2dispSumTermdn - * ((PhasePCSAFT) phase).getF2dispI2() - * ((PhasePCSAFT) phase).getF2dispZHC() - - ThermodynamicConstantsInterface.pi * ((PhasePCSAFT) phase).getmSAFT() - * ((PhasePCSAFT) phase).getF1dispVolTerm() - * ((PhasePCSAFT) phase).getF2dispSumTerm() * F2dispI2dn - * ((PhasePCSAFT) phase).getF2dispZHC() - - ThermodynamicConstantsInterface.pi * ((PhasePCSAFT) phase).getmSAFT() - * ((PhasePCSAFT) phase).getF1dispVolTerm() - * ((PhasePCSAFT) phase).getF2dispSumTerm() - * ((PhasePCSAFT) phase).getF2dispI2() * F2dispZHCdn));/// (ThermodynamicConstantsInterface.R*temperature); - } - - /** - *

- * calcF1dispSumTermdn. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComponents a int - * @param temperature a double - * @param pressure a double - * @return a double - */ - public double calcF1dispSumTermdn(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure) { - double temp1 = 0.0; - for (int i = 0; i < phase.getNumberOfComponents(); i++) { - temp1 += phase.getComponent(i).getNumberOfMolesInPhase() - * phase.getComponent(i).getmSAFTi() * getmSAFTi() - * Math.sqrt(getEpsikSAFT() / temperature * phase.getComponent(i).getEpsikSAFT() - / temperature) - * (1.0 - ((PhaseEosInterface) phase).getMixingRule() - .getBinaryInteractionParameter(componentNumber, i)) - * Math.pow(0.5 * (phase.getComponent(i).getSigmaSAFTi() + getSigmaSAFTi()), - 3.0); - } - return -2.0 / Math.pow(phase.getNumberOfMolesInPhase(), 1.0) - * ((PhasePCSAFT) phase).getF1dispSumTerm() - + 2.0 * temp1 / Math.pow(phase.getNumberOfMolesInPhase(), 2.0); - } - - /** - *

- * calcF2dispSumTermdn. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComponents a int - * @param temperature a double - * @param pressure a double - * @return a double - */ - public double calcF2dispSumTermdn(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure) { - double temp1 = 0.0; - for (int i = 0; i < phase.getNumberOfComponents(); i++) { - temp1 += phase.getComponent(i).getNumberOfMolesInPhase() - * phase.getComponent(i).getmSAFTi() * getmSAFTi() * getEpsikSAFT() / temperature - * phase.getComponent(i).getEpsikSAFT() / temperature - * Math.pow((1.0 - ((PhaseEosInterface) phase).getMixingRule() - .getBinaryInteractionParameter(componentNumber, i)), 2.0) - * Math.pow(0.5 * (phase.getComponent(i).getSigmaSAFTi() + getSigmaSAFTi()), - 3.0); - // System.out.println("kij "+ - // ((PhaseEosInterface)phase).getMixingRule().getBinaryInteractionParameter(componentNumber, - // i)); - } - return -2.0 / Math.pow(phase.getNumberOfMolesInPhase(), 1.0) - * ((PhasePCSAFT) phase).getF2dispSumTerm() - + 2.0 * temp1 / Math.pow(phase.getNumberOfMolesInPhase(), 2.0); - } - - /** - *

- * calcdghsSAFTdi. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param nuberOfComponents a int - * @param temp a double - * @param pres a double - * @return a double - */ - public double calcdghsSAFTdi(PhaseInterface phase, int nuberOfComponents, double temp, - double pres) { - double temp1 = ((PhasePCSAFT) phase).getDgHSSAFTdN(); - return temp1 * getDnSAFTdi(); - } - - /** - *

- * calcdahsSAFTdi. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param nuberOfComponents a int - * @param temp a double - * @param pres a double - * @return a double - */ - public double calcdahsSAFTdi(PhaseInterface phase, int nuberOfComponents, double temp, - double pres) { - double temp1 = ((4.0 - 6.0 * ((PhasePCSAFT) phase).getNSAFT()) - * Math.pow(1.0 - ((PhasePCSAFT) phase).getNSAFT(), 2.0) - - (4.0 * ((PhasePCSAFT) phase).getNSAFT() - - 3.0 * Math.pow(((PhasePCSAFT) phase).getNSAFT(), 2.0)) * (-2.0) - * (1.0 - ((PhasePCSAFT) phase).getNSAFT())); - return temp1 / Math.pow(1.0 - ((PhasePCSAFT) phase).getNSAFT(), 4.0) * getDnSAFTdi(); - } - - /** - *

- * calcdnSAFTdi. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param nuberOfComponents a int - * @param temp a double - * @param pres a double - * @return a double - */ - public double calcdnSAFTdi(PhaseInterface phase, int nuberOfComponents, double temp, - double pres) { - double temp1 = phase.getNumberOfMolesInPhase() / ((PhasePCSAFT) phase).getVolumeSAFT() - * getmSAFTi() * Math.pow(getdSAFTi(), 3.0) * 1.0 / phase.getNumberOfMolesInPhase() - + 1.0 / ((PhasePCSAFT) phase).getVolumeSAFT() * ((PhasePCSAFT) phase).getDSAFT() - - 1.0 / Math.pow(phase.getNumberOfMolesInPhase(), 1.0) - * phase.getNumberOfMolesInPhase() / ((PhasePCSAFT) phase).getVolumeSAFT() - * ((PhasePCSAFT) phase).getDSAFT(); - return ThermodynamicConstantsInterface.pi / 6.0 - * ThermodynamicConstantsInterface.avagadroNumber * (temp1); - } - - /** - *

- * Getter for the field dSAFTi. - *

- * - * @return a double - */ - public double getdSAFTi() { - return dSAFTi; - } - - /** - *

- * Setter for the field dSAFTi. - *

- * - * @param di a double - */ - public void setdSAFTi(double di) { - this.dSAFTi = di; - } - - /** - *

- * Getter for the field dghsSAFTdi. - *

- * - * @return a double - */ - public double getDghsSAFTdi() { - return dghsSAFTdi; - } - - /** - *

- * Setter for the field dghsSAFTdi. - *

- * - * @param dghsSAFTdi a double - */ - public void setDghsSAFTdi(double dghsSAFTdi) { - this.dghsSAFTdi = dghsSAFTdi; - } - - /** - *

- * Getter for the field dnSAFTdi. - *

- * - * @return a double - */ - public double getDnSAFTdi() { - return dnSAFTdi; - } - - /** - *

- * Setter for the field dnSAFTdi. - *

- * - * @param dnSAFTdi a double - */ - public void setDnSAFTdi(double dnSAFTdi) { - this.dnSAFTdi = dnSAFTdi; - } - - /** - *

- * Getter for the field dahsSAFTdi. - *

- * - * @return a double - */ - public double getdahsSAFTdi() { - return dahsSAFTdi; - } - - /** - *

- * Setter for the field dahsSAFTdi. - *

- * - * @param dahsSAFTdi a double - */ - public void setdahsSAFTdi(double dahsSAFTdi) { - this.dahsSAFTdi = dahsSAFTdi; - } - - /** - *

- * Getter for the field dmSAFTdi. - *

- * - * @return a double - */ - public double getDmSAFTdi() { - return dmSAFTdi; - } - - /** - *

- * Setter for the field dmSAFTdi. - *

- * - * @param dmSAFTdi a double - */ - public void setDmSAFTdi(double dmSAFTdi) { - this.dmSAFTdi = dmSAFTdi; - } - - /** - *

- * Getter for the field dlogghsSAFTdi. - *

- * - * @return a double - */ - public double getDlogghsSAFTdi() { - return dlogghsSAFTdi; - } - - /** - *

- * Setter for the field dlogghsSAFTdi. - *

- * - * @param dlogghsSAFTdi a double - */ - public void setDlogghsSAFTdi(double dlogghsSAFTdi) { - this.dlogghsSAFTdi = dlogghsSAFTdi; + return -2.0 / Math.pow(phase.getNumberOfMolesInPhase(), 1.0) + * ((PhasePCSAFT) phase).getF1dispSumTerm() + + 2.0 * temp1 / Math.pow(phase.getNumberOfMolesInPhase(), 2.0); + } + + /** + *

+ * calcF2dispSumTermdn. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComponents a int + * @param temperature a double + * @param pressure a double + * @return a double + */ + public double calcF2dispSumTermdn(PhaseInterface phase, int numberOfComponents, + double temperature, double pressure) { + double temp1 = 0.0; + for (int i = 0; i < phase.getNumberOfComponents(); i++) { + temp1 += phase.getComponent(i).getNumberOfMolesInPhase() * phase.getComponent(i).getmSAFTi() + * getmSAFTi() * getEpsikSAFT() / temperature * phase.getComponent(i).getEpsikSAFT() + / temperature + * Math.pow((1.0 - ((PhaseEosInterface) phase).getMixingRule() + .getBinaryInteractionParameter(componentNumber, i)), 2.0) + * Math.pow(0.5 * (phase.getComponent(i).getSigmaSAFTi() + getSigmaSAFTi()), 3.0); + // System.out.println("kij "+ + // ((PhaseEosInterface)phase).getMixingRule().getBinaryInteractionParameter(componentNumber, + // i)); } + return -2.0 / Math.pow(phase.getNumberOfMolesInPhase(), 1.0) + * ((PhasePCSAFT) phase).getF2dispSumTerm() + + 2.0 * temp1 / Math.pow(phase.getNumberOfMolesInPhase(), 2.0); + } + + /** + *

+ * calcdghsSAFTdi. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param nuberOfComponents a int + * @param temp a double + * @param pres a double + * @return a double + */ + public double calcdghsSAFTdi(PhaseInterface phase, int nuberOfComponents, double temp, + double pres) { + double temp1 = ((PhasePCSAFT) phase).getDgHSSAFTdN(); + return temp1 * getDnSAFTdi(); + } + + /** + *

+ * calcdahsSAFTdi. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param nuberOfComponents a int + * @param temp a double + * @param pres a double + * @return a double + */ + public double calcdahsSAFTdi(PhaseInterface phase, int nuberOfComponents, double temp, + double pres) { + double temp1 = ((4.0 - 6.0 * ((PhasePCSAFT) phase).getNSAFT()) + * Math.pow(1.0 - ((PhasePCSAFT) phase).getNSAFT(), 2.0) + - (4.0 * ((PhasePCSAFT) phase).getNSAFT() + - 3.0 * Math.pow(((PhasePCSAFT) phase).getNSAFT(), 2.0)) * (-2.0) + * (1.0 - ((PhasePCSAFT) phase).getNSAFT())); + return temp1 / Math.pow(1.0 - ((PhasePCSAFT) phase).getNSAFT(), 4.0) * getDnSAFTdi(); + } + + /** + *

+ * calcdnSAFTdi. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param nuberOfComponents a int + * @param temp a double + * @param pres a double + * @return a double + */ + public double calcdnSAFTdi(PhaseInterface phase, int nuberOfComponents, double temp, + double pres) { + double temp1 = phase.getNumberOfMolesInPhase() / ((PhasePCSAFT) phase).getVolumeSAFT() + * getmSAFTi() * Math.pow(getdSAFTi(), 3.0) * 1.0 / phase.getNumberOfMolesInPhase() + + 1.0 / ((PhasePCSAFT) phase).getVolumeSAFT() * ((PhasePCSAFT) phase).getDSAFT() + - 1.0 / Math.pow(phase.getNumberOfMolesInPhase(), 1.0) * phase.getNumberOfMolesInPhase() + / ((PhasePCSAFT) phase).getVolumeSAFT() * ((PhasePCSAFT) phase).getDSAFT(); + return ThermodynamicConstantsInterface.pi / 6.0 * ThermodynamicConstantsInterface.avagadroNumber + * (temp1); + } + + /** + *

+ * Getter for the field dSAFTi. + *

+ * + * @return a double + */ + public double getdSAFTi() { + return dSAFTi; + } + + /** + *

+ * Setter for the field dSAFTi. + *

+ * + * @param di a double + */ + public void setdSAFTi(double di) { + this.dSAFTi = di; + } + + /** + *

+ * Getter for the field dghsSAFTdi. + *

+ * + * @return a double + */ + public double getDghsSAFTdi() { + return dghsSAFTdi; + } + + /** + *

+ * Setter for the field dghsSAFTdi. + *

+ * + * @param dghsSAFTdi a double + */ + public void setDghsSAFTdi(double dghsSAFTdi) { + this.dghsSAFTdi = dghsSAFTdi; + } + + /** + *

+ * Getter for the field dnSAFTdi. + *

+ * + * @return a double + */ + public double getDnSAFTdi() { + return dnSAFTdi; + } + + /** + *

+ * Setter for the field dnSAFTdi. + *

+ * + * @param dnSAFTdi a double + */ + public void setDnSAFTdi(double dnSAFTdi) { + this.dnSAFTdi = dnSAFTdi; + } + + /** + *

+ * Getter for the field dahsSAFTdi. + *

+ * + * @return a double + */ + public double getdahsSAFTdi() { + return dahsSAFTdi; + } + + /** + *

+ * Setter for the field dahsSAFTdi. + *

+ * + * @param dahsSAFTdi a double + */ + public void setdahsSAFTdi(double dahsSAFTdi) { + this.dahsSAFTdi = dahsSAFTdi; + } + + /** + *

+ * Getter for the field dmSAFTdi. + *

+ * + * @return a double + */ + public double getDmSAFTdi() { + return dmSAFTdi; + } + + /** + *

+ * Setter for the field dmSAFTdi. + *

+ * + * @param dmSAFTdi a double + */ + public void setDmSAFTdi(double dmSAFTdi) { + this.dmSAFTdi = dmSAFTdi; + } + + /** + *

+ * Getter for the field dlogghsSAFTdi. + *

+ * + * @return a double + */ + public double getDlogghsSAFTdi() { + return dlogghsSAFTdi; + } + + /** + *

+ * Setter for the field dlogghsSAFTdi. + *

+ * + * @param dlogghsSAFTdi a double + */ + public void setDlogghsSAFTdi(double dlogghsSAFTdi) { + this.dlogghsSAFTdi = dlogghsSAFTdi; + } } diff --git a/src/main/java/neqsim/thermo/component/ComponentPCSAFTa.java b/src/main/java/neqsim/thermo/component/ComponentPCSAFTa.java index a68cb4b9bf..c591bef13b 100644 --- a/src/main/java/neqsim/thermo/component/ComponentPCSAFTa.java +++ b/src/main/java/neqsim/thermo/component/ComponentPCSAFTa.java @@ -156,7 +156,7 @@ public double dFCPAdN(PhaseInterface phase, int numberOfComponents, double tempe for (int i = 0; i < numberOfAssociationSites; i++) { xi += Math.log(xsite[i]); } - return (xi - ((PhaseCPAInterface) phase).getHcpatot() / 2.0 * dlogghsSAFTdi);// calc_lngi(phase)); + return (xi - ((PhaseCPAInterface) phase).getHcpatot() / 2.0 * dlogghsSAFTdi); // calc_lngi(phase)); } /** diff --git a/src/main/java/neqsim/thermo/component/ComponentPR.java b/src/main/java/neqsim/thermo/component/ComponentPR.java index a188149006..a1db328c56 100644 --- a/src/main/java/neqsim/thermo/component/ComponentPR.java +++ b/src/main/java/neqsim/thermo/component/ComponentPR.java @@ -11,155 +11,155 @@ * @version $Id: $Id */ public class ComponentPR extends ComponentEos { - private static final long serialVersionUID = 1000; - - /** - *

- * Constructor for ComponentPR. - *

- * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int - */ - public ComponentPR(String component_name, double moles, double molesInPhase, int compnumber) { - super(component_name, moles, molesInPhase, compnumber); - - a = .45724333333 * R * R * criticalTemperature * criticalTemperature / criticalPressure; - b = .077803333 * R * criticalTemperature / criticalPressure; - // m = 0.37464 + 1.54226 * acentricFactor - 0.26992* acentricFactor * - // acentricFactor; - - delta1 = 1.0 + Math.sqrt(2.0); - delta2 = 1.0 - Math.sqrt(2.0); - setAttractiveParameter(new AttractiveTermPr(this)); - - double[] surfTensInfluenceParamtemp = {1.3192, 1.6606, 1.1173, 0.8443}; - this.surfTensInfluenceParam = surfTensInfluenceParamtemp; + private static final long serialVersionUID = 1000; + + /** + *

+ * Constructor for ComponentPR. + *

+ * + * @param component_name a {@link java.lang.String} object + * @param moles a double + * @param molesInPhase a double + * @param compnumber a int + */ + public ComponentPR(String component_name, double moles, double molesInPhase, int compnumber) { + super(component_name, moles, molesInPhase, compnumber); + + a = .45724333333 * R * R * criticalTemperature * criticalTemperature / criticalPressure; + b = .077803333 * R * criticalTemperature / criticalPressure; + // m = 0.37464 + 1.54226 * acentricFactor - 0.26992* acentricFactor * + // acentricFactor; + + delta1 = 1.0 + Math.sqrt(2.0); + delta2 = 1.0 - Math.sqrt(2.0); + setAttractiveParameter(new AttractiveTermPr(this)); + + double[] surfTensInfluenceParamtemp = {1.3192, 1.6606, 1.1173, 0.8443}; + this.surfTensInfluenceParam = surfTensInfluenceParamtemp; + } + + /** + *

+ * Constructor for ComponentPR. + *

+ * + * @param number a int + * @param TC a double + * @param PC a double + * @param M a double + * @param a a double + * @param moles a double + */ + public ComponentPR(int number, double TC, double PC, double M, double a, double moles) { + super(number, TC, PC, M, a, moles); + } + + /** {@inheritDoc} */ + @Override + public ComponentPR clone() { + ComponentPR clonedComponent = null; + try { + clonedComponent = (ComponentPR) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); } - /** - *

- * Constructor for ComponentPR. - *

- * - * @param number a int - * @param TC a double - * @param PC a double - * @param M a double - * @param a a double - * @param moles a double - */ - public ComponentPR(int number, double TC, double PC, double M, double a, double moles) { - super(number, TC, PC, M, a, moles); + return clonedComponent; + } + + /** {@inheritDoc} */ + @Override + public void init(double temperature, double pressure, double totalNumberOfMoles, double beta, + int type) { + super.init(temperature, pressure, totalNumberOfMoles, beta, type); + } + + /** {@inheritDoc} */ + @Override + public double calca() { + return .45724333333 * R * R * criticalTemperature * criticalTemperature / criticalPressure; + } + + /** {@inheritDoc} */ + @Override + public double calcb() { + return .077803333 * R * criticalTemperature / criticalPressure; + } + + /** {@inheritDoc} */ + @Override + public double getVolumeCorrection() { + if (ionicCharge != 0) { + return 0.0; } - - /** {@inheritDoc} */ - @Override - public ComponentPR clone() { - ComponentPR clonedComponent = null; - try { - clonedComponent = (ComponentPR) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } - - return clonedComponent; - } - - /** {@inheritDoc} */ - @Override - public void init(double temperature, double pressure, double totalNumberOfMoles, double beta, - int type) { - super.init(temperature, pressure, totalNumberOfMoles, beta, type); - } - - /** {@inheritDoc} */ - @Override - public double calca() { - return .45724333333 * R * R * criticalTemperature * criticalTemperature / criticalPressure; - } - - /** {@inheritDoc} */ - @Override - public double calcb() { - return .077803333 * R * criticalTemperature / criticalPressure; + if (Math.abs(getVolumeCorrectionConst()) > 1.0e-10) { + return getVolumeCorrectionConst() * b; + } else if (Math.abs(this.getRacketZ()) < 1e-10) { + racketZ = 0.29056 - 0.08775 * getAcentricFactor(); } - - /** {@inheritDoc} */ - @Override - public double getVolumeCorrection() { - if (ionicCharge != 0) { - return 0.0; - } - if (Math.abs(getVolumeCorrectionConst()) > 1.0e-10) { - return getVolumeCorrectionConst() * b; - } else if (Math.abs(this.getRacketZ()) < 1e-10) { - racketZ = 0.29056 - 0.08775 * getAcentricFactor(); - } - return 0.50033 * (0.25969 - this.getRacketZ()) * R * criticalTemperature / criticalPressure; - } - - /** - *

- * getQpure. - *

- * - * @param temperature a double - * @return a double - */ - public double getQpure(double temperature) { - return this.getaT() / (this.getb() * R * temperature); + return 0.50033 * (0.25969 - this.getRacketZ()) * R * criticalTemperature / criticalPressure; + } + + /** + *

+ * getQpure. + *

+ * + * @param temperature a double + * @return a double + */ + public double getQpure(double temperature) { + return this.getaT() / (this.getb() * R * temperature); + } + + /** + *

+ * getdQpuredT. + *

+ * + * @param temperature a double + * @return a double + */ + public double getdQpuredT(double temperature) { + return dqPuredT; + } + + /** + *

+ * getdQpuredTdT. + *

+ * + * @param temperature a double + * @return a double + */ + public double getdQpuredTdT(double temperature) { + return dqPuredTdT; + } + + /** {@inheritDoc} */ + @Override + public double getSurfaceTenisionInfluenceParameter(double temperature) { + double TR = 1.0 - temperature / getTC(); + if (TR < 0) { + TR = 0.5; } - - /** - *

- * getdQpuredT. - *

- * - * @param temperature a double - * @return a double - */ - public double getdQpuredT(double temperature) { - return dqPuredT; + double AA = + -1.0e-16 / (surfTensInfluenceParam[0] + surfTensInfluenceParam[1] * getAcentricFactor()); + double BB = + 1.0e-16 / (surfTensInfluenceParam[2] + surfTensInfluenceParam[3] * getAcentricFactor()); + + // System.out.println("scale2 " + aT * 1e-5 * Math.pow(b * 1e-5, 2.0 / 3.0) * + // (AA * TR + BB)); + if (componentName.equals("water")) { + AA = -6.99632E-17; + BB = 5.68347E-17; } - - /** - *

- * getdQpuredTdT. - *

- * - * @param temperature a double - * @return a double - */ - public double getdQpuredTdT(double temperature) { - return dqPuredTdT; - } - - /** {@inheritDoc} */ - @Override - public double getSurfaceTenisionInfluenceParameter(double temperature) { - double TR = 1.0 - temperature / getTC(); - if (TR < 0) { - TR = 0.5; - } - double AA = -1.0e-16 - / (surfTensInfluenceParam[0] + surfTensInfluenceParam[1] * getAcentricFactor()); - double BB = 1.0e-16 - / (surfTensInfluenceParam[2] + surfTensInfluenceParam[3] * getAcentricFactor()); - - // System.out.println("scale2 " + aT * 1e-5 * Math.pow(b * 1e-5, 2.0 / 3.0) * - // (AA * TR + BB)); - if (componentName.equals("water")) { - AA = -6.99632E-17; - BB = 5.68347E-17; - } - // System.out.println("AA " + AA + " BB " + BB); - if (componentName.equals("MEG")) { - return 0.00000000000000000007101030813216131; - } - return aT * 1e-5 * Math.pow(b * 1e-5, 2.0 / 3.0) * (AA * TR + BB);/// Math.pow(ThermodynamicConstantsInterface.avagadroNumber, - /// 2.0 / 3.0); + // System.out.println("AA " + AA + " BB " + BB); + if (componentName.equals("MEG")) { + return 0.00000000000000000007101030813216131; } + return aT * 1e-5 * Math.pow(b * 1e-5, 2.0 / 3.0) * (AA * TR + BB); /// Math.pow(ThermodynamicConstantsInterface.avagadroNumber, + /// 2.0 / 3.0); + } } diff --git a/src/main/java/neqsim/thermo/component/ComponentSrkCPA.java b/src/main/java/neqsim/thermo/component/ComponentSrkCPA.java index 1bc9bbbb4c..949bf57255 100644 --- a/src/main/java/neqsim/thermo/component/ComponentSrkCPA.java +++ b/src/main/java/neqsim/thermo/component/ComponentSrkCPA.java @@ -338,7 +338,7 @@ public double dFCPAdNdV(PhaseInterface phase, int numberOfComponents, double tem * phase.getComponent(k).getNumberOfMolesInPhase() * tot3; } */ // System.out.println("dFCPAdndV " + (xi - tot1 - tot4)); - return xi + tempar[0] * calc_lngi(phase) + tempar[1] * calc_lngidV(phase);// - tot1 - tot4; + return xi + tempar[0] * calc_lngi(phase) + tempar[1] * calc_lngidV(phase); // - tot1 - tot4; } /** @@ -359,7 +359,8 @@ public double dFCPAdNdT(PhaseInterface phase, int numberOfComponents, double tem xi += 1.0 / xsite[i] * xsitedT[i]; } - double tot1 = 0.0, tot2 = 0.0; + double tot1 = 0.0; + double tot2 = 0.0; for (int k = 0; k < phase.getNumberOfComponents(); k++) { tot2 = 0.0; for (int i = 0; i < phase.getComponent(k).getNumberOfAssociationSites(); i++) { @@ -636,7 +637,8 @@ public void setXsitedni(int xnumb, int compnumb, double val) { /** {@inheritDoc} */ @Override public double getSurfaceTenisionInfluenceParameter(double temperature) { - double AA = 0, BB = 0; + double AA = 0; + double BB = 0; if (componentName.equals("water")) { double TR = 1.0 - temperature / getTC(); AA = -2.2367E-16; diff --git a/src/main/java/neqsim/thermo/component/ComponentUMRCPA.java b/src/main/java/neqsim/thermo/component/ComponentUMRCPA.java index 837550442b..9da5e72436 100644 --- a/src/main/java/neqsim/thermo/component/ComponentUMRCPA.java +++ b/src/main/java/neqsim/thermo/component/ComponentUMRCPA.java @@ -13,659 +13,657 @@ * @version $Id: $Id */ public class ComponentUMRCPA extends ComponentPR implements ComponentCPAInterface { - private static final long serialVersionUID = 1000; - - int cpaon = 1; - double[] xsite = new double[0]; - private double[][] xsitedni = new double[0][0]; - double[] xsiteOld = new double[0]; - double[] xsitedV = new double[0]; - double[] xsitedT = new double[0]; - double[] xsitedTdT = new double[0]; - - /** - *

- * Constructor for ComponentSrkCPA. - *

- * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + private static final long serialVersionUID = 1000; + + int cpaon = 1; + double[] xsite = new double[0]; + private double[][] xsitedni = new double[0][0]; + double[] xsiteOld = new double[0]; + double[] xsitedV = new double[0]; + double[] xsitedT = new double[0]; + double[] xsitedTdT = new double[0]; + + /** + *

+ * Constructor for ComponentSrkCPA. + *

+ * + * @param component_name a {@link java.lang.String} object + * @param moles a double + * @param molesInPhase a double + * @param compnumber a int + */ + public ComponentUMRCPA(String component_name, double moles, double molesInPhase, int compnumber) { + super(component_name, moles, molesInPhase, compnumber); + xsite = new double[numberOfAssociationSites]; + xsitedni = new double[numberOfAssociationSites][100]; + xsitedV = new double[numberOfAssociationSites]; + xsitedT = new double[numberOfAssociationSites]; + xsitedTdT = new double[numberOfAssociationSites]; + xsiteOld = new double[numberOfAssociationSites]; + if (numberOfAssociationSites != 0 && cpaon == 1) { + // System.out.println("ass sites: " + numberOfAssociationSites); + // System.out.println("aSRK " + a + " aCPA " + aCPA); + // System.out.println("bSRK " + b + " bCPA " + bCPA); + for (int j = 0; j < getNumberOfAssociationSites(); j++) { + setXsite(j, 1.0); + setXsiteOld(j, 1.0); + setXsitedV(j, 0.0); + setXsitedT(j, 0.0); + } + // if (Math.abs(aCPA) > 1e-6 && cpaon == 1) { + // a = aCPA; + // b = bCPA; + // } + setAttractiveTerm(0); + } + // double[] surfTensInfluenceParamtemp = {-0.0286407191587279700, + // -1.85760887578596, 0.520588, -0.1386439759, 1.1216308727071944}; + // this.surfTensInfluenceParam = surfTensInfluenceParamtemp; + } + + /** + *

+ * Constructor for ComponentSrkCPA. + *

+ * + * @param number a int + * @param TC a double + * @param PC a double + * @param M a double + * @param a a double + * @param moles a double + */ + public ComponentUMRCPA(int number, double TC, double PC, double M, double a, double moles) { + super(number, TC, PC, M, a, moles); + xsite = new double[numberOfAssociationSites]; + xsitedni = new double[numberOfAssociationSites][100]; + xsitedV = new double[numberOfAssociationSites]; + xsitedT = new double[numberOfAssociationSites]; + xsitedTdT = new double[numberOfAssociationSites]; + xsiteOld = new double[numberOfAssociationSites]; + if (numberOfAssociationSites != 0 && cpaon == 1) { + for (int j = 0; j < getNumberOfAssociationSites(); j++) { + setXsite(j, 1.0); + setXsiteOld(j, 1.0); + setXsitedV(j, 0.0); + setXsitedT(j, 0.0); + } + // if (Math.abs(aCPA) > 1e-6 && cpaon == 1) { + // a = aCPA; + // b = bCPA; + // } + setAttractiveTerm(0); + } + // double[] surfTensInfluenceParamtemp = {-0.0286407191587279700, + // -1.85760887578596, 0.520588, -0.1386439759, 1.1216308727071944}; + // this.surfTensInfluenceParam = surfTensInfluenceParamtemp; + } + + /** {@inheritDoc} */ + @Override + public ComponentUMRCPA clone() { + ComponentUMRCPA clonedComponent = null; + try { + clonedComponent = (ComponentUMRCPA) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); + } + + clonedComponent.xsite = xsite.clone(); + System.arraycopy(this.xsite, 0, clonedComponent.xsite, 0, xsite.length); + clonedComponent.xsiteOld = xsiteOld.clone(); + System.arraycopy(this.xsiteOld, 0, clonedComponent.xsiteOld, 0, xsiteOld.length); + clonedComponent.xsitedV = xsitedV.clone(); + System.arraycopy(this.xsitedV, 0, clonedComponent.xsitedV, 0, xsitedV.length); + clonedComponent.xsitedT = xsitedT.clone(); + System.arraycopy(this.xsitedT, 0, clonedComponent.xsitedT, 0, xsitedT.length); + clonedComponent.xsitedTdT = xsitedTdT.clone(); + System.arraycopy(this.xsitedTdT, 0, clonedComponent.xsitedTdT, 0, xsitedTdT.length); + clonedComponent.xsitedni = xsitedni.clone(); + System.arraycopy(this.xsitedni, 0, clonedComponent.xsitedni, 0, xsitedni.length); + return clonedComponent; + } + + /** {@inheritDoc} */ + @Override + public double getVolumeCorrection() { + if ((getRacketZCPA() < 1.0e-10) && cpaon == 1) { + return 0.0; + } else { + setVolumeCorrectionT(getVolumeCorrectionT_CPA()); + setRacketZ(getRacketZCPA()); + return super.getVolumeCorrection(); + } + } + + @Override + public void createComponent(String component_name, double moles, double molesInPhase, + int compnumber) { + super.createComponent(component_name, moles, molesInPhase, compnumber); + // criticalTemperature = 305.4; + // criticalPressure = 135.62; + // acentricFactor = 0.1609; + criticalTemperature = 647; + criticalPressure = 220.64; + acentricFactor = 0.3443; + associationEnergy = 15059.15; + associationVolume = 0.109; + + } + + + /** {@inheritDoc} */ + @Override + public void init(double temperature, double pressure, double totalNumberOfMoles, double beta, + int type) { + super.init(temperature, pressure, totalNumberOfMoles, beta, type); + } + + /** {@inheritDoc} */ + @Override + public void setAttractiveTerm(int i) { + super.setAttractiveTerm(i); + // if (Math.abs(aCPA) > 1e-6 && cpaon == 1) { + // getAttractiveTerm().setm(mCPA); + // } + } + + /** {@inheritDoc} */ + @Override + public void seta(double a) { + aCPA = a; + } + + /** {@inheritDoc} */ + @Override + public void setb(double a) { + bCPA = a; + } + + /** {@inheritDoc} */ + @Override + public double calca() { + // if (Math.abs(aCPA) > 1e-6 && cpaon == 1) { + // return aCPA; + // } else { + return super.calca(); + // } + } + + /** {@inheritDoc} */ + @Override + public double calcb() { + // if (Math.abs(aCPA) > 1e-6 && cpaon == 1) { + // return bCPA; + // } else { + return super.calcb(); + // } + } + + /** {@inheritDoc} */ + @Override + public double dFdN(PhaseInterface phase, int numberOfComponents, double temperature, + double pressure) { + double Fsup = super.dFdN(phase, numberOfComponents, temperature, pressure); + double Fcpa = 0.0; + // if(phase.getPhaseType()==1) cpaon=0; + if (((PhaseCPAInterface) phase).getTotalNumberOfAccociationSites() > 0) { + Fcpa = dFCPAdN(phase, numberOfComponents, temperature, pressure); + } + // System.out.println("Fsup " + Fsup + " fcpa " + Fcpa); + // System.out.println("i " + componentNumber + " dFCPAdn " + Fcpa); + return Fsup + cpaon * Fcpa; + } + + /** {@inheritDoc} */ + @Override + public double dFdNdT(PhaseInterface phase, int numberOfComponents, double temperature, + double pressure) { + if (((PhaseCPAInterface) phase).getTotalNumberOfAccociationSites() > 0) { + return super.dFdNdT(phase, numberOfComponents, temperature, pressure) + + dFCPAdNdT(phase, numberOfComponents, temperature, pressure); + } else { + return super.dFdNdT(phase, numberOfComponents, temperature, pressure); + } + } + + /** {@inheritDoc} */ + @Override + public double dFdNdV(PhaseInterface phase, int numberOfComponents, double temperature, + double pressure) { + // System.out.println("dQdndV " + dFCPAdNdV(phase, numberOfComponents, + // temperature, pressure) + " dFdndV " + super.dFdNdV(phase, numberOfComponents, + // temperature, pressure)); + if (((PhaseCPAInterface) phase).getTotalNumberOfAccociationSites() > 0) { + return super.dFdNdV(phase, numberOfComponents, temperature, pressure) + + dFCPAdNdV(phase, numberOfComponents, temperature, pressure); + } else { + return super.dFdNdV(phase, numberOfComponents, temperature, pressure); + } + } + + /** {@inheritDoc} */ + @Override + public double dFdNdN(int j, PhaseInterface phase, int numberOfComponents, double temperature, + double pressure) { + // System.out.println("ij " + componentNumber + " " + j + " dQCPAdndn " + + // dFCPAdNdN(j, phase, numberOfComponents, temperature, pressure)+ " dQsrkdndn " + // + super.dFdNdN(j, phase, numberOfComponents, temperature, pressure)); + // System.out.println("dFdndn " +(super.dFdNdN(j, phase, numberOfComponents, + // temperature, pressure) + dFCPAdNdN(j, phase, numberOfComponents, temperature, + // pressure))); + if (((PhaseCPAInterface) phase).getTotalNumberOfAccociationSites() > 0) { + return super.dFdNdN(j, phase, numberOfComponents, temperature, pressure) + + dFCPAdNdN(j, phase, numberOfComponents, temperature, pressure); + } else { + return super.dFdNdN(j, phase, numberOfComponents, temperature, pressure); + } + } + + /** + *

+ * dFCPAdNdN. + *

+ * + * @param j a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComponents a int + * @param temperature a double + * @param pressure a double + * @return a double + */ + public double dFCPAdNdN(int j, PhaseInterface phase, int numberOfComponents, double temperature, + double pressure) { + double temp1 = 0; + for (int i = 0; i < numberOfAssociationSites; i++) { + temp1 += 1.0 / getXsite()[i] * getXsitedni(i, j); + } + double tot2 = 0.0; + for (int i = 0; i < phase.getComponent(j).getNumberOfAssociationSites(); i++) { + tot2 += calc_lngi(phase) * (1.0 - ((ComponentUMRCPA) phase.getComponent(j)).getXsite()[i]); + } + double tot1 = 1.0 / 2.0 * tot2; + + double tot4 = 0.0; + tot4 = 0.5 * ((PhaseCPAInterface) phase).getHcpatot() * calc_lngij(j, phase); + double tot10 = 0.0; + for (int kk = 0; kk < phase.getNumberOfComponents(); kk++) { + for (int k = 0; k < phase.getComponent(kk).getNumberOfAssociationSites(); k++) { + tot10 += -phase.getComponent(kk).getNumberOfMolesInPhase() + * ((ComponentUMRCPA) phase.getComponent(kk)).getXsitedni(k, j); + } + } + double tot11 = tot10 / 2.0 * calc_lngi(phase); + + // System.out.println("dFCPAdndn " + (temp1 - tot1 - tot4 - tot11)); + return temp1 - tot1 - tot4 - tot11; + } + + /** + *

+ * dFCPAdN. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComponents a int + * @param temperature a double + * @param pressure a double + * @return a double + */ + public double dFCPAdN(PhaseInterface phase, int numberOfComponents, double temperature, + double pressure) { + double xi = 0.0; + for (int i = 0; i < numberOfAssociationSites; i++) { + xi += Math.log(xsite[i]); + } + // System.out.println("dFCPAdn " + ((xi - ((PhaseCPAInterface) + // phase).getHcpatot() / 2.0 * calc_lngi(phase)))+ " " + componentNumber); + return (xi - ((PhaseCPAInterface) phase).getHcpatot() / 2.0 * calc_lngi(phase)); + } + + /** + *

+ * dFCPAdNdV. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComponents a int + * @param temperature a double + * @param pressure a double + * @return a double + */ + public double dFCPAdNdV(PhaseInterface phase, int numberOfComponents, double temperature, + double pressure) { + double xi = 0.0; + for (int i = 0; i < numberOfAssociationSites; i++) { + xi += (1.0 / xsite[i]) * xsitedV[i]; + } + + double[] tempar = ((PhaseUMRCPA) phase).getdFdNtemp(); + // double temp = calc_lngi(phase); + // double temp2 = calc_lngidV(phase); + /* + * double tot1 = 0.0, tot2 = 0.0, tot3 = 0.0, tot4 = 0.0, temp, temp2; for (int k = 0; k < + * phase.getNumberOfComponents(); k++) { tot2 = 0.0; tot3 = 0.0; temp = calc_lngi(phase); temp2 + * = calc_lngidV(phase); for (int i = 0; i < + * phase.getComponent(k).getNumberOfAssociationSites(); i++) { tot2 -= temp * ((ComponentSrkCPA) + * phase.getComponent(k)).getXsitedV()[i]; tot3 += (1.0 - ((ComponentSrkCPA) + * phase.getComponent(k)).getXsite()[i]) * temp2; } tot1 += 1.0 / 2.0 * tot2 * + * phase.getComponent(k).getNumberOfMolesInPhase(); tot4 += 0.5 * + * phase.getComponent(k).getNumberOfMolesInPhase() * tot3; } */ - public ComponentUMRCPA(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); - xsite = new double[numberOfAssociationSites]; - xsitedni = new double[numberOfAssociationSites][100]; - xsitedV = new double[numberOfAssociationSites]; - xsitedT = new double[numberOfAssociationSites]; - xsitedTdT = new double[numberOfAssociationSites]; - xsiteOld = new double[numberOfAssociationSites]; - if (numberOfAssociationSites != 0 && cpaon == 1) { - // System.out.println("ass sites: " + numberOfAssociationSites); - // System.out.println("aSRK " + a + " aCPA " + aCPA); - // System.out.println("bSRK " + b + " bCPA " + bCPA); - for (int j = 0; j < getNumberOfAssociationSites(); j++) { - setXsite(j, 1.0); - setXsiteOld(j, 1.0); - setXsitedV(j, 0.0); - setXsitedT(j, 0.0); - } - //if (Math.abs(aCPA) > 1e-6 && cpaon == 1) { - // a = aCPA; - // b = bCPA; - //} - setAttractiveTerm(0); - } - // double[] surfTensInfluenceParamtemp = {-0.0286407191587279700, - // -1.85760887578596, 0.520588, -0.1386439759, 1.1216308727071944}; - // this.surfTensInfluenceParam = surfTensInfluenceParamtemp; - } - - /** - *

- * Constructor for ComponentSrkCPA. - *

- * - * @param number a int - * @param TC a double - * @param PC a double - * @param M a double - * @param a a double - * @param moles a double - */ - public ComponentUMRCPA(int number, double TC, double PC, double M, double a, double moles) { - super(number, TC, PC, M, a, moles); - xsite = new double[numberOfAssociationSites]; - xsitedni = new double[numberOfAssociationSites][100]; - xsitedV = new double[numberOfAssociationSites]; - xsitedT = new double[numberOfAssociationSites]; - xsitedTdT = new double[numberOfAssociationSites]; - xsiteOld = new double[numberOfAssociationSites]; - if (numberOfAssociationSites != 0 && cpaon == 1) { - for (int j = 0; j < getNumberOfAssociationSites(); j++) { - setXsite(j, 1.0); - setXsiteOld(j, 1.0); - setXsitedV(j, 0.0); - setXsitedT(j, 0.0); - } - //if (Math.abs(aCPA) > 1e-6 && cpaon == 1) { - // a = aCPA; - //b = bCPA; - // } - setAttractiveTerm(0); - } - // double[] surfTensInfluenceParamtemp = {-0.0286407191587279700, - // -1.85760887578596, 0.520588, -0.1386439759, 1.1216308727071944}; - // this.surfTensInfluenceParam = surfTensInfluenceParamtemp; - } - - /** {@inheritDoc} */ - @Override - public ComponentUMRCPA clone() { - ComponentUMRCPA clonedComponent = null; - try { - clonedComponent = (ComponentUMRCPA) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } - - clonedComponent.xsite = xsite.clone(); - System.arraycopy(this.xsite, 0, clonedComponent.xsite, 0, xsite.length); - clonedComponent.xsiteOld = xsiteOld.clone(); - System.arraycopy(this.xsiteOld, 0, clonedComponent.xsiteOld, 0, xsiteOld.length); - clonedComponent.xsitedV = xsitedV.clone(); - System.arraycopy(this.xsitedV, 0, clonedComponent.xsitedV, 0, xsitedV.length); - clonedComponent.xsitedT = xsitedT.clone(); - System.arraycopy(this.xsitedT, 0, clonedComponent.xsitedT, 0, xsitedT.length); - clonedComponent.xsitedTdT = xsitedTdT.clone(); - System.arraycopy(this.xsitedTdT, 0, clonedComponent.xsitedTdT, 0, xsitedTdT.length); - clonedComponent.xsitedni = xsitedni.clone(); - System.arraycopy(this.xsitedni, 0, clonedComponent.xsitedni, 0, xsitedni.length); - return clonedComponent; - } - - /** {@inheritDoc} */ - @Override - public double getVolumeCorrection() { - if ((getRacketZCPA() < 1.0e-10) && cpaon == 1) { - return 0.0; - } else { - setVolumeCorrectionT(getVolumeCorrectionT_CPA()); - setRacketZ(getRacketZCPA()); - return super.getVolumeCorrection(); - } - } - - @Override - public void createComponent(String component_name, double moles, double molesInPhase, - int compnumber) { - super.createComponent(component_name, moles, molesInPhase, - compnumber); - //criticalTemperature = 305.4; - //criticalPressure = 135.62; - //acentricFactor = 0.1609; - criticalTemperature = 647; - criticalPressure = 220.64; - acentricFactor = 0.3443; - associationEnergy = 15059.15; - associationVolume= 0.109; - - } - - - /** {@inheritDoc} */ - @Override - public void init(double temperature, double pressure, double totalNumberOfMoles, double beta, - int type) { - super.init(temperature, pressure, totalNumberOfMoles, beta, type); - } - - /** {@inheritDoc} */ - @Override - public void setAttractiveTerm(int i) { - super.setAttractiveTerm(i); - //if (Math.abs(aCPA) > 1e-6 && cpaon == 1) { - //getAttractiveTerm().setm(mCPA); - //} - } - - /** {@inheritDoc} */ - @Override - public void seta(double a) { - aCPA = a; - } - - /** {@inheritDoc} */ - @Override - public void setb(double a) { - bCPA = a; - } - - /** {@inheritDoc} */ - @Override - public double calca() { - //if (Math.abs(aCPA) > 1e-6 && cpaon == 1) { - //return aCPA; - //} else { - return super.calca(); - //} - } - - /** {@inheritDoc} */ - @Override - public double calcb() { - //if (Math.abs(aCPA) > 1e-6 && cpaon == 1) { - // return bCPA; - //} else { - return super.calcb(); - // } - } - - /** {@inheritDoc} */ - @Override - public double dFdN(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure) { - double Fsup = super.dFdN(phase, numberOfComponents, temperature, pressure); - double Fcpa = 0.0; - // if(phase.getPhaseType()==1) cpaon=0; - if (((PhaseCPAInterface) phase).getTotalNumberOfAccociationSites() > 0) { - Fcpa = dFCPAdN(phase, numberOfComponents, temperature, pressure); - } - // System.out.println("Fsup " + Fsup + " fcpa " + Fcpa); - // System.out.println("i " + componentNumber + " dFCPAdn " + Fcpa); - return Fsup + cpaon * Fcpa; - } - - /** {@inheritDoc} */ - @Override - public double dFdNdT(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure) { - if (((PhaseCPAInterface) phase).getTotalNumberOfAccociationSites() > 0) { - return super.dFdNdT(phase, numberOfComponents, temperature, pressure) - + dFCPAdNdT(phase, numberOfComponents, temperature, pressure); - } else { - return super.dFdNdT(phase, numberOfComponents, temperature, pressure); - } - } - - /** {@inheritDoc} */ - @Override - public double dFdNdV(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure) { - // System.out.println("dQdndV " + dFCPAdNdV(phase, numberOfComponents, - // temperature, pressure) + " dFdndV " + super.dFdNdV(phase, numberOfComponents, - // temperature, pressure)); - if (((PhaseCPAInterface) phase).getTotalNumberOfAccociationSites() > 0) { - return super.dFdNdV(phase, numberOfComponents, temperature, pressure) - + dFCPAdNdV(phase, numberOfComponents, temperature, pressure); - } else { - return super.dFdNdV(phase, numberOfComponents, temperature, pressure); - } - } - - /** {@inheritDoc} */ - @Override - public double dFdNdN(int j, PhaseInterface phase, int numberOfComponents, double temperature, - double pressure) { - // System.out.println("ij " + componentNumber + " " + j + " dQCPAdndn " + - // dFCPAdNdN(j, phase, numberOfComponents, temperature, pressure)+ " dQsrkdndn " - // + super.dFdNdN(j, phase, numberOfComponents, temperature, pressure)); - // System.out.println("dFdndn " +(super.dFdNdN(j, phase, numberOfComponents, - // temperature, pressure) + dFCPAdNdN(j, phase, numberOfComponents, temperature, - // pressure))); - if (((PhaseCPAInterface) phase).getTotalNumberOfAccociationSites() > 0) { - return super.dFdNdN(j, phase, numberOfComponents, temperature, pressure) - + dFCPAdNdN(j, phase, numberOfComponents, temperature, pressure); - } else { - return super.dFdNdN(j, phase, numberOfComponents, temperature, pressure); - } - } - - /** - *

- * dFCPAdNdN. - *

- * - * @param j a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComponents a int - * @param temperature a double - * @param pressure a double - * @return a double - */ - public double dFCPAdNdN(int j, PhaseInterface phase, int numberOfComponents, double temperature, - double pressure) { - double temp1 = 0; - for (int i = 0; i < numberOfAssociationSites; i++) { - temp1 += 1.0 / getXsite()[i] * getXsitedni(i, j); - } - double tot2 = 0.0; - for (int i = 0; i < phase.getComponent(j).getNumberOfAssociationSites(); i++) { - tot2 += calc_lngi(phase) - * (1.0 - ((ComponentUMRCPA) phase.getComponent(j)).getXsite()[i]); - } - double tot1 = 1.0 / 2.0 * tot2; - - double tot4 = 0.0; - tot4 = 0.5 * ((PhaseCPAInterface) phase).getHcpatot() * calc_lngij(j, phase); - double tot10 = 0.0; - for (int kk = 0; kk < phase.getNumberOfComponents(); kk++) { - for (int k = 0; k < phase.getComponent(kk).getNumberOfAssociationSites(); k++) { - tot10 += -phase.getComponent(kk).getNumberOfMolesInPhase() - * ((ComponentUMRCPA) phase.getComponent(kk)).getXsitedni(k, j); - } - } - double tot11 = tot10 / 2.0 * calc_lngi(phase); - - // System.out.println("dFCPAdndn " + (temp1 - tot1 - tot4 - tot11)); - return temp1 - tot1 - tot4 - tot11; - } - - /** - *

- * dFCPAdN. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComponents a int - * @param temperature a double - * @param pressure a double - * @return a double - */ - public double dFCPAdN(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure) { - double xi = 0.0; - for (int i = 0; i < numberOfAssociationSites; i++) { - xi += Math.log(xsite[i]); - } - // System.out.println("dFCPAdn " + ((xi - ((PhaseCPAInterface) - // phase).getHcpatot() / 2.0 * calc_lngi(phase)))+ " " + componentNumber); - return (xi - ((PhaseCPAInterface) phase).getHcpatot() / 2.0 * calc_lngi(phase)); - } - - /** - *

- * dFCPAdNdV. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComponents a int - * @param temperature a double - * @param pressure a double - * @return a double - */ - public double dFCPAdNdV(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure) { - double xi = 0.0; - for (int i = 0; i < numberOfAssociationSites; i++) { - xi += (1.0 / xsite[i]) * xsitedV[i]; - } - - double[] tempar = ((PhaseUMRCPA) phase).getdFdNtemp(); - // double temp = calc_lngi(phase); - // double temp2 = calc_lngidV(phase); - /* - * double tot1 = 0.0, tot2 = 0.0, tot3 = 0.0, tot4 = 0.0, temp, temp2; for (int k = 0; k < - * phase.getNumberOfComponents(); k++) { tot2 = 0.0; tot3 = 0.0; temp = calc_lngi(phase); - * temp2 = calc_lngidV(phase); for (int i = 0; i < - * phase.getComponent(k).getNumberOfAssociationSites(); i++) { tot2 -= temp * - * ((ComponentSrkCPA) phase.getComponent(k)).getXsitedV()[i]; tot3 += (1.0 - - * ((ComponentSrkCPA) phase.getComponent(k)).getXsite()[i]) * temp2; } tot1 += 1.0 / 2.0 * - * tot2 * phase.getComponent(k).getNumberOfMolesInPhase(); tot4 += 0.5 * - * phase.getComponent(k).getNumberOfMolesInPhase() * tot3; } - */ - // System.out.println("dFCPAdndV " + (xi - tot1 - tot4)); - return xi + tempar[0] * calc_lngi(phase) + tempar[1] * calc_lngidV(phase);// - tot1 - tot4; - } - - /** - *

- * dFCPAdNdT. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComponents a int - * @param temperature a double - * @param pressure a double - * @return a double - */ - public double dFCPAdNdT(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure) { - double xi = 0.0; - for (int i = 0; i < numberOfAssociationSites; i++) { - xi += 1.0 / xsite[i] * xsitedT[i]; - } - - double tot1 = 0.0, tot2 = 0.0; - for (int k = 0; k < phase.getNumberOfComponents(); k++) { - tot2 = 0.0; - for (int i = 0; i < phase.getComponent(k).getNumberOfAssociationSites(); i++) { - tot2 -= ((ComponentUMRCPA) phase.getComponent(k)).getXsitedT()[i]; - } - tot1 += tot2 * phase.getComponent(k).getNumberOfMolesInPhase(); - } - // System.out.println("dFCPAdndT " + (xi - 1.0 / 2.0 * calc_lngi(phase) * - // tot1)); - // System.out.println("dlngdni " + calc_lngi(phase)); - return xi - 1.0 / 2.0 * calc_lngi(phase) * tot1; - } - - /** - *

- * calc_hCPAdn. - *

- * - * @return a double - */ - public double calc_hCPAdn() { - double hdn = 0.0; - for (int i = 0; i < getNumberOfAssociationSites(); i++) { - hdn = 1.0 - getXsite()[i]; - } - return hdn; - } - - /** {@inheritDoc} */ - @Override - public double dFCPAdXi(int site, PhaseInterface phase) { - return getNumberOfMolesInPhase() * (1.0 / xsite[site] - 1.0 / 2.0); - } - - /** - *

- * dFCPAdXidni. - *

- * - * @param site a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double dFCPAdXidni(int site, PhaseInterface phase) { - return (1.0 / xsite[site] - 1.0 / 2.0); - } - - /** {@inheritDoc} */ - @Override - public double dFCPAdXidXj(int sitei, int sitej, int compj, PhaseInterface phase) { - double fact = 0.0; - if (sitei == sitej && compj == componentNumber) { - fact = 1.0; - } - return -getNumberOfMolesInPhase() / Math.pow(xsite[sitei], 2.0) * fact - - getNumberOfMolesInPhase() * phase.getComponent(compj).getNumberOfMolesInPhase() - * ((PhaseCPAInterface) phase).getCpamix().calcDelta(sitei, sitej, - componentNumber, compj, phase, phase.getTemperature(), - phase.getPressure(), phase.getNumberOfComponents()); - } - - /** {@inheritDoc} */ - @Override - public double dFCPAdVdXi(int site, PhaseInterface phase) { - return -1.0 / (2.0 * phase.getTotalVolume()) - * (1.0 - phase.getTotalVolume() * ((PhaseCPAInterface) phase).getGcpav()) - * getNumberOfMolesInPhase(); - } - - /** {@inheritDoc} */ - @Override - public double dFCPAdNdXi(int site, PhaseInterface phase) { - double xi = 1.0 / xsite[site]; - - // return xi - tempp; - return xi + getNumberOfMolesInPhase() / 2.0 * calc_lngi(phase); - } - - /** - *

- * dFCPAdNdXidXdV. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double dFCPAdNdXidXdV(PhaseInterface phase) { - double temp = 0.0; - for (int i = 0; i < numberOfAssociationSites; i++) { - temp += dFCPAdNdXi(i, phase) * getXsitedV()[i]; - } - return temp; - } - - /** - *

- * calc_lngi. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double calc_lngi(PhaseInterface phase) { - return 2.0 * getBi() * (10.0 * phase.getTotalVolume() - phase.getB()) - / ((8.0 * phase.getTotalVolume() - phase.getB()) - * (4.0 * phase.getTotalVolume() - phase.getB())); - } - - /** - *

- * calc_lngidV. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double calc_lngidV(PhaseInterface phase) { - return 2.0 * getBi() * (10.0) - / ((8.0 * phase.getTotalVolume() - phase.getB()) - * (4.0 * phase.getTotalVolume() - phase.getB())) - - 2.0 * getBi() * (10.0 * phase.getTotalVolume() - phase.getB()) - * (2.0 * 32.0 * phase.getTotalVolume() - 12.0 * phase.getB()) - / Math.pow(((8.0 * phase.getTotalVolume() - phase.getB()) - * (4.0 * phase.getTotalVolume() - phase.getB())), 2.0); - } - - /** - *

- * calc_lngij. - *

- * - * @param j a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double calc_lngij(int j, PhaseInterface phase) { - return 2.0 * getBij(j) * (10.0 * phase.getTotalVolume() - phase.getB()) - / ((8.0 * phase.getTotalVolume() - phase.getB()) - * (4.0 * phase.getTotalVolume() - phase.getB())); - } - - /** {@inheritDoc} */ - @Override - public double[] getXsite() { - return this.xsite; - } - - /** - * Setter for property xsite. - * - * @param xsite New value of property xsite. - */ - public void setXsite(double[] xsite) { - this.xsite = xsite; - } - - /** {@inheritDoc} */ - @Override - public void setXsite(int i, double xsite) { - this.xsite[i] = xsite; - } - - /** {@inheritDoc} */ - @Override - public double[] getXsitedV() { - return this.xsitedV; - } - - /** {@inheritDoc} */ - @Override - public void setXsitedV(int i, double xsitedV) { - this.xsitedV[i] = xsitedV; - } - - /** {@inheritDoc} */ - @Override - public double[] getXsitedT() { - return this.xsitedT; - } - - /** {@inheritDoc} */ - @Override - public double[] getXsitedTdT() { - return this.xsitedTdT; - } - - /** {@inheritDoc} */ - @Override - public void setXsitedT(int i, double xsitedT) { - this.xsitedT[i] = xsitedT; - } - - /** {@inheritDoc} */ - @Override - public void setXsitedTdT(int i, double xsitedTdT) { - this.xsitedTdT[i] = xsitedTdT; - } - - /** {@inheritDoc} */ - @Override - public double[] getXsiteOld() { - return this.xsiteOld; - } - - /** - * Setter for property xsite. - * - * @param xsiteOld an array of {@link double} objects - */ - public void setXsiteOld(double[] xsiteOld) { - this.xsiteOld = xsiteOld; - } - - /** {@inheritDoc} */ - @Override - public void setXsiteOld(int i, double xsiteOld) { - this.xsiteOld[i] = xsiteOld; - } - - /** - *

- * Getter for the field xsitedni. - *

- * - * @return the xsitedni - */ - public double[][] getXsitedni() { - return xsitedni; - } - - /** - *

- * Getter for the field xsitedni. - *

- * - * @param xNumb a int - * @param compNumbi a int - * @return a double - */ - public double getXsitedni(int xNumb, int compNumbi) { - return xsitedni[xNumb][compNumbi]; - } - - /** - *

- * Setter for the field xsitedni. - *

- * - * @param xsitedni the xsitedni to set - */ - public void setXsitedni(double[][] xsitedni) { - this.xsitedni = xsitedni; - } - - /** {@inheritDoc} */ - @Override - public void setXsitedni(int xnumb, int compnumb, double val) { - xsitedni[xnumb][compnumb] = val; - } - - /** {@inheritDoc} */ - @Override - public double getSurfaceTenisionInfluenceParameter(double temperature) { - double AA = 0, BB = 0; - if (componentName.equals("water")) { - double TR = 1.0 - temperature / getTC(); - AA = -2.2367E-16; - BB = 2.83732E-16; - // return aT * 1e-5 * Math.pow(b * 1e-5, 2.0 / 3.0) * (AA * TR + BB); - - double AAW1 = 2.2505E-16; - double AAW2 = -1.3646E-16; - - return aT * 1e-5 * Math.pow(b * 1e-5, 2.0 / 3.0) - * (AAW1 + AAW2 * TR + 0.5113e-16 * TR * TR); - } // old - else if (componentName.equals("water2")) { /// THis is the old method from - double TR = 1.0 - temperature / getTC(); - AA = -2.2367E-16; - BB = 2.83732E-16; - return aT * 1e-5 * Math.pow(b * 1e-5, 2.0 / 3.0) * (AA * TR + BB); - } else if (componentName.equals("MEG")) { - return 1.04874809905393E-19; - } else if (componentName.equals("TEG")) { - return 7.46824658716429E-19; - } else { - return super.getSurfaceTenisionInfluenceParameter(temperature); - } - } + // System.out.println("dFCPAdndV " + (xi - tot1 - tot4)); + return xi + tempar[0] * calc_lngi(phase) + tempar[1] * calc_lngidV(phase); // - tot1 - tot4; + } + + /** + *

+ * dFCPAdNdT. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComponents a int + * @param temperature a double + * @param pressure a double + * @return a double + */ + public double dFCPAdNdT(PhaseInterface phase, int numberOfComponents, double temperature, + double pressure) { + double xi = 0.0; + for (int i = 0; i < numberOfAssociationSites; i++) { + xi += 1.0 / xsite[i] * xsitedT[i]; + } + + double tot1 = 0.0; + double tot2 = 0.0; + for (int k = 0; k < phase.getNumberOfComponents(); k++) { + tot2 = 0.0; + for (int i = 0; i < phase.getComponent(k).getNumberOfAssociationSites(); i++) { + tot2 -= ((ComponentUMRCPA) phase.getComponent(k)).getXsitedT()[i]; + } + tot1 += tot2 * phase.getComponent(k).getNumberOfMolesInPhase(); + } + // System.out.println("dFCPAdndT " + (xi - 1.0 / 2.0 * calc_lngi(phase) * + // tot1)); + // System.out.println("dlngdni " + calc_lngi(phase)); + return xi - 1.0 / 2.0 * calc_lngi(phase) * tot1; + } + + /** + *

+ * calc_hCPAdn. + *

+ * + * @return a double + */ + public double calc_hCPAdn() { + double hdn = 0.0; + for (int i = 0; i < getNumberOfAssociationSites(); i++) { + hdn = 1.0 - getXsite()[i]; + } + return hdn; + } + + /** {@inheritDoc} */ + @Override + public double dFCPAdXi(int site, PhaseInterface phase) { + return getNumberOfMolesInPhase() * (1.0 / xsite[site] - 1.0 / 2.0); + } + + /** + *

+ * dFCPAdXidni. + *

+ * + * @param site a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double dFCPAdXidni(int site, PhaseInterface phase) { + return (1.0 / xsite[site] - 1.0 / 2.0); + } + + /** {@inheritDoc} */ + @Override + public double dFCPAdXidXj(int sitei, int sitej, int compj, PhaseInterface phase) { + double fact = 0.0; + if (sitei == sitej && compj == componentNumber) { + fact = 1.0; + } + return -getNumberOfMolesInPhase() / Math.pow(xsite[sitei], 2.0) * fact + - getNumberOfMolesInPhase() * phase.getComponent(compj).getNumberOfMolesInPhase() + * ((PhaseCPAInterface) phase).getCpamix().calcDelta(sitei, sitej, componentNumber, + compj, phase, phase.getTemperature(), phase.getPressure(), + phase.getNumberOfComponents()); + } + + /** {@inheritDoc} */ + @Override + public double dFCPAdVdXi(int site, PhaseInterface phase) { + return -1.0 / (2.0 * phase.getTotalVolume()) + * (1.0 - phase.getTotalVolume() * ((PhaseCPAInterface) phase).getGcpav()) + * getNumberOfMolesInPhase(); + } + + /** {@inheritDoc} */ + @Override + public double dFCPAdNdXi(int site, PhaseInterface phase) { + double xi = 1.0 / xsite[site]; + + // return xi - tempp; + return xi + getNumberOfMolesInPhase() / 2.0 * calc_lngi(phase); + } + + /** + *

+ * dFCPAdNdXidXdV. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double dFCPAdNdXidXdV(PhaseInterface phase) { + double temp = 0.0; + for (int i = 0; i < numberOfAssociationSites; i++) { + temp += dFCPAdNdXi(i, phase) * getXsitedV()[i]; + } + return temp; + } + + /** + *

+ * calc_lngi. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double calc_lngi(PhaseInterface phase) { + return 2.0 * getBi() * (10.0 * phase.getTotalVolume() - phase.getB()) + / ((8.0 * phase.getTotalVolume() - phase.getB()) + * (4.0 * phase.getTotalVolume() - phase.getB())); + } + + /** + *

+ * calc_lngidV. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double calc_lngidV(PhaseInterface phase) { + return 2.0 * getBi() * (10.0) + / ((8.0 * phase.getTotalVolume() - phase.getB()) + * (4.0 * phase.getTotalVolume() - phase.getB())) + - 2.0 * getBi() * (10.0 * phase.getTotalVolume() - phase.getB()) + * (2.0 * 32.0 * phase.getTotalVolume() - 12.0 * phase.getB()) + / Math.pow(((8.0 * phase.getTotalVolume() - phase.getB()) + * (4.0 * phase.getTotalVolume() - phase.getB())), 2.0); + } + + /** + *

+ * calc_lngij. + *

+ * + * @param j a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double calc_lngij(int j, PhaseInterface phase) { + return 2.0 * getBij(j) * (10.0 * phase.getTotalVolume() - phase.getB()) + / ((8.0 * phase.getTotalVolume() - phase.getB()) + * (4.0 * phase.getTotalVolume() - phase.getB())); + } + + /** {@inheritDoc} */ + @Override + public double[] getXsite() { + return this.xsite; + } + + /** + * Setter for property xsite. + * + * @param xsite New value of property xsite. + */ + public void setXsite(double[] xsite) { + this.xsite = xsite; + } + + /** {@inheritDoc} */ + @Override + public void setXsite(int i, double xsite) { + this.xsite[i] = xsite; + } + + /** {@inheritDoc} */ + @Override + public double[] getXsitedV() { + return this.xsitedV; + } + + /** {@inheritDoc} */ + @Override + public void setXsitedV(int i, double xsitedV) { + this.xsitedV[i] = xsitedV; + } + + /** {@inheritDoc} */ + @Override + public double[] getXsitedT() { + return this.xsitedT; + } + + /** {@inheritDoc} */ + @Override + public double[] getXsitedTdT() { + return this.xsitedTdT; + } + + /** {@inheritDoc} */ + @Override + public void setXsitedT(int i, double xsitedT) { + this.xsitedT[i] = xsitedT; + } + + /** {@inheritDoc} */ + @Override + public void setXsitedTdT(int i, double xsitedTdT) { + this.xsitedTdT[i] = xsitedTdT; + } + + /** {@inheritDoc} */ + @Override + public double[] getXsiteOld() { + return this.xsiteOld; + } + + /** + * Setter for property xsite. + * + * @param xsiteOld an array of {@link double} objects + */ + public void setXsiteOld(double[] xsiteOld) { + this.xsiteOld = xsiteOld; + } + + /** {@inheritDoc} */ + @Override + public void setXsiteOld(int i, double xsiteOld) { + this.xsiteOld[i] = xsiteOld; + } + + /** + *

+ * Getter for the field xsitedni. + *

+ * + * @return the xsitedni + */ + public double[][] getXsitedni() { + return xsitedni; + } + + /** + *

+ * Getter for the field xsitedni. + *

+ * + * @param xNumb a int + * @param compNumbi a int + * @return a double + */ + public double getXsitedni(int xNumb, int compNumbi) { + return xsitedni[xNumb][compNumbi]; + } + + /** + *

+ * Setter for the field xsitedni. + *

+ * + * @param xsitedni the xsitedni to set + */ + public void setXsitedni(double[][] xsitedni) { + this.xsitedni = xsitedni; + } + + /** {@inheritDoc} */ + @Override + public void setXsitedni(int xnumb, int compnumb, double val) { + xsitedni[xnumb][compnumb] = val; + } + + /** {@inheritDoc} */ + @Override + public double getSurfaceTenisionInfluenceParameter(double temperature) { + double AA = 0; + double BB = 0; + if (componentName.equals("water")) { + double TR = 1.0 - temperature / getTC(); + AA = -2.2367E-16; + BB = 2.83732E-16; + // return aT * 1e-5 * Math.pow(b * 1e-5, 2.0 / 3.0) * (AA * TR + BB); + + double AAW1 = 2.2505E-16; + double AAW2 = -1.3646E-16; + + return aT * 1e-5 * Math.pow(b * 1e-5, 2.0 / 3.0) * (AAW1 + AAW2 * TR + 0.5113e-16 * TR * TR); + } // old + else if (componentName.equals("water2")) { /// THis is the old method from + double TR = 1.0 - temperature / getTC(); + AA = -2.2367E-16; + BB = 2.83732E-16; + return aT * 1e-5 * Math.pow(b * 1e-5, 2.0 / 3.0) * (AA * TR + BB); + } else if (componentName.equals("MEG")) { + return 1.04874809905393E-19; + } else if (componentName.equals("TEG")) { + return 7.46824658716429E-19; + } else { + return super.getSurfaceTenisionInfluenceParameter(temperature); + } + } } diff --git a/src/main/java/neqsim/thermo/component/ComponentWaxWilson.java b/src/main/java/neqsim/thermo/component/ComponentWaxWilson.java index c3910088df..64834c4066 100644 --- a/src/main/java/neqsim/thermo/component/ComponentWaxWilson.java +++ b/src/main/java/neqsim/thermo/component/ComponentWaxWilson.java @@ -140,7 +140,7 @@ public double getWilsonActivityCoefficient(PhaseInterface phase1) { public double getCharEnergyParamter(PhaseInterface phase1, int comp1, int comp2) { double param1 = 0.0; // ((ComponentWaxWilson) // phase1.getComponent(comp1)).getWilsonInteractionEnergy(phase1); - double param2 = 0.0;// ((ComponentWaxWilson) + double param2 = 0.0; // ((ComponentWaxWilson) // phase1.getComponent(comp2)).getWilsonInteractionEnergy(phase1); // this need to be corrected accordint to how to select energy of shortest // carbon molecule ..... diff --git a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermCPAstatoil.java b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermCPAstatoil.java index deb662094f..968ec71936 100644 --- a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermCPAstatoil.java +++ b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermCPAstatoil.java @@ -80,7 +80,7 @@ public double alpha(double temperature) { double temp1 = 1.0 - Math.sqrt(Tr); double var = 1.0 + parameters[0] * temp1 + parameters[1] * temp1 * temp1 + parameters[2] * temp1 * temp1 * temp1; - return var * var;// Math.pow(1.0+parameters[0]*(1.0-Math.sqrt(Tr))+parameters[1]*temp1*temp1+parameters[2]*temp1*temp1*temp1,2.0); + return var * var; // Math.pow(1.0+parameters[0]*(1.0-Math.sqrt(Tr))+parameters[1]*temp1*temp1+parameters[2]*temp1*temp1*temp1,2.0); } /** {@inheritDoc} */ diff --git a/src/main/java/neqsim/thermo/mixingRule/EosMixingRules.java b/src/main/java/neqsim/thermo/mixingRule/EosMixingRules.java index ccf441caff..711fca2d37 100644 --- a/src/main/java/neqsim/thermo/mixingRule/EosMixingRules.java +++ b/src/main/java/neqsim/thermo/mixingRule/EosMixingRules.java @@ -33,2673 +33,2726 @@ * @version $Id: $Id */ public class EosMixingRules implements Cloneable, ThermodynamicConstantsInterface { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - public double Atot = 0, Btot = 0, Ai = 0, Bi = 0; - public double A, B; - public String mixingRuleGEModel = "NRTL"; - public String mixingRuleName = "no (kij=0)"; - public double intparam[][], intparamT[][], WSintparam[][], intparamij[][], intparamji[][]; - public int intparamTType[][]; - double[][] HVDij, HValpha, HVDijT; - double[][] NRTLDij, NRTLalpha, NRTLDijT; - double[][][] wij; - int[][] wijCalcOrFitted; - String[][] classicOrHV, classicOrWS; - public double nEOSkij = 3.0; - /** Constant calcEOSInteractionParameters=false */ - public static boolean calcEOSInteractionParameters = false; - private int bmixType = 0; - - static Logger logger = LogManager.getLogger(EosMixingRules.class); + public double Atot = 0; - /** - *

- * Constructor for EosMixingRules. - *

- */ - public EosMixingRules() {} + public double Btot = 0; - /** {@inheritDoc} */ - @Override - public EosMixingRules clone() { - EosMixingRules clonedSystem = null; - try { - clonedSystem = (EosMixingRules) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } + public double Ai = 0; - // clonedSystem.intparam = (double[][]) intparam.clone(); - // clonedSystem.wij = (double[][][]) wij.clone(); - // clonedSystem.WSintparam = (double[][]) WSintparam.clone() ; - // clonedSystem.HVDij = (double[][]) HVDij.clone(); - // clonedSystem.HValpha = (double[][]) HValpha.clone(); - // clonedSystem.HVDijT = (double[][]) HVDijT.clone(); - // clonedSystem.NRTLDij = (double[][]) NRTLDij.clone(); - // clonedSystem.NRTLalpha = (double[][]) NRTLalpha.clone(); - // clonedSystem.NRTLDijT = (double[][]) NRTLDijT.clone(); - // clonedSystem.classicOrHV = (String[][]) classicOrHV.clone(); - return clonedSystem; - } - - public class ClassicVdW implements EosMixingRulesInterface, java.io.Serializable { - private static final long serialVersionUID = 1000; - - @Override - public java.lang.String getMixingRuleName() { - return mixingRuleName; - } + public double Bi = 0; - @Override - public PhaseInterface getGEPhase() { - return null; - } + public double A; - @Override - public void setMixingRuleGEModel(java.lang.String GEmodel) { - mixingRuleGEModel = GEmodel; - } + public double B; - @Override - public double getBinaryInteractionParameter(int i, int j) { - if (i == j) { - return 0.0; - } - return intparam[i][j]; - } + public String mixingRuleGEModel = "NRTL"; + public String mixingRuleName = "no (kij=0)"; + public double intparam[][]; - @Override - public double getBinaryInteractionParameterT1(int i, int j) { - if (i == j) { - return 0.0; - } - return intparamT[i][j]; - } + public double intparamT[][]; - /** - * @return the bmixType - */ - @Override - public int getBmixType() { - return bmixType; - } + public double WSintparam[][]; - /** - * @param bmixType2 the bmixType to set - */ - @Override - public void setBmixType(int bmixType2) { - bmixType = bmixType2; - } + public double intparamij[][]; - public double getbij(ComponentEosInterface compi, ComponentEosInterface compj) { - switch (getBmixType()) { - case 0: - return (compi.getb() + compj.getb()) * 0.5; - case 1: - // return (compi.getb() + compj.getb()) * 0.5; - double temp = (Math.sqrt(compi.getb()) + Math.sqrt(compj.getb())) * 0.5; - return temp * temp; - // return Math.pow((Math.sqrt(compi.getb())+Math.sqrt(compj.getb()))/2.0, 2.0); - // return - // Math.pow(0.5*(Math.pow(compi.getb(),1.0/3.0)+Math.pow(compj.getb(),1.0/3.0)),3.0); - // return - // Math.sqrt(compi.getb()*compj.getb())*(1.0-intparam[compi.getComponentNumber()][compj.getComponentNumber()]); - // return - // Math.pow(0.5*(Math.pow(compi.getb(),3.0/4.0)+Math.pow(compj.getb(),3.0/4.0)),4.0/3.0); - default: - return (compi.getb() + compj.getb()) * 0.5; - } - } + public double intparamji[][]; - @Override - public void setBinaryInteractionParameter(int i, int j, double value) { - // System.out.println("intparam: " + intparam[i][j] + " value " + value); - intparam[i][j] = value; - intparam[j][i] = value; - } + public int intparamTType[][]; + double[][] HVDij; - @Override - public void setBinaryInteractionParameterij(int i, int j, double value) { - intparamij[i][j] = value; - intparamji[j][i] = value; - } + double[][] HValpha; - @Override - public void setBinaryInteractionParameterji(int i, int j, double value) { - // System.out.println("intparam: " + intparam[i][j] + " value " + value); - intparamji[i][j] = value; - intparamij[j][i] = value; - } + double[][] HVDijT; - @Override - public void setBinaryInteractionParameterT1(int i, int j, double value) { - // System.out.println("intparam: " + intparam[i][j] + " value " + value); - intparamT[i][j] = value; - intparamT[j][i] = value; - } + double[][] NRTLDij; - /** - * Setter for property CalcEOSInteractionParameters. - * - * @param CalcEOSInteractionParameters2 New value of property CalcEOSInteractionParameters. - */ - @Override - public void setCalcEOSInteractionParameters(boolean CalcEOSInteractionParameters2) { - calcEOSInteractionParameters = CalcEOSInteractionParameters2; - } + double[][] NRTLalpha; - @Override - public void setnEOSkij(double n) { - nEOSkij = n; - } + double[][] NRTLDijT; - public double getA() { - return Atot; - } + double[][][] wij; + int[][] wijCalcOrFitted; + String[][] classicOrHV; - public double getB() { - return Btot; - } + String[][] classicOrWS; - @Override - public double calcA(PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - double aij = 0.0, A = 0.0; - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - - for (int i = 0; i < numbcomp; i++) { - for (int j = 0; j < numbcomp; j++) { - aij = Math.sqrt(compArray[i].getaT() * compArray[j].getaT()); - A += compArray[i].getNumberOfMolesInPhase() - * compArray[j].getNumberOfMolesInPhase() * aij; - } - } - Atot = A; - return A; - } + public double nEOSkij = 3.0; + /** Constant calcEOSInteractionParameters=false */ + public static boolean calcEOSInteractionParameters = false; + private int bmixType = 0; - @Override - public double calcB(PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - B = 0.0; - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - - for (int i = 0; i < numbcomp; i++) { - for (int j = 0; j < numbcomp; j++) { - B += compArray[i].getNumberOfMolesInPhase() - * compArray[j].getNumberOfMolesInPhase() - * getbij(compArray[i], compArray[j]);// (compArray[i].getb()+compArray[j].getb())/2; - } - } - B /= phase.getNumberOfMolesInPhase(); - Btot = B; - return B; - } + static Logger logger = LogManager.getLogger(EosMixingRules.class); - @Override - public double calcAi(int compNumb, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - double aij = 0; - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + /** + *

+ * Constructor for EosMixingRules. + *

+ */ + public EosMixingRules() {} - Ai = 0.0; - for (int j = 0; j < numbcomp; j++) { - aij = Math.sqrt(compArray[compNumb].getaT() * compArray[j].getaT()); - Ai += compArray[j].getNumberOfMolesInPhase() * aij; - } + /** {@inheritDoc} */ + @Override + public EosMixingRules clone() { + EosMixingRules clonedSystem = null; + try { + clonedSystem = (EosMixingRules) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); + } - return 2.0 * Ai; - } + // clonedSystem.intparam = (double[][]) intparam.clone(); + // clonedSystem.wij = (double[][][]) wij.clone(); + // clonedSystem.WSintparam = (double[][]) WSintparam.clone() ; + // clonedSystem.HVDij = (double[][]) HVDij.clone(); + // clonedSystem.HValpha = (double[][]) HValpha.clone(); + // clonedSystem.HVDijT = (double[][]) HVDijT.clone(); + // clonedSystem.NRTLDij = (double[][]) NRTLDij.clone(); + // clonedSystem.NRTLalpha = (double[][]) NRTLalpha.clone(); + // clonedSystem.NRTLDijT = (double[][]) NRTLDijT.clone(); + // clonedSystem.classicOrHV = (String[][]) classicOrHV.clone(); + return clonedSystem; + } + + public class ClassicVdW implements EosMixingRulesInterface, java.io.Serializable { + private static final long serialVersionUID = 1000; - @Override - public double calcBi(int compNumb, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - double Bi = 0.0; + @Override + public java.lang.String getMixingRuleName() { + return mixingRuleName; + } - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + @Override + public PhaseInterface getGEPhase() { + return null; + } - for (int j = 0; j < numbcomp; j++) { - Bi += compArray[j].getNumberOfMolesInPhase() - * getbij(compArray[compNumb], compArray[j]); - } + @Override + public void setMixingRuleGEModel(java.lang.String GEmodel) { + mixingRuleGEModel = GEmodel; + } - Bi = (2.0 * Bi - getB()) / phase.getNumberOfMolesInPhase(); - return Bi; - } + @Override + public double getBinaryInteractionParameter(int i, int j) { + if (i == j) { + return 0.0; + } + return intparam[i][j]; + } - public double calcBi2(int compNumb, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - double Bi = 0.0; - - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - double sumk = 0; - for (int j = 0; j < numbcomp; j++) { - Bi += compArray[j].getNumberOfMolesInPhase() - * getbij(compArray[compNumb], compArray[j]); - for (int k = 0; k < numbcomp; k++) { - sumk += compArray[j].getNumberOfMolesInPhase() - * compArray[k].getNumberOfMolesInPhase() - * getbij(compArray[j], compArray[k]); - } - } - double ans1 = phase.getNumberOfMolesInPhase() * Bi - sumk; + @Override + public double getBinaryInteractionParameterT1(int i, int j) { + if (i == j) { + return 0.0; + } + return intparamT[i][j]; + } - return ans1 / (phase.getNumberOfMolesInPhase() * phase.getNumberOfMolesInPhase()); - } + /** + * @return the bmixType + */ + @Override + public int getBmixType() { + return bmixType; + } - @Override - public double calcBij(int compNumb, int compNumbj, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - double bij = 0.0; - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + /** + * @param bmixType2 the bmixType to set + */ + @Override + public void setBmixType(int bmixType2) { + bmixType = bmixType2; + } - bij = getbij(compArray[compNumb], compArray[compNumbj]); - return (2.0 * bij - compArray[compNumb].getBi() - compArray[compNumbj].getBi()) - / phase.getNumberOfMolesInPhase(); - } + public double getbij(ComponentEosInterface compi, ComponentEosInterface compj) { + switch (getBmixType()) { + case 0: + return (compi.getb() + compj.getb()) * 0.5; + case 1: + // return (compi.getb() + compj.getb()) * 0.5; + double temp = (Math.sqrt(compi.getb()) + Math.sqrt(compj.getb())) * 0.5; + return temp * temp; + // return Math.pow((Math.sqrt(compi.getb())+Math.sqrt(compj.getb()))/2.0, 2.0); + // return + // Math.pow(0.5*(Math.pow(compi.getb(),1.0/3.0)+Math.pow(compj.getb(),1.0/3.0)),3.0); + // return + // Math.sqrt(compi.getb()*compj.getb())*(1.0-intparam[compi.getComponentNumber()][compj.getComponentNumber()]); + // return + // Math.pow(0.5*(Math.pow(compi.getb(),3.0/4.0)+Math.pow(compj.getb(),3.0/4.0)),4.0/3.0); + default: + return (compi.getb() + compj.getb()) * 0.5; + } + } - @Override - public double calcAiT(int compNumb, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - double A = 0.0; - double aij = 0; - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - - for (int j = 0; j < numbcomp; j++) { - aij = 0.5 / Math.sqrt(compArray[compNumb].getaT() * compArray[j].getaT()) - * (compArray[compNumb].getaT() * compArray[j].getaDiffT() - + compArray[j].getaT() * compArray[compNumb].getaDiffT()); - A += compArray[j].getNumberOfMolesInPhase() * aij; - } + @Override + public void setBinaryInteractionParameter(int i, int j, double value) { + // System.out.println("intparam: " + intparam[i][j] + " value " + value); + intparam[i][j] = value; + intparam[j][i] = value; + } - return 2.0 * A; - } + @Override + public void setBinaryInteractionParameterij(int i, int j, double value) { + intparamij[i][j] = value; + intparamji[j][i] = value; + } - @Override - public double calcAij(int compNumb, int compNumbj, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - double aij = 0; - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + @Override + public void setBinaryInteractionParameterji(int i, int j, double value) { + // System.out.println("intparam: " + intparam[i][j] + " value " + value); + intparamji[i][j] = value; + intparamij[j][i] = value; + } - aij = Math.sqrt(compArray[compNumb].getaT() * compArray[compNumbj].getaT()); + @Override + public void setBinaryInteractionParameterT1(int i, int j, double value) { + // System.out.println("intparam: " + intparam[i][j] + " value " + value); + intparamT[i][j] = value; + intparamT[j][i] = value; + } - return 2.0 * aij; - } + /** + * Setter for property CalcEOSInteractionParameters. + * + * @param CalcEOSInteractionParameters2 New value of property CalcEOSInteractionParameters. + */ + @Override + public void setCalcEOSInteractionParameters(boolean CalcEOSInteractionParameters2) { + calcEOSInteractionParameters = CalcEOSInteractionParameters2; + } - @Override - public double calcAT(PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - double A = 0.0; - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + @Override + public void setnEOSkij(double n) { + nEOSkij = n; + } - for (int i = 0; i < numbcomp; i++) { - A += compArray[i].getNumberOfMolesInPhase() - * phase.calcAiT(i, phase, temperature, pressure, numbcomp); - } + public double getA() { + return Atot; + } - return 0.5 * A; - } + public double getB() { + return Btot; + } - @Override - public double calcATT(PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - double aij = 0, sqrtaij = 0, tempPow = 0; - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - - A = 0.0; - for (int i = 0; i < numbcomp; i++) { - for (int j = 0; j < numbcomp; j++) { - sqrtaij = Math.sqrt(compArray[i].getaT() * compArray[j].getaT()); - tempPow = compArray[i].getaT() * compArray[j].getaDiffT() - + compArray[j].getaT() * compArray[i].getaDiffT(); - aij = 0.5 * ((2.0 * compArray[i].getaDiffT() * compArray[j].getaDiffT() - + compArray[i].getaT() * compArray[j].getaDiffDiffT() - + compArray[j].getaT() * compArray[i].getaDiffDiffT()) / sqrtaij - - tempPow * tempPow / (2.0 * sqrtaij * compArray[i].getaT() - * compArray[j].getaT())); - A += compArray[i].getNumberOfMolesInPhase() - * compArray[j].getNumberOfMolesInPhase() * aij; - } - } - return A; - } + @Override + public double calcA(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + double aij = 0.0; + double A = 0.0; + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + + for (int i = 0; i < numbcomp; i++) { + for (int j = 0; j < numbcomp; j++) { + aij = Math.sqrt(compArray[i].getaT() * compArray[j].getaT()); + A += compArray[i].getNumberOfMolesInPhase() * compArray[j].getNumberOfMolesInPhase() + * aij; + } + } + Atot = A; + return A; + } - @Override - public ClassicVdW clone() { - ClassicVdW clonedSystem = null; - try { - clonedSystem = (ClassicVdW) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } + @Override + public double calcB(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + B = 0.0; + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + + for (int i = 0; i < numbcomp; i++) { + for (int j = 0; j < numbcomp; j++) { + B += compArray[i].getNumberOfMolesInPhase() * compArray[j].getNumberOfMolesInPhase() + * getbij(compArray[i], compArray[j]); // (compArray[i].getb()+compArray[j].getb())/2; + } + } + B /= phase.getNumberOfMolesInPhase(); + Btot = B; + return B; + } - return clonedSystem; - } + @Override + public double calcAi(int compNumb, PhaseInterface phase, double temperature, double pressure, + int numbcomp) { + double aij = 0; + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + + Ai = 0.0; + for (int j = 0; j < numbcomp; j++) { + aij = Math.sqrt(compArray[compNumb].getaT() * compArray[j].getaT()); + Ai += compArray[j].getNumberOfMolesInPhase() * aij; + } + + return 2.0 * Ai; } - public class ClassicSRK extends ClassicVdW { - private static final long serialVersionUID = 1000; + @Override + public double calcBi(int compNumb, PhaseInterface phase, double temperature, double pressure, + int numbcomp) { + double Bi = 0.0; - public double getkij(double temp, int i, int j) { - // System.out.println("kij " +intparam[i][j] ); - return intparam[i][j]; - } + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - @Override - public double calcA(PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - double aij = 0; - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - - A = 0.0; - for (int i = 0; i < numbcomp; i++) { - for (int j = 0; j < numbcomp; j++) { - aij = Math.sqrt(compArray[i].getaT() * compArray[j].getaT()) - * (1.0 - getkij(temperature, i, j)); - A += compArray[i].getNumberOfMolesInPhase() - * compArray[j].getNumberOfMolesInPhase() * aij; - } - } - Atot = A; - return A; - } + for (int j = 0; j < numbcomp; j++) { + Bi += compArray[j].getNumberOfMolesInPhase() * getbij(compArray[compNumb], compArray[j]); + } - // public double calcB(PhaseInterface phase, double temperature, double - // pressure, int numbcomp){ - // B = 0.0; - // ComponentEosInterface[] compArray = (ComponentEosInterface[]) - // phase.getcomponentArray(); - - // for (int i=0;i 1e-100) { - sqrtai[j] = Math.sqrt(compArray[j].getaT()); - } - } - A = 0.0; - for (int i = 0; i < numbcomp; i++) { - if (compArray[i].getNumberOfMolesInPhase() < 1e-100) { - continue; - } - for (int j = 0; j < numbcomp; j++) { - if (compArray[j].getNumberOfMolesInPhase() > 1e-100) { - aij = sqrtai[i] * sqrtai[j] * (1.0 - getkij(phase, temperature, i, j)); - A += compArray[i].getNumberOfMolesInPhase() - * compArray[j].getNumberOfMolesInPhase() * aij; - } - } - } - Atot = A; - return A; - } + // impl ttype check + } - @Override - public double calcAi(int compNumb, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - // if(Math.abs(intparamT[compNumb][numbcomp])<1e-10 && - // Math.abs(intparamij[compNumb][numbcomp]-intparamij[numbcomp][compNumb])<1e-10){ - // return super.calcAi(compNumb, phase, temperature, pressure, numbcomp); - // } - double aij = 0.0; - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - double A1 = 0.0; - double[] sqrtai = new double[numbcomp]; - for (int j = 0; j < numbcomp; j++) { - if (compArray[j].getNumberOfMolesInPhase() > 1e-100) { - sqrtai[j] = Math.sqrt(compArray[j].getaT()); - } - } - for (int j = 0; j < numbcomp; j++) { - if (compArray[j].getNumberOfMolesInPhase() > 1e-100) { - aij = sqrtai[compNumb] * sqrtai[j] - * (1.0 - getkij(phase, temperature, compNumb, j)); - A1 += compArray[j].getNumberOfMolesInPhase() * aij; - } - } - double A2 = 0.0; - for (int i = 0; i < numbcomp; i++) { - if (compArray[i].getNumberOfMolesInPhase() < 1e-100) { - continue; - } - for (int j = 0; j < numbcomp; j++) { - if (compArray[j].getNumberOfMolesInPhase() > 1e-100 - && (compNumb == j || compNumb == i) && i != j) { - aij = -sqrtai[i] * sqrtai[j] * getkijdn(compNumb, phase, temperature, i, j); - A2 += compArray[i].getNumberOfMolesInPhase() - * compArray[j].getNumberOfMolesInPhase() * aij; - } - } - } - return 2.0 * A1 + A2; - } + public double getkijdT(double temperature, int i, int j) { + return intparamT[i][j] * (1.0 / 273.15); + } - @Override - public double calcAij(int compNumb, int compNumbj, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - double aij = 0; - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - - double A1 = 0; - for (int j = 0; j < numbcomp; j++) { - aij = -Math.sqrt(compArray[compNumb].getaT() * compArray[j].getaT()) - * getkijdn(compNumbj, phase, temperature, compNumb, j); - A1 += compArray[j].getNumberOfMolesInPhase() * aij; - } - for (int j = 0; j < numbcomp; j++) { - aij = -Math.sqrt(compArray[compNumb].getaT() * compArray[j].getaT()) - * getkijdn(compNumbj, phase, temperature, j, compNumb); - A1 += compArray[j].getNumberOfMolesInPhase() * aij; - } + public double getkijdTdT(double temperature, int i, int j) { + return 0.0; + } - double A2 = 0; - for (int i = 0; i < numbcomp; i++) { - for (int j = 0; j < numbcomp; j++) { - aij = -Math.sqrt(compArray[i].getaT() * compArray[j].getaT()) - * getkijdndn(compNumb, compNumbj, phase, temperature, i, j); - A2 += compArray[i].getNumberOfMolesInPhase() - * compArray[j].getNumberOfMolesInPhase() * aij; - } - } + @Override + public double calcAiT(int compNumb, PhaseInterface phase, double temperature, double pressure, + int numbcomp) { + double A = 0.0; + double aij = 0.0; + double aij2 = 0.0; + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + + for (int j = 0; j < numbcomp; j++) { + aij = 0.5 / Math.sqrt(compArray[compNumb].getaT() * compArray[j].getaT()) + * (compArray[compNumb].getaT() * compArray[j].getaDiffT() + + compArray[j].getaT() * compArray[compNumb].getaDiffT()) + * (1.0 - getkij(temperature, compNumb, j)); + aij2 = Math.sqrt(compArray[compNumb].getaT() * compArray[j].getaT()) + * (-getkijdT(temperature, compNumb, j)); + A += compArray[j].getNumberOfMolesInPhase() * (aij + aij2); + } + // System.out.println("Ait SRK : " + (2*A)); + return 2.0 * A; + } - double A4 = 0; + public double calcAiTT(int compNumb, PhaseInterface phase, double temperature, double pressure, + int numbcomp) { + double A = 0.0; + double aij = 0.0; + double aij2 = 0.0; + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + + for (int j = 0; j < numbcomp; j++) { + aij = 0.5 / Math.sqrt(compArray[compNumb].getaT() * compArray[j].getaT()) + * (compArray[compNumb].getaT() * compArray[j].getaDiffT() + + compArray[j].getaT() * compArray[compNumb].getaDiffT()) + * (1.0 - getkij(temperature, compNumb, j)); + aij2 = Math.sqrt(compArray[compNumb].getaT() * compArray[j].getaT()) + * (-getkijdT(temperature, compNumb, j)); + A += compArray[j].getNumberOfMolesInPhase() * (aij + aij2); + } + // System.out.println("Ait SRK : " + (2*A)); + return 2.0 * A; + } - A4 = 2.0 * Math.sqrt(compArray[compNumb].getaT() * compArray[compNumbj].getaT()) - * (1.0 - getkij(phase, temperature, compNumbj, compNumb)); + @Override + public double calcATT(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + double aij = 0.0; + double aij2 = 0.0; + double aij3 = 0.0; + double aij4 = 0.0; + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + A = 0.0; + for (int i = 0; i < numbcomp; i++) { + for (int j = 0; j < numbcomp; j++) { + aij = 0.5 + * ((2.0 * compArray[i].getaDiffT() * compArray[j].getaDiffT() + + compArray[i].getaT() * compArray[j].getaDiffDiffT() + + compArray[j].getaT() * compArray[i].getaDiffDiffT()) + / Math.sqrt(compArray[i].getaT() * compArray[j].getaT()) + - Math + .pow(compArray[i].getaT() * compArray[j].getaDiffT() + + compArray[j].getaT() * compArray[i].getaDiffT(), 2) + / (2 * Math.sqrt(compArray[i].getaT() * compArray[j].getaT()) + * compArray[i].getaT() * compArray[j].getaT())) + * (1.0 - getkij(temperature, i, j)); + + aij2 = 0.5 / Math.sqrt(compArray[i].getaT() * compArray[j].getaT()) + * (compArray[i].getaT() * compArray[j].getaDiffT() + + compArray[j].getaT() * compArray[i].getaDiffT()) + * (-getkijdT(temperature, i, j)); + + aij3 = 0.5 / Math.sqrt(compArray[i].getaT() * compArray[j].getaT()) + * (compArray[i].getaT() * compArray[j].getaDiffT() + + compArray[j].getaT() * compArray[i].getaDiffT()) + * (-getkijdT(temperature, i, j)); + aij4 = Math.sqrt(compArray[i].getaT() * compArray[j].getaT()) + * (-getkijdTdT(temperature, i, j)); + A += compArray[i].getNumberOfMolesInPhase() * compArray[j].getNumberOfMolesInPhase() + * (aij + aij2 + aij3 + aij4); + } + } + return A; + } - for (int i = 0; i < numbcomp; i++) { - A4 += -compArray[i].getNumberOfMolesInPhase() - * Math.sqrt(compArray[compNumbj].getaT() * compArray[i].getaT()) - * getkijdn(compNumb, phase, temperature, compNumbj, i); - } - for (int i = 0; i < numbcomp; i++) { - A4 += -compArray[i].getNumberOfMolesInPhase() - * Math.sqrt(compArray[compNumbj].getaT() * compArray[i].getaT()) - * getkijdn(compNumb, phase, temperature, i, compNumbj); - } + @Override + public ClassicSRKT clone() { + ClassicSRKT clonedSystem = null; + try { + clonedSystem = (ClassicSRKT) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); + } + + return clonedSystem; + } + } - return A1 + A2 + A4; - } + public class ClassicSRKT2x extends ClassicSRKT2 { + private static final long serialVersionUID = 1000; - @Override - public double calcAiT(int compNumb, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - double A = 0.0; - double aij = 0.0, aij2 = 0.0, aij3 = 0; - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - double[] asqrt = new double[numbcomp]; - for (int j = 0; j < numbcomp; j++) { - asqrt[j] = Math.sqrt(compArray[j].getaT()); - } + public double getkij(PhaseInterface phase, double temperature, int i, int j) { + if (i == j) { + return 0.0; + } + double tot = phase.getComponent(i).getNumberOfMolesInPhase() + + phase.getComponent(j).getNumberOfMolesInPhase(); + if (tot < 1e-100) { + return 0.0; + } + double intkijMix = (phase.getComponent(i).getNumberOfMolesInPhase() * intparamij[i][j] + + phase.getComponent(j).getNumberOfMolesInPhase() * intparamji[i][j]) / tot; + // System.out.println("kij " + intkijMix + " kijT " +(intkijMix + + // intparamT[i][j] * temperature)); + + if (intparamTType[i][j] == 0) { + return intkijMix + intparamT[i][j] * temperature; + } else if (intparamTType[i][j] == 1) { + // System.out.println("kj mix " + (intkijMix +intparamT[i][j] / temperature)); + return intkijMix + intparamT[i][j] / temperature; + } else { + return intkijMix + intparamT[i][j] * temperature; + } + } - for (int j = 0; j < numbcomp; j++) { - if (compArray[j].getNumberOfMolesInPhase() < 1e-100) { - continue; - } - aij = 0.5 / asqrt[compNumb] / asqrt[j] - * (compArray[compNumb].getaT() * compArray[j].getaDiffT() - + compArray[j].getaT() * compArray[compNumb].getaDiffT()) - * (1.0 - getkij(phase, temperature, compNumb, j)); - aij2 = asqrt[compNumb] * asqrt[j] * (-getkijdT(temperature, compNumb, j)); - A += compArray[j].getNumberOfMolesInPhase() * (aij + aij2); - } + public double getkijdn(int k, PhaseInterface phase, double temperature, int i, int j) { + if (i == j || !((i == k) || (j == k)) + || Math.abs(intparamij[i][j] - intparamji[i][j]) < 1e-10) { + return 0.0; + } + double tot = phase.getComponent(i).getNumberOfMolesInPhase() + + phase.getComponent(j).getNumberOfMolesInPhase(); + if (tot < 1e-100) { + return 0.0; + } + double intkijMix = (phase.getComponent(i).getNumberOfMolesInPhase() * intparamij[i][j] + + phase.getComponent(j).getNumberOfMolesInPhase() * intparamji[i][j]) / tot; + + double temp = 0; + if (i == k) { + temp = intparamij[i][j]; + } else { + temp = intparamji[i][j]; + } + intkijMix = (temp - intkijMix) / tot; + + return intkijMix; + } - double A2 = 0; - for (int i = 0; i < numbcomp; i++) { - if (compArray[i].getNumberOfMolesInPhase() < 1e-100) { - continue; - } - for (int j = 0; j < numbcomp; j++) { - if (compArray[j].getNumberOfMolesInPhase() > 1e-100 - && (compNumb == j || compNumb == i) && i != j) { - aij3 = -0.5 / asqrt[compNumb] / asqrt[j] - * (compArray[compNumb].getaT() * compArray[j].getaDiffT() - + compArray[j].getaT() * compArray[compNumb].getaDiffT()) - * getkijdn(compNumb, phase, temperature, i, j); - A2 += compArray[i].getNumberOfMolesInPhase() - * compArray[j].getNumberOfMolesInPhase() * aij3; - } - } - } + public double getkijdndn(int k, int l, PhaseInterface phase, double temperature, int i, int j) { + if (i == j) { + return 0.0; + } + double tot = phase.getComponent(i).getNumberOfMolesInPhase() + + phase.getComponent(j).getNumberOfMolesInPhase(); + if (tot < 1e-100) { + return 0.0; + } + double temp = 0; + if ((i == k || j == k) && (i == l || j == l)) { + if (k == i && l == i) { + temp = -2.0 * intparamij[i][j] / (tot * tot) + + 2.0 * phase.getComponent(i).getNumberOfMolesInPhase() / (tot * tot * tot) + * intparamij[i][j] + + 2.0 * phase.getComponent(j).getNumberOfMolesInPhase() / (tot * tot * tot) + * intparamji[i][j]; + } else if (k == i && l == j) { + temp = -intparamij[i][j] / (tot * tot) + + 2.0 * phase.getComponent(i).getNumberOfMolesInPhase() / (tot * tot * tot) + * intparamij[i][j] + - 1.0 / (tot * tot) * intparamji[i][j] + + 2.0 * phase.getComponent(j).getNumberOfMolesInPhase() / (tot * tot * tot) + * intparamji[i][j]; + } else if (k == j && l == i) { + temp = -intparamji[i][j] / (tot * tot) + + 2.0 * phase.getComponent(j).getNumberOfMolesInPhase() / (tot * tot * tot) + * intparamji[i][j] + - 1.0 / (tot * tot) * intparamij[i][j] + + 2.0 * phase.getComponent(i).getNumberOfMolesInPhase() / (tot * tot * tot) + * intparamij[i][j]; + } else if (k == j && l == j) { + temp = -2.0 * intparamji[i][j] / (tot * tot) + + 2.0 * phase.getComponent(j).getNumberOfMolesInPhase() / (tot * tot * tot) + * intparamji[i][j] + + 2.0 * phase.getComponent(i).getNumberOfMolesInPhase() / (tot * tot * tot) + * intparamij[i][j]; + } + } else { + temp = 0.0; + } + return temp; + } - // System.out.println("Ait SRK : " + (2*A)); - return 2.0 * A + A2; - } + @Override + public double calcA(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + double aij = 0; + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + double[] sqrtai = new double[numbcomp]; + for (int j = 0; j < numbcomp; j++) { + if (compArray[j].getNumberOfMolesInPhase() > 1e-100) { + sqrtai[j] = Math.sqrt(compArray[j].getaT()); + } + } + A = 0.0; + for (int i = 0; i < numbcomp; i++) { + if (compArray[i].getNumberOfMolesInPhase() < 1e-100) { + continue; + } + for (int j = 0; j < numbcomp; j++) { + if (compArray[j].getNumberOfMolesInPhase() > 1e-100) { + aij = sqrtai[i] * sqrtai[j] * (1.0 - getkij(phase, temperature, i, j)); + A += compArray[i].getNumberOfMolesInPhase() * compArray[j].getNumberOfMolesInPhase() + * aij; + } + } + } + Atot = A; + return A; } - public class ClassicSRKT2 extends ClassicSRKT { - private static final long serialVersionUID = 1000; + @Override + public double calcAi(int compNumb, PhaseInterface phase, double temperature, double pressure, + int numbcomp) { + // if(Math.abs(intparamT[compNumb][numbcomp])<1e-10 && + // Math.abs(intparamij[compNumb][numbcomp]-intparamij[numbcomp][compNumb])<1e-10){ + // return super.calcAi(compNumb, phase, temperature, pressure, numbcomp); + // } + double aij = 0.0; + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + double A1 = 0.0; + double[] sqrtai = new double[numbcomp]; + for (int j = 0; j < numbcomp; j++) { + if (compArray[j].getNumberOfMolesInPhase() > 1e-100) { + sqrtai[j] = Math.sqrt(compArray[j].getaT()); + } + } + for (int j = 0; j < numbcomp; j++) { + if (compArray[j].getNumberOfMolesInPhase() > 1e-100) { + aij = sqrtai[compNumb] * sqrtai[j] * (1.0 - getkij(phase, temperature, compNumb, j)); + A1 += compArray[j].getNumberOfMolesInPhase() * aij; + } + } + double A2 = 0.0; + for (int i = 0; i < numbcomp; i++) { + if (compArray[i].getNumberOfMolesInPhase() < 1e-100) { + continue; + } + for (int j = 0; j < numbcomp; j++) { + if (compArray[j].getNumberOfMolesInPhase() > 1e-100 && (compNumb == j || compNumb == i) + && i != j) { + aij = -sqrtai[i] * sqrtai[j] * getkijdn(compNumb, phase, temperature, i, j); + A2 += compArray[i].getNumberOfMolesInPhase() * compArray[j].getNumberOfMolesInPhase() + * aij; + } + } + } + return 2.0 * A1 + A2; + } - @Override - public double getkij(double temperature, int i, int j) { - if (intparamTType[i][j] == 0) { - return intparam[i][j] + intparamT[i][j] * temperature; - } else if (intparamTType[i][j] == 1) { - return intparam[i][j] + intparamT[i][j] / temperature; - } else { - return intparam[i][j] + intparamT[i][j] * temperature; - } - } + @Override + public double calcAij(int compNumb, int compNumbj, PhaseInterface phase, double temperature, + double pressure, int numbcomp) { + double aij = 0; + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + + double A1 = 0; + for (int j = 0; j < numbcomp; j++) { + aij = -Math.sqrt(compArray[compNumb].getaT() * compArray[j].getaT()) + * getkijdn(compNumbj, phase, temperature, compNumb, j); + A1 += compArray[j].getNumberOfMolesInPhase() * aij; + } + for (int j = 0; j < numbcomp; j++) { + aij = -Math.sqrt(compArray[compNumb].getaT() * compArray[j].getaT()) + * getkijdn(compNumbj, phase, temperature, j, compNumb); + A1 += compArray[j].getNumberOfMolesInPhase() * aij; + } + + double A2 = 0; + for (int i = 0; i < numbcomp; i++) { + for (int j = 0; j < numbcomp; j++) { + aij = -Math.sqrt(compArray[i].getaT() * compArray[j].getaT()) + * getkijdndn(compNumb, compNumbj, phase, temperature, i, j); + A2 += + compArray[i].getNumberOfMolesInPhase() * compArray[j].getNumberOfMolesInPhase() * aij; + } + } + + double A4 = 0; + + A4 = 2.0 * Math.sqrt(compArray[compNumb].getaT() * compArray[compNumbj].getaT()) + * (1.0 - getkij(phase, temperature, compNumbj, compNumb)); + + for (int i = 0; i < numbcomp; i++) { + A4 += -compArray[i].getNumberOfMolesInPhase() + * Math.sqrt(compArray[compNumbj].getaT() * compArray[i].getaT()) + * getkijdn(compNumb, phase, temperature, compNumbj, i); + } + for (int i = 0; i < numbcomp; i++) { + A4 += -compArray[i].getNumberOfMolesInPhase() + * Math.sqrt(compArray[compNumbj].getaT() * compArray[i].getaT()) + * getkijdn(compNumb, phase, temperature, i, compNumbj); + } + + return A1 + A2 + A4; + } - @Override - public double getkijdT(double temperature, int i, int j) { - if (intparamTType[i][j] == 0) { - return intparamT[i][j]; - } else if (intparamTType[i][j] == 1) { - return -intparamT[i][j] / (temperature * temperature); - } else { - return intparamT[i][j]; - } - } + @Override + public double calcAiT(int compNumb, PhaseInterface phase, double temperature, double pressure, + int numbcomp) { + double A = 0.0; + double aij = 0.0; + double aij2 = 0.0; + double aij3 = 0; + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + double[] asqrt = new double[numbcomp]; + for (int j = 0; j < numbcomp; j++) { + asqrt[j] = Math.sqrt(compArray[j].getaT()); + } + + for (int j = 0; j < numbcomp; j++) { + if (compArray[j].getNumberOfMolesInPhase() < 1e-100) { + continue; + } + aij = 0.5 / asqrt[compNumb] / asqrt[j] + * (compArray[compNumb].getaT() * compArray[j].getaDiffT() + + compArray[j].getaT() * compArray[compNumb].getaDiffT()) + * (1.0 - getkij(phase, temperature, compNumb, j)); + aij2 = asqrt[compNumb] * asqrt[j] * (-getkijdT(temperature, compNumb, j)); + A += compArray[j].getNumberOfMolesInPhase() * (aij + aij2); + } + + double A2 = 0; + for (int i = 0; i < numbcomp; i++) { + if (compArray[i].getNumberOfMolesInPhase() < 1e-100) { + continue; + } + for (int j = 0; j < numbcomp; j++) { + if (compArray[j].getNumberOfMolesInPhase() > 1e-100 && (compNumb == j || compNumb == i) + && i != j) { + aij3 = -0.5 / asqrt[compNumb] / asqrt[j] + * (compArray[compNumb].getaT() * compArray[j].getaDiffT() + + compArray[j].getaT() * compArray[compNumb].getaDiffT()) + * getkijdn(compNumb, phase, temperature, i, j); + A2 += compArray[i].getNumberOfMolesInPhase() * compArray[j].getNumberOfMolesInPhase() + * aij3; + } + } + } + + // System.out.println("Ait SRK : " + (2*A)); + return 2.0 * A + A2; + } + } - @Override - public double getkijdTdT(double temperature, int i, int j) { - if (intparamTType[i][j] == 0) { - return 0; - } else if (intparamTType[i][j] == 1) { - return 2.0 * intparamT[i][j] / (temperature * temperature * temperature); - } else { - return 0; - } - } + public class ClassicSRKT2 extends ClassicSRKT { + private static final long serialVersionUID = 1000; - @Override - public ClassicSRKT clone() { - ClassicSRKT clonedSystem = null; - try { - clonedSystem = super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } + @Override + public double getkij(double temperature, int i, int j) { + if (intparamTType[i][j] == 0) { + return intparam[i][j] + intparamT[i][j] * temperature; + } else if (intparamTType[i][j] == 1) { + return intparam[i][j] + intparamT[i][j] / temperature; + } else { + return intparam[i][j] + intparamT[i][j] * temperature; + } + } - return clonedSystem; - } + @Override + public double getkijdT(double temperature, int i, int j) { + if (intparamTType[i][j] == 0) { + return intparamT[i][j]; + } else if (intparamTType[i][j] == 1) { + return -intparamT[i][j] / (temperature * temperature); + } else { + return intparamT[i][j]; + } } - public class SRKHuronVidal extends ClassicSRK implements HVmixingRuleInterface { - private static final long serialVersionUID = 1000; - - PhaseInterface orgPhase; - PhaseGENRTLmodifiedHV gePhase; - double hwfc = 0; - // double[][] HValpha, HVgij; - - public SRKHuronVidal(PhaseInterface phase, double[][] HValpha, double[][] HVDij, - String[][] mixRule) { - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - this.orgPhase = phase; - hwfc = 1.0 - / (compArray[0].getDeltaEosParameters()[1] - - compArray[0].getDeltaEosParameters()[0]) - * Math.log((1.0 + compArray[0].getDeltaEosParameters()[1]) - / (1.0 + compArray[0].getDeltaEosParameters()[0])); - gePhase = new PhaseGENRTLmodifiedHV(orgPhase, HValpha, HVDij, mixRule, intparam); - gePhase.getExessGibbsEnergy(phase, phase.getNumberOfComponents(), - phase.getTemperature(), phase.getPressure(), 1); - gePhase.setProperties(phase); - } + @Override + public double getkijdTdT(double temperature, int i, int j) { + if (intparamTType[i][j] == 0) { + return 0; + } else if (intparamTType[i][j] == 1) { + return 2.0 * intparamT[i][j] / (temperature * temperature * temperature); + } else { + return 0; + } + } - public SRKHuronVidal(PhaseInterface phase, double[][] HValpha, double[][] HVDij, - double[][] HVDijT, String[][] mixRule) { - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - this.orgPhase = phase; - hwfc = 1.0 - / (compArray[0].getDeltaEosParameters()[1] - - compArray[0].getDeltaEosParameters()[0]) - * Math.log((1.0 + compArray[0].getDeltaEosParameters()[1]) - / (1.0 + compArray[0].getDeltaEosParameters()[0])); - gePhase = - new PhaseGENRTLmodifiedHV(orgPhase, HValpha, HVDij, HVDijT, mixRule, intparam); - gePhase.getExessGibbsEnergy(phase, phase.getNumberOfComponents(), - phase.getTemperature(), phase.getPressure(), 1); - gePhase.setProperties(phase); - } + @Override + public ClassicSRKT clone() { + ClassicSRKT clonedSystem = null; + try { + clonedSystem = super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); + } + + return clonedSystem; + } + } - @Override - public void setHVDijParameter(int i, int j, double value) { - HVDij[i][j] = value; - // System.out.println("hv " + value); - // HVDij[j][i] = value; - gePhase.setDij(HVDij); - } + public class SRKHuronVidal extends ClassicSRK implements HVmixingRuleInterface { + private static final long serialVersionUID = 1000; - @Override - public double getHVDijParameter(int i, int j) { - return HVDij[i][j]; - } + PhaseInterface orgPhase; + PhaseGENRTLmodifiedHV gePhase; + double hwfc = 0; + // double[][] HValpha, HVgij; + + public SRKHuronVidal(PhaseInterface phase, double[][] HValpha, double[][] HVDij, + String[][] mixRule) { + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + this.orgPhase = phase; + hwfc = + 1.0 / (compArray[0].getDeltaEosParameters()[1] - compArray[0].getDeltaEosParameters()[0]) + * Math.log((1.0 + compArray[0].getDeltaEosParameters()[1]) + / (1.0 + compArray[0].getDeltaEosParameters()[0])); + gePhase = new PhaseGENRTLmodifiedHV(orgPhase, HValpha, HVDij, mixRule, intparam); + gePhase.getExessGibbsEnergy(phase, phase.getNumberOfComponents(), phase.getTemperature(), + phase.getPressure(), 1); + gePhase.setProperties(phase); + } - @Override - public void setHVDijTParameter(int i, int j, double value) { - HVDijT[i][j] = value; - // HVDijT[j][i] = value; - gePhase.setDijT(HVDijT); - } + public SRKHuronVidal(PhaseInterface phase, double[][] HValpha, double[][] HVDij, + double[][] HVDijT, String[][] mixRule) { + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + this.orgPhase = phase; + hwfc = + 1.0 / (compArray[0].getDeltaEosParameters()[1] - compArray[0].getDeltaEosParameters()[0]) + * Math.log((1.0 + compArray[0].getDeltaEosParameters()[1]) + / (1.0 + compArray[0].getDeltaEosParameters()[0])); + gePhase = new PhaseGENRTLmodifiedHV(orgPhase, HValpha, HVDij, HVDijT, mixRule, intparam); + gePhase.getExessGibbsEnergy(phase, phase.getNumberOfComponents(), phase.getTemperature(), + phase.getPressure(), 1); + gePhase.setProperties(phase); + } - @Override - public double getHVDijTParameter(int i, int j) { - return HVDijT[i][j]; - } + @Override + public void setHVDijParameter(int i, int j, double value) { + HVDij[i][j] = value; + // System.out.println("hv " + value); + // HVDij[j][i] = value; + gePhase.setDij(HVDij); + } - @Override - public void setHValphaParameter(int i, int j, double value) { - HValpha[i][j] = value; - HValpha[j][i] = value; - gePhase.setAlpha(HValpha); - } + @Override + public double getHVDijParameter(int i, int j) { + return HVDij[i][j]; + } - @Override - public double getHValphaParameter(int i, int j) { - return HValpha[i][j]; - } + @Override + public void setHVDijTParameter(int i, int j, double value) { + HVDijT[i][j] = value; + // HVDijT[j][i] = value; + gePhase.setDijT(HVDijT); + } - @Override - public double getKijWongSandler(int i, int j) { - return WSintparam[i][j]; - } + @Override + public double getHVDijTParameter(int i, int j) { + return HVDijT[i][j]; + } - @Override - public void setKijWongSandler(int i, int j, double value) { - WSintparam[i][j] = value; - WSintparam[j][i] = value; - } + @Override + public void setHValphaParameter(int i, int j, double value) { + HValpha[i][j] = value; + HValpha[j][i] = value; + gePhase.setAlpha(HValpha); + } - @Override - public double calcA(PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - double A = 0.0; - double aij = 0.0; - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - gePhase.setProperties(phase); - - for (int i = 0; i < numbcomp; i++) { - aij = compArray[i].getaT() / compArray[i].getb(); - A += compArray[i].getNumberOfMolesInPhase() * aij; - } - A = calcB(phase, temperature, pressure, numbcomp) * (A - phase.getNumberOfMolesInPhase() - * gePhase.getExessGibbsEnergy(phase, phase.getNumberOfComponents(), - phase.getTemperature(), phase.getPressure(), 0) - / gePhase.getNumberOfMolesInPhase() / hwfc); - Atot = A; - return A; - } + @Override + public double getHValphaParameter(int i, int j) { + return HValpha[i][j]; + } - @Override - public double calcAi(int compNumb, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - double A = 0.0; - double aij = 0; - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - aij = compArray[compNumb].getaT() / compArray[compNumb].getb(); - A = getB() * (aij - R * temperature - * Math.log( - ((ComponentGEInterface) gePhase.getComponents()[compNumb]).getGamma()) - / hwfc); - - A += getA() * calcBi(compNumb, phase, temperature, pressure, numbcomp) / getB(); - // System.out.println("Ai HV : " + A); - return A; - } + @Override + public double getKijWongSandler(int i, int j) { + return WSintparam[i][j]; + } - @Override - public double calcAiT(int compNumb, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - double A = 0; - - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - - A = getB() - * (compArray[compNumb].getaDiffT() / compArray[compNumb].getb() - R * Math.log( - ((ComponentGEInterface) gePhase.getComponents()[compNumb]).getGamma()) - / hwfc - - R * temperature - * ((ComponentGEInterface) gePhase.getComponents()[compNumb]) - .getlnGammadt() - / hwfc) - + compArray[compNumb].getb() * calcAT(phase, temperature, pressure, numbcomp) - / getB();// ....); - // 0.5/Math.sqrt(compArray[compNumb].getaT()*compArray[j].getaT())*(compArray[compNumb].getaT() - // * - // compArray[j].getaDiffT() - // +compArray[j].getaT() - // * - // compArray[compNumb].getaDiffT())*(1-intparam[compNumb][j]); - // System.out.println("Ait HV: " + A); - - return A; - } + @Override + public void setKijWongSandler(int i, int j, double value) { + WSintparam[i][j] = value; + WSintparam[j][i] = value; + } - @Override - public double calcAT(PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - double A = 0; - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - for (int i = 0; i < numbcomp; i++) { - A += compArray[i].getNumberOfMolesInPhase() - * (compArray[i].getaDiffT() / compArray[i].getb() - - R * Math.log(((ComponentGEInterface) gePhase.getComponents()[i]) - .getGamma()) / hwfc - - R * temperature - * ((ComponentGEInterface) gePhase.getComponents()[i]) - .getlnGammadt() - / Math.log(2.0));// ....); - // 0.5/Math.sqrt(compArray[compNumb].getaT()*compArray[j].getaT())*(compArray[compNumb].getaT() - // * compArray[j].getaDiffT() - // +compArray[j].getaT() * - // compArray[compNumb].getaDiffT())*(1-intparam[compNumb][j]); - } + @Override + public double calcA(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + double A = 0.0; + double aij = 0.0; + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + gePhase.setProperties(phase); + + for (int i = 0; i < numbcomp; i++) { + aij = compArray[i].getaT() / compArray[i].getb(); + A += compArray[i].getNumberOfMolesInPhase() * aij; + } + A = calcB(phase, temperature, pressure, numbcomp) * (A - phase.getNumberOfMolesInPhase() + * gePhase.getExessGibbsEnergy(phase, phase.getNumberOfComponents(), + phase.getTemperature(), phase.getPressure(), 0) + / gePhase.getNumberOfMolesInPhase() / hwfc); + Atot = A; + return A; + } - A *= getB(); - // System.out.println("AT HV: " + A); - return A; - } + @Override + public double calcAi(int compNumb, PhaseInterface phase, double temperature, double pressure, + int numbcomp) { + double A = 0.0; + double aij = 0; + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + aij = compArray[compNumb].getaT() / compArray[compNumb].getb(); + A = getB() * (aij - R * temperature + * Math.log(((ComponentGEInterface) gePhase.getComponents()[compNumb]).getGamma()) / hwfc); + + A += getA() * calcBi(compNumb, phase, temperature, pressure, numbcomp) / getB(); + // System.out.println("Ai HV : " + A); + return A; + } - @Override - public double calcAij(int compNumb, int compNumbj, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - double aij = - compArray[compNumbj].getb() - * (compArray[compNumb].getaT() / compArray[compNumb].getb() - - R * temperature - * Math.log(((ComponentGEInterface) gePhase - .getComponents()[compNumb]).getGamma()) - / hwfc) - - getB() * R * temperature / hwfc - * ((ComponentGEInterface) gePhase.getComponents()[compNumb]) - .getlnGammadn(compNumbj) - + compArray[compNumb].getb() - * (compArray[compNumbj].getaT() / compArray[compNumbj].getb() - - R * temperature - * Math.log(((ComponentGEInterface) gePhase - .getComponents()[compNumbj]).getGamma()) - / hwfc); - return aij; - } + @Override + public double calcAiT(int compNumb, PhaseInterface phase, double temperature, double pressure, + int numbcomp) { + double A = 0; + + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + + A = getB() + * (compArray[compNumb].getaDiffT() / compArray[compNumb].getb() + - R * Math.log(((ComponentGEInterface) gePhase.getComponents()[compNumb]).getGamma()) + / hwfc + - R * temperature + * ((ComponentGEInterface) gePhase.getComponents()[compNumb]).getlnGammadt() + / hwfc) + + compArray[compNumb].getb() * calcAT(phase, temperature, pressure, numbcomp) / getB(); // ....); + // 0.5/Math.sqrt(compArray[compNumb].getaT()*compArray[j].getaT())*(compArray[compNumb].getaT() + // * + // compArray[j].getaDiffT() + // +compArray[j].getaT() + // * + // compArray[compNumb].getaDiffT())*(1-intparam[compNumb][j]); + // System.out.println("Ait HV: " + A); + + return A; } - public class SRKHuronVidal2 extends ClassicSRK implements HVmixingRuleInterface { - private static final long serialVersionUID = 1000; - - PhaseInterface orgPhase; - PhaseGE gePhase; - double Q = 0, QT = 0, DDE2; - double alpha_mix = 0, dadt = 0, b_mix = 0, dbdt = 0, bdert = 0, d2adt2 = 0, d2bdt2 = 0; - double[] ader, adert, qf1, d2qp; - double[] qPure, qPuredT, qPuredTdT; - double[][] ad2, qf2, qft, bd2; - double hwfc = 0, gex = 0; - double[] oneSubAlf, abf, bc, abft2, abft, QFTD, BDER, BDERT; - - public SRKHuronVidal2(PhaseInterface phase, double[][] HValpha, double[][] HVDij, - String[][] mixRule) { - super(); - this.orgPhase = phase; - - if (mixingRuleGEModel.equals("NRTL")) { - gePhase = new PhaseGENRTLmodifiedHV(orgPhase, HValpha, HVDij, mixRule, intparam); - } else if (mixingRuleGEModel.equals("NRTL_HV")) { - gePhase = new PhaseGENRTLmodifiedHV(orgPhase, HValpha, HVDij, mixRule, intparam); - } else if (mixingRuleGEModel.equals("UNIQUAQ")) { - gePhase = new PhaseGENRTLmodifiedHV(orgPhase, HValpha, HVDij, mixRule, intparam); - } else if (mixingRuleGEModel.equals("UNIFAC")) { - gePhase = new PhaseGEUnifac(orgPhase, HValpha, HVDij, mixRule, intparam); - } else if (mixingRuleGEModel.equals("UNIFAC_PSRK")) { - gePhase = new PhaseGEUnifacPSRK(orgPhase, HValpha, HVDij, mixRule, intparam); - } else if (mixingRuleGEModel.equals("UNIFAC_UMRPRU")) { - gePhase = new PhaseGEUnifacUMRPRU(orgPhase, HValpha, HVDij, mixRule, intparam); - } else { - gePhase = new PhaseGEUnifac(orgPhase, HValpha, HVDij, mixRule, intparam); - } - gePhase.init(phase.getNumberOfMolesInPhase(), phase.getNumberOfComponents(), 0, - phase.getPhaseType(), phase.getBeta()); - gePhase.setProperties(phase); - } + @Override + public double calcAT(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + double A = 0; + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + for (int i = 0; i < numbcomp; i++) { + A += compArray[i].getNumberOfMolesInPhase() + * (compArray[i].getaDiffT() / compArray[i].getb() + - R * Math.log(((ComponentGEInterface) gePhase.getComponents()[i]).getGamma()) + / hwfc + - R * temperature + * ((ComponentGEInterface) gePhase.getComponents()[i]).getlnGammadt() + / Math.log(2.0)); // ....); + // 0.5/Math.sqrt(compArray[compNumb].getaT()*compArray[j].getaT())*(compArray[compNumb].getaT() + // * compArray[j].getaDiffT() + // +compArray[j].getaT() * + // compArray[compNumb].getaDiffT())*(1-intparam[compNumb][j]); + } + + A *= getB(); + // System.out.println("AT HV: " + A); + return A; + } - public SRKHuronVidal2(PhaseInterface phase, double[][] HValpha, double[][] HVDij, - double[][] HVDijT, String[][] mixRule) { - super(); - this.orgPhase = phase; - - if (mixingRuleGEModel.equals("NRTL")) { - gePhase = new PhaseGENRTLmodifiedHV(orgPhase, HValpha, HVDij, HVDijT, mixRule, - intparam); - } else if (mixingRuleGEModel.equals("NRTL_HV")) { - gePhase = new PhaseGENRTLmodifiedHV(orgPhase, HValpha, HVDij, mixRule, intparam); - } else if (mixingRuleGEModel.equals("UNIQUAQ")) { - gePhase = new PhaseGENRTLmodifiedHV(orgPhase, HValpha, HVDij, HVDijT, mixRule, - intparam); - } else if (mixingRuleGEModel.equals("UNIFAC")) { - gePhase = new PhaseGEUnifac(orgPhase, HValpha, HVDij, mixRule, intparam); - } else if (mixingRuleGEModel.equals("UNIFAC_PSRK")) { - gePhase = new PhaseGEUnifacPSRK(orgPhase, HValpha, HVDij, mixRule, intparam); - } else if (mixingRuleGEModel.equals("UNIFAC_UMRPRU")) { - gePhase = new PhaseGEUnifacUMRPRU(orgPhase, HValpha, HVDij, mixRule, intparam); - } else { - gePhase = new PhaseGEUnifac(orgPhase, HValpha, HVDij, mixRule, intparam); - } - gePhase.setProperties(phase); - // gePhase.init(phase.getNumberOfMolesInPhase(),phase.getNumberOfComponents(),0,phase.getPhaseType(),phase.getBeta()); - } + @Override + public double calcAij(int compNumb, int compNumbj, PhaseInterface phase, double temperature, + double pressure, int numbcomp) { + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + double aij = compArray[compNumbj].getb() + * (compArray[compNumb].getaT() / compArray[compNumb].getb() - R * temperature + * Math.log(((ComponentGEInterface) gePhase.getComponents()[compNumb]).getGamma()) + / hwfc) + - getB() * R * temperature / hwfc + * ((ComponentGEInterface) gePhase.getComponents()[compNumb]).getlnGammadn(compNumbj) + + compArray[compNumb].getb() + * (compArray[compNumbj].getaT() / compArray[compNumbj].getb() - R * temperature + * Math.log(((ComponentGEInterface) gePhase.getComponents()[compNumbj]).getGamma()) + / hwfc); + return aij; + } + } - public void init(PhaseInterface phase, double temperature, double pressure, int numbcomp) { - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + public class SRKHuronVidal2 extends ClassicSRK implements HVmixingRuleInterface { + private static final long serialVersionUID = 1000; - gePhase.setProperties(phase); - gePhase.setParams(phase, HValpha, HVDij, HVDijT, classicOrHV, intparam); + PhaseInterface orgPhase; + PhaseGE gePhase; + double Q = 0; - if (mixingRuleGEModel.equals("NRTL")) { - // gePhase.init(phase.getNumberOfMolesInPhase(),phase.getNumberOfComponents(),3,phase.getPhaseType(),phase.getBeta()); - gePhase.getExessGibbsEnergy(phase, numbcomp, temperature, pressure, - phase.getPhaseType()); - } else { - gePhase.init((phase.getNumberOfMolesInPhase() / phase.getBeta()), - phase.getNumberOfComponents(), phase.getInitType(), phase.getPhaseType(), - phase.getBeta()); - } + double QT = 0; - hwfc = -1.0 / (1.0 - / (compArray[0].getDeltaEosParameters()[1] - - compArray[0].getDeltaEosParameters()[0]) - * Math.log((1.0 + compArray[0].getDeltaEosParameters()[1]) - / (1.0 + compArray[0].getDeltaEosParameters()[0]))); - if (mixingRuleGEModel.equals("UNIFAC_PSRK")) { - hwfc = -1.0 / 0.64663; - } - if (mixingRuleGEModel.equals("UNIFAC_UMRPRU")) { - // hwfc = -1.0 / 0.64663; - hwfc = -1.0 / 0.53; - } + double DDE2; - double term = 0.0; - double dubdert = 0.0; - if (qPure == null) { - qPure = new double[numbcomp]; - qPuredT = new double[numbcomp]; - qPuredTdT = new double[numbcomp]; - ader = new double[numbcomp]; - adert = new double[numbcomp]; - ad2 = new double[numbcomp][numbcomp]; - qf2 = new double[numbcomp][numbcomp]; - bd2 = new double[numbcomp][numbcomp]; - qft = new double[numbcomp][numbcomp]; - qf1 = new double[numbcomp]; - oneSubAlf = new double[numbcomp]; - abf = new double[numbcomp]; - bc = new double[numbcomp]; - QFTD = new double[numbcomp]; - } - for (int i = 0; i < numbcomp; i++) { - qPure[i] = compArray[i].getaT() / (compArray[i].getb() * R * temperature); - if (phase.getInitType() > 1) { - qPuredT[i] = -compArray[i].getaT() - / (compArray[i].getb() * R * temperature * temperature) - + compArray[i].diffaT(temperature) - / (compArray[i].getb() * R * temperature); - qPuredTdT[i] = 2.0 * compArray[i].getaT() - / (compArray[i].getb() * R * Math.pow(temperature, 3.0)) - - compArray[i].getaDiffT() - / (compArray[i].getb() * R * temperature * temperature) - + compArray[i].getaDiffDiffT() / (compArray[i].getb() * R * temperature) - - compArray[i].getaDiffT() - / (compArray[i].getb() * R * temperature * temperature); - } - } + double alpha_mix = 0; - alpha_mix = 0.0; - dadt = 0.0; - for (int i = 0; i < numbcomp; i++) { - term = qPure[i] + hwfc - * Math.log(((ComponentGEInterface) gePhase.getComponents()[i]).getGamma()); - alpha_mix += phase.getComponents()[i].getNumberOfMolesInPhase() - / phase.getNumberOfMolesInPhase() * term; - ader[i] = term; - compArray[i].setAder(ader[i]); - - if (phase.getInitType() > 1) { - term = qPuredT[i] + hwfc - * ((ComponentGEInterface) gePhase.getComponents()[i]).getlnGammadt(); - dubdert += (qPuredTdT[i] + hwfc - * ((ComponentGEInterface) gePhase.getComponents()[i]).getlnGammadtdt()) - * phase.getComponents()[i].getNumberOfMolesInPhase() - / phase.getNumberOfMolesInPhase(); - dadt += term * phase.getComponents()[i].getNumberOfMolesInPhase() - / phase.getNumberOfMolesInPhase(); - adert[i] = term; - compArray[i].setdAdTdn(adert[i]); - } - } + double dadt = 0; - d2adt2 = dubdert; + double b_mix = 0; - if (phase.getInitType() > 2) { - for (int i = 0; i < numbcomp; i++) { - for (int j = 0; j < numbcomp; j++) { - ad2[i][j] = hwfc * ((ComponentGEInterface) gePhase.getComponents()[i]) - .getlnGammadn(j); - compArray[i].setdAdndn(j, ad2[i][j]); - } - } - } - } + double dbdt = 0; - @Override - public PhaseInterface getGEPhase() { - return gePhase; - } + double bdert = 0; - @Override - public void setHVDijParameter(int i, int j, double value) { - HVDij[i][j] = value; - gePhase.setDij(HVDij); - } + double d2adt2 = 0; + + double d2bdt2 = 0; + + double[] ader; + + double[] adert; + + double[] qf1; + + double[] d2qp; + + double[] qPure; + + double[] qPuredT; + + double[] qPuredTdT; + + double[][] ad2; + + double[][] qf2; + + double[][] qft; + + double[][] bd2; + + double hwfc = 0; + + double gex = 0; + + double[] oneSubAlf; + + double[] abf; + + double[] bc; + + double[] abft2; + + double[] abft; + + double[] QFTD; + + double[] BDER; + + double[] BDERT; - @Override - public double getHVDijParameter(int i, int j) { - return HVDij[i][j]; - } + public SRKHuronVidal2(PhaseInterface phase, double[][] HValpha, double[][] HVDij, + String[][] mixRule) { + super(); + this.orgPhase = phase; - @Override - public void setHVDijTParameter(int i, int j, double value) { - HVDijT[i][j] = value; - gePhase.setDijT(HVDijT); - } + if (mixingRuleGEModel.equals("NRTL")) { + gePhase = new PhaseGENRTLmodifiedHV(orgPhase, HValpha, HVDij, mixRule, intparam); + } else if (mixingRuleGEModel.equals("NRTL_HV")) { + gePhase = new PhaseGENRTLmodifiedHV(orgPhase, HValpha, HVDij, mixRule, intparam); + } else if (mixingRuleGEModel.equals("UNIQUAQ")) { + gePhase = new PhaseGENRTLmodifiedHV(orgPhase, HValpha, HVDij, mixRule, intparam); + } else if (mixingRuleGEModel.equals("UNIFAC")) { + gePhase = new PhaseGEUnifac(orgPhase, HValpha, HVDij, mixRule, intparam); + } else if (mixingRuleGEModel.equals("UNIFAC_PSRK")) { + gePhase = new PhaseGEUnifacPSRK(orgPhase, HValpha, HVDij, mixRule, intparam); + } else if (mixingRuleGEModel.equals("UNIFAC_UMRPRU")) { + gePhase = new PhaseGEUnifacUMRPRU(orgPhase, HValpha, HVDij, mixRule, intparam); + } else { + gePhase = new PhaseGEUnifac(orgPhase, HValpha, HVDij, mixRule, intparam); + } + gePhase.init(phase.getNumberOfMolesInPhase(), phase.getNumberOfComponents(), 0, + phase.getPhaseType(), phase.getBeta()); + gePhase.setProperties(phase); + } - @Override - public double getHVDijTParameter(int i, int j) { - return HVDijT[i][j]; - } + public SRKHuronVidal2(PhaseInterface phase, double[][] HValpha, double[][] HVDij, + double[][] HVDijT, String[][] mixRule) { + super(); + this.orgPhase = phase; + + if (mixingRuleGEModel.equals("NRTL")) { + gePhase = new PhaseGENRTLmodifiedHV(orgPhase, HValpha, HVDij, HVDijT, mixRule, intparam); + } else if (mixingRuleGEModel.equals("NRTL_HV")) { + gePhase = new PhaseGENRTLmodifiedHV(orgPhase, HValpha, HVDij, mixRule, intparam); + } else if (mixingRuleGEModel.equals("UNIQUAQ")) { + gePhase = new PhaseGENRTLmodifiedHV(orgPhase, HValpha, HVDij, HVDijT, mixRule, intparam); + } else if (mixingRuleGEModel.equals("UNIFAC")) { + gePhase = new PhaseGEUnifac(orgPhase, HValpha, HVDij, mixRule, intparam); + } else if (mixingRuleGEModel.equals("UNIFAC_PSRK")) { + gePhase = new PhaseGEUnifacPSRK(orgPhase, HValpha, HVDij, mixRule, intparam); + } else if (mixingRuleGEModel.equals("UNIFAC_UMRPRU")) { + gePhase = new PhaseGEUnifacUMRPRU(orgPhase, HValpha, HVDij, mixRule, intparam); + } else { + gePhase = new PhaseGEUnifac(orgPhase, HValpha, HVDij, mixRule, intparam); + } + gePhase.setProperties(phase); + // gePhase.init(phase.getNumberOfMolesInPhase(),phase.getNumberOfComponents(),0,phase.getPhaseType(),phase.getBeta()); + } - @Override - public void setHValphaParameter(int i, int j, double value) { - HValpha[i][j] = value; - HValpha[j][i] = value; - gePhase.setAlpha(HValpha); - } + public void init(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + + gePhase.setProperties(phase); + gePhase.setParams(phase, HValpha, HVDij, HVDijT, classicOrHV, intparam); + + if (mixingRuleGEModel.equals("NRTL")) { + // gePhase.init(phase.getNumberOfMolesInPhase(),phase.getNumberOfComponents(),3,phase.getPhaseType(),phase.getBeta()); + gePhase.getExessGibbsEnergy(phase, numbcomp, temperature, pressure, phase.getPhaseType()); + } else { + gePhase.init((phase.getNumberOfMolesInPhase() / phase.getBeta()), + phase.getNumberOfComponents(), phase.getInitType(), phase.getPhaseType(), + phase.getBeta()); + } + + hwfc = -1.0 / (1.0 + / (compArray[0].getDeltaEosParameters()[1] - compArray[0].getDeltaEosParameters()[0]) + * Math.log((1.0 + compArray[0].getDeltaEosParameters()[1]) + / (1.0 + compArray[0].getDeltaEosParameters()[0]))); + if (mixingRuleGEModel.equals("UNIFAC_PSRK")) { + hwfc = -1.0 / 0.64663; + } + if (mixingRuleGEModel.equals("UNIFAC_UMRPRU")) { + // hwfc = -1.0 / 0.64663; + hwfc = -1.0 / 0.53; + } + + double term = 0.0; + double dubdert = 0.0; + if (qPure == null) { + qPure = new double[numbcomp]; + qPuredT = new double[numbcomp]; + qPuredTdT = new double[numbcomp]; + ader = new double[numbcomp]; + adert = new double[numbcomp]; + ad2 = new double[numbcomp][numbcomp]; + qf2 = new double[numbcomp][numbcomp]; + bd2 = new double[numbcomp][numbcomp]; + qft = new double[numbcomp][numbcomp]; + qf1 = new double[numbcomp]; + oneSubAlf = new double[numbcomp]; + abf = new double[numbcomp]; + bc = new double[numbcomp]; + QFTD = new double[numbcomp]; + } + for (int i = 0; i < numbcomp; i++) { + qPure[i] = compArray[i].getaT() / (compArray[i].getb() * R * temperature); + if (phase.getInitType() > 1) { + qPuredT[i] = -compArray[i].getaT() / (compArray[i].getb() * R * temperature * temperature) + + compArray[i].diffaT(temperature) / (compArray[i].getb() * R * temperature); + qPuredTdT[i] = + 2.0 * compArray[i].getaT() / (compArray[i].getb() * R * Math.pow(temperature, 3.0)) + - compArray[i].getaDiffT() / (compArray[i].getb() * R * temperature * temperature) + + compArray[i].getaDiffDiffT() / (compArray[i].getb() * R * temperature) + - compArray[i].getaDiffT() + / (compArray[i].getb() * R * temperature * temperature); + } + } + + alpha_mix = 0.0; + dadt = 0.0; + for (int i = 0; i < numbcomp; i++) { + term = qPure[i] + + hwfc * Math.log(((ComponentGEInterface) gePhase.getComponents()[i]).getGamma()); + alpha_mix += phase.getComponents()[i].getNumberOfMolesInPhase() + / phase.getNumberOfMolesInPhase() * term; + ader[i] = term; + compArray[i].setAder(ader[i]); + + if (phase.getInitType() > 1) { + term = qPuredT[i] + + hwfc * ((ComponentGEInterface) gePhase.getComponents()[i]).getlnGammadt(); + dubdert += (qPuredTdT[i] + + hwfc * ((ComponentGEInterface) gePhase.getComponents()[i]).getlnGammadtdt()) + * phase.getComponents()[i].getNumberOfMolesInPhase() + / phase.getNumberOfMolesInPhase(); + dadt += term * phase.getComponents()[i].getNumberOfMolesInPhase() + / phase.getNumberOfMolesInPhase(); + adert[i] = term; + compArray[i].setdAdTdn(adert[i]); + } + } + + d2adt2 = dubdert; + + if (phase.getInitType() > 2) { + for (int i = 0; i < numbcomp; i++) { + for (int j = 0; j < numbcomp; j++) { + ad2[i][j] = hwfc * ((ComponentGEInterface) gePhase.getComponents()[i]).getlnGammadn(j); + compArray[i].setdAdndn(j, ad2[i][j]); + } + } + } + } - @Override - public double getHValphaParameter(int i, int j) { - return HValpha[i][j]; - } + @Override + public PhaseInterface getGEPhase() { + return gePhase; + } - @Override - public double getKijWongSandler(int i, int j) { - return WSintparam[i][j]; - } + @Override + public void setHVDijParameter(int i, int j, double value) { + HVDij[i][j] = value; + gePhase.setDij(HVDij); + } - @Override - public void setKijWongSandler(int i, int j, double value) { - WSintparam[i][j] = value; - WSintparam[j][i] = value; - } + @Override + public double getHVDijParameter(int i, int j) { + return HVDij[i][j]; + } - @Override - public double calcA(PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - double A = 0.0; - this.init(phase, temperature, pressure, numbcomp); - // A = phase.getNumberOfMolesInPhase() * calcB(phase, temperature, pressure, - // numbcomp) * R * temperature * alpha_mix; - A = phase.getNumberOfMolesInPhase() * phase.getB() * R * temperature * alpha_mix; - - // System.out.println("A: " + A); - Atot = A; - return A; - } + @Override + public void setHVDijTParameter(int i, int j, double value) { + HVDijT[i][j] = value; + gePhase.setDijT(HVDijT); + } - @Override - public double calcAi(int compNumb, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - double A = 0.0; - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - - // A = getB() * R * temperature * compArray[compNumb].getAder() + - // phase.getNumberOfMolesInPhase() * calcBi(compNumb, phase, temperature, - // pressure, numbcomp) * R * temperature * alpha_mix; - A = getB() * R * temperature * compArray[compNumb].getAder() - + phase.getNumberOfMolesInPhase() * compArray[compNumb].getBi() * R - * temperature * alpha_mix;;// calcBi(compNumb, phase, temperature, - // pressure, numbcomp) * R * temperature * - // alpha_mix; - - // System.out.println("Ai: " + A); - return A; - } + @Override + public double getHVDijTParameter(int i, int j) { + return HVDijT[i][j]; + } - @Override - public double calcAij(int compNumb, int compNumbj, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - double A = 0.0; - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - - A = calcBi(compNumbj, phase, temperature, pressure, numbcomp) * R * temperature - * compArray[compNumb].getAder() - + getB() * R * temperature * compArray[compNumb].getdAdndn(compNumbj) - + calcBi(compNumb, phase, temperature, pressure, numbcomp) * R * temperature - * compArray[compNumbj].getAder() - + calcBij(compNumb, compNumbj, phase, temperature, pressure, numbcomp) - * phase.getNumberOfMolesInPhase() * R * temperature * alpha_mix; - - return A; - } + @Override + public void setHValphaParameter(int i, int j, double value) { + HValpha[i][j] = value; + HValpha[j][i] = value; + gePhase.setAlpha(HValpha); + } - @Override - public double calcAT(PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - double A = 0.0; - // ComponentEosInterface[] compArray = (ComponentEosInterface[]) - // phase.getcomponentArray(); + @Override + public double getHValphaParameter(int i, int j) { + return HValpha[i][j]; + } - A = phase.getNumberOfMolesInPhase() * getB() * R * temperature * dadt - + phase.getNumberOfMolesInPhase() * getB() * R * alpha_mix; + @Override + public double getKijWongSandler(int i, int j) { + return WSintparam[i][j]; + } - return A; - } + @Override + public void setKijWongSandler(int i, int j, double value) { + WSintparam[i][j] = value; + WSintparam[j][i] = value; + } - @Override - public double calcATT(PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - double A = 0.0; - // A = Math.pow(phase.getNumberOfMolesInPhase(), 1.0) * getB() * R * temperature - // * d2adt2 + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) * getB() * R * dadt - // + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) * getB() * R * dadt; - A = phase.getNumberOfMolesInPhase() * getB() * R * temperature * d2adt2 - + 2.0 * phase.getNumberOfMolesInPhase() * getB() * R * dadt; - return A; - } + @Override + public double calcA(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + double A = 0.0; + this.init(phase, temperature, pressure, numbcomp); + // A = phase.getNumberOfMolesInPhase() * calcB(phase, temperature, pressure, + // numbcomp) * R * temperature * alpha_mix; + A = phase.getNumberOfMolesInPhase() * phase.getB() * R * temperature * alpha_mix; + + // System.out.println("A: " + A); + Atot = A; + return A; + } - @Override - public double calcAiT(int compNumb, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - - double A = getB() * R * compArray[compNumb].getAder() - + getB() * R * temperature * compArray[compNumb].getdAdTdn() - + phase.getNumberOfMolesInPhase() - * calcBi(compNumb, phase, temperature, pressure, numbcomp) * R - * temperature * dadt - + phase.getNumberOfMolesInPhase() - * calcBi(compNumb, phase, temperature, pressure, numbcomp) * R - * alpha_mix; - - return A; - } + @Override + public double calcAi(int compNumb, PhaseInterface phase, double temperature, double pressure, + int numbcomp) { + double A = 0.0; + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + + // A = getB() * R * temperature * compArray[compNumb].getAder() + + // phase.getNumberOfMolesInPhase() * calcBi(compNumb, phase, temperature, + // pressure, numbcomp) * R * temperature * alpha_mix; + A = getB() * R * temperature * compArray[compNumb].getAder() + phase.getNumberOfMolesInPhase() + * compArray[compNumb].getBi() * R * temperature * alpha_mix;; // calcBi(compNumb, phase, + // temperature, + // pressure, numbcomp) * R * + // temperature * + // alpha_mix; + + // System.out.println("Ai: " + A); + return A; } - public class WongSandlerMixingRule extends SRKHuronVidal2 { - private static final long serialVersionUID = 1000; + @Override + public double calcAij(int compNumb, int compNumbj, PhaseInterface phase, double temperature, + double pressure, int numbcomp) { + double A = 0.0; + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + + A = calcBi(compNumbj, phase, temperature, pressure, numbcomp) * R * temperature + * compArray[compNumb].getAder() + + getB() * R * temperature * compArray[compNumb].getdAdndn(compNumbj) + + calcBi(compNumb, phase, temperature, pressure, numbcomp) * R * temperature + * compArray[compNumbj].getAder() + + calcBij(compNumb, compNumbj, phase, temperature, pressure, numbcomp) + * phase.getNumberOfMolesInPhase() * R * temperature * alpha_mix; + + return A; + } - double Q = 0, QT = 0, DDE2; - double alpha_mix = 0, dadt = 0, b_mix = 0, dbdt = 0, bdert = 0, d2adt2 = 0, d2bdt2 = 0; - double[] ader, adert, qf1, d2qp; - double[] qPure, qPuredT, qPuredTdT; - double[][] ad2, qf2, qft, bd2; - double hwfc = 0, gex = 0, hex = 0, cpex = 0; - double[] oneSubAlf, abf, bc, abft2, abft, QFTD, BDER, BDERT; + @Override + public double calcAT(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + double A = 0.0; + // ComponentEosInterface[] compArray = (ComponentEosInterface[]) + // phase.getcomponentArray(); - public WongSandlerMixingRule(PhaseInterface phase, double[][] WSalpha, double[][] WSDij, - String[][] mixRule) { - super(phase, WSalpha, WSDij, mixRule); - } + A = phase.getNumberOfMolesInPhase() * getB() * R * temperature * dadt + + phase.getNumberOfMolesInPhase() * getB() * R * alpha_mix; - public WongSandlerMixingRule(PhaseInterface phase, double[][] WSalpha, double[][] WSDij, - double[][] WSDijT, String[][] mixRule) { - super(phase, WSalpha, WSDij, WSDijT, mixRule); - } + return A; + } - @Override - public void init(PhaseInterface phase, double temperature, double pressure, int numbcomp) { - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - gePhase.setProperties(phase); + @Override + public double calcATT(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + double A = 0.0; + // A = Math.pow(phase.getNumberOfMolesInPhase(), 1.0) * getB() * R * temperature + // * d2adt2 + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) * getB() * R * dadt + // + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) * getB() * R * dadt; + A = phase.getNumberOfMolesInPhase() * getB() * R * temperature * d2adt2 + + 2.0 * phase.getNumberOfMolesInPhase() * getB() * R * dadt; + return A; + } - if (mixingRuleGEModel.equals("NRTL")) { - // gePhase.init(phase.getNumberOfMolesInPhase(),phase.getNumberOfComponents(),3,phase.getPhaseType(),phase.getBeta()); - gePhase.getExessGibbsEnergy(phase, numbcomp, temperature, pressure, - phase.getPhaseType()); - } else { - gePhase.init(phase.getNumberOfMolesInPhase(), phase.getNumberOfComponents(), 3, - phase.getPhaseType(), phase.getBeta()); - } + @Override + public double calcAiT(int compNumb, PhaseInterface phase, double temperature, double pressure, + int numbcomp) { + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + + double A = getB() * R * compArray[compNumb].getAder() + + getB() * R * temperature * compArray[compNumb].getdAdTdn() + + phase.getNumberOfMolesInPhase() + * calcBi(compNumb, phase, temperature, pressure, numbcomp) * R * temperature * dadt + + phase.getNumberOfMolesInPhase() + * calcBi(compNumb, phase, temperature, pressure, numbcomp) * R * alpha_mix; + + return A; + } + } - hwfc = -1.0 / (1.0 - / (compArray[0].getDeltaEosParameters()[1] - - compArray[0].getDeltaEosParameters()[0]) - * Math.log((1.0 + compArray[0].getDeltaEosParameters()[1]) - / (1.0 + compArray[0].getDeltaEosParameters()[0]))); - - double term = 0.0; - qPure = new double[numbcomp]; - qPuredT = new double[numbcomp]; - qPuredTdT = new double[numbcomp]; - ader = new double[numbcomp]; - adert = new double[numbcomp]; - ad2 = new double[numbcomp][numbcomp]; - qf2 = new double[numbcomp][numbcomp]; - bd2 = new double[numbcomp][numbcomp]; - qft = new double[numbcomp][numbcomp]; - qf1 = new double[numbcomp]; - oneSubAlf = new double[numbcomp]; - abf = new double[numbcomp]; - bc = new double[numbcomp]; - abft2 = new double[numbcomp]; - abft = new double[numbcomp]; - QFTD = new double[numbcomp]; - BDER = new double[numbcomp]; - BDERT = new double[numbcomp]; - // first part - hex = phase.getHresTP() / phase.getNumberOfMolesInPhase(); - cpex = phase.getCpres() / phase.getNumberOfMolesInPhase(); - - for (int i = 0; i < numbcomp; i++) { - qPure[i] = compArray[i].getaT() / (compArray[i].getb() * R * temperature); - qPuredT[i] = -compArray[i].getaT() - / (compArray[i].getb() * R * temperature * temperature) - + compArray[i].diffaT(temperature) - / (compArray[i].getb() * R * temperature); - qPuredTdT[i] = 2.0 * compArray[i].getaT() - / (compArray[i].getb() * R * Math.pow(temperature, 3.0)) - - compArray[i].getaDiffT() - / (compArray[i].getb() * R * Math.pow(temperature, 2.0)) - + compArray[i].getaDiffDiffT() / (compArray[i].getb() * R * temperature) - - compArray[i].getaDiffT() - / (compArray[i].getb() * R * Math.pow(temperature, 2.0)); - } + public class WongSandlerMixingRule extends SRKHuronVidal2 { + private static final long serialVersionUID = 1000; - double sd2 = (2 * hex - cpex * temperature) / Math.pow(temperature, 3.0); - double cnt2 = 0.0; - for (int i = 0; i < numbcomp; i++) { - cnt2 += phase.getComponents()[i].getNumberOfMolesInPhase() - / phase.getNumberOfMolesInPhase() * qPuredTdT[i]; - // second part - } - alpha_mix = 0.0; - dadt = 0.0; - for (int i = 0; i < numbcomp; i++) { - term = qPure[i] + hwfc - * Math.log(((ComponentGEInterface) gePhase.getComponents()[i]).getGamma()); - alpha_mix += phase.getComponents()[i].getNumberOfMolesInPhase() - / phase.getNumberOfMolesInPhase() * term; - ader[i] = term; - compArray[i].setAder(ader[i]); - - term = qPuredT[i] - + hwfc * ((ComponentGEInterface) gePhase.getComponents()[i]).getlnGammadt(); - dadt += term * phase.getComponents()[i].getNumberOfMolesInPhase() - / phase.getNumberOfMolesInPhase(); - adert[i] = term; - compArray[i].setdAdTdn(adert[i]); - } - d2adt2 = cnt2 + hwfc * sd2; - // TODO implment hex and Cpex and set dAdTdT - for (int i = 0; i < numbcomp; i++) { - for (int j = 0; j < numbcomp; j++) { - ad2[i][j] = hwfc - * ((ComponentGEInterface) gePhase.getComponents()[i]).getlnGammadn(j); - compArray[i].setdAdndn(j, ad2[i][j]); - } - } + double Q = 0; - // double rhs = 0.0; - for (int i = 0; i < numbcomp; i++) { - oneSubAlf[i] = 1.0 - qPure[i]; - abf[i] = compArray[i].getb() * oneSubAlf[i]; - abft[i] = -compArray[i].getb() * qPuredT[i]; - abft2[i] = -compArray[i].getb() * qPuredTdT[i]; - } + double QT = 0; - double dd2 = 0.0; - for (int i = 0; i < numbcomp; i++) { - double ssi = 0.0; - for (int j = 0; j < numbcomp; j++) { - ssi += (1.0 - WSintparam[i][j]) * (abft2[i] + abft2[j]) - * phase.getComponents()[j].getNumberOfMolesInPhase() - / phase.getNumberOfMolesInPhase(); - } - dd2 += phase.getComponents()[i].getNumberOfMolesInPhase() - / phase.getNumberOfMolesInPhase() * ssi; - } - dd2 = 0.5 * dd2; + double DDE2; - for (int i = 0; i < numbcomp; i++) { - for (int j = i; j < numbcomp; j++) { - double ee = 1.0 - WSintparam[i][j]; - qf2[i][j] = ee * (abf[i] + abf[j]); - qf2[j][i] = qf2[i][j]; + double alpha_mix = 0; - qft[i][j] = ee * (abft[i] + abft[j]); - qft[j][i] = qft[i][j]; - } - } - Q = 0.0; - QT = 0.0; - - for (int i = 0; i < numbcomp; i++) { - double ss = 0.0; - for (int j = 0; j < numbcomp; j++) { - ss += qf2[j][i] * phase.getComponents()[j].getNumberOfMolesInPhase() - / phase.getNumberOfMolesInPhase(); - } - qf1[i] = ss; - Q += phase.getComponents()[i].getNumberOfMolesInPhase() - / phase.getNumberOfMolesInPhase() * ss; - double sst = 0.0; - for (int j = 0; j < numbcomp; j++) { - sst += qft[j][i] * phase.getComponents()[j].getNumberOfMolesInPhase() - / phase.getNumberOfMolesInPhase(); - } - QFTD[i] = sst; - QT += phase.getComponents()[i].getNumberOfMolesInPhase() - / phase.getNumberOfMolesInPhase() * sst; - } - double d_mix = 0.5 * Q; - double d_mixt = 0.5 * QT; - - double enum1 = 1.0 - alpha_mix; - double enumr = 1.0 / enum1; - b_mix = d_mix * enumr; - dbdt = (d_mixt + b_mix * dadt) * enumr; - - for (int i = 0; i < numbcomp; i++) { - BDER[i] = (qf1[i] - b_mix * (1.0 - ader[i])) * enumr; - compArray[i].setBder(BDER[i]); - double ss = QFTD[i] + b_mix * adert[i] + BDER[i] * dadt + dbdt * (ader[i] - 1.0); - BDERT[i] = ss * enumr; - compArray[i].setdBdndT(BDERT[i]); - } + double dadt = 0; - double DD2E = dd2 + b_mix * d2adt2 + 2.0 * dbdt * dadt; - d2bdt2 = DD2E / (1.0 - alpha_mix); + double b_mix = 0; - for (int i = 0; i < numbcomp; i++) { - for (int j = 0; j < numbcomp; j++) { - bd2[i][j] = - (qf2[i][j] + b_mix * ad2[i][j] + BDER[j] * ader[i] + BDER[i] * ader[j]) - * enumr; - compArray[i].setdBdndn(j, ad2[i][j]); - } - } - } + double dbdt = 0; - @Override - public double calcA(PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - double A = 0; - // super.calcA(phase, temperature, pressure, numbcomp); - this.init(phase, temperature, pressure, numbcomp); - A = Math.pow(phase.getNumberOfMolesInPhase(), 1.0) - * calcB(phase, temperature, pressure, numbcomp) * R * temperature * alpha_mix; - Atot = A; - return A; - } + double bdert = 0; - @Override - public double calcAi(int compNumb, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - double A = 0; - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + double d2adt2 = 0; - A = getB() * R * temperature * compArray[compNumb].getAder() - + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) - * calcBi(compNumb, phase, temperature, pressure, numbcomp) * R - * temperature * alpha_mix; + double d2bdt2 = 0; - // System.out.println("Ai: " + A); - return A; - } + double[] ader; - @Override - public double calcAT(PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - double A = 0; - // ComponentEosInterface[] compArray = (ComponentEosInterface[]) - // phase.getcomponentArray(); + double[] adert; - A = Math.pow(phase.getNumberOfMolesInPhase(), 1.0) * getB() * R * temperature * dadt - + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) * getB() * R * alpha_mix - + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) - * calcBT(phase, temperature, pressure, numbcomp) * R * temperature - * alpha_mix; + double[] qf1; - return A; - } + double[] d2qp; - @Override - public double calcATT(PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - double A = 0; - - A = Math.pow(phase.getNumberOfMolesInPhase(), 1.0) * getB() * R * temperature * d2adt2 - + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) * getB() * R * dadt - + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) * getB() * R * dadt - + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) - * calcBTT(phase, temperature, pressure, numbcomp) * R * temperature - * alpha_mix - + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) - * calcBT(phase, temperature, pressure, numbcomp) * R * alpha_mix - + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) - * calcBT(phase, temperature, pressure, numbcomp) * R * temperature - * dadt; - - return A; - } + double[] qPure; - @Override - public double calcAiT(int compNumb, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - double A = getB() * R * compArray[compNumb].getAder() - + getB() * R * temperature * compArray[compNumb].getdAdTdn() - + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) - * calcBi(compNumb, phase, temperature, pressure, numbcomp) * R - * temperature * dadt - + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) - * calcBi(compNumb, phase, temperature, pressure, numbcomp) * R - * alpha_mix - + calcBT(phase, temperature, pressure, numbcomp) * R * temperature - * compArray[compNumb].getAder() - + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) - * calcBiT(compNumb, phase, temperature, pressure, numbcomp) * R - * temperature * alpha_mix; - - return A; - } + double[] qPuredT; - @Override - public double calcAij(int compNumb, int compNumbj, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - double A = 0; - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - - A = Math.pow(phase.getNumberOfMolesInPhase(), 0.0) - * calcBi(compNumbj, phase, temperature, pressure, numbcomp) * R * temperature - * compArray[compNumb].getAder() - + Math.pow(phase.getNumberOfMolesInPhase(), 0.0) - * calcB(phase, temperature, pressure, numbcomp) * R * temperature - * compArray[compNumb].getdAdndn(compNumbj) - + Math.pow(phase.getNumberOfMolesInPhase(), 0.0) - * calcBi(compNumb, phase, temperature, pressure, numbcomp) * R - * temperature * compArray[compNumbj].getAder() - + Math.pow(phase.getNumberOfMolesInPhase(), 0.0) - * calcBij(compNumb, compNumbj, phase, temperature, pressure, numbcomp) - * R * temperature * alpha_mix; - - return A; - } + double[] qPuredTdT; - @Override - public double calcB(PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - double B = b_mix * phase.getNumberOfMolesInPhase(); - Btot = B; - return B; - } + double[][] ad2; - @Override - public double calcBi(int compNumb, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - return compArray[compNumb].getBder(); - } + double[][] qf2; - public double calcBT(PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - return dbdt * phase.getNumberOfMolesInPhase(); - } + double[][] qft; - public double calcBTT(PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - return d2bdt2 * phase.getNumberOfMolesInPhase(); - } + double[][] bd2; - public double calcBiT(int compNumb, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - double bit = compArray[compNumb].getdBdndT(); - return bit; - } + double hwfc = 0; - @Override - public double calcBij(int compNumb, int compNumbj, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - return compArray[compNumb].getdBdndn(compNumbj); - } - } + double gex = 0; - public class ElectrolyteMixRule implements ElectrolyteMixingRulesInterface, Cloneable { - private static final long serialVersionUID = 1000; + double hex = 0; - public ElectrolyteMixRule(PhaseInterface phase) { - calcWij(phase); - } + double cpex = 0; - @Override - public void calcWij(PhaseInterface phase) { - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - int numbcomp = phase.getNumberOfComponents(); - - // System.out.println("numb comp " + numbcomp); - for (int i = 0; i < numbcomp; i++) { - if (compArray[i].getIonicCharge() > 0) { - for (int j = 0; j < numbcomp; j++) { - if (wijCalcOrFitted[i][j] == 0) { - if (compArray[j].getComponentName().equals("water") - || compArray[j].getComponentName().equals("MDEA") - || compArray[j].getComponentName().equals("Piperazine")) {// compArray[j].getIonicCharge()==0){ - wij[0][i][j] = - neqsim.thermo.util.constants.FurstElectrolyteConstants - .getFurstParam(2) - * compArray[i].getStokesCationicDiameter() - + neqsim.thermo.util.constants.FurstElectrolyteConstants - .getFurstParam(3); - } - // if(compArray[j].getComponentName().equals("MDEA")){ - // wij[0][i][j] = - // (thermo.util.constants.FurstElectrolyteConstants.getFurstParamMDEA(2) - // * - // compArray[i].getStokesCationicDiameter() + - // thermo.util.constants.FurstElectrolyteConstants.getFurstParamMDEA(3)); - // } - if (compArray[j].getIonicCharge() < -0.01) { - wij[0][i][j] = - neqsim.thermo.util.constants.FurstElectrolyteConstants - .getFurstParam(4) - * Math.pow(compArray[i].getStokesCationicDiameter() - + compArray[j].getPaulingAnionicDiameter(), - 4.0) - + neqsim.thermo.util.constants.FurstElectrolyteConstants - .getFurstParam(5); - } - wij[0][j][i] = wij[0][i][j]; - } - } - } - } - } + double[] oneSubAlf; - @Override - public void setWijParameter(int i, int j, double value) { - // System.out.println("intparam: " + value); - wij[0][i][j] = value; - wij[0][j][i] = value; - } + double[] abf; - @Override - public double getWijParameter(int i, int j) { - return wij[0][i][j]; - } + double[] bc; - @Override - public void setWijT1Parameter(int i, int j, double value) { - wij[1][i][j] = value; - wij[1][j][i] = value; - } + double[] abft2; - @Override - public double gettWijT1Parameter(int i, int j) { - return wij[1][i][j]; - } + double[] abft; - @Override - public void setWijT2Parameter(int i, int j, double value) { - wij[2][i][j] = value; - wij[2][j][i] = value; - } + double[] QFTD; - @Override - public double gettWijT2Parameter(int i, int j) { - return wij[2][i][j]; - } + double[] BDER; - @Override - public double getWij(int i, int j, double temperature) { - return wij[0][i][j] + wij[1][i][j] * (1.0 / temperature - 1.0 / 298.15) + wij[2][i][j] - * ((298.15 - temperature) / temperature + Math.log(temperature / 298.15)); - } + double[] BDERT; - @Override - public double getWijT(int i, int j, double temperature) { - return (-wij[1][i][j] / (temperature * temperature) - - wij[2][i][j] * (298.15 - temperature) / (temperature * temperature)); - } + public WongSandlerMixingRule(PhaseInterface phase, double[][] WSalpha, double[][] WSDij, + String[][] mixRule) { + super(phase, WSalpha, WSDij, mixRule); + } - @Override - public double getWijTT(int i, int j, double temperature) { - return (2.0 * wij[1][i][j] / (temperature * temperature * temperature) - + wij[2][i][j] / (temperature * temperature) + 2.0 * wij[2][i][j] - * (298.15 - temperature) / (temperature * temperature * temperature)); - } + public WongSandlerMixingRule(PhaseInterface phase, double[][] WSalpha, double[][] WSDij, + double[][] WSDijT, String[][] mixRule) { + super(phase, WSalpha, WSDij, WSDijT, mixRule); + } - @Override - public double calcW(PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - double W = 0.0; - for (int i = 0; i < numbcomp; i++) { - for (int j = 0; j < numbcomp; j++) { - W += compArray[i].getNumberOfMolesInPhase() - * compArray[j].getNumberOfMolesInPhase() * getWij(i, j, temperature);// wij[0][i][j]; - } - } - return -W; - } + @Override + public void init(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + gePhase.setProperties(phase); + + if (mixingRuleGEModel.equals("NRTL")) { + // gePhase.init(phase.getNumberOfMolesInPhase(),phase.getNumberOfComponents(),3,phase.getPhaseType(),phase.getBeta()); + gePhase.getExessGibbsEnergy(phase, numbcomp, temperature, pressure, phase.getPhaseType()); + } else { + gePhase.init(phase.getNumberOfMolesInPhase(), phase.getNumberOfComponents(), 3, + phase.getPhaseType(), phase.getBeta()); + } + + hwfc = -1.0 / (1.0 + / (compArray[0].getDeltaEosParameters()[1] - compArray[0].getDeltaEosParameters()[0]) + * Math.log((1.0 + compArray[0].getDeltaEosParameters()[1]) + / (1.0 + compArray[0].getDeltaEosParameters()[0]))); + + double term = 0.0; + qPure = new double[numbcomp]; + qPuredT = new double[numbcomp]; + qPuredTdT = new double[numbcomp]; + ader = new double[numbcomp]; + adert = new double[numbcomp]; + ad2 = new double[numbcomp][numbcomp]; + qf2 = new double[numbcomp][numbcomp]; + bd2 = new double[numbcomp][numbcomp]; + qft = new double[numbcomp][numbcomp]; + qf1 = new double[numbcomp]; + oneSubAlf = new double[numbcomp]; + abf = new double[numbcomp]; + bc = new double[numbcomp]; + abft2 = new double[numbcomp]; + abft = new double[numbcomp]; + QFTD = new double[numbcomp]; + BDER = new double[numbcomp]; + BDERT = new double[numbcomp]; + // first part + hex = phase.getHresTP() / phase.getNumberOfMolesInPhase(); + cpex = phase.getCpres() / phase.getNumberOfMolesInPhase(); + + for (int i = 0; i < numbcomp; i++) { + qPure[i] = compArray[i].getaT() / (compArray[i].getb() * R * temperature); + qPuredT[i] = -compArray[i].getaT() / (compArray[i].getb() * R * temperature * temperature) + + compArray[i].diffaT(temperature) / (compArray[i].getb() * R * temperature); + qPuredTdT[i] = + 2.0 * compArray[i].getaT() / (compArray[i].getb() * R * Math.pow(temperature, 3.0)) + - compArray[i].getaDiffT() / (compArray[i].getb() * R * Math.pow(temperature, 2.0)) + + compArray[i].getaDiffDiffT() / (compArray[i].getb() * R * temperature) + - compArray[i].getaDiffT() / (compArray[i].getb() * R * Math.pow(temperature, 2.0)); + } + + double sd2 = (2 * hex - cpex * temperature) / Math.pow(temperature, 3.0); + double cnt2 = 0.0; + for (int i = 0; i < numbcomp; i++) { + cnt2 += phase.getComponents()[i].getNumberOfMolesInPhase() / phase.getNumberOfMolesInPhase() + * qPuredTdT[i]; + // second part + } + alpha_mix = 0.0; + dadt = 0.0; + for (int i = 0; i < numbcomp; i++) { + term = qPure[i] + + hwfc * Math.log(((ComponentGEInterface) gePhase.getComponents()[i]).getGamma()); + alpha_mix += phase.getComponents()[i].getNumberOfMolesInPhase() + / phase.getNumberOfMolesInPhase() * term; + ader[i] = term; + compArray[i].setAder(ader[i]); + + term = + qPuredT[i] + hwfc * ((ComponentGEInterface) gePhase.getComponents()[i]).getlnGammadt(); + dadt += term * phase.getComponents()[i].getNumberOfMolesInPhase() + / phase.getNumberOfMolesInPhase(); + adert[i] = term; + compArray[i].setdAdTdn(adert[i]); + } + d2adt2 = cnt2 + hwfc * sd2; + // TODO implment hex and Cpex and set dAdTdT + for (int i = 0; i < numbcomp; i++) { + for (int j = 0; j < numbcomp; j++) { + ad2[i][j] = hwfc * ((ComponentGEInterface) gePhase.getComponents()[i]).getlnGammadn(j); + compArray[i].setdAdndn(j, ad2[i][j]); + } + } + + // double rhs = 0.0; + for (int i = 0; i < numbcomp; i++) { + oneSubAlf[i] = 1.0 - qPure[i]; + abf[i] = compArray[i].getb() * oneSubAlf[i]; + abft[i] = -compArray[i].getb() * qPuredT[i]; + abft2[i] = -compArray[i].getb() * qPuredTdT[i]; + } + + double dd2 = 0.0; + for (int i = 0; i < numbcomp; i++) { + double ssi = 0.0; + for (int j = 0; j < numbcomp; j++) { + ssi += (1.0 - WSintparam[i][j]) * (abft2[i] + abft2[j]) + * phase.getComponents()[j].getNumberOfMolesInPhase() + / phase.getNumberOfMolesInPhase(); + } + dd2 += phase.getComponents()[i].getNumberOfMolesInPhase() / phase.getNumberOfMolesInPhase() + * ssi; + } + dd2 = 0.5 * dd2; + + for (int i = 0; i < numbcomp; i++) { + for (int j = i; j < numbcomp; j++) { + double ee = 1.0 - WSintparam[i][j]; + qf2[i][j] = ee * (abf[i] + abf[j]); + qf2[j][i] = qf2[i][j]; + + qft[i][j] = ee * (abft[i] + abft[j]); + qft[j][i] = qft[i][j]; + } + } + Q = 0.0; + QT = 0.0; + + for (int i = 0; i < numbcomp; i++) { + double ss = 0.0; + for (int j = 0; j < numbcomp; j++) { + ss += qf2[j][i] * phase.getComponents()[j].getNumberOfMolesInPhase() + / phase.getNumberOfMolesInPhase(); + } + qf1[i] = ss; + Q += phase.getComponents()[i].getNumberOfMolesInPhase() / phase.getNumberOfMolesInPhase() + * ss; + double sst = 0.0; + for (int j = 0; j < numbcomp; j++) { + sst += qft[j][i] * phase.getComponents()[j].getNumberOfMolesInPhase() + / phase.getNumberOfMolesInPhase(); + } + QFTD[i] = sst; + QT += phase.getComponents()[i].getNumberOfMolesInPhase() / phase.getNumberOfMolesInPhase() + * sst; + } + double d_mix = 0.5 * Q; + double d_mixt = 0.5 * QT; + + double enum1 = 1.0 - alpha_mix; + double enumr = 1.0 / enum1; + b_mix = d_mix * enumr; + dbdt = (d_mixt + b_mix * dadt) * enumr; + + for (int i = 0; i < numbcomp; i++) { + BDER[i] = (qf1[i] - b_mix * (1.0 - ader[i])) * enumr; + compArray[i].setBder(BDER[i]); + double ss = QFTD[i] + b_mix * adert[i] + BDER[i] * dadt + dbdt * (ader[i] - 1.0); + BDERT[i] = ss * enumr; + compArray[i].setdBdndT(BDERT[i]); + } + + double DD2E = dd2 + b_mix * d2adt2 + 2.0 * dbdt * dadt; + d2bdt2 = DD2E / (1.0 - alpha_mix); + + for (int i = 0; i < numbcomp; i++) { + for (int j = 0; j < numbcomp; j++) { + bd2[i][j] = + (qf2[i][j] + b_mix * ad2[i][j] + BDER[j] * ader[i] + BDER[i] * ader[j]) * enumr; + compArray[i].setdBdndn(j, ad2[i][j]); + } + } + } - @Override - public double calcWi(int compNumb, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + @Override + public double calcA(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + double A = 0; + // super.calcA(phase, temperature, pressure, numbcomp); + this.init(phase, temperature, pressure, numbcomp); + A = Math.pow(phase.getNumberOfMolesInPhase(), 1.0) + * calcB(phase, temperature, pressure, numbcomp) * R * temperature * alpha_mix; + Atot = A; + return A; + } - double Wi = 0.0; - for (int j = 0; j < numbcomp; j++) { - Wi += compArray[j].getNumberOfMolesInPhase() * getWij(compNumb, j, temperature); - } - return -2.0 * Wi; - } + @Override + public double calcAi(int compNumb, PhaseInterface phase, double temperature, double pressure, + int numbcomp) { + double A = 0; + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + + A = getB() * R * temperature * compArray[compNumb].getAder() + + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) + * calcBi(compNumb, phase, temperature, pressure, numbcomp) * R * temperature + * alpha_mix; + + // System.out.println("Ai: " + A); + return A; + } - @Override - public double calcWiT(int compNumb, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); - double WiT = 0; - for (int j = 0; j < numbcomp; j++) { - WiT += compArray[j].getNumberOfMolesInPhase() * getWijT(compNumb, j, temperature); - } - return -2.0 * WiT; - } + @Override + public double calcAT(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + double A = 0; + // ComponentEosInterface[] compArray = (ComponentEosInterface[]) + // phase.getcomponentArray(); - @Override - public double calcWT(PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + A = Math.pow(phase.getNumberOfMolesInPhase(), 1.0) * getB() * R * temperature * dadt + + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) * getB() * R * alpha_mix + + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) + * calcBT(phase, temperature, pressure, numbcomp) * R * temperature * alpha_mix; - double WT = 0; - for (int i = 0; i < numbcomp; i++) { - for (int j = 0; j < numbcomp; j++) { - WT += compArray[i].getNumberOfMolesInPhase() - * compArray[j].getNumberOfMolesInPhase() * getWijT(i, j, temperature);// wij[0][i][j]; - } - } - return -WT; - } + return A; + } - @Override - public double calcWTT(PhaseInterface phase, double temperature, double pressure, - int numbcomp) { - ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + @Override + public double calcATT(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + double A = 0; + + A = Math.pow(phase.getNumberOfMolesInPhase(), 1.0) * getB() * R * temperature * d2adt2 + + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) * getB() * R * dadt + + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) * getB() * R * dadt + + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) + * calcBTT(phase, temperature, pressure, numbcomp) * R * temperature * alpha_mix + + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) + * calcBT(phase, temperature, pressure, numbcomp) * R * alpha_mix + + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) + * calcBT(phase, temperature, pressure, numbcomp) * R * temperature * dadt; + + return A; + } - double WTT = 0; - for (int i = 0; i < numbcomp; i++) { - for (int j = 0; j < numbcomp; j++) { - WTT += compArray[i].getNumberOfMolesInPhase() - * compArray[j].getNumberOfMolesInPhase() * getWijTT(i, j, temperature);// wij[0][i][j]; - } - } - return -WTT; - } + @Override + public double calcAiT(int compNumb, PhaseInterface phase, double temperature, double pressure, + int numbcomp) { + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + double A = getB() * R * compArray[compNumb].getAder() + + getB() * R * temperature * compArray[compNumb].getdAdTdn() + + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) + * calcBi(compNumb, phase, temperature, pressure, numbcomp) * R * temperature * dadt + + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) + * calcBi(compNumb, phase, temperature, pressure, numbcomp) * R * alpha_mix + + calcBT(phase, temperature, pressure, numbcomp) * R * temperature + * compArray[compNumb].getAder() + + Math.pow(phase.getNumberOfMolesInPhase(), 1.0) + * calcBiT(compNumb, phase, temperature, pressure, numbcomp) * R * temperature + * alpha_mix; + + return A; + } - @Override - public double calcWij(int compNumbi, int compNumj, PhaseInterface phase, double temperature, - double pressure, int numbcomp) { - return -2.0 * getWij(compNumbi, compNumj, temperature);// iwij[0][compNumbi][compNumj]; - } + @Override + public double calcAij(int compNumb, int compNumbj, PhaseInterface phase, double temperature, + double pressure, int numbcomp) { + double A = 0; + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + + A = Math.pow(phase.getNumberOfMolesInPhase(), 0.0) + * calcBi(compNumbj, phase, temperature, pressure, numbcomp) * R * temperature + * compArray[compNumb].getAder() + + Math.pow(phase.getNumberOfMolesInPhase(), 0.0) + * calcB(phase, temperature, pressure, numbcomp) * R * temperature + * compArray[compNumb].getdAdndn(compNumbj) + + Math.pow(phase.getNumberOfMolesInPhase(), 0.0) + * calcBi(compNumb, phase, temperature, pressure, numbcomp) * R * temperature + * compArray[compNumbj].getAder() + + Math.pow(phase.getNumberOfMolesInPhase(), 0.0) + * calcBij(compNumb, compNumbj, phase, temperature, pressure, numbcomp) * R + * temperature * alpha_mix; + + return A; } - /** - *

- * getMixingRule. - *

- * - * @param i a int - * @return a {@link neqsim.thermo.mixingRule.EosMixingRulesInterface} object - */ - public EosMixingRulesInterface getMixingRule(int i) { - if (i == 1) { - return new ClassicVdW(); - } else if (i == 2) { - return new ClassicSRK(); - } else if (i == 3) { - return new ClassicVdW(); - } else { - return new ClassicVdW(); - } + @Override + public double calcB(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + double B = b_mix * phase.getNumberOfMolesInPhase(); + Btot = B; + return B; } - /** - *

- * getMixingRule. - *

- * - * @param i a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a {@link neqsim.thermo.mixingRule.EosMixingRulesInterface} object - */ - public EosMixingRulesInterface getMixingRule(int i, PhaseInterface phase) { - this.wij = new double[3][phase.getNumberOfComponents()][phase.getNumberOfComponents()]; + @Override + public double calcBi(int compNumb, PhaseInterface phase, double temperature, double pressure, + int numbcomp) { + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + return compArray[compNumb].getBder(); + } - if (i == 1) { - intparam = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; - return new ClassicVdW(); - } - intparam = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; - intparamji = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; - intparamij = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; - intparamT = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; - intparamTType = new int[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; - HVDij = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; - HVDijT = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; - NRTLDij = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; - NRTLDijT = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; - WSintparam = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; - HValpha = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; - NRTLalpha = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; - classicOrHV = new String[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; - classicOrWS = new String[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; - wijCalcOrFitted = new int[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; - neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); - - for (int k = 0; k < phase.getNumberOfComponents(); k++) { - String component_name = phase.getComponents()[k].getComponentName(); - - for (int l = k; l < phase.getNumberOfComponents(); l++) { - if (k == l) { - classicOrHV[k][l] = "Classic"; - classicOrWS[k][l] = "Classic"; - classicOrHV[l][k] = classicOrHV[k][l]; - classicOrWS[l][k] = classicOrWS[k][l]; - } else { - java.sql.ResultSet dataSet = null; - try { - if (phase.getComponent(k).isIsTBPfraction() - || phase.getComponent(l).isIsTBPfraction()) { - throw new Exception("no interaction coefficient for TBP fractions"); - } - int templ = l, tempk = k; - if (NeqSimDataBase.createTemporaryTables()) { - dataSet = database.getResultSet("SELECT * FROM intertemp WHERE (comp1='" - + component_name + "' AND comp2='" - + phase.getComponents()[l].getComponentName() + "') OR (comp1='" - + phase.getComponents()[l].getComponentName() + "' AND comp2='" - + component_name + "')"); - } else { - dataSet = database.getResultSet("SELECT * FROM inter WHERE (comp1='" - + component_name + "' AND comp2='" - + phase.getComponents()[l].getComponentName() + "') OR (comp1='" - + phase.getComponents()[l].getComponentName() + "' AND comp2='" - + component_name + "')"); - } - dataSet.next(); - if (dataSet.getString("comp1").trim() - .equals(phase.getComponents()[l].getComponentName())) { - templ = k; - tempk = l; - } - - classicOrHV[k][l] = dataSet.getString("HVTYPE").trim(); - classicOrHV[l][k] = classicOrHV[k][l]; - - if (isCalcEOSInteractionParameters()) { - intparam[k][l] = 1.0 - Math.pow((2.0 * Math.sqrt(Math - .pow(phase.getComponent(l).getCriticalVolume(), 1 / 3) - * Math.pow(phase.getComponent(k).getCriticalVolume(), 1 / 3)) - / (Math.pow(phase.getComponent(l).getCriticalVolume(), 1 / 3) - + Math.pow(phase.getComponent(k).getCriticalVolume(), - 1 / 3))), - nEOSkij); - intparamT[k][l] = 0.0; - // System.out.println("kij " + intparam[k][l]); - } else { - if (phase.getClass().getName() - .equals("neqsim.thermo.phase.PhasePrEos")) { - // System.out.println("using PR intparams"); - intparam[k][l] = Double.parseDouble(dataSet.getString("kijpr")); - intparamT[k][l] = Double.parseDouble(dataSet.getString("KIJTpr")); - } else { - intparam[k][l] = Double.parseDouble(dataSet.getString("kijsrk")); - intparamT[k][l] = Double.parseDouble(dataSet.getString("KIJTSRK")); - } - if (phase.getClass().getName() - .equals("neqsim.thermo.phase.PhasePrCPA")) { - intparam[k][l] = Double.parseDouble(dataSet.getString("cpakij_PR")); - intparamT[k][l] = 0.0; - } else if (phase.getClass().getName() - .equals("neqsim.thermo.phase.PhaseSrkCPA") - || phase.getClass().getName() - .equals("neqsim.thermo.phase.PhaseSrkCPAs") - || phase.getClass().getName().equals( - "neqsim.thermo.phase.PhaseElectrolyteCPAstatoil")) { - intparam[k][l] = - Double.parseDouble(dataSet.getString("cpakij_SRK")); - intparamT[k][l] = - Double.parseDouble(dataSet.getString("cpakijT_SRK")); - - intparamij[tempk][templ] = - Double.parseDouble(dataSet.getString("cpakijx_SRK")); - intparamji[templ][tempk] = intparamij[tempk][templ]; - - intparamji[tempk][templ] = - Double.parseDouble(dataSet.getString("cpakjix_SRK")); - intparamij[templ][tempk] = intparamji[tempk][templ]; - } - if (phase.getClass().getName() - .equals("neqsim.thermo.phase.PhasePCSAFTRahmat") - || phase.getClass().getName() - .equals("neqsim.thermo.phase.PhasePCSAFT") - || phase.getClass().getName() - .equals("neqsim.thermo.phase.PhasePCSAFTa")) { - intparam[k][l] = Double.parseDouble(dataSet.getString("KIJPCSAFT")); - intparamT[k][l] = 0.0; - } - } - - java.sql.ResultSetMetaData dataSetMD = dataSet.getMetaData(); - int cols = dataSetMD.getColumnCount(); - boolean hasKIJTTypeCPAcol = false; - String colname = "KIJTTypeCPA"; - for (int x = 1; x <= cols; x++) { - if (colname.equals(dataSetMD.getColumnName(x))) { - hasKIJTTypeCPAcol = true; - } - } - - // System.out.println("class name " + phase.getClass().getName()); - if (!phase.getClass().getName().equals("neqsim.thermo.phase.PhaseSrkCPAs") - || !hasKIJTTypeCPAcol) { - intparamTType[k][l] = Integer.parseInt(dataSet.getString("KIJTType")); - } else { - intparamTType[k][l] = - Integer.parseInt(dataSet.getString("KIJTTypeCPA")); // TODO: - // implement - // in all - // dbs - } - intparamTType[l][k] = intparamTType[k][l]; - - HValpha[k][l] = Double.parseDouble(dataSet.getString("HValpha")); - HValpha[l][k] = HValpha[k][l]; - - HVDij[tempk][templ] = Double.parseDouble(dataSet.getString("HVgij")); - HVDij[templ][tempk] = Double.parseDouble(dataSet.getString("HVgji")); - - wijCalcOrFitted[k][l] = Integer.parseInt(dataSet.getString("CalcWij")); - wijCalcOrFitted[l][k] = wijCalcOrFitted[k][l]; - - wij[0][k][l] = Double.parseDouble(dataSet.getString("w1")); - wij[0][l][k] = wij[0][k][l]; - wij[1][k][l] = Double.parseDouble(dataSet.getString("w2")); - wij[1][l][k] = wij[1][k][l]; - wij[2][k][l] = Double.parseDouble(dataSet.getString("w3")); - wij[2][l][k] = wij[2][k][l]; - - classicOrWS[k][l] = dataSet.getString("WSTYPE").trim(); - classicOrWS[l][k] = classicOrWS[k][l]; - - WSintparam[k][l] = Double.parseDouble(dataSet.getString("kijWS")); - WSintparam[k][l] = Double.parseDouble(dataSet.getString("KIJWSunifac")); - WSintparam[l][k] = WSintparam[k][l]; - - NRTLalpha[k][l] = Double.parseDouble(dataSet.getString("NRTLalpha")); - NRTLalpha[l][k] = NRTLalpha[k][l]; - - NRTLDij[tempk][templ] = Double.parseDouble(dataSet.getString("NRTLgij")); - NRTLDij[templ][tempk] = Double.parseDouble(dataSet.getString("NRTLgji")); - - HVDijT[tempk][templ] = Double.parseDouble(dataSet.getString("HVgijT")); - HVDijT[templ][tempk] = Double.parseDouble(dataSet.getString("HVgjiT")); - - NRTLDijT[tempk][templ] = Double.parseDouble(dataSet.getString("WSgijT")); - NRTLDijT[templ][tempk] = Double.parseDouble(dataSet.getString("WSgjiT")); - } catch (Exception e) { - // System.out.println("err in thermo mix....."); - // String err = e.toString(); - // System.out.println(err); - if (isCalcEOSInteractionParameters()) { - intparam[k][l] = 1.0 - Math.pow((2.0 - * Math.sqrt(Math.pow(phase.getComponent(l).getCriticalVolume(), - 1.0 / 3.0) - * Math.pow(phase.getComponent(k).getCriticalVolume(), - 1.0 / 3.0)) - / (Math.pow(phase.getComponent(l).getCriticalVolume(), - 1.0 / 3.0) - + Math.pow(phase.getComponent(k).getCriticalVolume(), - 1.0 / 3.0))), - nEOSkij); - // System.out.println("intparam not defined .... CALCULATING intparam - // between " - // +phase.getComponents()[l].getComponentName() + " and " + - // phase.getComponents()[k].getComponentName()+ " to " + - // intparam[k][l]); - } else if ((phase.getComponents()[k].getComponentName().equals("CO2") - && phase.getComponents()[l].isIsTBPfraction()) - || (phase.getComponents()[l].getComponentName().equals("CO2") - && phase.getComponents()[k].isIsTBPfraction())) { - intparam[k][l] = 0.1; - } else if ((phase.getComponents()[k].getComponentName().equals("nitrogen") - && phase.getComponents()[l].isIsTBPfraction()) - || (phase.getComponents()[l].getComponentName().equals("nitrogen") - && phase.getComponents()[k].isIsTBPfraction())) { - intparam[k][l] = 0.08; - } else if ((phase.getComponents()[k].getComponentName().equals("water") - && phase.getComponents()[l].isIsTBPfraction()) - || (phase.getComponents()[l].getComponentName().equals("water") - && phase.getComponents()[k].isIsTBPfraction())) { - intparam[k][l] = 0.2; - - if (phase.getClass().getName().equals("neqsim.thermo.phase.PhaseSrkCPA") - || phase.getClass().getName() - .equals("neqsim.thermo.phase.PhaseSrkCPAs") - || phase.getClass().getName().equals( - "neqsim.thermo.phase.PhaseElectrolyteCPAstatoil")) { - // intparam[k][l] = -0.0685; // taken from Riaz et a. 2012 - - double molmassPC = phase.getComponents()[l].getMolarMass(); - if (phase.getComponents()[k].isIsTBPfraction()) { - molmassPC = phase.getComponents()[k].getMolarMass(); - } - double intparamkPC = - -0.1533 * Math.log(1000.0 * molmassPC) + 0.7055; - intparam[k][l] = intparamkPC; - // System.out.println("kij water-HC " + intparam[k][l]); - - intparamT[k][l] = 0.0; - } - } else if ((phase.getComponents()[k].getComponentName().equals("MEG") - && phase.getComponents()[l].isIsTBPfraction()) - || (phase.getComponents()[l].getComponentName().equals("MEG") - && phase.getComponents()[k].isIsTBPfraction())) { - intparam[k][l] = 0.2; - if (phase.getClass().getName().equals("neqsim.thermo.phase.PhaseSrkCPA") - || phase.getClass().getName() - .equals("neqsim.thermo.phase.PhaseSrkCPAs") - || phase.getClass().getName().equals( - "neqsim.thermo.phase.PhaseElectrolyteCPAstatoil")) { - double molmassPC = phase.getComponents()[l].getMolarMass(); - if (phase.getComponents()[k].isIsTBPfraction()) { - molmassPC = phase.getComponents()[k].getMolarMass(); - } - double intparamkPC = - -0.0701 * Math.log(1000.0 * molmassPC) + 0.3521; - intparam[k][l] = intparamkPC; - // System.out.println("kij MEG-HC " + intparam[k][l]); - // intparam[k][l] = 0.01; - intparamT[k][l] = 0.0; - } - } else if ((phase.getComponents()[k].getComponentName().equals("ethanol") - && phase.getComponents()[l].isIsTBPfraction()) - || (phase.getComponents()[l].getComponentName().equals("ethanol") - && phase.getComponents()[k].isIsTBPfraction())) { - intparam[k][l] = 0.0; - if (phase.getClass().getName().equals("neqsim.thermo.phase.PhaseSrkCPA") - || phase.getClass().getName() - .equals("neqsim.thermo.phase.PhaseSrkCPAs") - || phase.getClass().getName().equals( - "neqsim.thermo.phase.PhaseElectrolyteCPAstatoil")) { - intparam[k][l] = -0.05; - intparamT[k][l] = 0.0; - if (phase.getComponents()[k].getMolarMass() > (200.0 / 1000.0) - || phase.getComponents()[l] - .getMolarMass() > (200.0 / 1000.0)) { - intparam[k][l] = -0.1; - } - } - } else if ((phase.getComponents()[k].getComponentName().equals("methanol") - && phase.getComponents()[l].isIsTBPfraction()) - || (phase.getComponents()[l].getComponentName().equals("methanol") - && phase.getComponents()[k].isIsTBPfraction())) { - intparam[k][l] = 0.0; - if (phase.getClass().getName().equals("neqsim.thermo.phase.PhaseSrkCPA") - || phase.getClass().getName() - .equals("neqsim.thermo.phase.PhaseSrkCPAs") - || phase.getClass().getName().equals( - "neqsim.thermo.phase.PhaseElectrolyteCPAstatoil")) { - intparam[k][l] = -0.1; - intparamT[k][l] = 0.0; - if (phase.getComponents()[k].getMolarMass() > (200.0 / 1000.0) - || phase.getComponents()[l] - .getMolarMass() > (200.0 / 1000.0)) { - intparam[k][l] = -0.2; - } - } - } else if ((phase.getComponents()[k].getComponentName().equals("TEG") - && phase.getComponents()[l].isIsTBPfraction()) - || (phase.getComponents()[l].getComponentName().equals("TEG") - && phase.getComponents()[k].isIsTBPfraction())) { - intparam[k][l] = 0.12; - if (phase.getClass().getName().equals("neqsim.thermo.phase.PhaseSrkCPA") - || phase.getClass().getName() - .equals("neqsim.thermo.phase.PhaseSrkCPAs") - || phase.getClass().getName().equals( - "neqsim.thermo.phase.PhaseElectrolyteCPAstatoil")) { - intparam[k][l] = 0.12; - intparamT[k][l] = 0.0; - } - } else if ((phase.getComponents()[k].getComponentName().equals("S8") - && phase.getComponents()[l].isIsTBPfraction()) - || (phase.getComponents()[l].getComponentName().equals("S8") - && phase.getComponents()[k].isIsTBPfraction())) { - intparam[k][l] = 0.05; - } else { - // if((phase.getComponents()[l].getComponentName().equals("CO2") || - // phase.getComponents()[k].getComponentName().equals("CO2")) && k!=l) - // intparam[k][l] = 0.1; - // else if((phase.getComponents()[l].getComponentName().equals("H2S") || - // phase.getComponents()[k].getComponentName().equals("H2S")) && k!=l) - // intparam[k][l] = 0.2; - // else if((phase.getComponents()[l].getComponentName().equals("water") - // || - // phase.getComponents()[k].getComponentName().equals("water")) && k!=l) - // intparam[k][l] = 0.5; - // else intparam[k][l] = 0.0; - // System.out.println("intparam not defined .... setting intparam - // between " + - // phase.getComponents()[l].getComponentName() + " and " + - // phase.getComponents()[k].getComponentName() + " to " + - // intparam[k][l]); - } - - // intparam[l][k] = intparam[k][l]; - // intparamT[l][k] = intparamT[k][l]; - intparamij[k][l] = intparam[k][l]; - intparamij[l][k] = intparam[k][l]; - intparamji[k][l] = intparam[k][l]; - intparamji[l][k] = intparam[k][l]; - // System.out.println("kij set to " + intparam[l][k] + " " + - // phase.getComponents()[l].getComponentName() + " " + - // phase.getComponents()[k].getComponentName()); - - classicOrHV[k][l] = "Classic"; - classicOrHV[l][k] = classicOrHV[k][l]; - - classicOrWS[k][l] = "Classic"; - classicOrWS[l][k] = classicOrWS[k][l]; - } finally { - intparam[l][k] = intparam[k][l]; - intparamT[l][k] = intparamT[k][l]; - try { - if (dataSet != null) { - dataSet.close(); - } - } catch (Exception e) { - logger.error("err closing dataSet IN MIX...", e); - } - } - } - } - } + public double calcBT(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + return dbdt * phase.getNumberOfMolesInPhase(); + } - try { - if (database.getStatement() != null) { - database.getStatement().close(); - } - if (database.getConnection() != null) { - database.getConnection().close(); - } - } catch (Exception e) { - logger.error("error closing database.....", e); - } + public double calcBTT(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + return d2bdt2 * phase.getNumberOfMolesInPhase(); + } - if (i == 2) { - mixingRuleName = "classic"; - return new ClassicSRK(); - } else if (i == 3) { - // Classic Huron-Vidal - mixingRuleName = "Huron-Vidal"; - return new SRKHuronVidal2(phase, HValpha, HVDij, classicOrHV); - } else if (i == 4) { - mixingRuleName = "Huron-Vidal"; - return new SRKHuronVidal2(phase, HValpha, HVDij, HVDijT, classicOrHV); - } else if (i == 5) { - mixingRuleName = "Wong-Sandler"; - return new WongSandlerMixingRule(phase, NRTLalpha, NRTLDij, NRTLDijT, classicOrWS); - } else if (i == 6) { - mixingRuleName = "Wong-Sandler"; - return new WongSandlerMixingRule(phase, NRTLalpha, NRTLDij, NRTLDijT, classicOrWS); - } else if (i == 7) { - mixingRuleName = "classic-CPA"; - return new ClassicSRK(); - } else if (i == 8) { - mixingRuleName = "classicdT"; - return new ClassicSRKT(); - } else if (i == 9) { - mixingRuleName = "classic-CPA_T"; - return new ClassicSRKT2(); - } else if (i == 10) { - org.ejml.simple.SimpleMatrix mat1 = new org.ejml.simple.SimpleMatrix(intparamij); - org.ejml.simple.SimpleMatrix mat2 = new org.ejml.simple.SimpleMatrix(intparamji); - org.ejml.simple.SimpleMatrix mat3 = new org.ejml.simple.SimpleMatrix(intparamT); - if (mat1.isIdentical(mat2, 1e-8)) { - if (mat3.elementMaxAbs() < 1e-8) { - mixingRuleName = "classic-CPA"; - return new ClassicSRK(); - } - mixingRuleName = "classic-CPA_T"; - return new ClassicSRKT2(); - } else { - mixingRuleName = "classic-CPA_Tx"; - return new ClassicSRKT2x(); - } - } // else if(i==10){ - // return new ElectrolyteMixRule(phase, HValpha, HVgij, HVgii, classicOrHV, - // wij);} - else { - return new ClassicVdW(); - } + public double calcBiT(int compNumb, PhaseInterface phase, double temperature, double pressure, + int numbcomp) { + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + double bit = compArray[compNumb].getdBdndT(); + return bit; } - /** - *

- * resetMixingRule. - *

- * - * @param i a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a {@link neqsim.thermo.mixingRule.EosMixingRulesInterface} object - */ - public EosMixingRulesInterface resetMixingRule(int i, PhaseInterface phase) { - if (i == 1) { - mixingRuleName = "no (kij=0)"; - return new ClassicVdW(); - } else if (i == 2) { - mixingRuleName = "classic"; - return new ClassicSRK(); - } else if (i == 3) { - // Classic Huron-Vidal - mixingRuleName = "Huron-Vidal"; - return new SRKHuronVidal2(phase, HValpha, HVDij, classicOrHV); - } else if (i == 4) { - mixingRuleName = "Huron-Vidal"; - return new SRKHuronVidal2(phase, HValpha, HVDij, HVDijT, classicOrHV); - } else if (i == 5) { - mixingRuleName = "Wong-Sandler"; - return new WongSandlerMixingRule(phase, NRTLalpha, NRTLDij, NRTLDijT, classicOrWS); - } else if (i == 6) { - mixingRuleName = "Wong-Sandler"; - return new WongSandlerMixingRule(phase, NRTLalpha, NRTLDij, NRTLDijT, classicOrWS); - } else if (i == 7) { - mixingRuleName = "classic-CPA"; - return new ClassicSRK(); - } else if (i == 8) { - mixingRuleName = "classic-T"; - return new ClassicSRKT(); - } else if (i == 9) { - mixingRuleName = "classic-CPA_T"; - return new ClassicSRKT2(); - } else if (i == 10) { - org.ejml.simple.SimpleMatrix mat1 = new org.ejml.simple.SimpleMatrix(intparamij); - org.ejml.simple.SimpleMatrix mat2 = new org.ejml.simple.SimpleMatrix(intparamji); - org.ejml.simple.SimpleMatrix mat3 = new org.ejml.simple.SimpleMatrix(intparamT); - if (mat1.isIdentical(mat2, 1e-8)) { - if (mat3.elementMaxAbs() < 1e-8) { - mixingRuleName = "classic-CPA"; - return new ClassicSRK(); - } - mixingRuleName = "classic-CPA_T"; - return new ClassicSRKT2(); - } else { - mixingRuleName = "classic-CPA_Tx"; - return new ClassicSRKT2x(); - } - } // else if(i==10){ - // return new ElectrolyteMixRule(phase, HValpha, HVgij, HVgii, classicOrHV, - // wij);} - else { - return new ClassicVdW(); - } + @Override + public double calcBij(int compNumb, int compNumbj, PhaseInterface phase, double temperature, + double pressure, int numbcomp) { + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + return compArray[compNumb].getdBdndn(compNumbj); } + } - /** - *

- * getElectrolyteMixingRule. - *

- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a {@link neqsim.thermo.mixingRule.ElectrolyteMixingRulesInterface} object - */ - public ElectrolyteMixingRulesInterface getElectrolyteMixingRule(PhaseInterface phase) { - return new ElectrolyteMixRule(phase); + public class ElectrolyteMixRule implements ElectrolyteMixingRulesInterface, Cloneable { + private static final long serialVersionUID = 1000; + + public ElectrolyteMixRule(PhaseInterface phase) { + calcWij(phase); } - /** - * Getter for property CalcEOSInteractionParameters. - * - * @return Value of property CalcEOSInteractionParameters. - */ - public boolean isCalcEOSInteractionParameters() { - return calcEOSInteractionParameters; + @Override + public void calcWij(PhaseInterface phase) { + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + int numbcomp = phase.getNumberOfComponents(); + + // System.out.println("numb comp " + numbcomp); + for (int i = 0; i < numbcomp; i++) { + if (compArray[i].getIonicCharge() > 0) { + for (int j = 0; j < numbcomp; j++) { + if (wijCalcOrFitted[i][j] == 0) { + if (compArray[j].getComponentName().equals("water") + || compArray[j].getComponentName().equals("MDEA") + || compArray[j].getComponentName().equals("Piperazine")) {// compArray[j].getIonicCharge()==0){ + wij[0][i][j] = + neqsim.thermo.util.constants.FurstElectrolyteConstants.getFurstParam(2) + * compArray[i].getStokesCationicDiameter() + + neqsim.thermo.util.constants.FurstElectrolyteConstants.getFurstParam(3); + } + // if(compArray[j].getComponentName().equals("MDEA")){ + // wij[0][i][j] = + // (thermo.util.constants.FurstElectrolyteConstants.getFurstParamMDEA(2) + // * + // compArray[i].getStokesCationicDiameter() + + // thermo.util.constants.FurstElectrolyteConstants.getFurstParamMDEA(3)); + // } + if (compArray[j].getIonicCharge() < -0.01) { + wij[0][i][j] = + neqsim.thermo.util.constants.FurstElectrolyteConstants.getFurstParam(4) + * Math.pow(compArray[i].getStokesCationicDiameter() + + compArray[j].getPaulingAnionicDiameter(), 4.0) + + neqsim.thermo.util.constants.FurstElectrolyteConstants.getFurstParam(5); + } + wij[0][j][i] = wij[0][i][j]; + } + } + } + } } - /** - *

- * Setter for the field calcEOSInteractionParameters. - *

- * - * @param CalcEOSInteractionParameters2 a boolean - */ - public void setCalcEOSInteractionParameters(boolean CalcEOSInteractionParameters2) { - calcEOSInteractionParameters = CalcEOSInteractionParameters2; + @Override + public void setWijParameter(int i, int j, double value) { + // System.out.println("intparam: " + value); + wij[0][i][j] = value; + wij[0][j][i] = value; } - /** - * Getter for property mixingRuleName. - * - * @return Value of property mixingRuleName. - */ - public java.lang.String getMixingRuleName() { - return mixingRuleName; + @Override + public double getWijParameter(int i, int j) { + return wij[0][i][j]; } - /** - * Setter for property mixingRuleName. - * - * @param mixingRuleName New value of property mixingRuleName. - */ - public void setMixingRuleName(java.lang.String mixingRuleName) { - this.mixingRuleName = mixingRuleName; + @Override + public void setWijT1Parameter(int i, int j, double value) { + wij[1][i][j] = value; + wij[1][j][i] = value; } - /** - *

- * Setter for the field mixingRuleGEModel. - *

- * - * @param GEmodel a {@link java.lang.String} object - */ - public void setMixingRuleGEModel(java.lang.String GEmodel) { - this.mixingRuleGEModel = GEmodel; + @Override + public double gettWijT1Parameter(int i, int j) { + return wij[1][i][j]; } - /** - *

- * getSRKbinaryInteractionParameters. - *

- * - * @return an array of {@link double} objects - */ - public double[][] getSRKbinaryInteractionParameters() { - return intparam; + @Override + public void setWijT2Parameter(int i, int j, double value) { + wij[2][i][j] = value; + wij[2][j][i] = value; } - /** - * Getter for property HVDij. - * - * @return Value of property HVDij. - */ - public double[][] getHVDij() { - return this.HVDij; + @Override + public double gettWijT2Parameter(int i, int j) { + return wij[2][i][j]; } - /** - * Getter for property HValpha. - * - * @return Value of property HValpha. - */ - public double[][] getHValpha() { - return this.HValpha; + @Override + public double getWij(int i, int j, double temperature) { + return wij[0][i][j] + wij[1][i][j] * (1.0 / temperature - 1.0 / 298.15) + + wij[2][i][j] * ((298.15 - temperature) / temperature + Math.log(temperature / 298.15)); } - /** - * Getter for property HVDijT. - * - * @return Value of property HVDijT. - */ - public double[][] getHVDijT() { - return this.HVDijT; + @Override + public double getWijT(int i, int j, double temperature) { + return (-wij[1][i][j] / (temperature * temperature) + - wij[2][i][j] * (298.15 - temperature) / (temperature * temperature)); } - /** - * Getter for property NRTLDij. - * - * @return Value of property NRTLDij. - */ - public double[][] getNRTLDij() { - return this.NRTLDij; + @Override + public double getWijTT(int i, int j, double temperature) { + return (2.0 * wij[1][i][j] / (temperature * temperature * temperature) + + wij[2][i][j] / (temperature * temperature) + 2.0 * wij[2][i][j] * (298.15 - temperature) + / (temperature * temperature * temperature)); } - /** - * Getter for property NRTLalpha. - * - * @return Value of property NRTLalpha. - */ - public double[][] getNRTLalpha() { - return this.NRTLalpha; + @Override + public double calcW(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + double W = 0.0; + for (int i = 0; i < numbcomp; i++) { + for (int j = 0; j < numbcomp; j++) { + W += compArray[i].getNumberOfMolesInPhase() * compArray[j].getNumberOfMolesInPhase() + * getWij(i, j, temperature); // wij[0][i][j]; + } + } + return -W; } - /** - * Getter for property NRTLDijT. - * - * @return Value of property NRTLDijT. - */ - public double[][] getNRTLDijT() { - return this.NRTLDijT; + @Override + public double calcWi(int compNumb, PhaseInterface phase, double temperature, double pressure, + int numbcomp) { + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + + double Wi = 0.0; + for (int j = 0; j < numbcomp; j++) { + Wi += compArray[j].getNumberOfMolesInPhase() * getWij(compNumb, j, temperature); + } + return -2.0 * Wi; } - /** - * Getter for property WSintparam. - * - * @return Value of property WSintparam. - */ - public double[][] getWSintparam() { - return this.WSintparam; + @Override + public double calcWiT(int compNumb, PhaseInterface phase, double temperature, double pressure, + int numbcomp) { + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + double WiT = 0; + for (int j = 0; j < numbcomp; j++) { + WiT += compArray[j].getNumberOfMolesInPhase() * getWijT(compNumb, j, temperature); + } + return -2.0 * WiT; } - /** - * Getter for property classicOrHV. - * - * @return Value of property classicOrHV. - */ - public java.lang.String[][] getClassicOrHV() { - return this.classicOrHV; + @Override + public double calcWT(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + + double WT = 0; + for (int i = 0; i < numbcomp; i++) { + for (int j = 0; j < numbcomp; j++) { + WT += compArray[i].getNumberOfMolesInPhase() * compArray[j].getNumberOfMolesInPhase() + * getWijT(i, j, temperature); // wij[0][i][j]; + } + } + return -WT; } - /** - * Getter for property classicOrWS. - * - * @return Value of property classicOrWS. - */ - public java.lang.String[][] getClassicOrWS() { - return this.classicOrWS; + @Override + public double calcWTT(PhaseInterface phase, double temperature, double pressure, int numbcomp) { + ComponentEosInterface[] compArray = (ComponentEosInterface[]) phase.getcomponentArray(); + + double WTT = 0; + for (int i = 0; i < numbcomp; i++) { + for (int j = 0; j < numbcomp; j++) { + WTT += compArray[i].getNumberOfMolesInPhase() * compArray[j].getNumberOfMolesInPhase() + * getWijTT(i, j, temperature); // wij[0][i][j]; + } + } + return -WTT; } - /** - *

- * displayInteractionCoefficients. - *

- * - * @param intType a {@link java.lang.String} object - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - */ - public void displayInteractionCoefficients(String intType, PhaseInterface phase) { - String[][] interactTable = - new String[phase.getNumberOfComponents() + 1][phase.getNumberOfComponents() + 1]; - - java.text.DecimalFormat nf = new java.text.DecimalFormat(); - - java.text.DecimalFormatSymbols symbols = new java.text.DecimalFormatSymbols(); - symbols.setDecimalSeparator('.'); - nf.setDecimalFormatSymbols(symbols); - - nf.setMaximumFractionDigits(5); - nf.applyPattern("#.#####E0"); - - /// String[][] table = new String[getPhases()[0].getNumberOfComponents() + - /// 30][7]; - String[] names = new String[phase.getNumberOfComponents() + 1]; - names[0] = ""; - for (int i = 0; i < phase.getNumberOfComponents(); i++) { - interactTable[i + 1][0] = phase.getComponent(i).getComponentName(); - interactTable[0][i + 1] = phase.getComponent(i).getComponentName(); - names[i + 1] = ""; - for (int j = 0; j < phase.getNumberOfComponents(); j++) { - interactTable[i + 1][j + 1] = Double.toString(intparam[i][j]); + @Override + public double calcWij(int compNumbi, int compNumj, PhaseInterface phase, double temperature, + double pressure, int numbcomp) { + return -2.0 * getWij(compNumbi, compNumj, temperature); // iwij[0][compNumbi][compNumj]; + } + } + + /** + *

+ * getMixingRule. + *

+ * + * @param i a int + * @return a {@link neqsim.thermo.mixingRule.EosMixingRulesInterface} object + */ + public EosMixingRulesInterface getMixingRule(int i) { + if (i == 1) { + return new ClassicVdW(); + } else if (i == 2) { + return new ClassicSRK(); + } else if (i == 3) { + return new ClassicVdW(); + } else { + return new ClassicVdW(); + } + } + + /** + *

+ * getMixingRule. + *

+ * + * @param i a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a {@link neqsim.thermo.mixingRule.EosMixingRulesInterface} object + */ + public EosMixingRulesInterface getMixingRule(int i, PhaseInterface phase) { + this.wij = new double[3][phase.getNumberOfComponents()][phase.getNumberOfComponents()]; + + if (i == 1) { + intparam = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; + return new ClassicVdW(); + } + intparam = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; + intparamji = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; + intparamij = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; + intparamT = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; + intparamTType = new int[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; + HVDij = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; + HVDijT = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; + NRTLDij = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; + NRTLDijT = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; + WSintparam = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; + HValpha = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; + NRTLalpha = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; + classicOrHV = new String[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; + classicOrWS = new String[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; + wijCalcOrFitted = new int[phase.getNumberOfComponents()][phase.getNumberOfComponents()]; + neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); + + for (int k = 0; k < phase.getNumberOfComponents(); k++) { + String component_name = phase.getComponents()[k].getComponentName(); + + for (int l = k; l < phase.getNumberOfComponents(); l++) { + if (k == l) { + classicOrHV[k][l] = "Classic"; + classicOrWS[k][l] = "Classic"; + classicOrHV[l][k] = classicOrHV[k][l]; + classicOrWS[l][k] = classicOrWS[k][l]; + } else { + java.sql.ResultSet dataSet = null; + try { + if (phase.getComponent(k).isIsTBPfraction() + || phase.getComponent(l).isIsTBPfraction()) { + throw new Exception("no interaction coefficient for TBP fractions"); + } + int templ = l; + int tempk = k; + if (NeqSimDataBase.createTemporaryTables()) { + dataSet = database.getResultSet("SELECT * FROM intertemp WHERE (comp1='" + + component_name + "' AND comp2='" + phase.getComponents()[l].getComponentName() + + "') OR (comp1='" + phase.getComponents()[l].getComponentName() + "' AND comp2='" + + component_name + "')"); + } else { + dataSet = database.getResultSet("SELECT * FROM inter WHERE (comp1='" + component_name + + "' AND comp2='" + phase.getComponents()[l].getComponentName() + "') OR (comp1='" + + phase.getComponents()[l].getComponentName() + "' AND comp2='" + component_name + + "')"); + } + dataSet.next(); + if (dataSet.getString("comp1").trim() + .equals(phase.getComponents()[l].getComponentName())) { + templ = k; + tempk = l; + } + + classicOrHV[k][l] = dataSet.getString("HVTYPE").trim(); + classicOrHV[l][k] = classicOrHV[k][l]; + + if (isCalcEOSInteractionParameters()) { + intparam[k][l] = 1.0 - Math.pow((2.0 + * Math.sqrt(Math.pow(phase.getComponent(l).getCriticalVolume(), 1 / 3) + * Math.pow(phase.getComponent(k).getCriticalVolume(), 1 / 3)) + / (Math.pow(phase.getComponent(l).getCriticalVolume(), 1 / 3) + + Math.pow(phase.getComponent(k).getCriticalVolume(), 1 / 3))), + nEOSkij); + intparamT[k][l] = 0.0; + // System.out.println("kij " + intparam[k][l]); + } else { + if (phase.getClass().getName().equals("neqsim.thermo.phase.PhasePrEos")) { + // System.out.println("using PR intparams"); + intparam[k][l] = Double.parseDouble(dataSet.getString("kijpr")); + intparamT[k][l] = Double.parseDouble(dataSet.getString("KIJTpr")); + } else { + intparam[k][l] = Double.parseDouble(dataSet.getString("kijsrk")); + intparamT[k][l] = Double.parseDouble(dataSet.getString("KIJTSRK")); + } + if (phase.getClass().getName().equals("neqsim.thermo.phase.PhasePrCPA")) { + intparam[k][l] = Double.parseDouble(dataSet.getString("cpakij_PR")); + intparamT[k][l] = 0.0; + } else if (phase.getClass().getName().equals("neqsim.thermo.phase.PhaseSrkCPA") + || phase.getClass().getName().equals("neqsim.thermo.phase.PhaseSrkCPAs") + || phase.getClass().getName() + .equals("neqsim.thermo.phase.PhaseElectrolyteCPAstatoil")) { + intparam[k][l] = Double.parseDouble(dataSet.getString("cpakij_SRK")); + intparamT[k][l] = Double.parseDouble(dataSet.getString("cpakijT_SRK")); + + intparamij[tempk][templ] = Double.parseDouble(dataSet.getString("cpakijx_SRK")); + intparamji[templ][tempk] = intparamij[tempk][templ]; + + intparamji[tempk][templ] = Double.parseDouble(dataSet.getString("cpakjix_SRK")); + intparamij[templ][tempk] = intparamji[tempk][templ]; + } + if (phase.getClass().getName().equals("neqsim.thermo.phase.PhasePCSAFTRahmat") + || phase.getClass().getName().equals("neqsim.thermo.phase.PhasePCSAFT") + || phase.getClass().getName().equals("neqsim.thermo.phase.PhasePCSAFTa")) { + intparam[k][l] = Double.parseDouble(dataSet.getString("KIJPCSAFT")); + intparamT[k][l] = 0.0; + } + } + + java.sql.ResultSetMetaData dataSetMD = dataSet.getMetaData(); + int cols = dataSetMD.getColumnCount(); + boolean hasKIJTTypeCPAcol = false; + String colname = "KIJTTypeCPA"; + for (int x = 1; x <= cols; x++) { + if (colname.equals(dataSetMD.getColumnName(x))) { + hasKIJTTypeCPAcol = true; + } + } + + // System.out.println("class name " + phase.getClass().getName()); + if (!phase.getClass().getName().equals("neqsim.thermo.phase.PhaseSrkCPAs") + || !hasKIJTTypeCPAcol) { + intparamTType[k][l] = Integer.parseInt(dataSet.getString("KIJTType")); + } else { + intparamTType[k][l] = Integer.parseInt(dataSet.getString("KIJTTypeCPA")); // TODO: + // implement + // in all + // dbs + } + intparamTType[l][k] = intparamTType[k][l]; + + HValpha[k][l] = Double.parseDouble(dataSet.getString("HValpha")); + HValpha[l][k] = HValpha[k][l]; + + HVDij[tempk][templ] = Double.parseDouble(dataSet.getString("HVgij")); + HVDij[templ][tempk] = Double.parseDouble(dataSet.getString("HVgji")); + + wijCalcOrFitted[k][l] = Integer.parseInt(dataSet.getString("CalcWij")); + wijCalcOrFitted[l][k] = wijCalcOrFitted[k][l]; + + wij[0][k][l] = Double.parseDouble(dataSet.getString("w1")); + wij[0][l][k] = wij[0][k][l]; + wij[1][k][l] = Double.parseDouble(dataSet.getString("w2")); + wij[1][l][k] = wij[1][k][l]; + wij[2][k][l] = Double.parseDouble(dataSet.getString("w3")); + wij[2][l][k] = wij[2][k][l]; + + classicOrWS[k][l] = dataSet.getString("WSTYPE").trim(); + classicOrWS[l][k] = classicOrWS[k][l]; + + WSintparam[k][l] = Double.parseDouble(dataSet.getString("kijWS")); + WSintparam[k][l] = Double.parseDouble(dataSet.getString("KIJWSunifac")); + WSintparam[l][k] = WSintparam[k][l]; + + NRTLalpha[k][l] = Double.parseDouble(dataSet.getString("NRTLalpha")); + NRTLalpha[l][k] = NRTLalpha[k][l]; + + NRTLDij[tempk][templ] = Double.parseDouble(dataSet.getString("NRTLgij")); + NRTLDij[templ][tempk] = Double.parseDouble(dataSet.getString("NRTLgji")); + + HVDijT[tempk][templ] = Double.parseDouble(dataSet.getString("HVgijT")); + HVDijT[templ][tempk] = Double.parseDouble(dataSet.getString("HVgjiT")); + + NRTLDijT[tempk][templ] = Double.parseDouble(dataSet.getString("WSgijT")); + NRTLDijT[templ][tempk] = Double.parseDouble(dataSet.getString("WSgjiT")); + } catch (Exception e) { + // System.out.println("err in thermo mix....."); + // String err = e.toString(); + // System.out.println(err); + if (isCalcEOSInteractionParameters()) { + intparam[k][l] = 1.0 - Math.pow((2.0 + * Math.sqrt(Math.pow(phase.getComponent(l).getCriticalVolume(), 1.0 / 3.0) + * Math.pow(phase.getComponent(k).getCriticalVolume(), 1.0 / 3.0)) + / (Math.pow(phase.getComponent(l).getCriticalVolume(), 1.0 / 3.0) + + Math.pow(phase.getComponent(k).getCriticalVolume(), 1.0 / 3.0))), + nEOSkij); + // System.out.println("intparam not defined .... CALCULATING intparam + // between " + // +phase.getComponents()[l].getComponentName() + " and " + + // phase.getComponents()[k].getComponentName()+ " to " + + // intparam[k][l]); + } else if ((phase.getComponents()[k].getComponentName().equals("CO2") + && phase.getComponents()[l].isIsTBPfraction()) + || (phase.getComponents()[l].getComponentName().equals("CO2") + && phase.getComponents()[k].isIsTBPfraction())) { + intparam[k][l] = 0.1; + } else if ((phase.getComponents()[k].getComponentName().equals("nitrogen") + && phase.getComponents()[l].isIsTBPfraction()) + || (phase.getComponents()[l].getComponentName().equals("nitrogen") + && phase.getComponents()[k].isIsTBPfraction())) { + intparam[k][l] = 0.08; + } else if ((phase.getComponents()[k].getComponentName().equals("water") + && phase.getComponents()[l].isIsTBPfraction()) + || (phase.getComponents()[l].getComponentName().equals("water") + && phase.getComponents()[k].isIsTBPfraction())) { + intparam[k][l] = 0.2; + + if (phase.getClass().getName().equals("neqsim.thermo.phase.PhaseSrkCPA") + || phase.getClass().getName().equals("neqsim.thermo.phase.PhaseSrkCPAs") + || phase.getClass().getName() + .equals("neqsim.thermo.phase.PhaseElectrolyteCPAstatoil")) { + // intparam[k][l] = -0.0685; // taken from Riaz et a. 2012 + + double molmassPC = phase.getComponents()[l].getMolarMass(); + if (phase.getComponents()[k].isIsTBPfraction()) { + molmassPC = phase.getComponents()[k].getMolarMass(); + } + double intparamkPC = -0.1533 * Math.log(1000.0 * molmassPC) + 0.7055; + intparam[k][l] = intparamkPC; + // System.out.println("kij water-HC " + intparam[k][l]); + + intparamT[k][l] = 0.0; + } + } else if ((phase.getComponents()[k].getComponentName().equals("MEG") + && phase.getComponents()[l].isIsTBPfraction()) + || (phase.getComponents()[l].getComponentName().equals("MEG") + && phase.getComponents()[k].isIsTBPfraction())) { + intparam[k][l] = 0.2; + if (phase.getClass().getName().equals("neqsim.thermo.phase.PhaseSrkCPA") + || phase.getClass().getName().equals("neqsim.thermo.phase.PhaseSrkCPAs") + || phase.getClass().getName() + .equals("neqsim.thermo.phase.PhaseElectrolyteCPAstatoil")) { + double molmassPC = phase.getComponents()[l].getMolarMass(); + if (phase.getComponents()[k].isIsTBPfraction()) { + molmassPC = phase.getComponents()[k].getMolarMass(); + } + double intparamkPC = -0.0701 * Math.log(1000.0 * molmassPC) + 0.3521; + intparam[k][l] = intparamkPC; + // System.out.println("kij MEG-HC " + intparam[k][l]); + // intparam[k][l] = 0.01; + intparamT[k][l] = 0.0; + } + } else if ((phase.getComponents()[k].getComponentName().equals("ethanol") + && phase.getComponents()[l].isIsTBPfraction()) + || (phase.getComponents()[l].getComponentName().equals("ethanol") + && phase.getComponents()[k].isIsTBPfraction())) { + intparam[k][l] = 0.0; + if (phase.getClass().getName().equals("neqsim.thermo.phase.PhaseSrkCPA") + || phase.getClass().getName().equals("neqsim.thermo.phase.PhaseSrkCPAs") + || phase.getClass().getName() + .equals("neqsim.thermo.phase.PhaseElectrolyteCPAstatoil")) { + intparam[k][l] = -0.05; + intparamT[k][l] = 0.0; + if (phase.getComponents()[k].getMolarMass() > (200.0 / 1000.0) + || phase.getComponents()[l].getMolarMass() > (200.0 / 1000.0)) { + intparam[k][l] = -0.1; + } + } + } else if ((phase.getComponents()[k].getComponentName().equals("methanol") + && phase.getComponents()[l].isIsTBPfraction()) + || (phase.getComponents()[l].getComponentName().equals("methanol") + && phase.getComponents()[k].isIsTBPfraction())) { + intparam[k][l] = 0.0; + if (phase.getClass().getName().equals("neqsim.thermo.phase.PhaseSrkCPA") + || phase.getClass().getName().equals("neqsim.thermo.phase.PhaseSrkCPAs") + || phase.getClass().getName() + .equals("neqsim.thermo.phase.PhaseElectrolyteCPAstatoil")) { + intparam[k][l] = -0.1; + intparamT[k][l] = 0.0; + if (phase.getComponents()[k].getMolarMass() > (200.0 / 1000.0) + || phase.getComponents()[l].getMolarMass() > (200.0 / 1000.0)) { + intparam[k][l] = -0.2; + } + } + } else if ((phase.getComponents()[k].getComponentName().equals("TEG") + && phase.getComponents()[l].isIsTBPfraction()) + || (phase.getComponents()[l].getComponentName().equals("TEG") + && phase.getComponents()[k].isIsTBPfraction())) { + intparam[k][l] = 0.12; + if (phase.getClass().getName().equals("neqsim.thermo.phase.PhaseSrkCPA") + || phase.getClass().getName().equals("neqsim.thermo.phase.PhaseSrkCPAs") + || phase.getClass().getName() + .equals("neqsim.thermo.phase.PhaseElectrolyteCPAstatoil")) { + intparam[k][l] = 0.12; + intparamT[k][l] = 0.0; + } + } else if ((phase.getComponents()[k].getComponentName().equals("S8") + && phase.getComponents()[l].isIsTBPfraction()) + || (phase.getComponents()[l].getComponentName().equals("S8") + && phase.getComponents()[k].isIsTBPfraction())) { + intparam[k][l] = 0.05; + } else { + // if((phase.getComponents()[l].getComponentName().equals("CO2") || + // phase.getComponents()[k].getComponentName().equals("CO2")) && k!=l) + // intparam[k][l] = 0.1; + // else if((phase.getComponents()[l].getComponentName().equals("H2S") || + // phase.getComponents()[k].getComponentName().equals("H2S")) && k!=l) + // intparam[k][l] = 0.2; + // else if((phase.getComponents()[l].getComponentName().equals("water") + // || + // phase.getComponents()[k].getComponentName().equals("water")) && k!=l) + // intparam[k][l] = 0.5; + // else intparam[k][l] = 0.0; + // System.out.println("intparam not defined .... setting intparam + // between " + + // phase.getComponents()[l].getComponentName() + " and " + + // phase.getComponents()[k].getComponentName() + " to " + + // intparam[k][l]); + } + + // intparam[l][k] = intparam[k][l]; + // intparamT[l][k] = intparamT[k][l]; + intparamij[k][l] = intparam[k][l]; + intparamij[l][k] = intparam[k][l]; + intparamji[k][l] = intparam[k][l]; + intparamji[l][k] = intparam[k][l]; + // System.out.println("kij set to " + intparam[l][k] + " " + + // phase.getComponents()[l].getComponentName() + " " + + // phase.getComponents()[k].getComponentName()); + + classicOrHV[k][l] = "Classic"; + classicOrHV[l][k] = classicOrHV[k][l]; + + classicOrWS[k][l] = "Classic"; + classicOrWS[l][k] = classicOrWS[k][l]; + } finally { + intparam[l][k] = intparam[k][l]; + intparamT[l][k] = intparamT[k][l]; + try { + if (dataSet != null) { + dataSet.close(); + } + } catch (Exception e) { + logger.error("err closing dataSet IN MIX...", e); } + } } + } + } - JFrame dialog = new JFrame("Interaction coefficients"); - Container dialogContentPane = dialog.getContentPane(); - dialogContentPane.setLayout(new BorderLayout()); + try { + if (database.getStatement() != null) { + database.getStatement().close(); + } + if (database.getConnection() != null) { + database.getConnection().close(); + } + } catch (Exception e) { + logger.error("error closing database.....", e); + } - JTable Jtab = new JTable(interactTable, names); - JScrollPane scrollpane = new JScrollPane(Jtab); - dialogContentPane.add(scrollpane); - dialog.setSize(800, 600); // pack(); - // \\dialog.pack(); - dialog.setVisible(true); + if (i == 2) { + mixingRuleName = "classic"; + return new ClassicSRK(); + } else if (i == 3) { + // Classic Huron-Vidal + mixingRuleName = "Huron-Vidal"; + return new SRKHuronVidal2(phase, HValpha, HVDij, classicOrHV); + } else if (i == 4) { + mixingRuleName = "Huron-Vidal"; + return new SRKHuronVidal2(phase, HValpha, HVDij, HVDijT, classicOrHV); + } else if (i == 5) { + mixingRuleName = "Wong-Sandler"; + return new WongSandlerMixingRule(phase, NRTLalpha, NRTLDij, NRTLDijT, classicOrWS); + } else if (i == 6) { + mixingRuleName = "Wong-Sandler"; + return new WongSandlerMixingRule(phase, NRTLalpha, NRTLDij, NRTLDijT, classicOrWS); + } else if (i == 7) { + mixingRuleName = "classic-CPA"; + return new ClassicSRK(); + } else if (i == 8) { + mixingRuleName = "classicdT"; + return new ClassicSRKT(); + } else if (i == 9) { + mixingRuleName = "classic-CPA_T"; + return new ClassicSRKT2(); + } else if (i == 10) { + org.ejml.simple.SimpleMatrix mat1 = new org.ejml.simple.SimpleMatrix(intparamij); + org.ejml.simple.SimpleMatrix mat2 = new org.ejml.simple.SimpleMatrix(intparamji); + org.ejml.simple.SimpleMatrix mat3 = new org.ejml.simple.SimpleMatrix(intparamT); + if (mat1.isIdentical(mat2, 1e-8)) { + if (mat3.elementMaxAbs() < 1e-8) { + mixingRuleName = "classic-CPA"; + return new ClassicSRK(); + } + mixingRuleName = "classic-CPA_T"; + return new ClassicSRKT2(); + } else { + mixingRuleName = "classic-CPA_Tx"; + return new ClassicSRKT2x(); + } + } // else if(i==10){ + // return new ElectrolyteMixRule(phase, HValpha, HVgij, HVgii, classicOrHV, + // wij);} + else { + return new ClassicVdW(); + } + } + + /** + *

+ * resetMixingRule. + *

+ * + * @param i a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a {@link neqsim.thermo.mixingRule.EosMixingRulesInterface} object + */ + public EosMixingRulesInterface resetMixingRule(int i, PhaseInterface phase) { + if (i == 1) { + mixingRuleName = "no (kij=0)"; + return new ClassicVdW(); + } else if (i == 2) { + mixingRuleName = "classic"; + return new ClassicSRK(); + } else if (i == 3) { + // Classic Huron-Vidal + mixingRuleName = "Huron-Vidal"; + return new SRKHuronVidal2(phase, HValpha, HVDij, classicOrHV); + } else if (i == 4) { + mixingRuleName = "Huron-Vidal"; + return new SRKHuronVidal2(phase, HValpha, HVDij, HVDijT, classicOrHV); + } else if (i == 5) { + mixingRuleName = "Wong-Sandler"; + return new WongSandlerMixingRule(phase, NRTLalpha, NRTLDij, NRTLDijT, classicOrWS); + } else if (i == 6) { + mixingRuleName = "Wong-Sandler"; + return new WongSandlerMixingRule(phase, NRTLalpha, NRTLDij, NRTLDijT, classicOrWS); + } else if (i == 7) { + mixingRuleName = "classic-CPA"; + return new ClassicSRK(); + } else if (i == 8) { + mixingRuleName = "classic-T"; + return new ClassicSRKT(); + } else if (i == 9) { + mixingRuleName = "classic-CPA_T"; + return new ClassicSRKT2(); + } else if (i == 10) { + org.ejml.simple.SimpleMatrix mat1 = new org.ejml.simple.SimpleMatrix(intparamij); + org.ejml.simple.SimpleMatrix mat2 = new org.ejml.simple.SimpleMatrix(intparamji); + org.ejml.simple.SimpleMatrix mat3 = new org.ejml.simple.SimpleMatrix(intparamT); + if (mat1.isIdentical(mat2, 1e-8)) { + if (mat3.elementMaxAbs() < 1e-8) { + mixingRuleName = "classic-CPA"; + return new ClassicSRK(); + } + mixingRuleName = "classic-CPA_T"; + return new ClassicSRKT2(); + } else { + mixingRuleName = "classic-CPA_Tx"; + return new ClassicSRKT2x(); + } + } // else if(i==10){ + // return new ElectrolyteMixRule(phase, HValpha, HVgij, HVgii, classicOrHV, + // wij);} + else { + return new ClassicVdW(); } + } + + /** + *

+ * getElectrolyteMixingRule. + *

+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a {@link neqsim.thermo.mixingRule.ElectrolyteMixingRulesInterface} object + */ + public ElectrolyteMixingRulesInterface getElectrolyteMixingRule(PhaseInterface phase) { + return new ElectrolyteMixRule(phase); + } + + /** + * Getter for property CalcEOSInteractionParameters. + * + * @return Value of property CalcEOSInteractionParameters. + */ + public boolean isCalcEOSInteractionParameters() { + return calcEOSInteractionParameters; + } + + /** + *

+ * Setter for the field calcEOSInteractionParameters. + *

+ * + * @param CalcEOSInteractionParameters2 a boolean + */ + public void setCalcEOSInteractionParameters(boolean CalcEOSInteractionParameters2) { + calcEOSInteractionParameters = CalcEOSInteractionParameters2; + } + + /** + * Getter for property mixingRuleName. + * + * @return Value of property mixingRuleName. + */ + public java.lang.String getMixingRuleName() { + return mixingRuleName; + } + + /** + * Setter for property mixingRuleName. + * + * @param mixingRuleName New value of property mixingRuleName. + */ + public void setMixingRuleName(java.lang.String mixingRuleName) { + this.mixingRuleName = mixingRuleName; + } + + /** + *

+ * Setter for the field mixingRuleGEModel. + *

+ * + * @param GEmodel a {@link java.lang.String} object + */ + public void setMixingRuleGEModel(java.lang.String GEmodel) { + this.mixingRuleGEModel = GEmodel; + } + + /** + *

+ * getSRKbinaryInteractionParameters. + *

+ * + * @return an array of {@link double} objects + */ + public double[][] getSRKbinaryInteractionParameters() { + return intparam; + } + + /** + * Getter for property HVDij. + * + * @return Value of property HVDij. + */ + public double[][] getHVDij() { + return this.HVDij; + } + + /** + * Getter for property HValpha. + * + * @return Value of property HValpha. + */ + public double[][] getHValpha() { + return this.HValpha; + } + + /** + * Getter for property HVDijT. + * + * @return Value of property HVDijT. + */ + public double[][] getHVDijT() { + return this.HVDijT; + } + + /** + * Getter for property NRTLDij. + * + * @return Value of property NRTLDij. + */ + public double[][] getNRTLDij() { + return this.NRTLDij; + } + + /** + * Getter for property NRTLalpha. + * + * @return Value of property NRTLalpha. + */ + public double[][] getNRTLalpha() { + return this.NRTLalpha; + } + + /** + * Getter for property NRTLDijT. + * + * @return Value of property NRTLDijT. + */ + public double[][] getNRTLDijT() { + return this.NRTLDijT; + } + + /** + * Getter for property WSintparam. + * + * @return Value of property WSintparam. + */ + public double[][] getWSintparam() { + return this.WSintparam; + } + + /** + * Getter for property classicOrHV. + * + * @return Value of property classicOrHV. + */ + public java.lang.String[][] getClassicOrHV() { + return this.classicOrHV; + } + + /** + * Getter for property classicOrWS. + * + * @return Value of property classicOrWS. + */ + public java.lang.String[][] getClassicOrWS() { + return this.classicOrWS; + } + + /** + *

+ * displayInteractionCoefficients. + *

+ * + * @param intType a {@link java.lang.String} object + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + */ + public void displayInteractionCoefficients(String intType, PhaseInterface phase) { + String[][] interactTable = + new String[phase.getNumberOfComponents() + 1][phase.getNumberOfComponents() + 1]; + + java.text.DecimalFormat nf = new java.text.DecimalFormat(); + + java.text.DecimalFormatSymbols symbols = new java.text.DecimalFormatSymbols(); + symbols.setDecimalSeparator('.'); + nf.setDecimalFormatSymbols(symbols); + + nf.setMaximumFractionDigits(5); + nf.applyPattern("#.#####E0"); + + /// String[][] table = new String[getPhases()[0].getNumberOfComponents() + + /// 30][7]; + String[] names = new String[phase.getNumberOfComponents() + 1]; + names[0] = ""; + for (int i = 0; i < phase.getNumberOfComponents(); i++) { + interactTable[i + 1][0] = phase.getComponent(i).getComponentName(); + interactTable[0][i + 1] = phase.getComponent(i).getComponentName(); + names[i + 1] = ""; + for (int j = 0; j < phase.getNumberOfComponents(); j++) { + interactTable[i + 1][j + 1] = Double.toString(intparam[i][j]); + } + } + + JFrame dialog = new JFrame("Interaction coefficients"); + Container dialogContentPane = dialog.getContentPane(); + dialogContentPane.setLayout(new BorderLayout()); + + JTable Jtab = new JTable(interactTable, names); + JScrollPane scrollpane = new JScrollPane(Jtab); + dialogContentPane.add(scrollpane); + dialog.setSize(800, 600); // pack(); + // \\dialog.pack(); + dialog.setVisible(true); + } } diff --git a/src/main/java/neqsim/thermo/phase/Phase.java b/src/main/java/neqsim/thermo/phase/Phase.java index 24688bcf6a..0d943adc1c 100644 --- a/src/main/java/neqsim/thermo/phase/Phase.java +++ b/src/main/java/neqsim/thermo/phase/Phase.java @@ -1462,7 +1462,8 @@ public double getOsmoticCoefficient(int watNumb) { // double ions=0.0; // for(int j=0;j - * Constructor for PhaseBWRSEos. - *

- */ - public PhaseBWRSEos() { - super(); - } - - /** {@inheritDoc} */ - @Override - public PhaseBWRSEos clone() { - PhaseBWRSEos clonedPhase = null; - try { - clonedPhase = (PhaseBWRSEos) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } - - return clonedPhase; - } - - /** {@inheritDoc} */ - @Override - public void addcomponent(String componentName, double moles, double molesInPhase, - int compNumber) { - super.addcomponent(componentName, moles, molesInPhase, compNumber); - - componentArray[compNumber] = - new ComponentBWRS(componentName, moles, molesInPhase, compNumber); - ((ComponentBWRS) componentArray[compNumber]).setRefPhaseBWRS(this); - } - - /** {@inheritDoc} */ - @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, - double beta) { - double oldMolDens = 0; - if (type == 0) { - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - super.init(totalNumberOfMoles, numberOfComponents, 3, phase, beta); - return; - } - do { - oldMolDens = getMolarDensity(); - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - } while (Math.abs((getMolarDensity() - oldMolDens) / oldMolDens) > 1e-10); - getF(); - // calcPVT(); - } - - /** - *

- * getMolarDensity. - *

- * - * @return a double - */ - public double getMolarDensity() { - return getNumberOfMolesInPhase() / getTotalVolume() * 1.0e2; + private static final long serialVersionUID = 1000; + + int OP = 9; + int OE = 6; + + static Logger logger = LogManager.getLogger(PhaseBWRSEos.class); + + /** + *

+ * Constructor for PhaseBWRSEos. + *

+ */ + public PhaseBWRSEos() { + super(); + } + + /** {@inheritDoc} */ + @Override + public PhaseBWRSEos clone() { + PhaseBWRSEos clonedPhase = null; + try { + clonedPhase = (PhaseBWRSEos) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); } - /** - *

- * getdRhodV. - *

- * - * @return a double - */ - public double getdRhodV() { - return -getMolarDensity() / (getTotalVolume() * 1e-5); + return clonedPhase; + } + + /** {@inheritDoc} */ + @Override + public void addcomponent(String componentName, double moles, double molesInPhase, + int compNumber) { + super.addcomponent(componentName, moles, molesInPhase, compNumber); + + componentArray[compNumber] = new ComponentBWRS(componentName, moles, molesInPhase, compNumber); + ((ComponentBWRS) componentArray[compNumber]).setRefPhaseBWRS(this); + } + + /** {@inheritDoc} */ + @Override + public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, + double beta) { + double oldMolDens = 0; + if (type == 0) { + super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, 3, phase, beta); + return; } - - /** - *

- * getdRhodVdV. - *

- * - * @return a double - */ - public double getdRhodVdV() { - return 2.0 * getMolarDensity() / (Math.pow(getTotalVolume() * 1e-5, 2)); + do { + oldMolDens = getMolarDensity(); + super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + } while (Math.abs((getMolarDensity() - oldMolDens) / oldMolDens) > 1e-10); + getF(); + // calcPVT(); + } + + /** + *

+ * getMolarDensity. + *

+ * + * @return a double + */ + public double getMolarDensity() { + return getNumberOfMolesInPhase() / getTotalVolume() * 1.0e2; + } + + /** + *

+ * getdRhodV. + *

+ * + * @return a double + */ + public double getdRhodV() { + return -getMolarDensity() / (getTotalVolume() * 1e-5); + } + + /** + *

+ * getdRhodVdV. + *

+ * + * @return a double + */ + public double getdRhodVdV() { + return 2.0 * getMolarDensity() / (Math.pow(getTotalVolume() * 1e-5, 2)); + } + + /** + *

+ * getdRhodVdVdV. + *

+ * + * @return a double + */ + public double getdRhodVdVdV() { + return -6.0 * getMolarDensity() / (Math.pow(getTotalVolume() * 1e-5, 3)); + } + + /** + *

+ * getGammadRho. + *

+ * + * @return a double + */ + public double getGammadRho() { + return 0.0; // -2.0/Math.pow(((ComponentBWRS)componentArray[0]).getRhoc(),3.0); + // //-1.0/(rhoc*rhoc); + } + + /** + *

+ * getFpol. + *

+ * + * @return a double + */ + public double getFpol() { + double temp = 0.0; + for (int i = 1; i < OP; i++) { + temp += + ((ComponentBWRS) componentArray[0]).getBP(i) / (i + 0.0) * Math.pow(getMolarDensity(), i); } - - /** - *

- * getdRhodVdVdV. - *

- * - * @return a double - */ - public double getdRhodVdVdV() { - return -6.0 * getMolarDensity() / (Math.pow(getTotalVolume() * 1e-5, 3)); + return numberOfMolesInPhase / (R * temperature) * temp; + } + + /** + *

+ * getFpoldV. + *

+ * + * @return a double + */ + public double getFpoldV() { + double temp = 0.0; + for (int i = 1; i < OP; i++) { + temp += (i) * ((ComponentBWRS) componentArray[0]).getBP(i) / (i - 0.0) + * Math.pow(getMolarDensity(), i - 1.0) * getdRhodV(); } - - /** - *

- * getGammadRho. - *

- * - * @return a double - */ - public double getGammadRho() { - return 0.0;// -2.0/Math.pow(((ComponentBWRS)componentArray[0]).getRhoc(),3.0);//-1.0/(rhoc*rhoc); + return numberOfMolesInPhase / (R * temperature) * temp; + } + + /** + *

+ * getFpoldVdV. + *

+ * + * @return a double + */ + public double getFpoldVdV() { + double temp = 0.0; + double temp2 = 0.0; + for (int i = 1; i < OP; i++) { + temp += (i - 1) * (i) * ((ComponentBWRS) componentArray[0]).getBP(i) / (i - 0.0) + * Math.pow(getMolarDensity(), i - 2.0); + temp2 += (i) * ((ComponentBWRS) componentArray[0]).getBP(i) / (i - 0.0) + * Math.pow(getMolarDensity(), i - 1.0); } - - /** - *

- * getFpol. - *

- * - * @return a double - */ - public double getFpol() { - double temp = 0.0; - for (int i = 1; i < OP; i++) { - temp += ((ComponentBWRS) componentArray[0]).getBP(i) / (i + 0.0) - * Math.pow(getMolarDensity(), i); - } - return numberOfMolesInPhase / (R * temperature) * temp; + return numberOfMolesInPhase / (R * temperature) * temp * Math.pow(getdRhodV(), 2) + + numberOfMolesInPhase / (R * temperature) * temp2 * getdRhodVdV(); + } + + /** + *

+ * getFpoldVdVdV. + *

+ * + * @return a double + */ + public double getFpoldVdVdV() { + double temp = 0.0; + double temp2 = 0.0; + // double temp3 = 0.0, temp4 = 0.0; + for (int i = 1; i < OP; i++) { + temp += (i - 2) * (i - 1) * (i) * ((ComponentBWRS) componentArray[0]).getBP(i) / (i - 0.0) + * Math.pow(getMolarDensity(), i - 3); + temp2 += (i - 1) * (i) * ((ComponentBWRS) componentArray[0]).getBP(i) / (i - 0.0) + * Math.pow(getMolarDensity(), i - 2); + // temp3 += (i) * ((ComponentBWRS) componentArray[0]).getBP(i) / (i - 0.0) * + // Math.pow(getMolarDensity(), i - 1); } - - /** - *

- * getFpoldV. - *

- * - * @return a double - */ - public double getFpoldV() { - double temp = 0.0; - for (int i = 1; i < OP; i++) { - temp += (i) * ((ComponentBWRS) componentArray[0]).getBP(i) / (i - 0.0) - * Math.pow(getMolarDensity(), i - 1.0) * getdRhodV(); - } - return numberOfMolesInPhase / (R * temperature) * temp; + return numberOfMolesInPhase / (R * temperature) * temp * Math.pow(getdRhodV(), 3) + + 2 * numberOfMolesInPhase / (R * temperature) * temp2 * Math.pow(getdRhodV(), 1) + * getdRhodVdV() + + numberOfMolesInPhase / (R * temperature) * temp2 * Math.pow(getdRhodV(), 1) + * getdRhodVdV() + + numberOfMolesInPhase / (R * temperature) * temp2 * getdRhodVdVdV(); + } + + /** + *

+ * getFpoldT. + *

+ * + * @return a double + */ + public double getFpoldT() { + double temp = 0.0; + double temp2 = 0.0; + for (int i = 1; i < OP; i++) { + temp += + ((ComponentBWRS) componentArray[0]).getBP(i) / (i + 0.0) * Math.pow(getMolarDensity(), i); + temp2 += ((ComponentBWRS) componentArray[0]).getBPdT(i) / (i + 0.0) + * Math.pow(getMolarDensity(), i); } - - /** - *

- * getFpoldVdV. - *

- * - * @return a double - */ - public double getFpoldVdV() { - double temp = 0.0, temp2 = 0.0; - for (int i = 1; i < OP; i++) { - temp += (i - 1) * (i) * ((ComponentBWRS) componentArray[0]).getBP(i) / (i - 0.0) - * Math.pow(getMolarDensity(), i - 2.0); - temp2 += (i) * ((ComponentBWRS) componentArray[0]).getBP(i) / (i - 0.0) - * Math.pow(getMolarDensity(), i - 1.0); - } - return numberOfMolesInPhase / (R * temperature) * temp * Math.pow(getdRhodV(), 2) - + numberOfMolesInPhase / (R * temperature) * temp2 * getdRhodVdV(); + return -numberOfMolesInPhase / (R * temperature * temperature) * temp + + numberOfMolesInPhase / (R * temperature) * temp2; + } + + /** + *

+ * getEL. + *

+ * + * @return a double + */ + public double getEL() { + return Math.exp( + -((ComponentBWRS) componentArray[0]).getGammaBWRS() * Math.pow(getMolarDensity(), 2.0)); + } + + /** + *

+ * getELdRho. + *

+ * + * @return a double + */ + public double getELdRho() { + return -2.0 * getMolarDensity() * ((ComponentBWRS) componentArray[0]).getGammaBWRS() * Math.exp( + -((ComponentBWRS) componentArray[0]).getGammaBWRS() * Math.pow(getMolarDensity(), 2.0)); + } + + /** + *

+ * getFexp. + *

+ * + * @return a double + */ + public double getFexp() { + double oldTemp = 0.0; + double temp = 0.0; + oldTemp = -((ComponentBWRS) componentArray[0]).getBE(0) + / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) * (getEL() - 1.0); + temp += oldTemp; + for (int i = 1; i < OE; i++) { + oldTemp = -((ComponentBWRS) componentArray[0]).getBE(i) + / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) + * (getEL() * Math.pow(getMolarDensity(), 2.0 * i) + - (2.0 * i) / ((ComponentBWRS) componentArray[0]).getBE(i - 1) * oldTemp); + temp += oldTemp; } - - /** - *

- * getFpoldVdVdV. - *

- * - * @return a double - */ - public double getFpoldVdVdV() { - double temp = 0.0, temp2 = 0.0; - // double temp3 = 0.0, temp4 = 0.0; - for (int i = 1; i < OP; i++) { - temp += (i - 2) * (i - 1) * (i) * ((ComponentBWRS) componentArray[0]).getBP(i) - / (i - 0.0) * Math.pow(getMolarDensity(), i - 3); - temp2 += (i - 1) * (i) * ((ComponentBWRS) componentArray[0]).getBP(i) / (i - 0.0) - * Math.pow(getMolarDensity(), i - 2); - // temp3 += (i) * ((ComponentBWRS) componentArray[0]).getBP(i) / (i - 0.0) * - // Math.pow(getMolarDensity(), i - 1); - } - return numberOfMolesInPhase / (R * temperature) * temp * Math.pow(getdRhodV(), 3) - + 2 * numberOfMolesInPhase / (R * temperature) * temp2 * Math.pow(getdRhodV(), 1) - * getdRhodVdV() - + numberOfMolesInPhase / (R * temperature) * temp2 * Math.pow(getdRhodV(), 1) - * getdRhodVdV() - + numberOfMolesInPhase / (R * temperature) * temp2 * getdRhodVdVdV(); + return numberOfMolesInPhase / (R * temperature) * temp; + } + + /** + *

+ * getFexpdV. + *

+ * + * @return a double + */ + public double getFexpdV() { + double oldTemp = 0.0; + double temp = 0.0; + oldTemp = -((ComponentBWRS) componentArray[0]).getBE(0) + / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) * getELdRho() * getdRhodV(); + + temp += oldTemp; + for (int i = 1; i < OE; i++) { + oldTemp = -((ComponentBWRS) componentArray[0]).getBE(i) + / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) + * Math.pow(getMolarDensity(), 2 * i) * getELdRho() * getdRhodV() + + - (2.0 * i) * ((ComponentBWRS) componentArray[0]).getBE(i) + / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) * getEL() + * Math.pow(getMolarDensity(), 2 * i - 1) * getdRhodV() + + + ((ComponentBWRS) componentArray[0]).getBE(i) + / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) * 2.0 * i + / ((ComponentBWRS) componentArray[0]).getBE(i - 1) * oldTemp; + + temp += oldTemp; } - /** - *

- * getFpoldT. - *

- * - * @return a double - */ - public double getFpoldT() { - double temp = 0.0, temp2 = 0.0; - for (int i = 1; i < OP; i++) { - temp += ((ComponentBWRS) componentArray[0]).getBP(i) / (i + 0.0) - * Math.pow(getMolarDensity(), i); - temp2 += ((ComponentBWRS) componentArray[0]).getBPdT(i) / (i + 0.0) - * Math.pow(getMolarDensity(), i); - } - return -numberOfMolesInPhase / (R * temperature * temperature) * temp - + numberOfMolesInPhase / (R * temperature) * temp2; + return numberOfMolesInPhase / (R * temperature) * temp; + } + + /** + *

+ * getFexpdVdV. + *

+ * + * @return a double + */ + public double getFexpdVdV() { + return 0.0; + } + + // public double getFexpdVdVdV(){ + // return 0.0;temp + // } + + /** + *

+ * getFexpdT. + *

+ * + * @return a double + */ + public double getFexpdT() { + double oldTemp = 0.0; + double temp = 0.0; + double oldTemp2 = 0; + oldTemp = -((ComponentBWRS) componentArray[0]).getBEdT(0) + / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) * (getEL() - 1.0); + oldTemp2 = -((ComponentBWRS) componentArray[0]).getBE(0) + / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) * (getEL() - 1.0); + temp += oldTemp; + for (int i = 1; i < OE; i++) { + oldTemp = -((ComponentBWRS) componentArray[0]).getBEdT(i) + / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) + * (getEL() * Math.pow(getMolarDensity(), 2.0 * i) + - (2.0 * i) / ((ComponentBWRS) componentArray[0]).getBE(i - 1) * oldTemp2) + + + + + -((ComponentBWRS) componentArray[0]).getBE(i) + / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) + * ((2.0 * i) / Math.pow(((ComponentBWRS) componentArray[0]).getBE(i - 1), 2.0) + * oldTemp2) + * ((ComponentBWRS) componentArray[0]).getBEdT(i - 1) + + + + + ((ComponentBWRS) componentArray[0]).getBE(i) + / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) + * ((2.0 * i) / ((ComponentBWRS) componentArray[0]).getBE(i - 1) * oldTemp); + + oldTemp2 = -((ComponentBWRS) componentArray[0]).getBE(i) + / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) + * (getEL() * Math.pow(getMolarDensity(), 2.0 * i) + - (2.0 * i) / ((ComponentBWRS) componentArray[0]).getBE(i - 1) * oldTemp2); + + temp += oldTemp; } - - /** - *

- * getEL. - *

- * - * @return a double - */ - public double getEL() { - return Math.exp(-((ComponentBWRS) componentArray[0]).getGammaBWRS() - * Math.pow(getMolarDensity(), 2.0)); + return -getFexp() / temperature + numberOfMolesInPhase / (R * temperature) * temp; + } + + /** + *

+ * calcPressure2. + *

+ * + * @return a double + */ + public double calcPressure2() { + // System.out.println("here............"); + double temp = 0.0; + logger.info("molar density " + getMolarDensity()); + for (int i = 0; i < OP; i++) { + temp += ((ComponentBWRS) componentArray[0]).getBP(i) * Math.pow(getMolarDensity(), 1.0 + i); } - - /** - *

- * getELdRho. - *

- * - * @return a double - */ - public double getELdRho() { - return -2.0 * getMolarDensity() * ((ComponentBWRS) componentArray[0]).getGammaBWRS() - * Math.exp(-((ComponentBWRS) componentArray[0]).getGammaBWRS() - * Math.pow(getMolarDensity(), 2.0)); + for (int i = 0; i < OE; i++) { + temp += getEL() * ((ComponentBWRS) componentArray[0]).getBE(i) + * Math.pow(getMolarDensity(), 3.0 + 2.0 * i); } - - /** - *

- * getFexp. - *

- * - * @return a double - */ - public double getFexp() { - double oldTemp = 0.0, temp = 0.0; - oldTemp = -((ComponentBWRS) componentArray[0]).getBE(0) - / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) * (getEL() - 1.0); - temp += oldTemp; - for (int i = 1; i < OE; i++) { - oldTemp = -((ComponentBWRS) componentArray[0]).getBE(i) - / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) - * (getEL() * Math.pow(getMolarDensity(), 2.0 * i) - (2.0 * i) - / ((ComponentBWRS) componentArray[0]).getBE(i - 1) * oldTemp); - temp += oldTemp; - } - return numberOfMolesInPhase / (R * temperature) * temp; + calcPVT(); + return temp / 100.0; + } + + /** + *

+ * calcPVT. + *

+ */ + public void calcPVT() { + double[] moldens = new double[300]; + double[] pres = new double[300]; + for (int j = 0; j < 300; j++) { + moldens[j] = 30 - j * 0.1; + double temp = 0.0; + for (int i = 0; i < OP; i++) { + temp += ((ComponentBWRS) componentArray[0]).getBP(i) * Math.pow(moldens[j], 1.0 + i); + } + for (int i = 0; i < OE; i++) { + temp += Math + .exp(-((ComponentBWRS) componentArray[0]).getGammaBWRS() * Math.pow(moldens[j], 2.0)) + * ((ComponentBWRS) componentArray[0]).getBE(i) * Math.pow(moldens[j], 3.0 + 2.0 * i); + } + pres[j] = temp / 100.0; + logger.info("moldens " + moldens[j] * 16.01 + " pres " + pres[j]); } - - /** - *

- * getFexpdV. - *

- * - * @return a double - */ - public double getFexpdV() { - double oldTemp = 0.0, temp = 0.0; - oldTemp = -((ComponentBWRS) componentArray[0]).getBE(0) - / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) * getELdRho() - * getdRhodV(); - - temp += oldTemp; - for (int i = 1; i < OE; i++) { - oldTemp = -((ComponentBWRS) componentArray[0]).getBE(i) - / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) - * Math.pow(getMolarDensity(), 2 * i) * getELdRho() * getdRhodV() - - - (2.0 * i) * ((ComponentBWRS) componentArray[0]).getBE(i) - / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) * getEL() - * Math.pow(getMolarDensity(), 2 * i - 1) * getdRhodV() - - + ((ComponentBWRS) componentArray[0]).getBE(i) - / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) * 2.0 * i - / ((ComponentBWRS) componentArray[0]).getBE(i - 1) * oldTemp; - - temp += oldTemp; - } - - return numberOfMolesInPhase / (R * temperature) * temp; + } + + /** {@inheritDoc} */ + @Override + public double getF() { + // System.out.println("F " + getFpol()*1e3+ " "+ getFexp()*1e3 + " super " + + // super.getF() + " phasetype " +getPhaseTypeName()); + return (getFpol() + getFexp()) * 1e3; + } + + /** + *

+ * getdFdN. + *

+ * + * @return a double + */ + public double getdFdN() { + double dn = numberOfMolesInPhase / 100.0; + getComponent(0).addMoles(dn); + numberOfMolesInPhase += dn; + + init(numberOfMolesInPhase, numberOfComponents, 3, phaseType, 1.0); + double fold = getF(); + numberOfMolesInPhase -= 2 * dn; + getComponent(0).addMoles(-2 * dn); + init(numberOfMolesInPhase, numberOfComponents, 3, phaseType, 1.0); + double fnew = getF(); + numberOfMolesInPhase += dn; + getComponent(0).addMoles(dn); + init(numberOfMolesInPhase, numberOfComponents, 3, phaseType, 1.0); + // System.out.println("F " + getFpol()*1e3+ " "+ getFexp()*1e3 + " super " + + // super.getF() + " phasetype " +getPhaseTypeName()); + return (fold - fnew) / (2 * dn); + } + + /** {@inheritDoc} */ + @Override + public double dFdT() { + // double dv = temperature/1000.0; + // temperature = temperature + dv; + // init(numberOfMolesInPhase, numberOfComponents, 3, phaseType, 1.0); + // double fold = getF(); + // temperature = temperature - 2*dv; + // init(numberOfMolesInPhase, numberOfComponents, 3, phaseType, 1.0); + // double fnew = getF(); + // temperature = temperature + dv; + // init(numberOfMolesInPhase, numberOfComponents, 3, phaseType, 1.0); + // System.out.println("dFdT " + ((fold-fnew)/(2*dv)) + " super " + + // (getFpoldT()+getFexpdT())*1e3+ " phasetype " +getPhaseTypeName()); + return (getFpoldT() + getFexpdT()) * 1e3; // (fold-fnew)/(2*dv); + + // // System.out.println("FT " + getFpoldT()*1e3+ " "+ getFexpdT()*1e3 + " super + // " + super.dFdT() + " phasetype " +getPhaseTypeName()); + // return (getFpoldT()+getFexpdT())*1e3; + } + + /** {@inheritDoc} */ + @Override + public double dFdTdT() { + double dv = temperature / 1000.0; + temperature += dv; + init(numberOfMolesInPhase, numberOfComponents, 3, phaseType, 1.0); + double fold = dFdT(); + temperature -= 2 * dv; + init(numberOfMolesInPhase, numberOfComponents, 3, phaseType, 1.0); + double fnew = dFdT(); + temperature += dv; + init(numberOfMolesInPhase, numberOfComponents, 3, phaseType, 1.0); + return (fold - fnew) / (2 * dv); + } + + /** {@inheritDoc} */ + @Override + public double dFdTdV() { + double dv = getMolarVolume() / 1000.0; + + setMolarVolume(getMolarVolume() + dv); + double fold = dFdT(); + setMolarVolume(getMolarVolume() - 2 * dv); + double fnew = dFdT(); + setMolarVolume(getMolarVolume() + dv); + + return (fold - fnew) / (2 * dv); + } + + /** {@inheritDoc} */ + @Override + public double dFdV() { + // double dv = molarVolume/1000.0; + + // molarVolume = molarVolume + dv; + // double fold = getF(); + // molarVolume = molarVolume - 2*dv; + // double fnew = getF(); + // molarVolume = molarVolume + dv; + + // System.out.println("dFdV " + ((fold-fnew)/(2*dv)) + " super " + super.dFdV()+ + // " phasetype " +getPhaseTypeName()); + // // return (fold-fnew)/(2*dv); + // System.out.println("dFdV " + ((getFpoldV()+getFexpdV()))*1e3*1e-5 + " super " + // + super.dFdV()+ " phasetype " +getPhaseTypeName()); + // System.out.println("dFdV " + getFpoldV()+getFexpdV()*1e3*1e-5); + return (getFpoldV() + getFexpdV()) * 1e3 * 1e-5; + } + + /** {@inheritDoc} */ + @Override + public double dFdVdV() { + double dv = getMolarVolume() / 1000.0; + + setMolarVolume(getMolarVolume() + dv); + double fold = dFdV(); + setMolarVolume(getMolarVolume() - 2 * dv); + double fnew = dFdV(); + setMolarVolume(getMolarVolume() + dv); + + // System.out.println("dFdV " + ((fold-fnew)/(2*dv)) + " super " + super.dFdV()+ + // " phasetype " +getPhaseTypeName()); + return (fold - fnew) / (2 * dv); + // return (getFpoldVdV()+getFexpdVdV())*1e3*1e-10; + } + + // public double dFdVdVdV(){ + // return getFpoldVdVdV(); + // } + + /** {@inheritDoc} */ + @Override + public double molarVolume2(double pressure, double temperature, double A, double B, int phase) + throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + double BonV = phase == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + double Btemp = getB(); + setMolarVolume(1.0 / BonV * Btemp); // numberOfMolesInPhase; + int iterations = 0; + int maxIterations = 10000; + double guesPres = pressure; + double guesPresdV = 0.0; + do { + iterations++; + guesPres = -R * temperature * dFdV() + R * temperature / getMolarVolume(); + guesPresdV = -R * temperature * dFdVdV() + - getNumberOfMolesInPhase() * R * temperature / Math.pow(getTotalVolume(), 2.0); + logger.info("gues pres " + guesPres); + setMolarVolume(getMolarVolume() + - 1.0 / (guesPresdV * getNumberOfMolesInPhase()) * (guesPres - pressure) / 50.0); + Z = pressure * getMolarVolume() / (R * temperature); + } while (Math.abs((guesPres - pressure) / pressure) > 1.0e-10 && iterations < maxIterations); + // System.out.println("gues pres " + guesPres); + if (iterations >= maxIterations) { + throw new neqsim.util.exception.TooManyIterationsException(this, "molarVolume2", + maxIterations); } - - /** - *

- * getFexpdVdV. - *

- * - * @return a double - */ - public double getFexpdVdV() { - return 0.0; + if (Double.isNaN(getMolarVolume())) { + throw new neqsim.util.exception.IsNaNException(this, "molarVolume2", "Molar Volume"); } + // System.out.println("Z: " + Z + " "+" itert: " +iterations); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " + // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + // + fVV()); - // public double getFexpdVdVdV(){ - // return 0.0;temp - // } - - /** - *

- * getFexpdT. - *

- * - * @return a double - */ - public double getFexpdT() { - double oldTemp = 0.0, temp = 0.0, oldTemp2 = 0; - oldTemp = -((ComponentBWRS) componentArray[0]).getBEdT(0) - / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) * (getEL() - 1.0); - oldTemp2 = -((ComponentBWRS) componentArray[0]).getBE(0) - / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) * (getEL() - 1.0); - temp += oldTemp; - for (int i = 1; i < OE; i++) { - oldTemp = -((ComponentBWRS) componentArray[0]).getBEdT(i) - / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) - * (getEL() * Math.pow(getMolarDensity(), 2.0 * i) - (2.0 * i) - / ((ComponentBWRS) componentArray[0]).getBE(i - 1) * oldTemp2) - - + - - -((ComponentBWRS) componentArray[0]).getBE(i) - / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) - * ((2.0 * i) / Math - .pow(((ComponentBWRS) componentArray[0]).getBE(i - 1), 2.0) - * oldTemp2) - * ((ComponentBWRS) componentArray[0]).getBEdT(i - 1) - - + - - ((ComponentBWRS) componentArray[0]).getBE(i) - / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) - * ((2.0 * i) / ((ComponentBWRS) componentArray[0]).getBE(i - 1) - * oldTemp); - - oldTemp2 = -((ComponentBWRS) componentArray[0]).getBE(i) - / (2.0 * ((ComponentBWRS) componentArray[0]).getGammaBWRS()) - * (getEL() * Math.pow(getMolarDensity(), 2.0 * i) - (2.0 * i) - / ((ComponentBWRS) componentArray[0]).getBE(i - 1) * oldTemp2); - - temp += oldTemp; - } - return -getFexp() / temperature + numberOfMolesInPhase / (R * temperature) * temp; - } - - /** - *

- * calcPressure2. - *

- * - * @return a double - */ - public double calcPressure2() { - // System.out.println("here............"); - double temp = 0.0; - logger.info("molar density " + getMolarDensity()); - for (int i = 0; i < OP; i++) { - temp += ((ComponentBWRS) componentArray[0]).getBP(i) - * Math.pow(getMolarDensity(), 1.0 + i); - } - for (int i = 0; i < OE; i++) { - temp += getEL() * ((ComponentBWRS) componentArray[0]).getBE(i) - * Math.pow(getMolarDensity(), 3.0 + 2.0 * i); - } - calcPVT(); - return temp / 100.0; - } - - /** - *

- * calcPVT. - *

- */ - public void calcPVT() { - double moldens[] = new double[300]; - double pres[] = new double[300]; - for (int j = 0; j < 300; j++) { - moldens[j] = 30 - j * 0.1; - double temp = 0.0; - for (int i = 0; i < OP; i++) { - temp += ((ComponentBWRS) componentArray[0]).getBP(i) - * Math.pow(moldens[j], 1.0 + i); - } - for (int i = 0; i < OE; i++) { - temp += Math - .exp(-((ComponentBWRS) componentArray[0]).getGammaBWRS() - * Math.pow(moldens[j], 2.0)) - * ((ComponentBWRS) componentArray[0]).getBE(i) - * Math.pow(moldens[j], 3.0 + 2.0 * i); - } - pres[j] = temp / 100.0; - logger.info("moldens " + moldens[j] * 16.01 + " pres " + pres[j]); - } - } - - /** {@inheritDoc} */ - @Override - public double getF() { - // System.out.println("F " + getFpol()*1e3+ " "+ getFexp()*1e3 + " super " + - // super.getF() + " phasetype " +getPhaseTypeName()); - return (getFpol() + getFexp()) * 1e3; - } - - /** - *

- * getdFdN. - *

- * - * @return a double - */ - public double getdFdN() { - double dn = numberOfMolesInPhase / 100.0; - getComponent(0).addMoles(dn); - numberOfMolesInPhase += dn; - - init(numberOfMolesInPhase, numberOfComponents, 3, phaseType, 1.0); - double fold = getF(); - numberOfMolesInPhase -= 2 * dn; - getComponent(0).addMoles(-2 * dn); - init(numberOfMolesInPhase, numberOfComponents, 3, phaseType, 1.0); - double fnew = getF(); - numberOfMolesInPhase += dn; - getComponent(0).addMoles(dn); - init(numberOfMolesInPhase, numberOfComponents, 3, phaseType, 1.0); - // System.out.println("F " + getFpol()*1e3+ " "+ getFexp()*1e3 + " super " + - // super.getF() + " phasetype " +getPhaseTypeName()); - return (fold - fnew) / (2 * dn); - } - - /** {@inheritDoc} */ - @Override - public double dFdT() { - // double dv = temperature/1000.0; - // temperature = temperature + dv; - // init(numberOfMolesInPhase, numberOfComponents, 3, phaseType, 1.0); - // double fold = getF(); - // temperature = temperature - 2*dv; - // init(numberOfMolesInPhase, numberOfComponents, 3, phaseType, 1.0); - // double fnew = getF(); - // temperature = temperature + dv; - // init(numberOfMolesInPhase, numberOfComponents, 3, phaseType, 1.0); - // System.out.println("dFdT " + ((fold-fnew)/(2*dv)) + " super " + - // (getFpoldT()+getFexpdT())*1e3+ " phasetype " +getPhaseTypeName()); - return (getFpoldT() + getFexpdT()) * 1e3;// (fold-fnew)/(2*dv); - - // // System.out.println("FT " + getFpoldT()*1e3+ " "+ getFexpdT()*1e3 + " super - // " + super.dFdT() + " phasetype " +getPhaseTypeName()); - // return (getFpoldT()+getFexpdT())*1e3; - } - - /** {@inheritDoc} */ - @Override - public double dFdTdT() { - double dv = temperature / 1000.0; - temperature += dv; - init(numberOfMolesInPhase, numberOfComponents, 3, phaseType, 1.0); - double fold = dFdT(); - temperature -= 2 * dv; - init(numberOfMolesInPhase, numberOfComponents, 3, phaseType, 1.0); - double fnew = dFdT(); - temperature += dv; - init(numberOfMolesInPhase, numberOfComponents, 3, phaseType, 1.0); - return (fold - fnew) / (2 * dv); - } - - /** {@inheritDoc} */ - @Override - public double dFdTdV() { - double dv = getMolarVolume() / 1000.0; - - setMolarVolume(getMolarVolume() + dv); - double fold = dFdT(); - setMolarVolume(getMolarVolume() - 2 * dv); - double fnew = dFdT(); - setMolarVolume(getMolarVolume() + dv); - - return (fold - fnew) / (2 * dv); - } - - /** {@inheritDoc} */ - @Override - public double dFdV() { - // double dv = molarVolume/1000.0; - - // molarVolume = molarVolume + dv; - // double fold = getF(); - // molarVolume = molarVolume - 2*dv; - // double fnew = getF(); - // molarVolume = molarVolume + dv; - - // System.out.println("dFdV " + ((fold-fnew)/(2*dv)) + " super " + super.dFdV()+ - // " phasetype " +getPhaseTypeName()); - // // return (fold-fnew)/(2*dv); - // System.out.println("dFdV " + ((getFpoldV()+getFexpdV()))*1e3*1e-5 + " super " - // + super.dFdV()+ " phasetype " +getPhaseTypeName()); - // System.out.println("dFdV " + getFpoldV()+getFexpdV()*1e3*1e-5); - return (getFpoldV() + getFexpdV()) * 1e3 * 1e-5; - } - - /** {@inheritDoc} */ - @Override - public double dFdVdV() { - double dv = getMolarVolume() / 1000.0; - - setMolarVolume(getMolarVolume() + dv); - double fold = dFdV(); - setMolarVolume(getMolarVolume() - 2 * dv); - double fnew = dFdV(); - setMolarVolume(getMolarVolume() + dv); - - // System.out.println("dFdV " + ((fold-fnew)/(2*dv)) + " super " + super.dFdV()+ - // " phasetype " +getPhaseTypeName()); - return (fold - fnew) / (2 * dv); - // return (getFpoldVdV()+getFexpdVdV())*1e3*1e-10; - } - - // public double dFdVdVdV(){ - // return getFpoldVdVdV(); - // } - - /** {@inheritDoc} */ - @Override - public double molarVolume2(double pressure, double temperature, double A, double B, int phase) - throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - double BonV = phase == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - double Btemp = getB(); - setMolarVolume(1.0 / BonV * Btemp);// numberOfMolesInPhase; - int iterations = 0; - int maxIterations = 10000; - double guesPres = pressure; - double guesPresdV = 0.0; - do { - iterations++; - guesPres = -R * temperature * dFdV() + R * temperature / getMolarVolume(); - guesPresdV = -R * temperature * dFdVdV() - - getNumberOfMolesInPhase() * R * temperature / Math.pow(getTotalVolume(), 2.0); - logger.info("gues pres " + guesPres); - setMolarVolume(getMolarVolume() - 1.0 / (guesPresdV * getNumberOfMolesInPhase()) - * (guesPres - pressure) / 50.0); - Z = pressure * getMolarVolume() / (R * temperature); - } while (Math.abs((guesPres - pressure) / pressure) > 1.0e-10 - && iterations < maxIterations); - // System.out.println("gues pres " + guesPres); - if (iterations >= maxIterations) { - throw new neqsim.util.exception.TooManyIterationsException(this, "molarVolume2", - maxIterations); - } - if (Double.isNaN(getMolarVolume())) { - throw new neqsim.util.exception.IsNaNException(this, "molarVolume2", "Molar Volume"); - } - // System.out.println("Z: " + Z + " "+" itert: " +iterations); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " - // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" - // + fVV()); - - return getMolarVolume(); - } + return getMolarVolume(); + } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseDefault.java b/src/main/java/neqsim/thermo/phase/PhaseDefault.java index ec0ab30008..7206e8145e 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseDefault.java +++ b/src/main/java/neqsim/thermo/phase/PhaseDefault.java @@ -90,7 +90,7 @@ public double getGibbsEnergy() { double val = 0.0; for (int i = 0; i < numberOfComponents; i++) { val += getComponent(i).getNumberOfMolesInPhase() - * (getComponent(i).getLogFugacityCoefficient());// +Math.log(getComponent(i).getx()*getComponent(i).getAntoineVaporPressure(temperature))); + * (getComponent(i).getLogFugacityCoefficient()); // +Math.log(getComponent(i).getx()*getComponent(i).getAntoineVaporPressure(temperature))); } return R * temperature * ((val) + Math.log(pressure) * numberOfMolesInPhase); } diff --git a/src/main/java/neqsim/thermo/phase/PhaseDesmukhMather.java b/src/main/java/neqsim/thermo/phase/PhaseDesmukhMather.java index 4dbe031ddb..30a0929a96 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseDesmukhMather.java +++ b/src/main/java/neqsim/thermo/phase/PhaseDesmukhMather.java @@ -14,261 +14,258 @@ * @version $Id: $Id */ public class PhaseDesmukhMather extends PhaseGE { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - double GE = 0.0; - double[][] aij; - double[][] bij; + double GE = 0.0; + double[][] aij; + double[][] bij; - static Logger logger = LogManager.getLogger(PhaseDesmukhMather.class); + static Logger logger = LogManager.getLogger(PhaseDesmukhMather.class); - /** - *

- * Constructor for PhaseDesmukhMather. - *

- */ - public PhaseDesmukhMather() { - super(); - } + /** + *

+ * Constructor for PhaseDesmukhMather. + *

+ */ + public PhaseDesmukhMather() { + super(); + } - /** {@inheritDoc} */ - @Override - public void addcomponent(String componentName, double moles, double molesInPhase, - int compNumber) { - super.addcomponent(molesInPhase); - componentArray[compNumber] = - new ComponentDesmukhMather(componentName, moles, molesInPhase, compNumber); - } + /** {@inheritDoc} */ + @Override + public void addcomponent(String componentName, double moles, double molesInPhase, + int compNumber) { + super.addcomponent(molesInPhase); + componentArray[compNumber] = + new ComponentDesmukhMather(componentName, moles, molesInPhase, compNumber); + } - /** {@inheritDoc} */ - @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int initType, int phase, - double beta) { - super.init(totalNumberOfMoles, numberOfComponents, initType, phase, beta); - if (initType != 0) { - phaseTypeName = phase == 0 ? "liquid" : "gas"; - } - setMolarVolume(0.980e-3 * getMolarMass() * 1e5); - Z = pressure * getMolarVolume() / (R * temperature); + /** {@inheritDoc} */ + @Override + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, int phase, + double beta) { + super.init(totalNumberOfMoles, numberOfComponents, initType, phase, beta); + if (initType != 0) { + phaseTypeName = phase == 0 ? "liquid" : "gas"; } + setMolarVolume(0.980e-3 * getMolarMass() * 1e5); + Z = pressure * getMolarVolume() / (R * temperature); + } - /** {@inheritDoc} */ - @Override - public void setMixingRule(int type) { - super.setMixingRule(type); - this.aij = new double[numberOfComponents][numberOfComponents]; - this.bij = new double[numberOfComponents][numberOfComponents]; - neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); - for (int k = 0; k < getNumberOfComponents(); k++) { - String component_name = getComponents()[k].getComponentName(); + /** {@inheritDoc} */ + @Override + public void setMixingRule(int type) { + super.setMixingRule(type); + this.aij = new double[numberOfComponents][numberOfComponents]; + this.bij = new double[numberOfComponents][numberOfComponents]; + neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); + for (int k = 0; k < getNumberOfComponents(); k++) { + String component_name = getComponents()[k].getComponentName(); - for (int l = k; l < getNumberOfComponents(); l++) { - try { - if (k == l) { - if (getComponents()[l].getComponentName().equals("MDEA") - && getComponents()[k].getComponentName().equals("MDEA")) { - aij[k][l] = -0.0828487; - this.aij[l][k] = this.aij[k][l]; - } - } else { - // int templ = l, tempk = k; - // database = new util.database.NeqSimDataBase(); - java.sql.ResultSet dataSet = database - .getResultSet("SELECT * FROM inter WHERE (comp1='" + component_name - + "' AND comp2='" + getComponents()[l].getComponentName() - + "') OR (comp1='" + getComponents()[l].getComponentName() - + "' AND comp2='" + component_name + "')"); - dataSet.next(); - - if (dataSet.getString("comp1").trim() - .equals(getComponents()[l].getComponentName())) { - // templ = k; - // tempk = l; - } - this.aij[k][l] = Double.parseDouble(dataSet.getString("aijDesMath")); - this.bij[k][l] = Double.parseDouble(dataSet.getString("bijDesMath")); - this.aij[l][k] = this.aij[k][l]; - this.bij[l][k] = this.bij[k][l]; + for (int l = k; l < getNumberOfComponents(); l++) { + try { + if (k == l) { + if (getComponents()[l].getComponentName().equals("MDEA") + && getComponents()[k].getComponentName().equals("MDEA")) { + aij[k][l] = -0.0828487; + this.aij[l][k] = this.aij[k][l]; + } + } else { + // int templ = l, tempk = k; + // database = new util.database.NeqSimDataBase(); + java.sql.ResultSet dataSet = database.getResultSet("SELECT * FROM inter WHERE (comp1='" + + component_name + "' AND comp2='" + getComponents()[l].getComponentName() + + "') OR (comp1='" + getComponents()[l].getComponentName() + "' AND comp2='" + + component_name + "')"); + dataSet.next(); - // System.out.println("aij " + this.aij[l][k]); - dataSet.close(); - // database.getConnection().close(); - } - } catch (Exception e) { - String err = e.toString(); - logger.info("comp names " + component_name); - logger.error(err); - } + if (dataSet.getString("comp1").trim().equals(getComponents()[l].getComponentName())) { + // templ = k; + // tempk = l; } - } - } + this.aij[k][l] = Double.parseDouble(dataSet.getString("aijDesMath")); + this.bij[k][l] = Double.parseDouble(dataSet.getString("bijDesMath")); + this.aij[l][k] = this.aij[k][l]; + this.bij[l][k] = this.bij[k][l]; - /** - *

- * Setter for the field aij. - *

- * - * @param alpha an array of {@link double} objects - */ - public void setAij(double[][] alpha) { - for (int i = 0; i < alpha.length; i++) { - System.arraycopy(aij[i], 0, this.aij[i], 0, alpha[0].length); + // System.out.println("aij " + this.aij[l][k]); + dataSet.close(); + // database.getConnection().close(); + } + } catch (Exception e) { + String err = e.toString(); + logger.info("comp names " + component_name); + logger.error(err); } + } } + } - /** - *

- * Setter for the field bij. - *

- * - * @param Dij an array of {@link double} objects - */ - public void setBij(double[][] Dij) { - for (int i = 0; i < Dij.length; i++) { - System.arraycopy(bij[i], 0, this.bij[i], 0, Dij[0].length); - } + /** + *

+ * Setter for the field aij. + *

+ * + * @param alpha an array of {@link double} objects + */ + public void setAij(double[][] alpha) { + for (int i = 0; i < alpha.length; i++) { + System.arraycopy(aij[i], 0, this.aij[i], 0, alpha[0].length); } + } - /** - *

- * getBetaDesMatij. - *

- * - * @param i a int - * @param j a int - * @return a double - */ - public double getBetaDesMatij(int i, int j) { - return aij[i][j] + bij[i][j] * temperature; + /** + *

+ * Setter for the field bij. + *

+ * + * @param Dij an array of {@link double} objects + */ + public void setBij(double[][] Dij) { + for (int i = 0; i < Dij.length; i++) { + System.arraycopy(bij[i], 0, this.bij[i], 0, Dij[0].length); } + } - /** - *

- * Getter for the field aij. - *

- * - * @param i a int - * @param j a int - * @return a double - */ - public double getAij(int i, int j) { - return aij[i][j]; - } + /** + *

+ * getBetaDesMatij. + *

+ * + * @param i a int + * @param j a int + * @return a double + */ + public double getBetaDesMatij(int i, int j) { + return aij[i][j] + bij[i][j] * temperature; + } - /** - *

- * Getter for the field bij. - *

- * - * @param i a int - * @param j a int - * @return a double - */ - public double getBij(int i, int j) { - return bij[i][j]; - } + /** + *

+ * Getter for the field aij. + *

+ * + * @param i a int + * @param j a int + * @return a double + */ + public double getAij(int i, int j) { + return aij[i][j]; + } - /** {@inheritDoc} */ - @Override - public double getExessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { - GE = 0; - for (int i = 0; i < numberOfComponents; i++) { - GE += phase.getComponents()[i].getx() - * Math.log(((ComponentDesmukhMather) componentArray[i]).getGamma(phase, - numberOfComponents, temperature, pressure, phasetype)); - } - // System.out.println("ge " + GE); - return R * temperature * numberOfMolesInPhase * GE;// phase.getNumberOfMolesInPhase()* - } + /** + *

+ * Getter for the field bij. + *

+ * + * @param i a int + * @param j a int + * @return a double + */ + public double getBij(int i, int j) { + return bij[i][j]; + } - /** {@inheritDoc} */ - @Override - public double getGibbsEnergy() { - return R * temperature * numberOfMolesInPhase * (GE + Math.log(pressure)); + /** {@inheritDoc} */ + @Override + public double getExessGibbsEnergy(PhaseInterface phase, int numberOfComponents, + double temperature, double pressure, int phasetype) { + GE = 0; + for (int i = 0; i < numberOfComponents; i++) { + GE += phase.getComponents()[i].getx() * Math.log(((ComponentDesmukhMather) componentArray[i]) + .getGamma(phase, numberOfComponents, temperature, pressure, phasetype)); } + // System.out.println("ge " + GE); + return R * temperature * numberOfMolesInPhase * GE; // phase.getNumberOfMolesInPhase()* + } - /** {@inheritDoc} */ - @Override - public double getExessGibbsEnergy() { - // double GE = getExessGibbsEnergy(this, numberOfComponents, temperature, - // pressure, phaseType); - return GE; - } + /** {@inheritDoc} */ + @Override + public double getGibbsEnergy() { + return R * temperature * numberOfMolesInPhase * (GE + Math.log(pressure)); + } - /** {@inheritDoc} */ - @Override - public double getActivityCoefficient(int k, int p) { - return ((ComponentGEInterface) getComponent(k)).getGamma(); - } + /** {@inheritDoc} */ + @Override + public double getExessGibbsEnergy() { + // double GE = getExessGibbsEnergy(this, numberOfComponents, temperature, + // pressure, phaseType); + return GE; + } - /** {@inheritDoc} */ - @Override - public double getActivityCoefficient(int k) { - return ((ComponentGEInterface) getComponent(k)).getGamma(); - } + /** {@inheritDoc} */ + @Override + public double getActivityCoefficient(int k, int p) { + return ((ComponentGEInterface) getComponent(k)).getGamma(); + } - /** - *

- * getIonicStrength. - *

- * - * @return a double - */ - public double getIonicStrength() { - double ionStrength = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - ionStrength += getComponent(i).getMolality(this) - * Math.pow(getComponent(i).getIonicCharge(), 2.0); - // getComponent(i).getMolarity(this)*Math.pow(getComponent(i).getIonicCharge(),2.0); - } - return 0.5 * ionStrength; - } + /** {@inheritDoc} */ + @Override + public double getActivityCoefficient(int k) { + return ((ComponentGEInterface) getComponent(k)).getGamma(); + } - /** - *

- * getSolventWeight. - *

- * - * @return a double - */ - public double getSolventWeight() { - double moles = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - if (getComponent(i).getReferenceStateType().equals("solvent")) { - moles += getComponent(i).getNumberOfMolesInPhase() * getComponent(i).getMolarMass(); - } - } - return moles; + /** + *

+ * getIonicStrength. + *

+ * + * @return a double + */ + public double getIonicStrength() { + double ionStrength = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + ionStrength += + getComponent(i).getMolality(this) * Math.pow(getComponent(i).getIonicCharge(), 2.0); + // getComponent(i).getMolarity(this)*Math.pow(getComponent(i).getIonicCharge(),2.0); } + return 0.5 * ionStrength; + } - /** - *

- * getSolventDensity. - *

- * - * @return a double - */ - public double getSolventDensity() { - return 1020.0; + /** + *

+ * getSolventWeight. + *

+ * + * @return a double + */ + public double getSolventWeight() { + double moles = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + if (getComponent(i).getReferenceStateType().equals("solvent")) { + moles += getComponent(i).getNumberOfMolesInPhase() * getComponent(i).getMolarMass(); + } } + return moles; + } - /** - *

- * getSolventMolarMass. - *

- * - * @return a double - */ - public double getSolventMolarMass() { - double molesMass = 0.0, moles = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - if (getComponent(i).getReferenceStateType().equals("solvent")) { - molesMass += - getComponent(i).getNumberOfMolesInPhase() * getComponent(i).getMolarMass(); - moles = getComponent(i).getNumberOfMolesInPhase(); - } - } - return molesMass / moles; + /** + *

+ * getSolventDensity. + *

+ * + * @return a double + */ + public double getSolventDensity() { + return 1020.0; + } + + /** + *

+ * getSolventMolarMass. + *

+ * + * @return a double + */ + public double getSolventMolarMass() { + double molesMass = 0.0; + double moles = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + if (getComponent(i).getReferenceStateType().equals("solvent")) { + molesMass += getComponent(i).getNumberOfMolesInPhase() * getComponent(i).getMolarMass(); + moles = getComponent(i).getNumberOfMolesInPhase(); + } } + return molesMass / moles; + } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseDuanSun.java b/src/main/java/neqsim/thermo/phase/PhaseDuanSun.java index 17e1412bb2..38de88c6d5 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseDuanSun.java +++ b/src/main/java/neqsim/thermo/phase/PhaseDuanSun.java @@ -11,107 +11,106 @@ * @version $Id: $Id */ public class PhaseDuanSun extends PhaseGE { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - double[][] alpha; - String[][] mixRule; - double[][] intparam; - double[][] Dij; - double GE = 0.0; + double[][] alpha; + String[][] mixRule; + double[][] intparam; + double[][] Dij; + double GE = 0.0; - /** - *

- * Constructor for PhaseDuanSun. - *

- */ - public PhaseDuanSun() { - super(); - } + /** + *

+ * Constructor for PhaseDuanSun. + *

+ */ + public PhaseDuanSun() { + super(); + } - /** {@inheritDoc} */ - @Override - public void addcomponent(String componentName, double moles, double molesInPhase, - int compNumber) { - super.addcomponent(molesInPhase); - componentArray[compNumber] = - new ComponentGeDuanSun(componentName, moles, molesInPhase, compNumber); - } + /** {@inheritDoc} */ + @Override + public void addcomponent(String componentName, double moles, double molesInPhase, + int compNumber) { + super.addcomponent(molesInPhase); + componentArray[compNumber] = + new ComponentGeDuanSun(componentName, moles, molesInPhase, compNumber); + } - /** {@inheritDoc} */ - @Override - public void setMixingRule(int type) { - super.setMixingRule(type); - this.alpha = mixSelect.getNRTLalpha(); - this.Dij = mixSelect.getNRTLDij(); - } + /** {@inheritDoc} */ + @Override + public void setMixingRule(int type) { + super.setMixingRule(type); + this.alpha = mixSelect.getNRTLalpha(); + this.Dij = mixSelect.getNRTLDij(); + } - /** {@inheritDoc} */ - @Override - public void setAlpha(double[][] alpha) { - for (int i = 0; i < alpha.length; i++) { - System.arraycopy(alpha[i], 0, this.alpha[i], 0, alpha[0].length); - } + /** {@inheritDoc} */ + @Override + public void setAlpha(double[][] alpha) { + for (int i = 0; i < alpha.length; i++) { + System.arraycopy(alpha[i], 0, this.alpha[i], 0, alpha[0].length); } + } - /** {@inheritDoc} */ - @Override - public void setDij(double[][] Dij) { - for (int i = 0; i < Dij.length; i++) { - System.arraycopy(Dij[i], 0, this.Dij[i], 0, Dij[0].length); - } + /** {@inheritDoc} */ + @Override + public void setDij(double[][] Dij) { + for (int i = 0; i < Dij.length; i++) { + System.arraycopy(Dij[i], 0, this.Dij[i], 0, Dij[0].length); } + } - /** {@inheritDoc} */ - @Override - public double getExessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { - GE = 0; - double salinity = 0.0; - // double k=0.0; - // salinity=salinity+phase.getComponent("Na+").getNumberOfMolesInPhase()/(phase.getComponent("water").getNumberOfmoles()*phase.getComponent("water").getMolarMass()); - - // for (int i=2;i=100) throw new util.exception.TooManyIterationsException(); // System.out.println("error in volume " + - // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " + // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV())); // + " // firstterm " + (R*temperature/molarVolume) + " second " + // R*temperature*dFdV()); @@ -1146,7 +1146,7 @@ public double molarVolume(double pressure, double temperature, double A, double // getMolarVolume()); // if(iterations>=100) throw new util.exception.TooManyIterationsException(); // System.out.println("error in volume " + - // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " + // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV())); // + " // firstterm " + (R*temperature/molarVolume) + " second " + // R*temperature*dFdV()); // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + " B @@ -1288,7 +1288,7 @@ public double molarVolumeChangePhase(double pressure, double temperature, double // getMolarVolume()); // if(iterations>=100) throw new util.exception.TooManyIterationsException(); // System.out.println("error in volume " + - // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " + // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV())); // + " // firstterm " + (R*temperature/molarVolume) + " second " + // R*temperature*dFdV()); // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + " B diff --git a/src/main/java/neqsim/thermo/phase/PhaseElectrolyteCPAOld.java b/src/main/java/neqsim/thermo/phase/PhaseElectrolyteCPAOld.java index e8378dc829..ca1a11ca87 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseElectrolyteCPAOld.java +++ b/src/main/java/neqsim/thermo/phase/PhaseElectrolyteCPAOld.java @@ -17,804 +17,823 @@ * @version $Id: $Id */ public class PhaseElectrolyteCPAOld extends PhaseModifiedFurstElectrolyteEos - implements PhaseCPAInterface { - private static final long serialVersionUID = 1000; - - public CPAMixing cpaSelect = new CPAMixing(); - - int totalNumberOfAccociationSites = 0; - public CPAMixingInterface cpamix; - double hcpatot = 1.0, hcpatotdT = 0.0, hcpatotdTdT = 0.0, gcpav = 0.0, lngcpa = 0.0, - lngcpav = 0.0, gcpavv = 1.0, gcpavvv = 0.0, gcpa = 0.0; - int cpaon = 1; - int[][][] selfAccociationScheme = null; - int[][][][] crossAccociationScheme = null; - double dFdVdXdXdVtotal = 0.0; - double dFCPAdXdXdTtotal = 0.0, dFCPAdTdT = 0.0; - - static Logger logger = LogManager.getLogger(PhaseElectrolyteCPAOld.class); - - /** - *

- * Constructor for PhaseElectrolyteCPAOld. - *

- */ - public PhaseElectrolyteCPAOld() { - super(); - } + implements PhaseCPAInterface { + private static final long serialVersionUID = 1000; - /** {@inheritDoc} */ - @Override - public PhaseElectrolyteCPAOld clone() { - PhaseElectrolyteCPAOld clonedPhase = null; - try { - clonedPhase = (PhaseElectrolyteCPAOld) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } - // clonedPhase.cpaSelect = (CPAMixing) cpaSelect.clone(); + public CPAMixing cpaSelect = new CPAMixing(); - return clonedPhase; - } + int totalNumberOfAccociationSites = 0; + public CPAMixingInterface cpamix; + double hcpatot = 1.0; - /** {@inheritDoc} */ - @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, - double beta) { - if (type == 0) { - selfAccociationScheme = new int[numberOfComponents][0][0]; - crossAccociationScheme = new int[numberOfComponents][numberOfComponents][0][0]; - for (int i = 0; i < numberOfComponents; i++) { - selfAccociationScheme[i] = cpaSelect.setAssociationScheme(i, this); - for (int j = 0; j < numberOfComponents; j++) { - crossAccociationScheme[i][j] = cpaSelect.setCrossAssociationScheme(i, j, this); - } - } - } - do { - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - } while (!solveX()); - - // System.out.println("test1 " + dFCPAdT()); - if (type > 1) { - // calcXsitedT(); - // System.out.println("test2 " + dFCPAdT()); - hcpatotdT = calc_hCPAdT(); - hcpatotdTdT = calc_hCPAdTdT(); - } + double hcpatotdT = 0.0; - // System.out.println("tot iter " + totiter); - } + double hcpatotdTdT = 0.0; - /** {@inheritDoc} */ - @Override - public void setMixingRule(int type) { - super.setMixingRule(type); - cpamix = cpaSelect.getMixingRule(1, this); - } + double gcpav = 0.0; - /** {@inheritDoc} */ - @Override - public void addcomponent(String componentName, double moles, double molesInPhase, - int compNumber) { - super.addcomponent(componentName, moles, molesInPhase, compNumber); - componentArray[compNumber] = - new ComponentElectrolyteCPA(componentName, moles, molesInPhase, compNumber); - } + double lngcpa = 0.0; - /** {@inheritDoc} */ - @Override - public double getF() { - return super.getF() + cpaon * FCPA(); - } + double lngcpav = 0.0; - /** {@inheritDoc} */ - @Override - public double dFdT() { - return super.dFdT() + cpaon * dFCPAdT(); - } + double gcpavv = 1.0; - /** {@inheritDoc} */ - @Override - public double dFdTdV() { - return super.dFdTdV(); - } + double gcpavvv = 0.0; - /** {@inheritDoc} */ - @Override - public double dFdV() { - // double dv = super.dFdV(); - double dv2 = dFCPAdV(); - // System.out.println("dv " + dv + " dvcpa " + dv2); - return super.dFdV() + cpaon * dv2; - } + double gcpa = 0.0; - /** {@inheritDoc} */ - @Override - public double dFdVdV() { - return super.dFdVdV() + cpaon * dFCPAdVdV(); - } + int cpaon = 1; + int[][][] selfAccociationScheme = null; + int[][][][] crossAccociationScheme = null; + double dFdVdXdXdVtotal = 0.0; + double dFCPAdXdXdTtotal = 0.0; - /** {@inheritDoc} */ - @Override - public double dFdVdVdV() { - return super.dFdVdVdV() + cpaon * dFCPAdVdVdV(); - } - - /** {@inheritDoc} */ - @Override - public double dFdTdT() { - return super.dFdTdT() + cpaon * dFCPAdTdT(); - } + double dFCPAdTdT = 0.0; - /** - *

- * FCPA. - *

- * - * @return a double - */ - public double FCPA() { - double tot = 0.0; - double ans = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - tot = 0.0; - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - double xai = ((ComponentElectrolyteCPA) getComponent(i)).getXsite()[j]; - tot += (Math.log(xai) - 1.0 / 2.0 * xai + 1.0 / 2.0); - } - ans += getComponent(i).getNumberOfMolesInPhase() * tot; - } - return ans; - } + static Logger logger = LogManager.getLogger(PhaseElectrolyteCPAOld.class); - /** - *

- * dFCPAdV. - *

- * - * @return a double - */ - public double dFCPAdV() { - return 1.0 / (2.0 * getTotalVolume()) * (1.0 - getTotalVolume() * getGcpav()) * hcpatot; - } + /** + *

+ * Constructor for PhaseElectrolyteCPAOld. + *

+ */ + public PhaseElectrolyteCPAOld() { + super(); + } - /** - *

- * dFCPAdVdV. - *

- * - * @return a double - */ - public double dFCPAdVdV() { - return -1.0 / getTotalVolume() * dFCPAdV() - + hcpatot / (2.0 * getTotalVolume()) * (-getGcpav() - getTotalVolume() * gcpavv) - + getdFdVdXdXdVtotal(); + /** {@inheritDoc} */ + @Override + public PhaseElectrolyteCPAOld clone() { + PhaseElectrolyteCPAOld clonedPhase = null; + try { + clonedPhase = (PhaseElectrolyteCPAOld) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); } + // clonedPhase.cpaSelect = (CPAMixing) cpaSelect.clone(); - /** - *

- * dFCPAdVdVdV. - *

- * - * @return a double - */ - public double dFCPAdVdVdV() { - return -1.0 / getTotalVolume() * dFCPAdVdV() - + 1.0 / Math.pow(getTotalVolume(), 2.0) * dFCPAdV() - - hcpatot / (2.0 * Math.pow(getTotalVolume(), 2.0)) - * (-getGcpav() - getTotalVolume() * gcpavv) - + hcpatot / (2.0 * getTotalVolume()) - * (-gcpavv - getTotalVolume() * gcpavvv - gcpavv); - } + return clonedPhase; + } - /** - *

- * dFCPAdT. - *

- * - * @return a double - */ - public double dFCPAdT() { - // System.out.println("dFCPAdXdXdTtotal " + dFCPAdXdXdTtotal); - return dFCPAdXdXdTtotal; - // -1.0 / 2.0 * hcpatotdT; - } - - /** - *

- * dFCPAdTdT. - *

- * - * @return a double - */ - public double dFCPAdTdT() { - return dFCPAdTdT;// -1.0 / 2.0 * hcpatotdTdT; - } - - /** - *

- * calc_hCPA. - *

- * - * @return a double - */ - public double calc_hCPA() { - double htot = 0.0; - double tot = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - htot = 0.0; - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - htot += (1.0 - ((ComponentElectrolyteCPA) getComponent(i)).getXsite()[j]); - } - tot += getComponent(i).getNumberOfMolesInPhase() * htot; + /** {@inheritDoc} */ + @Override + public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, + double beta) { + if (type == 0) { + selfAccociationScheme = new int[numberOfComponents][0][0]; + crossAccociationScheme = new int[numberOfComponents][numberOfComponents][0][0]; + for (int i = 0; i < numberOfComponents; i++) { + selfAccociationScheme[i] = cpaSelect.setAssociationScheme(i, this); + for (int j = 0; j < numberOfComponents; j++) { + crossAccociationScheme[i][j] = cpaSelect.setCrossAssociationScheme(i, j, this); } - // System.out.println("tot " +tot ); - return tot; - } - - /** - *

- * calc_hCPAdT. - *

- * - * @return a double - */ - public double calc_hCPAdT() { - double htot = 0.0; - double tot = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - for (int k = 0; k < numberOfComponents; k++) { - htot = 0.0; - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - for (int l = 0; l < getComponent(k).getNumberOfAssociationSites(); l++) { - htot += ((ComponentElectrolyteCPA) getComponent(i)).getXsite()[j] - * ((ComponentElectrolyteCPA) getComponent(k)).getXsite()[l] - * cpamix.calcDeltadT(j, l, i, k, this, temperature, pressure, - numberOfComponents); - } - } - - tot += getComponent(i).getNumberOfMolesInPhase() - * getComponent(k).getNumberOfMolesInPhase() * htot; - } + } + } + do { + super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + } while (!solveX()); + + // System.out.println("test1 " + dFCPAdT()); + if (type > 1) { + // calcXsitedT(); + // System.out.println("test2 " + dFCPAdT()); + hcpatotdT = calc_hCPAdT(); + hcpatotdTdT = calc_hCPAdTdT(); + } + + // System.out.println("tot iter " + totiter); + } + + /** {@inheritDoc} */ + @Override + public void setMixingRule(int type) { + super.setMixingRule(type); + cpamix = cpaSelect.getMixingRule(1, this); + } + + /** {@inheritDoc} */ + @Override + public void addcomponent(String componentName, double moles, double molesInPhase, + int compNumber) { + super.addcomponent(componentName, moles, molesInPhase, compNumber); + componentArray[compNumber] = + new ComponentElectrolyteCPA(componentName, moles, molesInPhase, compNumber); + } + + /** {@inheritDoc} */ + @Override + public double getF() { + return super.getF() + cpaon * FCPA(); + } + + /** {@inheritDoc} */ + @Override + public double dFdT() { + return super.dFdT() + cpaon * dFCPAdT(); + } + + /** {@inheritDoc} */ + @Override + public double dFdTdV() { + return super.dFdTdV(); + } + + /** {@inheritDoc} */ + @Override + public double dFdV() { + // double dv = super.dFdV(); + double dv2 = dFCPAdV(); + // System.out.println("dv " + dv + " dvcpa " + dv2); + return super.dFdV() + cpaon * dv2; + } + + /** {@inheritDoc} */ + @Override + public double dFdVdV() { + return super.dFdVdV() + cpaon * dFCPAdVdV(); + } + + /** {@inheritDoc} */ + @Override + public double dFdVdVdV() { + return super.dFdVdVdV() + cpaon * dFCPAdVdVdV(); + } + + /** {@inheritDoc} */ + @Override + public double dFdTdT() { + return super.dFdTdT() + cpaon * dFCPAdTdT(); + } + + /** + *

+ * FCPA. + *

+ * + * @return a double + */ + public double FCPA() { + double tot = 0.0; + double ans = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + tot = 0.0; + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + double xai = ((ComponentElectrolyteCPA) getComponent(i)).getXsite()[j]; + tot += (Math.log(xai) - 1.0 / 2.0 * xai + 1.0 / 2.0); + } + ans += getComponent(i).getNumberOfMolesInPhase() * tot; + } + return ans; + } + + /** + *

+ * dFCPAdV. + *

+ * + * @return a double + */ + public double dFCPAdV() { + return 1.0 / (2.0 * getTotalVolume()) * (1.0 - getTotalVolume() * getGcpav()) * hcpatot; + } + + /** + *

+ * dFCPAdVdV. + *

+ * + * @return a double + */ + public double dFCPAdVdV() { + return -1.0 / getTotalVolume() * dFCPAdV() + + hcpatot / (2.0 * getTotalVolume()) * (-getGcpav() - getTotalVolume() * gcpavv) + + getdFdVdXdXdVtotal(); + } + + /** + *

+ * dFCPAdVdVdV. + *

+ * + * @return a double + */ + public double dFCPAdVdVdV() { + return -1.0 / getTotalVolume() * dFCPAdVdV() + 1.0 / Math.pow(getTotalVolume(), 2.0) * dFCPAdV() + - hcpatot / (2.0 * Math.pow(getTotalVolume(), 2.0)) + * (-getGcpav() - getTotalVolume() * gcpavv) + + hcpatot / (2.0 * getTotalVolume()) * (-gcpavv - getTotalVolume() * gcpavvv - gcpavv); + } + + /** + *

+ * dFCPAdT. + *

+ * + * @return a double + */ + public double dFCPAdT() { + // System.out.println("dFCPAdXdXdTtotal " + dFCPAdXdXdTtotal); + return dFCPAdXdXdTtotal; + // -1.0 / 2.0 * hcpatotdT; + } + + /** + *

+ * dFCPAdTdT. + *

+ * + * @return a double + */ + public double dFCPAdTdT() { + return dFCPAdTdT; // -1.0 / 2.0 * hcpatotdTdT; + } + + /** + *

+ * calc_hCPA. + *

+ * + * @return a double + */ + public double calc_hCPA() { + double htot = 0.0; + double tot = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + htot = 0.0; + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + htot += (1.0 - ((ComponentElectrolyteCPA) getComponent(i)).getXsite()[j]); + } + tot += getComponent(i).getNumberOfMolesInPhase() * htot; + } + // System.out.println("tot " +tot ); + return tot; + } + + /** + *

+ * calc_hCPAdT. + *

+ * + * @return a double + */ + public double calc_hCPAdT() { + double htot = 0.0; + double tot = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + for (int k = 0; k < numberOfComponents; k++) { + htot = 0.0; + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + for (int l = 0; l < getComponent(k).getNumberOfAssociationSites(); l++) { + htot += ((ComponentElectrolyteCPA) getComponent(i)).getXsite()[j] + * ((ComponentElectrolyteCPA) getComponent(k)).getXsite()[l] + * cpamix.calcDeltadT(j, l, i, k, this, temperature, pressure, numberOfComponents); + } } - // System.out.println("tot " +tot ); - return tot / getTotalVolume(); - } - /** - *

- * calc_hCPAdTdT. - *

- * - * @return a double - */ - public double calc_hCPAdTdT() { - double htot = 0.0; - double tot = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - for (int k = 0; k < numberOfComponents; k++) { - htot = 0.0; - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - for (int l = 0; l < getComponent(k).getNumberOfAssociationSites(); l++) { - htot += ((ComponentElectrolyteCPA) getComponent(i)).getXsite()[j] - * ((ComponentElectrolyteCPA) getComponent(k)).getXsite()[l] - * cpamix.calcDeltadTdT(j, l, i, k, this, temperature, pressure, - numberOfComponents); - } - } - - tot += getComponent(i).getNumberOfMolesInPhase() - * getComponent(k).getNumberOfMolesInPhase() * htot; - } + tot += getComponent(i).getNumberOfMolesInPhase() * getComponent(k).getNumberOfMolesInPhase() + * htot; + } + } + // System.out.println("tot " +tot ); + return tot / getTotalVolume(); + } + + /** + *

+ * calc_hCPAdTdT. + *

+ * + * @return a double + */ + public double calc_hCPAdTdT() { + double htot = 0.0; + double tot = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + for (int k = 0; k < numberOfComponents; k++) { + htot = 0.0; + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + for (int l = 0; l < getComponent(k).getNumberOfAssociationSites(); l++) { + htot += ((ComponentElectrolyteCPA) getComponent(i)).getXsite()[j] + * ((ComponentElectrolyteCPA) getComponent(k)).getXsite()[l] + * cpamix.calcDeltadTdT(j, l, i, k, this, temperature, pressure, numberOfComponents); + } } - // System.out.println("tot " +tot ); - return tot / getTotalVolume(); - } - - /** - *

- * calc_g. - *

- * - * @return a double - */ - public double calc_g() { - double x = 1.9 / 4.0 * getB() / getTotalVolume(); - double g = 1.0 / (1.0 - x); - // System.out.println("ratio " + getMolarVolume()/getb()); - return g; - } - - /** - *

- * calc_lngni. - *

- * - * @param comp a int - * @return a double - */ - public double calc_lngni(int comp) { - double nbet = getb() / 4.0 / getMolarVolume(); - double dlngdb = 1.9 / (1.0 - 1.9 * nbet); - double nbeti = nbet / getb() * ((ComponentEosInterface) getComponent(comp)).getBi(); - return dlngdb * nbeti; - } - - /** - *

- * calc_lngV. - *

- * - * @return a double - */ - public double calc_lngV() { - double x = 1.9 / 4.0 * getB() / getTotalVolume(); - double gv = (x / getTotalVolume()) / (1.0 - x); - return -gv; - } - - /** - *

- * calc_lngVV. - *

- * - * @return a double - */ - public double calc_lngVV() { - double x = 1.9 / 4.0 * getB() / getTotalVolume(); - double xV = -1.9 / 4.0 * getB() / Math.pow(getTotalVolume(), 2.0); - double u = 1.0 - x; - - double val = -x / (Math.pow(getTotalVolume(), 2.0) * u) + xV / (getTotalVolume() * u) - - x / (getTotalVolume() * u * u) * (-1.0) * xV; - return -val; - - // double gvv - // =0.225625/Math.pow(1.0-0.475*getB()/getTotalVolume(),2.0)*Math.pow(getB(),2.0)/(Math.pow(getTotalVolume(),4.0))+0.95/(1.0-0.475*getB()/getTotalVolume())*getB()/(Math.pow(getTotalVolume(),3.0)); - // System.out.println("val2 " + gvv); - // return gvv; - } - /** - *

- * calc_lngVVV. - *

- * - * @return a double - */ - public double calc_lngVVV() { - double gvv = -0.21434375 / Math.pow(1.0 - 0.475 * getB() / getTotalVolume(), 3.0) - * Math.pow(getB(), 3.0) / (Math.pow(getTotalVolume(), 6.0)) - - 0.135375E1 / Math.pow(1.0 - 0.475 * getB() / getTotalVolume(), 2.0) - * Math.pow(getB(), 2.0) / (Math.pow(getTotalVolume(), 5.0)) - - 0.285E1 / (1.0 - 0.475 * getB() / getTotalVolume()) * getB() - / (Math.pow(getTotalVolume(), 4.0)); - return gvv; - } - - /** - *

- * setXsiteOld. - *

- */ - public void setXsiteOld() { - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - ((ComponentCPAInterface) getComponent(i)).setXsiteOld(j, - ((ComponentCPAInterface) getComponent(i)).getXsite()[j]); - } + tot += getComponent(i).getNumberOfMolesInPhase() * getComponent(k).getNumberOfMolesInPhase() + * htot; + } + } + // System.out.println("tot " +tot ); + return tot / getTotalVolume(); + } + + /** + *

+ * calc_g. + *

+ * + * @return a double + */ + public double calc_g() { + double x = 1.9 / 4.0 * getB() / getTotalVolume(); + double g = 1.0 / (1.0 - x); + // System.out.println("ratio " + getMolarVolume()/getb()); + return g; + } + + /** + *

+ * calc_lngni. + *

+ * + * @param comp a int + * @return a double + */ + public double calc_lngni(int comp) { + double nbet = getb() / 4.0 / getMolarVolume(); + double dlngdb = 1.9 / (1.0 - 1.9 * nbet); + double nbeti = nbet / getb() * ((ComponentEosInterface) getComponent(comp)).getBi(); + return dlngdb * nbeti; + } + + /** + *

+ * calc_lngV. + *

+ * + * @return a double + */ + public double calc_lngV() { + double x = 1.9 / 4.0 * getB() / getTotalVolume(); + double gv = (x / getTotalVolume()) / (1.0 - x); + return -gv; + } + + /** + *

+ * calc_lngVV. + *

+ * + * @return a double + */ + public double calc_lngVV() { + double x = 1.9 / 4.0 * getB() / getTotalVolume(); + double xV = -1.9 / 4.0 * getB() / Math.pow(getTotalVolume(), 2.0); + double u = 1.0 - x; + + double val = -x / (Math.pow(getTotalVolume(), 2.0) * u) + xV / (getTotalVolume() * u) + - x / (getTotalVolume() * u * u) * (-1.0) * xV; + return -val; + + // double gvv + // =0.225625/Math.pow(1.0-0.475*getB()/getTotalVolume(),2.0)*Math.pow(getB(),2.0)/(Math.pow(getTotalVolume(),4.0))+0.95/(1.0-0.475*getB()/getTotalVolume())*getB()/(Math.pow(getTotalVolume(),3.0)); + // System.out.println("val2 " + gvv); + // return gvv; + } + + /** + *

+ * calc_lngVVV. + *

+ * + * @return a double + */ + public double calc_lngVVV() { + double gvv = -0.21434375 / Math.pow(1.0 - 0.475 * getB() / getTotalVolume(), 3.0) + * Math.pow(getB(), 3.0) / (Math.pow(getTotalVolume(), 6.0)) + - 0.135375E1 / Math.pow(1.0 - 0.475 * getB() / getTotalVolume(), 2.0) + * Math.pow(getB(), 2.0) / (Math.pow(getTotalVolume(), 5.0)) + - 0.285E1 / (1.0 - 0.475 * getB() / getTotalVolume()) * getB() + / (Math.pow(getTotalVolume(), 4.0)); + return gvv; + } + + /** + *

+ * setXsiteOld. + *

+ */ + public void setXsiteOld() { + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + ((ComponentCPAInterface) getComponent(i)).setXsiteOld(j, + ((ComponentCPAInterface) getComponent(i)).getXsite()[j]); + } + } + } + + /** + *

+ * setXsitedV. + *

+ * + * @param dV a double + */ + public void setXsitedV(double dV) { + dFdVdXdXdVtotal = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + double XdV = (((ComponentCPAInterface) getComponent(i)).getXsite()[j] + - ((ComponentCPAInterface) getComponent(i)).getXsiteOld()[j]) / dV; + ((ComponentCPAInterface) getComponent(i)).setXsitedV(j, XdV); + dFdVdXdXdVtotal += XdV * ((ComponentCPAInterface) getComponent(i)).dFCPAdVdXi(j, this); + // System.out.println("xidv " + XdV); + } + } + } + + /** + *

+ * calcXsitedT. + *

+ */ + public void calcXsitedT() { + double dt = 0.01; + double XdT = 0.0; + setXsiteOld(); + setTemperature(temperature + dt); + solveX(); + dFCPAdXdXdTtotal = 0.0; + dFCPAdTdT = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + XdT = (((ComponentCPAInterface) getComponent(i)).getXsite()[j] + - ((ComponentCPAInterface) getComponent(i)).getXsiteOld()[j]) / dt; + ((ComponentCPAInterface) getComponent(i)).setXsitedT(j, XdT); + dFCPAdXdXdTtotal += XdT * ((ComponentCPAInterface) getComponent(i)).dFCPAdXi(j, this); + } + } + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + for (int k = 0; k < numberOfComponents; k++) { + for (int j2 = 0; j2 < getComponent(k).getNumberOfAssociationSites(); j2++) { + dFCPAdTdT += ((ComponentCPAInterface) getComponent(i)).dFCPAdXidXj(j, j2, k, this) + * ((ComponentCPAInterface) getComponent(i)).getXsitedT()[j] + * ((ComponentCPAInterface) getComponent(k)).getXsitedT()[j2]; + } } - } - - /** - *

- * setXsitedV. - *

- * - * @param dV a double - */ - public void setXsitedV(double dV) { - dFdVdXdXdVtotal = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - double XdV = (((ComponentCPAInterface) getComponent(i)).getXsite()[j] - - ((ComponentCPAInterface) getComponent(i)).getXsiteOld()[j]) / dV; - ((ComponentCPAInterface) getComponent(i)).setXsitedV(j, XdV); - dFdVdXdXdVtotal += - XdV * ((ComponentCPAInterface) getComponent(i)).dFCPAdVdXi(j, this); - // System.out.println("xidv " + XdV); - } + } + } + setTemperature(temperature - dt); + solveX(); + } + + /** + *

+ * Getter for the field dFdVdXdXdVtotal. + *

+ * + * @return a double + */ + public double getdFdVdXdXdVtotal() { + return dFdVdXdXdVtotal; + } + + /** + *

+ * solveX. + *

+ * + * @return a boolean + */ + public boolean solveX() { + double err = .0; + int iter = 0; + + do { + iter++; + err = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + double old = ((ComponentElectrolyteCPA) getComponent(i)).getXsite()[j]; + double neeval = getCpamix().calcXi(selfAccociationScheme, crossAccociationScheme, j, i, + this, temperature, pressure, numberOfComponents); + ((ComponentCPAInterface) getComponent(i)).setXsite(j, neeval); + err += Math.abs((old - neeval) / neeval); } - } - - /** - *

- * calcXsitedT. - *

- */ - public void calcXsitedT() { - double dt = 0.01, XdT = 0.0; - setXsiteOld(); - setTemperature(temperature + dt); - solveX(); - dFCPAdXdXdTtotal = 0.0; - dFCPAdTdT = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - XdT = (((ComponentCPAInterface) getComponent(i)).getXsite()[j] - - ((ComponentCPAInterface) getComponent(i)).getXsiteOld()[j]) / dt; - ((ComponentCPAInterface) getComponent(i)).setXsitedT(j, XdT); - dFCPAdXdXdTtotal += - XdT * ((ComponentCPAInterface) getComponent(i)).dFCPAdXi(j, this); - } - } - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - for (int k = 0; k < numberOfComponents; k++) { - for (int j2 = 0; j2 < getComponent(k).getNumberOfAssociationSites(); j2++) { - dFCPAdTdT += ((ComponentCPAInterface) getComponent(i)).dFCPAdXidXj(j, j2, k, - this) * ((ComponentCPAInterface) getComponent(i)).getXsitedT()[j] - * ((ComponentCPAInterface) getComponent(k)).getXsitedT()[j2]; - } - } - } - } - setTemperature(temperature - dt); - solveX(); - } - - /** - *

- * Getter for the field dFdVdXdXdVtotal. - *

- * - * @return a double - */ - public double getdFdVdXdXdVtotal() { - return dFdVdXdXdVtotal; - } - - /** - *

- * solveX. - *

- * - * @return a boolean - */ - public boolean solveX() { - double err = .0; - int iter = 0; - - do { - iter++; - err = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - double old = ((ComponentElectrolyteCPA) getComponent(i)).getXsite()[j]; - double neeval = - getCpamix().calcXi(selfAccociationScheme, crossAccociationScheme, j, i, - this, temperature, pressure, numberOfComponents); - ((ComponentCPAInterface) getComponent(i)).setXsite(j, neeval); - err += Math.abs((old - neeval) / neeval); - } - } - // System.out.println("err " + err); - } while (Math.abs(err) > 1e-10 && iter < 100); - // System.out.println("iter " +iter); - return Math.abs(err) < 1e-10; - } - - /** {@inheritDoc} */ - @Override - public double getHcpatot() { - return hcpatot; - } - - /** - * Setter for property hcpatot. - * - * @param hcpatot New value of property hcpatot. - */ - public void setHcpatot(double hcpatot) { - this.hcpatot = hcpatot; - } - - /** {@inheritDoc} */ - @Override - public double getGcpa() { - return gcpa; - } - - /** - *

- * molarVolume3. - *

- * - * @param pressure a double - * @param temperature a double - * @param A a double - * @param B a double - * @param phasetype a int - * @return a double - * @throws neqsim.util.exception.IsNaNException if any. - * @throws neqsim.util.exception.TooManyIterationsException if any. - */ - public double molarVolume3(double pressure, double temperature, double A, double B, - int phasetype) throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - - if (BonV < 0) { - BonV = 1.0e-8; - } - if (BonV > 1.0) { - BonV = 1.0 - 1.0e-8; - } - double BonVold = BonV; - double Btemp = 0, h = 0, dh = 0, dhh = 0; - // double Dtemp = 0, gvvv = 0, fvvv = 0; - double d1 = 0, d2 = 0; - Btemp = getB(); - // Dtemp = getA(); - if (Btemp < 0) { - logger.info("b negative in volume calc"); - } - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - int iterations = 0; - - do { - this.volInit(); - gcpa = calc_g(); - lngcpa = Math.log(gcpa); - gcpav = calc_lngV(); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - solveX(); - hcpatot = calc_hCPA(); - - iterations++; - BonVold = BonV; - h = BonV - Btemp / numberOfMolesInPhase * dFdV() - - pressure * Btemp / (numberOfMolesInPhase * R * temperature); - dh = 1.0 + Btemp / Math.pow(BonV, 2.0) * (Btemp / numberOfMolesInPhase * dFdVdV()); - dhh = -2.0 * Btemp / Math.pow(BonV, 3.0) * (Btemp / numberOfMolesInPhase * dFdVdV()) - - Math.pow(Btemp, 2.0) / Math.pow(BonV, 4.0) - * (Btemp / numberOfMolesInPhase * dFdVdVdV()); - - d1 = -h / dh; - d2 = -dh / dhh; - - if (Math.abs(d1 / d2) <= 1.0) { - BonV += d1 * (1.0 + 0.5 * d1 / d2); - } else if (d1 / d2 < -1) { - BonV += d1 * (1.0 + 0.5 * -1.0); - } else if (d1 / d2 > 1) { - BonV += d2; - double hnew = h + d2 * -h / d1; - if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } - - if (BonV > 1) { - BonV = 1.0 - 1.0e-8; - BonVold = 10; - } - if (BonV < 0) { - BonV = 1.0e-8; - BonVold = 10; - } - - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - // System.out.println("Z" + Z); - } while (Math.abs((BonV - BonVold) / BonV) > 1.0e-10 && iterations < 101); - // System.out.println("Z" + Z + " iterations " + iterations); - // System.out.println("pressure " + Z*R*temperature/molarVolume); - // if(iterations>=100) throw new util.exception.TooManyIterationsException(); - // System.out.println("error in volume " + - // (-pressure+R*temperature/molarVolume-R*temperature*dFdV()) + " firstterm " + - // (R*temperature/molarVolume) + " second " + R*temperature*dFdV()); - if (Double.isNaN(getMolarVolume())) { - throw new neqsim.util.exception.IsNaNException(this, "molarVolume3", "Molar volume"); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " - // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" - // + fVV()); - } - return getMolarVolume(); - } - - /** {@inheritDoc} */ - @Override - public double molarVolume(double pressure, double temperature, double A, double B, - int phasetype) throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - - if (BonV < 0) { - BonV = 1.0e-8; - } - if (BonV > 1.0) { - BonV = 1.0 - 1.0e-8; + } + // System.out.println("err " + err); + } while (Math.abs(err) > 1e-10 && iter < 100); + // System.out.println("iter " +iter); + return Math.abs(err) < 1e-10; + } + + /** {@inheritDoc} */ + @Override + public double getHcpatot() { + return hcpatot; + } + + /** + * Setter for property hcpatot. + * + * @param hcpatot New value of property hcpatot. + */ + public void setHcpatot(double hcpatot) { + this.hcpatot = hcpatot; + } + + /** {@inheritDoc} */ + @Override + public double getGcpa() { + return gcpa; + } + + /** + *

+ * molarVolume3. + *

+ * + * @param pressure a double + * @param temperature a double + * @param A a double + * @param B a double + * @param phasetype a int + * @return a double + * @throws neqsim.util.exception.IsNaNException if any. + * @throws neqsim.util.exception.TooManyIterationsException if any. + */ + public double molarVolume3(double pressure, double temperature, double A, double B, int phasetype) + throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + + if (BonV < 0) { + BonV = 1.0e-8; + } + if (BonV > 1.0) { + BonV = 1.0 - 1.0e-8; + } + double BonVold = BonV; + double Btemp = 0; + double h = 0; + double dh = 0; + double dhh = 0; + // double Dtemp = 0, gvvv = 0, fvvv = 0; + double d1 = 0; + double d2 = 0; + Btemp = getB(); + // Dtemp = getA(); + if (Btemp < 0) { + logger.info("b negative in volume calc"); + } + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + int iterations = 0; + + do { + this.volInit(); + gcpa = calc_g(); + lngcpa = Math.log(gcpa); + gcpav = calc_lngV(); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); + solveX(); + hcpatot = calc_hCPA(); + + iterations++; + BonVold = BonV; + h = BonV - Btemp / numberOfMolesInPhase * dFdV() + - pressure * Btemp / (numberOfMolesInPhase * R * temperature); + dh = 1.0 + Btemp / Math.pow(BonV, 2.0) * (Btemp / numberOfMolesInPhase * dFdVdV()); + dhh = -2.0 * Btemp / Math.pow(BonV, 3.0) * (Btemp / numberOfMolesInPhase * dFdVdV()) + - Math.pow(Btemp, 2.0) / Math.pow(BonV, 4.0) + * (Btemp / numberOfMolesInPhase * dFdVdVdV()); + + d1 = -h / dh; + d2 = -dh / dhh; + + if (Math.abs(d1 / d2) <= 1.0) { + BonV += d1 * (1.0 + 0.5 * d1 / d2); + } else if (d1 / d2 < -1) { + BonV += d1 * (1.0 + 0.5 * -1.0); + } else if (d1 / d2 > 1) { + BonV += d2; + double hnew = h + d2 * -h / d1; + if (Math.abs(hnew) > Math.abs(h)) { + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); } - double BonVold = BonV; - double Btemp = 0, h = 0, dh = 0, dhh = 0; - // double Dtemp = 0, fvvv = 0, gvvv = 0; - double d1 = 0, d2 = 0; - Btemp = getB(); - // Dtemp = getA(); - if (Btemp < 0) { - logger.info("b negative in volume calc"); + } + + if (BonV > 1) { + BonV = 1.0 - 1.0e-8; + BonVold = 10; + } + if (BonV < 0) { + BonV = 1.0e-8; + BonVold = 10; + } + + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); + // System.out.println("Z" + Z); + } while (Math.abs((BonV - BonVold) / BonV) > 1.0e-10 && iterations < 101); + // System.out.println("Z" + Z + " iterations " + iterations); + // System.out.println("pressure " + Z*R*temperature/molarVolume); + // if(iterations>=100) throw new util.exception.TooManyIterationsException(); + // System.out.println("error in volume " + + // (-pressure+R*temperature/molarVolume-R*temperature*dFdV()) + " firstterm " + + // (R*temperature/molarVolume) + " second " + R*temperature*dFdV()); + if (Double.isNaN(getMolarVolume())) { + throw new neqsim.util.exception.IsNaNException(this, "molarVolume3", "Molar volume"); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " + // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + // + fVV()); + } + return getMolarVolume(); + } + + /** {@inheritDoc} */ + @Override + public double molarVolume(double pressure, double temperature, double A, double B, int phasetype) + throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + + if (BonV < 0) { + BonV = 1.0e-8; + } + if (BonV > 1.0) { + BonV = 1.0 - 1.0e-8; + } + double BonVold = BonV; + double Btemp = 0; + double h = 0; + double dh = 0; + double dhh = 0; + // double Dtemp = 0, fvvv = 0, gvvv = 0; + double d1 = 0; + double d2 = 0; + Btemp = getB(); + // Dtemp = getA(); + if (Btemp < 0) { + logger.info("b negative in volume calc"); + } + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + int iterations = 0; + int maxIterations = 1000; + double oldVolume = getVolume(); + do { + this.volInit(); + gcpa = calc_g(); + lngcpa = Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); + + solveX(); + hcpatot = calc_hCPA(); + + double dV = getVolume() - oldVolume; + if (iterations > 0) { + setXsitedV(dV); + } + oldVolume = getVolume(); + setXsiteOld(); + + iterations++; + BonVold = BonV; + h = BonV - Btemp / numberOfMolesInPhase * dFdV() + - pressure * Btemp / (numberOfMolesInPhase * R * temperature); + dh = 1.0 + Btemp / Math.pow(BonV, 2.0) * (Btemp / numberOfMolesInPhase * dFdVdV()); + dhh = -2.0 * Btemp / Math.pow(BonV, 3.0) * (Btemp / numberOfMolesInPhase * dFdVdV()) + - Math.pow(Btemp, 2.0) / Math.pow(BonV, 4.0) + * (Btemp / numberOfMolesInPhase * dFdVdVdV()); + + d1 = -h / dh; + d2 = -dh / dhh; + + if (Math.abs(d1 / d2) <= 1.0) { + BonV += d1 * (1.0 + 0.5 * d1 / d2); + } else if (d1 / d2 < -1) { + BonV += d1 * (1.0 + 0.5 * -1.0); + } else if (d1 / d2 > 1) { + BonV += d2; + double hnew = h + d2 * -h / d1; + if (Math.abs(hnew) > Math.abs(h)) { + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); } - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - int iterations = 0; - int maxIterations = 1000; - double oldVolume = getVolume(); - do { - this.volInit(); - gcpa = calc_g(); - lngcpa = Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - - solveX(); - hcpatot = calc_hCPA(); - - double dV = getVolume() - oldVolume; - if (iterations > 0) { - setXsitedV(dV); - } - oldVolume = getVolume(); - setXsiteOld(); - - iterations++; - BonVold = BonV; - h = BonV - Btemp / numberOfMolesInPhase * dFdV() - - pressure * Btemp / (numberOfMolesInPhase * R * temperature); - dh = 1.0 + Btemp / Math.pow(BonV, 2.0) * (Btemp / numberOfMolesInPhase * dFdVdV()); - dhh = -2.0 * Btemp / Math.pow(BonV, 3.0) * (Btemp / numberOfMolesInPhase * dFdVdV()) - - Math.pow(Btemp, 2.0) / Math.pow(BonV, 4.0) - * (Btemp / numberOfMolesInPhase * dFdVdVdV()); - - d1 = -h / dh; - d2 = -dh / dhh; - - if (Math.abs(d1 / d2) <= 1.0) { - BonV += d1 * (1.0 + 0.5 * d1 / d2); - } else if (d1 / d2 < -1) { - BonV += d1 * (1.0 + 0.5 * -1.0); - } else if (d1 / d2 > 1) { - BonV += d2; - double hnew = h + d2 * -h / d1; - if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } - - if (BonV > 1) { - BonV = 1.0 - 1.0e-8; - BonVold = 10; - } - if (BonV < 0) { - BonV = 1.0e-8; - BonVold = 10; - } - - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - - // System.out.println("Z" + Z); - } while (Math.abs((BonV - BonVold) / BonV) > 1.0e-10 && iterations < maxIterations); - // System.out.println("Z" + Z + " iterations " + iterations + " h " + h); - // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); - // if(iterations>=100) throw new util.exception.TooManyIterationsException(); - // System.out.println("error in volume " + - // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " - // firstterm " + (R*temperature/molarVolume) + " second " + - // R*temperature*dFdV()); - if (Double.isNaN(getMolarVolume())) { - throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " - // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" - // + fVV()); - } - return getMolarVolume(); - } - - /** {@inheritDoc} */ - @Override - public double molarVolume2(double pressure, double temperature, double A, double B, int phase) - throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - Z = phase == 0 ? 1.0 : 1.0e-5; + } + + if (BonV > 1) { + BonV = 1.0 - 1.0e-8; + BonVold = 10; + } + if (BonV < 0) { + BonV = 1.0e-8; + BonVold = 10; + } + + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); + + // System.out.println("Z" + Z); + } while (Math.abs((BonV - BonVold) / BonV) > 1.0e-10 && iterations < maxIterations); + // System.out.println("Z" + Z + " iterations " + iterations + " h " + h); + // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); + // if(iterations>=100) throw new util.exception.TooManyIterationsException(); + // System.out.println("error in volume " + + // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV())); // + " + // firstterm " + (R*temperature/molarVolume) + " second " + + // R*temperature*dFdV()); + if (Double.isNaN(getMolarVolume())) { + throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " + // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + // + fVV()); + } + return getMolarVolume(); + } + + /** {@inheritDoc} */ + @Override + public double molarVolume2(double pressure, double temperature, double A, double B, int phase) + throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + Z = phase == 0 ? 1.0 : 1.0e-5; + setMolarVolume(Z * R * temperature / pressure); + // super.molarVolume(pressure,temperature, A, B, phase); + int iterations = 0; + double err = 0.0; + double dErrdV = 0.0; + double deltaV = 0; + + do { + A = calcA(this, temperature, pressure, numberOfComponents); + B = calcB(this, temperature, pressure, numberOfComponents); + double dFdV = dFdV(); + double dFdVdV = dFdVdV(); + // double dFdVdVdV = dFdVdVdV(); + // double factor1 = 1.0e0, factor2 = 1.0e0; + err = -R * temperature * dFdV + R * temperature / getMolarVolume() - pressure; + + logger.info("pressure " + -R * temperature * dFdV + " " + R * temperature / getMolarVolume()); + // -pressure; + dErrdV = -R * temperature * dFdVdV + - R * temperature * numberOfMolesInPhase / Math.pow(getVolume(), 2.0); + + logger.info("errdV " + dErrdV); + logger.info("err " + err); + + deltaV = -err / dErrdV; + + setMolarVolume(getMolarVolume() + deltaV / numberOfMolesInPhase); + + Z = pressure * getMolarVolume() / (R * temperature); + if (Z < 0) { + Z = 1e-6; setMolarVolume(Z * R * temperature / pressure); - // super.molarVolume(pressure,temperature, A, B, phase); - int iterations = 0; - double err = 0.0, dErrdV = 0.0; - double deltaV = 0; - - do { - A = calcA(this, temperature, pressure, numberOfComponents); - B = calcB(this, temperature, pressure, numberOfComponents); - double dFdV = dFdV(), dFdVdV = dFdVdV(); - // double dFdVdVdV = dFdVdVdV(); - // double factor1 = 1.0e0, factor2 = 1.0e0; - err = -R * temperature * dFdV + R * temperature / getMolarVolume() - pressure; - - logger.info("pressure " + -R * temperature * dFdV + " " - + R * temperature / getMolarVolume()); - // -pressure; - dErrdV = -R * temperature * dFdVdV - - R * temperature * numberOfMolesInPhase / Math.pow(getVolume(), 2.0); - - logger.info("errdV " + dErrdV); - logger.info("err " + err); - - deltaV = -err / dErrdV; - - setMolarVolume(getMolarVolume() + deltaV / numberOfMolesInPhase); - - Z = pressure * getMolarVolume() / (R * temperature); - if (Z < 0) { - Z = 1e-6; - setMolarVolume(Z * R * temperature / pressure); - } - // System.out.println("Z " + Z); - } while (Math.abs(err) > 1.0e-8 || iterations < 100); - // System.out.println("Z " + Z); - return getMolarVolume(); - } - - /** {@inheritDoc} */ - @Override - public double getGcpav() { - return gcpav; - } - - /** - *

- * Setter for the field gcpav. - *

- * - * @param gcpav a double - */ - public void setGcpav(double gcpav) { - this.gcpav = gcpav; - } - - /** {@inheritDoc} */ - @Override - public CPAMixingInterface getCpamix() { - return cpamix; - } - - /** {@inheritDoc} */ - @Override - public int getCrossAssosiationScheme(int comp1, int comp2, int site1, int site2) { - if (comp1 == comp2) { - return selfAccociationScheme[comp1][site1][site2]; - } - return crossAccociationScheme[comp1][comp2][site1][site2]; - } - - /** {@inheritDoc} */ - @Override - public int getTotalNumberOfAccociationSites() { - return totalNumberOfAccociationSites; - } - - /** {@inheritDoc} */ - @Override - public void setTotalNumberOfAccociationSites(int totalNumberOfAccociationSites) { - this.totalNumberOfAccociationSites = totalNumberOfAccociationSites; - } + } + // System.out.println("Z " + Z); + } while (Math.abs(err) > 1.0e-8 || iterations < 100); + // System.out.println("Z " + Z); + return getMolarVolume(); + } + + /** {@inheritDoc} */ + @Override + public double getGcpav() { + return gcpav; + } + + /** + *

+ * Setter for the field gcpav. + *

+ * + * @param gcpav a double + */ + public void setGcpav(double gcpav) { + this.gcpav = gcpav; + } + + /** {@inheritDoc} */ + @Override + public CPAMixingInterface getCpamix() { + return cpamix; + } + + /** {@inheritDoc} */ + @Override + public int getCrossAssosiationScheme(int comp1, int comp2, int site1, int site2) { + if (comp1 == comp2) { + return selfAccociationScheme[comp1][site1][site2]; + } + return crossAccociationScheme[comp1][comp2][site1][site2]; + } + + /** {@inheritDoc} */ + @Override + public int getTotalNumberOfAccociationSites() { + return totalNumberOfAccociationSites; + } + + /** {@inheritDoc} */ + @Override + public void setTotalNumberOfAccociationSites(int totalNumberOfAccociationSites) { + this.totalNumberOfAccociationSites = totalNumberOfAccociationSites; + } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseEos.java b/src/main/java/neqsim/thermo/phase/PhaseEos.java index 3d7846fabc..708ba596d2 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseEos.java +++ b/src/main/java/neqsim/thermo/phase/PhaseEos.java @@ -1033,7 +1033,7 @@ public double getdUdVSn() { * @return a double */ public double getdUdSdSVn() { - return 1.0 / (FTT() * R * getTemperature());// noe feil her + return 1.0 / (FTT() * R * getTemperature()); // noe feil her } /** diff --git a/src/main/java/neqsim/thermo/phase/PhaseGENRTL.java b/src/main/java/neqsim/thermo/phase/PhaseGENRTL.java index e7a9007e1a..0614810aa0 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGENRTL.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGENRTL.java @@ -110,7 +110,7 @@ public double getExessGibbsEnergy(PhaseInterface phase, int numberOfComponents, temperature, pressure, phasetype, alpha, Dij, intparam, mixRule)); } - return R * temperature * numberOfMolesInPhase * GE;// phase.getNumberOfMolesInPhase()* + return R * temperature * numberOfMolesInPhase * GE; // phase.getNumberOfMolesInPhase()* } /** {@inheritDoc} */ diff --git a/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedHV.java b/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedHV.java index 2cd4b6f956..e41ee5fb6e 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedHV.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedHV.java @@ -148,7 +148,7 @@ public double getGibbsEnergy() { double val = 0.0; for (int i = 0; i < numberOfComponents; i++) { val += - getComponent(i).getNumberOfMolesInPhase() * (getComponent(i).getLogFugacityCoefficient());// +Math.log(getComponent(i).getx()*getComponent(i).getAntoineVaporPressure(temperature))); + getComponent(i).getNumberOfMolesInPhase() * (getComponent(i).getLogFugacityCoefficient()); // +Math.log(getComponent(i).getx()*getComponent(i).getAntoineVaporPressure(temperature))); } return R * temperature * ((val) + Math.log(pressure) * numberOfMolesInPhase); } diff --git a/src/main/java/neqsim/thermo/phase/PhaseGEUnifac.java b/src/main/java/neqsim/thermo/phase/PhaseGEUnifac.java index 10f2458b65..b0b2f8abb1 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGEUnifac.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGEUnifac.java @@ -162,7 +162,7 @@ public void checkGroups() { .contains(((ComponentGEUnifac) getComponent(i)).getUnifacGroup(j))) { unifacGroups.add(((ComponentGEUnifac) getComponent(i)).getUnifacGroup(j)); } else - ;// System.out.println("no"); + ; // System.out.println("no"); } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseGEUnifacPSRK.java b/src/main/java/neqsim/thermo/phase/PhaseGEUnifacPSRK.java index 218dbce1eb..f82cb50da8 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGEUnifacPSRK.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGEUnifacPSRK.java @@ -89,7 +89,7 @@ public double getExessGibbsEnergy(PhaseInterface phase, int numberOfComponents, * Math.log(((ComponentGEUniquac) componentArray[i]).getGamma(phase, numberOfComponents, temperature, pressure, phasetype)); } - return R * phase.getTemperature() * GE * phase.getNumberOfMolesInPhase();// phase.getNumberOfMolesInPhase()* + return R * phase.getTemperature() * GE * phase.getNumberOfMolesInPhase(); // phase.getNumberOfMolesInPhase()* } /** diff --git a/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEos.java b/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEos.java index 7caa1ece92..f9e5e6fd64 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEos.java +++ b/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEos.java @@ -55,7 +55,7 @@ public class PhaseModifiedFurstElectrolyteEos extends PhaseSrkEos { double lrOn = 1.0; double bornOn = 1.0; // double gammLRdV=0.0; - // PhaseInterface[] refPhase;// = new PhaseInterface[10]; + // PhaseInterface[] refPhase; // = new PhaseInterface[10]; /** *

@@ -574,7 +574,7 @@ public double molarVolume(double pressure, double temperature, double A, double throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); } - // if(phaseType==0) System.out.println("density " + getDensity());//"BonV: " + + // if(phaseType==0) System.out.println("density " + getDensity()); //"BonV: " + // BonV + " "+" itert: " + iterations +" " + " phase " + phaseType+ " " + h + " // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" // + fVV()); @@ -687,7 +687,7 @@ public double calcDiElectricConstantdVdV(double temperature) { double Y = getSolventDiElectricConstant() - 1.0; double dXdf = getEpsIonicdVdV() * -3.0 / 2.0 / Math.pow(getEpsIonic() / 2.0 + 1.0, 2.0) + getEpsIonicdV() * getEpsIonicdV() * 3.0 / 2.0 / Math.pow(getEpsIonic() / 2.0 + 1.0, 3.0); - return Y * dXdf;// + Y*dXdf; + return Y * dXdf; // + Y*dXdf; } /** {@inheritDoc} */ @@ -797,7 +797,7 @@ public double dFLRdTdT() { * @return a double */ public double dFLRdV() { - return (FLRV() + dFdAlphaLR() * alphaLRdV) * 1e-5;// + FLRGammaLR()*gammLRdV + + return (FLRV() + dFdAlphaLR() * alphaLRdV) * 1e-5; // + FLRGammaLR()*gammLRdV + // 0*FLRXLR()*XLRdGammaLR()*gammLRdV)*1e-5; } diff --git a/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEosMod2004.java b/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEosMod2004.java index 00576928c1..dc4adc1ae3 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEosMod2004.java +++ b/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEosMod2004.java @@ -55,7 +55,7 @@ public class PhaseModifiedFurstElectrolyteEosMod2004 extends PhaseSrkEos { double lrOn = 1.0; double bornOn = 1.0; // double gammLRdV=0.0; - // PhaseInterface[] refPhase;// = new PhaseInterface[10]; + // PhaseInterface[] refPhase; // = new PhaseInterface[10]; /** *

@@ -575,7 +575,7 @@ public double molarVolume(double pressure, double temperature, double A, double throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); } - // if(phaseType==0) System.out.println("density " + getDensity());//"BonV: " + + // if(phaseType==0) System.out.println("density " + getDensity()); //"BonV: " + // BonV + " "+" itert: " + iterations +" " + " phase " + phaseType+ " " + h + " // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" // + fVV()); @@ -688,7 +688,7 @@ public double calcDiElectricConstantdVdV(double temperature) { double Y = getSolventDiElectricConstant() - 1.0; double dXdf = getEpsIonicdVdV() * -3.0 / 2.0 / Math.pow(getEpsIonic() / 2.0 + 1.0, 2.0) + getEpsIonicdV() * getEpsIonicdV() * 3.0 / 2.0 / Math.pow(getEpsIonic() / 2.0 + 1.0, 3.0); - return Y * dXdf;// + Y*dXdf; + return Y * dXdf; // + Y*dXdf; } /** {@inheritDoc} */ @@ -796,7 +796,7 @@ public double dFLRdTdT() { * @return a double */ public double dFLRdV() { - return (FLRV() + dFdAlphaLR() * alphaLRdV) * 1e-5;// + FLRGammaLR()*gammLRdV + + return (FLRV() + dFdAlphaLR() * alphaLRdV) * 1e-5; // + FLRGammaLR()*gammLRdV + // 0*FLRXLR()*XLRdGammaLR()*gammLRdV)*1e-5; } diff --git a/src/main/java/neqsim/thermo/phase/PhasePCSAFT.java b/src/main/java/neqsim/thermo/phase/PhasePCSAFT.java index d47d7ec1fd..38211483ca 100644 --- a/src/main/java/neqsim/thermo/phase/PhasePCSAFT.java +++ b/src/main/java/neqsim/thermo/phase/PhasePCSAFT.java @@ -17,7 +17,10 @@ public class PhasePCSAFT extends PhaseSrkEos { private static final long serialVersionUID = 1000; double nSAFT = 1.0; - double dnSAFTdV = 1.0, dnSAFTdVdV = 1.0; + double dnSAFTdV = 1.0; + + double dnSAFTdVdV = 1.0; + double dmeanSAFT = 0.0; double dSAFT = 1.0; double mSAFT = 1.0; @@ -28,9 +31,20 @@ public class PhasePCSAFT extends PhaseSrkEos { double aHSSAFT = 1.0; double volumeSAFT = 1.0; double daHCSAFTdN = 1.0; - double daHSSAFTdN = 1.0, dgHSSAFTdN = 1.0; - double daHSSAFTdNdN = 1.0, dgHSSAFTdNdN = 1.0; - int useHS = 1, useDISP1 = 1, useDISP2 = 1; + double daHSSAFTdN = 1.0; + + double dgHSSAFTdN = 1.0; + + double daHSSAFTdNdN = 1.0; + + double dgHSSAFTdNdN = 1.0; + + int useHS = 1; + + int useDISP1 = 1; + + int useDISP2 = 1; + private double[][] aConstSAFT = { {0.9105631445, 0.6361281449, 2.6861347891, -26.547362491, 97.759208784, -159.59154087, 91.297774084}, @@ -45,12 +59,52 @@ public class PhasePCSAFT extends PhaseSrkEos { -165.20769346}, {0.0976883116, -0.2557574982, -9.1558561530, 20.642075974, -38.804430052, 93.626774077, -29.666905585}}; - private double F1dispVolTerm = 1.0, F1dispSumTerm = 1.0, F1dispI1 = 1.0, F2dispI2 = 1.0, - F2dispZHC = 1.0, F2dispZHCdN = 1.0, F2dispZHCdm = 1.0, F2dispZHCdV = 1.0, F2dispI2dVdV = 0.0, - F2dispZHCdVdV = 0.0, F1dispI1dNdN = 1.0; - private double F1dispVolTermdV = 1.0, F1dispVolTermdVdV = 1.0, F1dispI1dN = 1.0, F1dispI1dm = 1.0, - F1dispI1dV = 1.0, F2dispI2dV = 1.0, F2dispI2dN = 1.0, F2dispI2dm = 1.0, F2dispSumTerm = 0.0, - F2dispZHCdNdN = 1.0, F2dispI2dNdN = 1.0, F1dispI1dVdV = 0.0; + private double F1dispVolTerm = 1.0; + + private double F1dispSumTerm = 1.0; + + private double F1dispI1 = 1.0; + + private double F2dispI2 = 1.0; + + private double F2dispZHC = 1.0; + + private double F2dispZHCdN = 1.0; + + private double F2dispZHCdm = 1.0; + + private double F2dispZHCdV = 1.0; + + private double F2dispI2dVdV = 0.0; + + private double F2dispZHCdVdV = 0.0; + + private double F1dispI1dNdN = 1.0; + + private double F1dispVolTermdV = 1.0; + + private double F1dispVolTermdVdV = 1.0; + + private double F1dispI1dN = 1.0; + + private double F1dispI1dm = 1.0; + + private double F1dispI1dV = 1.0; + + private double F2dispI2dV = 1.0; + + private double F2dispI2dN = 1.0; + + private double F2dispI2dm = 1.0; + + private double F2dispSumTerm = 0.0; + + private double F2dispZHCdNdN = 1.0; + + private double F2dispI2dNdN = 1.0; + + private double F1dispI1dVdV = 0.0; + static Logger logger = LogManager.getLogger(PhasePCSAFT.class); /** @@ -160,7 +214,7 @@ public void volInit() { F2dispI2dNdN = calcF2dispI2dNdN(); F2dispI2dm = calcF2dispI2dm(); F2dispI2dV = F2dispI2dN * getDnSAFTdV(); - F2dispI2dVdV = F2dispI2dNdN * getDnSAFTdV() * getDnSAFTdV() + F2dispI2dN * dnSAFTdVdV;// F2dispI2dNdN*dnSAFTdVdV;; + F2dispI2dVdV = F2dispI2dNdN * getDnSAFTdV() * getDnSAFTdV() + F2dispI2dN * dnSAFTdVdV; // F2dispI2dNdN*dnSAFTdVdV;; F2dispZHC = calcF2dispZHC(); F2dispZHCdN = calcF2dispZHCdN(); @@ -540,7 +594,8 @@ public double calcmmin1SAFT() { * @return a double */ public double calcdmeanSAFT() { - double temp = 0.0, temp2 = 0.0; + double temp = 0.0; + double temp2 = 0.0; for (int i = 0; i < numberOfComponents; i++) { temp += getComponent(i).getNumberOfMolesInPhase() * getComponent(i).getmSAFTi() * Math.pow(((ComponentPCSAFT) getComponent(i)).getdSAFTi(), 3.0); @@ -641,7 +696,7 @@ public void setGhsSAFT(double ghsSAFT) { */ public double F_HC_SAFT() { return getNumberOfMolesInPhase() - * (getmSAFT() * getAHSSAFT() - getMmin1SAFT() * Math.log(getGhsSAFT()));/// (ThermodynamicConstantsInterface.R*temperature); + * (getmSAFT() * getAHSSAFT() - getMmin1SAFT() * Math.log(getGhsSAFT())); /// (ThermodynamicConstantsInterface.R*temperature); } /** @@ -653,7 +708,7 @@ public double F_HC_SAFT() { */ public double dF_HC_SAFTdV() { return getNumberOfMolesInPhase() * (getmSAFT() * daHSSAFTdN * getDnSAFTdV() - - getMmin1SAFT() * 1.0 / getGhsSAFT() * getDgHSSAFTdN() * getDnSAFTdV());/// (ThermodynamicConstantsInterface.R*temperature); + - getMmin1SAFT() * 1.0 / getGhsSAFT() * getDgHSSAFTdN() * getDnSAFTdV()); /// (ThermodynamicConstantsInterface.R*temperature); } /** @@ -692,7 +747,7 @@ public double dF_HC_SAFTdVdVdV() { */ public double F_DISP1_SAFT() { return getNumberOfMolesInPhase() * (-2.0 * ThermodynamicConstantsInterface.pi - * getF1dispVolTerm() * getF1dispSumTerm() * getF1dispI1());/// (ThermodynamicConstantsInterface.R*temperature); + * getF1dispVolTerm() * getF1dispSumTerm() * getF1dispI1()); /// (ThermodynamicConstantsInterface.R*temperature); } /** @@ -706,7 +761,7 @@ public double dF_DISP1_SAFTdV() { return getNumberOfMolesInPhase() * (-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTermdV * getF1dispSumTerm() * getF1dispI1() - 2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTerm * getF1dispSumTerm() - * F1dispI1dV);/// (ThermodynamicConstantsInterface.R*temperature); + * F1dispI1dV); /// (ThermodynamicConstantsInterface.R*temperature); } /** @@ -736,7 +791,7 @@ public double dF_DISP1_SAFTdVdV() { */ public double F_DISP2_SAFT() { return getNumberOfMolesInPhase() * (-ThermodynamicConstantsInterface.pi * getmSAFT() - * getF1dispVolTerm() * getF2dispSumTerm() * getF2dispI2() * getF2dispZHC());/// (ThermodynamicConstantsInterface.R*temperature); + * getF1dispVolTerm() * getF2dispSumTerm() * getF2dispI2() * getF2dispZHC()); /// (ThermodynamicConstantsInterface.R*temperature); } /** @@ -752,7 +807,7 @@ public double dF_DISP2_SAFTdV() { - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm() * F2dispI2dV * getF2dispZHC() - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm() - * getF2dispI2() * F2dispZHCdV);/// (ThermodynamicConstantsInterface.R*temperature); + * getF2dispI2() * F2dispZHCdV); /// (ThermodynamicConstantsInterface.R*temperature); } /** @@ -1101,7 +1156,9 @@ public double molarVolume22(double pressure, double temperature, double A, doubl setMolarVolume(volume / numberOfMolesInPhase); double oldMolarVolume = 0; int iterations = 0; - double h = 0, dh = 0.0, d1 = 0.0; + double h = 0; + double dh = 0.0; + double d1 = 0.0; do { iterations++; this.volInit(); @@ -1137,7 +1194,9 @@ public double molarVolume(double pressure, double temperature, double A, double BonV = 1.0 - 1.0e-6; } double BonVold = BonV; - double Btemp = 0, h = 0, dh = 0; + double Btemp = 0; + double h = 0; + double dh = 0; // double gvvv = 0, fvvv = 0, dhh = 0, d2 = 0; double d1 = 0; Btemp = getB(); @@ -1183,7 +1242,7 @@ public double molarVolume(double pressure, double temperature, double A, double throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); } - // if(phaseType==0) System.out.println("density " + getDensity());//"BonV: " + + // if(phaseType==0) System.out.println("density " + getDensity()); //"BonV: " + // BonV + " "+" itert: " + iterations +" " + " phase " + phaseType+ " " + h + " // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" // + fVV()); diff --git a/src/main/java/neqsim/thermo/phase/PhasePCSAFTRahmat.java b/src/main/java/neqsim/thermo/phase/PhasePCSAFTRahmat.java index f93f359f73..381428f3b3 100644 --- a/src/main/java/neqsim/thermo/phase/PhasePCSAFTRahmat.java +++ b/src/main/java/neqsim/thermo/phase/PhasePCSAFTRahmat.java @@ -14,1504 +14,1495 @@ * @version $Id: $Id */ public class PhasePCSAFTRahmat extends PhasePCSAFT { - private static final long serialVersionUID = 1000; - - double nSAFT = 1.0; - double dnSAFTdV = 1.0, dnSAFTdVdV = 1.0, dnSAFTdVdVdV = 1.0; - double dmeanSAFT = 0.0; - double dSAFT = 1.0; - double mSAFT = 1.0; - double mdSAFT = 1.0; - double nmSAFT = 1.0; - double mmin1SAFT = 1.0; - double ghsSAFT = 1.0; - double aHSSAFT = 1.0; - double volumeSAFT = 1.0; - double daHCSAFTdN = 1.0; - double daHSSAFTdN = 1.0, dgHSSAFTdN = 1.0; - double daHSSAFTdNdN = 1.0, dgHSSAFTdNdN = 1.0; - double daHSSAFTdNdNdN = 1.0, dgHSSAFTdNdNdN = 1.0; - // by Rahmat - double dNSAFTdT = 1.0; - double dF1dispVolTermdT = 0.0; - double dF1dispI1dT = 1.0, dF2dispI2dT = 1.0; - double dF2dispZHCdT = 1.0; - double dF1dispSumTermdT = 1.0, dF2dispSumTermdT = 1.0; - int useHS = 1, useDISP1 = 1, useDISP2 = 1; - private double[][] aConstSAFT = { - {0.9105631445, 0.6361281449, 2.6861347891, -26.547362491, 97.759208784, -159.59154087, - 91.297774084}, - {-0.3084016918, 0.1860531159, -2.5030047259, 21.419793629, -65.255885330, 83.318680481, - -33.746922930}, - {-0.0906148351, 0.4527842806, 0.5962700728, -1.7241829131, -4.1302112531, 13.776631870, - -8.6728470368}}; - private double[][] bConstSAFT = { - {0.7240946941, 2.2382791861, -4.0025849485, -21.003576815, 26.855641363, 206.55133841, - -355.60235612}, - {-0.5755498075, 0.6995095521, 3.8925673390, -17.215471648, 192.67226447, -161.82646165, - -165.20769346}, - {0.0976883116, -0.2557574982, -9.1558561530, 20.642075974, -38.804430052, 93.626774077, - -29.666905585}}; - private double F1dispVolTerm = 1.0, F1dispSumTerm = 1.0, F1dispI1 = 1.0, F2dispI2 = 1.0, - F2dispZHC = 1.0, F2dispZHCdN = 1.0, F2dispZHCdm = 1.0, F2dispZHCdV = 1.0, F2dispI2dVdV, - F2dispI2dVdVdV = 0.0, F2dispZHCdVdV = 1.0, F2dispZHCdVdVdV = 1.0, F1dispI1dNdN = 1.0, - F1dispI1dNdNdN = 1.0; - private double F1dispVolTermdV = 1.0, F1dispVolTermdVdV = 1.0, F1dispI1dN = 1.0, - F1dispI1dm = 1.0, F1dispI1dV = 1.0, F2dispI2dV = 1.0, F2dispI2dN = 1.0, - F2dispI2dm = 1.0, F2dispSumTerm = 0.0, F2dispZHCdNdN = 1.0, F2dispZHCdNdNdN = 1.0, - F2dispI2dNdN = 1.0, F2dispI2dNdNdN = 1.0, F1dispI1dVdV = 1.0, F1dispI1dVdVdV = 1.0; - private double F1dispVolTermdVdVdV = 1.0; - static Logger logger = LogManager.getLogger(PhasePCSAFTRahmat.class); - - /** - *

- * Constructor for PhasePCSAFTRahmat. - *

- */ - public PhasePCSAFTRahmat() { - super(); - } + private static final long serialVersionUID = 1000; - /** {@inheritDoc} */ - @Override - public PhasePCSAFTRahmat clone() { - PhasePCSAFTRahmat clonedPhase = null; - try { - clonedPhase = (PhasePCSAFTRahmat) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } - - return clonedPhase; - } + double nSAFT = 1.0; + double dnSAFTdV = 1.0; - /** {@inheritDoc} */ - @Override - public void addcomponent(String componentName, double moles, double molesInPhase, - int compNumber) { - super.addcomponent(molesInPhase); - componentArray[compNumber] = - new ComponentPCSAFT(componentName, moles, molesInPhase, compNumber); - } + double dnSAFTdVdV = 1.0; - /** {@inheritDoc} */ - @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, - double beta) { - for (int i = 0; i < numberOfComponents; i++) { - componentArray[i].Finit(this, temperature, pressure, totalNumberOfMoles, beta, - numberOfComponents, type); - } - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - } + double dnSAFTdVdVdV = 1.0; - /** {@inheritDoc} */ - @Override - public void volInit() { - volumeSAFT = getVolume() * 1.0e-5; - setDmeanSAFT(calcdmeanSAFT()); - setDSAFT(calcdSAFT()); - // System.out.println("saft volume " + getVolumeSAFT()); - // System.out.println("dsaft " + getDSAFT()); - setNSAFT(1.0 * ThermodynamicConstantsInterface.pi / 6.0 - * ThermodynamicConstantsInterface.avagadroNumber * getNumberOfMolesInPhase() - / volumeSAFT * getDSAFT()); - dnSAFTdV = -1.0 * ThermodynamicConstantsInterface.pi / 6.0 - * ThermodynamicConstantsInterface.avagadroNumber * getNumberOfMolesInPhase() - / Math.pow(volumeSAFT, 2.0) * getDSAFT(); - dnSAFTdVdV = 2.0 * ThermodynamicConstantsInterface.pi / 6.0 - * ThermodynamicConstantsInterface.avagadroNumber * getNumberOfMolesInPhase() - / Math.pow(volumeSAFT, 3.0) * getDSAFT(); - // System.out.println("N SAFT " + getNSAFT()); - dnSAFTdVdVdV = -6.0 * ThermodynamicConstantsInterface.pi / 6.0 - * ThermodynamicConstantsInterface.avagadroNumber * getNumberOfMolesInPhase() - / Math.pow(volumeSAFT, 4.0) * getDSAFT(); - - // added by rahmat - dNSAFTdT = 1.0 * ThermodynamicConstantsInterface.pi / 6.0 - * ThermodynamicConstantsInterface.avagadroNumber * getNumberOfMolesInPhase() - / volumeSAFT * getdDSAFTdT(); - - setGhsSAFT((1.0 - nSAFT / 2.0) / Math.pow(1.0 - nSAFT, 3.0)); - setmSAFT(calcmSAFT()); - setMmin1SAFT(calcmmin1SAFT()); - setmdSAFT(calcmdSAFT()); - setAHSSAFT((4.0 * getNSAFT() - 3.0 * Math.pow(getNSAFT(), 2.0)) - / Math.pow(1.0 - getNSAFT(), 2.0)); - daHSSAFTdN = ((4.0 - 6.0 * getNSAFT()) * Math.pow(1.0 - getNSAFT(), 2.0) - - (4.0 * getNSAFT() - 3 * Math.pow(getNSAFT(), 2.0)) * 2.0 * (1.0 - getNSAFT()) - * (-1.0)) - / Math.pow(1.0 - getNSAFT(), 4.0); - daHSSAFTdNdN = (-6.0 * Math.pow(1.0 - getNSAFT(), 2.0) - + 2.0 * (1.0 - getNSAFT()) * (4.0 - 6 * getNSAFT())) - / Math.pow(1.0 - getNSAFT(), 4.0) - + ((8.0 - 12.0 * getNSAFT()) * Math.pow(1.0 - getNSAFT(), 3.0) - + (8.0 - 6.0 * Math.pow(getNSAFT(), 2.0)) * 3.0 - * Math.pow(1.0 - getNSAFT(), 2.0)) - / Math.pow(1.0 - getNSAFT(), 6.0); - daHSSAFTdNdNdN = -36 / Math.pow((1 - getNSAFT()), 3) - + (18.0 * (4.0 - 6.0 * getNSAFT())) / Math.pow((1 - getNSAFT()), 4.0) - + (24.0 * (4.0 * getNSAFT() - 3.0 * Math.pow(getNSAFT(), 2.0))) - / Math.pow((1 - getNSAFT()), 5.0); - - dgHSSAFTdN = (-0.5 * Math.pow(1.0 - getNSAFT(), 3.0) - - (1.0 - getNSAFT() / 2.0) * 3.0 * Math.pow(1.0 - nSAFT, 2.0) * (-1.0)) - / Math.pow(1.0 - getNSAFT(), 6.0); - dgHSSAFTdNdN = -3.0 / 2.0 * Math.pow(1.0 - getNSAFT(), 2.0) - / Math.pow(1.0 - getNSAFT(), 6.0) - + (-3.0 / 2.0 * Math.pow(1.0 - getNSAFT(), 4.0) - + 4.0 * Math.pow(1.0 - getNSAFT(), 3.0) * (3.0 - 3.0 / 2.0 * getNSAFT())) - / Math.pow(1.0 - getNSAFT(), 8.0); - dgHSSAFTdNdNdN = -6.0 / Math.pow(1.0 - getNSAFT(), 5.0) - - (12.0 * (3.0 - 1.5 * getNSAFT())) / Math.pow(1.0 - getNSAFT(), 6.0) - + (8 * (-1.5 * Math.pow(1.0 - getNSAFT(), 4) - + 4.0 * Math.pow(1.0 - getNSAFT(), 3) * (3.0 - 1.5 * getNSAFT()))) - / Math.pow(1.0 - getNSAFT(), 9); - - setF1dispVolTerm(ThermodynamicConstantsInterface.avagadroNumber * getNumberOfMolesInPhase() - / getVolumeSAFT()); - F1dispSumTerm = calcF1dispSumTerm(); - F1dispI1 = calcF1dispI1(); - F1dispVolTermdV = -ThermodynamicConstantsInterface.avagadroNumber - * getNumberOfMolesInPhase() / Math.pow(getVolumeSAFT(), 2.0); - F1dispVolTermdVdV = 2.0 * ThermodynamicConstantsInterface.avagadroNumber - * getNumberOfMolesInPhase() / Math.pow(getVolumeSAFT(), 3.0); - F1dispVolTermdVdVdV = -6.0 * ThermodynamicConstantsInterface.avagadroNumber - * getNumberOfMolesInPhase() / Math.pow(getVolumeSAFT(), 4.0); - - // added by rahmat - dF1dispI1dT = calcdF1dispI1dT(); - dF2dispI2dT = calcdF2dispI2dT(); - dF1dispSumTermdT = calcdF1dispSumTermdT(); - dF2dispSumTermdT = calcdF2dispSumTermdT(); - dF2dispZHCdT = calcdF2dispZHCdT(); - - F1dispI1dN = calcF1dispI1dN(); - F1dispI1dNdN = calcF1dispI1dNdN(); - F1dispI1dNdNdN = calcF1dispI1dNdNdN(); - - F1dispI1dm = calcF1dispI1dm(); - F1dispI1dV = F1dispI1dN * getDnSAFTdV(); - F1dispI1dVdV = F1dispI1dNdN * getDnSAFTdV() * getDnSAFTdV() + F1dispI1dN * dnSAFTdVdV; // F1dispI1dNdN*dnSAFTdVdV; - - // added by Rahmat - F1dispI1dVdVdV = F1dispI1dNdNdN * getDnSAFTdV() * getDnSAFTdV() * getDnSAFTdV() - + F1dispI1dN * 2.0 * getDnSAFTdV() * dnSAFTdVdV + F1dispI1dNdN * dnSAFTdVdV - + F1dispI1dN * dnSAFTdVdVdV; // F1dispI1dNdN*dnSAFTdVdV; - - setF2dispSumTerm(calcF2dispSumTerm()); - setF2dispI2(calcF2dispI2()); - F2dispI2dN = calcF2dispI2dN(); - F2dispI2dNdN = calcF2dispI2dNdN(); - // added by Rahmat - F2dispI2dNdNdN = calcF2dispI2dNdNdN(); - - F2dispI2dm = calcF2dispI2dm(); - - F2dispI2dV = F2dispI2dN * getDnSAFTdV(); - F2dispI2dVdV = F2dispI2dNdN * getDnSAFTdV() * getDnSAFTdV() + F2dispI2dN * dnSAFTdVdV;// F2dispI2dNdN*dnSAFTdVdV;; - - // added by Rahmat - F2dispI2dVdVdV = F2dispI2dNdNdN * getDnSAFTdV() * getDnSAFTdV() * getDnSAFTdV() - + F2dispI2dN * 2.0 * getDnSAFTdV() * dnSAFTdVdV + F2dispI2dNdN * dnSAFTdVdV - + F2dispI2dN * dnSAFTdVdVdV; - - F2dispZHC = calcF2dispZHC(); - F2dispZHCdN = calcF2dispZHCdN(); - F2dispZHCdNdN = calcF2dispZHCdNdN(); - F2dispZHCdNdNdN = calcF2dispZHCdNdNdN(); - - setF2dispZHCdm(calcF2dispZHCdm()); - F2dispZHCdV = F2dispZHCdN * getDnSAFTdV(); - F2dispZHCdVdV = F2dispZHCdNdN * getDnSAFTdV() * getDnSAFTdV() + F2dispZHCdN * dnSAFTdVdV; // F2dispZHCdNdN*dnSAFTdVdV*0; - F2dispZHCdVdVdV = F2dispZHCdNdNdN * getDnSAFTdV() * getDnSAFTdV() * getDnSAFTdV() - + F2dispZHCdNdN * 2.0 * getDnSAFTdV() * dnSAFTdVdV + F2dispZHCdNdN * dnSAFTdVdV - + F2dispZHCdN * dnSAFTdVdVdV; - } + double dmeanSAFT = 0.0; + double dSAFT = 1.0; + double mSAFT = 1.0; + double mdSAFT = 1.0; + double nmSAFT = 1.0; + double mmin1SAFT = 1.0; + double ghsSAFT = 1.0; + double aHSSAFT = 1.0; + double volumeSAFT = 1.0; + double daHCSAFTdN = 1.0; + double daHSSAFTdN = 1.0; - /** {@inheritDoc} */ - @Override - public double calcF2dispZHC() { - double temp = 1.0 - + getmSAFT() * (8.0 * getNSAFT() - 2.0 * Math.pow(getNSAFT(), 2.0)) - / Math.pow(1.0 - getNSAFT(), 4.0) - + (1.0 - getmSAFT()) - * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2.0) - + 12 * Math.pow(getNSAFT(), 3.0) - 2 * Math.pow(getNSAFT(), 4.0)) - / Math.pow((1.0 - getNSAFT()) * (2.0 - getNSAFT()), 2.0); - return 1.0 / temp; - } + double dgHSSAFTdN = 1.0; - /** {@inheritDoc} */ - @Override - public double calcF2dispZHCdm() { - double temp = -Math.pow(F2dispZHC, 2.0); - return temp * ((8.0 * getNSAFT() - 2.0 * Math.pow(getNSAFT(), 2.0)) - / Math.pow(1.0 - getNSAFT(), 4.0) - - (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2.0) + 12 * Math.pow(getNSAFT(), 3.0) - - 2 * Math.pow(getNSAFT(), 4.0)) - / Math.pow((1.0 - getNSAFT()) * (2.0 - getNSAFT()), 2.0)); - } + double daHSSAFTdNdN = 1.0; - /** {@inheritDoc} */ - @Override - public double calcF2dispZHCdN() { - double temp0 = -Math.pow(F2dispZHC, 2.0); - double temp1 = Math.pow((1.0 - getNSAFT()) * (2.0 - getNSAFT()), 2.0); - double temp2 = 20.0 * getNSAFT() - 27.0 * Math.pow(getNSAFT(), 2.0) - + 12.0 * Math.pow(getNSAFT(), 3.0) - 2.0 * Math.pow(getNSAFT(), 4.0); - // ikke rett implementert - return temp0 * (getmSAFT() - * ((8.0 - 4.0 * getNSAFT()) * Math.pow(1.0 - getNSAFT(), 4.0) - - 4.0 * Math.pow(1.0 - getNSAFT(), 3.0) * (-1.0) - * (8.0 * getNSAFT() - 2.0 * Math.pow(getNSAFT(), 2.0))) - / Math.pow(1.0 - getNSAFT(), 8.0) - + (1.0 - getmSAFT()) - * ((20.0 - (2.0 * 27.0) * getNSAFT() - + (12.0 * 3.0) * Math.pow(getNSAFT(), 2.0) - - 8.0 * Math.pow(getNSAFT(), 3.0)) * temp1 - - (2.0 * (2.0 - 3.0 * getNSAFT() + Math.pow(getNSAFT(), 2.0)) - * (-3.0 + 2.0 * getNSAFT())) * temp2) - / Math.pow(temp1, 2.0)); - } + double dgHSSAFTdNdN = 1.0; - /** {@inheritDoc} */ - @Override - public double calcF2dispZHCdNdN() { - double temp0 = 2.0 * Math.pow(F2dispZHC, 3.0); - double temp1 = Math.pow((1.0 - getNSAFT()) * (2.0 - getNSAFT()), 2.0); - double temp11 = Math.pow((1.0 - getNSAFT()) * (2.0 - getNSAFT()), 3.0); - double temp2 = 20.0 * getNSAFT() - 27.0 * Math.pow(getNSAFT(), 2.0) - + 12.0 * Math.pow(getNSAFT(), 3.0) - 2.0 * Math.pow(getNSAFT(), 4.0); - - double temp1der = 2.0 * (2.0 - 3.0 * getNSAFT() + Math.pow(getNSAFT(), 2.0)) - * (-3.0 + 2.0 * getNSAFT()); - double temp11der = 3.0 * Math.pow(2.0 - 3.0 * getNSAFT() + Math.pow(getNSAFT(), 2.0), 2.0) - * (-3.0 + 2.0 * getNSAFT()); - // ikke rett implementert - double temp3 = (getmSAFT() - * ((8.0 - 4.0 * getNSAFT()) * Math.pow(1.0 - getNSAFT(), 4.0) - - 4.0 * Math.pow(1.0 - getNSAFT(), 3.0) * (-1.0) - * (8.0 * getNSAFT() - 2.0 * Math.pow(getNSAFT(), 2.0))) - / Math.pow(1.0 - getNSAFT(), 8.0) - + (1.0 - getmSAFT()) - * ((20.0 - (2.0 * 27.0) * getNSAFT() - + (12.0 * 3.0) * Math.pow(getNSAFT(), 2.0) - - 8.0 * Math.pow(getNSAFT(), 3.0)) * temp1 - - (2.0 * (2.0 - 3.0 * getNSAFT() + Math.pow(getNSAFT(), 2.0)) - * (-3.0 + 2.0 * getNSAFT())) * temp2) - / Math.pow(temp1, 2.0)); - - double temp4 = -Math.pow(F2dispZHC, 2.0); - double dZdndn = - getmSAFT() - * ((-4.0 * Math.pow(1.0 - getNSAFT(), 4.0) - 4.0 - * Math.pow(1.0 - getNSAFT(), 3.0) * (-1.0) - * (8.0 - 4.0 * getNSAFT())) / Math.pow(1.0 - getNSAFT(), 8.0) - + ((32.0 - 16.0 * getNSAFT()) * Math.pow(1.0 - getNSAFT(), 5.0) - - 5.0 * Math.pow(1.0 - getNSAFT(), 4.0) * (-1.0) - * (32.0 * getNSAFT() - - 8.0 * Math.pow(getNSAFT(), 2.0))) - / Math.pow(1.0 - getNSAFT(), 10.0)) - + (1.0 - getmSAFT()) - * (((-54.0 + 72.0 * getNSAFT() - 24.0 * Math.pow(getNSAFT(), 2.0)) - * temp1 - - temp1der * (20.0 - 54.0 * getNSAFT() - + 36.0 * Math.pow(getNSAFT(), 2.0) - - 8.0 * Math.pow(getNSAFT(), 3.0))) - / Math.pow(temp1, 2.0) - - ((-40.0 * Math.pow(getNSAFT(), 4.0) - + 240.0 * Math.pow(getNSAFT(), 3.0) - - 3.0 * 180.0 * Math.pow(getNSAFT(), 2.0) - + 242.0 * 2.0 * getNSAFT() - 120.0) * temp11 - - temp11der * (-8.0 * Math.pow(getNSAFT(), 5.0) - + 60.0 * Math.pow(getNSAFT(), 4.0) - - 180.0 * Math.pow(getNSAFT(), 3.0) - + 242.0 * Math.pow(getNSAFT(), 2.0) - - 120.0 * getNSAFT())) - / Math.pow(temp11, 2.0)); - - return temp0 * Math.pow(temp3, 2.0) + temp4 * dZdndn; - } + double daHSSAFTdNdNdN = 1.0; - /** - *

- * calcF2dispZHCdNdNdN. - *

- * - * @return a double - */ - public double calcF2dispZHCdNdNdN() { - double temp = -6 - * Math.pow( - (getmSAFT() * (8.0 - - 4.0 * getNSAFT()) / Math.pow((1.0 - getNSAFT()), - 4) - + 4 * getmSAFT() * (8.0 * getNSAFT() - - 2.0 * Math.pow(getNSAFT(), 2) - / Math.pow((1.0 - getNSAFT()), 5) - + (1.0 - getmSAFT()) - * (20 - 54 * getNSAFT() - + 36 * Math.pow(getNSAFT(), 2) - - 8 * Math.pow(getNSAFT(), 3)) - / (Math.pow((1.0 - getNSAFT()), 2) - * Math.pow((2.0 - getNSAFT()), 2)) - + (2 * (1.0 - getmSAFT())) - * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) - + 12 * Math.pow(getNSAFT(), 3) - - 2 * Math.pow(getNSAFT(), 4)) - / (Math.pow((1.0 - getNSAFT()), 3) - * Math.pow((2.0 - getNSAFT()), 2)) - + (2 * (1.0 - getmSAFT())) - * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) - + 12 * Math.pow(getNSAFT(), 3) - - 2 * Math.pow(getNSAFT(), 4)) - / (Math.pow((1.0 - getNSAFT()), 2) - * Math.pow((2.0 - getNSAFT()), 3)))), - 3) - / Math.pow((1.0 - + getmSAFT() * (8.0 * getNSAFT() - 2.0 * Math.pow(getNSAFT(), 2)) - / Math.pow((1.0 - getNSAFT()), 4) - + (1.0 - getmSAFT()) * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) - + 12 * Math.pow(getNSAFT(), 3) - 2 * Math.pow(getNSAFT(), 4)) - / (Math.pow((1.0 - getNSAFT()), 2) - * Math.pow((2.0 - getNSAFT()), 2))), - 4) - + (6 * (getmSAFT() * (8.0 - 4.0 * getNSAFT()) / Math.pow((1.0 - getNSAFT()), 4) - + 4 * getmSAFT() * (8.0 * getNSAFT() - Math.pow(2.0 * getNSAFT(), 2)) - / Math.pow((1.0 - getNSAFT()), 5) - + (1.0 - getmSAFT()) - * (20 - 54 * getNSAFT() + 36 * Math.pow(getNSAFT(), 2) - - 8 * Math.pow(getNSAFT(), 3)) - / (Math.pow((1.0 - getNSAFT()), 2) - * Math.pow((2.0 - getNSAFT()), 2)) - + (2 * (1.0 - getmSAFT())) * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) - + 12 * Math.pow(getNSAFT(), 3) - 2 * Math.pow(getNSAFT(), 4)) - / (Math.pow((1.0 - getNSAFT()), 3) - * Math.pow((2.0 - getNSAFT()), 2)) - + (2 * (1.0 - getmSAFT())) * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) - + 12 * Math.pow(getNSAFT(), 3) - 2 * Math.pow(getNSAFT(), 4)) - / (Math.pow((1.0 - getNSAFT()), 2) - * Math.pow((2.0 - getNSAFT()), 3)))) - * (-4.0 * getmSAFT() / Math.pow((1.0 - getNSAFT()), 4) - + 8 * getmSAFT() * (8.0 - 4.0 * getNSAFT()) - / Math.pow((1.0 - getNSAFT()), 5) - + 20 * getmSAFT() - * (8.0 * getNSAFT() - 2.0 * Math.pow(getNSAFT(), 2)) - / Math.pow((1.0 - getNSAFT()), 6) - + (1.0 - getmSAFT()) - * (-54 + 72 * getNSAFT() - 24 * Math.pow(getNSAFT(), 2)) - / (Math.pow((1.0 - getNSAFT()), 2) - * Math.pow((2.0 - getNSAFT()), 2)) - + (4 * (1.0 - getmSAFT())) - * (20 - 54 * getNSAFT() + 36 * Math.pow(getNSAFT(), 2) - - 8 * Math.pow(getNSAFT(), 3)) - / (Math.pow((1.0 - getNSAFT()), 3) - * Math.pow((2.0 - getNSAFT()), 2)) - + (4 * (1.0 - getmSAFT())) - * (20 - 54 * getNSAFT() + 36 * Math.pow(getNSAFT(), 2) - - 8 * Math.pow(getNSAFT(), 3)) - / (Math.pow((1.0 - getNSAFT()), 2) - * Math.pow((2.0 - getNSAFT()), 3)) - + (6 * (1.0 - getmSAFT())) - * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) - + 12 * Math.pow(getNSAFT(), 3) - - 2 * Math.pow(getNSAFT(), 4)) - / (Math.pow((1.0 - getNSAFT()), 4) - * Math.pow((2.0 - getNSAFT()), 2)) - + (8 * (1.0 - getmSAFT())) - * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) - + 12 * Math.pow(getNSAFT(), 3) - - 2 * Math.pow(getNSAFT(), 4)) - / (Math.pow((1.0 - getNSAFT()), 3) - * Math.pow((2.0 - getNSAFT()), 3)) - + (6 * (1.0 - getmSAFT())) - * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) - + 12 * Math.pow(getNSAFT(), 3) - - 2 * Math.pow(getNSAFT(), 4)) - / (Math.pow((1.0 - getNSAFT()), 2) - * Math.pow((2.0 - getNSAFT()), 4))) - / Math.pow(1.0 - + getmSAFT() * (8.0 * getNSAFT() - 2.0 * Math.pow(getNSAFT(), 2)) - / Math.pow((1.0 - getNSAFT()), 4) - + ((1.0 - getmSAFT()) - * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) - + 12 * Math.pow(getNSAFT(), 3) - - 2 * Math.pow(getNSAFT(), 4)) - / (Math.pow((1.0 - getNSAFT()), 2) - * Math.pow((2.0 - getNSAFT()), 2))), - 3) - - (-48.0 * getmSAFT() / Math.pow((1.0 - getNSAFT()), 5) - + 60 * getmSAFT() * (8.0 - 4.0 * getNSAFT()) - / Math.pow((1.0 - getNSAFT()), 6) - + 120 * getmSAFT() * (8.0 * getNSAFT() - 2.0 * Math.pow(getNSAFT(), 2)) - / Math.pow((1.0 - getNSAFT()), 7) - + (1.0 - getmSAFT()) * (72 - 48 * getNSAFT()) - / (Math.pow((1.0 - getNSAFT()), 2) - * Math.pow((2.0 - getNSAFT()), 2)) - + (6 * (1.0 - getmSAFT())) - * (-54 + 72 * getNSAFT() - 24 * Math.pow(getNSAFT(), 2)) - / (Math.pow((1.0 - getNSAFT()), 3) - * Math.pow((2.0 - getNSAFT()), 2)) - + (6 * (1.0 - getmSAFT())) - * (-54 + 72 * getNSAFT() - 24 * Math.pow(getNSAFT(), 2)) - / (Math.pow((1.0 - getNSAFT()), 2) - * Math.pow((2.0 - getNSAFT()), 3)) - + (18 * (1.0 - getmSAFT())) - * (20 - 54 * getNSAFT() + 36 * Math.pow(getNSAFT(), 2) - - 8 * Math.pow(getNSAFT(), 3)) - / (Math.pow((1.0 - getNSAFT()), 4) - * Math.pow((2.0 - getNSAFT()), 2)) - + (24 * (1.0 - getmSAFT())) - * (20 - 54 * getNSAFT() + 36 * Math.pow(getNSAFT(), 2) - - 8 * Math.pow(getNSAFT(), 3)) - / (Math.pow((1.0 - getNSAFT()), 3) - * Math.pow((2.0 - getNSAFT()), 3)) - + (18 * (1.0 - getmSAFT())) - * (20 - 54 * getNSAFT() + 36 * Math.pow(getNSAFT(), 2) - - 8 * Math.pow(getNSAFT(), 3)) - / (Math.pow((1.0 - getNSAFT()), 2) - * Math.pow((2.0 - getNSAFT()), 4)) - + (24 * (1.0 - getmSAFT())) - * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) - + 12 * Math.pow(getNSAFT(), 3) - - 2 * Math.pow(getNSAFT(), 4)) - / (Math.pow((1.0 - getNSAFT()), 5) - * Math.pow((2.0 - getNSAFT()), 2)) - + (36 * (1.0 - getmSAFT())) - * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) - + 12 * Math.pow(getNSAFT(), 3) - - 2 * Math.pow(getNSAFT(), 4)) - / (Math.pow((1.0 - getNSAFT()), 4) - * Math.pow((2.0 - getNSAFT()), 3)) - + (36 * (1.0 - getmSAFT())) - * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) - + 12 * Math.pow(getNSAFT(), 3) - - 2 * Math.pow(getNSAFT(), 4)) - / (Math.pow((1.0 - getNSAFT()), 3) - * Math.pow((2.0 - getNSAFT()), 4)) - + (24 * (1.0 - getmSAFT())) - * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) - + 12 * Math.pow(getNSAFT(), 3) - - 2 * Math.pow(getNSAFT(), 4)) - / (Math.pow((1.0 - getNSAFT()), 2) - * Math.pow((2.0 - getNSAFT()), 5))) - / Math.pow((1.0 - + getmSAFT() * (8.0 * getNSAFT() - 2.0 * Math.pow(getNSAFT(), 2)) - / Math.pow((1.0 - getNSAFT()), 4) - + (1.0 - getmSAFT()) - * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) - + 12 * Math.pow(getNSAFT(), 3) - - 2 * Math.pow(getNSAFT(), 4)) - / (Math.pow((1.0 - getNSAFT()), 2) - * Math.pow((2.0 - getNSAFT()), 2))), - 2); - - return temp; - } + double dgHSSAFTdNdNdN = 1.0; - // added by rahmat - /** - *

- * calcdF2dispZHCdT. - *

- * - * @return a double - */ - public double calcdF2dispZHCdT() { - double temp0 = -Math.pow(F2dispZHC, 2.0); - double temp1 = getmSAFT() - * ((8 - 4 * getNSAFT()) * dNSAFTdT * Math.pow(1 - getNSAFT(), 4) - + 4 * Math.pow(1 - getNSAFT(), 3) * dNSAFTdT - * (8 * getNSAFT() - 2 * Math.pow(getNSAFT(), 2))) - / Math.pow(1 - getNSAFT(), 8); - double temp2a = (1 - getmSAFT()) - * (20 - 54 * getNSAFT() + 36 * Math.pow(getNSAFT(), 2) - + 8 * Math.pow(getNSAFT(), 3)) - * dNSAFTdT * Math.pow((1 - getNSAFT()) * (2 - getNSAFT()), 2); - double temp2b = (1 - getmSAFT()) * 2 * ((1 - getNSAFT()) * (2 - getNSAFT())) - * (-1 * dNSAFTdT * (2 - getNSAFT()) + (-1) * dNSAFTdT * (1 - getNSAFT())) - * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) + 12 * Math.pow(getNSAFT(), 3) - - 2 * Math.pow(getNSAFT(), 4)); - double temp2 = (temp2a - temp2b) / Math.pow((1 - getNSAFT()) * (2 - getNSAFT()), 4); - return temp0 * (temp1 + temp2); - } + // by Rahmat + double dNSAFTdT = 1.0; + double dF1dispVolTermdT = 0.0; + double dF1dispI1dT = 1.0; - /** {@inheritDoc} */ - @Override - public double calcmSAFT() { - double temp2 = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - temp2 += getComponent(i).getNumberOfMolesInPhase() * getComponent(i).getmSAFTi() - / getNumberOfMolesInPhase(); - } + double dF2dispI2dT = 1.0; - return temp2; - } - - /** {@inheritDoc} */ - @Override - public double calcF1dispSumTerm() { - double temp1 = 0.0; - - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < numberOfComponents; j++) { - temp1 += getComponent(i).getNumberOfMolesInPhase() - * getComponent(j).getNumberOfMolesInPhase() * getComponent(i).getmSAFTi() - * getComponent(j).getmSAFTi() - * Math.sqrt(getComponent(i).getEpsikSAFT() / temperature - * getComponent(j).getEpsikSAFT() / temperature) - * (1.0 - mixRule.getBinaryInteractionParameter(i, j)) - * Math.pow(0.5 * (getComponent(i).getSigmaSAFTi() - + getComponent(j).getSigmaSAFTi()), 3.0); - } - } - return temp1 / Math.pow(getNumberOfMolesInPhase(), 2.0); - } - - // added by rahmat - /** - *

- * calcdF1dispSumTermdT. - *

- * - * @return a double - */ - public double calcdF1dispSumTermdT() { - double temp1 = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < numberOfComponents; j++) { - temp1 += getComponent(i).getNumberOfMolesInPhase() - * getComponent(j).getNumberOfMolesInPhase() * getComponent(i).getmSAFTi() - * getComponent(j).getmSAFTi() - * Math.sqrt(getComponent(i).getEpsikSAFT() / temperature - * getComponent(j).getEpsikSAFT() / temperature) - * (1.0 - mixRule.getBinaryInteractionParameter(i, j)) - * Math.pow(0.5 * (getComponent(i).getSigmaSAFTi() - + getComponent(j).getSigmaSAFTi()), 3.0) - * (-1 / temperature); - } - } - return temp1 / Math.pow(getNumberOfMolesInPhase(), 2.0); - } - - /** - *

- * calcdF2dispSumTermdT. - *

- * - * @return a double - */ - public double calcdF2dispSumTermdT() { - double temp1 = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < numberOfComponents; j++) { - temp1 += getComponent(i).getNumberOfMolesInPhase() - * getComponent(j).getNumberOfMolesInPhase() * getComponent(i).getmSAFTi() - * getComponent(j).getmSAFTi() - * (getComponent(i).getEpsikSAFT() / temperature - * getComponent(j).getEpsikSAFT() / temperature) - * Math.pow(1.0 - mixRule.getBinaryInteractionParameter(i, j), 2) - * Math.pow(0.5 * (getComponent(i).getSigmaSAFTi() - + getComponent(j).getSigmaSAFTi()), 3.0) - * (-2 / temperature); - } - } - return temp1 / Math.pow(getNumberOfMolesInPhase(), 2.0); - } - - /** {@inheritDoc} */ - @Override - public double calcF2dispSumTerm() { - double temp1 = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < numberOfComponents; j++) { - temp1 += getComponent(i).getNumberOfMolesInPhase() - * getComponent(j).getNumberOfMolesInPhase() * getComponent(i).getmSAFTi() - * getComponent(j).getmSAFTi() * getComponent(i).getEpsikSAFT() / temperature - * getComponent(j).getEpsikSAFT() / temperature - * Math.pow((1.0 - mixRule.getBinaryInteractionParameter(i, j)), 2.0) - * Math.pow(0.5 * (getComponent(i).getSigmaSAFTi() - + getComponent(j).getSigmaSAFTi()), 3.0); - } - } - return temp1 / Math.pow(getNumberOfMolesInPhase(), 2.0); - } + double dF2dispZHCdT = 1.0; + double dF1dispSumTermdT = 1.0; - /** {@inheritDoc} */ - @Override - public double calcF1dispI1dN() { - double temp1 = 0.0; - for (int i = 1; i < 7; i++) { - temp1 += i * getaSAFT(i, getmSAFT(), aConstSAFT) * Math.pow(getNSAFT(), i - 1.0); - } - return temp1; - } + double dF2dispSumTermdT = 1.0; - /** {@inheritDoc} */ - @Override - public double calcF1dispI1dNdN() { - double temp1 = 0.0; - for (int i = 2; i < 7; i++) { - temp1 += (i - 1.0) * i * getaSAFT(i, getmSAFT(), aConstSAFT) - * Math.pow(getNSAFT(), i - 2.0); - } - return temp1; - } + int useHS = 1; - // added by Rahmat - /** - *

- * calcF1dispI1dNdNdN. - *

- * - * @return a double - */ - public double calcF1dispI1dNdNdN() { - double temp1 = 0.0; - for (int i = 2; i < 7; i++) { - temp1 += (i - 1.0) * (i - 2.0) * i * getaSAFT(i, getmSAFT(), aConstSAFT) - * Math.pow(getNSAFT(), i - 3.0); - } - return temp1; - } + int useDISP1 = 1; - /** {@inheritDoc} */ - @Override - public double calcF1dispI1dm() { - double temp1 = 0.0; - for (int i = 0; i < 7; i++) { - temp1 += getaSAFTdm(i, getmSAFT(), aConstSAFT) * Math.pow(getNSAFT(), i); - } - return temp1; - } + int useDISP2 = 1; - /** {@inheritDoc} */ - @Override - public double calcF2dispI2dN() { - double temp1 = 0.0; - for (int i = 1; i < 7; i++) { - temp1 += i * getaSAFT(i, getmSAFT(), bConstSAFT) * Math.pow(getNSAFT(), i - 1.0); - } - return temp1; - } + private double[][] aConstSAFT = { + {0.9105631445, 0.6361281449, 2.6861347891, -26.547362491, 97.759208784, -159.59154087, + 91.297774084}, + {-0.3084016918, 0.1860531159, -2.5030047259, 21.419793629, -65.255885330, 83.318680481, + -33.746922930}, + {-0.0906148351, 0.4527842806, 0.5962700728, -1.7241829131, -4.1302112531, 13.776631870, + -8.6728470368}}; + private double[][] bConstSAFT = { + {0.7240946941, 2.2382791861, -4.0025849485, -21.003576815, 26.855641363, 206.55133841, + -355.60235612}, + {-0.5755498075, 0.6995095521, 3.8925673390, -17.215471648, 192.67226447, -161.82646165, + -165.20769346}, + {0.0976883116, -0.2557574982, -9.1558561530, 20.642075974, -38.804430052, 93.626774077, + -29.666905585}}; + private double F1dispVolTerm = 1.0; - /** {@inheritDoc} */ - @Override - public double calcF2dispI2dNdN() { - double temp1 = 0.0; - for (int i = 2; i < 7; i++) { - temp1 += (i - 1.0) * i * getaSAFT(i, getmSAFT(), bConstSAFT) - * Math.pow(getNSAFT(), i - 2.0); - } - return temp1; - } - - /** - *

- * calcF2dispI2dNdNdN. - *

- * - * @return a double - */ - public double calcF2dispI2dNdNdN() { - double temp1 = 0.0; - for (int i = 2; i < 7; i++) { - temp1 += (i - 1.0) * (i - 2.0) * i * getaSAFT(i, getmSAFT(), bConstSAFT) - * Math.pow(getNSAFT(), i - 3.0); - } - return temp1; - } + private double F1dispSumTerm = 1.0; - /** {@inheritDoc} */ - @Override - public double calcF2dispI2dm() { - double temp1 = 0.0; - for (int i = 0; i < 7; i++) { - temp1 += getaSAFTdm(i, getmSAFT(), bConstSAFT) * Math.pow(getNSAFT(), i); - } - return temp1; - } + private double F1dispI1 = 1.0; - /** {@inheritDoc} */ - @Override - public double calcF1dispI1() { - double temp1 = 0.0; - for (int i = 0; i < 7; i++) { - temp1 += getaSAFT(i, getmSAFT(), aConstSAFT) * Math.pow(getNSAFT(), i); - } - return temp1; - } + private double F2dispI2 = 1.0; - // added by rahmat - /** - *

- * calcdF1dispI1dT. - *

- * - * @return a double - */ - public double calcdF1dispI1dT() { - double temp1 = 0.0; - for (int i = 0; i < 7; i++) { - temp1 += getaSAFT(i, getmSAFT(), aConstSAFT) * i * Math.pow(getNSAFT(), i - 1) - * dNSAFTdT; - } - return temp1; - } + private double F2dispZHC = 1.0; - /** - *

- * calcdF2dispI2dT. - *

- * - * @return a double - */ - public double calcdF2dispI2dT() { - double temp1 = 0.0; - for (int i = 0; i < 7; i++) { - temp1 += getaSAFT(i, getmSAFT(), bConstSAFT) * i * Math.pow(getNSAFT(), i - 1) - * dNSAFTdT; - } - return temp1; - } + private double F2dispZHCdN = 1.0; - /** {@inheritDoc} */ - @Override - public double calcF2dispI2() { - double temp1 = 0.0; - for (int i = 0; i < 7; i++) { - temp1 += getaSAFT(i, getmSAFT(), bConstSAFT) * Math.pow(getNSAFT(), i); - } - return temp1; - } + private double F2dispZHCdm = 1.0; - /** {@inheritDoc} */ - @Override - public double getaSAFT(int i, double m, double ab[][]) { - return ab[0][i] + (m - 1.0) / m * ab[1][i] + (m - 1.0) / m * (m - 2.0) / m * ab[2][i]; - } + private double F2dispZHCdV = 1.0; - /** {@inheritDoc} */ - @Override - public double getaSAFTdm(int i, double m, double ab[][]) { - return (m - (m - 1.0)) / (m * m) * ab[1][i] - + ((2.0 * m - 3.0) * m * m - 2 * m * (m * m - 3 * m + 2)) / Math.pow(m, 4.0) - * ab[2][i]; - } + private double F2dispI2dVdV; - /** {@inheritDoc} */ - @Override - public double calcmdSAFT() { - double temp2 = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - temp2 += getComponent(i).getNumberOfMolesInPhase() / getNumberOfMolesInPhase() - * getComponent(i).getmSAFTi() - * Math.pow(((ComponentPCSAFT) getComponent(i)).getdSAFTi(), 3.0); - } - - return temp2; - } + private double F2dispI2dVdVdV = 0.0; - /** {@inheritDoc} */ - @Override - public double calcmmin1SAFT() { - double temp2 = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - temp2 += getComponent(i).getNumberOfMolesInPhase() / getNumberOfMolesInPhase() - * (getComponent(i).getmSAFTi() - 1.0); - } + private double F2dispZHCdVdV = 1.0; - return temp2; - } + private double F2dispZHCdVdVdV = 1.0; - /** {@inheritDoc} */ - @Override - public double calcdmeanSAFT() { - double temp = 0.0, temp2 = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - temp += getComponent(i).getNumberOfMolesInPhase() * getComponent(i).getmSAFTi() - * Math.pow(((ComponentPCSAFT) getComponent(i)).getdSAFTi(), 3.0); - temp2 += getComponent(i).getNumberOfMolesInPhase() * getComponent(i).getmSAFTi(); - } - return Math.pow(temp / temp2, 1.0 / 3.0); - } + private double F1dispI1dNdN = 1.0; - // need to check (modified by rahmat) - /** {@inheritDoc} */ - @Override - public double calcdSAFT() { - double temp1 = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - temp1 += getComponent(i).getNumberOfMolesInPhase() * getComponent(i).getmSAFTi() - * Math.pow(((ComponentPCSAFT) getComponent(i)).getdSAFTi(), 3.0); - } - // System.out.println("d saft calc " + temp/getNumberOfMolesInPhase()); - return temp1 / getNumberOfMolesInPhase(); - } + private double F1dispI1dNdNdN = 1.0; - /** {@inheritDoc} */ - @Override - public double getNSAFT() { - return nSAFT; - } + private double F1dispVolTermdV = 1.0; - /** {@inheritDoc} */ - @Override - public void setNSAFT(double nSAFT) { - this.nSAFT = nSAFT; - } + private double F1dispVolTermdVdV = 1.0; - /** {@inheritDoc} */ - @Override - public double getDSAFT() { - return dSAFT; - } + private double F1dispI1dN = 1.0; - /** {@inheritDoc} */ - @Override - public void setDSAFT(double dSAFT) { - this.dSAFT = dSAFT; - } + private double F1dispI1dm = 1.0; - /** {@inheritDoc} */ - @Override - public double getGhsSAFT() { - return ghsSAFT; - } + private double F1dispI1dV = 1.0; - /** {@inheritDoc} */ - @Override - public void setGhsSAFT(double ghsSAFT) { - this.ghsSAFT = ghsSAFT; - } + private double F2dispI2dV = 1.0; - /** {@inheritDoc} */ - @Override - public double F_HC_SAFT() { - return getNumberOfMolesInPhase() - * (getmSAFT() * getAHSSAFT() - getMmin1SAFT() * Math.log(getGhsSAFT()));/// (ThermodynamicConstantsInterface.R*temperature); - } + private double F2dispI2dN = 1.0; - /** {@inheritDoc} */ - @Override - public double dF_HC_SAFTdV() { - return getNumberOfMolesInPhase() * (getmSAFT() * daHSSAFTdN * getDnSAFTdV() - - getMmin1SAFT() * 1.0 / getGhsSAFT() * getDgHSSAFTdN() * getDnSAFTdV());/// (ThermodynamicConstantsInterface.R*temperature); - } + private double F2dispI2dm = 1.0; - // edited by Rahmat - /** {@inheritDoc} */ - @Override - public double dFdT() { - return useHS * dF_HC_SAFTdT() + useDISP1 * dF_DISP1_SAFTdT() + useDISP2 * dF_DISP2_SAFTdT(); - } + private double F2dispSumTerm = 0.0; - /** - *

- * dF_HC_SAFTdT. - *

- * - * @return a double - */ - public double dF_HC_SAFTdT() { - return getNumberOfMolesInPhase() * (getmSAFT() * daHSSAFTdN * dNSAFTdT - - getMmin1SAFT() * 1.0 / getGhsSAFT() * getDgHSSAFTdN() * dNSAFTdT);/// (ThermodynamicConstantsInterface.R*temperature); - } + private double F2dispZHCdNdN = 1.0; - /** {@inheritDoc} */ - @Override - public double dF_HC_SAFTdVdV() { - return getNumberOfMolesInPhase() - * (getmSAFT() * daHSSAFTdNdN * getDnSAFTdV() * getDnSAFTdV() - + getmSAFT() * daHSSAFTdN * dnSAFTdVdV - + getMmin1SAFT() * Math.pow(getGhsSAFT(), -2.0) - * Math.pow(getDgHSSAFTdN(), 2.0) * getDnSAFTdV() * getDnSAFTdV() - - getMmin1SAFT() * Math.pow(getGhsSAFT(), -1.0) * dgHSSAFTdNdN * dnSAFTdV - * dnSAFTdV - - getMmin1SAFT() * 1.0 / getGhsSAFT() * getDgHSSAFTdN() * dnSAFTdVdV); // (ThermodynamicConstantsInterface.R*temperature); - } - // additonal dF_HC_SAFTdVdVdV (by Rahmat) - - /** {@inheritDoc} */ - @Override - public double dF_HC_SAFTdVdVdV() { - return getNumberOfMolesInPhase() - * (getmSAFT() * daHSSAFTdNdNdN * getDnSAFTdV() * getDnSAFTdV() * getDnSAFTdV() - + getmSAFT() * daHSSAFTdNdN * 2.0 * dnSAFTdV * dnSAFTdVdV - + getmSAFT() * daHSSAFTdNdN * dnSAFTdV * dnSAFTdVdV - + getmSAFT() * daHSSAFTdN * dnSAFTdVdVdV - - 2.0 * getMmin1SAFT() * Math.pow(getGhsSAFT(), -3.0) - * Math.pow(getDgHSSAFTdN(), 3.0) * getDnSAFTdV() * getDnSAFTdV() - * getDnSAFTdV() - + getMmin1SAFT() * Math.pow(getGhsSAFT(), -2.0) * 2.0 * getDgHSSAFTdN() - * dgHSSAFTdNdN * getDnSAFTdV() * getDnSAFTdV() * getDnSAFTdV() - + getMmin1SAFT() * Math.pow(getGhsSAFT(), -2.0) - * Math.pow(getDgHSSAFTdN(), 2.0) * 2.0 * getDnSAFTdV() * dnSAFTdVdV - + getMmin1SAFT() * Math.pow(getGhsSAFT(), -2.0) * getDgHSSAFTdN() - * dgHSSAFTdNdN * dnSAFTdV * dnSAFTdV * dnSAFTdV - - getMmin1SAFT() * Math.pow(getGhsSAFT(), -1.0) * dgHSSAFTdNdNdN * dnSAFTdV - * dnSAFTdV * dnSAFTdV - - getMmin1SAFT() * Math.pow(getGhsSAFT(), -1.0) * dgHSSAFTdNdN * 2.0 - * dnSAFTdV * dnSAFTdVdV - + getMmin1SAFT() * Math.pow(getGhsSAFT(), -2.0) - * Math.pow(getDgHSSAFTdN(), 2) * dnSAFTdV * dnSAFTdVdV - - getMmin1SAFT() * Math.pow(getGhsSAFT(), -1.0) * dgHSSAFTdNdN * dnSAFTdV - * dnSAFTdVdV - - getMmin1SAFT() * Math.pow(getGhsSAFT(), -1.0) * getDgHSSAFTdN() - * dnSAFTdVdVdV); - } + private double F2dispZHCdNdNdN = 1.0; - /** {@inheritDoc} */ - @Override - public double F_DISP1_SAFT() { - return getNumberOfMolesInPhase() * (-2.0 * ThermodynamicConstantsInterface.pi - * getF1dispVolTerm() * getF1dispSumTerm() * getF1dispI1());/// (ThermodynamicConstantsInterface.R*temperature); - } + private double F2dispI2dNdN = 1.0; - /** {@inheritDoc} */ - @Override - public double dF_DISP1_SAFTdV() { - return getNumberOfMolesInPhase() * (-2.0 * ThermodynamicConstantsInterface.pi - * F1dispVolTermdV * getF1dispSumTerm() * getF1dispI1() - - 2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTerm * getF1dispSumTerm() - * F1dispI1dV);/// (ThermodynamicConstantsInterface.R*temperature); - } + private double F2dispI2dNdNdN = 1.0; - /** {@inheritDoc} */ - @Override - public double dF_DISP1_SAFTdVdV() { - return getNumberOfMolesInPhase() * ((-2.0 * ThermodynamicConstantsInterface.pi - * F1dispVolTermdVdV * getF1dispSumTerm() * getF1dispI1()) - + (-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTermdV * getF1dispSumTerm() - * F1dispI1dV) - + (-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTermdV * getF1dispSumTerm() - * F1dispI1dV) - + (-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTerm * getF1dispSumTerm() - * F1dispI1dVdV)); - } + private double F1dispI1dVdV = 1.0; - // added by Rahmat - /** - *

- * dF_DISP1_SAFTdVdVdV. - *

- * - * @return a double - */ - public double dF_DISP1_SAFTdVdVdV() { - return getNumberOfMolesInPhase() * ((-2.0 * ThermodynamicConstantsInterface.pi - * F1dispVolTermdVdVdV * getF1dispSumTerm() * getF1dispI1()) - + (-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTermdVdV - * getF1dispSumTerm() * F1dispI1dV) - + (-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTermdVdV - * getF1dispSumTerm() * F1dispI1dV) - + (-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTermdV * getF1dispSumTerm() - * F1dispI1dVdV) - + (-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTermdVdV - * getF1dispSumTerm() * F1dispI1dV) - + (-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTermdV * getF1dispSumTerm() - * F1dispI1dVdV) - + (-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTermdV * getF1dispSumTerm() - * F1dispI1dVdV) - + (-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTerm * getF1dispSumTerm() - * F1dispI1dVdVdV)); - } + private double F1dispI1dVdVdV = 1.0; - // added by Rahmat - /** - *

- * dF_DISP1_SAFTdT. - *

- * - * @return a double - */ - public double dF_DISP1_SAFTdT() { - return getNumberOfMolesInPhase() * (-2.0 * ThermodynamicConstantsInterface.pi - * (dF1dispVolTermdT * getF1dispSumTerm() * getF1dispI1() - + dF1dispSumTermdT * getF1dispVolTerm() * getF1dispI1() - + dF1dispI1dT * getF1dispVolTerm() * getF1dispSumTerm())); - } + private double F1dispVolTermdVdVdV = 1.0; + static Logger logger = LogManager.getLogger(PhasePCSAFTRahmat.class); - /** - *

- * dF_DISP2_SAFTdT. - *

- * - * @return a double - */ - public double dF_DISP2_SAFTdT() { - return getNumberOfMolesInPhase() * (-1 * ThermodynamicConstantsInterface.pi * getmSAFT()) - * getF1dispVolTerm() - * (dF2dispSumTermdT * getF2dispI2() * getF2dispZHC() - + dF2dispI2dT * getF2dispSumTerm() * getF2dispZHC() - + dF2dispZHCdT * getF2dispSumTerm() * getF2dispI2()); - } + /** + *

+ * Constructor for PhasePCSAFTRahmat. + *

+ */ + public PhasePCSAFTRahmat() { + super(); + } - /** {@inheritDoc} */ - @Override - public double F_DISP2_SAFT() { - return getNumberOfMolesInPhase() * (-ThermodynamicConstantsInterface.pi * getmSAFT() - * getF1dispVolTerm() * getF2dispSumTerm() * getF2dispI2() * getF2dispZHC());/// (ThermodynamicConstantsInterface.R*temperature); + /** {@inheritDoc} */ + @Override + public PhasePCSAFTRahmat clone() { + PhasePCSAFTRahmat clonedPhase = null; + try { + clonedPhase = (PhasePCSAFTRahmat) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); } - /** {@inheritDoc} */ - @Override - public double dF_DISP2_SAFTdV() { - return getNumberOfMolesInPhase() * (-ThermodynamicConstantsInterface.pi * getmSAFT() - * F1dispVolTermdV * getF2dispSumTerm() * getF2dispI2() * getF2dispZHC() - - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm - * getF2dispSumTerm() * F2dispI2dV * getF2dispZHC() - - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm - * getF2dispSumTerm() * getF2dispI2() * F2dispZHCdV);/// (ThermodynamicConstantsInterface.R*temperature); - } + return clonedPhase; + } - /** {@inheritDoc} */ - @Override - public double dF_DISP2_SAFTdVdV() { - return getNumberOfMolesInPhase() * ((-ThermodynamicConstantsInterface.pi * getmSAFT() - * F1dispVolTermdVdV * getF2dispSumTerm() * getF2dispI2() * getF2dispZHC()) - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV - * getF2dispSumTerm() * getF2dispZHC() * F2dispI2dV) - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV - * getF2dispSumTerm() * getF2dispI2() * F2dispZHCdV) - - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV - * getF2dispSumTerm() * F2dispI2dV * getF2dispZHC() - - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm - * getF2dispSumTerm() * F2dispI2dVdV * getF2dispZHC() - - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm - * getF2dispSumTerm() * F2dispI2dV * F2dispZHCdV - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV - * getF2dispSumTerm() * getF2dispI2() * F2dispZHCdV) - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm - * getF2dispSumTerm() * F2dispI2dV * F2dispZHCdV) - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm - * getF2dispSumTerm() * getF2dispI2() * F2dispZHCdVdV)); - } + /** {@inheritDoc} */ + @Override + public void addcomponent(String componentName, double moles, double molesInPhase, + int compNumber) { + super.addcomponent(molesInPhase); + componentArray[compNumber] = + new ComponentPCSAFT(componentName, moles, molesInPhase, compNumber); + } - /** - *

- * dF_DISP2_SAFTdVdVdV. - *

- * - * @return a double - */ - public double dF_DISP2_SAFTdVdVdV() { - return getNumberOfMolesInPhase() * ((-ThermodynamicConstantsInterface.pi * getmSAFT() - * F1dispVolTermdVdVdV * getF2dispSumTerm() * getF2dispI2() * getF2dispZHC()) - + (-ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdVdV - * getF2dispSumTerm() * F2dispI2dV * getF2dispZHC()) - + (-ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdVdV - * getF2dispSumTerm() * getF2dispI2() * F2dispZHCdV) - + -(ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdVdV - * getF2dispSumTerm() * getF2dispZHC() * F2dispI2dV) - + -(ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV - * getF2dispSumTerm() * F2dispZHCdV * F2dispI2dV) - + -(ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV - * getF2dispSumTerm() * getF2dispZHC() * F2dispI2dVdV) - + -(ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdVdV - * getF2dispSumTerm() * getF2dispI2() * F2dispZHCdV) - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV - * getF2dispSumTerm() * F2dispI2dV * F2dispZHCdV) - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV - * getF2dispSumTerm() * getF2dispI2() * F2dispZHCdVdV) - - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdVdV - * getF2dispSumTerm() * F2dispI2dV * getF2dispZHC() - - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV - * getF2dispSumTerm() * F2dispI2dVdV * getF2dispZHC() - - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV - * getF2dispSumTerm() * F2dispI2dV * F2dispZHCdV - - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV - * getF2dispSumTerm() * F2dispI2dVdV * getF2dispZHC() - - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm - * getF2dispSumTerm() * F2dispI2dVdVdV * getF2dispZHC() - - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm - * getF2dispSumTerm() * F2dispI2dVdV * F2dispZHCdV - - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV - * getF2dispSumTerm() * F2dispI2dV * F2dispZHCdV - - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm - * getF2dispSumTerm() * F2dispI2dVdV * F2dispZHCdV - - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm - * getF2dispSumTerm() * F2dispI2dV * F2dispZHCdVdV - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdVdV - * getF2dispSumTerm() * getF2dispI2() * F2dispZHCdV) - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV - * getF2dispSumTerm() * F2dispI2dV * F2dispZHCdV) - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV - * getF2dispSumTerm() * getF2dispI2() * F2dispZHCdVdV) - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV - * getF2dispSumTerm() * F2dispI2dV * F2dispZHCdV) - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm - * getF2dispSumTerm() * F2dispI2dVdV * F2dispZHCdV) - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm - * getF2dispSumTerm() * F2dispI2dV * F2dispZHCdVdV) - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV - * getF2dispSumTerm() * getF2dispI2() * F2dispZHCdVdV) - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm - * getF2dispSumTerm() * F2dispI2dV * F2dispZHCdVdV) - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm - * getF2dispSumTerm() * getF2dispI2() * F2dispZHCdVdVdV) - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdVdV - * getF2dispSumTerm() * getF2dispI2() * F2dispZHCdV) - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV - * getF2dispSumTerm() * F2dispI2dV * F2dispZHCdV) - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV - * getF2dispSumTerm() * getF2dispI2() * F2dispZHCdVdV) - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV - * getF2dispSumTerm() * F2dispI2dV * F2dispZHCdV) - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm - * getF2dispSumTerm() * F2dispI2dVdV * F2dispZHCdV) - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm - * getF2dispSumTerm() * F2dispI2dV * F2dispZHCdVdV) - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV - * getF2dispSumTerm() * getF2dispI2() * F2dispZHCdVdV) - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm - * getF2dispSumTerm() * F2dispI2dV * F2dispZHCdVdV) - - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm - * getF2dispSumTerm() * getF2dispI2() * F2dispZHCdVdVdV)); + /** {@inheritDoc} */ + @Override + public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, + double beta) { + for (int i = 0; i < numberOfComponents; i++) { + componentArray[i].Finit(this, temperature, pressure, totalNumberOfMoles, beta, + numberOfComponents, type); } + super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + } - /** {@inheritDoc} */ - @Override - public double getF() { - // System.out.println("F-HC " + useHS*F_HC_SAFT()); - - // System.out.println("F-DISP1 " + useDISP1*F_DISP1_SAFT()); - - // System.out.println("F-DISP2 " + useDISP2*F_DISP2_SAFT()); - return useHS * F_HC_SAFT() + useDISP1 * F_DISP1_SAFT() + useDISP2 * F_DISP2_SAFT(); - } - - /** {@inheritDoc} */ - @Override - public double dFdV() { - // System.out.println("N-saft " + getNSAFT()); - // System.out.println("F-HC " + useHS*F_HC_SAFT()); - // System.out.println("F-DISP1 " + useDISP1*F_DISP1_SAFT()); - - // System.out.println("F-DISP2 " + useDISP2*F_DISP2_SAFT()); - - return (useHS * dF_HC_SAFTdV() + useDISP1 * dF_DISP1_SAFTdV() - + useDISP2 * dF_DISP2_SAFTdV()) * 1.0e-5; - } - - /** {@inheritDoc} */ - @Override - public double dFdVdV() { - return (useHS * dF_HC_SAFTdVdV() + useDISP1 * dF_DISP1_SAFTdVdV() - + useDISP2 * dF_DISP2_SAFTdVdV()) * 1.0e-10; - } - - /** {@inheritDoc} */ - @Override - public double dFdVdVdV() { - return (useHS * dF_HC_SAFTdVdVdV() + useDISP1 * dF_DISP1_SAFTdVdVdV() - + useDISP2 * dF_DISP2_SAFTdVdVdV()) * 1.0e-20; - } - - /** {@inheritDoc} */ - @Override - public double getmdSAFT() { - return mdSAFT; - } - - /** {@inheritDoc} */ - @Override - public void setmdSAFT(double mdSAFT) { - this.mdSAFT = mdSAFT; - } - - /** {@inheritDoc} */ - @Override - public double getmSAFT() { - return mSAFT; - } - - /** {@inheritDoc} */ - @Override - public void setmSAFT(double mSAFT) { - this.mSAFT = mSAFT; - } - - /** {@inheritDoc} */ - @Override - public double getAHSSAFT() { - return aHSSAFT; - } - - /** {@inheritDoc} */ - @Override - public void setAHSSAFT(double aHSSAFT) { - this.aHSSAFT = aHSSAFT; - } - - /** {@inheritDoc} */ - @Override - public double getMmin1SAFT() { - return mmin1SAFT; - } - - /** {@inheritDoc} */ - @Override - public void setMmin1SAFT(double mmin1SAFT) { - this.mmin1SAFT = mmin1SAFT; - } - - /** {@inheritDoc} */ - @Override - public double getVolumeSAFT() { - return volumeSAFT; - } - - /** {@inheritDoc} */ - @Override - public void setVolumeSAFT(double volumeSAFT) { - this.volumeSAFT = volumeSAFT; - } - - /** {@inheritDoc} */ - @Override - public double getDgHSSAFTdN() { - return dgHSSAFTdN; - } - - /** {@inheritDoc} */ - @Override - public void setDgHSSAFTdN(double dgHSSAFTdN) { - this.dgHSSAFTdN = dgHSSAFTdN; - } - - /** {@inheritDoc} */ - @Override - public double getDnSAFTdV() { - return dnSAFTdV; - } + /** {@inheritDoc} */ + @Override + public void volInit() { + volumeSAFT = getVolume() * 1.0e-5; + setDmeanSAFT(calcdmeanSAFT()); + setDSAFT(calcdSAFT()); + // System.out.println("saft volume " + getVolumeSAFT()); + // System.out.println("dsaft " + getDSAFT()); + setNSAFT(1.0 * ThermodynamicConstantsInterface.pi / 6.0 + * ThermodynamicConstantsInterface.avagadroNumber * getNumberOfMolesInPhase() / volumeSAFT + * getDSAFT()); + dnSAFTdV = -1.0 * ThermodynamicConstantsInterface.pi / 6.0 + * ThermodynamicConstantsInterface.avagadroNumber * getNumberOfMolesInPhase() + / Math.pow(volumeSAFT, 2.0) * getDSAFT(); + dnSAFTdVdV = 2.0 * ThermodynamicConstantsInterface.pi / 6.0 + * ThermodynamicConstantsInterface.avagadroNumber * getNumberOfMolesInPhase() + / Math.pow(volumeSAFT, 3.0) * getDSAFT(); + // System.out.println("N SAFT " + getNSAFT()); + dnSAFTdVdVdV = -6.0 * ThermodynamicConstantsInterface.pi / 6.0 + * ThermodynamicConstantsInterface.avagadroNumber * getNumberOfMolesInPhase() + / Math.pow(volumeSAFT, 4.0) * getDSAFT(); // added by rahmat - /** - *

- * getdDSAFTdT. - *

- * - * @return a double - */ - public double getdDSAFTdT() { - double temp = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - temp += getComponent(i).getNumberOfMolesInPhase() * getComponent(i).getmSAFTi() - / getNumberOfMolesInPhase() * 3 - * Math.pow(((ComponentPCSAFT) getComponent(i)).getdSAFTi(), 2.0) - * (-1.08 / Math.pow(temperature, 2)) - * Math.pow(getComponent(i).getSigmaSAFTi(), 3) - * Math.pow( - 1 - 0.12 * Math.exp(-3 * getComponent(i).getEpsikSAFT() / temperature), - 2) - * getComponent(i).getEpsikSAFT() - * Math.exp(-3 * getComponent(i).getEpsikSAFT() / temperature); - } - return temp; - } - - /** {@inheritDoc} */ - @Override - public void setDnSAFTdV(double dnSAFTdV) { - this.dnSAFTdV = dnSAFTdV; - } - - /** {@inheritDoc} */ - @Override - public double getF1dispVolTerm() { - return F1dispVolTerm; - } - - /** {@inheritDoc} */ - @Override - public void setF1dispVolTerm(double F1dispVolTerm) { - this.F1dispVolTerm = F1dispVolTerm; - } - - /** {@inheritDoc} */ - @Override - public double getF1dispSumTerm() { - return F1dispSumTerm; - } - - /** {@inheritDoc} */ - @Override - public double getF1dispI1() { - return F1dispI1; - } - - /** {@inheritDoc} */ - @Override - public double getF2dispI2() { - return F2dispI2; - } - - /** {@inheritDoc} */ - @Override - public void setF2dispI2(double F2dispI2) { - this.F2dispI2 = F2dispI2; - } - - /** {@inheritDoc} */ - @Override - public double getF2dispZHC() { - return F2dispZHC; - } - - /** {@inheritDoc} */ - @Override - public void setF2dispZHC(double F2dispZHC) { - this.F2dispZHC = F2dispZHC; - } - - /** {@inheritDoc} */ - @Override - public double getF2dispZHCdN() { - return F2dispZHCdN; - } - - /** {@inheritDoc} */ - @Override - public double getF2dispZHCdm() { - return F2dispZHCdm; - } - - /** {@inheritDoc} */ - @Override - public double molarVolume(double pressure, double temperature, double A, double B, int phase) - throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - double BonV = phase == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - // double BonV = phase== 0 ? 0.99:1e-5; - - if (BonV < 0) { - BonV = 1.0e-6; - } - if (BonV > 1.0) { - BonV = 1.0 - 1.0e-6; - } - // double BonVold = BonV; - double Btemp = 0, dh = 0, h = 0; - // double Dtemp = 0, hOld = 0, dhOld = 0, gvvv = 0, fvvv = 0, d2 = 0, dhh = 1; - double d1 = 0; - Btemp = getB(); - // Dtemp = getA(); - if (Btemp <= 0) { - logger.info("b negative in volume calc"); - } - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - int iterations = 0; - double oldMolarVolume = 0.0; - // System.out.println("volume " + getVolume()); - do { - iterations++; - this.volInit(); - oldMolarVolume = getMolarVolume(); - h = pressure - calcPressure(); - dh = -calcPressuredV(); - d1 = -h / dh; - double newVolume = getMolarVolume() + 0.9 * d1 / numberOfMolesInPhase; - if (newVolume > 1e-100) { - setMolarVolume(newVolume); - } else { - setMolarVolume(oldMolarVolume / 10.0); - } - - /* - * BonVold = BonV; //BonV = BonVold; h = BonVold - - * Btemp/numberOfMolesInPhase*dFdV()-pressure*Btemp/(numberOfMolesInPhase*R* - * temperature); dh = 1.0 + - * Btemp/Math.pow(BonVold,2.0)*(Btemp/numberOfMolesInPhase*dFdVdV()); //dhh = - * -2.0*Btemp/Math.pow(BonV,3.0)*(Btemp/numberOfMolesInPhase*dFdVdV())-Math.pow( - * Btemp,2.0)/Math.pow(BonV,4.0)*(Btemp/numberOfMolesInPhase*dFdVdVdV()); - * - * //made by Rahmat - * - * BonV = BonVold - 0.5* (2* h * dh / ((2* Math.pow(dh,2) - h * dhh))); - * - * double dBonV = BonV - BonVold; dhh = (dh - dhOld)/ dBonV; dhOld = dh; - * - * hOld = h; - * - * - * //d1 = - h/dh; //d2 = - dh/dhh; //BonV += d1;//*(1.0+0.5*-1.0); /* - * if(Math.abs(d1/d2)<=1.0){ BonV += d1*(1.0+0.5*d1/d2); } else if(d1/d2<-1){ BonV += - * d1*(1.0+0.5*-1.0); } else if(d1/d2>1){ BonV += d2; double hnew = h +d2*-h/d1; - * if(Math.abs(hnew)>Math.abs(h)){ System.out.println("volume correction needed...."); - * BonV = phase== 1 ? - * 2.0/(2.0+temperature/getPseudoCriticalTemperature()):pressure*getB()/( - * numberOfMolesInPhase*temperature*R); } } - * - * if(BonV>1){ BonV=1.0-1.0e-6; BonVold=10; } if (BonV < 0) { BonV = 1.0e-16; BonVold = - * 10; } - */ - // setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - // System.out.println("BonV " + BonV); - } while (Math.abs((oldMolarVolume - getMolarVolume()) / oldMolarVolume) > 1.0e-10 - && iterations < 100); - // while(Math.abs((BonV-BonVold)/BonV)>1.0e-10 && iterations<500); - - // while(Math.abs((h-hOld)/h)>1.0e-10 && iterations<6000); - // System.out.println("error BonV " + Math.abs((BonV-BonVold)/BonV)); - // System.out.println("iterations " + iterations); - /* - * if(BonV<0){ BonV = pressure*getB()/(numberOfMolesInPhase*temperature*R); - * setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); Z = - * pressure*getMolarVolume()/(R*temperature); - * - * } if(iterations>=6000) throw new util.exception.TooManyIterationsException(); - * if(Double.isNaN(getMolarVolume())) throw new util.exception.IsNaNException(); - * - * // if(phaseType==0) System.out.println("density " + getDensity());//"BonV: " + BonV + - * " "+" itert: " + iterations +" " + " phase " + phaseType+ " " + h + " " +dh + " B " + - * Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); - */ - return getMolarVolume(); - } + dNSAFTdT = 1.0 * ThermodynamicConstantsInterface.pi / 6.0 + * ThermodynamicConstantsInterface.avagadroNumber * getNumberOfMolesInPhase() / volumeSAFT + * getdDSAFTdT(); + + setGhsSAFT((1.0 - nSAFT / 2.0) / Math.pow(1.0 - nSAFT, 3.0)); + setmSAFT(calcmSAFT()); + setMmin1SAFT(calcmmin1SAFT()); + setmdSAFT(calcmdSAFT()); + setAHSSAFT( + (4.0 * getNSAFT() - 3.0 * Math.pow(getNSAFT(), 2.0)) / Math.pow(1.0 - getNSAFT(), 2.0)); + daHSSAFTdN = ((4.0 - 6.0 * getNSAFT()) * Math.pow(1.0 - getNSAFT(), 2.0) + - (4.0 * getNSAFT() - 3 * Math.pow(getNSAFT(), 2.0)) * 2.0 * (1.0 - getNSAFT()) * (-1.0)) + / Math.pow(1.0 - getNSAFT(), 4.0); + daHSSAFTdNdN = (-6.0 * Math.pow(1.0 - getNSAFT(), 2.0) + + 2.0 * (1.0 - getNSAFT()) * (4.0 - 6 * getNSAFT())) / Math.pow(1.0 - getNSAFT(), 4.0) + + ((8.0 - 12.0 * getNSAFT()) * Math.pow(1.0 - getNSAFT(), 3.0) + + (8.0 - 6.0 * Math.pow(getNSAFT(), 2.0)) * 3.0 * Math.pow(1.0 - getNSAFT(), 2.0)) + / Math.pow(1.0 - getNSAFT(), 6.0); + daHSSAFTdNdNdN = -36 / Math.pow((1 - getNSAFT()), 3) + + (18.0 * (4.0 - 6.0 * getNSAFT())) / Math.pow((1 - getNSAFT()), 4.0) + + (24.0 * (4.0 * getNSAFT() - 3.0 * Math.pow(getNSAFT(), 2.0))) + / Math.pow((1 - getNSAFT()), 5.0); + + dgHSSAFTdN = (-0.5 * Math.pow(1.0 - getNSAFT(), 3.0) + - (1.0 - getNSAFT() / 2.0) * 3.0 * Math.pow(1.0 - nSAFT, 2.0) * (-1.0)) + / Math.pow(1.0 - getNSAFT(), 6.0); + dgHSSAFTdNdN = -3.0 / 2.0 * Math.pow(1.0 - getNSAFT(), 2.0) / Math.pow(1.0 - getNSAFT(), 6.0) + + (-3.0 / 2.0 * Math.pow(1.0 - getNSAFT(), 4.0) + + 4.0 * Math.pow(1.0 - getNSAFT(), 3.0) * (3.0 - 3.0 / 2.0 * getNSAFT())) + / Math.pow(1.0 - getNSAFT(), 8.0); + dgHSSAFTdNdNdN = -6.0 / Math.pow(1.0 - getNSAFT(), 5.0) + - (12.0 * (3.0 - 1.5 * getNSAFT())) / Math.pow(1.0 - getNSAFT(), 6.0) + + (8 * (-1.5 * Math.pow(1.0 - getNSAFT(), 4) + + 4.0 * Math.pow(1.0 - getNSAFT(), 3) * (3.0 - 1.5 * getNSAFT()))) + / Math.pow(1.0 - getNSAFT(), 9); + + setF1dispVolTerm(ThermodynamicConstantsInterface.avagadroNumber * getNumberOfMolesInPhase() + / getVolumeSAFT()); + F1dispSumTerm = calcF1dispSumTerm(); + F1dispI1 = calcF1dispI1(); + F1dispVolTermdV = -ThermodynamicConstantsInterface.avagadroNumber * getNumberOfMolesInPhase() + / Math.pow(getVolumeSAFT(), 2.0); + F1dispVolTermdVdV = 2.0 * ThermodynamicConstantsInterface.avagadroNumber + * getNumberOfMolesInPhase() / Math.pow(getVolumeSAFT(), 3.0); + F1dispVolTermdVdVdV = -6.0 * ThermodynamicConstantsInterface.avagadroNumber + * getNumberOfMolesInPhase() / Math.pow(getVolumeSAFT(), 4.0); - /** {@inheritDoc} */ - @Override - public double getDmeanSAFT() { - return dmeanSAFT; - } + // added by rahmat + dF1dispI1dT = calcdF1dispI1dT(); + dF2dispI2dT = calcdF2dispI2dT(); + dF1dispSumTermdT = calcdF1dispSumTermdT(); + dF2dispSumTermdT = calcdF2dispSumTermdT(); + dF2dispZHCdT = calcdF2dispZHCdT(); - /** {@inheritDoc} */ - @Override - public void setDmeanSAFT(double dmeanSAFT) { - this.dmeanSAFT = dmeanSAFT; - } + F1dispI1dN = calcF1dispI1dN(); + F1dispI1dNdN = calcF1dispI1dNdN(); + F1dispI1dNdNdN = calcF1dispI1dNdNdN(); - /** {@inheritDoc} */ - @Override - public double getNmSAFT() { - return nmSAFT; - } + F1dispI1dm = calcF1dispI1dm(); + F1dispI1dV = F1dispI1dN * getDnSAFTdV(); + F1dispI1dVdV = F1dispI1dNdN * getDnSAFTdV() * getDnSAFTdV() + F1dispI1dN * dnSAFTdVdV; // F1dispI1dNdN*dnSAFTdVdV; - /** {@inheritDoc} */ - @Override - public void setNmSAFT(double nmSAFT) { - this.nmSAFT = nmSAFT; - } + // added by Rahmat + F1dispI1dVdVdV = F1dispI1dNdNdN * getDnSAFTdV() * getDnSAFTdV() * getDnSAFTdV() + + F1dispI1dN * 2.0 * getDnSAFTdV() * dnSAFTdVdV + F1dispI1dNdN * dnSAFTdVdV + + F1dispI1dN * dnSAFTdVdVdV; // F1dispI1dNdN*dnSAFTdVdV; + + setF2dispSumTerm(calcF2dispSumTerm()); + setF2dispI2(calcF2dispI2()); + F2dispI2dN = calcF2dispI2dN(); + F2dispI2dNdN = calcF2dispI2dNdN(); + // added by Rahmat + F2dispI2dNdNdN = calcF2dispI2dNdNdN(); - /** {@inheritDoc} */ - @Override - public double getF2dispSumTerm() { - return F2dispSumTerm; - } + F2dispI2dm = calcF2dispI2dm(); - /** {@inheritDoc} */ - @Override - public void setF2dispSumTerm(double F2dispSumTerm) { - this.F2dispSumTerm = F2dispSumTerm; - } + F2dispI2dV = F2dispI2dN * getDnSAFTdV(); + F2dispI2dVdV = F2dispI2dNdN * getDnSAFTdV() * getDnSAFTdV() + F2dispI2dN * dnSAFTdVdV; // F2dispI2dNdN*dnSAFTdVdV;; - /** {@inheritDoc} */ - @Override - public void setF2dispZHCdm(double F2dispZHCdm) { - this.F2dispZHCdm = F2dispZHCdm; - } + // added by Rahmat + F2dispI2dVdVdV = F2dispI2dNdNdN * getDnSAFTdV() * getDnSAFTdV() * getDnSAFTdV() + + F2dispI2dN * 2.0 * getDnSAFTdV() * dnSAFTdVdV + F2dispI2dNdN * dnSAFTdVdV + + F2dispI2dN * dnSAFTdVdVdV; + + F2dispZHC = calcF2dispZHC(); + F2dispZHCdN = calcF2dispZHCdN(); + F2dispZHCdNdN = calcF2dispZHCdNdN(); + F2dispZHCdNdNdN = calcF2dispZHCdNdNdN(); + + setF2dispZHCdm(calcF2dispZHCdm()); + F2dispZHCdV = F2dispZHCdN * getDnSAFTdV(); + F2dispZHCdVdV = F2dispZHCdNdN * getDnSAFTdV() * getDnSAFTdV() + F2dispZHCdN * dnSAFTdVdV; // F2dispZHCdNdN*dnSAFTdVdV*0; + F2dispZHCdVdVdV = F2dispZHCdNdNdN * getDnSAFTdV() * getDnSAFTdV() * getDnSAFTdV() + + F2dispZHCdNdN * 2.0 * getDnSAFTdV() * dnSAFTdVdV + F2dispZHCdNdN * dnSAFTdVdV + + F2dispZHCdN * dnSAFTdVdVdV; + } + + /** {@inheritDoc} */ + @Override + public double calcF2dispZHC() { + double temp = 1.0 + + getmSAFT() * (8.0 * getNSAFT() - 2.0 * Math.pow(getNSAFT(), 2.0)) + / Math.pow(1.0 - getNSAFT(), 4.0) + + (1.0 - getmSAFT()) + * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2.0) + 12 * Math.pow(getNSAFT(), 3.0) + - 2 * Math.pow(getNSAFT(), 4.0)) + / Math.pow((1.0 - getNSAFT()) * (2.0 - getNSAFT()), 2.0); + return 1.0 / temp; + } + + /** {@inheritDoc} */ + @Override + public double calcF2dispZHCdm() { + double temp = -Math.pow(F2dispZHC, 2.0); + return temp + * ((8.0 * getNSAFT() - 2.0 * Math.pow(getNSAFT(), 2.0)) / Math.pow(1.0 - getNSAFT(), 4.0) + - (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2.0) + 12 * Math.pow(getNSAFT(), 3.0) + - 2 * Math.pow(getNSAFT(), 4.0)) + / Math.pow((1.0 - getNSAFT()) * (2.0 - getNSAFT()), 2.0)); + } + + /** {@inheritDoc} */ + @Override + public double calcF2dispZHCdN() { + double temp0 = -Math.pow(F2dispZHC, 2.0); + double temp1 = Math.pow((1.0 - getNSAFT()) * (2.0 - getNSAFT()), 2.0); + double temp2 = 20.0 * getNSAFT() - 27.0 * Math.pow(getNSAFT(), 2.0) + + 12.0 * Math.pow(getNSAFT(), 3.0) - 2.0 * Math.pow(getNSAFT(), 4.0); + // ikke rett implementert + return temp0 * (getmSAFT() + * ((8.0 - 4.0 * getNSAFT()) * Math.pow(1.0 - getNSAFT(), 4.0) + - 4.0 * Math.pow(1.0 - getNSAFT(), 3.0) * (-1.0) + * (8.0 * getNSAFT() - 2.0 * Math.pow(getNSAFT(), 2.0))) + / Math.pow(1.0 - getNSAFT(), 8.0) + + (1.0 - getmSAFT()) * ((20.0 - (2.0 * 27.0) * getNSAFT() + + (12.0 * 3.0) * Math.pow(getNSAFT(), 2.0) - 8.0 * Math.pow(getNSAFT(), 3.0)) * temp1 + - (2.0 * (2.0 - 3.0 * getNSAFT() + Math.pow(getNSAFT(), 2.0)) + * (-3.0 + 2.0 * getNSAFT())) * temp2) + / Math.pow(temp1, 2.0)); + } + + /** {@inheritDoc} */ + @Override + public double calcF2dispZHCdNdN() { + double temp0 = 2.0 * Math.pow(F2dispZHC, 3.0); + double temp1 = Math.pow((1.0 - getNSAFT()) * (2.0 - getNSAFT()), 2.0); + double temp11 = Math.pow((1.0 - getNSAFT()) * (2.0 - getNSAFT()), 3.0); + double temp2 = 20.0 * getNSAFT() - 27.0 * Math.pow(getNSAFT(), 2.0) + + 12.0 * Math.pow(getNSAFT(), 3.0) - 2.0 * Math.pow(getNSAFT(), 4.0); + + double temp1der = + 2.0 * (2.0 - 3.0 * getNSAFT() + Math.pow(getNSAFT(), 2.0)) * (-3.0 + 2.0 * getNSAFT()); + double temp11der = 3.0 * Math.pow(2.0 - 3.0 * getNSAFT() + Math.pow(getNSAFT(), 2.0), 2.0) + * (-3.0 + 2.0 * getNSAFT()); + // ikke rett implementert + double temp3 = (getmSAFT() + * ((8.0 - 4.0 * getNSAFT()) * Math.pow(1.0 - getNSAFT(), 4.0) + - 4.0 * Math.pow(1.0 - getNSAFT(), 3.0) * (-1.0) + * (8.0 * getNSAFT() - 2.0 * Math.pow(getNSAFT(), 2.0))) + / Math.pow(1.0 - getNSAFT(), 8.0) + + (1.0 - getmSAFT()) * ((20.0 - (2.0 * 27.0) * getNSAFT() + + (12.0 * 3.0) * Math.pow(getNSAFT(), 2.0) - 8.0 * Math.pow(getNSAFT(), 3.0)) * temp1 + - (2.0 * (2.0 - 3.0 * getNSAFT() + Math.pow(getNSAFT(), 2.0)) + * (-3.0 + 2.0 * getNSAFT())) * temp2) + / Math.pow(temp1, 2.0)); + + double temp4 = -Math.pow(F2dispZHC, 2.0); + double dZdndn = getmSAFT() * ((-4.0 * Math.pow(1.0 - getNSAFT(), 4.0) + - 4.0 * Math.pow(1.0 - getNSAFT(), 3.0) * (-1.0) * (8.0 - 4.0 * getNSAFT())) + / Math.pow(1.0 - getNSAFT(), 8.0) + + ((32.0 - 16.0 * getNSAFT()) * Math.pow(1.0 - getNSAFT(), 5.0) - 5.0 + * Math.pow(1.0 - getNSAFT(), 4.0) * (-1.0) + * (32.0 * getNSAFT() - 8.0 * Math.pow(getNSAFT(), 2.0))) + / Math.pow(1.0 - getNSAFT(), 10.0)) + + (1.0 - getmSAFT()) + * (((-54.0 + 72.0 * getNSAFT() - 24.0 * Math.pow(getNSAFT(), 2.0)) * temp1 + - temp1der * (20.0 - 54.0 * getNSAFT() + 36.0 * Math.pow(getNSAFT(), 2.0) + - 8.0 * Math.pow(getNSAFT(), 3.0))) + / Math.pow(temp1, 2.0) + - ((-40.0 * Math.pow(getNSAFT(), 4.0) + 240.0 * Math.pow(getNSAFT(), 3.0) + - 3.0 * 180.0 * Math.pow(getNSAFT(), 2.0) + 242.0 * 2.0 * getNSAFT() - 120.0) + * temp11 + - temp11der * (-8.0 * Math.pow(getNSAFT(), 5.0) + + 60.0 * Math.pow(getNSAFT(), 4.0) - 180.0 * Math.pow(getNSAFT(), 3.0) + + 242.0 * Math.pow(getNSAFT(), 2.0) - 120.0 * getNSAFT())) + / Math.pow(temp11, 2.0)); + + return temp0 * Math.pow(temp3, 2.0) + temp4 * dZdndn; + } + + /** + *

+ * calcF2dispZHCdNdNdN. + *

+ * + * @return a double + */ + public double calcF2dispZHCdNdNdN() { + double temp = -6 * Math.pow((getmSAFT() * (8.0 - 4.0 * getNSAFT()) + / Math.pow((1.0 - getNSAFT()), 4) + + 4 * getmSAFT() * (8.0 * getNSAFT() + - 2.0 * Math.pow(getNSAFT(), 2) / Math.pow((1.0 - getNSAFT()), 5) + (1.0 - getmSAFT()) + * (20 - 54 * getNSAFT() + 36 * Math.pow(getNSAFT(), 2) + - 8 * Math.pow(getNSAFT(), 3)) + / (Math.pow((1.0 - getNSAFT()), 2) * Math.pow((2.0 - getNSAFT()), 2)) + + (2 * (1.0 - getmSAFT())) + * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) + 12 * Math.pow(getNSAFT(), 3) + - 2 * Math.pow(getNSAFT(), 4)) + / (Math.pow((1.0 - getNSAFT()), 3) * Math.pow((2.0 - getNSAFT()), 2)) + + (2 * (1.0 - getmSAFT())) + * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) + 12 * Math.pow(getNSAFT(), 3) + - 2 * Math.pow(getNSAFT(), 4)) + / (Math.pow((1.0 - getNSAFT()), 2) * Math.pow((2.0 - getNSAFT()), 3)))), + 3) + / Math.pow((1.0 + + getmSAFT() * (8.0 * getNSAFT() - 2.0 * Math.pow(getNSAFT(), 2)) + / Math.pow((1.0 - getNSAFT()), 4) + + (1.0 - getmSAFT()) + * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) + 12 * Math.pow(getNSAFT(), 3) + - 2 * Math.pow(getNSAFT(), 4)) + / (Math.pow((1.0 - getNSAFT()), 2) * Math.pow((2.0 - getNSAFT()), 2))), + 4) + + (6 * (getmSAFT() * (8.0 - 4.0 * getNSAFT()) / Math.pow((1.0 - getNSAFT()), 4) + + 4 * getmSAFT() * (8.0 * getNSAFT() - Math.pow(2.0 * getNSAFT(), 2)) + / Math.pow((1.0 - getNSAFT()), 5) + + (1.0 - getmSAFT()) + * (20 - 54 * getNSAFT() + 36 * Math.pow(getNSAFT(), 2) + - 8 * Math.pow(getNSAFT(), 3)) + / (Math.pow((1.0 - getNSAFT()), 2) * Math.pow((2.0 - getNSAFT()), 2)) + + (2 * (1.0 - getmSAFT())) + * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) + 12 * Math.pow(getNSAFT(), 3) + - 2 * Math.pow(getNSAFT(), 4)) + / (Math.pow((1.0 - getNSAFT()), 3) * Math.pow((2.0 - getNSAFT()), 2)) + + (2 * (1.0 - getmSAFT())) + * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) + 12 * Math.pow(getNSAFT(), 3) + - 2 * Math.pow(getNSAFT(), 4)) + / (Math.pow((1.0 - getNSAFT()), 2) * Math.pow((2.0 - getNSAFT()), 3)))) + * (-4.0 * getmSAFT() / Math.pow((1.0 - getNSAFT()), 4) + + 8 * getmSAFT() * (8.0 - 4.0 * getNSAFT()) / Math.pow((1.0 - getNSAFT()), 5) + + 20 * getmSAFT() * (8.0 * getNSAFT() - 2.0 * Math.pow(getNSAFT(), 2)) + / Math.pow((1.0 - getNSAFT()), 6) + + (1.0 - getmSAFT()) * (-54 + 72 * getNSAFT() - 24 * Math.pow(getNSAFT(), 2)) + / (Math.pow((1.0 - getNSAFT()), 2) * Math.pow((2.0 - getNSAFT()), 2)) + + (4 * (1.0 - getmSAFT())) + * (20 - 54 * getNSAFT() + 36 * Math.pow(getNSAFT(), 2) + - 8 * Math.pow(getNSAFT(), 3)) + / (Math.pow((1.0 - getNSAFT()), 3) * Math.pow((2.0 - getNSAFT()), 2)) + + (4 * (1.0 - getmSAFT())) + * (20 - 54 * getNSAFT() + 36 * Math.pow(getNSAFT(), 2) + - 8 * Math.pow(getNSAFT(), 3)) + / (Math.pow((1.0 - getNSAFT()), 2) * Math.pow((2.0 - getNSAFT()), 3)) + + (6 * (1.0 - getmSAFT())) + * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) + 12 * Math.pow(getNSAFT(), 3) + - 2 * Math.pow(getNSAFT(), 4)) + / (Math.pow((1.0 - getNSAFT()), 4) * Math.pow((2.0 - getNSAFT()), 2)) + + (8 * (1.0 - getmSAFT())) + * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) + 12 * Math.pow(getNSAFT(), 3) + - 2 * Math.pow(getNSAFT(), 4)) + / (Math.pow((1.0 - getNSAFT()), 3) * Math.pow((2.0 - getNSAFT()), 3)) + + (6 * (1.0 - getmSAFT())) + * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) + 12 * Math.pow(getNSAFT(), 3) + - 2 * Math.pow(getNSAFT(), 4)) + / (Math.pow((1.0 - getNSAFT()), 2) * Math.pow((2.0 - getNSAFT()), 4))) + / Math.pow(1.0 + + getmSAFT() * (8.0 * getNSAFT() - 2.0 * Math.pow(getNSAFT(), 2)) + / Math.pow((1.0 - getNSAFT()), 4) + + ((1.0 - getmSAFT()) * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) + + 12 * Math.pow(getNSAFT(), 3) - 2 * Math.pow(getNSAFT(), 4)) + / (Math.pow((1.0 - getNSAFT()), 2) * Math.pow((2.0 - getNSAFT()), 2))), + 3) + - (-48.0 * getmSAFT() / Math.pow((1.0 - getNSAFT()), 5) + + 60 * getmSAFT() * (8.0 - 4.0 * getNSAFT()) / Math.pow((1.0 - getNSAFT()), 6) + + 120 * getmSAFT() * (8.0 * getNSAFT() - 2.0 * Math.pow(getNSAFT(), 2)) + / Math.pow((1.0 - getNSAFT()), 7) + + (1.0 - getmSAFT()) * (72 - 48 * getNSAFT()) + / (Math.pow((1.0 - getNSAFT()), 2) * Math.pow((2.0 - getNSAFT()), 2)) + + (6 * (1.0 - getmSAFT())) * (-54 + 72 * getNSAFT() - 24 * Math.pow(getNSAFT(), 2)) + / (Math.pow((1.0 - getNSAFT()), 3) * Math.pow((2.0 - getNSAFT()), 2)) + + (6 * (1.0 - getmSAFT())) * (-54 + 72 * getNSAFT() - 24 * Math.pow(getNSAFT(), 2)) + / (Math.pow((1.0 - getNSAFT()), 2) * Math.pow((2.0 - getNSAFT()), 3)) + + (18 * (1.0 - getmSAFT())) + * (20 - 54 * getNSAFT() + 36 * Math.pow(getNSAFT(), 2) + - 8 * Math.pow(getNSAFT(), 3)) + / (Math.pow((1.0 - getNSAFT()), 4) * Math.pow((2.0 - getNSAFT()), 2)) + + (24 * (1.0 - getmSAFT())) + * (20 - 54 * getNSAFT() + 36 * Math.pow(getNSAFT(), 2) + - 8 * Math.pow(getNSAFT(), 3)) + / (Math.pow((1.0 - getNSAFT()), 3) * Math.pow((2.0 - getNSAFT()), 3)) + + (18 * (1.0 - getmSAFT())) + * (20 - 54 * getNSAFT() + 36 * Math.pow(getNSAFT(), 2) + - 8 * Math.pow(getNSAFT(), 3)) + / (Math.pow((1.0 - getNSAFT()), 2) * Math.pow((2.0 - getNSAFT()), 4)) + + (24 * (1.0 - getmSAFT())) + * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) + 12 * Math.pow(getNSAFT(), 3) + - 2 * Math.pow(getNSAFT(), 4)) + / (Math.pow((1.0 - getNSAFT()), 5) * Math.pow((2.0 - getNSAFT()), 2)) + + (36 * (1.0 - getmSAFT())) + * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) + 12 * Math.pow(getNSAFT(), 3) + - 2 * Math.pow(getNSAFT(), 4)) + / (Math.pow((1.0 - getNSAFT()), 4) * Math.pow((2.0 - getNSAFT()), 3)) + + (36 * (1.0 - getmSAFT())) + * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) + 12 * Math.pow(getNSAFT(), 3) + - 2 * Math.pow(getNSAFT(), 4)) + / (Math.pow((1.0 - getNSAFT()), 3) * Math.pow((2.0 - getNSAFT()), 4)) + + (24 * (1.0 - getmSAFT())) + * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) + 12 * Math.pow(getNSAFT(), 3) + - 2 * Math.pow(getNSAFT(), 4)) + / (Math.pow((1.0 - getNSAFT()), 2) * Math.pow((2.0 - getNSAFT()), 5))) + / Math.pow((1.0 + + getmSAFT() * (8.0 * getNSAFT() - 2.0 * Math.pow(getNSAFT(), 2)) + / Math.pow((1.0 - getNSAFT()), 4) + + (1.0 - getmSAFT()) * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) + + 12 * Math.pow(getNSAFT(), 3) - 2 * Math.pow(getNSAFT(), 4)) + / (Math.pow((1.0 - getNSAFT()), 2) * Math.pow((2.0 - getNSAFT()), 2))), + 2); + + return temp; + } + + // added by rahmat + /** + *

+ * calcdF2dispZHCdT. + *

+ * + * @return a double + */ + public double calcdF2dispZHCdT() { + double temp0 = -Math.pow(F2dispZHC, 2.0); + double temp1 = getmSAFT() * ((8 - 4 * getNSAFT()) * dNSAFTdT * Math.pow(1 - getNSAFT(), 4) + 4 + * Math.pow(1 - getNSAFT(), 3) * dNSAFTdT * (8 * getNSAFT() - 2 * Math.pow(getNSAFT(), 2))) + / Math.pow(1 - getNSAFT(), 8); + double temp2a = (1 - getmSAFT()) + * (20 - 54 * getNSAFT() + 36 * Math.pow(getNSAFT(), 2) + 8 * Math.pow(getNSAFT(), 3)) + * dNSAFTdT * Math.pow((1 - getNSAFT()) * (2 - getNSAFT()), 2); + double temp2b = (1 - getmSAFT()) * 2 * ((1 - getNSAFT()) * (2 - getNSAFT())) + * (-1 * dNSAFTdT * (2 - getNSAFT()) + (-1) * dNSAFTdT * (1 - getNSAFT())) + * (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2) + 12 * Math.pow(getNSAFT(), 3) + - 2 * Math.pow(getNSAFT(), 4)); + double temp2 = (temp2a - temp2b) / Math.pow((1 - getNSAFT()) * (2 - getNSAFT()), 4); + return temp0 * (temp1 + temp2); + } + + /** {@inheritDoc} */ + @Override + public double calcmSAFT() { + double temp2 = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + temp2 += getComponent(i).getNumberOfMolesInPhase() * getComponent(i).getmSAFTi() + / getNumberOfMolesInPhase(); + } + + return temp2; + } + + /** {@inheritDoc} */ + @Override + public double calcF1dispSumTerm() { + double temp1 = 0.0; + + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < numberOfComponents; j++) { + temp1 += getComponent(i).getNumberOfMolesInPhase() + * getComponent(j).getNumberOfMolesInPhase() * getComponent(i).getmSAFTi() + * getComponent(j).getmSAFTi() + * Math.sqrt(getComponent(i).getEpsikSAFT() / temperature + * getComponent(j).getEpsikSAFT() / temperature) + * (1.0 - mixRule.getBinaryInteractionParameter(i, j)) * Math.pow( + 0.5 * (getComponent(i).getSigmaSAFTi() + getComponent(j).getSigmaSAFTi()), 3.0); + } + } + return temp1 / Math.pow(getNumberOfMolesInPhase(), 2.0); + } + + // added by rahmat + /** + *

+ * calcdF1dispSumTermdT. + *

+ * + * @return a double + */ + public double calcdF1dispSumTermdT() { + double temp1 = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < numberOfComponents; j++) { + temp1 += getComponent(i).getNumberOfMolesInPhase() + * getComponent(j).getNumberOfMolesInPhase() * getComponent(i).getmSAFTi() + * getComponent(j).getmSAFTi() + * Math.sqrt(getComponent(i).getEpsikSAFT() / temperature + * getComponent(j).getEpsikSAFT() / temperature) + * (1.0 - mixRule.getBinaryInteractionParameter(i, j)) + * Math.pow( + 0.5 * (getComponent(i).getSigmaSAFTi() + getComponent(j).getSigmaSAFTi()), 3.0) + * (-1 / temperature); + } + } + return temp1 / Math.pow(getNumberOfMolesInPhase(), 2.0); + } + + /** + *

+ * calcdF2dispSumTermdT. + *

+ * + * @return a double + */ + public double calcdF2dispSumTermdT() { + double temp1 = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < numberOfComponents; j++) { + temp1 += getComponent(i).getNumberOfMolesInPhase() + * getComponent(j).getNumberOfMolesInPhase() * getComponent(i).getmSAFTi() + * getComponent(j).getmSAFTi() + * (getComponent(i).getEpsikSAFT() / temperature * getComponent(j).getEpsikSAFT() + / temperature) + * Math.pow(1.0 - mixRule.getBinaryInteractionParameter(i, j), 2) + * Math.pow( + 0.5 * (getComponent(i).getSigmaSAFTi() + getComponent(j).getSigmaSAFTi()), 3.0) + * (-2 / temperature); + } + } + return temp1 / Math.pow(getNumberOfMolesInPhase(), 2.0); + } + + /** {@inheritDoc} */ + @Override + public double calcF2dispSumTerm() { + double temp1 = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < numberOfComponents; j++) { + temp1 += getComponent(i).getNumberOfMolesInPhase() + * getComponent(j).getNumberOfMolesInPhase() * getComponent(i).getmSAFTi() + * getComponent(j).getmSAFTi() * getComponent(i).getEpsikSAFT() / temperature + * getComponent(j).getEpsikSAFT() / temperature + * Math.pow((1.0 - mixRule.getBinaryInteractionParameter(i, j)), 2.0) * Math.pow( + 0.5 * (getComponent(i).getSigmaSAFTi() + getComponent(j).getSigmaSAFTi()), 3.0); + } + } + return temp1 / Math.pow(getNumberOfMolesInPhase(), 2.0); + } + + /** {@inheritDoc} */ + @Override + public double calcF1dispI1dN() { + double temp1 = 0.0; + for (int i = 1; i < 7; i++) { + temp1 += i * getaSAFT(i, getmSAFT(), aConstSAFT) * Math.pow(getNSAFT(), i - 1.0); + } + return temp1; + } + + /** {@inheritDoc} */ + @Override + public double calcF1dispI1dNdN() { + double temp1 = 0.0; + for (int i = 2; i < 7; i++) { + temp1 += (i - 1.0) * i * getaSAFT(i, getmSAFT(), aConstSAFT) * Math.pow(getNSAFT(), i - 2.0); + } + return temp1; + } + + // added by Rahmat + /** + *

+ * calcF1dispI1dNdNdN. + *

+ * + * @return a double + */ + public double calcF1dispI1dNdNdN() { + double temp1 = 0.0; + for (int i = 2; i < 7; i++) { + temp1 += (i - 1.0) * (i - 2.0) * i * getaSAFT(i, getmSAFT(), aConstSAFT) + * Math.pow(getNSAFT(), i - 3.0); + } + return temp1; + } + + /** {@inheritDoc} */ + @Override + public double calcF1dispI1dm() { + double temp1 = 0.0; + for (int i = 0; i < 7; i++) { + temp1 += getaSAFTdm(i, getmSAFT(), aConstSAFT) * Math.pow(getNSAFT(), i); + } + return temp1; + } + + /** {@inheritDoc} */ + @Override + public double calcF2dispI2dN() { + double temp1 = 0.0; + for (int i = 1; i < 7; i++) { + temp1 += i * getaSAFT(i, getmSAFT(), bConstSAFT) * Math.pow(getNSAFT(), i - 1.0); + } + return temp1; + } + + /** {@inheritDoc} */ + @Override + public double calcF2dispI2dNdN() { + double temp1 = 0.0; + for (int i = 2; i < 7; i++) { + temp1 += (i - 1.0) * i * getaSAFT(i, getmSAFT(), bConstSAFT) * Math.pow(getNSAFT(), i - 2.0); + } + return temp1; + } + + /** + *

+ * calcF2dispI2dNdNdN. + *

+ * + * @return a double + */ + public double calcF2dispI2dNdNdN() { + double temp1 = 0.0; + for (int i = 2; i < 7; i++) { + temp1 += (i - 1.0) * (i - 2.0) * i * getaSAFT(i, getmSAFT(), bConstSAFT) + * Math.pow(getNSAFT(), i - 3.0); + } + return temp1; + } + + /** {@inheritDoc} */ + @Override + public double calcF2dispI2dm() { + double temp1 = 0.0; + for (int i = 0; i < 7; i++) { + temp1 += getaSAFTdm(i, getmSAFT(), bConstSAFT) * Math.pow(getNSAFT(), i); + } + return temp1; + } + + /** {@inheritDoc} */ + @Override + public double calcF1dispI1() { + double temp1 = 0.0; + for (int i = 0; i < 7; i++) { + temp1 += getaSAFT(i, getmSAFT(), aConstSAFT) * Math.pow(getNSAFT(), i); + } + return temp1; + } + + // added by rahmat + /** + *

+ * calcdF1dispI1dT. + *

+ * + * @return a double + */ + public double calcdF1dispI1dT() { + double temp1 = 0.0; + for (int i = 0; i < 7; i++) { + temp1 += getaSAFT(i, getmSAFT(), aConstSAFT) * i * Math.pow(getNSAFT(), i - 1) * dNSAFTdT; + } + return temp1; + } + + /** + *

+ * calcdF2dispI2dT. + *

+ * + * @return a double + */ + public double calcdF2dispI2dT() { + double temp1 = 0.0; + for (int i = 0; i < 7; i++) { + temp1 += getaSAFT(i, getmSAFT(), bConstSAFT) * i * Math.pow(getNSAFT(), i - 1) * dNSAFTdT; + } + return temp1; + } + + /** {@inheritDoc} */ + @Override + public double calcF2dispI2() { + double temp1 = 0.0; + for (int i = 0; i < 7; i++) { + temp1 += getaSAFT(i, getmSAFT(), bConstSAFT) * Math.pow(getNSAFT(), i); + } + return temp1; + } + + /** {@inheritDoc} */ + @Override + public double getaSAFT(int i, double m, double ab[][]) { + return ab[0][i] + (m - 1.0) / m * ab[1][i] + (m - 1.0) / m * (m - 2.0) / m * ab[2][i]; + } + + /** {@inheritDoc} */ + @Override + public double getaSAFTdm(int i, double m, double ab[][]) { + return (m - (m - 1.0)) / (m * m) * ab[1][i] + + ((2.0 * m - 3.0) * m * m - 2 * m * (m * m - 3 * m + 2)) / Math.pow(m, 4.0) * ab[2][i]; + } + + /** {@inheritDoc} */ + @Override + public double calcmdSAFT() { + double temp2 = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + temp2 += getComponent(i).getNumberOfMolesInPhase() / getNumberOfMolesInPhase() + * getComponent(i).getmSAFTi() + * Math.pow(((ComponentPCSAFT) getComponent(i)).getdSAFTi(), 3.0); + } + + return temp2; + } + + /** {@inheritDoc} */ + @Override + public double calcmmin1SAFT() { + double temp2 = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + temp2 += getComponent(i).getNumberOfMolesInPhase() / getNumberOfMolesInPhase() + * (getComponent(i).getmSAFTi() - 1.0); + } + + return temp2; + } + + /** {@inheritDoc} */ + @Override + public double calcdmeanSAFT() { + double temp = 0.0; + double temp2 = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + temp += getComponent(i).getNumberOfMolesInPhase() * getComponent(i).getmSAFTi() + * Math.pow(((ComponentPCSAFT) getComponent(i)).getdSAFTi(), 3.0); + temp2 += getComponent(i).getNumberOfMolesInPhase() * getComponent(i).getmSAFTi(); + } + return Math.pow(temp / temp2, 1.0 / 3.0); + } + + // need to check (modified by rahmat) + /** {@inheritDoc} */ + @Override + public double calcdSAFT() { + double temp1 = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + temp1 += getComponent(i).getNumberOfMolesInPhase() * getComponent(i).getmSAFTi() + * Math.pow(((ComponentPCSAFT) getComponent(i)).getdSAFTi(), 3.0); + } + // System.out.println("d saft calc " + temp/getNumberOfMolesInPhase()); + return temp1 / getNumberOfMolesInPhase(); + } + + /** {@inheritDoc} */ + @Override + public double getNSAFT() { + return nSAFT; + } + + /** {@inheritDoc} */ + @Override + public void setNSAFT(double nSAFT) { + this.nSAFT = nSAFT; + } + + /** {@inheritDoc} */ + @Override + public double getDSAFT() { + return dSAFT; + } + + /** {@inheritDoc} */ + @Override + public void setDSAFT(double dSAFT) { + this.dSAFT = dSAFT; + } + + /** {@inheritDoc} */ + @Override + public double getGhsSAFT() { + return ghsSAFT; + } + + /** {@inheritDoc} */ + @Override + public void setGhsSAFT(double ghsSAFT) { + this.ghsSAFT = ghsSAFT; + } + + /** {@inheritDoc} */ + @Override + public double F_HC_SAFT() { + return getNumberOfMolesInPhase() + * (getmSAFT() * getAHSSAFT() - getMmin1SAFT() * Math.log(getGhsSAFT())); /// (ThermodynamicConstantsInterface.R*temperature); + } + + /** {@inheritDoc} */ + @Override + public double dF_HC_SAFTdV() { + return getNumberOfMolesInPhase() * (getmSAFT() * daHSSAFTdN * getDnSAFTdV() + - getMmin1SAFT() * 1.0 / getGhsSAFT() * getDgHSSAFTdN() * getDnSAFTdV()); /// (ThermodynamicConstantsInterface.R*temperature); + } + + // edited by Rahmat + /** {@inheritDoc} */ + @Override + public double dFdT() { + return useHS * dF_HC_SAFTdT() + useDISP1 * dF_DISP1_SAFTdT() + useDISP2 * dF_DISP2_SAFTdT(); + } + + /** + *

+ * dF_HC_SAFTdT. + *

+ * + * @return a double + */ + public double dF_HC_SAFTdT() { + return getNumberOfMolesInPhase() * (getmSAFT() * daHSSAFTdN * dNSAFTdT + - getMmin1SAFT() * 1.0 / getGhsSAFT() * getDgHSSAFTdN() * dNSAFTdT); /// (ThermodynamicConstantsInterface.R*temperature); + } + + /** {@inheritDoc} */ + @Override + public double dF_HC_SAFTdVdV() { + return getNumberOfMolesInPhase() * (getmSAFT() * daHSSAFTdNdN * getDnSAFTdV() * getDnSAFTdV() + + getmSAFT() * daHSSAFTdN * dnSAFTdVdV + + getMmin1SAFT() * Math.pow(getGhsSAFT(), -2.0) * Math.pow(getDgHSSAFTdN(), 2.0) + * getDnSAFTdV() * getDnSAFTdV() + - getMmin1SAFT() * Math.pow(getGhsSAFT(), -1.0) * dgHSSAFTdNdN * dnSAFTdV * dnSAFTdV + - getMmin1SAFT() * 1.0 / getGhsSAFT() * getDgHSSAFTdN() * dnSAFTdVdV); // (ThermodynamicConstantsInterface.R*temperature); + } + // additonal dF_HC_SAFTdVdVdV (by Rahmat) + + /** {@inheritDoc} */ + @Override + public double dF_HC_SAFTdVdVdV() { + return getNumberOfMolesInPhase() * (getmSAFT() * daHSSAFTdNdNdN * getDnSAFTdV() * getDnSAFTdV() + * getDnSAFTdV() + getmSAFT() * daHSSAFTdNdN * 2.0 * dnSAFTdV * dnSAFTdVdV + + getmSAFT() * daHSSAFTdNdN * dnSAFTdV * dnSAFTdVdV + getmSAFT() * daHSSAFTdN * dnSAFTdVdVdV + - 2.0 * getMmin1SAFT() * Math.pow(getGhsSAFT(), -3.0) * Math.pow(getDgHSSAFTdN(), 3.0) + * getDnSAFTdV() * getDnSAFTdV() * getDnSAFTdV() + + getMmin1SAFT() * Math.pow(getGhsSAFT(), -2.0) * 2.0 * getDgHSSAFTdN() * dgHSSAFTdNdN + * getDnSAFTdV() * getDnSAFTdV() * getDnSAFTdV() + + getMmin1SAFT() * Math.pow(getGhsSAFT(), -2.0) * Math.pow(getDgHSSAFTdN(), 2.0) * 2.0 + * getDnSAFTdV() * dnSAFTdVdV + + getMmin1SAFT() * Math.pow(getGhsSAFT(), -2.0) * getDgHSSAFTdN() * dgHSSAFTdNdN + * dnSAFTdV * dnSAFTdV * dnSAFTdV + - getMmin1SAFT() * Math.pow(getGhsSAFT(), -1.0) * dgHSSAFTdNdNdN * dnSAFTdV * dnSAFTdV + * dnSAFTdV + - getMmin1SAFT() * Math.pow(getGhsSAFT(), -1.0) * dgHSSAFTdNdN * 2.0 * dnSAFTdV + * dnSAFTdVdV + + getMmin1SAFT() * Math.pow(getGhsSAFT(), -2.0) * Math.pow(getDgHSSAFTdN(), 2) + * dnSAFTdV * dnSAFTdVdV + - getMmin1SAFT() * Math.pow(getGhsSAFT(), -1.0) * dgHSSAFTdNdN * dnSAFTdV * dnSAFTdVdV + - getMmin1SAFT() * Math.pow(getGhsSAFT(), -1.0) * getDgHSSAFTdN() * dnSAFTdVdVdV); + } + + /** {@inheritDoc} */ + @Override + public double F_DISP1_SAFT() { + return getNumberOfMolesInPhase() * (-2.0 * ThermodynamicConstantsInterface.pi + * getF1dispVolTerm() * getF1dispSumTerm() * getF1dispI1()); /// (ThermodynamicConstantsInterface.R*temperature); + } + + /** {@inheritDoc} */ + @Override + public double dF_DISP1_SAFTdV() { + return getNumberOfMolesInPhase() * (-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTermdV + * getF1dispSumTerm() * getF1dispI1() + - 2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTerm * getF1dispSumTerm() + * F1dispI1dV); /// (ThermodynamicConstantsInterface.R*temperature); + } + + /** {@inheritDoc} */ + @Override + public double dF_DISP1_SAFTdVdV() { + return getNumberOfMolesInPhase() * ((-2.0 * ThermodynamicConstantsInterface.pi + * F1dispVolTermdVdV * getF1dispSumTerm() * getF1dispI1()) + + (-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTermdV * getF1dispSumTerm() + * F1dispI1dV) + + (-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTermdV * getF1dispSumTerm() + * F1dispI1dV) + + (-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTerm * getF1dispSumTerm() + * F1dispI1dVdV)); + } + + // added by Rahmat + /** + *

+ * dF_DISP1_SAFTdVdVdV. + *

+ * + * @return a double + */ + public double dF_DISP1_SAFTdVdVdV() { + return getNumberOfMolesInPhase() * ((-2.0 * ThermodynamicConstantsInterface.pi + * F1dispVolTermdVdVdV * getF1dispSumTerm() * getF1dispI1()) + + (-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTermdVdV * getF1dispSumTerm() + * F1dispI1dV) + + (-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTermdVdV * getF1dispSumTerm() + * F1dispI1dV) + + (-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTermdV * getF1dispSumTerm() + * F1dispI1dVdV) + + (-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTermdVdV * getF1dispSumTerm() + * F1dispI1dV) + + (-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTermdV * getF1dispSumTerm() + * F1dispI1dVdV) + + (-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTermdV * getF1dispSumTerm() + * F1dispI1dVdV) + + (-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTerm * getF1dispSumTerm() + * F1dispI1dVdVdV)); + } + + // added by Rahmat + /** + *

+ * dF_DISP1_SAFTdT. + *

+ * + * @return a double + */ + public double dF_DISP1_SAFTdT() { + return getNumberOfMolesInPhase() * (-2.0 * ThermodynamicConstantsInterface.pi + * (dF1dispVolTermdT * getF1dispSumTerm() * getF1dispI1() + + dF1dispSumTermdT * getF1dispVolTerm() * getF1dispI1() + + dF1dispI1dT * getF1dispVolTerm() * getF1dispSumTerm())); + } + + /** + *

+ * dF_DISP2_SAFTdT. + *

+ * + * @return a double + */ + public double dF_DISP2_SAFTdT() { + return getNumberOfMolesInPhase() * (-1 * ThermodynamicConstantsInterface.pi * getmSAFT()) + * getF1dispVolTerm() + * (dF2dispSumTermdT * getF2dispI2() * getF2dispZHC() + + dF2dispI2dT * getF2dispSumTerm() * getF2dispZHC() + + dF2dispZHCdT * getF2dispSumTerm() * getF2dispI2()); + } + + /** {@inheritDoc} */ + @Override + public double F_DISP2_SAFT() { + return getNumberOfMolesInPhase() * (-ThermodynamicConstantsInterface.pi * getmSAFT() + * getF1dispVolTerm() * getF2dispSumTerm() * getF2dispI2() * getF2dispZHC()); /// (ThermodynamicConstantsInterface.R*temperature); + } + + /** {@inheritDoc} */ + @Override + public double dF_DISP2_SAFTdV() { + return getNumberOfMolesInPhase() * (-ThermodynamicConstantsInterface.pi * getmSAFT() + * F1dispVolTermdV * getF2dispSumTerm() * getF2dispI2() * getF2dispZHC() + - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm() + * F2dispI2dV * getF2dispZHC() + - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm() + * getF2dispI2() * F2dispZHCdV); /// (ThermodynamicConstantsInterface.R*temperature); + } + + /** {@inheritDoc} */ + @Override + public double dF_DISP2_SAFTdVdV() { + return getNumberOfMolesInPhase() * ((-ThermodynamicConstantsInterface.pi * getmSAFT() + * F1dispVolTermdVdV * getF2dispSumTerm() * getF2dispI2() * getF2dispZHC()) + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm() + * getF2dispZHC() * F2dispI2dV) + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm() + * getF2dispI2() * F2dispZHCdV) + - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm() + * F2dispI2dV * getF2dispZHC() + - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm() + * F2dispI2dVdV * getF2dispZHC() + - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm() + * F2dispI2dV * F2dispZHCdV + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm() + * getF2dispI2() * F2dispZHCdV) + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm() + * F2dispI2dV * F2dispZHCdV) + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm() + * getF2dispI2() * F2dispZHCdVdV)); + } + + /** + *

+ * dF_DISP2_SAFTdVdVdV. + *

+ * + * @return a double + */ + public double dF_DISP2_SAFTdVdVdV() { + return getNumberOfMolesInPhase() * ((-ThermodynamicConstantsInterface.pi * getmSAFT() + * F1dispVolTermdVdVdV * getF2dispSumTerm() * getF2dispI2() * getF2dispZHC()) + + (-ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdVdV * getF2dispSumTerm() + * F2dispI2dV * getF2dispZHC()) + + (-ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdVdV * getF2dispSumTerm() + * getF2dispI2() * F2dispZHCdV) + + -(ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdVdV * getF2dispSumTerm() + * getF2dispZHC() * F2dispI2dV) + + -(ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm() + * F2dispZHCdV * F2dispI2dV) + + -(ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm() + * getF2dispZHC() * F2dispI2dVdV) + + -(ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdVdV * getF2dispSumTerm() + * getF2dispI2() * F2dispZHCdV) + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm() + * F2dispI2dV * F2dispZHCdV) + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm() + * getF2dispI2() * F2dispZHCdVdV) + - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdVdV * getF2dispSumTerm() + * F2dispI2dV * getF2dispZHC() + - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm() + * F2dispI2dVdV * getF2dispZHC() + - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm() + * F2dispI2dV * F2dispZHCdV + - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm() + * F2dispI2dVdV * getF2dispZHC() + - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm() + * F2dispI2dVdVdV * getF2dispZHC() + - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm() + * F2dispI2dVdV * F2dispZHCdV + - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm() + * F2dispI2dV * F2dispZHCdV + - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm() + * F2dispI2dVdV * F2dispZHCdV + - ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm() + * F2dispI2dV * F2dispZHCdVdV + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdVdV * getF2dispSumTerm() + * getF2dispI2() * F2dispZHCdV) + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm() + * F2dispI2dV * F2dispZHCdV) + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm() + * getF2dispI2() * F2dispZHCdVdV) + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm() + * F2dispI2dV * F2dispZHCdV) + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm() + * F2dispI2dVdV * F2dispZHCdV) + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm() + * F2dispI2dV * F2dispZHCdVdV) + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm() + * getF2dispI2() * F2dispZHCdVdV) + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm() + * F2dispI2dV * F2dispZHCdVdV) + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm() + * getF2dispI2() * F2dispZHCdVdVdV) + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdVdV * getF2dispSumTerm() + * getF2dispI2() * F2dispZHCdV) + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm() + * F2dispI2dV * F2dispZHCdV) + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm() + * getF2dispI2() * F2dispZHCdVdV) + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm() + * F2dispI2dV * F2dispZHCdV) + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm() + * F2dispI2dVdV * F2dispZHCdV) + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm() + * F2dispI2dV * F2dispZHCdVdV) + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm() + * getF2dispI2() * F2dispZHCdVdV) + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm() + * F2dispI2dV * F2dispZHCdVdV) + - (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm() + * getF2dispI2() * F2dispZHCdVdVdV)); + } + + /** {@inheritDoc} */ + @Override + public double getF() { + // System.out.println("F-HC " + useHS*F_HC_SAFT()); + + // System.out.println("F-DISP1 " + useDISP1*F_DISP1_SAFT()); + + // System.out.println("F-DISP2 " + useDISP2*F_DISP2_SAFT()); + return useHS * F_HC_SAFT() + useDISP1 * F_DISP1_SAFT() + useDISP2 * F_DISP2_SAFT(); + } + + /** {@inheritDoc} */ + @Override + public double dFdV() { + // System.out.println("N-saft " + getNSAFT()); + // System.out.println("F-HC " + useHS*F_HC_SAFT()); + // System.out.println("F-DISP1 " + useDISP1*F_DISP1_SAFT()); + + // System.out.println("F-DISP2 " + useDISP2*F_DISP2_SAFT()); + + return (useHS * dF_HC_SAFTdV() + useDISP1 * dF_DISP1_SAFTdV() + useDISP2 * dF_DISP2_SAFTdV()) + * 1.0e-5; + } + + /** {@inheritDoc} */ + @Override + public double dFdVdV() { + return (useHS * dF_HC_SAFTdVdV() + useDISP1 * dF_DISP1_SAFTdVdV() + + useDISP2 * dF_DISP2_SAFTdVdV()) * 1.0e-10; + } + + /** {@inheritDoc} */ + @Override + public double dFdVdVdV() { + return (useHS * dF_HC_SAFTdVdVdV() + useDISP1 * dF_DISP1_SAFTdVdVdV() + + useDISP2 * dF_DISP2_SAFTdVdVdV()) * 1.0e-20; + } + + /** {@inheritDoc} */ + @Override + public double getmdSAFT() { + return mdSAFT; + } + + /** {@inheritDoc} */ + @Override + public void setmdSAFT(double mdSAFT) { + this.mdSAFT = mdSAFT; + } + + /** {@inheritDoc} */ + @Override + public double getmSAFT() { + return mSAFT; + } + + /** {@inheritDoc} */ + @Override + public void setmSAFT(double mSAFT) { + this.mSAFT = mSAFT; + } + + /** {@inheritDoc} */ + @Override + public double getAHSSAFT() { + return aHSSAFT; + } + + /** {@inheritDoc} */ + @Override + public void setAHSSAFT(double aHSSAFT) { + this.aHSSAFT = aHSSAFT; + } + + /** {@inheritDoc} */ + @Override + public double getMmin1SAFT() { + return mmin1SAFT; + } + + /** {@inheritDoc} */ + @Override + public void setMmin1SAFT(double mmin1SAFT) { + this.mmin1SAFT = mmin1SAFT; + } + + /** {@inheritDoc} */ + @Override + public double getVolumeSAFT() { + return volumeSAFT; + } + + /** {@inheritDoc} */ + @Override + public void setVolumeSAFT(double volumeSAFT) { + this.volumeSAFT = volumeSAFT; + } + + /** {@inheritDoc} */ + @Override + public double getDgHSSAFTdN() { + return dgHSSAFTdN; + } + + /** {@inheritDoc} */ + @Override + public void setDgHSSAFTdN(double dgHSSAFTdN) { + this.dgHSSAFTdN = dgHSSAFTdN; + } + + /** {@inheritDoc} */ + @Override + public double getDnSAFTdV() { + return dnSAFTdV; + } + + // added by rahmat + /** + *

+ * getdDSAFTdT. + *

+ * + * @return a double + */ + public double getdDSAFTdT() { + double temp = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + temp += getComponent(i).getNumberOfMolesInPhase() * getComponent(i).getmSAFTi() + / getNumberOfMolesInPhase() * 3 + * Math.pow(((ComponentPCSAFT) getComponent(i)).getdSAFTi(), 2.0) + * (-1.08 / Math.pow(temperature, 2)) * Math.pow(getComponent(i).getSigmaSAFTi(), 3) + * Math.pow(1 - 0.12 * Math.exp(-3 * getComponent(i).getEpsikSAFT() / temperature), 2) + * getComponent(i).getEpsikSAFT() + * Math.exp(-3 * getComponent(i).getEpsikSAFT() / temperature); + } + return temp; + } + + /** {@inheritDoc} */ + @Override + public void setDnSAFTdV(double dnSAFTdV) { + this.dnSAFTdV = dnSAFTdV; + } + + /** {@inheritDoc} */ + @Override + public double getF1dispVolTerm() { + return F1dispVolTerm; + } + + /** {@inheritDoc} */ + @Override + public void setF1dispVolTerm(double F1dispVolTerm) { + this.F1dispVolTerm = F1dispVolTerm; + } + + /** {@inheritDoc} */ + @Override + public double getF1dispSumTerm() { + return F1dispSumTerm; + } + + /** {@inheritDoc} */ + @Override + public double getF1dispI1() { + return F1dispI1; + } + + /** {@inheritDoc} */ + @Override + public double getF2dispI2() { + return F2dispI2; + } + + /** {@inheritDoc} */ + @Override + public void setF2dispI2(double F2dispI2) { + this.F2dispI2 = F2dispI2; + } + + /** {@inheritDoc} */ + @Override + public double getF2dispZHC() { + return F2dispZHC; + } + + /** {@inheritDoc} */ + @Override + public void setF2dispZHC(double F2dispZHC) { + this.F2dispZHC = F2dispZHC; + } + + /** {@inheritDoc} */ + @Override + public double getF2dispZHCdN() { + return F2dispZHCdN; + } + + /** {@inheritDoc} */ + @Override + public double getF2dispZHCdm() { + return F2dispZHCdm; + } + + /** {@inheritDoc} */ + @Override + public double molarVolume(double pressure, double temperature, double A, double B, int phase) + throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + double BonV = phase == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + // double BonV = phase== 0 ? 0.99:1e-5; + + if (BonV < 0) { + BonV = 1.0e-6; + } + if (BonV > 1.0) { + BonV = 1.0 - 1.0e-6; + } + // double BonVold = BonV; + double Btemp = 0; + double dh = 0; + double h = 0; + // double Dtemp = 0, hOld = 0, dhOld = 0, gvvv = 0, fvvv = 0, d2 = 0, dhh = 1; + double d1 = 0; + Btemp = getB(); + // Dtemp = getA(); + if (Btemp <= 0) { + logger.info("b negative in volume calc"); + } + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + int iterations = 0; + double oldMolarVolume = 0.0; + // System.out.println("volume " + getVolume()); + do { + iterations++; + this.volInit(); + oldMolarVolume = getMolarVolume(); + h = pressure - calcPressure(); + dh = -calcPressuredV(); + d1 = -h / dh; + double newVolume = getMolarVolume() + 0.9 * d1 / numberOfMolesInPhase; + if (newVolume > 1e-100) { + setMolarVolume(newVolume); + } else { + setMolarVolume(oldMolarVolume / 10.0); + } + + /* + * BonVold = BonV; //BonV = BonVold; h = BonVold - + * Btemp/numberOfMolesInPhase*dFdV()-pressure*Btemp/(numberOfMolesInPhase*R* temperature); dh + * = 1.0 + Btemp/Math.pow(BonVold,2.0)*(Btemp/numberOfMolesInPhase*dFdVdV()); //dhh = + * -2.0*Btemp/Math.pow(BonV,3.0)*(Btemp/numberOfMolesInPhase*dFdVdV())-Math.pow( + * Btemp,2.0)/Math.pow(BonV,4.0)*(Btemp/numberOfMolesInPhase*dFdVdVdV()); + * + * //made by Rahmat + * + * BonV = BonVold - 0.5* (2* h * dh / ((2* Math.pow(dh,2) - h * dhh))); + * + * double dBonV = BonV - BonVold; dhh = (dh - dhOld)/ dBonV; dhOld = dh; + * + * hOld = h; + * + * + * //d1 = - h/dh; //d2 = - dh/dhh; //BonV += d1; //*(1.0+0.5*-1.0); /* + * if(Math.abs(d1/d2)<=1.0){ BonV += d1*(1.0+0.5*d1/d2); } else if(d1/d2<-1){ BonV += + * d1*(1.0+0.5*-1.0); } else if(d1/d2>1){ BonV += d2; double hnew = h +d2*-h/d1; + * if(Math.abs(hnew)>Math.abs(h)){ System.out.println("volume correction needed...."); BonV = + * phase== 1 ? 2.0/(2.0+temperature/getPseudoCriticalTemperature()):pressure*getB()/( + * numberOfMolesInPhase*temperature*R); } } + * + * if(BonV>1){ BonV=1.0-1.0e-6; BonVold=10; } if (BonV < 0) { BonV = 1.0e-16; BonVold = 10; } + */ + // setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); + // System.out.println("BonV " + BonV); + } while (Math.abs((oldMolarVolume - getMolarVolume()) / oldMolarVolume) > 1.0e-10 + && iterations < 100); + // while(Math.abs((BonV-BonVold)/BonV)>1.0e-10 && iterations<500); + + // while(Math.abs((h-hOld)/h)>1.0e-10 && iterations<6000); + // System.out.println("error BonV " + Math.abs((BonV-BonVold)/BonV)); + // System.out.println("iterations " + iterations); + /* + * if(BonV<0){ BonV = pressure*getB()/(numberOfMolesInPhase*temperature*R); setMolarVolume(1.0 / + * BonV * Btemp / numberOfMolesInPhase); Z = pressure*getMolarVolume()/(R*temperature); + * + * } if(iterations>=6000) throw new util.exception.TooManyIterationsException(); + * if(Double.isNaN(getMolarVolume())) throw new util.exception.IsNaNException(); + * + * // if(phaseType==0) System.out.println("density " + getDensity()); //"BonV: " + BonV + + * " "+" itert: " + iterations +" " + " phase " + phaseType+ " " + h + " " +dh + " B " + + * Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); + */ + return getMolarVolume(); + } + + /** {@inheritDoc} */ + @Override + public double getDmeanSAFT() { + return dmeanSAFT; + } + + /** {@inheritDoc} */ + @Override + public void setDmeanSAFT(double dmeanSAFT) { + this.dmeanSAFT = dmeanSAFT; + } + + /** {@inheritDoc} */ + @Override + public double getNmSAFT() { + return nmSAFT; + } + + /** {@inheritDoc} */ + @Override + public void setNmSAFT(double nmSAFT) { + this.nmSAFT = nmSAFT; + } + + /** {@inheritDoc} */ + @Override + public double getF2dispSumTerm() { + return F2dispSumTerm; + } + + /** {@inheritDoc} */ + @Override + public void setF2dispSumTerm(double F2dispSumTerm) { + this.F2dispSumTerm = F2dispSumTerm; + } + + /** {@inheritDoc} */ + @Override + public void setF2dispZHCdm(double F2dispZHCdm) { + this.F2dispZHCdm = F2dispZHCdm; + } } diff --git a/src/main/java/neqsim/thermo/phase/PhasePCSAFTa.java b/src/main/java/neqsim/thermo/phase/PhasePCSAFTa.java index 98faf3e100..341881cca4 100644 --- a/src/main/java/neqsim/thermo/phase/PhasePCSAFTa.java +++ b/src/main/java/neqsim/thermo/phase/PhasePCSAFTa.java @@ -20,11 +20,17 @@ public class PhasePCSAFTa extends PhasePCSAFT implements PhaseCPAInterface { public CPAMixing cpaSelect = new CPAMixing(); public CPAMixingInterface cpamix; - double hcpatot = 1.0, hcpatotdT = 0.0, hcpatotdTdT = 0.0; + double hcpatot = 1.0; + double hcpatotdT = 0.0; + double hcpatotdTdT = 0.0; int cpaon = 1; - int totalNumberOfAccociationSites = 0; - double gcpav = 0.0, lngcpa = 0.0, gcpavv = 1.0, gcpavvv = 0.0, gcpa = 0.0; + double gcpav = 0.0; + double lngcpa = 0.0; + double gcpavv = 1.0; + double gcpavvv = 0.0; + double gcpa = 0.0; + int[][][] selfAccociationScheme = null; int[][][][] crossAccociationScheme = null; static Logger logger = LogManager.getLogger(PhasePCSAFTa.class); @@ -383,7 +389,9 @@ public double molarVolume(double pressure, double temperature, double A, double BonV = 1.0 - 1.0e-6; } double BonVold = BonV; - double Btemp = 0, h = 0, dh = 0; + double Btemp = 0; + double h = 0; + double dh = 0; // double gvvv = 0, fvvv = 0, dhh = 0, d2 = 0; double d1 = 0; Btemp = getB(); @@ -410,7 +418,7 @@ public double molarVolume(double pressure, double temperature, double A, double d1 = -h / dh; // d2 = -dh / dhh; - BonV += d1;// (1.0+0.5*-1.0); + BonV += d1; // (1.0+0.5*-1.0); // if(Math.abs(d1/d2)<=1.0){ // BonV += d1*(1.0+0.5*d1/d2); // } else if(d1/d2<-1){ @@ -449,7 +457,7 @@ public double molarVolume(double pressure, double temperature, double A, double throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); // if(phaseType==0) // System.out.println("density " + - // getDensity());//"BonV: " + BonV + " + // getDensity()); //"BonV: " + BonV + " // "+" itert: " + // iterations +" " + " phase " + // phaseType+ " " + h + diff --git a/src/main/java/neqsim/thermo/phase/PhasePrEosvolcor.java b/src/main/java/neqsim/thermo/phase/PhasePrEosvolcor.java index c1b853da90..f118854482 100644 --- a/src/main/java/neqsim/thermo/phase/PhasePrEosvolcor.java +++ b/src/main/java/neqsim/thermo/phase/PhasePrEosvolcor.java @@ -134,7 +134,7 @@ public double calcC(PhaseInterface phase, double temperature, double pressure, for (int j = 0; j < numbcomp; j++) { C += compArray[i].getNumberOfMolesInPhase() * compArray[j].getNumberOfMolesInPhase() - * getcij(compArray[i], compArray[j]);// (compArray[i].getb()+compArray[j].getb())/2; + * getcij(compArray[i], compArray[j]); // (compArray[i].getb()+compArray[j].getb())/2; } } C /= phase.getNumberOfMolesInPhase(); diff --git a/src/main/java/neqsim/thermo/phase/PhaseSrkCPA.java b/src/main/java/neqsim/thermo/phase/PhaseSrkCPA.java index 36eb5fead5..81c63e56af 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseSrkCPA.java +++ b/src/main/java/neqsim/thermo/phase/PhaseSrkCPA.java @@ -21,2100 +21,2132 @@ * @version $Id: $Id */ public class PhaseSrkCPA extends PhaseSrkEos implements PhaseCPAInterface { - /** - *

- * Getter for the field dFdNtemp. - *

- * - * @return the dFdNtemp - */ - public double[] getdFdNtemp() { - return dFdNtemp; - } - - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(PhaseSrkCPA.class); - - public CPAMixing cpaSelect = new CPAMixing(); - public CPAMixingInterface cpamix; - double gcpavv = 0.0, gcpavvv = 0.0, gcpa = 0.0, hcpatot = 1.0, FCPA = 0.0, dFCPAdTdV, - dFCPAdTdT = 0.0, dFCPAdT = 0, dFCPAdV = 0, dFCPAdVdV = 0.0, dFCPAdVdVdV = 0.0; - double gcpav = 0.0, tempTotVol = 0; - private double[] dFdNtemp = {0, 0}; - int cpaon = 1, oldTotalNumberOfAccociationSites = 0; - int totalNumberOfAccociationSites = 0; - int[][][] selfAccociationScheme = null; - int[][][][] crossAccociationScheme = null; - int[] activeAccosComp = null;// new int[100]; - private double[] lngi; - int[] moleculeNumber = null, assSiteNumber = null; - private double[][] gvector = null, delta = null, deltaNog = null, deltadT = null, - deltadTdT = null; - double[][][] Klkni = null; - private SimpleMatrix KlkTVMatrix = null, KlkTTMatrix = null, KlkTMatrix = null, - udotTimesmMatrix = null, mVector = null, udotMatrix = null, uMatrix = null, - QMatksiksiksi = null, KlkVVVMatrix = null, KlkVVMatrix = null, udotTimesmiMatrix = null, - ksiMatrix = null, KlkMatrix = null, hessianMatrix = null, hessianInvers = null, - KlkVMatrix = null; - private DMatrixRMaj corr2Matrix = null, corr3Matrix = null, corr4Matrix = null;// new - // DenseMatrix64F(getTotalNumberOfAccociationSites(), - // 1); - - /** - *

- * Constructor for PhaseSrkCPA. - *

- */ - public PhaseSrkCPA() { - super(); - thermoPropertyModelName = "SRK-CPA-EoS"; - } - - /** {@inheritDoc} */ - @Override - public PhaseSrkCPA clone() { - PhaseSrkCPA clonedPhase = null; - try { - clonedPhase = (PhaseSrkCPA) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } - if (activeAccosComp != null) { - clonedPhase.activeAccosComp = activeAccosComp.clone(); - System.arraycopy(this.activeAccosComp, 0, clonedPhase.activeAccosComp, 0, - activeAccosComp.length); + /** + *

+ * Getter for the field dFdNtemp. + *

+ * + * @return the dFdNtemp + */ + public double[] getdFdNtemp() { + return dFdNtemp; + } + + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(PhaseSrkCPA.class); + + public CPAMixing cpaSelect = new CPAMixing(); + public CPAMixingInterface cpamix; + double gcpavv = 0.0; + double gcpavvv = 0.0; + double gcpa = 0.0; + double hcpatot = 1.0; + double FCPA = 0.0; + double dFCPAdTdV; + double dFCPAdTdT = 0.0; + double dFCPAdT = 0; + double dFCPAdV = 0; + double dFCPAdVdV = 0.0; + double dFCPAdVdVdV = 0.0; + double gcpav = 0.0; + double tempTotVol = 0; + private double[] dFdNtemp = {0, 0}; + int cpaon = 1; + int oldTotalNumberOfAccociationSites = 0; + int totalNumberOfAccociationSites = 0; + int[][][] selfAccociationScheme = null; + int[][][][] crossAccociationScheme = null; + int[] activeAccosComp = null; // new int[100]; + private double[] lngi; + int[] moleculeNumber = null; + int[] assSiteNumber = null; + private double[][] gvector = null; + private double[][] delta = null; + private double[][] deltaNog = null; + private double[][] deltadT = null; + private double[][] deltadTdT = null; + double[][][] Klkni = null; + private SimpleMatrix KlkTVMatrix = null; + private SimpleMatrix KlkTTMatrix = null; + private SimpleMatrix KlkTMatrix = null; + private SimpleMatrix udotTimesmMatrix = null; + private SimpleMatrix mVector = null; + private SimpleMatrix udotMatrix = null; + private SimpleMatrix uMatrix = null; + private SimpleMatrix QMatksiksiksi = null; + private SimpleMatrix KlkVVVMatrix = null; + private SimpleMatrix KlkVVMatrix = null; + private SimpleMatrix udotTimesmiMatrix = null; + private SimpleMatrix ksiMatrix = null; + private SimpleMatrix KlkMatrix = null; + private SimpleMatrix hessianMatrix = null; + private SimpleMatrix hessianInvers = null; + private SimpleMatrix KlkVMatrix = null; + private DMatrixRMaj corr2Matrix = null; + private DMatrixRMaj corr3Matrix = null; + private DMatrixRMaj corr4Matrix = null; + + /** + *

+ * Constructor for PhaseSrkCPA. + *

+ */ + public PhaseSrkCPA() { + super(); + thermoPropertyModelName = "SRK-CPA-EoS"; + } + + /** {@inheritDoc} */ + @Override + public PhaseSrkCPA clone() { + PhaseSrkCPA clonedPhase = null; + try { + clonedPhase = (PhaseSrkCPA) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); + } + if (activeAccosComp != null) { + clonedPhase.activeAccosComp = activeAccosComp.clone(); + System.arraycopy(this.activeAccosComp, 0, clonedPhase.activeAccosComp, 0, + activeAccosComp.length); + } + // clonedPhase.cpaSelect = (CPAMixing) cpaSelect.clone(); + // clonedPhase.cpamix = (CPAMixingInterface) cpamix.clone(); + // clonedPhase.cpamix = cpaSelect.getMixingRule(1, this); + + return clonedPhase; + } + + /** {@inheritDoc} */ + @Override + public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, + double beta) { + boolean changedAssosiationStatus = false; + + if (type == 0) { + activeAccosComp = new int[numberOfComponents]; + for (int i = 0; i < numberOfComponents; i++) { + if (componentArray[i].getNumberOfmoles() < 1e-50) { + componentArray[i].setNumberOfAssociationSites(0); + if (activeAccosComp[i] == 1) { + activeAccosComp[i] = 0; + changedAssosiationStatus = true; + } + } else { + if (activeAccosComp[i] == 0) { + changedAssosiationStatus = true; + activeAccosComp[i] = 1; + } } - // clonedPhase.cpaSelect = (CPAMixing) cpaSelect.clone(); - // clonedPhase.cpamix = (CPAMixingInterface) cpamix.clone(); - // clonedPhase.cpamix = cpaSelect.getMixingRule(1, this); - - return clonedPhase; - } - - /** {@inheritDoc} */ - @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, - double beta) { - boolean changedAssosiationStatus = false; - - if (type == 0) { - activeAccosComp = new int[numberOfComponents]; - for (int i = 0; i < numberOfComponents; i++) { - if (componentArray[i].getNumberOfmoles() < 1e-50) { - componentArray[i].setNumberOfAssociationSites(0); - if (activeAccosComp[i] == 1) { - activeAccosComp[i] = 0; - changedAssosiationStatus = true; - } - } else { - if (activeAccosComp[i] == 0) { - changedAssosiationStatus = true; - activeAccosComp[i] = 1; - } - } - } - - if (changedAssosiationStatus || lngi == null) { - setTotalNumberOfAccociationSites(0); - selfAccociationScheme = new int[numberOfComponents][0][0]; - crossAccociationScheme = new int[numberOfComponents][numberOfComponents][0][0]; - for (int i = 0; i < numberOfComponents; i++) { - if (componentArray[i].getNumberOfmoles() < 1e-50) { - componentArray[i].setNumberOfAssociationSites(0); - } else { - componentArray[i].setNumberOfAssociationSites( - componentArray[i].getOrginalNumberOfAssociationSites()); - setTotalNumberOfAccociationSites(getTotalNumberOfAccociationSites() - + componentArray[i].getNumberOfAssociationSites()); - selfAccociationScheme[i] = cpaSelect.setAssociationScheme(i, this); - for (int j = 0; j < numberOfComponents; j++) { - crossAccociationScheme[i][j] = - cpaSelect.setCrossAssociationScheme(i, j, this); - } - } - } - } + } - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - ((ComponentSrkCPA) componentArray[i]).setXsite(j, 1.0); - ((ComponentSrkCPA) componentArray[i]).setXsitedV(j, 0.0); - ((ComponentSrkCPA) componentArray[i]).setXsitedT(j, 0.0); - } - } - - if (changedAssosiationStatus || lngi == null || mVector == null) { - lngi = new double[numberOfComponents]; - mVector = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - KlkMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkVVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkVVVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - hessianMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkTMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkTTMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkTVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - corr2Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - corr3Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - corr4Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - Klkni = new double[numberOfComponents][getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - ksiMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - uMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - udotMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - moleculeNumber = new int[getTotalNumberOfAccociationSites()]; - assSiteNumber = new int[getTotalNumberOfAccociationSites()]; - gvector = new double[getTotalNumberOfAccociationSites()][1]; - udotTimesmMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - delta = new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - deltaNog = - new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - deltadT = - new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - deltadTdT = - new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - QMatksiksiksi = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - udotTimesmiMatrix = - new SimpleMatrix(numberOfComponents, getTotalNumberOfAccociationSites()); - - oldTotalNumberOfAccociationSites = getTotalNumberOfAccociationSites(); - - int temp = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - moleculeNumber[temp + j] = i; - assSiteNumber[temp + j] = j; - } - temp += componentArray[i].getNumberOfAssociationSites(); - } + if (changedAssosiationStatus || lngi == null) { + setTotalNumberOfAccociationSites(0); + selfAccociationScheme = new int[numberOfComponents][0][0]; + crossAccociationScheme = new int[numberOfComponents][numberOfComponents][0][0]; + for (int i = 0; i < numberOfComponents; i++) { + if (componentArray[i].getNumberOfmoles() < 1e-50) { + componentArray[i].setNumberOfAssociationSites(0); + } else { + componentArray[i].setNumberOfAssociationSites( + componentArray[i].getOrginalNumberOfAssociationSites()); + setTotalNumberOfAccociationSites(getTotalNumberOfAccociationSites() + + componentArray[i].getNumberOfAssociationSites()); + selfAccociationScheme[i] = cpaSelect.setAssociationScheme(i, this); + for (int j = 0; j < numberOfComponents; j++) { + crossAccociationScheme[i][j] = cpaSelect.setCrossAssociationScheme(i, j, this); } - } + } + } + } + + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + ((ComponentSrkCPA) componentArray[i]).setXsite(j, 1.0); + ((ComponentSrkCPA) componentArray[i]).setXsitedV(j, 0.0); + ((ComponentSrkCPA) componentArray[i]).setXsitedT(j, 0.0); + } + } + + if (changedAssosiationStatus || lngi == null || mVector == null) { + lngi = new double[numberOfComponents]; + mVector = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + KlkMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkVVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkVVVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + hessianMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkTMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkTTMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkTVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + corr2Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + corr3Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + corr4Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + Klkni = + new double[numberOfComponents][getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + ksiMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + uMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + udotMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + moleculeNumber = new int[getTotalNumberOfAccociationSites()]; + assSiteNumber = new int[getTotalNumberOfAccociationSites()]; + gvector = new double[getTotalNumberOfAccociationSites()][1]; + udotTimesmMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + delta = new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + deltaNog = + new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + deltadT = + new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + deltadTdT = + new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + QMatksiksiksi = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + udotTimesmiMatrix = + new SimpleMatrix(numberOfComponents, getTotalNumberOfAccociationSites()); + + oldTotalNumberOfAccociationSites = getTotalNumberOfAccociationSites(); - if (cpamix == null) { - cpamix = cpaSelect.getMixingRule(1, this); - } - if (type > 0) { - calcDelta(); + int temp = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + moleculeNumber[temp + j] = i; + assSiteNumber[temp + j] = j; + } + temp += componentArray[i].getNumberOfAssociationSites(); } + } + } - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + if (cpamix == null) { + cpamix = cpaSelect.getMixingRule(1, this); + } + if (type > 0) { + calcDelta(); + } - if (type > 0 && isConstantPhaseVolume()) { - solveX(); - super.init(totalNumberOfMoles, numberOfComponents, 1, phase, beta); - gcpa = calc_g(); - gcpav = calc_lngV(); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - } + super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - if (type > 0) { - hcpatot = calc_hCPA(); - } + if (type > 0 && isConstantPhaseVolume()) { + solveX(); + super.init(totalNumberOfMoles, numberOfComponents, 1, phase, beta); + gcpa = calc_g(); + gcpav = calc_lngV(); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); + } - if (type > 1) { - initCPAMatrix(type); - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - } + if (type > 0) { + hcpatot = calc_hCPA(); } - /** - *

- * initCPAMatrix. - *

- * - * @param type a int - */ - public void initCPAMatrix(int type) { - if (totalNumberOfAccociationSites == 0) { - FCPA = 0.0; - dFCPAdTdV = 0.0; - dFCPAdTdT = 0.0; - dFCPAdT = 0; - dFCPAdV = 0; - dFCPAdVdV = 0.0; - dFCPAdVdVdV = 0.0; - return; - } + if (type > 1) { + initCPAMatrix(type); + super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + } + } + + /** + *

+ * initCPAMatrix. + *

+ * + * @param type a int + */ + public void initCPAMatrix(int type) { + if (totalNumberOfAccociationSites == 0) { + FCPA = 0.0; + dFCPAdTdV = 0.0; + dFCPAdTdT = 0.0; + dFCPAdT = 0; + dFCPAdV = 0; + dFCPAdVdV = 0.0; + dFCPAdVdVdV = 0.0; + return; + } - int temp = 0; - double tempVar1, tempVar2; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - tempVar1 = ksiMatrix.get(temp + j, 0); - tempVar2 = udotMatrix.get(temp + j, 0); - uMatrix.set(temp + j, 0, Math.log(tempVar1) - tempVar1 + 1.0); - gvector[temp + j][0] = mVector.get(temp + j, 0) * tempVar2; - - if (moleculeNumber[temp + j] == i) { - udotTimesmiMatrix.set(i, temp + j, tempVar2); - } else { - udotTimesmiMatrix.set(i, temp + j, 0.0); - } - } - temp += componentArray[i].getNumberOfAssociationSites(); + int temp = 0; + double tempVar1; + double tempVar2; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + tempVar1 = ksiMatrix.get(temp + j, 0); + tempVar2 = udotMatrix.get(temp + j, 0); + uMatrix.set(temp + j, 0, Math.log(tempVar1) - tempVar1 + 1.0); + gvector[temp + j][0] = mVector.get(temp + j, 0) * tempVar2; + + if (moleculeNumber[temp + j] == i) { + udotTimesmiMatrix.set(i, temp + j, tempVar2); + } else { + udotTimesmiMatrix.set(i, temp + j, 0.0); } + } + temp += componentArray[i].getNumberOfAssociationSites(); + } - if (type > 2) { - for (int p = 0; p < numberOfComponents; p++) { - lngi[p] = ((ComponentSrkCPA) componentArray[p]).calc_lngi(this); - } - } + if (type > 2) { + for (int p = 0; p < numberOfComponents; p++) { + lngi[p] = ((ComponentSrkCPA) componentArray[p]).calc_lngi(this); + } + } - for (int i = 0; i < totalNumberOfAccociationSites; i++) { - for (int j = i; j < totalNumberOfAccociationSites; j++) { - delta[i][j] = deltaNog[i][j] * gcpa; - delta[j][i] = delta[i][j]; - if (type > 1) { - deltadT[i][j] = cpamix.calcDeltadT(assSiteNumber[i], assSiteNumber[j], - moleculeNumber[i], moleculeNumber[j], this, getTemperature(), - getPressure(), numberOfComponents); - deltadT[j][i] = deltadT[i][j]; - - deltadTdT[i][j] = cpamix.calcDeltadTdT(assSiteNumber[i], assSiteNumber[j], - moleculeNumber[i], moleculeNumber[j], this, getTemperature(), - getPressure(), numberOfComponents); - deltadTdT[j][i] = deltadTdT[i][j]; - } - } - } + for (int i = 0; i < totalNumberOfAccociationSites; i++) { + for (int j = i; j < totalNumberOfAccociationSites; j++) { + delta[i][j] = deltaNog[i][j] * gcpa; + delta[j][i] = delta[i][j]; + if (type > 1) { + deltadT[i][j] = cpamix.calcDeltadT(assSiteNumber[i], assSiteNumber[j], moleculeNumber[i], + moleculeNumber[j], this, getTemperature(), getPressure(), numberOfComponents); + deltadT[j][i] = deltadT[i][j]; - double totalVolume = getTotalVolume(); - double totalVolume2 = totalVolume * totalVolume, totalVolume3 = totalVolume2 * totalVolume; - double gdv1 = getGcpav() - 1.0 / totalVolume; - double gdv2 = gdv1 * gdv1; - double gdv3 = gdv2 * gdv1; - double Klk = 0.0; - double tempVar; - double tempKsiRead = 0.0; - for (int i = 0; i < totalNumberOfAccociationSites; i++) { - for (int j = i; j < totalNumberOfAccociationSites; j++) { - Klk = KlkMatrix.get(i, j); - tempVar = Klk * gdv1; - KlkVMatrix.set(i, j, tempVar); - KlkVMatrix.set(j, i, tempVar); - - tempVar = Klk * gdv2 + Klk * (gcpavv + 1.0 / totalVolume2); - KlkVVMatrix.set(i, j, tempVar); - KlkVVMatrix.set(j, i, tempVar); - - tempVar = Klk * gdv3 - + 3.0 * Klk * (gcpav - 1.0 / totalVolume) * (gcpavv + 1.0 / (totalVolume2)) - + Klk * (gcpavvv - 2.0 / (totalVolume3)); - KlkVVVMatrix.set(i, j, tempVar); - KlkVVVMatrix.set(j, i, tempVar); - - if (type > 1) { - tempVar = deltadT[i][j] / delta[i][j]; - - if (Math.abs(tempVar) > 1e-50) { - double tempVardT = deltadTdT[i][j] / delta[i][j] - - (deltadT[i][j] * deltadT[i][j]) / (delta[i][j] * delta[i][j]); - - tempVar2 = Klk * tempVar; - KlkTMatrix.set(i, j, tempVar2); - KlkTMatrix.set(j, i, tempVar2); - - tempVar2 = Klk * tempVar * (gcpav - 1.0 / totalVolume); - KlkTVMatrix.set(i, j, tempVar2); - KlkTVMatrix.set(j, i, tempVar2); - - tempVar2 = Klk * (tempVar * tempVar + tempVardT); - KlkTTMatrix.set(i, j, tempVar2); - KlkTTMatrix.set(j, i, tempVar2); - } - - if (type > 2) { - for (int p = 0; p < numberOfComponents; p++) { - double t1 = 0.0, t2 = 0.0; - if (moleculeNumber[i] == p) { - t1 = 1.0 / mVector.get(i, 0); - } - if (moleculeNumber[j] == p) { - t2 = 1.0 / mVector.get(j, 0); - } - Klkni[p][i][j] = Klk * (t1 + t2 + lngi[p]);// ((ComponentSrkCPA) - // getComponent(p)).calc_lngi(this)); - Klkni[p][j][i] = Klkni[p][i][j]; - } - } - } - } - tempKsiRead = ksiMatrix.get(i, 0); - QMatksiksiksi.set(i, 0, - 2.0 * mVector.get(i, 0) / (tempKsiRead * tempKsiRead * tempKsiRead)); + deltadTdT[i][j] = + cpamix.calcDeltadTdT(assSiteNumber[i], assSiteNumber[j], moleculeNumber[i], + moleculeNumber[j], this, getTemperature(), getPressure(), numberOfComponents); + deltadTdT[j][i] = deltadTdT[i][j]; } + } + } - SimpleMatrix ksiMatrixTranspose = ksiMatrix.transpose(); - - // dXdV - SimpleMatrix KlkVMatrixksi = KlkVMatrix.mult(ksiMatrix); - SimpleMatrix XV = hessianInvers.mult(KlkVMatrixksi); - SimpleMatrix XVtranspose = XV.transpose(); + double totalVolume = getTotalVolume(); + double totalVolume2 = totalVolume * totalVolume; + double totalVolume3 = totalVolume2 * totalVolume; + double gdv1 = getGcpav() - 1.0 / totalVolume; + double gdv2 = gdv1 * gdv1; + double gdv3 = gdv2 * gdv1; + double Klk = 0.0; + double tempVar; + double tempKsiRead = 0.0; + for (int i = 0; i < totalNumberOfAccociationSites; i++) { + for (int j = i; j < totalNumberOfAccociationSites; j++) { + Klk = KlkMatrix.get(i, j); + tempVar = Klk * gdv1; + KlkVMatrix.set(i, j, tempVar); + KlkVMatrix.set(j, i, tempVar); + + tempVar = Klk * gdv2 + Klk * (gcpavv + 1.0 / totalVolume2); + KlkVVMatrix.set(i, j, tempVar); + KlkVVMatrix.set(j, i, tempVar); + + tempVar = + Klk * gdv3 + 3.0 * Klk * (gcpav - 1.0 / totalVolume) * (gcpavv + 1.0 / (totalVolume2)) + + Klk * (gcpavvv - 2.0 / (totalVolume3)); + KlkVVVMatrix.set(i, j, tempVar); + KlkVVVMatrix.set(j, i, tempVar); - FCPA = mVector.transpose().mult(uMatrix.minus(ksiMatrix.elementMult(udotMatrix).scale(0.5))) - .get(0, 0);// QCPA.get(0, - // 0);//*0.5; + if (type > 1) { + tempVar = deltadT[i][j] / delta[i][j]; - dFCPAdV = ksiMatrixTranspose.mult(KlkVMatrixksi).get(0, 0) * (-0.5); - SimpleMatrix KlkVVMatrixTImesKsi = KlkVVMatrix.mult(ksiMatrix); - dFCPAdVdV = ksiMatrixTranspose.mult(KlkVVMatrixTImesKsi).scale(-0.5) - .minus(KlkVMatrixksi.transpose().mult(XV)).get(0, 0); + if (Math.abs(tempVar) > 1e-50) { + double tempVardT = deltadTdT[i][j] / delta[i][j] + - (deltadT[i][j] * deltadT[i][j]) / (delta[i][j] * delta[i][j]); - SimpleMatrix QVVV = ksiMatrixTranspose.mult(KlkVVVMatrix.mult(ksiMatrix));// .scale(-0.5); - SimpleMatrix QVVksi = KlkVVMatrixTImesKsi.scale(-1.0); - SimpleMatrix QksiVksi = KlkVMatrix.scale(-1.0); + tempVar2 = Klk * tempVar; + KlkTMatrix.set(i, j, tempVar2); + KlkTMatrix.set(j, i, tempVar2); - dFCPAdVdVdV = -0.5 * QVVV.get(0, 0) + QVVksi.transpose().mult(XV).get(0, 0) * 3.0 - + XVtranspose.mult(QksiVksi.mult(XV)).get(0, 0) * 3.0 - + XVtranspose.mult(QMatksiksiksi.mult(XVtranspose)).mult(XV).get(0, 0); + tempVar2 = Klk * tempVar * (gcpav - 1.0 / totalVolume); + KlkTVMatrix.set(i, j, tempVar2); + KlkTVMatrix.set(j, i, tempVar2); - if (type == 1) { - return; - } + tempVar2 = Klk * (tempVar * tempVar + tempVardT); + KlkTTMatrix.set(i, j, tempVar2); + KlkTTMatrix.set(j, i, tempVar2); + } - temp = 0; - for (int p = 0; p < numberOfComponents; p++) { - for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { - ((ComponentCPAInterface) getComponent(p)).setXsitedV(kk, XV.get(temp + kk, 0)); + if (type > 2) { + for (int p = 0; p < numberOfComponents; p++) { + double t1 = 0.0; + double t2 = 0.0; + if (moleculeNumber[i] == p) { + t1 = 1.0 / mVector.get(i, 0); + } + if (moleculeNumber[j] == p) { + t2 = 1.0 / mVector.get(j, 0); + } + Klkni[p][i][j] = Klk * (t1 + t2 + lngi[p]); // ((ComponentSrkCPA) + // getComponent(p)).calc_lngi(this)); + Klkni[p][j][i] = Klkni[p][i][j]; } - temp += getComponent(p).getNumberOfAssociationSites(); + } } + } + tempKsiRead = ksiMatrix.get(i, 0); + QMatksiksiksi.set(i, 0, 2.0 * mVector.get(i, 0) / (tempKsiRead * tempKsiRead * tempKsiRead)); + } - // KlkTMatrix = new SimpleMatrix(KlkdT); - SimpleMatrix KlkTMatrixTImesKsi = KlkTMatrix.mult(ksiMatrix); - // dQdT - SimpleMatrix tempMatrix2 = ksiMatrixTranspose.mult(KlkTMatrixTImesKsi);// .scale(-0.5); - dFCPAdT = tempMatrix2.get(0, 0) * (-0.5); - - // SimpleMatrix KlkTVMatrix = new SimpleMatrix(KlkdTdV); - // SimpleMatrix tempMatrixTV = - // ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5).minus(KlkTMatrixTImesKsi.transpose().mult(XV)); - // dFCPAdTdV = tempMatrixTV.get(0, 0); - // dXdT - SimpleMatrix XT = hessianInvers.mult(KlkTMatrixTImesKsi); - // dQdTdT - SimpleMatrix tempMatrixTT = ksiMatrixTranspose.mult(KlkTTMatrix.mult(ksiMatrix)).scale(-0.5) - .minus(KlkTMatrixTImesKsi.transpose().mult(XT)); - dFCPAdTdT = tempMatrixTT.get(0, 0); - - SimpleMatrix tempMatrixTV = ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5) - .minus(KlkTMatrixTImesKsi.transpose().mult(XV)); - dFCPAdTdV = tempMatrixTV.get(0, 0); - - temp = 0; - for (int p = 0; p < numberOfComponents; p++) { - for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { - ((ComponentCPAInterface) getComponent(p)).setXsitedT(kk, XT.get(temp + kk, 0)); - } - temp += getComponent(p).getNumberOfAssociationSites(); - } + SimpleMatrix ksiMatrixTranspose = ksiMatrix.transpose(); - if (type == 2) { - return; - } + // dXdV + SimpleMatrix KlkVMatrixksi = KlkVMatrix.mult(ksiMatrix); + SimpleMatrix XV = hessianInvers.mult(KlkVMatrixksi); + SimpleMatrix XVtranspose = XV.transpose(); - // int assSites = 0; - // if(true) return; - for (int p = 0; p < numberOfComponents; p++) { - SimpleMatrix KiMatrix = new SimpleMatrix(Klkni[p]); - // KiMatrix.print(10,10); - // Matrix dQdniMatrix = - // (ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5)); // this - // methods misses one part of .... - // dQdniMatrix.print(10,10); - // KiMatrix.print(10, 10); - // miMatrix.getMatrix(assSites, assSites, 0, totalNumberOfAccociationSites - - // 1).print(10, 10); - // Matrix tempMatrix20 = miMatrix.getMatrix(assSites, assSites, 0, - // totalNumberOfAccociationSites - - // 1).times(uMatrix).minus(ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5));// - // ksiMatrix.transpose().times(KlkTMatrix.times(ksiMatrix)).times(-0.5); - // System.out.println("dQdn "); - // tempMatrix20.print(10, 10); - SimpleMatrix tempMatrix4 = KiMatrix.mult(ksiMatrix); - // udotTimesmiMatrix.getMatrix(assSites, assSites, 0, - // totalNumberOfAccociationSites - 1).print(10, 10); - SimpleMatrix tempMatrix5 = - udotTimesmiMatrix.extractVector(true, p).transpose().minus(tempMatrix4); - // tempMki[0] = mki[p]; - // Matrix amatrix = new Matrix(croeneckerProduct(tempMki, - // udotMatrix.getArray())); - // System.out.println("aMatrix "); - // amatrix.transpose().print(10, 10); - // System.out.println("temp4 matrix"); - // tempMatrix4.print(10, 10); - // Matrix tempMatrix5 = amatrix.minus(tempMatrix4); - SimpleMatrix tempMatrix6 = hessianInvers.mult(tempMatrix5);// .scale(-1.0); - // System.out.println("dXdni"); - // tempMatrix4.print(10, 10); - // tempMatrix5.print(10, 10); - // System.out.println("dXdn "); - // tempMatrix6.print(10, 10); - int temp2 = 0; - for (int compp = 0; compp < numberOfComponents; compp++) { - for (int kk = 0; kk < getComponent(compp).getNumberOfAssociationSites(); kk++) { - ((ComponentCPAInterface) getComponent(compp)).setXsitedni(kk, p, - -1.0 * tempMatrix6.get(temp2 + kk, 0)); - } - temp2 += getComponent(compp).getNumberOfAssociationSites(); - } - // assSites += getComponent(p).getNumberOfAssociationSites(); - } - } - - /** {@inheritDoc} */ - @Override - public void setMixingRule(int type) { - super.setMixingRule(type); - cpamix = cpaSelect.getMixingRule(1, this); - } + FCPA = mVector.transpose().mult(uMatrix.minus(ksiMatrix.elementMult(udotMatrix).scale(0.5))) + .get(0, 0); // QCPA.get(0, + // 0); //*0.5; - /** - *

- * calcDelta. - *

- */ - public void calcDelta() { - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - deltaNog[i][j] = cpamix.calcDeltaNog(assSiteNumber[i], assSiteNumber[j], - moleculeNumber[i], moleculeNumber[j], this, getTemperature(), getPressure(), - numberOfComponents); - deltaNog[j][i] = deltaNog[i][j]; - } - } - } + dFCPAdV = ksiMatrixTranspose.mult(KlkVMatrixksi).get(0, 0) * (-0.5); + SimpleMatrix KlkVVMatrixTImesKsi = KlkVVMatrix.mult(ksiMatrix); + dFCPAdVdV = ksiMatrixTranspose.mult(KlkVVMatrixTImesKsi).scale(-0.5) + .minus(KlkVMatrixksi.transpose().mult(XV)).get(0, 0); - /** {@inheritDoc} */ - @Override - public void addcomponent(String componentName, double moles, double molesInPhase, - int compNumber) { - super.addcomponent(componentName, moles, molesInPhase, compNumber); - componentArray[compNumber] = - new ComponentSrkCPA(componentName, moles, molesInPhase, compNumber); - } + SimpleMatrix QVVV = ksiMatrixTranspose.mult(KlkVVVMatrix.mult(ksiMatrix)); // .scale(-0.5); + SimpleMatrix QVVksi = KlkVVMatrixTImesKsi.scale(-1.0); + SimpleMatrix QksiVksi = KlkVMatrix.scale(-1.0); - /** {@inheritDoc} */ - @Override - public double getF() { - return super.getF() + cpaon * FCPA(); - } + dFCPAdVdVdV = -0.5 * QVVV.get(0, 0) + QVVksi.transpose().mult(XV).get(0, 0) * 3.0 + + XVtranspose.mult(QksiVksi.mult(XV)).get(0, 0) * 3.0 + + XVtranspose.mult(QMatksiksiksi.mult(XVtranspose)).mult(XV).get(0, 0); - /** {@inheritDoc} */ - @Override - public double dFdT() { - return super.dFdT() + cpaon * dFCPAdT(); + if (type == 1) { + return; } - /** {@inheritDoc} */ - @Override - public double dFdTdV() { - return super.dFdTdV() + cpaon * dFCPAdTdV(); + temp = 0; + for (int p = 0; p < numberOfComponents; p++) { + for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { + ((ComponentCPAInterface) getComponent(p)).setXsitedV(kk, XV.get(temp + kk, 0)); + } + temp += getComponent(p).getNumberOfAssociationSites(); } - /** {@inheritDoc} */ - @Override - public double dFdV() { - double dv2 = dFCPAdV(); - return super.dFdV() + cpaon * dv2; + // KlkTMatrix = new SimpleMatrix(KlkdT); + SimpleMatrix KlkTMatrixTImesKsi = KlkTMatrix.mult(ksiMatrix); + // dQdT + SimpleMatrix tempMatrix2 = ksiMatrixTranspose.mult(KlkTMatrixTImesKsi); // .scale(-0.5); + dFCPAdT = tempMatrix2.get(0, 0) * (-0.5); + + // SimpleMatrix KlkTVMatrix = new SimpleMatrix(KlkdTdV); + // SimpleMatrix tempMatrixTV = + // ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5).minus(KlkTMatrixTImesKsi.transpose().mult(XV)); + // dFCPAdTdV = tempMatrixTV.get(0, 0); + // dXdT + SimpleMatrix XT = hessianInvers.mult(KlkTMatrixTImesKsi); + // dQdTdT + SimpleMatrix tempMatrixTT = ksiMatrixTranspose.mult(KlkTTMatrix.mult(ksiMatrix)).scale(-0.5) + .minus(KlkTMatrixTImesKsi.transpose().mult(XT)); + dFCPAdTdT = tempMatrixTT.get(0, 0); + + SimpleMatrix tempMatrixTV = ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5) + .minus(KlkTMatrixTImesKsi.transpose().mult(XV)); + dFCPAdTdV = tempMatrixTV.get(0, 0); + + temp = 0; + for (int p = 0; p < numberOfComponents; p++) { + for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { + ((ComponentCPAInterface) getComponent(p)).setXsitedT(kk, XT.get(temp + kk, 0)); + } + temp += getComponent(p).getNumberOfAssociationSites(); } - // @Override - /** {@inheritDoc} */ - @Override - public double dFdVdV() { - return super.dFdVdV() + cpaon * dFCPAdVdV(); + if (type == 2) { + return; } - /** {@inheritDoc} */ - @Override - public double dFdVdVdV() { - return super.dFdVdVdV() + cpaon * dFCPAdVdVdV(); + // int assSites = 0; + // if(true) return; + for (int p = 0; p < numberOfComponents; p++) { + SimpleMatrix KiMatrix = new SimpleMatrix(Klkni[p]); + // KiMatrix.print(10,10); + // Matrix dQdniMatrix = + // (ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5)); // this + // methods misses one part of .... + // dQdniMatrix.print(10,10); + // KiMatrix.print(10, 10); + // miMatrix.getMatrix(assSites, assSites, 0, totalNumberOfAccociationSites - + // 1).print(10, 10); + // Matrix tempMatrix20 = miMatrix.getMatrix(assSites, assSites, 0, + // totalNumberOfAccociationSites - + // 1).times(uMatrix).minus(ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5)); + // // + // ksiMatrix.transpose().times(KlkTMatrix.times(ksiMatrix)).times(-0.5); + // System.out.println("dQdn "); + // tempMatrix20.print(10, 10); + SimpleMatrix tempMatrix4 = KiMatrix.mult(ksiMatrix); + // udotTimesmiMatrix.getMatrix(assSites, assSites, 0, + // totalNumberOfAccociationSites - 1).print(10, 10); + SimpleMatrix tempMatrix5 = + udotTimesmiMatrix.extractVector(true, p).transpose().minus(tempMatrix4); + // tempMki[0] = mki[p]; + // Matrix amatrix = new Matrix(croeneckerProduct(tempMki, + // udotMatrix.getArray())); + // System.out.println("aMatrix "); + // amatrix.transpose().print(10, 10); + // System.out.println("temp4 matrix"); + // tempMatrix4.print(10, 10); + // Matrix tempMatrix5 = amatrix.minus(tempMatrix4); + SimpleMatrix tempMatrix6 = hessianInvers.mult(tempMatrix5); // .scale(-1.0); + // System.out.println("dXdni"); + // tempMatrix4.print(10, 10); + // tempMatrix5.print(10, 10); + // System.out.println("dXdn "); + // tempMatrix6.print(10, 10); + int temp2 = 0; + for (int compp = 0; compp < numberOfComponents; compp++) { + for (int kk = 0; kk < getComponent(compp).getNumberOfAssociationSites(); kk++) { + ((ComponentCPAInterface) getComponent(compp)).setXsitedni(kk, p, + -1.0 * tempMatrix6.get(temp2 + kk, 0)); + } + temp2 += getComponent(compp).getNumberOfAssociationSites(); + } + // assSites += getComponent(p).getNumberOfAssociationSites(); } - - /** {@inheritDoc} */ - @Override - public double dFdTdT() { - return super.dFdTdT() + cpaon * dFCPAdTdT(); + } + + /** {@inheritDoc} */ + @Override + public void setMixingRule(int type) { + super.setMixingRule(type); + cpamix = cpaSelect.getMixingRule(1, this); + } + + /** + *

+ * calcDelta. + *

+ */ + public void calcDelta() { + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + deltaNog[i][j] = cpamix.calcDeltaNog(assSiteNumber[i], assSiteNumber[j], moleculeNumber[i], + moleculeNumber[j], this, getTemperature(), getPressure(), numberOfComponents); + deltaNog[j][i] = deltaNog[i][j]; + } } - - /** - *

- * FCPA. - *

- * - * @return a double - */ - public double FCPA() { - /* - * double tot = 0.0; double ans = 0.0; for (int i = 0; i < numberOfComponents; i++) { tot = - * 0.0; for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { double - * xai = ((ComponentSrkCPA) componentArray[i]).getXsite()[j]; tot += (Math.log(xai) - 1.0 / - * 2.0 * xai + 1.0 / 2.0); } ans += componentArray[i].getNumberOfMolesInPhase() * tot; } - * return ans; - */ - return FCPA; - } - - /** - *

- * dFCPAdV. - *

- * - * @return a double - */ - public double dFCPAdV() { - // return 1.0 / (2.0 * getTotalVolume()) * (1.0 - getTotalVolume() * getGcpav()) - // * hcpatot; - return dFCPAdV; - } - - /** - *

- * dFCPAdVdV. - *

- * - * @return a double - */ - public double dFCPAdVdV() { - // double sum1 = -1.0 / 2.0 * gcpavv * hcpatot; - // return -1.0 / getTotalVolume() * dFCPAdV() + sum1; - return dFCPAdVdV; - } - - /** - *

- * dFCPAdVdVdV. - *

- * - * @return a double + } + + /** {@inheritDoc} */ + @Override + public void addcomponent(String componentName, double moles, double molesInPhase, + int compNumber) { + super.addcomponent(componentName, moles, molesInPhase, compNumber); + componentArray[compNumber] = + new ComponentSrkCPA(componentName, moles, molesInPhase, compNumber); + } + + /** {@inheritDoc} */ + @Override + public double getF() { + return super.getF() + cpaon * FCPA(); + } + + /** {@inheritDoc} */ + @Override + public double dFdT() { + return super.dFdT() + cpaon * dFCPAdT(); + } + + /** {@inheritDoc} */ + @Override + public double dFdTdV() { + return super.dFdTdV() + cpaon * dFCPAdTdV(); + } + + /** {@inheritDoc} */ + @Override + public double dFdV() { + double dv2 = dFCPAdV(); + return super.dFdV() + cpaon * dv2; + } + + // @Override + /** {@inheritDoc} */ + @Override + public double dFdVdV() { + return super.dFdVdV() + cpaon * dFCPAdVdV(); + } + + /** {@inheritDoc} */ + @Override + public double dFdVdVdV() { + return super.dFdVdVdV() + cpaon * dFCPAdVdVdV(); + } + + /** {@inheritDoc} */ + @Override + public double dFdTdT() { + return super.dFdTdT() + cpaon * dFCPAdTdT(); + } + + /** + *

+ * FCPA. + *

+ * + * @return a double + */ + public double FCPA() { + /* + * double tot = 0.0; double ans = 0.0; for (int i = 0; i < numberOfComponents; i++) { tot = 0.0; + * for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { double xai = + * ((ComponentSrkCPA) componentArray[i]).getXsite()[j]; tot += (Math.log(xai) - 1.0 / 2.0 * xai + * + 1.0 / 2.0); } ans += componentArray[i].getNumberOfMolesInPhase() * tot; } return ans; */ - public double dFCPAdVdVdV() { - return dFCPAdVdVdV; - // return -1.0 / getTotalVolume() * dFCPAdVdV() + 1.0 / - // Math.pow(getTotalVolume(), 2.0) * dFCPAdV() - hcpatot / (2.0 * - // Math.pow(getTotalVolume(), 2.0)) * (-getGcpav() - getTotalVolume() * gcpavv) - // + hcpatot / (2.0 * getTotalVolume()) * (-gcpavv - getTotalVolume() * gcpavvv - // - gcpavv); - } - - /** - *

- * dFCPAdT. - *

- * - * @return a double + return FCPA; + } + + /** + *

+ * dFCPAdV. + *

+ * + * @return a double + */ + public double dFCPAdV() { + // return 1.0 / (2.0 * getTotalVolume()) * (1.0 - getTotalVolume() * getGcpav()) + // * hcpatot; + return dFCPAdV; + } + + /** + *

+ * dFCPAdVdV. + *

+ * + * @return a double + */ + public double dFCPAdVdV() { + // double sum1 = -1.0 / 2.0 * gcpavv * hcpatot; + // return -1.0 / getTotalVolume() * dFCPAdV() + sum1; + return dFCPAdVdV; + } + + /** + *

+ * dFCPAdVdVdV. + *

+ * + * @return a double + */ + public double dFCPAdVdVdV() { + return dFCPAdVdVdV; + // return -1.0 / getTotalVolume() * dFCPAdVdV() + 1.0 / + // Math.pow(getTotalVolume(), 2.0) * dFCPAdV() - hcpatot / (2.0 * + // Math.pow(getTotalVolume(), 2.0)) * (-getGcpav() - getTotalVolume() * gcpavv) + // + hcpatot / (2.0 * getTotalVolume()) * (-gcpavv - getTotalVolume() * gcpavvv + // - gcpavv); + } + + /** + *

+ * dFCPAdT. + *

+ * + * @return a double + */ + public double dFCPAdT() { + /* + * double tot = 0.0; double ans = 0.0; for (int i = 0; i < numberOfComponents; i++) { tot = 0.0; + * for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { double xai = + * ((ComponentSrkCPA) componentArray[i]).getXsite()[j]; double xaidT = ((ComponentSrkCPA) + * componentArray[i]).getXsitedT()[j]; tot += 1.0 / xai * xaidT - 0.5 * xaidT; // - 1.0 / 2.0 * + * xai + 1.0 / 2.0); } ans += componentArray[i].getNumberOfMolesInPhase() * tot; } + * System.out.println("dFCPAdT1 " + ans + " dfcpa2 " +dFCPAdT); return ans; */ - public double dFCPAdT() { - /* - * double tot = 0.0; double ans = 0.0; for (int i = 0; i < numberOfComponents; i++) { tot = - * 0.0; for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { double - * xai = ((ComponentSrkCPA) componentArray[i]).getXsite()[j]; double xaidT = - * ((ComponentSrkCPA) componentArray[i]).getXsitedT()[j]; tot += 1.0 / xai * xaidT - 0.5 * - * xaidT;// - 1.0 / 2.0 * xai + 1.0 / 2.0); } ans += - * componentArray[i].getNumberOfMolesInPhase() * tot; } System.out.println("dFCPAdT1 " + - * ans + " dfcpa2 " +dFCPAdT); return ans; - */ - return dFCPAdT; - } - - /** - *

- * dFCPAdTdT. - *

- * - * @return a double + return dFCPAdT; + } + + /** + *

+ * dFCPAdTdT. + *

+ * + * @return a double + */ + public double dFCPAdTdT() { + return dFCPAdTdT; + } + + /** + *

+ * dFCPAdTdV. + *

+ * + * @return a double + */ + public double dFCPAdTdV() { + // System.out.println("dFCPAdTdV1 " + dFCPAdTdV + " dFCPAdTdV " +( 1.0 / (2.0 * + // getTotalVolume()) * (1.0 - getTotalVolume() * getGcpav()) * hcpatotdT)); + return dFCPAdTdV; + /* + * if (totalNumberOfAccociationSites > 0) { return 1.0 / (2.0 * getTotalVolume()) * (1.0 - + * getTotalVolume() * getGcpav()) * hcpatotdT; } else { return 0; } */ - public double dFCPAdTdT() { - return dFCPAdTdT; + } + + /** {@inheritDoc} */ + @Override + public double molarVolume(double pressure, double temperature, double A, double B, int phasetype) + throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + + if (BonV < 0) { + BonV = 1.0e-8; } - /** - *

- * dFCPAdTdV. - *

- * - * @return a double - */ - public double dFCPAdTdV() { - // System.out.println("dFCPAdTdV1 " + dFCPAdTdV + " dFCPAdTdV " +( 1.0 / (2.0 * - // getTotalVolume()) * (1.0 - getTotalVolume() * getGcpav()) * hcpatotdT)); - return dFCPAdTdV; - /* - * if (totalNumberOfAccociationSites > 0) { return 1.0 / (2.0 * getTotalVolume()) * (1.0 - - * getTotalVolume() * getGcpav()) * hcpatotdT; } else { return 0; } - */ - } - - /** {@inheritDoc} */ - @Override - public double molarVolume(double pressure, double temperature, double A, double B, - int phasetype) throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - - if (BonV < 0) { - BonV = 1.0e-8; - } - - if (BonV >= 1.0) { - BonV = 0.9999; - } - double BonVold; - double BonV2; - double h = 0, dh = 0, dhh = 0; - double d1 = 0, d2 = 0; - double Btemp = getB(); - if (Btemp < 0) { - logger.info("b negative in volume calc"); - } - - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - int iterations = 0; - int maxIterations = 300; - do { - iterations++; - gcpa = calc_g(); - if (gcpa < 0) { - setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); - gcpa = calc_g(); - } - - // lngcpa = - // Math.log(gcpa); - gcpav = calc_lngV(); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); + if (BonV >= 1.0) { + BonV = 0.9999; + } + double BonVold; + double BonV2; + double h = 0; + double dh = 0; + double dhh = 0; + double d1 = 0; + double d2 = 0; + double Btemp = getB(); + if (Btemp < 0) { + logger.info("b negative in volume calc"); + } - if (totalNumberOfAccociationSites > 0) { - solveX(); - } + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + int iterations = 0; + int maxIterations = 300; + do { + iterations++; + gcpa = calc_g(); + if (gcpa < 0) { + setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); + gcpa = calc_g(); + } - initCPAMatrix(1); - - BonV2 = BonV * BonV; - BonVold = BonV; - h = BonV - Btemp / numberOfMolesInPhase * dFdV() - - pressure * Btemp / (numberOfMolesInPhase * R * temperature); - dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); - dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) - - (Btemp * Btemp) / (BonV2 * BonV2) - * (Btemp / numberOfMolesInPhase * dFdVdVdV()); - - d1 = -h / dh; - d2 = -dh / dhh; - // System.out.println("h " + h + " iter " + iterations + " " + d1 + " d2 " + d2 - // + " d1 / d2 " + (d1 / d2)); - if (Math.abs(d1 / d2) <= 1.0) { - BonV += d1 * (1.0 + 0.5 * d1 / d2); - } else if (d1 / d2 < -1) { - BonV += 0.5 * d1; - } else if (d1 > d2) { - return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - // BonV += d2; - // double hnew = h + d2 * dh; - // if (Math.abs(hnew) > Math.abs(h)) { - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / - // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * - // temperature * R); - // } - } else { - BonV += 0.5 * d1; - } - if (Math.abs((BonV - BonVold) / BonV) > 0.1) { - BonV = BonVold + 0.1 * (BonV - BonVold); - } - if (BonV < 0) { - if (iterations < 10) { - // System.out.println(iterations + " BonV " + BonV); - BonV = (BonVold + BonV) / 2.0; - } else { - return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - } - } + // lngcpa = + // Math.log(gcpa); + gcpav = calc_lngV(); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); - if (BonV >= 1.0) { - if (iterations < 10) { - BonV = (BonVold + BonV) / 2.0; - } else { - return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - } - } - /* - * if (BonV > 0.9999) { if (iterations < 10) { BonV = (BonVold + BonV) / 2.0; } else { - * // BonV = calcRootVolFinder(phasetype); // BonV = molarVolumeChangePhase(pressure, - * temperature, A, B, phasetype); // BonV = 0.9999; // BonV = phasetype == 1 ? 2.0 / - * (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / - * (numberOfMolesInPhase * temperature * R); } - * - * } else if (BonV < 0) { if (iterations < 10) { BonV = Math.abs(BonVold + BonV) / 2.0; - * } else { // BonV = calcRootVolFinder(phasetype); // return - * molarVolumeChangePhase(pressure, temperature, A, B, phasetype); // BonV = phasetype - * == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() - * / (numberOfMolesInPhase * temperature * R); } } - */ - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10 || Math.abs(h) > 1e-12) - && iterations < maxIterations); - - // System.out.println("h failed " + h + " Z" + Z + " iterations " + iterations + - // " BonV " + BonV); - // if (Math.abs(h) > 1e-12) { - // System.out.println("h failed " + h + " Z" + Z + " iterations " + iterations + - // " BonV " + BonV); - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + if (totalNumberOfAccociationSites > 0) { + solveX(); + } + + initCPAMatrix(1); + + BonV2 = BonV * BonV; + BonVold = BonV; + h = BonV - Btemp / numberOfMolesInPhase * dFdV() + - pressure * Btemp / (numberOfMolesInPhase * R * temperature); + dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); + dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) + - (Btemp * Btemp) / (BonV2 * BonV2) * (Btemp / numberOfMolesInPhase * dFdVdVdV()); + + d1 = -h / dh; + d2 = -dh / dhh; + // System.out.println("h " + h + " iter " + iterations + " " + d1 + " d2 " + d2 + // + " d1 / d2 " + (d1 / d2)); + if (Math.abs(d1 / d2) <= 1.0) { + BonV += d1 * (1.0 + 0.5 * d1 / d2); + } else if (d1 / d2 < -1) { + BonV += 0.5 * d1; + } else if (d1 > d2) { + return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // BonV += d2; + // double hnew = h + d2 * dh; + // if (Math.abs(hnew) > Math.abs(h)) { + // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * + // temperature * R); // } - // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); - // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); - // System.out.println("volume " + getTotalVolume() + " molar volume " + - // getMolarVolume()); - // if(iterations>=100) throw new util.exception.TooManyIterationsException(); - // System.out.println("error in volume " + - // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " - // firstterm " + (R*temperature/molarVolume) + " second " + - // R*temperature*dFdV()); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " - // " +dh + " B " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); - if (Double.isNaN(getMolarVolume())) { - throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " - // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" - // + fVV()); + } else { + BonV += 0.5 * d1; + } + if (Math.abs((BonV - BonVold) / BonV) > 0.1) { + BonV = BonVold + 0.1 * (BonV - BonVold); + } + if (BonV < 0) { + if (iterations < 10) { + // System.out.println(iterations + " BonV " + BonV); + BonV = (BonVold + BonV) / 2.0; + } else { + return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); } - dFdNtemp = calcdFdNtemp(); - return getMolarVolume(); - } + } - /** - * @return double[] - */ - double[] calcdFdNtemp() { - double tot1 = 0.0, tot2 = 0.0, tot3 = 0.0, tot4 = 0.0; - // double temp, temp2; - for (int k = 0; k < getNumberOfComponents(); k++) { - tot2 = 0.0; - tot3 = 0.0; - // temp = ((ComponentSrkCPA) getComponent(k)).calc_lngi(this); - // temp2 = ((ComponentSrkCPA) getComponent(k)).calc_lngidV(this); - for (int i = 0; i < getComponent(k).getNumberOfAssociationSites(); i++) { - tot2 -= 1.0 * ((ComponentSrkCPA) getComponent(k)).getXsitedV()[i]; - tot3 += (1.0 - ((ComponentSrkCPA) getComponent(k)).getXsite()[i]) * 1.0; - } - tot1 += 1.0 / 2.0 * tot2 * getComponent(k).getNumberOfMolesInPhase(); - tot4 += 0.5 * getComponent(k).getNumberOfMolesInPhase() * tot3; - } - return new double[] {-tot1, -tot4}; + if (BonV >= 1.0) { + if (iterations < 10) { + BonV = (BonVold + BonV) / 2.0; + } else { + return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + } + } + /* + * if (BonV > 0.9999) { if (iterations < 10) { BonV = (BonVold + BonV) / 2.0; } else { // BonV + * = calcRootVolFinder(phasetype); // BonV = molarVolumeChangePhase(pressure, temperature, A, + * B, phasetype); // BonV = 0.9999; // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + * getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * + * R); } + * + * } else if (BonV < 0) { if (iterations < 10) { BonV = Math.abs(BonVold + BonV) / 2.0; } else + * { // BonV = calcRootVolFinder(phasetype); // return molarVolumeChangePhase(pressure, + * temperature, A, B, phasetype); // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + * getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * + * R); } } + */ + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); + } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10 || Math.abs(h) > 1e-12) + && iterations < maxIterations); + + // System.out.println("h failed " + h + " Z" + Z + " iterations " + iterations + + // " BonV " + BonV); + // if (Math.abs(h) > 1e-12) { + // System.out.println("h failed " + h + " Z" + Z + " iterations " + iterations + + // " BonV " + BonV); + // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // } + // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); + // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); + // System.out.println("volume " + getTotalVolume() + " molar volume " + + // getMolarVolume()); + // if(iterations>=100) throw new util.exception.TooManyIterationsException(); + // System.out.println("error in volume " + + // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV())); // + " + // firstterm " + (R*temperature/molarVolume) + " second " + + // R*temperature*dFdV()); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " + // " +dh + " B " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); + if (Double.isNaN(getMolarVolume())) { + throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " + // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + // + fVV()); } - - /** - *

- * calc_hCPA. - *

- * - * @return a double - */ - public double calc_hCPA() { - double htot = 0.0; - double tot = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - htot = 0.0; - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - htot += (1.0 - ((ComponentSrkCPA) componentArray[i]).getXsite()[j]); - } - tot += componentArray[i].getNumberOfMolesInPhase() * htot; - } - return tot; + dFdNtemp = calcdFdNtemp(); + return getMolarVolume(); + } + + /** + * @return double[] + */ + double[] calcdFdNtemp() { + double tot1 = 0.0; + double tot2 = 0.0; + double tot3 = 0.0; + double tot4 = 0.0; + // double temp, temp2; + for (int k = 0; k < getNumberOfComponents(); k++) { + tot2 = 0.0; + tot3 = 0.0; + // temp = ((ComponentSrkCPA) getComponent(k)).calc_lngi(this); + // temp2 = ((ComponentSrkCPA) getComponent(k)).calc_lngidV(this); + for (int i = 0; i < getComponent(k).getNumberOfAssociationSites(); i++) { + tot2 -= 1.0 * ((ComponentSrkCPA) getComponent(k)).getXsitedV()[i]; + tot3 += (1.0 - ((ComponentSrkCPA) getComponent(k)).getXsite()[i]) * 1.0; + } + tot1 += 1.0 / 2.0 * tot2 * getComponent(k).getNumberOfMolesInPhase(); + tot4 += 0.5 * getComponent(k).getNumberOfMolesInPhase() * tot3; } - - /** - *

- * calc_g. - *

- * - * @return a double - */ - public double calc_g() { - tempTotVol = getMolarVolume(); - double temp = 1.0 - getb() / 4.0 / tempTotVol; - return (2.0 - getb() / 4.0 / tempTotVol) / (2.0 * temp * temp * temp); - } - - /** - *

- * calc_lngV. - *

- * - * @return a double - */ - public double calc_lngV() { - tempTotVol = getTotalVolume(); - // gv = -2.0 * getB() * (10.0 * getTotalVolume() - getB()) / getTotalVolume() / - // ((8.0 * getTotalVolume() - getB()) * (4.0 * getTotalVolume() - getB())); - return 1.0 / (2.0 - getB() / (4.0 * tempTotVol)) * getB() / (4.0 * tempTotVol * tempTotVol) - - 3.0 / (1.0 - getB() / (4.0 * tempTotVol)) * getB() - / (4.0 * tempTotVol * tempTotVol); - } - - /** - *

- * calc_lngVV. - *

- * - * @return a double - */ - public double calc_lngVV() { - tempTotVol = getTotalVolume(); - return 2.0 - * (640.0 * Math.pow(tempTotVol, 3.0) - 216.0 * getB() * tempTotVol * tempTotVol - + 24.0 * Math.pow(getB(), 2.0) * tempTotVol - Math.pow(getB(), 3.0)) - * getB() / (tempTotVol * tempTotVol) / Math.pow(8.0 * tempTotVol - getB(), 2.0) - / Math.pow(4.0 * tempTotVol - getB(), 2.0); - } - - /** - *

- * calc_lngVVV. - *

- * - * @return a double - */ - public double calc_lngVVV() { - tempTotVol = getTotalVolume(); - return 4.0 - * (Math.pow(getB(), 5.0) + 17664.0 * Math.pow(tempTotVol, 4.0) * getB() - - 4192.0 * Math.pow(tempTotVol, 3.0) * Math.pow(getB(), 2.0) - + 528.0 * Math.pow(getB(), 3.0) * tempTotVol * tempTotVol - - 36.0 * tempTotVol * Math.pow(getB(), 4.0) - - 30720.0 * Math.pow(tempTotVol, 5.0)) - * getB() / (Math.pow(tempTotVol, 3.0)) / Math.pow(-8.0 * tempTotVol + getB(), 3.0) - / Math.pow(-4.0 * tempTotVol + getB(), 3.0); - } - - /** - *

- * calcXsitedV. - *

- */ - public void calcXsitedV() { - if (getTotalNumberOfAccociationSites() > 0) { - initCPAMatrix(1); - } + return new double[] {-tot1, -tot4}; + } + + /** + *

+ * calc_hCPA. + *

+ * + * @return a double + */ + public double calc_hCPA() { + double htot = 0.0; + double tot = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + htot = 0.0; + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + htot += (1.0 - ((ComponentSrkCPA) componentArray[i]).getXsite()[j]); + } + tot += componentArray[i].getNumberOfMolesInPhase() * htot; + } + return tot; + } + + /** + *

+ * calc_g. + *

+ * + * @return a double + */ + public double calc_g() { + tempTotVol = getMolarVolume(); + double temp = 1.0 - getb() / 4.0 / tempTotVol; + return (2.0 - getb() / 4.0 / tempTotVol) / (2.0 * temp * temp * temp); + } + + /** + *

+ * calc_lngV. + *

+ * + * @return a double + */ + public double calc_lngV() { + tempTotVol = getTotalVolume(); + // gv = -2.0 * getB() * (10.0 * getTotalVolume() - getB()) / getTotalVolume() / + // ((8.0 * getTotalVolume() - getB()) * (4.0 * getTotalVolume() - getB())); + return 1.0 / (2.0 - getB() / (4.0 * tempTotVol)) * getB() / (4.0 * tempTotVol * tempTotVol) + - 3.0 / (1.0 - getB() / (4.0 * tempTotVol)) * getB() / (4.0 * tempTotVol * tempTotVol); + } + + /** + *

+ * calc_lngVV. + *

+ * + * @return a double + */ + public double calc_lngVV() { + tempTotVol = getTotalVolume(); + return 2.0 + * (640.0 * Math.pow(tempTotVol, 3.0) - 216.0 * getB() * tempTotVol * tempTotVol + + 24.0 * Math.pow(getB(), 2.0) * tempTotVol - Math.pow(getB(), 3.0)) + * getB() / (tempTotVol * tempTotVol) / Math.pow(8.0 * tempTotVol - getB(), 2.0) + / Math.pow(4.0 * tempTotVol - getB(), 2.0); + } + + /** + *

+ * calc_lngVVV. + *

+ * + * @return a double + */ + public double calc_lngVVV() { + tempTotVol = getTotalVolume(); + return 4.0 * (Math.pow(getB(), 5.0) + 17664.0 * Math.pow(tempTotVol, 4.0) * getB() + - 4192.0 * Math.pow(tempTotVol, 3.0) * Math.pow(getB(), 2.0) + + 528.0 * Math.pow(getB(), 3.0) * tempTotVol * tempTotVol + - 36.0 * tempTotVol * Math.pow(getB(), 4.0) - 30720.0 * Math.pow(tempTotVol, 5.0)) + * getB() / (Math.pow(tempTotVol, 3.0)) / Math.pow(-8.0 * tempTotVol + getB(), 3.0) + / Math.pow(-4.0 * tempTotVol + getB(), 3.0); + } + + /** + *

+ * calcXsitedV. + *

+ */ + public void calcXsitedV() { + if (getTotalNumberOfAccociationSites() > 0) { + initCPAMatrix(1); + } + } + + /** + *

+ * solveX. + *

+ * + * @return a boolean + */ + public boolean solveX() { + if (totalNumberOfAccociationSites == 0) { + return true; } - /** - *

- * solveX. - *

- * - * @return a boolean - */ - public boolean solveX() { - if (totalNumberOfAccociationSites == 0) { - return true; - } - - boolean solvedX = solveX2(15); - - DMatrixRMaj mVectorMat = mVector.getMatrix(); - DMatrixRMaj ksiMatrixMat = ksiMatrix.getMatrix(); - - // ksiMatrix.print(); - // second order method not working correctly and not used t the moment b ecause of numerical - // stability - int temp = 0, iter = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - mVectorMat.unsafe_set(temp + j, 0, componentArray[i].getNumberOfMolesInPhase()); - } - temp += componentArray[i].getNumberOfAssociationSites(); - } - - DMatrixRMaj mat1 = KlkMatrix.getMatrix(); - double Klk = 0.0; - double totvolume = getTotalVolume(); - double tempVari, tempVarj; - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - tempVari = mVectorMat.unsafe_get(i, 0); - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - tempVarj = mVectorMat.unsafe_get(j, 0); - Klk = tempVari * tempVarj / totvolume * delta[i][j]; - mat1.unsafe_set(i, j, Klk); - mat1.unsafe_set(j, i, Klk); - } - } - boolean solved = true; - // SimpleMatrix corrMatrix = null; - do { - solved = true; - iter++; - temp = 0; - double ksi = 0; - - double temp1, temp2; - for (int i = 0; i < numberOfComponents; i++) { - temp1 = componentArray[i].getNumberOfMolesInPhase(); - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - ksi = ((ComponentSrkCPA) componentArray[i]).getXsite()[j]; - ksiMatrixMat.unsafe_set(temp + j, 0, ksi); - // ksiMatrix.getMatrix().unsafe_set(temp + j, 0, - // ksiMatrix.getMatrix().unsafe_get(temp + j, 0)); - tempVari = 1.0 / ksi - 1.0; - udotMatrix.set(temp + j, 0, tempVari); - udotTimesmMatrix.set(temp + j, 0, temp1 * tempVari); - } - temp += componentArray[i].getNumberOfAssociationSites(); - } - - int krondelt; - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - temp1 = mVectorMat.unsafe_get(i, 0); - temp2 = ksiMatrix.get(i, 0); - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - krondelt = 0; - if (i == j) { - krondelt = 1; - } - tempVari = -temp1 / (temp2 * temp2) * krondelt - mat1.unsafe_get(i, j); - hessianMatrix.set(i, j, tempVari); - hessianMatrix.set(j, i, tempVari); - } - } - - // ksiMatrix = new SimpleMatrix(ksi); - // SimpleMatrix hessianMatrix = new SimpleMatrix(hessian); - try { - hessianInvers = hessianMatrix.invert(); - } catch (Exception e) { - logger.error("error", e); - return false; - } - if (solvedX) { - // System.out.println("solvedX "); - return true; - } - - DMatrixRMaj mat2 = ksiMatrix.getMatrix(); - CommonOps_DDRM.mult(mat1, mat2, corr2Matrix); - CommonOps_DDRM.subtract(udotTimesmMatrix.getDDRM(), corr2Matrix, corr3Matrix); - CommonOps_DDRM.mult(hessianInvers.getDDRM(), corr3Matrix, corr4Matrix); - // SimpleMatrix gMatrix = udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)); - // corrMatrix = - // hessianInvers.mult(udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)));//.scale(-1.0); - temp = 0; - // System.out.println("print SimpleMatrix ..."); - // corrMatrix.print(10, 10); - // SimpleMatrix simp = new SimpleMatrix(corr4Matrix); - // System.out.println("print CommonOps ..."); - // simp.print(10,10); - double newX; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - newX = ksiMatrix.get(temp + j, 0) - corr4Matrix.unsafe_get((temp + j), 0); - if (newX < 0) { - newX = 1e-10; - solved = false; - } - ((ComponentCPAInterface) componentArray[i]).setXsite(j, newX); - } - temp += componentArray[i].getNumberOfAssociationSites(); - } - // System.out.println("corrmatrix error " ); - // System.out.println("error " + NormOps_DDRM.normF(corr4Matrix)); - } while ((NormOps_DDRM.normF(corr4Matrix) > 1e-12 || !solved) && iter < 100); + boolean solvedX = solveX2(15); + + DMatrixRMaj mVectorMat = mVector.getMatrix(); + DMatrixRMaj ksiMatrixMat = ksiMatrix.getMatrix(); + + // ksiMatrix.print(); + // second order method not working correctly and not used t the moment b ecause of numerical + // stability + int temp = 0; + int iter = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + mVectorMat.unsafe_set(temp + j, 0, componentArray[i].getNumberOfMolesInPhase()); + } + temp += componentArray[i].getNumberOfAssociationSites(); + } - // System.out.println("iter " + iter + " error " + - // NormOps_DDRM.normF(corr4Matrix)); // corrMatrix.print(10, 10); - // ksiMatrix.print(10, 10); + DMatrixRMaj mat1 = KlkMatrix.getMatrix(); + double Klk = 0.0; + double totvolume = getTotalVolume(); + double tempVari; + double tempVarj; + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + tempVari = mVectorMat.unsafe_get(i, 0); + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + tempVarj = mVectorMat.unsafe_get(j, 0); + Klk = tempVari * tempVarj / totvolume * delta[i][j]; + mat1.unsafe_set(i, j, Klk); + mat1.unsafe_set(j, i, Klk); + } + } + boolean solved = true; + // SimpleMatrix corrMatrix = null; + do { + solved = true; + iter++; + temp = 0; + double ksi = 0; + + double temp1; + double temp2; + for (int i = 0; i < numberOfComponents; i++) { + temp1 = componentArray[i].getNumberOfMolesInPhase(); + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + ksi = ((ComponentSrkCPA) componentArray[i]).getXsite()[j]; + ksiMatrixMat.unsafe_set(temp + j, 0, ksi); + // ksiMatrix.getMatrix().unsafe_set(temp + j, 0, + // ksiMatrix.getMatrix().unsafe_get(temp + j, 0)); + tempVari = 1.0 / ksi - 1.0; + udotMatrix.set(temp + j, 0, tempVari); + udotTimesmMatrix.set(temp + j, 0, temp1 * tempVari); + } + temp += componentArray[i].getNumberOfAssociationSites(); + } + + int krondelt; + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + temp1 = mVectorMat.unsafe_get(i, 0); + temp2 = ksiMatrix.get(i, 0); + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + krondelt = 0; + if (i == j) { + krondelt = 1; + } + tempVari = -temp1 / (temp2 * temp2) * krondelt - mat1.unsafe_get(i, j); + hessianMatrix.set(i, j, tempVari); + hessianMatrix.set(j, i, tempVari); + } + } + + // ksiMatrix = new SimpleMatrix(ksi); + // SimpleMatrix hessianMatrix = new SimpleMatrix(hessian); + try { + hessianInvers = hessianMatrix.invert(); + } catch (Exception e) { + logger.error("error", e); + return false; + } + if (solvedX) { + // System.out.println("solvedX "); return true; + } + + DMatrixRMaj mat2 = ksiMatrix.getMatrix(); + CommonOps_DDRM.mult(mat1, mat2, corr2Matrix); + CommonOps_DDRM.subtract(udotTimesmMatrix.getDDRM(), corr2Matrix, corr3Matrix); + CommonOps_DDRM.mult(hessianInvers.getDDRM(), corr3Matrix, corr4Matrix); + // SimpleMatrix gMatrix = udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)); + // corrMatrix = + // hessianInvers.mult(udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix))); + // //.scale(-1.0); + temp = 0; + // System.out.println("print SimpleMatrix ..."); + // corrMatrix.print(10, 10); + // SimpleMatrix simp = new SimpleMatrix(corr4Matrix); + // System.out.println("print CommonOps ..."); + // simp.print(10,10); + double newX; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + newX = ksiMatrix.get(temp + j, 0) - corr4Matrix.unsafe_get((temp + j), 0); + if (newX < 0) { + newX = 1e-10; + solved = false; + } + ((ComponentCPAInterface) componentArray[i]).setXsite(j, newX); + } + temp += componentArray[i].getNumberOfAssociationSites(); + } + // System.out.println("corrmatrix error " ); + // System.out.println("error " + NormOps_DDRM.normF(corr4Matrix)); + } while ((NormOps_DDRM.normF(corr4Matrix) > 1e-12 || !solved) && iter < 100); + + // System.out.println("iter " + iter + " error " + + // NormOps_DDRM.normF(corr4Matrix)); // corrMatrix.print(10, 10); + // ksiMatrix.print(10, 10); + return true; + } + + /** + *

+ * solveX2. + *

+ * + * @param maxIter a int + * @return a boolean + */ + public boolean solveX2(int maxIter) { + double err = .0; + double totalVolume = getTotalVolume(); + int iter = 0; + // if (delta == null) { + // initCPAMatrix(1); + double old = 0.0; + double neeval = 0.0; + // } + do { + iter++; + err = 0.0; + for (int i = 0; i < totalNumberOfAccociationSites; i++) { + old = ((ComponentSrkCPA) componentArray[moleculeNumber[i]]).getXsite()[assSiteNumber[i]]; + neeval = 0.0; + for (int j = 0; j < totalNumberOfAccociationSites; j++) { + neeval += componentArray[moleculeNumber[j]].getNumberOfMolesInPhase() * delta[i][j] + * ((ComponentSrkCPA) componentArray[moleculeNumber[j]]).getXsite()[assSiteNumber[j]]; + } + neeval = 1.0 / (1.0 + 1.0 / totalVolume * neeval); + ((ComponentSrkCPA) componentArray[moleculeNumber[i]]).setXsite(assSiteNumber[i], neeval); + err += Math.abs((old - neeval) / neeval); + } + } while (Math.abs(err) > 1e-12 && iter < maxIter); + // System.out.println("iter " + iter); + if (Math.abs(err) < 1e-12) { + return true; + } else { + // System.out.println("did not solve for Xi in iterations: " + iter); + // System.out.println("error: " + err); + return false; } - - /** - *

- * solveX2. - *

- * - * @param maxIter a int - * @return a boolean - */ - public boolean solveX2(int maxIter) { - double err = .0, totalVolume = getTotalVolume(); - int iter = 0; - // if (delta == null) { - // initCPAMatrix(1); - double old = 0.0, neeval = 0.0; - // } - do { - iter++; - err = 0.0; - for (int i = 0; i < totalNumberOfAccociationSites; i++) { - old = ((ComponentSrkCPA) componentArray[moleculeNumber[i]]) - .getXsite()[assSiteNumber[i]]; - neeval = 0.0; - for (int j = 0; j < totalNumberOfAccociationSites; j++) { - neeval += componentArray[moleculeNumber[j]].getNumberOfMolesInPhase() - * delta[i][j] * ((ComponentSrkCPA) componentArray[moleculeNumber[j]]) - .getXsite()[assSiteNumber[j]]; - } - neeval = 1.0 / (1.0 + 1.0 / totalVolume * neeval); - ((ComponentSrkCPA) componentArray[moleculeNumber[i]]).setXsite(assSiteNumber[i], - neeval); - err += Math.abs((old - neeval) / neeval); - } - } while (Math.abs(err) > 1e-12 && iter < maxIter); - // System.out.println("iter " + iter); - if (Math.abs(err) < 1e-12) { - return true; + } + + /** {@inheritDoc} */ + @Override + public double getHcpatot() { + return hcpatot; + } + + /** + * Setter for property hcpatot. + * + * @param hcpatot New value of property hcpatot. + */ + public void setHcpatot(double hcpatot) { + this.hcpatot = hcpatot; + } + + /** {@inheritDoc} */ + @Override + public double getGcpa() { + return gcpa; + } + + /** + *

+ * calcRootVolFinder. + *

+ * + * @param phase a int + * @return a double + */ + public double calcRootVolFinder(int phase) { + double solvedBonVHigh = 0.0; + double solvedBonVlow = 1.0; + double oldh = 1; + // double[][] matrix = new double[2][2000]; + double BonV = 1.0 - 1e-10; + try { + // molarVolume(pressure, temperature, A, B, phaseType); + } catch (Exception e) { + logger.error("error", e); + } + double BonVold = BonV; + double Btemp = 0; + double h = 1; + // double Dtemp = 0, dh = 0, gvvv = 0, fvvv = 0, dhh = 0; + // double d1 = 0, d2 = 0; + Btemp = getB(); + // Dtemp = getA(); + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + for (int i = 0; i < 2000; i++) { + BonVold = BonV; + BonV = 1.0 - (i + 1e-6) * 1.0 / 2000.0; + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); + gcpa = calc_g(); + // lngcpa = + // Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); + + do { + } while (!solveX()); + + h = BonV - Btemp / numberOfMolesInPhase * dFdV() + - pressure * Btemp / (numberOfMolesInPhase * R * temperature); + + if (Math.signum(h) * Math.signum(oldh) < 0 && i > 2) { + if (solvedBonVlow < 1e-3) { + solvedBonVlow = (BonV + BonVold) / 2.0; + if (phase == 1) { + break; + } } else { - // System.out.println("did not solve for Xi in iterations: " + iter); - // System.out.println("error: " + err); - return false; - } + solvedBonVHigh = (BonV + BonVold) / 2.0; + if (phase == 0) { + break; + } + } + } + solvedBonVHigh = (BonV + BonVold) / 2.0; + oldh = h; + // matrix[0][i] = BonV; + // matrix[1][i] = h; } - - /** {@inheritDoc} */ - @Override - public double getHcpatot() { - return hcpatot; + if (solvedBonVlow < 1e-3) { + solvedBonVlow = solvedBonVHigh; } - - /** - * Setter for property hcpatot. - * - * @param hcpatot New value of property hcpatot. - */ - public void setHcpatot(double hcpatot) { - this.hcpatot = hcpatot; + // dataPresentation.fileHandeling.createTextFile.TextFile file = new + // dataPresentation.fileHandeling.createTextFile.TextFile(); + // file.setValues(matrix); + // file.setOutputFileName("D:/temp/temp2.txt"); + // file.createFile(); + if (phase == 1) { + return solvedBonVlow; + } else { + return solvedBonVHigh; } - - /** {@inheritDoc} */ - @Override - public double getGcpa() { - return gcpa; + } + + /** + *

+ * molarVolumeChangePhase. + *

+ * + * @param pressure a double + * @param temperature a double + * @param A a double + * @param B a double + * @param phasetype a int + * @return a double + * @throws neqsim.util.exception.IsNaNException if any. + * @throws neqsim.util.exception.TooManyIterationsException if any. + */ + public double molarVolumeChangePhase(double pressure, double temperature, double A, double B, + int phasetype) throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + double BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + // double BonV = calcRootVolFinder(phasetype); + // double BonVInit = BonV; + if (BonV < 0) { + BonV = 1.0e-8; } - /** - *

- * calcRootVolFinder. - *

- * - * @param phase a int - * @return a double - */ - public double calcRootVolFinder(int phase) { - double solvedBonVHigh = 0.0; - double solvedBonVlow = 1.0; - double oldh = 1; - // double[][] matrix = new double[2][2000]; - double BonV = 1.0 - 1e-10; - try { - // molarVolume(pressure, temperature, A, B, phaseType); - } catch (Exception e) { - logger.error("error", e); - } - double BonVold = BonV; - double Btemp = 0, h = 1; - // double Dtemp = 0, dh = 0, gvvv = 0, fvvv = 0, dhh = 0; - // double d1 = 0, d2 = 0; - Btemp = getB(); - // Dtemp = getA(); - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - for (int i = 0; i < 2000; i++) { - BonVold = BonV; - BonV = 1.0 - (i + 1e-6) * 1.0 / 2000.0; - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - gcpa = calc_g(); - // lngcpa = - // Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - - do { - } while (!solveX()); - - h = BonV - Btemp / numberOfMolesInPhase * dFdV() - - pressure * Btemp / (numberOfMolesInPhase * R * temperature); - - if (Math.signum(h) * Math.signum(oldh) < 0 && i > 2) { - if (solvedBonVlow < 1e-3) { - solvedBonVlow = (BonV + BonVold) / 2.0; - if (phase == 1) { - break; - } - } else { - solvedBonVHigh = (BonV + BonVold) / 2.0; - if (phase == 0) { - break; - } - } - } - solvedBonVHigh = (BonV + BonVold) / 2.0; - oldh = h; - // matrix[0][i] = BonV; - // matrix[1][i] = h; - } - if (solvedBonVlow < 1e-3) { - solvedBonVlow = solvedBonVHigh; - } - // dataPresentation.fileHandeling.createTextFile.TextFile file = new - // dataPresentation.fileHandeling.createTextFile.TextFile(); - // file.setValues(matrix); - // file.setOutputFileName("D:/temp/temp2.txt"); - // file.createFile(); - if (phase == 1) { - return solvedBonVlow; - } else { - return solvedBonVHigh; - } + if (BonV >= 1.0) { + BonV = 0.9999; + } + double BonVold = BonV; + double Btemp = 0; + double h = 0; + double dh = 0; + double dhh = 0; + // double gvvv = 0, fvvv = 0; + double d1 = 0; + double d2 = 0; + Btemp = getB(); + if (Btemp < 0) { + logger.info("b negative in volume calc"); } + calcDelta(); - /** - *

- * molarVolumeChangePhase. - *

- * - * @param pressure a double - * @param temperature a double - * @param A a double - * @param B a double - * @param phasetype a int - * @return a double - * @throws neqsim.util.exception.IsNaNException if any. - * @throws neqsim.util.exception.TooManyIterationsException if any. - */ - public double molarVolumeChangePhase(double pressure, double temperature, double A, double B, - int phasetype) throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - // double BonV = calcRootVolFinder(phasetype); - // double BonVInit = BonV; - if (BonV < 0) { - BonV = 1.0e-8; - } + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + int iterations = 0; - if (BonV >= 1.0) { - BonV = 0.9999; - } - double BonVold = BonV; - double Btemp = 0, h = 0, dh = 0, dhh = 0; - // double gvvv = 0, fvvv = 0; - double d1 = 0, d2 = 0; - Btemp = getB(); - if (Btemp < 0) { - logger.info("b negative in volume calc"); + do { + iterations++; + gcpa = calc_g(); + if (gcpa < 0) { + setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); + gcpa = calc_g(); + } + + // lngcpa = + // Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); + + solveX(); + + initCPAMatrix(1); + double BonV2 = BonV * BonV; + BonVold = BonV; + h = BonV - Btemp / numberOfMolesInPhase * dFdV() + - pressure * Btemp / (numberOfMolesInPhase * R * temperature); + dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); + dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) + - (Btemp * Btemp) / (BonV2 * BonV2) * (Btemp / numberOfMolesInPhase * dFdVdVdV()); + + d1 = -h / dh; + d2 = -dh / dhh; + // System.out.println("d1" + d1 + " d2 " + d2 + " d1 / d2 " + (d1 / d2)); + if (Math.abs(d1 / d2) <= 1.0) { + BonV += d1 * (1.0 + 0.5 * d1 / d2); + } else if (d1 / d2 < -1) { + BonV += 0.5 * d1; + } else if (d1 > d2) { + BonV += d2; + double hnew = h + d2 * dh; + if (Math.abs(hnew) > Math.abs(h)) { + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + } + } else { + BonV += 0.5 * d1; + } + if (Math.abs((BonV - BonVold) / BonVold) > 0.1) { + BonV = BonVold + 0.1 * (BonV - BonVold); + } + + if (BonV > 1.1) { + if (iterations < 3) { + BonV = (BonVold + BonV) / 2.0; + } else { + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); } - calcDelta(); - - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - int iterations = 0; - - do { - iterations++; - gcpa = calc_g(); - if (gcpa < 0) { - setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); - gcpa = calc_g(); - } - - // lngcpa = - // Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - - solveX(); - - initCPAMatrix(1); - double BonV2 = BonV * BonV; - BonVold = BonV; - h = BonV - Btemp / numberOfMolesInPhase * dFdV() - - pressure * Btemp / (numberOfMolesInPhase * R * temperature); - dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); - dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) - - (Btemp * Btemp) / (BonV2 * BonV2) - * (Btemp / numberOfMolesInPhase * dFdVdVdV()); - - d1 = -h / dh; - d2 = -dh / dhh; - // System.out.println("d1" + d1 + " d2 " + d2 + " d1 / d2 " + (d1 / d2)); - if (Math.abs(d1 / d2) <= 1.0) { - BonV += d1 * (1.0 + 0.5 * d1 / d2); - } else if (d1 / d2 < -1) { - BonV += 0.5 * d1; - } else if (d1 > d2) { - BonV += d2; - double hnew = h + d2 * dh; - if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } else { - BonV += 0.5 * d1; - } - if (Math.abs((BonV - BonVold) / BonVold) > 0.1) { - BonV = BonVold + 0.1 * (BonV - BonVold); - } - - if (BonV > 1.1) { - if (iterations < 3) { - BonV = (BonVold + BonV) / 2.0; - } else { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } - - if (BonV < 0) { - if (iterations < 3) { - BonV = Math.abs(BonVold + BonV) / 2.0; - } else { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } + } - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - - // System.out.println("Z " + Z + "h " + h + " BONV " + (Math.abs((BonV - - // BonVold) / BonV))); - } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10) && iterations < 100); - - /* - * if (Math.abs(h) > 1e-8) { if (phasetype == 0) { molarVolume(pressure, temperature, A, B, - * 1); } else { molarVolume(pressure, temperature, A, B, 0); } return getMolarVolume(); } - */ - // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); - // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); - // System.out.println("volume " + getTotalVolume() + " molar volume " + - // getMolarVolume()); - // if(iterations>=100) throw new util.exception.TooManyIterationsException(); - // System.out.println("error in volume " + - // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " - // firstterm " + (R*temperature/molarVolume) + " second " + - // R*temperature*dFdV()); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + " B - // " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); - if (Double.isNaN(getMolarVolume())) { - throw new neqsim.util.exception.IsNaNException(this, "molarVolumeChangePhase", - "Molar volume"); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " - // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" - // + fVV()); + if (BonV < 0) { + if (iterations < 3) { + BonV = Math.abs(BonVold + BonV) / 2.0; + } else { + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); } + } - return getMolarVolume(); - } + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); - /** {@inheritDoc} */ - @Override - public double getGcpav() { - return gcpav; - } + // System.out.println("Z " + Z + "h " + h + " BONV " + (Math.abs((BonV - + // BonVold) / BonV))); + } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10) && iterations < 100); - /** - *

- * Setter for the field gcpav. - *

- * - * @param gcpav a double + /* + * if (Math.abs(h) > 1e-8) { if (phasetype == 0) { molarVolume(pressure, temperature, A, B, 1); + * } else { molarVolume(pressure, temperature, A, B, 0); } return getMolarVolume(); } */ - public void setGcpav(double gcpav) { - this.gcpav = gcpav; + // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); + // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); + // System.out.println("volume " + getTotalVolume() + " molar volume " + + // getMolarVolume()); + // if(iterations>=100) throw new util.exception.TooManyIterationsException(); + // System.out.println("error in volume " + + // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV())); // + " + // firstterm " + (R*temperature/molarVolume) + " second " + + // R*temperature*dFdV()); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + " B + // " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); + if (Double.isNaN(getMolarVolume())) { + throw new neqsim.util.exception.IsNaNException(this, "molarVolumeChangePhase", + "Molar volume"); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " + // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + // + fVV()); } - /** {@inheritDoc} */ - @Override - public CPAMixingInterface getCpamix() { - return cpamix; + return getMolarVolume(); + } + + /** {@inheritDoc} */ + @Override + public double getGcpav() { + return gcpav; + } + + /** + *

+ * Setter for the field gcpav. + *

+ * + * @param gcpav a double + */ + public void setGcpav(double gcpav) { + this.gcpav = gcpav; + } + + /** {@inheritDoc} */ + @Override + public CPAMixingInterface getCpamix() { + return cpamix; + } + + /** {@inheritDoc} */ + @Override + public double calcPressure() { + gcpa = calc_g(); + // lngcpa = + // Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); + solveX(); + hcpatot = calc_hCPA(); + + initCPAMatrix(1); + return super.calcPressure(); + } + + /** {@inheritDoc} */ + @Override + public int getCrossAssosiationScheme(int comp1, int comp2, int site1, int site2) { + if (comp1 == comp2) { + return selfAccociationScheme[comp1][site1][site2]; + } else { + return crossAccociationScheme[comp1][comp2][site1][site2]; } - - /** {@inheritDoc} */ - @Override - public double calcPressure() { - gcpa = calc_g(); - // lngcpa = - // Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - solveX(); - hcpatot = calc_hCPA(); - - initCPAMatrix(1); - return super.calcPressure(); + } + + /** + *

+ * croeneckerProduct. + *

+ * + * @param a an array of {@link double} objects + * @param b an array of {@link double} objects + * @return an array of {@link double} objects + */ + public double[][] croeneckerProduct(double[][] a, double[][] b) { + int aLength = a.length; + int aCols = a[0].length; + int bLength = b.length; + int bCols = b[0].length; + double[][] result = new double[aLength * bLength][(aCols) * (bCols)]; + for (int z = 0; z < aLength; z++) { + for (int i = 0; i < aCols; i++) { + for (int j = 0; j < bLength; j++) { + for (int k = 0; k < bCols; k++) { + result[j + (z * bLength)][k + (i * bCols)] = a[z][i] * b[j][k]; + } + } + } } - - /** {@inheritDoc} */ - @Override - public int getCrossAssosiationScheme(int comp1, int comp2, int site1, int site2) { - if (comp1 == comp2) { - return selfAccociationScheme[comp1][site1][site2]; + return result; + } + + /** {@inheritDoc} */ + @Override + public int getTotalNumberOfAccociationSites() { + return totalNumberOfAccociationSites; + } + + /** {@inheritDoc} */ + @Override + public void setTotalNumberOfAccociationSites(int totalNumberOfAccociationSites) { + this.totalNumberOfAccociationSites = totalNumberOfAccociationSites; + } + + /** + *

+ * initOld2. + *

+ * + * @param totalNumberOfMoles a double + * @param numberOfComponents a int + * @param type a int + * @param phase a int + * @param beta a double + */ + public void initOld2(double totalNumberOfMoles, int numberOfComponents, int type, int phase, + double beta) { // type + // = 0 + // start + // init + // type + // =1 gi + // nye + // betingelser + if (type == 0) { + setTotalNumberOfAccociationSites(0); + selfAccociationScheme = new int[numberOfComponents][0][0]; + crossAccociationScheme = new int[numberOfComponents][numberOfComponents][0][0]; + for (int i = 0; i < numberOfComponents; i++) { + if (componentArray[i].getNumberOfmoles() < 1e-50) { + componentArray[i].setNumberOfAssociationSites(0); } else { - return crossAccociationScheme[comp1][comp2][site1][site2]; - } + componentArray[i] + .setNumberOfAssociationSites(componentArray[i].getOrginalNumberOfAssociationSites()); + setTotalNumberOfAccociationSites( + getTotalNumberOfAccociationSites() + componentArray[i].getNumberOfAssociationSites()); + selfAccociationScheme[i] = cpaSelect.setAssociationScheme(i, this); + for (int j = 0; j < numberOfComponents; j++) { + crossAccociationScheme[i][j] = cpaSelect.setCrossAssociationScheme(i, j, this); + } + } + } + + // had to remove if below - dont understand why.. Even + // if (getTotalNumberOfAccociationSites() != oldTotalNumberOfAccociationSites) { + mVector = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + KlkMatrix = + new SimpleMatrix(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + KlkVMatrix = + new SimpleMatrix(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + KlkVVMatrix = + new SimpleMatrix(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + KlkVVVMatrix = + new SimpleMatrix(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + hessianMatrix = + new SimpleMatrix(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + KlkTMatrix = + new SimpleMatrix(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + KlkTTMatrix = + new SimpleMatrix(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + KlkTVMatrix = + new SimpleMatrix(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + corr2Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + corr3Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + corr4Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + Klkni = + new double[numberOfComponents][getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + ksiMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + uMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + udotMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + moleculeNumber = new int[getTotalNumberOfAccociationSites()]; + assSiteNumber = new int[getTotalNumberOfAccociationSites()]; + gvector = new double[getTotalNumberOfAccociationSites()][1]; + udotTimesmMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + delta = new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + deltaNog = new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + deltadT = new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + deltadTdT = + new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + QMatksiksiksi = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + // } + udotTimesmiMatrix = + new SimpleMatrix(getNumberOfComponents(), getTotalNumberOfAccociationSites()); + + oldTotalNumberOfAccociationSites = getTotalNumberOfAccociationSites(); + + int temp = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + moleculeNumber[temp + j] = i; + assSiteNumber[temp + j] = j; + } + temp += componentArray[i].getNumberOfAssociationSites(); + } } - - /** - *

- * croeneckerProduct. - *

- * - * @param a an array of {@link double} objects - * @param b an array of {@link double} objects - * @return an array of {@link double} objects - */ - public double[][] croeneckerProduct(double[][] a, double[][] b) { - int aLength = a.length; - int aCols = a[0].length; - int bLength = b.length; - int bCols = b[0].length; - double[][] result = new double[aLength * bLength][(aCols) * (bCols)]; - for (int z = 0; z < aLength; z++) { - for (int i = 0; i < aCols; i++) { - for (int j = 0; j < bLength; j++) { - for (int k = 0; k < bCols; k++) { - result[j + (z * bLength)][k + (i * bCols)] = a[z][i] * b[j][k]; - } - } - } - } - return result; + if (cpamix == null) { + cpamix = cpaSelect.getMixingRule(1, this); } - /** {@inheritDoc} */ - @Override - public int getTotalNumberOfAccociationSites() { - return totalNumberOfAccociationSites; + super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + if (type > 0 && isConstantPhaseVolume()) { + calcDelta(); + solveX(); + super.init(totalNumberOfMoles, numberOfComponents, 1, phase, beta); + gcpa = calc_g(); + // lngcpa = Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); } - /** {@inheritDoc} */ - @Override - public void setTotalNumberOfAccociationSites(int totalNumberOfAccociationSites) { - this.totalNumberOfAccociationSites = totalNumberOfAccociationSites; + if (type > 0) { + hcpatot = calc_hCPA(); } - /** - *

- * initOld2. - *

- * - * @param totalNumberOfMoles a double - * @param numberOfComponents a int - * @param type a int - * @param phase a int - * @param beta a double - */ - public void initOld2(double totalNumberOfMoles, int numberOfComponents, int type, int phase, - double beta) { // type - // = 0 - // start - // init - // type - // =1 gi - // nye - // betingelser - if (type == 0) { - setTotalNumberOfAccociationSites(0); - selfAccociationScheme = new int[numberOfComponents][0][0]; - crossAccociationScheme = new int[numberOfComponents][numberOfComponents][0][0]; - for (int i = 0; i < numberOfComponents; i++) { - if (componentArray[i].getNumberOfmoles() < 1e-50) { - componentArray[i].setNumberOfAssociationSites(0); - } else { - componentArray[i].setNumberOfAssociationSites( - componentArray[i].getOrginalNumberOfAssociationSites()); - setTotalNumberOfAccociationSites(getTotalNumberOfAccociationSites() - + componentArray[i].getNumberOfAssociationSites()); - selfAccociationScheme[i] = cpaSelect.setAssociationScheme(i, this); - for (int j = 0; j < numberOfComponents; j++) { - crossAccociationScheme[i][j] = - cpaSelect.setCrossAssociationScheme(i, j, this); - } - } - } - - // had to remove if below - dont understand why.. Even - // if (getTotalNumberOfAccociationSites() != oldTotalNumberOfAccociationSites) { - mVector = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - KlkMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkVVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkVVVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - hessianMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkTMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkTTMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkTVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - corr2Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - corr3Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - corr4Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - Klkni = new double[numberOfComponents][getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - ksiMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - uMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - udotMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - moleculeNumber = new int[getTotalNumberOfAccociationSites()]; - assSiteNumber = new int[getTotalNumberOfAccociationSites()]; - gvector = new double[getTotalNumberOfAccociationSites()][1]; - udotTimesmMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - delta = new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - deltaNog = - new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - deltadT = - new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - deltadTdT = - new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - QMatksiksiksi = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - // } - udotTimesmiMatrix = - new SimpleMatrix(getNumberOfComponents(), getTotalNumberOfAccociationSites()); - - oldTotalNumberOfAccociationSites = getTotalNumberOfAccociationSites(); - - int temp = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - moleculeNumber[temp + j] = i; - assSiteNumber[temp + j] = j; - } - temp += componentArray[i].getNumberOfAssociationSites(); - } - } - if (cpamix == null) { - cpamix = cpaSelect.getMixingRule(1, this); - } - - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - if (type > 0 && isConstantPhaseVolume()) { - calcDelta(); - solveX(); - super.init(totalNumberOfMoles, numberOfComponents, 1, phase, beta); - gcpa = calc_g(); - // lngcpa = Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - } - - if (type > 0) { - hcpatot = calc_hCPA(); - } - - if (type > 1) { - initCPAMatrix(type); - // hcpatotdT = calc_hCPAdT(); - // super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - } + if (type > 1) { + initCPAMatrix(type); + // hcpatotdT = calc_hCPAdT(); + // super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); } - - /** {@inheritDoc} */ - @Override - public double molarVolume2(double pressure, double temperature, double A, double B, int phase) - throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - Z = phase == 0 ? 1.0 : 1.0e-5; + } + + /** {@inheritDoc} */ + @Override + public double molarVolume2(double pressure, double temperature, double A, double B, int phase) + throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + Z = phase == 0 ? 1.0 : 1.0e-5; + setMolarVolume(Z * R * temperature / pressure); + // super.molarVolume(pressure,temperature, A, B, phase); + int iterations = 0; + double err = 0.0; + double dErrdV = 0.0; + double deltaV = 0; + + do { + A = calcA(this, temperature, pressure, numberOfComponents); + B = calcB(this, temperature, pressure, numberOfComponents); + + double dFdV = dFdV(); + double dFdVdV = dFdVdV(); + // double dFdVdVdV = dFdVdVdV(); + // double factor1 = 1.0e0, factor2 = 1.0e0; + err = -R * temperature * dFdV + R * temperature / getMolarVolume() - pressure; + + // System.out.println("pressure " + -R * temperature * dFdV + " " + R * + // temperature / getMolarVolume()); + // -pressure; + dErrdV = -R * temperature * dFdVdV + - R * temperature * numberOfMolesInPhase / Math.pow(getVolume(), 2.0); + + // System.out.println("errdV " + dErrdV); + // System.out.println("err " + err); + deltaV = -err / dErrdV; + + setMolarVolume(getMolarVolume() + deltaV / numberOfMolesInPhase); + + Z = pressure * getMolarVolume() / (R * temperature); + if (Z < 0) { + Z = 1e-6; setMolarVolume(Z * R * temperature / pressure); - // super.molarVolume(pressure,temperature, A, B, phase); - int iterations = 0; - double err = 0.0, dErrdV = 0.0; - double deltaV = 0; - - do { - A = calcA(this, temperature, pressure, numberOfComponents); - B = calcB(this, temperature, pressure, numberOfComponents); - - double dFdV = dFdV(), dFdVdV = dFdVdV(); - // double dFdVdVdV = dFdVdVdV(); - // double factor1 = 1.0e0, factor2 = 1.0e0; - err = -R * temperature * dFdV + R * temperature / getMolarVolume() - pressure; - - // System.out.println("pressure " + -R * temperature * dFdV + " " + R * - // temperature / getMolarVolume()); - // -pressure; - dErrdV = -R * temperature * dFdVdV - - R * temperature * numberOfMolesInPhase / Math.pow(getVolume(), 2.0); - - // System.out.println("errdV " + dErrdV); - // System.out.println("err " + err); - deltaV = -err / dErrdV; - - setMolarVolume(getMolarVolume() + deltaV / numberOfMolesInPhase); - - Z = pressure * getMolarVolume() / (R * temperature); - if (Z < 0) { - Z = 1e-6; - setMolarVolume(Z * R * temperature / pressure); - } - - // System.out.println("Z " + Z); - } while (Math.abs(err) > 1.0e-8 || iterations < 100); - // System.out.println("Z " + Z); - return getMolarVolume(); + } + + // System.out.println("Z " + Z); + } while (Math.abs(err) > 1.0e-8 || iterations < 100); + // System.out.println("Z " + Z); + return getMolarVolume(); + } + + /** + *

+ * initCPAMatrixOld. + *

+ * + * @param type a int + */ + public void initCPAMatrixOld(int type) { + if (getTotalNumberOfAccociationSites() == 0) { + FCPA = 0.0; + dFCPAdTdV = 0.0; + dFCPAdTdT = 0.0; + dFCPAdT = 0; + dFCPAdV = 0; + dFCPAdVdV = 0.0; + dFCPAdVdVdV = 0.0; + + return; } - /** - *

- * initCPAMatrixOld. - *

- * - * @param type a int - */ - public void initCPAMatrixOld(int type) { - if (getTotalNumberOfAccociationSites() == 0) { - FCPA = 0.0; - dFCPAdTdV = 0.0; - dFCPAdTdT = 0.0; - dFCPAdT = 0; - dFCPAdV = 0; - dFCPAdVdV = 0.0; - dFCPAdVdVdV = 0.0; - - return; - } - - int temp = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - uMatrix.set(temp + j, 0, - Math.log(ksiMatrix.get(temp + j, 0)) - ksiMatrix.get(temp + j, 0) + 1.0); - gvector[temp + j][0] = mVector.get(temp + j, 0) * udotMatrix.get(temp + j, 0); - } - temp += componentArray[i].getNumberOfAssociationSites(); - } - for (int i = 0; i < getNumberOfComponents(); i++) { - for (int j = 0; j < getTotalNumberOfAccociationSites(); j++) { - if (moleculeNumber[j] == i) { - udotTimesmiMatrix.set(i, j, udotMatrix.get(j, 0)); - } else { - udotTimesmiMatrix.set(i, j, 0.0); - } - } + int temp = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + uMatrix.set(temp + j, 0, + Math.log(ksiMatrix.get(temp + j, 0)) - ksiMatrix.get(temp + j, 0) + 1.0); + gvector[temp + j][0] = mVector.get(temp + j, 0) * udotMatrix.get(temp + j, 0); + } + temp += componentArray[i].getNumberOfAssociationSites(); + } + for (int i = 0; i < getNumberOfComponents(); i++) { + for (int j = 0; j < getTotalNumberOfAccociationSites(); j++) { + if (moleculeNumber[j] == i) { + udotTimesmiMatrix.set(i, j, udotMatrix.get(j, 0)); + } else { + udotTimesmiMatrix.set(i, j, 0.0); } + } + } - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - delta[i][j] = deltaNog[i][j] * getGcpa(); - delta[j][i] = delta[i][j]; - if (type > 1) { - deltadT[i][j] = cpamix.calcDeltadT(assSiteNumber[i], assSiteNumber[j], - moleculeNumber[i], moleculeNumber[j], this, getTemperature(), - getPressure(), numberOfComponents); - deltadT[j][i] = deltadT[i][j]; - - deltadTdT[i][j] = cpamix.calcDeltadTdT(assSiteNumber[i], assSiteNumber[j], - moleculeNumber[i], moleculeNumber[j], this, getTemperature(), - getPressure(), numberOfComponents); - deltadTdT[j][i] = deltadTdT[i][j]; - } - } - } + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + delta[i][j] = deltaNog[i][j] * getGcpa(); + delta[j][i] = delta[i][j]; + if (type > 1) { + deltadT[i][j] = cpamix.calcDeltadT(assSiteNumber[i], assSiteNumber[j], moleculeNumber[i], + moleculeNumber[j], this, getTemperature(), getPressure(), numberOfComponents); + deltadT[j][i] = deltadT[i][j]; - double totalVolume = getTotalVolume(); - double totalVolume2 = totalVolume * totalVolume, totalVolume3 = totalVolume2 * totalVolume; - double gdv1 = getGcpav() - 1.0 / totalVolume; - double gdv2 = gdv1 * gdv1; - double gdv3 = gdv2 * gdv1; - // double Klk = 0.0; - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - KlkVMatrix.set(i, j, KlkMatrix.get(i, j) * gdv1); - KlkVMatrix.set(j, i, KlkVMatrix.get(i, j)); - - KlkVVMatrix.set(i, j, KlkMatrix.get(i, j) * gdv2 - + KlkMatrix.get(i, j) * (gcpavv + 1.0 / totalVolume / totalVolume)); - KlkVVMatrix.set(j, i, KlkVVMatrix.get(i, j)); - - KlkVVVMatrix.set(i, j, - KlkMatrix.get(i, j) * gdv3 - + 3.0 * KlkMatrix.get(i, j) * (getGcpav() - 1.0 / totalVolume) - * (gcpavv + 1.0 / (totalVolume2)) - + KlkMatrix.get(i, j) * (gcpavvv - 2.0 / (totalVolume3))); - KlkVVVMatrix.set(j, i, KlkVVVMatrix.get(i, j)); - - if (type > 1) { - double tempVar = deltadT[i][j] / delta[i][j]; - double tempVardT = deltadTdT[i][j] / delta[i][j] - - (deltadT[i][j] * deltadT[i][j]) / (delta[i][j] * delta[i][j]); - - if (!Double.isNaN(tempVar)) { - // KlkdT[i][j] = KlkMatrix.getMatrix().unsafe_get(i, j) * tempVar; - // KlkdT[j][i] = KlkdT[i][j]; - - KlkTMatrix.set(i, j, KlkMatrix.get(i, j) * tempVar); - KlkTMatrix.set(j, i, KlkTMatrix.get(i, j)); - - KlkTVMatrix.set(i, j, - KlkMatrix.get(i, j) * tempVar * (gcpav - 1.0 / totalVolume)); - KlkTVMatrix.set(j, i, KlkTVMatrix.get(i, j)); - - KlkTTMatrix.set(i, j, - KlkMatrix.get(i, j) * (tempVar * tempVar + tempVardT)); - KlkTTMatrix.set(j, i, KlkTTMatrix.get(i, j)); - } - - if (type > 2) { - for (int p = 0; p < numberOfComponents; p++) { - double t1 = 0.0, t2 = 0.0; - if (moleculeNumber[i] == p) { - t1 = 1.0 / mVector.get(i, 0); - } - if (moleculeNumber[j] == p) { - t2 = 1.0 / mVector.get(j, 0); - } - Klkni[p][i][j] = KlkMatrix.get(i, j) * (t1 + t2 - + ((ComponentSrkCPA) getComponent(p)).calc_lngi(this)); - Klkni[p][j][i] = Klkni[p][i][j]; - } - } - } - } - QMatksiksiksi.set(i, 0, 2.0 * mVector.get(i, 0) - / (ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0))); + deltadTdT[i][j] = + cpamix.calcDeltadTdT(assSiteNumber[i], assSiteNumber[j], moleculeNumber[i], + moleculeNumber[j], this, getTemperature(), getPressure(), numberOfComponents); + deltadTdT[j][i] = deltadTdT[i][j]; } + } + } - SimpleMatrix ksiMatrixTranspose = ksiMatrix.transpose(); - - // dXdV - SimpleMatrix KlkVMatrixksi = KlkVMatrix.mult(ksiMatrix); - SimpleMatrix XV = hessianInvers.mult(KlkVMatrixksi); - SimpleMatrix XVtranspose = XV.transpose(); - - SimpleMatrix QCPA = mVector.transpose() - .mult(uMatrix.minus(ksiMatrix.elementMult(udotMatrix).scale(0.5))); - FCPA = QCPA.get(0, 0); - - SimpleMatrix tempMatrix = ksiMatrixTranspose.mult(KlkVMatrixksi).scale(-0.5); - dFCPAdV = tempMatrix.get(0, 0); - SimpleMatrix KlkVVMatrixTImesKsi = KlkVVMatrix.mult(ksiMatrix); - SimpleMatrix tempMatrixVV = ksiMatrixTranspose.mult(KlkVVMatrixTImesKsi).scale(-0.5) - .minus(KlkVMatrixksi.transpose().mult(XV)); - dFCPAdVdV = tempMatrixVV.get(0, 0); + double totalVolume = getTotalVolume(); + double totalVolume2 = totalVolume * totalVolume; + double totalVolume3 = totalVolume2 * totalVolume; + double gdv1 = getGcpav() - 1.0 / totalVolume; + double gdv2 = gdv1 * gdv1; + double gdv3 = gdv2 * gdv1; + // double Klk = 0.0; + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + KlkVMatrix.set(i, j, KlkMatrix.get(i, j) * gdv1); + KlkVMatrix.set(j, i, KlkVMatrix.get(i, j)); + + KlkVVMatrix.set(i, j, KlkMatrix.get(i, j) * gdv2 + + KlkMatrix.get(i, j) * (gcpavv + 1.0 / totalVolume / totalVolume)); + KlkVVMatrix.set(j, i, KlkVVMatrix.get(i, j)); + + KlkVVVMatrix.set(i, j, + KlkMatrix.get(i, j) * gdv3 + + 3.0 * KlkMatrix.get(i, j) * (getGcpav() - 1.0 / totalVolume) + * (gcpavv + 1.0 / (totalVolume2)) + + KlkMatrix.get(i, j) * (gcpavvv - 2.0 / (totalVolume3))); + KlkVVVMatrix.set(j, i, KlkVVVMatrix.get(i, j)); - SimpleMatrix QVVV = ksiMatrixTranspose.mult(KlkVVVMatrix.mult(ksiMatrix)).scale(-0.5); - SimpleMatrix QVVksi = KlkVVMatrixTImesKsi.scale(-1.0); - SimpleMatrix QksiVksi = KlkVMatrix.scale(-1.0); + if (type > 1) { + double tempVar = deltadT[i][j] / delta[i][j]; + double tempVardT = deltadTdT[i][j] / delta[i][j] + - (deltadT[i][j] * deltadT[i][j]) / (delta[i][j] * delta[i][j]); - SimpleMatrix mat1 = QVVksi.transpose().mult(XV).scale(3.0); - SimpleMatrix mat2 = XVtranspose.mult(QksiVksi.mult(XV)).scale(3.0); - SimpleMatrix mat4 = XVtranspose.mult(QMatksiksiksi.mult(XVtranspose)).mult(XV); + if (!Double.isNaN(tempVar)) { + // KlkdT[i][j] = KlkMatrix.getMatrix().unsafe_get(i, j) * tempVar; + // KlkdT[j][i] = KlkdT[i][j]; - SimpleMatrix dFCPAdVdVdVMatrix = QVVV.plus(mat1).plus(mat2).plus(mat2).plus(mat4); - dFCPAdVdVdV = dFCPAdVdVdVMatrix.get(0, 0); - temp = 0; + KlkTMatrix.set(i, j, KlkMatrix.get(i, j) * tempVar); + KlkTMatrix.set(j, i, KlkTMatrix.get(i, j)); - if (type == 1) { - return; - } - for (int p = 0; p < numberOfComponents; p++) { - for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { - ((ComponentCPAInterface) getComponent(p)).setXsitedV(kk, XV.get(temp + kk, 0)); - } - temp += getComponent(p).getNumberOfAssociationSites(); - } + KlkTVMatrix.set(i, j, KlkMatrix.get(i, j) * tempVar * (gcpav - 1.0 / totalVolume)); + KlkTVMatrix.set(j, i, KlkTVMatrix.get(i, j)); - // KlkTMatrix = new SimpleMatrix(KlkdT); - SimpleMatrix KlkTMatrixTImesKsi = KlkTMatrix.mult(ksiMatrix); - // dQdT - SimpleMatrix tempMatrix2 = ksiMatrixTranspose.mult(KlkTMatrixTImesKsi).scale(-0.5); - dFCPAdT = tempMatrix2.get(0, 0); - - // SimpleMatrix KlkTVMatrix = new SimpleMatrix(KlkdTdV); - // SimpleMatrix tempMatrixTV = - // ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5).minus(KlkTMatrixTImesKsi.transpose().mult(XV)); - // dFCPAdTdV = tempMatrixTV.get(0, 0); - // dXdT - SimpleMatrix XT = hessianInvers.mult(KlkTMatrixTImesKsi); - // dQdTdT - SimpleMatrix tempMatrixTT = ksiMatrixTranspose.mult(KlkTTMatrix.mult(ksiMatrix)).scale(-0.5) - .minus(KlkTMatrixTImesKsi.transpose().mult(XT)); - dFCPAdTdT = tempMatrixTT.get(0, 0); - - SimpleMatrix tempMatrixTV = ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5) - .minus(KlkTMatrixTImesKsi.transpose().mult(XV)); - dFCPAdTdV = tempMatrixTV.get(0, 0); - - temp = 0; - for (int p = 0; p < numberOfComponents; p++) { - for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { - ((ComponentCPAInterface) getComponent(p)).setXsitedT(kk, XT.get(temp + kk, 0)); - } - temp += getComponent(p).getNumberOfAssociationSites(); - } + KlkTTMatrix.set(i, j, KlkMatrix.get(i, j) * (tempVar * tempVar + tempVardT)); + KlkTTMatrix.set(j, i, KlkTTMatrix.get(i, j)); + } - if (type == 2) { - return; - } - - // int assSites = 0; - // if(true) return; - for (int p = 0; p < numberOfComponents; p++) { - SimpleMatrix KiMatrix = new SimpleMatrix(Klkni[p]); - // KiMatrix.print(10,10); - // Matrix dQdniMatrix = - // (ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5)); // this - // methods misses one part of .... - // dQdniMatrix.print(10,10); - // KiMatrix.print(10, 10); - // miMatrix.getMatrix(assSites, assSites, 0, totalNumberOfAccociationSites - - // 1).print(10, 10); - // Matrix tempMatrix20 = miMatrix.getMatrix(assSites, assSites, 0, - // totalNumberOfAccociationSites - - // 1).times(uMatrix).minus(ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5));// - // ksiMatrix.transpose().times(KlkTMatrix.times(ksiMatrix)).times(-0.5); - // System.out.println("dQdn "); - // tempMatrix20.print(10, 10); - SimpleMatrix tempMatrix4 = KiMatrix.mult(ksiMatrix); - // udotTimesmiMatrix.getMatrix(assSites, assSites, 0, - // totalNumberOfAccociationSites - 1).print(10, 10); - SimpleMatrix tempMatrix5 = - udotTimesmiMatrix.extractVector(true, p).transpose().minus(tempMatrix4); - // tempMki[0] = mki[p]; - // Matrix amatrix = new Matrix(croeneckerProduct(tempMki, - // udotMatrix.getArray())); - // System.out.println("aMatrix "); - // amatrix.transpose().print(10, 10); - // System.out.println("temp4 matrix"); - // tempMatrix4.print(10, 10); - // Matrix tempMatrix5 = amatrix.minus(tempMatrix4); - SimpleMatrix tempMatrix6 = hessianInvers.mult(tempMatrix5);// .scale(-1.0); - // System.out.println("dXdni"); - // tempMatrix4.print(10, 10); - // tempMatrix5.print(10, 10); - // System.out.println("dXdn "); - // tempMatrix6.print(10, 10); - int temp2 = 0; - for (int compp = 0; compp < numberOfComponents; compp++) { - for (int kk = 0; kk < getComponent(compp).getNumberOfAssociationSites(); kk++) { - ((ComponentCPAInterface) getComponent(compp)).setXsitedni(kk, p, - -1.0 * tempMatrix6.get(temp2 + kk, 0)); - } - temp2 += getComponent(compp).getNumberOfAssociationSites(); + if (type > 2) { + for (int p = 0; p < numberOfComponents; p++) { + double t1 = 0.0; + double t2 = 0.0; + if (moleculeNumber[i] == p) { + t1 = 1.0 / mVector.get(i, 0); + } + if (moleculeNumber[j] == p) { + t2 = 1.0 / mVector.get(j, 0); + } + Klkni[p][i][j] = KlkMatrix.get(i, j) + * (t1 + t2 + ((ComponentSrkCPA) getComponent(p)).calc_lngi(this)); + Klkni[p][j][i] = Klkni[p][i][j]; } - // assSites += getComponent(p).getNumberOfAssociationSites(); + } } + } + QMatksiksiksi.set(i, 0, 2.0 * mVector.get(i, 0) + / (ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0))); } - /** - *

- * solveXOld. - *

- * - * @return a boolean - */ - public boolean solveXOld() { - if (getTotalNumberOfAccociationSites() == 0) { - return true; - } + SimpleMatrix ksiMatrixTranspose = ksiMatrix.transpose(); - boolean solvedX = solveX2(5); - if (solvedX) { - // return true; - } + // dXdV + SimpleMatrix KlkVMatrixksi = KlkVMatrix.mult(ksiMatrix); + SimpleMatrix XV = hessianInvers.mult(KlkVMatrixksi); + SimpleMatrix XVtranspose = XV.transpose(); - DMatrixRMaj mat1 = KlkMatrix.getMatrix(); - DMatrixRMaj mat2 = ksiMatrix.getMatrix(); - // second order method not working correctly and not used t the moment b ecause of numerical - // stability - int temp = 0, iter = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - mVector.set(temp + j, 0, componentArray[i].getNumberOfMolesInPhase()); - } - temp += componentArray[i].getNumberOfAssociationSites(); - } - double Klk = 0.0; - double totalVolume = getTotalVolume(); - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - Klk = mVector.get(i, 0) * mVector.get(j, 0) / totalVolume * delta[i][j]; - KlkMatrix.set(i, j, Klk); - KlkMatrix.set(j, i, Klk); - } - } - boolean solved = true; - // SimpleMatrix corrMatrix = null; - do { - solved = true; - iter++; - temp = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - ksiMatrix.set(temp + j, 0, ((ComponentSrkCPA) componentArray[i]).getXsite()[j]); - // ksiMatrix.getMatrix().unsafe_set(temp + j, 0, - // ksiMatrix.getMatrix().unsafe_get(temp + j, 0)); - udotMatrix.set(temp + j, 0, 1.0 / ksiMatrix.get(temp + j, 0) - 1.0); - udotTimesmMatrix.set(temp + j, 0, - mVector.get(temp + j, 0) * udotMatrix.get(temp + j, 0)); - } - temp += componentArray[i].getNumberOfAssociationSites(); - } + SimpleMatrix QCPA = + mVector.transpose().mult(uMatrix.minus(ksiMatrix.elementMult(udotMatrix).scale(0.5))); + FCPA = QCPA.get(0, 0); - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - int krondelt = 0; - if (i == j) { - krondelt = 1; - } - hessianMatrix.set(i, j, - -mVector.get(i, 0) / (ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0)) - * krondelt - KlkMatrix.get(i, j)); - hessianMatrix.set(j, i, hessianMatrix.get(i, j)); - } - } + SimpleMatrix tempMatrix = ksiMatrixTranspose.mult(KlkVMatrixksi).scale(-0.5); + dFCPAdV = tempMatrix.get(0, 0); + SimpleMatrix KlkVVMatrixTImesKsi = KlkVVMatrix.mult(ksiMatrix); + SimpleMatrix tempMatrixVV = ksiMatrixTranspose.mult(KlkVVMatrixTImesKsi).scale(-0.5) + .minus(KlkVMatrixksi.transpose().mult(XV)); + dFCPAdVdV = tempMatrixVV.get(0, 0); - // ksiMatrix = new SimpleMatrix(ksi); - // SimpleMatrix hessianMatrix = new SimpleMatrix(hessian); - try { - hessianInvers = hessianMatrix.invert(); - } catch (Exception e) { - logger.error("error", e); - return false; - } + SimpleMatrix QVVV = ksiMatrixTranspose.mult(KlkVVVMatrix.mult(ksiMatrix)).scale(-0.5); + SimpleMatrix QVVksi = KlkVVMatrixTImesKsi.scale(-1.0); + SimpleMatrix QksiVksi = KlkVMatrix.scale(-1.0); - CommonOps_DDRM.mult(mat1, mat2, corr2Matrix); - CommonOps_DDRM.subtract(udotTimesmMatrix.getDDRM(), corr2Matrix, corr3Matrix); - CommonOps_DDRM.mult(hessianInvers.getDDRM(), corr3Matrix, corr4Matrix); - // SimpleMatrix gMatrix = udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)); - // corrMatrix = - // hessianInvers.mult(udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)));//.scale(-1.0); - temp = 0; - // System.out.println("print SimpleMatrix ..."); - // corrMatrix.print(10, 10); - // SimpleMatrix simp = new SimpleMatrix(corr4Matrix); - // System.out.println("print CommonOps ..."); - // simp.print(10,10); - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - double newX = - ksiMatrix.get(temp + j, 0) - corr4Matrix.unsafe_get((temp + j), 0); - if (newX < 0) { - newX = 1e-10; - solved = false; - } - ((ComponentCPAInterface) componentArray[i]).setXsite(j, newX); - } - temp += componentArray[i].getNumberOfAssociationSites(); - } - // System.out.println("corrmatrix error " ); - // System.out.println("error " + corrMatrix.norm1()); - } while ((NormOps_DDRM.normF(corr4Matrix) > 1e-12 || !solved) && iter < 100); + SimpleMatrix mat1 = QVVksi.transpose().mult(XV).scale(3.0); + SimpleMatrix mat2 = XVtranspose.mult(QksiVksi.mult(XV)).scale(3.0); + SimpleMatrix mat4 = XVtranspose.mult(QMatksiksiksi.mult(XVtranspose)).mult(XV); - // System.out.println("iter " + iter + " error " + NormOps.normF(corr4Matrix)); - // // corrMatrix.print(10, 10); - // ksiMatrix.print(10, 10); - return true; + SimpleMatrix dFCPAdVdVdVMatrix = QVVV.plus(mat1).plus(mat2).plus(mat2).plus(mat4); + dFCPAdVdVdV = dFCPAdVdVdVMatrix.get(0, 0); + temp = 0; + + if (type == 1) { + return; + } + for (int p = 0; p < numberOfComponents; p++) { + for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { + ((ComponentCPAInterface) getComponent(p)).setXsitedV(kk, XV.get(temp + kk, 0)); + } + temp += getComponent(p).getNumberOfAssociationSites(); } - /** - *

- * solveX2Old. - *

- * - * @param maxIter a int - * @return a boolean - */ - public boolean solveX2Old(int maxIter) { - double err = .0; - int iter = 0; - // if (delta == null) { - // initCPAMatrix(1); - double old = 0.0, neeval = 0.0, totalVolume = getTotalVolume(); - // } - do { - iter++; - err = 0.0; - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - old = ((ComponentSrkCPA) getComponent(moleculeNumber[i])) - .getXsite()[assSiteNumber[i]]; - neeval = 0; - for (int j = 0; j < getTotalNumberOfAccociationSites(); j++) { - neeval += getComponent(moleculeNumber[j]).getNumberOfMolesInPhase() - * delta[i][j] * ((ComponentSrkCPA) getComponent(moleculeNumber[j])) - .getXsite()[assSiteNumber[j]]; - } - neeval = 1.0 / (1.0 + 1.0 / totalVolume * neeval); - ((ComponentCPAInterface) getComponent(moleculeNumber[i])).setXsite(assSiteNumber[i], - neeval); - err += Math.abs((old - neeval) / neeval); - } - } while (Math.abs(err) > 1e-10 && iter < maxIter); - // System.out.println("iter " + iter); - // if (Math.abs(err) - // < 1e-12) { - // return true; - // } else { - // System.out.println("did not solve for Xi in iterations: " + iter); - // System.out.println("error: " + err); - return false; + // KlkTMatrix = new SimpleMatrix(KlkdT); + SimpleMatrix KlkTMatrixTImesKsi = KlkTMatrix.mult(ksiMatrix); + // dQdT + SimpleMatrix tempMatrix2 = ksiMatrixTranspose.mult(KlkTMatrixTImesKsi).scale(-0.5); + dFCPAdT = tempMatrix2.get(0, 0); + + // SimpleMatrix KlkTVMatrix = new SimpleMatrix(KlkdTdV); + // SimpleMatrix tempMatrixTV = + // ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5).minus(KlkTMatrixTImesKsi.transpose().mult(XV)); + // dFCPAdTdV = tempMatrixTV.get(0, 0); + // dXdT + SimpleMatrix XT = hessianInvers.mult(KlkTMatrixTImesKsi); + // dQdTdT + SimpleMatrix tempMatrixTT = ksiMatrixTranspose.mult(KlkTTMatrix.mult(ksiMatrix)).scale(-0.5) + .minus(KlkTMatrixTImesKsi.transpose().mult(XT)); + dFCPAdTdT = tempMatrixTT.get(0, 0); + + SimpleMatrix tempMatrixTV = ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5) + .minus(KlkTMatrixTImesKsi.transpose().mult(XV)); + dFCPAdTdV = tempMatrixTV.get(0, 0); + + temp = 0; + for (int p = 0; p < numberOfComponents; p++) { + for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { + ((ComponentCPAInterface) getComponent(p)).setXsitedT(kk, XT.get(temp + kk, 0)); + } + temp += getComponent(p).getNumberOfAssociationSites(); } - /** - *

- * molarVolumeOld. - *

- * - * @param pressure a double - * @param temperature a double - * @param A a double - * @param B a double - * @param phasetype a int - * @return a double - * @throws neqsim.util.exception.IsNaNException if any. - * @throws neqsim.util.exception.TooManyIterationsException if any. - */ - public double molarVolumeOld(double pressure, double temperature, double A, double B, - int phasetype) throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - // if (pressure > 1000) { - // BonV = 0.9999; - // } + if (type == 2) { + return; + } - // double calcRooBonVtVolFinder = calcRootVolFinder(phasetype); - // BonV = calcRooBonVtVolFinder; - // double BonVInit = BonV; - if (BonV < 0) { - BonV = 1.0e-8; - } + // int assSites = 0; + // if(true) return; + for (int p = 0; p < numberOfComponents; p++) { + SimpleMatrix KiMatrix = new SimpleMatrix(Klkni[p]); + // KiMatrix.print(10,10); + // Matrix dQdniMatrix = + // (ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5)); // this + // methods misses one part of .... + // dQdniMatrix.print(10,10); + // KiMatrix.print(10, 10); + // miMatrix.getMatrix(assSites, assSites, 0, totalNumberOfAccociationSites - + // 1).print(10, 10); + // Matrix tempMatrix20 = miMatrix.getMatrix(assSites, assSites, 0, + // totalNumberOfAccociationSites - + // 1).times(uMatrix).minus(ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5)); + // // + // ksiMatrix.transpose().times(KlkTMatrix.times(ksiMatrix)).times(-0.5); + // System.out.println("dQdn "); + // tempMatrix20.print(10, 10); + SimpleMatrix tempMatrix4 = KiMatrix.mult(ksiMatrix); + // udotTimesmiMatrix.getMatrix(assSites, assSites, 0, + // totalNumberOfAccociationSites - 1).print(10, 10); + SimpleMatrix tempMatrix5 = + udotTimesmiMatrix.extractVector(true, p).transpose().minus(tempMatrix4); + // tempMki[0] = mki[p]; + // Matrix amatrix = new Matrix(croeneckerProduct(tempMki, + // udotMatrix.getArray())); + // System.out.println("aMatrix "); + // amatrix.transpose().print(10, 10); + // System.out.println("temp4 matrix"); + // tempMatrix4.print(10, 10); + // Matrix tempMatrix5 = amatrix.minus(tempMatrix4); + SimpleMatrix tempMatrix6 = hessianInvers.mult(tempMatrix5); // .scale(-1.0); + // System.out.println("dXdni"); + // tempMatrix4.print(10, 10); + // tempMatrix5.print(10, 10); + // System.out.println("dXdn "); + // tempMatrix6.print(10, 10); + int temp2 = 0; + for (int compp = 0; compp < numberOfComponents; compp++) { + for (int kk = 0; kk < getComponent(compp).getNumberOfAssociationSites(); kk++) { + ((ComponentCPAInterface) getComponent(compp)).setXsitedni(kk, p, + -1.0 * tempMatrix6.get(temp2 + kk, 0)); + } + temp2 += getComponent(compp).getNumberOfAssociationSites(); + } + // assSites += getComponent(p).getNumberOfAssociationSites(); + } + } + + /** + *

+ * solveXOld. + *

+ * + * @return a boolean + */ + public boolean solveXOld() { + if (getTotalNumberOfAccociationSites() == 0) { + return true; + } - if (BonV >= 1.0) { - BonV = 0.9999; - } - double BonVold; - double h = 0, dh = 0, dhh = 0; - double d1 = 0, d2 = 0; - double Btemp = getB(); - if (Btemp < 0) { - logger.info("b negative in volume calc"); - } - calcDelta(); + boolean solvedX = solveX2(5); + if (solvedX) { + // return true; + } - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - int iterations = 0; + DMatrixRMaj mat1 = KlkMatrix.getMatrix(); + DMatrixRMaj mat2 = ksiMatrix.getMatrix(); + // second order method not working correctly and not used t the moment b ecause of numerical + // stability + int temp = 0; + int iter = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + mVector.set(temp + j, 0, componentArray[i].getNumberOfMolesInPhase()); + } + temp += componentArray[i].getNumberOfAssociationSites(); + } + double Klk = 0.0; + double totalVolume = getTotalVolume(); + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + Klk = mVector.get(i, 0) * mVector.get(j, 0) / totalVolume * delta[i][j]; + KlkMatrix.set(i, j, Klk); + KlkMatrix.set(j, i, Klk); + } + } + boolean solved = true; + // SimpleMatrix corrMatrix = null; + do { + solved = true; + iter++; + temp = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + ksiMatrix.set(temp + j, 0, ((ComponentSrkCPA) componentArray[i]).getXsite()[j]); + // ksiMatrix.getMatrix().unsafe_set(temp + j, 0, + // ksiMatrix.getMatrix().unsafe_get(temp + j, 0)); + udotMatrix.set(temp + j, 0, 1.0 / ksiMatrix.get(temp + j, 0) - 1.0); + udotTimesmMatrix.set(temp + j, 0, mVector.get(temp + j, 0) * udotMatrix.get(temp + j, 0)); + } + temp += componentArray[i].getNumberOfAssociationSites(); + } + + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + int krondelt = 0; + if (i == j) { + krondelt = 1; + } + hessianMatrix.set(i, j, + -mVector.get(i, 0) / (ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0)) * krondelt + - KlkMatrix.get(i, j)); + hessianMatrix.set(j, i, hessianMatrix.get(i, j)); + } + } + + // ksiMatrix = new SimpleMatrix(ksi); + // SimpleMatrix hessianMatrix = new SimpleMatrix(hessian); + try { + hessianInvers = hessianMatrix.invert(); + } catch (Exception e) { + logger.error("error", e); + return false; + } + + CommonOps_DDRM.mult(mat1, mat2, corr2Matrix); + CommonOps_DDRM.subtract(udotTimesmMatrix.getDDRM(), corr2Matrix, corr3Matrix); + CommonOps_DDRM.mult(hessianInvers.getDDRM(), corr3Matrix, corr4Matrix); + // SimpleMatrix gMatrix = udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)); + // corrMatrix = + // hessianInvers.mult(udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix))); + // //.scale(-1.0); + temp = 0; + // System.out.println("print SimpleMatrix ..."); + // corrMatrix.print(10, 10); + // SimpleMatrix simp = new SimpleMatrix(corr4Matrix); + // System.out.println("print CommonOps ..."); + // simp.print(10,10); + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + double newX = ksiMatrix.get(temp + j, 0) - corr4Matrix.unsafe_get((temp + j), 0); + if (newX < 0) { + newX = 1e-10; + solved = false; + } + ((ComponentCPAInterface) componentArray[i]).setXsite(j, newX); + } + temp += componentArray[i].getNumberOfAssociationSites(); + } + // System.out.println("corrmatrix error " ); + // System.out.println("error " + corrMatrix.norm1()); + } while ((NormOps_DDRM.normF(corr4Matrix) > 1e-12 || !solved) && iter < 100); + + // System.out.println("iter " + iter + " error " + NormOps.normF(corr4Matrix)); + // // corrMatrix.print(10, 10); + // ksiMatrix.print(10, 10); + return true; + } + + /** + *

+ * solveX2Old. + *

+ * + * @param maxIter a int + * @return a boolean + */ + public boolean solveX2Old(int maxIter) { + double err = .0; + int iter = 0; + // if (delta == null) { + // initCPAMatrix(1); + double old = 0.0; + double neeval = 0.0; + double totalVolume = getTotalVolume(); + // } + do { + iter++; + err = 0.0; + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + old = ((ComponentSrkCPA) getComponent(moleculeNumber[i])).getXsite()[assSiteNumber[i]]; + neeval = 0; + for (int j = 0; j < getTotalNumberOfAccociationSites(); j++) { + neeval += getComponent(moleculeNumber[j]).getNumberOfMolesInPhase() * delta[i][j] + * ((ComponentSrkCPA) getComponent(moleculeNumber[j])).getXsite()[assSiteNumber[j]]; + } + neeval = 1.0 / (1.0 + 1.0 / totalVolume * neeval); + ((ComponentCPAInterface) getComponent(moleculeNumber[i])).setXsite(assSiteNumber[i], + neeval); + err += Math.abs((old - neeval) / neeval); + } + } while (Math.abs(err) > 1e-10 && iter < maxIter); + // System.out.println("iter " + iter); + // if (Math.abs(err) + // < 1e-12) { + // return true; + // } else { + // System.out.println("did not solve for Xi in iterations: " + iter); + // System.out.println("error: " + err); + return false; + } + + /** + *

+ * molarVolumeOld. + *

+ * + * @param pressure a double + * @param temperature a double + * @param A a double + * @param B a double + * @param phasetype a int + * @return a double + * @throws neqsim.util.exception.IsNaNException if any. + * @throws neqsim.util.exception.TooManyIterationsException if any. + */ + public double molarVolumeOld(double pressure, double temperature, double A, double B, + int phasetype) throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + // if (pressure > 1000) { + // BonV = 0.9999; + // } + + // double calcRooBonVtVolFinder = calcRootVolFinder(phasetype); + // BonV = calcRooBonVtVolFinder; + // double BonVInit = BonV; + if (BonV < 0) { + BonV = 1.0e-8; + } - do { - iterations++; - gcpa = calc_g(); - if (gcpa < 0) { - setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); - gcpa = calc_g(); - } + if (BonV >= 1.0) { + BonV = 0.9999; + } + double BonVold; + double h = 0; + double dh = 0; + double dhh = 0; + double d1 = 0; + double d2 = 0; + double Btemp = getB(); + if (Btemp < 0) { + logger.info("b negative in volume calc"); + } + calcDelta(); - // lngcpa = - // Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + int iterations = 0; - if (getTotalNumberOfAccociationSites() > 0) { - solveX(); - } + do { + iterations++; + gcpa = calc_g(); + if (gcpa < 0) { + setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); + gcpa = calc_g(); + } - initCPAMatrix(1); - double BonV2 = BonV * BonV; - BonVold = BonV; - h = BonV - Btemp / numberOfMolesInPhase * dFdV() - - pressure * Btemp / (numberOfMolesInPhase * R * temperature); - dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); - dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) - - (Btemp * Btemp) / (BonV2 * BonV2) - * (Btemp / numberOfMolesInPhase * dFdVdVdV()); - - d1 = -h / dh; - d2 = -dh / dhh; - // System.out.println("h " + h + " iter " + iterations + " " + d1 + " d2 " + d2 - // + " d1 / d2 " + (d1 / d2)); - if (Math.abs(d1 / d2) <= 1.0) { - BonV += d1 * (1.0 + 0.5 * d1 / d2); - } else if (d1 / d2 < -1) { - BonV += 0.5 * d1; - } else if (d1 > d2) { - BonV += d2; - double hnew = h + d2 * dh; - if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } else { - BonV += 0.5 * d1; - } - if (Math.abs((BonV - BonVold) / BonVold) > 0.1) { - BonV = BonVold + 0.1 * (BonV - BonVold); - } + // lngcpa = + // Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); - if (BonV > 0.9999) { - if (iterations < 3) { - BonV = (BonVold + BonV) / 2.0; - } else { - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - // BonV = 0.9999; - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / - // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * - // temperature * R); - } - } else if (BonV < 0) { - if (iterations < 3) { - BonV = Math.abs(BonVold + BonV) / 2.0; - } else { - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / - // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * - // temperature * R); - } - } - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10 || Math.abs(h) > 1e-12) - && iterations < 100); - - if (Math.abs(h) > 1e-12) { - // System.out.println("h failed " + "Z" + Z + " iterations " + iterations + " - // BonV " + BonV); - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - } - // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); - // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); - // System.out.println("volume " + totalVolume + " molar volume " + - // getMolarVolume()); - // if(iterations>=100) throw new util.exception.TooManyIterationsException(); - // System.out.println("error in volume " + - // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " - // firstterm " + (R*temperature/molarVolume) + " second " + - // R*temperature*dFdV()); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + " B - // " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); - - if (Double.isNaN(getMolarVolume())) { - throw new neqsim.util.exception.IsNaNException(this, "molarVolumeOld", "Molar volume"); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " - // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" - // + fVV()); - } - return getMolarVolume(); + if (getTotalNumberOfAccociationSites() > 0) { + solveX(); + } + + initCPAMatrix(1); + double BonV2 = BonV * BonV; + BonVold = BonV; + h = BonV - Btemp / numberOfMolesInPhase * dFdV() + - pressure * Btemp / (numberOfMolesInPhase * R * temperature); + dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); + dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) + - (Btemp * Btemp) / (BonV2 * BonV2) * (Btemp / numberOfMolesInPhase * dFdVdVdV()); + + d1 = -h / dh; + d2 = -dh / dhh; + // System.out.println("h " + h + " iter " + iterations + " " + d1 + " d2 " + d2 + // + " d1 / d2 " + (d1 / d2)); + if (Math.abs(d1 / d2) <= 1.0) { + BonV += d1 * (1.0 + 0.5 * d1 / d2); + } else if (d1 / d2 < -1) { + BonV += 0.5 * d1; + } else if (d1 > d2) { + BonV += d2; + double hnew = h + d2 * dh; + if (Math.abs(hnew) > Math.abs(h)) { + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + } + } else { + BonV += 0.5 * d1; + } + if (Math.abs((BonV - BonVold) / BonVold) > 0.1) { + BonV = BonVold + 0.1 * (BonV - BonVold); + } + + if (BonV > 0.9999) { + if (iterations < 3) { + BonV = (BonVold + BonV) / 2.0; + } else { + // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // BonV = 0.9999; + // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * + // temperature * R); + } + } else if (BonV < 0) { + if (iterations < 3) { + BonV = Math.abs(BonVold + BonV) / 2.0; + } else { + // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * + // temperature * R); + } + } + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); + } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10 || Math.abs(h) > 1e-12) + && iterations < 100); + + if (Math.abs(h) > 1e-12) { + // System.out.println("h failed " + "Z" + Z + " iterations " + iterations + " + // BonV " + BonV); + // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + } + // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); + // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); + // System.out.println("volume " + totalVolume + " molar volume " + + // getMolarVolume()); + // if(iterations>=100) throw new util.exception.TooManyIterationsException(); + // System.out.println("error in volume " + + // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV())); // + " + // firstterm " + (R*temperature/molarVolume) + " second " + + // R*temperature*dFdV()); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + " B + // " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); + + if (Double.isNaN(getMolarVolume())) { + throw new neqsim.util.exception.IsNaNException(this, "molarVolumeOld", "Molar volume"); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " + // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + // + fVV()); } + return getMolarVolume(); + } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseSrkCPA_proceduralMatrices.java b/src/main/java/neqsim/thermo/phase/PhaseSrkCPA_proceduralMatrices.java index a1d4f1670c..c49d232217 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseSrkCPA_proceduralMatrices.java +++ b/src/main/java/neqsim/thermo/phase/PhaseSrkCPA_proceduralMatrices.java @@ -21,1437 +21,1502 @@ * @version Modified to use procedural oriented ejml matrices by Marlene Lund */ public class PhaseSrkCPA_proceduralMatrices extends PhaseSrkEos implements PhaseCPAInterface { - private static final long serialVersionUID = 1000; - - public CPAMixing cpaSelect = new CPAMixing(); - public CPAMixingInterface cpamix; - double gcpavv = 0.0, gcpavvv = 0.0, gcpa = 0.0, hcpatot = 1.0, FCPA = 0.0, dFCPAdTdV, - dFCPAdTdT = 0.0, dFCPAdT = 0, dFCPAdV = 0, dFCPAdVdV = 0.0, dFCPAdVdVdV = 0.0; - private double gcpav = 0.0; - int cpaon = 1, oldTotalNumberOfAccociationSites = 0; - private int totalNumberOfAccociationSites = 0; - int[][][] selfAccociationScheme = null; - int[][][][] crossAccociationScheme = null; - int[] moleculeNumber = null, assSiteNumber = null; - private double[][] gvector = null, delta = null, deltaNog = null, deltadT = null, - deltadTdT = null; - private double[][][] Klkni = null; - private DMatrixRMaj KlkTVMatrix = null, KlkTTMatrix = null, KlkTMatrix = null, - udotTimesmMatrix = null, mVector = null, udotMatrix = null, uMatrix = null, - QMatksiksiksi = null, KlkVVVMatrix = null, KlkVVMatrix = null, udotTimesmiMatrix = null, - ksiMatrix = null, KlkMatrix = null, hessianMatrix = null, hessianInvers = null, - KlkVMatrix = null; - DMatrixRMaj corr2Matrix = null, corr3Matrix = null, corr4Matrix = null;// new - // DenseMatrix64F(getTotalNumberOfAccociationSites(), - // 1); - static Logger logger = LogManager.getLogger(PhaseSrkCPA_proceduralMatrices.class); - - /** - *

- * Constructor for PhaseSrkCPA_proceduralMatrices. - *

- */ - public PhaseSrkCPA_proceduralMatrices() { - super(); - } + private static final long serialVersionUID = 1000; - /** {@inheritDoc} */ - @Override - public PhaseSrkCPA clone() { - PhaseSrkCPA clonedPhase = null; - try { - clonedPhase = (PhaseSrkCPA) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } - // clonedPhase.cpaSelect = (CPAMixing) cpaSelect.clone(); - // clonedPhase.cpamix = (CPAMixingInterface) cpamix.clone(); - // clonedPhase.cpamix = cpaSelect.getMixingRule(1, this); + public CPAMixing cpaSelect = new CPAMixing(); + public CPAMixingInterface cpamix; + double gcpavv = 0.0; - return clonedPhase; - } + double gcpavvv = 0.0; - /** {@inheritDoc} */ - @Override - public void setMixingRule(int type) { - super.setMixingRule(type); - cpamix = cpaSelect.getMixingRule(1, this); - } + double gcpa = 0.0; - /** {@inheritDoc} */ - @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, - double beta) { - if (type == 0) { - setTotalNumberOfAccociationSites(0); - selfAccociationScheme = new int[numberOfComponents][0][0]; - crossAccociationScheme = new int[numberOfComponents][numberOfComponents][0][0]; - for (int i = 0; i < numberOfComponents; i++) { - if (getComponent(i).getNumberOfmoles() < 1e-50) { - getComponent(i).setNumberOfAssociationSites(0); - } else { - getComponent(i).setNumberOfAssociationSites( - getComponent(i).getOrginalNumberOfAssociationSites()); - setTotalNumberOfAccociationSites(getTotalNumberOfAccociationSites() - + getComponent(i).getNumberOfAssociationSites()); - selfAccociationScheme[i] = cpaSelect.setAssociationScheme(i, this); - for (int j = 0; j < numberOfComponents; j++) { - crossAccociationScheme[i][j] = - cpaSelect.setCrossAssociationScheme(i, j, this); - } - } - } + double hcpatot = 1.0; - // had to remove if below - dont understand why.. Even - // if (getTotalNumberOfAccociationSites() != oldTotalNumberOfAccociationSites) { - mVector = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - KlkMatrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkVMatrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkVVMatrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkVVVMatrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - hessianMatrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkTMatrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkTTMatrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkTVMatrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - corr2Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - corr3Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - corr4Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - Klkni = new double[numberOfComponents][getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - ksiMatrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - uMatrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - udotMatrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - moleculeNumber = new int[getTotalNumberOfAccociationSites()]; - assSiteNumber = new int[getTotalNumberOfAccociationSites()]; - gvector = new double[getTotalNumberOfAccociationSites()][1]; - udotTimesmMatrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - delta = new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - deltaNog = - new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - deltadT = - new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - deltadTdT = - new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - QMatksiksiksi = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - // } - udotTimesmiMatrix = - new DMatrixRMaj(getNumberOfComponents(), getTotalNumberOfAccociationSites()); - - oldTotalNumberOfAccociationSites = getTotalNumberOfAccociationSites(); - - int temp = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - moleculeNumber[temp + j] = i; - assSiteNumber[temp + j] = j; - } - temp += getComponent(i).getNumberOfAssociationSites(); - } - } - if (cpamix == null) { - cpamix = cpaSelect.getMixingRule(1, this); - } + double FCPA = 0.0; - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - if (type > 0 && isConstantPhaseVolume()) { - calcDelta(); - solveX(); - super.init(totalNumberOfMoles, numberOfComponents, 1, phase, beta); - gcpa = calc_g(); - // lngcpa = Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - } + double dFCPAdTdV; - if (type > 0) { - hcpatot = calc_hCPA(); - } + double dFCPAdTdT = 0.0; - if (type > 1) { - initCPAMatrix(type); - // hcpatotdT = calc_hCPAdT(); - // super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - } - } + double dFCPAdT = 0; - /** - *

- * calcDelta. - *

- */ - public void calcDelta() { - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - deltaNog[i][j] = cpamix.calcDeltaNog(assSiteNumber[i], assSiteNumber[j], - moleculeNumber[i], moleculeNumber[j], this, getTemperature(), getPressure(), - numberOfComponents); - deltaNog[j][i] = deltaNog[i][j]; - } - } - } + double dFCPAdV = 0; - /** - *

- * initCPAMatrix. - *

- * - * @param type a int - */ - public void initCPAMatrix(int type) { - if (getTotalNumberOfAccociationSites() == 0) { - FCPA = 0.0; - dFCPAdTdV = 0.0; - dFCPAdTdT = 0.0; - dFCPAdT = 0; - dFCPAdV = 0; - dFCPAdVdV = 0.0; - dFCPAdVdVdV = 0.0; - - return; - } + double dFCPAdVdV = 0.0; - int temp = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - uMatrix.set(temp + j, 0, - Math.log(ksiMatrix.get(temp + j, 0)) - ksiMatrix.get(temp + j, 0) + 1.0); - gvector[temp + j][0] = mVector.get(temp + j, 0) * udotMatrix.get(temp + j, 0); - } - temp += getComponent(i).getNumberOfAssociationSites(); - } - for (int i = 0; i < getNumberOfComponents(); i++) { - for (int j = 0; j < getTotalNumberOfAccociationSites(); j++) { - if (moleculeNumber[j] == i) { - udotTimesmiMatrix.set(i, j, udotMatrix.get(j, 0)); - } else { - udotTimesmiMatrix.set(i, j, 0.0); - } - } - } + double dFCPAdVdVdV = 0.0; - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - delta[i][j] = deltaNog[i][j] * getGcpa(); - delta[j][i] = delta[i][j]; - if (type > 1) { - deltadT[i][j] = cpamix.calcDeltadT(assSiteNumber[i], assSiteNumber[j], - moleculeNumber[i], moleculeNumber[j], this, getTemperature(), - getPressure(), numberOfComponents); - deltadT[j][i] = deltadT[i][j]; - - deltadTdT[i][j] = cpamix.calcDeltadTdT(assSiteNumber[i], assSiteNumber[j], - moleculeNumber[i], moleculeNumber[j], this, getTemperature(), - getPressure(), numberOfComponents); - deltadTdT[j][i] = deltadTdT[i][j]; - } - } - } + private double gcpav = 0.0; + int cpaon = 1; - double gdv1 = getGcpav() - 1.0 / getTotalVolume(); - double gdv2 = gdv1 * gdv1; - double gdv3 = gdv2 * gdv1; - double totVol = getTotalVolume(); - // double Klk = 0.0; - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - KlkVMatrix.set(i, j, KlkMatrix.get(i, j) * gdv1); - KlkVMatrix.set(j, i, KlkVMatrix.get(i, j)); - - KlkVVMatrix.set(i, j, KlkMatrix.get(i, j) * gdv2 + KlkMatrix.get(i, j) - * (gcpavv + 1.0 / getTotalVolume() / getTotalVolume())); - KlkVVMatrix.set(j, i, KlkVVMatrix.get(i, j)); - - KlkVVVMatrix.set(i, j, KlkMatrix.get(i, j) * gdv3 - + 3.0 * KlkMatrix.get(i, j) * (getGcpav() - 1.0 / getTotalVolume()) - * (gcpavv + 1.0 / (totVol * totVol)) - + KlkMatrix.get(i, j) * (gcpavvv - 2.0 / (totVol * totVol * totVol))); - KlkVVVMatrix.set(j, i, KlkVVVMatrix.get(i, j)); - - if (type > 1) { - double tempVar = deltadT[i][j] / delta[i][j]; - double tempVardT = deltadTdT[i][j] / delta[i][j] - - (deltadT[i][j] * deltadT[i][j]) / (delta[i][j] * delta[i][j]); - - if (!Double.isNaN(tempVar)) { - // KlkdT[i][j] = KlkMatrix.getMatrix().unsafe_get(i, j) * tempVar; - // KlkdT[j][i] = KlkdT[i][j]; - - KlkTMatrix.set(i, j, KlkMatrix.get(i, j) * tempVar); - KlkTMatrix.set(j, i, KlkTMatrix.get(i, j)); - - KlkTVMatrix.set(i, j, - KlkMatrix.get(i, j) * tempVar * (gcpav - 1.0 / getTotalVolume())); - KlkTVMatrix.set(j, i, KlkTVMatrix.get(i, j)); - - KlkTTMatrix.set(i, j, - KlkMatrix.get(i, j) * (tempVar * tempVar + tempVardT)); - KlkTTMatrix.set(j, i, KlkTTMatrix.get(i, j)); - } - - if (type > 2) { - for (int p = 0; p < numberOfComponents; p++) { - double t1 = 0.0, t2 = 0.0; - if (moleculeNumber[i] == p) { - t1 = 1.0 / mVector.get(i, 0); - } - if (moleculeNumber[j] == p) { - t2 = 1.0 / mVector.get(j, 0); - } - Klkni[p][i][j] = KlkMatrix.get(i, j) * (t1 + t2 - + ((ComponentSrkCPA) getComponent(p)).calc_lngi(this)); - Klkni[p][j][i] = Klkni[p][i][j]; - } - } - } - } - QMatksiksiksi.set(i, 0, 2.0 * mVector.get(i, 0) - / (ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0))); - } + int oldTotalNumberOfAccociationSites = 0; - DMatrixRMaj ksiMatrixTranspose = new DMatrixRMaj(); - CommonOps_DDRM.transpose(ksiMatrix, ksiMatrixTranspose); - - // dXdV - DMatrixRMaj KlkVMatrixksi = new DMatrixRMaj(); - CommonOps_DDRM.mult(KlkVMatrix, ksiMatrix, KlkVMatrixksi); - - DMatrixRMaj XV = new DMatrixRMaj(); - DMatrixRMaj XVtranspose = new DMatrixRMaj(); - CommonOps_DDRM.mult(hessianInvers, KlkVMatrixksi, XV); - CommonOps_DDRM.transpose(XV, XVtranspose); - - DMatrixRMaj QCPA = new DMatrixRMaj(); - DMatrixRMaj mVectorTranspose = new DMatrixRMaj(); - DMatrixRMaj ksiMatrixudotMatrix = new DMatrixRMaj(); - DMatrixRMaj ksiMatrixudotMatrixScaled = new DMatrixRMaj(); - DMatrixRMaj uMatrixMinusksiMatrixudotMatrixScaled = new DMatrixRMaj(); - DMatrixRMaj ksiMatrixudotMatrixScaledNegative = new DMatrixRMaj(); - CommonOps_DDRM.transpose(mVector, mVectorTranspose); - CommonOps_DDRM.elementMult(ksiMatrix, udotMatrix, ksiMatrixudotMatrix); - CommonOps_DDRM.scale(0.5, ksiMatrixudotMatrix, ksiMatrixudotMatrixScaled); - CommonOps_DDRM.scale(-1.0, ksiMatrixudotMatrixScaled, ksiMatrixudotMatrixScaledNegative); - CommonOps_DDRM.add(uMatrix, ksiMatrixudotMatrixScaledNegative, - uMatrixMinusksiMatrixudotMatrixScaled); - CommonOps_DDRM.mult(mVectorTranspose, uMatrixMinusksiMatrixudotMatrixScaled, QCPA); - FCPA = QCPA.get(0, 0); - - DMatrixRMaj tempMatrix = new DMatrixRMaj(); - CommonOps_DDRM.mult(ksiMatrixTranspose, KlkVMatrixksi, tempMatrix); - CommonOps_DDRM.scale(-0.5, tempMatrix); - dFCPAdV = tempMatrix.get(0, 0); - - DMatrixRMaj KlkVVMatrixTimesKsi = new DMatrixRMaj(); - DMatrixRMaj KlkVMatrixksiTranspose = new DMatrixRMaj(); - DMatrixRMaj KlkVMatrixksiXV = new DMatrixRMaj(); - DMatrixRMaj ksiKlkVVksi = new DMatrixRMaj(); - DMatrixRMaj tempMatrixVV = new DMatrixRMaj(); - CommonOps_DDRM.mult(KlkVVMatrix, ksiMatrix, KlkVVMatrixTimesKsi); - CommonOps_DDRM.transpose(KlkVMatrixksi, KlkVMatrixksiTranspose); - CommonOps_DDRM.mult(KlkVMatrixksiTranspose, XV, KlkVMatrixksiXV); - CommonOps_DDRM.mult(ksiMatrixTranspose, KlkVVMatrixTimesKsi, ksiKlkVVksi); - CommonOps_DDRM.scale(-0.5, ksiKlkVVksi); - CommonOps_DDRM.scale(-1.0, KlkVMatrixksiXV); - CommonOps_DDRM.add(ksiKlkVVksi, KlkVMatrixksiXV, tempMatrixVV); - dFCPAdVdV = tempMatrixVV.get(0, 0); - - DMatrixRMaj QVVV = new DMatrixRMaj(); - DMatrixRMaj QVVksi = new DMatrixRMaj(); - DMatrixRMaj QksiVksi = new DMatrixRMaj(); - DMatrixRMaj KlkVVVMatrixksi = new DMatrixRMaj(); - CommonOps_DDRM.mult(KlkVVVMatrix, ksiMatrix, KlkVVVMatrixksi); - CommonOps_DDRM.mult(ksiMatrixTranspose, KlkVVVMatrixksi, QVVV); - CommonOps_DDRM.scale(-0.5, QVVV); - CommonOps_DDRM.scale(-1.0, KlkVVMatrixTimesKsi, QVVksi); - CommonOps_DDRM.scale(-1.0, KlkVMatrix, QksiVksi); - - DMatrixRMaj mat1 = new DMatrixRMaj(); - DMatrixRMaj mat2 = new DMatrixRMaj(); - DMatrixRMaj mat4 = new DMatrixRMaj(); - DMatrixRMaj QVVksiTranspose = new DMatrixRMaj(); - DMatrixRMaj QksiVksiXV = new DMatrixRMaj(); - DMatrixRMaj XVtransposeQMatksiksiksiXVtranspose = new DMatrixRMaj(); - DMatrixRMaj QMatksiksiksiXVtranspose = new DMatrixRMaj(); - - CommonOps_DDRM.transpose(QVVksi, QVVksiTranspose); - CommonOps_DDRM.mult(QVVksiTranspose, XV, mat1); - CommonOps_DDRM.scale(3.0, mat1); - CommonOps_DDRM.mult(QksiVksi, XV, QksiVksiXV); - CommonOps_DDRM.mult(XVtranspose, QksiVksiXV, mat2); - CommonOps_DDRM.scale(3.0, mat2); - CommonOps_DDRM.mult(QMatksiksiksi, XVtranspose, QMatksiksiksiXVtranspose); - CommonOps_DDRM.mult(XVtranspose, QMatksiksiksiXVtranspose, - XVtransposeQMatksiksiksiXVtranspose); - CommonOps_DDRM.mult(XVtransposeQMatksiksiksiXVtranspose, XV, mat4); - - DMatrixRMaj dFCPAdVdVdVMatrix = new DMatrixRMaj(); - dFCPAdVdVdVMatrix.setTo(QVVV); - CommonOps_DDRM.addEquals(dFCPAdVdVdVMatrix, mat1); - CommonOps_DDRM.addEquals(dFCPAdVdVdVMatrix, mat2); - CommonOps_DDRM.addEquals(dFCPAdVdVdVMatrix, mat2); - CommonOps_DDRM.addEquals(dFCPAdVdVdVMatrix, mat4); - dFCPAdVdVdV = dFCPAdVdVdVMatrix.get(0, 0); - temp = 0; - - if (type == 1) { - return; - } - for (int p = 0; p < numberOfComponents; p++) { - for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { - ((ComponentCPAInterface) getComponent(p)).setXsitedV(kk, XV.get(temp + kk, 0)); - } - temp += getComponent(p).getNumberOfAssociationSites(); - } + private int totalNumberOfAccociationSites = 0; + int[][][] selfAccociationScheme = null; + int[][][][] crossAccociationScheme = null; + int[] moleculeNumber = null; - // KlkTMatrix = new SimpleMatrix(KlkdT); - DMatrixRMaj KlkTMatrixTimesKsi = new DMatrixRMaj(); - CommonOps_DDRM.mult(KlkTMatrix, ksiMatrix, KlkTMatrixTimesKsi); - - // dQdT - DMatrixRMaj tempMatrix2 = new DMatrixRMaj(); - CommonOps_DDRM.mult(ksiMatrixTranspose, KlkTMatrixTimesKsi, tempMatrix2); - CommonOps_DDRM.scale(-0.5, tempMatrix2); - dFCPAdT = tempMatrix2.get(0, 0); - - // SimpleMatrix KlkTVMatrix = new SimpleMatrix(KlkdTdV); - // SimpleMatrix tempMatrixTV = - // ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5).minus(KlkTMatrixTImesKsi.transpose().mult(XV)); - // dFCPAdTdV = tempMatrixTV.get(0, 0); - // dXdT - DMatrixRMaj XT = new DMatrixRMaj(); - CommonOps_DDRM.mult(hessianInvers, KlkTMatrixTimesKsi, XT); - - // dQdTdT - DMatrixRMaj tempMatrixTT = new DMatrixRMaj(); - DMatrixRMaj KlkTMatrixTimesKsiTranspose = new DMatrixRMaj(); - DMatrixRMaj KlkTMatrixTimesKsiTransposeXT = new DMatrixRMaj(); - DMatrixRMaj KlkTTMatrixksi = new DMatrixRMaj(); - DMatrixRMaj ksiMatrixTransposeKlkTTMatrixksi = new DMatrixRMaj(); - CommonOps_DDRM.transpose(KlkTMatrixTimesKsi, KlkTMatrixTimesKsiTranspose); - CommonOps_DDRM.mult(KlkTMatrixTimesKsiTranspose, XT, KlkTMatrixTimesKsiTransposeXT); - CommonOps_DDRM.mult(KlkTTMatrix, ksiMatrix, KlkTTMatrixksi); - CommonOps_DDRM.mult(ksiMatrixTranspose, KlkTTMatrixksi, ksiMatrixTransposeKlkTTMatrixksi); - CommonOps_DDRM.scale(-0.5, ksiMatrixTransposeKlkTTMatrixksi); - CommonOps_DDRM.scale(-1.0, KlkTMatrixTimesKsiTransposeXT); - CommonOps_DDRM.add(ksiMatrixTransposeKlkTTMatrixksi, KlkTMatrixTimesKsiTransposeXT, - tempMatrixTT); - // SimpleMatrix tempMatrixTT = - // ksiMatrixTranspose.mult(KlkTTMatrix.mult(ksiMatrix)).scale(-0.5).minus(KlkTMatrixTImesKsi.transpose().mult(XT)); - dFCPAdTdT = tempMatrixTT.get(0, 0); - - DMatrixRMaj tempMatrixTV = new DMatrixRMaj(); - DMatrixRMaj KlkTMatrixTimesKsiTransposeXV = new DMatrixRMaj(); - DMatrixRMaj KlkTVMatrixksi = new DMatrixRMaj(); - DMatrixRMaj ksiMatrixTransposeKlkTVMatrixksi = new DMatrixRMaj(); - CommonOps_DDRM.transpose(KlkTMatrixTimesKsi, KlkTMatrixTimesKsiTranspose); - CommonOps_DDRM.mult(KlkTMatrixTimesKsiTranspose, XV, KlkTMatrixTimesKsiTransposeXV); - CommonOps_DDRM.mult(KlkTVMatrix, ksiMatrix, KlkTVMatrixksi); - CommonOps_DDRM.mult(ksiMatrixTranspose, KlkTVMatrixksi, ksiMatrixTransposeKlkTTMatrixksi); - CommonOps_DDRM.scale(-0.5, ksiMatrixTransposeKlkTVMatrixksi); - CommonOps_DDRM.scale(-1.0, KlkTMatrixTimesKsiTransposeXV); - CommonOps_DDRM.add(ksiMatrixTransposeKlkTVMatrixksi, KlkTMatrixTimesKsiTransposeXV, - tempMatrixTV); - // SimpleMatrix tempMatrixTV = - // ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5).minus(KlkTMatrixTImesKsi.transpose().mult(XV)); - dFCPAdTdV = tempMatrixTV.get(0, 0); - - temp = 0; - for (int p = 0; p < numberOfComponents; p++) { - for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { - ((ComponentCPAInterface) getComponent(p)).setXsitedT(kk, XT.get(temp + kk, 0)); - } - temp += getComponent(p).getNumberOfAssociationSites(); - } + int[] assSiteNumber = null; - if (type == 2) { - return; - } + private double[][] gvector = null; - // int assSites = 0; - // if(true) return; - for (int p = 0; p < numberOfComponents; p++) { - DMatrixRMaj KiMatrix = new DMatrixRMaj(Klkni[p]); - // KiMatrix.print(10,10); - // Matrix dQdniMatrix = - // (ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5)); // this - // methods misses one part of .... - // dQdniMatrix.print(10,10); - // KiMatrix.print(10, 10); - // miMatrix.getMatrix(assSites, assSites, 0, totalNumberOfAccociationSites - - // 1).print(10, 10); - // Matrix tempMatrix20 = miMatrix.getMatrix(assSites, assSites, 0, - // totalNumberOfAccociationSites - - // 1).times(uMatrix).minus(ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5));// - // ksiMatrix.transpose().times(KlkTMatrix.times(ksiMatrix)).times(-0.5); - // System.out.println("dQdn "); - // tempMatrix20.print(10, 10); - DMatrixRMaj tempMatrix4 = new DMatrixRMaj(); - CommonOps_DDRM.mult(KiMatrix, ksiMatrix, tempMatrix4); - // udotTimesmiMatrix.getMatrix(assSites, assSites, 0, - // totalNumberOfAccociationSites - 1).print(10, 10); - DMatrixRMaj tempMatrix5 = new DMatrixRMaj(); - DMatrixRMaj extractedVector = new DMatrixRMaj(); - DMatrixRMaj extractedVectorTranspose = new DMatrixRMaj(); - CommonOps_DDRM.extractRow(udotTimesmiMatrix, p, extractedVector); - CommonOps_DDRM.transpose(extractedVector, extractedVectorTranspose); - CommonOps_DDRM.changeSign(tempMatrix4); - CommonOps_DDRM.add(extractedVectorTranspose, tempMatrix4, tempMatrix5); - - // tempMki[0] = mki[p]; - // Matrix amatrix = new Matrix(croeneckerProduct(tempMki, - // udotMatrix.getArray())); - // System.out.println("aMatrix "); - // amatrix.transpose().print(10, 10); - // System.out.println("temp4 matrix"); - // tempMatrix4.print(10, 10); - // Matrix tempMatrix5 = amatrix.minus(tempMatrix4); - - DMatrixRMaj tempMatrix6 = new DMatrixRMaj(); - CommonOps_DDRM.mult(hessianInvers, tempMatrix5, tempMatrix6);// .scale(-1.0); - // System.out.println("dXdni"); - // tempMatrix4.print(10, 10); - // tempMatrix5.print(10, 10); - // System.out.println("dXdn "); - // tempMatrix6.print(10, 10); - int temp2 = 0; - for (int compp = 0; compp < numberOfComponents; compp++) { - for (int kk = 0; kk < getComponent(compp).getNumberOfAssociationSites(); kk++) { - ((ComponentCPAInterface) getComponent(compp)).setXsitedni(kk, p, - -1.0 * tempMatrix6.get(temp2 + kk, 0)); - } - temp2 += getComponent(compp).getNumberOfAssociationSites(); - } - // assSites += getComponent(p).getNumberOfAssociationSites(); - } - } + private double[][] delta = null; - /** {@inheritDoc} */ - @Override - public void addcomponent(String componentName, double moles, double molesInPhase, - int compNumber) { - super.addcomponent(componentName, moles, molesInPhase, compNumber); - componentArray[compNumber] = - new ComponentSrkCPA(componentName, moles, molesInPhase, compNumber); - } + private double[][] deltaNog = null; - /** {@inheritDoc} */ - @Override - public double getF() { - return super.getF() + cpaon * FCPA(); - } + private double[][] deltadT = null; - /** {@inheritDoc} */ - @Override - public double dFdT() { - return super.dFdT() + cpaon * dFCPAdT(); - } + private double[][] deltadTdT = null; - /** {@inheritDoc} */ - @Override - public double dFdTdV() { - return super.dFdTdV() + cpaon * dFCPAdTdV(); - } + private double[][][] Klkni = null; + private DMatrixRMaj KlkTVMatrix = null; - /** {@inheritDoc} */ - @Override - public double dFdV() { - double dv2 = dFCPAdV(); - return super.dFdV() + cpaon * dv2; - } + private DMatrixRMaj KlkTTMatrix = null; - // @Override - /** {@inheritDoc} */ - @Override - public double dFdVdV() { - return super.dFdVdV() + cpaon * dFCPAdVdV(); - } + private DMatrixRMaj KlkTMatrix = null; - /** {@inheritDoc} */ - @Override - public double dFdVdVdV() { - return super.dFdVdVdV() + cpaon * dFCPAdVdVdV(); - } + private DMatrixRMaj udotTimesmMatrix = null; - /** {@inheritDoc} */ - @Override - public double dFdTdT() { - return super.dFdTdT() + cpaon * dFCPAdTdT(); - } + private DMatrixRMaj mVector = null; - /** - *

- * FCPA. - *

- * - * @return a double - */ - public double FCPA() { - /* - * double tot = 0.0; double ans = 0.0; for (int i = 0; i < numberOfComponents; i++) { tot = - * 0.0; for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { double xai - * = ((ComponentSrkCPA) getComponent(i)).getXsite()[j]; tot += (Math.log(xai) - 1.0 / 2.0 * - * xai + 1.0 / 2.0); } ans += getComponent(i).getNumberOfMolesInPhase() * tot; } return ans; - */ - return FCPA; - } + private DMatrixRMaj udotMatrix = null; - /** - *

- * dFCPAdV. - *

- * - * @return a double - */ - public double dFCPAdV() { - // return 1.0 / (2.0 * getTotalVolume()) * (1.0 - getTotalVolume() * getGcpav()) - // * hcpatot; - return dFCPAdV; - } + private DMatrixRMaj uMatrix = null; - /** - *

- * dFCPAdVdV. - *

- * - * @return a double - */ - public double dFCPAdVdV() { - // double sum1 = -1.0 / 2.0 * gcpavv * hcpatot; - // return -1.0 / getTotalVolume() * dFCPAdV() + sum1; - return dFCPAdVdV; - } + private DMatrixRMaj QMatksiksiksi = null; - /** - *

- * dFCPAdVdVdV. - *

- * - * @return a double - */ - public double dFCPAdVdVdV() { - return dFCPAdVdVdV; - // return -1.0 / getTotalVolume() * dFCPAdVdV() + 1.0 / - // Math.pow(getTotalVolume(), 2.0) * dFCPAdV() - hcpatot / (2.0 * - // Math.pow(getTotalVolume(), 2.0)) * (-getGcpav() - getTotalVolume() * gcpavv) - // + hcpatot / (2.0 * getTotalVolume()) * (-gcpavv - getTotalVolume() * gcpavvv - // - gcpavv); - } + private DMatrixRMaj KlkVVVMatrix = null; - /** - *

- * dFCPAdT. - *

- * - * @return a double - */ - public double dFCPAdT() { - /* - * double tot = 0.0; double ans = 0.0; for (int i = 0; i < numberOfComponents; i++) { tot = - * 0.0; for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { double xai - * = ((ComponentSrkCPA) getComponent(i)).getXsite()[j]; double xaidT = ((ComponentSrkCPA) - * getComponent(i)).getXsitedT()[j]; tot += 1.0 / xai * xaidT - 0.5 * xaidT;// - 1.0 / 2.0 * - * xai + 1.0 / 2.0); } ans += getComponent(i).getNumberOfMolesInPhase() * tot; } - * System.out.println("dFCPAdT1 " + ans + " dfcpa2 " +dFCPAdT); return ans; - */ - return dFCPAdT; - } + private DMatrixRMaj KlkVVMatrix = null; - /** - *

- * dFCPAdTdT. - *

- * - * @return a double - */ - public double dFCPAdTdT() { - return dFCPAdTdT; - } + private DMatrixRMaj udotTimesmiMatrix = null; - /** - *

- * dFCPAdTdV. - *

- * - * @return a double - */ - public double dFCPAdTdV() { - // System.out.println("dFCPAdTdV1 " + dFCPAdTdV + " dFCPAdTdV " +( 1.0 / (2.0 * - // getTotalVolume()) * (1.0 - getTotalVolume() * getGcpav()) * hcpatotdT)); - return dFCPAdTdV; - /* - * if (totalNumberOfAccociationSites > 0) { return 1.0 / (2.0 * getTotalVolume()) * (1.0 - - * getTotalVolume() * getGcpav()) * hcpatotdT; } else { return 0; } - */ - } + private DMatrixRMaj ksiMatrix = null; - /** - *

- * calc_hCPA. - *

- * - * @return a double - */ - public double calc_hCPA() { - double htot = 0.0; - double tot = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - htot = 0.0; - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - htot += (1.0 - ((ComponentSrkCPA) getComponent(i)).getXsite()[j]); - } - tot += getComponent(i).getNumberOfMolesInPhase() * htot; + private DMatrixRMaj KlkMatrix = null; + + private DMatrixRMaj hessianMatrix = null; + + private DMatrixRMaj hessianInvers = null; + + private DMatrixRMaj KlkVMatrix = null; + + DMatrixRMaj corr2Matrix = null; + + DMatrixRMaj corr3Matrix = null; + + DMatrixRMaj corr4Matrix = null; + + // DenseMatrix64F(getTotalNumberOfAccociationSites(), + // 1); + static Logger logger = LogManager.getLogger(PhaseSrkCPA_proceduralMatrices.class); + + /** + *

+ * Constructor for PhaseSrkCPA_proceduralMatrices. + *

+ */ + public PhaseSrkCPA_proceduralMatrices() { + super(); + } + + /** {@inheritDoc} */ + @Override + public PhaseSrkCPA clone() { + PhaseSrkCPA clonedPhase = null; + try { + clonedPhase = (PhaseSrkCPA) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); + } + // clonedPhase.cpaSelect = (CPAMixing) cpaSelect.clone(); + // clonedPhase.cpamix = (CPAMixingInterface) cpamix.clone(); + // clonedPhase.cpamix = cpaSelect.getMixingRule(1, this); + + return clonedPhase; + } + + /** {@inheritDoc} */ + @Override + public void setMixingRule(int type) { + super.setMixingRule(type); + cpamix = cpaSelect.getMixingRule(1, this); + } + + /** {@inheritDoc} */ + @Override + public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, + double beta) { + if (type == 0) { + setTotalNumberOfAccociationSites(0); + selfAccociationScheme = new int[numberOfComponents][0][0]; + crossAccociationScheme = new int[numberOfComponents][numberOfComponents][0][0]; + for (int i = 0; i < numberOfComponents; i++) { + if (getComponent(i).getNumberOfmoles() < 1e-50) { + getComponent(i).setNumberOfAssociationSites(0); + } else { + getComponent(i) + .setNumberOfAssociationSites(getComponent(i).getOrginalNumberOfAssociationSites()); + setTotalNumberOfAccociationSites( + getTotalNumberOfAccociationSites() + getComponent(i).getNumberOfAssociationSites()); + selfAccociationScheme[i] = cpaSelect.setAssociationScheme(i, this); + for (int j = 0; j < numberOfComponents; j++) { + crossAccociationScheme[i][j] = cpaSelect.setCrossAssociationScheme(i, j, this); + } + } + } + + // had to remove if below - dont understand why.. Even + // if (getTotalNumberOfAccociationSites() != oldTotalNumberOfAccociationSites) { + mVector = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + KlkMatrix = + new DMatrixRMaj(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + KlkVMatrix = + new DMatrixRMaj(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + KlkVVMatrix = + new DMatrixRMaj(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + KlkVVVMatrix = + new DMatrixRMaj(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + hessianMatrix = + new DMatrixRMaj(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + KlkTMatrix = + new DMatrixRMaj(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + KlkTTMatrix = + new DMatrixRMaj(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + KlkTVMatrix = + new DMatrixRMaj(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + corr2Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + corr3Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + corr4Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + Klkni = + new double[numberOfComponents][getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + ksiMatrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + uMatrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + udotMatrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + moleculeNumber = new int[getTotalNumberOfAccociationSites()]; + assSiteNumber = new int[getTotalNumberOfAccociationSites()]; + gvector = new double[getTotalNumberOfAccociationSites()][1]; + udotTimesmMatrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + delta = new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + deltaNog = new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + deltadT = new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + deltadTdT = + new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + QMatksiksiksi = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + // } + udotTimesmiMatrix = + new DMatrixRMaj(getNumberOfComponents(), getTotalNumberOfAccociationSites()); + + oldTotalNumberOfAccociationSites = getTotalNumberOfAccociationSites(); + + int temp = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + moleculeNumber[temp + j] = i; + assSiteNumber[temp + j] = j; } - return tot; + temp += getComponent(i).getNumberOfAssociationSites(); + } } - - /** - *

- * calc_g. - *

- * - * @return a double - */ - public double calc_g() { - double temp = 1.0 - getb() / 4.0 / getMolarVolume(); - double g = (2.0 - getb() / 4.0 / getMolarVolume()) / (2.0 * temp * temp * temp); - return g; + if (cpamix == null) { + cpamix = cpaSelect.getMixingRule(1, this); } - /** - *

- * calc_lngV. - *

- * - * @return a double - */ - public double calc_lngV() { - double gv2 = 0.0; - // gv = -2.0 * getB() * (10.0 * getTotalVolume() - getB()) / getTotalVolume() / - // ((8.0 * getTotalVolume() - getB()) * (4.0 * getTotalVolume() - getB())); - - gv2 = 1.0 / (2.0 - getB() / (4.0 * getTotalVolume())) * getB() - / (4.0 * getTotalVolume() * getTotalVolume()) - - 3.0 / (1.0 - getB() / (4.0 * getTotalVolume())) * getB() - / (4.0 * getTotalVolume() * getTotalVolume()); - return gv2; + super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + if (type > 0 && isConstantPhaseVolume()) { + calcDelta(); + solveX(); + super.init(totalNumberOfMoles, numberOfComponents, 1, phase, beta); + gcpa = calc_g(); + // lngcpa = Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); } - /** - *

- * calc_lngVV. - *

- * - * @return a double - */ - public double calc_lngVV() { - double gvv = 2.0 - * (640.0 * Math.pow(getTotalVolume(), 3.0) - - 216.0 * getB() * getTotalVolume() * getTotalVolume() - + 24.0 * Math.pow(getB(), 2.0) * getTotalVolume() - Math.pow(getB(), 3.0)) - * getB() / (getTotalVolume() * getTotalVolume()) - / Math.pow(8.0 * getTotalVolume() - getB(), 2.0) - / Math.pow(4.0 * getTotalVolume() - getB(), 2.0); - return gvv; + if (type > 0) { + hcpatot = calc_hCPA(); } - /** - *

- * calc_lngVVV. - *

- * - * @return a double - */ - public double calc_lngVVV() { - double gvvv = 4.0 - * (Math.pow(getB(), 5.0) + 17664.0 * Math.pow(getTotalVolume(), 4.0) * getB() - - 4192.0 * Math.pow(getTotalVolume(), 3.0) * Math.pow(getB(), 2.0) - + 528.0 * Math.pow(getB(), 3.0) * getTotalVolume() * getTotalVolume() - - 36.0 * getTotalVolume() * Math.pow(getB(), 4.0) - - 30720.0 * Math.pow(getTotalVolume(), 5.0)) - * getB() / (Math.pow(getTotalVolume(), 3.0)) - / Math.pow(-8.0 * getTotalVolume() + getB(), 3.0) - / Math.pow(-4.0 * getTotalVolume() + getB(), 3.0); - return gvvv; + if (type > 1) { + initCPAMatrix(type); + // hcpatotdT = calc_hCPAdT(); + // super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + } + } + + /** + *

+ * calcDelta. + *

+ */ + public void calcDelta() { + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + deltaNog[i][j] = cpamix.calcDeltaNog(assSiteNumber[i], assSiteNumber[j], moleculeNumber[i], + moleculeNumber[j], this, getTemperature(), getPressure(), numberOfComponents); + deltaNog[j][i] = deltaNog[i][j]; + } + } + } + + /** + *

+ * initCPAMatrix. + *

+ * + * @param type a int + */ + public void initCPAMatrix(int type) { + if (getTotalNumberOfAccociationSites() == 0) { + FCPA = 0.0; + dFCPAdTdV = 0.0; + dFCPAdTdT = 0.0; + dFCPAdT = 0; + dFCPAdV = 0; + dFCPAdVdV = 0.0; + dFCPAdVdVdV = 0.0; + + return; } - /** - *

- * calcXsitedV. - *

- */ - public void calcXsitedV() { - if (getTotalNumberOfAccociationSites() > 0) { - initCPAMatrix(1); + int temp = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + uMatrix.set(temp + j, 0, + Math.log(ksiMatrix.get(temp + j, 0)) - ksiMatrix.get(temp + j, 0) + 1.0); + gvector[temp + j][0] = mVector.get(temp + j, 0) * udotMatrix.get(temp + j, 0); + } + temp += getComponent(i).getNumberOfAssociationSites(); + } + for (int i = 0; i < getNumberOfComponents(); i++) { + for (int j = 0; j < getTotalNumberOfAccociationSites(); j++) { + if (moleculeNumber[j] == i) { + udotTimesmiMatrix.set(i, j, udotMatrix.get(j, 0)); + } else { + udotTimesmiMatrix.set(i, j, 0.0); } + } } - /** - *

- * solveX. - *

- * - * @return a boolean - */ - public boolean solveX() { - if (getTotalNumberOfAccociationSites() == 0) { - return true; + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + delta[i][j] = deltaNog[i][j] * getGcpa(); + delta[j][i] = delta[i][j]; + if (type > 1) { + deltadT[i][j] = cpamix.calcDeltadT(assSiteNumber[i], assSiteNumber[j], moleculeNumber[i], + moleculeNumber[j], this, getTemperature(), getPressure(), numberOfComponents); + deltadT[j][i] = deltadT[i][j]; + + deltadTdT[i][j] = + cpamix.calcDeltadTdT(assSiteNumber[i], assSiteNumber[j], moleculeNumber[i], + moleculeNumber[j], this, getTemperature(), getPressure(), numberOfComponents); + deltadTdT[j][i] = deltadTdT[i][j]; } + } + } - boolean solvedX = solveX2(5); - if (solvedX) { - // return true; - } + double gdv1 = getGcpav() - 1.0 / getTotalVolume(); + double gdv2 = gdv1 * gdv1; + double gdv3 = gdv2 * gdv1; + double totVol = getTotalVolume(); + // double Klk = 0.0; + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + KlkVMatrix.set(i, j, KlkMatrix.get(i, j) * gdv1); + KlkVMatrix.set(j, i, KlkVMatrix.get(i, j)); + + KlkVVMatrix.set(i, j, KlkMatrix.get(i, j) * gdv2 + + KlkMatrix.get(i, j) * (gcpavv + 1.0 / getTotalVolume() / getTotalVolume())); + KlkVVMatrix.set(j, i, KlkVVMatrix.get(i, j)); + + KlkVVVMatrix.set(i, j, + KlkMatrix.get(i, j) * gdv3 + + 3.0 * KlkMatrix.get(i, j) * (getGcpav() - 1.0 / getTotalVolume()) + * (gcpavv + 1.0 / (totVol * totVol)) + + KlkMatrix.get(i, j) * (gcpavvv - 2.0 / (totVol * totVol * totVol))); + KlkVVVMatrix.set(j, i, KlkVVVMatrix.get(i, j)); - DMatrixRMaj mat1 = KlkMatrix; - DMatrixRMaj mat2 = ksiMatrix; - // second order method not working correctly and not used t the moment b ecause of numerical - // stability - int temp = 0, iter = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - mVector.set(temp + j, 0, getComponent(i).getNumberOfMolesInPhase()); - } - temp += getComponent(i).getNumberOfAssociationSites(); - } - double Klk = 0.0; - double totvolume = getTotalVolume(); - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - Klk = mVector.get(i, 0) * mVector.get(j, 0) / totvolume * delta[i][j]; - KlkMatrix.set(i, j, Klk); - KlkMatrix.set(j, i, Klk); + if (type > 1) { + double tempVar = deltadT[i][j] / delta[i][j]; + double tempVardT = deltadTdT[i][j] / delta[i][j] + - (deltadT[i][j] * deltadT[i][j]) / (delta[i][j] * delta[i][j]); + + if (!Double.isNaN(tempVar)) { + // KlkdT[i][j] = KlkMatrix.getMatrix().unsafe_get(i, j) * tempVar; + // KlkdT[j][i] = KlkdT[i][j]; + + KlkTMatrix.set(i, j, KlkMatrix.get(i, j) * tempVar); + KlkTMatrix.set(j, i, KlkTMatrix.get(i, j)); + + KlkTVMatrix.set(i, j, KlkMatrix.get(i, j) * tempVar * (gcpav - 1.0 / getTotalVolume())); + KlkTVMatrix.set(j, i, KlkTVMatrix.get(i, j)); + + KlkTTMatrix.set(i, j, KlkMatrix.get(i, j) * (tempVar * tempVar + tempVardT)); + KlkTTMatrix.set(j, i, KlkTTMatrix.get(i, j)); + } + + if (type > 2) { + for (int p = 0; p < numberOfComponents; p++) { + double t1 = 0.0; + double t2 = 0.0; + if (moleculeNumber[i] == p) { + t1 = 1.0 / mVector.get(i, 0); + } + if (moleculeNumber[j] == p) { + t2 = 1.0 / mVector.get(j, 0); + } + Klkni[p][i][j] = KlkMatrix.get(i, j) + * (t1 + t2 + ((ComponentSrkCPA) getComponent(p)).calc_lngi(this)); + Klkni[p][j][i] = Klkni[p][i][j]; } + } } - boolean solved = true; - // SimpleMatrix corrMatrix = null; - do { - solved = true; - iter++; - temp = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - ksiMatrix.set(temp + j, 0, ((ComponentSrkCPA) getComponent(i)).getXsite()[j]); - // ksiMatrix.getMatrix().unsafe_set(temp + j, 0, - // ksiMatrix.getMatrix().unsafe_get(temp + j, 0)); - udotMatrix.set(temp + j, 0, 1.0 / ksiMatrix.get(temp + j, 0) - 1.0); - udotTimesmMatrix.set(temp + j, 0, - mVector.get(temp + j, 0) * udotMatrix.get(temp + j, 0)); - } - temp += getComponent(i).getNumberOfAssociationSites(); - } - - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - int krondelt = 0; - if (i == j) { - krondelt = 1; - } - hessianMatrix.set(i, j, - -mVector.get(i, 0) / (ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0)) - * krondelt - KlkMatrix.get(i, j)); - hessianMatrix.set(j, i, hessianMatrix.get(i, j)); - } - } - - // ksiMatrix = new SimpleMatrix(ksi); - // SimpleMatrix hessianMatrix = new SimpleMatrix(hessian); - try { - CommonOps_DDRM.invert(hessianMatrix, hessianInvers); - } catch (Exception e) { - logger.error("error", e); - return false; - } + } + QMatksiksiksi.set(i, 0, 2.0 * mVector.get(i, 0) + / (ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0))); + } - CommonOps_DDRM.mult(mat1, mat2, corr2Matrix); - CommonOps_DDRM.subtract(udotTimesmMatrix, corr2Matrix, corr3Matrix); - CommonOps_DDRM.mult(hessianInvers, corr3Matrix, corr4Matrix); - // SimpleMatrix gMatrix = udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)); - // corrMatrix = - // hessianInvers.mult(udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)));//.scale(-1.0); - temp = 0; - // System.out.println("print SimpleMatrix ..."); - // corrMatrix.print(10, 10); - // SimpleMatrix simp = new SimpleMatrix(corr4Matrix); - // System.out.println("print CommonOps ..."); - // simp.print(10,10); - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { - double newX = - ksiMatrix.get(temp + j, 0) - corr4Matrix.unsafe_get((temp + j), 0); - if (newX < 0) { - newX = 1e-10; - solved = false; - } - ((ComponentCPAInterface) getComponent(i)).setXsite(j, newX); - } - temp += getComponent(i).getNumberOfAssociationSites(); - } - // System.out.println("corrmatrix error " ); - // System.out.println("error " + corrMatrix.norm1()); - } while ((NormOps_DDRM.normF(corr4Matrix) > 1e-12 || !solved) && iter < 100); - - // System.out.println("iter " + iter + " error " + NormOps.normF(corr4Matrix)); - // // corrMatrix.print(10, 10); - // ksiMatrix.print(10, 10); - return true; + DMatrixRMaj ksiMatrixTranspose = new DMatrixRMaj(); + CommonOps_DDRM.transpose(ksiMatrix, ksiMatrixTranspose); + + // dXdV + DMatrixRMaj KlkVMatrixksi = new DMatrixRMaj(); + CommonOps_DDRM.mult(KlkVMatrix, ksiMatrix, KlkVMatrixksi); + + DMatrixRMaj XV = new DMatrixRMaj(); + DMatrixRMaj XVtranspose = new DMatrixRMaj(); + CommonOps_DDRM.mult(hessianInvers, KlkVMatrixksi, XV); + CommonOps_DDRM.transpose(XV, XVtranspose); + + DMatrixRMaj QCPA = new DMatrixRMaj(); + DMatrixRMaj mVectorTranspose = new DMatrixRMaj(); + DMatrixRMaj ksiMatrixudotMatrix = new DMatrixRMaj(); + DMatrixRMaj ksiMatrixudotMatrixScaled = new DMatrixRMaj(); + DMatrixRMaj uMatrixMinusksiMatrixudotMatrixScaled = new DMatrixRMaj(); + DMatrixRMaj ksiMatrixudotMatrixScaledNegative = new DMatrixRMaj(); + CommonOps_DDRM.transpose(mVector, mVectorTranspose); + CommonOps_DDRM.elementMult(ksiMatrix, udotMatrix, ksiMatrixudotMatrix); + CommonOps_DDRM.scale(0.5, ksiMatrixudotMatrix, ksiMatrixudotMatrixScaled); + CommonOps_DDRM.scale(-1.0, ksiMatrixudotMatrixScaled, ksiMatrixudotMatrixScaledNegative); + CommonOps_DDRM.add(uMatrix, ksiMatrixudotMatrixScaledNegative, + uMatrixMinusksiMatrixudotMatrixScaled); + CommonOps_DDRM.mult(mVectorTranspose, uMatrixMinusksiMatrixudotMatrixScaled, QCPA); + FCPA = QCPA.get(0, 0); + + DMatrixRMaj tempMatrix = new DMatrixRMaj(); + CommonOps_DDRM.mult(ksiMatrixTranspose, KlkVMatrixksi, tempMatrix); + CommonOps_DDRM.scale(-0.5, tempMatrix); + dFCPAdV = tempMatrix.get(0, 0); + + DMatrixRMaj KlkVVMatrixTimesKsi = new DMatrixRMaj(); + DMatrixRMaj KlkVMatrixksiTranspose = new DMatrixRMaj(); + DMatrixRMaj KlkVMatrixksiXV = new DMatrixRMaj(); + DMatrixRMaj ksiKlkVVksi = new DMatrixRMaj(); + DMatrixRMaj tempMatrixVV = new DMatrixRMaj(); + CommonOps_DDRM.mult(KlkVVMatrix, ksiMatrix, KlkVVMatrixTimesKsi); + CommonOps_DDRM.transpose(KlkVMatrixksi, KlkVMatrixksiTranspose); + CommonOps_DDRM.mult(KlkVMatrixksiTranspose, XV, KlkVMatrixksiXV); + CommonOps_DDRM.mult(ksiMatrixTranspose, KlkVVMatrixTimesKsi, ksiKlkVVksi); + CommonOps_DDRM.scale(-0.5, ksiKlkVVksi); + CommonOps_DDRM.scale(-1.0, KlkVMatrixksiXV); + CommonOps_DDRM.add(ksiKlkVVksi, KlkVMatrixksiXV, tempMatrixVV); + dFCPAdVdV = tempMatrixVV.get(0, 0); + + DMatrixRMaj QVVV = new DMatrixRMaj(); + DMatrixRMaj QVVksi = new DMatrixRMaj(); + DMatrixRMaj QksiVksi = new DMatrixRMaj(); + DMatrixRMaj KlkVVVMatrixksi = new DMatrixRMaj(); + CommonOps_DDRM.mult(KlkVVVMatrix, ksiMatrix, KlkVVVMatrixksi); + CommonOps_DDRM.mult(ksiMatrixTranspose, KlkVVVMatrixksi, QVVV); + CommonOps_DDRM.scale(-0.5, QVVV); + CommonOps_DDRM.scale(-1.0, KlkVVMatrixTimesKsi, QVVksi); + CommonOps_DDRM.scale(-1.0, KlkVMatrix, QksiVksi); + + DMatrixRMaj mat1 = new DMatrixRMaj(); + DMatrixRMaj mat2 = new DMatrixRMaj(); + DMatrixRMaj mat4 = new DMatrixRMaj(); + DMatrixRMaj QVVksiTranspose = new DMatrixRMaj(); + DMatrixRMaj QksiVksiXV = new DMatrixRMaj(); + DMatrixRMaj XVtransposeQMatksiksiksiXVtranspose = new DMatrixRMaj(); + DMatrixRMaj QMatksiksiksiXVtranspose = new DMatrixRMaj(); + + CommonOps_DDRM.transpose(QVVksi, QVVksiTranspose); + CommonOps_DDRM.mult(QVVksiTranspose, XV, mat1); + CommonOps_DDRM.scale(3.0, mat1); + CommonOps_DDRM.mult(QksiVksi, XV, QksiVksiXV); + CommonOps_DDRM.mult(XVtranspose, QksiVksiXV, mat2); + CommonOps_DDRM.scale(3.0, mat2); + CommonOps_DDRM.mult(QMatksiksiksi, XVtranspose, QMatksiksiksiXVtranspose); + CommonOps_DDRM.mult(XVtranspose, QMatksiksiksiXVtranspose, XVtransposeQMatksiksiksiXVtranspose); + CommonOps_DDRM.mult(XVtransposeQMatksiksiksiXVtranspose, XV, mat4); + + DMatrixRMaj dFCPAdVdVdVMatrix = new DMatrixRMaj(); + dFCPAdVdVdVMatrix.setTo(QVVV); + CommonOps_DDRM.addEquals(dFCPAdVdVdVMatrix, mat1); + CommonOps_DDRM.addEquals(dFCPAdVdVdVMatrix, mat2); + CommonOps_DDRM.addEquals(dFCPAdVdVdVMatrix, mat2); + CommonOps_DDRM.addEquals(dFCPAdVdVdVMatrix, mat4); + dFCPAdVdVdV = dFCPAdVdVdVMatrix.get(0, 0); + temp = 0; + + if (type == 1) { + return; + } + for (int p = 0; p < numberOfComponents; p++) { + for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { + ((ComponentCPAInterface) getComponent(p)).setXsitedV(kk, XV.get(temp + kk, 0)); + } + temp += getComponent(p).getNumberOfAssociationSites(); } - /** - *

- * solveX2. - *

- * - * @param maxIter a int - * @return a boolean - */ - public boolean solveX2(int maxIter) { - double err = .0; - int iter = 0; - // if (delta == null) { - // initCPAMatrix(1); - double old = 0.0, neeval = 0.0; - // } - do { - iter++; - err = 0.0; - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - old = ((ComponentSrkCPA) getComponent(moleculeNumber[i])) - .getXsite()[assSiteNumber[i]]; - neeval = 0; - for (int j = 0; j < getTotalNumberOfAccociationSites(); j++) { - neeval += getComponent(moleculeNumber[j]).getNumberOfMolesInPhase() - * delta[i][j] * ((ComponentSrkCPA) getComponent(moleculeNumber[j])) - .getXsite()[assSiteNumber[j]]; - } - neeval = 1.0 / (1.0 + 1.0 / getTotalVolume() * neeval); - ((ComponentCPAInterface) getComponent(moleculeNumber[i])).setXsite(assSiteNumber[i], - neeval); - err += Math.abs((old - neeval) / neeval); - } - } while (Math.abs(err) > 1e-10 && iter < maxIter); - // System.out.println("iter " + iter); - // if (Math.abs(err) - // < 1e-12) { - // return true; - // } else { - // System.out.println("did not solve for Xi in iterations: " + iter); - // System.out.println("error: " + err); - return false; + // KlkTMatrix = new SimpleMatrix(KlkdT); + DMatrixRMaj KlkTMatrixTimesKsi = new DMatrixRMaj(); + CommonOps_DDRM.mult(KlkTMatrix, ksiMatrix, KlkTMatrixTimesKsi); + + // dQdT + DMatrixRMaj tempMatrix2 = new DMatrixRMaj(); + CommonOps_DDRM.mult(ksiMatrixTranspose, KlkTMatrixTimesKsi, tempMatrix2); + CommonOps_DDRM.scale(-0.5, tempMatrix2); + dFCPAdT = tempMatrix2.get(0, 0); + + // SimpleMatrix KlkTVMatrix = new SimpleMatrix(KlkdTdV); + // SimpleMatrix tempMatrixTV = + // ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5).minus(KlkTMatrixTImesKsi.transpose().mult(XV)); + // dFCPAdTdV = tempMatrixTV.get(0, 0); + // dXdT + DMatrixRMaj XT = new DMatrixRMaj(); + CommonOps_DDRM.mult(hessianInvers, KlkTMatrixTimesKsi, XT); + + // dQdTdT + DMatrixRMaj tempMatrixTT = new DMatrixRMaj(); + DMatrixRMaj KlkTMatrixTimesKsiTranspose = new DMatrixRMaj(); + DMatrixRMaj KlkTMatrixTimesKsiTransposeXT = new DMatrixRMaj(); + DMatrixRMaj KlkTTMatrixksi = new DMatrixRMaj(); + DMatrixRMaj ksiMatrixTransposeKlkTTMatrixksi = new DMatrixRMaj(); + CommonOps_DDRM.transpose(KlkTMatrixTimesKsi, KlkTMatrixTimesKsiTranspose); + CommonOps_DDRM.mult(KlkTMatrixTimesKsiTranspose, XT, KlkTMatrixTimesKsiTransposeXT); + CommonOps_DDRM.mult(KlkTTMatrix, ksiMatrix, KlkTTMatrixksi); + CommonOps_DDRM.mult(ksiMatrixTranspose, KlkTTMatrixksi, ksiMatrixTransposeKlkTTMatrixksi); + CommonOps_DDRM.scale(-0.5, ksiMatrixTransposeKlkTTMatrixksi); + CommonOps_DDRM.scale(-1.0, KlkTMatrixTimesKsiTransposeXT); + CommonOps_DDRM.add(ksiMatrixTransposeKlkTTMatrixksi, KlkTMatrixTimesKsiTransposeXT, + tempMatrixTT); + // SimpleMatrix tempMatrixTT = + // ksiMatrixTranspose.mult(KlkTTMatrix.mult(ksiMatrix)).scale(-0.5).minus(KlkTMatrixTImesKsi.transpose().mult(XT)); + dFCPAdTdT = tempMatrixTT.get(0, 0); + + DMatrixRMaj tempMatrixTV = new DMatrixRMaj(); + DMatrixRMaj KlkTMatrixTimesKsiTransposeXV = new DMatrixRMaj(); + DMatrixRMaj KlkTVMatrixksi = new DMatrixRMaj(); + DMatrixRMaj ksiMatrixTransposeKlkTVMatrixksi = new DMatrixRMaj(); + CommonOps_DDRM.transpose(KlkTMatrixTimesKsi, KlkTMatrixTimesKsiTranspose); + CommonOps_DDRM.mult(KlkTMatrixTimesKsiTranspose, XV, KlkTMatrixTimesKsiTransposeXV); + CommonOps_DDRM.mult(KlkTVMatrix, ksiMatrix, KlkTVMatrixksi); + CommonOps_DDRM.mult(ksiMatrixTranspose, KlkTVMatrixksi, ksiMatrixTransposeKlkTTMatrixksi); + CommonOps_DDRM.scale(-0.5, ksiMatrixTransposeKlkTVMatrixksi); + CommonOps_DDRM.scale(-1.0, KlkTMatrixTimesKsiTransposeXV); + CommonOps_DDRM.add(ksiMatrixTransposeKlkTVMatrixksi, KlkTMatrixTimesKsiTransposeXV, + tempMatrixTV); + // SimpleMatrix tempMatrixTV = + // ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5).minus(KlkTMatrixTImesKsi.transpose().mult(XV)); + dFCPAdTdV = tempMatrixTV.get(0, 0); + + temp = 0; + for (int p = 0; p < numberOfComponents; p++) { + for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { + ((ComponentCPAInterface) getComponent(p)).setXsitedT(kk, XT.get(temp + kk, 0)); + } + temp += getComponent(p).getNumberOfAssociationSites(); } - /** {@inheritDoc} */ - @Override - public double getHcpatot() { - return hcpatot; + if (type == 2) { + return; } - /** - * Setter for property hcpatot. - * - * @param hcpatot New value of property hcpatot. + // int assSites = 0; + // if(true) return; + for (int p = 0; p < numberOfComponents; p++) { + DMatrixRMaj KiMatrix = new DMatrixRMaj(Klkni[p]); + // KiMatrix.print(10,10); + // Matrix dQdniMatrix = + // (ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5)); // this + // methods misses one part of .... + // dQdniMatrix.print(10,10); + // KiMatrix.print(10, 10); + // miMatrix.getMatrix(assSites, assSites, 0, totalNumberOfAccociationSites - + // 1).print(10, 10); + // Matrix tempMatrix20 = miMatrix.getMatrix(assSites, assSites, 0, + // totalNumberOfAccociationSites - + // 1).times(uMatrix).minus(ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5)); + // // + // ksiMatrix.transpose().times(KlkTMatrix.times(ksiMatrix)).times(-0.5); + // System.out.println("dQdn "); + // tempMatrix20.print(10, 10); + DMatrixRMaj tempMatrix4 = new DMatrixRMaj(); + CommonOps_DDRM.mult(KiMatrix, ksiMatrix, tempMatrix4); + // udotTimesmiMatrix.getMatrix(assSites, assSites, 0, + // totalNumberOfAccociationSites - 1).print(10, 10); + DMatrixRMaj tempMatrix5 = new DMatrixRMaj(); + DMatrixRMaj extractedVector = new DMatrixRMaj(); + DMatrixRMaj extractedVectorTranspose = new DMatrixRMaj(); + CommonOps_DDRM.extractRow(udotTimesmiMatrix, p, extractedVector); + CommonOps_DDRM.transpose(extractedVector, extractedVectorTranspose); + CommonOps_DDRM.changeSign(tempMatrix4); + CommonOps_DDRM.add(extractedVectorTranspose, tempMatrix4, tempMatrix5); + + // tempMki[0] = mki[p]; + // Matrix amatrix = new Matrix(croeneckerProduct(tempMki, + // udotMatrix.getArray())); + // System.out.println("aMatrix "); + // amatrix.transpose().print(10, 10); + // System.out.println("temp4 matrix"); + // tempMatrix4.print(10, 10); + // Matrix tempMatrix5 = amatrix.minus(tempMatrix4); + + DMatrixRMaj tempMatrix6 = new DMatrixRMaj(); + CommonOps_DDRM.mult(hessianInvers, tempMatrix5, tempMatrix6); // .scale(-1.0); + // System.out.println("dXdni"); + // tempMatrix4.print(10, 10); + // tempMatrix5.print(10, 10); + // System.out.println("dXdn "); + // tempMatrix6.print(10, 10); + int temp2 = 0; + for (int compp = 0; compp < numberOfComponents; compp++) { + for (int kk = 0; kk < getComponent(compp).getNumberOfAssociationSites(); kk++) { + ((ComponentCPAInterface) getComponent(compp)).setXsitedni(kk, p, + -1.0 * tempMatrix6.get(temp2 + kk, 0)); + } + temp2 += getComponent(compp).getNumberOfAssociationSites(); + } + // assSites += getComponent(p).getNumberOfAssociationSites(); + } + } + + /** {@inheritDoc} */ + @Override + public void addcomponent(String componentName, double moles, double molesInPhase, + int compNumber) { + super.addcomponent(componentName, moles, molesInPhase, compNumber); + componentArray[compNumber] = + new ComponentSrkCPA(componentName, moles, molesInPhase, compNumber); + } + + /** {@inheritDoc} */ + @Override + public double getF() { + return super.getF() + cpaon * FCPA(); + } + + /** {@inheritDoc} */ + @Override + public double dFdT() { + return super.dFdT() + cpaon * dFCPAdT(); + } + + /** {@inheritDoc} */ + @Override + public double dFdTdV() { + return super.dFdTdV() + cpaon * dFCPAdTdV(); + } + + /** {@inheritDoc} */ + @Override + public double dFdV() { + double dv2 = dFCPAdV(); + return super.dFdV() + cpaon * dv2; + } + + // @Override + /** {@inheritDoc} */ + @Override + public double dFdVdV() { + return super.dFdVdV() + cpaon * dFCPAdVdV(); + } + + /** {@inheritDoc} */ + @Override + public double dFdVdVdV() { + return super.dFdVdVdV() + cpaon * dFCPAdVdVdV(); + } + + /** {@inheritDoc} */ + @Override + public double dFdTdT() { + return super.dFdTdT() + cpaon * dFCPAdTdT(); + } + + /** + *

+ * FCPA. + *

+ * + * @return a double + */ + public double FCPA() { + /* + * double tot = 0.0; double ans = 0.0; for (int i = 0; i < numberOfComponents; i++) { tot = 0.0; + * for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { double xai = + * ((ComponentSrkCPA) getComponent(i)).getXsite()[j]; tot += (Math.log(xai) - 1.0 / 2.0 * xai + + * 1.0 / 2.0); } ans += getComponent(i).getNumberOfMolesInPhase() * tot; } return ans; */ - public void setHcpatot(double hcpatot) { - this.hcpatot = hcpatot; + return FCPA; + } + + /** + *

+ * dFCPAdV. + *

+ * + * @return a double + */ + public double dFCPAdV() { + // return 1.0 / (2.0 * getTotalVolume()) * (1.0 - getTotalVolume() * getGcpav()) + // * hcpatot; + return dFCPAdV; + } + + /** + *

+ * dFCPAdVdV. + *

+ * + * @return a double + */ + public double dFCPAdVdV() { + // double sum1 = -1.0 / 2.0 * gcpavv * hcpatot; + // return -1.0 / getTotalVolume() * dFCPAdV() + sum1; + return dFCPAdVdV; + } + + /** + *

+ * dFCPAdVdVdV. + *

+ * + * @return a double + */ + public double dFCPAdVdVdV() { + return dFCPAdVdVdV; + // return -1.0 / getTotalVolume() * dFCPAdVdV() + 1.0 / + // Math.pow(getTotalVolume(), 2.0) * dFCPAdV() - hcpatot / (2.0 * + // Math.pow(getTotalVolume(), 2.0)) * (-getGcpav() - getTotalVolume() * gcpavv) + // + hcpatot / (2.0 * getTotalVolume()) * (-gcpavv - getTotalVolume() * gcpavvv + // - gcpavv); + } + + /** + *

+ * dFCPAdT. + *

+ * + * @return a double + */ + public double dFCPAdT() { + /* + * double tot = 0.0; double ans = 0.0; for (int i = 0; i < numberOfComponents; i++) { tot = 0.0; + * for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { double xai = + * ((ComponentSrkCPA) getComponent(i)).getXsite()[j]; double xaidT = ((ComponentSrkCPA) + * getComponent(i)).getXsitedT()[j]; tot += 1.0 / xai * xaidT - 0.5 * xaidT; // - 1.0 / 2.0 * + * xai + 1.0 / 2.0); } ans += getComponent(i).getNumberOfMolesInPhase() * tot; } + * System.out.println("dFCPAdT1 " + ans + " dfcpa2 " +dFCPAdT); return ans; + */ + return dFCPAdT; + } + + /** + *

+ * dFCPAdTdT. + *

+ * + * @return a double + */ + public double dFCPAdTdT() { + return dFCPAdTdT; + } + + /** + *

+ * dFCPAdTdV. + *

+ * + * @return a double + */ + public double dFCPAdTdV() { + // System.out.println("dFCPAdTdV1 " + dFCPAdTdV + " dFCPAdTdV " +( 1.0 / (2.0 * + // getTotalVolume()) * (1.0 - getTotalVolume() * getGcpav()) * hcpatotdT)); + return dFCPAdTdV; + /* + * if (totalNumberOfAccociationSites > 0) { return 1.0 / (2.0 * getTotalVolume()) * (1.0 - + * getTotalVolume() * getGcpav()) * hcpatotdT; } else { return 0; } + */ + } + + /** + *

+ * calc_hCPA. + *

+ * + * @return a double + */ + public double calc_hCPA() { + double htot = 0.0; + double tot = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + htot = 0.0; + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + htot += (1.0 - ((ComponentSrkCPA) getComponent(i)).getXsite()[j]); + } + tot += getComponent(i).getNumberOfMolesInPhase() * htot; + } + return tot; + } + + /** + *

+ * calc_g. + *

+ * + * @return a double + */ + public double calc_g() { + double temp = 1.0 - getb() / 4.0 / getMolarVolume(); + double g = (2.0 - getb() / 4.0 / getMolarVolume()) / (2.0 * temp * temp * temp); + return g; + } + + /** + *

+ * calc_lngV. + *

+ * + * @return a double + */ + public double calc_lngV() { + double gv2 = 0.0; + // gv = -2.0 * getB() * (10.0 * getTotalVolume() - getB()) / getTotalVolume() / + // ((8.0 * getTotalVolume() - getB()) * (4.0 * getTotalVolume() - getB())); + + gv2 = 1.0 / (2.0 - getB() / (4.0 * getTotalVolume())) * getB() + / (4.0 * getTotalVolume() * getTotalVolume()) + - 3.0 / (1.0 - getB() / (4.0 * getTotalVolume())) * getB() + / (4.0 * getTotalVolume() * getTotalVolume()); + return gv2; + } + + /** + *

+ * calc_lngVV. + *

+ * + * @return a double + */ + public double calc_lngVV() { + double gvv = 2.0 + * (640.0 * Math.pow(getTotalVolume(), 3.0) + - 216.0 * getB() * getTotalVolume() * getTotalVolume() + + 24.0 * Math.pow(getB(), 2.0) * getTotalVolume() - Math.pow(getB(), 3.0)) + * getB() / (getTotalVolume() * getTotalVolume()) + / Math.pow(8.0 * getTotalVolume() - getB(), 2.0) + / Math.pow(4.0 * getTotalVolume() - getB(), 2.0); + return gvv; + } + + /** + *

+ * calc_lngVVV. + *

+ * + * @return a double + */ + public double calc_lngVVV() { + double gvvv = 4.0 + * (Math.pow(getB(), 5.0) + 17664.0 * Math.pow(getTotalVolume(), 4.0) * getB() + - 4192.0 * Math.pow(getTotalVolume(), 3.0) * Math.pow(getB(), 2.0) + + 528.0 * Math.pow(getB(), 3.0) * getTotalVolume() * getTotalVolume() + - 36.0 * getTotalVolume() * Math.pow(getB(), 4.0) + - 30720.0 * Math.pow(getTotalVolume(), 5.0)) + * getB() / (Math.pow(getTotalVolume(), 3.0)) + / Math.pow(-8.0 * getTotalVolume() + getB(), 3.0) + / Math.pow(-4.0 * getTotalVolume() + getB(), 3.0); + return gvvv; + } + + /** + *

+ * calcXsitedV. + *

+ */ + public void calcXsitedV() { + if (getTotalNumberOfAccociationSites() > 0) { + initCPAMatrix(1); + } + } + + /** + *

+ * solveX. + *

+ * + * @return a boolean + */ + public boolean solveX() { + if (getTotalNumberOfAccociationSites() == 0) { + return true; } - /** {@inheritDoc} */ - @Override - public double getGcpa() { - return gcpa; + boolean solvedX = solveX2(5); + if (solvedX) { + // return true; } - /** - *

- * calcRootVolFinder. - *

- * - * @param phase a int - * @return a double - */ - public double calcRootVolFinder(int phase) { - double solvedBonVHigh = 0.0; - double solvedBonVlow = 1.0; - double oldh = 1; - // double[][] matrix = new double[2][2000]; - double BonV = 1.0 - 1e-10; - try { - // molarVolume(pressure, temperature, A, B, phaseType); - } catch (Exception e) { - logger.error("error", e); + DMatrixRMaj mat1 = KlkMatrix; + DMatrixRMaj mat2 = ksiMatrix; + // second order method not working correctly and not used t the moment b ecause of numerical + // stability + int temp = 0; + int iter = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + mVector.set(temp + j, 0, getComponent(i).getNumberOfMolesInPhase()); + } + temp += getComponent(i).getNumberOfAssociationSites(); + } + double Klk = 0.0; + double totvolume = getTotalVolume(); + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + Klk = mVector.get(i, 0) * mVector.get(j, 0) / totvolume * delta[i][j]; + KlkMatrix.set(i, j, Klk); + KlkMatrix.set(j, i, Klk); + } + } + boolean solved = true; + // SimpleMatrix corrMatrix = null; + do { + solved = true; + iter++; + temp = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + ksiMatrix.set(temp + j, 0, ((ComponentSrkCPA) getComponent(i)).getXsite()[j]); + // ksiMatrix.getMatrix().unsafe_set(temp + j, 0, + // ksiMatrix.getMatrix().unsafe_get(temp + j, 0)); + udotMatrix.set(temp + j, 0, 1.0 / ksiMatrix.get(temp + j, 0) - 1.0); + udotTimesmMatrix.set(temp + j, 0, mVector.get(temp + j, 0) * udotMatrix.get(temp + j, 0)); } - double BonVold = BonV; - double Btemp = 0, h = 1; - // double Dtemp = 0, dh = 0, gvvv = 0, fvvv = 0, dhh = 0; - // double d1 = 0, d2 = 0; - Btemp = getB(); - // Dtemp = getA(); - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - for (int i = 0; i < 2000; i++) { - BonVold = BonV; - BonV = 1.0 - (i + 1e-6) * 1.0 / 2000.0; - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - gcpa = calc_g(); - // lngcpa = - // Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - - do { - } while (!solveX()); - - h = BonV - Btemp / numberOfMolesInPhase * dFdV() - - pressure * Btemp / (numberOfMolesInPhase * R * temperature); - - if (Math.signum(h) * Math.signum(oldh) < 0 && i > 2) { - if (solvedBonVlow < 1e-3) { - solvedBonVlow = (BonV + BonVold) / 2.0; - if (phase == 1) { - break; - } - } else { - solvedBonVHigh = (BonV + BonVold) / 2.0; - if (phase == 0) { - break; - } - } - } - solvedBonVHigh = (BonV + BonVold) / 2.0; - oldh = h; - // matrix[0][i] = BonV; - // matrix[1][i] = h; + temp += getComponent(i).getNumberOfAssociationSites(); + } + + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + int krondelt = 0; + if (i == j) { + krondelt = 1; + } + hessianMatrix.set(i, j, + -mVector.get(i, 0) / (ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0)) * krondelt + - KlkMatrix.get(i, j)); + hessianMatrix.set(j, i, hessianMatrix.get(i, j)); } - if (solvedBonVlow < 1e-3) { - solvedBonVlow = solvedBonVHigh; + } + + // ksiMatrix = new SimpleMatrix(ksi); + // SimpleMatrix hessianMatrix = new SimpleMatrix(hessian); + try { + CommonOps_DDRM.invert(hessianMatrix, hessianInvers); + } catch (Exception e) { + logger.error("error", e); + return false; + } + + CommonOps_DDRM.mult(mat1, mat2, corr2Matrix); + CommonOps_DDRM.subtract(udotTimesmMatrix, corr2Matrix, corr3Matrix); + CommonOps_DDRM.mult(hessianInvers, corr3Matrix, corr4Matrix); + // SimpleMatrix gMatrix = udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)); + // corrMatrix = + // hessianInvers.mult(udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix))); + // //.scale(-1.0); + temp = 0; + // System.out.println("print SimpleMatrix ..."); + // corrMatrix.print(10, 10); + // SimpleMatrix simp = new SimpleMatrix(corr4Matrix); + // System.out.println("print CommonOps ..."); + // simp.print(10,10); + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { + double newX = ksiMatrix.get(temp + j, 0) - corr4Matrix.unsafe_get((temp + j), 0); + if (newX < 0) { + newX = 1e-10; + solved = false; + } + ((ComponentCPAInterface) getComponent(i)).setXsite(j, newX); } - // dataPresentation.fileHandeling.createTextFile.TextFile file = new - // dataPresentation.fileHandeling.createTextFile.TextFile(); - // file.setValues(matrix); - // file.setOutputFileName("D:/temp/temp2.txt"); - // file.createFile(); - if (phase == 1) { - return solvedBonVlow; - } else { - return solvedBonVHigh; + temp += getComponent(i).getNumberOfAssociationSites(); + } + // System.out.println("corrmatrix error " ); + // System.out.println("error " + corrMatrix.norm1()); + } while ((NormOps_DDRM.normF(corr4Matrix) > 1e-12 || !solved) && iter < 100); + + // System.out.println("iter " + iter + " error " + NormOps.normF(corr4Matrix)); + // // corrMatrix.print(10, 10); + // ksiMatrix.print(10, 10); + return true; + } + + /** + *

+ * solveX2. + *

+ * + * @param maxIter a int + * @return a boolean + */ + public boolean solveX2(int maxIter) { + double err = .0; + int iter = 0; + // if (delta == null) { + // initCPAMatrix(1); + double old = 0.0; + double neeval = 0.0; + // } + do { + iter++; + err = 0.0; + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + old = ((ComponentSrkCPA) getComponent(moleculeNumber[i])).getXsite()[assSiteNumber[i]]; + neeval = 0; + for (int j = 0; j < getTotalNumberOfAccociationSites(); j++) { + neeval += getComponent(moleculeNumber[j]).getNumberOfMolesInPhase() * delta[i][j] + * ((ComponentSrkCPA) getComponent(moleculeNumber[j])).getXsite()[assSiteNumber[j]]; } + neeval = 1.0 / (1.0 + 1.0 / getTotalVolume() * neeval); + ((ComponentCPAInterface) getComponent(moleculeNumber[i])).setXsite(assSiteNumber[i], + neeval); + err += Math.abs((old - neeval) / neeval); + } + } while (Math.abs(err) > 1e-10 && iter < maxIter); + // System.out.println("iter " + iter); + // if (Math.abs(err) + // < 1e-12) { + // return true; + // } else { + // System.out.println("did not solve for Xi in iterations: " + iter); + // System.out.println("error: " + err); + return false; + } + + /** {@inheritDoc} */ + @Override + public double getHcpatot() { + return hcpatot; + } + + /** + * Setter for property hcpatot. + * + * @param hcpatot New value of property hcpatot. + */ + public void setHcpatot(double hcpatot) { + this.hcpatot = hcpatot; + } + + /** {@inheritDoc} */ + @Override + public double getGcpa() { + return gcpa; + } + + /** + *

+ * calcRootVolFinder. + *

+ * + * @param phase a int + * @return a double + */ + public double calcRootVolFinder(int phase) { + double solvedBonVHigh = 0.0; + double solvedBonVlow = 1.0; + double oldh = 1; + // double[][] matrix = new double[2][2000]; + double BonV = 1.0 - 1e-10; + try { + // molarVolume(pressure, temperature, A, B, phaseType); + } catch (Exception e) { + logger.error("error", e); } - - /** {@inheritDoc} */ - @Override - public double molarVolume(double pressure, double temperature, double A, double B, - int phasetype) throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - // if (pressure > 1000) { - // BonV = 0.9999; - // } - - // double calcRooBonVtVolFinder = calcRootVolFinder(phasetype); - // BonV = calcRooBonVtVolFinder; - // double BonVInit = BonV; - if (BonV < 0) { - BonV = 1.0e-8; - } - - if (BonV >= 1.0) { - BonV = 0.9999; - } - double BonVold; - double h = 0, dh = 0, dhh = 0; - double d1 = 0, d2 = 0; - double Btemp = getB(); - if (Btemp < 0) { - logger.info("b negative in volume calc"); + double BonVold = BonV; + double Btemp = 0; + double h = 1; + // double Dtemp = 0, dh = 0, gvvv = 0, fvvv = 0, dhh = 0; + // double d1 = 0, d2 = 0; + Btemp = getB(); + // Dtemp = getA(); + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + for (int i = 0; i < 2000; i++) { + BonVold = BonV; + BonV = 1.0 - (i + 1e-6) * 1.0 / 2000.0; + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); + gcpa = calc_g(); + // lngcpa = + // Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); + + do { + } while (!solveX()); + + h = BonV - Btemp / numberOfMolesInPhase * dFdV() + - pressure * Btemp / (numberOfMolesInPhase * R * temperature); + + if (Math.signum(h) * Math.signum(oldh) < 0 && i > 2) { + if (solvedBonVlow < 1e-3) { + solvedBonVlow = (BonV + BonVold) / 2.0; + if (phase == 1) { + break; + } + } else { + solvedBonVHigh = (BonV + BonVold) / 2.0; + if (phase == 0) { + break; + } } - calcDelta(); - - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - int iterations = 0; - - do { - iterations++; - gcpa = calc_g(); - if (gcpa < 0) { - setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); - gcpa = calc_g(); - } - - // lngcpa = - // Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); + } + solvedBonVHigh = (BonV + BonVold) / 2.0; + oldh = h; + // matrix[0][i] = BonV; + // matrix[1][i] = h; + } + if (solvedBonVlow < 1e-3) { + solvedBonVlow = solvedBonVHigh; + } + // dataPresentation.fileHandeling.createTextFile.TextFile file = new + // dataPresentation.fileHandeling.createTextFile.TextFile(); + // file.setValues(matrix); + // file.setOutputFileName("D:/temp/temp2.txt"); + // file.createFile(); + if (phase == 1) { + return solvedBonVlow; + } else { + return solvedBonVHigh; + } + } + + /** {@inheritDoc} */ + @Override + public double molarVolume(double pressure, double temperature, double A, double B, int phasetype) + throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + // if (pressure > 1000) { + // BonV = 0.9999; + // } + + // double calcRooBonVtVolFinder = calcRootVolFinder(phasetype); + // BonV = calcRooBonVtVolFinder; + // double BonVInit = BonV; + if (BonV < 0) { + BonV = 1.0e-8; + } - if (getTotalNumberOfAccociationSites() > 0) { - solveX(); - } + if (BonV >= 1.0) { + BonV = 0.9999; + } + double BonVold; + double h = 0; + double dh = 0; + double dhh = 0; + double d1 = 0; + double d2 = 0; + double Btemp = getB(); + if (Btemp < 0) { + logger.info("b negative in volume calc"); + } + calcDelta(); - initCPAMatrix(1); - double BonV2 = BonV * BonV; - BonVold = BonV; - h = BonV - Btemp / numberOfMolesInPhase * dFdV() - - pressure * Btemp / (numberOfMolesInPhase * R * temperature); - dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); - dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) - - (Btemp * Btemp) / (BonV2 * BonV2) - * (Btemp / numberOfMolesInPhase * dFdVdVdV()); - - d1 = -h / dh; - d2 = -dh / dhh; - // System.out.println("h " + h + " iter " + iterations + " " + d1 + " d2 " + d2 - // + " d1 / d2 " + (d1 / d2)); - if (Math.abs(d1 / d2) <= 1.0) { - BonV += d1 * (1.0 + 0.5 * d1 / d2); - } else if (d1 / d2 < -1) { - BonV += 0.5 * d1; - } else if (d1 > d2) { - BonV += d2; - double hnew = h + d2 * dh; - if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } else { - BonV += 0.5 * d1; - } - if (Math.abs((BonV - BonVold) / BonVold) > 0.1) { - BonV = BonVold + 0.1 * (BonV - BonVold); - } + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + int iterations = 0; - if (BonV > 0.9999) { - if (iterations < 3) { - BonV = (BonVold + BonV) / 2.0; - } else { - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - // BonV = 0.9999; - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / - // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * - // temperature * R); - } - } else if (BonV < 0) { - if (iterations < 3) { - BonV = Math.abs(BonVold + BonV) / 2.0; - } else { - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / - // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * - // temperature * R); - } - } - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10 || Math.abs(h) > 1e-12) - && iterations < 100); - - if (Math.abs(h) > 1e-12) { - // System.out.println("h failed " + "Z" + Z + " iterations " + iterations + " - // BonV " + BonV); - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - } - // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); - // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); - // System.out.println("volume " + getTotalVolume() + " molar volume " + - // getMolarVolume()); - // if(iterations>=100) throw new util.exception.TooManyIterationsException(); - // System.out.println("error in volume " + - // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " - // firstterm " + (R*temperature/molarVolume) + " second " + - // R*temperature*dFdV()); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + " B - // " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); - - if (Double.isNaN(getMolarVolume())) { - throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " - // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" - // + fVV()); - } - return getMolarVolume(); - } + do { + iterations++; + gcpa = calc_g(); + if (gcpa < 0) { + setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); + gcpa = calc_g(); + } - /** - *

- * molarVolumeChangePhase. - *

- * - * @param pressure a double - * @param temperature a double - * @param A a double - * @param B a double - * @param phasetype a int - * @return a double - * @throws neqsim.util.exception.IsNaNException if any. - * @throws neqsim.util.exception.TooManyIterationsException if any. - */ - public double molarVolumeChangePhase(double pressure, double temperature, double A, double B, - int phasetype) throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - // double BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / - // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * - // temperature * R); - double BonV = calcRootVolFinder(phasetype); - // double BonVInit = BonV; - if (BonV < 0) { - BonV = 1.0e-8; - } + // lngcpa = + // Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); - if (BonV >= 1.0) { - BonV = 0.9999; + if (getTotalNumberOfAccociationSites() > 0) { + solveX(); + } + + initCPAMatrix(1); + double BonV2 = BonV * BonV; + BonVold = BonV; + h = BonV - Btemp / numberOfMolesInPhase * dFdV() + - pressure * Btemp / (numberOfMolesInPhase * R * temperature); + dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); + dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) + - (Btemp * Btemp) / (BonV2 * BonV2) * (Btemp / numberOfMolesInPhase * dFdVdVdV()); + + d1 = -h / dh; + d2 = -dh / dhh; + // System.out.println("h " + h + " iter " + iterations + " " + d1 + " d2 " + d2 + // + " d1 / d2 " + (d1 / d2)); + if (Math.abs(d1 / d2) <= 1.0) { + BonV += d1 * (1.0 + 0.5 * d1 / d2); + } else if (d1 / d2 < -1) { + BonV += 0.5 * d1; + } else if (d1 > d2) { + BonV += d2; + double hnew = h + d2 * dh; + if (Math.abs(hnew) > Math.abs(h)) { + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); } - double BonVold = BonV; - double Btemp = 0, h = 0, dh = 0, dhh = 0; - // double fvvv = 0, gvvv = 0; - double d1 = 0, d2 = 0; - Btemp = getB(); - if (Btemp < 0) { - logger.info("b negative in volume calc"); + } else { + BonV += 0.5 * d1; + } + if (Math.abs((BonV - BonVold) / BonVold) > 0.1) { + BonV = BonVold + 0.1 * (BonV - BonVold); + } + + if (BonV > 0.9999) { + if (iterations < 3) { + BonV = (BonVold + BonV) / 2.0; + } else { + // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // BonV = 0.9999; + // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * + // temperature * R); } - calcDelta(); - - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - int iterations = 0; - - do { - iterations++; - gcpa = calc_g(); - if (gcpa < 0) { - setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); - gcpa = calc_g(); - } - - // lngcpa = - // Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - - solveX(); - - initCPAMatrix(1); - double BonV2 = BonV * BonV; - BonVold = BonV; - h = BonV - Btemp / numberOfMolesInPhase * dFdV() - - pressure * Btemp / (numberOfMolesInPhase * R * temperature); - dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); - dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) - - (Btemp * Btemp) / (BonV2 * BonV2) - * (Btemp / numberOfMolesInPhase * dFdVdVdV()); - - d1 = -h / dh; - d2 = -dh / dhh; - // System.out.println("d1" + d1 + " d2 " + d2 + " d1 / d2 " + (d1 / d2)); - if (Math.abs(d1 / d2) <= 1.0) { - BonV += d1 * (1.0 + 0.5 * d1 / d2); - } else if (d1 / d2 < -1) { - BonV += 0.5 * d1; - } else if (d1 > d2) { - BonV += d2; - double hnew = h + d2 * dh; - if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } else { - BonV += 0.5 * d1; - } - if (Math.abs((BonV - BonVold) / BonVold) > 0.1) { - BonV = BonVold + 0.1 * (BonV - BonVold); - } - - if (BonV > 1.1) { - if (iterations < 3) { - BonV = (BonVold + BonV) / 2.0; - } else { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } - - if (BonV < 0) { - if (iterations < 3) { - BonV = Math.abs(BonVold + BonV) / 2.0; - } else { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } - - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - - // System.out.println("Z " + Z + "h " + h + " BONV " + (Math.abs((BonV - - // BonVold) / BonV))); - } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10) && iterations < 100); - - /* - * if (Math.abs(h) > 1e-8) { if (phasetype == 0) { molarVolume(pressure, temperature, A, B, - * 1); } else { molarVolume(pressure, temperature, A, B, 0); } return getMolarVolume(); } - */ - // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); - // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); - // System.out.println("volume " + getTotalVolume() + " molar volume " + - // getMolarVolume()); - // if(iterations>=100) throw new util.exception.TooManyIterationsException(); - // System.out.println("error in volume " + - // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " - // firstterm " + (R*temperature/molarVolume) + " second " + - // R*temperature*dFdV()); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + " B - // " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); - if (Double.isNaN(getMolarVolume())) { - throw new neqsim.util.exception.IsNaNException(this, "molarVolumeChangePhase", - "Molar volume"); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " - // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" - // + fVV()); + } else if (BonV < 0) { + if (iterations < 3) { + BonV = Math.abs(BonVold + BonV) / 2.0; + } else { + // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * + // temperature * R); } - - return getMolarVolume(); + } + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); + } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10 || Math.abs(h) > 1e-12) + && iterations < 100); + + if (Math.abs(h) > 1e-12) { + // System.out.println("h failed " + "Z" + Z + " iterations " + iterations + " + // BonV " + BonV); + // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); } - - /** {@inheritDoc} */ - @Override - public double molarVolume2(double pressure, double temperature, double A, double B, int phase) - throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - Z = phase == 0 ? 1.0 : 1.0e-5; - setMolarVolume(Z * R * temperature / pressure); - // super.molarVolume(pressure,temperature, A, B, phase); - int iterations = 0; - double err = 0.0, dErrdV = 0.0; - double deltaV = 0; - - do { - A = calcA(this, temperature, pressure, numberOfComponents); - B = calcB(this, temperature, pressure, numberOfComponents); - - double dFdV = dFdV(), dFdVdV = dFdVdV(); - // double dFdVdVdV = dFdVdVdV(); - // double factor1 = 1.0e0, factor2 = 1.0e0; - err = -R * temperature * dFdV + R * temperature / getMolarVolume() - pressure; - - // System.out.println("pressure " + -R * temperature * dFdV + " " + R * - // temperature / getMolarVolume()); - // -pressure; - dErrdV = -R * temperature * dFdVdV - - R * temperature * numberOfMolesInPhase / Math.pow(getVolume(), 2.0); - - // System.out.println("errdV " + dErrdV); - // System.out.println("err " + err); - deltaV = -err / dErrdV; - - setMolarVolume(getMolarVolume() + deltaV / numberOfMolesInPhase); - - Z = pressure * getMolarVolume() / (R * temperature); - if (Z < 0) { - Z = 1e-6; - setMolarVolume(Z * R * temperature / pressure); - } - - // System.out.println("Z " + Z); - } while (Math.abs(err) > 1.0e-8 || iterations < 100); - // System.out.println("Z " + Z); - return getMolarVolume(); + // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); + // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); + // System.out.println("volume " + getTotalVolume() + " molar volume " + + // getMolarVolume()); + // if(iterations>=100) throw new util.exception.TooManyIterationsException(); + // System.out.println("error in volume " + + // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV())); // + " + // firstterm " + (R*temperature/molarVolume) + " second " + + // R*temperature*dFdV()); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + " B + // " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); + + if (Double.isNaN(getMolarVolume())) { + throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " + // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + // + fVV()); } - - /** {@inheritDoc} */ - @Override - public double getGcpav() { - return gcpav; + return getMolarVolume(); + } + + /** + *

+ * molarVolumeChangePhase. + *

+ * + * @param pressure a double + * @param temperature a double + * @param A a double + * @param B a double + * @param phasetype a int + * @return a double + * @throws neqsim.util.exception.IsNaNException if any. + * @throws neqsim.util.exception.TooManyIterationsException if any. + */ + public double molarVolumeChangePhase(double pressure, double temperature, double A, double B, + int phasetype) throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + // double BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * + // temperature * R); + double BonV = calcRootVolFinder(phasetype); + // double BonVInit = BonV; + if (BonV < 0) { + BonV = 1.0e-8; } - /** - *

- * Setter for the field gcpav. - *

- * - * @param gcpav a double - */ - public void setGcpav(double gcpav) { - this.gcpav = gcpav; + if (BonV >= 1.0) { + BonV = 0.9999; } - - /** {@inheritDoc} */ - @Override - public CPAMixingInterface getCpamix() { - return cpamix; + double BonVold = BonV; + double Btemp = 0; + double h = 0; + double dh = 0; + double dhh = 0; + // double fvvv = 0, gvvv = 0; + double d1 = 0; + double d2 = 0; + Btemp = getB(); + if (Btemp < 0) { + logger.info("b negative in volume calc"); } + calcDelta(); - /** {@inheritDoc} */ - @Override - public double calcPressure() { - gcpa = calc_g(); - // lngcpa = - // Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - solveX(); - hcpatot = calc_hCPA(); + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + int iterations = 0; - initCPAMatrix(1); - return super.calcPressure(); - } + do { + iterations++; + gcpa = calc_g(); + if (gcpa < 0) { + setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); + gcpa = calc_g(); + } + + // lngcpa = + // Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); + + solveX(); + + initCPAMatrix(1); + double BonV2 = BonV * BonV; + BonVold = BonV; + h = BonV - Btemp / numberOfMolesInPhase * dFdV() + - pressure * Btemp / (numberOfMolesInPhase * R * temperature); + dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); + dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) + - (Btemp * Btemp) / (BonV2 * BonV2) * (Btemp / numberOfMolesInPhase * dFdVdVdV()); + + d1 = -h / dh; + d2 = -dh / dhh; + // System.out.println("d1" + d1 + " d2 " + d2 + " d1 / d2 " + (d1 / d2)); + if (Math.abs(d1 / d2) <= 1.0) { + BonV += d1 * (1.0 + 0.5 * d1 / d2); + } else if (d1 / d2 < -1) { + BonV += 0.5 * d1; + } else if (d1 > d2) { + BonV += d2; + double hnew = h + d2 * dh; + if (Math.abs(hnew) > Math.abs(h)) { + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + } + } else { + BonV += 0.5 * d1; + } + if (Math.abs((BonV - BonVold) / BonVold) > 0.1) { + BonV = BonVold + 0.1 * (BonV - BonVold); + } + + if (BonV > 1.1) { + if (iterations < 3) { + BonV = (BonVold + BonV) / 2.0; + } else { + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + } + } - /** {@inheritDoc} */ - @Override - public int getCrossAssosiationScheme(int comp1, int comp2, int site1, int site2) { - if (comp1 == comp2) { - return selfAccociationScheme[comp1][site1][site2]; + if (BonV < 0) { + if (iterations < 3) { + BonV = Math.abs(BonVold + BonV) / 2.0; } else { - return crossAccociationScheme[comp1][comp2][site1][site2]; + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); } - } + } + + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); + + // System.out.println("Z " + Z + "h " + h + " BONV " + (Math.abs((BonV - + // BonVold) / BonV))); + } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10) && iterations < 100); - /** - *

- * croeneckerProduct. - *

- * - * @param a an array of {@link double} objects - * @param b an array of {@link double} objects - * @return an array of {@link double} objects + /* + * if (Math.abs(h) > 1e-8) { if (phasetype == 0) { molarVolume(pressure, temperature, A, B, 1); + * } else { molarVolume(pressure, temperature, A, B, 0); } return getMolarVolume(); } */ - public double[][] croeneckerProduct(double[][] a, double[][] b) { - int aLength = a.length; - int aCols = a[0].length; - int bLength = b.length; - int bCols = b[0].length; - double[][] result = new double[aLength * bLength][(aCols) * (bCols)]; - for (int z = 0; z < aLength; z++) { - for (int i = 0; i < aCols; i++) { - for (int j = 0; j < bLength; j++) { - for (int k = 0; k < bCols; k++) { - result[j + (z * bLength)][k + (i * bCols)] = a[z][i] * b[j][k]; - } - } - } - } - return result; + // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); + // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); + // System.out.println("volume " + getTotalVolume() + " molar volume " + + // getMolarVolume()); + // if(iterations>=100) throw new util.exception.TooManyIterationsException(); + // System.out.println("error in volume " + + // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV())); // + " + // firstterm " + (R*temperature/molarVolume) + " second " + + // R*temperature*dFdV()); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + " B + // " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); + if (Double.isNaN(getMolarVolume())) { + throw new neqsim.util.exception.IsNaNException(this, "molarVolumeChangePhase", + "Molar volume"); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " + // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + // + fVV()); } - /** {@inheritDoc} */ - @Override - public int getTotalNumberOfAccociationSites() { - return totalNumberOfAccociationSites; + return getMolarVolume(); + } + + /** {@inheritDoc} */ + @Override + public double molarVolume2(double pressure, double temperature, double A, double B, int phase) + throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + Z = phase == 0 ? 1.0 : 1.0e-5; + setMolarVolume(Z * R * temperature / pressure); + // super.molarVolume(pressure,temperature, A, B, phase); + int iterations = 0; + double err = 0.0; + double dErrdV = 0.0; + double deltaV = 0; + + do { + A = calcA(this, temperature, pressure, numberOfComponents); + B = calcB(this, temperature, pressure, numberOfComponents); + + double dFdV = dFdV(); + double dFdVdV = dFdVdV(); + // double dFdVdVdV = dFdVdVdV(); + // double factor1 = 1.0e0, factor2 = 1.0e0; + err = -R * temperature * dFdV + R * temperature / getMolarVolume() - pressure; + + // System.out.println("pressure " + -R * temperature * dFdV + " " + R * + // temperature / getMolarVolume()); + // -pressure; + dErrdV = -R * temperature * dFdVdV + - R * temperature * numberOfMolesInPhase / Math.pow(getVolume(), 2.0); + + // System.out.println("errdV " + dErrdV); + // System.out.println("err " + err); + deltaV = -err / dErrdV; + + setMolarVolume(getMolarVolume() + deltaV / numberOfMolesInPhase); + + Z = pressure * getMolarVolume() / (R * temperature); + if (Z < 0) { + Z = 1e-6; + setMolarVolume(Z * R * temperature / pressure); + } + + // System.out.println("Z " + Z); + } while (Math.abs(err) > 1.0e-8 || iterations < 100); + // System.out.println("Z " + Z); + return getMolarVolume(); + } + + /** {@inheritDoc} */ + @Override + public double getGcpav() { + return gcpav; + } + + /** + *

+ * Setter for the field gcpav. + *

+ * + * @param gcpav a double + */ + public void setGcpav(double gcpav) { + this.gcpav = gcpav; + } + + /** {@inheritDoc} */ + @Override + public CPAMixingInterface getCpamix() { + return cpamix; + } + + /** {@inheritDoc} */ + @Override + public double calcPressure() { + gcpa = calc_g(); + // lngcpa = + // Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); + solveX(); + hcpatot = calc_hCPA(); + + initCPAMatrix(1); + return super.calcPressure(); + } + + /** {@inheritDoc} */ + @Override + public int getCrossAssosiationScheme(int comp1, int comp2, int site1, int site2) { + if (comp1 == comp2) { + return selfAccociationScheme[comp1][site1][site2]; + } else { + return crossAccociationScheme[comp1][comp2][site1][site2]; } - - /** {@inheritDoc} */ - @Override - public void setTotalNumberOfAccociationSites(int totalNumberOfAccociationSites) { - this.totalNumberOfAccociationSites = totalNumberOfAccociationSites; + } + + /** + *

+ * croeneckerProduct. + *

+ * + * @param a an array of {@link double} objects + * @param b an array of {@link double} objects + * @return an array of {@link double} objects + */ + public double[][] croeneckerProduct(double[][] a, double[][] b) { + int aLength = a.length; + int aCols = a[0].length; + int bLength = b.length; + int bCols = b[0].length; + double[][] result = new double[aLength * bLength][(aCols) * (bCols)]; + for (int z = 0; z < aLength; z++) { + for (int i = 0; i < aCols; i++) { + for (int j = 0; j < bLength; j++) { + for (int k = 0; k < bCols; k++) { + result[j + (z * bLength)][k + (i * bCols)] = a[z][i] * b[j][k]; + } + } + } } + return result; + } + + /** {@inheritDoc} */ + @Override + public int getTotalNumberOfAccociationSites() { + return totalNumberOfAccociationSites; + } + + /** {@inheritDoc} */ + @Override + public void setTotalNumberOfAccociationSites(int totalNumberOfAccociationSites) { + this.totalNumberOfAccociationSites = totalNumberOfAccociationSites; + } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseSrkCPAojAlgo.java b/src/main/java/neqsim/thermo/phase/PhaseSrkCPAojAlgo.java index cf2deaaa79..e7e8b307ee 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseSrkCPAojAlgo.java +++ b/src/main/java/neqsim/thermo/phase/PhaseSrkCPAojAlgo.java @@ -86,7 +86,7 @@ public class PhaseSrkCPAojAlgo extends PhaseSrkEos implements PhaseCPAInterface // null, uMatrix = null, QMatksiksiksi = null, KlkVVVMatrix = null, KlkVVMatrix // = null, udotTimesmiMatrix = null, ksiMatrix = null, KlkMatrix = null, // hessianMatrix = null, hessianInvers = null, KlkVMatrix = null; - // DMatrixRMaj corr2Matrix = null, corr3Matrix = null, corr4Matrix = null;//new + // DMatrixRMaj corr2Matrix = null, corr3Matrix = null, corr4Matrix = null; //new // DenseMatrix64F(getTotalNumberOfAccociationSites(), 1); /** @@ -449,7 +449,8 @@ public void initCPAMatrix(int type) { // 1).print(10, 10); // Matrix tempMatrix20 = miMatrix.getMatrix(assSites, assSites, 0, // totalNumberOfAccociationSites - - // 1).times(uMatrix).minus(ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5));// + // 1).times(uMatrix).minus(ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5)); + // // // ksiMatrix.transpose().times(KlkTMatrix.times(ksiMatrix)).times(-0.5); // System.out.println("dQdn "); // tempMatrix20.print(10, 10); @@ -466,7 +467,7 @@ public void initCPAMatrix(int type) { // System.out.println("temp4 matrix"); // tempMatrix4.print(10, 10); // Matrix tempMatrix5 = amatrix.minus(tempMatrix4); - // SimpleMatrix tempMatrix6 = hessianInvers.mult(tempMatrix5);//.scale(-1.0); + // SimpleMatrix tempMatrix6 = hessianInvers.mult(tempMatrix5); //.scale(-1.0); // System.out.println("dXdni"); // tempMatrix4.print(10, 10); // tempMatrix5.print(10, 10); @@ -608,8 +609,8 @@ public double dFCPAdT() { * double tot = 0.0; double ans = 0.0; for (int i = 0; i < numberOfComponents; i++) { tot = 0.0; * for (int j = 0; j < getComponent(i).getNumberOfAssociationSites(); j++) { double xai = * ((ComponentSrkCPA) getComponent(i)).getXsite()[j]; double xaidT = ((ComponentSrkCPA) - * getComponent(i)).getXsitedT()[j]; tot += 1.0 / xai * xaidT - 0.5 * xaidT;// - 1.0 / 2.0 * xai - * + 1.0 / 2.0); } ans += getComponent(i).getNumberOfMolesInPhase() * tot; } + * getComponent(i)).getXsitedT()[j]; tot += 1.0 / xai * xaidT - 0.5 * xaidT; // - 1.0 / 2.0 * + * xai + 1.0 / 2.0); } ans += getComponent(i).getNumberOfMolesInPhase() * tot; } * System.out.println("dFCPAdT1 " + ans + " dfcpa2 " +dFCPAdT); return ans; */ return dFCPAdT; @@ -825,7 +826,7 @@ public boolean solveX() { } // MatrixStore corr2Matrix2 = mat1.multiply(mat2); - // corr2Matrix2 = mat1.multiply(mat2);//gcpa)CommonOps_DDRM.mult(mat1, mat2, + // corr2Matrix2 = mat1.multiply(mat2); //gcpa)CommonOps_DDRM.mult(mat1, mat2, // corr2Matrix); // MatrixStore corr3Matrix = udotTimesmMatrix2.subtract(corr2Matrix2); // PrimitiveMatrix corr4Matrix = hessianInvers2.multiply(corr3Matrix); @@ -834,7 +835,7 @@ public boolean solveX() { // CommonOps_DDRM.mult(hessianInvers.getDDRM(), corr3Matrix, corr4Matrix); // SimpleMatrix gMatrix = udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)); // corrMatrix = - // hessianInvers.mult(udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)));//.scale(-1.0); + // hessianInvers.mult(udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix))); //.scale(-1.0); temp = 0; // System.out.println("print SimpleMatrix ..."); // corrMatrix.print(10, 10); @@ -1123,7 +1124,7 @@ public double molarVolume(double pressure, double temperature, double A, double // getMolarVolume()); // if(iterations>=100) throw new util.exception.TooManyIterationsException(); // System.out.println("error in volume " + - // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " + // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV())); // + " // firstterm " + (R*temperature/molarVolume) + " second " + // R*temperature*dFdV()); // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " @@ -1265,7 +1266,7 @@ public double molarVolumeChangePhase(double pressure, double temperature, double // getMolarVolume()); // if(iterations>=100) throw new util.exception.TooManyIterationsException(); // System.out.println("error in volume " + - // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " + // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV())); // + " // firstterm " + (R*temperature/molarVolume) + " second " + // R*temperature*dFdV()); // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " diff --git a/src/main/java/neqsim/thermo/phase/PhaseUMRCPA.java b/src/main/java/neqsim/thermo/phase/PhaseUMRCPA.java index 558effcbf7..75a39eca7e 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseUMRCPA.java +++ b/src/main/java/neqsim/thermo/phase/PhaseUMRCPA.java @@ -21,2100 +21,2132 @@ * @version $Id: $Id */ public class PhaseUMRCPA extends PhasePrEos implements PhaseCPAInterface { - /** - *

- * Getter for the field dFdNtemp. - *

- * - * @return the dFdNtemp - */ - public double[] getdFdNtemp() { - return dFdNtemp; - } - - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(PhaseUMRCPA.class); - - public CPAMixing cpaSelect = new CPAMixing(); - public CPAMixingInterface cpamix; - double gcpavv = 0.0, gcpavvv = 0.0, gcpa = 0.0, hcpatot = 1.0, FCPA = 0.0, dFCPAdTdV, - dFCPAdTdT = 0.0, dFCPAdT = 0, dFCPAdV = 0, dFCPAdVdV = 0.0, dFCPAdVdVdV = 0.0; - double gcpav = 0.0, tempTotVol = 0; - private double[] dFdNtemp = {0, 0}; - int cpaon = 1, oldTotalNumberOfAccociationSites = 0; - int totalNumberOfAccociationSites = 0; - int[][][] selfAccociationScheme = null; - int[][][][] crossAccociationScheme = null; - int[] activeAccosComp = null;// new int[100]; - private double[] lngi; - int[] moleculeNumber = null, assSiteNumber = null; - private double[][] gvector = null, delta = null, deltaNog = null, deltadT = null, - deltadTdT = null; - double[][][] Klkni = null; - private SimpleMatrix KlkTVMatrix = null, KlkTTMatrix = null, KlkTMatrix = null, - udotTimesmMatrix = null, mVector = null, udotMatrix = null, uMatrix = null, - QMatksiksiksi = null, KlkVVVMatrix = null, KlkVVMatrix = null, udotTimesmiMatrix = null, - ksiMatrix = null, KlkMatrix = null, hessianMatrix = null, hessianInvers = null, - KlkVMatrix = null; - private DMatrixRMaj corr2Matrix = null, corr3Matrix = null, corr4Matrix = null;// new - // DenseMatrix64F(getTotalNumberOfAccociationSites(), - // 1); - - /** - *

- * Constructor for PhaseUMRCPA. - *

- */ - public PhaseUMRCPA() { - super(); - thermoPropertyModelName = "UMR-CPA-EoS"; - } - - /** {@inheritDoc} */ - @Override - public PhaseUMRCPA clone() { - PhaseUMRCPA clonedPhase = null; - try { - clonedPhase = (PhaseUMRCPA) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } - if (activeAccosComp != null) { - clonedPhase.activeAccosComp = activeAccosComp.clone(); - System.arraycopy(this.activeAccosComp, 0, clonedPhase.activeAccosComp, 0, - activeAccosComp.length); + /** + *

+ * Getter for the field dFdNtemp. + *

+ * + * @return the dFdNtemp + */ + public double[] getdFdNtemp() { + return dFdNtemp; + } + + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(PhaseUMRCPA.class); + + public CPAMixing cpaSelect = new CPAMixing(); + public CPAMixingInterface cpamix; + double gcpavv = 0.0; + double gcpavvv = 0.0; + double gcpa = 0.0; + double hcpatot = 1.0; + double FCPA = 0.0; + double dFCPAdTdV; + double dFCPAdTdT = 0.0; + double dFCPAdT = 0; + double dFCPAdV = 0; + double dFCPAdVdV = 0.0; + double dFCPAdVdVdV = 0.0; + double gcpav = 0.0; + double tempTotVol = 0; + private double[] dFdNtemp = {0, 0}; + int cpaon = 1; + int oldTotalNumberOfAccociationSites = 0; + int totalNumberOfAccociationSites = 0; + int[][][] selfAccociationScheme = null; + int[][][][] crossAccociationScheme = null; + int[] activeAccosComp = null; // new int[100]; + private double[] lngi; + int[] moleculeNumber = null; + int[] assSiteNumber = null; + private double[][] gvector = null; + private double[][] delta = null; + private double[][] deltaNog = null; + private double[][] deltadT = null; + private double[][] deltadTdT = null; + double[][][] Klkni = null; + private SimpleMatrix KlkTVMatrix = null; + private SimpleMatrix KlkTTMatrix = null; + private SimpleMatrix KlkTMatrix = null; + private SimpleMatrix udotTimesmMatrix = null; + private SimpleMatrix mVector = null; + private SimpleMatrix udotMatrix = null; + private SimpleMatrix uMatrix = null; + private SimpleMatrix QMatksiksiksi = null; + private SimpleMatrix KlkVVVMatrix = null; + private SimpleMatrix KlkVVMatrix = null; + private SimpleMatrix udotTimesmiMatrix = null; + private SimpleMatrix ksiMatrix = null; + private SimpleMatrix KlkMatrix = null; + private SimpleMatrix hessianMatrix = null; + private SimpleMatrix hessianInvers = null; + private SimpleMatrix KlkVMatrix = null; + private DMatrixRMaj corr2Matrix = null; + private DMatrixRMaj corr3Matrix = null; + private DMatrixRMaj corr4Matrix = null; + + /** + *

+ * Constructor for PhaseUMRCPA. + *

+ */ + public PhaseUMRCPA() { + super(); + thermoPropertyModelName = "UMR-CPA-EoS"; + } + + /** {@inheritDoc} */ + @Override + public PhaseUMRCPA clone() { + PhaseUMRCPA clonedPhase = null; + try { + clonedPhase = (PhaseUMRCPA) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); + } + if (activeAccosComp != null) { + clonedPhase.activeAccosComp = activeAccosComp.clone(); + System.arraycopy(this.activeAccosComp, 0, clonedPhase.activeAccosComp, 0, + activeAccosComp.length); + } + // clonedPhase.cpaSelect = (CPAMixing) cpaSelect.clone(); + // clonedPhase.cpamix = (CPAMixingInterface) cpamix.clone(); + // clonedPhase.cpamix = cpaSelect.getMixingRule(1, this); + + return clonedPhase; + } + + /** {@inheritDoc} */ + @Override + public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, + double beta) { + boolean changedAssosiationStatus = false; + + if (type == 0) { + activeAccosComp = new int[numberOfComponents]; + for (int i = 0; i < numberOfComponents; i++) { + if (componentArray[i].getNumberOfmoles() < 1e-50) { + componentArray[i].setNumberOfAssociationSites(0); + if (activeAccosComp[i] == 1) { + activeAccosComp[i] = 0; + changedAssosiationStatus = true; + } + } else { + if (activeAccosComp[i] == 0) { + changedAssosiationStatus = true; + activeAccosComp[i] = 1; + } } - // clonedPhase.cpaSelect = (CPAMixing) cpaSelect.clone(); - // clonedPhase.cpamix = (CPAMixingInterface) cpamix.clone(); - // clonedPhase.cpamix = cpaSelect.getMixingRule(1, this); - - return clonedPhase; - } - - /** {@inheritDoc} */ - @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, int phase, - double beta) { - boolean changedAssosiationStatus = false; - - if (type == 0) { - activeAccosComp = new int[numberOfComponents]; - for (int i = 0; i < numberOfComponents; i++) { - if (componentArray[i].getNumberOfmoles() < 1e-50) { - componentArray[i].setNumberOfAssociationSites(0); - if (activeAccosComp[i] == 1) { - activeAccosComp[i] = 0; - changedAssosiationStatus = true; - } - } else { - if (activeAccosComp[i] == 0) { - changedAssosiationStatus = true; - activeAccosComp[i] = 1; - } - } - } - - if (changedAssosiationStatus || lngi == null) { - setTotalNumberOfAccociationSites(0); - selfAccociationScheme = new int[numberOfComponents][0][0]; - crossAccociationScheme = new int[numberOfComponents][numberOfComponents][0][0]; - for (int i = 0; i < numberOfComponents; i++) { - if (componentArray[i].getNumberOfmoles() < 1e-50) { - componentArray[i].setNumberOfAssociationSites(0); - } else { - componentArray[i].setNumberOfAssociationSites( - componentArray[i].getOrginalNumberOfAssociationSites()); - setTotalNumberOfAccociationSites(getTotalNumberOfAccociationSites() - + componentArray[i].getNumberOfAssociationSites()); - selfAccociationScheme[i] = cpaSelect.setAssociationScheme(i, this); - for (int j = 0; j < numberOfComponents; j++) { - crossAccociationScheme[i][j] = - cpaSelect.setCrossAssociationScheme(i, j, this); - } - } - } - } + } - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - ((ComponentUMRCPA) componentArray[i]).setXsite(j, 1.0); - ((ComponentUMRCPA) componentArray[i]).setXsitedV(j, 0.0); - ((ComponentUMRCPA) componentArray[i]).setXsitedT(j, 0.0); - } - } - - if (changedAssosiationStatus || lngi == null || mVector == null) { - lngi = new double[numberOfComponents]; - mVector = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - KlkMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkVVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkVVVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - hessianMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkTMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkTTMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkTVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - corr2Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - corr3Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - corr4Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - Klkni = new double[numberOfComponents][getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - ksiMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - uMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - udotMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - moleculeNumber = new int[getTotalNumberOfAccociationSites()]; - assSiteNumber = new int[getTotalNumberOfAccociationSites()]; - gvector = new double[getTotalNumberOfAccociationSites()][1]; - udotTimesmMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - delta = new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - deltaNog = - new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - deltadT = - new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - deltadTdT = - new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - QMatksiksiksi = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - udotTimesmiMatrix = - new SimpleMatrix(numberOfComponents, getTotalNumberOfAccociationSites()); - - oldTotalNumberOfAccociationSites = getTotalNumberOfAccociationSites(); - - int temp = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - moleculeNumber[temp + j] = i; - assSiteNumber[temp + j] = j; - } - temp += componentArray[i].getNumberOfAssociationSites(); - } + if (changedAssosiationStatus || lngi == null) { + setTotalNumberOfAccociationSites(0); + selfAccociationScheme = new int[numberOfComponents][0][0]; + crossAccociationScheme = new int[numberOfComponents][numberOfComponents][0][0]; + for (int i = 0; i < numberOfComponents; i++) { + if (componentArray[i].getNumberOfmoles() < 1e-50) { + componentArray[i].setNumberOfAssociationSites(0); + } else { + componentArray[i].setNumberOfAssociationSites( + componentArray[i].getOrginalNumberOfAssociationSites()); + setTotalNumberOfAccociationSites(getTotalNumberOfAccociationSites() + + componentArray[i].getNumberOfAssociationSites()); + selfAccociationScheme[i] = cpaSelect.setAssociationScheme(i, this); + for (int j = 0; j < numberOfComponents; j++) { + crossAccociationScheme[i][j] = cpaSelect.setCrossAssociationScheme(i, j, this); } - } + } + } + } + + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + ((ComponentUMRCPA) componentArray[i]).setXsite(j, 1.0); + ((ComponentUMRCPA) componentArray[i]).setXsitedV(j, 0.0); + ((ComponentUMRCPA) componentArray[i]).setXsitedT(j, 0.0); + } + } + + if (changedAssosiationStatus || lngi == null || mVector == null) { + lngi = new double[numberOfComponents]; + mVector = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + KlkMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkVVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkVVVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + hessianMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkTMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkTTMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + KlkTVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), + getTotalNumberOfAccociationSites()); + corr2Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + corr3Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + corr4Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + Klkni = + new double[numberOfComponents][getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + ksiMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + uMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + udotMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + moleculeNumber = new int[getTotalNumberOfAccociationSites()]; + assSiteNumber = new int[getTotalNumberOfAccociationSites()]; + gvector = new double[getTotalNumberOfAccociationSites()][1]; + udotTimesmMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + delta = new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + deltaNog = + new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + deltadT = + new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + deltadTdT = + new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + QMatksiksiksi = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + udotTimesmiMatrix = + new SimpleMatrix(numberOfComponents, getTotalNumberOfAccociationSites()); + + oldTotalNumberOfAccociationSites = getTotalNumberOfAccociationSites(); - if (cpamix == null) { - cpamix = cpaSelect.getMixingRule(1, this); - } - if (type > 0) { - calcDelta(); + int temp = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + moleculeNumber[temp + j] = i; + assSiteNumber[temp + j] = j; + } + temp += componentArray[i].getNumberOfAssociationSites(); } + } + } - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + if (cpamix == null) { + cpamix = cpaSelect.getMixingRule(1, this); + } + if (type > 0) { + calcDelta(); + } - if (type > 0 && isConstantPhaseVolume()) { - solveX(); - super.init(totalNumberOfMoles, numberOfComponents, 1, phase, beta); - gcpa = calc_g(); - gcpav = calc_lngV(); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - } + super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - if (type > 0) { - hcpatot = calc_hCPA(); - } + if (type > 0 && isConstantPhaseVolume()) { + solveX(); + super.init(totalNumberOfMoles, numberOfComponents, 1, phase, beta); + gcpa = calc_g(); + gcpav = calc_lngV(); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); + } - if (type > 1) { - initCPAMatrix(type); - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - } + if (type > 0) { + hcpatot = calc_hCPA(); } - /** - *

- * initCPAMatrix. - *

- * - * @param type a int - */ - public void initCPAMatrix(int type) { - if (totalNumberOfAccociationSites == 0) { - FCPA = 0.0; - dFCPAdTdV = 0.0; - dFCPAdTdT = 0.0; - dFCPAdT = 0; - dFCPAdV = 0; - dFCPAdVdV = 0.0; - dFCPAdVdVdV = 0.0; - return; - } + if (type > 1) { + initCPAMatrix(type); + super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + } + } + + /** + *

+ * initCPAMatrix. + *

+ * + * @param type a int + */ + public void initCPAMatrix(int type) { + if (totalNumberOfAccociationSites == 0) { + FCPA = 0.0; + dFCPAdTdV = 0.0; + dFCPAdTdT = 0.0; + dFCPAdT = 0; + dFCPAdV = 0; + dFCPAdVdV = 0.0; + dFCPAdVdVdV = 0.0; + return; + } - int temp = 0; - double tempVar1, tempVar2; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - tempVar1 = ksiMatrix.get(temp + j, 0); - tempVar2 = udotMatrix.get(temp + j, 0); - uMatrix.set(temp + j, 0, Math.log(tempVar1) - tempVar1 + 1.0); - gvector[temp + j][0] = mVector.get(temp + j, 0) * tempVar2; - - if (moleculeNumber[temp + j] == i) { - udotTimesmiMatrix.set(i, temp + j, tempVar2); - } else { - udotTimesmiMatrix.set(i, temp + j, 0.0); - } - } - temp += componentArray[i].getNumberOfAssociationSites(); + int temp = 0; + double tempVar1; + double tempVar2; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + tempVar1 = ksiMatrix.get(temp + j, 0); + tempVar2 = udotMatrix.get(temp + j, 0); + uMatrix.set(temp + j, 0, Math.log(tempVar1) - tempVar1 + 1.0); + gvector[temp + j][0] = mVector.get(temp + j, 0) * tempVar2; + + if (moleculeNumber[temp + j] == i) { + udotTimesmiMatrix.set(i, temp + j, tempVar2); + } else { + udotTimesmiMatrix.set(i, temp + j, 0.0); } + } + temp += componentArray[i].getNumberOfAssociationSites(); + } - if (type > 2) { - for (int p = 0; p < numberOfComponents; p++) { - lngi[p] = ((ComponentUMRCPA) componentArray[p]).calc_lngi(this); - } - } + if (type > 2) { + for (int p = 0; p < numberOfComponents; p++) { + lngi[p] = ((ComponentUMRCPA) componentArray[p]).calc_lngi(this); + } + } - for (int i = 0; i < totalNumberOfAccociationSites; i++) { - for (int j = i; j < totalNumberOfAccociationSites; j++) { - delta[i][j] = deltaNog[i][j] * gcpa; - delta[j][i] = delta[i][j]; - if (type > 1) { - deltadT[i][j] = cpamix.calcDeltadT(assSiteNumber[i], assSiteNumber[j], - moleculeNumber[i], moleculeNumber[j], this, getTemperature(), - getPressure(), numberOfComponents); - deltadT[j][i] = deltadT[i][j]; - - deltadTdT[i][j] = cpamix.calcDeltadTdT(assSiteNumber[i], assSiteNumber[j], - moleculeNumber[i], moleculeNumber[j], this, getTemperature(), - getPressure(), numberOfComponents); - deltadTdT[j][i] = deltadTdT[i][j]; - } - } - } + for (int i = 0; i < totalNumberOfAccociationSites; i++) { + for (int j = i; j < totalNumberOfAccociationSites; j++) { + delta[i][j] = deltaNog[i][j] * gcpa; + delta[j][i] = delta[i][j]; + if (type > 1) { + deltadT[i][j] = cpamix.calcDeltadT(assSiteNumber[i], assSiteNumber[j], moleculeNumber[i], + moleculeNumber[j], this, getTemperature(), getPressure(), numberOfComponents); + deltadT[j][i] = deltadT[i][j]; - double totalVolume = getTotalVolume(); - double totalVolume2 = totalVolume * totalVolume, totalVolume3 = totalVolume2 * totalVolume; - double gdv1 = getGcpav() - 1.0 / totalVolume; - double gdv2 = gdv1 * gdv1; - double gdv3 = gdv2 * gdv1; - double Klk = 0.0; - double tempVar; - double tempKsiRead = 0.0; - for (int i = 0; i < totalNumberOfAccociationSites; i++) { - for (int j = i; j < totalNumberOfAccociationSites; j++) { - Klk = KlkMatrix.get(i, j); - tempVar = Klk * gdv1; - KlkVMatrix.set(i, j, tempVar); - KlkVMatrix.set(j, i, tempVar); - - tempVar = Klk * gdv2 + Klk * (gcpavv + 1.0 / totalVolume2); - KlkVVMatrix.set(i, j, tempVar); - KlkVVMatrix.set(j, i, tempVar); - - tempVar = Klk * gdv3 - + 3.0 * Klk * (gcpav - 1.0 / totalVolume) * (gcpavv + 1.0 / (totalVolume2)) - + Klk * (gcpavvv - 2.0 / (totalVolume3)); - KlkVVVMatrix.set(i, j, tempVar); - KlkVVVMatrix.set(j, i, tempVar); - - if (type > 1) { - tempVar = deltadT[i][j] / delta[i][j]; - - if (Math.abs(tempVar) > 1e-50) { - double tempVardT = deltadTdT[i][j] / delta[i][j] - - (deltadT[i][j] * deltadT[i][j]) / (delta[i][j] * delta[i][j]); - - tempVar2 = Klk * tempVar; - KlkTMatrix.set(i, j, tempVar2); - KlkTMatrix.set(j, i, tempVar2); - - tempVar2 = Klk * tempVar * (gcpav - 1.0 / totalVolume); - KlkTVMatrix.set(i, j, tempVar2); - KlkTVMatrix.set(j, i, tempVar2); - - tempVar2 = Klk * (tempVar * tempVar + tempVardT); - KlkTTMatrix.set(i, j, tempVar2); - KlkTTMatrix.set(j, i, tempVar2); - } - - if (type > 2) { - for (int p = 0; p < numberOfComponents; p++) { - double t1 = 0.0, t2 = 0.0; - if (moleculeNumber[i] == p) { - t1 = 1.0 / mVector.get(i, 0); - } - if (moleculeNumber[j] == p) { - t2 = 1.0 / mVector.get(j, 0); - } - Klkni[p][i][j] = Klk * (t1 + t2 + lngi[p]);// ((ComponentSrkCPA) - // getComponent(p)).calc_lngi(this)); - Klkni[p][j][i] = Klkni[p][i][j]; - } - } - } - } - tempKsiRead = ksiMatrix.get(i, 0); - QMatksiksiksi.set(i, 0, - 2.0 * mVector.get(i, 0) / (tempKsiRead * tempKsiRead * tempKsiRead)); + deltadTdT[i][j] = + cpamix.calcDeltadTdT(assSiteNumber[i], assSiteNumber[j], moleculeNumber[i], + moleculeNumber[j], this, getTemperature(), getPressure(), numberOfComponents); + deltadTdT[j][i] = deltadTdT[i][j]; } + } + } - SimpleMatrix ksiMatrixTranspose = ksiMatrix.transpose(); - - // dXdV - SimpleMatrix KlkVMatrixksi = KlkVMatrix.mult(ksiMatrix); - SimpleMatrix XV = hessianInvers.mult(KlkVMatrixksi); - SimpleMatrix XVtranspose = XV.transpose(); + double totalVolume = getTotalVolume(); + double totalVolume2 = totalVolume * totalVolume; + double totalVolume3 = totalVolume2 * totalVolume; + double gdv1 = getGcpav() - 1.0 / totalVolume; + double gdv2 = gdv1 * gdv1; + double gdv3 = gdv2 * gdv1; + double Klk = 0.0; + double tempVar; + double tempKsiRead = 0.0; + for (int i = 0; i < totalNumberOfAccociationSites; i++) { + for (int j = i; j < totalNumberOfAccociationSites; j++) { + Klk = KlkMatrix.get(i, j); + tempVar = Klk * gdv1; + KlkVMatrix.set(i, j, tempVar); + KlkVMatrix.set(j, i, tempVar); + + tempVar = Klk * gdv2 + Klk * (gcpavv + 1.0 / totalVolume2); + KlkVVMatrix.set(i, j, tempVar); + KlkVVMatrix.set(j, i, tempVar); + + tempVar = + Klk * gdv3 + 3.0 * Klk * (gcpav - 1.0 / totalVolume) * (gcpavv + 1.0 / (totalVolume2)) + + Klk * (gcpavvv - 2.0 / (totalVolume3)); + KlkVVVMatrix.set(i, j, tempVar); + KlkVVVMatrix.set(j, i, tempVar); - FCPA = mVector.transpose().mult(uMatrix.minus(ksiMatrix.elementMult(udotMatrix).scale(0.5))) - .get(0, 0);// QCPA.get(0, - // 0);//*0.5; + if (type > 1) { + tempVar = deltadT[i][j] / delta[i][j]; - dFCPAdV = ksiMatrixTranspose.mult(KlkVMatrixksi).get(0, 0) * (-0.5); - SimpleMatrix KlkVVMatrixTImesKsi = KlkVVMatrix.mult(ksiMatrix); - dFCPAdVdV = ksiMatrixTranspose.mult(KlkVVMatrixTImesKsi).scale(-0.5) - .minus(KlkVMatrixksi.transpose().mult(XV)).get(0, 0); + if (Math.abs(tempVar) > 1e-50) { + double tempVardT = deltadTdT[i][j] / delta[i][j] + - (deltadT[i][j] * deltadT[i][j]) / (delta[i][j] * delta[i][j]); - SimpleMatrix QVVV = ksiMatrixTranspose.mult(KlkVVVMatrix.mult(ksiMatrix));// .scale(-0.5); - SimpleMatrix QVVksi = KlkVVMatrixTImesKsi.scale(-1.0); - SimpleMatrix QksiVksi = KlkVMatrix.scale(-1.0); + tempVar2 = Klk * tempVar; + KlkTMatrix.set(i, j, tempVar2); + KlkTMatrix.set(j, i, tempVar2); - dFCPAdVdVdV = -0.5 * QVVV.get(0, 0) + QVVksi.transpose().mult(XV).get(0, 0) * 3.0 - + XVtranspose.mult(QksiVksi.mult(XV)).get(0, 0) * 3.0 - + XVtranspose.mult(QMatksiksiksi.mult(XVtranspose)).mult(XV).get(0, 0); + tempVar2 = Klk * tempVar * (gcpav - 1.0 / totalVolume); + KlkTVMatrix.set(i, j, tempVar2); + KlkTVMatrix.set(j, i, tempVar2); - if (type == 1) { - return; - } + tempVar2 = Klk * (tempVar * tempVar + tempVardT); + KlkTTMatrix.set(i, j, tempVar2); + KlkTTMatrix.set(j, i, tempVar2); + } - temp = 0; - for (int p = 0; p < numberOfComponents; p++) { - for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { - ((ComponentCPAInterface) getComponent(p)).setXsitedV(kk, XV.get(temp + kk, 0)); + if (type > 2) { + for (int p = 0; p < numberOfComponents; p++) { + double t1 = 0.0; + double t2 = 0.0; + if (moleculeNumber[i] == p) { + t1 = 1.0 / mVector.get(i, 0); + } + if (moleculeNumber[j] == p) { + t2 = 1.0 / mVector.get(j, 0); + } + Klkni[p][i][j] = Klk * (t1 + t2 + lngi[p]); // ((ComponentSrkCPA) + // getComponent(p)).calc_lngi(this)); + Klkni[p][j][i] = Klkni[p][i][j]; } - temp += getComponent(p).getNumberOfAssociationSites(); + } } + } + tempKsiRead = ksiMatrix.get(i, 0); + QMatksiksiksi.set(i, 0, 2.0 * mVector.get(i, 0) / (tempKsiRead * tempKsiRead * tempKsiRead)); + } - // KlkTMatrix = new SimpleMatrix(KlkdT); - SimpleMatrix KlkTMatrixTImesKsi = KlkTMatrix.mult(ksiMatrix); - // dQdT - SimpleMatrix tempMatrix2 = ksiMatrixTranspose.mult(KlkTMatrixTImesKsi);// .scale(-0.5); - dFCPAdT = tempMatrix2.get(0, 0) * (-0.5); - - // SimpleMatrix KlkTVMatrix = new SimpleMatrix(KlkdTdV); - // SimpleMatrix tempMatrixTV = - // ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5).minus(KlkTMatrixTImesKsi.transpose().mult(XV)); - // dFCPAdTdV = tempMatrixTV.get(0, 0); - // dXdT - SimpleMatrix XT = hessianInvers.mult(KlkTMatrixTImesKsi); - // dQdTdT - SimpleMatrix tempMatrixTT = ksiMatrixTranspose.mult(KlkTTMatrix.mult(ksiMatrix)).scale(-0.5) - .minus(KlkTMatrixTImesKsi.transpose().mult(XT)); - dFCPAdTdT = tempMatrixTT.get(0, 0); - - SimpleMatrix tempMatrixTV = ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5) - .minus(KlkTMatrixTImesKsi.transpose().mult(XV)); - dFCPAdTdV = tempMatrixTV.get(0, 0); - - temp = 0; - for (int p = 0; p < numberOfComponents; p++) { - for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { - ((ComponentCPAInterface) getComponent(p)).setXsitedT(kk, XT.get(temp + kk, 0)); - } - temp += getComponent(p).getNumberOfAssociationSites(); - } + SimpleMatrix ksiMatrixTranspose = ksiMatrix.transpose(); - if (type == 2) { - return; - } + // dXdV + SimpleMatrix KlkVMatrixksi = KlkVMatrix.mult(ksiMatrix); + SimpleMatrix XV = hessianInvers.mult(KlkVMatrixksi); + SimpleMatrix XVtranspose = XV.transpose(); - // int assSites = 0; - // if(true) return; - for (int p = 0; p < numberOfComponents; p++) { - SimpleMatrix KiMatrix = new SimpleMatrix(Klkni[p]); - // KiMatrix.print(10,10); - // Matrix dQdniMatrix = - // (ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5)); // this - // methods misses one part of .... - // dQdniMatrix.print(10,10); - // KiMatrix.print(10, 10); - // miMatrix.getMatrix(assSites, assSites, 0, totalNumberOfAccociationSites - - // 1).print(10, 10); - // Matrix tempMatrix20 = miMatrix.getMatrix(assSites, assSites, 0, - // totalNumberOfAccociationSites - - // 1).times(uMatrix).minus(ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5));// - // ksiMatrix.transpose().times(KlkTMatrix.times(ksiMatrix)).times(-0.5); - // System.out.println("dQdn "); - // tempMatrix20.print(10, 10); - SimpleMatrix tempMatrix4 = KiMatrix.mult(ksiMatrix); - // udotTimesmiMatrix.getMatrix(assSites, assSites, 0, - // totalNumberOfAccociationSites - 1).print(10, 10); - SimpleMatrix tempMatrix5 = - udotTimesmiMatrix.extractVector(true, p).transpose().minus(tempMatrix4); - // tempMki[0] = mki[p]; - // Matrix amatrix = new Matrix(croeneckerProduct(tempMki, - // udotMatrix.getArray())); - // System.out.println("aMatrix "); - // amatrix.transpose().print(10, 10); - // System.out.println("temp4 matrix"); - // tempMatrix4.print(10, 10); - // Matrix tempMatrix5 = amatrix.minus(tempMatrix4); - SimpleMatrix tempMatrix6 = hessianInvers.mult(tempMatrix5);// .scale(-1.0); - // System.out.println("dXdni"); - // tempMatrix4.print(10, 10); - // tempMatrix5.print(10, 10); - // System.out.println("dXdn "); - // tempMatrix6.print(10, 10); - int temp2 = 0; - for (int compp = 0; compp < numberOfComponents; compp++) { - for (int kk = 0; kk < getComponent(compp).getNumberOfAssociationSites(); kk++) { - ((ComponentCPAInterface) getComponent(compp)).setXsitedni(kk, p, - -1.0 * tempMatrix6.get(temp2 + kk, 0)); - } - temp2 += getComponent(compp).getNumberOfAssociationSites(); - } - // assSites += getComponent(p).getNumberOfAssociationSites(); - } - } - - /** {@inheritDoc} */ - @Override - public void setMixingRule(int type) { - super.setMixingRule(type); - cpamix = cpaSelect.getMixingRule(1, this); - } + FCPA = mVector.transpose().mult(uMatrix.minus(ksiMatrix.elementMult(udotMatrix).scale(0.5))) + .get(0, 0); // QCPA.get(0, + // 0); //*0.5; - /** - *

- * calcDelta. - *

- */ - public void calcDelta() { - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - deltaNog[i][j] = cpamix.calcDeltaNog(assSiteNumber[i], assSiteNumber[j], - moleculeNumber[i], moleculeNumber[j], this, getTemperature(), getPressure(), - numberOfComponents); - deltaNog[j][i] = deltaNog[i][j]; - } - } - } + dFCPAdV = ksiMatrixTranspose.mult(KlkVMatrixksi).get(0, 0) * (-0.5); + SimpleMatrix KlkVVMatrixTImesKsi = KlkVVMatrix.mult(ksiMatrix); + dFCPAdVdV = ksiMatrixTranspose.mult(KlkVVMatrixTImesKsi).scale(-0.5) + .minus(KlkVMatrixksi.transpose().mult(XV)).get(0, 0); - /** {@inheritDoc} */ - @Override - public void addcomponent(String componentName, double moles, double molesInPhase, - int compNumber) { - super.addcomponent(componentName, moles, molesInPhase, compNumber); - componentArray[compNumber] = - new ComponentUMRCPA(componentName, moles, molesInPhase, compNumber); - } + SimpleMatrix QVVV = ksiMatrixTranspose.mult(KlkVVVMatrix.mult(ksiMatrix)); // .scale(-0.5); + SimpleMatrix QVVksi = KlkVVMatrixTImesKsi.scale(-1.0); + SimpleMatrix QksiVksi = KlkVMatrix.scale(-1.0); - /** {@inheritDoc} */ - @Override - public double getF() { - return super.getF() + cpaon * FCPA(); - } + dFCPAdVdVdV = -0.5 * QVVV.get(0, 0) + QVVksi.transpose().mult(XV).get(0, 0) * 3.0 + + XVtranspose.mult(QksiVksi.mult(XV)).get(0, 0) * 3.0 + + XVtranspose.mult(QMatksiksiksi.mult(XVtranspose)).mult(XV).get(0, 0); - /** {@inheritDoc} */ - @Override - public double dFdT() { - return super.dFdT() + cpaon * dFCPAdT(); + if (type == 1) { + return; } - /** {@inheritDoc} */ - @Override - public double dFdTdV() { - return super.dFdTdV() + cpaon * dFCPAdTdV(); + temp = 0; + for (int p = 0; p < numberOfComponents; p++) { + for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { + ((ComponentCPAInterface) getComponent(p)).setXsitedV(kk, XV.get(temp + kk, 0)); + } + temp += getComponent(p).getNumberOfAssociationSites(); } - /** {@inheritDoc} */ - @Override - public double dFdV() { - double dv2 = dFCPAdV(); - return super.dFdV() + cpaon * dv2; + // KlkTMatrix = new SimpleMatrix(KlkdT); + SimpleMatrix KlkTMatrixTImesKsi = KlkTMatrix.mult(ksiMatrix); + // dQdT + SimpleMatrix tempMatrix2 = ksiMatrixTranspose.mult(KlkTMatrixTImesKsi); // .scale(-0.5); + dFCPAdT = tempMatrix2.get(0, 0) * (-0.5); + + // SimpleMatrix KlkTVMatrix = new SimpleMatrix(KlkdTdV); + // SimpleMatrix tempMatrixTV = + // ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5).minus(KlkTMatrixTImesKsi.transpose().mult(XV)); + // dFCPAdTdV = tempMatrixTV.get(0, 0); + // dXdT + SimpleMatrix XT = hessianInvers.mult(KlkTMatrixTImesKsi); + // dQdTdT + SimpleMatrix tempMatrixTT = ksiMatrixTranspose.mult(KlkTTMatrix.mult(ksiMatrix)).scale(-0.5) + .minus(KlkTMatrixTImesKsi.transpose().mult(XT)); + dFCPAdTdT = tempMatrixTT.get(0, 0); + + SimpleMatrix tempMatrixTV = ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5) + .minus(KlkTMatrixTImesKsi.transpose().mult(XV)); + dFCPAdTdV = tempMatrixTV.get(0, 0); + + temp = 0; + for (int p = 0; p < numberOfComponents; p++) { + for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { + ((ComponentCPAInterface) getComponent(p)).setXsitedT(kk, XT.get(temp + kk, 0)); + } + temp += getComponent(p).getNumberOfAssociationSites(); } - // @Override - /** {@inheritDoc} */ - @Override - public double dFdVdV() { - return super.dFdVdV() + cpaon * dFCPAdVdV(); + if (type == 2) { + return; } - /** {@inheritDoc} */ - @Override - public double dFdVdVdV() { - return super.dFdVdVdV() + cpaon * dFCPAdVdVdV(); + // int assSites = 0; + // if(true) return; + for (int p = 0; p < numberOfComponents; p++) { + SimpleMatrix KiMatrix = new SimpleMatrix(Klkni[p]); + // KiMatrix.print(10,10); + // Matrix dQdniMatrix = + // (ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5)); // this + // methods misses one part of .... + // dQdniMatrix.print(10,10); + // KiMatrix.print(10, 10); + // miMatrix.getMatrix(assSites, assSites, 0, totalNumberOfAccociationSites - + // 1).print(10, 10); + // Matrix tempMatrix20 = miMatrix.getMatrix(assSites, assSites, 0, + // totalNumberOfAccociationSites - + // 1).times(uMatrix).minus(ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5)); + // // + // ksiMatrix.transpose().times(KlkTMatrix.times(ksiMatrix)).times(-0.5); + // System.out.println("dQdn "); + // tempMatrix20.print(10, 10); + SimpleMatrix tempMatrix4 = KiMatrix.mult(ksiMatrix); + // udotTimesmiMatrix.getMatrix(assSites, assSites, 0, + // totalNumberOfAccociationSites - 1).print(10, 10); + SimpleMatrix tempMatrix5 = + udotTimesmiMatrix.extractVector(true, p).transpose().minus(tempMatrix4); + // tempMki[0] = mki[p]; + // Matrix amatrix = new Matrix(croeneckerProduct(tempMki, + // udotMatrix.getArray())); + // System.out.println("aMatrix "); + // amatrix.transpose().print(10, 10); + // System.out.println("temp4 matrix"); + // tempMatrix4.print(10, 10); + // Matrix tempMatrix5 = amatrix.minus(tempMatrix4); + SimpleMatrix tempMatrix6 = hessianInvers.mult(tempMatrix5); // .scale(-1.0); + // System.out.println("dXdni"); + // tempMatrix4.print(10, 10); + // tempMatrix5.print(10, 10); + // System.out.println("dXdn "); + // tempMatrix6.print(10, 10); + int temp2 = 0; + for (int compp = 0; compp < numberOfComponents; compp++) { + for (int kk = 0; kk < getComponent(compp).getNumberOfAssociationSites(); kk++) { + ((ComponentCPAInterface) getComponent(compp)).setXsitedni(kk, p, + -1.0 * tempMatrix6.get(temp2 + kk, 0)); + } + temp2 += getComponent(compp).getNumberOfAssociationSites(); + } + // assSites += getComponent(p).getNumberOfAssociationSites(); } - - /** {@inheritDoc} */ - @Override - public double dFdTdT() { - return super.dFdTdT() + cpaon * dFCPAdTdT(); + } + + /** {@inheritDoc} */ + @Override + public void setMixingRule(int type) { + super.setMixingRule(type); + cpamix = cpaSelect.getMixingRule(1, this); + } + + /** + *

+ * calcDelta. + *

+ */ + public void calcDelta() { + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + deltaNog[i][j] = cpamix.calcDeltaNog(assSiteNumber[i], assSiteNumber[j], moleculeNumber[i], + moleculeNumber[j], this, getTemperature(), getPressure(), numberOfComponents); + deltaNog[j][i] = deltaNog[i][j]; + } } - - /** - *

- * FCPA. - *

- * - * @return a double - */ - public double FCPA() { - /* - * double tot = 0.0; double ans = 0.0; for (int i = 0; i < numberOfComponents; i++) { tot = - * 0.0; for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { double - * xai = ((ComponentSrkCPA) componentArray[i]).getXsite()[j]; tot += (Math.log(xai) - 1.0 / - * 2.0 * xai + 1.0 / 2.0); } ans += componentArray[i].getNumberOfMolesInPhase() * tot; } - * return ans; - */ - return FCPA; - } - - /** - *

- * dFCPAdV. - *

- * - * @return a double - */ - public double dFCPAdV() { - // return 1.0 / (2.0 * getTotalVolume()) * (1.0 - getTotalVolume() * getGcpav()) - // * hcpatot; - return dFCPAdV; - } - - /** - *

- * dFCPAdVdV. - *

- * - * @return a double - */ - public double dFCPAdVdV() { - // double sum1 = -1.0 / 2.0 * gcpavv * hcpatot; - // return -1.0 / getTotalVolume() * dFCPAdV() + sum1; - return dFCPAdVdV; - } - - /** - *

- * dFCPAdVdVdV. - *

- * - * @return a double + } + + /** {@inheritDoc} */ + @Override + public void addcomponent(String componentName, double moles, double molesInPhase, + int compNumber) { + super.addcomponent(componentName, moles, molesInPhase, compNumber); + componentArray[compNumber] = + new ComponentUMRCPA(componentName, moles, molesInPhase, compNumber); + } + + /** {@inheritDoc} */ + @Override + public double getF() { + return super.getF() + cpaon * FCPA(); + } + + /** {@inheritDoc} */ + @Override + public double dFdT() { + return super.dFdT() + cpaon * dFCPAdT(); + } + + /** {@inheritDoc} */ + @Override + public double dFdTdV() { + return super.dFdTdV() + cpaon * dFCPAdTdV(); + } + + /** {@inheritDoc} */ + @Override + public double dFdV() { + double dv2 = dFCPAdV(); + return super.dFdV() + cpaon * dv2; + } + + // @Override + /** {@inheritDoc} */ + @Override + public double dFdVdV() { + return super.dFdVdV() + cpaon * dFCPAdVdV(); + } + + /** {@inheritDoc} */ + @Override + public double dFdVdVdV() { + return super.dFdVdVdV() + cpaon * dFCPAdVdVdV(); + } + + /** {@inheritDoc} */ + @Override + public double dFdTdT() { + return super.dFdTdT() + cpaon * dFCPAdTdT(); + } + + /** + *

+ * FCPA. + *

+ * + * @return a double + */ + public double FCPA() { + /* + * double tot = 0.0; double ans = 0.0; for (int i = 0; i < numberOfComponents; i++) { tot = 0.0; + * for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { double xai = + * ((ComponentSrkCPA) componentArray[i]).getXsite()[j]; tot += (Math.log(xai) - 1.0 / 2.0 * xai + * + 1.0 / 2.0); } ans += componentArray[i].getNumberOfMolesInPhase() * tot; } return ans; */ - public double dFCPAdVdVdV() { - return dFCPAdVdVdV; - // return -1.0 / getTotalVolume() * dFCPAdVdV() + 1.0 / - // Math.pow(getTotalVolume(), 2.0) * dFCPAdV() - hcpatot / (2.0 * - // Math.pow(getTotalVolume(), 2.0)) * (-getGcpav() - getTotalVolume() * gcpavv) - // + hcpatot / (2.0 * getTotalVolume()) * (-gcpavv - getTotalVolume() * gcpavvv - // - gcpavv); - } - - /** - *

- * dFCPAdT. - *

- * - * @return a double + return FCPA; + } + + /** + *

+ * dFCPAdV. + *

+ * + * @return a double + */ + public double dFCPAdV() { + // return 1.0 / (2.0 * getTotalVolume()) * (1.0 - getTotalVolume() * getGcpav()) + // * hcpatot; + return dFCPAdV; + } + + /** + *

+ * dFCPAdVdV. + *

+ * + * @return a double + */ + public double dFCPAdVdV() { + // double sum1 = -1.0 / 2.0 * gcpavv * hcpatot; + // return -1.0 / getTotalVolume() * dFCPAdV() + sum1; + return dFCPAdVdV; + } + + /** + *

+ * dFCPAdVdVdV. + *

+ * + * @return a double + */ + public double dFCPAdVdVdV() { + return dFCPAdVdVdV; + // return -1.0 / getTotalVolume() * dFCPAdVdV() + 1.0 / + // Math.pow(getTotalVolume(), 2.0) * dFCPAdV() - hcpatot / (2.0 * + // Math.pow(getTotalVolume(), 2.0)) * (-getGcpav() - getTotalVolume() * gcpavv) + // + hcpatot / (2.0 * getTotalVolume()) * (-gcpavv - getTotalVolume() * gcpavvv + // - gcpavv); + } + + /** + *

+ * dFCPAdT. + *

+ * + * @return a double + */ + public double dFCPAdT() { + /* + * double tot = 0.0; double ans = 0.0; for (int i = 0; i < numberOfComponents; i++) { tot = 0.0; + * for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { double xai = + * ((ComponentSrkCPA) componentArray[i]).getXsite()[j]; double xaidT = ((ComponentSrkCPA) + * componentArray[i]).getXsitedT()[j]; tot += 1.0 / xai * xaidT - 0.5 * xaidT; // - 1.0 / 2.0 * + * xai + 1.0 / 2.0); } ans += componentArray[i].getNumberOfMolesInPhase() * tot; } + * System.out.println("dFCPAdT1 " + ans + " dfcpa2 " +dFCPAdT); return ans; */ - public double dFCPAdT() { - /* - * double tot = 0.0; double ans = 0.0; for (int i = 0; i < numberOfComponents; i++) { tot = - * 0.0; for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { double - * xai = ((ComponentSrkCPA) componentArray[i]).getXsite()[j]; double xaidT = - * ((ComponentSrkCPA) componentArray[i]).getXsitedT()[j]; tot += 1.0 / xai * xaidT - 0.5 * - * xaidT;// - 1.0 / 2.0 * xai + 1.0 / 2.0); } ans += - * componentArray[i].getNumberOfMolesInPhase() * tot; } System.out.println("dFCPAdT1 " + - * ans + " dfcpa2 " +dFCPAdT); return ans; - */ - return dFCPAdT; - } - - /** - *

- * dFCPAdTdT. - *

- * - * @return a double + return dFCPAdT; + } + + /** + *

+ * dFCPAdTdT. + *

+ * + * @return a double + */ + public double dFCPAdTdT() { + return dFCPAdTdT; + } + + /** + *

+ * dFCPAdTdV. + *

+ * + * @return a double + */ + public double dFCPAdTdV() { + // System.out.println("dFCPAdTdV1 " + dFCPAdTdV + " dFCPAdTdV " +( 1.0 / (2.0 * + // getTotalVolume()) * (1.0 - getTotalVolume() * getGcpav()) * hcpatotdT)); + return dFCPAdTdV; + /* + * if (totalNumberOfAccociationSites > 0) { return 1.0 / (2.0 * getTotalVolume()) * (1.0 - + * getTotalVolume() * getGcpav()) * hcpatotdT; } else { return 0; } */ - public double dFCPAdTdT() { - return dFCPAdTdT; + } + + /** {@inheritDoc} */ + @Override + public double molarVolume(double pressure, double temperature, double A, double B, int phasetype) + throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + + if (BonV < 0) { + BonV = 1.0e-8; } - /** - *

- * dFCPAdTdV. - *

- * - * @return a double - */ - public double dFCPAdTdV() { - // System.out.println("dFCPAdTdV1 " + dFCPAdTdV + " dFCPAdTdV " +( 1.0 / (2.0 * - // getTotalVolume()) * (1.0 - getTotalVolume() * getGcpav()) * hcpatotdT)); - return dFCPAdTdV; - /* - * if (totalNumberOfAccociationSites > 0) { return 1.0 / (2.0 * getTotalVolume()) * (1.0 - - * getTotalVolume() * getGcpav()) * hcpatotdT; } else { return 0; } - */ - } - - /** {@inheritDoc} */ - @Override - public double molarVolume(double pressure, double temperature, double A, double B, - int phasetype) throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - - if (BonV < 0) { - BonV = 1.0e-8; - } - - if (BonV >= 1.0) { - BonV = 0.9999; - } - double BonVold; - double BonV2; - double h = 0, dh = 0, dhh = 0; - double d1 = 0, d2 = 0; - double Btemp = getB(); - if (Btemp < 0) { - logger.info("b negative in volume calc"); - } - - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - int iterations = 0; - int maxIterations = 300; - do { - iterations++; - gcpa = calc_g(); - if (gcpa < 0) { - setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); - gcpa = calc_g(); - } - - // lngcpa = - // Math.log(gcpa); - gcpav = calc_lngV(); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); + if (BonV >= 1.0) { + BonV = 0.9999; + } + double BonVold; + double BonV2; + double h = 0; + double dh = 0; + double dhh = 0; + double d1 = 0; + double d2 = 0; + double Btemp = getB(); + if (Btemp < 0) { + logger.info("b negative in volume calc"); + } - if (totalNumberOfAccociationSites > 0) { - solveX(); - } + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + int iterations = 0; + int maxIterations = 300; + do { + iterations++; + gcpa = calc_g(); + if (gcpa < 0) { + setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); + gcpa = calc_g(); + } - initCPAMatrix(1); - - BonV2 = BonV * BonV; - BonVold = BonV; - h = BonV - Btemp / numberOfMolesInPhase * dFdV() - - pressure * Btemp / (numberOfMolesInPhase * R * temperature); - dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); - dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) - - (Btemp * Btemp) / (BonV2 * BonV2) - * (Btemp / numberOfMolesInPhase * dFdVdVdV()); - - d1 = -h / dh; - d2 = -dh / dhh; - // System.out.println("h " + h + " iter " + iterations + " " + d1 + " d2 " + d2 - // + " d1 / d2 " + (d1 / d2)); - if (Math.abs(d1 / d2) <= 1.0) { - BonV += d1 * (1.0 + 0.5 * d1 / d2); - } else if (d1 / d2 < -1) { - BonV += 0.5 * d1; - } else if (d1 > d2) { - return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - // BonV += d2; - // double hnew = h + d2 * dh; - // if (Math.abs(hnew) > Math.abs(h)) { - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / - // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * - // temperature * R); - // } - } else { - BonV += 0.5 * d1; - } - if (Math.abs((BonV - BonVold) / BonV) > 0.1) { - BonV = BonVold + 0.1 * (BonV - BonVold); - } - if (BonV < 0) { - if (iterations < 10) { - // System.out.println(iterations + " BonV " + BonV); - BonV = (BonVold + BonV) / 2.0; - } else { - return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - } - } + // lngcpa = + // Math.log(gcpa); + gcpav = calc_lngV(); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); - if (BonV >= 1.0) { - if (iterations < 10) { - BonV = (BonVold + BonV) / 2.0; - } else { - return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - } - } - /* - * if (BonV > 0.9999) { if (iterations < 10) { BonV = (BonVold + BonV) / 2.0; } else { - * // BonV = calcRootVolFinder(phasetype); // BonV = molarVolumeChangePhase(pressure, - * temperature, A, B, phasetype); // BonV = 0.9999; // BonV = phasetype == 1 ? 2.0 / - * (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / - * (numberOfMolesInPhase * temperature * R); } - * - * } else if (BonV < 0) { if (iterations < 10) { BonV = Math.abs(BonVold + BonV) / 2.0; - * } else { // BonV = calcRootVolFinder(phasetype); // return - * molarVolumeChangePhase(pressure, temperature, A, B, phasetype); // BonV = phasetype - * == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() - * / (numberOfMolesInPhase * temperature * R); } } - */ - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10 || Math.abs(h) > 1e-12) - && iterations < maxIterations); - - // System.out.println("h failed " + h + " Z" + Z + " iterations " + iterations + - // " BonV " + BonV); - // if (Math.abs(h) > 1e-12) { - // System.out.println("h failed " + h + " Z" + Z + " iterations " + iterations + - // " BonV " + BonV); - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + if (totalNumberOfAccociationSites > 0) { + solveX(); + } + + initCPAMatrix(1); + + BonV2 = BonV * BonV; + BonVold = BonV; + h = BonV - Btemp / numberOfMolesInPhase * dFdV() + - pressure * Btemp / (numberOfMolesInPhase * R * temperature); + dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); + dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) + - (Btemp * Btemp) / (BonV2 * BonV2) * (Btemp / numberOfMolesInPhase * dFdVdVdV()); + + d1 = -h / dh; + d2 = -dh / dhh; + // System.out.println("h " + h + " iter " + iterations + " " + d1 + " d2 " + d2 + // + " d1 / d2 " + (d1 / d2)); + if (Math.abs(d1 / d2) <= 1.0) { + BonV += d1 * (1.0 + 0.5 * d1 / d2); + } else if (d1 / d2 < -1) { + BonV += 0.5 * d1; + } else if (d1 > d2) { + return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // BonV += d2; + // double hnew = h + d2 * dh; + // if (Math.abs(hnew) > Math.abs(h)) { + // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * + // temperature * R); // } - // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); - // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); - // System.out.println("volume " + getTotalVolume() + " molar volume " + - // getMolarVolume()); - // if(iterations>=100) throw new util.exception.TooManyIterationsException(); - // System.out.println("error in volume " + - // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " - // firstterm " + (R*temperature/molarVolume) + " second " + - // R*temperature*dFdV()); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " - // " +dh + " B " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); - if (Double.isNaN(getMolarVolume())) { - throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " - // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" - // + fVV()); + } else { + BonV += 0.5 * d1; + } + if (Math.abs((BonV - BonVold) / BonV) > 0.1) { + BonV = BonVold + 0.1 * (BonV - BonVold); + } + if (BonV < 0) { + if (iterations < 10) { + // System.out.println(iterations + " BonV " + BonV); + BonV = (BonVold + BonV) / 2.0; + } else { + return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); } - dFdNtemp = calcdFdNtemp(); - return getMolarVolume(); - } + } - /** - * @return double[] - */ - double[] calcdFdNtemp() { - double tot1 = 0.0, tot2 = 0.0, tot3 = 0.0, tot4 = 0.0; - // double temp, temp2; - for (int k = 0; k < getNumberOfComponents(); k++) { - tot2 = 0.0; - tot3 = 0.0; - // temp = ((ComponentSrkCPA) getComponent(k)).calc_lngi(this); - // temp2 = ((ComponentSrkCPA) getComponent(k)).calc_lngidV(this); - for (int i = 0; i < getComponent(k).getNumberOfAssociationSites(); i++) { - tot2 -= 1.0 * ((ComponentUMRCPA) getComponent(k)).getXsitedV()[i]; - tot3 += (1.0 - ((ComponentUMRCPA) getComponent(k)).getXsite()[i]) * 1.0; - } - tot1 += 1.0 / 2.0 * tot2 * getComponent(k).getNumberOfMolesInPhase(); - tot4 += 0.5 * getComponent(k).getNumberOfMolesInPhase() * tot3; - } - return new double[] {-tot1, -tot4}; + if (BonV >= 1.0) { + if (iterations < 10) { + BonV = (BonVold + BonV) / 2.0; + } else { + return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + } + } + /* + * if (BonV > 0.9999) { if (iterations < 10) { BonV = (BonVold + BonV) / 2.0; } else { // BonV + * = calcRootVolFinder(phasetype); // BonV = molarVolumeChangePhase(pressure, temperature, A, + * B, phasetype); // BonV = 0.9999; // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + * getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * + * R); } + * + * } else if (BonV < 0) { if (iterations < 10) { BonV = Math.abs(BonVold + BonV) / 2.0; } else + * { // BonV = calcRootVolFinder(phasetype); // return molarVolumeChangePhase(pressure, + * temperature, A, B, phasetype); // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + * getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * + * R); } } + */ + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); + } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10 || Math.abs(h) > 1e-12) + && iterations < maxIterations); + + // System.out.println("h failed " + h + " Z" + Z + " iterations " + iterations + + // " BonV " + BonV); + // if (Math.abs(h) > 1e-12) { + // System.out.println("h failed " + h + " Z" + Z + " iterations " + iterations + + // " BonV " + BonV); + // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // } + // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); + // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); + // System.out.println("volume " + getTotalVolume() + " molar volume " + + // getMolarVolume()); + // if(iterations>=100) throw new util.exception.TooManyIterationsException(); + // System.out.println("error in volume " + + // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV())); // + " + // firstterm " + (R*temperature/molarVolume) + " second " + + // R*temperature*dFdV()); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " + // " +dh + " B " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); + if (Double.isNaN(getMolarVolume())) { + throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " + // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + // + fVV()); } - - /** - *

- * calc_hCPA. - *

- * - * @return a double - */ - public double calc_hCPA() { - double htot = 0.0; - double tot = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - htot = 0.0; - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - htot += (1.0 - ((ComponentUMRCPA) componentArray[i]).getXsite()[j]); - } - tot += componentArray[i].getNumberOfMolesInPhase() * htot; - } - return tot; + dFdNtemp = calcdFdNtemp(); + return getMolarVolume(); + } + + /** + * @return double[] + */ + double[] calcdFdNtemp() { + double tot1 = 0.0; + double tot2 = 0.0; + double tot3 = 0.0; + double tot4 = 0.0; + // double temp, temp2; + for (int k = 0; k < getNumberOfComponents(); k++) { + tot2 = 0.0; + tot3 = 0.0; + // temp = ((ComponentSrkCPA) getComponent(k)).calc_lngi(this); + // temp2 = ((ComponentSrkCPA) getComponent(k)).calc_lngidV(this); + for (int i = 0; i < getComponent(k).getNumberOfAssociationSites(); i++) { + tot2 -= 1.0 * ((ComponentUMRCPA) getComponent(k)).getXsitedV()[i]; + tot3 += (1.0 - ((ComponentUMRCPA) getComponent(k)).getXsite()[i]) * 1.0; + } + tot1 += 1.0 / 2.0 * tot2 * getComponent(k).getNumberOfMolesInPhase(); + tot4 += 0.5 * getComponent(k).getNumberOfMolesInPhase() * tot3; } - - /** - *

- * calc_g. - *

- * - * @return a double - */ - public double calc_g() { - tempTotVol = getMolarVolume(); - double temp = 1.0 - getb() / 4.0 / tempTotVol; - return (2.0 - getb() / 4.0 / tempTotVol) / (2.0 * temp * temp * temp); - } - - /** - *

- * calc_lngV. - *

- * - * @return a double - */ - public double calc_lngV() { - tempTotVol = getMolarVolume(); - // gv = -2.0 * getB() * (10.0 * getTotalVolume() - getB()) / getTotalVolume() / - // ((8.0 * getTotalVolume() - getB()) * (4.0 * getTotalVolume() - getB())); - return 1.0 / (2.0 - getB() / (4.0 * tempTotVol)) * getB() / (4.0 * tempTotVol * tempTotVol) - - 3.0 / (1.0 - getB() / (4.0 * tempTotVol)) * getB() - / (4.0 * tempTotVol * tempTotVol); - } - - /** - *

- * calc_lngVV. - *

- * - * @return a double - */ - public double calc_lngVV() { - tempTotVol = getMolarVolume(); - return 2.0 - * (640.0 * Math.pow(tempTotVol, 3.0) - 216.0 * getB() * tempTotVol * tempTotVol - + 24.0 * Math.pow(getB(), 2.0) * tempTotVol - Math.pow(getB(), 3.0)) - * getB() / (tempTotVol * tempTotVol) / Math.pow(8.0 * tempTotVol - getB(), 2.0) - / Math.pow(4.0 * tempTotVol - getB(), 2.0); - } - - /** - *

- * calc_lngVVV. - *

- * - * @return a double - */ - public double calc_lngVVV() { - tempTotVol = getMolarVolume(); - return 4.0 - * (Math.pow(getB(), 5.0) + 17664.0 * Math.pow(tempTotVol, 4.0) * getB() - - 4192.0 * Math.pow(tempTotVol, 3.0) * Math.pow(getB(), 2.0) - + 528.0 * Math.pow(getB(), 3.0) * tempTotVol * tempTotVol - - 36.0 * tempTotVol * Math.pow(getB(), 4.0) - - 30720.0 * Math.pow(tempTotVol, 5.0)) - * getB() / (Math.pow(tempTotVol, 3.0)) / Math.pow(-8.0 * tempTotVol + getB(), 3.0) - / Math.pow(-4.0 * tempTotVol + getB(), 3.0); - } - - /** - *

- * calcXsitedV. - *

- */ - public void calcXsitedV() { - if (getTotalNumberOfAccociationSites() > 0) { - initCPAMatrix(1); - } + return new double[] {-tot1, -tot4}; + } + + /** + *

+ * calc_hCPA. + *

+ * + * @return a double + */ + public double calc_hCPA() { + double htot = 0.0; + double tot = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + htot = 0.0; + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + htot += (1.0 - ((ComponentUMRCPA) componentArray[i]).getXsite()[j]); + } + tot += componentArray[i].getNumberOfMolesInPhase() * htot; + } + return tot; + } + + /** + *

+ * calc_g. + *

+ * + * @return a double + */ + public double calc_g() { + tempTotVol = getMolarVolume(); + double temp = 1.0 - getb() / 4.0 / tempTotVol; + return (2.0 - getb() / 4.0 / tempTotVol) / (2.0 * temp * temp * temp); + } + + /** + *

+ * calc_lngV. + *

+ * + * @return a double + */ + public double calc_lngV() { + tempTotVol = getMolarVolume(); + // gv = -2.0 * getB() * (10.0 * getTotalVolume() - getB()) / getTotalVolume() / + // ((8.0 * getTotalVolume() - getB()) * (4.0 * getTotalVolume() - getB())); + return 1.0 / (2.0 - getB() / (4.0 * tempTotVol)) * getB() / (4.0 * tempTotVol * tempTotVol) + - 3.0 / (1.0 - getB() / (4.0 * tempTotVol)) * getB() / (4.0 * tempTotVol * tempTotVol); + } + + /** + *

+ * calc_lngVV. + *

+ * + * @return a double + */ + public double calc_lngVV() { + tempTotVol = getMolarVolume(); + return 2.0 + * (640.0 * Math.pow(tempTotVol, 3.0) - 216.0 * getB() * tempTotVol * tempTotVol + + 24.0 * Math.pow(getB(), 2.0) * tempTotVol - Math.pow(getB(), 3.0)) + * getB() / (tempTotVol * tempTotVol) / Math.pow(8.0 * tempTotVol - getB(), 2.0) + / Math.pow(4.0 * tempTotVol - getB(), 2.0); + } + + /** + *

+ * calc_lngVVV. + *

+ * + * @return a double + */ + public double calc_lngVVV() { + tempTotVol = getMolarVolume(); + return 4.0 * (Math.pow(getB(), 5.0) + 17664.0 * Math.pow(tempTotVol, 4.0) * getB() + - 4192.0 * Math.pow(tempTotVol, 3.0) * Math.pow(getB(), 2.0) + + 528.0 * Math.pow(getB(), 3.0) * tempTotVol * tempTotVol + - 36.0 * tempTotVol * Math.pow(getB(), 4.0) - 30720.0 * Math.pow(tempTotVol, 5.0)) + * getB() / (Math.pow(tempTotVol, 3.0)) / Math.pow(-8.0 * tempTotVol + getB(), 3.0) + / Math.pow(-4.0 * tempTotVol + getB(), 3.0); + } + + /** + *

+ * calcXsitedV. + *

+ */ + public void calcXsitedV() { + if (getTotalNumberOfAccociationSites() > 0) { + initCPAMatrix(1); + } + } + + /** + *

+ * solveX. + *

+ * + * @return a boolean + */ + public boolean solveX() { + if (totalNumberOfAccociationSites == 0) { + return true; } - /** - *

- * solveX. - *

- * - * @return a boolean - */ - public boolean solveX() { - if (totalNumberOfAccociationSites == 0) { - return true; - } - - boolean solvedX = solveX2(15); - - DMatrixRMaj mVectorMat = mVector.getMatrix(); - DMatrixRMaj ksiMatrixMat = ksiMatrix.getMatrix(); - - // ksiMatrix.print(); - // second order method not working correctly and not used t the moment b ecause of numerical - // stability - int temp = 0, iter = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - mVectorMat.unsafe_set(temp + j, 0, componentArray[i].getNumberOfMolesInPhase()); - } - temp += componentArray[i].getNumberOfAssociationSites(); - } - - DMatrixRMaj mat1 = KlkMatrix.getMatrix(); - double Klk = 0.0; - double totvolume = getTotalVolume(); - double tempVari, tempVarj; - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - tempVari = mVectorMat.unsafe_get(i, 0); - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - tempVarj = mVectorMat.unsafe_get(j, 0); - Klk = tempVari * tempVarj / totvolume * delta[i][j]; - mat1.unsafe_set(i, j, Klk); - mat1.unsafe_set(j, i, Klk); - } - } - boolean solved = true; - // SimpleMatrix corrMatrix = null; - do { - solved = true; - iter++; - temp = 0; - double ksi = 0; - - double temp1, temp2; - for (int i = 0; i < numberOfComponents; i++) { - temp1 = componentArray[i].getNumberOfMolesInPhase(); - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - ksi = ((ComponentUMRCPA) componentArray[i]).getXsite()[j]; - ksiMatrixMat.unsafe_set(temp + j, 0, ksi); - // ksiMatrix.getMatrix().unsafe_set(temp + j, 0, - // ksiMatrix.getMatrix().unsafe_get(temp + j, 0)); - tempVari = 1.0 / ksi - 1.0; - udotMatrix.set(temp + j, 0, tempVari); - udotTimesmMatrix.set(temp + j, 0, temp1 * tempVari); - } - temp += componentArray[i].getNumberOfAssociationSites(); - } - - int krondelt; - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - temp1 = mVectorMat.unsafe_get(i, 0); - temp2 = ksiMatrix.get(i, 0); - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - krondelt = 0; - if (i == j) { - krondelt = 1; - } - tempVari = -temp1 / (temp2 * temp2) * krondelt - mat1.unsafe_get(i, j); - hessianMatrix.set(i, j, tempVari); - hessianMatrix.set(j, i, tempVari); - } - } - - // ksiMatrix = new SimpleMatrix(ksi); - // SimpleMatrix hessianMatrix = new SimpleMatrix(hessian); - try { - hessianInvers = hessianMatrix.invert(); - } catch (Exception e) { - logger.error("error", e); - return false; - } - if (solvedX) { - // System.out.println("solvedX "); - return true; - } - - DMatrixRMaj mat2 = ksiMatrix.getMatrix(); - CommonOps_DDRM.mult(mat1, mat2, corr2Matrix); - CommonOps_DDRM.subtract(udotTimesmMatrix.getDDRM(), corr2Matrix, corr3Matrix); - CommonOps_DDRM.mult(hessianInvers.getDDRM(), corr3Matrix, corr4Matrix); - // SimpleMatrix gMatrix = udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)); - // corrMatrix = - // hessianInvers.mult(udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)));//.scale(-1.0); - temp = 0; - // System.out.println("print SimpleMatrix ..."); - // corrMatrix.print(10, 10); - // SimpleMatrix simp = new SimpleMatrix(corr4Matrix); - // System.out.println("print CommonOps ..."); - // simp.print(10,10); - double newX; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - newX = ksiMatrix.get(temp + j, 0) - corr4Matrix.unsafe_get((temp + j), 0); - if (newX < 0) { - newX = 1e-10; - solved = false; - } - ((ComponentCPAInterface) componentArray[i]).setXsite(j, newX); - } - temp += componentArray[i].getNumberOfAssociationSites(); - } - // System.out.println("corrmatrix error " ); - // System.out.println("error " + NormOps_DDRM.normF(corr4Matrix)); - } while ((NormOps_DDRM.normF(corr4Matrix) > 1e-12 || !solved) && iter < 100); + boolean solvedX = solveX2(15); + + DMatrixRMaj mVectorMat = mVector.getMatrix(); + DMatrixRMaj ksiMatrixMat = ksiMatrix.getMatrix(); + + // ksiMatrix.print(); + // second order method not working correctly and not used t the moment b ecause of numerical + // stability + int temp = 0; + int iter = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + mVectorMat.unsafe_set(temp + j, 0, componentArray[i].getNumberOfMolesInPhase()); + } + temp += componentArray[i].getNumberOfAssociationSites(); + } - // System.out.println("iter " + iter + " error " + - // NormOps_DDRM.normF(corr4Matrix)); // corrMatrix.print(10, 10); - // ksiMatrix.print(10, 10); + DMatrixRMaj mat1 = KlkMatrix.getMatrix(); + double Klk = 0.0; + double totvolume = getTotalVolume(); + double tempVari; + double tempVarj; + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + tempVari = mVectorMat.unsafe_get(i, 0); + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + tempVarj = mVectorMat.unsafe_get(j, 0); + Klk = tempVari * tempVarj / totvolume * delta[i][j]; + mat1.unsafe_set(i, j, Klk); + mat1.unsafe_set(j, i, Klk); + } + } + boolean solved = true; + // SimpleMatrix corrMatrix = null; + do { + solved = true; + iter++; + temp = 0; + double ksi = 0; + + double temp1; + double temp2; + for (int i = 0; i < numberOfComponents; i++) { + temp1 = componentArray[i].getNumberOfMolesInPhase(); + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + ksi = ((ComponentUMRCPA) componentArray[i]).getXsite()[j]; + ksiMatrixMat.unsafe_set(temp + j, 0, ksi); + // ksiMatrix.getMatrix().unsafe_set(temp + j, 0, + // ksiMatrix.getMatrix().unsafe_get(temp + j, 0)); + tempVari = 1.0 / ksi - 1.0; + udotMatrix.set(temp + j, 0, tempVari); + udotTimesmMatrix.set(temp + j, 0, temp1 * tempVari); + } + temp += componentArray[i].getNumberOfAssociationSites(); + } + + int krondelt; + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + temp1 = mVectorMat.unsafe_get(i, 0); + temp2 = ksiMatrix.get(i, 0); + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + krondelt = 0; + if (i == j) { + krondelt = 1; + } + tempVari = -temp1 / (temp2 * temp2) * krondelt - mat1.unsafe_get(i, j); + hessianMatrix.set(i, j, tempVari); + hessianMatrix.set(j, i, tempVari); + } + } + + // ksiMatrix = new SimpleMatrix(ksi); + // SimpleMatrix hessianMatrix = new SimpleMatrix(hessian); + try { + hessianInvers = hessianMatrix.invert(); + } catch (Exception e) { + logger.error("error", e); + return false; + } + if (solvedX) { + // System.out.println("solvedX "); return true; + } + + DMatrixRMaj mat2 = ksiMatrix.getMatrix(); + CommonOps_DDRM.mult(mat1, mat2, corr2Matrix); + CommonOps_DDRM.subtract(udotTimesmMatrix.getDDRM(), corr2Matrix, corr3Matrix); + CommonOps_DDRM.mult(hessianInvers.getDDRM(), corr3Matrix, corr4Matrix); + // SimpleMatrix gMatrix = udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)); + // corrMatrix = + // hessianInvers.mult(udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix))); + // //.scale(-1.0); + temp = 0; + // System.out.println("print SimpleMatrix ..."); + // corrMatrix.print(10, 10); + // SimpleMatrix simp = new SimpleMatrix(corr4Matrix); + // System.out.println("print CommonOps ..."); + // simp.print(10,10); + double newX; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + newX = ksiMatrix.get(temp + j, 0) - corr4Matrix.unsafe_get((temp + j), 0); + if (newX < 0) { + newX = 1e-10; + solved = false; + } + ((ComponentCPAInterface) componentArray[i]).setXsite(j, newX); + } + temp += componentArray[i].getNumberOfAssociationSites(); + } + // System.out.println("corrmatrix error " ); + // System.out.println("error " + NormOps_DDRM.normF(corr4Matrix)); + } while ((NormOps_DDRM.normF(corr4Matrix) > 1e-12 || !solved) && iter < 100); + + // System.out.println("iter " + iter + " error " + + // NormOps_DDRM.normF(corr4Matrix)); // corrMatrix.print(10, 10); + // ksiMatrix.print(10, 10); + return true; + } + + /** + *

+ * solveX2. + *

+ * + * @param maxIter a int + * @return a boolean + */ + public boolean solveX2(int maxIter) { + double err = .0; + double totalVolume = getTotalVolume(); + int iter = 0; + // if (delta == null) { + // initCPAMatrix(1); + double old = 0.0; + double neeval = 0.0; + // } + do { + iter++; + err = 0.0; + for (int i = 0; i < totalNumberOfAccociationSites; i++) { + old = ((ComponentUMRCPA) componentArray[moleculeNumber[i]]).getXsite()[assSiteNumber[i]]; + neeval = 0.0; + for (int j = 0; j < totalNumberOfAccociationSites; j++) { + neeval += componentArray[moleculeNumber[j]].getNumberOfMolesInPhase() * delta[i][j] + * ((ComponentUMRCPA) componentArray[moleculeNumber[j]]).getXsite()[assSiteNumber[j]]; + } + neeval = 1.0 / (1.0 + 1.0 / totalVolume * neeval); + ((ComponentUMRCPA) componentArray[moleculeNumber[i]]).setXsite(assSiteNumber[i], neeval); + err += Math.abs((old - neeval) / neeval); + } + } while (Math.abs(err) > 1e-12 && iter < maxIter); + // System.out.println("iter " + iter); + if (Math.abs(err) < 1e-12) { + return true; + } else { + // System.out.println("did not solve for Xi in iterations: " + iter); + // System.out.println("error: " + err); + return false; } - - /** - *

- * solveX2. - *

- * - * @param maxIter a int - * @return a boolean - */ - public boolean solveX2(int maxIter) { - double err = .0, totalVolume = getTotalVolume(); - int iter = 0; - // if (delta == null) { - // initCPAMatrix(1); - double old = 0.0, neeval = 0.0; - // } - do { - iter++; - err = 0.0; - for (int i = 0; i < totalNumberOfAccociationSites; i++) { - old = ((ComponentUMRCPA) componentArray[moleculeNumber[i]]) - .getXsite()[assSiteNumber[i]]; - neeval = 0.0; - for (int j = 0; j < totalNumberOfAccociationSites; j++) { - neeval += componentArray[moleculeNumber[j]].getNumberOfMolesInPhase() - * delta[i][j] * ((ComponentUMRCPA) componentArray[moleculeNumber[j]]) - .getXsite()[assSiteNumber[j]]; - } - neeval = 1.0 / (1.0 + 1.0 / totalVolume * neeval); - ((ComponentUMRCPA) componentArray[moleculeNumber[i]]).setXsite(assSiteNumber[i], - neeval); - err += Math.abs((old - neeval) / neeval); - } - } while (Math.abs(err) > 1e-12 && iter < maxIter); - // System.out.println("iter " + iter); - if (Math.abs(err) < 1e-12) { - return true; + } + + /** {@inheritDoc} */ + @Override + public double getHcpatot() { + return hcpatot; + } + + /** + * Setter for property hcpatot. + * + * @param hcpatot New value of property hcpatot. + */ + public void setHcpatot(double hcpatot) { + this.hcpatot = hcpatot; + } + + /** {@inheritDoc} */ + @Override + public double getGcpa() { + return gcpa; + } + + /** + *

+ * calcRootVolFinder. + *

+ * + * @param phase a int + * @return a double + */ + public double calcRootVolFinder(int phase) { + double solvedBonVHigh = 0.0; + double solvedBonVlow = 1.0; + double oldh = 1; + // double[][] matrix = new double[2][2000]; + double BonV = 1.0 - 1e-10; + try { + // molarVolume(pressure, temperature, A, B, phaseType); + } catch (Exception e) { + logger.error("error", e); + } + double BonVold = BonV; + double Btemp = 0; + double h = 1; + // double Dtemp = 0, dh = 0, gvvv = 0, fvvv = 0, dhh = 0; + // double d1 = 0, d2 = 0; + Btemp = getB(); + // Dtemp = getA(); + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + for (int i = 0; i < 2000; i++) { + BonVold = BonV; + BonV = 1.0 - (i + 1e-6) * 1.0 / 2000.0; + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); + gcpa = calc_g(); + // lngcpa = + // Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); + + do { + } while (!solveX()); + + h = BonV - Btemp / numberOfMolesInPhase * dFdV() + - pressure * Btemp / (numberOfMolesInPhase * R * temperature); + + if (Math.signum(h) * Math.signum(oldh) < 0 && i > 2) { + if (solvedBonVlow < 1e-3) { + solvedBonVlow = (BonV + BonVold) / 2.0; + if (phase == 1) { + break; + } } else { - // System.out.println("did not solve for Xi in iterations: " + iter); - // System.out.println("error: " + err); - return false; - } + solvedBonVHigh = (BonV + BonVold) / 2.0; + if (phase == 0) { + break; + } + } + } + solvedBonVHigh = (BonV + BonVold) / 2.0; + oldh = h; + // matrix[0][i] = BonV; + // matrix[1][i] = h; } - - /** {@inheritDoc} */ - @Override - public double getHcpatot() { - return hcpatot; + if (solvedBonVlow < 1e-3) { + solvedBonVlow = solvedBonVHigh; } - - /** - * Setter for property hcpatot. - * - * @param hcpatot New value of property hcpatot. - */ - public void setHcpatot(double hcpatot) { - this.hcpatot = hcpatot; + // dataPresentation.fileHandeling.createTextFile.TextFile file = new + // dataPresentation.fileHandeling.createTextFile.TextFile(); + // file.setValues(matrix); + // file.setOutputFileName("D:/temp/temp2.txt"); + // file.createFile(); + if (phase == 1) { + return solvedBonVlow; + } else { + return solvedBonVHigh; } - - /** {@inheritDoc} */ - @Override - public double getGcpa() { - return gcpa; + } + + /** + *

+ * molarVolumeChangePhase. + *

+ * + * @param pressure a double + * @param temperature a double + * @param A a double + * @param B a double + * @param phasetype a int + * @return a double + * @throws neqsim.util.exception.IsNaNException if any. + * @throws neqsim.util.exception.TooManyIterationsException if any. + */ + public double molarVolumeChangePhase(double pressure, double temperature, double A, double B, + int phasetype) throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + double BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + // double BonV = calcRootVolFinder(phasetype); + // double BonVInit = BonV; + if (BonV < 0) { + BonV = 1.0e-8; } - /** - *

- * calcRootVolFinder. - *

- * - * @param phase a int - * @return a double - */ - public double calcRootVolFinder(int phase) { - double solvedBonVHigh = 0.0; - double solvedBonVlow = 1.0; - double oldh = 1; - // double[][] matrix = new double[2][2000]; - double BonV = 1.0 - 1e-10; - try { - // molarVolume(pressure, temperature, A, B, phaseType); - } catch (Exception e) { - logger.error("error", e); - } - double BonVold = BonV; - double Btemp = 0, h = 1; - // double Dtemp = 0, dh = 0, gvvv = 0, fvvv = 0, dhh = 0; - // double d1 = 0, d2 = 0; - Btemp = getB(); - // Dtemp = getA(); - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - for (int i = 0; i < 2000; i++) { - BonVold = BonV; - BonV = 1.0 - (i + 1e-6) * 1.0 / 2000.0; - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - gcpa = calc_g(); - // lngcpa = - // Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - - do { - } while (!solveX()); - - h = BonV - Btemp / numberOfMolesInPhase * dFdV() - - pressure * Btemp / (numberOfMolesInPhase * R * temperature); - - if (Math.signum(h) * Math.signum(oldh) < 0 && i > 2) { - if (solvedBonVlow < 1e-3) { - solvedBonVlow = (BonV + BonVold) / 2.0; - if (phase == 1) { - break; - } - } else { - solvedBonVHigh = (BonV + BonVold) / 2.0; - if (phase == 0) { - break; - } - } - } - solvedBonVHigh = (BonV + BonVold) / 2.0; - oldh = h; - // matrix[0][i] = BonV; - // matrix[1][i] = h; - } - if (solvedBonVlow < 1e-3) { - solvedBonVlow = solvedBonVHigh; - } - // dataPresentation.fileHandeling.createTextFile.TextFile file = new - // dataPresentation.fileHandeling.createTextFile.TextFile(); - // file.setValues(matrix); - // file.setOutputFileName("D:/temp/temp2.txt"); - // file.createFile(); - if (phase == 1) { - return solvedBonVlow; - } else { - return solvedBonVHigh; - } + if (BonV >= 1.0) { + BonV = 0.9999; + } + double BonVold = BonV; + double Btemp = 0; + double h = 0; + double dh = 0; + double dhh = 0; + // double gvvv = 0, fvvv = 0; + double d1 = 0; + double d2 = 0; + Btemp = getB(); + if (Btemp < 0) { + logger.info("b negative in volume calc"); } + calcDelta(); - /** - *

- * molarVolumeChangePhase. - *

- * - * @param pressure a double - * @param temperature a double - * @param A a double - * @param B a double - * @param phasetype a int - * @return a double - * @throws neqsim.util.exception.IsNaNException if any. - * @throws neqsim.util.exception.TooManyIterationsException if any. - */ - public double molarVolumeChangePhase(double pressure, double temperature, double A, double B, - int phasetype) throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - // double BonV = calcRootVolFinder(phasetype); - // double BonVInit = BonV; - if (BonV < 0) { - BonV = 1.0e-8; - } + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + int iterations = 0; - if (BonV >= 1.0) { - BonV = 0.9999; - } - double BonVold = BonV; - double Btemp = 0, h = 0, dh = 0, dhh = 0; - // double gvvv = 0, fvvv = 0; - double d1 = 0, d2 = 0; - Btemp = getB(); - if (Btemp < 0) { - logger.info("b negative in volume calc"); + do { + iterations++; + gcpa = calc_g(); + if (gcpa < 0) { + setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); + gcpa = calc_g(); + } + + // lngcpa = + // Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); + + solveX(); + + initCPAMatrix(1); + double BonV2 = BonV * BonV; + BonVold = BonV; + h = BonV - Btemp / numberOfMolesInPhase * dFdV() + - pressure * Btemp / (numberOfMolesInPhase * R * temperature); + dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); + dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) + - (Btemp * Btemp) / (BonV2 * BonV2) * (Btemp / numberOfMolesInPhase * dFdVdVdV()); + + d1 = -h / dh; + d2 = -dh / dhh; + // System.out.println("d1" + d1 + " d2 " + d2 + " d1 / d2 " + (d1 / d2)); + if (Math.abs(d1 / d2) <= 1.0) { + BonV += d1 * (1.0 + 0.5 * d1 / d2); + } else if (d1 / d2 < -1) { + BonV += 0.5 * d1; + } else if (d1 > d2) { + BonV += d2; + double hnew = h + d2 * dh; + if (Math.abs(hnew) > Math.abs(h)) { + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + } + } else { + BonV += 0.5 * d1; + } + if (Math.abs((BonV - BonVold) / BonVold) > 0.1) { + BonV = BonVold + 0.1 * (BonV - BonVold); + } + + if (BonV > 1.1) { + if (iterations < 3) { + BonV = (BonVold + BonV) / 2.0; + } else { + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); } - calcDelta(); - - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - int iterations = 0; - - do { - iterations++; - gcpa = calc_g(); - if (gcpa < 0) { - setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); - gcpa = calc_g(); - } - - // lngcpa = - // Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - - solveX(); - - initCPAMatrix(1); - double BonV2 = BonV * BonV; - BonVold = BonV; - h = BonV - Btemp / numberOfMolesInPhase * dFdV() - - pressure * Btemp / (numberOfMolesInPhase * R * temperature); - dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); - dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) - - (Btemp * Btemp) / (BonV2 * BonV2) - * (Btemp / numberOfMolesInPhase * dFdVdVdV()); - - d1 = -h / dh; - d2 = -dh / dhh; - // System.out.println("d1" + d1 + " d2 " + d2 + " d1 / d2 " + (d1 / d2)); - if (Math.abs(d1 / d2) <= 1.0) { - BonV += d1 * (1.0 + 0.5 * d1 / d2); - } else if (d1 / d2 < -1) { - BonV += 0.5 * d1; - } else if (d1 > d2) { - BonV += d2; - double hnew = h + d2 * dh; - if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } else { - BonV += 0.5 * d1; - } - if (Math.abs((BonV - BonVold) / BonVold) > 0.1) { - BonV = BonVold + 0.1 * (BonV - BonVold); - } - - if (BonV > 1.1) { - if (iterations < 3) { - BonV = (BonVold + BonV) / 2.0; - } else { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } - - if (BonV < 0) { - if (iterations < 3) { - BonV = Math.abs(BonVold + BonV) / 2.0; - } else { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } + } - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - - // System.out.println("Z " + Z + "h " + h + " BONV " + (Math.abs((BonV - - // BonVold) / BonV))); - } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10) && iterations < 100); - - /* - * if (Math.abs(h) > 1e-8) { if (phasetype == 0) { molarVolume(pressure, temperature, A, B, - * 1); } else { molarVolume(pressure, temperature, A, B, 0); } return getMolarVolume(); } - */ - // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); - // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); - // System.out.println("volume " + getTotalVolume() + " molar volume " + - // getMolarVolume()); - // if(iterations>=100) throw new util.exception.TooManyIterationsException(); - // System.out.println("error in volume " + - // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " - // firstterm " + (R*temperature/molarVolume) + " second " + - // R*temperature*dFdV()); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + " B - // " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); - if (Double.isNaN(getMolarVolume())) { - throw new neqsim.util.exception.IsNaNException(this, "molarVolumeChangePhase", - "Molar volume"); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " - // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" - // + fVV()); + if (BonV < 0) { + if (iterations < 3) { + BonV = Math.abs(BonVold + BonV) / 2.0; + } else { + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); } + } - return getMolarVolume(); - } + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); - /** {@inheritDoc} */ - @Override - public double getGcpav() { - return gcpav; - } + // System.out.println("Z " + Z + "h " + h + " BONV " + (Math.abs((BonV - + // BonVold) / BonV))); + } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10) && iterations < 100); - /** - *

- * Setter for the field gcpav. - *

- * - * @param gcpav a double + /* + * if (Math.abs(h) > 1e-8) { if (phasetype == 0) { molarVolume(pressure, temperature, A, B, 1); + * } else { molarVolume(pressure, temperature, A, B, 0); } return getMolarVolume(); } */ - public void setGcpav(double gcpav) { - this.gcpav = gcpav; + // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); + // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); + // System.out.println("volume " + getTotalVolume() + " molar volume " + + // getMolarVolume()); + // if(iterations>=100) throw new util.exception.TooManyIterationsException(); + // System.out.println("error in volume " + + // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV())); // + " + // firstterm " + (R*temperature/molarVolume) + " second " + + // R*temperature*dFdV()); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + " B + // " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); + if (Double.isNaN(getMolarVolume())) { + throw new neqsim.util.exception.IsNaNException(this, "molarVolumeChangePhase", + "Molar volume"); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " + // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + // + fVV()); } - /** {@inheritDoc} */ - @Override - public CPAMixingInterface getCpamix() { - return cpamix; + return getMolarVolume(); + } + + /** {@inheritDoc} */ + @Override + public double getGcpav() { + return gcpav; + } + + /** + *

+ * Setter for the field gcpav. + *

+ * + * @param gcpav a double + */ + public void setGcpav(double gcpav) { + this.gcpav = gcpav; + } + + /** {@inheritDoc} */ + @Override + public CPAMixingInterface getCpamix() { + return cpamix; + } + + /** {@inheritDoc} */ + @Override + public double calcPressure() { + gcpa = calc_g(); + // lngcpa = + // Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); + solveX(); + hcpatot = calc_hCPA(); + + initCPAMatrix(1); + return super.calcPressure(); + } + + /** {@inheritDoc} */ + @Override + public int getCrossAssosiationScheme(int comp1, int comp2, int site1, int site2) { + if (comp1 == comp2) { + return selfAccociationScheme[comp1][site1][site2]; + } else { + return crossAccociationScheme[comp1][comp2][site1][site2]; } - - /** {@inheritDoc} */ - @Override - public double calcPressure() { - gcpa = calc_g(); - // lngcpa = - // Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - solveX(); - hcpatot = calc_hCPA(); - - initCPAMatrix(1); - return super.calcPressure(); + } + + /** + *

+ * croeneckerProduct. + *

+ * + * @param a an array of {@link double} objects + * @param b an array of {@link double} objects + * @return an array of {@link double} objects + */ + public double[][] croeneckerProduct(double[][] a, double[][] b) { + int aLength = a.length; + int aCols = a[0].length; + int bLength = b.length; + int bCols = b[0].length; + double[][] result = new double[aLength * bLength][(aCols) * (bCols)]; + for (int z = 0; z < aLength; z++) { + for (int i = 0; i < aCols; i++) { + for (int j = 0; j < bLength; j++) { + for (int k = 0; k < bCols; k++) { + result[j + (z * bLength)][k + (i * bCols)] = a[z][i] * b[j][k]; + } + } + } } - - /** {@inheritDoc} */ - @Override - public int getCrossAssosiationScheme(int comp1, int comp2, int site1, int site2) { - if (comp1 == comp2) { - return selfAccociationScheme[comp1][site1][site2]; + return result; + } + + /** {@inheritDoc} */ + @Override + public int getTotalNumberOfAccociationSites() { + return totalNumberOfAccociationSites; + } + + /** {@inheritDoc} */ + @Override + public void setTotalNumberOfAccociationSites(int totalNumberOfAccociationSites) { + this.totalNumberOfAccociationSites = totalNumberOfAccociationSites; + } + + /** + *

+ * initOld2. + *

+ * + * @param totalNumberOfMoles a double + * @param numberOfComponents a int + * @param type a int + * @param phase a int + * @param beta a double + */ + public void initOld2(double totalNumberOfMoles, int numberOfComponents, int type, int phase, + double beta) { // type + // = 0 + // start + // init + // type + // =1 gi + // nye + // betingelser + if (type == 0) { + setTotalNumberOfAccociationSites(0); + selfAccociationScheme = new int[numberOfComponents][0][0]; + crossAccociationScheme = new int[numberOfComponents][numberOfComponents][0][0]; + for (int i = 0; i < numberOfComponents; i++) { + if (componentArray[i].getNumberOfmoles() < 1e-50) { + componentArray[i].setNumberOfAssociationSites(0); } else { - return crossAccociationScheme[comp1][comp2][site1][site2]; - } + componentArray[i] + .setNumberOfAssociationSites(componentArray[i].getOrginalNumberOfAssociationSites()); + setTotalNumberOfAccociationSites( + getTotalNumberOfAccociationSites() + componentArray[i].getNumberOfAssociationSites()); + selfAccociationScheme[i] = cpaSelect.setAssociationScheme(i, this); + for (int j = 0; j < numberOfComponents; j++) { + crossAccociationScheme[i][j] = cpaSelect.setCrossAssociationScheme(i, j, this); + } + } + } + + // had to remove if below - dont understand why.. Even + // if (getTotalNumberOfAccociationSites() != oldTotalNumberOfAccociationSites) { + mVector = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + KlkMatrix = + new SimpleMatrix(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + KlkVMatrix = + new SimpleMatrix(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + KlkVVMatrix = + new SimpleMatrix(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + KlkVVVMatrix = + new SimpleMatrix(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + hessianMatrix = + new SimpleMatrix(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + KlkTMatrix = + new SimpleMatrix(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + KlkTTMatrix = + new SimpleMatrix(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + KlkTVMatrix = + new SimpleMatrix(getTotalNumberOfAccociationSites(), getTotalNumberOfAccociationSites()); + corr2Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + corr3Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + corr4Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); + Klkni = + new double[numberOfComponents][getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + ksiMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + uMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + udotMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + moleculeNumber = new int[getTotalNumberOfAccociationSites()]; + assSiteNumber = new int[getTotalNumberOfAccociationSites()]; + gvector = new double[getTotalNumberOfAccociationSites()][1]; + udotTimesmMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + delta = new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + deltaNog = new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + deltadT = new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + deltadTdT = + new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; + QMatksiksiksi = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); + // } + udotTimesmiMatrix = + new SimpleMatrix(getNumberOfComponents(), getTotalNumberOfAccociationSites()); + + oldTotalNumberOfAccociationSites = getTotalNumberOfAccociationSites(); + + int temp = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + moleculeNumber[temp + j] = i; + assSiteNumber[temp + j] = j; + } + temp += componentArray[i].getNumberOfAssociationSites(); + } } - - /** - *

- * croeneckerProduct. - *

- * - * @param a an array of {@link double} objects - * @param b an array of {@link double} objects - * @return an array of {@link double} objects - */ - public double[][] croeneckerProduct(double[][] a, double[][] b) { - int aLength = a.length; - int aCols = a[0].length; - int bLength = b.length; - int bCols = b[0].length; - double[][] result = new double[aLength * bLength][(aCols) * (bCols)]; - for (int z = 0; z < aLength; z++) { - for (int i = 0; i < aCols; i++) { - for (int j = 0; j < bLength; j++) { - for (int k = 0; k < bCols; k++) { - result[j + (z * bLength)][k + (i * bCols)] = a[z][i] * b[j][k]; - } - } - } - } - return result; + if (cpamix == null) { + cpamix = cpaSelect.getMixingRule(1, this); } - /** {@inheritDoc} */ - @Override - public int getTotalNumberOfAccociationSites() { - return totalNumberOfAccociationSites; + super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + if (type > 0 && isConstantPhaseVolume()) { + calcDelta(); + solveX(); + super.init(totalNumberOfMoles, numberOfComponents, 1, phase, beta); + gcpa = calc_g(); + // lngcpa = Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); } - /** {@inheritDoc} */ - @Override - public void setTotalNumberOfAccociationSites(int totalNumberOfAccociationSites) { - this.totalNumberOfAccociationSites = totalNumberOfAccociationSites; + if (type > 0) { + hcpatot = calc_hCPA(); } - /** - *

- * initOld2. - *

- * - * @param totalNumberOfMoles a double - * @param numberOfComponents a int - * @param type a int - * @param phase a int - * @param beta a double - */ - public void initOld2(double totalNumberOfMoles, int numberOfComponents, int type, int phase, - double beta) { // type - // = 0 - // start - // init - // type - // =1 gi - // nye - // betingelser - if (type == 0) { - setTotalNumberOfAccociationSites(0); - selfAccociationScheme = new int[numberOfComponents][0][0]; - crossAccociationScheme = new int[numberOfComponents][numberOfComponents][0][0]; - for (int i = 0; i < numberOfComponents; i++) { - if (componentArray[i].getNumberOfmoles() < 1e-50) { - componentArray[i].setNumberOfAssociationSites(0); - } else { - componentArray[i].setNumberOfAssociationSites( - componentArray[i].getOrginalNumberOfAssociationSites()); - setTotalNumberOfAccociationSites(getTotalNumberOfAccociationSites() - + componentArray[i].getNumberOfAssociationSites()); - selfAccociationScheme[i] = cpaSelect.setAssociationScheme(i, this); - for (int j = 0; j < numberOfComponents; j++) { - crossAccociationScheme[i][j] = - cpaSelect.setCrossAssociationScheme(i, j, this); - } - } - } - - // had to remove if below - dont understand why.. Even - // if (getTotalNumberOfAccociationSites() != oldTotalNumberOfAccociationSites) { - mVector = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - KlkMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkVVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkVVVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - hessianMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkTMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkTTMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - KlkTVMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), - getTotalNumberOfAccociationSites()); - corr2Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - corr3Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - corr4Matrix = new DMatrixRMaj(getTotalNumberOfAccociationSites(), 1); - Klkni = new double[numberOfComponents][getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - ksiMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - uMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - udotMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - moleculeNumber = new int[getTotalNumberOfAccociationSites()]; - assSiteNumber = new int[getTotalNumberOfAccociationSites()]; - gvector = new double[getTotalNumberOfAccociationSites()][1]; - udotTimesmMatrix = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - delta = new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - deltaNog = - new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - deltadT = - new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - deltadTdT = - new double[getTotalNumberOfAccociationSites()][getTotalNumberOfAccociationSites()]; - QMatksiksiksi = new SimpleMatrix(getTotalNumberOfAccociationSites(), 1); - // } - udotTimesmiMatrix = - new SimpleMatrix(getNumberOfComponents(), getTotalNumberOfAccociationSites()); - - oldTotalNumberOfAccociationSites = getTotalNumberOfAccociationSites(); - - int temp = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - moleculeNumber[temp + j] = i; - assSiteNumber[temp + j] = j; - } - temp += componentArray[i].getNumberOfAssociationSites(); - } - } - if (cpamix == null) { - cpamix = cpaSelect.getMixingRule(1, this); - } - - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - if (type > 0 && isConstantPhaseVolume()) { - calcDelta(); - solveX(); - super.init(totalNumberOfMoles, numberOfComponents, 1, phase, beta); - gcpa = calc_g(); - // lngcpa = Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); - } - - if (type > 0) { - hcpatot = calc_hCPA(); - } - - if (type > 1) { - initCPAMatrix(type); - // hcpatotdT = calc_hCPAdT(); - // super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - } + if (type > 1) { + initCPAMatrix(type); + // hcpatotdT = calc_hCPAdT(); + // super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); } - - /** {@inheritDoc} */ - @Override - public double molarVolume2(double pressure, double temperature, double A, double B, int phase) - throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - Z = phase == 0 ? 1.0 : 1.0e-5; + } + + /** {@inheritDoc} */ + @Override + public double molarVolume2(double pressure, double temperature, double A, double B, int phase) + throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + Z = phase == 0 ? 1.0 : 1.0e-5; + setMolarVolume(Z * R * temperature / pressure); + // super.molarVolume(pressure,temperature, A, B, phase); + int iterations = 0; + double err = 0.0; + double dErrdV = 0.0; + double deltaV = 0; + + do { + A = calcA(this, temperature, pressure, numberOfComponents); + B = calcB(this, temperature, pressure, numberOfComponents); + + double dFdV = dFdV(); + double dFdVdV = dFdVdV(); + // double dFdVdVdV = dFdVdVdV(); + // double factor1 = 1.0e0, factor2 = 1.0e0; + err = -R * temperature * dFdV + R * temperature / getMolarVolume() - pressure; + + // System.out.println("pressure " + -R * temperature * dFdV + " " + R * + // temperature / getMolarVolume()); + // -pressure; + dErrdV = -R * temperature * dFdVdV + - R * temperature * numberOfMolesInPhase / Math.pow(getVolume(), 2.0); + + // System.out.println("errdV " + dErrdV); + // System.out.println("err " + err); + deltaV = -err / dErrdV; + + setMolarVolume(getMolarVolume() + deltaV / numberOfMolesInPhase); + + Z = pressure * getMolarVolume() / (R * temperature); + if (Z < 0) { + Z = 1e-6; setMolarVolume(Z * R * temperature / pressure); - // super.molarVolume(pressure,temperature, A, B, phase); - int iterations = 0; - double err = 0.0, dErrdV = 0.0; - double deltaV = 0; - - do { - A = calcA(this, temperature, pressure, numberOfComponents); - B = calcB(this, temperature, pressure, numberOfComponents); - - double dFdV = dFdV(), dFdVdV = dFdVdV(); - // double dFdVdVdV = dFdVdVdV(); - // double factor1 = 1.0e0, factor2 = 1.0e0; - err = -R * temperature * dFdV + R * temperature / getMolarVolume() - pressure; - - // System.out.println("pressure " + -R * temperature * dFdV + " " + R * - // temperature / getMolarVolume()); - // -pressure; - dErrdV = -R * temperature * dFdVdV - - R * temperature * numberOfMolesInPhase / Math.pow(getVolume(), 2.0); - - // System.out.println("errdV " + dErrdV); - // System.out.println("err " + err); - deltaV = -err / dErrdV; - - setMolarVolume(getMolarVolume() + deltaV / numberOfMolesInPhase); - - Z = pressure * getMolarVolume() / (R * temperature); - if (Z < 0) { - Z = 1e-6; - setMolarVolume(Z * R * temperature / pressure); - } - - // System.out.println("Z " + Z); - } while (Math.abs(err) > 1.0e-8 || iterations < 100); - // System.out.println("Z " + Z); - return getMolarVolume(); + } + + // System.out.println("Z " + Z); + } while (Math.abs(err) > 1.0e-8 || iterations < 100); + // System.out.println("Z " + Z); + return getMolarVolume(); + } + + /** + *

+ * initCPAMatrixOld. + *

+ * + * @param type a int + */ + public void initCPAMatrixOld(int type) { + if (getTotalNumberOfAccociationSites() == 0) { + FCPA = 0.0; + dFCPAdTdV = 0.0; + dFCPAdTdT = 0.0; + dFCPAdT = 0; + dFCPAdV = 0; + dFCPAdVdV = 0.0; + dFCPAdVdVdV = 0.0; + + return; } - /** - *

- * initCPAMatrixOld. - *

- * - * @param type a int - */ - public void initCPAMatrixOld(int type) { - if (getTotalNumberOfAccociationSites() == 0) { - FCPA = 0.0; - dFCPAdTdV = 0.0; - dFCPAdTdT = 0.0; - dFCPAdT = 0; - dFCPAdV = 0; - dFCPAdVdV = 0.0; - dFCPAdVdVdV = 0.0; - - return; - } - - int temp = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - uMatrix.set(temp + j, 0, - Math.log(ksiMatrix.get(temp + j, 0)) - ksiMatrix.get(temp + j, 0) + 1.0); - gvector[temp + j][0] = mVector.get(temp + j, 0) * udotMatrix.get(temp + j, 0); - } - temp += componentArray[i].getNumberOfAssociationSites(); - } - for (int i = 0; i < getNumberOfComponents(); i++) { - for (int j = 0; j < getTotalNumberOfAccociationSites(); j++) { - if (moleculeNumber[j] == i) { - udotTimesmiMatrix.set(i, j, udotMatrix.get(j, 0)); - } else { - udotTimesmiMatrix.set(i, j, 0.0); - } - } + int temp = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + uMatrix.set(temp + j, 0, + Math.log(ksiMatrix.get(temp + j, 0)) - ksiMatrix.get(temp + j, 0) + 1.0); + gvector[temp + j][0] = mVector.get(temp + j, 0) * udotMatrix.get(temp + j, 0); + } + temp += componentArray[i].getNumberOfAssociationSites(); + } + for (int i = 0; i < getNumberOfComponents(); i++) { + for (int j = 0; j < getTotalNumberOfAccociationSites(); j++) { + if (moleculeNumber[j] == i) { + udotTimesmiMatrix.set(i, j, udotMatrix.get(j, 0)); + } else { + udotTimesmiMatrix.set(i, j, 0.0); } + } + } - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - delta[i][j] = deltaNog[i][j] * getGcpa(); - delta[j][i] = delta[i][j]; - if (type > 1) { - deltadT[i][j] = cpamix.calcDeltadT(assSiteNumber[i], assSiteNumber[j], - moleculeNumber[i], moleculeNumber[j], this, getTemperature(), - getPressure(), numberOfComponents); - deltadT[j][i] = deltadT[i][j]; - - deltadTdT[i][j] = cpamix.calcDeltadTdT(assSiteNumber[i], assSiteNumber[j], - moleculeNumber[i], moleculeNumber[j], this, getTemperature(), - getPressure(), numberOfComponents); - deltadTdT[j][i] = deltadTdT[i][j]; - } - } - } + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + delta[i][j] = deltaNog[i][j] * getGcpa(); + delta[j][i] = delta[i][j]; + if (type > 1) { + deltadT[i][j] = cpamix.calcDeltadT(assSiteNumber[i], assSiteNumber[j], moleculeNumber[i], + moleculeNumber[j], this, getTemperature(), getPressure(), numberOfComponents); + deltadT[j][i] = deltadT[i][j]; - double totalVolume = getTotalVolume(); - double totalVolume2 = totalVolume * totalVolume, totalVolume3 = totalVolume2 * totalVolume; - double gdv1 = getGcpav() - 1.0 / totalVolume; - double gdv2 = gdv1 * gdv1; - double gdv3 = gdv2 * gdv1; - // double Klk = 0.0; - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - KlkVMatrix.set(i, j, KlkMatrix.get(i, j) * gdv1); - KlkVMatrix.set(j, i, KlkVMatrix.get(i, j)); - - KlkVVMatrix.set(i, j, KlkMatrix.get(i, j) * gdv2 - + KlkMatrix.get(i, j) * (gcpavv + 1.0 / totalVolume / totalVolume)); - KlkVVMatrix.set(j, i, KlkVVMatrix.get(i, j)); - - KlkVVVMatrix.set(i, j, - KlkMatrix.get(i, j) * gdv3 - + 3.0 * KlkMatrix.get(i, j) * (getGcpav() - 1.0 / totalVolume) - * (gcpavv + 1.0 / (totalVolume2)) - + KlkMatrix.get(i, j) * (gcpavvv - 2.0 / (totalVolume3))); - KlkVVVMatrix.set(j, i, KlkVVVMatrix.get(i, j)); - - if (type > 1) { - double tempVar = deltadT[i][j] / delta[i][j]; - double tempVardT = deltadTdT[i][j] / delta[i][j] - - (deltadT[i][j] * deltadT[i][j]) / (delta[i][j] * delta[i][j]); - - if (!Double.isNaN(tempVar)) { - // KlkdT[i][j] = KlkMatrix.getMatrix().unsafe_get(i, j) * tempVar; - // KlkdT[j][i] = KlkdT[i][j]; - - KlkTMatrix.set(i, j, KlkMatrix.get(i, j) * tempVar); - KlkTMatrix.set(j, i, KlkTMatrix.get(i, j)); - - KlkTVMatrix.set(i, j, - KlkMatrix.get(i, j) * tempVar * (gcpav - 1.0 / totalVolume)); - KlkTVMatrix.set(j, i, KlkTVMatrix.get(i, j)); - - KlkTTMatrix.set(i, j, - KlkMatrix.get(i, j) * (tempVar * tempVar + tempVardT)); - KlkTTMatrix.set(j, i, KlkTTMatrix.get(i, j)); - } - - if (type > 2) { - for (int p = 0; p < numberOfComponents; p++) { - double t1 = 0.0, t2 = 0.0; - if (moleculeNumber[i] == p) { - t1 = 1.0 / mVector.get(i, 0); - } - if (moleculeNumber[j] == p) { - t2 = 1.0 / mVector.get(j, 0); - } - Klkni[p][i][j] = KlkMatrix.get(i, j) * (t1 + t2 - + ((ComponentUMRCPA) getComponent(p)).calc_lngi(this)); - Klkni[p][j][i] = Klkni[p][i][j]; - } - } - } - } - QMatksiksiksi.set(i, 0, 2.0 * mVector.get(i, 0) - / (ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0))); + deltadTdT[i][j] = + cpamix.calcDeltadTdT(assSiteNumber[i], assSiteNumber[j], moleculeNumber[i], + moleculeNumber[j], this, getTemperature(), getPressure(), numberOfComponents); + deltadTdT[j][i] = deltadTdT[i][j]; } + } + } - SimpleMatrix ksiMatrixTranspose = ksiMatrix.transpose(); - - // dXdV - SimpleMatrix KlkVMatrixksi = KlkVMatrix.mult(ksiMatrix); - SimpleMatrix XV = hessianInvers.mult(KlkVMatrixksi); - SimpleMatrix XVtranspose = XV.transpose(); - - SimpleMatrix QCPA = mVector.transpose() - .mult(uMatrix.minus(ksiMatrix.elementMult(udotMatrix).scale(0.5))); - FCPA = QCPA.get(0, 0); - - SimpleMatrix tempMatrix = ksiMatrixTranspose.mult(KlkVMatrixksi).scale(-0.5); - dFCPAdV = tempMatrix.get(0, 0); - SimpleMatrix KlkVVMatrixTImesKsi = KlkVVMatrix.mult(ksiMatrix); - SimpleMatrix tempMatrixVV = ksiMatrixTranspose.mult(KlkVVMatrixTImesKsi).scale(-0.5) - .minus(KlkVMatrixksi.transpose().mult(XV)); - dFCPAdVdV = tempMatrixVV.get(0, 0); + double totalVolume = getTotalVolume(); + double totalVolume2 = totalVolume * totalVolume; + double totalVolume3 = totalVolume2 * totalVolume; + double gdv1 = getGcpav() - 1.0 / totalVolume; + double gdv2 = gdv1 * gdv1; + double gdv3 = gdv2 * gdv1; + // double Klk = 0.0; + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + KlkVMatrix.set(i, j, KlkMatrix.get(i, j) * gdv1); + KlkVMatrix.set(j, i, KlkVMatrix.get(i, j)); + + KlkVVMatrix.set(i, j, KlkMatrix.get(i, j) * gdv2 + + KlkMatrix.get(i, j) * (gcpavv + 1.0 / totalVolume / totalVolume)); + KlkVVMatrix.set(j, i, KlkVVMatrix.get(i, j)); + + KlkVVVMatrix.set(i, j, + KlkMatrix.get(i, j) * gdv3 + + 3.0 * KlkMatrix.get(i, j) * (getGcpav() - 1.0 / totalVolume) + * (gcpavv + 1.0 / (totalVolume2)) + + KlkMatrix.get(i, j) * (gcpavvv - 2.0 / (totalVolume3))); + KlkVVVMatrix.set(j, i, KlkVVVMatrix.get(i, j)); - SimpleMatrix QVVV = ksiMatrixTranspose.mult(KlkVVVMatrix.mult(ksiMatrix)).scale(-0.5); - SimpleMatrix QVVksi = KlkVVMatrixTImesKsi.scale(-1.0); - SimpleMatrix QksiVksi = KlkVMatrix.scale(-1.0); + if (type > 1) { + double tempVar = deltadT[i][j] / delta[i][j]; + double tempVardT = deltadTdT[i][j] / delta[i][j] + - (deltadT[i][j] * deltadT[i][j]) / (delta[i][j] * delta[i][j]); - SimpleMatrix mat1 = QVVksi.transpose().mult(XV).scale(3.0); - SimpleMatrix mat2 = XVtranspose.mult(QksiVksi.mult(XV)).scale(3.0); - SimpleMatrix mat4 = XVtranspose.mult(QMatksiksiksi.mult(XVtranspose)).mult(XV); + if (!Double.isNaN(tempVar)) { + // KlkdT[i][j] = KlkMatrix.getMatrix().unsafe_get(i, j) * tempVar; + // KlkdT[j][i] = KlkdT[i][j]; - SimpleMatrix dFCPAdVdVdVMatrix = QVVV.plus(mat1).plus(mat2).plus(mat2).plus(mat4); - dFCPAdVdVdV = dFCPAdVdVdVMatrix.get(0, 0); - temp = 0; + KlkTMatrix.set(i, j, KlkMatrix.get(i, j) * tempVar); + KlkTMatrix.set(j, i, KlkTMatrix.get(i, j)); - if (type == 1) { - return; - } - for (int p = 0; p < numberOfComponents; p++) { - for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { - ((ComponentCPAInterface) getComponent(p)).setXsitedV(kk, XV.get(temp + kk, 0)); - } - temp += getComponent(p).getNumberOfAssociationSites(); - } + KlkTVMatrix.set(i, j, KlkMatrix.get(i, j) * tempVar * (gcpav - 1.0 / totalVolume)); + KlkTVMatrix.set(j, i, KlkTVMatrix.get(i, j)); - // KlkTMatrix = new SimpleMatrix(KlkdT); - SimpleMatrix KlkTMatrixTImesKsi = KlkTMatrix.mult(ksiMatrix); - // dQdT - SimpleMatrix tempMatrix2 = ksiMatrixTranspose.mult(KlkTMatrixTImesKsi).scale(-0.5); - dFCPAdT = tempMatrix2.get(0, 0); - - // SimpleMatrix KlkTVMatrix = new SimpleMatrix(KlkdTdV); - // SimpleMatrix tempMatrixTV = - // ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5).minus(KlkTMatrixTImesKsi.transpose().mult(XV)); - // dFCPAdTdV = tempMatrixTV.get(0, 0); - // dXdT - SimpleMatrix XT = hessianInvers.mult(KlkTMatrixTImesKsi); - // dQdTdT - SimpleMatrix tempMatrixTT = ksiMatrixTranspose.mult(KlkTTMatrix.mult(ksiMatrix)).scale(-0.5) - .minus(KlkTMatrixTImesKsi.transpose().mult(XT)); - dFCPAdTdT = tempMatrixTT.get(0, 0); - - SimpleMatrix tempMatrixTV = ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5) - .minus(KlkTMatrixTImesKsi.transpose().mult(XV)); - dFCPAdTdV = tempMatrixTV.get(0, 0); - - temp = 0; - for (int p = 0; p < numberOfComponents; p++) { - for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { - ((ComponentCPAInterface) getComponent(p)).setXsitedT(kk, XT.get(temp + kk, 0)); - } - temp += getComponent(p).getNumberOfAssociationSites(); - } + KlkTTMatrix.set(i, j, KlkMatrix.get(i, j) * (tempVar * tempVar + tempVardT)); + KlkTTMatrix.set(j, i, KlkTTMatrix.get(i, j)); + } - if (type == 2) { - return; - } - - // int assSites = 0; - // if(true) return; - for (int p = 0; p < numberOfComponents; p++) { - SimpleMatrix KiMatrix = new SimpleMatrix(Klkni[p]); - // KiMatrix.print(10,10); - // Matrix dQdniMatrix = - // (ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5)); // this - // methods misses one part of .... - // dQdniMatrix.print(10,10); - // KiMatrix.print(10, 10); - // miMatrix.getMatrix(assSites, assSites, 0, totalNumberOfAccociationSites - - // 1).print(10, 10); - // Matrix tempMatrix20 = miMatrix.getMatrix(assSites, assSites, 0, - // totalNumberOfAccociationSites - - // 1).times(uMatrix).minus(ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5));// - // ksiMatrix.transpose().times(KlkTMatrix.times(ksiMatrix)).times(-0.5); - // System.out.println("dQdn "); - // tempMatrix20.print(10, 10); - SimpleMatrix tempMatrix4 = KiMatrix.mult(ksiMatrix); - // udotTimesmiMatrix.getMatrix(assSites, assSites, 0, - // totalNumberOfAccociationSites - 1).print(10, 10); - SimpleMatrix tempMatrix5 = - udotTimesmiMatrix.extractVector(true, p).transpose().minus(tempMatrix4); - // tempMki[0] = mki[p]; - // Matrix amatrix = new Matrix(croeneckerProduct(tempMki, - // udotMatrix.getArray())); - // System.out.println("aMatrix "); - // amatrix.transpose().print(10, 10); - // System.out.println("temp4 matrix"); - // tempMatrix4.print(10, 10); - // Matrix tempMatrix5 = amatrix.minus(tempMatrix4); - SimpleMatrix tempMatrix6 = hessianInvers.mult(tempMatrix5);// .scale(-1.0); - // System.out.println("dXdni"); - // tempMatrix4.print(10, 10); - // tempMatrix5.print(10, 10); - // System.out.println("dXdn "); - // tempMatrix6.print(10, 10); - int temp2 = 0; - for (int compp = 0; compp < numberOfComponents; compp++) { - for (int kk = 0; kk < getComponent(compp).getNumberOfAssociationSites(); kk++) { - ((ComponentCPAInterface) getComponent(compp)).setXsitedni(kk, p, - -1.0 * tempMatrix6.get(temp2 + kk, 0)); - } - temp2 += getComponent(compp).getNumberOfAssociationSites(); + if (type > 2) { + for (int p = 0; p < numberOfComponents; p++) { + double t1 = 0.0; + double t2 = 0.0; + if (moleculeNumber[i] == p) { + t1 = 1.0 / mVector.get(i, 0); + } + if (moleculeNumber[j] == p) { + t2 = 1.0 / mVector.get(j, 0); + } + Klkni[p][i][j] = KlkMatrix.get(i, j) + * (t1 + t2 + ((ComponentUMRCPA) getComponent(p)).calc_lngi(this)); + Klkni[p][j][i] = Klkni[p][i][j]; } - // assSites += getComponent(p).getNumberOfAssociationSites(); + } } + } + QMatksiksiksi.set(i, 0, 2.0 * mVector.get(i, 0) + / (ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0))); } - /** - *

- * solveXOld. - *

- * - * @return a boolean - */ - public boolean solveXOld() { - if (getTotalNumberOfAccociationSites() == 0) { - return true; - } + SimpleMatrix ksiMatrixTranspose = ksiMatrix.transpose(); - boolean solvedX = solveX2(5); - if (solvedX) { - // return true; - } + // dXdV + SimpleMatrix KlkVMatrixksi = KlkVMatrix.mult(ksiMatrix); + SimpleMatrix XV = hessianInvers.mult(KlkVMatrixksi); + SimpleMatrix XVtranspose = XV.transpose(); - DMatrixRMaj mat1 = KlkMatrix.getMatrix(); - DMatrixRMaj mat2 = ksiMatrix.getMatrix(); - // second order method not working correctly and not used t the moment b ecause of numerical - // stability - int temp = 0, iter = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - mVector.set(temp + j, 0, componentArray[i].getNumberOfMolesInPhase()); - } - temp += componentArray[i].getNumberOfAssociationSites(); - } - double Klk = 0.0; - double totalVolume = getTotalVolume(); - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - Klk = mVector.get(i, 0) * mVector.get(j, 0) / totalVolume * delta[i][j]; - KlkMatrix.set(i, j, Klk); - KlkMatrix.set(j, i, Klk); - } - } - boolean solved = true; - // SimpleMatrix corrMatrix = null; - do { - solved = true; - iter++; - temp = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - ksiMatrix.set(temp + j, 0, ((ComponentUMRCPA) componentArray[i]).getXsite()[j]); - // ksiMatrix.getMatrix().unsafe_set(temp + j, 0, - // ksiMatrix.getMatrix().unsafe_get(temp + j, 0)); - udotMatrix.set(temp + j, 0, 1.0 / ksiMatrix.get(temp + j, 0) - 1.0); - udotTimesmMatrix.set(temp + j, 0, - mVector.get(temp + j, 0) * udotMatrix.get(temp + j, 0)); - } - temp += componentArray[i].getNumberOfAssociationSites(); - } + SimpleMatrix QCPA = + mVector.transpose().mult(uMatrix.minus(ksiMatrix.elementMult(udotMatrix).scale(0.5))); + FCPA = QCPA.get(0, 0); - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { - int krondelt = 0; - if (i == j) { - krondelt = 1; - } - hessianMatrix.set(i, j, - -mVector.get(i, 0) / (ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0)) - * krondelt - KlkMatrix.get(i, j)); - hessianMatrix.set(j, i, hessianMatrix.get(i, j)); - } - } + SimpleMatrix tempMatrix = ksiMatrixTranspose.mult(KlkVMatrixksi).scale(-0.5); + dFCPAdV = tempMatrix.get(0, 0); + SimpleMatrix KlkVVMatrixTImesKsi = KlkVVMatrix.mult(ksiMatrix); + SimpleMatrix tempMatrixVV = ksiMatrixTranspose.mult(KlkVVMatrixTImesKsi).scale(-0.5) + .minus(KlkVMatrixksi.transpose().mult(XV)); + dFCPAdVdV = tempMatrixVV.get(0, 0); - // ksiMatrix = new SimpleMatrix(ksi); - // SimpleMatrix hessianMatrix = new SimpleMatrix(hessian); - try { - hessianInvers = hessianMatrix.invert(); - } catch (Exception e) { - logger.error("error", e); - return false; - } + SimpleMatrix QVVV = ksiMatrixTranspose.mult(KlkVVVMatrix.mult(ksiMatrix)).scale(-0.5); + SimpleMatrix QVVksi = KlkVVMatrixTImesKsi.scale(-1.0); + SimpleMatrix QksiVksi = KlkVMatrix.scale(-1.0); - CommonOps_DDRM.mult(mat1, mat2, corr2Matrix); - CommonOps_DDRM.subtract(udotTimesmMatrix.getDDRM(), corr2Matrix, corr3Matrix); - CommonOps_DDRM.mult(hessianInvers.getDDRM(), corr3Matrix, corr4Matrix); - // SimpleMatrix gMatrix = udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)); - // corrMatrix = - // hessianInvers.mult(udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)));//.scale(-1.0); - temp = 0; - // System.out.println("print SimpleMatrix ..."); - // corrMatrix.print(10, 10); - // SimpleMatrix simp = new SimpleMatrix(corr4Matrix); - // System.out.println("print CommonOps ..."); - // simp.print(10,10); - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { - double newX = - ksiMatrix.get(temp + j, 0) - corr4Matrix.unsafe_get((temp + j), 0); - if (newX < 0) { - newX = 1e-10; - solved = false; - } - ((ComponentCPAInterface) componentArray[i]).setXsite(j, newX); - } - temp += componentArray[i].getNumberOfAssociationSites(); - } - // System.out.println("corrmatrix error " ); - // System.out.println("error " + corrMatrix.norm1()); - } while ((NormOps_DDRM.normF(corr4Matrix) > 1e-12 || !solved) && iter < 100); + SimpleMatrix mat1 = QVVksi.transpose().mult(XV).scale(3.0); + SimpleMatrix mat2 = XVtranspose.mult(QksiVksi.mult(XV)).scale(3.0); + SimpleMatrix mat4 = XVtranspose.mult(QMatksiksiksi.mult(XVtranspose)).mult(XV); - // System.out.println("iter " + iter + " error " + NormOps.normF(corr4Matrix)); - // // corrMatrix.print(10, 10); - // ksiMatrix.print(10, 10); - return true; + SimpleMatrix dFCPAdVdVdVMatrix = QVVV.plus(mat1).plus(mat2).plus(mat2).plus(mat4); + dFCPAdVdVdV = dFCPAdVdVdVMatrix.get(0, 0); + temp = 0; + + if (type == 1) { + return; + } + for (int p = 0; p < numberOfComponents; p++) { + for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { + ((ComponentCPAInterface) getComponent(p)).setXsitedV(kk, XV.get(temp + kk, 0)); + } + temp += getComponent(p).getNumberOfAssociationSites(); } - /** - *

- * solveX2Old. - *

- * - * @param maxIter a int - * @return a boolean - */ - public boolean solveX2Old(int maxIter) { - double err = .0; - int iter = 0; - // if (delta == null) { - // initCPAMatrix(1); - double old = 0.0, neeval = 0.0, totalVolume = getTotalVolume(); - // } - do { - iter++; - err = 0.0; - for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { - old = ((ComponentUMRCPA) getComponent(moleculeNumber[i])) - .getXsite()[assSiteNumber[i]]; - neeval = 0; - for (int j = 0; j < getTotalNumberOfAccociationSites(); j++) { - neeval += getComponent(moleculeNumber[j]).getNumberOfMolesInPhase() - * delta[i][j] * ((ComponentUMRCPA) getComponent(moleculeNumber[j])) - .getXsite()[assSiteNumber[j]]; - } - neeval = 1.0 / (1.0 + 1.0 / totalVolume * neeval); - ((ComponentCPAInterface) getComponent(moleculeNumber[i])).setXsite(assSiteNumber[i], - neeval); - err += Math.abs((old - neeval) / neeval); - } - } while (Math.abs(err) > 1e-10 && iter < maxIter); - // System.out.println("iter " + iter); - // if (Math.abs(err) - // < 1e-12) { - // return true; - // } else { - // System.out.println("did not solve for Xi in iterations: " + iter); - // System.out.println("error: " + err); - return false; + // KlkTMatrix = new SimpleMatrix(KlkdT); + SimpleMatrix KlkTMatrixTImesKsi = KlkTMatrix.mult(ksiMatrix); + // dQdT + SimpleMatrix tempMatrix2 = ksiMatrixTranspose.mult(KlkTMatrixTImesKsi).scale(-0.5); + dFCPAdT = tempMatrix2.get(0, 0); + + // SimpleMatrix KlkTVMatrix = new SimpleMatrix(KlkdTdV); + // SimpleMatrix tempMatrixTV = + // ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5).minus(KlkTMatrixTImesKsi.transpose().mult(XV)); + // dFCPAdTdV = tempMatrixTV.get(0, 0); + // dXdT + SimpleMatrix XT = hessianInvers.mult(KlkTMatrixTImesKsi); + // dQdTdT + SimpleMatrix tempMatrixTT = ksiMatrixTranspose.mult(KlkTTMatrix.mult(ksiMatrix)).scale(-0.5) + .minus(KlkTMatrixTImesKsi.transpose().mult(XT)); + dFCPAdTdT = tempMatrixTT.get(0, 0); + + SimpleMatrix tempMatrixTV = ksiMatrixTranspose.mult(KlkTVMatrix.mult(ksiMatrix)).scale(-0.5) + .minus(KlkTMatrixTImesKsi.transpose().mult(XV)); + dFCPAdTdV = tempMatrixTV.get(0, 0); + + temp = 0; + for (int p = 0; p < numberOfComponents; p++) { + for (int kk = 0; kk < getComponent(p).getNumberOfAssociationSites(); kk++) { + ((ComponentCPAInterface) getComponent(p)).setXsitedT(kk, XT.get(temp + kk, 0)); + } + temp += getComponent(p).getNumberOfAssociationSites(); } - /** - *

- * molarVolumeOld. - *

- * - * @param pressure a double - * @param temperature a double - * @param A a double - * @param B a double - * @param phasetype a int - * @return a double - * @throws neqsim.util.exception.IsNaNException if any. - * @throws neqsim.util.exception.TooManyIterationsException if any. - */ - public double molarVolumeOld(double pressure, double temperature, double A, double B, - int phasetype) throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - // if (pressure > 1000) { - // BonV = 0.9999; - // } + if (type == 2) { + return; + } - // double calcRooBonVtVolFinder = calcRootVolFinder(phasetype); - // BonV = calcRooBonVtVolFinder; - // double BonVInit = BonV; - if (BonV < 0) { - BonV = 1.0e-8; - } + // int assSites = 0; + // if(true) return; + for (int p = 0; p < numberOfComponents; p++) { + SimpleMatrix KiMatrix = new SimpleMatrix(Klkni[p]); + // KiMatrix.print(10,10); + // Matrix dQdniMatrix = + // (ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5)); // this + // methods misses one part of .... + // dQdniMatrix.print(10,10); + // KiMatrix.print(10, 10); + // miMatrix.getMatrix(assSites, assSites, 0, totalNumberOfAccociationSites - + // 1).print(10, 10); + // Matrix tempMatrix20 = miMatrix.getMatrix(assSites, assSites, 0, + // totalNumberOfAccociationSites - + // 1).times(uMatrix).minus(ksiMatrix.transpose().times(KiMatrix.times(ksiMatrix)).times(-0.5)); + // // + // ksiMatrix.transpose().times(KlkTMatrix.times(ksiMatrix)).times(-0.5); + // System.out.println("dQdn "); + // tempMatrix20.print(10, 10); + SimpleMatrix tempMatrix4 = KiMatrix.mult(ksiMatrix); + // udotTimesmiMatrix.getMatrix(assSites, assSites, 0, + // totalNumberOfAccociationSites - 1).print(10, 10); + SimpleMatrix tempMatrix5 = + udotTimesmiMatrix.extractVector(true, p).transpose().minus(tempMatrix4); + // tempMki[0] = mki[p]; + // Matrix amatrix = new Matrix(croeneckerProduct(tempMki, + // udotMatrix.getArray())); + // System.out.println("aMatrix "); + // amatrix.transpose().print(10, 10); + // System.out.println("temp4 matrix"); + // tempMatrix4.print(10, 10); + // Matrix tempMatrix5 = amatrix.minus(tempMatrix4); + SimpleMatrix tempMatrix6 = hessianInvers.mult(tempMatrix5); // .scale(-1.0); + // System.out.println("dXdni"); + // tempMatrix4.print(10, 10); + // tempMatrix5.print(10, 10); + // System.out.println("dXdn "); + // tempMatrix6.print(10, 10); + int temp2 = 0; + for (int compp = 0; compp < numberOfComponents; compp++) { + for (int kk = 0; kk < getComponent(compp).getNumberOfAssociationSites(); kk++) { + ((ComponentCPAInterface) getComponent(compp)).setXsitedni(kk, p, + -1.0 * tempMatrix6.get(temp2 + kk, 0)); + } + temp2 += getComponent(compp).getNumberOfAssociationSites(); + } + // assSites += getComponent(p).getNumberOfAssociationSites(); + } + } + + /** + *

+ * solveXOld. + *

+ * + * @return a boolean + */ + public boolean solveXOld() { + if (getTotalNumberOfAccociationSites() == 0) { + return true; + } - if (BonV >= 1.0) { - BonV = 0.9999; - } - double BonVold; - double h = 0, dh = 0, dhh = 0; - double d1 = 0, d2 = 0; - double Btemp = getB(); - if (Btemp < 0) { - logger.info("b negative in volume calc"); - } - calcDelta(); + boolean solvedX = solveX2(5); + if (solvedX) { + // return true; + } - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - int iterations = 0; + DMatrixRMaj mat1 = KlkMatrix.getMatrix(); + DMatrixRMaj mat2 = ksiMatrix.getMatrix(); + // second order method not working correctly and not used t the moment b ecause of numerical + // stability + int temp = 0; + int iter = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + mVector.set(temp + j, 0, componentArray[i].getNumberOfMolesInPhase()); + } + temp += componentArray[i].getNumberOfAssociationSites(); + } + double Klk = 0.0; + double totalVolume = getTotalVolume(); + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + Klk = mVector.get(i, 0) * mVector.get(j, 0) / totalVolume * delta[i][j]; + KlkMatrix.set(i, j, Klk); + KlkMatrix.set(j, i, Klk); + } + } + boolean solved = true; + // SimpleMatrix corrMatrix = null; + do { + solved = true; + iter++; + temp = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + ksiMatrix.set(temp + j, 0, ((ComponentUMRCPA) componentArray[i]).getXsite()[j]); + // ksiMatrix.getMatrix().unsafe_set(temp + j, 0, + // ksiMatrix.getMatrix().unsafe_get(temp + j, 0)); + udotMatrix.set(temp + j, 0, 1.0 / ksiMatrix.get(temp + j, 0) - 1.0); + udotTimesmMatrix.set(temp + j, 0, mVector.get(temp + j, 0) * udotMatrix.get(temp + j, 0)); + } + temp += componentArray[i].getNumberOfAssociationSites(); + } + + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + for (int j = i; j < getTotalNumberOfAccociationSites(); j++) { + int krondelt = 0; + if (i == j) { + krondelt = 1; + } + hessianMatrix.set(i, j, + -mVector.get(i, 0) / (ksiMatrix.get(i, 0) * ksiMatrix.get(i, 0)) * krondelt + - KlkMatrix.get(i, j)); + hessianMatrix.set(j, i, hessianMatrix.get(i, j)); + } + } + + // ksiMatrix = new SimpleMatrix(ksi); + // SimpleMatrix hessianMatrix = new SimpleMatrix(hessian); + try { + hessianInvers = hessianMatrix.invert(); + } catch (Exception e) { + logger.error("error", e); + return false; + } + + CommonOps_DDRM.mult(mat1, mat2, corr2Matrix); + CommonOps_DDRM.subtract(udotTimesmMatrix.getDDRM(), corr2Matrix, corr3Matrix); + CommonOps_DDRM.mult(hessianInvers.getDDRM(), corr3Matrix, corr4Matrix); + // SimpleMatrix gMatrix = udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix)); + // corrMatrix = + // hessianInvers.mult(udotTimesmMatrix.minus(KlkMatrix.mult(ksiMatrix))); + // //.scale(-1.0); + temp = 0; + // System.out.println("print SimpleMatrix ..."); + // corrMatrix.print(10, 10); + // SimpleMatrix simp = new SimpleMatrix(corr4Matrix); + // System.out.println("print CommonOps ..."); + // simp.print(10,10); + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < componentArray[i].getNumberOfAssociationSites(); j++) { + double newX = ksiMatrix.get(temp + j, 0) - corr4Matrix.unsafe_get((temp + j), 0); + if (newX < 0) { + newX = 1e-10; + solved = false; + } + ((ComponentCPAInterface) componentArray[i]).setXsite(j, newX); + } + temp += componentArray[i].getNumberOfAssociationSites(); + } + // System.out.println("corrmatrix error " ); + // System.out.println("error " + corrMatrix.norm1()); + } while ((NormOps_DDRM.normF(corr4Matrix) > 1e-12 || !solved) && iter < 100); + + // System.out.println("iter " + iter + " error " + NormOps.normF(corr4Matrix)); + // // corrMatrix.print(10, 10); + // ksiMatrix.print(10, 10); + return true; + } + + /** + *

+ * solveX2Old. + *

+ * + * @param maxIter a int + * @return a boolean + */ + public boolean solveX2Old(int maxIter) { + double err = .0; + int iter = 0; + // if (delta == null) { + // initCPAMatrix(1); + double old = 0.0; + double neeval = 0.0; + double totalVolume = getTotalVolume(); + // } + do { + iter++; + err = 0.0; + for (int i = 0; i < getTotalNumberOfAccociationSites(); i++) { + old = ((ComponentUMRCPA) getComponent(moleculeNumber[i])).getXsite()[assSiteNumber[i]]; + neeval = 0; + for (int j = 0; j < getTotalNumberOfAccociationSites(); j++) { + neeval += getComponent(moleculeNumber[j]).getNumberOfMolesInPhase() * delta[i][j] + * ((ComponentUMRCPA) getComponent(moleculeNumber[j])).getXsite()[assSiteNumber[j]]; + } + neeval = 1.0 / (1.0 + 1.0 / totalVolume * neeval); + ((ComponentCPAInterface) getComponent(moleculeNumber[i])).setXsite(assSiteNumber[i], + neeval); + err += Math.abs((old - neeval) / neeval); + } + } while (Math.abs(err) > 1e-10 && iter < maxIter); + // System.out.println("iter " + iter); + // if (Math.abs(err) + // < 1e-12) { + // return true; + // } else { + // System.out.println("did not solve for Xi in iterations: " + iter); + // System.out.println("error: " + err); + return false; + } + + /** + *

+ * molarVolumeOld. + *

+ * + * @param pressure a double + * @param temperature a double + * @param A a double + * @param B a double + * @param phasetype a int + * @return a double + * @throws neqsim.util.exception.IsNaNException if any. + * @throws neqsim.util.exception.TooManyIterationsException if any. + */ + public double molarVolumeOld(double pressure, double temperature, double A, double B, + int phasetype) throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + // if (pressure > 1000) { + // BonV = 0.9999; + // } + + // double calcRooBonVtVolFinder = calcRootVolFinder(phasetype); + // BonV = calcRooBonVtVolFinder; + // double BonVInit = BonV; + if (BonV < 0) { + BonV = 1.0e-8; + } - do { - iterations++; - gcpa = calc_g(); - if (gcpa < 0) { - setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); - gcpa = calc_g(); - } + if (BonV >= 1.0) { + BonV = 0.9999; + } + double BonVold; + double h = 0; + double dh = 0; + double dhh = 0; + double d1 = 0; + double d2 = 0; + double Btemp = getB(); + if (Btemp < 0) { + logger.info("b negative in volume calc"); + } + calcDelta(); - // lngcpa = - // Math.log(gcpa); - setGcpav(calc_lngV()); - gcpavv = calc_lngVV(); - gcpavvv = calc_lngVVV(); + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + int iterations = 0; - if (getTotalNumberOfAccociationSites() > 0) { - solveX(); - } + do { + iterations++; + gcpa = calc_g(); + if (gcpa < 0) { + setMolarVolume(1.0 / Btemp / numberOfMolesInPhase); + gcpa = calc_g(); + } - initCPAMatrix(1); - double BonV2 = BonV * BonV; - BonVold = BonV; - h = BonV - Btemp / numberOfMolesInPhase * dFdV() - - pressure * Btemp / (numberOfMolesInPhase * R * temperature); - dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); - dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) - - (Btemp * Btemp) / (BonV2 * BonV2) - * (Btemp / numberOfMolesInPhase * dFdVdVdV()); - - d1 = -h / dh; - d2 = -dh / dhh; - // System.out.println("h " + h + " iter " + iterations + " " + d1 + " d2 " + d2 - // + " d1 / d2 " + (d1 / d2)); - if (Math.abs(d1 / d2) <= 1.0) { - BonV += d1 * (1.0 + 0.5 * d1 / d2); - } else if (d1 / d2 < -1) { - BonV += 0.5 * d1; - } else if (d1 > d2) { - BonV += d2; - double hnew = h + d2 * dh; - if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 - ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); - } - } else { - BonV += 0.5 * d1; - } - if (Math.abs((BonV - BonVold) / BonVold) > 0.1) { - BonV = BonVold + 0.1 * (BonV - BonVold); - } + // lngcpa = + // Math.log(gcpa); + setGcpav(calc_lngV()); + gcpavv = calc_lngVV(); + gcpavvv = calc_lngVVV(); - if (BonV > 0.9999) { - if (iterations < 3) { - BonV = (BonVold + BonV) / 2.0; - } else { - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - // BonV = 0.9999; - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / - // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * - // temperature * R); - } - } else if (BonV < 0) { - if (iterations < 3) { - BonV = Math.abs(BonVold + BonV) / 2.0; - } else { - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / - // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * - // temperature * R); - } - } - setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); - Z = pressure * getMolarVolume() / (R * temperature); - } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10 || Math.abs(h) > 1e-12) - && iterations < 100); - - if (Math.abs(h) > 1e-12) { - // System.out.println("h failed " + "Z" + Z + " iterations " + iterations + " - // BonV " + BonV); - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - } - // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); - // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); - // System.out.println("volume " + totalVolume + " molar volume " + - // getMolarVolume()); - // if(iterations>=100) throw new util.exception.TooManyIterationsException(); - // System.out.println("error in volume " + - // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV()));// + " - // firstterm " + (R*temperature/molarVolume) + " second " + - // R*temperature*dFdV()); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + " B - // " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); - - if (Double.isNaN(getMolarVolume())) { - throw new neqsim.util.exception.IsNaNException(this, "molarVolumeOld", "Molar volume"); - // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " - // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" - // + fVV()); - } - return getMolarVolume(); + if (getTotalNumberOfAccociationSites() > 0) { + solveX(); + } + + initCPAMatrix(1); + double BonV2 = BonV * BonV; + BonVold = BonV; + h = BonV - Btemp / numberOfMolesInPhase * dFdV() + - pressure * Btemp / (numberOfMolesInPhase * R * temperature); + dh = 1.0 + Btemp / (BonV2) * (Btemp / numberOfMolesInPhase * dFdVdV()); + dhh = -2.0 * Btemp / (BonV2 * BonV) * (Btemp / numberOfMolesInPhase * dFdVdV()) + - (Btemp * Btemp) / (BonV2 * BonV2) * (Btemp / numberOfMolesInPhase * dFdVdVdV()); + + d1 = -h / dh; + d2 = -dh / dhh; + // System.out.println("h " + h + " iter " + iterations + " " + d1 + " d2 " + d2 + // + " d1 / d2 " + (d1 / d2)); + if (Math.abs(d1 / d2) <= 1.0) { + BonV += d1 * (1.0 + 0.5 * d1 / d2); + } else if (d1 / d2 < -1) { + BonV += 0.5 * d1; + } else if (d1 > d2) { + BonV += d2; + double hnew = h + d2 * dh; + if (Math.abs(hnew) > Math.abs(h)) { + BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); + } + } else { + BonV += 0.5 * d1; + } + if (Math.abs((BonV - BonVold) / BonVold) > 0.1) { + BonV = BonVold + 0.1 * (BonV - BonVold); + } + + if (BonV > 0.9999) { + if (iterations < 3) { + BonV = (BonVold + BonV) / 2.0; + } else { + // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // BonV = 0.9999; + // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * + // temperature * R); + } + } else if (BonV < 0) { + if (iterations < 3) { + BonV = Math.abs(BonVold + BonV) / 2.0; + } else { + // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * + // temperature * R); + } + } + setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); + Z = pressure * getMolarVolume() / (R * temperature); + } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10 || Math.abs(h) > 1e-12) + && iterations < 100); + + if (Math.abs(h) > 1e-12) { + // System.out.println("h failed " + "Z" + Z + " iterations " + iterations + " + // BonV " + BonV); + // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + } + // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); + // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); + // System.out.println("volume " + totalVolume + " molar volume " + + // getMolarVolume()); + // if(iterations>=100) throw new util.exception.TooManyIterationsException(); + // System.out.println("error in volume " + + // (-pressure+R*temperature/getMolarVolume()-R*temperature*dFdV())); // + " + // firstterm " + (R*temperature/molarVolume) + " second " + + // R*temperature*dFdV()); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh + " B + // " + Btemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); + + if (Double.isNaN(getMolarVolume())) { + throw new neqsim.util.exception.IsNaNException(this, "molarVolumeOld", "Molar volume"); + // System.out.println("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " + // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + // + fVV()); } + return getMolarVolume(); + } } diff --git a/src/main/java/neqsim/thermo/system/SystemDesmukhMather.java b/src/main/java/neqsim/thermo/system/SystemDesmukhMather.java index 8d143a01d9..6a28ef2dbb 100644 --- a/src/main/java/neqsim/thermo/system/SystemDesmukhMather.java +++ b/src/main/java/neqsim/thermo/system/SystemDesmukhMather.java @@ -18,7 +18,7 @@ public SystemDesmukhMather() { attractiveTermNumber = 0; phaseArray[0] = new PhaseSrkEos(); for (int i = 1; i < numberOfPhases; i++) { - phaseArray[i] = new PhaseDesmukhMather();// modifiedWS(); + phaseArray[i] = new PhaseDesmukhMather(); // modifiedWS(); } } @@ -38,7 +38,7 @@ public SystemDesmukhMather(double T, double P) { phaseArray[0].setTemperature(T); phaseArray[0].setPressure(P); for (int i = 1; i < numberOfPhases; i++) { - phaseArray[i] = new PhaseDesmukhMather();// new PhaseGENRTLmodifiedWS(); + phaseArray[i] = new PhaseDesmukhMather(); // new PhaseGENRTLmodifiedWS(); phaseArray[i].setTemperature(T); phaseArray[i].setPressure(P); } @@ -64,7 +64,7 @@ public SystemDesmukhMather(double T, double P, boolean solidCheck) { phaseArray[0].setTemperature(T); phaseArray[0].setPressure(P); for (int i = 1; i < numberOfPhases; i++) { - phaseArray[i] = new PhaseDesmukhMather();// new PhaseGENRTLmodifiedWS(); + phaseArray[i] = new PhaseDesmukhMather(); // new PhaseGENRTLmodifiedWS(); phaseArray[i].setTemperature(T); phaseArray[i].setPressure(P); } diff --git a/src/main/java/neqsim/thermo/system/SystemDuanSun.java b/src/main/java/neqsim/thermo/system/SystemDuanSun.java index 041a8096d2..9dc62d10d8 100644 --- a/src/main/java/neqsim/thermo/system/SystemDuanSun.java +++ b/src/main/java/neqsim/thermo/system/SystemDuanSun.java @@ -11,117 +11,117 @@ * @author Even Solbraa */ public class SystemDuanSun extends SystemEos { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - protected String[] CapeOpenProperties11 = - {"molecularWeight", "fugacityCoefficient", "logFugacityCoefficient"}; + protected String[] CapeOpenProperties11 = + {"molecularWeight", "fugacityCoefficient", "logFugacityCoefficient"}; - /** - *

- * Constructor for SystemDuanSun. - *

- */ - public SystemDuanSun() { - super(); - modelName = "Duan-Sun-model"; - attractiveTermNumber = 0; - phaseArray[0] = new PhaseSrkEos(); - for (int i = 1; i < numberOfPhases; i++) { - phaseArray[i] = new PhaseDuanSun(); - } + /** + *

+ * Constructor for SystemDuanSun. + *

+ */ + public SystemDuanSun() { + super(); + modelName = "Duan-Sun-model"; + attractiveTermNumber = 0; + phaseArray[0] = new PhaseSrkEos(); + for (int i = 1; i < numberOfPhases; i++) { + phaseArray[i] = new PhaseDuanSun(); } + } - /** - *

- * Constructor for SystemDuanSun. - *

- * - * @param T a double - * @param P a double - */ - public SystemDuanSun(double T, double P) { - super(T, P); - attractiveTermNumber = 0; - modelName = "Duan-Sun-model"; - phaseArray[0] = new PhaseSrkEos(); - phaseArray[0].setTemperature(T); - phaseArray[0].setPressure(P); - for (int i = 1; i < numberOfPhases; i++) { - phaseArray[i] = new PhaseDuanSun();// new PhaseGENRTLmodifiedWS(); - phaseArray[i].setTemperature(T); - phaseArray[i].setPressure(P); - } + /** + *

+ * Constructor for SystemDuanSun. + *

+ * + * @param T a double + * @param P a double + */ + public SystemDuanSun(double T, double P) { + super(T, P); + attractiveTermNumber = 0; + modelName = "Duan-Sun-model"; + phaseArray[0] = new PhaseSrkEos(); + phaseArray[0].setTemperature(T); + phaseArray[0].setPressure(P); + for (int i = 1; i < numberOfPhases; i++) { + phaseArray[i] = new PhaseDuanSun(); // new PhaseGENRTLmodifiedWS(); + phaseArray[i].setTemperature(T); + phaseArray[i].setPressure(P); } + } - /** - *

- * Constructor for SystemDuanSun. - *

- * - * @param T a double - * @param P a double - * @param solidCheck a boolean - */ - public SystemDuanSun(double T, double P, boolean solidCheck) { - this(T, P); - attractiveTermNumber = 0; - setNumberOfPhases(4); - modelName = "Duan-Sun-model"; - solidPhaseCheck = solidCheck; + /** + *

+ * Constructor for SystemDuanSun. + *

+ * + * @param T a double + * @param P a double + * @param solidCheck a boolean + */ + public SystemDuanSun(double T, double P, boolean solidCheck) { + this(T, P); + attractiveTermNumber = 0; + setNumberOfPhases(4); + modelName = "Duan-Sun-model"; + solidPhaseCheck = solidCheck; - phaseArray[0] = new PhaseSrkEos(); - phaseArray[0].setTemperature(T); - phaseArray[0].setPressure(P); - for (int i = 1; i < numberOfPhases; i++) { - phaseArray[i] = new PhaseDuanSun();// new PhaseGENRTLmodifiedWS(); - phaseArray[i].setTemperature(T); - phaseArray[i].setPressure(P); - } - - if (solidPhaseCheck) { - // System.out.println("here first"); - phaseArray[numberOfPhases - 1] = new PhasePureComponentSolid(); - phaseArray[numberOfPhases - 1].setTemperature(T); - phaseArray[numberOfPhases - 1].setPressure(P); - phaseArray[numberOfPhases - 1].setRefPhase(phaseArray[1].getRefPhase()); - } + phaseArray[0] = new PhaseSrkEos(); + phaseArray[0].setTemperature(T); + phaseArray[0].setPressure(P); + for (int i = 1; i < numberOfPhases; i++) { + phaseArray[i] = new PhaseDuanSun(); // new PhaseGENRTLmodifiedWS(); + phaseArray[i].setTemperature(T); + phaseArray[i].setPressure(P); } - /** {@inheritDoc} */ - @Override - public SystemDuanSun clone() { - SystemDuanSun clonedSystem = null; - try { - clonedSystem = (SystemDuanSun) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } + if (solidPhaseCheck) { + // System.out.println("here first"); + phaseArray[numberOfPhases - 1] = new PhasePureComponentSolid(); + phaseArray[numberOfPhases - 1].setTemperature(T); + phaseArray[numberOfPhases - 1].setPressure(P); + phaseArray[numberOfPhases - 1].setRefPhase(phaseArray[1].getRefPhase()); + } + } - return clonedSystem; + /** {@inheritDoc} */ + @Override + public SystemDuanSun clone() { + SystemDuanSun clonedSystem = null; + try { + clonedSystem = (SystemDuanSun) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); } - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - SystemInterface fluid1 = new SystemSrkCPA(298.15, 10.0); + return clonedSystem; + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + SystemInterface fluid1 = new SystemSrkCPA(298.15, 10.0); - fluid1.addComponent("CO2", 1.0); - fluid1.addComponent("nitrogen", 1.0); - fluid1.addComponent("water", 1.0); - fluid1.addComponent("NaCl", 1.0); - fluid1.setMixingRule(2); + fluid1.addComponent("CO2", 1.0); + fluid1.addComponent("nitrogen", 1.0); + fluid1.addComponent("water", 1.0); + fluid1.addComponent("NaCl", 1.0); + fluid1.setMixingRule(2); - try { - ThermodynamicOperations testOps = new ThermodynamicOperations(fluid1); - testOps.TPflash(); - } catch (Exception e) { - logger.error(e.toString()); - } - fluid1.display(); + try { + ThermodynamicOperations testOps = new ThermodynamicOperations(fluid1); + testOps.TPflash(); + } catch (Exception e) { + logger.error(e.toString()); } + fluid1.display(); + } } diff --git a/src/main/java/neqsim/thermo/system/SystemKentEisenberg.java b/src/main/java/neqsim/thermo/system/SystemKentEisenberg.java index 666c244305..fc1922eced 100644 --- a/src/main/java/neqsim/thermo/system/SystemKentEisenberg.java +++ b/src/main/java/neqsim/thermo/system/SystemKentEisenberg.java @@ -10,88 +10,88 @@ * @author Even Solbraa */ public class SystemKentEisenberg extends SystemEos { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - public SystemKentEisenberg() { - super(); - modelName = "Kent Eisenberg-model"; - attractiveTermNumber = 0; - phaseArray[0] = new PhaseSrkEos(); - for (int i = 1; i < numberOfPhases; i++) { - phaseArray[i] = new PhaseKentEisenberg(); - } + public SystemKentEisenberg() { + super(); + modelName = "Kent Eisenberg-model"; + attractiveTermNumber = 0; + phaseArray[0] = new PhaseSrkEos(); + for (int i = 1; i < numberOfPhases; i++) { + phaseArray[i] = new PhaseKentEisenberg(); } + } - /** - *

- * Constructor for SystemKentEisenberg. - *

- * - * @param T a double - * @param P a double - */ - public SystemKentEisenberg(double T, double P) { - super(T, P); - attractiveTermNumber = 0; - modelName = "Kent Eisenberg-model"; - phaseArray[0] = new PhaseSrkEos(); - phaseArray[0].setTemperature(T); - phaseArray[0].setPressure(P); - for (int i = 1; i < numberOfPhases; i++) { - phaseArray[i] = new PhaseKentEisenberg();// new PhaseGENRTLmodifiedWS(); - phaseArray[i].setTemperature(T); - phaseArray[i].setPressure(P); - } + /** + *

+ * Constructor for SystemKentEisenberg. + *

+ * + * @param T a double + * @param P a double + */ + public SystemKentEisenberg(double T, double P) { + super(T, P); + attractiveTermNumber = 0; + modelName = "Kent Eisenberg-model"; + phaseArray[0] = new PhaseSrkEos(); + phaseArray[0].setTemperature(T); + phaseArray[0].setPressure(P); + for (int i = 1; i < numberOfPhases; i++) { + phaseArray[i] = new PhaseKentEisenberg(); // new PhaseGENRTLmodifiedWS(); + phaseArray[i].setTemperature(T); + phaseArray[i].setPressure(P); } + } - /** - *

- * Constructor for SystemKentEisenberg. - *

- * - * @param T a double - * @param P a double - * @param solidCheck a boolean - */ - public SystemKentEisenberg(double T, double P, boolean solidCheck) { - this(T, P); - attractiveTermNumber = 0; - setNumberOfPhases(4); - modelName = "Kent Eisenberg-model"; - solidPhaseCheck = solidCheck; + /** + *

+ * Constructor for SystemKentEisenberg. + *

+ * + * @param T a double + * @param P a double + * @param solidCheck a boolean + */ + public SystemKentEisenberg(double T, double P, boolean solidCheck) { + this(T, P); + attractiveTermNumber = 0; + setNumberOfPhases(4); + modelName = "Kent Eisenberg-model"; + solidPhaseCheck = solidCheck; - phaseArray[0] = new PhaseSrkEos(); - phaseArray[0].setTemperature(T); - phaseArray[0].setPressure(P); - for (int i = 1; i < numberOfPhases; i++) { - phaseArray[i] = new PhaseKentEisenberg();// new PhaseGENRTLmodifiedWS(); - phaseArray[i].setTemperature(T); - phaseArray[i].setPressure(P); - } + phaseArray[0] = new PhaseSrkEos(); + phaseArray[0].setTemperature(T); + phaseArray[0].setPressure(P); + for (int i = 1; i < numberOfPhases; i++) { + phaseArray[i] = new PhaseKentEisenberg(); // new PhaseGENRTLmodifiedWS(); + phaseArray[i].setTemperature(T); + phaseArray[i].setPressure(P); + } - if (solidPhaseCheck) { - // System.out.println("here first"); - phaseArray[numberOfPhases - 1] = new PhasePureComponentSolid(); - phaseArray[numberOfPhases - 1].setTemperature(T); - phaseArray[numberOfPhases - 1].setPressure(P); - phaseArray[numberOfPhases - 1].setRefPhase(phaseArray[1].getRefPhase()); - } + if (solidPhaseCheck) { + // System.out.println("here first"); + phaseArray[numberOfPhases - 1] = new PhasePureComponentSolid(); + phaseArray[numberOfPhases - 1].setTemperature(T); + phaseArray[numberOfPhases - 1].setPressure(P); + phaseArray[numberOfPhases - 1].setRefPhase(phaseArray[1].getRefPhase()); } + } - /** {@inheritDoc} */ - @Override - public SystemKentEisenberg clone() { - SystemKentEisenberg clonedSystem = null; - try { - clonedSystem = (SystemKentEisenberg) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } + /** {@inheritDoc} */ + @Override + public SystemKentEisenberg clone() { + SystemKentEisenberg clonedSystem = null; + try { + clonedSystem = (SystemKentEisenberg) super.clone(); + } catch (Exception e) { + logger.error("Cloning failed.", e); + } - // for(int i = 0; i < numberOfPhases; i++) { - // clonedSystem.phaseArray[i] = (PhaseInterface) phaseArray[i].clone(); - // } + // for(int i = 0; i < numberOfPhases; i++) { + // clonedSystem.phaseArray[i] = (PhaseInterface) phaseArray[i].clone(); + // } - return clonedSystem; - } + return clonedSystem; + } } diff --git a/src/main/java/neqsim/thermo/system/SystemNRTL.java b/src/main/java/neqsim/thermo/system/SystemNRTL.java index 24d173a004..fd78f58c1f 100644 --- a/src/main/java/neqsim/thermo/system/SystemNRTL.java +++ b/src/main/java/neqsim/thermo/system/SystemNRTL.java @@ -18,7 +18,7 @@ public SystemNRTL() { attractiveTermNumber = 0; phaseArray[0] = new PhaseSrkEos(); for (int i = 1; i < numberOfPhases; i++) { - phaseArray[i] = new PhaseGENRTL();// modifiedWS(); + phaseArray[i] = new PhaseGENRTL(); // modifiedWS(); } } @@ -38,7 +38,7 @@ public SystemNRTL(double T, double P) { phaseArray[0].setTemperature(T); phaseArray[0].setPressure(P); for (int i = 1; i < numberOfPhases; i++) { - phaseArray[i] = new PhaseGENRTL();// new PhaseGENRTLmodifiedWS(); + phaseArray[i] = new PhaseGENRTL(); // new PhaseGENRTLmodifiedWS(); phaseArray[i].setTemperature(T); phaseArray[i].setPressure(P); } @@ -64,7 +64,7 @@ public SystemNRTL(double T, double P, boolean solidCheck) { phaseArray[0].setTemperature(T); phaseArray[0].setPressure(P); for (int i = 1; i < numberOfPhases; i++) { - phaseArray[i] = new PhaseGENRTL();// new PhaseGENRTLmodifiedWS(); + phaseArray[i] = new PhaseGENRTL(); // new PhaseGENRTLmodifiedWS(); phaseArray[i].setTemperature(T); phaseArray[i].setPressure(P); } diff --git a/src/main/java/neqsim/thermo/system/SystemPrEos.java b/src/main/java/neqsim/thermo/system/SystemPrEos.java index 4a40b5627a..a97f0bf032 100644 --- a/src/main/java/neqsim/thermo/system/SystemPrEos.java +++ b/src/main/java/neqsim/thermo/system/SystemPrEos.java @@ -18,7 +18,7 @@ public class SystemPrEos extends SystemEos { public SystemPrEos() { super(); modelName = "PR-EOS"; - getCharacterization().setTBPModel("PedersenPR");// (RiaziDaubert PedersenPR PedersenSRK + getCharacterization().setTBPModel("PedersenPR"); // (RiaziDaubert PedersenPR PedersenSRK attractiveTermNumber = 1; for (int i = 0; i < numberOfPhases; i++) { diff --git a/src/main/java/neqsim/thermo/system/SystemSrkEos.java b/src/main/java/neqsim/thermo/system/SystemSrkEos.java index bd85091f56..02783e9539 100644 --- a/src/main/java/neqsim/thermo/system/SystemSrkEos.java +++ b/src/main/java/neqsim/thermo/system/SystemSrkEos.java @@ -18,7 +18,7 @@ public class SystemSrkEos extends SystemEos { public SystemSrkEos() { super(); modelName = "SRK-EOS"; - getCharacterization().setTBPModel("PedersenSRK");// (RiaziDaubert PedersenPR PedersenSRK + getCharacterization().setTBPModel("PedersenSRK"); // (RiaziDaubert PedersenPR PedersenSRK attractiveTermNumber = 0; for (int i = 0; i < numberOfPhases; i++) { diff --git a/src/main/java/neqsim/thermo/system/SystemSrkPenelouxEos.java b/src/main/java/neqsim/thermo/system/SystemSrkPenelouxEos.java index 510cfd1cb4..cef5bf2b12 100644 --- a/src/main/java/neqsim/thermo/system/SystemSrkPenelouxEos.java +++ b/src/main/java/neqsim/thermo/system/SystemSrkPenelouxEos.java @@ -18,7 +18,7 @@ public class SystemSrkPenelouxEos extends SystemSrkEos { public SystemSrkPenelouxEos() { super(); modelName = "SRK-Peneloux-EOS"; - getCharacterization().setTBPModel("PedersenSRK");// (RiaziDaubert PedersenPR PedersenSRK + getCharacterization().setTBPModel("PedersenSRK"); // (RiaziDaubert PedersenPR PedersenSRK attractiveTermNumber = 0; for (int i = 0; i < numberOfPhases; i++) { diff --git a/src/main/java/neqsim/thermo/system/SystemThermo.java b/src/main/java/neqsim/thermo/system/SystemThermo.java index 511cad5d22..ea7426826b 100644 --- a/src/main/java/neqsim/thermo/system/SystemThermo.java +++ b/src/main/java/neqsim/thermo/system/SystemThermo.java @@ -75,7 +75,7 @@ abstract class SystemThermo implements SystemInterface { private ArrayList componentNames = new ArrayList(); // protected ArrayList resultArray1 = new ArrayList(); - protected String[] CapeOpenProperties11 = { "molecularWeight", "speedOfSound", + protected String[] CapeOpenProperties11 = {"molecularWeight", "speedOfSound", "jouleThomsonCoefficient", "internalEnergy", "internalEnergy.Dtemperature", "gibbsEnergy", "helmholtzEnergy", "fugacityCoefficient", "logFugacityCoefficient", "logFugacityCoefficient.Dtemperature", "logFugacityCoefficient.Dpressure", @@ -84,8 +84,8 @@ abstract class SystemThermo implements SystemInterface { "entropy.Dmoles", "heatCapacityCp", "heatCapacityCv", "density", "density.Dtemperature", "density.Dpressure", "density.Dmoles", "volume", "volume.Dpressure", "volume.Dtemperature", "molecularWeight.Dtemperature", "molecularWeight.Dpressure", "molecularWeight.Dmoles", - "compressibilityFactor" }; - protected String[] CapeOpenProperties10 = { "molecularWeight", "speedOfSound", + "compressibilityFactor"}; + protected String[] CapeOpenProperties10 = {"molecularWeight", "speedOfSound", "jouleThomsonCoefficient", "energy", "energy.Dtemperature", "gibbsFreeEnergy", "helmholtzFreeEnergy", "fugacityCoefficient", "logFugacityCoefficient", "logFugacityCoefficient.Dtemperature", "logFugacityCoefficient.Dpressure", @@ -94,15 +94,15 @@ abstract class SystemThermo implements SystemInterface { "entropy.Dmoles", "heatCapacity", "heatCapacityCv", "density", "density.Dtemperature", "density.Dpressure", "density.Dmoles", "volume", "volume.Dpressure", "volume.Dtemperature", "molecularWeight.Dtemperature", "molecularWeight.Dpressure", "molecularWeight.Dmoles", - "compressibilityFactor" }; + "compressibilityFactor"}; protected int numberOfComponents = 0; protected int numberOfPhases = 2; public int maxNumberOfPhases = 2; protected int attractiveTermNumber = 0; protected int phase = 2; protected int onePhaseType = 1; // 0 - liquid 1 - gas - protected int[] phaseType = { 1, 0, 0, 0, 0, 0 }; - protected int[] phaseIndex = { 0, 1, 2, 3, 4, 5 }; + protected int[] phaseType = {1, 0, 0, 0, 0, 0}; + protected int[] phaseIndex = {0, 1, 2, 3, 4, 5}; protected ChemicalReactionOperations chemicalReactionOperations = null; private int mixingRule = 1; protected boolean chemicalSystem = false; @@ -146,18 +146,18 @@ public SystemThermo(double T, double P) { if (T < 0.0) { String msg = "Negative input temperature"; logger.error(msg); - neqsim.util.exception.InvalidInputException e = new neqsim.util.exception.InvalidInputException( - this.getClass().getSimpleName(), - "SystemThermo", "T", "is negative"); + neqsim.util.exception.InvalidInputException e = + new neqsim.util.exception.InvalidInputException(this.getClass().getSimpleName(), + "SystemThermo", "T", "is negative"); throw new RuntimeException(e); } if (P < 0.0) { String msg = "Negative input pressure"; logger.error(msg); - neqsim.util.exception.InvalidInputException e = new neqsim.util.exception.InvalidInputException( - this.getClass().getSimpleName(), - "SystemThermo", "P", "is negative"); + neqsim.util.exception.InvalidInputException e = + new neqsim.util.exception.InvalidInputException(this.getClass().getSimpleName(), + "SystemThermo", "P", "is negative"); throw new RuntimeException(e); } beta[0] = 1.0; @@ -275,10 +275,8 @@ public SystemInterface addFluid(SystemInterface addSystem) { * addSystem.getPhase(0).getComponent(i).getNumberOfmoles(), * addSystem.getPhase(0).getComponent(i).getMolarMass(), * addSystem.getPhase(0).getComponent(i).getNormalLiquidDensity()); - * changeComponentName(addSystem.getPhase(0).getComponent(i).getComponentName()+ - * "_PC", - * addSystem.getPhase(0).getComponent(i).getComponentName().replaceFirst("_PC", - * "")); } + * changeComponentName(addSystem.getPhase(0).getComponent(i).getComponentName()+ "_PC", + * addSystem.getPhase(0).getComponent(i).getComponentName().replaceFirst("_PC", "")); } * addComponent(addSystem.getPhase(0).getComponent(i).getComponentName(), * addSystem.getPhase(0).getComponent(i).getNumberOfmoles()); */ @@ -297,24 +295,19 @@ public SystemInterface addFluid(SystemInterface addSystem) { @Override public void addPhase() { /* - * if (maxNumberOfPhases < 6 && !hydrateCheck) { ArrayList phaseList = new - * ArrayList(0); for - * (int i = 0; i < numberOfPhases; i++) { phaseList.add(phaseArray[i]); } // add - * the new phase - * phaseList.add(phaseArray[0].clone()); beta[phaseList.size() - 1] = 1.0e-8; // - * beta[1] -= + * if (maxNumberOfPhases < 6 && !hydrateCheck) { ArrayList phaseList = new ArrayList(0); for + * (int i = 0; i < numberOfPhases; i++) { phaseList.add(phaseArray[i]); } // add the new phase + * phaseList.add(phaseArray[0].clone()); beta[phaseList.size() - 1] = 1.0e-8; // beta[1] -= * beta[1]/1.0e5; * * PhaseInterface[] phaseArray2 = new PhaseInterface[numberOfPhases + 1]; * - * for (int i = 0; i < numberOfPhases + 1; i++) { phaseArray2[i] = - * (PhaseInterface) + * for (int i = 0; i < numberOfPhases + 1; i++) { phaseArray2[i] = (PhaseInterface) * phaseList.get(i); } * * phaseArray = phaseArray2; * - * System.out.println("number of phases " + numberOfPhases); if - * (maxNumberOfPhases < + * System.out.println("number of phases " + numberOfPhases); if (maxNumberOfPhases < * numberOfPhases) { maxNumberOfPhases = numberOfPhases; } } */ numberOfPhases++; @@ -654,7 +647,7 @@ public SystemInterface phaseToSystem(int phaseNumber1, int phaseNumber2) { newSystem.setNumberOfPhases(1); // newSystem.setPhaseType(0, - // getPhase(phaseNumber1).getPhaseType());//phaseType[phaseNumber]); + // getPhase(phaseNumber1).getPhaseType()); //phaseType[phaseNumber]); newSystem.init(1); return newSystem; } @@ -669,7 +662,8 @@ public void setTotalFlowRate(double flowRate, String flowunit) { initPhysicalProperties("density"); } density = getPhase(0).getDensity("kg/m3"); - neqsim.util.unit.Unit unit = new neqsim.util.unit.RateUnit(flowRate, flowunit, getMolarMass(), density, 0); + neqsim.util.unit.Unit unit = + new neqsim.util.unit.RateUnit(flowRate, flowunit, getMolarMass(), density, 0); double SIval = unit.getSIvalue(); double totalNumberOfMolesLocal = totalNumberOfMoles; for (int i = 0; i < numberOfComponents; i++) { @@ -749,7 +743,8 @@ public void changeComponentName(String name, String newName) { @Override public void addSalt(String componentName, double value) { neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); - java.sql.ResultSet dataSet = database.getResultSet("SELECT * FROM compsalt WHERE SaltName='" + componentName + "'"); + java.sql.ResultSet dataSet = + database.getResultSet("SELECT * FROM compsalt WHERE SaltName='" + componentName + "'"); double val1 = 1e-20; double val2 = 1e-20; try { @@ -863,8 +858,8 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo double Kwatson = Math.pow(TB * 1.8, 1.0 / 3.0) / density; // System.out.println("watson " + Kwatson); double CF = Math.pow((12.8 - Kwatson) * (10.0 - Kwatson) / (10.0 * acs), 2.0); - double acsKeslerLee = acs;// characterization.getTBPModel().calcAcentricFactorKeslerLee(molarMass*1000.0, - // density); + double acsKeslerLee = acs; // characterization.getTBPModel().calcAcentricFactorKeslerLee(molarMass*1000.0, + // density); double cpa = (-0.33886 + 0.02827 * Kwatson - 0.26105 * CF + 0.59332 * acsKeslerLee * CF) * 4.18682 * molarMass * 1e3; double cpb = (-(0.9291 - 1.1543 * Kwatson + 0.0368 * Kwatson * Kwatson) * 1e-4 @@ -886,10 +881,11 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo getPhase(i).getComponent(componentName).setRacketZCPA(racketZ); getPhase(i).getComponent(componentName).setIsTBPfraction(true); getPhase(i).getComponent(componentName).setParachorParameter( - characterization.getTBPModel().calcParachorParameter(molarMass, density));// 59.3+2.34*molarMass*1000.0);//0.5003*thermo.ThermodynamicConstantsInterface.R*TC/PC*(0.25969-racketZ)); + characterization.getTBPModel().calcParachorParameter(molarMass, density)); // 59.3+2.34*molarMass*1000.0); + // //0.5003*thermo.ThermodynamicConstantsInterface.R*TC/PC*(0.25969-racketZ)); getPhase(i).getComponent(componentName).setCriticalViscosity( - characterization.getTBPModel().calcCriticalViscosity(molarMass * 1000.0, density));// 7.94830*Math.sqrt(1e3*molarMass)*Math.pow(PC,2.0/3.0)/Math.pow(TC, - // 1.0/6.0)*1e-7); + characterization.getTBPModel().calcCriticalViscosity(molarMass * 1000.0, density)); // 7.94830*Math.sqrt(1e3*molarMass)*Math.pow(PC,2.0/3.0)/Math.pow(TC, + // 1.0/6.0)*1e-7); getPhase(i).getComponent(componentName).setTriplePointTemperature( 374.5 + 0.02617 * getPhase(i).getComponent(componentName).getMolarMass() * 1000.0 - 20172.0 / (getPhase(i).getComponent(componentName).getMolarMass() * 1000.0)); @@ -937,7 +933,7 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo double acs = 0.0; // double penelouxC = 0.0; double racketZ = 0.0; - componentName = (componentName.split("_PC")[0]) + "_PC";// + getFluidName()); + componentName = (componentName.split("_PC")[0]) + "_PC"; // + getFluidName()); try { refSystem = this.getClass().getDeclaredConstructor().newInstance(); @@ -948,11 +944,11 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo refSystem.setNumberOfPhases(1); refSystem.setPhaseType(0, "liquid"); molarMass = 1000 * molarMass; - TC = criticalTemperature;// characterization.getTBPModel().calcTC(molarMass, density); - PC = criticalPressure;// characterization.getTBPModel().calcPC(molarMass, density); + TC = criticalTemperature; // characterization.getTBPModel().calcTC(molarMass, density); + PC = criticalPressure; // characterization.getTBPModel().calcPC(molarMass, density); m = characterization.getTBPModel().calcm(molarMass, density); - acs = acentricFactor;// acentracentrcharacterization.getTBPModel().calcAcentricFactor(molarMass, - // density); + acs = acentricFactor; // acentracentrcharacterization.getTBPModel().calcAcentricFactor(molarMass, + // density); TB = characterization.getTBPModel().calcTB(molarMass, density); molarMass /= 1000.0; @@ -998,14 +994,14 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo logger.error("error", e); } - double critVol = characterization.getTBPModel().calcCriticalVolume(molarMass * 1000, density);// 0.2918-0.0928* - // acs)*8.314*TC/PC*10.0; + double critVol = characterization.getTBPModel().calcCriticalVolume(molarMass * 1000, density); // 0.2918-0.0928* + // acs)*8.314*TC/PC*10.0; addComponent(componentName, numberOfMoles, TC, PC, acs); double Kwatson = Math.pow(TB * 1.8, 1.0 / 3.0) / density; // System.out.println("watson " + Kwatson); double CF = Math.pow((12.8 - Kwatson) * (10.0 - Kwatson) / (10.0 * acs), 2.0); - double acsKeslerLee = acs;// characterization.getTBPModel().calcAcentricFactorKeslerLee(molarMass*1000.0, - // density); + double acsKeslerLee = acs; // characterization.getTBPModel().calcAcentricFactorKeslerLee(molarMass*1000.0, + // density); double cpa = (-0.33886 + 0.02827 * Kwatson - 0.26105 * CF + 0.59332 * acsKeslerLee * CF) * 4.18682 * molarMass * 1e3; double cpb = (-(0.9291 - 1.1543 * Kwatson + 0.0368 * Kwatson * Kwatson) * 1e-4 @@ -1027,10 +1023,11 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo getPhase(i).getComponent(componentName).setRacketZCPA(racketZ); getPhase(i).getComponent(componentName).setIsTBPfraction(true); getPhase(i).getComponent(componentName).setParachorParameter( - characterization.getTBPModel().calcParachorParameter(molarMass, density));// 59.3+2.34*molarMass*1000.0);//0.5003*thermo.ThermodynamicConstantsInterface.R*TC/PC*(0.25969-racketZ)); + characterization.getTBPModel().calcParachorParameter(molarMass, density)); // 59.3+2.34*molarMass*1000.0); + // //0.5003*thermo.ThermodynamicConstantsInterface.R*TC/PC*(0.25969-racketZ)); getPhase(i).getComponent(componentName).setCriticalViscosity( - characterization.getTBPModel().calcCriticalViscosity(molarMass * 1000.0, density));// 7.94830*Math.sqrt(1e3*molarMass)*Math.pow(PC,2.0/3.0)/Math.pow(TC, - // 1.0/6.0)*1e-7); + characterization.getTBPModel().calcCriticalViscosity(molarMass * 1000.0, density)); // 7.94830*Math.sqrt(1e3*molarMass)*Math.pow(PC,2.0/3.0)/Math.pow(TC, + // 1.0/6.0)*1e-7); getPhase(i).getComponent(componentName).setTriplePointTemperature( 374.5 + 0.02617 * getPhase(i).getComponent(componentName).getMolarMass() * 1000.0 - 20172.0 / (getPhase(i).getComponent(componentName).getMolarMass() * 1000.0)); @@ -1057,7 +1054,7 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo public void addPlusFraction(String componentName, double numberOfMoles, double molarMass, double density) { addTBPfraction(componentName, numberOfMoles, molarMass, density); - componentName = (componentName + "_" + "PC");// getFluidName()); + componentName = (componentName + "_" + "PC"); // getFluidName()); for (int i = 0; i < numberOfPhases; i++) { // System.out.println("comp " + componentName); getPhase(i).getComponent(componentName).setIsPlusFraction(true); @@ -1178,7 +1175,8 @@ public void addComponent(String componentName, double value, String unitName) { return; } neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); - java.sql.ResultSet dataSet = database.getResultSet(("SELECT * FROM comp WHERE name='" + componentName + "'")); + java.sql.ResultSet dataSet = + database.getResultSet(("SELECT * FROM comp WHERE name='" + componentName + "'")); double molarmass = 0.0; double stddens = 0.0; double boilp = 0.0; @@ -1196,7 +1194,8 @@ public void addComponent(String componentName, double value, String unitName) { logger.error("error", e); } } - neqsim.util.unit.Unit unit = new neqsim.util.unit.RateUnit(value, unitName, molarmass, stddens, boilp); + neqsim.util.unit.Unit unit = + new neqsim.util.unit.RateUnit(value, unitName, molarmass, stddens, boilp); double SIval = unit.getSIvalue(); // System.out.println("number of moles " + SIval); this.addComponent(componentName, SIval); @@ -1248,8 +1247,8 @@ public void addComponent(String componentName, double moles, int phaseNumber) { if (moles < 0.0) { String msg = "Negative input number of moles."; logger.error(msg); - neqsim.util.exception.InvalidInputException e = new neqsim.util.exception.InvalidInputException(this, - "addComponent", "moles", msg); + neqsim.util.exception.InvalidInputException e = + new neqsim.util.exception.InvalidInputException(this, "addComponent", "moles", msg); throw new RuntimeException(e); } @@ -1279,7 +1278,8 @@ public void addComponent(String componentName, double value, String name, int ph return; } neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); - java.sql.ResultSet dataSet = database.getResultSet(("SELECT * FROM comp WHERE name='" + componentName + "'")); + java.sql.ResultSet dataSet = + database.getResultSet(("SELECT * FROM comp WHERE name='" + componentName + "'")); double molarmass = 0.0; double stddens = 0.0; double boilp = 0.0; @@ -1304,7 +1304,8 @@ public void addComponent(String componentName, double value, String name, int ph logger.error("error", e); } } - neqsim.util.unit.Unit unit = new neqsim.util.unit.RateUnit(value, name, molarmass, stddens, boilp); + neqsim.util.unit.Unit unit = + new neqsim.util.unit.RateUnit(value, name, molarmass, stddens, boilp); double SIval = unit.getSIvalue(); // System.out.println("number of moles " + SIval); this.addComponent(componentName, SIval, phase); @@ -1480,8 +1481,7 @@ public final double calcBeta() throws neqsim.util.exception.IsNaNException, } /* - * if ((nybeta > maxBeta) || (nybeta < minBeta)) { // nybeta = 0.5 * (maxBeta + - * minBeta); + * if ((nybeta > maxBeta) || (nybeta < minBeta)) { // nybeta = 0.5 * (maxBeta + minBeta); * gbeta = 1.0; } */ } else { @@ -1512,15 +1512,14 @@ public final double calcBeta() throws neqsim.util.exception.IsNaNException, } /* - * if ((betal > maxBeta) || (betal < minBeta)) { gbeta = 1.0; { betal = 0.5 * - * (maxBeta + + * if ((betal > maxBeta) || (betal < minBeta)) { gbeta = 1.0; { betal = 0.5 * (maxBeta + * minBeta); } } */ nybeta = 1.0 - betal; } step = gbeta / deriv; // System.out.println("step : " + step); - } while (((Math.abs(step)) >= 1.0e-10 && iterations < maxIterations));// && + } while (((Math.abs(step)) >= 1.0e-10 && iterations < maxIterations)); // && // (Math.abs(nybeta)-Math.abs(maxBeta))>0.1); // System.out.println("beta: " + nybeta + " iterations: " + iterations); @@ -1543,8 +1542,7 @@ public final double calcBeta() throws neqsim.util.exception.IsNaNException, } if (Double.isNaN(beta[1])) { /* - * for (i = 0; i < numberOfComponents; i++) { System.out.println("K " + - * compArray[i].getK()); + * for (i = 0; i < numberOfComponents; i++) { System.out.println("K " + compArray[i].getK()); * System.out.println("z " + compArray[i].getz()); } */ throw new neqsim.util.exception.IsNaNException(this, "calcBeta", "beta"); @@ -1751,10 +1749,8 @@ public void init(int type, int phase) { * initAnalytic. *

* - * @param type a int. 0 to initialize and 1 to reset, 2 to calculate T and P - * derivatives, 3 to - * calculate all derivatives and 4 to calculate all derivatives - * numerically + * @param type a int. 0 to initialize and 1 to reset, 2 to calculate T and P derivatives, 3 to + * calculate all derivatives and 4 to calculate all derivatives numerically */ public void initAnalytic(int type) { if (type == 0) { @@ -1857,7 +1853,7 @@ public void initAnalytic(int type) { * initAnalytic. *

* - * @param type a int + * @param type a int * @param phase a int */ public void initAnalytic(int type, int phase) { @@ -1922,7 +1918,7 @@ public void initNumeric(int type) { * initNumeric. *

* - * @param type a int + * @param type a int * @param phasen a int */ public void initNumeric(int type, int phasen) { @@ -1992,7 +1988,8 @@ public void initNumeric(int type, int phasen) { init(1); for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - liqfug[0][i] = Math.log(getPhases()[phase].getComponents()[i].getFugacityCoefficient()); + liqfug[0][i] = + Math.log(getPhases()[phase].getComponents()[i].getFugacityCoefficient()); } addComponent(k, -2.0 * dn, phase); @@ -2003,7 +2000,8 @@ public void initNumeric(int type, int phasen) { for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { // gasfug[1][i] = // Math.log(getPhases()[0].getComponents()[i].getFugacityCoefficient()); - liqfug[1][i] = Math.log(getPhases()[phase].getComponents()[i].getFugacityCoefficient()); + liqfug[1][i] = + Math.log(getPhases()[phase].getComponents()[i].getFugacityCoefficient()); } addComponent(k, dn, phase); init_x_y(); @@ -2358,7 +2356,7 @@ public void setMixingRuleGEmodel(String name) { public final void setMixingRule(int type) { mixingRule = type; if (numberOfPhases < 4) { - resetPhysicalProperties();// initPhysicalProperties(); + resetPhysicalProperties(); // initPhysicalProperties(); } for (int i = 0; i < maxNumberOfPhases; i++) { if (IsPhase(i)) { @@ -2717,7 +2715,8 @@ public double getMolarVolume() { public double getDensity() { double density = 0; for (int i = 0; i < numberOfPhases; i++) { - density += 1.0e5 * (getPhase(i).getMolarMass() * beta[phaseIndex[i]] / getPhase(i).getMolarVolume()); + density += + 1.0e5 * (getPhase(i).getMolarMass() * beta[phaseIndex[i]] / getPhase(i).getMolarVolume()); } return density; } @@ -2727,7 +2726,8 @@ public double getDensity() { public double getDensity(String unit) { double density = 0; for (int i = 0; i < getNumberOfPhases(); i++) { - density += getPhase(i).getVolume() / getVolume() * getPhase(i).getPhysicalProperties().getDensity(); + density += + getPhase(i).getVolume() / getVolume() * getPhase(i).getPhysicalProperties().getDensity(); } double refDensity = density; // density in kg/m3 double conversionFactor = 1.0; @@ -2772,7 +2772,8 @@ public double getMoleFractionsSum() { public double getMolarMass() { double tempVar = 0; for (int i = 0; i < phaseArray[0].getNumberOfComponents(); i++) { - tempVar += phaseArray[0].getComponents()[i].getz() * phaseArray[0].getComponents()[i].getMolarMass(); + tempVar += + phaseArray[0].getComponents()[i].getz() * phaseArray[0].getComponents()[i].getMolarMass(); } return tempVar; } @@ -3199,8 +3200,7 @@ public double getCv(String unit) { * * @return kappa real gas kappa * - * method to return real gas isentropic exponent (kappa = - - * Cp/Cv*(v/p)*dp/dv + * method to return real gas isentropic exponent (kappa = - Cp/Cv*(v/p)*dp/dv */ public double getKappa() { return -getCp() / getCv() * getVolume() / getPressure() * getdPdVtn(); @@ -3287,7 +3287,7 @@ public String[][] createTable(String name) { /// 30][7]; // String[] names = {"", "Feed", "Phase 1", "Phase 2", "Phase 3", "Phase 4", /// "Unit"}; - table[0][0] = "";// getPhases()[0].getPhaseTypeName();//""; + table[0][0] = ""; // getPhases()[0].getPhaseTypeName(); //""; for (int i = 0; i < getPhases()[0].getNumberOfComponents() + 30; i++) { for (int j = 0; j < 7; j++) { @@ -3306,45 +3306,49 @@ public String[][] createTable(String name) { table[j + 1][1] = nf.format(getPhase(0).getComponents()[j].getz(), buf, test).toString(); } buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 4][1] = nf.format(getMolarMass() * 1000, buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 4][1] = + nf.format(getMolarMass() * 1000, buf, test).toString(); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 9][1] = nf - .format(getEnthalpy() / (getTotalNumberOfMoles() * getMolarMass() * 1000), buf, test) - .toString(); + table[getPhases()[0].getNumberOfComponents() + 9][1] = + nf.format(getEnthalpy() / (getTotalNumberOfMoles() * getMolarMass() * 1000), buf, test) + .toString(); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 10][1] = nf - .format(getEntropy() / (getTotalNumberOfMoles() * getMolarMass() * 1000), buf, test) - .toString(); + table[getPhases()[0].getNumberOfComponents() + 10][1] = + nf.format(getEntropy() / (getTotalNumberOfMoles() * getMolarMass() * 1000), buf, test) + .toString(); for (int i = 0; i < numberOfPhases; i++) { for (int j = 0; j < getPhases()[0].getNumberOfComponents(); j++) { table[j + 1][0] = getPhases()[0].getComponents()[j].getName(); buf = new StringBuffer(); - table[j + 1][i + 2] = nf.format(getPhase(i).getComponents()[j].getx(), buf, test).toString(); + table[j + 1][i + 2] = + nf.format(getPhase(i).getComponents()[j].getx(), buf, test).toString(); table[j + 1][6] = "[mole fraction]"; } buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 2][0] = "Density"; - table[getPhases()[0].getNumberOfComponents() + 2][i + 2] = nf - .format(getPhase(i).getPhysicalProperties().getDensity(), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 2][i + 2] = + nf.format(getPhase(i).getPhysicalProperties().getDensity(), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 2][6] = "[kg/m^3]"; // Double.longValue(system.getPhase(i).getBeta()); buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 3][0] = "PhaseFraction"; - table[getPhases()[0].getNumberOfComponents() + 3][i + 2] = nf.format(getPhase(i).getBeta(), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 3][i + 2] = + nf.format(getPhase(i).getBeta(), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 3][6] = "[mole fraction]"; buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 4][0] = "MolarMass"; - table[getPhases()[0].getNumberOfComponents() + 4][i + 2] = nf.format(getPhase(i).getMolarMass() * 1000, buf, test) - .toString(); + table[getPhases()[0].getNumberOfComponents() + 4][i + 2] = + nf.format(getPhase(i).getMolarMass() * 1000, buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 4][6] = "[kg/kmol]"; buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 5][0] = "Z factor"; - table[getPhases()[0].getNumberOfComponents() + 5][i + 2] = nf.format(getPhase(i).getZ(), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 5][i + 2] = + nf.format(getPhase(i).getZ(), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 5][6] = "[-]"; buf = new StringBuffer(); @@ -3365,8 +3369,8 @@ public String[][] createTable(String name) { buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 8][0] = "Speed of Sound"; - table[getPhases()[0].getNumberOfComponents() + 8][i + 2] = nf.format((getPhase(i).getSoundSpeed()), buf, test) - .toString(); + table[getPhases()[0].getNumberOfComponents() + 8][i + 2] = + nf.format((getPhase(i).getSoundSpeed()), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 8][6] = "[m/sec]"; buf = new StringBuffer(); @@ -3387,47 +3391,47 @@ public String[][] createTable(String name) { buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 11][0] = "JT coefficient"; - table[getPhases()[0].getNumberOfComponents() + 11][i + 2] = nf - .format((getPhase(i).getJouleThomsonCoefficient()), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 11][i + 2] = + nf.format((getPhase(i).getJouleThomsonCoefficient()), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 11][6] = "[K/bar]"; buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 13][0] = "Viscosity"; - table[getPhases()[0].getNumberOfComponents() + 13][i + 2] = nf - .format((getPhase(i).getPhysicalProperties().getViscosity()), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 13][i + 2] = + nf.format((getPhase(i).getPhysicalProperties().getViscosity()), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 13][6] = "[kg/m*sec]"; buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 14][0] = "Conductivity"; - table[getPhases()[0].getNumberOfComponents() + 14][i + 2] = nf - .format(getPhase(i).getPhysicalProperties().getConductivity(), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 14][i + 2] = + nf.format(getPhase(i).getPhysicalProperties().getConductivity(), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 14][6] = "[W/m*K]"; buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 15][0] = "SurfaceTension"; try { if (i < numberOfPhases - 1) { - table[getPhases()[0].getNumberOfComponents() + 15][2] = nf - .format(getInterphaseProperties().getSurfaceTension(0, 1), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 15][2] = + nf.format(getInterphaseProperties().getSurfaceTension(0, 1), buf, test).toString(); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 15][3] = nf - .format(getInterphaseProperties().getSurfaceTension(0, 1), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 15][3] = + nf.format(getInterphaseProperties().getSurfaceTension(0, 1), buf, test).toString(); buf = new StringBuffer(); if (i == 1) { - table[getPhases()[0].getNumberOfComponents() + 17][2] = nf - .format(getInterphaseProperties().getSurfaceTension(0, 2), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 17][2] = + nf.format(getInterphaseProperties().getSurfaceTension(0, 2), buf, test).toString(); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 17][4] = nf - .format(getInterphaseProperties().getSurfaceTension(0, 2), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 17][4] = + nf.format(getInterphaseProperties().getSurfaceTension(0, 2), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 17][6] = "[N/m]"; } if (i == 1) { buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 16][3] = nf - .format(getInterphaseProperties().getSurfaceTension(1, 2), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 16][3] = + nf.format(getInterphaseProperties().getSurfaceTension(1, 2), buf, test).toString(); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 16][4] = nf - .format(getInterphaseProperties().getSurfaceTension(1, 2), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 16][4] = + nf.format(getInterphaseProperties().getSurfaceTension(1, 2), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 16][6] = "[N/m]"; } } @@ -3438,12 +3442,14 @@ public String[][] createTable(String name) { buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 19][0] = "Pressure"; - table[getPhases()[0].getNumberOfComponents() + 19][i + 2] = Double.toString(getPhase(i).getPressure()); + table[getPhases()[0].getNumberOfComponents() + 19][i + 2] = + Double.toString(getPhase(i).getPressure()); table[getPhases()[0].getNumberOfComponents() + 19][6] = "[bar]"; buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 20][0] = "Temperature"; - table[getPhases()[0].getNumberOfComponents() + 20][i + 2] = Double.toString(getPhase(i).getTemperature()); + table[getPhases()[0].getNumberOfComponents() + 20][i + 2] = + Double.toString(getPhase(i).getTemperature()); table[getPhases()[0].getNumberOfComponents() + 20][6] = "[K]"; Double.toString(getPhase(i).getTemperature()); @@ -3455,8 +3461,8 @@ public String[][] createTable(String name) { buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 23][0] = "Mixing Rule"; try { - table[getPhases()[0].getNumberOfComponents() + 23][i + 2] = ((PhaseEosInterface) getPhase(i)) - .getMixingRuleName(); + table[getPhases()[0].getNumberOfComponents() + 23][i + 2] = + ((PhaseEosInterface) getPhase(i)).getMixingRuleName(); } catch (Exception e) { table[getPhases()[0].getNumberOfComponents() + 23][i + 2] = "?"; // logger.error("error",e); @@ -3487,7 +3493,7 @@ public void display(String name) { Container dialogContentPane = dialog.getContentPane(); dialogContentPane.setLayout(new BorderLayout()); - String[] names = { "", "Feed", "Phase 1", "Phase 2", "Phase 3", "Phase 4", "Unit" }; + String[] names = {"", "Feed", "Phase 1", "Phase 2", "Phase 3", "Phase 4", "Unit"}; String[][] table = createTable(name); JTable Jtab = new JTable(table, names); JScrollPane scrollpane = new JScrollPane(Jtab); @@ -3519,7 +3525,8 @@ public String write() { @Override public void write(String name, String filename, boolean newfile) { String[][] table = createTable(name); - neqsim.dataPresentation.fileHandeling.createTextFile.TextFile file = new neqsim.dataPresentation.fileHandeling.createTextFile.TextFile(); + neqsim.dataPresentation.fileHandeling.createTextFile.TextFile file = + new neqsim.dataPresentation.fileHandeling.createTextFile.TextFile(); if (newfile) { file.newFile(filename); } @@ -3757,7 +3764,8 @@ public void save(String name) { public SystemInterface readObject(int ID) { ResultSet rs = null; SystemThermo tempSystem = null; - neqsim.util.database.NeqSimBlobDatabase database = new neqsim.util.database.NeqSimBlobDatabase(); + neqsim.util.database.NeqSimBlobDatabase database = + new neqsim.util.database.NeqSimBlobDatabase(); try { java.sql.Connection con = database.openConnection(); String sqlStr = "SELECT FLUID FROM fluid_blobdb WHERE ID=" + Integer.toString(ID); @@ -3765,7 +3773,8 @@ public SystemInterface readObject(int ID) { rs = ps.executeQuery(); if (rs.next()) { - try (ObjectInputStream ins = new ObjectInputStream(new ByteArrayInputStream(rs.getBytes("FLUID")))) { + try (ObjectInputStream ins = + new ObjectInputStream(new ByteArrayInputStream(rs.getBytes("FLUID")))) { tempSystem = (SystemThermo) ins.readObject(); } } @@ -3812,20 +3821,21 @@ public void saveObject(int ID, String text) { byte[] byteObject = fout.toByteArray(); ByteArrayInputStream inpStream = new ByteArrayInputStream(byteObject); - neqsim.util.database.NeqSimBlobDatabase database = new neqsim.util.database.NeqSimBlobDatabase(); + neqsim.util.database.NeqSimBlobDatabase database = + new neqsim.util.database.NeqSimBlobDatabase(); try { java.sql.Connection con = database.openConnection(); - java.sql.PreparedStatement ps = con.prepareStatement("REPLACE INTO fluid_blobdb (ID, FLUID) VALUES (?,?)"); + java.sql.PreparedStatement ps = + con.prepareStatement("REPLACE INTO fluid_blobdb (ID, FLUID) VALUES (?,?)"); ps.setInt(1, ID); ps.setBlob(2, inpStream); ps.executeUpdate(); /* * if (!text.isEmpty()) { ps = con.prepareStatement( - * "REPLACE INTO fluidinfo (ID, TEXT) VALUES (?,?)"); ps.setInt(1, ID); - * ps.setString(2, text); + * "REPLACE INTO fluidinfo (ID, TEXT) VALUES (?,?)"); ps.setInt(1, ID); ps.setString(2, text); * } * * ps.executeUpdate(); @@ -3862,7 +3872,8 @@ public void saveObjectToFile(String filePath, String fluidName) { @Override public SystemInterface readObjectFromFile(String filePath, String fluidName) { SystemThermo tempSystem = null; - try (ObjectInputStream objectinputstream = new ObjectInputStream(new FileInputStream(filePath))) { + try (ObjectInputStream objectinputstream = + new ObjectInputStream(new FileInputStream(filePath))) { tempSystem = (SystemThermo) objectinputstream.readObject(); } catch (Exception e) { logger.error(e.toString()); @@ -3920,7 +3931,8 @@ public void addToComponentNames(java.lang.String name) { * @return a boolean */ public boolean setLastTBPasPlus() { - neqsim.thermo.characterization.PlusCharacterize temp = new neqsim.thermo.characterization.PlusCharacterize(this); + neqsim.thermo.characterization.PlusCharacterize temp = + new neqsim.thermo.characterization.PlusCharacterize(this); if (temp.hasPlusFraction()) { return false; } else { @@ -4045,8 +4057,9 @@ public void saveToDataBase() { database.execute("delete FROM systemreport"); int i = 0; for (; i < numberOfComponents; i++) { - String sqlString = "'" + Integer.toString(i + 1) + "', '" + getPhase(0).getComponent(i).getName() + "', " - + "'molfrac[-] ', '" + Double.toString(getPhase(0).getComponent(i).getz()) + "'"; + String sqlString = + "'" + Integer.toString(i + 1) + "', '" + getPhase(0).getComponent(i).getName() + "', " + + "'molfrac[-] ', '" + Double.toString(getPhase(0).getComponent(i).getz()) + "'"; int j = 0; for (; j < numberOfPhases; j++) { @@ -4215,7 +4228,8 @@ public double getHeatOfVaporization() { public void readFluid(String fluidName) { this.fluidName = fluidName; try { - neqsim.util.database.NeqSimFluidDataBase database = new neqsim.util.database.NeqSimFluidDataBase(); + neqsim.util.database.NeqSimFluidDataBase database = + new neqsim.util.database.NeqSimFluidDataBase(); java.sql.ResultSet dataSet = null; dataSet = database.getResultSet("SELECT * FROM " + fluidName); @@ -4279,13 +4293,15 @@ public SystemInterface setModel(String model) { tempModel = new SystemSrkSchwartzentruberEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); } else if (model.equals("Electrolyte-ScRK-EOS")) { - tempModel = new SystemFurstElectrolyteEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); + tempModel = + new SystemFurstElectrolyteEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); } else if (model.equals("GERG-water-EOS")) { tempModel = new SystemGERGwaterEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); } else if (model.equals("CPAs-SRK-EOS")) { tempModel = new SystemSrkCPAs(getPhase(0).getTemperature(), getPhase(0).getPressure()); } else if (model.equals("CPAs-SRK-EOS-statoil")) { - tempModel = new SystemSrkCPAstatoil(getPhase(0).getTemperature(), getPhase(0).getPressure()); + tempModel = + new SystemSrkCPAstatoil(getPhase(0).getTemperature(), getPhase(0).getPressure()); } else if (model.equals("Electrolyte-CPA-EOS-statoil") || model.equals("Electrolyte-CPA-EOS")) { tempModel = new SystemElectrolyteCPAstatoil(getPhase(0).getTemperature(), @@ -4297,9 +4313,11 @@ public SystemInterface setModel(String model) { } else if (model.equals("GERG-2008-EoS")) { tempModel = new SystemGERG2004Eos(getPhase(0).getTemperature(), getPhase(0).getPressure()); } else if (model.equals("SRK-TwuCoon-Statoil-EOS") || model.equals("SRK-TwuCoon-EOS")) { - tempModel = new SystemSrkTwuCoonStatoilEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); + tempModel = + new SystemSrkTwuCoonStatoilEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); } else if (model.equals("SRK-TwuCoon-Param-EOS")) { - tempModel = new SystemSrkTwuCoonParamEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); + tempModel = + new SystemSrkTwuCoonParamEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); } else if (model.equals("Duan-Sun")) { tempModel = new SystemDuanSun(getPhase(0).getTemperature(), getPhase(0).getPressure()); } else { diff --git a/src/main/java/neqsim/thermo/util/GERG/GERG2008.java b/src/main/java/neqsim/thermo/util/GERG/GERG2008.java index 165928b8d1..3a0488159d 100644 --- a/src/main/java/neqsim/thermo/util/GERG/GERG2008.java +++ b/src/main/java/neqsim/thermo/util/GERG/GERG2008.java @@ -15,14 +15,21 @@ public class GERG2008 { // Variables containing the common parameters in the GERG-2008 equations static double RGERG; - static int NcGERG = 21, MaxFlds = 21, MaxMdl = 10, MaxTrmM = 12, MaxTrmP = 24; + static int NcGERG = 21; + static int MaxFlds = 21; + static int MaxMdl = 10; + static int MaxTrmM = 12; + static int MaxTrmP = 24; static double epsilon = 1e-15; static int[][] intcoik = new int[MaxFlds + 1][MaxTrmP + 1]; static int[][] coik = new int[MaxFlds + 1][MaxTrmP + 1]; static int[][] doik = new int[MaxFlds + 1][MaxTrmP + 1]; static int[][] dijk = new int[MaxMdl + 1][MaxTrmM + 1]; - static double Drold, Trold, Told, Trold2; + static double Drold; + static double Trold; + static double Told; + static double Trold2; static double[] xold = new double[MaxFlds + 1]; static int[][] mNumb = new int[MaxFlds + 1][MaxFlds + 1]; static int[] kpol = new int[MaxFlds + 1]; @@ -68,25 +75,25 @@ public class GERG2008 { * @param Mm a {@link org.netlib.util.doubleW} object */ public static void MolarMassGERG(double[] x, doubleW Mm) { - // Sub MolarMassGERG(x, Mm) + // Sub MolarMassGERG(x, Mm) - // Calculate molar mass of the mixture with the compositions contained in the - // x() input array + // Calculate molar mass of the mixture with the compositions contained in the + // x() input array - // Inputs: - // x() - Composition (mole fraction) - // Do not send mole percents or mass fractions in the x() array, otherwise the - // output will be incorrect. - // The sum of the compositions in the x() array must be equal to one. - // The order of the fluids in this array is given at the top of this module. + // Inputs: + // x() - Composition (mole fraction) + // Do not send mole percents or mass fractions in the x() array, otherwise the + // output will be incorrect. + // The sum of the compositions in the x() array must be equal to one. + // The order of the fluids in this array is given at the top of this module. - // Outputs: - // Mm - Molar mass (g/mol) + // Outputs: + // Mm - Molar mass (g/mol) - Mm.val = 0; - for (int i = 1; i <= NcGERG; ++i) { - Mm.val += x[i] * MMiGERG[i]; - } + Mm.val = 0; + for (int i = 1; i <= NcGERG; ++i) { + Mm.val += x[i] * MMiGERG[i]; + } } /** @@ -101,39 +108,39 @@ public static void MolarMassGERG(double[] x, doubleW Mm) { * @param Z a {@link org.netlib.util.doubleW} object */ public static void PressureGERG(double T, double D, double[] x, doubleW P, doubleW Z) { - // Sub PressureGERG(T, D, x, P, Z) - - // Calculate pressure as a function of temperature and density. The derivative - // d(P)/d(D) is also calculated - // for use in the iterative DensityGERG subroutine (and is only returned as a - // common variable). - - // Inputs: - // T - Temperature (K) - // D - Density (mol/l) - // x() - Composition (mole fraction) - // Do not send mole percents or mass fractions in the x() array, otherwise the - // output will be incorrect. - // The sum of the compositions in the x() array must be equal to one. - - // Outputs: - // P - Pressure (kPa) - // Z - Compressibility factor - // dPdDsave - d(P)/d(D) [kPa/(mol/l)] (at constant temperature) - // - This variable is cached in the common variables for use in the iterative - // density solver, but not returned as an argument. - - doubleW[][] ar = new doubleW[4][4]; - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - ar[i][j] = new doubleW(0.0d); - } + // Sub PressureGERG(T, D, x, P, Z) + + // Calculate pressure as a function of temperature and density. The derivative + // d(P)/d(D) is also calculated + // for use in the iterative DensityGERG subroutine (and is only returned as a + // common variable). + + // Inputs: + // T - Temperature (K) + // D - Density (mol/l) + // x() - Composition (mole fraction) + // Do not send mole percents or mass fractions in the x() array, otherwise the + // output will be incorrect. + // The sum of the compositions in the x() array must be equal to one. + + // Outputs: + // P - Pressure (kPa) + // Z - Compressibility factor + // dPdDsave - d(P)/d(D) [kPa/(mol/l)] (at constant temperature) + // - This variable is cached in the common variables for use in the iterative + // density solver, but not returned as an argument. + + doubleW[][] ar = new doubleW[4][4]; + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + ar[i][j] = new doubleW(0.0d); } - AlpharGERG(0, 0, T, D, x, ar); + } + AlpharGERG(0, 0, T, D, x, ar); - Z.val = 1 + ar[0][1].val; - P.val = D * RGERG * T * Z.val; - dPdDsave = RGERG * T * (1 + 2 * ar[0][1].val + ar[0][2].val); + Z.val = 1 + ar[0][1].val; + P.val = D * RGERG * T * Z.val; + dPdDsave = RGERG * T * (1 + 2 * ar[0][1].val + ar[0][2].val); } /** @@ -150,158 +157,174 @@ public static void PressureGERG(double T, double D, double[] x, doubleW P, doubl * @param herr a {@link org.netlib.util.StringW} object */ public static void DensityGERG(int iFlag, double T, double P, double[] x, doubleW D, intW ierr, - StringW herr) { - // Sub DensityGERG(iFlag, T, P, x, D, ierr, herr) - - // Calculate density as a function of temperature and pressure. This is an - // iterative routine that calls PressureGERG - // to find the correct state point. Generally only 6 iterations at most are - // required. - // If the iteration fails to converge, the ideal gas density and an error - // message are returned. - // No checks are made to determine the phase boundary, which would have - // guaranteed that the output is in the gas phase (or liquid phase when - // iFlag=2). - // It is up to the user to locate the phase boundary, and thus identify the - // phase of the T and P inputs. - // If the state point is 2-phase, the output density will represent a metastable - // state. - - // Inputs: - // iFlag - Set to 0 for strict pressure solver in the gas phase without checks - // (fastest mode, but output state may not be stable single phase) - // Set to 1 to make checks for possible 2-phase states (result may still not be - // stable single phase, but many unstable states will be identified) - // Set to 2 to search for liquid phase (and make the same checks when iFlag=1) - // T - Temperature (K) - // P - Pressure (kPa) - // x() - Composition (mole fraction) - // (An initial guess for the density can be sent in D as the negative of the - // guess for roots that are in the liquid phase instead of using iFlag=2) - - // Outputs: - // D - Density (mol/l) - // For the liquid phase, an initial value can be sent to the routine to avoid - // a solution in the metastable or gas phases. - // The initial value should be sent as a negative number. - // ierr - Error number (0 indicates no error) - // herr - Error message if ierr is not equal to zero - - int nFail, iFail; - double plog, vlog, dpdlv, vdiff, tolr, vinc; - doubleW Tcx = new doubleW(0.0d), Dcx = new doubleW(0.0d); - - doubleW dPdD = new doubleW(0.0d), d2PdD2 = new doubleW(0.0d), d2PdTD = new doubleW(0.0d), - dPdT = new doubleW(0.0d), U = new doubleW(0.0d), H = new doubleW(0.0d), - S = new doubleW(0.0d), A = new doubleW(0.0d), P2 = new doubleW(0.0d), - Z = new doubleW(0.0d); - doubleW Cv = new doubleW(0.0d), Cp = new doubleW(0.0d), W = new doubleW(0.0d), - G = new doubleW(0.0d), JT = new doubleW(0.0d), Kappa = new doubleW(0.0d), - PP = new doubleW(0.0d); - - ierr.val = 0; - herr.val = ""; - nFail = 0; - iFail = 0; - if (P < epsilon) { - D.val = 0; - return; + StringW herr) { + // Sub DensityGERG(iFlag, T, P, x, D, ierr, herr) + + // Calculate density as a function of temperature and pressure. This is an + // iterative routine that calls PressureGERG + // to find the correct state point. Generally only 6 iterations at most are + // required. + // If the iteration fails to converge, the ideal gas density and an error + // message are returned. + // No checks are made to determine the phase boundary, which would have + // guaranteed that the output is in the gas phase (or liquid phase when + // iFlag=2). + // It is up to the user to locate the phase boundary, and thus identify the + // phase of the T and P inputs. + // If the state point is 2-phase, the output density will represent a metastable + // state. + + // Inputs: + // iFlag - Set to 0 for strict pressure solver in the gas phase without checks + // (fastest mode, but output state may not be stable single phase) + // Set to 1 to make checks for possible 2-phase states (result may still not be + // stable single phase, but many unstable states will be identified) + // Set to 2 to search for liquid phase (and make the same checks when iFlag=1) + // T - Temperature (K) + // P - Pressure (kPa) + // x() - Composition (mole fraction) + // (An initial guess for the density can be sent in D as the negative of the + // guess for roots that are in the liquid phase instead of using iFlag=2) + + // Outputs: + // D - Density (mol/l) + // For the liquid phase, an initial value can be sent to the routine to avoid + // a solution in the metastable or gas phases. + // The initial value should be sent as a negative number. + // ierr - Error number (0 indicates no error) + // herr - Error message if ierr is not equal to zero + + int nFail; + int iFail; + double plog; + double vlog; + double dpdlv; + double vdiff; + double tolr; + double vinc; + doubleW Tcx = new doubleW(0.0d); + + doubleW Dcx = new doubleW(0.0d); + doubleW dPdD = new doubleW(0.0d); + doubleW d2PdD2 = new doubleW(0.0d); + doubleW d2PdTD = new doubleW(0.0d); + doubleW dPdT = new doubleW(0.0d); + doubleW U = new doubleW(0.0d); + doubleW H = new doubleW(0.0d); + doubleW S = new doubleW(0.0d); + doubleW A = new doubleW(0.0d); + doubleW P2 = new doubleW(0.0d); + doubleW Z = new doubleW(0.0d); + doubleW Cv = new doubleW(0.0d); + + doubleW Cp = new doubleW(0.0d); + doubleW W = new doubleW(0.0d); + doubleW G = new doubleW(0.0d); + doubleW JT = new doubleW(0.0d); + doubleW Kappa = new doubleW(0.0d); + doubleW PP = new doubleW(0.0d); + ierr.val = 0; + herr.val = ""; + nFail = 0; + iFail = 0; + if (P < epsilon) { + D.val = 0; + return; + } + tolr = 0.0000001; + PseudoCriticalPointGERG(x, Tcx, Dcx); + + if (D.val > -epsilon) { + D.val = P / RGERG / T; // Ideal gas estimate for vapor phase + if (iFlag == 2) { + D.val = Dcx.val * 3; + } // Initial estimate for liquid phase + } else { + D.val = Math.abs(D.val); // If D<0, then use as initial estimate + } + + plog = Math.log(P); + vlog = -Math.log(D.val); + for (int it = 1; it <= 50; ++it) { + if (vlog < -7 || vlog > 100 || it == 20 || it == 30 || it == 40 || iFail == 1) { + // Current state is bad or iteration is taking too long. Restart with completely + // different initial state + iFail = 0; + if (nFail > 2) { + // Iteration failed (above loop did not find a solution or checks made below + // indicate possible 2-phase state) + ierr.val = 1; + herr.val = "Calculation failed to converge in GERG method, ideal gas density returned."; + D.val = P / RGERG / T; + } + nFail++; + if (nFail == 1) { + D.val = Dcx.val * 3; // If vapor phase search fails, look for root in liquid + // region + } else if (nFail == 2) { + D.val = Dcx.val * 2.5; // If liquid phase search fails, look for root between + // liquid and critical + // regions + } else if (nFail == 3) { + D.val = Dcx.val * 2; // If search fails, look for root in critical region + } + vlog = -Math.log(D.val); } - tolr = 0.0000001; - PseudoCriticalPointGERG(x, Tcx, Dcx); - - if (D.val > -epsilon) { - D.val = P / RGERG / T; // Ideal gas estimate for vapor phase - if (iFlag == 2) { - D.val = Dcx.val * 3; - } // Initial estimate for liquid phase + D.val = Math.exp(-vlog); + PressureGERG(T, D.val, x, P2, Z); + if (dPdDsave < epsilon || P2.val < epsilon) { + // Current state is 2-phase, try locating a different state that is single phase + vinc = 0.1; + if (D.val > Dcx.val) { + vinc = -0.1; + } + if (it > 5) { + vinc = vinc / 2; + } + if (it > 10 && it < 20) { + vinc = vinc / 5; + } + vlog += vinc; } else { - D.val = Math.abs(D.val); // If D<0, then use as initial estimate - } - - plog = Math.log(P); - vlog = -Math.log(D.val); - for (int it = 1; it <= 50; ++it) { - if (vlog < -7 || vlog > 100 || it == 20 || it == 30 || it == 40 || iFail == 1) { - // Current state is bad or iteration is taking too long. Restart with completely - // different initial state - iFail = 0; - if (nFail > 2) { - // Iteration failed (above loop did not find a solution or checks made below - // indicate possible 2-phase state) - ierr.val = 1; - herr.val = - "Calculation failed to converge in GERG method, ideal gas density returned."; - D.val = P / RGERG / T; - } - nFail++; - if (nFail == 1) { - D.val = Dcx.val * 3; // If vapor phase search fails, look for root in liquid - // region - } else if (nFail == 2) { - D.val = Dcx.val * 2.5; // If liquid phase search fails, look for root between - // liquid and critical - // regions - } else if (nFail == 3) { - D.val = Dcx.val * 2; // If search fails, look for root in critical region - } - vlog = -Math.log(D.val); - } - D.val = Math.exp(-vlog); - PressureGERG(T, D.val, x, P2, Z); - if (dPdDsave < epsilon || P2.val < epsilon) { - // Current state is 2-phase, try locating a different state that is single phase - vinc = 0.1; - if (D.val > Dcx.val) { - vinc = -0.1; - } - if (it > 5) { - vinc = vinc / 2; - } - if (it > 10 && it < 20) { - vinc = vinc / 5; - } - vlog += vinc; + // Find the next density with a first order Newton's type iterative scheme, with + // log(P) as the known variable and log(v) as the unknown property. + // See AGA 8 publication for further information. + dpdlv = -D.val * dPdDsave; // d(p)/d[log(v)] + vdiff = (Math.log(P2.val) - plog) * P2.val / dpdlv; + vlog += -vdiff; + if (Math.abs(vdiff) < tolr) { + // Check to see if state is possibly 2-phase, and if so restart + if (dPdDsave < 0) { + iFail = 1; } else { - // Find the next density with a first order Newton's type iterative scheme, with - // log(P) as the known variable and log(v) as the unknown property. - // See AGA 8 publication for further information. - dpdlv = -D.val * dPdDsave; // d(p)/d[log(v)] - vdiff = (Math.log(P2.val) - plog) * P2.val / dpdlv; - vlog += -vdiff; - if (Math.abs(vdiff) < tolr) { - // Check to see if state is possibly 2-phase, and if so restart - if (dPdDsave < 0) { - iFail = 1; - } else { - D.val = Math.exp(-vlog); - - // If requested, check to see if point is possibly 2-phase - if (iFlag > 0) { - PropertiesGERG(T, D.val, x, PP, Z, dPdD, d2PdD2, d2PdTD, dPdT, U, H, S, - Cv, Cp, W, G, JT, Kappa, A); - if ((PP.val <= 0 || dPdD.val <= 0 || d2PdTD.val <= 0) - || (Cv.val <= 0 || Cp.val <= 0 || W.val <= 0)) { - // Iteration failed (above loop did find a solution or checks made - // below - // indicate possible 2-phase state) - ierr.val = 1; - herr.val = - "Calculation failed to converge in GERG method, ideal gas density returned."; - D.val = P / RGERG / T; - } - return; - } - return; // Iteration converged - } + D.val = Math.exp(-vlog); + + // If requested, check to see if point is possibly 2-phase + if (iFlag > 0) { + PropertiesGERG(T, D.val, x, PP, Z, dPdD, d2PdD2, d2PdTD, dPdT, U, H, S, Cv, Cp, W, + G, JT, Kappa, A); + if ((PP.val <= 0 || dPdD.val <= 0 || d2PdTD.val <= 0) + || (Cv.val <= 0 || Cp.val <= 0 || W.val <= 0)) { + // Iteration failed (above loop did find a solution or checks made + // below + // indicate possible 2-phase state) + ierr.val = 1; + herr.val = + "Calculation failed to converge in GERG method, ideal gas density returned."; + D.val = P / RGERG / T; } + return; + } + return; // Iteration converged } + } } - // Iteration failed (above loop did not find a solution or checks made below - // indicate possible 2-phase state) - ierr.val = 1; - herr.val = "Calculation failed to converge in GERG method, ideal gas density returned."; - D.val = P / RGERG / T; + } + // Iteration failed (above loop did not find a solution or checks made below + // indicate possible 2-phase state) + ierr.val = 1; + herr.val = "Calculation failed to converge in GERG method, ideal gas density returned."; + D.val = P / RGERG / T; } /** @@ -330,101 +353,101 @@ public static void DensityGERG(int iFlag, double T, double P, double[] x, double * @param A a {@link org.netlib.util.doubleW} object */ public static void PropertiesGERG(double T, double D, double[] x, doubleW P, doubleW Z, - doubleW dPdD, doubleW d2PdD2, doubleW d2PdTD, doubleW dPdT, doubleW U, doubleW H, - doubleW S, doubleW Cv, doubleW Cp, doubleW W, doubleW G, doubleW JT, doubleW Kappa, - doubleW A) { - // Sub PropertiesGERG(T, D, x, P, Z, dPdD, d2PdD2, d2PdTD, dPdT, U, H, S, Cv, - // Cp, W, G, JT, Kappa, A) - - // Calculate thermodynamic properties as a function of temperature and density. - // Calls are made to the subroutines - // ReducingParametersGERG, IdealGERG, and ResidualGERG. If the density is not - // known, call subroutine DENSITY first - // with the known values of pressure and temperature. - - // Inputs: - // T - Temperature (K) - // D - Density (mol/l) - // x() - Composition (mole fraction) - - // Outputs: - // P - Pressure (kPa) - // Z - Compressibility factor - // dPdD - First derivative of pressure with respect to density at constant - // temperature [kPa/(mol/l)] - // d2PdD2 - Second derivative of pressure with respect to density at constant - // temperature [kPa/(mol/l)^2] - // d2PdTD - Second derivative of pressure with respect to temperature and - // density [kPa/(mol/l)/K] - // dPdT - First derivative of pressure with respect to temperature at constant - // density (kPa/K) - // U - Internal energy (J/mol) - // H - Enthalpy (J/mol) - // S - Entropy [J/(mol-K)] - // Cv - Isochoric heat capacity [J/(mol-K)] - // Cp - Isobaric heat capacity [J/(mol-K)] - // W - Speed of sound (m/s) - // G - Gibbs energy (J/mol) - // JT - Joule-Thomson coefficient (K/kPa) - // Kappa - Isentropic Exponent - // A - Helmholtz energy (J/mol) - - doubleW[] a0 = new doubleW[2 + 1]; - for (int i = 0; i < 3; i++) { - a0[i] = new doubleW(0.0d); - } - doubleW[][] ar = new doubleW[3 + 1][3 + 1]; - - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - ar[i][j] = new doubleW(0.0d); - } - } - - doubleW Mm = new doubleW(0.0d);// , R, RT; - double R, RT; - // Calculate molar mass - MolarMassGERG(x, Mm); - - // Calculate the ideal gas Helmholtz energy, and its first and second - // derivatives with respect to temperature. - Alpha0GERG(T, D, x, a0); - - // Calculate the real gas Helmholtz energy, and its derivatives with respect to - // temperature and/or density. - AlpharGERG(1, 0, T, D, x, ar); - - R = RGERG; - RT = R * T; - Z.val = 1 + ar[0][1].val; - P.val = D * RT * Z.val; - dPdD.val = RT * (1 + 2 * ar[0][1].val + ar[0][2].val); - dPdT.val = D * R * (1 + ar[0][1].val - ar[1][1].val); - - d2PdTD.val = R * (1 + 2 * ar[0][1].val + ar[0][2].val - 2 * ar[1][1].val - ar[1][2].val); - A.val = RT * (a0[0].val + ar[0][0].val); - G.val = RT * (1 + ar[0][1].val + a0[0].val + ar[0][0].val); - U.val = RT * (a0[1].val + ar[1][0].val); - H.val = RT * (1 + ar[0][1].val + a0[1].val + ar[1][0].val); - S.val = R * (a0[1].val + ar[1][0].val - a0[0].val - ar[0][0].val); - Cv.val = -R * (a0[2].val + ar[2][0].val); - if (D > epsilon) { - Cp.val = Cv.val + T * (dPdT.val / D) * (dPdT.val / D) / dPdD.val; - d2PdD2.val = RT * (2 * ar[0][1].val + 4 * ar[0][2].val + ar[0][3].val) / D; - JT.val = (T / D * dPdT.val / dPdD.val - 1) / Cp.val / D; // '=(dB/dT*T-B)/Cp for an - // ideal gas, but dB/dT is - // not known - } else { - Cp.val = Cv.val + R; - d2PdD2.val = 0; - JT.val = 1E+20; - } - W.val = 1000 * Cp.val / Cv.val * dPdD.val / Mm.val; - if (W.val < 0) { - W.val = 0; + doubleW dPdD, doubleW d2PdD2, doubleW d2PdTD, doubleW dPdT, doubleW U, doubleW H, doubleW S, + doubleW Cv, doubleW Cp, doubleW W, doubleW G, doubleW JT, doubleW Kappa, doubleW A) { + // Sub PropertiesGERG(T, D, x, P, Z, dPdD, d2PdD2, d2PdTD, dPdT, U, H, S, Cv, + // Cp, W, G, JT, Kappa, A) + + // Calculate thermodynamic properties as a function of temperature and density. + // Calls are made to the subroutines + // ReducingParametersGERG, IdealGERG, and ResidualGERG. If the density is not + // known, call subroutine DENSITY first + // with the known values of pressure and temperature. + + // Inputs: + // T - Temperature (K) + // D - Density (mol/l) + // x() - Composition (mole fraction) + + // Outputs: + // P - Pressure (kPa) + // Z - Compressibility factor + // dPdD - First derivative of pressure with respect to density at constant + // temperature [kPa/(mol/l)] + // d2PdD2 - Second derivative of pressure with respect to density at constant + // temperature [kPa/(mol/l)^2] + // d2PdTD - Second derivative of pressure with respect to temperature and + // density [kPa/(mol/l)/K] + // dPdT - First derivative of pressure with respect to temperature at constant + // density (kPa/K) + // U - Internal energy (J/mol) + // H - Enthalpy (J/mol) + // S - Entropy [J/(mol-K)] + // Cv - Isochoric heat capacity [J/(mol-K)] + // Cp - Isobaric heat capacity [J/(mol-K)] + // W - Speed of sound (m/s) + // G - Gibbs energy (J/mol) + // JT - Joule-Thomson coefficient (K/kPa) + // Kappa - Isentropic Exponent + // A - Helmholtz energy (J/mol) + + doubleW[] a0 = new doubleW[2 + 1]; + for (int i = 0; i < 3; i++) { + a0[i] = new doubleW(0.0d); + } + doubleW[][] ar = new doubleW[3 + 1][3 + 1]; + + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + ar[i][j] = new doubleW(0.0d); } - W.val = Math.sqrt(W.val); - Kappa.val = Math.pow(W.val, 2) * Mm.val / (RT * 1000 * Z.val); + } + + doubleW Mm = new doubleW(0.0d); // , R, RT; + double R; + double RT; + // Calculate molar mass + MolarMassGERG(x, Mm); + + // Calculate the ideal gas Helmholtz energy, and its first and second + // derivatives with respect to temperature. + Alpha0GERG(T, D, x, a0); + + // Calculate the real gas Helmholtz energy, and its derivatives with respect to + // temperature and/or density. + AlpharGERG(1, 0, T, D, x, ar); + + R = RGERG; + RT = R * T; + Z.val = 1 + ar[0][1].val; + P.val = D * RT * Z.val; + dPdD.val = RT * (1 + 2 * ar[0][1].val + ar[0][2].val); + dPdT.val = D * R * (1 + ar[0][1].val - ar[1][1].val); + + d2PdTD.val = R * (1 + 2 * ar[0][1].val + ar[0][2].val - 2 * ar[1][1].val - ar[1][2].val); + A.val = RT * (a0[0].val + ar[0][0].val); + G.val = RT * (1 + ar[0][1].val + a0[0].val + ar[0][0].val); + U.val = RT * (a0[1].val + ar[1][0].val); + H.val = RT * (1 + ar[0][1].val + a0[1].val + ar[1][0].val); + S.val = R * (a0[1].val + ar[1][0].val - a0[0].val - ar[0][0].val); + Cv.val = -R * (a0[2].val + ar[2][0].val); + if (D > epsilon) { + Cp.val = Cv.val + T * (dPdT.val / D) * (dPdT.val / D) / dPdD.val; + d2PdD2.val = RT * (2 * ar[0][1].val + 4 * ar[0][2].val + ar[0][3].val) / D; + JT.val = (T / D * dPdT.val / dPdD.val - 1) / Cp.val / D; // '=(dB/dT*T-B)/Cp for an + // ideal gas, but dB/dT is + // not known + } else { + Cp.val = Cv.val + R; + d2PdD2.val = 0; + JT.val = 1E+20; + } + W.val = 1000 * Cp.val / Cv.val * dPdD.val / Mm.val; + if (W.val < 0) { + W.val = 0; + } + W.val = Math.sqrt(W.val); + Kappa.val = Math.pow(W.val, 2) * Mm.val / (RT * 1000 * Z.val); } /** @@ -434,60 +457,62 @@ public static void PropertiesGERG(double T, double D, double[] x, doubleW P, dou */ // The following routines are low-level routines that should not be called outside of this code. static void ReducingParametersGERG(double[] x, doubleW Tr, doubleW Dr) { - // Private Sub ReducingParametersGERG(x, Tr, Dr) + // Private Sub ReducingParametersGERG(x, Tr, Dr) - // Calculate reducing variables. Only need to call this if the composition has - // changed. + // Calculate reducing variables. Only need to call this if the composition has + // changed. - // Inputs: - // x() - Composition (mole fraction) + // Inputs: + // x() - Composition (mole fraction) - // Outputs: - // Tr - Reducing temperature (K) - // Dr - Reducing density (mol/l) + // Outputs: + // Tr - Reducing temperature (K) + // Dr - Reducing density (mol/l) - double Vr, xij, F; - int icheck; + double Vr; + double xij; + double F; + int icheck; - // Check to see if a component fraction has changed. If x is the same as the previous call, - // then exit. - icheck = 0; - for (int i = 1; i <= NcGERG; ++i) { - if (Math.abs(x[i] - xold[i]) > 0.0000001) { - icheck = 1; - } - xold[i] = x[i]; - } - if (icheck == 0) { - Dr.val = Drold; - Tr.val = Trold; - return; + // Check to see if a component fraction has changed. If x is the same as the previous call, + // then exit. + icheck = 0; + for (int i = 1; i <= NcGERG; ++i) { + if (Math.abs(x[i] - xold[i]) > 0.0000001) { + icheck = 1; } - Told = 0; - Trold2 = 0; - - // Calculate reducing variables for T and D - Dr.val = 0; - Vr = 0; - Tr.val = 0; - for (int i = 1; i <= NcGERG; ++i) { - if (x[i] > epsilon) { - F = 1; - for (int j = i; j <= NcGERG; ++j) { - if (x[j] > epsilon) { - xij = F * (x[i] * x[j]) * (x[i] + x[j]); - Vr = Vr + xij * gvij[i][j] / (bvij[i][j] * x[i] + x[j]); - Tr.val = Tr.val + xij * gtij[i][j] / (btij[i][j] * x[i] + x[j]); - F = 2; - } - } + xold[i] = x[i]; + } + if (icheck == 0) { + Dr.val = Drold; + Tr.val = Trold; + return; + } + Told = 0; + Trold2 = 0; + + // Calculate reducing variables for T and D + Dr.val = 0; + Vr = 0; + Tr.val = 0; + for (int i = 1; i <= NcGERG; ++i) { + if (x[i] > epsilon) { + F = 1; + for (int j = i; j <= NcGERG; ++j) { + if (x[j] > epsilon) { + xij = F * (x[i] * x[j]) * (x[i] + x[j]); + Vr = Vr + xij * gvij[i][j] / (bvij[i][j] * x[i] + x[j]); + Tr.val = Tr.val + xij * gtij[i][j] / (btij[i][j] * x[i] + x[j]); + F = 2; } + } } - if (Vr > epsilon) { - Dr.val = 1 / Vr; - } - Drold = Dr.val; - Trold = Tr.val; + } + if (Vr > epsilon) { + Dr.val = 1 / Vr; + } + Drold = Dr.val; + Trold = Tr.val; } /** @@ -497,67 +522,75 @@ static void ReducingParametersGERG(double[] x, doubleW Tr, doubleW Dr) { * @param a0 ... */ static void Alpha0GERG(double T, double D, double[] x, doubleW[] a0) { - // Private Sub Alpha0GERG(T, D, x, a0) - - // Calculate the ideal gas Helmholtz energy and its derivatives with respect to - // tau and delta. - // This routine is not needed when only P (or Z) is calculated. - - // Inputs: - // T - Temperature (K) - // D - Density (mol/l) - // x() - Composition (mole fraction) - - // Outputs: - // a0(0) - Ideal gas Helmholtz energy (all dimensionless [i.e., divided by RT]) - // a0(1) - tau*partial(a0)/partial(tau) - // a0(2) - tau^2*partial^2(a0)/partial(tau)^2 - - double LogT, LogD, LogHyp, th0T, LogxD; - double SumHyp0, SumHyp1, SumHyp2; - double em, ep, hcn, hsn; - - a0[0].val = 0; - a0[1].val = 0; - a0[2].val = 0; - if (D > epsilon) { - LogD = Math.log(D); - } else { - LogD = Math.log(epsilon); - } - LogT = Math.log(T); - for (int i = 1; i <= NcGERG; ++i) { - if (x[i] > epsilon) { - LogxD = LogD + Math.log(x[i]); - SumHyp0 = 0; - SumHyp1 = 0; - SumHyp2 = 0; - for (int j = 4; j <= 7; ++j) { - if (th0i[i][j] > epsilon) { - th0T = th0i[i][j] / T; - ep = Math.exp(th0T); - em = 1 / ep; - hsn = (ep - em) / 2; - hcn = (ep + em) / 2; - if (j == 4 || j == 6) { - LogHyp = Math.log(Math.abs(hsn)); - SumHyp0 = SumHyp0 + n0i[i][j] * LogHyp; - SumHyp1 = SumHyp1 + n0i[i][j] * th0T * hcn / hsn; - SumHyp2 = SumHyp2 + n0i[i][j] * (th0T / hsn) * (th0T / hsn); - } else { - LogHyp = Math.log(Math.abs(hcn)); - SumHyp0 = SumHyp0 - n0i[i][j] * LogHyp; - SumHyp1 = SumHyp1 - n0i[i][j] * th0T * hsn / hcn; - SumHyp2 = SumHyp2 + n0i[i][j] * (th0T / hcn) * (th0T / hcn); - } - } - } - a0[0].val += - +x[i] * (LogxD + n0i[i][1] + n0i[i][2] / T - n0i[i][3] * LogT + SumHyp0); - a0[1].val += +x[i] * (n0i[i][3] + n0i[i][2] / T + SumHyp1); - a0[2].val += -x[i] * (n0i[i][3] + SumHyp2); + // Private Sub Alpha0GERG(T, D, x, a0) + + // Calculate the ideal gas Helmholtz energy and its derivatives with respect to + // tau and delta. + // This routine is not needed when only P (or Z) is calculated. + + // Inputs: + // T - Temperature (K) + // D - Density (mol/l) + // x() - Composition (mole fraction) + + // Outputs: + // a0(0) - Ideal gas Helmholtz energy (all dimensionless [i.e., divided by RT]) + // a0(1) - tau*partial(a0)/partial(tau) + // a0(2) - tau^2*partial^2(a0)/partial(tau)^2 + + double LogT; + double LogD; + double LogHyp; + double th0T; + double LogxD; + double SumHyp0; + double SumHyp1; + double SumHyp2; + double em; + + double ep; + double hcn; + double hsn; + a0[0].val = 0; + a0[1].val = 0; + a0[2].val = 0; + if (D > epsilon) { + LogD = Math.log(D); + } else { + LogD = Math.log(epsilon); + } + LogT = Math.log(T); + for (int i = 1; i <= NcGERG; ++i) { + if (x[i] > epsilon) { + LogxD = LogD + Math.log(x[i]); + SumHyp0 = 0; + SumHyp1 = 0; + SumHyp2 = 0; + for (int j = 4; j <= 7; ++j) { + if (th0i[i][j] > epsilon) { + th0T = th0i[i][j] / T; + ep = Math.exp(th0T); + em = 1 / ep; + hsn = (ep - em) / 2; + hcn = (ep + em) / 2; + if (j == 4 || j == 6) { + LogHyp = Math.log(Math.abs(hsn)); + SumHyp0 = SumHyp0 + n0i[i][j] * LogHyp; + SumHyp1 = SumHyp1 + n0i[i][j] * th0T * hcn / hsn; + SumHyp2 = SumHyp2 + n0i[i][j] * (th0T / hsn) * (th0T / hsn); + } else { + LogHyp = Math.log(Math.abs(hcn)); + SumHyp0 = SumHyp0 - n0i[i][j] * LogHyp; + SumHyp1 = SumHyp1 - n0i[i][j] * th0T * hsn / hcn; + SumHyp2 = SumHyp2 + n0i[i][j] * (th0T / hcn) * (th0T / hcn); + } } + } + a0[0].val += +x[i] * (LogxD + n0i[i][1] + n0i[i][2] / T - n0i[i][3] * LogT + SumHyp0); + a0[1].val += +x[i] * (n0i[i][3] + n0i[i][2] / T + SumHyp1); + a0[2].val += -x[i] * (n0i[i][3] + SumHyp2); } + } } /** @@ -569,149 +602,159 @@ static void Alpha0GERG(double T, double D, double[] x, doubleW[] a0) { * @param ar ... */ static void AlpharGERG(int itau, int idelta, double T, double D, double[] x, doubleW[][] ar) { - // Private Sub AlpharGERG(itau, idelta, T, D, x, ar) - - // Calculate dimensionless residual Helmholtz energy and its derivatives with - // respect to tau and delta. - - // Inputs: - // itau - Set this to 1 to calculate "ar" derivatives with respect to tau [i.e., - // ar(1,0), ar(1,1), and ar(2,0)], otherwise set it to 0. - // idelta - Currently not used, but kept as an input for future use in specifing - // the highest density derivative needed. - // T - Temperature (K) - // D - Density (mol/l) - // x() - Composition (mole fraction) - - // Outputs: - // ar(0,0) - Residual Helmholtz energy (dimensionless, =a/RT) - // ar(0,1) - delta*partial (ar)/partial(delta) - // ar(0,2) - delta^2*partial^2(ar)/partial(delta)^2 - // ar(0,3) - delta^3*partial^3(ar)/partial(delta)^3 - // ar(1,0) - tau*partial (ar)/partial(tau) - // ar(1,1) - tau*delta*partial^2(ar)/partial(tau)/partial(delta) - // ar(2,0) - tau^2*partial^2(ar)/partial(tau)^2 - - int mn; - doubleW Tr = new doubleW(0.0d), Dr = new doubleW(0.0d); - double del, tau; - double lntau, ex, ex2, ex3, cij0, eij0; - double ndt, ndtd, ndtt, xijf; - double[] delp = new double[7 + 1]; - double[] Expd = new double[7 + 1]; - - for (int i = 0; i <= 3; ++i) { - for (int j = 0; j <= 3; ++j) { - ar[i][j].val = 0; - } + // Private Sub AlpharGERG(itau, idelta, T, D, x, ar) + + // Calculate dimensionless residual Helmholtz energy and its derivatives with + // respect to tau and delta. + + // Inputs: + // itau - Set this to 1 to calculate "ar" derivatives with respect to tau [i.e., + // ar(1,0), ar(1,1), and ar(2,0)], otherwise set it to 0. + // idelta - Currently not used, but kept as an input for future use in specifing + // the highest density derivative needed. + // T - Temperature (K) + // D - Density (mol/l) + // x() - Composition (mole fraction) + + // Outputs: + // ar(0,0) - Residual Helmholtz energy (dimensionless, =a/RT) + // ar(0,1) - delta*partial (ar)/partial(delta) + // ar(0,2) - delta^2*partial^2(ar)/partial(delta)^2 + // ar(0,3) - delta^3*partial^3(ar)/partial(delta)^3 + // ar(1,0) - tau*partial (ar)/partial(tau) + // ar(1,1) - tau*delta*partial^2(ar)/partial(tau)/partial(delta) + // ar(2,0) - tau^2*partial^2(ar)/partial(tau)^2 + + int mn; + doubleW Tr = new doubleW(0.0d); + doubleW Dr = new doubleW(0.0d); + double del; + double tau; + double lntau; + double ex; + double ex2; + double ex3; + double cij0; + double eij0; + double ndt; + double ndtd; + double ndtt; + double xijf; + double[] delp = new double[7 + 1]; + double[] Expd = new double[7 + 1]; + + for (int i = 0; i <= 3; ++i) { + for (int j = 0; j <= 3; ++j) { + ar[i][j].val = 0; } - - // Set up del, tau, log(tau), and the first 7 calculations for del^i - ReducingParametersGERG(x, Tr, Dr); - del = D / Dr.val; - tau = Tr.val / T; - lntau = Math.log(tau); - delp[1] = del; - Expd[1] = Math.exp(-delp[1]); - for (int i = 2; i <= 7; ++i) { - delp[i] = delp[i - 1] * del; - Expd[i] = Math.exp(-delp[i]); - } - - // If temperature has changed, calculate temperature dependent parts - if (Math.abs(T - Told) > 0.0000001 || Math.abs(Tr.val - Trold2) > 0.0000001) { - tTermsGERG(lntau, x); - } - Told = T; - Trold2 = Tr.val; - - // Calculate pure fluid contributions - for (int i = 1; i <= NcGERG; ++i) { - if (x[i] > epsilon) { - for (int k = 1; k <= kpol[i]; ++k) { - ndt = x[i] * delp[doik[i][k]] * taup[i][k]; - ndtd = ndt * doik[i][k]; - ar[0][1].val += ndtd; - ar[0][2].val += ndtd * (doik[i][k] - 1); - if (itau > 0) { - ndtt = ndt * toik[i][k]; - ar[0][0].val += ndt; - ar[1][0].val += ndtt; - ar[2][0].val += ndtt * (toik[i][k] - 1); - ar[1][1].val += ndtt * doik[i][k]; - ar[1][2].val += ndtt * doik[i][k] * (doik[i][k] - 1); - ar[0][3].val += ndtd * (doik[i][k] - 1) * (doik[i][k] - 2); - } - } - for (int k = 1 + kpol[i]; k <= kpol[i] + kexp[i]; ++k) { - ndt = x[i] * delp[doik[i][k]] * taup[i][k] * Expd[coik[i][k]]; - ex = coik[i][k] * delp[coik[i][k]]; - ex2 = doik[i][k] - ex; - ex3 = ex2 * (ex2 - 1); - ar[0][1].val += ndt * ex2; - ar[0][2].val += ndt * (ex3 - coik[i][k] * ex); - if (itau > 0) { - ndtt = ndt * toik[i][k]; - ar[0][0].val += ndt; - ar[1][0].val += ndtt; - ar[2][0].val += ndtt * (toik[i][k] - 1); - ar[1][1].val += ndtt * ex2; - ar[1][2].val += ndtt * (ex3 - coik[i][k] * ex); - ar[0][3].val += ndt - * (ex3 * (ex2 - 2) - ex * (3 * ex2 - 3 + coik[i][k]) * coik[i][k]); - } - } + } + + // Set up del, tau, log(tau), and the first 7 calculations for del^i + ReducingParametersGERG(x, Tr, Dr); + del = D / Dr.val; + tau = Tr.val / T; + lntau = Math.log(tau); + delp[1] = del; + Expd[1] = Math.exp(-delp[1]); + for (int i = 2; i <= 7; ++i) { + delp[i] = delp[i - 1] * del; + Expd[i] = Math.exp(-delp[i]); + } + + // If temperature has changed, calculate temperature dependent parts + if (Math.abs(T - Told) > 0.0000001 || Math.abs(Tr.val - Trold2) > 0.0000001) { + tTermsGERG(lntau, x); + } + Told = T; + Trold2 = Tr.val; + + // Calculate pure fluid contributions + for (int i = 1; i <= NcGERG; ++i) { + if (x[i] > epsilon) { + for (int k = 1; k <= kpol[i]; ++k) { + ndt = x[i] * delp[doik[i][k]] * taup[i][k]; + ndtd = ndt * doik[i][k]; + ar[0][1].val += ndtd; + ar[0][2].val += ndtd * (doik[i][k] - 1); + if (itau > 0) { + ndtt = ndt * toik[i][k]; + ar[0][0].val += ndt; + ar[1][0].val += ndtt; + ar[2][0].val += ndtt * (toik[i][k] - 1); + ar[1][1].val += ndtt * doik[i][k]; + ar[1][2].val += ndtt * doik[i][k] * (doik[i][k] - 1); + ar[0][3].val += ndtd * (doik[i][k] - 1) * (doik[i][k] - 2); } + } + for (int k = 1 + kpol[i]; k <= kpol[i] + kexp[i]; ++k) { + ndt = x[i] * delp[doik[i][k]] * taup[i][k] * Expd[coik[i][k]]; + ex = coik[i][k] * delp[coik[i][k]]; + ex2 = doik[i][k] - ex; + ex3 = ex2 * (ex2 - 1); + ar[0][1].val += ndt * ex2; + ar[0][2].val += ndt * (ex3 - coik[i][k] * ex); + if (itau > 0) { + ndtt = ndt * toik[i][k]; + ar[0][0].val += ndt; + ar[1][0].val += ndtt; + ar[2][0].val += ndtt * (toik[i][k] - 1); + ar[1][1].val += ndtt * ex2; + ar[1][2].val += ndtt * (ex3 - coik[i][k] * ex); + ar[0][3].val += + ndt * (ex3 * (ex2 - 2) - ex * (3 * ex2 - 3 + coik[i][k]) * coik[i][k]); + } + } } - - // Calculate mixture contributions - for (int i = 1; i <= NcGERG - 1; ++i) { - if (x[i] > epsilon) { - for (int j = i + 1; j <= NcGERG; ++j) { - if (x[j] > epsilon) { - mn = mNumb[i][j]; - if (mn >= 0) { - xijf = x[i] * x[j] * fij[i][j]; - for (int k = 1; k <= kpolij[mn]; ++k) { - ndt = xijf * delp[dijk[mn][k]] * taupijk[mn][k]; - ndtd = ndt * dijk[mn][k]; - ar[0][1].val += ndtd; - ar[0][2].val += ndtd * (dijk[mn][k] - 1); - if (itau > 0) { - ndtt = ndt * tijk[mn][k]; - ar[0][0].val += ndt; - ar[1][0].val += ndtt; - ar[2][0].val += ndtt * (tijk[mn][k] - 1); - ar[1][1].val += ndtt * dijk[mn][k]; - ar[1][2].val += ndtt * dijk[mn][k] * (dijk[mn][k] - 1); - ar[0][3].val += ndtd * (dijk[mn][k] - 1) * (dijk[mn][k] - 2); - } - } - for (int k = 1 + kpolij[mn]; k <= kpolij[mn] + kexpij[mn]; ++k) { - cij0 = cijk[mn][k] * delp[2]; - eij0 = eijk[mn][k] * del; - ndt = xijf * nijk[mn][k] * delp[dijk[mn][k]] - * Math.exp(cij0 + eij0 + gijk[mn][k] + tijk[mn][k] * lntau); - ex = dijk[mn][k] + 2 * cij0 + eij0; - ex2 = (ex * ex - dijk[mn][k] + 2 * cij0); - ar[0][1].val += ndt * ex; - ar[0][2].val += ndt * ex2; - if (itau > 0) { - ndtt = ndt * tijk[mn][k]; - ar[0][0].val += ndt; - ar[1][0].val += ndtt; - ar[2][0].val += ndtt * (tijk[mn][k] - 1); - ar[1][1].val += ndtt * ex; - ar[1][2].val += ndtt * ex2; - ar[0][3].val += ndt * (ex * (ex2 - 2 * (dijk[mn][k] - 2 * cij0)) - + 2 * dijk[mn][k]); - } - } - } - } + } + + // Calculate mixture contributions + for (int i = 1; i <= NcGERG - 1; ++i) { + if (x[i] > epsilon) { + for (int j = i + 1; j <= NcGERG; ++j) { + if (x[j] > epsilon) { + mn = mNumb[i][j]; + if (mn >= 0) { + xijf = x[i] * x[j] * fij[i][j]; + for (int k = 1; k <= kpolij[mn]; ++k) { + ndt = xijf * delp[dijk[mn][k]] * taupijk[mn][k]; + ndtd = ndt * dijk[mn][k]; + ar[0][1].val += ndtd; + ar[0][2].val += ndtd * (dijk[mn][k] - 1); + if (itau > 0) { + ndtt = ndt * tijk[mn][k]; + ar[0][0].val += ndt; + ar[1][0].val += ndtt; + ar[2][0].val += ndtt * (tijk[mn][k] - 1); + ar[1][1].val += ndtt * dijk[mn][k]; + ar[1][2].val += ndtt * dijk[mn][k] * (dijk[mn][k] - 1); + ar[0][3].val += ndtd * (dijk[mn][k] - 1) * (dijk[mn][k] - 2); + } } + for (int k = 1 + kpolij[mn]; k <= kpolij[mn] + kexpij[mn]; ++k) { + cij0 = cijk[mn][k] * delp[2]; + eij0 = eijk[mn][k] * del; + ndt = xijf * nijk[mn][k] * delp[dijk[mn][k]] + * Math.exp(cij0 + eij0 + gijk[mn][k] + tijk[mn][k] * lntau); + ex = dijk[mn][k] + 2 * cij0 + eij0; + ex2 = (ex * ex - dijk[mn][k] + 2 * cij0); + ar[0][1].val += ndt * ex; + ar[0][2].val += ndt * ex2; + if (itau > 0) { + ndtt = ndt * tijk[mn][k]; + ar[0][0].val += ndt; + ar[1][0].val += ndtt; + ar[2][0].val += ndtt * (tijk[mn][k] - 1); + ar[1][1].val += ndtt * ex; + ar[1][2].val += ndtt * ex2; + ar[0][3].val += + ndt * (ex * (ex2 - 2 * (dijk[mn][k] - 2 * cij0)) + 2 * dijk[mn][k]); + } + } + } } + } } + } } /** @@ -719,45 +762,46 @@ static void AlpharGERG(int itau, int idelta, double T, double D, double[] x, dou * @param x .... */ static void tTermsGERG(double lntau, double[] x) { - // Private Sub tTermsGERG(lntau, x) - - // Calculate temperature dependent parts of the GERG-2008 equation of state - - int i, mn; - double[] taup0 = new double[12 + 1]; - - i = 5; // Use propane to get exponents for short form of EOS - for (int k = 1; k <= kpol[i] + kexp[i]; ++k) { - taup0[k] = Math.exp(toik[i][k] * lntau); - } - for (i = 1; i <= NcGERG; ++i) { - if (x[i] > epsilon) { - if (i > 4 && i != 15 && i != 18 && i != 20) { - for (int k = 1; k <= kpol[i] + kexp[i]; ++k) { - taup[i][k] = noik[i][k] * taup0[k]; - } - } else { - for (int k = 1; k <= kpol[i] + kexp[i]; ++k) { - taup[i][k] = noik[i][k] * Math.exp(toik[i][k] * lntau); - } - } + // Private Sub tTermsGERG(lntau, x) + + // Calculate temperature dependent parts of the GERG-2008 equation of state + + int i; + int mn; + double[] taup0 = new double[12 + 1]; + + i = 5; // Use propane to get exponents for short form of EOS + for (int k = 1; k <= kpol[i] + kexp[i]; ++k) { + taup0[k] = Math.exp(toik[i][k] * lntau); + } + for (i = 1; i <= NcGERG; ++i) { + if (x[i] > epsilon) { + if (i > 4 && i != 15 && i != 18 && i != 20) { + for (int k = 1; k <= kpol[i] + kexp[i]; ++k) { + taup[i][k] = noik[i][k] * taup0[k]; + } + } else { + for (int k = 1; k <= kpol[i] + kexp[i]; ++k) { + taup[i][k] = noik[i][k] * Math.exp(toik[i][k] * lntau); } + } } - - for (i = 1; i <= NcGERG - 1; ++i) { - if (x[i] > epsilon) { - for (int j = i + 1; j <= NcGERG; ++j) { - if (x[j] > epsilon) { - mn = mNumb[i][j]; - if (mn >= 0) { - for (int k = 1; k <= kpolij[mn]; ++k) { - taupijk[mn][k] = nijk[mn][k] * Math.exp(tijk[mn][k] * lntau); - } - } - } + } + + for (i = 1; i <= NcGERG - 1; ++i) { + if (x[i] > epsilon) { + for (int j = i + 1; j <= NcGERG; ++j) { + if (x[j] > epsilon) { + mn = mNumb[i][j]; + if (mn >= 0) { + for (int k = 1; k <= kpolij[mn]; ++k) { + taupijk[mn][k] = nijk[mn][k] * Math.exp(tijk[mn][k] * lntau); } + } } + } } + } } /** @@ -766,22 +810,22 @@ static void tTermsGERG(double lntau, double[] x) { * @param Dcx density */ static void PseudoCriticalPointGERG(double[] x, doubleW Tcx, doubleW Dcx) { - // PseudoCriticalPointGERG(x, Tcx, Dcx) - - // Calculate a pseudo critical point as the mole fraction average of the - // critical temperatures and critical volumes - - double Vcx; - Tcx.val = 0; - Vcx = 0; - Dcx.val = 0; - for (int i = 1; i <= NcGERG; ++i) { - Tcx.val = Tcx.val + x[i] * Tc[i]; - Vcx = Vcx + x[i] / Dc[i]; - } - if (Vcx > epsilon) { - Dcx.val = 1 / Vcx; - } + // PseudoCriticalPointGERG(x, Tcx, Dcx) + + // Calculate a pseudo critical point as the mole fraction average of the + // critical temperatures and critical volumes + + double Vcx; + Tcx.val = 0; + Vcx = 0; + Dcx.val = 0; + for (int i = 1; i <= NcGERG; ++i) { + Tcx.val = Tcx.val + x[i] * Tc[i]; + Vcx = Vcx + x[i] / Dc[i]; + } + if (Vcx > epsilon) { + Dcx.val = 1 / Vcx; + } } // The following routine must be called once before any other routine. @@ -791,2390 +835,2393 @@ static void PseudoCriticalPointGERG(double[] x, doubleW Tcx, doubleW Dcx) { *

*/ public static void SetupGERG() { - // Initialize all the constants and parameters in the GERG-2008 model. - // Some values are modified for calculations that do not depend on T, D, and x in order to - // speed up the program. - - double o13, Rs, Rsr; - double[][] bijk = new double[MaxMdl + 1][MaxTrmM + 1]; - double T0, d0; - - RGERG = 8.314472; - Rs = 8.31451; - Rsr = Rs / RGERG; - o13 = 1.0 / 3.0; - - for (int i = 1; i <= MaxFlds; ++i) { - xold[i] = 0; + // Initialize all the constants and parameters in the GERG-2008 model. + // Some values are modified for calculations that do not depend on T, D, and x in order to + // speed up the program. + + double o13; + double Rs; + double Rsr; + double[][] bijk = new double[MaxMdl + 1][MaxTrmM + 1]; + double T0; + + double d0; + RGERG = 8.314472; + Rs = 8.31451; + Rsr = Rs / RGERG; + o13 = 1.0 / 3.0; + + for (int i = 1; i <= MaxFlds; ++i) { + xold[i] = 0; + } + Told = 0; + + // Molar masses [g/mol] + MMiGERG[1] = 16.04246; // Methane + MMiGERG[2] = 28.0134; // Nitrogen + MMiGERG[3] = 44.0095; // Carbon dioxide + MMiGERG[4] = 30.06904; // Ethane + MMiGERG[5] = 44.09562; // Propane + MMiGERG[6] = 58.1222; // Isobutane + MMiGERG[7] = 58.1222; // n-Butane + MMiGERG[8] = 72.14878; // Isopentane + MMiGERG[9] = 72.14878; // n-Pentane + MMiGERG[10] = 86.17536; // Hexane + MMiGERG[11] = 100.20194; // Heptane + MMiGERG[12] = 114.22852; // Octane + MMiGERG[13] = 128.2551; // Nonane + MMiGERG[14] = 142.28168; // Decane + MMiGERG[15] = 2.01588; // Hydrogen + MMiGERG[16] = 31.9988; // Oxygen + MMiGERG[17] = 28.0101; // Carbon monoxide + MMiGERG[18] = 18.01528; // Water + MMiGERG[19] = 34.08088; // Hydrogen sulfide + MMiGERG[20] = 4.002602; // Helium + MMiGERG[21] = 39.948; // Argon + + // Number of polynomial and exponential terms + for (int i = 1; i <= MaxFlds; ++i) { + kpol[i] = 6; + kexp[i] = 6; + } + kexp[1] = 18; + kexp[2] = 18; + kexp[4] = 18; + kpol[3] = 4; + kexp[3] = 18; + kpol[15] = 5; + kexp[15] = 9; + kpol[18] = 7; + kexp[18] = 9; + kpol[20] = 4; + kexp[20] = 8; + kpolij[1] = 2; + kexpij[1] = 10; + kpolij[2] = 5; + kexpij[2] = 4; + kpolij[3] = 2; + kexpij[3] = 7; + kpolij[4] = 3; + kexpij[4] = 3; + kpolij[5] = 2; + kexpij[5] = 4; + kpolij[6] = 3; + kexpij[6] = 3; + kpolij[7] = 4; + kexpij[7] = 0; + kpolij[10] = 10; + kexpij[10] = 0; + + // Critical densities [mol/l] + Dc[1] = 10.139342719; + Dc[2] = 11.1839; + Dc[3] = 10.624978698; + Dc[4] = 6.87085454; + Dc[5] = 5.000043088; + Dc[6] = 3.86014294; + Dc[7] = 3.920016792; + Dc[8] = 3.271; + Dc[9] = 3.215577588; + Dc[10] = 2.705877875; + Dc[11] = 2.315324434; + Dc[12] = 2.056404127; + Dc[13] = 1.81; + Dc[14] = 1.64; + Dc[15] = 14.94; + Dc[16] = 13.63; + Dc[17] = 10.85; + Dc[18] = 17.87371609; + Dc[19] = 10.19; + Dc[20] = 17.399; + Dc[21] = 13.407429659; + + // Critical temperatures [K] + Tc[1] = 190.564; + Tc[2] = 126.192; + Tc[3] = 304.1282; + Tc[4] = 305.322; + Tc[5] = 369.825; + Tc[6] = 407.817; + Tc[7] = 425.125; + Tc[8] = 460.35; + Tc[9] = 469.7; + Tc[10] = 507.82; + Tc[11] = 540.13; + Tc[12] = 569.32; + Tc[13] = 594.55; + Tc[14] = 617.7; + Tc[15] = 33.19; + Tc[16] = 154.595; + Tc[17] = 132.86; + Tc[18] = 647.096; + Tc[19] = 373.1; + Tc[20] = 5.1953; + Tc[21] = 150.687; + + // Exponents in pure fluid equations + for (int i = 1; i <= MaxFlds; ++i) { + Vc3[i] = 1 / Math.pow(Dc[i], o13) / 2; + Tc2[i] = Math.sqrt(Tc[i]); + coik[i][1] = 0; + doik[i][1] = 1; + toik[i][1] = 0.25; + coik[i][2] = 0; + doik[i][2] = 1; + toik[i][2] = 1.125; + coik[i][3] = 0; + doik[i][3] = 1; + toik[i][3] = 1.5; + coik[i][4] = 0; + doik[i][4] = 2; + toik[i][4] = 1.375; + coik[i][5] = 0; + doik[i][5] = 3; + toik[i][5] = 0.25; + coik[i][6] = 0; + doik[i][6] = 7; + toik[i][6] = 0.875; + coik[i][7] = 1; + doik[i][7] = 2; + toik[i][7] = 0.625; + coik[i][8] = 1; + doik[i][8] = 5; + toik[i][8] = 1.75; + coik[i][9] = 2; + doik[i][9] = 1; + toik[i][9] = 3.625; + coik[i][10] = 2; + doik[i][10] = 4; + toik[i][10] = 3.625; + coik[i][11] = 3; + doik[i][11] = 3; + toik[i][11] = 14.5; + coik[i][12] = 3; + doik[i][12] = 4; + toik[i][12] = 12; + } + for (int i = 1; i <= 4; ++i) { + if (i != 3) { + coik[i][1] = 0; + doik[i][1] = 1; + toik[i][1] = 0.125; + coik[i][2] = 0; + doik[i][2] = 1; + toik[i][2] = 1.125; + coik[i][3] = 0; + doik[i][3] = 2; + toik[i][3] = 0.375; + coik[i][4] = 0; + doik[i][4] = 2; + toik[i][4] = 1.125; + coik[i][5] = 0; + doik[i][5] = 4; + toik[i][5] = 0.625; + coik[i][6] = 0; + doik[i][6] = 4; + toik[i][6] = 1.5; + coik[i][7] = 1; + doik[i][7] = 1; + toik[i][7] = 0.625; + coik[i][8] = 1; + doik[i][8] = 1; + toik[i][8] = 2.625; + coik[i][9] = 1; + doik[i][9] = 1; + toik[i][9] = 2.75; + coik[i][10] = 1; + doik[i][10] = 2; + toik[i][10] = 2.125; + coik[i][11] = 1; + doik[i][11] = 3; + toik[i][11] = 2; + coik[i][12] = 1; + doik[i][12] = 6; + toik[i][12] = 1.75; + coik[i][13] = 2; + doik[i][13] = 2; + toik[i][13] = 4.5; + coik[i][14] = 2; + doik[i][14] = 3; + toik[i][14] = 4.75; + coik[i][15] = 2; + doik[i][15] = 3; + toik[i][15] = 5; + coik[i][16] = 2; + doik[i][16] = 4; + toik[i][16] = 4; + coik[i][17] = 2; + doik[i][17] = 4; + toik[i][17] = 4.5; + coik[i][18] = 3; + doik[i][18] = 2; + toik[i][18] = 7.5; + coik[i][19] = 3; + doik[i][19] = 3; + toik[i][19] = 14; + coik[i][20] = 3; + doik[i][20] = 4; + toik[i][20] = 11.5; + coik[i][21] = 6; + doik[i][21] = 5; + toik[i][21] = 26; + coik[i][22] = 6; + doik[i][22] = 6; + toik[i][22] = 28; + coik[i][23] = 6; + doik[i][23] = 6; + toik[i][23] = 30; + coik[i][24] = 6; + doik[i][24] = 7; + toik[i][24] = 16; } - Told = 0; - - // Molar masses [g/mol] - MMiGERG[1] = 16.04246; // Methane - MMiGERG[2] = 28.0134; // Nitrogen - MMiGERG[3] = 44.0095; // Carbon dioxide - MMiGERG[4] = 30.06904; // Ethane - MMiGERG[5] = 44.09562; // Propane - MMiGERG[6] = 58.1222; // Isobutane - MMiGERG[7] = 58.1222; // n-Butane - MMiGERG[8] = 72.14878; // Isopentane - MMiGERG[9] = 72.14878; // n-Pentane - MMiGERG[10] = 86.17536; // Hexane - MMiGERG[11] = 100.20194; // Heptane - MMiGERG[12] = 114.22852; // Octane - MMiGERG[13] = 128.2551; // Nonane - MMiGERG[14] = 142.28168; // Decane - MMiGERG[15] = 2.01588; // Hydrogen - MMiGERG[16] = 31.9988; // Oxygen - MMiGERG[17] = 28.0101; // Carbon monoxide - MMiGERG[18] = 18.01528; // Water - MMiGERG[19] = 34.08088; // Hydrogen sulfide - MMiGERG[20] = 4.002602; // Helium - MMiGERG[21] = 39.948; // Argon - - // Number of polynomial and exponential terms - for (int i = 1; i <= MaxFlds; ++i) { - kpol[i] = 6; - kexp[i] = 6; + } + + // Coefficients of pure fluid equations + // Methane + noik[1][1] = 0.57335704239162; + noik[1][2] = -1.676068752373; + noik[1][3] = 0.23405291834916; + noik[1][4] = -0.21947376343441; + noik[1][5] = 0.016369201404128; + noik[1][6] = 0.01500440638928; + noik[1][7] = 0.098990489492918; + noik[1][8] = 0.58382770929055; + noik[1][9] = -0.7478686756039; + noik[1][10] = 0.30033302857974; + noik[1][11] = 0.20985543806568; + noik[1][12] = -0.018590151133061; + noik[1][13] = -0.15782558339049; + noik[1][14] = 0.12716735220791; + noik[1][15] = -0.032019743894346; + noik[1][16] = -0.068049729364536; + noik[1][17] = 0.024291412853736; + noik[1][18] = 5.1440451639444E-03; + noik[1][19] = -0.019084949733532; + noik[1][20] = 5.5229677241291E-03; + noik[1][21] = -4.4197392976085E-03; + noik[1][22] = 0.040061416708429; + noik[1][23] = -0.033752085907575; + noik[1][24] = -2.5127658213357E-03; + // Nitrogen + noik[2][1] = 0.59889711801201; + noik[2][2] = -1.6941557480731; + noik[2][3] = 0.24579736191718; + noik[2][4] = -0.23722456755175; + noik[2][5] = 0.017954918715141; + noik[2][6] = 0.014592875720215; + noik[2][7] = 0.10008065936206; + noik[2][8] = 0.73157115385532; + noik[2][9] = -0.88372272336366; + noik[2][10] = 0.31887660246708; + noik[2][11] = 0.20766491728799; + noik[2][12] = -0.019379315454158; + noik[2][13] = -0.16936641554983; + noik[2][14] = 0.13546846041701; + noik[2][15] = -0.033066712095307; + noik[2][16] = -0.060690817018557; + noik[2][17] = 0.012797548292871; + noik[2][18] = 5.8743664107299E-03; + noik[2][19] = -0.018451951971969; + noik[2][20] = 4.7226622042472E-03; + noik[2][21] = -5.2024079680599E-03; + noik[2][22] = 0.043563505956635; + noik[2][23] = -0.036251690750939; + noik[2][24] = -2.8974026866543E-03; + // Ethane + noik[4][1] = 0.63596780450714; + noik[4][2] = -1.7377981785459; + noik[4][3] = 0.28914060926272; + noik[4][4] = -0.33714276845694; + noik[4][5] = 0.022405964699561; + noik[4][6] = 0.015715424886913; + noik[4][7] = 0.11450634253745; + noik[4][8] = 1.0612049379745; + noik[4][9] = -1.2855224439423; + noik[4][10] = 0.39414630777652; + noik[4][11] = 0.31390924682041; + noik[4][12] = -0.021592277117247; + noik[4][13] = -0.21723666564905; + noik[4][14] = -0.28999574439489; + noik[4][15] = 0.42321173025732; + noik[4][16] = 0.04643410025926; + noik[4][17] = -0.13138398329741; + noik[4][18] = 0.011492850364368; + noik[4][19] = -0.033387688429909; + noik[4][20] = 0.015183171583644; + noik[4][21] = -4.7610805647657E-03; + noik[4][22] = 0.046917166277885; + noik[4][23] = -0.039401755804649; + noik[4][24] = -3.2569956247611E-03; + // Propane + noik[5][1] = 1.0403973107358; + noik[5][2] = -2.8318404081403; + noik[5][3] = 0.84393809606294; + noik[5][4] = -0.076559591850023; + noik[5][5] = 0.09469737305728; + noik[5][6] = 2.4796475497006E-04; + noik[5][7] = 0.2774376042287; + noik[5][8] = -0.043846000648377; + noik[5][9] = -0.2699106478435; + noik[5][10] = -0.06931341308986; + noik[5][11] = -0.029632145981653; + noik[5][12] = 0.01404012675138; + // Isobutane + noik[6][1] = 1.04293315891; + noik[6][2] = -2.8184272548892; + noik[6][3] = 0.8617623239785; + noik[6][4] = -0.10613619452487; + noik[6][5] = 0.098615749302134; + noik[6][6] = 2.3948208682322E-04; + noik[6][7] = 0.3033000485695; + noik[6][8] = -0.041598156135099; + noik[6][9] = -0.29991937470058; + noik[6][10] = -0.080369342764109; + noik[6][11] = -0.029761373251151; + noik[6][12] = 0.01305963030314; + // n-Butane + noik[7][1] = 1.0626277411455; + noik[7][2] = -2.862095182835; + noik[7][3] = 0.88738233403777; + noik[7][4] = -0.12570581155345; + noik[7][5] = 0.10286308708106; + noik[7][6] = 2.5358040602654E-04; + noik[7][7] = 0.32325200233982; + noik[7][8] = -0.037950761057432; + noik[7][9] = -0.32534802014452; + noik[7][10] = -0.079050969051011; + noik[7][11] = -0.020636720547775; + noik[7][12] = 0.005705380933475; + // Isopentane + noik[8][1] = 1.0963; + noik[8][2] = -3.0402; + noik[8][3] = 1.0317; + noik[8][4] = -0.1541; + noik[8][5] = 0.11535; + noik[8][6] = 0.00029809; + noik[8][7] = 0.39571; + noik[8][8] = -0.045881; + noik[8][9] = -0.35804; + noik[8][10] = -0.10107; + noik[8][11] = -0.035484; + noik[8][12] = 0.018156; + // n-Pentane + noik[9][1] = 1.0968643098001; + noik[9][2] = -2.9988888298061; + noik[9][3] = 0.99516886799212; + noik[9][4] = -0.16170708558539; + noik[9][5] = 0.11334460072775; + noik[9][6] = 2.6760595150748E-04; + noik[9][7] = 0.40979881986931; + noik[9][8] = -0.040876423083075; + noik[9][9] = -0.38169482469447; + noik[9][10] = -0.10931956843993; + noik[9][11] = -0.03207322332799; + noik[9][12] = 0.016877016216975; + // Hexane + noik[10][1] = 1.0553238013661; + noik[10][2] = -2.6120615890629; + noik[10][3] = 0.7661388296726; + noik[10][4] = -0.29770320622459; + noik[10][5] = 0.11879907733358; + noik[10][6] = 2.7922861062617E-04; + noik[10][7] = 0.46347589844105; + noik[10][8] = 0.011433196980297; + noik[10][9] = -0.48256968738131; + noik[10][10] = -0.093750558924659; + noik[10][11] = -6.7273247155994E-03; + noik[10][12] = -5.1141583585428E-03; + // Heptane + noik[11][1] = 1.0543747645262; + noik[11][2] = -2.6500681506144; + noik[11][3] = 0.81730047827543; + noik[11][4] = -0.30451391253428; + noik[11][5] = 0.122538687108; + noik[11][6] = 2.7266472743928E-04; + noik[11][7] = 0.4986582568167; + noik[11][8] = -7.1432815084176E-04; + noik[11][9] = -0.5423689552545; + noik[11][10] = -0.13801821610756; + noik[11][11] = -6.1595287380011E-03; + noik[11][12] = 4.8602510393022E-04; + // Octane + noik[12][1] = 1.0722544875633; + noik[12][2] = -2.4632951172003; + noik[12][3] = 0.65386674054928; + noik[12][4] = -0.36324974085628; + noik[12][5] = 0.12713269626764; + noik[12][6] = 3.071357277793E-04; + noik[12][7] = 0.5265685698754; + noik[12][8] = 0.019362862857653; + noik[12][9] = -0.58939426849155; + noik[12][10] = -0.14069963991934; + noik[12][11] = -7.8966330500036E-03; + noik[12][12] = 3.3036597968109E-03; + // Nonane + noik[13][1] = 1.1151; + noik[13][2] = -2.702; + noik[13][3] = 0.83416; + noik[13][4] = -0.38828; + noik[13][5] = 0.1376; + noik[13][6] = 0.00028185; + noik[13][7] = 0.62037; + noik[13][8] = 0.015847; + noik[13][9] = -0.61726; + noik[13][10] = -0.15043; + noik[13][11] = -0.012982; + noik[13][12] = 0.0044325; + // Decane + noik[14][1] = 1.0461; + noik[14][2] = -2.4807; + noik[14][3] = 0.74372; + noik[14][4] = -0.52579; + noik[14][5] = 0.15315; + noik[14][6] = 0.00032865; + noik[14][7] = 0.84178; + noik[14][8] = 0.055424; + noik[14][9] = -0.73555; + noik[14][10] = -0.18507; + noik[14][11] = -0.020775; + noik[14][12] = 0.012335; + // Oxygen + noik[16][1] = 0.88878286369701; + noik[16][2] = -2.4879433312148; + noik[16][3] = 0.59750190775886; + noik[16][4] = 9.6501817061881E-03; + noik[16][5] = 0.07197042871277; + noik[16][6] = 2.2337443000195E-04; + noik[16][7] = 0.18558686391474; + noik[16][8] = -0.03812936803576; + noik[16][9] = -0.15352245383006; + noik[16][10] = -0.026726814910919; + noik[16][11] = -0.025675298677127; + noik[16][12] = 9.5714302123668E-03; + // Carbon monoxide + noik[17][1] = 0.90554; + noik[17][2] = -2.4515; + noik[17][3] = 0.53149; + noik[17][4] = 0.024173; + noik[17][5] = 0.072156; + noik[17][6] = 0.00018818; + noik[17][7] = 0.19405; + noik[17][8] = -0.043268; + noik[17][9] = -0.12778; + noik[17][10] = -0.027896; + noik[17][11] = -0.034154; + noik[17][12] = 0.016329; + // Hydrogen sulfide + noik[19][1] = 0.87641; + noik[19][2] = -2.0367; + noik[19][3] = 0.21634; + noik[19][4] = -0.050199; + noik[19][5] = 0.066994; + noik[19][6] = 0.00019076; + noik[19][7] = 0.20227; + noik[19][8] = -0.0045348; + noik[19][9] = -0.2223; + noik[19][10] = -0.034714; + noik[19][11] = -0.014885; + noik[19][12] = 0.0074154; + // Argon + noik[21][1] = 0.85095714803969; + noik[21][2] = -2.400322294348; + noik[21][3] = 0.54127841476466; + noik[21][4] = 0.016919770692538; + noik[21][5] = 0.068825965019035; + noik[21][6] = 2.1428032815338E-04; + noik[21][7] = 0.17429895321992; + noik[21][8] = -0.033654495604194; + noik[21][9] = -0.13526799857691; + noik[21][10] = -0.016387350791552; + noik[21][11] = -0.024987666851475; + noik[21][12] = 8.8769204815709E-03; + // Carbon dioxide + coik[3][1] = 0; + doik[3][1] = 1; + toik[3][1] = 0; + noik[3][1] = 0.52646564804653; + coik[3][2] = 0; + doik[3][2] = 1; + toik[3][2] = 1.25; + noik[3][2] = -1.4995725042592; + coik[3][3] = 0; + doik[3][3] = 2; + toik[3][3] = 1.625; + noik[3][3] = 0.27329786733782; + coik[3][4] = 0; + doik[3][4] = 3; + toik[3][4] = 0.375; + noik[3][4] = 0.12949500022786; + coik[3][5] = 1; + doik[3][5] = 3; + toik[3][5] = 0.375; + noik[3][5] = 0.15404088341841; + coik[3][6] = 1; + doik[3][6] = 3; + toik[3][6] = 1.375; + noik[3][6] = -0.58186950946814; + coik[3][7] = 1; + doik[3][7] = 4; + toik[3][7] = 1.125; + noik[3][7] = -0.18022494838296; + coik[3][8] = 1; + doik[3][8] = 5; + toik[3][8] = 1.375; + noik[3][8] = -0.095389904072812; + coik[3][9] = 1; + doik[3][9] = 6; + toik[3][9] = 0.125; + noik[3][9] = -8.0486819317679E-03; + coik[3][10] = 1; + doik[3][10] = 6; + toik[3][10] = 1.625; + noik[3][10] = -0.03554775127309; + coik[3][11] = 2; + doik[3][11] = 1; + toik[3][11] = 3.75; + noik[3][11] = -0.28079014882405; + coik[3][12] = 2; + doik[3][12] = 4; + toik[3][12] = 3.5; + noik[3][12] = -0.082435890081677; + coik[3][13] = 3; + doik[3][13] = 1; + toik[3][13] = 7.5; + noik[3][13] = 0.010832427979006; + coik[3][14] = 3; + doik[3][14] = 1; + toik[3][14] = 8; + noik[3][14] = -6.7073993161097E-03; + coik[3][15] = 3; + doik[3][15] = 3; + toik[3][15] = 6; + noik[3][15] = -4.6827907600524E-03; + coik[3][16] = 3; + doik[3][16] = 3; + toik[3][16] = 16; + noik[3][16] = -0.028359911832177; + coik[3][17] = 3; + doik[3][17] = 4; + toik[3][17] = 11; + noik[3][17] = 0.019500174744098; + coik[3][18] = 5; + doik[3][18] = 5; + toik[3][18] = 24; + noik[3][18] = -0.21609137507166; + coik[3][19] = 5; + doik[3][19] = 5; + toik[3][19] = 26; + noik[3][19] = 0.43772794926972; + coik[3][20] = 5; + doik[3][20] = 5; + toik[3][20] = 28; + noik[3][20] = -0.22130790113593; + coik[3][21] = 6; + doik[3][21] = 5; + toik[3][21] = 24; + noik[3][21] = 0.015190189957331; + coik[3][22] = 6; + doik[3][22] = 5; + toik[3][22] = 26; + noik[3][22] = -0.0153809489533; + // Hydrogen + coik[15][1] = 0; + doik[15][1] = 1; + toik[15][1] = 0.5; + noik[15][1] = 5.3579928451252; + coik[15][2] = 0; + doik[15][2] = 1; + toik[15][2] = 0.625; + noik[15][2] = -6.2050252530595; + coik[15][3] = 0; + doik[15][3] = 2; + toik[15][3] = 0.375; + noik[15][3] = 0.13830241327086; + coik[15][4] = 0; + doik[15][4] = 2; + toik[15][4] = 0.625; + noik[15][4] = -0.071397954896129; + coik[15][5] = 0; + doik[15][5] = 4; + toik[15][5] = 1.125; + noik[15][5] = 0.015474053959733; + coik[15][6] = 1; + doik[15][6] = 1; + toik[15][6] = 2.625; + noik[15][6] = -0.14976806405771; + coik[15][7] = 1; + doik[15][7] = 5; + toik[15][7] = 0; + noik[15][7] = -0.026368723988451; + coik[15][8] = 1; + doik[15][8] = 5; + toik[15][8] = 0.25; + noik[15][8] = 0.056681303156066; + coik[15][9] = 1; + doik[15][9] = 5; + toik[15][9] = 1.375; + noik[15][9] = -0.060063958030436; + coik[15][10] = 2; + doik[15][10] = 1; + toik[15][10] = 4; + noik[15][10] = -0.45043942027132; + coik[15][11] = 2; + doik[15][11] = 1; + toik[15][11] = 4.25; + noik[15][11] = 0.424788402445; + coik[15][12] = 3; + doik[15][12] = 2; + toik[15][12] = 5; + noik[15][12] = -0.021997640827139; + coik[15][13] = 3; + doik[15][13] = 5; + toik[15][13] = 8; + noik[15][13] = -0.01049952137453; + coik[15][14] = 5; + doik[15][14] = 1; + toik[15][14] = 8; + noik[15][14] = -2.8955902866816E-03; + // Water + coik[18][1] = 0; + doik[18][1] = 1; + toik[18][1] = 0.5; + noik[18][1] = 0.82728408749586; + coik[18][2] = 0; + doik[18][2] = 1; + toik[18][2] = 1.25; + noik[18][2] = -1.8602220416584; + coik[18][3] = 0; + doik[18][3] = 1; + toik[18][3] = 1.875; + noik[18][3] = -1.1199009613744; + coik[18][4] = 0; + doik[18][4] = 2; + toik[18][4] = 0.125; + noik[18][4] = 0.15635753976056; + coik[18][5] = 0; + doik[18][5] = 2; + toik[18][5] = 1.5; + noik[18][5] = 0.87375844859025; + coik[18][6] = 0; + doik[18][6] = 3; + toik[18][6] = 1; + noik[18][6] = -0.36674403715731; + coik[18][7] = 0; + doik[18][7] = 4; + toik[18][7] = 0.75; + noik[18][7] = 0.053987893432436; + coik[18][8] = 1; + doik[18][8] = 1; + toik[18][8] = 1.5; + noik[18][8] = 1.0957690214499; + coik[18][9] = 1; + doik[18][9] = 5; + toik[18][9] = 0.625; + noik[18][9] = 0.053213037828563; + coik[18][10] = 1; + doik[18][10] = 5; + toik[18][10] = 2.625; + noik[18][10] = 0.013050533930825; + coik[18][11] = 2; + doik[18][11] = 1; + toik[18][11] = 5; + noik[18][11] = -0.41079520434476; + coik[18][12] = 2; + doik[18][12] = 2; + toik[18][12] = 4; + noik[18][12] = 0.1463744334412; + coik[18][13] = 2; + doik[18][13] = 4; + toik[18][13] = 4.5; + noik[18][13] = -0.055726838623719; + coik[18][14] = 3; + doik[18][14] = 4; + toik[18][14] = 3; + noik[18][14] = -0.0112017741438; + coik[18][15] = 5; + doik[18][15] = 1; + toik[18][15] = 4; + noik[18][15] = -6.6062758068099E-03; + coik[18][16] = 5; + doik[18][16] = 1; + toik[18][16] = 6; + noik[18][16] = 4.6918522004538E-03; + // Helium + coik[20][1] = 0; + doik[20][1] = 1; + toik[20][1] = 0; + noik[20][1] = -0.45579024006737; + coik[20][2] = 0; + doik[20][2] = 1; + toik[20][2] = 0.125; + noik[20][2] = 1.2516390754925; + coik[20][3] = 0; + doik[20][3] = 1; + toik[20][3] = 0.75; + noik[20][3] = -1.5438231650621; + coik[20][4] = 0; + doik[20][4] = 4; + toik[20][4] = 1; + noik[20][4] = 0.020467489707221; + coik[20][5] = 1; + doik[20][5] = 1; + toik[20][5] = 0.75; + noik[20][5] = -0.34476212380781; + coik[20][6] = 1; + doik[20][6] = 3; + toik[20][6] = 2.625; + noik[20][6] = -0.020858459512787; + coik[20][7] = 1; + doik[20][7] = 5; + toik[20][7] = 0.125; + noik[20][7] = 0.016227414711778; + coik[20][8] = 1; + doik[20][8] = 5; + toik[20][8] = 1.25; + noik[20][8] = -0.057471818200892; + coik[20][9] = 1; + doik[20][9] = 5; + toik[20][9] = 2; + noik[20][9] = 0.019462416430715; + coik[20][10] = 2; + doik[20][10] = 2; + toik[20][10] = 1; + noik[20][10] = -0.03329568012302; + coik[20][11] = 3; + doik[20][11] = 1; + toik[20][11] = 4.5; + noik[20][11] = -0.010863577372367; + coik[20][12] = 3; + doik[20][12] = 2; + toik[20][12] = 5; + noik[20][12] = -0.022173365245954; + + // Exponents in mixture equations + // Methane-Nitrogen + dijk[3][1] = 1; + tijk[3][1] = 0; + cijk[3][1] = 0; + eijk[3][1] = 0; + bijk[3][1] = 0; + gijk[3][1] = 0; + nijk[3][1] = -9.8038985517335E-03; + dijk[3][2] = 4; + tijk[3][2] = 1.85; + cijk[3][2] = 0; + eijk[3][2] = 0; + bijk[3][2] = 0; + gijk[3][2] = 0; + nijk[3][2] = 4.2487270143005E-04; + dijk[3][3] = 1; + tijk[3][3] = 7.85; + cijk[3][3] = 1; + eijk[3][3] = 0.5; + bijk[3][3] = 1; + gijk[3][3] = 0.5; + nijk[3][3] = -0.034800214576142; + dijk[3][4] = 2; + tijk[3][4] = 5.4; + cijk[3][4] = 1; + eijk[3][4] = 0.5; + bijk[3][4] = 1; + gijk[3][4] = 0.5; + nijk[3][4] = -0.13333813013896; + dijk[3][5] = 2; + tijk[3][5] = 0; + cijk[3][5] = 0.25; + eijk[3][5] = 0.5; + bijk[3][5] = 2.5; + gijk[3][5] = 0.5; + nijk[3][5] = -0.011993694974627; + dijk[3][6] = 2; + tijk[3][6] = 0.75; + cijk[3][6] = 0; + eijk[3][6] = 0.5; + bijk[3][6] = 3; + gijk[3][6] = 0.5; + nijk[3][6] = 0.069243379775168; + dijk[3][7] = 2; + tijk[3][7] = 2.8; + cijk[3][7] = 0; + eijk[3][7] = 0.5; + bijk[3][7] = 3; + gijk[3][7] = 0.5; + nijk[3][7] = -0.31022508148249; + dijk[3][8] = 2; + tijk[3][8] = 4.45; + cijk[3][8] = 0; + eijk[3][8] = 0.5; + bijk[3][8] = 3; + gijk[3][8] = 0.5; + nijk[3][8] = 0.24495491753226; + dijk[3][9] = 3; + tijk[3][9] = 4.25; + cijk[3][9] = 0; + eijk[3][9] = 0.5; + bijk[3][9] = 3; + gijk[3][9] = 0.5; + nijk[3][9] = 0.22369816716981; + // Methane-Carbon dioxide + dijk[4][1] = 1; + tijk[4][1] = 2.6; + cijk[4][1] = 0; + eijk[4][1] = 0; + bijk[4][1] = 0; + gijk[4][1] = 0; + nijk[4][1] = -0.10859387354942; + dijk[4][2] = 2; + tijk[4][2] = 1.95; + cijk[4][2] = 0; + eijk[4][2] = 0; + bijk[4][2] = 0; + gijk[4][2] = 0; + nijk[4][2] = 0.080228576727389; + dijk[4][3] = 3; + tijk[4][3] = 0; + cijk[4][3] = 0; + eijk[4][3] = 0; + bijk[4][3] = 0; + gijk[4][3] = 0; + nijk[4][3] = -9.3303985115717E-03; + dijk[4][4] = 1; + tijk[4][4] = 3.95; + cijk[4][4] = 1; + eijk[4][4] = 0.5; + bijk[4][4] = 1; + gijk[4][4] = 0.5; + nijk[4][4] = 0.040989274005848; + dijk[4][5] = 2; + tijk[4][5] = 7.95; + cijk[4][5] = 0.5; + eijk[4][5] = 0.5; + bijk[4][5] = 2; + gijk[4][5] = 0.5; + nijk[4][5] = -0.24338019772494; + dijk[4][6] = 3; + tijk[4][6] = 8; + cijk[4][6] = 0; + eijk[4][6] = 0.5; + bijk[4][6] = 3; + gijk[4][6] = 0.5; + nijk[4][6] = 0.23855347281124; + // Methane-Ethane + dijk[1][1] = 3; + tijk[1][1] = 0.65; + cijk[1][1] = 0; + eijk[1][1] = 0; + bijk[1][1] = 0; + gijk[1][1] = 0; + nijk[1][1] = -8.0926050298746E-04; + dijk[1][2] = 4; + tijk[1][2] = 1.55; + cijk[1][2] = 0; + eijk[1][2] = 0; + bijk[1][2] = 0; + gijk[1][2] = 0; + nijk[1][2] = -7.5381925080059E-04; + dijk[1][3] = 1; + tijk[1][3] = 3.1; + cijk[1][3] = 1; + eijk[1][3] = 0.5; + bijk[1][3] = 1; + gijk[1][3] = 0.5; + nijk[1][3] = -0.041618768891219; + dijk[1][4] = 2; + tijk[1][4] = 5.9; + cijk[1][4] = 1; + eijk[1][4] = 0.5; + bijk[1][4] = 1; + gijk[1][4] = 0.5; + nijk[1][4] = -0.23452173681569; + dijk[1][5] = 2; + tijk[1][5] = 7.05; + cijk[1][5] = 1; + eijk[1][5] = 0.5; + bijk[1][5] = 1; + gijk[1][5] = 0.5; + nijk[1][5] = 0.14003840584586; + dijk[1][6] = 2; + tijk[1][6] = 3.35; + cijk[1][6] = 0.875; + eijk[1][6] = 0.5; + bijk[1][6] = 1.25; + gijk[1][6] = 0.5; + nijk[1][6] = 0.063281744807738; + dijk[1][7] = 2; + tijk[1][7] = 1.2; + cijk[1][7] = 0.75; + eijk[1][7] = 0.5; + bijk[1][7] = 1.5; + gijk[1][7] = 0.5; + nijk[1][7] = -0.034660425848809; + dijk[1][8] = 2; + tijk[1][8] = 5.8; + cijk[1][8] = 0.5; + eijk[1][8] = 0.5; + bijk[1][8] = 2; + gijk[1][8] = 0.5; + nijk[1][8] = -0.23918747334251; + dijk[1][9] = 2; + tijk[1][9] = 2.7; + cijk[1][9] = 0; + eijk[1][9] = 0.5; + bijk[1][9] = 3; + gijk[1][9] = 0.5; + nijk[1][9] = 1.9855255066891E-03; + dijk[1][10] = 3; + tijk[1][10] = 0.45; + cijk[1][10] = 0; + eijk[1][10] = 0.5; + bijk[1][10] = 3; + gijk[1][10] = 0.5; + nijk[1][10] = 6.1777746171555; + dijk[1][11] = 3; + tijk[1][11] = 0.55; + cijk[1][11] = 0; + eijk[1][11] = 0.5; + bijk[1][11] = 3; + gijk[1][11] = 0.5; + nijk[1][11] = -6.9575358271105; + dijk[1][12] = 3; + tijk[1][12] = 1.95; + cijk[1][12] = 0; + eijk[1][12] = 0.5; + bijk[1][12] = 3; + gijk[1][12] = 0.5; + nijk[1][12] = 1.0630185306388; + // Methane-Propane + dijk[2][1] = 3; + tijk[2][1] = 1.85; + cijk[2][1] = 0; + eijk[2][1] = 0; + bijk[2][1] = 0; + gijk[2][1] = 0; + nijk[2][1] = 0.013746429958576; + dijk[2][2] = 3; + tijk[2][2] = 3.95; + cijk[2][2] = 0; + eijk[2][2] = 0; + bijk[2][2] = 0; + gijk[2][2] = 0; + nijk[2][2] = -7.4425012129552E-03; + dijk[2][3] = 4; + tijk[2][3] = 0; + cijk[2][3] = 0; + eijk[2][3] = 0; + bijk[2][3] = 0; + gijk[2][3] = 0; + nijk[2][3] = -4.5516600213685E-03; + dijk[2][4] = 4; + tijk[2][4] = 1.85; + cijk[2][4] = 0; + eijk[2][4] = 0; + bijk[2][4] = 0; + gijk[2][4] = 0; + nijk[2][4] = -5.4546603350237E-03; + dijk[2][5] = 4; + tijk[2][5] = 3.85; + cijk[2][5] = 0; + eijk[2][5] = 0; + bijk[2][5] = 0; + gijk[2][5] = 0; + nijk[2][5] = 2.3682016824471E-03; + dijk[2][6] = 1; + tijk[2][6] = 5.25; + cijk[2][6] = 0.25; + eijk[2][6] = 0.5; + bijk[2][6] = 0.75; + gijk[2][6] = 0.5; + nijk[2][6] = 0.18007763721438; + dijk[2][7] = 1; + tijk[2][7] = 3.85; + cijk[2][7] = 0.25; + eijk[2][7] = 0.5; + bijk[2][7] = 1; + gijk[2][7] = 0.5; + nijk[2][7] = -0.44773942932486; + dijk[2][8] = 1; + tijk[2][8] = 0.2; + cijk[2][8] = 0; + eijk[2][8] = 0.5; + bijk[2][8] = 2; + gijk[2][8] = 0.5; + nijk[2][8] = 0.0193273748882; + dijk[2][9] = 2; + tijk[2][9] = 6.5; + cijk[2][9] = 0; + eijk[2][9] = 0.5; + bijk[2][9] = 3; + gijk[2][9] = 0.5; + nijk[2][9] = -0.30632197804624; + // Nitrogen-Carbon dioxide + dijk[5][1] = 2; + tijk[5][1] = 1.85; + cijk[5][1] = 0; + eijk[5][1] = 0; + bijk[5][1] = 0; + gijk[5][1] = 0; + nijk[5][1] = 0.28661625028399; + dijk[5][2] = 3; + tijk[5][2] = 1.4; + cijk[5][2] = 0; + eijk[5][2] = 0; + bijk[5][2] = 0; + gijk[5][2] = 0; + nijk[5][2] = -0.10919833861247; + dijk[5][3] = 1; + tijk[5][3] = 3.2; + cijk[5][3] = 0.25; + eijk[5][3] = 0.5; + bijk[5][3] = 0.75; + gijk[5][3] = 0.5; + nijk[5][3] = -1.137403208227; + dijk[5][4] = 1; + tijk[5][4] = 2.5; + cijk[5][4] = 0.25; + eijk[5][4] = 0.5; + bijk[5][4] = 1; + gijk[5][4] = 0.5; + nijk[5][4] = 0.76580544237358; + dijk[5][5] = 1; + tijk[5][5] = 8; + cijk[5][5] = 0; + eijk[5][5] = 0.5; + bijk[5][5] = 2; + gijk[5][5] = 0.5; + nijk[5][5] = 4.2638000926819E-03; + dijk[5][6] = 2; + tijk[5][6] = 3.75; + cijk[5][6] = 0; + eijk[5][6] = 0.5; + bijk[5][6] = 3; + gijk[5][6] = 0.5; + nijk[5][6] = 0.17673538204534; + // Nitrogen-Ethane + dijk[6][1] = 2; + tijk[6][1] = 0; + cijk[6][1] = 0; + eijk[6][1] = 0; + bijk[6][1] = 0; + gijk[6][1] = 0; + nijk[6][1] = -0.47376518126608; + dijk[6][2] = 2; + tijk[6][2] = 0.05; + cijk[6][2] = 0; + eijk[6][2] = 0; + bijk[6][2] = 0; + gijk[6][2] = 0; + nijk[6][2] = 0.48961193461001; + dijk[6][3] = 3; + tijk[6][3] = 0; + cijk[6][3] = 0; + eijk[6][3] = 0; + bijk[6][3] = 0; + gijk[6][3] = 0; + nijk[6][3] = -5.7011062090535E-03; + dijk[6][4] = 1; + tijk[6][4] = 3.65; + cijk[6][4] = 1; + eijk[6][4] = 0.5; + bijk[6][4] = 1; + gijk[6][4] = 0.5; + nijk[6][4] = -0.1996682004132; + dijk[6][5] = 2; + tijk[6][5] = 4.9; + cijk[6][5] = 1; + eijk[6][5] = 0.5; + bijk[6][5] = 1; + gijk[6][5] = 0.5; + nijk[6][5] = -0.69411103101723; + dijk[6][6] = 2; + tijk[6][6] = 4.45; + cijk[6][6] = 0.875; + eijk[6][6] = 0.5; + bijk[6][6] = 1.25; + gijk[6][6] = 0.5; + nijk[6][6] = 0.69226192739021; + // Methane-Hydrogen + dijk[7][1] = 1; + tijk[7][1] = 2; + cijk[7][1] = 0; + eijk[7][1] = 0; + bijk[7][1] = 0; + gijk[7][1] = 0; + nijk[7][1] = -0.25157134971934; + dijk[7][2] = 3; + tijk[7][2] = -1; + cijk[7][2] = 0; + eijk[7][2] = 0; + bijk[7][2] = 0; + gijk[7][2] = 0; + nijk[7][2] = -6.2203841111983E-03; + dijk[7][3] = 3; + tijk[7][3] = 1.75; + cijk[7][3] = 0; + eijk[7][3] = 0; + bijk[7][3] = 0; + gijk[7][3] = 0; + nijk[7][3] = 0.088850315184396; + dijk[7][4] = 4; + tijk[7][4] = 1.4; + cijk[7][4] = 0; + eijk[7][4] = 0; + bijk[7][4] = 0; + gijk[7][4] = 0; + nijk[7][4] = -0.035592212573239; + // Methane-n-Butane, Methane-Isobutane, Ethane-Propane, Ethane-n-Butane, + // Ethane-Isobutane, Propane-n-Butane, Propane-Isobutane, and n-Butane-Isobutane + dijk[10][1] = 1; + tijk[10][1] = 1; + cijk[10][1] = 0; + eijk[10][1] = 0; + bijk[10][1] = 0; + gijk[10][1] = 0; + nijk[10][1] = 2.5574776844118; + dijk[10][2] = 1; + tijk[10][2] = 1.55; + cijk[10][2] = 0; + eijk[10][2] = 0; + bijk[10][2] = 0; + gijk[10][2] = 0; + nijk[10][2] = -7.9846357136353; + dijk[10][3] = 1; + tijk[10][3] = 1.7; + cijk[10][3] = 0; + eijk[10][3] = 0; + bijk[10][3] = 0; + gijk[10][3] = 0; + nijk[10][3] = 4.7859131465806; + dijk[10][4] = 2; + tijk[10][4] = 0.25; + cijk[10][4] = 0; + eijk[10][4] = 0; + bijk[10][4] = 0; + gijk[10][4] = 0; + nijk[10][4] = -0.73265392369587; + dijk[10][5] = 2; + tijk[10][5] = 1.35; + cijk[10][5] = 0; + eijk[10][5] = 0; + bijk[10][5] = 0; + gijk[10][5] = 0; + nijk[10][5] = 1.3805471345312; + dijk[10][6] = 3; + tijk[10][6] = 0; + cijk[10][6] = 0; + eijk[10][6] = 0; + bijk[10][6] = 0; + gijk[10][6] = 0; + nijk[10][6] = 0.28349603476365; + dijk[10][7] = 3; + tijk[10][7] = 1.25; + cijk[10][7] = 0; + eijk[10][7] = 0; + bijk[10][7] = 0; + gijk[10][7] = 0; + nijk[10][7] = -0.49087385940425; + dijk[10][8] = 4; + tijk[10][8] = 0; + cijk[10][8] = 0; + eijk[10][8] = 0; + bijk[10][8] = 0; + gijk[10][8] = 0; + nijk[10][8] = -0.10291888921447; + dijk[10][9] = 4; + tijk[10][9] = 0.7; + cijk[10][9] = 0; + eijk[10][9] = 0; + bijk[10][9] = 0; + gijk[10][9] = 0; + nijk[10][9] = 0.11836314681968; + dijk[10][10] = 4; + tijk[10][10] = 5.4; + cijk[10][10] = 0; + eijk[10][10] = 0; + bijk[10][10] = 0; + gijk[10][10] = 0; + nijk[10][10] = 5.5527385721943E-05; + + // Generalized parameters + fij[1][2] = 1; // Methane-Nitrogen + fij[1][3] = 1; // Methane-CO2 + fij[1][4] = 1; // Methane-Ethane + fij[1][5] = 1; // Methane-Propane + fij[2][3] = 1; // Nitrogen-CO2 + fij[2][4] = 1; // Nitrogen-Ethane + fij[1][15] = 1; // Methane-Hydrogen + fij[1][6] = 0.771035405688; // Methane-Isobutane + fij[1][7] = 1; // Methane-n-Butane + fij[4][5] = 0.13042476515; // Ethane-Propane + fij[4][6] = 0.260632376098; // Ethane-Isobutane + fij[4][7] = 0.281570073085; // Ethane-n-Butane + fij[5][6] = -0.0551609771024; // Propane-Isobutane + fij[5][7] = 0.0312572600489; // Propane-n-Butane + fij[6][7] = -0.0551240293009; // Isobutane-n-Butane + + // Model numbers for binary mixtures with no excess functions (mn=-1) + for (int i = 1; i <= MaxFlds; ++i) { + mNumb[i][i] = -1; + for (int j = i + 1; j <= MaxFlds; ++j) { + fij[j][i] = fij[i][j]; + mNumb[i][j] = -1; + mNumb[j][i] = -1; } - kexp[1] = 18; - kexp[2] = 18; - kexp[4] = 18; - kpol[3] = 4; - kexp[3] = 18; - kpol[15] = 5; - kexp[15] = 9; - kpol[18] = 7; - kexp[18] = 9; - kpol[20] = 4; - kexp[20] = 8; - kpolij[1] = 2; - kexpij[1] = 10; - kpolij[2] = 5; - kexpij[2] = 4; - kpolij[3] = 2; - kexpij[3] = 7; - kpolij[4] = 3; - kexpij[4] = 3; - kpolij[5] = 2; - kexpij[5] = 4; - kpolij[6] = 3; - kexpij[6] = 3; - kpolij[7] = 4; - kexpij[7] = 0; - kpolij[10] = 10; - kexpij[10] = 0; - - // Critical densities [mol/l] - Dc[1] = 10.139342719; - Dc[2] = 11.1839; - Dc[3] = 10.624978698; - Dc[4] = 6.87085454; - Dc[5] = 5.000043088; - Dc[6] = 3.86014294; - Dc[7] = 3.920016792; - Dc[8] = 3.271; - Dc[9] = 3.215577588; - Dc[10] = 2.705877875; - Dc[11] = 2.315324434; - Dc[12] = 2.056404127; - Dc[13] = 1.81; - Dc[14] = 1.64; - Dc[15] = 14.94; - Dc[16] = 13.63; - Dc[17] = 10.85; - Dc[18] = 17.87371609; - Dc[19] = 10.19; - Dc[20] = 17.399; - Dc[21] = 13.407429659; - - // Critical temperatures [K] - Tc[1] = 190.564; - Tc[2] = 126.192; - Tc[3] = 304.1282; - Tc[4] = 305.322; - Tc[5] = 369.825; - Tc[6] = 407.817; - Tc[7] = 425.125; - Tc[8] = 460.35; - Tc[9] = 469.7; - Tc[10] = 507.82; - Tc[11] = 540.13; - Tc[12] = 569.32; - Tc[13] = 594.55; - Tc[14] = 617.7; - Tc[15] = 33.19; - Tc[16] = 154.595; - Tc[17] = 132.86; - Tc[18] = 647.096; - Tc[19] = 373.1; - Tc[20] = 5.1953; - Tc[21] = 150.687; - - // Exponents in pure fluid equations - for (int i = 1; i <= MaxFlds; ++i) { - Vc3[i] = 1 / Math.pow(Dc[i], o13) / 2; - Tc2[i] = Math.sqrt(Tc[i]); - coik[i][1] = 0; - doik[i][1] = 1; - toik[i][1] = 0.25; - coik[i][2] = 0; - doik[i][2] = 1; - toik[i][2] = 1.125; - coik[i][3] = 0; - doik[i][3] = 1; - toik[i][3] = 1.5; - coik[i][4] = 0; - doik[i][4] = 2; - toik[i][4] = 1.375; - coik[i][5] = 0; - doik[i][5] = 3; - toik[i][5] = 0.25; - coik[i][6] = 0; - doik[i][6] = 7; - toik[i][6] = 0.875; - coik[i][7] = 1; - doik[i][7] = 2; - toik[i][7] = 0.625; - coik[i][8] = 1; - doik[i][8] = 5; - toik[i][8] = 1.75; - coik[i][9] = 2; - doik[i][9] = 1; - toik[i][9] = 3.625; - coik[i][10] = 2; - doik[i][10] = 4; - toik[i][10] = 3.625; - coik[i][11] = 3; - doik[i][11] = 3; - toik[i][11] = 14.5; - coik[i][12] = 3; - doik[i][12] = 4; - toik[i][12] = 12; - } - for (int i = 1; i <= 4; ++i) { - if (i != 3) { - coik[i][1] = 0; - doik[i][1] = 1; - toik[i][1] = 0.125; - coik[i][2] = 0; - doik[i][2] = 1; - toik[i][2] = 1.125; - coik[i][3] = 0; - doik[i][3] = 2; - toik[i][3] = 0.375; - coik[i][4] = 0; - doik[i][4] = 2; - toik[i][4] = 1.125; - coik[i][5] = 0; - doik[i][5] = 4; - toik[i][5] = 0.625; - coik[i][6] = 0; - doik[i][6] = 4; - toik[i][6] = 1.5; - coik[i][7] = 1; - doik[i][7] = 1; - toik[i][7] = 0.625; - coik[i][8] = 1; - doik[i][8] = 1; - toik[i][8] = 2.625; - coik[i][9] = 1; - doik[i][9] = 1; - toik[i][9] = 2.75; - coik[i][10] = 1; - doik[i][10] = 2; - toik[i][10] = 2.125; - coik[i][11] = 1; - doik[i][11] = 3; - toik[i][11] = 2; - coik[i][12] = 1; - doik[i][12] = 6; - toik[i][12] = 1.75; - coik[i][13] = 2; - doik[i][13] = 2; - toik[i][13] = 4.5; - coik[i][14] = 2; - doik[i][14] = 3; - toik[i][14] = 4.75; - coik[i][15] = 2; - doik[i][15] = 3; - toik[i][15] = 5; - coik[i][16] = 2; - doik[i][16] = 4; - toik[i][16] = 4; - coik[i][17] = 2; - doik[i][17] = 4; - toik[i][17] = 4.5; - coik[i][18] = 3; - doik[i][18] = 2; - toik[i][18] = 7.5; - coik[i][19] = 3; - doik[i][19] = 3; - toik[i][19] = 14; - coik[i][20] = 3; - doik[i][20] = 4; - toik[i][20] = 11.5; - coik[i][21] = 6; - doik[i][21] = 5; - toik[i][21] = 26; - coik[i][22] = 6; - doik[i][22] = 6; - toik[i][22] = 28; - coik[i][23] = 6; - doik[i][23] = 6; - toik[i][23] = 30; - coik[i][24] = 6; - doik[i][24] = 7; - toik[i][24] = 16; - } + } + + // Model numbers for excess functions, 10 is for generalized equation + mNumb[1][2] = 3; + mNumb[1][3] = 4; + mNumb[1][4] = 1; + mNumb[1][5] = 2; + mNumb[1][6] = 10; + mNumb[1][7] = 10; + mNumb[1][15] = 7; + mNumb[2][3] = 5; + mNumb[2][4] = 6; + mNumb[4][5] = 10; + mNumb[4][6] = 10; + mNumb[4][7] = 10; + mNumb[5][6] = 10; + mNumb[5][7] = 10; + mNumb[6][7] = 10; + + // Ideal gas parameters + n0i[1][3] = 4.00088; + n0i[1][4] = 0.76315; + n0i[1][5] = 0.0046; + n0i[1][6] = 8.74432; + n0i[1][7] = -4.46921; + n0i[1][1] = 29.83843397; + n0i[1][2] = -15999.69151; + n0i[2][3] = 3.50031; + n0i[2][4] = 0.13732; + n0i[2][5] = -0.1466; + n0i[2][6] = 0.90066; + n0i[2][7] = 0; + n0i[2][1] = 17.56770785; + n0i[2][2] = -2801.729072; + n0i[3][3] = 3.50002; + n0i[3][4] = 2.04452; + n0i[3][5] = -1.06044; + n0i[3][6] = 2.03366; + n0i[3][7] = 0.01393; + n0i[3][1] = 20.65844696; + n0i[3][2] = -4902.171516; + n0i[4][3] = 4.00263; + n0i[4][4] = 4.33939; + n0i[4][5] = 1.23722; + n0i[4][6] = 13.1974; + n0i[4][7] = -6.01989; + n0i[4][1] = 36.73005938; + n0i[4][2] = -23639.65301; + n0i[5][3] = 4.02939; + n0i[5][4] = 6.60569; + n0i[5][5] = 3.197; + n0i[5][6] = 19.1921; + n0i[5][7] = -8.37267; + n0i[5][1] = 44.70909619; + n0i[5][2] = -31236.63551; + n0i[6][3] = 4.06714; + n0i[6][4] = 8.97575; + n0i[6][5] = 5.25156; + n0i[6][6] = 25.1423; + n0i[6][7] = 16.1388; + n0i[6][1] = 34.30180349; + n0i[6][2] = -38525.50276; + n0i[7][3] = 4.33944; + n0i[7][4] = 9.44893; + n0i[7][5] = 6.89406; + n0i[7][6] = 24.4618; + n0i[7][7] = 14.7824; + n0i[7][1] = 36.53237783; + n0i[7][2] = -38957.80933; + n0i[8][3] = 4; + n0i[8][4] = 11.7618; + n0i[8][5] = 20.1101; + n0i[8][6] = 33.1688; + n0i[8][7] = 0; + n0i[8][1] = 43.17218626; + n0i[8][2] = -51198.30946; + n0i[9][3] = 4; + n0i[9][4] = 8.95043; + n0i[9][5] = 21.836; + n0i[9][6] = 33.4032; + n0i[9][7] = 0; + n0i[9][1] = 42.67837089; + n0i[9][2] = -45215.83; + n0i[10][3] = 4; + n0i[10][4] = 11.6977; + n0i[10][5] = 26.8142; + n0i[10][6] = 38.6164; + n0i[10][7] = 0; + n0i[10][1] = 46.99717188; + n0i[10][2] = -52746.83318; + n0i[11][3] = 4; + n0i[11][4] = 13.7266; + n0i[11][5] = 30.4707; + n0i[11][6] = 43.5561; + n0i[11][7] = 0; + n0i[11][1] = 52.07631631; + n0i[11][2] = -57104.81056; + n0i[12][3] = 4; + n0i[12][4] = 15.6865; + n0i[12][5] = 33.8029; + n0i[12][6] = 48.1731; + n0i[12][7] = 0; + n0i[12][1] = 57.25830934; + n0i[12][2] = -60546.76385; + n0i[13][3] = 4; + n0i[13][4] = 18.0241; + n0i[13][5] = 38.1235; + n0i[13][6] = 53.3415; + n0i[13][7] = 0; + n0i[13][1] = 62.09646901; + n0i[13][2] = -66600.12837; + n0i[14][3] = 4; + n0i[14][4] = 21.0069; + n0i[14][5] = 43.4931; + n0i[14][6] = 58.3657; + n0i[14][7] = 0; + n0i[14][1] = 65.93909154; + n0i[14][2] = -74131.45483; + n0i[15][3] = 2.47906; + n0i[15][4] = 0.95806; + n0i[15][5] = 0.45444; + n0i[15][6] = 1.56039; + n0i[15][7] = -1.3756; + n0i[15][1] = 13.07520288; + n0i[15][2] = -5836.943696; + n0i[16][3] = 3.50146; + n0i[16][4] = 1.07558; + n0i[16][5] = 1.01334; + n0i[16][6] = 0; + n0i[16][7] = 0; + n0i[16][1] = 16.8017173; + n0i[16][2] = -2318.32269; + n0i[17][3] = 3.50055; + n0i[17][4] = 1.02865; + n0i[17][5] = 0.00493; + n0i[17][6] = 0; + n0i[17][7] = 0; + n0i[17][1] = 17.45786899; + n0i[17][2] = -2635.244116; + n0i[18][3] = 4.00392; + n0i[18][4] = 0.01059; + n0i[18][5] = 0.98763; + n0i[18][6] = 3.06904; + n0i[18][7] = 0; + n0i[18][1] = 21.57882705; + n0i[18][2] = -7766.733078; + n0i[19][3] = 4; + n0i[19][4] = 3.11942; + n0i[19][5] = 1.00243; + n0i[19][6] = 0; + n0i[19][7] = 0; + n0i[19][1] = 21.5830944; + n0i[19][2] = -6069.035869; + n0i[20][3] = 2.5; + n0i[20][4] = 0; + n0i[20][5] = 0; + n0i[20][6] = 0; + n0i[20][7] = 0; + n0i[20][1] = 10.04639507; + n0i[20][2] = -745.375; + n0i[21][3] = 2.5; + n0i[21][4] = 0; + n0i[21][5] = 0; + n0i[21][6] = 0; + n0i[21][7] = 0; + n0i[21][1] = 10.04639507; + n0i[21][2] = -745.375; + th0i[1][4] = 820.659; + th0i[1][5] = 178.41; + th0i[1][6] = 1062.82; + th0i[1][7] = 1090.53; + th0i[2][4] = 662.738; + th0i[2][5] = 680.562; + th0i[2][6] = 1740.06; + th0i[2][7] = 0; + th0i[3][4] = 919.306; + th0i[3][5] = 865.07; + th0i[3][6] = 483.553; + th0i[3][7] = 341.109; + th0i[4][4] = 559.314; + th0i[4][5] = 223.284; + th0i[4][6] = 1031.38; + th0i[4][7] = 1071.29; + th0i[5][4] = 479.856; + th0i[5][5] = 200.893; + th0i[5][6] = 955.312; + th0i[5][7] = 1027.29; + th0i[6][4] = 438.27; + th0i[6][5] = 198.018; + th0i[6][6] = 1905.02; + th0i[6][7] = 893.765; + th0i[7][4] = 468.27; + th0i[7][5] = 183.636; + th0i[7][6] = 1914.1; + th0i[7][7] = 903.185; + th0i[8][4] = 292.503; + th0i[8][5] = 910.237; + th0i[8][6] = 1919.37; + th0i[8][7] = 0; + th0i[9][4] = 178.67; + th0i[9][5] = 840.538; + th0i[9][6] = 1774.25; + th0i[9][7] = 0; + th0i[10][4] = 182.326; + th0i[10][5] = 859.207; + th0i[10][6] = 1826.59; + th0i[10][7] = 0; + th0i[11][4] = 169.789; + th0i[11][5] = 836.195; + th0i[11][6] = 1760.46; + th0i[11][7] = 0; + th0i[12][4] = 158.922; + th0i[12][5] = 815.064; + th0i[12][6] = 1693.07; + th0i[12][7] = 0; + th0i[13][4] = 156.854; + th0i[13][5] = 814.882; + th0i[13][6] = 1693.79; + th0i[13][7] = 0; + th0i[14][4] = 164.947; + th0i[14][5] = 836.264; + th0i[14][6] = 1750.24; + th0i[14][7] = 0; + th0i[15][4] = 228.734; + th0i[15][5] = 326.843; + th0i[15][6] = 1651.71; + th0i[15][7] = 1671.69; + th0i[16][4] = 2235.71; + th0i[16][5] = 1116.69; + th0i[16][6] = 0; + th0i[16][7] = 0; + th0i[17][4] = 1550.45; + th0i[17][5] = 704.525; + th0i[17][6] = 0; + th0i[17][7] = 0; + th0i[18][4] = 268.795; + th0i[18][5] = 1141.41; + th0i[18][6] = 2507.37; + th0i[18][7] = 0; + th0i[19][4] = 1833.63; + th0i[19][5] = 847.181; + th0i[19][6] = 0; + th0i[19][7] = 0; + th0i[20][4] = 0; + th0i[20][5] = 0; + th0i[20][6] = 0; + th0i[20][7] = 0; + th0i[21][4] = 0; + th0i[21][5] = 0; + th0i[21][6] = 0; + th0i[21][7] = 0; + + // Mixture parameters for reducing variables + bvij[1][2] = 0.998721377; + gvij[1][2] = 1.013950311; + btij[1][2] = 0.99809883; + gtij[1][2] = 0.979273013; // CH4-N2 + bvij[1][3] = 0.999518072; + gvij[1][3] = 1.002806594; + btij[1][3] = 1.02262449; + gtij[1][3] = 0.975665369; // CH4-CO2 + bvij[1][4] = 0.997547866; + gvij[1][4] = 1.006617867; + btij[1][4] = 0.996336508; + gtij[1][4] = 1.049707697; // CH4-C2H6 + bvij[1][5] = 1.00482707; + gvij[1][5] = 1.038470657; + btij[1][5] = 0.989680305; + gtij[1][5] = 1.098655531; // CH4-C3H8 + bvij[1][6] = 1.011240388; + gvij[1][6] = 1.054319053; + btij[1][6] = 0.980315756; + gtij[1][6] = 1.161117729; // CH4-i-C4H10 + bvij[1][7] = 0.979105972; + gvij[1][7] = 1.045375122; + btij[1][7] = 0.99417491; + gtij[1][7] = 1.171607691; // CH4-C4H10 + bvij[1][8] = 1; + gvij[1][8] = 1.343685343; + btij[1][8] = 1; + gtij[1][8] = 1.188899743; // CH4-i-C5H12 + bvij[1][9] = 0.94833012; + gvij[1][9] = 1.124508039; + btij[1][9] = 0.992127525; + gtij[1][9] = 1.249173968; // CH4-C5H12 + bvij[1][10] = 0.958015294; + gvij[1][10] = 1.052643846; + btij[1][10] = 0.981844797; + gtij[1][10] = 1.330570181; // CH4-C6H14 + bvij[1][11] = 0.962050831; + gvij[1][11] = 1.156655935; + btij[1][11] = 0.977431529; + gtij[1][11] = 1.379850328; // CH4-C7H16 + bvij[1][12] = 0.994740603; + gvij[1][12] = 1.116549372; + btij[1][12] = 0.957473785; + gtij[1][12] = 1.449245409; // CH4-C8H18 + bvij[1][13] = 1.002852287; + gvij[1][13] = 1.141895355; + btij[1][13] = 0.947716769; + gtij[1][13] = 1.528532478; // CH4-C9H20 + bvij[1][14] = 1.033086292; + gvij[1][14] = 1.146089637; + btij[1][14] = 0.937777823; + gtij[1][14] = 1.568231489; // CH4-C10H22 + bvij[1][15] = 1; + gvij[1][15] = 1.018702573; + btij[1][15] = 1; + gtij[1][15] = 1.352643115; // CH4-H2 + bvij[1][16] = 1; + gvij[1][16] = 1; + btij[1][16] = 1; + gtij[1][16] = 0.95; // CH4-O2 + bvij[1][17] = 0.997340772; + gvij[1][17] = 1.006102927; + btij[1][17] = 0.987411732; + gtij[1][17] = 0.987473033; // CH4-CO + bvij[1][18] = 1.012783169; + gvij[1][18] = 1.585018334; + btij[1][18] = 1.063333913; + gtij[1][18] = 0.775810513; // CH4-H2O + bvij[1][19] = 1.012599087; + gvij[1][19] = 1.040161207; + btij[1][19] = 1.011090031; + gtij[1][19] = 0.961155729; // CH4-H2S + bvij[1][20] = 1; + gvij[1][20] = 0.881405683; + btij[1][20] = 1; + gtij[1][20] = 3.159776855; // CH4-He + bvij[1][21] = 1.034630259; + gvij[1][21] = 1.014678542; + btij[1][21] = 0.990954281; + gtij[1][21] = 0.989843388; // CH4-Ar + bvij[2][3] = 0.977794634; + gvij[2][3] = 1.047578256; + btij[2][3] = 1.005894529; + gtij[2][3] = 1.107654104; // N2-CO2 + bvij[2][4] = 0.978880168; + gvij[2][4] = 1.042352891; + btij[2][4] = 1.007671428; + gtij[2][4] = 1.098650964; // N2-C2H6 + bvij[2][5] = 0.974424681; + gvij[2][5] = 1.081025408; + btij[2][5] = 1.002677329; + gtij[2][5] = 1.201264026; // N2-C3H8 + bvij[2][6] = 0.98641583; + gvij[2][6] = 1.100576129; + btij[2][6] = 0.99286813; + gtij[2][6] = 1.284462634; // N2-i-C4H10 + bvij[2][7] = 0.99608261; + gvij[2][7] = 1.146949309; + btij[2][7] = 0.994515234; + gtij[2][7] = 1.304886838; // N2-C4H10 + bvij[2][8] = 1; + gvij[2][8] = 1.154135439; + btij[2][8] = 1; + gtij[2][8] = 1.38177077; // N2-i-C5H12 + bvij[2][9] = 1; + gvij[2][9] = 1.078877166; + btij[2][9] = 1; + gtij[2][9] = 1.419029041; // N2-C5H12 + bvij[2][10] = 1; + gvij[2][10] = 1.195952177; + btij[2][10] = 1; + gtij[2][10] = 1.472607971; // N2-C6H14 + bvij[2][11] = 1; + gvij[2][11] = 1.40455409; + btij[2][11] = 1; + gtij[2][11] = 1.520975334; // N2-C7H16 + bvij[2][12] = 1; + gvij[2][12] = 1.186067025; + btij[2][12] = 1; + gtij[2][12] = 1.733280051; // N2-C8H18 + bvij[2][13] = 1; + gvij[2][13] = 1.100405929; + btij[2][13] = 0.95637945; + gtij[2][13] = 1.749119996; // N2-C9H20 + bvij[2][14] = 1; + gvij[2][14] = 1; + btij[2][14] = 0.957934447; + gtij[2][14] = 1.822157123; // N2-C10H22 + bvij[2][15] = 0.972532065; + gvij[2][15] = 0.970115357; + btij[2][15] = 0.946134337; + gtij[2][15] = 1.175696583; // N2-H2 + bvij[2][16] = 0.99952177; + gvij[2][16] = 0.997082328; + btij[2][16] = 0.997190589; + gtij[2][16] = 0.995157044; // N2-O2 + bvij[2][17] = 1; + gvij[2][17] = 1.008690943; + btij[2][17] = 1; + gtij[2][17] = 0.993425388; // N2-CO + bvij[2][18] = 1; + gvij[2][18] = 1.094749685; + btij[2][18] = 1; + gtij[2][18] = 0.968808467; // N2-H2O + bvij[2][19] = 0.910394249; + gvij[2][19] = 1.256844157; + btij[2][19] = 1.004692366; + gtij[2][19] = 0.9601742; // N2-H2S + bvij[2][20] = 0.969501055; + gvij[2][20] = 0.932629867; + btij[2][20] = 0.692868765; + gtij[2][20] = 1.47183158; // N2-He + bvij[2][21] = 1.004166412; + gvij[2][21] = 1.002212182; + btij[2][21] = 0.999069843; + gtij[2][21] = 0.990034831; // N2-Ar + bvij[3][4] = 1.002525718; + gvij[3][4] = 1.032876701; + btij[3][4] = 1.013871147; + gtij[3][4] = 0.90094953; // CO2-C2H6 + bvij[3][5] = 0.996898004; + gvij[3][5] = 1.047596298; + btij[3][5] = 1.033620538; + gtij[3][5] = 0.908772477; // CO2-C3H8 + bvij[3][6] = 1.076551882; + gvij[3][6] = 1.081909003; + btij[3][6] = 1.023339824; + gtij[3][6] = 0.929982936; // CO2-i-C4H10 + bvij[3][7] = 1.174760923; + gvij[3][7] = 1.222437324; + btij[3][7] = 1.018171004; + gtij[3][7] = 0.911498231; // CO2-C4H10 + bvij[3][8] = 1.060793104; + gvij[3][8] = 1.116793198; + btij[3][8] = 1.019180957; + gtij[3][8] = 0.961218039; // CO2-i-C5H12 + bvij[3][9] = 1.024311498; + gvij[3][9] = 1.068406078; + btij[3][9] = 1.027000795; + gtij[3][9] = 0.979217302; // CO2-C5H12 + bvij[3][10] = 1; + gvij[3][10] = 0.851343711; + btij[3][10] = 1; + gtij[3][10] = 1.038675574; // CO2-C6H14 + bvij[3][11] = 1.205469976; + gvij[3][11] = 1.164585914; + btij[3][11] = 1.011806317; + gtij[3][11] = 1.046169823; // CO2-C7H16 + bvij[3][12] = 1.026169373; + gvij[3][12] = 1.104043935; + btij[3][12] = 1.02969078; + gtij[3][12] = 1.074455386; // CO2-C8H18 + bvij[3][13] = 1; + gvij[3][13] = 0.973386152; + btij[3][13] = 1.00768862; + gtij[3][13] = 1.140671202; // CO2-C9H20 + bvij[3][14] = 1.000151132; + gvij[3][14] = 1.183394668; + btij[3][14] = 1.02002879; + gtij[3][14] = 1.145512213; // CO2-C10H22 + bvij[3][15] = 0.904142159; + gvij[3][15] = 1.15279255; + btij[3][15] = 0.942320195; + gtij[3][15] = 1.782924792; // CO2-H2 + bvij[3][16] = 1; + gvij[3][16] = 1; + btij[3][16] = 1; + gtij[3][16] = 1; // CO2-O2 + bvij[3][17] = 1; + gvij[3][17] = 1; + btij[3][17] = 1; + gtij[3][17] = 1; // CO2-CO + bvij[3][18] = 0.949055959; + gvij[3][18] = 1.542328793; + btij[3][18] = 0.997372205; + gtij[3][18] = 0.775453996; // CO2-H2O + bvij[3][19] = 0.906630564; + gvij[3][19] = 1.024085837; + btij[3][19] = 1.016034583; + gtij[3][19] = 0.92601888; // CO2-H2S + bvij[3][20] = 0.846647561; + gvij[3][20] = 0.864141549; + btij[3][20] = 0.76837763; + gtij[3][20] = 3.207456948; // CO2-He + bvij[3][21] = 1.008392428; + gvij[3][21] = 1.029205465; + btij[3][21] = 0.996512863; + gtij[3][21] = 1.050971635; // CO2-Ar + bvij[4][5] = 0.997607277; + gvij[4][5] = 1.00303472; + btij[4][5] = 0.996199694; + gtij[4][5] = 1.01473019; // C2H6-C3H8 + bvij[4][6] = 1; + gvij[4][6] = 1.006616886; + btij[4][6] = 1; + gtij[4][6] = 1.033283811; // C2H6-i-C4H10 + bvij[4][7] = 0.999157205; + gvij[4][7] = 1.006179146; + btij[4][7] = 0.999130554; + gtij[4][7] = 1.034832749; // C2H6-C4H10 + bvij[4][8] = 1; + gvij[4][8] = 1.045439935; + btij[4][8] = 1; + gtij[4][8] = 1.021150247; // C2H6-i-C5H12 + bvij[4][9] = 0.993851009; + gvij[4][9] = 1.026085655; + btij[4][9] = 0.998688946; + gtij[4][9] = 1.066665676; // C2H6-C5H12 + bvij[4][10] = 1; + gvij[4][10] = 1.169701102; + btij[4][10] = 1; + gtij[4][10] = 1.092177796; // C2H6-C6H14 + bvij[4][11] = 1; + gvij[4][11] = 1.057666085; + btij[4][11] = 1; + gtij[4][11] = 1.134532014; // C2H6-C7H16 + bvij[4][12] = 1.007469726; + gvij[4][12] = 1.071917985; + btij[4][12] = 0.984068272; + gtij[4][12] = 1.168636194; // C2H6-C8H18 + bvij[4][13] = 1; + gvij[4][13] = 1.14353473; + btij[4][13] = 1; + gtij[4][13] = 1.05603303; // C2H6-C9H20 + bvij[4][14] = 0.995676258; + gvij[4][14] = 1.098361281; + btij[4][14] = 0.970918061; + gtij[4][14] = 1.237191558; // C2H6-C10H22 + bvij[4][15] = 0.925367171; + gvij[4][15] = 1.10607204; + btij[4][15] = 0.932969831; + gtij[4][15] = 1.902008495; // C2H6-H2 + bvij[4][16] = 1; + gvij[4][16] = 1; + btij[4][16] = 1; + gtij[4][16] = 1; // C2H6-O2 + bvij[4][17] = 1; + gvij[4][17] = 1.201417898; + btij[4][17] = 1; + gtij[4][17] = 1.069224728; // C2H6-CO + bvij[4][18] = 1; + gvij[4][18] = 1; + btij[4][18] = 1; + gtij[4][18] = 1; // C2H6-H2O + bvij[4][19] = 1.010817909; + gvij[4][19] = 1.030988277; + btij[4][19] = 0.990197354; + gtij[4][19] = 0.90273666; // C2H6-H2S + bvij[4][20] = 1; + gvij[4][20] = 1; + btij[4][20] = 1; + gtij[4][20] = 1; // C2H6-He + bvij[4][21] = 1; + gvij[4][21] = 1; + btij[4][21] = 1; + gtij[4][21] = 1; // C2H6-Ar + bvij[5][6] = 0.999243146; + gvij[5][6] = 1.001156119; + btij[5][6] = 0.998012298; + gtij[5][6] = 1.005250774; // C3H8-i-C4H10 + bvij[5][7] = 0.999795868; + gvij[5][7] = 1.003264179; + btij[5][7] = 1.000310289; + gtij[5][7] = 1.007392782; // C3H8-C4H10 + bvij[5][8] = 1.040459289; + gvij[5][8] = 0.999432118; + btij[5][8] = 0.994364425; + gtij[5][8] = 1.0032695; // C3H8-i-C5H12 + bvij[5][9] = 1.044919431; + gvij[5][9] = 1.019921513; + btij[5][9] = 0.996484021; + gtij[5][9] = 1.008344412; // C3H8-C5H12 + bvij[5][10] = 1; + gvij[5][10] = 1.057872566; + btij[5][10] = 1; + gtij[5][10] = 1.025657518; // C3H8-C6H14 + bvij[5][11] = 1; + gvij[5][11] = 1.079648053; + btij[5][11] = 1; + gtij[5][11] = 1.050044169; // C3H8-C7H16 + bvij[5][12] = 1; + gvij[5][12] = 1.102764612; + btij[5][12] = 1; + gtij[5][12] = 1.063694129; // C3H8-C8H18 + bvij[5][13] = 1; + gvij[5][13] = 1.199769134; + btij[5][13] = 1; + gtij[5][13] = 1.109973833; // C3H8-C9H20 + bvij[5][14] = 0.984104227; + gvij[5][14] = 1.053040574; + btij[5][14] = 0.985331233; + gtij[5][14] = 1.140905252; // C3H8-C10H22 + bvij[5][15] = 1; + gvij[5][15] = 1.07400611; + btij[5][15] = 1; + gtij[5][15] = 2.308215191; // C3H8-H2 + bvij[5][16] = 1; + gvij[5][16] = 1; + btij[5][16] = 1; + gtij[5][16] = 1; // C3H8-O2 + bvij[5][17] = 1; + gvij[5][17] = 1.108143673; + btij[5][17] = 1; + gtij[5][17] = 1.197564208; // C3H8-CO + bvij[5][18] = 1; + gvij[5][18] = 1.011759763; + btij[5][18] = 1; + gtij[5][18] = 0.600340961; // C3H8-H2O + bvij[5][19] = 0.936811219; + gvij[5][19] = 1.010593999; + btij[5][19] = 0.992573556; + gtij[5][19] = 0.905829247; // C3H8-H2S + bvij[5][20] = 1; + gvij[5][20] = 1; + btij[5][20] = 1; + gtij[5][20] = 1; // C3H8-He + bvij[5][21] = 1; + gvij[5][21] = 1; + btij[5][21] = 1; + gtij[5][21] = 1; // C3H8-Ar + + // The beta values for isobutane+butane are the reciprocal values of those in the GERG-2008 + // publication because the order was reversed in this work. + bvij[6][7] = 0.999120311; + gvij[6][7] = 1.00041444; + btij[6][7] = 0.999922459; + gtij[6][7] = 1.001432824; // C4H10-i-C4H10 + + bvij[6][8] = 1; + gvij[6][8] = 1.002284353; + btij[6][8] = 1; + gtij[6][8] = 1.001835788; // i-C4H10-i-C5H1 + bvij[6][9] = 1; + gvij[6][9] = 1.002779804; + btij[6][9] = 1; + gtij[6][9] = 1.002495889; // i-C4H10-C5H12 + bvij[6][10] = 1; + gvij[6][10] = 1.010493989; + btij[6][10] = 1; + gtij[6][10] = 1.006018054; // i-C4H10-C6H14 + bvij[6][11] = 1; + gvij[6][11] = 1.021668316; + btij[6][11] = 1; + gtij[6][11] = 1.00988576; // i-C4H10-C7H16 + bvij[6][12] = 1; + gvij[6][12] = 1.032807063; + btij[6][12] = 1; + gtij[6][12] = 1.013945424; // i-C4H10-C8H18 + bvij[6][13] = 1; + gvij[6][13] = 1.047298475; + btij[6][13] = 1; + gtij[6][13] = 1.017817492; // i-C4H10-C9H20 + bvij[6][14] = 1; + gvij[6][14] = 1.060243344; + btij[6][14] = 1; + gtij[6][14] = 1.021624748; // i-C4H10-C10H22 + bvij[6][15] = 1; + gvij[6][15] = 1.147595688; + btij[6][15] = 1; + gtij[6][15] = 1.895305393; // i-C4H10-H2 + bvij[6][16] = 1; + gvij[6][16] = 1; + btij[6][16] = 1; + gtij[6][16] = 1; // i-C4H10-O2 + bvij[6][17] = 1; + gvij[6][17] = 1.087272232; + btij[6][17] = 1; + gtij[6][17] = 1.161390082; // i-C4H10-CO + bvij[6][18] = 1; + gvij[6][18] = 1; + btij[6][18] = 1; + gtij[6][18] = 1; // i-C4H10-H2O + bvij[6][19] = 1.012994431; + gvij[6][19] = 0.988591117; + btij[6][19] = 0.974550548; + gtij[6][19] = 0.937130844; // i-C4H10-H2S + bvij[6][20] = 1; + gvij[6][20] = 1; + btij[6][20] = 1; + gtij[6][20] = 1; // i-C4H10-He + bvij[6][21] = 1; + gvij[6][21] = 1; + btij[6][21] = 1; + gtij[6][21] = 1; // i-C4H10-Ar + bvij[7][8] = 1; + gvij[7][8] = 1.002728434; + btij[7][8] = 1; + gtij[7][8] = 1.000792201; // C4H10-i-C5H12 + bvij[7][9] = 1; + gvij[7][9] = 1.01815965; + btij[7][9] = 1; + gtij[7][9] = 1.00214364; // C4H10-C5H12 + bvij[7][10] = 1; + gvij[7][10] = 1.034995284; + btij[7][10] = 1; + gtij[7][10] = 1.00915706; // C4H10-C6H14 + bvij[7][11] = 1; + gvij[7][11] = 1.019174227; + btij[7][11] = 1; + gtij[7][11] = 1.021283378; // C4H10-C7H16 + bvij[7][12] = 1; + gvij[7][12] = 1.046905515; + btij[7][12] = 1; + gtij[7][12] = 1.033180106; // C4H10-C8H18 + bvij[7][13] = 1; + gvij[7][13] = 1.049219137; + btij[7][13] = 1; + gtij[7][13] = 1.014096448; // C4H10-C9H20 + bvij[7][14] = 0.976951968; + gvij[7][14] = 1.027845529; + btij[7][14] = 0.993688386; + gtij[7][14] = 1.076466918; // C4H10-C10H22 + bvij[7][15] = 1; + gvij[7][15] = 1.232939523; + btij[7][15] = 1; + gtij[7][15] = 2.509259945; // C4H10-H2 + bvij[7][16] = 1; + gvij[7][16] = 1; + btij[7][16] = 1; + gtij[7][16] = 1; // C4H10-O2 + bvij[7][17] = 1; + gvij[7][17] = 1.084740904; + btij[7][17] = 1; + gtij[7][17] = 1.173916162; // C4H10-CO + bvij[7][18] = 1; + gvij[7][18] = 1.223638763; + btij[7][18] = 1; + gtij[7][18] = 0.615512682; // C4H10-H2O + bvij[7][19] = 0.908113163; + gvij[7][19] = 1.033366041; + btij[7][19] = 0.985962886; + gtij[7][19] = 0.926156602; // C4H10-H2S + bvij[7][20] = 1; + gvij[7][20] = 1; + btij[7][20] = 1; + gtij[7][20] = 1; // C4H10-He + bvij[7][21] = 1; + gvij[7][21] = 1.214638734; + btij[7][21] = 1; + gtij[7][21] = 1.245039498; // C4H10-Ar + bvij[8][9] = 1; + gvij[8][9] = 1.000024335; + btij[8][9] = 1; + gtij[8][9] = 1.000050537; // C5H12-i-C5H12 + bvij[8][10] = 1; + gvij[8][10] = 1.002995876; + btij[8][10] = 1; + gtij[8][10] = 1.001204174; // i-C5H12-C6H14 + bvij[8][11] = 1; + gvij[8][11] = 1.009928206; + btij[8][11] = 1; + gtij[8][11] = 1.003194615; // i-C5H12-C7H16 + bvij[8][12] = 1; + gvij[8][12] = 1.017880545; + btij[8][12] = 1; + gtij[8][12] = 1.00564748; // i-C5H12-C8H18 + bvij[8][13] = 1; + gvij[8][13] = 1.028994325; + btij[8][13] = 1; + gtij[8][13] = 1.008191499; // i-C5H12-C9H20 + bvij[8][14] = 1; + gvij[8][14] = 1.039372957; + btij[8][14] = 1; + gtij[8][14] = 1.010825138; // i-C5H12-C10H22 + bvij[8][15] = 1; + gvij[8][15] = 1.184340443; + btij[8][15] = 1; + gtij[8][15] = 1.996386669; // i-C5H12-H2 + bvij[8][16] = 1; + gvij[8][16] = 1; + btij[8][16] = 1; + gtij[8][16] = 1; // i-C5H12-O2 + bvij[8][17] = 1; + gvij[8][17] = 1.116694577; + btij[8][17] = 1; + gtij[8][17] = 1.199326059; // i-C5H12-CO + bvij[8][18] = 1; + gvij[8][18] = 1; + btij[8][18] = 1; + gtij[8][18] = 1; // i-C5H12-H2O + bvij[8][19] = 1; + gvij[8][19] = 0.835763343; + btij[8][19] = 1; + gtij[8][19] = 0.982651529; // i-C5H12-H2S + bvij[8][20] = 1; + gvij[8][20] = 1; + btij[8][20] = 1; + gtij[8][20] = 1; // i-C5H12-He + bvij[8][21] = 1; + gvij[8][21] = 1; + btij[8][21] = 1; + gtij[8][21] = 1; // i-C5H12-Ar + bvij[9][10] = 1; + gvij[9][10] = 1.002480637; + btij[9][10] = 1; + gtij[9][10] = 1.000761237; // C5H12-C6H14 + bvij[9][11] = 1; + gvij[9][11] = 1.008972412; + btij[9][11] = 1; + gtij[9][11] = 1.002441051; // C5H12-C7H16 + bvij[9][12] = 1; + gvij[9][12] = 1.069223964; + btij[9][12] = 1; + gtij[9][12] = 1.016422347; // C5H12-C8H18 + bvij[9][13] = 1; + gvij[9][13] = 1.034910633; + btij[9][13] = 1; + gtij[9][13] = 1.103421755; // C5H12-C9H20 + bvij[9][14] = 1; + gvij[9][14] = 1.016370338; + btij[9][14] = 1; + gtij[9][14] = 1.049035838; // C5H12-C10H22 + bvij[9][15] = 1; + gvij[9][15] = 1.188334783; + btij[9][15] = 1; + gtij[9][15] = 2.013859174; // C5H12-H2 + bvij[9][16] = 1; + gvij[9][16] = 1; + btij[9][16] = 1; + gtij[9][16] = 1; // C5H12-O2 + bvij[9][17] = 1; + gvij[9][17] = 1.119954454; + btij[9][17] = 1; + gtij[9][17] = 1.206043295; // C5H12-CO + bvij[9][18] = 1; + gvij[9][18] = 0.95667731; + btij[9][18] = 1; + gtij[9][18] = 0.447666011; // C5H12-H2O + bvij[9][19] = 0.984613203; + gvij[9][19] = 1.076539234; + btij[9][19] = 0.962006651; + gtij[9][19] = 0.959065662; // C5H12-H2S + bvij[9][20] = 1; + gvij[9][20] = 1; + btij[9][20] = 1; + gtij[9][20] = 1; // C5H12-He + bvij[9][21] = 1; + gvij[9][21] = 1; + btij[9][21] = 1; + gtij[9][21] = 1; // C5H12-Ar + bvij[10][11] = 1; + gvij[10][11] = 1.001508227; + btij[10][11] = 1; + gtij[10][11] = 0.999762786; // C6H14-C7H16 + bvij[10][12] = 1; + gvij[10][12] = 1.006268954; + btij[10][12] = 1; + gtij[10][12] = 1.001633952; // C6H14-C8H18 + bvij[10][13] = 1; + gvij[10][13] = 1.02076168; + btij[10][13] = 1; + gtij[10][13] = 1.055369591; // C6H14-C9H20 + bvij[10][14] = 1.001516371; + gvij[10][14] = 1.013511439; + btij[10][14] = 0.99764101; + gtij[10][14] = 1.028939539; // C6H14-C10H22 + bvij[10][15] = 1; + gvij[10][15] = 1.243461678; + btij[10][15] = 1; + gtij[10][15] = 3.021197546; // C6H14-H2 + bvij[10][16] = 1; + gvij[10][16] = 1; + btij[10][16] = 1; + gtij[10][16] = 1; // C6H14-O2 + bvij[10][17] = 1; + gvij[10][17] = 1.155145836; + btij[10][17] = 1; + gtij[10][17] = 1.233272781; // C6H14-CO + bvij[10][18] = 1; + gvij[10][18] = 1.170217596; + btij[10][18] = 1; + gtij[10][18] = 0.569681333; // C6H14-H2O + bvij[10][19] = 0.754473958; + gvij[10][19] = 1.339283552; + btij[10][19] = 0.985891113; + gtij[10][19] = 0.956075596; // C6H14-H2S + bvij[10][20] = 1; + gvij[10][20] = 1; + btij[10][20] = 1; + gtij[10][20] = 1; // C6H14-He + bvij[10][21] = 1; + gvij[10][21] = 1; + btij[10][21] = 1; + gtij[10][21] = 1; // C6H14-Ar + bvij[11][12] = 1; + gvij[11][12] = 1.006767176; + btij[11][12] = 1; + gtij[11][12] = 0.998793111; // C7H16-C8H18 + bvij[11][13] = 1; + gvij[11][13] = 1.001370076; + btij[11][13] = 1; + gtij[11][13] = 1.001150096; // C7H16-C9H20 + bvij[11][14] = 1; + gvij[11][14] = 1.002972346; + btij[11][14] = 1; + gtij[11][14] = 1.002229938; // C7H16-C10H22 + bvij[11][15] = 1; + gvij[11][15] = 1.159131722; + btij[11][15] = 1; + gtij[11][15] = 3.169143057; // C7H16-H2 + bvij[11][16] = 1; + gvij[11][16] = 1; + btij[11][16] = 1; + gtij[11][16] = 1; // C7H16-O2 + bvij[11][17] = 1; + gvij[11][17] = 1.190354273; + btij[11][17] = 1; + gtij[11][17] = 1.256123503; // C7H16-CO + bvij[11][18] = 1; + gvij[11][18] = 1; + btij[11][18] = 1; + gtij[11][18] = 1; // C7H16-H2O + bvij[11][19] = 0.828967164; + gvij[11][19] = 1.087956749; + btij[11][19] = 0.988937417; + gtij[11][19] = 1.013453092; // C7H16-H2S + bvij[11][20] = 1; + gvij[11][20] = 1; + btij[11][20] = 1; + gtij[11][20] = 1; // C7H16-He + bvij[11][21] = 1; + gvij[11][21] = 1; + btij[11][21] = 1; + gtij[11][21] = 1; // C7H16-Ar + bvij[12][13] = 1; + gvij[12][13] = 1.001357085; + btij[12][13] = 1; + gtij[12][13] = 1.000235044; // C8H18-C9H20 + bvij[12][14] = 1; + gvij[12][14] = 1.002553544; + btij[12][14] = 1; + gtij[12][14] = 1.007186267; // C8H18-C10H22 + bvij[12][15] = 1; + gvij[12][15] = 1.305249405; + btij[12][15] = 1; + gtij[12][15] = 2.191555216; // C8H18-H2 + bvij[12][16] = 1; + gvij[12][16] = 1; + btij[12][16] = 1; + gtij[12][16] = 1; // C8H18-O2 + bvij[12][17] = 1; + gvij[12][17] = 1.219206702; + btij[12][17] = 1; + gtij[12][17] = 1.276565536; // C8H18-CO + bvij[12][18] = 1; + gvij[12][18] = 0.599484191; + btij[12][18] = 1; + gtij[12][18] = 0.662072469; // C8H18-H2O + bvij[12][19] = 1; + gvij[12][19] = 1; + btij[12][19] = 1; + gtij[12][19] = 1; // C8H18-H2S + bvij[12][20] = 1; + gvij[12][20] = 1; + btij[12][20] = 1; + gtij[12][20] = 1; // C8H18-He + bvij[12][21] = 1; + gvij[12][21] = 1; + btij[12][21] = 1; + gtij[12][21] = 1; // C8H18-Ar + bvij[13][14] = 1; + gvij[13][14] = 1.00081052; + btij[13][14] = 1; + gtij[13][14] = 1.000182392; // C9H20-C10H22 + bvij[13][15] = 1; + gvij[13][15] = 1.342647661; + btij[13][15] = 1; + gtij[13][15] = 2.23435404; // C9H20-H2 + bvij[13][16] = 1; + gvij[13][16] = 1; + btij[13][16] = 1; + gtij[13][16] = 1; // C9H20-O2 + bvij[13][17] = 1; + gvij[13][17] = 1.252151449; + btij[13][17] = 1; + gtij[13][17] = 1.294070556; // C9H20-CO + bvij[13][18] = 1; + gvij[13][18] = 1; + btij[13][18] = 1; + gtij[13][18] = 1; // C9H20-H2O + bvij[13][19] = 1; + gvij[13][19] = 1.082905109; + btij[13][19] = 1; + gtij[13][19] = 1.086557826; // C9H20-H2S + bvij[13][20] = 1; + gvij[13][20] = 1; + btij[13][20] = 1; + gtij[13][20] = 1; // C9H20-He + bvij[13][21] = 1; + gvij[13][21] = 1; + btij[13][21] = 1; + gtij[13][21] = 1; // C9H20-Ar + bvij[14][15] = 1.695358382; + gvij[14][15] = 1.120233729; + btij[14][15] = 1.064818089; + gtij[14][15] = 3.786003724; // C10H22-H2 + bvij[14][16] = 1; + gvij[14][16] = 1; + btij[14][16] = 1; + gtij[14][16] = 1; // C10H22-O2 + bvij[14][17] = 1; + gvij[14][17] = 0.87018496; + btij[14][17] = 1.049594632; + gtij[14][17] = 1.803567587; // C10H22-CO + bvij[14][18] = 1; + gvij[14][18] = 0.551405318; + btij[14][18] = 0.897162268; + gtij[14][18] = 0.740416402; // C10H22-H2O + bvij[14][19] = 0.975187766; + gvij[14][19] = 1.171714677; + btij[14][19] = 0.973091413; + gtij[14][19] = 1.103693489; // C10H22-H2S + bvij[14][20] = 1; + gvij[14][20] = 1; + btij[14][20] = 1; + gtij[14][20] = 1; // C10H22-He + bvij[14][21] = 1; + gvij[14][21] = 1; + btij[14][21] = 1; + gtij[14][21] = 1; // C10H22-Ar + bvij[15][16] = 1; + gvij[15][16] = 1; + btij[15][16] = 1; + gtij[15][16] = 1; // H2-O2 + bvij[15][17] = 1; + gvij[15][17] = 1.121416201; + btij[15][17] = 1; + gtij[15][17] = 1.377504607; // H2-CO + bvij[15][18] = 1; + gvij[15][18] = 1; + btij[15][18] = 1; + gtij[15][18] = 1; // H2-H2O + bvij[15][19] = 1; + gvij[15][19] = 1; + btij[15][19] = 1; + gtij[15][19] = 1; // H2-H2S + bvij[15][20] = 1; + gvij[15][20] = 1; + btij[15][20] = 1; + gtij[15][20] = 1; // H2-He + bvij[15][21] = 1; + gvij[15][21] = 1; + btij[15][21] = 1; + gtij[15][21] = 1; // H2-Ar + bvij[16][17] = 1; + gvij[16][17] = 1; + btij[16][17] = 1; + gtij[16][17] = 1; // O2-CO + bvij[16][18] = 1; + gvij[16][18] = 1.143174289; + btij[16][18] = 1; + gtij[16][18] = 0.964767932; // O2-H2O + bvij[16][19] = 1; + gvij[16][19] = 1; + btij[16][19] = 1; + gtij[16][19] = 1; // O2-H2S + bvij[16][20] = 1; + gvij[16][20] = 1; + btij[16][20] = 1; + gtij[16][20] = 1; // O2-He + bvij[16][21] = 0.999746847; + gvij[16][21] = 0.993907223; + btij[16][21] = 1.000023103; + gtij[16][21] = 0.990430423; // O2-Ar + bvij[17][18] = 1; + gvij[17][18] = 1; + btij[17][18] = 1; + gtij[17][18] = 1; // CO-H2O + bvij[17][19] = 0.795660392; + gvij[17][19] = 1.101731308; + btij[17][19] = 1.025536736; + gtij[17][19] = 1.022749748; // CO-H2S + bvij[17][20] = 1; + gvij[17][20] = 1; + btij[17][20] = 1; + gtij[17][20] = 1; // CO-He + bvij[17][21] = 1; + gvij[17][21] = 1.159720623; + btij[17][21] = 1; + gtij[17][21] = 0.954215746; // CO-Ar + bvij[18][19] = 1; + gvij[18][19] = 1.014832832; + btij[18][19] = 1; + gtij[18][19] = 0.940587083; // H2O-H2S + bvij[18][20] = 1; + gvij[18][20] = 1; + btij[18][20] = 1; + gtij[18][20] = 1; // H2O-He + bvij[18][21] = 1; + gvij[18][21] = 1.038993495; + btij[18][21] = 1; + gtij[18][21] = 1.070941866; // H2O-Ar + bvij[19][20] = 1; + gvij[19][20] = 1; + btij[19][20] = 1; + gtij[19][20] = 1; // H2S-He + bvij[19][21] = 1; + gvij[19][21] = 1; + btij[19][21] = 1; + gtij[19][21] = 1; // H2S-Ar + bvij[20][21] = 1; + gvij[20][21] = 1; + btij[20][21] = 1; + gtij[20][21] = 1; // He-Ar + + for (int i = 1; i <= MaxFlds; ++i) { + bvij[i][i] = 1; + btij[i][i] = 1; + gvij[i][i] = 1 / Dc[i]; + gtij[i][i] = Tc[i]; + for (int j = i + 1; j <= MaxFlds; ++j) { + gvij[i][j] = gvij[i][j] * bvij[i][j] * Math.pow(Vc3[i] + Vc3[j], 3); + gtij[i][j] = gtij[i][j] * btij[i][j] * Tc2[i] * Tc2[j]; + bvij[i][j] = Math.pow(bvij[i][j], 2); + btij[i][j] = Math.pow(btij[i][j], 2); } + } - // Coefficients of pure fluid equations - // Methane - noik[1][1] = 0.57335704239162; - noik[1][2] = -1.676068752373; - noik[1][3] = 0.23405291834916; - noik[1][4] = -0.21947376343441; - noik[1][5] = 0.016369201404128; - noik[1][6] = 0.01500440638928; - noik[1][7] = 0.098990489492918; - noik[1][8] = 0.58382770929055; - noik[1][9] = -0.7478686756039; - noik[1][10] = 0.30033302857974; - noik[1][11] = 0.20985543806568; - noik[1][12] = -0.018590151133061; - noik[1][13] = -0.15782558339049; - noik[1][14] = 0.12716735220791; - noik[1][15] = -0.032019743894346; - noik[1][16] = -0.068049729364536; - noik[1][17] = 0.024291412853736; - noik[1][18] = 5.1440451639444E-03; - noik[1][19] = -0.019084949733532; - noik[1][20] = 5.5229677241291E-03; - noik[1][21] = -4.4197392976085E-03; - noik[1][22] = 0.040061416708429; - noik[1][23] = -0.033752085907575; - noik[1][24] = -2.5127658213357E-03; - // Nitrogen - noik[2][1] = 0.59889711801201; - noik[2][2] = -1.6941557480731; - noik[2][3] = 0.24579736191718; - noik[2][4] = -0.23722456755175; - noik[2][5] = 0.017954918715141; - noik[2][6] = 0.014592875720215; - noik[2][7] = 0.10008065936206; - noik[2][8] = 0.73157115385532; - noik[2][9] = -0.88372272336366; - noik[2][10] = 0.31887660246708; - noik[2][11] = 0.20766491728799; - noik[2][12] = -0.019379315454158; - noik[2][13] = -0.16936641554983; - noik[2][14] = 0.13546846041701; - noik[2][15] = -0.033066712095307; - noik[2][16] = -0.060690817018557; - noik[2][17] = 0.012797548292871; - noik[2][18] = 5.8743664107299E-03; - noik[2][19] = -0.018451951971969; - noik[2][20] = 4.7226622042472E-03; - noik[2][21] = -5.2024079680599E-03; - noik[2][22] = 0.043563505956635; - noik[2][23] = -0.036251690750939; - noik[2][24] = -2.8974026866543E-03; - // Ethane - noik[4][1] = 0.63596780450714; - noik[4][2] = -1.7377981785459; - noik[4][3] = 0.28914060926272; - noik[4][4] = -0.33714276845694; - noik[4][5] = 0.022405964699561; - noik[4][6] = 0.015715424886913; - noik[4][7] = 0.11450634253745; - noik[4][8] = 1.0612049379745; - noik[4][9] = -1.2855224439423; - noik[4][10] = 0.39414630777652; - noik[4][11] = 0.31390924682041; - noik[4][12] = -0.021592277117247; - noik[4][13] = -0.21723666564905; - noik[4][14] = -0.28999574439489; - noik[4][15] = 0.42321173025732; - noik[4][16] = 0.04643410025926; - noik[4][17] = -0.13138398329741; - noik[4][18] = 0.011492850364368; - noik[4][19] = -0.033387688429909; - noik[4][20] = 0.015183171583644; - noik[4][21] = -4.7610805647657E-03; - noik[4][22] = 0.046917166277885; - noik[4][23] = -0.039401755804649; - noik[4][24] = -3.2569956247611E-03; - // Propane - noik[5][1] = 1.0403973107358; - noik[5][2] = -2.8318404081403; - noik[5][3] = 0.84393809606294; - noik[5][4] = -0.076559591850023; - noik[5][5] = 0.09469737305728; - noik[5][6] = 2.4796475497006E-04; - noik[5][7] = 0.2774376042287; - noik[5][8] = -0.043846000648377; - noik[5][9] = -0.2699106478435; - noik[5][10] = -0.06931341308986; - noik[5][11] = -0.029632145981653; - noik[5][12] = 0.01404012675138; - // Isobutane - noik[6][1] = 1.04293315891; - noik[6][2] = -2.8184272548892; - noik[6][3] = 0.8617623239785; - noik[6][4] = -0.10613619452487; - noik[6][5] = 0.098615749302134; - noik[6][6] = 2.3948208682322E-04; - noik[6][7] = 0.3033000485695; - noik[6][8] = -0.041598156135099; - noik[6][9] = -0.29991937470058; - noik[6][10] = -0.080369342764109; - noik[6][11] = -0.029761373251151; - noik[6][12] = 0.01305963030314; - // n-Butane - noik[7][1] = 1.0626277411455; - noik[7][2] = -2.862095182835; - noik[7][3] = 0.88738233403777; - noik[7][4] = -0.12570581155345; - noik[7][5] = 0.10286308708106; - noik[7][6] = 2.5358040602654E-04; - noik[7][7] = 0.32325200233982; - noik[7][8] = -0.037950761057432; - noik[7][9] = -0.32534802014452; - noik[7][10] = -0.079050969051011; - noik[7][11] = -0.020636720547775; - noik[7][12] = 0.005705380933475; - // Isopentane - noik[8][1] = 1.0963; - noik[8][2] = -3.0402; - noik[8][3] = 1.0317; - noik[8][4] = -0.1541; - noik[8][5] = 0.11535; - noik[8][6] = 0.00029809; - noik[8][7] = 0.39571; - noik[8][8] = -0.045881; - noik[8][9] = -0.35804; - noik[8][10] = -0.10107; - noik[8][11] = -0.035484; - noik[8][12] = 0.018156; - // n-Pentane - noik[9][1] = 1.0968643098001; - noik[9][2] = -2.9988888298061; - noik[9][3] = 0.99516886799212; - noik[9][4] = -0.16170708558539; - noik[9][5] = 0.11334460072775; - noik[9][6] = 2.6760595150748E-04; - noik[9][7] = 0.40979881986931; - noik[9][8] = -0.040876423083075; - noik[9][9] = -0.38169482469447; - noik[9][10] = -0.10931956843993; - noik[9][11] = -0.03207322332799; - noik[9][12] = 0.016877016216975; - // Hexane - noik[10][1] = 1.0553238013661; - noik[10][2] = -2.6120615890629; - noik[10][3] = 0.7661388296726; - noik[10][4] = -0.29770320622459; - noik[10][5] = 0.11879907733358; - noik[10][6] = 2.7922861062617E-04; - noik[10][7] = 0.46347589844105; - noik[10][8] = 0.011433196980297; - noik[10][9] = -0.48256968738131; - noik[10][10] = -0.093750558924659; - noik[10][11] = -6.7273247155994E-03; - noik[10][12] = -5.1141583585428E-03; - // Heptane - noik[11][1] = 1.0543747645262; - noik[11][2] = -2.6500681506144; - noik[11][3] = 0.81730047827543; - noik[11][4] = -0.30451391253428; - noik[11][5] = 0.122538687108; - noik[11][6] = 2.7266472743928E-04; - noik[11][7] = 0.4986582568167; - noik[11][8] = -7.1432815084176E-04; - noik[11][9] = -0.5423689552545; - noik[11][10] = -0.13801821610756; - noik[11][11] = -6.1595287380011E-03; - noik[11][12] = 4.8602510393022E-04; - // Octane - noik[12][1] = 1.0722544875633; - noik[12][2] = -2.4632951172003; - noik[12][3] = 0.65386674054928; - noik[12][4] = -0.36324974085628; - noik[12][5] = 0.12713269626764; - noik[12][6] = 3.071357277793E-04; - noik[12][7] = 0.5265685698754; - noik[12][8] = 0.019362862857653; - noik[12][9] = -0.58939426849155; - noik[12][10] = -0.14069963991934; - noik[12][11] = -7.8966330500036E-03; - noik[12][12] = 3.3036597968109E-03; - // Nonane - noik[13][1] = 1.1151; - noik[13][2] = -2.702; - noik[13][3] = 0.83416; - noik[13][4] = -0.38828; - noik[13][5] = 0.1376; - noik[13][6] = 0.00028185; - noik[13][7] = 0.62037; - noik[13][8] = 0.015847; - noik[13][9] = -0.61726; - noik[13][10] = -0.15043; - noik[13][11] = -0.012982; - noik[13][12] = 0.0044325; - // Decane - noik[14][1] = 1.0461; - noik[14][2] = -2.4807; - noik[14][3] = 0.74372; - noik[14][4] = -0.52579; - noik[14][5] = 0.15315; - noik[14][6] = 0.00032865; - noik[14][7] = 0.84178; - noik[14][8] = 0.055424; - noik[14][9] = -0.73555; - noik[14][10] = -0.18507; - noik[14][11] = -0.020775; - noik[14][12] = 0.012335; - // Oxygen - noik[16][1] = 0.88878286369701; - noik[16][2] = -2.4879433312148; - noik[16][3] = 0.59750190775886; - noik[16][4] = 9.6501817061881E-03; - noik[16][5] = 0.07197042871277; - noik[16][6] = 2.2337443000195E-04; - noik[16][7] = 0.18558686391474; - noik[16][8] = -0.03812936803576; - noik[16][9] = -0.15352245383006; - noik[16][10] = -0.026726814910919; - noik[16][11] = -0.025675298677127; - noik[16][12] = 9.5714302123668E-03; - // Carbon monoxide - noik[17][1] = 0.90554; - noik[17][2] = -2.4515; - noik[17][3] = 0.53149; - noik[17][4] = 0.024173; - noik[17][5] = 0.072156; - noik[17][6] = 0.00018818; - noik[17][7] = 0.19405; - noik[17][8] = -0.043268; - noik[17][9] = -0.12778; - noik[17][10] = -0.027896; - noik[17][11] = -0.034154; - noik[17][12] = 0.016329; - // Hydrogen sulfide - noik[19][1] = 0.87641; - noik[19][2] = -2.0367; - noik[19][3] = 0.21634; - noik[19][4] = -0.050199; - noik[19][5] = 0.066994; - noik[19][6] = 0.00019076; - noik[19][7] = 0.20227; - noik[19][8] = -0.0045348; - noik[19][9] = -0.2223; - noik[19][10] = -0.034714; - noik[19][11] = -0.014885; - noik[19][12] = 0.0074154; - // Argon - noik[21][1] = 0.85095714803969; - noik[21][2] = -2.400322294348; - noik[21][3] = 0.54127841476466; - noik[21][4] = 0.016919770692538; - noik[21][5] = 0.068825965019035; - noik[21][6] = 2.1428032815338E-04; - noik[21][7] = 0.17429895321992; - noik[21][8] = -0.033654495604194; - noik[21][9] = -0.13526799857691; - noik[21][10] = -0.016387350791552; - noik[21][11] = -0.024987666851475; - noik[21][12] = 8.8769204815709E-03; - // Carbon dioxide - coik[3][1] = 0; - doik[3][1] = 1; - toik[3][1] = 0; - noik[3][1] = 0.52646564804653; - coik[3][2] = 0; - doik[3][2] = 1; - toik[3][2] = 1.25; - noik[3][2] = -1.4995725042592; - coik[3][3] = 0; - doik[3][3] = 2; - toik[3][3] = 1.625; - noik[3][3] = 0.27329786733782; - coik[3][4] = 0; - doik[3][4] = 3; - toik[3][4] = 0.375; - noik[3][4] = 0.12949500022786; - coik[3][5] = 1; - doik[3][5] = 3; - toik[3][5] = 0.375; - noik[3][5] = 0.15404088341841; - coik[3][6] = 1; - doik[3][6] = 3; - toik[3][6] = 1.375; - noik[3][6] = -0.58186950946814; - coik[3][7] = 1; - doik[3][7] = 4; - toik[3][7] = 1.125; - noik[3][7] = -0.18022494838296; - coik[3][8] = 1; - doik[3][8] = 5; - toik[3][8] = 1.375; - noik[3][8] = -0.095389904072812; - coik[3][9] = 1; - doik[3][9] = 6; - toik[3][9] = 0.125; - noik[3][9] = -8.0486819317679E-03; - coik[3][10] = 1; - doik[3][10] = 6; - toik[3][10] = 1.625; - noik[3][10] = -0.03554775127309; - coik[3][11] = 2; - doik[3][11] = 1; - toik[3][11] = 3.75; - noik[3][11] = -0.28079014882405; - coik[3][12] = 2; - doik[3][12] = 4; - toik[3][12] = 3.5; - noik[3][12] = -0.082435890081677; - coik[3][13] = 3; - doik[3][13] = 1; - toik[3][13] = 7.5; - noik[3][13] = 0.010832427979006; - coik[3][14] = 3; - doik[3][14] = 1; - toik[3][14] = 8; - noik[3][14] = -6.7073993161097E-03; - coik[3][15] = 3; - doik[3][15] = 3; - toik[3][15] = 6; - noik[3][15] = -4.6827907600524E-03; - coik[3][16] = 3; - doik[3][16] = 3; - toik[3][16] = 16; - noik[3][16] = -0.028359911832177; - coik[3][17] = 3; - doik[3][17] = 4; - toik[3][17] = 11; - noik[3][17] = 0.019500174744098; - coik[3][18] = 5; - doik[3][18] = 5; - toik[3][18] = 24; - noik[3][18] = -0.21609137507166; - coik[3][19] = 5; - doik[3][19] = 5; - toik[3][19] = 26; - noik[3][19] = 0.43772794926972; - coik[3][20] = 5; - doik[3][20] = 5; - toik[3][20] = 28; - noik[3][20] = -0.22130790113593; - coik[3][21] = 6; - doik[3][21] = 5; - toik[3][21] = 24; - noik[3][21] = 0.015190189957331; - coik[3][22] = 6; - doik[3][22] = 5; - toik[3][22] = 26; - noik[3][22] = -0.0153809489533; - // Hydrogen - coik[15][1] = 0; - doik[15][1] = 1; - toik[15][1] = 0.5; - noik[15][1] = 5.3579928451252; - coik[15][2] = 0; - doik[15][2] = 1; - toik[15][2] = 0.625; - noik[15][2] = -6.2050252530595; - coik[15][3] = 0; - doik[15][3] = 2; - toik[15][3] = 0.375; - noik[15][3] = 0.13830241327086; - coik[15][4] = 0; - doik[15][4] = 2; - toik[15][4] = 0.625; - noik[15][4] = -0.071397954896129; - coik[15][5] = 0; - doik[15][5] = 4; - toik[15][5] = 1.125; - noik[15][5] = 0.015474053959733; - coik[15][6] = 1; - doik[15][6] = 1; - toik[15][6] = 2.625; - noik[15][6] = -0.14976806405771; - coik[15][7] = 1; - doik[15][7] = 5; - toik[15][7] = 0; - noik[15][7] = -0.026368723988451; - coik[15][8] = 1; - doik[15][8] = 5; - toik[15][8] = 0.25; - noik[15][8] = 0.056681303156066; - coik[15][9] = 1; - doik[15][9] = 5; - toik[15][9] = 1.375; - noik[15][9] = -0.060063958030436; - coik[15][10] = 2; - doik[15][10] = 1; - toik[15][10] = 4; - noik[15][10] = -0.45043942027132; - coik[15][11] = 2; - doik[15][11] = 1; - toik[15][11] = 4.25; - noik[15][11] = 0.424788402445; - coik[15][12] = 3; - doik[15][12] = 2; - toik[15][12] = 5; - noik[15][12] = -0.021997640827139; - coik[15][13] = 3; - doik[15][13] = 5; - toik[15][13] = 8; - noik[15][13] = -0.01049952137453; - coik[15][14] = 5; - doik[15][14] = 1; - toik[15][14] = 8; - noik[15][14] = -2.8955902866816E-03; - // Water - coik[18][1] = 0; - doik[18][1] = 1; - toik[18][1] = 0.5; - noik[18][1] = 0.82728408749586; - coik[18][2] = 0; - doik[18][2] = 1; - toik[18][2] = 1.25; - noik[18][2] = -1.8602220416584; - coik[18][3] = 0; - doik[18][3] = 1; - toik[18][3] = 1.875; - noik[18][3] = -1.1199009613744; - coik[18][4] = 0; - doik[18][4] = 2; - toik[18][4] = 0.125; - noik[18][4] = 0.15635753976056; - coik[18][5] = 0; - doik[18][5] = 2; - toik[18][5] = 1.5; - noik[18][5] = 0.87375844859025; - coik[18][6] = 0; - doik[18][6] = 3; - toik[18][6] = 1; - noik[18][6] = -0.36674403715731; - coik[18][7] = 0; - doik[18][7] = 4; - toik[18][7] = 0.75; - noik[18][7] = 0.053987893432436; - coik[18][8] = 1; - doik[18][8] = 1; - toik[18][8] = 1.5; - noik[18][8] = 1.0957690214499; - coik[18][9] = 1; - doik[18][9] = 5; - toik[18][9] = 0.625; - noik[18][9] = 0.053213037828563; - coik[18][10] = 1; - doik[18][10] = 5; - toik[18][10] = 2.625; - noik[18][10] = 0.013050533930825; - coik[18][11] = 2; - doik[18][11] = 1; - toik[18][11] = 5; - noik[18][11] = -0.41079520434476; - coik[18][12] = 2; - doik[18][12] = 2; - toik[18][12] = 4; - noik[18][12] = 0.1463744334412; - coik[18][13] = 2; - doik[18][13] = 4; - toik[18][13] = 4.5; - noik[18][13] = -0.055726838623719; - coik[18][14] = 3; - doik[18][14] = 4; - toik[18][14] = 3; - noik[18][14] = -0.0112017741438; - coik[18][15] = 5; - doik[18][15] = 1; - toik[18][15] = 4; - noik[18][15] = -6.6062758068099E-03; - coik[18][16] = 5; - doik[18][16] = 1; - toik[18][16] = 6; - noik[18][16] = 4.6918522004538E-03; - // Helium - coik[20][1] = 0; - doik[20][1] = 1; - toik[20][1] = 0; - noik[20][1] = -0.45579024006737; - coik[20][2] = 0; - doik[20][2] = 1; - toik[20][2] = 0.125; - noik[20][2] = 1.2516390754925; - coik[20][3] = 0; - doik[20][3] = 1; - toik[20][3] = 0.75; - noik[20][3] = -1.5438231650621; - coik[20][4] = 0; - doik[20][4] = 4; - toik[20][4] = 1; - noik[20][4] = 0.020467489707221; - coik[20][5] = 1; - doik[20][5] = 1; - toik[20][5] = 0.75; - noik[20][5] = -0.34476212380781; - coik[20][6] = 1; - doik[20][6] = 3; - toik[20][6] = 2.625; - noik[20][6] = -0.020858459512787; - coik[20][7] = 1; - doik[20][7] = 5; - toik[20][7] = 0.125; - noik[20][7] = 0.016227414711778; - coik[20][8] = 1; - doik[20][8] = 5; - toik[20][8] = 1.25; - noik[20][8] = -0.057471818200892; - coik[20][9] = 1; - doik[20][9] = 5; - toik[20][9] = 2; - noik[20][9] = 0.019462416430715; - coik[20][10] = 2; - doik[20][10] = 2; - toik[20][10] = 1; - noik[20][10] = -0.03329568012302; - coik[20][11] = 3; - doik[20][11] = 1; - toik[20][11] = 4.5; - noik[20][11] = -0.010863577372367; - coik[20][12] = 3; - doik[20][12] = 2; - toik[20][12] = 5; - noik[20][12] = -0.022173365245954; - - // Exponents in mixture equations - // Methane-Nitrogen - dijk[3][1] = 1; - tijk[3][1] = 0; - cijk[3][1] = 0; - eijk[3][1] = 0; - bijk[3][1] = 0; - gijk[3][1] = 0; - nijk[3][1] = -9.8038985517335E-03; - dijk[3][2] = 4; - tijk[3][2] = 1.85; - cijk[3][2] = 0; - eijk[3][2] = 0; - bijk[3][2] = 0; - gijk[3][2] = 0; - nijk[3][2] = 4.2487270143005E-04; - dijk[3][3] = 1; - tijk[3][3] = 7.85; - cijk[3][3] = 1; - eijk[3][3] = 0.5; - bijk[3][3] = 1; - gijk[3][3] = 0.5; - nijk[3][3] = -0.034800214576142; - dijk[3][4] = 2; - tijk[3][4] = 5.4; - cijk[3][4] = 1; - eijk[3][4] = 0.5; - bijk[3][4] = 1; - gijk[3][4] = 0.5; - nijk[3][4] = -0.13333813013896; - dijk[3][5] = 2; - tijk[3][5] = 0; - cijk[3][5] = 0.25; - eijk[3][5] = 0.5; - bijk[3][5] = 2.5; - gijk[3][5] = 0.5; - nijk[3][5] = -0.011993694974627; - dijk[3][6] = 2; - tijk[3][6] = 0.75; - cijk[3][6] = 0; - eijk[3][6] = 0.5; - bijk[3][6] = 3; - gijk[3][6] = 0.5; - nijk[3][6] = 0.069243379775168; - dijk[3][7] = 2; - tijk[3][7] = 2.8; - cijk[3][7] = 0; - eijk[3][7] = 0.5; - bijk[3][7] = 3; - gijk[3][7] = 0.5; - nijk[3][7] = -0.31022508148249; - dijk[3][8] = 2; - tijk[3][8] = 4.45; - cijk[3][8] = 0; - eijk[3][8] = 0.5; - bijk[3][8] = 3; - gijk[3][8] = 0.5; - nijk[3][8] = 0.24495491753226; - dijk[3][9] = 3; - tijk[3][9] = 4.25; - cijk[3][9] = 0; - eijk[3][9] = 0.5; - bijk[3][9] = 3; - gijk[3][9] = 0.5; - nijk[3][9] = 0.22369816716981; - // Methane-Carbon dioxide - dijk[4][1] = 1; - tijk[4][1] = 2.6; - cijk[4][1] = 0; - eijk[4][1] = 0; - bijk[4][1] = 0; - gijk[4][1] = 0; - nijk[4][1] = -0.10859387354942; - dijk[4][2] = 2; - tijk[4][2] = 1.95; - cijk[4][2] = 0; - eijk[4][2] = 0; - bijk[4][2] = 0; - gijk[4][2] = 0; - nijk[4][2] = 0.080228576727389; - dijk[4][3] = 3; - tijk[4][3] = 0; - cijk[4][3] = 0; - eijk[4][3] = 0; - bijk[4][3] = 0; - gijk[4][3] = 0; - nijk[4][3] = -9.3303985115717E-03; - dijk[4][4] = 1; - tijk[4][4] = 3.95; - cijk[4][4] = 1; - eijk[4][4] = 0.5; - bijk[4][4] = 1; - gijk[4][4] = 0.5; - nijk[4][4] = 0.040989274005848; - dijk[4][5] = 2; - tijk[4][5] = 7.95; - cijk[4][5] = 0.5; - eijk[4][5] = 0.5; - bijk[4][5] = 2; - gijk[4][5] = 0.5; - nijk[4][5] = -0.24338019772494; - dijk[4][6] = 3; - tijk[4][6] = 8; - cijk[4][6] = 0; - eijk[4][6] = 0.5; - bijk[4][6] = 3; - gijk[4][6] = 0.5; - nijk[4][6] = 0.23855347281124; - // Methane-Ethane - dijk[1][1] = 3; - tijk[1][1] = 0.65; - cijk[1][1] = 0; - eijk[1][1] = 0; - bijk[1][1] = 0; - gijk[1][1] = 0; - nijk[1][1] = -8.0926050298746E-04; - dijk[1][2] = 4; - tijk[1][2] = 1.55; - cijk[1][2] = 0; - eijk[1][2] = 0; - bijk[1][2] = 0; - gijk[1][2] = 0; - nijk[1][2] = -7.5381925080059E-04; - dijk[1][3] = 1; - tijk[1][3] = 3.1; - cijk[1][3] = 1; - eijk[1][3] = 0.5; - bijk[1][3] = 1; - gijk[1][3] = 0.5; - nijk[1][3] = -0.041618768891219; - dijk[1][4] = 2; - tijk[1][4] = 5.9; - cijk[1][4] = 1; - eijk[1][4] = 0.5; - bijk[1][4] = 1; - gijk[1][4] = 0.5; - nijk[1][4] = -0.23452173681569; - dijk[1][5] = 2; - tijk[1][5] = 7.05; - cijk[1][5] = 1; - eijk[1][5] = 0.5; - bijk[1][5] = 1; - gijk[1][5] = 0.5; - nijk[1][5] = 0.14003840584586; - dijk[1][6] = 2; - tijk[1][6] = 3.35; - cijk[1][6] = 0.875; - eijk[1][6] = 0.5; - bijk[1][6] = 1.25; - gijk[1][6] = 0.5; - nijk[1][6] = 0.063281744807738; - dijk[1][7] = 2; - tijk[1][7] = 1.2; - cijk[1][7] = 0.75; - eijk[1][7] = 0.5; - bijk[1][7] = 1.5; - gijk[1][7] = 0.5; - nijk[1][7] = -0.034660425848809; - dijk[1][8] = 2; - tijk[1][8] = 5.8; - cijk[1][8] = 0.5; - eijk[1][8] = 0.5; - bijk[1][8] = 2; - gijk[1][8] = 0.5; - nijk[1][8] = -0.23918747334251; - dijk[1][9] = 2; - tijk[1][9] = 2.7; - cijk[1][9] = 0; - eijk[1][9] = 0.5; - bijk[1][9] = 3; - gijk[1][9] = 0.5; - nijk[1][9] = 1.9855255066891E-03; - dijk[1][10] = 3; - tijk[1][10] = 0.45; - cijk[1][10] = 0; - eijk[1][10] = 0.5; - bijk[1][10] = 3; - gijk[1][10] = 0.5; - nijk[1][10] = 6.1777746171555; - dijk[1][11] = 3; - tijk[1][11] = 0.55; - cijk[1][11] = 0; - eijk[1][11] = 0.5; - bijk[1][11] = 3; - gijk[1][11] = 0.5; - nijk[1][11] = -6.9575358271105; - dijk[1][12] = 3; - tijk[1][12] = 1.95; - cijk[1][12] = 0; - eijk[1][12] = 0.5; - bijk[1][12] = 3; - gijk[1][12] = 0.5; - nijk[1][12] = 1.0630185306388; - // Methane-Propane - dijk[2][1] = 3; - tijk[2][1] = 1.85; - cijk[2][1] = 0; - eijk[2][1] = 0; - bijk[2][1] = 0; - gijk[2][1] = 0; - nijk[2][1] = 0.013746429958576; - dijk[2][2] = 3; - tijk[2][2] = 3.95; - cijk[2][2] = 0; - eijk[2][2] = 0; - bijk[2][2] = 0; - gijk[2][2] = 0; - nijk[2][2] = -7.4425012129552E-03; - dijk[2][3] = 4; - tijk[2][3] = 0; - cijk[2][3] = 0; - eijk[2][3] = 0; - bijk[2][3] = 0; - gijk[2][3] = 0; - nijk[2][3] = -4.5516600213685E-03; - dijk[2][4] = 4; - tijk[2][4] = 1.85; - cijk[2][4] = 0; - eijk[2][4] = 0; - bijk[2][4] = 0; - gijk[2][4] = 0; - nijk[2][4] = -5.4546603350237E-03; - dijk[2][5] = 4; - tijk[2][5] = 3.85; - cijk[2][5] = 0; - eijk[2][5] = 0; - bijk[2][5] = 0; - gijk[2][5] = 0; - nijk[2][5] = 2.3682016824471E-03; - dijk[2][6] = 1; - tijk[2][6] = 5.25; - cijk[2][6] = 0.25; - eijk[2][6] = 0.5; - bijk[2][6] = 0.75; - gijk[2][6] = 0.5; - nijk[2][6] = 0.18007763721438; - dijk[2][7] = 1; - tijk[2][7] = 3.85; - cijk[2][7] = 0.25; - eijk[2][7] = 0.5; - bijk[2][7] = 1; - gijk[2][7] = 0.5; - nijk[2][7] = -0.44773942932486; - dijk[2][8] = 1; - tijk[2][8] = 0.2; - cijk[2][8] = 0; - eijk[2][8] = 0.5; - bijk[2][8] = 2; - gijk[2][8] = 0.5; - nijk[2][8] = 0.0193273748882; - dijk[2][9] = 2; - tijk[2][9] = 6.5; - cijk[2][9] = 0; - eijk[2][9] = 0.5; - bijk[2][9] = 3; - gijk[2][9] = 0.5; - nijk[2][9] = -0.30632197804624; - // Nitrogen-Carbon dioxide - dijk[5][1] = 2; - tijk[5][1] = 1.85; - cijk[5][1] = 0; - eijk[5][1] = 0; - bijk[5][1] = 0; - gijk[5][1] = 0; - nijk[5][1] = 0.28661625028399; - dijk[5][2] = 3; - tijk[5][2] = 1.4; - cijk[5][2] = 0; - eijk[5][2] = 0; - bijk[5][2] = 0; - gijk[5][2] = 0; - nijk[5][2] = -0.10919833861247; - dijk[5][3] = 1; - tijk[5][3] = 3.2; - cijk[5][3] = 0.25; - eijk[5][3] = 0.5; - bijk[5][3] = 0.75; - gijk[5][3] = 0.5; - nijk[5][3] = -1.137403208227; - dijk[5][4] = 1; - tijk[5][4] = 2.5; - cijk[5][4] = 0.25; - eijk[5][4] = 0.5; - bijk[5][4] = 1; - gijk[5][4] = 0.5; - nijk[5][4] = 0.76580544237358; - dijk[5][5] = 1; - tijk[5][5] = 8; - cijk[5][5] = 0; - eijk[5][5] = 0.5; - bijk[5][5] = 2; - gijk[5][5] = 0.5; - nijk[5][5] = 4.2638000926819E-03; - dijk[5][6] = 2; - tijk[5][6] = 3.75; - cijk[5][6] = 0; - eijk[5][6] = 0.5; - bijk[5][6] = 3; - gijk[5][6] = 0.5; - nijk[5][6] = 0.17673538204534; - // Nitrogen-Ethane - dijk[6][1] = 2; - tijk[6][1] = 0; - cijk[6][1] = 0; - eijk[6][1] = 0; - bijk[6][1] = 0; - gijk[6][1] = 0; - nijk[6][1] = -0.47376518126608; - dijk[6][2] = 2; - tijk[6][2] = 0.05; - cijk[6][2] = 0; - eijk[6][2] = 0; - bijk[6][2] = 0; - gijk[6][2] = 0; - nijk[6][2] = 0.48961193461001; - dijk[6][3] = 3; - tijk[6][3] = 0; - cijk[6][3] = 0; - eijk[6][3] = 0; - bijk[6][3] = 0; - gijk[6][3] = 0; - nijk[6][3] = -5.7011062090535E-03; - dijk[6][4] = 1; - tijk[6][4] = 3.65; - cijk[6][4] = 1; - eijk[6][4] = 0.5; - bijk[6][4] = 1; - gijk[6][4] = 0.5; - nijk[6][4] = -0.1996682004132; - dijk[6][5] = 2; - tijk[6][5] = 4.9; - cijk[6][5] = 1; - eijk[6][5] = 0.5; - bijk[6][5] = 1; - gijk[6][5] = 0.5; - nijk[6][5] = -0.69411103101723; - dijk[6][6] = 2; - tijk[6][6] = 4.45; - cijk[6][6] = 0.875; - eijk[6][6] = 0.5; - bijk[6][6] = 1.25; - gijk[6][6] = 0.5; - nijk[6][6] = 0.69226192739021; - // Methane-Hydrogen - dijk[7][1] = 1; - tijk[7][1] = 2; - cijk[7][1] = 0; - eijk[7][1] = 0; - bijk[7][1] = 0; - gijk[7][1] = 0; - nijk[7][1] = -0.25157134971934; - dijk[7][2] = 3; - tijk[7][2] = -1; - cijk[7][2] = 0; - eijk[7][2] = 0; - bijk[7][2] = 0; - gijk[7][2] = 0; - nijk[7][2] = -6.2203841111983E-03; - dijk[7][3] = 3; - tijk[7][3] = 1.75; - cijk[7][3] = 0; - eijk[7][3] = 0; - bijk[7][3] = 0; - gijk[7][3] = 0; - nijk[7][3] = 0.088850315184396; - dijk[7][4] = 4; - tijk[7][4] = 1.4; - cijk[7][4] = 0; - eijk[7][4] = 0; - bijk[7][4] = 0; - gijk[7][4] = 0; - nijk[7][4] = -0.035592212573239; - // Methane-n-Butane, Methane-Isobutane, Ethane-Propane, Ethane-n-Butane, - // Ethane-Isobutane, Propane-n-Butane, Propane-Isobutane, and n-Butane-Isobutane - dijk[10][1] = 1; - tijk[10][1] = 1; - cijk[10][1] = 0; - eijk[10][1] = 0; - bijk[10][1] = 0; - gijk[10][1] = 0; - nijk[10][1] = 2.5574776844118; - dijk[10][2] = 1; - tijk[10][2] = 1.55; - cijk[10][2] = 0; - eijk[10][2] = 0; - bijk[10][2] = 0; - gijk[10][2] = 0; - nijk[10][2] = -7.9846357136353; - dijk[10][3] = 1; - tijk[10][3] = 1.7; - cijk[10][3] = 0; - eijk[10][3] = 0; - bijk[10][3] = 0; - gijk[10][3] = 0; - nijk[10][3] = 4.7859131465806; - dijk[10][4] = 2; - tijk[10][4] = 0.25; - cijk[10][4] = 0; - eijk[10][4] = 0; - bijk[10][4] = 0; - gijk[10][4] = 0; - nijk[10][4] = -0.73265392369587; - dijk[10][5] = 2; - tijk[10][5] = 1.35; - cijk[10][5] = 0; - eijk[10][5] = 0; - bijk[10][5] = 0; - gijk[10][5] = 0; - nijk[10][5] = 1.3805471345312; - dijk[10][6] = 3; - tijk[10][6] = 0; - cijk[10][6] = 0; - eijk[10][6] = 0; - bijk[10][6] = 0; - gijk[10][6] = 0; - nijk[10][6] = 0.28349603476365; - dijk[10][7] = 3; - tijk[10][7] = 1.25; - cijk[10][7] = 0; - eijk[10][7] = 0; - bijk[10][7] = 0; - gijk[10][7] = 0; - nijk[10][7] = -0.49087385940425; - dijk[10][8] = 4; - tijk[10][8] = 0; - cijk[10][8] = 0; - eijk[10][8] = 0; - bijk[10][8] = 0; - gijk[10][8] = 0; - nijk[10][8] = -0.10291888921447; - dijk[10][9] = 4; - tijk[10][9] = 0.7; - cijk[10][9] = 0; - eijk[10][9] = 0; - bijk[10][9] = 0; - gijk[10][9] = 0; - nijk[10][9] = 0.11836314681968; - dijk[10][10] = 4; - tijk[10][10] = 5.4; - cijk[10][10] = 0; - eijk[10][10] = 0; - bijk[10][10] = 0; - gijk[10][10] = 0; - nijk[10][10] = 5.5527385721943E-05; - - // Generalized parameters - fij[1][2] = 1; // Methane-Nitrogen - fij[1][3] = 1; // Methane-CO2 - fij[1][4] = 1; // Methane-Ethane - fij[1][5] = 1; // Methane-Propane - fij[2][3] = 1; // Nitrogen-CO2 - fij[2][4] = 1; // Nitrogen-Ethane - fij[1][15] = 1; // Methane-Hydrogen - fij[1][6] = 0.771035405688; // Methane-Isobutane - fij[1][7] = 1; // Methane-n-Butane - fij[4][5] = 0.13042476515; // Ethane-Propane - fij[4][6] = 0.260632376098; // Ethane-Isobutane - fij[4][7] = 0.281570073085; // Ethane-n-Butane - fij[5][6] = -0.0551609771024; // Propane-Isobutane - fij[5][7] = 0.0312572600489; // Propane-n-Butane - fij[6][7] = -0.0551240293009; // Isobutane-n-Butane - - // Model numbers for binary mixtures with no excess functions (mn=-1) - for (int i = 1; i <= MaxFlds; ++i) { - mNumb[i][i] = -1; - for (int j = i + 1; j <= MaxFlds; ++j) { - fij[j][i] = fij[i][j]; - mNumb[i][j] = -1; - mNumb[j][i] = -1; - } + for (int i = 1; i <= MaxMdl; ++i) { + for (int j = 1; j <= MaxTrmM; ++j) { + gijk[i][j] = -cijk[i][j] * Math.pow(eijk[i][j], 2) + bijk[i][j] * gijk[i][j]; + eijk[i][j] = 2 * cijk[i][j] * eijk[i][j] - bijk[i][j]; + cijk[i][j] = -cijk[i][j]; } - - // Model numbers for excess functions, 10 is for generalized equation - mNumb[1][2] = 3; - mNumb[1][3] = 4; - mNumb[1][4] = 1; - mNumb[1][5] = 2; - mNumb[1][6] = 10; - mNumb[1][7] = 10; - mNumb[1][15] = 7; - mNumb[2][3] = 5; - mNumb[2][4] = 6; - mNumb[4][5] = 10; - mNumb[4][6] = 10; - mNumb[4][7] = 10; - mNumb[5][6] = 10; - mNumb[5][7] = 10; - mNumb[6][7] = 10; - - // Ideal gas parameters - n0i[1][3] = 4.00088; - n0i[1][4] = 0.76315; - n0i[1][5] = 0.0046; - n0i[1][6] = 8.74432; - n0i[1][7] = -4.46921; - n0i[1][1] = 29.83843397; - n0i[1][2] = -15999.69151; - n0i[2][3] = 3.50031; - n0i[2][4] = 0.13732; - n0i[2][5] = -0.1466; - n0i[2][6] = 0.90066; - n0i[2][7] = 0; - n0i[2][1] = 17.56770785; - n0i[2][2] = -2801.729072; - n0i[3][3] = 3.50002; - n0i[3][4] = 2.04452; - n0i[3][5] = -1.06044; - n0i[3][6] = 2.03366; - n0i[3][7] = 0.01393; - n0i[3][1] = 20.65844696; - n0i[3][2] = -4902.171516; - n0i[4][3] = 4.00263; - n0i[4][4] = 4.33939; - n0i[4][5] = 1.23722; - n0i[4][6] = 13.1974; - n0i[4][7] = -6.01989; - n0i[4][1] = 36.73005938; - n0i[4][2] = -23639.65301; - n0i[5][3] = 4.02939; - n0i[5][4] = 6.60569; - n0i[5][5] = 3.197; - n0i[5][6] = 19.1921; - n0i[5][7] = -8.37267; - n0i[5][1] = 44.70909619; - n0i[5][2] = -31236.63551; - n0i[6][3] = 4.06714; - n0i[6][4] = 8.97575; - n0i[6][5] = 5.25156; - n0i[6][6] = 25.1423; - n0i[6][7] = 16.1388; - n0i[6][1] = 34.30180349; - n0i[6][2] = -38525.50276; - n0i[7][3] = 4.33944; - n0i[7][4] = 9.44893; - n0i[7][5] = 6.89406; - n0i[7][6] = 24.4618; - n0i[7][7] = 14.7824; - n0i[7][1] = 36.53237783; - n0i[7][2] = -38957.80933; - n0i[8][3] = 4; - n0i[8][4] = 11.7618; - n0i[8][5] = 20.1101; - n0i[8][6] = 33.1688; - n0i[8][7] = 0; - n0i[8][1] = 43.17218626; - n0i[8][2] = -51198.30946; - n0i[9][3] = 4; - n0i[9][4] = 8.95043; - n0i[9][5] = 21.836; - n0i[9][6] = 33.4032; - n0i[9][7] = 0; - n0i[9][1] = 42.67837089; - n0i[9][2] = -45215.83; - n0i[10][3] = 4; - n0i[10][4] = 11.6977; - n0i[10][5] = 26.8142; - n0i[10][6] = 38.6164; - n0i[10][7] = 0; - n0i[10][1] = 46.99717188; - n0i[10][2] = -52746.83318; - n0i[11][3] = 4; - n0i[11][4] = 13.7266; - n0i[11][5] = 30.4707; - n0i[11][6] = 43.5561; - n0i[11][7] = 0; - n0i[11][1] = 52.07631631; - n0i[11][2] = -57104.81056; - n0i[12][3] = 4; - n0i[12][4] = 15.6865; - n0i[12][5] = 33.8029; - n0i[12][6] = 48.1731; - n0i[12][7] = 0; - n0i[12][1] = 57.25830934; - n0i[12][2] = -60546.76385; - n0i[13][3] = 4; - n0i[13][4] = 18.0241; - n0i[13][5] = 38.1235; - n0i[13][6] = 53.3415; - n0i[13][7] = 0; - n0i[13][1] = 62.09646901; - n0i[13][2] = -66600.12837; - n0i[14][3] = 4; - n0i[14][4] = 21.0069; - n0i[14][5] = 43.4931; - n0i[14][6] = 58.3657; - n0i[14][7] = 0; - n0i[14][1] = 65.93909154; - n0i[14][2] = -74131.45483; - n0i[15][3] = 2.47906; - n0i[15][4] = 0.95806; - n0i[15][5] = 0.45444; - n0i[15][6] = 1.56039; - n0i[15][7] = -1.3756; - n0i[15][1] = 13.07520288; - n0i[15][2] = -5836.943696; - n0i[16][3] = 3.50146; - n0i[16][4] = 1.07558; - n0i[16][5] = 1.01334; - n0i[16][6] = 0; - n0i[16][7] = 0; - n0i[16][1] = 16.8017173; - n0i[16][2] = -2318.32269; - n0i[17][3] = 3.50055; - n0i[17][4] = 1.02865; - n0i[17][5] = 0.00493; - n0i[17][6] = 0; - n0i[17][7] = 0; - n0i[17][1] = 17.45786899; - n0i[17][2] = -2635.244116; - n0i[18][3] = 4.00392; - n0i[18][4] = 0.01059; - n0i[18][5] = 0.98763; - n0i[18][6] = 3.06904; - n0i[18][7] = 0; - n0i[18][1] = 21.57882705; - n0i[18][2] = -7766.733078; - n0i[19][3] = 4; - n0i[19][4] = 3.11942; - n0i[19][5] = 1.00243; - n0i[19][6] = 0; - n0i[19][7] = 0; - n0i[19][1] = 21.5830944; - n0i[19][2] = -6069.035869; - n0i[20][3] = 2.5; - n0i[20][4] = 0; - n0i[20][5] = 0; - n0i[20][6] = 0; - n0i[20][7] = 0; - n0i[20][1] = 10.04639507; - n0i[20][2] = -745.375; - n0i[21][3] = 2.5; - n0i[21][4] = 0; - n0i[21][5] = 0; - n0i[21][6] = 0; - n0i[21][7] = 0; - n0i[21][1] = 10.04639507; - n0i[21][2] = -745.375; - th0i[1][4] = 820.659; - th0i[1][5] = 178.41; - th0i[1][6] = 1062.82; - th0i[1][7] = 1090.53; - th0i[2][4] = 662.738; - th0i[2][5] = 680.562; - th0i[2][6] = 1740.06; - th0i[2][7] = 0; - th0i[3][4] = 919.306; - th0i[3][5] = 865.07; - th0i[3][6] = 483.553; - th0i[3][7] = 341.109; - th0i[4][4] = 559.314; - th0i[4][5] = 223.284; - th0i[4][6] = 1031.38; - th0i[4][7] = 1071.29; - th0i[5][4] = 479.856; - th0i[5][5] = 200.893; - th0i[5][6] = 955.312; - th0i[5][7] = 1027.29; - th0i[6][4] = 438.27; - th0i[6][5] = 198.018; - th0i[6][6] = 1905.02; - th0i[6][7] = 893.765; - th0i[7][4] = 468.27; - th0i[7][5] = 183.636; - th0i[7][6] = 1914.1; - th0i[7][7] = 903.185; - th0i[8][4] = 292.503; - th0i[8][5] = 910.237; - th0i[8][6] = 1919.37; - th0i[8][7] = 0; - th0i[9][4] = 178.67; - th0i[9][5] = 840.538; - th0i[9][6] = 1774.25; - th0i[9][7] = 0; - th0i[10][4] = 182.326; - th0i[10][5] = 859.207; - th0i[10][6] = 1826.59; - th0i[10][7] = 0; - th0i[11][4] = 169.789; - th0i[11][5] = 836.195; - th0i[11][6] = 1760.46; - th0i[11][7] = 0; - th0i[12][4] = 158.922; - th0i[12][5] = 815.064; - th0i[12][6] = 1693.07; - th0i[12][7] = 0; - th0i[13][4] = 156.854; - th0i[13][5] = 814.882; - th0i[13][6] = 1693.79; - th0i[13][7] = 0; - th0i[14][4] = 164.947; - th0i[14][5] = 836.264; - th0i[14][6] = 1750.24; - th0i[14][7] = 0; - th0i[15][4] = 228.734; - th0i[15][5] = 326.843; - th0i[15][6] = 1651.71; - th0i[15][7] = 1671.69; - th0i[16][4] = 2235.71; - th0i[16][5] = 1116.69; - th0i[16][6] = 0; - th0i[16][7] = 0; - th0i[17][4] = 1550.45; - th0i[17][5] = 704.525; - th0i[17][6] = 0; - th0i[17][7] = 0; - th0i[18][4] = 268.795; - th0i[18][5] = 1141.41; - th0i[18][6] = 2507.37; - th0i[18][7] = 0; - th0i[19][4] = 1833.63; - th0i[19][5] = 847.181; - th0i[19][6] = 0; - th0i[19][7] = 0; - th0i[20][4] = 0; - th0i[20][5] = 0; - th0i[20][6] = 0; - th0i[20][7] = 0; - th0i[21][4] = 0; - th0i[21][5] = 0; - th0i[21][6] = 0; - th0i[21][7] = 0; - - // Mixture parameters for reducing variables - bvij[1][2] = 0.998721377; - gvij[1][2] = 1.013950311; - btij[1][2] = 0.99809883; - gtij[1][2] = 0.979273013; // CH4-N2 - bvij[1][3] = 0.999518072; - gvij[1][3] = 1.002806594; - btij[1][3] = 1.02262449; - gtij[1][3] = 0.975665369; // CH4-CO2 - bvij[1][4] = 0.997547866; - gvij[1][4] = 1.006617867; - btij[1][4] = 0.996336508; - gtij[1][4] = 1.049707697; // CH4-C2H6 - bvij[1][5] = 1.00482707; - gvij[1][5] = 1.038470657; - btij[1][5] = 0.989680305; - gtij[1][5] = 1.098655531; // CH4-C3H8 - bvij[1][6] = 1.011240388; - gvij[1][6] = 1.054319053; - btij[1][6] = 0.980315756; - gtij[1][6] = 1.161117729; // CH4-i-C4H10 - bvij[1][7] = 0.979105972; - gvij[1][7] = 1.045375122; - btij[1][7] = 0.99417491; - gtij[1][7] = 1.171607691; // CH4-C4H10 - bvij[1][8] = 1; - gvij[1][8] = 1.343685343; - btij[1][8] = 1; - gtij[1][8] = 1.188899743; // CH4-i-C5H12 - bvij[1][9] = 0.94833012; - gvij[1][9] = 1.124508039; - btij[1][9] = 0.992127525; - gtij[1][9] = 1.249173968; // CH4-C5H12 - bvij[1][10] = 0.958015294; - gvij[1][10] = 1.052643846; - btij[1][10] = 0.981844797; - gtij[1][10] = 1.330570181; // CH4-C6H14 - bvij[1][11] = 0.962050831; - gvij[1][11] = 1.156655935; - btij[1][11] = 0.977431529; - gtij[1][11] = 1.379850328; // CH4-C7H16 - bvij[1][12] = 0.994740603; - gvij[1][12] = 1.116549372; - btij[1][12] = 0.957473785; - gtij[1][12] = 1.449245409; // CH4-C8H18 - bvij[1][13] = 1.002852287; - gvij[1][13] = 1.141895355; - btij[1][13] = 0.947716769; - gtij[1][13] = 1.528532478; // CH4-C9H20 - bvij[1][14] = 1.033086292; - gvij[1][14] = 1.146089637; - btij[1][14] = 0.937777823; - gtij[1][14] = 1.568231489; // CH4-C10H22 - bvij[1][15] = 1; - gvij[1][15] = 1.018702573; - btij[1][15] = 1; - gtij[1][15] = 1.352643115; // CH4-H2 - bvij[1][16] = 1; - gvij[1][16] = 1; - btij[1][16] = 1; - gtij[1][16] = 0.95; // CH4-O2 - bvij[1][17] = 0.997340772; - gvij[1][17] = 1.006102927; - btij[1][17] = 0.987411732; - gtij[1][17] = 0.987473033; // CH4-CO - bvij[1][18] = 1.012783169; - gvij[1][18] = 1.585018334; - btij[1][18] = 1.063333913; - gtij[1][18] = 0.775810513; // CH4-H2O - bvij[1][19] = 1.012599087; - gvij[1][19] = 1.040161207; - btij[1][19] = 1.011090031; - gtij[1][19] = 0.961155729; // CH4-H2S - bvij[1][20] = 1; - gvij[1][20] = 0.881405683; - btij[1][20] = 1; - gtij[1][20] = 3.159776855; // CH4-He - bvij[1][21] = 1.034630259; - gvij[1][21] = 1.014678542; - btij[1][21] = 0.990954281; - gtij[1][21] = 0.989843388; // CH4-Ar - bvij[2][3] = 0.977794634; - gvij[2][3] = 1.047578256; - btij[2][3] = 1.005894529; - gtij[2][3] = 1.107654104; // N2-CO2 - bvij[2][4] = 0.978880168; - gvij[2][4] = 1.042352891; - btij[2][4] = 1.007671428; - gtij[2][4] = 1.098650964; // N2-C2H6 - bvij[2][5] = 0.974424681; - gvij[2][5] = 1.081025408; - btij[2][5] = 1.002677329; - gtij[2][5] = 1.201264026; // N2-C3H8 - bvij[2][6] = 0.98641583; - gvij[2][6] = 1.100576129; - btij[2][6] = 0.99286813; - gtij[2][6] = 1.284462634; // N2-i-C4H10 - bvij[2][7] = 0.99608261; - gvij[2][7] = 1.146949309; - btij[2][7] = 0.994515234; - gtij[2][7] = 1.304886838; // N2-C4H10 - bvij[2][8] = 1; - gvij[2][8] = 1.154135439; - btij[2][8] = 1; - gtij[2][8] = 1.38177077; // N2-i-C5H12 - bvij[2][9] = 1; - gvij[2][9] = 1.078877166; - btij[2][9] = 1; - gtij[2][9] = 1.419029041; // N2-C5H12 - bvij[2][10] = 1; - gvij[2][10] = 1.195952177; - btij[2][10] = 1; - gtij[2][10] = 1.472607971; // N2-C6H14 - bvij[2][11] = 1; - gvij[2][11] = 1.40455409; - btij[2][11] = 1; - gtij[2][11] = 1.520975334; // N2-C7H16 - bvij[2][12] = 1; - gvij[2][12] = 1.186067025; - btij[2][12] = 1; - gtij[2][12] = 1.733280051; // N2-C8H18 - bvij[2][13] = 1; - gvij[2][13] = 1.100405929; - btij[2][13] = 0.95637945; - gtij[2][13] = 1.749119996; // N2-C9H20 - bvij[2][14] = 1; - gvij[2][14] = 1; - btij[2][14] = 0.957934447; - gtij[2][14] = 1.822157123; // N2-C10H22 - bvij[2][15] = 0.972532065; - gvij[2][15] = 0.970115357; - btij[2][15] = 0.946134337; - gtij[2][15] = 1.175696583; // N2-H2 - bvij[2][16] = 0.99952177; - gvij[2][16] = 0.997082328; - btij[2][16] = 0.997190589; - gtij[2][16] = 0.995157044; // N2-O2 - bvij[2][17] = 1; - gvij[2][17] = 1.008690943; - btij[2][17] = 1; - gtij[2][17] = 0.993425388; // N2-CO - bvij[2][18] = 1; - gvij[2][18] = 1.094749685; - btij[2][18] = 1; - gtij[2][18] = 0.968808467; // N2-H2O - bvij[2][19] = 0.910394249; - gvij[2][19] = 1.256844157; - btij[2][19] = 1.004692366; - gtij[2][19] = 0.9601742; // N2-H2S - bvij[2][20] = 0.969501055; - gvij[2][20] = 0.932629867; - btij[2][20] = 0.692868765; - gtij[2][20] = 1.47183158; // N2-He - bvij[2][21] = 1.004166412; - gvij[2][21] = 1.002212182; - btij[2][21] = 0.999069843; - gtij[2][21] = 0.990034831; // N2-Ar - bvij[3][4] = 1.002525718; - gvij[3][4] = 1.032876701; - btij[3][4] = 1.013871147; - gtij[3][4] = 0.90094953; // CO2-C2H6 - bvij[3][5] = 0.996898004; - gvij[3][5] = 1.047596298; - btij[3][5] = 1.033620538; - gtij[3][5] = 0.908772477; // CO2-C3H8 - bvij[3][6] = 1.076551882; - gvij[3][6] = 1.081909003; - btij[3][6] = 1.023339824; - gtij[3][6] = 0.929982936; // CO2-i-C4H10 - bvij[3][7] = 1.174760923; - gvij[3][7] = 1.222437324; - btij[3][7] = 1.018171004; - gtij[3][7] = 0.911498231; // CO2-C4H10 - bvij[3][8] = 1.060793104; - gvij[3][8] = 1.116793198; - btij[3][8] = 1.019180957; - gtij[3][8] = 0.961218039; // CO2-i-C5H12 - bvij[3][9] = 1.024311498; - gvij[3][9] = 1.068406078; - btij[3][9] = 1.027000795; - gtij[3][9] = 0.979217302; // CO2-C5H12 - bvij[3][10] = 1; - gvij[3][10] = 0.851343711; - btij[3][10] = 1; - gtij[3][10] = 1.038675574; // CO2-C6H14 - bvij[3][11] = 1.205469976; - gvij[3][11] = 1.164585914; - btij[3][11] = 1.011806317; - gtij[3][11] = 1.046169823; // CO2-C7H16 - bvij[3][12] = 1.026169373; - gvij[3][12] = 1.104043935; - btij[3][12] = 1.02969078; - gtij[3][12] = 1.074455386; // CO2-C8H18 - bvij[3][13] = 1; - gvij[3][13] = 0.973386152; - btij[3][13] = 1.00768862; - gtij[3][13] = 1.140671202; // CO2-C9H20 - bvij[3][14] = 1.000151132; - gvij[3][14] = 1.183394668; - btij[3][14] = 1.02002879; - gtij[3][14] = 1.145512213; // CO2-C10H22 - bvij[3][15] = 0.904142159; - gvij[3][15] = 1.15279255; - btij[3][15] = 0.942320195; - gtij[3][15] = 1.782924792; // CO2-H2 - bvij[3][16] = 1; - gvij[3][16] = 1; - btij[3][16] = 1; - gtij[3][16] = 1; // CO2-O2 - bvij[3][17] = 1; - gvij[3][17] = 1; - btij[3][17] = 1; - gtij[3][17] = 1; // CO2-CO - bvij[3][18] = 0.949055959; - gvij[3][18] = 1.542328793; - btij[3][18] = 0.997372205; - gtij[3][18] = 0.775453996; // CO2-H2O - bvij[3][19] = 0.906630564; - gvij[3][19] = 1.024085837; - btij[3][19] = 1.016034583; - gtij[3][19] = 0.92601888; // CO2-H2S - bvij[3][20] = 0.846647561; - gvij[3][20] = 0.864141549; - btij[3][20] = 0.76837763; - gtij[3][20] = 3.207456948; // CO2-He - bvij[3][21] = 1.008392428; - gvij[3][21] = 1.029205465; - btij[3][21] = 0.996512863; - gtij[3][21] = 1.050971635; // CO2-Ar - bvij[4][5] = 0.997607277; - gvij[4][5] = 1.00303472; - btij[4][5] = 0.996199694; - gtij[4][5] = 1.01473019; // C2H6-C3H8 - bvij[4][6] = 1; - gvij[4][6] = 1.006616886; - btij[4][6] = 1; - gtij[4][6] = 1.033283811; // C2H6-i-C4H10 - bvij[4][7] = 0.999157205; - gvij[4][7] = 1.006179146; - btij[4][7] = 0.999130554; - gtij[4][7] = 1.034832749; // C2H6-C4H10 - bvij[4][8] = 1; - gvij[4][8] = 1.045439935; - btij[4][8] = 1; - gtij[4][8] = 1.021150247; // C2H6-i-C5H12 - bvij[4][9] = 0.993851009; - gvij[4][9] = 1.026085655; - btij[4][9] = 0.998688946; - gtij[4][9] = 1.066665676; // C2H6-C5H12 - bvij[4][10] = 1; - gvij[4][10] = 1.169701102; - btij[4][10] = 1; - gtij[4][10] = 1.092177796; // C2H6-C6H14 - bvij[4][11] = 1; - gvij[4][11] = 1.057666085; - btij[4][11] = 1; - gtij[4][11] = 1.134532014; // C2H6-C7H16 - bvij[4][12] = 1.007469726; - gvij[4][12] = 1.071917985; - btij[4][12] = 0.984068272; - gtij[4][12] = 1.168636194; // C2H6-C8H18 - bvij[4][13] = 1; - gvij[4][13] = 1.14353473; - btij[4][13] = 1; - gtij[4][13] = 1.05603303; // C2H6-C9H20 - bvij[4][14] = 0.995676258; - gvij[4][14] = 1.098361281; - btij[4][14] = 0.970918061; - gtij[4][14] = 1.237191558; // C2H6-C10H22 - bvij[4][15] = 0.925367171; - gvij[4][15] = 1.10607204; - btij[4][15] = 0.932969831; - gtij[4][15] = 1.902008495; // C2H6-H2 - bvij[4][16] = 1; - gvij[4][16] = 1; - btij[4][16] = 1; - gtij[4][16] = 1; // C2H6-O2 - bvij[4][17] = 1; - gvij[4][17] = 1.201417898; - btij[4][17] = 1; - gtij[4][17] = 1.069224728; // C2H6-CO - bvij[4][18] = 1; - gvij[4][18] = 1; - btij[4][18] = 1; - gtij[4][18] = 1; // C2H6-H2O - bvij[4][19] = 1.010817909; - gvij[4][19] = 1.030988277; - btij[4][19] = 0.990197354; - gtij[4][19] = 0.90273666; // C2H6-H2S - bvij[4][20] = 1; - gvij[4][20] = 1; - btij[4][20] = 1; - gtij[4][20] = 1; // C2H6-He - bvij[4][21] = 1; - gvij[4][21] = 1; - btij[4][21] = 1; - gtij[4][21] = 1; // C2H6-Ar - bvij[5][6] = 0.999243146; - gvij[5][6] = 1.001156119; - btij[5][6] = 0.998012298; - gtij[5][6] = 1.005250774; // C3H8-i-C4H10 - bvij[5][7] = 0.999795868; - gvij[5][7] = 1.003264179; - btij[5][7] = 1.000310289; - gtij[5][7] = 1.007392782; // C3H8-C4H10 - bvij[5][8] = 1.040459289; - gvij[5][8] = 0.999432118; - btij[5][8] = 0.994364425; - gtij[5][8] = 1.0032695; // C3H8-i-C5H12 - bvij[5][9] = 1.044919431; - gvij[5][9] = 1.019921513; - btij[5][9] = 0.996484021; - gtij[5][9] = 1.008344412; // C3H8-C5H12 - bvij[5][10] = 1; - gvij[5][10] = 1.057872566; - btij[5][10] = 1; - gtij[5][10] = 1.025657518; // C3H8-C6H14 - bvij[5][11] = 1; - gvij[5][11] = 1.079648053; - btij[5][11] = 1; - gtij[5][11] = 1.050044169; // C3H8-C7H16 - bvij[5][12] = 1; - gvij[5][12] = 1.102764612; - btij[5][12] = 1; - gtij[5][12] = 1.063694129; // C3H8-C8H18 - bvij[5][13] = 1; - gvij[5][13] = 1.199769134; - btij[5][13] = 1; - gtij[5][13] = 1.109973833; // C3H8-C9H20 - bvij[5][14] = 0.984104227; - gvij[5][14] = 1.053040574; - btij[5][14] = 0.985331233; - gtij[5][14] = 1.140905252; // C3H8-C10H22 - bvij[5][15] = 1; - gvij[5][15] = 1.07400611; - btij[5][15] = 1; - gtij[5][15] = 2.308215191; // C3H8-H2 - bvij[5][16] = 1; - gvij[5][16] = 1; - btij[5][16] = 1; - gtij[5][16] = 1; // C3H8-O2 - bvij[5][17] = 1; - gvij[5][17] = 1.108143673; - btij[5][17] = 1; - gtij[5][17] = 1.197564208; // C3H8-CO - bvij[5][18] = 1; - gvij[5][18] = 1.011759763; - btij[5][18] = 1; - gtij[5][18] = 0.600340961; // C3H8-H2O - bvij[5][19] = 0.936811219; - gvij[5][19] = 1.010593999; - btij[5][19] = 0.992573556; - gtij[5][19] = 0.905829247; // C3H8-H2S - bvij[5][20] = 1; - gvij[5][20] = 1; - btij[5][20] = 1; - gtij[5][20] = 1; // C3H8-He - bvij[5][21] = 1; - gvij[5][21] = 1; - btij[5][21] = 1; - gtij[5][21] = 1; // C3H8-Ar - - // The beta values for isobutane+butane are the reciprocal values of those in the GERG-2008 - // publication because the order was reversed in this work. - bvij[6][7] = 0.999120311; - gvij[6][7] = 1.00041444; - btij[6][7] = 0.999922459; - gtij[6][7] = 1.001432824; // C4H10-i-C4H10 - - bvij[6][8] = 1; - gvij[6][8] = 1.002284353; - btij[6][8] = 1; - gtij[6][8] = 1.001835788; // i-C4H10-i-C5H1 - bvij[6][9] = 1; - gvij[6][9] = 1.002779804; - btij[6][9] = 1; - gtij[6][9] = 1.002495889; // i-C4H10-C5H12 - bvij[6][10] = 1; - gvij[6][10] = 1.010493989; - btij[6][10] = 1; - gtij[6][10] = 1.006018054; // i-C4H10-C6H14 - bvij[6][11] = 1; - gvij[6][11] = 1.021668316; - btij[6][11] = 1; - gtij[6][11] = 1.00988576; // i-C4H10-C7H16 - bvij[6][12] = 1; - gvij[6][12] = 1.032807063; - btij[6][12] = 1; - gtij[6][12] = 1.013945424; // i-C4H10-C8H18 - bvij[6][13] = 1; - gvij[6][13] = 1.047298475; - btij[6][13] = 1; - gtij[6][13] = 1.017817492; // i-C4H10-C9H20 - bvij[6][14] = 1; - gvij[6][14] = 1.060243344; - btij[6][14] = 1; - gtij[6][14] = 1.021624748; // i-C4H10-C10H22 - bvij[6][15] = 1; - gvij[6][15] = 1.147595688; - btij[6][15] = 1; - gtij[6][15] = 1.895305393; // i-C4H10-H2 - bvij[6][16] = 1; - gvij[6][16] = 1; - btij[6][16] = 1; - gtij[6][16] = 1; // i-C4H10-O2 - bvij[6][17] = 1; - gvij[6][17] = 1.087272232; - btij[6][17] = 1; - gtij[6][17] = 1.161390082; // i-C4H10-CO - bvij[6][18] = 1; - gvij[6][18] = 1; - btij[6][18] = 1; - gtij[6][18] = 1; // i-C4H10-H2O - bvij[6][19] = 1.012994431; - gvij[6][19] = 0.988591117; - btij[6][19] = 0.974550548; - gtij[6][19] = 0.937130844; // i-C4H10-H2S - bvij[6][20] = 1; - gvij[6][20] = 1; - btij[6][20] = 1; - gtij[6][20] = 1; // i-C4H10-He - bvij[6][21] = 1; - gvij[6][21] = 1; - btij[6][21] = 1; - gtij[6][21] = 1; // i-C4H10-Ar - bvij[7][8] = 1; - gvij[7][8] = 1.002728434; - btij[7][8] = 1; - gtij[7][8] = 1.000792201; // C4H10-i-C5H12 - bvij[7][9] = 1; - gvij[7][9] = 1.01815965; - btij[7][9] = 1; - gtij[7][9] = 1.00214364; // C4H10-C5H12 - bvij[7][10] = 1; - gvij[7][10] = 1.034995284; - btij[7][10] = 1; - gtij[7][10] = 1.00915706; // C4H10-C6H14 - bvij[7][11] = 1; - gvij[7][11] = 1.019174227; - btij[7][11] = 1; - gtij[7][11] = 1.021283378; // C4H10-C7H16 - bvij[7][12] = 1; - gvij[7][12] = 1.046905515; - btij[7][12] = 1; - gtij[7][12] = 1.033180106; // C4H10-C8H18 - bvij[7][13] = 1; - gvij[7][13] = 1.049219137; - btij[7][13] = 1; - gtij[7][13] = 1.014096448; // C4H10-C9H20 - bvij[7][14] = 0.976951968; - gvij[7][14] = 1.027845529; - btij[7][14] = 0.993688386; - gtij[7][14] = 1.076466918; // C4H10-C10H22 - bvij[7][15] = 1; - gvij[7][15] = 1.232939523; - btij[7][15] = 1; - gtij[7][15] = 2.509259945; // C4H10-H2 - bvij[7][16] = 1; - gvij[7][16] = 1; - btij[7][16] = 1; - gtij[7][16] = 1; // C4H10-O2 - bvij[7][17] = 1; - gvij[7][17] = 1.084740904; - btij[7][17] = 1; - gtij[7][17] = 1.173916162; // C4H10-CO - bvij[7][18] = 1; - gvij[7][18] = 1.223638763; - btij[7][18] = 1; - gtij[7][18] = 0.615512682; // C4H10-H2O - bvij[7][19] = 0.908113163; - gvij[7][19] = 1.033366041; - btij[7][19] = 0.985962886; - gtij[7][19] = 0.926156602; // C4H10-H2S - bvij[7][20] = 1; - gvij[7][20] = 1; - btij[7][20] = 1; - gtij[7][20] = 1; // C4H10-He - bvij[7][21] = 1; - gvij[7][21] = 1.214638734; - btij[7][21] = 1; - gtij[7][21] = 1.245039498; // C4H10-Ar - bvij[8][9] = 1; - gvij[8][9] = 1.000024335; - btij[8][9] = 1; - gtij[8][9] = 1.000050537; // C5H12-i-C5H12 - bvij[8][10] = 1; - gvij[8][10] = 1.002995876; - btij[8][10] = 1; - gtij[8][10] = 1.001204174; // i-C5H12-C6H14 - bvij[8][11] = 1; - gvij[8][11] = 1.009928206; - btij[8][11] = 1; - gtij[8][11] = 1.003194615; // i-C5H12-C7H16 - bvij[8][12] = 1; - gvij[8][12] = 1.017880545; - btij[8][12] = 1; - gtij[8][12] = 1.00564748; // i-C5H12-C8H18 - bvij[8][13] = 1; - gvij[8][13] = 1.028994325; - btij[8][13] = 1; - gtij[8][13] = 1.008191499; // i-C5H12-C9H20 - bvij[8][14] = 1; - gvij[8][14] = 1.039372957; - btij[8][14] = 1; - gtij[8][14] = 1.010825138; // i-C5H12-C10H22 - bvij[8][15] = 1; - gvij[8][15] = 1.184340443; - btij[8][15] = 1; - gtij[8][15] = 1.996386669; // i-C5H12-H2 - bvij[8][16] = 1; - gvij[8][16] = 1; - btij[8][16] = 1; - gtij[8][16] = 1; // i-C5H12-O2 - bvij[8][17] = 1; - gvij[8][17] = 1.116694577; - btij[8][17] = 1; - gtij[8][17] = 1.199326059; // i-C5H12-CO - bvij[8][18] = 1; - gvij[8][18] = 1; - btij[8][18] = 1; - gtij[8][18] = 1; // i-C5H12-H2O - bvij[8][19] = 1; - gvij[8][19] = 0.835763343; - btij[8][19] = 1; - gtij[8][19] = 0.982651529; // i-C5H12-H2S - bvij[8][20] = 1; - gvij[8][20] = 1; - btij[8][20] = 1; - gtij[8][20] = 1; // i-C5H12-He - bvij[8][21] = 1; - gvij[8][21] = 1; - btij[8][21] = 1; - gtij[8][21] = 1; // i-C5H12-Ar - bvij[9][10] = 1; - gvij[9][10] = 1.002480637; - btij[9][10] = 1; - gtij[9][10] = 1.000761237; // C5H12-C6H14 - bvij[9][11] = 1; - gvij[9][11] = 1.008972412; - btij[9][11] = 1; - gtij[9][11] = 1.002441051; // C5H12-C7H16 - bvij[9][12] = 1; - gvij[9][12] = 1.069223964; - btij[9][12] = 1; - gtij[9][12] = 1.016422347; // C5H12-C8H18 - bvij[9][13] = 1; - gvij[9][13] = 1.034910633; - btij[9][13] = 1; - gtij[9][13] = 1.103421755; // C5H12-C9H20 - bvij[9][14] = 1; - gvij[9][14] = 1.016370338; - btij[9][14] = 1; - gtij[9][14] = 1.049035838; // C5H12-C10H22 - bvij[9][15] = 1; - gvij[9][15] = 1.188334783; - btij[9][15] = 1; - gtij[9][15] = 2.013859174; // C5H12-H2 - bvij[9][16] = 1; - gvij[9][16] = 1; - btij[9][16] = 1; - gtij[9][16] = 1; // C5H12-O2 - bvij[9][17] = 1; - gvij[9][17] = 1.119954454; - btij[9][17] = 1; - gtij[9][17] = 1.206043295; // C5H12-CO - bvij[9][18] = 1; - gvij[9][18] = 0.95667731; - btij[9][18] = 1; - gtij[9][18] = 0.447666011; // C5H12-H2O - bvij[9][19] = 0.984613203; - gvij[9][19] = 1.076539234; - btij[9][19] = 0.962006651; - gtij[9][19] = 0.959065662; // C5H12-H2S - bvij[9][20] = 1; - gvij[9][20] = 1; - btij[9][20] = 1; - gtij[9][20] = 1; // C5H12-He - bvij[9][21] = 1; - gvij[9][21] = 1; - btij[9][21] = 1; - gtij[9][21] = 1; // C5H12-Ar - bvij[10][11] = 1; - gvij[10][11] = 1.001508227; - btij[10][11] = 1; - gtij[10][11] = 0.999762786; // C6H14-C7H16 - bvij[10][12] = 1; - gvij[10][12] = 1.006268954; - btij[10][12] = 1; - gtij[10][12] = 1.001633952; // C6H14-C8H18 - bvij[10][13] = 1; - gvij[10][13] = 1.02076168; - btij[10][13] = 1; - gtij[10][13] = 1.055369591; // C6H14-C9H20 - bvij[10][14] = 1.001516371; - gvij[10][14] = 1.013511439; - btij[10][14] = 0.99764101; - gtij[10][14] = 1.028939539; // C6H14-C10H22 - bvij[10][15] = 1; - gvij[10][15] = 1.243461678; - btij[10][15] = 1; - gtij[10][15] = 3.021197546; // C6H14-H2 - bvij[10][16] = 1; - gvij[10][16] = 1; - btij[10][16] = 1; - gtij[10][16] = 1; // C6H14-O2 - bvij[10][17] = 1; - gvij[10][17] = 1.155145836; - btij[10][17] = 1; - gtij[10][17] = 1.233272781; // C6H14-CO - bvij[10][18] = 1; - gvij[10][18] = 1.170217596; - btij[10][18] = 1; - gtij[10][18] = 0.569681333; // C6H14-H2O - bvij[10][19] = 0.754473958; - gvij[10][19] = 1.339283552; - btij[10][19] = 0.985891113; - gtij[10][19] = 0.956075596; // C6H14-H2S - bvij[10][20] = 1; - gvij[10][20] = 1; - btij[10][20] = 1; - gtij[10][20] = 1; // C6H14-He - bvij[10][21] = 1; - gvij[10][21] = 1; - btij[10][21] = 1; - gtij[10][21] = 1; // C6H14-Ar - bvij[11][12] = 1; - gvij[11][12] = 1.006767176; - btij[11][12] = 1; - gtij[11][12] = 0.998793111; // C7H16-C8H18 - bvij[11][13] = 1; - gvij[11][13] = 1.001370076; - btij[11][13] = 1; - gtij[11][13] = 1.001150096; // C7H16-C9H20 - bvij[11][14] = 1; - gvij[11][14] = 1.002972346; - btij[11][14] = 1; - gtij[11][14] = 1.002229938; // C7H16-C10H22 - bvij[11][15] = 1; - gvij[11][15] = 1.159131722; - btij[11][15] = 1; - gtij[11][15] = 3.169143057; // C7H16-H2 - bvij[11][16] = 1; - gvij[11][16] = 1; - btij[11][16] = 1; - gtij[11][16] = 1; // C7H16-O2 - bvij[11][17] = 1; - gvij[11][17] = 1.190354273; - btij[11][17] = 1; - gtij[11][17] = 1.256123503; // C7H16-CO - bvij[11][18] = 1; - gvij[11][18] = 1; - btij[11][18] = 1; - gtij[11][18] = 1; // C7H16-H2O - bvij[11][19] = 0.828967164; - gvij[11][19] = 1.087956749; - btij[11][19] = 0.988937417; - gtij[11][19] = 1.013453092; // C7H16-H2S - bvij[11][20] = 1; - gvij[11][20] = 1; - btij[11][20] = 1; - gtij[11][20] = 1; // C7H16-He - bvij[11][21] = 1; - gvij[11][21] = 1; - btij[11][21] = 1; - gtij[11][21] = 1; // C7H16-Ar - bvij[12][13] = 1; - gvij[12][13] = 1.001357085; - btij[12][13] = 1; - gtij[12][13] = 1.000235044; // C8H18-C9H20 - bvij[12][14] = 1; - gvij[12][14] = 1.002553544; - btij[12][14] = 1; - gtij[12][14] = 1.007186267; // C8H18-C10H22 - bvij[12][15] = 1; - gvij[12][15] = 1.305249405; - btij[12][15] = 1; - gtij[12][15] = 2.191555216; // C8H18-H2 - bvij[12][16] = 1; - gvij[12][16] = 1; - btij[12][16] = 1; - gtij[12][16] = 1; // C8H18-O2 - bvij[12][17] = 1; - gvij[12][17] = 1.219206702; - btij[12][17] = 1; - gtij[12][17] = 1.276565536; // C8H18-CO - bvij[12][18] = 1; - gvij[12][18] = 0.599484191; - btij[12][18] = 1; - gtij[12][18] = 0.662072469; // C8H18-H2O - bvij[12][19] = 1; - gvij[12][19] = 1; - btij[12][19] = 1; - gtij[12][19] = 1; // C8H18-H2S - bvij[12][20] = 1; - gvij[12][20] = 1; - btij[12][20] = 1; - gtij[12][20] = 1; // C8H18-He - bvij[12][21] = 1; - gvij[12][21] = 1; - btij[12][21] = 1; - gtij[12][21] = 1; // C8H18-Ar - bvij[13][14] = 1; - gvij[13][14] = 1.00081052; - btij[13][14] = 1; - gtij[13][14] = 1.000182392; // C9H20-C10H22 - bvij[13][15] = 1; - gvij[13][15] = 1.342647661; - btij[13][15] = 1; - gtij[13][15] = 2.23435404; // C9H20-H2 - bvij[13][16] = 1; - gvij[13][16] = 1; - btij[13][16] = 1; - gtij[13][16] = 1; // C9H20-O2 - bvij[13][17] = 1; - gvij[13][17] = 1.252151449; - btij[13][17] = 1; - gtij[13][17] = 1.294070556; // C9H20-CO - bvij[13][18] = 1; - gvij[13][18] = 1; - btij[13][18] = 1; - gtij[13][18] = 1; // C9H20-H2O - bvij[13][19] = 1; - gvij[13][19] = 1.082905109; - btij[13][19] = 1; - gtij[13][19] = 1.086557826; // C9H20-H2S - bvij[13][20] = 1; - gvij[13][20] = 1; - btij[13][20] = 1; - gtij[13][20] = 1; // C9H20-He - bvij[13][21] = 1; - gvij[13][21] = 1; - btij[13][21] = 1; - gtij[13][21] = 1; // C9H20-Ar - bvij[14][15] = 1.695358382; - gvij[14][15] = 1.120233729; - btij[14][15] = 1.064818089; - gtij[14][15] = 3.786003724; // C10H22-H2 - bvij[14][16] = 1; - gvij[14][16] = 1; - btij[14][16] = 1; - gtij[14][16] = 1; // C10H22-O2 - bvij[14][17] = 1; - gvij[14][17] = 0.87018496; - btij[14][17] = 1.049594632; - gtij[14][17] = 1.803567587; // C10H22-CO - bvij[14][18] = 1; - gvij[14][18] = 0.551405318; - btij[14][18] = 0.897162268; - gtij[14][18] = 0.740416402; // C10H22-H2O - bvij[14][19] = 0.975187766; - gvij[14][19] = 1.171714677; - btij[14][19] = 0.973091413; - gtij[14][19] = 1.103693489; // C10H22-H2S - bvij[14][20] = 1; - gvij[14][20] = 1; - btij[14][20] = 1; - gtij[14][20] = 1; // C10H22-He - bvij[14][21] = 1; - gvij[14][21] = 1; - btij[14][21] = 1; - gtij[14][21] = 1; // C10H22-Ar - bvij[15][16] = 1; - gvij[15][16] = 1; - btij[15][16] = 1; - gtij[15][16] = 1; // H2-O2 - bvij[15][17] = 1; - gvij[15][17] = 1.121416201; - btij[15][17] = 1; - gtij[15][17] = 1.377504607; // H2-CO - bvij[15][18] = 1; - gvij[15][18] = 1; - btij[15][18] = 1; - gtij[15][18] = 1; // H2-H2O - bvij[15][19] = 1; - gvij[15][19] = 1; - btij[15][19] = 1; - gtij[15][19] = 1; // H2-H2S - bvij[15][20] = 1; - gvij[15][20] = 1; - btij[15][20] = 1; - gtij[15][20] = 1; // H2-He - bvij[15][21] = 1; - gvij[15][21] = 1; - btij[15][21] = 1; - gtij[15][21] = 1; // H2-Ar - bvij[16][17] = 1; - gvij[16][17] = 1; - btij[16][17] = 1; - gtij[16][17] = 1; // O2-CO - bvij[16][18] = 1; - gvij[16][18] = 1.143174289; - btij[16][18] = 1; - gtij[16][18] = 0.964767932; // O2-H2O - bvij[16][19] = 1; - gvij[16][19] = 1; - btij[16][19] = 1; - gtij[16][19] = 1; // O2-H2S - bvij[16][20] = 1; - gvij[16][20] = 1; - btij[16][20] = 1; - gtij[16][20] = 1; // O2-He - bvij[16][21] = 0.999746847; - gvij[16][21] = 0.993907223; - btij[16][21] = 1.000023103; - gtij[16][21] = 0.990430423; // O2-Ar - bvij[17][18] = 1; - gvij[17][18] = 1; - btij[17][18] = 1; - gtij[17][18] = 1; // CO-H2O - bvij[17][19] = 0.795660392; - gvij[17][19] = 1.101731308; - btij[17][19] = 1.025536736; - gtij[17][19] = 1.022749748; // CO-H2S - bvij[17][20] = 1; - gvij[17][20] = 1; - btij[17][20] = 1; - gtij[17][20] = 1; // CO-He - bvij[17][21] = 1; - gvij[17][21] = 1.159720623; - btij[17][21] = 1; - gtij[17][21] = 0.954215746; // CO-Ar - bvij[18][19] = 1; - gvij[18][19] = 1.014832832; - btij[18][19] = 1; - gtij[18][19] = 0.940587083; // H2O-H2S - bvij[18][20] = 1; - gvij[18][20] = 1; - btij[18][20] = 1; - gtij[18][20] = 1; // H2O-He - bvij[18][21] = 1; - gvij[18][21] = 1.038993495; - btij[18][21] = 1; - gtij[18][21] = 1.070941866; // H2O-Ar - bvij[19][20] = 1; - gvij[19][20] = 1; - btij[19][20] = 1; - gtij[19][20] = 1; // H2S-He - bvij[19][21] = 1; - gvij[19][21] = 1; - btij[19][21] = 1; - gtij[19][21] = 1; // H2S-Ar - bvij[20][21] = 1; - gvij[20][21] = 1; - btij[20][21] = 1; - gtij[20][21] = 1; // He-Ar - - for (int i = 1; i <= MaxFlds; ++i) { - bvij[i][i] = 1; - btij[i][i] = 1; - gvij[i][i] = 1 / Dc[i]; - gtij[i][i] = Tc[i]; - for (int j = i + 1; j <= MaxFlds; ++j) { - gvij[i][j] = gvij[i][j] * bvij[i][j] * Math.pow(Vc3[i] + Vc3[j], 3); - gtij[i][j] = gtij[i][j] * btij[i][j] * Tc2[i] * Tc2[j]; - bvij[i][j] = Math.pow(bvij[i][j], 2); - btij[i][j] = Math.pow(btij[i][j], 2); - } + } + + // Ideal gas terms + T0 = 298.15; + d0 = 101.325 / RGERG / T0; + for (int i = 1; i <= MaxFlds; ++i) { + n0i[i][3] = n0i[i][3] - 1; + n0i[i][2] = n0i[i][2] + T0; + for (int j = 1; j <= 7; ++j) { + n0i[i][j] = Rsr * n0i[i][j]; } - - for (int i = 1; i <= MaxMdl; ++i) { - for (int j = 1; j <= MaxTrmM; ++j) { - gijk[i][j] = -cijk[i][j] * Math.pow(eijk[i][j], 2) + bijk[i][j] * gijk[i][j]; - eijk[i][j] = 2 * cijk[i][j] * eijk[i][j] - bijk[i][j]; - cijk[i][j] = -cijk[i][j]; - } - } - - // Ideal gas terms - T0 = 298.15; - d0 = 101.325 / RGERG / T0; - for (int i = 1; i <= MaxFlds; ++i) { - n0i[i][3] = n0i[i][3] - 1; - n0i[i][2] = n0i[i][2] + T0; - for (int j = 1; j <= 7; ++j) { - n0i[i][j] = Rsr * n0i[i][j]; - } - n0i[i][2] = n0i[i][2] - T0; - n0i[i][1] = n0i[i][1] - Math.log(d0); - } - return; - - // Code to produce nearly exact values for n0(1) and n0(2) - // This is not called in the current code, but included below to show how the values were - // calculated. The return above can be removed to call this code. - // T0 = 298.15; - // d0 = 101.325 / RGERG / T0; - // for (int i = 1; i <= MaxFlds; ++i){ - // n1 = 0; n2 = 0; - // if (th0i[i][4] > epsilon) { n2 += - n0i[i][4] * th0i[i][4] / Tanh(th0i[i][4] / T0); n1 += - // - n0i[i][4] * log(Sinh(th0i[i][4] / T0)); } - // if (th0i[i][5] > epsilon) { n2 += + n0i[i][5] * th0i[i][5] * Tanh(th0i[i][5] / T0); n1 += - // + n0i[i][5] * log(Cosh(th0i[i][5] / T0)); } - // if (th0i[i][6] > epsilon) { n2 += - n0i[i][6] * th0i[i][6] / Tanh(th0i[i][6] / T0); n1 += - // - n0i[i][6] * log(Sinh(th0i[i][6] / T0)); } - // if (th0i[i][7] > epsilon) { n2 += + n0i[i][7] * th0i[i][7] * Tanh(th0i[i][7] / T0); n1 += - // + n0i[i][7] * log(Cosh(th0i[i][7] / T0)); } - // n0i[i][3] = n0i[i][3] - 1; - // n0i[i][1] = n1 - n2 / T0 + n0i[i][3] * (1 + log(T0)); - // n0i[i][2] = n2 - n0i[i][3] * T0; - // for (int j = 1; j <= 7; ++j){ - // n0i[i][j] = Rsr * n0i[i][j]; - // } - // n0i[i][2] = n0i[i][2] - T0; - // n0i[i][1] = n0i[i][1] - log(d0); - // } + n0i[i][2] = n0i[i][2] - T0; + n0i[i][1] = n0i[i][1] - Math.log(d0); + } + return; + + // Code to produce nearly exact values for n0(1) and n0(2) + // This is not called in the current code, but included below to show how the values were + // calculated. The return above can be removed to call this code. + // T0 = 298.15; + // d0 = 101.325 / RGERG / T0; + // for (int i = 1; i <= MaxFlds; ++i){ + // n1 = 0; n2 = 0; + // if (th0i[i][4] > epsilon) { n2 += - n0i[i][4] * th0i[i][4] / Tanh(th0i[i][4] / T0); n1 += + // - n0i[i][4] * log(Sinh(th0i[i][4] / T0)); } + // if (th0i[i][5] > epsilon) { n2 += + n0i[i][5] * th0i[i][5] * Tanh(th0i[i][5] / T0); n1 += + // + n0i[i][5] * log(Cosh(th0i[i][5] / T0)); } + // if (th0i[i][6] > epsilon) { n2 += - n0i[i][6] * th0i[i][6] / Tanh(th0i[i][6] / T0); n1 += + // - n0i[i][6] * log(Sinh(th0i[i][6] / T0)); } + // if (th0i[i][7] > epsilon) { n2 += + n0i[i][7] * th0i[i][7] * Tanh(th0i[i][7] / T0); n1 += + // + n0i[i][7] * log(Cosh(th0i[i][7] / T0)); } + // n0i[i][3] = n0i[i][3] - 1; + // n0i[i][1] = n1 - n2 / T0 + n0i[i][3] * (1 + log(T0)); + // n0i[i][2] = n2 - n0i[i][3] * T0; + // for (int j = 1; j <= 7; ++j){ + // n0i[i][j] = Rsr * n0i[i][j]; + // } + // n0i[i][2] = n0i[i][2] - T0; + // n0i[i][1] = n0i[i][1] - log(d0); + // } } /** @@ -3186,42 +3233,51 @@ public static void SetupGERG() { */ @SuppressWarnings("unused") public static void main(String[] args) { - GERG2008 test = new GERG2008(); - GERG2008.SetupGERG(); - - double T = 400; - doubleW D = new doubleW(12.79828626082062); - doubleW P = new doubleW(50000.0d); - intW ierr = new intW(0); - doubleW Mm = new doubleW(0.0d); - doubleW Z = new doubleW(0.0d); - int iFlag = 0; - StringW herr = new StringW(""); - - double x[] = {0.0, 0.77824, 0.02, 0.06, 0.08, 0.03, 0.0015, 0.003, 0.0005, 0.00165, 0.00215, - 0.00088, 0.00024, 0.00015, 0.00009, 0.004, 0.005, 0.002, 0.0001, 0.0025, 0.007, - 0.001}; - - GERG2008.MolarMassGERG(x, Mm); - - System.out.println("mol mass " + Mm.val); - - GERG2008.PressureGERG(T, D.val, x, P, Z); - - System.out.println("pressure " + P.val); - System.out.println("Z " + Z.val); - - GERG2008.DensityGERG(iFlag, T, P.val, x, D, ierr, herr); - System.out.println("density " + D.val); - - doubleW dPdD = new doubleW(0.0d), d2PdD2 = new doubleW(0.0d), d2PdTD = new doubleW(0.0d), - dPdT = new doubleW(0.0d), U = new doubleW(0.0d), H = new doubleW(0.0d), - S = new doubleW(0.0d), A = new doubleW(0.0d), P2 = new doubleW(0.0d); - doubleW Cv = new doubleW(0.0d), Cp = new doubleW(0.0d), W = new doubleW(0.0d), - G = new doubleW(0.0d), JT = new doubleW(0.0d), Kappa = new doubleW(0.0d), - PP = new doubleW(0.0d); - - GERG2008.PropertiesGERG(T, D.val, x, P, Z, dPdD, d2PdD2, d2PdTD, dPdT, U, H, S, Cv, Cp, W, + GERG2008 test = new GERG2008(); + GERG2008.SetupGERG(); + + double T = 400; + doubleW D = new doubleW(12.79828626082062); + doubleW P = new doubleW(50000.0d); + intW ierr = new intW(0); + doubleW Mm = new doubleW(0.0d); + doubleW Z = new doubleW(0.0d); + int iFlag = 0; + StringW herr = new StringW(""); + + double[] x = {0.0, 0.77824, 0.02, 0.06, 0.08, 0.03, 0.0015, 0.003, 0.0005, 0.00165, 0.00215, + 0.00088, 0.00024, 0.00015, 0.00009, 0.004, 0.005, 0.002, 0.0001, 0.0025, 0.007, 0.001}; + + GERG2008.MolarMassGERG(x, Mm); + + System.out.println("mol mass " + Mm.val); + + GERG2008.PressureGERG(T, D.val, x, P, Z); + + System.out.println("pressure " + P.val); + System.out.println("Z " + Z.val); + + GERG2008.DensityGERG(iFlag, T, P.val, x, D, ierr, herr); + System.out.println("density " + D.val); + + doubleW dPdD = new doubleW(0.0d); + doubleW d2PdD2 = new doubleW(0.0d); + doubleW d2PdTD = new doubleW(0.0d); + doubleW dPdT = new doubleW(0.0d); + doubleW U = new doubleW(0.0d); + doubleW H = new doubleW(0.0d); + doubleW S = new doubleW(0.0d); + doubleW A = new doubleW(0.0d); + doubleW P2 = new doubleW(0.0d); + doubleW Cv = new doubleW(0.0d); + + doubleW Cp = new doubleW(0.0d); + doubleW W = new doubleW(0.0d); + doubleW G = new doubleW(0.0d); + doubleW JT = new doubleW(0.0d); + doubleW Kappa = new doubleW(0.0d); + doubleW PP = new doubleW(0.0d); + GERG2008.PropertiesGERG(T, D.val, x, P, Z, dPdD, d2PdD2, d2PdTD, dPdT, U, H, S, Cv, Cp, W, G, JT, Kappa, A); /* diff --git a/src/main/java/neqsim/thermo/util/constants/FurstElectrolyteConstants.java b/src/main/java/neqsim/thermo/util/constants/FurstElectrolyteConstants.java index 6047490b19..b5d7a40ecc 100644 --- a/src/main/java/neqsim/thermo/util/constants/FurstElectrolyteConstants.java +++ b/src/main/java/neqsim/thermo/util/constants/FurstElectrolyteConstants.java @@ -33,7 +33,7 @@ public class FurstElectrolyteConstants implements java.io.Serializable { //// public static double[] furstParams = {8.717E-8, 8.309E-6, 2.435E-5, // 2.024E-4, -5.757E-8, -5.693E-5}; // public static double[] furstParams = {9.8647e-8, 6.9638e-6, 7.713e-5, - // -2.501e-5, -5.813E-8, -4.447E-5};;//{9.8647e-8, 6.9638e-6, 7.713E-5, + // -2.501e-5, -5.813E-8, -4.447E-5};; //{9.8647e-8, 6.9638e-6, 7.713E-5, // -2.501E-5, -5.813E-8, -4.447E-5}; // public static double[] furstParams = {9.463E-8, 6.694E-6, -1.021E-5, // 4.137E-4, -5.172E-8, -5.832E-5}; diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/Procede/CO2WaterMDEA/TestIonicInteractionParameterFitting_CO2.java b/src/main/java/neqsim/thermo/util/parameterFitting/Procede/CO2WaterMDEA/TestIonicInteractionParameterFitting_CO2.java index a1cd227e47..dc3cfeaf4e 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/Procede/CO2WaterMDEA/TestIonicInteractionParameterFitting_CO2.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/Procede/CO2WaterMDEA/TestIonicInteractionParameterFitting_CO2.java @@ -29,8 +29,14 @@ public class TestIonicInteractionParameterFitting_CO2 { public static void main(String[] args) { LevenbergMarquardt optim = new LevenbergMarquardt(); ArrayList sampleList = new ArrayList(); - double ID, pressure, temperature, x1, x2, x3, loading; - + double ID; + + double pressure; + double temperature; + double x1; + double x2; + double x3; + double loading; // inserting samples from database NeqSimDataBase database = new NeqSimDataBase(); ResultSet dataSet = database.getResultSet("SELECT * FROM CO2WaterMDEA WHERE ID<231"); @@ -40,21 +46,23 @@ public static void main(String[] args) { // double guess[] = {0.0004463876, -0.0001475081, 0.0021294606, 0.0002761438, // -0.0003450177}; //Detailed reactions, no data for 75 wt% MDEA or temp > 400K, // more iterations - double guess[] = {-0.0001660156, -0.0006035675, -0.0000068587, -0.0002164970};// ,0.0005}; - // //Detailed - // reactions, - // no data for - // 75 wt% - // MDEA or - // temp > 400K - // or - // loading < - // 0.1 and - // bias = -4% - // and AAD = - // 18% for - // loading - // >0.1 + double[] guess = {-0.0001660156, -0.0006035675, -0.0000068587, -0.0002164970}; // ,0.0005}; + // //Detailed + // reactions, + // no data + // for + // 75 wt% + // MDEA or + // temp > + // 400K + // or + // loading < + // 0.1 and + // bias = -4% + // and AAD = + // 18% for + // loading + // >0.1 // double guess[] = {0.0004164151, 0.0002034767, 0.0018993447, 0.0022461592, // -0.0008412103}; //Detailed reactions, no data for 75 wt% MDEA or temp > 400K // or loading > 0.1 bias of -7% and AAD= 27% for loading<0.1 @@ -67,174 +75,170 @@ public static void main(String[] args) { // double guess[] = {1e-10, 1e-10, 1e-10, 1e-10, 1e-10}; //Debye - Huckle type // equation try { - int i = 0; - logger.info("adding...."); - while (dataSet.next()) { - i++; - IonicInteractionParameterFittingFunction_CO2 function = - new IonicInteractionParameterFittingFunction_CO2(); - function.setInitialGuess(guess); - - ID = Integer.parseInt(dataSet.getString("ID")); - pressure = Double.parseDouble(dataSet.getString("PressureCO2")); - temperature = Double.parseDouble(dataSet.getString("Temperature")); - x1 = Double.parseDouble(dataSet.getString("x1")); - x2 = Double.parseDouble(dataSet.getString("x2")); - x3 = Double.parseDouble(dataSet.getString("x3")); - - loading = x1 / x3; - - // if(loading <= 0.1) continue; - - if ((ID > 56 && ID < 64) || (ID > 92 && ID < 101) || (ID > 123 && ID < 131)) { // 75 - // wt% - // amine - continue; - } - if (ID == 155) { - continue; // AAD >100 - } - if (ID == 29 || ID == 28 || ID == 258) { - continue; // large values of Pexp/Pcalc - } - if (temperature > 400) { // Since Wij are assumed to be temp. independent, higher - // temp. are neglected - continue; - } - - SystemInterface testSystem = - new SystemFurstElectrolyteEos(temperature, 1.5 * pressure); - testSystem.addComponent("CO2", x1); - testSystem.addComponent("MDEA", x3); - testSystem.addComponent("water", x2); - - logger.info("...........ID............." + ID); - - testSystem.chemicalReactionInit(); - testSystem.createDatabase(true); - testSystem.setMixingRule(4); - testSystem.init(0); - - double sample1[] = {loading}; - double standardDeviation1[] = {0.1}; - double stddev = (pressure / 100.0); - SampleValue sample = - new SampleValue((pressure), stddev, sample1, standardDeviation1); - - sample.setFunction(function); - sample.setReference(Double.toString(ID)); - sample.setThermodynamicSystem(testSystem); - sampleList.add(sample); + int i = 0; + logger.info("adding...."); + while (dataSet.next()) { + i++; + IonicInteractionParameterFittingFunction_CO2 function = + new IonicInteractionParameterFittingFunction_CO2(); + function.setInitialGuess(guess); + + ID = Integer.parseInt(dataSet.getString("ID")); + pressure = Double.parseDouble(dataSet.getString("PressureCO2")); + temperature = Double.parseDouble(dataSet.getString("Temperature")); + x1 = Double.parseDouble(dataSet.getString("x1")); + x2 = Double.parseDouble(dataSet.getString("x2")); + x3 = Double.parseDouble(dataSet.getString("x3")); + + loading = x1 / x3; + + // if(loading <= 0.1) continue; + + if ((ID > 56 && ID < 64) || (ID > 92 && ID < 101) || (ID > 123 && ID < 131)) { // 75 + // wt% + // amine + continue; } + if (ID == 155) { + continue; // AAD >100 + } + if (ID == 29 || ID == 28 || ID == 258) { + continue; // large values of Pexp/Pcalc + } + if (temperature > 400) { // Since Wij are assumed to be temp. independent, higher + // temp. are neglected + continue; + } + + SystemInterface testSystem = new SystemFurstElectrolyteEos(temperature, 1.5 * pressure); + testSystem.addComponent("CO2", x1); + testSystem.addComponent("MDEA", x3); + testSystem.addComponent("water", x2); + + logger.info("...........ID............." + ID); + + testSystem.chemicalReactionInit(); + testSystem.createDatabase(true); + testSystem.setMixingRule(4); + testSystem.init(0); + + double[] sample1 = {loading}; + double[] standardDeviation1 = {0.1}; + double stddev = (pressure / 100.0); + SampleValue sample = new SampleValue((pressure), stddev, sample1, standardDeviation1); + + sample.setFunction(function); + sample.setReference(Double.toString(ID)); + sample.setThermodynamicSystem(testSystem); + sampleList.add(sample); + } } catch (Exception e) { - logger.error("database error" + e); + logger.error("database error" + e); } dataSet = database.getResultSet("SELECT * FROM CO2WaterMDEA WHERE ID>230"); try { - int i = 0; - - logger.info("adding...."); - while (dataSet.next()) { - i++; - - IonicInteractionParameterFittingFunction_CO2 function = - new IonicInteractionParameterFittingFunction_CO2(1, 1); - function.setInitialGuess(guess); - - ID = Integer.parseInt(dataSet.getString("ID")); - pressure = Double.parseDouble(dataSet.getString("Pressure")); - temperature = Double.parseDouble(dataSet.getString("Temperature")); - x1 = Double.parseDouble(dataSet.getString("x1")); - x2 = Double.parseDouble(dataSet.getString("x2")); - x3 = Double.parseDouble(dataSet.getString("x3")); - - loading = x1 / x3; - // if(loading <= 0.1) continue; - - SystemInterface testSystem = new SystemFurstElectrolyteEos(temperature, pressure); - testSystem.addComponent("CO2", x1); - testSystem.addComponent("water", x2); - testSystem.addComponent("MDEA", x3); - logger.info("...........ID............." + ID); - - if (ID == 294 || ID == 295) { - continue; // convergence problem - } - if (ID > 235 && ID < 244) { - continue; // large error - } - if (ID > 246 && ID < 252) { - continue; // large error - } - if (ID == 258 || ID == 322) { - continue; - } - if (ID == 328 || ID == 329 || (ID > 332 && ID < 339)) { - continue; - } - if (temperature > 400) { // Since Wij are assumed to be temp. independent, higher - // temp. are neglected - continue; - } - - testSystem.chemicalReactionInit(); - testSystem.createDatabase(true); - testSystem.setMixingRule(4); - testSystem.init(0); - - double sample1[] = {loading}; - double standardDeviation1[] = {0.1}; - double stddev = (pressure / 100.0); - SampleValue sample = - new SampleValue((pressure), stddev, sample1, standardDeviation1); - - sample.setFunction(function); - sample.setReference(Double.toString(ID)); - sample.setThermodynamicSystem(testSystem); - sampleList.add(sample); + int i = 0; + + logger.info("adding...."); + while (dataSet.next()) { + i++; + + IonicInteractionParameterFittingFunction_CO2 function = + new IonicInteractionParameterFittingFunction_CO2(1, 1); + function.setInitialGuess(guess); + + ID = Integer.parseInt(dataSet.getString("ID")); + pressure = Double.parseDouble(dataSet.getString("Pressure")); + temperature = Double.parseDouble(dataSet.getString("Temperature")); + x1 = Double.parseDouble(dataSet.getString("x1")); + x2 = Double.parseDouble(dataSet.getString("x2")); + x3 = Double.parseDouble(dataSet.getString("x3")); + + loading = x1 / x3; + // if(loading <= 0.1) continue; + + SystemInterface testSystem = new SystemFurstElectrolyteEos(temperature, pressure); + testSystem.addComponent("CO2", x1); + testSystem.addComponent("water", x2); + testSystem.addComponent("MDEA", x3); + logger.info("...........ID............." + ID); + + if (ID == 294 || ID == 295) { + continue; // convergence problem + } + if (ID > 235 && ID < 244) { + continue; // large error + } + if (ID > 246 && ID < 252) { + continue; // large error + } + if (ID == 258 || ID == 322) { + continue; } + if (ID == 328 || ID == 329 || (ID > 332 && ID < 339)) { + continue; + } + if (temperature > 400) { // Since Wij are assumed to be temp. independent, higher + // temp. are neglected + continue; + } + + testSystem.chemicalReactionInit(); + testSystem.createDatabase(true); + testSystem.setMixingRule(4); + testSystem.init(0); + + double[] sample1 = {loading}; + double[] standardDeviation1 = {0.1}; + double stddev = (pressure / 100.0); + SampleValue sample = new SampleValue((pressure), stddev, sample1, standardDeviation1); + + sample.setFunction(function); + sample.setReference(Double.toString(ID)); + sample.setThermodynamicSystem(testSystem); + sampleList.add(sample); + } } catch (Exception e) { - logger.error("database error" + e); + logger.error("database error" + e); } dataSet = database.getResultSet("SELECT * FROM CO2WaterMDEAtest"); try { - int i = 0; - logger.info("adding...."); - while (dataSet.next()) { - i++; - IonicInteractionParameterFittingFunction_CO2 function = - new IonicInteractionParameterFittingFunction_CO2(); - function.setInitialGuess(guess); - - ID = Integer.parseInt(dataSet.getString("ID")); - pressure = Double.parseDouble(dataSet.getString("PressureCO2")); - temperature = Double.parseDouble(dataSet.getString("Temperature")); - x1 = Double.parseDouble(dataSet.getString("x1")); - x2 = Double.parseDouble(dataSet.getString("x2")); - x3 = Double.parseDouble(dataSet.getString("x3")); - - loading = x1 / x3; - // if(loading <= 0.1) continue; - - SystemInterface testSystem = - new SystemFurstElectrolyteEos(temperature, 1.5 * pressure); - testSystem.addComponent("CO2", x1); - testSystem.addComponent("MDEA", x3); - testSystem.addComponent("water", x2); - - logger.info("...........ID............." + ID); - - testSystem.chemicalReactionInit(); - testSystem.createDatabase(true); - testSystem.setMixingRule(4); - testSystem.init(0); - - double sample1[] = {loading}; - double standardDeviation1[] = {0.1}; + int i = 0; + logger.info("adding...."); + while (dataSet.next()) { + i++; + IonicInteractionParameterFittingFunction_CO2 function = + new IonicInteractionParameterFittingFunction_CO2(); + function.setInitialGuess(guess); + + ID = Integer.parseInt(dataSet.getString("ID")); + pressure = Double.parseDouble(dataSet.getString("PressureCO2")); + temperature = Double.parseDouble(dataSet.getString("Temperature")); + x1 = Double.parseDouble(dataSet.getString("x1")); + x2 = Double.parseDouble(dataSet.getString("x2")); + x3 = Double.parseDouble(dataSet.getString("x3")); + + loading = x1 / x3; + // if(loading <= 0.1) continue; + + SystemInterface testSystem = new SystemFurstElectrolyteEos(temperature, 1.5 * pressure); + testSystem.addComponent("CO2", x1); + testSystem.addComponent("MDEA", x3); + testSystem.addComponent("water", x2); + + logger.info("...........ID............." + ID); + + testSystem.chemicalReactionInit(); + testSystem.createDatabase(true); + testSystem.setMixingRule(4); + testSystem.init(0); + + double[] sample1 = {loading}; + double[] standardDeviation1 = {0.1}; double stddev = (pressure / 100.0); SampleValue sample = new SampleValue((pressure), stddev, sample1, standardDeviation1); diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/Procede/WaterMDEA/BinaryHVParameterFittingFunction_MDEA.java b/src/main/java/neqsim/thermo/util/parameterFitting/Procede/WaterMDEA/BinaryHVParameterFittingFunction_MDEA.java index bd430fb8ca..4bb18f3045 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/Procede/WaterMDEA/BinaryHVParameterFittingFunction_MDEA.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/Procede/WaterMDEA/BinaryHVParameterFittingFunction_MDEA.java @@ -15,133 +15,139 @@ * @version $Id: $Id */ public class BinaryHVParameterFittingFunction_MDEA extends LevenbergMarquardtFunction { - int type = 0; - int phase = 0; - static Logger logger = LogManager.getLogger(BinaryHVParameterFittingFunction_MDEA.class); - - /** - *

- * Constructor for BinaryHVParameterFittingFunction_MDEA. - *

- */ - public BinaryHVParameterFittingFunction_MDEA() {} - - /** - *

- * Constructor for BinaryHVParameterFittingFunction_MDEA. - *

- * - * @param phase a int - * @param type a int - */ - public BinaryHVParameterFittingFunction_MDEA(int phase, int type) { - this.phase = phase; - this.type = type; + int type = 0; + int phase = 0; + static Logger logger = LogManager.getLogger(BinaryHVParameterFittingFunction_MDEA.class); + + /** + *

+ * Constructor for BinaryHVParameterFittingFunction_MDEA. + *

+ */ + public BinaryHVParameterFittingFunction_MDEA() {} + + /** + *

+ * Constructor for BinaryHVParameterFittingFunction_MDEA. + *

+ * + * @param phase a int + * @param type a int + */ + public BinaryHVParameterFittingFunction_MDEA(int phase, int type) { + this.phase = phase; + this.type = type; + } + + /** {@inheritDoc} */ + @Override + public double calcValue(double[] dependentValues) { + double aMDEAold; + + double aWaterold; + double aMDEAnew; + double aWaternew; + double daMDEAdT; + double daWaterdT; + double H; + if (type == 0) { + try { + thermoOps.bubblePointPressureFlash(false); + } catch (Exception e) { + logger.error(e.toString()); + } + return (system.getPressure()); // *system.getPhases()[0].getComponent(0).getx()); + } + + if (type == 1) { + system.init(0); + system.init(1); + return system.getPhases()[1].getActivityCoefficient(0); + } + + if (type == 2) { + system.init(0); + system.init(1); + aMDEAold = system.getPhase(1).getActivityCoefficient(1); + aWaterold = system.getPhase(1).getActivityCoefficient(0); + system.setTemperature(system.getTemperature() + 0.00001); + system.init(0); + system.init(1); + aMDEAnew = system.getPhase(1).getActivityCoefficient(1); + aWaternew = system.getPhase(1).getActivityCoefficient(0); + daMDEAdT = (Math.log(aMDEAnew) - Math.log(aMDEAold)) / 0.00001; + daWaterdT = (Math.log(aWaternew) - Math.log(aWaterold)) / 0.00001; + system.setTemperature(system.getTemperature() - 0.00001); + H = -8.314 * system.getTemperature() * system.getTemperature() + * (system.getPhase(1).getComponent(0).getx() * daWaterdT + + system.getPhase(1).getComponent(1).getx() * daMDEAdT); + return H; + } + + if (type == 3) { + system.init(0); + system.init(1); + return system.getPhase(1).getActivityCoefficient(0); // system.getPhase(0).getComponent(0).getFugacityCoefficient(); } - /** {@inheritDoc} */ - @Override - public double calcValue(double[] dependentValues) { - double aMDEAold, aWaterold, aMDEAnew, aWaternew, daMDEAdT, daWaterdT, H; - - if (type == 0) { - try { - thermoOps.bubblePointPressureFlash(false); - } catch (Exception e) { - logger.error(e.toString()); - } - return (system.getPressure());// *system.getPhases()[0].getComponent(0).getx()); - } - - if (type == 1) { - system.init(0); - system.init(1); - return system.getPhases()[1].getActivityCoefficient(0); - } - - if (type == 2) { - system.init(0); - system.init(1); - aMDEAold = system.getPhase(1).getActivityCoefficient(1); - aWaterold = system.getPhase(1).getActivityCoefficient(0); - system.setTemperature(system.getTemperature() + 0.00001); - system.init(0); - system.init(1); - aMDEAnew = system.getPhase(1).getActivityCoefficient(1); - aWaternew = system.getPhase(1).getActivityCoefficient(0); - daMDEAdT = (Math.log(aMDEAnew) - Math.log(aMDEAold)) / 0.00001; - daWaterdT = (Math.log(aWaternew) - Math.log(aWaterold)) / 0.00001; - system.setTemperature(system.getTemperature() - 0.00001); - H = -8.314 * system.getTemperature() * system.getTemperature() - * (system.getPhase(1).getComponent(0).getx() * daWaterdT - + system.getPhase(1).getComponent(1).getx() * daMDEAdT); - return H; - } - - if (type == 3) { - system.init(0); - system.init(1); - return system.getPhase(1).getActivityCoefficient(0);// system.getPhase(0).getComponent(0).getFugacityCoefficient(); - } - - if (type == 4) { - system.init(0); - system.init(1); - return system.getPhase(1).getActivityCoefficient(1);// system.getPhase(0).getComponent(0).getFugacityCoefficient(); - } - - return (0); + if (type == 4) { + system.init(0); + system.init(1); + return system.getPhase(1).getActivityCoefficient(1); // system.getPhase(0).getComponent(0).getFugacityCoefficient(); } - /** {@inheritDoc} */ - @Override - public double calcTrueValue(double val) { - return (val); + return (0); + } + + /** {@inheritDoc} */ + @Override + public double calcTrueValue(double val) { + return (val); + } + + /** {@inheritDoc} */ + @Override + public void setFittingParams(int i, double value) { + params[i] = value; + + /* + * ((PhaseEosInterface)system.getPhases()[0]).getMixingRule(). + * setBinaryInteractionParameter(0,1, value); + * ((PhaseEosInterface)system.getPhases()[1]).getMixingRule(). + * setBinaryInteractionParameter(0,1, value); + */ + + if (i == 0) { + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) + .setHVDijParameter(0, 1, value); + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) + .setHVDijParameter(0, 1, value); + } + if (i == 1) { + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) + .setHVDijParameter(1, 0, value); + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) + .setHVDijParameter(1, 0, value); } - /** {@inheritDoc} */ - @Override - public void setFittingParams(int i, double value) { - params[i] = value; - - /* - * ((PhaseEosInterface)system.getPhases()[0]).getMixingRule(). - * setBinaryInteractionParameter(0,1, value); - * ((PhaseEosInterface)system.getPhases()[1]).getMixingRule(). - * setBinaryInteractionParameter(0,1, value); - */ - - if (i == 0) { - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) - .setHVDijParameter(0, 1, value); - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) - .setHVDijParameter(0, 1, value); - } - if (i == 1) { - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) - .setHVDijParameter(1, 0, value); - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) - .setHVDijParameter(1, 0, value); - } - - if (i == 4) { - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) - .setHValphaParameter(0, 1, value); - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) - .setHValphaParameter(0, 1, value); - } - - if (i == 2) { - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) - .setHVDijTParameter(0, 1, value); - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) - .setHVDijTParameter(0, 1, value); - } - if (i == 3) { - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) - .setHVDijTParameter(1, 0, value); - ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) - .setHVDijTParameter(1, 0, value); - } + if (i == 4) { + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) + .setHValphaParameter(0, 1, value); + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) + .setHValphaParameter(0, 1, value); + } + + if (i == 2) { + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) + .setHVDijTParameter(0, 1, value); + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) + .setHVDijTParameter(0, 1, value); + } + if (i == 3) { + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[0]).getMixingRule()) + .setHVDijTParameter(1, 0, value); + ((HVmixingRuleInterface) ((PhaseEosInterface) system.getPhases()[1]).getMixingRule()) + .setHVDijTParameter(1, 0, value); } + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestBinaryCPAfitToActivityCoefficientDB.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestBinaryCPAfitToActivityCoefficientDB.java index c20ad1cc2c..1a82b604d6 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestBinaryCPAfitToActivityCoefficientDB.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestBinaryCPAfitToActivityCoefficientDB.java @@ -64,8 +64,8 @@ public static void main(String[] args) { // function.setDatabaseParameters(); // double guess[] = {-1466.3924707953, 1197.4327552750, 5.9188456398, // -7.2410712156, 0.2127650110}; - double guess[] = {-0.241488376, -0.344136439, 0.0004315217};// ,0.02};//, - // -55};//,-30}; + double guess[] = {-0.241488376, -0.344136439, 0.0004315217}; // ,0.02}; //, + // -55}; //,-30}; function.setInitialGuess(guess); sampleList.add(sample); diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityData.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityData.java index a38f95d3dd..6f5821435d 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityData.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityData.java @@ -40,7 +40,7 @@ public static void main(String[] args) { // ResultSet dataSet = database.getResultSet( "SELECT * FROM // binarysolubilitydata WHERE ComponentSolute='methane' AND // ComponentSolvent='water' AND Temperature>278.0 AND Temperature<350.0"); - double parameterGuess[] = {-0.27686, 0.001121};// , 0.000117974}; //cpa + double parameterGuess[] = {-0.27686, 0.001121}; // , 0.000117974}; //cpa try { int p = 0; diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityData_Lucia.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityData_Lucia.java index 78e2fabf28..f632b68f40 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityData_Lucia.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityData_Lucia.java @@ -36,7 +36,7 @@ public static void main(String[] args) { // inserting samples from database NeqSimDataBase database = new NeqSimDataBase(); ResultSet dataSet = database.getResultSet( - "SELECT * FROM luciadata8 WHERE Component='methane' AND Temperature>410.15 AND Pressure<100000000 AND L2<>NULL AND L2>0.00000001 ORDER BY Temperature,Pressure");// AND + "SELECT * FROM luciadata8 WHERE Component='methane' AND Temperature>410.15 AND Pressure<100000000 AND L2<>NULL AND L2>0.00000001 ORDER BY Temperature,Pressure"); // AND // Reference='Houghton1957' // AND // Reference<>'Nighswander1989' @@ -87,7 +87,7 @@ public static void main(String[] args) { double sdev = val / 100.0; SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); sample.setFunction(function); - sample.setThermodynamicSystem(testSystem);// 34.7 + sample.setThermodynamicSystem(testSystem); // 34.7 sample.setReference(Double.toString(testSystem.getTemperature())); // double parameterGuess[] = {0.05155112588}; //srk double parameterGuess[] = {0.0459393339}; // cpa-srk- metan 23.658199 abs dev bias @@ -111,7 +111,7 @@ public static void main(String[] args) { // dataSet = database.getResultSet( "SELECT * FROM LuciaData WHERE // Component='methane' AND ID<3000 AND Temperature<380 AND Pressure<100000000 - // AND Y<>NULL AND Y>0.00000001 ORDER BY Temperature,Pressure");// AND + // AND Y<>NULL AND Y>0.00000001 ORDER BY Temperature,Pressure"); // AND // Reference='Houghton1957' AND Reference<>'Nighswander1989' AND // Temperature>278.15 AND Temperature<383.15 AND Pressure<60.01325"); dataSet = database.getResultSet( diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityGlycolHC.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityGlycolHC.java index 06db3d4f1e..4e8a6ab01a 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityGlycolHC.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/EosInteractionParameterFitting/TestCPAParameterFittingToSolubilityGlycolHC.java @@ -34,9 +34,9 @@ public static void main(String[] args) { ArrayList sampleList = new ArrayList(); // inserting samples from database - NeqSimDataBase database = new NeqSimDataBase();// AND reference<>'Lindboe2002' + NeqSimDataBase database = new NeqSimDataBase(); // AND reference<>'Lindboe2002' ResultSet dataSet = database.getResultSet( - "SELECT * FROM hcglycollldata WHERE comp1='n-heptane' AND comp2='MEG' AND reference='Lindboe2002' ORDER BY Temperature,Pressure");// AND + "SELECT * FROM hcglycollldata WHERE comp1='n-heptane' AND comp2='MEG' AND reference='Lindboe2002' ORDER BY Temperature,Pressure"); // AND // Reference='Houghton1957' // AND // Reference<>'Nighswander1989' @@ -49,7 +49,7 @@ public static void main(String[] args) { // double parameterGuess[] = {0.0471326591, 5.14, 10.819, 0.6744, 0.0141}; // double parameterGuess[] = {0.0602997387, 5.2137117933, 10.3039876875, // 0.6714377099, 0.0178639622}; // fitted to all data - double parameterGuess[] = {1924, 4938};// , -1.11, 1.24}; + double parameterGuess[] = {1924, 4938}; // , -1.11, 1.24}; // double parameterGuess[] = {0.0471326591}; try { @@ -78,7 +78,7 @@ public static void main(String[] args) { double sdev = val / 100.0; SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); sample.setFunction(function); - sample.setThermodynamicSystem(testSystem);// 34.7 + sample.setThermodynamicSystem(testSystem); // 34.7 sample.setReference(Double.toString(testSystem.getTemperature())); function.setInitialGuess(parameterGuess); sampleList.add(sample); diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToDewPointData.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToDewPointData.java index 7544e86cbd..eda35aedab 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToDewPointData.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToDewPointData.java @@ -92,7 +92,7 @@ public static void main(String[] args) { // double parameterGuess[] = {3204.3057406886, -2753.7379912645, -12.4728330162 // , 13.0150379323}; // HV // double parameterGuess[] = {8.992E3, -3.244E3, -8.424E0, -1.824E0}; // HV - // double parameterGuess[] = {-7.132E2, -3.933E2};//, 3.96E0, 9.602E-1}; //, + // double parameterGuess[] = {-7.132E2, -3.933E2}; //, 3.96E0, 9.602E-1}; //, // 1.239}; //WS sample.setReference(Double.toString(testSystem.getPressure())); function.setInitialGuess(parameterGuess); diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData.java index d98d7547fe..fe5e0dc2ba 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData.java @@ -90,7 +90,7 @@ public static void main(String[] args) { // double parameterGuess[] = {4799.35, -2772.29, 0.6381, -1.68096}; // double parameterGuess[] = {5640.38, -3793.1, -4.42, 2.82}; // HV CO2 // double parameterGuess[] = {7263.5285887088, -3712.3594920781, -7.1458168635, - // 1.2714576276};//CO2-SRK-MC + // 1.2714576276}; //CO2-SRK-MC // double parameterGuess[] = {5251.7374371982, -3121.2788585048, -0.8420253536, // -0.5123316046}; // HV CO2 -PVT-sim double parameterGuess[] = {2423.6600682957, -2136.4306560594, 1.9812435921, 1.4579901393}; // HV @@ -98,7 +98,7 @@ public static void main(String[] args) { // double parameterGuess[] = {3204.3057406886, -2753.7379912645, -12.4728330162 // , 13.0150379323}; // HV // double parameterGuess[] = {8.992E3, -3.244E3, -8.424E0, -1.824E0}; // HV - // double parameterGuess[] = {-7.132E2, -3.933E2};//, 3.96E0, 9.602E-1}; //, + // double parameterGuess[] = {-7.132E2, -3.933E2}; //, 3.96E0, 9.602E-1}; //, // 1.239}; //WS function.setInitialGuess(parameterGuess); sampleList.add(sample); diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData_Lucia.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData_Lucia.java index a612bb4023..d0dbdea6f5 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData_Lucia.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData_Lucia.java @@ -37,7 +37,7 @@ public static void main(String[] args) { // inserting samples from database NeqSimDataBase database = new NeqSimDataBase(); ResultSet dataSet = database.getResultSet( - "SELECT * FROM LuciaData8 WHERE Component='methane' AND Temperature<520 AND L2<>NULL AND L2>0.0000000001 ORDER BY Temperature,Pressure");// AND + "SELECT * FROM LuciaData8 WHERE Component='methane' AND Temperature<520 AND L2<>NULL AND L2>0.0000000001 ORDER BY Temperature,Pressure"); // AND // Reference='Houghton1957' // AND // Reference<>'Nighswander1989' @@ -50,18 +50,18 @@ public static void main(String[] args) { // ResultSet dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE // Component='CO2' AND Temperature>250 AND Temperature<420 AND // Pressure<700000000 AND L2 IS NOT NULL AND L2>0.000000001 ORDER BY - // Temperature,Pressure");// AND Reference='Houghton1957' AND + // Temperature,Pressure"); // AND Reference='Houghton1957' AND // Reference<>'Nighswander1989' AND Temperature>278.15 AND Temperature<383.15 // AND Pressure<60.01325"); // ResultSet dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE // Component='propane' AND Temperature>250 AND Temperature<420 AND // Pressure<700000000 AND L2<>NULL AND L2>0.000000001 ORDER BY - // Temperature,Pressure");// AND Reference='Houghton1957' AND + // Temperature,Pressure"); // AND Reference='Houghton1957' AND // Reference<>'Nighswander1989' AND Temperature>278.15 AND Temperature<383.15 // AND Pressure<60.01325"); // ResultSet dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE // Component='methane' AND ID1>662 AND ID1<760 AND Temperature<520 AND L2<>NULL - // AND L2>0.0000000001 ORDER BY Temperature,Pressure");// AND + // AND L2>0.0000000001 ORDER BY Temperature,Pressure"); // AND // Reference='Houghton1957' AND Reference<>'Nighswander1989' AND // Temperature>278.15 AND Temperature<383.15 AND Pressure<60.01325"); // ResultSet dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE @@ -122,8 +122,8 @@ public static void main(String[] args) { // double parameterGuess[] = {1193.8840735911, 69.2494254233, -7.8323508140, // 4.5299137720}; // H2S MDEA // double parameterGuess[] ={5251.7374371982, -3121.2788585048, -0.8420253536, - // -0.5123316046};//;//,0.03};//co2 scsrk-ny - // double parameterGuess[] ={-1584, 3517, 3.9121943388, -0.44,-0.1};//propane + // -0.5123316046}; //; //,0.03}; //co2 scsrk-ny + // double parameterGuess[] ={-1584, 3517, 3.9121943388, -0.44,-0.1}; //propane // double parameterGuess[] = { 5607, 0.897598343, -123.6011438188, // -6.5496550381, 2.1378539395}; // HV methan570 double parameterGuess[] = @@ -132,7 +132,7 @@ public static void main(String[] args) { // double parameterGuess[] = {3204.3057406886, -2753.7379912645, -12.4728330162 // , 13.0150379323}; // HV // double parameterGuess[] = {8.992E3, -3.244E3, -8.424E0, -1.824E0}; // HV - // double parameterGuess[] = {-7.132E2, -3.933E2};//, 3.96E0, 9.602E-1}; //, + // double parameterGuess[] = {-7.132E2, -3.933E2}; //, 3.96E0, 9.602E-1}; //, // 1.239}; //WS function.setInitialGuess(parameterGuess); sampleList.add(sample); @@ -143,7 +143,7 @@ public static void main(String[] args) { } dataSet = database.getResultSet( - "SELECT * FROM LuciaData8 WHERE Component='methane' AND ID<3000 AND Temperature<520 AND Y<>NULL AND Y>0.0000000001 ORDER BY Temperature,Pressure");// AND + "SELECT * FROM LuciaData8 WHERE Component='methane' AND ID<3000 AND Temperature<520 AND Y<>NULL AND Y>0.0000000001 ORDER BY Temperature,Pressure"); // AND // Reference='Houghton1957' // AND // Reference<>'Nighswander1989' @@ -156,7 +156,7 @@ public static void main(String[] args) { // dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE // Component='CO2' AND ID<3000 AND Temperature>250 AND Pressure<700000000 AND // Temperature<420 AND Y IS NOT NULL AND Y>0.0000000001 ORDER BY - // Temperature,Pressure");// AND Reference='Houghton1957' AND + // Temperature,Pressure"); // AND Reference='Houghton1957' AND // Reference<>'Nighswander1989' AND Temperature>278.15 AND Temperature<383.15 // AND Pressure<60.01325"); // dataSet = database.getResultSet( "SELECT * FROM LuciaData8 WHERE @@ -223,14 +223,14 @@ public static void main(String[] args) { // -3.3157456878}; // double parameterGuess[] = {5640.0, -3793.0, -5.89, 8.9}; // HV CO2 // double parameterGuess[] ={5251.7374371982, -3121.2788585048, -0.8420253536, - // -0.5123316046};//;//,0.03};//co2 scsrk-ny + // -0.5123316046}; //; //,0.03}; //co2 scsrk-ny double parameterGuess[] = {6114.2013874102, -188.264597921, -10.7239107857559, 2.310651690177652}; // HV // methane // double parameterGuess[] = {3204.3057406886, -2753.7379912645, -12.4728330162 // , 13.0150379323}; // HV // double parameterGuess[] = {8.992E3, -3.244E3, -8.424E0, -1.824E0}; // HV - // double parameterGuess[] = {-7.132E2, -3.933E2};//, 3.96E0, 9.602E-1}; //, + // double parameterGuess[] = {-7.132E2, -3.933E2}; //, 3.96E0, 9.602E-1}; //, // 1.239}; //WS function.setInitialGuess(parameterGuess); sample.setDescription(Double.toString(testSystem.getTemperature())); diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData_LuciaPropane.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData_LuciaPropane.java index ac7f6e8041..52e28f0b94 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData_LuciaPropane.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityData_LuciaPropane.java @@ -37,27 +37,27 @@ public static void main(String[] args) { // inserting samples from database NeqSimExperimentDatabase database = new NeqSimExperimentDatabase(); ResultSet dataSet = database.getResultSet( - "SELECT * FROM LuciaData8 WHERE Component='nitrogen' AND Temperature>270.0 AND L2>0.000000001");// AND - // Temperature<600 - // AND - // Pressure<7000000000 - // AND - // L2<>NULL - // AND - // L2>0.000000001 - // ORDER - // BY - // Temperature,Pressure");// - // AND - // Reference='Houghton1957' - // AND - // Reference<>'Nighswander1989' - // AND - // Temperature>278.15 - // AND - // Temperature<383.15 - // AND - // Pressure<60.01325"); + "SELECT * FROM LuciaData8 WHERE Component='nitrogen' AND Temperature>270.0 AND L2>0.000000001"); // AND + // Temperature<600 + // AND + // Pressure<7000000000 + // AND + // L2<>NULL + // AND + // L2>0.000000001 + // ORDER + // BY + // Temperature,Pressure"); + // AND + // Reference='Houghton1957' + // AND + // Reference<>'Nighswander1989' + // AND + // Temperature>278.15 + // AND + // Temperature<383.15 + // AND + // Pressure<60.01325"); try { int p = 0; @@ -86,7 +86,7 @@ public static void main(String[] args) { sample.setFunction(function); sample.setThermodynamicSystem(testSystem); sample.setReference(Double.toString(testSystem.getTemperature())); - double parameterGuess[] = {4898.64, -111.76};// , -0.1, -0.44};//, 0.07};//propane + double parameterGuess[] = {4898.64, -111.76}; // , -0.1, -0.44}; //, 0.07}; //propane function.setInitialGuess(parameterGuess); sampleList.add(sample); @@ -96,31 +96,31 @@ public static void main(String[] args) { } dataSet = database.getResultSet( - "SELECT * FROM LuciaData8 WHERE Component='nitrogen' AND ID>=1014 AND ID<=1045 AND Temperature<373.0");// AND - // ID<3000 - // AND - // Temperature>250 - // AND - // Pressure<7000000000 - // AND - // Temperature<600 - // AND - // Y<>NULL - // AND - // Y>0.0000000001 - // ORDER - // BY - // Temperature,Pressure");// - // AND - // Reference='Houghton1957' - // AND - // Reference<>'Nighswander1989' - // AND - // Temperature>278.15 - // AND - // Temperature<383.15 - // AND - // Pressure<60.01325"); + "SELECT * FROM LuciaData8 WHERE Component='nitrogen' AND ID>=1014 AND ID<=1045 AND Temperature<373.0"); // AND + // ID<3000 + // AND + // Temperature>250 + // AND + // Pressure<7000000000 + // AND + // Temperature<600 + // AND + // Y<>NULL + // AND + // Y>0.0000000001 + // ORDER + // BY + // Temperature,Pressure"); + // AND + // Reference='Houghton1957' + // AND + // Reference<>'Nighswander1989' + // AND + // Temperature>278.15 + // AND + // Temperature<383.15 + // AND + // Pressure<60.01325"); try { int p = 0; logger.info("adding...."); @@ -143,7 +143,7 @@ public static void main(String[] args) { sample.setFunction(function); sample.setThermodynamicSystem(testSystem); sample.setReference(Double.toString(testSystem.getTemperature())); - double parameterGuess[] = {4898.64, -111.76};// , -0.1, -0.44};//, 0.07};//propane + double parameterGuess[] = {4898.64, -111.76}; // , -0.1, -0.44}; //, 0.07}; //propane function.setInitialGuess(parameterGuess); sample.setDescription(Double.toString(testSystem.getTemperature())); sampleList.add(sample); @@ -153,9 +153,9 @@ public static void main(String[] args) { } /* * dataSet = database.getResultSet( - * "SELECT * FROM LuciaData8 WHERE Component='propane');// AND Temperature>270 AND Temperature<400 AND Pressure<700000000 AND L1<>NULL ORDER BY Temperature,Pressure" - * );// AND Reference='Houghton1957' AND Reference<>'Nighswander1989' AND Temperature>278.15 AND - * Temperature<383.15 AND Pressure<60.01325"); + * "SELECT * FROM LuciaData8 WHERE Component='propane'); // AND Temperature>270 AND Temperature<400 AND Pressure<700000000 AND L1<>NULL ORDER BY Temperature,Pressure" + * ); // AND Reference='Houghton1957' AND Reference<>'Nighswander1989' AND Temperature>278.15 + * AND Temperature<383.15 AND Pressure<60.01325"); * * try{ int p=0; logger.info("adding...."); while(!dataSet.next() && p<10){ p++; * BinaryHVParameterFittingToSolubilityData function = new @@ -175,7 +175,7 @@ public static void main(String[] args) { * SampleValue sample = new SampleValue(val, sdev, sample1, standardDeviation1); * sample.setFunction(function); sample.setThermodynamicSystem(testSystem); * sample.setReference(Double.toString(testSystem.getTemperature())); double parameterGuess[] - * ={3517,-1584, -0.1, -0.44, 0.07};//propane function.setInitialGuess(parameterGuess); + * ={3517,-1584, -0.1, -0.44, 0.07}; //propane function.setInitialGuess(parameterGuess); * sampleList.add(sample); } } catch(Exception e){ logger.error("database error" + e); } */ SampleSet sampleSet = new SampleSet(sampleList); diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityDatawaterCO2.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityDatawaterCO2.java index 878c16d8a2..7b5f2da349 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityDatawaterCO2.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVParameterFittingToSolubilityDatawaterCO2.java @@ -114,7 +114,7 @@ public static void main(String[] args) { sample.setReference(Double.toString(testSystem.getTemperature())); // double parameterGuess[] = {5601.2391787479, -3170.8329162571, -1.7069851770, // -0.5058509407}; // HV CO2 - double parameterGuess[] = {3626.0, -2241.0, 3.91, -3.16};// ; // HV CO2 + double parameterGuess[] = {3626.0, -2241.0, 3.91, -3.16}; // ; // HV CO2 function.setInitialGuess(parameterGuess); sample.setDescription(Double.toString(testSystem.getTemperature())); sampleList.add(sample); diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVfitToActivityCPA.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVfitToActivityCPA.java index 138814d68b..a1c2f6e7b4 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVfitToActivityCPA.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVfitToActivityCPA.java @@ -35,9 +35,9 @@ public static void main(String[] args) { // double parameterGuess[] ={2012.8210952954, -1074.4698351045, 5.5675858688, // -1.0503110172, - // -0.0082939895};//, 1.3505557460};//, 0.1169806819}; /SRK-EOS - // double parameterGuess[] ={1506.3, -863.3, 4.11, -0.603, -0.0145};//, - // 1.3505557460};//, 0.1169806819}; /PR-EOS + // -0.0082939895}; //, 1.3505557460}; //, 0.1169806819}; /SRK-EOS + // double parameterGuess[] ={1506.3, -863.3, 4.11, -0.603, -0.0145}; //, + // 1.3505557460}; //, 0.1169806819}; /PR-EOS double parameterGuess[] = {-359.2, 351.7, -1.31, 2.44, 0.25}; // PVTsim SRK // double parameterGuess[] ={ -446.3717107738, 523.8799876586, -1.2101168104, // 1.1754366244, 0.1726026869}; // fitted MeOH diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVfitToActivityUNIFAC.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVfitToActivityUNIFAC.java index a96d568cf2..b8a2cf72df 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVfitToActivityUNIFAC.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryHVfitToActivityUNIFAC.java @@ -17,63 +17,62 @@ * @version $Id: $Id */ public class TestBinaryHVfitToActivityUNIFAC implements Cloneable { - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList sampleList = new ArrayList(); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList sampleList = new ArrayList(); - // inserting samples from database - int numb = 0; - for (int i = 0; i < 20; i++) { - numb++; - BinaryHVparameterFitToActivityCoefficientFunction function = - new BinaryHVparameterFitToActivityCoefficientFunction(); - SystemInterface testSystem = new SystemSrkSchwartzentruberEos(273.0 + i * 5, 1.01); - testSystem.addComponent("Piperazine", 1.0); - testSystem.addComponent("AceticAcid", 1000.0); - testSystem.createDatabase(true); - // testSystem.chemicalReactionInit(); - testSystem.setMixingRule(4); - testSystem.init(0); + // inserting samples from database + int numb = 0; + for (int i = 0; i < 20; i++) { + numb++; + BinaryHVparameterFitToActivityCoefficientFunction function = + new BinaryHVparameterFitToActivityCoefficientFunction(); + SystemInterface testSystem = new SystemSrkSchwartzentruberEos(273.0 + i * 5, 1.01); + testSystem.addComponent("Piperazine", 1.0); + testSystem.addComponent("AceticAcid", 1000.0); + testSystem.createDatabase(true); + // testSystem.chemicalReactionInit(); + testSystem.setMixingRule(4); + testSystem.init(0); - SystemInterface testSystem2 = new SystemUNIFACpsrk(273.0 + i * 5, 1.01); - testSystem2.addComponent("Piperazine", 1.0); - testSystem2.addComponent("AceticAcid", 1000.0); + SystemInterface testSystem2 = new SystemUNIFACpsrk(273.0 + i * 5, 1.01); + testSystem2.addComponent("Piperazine", 1.0); + testSystem2.addComponent("AceticAcid", 1000.0); - testSystem2.createDatabase(true); - testSystem2.setMixingRule(2); - testSystem2.init(0); - testSystem2.init(1); - double activ = testSystem2.getPhase(1).getActivityCoefficient(0); - // System.out.println("activity " + activ); + testSystem2.createDatabase(true); + testSystem2.setMixingRule(2); + testSystem2.init(0); + testSystem2.init(1); + double activ = testSystem2.getPhase(1).getActivityCoefficient(0); + // System.out.println("activity " + activ); - // double parameterGuess[] ={4600.679072303, -1200.64471708, -3.89, - // 1.9};//Piperazine - water - double parameterGuess[] = {-460.679072303, 120.64471708, -3.89, 1.9};// Piuperazine - // -AceticAcid - function.setInitialGuess(parameterGuess); - double sample1[] = {numb / 1000.0, testSystem.getTemperature()}; - double standardDeviation1[] = {1.0}; - SampleValue sample = - new SampleValue(activ, activ / 1000.0, sample1, standardDeviation1); - sample.setFunction(function); - sample.setThermodynamicSystem(testSystem); - sampleList.add(sample); - } + // double parameterGuess[] ={4600.679072303, -1200.64471708, -3.89, + // 1.9}; //Piperazine - water + double parameterGuess[] = {-460.679072303, 120.64471708, -3.89, 1.9}; // Piuperazine + // -AceticAcid + function.setInitialGuess(parameterGuess); + double sample1[] = {numb / 1000.0, testSystem.getTemperature()}; + double standardDeviation1[] = {1.0}; + SampleValue sample = new SampleValue(activ, activ / 1000.0, sample1, standardDeviation1); + sample.setFunction(function); + sample.setThermodynamicSystem(testSystem); + sampleList.add(sample); + } - SampleSet sampleSet = new SampleSet(sampleList); - optim.setSampleSet(sampleSet); + SampleSet sampleSet = new SampleSet(sampleList); + optim.setSampleSet(sampleSet); - // do simulations - optim.solve(); - // optim.runMonteCarloSimulation(); - optim.displayCurveFit(); - optim.writeToTextFile("c:/testFit.txt"); - } + // do simulations + optim.solve(); + // optim.runMonteCarloSimulation(); + optim.displayCurveFit(); + optim.writeToTextFile("c:/testFit.txt"); + } } diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryUMRPRUFittingToSolubilityData.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryUMRPRUFittingToSolubilityData.java index 12b94111c5..427d15d6e3 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryUMRPRUFittingToSolubilityData.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryUMRPRUFittingToSolubilityData.java @@ -37,7 +37,7 @@ public static void main(String[] args) { ResultSet dataSet = database.getResultSet( "SELECT * FROM binarySolubilityData WHERE ComponentSolute='Hg' AND ComponentSolvent='n-decane'"); - double parameterGuess[] = {188.385052774267, -0.84022345};// , 2630.871733876947}; + double parameterGuess[] = {188.385052774267, -0.84022345}; // , 2630.871733876947}; try { int p = 0; diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryWSParameterFittingToSolubilityData_Lucia.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryWSParameterFittingToSolubilityData_Lucia.java index f3d7b244c1..5923248a72 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryWSParameterFittingToSolubilityData_Lucia.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/HuronVidalParameterFitting/TestBinaryWSParameterFittingToSolubilityData_Lucia.java @@ -37,19 +37,19 @@ public static void main(String[] args) { // inserting samples from database NeqSimDataBase database = new NeqSimDataBase(); ResultSet dataSet = database.getResultSet( - "SELECT * FROM LuciaData WHERE Component='methane' AND Temperature<520 AND L2<>NULL AND L2>0.00000001 ORDER BY Temperature,Pressure");// AND - // Reference='Houghton1957' - // AND - // Reference<>'Nighswander1989' - // AND - // Temperature>278.15 - // AND - // Temperature<383.15 - // AND - // Pressure<60.01325"); + "SELECT * FROM LuciaData WHERE Component='methane' AND Temperature<520 AND L2<>NULL AND L2>0.00000001 ORDER BY Temperature,Pressure"); // AND + // Reference='Houghton1957' + // AND + // Reference<>'Nighswander1989' + // AND + // Temperature>278.15 + // AND + // Temperature<383.15 + // AND + // Pressure<60.01325"); // ResultSet dataSet = database.getResultSet( "SELECT * FROM LuciaData WHERE // Component='CO2' AND Temperature>250 AND Temperature<420 AND L2<>NULL AND - // L2>0.00000001 ORDER BY Temperature,Pressure");// AND Reference='Houghton1957' + // L2>0.00000001 ORDER BY Temperature,Pressure"); // AND Reference='Houghton1957' // AND Reference<>'Nighswander1989' AND Temperature>278.15 AND // Temperature<383.15 AND Pressure<60.01325"); @@ -105,7 +105,7 @@ public static void main(String[] args) { // double parameterGuess[] = {3204.3057406886, -2753.7379912645, -12.4728330162 // , 13.0150379323}; // HV // double parameterGuess[] = {8.992E3, -3.244E3, -8.424E0, -1.824E0}; // HV - // double parameterGuess[] = {-7.132E2, -3.933E2};//, 3.96E0, 9.602E-1}; //, + // double parameterGuess[] = {-7.132E2, -3.933E2}; //, 3.96E0, 9.602E-1}; //, // 1.239}; //WS function.setInitialGuess(parameterGuess); sampleList.add(sample); @@ -115,19 +115,19 @@ public static void main(String[] args) { } dataSet = database.getResultSet( - "SELECT * FROM LuciaData WHERE Component='methane' AND ID<3000 AND Temperature<520 AND Y<>NULL AND Y>0.00000001 ORDER BY Temperature,Pressure");// AND - // Reference='Houghton1957' - // AND - // Reference<>'Nighswander1989' - // AND - // Temperature>278.15 - // AND - // Temperature<383.15 - // AND - // Pressure<60.01325"); + "SELECT * FROM LuciaData WHERE Component='methane' AND ID<3000 AND Temperature<520 AND Y<>NULL AND Y>0.00000001 ORDER BY Temperature,Pressure"); // AND + // Reference='Houghton1957' + // AND + // Reference<>'Nighswander1989' + // AND + // Temperature>278.15 + // AND + // Temperature<383.15 + // AND + // Pressure<60.01325"); // dataSet = database.getResultSet( "SELECT * FROM LuciaData WHERE // Component='CO2' AND ID<3000 AND Temperature>250 AND Temperature<420 AND - // Y<>NULL AND Y>0.00000001 ORDER BY Temperature,Pressure");// AND + // Y<>NULL AND Y>0.00000001 ORDER BY Temperature,Pressure"); // AND // Reference='Houghton1957' AND Reference<>'Nighswander1989' AND // Temperature>278.15 AND Temperature<383.15 AND Pressure<60.01325"); @@ -188,7 +188,7 @@ public static void main(String[] args) { // double parameterGuess[] = {3204.3057406886, -2753.7379912645, -12.4728330162 // , 13.0150379323}; // HV // double parameterGuess[] = {8.992E3, -3.244E3, -8.424E0, -1.824E0}; // HV - // double parameterGuess[] = {-7.132E2, -3.933E2};//, 3.96E0, 9.602E-1}; //, + // double parameterGuess[] = {-7.132E2, -3.933E2}; //, 3.96E0, 9.602E-1}; //, // 1.239}; //WS function.setInitialGuess(parameterGuess); sampleList.add(sample); diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/freezingFit/TestSolidComplexFunction.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/freezingFit/TestSolidComplexFunction.java index b7e1a820ab..471529b55e 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/freezingFit/TestSolidComplexFunction.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/freezingFit/TestSolidComplexFunction.java @@ -36,7 +36,7 @@ public static void main(String[] args) { ResultSet dataSet = database.getResultSet( "SELECT * FROM comlexsolidfreezingdata WHERE Component1='TEG' AND Component2='water'"); - // double parameterGuess[] = {0.1640550024};//, 7578.080};//, 245.0}; + // double parameterGuess[] = {0.1640550024}; //, 7578.080}; //, 245.0}; double parameterGuess[] = {0.119803125, 4482.0}; try { diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFitting.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFitting.java index 974e105fee..c21bcc3ac5 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFitting.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFitting.java @@ -60,26 +60,27 @@ public static void main(String[] args) { // //IonicInteractionParameterFittingFunction_CO2 function = new // IonicInteractionParameterFittingFunction_CO2(); // //double guess[] = {-0.0005842392, 0.0003621714, 0.0481887797, - // 239.2501170265};//{-0.0000629, 0.00001255, 0.05, 240.8165};//, - // 0.311975E-4};//,0.0001439};//, 0.00000001439};//, -0.0000745697};//, 263.73, - // 466.41,0.1,0.1};//, 1.0,1.0};//;{-2.9222e-6, -7.991E-6, 3.924E-6};//,1.0,1.0};//, + // 239.2501170265}; //{-0.0000629, 0.00001255, 0.05, 240.8165}; //, + // 0.311975E-4}; //,0.0001439}; //, 0.00000001439}; //, -0.0000745697}; //, 263.73, + // 466.41,0.1,0.1}; //, 1.0,1.0}; //;{-2.9222e-6, -7.991E-6, 3.924E-6}; //,1.0,1.0}; //, // -7.223e-4}; // //double bounds[][] = - // {{-0.0055,0.0055}};//,{-0.0055,0.0055},{-10.001,10.001},{-1.0015,1.0015},{-320.0015,320.0015},{-320.901,320.900195},{-1.0,1000},{-0.800001,0.8},{-80000.01,20000.8},{-0.01,10.6},{-0.01,0.0015},{-0.01,0.0015}}; - // //double guess[] = {0.0000231069, 0.0001092540, 0.00001046762};//, -0.0001190554};//, - // 1e-3,1e-3,1e-3,1e-3};//, 1110.0e-8};//, 0.0001052339, -0.0001046940};//,-2753.0e-8, - // 13.01e-8};//, 242.6021196937,-7858.0,-36.7816};//, -2753.0e-4, 13.01e-4};//, - // -0.00002653966};//, -0.000000745697};//,-2753.0e-4, 13.01e-4};//, - // 0.0000152542010};//,4.5};//, -2753.0e-4, 13.01e-4};//, 240.2701596331};// - // -2753.7379912645, 13.0150379323};//, -2.5254669805767994E-6};//,0.78000000000};// - // 241.2701596331, 0.8000000000};//, 3.162827E-4, -2.5254669805767994E-4};//, - // 239.2501170265};//, 3.11975E-5}; - // double guess[] = {0.0000260019, -0.0001172396, 0.0000615323, -0.0001285810};//, - // -0.0004677550, -0.0000389863};//, 2.88281314E-4};// detailed reactions + // {{-0.0055,0.0055}}; + // //,{-0.0055,0.0055},{-10.001,10.001},{-1.0015,1.0015},{-320.0015,320.0015},{-320.901,320.900195},{-1.0,1000},{-0.800001,0.8},{-80000.01,20000.8},{-0.01,10.6},{-0.01,0.0015},{-0.01,0.0015}}; + // //double guess[] = {0.0000231069, 0.0001092540, 0.00001046762}; //, -0.0001190554}; //, + // 1e-3,1e-3,1e-3,1e-3}; //, 1110.0e-8}; //, 0.0001052339, -0.0001046940}; //,-2753.0e-8, + // 13.01e-8}; //, 242.6021196937,-7858.0,-36.7816}; //, -2753.0e-4, 13.01e-4}; //, + // -0.00002653966}; //, -0.000000745697}; //,-2753.0e-4, 13.01e-4}; //, + // 0.0000152542010}; //,4.5}; //, -2753.0e-4, 13.01e-4}; //, 240.2701596331}; // + // -2753.7379912645, 13.0150379323}; //, -2.5254669805767994E-6}; //,0.78000000000}; // + // 241.2701596331, 0.8000000000}; //, 3.162827E-4, -2.5254669805767994E-4}; //, + // 239.2501170265}; //, 3.11975E-5}; + // double guess[] = {0.0000260019, -0.0001172396, 0.0000615323, -0.0001285810}; //, + // -0.0004677550, -0.0000389863}; //, 2.88281314E-4}; // detailed reactions // // -0,0000186524 -0,0000470206 0,0000816440 -0,0001147055 -0,1422977509 -0,0351820850 // 0,1531978514 -0,0062978601 // //double guess[] = {0,0041639953 0,0009961457};, - // //double guess[] = {-2753.0e-4, 13.01e-4};// 263.73, -5.717, 8.6}; + // //double guess[] = {-2753.0e-4, 13.01e-4}; // 263.73, -5.717, 8.6}; // //SystemInterface testSystem = new SystemElectrolyteCPA((273.15+25.0), 1.0); // SystemInterface testSystem = new SystemFurstElectrolyteEos((273.15+25.0), 1.0); // testSystem.addComponent("CO2", Double.parseDouble(dataSet.getString("x1"))); @@ -97,7 +98,7 @@ public static void main(String[] args) { // {testSystem.getPhase(0).getComponent(0).getNumberOfmoles()/testSystem.getPhase(0).getComponent(1).getNumberOfmoles()}; // // double standardDeviation1[] = {0.01}; - // double stddev = pressure;//Double.parseDouble(dataSet.getString("StandardDeviation")) + // double stddev = pressure; //Double.parseDouble(dataSet.getString("StandardDeviation")) // SampleValue sample = new SampleValue(pressure, stddev, sample1, standardDeviation1); // function.setInitialGuess(guess); // //function.setBounds(bounds); @@ -139,29 +140,30 @@ public static void main(String[] args) { // IonicInteractionParameterFittingFunction_CO2 function = new // IonicInteractionParameterFittingFunction_CO2(); // double guess[] = {-0.0005842392, 0.0003621714, 0.0481887797, - // 239.2501170265};//{-0.0000629, 0.00001255, 0.05, 240.8165};//, - // 0.311975E-4};//,0.0001439};//, 0.00000001439};//, -0.0000745697};//, 263.73, - // 466.41,0.1,0.1};//, 1.0,1.0};//;{-2.9222e-6, -7.991E-6, - // 3.924E-6};//,1.0,1.0};//, -7.223e-4}; + // 239.2501170265}; //{-0.0000629, 0.00001255, 0.05, 240.8165}; //, + // 0.311975E-4}; //,0.0001439}; //, 0.00000001439}; //, -0.0000745697}; //, 263.73, + // 466.41,0.1,0.1}; //, 1.0,1.0}; //;{-2.9222e-6, -7.991E-6, + // 3.924E-6}; //,1.0,1.0}; //, -7.223e-4}; // double bounds[][] = - // {{-0.0055,0.0055}};//,{-0.0055,0.0055},{-10.001,10.001},{-1.0015,1.0015},{-320.0015,320.0015},{-320.901,320.900195},{-1.0,1000},{-0.800001,0.8},{-80000.01,20000.8},{-0.01,10.6},{-0.01,0.0015},{-0.01,0.0015}}; - // double guess[] = {0.0000231069, 0.0001092540, 0.00001046762};//, - // -0.0001190554};//, 1e-3,1e-3,1e-3,1e-3};//, 1110.0e-8};//, 0.0001052339, - // -0.0001046940};//,-2753.0e-8, 13.01e-8};//, - // 242.6021196937,-7858.0,-36.7816};//, -2753.0e-4, 13.01e-4};//, - // -0.00002653966};//, -0.000000745697};//,-2753.0e-4, 13.01e-4};//, - // 0.0000152542010};//,4.5};//, -2753.0e-4, 13.01e-4};//, 240.2701596331};// - // -2753.7379912645, 13.0150379323};//, - // -2.5254669805767994E-6};//,0.78000000000};// 241.2701596331, - // 0.8000000000};//, 3.162827E-4, -2.5254669805767994E-4};//, - // 239.2501170265};//, 3.11975E-5}; + // {{-0.0055,0.0055}}; + // //,{-0.0055,0.0055},{-10.001,10.001},{-1.0015,1.0015},{-320.0015,320.0015},{-320.901,320.900195},{-1.0,1000},{-0.800001,0.8},{-80000.01,20000.8},{-0.01,10.6},{-0.01,0.0015},{-0.01,0.0015}}; + // double guess[] = {0.0000231069, 0.0001092540, 0.00001046762}; //, + // -0.0001190554}; //, 1e-3,1e-3,1e-3,1e-3}; //, 1110.0e-8}; //, 0.0001052339, + // -0.0001046940}; //,-2753.0e-8, 13.01e-8}; //, + // 242.6021196937,-7858.0,-36.7816}; //, -2753.0e-4, 13.01e-4}; //, + // -0.00002653966}; //, -0.000000745697}; //,-2753.0e-4, 13.01e-4}; //, + // 0.0000152542010}; //,4.5}; //, -2753.0e-4, 13.01e-4}; //, 240.2701596331}; // + // -2753.7379912645, 13.0150379323}; //, + // -2.5254669805767994E-6}; //,0.78000000000}; // 241.2701596331, + // 0.8000000000}; //, 3.162827E-4, -2.5254669805767994E-4}; //, + // 239.2501170265}; //, 3.11975E-5}; // double guess[] = {0.0000260019, -0.0001172396, 0.0000615323, - // -0.0001285810};//, -0.0004677550, -0.0000389863};//, 2.88281314E-4};// + // -0.0001285810}; //, -0.0004677550, -0.0000389863}; //, 2.88281314E-4}; // // detailed reactions // -0,0000186524 -0,0000470206 0,0000816440 -0,0001147055 -0,1422977509 // -0,0351820850 0,1531978514 -0,0062978601 // double guess[] = {0,0041639953 0,0009961457};, - // double guess[] = {-2753.0e-4, 13.01e-4};// 263.73, -5.717, 8.6}; + // double guess[] = {-2753.0e-4, 13.01e-4}; // 263.73, -5.717, 8.6}; // SystemInterface testSystem = new SystemElectrolyteCPA((273.15+25.0), 1.0); SystemInterface testSystem = new SystemFurstElectrolyteEos((273.15 + 25.0), 1.0); testSystem.addComponent("CO2", Double.parseDouble(dataSet.getString("x1"))); @@ -178,7 +180,7 @@ public static void main(String[] args) { double sample1[] = {testSystem.getPhase(0).getComponent(0).getNumberOfmoles() / testSystem.getPhase(0).getComponent(1).getNumberOfmoles()}; double standardDeviation1[] = {0.01}; - double stddev = pressure;// Double.parseDouble(dataSet.getString("StandardDeviation")) + double stddev = pressure; // Double.parseDouble(dataSet.getString("StandardDeviation")) SampleValue sample = new SampleValue(pressure, stddev, sample1, standardDeviation1); function.setInitialGuess(guess); // function.setBounds(bounds); @@ -216,29 +218,30 @@ public static void main(String[] args) { // IonicInteractionParameterFittingFunction_CO2 function = new // IonicInteractionParameterFittingFunction_CO2(); // double guess[] = {-0.0005842392, 0.0003621714, 0.0481887797, - // 239.2501170265};//{-0.0000629, 0.00001255, 0.05, 240.8165};//, - // 0.311975E-4};//,0.0001439};//, 0.00000001439};//, -0.0000745697};//, 263.73, - // 466.41,0.1,0.1};//, 1.0,1.0};//;{-2.9222e-6, -7.991E-6, - // 3.924E-6};//,1.0,1.0};//, -7.223e-4}; + // 239.2501170265}; //{-0.0000629, 0.00001255, 0.05, 240.8165}; //, + // 0.311975E-4}; //,0.0001439}; //, 0.00000001439}; //, -0.0000745697}; //, 263.73, + // 466.41,0.1,0.1}; //, 1.0,1.0}; //;{-2.9222e-6, -7.991E-6, + // 3.924E-6}; //,1.0,1.0}; //, -7.223e-4}; // double bounds[][] = - // {{-0.0055,0.0055}};//,{-0.0055,0.0055},{-10.001,10.001},{-1.0015,1.0015},{-320.0015,320.0015},{-320.901,320.900195},{-1.0,1000},{-0.800001,0.8},{-80000.01,20000.8},{-0.01,10.6},{-0.01,0.0015},{-0.01,0.0015}}; - // double guess[] = {0.0000231069, 0.0001092540, 0.00001046762};//, - // -0.0001190554};//, 1e-3,1e-3,1e-3,1e-3};//, 1110.0e-8};//, 0.0001052339, - // -0.0001046940};//,-2753.0e-8, 13.01e-8};//, - // 242.6021196937,-7858.0,-36.7816};//, -2753.0e-4, 13.01e-4};//, - // -0.00002653966};//, -0.000000745697};//,-2753.0e-4, 13.01e-4};//, - // 0.0000152542010};//,4.5};//, -2753.0e-4, 13.01e-4};//, 240.2701596331};// - // -2753.7379912645, 13.0150379323};//, - // -2.5254669805767994E-6};//,0.78000000000};// 241.2701596331, - // 0.8000000000};//, 3.162827E-4, -2.5254669805767994E-4};//, - // 239.2501170265};//, 3.11975E-5}; + // {{-0.0055,0.0055}}; + // //,{-0.0055,0.0055},{-10.001,10.001},{-1.0015,1.0015},{-320.0015,320.0015},{-320.901,320.900195},{-1.0,1000},{-0.800001,0.8},{-80000.01,20000.8},{-0.01,10.6},{-0.01,0.0015},{-0.01,0.0015}}; + // double guess[] = {0.0000231069, 0.0001092540, 0.00001046762}; //, + // -0.0001190554}; //, 1e-3,1e-3,1e-3,1e-3}; //, 1110.0e-8}; //, 0.0001052339, + // -0.0001046940}; //,-2753.0e-8, 13.01e-8}; //, + // 242.6021196937,-7858.0,-36.7816}; //, -2753.0e-4, 13.01e-4}; //, + // -0.00002653966}; //, -0.000000745697}; //,-2753.0e-4, 13.01e-4}; //, + // 0.0000152542010}; //,4.5}; //, -2753.0e-4, 13.01e-4}; //, 240.2701596331}; // + // -2753.7379912645, 13.0150379323}; //, + // -2.5254669805767994E-6}; //,0.78000000000}; // 241.2701596331, + // 0.8000000000}; //, 3.162827E-4, -2.5254669805767994E-4}; //, + // 239.2501170265}; //, 3.11975E-5}; // double guess[] = {0.0000260019, -0.0001172396, 0.0000615323, - // -0.0001285810};//, -0.0004677550, -0.0000389863};//, 2.88281314E-4};// + // -0.0001285810}; //, -0.0004677550, -0.0000389863}; //, 2.88281314E-4}; // // detailed reactions // -0,0000186524 -0,0000470206 0,0000816440 -0,0001147055 -0,1422977509 // -0,0351820850 0,1531978514 -0,0062978601 // double guess[] = {0,0041639953 0,0009961457};, - // double guess[] = {-2753.0e-4, 13.01e-4};// 263.73, -5.717, 8.6}; + // double guess[] = {-2753.0e-4, 13.01e-4}; // 263.73, -5.717, 8.6}; // SystemInterface testSystem = new SystemElectrolyteCPA((273.15+25.0), 1.0); SystemInterface testSystem = new SystemFurstElectrolyteEos((273.15 + 25.0), 1.0); testSystem.addComponent("CO2", Double.parseDouble(dataSet.getString("x1"))); @@ -255,7 +258,7 @@ public static void main(String[] args) { double sample1[] = {testSystem.getPhase(0).getComponent(0).getNumberOfmoles() / testSystem.getPhase(0).getComponent(1).getNumberOfmoles()}; double standardDeviation1[] = {0.01}; - double stddev = pressure;// Double.parseDouble(dataSet.getString("StandardDeviation")) + double stddev = pressure; // Double.parseDouble(dataSet.getString("StandardDeviation")) SampleValue sample = new SampleValue(pressure, stddev, sample1, standardDeviation1); function.setInitialGuess(guess); // function.setBounds(bounds); diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingCH4.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingCH4.java index 8b13b7e1e6..f40970287c 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingCH4.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingCH4.java @@ -35,7 +35,7 @@ public static void main(String[] args) { // inserting samples from database NeqSimDataBase database = new NeqSimDataBase(); - ResultSet dataSet = database.getResultSet("SELECT * FROM Co2Ch4MDEA WHERE loading<1.9");// AND + ResultSet dataSet = database.getResultSet("SELECT * FROM Co2Ch4MDEA WHERE loading<1.9"); // AND // temperature=313.15 // AND // pressure<210 @@ -44,7 +44,7 @@ public static void main(String[] args) { // ResultSet dataSet = database.getResultSet( "SELECT * FROM // activityCoefficientTable WHERE Component1='MDEA' AND Component2='water'");AND // Reference='Lemoine2000' - double guess[] = {-0.0001617266, 0.5 * 1e-3};// , -0.0932324951};//, 0.6465043774,}; + double guess[] = {-0.0001617266, 0.5 * 1e-3}; // , -0.0932324951}; //, 0.6465043774,}; // -0,0001550096 0,0007612383 // double guess[] = {-0.0000309356,-0.1469925592,-0.0272808384}; @@ -95,7 +95,7 @@ public static void main(String[] args) { // ResultSet dataSet = database.getResultSet( "SELECT * FROM // activityCoefficientTable WHERE Component1='MDEA' AND Component2='water'");AND // Reference='Lemoine2000' - dataSet = database.getResultSet("SELECT * FROM Co2Ch4MDEA WHERE loading<1.9");// AND + dataSet = database.getResultSet("SELECT * FROM Co2Ch4MDEA WHERE loading<1.9"); // AND // temperature=313.15 // AND // pressure<210 diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingCo2nacl.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingCo2nacl.java index e4f7f46921..5cf5a8a549 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingCo2nacl.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingCo2nacl.java @@ -40,13 +40,13 @@ public static void main(String[] args) { // ResultSet dataSet = database.getResultSet( "SELECT * FROM // activityCoefficientTable WHERE Component1='MDEA' AND Component2='water'");AND // Reference='Lemoine2000' - // double guess[] = {-0.0000110329, -0.1238487876};//Na+ - // double guess[] = {0.0000258505};//Na+ all temp - // double guess[] = {0.0000080642};//Na+ 40 - // double guess[] = {0.0000542456};//Na+ 80 - // double guess[] = { -0.0000442947, -0.1933846606};//k+ - // double guess[] = {-0.00000650867};//k+ 40 - double guess[] = {0.0000267226};// k+ 80 + // double guess[] = {-0.0000110329, -0.1238487876}; //Na+ + // double guess[] = {0.0000258505}; //Na+ all temp + // double guess[] = {0.0000080642}; //Na+ 40 + // double guess[] = {0.0000542456}; //Na+ 80 + // double guess[] = { -0.0000442947, -0.1933846606}; //k+ + // double guess[] = {-0.00000650867}; //k+ 40 + double guess[] = {0.0000267226}; // k+ 80 try { int i = 0; diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingMDEAPiperazine.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingMDEAPiperazine.java index adf2e7f0b1..378a557f61 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingMDEAPiperazine.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingMDEAPiperazine.java @@ -37,9 +37,9 @@ public static void main(String[] args) { // inserting samples from database NeqSimDataBase database = new NeqSimDataBase(); - double guess[] = {0.0007757516};// , -0.00013534324};//, -0.000210224};//, -0.0002324934, + double guess[] = {0.0007757516}; // , -0.00013534324}; //, -0.000210224}; //, -0.0002324934, // 0.0005}; - ResultSet dataSet = database.getResultSet("SELECT * FROM CO2waterPZ");// WHERE + ResultSet dataSet = database.getResultSet("SELECT * FROM CO2waterPZ"); // WHERE // Temperature<393.15 // AND // PressureCO2<4"); @@ -65,7 +65,7 @@ public static void main(String[] args) { double sample1[] = {testSystem.getPhase(0).getComponent(0).getNumberOfmoles() / testSystem.getPhase(0).getComponent(1).getNumberOfmoles()}; double standardDeviation1[] = {0.01}; - double stddev = pressure;// Double.parseDouble(dataSet.getString("StandardDeviation")) + double stddev = pressure; // Double.parseDouble(dataSet.getString("StandardDeviation")) SampleValue sample = new SampleValue(pressure, stddev, sample1, standardDeviation1); function.setInitialGuess(guess); // function.setBounds(bounds); diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingPiperazine.java b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingPiperazine.java index 7558c1b264..1c70b40f0c 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingPiperazine.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/binaryInteractionParameterFitting/ionicInteractionCoefficientFitting/TestIonicInteractionParameterFittingPiperazine.java @@ -37,7 +37,7 @@ public static void main(String[] args) { NeqSimDataBase database = new NeqSimDataBase(); double guess[] = {-0.0001868490, -0.0006868943, -0.0000210224, -0.0002324934, 0.0005}; - ResultSet dataSet = database.getResultSet("SELECT * FROM CO2waterMDEAPiperazine");// WHERE + ResultSet dataSet = database.getResultSet("SELECT * FROM CO2waterMDEAPiperazine"); // WHERE // Temperature<393.15 // AND // PressureCO2<4"); @@ -64,7 +64,7 @@ public static void main(String[] args) { double sample1[] = {testSystem.getPhase(0).getComponent(0).getNumberOfmoles() / testSystem.getPhase(0).getComponent(1).getNumberOfmoles()}; double standardDeviation1[] = {0.01}; - double stddev = pressure;// Double.parseDouble(dataSet.getString("StandardDeviation")) + double stddev = pressure; // Double.parseDouble(dataSet.getString("StandardDeviation")) SampleValue sample = new SampleValue(pressure, stddev, sample1, standardDeviation1); function.setInitialGuess(guess); // function.setBounds(bounds); diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestAcentricSchwartzentruber.java b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestAcentricSchwartzentruber.java index 2258531f7b..4308a09749 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestAcentricSchwartzentruber.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestAcentricSchwartzentruber.java @@ -69,7 +69,7 @@ public static void main(String[] args) { double guess[] = {0.09245, 0.9784, 2.244}; // double guess[] ={0.1208932305, 0.9580163852, 0.9875864928} ; //mercury PROII - - // double guess[] = {0.4563609446};//, -140.87783836,44.122}; // nitrogen + // double guess[] = {0.4563609446}; //, -140.87783836,44.122}; // nitrogen function.setInitialGuess(guess); // SystemInterface testSystem = new SystemSrkSchwartzentruberEos(280, 0.101); diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestMathiasCopemanToDewPoint.java b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestMathiasCopemanToDewPoint.java index 79169abba6..8a6e4a5b3c 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestMathiasCopemanToDewPoint.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/acentricFactorFitting/TestMathiasCopemanToDewPoint.java @@ -104,7 +104,7 @@ public static void main(String[] args) { } } - dataSet = database.getResultSet("SELECT * FROM dewPointDataSynthHCStatoil WHERE Pressure<80.0");// "0 + dataSet = database.getResultSet("SELECT * FROM dewPointDataSynthHCStatoil WHERE Pressure<80.0"); // "0 // AND // reference='Morch2004gas1'"); diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/CPAFunctionCp.java b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/CPAFunctionCp.java index 0f756b6990..93cb8facf2 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/CPAFunctionCp.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/CPAFunctionCp.java @@ -51,7 +51,7 @@ public double calcTrueValue(double val) { @Override public double calcValue(double[] dependentValues) { system.setTemperature(dependentValues[0]); - system.setPressure(1.0);// system.getPhases()[0].getComponents()[0].getAntoineVaporPressure(dependentValues[0])); + system.setPressure(1.0); // system.getPhases()[0].getComponents()[0].getAntoineVaporPressure(dependentValues[0])); try { thermoOps.bubblePointPressureFlash(false); } catch (Exception e) { diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/CPAFunctionDens.java b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/CPAFunctionDens.java index 718d249620..8b8ff8e373 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/CPAFunctionDens.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/CPAFunctionDens.java @@ -57,7 +57,7 @@ public double calcTrueValue(double val) { */ public double calcValue2(double[] dependentValues) { system.setTemperature(dependentValues[0]); - system.setPressure(1.0);// system.getPhases()[0].getComponents()[0].getAntoineVaporPressure(dependentValues[0])); + system.setPressure(1.0); // system.getPhases()[0].getComponents()[0].getAntoineVaporPressure(dependentValues[0])); try { thermoOps.bubblePointPressureFlash(false); } catch (Exception e) { diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/TestCPA.java b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/TestCPA.java index 6664339807..9543995262 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/TestCPA.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/TestCPA.java @@ -64,7 +64,7 @@ public static void main(String[] args) { // double guess[] = // {((ComponentSrk)testSystem.getPhase(0).getComponent(0)).geta(),((ComponentSrk)testSystem.getPhase(0).getComponent(0)).getb(),testSystem.getPhase(0).getComponent(0).getAcentricFactor(),0.04567}; - double guess[] = {13.21, 39.123563589168, 1.1692, 0.0188, 14337.0};// , + double guess[] = {13.21, 39.123563589168, 1.1692, 0.0188, 14337.0}; // , // 0.3255175584, // 10725.7300849509}; // abs 3.2% 10,8185533003 33,0294376487 1,0676048144 0,0221795587 @@ -100,9 +100,9 @@ public static void main(String[] args) { SampleValue sample = new SampleValue(val, val / 100.0, sample1, standardDeviation1); // double guess[] = // {testSystem.getPhase(0).geta(),testSystem.getPhase(0).getb(), - // testSystem.getPhase(0).getComponent(0).getAcentricFactor()};// , 2260.69, + // testSystem.getPhase(0).getComponent(0).getAcentricFactor()}; // , 2260.69, // 0.0229}; - double guess[] = {13.21, 39.123563589168, 1.1692, 0.0188, 14337.0};// , + double guess[] = {13.21, 39.123563589168, 1.1692, 0.0188, 14337.0}; // , // 0.4354649799, // 0.3255175584, // 10725.7300849509}; diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/TestCPA2.java b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/TestCPA2.java index b95fbafa61..ed42713f80 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/TestCPA2.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/TestCPA2.java @@ -38,7 +38,7 @@ public static void main(String[] args) { // ResultSet dataSet = database.getResultSet( "SELECT * FROM // PureComponentVapourPressures WHERE ComponentName='water'"); // double guess[] = {23939.4738048507, 1.5971863018, 0.63623134978, - // 0.00292037583};//, 1002.0}; + // 0.00292037583}; //, 1002.0}; // double guess[] = { 1.4403259969, 0.8551003534, 1.2240339308, 0.0871385903}; // // water - srk-cpa // double guess[] = {1.4563608786, 1.3855596964, 0.6641553237, 0.0464737892}; @@ -46,11 +46,11 @@ public static void main(String[] args) { // double guess[] = {5.2313853467, 12.6519920554, 0.5439839271, 0.0063462374}; // MEG srk-cpas // double guess[] = { 10.7510088868, 25.8457097739, 1.3642192066, - // 0.0541207125};// MDEA srk-cpa + // 0.0541207125}; // MDEA srk-cpa double guess[] = {2.7063578765, 3.4369093554, 0.8047829596, 0.0011604894}; // CO2 cpas // double guess[] = {5.14, 1.08190, 0.6744, 0.0141}; // MEG - srk-cpa - // double guess[] = {2.97, 3.7359, 0.0692, 0.0787};//, 0.01787};//co2 + // double guess[] = {2.97, 3.7359, 0.0692, 0.0787}; //, 0.01787}; //co2 double bounds[][] = {{0, 3.0055}, {0, 8.0055}, {0.00001, 10.001}, {-1.0015, 1.0015}, {-320.0015, 320.0015}, {-320.901, 320.900195}, {-1.0, 1000}, {-0.800001, 0.8}, {-80000.01, 20000.8}, {-0.01, 10.6}, {-0.01, 0.0015}, {-0.01, 0.0015}}; diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/TestCPA2_1.java b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/TestCPA2_1.java index 76972250b6..1cf04ebbc6 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/TestCPA2_1.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/TestCPA2_1.java @@ -38,7 +38,7 @@ public static void main(String[] args) { // ResultSet dataSet = database.getResultSet( "SELECT * FROM // PureComponentVapourPressures WHERE ComponentName='water'"); // double guess[] = {23939.4738048507, 1.5971863018, 0.63623134978, - // 0.00292037583};//, 1002.0}; + // 0.00292037583}; //, 1002.0}; // double guess[] = {1.453, 0.9894, 1.0669, 0.0787}; // water - srk-cpa // double guess[] = {1.4563608786, 1.3855596964, 0.6641553237, 0.0464737892}; // water - pr-cpa @@ -47,7 +47,7 @@ public static void main(String[] args) { // double guess[] = {5.2261531848, 10.4652138885, 0.6690350867, 0.0197428805}; // double guess[] = {5.14, 1.08190, 0.6744, 0.0141}; // MEG - srk-cpa - double guess[] = {1.4515, 0.67359, 0.0692};// , 0.01787};//co2 + double guess[] = {1.4515, 0.67359, 0.0692}; // , 0.01787}; //co2 double bounds[][] = {{0, 3.0055}, {0, 8.0055}, {0.00001, 10.001}, {-1.0015, 1.0015}, {-320.0015, 320.0015}, {-320.901, 320.900195}, {-1.0, 1000}, {-0.800001, 0.8}, {-80000.01, 20000.8}, {-0.01, 10.6}, {-0.01, 0.0015}, {-0.01, 0.0015}}; @@ -114,7 +114,7 @@ public static void main(String[] args) { // SystemInterface testSystem = new SystemSrkEos(280, 0.001); double temp = testSystem.getTemperature(); testSystem.addComponent(dataSet.getString("ComponentName"), 100.0); - testSystem.setPressure(1.0);// Double.parseDouble(dataSet.getString("VapourPressure"))); + testSystem.setPressure(1.0); // Double.parseDouble(dataSet.getString("VapourPressure"))); // testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure"))); testSystem.setTemperature(temp); testSystem.setMixingRule(1); diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/TestCPAStatoil.java b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/TestCPAStatoil.java index 6f831a653d..2deffe93b3 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/TestCPAStatoil.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/TestCPAStatoil.java @@ -36,7 +36,7 @@ public static void main(String[] args) { // inserting samples from database NeqSimDataBase database = new NeqSimDataBase(); ResultSet dataSet = database.getResultSet( - "SELECT * FROM PureComponentVapourPressures WHERE ComponentName='MEG' AND Temperature<500.0");// AND + "SELECT * FROM PureComponentVapourPressures WHERE ComponentName='MEG' AND Temperature<500.0"); // AND // VapourPressure>0.00000000001 // AND // Reference='Stull1947'"); @@ -64,10 +64,10 @@ public static void main(String[] args) { // double guess[] = // {((ComponentSrk)testSystem.getPhase(0).getComponent(0)).geta(),((ComponentSrk)testSystem.getPhase(0).getComponent(0)).getb(),testSystem.getPhase(0).getComponent(0).getAcentricFactor(),0.04567}; - double guess[] = {0.7892765953, -1.0606510837, 2.2071936510};// water CPA statoil - // double guess[] ={0.8581331725*0, -1.0053180150*0, 1.2736063639*0};//MEG CPA + double guess[] = {0.7892765953, -1.0606510837, 2.2071936510}; // water CPA statoil + // double guess[] ={0.8581331725*0, -1.0053180150*0, 1.2736063639*0}; //MEG CPA // statoil - // double guess[] ={ 1.0008858863, 1.8649645470, -4.6720397496};//TEG CPA + // double guess[] ={ 1.0008858863, 1.8649645470, -4.6720397496}; //TEG CPA // statoil function.setInitialGuess(guess); diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/TestCPA_TEG.java b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/TestCPA_TEG.java index 72c654684a..df18d44f52 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/TestCPA_TEG.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/cpaParam/TestCPA_TEG.java @@ -36,17 +36,17 @@ public static void main(String[] args) { // inserting samples from database NeqSimExperimentDatabase database = new NeqSimExperimentDatabase(); - // double guess[] = {13.21, 39.1260, 1.1692, 0.0188, 1.4337};//,1.0008858863, + // double guess[] = {13.21, 39.1260, 1.1692, 0.0188, 1.4337}; //,1.0008858863, // 1.8649645470, -4.6720397496}; // MEG - srk-cpa // double guess[] = {0.903477158616734, 1.514853438, -1.86430399826}; double guess[] = {0.28454, -0.0044236}; // double guess[] = {0.28652795, 0.001}; // double guess[] ={ 0.6224061375113976, -0.050295759360433255, - // 0.7162394329011095};//water CPA statoil + // 0.7162394329011095}; //water CPA statoil // double guess[] ={ 1.683161439854159, -2.0134329439188, - // 2.1912144731621446};//water CPA statoil + // 2.1912144731621446}; //water CPA statoil - // double guess[] = {2.97, 3.7359, 0.0692, 0.0787};//, 0.01787};//co2 + // double guess[] = {2.97, 3.7359, 0.0692, 0.0787}; //, 0.01787}; //co2 // double guess[] = {0.1}; ResultSet dataSet = database.getResultSet( "SELECT * FROM PureComponentVapourPressures WHERE ComponentName='TEG' AND Temperature>273.15 AND Temperature<690.0 ORDER BY Temperature"); diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/furstIonicParameters/TestFurstIonicParameterFunction.java b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/furstIonicParameters/TestFurstIonicParameterFunction.java index 0f07938f63..b9f8e25749 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/furstIonicParameters/TestFurstIonicParameterFunction.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/furstIonicParameters/TestFurstIonicParameterFunction.java @@ -41,11 +41,11 @@ public static void main(String[] args) { // double[] guess = { 0.0000001116, 0.0000053822, 0.0000691846, 0.0000049520, // -0.0000000605, -0.0000216352}; // double[] guess = {0.0000000640, 0.0000011845 , 0.0000209744, 0.0000089071, - // -0.0000000272, 0.0000019014};//cpa-el + // -0.0000000272, 0.0000019014}; //cpa-el double[] guess = {0.0000000752, 0.0000037242, 0.0000250998, 0.0000198635, -0.0000000311, -0.0000006630}; // ResultSet dataSet = database.getResultSet( "SELECT * FROM ionicData WHERE - // Description IN ('NaCl')");//,'LiCl','Sr2Br','Sr2I')"); + // Description IN ('NaCl')"); //,'LiCl','Sr2Br','Sr2I')"); ResultSet dataSet = database .getResultSet("SELECT * FROM ionicData WHERE ion1<>'H3Oplus2' ORDER BY ion1,ion2,x2"); // ResultSet dataSet = database.getResultSet( "SELECT * FROM ionicData WHERE diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/hydrate/TestHydrateFunction.java b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/hydrate/TestHydrateFunction.java index 0d9e033184..8f84679390 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/hydrate/TestHydrateFunction.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/hydrate/TestHydrateFunction.java @@ -36,7 +36,7 @@ public static void main(String[] args) { // inserting samples from database NeqSimDataBase database = new NeqSimDataBase(); - double[] guess = {155.8090060223, 3.1907109417, 0.4069986258};// methane fitted statoil + double[] guess = {155.8090060223, 3.1907109417, 0.4069986258}; // methane fitted statoil // sCPA-MC // double[] guess = { 176.4, 3.2641, 0.5651}; //ethane fitted statoil sCPA-MC // double[] guess = {126.5783867132, 3.1325067483, 0.3591889027}; // nitrogen @@ -46,11 +46,11 @@ public static void main(String[] args) { // double[] guess = { 225.1504438988, 3.0810162204, 0.8708186545}; // i-butane // fitted statoil sCPA-MC - // double[] guess = { 154.7937576383, 3.2008300801, 0.4526279094};//methane + // double[] guess = { 154.7937576383, 3.2008300801, 0.4526279094}; //methane // fitted sCPA // double[] guess = { 170.1623828321, 3.0372071690, 0.6846338805}; //CO2 - // double[] guess = { 154.0936564578, 3.1720449934, 0.4436459226};//, - // -293247.7186651294};//methane fitted' + // double[] guess = { 154.0936564578, 3.1720449934, 0.4436459226}; //, + // -293247.7186651294}; //methane fitted' // double[] guess = {17.5988597357, -6056.9305919979}; // ljeps, ljdiam,a diff --git a/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java b/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java index 0b4c4aaeb6..20371de105 100644 --- a/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java +++ b/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java @@ -1798,7 +1798,7 @@ public void display() { Container dialogContentPane = dialog.getContentPane(); dialogContentPane.setLayout(new BorderLayout()); - String[] names = new String[resultTable[0].length];// {"", "", ""}; + String[] names = new String[resultTable[0].length]; // {"", "", ""}; for (int i = 0; i < names.length; i++) { names[i] = ""; } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/CriticalPointFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/CriticalPointFlash.java index 6a63ff9c81..6700b2064b 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/CriticalPointFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/CriticalPointFlash.java @@ -14,231 +14,233 @@ * @version $Id: $Id */ public class CriticalPointFlash extends Flash { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(CriticalPointFlash.class); - - SimpleMatrix Mmatrix = null; - SimpleMatrix HeidemannMmatrix = null; - SimpleMatrix Nmatrix = null; - SimpleMatrix fmatrix = null; - int numberOfComponents; - double Vc0, Tc0; - // SystemInterface clonedsystem; - - /** - *

- * Constructor for CriticalPointFlash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public CriticalPointFlash(SystemInterface system) { - this.system = system; - // clonedsystem = system.clone(); - numberOfComponents = system.getPhase(0).getNumberOfComponents(); - Mmatrix = new SimpleMatrix(numberOfComponents, numberOfComponents); - Nmatrix = new SimpleMatrix(numberOfComponents, numberOfComponents); - HeidemannMmatrix = new SimpleMatrix(numberOfComponents, numberOfComponents); - fmatrix = new SimpleMatrix(numberOfComponents, 1); - } - - /** - *

- * calcMmatrixHeidemann. - *

- */ - public void calcMmatrixHeidemann() { - Tc0 = system.getPhase(0).getPseudoCriticalTemperature(); - Vc0 = 4 * system.getPhase(0).getB() / system.getPhase(0).getNumberOfMolesInPhase(); - - system.setUseTVasIndependentVariables(true); - system.setNumberOfPhases(1); - system.setTemperature(Tc0); - system.getPhase(0).setTotalVolume(Vc0 * system.getTotalNumberOfMoles()); - system.init(3); - double dt = 1.0; - - for (int iii = 0; iii < 100; iii++) { - system.setTemperature(system.getTemperature() + dt); - system.init(3); - // system.getPressure(); - - double dij = 0; - double tempJ = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < numberOfComponents; j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta - - tempJ = (dij / system.getPhase(0).getComponent(i).getNumberOfMolesInPhase() - - 1.0 / system.getPhase(0).getNumberOfMolesInPhase() - + (system.getPhase(0).getComponent(i).getdfugdn(j) - + system.getPhase(0).getComponent(i).getdfugdp() - * system.getPhase(0).getComponent(j).getVoli() - * system.getPhase(0).getdPdVTn() * -1)); - // tempJ = ((PhaseSrkEos)system.getPhase(0)).dFdNdN(i,j); - - HeidemannMmatrix.set(i, j, tempJ); - // Math.sqrt(system.getPhase(0).getComponent(i).getz() * - // system.getPhase(0).getComponent(j).getz()) * - } - } - HeidemannMmatrix.print(); - logger.info("Q det " + HeidemannMmatrix.determinant() + " temperature " - + system.getTemperature() + " pressure " + system.getPressure()); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(CriticalPointFlash.class); + + SimpleMatrix Mmatrix = null; + SimpleMatrix HeidemannMmatrix = null; + SimpleMatrix Nmatrix = null; + SimpleMatrix fmatrix = null; + int numberOfComponents; + double Vc0; + double Tc0; + + /** + *

+ * Constructor for CriticalPointFlash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public CriticalPointFlash(SystemInterface system) { + this.system = system; + // clonedsystem = system.clone(); + numberOfComponents = system.getPhase(0).getNumberOfComponents(); + Mmatrix = new SimpleMatrix(numberOfComponents, numberOfComponents); + Nmatrix = new SimpleMatrix(numberOfComponents, numberOfComponents); + HeidemannMmatrix = new SimpleMatrix(numberOfComponents, numberOfComponents); + fmatrix = new SimpleMatrix(numberOfComponents, 1); + } + + /** + *

+ * calcMmatrixHeidemann. + *

+ */ + public void calcMmatrixHeidemann() { + Tc0 = system.getPhase(0).getPseudoCriticalTemperature(); + Vc0 = 4 * system.getPhase(0).getB() / system.getPhase(0).getNumberOfMolesInPhase(); + + system.setUseTVasIndependentVariables(true); + system.setNumberOfPhases(1); + system.setTemperature(Tc0); + system.getPhase(0).setTotalVolume(Vc0 * system.getTotalNumberOfMoles()); + system.init(3); + double dt = 1.0; + + for (int iii = 0; iii < 100; iii++) { + system.setTemperature(system.getTemperature() + dt); + system.init(3); + // system.getPressure(); + + double dij = 0; + double tempJ = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < numberOfComponents; j++) { + dij = i == j ? 1.0 : 0.0; // Kroneckers delta + + tempJ = (dij / system.getPhase(0).getComponent(i).getNumberOfMolesInPhase() + - 1.0 / system.getPhase(0).getNumberOfMolesInPhase() + + (system.getPhase(0).getComponent(i).getdfugdn(j) + + system.getPhase(0).getComponent(i).getdfugdp() + * system.getPhase(0).getComponent(j).getVoli() + * system.getPhase(0).getdPdVTn() * -1)); + // tempJ = ((PhaseSrkEos)system.getPhase(0)).dFdNdN(i,j); + + HeidemannMmatrix.set(i, j, tempJ); + // Math.sqrt(system.getPhase(0).getComponent(i).getz() * + // system.getPhase(0).getComponent(j).getz()) * } + } + HeidemannMmatrix.print(); + logger.info("Q det " + HeidemannMmatrix.determinant() + " temperature " + + system.getTemperature() + " pressure " + system.getPressure()); } - - /** - *

- * calcMmatrix. - *

- */ - public void calcMmatrix() { - double dij = 0; - double tempJ = 0; - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < numberOfComponents; j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta - - tempJ = (dij / system.getPhase(0).getComponent(i).getNumberOfMolesInPhase() - - 1.0 / system.getPhase(0).getNumberOfMolesInPhase() - + (system.getPhase(0).getComponent(i).getdfugdn(j) - + system.getPhase(0).getComponent(i).getdfugdp() - * system.getPhase(0).getComponent(j).getVoli() - * system.getPhase(0).getdPdVTn() * -1.0)); - - Mmatrix.set(i, j, Math.sqrt(system.getPhase(0).getComponent(i).getz() - * system.getPhase(0).getComponent(j).getz()) * tempJ); - // Math.sqrt(system.getPhase(0).getComponent(i).getz() * - // system.getPhase(0).getComponent(j).getz()) * - } - } + } + + /** + *

+ * calcMmatrix. + *

+ */ + public void calcMmatrix() { + double dij = 0; + double tempJ = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < numberOfComponents; j++) { + dij = i == j ? 1.0 : 0.0; // Kroneckers delta + + tempJ = (dij / system.getPhase(0).getComponent(i).getNumberOfMolesInPhase() + - 1.0 / system.getPhase(0).getNumberOfMolesInPhase() + + (system.getPhase(0).getComponent(i).getdfugdn(j) + system.getPhase(0).getComponent(i) + .getdfugdp() + * system.getPhase(0).getComponent(j).getVoli() * system.getPhase(0).getdPdVTn() + * -1.0)); + + Mmatrix.set(i, j, Math.sqrt( + system.getPhase(0).getComponent(i).getz() * system.getPhase(0).getComponent(j).getz()) + * tempJ); + // Math.sqrt(system.getPhase(0).getComponent(i).getz() * + // system.getPhase(0).getComponent(j).getz()) * + } + } + } + + /** + *

+ * calcdpd. + *

+ * + * @return a double + */ + public double calcdpd() { + double[] oldz = system.getMolarRate(); + i = Mmatrix.eig().getNumberOfEigenvalues(); + SimpleMatrix eigenVector = Mmatrix.eig().getEigenVector(0); + + double[] newz1 = new double[numberOfComponents]; + double[] newz2 = new double[numberOfComponents]; + double sperturb = 1e-3; + for (int ii = 0; ii < numberOfComponents; ii++) { + newz1[ii] = system.getPhase(0).getComponent(ii).getz() + + sperturb * eigenVector.get(ii) * Math.sqrt(system.getPhase(0).getComponent(ii).getz()); + newz2[ii] = system.getPhase(0).getComponent(ii).getz() + - sperturb * eigenVector.get(ii) * Math.sqrt(system.getPhase(0).getComponent(ii).getz()); } - /** - *

- * calcdpd. - *

- * - * @return a double - */ - public double calcdpd() { - double[] oldz = system.getMolarRate(); - i = Mmatrix.eig().getNumberOfEigenvalues(); - SimpleMatrix eigenVector = Mmatrix.eig().getEigenVector(0); - - double[] newz1 = new double[numberOfComponents]; - double[] newz2 = new double[numberOfComponents]; - double sperturb = 1e-3; - for (int ii = 0; ii < numberOfComponents; ii++) { - newz1[ii] = system.getPhase(0).getComponent(ii).getz() + sperturb * eigenVector.get(ii) - * Math.sqrt(system.getPhase(0).getComponent(ii).getz()); - newz2[ii] = system.getPhase(0).getComponent(ii).getz() - sperturb * eigenVector.get(ii) - * Math.sqrt(system.getPhase(0).getComponent(ii).getz()); - } - - system.setMolarComposition(newz1); - system.init(3); - calcMmatrix(); - // eigenVector = Mmatrix.eig().getEigenVector(0); - SimpleMatrix evalMatrix = eigenVector.transpose().mult(Mmatrix).mult(eigenVector); - double perturb1 = evalMatrix.get(0, 0); - - system.setMolarComposition(newz2); + system.setMolarComposition(newz1); + system.init(3); + calcMmatrix(); + // eigenVector = Mmatrix.eig().getEigenVector(0); + SimpleMatrix evalMatrix = eigenVector.transpose().mult(Mmatrix).mult(eigenVector); + double perturb1 = evalMatrix.get(0, 0); + + system.setMolarComposition(newz2); + system.init(3); + calcMmatrix(); + // eigenVector = Mmatrix.eig().getEigenVector(0); + evalMatrix = eigenVector.transpose().mult(Mmatrix).mult(eigenVector); + double perturb2 = evalMatrix.get(0, 0); + + system.setMolarComposition(oldz); + system.init(3); + + double dtpddsss = (perturb1 + perturb2) / (sperturb * sperturb); + return dtpddsss; + } + + /** {@inheritDoc} */ + @Override + public void run() { + system.init(0); + system.setTotalNumberOfMoles(1.0); + system.init(3); + + calcMmatrixHeidemann(); + system.setNumberOfPhases(1); + + Tc0 = system.getPhase(0).getPseudoCriticalTemperature(); + Vc0 = 4 * system.getPhase(0).getB() / system.getPhase(0).getNumberOfMolesInPhase(); + + system.setUseTVasIndependentVariables(true); + system.setNumberOfPhases(1); + system.setTemperature(Tc0); + system.getPhase(0).setTotalVolume(Vc0 * system.getTotalNumberOfMoles()); + system.init(3); + system.init(3); + // system.display(); + + for (int k = 0; k < 13; k++) { + double detM; + double olddetM; + double ddetdT; + double dT = 0.1; + calcMmatrix(); + // int i = Mmatrix.eig().getNumberOfEigenvalues(); + SimpleMatrix eigenVector = Mmatrix.eig().getEigenVector(0); + SimpleMatrix evalMatrix = eigenVector.transpose().mult(Mmatrix).mult(eigenVector); + detM = Mmatrix.determinant(); // evalMatrix.get(0, 0); + int iter = 0; + system.setTemperature(system.getTemperature() + dT); + + // double dTOld = 111110; + + do { system.init(3); + iter++; + olddetM = detM; calcMmatrix(); - // eigenVector = Mmatrix.eig().getEigenVector(0); + i = Mmatrix.eig().getNumberOfEigenvalues(); + eigenVector = Mmatrix.eig().getEigenVector(0); evalMatrix = eigenVector.transpose().mult(Mmatrix).mult(eigenVector); - double perturb2 = evalMatrix.get(0, 0); - - system.setMolarComposition(oldz); - system.init(3); - - double dtpddsss = (perturb1 + perturb2) / (sperturb * sperturb); - return dtpddsss; - } - - /** {@inheritDoc} */ - @Override - public void run() { - system.init(0); - system.setTotalNumberOfMoles(1.0); - system.init(3); - - calcMmatrixHeidemann(); - system.setNumberOfPhases(1); - - Tc0 = system.getPhase(0).getPseudoCriticalTemperature(); - Vc0 = 4 * system.getPhase(0).getB() / system.getPhase(0).getNumberOfMolesInPhase(); - - system.setUseTVasIndependentVariables(true); - system.setNumberOfPhases(1); - system.setTemperature(Tc0); - system.getPhase(0).setTotalVolume(Vc0 * system.getTotalNumberOfMoles()); - system.init(3); - system.init(3); - // system.display(); - - for (int k = 0; k < 13; k++) { - double detM, olddetM, ddetdT; - double dT = 0.1; - calcMmatrix(); - // int i = Mmatrix.eig().getNumberOfEigenvalues(); - SimpleMatrix eigenVector = Mmatrix.eig().getEigenVector(0); - SimpleMatrix evalMatrix = eigenVector.transpose().mult(Mmatrix).mult(eigenVector); - detM = Mmatrix.determinant();// evalMatrix.get(0, 0); - int iter = 0; - system.setTemperature(system.getTemperature() + dT); - - // double dTOld = 111110; - - do { - system.init(3); - iter++; - olddetM = detM; - calcMmatrix(); - i = Mmatrix.eig().getNumberOfEigenvalues(); - eigenVector = Mmatrix.eig().getEigenVector(0); - evalMatrix = eigenVector.transpose().mult(Mmatrix).mult(eigenVector); - detM = Mmatrix.determinant();// evalMatrix.get(0, 0); - ddetdT = (detM - olddetM) / dT; - // dTOld = dT; - dT = -detM / ddetdT; - if (Math.abs(dT) > 5.0) { - // dT = Math.signum(dT) * 5.0; - } - double oldTemp = system.getTemperature(); - system.setTemperature(oldTemp + dT); - logger.info("Temperature " + oldTemp + " dT " + dT + " evalMatrix " - + evalMatrix.get(0, 0)); - } while (Math.abs(dT) > 1e-8 && iter < 112);// && (Math.abs(dT) < Math.abs(dTOld) || - // iter < 3)); - - double dVc = Vc0 / 100.0; - double ddetdV, oldVal; - system.init(3); - double valstart = calcdpd(); - iter = 0; - system.getPhase(0).setTotalVolume(system.getPhase(0).getTotalVolume() + dVc); - double dVOld = 1111110; - do { - oldVal = valstart; - system.init(3); - iter++; - valstart = calcdpd(); - ddetdV = (valstart - oldVal) / dVc; - dVOld = dVc; - dVc = -valstart / ddetdV; - system.getPhase(0).setTotalVolume(system.getPhase(0).getVolume() + 0.5 * dVc); - logger.info("Volume " + system.getPhase(0).getVolume() + " dVc " + dVc + " tddpp " - + valstart + " pressure " + system.getPressure()); - } while (Math.abs(dVc) > 1e-5 && iter < 112 - && (Math.abs(dVc) < Math.abs(dVOld) || iter < 3)); + detM = Mmatrix.determinant(); // evalMatrix.get(0, 0); + ddetdT = (detM - olddetM) / dT; + // dTOld = dT; + dT = -detM / ddetdT; + if (Math.abs(dT) > 5.0) { + // dT = Math.signum(dT) * 5.0; } - system.display(); - // solve(fmatrix); - // dnMatrix.print(10, 10); - // system.display(); - // clonedsystem.display(); + double oldTemp = system.getTemperature(); + system.setTemperature(oldTemp + dT); + logger.info("Temperature " + oldTemp + " dT " + dT + " evalMatrix " + evalMatrix.get(0, 0)); + } while (Math.abs(dT) > 1e-8 && iter < 112); // && (Math.abs(dT) < Math.abs(dTOld) || + // iter < 3)); + + double dVc = Vc0 / 100.0; + double ddetdV; + double oldVal; + system.init(3); + double valstart = calcdpd(); + iter = 0; + system.getPhase(0).setTotalVolume(system.getPhase(0).getTotalVolume() + dVc); + double dVOld = 1111110; + do { + oldVal = valstart; + system.init(3); + iter++; + valstart = calcdpd(); + ddetdV = (valstart - oldVal) / dVc; + dVOld = dVc; + dVc = -valstart / ddetdV; + system.getPhase(0).setTotalVolume(system.getPhase(0).getVolume() + 0.5 * dVc); + logger.info("Volume " + system.getPhase(0).getVolume() + " dVc " + dVc + " tddpp " + + valstart + " pressure " + system.getPressure()); + } while (Math.abs(dVc) > 1e-5 && iter < 112 && (Math.abs(dVc) < Math.abs(dVOld) || iter < 3)); } + system.display(); + // solve(fmatrix); + // dnMatrix.print(10, 10); + // system.display(); + // clonedsystem.display(); + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java index 1c4aa245e7..2aefb25cef 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java @@ -129,7 +129,7 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException, // System.out.println("sumw1 " + sumw[1]); int start = 0; - int end = 1;// clonedSystem.getNumberOfPhases()-1; + int end = 1; // clonedSystem.getNumberOfPhases()-1; int mult = 1; // if (sumw[1] > sumw[0]) { if (lowestGibbsEnergyPhase == 0) { @@ -227,7 +227,7 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException, for (int k = 0; k < clonedSystem.getPhases()[0].getNumberOfComponents(); k++) { double kronDelt = (i == k) ? 1.5 : 0.0; // adding 0.5 to diagonal df.set(i, k, kronDelt + Math.sqrt(Wi[j][k] * Wi[j][i]) - * clonedSystem.getPhase(j).getComponent(i).getdfugdn(k));// * + * clonedSystem.getPhase(j).getComponent(i).getdfugdn(k)); // * // clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/PSFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/PSFlash.java index 106c041b1f..7ceab1bda9 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/PSFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/PSFlash.java @@ -64,9 +64,11 @@ public double calcdQdT() { /** {@inheritDoc} */ @Override public double solveQ() { - double oldTemp = system.getTemperature(), nyTemp = system.getTemperature(); + double oldTemp = system.getTemperature(); + double nyTemp = system.getTemperature(); int iterations = 1; - double error = 1.0, erorOld = 10.0e10; + double error = 1.0; + double erorOld = 10.0e10; double factor = 0.8; boolean correctFactor = true; @@ -102,7 +104,7 @@ public double solveQ() { tpFlash.run(); system.init(2); erorOld = error; - error = Math.abs(calcdQdT());// Math.abs((nyTemp - oldTemp) / (nyTemp)); + error = Math.abs(calcdQdT()); // Math.abs((nyTemp - oldTemp) / (nyTemp)); // if(error>erorOld) factor *= -1.0; // System.out.println("temp " + system.getTemperature() + " iter "+ iterations + // " error "+ error + " correction " + newCorr + " factor "+ factor); diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/PSFlashGERG2008.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/PSFlashGERG2008.java index 20cb56f55e..1bc9293feb 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/PSFlashGERG2008.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/PSFlashGERG2008.java @@ -2,7 +2,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import neqsim.thermo.system.SystemInterface; /** @@ -59,10 +58,12 @@ public double calcdQdT() { /** {@inheritDoc} */ @Override public double solveQ() { - double oldTemp = system.getTemperature(), nyTemp = system.getTemperature(); - int iterations = 1; - double error = 1.0, erorOld = 10.0e10; - double factor = 0.8; + double oldTemp = system.getTemperature(); + double nyTemp = system.getTemperature(); + int iterations = 1; + double error = 1.0; + double erorOld = 10.0e10; + double factor = 0.8; boolean correctFactor = true; double newCorr = 1.0; @@ -97,7 +98,7 @@ public double solveQ() { system.setTemperature(nyTemp); erorOld = error; - error = Math.abs(calcdQdT());// Math.abs((nyTemp - oldTemp) / (nyTemp)); + error = Math.abs(calcdQdT()); // Math.abs((nyTemp - oldTemp) / (nyTemp)); } while (((error + erorOld) > 1e-8 || iterations < 3) && iterations < 200); return nyTemp; } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/PVrefluxflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/PVrefluxflash.java index d1ef332044..be4153443e 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/PVrefluxflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/PVrefluxflash.java @@ -44,7 +44,11 @@ public PVrefluxflash(SystemInterface system, double refluxSpec, int refluxPhase) @Override public void run() { int iter = 0; - double f_func = 0.0, f_func_old = 0.0, df_func_dt = 0, t_old = 0, t_oldold = 0.0; + double f_func = 0.0; + double f_func_old = 0.0; + double df_func_dt = 0; + double t_old = 0; + double t_oldold = 0.0; tpFlash.run(); double dt = 1.0; do { @@ -54,8 +58,8 @@ public void run() { t_oldold = t_old; t_old = system.getTemperature(); - f_func = refluxSpec - (1.0 / system.getBeta(refluxPhase) - 1.0);// system.getPhase(refluxPhase).getVolume() - // / system.getVolume(); + f_func = refluxSpec - (1.0 / system.getBeta(refluxPhase) - 1.0); // system.getPhase(refluxPhase).getVolume() + // / system.getVolume(); df_func_dt = (f_func - f_func_old) / (t_old - t_oldold); // err = Math.abs(f_func); diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPgradientFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPgradientFlash.java index 0b8be39025..16b01a81a4 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPgradientFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPgradientFlash.java @@ -20,8 +20,12 @@ public class TPgradientFlash extends Flash { private static final long serialVersionUID = 1000; - SystemInterface localSystem = null, tempSystem = null; - double temperature = 0.0, height = 0.0, deltaHeight = 0.0; + SystemInterface localSystem = null; + SystemInterface tempSystem = null; + double temperature = 0.0; + double height = 0.0; + double deltaHeight = 0.0; + double deltaT = 0.0; Matrix Jac; Matrix fvec; @@ -61,10 +65,9 @@ public TPgradientFlash(SystemInterface system, double height, double temperature */ public void setfvec() { for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - fvec.set(i, 0, Math - .log(localSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient() + fvec.set(i, 0, Math.log(localSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient() * localSystem.getPhases()[0].getComponents()[i].getx() * localSystem.getPressure()) - - Math.log(tempSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient() + - Math.log(tempSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient() * tempSystem.getPhases()[0].getComponents()[i].getx() * tempSystem.getPressure()) - tempSystem.getPhases()[0].getComponents()[i].getMolarMass() * neqsim.thermo.ThermodynamicConstantsInterface.gravity * deltaHeight @@ -97,7 +100,7 @@ public void setJac() { for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { for (int j = 0; j < system.getPhase(0).getNumberOfComponents(); j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta + dij = i == j ? 1.0 : 0.0; // Kroneckers delta tempJ = 1.0 / (localSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient() * localSystem.getPhases()[0].getComponents()[i].getx() * localSystem.getPressure()) * (localSystem.getPhases()[0].getComponents()[i].getFugacityCoefficient() * dij diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash.java index 4121824f4b..ff8b37e09e 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash.java @@ -444,8 +444,8 @@ public void stabilityAnalysis() { alpha = new double[clonedSystem.get(0).getPhases()[0].getNumberOfComponents()]; df = new SimpleMatrix(system.getPhases()[0].getNumberOfComponents(), system.getPhases()[0].getNumberOfComponents()); - identitytimesConst = SimpleMatrix.identity(system.getPhases()[0].getNumberOfComponents());// , - // system.getPhases()[0].getNumberOfComponents()); + identitytimesConst = SimpleMatrix.identity(system.getPhases()[0].getNumberOfComponents()); // , + // system.getPhases()[0].getNumberOfComponents()); // secondOrderStabilityAnalysis = true; // } @@ -464,11 +464,11 @@ public void stabilityAnalysis() { double kronDelt = (i == k) ? 1.0 : 0.0; if (system.getPhase(0).getComponent(i).getz() > 1e-100) { df.set(i, k, kronDelt + Math.sqrt(Wi[j][k] * Wi[j][i]) - * clonedSystem.get(0).getPhases()[1].getComponents()[i].getdfugdn(k));// * - // clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); + * clonedSystem.get(0).getPhases()[1].getComponents()[i].getdfugdn(k)); // * + // clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); } else { - df.set(i, k, 0);// * - // clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); + df.set(i, k, 0); // * + // clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); } } } @@ -772,8 +772,8 @@ public void stabilityAnalysis2() { alpha = new double[(clonedSystem.get(j)).getPhases()[0].getNumberOfComponents()]; df = new SimpleMatrix(system.getPhases()[0].getNumberOfComponents(), system.getPhases()[0].getNumberOfComponents()); - identitytimesConst = SimpleMatrix.identity(system.getPhases()[0].getNumberOfComponents());// , - // system.getPhases()[0].getNumberOfComponents()); + identitytimesConst = SimpleMatrix.identity(system.getPhases()[0].getNumberOfComponents()); // , + // system.getPhases()[0].getNumberOfComponents()); // secondOrderStabilityAnalysis = true; // } @@ -791,11 +791,11 @@ public void stabilityAnalysis2() { double kronDelt = (i == k) ? 1.0 : 0.0; if (system.getPhase(0).getComponent(i).getz() > 1e-100) { df.set(i, k, kronDelt + Math.sqrt(Wi[j][k] * Wi[j][i]) - * (clonedSystem.get(j)).getPhases()[1].getComponents()[i].getdfugdn(k));// * - // clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); + * (clonedSystem.get(j)).getPhases()[1].getComponents()[i].getdfugdn(k)); // * + // clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); } else { - df.set(i, k, 0);// * - // clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); + df.set(i, k, 0); // * + // clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); } } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/TVflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/TVflash.java index 4e972ce4cf..f0e085f40f 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/TVflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/TVflash.java @@ -54,7 +54,7 @@ public double calcdQdVV() { double dQdVV = 0.0; for (int i = 0; i < system.getNumberOfPhases(); i++) { dQdVV += 1.0 / (system.getPhase(i).getVolume() / system.getVolume()) * 1.0 - / system.getPhase(i).getdPdVTn();// *system.getPhase(i).getdVdP();system.getPhase(i).getVolume()/system.getVolume()* + / system.getPhase(i).getdPdVTn(); // *system.getPhase(i).getdVdP();system.getPhase(i).getVolume()/system.getVolume()* } return dQdVV; } @@ -79,7 +79,8 @@ public double calcdQdV() { * @return a double */ public double solveQ() { - double oldPres = system.getPressure(), nyPres = system.getPressure(); + double oldPres = system.getPressure(); + double nyPres = system.getPressure(); double iterations = 1; do { iterations++; diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/VHflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/VHflash.java index 071a640e17..a2c0cfa980 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/VHflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/VHflash.java @@ -11,86 +11,87 @@ * @version $Id: $Id */ public class VHflash extends Flash { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - double Hspec = 0; - double Vspec = 0; - Flash pHFlash; + double Hspec = 0; + double Vspec = 0; + Flash pHFlash; - /** - *

- * Constructor for VHflash. - *

- */ - public VHflash() {} + /** + *

+ * Constructor for VHflash. + *

+ */ + public VHflash() {} - /** - *

- * Constructor for VHflash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param Hspec a double - * @param Vspec a double - */ - public VHflash(SystemInterface system, double Hspec, double Vspec) { - this.system = system; - this.pHFlash = new PHflash(system, Hspec, 0); - this.Hspec = Hspec; - this.Vspec = Vspec; - // System.out.println("enthalpy " + Hspec); - // System.out.println("volume " + Vspec); - } + /** + *

+ * Constructor for VHflash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param Hspec a double + * @param Vspec a double + */ + public VHflash(SystemInterface system, double Hspec, double Vspec) { + this.system = system; + this.pHFlash = new PHflash(system, Hspec, 0); + this.Hspec = Hspec; + this.Vspec = Vspec; + // System.out.println("enthalpy " + Hspec); + // System.out.println("volume " + Vspec); + } - /** {@inheritDoc} */ - @Override - public void run() { - // double oldVol = system.getVolume(); - double newVol = system.getVolume(); - // double pNew = system.getPressure(), pOld = system.getPressure(), pOldOld = 0.0; - double err = 0.0; - int iterations = 0; - // System.out.println("enthalpy start " + system.getEnthalpy()); - // double dPdV = 0.0; - double wallHeat = 0.0; - for (int i = 0; i < 1; i++) { - wallHeat = 0 * i / 20.0 * 400.0 * 1295.0 * 1000.0 * (293.15 - system.getTemperature()); - // System.out.println("Hwall " + wallHeat + " i " + i); - iterations = 1; - do { - iterations++; + /** {@inheritDoc} */ + @Override + public void run() { + // double oldVol = system.getVolume(); + double newVol = system.getVolume(); + // double pNew = system.getPressure(), pOld = system.getPressure(), pOldOld = 0.0; + double err = 0.0; + int iterations = 0; + // System.out.println("enthalpy start " + system.getEnthalpy()); + // double dPdV = 0.0; + double wallHeat = 0.0; + for (int i = 0; i < 1; i++) { + wallHeat = 0 * i / 20.0 * 400.0 * 1295.0 * 1000.0 * (293.15 - system.getTemperature()); + // System.out.println("Hwall " + wallHeat + " i " + i); + iterations = 1; + do { + iterations++; - this.pHFlash = new PHflash(system, Hspec + wallHeat, 0); - // System.out.println("Hspec " + Hspec); - this.pHFlash.run(); - // pOldOld = pOld; - // pOld = system.getPressure(); - // oldVol = newVol; - newVol = system.getVolume(); + this.pHFlash = new PHflash(system, Hspec + wallHeat, 0); + // System.out.println("Hspec " + Hspec); + this.pHFlash.run(); + // pOldOld = pOld; + // pOld = system.getPressure(); + // oldVol = newVol; + newVol = system.getVolume(); - err = (newVol - Vspec) / Vspec; + err = (newVol - Vspec) / Vspec; - // System.out.println("err................................................................................ - // " + err); - if (iterations < -5) { - system.setPressure(system.getPressure() + err / 10.0); - } else { - // System.out.println("pres " + (system.getPressure()+0.1*dPdV*(newVol-Vspec))); - system.setPressure(system.getPressure() - - 0.6 * 1.0 / system.getdVdPtn() * (newVol - Vspec));// system.getdVdPtn()*(newVol-Vspec));//dPdV*(newVol-Vspec)); - } - // pNew = system.getPressure(); - // dPdV = (pOld - pOldOld) / (newVol - oldVol); - // System.out.println("pressure " + system.getPressure()); - } while ((Math.abs(err) > 1e-10 && iterations < 1000) || iterations < 7); + // System.out.println("err................................................................................ + // " + err); + if (iterations < -5) { + system.setPressure(system.getPressure() + err / 10.0); + } else { + // System.out.println("pres " + (system.getPressure()+0.1*dPdV*(newVol-Vspec))); + system.setPressure( + system.getPressure() - 0.6 * 1.0 / system.getdVdPtn() * (newVol - Vspec)); // system.getdVdPtn()*(newVol-Vspec)); + // //dPdV*(newVol-Vspec)); } - // System.out.println("enthalpy end " + system.getEnthalpy()); - // System.out.println("iterations " + iterations); + // pNew = system.getPressure(); + // dPdV = (pOld - pOldOld) / (newVol - oldVol); + // System.out.println("pressure " + system.getPressure()); + } while ((Math.abs(err) > 1e-10 && iterations < 1000) || iterations < 7); } + // System.out.println("enthalpy end " + system.getEnthalpy()); + // System.out.println("iterations " + iterations); + } - /** {@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/VUflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/VUflash.java index 1b1668895f..33a99f9df8 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/VUflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/VUflash.java @@ -86,7 +86,8 @@ public void run() { } else { // System.out.println("pres " + (system.getPressure()+0.1*dPdV*(newVol-Vspec))); system.setPressure( - system.getPressure() - 0.6 * 1.0 / system.getdVdPtn() * (newVol - Vspec));// system.getdVdPtn()*(newVol-Vspec));//dPdV*(newVol-Vspec)); + system.getPressure() - 0.6 * 1.0 / system.getdVdPtn() * (newVol - Vspec)); // system.getdVdPtn()*(newVol-Vspec)); + // //dPdV*(newVol-Vspec)); } // pNew = system.getPressure(); // dPdV = (pOld - pOldOld) / (newVol - oldVol); diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/HydrateInhibitorConcentrationFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/HydrateInhibitorConcentrationFlash.java index 4c31719005..3684f7b035 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/HydrateInhibitorConcentrationFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/HydrateInhibitorConcentrationFlash.java @@ -2,7 +2,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkCPAstatoil; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -16,124 +15,125 @@ * @version $Id: $Id */ public class HydrateInhibitorConcentrationFlash extends constantDutyTemperatureFlash { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(HydrateInhibitorConcentrationFlash.class); - - double hydT = 273.15; - String inhibitor = "MEG"; - - /** - *

- * Constructor for HydrateInhibitorConcentrationFlash. - *

- */ - public HydrateInhibitorConcentrationFlash() {} - - /** - *

- * Constructor for HydrateInhibitorConcentrationFlash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param inhibitor a {@link java.lang.String} object - * @param hydrateTemperature a double - */ - public HydrateInhibitorConcentrationFlash(SystemInterface system, String inhibitor, - double hydrateTemperature) { - super(system); - hydT = hydrateTemperature; - this.inhibitor = inhibitor; - } - - /** - *

- * stop. - *

- */ - public void stop() { - system = null; - } - - /** {@inheritDoc} */ - @Override - public void run() { - ThermodynamicOperations ops = new ThermodynamicOperations(system); - int iter = 0; - double error = 1.0, oldError = 1.0, - oldC = system.getPhase(0).getComponent(inhibitor).getNumberOfmoles(); - double derrordC = 1.0; - do { - iter++; - try { - derrordC = (error - oldError) - / (system.getPhase(0).getComponent(inhibitor).getNumberOfmoles() - oldC); - oldError = error; - oldC = system.getPhase(0).getComponent(inhibitor).getNumberOfmoles(); - - if (iter < 4) { - system.addComponent(inhibitor, error * 0.01); - } else { - double newC = -error / derrordC; - double correction = newC * 0.5;// (newC - - // system.getPhase(0).getComponent(inhibitor).getNumberOfmoles()) - // * - // 0.5; - - system.addComponent(inhibitor, correction); - } - system.init(0); - system.init(1); - ops.hydrateFormationTemperature(system.getTemperature()); - error = system.getTemperature() - hydT; - - logger.info("error " + error); - } catch (Exception e) { - logger.error("error", e); - } - } while ((Math.abs(error) > 1e-3 && iter < 100) || iter < 3); - } - - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 0, 100.0); - - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - - testSystem.addComponent("methane", 1.0); - testSystem.addComponent("ethane", 0.10); - testSystem.addComponent("propane", 0.050); - testSystem.addComponent("i-butane", 0.0050); - testSystem.addComponent("MEG", 0.1); - testSystem.addComponent("water", 1.0); - testSystem.createDatabase(true); - testSystem.setMixingRule(9); - - testSystem.init(0); - testSystem.setMultiPhaseCheck(true); - testSystem.setHydrateCheck(true); - - try { - testOps.hydrateInhibitorConcentration("MEG", 270.9); - double cons = 100 * testSystem.getPhase(0).getComponent("MEG").getNumberOfmoles() - * testSystem.getPhase(0).getComponent("MEG").getMolarMass() - / (testSystem.getPhase(0).getComponent("MEG").getNumberOfmoles() - * testSystem.getPhase(0).getComponent("MEG").getMolarMass() - + testSystem.getPhase(0).getComponent("water").getNumberOfmoles() - * testSystem.getPhase(0).getComponent("water").getMolarMass()); - logger.info("hydrate inhibitor concentration " + cons + " wt%"); - } catch (Exception e) { - e.toString(); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(HydrateInhibitorConcentrationFlash.class); + + double hydT = 273.15; + String inhibitor = "MEG"; + + /** + *

+ * Constructor for HydrateInhibitorConcentrationFlash. + *

+ */ + public HydrateInhibitorConcentrationFlash() {} + + /** + *

+ * Constructor for HydrateInhibitorConcentrationFlash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param inhibitor a {@link java.lang.String} object + * @param hydrateTemperature a double + */ + public HydrateInhibitorConcentrationFlash(SystemInterface system, String inhibitor, + double hydrateTemperature) { + super(system); + hydT = hydrateTemperature; + this.inhibitor = inhibitor; + } + + /** + *

+ * stop. + *

+ */ + public void stop() { + system = null; + } + + /** {@inheritDoc} */ + @Override + public void run() { + ThermodynamicOperations ops = new ThermodynamicOperations(system); + int iter = 0; + double error = 1.0; + double oldError = 1.0; + double oldC = system.getPhase(0).getComponent(inhibitor).getNumberOfmoles(); + double derrordC = 1.0; + do { + iter++; + try { + derrordC = (error - oldError) + / (system.getPhase(0).getComponent(inhibitor).getNumberOfmoles() - oldC); + oldError = error; + oldC = system.getPhase(0).getComponent(inhibitor).getNumberOfmoles(); + + if (iter < 4) { + system.addComponent(inhibitor, error * 0.01); + } else { + double newC = -error / derrordC; + double correction = newC * 0.5; // (newC - + // system.getPhase(0).getComponent(inhibitor).getNumberOfmoles()) + // * + // 0.5; + + system.addComponent(inhibitor, correction); } - testSystem.display(); + system.init(0); + system.init(1); + ops.hydrateFormationTemperature(system.getTemperature()); + error = system.getTemperature() - hydT; + + logger.info("error " + error); + } catch (Exception e) { + logger.error("error", e); + } + } while ((Math.abs(error) > 1e-3 && iter < 100) || iter < 3); + } + + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 0, 100.0); + + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + + testSystem.addComponent("methane", 1.0); + testSystem.addComponent("ethane", 0.10); + testSystem.addComponent("propane", 0.050); + testSystem.addComponent("i-butane", 0.0050); + testSystem.addComponent("MEG", 0.1); + testSystem.addComponent("water", 1.0); + testSystem.createDatabase(true); + testSystem.setMixingRule(9); + + testSystem.init(0); + testSystem.setMultiPhaseCheck(true); + testSystem.setHydrateCheck(true); + + try { + testOps.hydrateInhibitorConcentration("MEG", 270.9); + double cons = 100 * testSystem.getPhase(0).getComponent("MEG").getNumberOfmoles() + * testSystem.getPhase(0).getComponent("MEG").getMolarMass() + / (testSystem.getPhase(0).getComponent("MEG").getNumberOfmoles() + * testSystem.getPhase(0).getComponent("MEG").getMolarMass() + + testSystem.getPhase(0).getComponent("water").getNumberOfmoles() + * testSystem.getPhase(0).getComponent("water").getMolarMass()); + logger.info("hydrate inhibitor concentration " + cons + " wt%"); + } catch (Exception e) { + e.toString(); } + testSystem.display(); + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/HydrateInhibitorwtFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/HydrateInhibitorwtFlash.java index 3ca1b071e5..bd59d2a807 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/HydrateInhibitorwtFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/HydrateInhibitorwtFlash.java @@ -2,7 +2,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkCPAstatoil; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -16,148 +15,145 @@ * @version $Id: $Id */ public class HydrateInhibitorwtFlash extends constantDutyTemperatureFlash { - private static final long serialVersionUID = 1000; - - double wtfrac = 0.5; - String inhibitor = "MEG"; - - static Logger logger = LogManager.getLogger(HydrateInhibitorwtFlash.class); - - /** - *

- * Constructor for HydrateInhibitorwtFlash. - *

- */ - public HydrateInhibitorwtFlash() {} - - /** - *

- * Constructor for HydrateInhibitorwtFlash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param inhibitor a {@link java.lang.String} object - * @param wtfr a double - */ - public HydrateInhibitorwtFlash(SystemInterface system, String inhibitor, double wtfr) { - super(system); - wtfrac = wtfr; - this.inhibitor = inhibitor; - } - - /** - *

- * stop. - *

- */ - public void stop() { - system = null; - } - - /** {@inheritDoc} */ - @Override - public void run() { - ThermodynamicOperations ops = new ThermodynamicOperations(system); - int iter = 0; - double error = 1.0, oldError = 1.0, - oldC = system.getPhase(0).getComponent(inhibitor).getNumberOfmoles(); - double derrordC = 1.0; - do { - iter++; - try { - derrordC = (error - oldError) - / (system.getPhase(0).getComponent(inhibitor).getNumberOfmoles() - oldC); - oldError = error; - oldC = system.getPhase(0).getComponent(inhibitor).getNumberOfmoles(); - - if (iter < 4) { - system.addComponent(inhibitor, error * 0.01); - } else { - double newC = -error / derrordC; - double correction = newC * 0.5;// (newC - - // system.getPhase(0).getComponent(inhibitor).getNumberOfmoles()) - // * - // 0.5; - - system.addComponent(inhibitor, correction); - } - system.init(0); - system.init(1); - ops.TPflash(); - double wtp = 0.0; - if (system.hasPhaseType("aqueous")) { - wtp = system.getPhase("aqueous").getComponent(inhibitor).getx() - * system.getPhase("aqueous").getComponent(inhibitor).getMolarMass() - / (system.getPhase("aqueous").getComponent(inhibitor).getx() - * system.getPhase("aqueous").getComponent(inhibitor) - .getMolarMass() - + system.getPhase("aqueous").getComponent("water").getx() - * system.getPhase("aqueous").getComponent("water") - .getMolarMass()); - } else { - system.addComponent(inhibitor, system.getTotalNumberOfMoles()); - ops.TPflash(); - wtp = system.getPhase("aqueous").getComponent(inhibitor).getx() - * system.getPhase("aqueous").getComponent(inhibitor).getMolarMass() - / (system.getPhase("aqueous").getComponent(inhibitor).getx() - * system.getPhase("aqueous").getComponent(inhibitor) - .getMolarMass() - + system.getPhase("aqueous").getComponent("water").getx() - * system.getPhase("aqueous").getComponent("water") - .getMolarMass()); - } - error = -(wtp - wtfrac); - - logger.info("error " + error); - } catch (Exception e) { - logger.error("error", e); - } - } while ((Math.abs(error) > 1e-5 && iter < 100) || iter < 3); - // system.display(); - } - - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 0, 100.0); - - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - - testSystem.addComponent("nitrogen", 79.0); - testSystem.addComponent("oxygen", 21.0); - // testSystem.addComponent("ethane", 0.10); - // testSystem.addComponent("propane", 0.050); - // testSystem.addComponent("i-butane", 0.0050); - testSystem.addComponent("MEG", 0.000001); - testSystem.addComponent("water", 0.0010); - testSystem.createDatabase(true); - testSystem.setMixingRule(10); - - testSystem.init(0); - testSystem.setMultiPhaseCheck(true); - testSystem.setHydrateCheck(true); - - try { - testOps.hydrateInhibitorConcentrationSet("MEG", 0.99); - double cons = 100 * testSystem.getPhase(0).getComponent("MEG").getNumberOfmoles() - * testSystem.getPhase(0).getComponent("MEG").getMolarMass() - / (testSystem.getPhase(0).getComponent("MEG").getNumberOfmoles() - * testSystem.getPhase(0).getComponent("MEG").getMolarMass() - + testSystem.getPhase(0).getComponent("water").getNumberOfmoles() - * testSystem.getPhase(0).getComponent("water").getMolarMass()); - logger.info("hydrate inhibitor concentration " + cons + " wt%"); - } catch (Exception e) { - e.toString(); + private static final long serialVersionUID = 1000; + + double wtfrac = 0.5; + String inhibitor = "MEG"; + + static Logger logger = LogManager.getLogger(HydrateInhibitorwtFlash.class); + + /** + *

+ * Constructor for HydrateInhibitorwtFlash. + *

+ */ + public HydrateInhibitorwtFlash() {} + + /** + *

+ * Constructor for HydrateInhibitorwtFlash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param inhibitor a {@link java.lang.String} object + * @param wtfr a double + */ + public HydrateInhibitorwtFlash(SystemInterface system, String inhibitor, double wtfr) { + super(system); + wtfrac = wtfr; + this.inhibitor = inhibitor; + } + + /** + *

+ * stop. + *

+ */ + public void stop() { + system = null; + } + + /** {@inheritDoc} */ + @Override + public void run() { + ThermodynamicOperations ops = new ThermodynamicOperations(system); + int iter = 0; + double error = 1.0; + double oldError = 1.0; + double oldC = system.getPhase(0).getComponent(inhibitor).getNumberOfmoles(); + double derrordC = 1.0; + do { + iter++; + try { + derrordC = (error - oldError) + / (system.getPhase(0).getComponent(inhibitor).getNumberOfmoles() - oldC); + oldError = error; + oldC = system.getPhase(0).getComponent(inhibitor).getNumberOfmoles(); + + if (iter < 4) { + system.addComponent(inhibitor, error * 0.01); + } else { + double newC = -error / derrordC; + double correction = newC * 0.5; // (newC - + // system.getPhase(0).getComponent(inhibitor).getNumberOfmoles()) + // * + // 0.5; + + system.addComponent(inhibitor, correction); + } + system.init(0); + system.init(1); + ops.TPflash(); + double wtp = 0.0; + if (system.hasPhaseType("aqueous")) { + wtp = system.getPhase("aqueous").getComponent(inhibitor).getx() + * system.getPhase("aqueous").getComponent(inhibitor).getMolarMass() + / (system.getPhase("aqueous").getComponent(inhibitor).getx() + * system.getPhase("aqueous").getComponent(inhibitor).getMolarMass() + + system.getPhase("aqueous").getComponent("water").getx() + * system.getPhase("aqueous").getComponent("water").getMolarMass()); + } else { + system.addComponent(inhibitor, system.getTotalNumberOfMoles()); + ops.TPflash(); + wtp = system.getPhase("aqueous").getComponent(inhibitor).getx() + * system.getPhase("aqueous").getComponent(inhibitor).getMolarMass() + / (system.getPhase("aqueous").getComponent(inhibitor).getx() + * system.getPhase("aqueous").getComponent(inhibitor).getMolarMass() + + system.getPhase("aqueous").getComponent("water").getx() + * system.getPhase("aqueous").getComponent("water").getMolarMass()); } - testSystem.display(); + error = -(wtp - wtfrac); + + logger.info("error " + error); + } catch (Exception e) { + logger.error("error", e); + } + } while ((Math.abs(error) > 1e-5 && iter < 100) || iter < 3); + // system.display(); + } + + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 0, 100.0); + + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + + testSystem.addComponent("nitrogen", 79.0); + testSystem.addComponent("oxygen", 21.0); + // testSystem.addComponent("ethane", 0.10); + // testSystem.addComponent("propane", 0.050); + // testSystem.addComponent("i-butane", 0.0050); + testSystem.addComponent("MEG", 0.000001); + testSystem.addComponent("water", 0.0010); + testSystem.createDatabase(true); + testSystem.setMixingRule(10); + + testSystem.init(0); + testSystem.setMultiPhaseCheck(true); + testSystem.setHydrateCheck(true); + + try { + testOps.hydrateInhibitorConcentrationSet("MEG", 0.99); + double cons = 100 * testSystem.getPhase(0).getComponent("MEG").getNumberOfmoles() + * testSystem.getPhase(0).getComponent("MEG").getMolarMass() + / (testSystem.getPhase(0).getComponent("MEG").getNumberOfmoles() + * testSystem.getPhase(0).getComponent("MEG").getMolarMass() + + testSystem.getPhase(0).getComponent("water").getNumberOfmoles() + * testSystem.getPhase(0).getComponent("water").getMolarMass()); + logger.info("hydrate inhibitor concentration " + cons + " wt%"); + } catch (Exception e) { + e.toString(); } + testSystem.display(); + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/addIonToScaleSaturation.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/addIonToScaleSaturation.java index f63d17facc..078f1ea3d7 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/addIonToScaleSaturation.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/addIonToScaleSaturation.java @@ -14,183 +14,174 @@ * @version $Id: $Id */ public class addIonToScaleSaturation extends constantDutyTemperatureFlash { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(addIonToScaleSaturation.class); - String saltName = "", scaleSaltName = "", nameOfIonToBeAdded = ""; - int phaseNumber = 1; - String[][] resultTable = null; - - /** - *

- * Constructor for addIonToScaleSaturation. - *

- */ - public addIonToScaleSaturation() {} - - /** - *

- * Constructor for addIonToScaleSaturation. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param phaseNumber a int - * @param scaleSaltName a {@link java.lang.String} object - * @param nameOfIonToBeAdded a {@link java.lang.String} object - */ - public addIonToScaleSaturation(SystemInterface system, int phaseNumber, String scaleSaltName, - String nameOfIonToBeAdded) { - super(system); - this.phaseNumber = phaseNumber; - this.scaleSaltName = scaleSaltName; - this.nameOfIonToBeAdded = nameOfIonToBeAdded; - logger.info("ok "); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(addIonToScaleSaturation.class); + String saltName = ""; + String scaleSaltName = ""; + String nameOfIonToBeAdded = ""; + int phaseNumber = 1; + String[][] resultTable = null; + + /** + *

+ * Constructor for addIonToScaleSaturation. + *

+ */ + public addIonToScaleSaturation() {} + + /** + *

+ * Constructor for addIonToScaleSaturation. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param phaseNumber a int + * @param scaleSaltName a {@link java.lang.String} object + * @param nameOfIonToBeAdded a {@link java.lang.String} object + */ + public addIonToScaleSaturation(SystemInterface system, int phaseNumber, String scaleSaltName, + String nameOfIonToBeAdded) { + super(system); + this.phaseNumber = phaseNumber; + this.scaleSaltName = scaleSaltName; + this.nameOfIonToBeAdded = nameOfIonToBeAdded; + logger.info("ok "); + } + + /** {@inheritDoc} */ + @Override + public void run() { + ThermodynamicOperations ops = new ThermodynamicOperations(system); + double ksp = 0.0; + neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); + java.sql.ResultSet dataSet = database.getResultSet("SELECT * FROM compsalt"); + resultTable = new String[10][3]; + double stoc1 = 1e-20; + double stoc2 = 1e-20; + String saltName = ""; + String name1 = ""; + String name2 = ""; + system.init(1); + int numb = 0; + + for (int i = 0; i < 10; i++) { + for (int j = 0; j < 3; j++) { + resultTable[i][j] = ""; + } } - /** {@inheritDoc} */ - @Override - public void run() { - ThermodynamicOperations ops = new ThermodynamicOperations(system); - double ksp = 0.0; - neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); - java.sql.ResultSet dataSet = database.getResultSet("SELECT * FROM compsalt"); - resultTable = new String[10][3]; - double stoc1 = 1e-20, stoc2 = 1e-20; - String saltName = ""; - String name1 = ""; - String name2 = ""; - system.init(1); - int numb = 0; - - for (int i = 0; i < 10; i++) { - for (int j = 0; j < 3; j++) { - resultTable[i][j] = ""; - } - } + resultTable[0][0] = "Salt"; + resultTable[0][1] = "relative solubility"; + resultTable[0][2] = ""; + + double numberOfMolesMEG = 0.0; + if (system.getPhase(phaseNumber).hasComponent("MEG")) { + numberOfMolesMEG = system.getPhase(phaseNumber).getComponent("MEG").getNumberOfMolesInPhase(); + system.addComponent("MEG", -numberOfMolesMEG * 0.9999, phaseNumber); + system.addComponent("water", numberOfMolesMEG, phaseNumber); + system.init(1); + system.getChemicalReactionOperations().solveChemEq(phaseNumber, 1); + } - resultTable[0][0] = "Salt"; - resultTable[0][1] = "relative solubility"; - resultTable[0][2] = ""; - - double numberOfMolesMEG = 0.0; - if (system.getPhase(phaseNumber).hasComponent("MEG")) { - numberOfMolesMEG = - system.getPhase(phaseNumber).getComponent("MEG").getNumberOfMolesInPhase(); - system.addComponent("MEG", -numberOfMolesMEG * 0.9999, phaseNumber); - system.addComponent("water", numberOfMolesMEG, phaseNumber); - system.init(1); - system.getChemicalReactionOperations().solveChemEq(phaseNumber, 1); + try { + while (dataSet.next()) { + saltName = dataSet.getString("SaltName").trim(); + name1 = dataSet.getString("ion1").trim(); + name2 = dataSet.getString("ion2").trim(); + iterations++; + stoc1 = Double.parseDouble(dataSet.getString("stoc1")); + stoc2 = Double.parseDouble(dataSet.getString("stoc2")); + double temperatureC = system.getPhase(phaseNumber).getTemperature(); + ksp = Math.exp(Double.parseDouble(dataSet.getString("Ksp-water")) / temperatureC + + Double.parseDouble(dataSet.getString("Ksp-water2")) + + Math.log(temperatureC) * Double.parseDouble(dataSet.getString("Ksp-water3")) + + temperatureC * Double.parseDouble(dataSet.getString("Ksp-water4")) + + Double.parseDouble(dataSet.getString("Ksp-water5")) / (temperatureC * temperatureC)); + if (saltName.equals("NaCl")) { + ksp = -814.18 + 7.4685 * temperatureC - 2.3262e-2 * temperatureC * temperatureC + + 3.0536e-5 * Math.pow(temperatureC, 3.0) - 1.4573e-8 * Math.pow(temperatureC, 4.0); } - try { - while (dataSet.next()) { - saltName = dataSet.getString("SaltName").trim(); - name1 = dataSet.getString("ion1").trim(); - name2 = dataSet.getString("ion2").trim(); - iterations++; - stoc1 = Double.parseDouble(dataSet.getString("stoc1")); - stoc2 = Double.parseDouble(dataSet.getString("stoc2")); - double temperatureC = system.getPhase(phaseNumber).getTemperature(); - ksp = Math.exp(Double.parseDouble(dataSet.getString("Ksp-water")) / temperatureC - + Double.parseDouble(dataSet.getString("Ksp-water2")) - + Math.log(temperatureC) - * Double.parseDouble(dataSet.getString("Ksp-water3")) - + temperatureC * Double.parseDouble(dataSet.getString("Ksp-water4")) - + Double.parseDouble(dataSet.getString("Ksp-water5")) - / (temperatureC * temperatureC)); - if (saltName.equals("NaCl")) { - ksp = -814.18 + 7.4685 * temperatureC - 2.3262e-2 * temperatureC * temperatureC - + 3.0536e-5 * Math.pow(temperatureC, 3.0) - - 1.4573e-8 * Math.pow(temperatureC, 4.0); - } - - if (system.getPhase(phaseNumber).hasComponent(name1) - && system.getPhase(phaseNumber).hasComponent(name2)) { - numb++; - logger.info("reaction added: " + name1 + " " + name2); - logger.info("theoretic Ksp = " + ksp); - double oldScalePotentialFactor = 1.0, error = 1.0; - int iterations = 0; - do { - iterations++; - logger.info("theoretic lnKsp = " + Math.log(ksp)); - int compNumb1 = system.getPhase(phaseNumber).getComponent(name1) - .getComponentNumber(); - int compNumb2 = system.getPhase(phaseNumber).getComponent(name2) - .getComponentNumber(); - int waterompNumb = system.getPhase(phaseNumber).getComponent("water") - .getComponentNumber(); - - double x1 = system.getPhase(phaseNumber).getComponent(name1).getx() - / (system.getPhase(phaseNumber).getComponent(waterompNumb).getx() - * system.getPhase(phaseNumber).getComponent(waterompNumb) - .getMolarMass()); - double x2 = system.getPhase(phaseNumber).getComponent(name2).getx() - / (system.getPhase(phaseNumber).getComponent(waterompNumb).getx() - * system.getPhase(phaseNumber).getComponent(waterompNumb) - .getMolarMass()); - double kspReac = Math - .pow(system.getPhase(phaseNumber).getActivityCoefficient(compNumb1, - waterompNumb) * x1, stoc1) - * Math.pow( - x2 * system.getPhase(phaseNumber) - .getActivityCoefficient(compNumb2, waterompNumb), - stoc2); - double stocKsp = Math.pow(x1, stoc1) * Math.pow(x2, stoc2); - logger.info("calc Ksp " + kspReac); - logger.info("stoc Ksp " + stocKsp); - logger.info("activity " + kspReac / stocKsp); - logger.info("mol/kg " + x1); - - double scalePotentialFactor = kspReac / ksp; - - error = (scalePotentialFactor - oldScalePotentialFactor) - / scalePotentialFactor * 100; - oldScalePotentialFactor = scalePotentialFactor; - logger.info("Scale potential factor " + scalePotentialFactor); - resultTable[numb][0] = name1 + " " + name2; - resultTable[numb][1] = Double.toString(scalePotentialFactor); - resultTable[numb][2] = ""; - - if (saltName.equals(scaleSaltName)) { - logger.info("error " + error); - logger.info("pH : " + system.getPhase(phaseNumber).getpH()); - system.addComponent(nameOfIonToBeAdded, - (1.0 - scalePotentialFactor) / 100000.0, phaseNumber); - ops.TPflash(); - logger.info("x1 " - + system.getPhase(phaseNumber).getComponent(name1).getx()); - logger.info("x2 " - + system.getPhase(phaseNumber).getComponent(name2).getx()); - } - } while (saltName.equals(scaleSaltName) && Math.abs(error) > 1e-6 - && iterations < 200);// - } + if (system.getPhase(phaseNumber).hasComponent(name1) + && system.getPhase(phaseNumber).hasComponent(name2)) { + numb++; + logger.info("reaction added: " + name1 + " " + name2); + logger.info("theoretic Ksp = " + ksp); + double oldScalePotentialFactor = 1.0; + double error = 1.0; + int iterations = 0; + do { + iterations++; + logger.info("theoretic lnKsp = " + Math.log(ksp)); + int compNumb1 = system.getPhase(phaseNumber).getComponent(name1).getComponentNumber(); + int compNumb2 = system.getPhase(phaseNumber).getComponent(name2).getComponentNumber(); + int waterompNumb = + system.getPhase(phaseNumber).getComponent("water").getComponentNumber(); + + double x1 = system.getPhase(phaseNumber).getComponent(name1).getx() + / (system.getPhase(phaseNumber).getComponent(waterompNumb).getx() + * system.getPhase(phaseNumber).getComponent(waterompNumb).getMolarMass()); + double x2 = system.getPhase(phaseNumber).getComponent(name2).getx() + / (system.getPhase(phaseNumber).getComponent(waterompNumb).getx() + * system.getPhase(phaseNumber).getComponent(waterompNumb).getMolarMass()); + double kspReac = Math + .pow(system.getPhase(phaseNumber).getActivityCoefficient(compNumb1, waterompNumb) + * x1, stoc1) + * Math.pow(x2 + * system.getPhase(phaseNumber).getActivityCoefficient(compNumb2, waterompNumb), + stoc2); + double stocKsp = Math.pow(x1, stoc1) * Math.pow(x2, stoc2); + logger.info("calc Ksp " + kspReac); + logger.info("stoc Ksp " + stocKsp); + logger.info("activity " + kspReac / stocKsp); + logger.info("mol/kg " + x1); + + double scalePotentialFactor = kspReac / ksp; + + error = (scalePotentialFactor - oldScalePotentialFactor) / scalePotentialFactor * 100; + oldScalePotentialFactor = scalePotentialFactor; + logger.info("Scale potential factor " + scalePotentialFactor); + resultTable[numb][0] = name1 + " " + name2; + resultTable[numb][1] = Double.toString(scalePotentialFactor); + resultTable[numb][2] = ""; + + if (saltName.equals(scaleSaltName)) { + logger.info("error " + error); + logger.info("pH : " + system.getPhase(phaseNumber).getpH()); + system.addComponent(nameOfIonToBeAdded, (1.0 - scalePotentialFactor) / 100000.0, + phaseNumber); + ops.TPflash(); + logger.info("x1 " + system.getPhase(phaseNumber).getComponent(name1).getx()); + logger.info("x2 " + system.getPhase(phaseNumber).getComponent(name2).getx()); } - } catch (Exception e) { - logger.info("failed " + e.toString()); - } - - if (system.getPhase(phaseNumber).hasComponent("MEG")) { - system.addComponent("MEG", numberOfMolesMEG * 0.9999, phaseNumber); - system.addComponent("water", -numberOfMolesMEG, phaseNumber); - system.init(1); - system.getChemicalReactionOperations().solveChemEq(phaseNumber, 1); + } while (saltName.equals(scaleSaltName) && Math.abs(error) > 1e-6 && iterations < 200); } + } + } catch (Exception e) { + logger.info("failed " + e.toString()); } - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} - - /** {@inheritDoc} */ - @Override - public String[][] getResultTable() { - logger.info("checking table...scale " + resultTable[0][0]); - logger.info("checking table...scale " + resultTable[0][1]); - logger.info("checking table...scale " + resultTable[0][2]); - logger.info("checking table...scale " + resultTable[1][0]); - logger.info("checking table...scale " + resultTable[1][1]); - logger.info("checking table...scale " + resultTable[1][2]); - return resultTable; + if (system.getPhase(phaseNumber).hasComponent("MEG")) { + system.addComponent("MEG", numberOfMolesMEG * 0.9999, phaseNumber); + system.addComponent("water", -numberOfMolesMEG, phaseNumber); + system.init(1); + system.getChemicalReactionOperations().solveChemEq(phaseNumber, 1); } + } + + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} + + /** {@inheritDoc} */ + @Override + public String[][] getResultTable() { + logger.info("checking table...scale " + resultTable[0][0]); + logger.info("checking table...scale " + resultTable[0][1]); + logger.info("checking table...scale " + resultTable[0][2]); + logger.info("checking table...scale " + resultTable[1][0]); + logger.info("checking table...scale " + resultTable[1][1]); + logger.info("checking table...scale " + resultTable[1][2]); + return resultTable; + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointPressureFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointPressureFlash.java index 46c5d916b4..13e539f2a7 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointPressureFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointPressureFlash.java @@ -13,178 +13,177 @@ * @version $Id: $Id */ public class bubblePointPressureFlash extends constantDutyPressureFlash { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(bubblePointPressureFlash.class); - - /** - *

- * Constructor for bubblePointPressureFlash. - *

- */ - public bubblePointPressureFlash() {} - - /** - *

- * Constructor for bubblePointPressureFlash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public bubblePointPressureFlash(SystemInterface system) { - super(system); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(bubblePointPressureFlash.class); + + /** + *

+ * Constructor for bubblePointPressureFlash. + *

+ */ + public bubblePointPressureFlash() {} + + /** + *

+ * Constructor for bubblePointPressureFlash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public bubblePointPressureFlash(SystemInterface system) { + super(system); + } + + /** {@inheritDoc} */ + @Override + public void run() { + if (system.getPhase(0).getNumberOfComponents() == 1 + && system.getTemperature() > system.getPhase(0).getComponent(0).getTC()) { + setSuperCritical(true); } - /** {@inheritDoc} */ - @Override - public void run() { - if (system.getPhase(0).getNumberOfComponents() == 1 - && system.getTemperature() > system.getPhase(0).getComponent(0).getTC()) { - setSuperCritical(true); - } + int iterations = 0; + int maxNumberOfIterations = 500; + double yold = 0; + double ytotal = 1; + // double deriv = 0, funk = 0; + boolean chemSolved = true; + // logger.info("starting"); + // system.setPressure(1.0); + system.init(0); + system.setNumberOfPhases(2); + system.setBeta(1, 1.0 - 1e-10); + system.setBeta(0, 1e-10); + + double oldPres = 0; + double oldChemPres = 1; + if (system.isChemicalSystem()) { + system.getChemicalReactionOperations().solveChemEq(1, 0); + system.getChemicalReactionOperations().solveChemEq(1, 1); + } - int iterations = 0, maxNumberOfIterations = 500; - double yold = 0, ytotal = 1; - // double deriv = 0, funk = 0; - boolean chemSolved = true; - // logger.info("starting"); - // system.setPressure(1.0); - system.init(0); - system.setNumberOfPhases(2); - system.setBeta(1, 1.0 - 1e-10); - system.setBeta(0, 1e-10); + for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + system.getPhases()[1].getComponents()[i] + .setx(system.getPhases()[0].getComponents()[i].getz()); + if (system.getPhases()[0].getComponents()[i].getIonicCharge() != 0) { + system.getPhases()[0].getComponents()[i].setx(1e-40); + } else { + system.getPhases()[0].getComponents()[i] + .setx(system.getPhases()[0].getComponents()[i].getK() + * system.getPhases()[1].getComponents()[i].getz()); + } + } - double oldPres = 0, oldChemPres = 1; - if (system.isChemicalSystem()) { - system.getChemicalReactionOperations().solveChemEq(1, 0); - system.getChemicalReactionOperations().solveChemEq(1, 1); - } + ytotal = 0.0; + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + ytotal += system.getPhases()[0].getComponents()[i].getx(); + } + + double ktot = 0.0; + int chemIter = 0; + do { + chemIter++; + oldChemPres = system.getPressure(); + iterations = 0; + do { + iterations++; + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + system.getPhases()[0].getComponents()[i] + .setx(system.getPhases()[0].getComponents()[i].getx() / ytotal); + } + system.init(3); + oldPres = system.getPressure(); + ktot = 0.0; for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - system.getPhases()[1].getComponents()[i] - .setx(system.getPhases()[0].getComponents()[i].getz()); - if (system.getPhases()[0].getComponents()[i].getIonicCharge() != 0) { - system.getPhases()[0].getComponents()[i].setx(1e-40); - } else { - system.getPhases()[0].getComponents()[i] - .setx(system.getPhases()[0].getComponents()[i].getK() - * system.getPhases()[1].getComponents()[i].getz()); + do { + yold = system.getPhases()[0].getComponents()[i].getx(); + if (!Double.isNaN(Math.exp( + Math.log(system.getPhases()[1].getComponents()[i].getFugacityCoefficient()) - Math + .log(system.getPhases()[0].getComponents()[i].getFugacityCoefficient())))) { + if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { + system.getPhases()[0].getComponents()[i].setK(1e-40); + } else { + system.getPhases()[0].getComponents()[i].setK(Math.exp(Math + .log(system.getPhases()[1].getComponents()[i].getFugacityCoefficient()) + - Math.log(system.getPhases()[0].getComponents()[i].getFugacityCoefficient()))); + } } + system.getPhases()[1].getComponents()[i] + .setK(system.getPhases()[0].getComponents()[i].getK()); + system.getPhases()[0].getComponents()[i] + .setx(system.getPhases()[0].getComponents()[i].getK() + * system.getPhases()[1].getComponents()[i].getz()); + // logger.info("y err " + + // Math.abs(system.getPhases()[0].getComponents()[i].getx()-yold)); + } while (Math.abs(system.getPhases()[0].getComponents()[i].getx() - yold) / yold > 1e-8); + ktot += Math.abs(system.getPhases()[1].getComponents()[i].getK() - 1.0); + } + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + if (!Double.isNaN(system.getPhases()[0].getComponents()[i].getK())) { + system.getPhases()[0].getComponents()[i] + .setx(system.getPhases()[0].getComponents()[i].getK() + * system.getPhases()[1].getComponents()[i].getz()); + } else { + system.init(0); + logger.error("k err. : nan"); + } } ytotal = 0.0; for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - ytotal += system.getPhases()[0].getComponents()[i].getx(); + ytotal += system.getPhases()[0].getComponents()[i].getx(); } + // zlogger.info("ytot " + ytotal + " pres " + system.getPressure()); - double ktot = 0.0; - int chemIter = 0; - - do { - chemIter++; - oldChemPres = system.getPressure(); - iterations = 0; - do { - iterations++; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - system.getPhases()[0].getComponents()[i] - .setx(system.getPhases()[0].getComponents()[i].getx() / ytotal); - } - system.init(3); - oldPres = system.getPressure(); - ktot = 0.0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - do { - yold = system.getPhases()[0].getComponents()[i].getx(); - if (!Double.isNaN(Math.exp(Math.log( - system.getPhases()[1].getComponents()[i].getFugacityCoefficient()) - - Math.log(system.getPhases()[0].getComponents()[i] - .getFugacityCoefficient())))) { - if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { - system.getPhases()[0].getComponents()[i].setK(1e-40); - } else { - system.getPhases()[0].getComponents()[i].setK(Math.exp(Math - .log(system.getPhases()[1].getComponents()[i] - .getFugacityCoefficient()) - - Math.log(system.getPhases()[0].getComponents()[i] - .getFugacityCoefficient()))); - } - } - system.getPhases()[1].getComponents()[i] - .setK(system.getPhases()[0].getComponents()[i].getK()); - system.getPhases()[0].getComponents()[i] - .setx(system.getPhases()[0].getComponents()[i].getK() - * system.getPhases()[1].getComponents()[i].getz()); - // logger.info("y err " + - // Math.abs(system.getPhases()[0].getComponents()[i].getx()-yold)); - } while (Math.abs(system.getPhases()[0].getComponents()[i].getx() - yold) - / yold > 1e-8); - ktot += Math.abs(system.getPhases()[1].getComponents()[i].getK() - 1.0); - } - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - if (!Double.isNaN(system.getPhases()[0].getComponents()[i].getK())) { - system.getPhases()[0].getComponents()[i] - .setx(system.getPhases()[0].getComponents()[i].getK() - * system.getPhases()[1].getComponents()[i].getz()); - } else { - system.init(0); - logger.error("k err. : nan"); - } - } - - ytotal = 0.0; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - ytotal += system.getPhases()[0].getComponents()[i].getx(); - } - // zlogger.info("ytot " + ytotal + " pres " + system.getPressure()); - - // system.getPhase(0).normalize(); - - if (ytotal > 1.5) { - ytotal = 1.5; - } - if (ytotal < 0.5) { - ytotal = 0.5; - } - system.setPressure(system.getPressure() * ytotal);// + - // 0.5*(ytotal*system.getPressure()-system.getPressure())); - if (system.getPressure() < 0) { - system.setPressure(oldChemPres / 2.0); - run(); - return; - } - if (system.getPressure() > 5 * oldChemPres) { - system.setPressure(oldChemPres * 5); - run(); - return; - } - // logger.info("iter in bub calc " + iterations + " pres " + - // system.getPressure()+ " ytot " + ytotal + " chem iter " + chemIter); - } while (((((Math.abs(ytotal - 1.0)) > 1e-7) - || Math.abs(oldPres - system.getPressure()) / oldPres > 1e-6) - && (iterations < maxNumberOfIterations)) || iterations < 5); - - if (system.isChemicalSystem()) {// && (iterations%3)==0 && iterations<50){ - chemSolved = system.getChemicalReactionOperations().solveChemEq(1, 1); - system.setBeta(1, 1.0 - 1e-10); - system.setBeta(0, 1e-10); - } - // logger.info("iter in bub calc " + iterations + " pres " + - // system.getPressure()+ " chem iter " + chemIter); - } while ((Math.abs(oldChemPres - system.getPressure()) / oldChemPres > 1e-6 || chemIter < 2 - || !chemSolved) && chemIter < 20); - // if(system.getPressure()>300) system.setPressure(300.0); - // logger.info("iter in bub calc " + iterations + " pres " + - // system.getPressure()+ " chem iter " + chemIter); - // logger.info("iter " + iterations + " XTOT " +ytotal + " ktot " +ktot); - system.init(1); - if (Math.abs(ytotal - 1.0) > 1e-4 - || ktot < 1e-3 && system.getPhase(0).getNumberOfComponents() > 1) { - logger.info("ytot " + Math.abs(ytotal - 1.0)); - setSuperCritical(true); + // system.getPhase(0).normalize(); + + if (ytotal > 1.5) { + ytotal = 1.5; + } + if (ytotal < 0.5) { + ytotal = 0.5; } + system.setPressure(system.getPressure() * ytotal); // + + // 0.5*(ytotal*system.getPressure()-system.getPressure())); + if (system.getPressure() < 0) { + system.setPressure(oldChemPres / 2.0); + run(); + return; + } + if (system.getPressure() > 5 * oldChemPres) { + system.setPressure(oldChemPres * 5); + run(); + return; + } + // logger.info("iter in bub calc " + iterations + " pres " + + // system.getPressure()+ " ytot " + ytotal + " chem iter " + chemIter); + } while (((((Math.abs(ytotal - 1.0)) > 1e-7) + || Math.abs(oldPres - system.getPressure()) / oldPres > 1e-6) + && (iterations < maxNumberOfIterations)) || iterations < 5); + + if (system.isChemicalSystem()) {// && (iterations%3)==0 && iterations<50){ + chemSolved = system.getChemicalReactionOperations().solveChemEq(1, 1); + system.setBeta(1, 1.0 - 1e-10); + system.setBeta(0, 1e-10); + } + // logger.info("iter in bub calc " + iterations + " pres " + + // system.getPressure()+ " chem iter " + chemIter); + } while ((Math.abs(oldChemPres - system.getPressure()) / oldChemPres > 1e-6 || chemIter < 2 + || !chemSolved) && chemIter < 20); + // if(system.getPressure()>300) system.setPressure(300.0); + // logger.info("iter in bub calc " + iterations + " pres " + + // system.getPressure()+ " chem iter " + chemIter); + // logger.info("iter " + iterations + " XTOT " +ytotal + " ktot " +ktot); + system.init(1); + if (Math.abs(ytotal - 1.0) > 1e-4 + || ktot < 1e-3 && system.getPhase(0).getNumberOfComponents() > 1) { + logger.info("ytot " + Math.abs(ytotal - 1.0)); + setSuperCritical(true); } + } - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointPressureFlashDer.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointPressureFlashDer.java index f3faddc8bc..014c2725a3 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointPressureFlashDer.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointPressureFlashDer.java @@ -13,196 +13,195 @@ * @version $Id: $Id */ public class bubblePointPressureFlashDer extends constantDutyPressureFlash { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(bubblePointPressureFlashDer.class); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(bubblePointPressureFlashDer.class); - /** - *

- * Constructor for bubblePointPressureFlashDer. - *

- */ - public bubblePointPressureFlashDer() {} + /** + *

+ * Constructor for bubblePointPressureFlashDer. + *

+ */ + public bubblePointPressureFlashDer() {} - /** - *

- * Constructor for bubblePointPressureFlashDer. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public bubblePointPressureFlashDer(SystemInterface system) { - super(system); + /** + *

+ * Constructor for bubblePointPressureFlashDer. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public bubblePointPressureFlashDer(SystemInterface system) { + super(system); + } + + /** {@inheritDoc} */ + @Override + public void run() { + if (system.getPhase(0).getNumberOfComponents() == 1 + && system.getTemperature() > system.getPhase(0).getComponent(0).getTC()) { + setSuperCritical(true); } + int iterations = 0; + int maxNumberOfIterations = 500; + double yold = 0; + double ytotal = 1; + double deriv = 0; + double funk = 0; + boolean chemSolved = true; + // logger.info("starting"); + // system.setPressure(1.0); + system.init(0); + system.setNumberOfPhases(2); + system.setBeta(1, 1.0 - 1e-10); + system.setBeta(0, 1e-10); - /** {@inheritDoc} */ - @Override - public void run() { - if (system.getPhase(0).getNumberOfComponents() == 1 - && system.getTemperature() > system.getPhase(0).getComponent(0).getTC()) { - setSuperCritical(true); - } - int iterations = 0, maxNumberOfIterations = 500; - double yold = 0, ytotal = 1, deriv = 0, funk = 0; - boolean chemSolved = true; - // logger.info("starting"); - // system.setPressure(1.0); - system.init(0); - system.setNumberOfPhases(2); - system.setBeta(1, 1.0 - 1e-10); - system.setBeta(0, 1e-10); + double oldPres = 0; + double oldChemPres = 1; + if (system.isChemicalSystem()) { + // (1,1) changed to (1,0) by Neeraj. Also change at line 125 + system.getChemicalReactionOperations().solveChemEq(1, 0); + } - double oldPres = 0, oldChemPres = 1; - if (system.isChemicalSystem()) { - // (1,1) changed to (1,0) by Neeraj. Also change at line 125 - system.getChemicalReactionOperations().solveChemEq(1, 0); - } + for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + system.getPhases()[1].getComponents()[i] + .setx(system.getPhases()[0].getComponents()[i].getz()); + if (system.getPhases()[0].getComponents()[i].getIonicCharge() != 0) { + system.getPhases()[0].getComponents()[i].setx(1e-40); + } else { + system.getPhases()[0].getComponents()[i] + .setx(system.getPhases()[0].getComponents()[i].getK() + * system.getPhases()[1].getComponents()[i].getz()); + } + } + + ytotal = 0.0; + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + ytotal += system.getPhases()[0].getComponents()[i].getx(); + } + + double ktot = 0.0; + int chemIter = 0; + do { + chemIter++; + oldChemPres = system.getPressure(); + iterations = 0; + do { + iterations++; + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + system.getPhases()[0].getComponents()[i] + .setx(system.getPhases()[0].getComponents()[i].getx() / ytotal); + } + system.init(1); + oldPres = system.getPressure(); + ktot = 0.0; for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - system.getPhases()[1].getComponents()[i] - .setx(system.getPhases()[0].getComponents()[i].getz()); - if (system.getPhases()[0].getComponents()[i].getIonicCharge() != 0) { - system.getPhases()[0].getComponents()[i].setx(1e-40); - } else { - system.getPhases()[0].getComponents()[i] - .setx(system.getPhases()[0].getComponents()[i].getK() - * system.getPhases()[1].getComponents()[i].getz()); + do { + yold = system.getPhases()[0].getComponents()[i].getx(); + if (!Double.isNaN(Math.exp( + Math.log(system.getPhases()[1].getComponents()[i].getFugacityCoefficient()) - Math + .log(system.getPhases()[0].getComponents()[i].getFugacityCoefficient())))) { + if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { + system.getPhases()[0].getComponents()[i].setK(1e-40); + } else { + system.getPhases()[0].getComponents()[i].setK(Math.exp(Math + .log(system.getPhases()[1].getComponents()[i].getFugacityCoefficient()) + - Math.log(system.getPhases()[0].getComponents()[i].getFugacityCoefficient()))); + } } + system.getPhases()[1].getComponents()[i] + .setK(system.getPhases()[0].getComponents()[i].getK()); + system.getPhases()[0].getComponents()[i] + .setx(system.getPhases()[0].getComponents()[i].getK() + * system.getPhases()[1].getComponents()[i].getz()); + // logger.info("y err " + + // Math.abs(system.getPhases()[0].getComponents()[i].getx()-yold)); + } while (Math.abs(system.getPhases()[0].getComponents()[i].getx() - yold) / yold > 1e-8); + ktot += Math.abs(system.getPhases()[1].getComponents()[i].getK() - 1.0); + } + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + if (!Double.isNaN(system.getPhases()[0].getComponents()[i].getK())) { + system.getPhases()[0].getComponents()[i] + .setx(system.getPhases()[0].getComponents()[i].getK() + * system.getPhases()[1].getComponents()[i].getz()); + } else { + system.init(0); + logger.error("K error : nan"); + } } ytotal = 0.0; + deriv = 0.0; + funk = 0.0; for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - ytotal += system.getPhases()[0].getComponents()[i].getx(); + ytotal += system.getPhases()[0].getComponents()[i].getx(); + // Following lines added by Neeraj + funk += system.getPhases()[1].getComponents()[i].getx() + * system.getPhases()[1].getComponents()[i].getK(); + deriv += system.getPhases()[1].getComponents()[i].getx() + * system.getPhases()[1].getComponents()[i].getK() + * (system.getPhases()[1].getComponents()[i].logfugcoefdP(this.system.getPhase(1)) + - system.getPhases()[0].getComponents()[i].logfugcoefdP(this.system.getPhase(0))); } + // logger.info("ytot " + ytotal + " pres " + system.getPressure()); - double ktot = 0.0; - int chemIter = 0; - - do { - chemIter++; - oldChemPres = system.getPressure(); - iterations = 0; - do { - iterations++; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - system.getPhases()[0].getComponents()[i] - .setx(system.getPhases()[0].getComponents()[i].getx() / ytotal); - } - system.init(1); - oldPres = system.getPressure(); - ktot = 0.0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - do { - yold = system.getPhases()[0].getComponents()[i].getx(); - if (!Double.isNaN(Math.exp(Math.log( - system.getPhases()[1].getComponents()[i].getFugacityCoefficient()) - - Math.log(system.getPhases()[0].getComponents()[i] - .getFugacityCoefficient())))) { - if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { - system.getPhases()[0].getComponents()[i].setK(1e-40); - } else { - system.getPhases()[0].getComponents()[i].setK(Math.exp(Math - .log(system.getPhases()[1].getComponents()[i] - .getFugacityCoefficient()) - - Math.log(system.getPhases()[0].getComponents()[i] - .getFugacityCoefficient()))); - } - } - system.getPhases()[1].getComponents()[i] - .setK(system.getPhases()[0].getComponents()[i].getK()); - system.getPhases()[0].getComponents()[i] - .setx(system.getPhases()[0].getComponents()[i].getK() - * system.getPhases()[1].getComponents()[i].getz()); - // logger.info("y err " + - // Math.abs(system.getPhases()[0].getComponents()[i].getx()-yold)); - } while (Math.abs(system.getPhases()[0].getComponents()[i].getx() - yold) - / yold > 1e-8); - ktot += Math.abs(system.getPhases()[1].getComponents()[i].getK() - 1.0); - } - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - if (!Double.isNaN(system.getPhases()[0].getComponents()[i].getK())) { - system.getPhases()[0].getComponents()[i] - .setx(system.getPhases()[0].getComponents()[i].getK() - * system.getPhases()[1].getComponents()[i].getz()); - } else { - system.init(0); - logger.error("K error : nan"); - } - } - - ytotal = 0.0; - deriv = 0.0; - funk = 0.0; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - ytotal += system.getPhases()[0].getComponents()[i].getx(); - // Following lines added by Neeraj - funk += system.getPhases()[1].getComponents()[i].getx() - * system.getPhases()[1].getComponents()[i].getK(); - deriv += system.getPhases()[1].getComponents()[i].getx() - * system.getPhases()[1].getComponents()[i].getK() - * (system.getPhases()[1].getComponents()[i] - .logfugcoefdP(this.system.getPhase(1)) - - system.getPhases()[0].getComponents()[i] - .logfugcoefdP(this.system.getPhase(0))); - } - // logger.info("ytot " + ytotal + " pres " + system.getPressure()); - - // system.getPhase(0).normalize(); - // logger.info("deriv - // "+system.getPhases()[0].getComponents()[3].logfugcoefdP(this.system.getPhase(0))); - // logger.info("ytot "+ytotal); - if (ytotal > 1.5) { - ytotal = 1.5; - } - if (ytotal < 0.5) { - ytotal = 0.5; - } - - // Following line added by Neeraj - system.setPressure(system.getPressure() - (funk - 1) / deriv); - // Following line commented out by Neeraj - // system.setPressure(system.getPressure()*ytotal);// + - // 0.5*(ytotal*system.getPressure()-system.getPressure())); - if (system.getPressure() < 0) { - system.setPressure(oldChemPres / 2.0); - run(); - return; - } - if (system.getPressure() > 5 * oldChemPres) { - system.setPressure(oldChemPres * 5); - run(); - return; - } - // logger.info("iter in bub calc " + iterations + " pres " + - // system.getPressure()+ " ytot " + ytotal + " chem iter " + chemIter); - } while (((((Math.abs(ytotal - 1.0)) > 1e-7) - || Math.abs(oldPres - system.getPressure()) / oldPres > 1e-6) - && (iterations < maxNumberOfIterations)) || iterations < 5); + // system.getPhase(0).normalize(); + // logger.info("deriv + // "+system.getPhases()[0].getComponents()[3].logfugcoefdP(this.system.getPhase(0))); + // logger.info("ytot "+ytotal); + if (ytotal > 1.5) { + ytotal = 1.5; + } + if (ytotal < 0.5) { + ytotal = 0.5; + } - if (system.isChemicalSystem()) {// && (iterations%3)==0 && iterations<50){ - // Should also change -- Neeraj - chemSolved = system.getChemicalReactionOperations().solveChemEq(1, 0); - system.setBeta(1, 1.0 - 1e-10); - system.setBeta(0, 1e-10); - } - // logger.info("iter in bub calc " + iterations + " pres " + - // system.getPressure()+ " chem iter " + chemIter); - } while ((Math.abs(oldChemPres - system.getPressure()) / oldChemPres > 1e-6 || chemIter < 2 - || !chemSolved) && chemIter < 20); - // if(system.getPressure()>300) system.setPressure(300.0); - // logger.info("iter in bub calc " + iterations + " pres " + - // system.getPressure()+ " chem iter " + chemIter); - // logger.info("iter " + iterations + " XTOT " +ytotal + " ktot " +ktot); - system.init(1); - if (Math.abs(ytotal - 1.0) > 1e-4 - || ktot < 1e-3 && system.getPhase(0).getNumberOfComponents() > 1) { - logger.info("ytot " + Math.abs(ytotal - 1.0)); - // Print command added by Neeraj - logger.info("Supercritical vapor phase !!"); - setSuperCritical(true); + // Following line added by Neeraj + system.setPressure(system.getPressure() - (funk - 1) / deriv); + // Following line commented out by Neeraj + // system.setPressure(system.getPressure()*ytotal); // + + // 0.5*(ytotal*system.getPressure()-system.getPressure())); + if (system.getPressure() < 0) { + system.setPressure(oldChemPres / 2.0); + run(); + return; } + if (system.getPressure() > 5 * oldChemPres) { + system.setPressure(oldChemPres * 5); + run(); + return; + } + // logger.info("iter in bub calc " + iterations + " pres " + + // system.getPressure()+ " ytot " + ytotal + " chem iter " + chemIter); + } while (((((Math.abs(ytotal - 1.0)) > 1e-7) + || Math.abs(oldPres - system.getPressure()) / oldPres > 1e-6) + && (iterations < maxNumberOfIterations)) || iterations < 5); + + if (system.isChemicalSystem()) {// && (iterations%3)==0 && iterations<50){ + // Should also change -- Neeraj + chemSolved = system.getChemicalReactionOperations().solveChemEq(1, 0); + system.setBeta(1, 1.0 - 1e-10); + system.setBeta(0, 1e-10); + } + // logger.info("iter in bub calc " + iterations + " pres " + + // system.getPressure()+ " chem iter " + chemIter); + } while ((Math.abs(oldChemPres - system.getPressure()) / oldChemPres > 1e-6 || chemIter < 2 + || !chemSolved) && chemIter < 20); + // if(system.getPressure()>300) system.setPressure(300.0); + // logger.info("iter in bub calc " + iterations + " pres " + + // system.getPressure()+ " chem iter " + chemIter); + // logger.info("iter " + iterations + " XTOT " +ytotal + " ktot " +ktot); + system.init(1); + if (Math.abs(ytotal - 1.0) > 1e-4 + || ktot < 1e-3 && system.getPhase(0).getNumberOfComponents() > 1) { + logger.info("ytot " + Math.abs(ytotal - 1.0)); + // Print command added by Neeraj + logger.info("Supercritical vapor phase !!"); + setSuperCritical(true); } + } - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/calcSaltSatauration.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/calcSaltSatauration.java index c92891428b..3868669639 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/calcSaltSatauration.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/calcSaltSatauration.java @@ -13,127 +13,121 @@ * @version $Id: $Id */ public class calcSaltSatauration extends constantDutyTemperatureFlash { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(calcSaltSatauration.class); - String saltName; + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(calcSaltSatauration.class); + String saltName; - /** - *

- * Constructor for calcSaltSatauration. - *

- */ - public calcSaltSatauration() {} + /** + *

+ * Constructor for calcSaltSatauration. + *

+ */ + public calcSaltSatauration() {} - /** - *

- * Constructor for calcSaltSatauration. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param name a {@link java.lang.String} object - */ - public calcSaltSatauration(SystemInterface system, String name) { - super(system); - this.saltName = name; - logger.info("ok "); - } + /** + *

+ * Constructor for calcSaltSatauration. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param name a {@link java.lang.String} object + */ + public calcSaltSatauration(SystemInterface system, String name) { + super(system); + this.saltName = name; + logger.info("ok "); + } - /** {@inheritDoc} */ - @Override - public void run() { - double ksp = 0.0; - neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); - java.sql.ResultSet dataSet = - database.getResultSet("SELECT * FROM compsalt WHERE SaltName='" + saltName + "'"); - double stoc1 = 1e-20, stoc2 = 1e-20; - String name1 = ""; - String name2 = ""; - try { - dataSet.next(); - name1 = dataSet.getString("ion1").trim(); - name2 = dataSet.getString("ion2").trim(); - stoc1 = Double.parseDouble(dataSet.getString("stoc1")); - stoc2 = Double.parseDouble(dataSet.getString("stoc2")); - ksp = Double.parseDouble(dataSet.getString("Ksp-water")); - system.addComponent(name1, ksp / 100.0); - system.addComponent(name2, ksp / 100.0); - system.createDatabase(true); - } catch (Exception e) { - logger.error("failed " + e.toString()); - } + /** {@inheritDoc} */ + @Override + public void run() { + double ksp = 0.0; + neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); + java.sql.ResultSet dataSet = + database.getResultSet("SELECT * FROM compsalt WHERE SaltName='" + saltName + "'"); + double stoc1 = 1e-20; + double stoc2 = 1e-20; + String name1 = ""; + String name2 = ""; + try { + dataSet.next(); + name1 = dataSet.getString("ion1").trim(); + name2 = dataSet.getString("ion2").trim(); + stoc1 = Double.parseDouble(dataSet.getString("stoc1")); + stoc2 = Double.parseDouble(dataSet.getString("stoc2")); + ksp = Double.parseDouble(dataSet.getString("Ksp-water")); + system.addComponent(name1, ksp / 100.0); + system.addComponent(name2, ksp / 100.0); + system.createDatabase(true); + } catch (Exception e) { + logger.error("failed " + e.toString()); + } - system.init(0); - system.init(1); - system.initPhysicalProperties(); - double err = 1.0; - int iter = 1; - double kspcalc = 0.0, kspcalc1 = 0.0, kspcalc2 = 0.0; - do { - iter++; - double addnumb = 0.0; - // logger.info("testing"); + system.init(0); + system.init(1); + system.initPhysicalProperties(); + double err = 1.0; + int iter = 1; + double kspcalc = 0.0; + double kspcalc1 = 0.0; + double kspcalc2 = 0.0; + do { + iter++; + double addnumb = 0.0; + // logger.info("testing"); - system.addComponent(name1, 0.001);// *stoc1*constant*system.getPhase(1).getComponent(name1).getNumberOfMolesInPhase()); - system.addComponent(name2, 0.001); - // system.init(1); - system.init(0); - system.initPhysicalProperties(); - kspcalc1 = Math.pow( - system.getPhase(1).getComponent(name1).getx() - / system.getPhase(1).getMolarMass() - * system.getPhase(1).getPhysicalProperties().getDensity() / 1000.0, - stoc1) - * Math.pow(system.getPhase(1).getComponent(name2).getx() - / system.getPhase(1).getMolarMass() - * system.getPhase(1).getPhysicalProperties().getDensity() / 1000.0, - stoc2); + system.addComponent(name1, 0.001); // *stoc1*constant*system.getPhase(1).getComponent(name1).getNumberOfMolesInPhase()); + system.addComponent(name2, 0.001); + // system.init(1); + system.init(0); + system.initPhysicalProperties(); + kspcalc1 = Math + .pow(system.getPhase(1).getComponent(name1).getx() / system.getPhase(1).getMolarMass() + * system.getPhase(1).getPhysicalProperties().getDensity() / 1000.0, stoc1) + * Math + .pow(system.getPhase(1).getComponent(name2).getx() / system.getPhase(1).getMolarMass() + * system.getPhase(1).getPhysicalProperties().getDensity() / 1000.0, stoc2); - system.addComponent(name1, -2 * 0.001);// *stoc1*constant*system.getPhase(1).getComponent(name1).getNumberOfMolesInPhase()); - system.addComponent(name2, -2 * 0.001); - // system.init(1); - system.init(0); - system.initPhysicalProperties(); - kspcalc2 = Math.pow( - system.getPhase(1).getComponent(name1).getx() - / system.getPhase(1).getMolarMass() - * system.getPhase(1).getPhysicalProperties().getDensity() / 1000.0, - stoc1) - * Math.pow(system.getPhase(1).getComponent(name2).getx() - / system.getPhase(1).getMolarMass() - * system.getPhase(1).getPhysicalProperties().getDensity() / 1000.0, - stoc2); + system.addComponent(name1, -2 * 0.001); // *stoc1*constant*system.getPhase(1).getComponent(name1).getNumberOfMolesInPhase()); + system.addComponent(name2, -2 * 0.001); + // system.init(1); + system.init(0); + system.initPhysicalProperties(); + kspcalc2 = Math + .pow(system.getPhase(1).getComponent(name1).getx() / system.getPhase(1).getMolarMass() + * system.getPhase(1).getPhysicalProperties().getDensity() / 1000.0, stoc1) + * Math + .pow(system.getPhase(1).getComponent(name2).getx() / system.getPhase(1).getMolarMass() + * system.getPhase(1).getPhysicalProperties().getDensity() / 1000.0, stoc2); - system.addComponent(name1, 0.001);// *stoc1*constant*system.getPhase(1).getComponent(name1).getNumberOfMolesInPhase()); - system.addComponent(name2, 0.001); - // system.init(1); - system.init(0); - system.initPhysicalProperties(); - kspcalc = Math.pow( - system.getPhase(1).getComponent(name1).getx() - / system.getPhase(1).getMolarMass() - * system.getPhase(1).getPhysicalProperties().getDensity() / 1000.0, - stoc1) - * Math.pow(system.getPhase(1).getComponent(name2).getx() - / system.getPhase(1).getMolarMass() - * system.getPhase(1).getPhysicalProperties().getDensity() / 1000.0, - stoc2); + system.addComponent(name1, 0.001); // *stoc1*constant*system.getPhase(1).getComponent(name1).getNumberOfMolesInPhase()); + system.addComponent(name2, 0.001); + // system.init(1); + system.init(0); + system.initPhysicalProperties(); + kspcalc = Math + .pow(system.getPhase(1).getComponent(name1).getx() / system.getPhase(1).getMolarMass() + * system.getPhase(1).getPhysicalProperties().getDensity() / 1000.0, stoc1) + * Math + .pow(system.getPhase(1).getComponent(name2).getx() / system.getPhase(1).getMolarMass() + * system.getPhase(1).getPhysicalProperties().getDensity() / 1000.0, stoc2); - double diff = (kspcalc1 - kspcalc2) / 0.002; - // logger.info("diff " + diff); - err = (kspcalc - ksp); - addnumb = -(err / diff); - logger.info("kspcalc " + kspcalc + " err " + err + " add " + addnumb); - system.addComponent(name1, iter / 100.0 * addnumb);// *stoc1*constant*system.getPhase(1).getComponent(name1).getNumberOfMolesInPhase()); - system.addComponent(name2, iter / 100.0 * addnumb); - // system.init(1); - system.init(0); - system.initPhysicalProperties(); - } while (Math.abs(err / ksp) > 1e-5 && iter < 1000); + double diff = (kspcalc1 - kspcalc2) / 0.002; + // logger.info("diff " + diff); + err = (kspcalc - ksp); + addnumb = -(err / diff); + logger.info("kspcalc " + kspcalc + " err " + err + " add " + addnumb); + system.addComponent(name1, iter / 100.0 * addnumb); // *stoc1*constant*system.getPhase(1).getComponent(name1).getNumberOfMolesInPhase()); + system.addComponent(name2, iter / 100.0 * addnumb); + // system.init(1); + system.init(0); + system.initPhysicalProperties(); + } while (Math.abs(err / ksp) > 1e-5 && iter < 1000); - logger.info("solution found after " + iter + " iterations in calcSaltSatauration()"); - } + logger.info("solution found after " + iter + " iterations in calcSaltSatauration()"); + } - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/checkScalePotential.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/checkScalePotential.java index d147472c87..f2e777dbd0 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/checkScalePotential.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/checkScalePotential.java @@ -13,215 +13,198 @@ * @version $Id: $Id */ public class checkScalePotential extends constantDutyTemperatureFlash { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(checkScalePotential.class); - - String saltName; - int phaseNumber = 1; - String[][] resultTable = null; - - /** - *

- * Constructor for checkScalePotential. - *

- */ - public checkScalePotential() {} - - /** - *

- * Constructor for checkScalePotential. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param phaseNumber a int - */ - public checkScalePotential(SystemInterface system, int phaseNumber) { - super(system); - this.phaseNumber = phaseNumber; - logger.info("ok "); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(checkScalePotential.class); + + String saltName; + int phaseNumber = 1; + String[][] resultTable = null; + + /** + *

+ * Constructor for checkScalePotential. + *

+ */ + public checkScalePotential() {} + + /** + *

+ * Constructor for checkScalePotential. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param phaseNumber a int + */ + public checkScalePotential(SystemInterface system, int phaseNumber) { + super(system); + this.phaseNumber = phaseNumber; + logger.info("ok "); + } + + /** {@inheritDoc} */ + @Override + public void run() { + double ksp = 0.0; + neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); + java.sql.ResultSet dataSet = database.getResultSet("SELECT * FROM compsalt"); + resultTable = new String[10][3]; + double stoc1 = 1e-20; + double stoc2 = 1e-20; + String saltName = ""; + String name1 = ""; + String name2 = ""; + int numb = 0; + + for (int i = 0; i < 10; i++) { + for (int j = 0; j < 3; j++) { + resultTable[i][j] = ""; + } } - /** {@inheritDoc} */ - @Override - public void run() { - double ksp = 0.0; - neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); - java.sql.ResultSet dataSet = database.getResultSet("SELECT * FROM compsalt"); - resultTable = new String[10][3]; - double stoc1 = 1e-20, stoc2 = 1e-20; - String saltName = ""; - String name1 = ""; - String name2 = ""; - int numb = 0; - - for (int i = 0; i < 10; i++) { - for (int j = 0; j < 3; j++) { - resultTable[i][j] = ""; - } + resultTable[0][0] = "Salt"; + resultTable[0][1] = "relative solubility"; + resultTable[0][2] = ""; + + double numberOfMolesMEG = 0.0; + + try { + if (system.getPhase(phaseNumber).hasComponent("MEG")) { + numberOfMolesMEG = + system.getPhase(phaseNumber).getComponent("MEG").getNumberOfMolesInPhase(); + system.addComponent("MEG", -numberOfMolesMEG * 0.9999, phaseNumber); + system.addComponent("water", numberOfMolesMEG, phaseNumber); + system.init(1); + system.getChemicalReactionOperations().solveChemEq(phaseNumber, 1); + } + while (dataSet.next()) { + saltName = dataSet.getString("SaltName").trim(); + name1 = dataSet.getString("ion1").trim(); + name2 = dataSet.getString("ion2").trim(); + + stoc1 = Double.parseDouble(dataSet.getString("stoc1")); + stoc2 = Double.parseDouble(dataSet.getString("stoc2")); + double temperatureC = system.getPhase(phaseNumber).getTemperature(); + double lnKsp = Double.parseDouble(dataSet.getString("Kspwater")) / temperatureC + + Double.parseDouble(dataSet.getString("Kspwater2")) + + Math.log(temperatureC) * Double.parseDouble(dataSet.getString("Kspwater3")) + + temperatureC * Double.parseDouble(dataSet.getString("Kspwater4")) + + Double.parseDouble(dataSet.getString("Kspwater5")) / (temperatureC * temperatureC); + ksp = Math.exp(lnKsp); + + if (saltName.equals("NaCl")) { + ksp = -814.18 + 7.4685 * temperatureC - 2.3262e-2 * temperatureC * temperatureC + + 3.0536e-5 * Math.pow(temperatureC, 3.0) - 1.4573e-8 * Math.pow(temperatureC, 4.0); } - - resultTable[0][0] = "Salt"; - resultTable[0][1] = "relative solubility"; - resultTable[0][2] = ""; - - double numberOfMolesMEG = 0.0; - - try { - if (system.getPhase(phaseNumber).hasComponent("MEG")) { - numberOfMolesMEG = - system.getPhase(phaseNumber).getComponent("MEG").getNumberOfMolesInPhase(); - system.addComponent("MEG", -numberOfMolesMEG * 0.9999, phaseNumber); - system.addComponent("water", numberOfMolesMEG, phaseNumber); - system.init(1); - system.getChemicalReactionOperations().solveChemEq(phaseNumber, 1); - } - while (dataSet.next()) { - saltName = dataSet.getString("SaltName").trim(); - name1 = dataSet.getString("ion1").trim(); - name2 = dataSet.getString("ion2").trim(); - - stoc1 = Double.parseDouble(dataSet.getString("stoc1")); - stoc2 = Double.parseDouble(dataSet.getString("stoc2")); - double temperatureC = system.getPhase(phaseNumber).getTemperature(); - double lnKsp = Double.parseDouble(dataSet.getString("Kspwater")) / temperatureC - + Double.parseDouble(dataSet.getString("Kspwater2")) - + Math.log(temperatureC) - * Double.parseDouble(dataSet.getString("Kspwater3")) - + temperatureC * Double.parseDouble(dataSet.getString("Kspwater4")) - + Double.parseDouble(dataSet.getString("Kspwater5")) - / (temperatureC * temperatureC); - ksp = Math.exp(lnKsp); - - if (saltName.equals("NaCl")) { - ksp = -814.18 + 7.4685 * temperatureC - 2.3262e-2 * temperatureC * temperatureC - + 3.0536e-5 * Math.pow(temperatureC, 3.0) - - 1.4573e-8 * Math.pow(temperatureC, 4.0); - } - if (saltName.equals("FeS")) { - int waterompNumb = - system.getPhase(phaseNumber).getComponent("water").getComponentNumber(); - double h3ox = system.getPhase(phaseNumber).getComponent("H3O+").getx() - / (system.getPhase(phaseNumber).getComponent(waterompNumb).getx() - * system.getPhase(phaseNumber).getComponent(waterompNumb) - .getMolarMass()); - - ksp *= h3ox; - } - - if (system.getPhase(phaseNumber).hasComponent(name1) - && system.getPhase(phaseNumber).hasComponent(name2)) { - numb++; - logger.info("reaction added: " + name1 + " " + name2); - logger.info("theoretic Ksp = " + ksp); - logger.info("theoretic lnKsp = " + Math.log(ksp)); - int compNumb1 = - system.getPhase(phaseNumber).getComponent(name1).getComponentNumber(); - int compNumb2 = - system.getPhase(phaseNumber).getComponent(name2).getComponentNumber(); - int waterompNumb = - system.getPhase(phaseNumber).getComponent("water").getComponentNumber(); - - double x1 = system.getPhase(phaseNumber).getComponent(name1).getx() - / (system.getPhase(phaseNumber).getComponent(waterompNumb).getx() - * system.getPhase(phaseNumber).getComponent(waterompNumb) - .getMolarMass()); - double x2 = system.getPhase(phaseNumber).getComponent(name2).getx() - / (system.getPhase(phaseNumber).getComponent(waterompNumb).getx() - * system.getPhase(phaseNumber).getComponent(waterompNumb) - .getMolarMass()); - double kspReac = Math - .pow(system.getPhase(phaseNumber).getActivityCoefficient(compNumb1, - waterompNumb) * x1, stoc1) - * Math.pow( - x2 * system.getPhase(phaseNumber) - .getActivityCoefficient(compNumb2, waterompNumb), - stoc2); - // double kspReac = - // Math.pow(system.getPhase(phaseNumber).getActivityCoefficient(compNumb1) * x1, - // stoc1) * Math.pow(x2 * - // system.getPhase(phaseNumber).getActivityCoefficient(compNumb2), stoc2); - - double stocKsp = Math.pow(x1, stoc1) * Math.pow(x2, stoc2); - - if (saltName.contains("hydromagnesite (3MgCO3-Mg(OH)2-3H2O)")) { - x1 = system.getPhase(phaseNumber).getComponent(name1).getx() - / (system.getPhase(phaseNumber).getComponent(waterompNumb).getx() - * system.getPhase(phaseNumber).getComponent(waterompNumb) - .getMolarMass()); - x2 = system.getPhase(phaseNumber).getComponent(name2).getx() - / (system.getPhase(phaseNumber).getComponent(waterompNumb).getx() - * system.getPhase(phaseNumber).getComponent(waterompNumb) - .getMolarMass()); - double x3 = system.getPhase(phaseNumber).getComponent(waterompNumb).getx() - / (system.getPhase(phaseNumber).getComponent(waterompNumb).getx() - * system.getPhase(phaseNumber).getComponent(waterompNumb) - .getMolarMass()); - double x4 = system.getPhase(phaseNumber).getComponent("OH-").getx() - / (system.getPhase(phaseNumber).getComponent(waterompNumb).getx() - * system.getPhase(phaseNumber).getComponent(waterompNumb) - .getMolarMass()); - kspReac = Math - .pow(system.getPhase(phaseNumber).getActivityCoefficient(compNumb1, - waterompNumb) * x1, stoc1) - * Math.pow( - x2 * system.getPhase(phaseNumber) - .getActivityCoefficient(compNumb2, waterompNumb), - stoc2) - * Math.pow( - x3 * system.getPhase(phaseNumber) - .getActivityCoefficient(waterompNumb, waterompNumb), - 3.0) - * Math.pow(x4 * system.getPhase(phaseNumber) - .getActivityCoefficient(system.getPhase(phaseNumber) - .getComponent("OH-").getComponentNumber(), - waterompNumb), - 2.0); - stocKsp = Math.pow(x1, stoc1) * Math.pow(x2, stoc2) * Math.pow(x3, 3) - * Math.pow(x4, 2); - } - - logger.info("calc Ksp " + kspReac); - logger.info("stoc Ksp " + stocKsp); - logger.info("activity " + kspReac / stocKsp); - logger.info("mol/kg " + x1); - - double scalePotentialFactor = kspReac / ksp; - logger.info("Scale potential factor " + scalePotentialFactor); - - resultTable[numb][0] = saltName;// name1+ " " +name2; - resultTable[numb][1] = Double.toString(scalePotentialFactor); - resultTable[numb][2] = ""; - // double maxn = scalePotentialFactor/(stoc1*stoc2); - - // double x1max =system.getPhase(phaseNumber).getComponent(name1).getx()/maxn; - // double x2max =system.getPhase(phaseNumber).getComponent(name2).getx()/maxn; - } - } - } catch (Exception e) { - logger.error("failed " + e.toString()); - - if (system.getPhase(phaseNumber).hasComponent("MEG")) { - system.addComponent("MEG", numberOfMolesMEG * 0.9999, phaseNumber); - system.addComponent("water", -numberOfMolesMEG, phaseNumber); - system.init(1); - system.getChemicalReactionOperations().solveChemEq(phaseNumber, 1); - } + if (saltName.equals("FeS")) { + int waterompNumb = + system.getPhase(phaseNumber).getComponent("water").getComponentNumber(); + double h3ox = system.getPhase(phaseNumber).getComponent("H3O+").getx() + / (system.getPhase(phaseNumber).getComponent(waterompNumb).getx() + * system.getPhase(phaseNumber).getComponent(waterompNumb).getMolarMass()); + + ksp *= h3ox; } - } - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} - - /** {@inheritDoc} */ - @Override - public String[][] getResultTable() { - logger.info("checking table...scale " + resultTable[0][0]); - logger.info("checking table...scale " + resultTable[0][1]); - logger.info("checking table...scale " + resultTable[0][2]); - logger.info("checking table...scale " + resultTable[1][0]); - logger.info("checking table...scale " + resultTable[1][1]); - logger.info("checking table...scale " + resultTable[1][2]); - return resultTable; + if (system.getPhase(phaseNumber).hasComponent(name1) + && system.getPhase(phaseNumber).hasComponent(name2)) { + numb++; + logger.info("reaction added: " + name1 + " " + name2); + logger.info("theoretic Ksp = " + ksp); + logger.info("theoretic lnKsp = " + Math.log(ksp)); + int compNumb1 = system.getPhase(phaseNumber).getComponent(name1).getComponentNumber(); + int compNumb2 = system.getPhase(phaseNumber).getComponent(name2).getComponentNumber(); + int waterompNumb = + system.getPhase(phaseNumber).getComponent("water").getComponentNumber(); + + double x1 = system.getPhase(phaseNumber).getComponent(name1).getx() + / (system.getPhase(phaseNumber).getComponent(waterompNumb).getx() + * system.getPhase(phaseNumber).getComponent(waterompNumb).getMolarMass()); + double x2 = system.getPhase(phaseNumber).getComponent(name2).getx() + / (system.getPhase(phaseNumber).getComponent(waterompNumb).getx() + * system.getPhase(phaseNumber).getComponent(waterompNumb).getMolarMass()); + double kspReac = Math.pow( + system.getPhase(phaseNumber).getActivityCoefficient(compNumb1, waterompNumb) * x1, + stoc1) + * Math.pow( + x2 * system.getPhase(phaseNumber).getActivityCoefficient(compNumb2, waterompNumb), + stoc2); + // double kspReac = + // Math.pow(system.getPhase(phaseNumber).getActivityCoefficient(compNumb1) * x1, + // stoc1) * Math.pow(x2 * + // system.getPhase(phaseNumber).getActivityCoefficient(compNumb2), stoc2); + + double stocKsp = Math.pow(x1, stoc1) * Math.pow(x2, stoc2); + + if (saltName.contains("hydromagnesite (3MgCO3-Mg(OH)2-3H2O)")) { + x1 = system.getPhase(phaseNumber).getComponent(name1).getx() + / (system.getPhase(phaseNumber).getComponent(waterompNumb).getx() + * system.getPhase(phaseNumber).getComponent(waterompNumb).getMolarMass()); + x2 = system.getPhase(phaseNumber).getComponent(name2).getx() + / (system.getPhase(phaseNumber).getComponent(waterompNumb).getx() + * system.getPhase(phaseNumber).getComponent(waterompNumb).getMolarMass()); + double x3 = system.getPhase(phaseNumber).getComponent(waterompNumb).getx() + / (system.getPhase(phaseNumber).getComponent(waterompNumb).getx() + * system.getPhase(phaseNumber).getComponent(waterompNumb).getMolarMass()); + double x4 = system.getPhase(phaseNumber).getComponent("OH-").getx() + / (system.getPhase(phaseNumber).getComponent(waterompNumb).getx() + * system.getPhase(phaseNumber).getComponent(waterompNumb).getMolarMass()); + kspReac = Math + .pow(system.getPhase(phaseNumber).getActivityCoefficient(compNumb1, waterompNumb) + * x1, stoc1) + * Math.pow(x2 + * system.getPhase(phaseNumber).getActivityCoefficient(compNumb2, waterompNumb), + stoc2) + * Math + .pow(x3 * system.getPhase(phaseNumber).getActivityCoefficient(waterompNumb, + waterompNumb), 3.0) + * Math.pow(x4 * system.getPhase(phaseNumber).getActivityCoefficient( + system.getPhase(phaseNumber).getComponent("OH-").getComponentNumber(), + waterompNumb), 2.0); + stocKsp = Math.pow(x1, stoc1) * Math.pow(x2, stoc2) * Math.pow(x3, 3) * Math.pow(x4, 2); + } + + logger.info("calc Ksp " + kspReac); + logger.info("stoc Ksp " + stocKsp); + logger.info("activity " + kspReac / stocKsp); + logger.info("mol/kg " + x1); + + double scalePotentialFactor = kspReac / ksp; + logger.info("Scale potential factor " + scalePotentialFactor); + + resultTable[numb][0] = saltName; // name1+ " " +name2; + resultTable[numb][1] = Double.toString(scalePotentialFactor); + resultTable[numb][2] = ""; + // double maxn = scalePotentialFactor/(stoc1*stoc2); + + // double x1max =system.getPhase(phaseNumber).getComponent(name1).getx()/maxn; + // double x2max =system.getPhase(phaseNumber).getComponent(name2).getx()/maxn; + } + } + } catch (Exception e) { + logger.error("failed " + e.toString()); + + if (system.getPhase(phaseNumber).hasComponent("MEG")) { + system.addComponent("MEG", numberOfMolesMEG * 0.9999, phaseNumber); + system.addComponent("water", -numberOfMolesMEG, phaseNumber); + system.init(1); + system.getChemicalReactionOperations().solveChemEq(phaseNumber, 1); + } } + } + + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} + + /** {@inheritDoc} */ + @Override + public String[][] getResultTable() { + logger.info("checking table...scale " + resultTable[0][0]); + logger.info("checking table...scale " + resultTable[0][1]); + logger.info("checking table...scale " + resultTable[0][2]); + logger.info("checking table...scale " + resultTable[1][0]); + logger.info("checking table...scale " + resultTable[1][1]); + logger.info("checking table...scale " + resultTable[1][2]); + return resultTable; + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondebarFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondebarFlash.java index 74464c0564..e7b917b63b 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondebarFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondebarFlash.java @@ -86,7 +86,7 @@ public double initMoleFraction() { - system.getPhase(1).getComponent(i).getLogFugacityCoefficient()); // sumX += XI[i]; } - double tempSumXI = 1.0;// sumX; + double tempSumXI = 1.0; // sumX; for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { system.getPhase(1).getComponent(i).setx(XI[i] / tempSumXI); } @@ -241,7 +241,7 @@ public void run() { logger.info("temp " + system.getTemperature() + "dewTemp " + dewTemp + " Q1 " + Q1 + " pressure " + system.getPressure()); - } while (Math.abs(Q1) > 1e-10 && iterations < 15);// maxNumberOfIterations); + } while (Math.abs(Q1) > 1e-10 && iterations < 15); // maxNumberOfIterations); logger.info("temp " + system.getTemperature() + " Q1 " + Q1); // if(ii<2) system.setTemperature(dewTemp-); logger.info("fvec " + fvec.norm2() + " pressure " + system.getPressure()); @@ -280,7 +280,7 @@ public void setJac() { for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { for (int j = 0; j < system.getPhase(0).getNumberOfComponents(); j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta + dij = i == j ? 1.0 : 0.0; // Kroneckers delta tempJ = -dij * 1.0 / system.getPhases()[1].getComponents()[i].getx() - system.getPhases()[1].getComponents()[i].getdfugdx(j); Jac.set(i, j, tempJ); diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp.java index 9f74564a56..0760d0f26a 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp.java @@ -98,7 +98,7 @@ public void setJac() { double tempJ = 0.0; for (int i = 0; i < numberOfComponents; i++) { for (int j = 0; j < numberOfComponents; j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta + dij = i == j ? 1.0 : 0.0; // Kroneckers delta tempJ = 1.0 / system.getBeta() * (dij / system.getPhases()[0].getComponents()[i].getx() - 1.0 + system.getPhases()[0].getComponents()[i].getdfugdx(j)) diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp1.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp1.java index 8569a03781..371f23d892 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp1.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp1.java @@ -12,238 +12,250 @@ * @version $Id: $Id */ public class cricondenBarTemp1 implements java.io.Serializable { - private static final long serialVersionUID = 1000; - - int neq = 0, iter = 0; - int ic02p = -100, ic03p = -100, testcrit = 0, npCrit = 0; - double beta = 0, ds = 0, dTmax = 1, dPmax = 1, avscp = 0.1, TC1 = 0, TC2 = 0, PC1 = 0, PC2 = 0; - Matrix Jac; - Matrix fvec; - Matrix u; - Matrix uold; - Matrix Xgij; - SystemInterface system; - int numberOfComponents; - int speceq = 0; - Matrix a = new Matrix(4, 4); - Matrix s = new Matrix(1, 4); - Matrix xg; - Matrix dx; - Matrix xcoef; - - /** - *

- * Constructor for cricondenBarTemp1. - *

- */ - public cricondenBarTemp1() {} - - /** - *

- * Constructor for cricondenBarTemp1. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public cricondenBarTemp1(SystemInterface system) { - this.system = system; - this.numberOfComponents = system.getPhase(0).getNumberOfComponents(); - neq = numberOfComponents; - Jac = new Matrix(neq + 2, neq + 2); - fvec = new Matrix(neq + 2, 1); - u = new Matrix(neq + 2, 1); - Xgij = new Matrix(neq + 2, 4); - setu(); - uold = u.copy(); - // System.out.println("Spec : " +speceq); - } + private static final long serialVersionUID = 1000; - /** - *

- * Setter for the field fvec. - *

- */ - public void setfvec() { - double xtot = 0.0, dQdT = 0; - for (int i = 0; i < numberOfComponents; i++) { - xtot += system.getPhase(1).getComponent(i).getx(); - dQdT -= system.getPhase(1).getComponent(i).getx() - * (system.getPhase(0).getComponent(i).getdfugdt() - - system.getPhase(1).getComponent(i).getdfugdt()); - fvec.set(i, 0, Math - .log(system.getPhase(0).getComponents()[i].getFugacityCoefficient() - * system.getPhase(0).getComponents()[i].getz() * system.getPressure()) - - Math.log(system.getPhases()[1].getComponents()[i].getFugacityCoefficient() - * system.getPhases()[1].getComponents()[i].getx() - * system.getPressure())); - } - fvec.set(numberOfComponents, 0, 1.0 - xtot); - fvec.set(numberOfComponents + 1, 0, dQdT); - } + int neq = 0; + int iter = 0; + int ic02p = -100; + int ic03p = -100; + int testcrit = 0; + int npCrit = 0; + double beta = 0; + double ds = 0; + double dTmax = 1; + double dPmax = 1; + double avscp = 0.1; + double TC1 = 0; + double TC2 = 0; + double PC1 = 0; + double PC2 = 0; - /** - *

- * setJac. - *

- */ - public void setJac() { - Jac.timesEquals(0.0); - double dij = 0.0; - - double tempJ = 0.0; - // double sumdyidbeta = 0, sumdxidbeta = 0; - // int nofc = numberOfComponents; - - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < numberOfComponents; j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta - tempJ = 1.0 / system.getBeta() - * (dij / system.getPhases()[0].getComponents()[i].getx() - 1.0 - + system.getPhases()[0].getComponents()[i].getdfugdx(j)) - + 1.0 / (1.0 - system.getBeta()) - * (dij / system.getPhases()[1].getComponents()[i].getx() - 1.0 - + system.getPhases()[1].getComponents()[i].getdfugdx(j)); - Jac.set(i, j, tempJ); - } - } - } + Matrix Jac; + Matrix fvec; + Matrix u; + Matrix uold; + Matrix Xgij; + SystemInterface system; + int numberOfComponents; + int speceq = 0; + Matrix a = new Matrix(4, 4); + Matrix s = new Matrix(1, 4); + Matrix xg; + Matrix dx; + Matrix xcoef; - /** - *

- * Setter for the field u. - *

- */ - public void setu() { - for (int i = 0; i < numberOfComponents; i++) { - u.set(i, 0, system.getBeta() * system.getPhases()[0].getComponents()[i].getx()); - } - } + /** + *

+ * Constructor for cricondenBarTemp1. + *

+ */ + public cricondenBarTemp1() {} - /** - *

- * init. - *

- */ - public void init() { - double temp = 0; - - for (int i = 0; i < numberOfComponents; i++) { - temp += u.get(i, 0); - } - system.setBeta(temp); - for (int i = 0; i < numberOfComponents; i++) { - system.getPhases()[0].getComponents()[i].setx(u.get(i, 0) / system.getBeta()); - system.getPhases()[1].getComponents()[i] - .setx((system.getPhases()[0].getComponents()[i].getz() - u.get(i, 0)) - / (1.0 - system.getBeta())); - system.getPhases()[0].getComponents()[i] - .setK(system.getPhases()[0].getComponents()[i].getx() - / system.getPhases()[1].getComponents()[i].getx()); - system.getPhases()[1].getComponents()[i] - .setK(system.getPhases()[0].getComponents()[i].getK()); - } - - system.init(3); - } + /** + *

+ * Constructor for cricondenBarTemp1. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public cricondenBarTemp1(SystemInterface system) { + this.system = system; + this.numberOfComponents = system.getPhase(0).getNumberOfComponents(); + neq = numberOfComponents; + Jac = new Matrix(neq + 2, neq + 2); + fvec = new Matrix(neq + 2, 1); + u = new Matrix(neq + 2, 1); + Xgij = new Matrix(neq + 2, 4); + setu(); + uold = u.copy(); + // System.out.println("Spec : " +speceq); + } - /** - *

- * solve. - *

- * - * @return a double - */ - public double solve() { - iter++; - init(); - setfvec(); - setJac(); - dx = Jac.solve(fvec); - dx.print(10, 10); - u.minusEquals(dx); - return (dx.norm2() / u.norm2()); + /** + *

+ * Setter for the field fvec. + *

+ */ + public void setfvec() { + double xtot = 0.0; + double dQdT = 0; + for (int i = 0; i < numberOfComponents; i++) { + xtot += system.getPhase(1).getComponent(i).getx(); + dQdT -= system.getPhase(1).getComponent(i).getx() + * (system.getPhase(0).getComponent(i).getdfugdt() + - system.getPhase(1).getComponent(i).getdfugdt()); + fvec.set(i, 0, + Math.log(system.getPhase(0).getComponents()[i].getFugacityCoefficient() + * system.getPhase(0).getComponents()[i].getz() * system.getPressure()) + - Math.log(system.getPhases()[1].getComponents()[i].getFugacityCoefficient() + * system.getPhases()[1].getComponents()[i].getx() * system.getPressure())); } + fvec.set(numberOfComponents, 0, 1.0 - xtot); + fvec.set(numberOfComponents + 1, 0, dQdT); + } - /** - *

- * run. - *

- */ - public void run() { - solve(); - } + /** + *

+ * setJac. + *

+ */ + public void setJac() { + Jac.timesEquals(0.0); + double dij = 0.0; - /** - *

- * getJFreeChart. - *

- * - * @param name a {@link java.lang.String} object - * @return a {@link org.jfree.chart.JFreeChart} object - */ - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - return null; - } + double tempJ = 0.0; + // double sumdyidbeta = 0, sumdxidbeta = 0; + // int nofc = numberOfComponents; - /** - *

- * get. - *

- * - * @param name a {@link java.lang.String} object - * @return an array of {@link double} objects - */ - public double[] get(String name) { - return new double[0]; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < numberOfComponents; j++) { + dij = i == j ? 1.0 : 0.0; // Kroneckers delta + tempJ = 1.0 / system.getBeta() + * (dij / system.getPhases()[0].getComponents()[i].getx() - 1.0 + + system.getPhases()[0].getComponents()[i].getdfugdx(j)) + + 1.0 / (1.0 - system.getBeta()) + * (dij / system.getPhases()[1].getComponents()[i].getx() - 1.0 + + system.getPhases()[1].getComponents()[i].getdfugdx(j)); + Jac.set(i, j, tempJ); + } } + } - /** - *

- * printToFile. - *

- * - * @param name a {@link java.lang.String} object - */ - public void printToFile(String name) {} - - /** - *

- * displayResult. - *

- */ - public void displayResult() {} - - /** - *

- * getPoints. - *

- * - * @param i a int - * @return an array of {@link double} objects - */ - public double[][] getPoints(int i) { - return null; + /** + *

+ * Setter for the field u. + *

+ */ + public void setu() { + for (int i = 0; i < numberOfComponents; i++) { + u.set(i, 0, system.getBeta() * system.getPhases()[0].getComponents()[i].getx()); } + } - /** - *

- * getResultTable. - *

- * - * @return an array of {@link java.lang.String} objects - */ - public String[][] getResultTable() { - return null; - } + /** + *

+ * init. + *

+ */ + public void init() { + double temp = 0; - /** - *

- * getThermoSystem. - *

- * - * @return a {@link neqsim.thermo.system.SystemInterface} object - */ - public SystemInterface getThermoSystem() { - return system; + for (int i = 0; i < numberOfComponents; i++) { + temp += u.get(i, 0); } + system.setBeta(temp); + for (int i = 0; i < numberOfComponents; i++) { + system.getPhases()[0].getComponents()[i].setx(u.get(i, 0) / system.getBeta()); + system.getPhases()[1].getComponents()[i] + .setx((system.getPhases()[0].getComponents()[i].getz() - u.get(i, 0)) + / (1.0 - system.getBeta())); + system.getPhases()[0].getComponents()[i].setK(system.getPhases()[0].getComponents()[i].getx() + / system.getPhases()[1].getComponents()[i].getx()); + system.getPhases()[1].getComponents()[i] + .setK(system.getPhases()[0].getComponents()[i].getK()); + } + + system.init(3); + } + + /** + *

+ * solve. + *

+ * + * @return a double + */ + public double solve() { + iter++; + init(); + setfvec(); + setJac(); + dx = Jac.solve(fvec); + dx.print(10, 10); + u.minusEquals(dx); + return (dx.norm2() / u.norm2()); + } + + /** + *

+ * run. + *

+ */ + public void run() { + solve(); + } + + /** + *

+ * getJFreeChart. + *

+ * + * @param name a {@link java.lang.String} object + * @return a {@link org.jfree.chart.JFreeChart} object + */ + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + return null; + } + + /** + *

+ * get. + *

+ * + * @param name a {@link java.lang.String} object + * @return an array of {@link double} objects + */ + public double[] get(String name) { + return new double[0]; + } + + /** + *

+ * printToFile. + *

+ * + * @param name a {@link java.lang.String} object + */ + public void printToFile(String name) {} + + /** + *

+ * displayResult. + *

+ */ + public void displayResult() {} + + /** + *

+ * getPoints. + *

+ * + * @param i a int + * @return an array of {@link double} objects + */ + public double[][] getPoints(int i) { + return null; + } + + /** + *

+ * getResultTable. + *

+ * + * @return an array of {@link java.lang.String} objects + */ + public String[][] getResultTable() { + return null; + } + + /** + *

+ * getThermoSystem. + *

+ * + * @return a {@link neqsim.thermo.system.SystemInterface} object + */ + public SystemInterface getThermoSystem() { + return system; + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/waterDewPointTemperatureMultiphaseFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/waterDewPointTemperatureMultiphaseFlash.java index 159ddbffa2..f732e2a0db 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/waterDewPointTemperatureMultiphaseFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/waterDewPointTemperatureMultiphaseFlash.java @@ -2,7 +2,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -15,58 +14,57 @@ * @version $Id: $Id */ public class waterDewPointTemperatureMultiphaseFlash extends constantDutyTemperatureFlash { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(waterDewPointTemperatureMultiphaseFlash.class); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(waterDewPointTemperatureMultiphaseFlash.class); - /** - *

- * Constructor for waterDewPointTemperatureMultiphaseFlash. - *

- */ - public waterDewPointTemperatureMultiphaseFlash() {} + /** + *

+ * Constructor for waterDewPointTemperatureMultiphaseFlash. + *

+ */ + public waterDewPointTemperatureMultiphaseFlash() {} - /** - *

- * Constructor for waterDewPointTemperatureMultiphaseFlash. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public waterDewPointTemperatureMultiphaseFlash(SystemInterface system) { - super(system); - } + /** + *

+ * Constructor for waterDewPointTemperatureMultiphaseFlash. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public waterDewPointTemperatureMultiphaseFlash(SystemInterface system) { + super(system); + } - /** {@inheritDoc} */ - @Override - public void run() { - ThermodynamicOperations TPflashOps = new ThermodynamicOperations(system); - system.setMultiPhaseCheck(true); - double dT = 0.1; - system.setTemperature(600.0); - do { - i++; - TPflashOps.TPflash(); - if (system.hasPhaseType("aqueous")) { - dT = system.getPhaseOfType("aqueous").getComponent("water") - .getNumberOfMolesInPhase() - / system.getPhase(0).getComponent("water").getNumberOfmoles(); - if (dT > 1.0) { - dT = 1.0; - } - system.setTemperature(system.getTemperature() + dT); - } else { - dT = -10.0;// system.getPhaseOfType("aqueous").getComponent("water").getNumberOfMolesInPhase() - // / system.getNumberOfMoles(); - system.setTemperature(system.getTemperature() + dT); - // system.display(); - } - // logger.info("dew temperature " + system.getTemperature()); - } while ((i < 350 && Math.abs(dT) > 1e-5)); - logger.info("i " + i); + /** {@inheritDoc} */ + @Override + public void run() { + ThermodynamicOperations TPflashOps = new ThermodynamicOperations(system); + system.setMultiPhaseCheck(true); + double dT = 0.1; + system.setTemperature(600.0); + do { + i++; + TPflashOps.TPflash(); + if (system.hasPhaseType("aqueous")) { + dT = system.getPhaseOfType("aqueous").getComponent("water").getNumberOfMolesInPhase() + / system.getPhase(0).getComponent("water").getNumberOfmoles(); + if (dT > 1.0) { + dT = 1.0; + } + system.setTemperature(system.getTemperature() + dT); + } else { + dT = -10.0; // system.getPhaseOfType("aqueous").getComponent("water").getNumberOfMolesInPhase() + // / system.getNumberOfMoles(); + system.setTemperature(system.getTemperature() + dT); // system.display(); - } + } + // logger.info("dew temperature " + system.getTemperature()); + } while ((i < 350 && Math.abs(dT) > 1e-5)); + logger.info("i " + i); + // system.display(); + } - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/sysNewtonRhapsonPHflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/sysNewtonRhapsonPHflash.java index d5d4a11b8e..e335ab7a01 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/sysNewtonRhapsonPHflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/sysNewtonRhapsonPHflash.java @@ -155,7 +155,7 @@ public void setJac() { double tempJ = 0.0; for (int i = 0; i < numberOfComponents; i++) { for (int j = 0; j < numberOfComponents; j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta + dij = i == j ? 1.0 : 0.0; // Kroneckers delta tempJ = 1.0 / system.getBeta() * (dij / system.getPhases()[0].getComponents()[i].getx() - 1.0 + system.getPhases()[0].getComponents()[i].getdfugdx(j)) @@ -267,7 +267,7 @@ public int solve(int np) { // u.equals(dx.timesEquals(1.0)); fvec.print(10, 10); logger.info("iter: " + iter); - } while (fvec.norm2() > 1.e-10 && iter < 1000);// && Double.isNaN(dx.norm2())); + } while (fvec.norm2() > 1.e-10 && iter < 1000); // && Double.isNaN(dx.norm2())); logger.info("iter: " + iter); logger.info("temperature: " + system.getTemperature()); logger.info("pressure: " + system.getPressure()); diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/sysNewtonRhapsonTPflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/sysNewtonRhapsonTPflash.java index 7190082673..61bd466080 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/sysNewtonRhapsonTPflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/sysNewtonRhapsonTPflash.java @@ -99,7 +99,7 @@ public void setJac() { double tempJ = 0.0; for (int i = 0; i < numberOfComponents; i++) { for (int j = 0; j < numberOfComponents; j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta + dij = i == j ? 1.0 : 0.0; // Kroneckers delta tempJ = 1.0 / system.getBeta() * (dij / system.getPhase(0).getComponents()[i].getx() - 1.0 + system.getPhase(0).getComponents()[i].getdfugdx(j)) diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/sysNewtonRhapsonTPflashNew.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/sysNewtonRhapsonTPflashNew.java index a87804e84b..5eb978dd7d 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/sysNewtonRhapsonTPflashNew.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/sysNewtonRhapsonTPflashNew.java @@ -14,9 +14,21 @@ */ public class sysNewtonRhapsonTPflashNew implements java.io.Serializable { private static final long serialVersionUID = 1000; - int neq = 0, iter = 0; - int ic02p = -100, ic03p = -100, testcrit = 0, npCrit = 0; - double beta = 0, ds = 0, dTmax = 1, dPmax = 1, avscp = 0.1, TC1 = 0, TC2 = 0, PC1 = 0, PC2 = 0; + int neq = 0; + int iter = 0; + int ic02p = -100; + int ic03p = -100; + int testcrit = 0; + int npCrit = 0; + double beta = 0; + double ds = 0; + double dTmax = 1; + double dPmax = 1; + double avscp = 0.1; + double TC1 = 0; + double TC2 = 0; + double PC1 = 0; + double PC2 = 0; Matrix Jac; Matrix fvec; Matrix u; @@ -50,19 +62,19 @@ public sysNewtonRhapsonTPflashNew() {} * @param numberOfComponents a int */ public sysNewtonRhapsonTPflashNew(SystemInterface system, int numberOfPhases, - int numberOfComponents) { - this.system = system; - this.numberOfComponents = numberOfComponents; - neq = numberOfComponents + 1; - Jac = new Matrix(neq, neq); - fvec = new Matrix(neq, 1); - u = new Matrix(neq, 1); - Xgij = new Matrix(neq, 4); - setu(); - uold = u.copy(); - // System.out.println("Spec : " +speceq); - solver = new newtonRhapson(); - solver.setOrder(3); + int numberOfComponents) { + this.system = system; + this.numberOfComponents = numberOfComponents; + neq = numberOfComponents + 1; + Jac = new Matrix(neq, neq); + fvec = new Matrix(neq, 1); + u = new Matrix(neq, 1); + Xgij = new Matrix(neq, 4); + setu(); + uold = u.copy(); + // System.out.println("Spec : " +speceq); + solver = new newtonRhapson(); + solver.setOrder(3); } /** @@ -71,19 +83,19 @@ public sysNewtonRhapsonTPflashNew(SystemInterface system, int numberOfPhases, *

*/ public void setfvec() { - for (int i = 0; i < numberOfComponents; i++) { - fvec.set(i, 0, u.get(i, 0) - + Math.log(system.getPhases()[1].getComponents()[i].getFugacityCoefficient() - / system.getPhases()[0].getComponents()[i].getFugacityCoefficient())); - } - - double fsum = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - fsum = fsum + system.getPhases()[1].getComponents()[i].getx() - - system.getPhases()[0].getComponents()[i].getx(); - } - fvec.set(numberOfComponents, 0, fsum); - // fvec.print(0,20); + for (int i = 0; i < numberOfComponents; i++) { + fvec.set(i, 0, + u.get(i, 0) + Math.log(system.getPhases()[1].getComponents()[i].getFugacityCoefficient() + / system.getPhases()[0].getComponents()[i].getFugacityCoefficient())); + } + + double fsum = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + fsum = fsum + system.getPhases()[1].getComponents()[i].getx() + - system.getPhases()[0].getComponents()[i].getx(); + } + fvec.set(numberOfComponents, 0, fsum); + // fvec.print(0,20); } /** @@ -92,16 +104,18 @@ public void setfvec() { *

*/ public void setJac() { - Jac.timesEquals(0.0); - double dij = 0.0; - double[] dxidlnk = new double[numberOfComponents]; - double[] dyidlnk = new double[numberOfComponents]; - - double[] dxidbeta = new double[numberOfComponents]; - double[] dyidbeta = new double[numberOfComponents]; - - double tempJ = 0.0, sumdyidbeta = 0, sumdxidbeta = 0; - int nofc = numberOfComponents; + Jac.timesEquals(0.0); + double dij = 0.0; + double[] dxidlnk = new double[numberOfComponents]; + double[] dyidlnk = new double[numberOfComponents]; + + double[] dxidbeta = new double[numberOfComponents]; + double[] dyidbeta = new double[numberOfComponents]; + + double tempJ = 0.0; + double sumdyidbeta = 0; + double sumdxidbeta = 0; + int nofc = numberOfComponents; for (int i = 0; i < numberOfComponents; i++) { dxidlnk[i] = -system.getBeta() * system.getPhases()[0].getComponents()[i].getx() * system.getPhases()[1].getComponents()[i].getx() @@ -127,7 +141,7 @@ public void setJac() { for (int i = 0; i < numberOfComponents; i++) { for (int j = 0; j < numberOfComponents; j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta + dij = i == j ? 1.0 : 0.0; // Kroneckers delta tempJ = dij + system.getPhases()[1].getComponents()[i].getdfugdx(j) * dyidlnk[j] - system.getPhases()[0].getComponents()[i].getdfugdx(j) * dxidlnk[j]; Jac.set(i, j, tempJ); @@ -186,7 +200,7 @@ public void solve(int np) { dx = Jac.solve(fvec); u.minusEquals(dx); // System.out.println("feilen: "+dx.norm2()); - } while (dx.norm2() / u.norm2() > 1.e-10);// && Double.isNaN(dx.norm2())); + } while (dx.norm2() / u.norm2() > 1.e-10); // && Double.isNaN(dx.norm2())); // System.out.println("iter: "+iter); init(); } diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/sysNewtonRhapsonPhaseEnvelope.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/sysNewtonRhapsonPhaseEnvelope.java index 7d9647642b..f9a38e4fc2 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/sysNewtonRhapsonPhaseEnvelope.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/sysNewtonRhapsonPhaseEnvelope.java @@ -15,685 +15,687 @@ * @version $Id: $Id */ public class sysNewtonRhapsonPhaseEnvelope implements java.io.Serializable { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(sysNewtonRhapsonPhaseEnvelope.class); - - double sumx = 0, sumy = 0; - int neq = 0, iter = 0, iter2 = 0; - int ic02p = -100, ic03p = -100, testcrit = 0, npCrit = 0; - double beta = 0, ds = 0, dTmax = 10, dPmax = 10, TC1 = 0, TC2 = 0, PC1 = 0, PC2 = 0, - specVal = 0.0; - int lc = 0, hc = 0; - double sumlnKvals; - Matrix Jac; - Matrix fvec; - Matrix u; - Matrix uold; - Matrix uolder; - Matrix ucrit; - Matrix ucritold; - Matrix Xgij; - SystemInterface system; - int numberOfComponents; - int speceq = 0; - Matrix a = new Matrix(4, 4); - Matrix dxds = null; - Matrix s = new Matrix(1, 4); - Matrix xg; - Matrix xcoef; - newtonRhapson solver; - boolean etterCP = false; - boolean etterCP2 = false; - boolean calcCP = false; - boolean ettercricoT = false; - Matrix xcoefOld; - double sign = 1.0; - double dt; - double dp; - double norm; - double vol = Math.pow(10, 5); - double volold = Math.pow(10, 5); - double volold2 = Math.pow(10, 5); - - /** - *

- * Constructor for sysNewtonRhapsonPhaseEnvelope. - *

- */ - public sysNewtonRhapsonPhaseEnvelope() {} - - /** - *

- * Constructor for sysNewtonRhapsonPhaseEnvelope. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param numberOfPhases a int - * @param numberOfComponents a int - */ - public sysNewtonRhapsonPhaseEnvelope(SystemInterface system, int numberOfPhases, - int numberOfComponents) { - this.system = system; - this.numberOfComponents = numberOfComponents; - neq = numberOfComponents + 2; - Jac = new Matrix(neq, neq); // this is the jacobian of the system of equations - fvec = new Matrix(neq, 1); // this is the system of equations - u = new Matrix(neq, 1); // this is the vector of variables - Xgij = new Matrix(neq, 4); - setu(); - uold = u.copy(); - findSpecEqInit(); - solver = new newtonRhapson(); - solver.setOrder(3); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(sysNewtonRhapsonPhaseEnvelope.class); + + double sumx = 0; + double sumy = 0; + int neq = 0; + int iter = 0; + int iter2 = 0; + int ic02p = -100; + int ic03p = -100; + int testcrit = 0; + int npCrit = 0; + double beta = 0; + double ds = 0; + double dTmax = 10; + double dPmax = 10; + double TC1 = 0; + double TC2 = 0; + double PC1 = 0; + double PC2 = 0; + double specVal = 0.0; + int lc = 0; + int hc = 0; + double sumlnKvals; + Matrix Jac; + Matrix fvec; + Matrix u; + Matrix uold; + Matrix uolder; + Matrix ucrit; + Matrix ucritold; + Matrix Xgij; + SystemInterface system; + int numberOfComponents; + int speceq = 0; + Matrix a = new Matrix(4, 4); + Matrix dxds = null; + Matrix s = new Matrix(1, 4); + Matrix xg; + Matrix xcoef; + newtonRhapson solver; + boolean etterCP = false; + boolean etterCP2 = false; + boolean calcCP = false; + boolean ettercricoT = false; + Matrix xcoefOld; + double sign = 1.0; + double dt; + double dp; + double norm; + double vol = Math.pow(10, 5); + double volold = Math.pow(10, 5); + double volold2 = Math.pow(10, 5); + + /** + *

+ * Constructor for sysNewtonRhapsonPhaseEnvelope. + *

+ */ + public sysNewtonRhapsonPhaseEnvelope() {} + + /** + *

+ * Constructor for sysNewtonRhapsonPhaseEnvelope. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param numberOfPhases a int + * @param numberOfComponents a int + */ + public sysNewtonRhapsonPhaseEnvelope(SystemInterface system, int numberOfPhases, + int numberOfComponents) { + this.system = system; + this.numberOfComponents = numberOfComponents; + neq = numberOfComponents + 2; + Jac = new Matrix(neq, neq); // this is the jacobian of the system of equations + fvec = new Matrix(neq, 1); // this is the system of equations + u = new Matrix(neq, 1); // this is the vector of variables + Xgij = new Matrix(neq, 4); + setu(); + uold = u.copy(); + findSpecEqInit(); + solver = new newtonRhapson(); + solver.setOrder(3); + } + + /** + *

+ * setfvec22. + *

+ */ + public void setfvec22() { + for (int i = 0; i < numberOfComponents; i++) { + fvec.set(i, 0, + Math.log(system.getPhase(0).getComponents()[i].getFugacityCoefficient() + * system.getPhase(0).getComponents()[i].getx()) + - Math.log(system.getPhase(1).getComponents()[i].getFugacityCoefficient() + * system.getPhase(1).getComponents()[i].getx())); } - - /** - *

- * setfvec22. - *

- */ - public void setfvec22() { - for (int i = 0; i < numberOfComponents; i++) { - fvec.set(i, 0, Math - .log(system.getPhase(0).getComponents()[i].getFugacityCoefficient() - * system.getPhase(0).getComponents()[i].getx()) - - Math.log(system.getPhase(1).getComponents()[i].getFugacityCoefficient() - * system.getPhase(1).getComponents()[i].getx())); - } - double fsum = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - fsum += system.getPhase(0).getComponents()[i].getx() - - system.getPhase(1).getComponents()[i].getx(); - } - fvec.set(numberOfComponents, 0, fsum); - fvec.set(numberOfComponents, 0, sumy - sumx); - fvec.set(numberOfComponents + 1, 0, u.get(speceq, 0) - specVal); + double fsum = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + fsum += system.getPhase(0).getComponents()[i].getx() + - system.getPhase(1).getComponents()[i].getx(); } - - /** - *

- * Setter for the field fvec. - *

- */ - public void setfvec() { - for (int i = 0; i < numberOfComponents; i++) { - fvec.set(i, 0, - u.get(i, 0) + system.getPhase(0).getComponents()[i].getLogFugacityCoefficient() - - system.getPhase(1).getComponents()[i].getLogFugacityCoefficient()); - } - fvec.set(numberOfComponents, 0, sumy - sumx); - fvec.set(numberOfComponents + 1, 0, u.get(speceq, 0) - specVal); + fvec.set(numberOfComponents, 0, fsum); + fvec.set(numberOfComponents, 0, sumy - sumx); + fvec.set(numberOfComponents + 1, 0, u.get(speceq, 0) - specVal); + } + + /** + *

+ * Setter for the field fvec. + *

+ */ + public void setfvec() { + for (int i = 0; i < numberOfComponents; i++) { + fvec.set(i, 0, u.get(i, 0) + system.getPhase(0).getComponents()[i].getLogFugacityCoefficient() + - system.getPhase(1).getComponents()[i].getLogFugacityCoefficient()); } - - /** - *

- * findSpecEqInit. - *

- */ - public void findSpecEqInit() { - speceq = 0; - int speceqmin = 0; - - system.getPhase(0).getComponents()[numberOfComponents - 1].getPC(); - system.getPhase(0).getComponents()[numberOfComponents - 1].getTC(); - system.getPhase(0).getComponents()[numberOfComponents - 1].getAcentricFactor(); - - for (int i = 0; i < numberOfComponents; i++) { - if (system.getComponent(i).getz() < 1e-10) { - continue; - } - if (system.getPhase(0).getComponents()[i] - .getTC() > system.getPhase(0).getComponents()[speceq].getTC()) { - speceq = system.getPhase(0).getComponents()[i].getComponentNumber(); - specVal = u.get(i, 0); - hc = i; - } - if (system.getPhase(0).getComponents()[i] - .getTC() < system.getPhase(0).getComponents()[speceqmin].getTC()) { - speceqmin = system.getPhase(0).getComponents()[i].getComponentNumber(); - lc = i; - } - } + fvec.set(numberOfComponents, 0, sumy - sumx); + fvec.set(numberOfComponents + 1, 0, u.get(speceq, 0) - specVal); + } + + /** + *

+ * findSpecEqInit. + *

+ */ + public void findSpecEqInit() { + speceq = 0; + int speceqmin = 0; + + system.getPhase(0).getComponents()[numberOfComponents - 1].getPC(); + system.getPhase(0).getComponents()[numberOfComponents - 1].getTC(); + system.getPhase(0).getComponents()[numberOfComponents - 1].getAcentricFactor(); + + for (int i = 0; i < numberOfComponents; i++) { + if (system.getComponent(i).getz() < 1e-10) { + continue; + } + if (system.getPhase(0).getComponents()[i].getTC() > system.getPhase(0).getComponents()[speceq] + .getTC()) { + speceq = system.getPhase(0).getComponents()[i].getComponentNumber(); + specVal = u.get(i, 0); + hc = i; + } + if (system.getPhase(0).getComponents()[i] + .getTC() < system.getPhase(0).getComponents()[speceqmin].getTC()) { + speceqmin = system.getPhase(0).getComponents()[i].getComponentNumber(); + lc = i; + } } + } + + /** + *

+ * findSpecEq. + *

+ */ + public void findSpecEq() { + double max = 0; + double max2 = 0.; + int speceq2 = 0; + + for (int i = 0; i < numberOfComponents + 2; i++) { + double testVal = + Math.abs((Math.exp(u.get(i, 0)) - Math.exp(uold.get(i, 0))) / Math.exp(uold.get(i, 0))); + + // the most sensitive variable is calculated not by the difference, + // but from the sensibility vector in the original Michelsen code + + if (testVal > max) { + speceq = i; + specVal = u.get(i, 0); + max = testVal; + } - /** - *

- * findSpecEq. - *

- */ - public void findSpecEq() { - double max = 0; - double max2 = 0.; - int speceq2 = 0; - - for (int i = 0; i < numberOfComponents + 2; i++) { - double testVal = Math.abs( - (Math.exp(u.get(i, 0)) - Math.exp(uold.get(i, 0))) / Math.exp(uold.get(i, 0))); - - // the most sensitive variable is calculated not by the difference, - // but from the sensibility vector in the original Michelsen code - - if (testVal > max) { - speceq = i; - specVal = u.get(i, 0); - max = testVal; - } - - testVal = Math.abs(dxds.get(i, 0)); - - if (testVal > max2) { - speceq2 = i; - // double specVal2 = u.get(i, 0); - max2 = testVal; - } - } - - if (Double.isNaN(dxds.get(1, 0))) { - speceq2 = numberOfComponents + 3; - } + testVal = Math.abs(dxds.get(i, 0)); - if (speceq != speceq2) { - speceq = speceq2; - } + if (testVal > max2) { + speceq2 = i; + // double specVal2 = u.get(i, 0); + max2 = testVal; + } } - /** - *

- * useAsSpecEq. - *

- * - * @param i a int - */ - public void useAsSpecEq(int i) { - speceq = i; - specVal = u.get(i, 0); - System.out.println("Enforced Scec Variable" + speceq + " " + specVal); + if (Double.isNaN(dxds.get(1, 0))) { + speceq2 = numberOfComponents + 3; } - /** - *

- * calc_x_y. - *

- */ - public final void calc_x_y() { - sumx = 0; - sumy = 0; - for (int j = 0; j < system.getNumberOfPhases(); j++) { - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - if (j == 0) { - sumy += system.getPhase(j).getComponents()[i].getK() - * system.getPhase(j).getComponents()[i].getz() - / (1.0 - system.getBeta(0) + system.getBeta(0) - * system.getPhase(0).getComponents()[i].getK()); - } - if (j == 1) { - sumx += system.getPhase(0).getComponents()[i].getz() / (1.0 - system.getBeta(0) - + system.getBeta(0) * system.getPhase(0).getComponents()[i].getK()); - } - } - } + if (speceq != speceq2) { + speceq = speceq2; } - - /** - *

- * setJac2. - *

- */ - public void setJac2() { - Jac.timesEquals(0.0); - double dij = 0.0; - double[] dxidlnk = new double[numberOfComponents]; - double[] dyidlnk = new double[numberOfComponents]; - double tempJ = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - dxidlnk[i] = -system.getBeta() * system.getPhase(1).getComponents()[i].getx() - * system.getPhase(0).getComponents()[i].getx() - / system.getPhase(0).getComponents()[i].getz(); - dyidlnk[i] = system.getPhase(0).getComponents()[i].getx() - + system.getPhase(1).getComponents()[i].getK() * dxidlnk[i]; + } + + /** + *

+ * useAsSpecEq. + *

+ * + * @param i a int + */ + public void useAsSpecEq(int i) { + speceq = i; + specVal = u.get(i, 0); + System.out.println("Enforced Scec Variable" + speceq + " " + specVal); + } + + /** + *

+ * calc_x_y. + *

+ */ + public final void calc_x_y() { + sumx = 0; + sumy = 0; + for (int j = 0; j < system.getNumberOfPhases(); j++) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (j == 0) { + sumy += system.getPhase(j).getComponents()[i].getK() + * system.getPhase(j).getComponents()[i].getz() / (1.0 - system.getBeta(0) + + system.getBeta(0) * system.getPhase(0).getComponents()[i].getK()); } - for (int i = 0; i < numberOfComponents; i++) { - double dlnxdlnK = -1.0 - / (1.0 + system.getBeta() * system.getPhase(0).getComponents()[i].getK() - - system.getBeta()) - * system.getBeta() * system.getPhase(0).getComponents()[i].getK(); - double dlnydlnK = 1.0 - 1.0 - / (system.getPhase(0).getComponents()[i].getK() * system.getBeta() + 1 - - system.getBeta()) - * system.getBeta() * system.getPhase(0).getComponents()[i].getK(); - for (int j = 0; j < numberOfComponents; j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers deltaget - tempJ = -dij + dij * dlnydlnK - dij * dlnxdlnK; - Jac.set(i, j, tempJ); - } - tempJ = system.getTemperature() * (system.getPhase(0).getComponents()[i].getdfugdt() - - system.getPhase(1).getComponents()[i].getdfugdt()); - Jac.set(i, numberOfComponents, tempJ); - tempJ = system.getPressure() * (system.getPhase(0).getComponents()[i].getdfugdp() - - system.getPhase(1).getComponents()[i].getdfugdp()); - Jac.set(i, numberOfComponents + 1, tempJ); - Jac.set(numberOfComponents, i, dyidlnk[i] - dxidlnk[i]); + if (j == 1) { + sumx += system.getPhase(0).getComponents()[i].getz() / (1.0 - system.getBeta(0) + + system.getBeta(0) * system.getPhase(0).getComponents()[i].getK()); } - Jac.set(numberOfComponents + 1, speceq, 1.0); + } } - - /** - *

- * setJac. - *

- */ - public void setJac() { - Jac.timesEquals(0.0); - double dij = 0.0; - double[] dxidlnk = new double[numberOfComponents]; - double[] dyidlnk = new double[numberOfComponents]; - double tempJ = 0.0; - for (int i = 0; i < numberOfComponents; i++) { - dxidlnk[i] = -system.getPhase(1).getComponents()[i].getz() - * Math.pow(system.getPhase(0).getComponents()[i].getK() * system.getBeta() + 1.0 - - system.getBeta(), -2.0) - * system.getBeta() * system.getPhase(1).getComponents()[i].getK(); - dyidlnk[i] = system.getPhase(1).getComponents()[i].getz() - / (system.getPhase(0).getComponents()[i].getK() * system.getBeta() + 1.0 - - system.getBeta()) - * system.getPhase(1).getComponents()[i].getK() - - system.getPhase(0).getComponents()[i].getK() - * system.getPhase(1).getComponents()[i].getz() - / Math.pow( - 1.0 - system.getBeta() - + system.getBeta() - * system.getPhase(0).getComponents()[i].getK(), - 2.0) - * system.getBeta() * system.getPhase(0).getComponents()[i].getK(); - } - for (int i = 0; i < numberOfComponents; i++) { - for (int j = 0; j < numberOfComponents; j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta - tempJ = dij + system.getPhase(0).getComponents()[i].getdfugdx(j) * dyidlnk[j] - - system.getPhase(1).getComponents()[i].getdfugdx(j) * dxidlnk[j]; - Jac.set(i, j, tempJ); - } - tempJ = system.getTemperature() * (system.getPhase(0).getComponents()[i].getdfugdt() - - system.getPhase(1).getComponents()[i].getdfugdt()); - Jac.set(i, numberOfComponents, tempJ); - tempJ = system.getPressure() * (system.getPhase(0).getComponents()[i].getdfugdp() - - system.getPhase(1).getComponents()[i].getdfugdp()); - Jac.set(i, numberOfComponents + 1, tempJ); - Jac.set(numberOfComponents, i, dyidlnk[i] - dxidlnk[i]); - Jac.set(numberOfComponents + 1, i, 0.0); - } - Jac.set(numberOfComponents + 1, speceq, 1.0); + } + + /** + *

+ * setJac2. + *

+ */ + public void setJac2() { + Jac.timesEquals(0.0); + double dij = 0.0; + double[] dxidlnk = new double[numberOfComponents]; + double[] dyidlnk = new double[numberOfComponents]; + double tempJ = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + dxidlnk[i] = -system.getBeta() * system.getPhase(1).getComponents()[i].getx() + * system.getPhase(0).getComponents()[i].getx() + / system.getPhase(0).getComponents()[i].getz(); + dyidlnk[i] = system.getPhase(0).getComponents()[i].getx() + + system.getPhase(1).getComponents()[i].getK() * dxidlnk[i]; } - - /** - *

- * Setter for the field u. - *

- */ - public void setu() { - for (int i = 0; i < numberOfComponents; i++) { - u.set(i, 0, Math.log(system.getPhase(0).getComponents()[i].getK())); - } - u.set(numberOfComponents, 0, Math.log(system.getTemperature())); - u.set(numberOfComponents + 1, 0, Math.log(system.getPressure())); + for (int i = 0; i < numberOfComponents; i++) { + double dlnxdlnK = + -1.0 / (1.0 + system.getBeta() * system.getPhase(0).getComponents()[i].getK() + - system.getBeta()) * system.getBeta() * system.getPhase(0).getComponents()[i].getK(); + double dlnydlnK = 1.0 - 1.0 + / (system.getPhase(0).getComponents()[i].getK() * system.getBeta() + 1 - system.getBeta()) + * system.getBeta() * system.getPhase(0).getComponents()[i].getK(); + for (int j = 0; j < numberOfComponents; j++) { + dij = i == j ? 1.0 : 0.0; // Kroneckers deltaget + tempJ = -dij + dij * dlnydlnK - dij * dlnxdlnK; + Jac.set(i, j, tempJ); + } + tempJ = system.getTemperature() * (system.getPhase(0).getComponents()[i].getdfugdt() + - system.getPhase(1).getComponents()[i].getdfugdt()); + Jac.set(i, numberOfComponents, tempJ); + tempJ = system.getPressure() * (system.getPhase(0).getComponents()[i].getdfugdp() + - system.getPhase(1).getComponents()[i].getdfugdp()); + Jac.set(i, numberOfComponents + 1, tempJ); + Jac.set(numberOfComponents, i, dyidlnk[i] - dxidlnk[i]); } - - /** - *

- * init. - *

- */ - public void init() { - for (int i = 0; i < numberOfComponents; i++) { - system.getPhase(0).getComponents()[i].setK(Math.exp(u.get(i, 0))); - system.getPhase(1).getComponents()[i].setK(Math.exp(u.get(i, 0))); - } - system.setTemperature(Math.exp(u.get(numberOfComponents, 0))); - system.setPressure(Math.exp(u.get(numberOfComponents + 1, 0))); - - calc_x_y(); - system.calc_x_y(); - system.init(3); + Jac.set(numberOfComponents + 1, speceq, 1.0); + } + + /** + *

+ * setJac. + *

+ */ + public void setJac() { + Jac.timesEquals(0.0); + double dij = 0.0; + double[] dxidlnk = new double[numberOfComponents]; + double[] dyidlnk = new double[numberOfComponents]; + double tempJ = 0.0; + for (int i = 0; i < numberOfComponents; i++) { + dxidlnk[i] = -system.getPhase(1).getComponents()[i].getz() + * Math.pow(system.getPhase(0).getComponents()[i].getK() * system.getBeta() + 1.0 + - system.getBeta(), -2.0) + * system.getBeta() * system.getPhase(1).getComponents()[i].getK(); + dyidlnk[i] = system.getPhase(1).getComponents()[i].getz() + / (system.getPhase(0).getComponents()[i].getK() * system.getBeta() + 1.0 + - system.getBeta()) + * system.getPhase(1).getComponents()[i].getK() + - system.getPhase(0).getComponents()[i].getK() + * system.getPhase(1).getComponents()[i].getz() + / Math.pow(1.0 - system.getBeta() + + system.getBeta() * system.getPhase(0).getComponents()[i].getK(), 2.0) + * system.getBeta() * system.getPhase(0).getComponents()[i].getK(); } - - /** - *

- * calcInc. - *

- * - * @param np a int - */ - public void calcInc(int np) { - // First we need the sensitivity vector dX/dS - // calculates the sensitivity vector and stores the xgij matrix - - init(); - - if (np < 5) { - // for the first five points use as spec eq the nc+1 - // which is pressure - - setu(); - speceq = numberOfComponents + 1; - specVal = u.get(speceq, 0); - setJac(); - fvec.timesEquals(0.0); - fvec.set(speceq, 0, 1.0); - dxds = Jac.solve(fvec); - double dp = 0.1; - ds = dp / dxds.get(numberOfComponents + 1, 0); - - Xgij.setMatrix(0, numberOfComponents + 1, np - 1, np - 1, u.copy()); - u.plusEquals(dxds.times(ds)); - specVal = u.get(speceq, 0); - } else { - // for the rest of the points use as spec eq the most sensitive variable - int speceqOld = speceq; - findSpecEq(); - if (speceq == numberOfComponents + 3) { - speceq = speceqOld; - } - - int intsign = Math.round(Math.round(dxds.get(speceq, 0) * 100000000)); - int sign1 = Integer.signum(intsign); - ds = sign1 * ds; - - setfvec(); - setJac(); - fvec.timesEquals(0.0); - fvec.set(numberOfComponents + 1, 0, 1.0); - - // calculate the dxds of the system - dxds = Jac.solve(fvec); - - // check for critical point - - // check density - // double densV = system.getPhase(0).getDensity(); - // double densL = system.getPhase(1).getDensity(); - // check the proximity to the critical point by addind the lnKs and finding the - // highest - double Kvallc = system.getPhase(0).getComponent(lc).getx() - / system.getPhase(1).getComponent(lc).getx(); - double Kvalhc = system.getPhase(0).getComponent(hc).getx() - / system.getPhase(1).getComponent(hc).getx(); - - if ((etterCP == false)) { - if (Kvallc < 1.05 && Kvalhc > 0.95) { - calcCP = true; - etterCP = true; - npCrit = np; - system.invertPhaseTypes(); - // System.out.println("critical point"); - } - } - - // manipulate stepsize according to the number of iterations of the previous - // point - if (iter > 6) { - ds *= 0.5; - } else { - if (iter < 3) { - ds *= 1.1; - } - if (iter == 3) { - ds *= 1.0; - } - if (iter == 4) { - ds *= 0.9; - } - if (iter > 4) { - ds *= 0.7; - } - } - - // Now we check wheater this ds is greater than dTmax and dPmax. - intsign = Math.round(Math.round(ds * 100000000)); - int sign2 = Integer.signum(intsign); - - if ((1 + dTmax / system.getTemperature()) < Math - .exp(dxds.get(numberOfComponents, 0) * ds)) { - // logger.info("too high dT"); - ds = Math.log(1 + dTmax / system.getTemperature()) - / dxds.get(numberOfComponents, 0); - } else if ((1 - dTmax / system.getTemperature()) > Math - .exp(dxds.get(numberOfComponents, 0) * ds)) { - // logger.info("too low dT"); - ds = Math.log(1 - dTmax / system.getTemperature()) - / dxds.get(numberOfComponents, 0); - } else if ((1 + dPmax / system.getPressure()) < Math - .exp(dxds.get(numberOfComponents + 1, 0) * ds)) { - // logger.info("too low dP"); - ds = Math.log(1 + dPmax / system.getPressure()) - / dxds.get(numberOfComponents + 1, 0); - } else if ((1 - dPmax / system.getPressure()) > Math - .exp(dxds.get(numberOfComponents + 1, 0) * ds)) { - // logger.info("too low dP"); - ds = Math.log(1 - dPmax / system.getPressure()) - / dxds.get(numberOfComponents + 1, 0); - } - ds = sign2 * Math.abs(ds); - - // store the values of the solution for the last 5 iterations - Xgij.setMatrix(0, numberOfComponents + 1, 0, 2, - Xgij.getMatrix(0, numberOfComponents + 1, 1, 3)); - Xgij.setMatrix(0, numberOfComponents + 1, 3, 3, u.copy()); - - s.setMatrix(0, 0, 0, 3, Xgij.getMatrix(speceq, speceq, 0, 3)); - - // calculate next u - calcInc2(np); - } - // since you are calculating the next point the previous iterations should be - // zero - iter = 0; - iter2 = 0; + for (int i = 0; i < numberOfComponents; i++) { + for (int j = 0; j < numberOfComponents; j++) { + dij = i == j ? 1.0 : 0.0; // Kroneckers delta + tempJ = dij + system.getPhase(0).getComponents()[i].getdfugdx(j) * dyidlnk[j] + - system.getPhase(1).getComponents()[i].getdfugdx(j) * dxidlnk[j]; + Jac.set(i, j, tempJ); + } + tempJ = system.getTemperature() * (system.getPhase(0).getComponents()[i].getdfugdt() + - system.getPhase(1).getComponents()[i].getdfugdt()); + Jac.set(i, numberOfComponents, tempJ); + tempJ = system.getPressure() * (system.getPhase(0).getComponents()[i].getdfugdp() + - system.getPhase(1).getComponents()[i].getdfugdp()); + Jac.set(i, numberOfComponents + 1, tempJ); + Jac.set(numberOfComponents, i, dyidlnk[i] - dxidlnk[i]); + Jac.set(numberOfComponents + 1, i, 0.0); } - - /** - *

- * calcInc2. - *

- * - * @param np a int - */ - public void calcInc2(int np) { - // Here we calcualte the estimate of the next point from the polynomial. - for (int i = 0; i < 4; i++) { - a.set(i, 0, 1.0); - a.set(i, 1, s.get(0, i)); - a.set(i, 2, s.get(0, i) * s.get(0, i)); - a.set(i, 3, a.get(i, 2) * s.get(0, i)); + Jac.set(numberOfComponents + 1, speceq, 1.0); + } + + /** + *

+ * Setter for the field u. + *

+ */ + public void setu() { + for (int i = 0; i < numberOfComponents; i++) { + u.set(i, 0, Math.log(system.getPhase(0).getComponents()[i].getK())); + } + u.set(numberOfComponents, 0, Math.log(system.getTemperature())); + u.set(numberOfComponents + 1, 0, Math.log(system.getPressure())); + } + + /** + *

+ * init. + *

+ */ + public void init() { + for (int i = 0; i < numberOfComponents; i++) { + system.getPhase(0).getComponents()[i].setK(Math.exp(u.get(i, 0))); + system.getPhase(1).getComponents()[i].setK(Math.exp(u.get(i, 0))); + } + system.setTemperature(Math.exp(u.get(numberOfComponents, 0))); + system.setPressure(Math.exp(u.get(numberOfComponents + 1, 0))); + + calc_x_y(); + system.calc_x_y(); + system.init(3); + } + + /** + *

+ * calcInc. + *

+ * + * @param np a int + */ + public void calcInc(int np) { + // First we need the sensitivity vector dX/dS + // calculates the sensitivity vector and stores the xgij matrix + + init(); + + if (np < 5) { + // for the first five points use as spec eq the nc+1 + // which is pressure + + setu(); + speceq = numberOfComponents + 1; + specVal = u.get(speceq, 0); + setJac(); + fvec.timesEquals(0.0); + fvec.set(speceq, 0, 1.0); + dxds = Jac.solve(fvec); + double dp = 0.1; + ds = dp / dxds.get(numberOfComponents + 1, 0); + + Xgij.setMatrix(0, numberOfComponents + 1, np - 1, np - 1, u.copy()); + u.plusEquals(dxds.times(ds)); + specVal = u.get(speceq, 0); + } else { + // for the rest of the points use as spec eq the most sensitive variable + int speceqOld = speceq; + findSpecEq(); + if (speceq == numberOfComponents + 3) { + speceq = speceqOld; + } + + int intsign = Math.round(Math.round(dxds.get(speceq, 0) * 100000000)); + int sign1 = Integer.signum(intsign); + ds = sign1 * ds; + + setfvec(); + setJac(); + fvec.timesEquals(0.0); + fvec.set(numberOfComponents + 1, 0, 1.0); + + // calculate the dxds of the system + dxds = Jac.solve(fvec); + + // check for critical point + + // check density + // double densV = system.getPhase(0).getDensity(); + // double densL = system.getPhase(1).getDensity(); + // check the proximity to the critical point by addind the lnKs and finding the + // highest + double Kvallc = + system.getPhase(0).getComponent(lc).getx() / system.getPhase(1).getComponent(lc).getx(); + double Kvalhc = + system.getPhase(0).getComponent(hc).getx() / system.getPhase(1).getComponent(hc).getx(); + + if ((etterCP == false)) { + if (Kvallc < 1.05 && Kvalhc > 0.95) { + calcCP = true; + etterCP = true; + npCrit = np; + system.invertPhaseTypes(); + // System.out.println("critical point"); } - - // finds the estimate of the next point of the envelope that corresponds - // to the most specified equation - double sny; - sny = ds * dxds.get(speceq, 0) + s.get(0, 3); - specVal = sny; - - // finds the estimate of the next point of the envelope that corresponds - // to all the equations - for (int j = 0; j < neq; j++) { - xg = Xgij.getMatrix(j, j, 0, 3); - try { - xcoef = a.solve(xg.transpose()); - } catch (Exception e) { - xcoef = xcoefOld.copy(); - } - u.set(j, 0, xcoef.get(0, 0) - + sny * (xcoef.get(1, 0) + sny * (xcoef.get(2, 0) + sny * xcoef.get(3, 0)))); + } + + // manipulate stepsize according to the number of iterations of the previous + // point + if (iter > 6) { + ds *= 0.5; + } else { + if (iter < 3) { + ds *= 1.1; } - xcoefOld = xcoef.copy(); - } - - /** - *

- * calcCrit. - *

- */ - public void calcCrit() { - // calculates the critical point based on interpolation polynomials - Matrix aa = a.copy(); - Matrix ss = s.copy(); - Matrix xx = Xgij.copy(); - Matrix uu = u.copy(); - - // Here we calcualte the estimate of the next point from the polynomial. - for (int i = 0; i < 4; i++) { - a.set(i, 0, 1.0); - a.set(i, 1, s.get(0, i)); - a.set(i, 2, s.get(0, i) * s.get(0, i)); - a.set(i, 3, a.get(i, 2) * s.get(0, i)); + if (iter == 3) { + ds *= 1.0; } - - double sny; - sny = 0.; - try { - for (int j = 0; j < neq; j++) { - xg = Xgij.getMatrix(j, j, 0, 3); - try { - xcoef = a.solve(xg.transpose()); - } catch (Exception e) { - xcoef = xcoefOld.copy(); - } - u.set(j, 0, xcoef.get(0, 0) + sny - * (xcoef.get(1, 0) + sny * (xcoef.get(2, 0) + sny * xcoef.get(3, 0)))); - } - } catch (Exception e) { - logger.error("error", e); + if (iter == 4) { + ds *= 0.9; } - - system.setTC(Math.exp(u.get(numberOfComponents, 0))); - system.setPC(Math.exp(u.get(numberOfComponents + 1, 0))); - - a = aa.copy(); - s = ss.copy(); - Xgij = xx.copy(); - u = uu.copy(); + if (iter > 4) { + ds *= 0.7; + } + } + + // Now we check wheater this ds is greater than dTmax and dPmax. + intsign = Math.round(Math.round(ds * 100000000)); + int sign2 = Integer.signum(intsign); + + if ((1 + dTmax / system.getTemperature()) < Math.exp(dxds.get(numberOfComponents, 0) * ds)) { + // logger.info("too high dT"); + ds = Math.log(1 + dTmax / system.getTemperature()) / dxds.get(numberOfComponents, 0); + } else if ((1 - dTmax / system.getTemperature()) > Math + .exp(dxds.get(numberOfComponents, 0) * ds)) { + // logger.info("too low dT"); + ds = Math.log(1 - dTmax / system.getTemperature()) / dxds.get(numberOfComponents, 0); + } else if ((1 + dPmax / system.getPressure()) < Math + .exp(dxds.get(numberOfComponents + 1, 0) * ds)) { + // logger.info("too low dP"); + ds = Math.log(1 + dPmax / system.getPressure()) / dxds.get(numberOfComponents + 1, 0); + } else if ((1 - dPmax / system.getPressure()) > Math + .exp(dxds.get(numberOfComponents + 1, 0) * ds)) { + // logger.info("too low dP"); + ds = Math.log(1 - dPmax / system.getPressure()) / dxds.get(numberOfComponents + 1, 0); + } + ds = sign2 * Math.abs(ds); + + // store the values of the solution for the last 5 iterations + Xgij.setMatrix(0, numberOfComponents + 1, 0, 2, + Xgij.getMatrix(0, numberOfComponents + 1, 1, 3)); + Xgij.setMatrix(0, numberOfComponents + 1, 3, 3, u.copy()); + + s.setMatrix(0, 0, 0, 3, Xgij.getMatrix(speceq, speceq, 0, 3)); + + // calculate next u + calcInc2(np); } - - /** - *

- * Getter for the field npCrit. - *

- * - * @return a int - */ - public int getNpCrit() { - return npCrit; + // since you are calculating the next point the previous iterations should be + // zero + iter = 0; + iter2 = 0; + } + + /** + *

+ * calcInc2. + *

+ * + * @param np a int + */ + public void calcInc2(int np) { + // Here we calcualte the estimate of the next point from the polynomial. + for (int i = 0; i < 4; i++) { + a.set(i, 0, 1.0); + a.set(i, 1, s.get(0, i)); + a.set(i, 2, s.get(0, i) * s.get(0, i)); + a.set(i, 3, a.get(i, 2) * s.get(0, i)); } - /** - *

- * sign. - *

- * - * @param a a double - * @param b a double - * @return a double - */ - public double sign(double a, double b) { - a = Math.abs(a); - b = b >= 0 ? 1.0 : -1.0; - return a * b; + // finds the estimate of the next point of the envelope that corresponds + // to the most specified equation + double sny; + sny = ds * dxds.get(speceq, 0) + s.get(0, 3); + specVal = sny; + + // finds the estimate of the next point of the envelope that corresponds + // to all the equations + for (int j = 0; j < neq; j++) { + xg = Xgij.getMatrix(j, j, 0, 3); + try { + xcoef = a.solve(xg.transpose()); + } catch (Exception e) { + xcoef = xcoefOld.copy(); + } + u.set(j, 0, xcoef.get(0, 0) + + sny * (xcoef.get(1, 0) + sny * (xcoef.get(2, 0) + sny * xcoef.get(3, 0)))); + } + xcoefOld = xcoef.copy(); + } + + /** + *

+ * calcCrit. + *

+ */ + public void calcCrit() { + // calculates the critical point based on interpolation polynomials + Matrix aa = a.copy(); + Matrix ss = s.copy(); + Matrix xx = Xgij.copy(); + Matrix uu = u.copy(); + + // Here we calcualte the estimate of the next point from the polynomial. + for (int i = 0; i < 4; i++) { + a.set(i, 0, 1.0); + a.set(i, 1, s.get(0, i)); + a.set(i, 2, s.get(0, i) * s.get(0, i)); + a.set(i, 3, a.get(i, 2) * s.get(0, i)); } - /** - *

- * solve. - *

- * - * @param np a int - */ - public void solve(int np) { - // this method actually solves the phase evnelope point - Matrix dx; - double dxOldNorm = 1e10; - - do { - iter++; - init(); - setfvec(); - setJac(); - - dx = Jac.solve(fvec); - u.minusEquals(dx); - - if (Double.isNaN(dx.norm2()) || Double.isInfinite(dx.norm2())) { - if (iter2 >= 15) { - // deliberate crush - ds = 0. / 0.; - u.set(numberOfComponents, 0, ds); - u.set(numberOfComponents + 1, 0, ds); - } - // if the norm is NAN reduce step and try again - // logger.info("Double.isNaN(dx.norm2())........"); - iter2++; - u = uold.copy(); - ds *= 0.5; - calcInc2(np); - solve(np); - } else if (dxOldNorm < dx.norm2()) { - if (iter2 == 0) { - uolder = uold.copy(); - } - if (iter2 >= 15) { - // deliberate crush - ds = 0. / 0.; - u.set(numberOfComponents, 0, ds); - u.set(numberOfComponents + 1, 0, ds); - } - // if the norm does not reduce there is a danger of entering trivial solution - // reduce step and try again to avoid it - // logger.info("dxOldNorm < dx.norm2()"); - iter2++; - u = uold.copy(); - ds *= 0.5; - calcInc2(np); - solve(np); - } - - if (Double.isNaN(dx.norm2())) { - norm = 1e10; - } else { - norm = dx.norm2(); - dxOldNorm = norm; - } - } while (norm > 1.e-5); - - init(); - findSpecEq(); - - // check density for direction - volold2 = volold; - volold = vol; - vol = system.getPhase(0).getMolarVolume(); - uold = u.copy(); - - if (volold < vol) { - /* - * volold=volold2; ds=-ds; u = uold.copy(); calcInc2(np); solve(np); - */ + double sny; + sny = 0.; + try { + for (int j = 0; j < neq; j++) { + xg = Xgij.getMatrix(j, j, 0, 3); + try { + xcoef = a.solve(xg.transpose()); + } catch (Exception e) { + xcoef = xcoefOld.copy(); } + u.set(j, 0, xcoef.get(0, 0) + + sny * (xcoef.get(1, 0) + sny * (xcoef.get(2, 0) + sny * xcoef.get(3, 0)))); + } + } catch (Exception e) { + logger.error("error", e); + } - /* - * try { Matrix utest = u.copy(); } catch (Exception e0) { double nef = 0.; } - */ + system.setTC(Math.exp(u.get(numberOfComponents, 0))); + system.setPC(Math.exp(u.get(numberOfComponents + 1, 0))); + + a = aa.copy(); + s = ss.copy(); + Xgij = xx.copy(); + u = uu.copy(); + } + + /** + *

+ * Getter for the field npCrit. + *

+ * + * @return a int + */ + public int getNpCrit() { + return npCrit; + } + + /** + *

+ * sign. + *

+ * + * @param a a double + * @param b a double + * @return a double + */ + public double sign(double a, double b) { + a = Math.abs(a); + b = b >= 0 ? 1.0 : -1.0; + return a * b; + } + + /** + *

+ * solve. + *

+ * + * @param np a int + */ + public void solve(int np) { + // this method actually solves the phase evnelope point + Matrix dx; + double dxOldNorm = 1e10; + + do { + iter++; + init(); + setfvec(); + setJac(); + + dx = Jac.solve(fvec); + u.minusEquals(dx); + + if (Double.isNaN(dx.norm2()) || Double.isInfinite(dx.norm2())) { + if (iter2 >= 15) { + // deliberate crush + ds = 0. / 0.; + u.set(numberOfComponents, 0, ds); + u.set(numberOfComponents + 1, 0, ds); + } + // if the norm is NAN reduce step and try again + // logger.info("Double.isNaN(dx.norm2())........"); + iter2++; + u = uold.copy(); + ds *= 0.5; + calcInc2(np); + solve(np); + } else if (dxOldNorm < dx.norm2()) { + if (iter2 == 0) { + uolder = uold.copy(); + } + if (iter2 >= 15) { + // deliberate crush + ds = 0. / 0.; + u.set(numberOfComponents, 0, ds); + u.set(numberOfComponents + 1, 0, ds); + } + // if the norm does not reduce there is a danger of entering trivial solution + // reduce step and try again to avoid it + // logger.info("dxOldNorm < dx.norm2()"); + iter2++; + u = uold.copy(); + ds *= 0.5; + calcInc2(np); + solve(np); + } + + if (Double.isNaN(dx.norm2())) { + norm = 1e10; + } else { + norm = dx.norm2(); + dxOldNorm = norm; + } + } while (norm > 1.e-5); + + init(); + findSpecEq(); + + // check density for direction + volold2 = volold; + volold = vol; + vol = system.getPhase(0).getMolarVolume(); + uold = u.copy(); + + if (volold < vol) { + /* + * volold=volold2; ds=-ds; u = uold.copy(); calcInc2(np); solve(np); + */ } - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects + /* + * try { Matrix utest = u.copy(); } catch (Exception e0) { double nef = 0.; } */ - public static void main(String args[]) { - /* - * sysNewtonRhapson test=new sysNewtonRhapson(); double[] constants = new double[]{0.4,0.4}; - * test.setx(constants); while (test.nonsol()>1.0e-8) { constants=test.getx(); - * logger.info(constants[0]+" "+constants[1]); } test.nonsol(); constants=test.getf(); - * logger.info(constants[0]+" "+constants[1]); System.exit(0); - */ } + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + /* + * sysNewtonRhapson test=new sysNewtonRhapson(); double[] constants = new double[]{0.4,0.4}; + * test.setx(constants); while (test.nonsol()>1.0e-8) { constants=test.getx(); + * logger.info(constants[0]+" "+constants[1]); } test.nonsol(); constants=test.getf(); + * logger.info(constants[0]+" "+constants[1]); System.exit(0); + */ } } diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/sysNewtonRhapsonPhaseEnvelope2.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/sysNewtonRhapsonPhaseEnvelope2.java index d8d704ce59..655a413997 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/sysNewtonRhapsonPhaseEnvelope2.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/sysNewtonRhapsonPhaseEnvelope2.java @@ -18,487 +18,495 @@ * @version $Id: $Id */ public class sysNewtonRhapsonPhaseEnvelope2 implements java.io.Serializable { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(sysNewtonRhapsonPhaseEnvelope2.class); - - int neq = 0, iter = 0; - int ic02p = -100, ic03p = -100, testcrit = 0, npCrit = 0; - double beta = 0, ds = 0, dTmax = 1, dPmax = 1, avscp = 0.2, TC1 = 0, TC2 = 0, PC1 = 0, PC2 = 0; - RealMatrix Jac; - RealMatrix fvec; - RealMatrix u; - RealMatrix uold; - RealMatrix Xgij; - SystemInterface system; - int speceq = 0; - RealMatrix a = new Array2DRowRealMatrix(4, 4); - RealMatrix s = new Array2DRowRealMatrix(1, 4); - RealMatrix xg; - RealMatrix xcoef; - newtonRhapson solver; - boolean etterCP = false; - boolean etterCP2 = false; - - /** - *

- * Constructor for sysNewtonRhapsonPhaseEnvelope2. - *

- */ - public sysNewtonRhapsonPhaseEnvelope2() {} - - /** - *

- * Constructor for sysNewtonRhapsonPhaseEnvelope2. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public sysNewtonRhapsonPhaseEnvelope2(SystemInterface system) { - this.system = system; - neq = system.getPhase(0).getNumberOfComponents() + 2; - Jac = new Array2DRowRealMatrix(neq, neq); - fvec = new Array2DRowRealMatrix(neq, 1); - u = new Array2DRowRealMatrix(neq, 1); - Xgij = new Array2DRowRealMatrix(neq, 4); - - setu(); - uold = u.copy(); - findSpecEqInit(); - solver = new newtonRhapson(); - solver.setOrder(3); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(sysNewtonRhapsonPhaseEnvelope2.class); + + int neq = 0; + int iter = 0; + int ic02p = -100; + int ic03p = -100; + int testcrit = 0; + int npCrit = 0; + double beta = 0; + double ds = 0; + double dTmax = 1; + double dPmax = 1; + double avscp = 0.2; + double TC1 = 0; + double TC2 = 0; + double PC1 = 0; + double PC2 = 0; + RealMatrix Jac; + RealMatrix fvec; + RealMatrix u; + RealMatrix uold; + RealMatrix Xgij; + SystemInterface system; + int speceq = 0; + RealMatrix a = new Array2DRowRealMatrix(4, 4); + RealMatrix s = new Array2DRowRealMatrix(1, 4); + RealMatrix xg; + RealMatrix xcoef; + newtonRhapson solver; + boolean etterCP = false; + boolean etterCP2 = false; + + /** + *

+ * Constructor for sysNewtonRhapsonPhaseEnvelope2. + *

+ */ + public sysNewtonRhapsonPhaseEnvelope2() {} + + /** + *

+ * Constructor for sysNewtonRhapsonPhaseEnvelope2. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public sysNewtonRhapsonPhaseEnvelope2(SystemInterface system) { + this.system = system; + neq = system.getPhase(0).getNumberOfComponents() + 2; + Jac = new Array2DRowRealMatrix(neq, neq); + fvec = new Array2DRowRealMatrix(neq, 1); + u = new Array2DRowRealMatrix(neq, 1); + Xgij = new Array2DRowRealMatrix(neq, 4); + + setu(); + uold = u.copy(); + findSpecEqInit(); + solver = new newtonRhapson(); + solver.setOrder(3); + } + + /** + *

+ * Setter for the field fvec. + *

+ */ + public void setfvec() { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + fvec.setEntry(i, 0, + u.getEntry(i, 0) + Math.log(system.getPhase(0).getComponents()[i].getFugacityCoefficient() + / system.getPhase(1).getComponents()[i].getFugacityCoefficient())); } - - /** - *

- * Setter for the field fvec. - *

- */ - public void setfvec() { - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - fvec.setEntry(i, 0, u.getEntry(i, 0) - + Math.log(system.getPhase(0).getComponents()[i].getFugacityCoefficient() - / system.getPhase(1).getComponents()[i].getFugacityCoefficient())); - } - double fsum = 0.0; - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - fsum += system.getPhase(0).getComponents()[i].getx() - - system.getPhase(1).getComponents()[i].getx(); - } - fvec.setEntry(system.getPhase(0).getNumberOfComponents(), 0, fsum); - fvec.setEntry(system.getPhase(0).getNumberOfComponents() + 1, 0, 0); + double fsum = 0.0; + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + fsum += system.getPhase(0).getComponents()[i].getx() + - system.getPhase(1).getComponents()[i].getx(); } - - /** - *

- * findSpecEqInit. - *

- */ - public void findSpecEqInit() { - speceq = 0; - int speceqmin = 0; - - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - if (system.getPhase(0).getComponents()[i] - .getTC() > system.getPhase(0).getComponents()[speceq].getTC()) { - speceq = system.getPhase(0).getComponents()[i].getComponentNumber(); - } - if (system.getPhase(0).getComponents()[i] - .getTC() < system.getPhase(0).getComponents()[speceqmin].getTC()) { - speceqmin = system.getPhase(0).getComponents()[i].getComponentNumber(); - } - } - avscp = 0.3;// (system.getPhase(0).getComponents()[speceq].getTC()-system.getPhase(0).getComponents()[speceqmin].getTC())/300.0; - logger.info("avscp: " + avscp); - dTmax = 10.0;// avscp*10; - dPmax = 10.0;// avscp*10; - logger.info("dTmax: " + dTmax + " dPmax: " + dPmax); + fvec.setEntry(system.getPhase(0).getNumberOfComponents(), 0, fsum); + fvec.setEntry(system.getPhase(0).getNumberOfComponents() + 1, 0, 0); + } + + /** + *

+ * findSpecEqInit. + *

+ */ + public void findSpecEqInit() { + speceq = 0; + int speceqmin = 0; + + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (system.getPhase(0).getComponents()[i].getTC() > system.getPhase(0).getComponents()[speceq] + .getTC()) { + speceq = system.getPhase(0).getComponents()[i].getComponentNumber(); + } + if (system.getPhase(0).getComponents()[i] + .getTC() < system.getPhase(0).getComponents()[speceqmin].getTC()) { + speceqmin = system.getPhase(0).getComponents()[i].getComponentNumber(); + } } - - /** - *

- * findSpecEq. - *

- */ - public void findSpecEq() { - double max = 0; - for (int i = 0; i < system.getPhase(0).getNumberOfComponents() + 2; i++) { - if (Math.abs((u.getEntry(i, 0) - uold.getEntry(i, 0)) / uold.getEntry(i, 0)) > max) { - speceq = i; - max = Math.abs((u.getEntry(i, 0) - uold.getEntry(i, 0)) / uold.getEntry(i, 0)); - } - } - - // logger.info("spec eq: " + speceq); + avscp = 0.3; // (system.getPhase(0).getComponents()[speceq].getTC()-system.getPhase(0).getComponents()[speceqmin].getTC())/300.0; + logger.info("avscp: " + avscp); + dTmax = 10.0; // avscp*10; + dPmax = 10.0; // avscp*10; + logger.info("dTmax: " + dTmax + " dPmax: " + dPmax); + } + + /** + *

+ * findSpecEq. + *

+ */ + public void findSpecEq() { + double max = 0; + for (int i = 0; i < system.getPhase(0).getNumberOfComponents() + 2; i++) { + if (Math.abs((u.getEntry(i, 0) - uold.getEntry(i, 0)) / uold.getEntry(i, 0)) > max) { + speceq = i; + max = Math.abs((u.getEntry(i, 0) - uold.getEntry(i, 0)) / uold.getEntry(i, 0)); + } } - /** - *

- * setJac. - *

- */ - public void setJac() { - Jac = Jac.scalarMultiply(0.0); - double dij = 0.0; - double[] dxidlnk = new double[system.getPhase(0).getNumberOfComponents()]; - double[] dyidlnk = new double[system.getPhase(0).getNumberOfComponents()]; - double tempJ = 0.0; - int nofc = system.getPhase(0).getNumberOfComponents(); - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - dxidlnk[i] = -system.getBeta() * system.getPhase(1).getComponents()[i].getx() - * system.getPhase(0).getComponents()[i].getx() - / system.getPhase(0).getComponents()[i].getz(); - dyidlnk[i] = system.getPhase(0).getComponents()[i].getx() - + system.getPhase(1).getComponents()[i].getK() * dxidlnk[i]; - // logger.info("dxidlnk("+i+") "+dxidlnk[i]); - // logger.info("dyidlnk("+i+") "+dyidlnk[i]); - } - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - for (int j = 0; j < system.getPhase(0).getNumberOfComponents(); j++) { - dij = i == j ? 1.0 : 0.0;// Kroneckers delta - tempJ = dij + system.getPhase(0).getComponents()[i].getdfugdx(j) * dyidlnk[j] - - system.getPhase(1).getComponents()[i].getdfugdx(j) * dxidlnk[j]; - Jac.setEntry(i, j, tempJ); - } - tempJ = system.getTemperature() * (system.getPhase(0).getComponents()[i].getdfugdt() - - system.getPhase(1).getComponents()[i].getdfugdt()); - Jac.setEntry(i, nofc, tempJ); - tempJ = system.getPressure() * (system.getPhase(0).getComponents()[i].getdfugdp() - - system.getPhase(1).getComponents()[i].getdfugdp()); - Jac.setEntry(i, nofc + 1, tempJ); - Jac.setEntry(nofc, i, dyidlnk[i] - dxidlnk[i]); - } - Jac.setEntry(nofc + 1, speceq, 1.0); + // logger.info("spec eq: " + speceq); + } + + /** + *

+ * setJac. + *

+ */ + public void setJac() { + Jac = Jac.scalarMultiply(0.0); + double dij = 0.0; + double[] dxidlnk = new double[system.getPhase(0).getNumberOfComponents()]; + double[] dyidlnk = new double[system.getPhase(0).getNumberOfComponents()]; + double tempJ = 0.0; + int nofc = system.getPhase(0).getNumberOfComponents(); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + dxidlnk[i] = -system.getBeta() * system.getPhase(1).getComponents()[i].getx() + * system.getPhase(0).getComponents()[i].getx() + / system.getPhase(0).getComponents()[i].getz(); + dyidlnk[i] = system.getPhase(0).getComponents()[i].getx() + + system.getPhase(1).getComponents()[i].getK() * dxidlnk[i]; + // logger.info("dxidlnk("+i+") "+dxidlnk[i]); + // logger.info("dyidlnk("+i+") "+dyidlnk[i]); } - - /** - *

- * Setter for the field u. - *

- */ - public void setu() { - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - u.setEntry(i, 0, Math.log(system.getPhase(0).getComponents()[i].getK())); - } - u.setEntry(system.getPhase(0).getNumberOfComponents(), 0, - Math.log(system.getTemperature())); - u.setEntry(system.getPhase(0).getNumberOfComponents() + 1, 0, - Math.log(system.getPressure())); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + for (int j = 0; j < system.getPhase(0).getNumberOfComponents(); j++) { + dij = i == j ? 1.0 : 0.0; // Kroneckers delta + tempJ = dij + system.getPhase(0).getComponents()[i].getdfugdx(j) * dyidlnk[j] + - system.getPhase(1).getComponents()[i].getdfugdx(j) * dxidlnk[j]; + Jac.setEntry(i, j, tempJ); + } + tempJ = system.getTemperature() * (system.getPhase(0).getComponents()[i].getdfugdt() + - system.getPhase(1).getComponents()[i].getdfugdt()); + Jac.setEntry(i, nofc, tempJ); + tempJ = system.getPressure() * (system.getPhase(0).getComponents()[i].getdfugdp() + - system.getPhase(1).getComponents()[i].getdfugdp()); + Jac.setEntry(i, nofc + 1, tempJ); + Jac.setEntry(nofc, i, dyidlnk[i] - dxidlnk[i]); } - - /** - *

- * init. - *

- */ - public void init() { - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - system.getPhase(0).getComponents()[i].setK(Math.exp(u.getEntry(i, 0))); - system.getPhase(1).getComponents()[i].setK(Math.exp(u.getEntry(i, 0))); - } - system.setTemperature(Math.exp(u.getEntry(system.getPhase(0).getNumberOfComponents(), 0))); - system.setPressure(Math.exp(u.getEntry(system.getPhase(0).getNumberOfComponents() + 1, 0))); - system.calc_x_y(); - system.init(3); + Jac.setEntry(nofc + 1, speceq, 1.0); + } + + /** + *

+ * Setter for the field u. + *

+ */ + public void setu() { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + u.setEntry(i, 0, Math.log(system.getPhase(0).getComponents()[i].getK())); } - - /** - *

- * calcInc. - *

- * - * @param np a int - */ - public void calcInc(int np) { - // First we need the sensitivity vector dX/dS - - findSpecEq(); - int nofc = system.getPhase(0).getNumberOfComponents(); - fvec = fvec.scalarMultiply(0.0); - fvec.setEntry(nofc + 1, 0, 1.0); - DecompositionSolver solver2 = new LUDecomposition(Jac).getSolver(); - RealMatrix dxds = solver2.solve(fvec); - if (np < 5) { - double dp = 0.1; - ds = dp / dxds.getEntry(nofc + 1, 0); - Xgij.setSubMatrix(u.getData(), 0, np - 1); - dxds = dxds.scalarMultiply(ds); - u = u.add(dxds); - } else { - // logger.info("iter " +iter + " np " + np); - if (iter > 6) { - ds *= 0.5; - logger.info("ds > 6"); - } else { - if (iter < 3) { - ds *= 1.3; - } - if (iter == 3) { - ds *= 1.0; - } - if (iter == 4) { - ds *= 0.9; - } - if (iter > 4) { - ds *= 0.7; - } - - // Now we check wheater this ds is greater than dTmax and dPmax. - if (Math.abs(system.getTemperature() * dxds.getEntry(nofc, 0) * ds) > dTmax) { - // logger.info("true T"); - ds = sign(dTmax / system.getTemperature() / Math.abs(dxds.getEntry(nofc, 0)), - ds); - } - - if (Math.abs(system.getPressure() * dxds.getEntry(nofc + 1, 0) * ds) > dPmax) { - ds = sign(dPmax / system.getPressure() / Math.abs(dxds.getEntry(nofc + 1, 0)), - ds); - // logger.info("true P"); - } - - if (etterCP2) { - etterCP2 = false; - // ds = 0.5*ds; - } - logger.info("ds here " + ds); - - Xgij.setSubMatrix(Xgij.getSubMatrix(0, nofc + 1, 1, 3).getData(), 0, 0); - Xgij.setSubMatrix(u.getData(), 0, 3); - s.setSubMatrix(Xgij.getSubMatrix(speceq, speceq, 0, 3).getData(), 0, 0); - // s.print(0,10); - // logger.info("ds1 : " + ds); - - for (int i = 0; i < nofc + 2; i++) { - logger.info("Xgij " + Xgij.getEntry(i, 0)); - logger.info("Xgij " + Xgij.getEntry(i, 1)); - logger.info("Xgij " + Xgij.getEntry(i, 2)); - logger.info("Xgij " + Xgij.getEntry(i, 3)); - } - calcInc2(np); - - // Here we find the next point from the polynomial. - } - } + u.setEntry(system.getPhase(0).getNumberOfComponents(), 0, Math.log(system.getTemperature())); + u.setEntry(system.getPhase(0).getNumberOfComponents() + 1, 0, Math.log(system.getPressure())); + } + + /** + *

+ * init. + *

+ */ + public void init() { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + system.getPhase(0).getComponents()[i].setK(Math.exp(u.getEntry(i, 0))); + system.getPhase(1).getComponents()[i].setK(Math.exp(u.getEntry(i, 0))); } - - /** - *

- * calcInc2. - *

- * - * @param np a int - */ - public void calcInc2(int np) { - for (int j = 0; j < neq; j++) { - xg = Xgij.getSubMatrix(j, j, 0, 3); - for (int i = 0; i < 4; i++) { - a.setEntry(i, 0, 1.0); - a.setEntry(i, 1, s.getEntry(0, i)); - a.setEntry(i, 2, s.getEntry(0, i) * s.getEntry(0, i)); - a.setEntry(i, 3, a.getEntry(i, 2) * s.getEntry(0, i)); - } + system.setTemperature(Math.exp(u.getEntry(system.getPhase(0).getNumberOfComponents(), 0))); + system.setPressure(Math.exp(u.getEntry(system.getPhase(0).getNumberOfComponents() + 1, 0))); + system.calc_x_y(); + system.init(3); + } + + /** + *

+ * calcInc. + *

+ * + * @param np a int + */ + public void calcInc(int np) { + // First we need the sensitivity vector dX/dS + + findSpecEq(); + int nofc = system.getPhase(0).getNumberOfComponents(); + fvec = fvec.scalarMultiply(0.0); + fvec.setEntry(nofc + 1, 0, 1.0); + DecompositionSolver solver2 = new LUDecomposition(Jac).getSolver(); + RealMatrix dxds = solver2.solve(fvec); + if (np < 5) { + double dp = 0.1; + ds = dp / dxds.getEntry(nofc + 1, 0); + Xgij.setSubMatrix(u.getData(), 0, np - 1); + dxds = dxds.scalarMultiply(ds); + u = u.add(dxds); + } else { + // logger.info("iter " +iter + " np " + np); + if (iter > 6) { + ds *= 0.5; + logger.info("ds > 6"); + } else { + if (iter < 3) { + ds *= 1.3; } - for (int j = 0; j < neq; j++) { - xg = Xgij.getSubMatrix(j, j, 0, 3).copy(); - DecompositionSolver solver2 = new LUDecomposition(a).getSolver(); - xcoef = solver2.solve(xg.transpose()); - double sny = ds + s.getEntry(0, 3); - u.setEntry(j, 0, xcoef.getEntry(0, 0) + sny * (xcoef.getEntry(1, 0) - + sny * (xcoef.getEntry(2, 0) + sny * xcoef.getEntry(3, 0)))); - logger.info("u" + j + " " + Math.exp(u.getEntry(j, 0))); + if (iter == 3) { + ds *= 1.0; + } + if (iter == 4) { + ds *= 0.9; + } + if (iter > 4) { + ds *= 0.7; } - uold = u.copy(); - - double xlnkmax = 0; - int numb = 0; - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - if (Math.abs(u.getEntry(i, 0)) > xlnkmax) { - xlnkmax = Math.abs(u.getEntry(i, 0)); - numb = i; - } + // Now we check wheater this ds is greater than dTmax and dPmax. + if (Math.abs(system.getTemperature() * dxds.getEntry(nofc, 0) * ds) > dTmax) { + // logger.info("true T"); + ds = sign(dTmax / system.getTemperature() / Math.abs(dxds.getEntry(nofc, 0)), ds); } - logger.info("klnmax: " + u.getEntry(numb, 0) + " np " + np + " xlnmax " + xlnkmax - + "avsxp " + avscp); - // logger.info("np: " + np + " ico2p: " + ic02p + " ic03p " + ic03p); - - if ((testcrit == -3) && ic03p != np) { - etterCP2 = true; - etterCP = true; - logger.info("Etter CP"); - // System.exit(0); - ic03p = np; - testcrit = 0; - xg = Xgij.getSubMatrix(numb, numb, 0, 3); - - for (int i = 0; i < 4; i++) { - a.setEntry(i, 0, 1.0); - a.setEntry(i, 1, s.getEntry(0, i)); - a.setEntry(i, 2, s.getEntry(0, i) * s.getEntry(0, i)); - a.setEntry(i, 3, a.getEntry(i, 2) * s.getEntry(0, i)); - } - - DecompositionSolver solver2 = new LUDecomposition(a).getSolver(); - RealMatrix xcoef = solver2.solve(xg.transpose()); - - double[] coefs = new double[4]; - coefs[0] = xcoef.getEntry(3, 0); - coefs[1] = xcoef.getEntry(2, 0); - coefs[2] = xcoef.getEntry(1, 0); - coefs[3] = xcoef.getEntry(0, 0) - sign(avscp, -s.getEntry(0, 3)); - solver.setConstants(coefs); - - // logger.info("s4: " + s.get(0,3) + " coefs " + coefs[0] +" "+ coefs[1]+" " + - // coefs[2]+" " + coefs[3]); - double nys = solver.solve1order(s.getEntry(0, 3)); - // s = nys - s.get(0,3); - ds = sign(s.getEntry(0, 3) - nys, ds); - // logger.info("critpoint: " + ds); - - // ds = -nys - s.get(0,3); - calcInc2(np); - - TC2 = Math.exp(u.getEntry(system.getPhase(0).getNumberOfComponents(), 0)); - PC2 = Math.exp(u.getEntry(system.getPhase(0).getNumberOfComponents() + 1, 0)); - system.setTC((TC1 + TC2) * 0.5); - system.setPC((PC1 + PC2) * 0.5); - system.invertPhaseTypes(); - logger.info("invert phases...."); - // system.setPhaseType(0,0); - // system.setPhaseType(1,1); - return; - } else if ((xlnkmax < 1.5 && testcrit != 1) && (np != ic03p && !etterCP)) { - logger.info("hei fra her"); - testcrit = 1; - xg = Xgij.getSubMatrix(numb, numb, 0, 3); - - for (int i = 0; i < 4; i++) { - a.setEntry(i, 0, 1.0); - a.setEntry(i, 1, s.getEntry(0, i)); - a.setEntry(i, 2, s.getEntry(0, i) * s.getEntry(0, i)); - a.setEntry(i, 3, a.getEntry(i, 2) * s.getEntry(0, i)); - } - // a.print(0,10); - // xg.print(0,10); - - DecompositionSolver solver2 = new LUDecomposition(a).getSolver(); - RealMatrix xcoef = solver2.solve(xg.transpose()); - // xcoef.print(0,10); - - double[] coefs = new double[4]; - coefs[0] = xcoef.getEntry(3, 0); - coefs[1] = xcoef.getEntry(2, 0); - coefs[2] = xcoef.getEntry(1, 0); - coefs[3] = xcoef.getEntry(0, 0) - sign(avscp, ds); - solver.setConstants(coefs); - - // logger.info("s4: " + s.get(0,3) + " coefs " + coefs[0] +" "+ coefs[1]+" " + - // coefs[2]+" " + coefs[3]); - double nys = solver.solve1order(s.getEntry(0, 3)); - - ds = -nys - s.getEntry(0, 3); - // logger.info("critpoint: " + ds); - npCrit = np; - - calcInc2(np); - - TC1 = Math.exp(u.getEntry(system.getPhase(0).getNumberOfComponents(), 0)); - PC1 = Math.exp(u.getEntry(system.getPhase(0).getNumberOfComponents() + 1, 0)); - return; + if (Math.abs(system.getPressure() * dxds.getEntry(nofc + 1, 0) * ds) > dPmax) { + ds = sign(dPmax / system.getPressure() / Math.abs(dxds.getEntry(nofc + 1, 0)), ds); + // logger.info("true P"); } - if (testcrit == 1) { - testcrit = -3; + if (etterCP2) { + etterCP2 = false; + // ds = 0.5*ds; } - } + logger.info("ds here " + ds); + + Xgij.setSubMatrix(Xgij.getSubMatrix(0, nofc + 1, 1, 3).getData(), 0, 0); + Xgij.setSubMatrix(u.getData(), 0, 3); + s.setSubMatrix(Xgij.getSubMatrix(speceq, speceq, 0, 3).getData(), 0, 0); + // s.print(0,10); + // logger.info("ds1 : " + ds); + + for (int i = 0; i < nofc + 2; i++) { + logger.info("Xgij " + Xgij.getEntry(i, 0)); + logger.info("Xgij " + Xgij.getEntry(i, 1)); + logger.info("Xgij " + Xgij.getEntry(i, 2)); + logger.info("Xgij " + Xgij.getEntry(i, 3)); + } + calcInc2(np); - /** - *

- * Getter for the field npCrit. - *

- * - * @return a int - */ - public int getNpCrit() { - return npCrit; + // Here we find the next point from the polynomial. + } } - - /** - *

- * critPassed. - *

- * - * @return a boolean - */ - public boolean critPassed() { - if (testcrit == 1) { - testcrit = -3; - return true; - } else { - return false; - } + } + + /** + *

+ * calcInc2. + *

+ * + * @param np a int + */ + public void calcInc2(int np) { + for (int j = 0; j < neq; j++) { + xg = Xgij.getSubMatrix(j, j, 0, 3); + for (int i = 0; i < 4; i++) { + a.setEntry(i, 0, 1.0); + a.setEntry(i, 1, s.getEntry(0, i)); + a.setEntry(i, 2, s.getEntry(0, i) * s.getEntry(0, i)); + a.setEntry(i, 3, a.getEntry(i, 2) * s.getEntry(0, i)); + } + } + for (int j = 0; j < neq; j++) { + xg = Xgij.getSubMatrix(j, j, 0, 3).copy(); + DecompositionSolver solver2 = new LUDecomposition(a).getSolver(); + xcoef = solver2.solve(xg.transpose()); + double sny = ds + s.getEntry(0, 3); + u.setEntry(j, 0, xcoef.getEntry(0, 0) + sny + * (xcoef.getEntry(1, 0) + sny * (xcoef.getEntry(2, 0) + sny * xcoef.getEntry(3, 0)))); + logger.info("u" + j + " " + Math.exp(u.getEntry(j, 0))); } + uold = u.copy(); - /** - *

- * sign. - *

- * - * @param a a double - * @param b a double - * @return a double - */ - public double sign(double a, double b) { - a = Math.abs(a); - b = b >= 0 ? 1.0 : -1.0; - return a * b; + double xlnkmax = 0; + int numb = 0; + + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (Math.abs(u.getEntry(i, 0)) > xlnkmax) { + xlnkmax = Math.abs(u.getEntry(i, 0)); + numb = i; + } } - /** - *

- * solve. - *

- * - * @param np a int - */ - public void solve(int np) { - RealMatrix dx; - iter = 0; - - do { - iter++; - init(); - setfvec(); - setJac(); - DecompositionSolver solver2 = new LUDecomposition(Jac).getSolver(); - dx = solver2.solve(fvec); - u = u.subtract(dx); - - if (iter > 6) { - logger.info("iter > " + iter); - calcInc(np); - solve(np); - break; - } - - logger.info("feilen: " + dx.getNorm() / u.getNorm()); - } while (dx.getNorm() / u.getNorm() > 1.e-10 && !Double.isNaN(dx.getNorm())); - logger.info("iter: " + iter); - init(); + logger.info( + "klnmax: " + u.getEntry(numb, 0) + " np " + np + " xlnmax " + xlnkmax + "avsxp " + avscp); + // logger.info("np: " + np + " ico2p: " + ic02p + " ic03p " + ic03p); + + if ((testcrit == -3) && ic03p != np) { + etterCP2 = true; + etterCP = true; + logger.info("Etter CP"); + // System.exit(0); + ic03p = np; + testcrit = 0; + xg = Xgij.getSubMatrix(numb, numb, 0, 3); + + for (int i = 0; i < 4; i++) { + a.setEntry(i, 0, 1.0); + a.setEntry(i, 1, s.getEntry(0, i)); + a.setEntry(i, 2, s.getEntry(0, i) * s.getEntry(0, i)); + a.setEntry(i, 3, a.getEntry(i, 2) * s.getEntry(0, i)); + } + + DecompositionSolver solver2 = new LUDecomposition(a).getSolver(); + RealMatrix xcoef = solver2.solve(xg.transpose()); + + double[] coefs = new double[4]; + coefs[0] = xcoef.getEntry(3, 0); + coefs[1] = xcoef.getEntry(2, 0); + coefs[2] = xcoef.getEntry(1, 0); + coefs[3] = xcoef.getEntry(0, 0) - sign(avscp, -s.getEntry(0, 3)); + solver.setConstants(coefs); + + // logger.info("s4: " + s.get(0,3) + " coefs " + coefs[0] +" "+ coefs[1]+" " + + // coefs[2]+" " + coefs[3]); + double nys = solver.solve1order(s.getEntry(0, 3)); + // s = nys - s.get(0,3); + ds = sign(s.getEntry(0, 3) - nys, ds); + // logger.info("critpoint: " + ds); + + // ds = -nys - s.get(0,3); + calcInc2(np); + + TC2 = Math.exp(u.getEntry(system.getPhase(0).getNumberOfComponents(), 0)); + PC2 = Math.exp(u.getEntry(system.getPhase(0).getNumberOfComponents() + 1, 0)); + system.setTC((TC1 + TC2) * 0.5); + system.setPC((PC1 + PC2) * 0.5); + system.invertPhaseTypes(); + logger.info("invert phases...."); + // system.setPhaseType(0,0); + // system.setPhaseType(1,1); + return; + } else if ((xlnkmax < 1.5 && testcrit != 1) && (np != ic03p && !etterCP)) { + logger.info("hei fra her"); + testcrit = 1; + xg = Xgij.getSubMatrix(numb, numb, 0, 3); + + for (int i = 0; i < 4; i++) { + a.setEntry(i, 0, 1.0); + a.setEntry(i, 1, s.getEntry(0, i)); + a.setEntry(i, 2, s.getEntry(0, i) * s.getEntry(0, i)); + a.setEntry(i, 3, a.getEntry(i, 2) * s.getEntry(0, i)); + } + // a.print(0,10); + // xg.print(0,10); + + DecompositionSolver solver2 = new LUDecomposition(a).getSolver(); + RealMatrix xcoef = solver2.solve(xg.transpose()); + // xcoef.print(0,10); + + double[] coefs = new double[4]; + coefs[0] = xcoef.getEntry(3, 0); + coefs[1] = xcoef.getEntry(2, 0); + coefs[2] = xcoef.getEntry(1, 0); + coefs[3] = xcoef.getEntry(0, 0) - sign(avscp, ds); + solver.setConstants(coefs); + + // logger.info("s4: " + s.get(0,3) + " coefs " + coefs[0] +" "+ coefs[1]+" " + + // coefs[2]+" " + coefs[3]); + double nys = solver.solve1order(s.getEntry(0, 3)); + + ds = -nys - s.getEntry(0, 3); + // logger.info("critpoint: " + ds); + npCrit = np; + + calcInc2(np); + + TC1 = Math.exp(u.getEntry(system.getPhase(0).getNumberOfComponents(), 0)); + PC1 = Math.exp(u.getEntry(system.getPhase(0).getNumberOfComponents() + 1, 0)); + return; } - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - /* - * sysNewtonRhapson test=new sysNewtonRhapson(); double[] constants = new double[]{0.4,0.4}; - * test.setx(constants); while (test.nonsol()>1.0e-8) { constants=test.getx(); - * logger.info(constants[0]+" "+constants[1]); } test.nonsol(); constants=test.getf(); - * logger.info(constants[0]+" "+constants[1]); System.exit(0); - */ } + if (testcrit == 1) { + testcrit = -3; + } + } + + /** + *

+ * Getter for the field npCrit. + *

+ * + * @return a int + */ + public int getNpCrit() { + return npCrit; + } + + /** + *

+ * critPassed. + *

+ * + * @return a boolean + */ + public boolean critPassed() { + if (testcrit == 1) { + testcrit = -3; + return true; + } else { + return false; + } + } + + /** + *

+ * sign. + *

+ * + * @param a a double + * @param b a double + * @return a double + */ + public double sign(double a, double b) { + a = Math.abs(a); + b = b >= 0 ? 1.0 : -1.0; + return a * b; + } + + /** + *

+ * solve. + *

+ * + * @param np a int + */ + public void solve(int np) { + RealMatrix dx; + iter = 0; + + do { + iter++; + init(); + setfvec(); + setJac(); + DecompositionSolver solver2 = new LUDecomposition(Jac).getSolver(); + dx = solver2.solve(fvec); + u = u.subtract(dx); + + if (iter > 6) { + logger.info("iter > " + iter); + calcInc(np); + solve(np); + break; + } + + logger.info("feilen: " + dx.getNorm() / u.getNorm()); + } while (dx.getNorm() / u.getNorm() > 1.e-10 && !Double.isNaN(dx.getNorm())); + logger.info("iter: " + iter); + init(); + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + /* + * sysNewtonRhapson test=new sysNewtonRhapson(); double[] constants = new double[]{0.4,0.4}; + * test.setx(constants); while (test.nonsol()>1.0e-8) { constants=test.getx(); + * logger.info(constants[0]+" "+constants[1]); } test.nonsol(); constants=test.getf(); + * logger.info(constants[0]+" "+constants[1]); System.exit(0); + */ } } diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/reactiveCurves/pLoadingCurve2.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/reactiveCurves/pLoadingCurve2.java index aa2372274b..79c3c12a05 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/reactiveCurves/pLoadingCurve2.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/reactiveCurves/pLoadingCurve2.java @@ -25,20 +25,32 @@ public class pLoadingCurve2 extends BaseOperation { static Logger logger = LogManager.getLogger(pLoadingCurve2.class); SystemInterface system; - int i, j = 0, nummer = 0, iterations = 0, maxNumberOfIterations = 10000; - double gibbsEnergy = 0, gibbsEnergyOld = 0; - double Kold, deviation = 0, g0 = 0, g1 = 0; - double lnOldOldK[], lnK[]; - double lnOldK[]; - double oldDeltalnK[], deltalnK[]; - double tm[] = {1, 1}; + int i; + int j = 0; + int nummer = 0; + int iterations = 0; + int maxNumberOfIterations = 10000; + double gibbsEnergy = 0; + double gibbsEnergyOld = 0; + double Kold; + double deviation = 0; + double g0 = 0; + double g1 = 0; + double lnOldOldK[]; + double lnK[]; + double[] lnOldK; + double oldDeltalnK[]; + double deltalnK[]; + double[] tm = {1, 1}; double beta = 1e-5; int lowestGibbsEnergyPhase = 0; // lowestGibbsEnergyPhase JProgressBar monitor; JFrame mainFrame; JPanel mainPanel; - double temp = 0, pres = 0, startPres = 0; + double temp = 0; + double pres = 0; + double startPres = 0; double[][] points = new double[35][]; boolean moreLines = false; @@ -115,7 +127,7 @@ public void run() { for (int k = 0; k < system.getPhases()[1].getNumberOfComponents(); k++) { points[k + 3][i] = system.getPhases()[1].getComponents()[k].getx(); points[k + 3 + system.getPhases()[1].getNumberOfComponents()][i] = - system.getPhase(1).getActivityCoefficient(k, 1);// ,1); + system.getPhase(1).getActivityCoefficient(k, 1); // ,1); } logger.info( "point: " + points[0][i] + " tot pres " + points[1][i] + " CO2 pres " + points[2][i]); diff --git a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWater.java b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWater.java index 827866df42..e0a7768109 100644 --- a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWater.java +++ b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWater.java @@ -24,1507 +24,1484 @@ * @version $Id: $Id */ public class OLGApropertyTableGeneratorWater extends neqsim.thermodynamicOperations.BaseOperation { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(OLGApropertyTableGeneratorWater.class); - - BicubicInterpolator interpolationFunc = new BicubicInterpolator(); - SystemInterface thermoSystem = null, gasSystem = null, oilSystem = null, waterSystem = null; - ThermodynamicOperations thermoOps = null; - double[] pressures, temperatureLOG, temperatures, pressureLOG = null; - double[] bubP, bubT, dewP, bubPLOG, dewPLOG; - Matrix XMatrixgas, XMatrixoil, XMatrixwater; - double[][] ROG = null; - // double[][] ROL, CPG, CPHL, HG, HHL, TCG, TCHL, VISG, VISHL, SIGGHL, SEG, - // SEHL, RS; - double TC, PC; - double RSWTOB; - double[][][] props; - int nProps; - String[] names; - Matrix[] xcoef = new Matrix[9]; - String[] units; - int temperatureSteps, pressureSteps; - boolean continuousDerivativesExtrapolation = true; - boolean hasGasValues = false; - boolean hasOilValues = false; - boolean hasWaterValues = false; - boolean[][][] hasValue; - Matrix aMatrix = new Matrix(4, 4); - Matrix s = new Matrix(1, 4); - String fileName = "c:/Appl/OLGAneqsim.tab"; - - /** - *

- * Constructor for OLGApropertyTableGeneratorWater. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public OLGApropertyTableGeneratorWater(SystemInterface system) { - this.thermoSystem = system; - thermoOps = new ThermodynamicOperations(thermoSystem); - - XMatrixgas = new Matrix(9, 4); - XMatrixoil = new Matrix(9, 4); - XMatrixwater = new Matrix(9, 4); - - gasSystem = new SystemSrkEos(298, 10); - gasSystem.addComponent("methane", 1); - // gasSystem.createDatabase(true); - gasSystem.init(0); - gasSystem.setNumberOfPhases(1); - - waterSystem = new SystemSrkCPAstatoil(298, 10); - waterSystem.addComponent("water", 1); - // waterSystem.createDatabase(true); - waterSystem.init(0); - waterSystem.setNumberOfPhases(1); - - oilSystem = new SystemSrkEos(298, 10); - oilSystem.addComponent("nC10", 1); - // oilSystem.createDatabase(true); - oilSystem.init(0); - oilSystem.setNumberOfPhases(1); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(OLGApropertyTableGeneratorWater.class); + + BicubicInterpolator interpolationFunc = new BicubicInterpolator(); + SystemInterface thermoSystem = null; + SystemInterface gasSystem = null; + SystemInterface oilSystem = null; + SystemInterface waterSystem = null; + ThermodynamicOperations thermoOps = null; + double[] pressures; + double[] temperatureLOG; + double[] temperatures; + double[] pressureLOG = null; + double[] bubP; + double[] bubT; + double[] dewP; + double[] bubPLOG; + double[] dewPLOG; + Matrix XMatrixgas; + Matrix XMatrixoil; + Matrix XMatrixwater; + double[][] ROG = null; + double TC; + double PC; + double RSWTOB; + double[][][] props; + int nProps; + String[] names; + Matrix[] xcoef = new Matrix[9]; + String[] units; + int temperatureSteps; + int pressureSteps; + boolean continuousDerivativesExtrapolation = true; + boolean hasGasValues = false; + boolean hasOilValues = false; + boolean hasWaterValues = false; + boolean[][][] hasValue; + Matrix aMatrix = new Matrix(4, 4); + Matrix s = new Matrix(1, 4); + String fileName = "c:/Appl/OLGAneqsim.tab"; + + /** + *

+ * Constructor for OLGApropertyTableGeneratorWater. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public OLGApropertyTableGeneratorWater(SystemInterface system) { + this.thermoSystem = system; + thermoOps = new ThermodynamicOperations(thermoSystem); + + XMatrixgas = new Matrix(9, 4); + XMatrixoil = new Matrix(9, 4); + XMatrixwater = new Matrix(9, 4); + + gasSystem = new SystemSrkEos(298, 10); + gasSystem.addComponent("methane", 1); + // gasSystem.createDatabase(true); + gasSystem.init(0); + gasSystem.setNumberOfPhases(1); + + waterSystem = new SystemSrkCPAstatoil(298, 10); + waterSystem.addComponent("water", 1); + // waterSystem.createDatabase(true); + waterSystem.init(0); + waterSystem.setNumberOfPhases(1); + + oilSystem = new SystemSrkEos(298, 10); + oilSystem.addComponent("nC10", 1); + // oilSystem.createDatabase(true); + oilSystem.init(0); + oilSystem.setNumberOfPhases(1); + } + + /** + *

+ * Setter for the field fileName. + *

+ * + * @param name a {@link java.lang.String} object + */ + public void setFileName(String name) { + fileName = name; + } + + /** + *

+ * setPressureRange. + *

+ * + * @param minPressure a double + * @param maxPressure a double + * @param numberOfSteps a int + */ + public void setPressureRange(double minPressure, double maxPressure, int numberOfSteps) { + pressures = new double[numberOfSteps]; + pressureLOG = new double[numberOfSteps]; + double step = (maxPressure - minPressure) / (numberOfSteps * 1.0 - 1.0); + for (int i = 0; i < numberOfSteps; i++) { + pressures[i] = minPressure + i * step; + pressureLOG[i] = pressures[i] * 1e5; + } + } + + /** + *

+ * setTemperatureRange. + *

+ * + * @param minTemperature a double + * @param maxTemperature a double + * @param numberOfSteps a int + */ + public void setTemperatureRange(double minTemperature, double maxTemperature, int numberOfSteps) { + temperatures = new double[numberOfSteps]; + temperatureLOG = new double[numberOfSteps]; + double step = (maxTemperature - minTemperature) / (numberOfSteps * 1.0 - 1.0); + for (int i = 0; i < numberOfSteps; i++) { + temperatures[i] = minTemperature + i * step; + temperatureLOG[i] = temperatures[i] - 273.15; + } + } + + /** + *

+ * calcPhaseEnvelope. + *

+ */ + public void calcPhaseEnvelope() { + try { + thermoOps.calcPTphaseEnvelope(); + TC = thermoSystem.getTC() - 273.15; + PC = thermoSystem.getPC() * 1e5; + } catch (Exception e) { + logger.error("error", e); + } + } + + /** + *

+ * calcBubP. + *

+ * + * @param temperatures an array of {@link double} objects + * @return an array of {@link double} objects + */ + public double[] calcBubP(double[] temperatures) { + double[] bubP = new double[temperatures.length]; + bubPLOG = new double[temperatures.length]; + for (int i = 0; i < temperatures.length; i++) { + thermoSystem.setTemperature(temperatures[i]); + try { + thermoOps.bubblePointPressureFlash(false); + bubP[i] = thermoSystem.getPressure(); + bubPLOG[i] = bubP[i] * 1e5; + } catch (Exception e) { + logger.error("error", e); + bubP[i] = 0; + } + } + return bubP; + } + + /** + *

+ * calcDewP. + *

+ * + * @param temperatures an array of {@link double} objects + * @return an array of {@link double} objects + */ + public double[] calcDewP(double[] temperatures) { + double[] dewP = new double[temperatures.length]; + dewPLOG = new double[temperatures.length]; + for (int i = 0; i < temperatures.length; i++) { + thermoSystem.setTemperature(temperatures[i]); + try { + thermoOps.dewPointPressureFlashHC(); + dewP[i] = thermoSystem.getPressure(); + dewPLOG[i] = dewP[i] * 1e5; + } catch (Exception e) { + logger.error("error", e); + dewP[i] = 0; + } + } + return dewP; + } + + /** + *

+ * calcBubT. + *

+ * + * @param pressures an array of {@link double} objects + * @return an array of {@link double} objects + */ + public double[] calcBubT(double[] pressures) { + double[] bubTemps = new double[pressures.length]; + for (int i = 0; i < pressures.length; i++) { + thermoSystem.setPressure(pressures[i]); + try { + thermoOps.bubblePointTemperatureFlash(); + bubT[i] = thermoSystem.getPressure(); + } catch (Exception e) { + logger.error("error", e); + bubT[i] = 0.0; + } + } + return bubTemps; + } + + /** + *

+ * initCalc. + *

+ */ + public void initCalc() { + double stdTemp = 288.15; + double stdPres = 1.01325; + // double GOR, GLR; + double[] molfracs = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; + double[] MW = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; + double[] dens = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; + String[] components = new String[thermoSystem.getPhase(0).getNumberOfComponents()]; + + for (int i = 0; i < molfracs.length; i++) { + molfracs[i] = thermoSystem.getPhase(0).getComponent(i).getz(); + components[i] = thermoSystem.getPhase(0).getComponent(i).getComponentName(); + MW[i] = thermoSystem.getPhase(0).getComponent(i).getMolarMass() * 1000; + dens[i] = thermoSystem.getPhase(0).getComponent(i).getNormalLiquidDensity(); } - /** - *

- * Setter for the field fileName. - *

- * - * @param name a {@link java.lang.String} object - */ - public void setFileName(String name) { - fileName = name; + thermoSystem.setTemperature(stdTemp); + thermoSystem.setPressure(stdPres); + + thermoOps.TPflash(); + + // GOR = thermoSystem.getPhase(0).getTotalVolume() / + // thermoSystem.getPhase(1).getTotalVolume(); + // GLR = thermoSystem.getPhase(0).getTotalVolume() / + // thermoSystem.getPhase(1).getTotalVolume(); + } + + /** + *

+ * calcRSWTOB. + *

+ */ + public void calcRSWTOB() { + thermoSystem.init(0); + thermoSystem.init(1); + if (thermoSystem.getPhase(0).hasComponent("water")) { + RSWTOB = thermoSystem.getPhase(0).getComponent("water").getNumberOfmoles() + * thermoSystem.getPhase(0).getComponent("water").getMolarMass() + / (thermoSystem.getTotalNumberOfMoles() * thermoSystem.getMolarMass()); + } else { + RSWTOB = 0.0; } + } + + /** {@inheritDoc} */ + @Override + public void run() { + calcRSWTOB(); + logger.info("RSWTOB " + RSWTOB); + nProps = 29; + props = new double[nProps][pressures.length][temperatures.length]; + units = new String[nProps]; + names = new String[nProps]; + + // int startGasTemperatures = 0; + boolean acceptedFlash = true; + for (int j = 0; j < temperatures.length; j++) { + thermoSystem.setTemperature(temperatures[j]); + for (int i = 0; i < pressures.length; i++) { + thermoSystem.setPressure(pressures[i]); + try { + logger.info("TPflash... " + thermoSystem.getTemperature() + " pressure " + + thermoSystem.getPressure()); + if (thermoSystem.getTemperature() > (273.15 + 106.8)) { + logger.info("here I am"); + thermoOps.TPflash(); + } else { + thermoOps.TPflash(); + } + thermoSystem.init(3); + thermoSystem.initPhysicalProperties(); + acceptedFlash = true; + } catch (Exception e) { + acceptedFlash = false; + logger.info("fail temperature " + thermoSystem.getTemperature() + " fail pressure " + + thermoSystem.getPressure()); - /** - *

- * setPressureRange. - *

- * - * @param minPressure a double - * @param maxPressure a double - * @param numberOfSteps a int - */ - public void setPressureRange(double minPressure, double maxPressure, int numberOfSteps) { - pressures = new double[numberOfSteps]; - pressureLOG = new double[numberOfSteps]; - double step = (maxPressure - minPressure) / (numberOfSteps * 1.0 - 1.0); - for (int i = 0; i < numberOfSteps; i++) { - pressures[i] = minPressure + i * step; - pressureLOG[i] = pressures[i] * 1e5; + thermoSystem.display(); + logger.error("error", e); } - } - /** - *

- * setTemperatureRange. - *

- * - * @param minTemperature a double - * @param maxTemperature a double - * @param numberOfSteps a int - */ - public void setTemperatureRange(double minTemperature, double maxTemperature, - int numberOfSteps) { - temperatures = new double[numberOfSteps]; - temperatureLOG = new double[numberOfSteps]; - double step = (maxTemperature - minTemperature) / (numberOfSteps * 1.0 - 1.0); - for (int i = 0; i < numberOfSteps; i++) { - temperatures[i] = minTemperature + i * step; - temperatureLOG[i] = temperatures[i] - 273.15; + /* + * logger.info("water density " + + * thermoSystem.getPhase(2).getPhysicalProperties().getDensity()); logger.info("RSW " + + * thermoSystem.getPhase(0).getComponent("water").getx() * + * thermoSystem.getPhase(0).getComponent("water").getMolarMass() / + * thermoSystem.getPhase(0).getMolarMass()); logger.info("surf tens oil-water " + + * thermoSystem.getInterphaseProperties().getSurfaceTension(1, 2)); + * logger.info("surf tens gas-water " + + * thermoSystem.getInterphaseProperties().getSurfaceTension(0, 2)); + */ + int k = 0; + if (thermoSystem.hasPhaseType("gas") && acceptedFlash) { + int phaseNumb = thermoSystem.getPhaseNumberOfPhase("gas"); + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); + names[k] = "GAS DENSITY"; + units[k] = "KG/M3"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; + names[k] = "DRHOG/DP"; + units[k] = "S2/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); + names[k] = "DRHOG/DT"; + units[k] = "KG/M3-K"; + k++; + + // double beta = 0.0; + if (thermoSystem.hasPhaseType("oil")) { + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getBeta() + * thermoSystem.getPhase(phaseNumb).getMolarMass() + / (thermoSystem.getPhase(phaseNumb).getBeta() + * thermoSystem.getPhase(phaseNumb).getMolarMass() + + thermoSystem.getPhase("oil").getBeta() + * thermoSystem.getPhase("oil").getMolarMass()); + } else { + props[k][i][j] = 1.0; // thermoSystem.getPhase(phaseNumb).getBeta() * + // thermoSystem.getPhase(phaseNumb).getMolarMass() / + // thermoSystem.getMolarMass(); + } + names[k] = "GAS MASS FRACTION"; + units[k] = "-"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); + names[k] = "GAS VISCOSITY"; + units[k] = "NS/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "GAS HEAT CAPACITY"; + units[k] = "J/KG-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEnthalpy() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "GAS ENTHALPY"; + units[k] = "J/KG"; + k++; + + props[k][i][j] = + thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getConductivity(); + names[k] = "GAS THERMAL CONDUCTIVITY"; + units[k] = "W/M-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "GAS ENTROPY"; + units[k] = "J/KG/K"; + k++; + hasGasValues = true; + // set gas properties + } else { + if (continuousDerivativesExtrapolation && hasGasValues) { + do { + if (i > 1) { + props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) + / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + // } //else if (j < 2) { + // props[k][i][j] = 0; //props[k][i - 1][j] + (props[k][i - 1][j] - + // props[k][i - + // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - + // pressures[i + // - 1]); + // } else { + // props[k][i][j] = 0; //props[k][i - 1][j - 1] + (props[k][i][j - + // 1] + // - + // props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - 2]) + // * + // (temperatures[j] - temperatures[j - 1]) + (props[k][i - 1][j] - + // props[k][i - + // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - + // pressures[i + // - 1]); + // double newTemp = pressures[i]; + // double vall = xcoef[k].get(0, 0) + newTemp * (xcoef[k].get(1, 0) + // + newTemp * + // (xcoef[k].get(2, 0) + newTemp * xcoef[k].get(3, 0))); + // props[k][i][j] = vall; + // if(i>0 && props[k][i-1][j]>1e-10) props[k][i][j] = + // props[k][i-1][j]*pressures[i]/pressures[i-1]; + } + if (names[k].equals("GAS MASS FRACTION") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + k++; + } while (k < 9); // names[k] = "GAS DENSITY"; + // units[k] = "KG/M3"; + /* + * } else if (false && !hasGasValues) { startGasTemperatures = j; + */ + } else { + gasSystem.setTemperature(temperatures[j]); + gasSystem.setPressure(pressures[i]); + gasSystem.init(3); + gasSystem.initPhysicalProperties(); + // gasSystem.display(); + props[k][i][j] = gasSystem.getPhase(0).getPhysicalProperties().getDensity(); + names[k] = "GAS DENSITY"; + units[k] = "KG/M3"; + k++; + props[k][i][j] = gasSystem.getPhase(0).getdrhodP() / 1.0e5; + names[k] = "DRHOG/DP"; + units[k] = "S2/M2"; + k++; + props[k][i][j] = gasSystem.getPhase(0).getdrhodT(); + names[k] = "DRHOG/DT"; + units[k] = "KG/M3-K"; + k++; + + props[k][i][j] = 0.0; // thermoSystem.getPhase(phaseNumb).getBeta() * + // thermoSystem.getPhase(phaseNumb).getMolarMass() / + // thermoSystem.getMolarMass(); + names[k] = "GAS MASS FRACTION"; + units[k] = "-"; + k++; + + props[k][i][j] = gasSystem.getPhase(0).getPhysicalProperties().getViscosity(); + names[k] = "GAS VISCOSITY"; + units[k] = "NS/M2"; + k++; + + props[k][i][j] = + gasSystem.getPhase(0).getCp() / gasSystem.getPhase(0).getNumberOfMolesInPhase() + / gasSystem.getPhase(0).getMolarMass(); + names[k] = "GAS HEAT CAPACITY"; + units[k] = "J/KG-K"; + k++; + + props[k][i][j] = gasSystem.getPhase(0).getEnthalpy() + / gasSystem.getPhase(0).getNumberOfMolesInPhase() + / gasSystem.getPhase(0).getMolarMass(); + names[k] = "GAS ENTHALPY"; + units[k] = "J/KG"; + k++; + + props[k][i][j] = gasSystem.getPhase(0).getPhysicalProperties().getConductivity(); + names[k] = "GAS THERMAL CONDUCTIVITY"; + units[k] = "W/M-K"; + k++; + + props[k][i][j] = + gasSystem.getPhase(0).getEntropy() / gasSystem.getPhase(0).getNumberOfMolesInPhase() + / gasSystem.getPhase(0).getMolarMass(); + names[k] = "GAS ENTROPY"; + units[k] = "J/KG/K"; + k++; + } } - } - /** - *

- * calcPhaseEnvelope. - *

- */ - public void calcPhaseEnvelope() { - try { - thermoOps.calcPTphaseEnvelope(); - TC = thermoSystem.getTC() - 273.15; - PC = thermoSystem.getPC() * 1e5; - } catch (Exception e) { - logger.error("error", e); + if (thermoSystem.hasPhaseType("oil") && acceptedFlash) { + int phaseNumb = thermoSystem.getPhaseNumberOfPhase("oil"); + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); + names[k] = "LIQUID DENSITY"; + units[k] = "KG/M3"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; + names[k] = "DRHOL/DP"; + units[k] = "S2/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); + names[k] = "DRHOL/DT"; + units[k] = "KG/M3-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); + names[k] = "LIQUID VISCOSITY"; + units[k] = "NS/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "LIQUID HEAT CAPACITY"; + units[k] = "J/KG-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEnthalpy() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "LIQUID ENTHALPY"; + units[k] = "J/KG"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "LIQUID ENTROPY"; + units[k] = "J/KG/K"; + k++; + + props[k][i][j] = + thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getConductivity(); + names[k] = "LIQUID THERMAL CONDUCTIVITY"; + units[k] = "W/M-K"; + k++; + hasOilValues = true; + } else { + if (continuousDerivativesExtrapolation && hasOilValues) { + do { + if (i > 1) { + props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) + / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + } + /* + * if (i < 2) { props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - + * props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * + * (temperatures[j] - temperatures[j - 1]); } else if (j < 2) { props[k][i][j] = + * props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) / (pressures[i - 1] + * - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); } else { props[k][i][j] = + * props[k][i - 1][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) / + * (temperatures[j - 1] - temperatures[j - 2]) * (temperatures[j] - temperatures[j - + * 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / (pressures[i - 1] - pressures[i - + * 2]) * (pressures[i] - pressures[i - 1]); } props[k][i][j] = 0.0; + */ + k++; + } while (k < 17); // names[k] = "GAS DENSITY"; + // units[k] = "KG/M3"; + } else { + oilSystem.setPhaseType(0, 0); + oilSystem.setTemperature(temperatures[j]); + oilSystem.setPressure(pressures[i]); + oilSystem.init(3); + oilSystem.initPhysicalProperties(); + + props[k][i][j] = oilSystem.getPhase(0).getPhysicalProperties().getDensity(); + names[k] = "LIQUID DENSITY"; + units[k] = "KG/M3"; + k++; + + props[k][i][j] = oilSystem.getPhase(0).getdrhodP() / 1.0e5; + names[k] = "DRHOL/DP"; + units[k] = "S2/M2"; + k++; + + props[k][i][j] = oilSystem.getPhase(0).getdrhodT(); + names[k] = "DRHOL/DT"; + units[k] = "KG/M3-K"; + k++; + + props[k][i][j] = oilSystem.getPhase(0).getPhysicalProperties().getViscosity(); + names[k] = "LIQUID VISCOSITY"; + units[k] = "NS/M2"; + k++; + + props[k][i][j] = + oilSystem.getPhase(0).getCp() / oilSystem.getPhase(0).getNumberOfMolesInPhase() + / oilSystem.getPhase(0).getMolarMass(); + names[k] = "LIQUID HEAT CAPACITY"; + units[k] = "J/KG-K"; + k++; + + props[k][i][j] = oilSystem.getPhase(0).getEnthalpy() + / oilSystem.getPhase(0).getNumberOfMolesInPhase() + / oilSystem.getPhase(0).getMolarMass(); + names[k] = "LIQUID ENTHALPY"; + units[k] = "J/KG"; + k++; + + props[k][i][j] = + oilSystem.getPhase(0).getEntropy() / oilSystem.getPhase(0).getNumberOfMolesInPhase() + / oilSystem.getPhase(0).getMolarMass(); + names[k] = "LIQUID ENTROPY"; + units[k] = "J/KG/K"; + k++; + + props[k][i][j] = oilSystem.getPhase(0).getPhysicalProperties().getConductivity(); + names[k] = "LIQUID THERMAL CONDUCTIVITY"; + units[k] = "W/M-K"; + k++; + } + // setOilProperties(); + // set gas properties } - } - /** - *

- * calcBubP. - *

- * - * @param temperatures an array of {@link double} objects - * @return an array of {@link double} objects - */ - public double[] calcBubP(double[] temperatures) { - double[] bubP = new double[temperatures.length]; - bubPLOG = new double[temperatures.length]; - for (int i = 0; i < temperatures.length; i++) { - thermoSystem.setTemperature(temperatures[i]); - try { - thermoOps.bubblePointPressureFlash(false); - bubP[i] = thermoSystem.getPressure(); - bubPLOG[i] = bubP[i] * 1e5; - } catch (Exception e) { - logger.error("error", e); - bubP[i] = 0; + if (thermoSystem.hasPhaseType("aqueous") && acceptedFlash) { + int phaseNumb = thermoSystem.getPhaseNumberOfPhase("aqueous"); + + props[k][i][j] = thermoSystem.getPhase(0).getComponent("water").getx() + * thermoSystem.getPhase(0).getComponent("water").getMolarMass() + / thermoSystem.getPhase(0).getMolarMass(); + names[k] = "WATER VAPOR MASS FRACTION"; + units[k] = "-"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); + names[k] = "WATER DENSITY"; + units[k] = "KG/M3"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; + names[k] = "DRHOWAT/DP"; + units[k] = "S2/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); + names[k] = "DRHOWAT/DT"; + units[k] = "KG/M3-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); + names[k] = "WATER VISCOSITY"; + units[k] = "NS/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "WATER HEAT CAPACITY"; + units[k] = "J/KG-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEnthalpy() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "WATER ENTHALPY"; + units[k] = "J/KG"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "WATER ENTROPY"; + units[k] = "J/KG/K"; + k++; + + props[k][i][j] = + thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getConductivity(); + names[k] = "WATER THERMAL CONDUCTIVITY"; + units[k] = "W/M-K"; + k++; + hasWaterValues = true; + } else { + if (continuousDerivativesExtrapolation && hasWaterValues) { + do { + if (j > 1) { + props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) + / (temperatures[j - 1] - temperatures[j - 2]) + * (temperatures[j] - temperatures[j - 1]); + } + /* + * if (i < 2) { props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - + * props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * + * (temperatures[j] - temperatures[j - 1]); } else if (j < 2) { props[k][i][j] = + * props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) / (pressures[i - 1] + * - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); } else { props[k][i][j] = + * props[k][i - 1][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) / + * (temperatures[j - 1] - temperatures[j - 2]) * (temperatures[j] - temperatures[j - + * 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / (pressures[i - 1] - pressures[i - + * 2]) * (pressures[i] - pressures[i - 1]); } props[k][i][j] = 0.0; + */ + k++; + } while (k < 26); // names[k] = "GAS DENSITY"; + // units[k] = "KG/M3"; + } else { + waterSystem.setTemperature(temperatures[j]); + waterSystem.setPressure(pressures[i]); + waterSystem.setPhaseType(0, 0); + waterSystem.init(3); + waterSystem.initPhysicalProperties(); + + if (thermoSystem.getPhase(0).hasComponent("water")) { + props[k][i][j] = thermoSystem.getPhase(0).getComponent("water").getz() + * thermoSystem.getPhase(0).getComponent("water").getMolarMass() + / thermoSystem.getPhase(0).getMolarMass(); + } else { + props[k][i][j] = 0.0; } + names[k] = "WATER VAPOR MASS FRACTION"; + units[k] = "-"; + k++; + + props[k][i][j] = waterSystem.getPhase(0).getPhysicalProperties().getDensity(); + names[k] = "WATER DENSITY"; + units[k] = "KG/M3"; + k++; + + props[k][i][j] = waterSystem.getPhase(0).getdrhodP() / 1.0e5; + names[k] = "DRHOWAT/DP"; + units[k] = "S2/M2"; + k++; + + props[k][i][j] = waterSystem.getPhase(0).getdrhodT(); + names[k] = "DRHOWAT/DT"; + units[k] = "KG/M3-K"; + k++; + + props[k][i][j] = waterSystem.getPhase(0).getPhysicalProperties().getViscosity(); + names[k] = "WATER VISCOSITY"; + units[k] = "NS/M2"; + k++; + + props[k][i][j] = + waterSystem.getPhase(0).getCp() / waterSystem.getPhase(0).getNumberOfMolesInPhase() + / waterSystem.getPhase(0).getMolarMass(); + names[k] = "WATER HEAT CAPACITY"; + units[k] = "J/KG-K"; + k++; + + props[k][i][j] = waterSystem.getPhase(0).getEnthalpy() + / waterSystem.getPhase(0).getNumberOfMolesInPhase() + / waterSystem.getPhase(0).getMolarMass(); + names[k] = "WATER ENTHALPY"; + units[k] = "J/KG"; + k++; + + props[k][i][j] = waterSystem.getPhase(0).getEntropy() + / waterSystem.getPhase(0).getNumberOfMolesInPhase() + / waterSystem.getPhase(0).getMolarMass(); + names[k] = "WATER ENTROPY"; + units[k] = "J/KG/K"; + k++; + + props[k][i][j] = waterSystem.getPhase(0).getPhysicalProperties().getConductivity(); + names[k] = "WATER THERMAL CONDUCTIVITY"; + units[k] = "W/M-K"; + k++; + } } - return bubP; - } - /** - *

- * calcDewP. - *

- * - * @param temperatures an array of {@link double} objects - * @return an array of {@link double} objects - */ - public double[] calcDewP(double[] temperatures) { - double[] dewP = new double[temperatures.length]; - dewPLOG = new double[temperatures.length]; - for (int i = 0; i < temperatures.length; i++) { - thermoSystem.setTemperature(temperatures[i]); - try { - thermoOps.dewPointPressureFlashHC(); - dewP[i] = thermoSystem.getPressure(); - dewPLOG[i] = dewP[i] * 1e5; - } catch (Exception e) { - logger.error("error", e); - dewP[i] = 0; + if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("oil") && acceptedFlash) { + props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( + thermoSystem.getPhaseNumberOfPhase("gas"), thermoSystem.getPhaseNumberOfPhase("oil")); + names[k] = "VAPOR-LIQUID SURFACE TENSION"; + units[k] = "N/M"; + k++; + } else { + if (continuousDerivativesExtrapolation && (i >= 2 || j >= 2)) { + if (i < 2) { + props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) + / (temperatures[j - 1] - temperatures[j - 2]) + * (temperatures[j] - temperatures[j - 1]); + } else if (j < 2) { + props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) + / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + } else { + props[k][i][j] = props[k][i - 1][j - 1] + + (props[k][i][j - 1] - props[k][i][j - 2]) + / (temperatures[j - 1] - temperatures[j - 2]) + * (temperatures[j] - temperatures[j - 1]) + + (props[k][i - 1][j] - props[k][i - 2][j]) + / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); } + props[k][i][j] = 10.0e-3; + k++; + } else { + props[k][i][j] = 10.0e-3; + names[k] = "VAPOR-LIQUID SURFACE TENSION"; + units[k] = "N/M"; + k++; + } } - return dewP; - } - /** - *

- * calcBubT. - *

- * - * @param pressures an array of {@link double} objects - * @return an array of {@link double} objects - */ - public double[] calcBubT(double[] pressures) { - double[] bubTemps = new double[pressures.length]; - for (int i = 0; i < pressures.length; i++) { - thermoSystem.setPressure(pressures[i]); - try { - thermoOps.bubblePointTemperatureFlash(); - bubT[i] = thermoSystem.getPressure(); - } catch (Exception e) { - logger.error("error", e); - bubT[i] = 0.0; + if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("aqueous") + && acceptedFlash) { + props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( + thermoSystem.getPhaseNumberOfPhase("gas"), + thermoSystem.getPhaseNumberOfPhase("aqueous")); + names[k] = "VAPOR-WATER SURFACE TENSION"; + units[k] = "N/M"; + k++; + } else { + if (continuousDerivativesExtrapolation && (i >= 2 || j >= 2)) { + if (i < 2) { + props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) + / (temperatures[j - 1] - temperatures[j - 2]) + * (temperatures[j] - temperatures[j - 1]); + } else if (j < 2) { + props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) + / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + } else { + props[k][i][j] = props[k][i - 1][j - 1] + + (props[k][i][j - 1] - props[k][i][j - 2]) + / (temperatures[j - 1] - temperatures[j - 2]) + * (temperatures[j] - temperatures[j - 1]) + + (props[k][i - 1][j] - props[k][i - 2][j]) + / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); } + props[k][i][j] = 60.0e-3; + k++; + } else { + props[k][i][j] = 60.0e-3; + names[k] = "VAPOR-WATER SURFACE TENSION"; + units[k] = "N/M"; + k++; + } } - return bubTemps; - } - /** - *

- * initCalc. - *

- */ - public void initCalc() { - double stdTemp = 288.15, stdPres = 1.01325; - // double GOR, GLR; - double molfracs[] = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; - double MW[] = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; - double dens[] = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; - String components[] = new String[thermoSystem.getPhase(0).getNumberOfComponents()]; - - for (int i = 0; i < molfracs.length; i++) { - molfracs[i] = thermoSystem.getPhase(0).getComponent(i).getz(); - components[i] = thermoSystem.getPhase(0).getComponent(i).getComponentName(); - MW[i] = thermoSystem.getPhase(0).getComponent(i).getMolarMass() * 1000; - dens[i] = thermoSystem.getPhase(0).getComponent(i).getNormalLiquidDensity(); + if (thermoSystem.hasPhaseType("oil") && thermoSystem.hasPhaseType("aqueous") + && acceptedFlash) { + props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( + thermoSystem.getPhaseNumberOfPhase("oil"), + thermoSystem.getPhaseNumberOfPhase("aqueous")); + names[k] = "LIQUID-WATER SURFACE TENSION"; + units[k] = "N/M"; + k++; + } else { + if (continuousDerivativesExtrapolation && (i >= 2 || j >= 2)) { + if (i < 2) { + props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) + / (temperatures[j - 1] - temperatures[j - 2]) + * (temperatures[j] - temperatures[j - 1]); + } else if (j < 2) { + props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) + / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + } else { + props[k][i][j] = props[k][i - 1][j - 1] + + (props[k][i][j - 1] - props[k][i][j - 2]) + / (temperatures[j - 1] - temperatures[j - 2]) + * (temperatures[j] - temperatures[j - 1]) + + (props[k][i - 1][j] - props[k][i - 2][j]) + / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + } + props[k][i][j] = 20.0e-3; + k++; + } else { + props[k][i][j] = 20.0e-3; + names[k] = "LIQUID-WATER SURFACE TENSION"; + units[k] = "N/M"; + k++; + } } - - thermoSystem.setTemperature(stdTemp); - thermoSystem.setPressure(stdPres); - - thermoOps.TPflash(); - - // GOR = thermoSystem.getPhase(0).getTotalVolume() / - // thermoSystem.getPhase(1).getTotalVolume(); - // GLR = thermoSystem.getPhase(0).getTotalVolume() / - // thermoSystem.getPhase(1).getTotalVolume(); + } } - - /** - *

- * calcRSWTOB. - *

+ logger.info("Finished TPflash..."); + if (thermoSystem.getPhase(0).hasComponent("water")) { + thermoSystem.removeComponent("water"); + } + bubP = calcBubP(temperatures); + dewP = calcDewP(temperatures); + // bubT = calcBubT(temperatures); + logger.info("Finished creating arrays"); + BicubicInterpolatingFunction funcGasDens = + interpolationFunc.interpolate(pressures, temperatures, props[0]); + logger.info("interpolated value " + funcGasDens.value(40, 298.0)); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + logger.info("TC " + TC + " PC " + PC); + for (int i = 0; i < pressures.length; i++) { + thermoSystem.setPressure(pressures[i]); + for (int j = 0; j < temperatures.length; j++) { + logger.info("pressure " + pressureLOG[i] + " temperature " + temperatureLOG[j]); // + + // " + // ROG + // " + // + + // ROG[i][j] + // + + // " + // ROL + // " + // + + // ROL[i][j]); + } + } + writeOLGAinpFile(fileName); + } + + /** + *

+ * writeOLGAinpFile2. + *

+ * + * @param filename a {@link java.lang.String} object + */ + public void writeOLGAinpFile2(String filename) { + /* + * try { writer = new BufferedWriter(new OutputStreamWriter( new + * FileOutputStream("C:/Users/Kjetil Raul/Documents/Master KRB/javacode_ROG55.txt" ), "utf-8")); + * writer.write("GAS DENSITY (KG/M3) = ("); for (int i = 0; i < pressures.length; i++) { + * thermoSystem.setPressure(pressures[i]); for (int j = 0; j < temperatures.length; j++) { + * thermoSystem.setTemperature(temperatures[j]); writer.write(ROG[i][j] + ","); } } + * writer.write(")"); } catch (IOException ex) { // report } finally { try { } writer.close(); } + * catch (Exception ex) { } } */ - public void calcRSWTOB() { - thermoSystem.init(0); - thermoSystem.init(1); - if (thermoSystem.getPhase(0).hasComponent("water")) { - RSWTOB = thermoSystem.getPhase(0).getComponent("water").getNumberOfmoles() - * thermoSystem.getPhase(0).getComponent("water").getMolarMass() - / (thermoSystem.getTotalNumberOfMoles() * thermoSystem.getMolarMass()); - } else { - RSWTOB = 0.0; + try (Writer writer = + new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName), "utf-8"))) { + writer.write("'WATER-OPTION ENTROPY NONEQ '" + "\n"); + + writer.write(pressures.length + " " + temperatures.length + " " + RSWTOB + "\n"); + int Pcounter = 0; + for (int i = 0; i < pressures.length; i++) { + if (Pcounter > 4) { + writer.write("\n"); + Pcounter = 0; } - } - - /** {@inheritDoc} */ - @Override - public void run() { - calcRSWTOB(); - logger.info("RSWTOB " + RSWTOB); - nProps = 29; - props = new double[nProps][pressures.length][temperatures.length]; - units = new String[nProps]; - names = new String[nProps]; - - // int startGasTemperatures = 0; - boolean acceptedFlash = true; - for (int j = 0; j < temperatures.length; j++) { - thermoSystem.setTemperature(temperatures[j]); - for (int i = 0; i < pressures.length; i++) { - thermoSystem.setPressure(pressures[i]); - try { - logger.info("TPflash... " + thermoSystem.getTemperature() + " pressure " - + thermoSystem.getPressure()); - if (thermoSystem.getTemperature() > (273.15 + 106.8)) { - logger.info("here I am"); - thermoOps.TPflash(); - } else { - thermoOps.TPflash(); - } - thermoSystem.init(3); - thermoSystem.initPhysicalProperties(); - acceptedFlash = true; - } catch (Exception e) { - acceptedFlash = false; - logger.info("fail temperature " + thermoSystem.getTemperature() - + " fail pressure " + thermoSystem.getPressure()); - - thermoSystem.display(); - logger.error("error", e); - } - - /* - * logger.info("water density " + - * thermoSystem.getPhase(2).getPhysicalProperties().getDensity()); - * logger.info("RSW " + thermoSystem.getPhase(0).getComponent("water").getx() * - * thermoSystem.getPhase(0).getComponent("water").getMolarMass() / - * thermoSystem.getPhase(0).getMolarMass()); logger.info("surf tens oil-water " + - * thermoSystem.getInterphaseProperties().getSurfaceTension(1, 2)); - * logger.info("surf tens gas-water " + - * thermoSystem.getInterphaseProperties().getSurfaceTension(0, 2)); - */ - int k = 0; - if (thermoSystem.hasPhaseType("gas") && acceptedFlash) { - int phaseNumb = thermoSystem.getPhaseNumberOfPhase("gas"); - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); - names[k] = "GAS DENSITY"; - units[k] = "KG/M3"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; - names[k] = "DRHOG/DP"; - units[k] = "S2/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); - names[k] = "DRHOG/DT"; - units[k] = "KG/M3-K"; - k++; - - // double beta = 0.0; - if (thermoSystem.hasPhaseType("oil")) { - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getBeta() - * thermoSystem.getPhase(phaseNumb).getMolarMass() - / (thermoSystem.getPhase(phaseNumb).getBeta() - * thermoSystem.getPhase(phaseNumb).getMolarMass() - + thermoSystem.getPhase("oil").getBeta() - * thermoSystem.getPhase("oil").getMolarMass()); - } else { - props[k][i][j] = 1.0;// thermoSystem.getPhase(phaseNumb).getBeta() * - // thermoSystem.getPhase(phaseNumb).getMolarMass() / - // thermoSystem.getMolarMass(); - } - names[k] = "GAS MASS FRACTION"; - units[k] = "-"; - k++; - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); - names[k] = "GAS VISCOSITY"; - units[k] = "NS/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "GAS HEAT CAPACITY"; - units[k] = "J/KG-K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEnthalpy() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "GAS ENTHALPY"; - units[k] = "J/KG"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties() - .getConductivity(); - names[k] = "GAS THERMAL CONDUCTIVITY"; - units[k] = "W/M-K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "GAS ENTROPY"; - units[k] = "J/KG/K"; - k++; - hasGasValues = true; - // set gas properties - } else { - if (continuousDerivativesExtrapolation && hasGasValues) { - do { - if (i > 1) { - props[k][i][j] = props[k][i - 1][j] - + (props[k][i - 1][j] - props[k][i - 2][j]) - / (pressures[i - 1] - pressures[i - 2]) - * (pressures[i] - pressures[i - 1]); - // } //else if (j < 2) { - // props[k][i][j] = 0;//props[k][i - 1][j] + (props[k][i - 1][j] - - // props[k][i - - // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - - // pressures[i - // - 1]); - // } else { - // props[k][i][j] = 0;//props[k][i - 1][j - 1] + (props[k][i][j - 1] - // - - // props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - 2]) - // * - // (temperatures[j] - temperatures[j - 1]) + (props[k][i - 1][j] - - // props[k][i - - // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - - // pressures[i - // - 1]); - // double newTemp = pressures[i]; - // double vall = xcoef[k].get(0, 0) + newTemp * (xcoef[k].get(1, 0) - // + newTemp * - // (xcoef[k].get(2, 0) + newTemp * xcoef[k].get(3, 0))); - // props[k][i][j] = vall; - // if(i>0 && props[k][i-1][j]>1e-10) props[k][i][j] = - // props[k][i-1][j]*pressures[i]/pressures[i-1]; - } - if (names[k].equals("GAS MASS FRACTION") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - k++; - } while (k < 9);// names[k] = "GAS DENSITY"; - // units[k] = "KG/M3"; - /* - * } else if (false && !hasGasValues) { startGasTemperatures = j; - */ - } else { - gasSystem.setTemperature(temperatures[j]); - gasSystem.setPressure(pressures[i]); - gasSystem.init(3); - gasSystem.initPhysicalProperties(); - // gasSystem.display(); - props[k][i][j] = gasSystem.getPhase(0).getPhysicalProperties().getDensity(); - names[k] = "GAS DENSITY"; - units[k] = "KG/M3"; - k++; - props[k][i][j] = gasSystem.getPhase(0).getdrhodP() / 1.0e5; - names[k] = "DRHOG/DP"; - units[k] = "S2/M2"; - k++; - props[k][i][j] = gasSystem.getPhase(0).getdrhodT(); - names[k] = "DRHOG/DT"; - units[k] = "KG/M3-K"; - k++; - - props[k][i][j] = 0.0;// thermoSystem.getPhase(phaseNumb).getBeta() * - // thermoSystem.getPhase(phaseNumb).getMolarMass() / - // thermoSystem.getMolarMass(); - names[k] = "GAS MASS FRACTION"; - units[k] = "-"; - k++; - - props[k][i][j] = - gasSystem.getPhase(0).getPhysicalProperties().getViscosity(); - names[k] = "GAS VISCOSITY"; - units[k] = "NS/M2"; - k++; - - props[k][i][j] = gasSystem.getPhase(0).getCp() - / gasSystem.getPhase(0).getNumberOfMolesInPhase() - / gasSystem.getPhase(0).getMolarMass(); - names[k] = "GAS HEAT CAPACITY"; - units[k] = "J/KG-K"; - k++; - - props[k][i][j] = gasSystem.getPhase(0).getEnthalpy() - / gasSystem.getPhase(0).getNumberOfMolesInPhase() - / gasSystem.getPhase(0).getMolarMass(); - names[k] = "GAS ENTHALPY"; - units[k] = "J/KG"; - k++; - - props[k][i][j] = - gasSystem.getPhase(0).getPhysicalProperties().getConductivity(); - names[k] = "GAS THERMAL CONDUCTIVITY"; - units[k] = "W/M-K"; - k++; - - props[k][i][j] = gasSystem.getPhase(0).getEntropy() - / gasSystem.getPhase(0).getNumberOfMolesInPhase() - / gasSystem.getPhase(0).getMolarMass(); - names[k] = "GAS ENTROPY"; - units[k] = "J/KG/K"; - k++; - } - } - - if (thermoSystem.hasPhaseType("oil") && acceptedFlash) { - int phaseNumb = thermoSystem.getPhaseNumberOfPhase("oil"); - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); - names[k] = "LIQUID DENSITY"; - units[k] = "KG/M3"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; - names[k] = "DRHOL/DP"; - units[k] = "S2/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); - names[k] = "DRHOL/DT"; - units[k] = "KG/M3-K"; - k++; - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); - names[k] = "LIQUID VISCOSITY"; - units[k] = "NS/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "LIQUID HEAT CAPACITY"; - units[k] = "J/KG-K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEnthalpy() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "LIQUID ENTHALPY"; - units[k] = "J/KG"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "LIQUID ENTROPY"; - units[k] = "J/KG/K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties() - .getConductivity(); - names[k] = "LIQUID THERMAL CONDUCTIVITY"; - units[k] = "W/M-K"; - k++; - hasOilValues = true; - } else { - if (continuousDerivativesExtrapolation && hasOilValues) { - do { - if (i > 1) { - props[k][i][j] = props[k][i - 1][j] - + (props[k][i - 1][j] - props[k][i - 2][j]) - / (pressures[i - 1] - pressures[i - 2]) - * (pressures[i] - pressures[i - 1]); - } - /* - * if (i < 2) { props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - - * 1] - props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - - * 2]) * (temperatures[j] - temperatures[j - 1]); } else if (j < 2) { - * props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - - * props[k][i - 2][j]) / (pressures[i - 1] - pressures[i - 2]) * - * (pressures[i] - pressures[i - 1]); } else { props[k][i][j] = - * props[k][i - 1][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) / - * (temperatures[j - 1] - temperatures[j - 2]) * (temperatures[j] - - * temperatures[j - 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / - * (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - - * 1]); } props[k][i][j] = 0.0; - */ - k++; - } while (k < 17);// names[k] = "GAS DENSITY"; - // units[k] = "KG/M3"; - } else { - oilSystem.setPhaseType(0, 0); - oilSystem.setTemperature(temperatures[j]); - oilSystem.setPressure(pressures[i]); - oilSystem.init(3); - oilSystem.initPhysicalProperties(); - - props[k][i][j] = oilSystem.getPhase(0).getPhysicalProperties().getDensity(); - names[k] = "LIQUID DENSITY"; - units[k] = "KG/M3"; - k++; - - props[k][i][j] = oilSystem.getPhase(0).getdrhodP() / 1.0e5; - names[k] = "DRHOL/DP"; - units[k] = "S2/M2"; - k++; - - props[k][i][j] = oilSystem.getPhase(0).getdrhodT(); - names[k] = "DRHOL/DT"; - units[k] = "KG/M3-K"; - k++; - - props[k][i][j] = - oilSystem.getPhase(0).getPhysicalProperties().getViscosity(); - names[k] = "LIQUID VISCOSITY"; - units[k] = "NS/M2"; - k++; - - props[k][i][j] = oilSystem.getPhase(0).getCp() - / oilSystem.getPhase(0).getNumberOfMolesInPhase() - / oilSystem.getPhase(0).getMolarMass(); - names[k] = "LIQUID HEAT CAPACITY"; - units[k] = "J/KG-K"; - k++; - - props[k][i][j] = oilSystem.getPhase(0).getEnthalpy() - / oilSystem.getPhase(0).getNumberOfMolesInPhase() - / oilSystem.getPhase(0).getMolarMass(); - names[k] = "LIQUID ENTHALPY"; - units[k] = "J/KG"; - k++; - - props[k][i][j] = oilSystem.getPhase(0).getEntropy() - / oilSystem.getPhase(0).getNumberOfMolesInPhase() - / oilSystem.getPhase(0).getMolarMass(); - names[k] = "LIQUID ENTROPY"; - units[k] = "J/KG/K"; - k++; - - props[k][i][j] = - oilSystem.getPhase(0).getPhysicalProperties().getConductivity(); - names[k] = "LIQUID THERMAL CONDUCTIVITY"; - units[k] = "W/M-K"; - k++; - } - // setOilProperties(); - // set gas properties - } - - if (thermoSystem.hasPhaseType("aqueous") && acceptedFlash) { - int phaseNumb = thermoSystem.getPhaseNumberOfPhase("aqueous"); - - props[k][i][j] = thermoSystem.getPhase(0).getComponent("water").getx() - * thermoSystem.getPhase(0).getComponent("water").getMolarMass() - / thermoSystem.getPhase(0).getMolarMass(); - names[k] = "WATER VAPOR MASS FRACTION"; - units[k] = "-"; - k++; - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); - names[k] = "WATER DENSITY"; - units[k] = "KG/M3"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; - names[k] = "DRHOWAT/DP"; - units[k] = "S2/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); - names[k] = "DRHOWAT/DT"; - units[k] = "KG/M3-K"; - k++; - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); - names[k] = "WATER VISCOSITY"; - units[k] = "NS/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "WATER HEAT CAPACITY"; - units[k] = "J/KG-K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEnthalpy() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "WATER ENTHALPY"; - units[k] = "J/KG"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "WATER ENTROPY"; - units[k] = "J/KG/K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties() - .getConductivity(); - names[k] = "WATER THERMAL CONDUCTIVITY"; - units[k] = "W/M-K"; - k++; - hasWaterValues = true; - } else { - if (continuousDerivativesExtrapolation && hasWaterValues) { - do { - if (j > 1) { - props[k][i][j] = props[k][i][j - 1] - + (props[k][i][j - 1] - props[k][i][j - 2]) - / (temperatures[j - 1] - temperatures[j - 2]) - * (temperatures[j] - temperatures[j - 1]); - } - /* - * if (i < 2) { props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - - * 1] - props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - - * 2]) * (temperatures[j] - temperatures[j - 1]); } else if (j < 2) { - * props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - - * props[k][i - 2][j]) / (pressures[i - 1] - pressures[i - 2]) * - * (pressures[i] - pressures[i - 1]); } else { props[k][i][j] = - * props[k][i - 1][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) / - * (temperatures[j - 1] - temperatures[j - 2]) * (temperatures[j] - - * temperatures[j - 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / - * (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - - * 1]); } props[k][i][j] = 0.0; - */ - k++; - } while (k < 26);// names[k] = "GAS DENSITY"; - // units[k] = "KG/M3"; - } else { - waterSystem.setTemperature(temperatures[j]); - waterSystem.setPressure(pressures[i]); - waterSystem.setPhaseType(0, 0); - waterSystem.init(3); - waterSystem.initPhysicalProperties(); - - if (thermoSystem.getPhase(0).hasComponent("water")) { - props[k][i][j] = thermoSystem.getPhase(0).getComponent("water").getz() - * thermoSystem.getPhase(0).getComponent("water").getMolarMass() - / thermoSystem.getPhase(0).getMolarMass(); - } else { - props[k][i][j] = 0.0; - } - names[k] = "WATER VAPOR MASS FRACTION"; - units[k] = "-"; - k++; - - props[k][i][j] = - waterSystem.getPhase(0).getPhysicalProperties().getDensity(); - names[k] = "WATER DENSITY"; - units[k] = "KG/M3"; - k++; - - props[k][i][j] = waterSystem.getPhase(0).getdrhodP() / 1.0e5; - names[k] = "DRHOWAT/DP"; - units[k] = "S2/M2"; - k++; - - props[k][i][j] = waterSystem.getPhase(0).getdrhodT(); - names[k] = "DRHOWAT/DT"; - units[k] = "KG/M3-K"; - k++; - - props[k][i][j] = - waterSystem.getPhase(0).getPhysicalProperties().getViscosity(); - names[k] = "WATER VISCOSITY"; - units[k] = "NS/M2"; - k++; - - props[k][i][j] = waterSystem.getPhase(0).getCp() - / waterSystem.getPhase(0).getNumberOfMolesInPhase() - / waterSystem.getPhase(0).getMolarMass(); - names[k] = "WATER HEAT CAPACITY"; - units[k] = "J/KG-K"; - k++; - - props[k][i][j] = waterSystem.getPhase(0).getEnthalpy() - / waterSystem.getPhase(0).getNumberOfMolesInPhase() - / waterSystem.getPhase(0).getMolarMass(); - names[k] = "WATER ENTHALPY"; - units[k] = "J/KG"; - k++; - - props[k][i][j] = waterSystem.getPhase(0).getEntropy() - / waterSystem.getPhase(0).getNumberOfMolesInPhase() - / waterSystem.getPhase(0).getMolarMass(); - names[k] = "WATER ENTROPY"; - units[k] = "J/KG/K"; - k++; - - props[k][i][j] = - waterSystem.getPhase(0).getPhysicalProperties().getConductivity(); - names[k] = "WATER THERMAL CONDUCTIVITY"; - units[k] = "W/M-K"; - k++; - } - } - - if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("oil") - && acceptedFlash) { - props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( - thermoSystem.getPhaseNumberOfPhase("gas"), - thermoSystem.getPhaseNumberOfPhase("oil")); - names[k] = "VAPOR-LIQUID SURFACE TENSION"; - units[k] = "N/M"; - k++; - } else { - if (continuousDerivativesExtrapolation && (i >= 2 || j >= 2)) { - if (i < 2) { - props[k][i][j] = - props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) - / (temperatures[j - 1] - temperatures[j - 2]) - * (temperatures[j] - temperatures[j - 1]); - } else if (j < 2) { - props[k][i][j] = - props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) - / (pressures[i - 1] - pressures[i - 2]) - * (pressures[i] - pressures[i - 1]); - } else { - props[k][i][j] = props[k][i - 1][j - 1] - + (props[k][i][j - 1] - props[k][i][j - 2]) - / (temperatures[j - 1] - temperatures[j - 2]) - * (temperatures[j] - temperatures[j - 1]) - + (props[k][i - 1][j] - props[k][i - 2][j]) - / (pressures[i - 1] - pressures[i - 2]) - * (pressures[i] - pressures[i - 1]); - } - props[k][i][j] = 10.0e-3; - k++; - } else { - props[k][i][j] = 10.0e-3; - names[k] = "VAPOR-LIQUID SURFACE TENSION"; - units[k] = "N/M"; - k++; - } - } - - if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("aqueous") - && acceptedFlash) { - props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( - thermoSystem.getPhaseNumberOfPhase("gas"), - thermoSystem.getPhaseNumberOfPhase("aqueous")); - names[k] = "VAPOR-WATER SURFACE TENSION"; - units[k] = "N/M"; - k++; - } else { - if (continuousDerivativesExtrapolation && (i >= 2 || j >= 2)) { - if (i < 2) { - props[k][i][j] = - props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) - / (temperatures[j - 1] - temperatures[j - 2]) - * (temperatures[j] - temperatures[j - 1]); - } else if (j < 2) { - props[k][i][j] = - props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) - / (pressures[i - 1] - pressures[i - 2]) - * (pressures[i] - pressures[i - 1]); - } else { - props[k][i][j] = props[k][i - 1][j - 1] - + (props[k][i][j - 1] - props[k][i][j - 2]) - / (temperatures[j - 1] - temperatures[j - 2]) - * (temperatures[j] - temperatures[j - 1]) - + (props[k][i - 1][j] - props[k][i - 2][j]) - / (pressures[i - 1] - pressures[i - 2]) - * (pressures[i] - pressures[i - 1]); - } - props[k][i][j] = 60.0e-3; - k++; - } else { - props[k][i][j] = 60.0e-3; - names[k] = "VAPOR-WATER SURFACE TENSION"; - units[k] = "N/M"; - k++; - } - } - - if (thermoSystem.hasPhaseType("oil") && thermoSystem.hasPhaseType("aqueous") - && acceptedFlash) { - props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( - thermoSystem.getPhaseNumberOfPhase("oil"), - thermoSystem.getPhaseNumberOfPhase("aqueous")); - names[k] = "LIQUID-WATER SURFACE TENSION"; - units[k] = "N/M"; - k++; - } else { - if (continuousDerivativesExtrapolation && (i >= 2 || j >= 2)) { - if (i < 2) { - props[k][i][j] = - props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) - / (temperatures[j - 1] - temperatures[j - 2]) - * (temperatures[j] - temperatures[j - 1]); - } else if (j < 2) { - props[k][i][j] = - props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) - / (pressures[i - 1] - pressures[i - 2]) - * (pressures[i] - pressures[i - 1]); - } else { - props[k][i][j] = props[k][i - 1][j - 1] - + (props[k][i][j - 1] - props[k][i][j - 2]) - / (temperatures[j - 1] - temperatures[j - 2]) - * (temperatures[j] - temperatures[j - 1]) - + (props[k][i - 1][j] - props[k][i - 2][j]) - / (pressures[i - 1] - pressures[i - 2]) - * (pressures[i] - pressures[i - 1]); - } - props[k][i][j] = 20.0e-3; - k++; - } else { - props[k][i][j] = 20.0e-3; - names[k] = "LIQUID-WATER SURFACE TENSION"; - units[k] = "N/M"; - k++; - } - } - } + writer.write(pressureLOG[i] + " "); + Pcounter++; + } + writer.write("\n"); + + int Tcounter = 0; + for (int i = 0; i < temperatures.length; i++) { + if (Tcounter > 4) { + writer.write("\n"); + Tcounter = 0; } - logger.info("Finished TPflash..."); - if (thermoSystem.getPhase(0).hasComponent("water")) { - thermoSystem.removeComponent("water"); + writer.write(temperatureLOG[i] + " "); + Tcounter++; + } + writer.write("\n"); + + int bubPcounter = 0; + for (int i = 0; i < temperatures.length; i++) { + if (bubPcounter > 4) { + writer.write("\n"); + bubPcounter = 0; } - bubP = calcBubP(temperatures); - dewP = calcDewP(temperatures); - // bubT = calcBubT(temperatures); - logger.info("Finished creating arrays"); - BicubicInterpolatingFunction funcGasDens = - interpolationFunc.interpolate(pressures, temperatures, props[0]); - logger.info("interpolated value " + funcGasDens.value(40, 298.0)); - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - logger.info("TC " + TC + " PC " + PC); + writer.write(bubPLOG[i] + " "); + bubPcounter++; + } + writer.write("\n"); + + int dewPcounter = 0; + for (int i = 0; i < temperatures.length; i++) { + if (dewPcounter > 4) { + writer.write("\n"); + dewPcounter = 0; + } + writer.write(dewPLOG[i] + " "); + dewPcounter++; + } + writer.write("\n"); + + for (int k = 0; k < nProps; k++) { + if (names[k] == null) { + continue; + } + logger.info("Writing variable: " + names[k]); + writer.write(names[k] + " (" + units[k] + ")\n"); for (int i = 0; i < pressures.length; i++) { - thermoSystem.setPressure(pressures[i]); - for (int j = 0; j < temperatures.length; j++) { - logger.info("pressure " + pressureLOG[i] + " temperature " + temperatureLOG[j]);// + - // " - // ROG - // " - // + - // ROG[i][j] - // + - // " - // ROL - // " - // + - // ROL[i][j]); + // thermoSystem.setPressure(pressures[i]); + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + // thermoSystem.setTemperature(temperatures[j]); + if (counter > 4) { + writer.write("\n"); + counter = 0; } + writer.write(props[k][i][j] + " "); + counter++; + } + writer.write("\n"); } - writeOLGAinpFile(fileName); + } + } catch (IOException ex) { + // report } - - /** - *

- * writeOLGAinpFile2. - *

- * - * @param filename a {@link java.lang.String} object + } + + /** + *

+ * writeOLGAinpFile. + *

+ * + * @param filename a {@link java.lang.String} object + */ + public void writeOLGAinpFile(String filename) { + /* + * try { writer = new BufferedWriter(new OutputStreamWriter( new + * FileOutputStream("C:/Users/Kjetil Raul/Documents/Master KRB/javacode_ROG55.txt" ), "utf-8")); + * writer.write("GAS DENSITY (KG/M3) = ("); for (int i = 0; i < pressures.length; i++) { + * thermoSystem.setPressure(pressures[i]); for (int j = 0; j < temperatures.length; j++) { + * thermoSystem.setTemperature(temperatures[j]); writer.write(ROG[i][j] + ","); } } + * writer.write(")"); } catch (IOException ex) { // report } finally { try { } writer.close(); } + * catch (Exception ex) { } } */ - public void writeOLGAinpFile2(String filename) { - /* - * try { writer = new BufferedWriter(new OutputStreamWriter( new - * FileOutputStream("C:/Users/Kjetil Raul/Documents/Master KRB/javacode_ROG55.txt" ), - * "utf-8")); writer.write("GAS DENSITY (KG/M3) = ("); for (int i = 0; i < pressures.length; - * i++) { thermoSystem.setPressure(pressures[i]); for (int j = 0; j < temperatures.length; - * j++) { thermoSystem.setTemperature(temperatures[j]); writer.write(ROG[i][j] + ","); } } - * writer.write(")"); } catch (IOException ex) { // report } finally { try { } - * writer.close(); } catch (Exception ex) { } } - */ - try (Writer writer = new BufferedWriter( - new OutputStreamWriter(new FileOutputStream(fileName), "utf-8"))) { - writer.write("'WATER-OPTION ENTROPY NONEQ '" + "\n"); - - writer.write(pressures.length + " " + temperatures.length + " " + RSWTOB + "\n"); - int Pcounter = 0; - for (int i = 0; i < pressures.length; i++) { - if (Pcounter > 4) { - writer.write("\n"); - Pcounter = 0; - } - writer.write(pressureLOG[i] + " "); - Pcounter++; - } + try (Writer writer = + new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename), "utf-8"))) { + writer.write("'WATER-OPTION ENTROPY NONEQ '" + "\n"); + + writer.write(pressures.length + " " + temperatures.length + " " + RSWTOB + "\n"); + int Pcounter = 0; + for (int i = 0; i < pressures.length; i++) { + if (Pcounter > 4) { + writer.write("\n"); + Pcounter = 0; + } + writer.write(pressureLOG[i] + " "); + Pcounter++; + } + writer.write("\n"); + + int Tcounter = 0; + for (int i = 0; i < temperatures.length; i++) { + if (Tcounter > 4) { + writer.write("\n"); + Tcounter = 0; + } + writer.write(temperatureLOG[i] + " "); + Tcounter++; + } + writer.write("\n"); + + int bubPcounter = 0; + for (int i = 0; i < temperatures.length; i++) { + if (bubPcounter > 4) { + writer.write("\n"); + bubPcounter = 0; + } + writer.write(bubPLOG[i] + " "); + bubPcounter++; + } + writer.write("\n"); + + int dewPcounter = 0; + for (int i = 0; i < temperatures.length; i++) { + if (dewPcounter > 4) { + writer.write("\n"); + dewPcounter = 0; + } + writer.write(dewPLOG[i] + " "); + dewPcounter++; + } + writer.write("\n"); + + writer.write("GAS DENSITY (KG/M3)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[0][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int Tcounter = 0; - for (int i = 0; i < temperatures.length; i++) { - if (Tcounter > 4) { - writer.write("\n"); - Tcounter = 0; - } - writer.write(temperatureLOG[i] + " "); - Tcounter++; - } + writer.write("LIQUID DENSITY (KG/M3)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[9][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int bubPcounter = 0; - for (int i = 0; i < temperatures.length; i++) { - if (bubPcounter > 4) { - writer.write("\n"); - bubPcounter = 0; - } - writer.write(bubPLOG[i] + " "); - bubPcounter++; - } + writer.write("WATER DENSITY (KG/M3)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[18][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int dewPcounter = 0; - for (int i = 0; i < temperatures.length; i++) { - if (dewPcounter > 4) { - writer.write("\n"); - dewPcounter = 0; - } - writer.write(dewPLOG[i] + " "); - dewPcounter++; - } + writer.write("DRHOG/DP (S2/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); - - for (int k = 0; k < nProps; k++) { - if (names[k] == null) { - continue; - } - logger.info("Writing variable: " + names[k]); - writer.write(names[k] + " (" + units[k] + ")\n"); - for (int i = 0; i < pressures.length; i++) { - // thermoSystem.setPressure(pressures[i]); - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - // thermoSystem.setTemperature(temperatures[j]); - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[k][i][j] + " "); - counter++; - } - writer.write("\n"); - } - } - } catch (IOException ex) { - // report + counter = 0; + } + writer.write(props[1][i][j] + " "); + counter++; } - } + writer.write("\n"); + } - /** - *

- * writeOLGAinpFile. - *

- * - * @param filename a {@link java.lang.String} object - */ - public void writeOLGAinpFile(String filename) { - /* - * try { writer = new BufferedWriter(new OutputStreamWriter( new - * FileOutputStream("C:/Users/Kjetil Raul/Documents/Master KRB/javacode_ROG55.txt" ), - * "utf-8")); writer.write("GAS DENSITY (KG/M3) = ("); for (int i = 0; i < pressures.length; - * i++) { thermoSystem.setPressure(pressures[i]); for (int j = 0; j < temperatures.length; - * j++) { thermoSystem.setTemperature(temperatures[j]); writer.write(ROG[i][j] + ","); } } - * writer.write(")"); } catch (IOException ex) { // report } finally { try { } - * writer.close(); } catch (Exception ex) { } } - */ - try (Writer writer = new BufferedWriter( - new OutputStreamWriter(new FileOutputStream(filename), "utf-8"))) { - writer.write("'WATER-OPTION ENTROPY NONEQ '" + "\n"); - - writer.write(pressures.length + " " + temperatures.length + " " + RSWTOB + "\n"); - int Pcounter = 0; - for (int i = 0; i < pressures.length; i++) { - if (Pcounter > 4) { - writer.write("\n"); - Pcounter = 0; - } - writer.write(pressureLOG[i] + " "); - Pcounter++; - } + writer.write("DRHOL/DP (S2/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[10][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int Tcounter = 0; - for (int i = 0; i < temperatures.length; i++) { - if (Tcounter > 4) { - writer.write("\n"); - Tcounter = 0; - } - writer.write(temperatureLOG[i] + " "); - Tcounter++; - } + writer.write("DRHOWAT/DP (S2/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[19][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int bubPcounter = 0; - for (int i = 0; i < temperatures.length; i++) { - if (bubPcounter > 4) { - writer.write("\n"); - bubPcounter = 0; - } - writer.write(bubPLOG[i] + " "); - bubPcounter++; - } + writer.write("DRHOG/DT (KG/M3-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[2][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int dewPcounter = 0; - for (int i = 0; i < temperatures.length; i++) { - if (dewPcounter > 4) { - writer.write("\n"); - dewPcounter = 0; - } - writer.write(dewPLOG[i] + " "); - dewPcounter++; - } + writer.write("DRHOL/DT (KG/M3-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[11][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS DENSITY (KG/M3)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[0][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("LIQUID DENSITY (KG/M3)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[9][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("WATER DENSITY (KG/M3)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[18][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOG/DP (S2/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[1][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOL/DP (S2/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[10][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOWAT/DP (S2/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[19][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOG/DT (KG/M3-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[2][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOL/DT (KG/M3-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[11][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOWAT/DT (KG/M3-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[20][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("GAS MASS FRACTION (-)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[3][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("DRHOWAT/DT (KG/M3-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[20][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("WATER VAPOR MASS FRACTION (-)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[17][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS MASS FRACTION (-)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[3][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS VISCOSITY (NS/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[4][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("WATER VAPOR MASS FRACTION (-)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[17][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID VISCOSITY (NS/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[12][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS VISCOSITY (NS/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[4][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("WATER VISCOSITY (NS/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[21][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("LIQUID VISCOSITY (NS/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[12][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS HEAT CAPACITY (J/KG-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[5][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("WATER VISCOSITY (NS/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[21][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID HEAT CAPACITY (J/KG-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[13][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS HEAT CAPACITY (J/KG-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[5][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("WATER HEAT CAPACITY (J/KG-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[22][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("LIQUID HEAT CAPACITY (J/KG-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[13][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS ENTHALPY (J/KG)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[6][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("WATER HEAT CAPACITY (J/KG-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[22][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID ENTHALPY (J/KG)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[14][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS ENTHALPY (J/KG)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[6][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("WATER ENTHALPY (J/KG)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[23][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("LIQUID ENTHALPY (J/KG)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[14][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS THERMAL CONDUCTIVITY (W/M-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[7][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("WATER ENTHALPY (J/KG)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[23][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID THERMAL CONDUCTIVITY (W/M-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[16][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS THERMAL CONDUCTIVITY (W/M-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[7][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("WATER THERMAL CONDUCTIVITY (W/M-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[25][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("LIQUID THERMAL CONDUCTIVITY (W/M-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[16][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("VAPOR-LIQUID SURFACE TENSION (N/M)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[26][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("WATER THERMAL CONDUCTIVITY (W/M-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[25][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("VAPOR-WATER SURFACE TENSION (N/M)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[27][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("VAPOR-LIQUID SURFACE TENSION (N/M)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[26][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID-WATER SURFACE TENSION (N/M)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[28][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("VAPOR-WATER SURFACE TENSION (N/M)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[27][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS ENTROPY (J/KG/K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[8][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("LIQUID-WATER SURFACE TENSION (N/M)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[28][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID ENTROPY (J/KG/K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[15][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS ENTROPY (J/KG/K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[8][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("WATER ENTROPY (J/KG/K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[24][i][j] + " "); - counter++; - } - writer.write("\n"); - } - /* - * for (int k = 0; k < nProps; k++) { if (names[k] == null) { continue; } - * logger.info("Writing variable: " + names[k]); writer.write(names[k] + " (" + units[k] - * + ")\n"); for (int i = 0; i < pressures.length; i++) { - * //thermoSystem.setPressure(pressures[i]); int counter = 0; for (int j = 0; j < - * temperatures.length; j++) { // thermoSystem.setTemperature(temperatures[j]); if - * (counter > 4) { writer.write("\n"); counter = 0; } writer.write(props[k][i][j] + - * " "); counter++; } writer.write("\n"); } } - */ - } catch (IOException ex) { - // report + writer.write("LIQUID ENTROPY (J/KG/K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[15][i][j] + " "); + counter++; } - } + writer.write("\n"); + } - /** - *

- * extrapolateTable. - *

- */ - public void extrapolateTable() { + writer.write("WATER ENTROPY (J/KG/K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; for (int j = 0; j < temperatures.length; j++) { - for (int i = 0; i < pressures.length; i++) { - if (!hasValue[26][i][j]) { - } - } + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[24][i][j] + " "); + counter++; + } + writer.write("\n"); + } + /* + * for (int k = 0; k < nProps; k++) { if (names[k] == null) { continue; } + * logger.info("Writing variable: " + names[k]); writer.write(names[k] + " (" + units[k] + + * ")\n"); for (int i = 0; i < pressures.length; i++) { + * //thermoSystem.setPressure(pressures[i]); int counter = 0; for (int j = 0; j < + * temperatures.length; j++) { // thermoSystem.setTemperature(temperatures[j]); if (counter > + * 4) { writer.write("\n"); counter = 0; } writer.write(props[k][i][j] + " "); counter++; } + * writer.write("\n"); } } + */ + } catch (IOException ex) { + // report + } + } + + /** + *

+ * extrapolateTable. + *

+ */ + public void extrapolateTable() { + for (int j = 0; j < temperatures.length; j++) { + for (int i = 0; i < pressures.length; i++) { + if (!hasValue[26][i][j]) { } + } } + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterEven.java b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterEven.java index b02fc08bb7..64083383b0 100644 --- a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterEven.java +++ b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterEven.java @@ -19,1339 +19,1322 @@ * @version $Id: $Id */ public class OLGApropertyTableGeneratorWaterEven - extends neqsim.thermodynamicOperations.BaseOperation { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(OLGApropertyTableGeneratorWaterEven.class); - - SystemInterface thermoSystem = null; - ThermodynamicOperations thermoOps = null; - double[] pressures, temperatureLOG, temperatures, pressureLOG = null; - double[] bubP, bubT, dewP, bubPLOG, dewPLOG; - double[][] ROG = null; - // double[][] ROL, CPG, CPHL, HG, HHL, TCG, TCHL, VISG, VISHL, SIGGHL, SEG, - // SEHL, RS; - double TC, PC; - double RSWTOB; - double[][][] props; - int nProps; - String[] names; - String[] units; - int temperatureSteps, pressureSteps; - boolean continuousDerivativesExtrapolation = true; - boolean hasGasValues = false; - boolean hasOilValues = false; - boolean hasWaterValues = false; - boolean[][][] hasValue; - String fileName = "c:/temp/OLGAneqsim.tab"; - - /** - *

- * Constructor for OLGApropertyTableGeneratorWaterEven. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public OLGApropertyTableGeneratorWaterEven(SystemInterface system) { - this.thermoSystem = system; - thermoOps = new ThermodynamicOperations(thermoSystem); + extends neqsim.thermodynamicOperations.BaseOperation { + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(OLGApropertyTableGeneratorWaterEven.class); + + SystemInterface thermoSystem = null; + ThermodynamicOperations thermoOps = null; + double[] pressures; + double[] temperatureLOG; + double[] temperatures; + double[] pressureLOG = null; + double[] bubP; + double[] bubT; + double[] dewP; + double[] bubPLOG; + double[] dewPLOG; + double[][] ROG = null; + double TC; + double PC; + double RSWTOB; + double[][][] props; + int nProps; + String[] names; + String[] units; + int temperatureSteps; + int pressureSteps; + boolean continuousDerivativesExtrapolation = true; + boolean hasGasValues = false; + boolean hasOilValues = false; + boolean hasWaterValues = false; + boolean[][][] hasValue; + String fileName = "c:/temp/OLGAneqsim.tab"; + + /** + *

+ * Constructor for OLGApropertyTableGeneratorWaterEven. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public OLGApropertyTableGeneratorWaterEven(SystemInterface system) { + this.thermoSystem = system; + thermoOps = new ThermodynamicOperations(thermoSystem); + } + + /** + *

+ * Setter for the field fileName. + *

+ * + * @param name a {@link java.lang.String} object + */ + public void setFileName(String name) { + fileName = name; + } + + /** + *

+ * setPressureRange. + *

+ * + * @param minPressure a double + * @param maxPressure a double + * @param numberOfSteps a int + */ + public void setPressureRange(double minPressure, double maxPressure, int numberOfSteps) { + pressures = new double[numberOfSteps]; + pressureLOG = new double[numberOfSteps]; + double step = (maxPressure - minPressure) / (numberOfSteps * 1.0 - 1.0); + for (int i = 0; i < numberOfSteps; i++) { + pressures[i] = minPressure + i * step; + pressureLOG[i] = pressures[i] * 1e5; } - - /** - *

- * Setter for the field fileName. - *

- * - * @param name a {@link java.lang.String} object - */ - public void setFileName(String name) { - fileName = name; + } + + /** + *

+ * setTemperatureRange. + *

+ * + * @param minTemperature a double + * @param maxTemperature a double + * @param numberOfSteps a int + */ + public void setTemperatureRange(double minTemperature, double maxTemperature, int numberOfSteps) { + temperatures = new double[numberOfSteps]; + temperatureLOG = new double[numberOfSteps]; + double step = (maxTemperature - minTemperature) / (numberOfSteps * 1.0 - 1.0); + for (int i = 0; i < numberOfSteps; i++) { + temperatures[i] = minTemperature + i * step; + temperatureLOG[i] = temperatures[i] - 273.15; } - - /** - *

- * setPressureRange. - *

- * - * @param minPressure a double - * @param maxPressure a double - * @param numberOfSteps a int - */ - public void setPressureRange(double minPressure, double maxPressure, int numberOfSteps) { - pressures = new double[numberOfSteps]; - pressureLOG = new double[numberOfSteps]; - double step = (maxPressure - minPressure) / (numberOfSteps * 1.0 - 1.0); - for (int i = 0; i < numberOfSteps; i++) { - pressures[i] = minPressure + i * step; - pressureLOG[i] = pressures[i] * 1e5; - } + } + + /** + *

+ * calcPhaseEnvelope. + *

+ */ + public void calcPhaseEnvelope() { + try { + thermoOps.calcPTphaseEnvelope(); + TC = thermoSystem.getTC() - 273.15; + PC = thermoSystem.getPC() * 1e5; + } catch (Exception e) { + logger.error("error", e); } - - /** - *

- * setTemperatureRange. - *

- * - * @param minTemperature a double - * @param maxTemperature a double - * @param numberOfSteps a int - */ - public void setTemperatureRange(double minTemperature, double maxTemperature, - int numberOfSteps) { - temperatures = new double[numberOfSteps]; - temperatureLOG = new double[numberOfSteps]; - double step = (maxTemperature - minTemperature) / (numberOfSteps * 1.0 - 1.0); - for (int i = 0; i < numberOfSteps; i++) { - temperatures[i] = minTemperature + i * step; - temperatureLOG[i] = temperatures[i] - 273.15; - } + } + + /** + *

+ * calcBubP. + *

+ * + * @param temperatures an array of {@link double} objects + * @return an array of {@link double} objects + */ + public double[] calcBubP(double[] temperatures) { + double[] bubP = new double[temperatures.length]; + bubPLOG = new double[temperatures.length]; + for (int i = 0; i < temperatures.length; i++) { + thermoSystem.setTemperature(temperatures[i]); + try { + // thermoOps.bubblePointPressureFlash(false); + bubP[i] = thermoSystem.getPressure(); + bubPLOG[i] = bubP[i] * 1e5; + } catch (Exception e) { + logger.error("error", e); + bubP[i] = 0; + } + } + return bubP; + } + + /** + *

+ * calcDewP. + *

+ * + * @param temperatures an array of {@link double} objects + * @return an array of {@link double} objects + */ + public double[] calcDewP(double[] temperatures) { + double[] dewP = new double[temperatures.length]; + dewPLOG = new double[temperatures.length]; + for (int i = 0; i < temperatures.length; i++) { + thermoSystem.setTemperature(temperatures[i]); + try { + // thermoOps.dewPointPressureFlashHC(); + dewP[i] = thermoSystem.getPressure(); + dewPLOG[i] = dewP[i] * 1e5; + } catch (Exception e) { + logger.error("error", e); + dewP[i] = 0; + } + } + return dewP; + } + + /** + *

+ * calcBubT. + *

+ * + * @param pressures an array of {@link double} objects + * @return an array of {@link double} objects + */ + public double[] calcBubT(double[] pressures) { + double[] bubTemps = new double[pressures.length]; + for (int i = 0; i < pressures.length; i++) { + thermoSystem.setPressure(pressures[i]); + try { + // thermoOps.bubblePointTemperatureFlash(); + bubT[i] = thermoSystem.getPressure(); + } catch (Exception e) { + logger.error("error", e); + bubT[i] = 0.0; + } + } + return bubTemps; + } + + /** + *

+ * initCalc. + *

+ */ + public void initCalc() { + double stdTemp = 288.15; + double stdPres = 1.01325; + // double GOR, GLR; + double[] molfracs = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; + double[] MW = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; + double[] dens = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; + String[] components = new String[thermoSystem.getPhase(0).getNumberOfComponents()]; + + for (int i = 0; i < molfracs.length; i++) { + molfracs[i] = thermoSystem.getPhase(0).getComponent(i).getz(); + components[i] = thermoSystem.getPhase(0).getComponent(i).getComponentName(); + MW[i] = thermoSystem.getPhase(0).getComponent(i).getMolarMass() * 1000; + dens[i] = thermoSystem.getPhase(0).getComponent(i).getNormalLiquidDensity(); } - /** - *

- * calcPhaseEnvelope. - *

- */ - public void calcPhaseEnvelope() { + thermoSystem.setTemperature(stdTemp); + thermoSystem.setPressure(stdPres); + + thermoOps.TPflash(); + + // GOR = thermoSystem.getPhase(0).getTotalVolume() / + // thermoSystem.getPhase(1).getTotalVolume(); + // GLR = thermoSystem.getPhase(0).getTotalVolume() / + // thermoSystem.getPhase(1).getTotalVolume(); + } + + /** + *

+ * calcRSWTOB. + *

+ */ + public void calcRSWTOB() { + thermoSystem.init(0); + thermoSystem.init(1); + if (thermoSystem.getPhase(0).hasComponent("water")) { + RSWTOB = thermoSystem.getPhase(0).getComponent("water").getNumberOfmoles() + * thermoSystem.getPhase(0).getComponent("water").getMolarMass() + / (thermoSystem.getTotalNumberOfMoles() * thermoSystem.getMolarMass()); + } else { + RSWTOB = 0.0; + } + } + + /** {@inheritDoc} */ + @Override + public void run() { + calcRSWTOB(); + logger.info("RSWTOB " + RSWTOB); + nProps = 29; + props = new double[nProps][pressures.length][temperatures.length]; + units = new String[nProps]; + names = new String[nProps]; + + // int startGasTemperatures = 0; + boolean acceptedFlash = true; + for (int j = 0; j < temperatures.length; j++) { + thermoSystem.setTemperature(temperatures[j]); + for (int i = 0; i < pressures.length; i++) { + thermoSystem.setPressure(pressures[i]); try { - thermoOps.calcPTphaseEnvelope(); - TC = thermoSystem.getTC() - 273.15; - PC = thermoSystem.getPC() * 1e5; + // logger.info("TPflash... " + thermoSystem.getTemperature() + " pressure " + + // thermoSystem.getPressure()); + thermoOps.TPflash(); + // thermoSystem.createTable("test"); + thermoSystem.init(3); + thermoSystem.initPhysicalProperties(); + // if(thermoSystem.getPressure()>120){ + // thermoSystem.display(); + // } + // thermoSystem.display(); + acceptedFlash = true; } catch (Exception e) { - logger.error("error", e); + acceptedFlash = false; + logger.info("fail temperature " + thermoSystem.getTemperature() + " fail pressure " + + thermoSystem.getPressure()); + + thermoSystem.display(); + logger.error("error", e); } - } - /** - *

- * calcBubP. - *

- * - * @param temperatures an array of {@link double} objects - * @return an array of {@link double} objects - */ - public double[] calcBubP(double[] temperatures) { - double[] bubP = new double[temperatures.length]; - bubPLOG = new double[temperatures.length]; - for (int i = 0; i < temperatures.length; i++) { - thermoSystem.setTemperature(temperatures[i]); - try { - // thermoOps.bubblePointPressureFlash(false); - bubP[i] = thermoSystem.getPressure(); - bubPLOG[i] = bubP[i] * 1e5; - } catch (Exception e) { - logger.error("error", e); - bubP[i] = 0; - } + /* + * logger.info("water density " + + * thermoSystem.getPhase(2).getPhysicalProperties().getDensity()); logger.info("RSW " + + * thermoSystem.getPhase(0).getComponent("water").getx() * + * thermoSystem.getPhase(0).getComponent("water").getMolarMass() / + * thermoSystem.getPhase(0).getMolarMass()); logger.info("surf tens oil-water " + + * thermoSystem.getInterphaseProperties().getSurfaceTension(1, 2)); + * logger.info("surf tens gas-water " + + * thermoSystem.getInterphaseProperties().getSurfaceTension(0, 2)); + */ + int k = 0; + if (thermoSystem.hasPhaseType("gas") && acceptedFlash) { + int phaseNumb = thermoSystem.getPhaseNumberOfPhase("gas"); + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); + names[k] = "GAS DENSITY"; + units[k] = "KG/M3"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; + names[k] = "DRHOG/DP"; + units[k] = "S2/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); + names[k] = "DRHOG/DT"; + units[k] = "KG/M3-K"; + k++; + + if (thermoSystem.hasPhaseType("oil")) { + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getBeta() + * thermoSystem.getPhase(phaseNumb).getMolarMass() + / (thermoSystem.getPhase(phaseNumb).getBeta() + * thermoSystem.getPhase(phaseNumb).getMolarMass() + + thermoSystem.getPhase("oil").getBeta() + * thermoSystem.getPhase("oil").getMolarMass()); + } else { + props[k][i][j] = 1.0; // thermoSystem.getPhase(phaseNumb).getBeta() * + // thermoSystem.getPhase(phaseNumb).getMolarMass() / + // thermoSystem.getMolarMass(); + } + names[k] = "GAS MASS FRACTION"; + units[k] = "-"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); + names[k] = "GAS VISCOSITY"; + units[k] = "NS/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "GAS HEAT CAPACITY"; + units[k] = "J/KG-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEnthalpy() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "GAS ENTHALPY"; + units[k] = "J/KG"; + k++; + + props[k][i][j] = + thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getConductivity(); + names[k] = "GAS THERMAL CONDUCTIVITY"; + units[k] = "W/M-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "GAS ENTROPY"; + units[k] = "J/KG/K"; + k++; + hasGasValues = true; + // set gas properties + } else { + if (continuousDerivativesExtrapolation && hasGasValues) { + do { + if (i > 1) { + props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) + / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + // } //else if (j < 2) { + // props[k][i][j] = 0; //props[k][i - 1][j] + (props[k][i - 1][j] - + // props[k][i - + // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - + // pressures[i + // - 1]); + // } else { + // props[k][i][j] = 0; //props[k][i - 1][j - 1] + (props[k][i][j - + // 1] + // - + // props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - 2]) + // * + // (temperatures[j] - temperatures[j - 1]) + (props[k][i - 1][j] - + // props[k][i - + // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - + // pressures[i + // - 1]); + // double newTemp = pressures[i]; + // double vall = xcoef[k].get(0, 0) + newTemp * (xcoef[k].get(1, 0) + // + newTemp * + // (xcoef[k].get(2, 0) + newTemp * xcoef[k].get(3, 0))); + // props[k][i][j] = vall; + // if(i>0 && props[k][i-1][j]>1e-10) props[k][i][j] = + // props[k][i-1][j]*pressures[i]/pressures[i-1]; + } + if (names[k].equals("GAS MASS FRACTION") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + k++; + } while (k < 9); // names[k] = "GAS DENSITY"; + // units[k] = "KG/M3"; + } + /* + * else if (false && !hasGasValues) { startGasTemperatures = j; } + */ + } + /* + * double[] gasVals = new double[9]; for (int kk = 0; kk < 9; kk++) { gasVals[kk] = + * props[kk][i][j]; } Matrix gasVector = new Matrix(gasVals, 1).transpose(); + * XMatrixgas.setMatrix(0, 8, 0, 2, XMatrixgas.getMatrix(0, 8, 1, 3)); + * XMatrixgas.setMatrix(0, 8, 3, 3, gasVector); if (i > 3) { for (int ii = 0; ii < 4; ii++) + * { aMatrix.set(ii, 0, 1.0); aMatrix.set(ii, 1, pressures[i - ii]); aMatrix.set(ii, 2, + * pressures[i - ii] * pressures[i - ii]); aMatrix.set(ii, 3, pressures[i - ii] * + * pressures[i - ii] * pressures[i - ii]); } + * + * for (int jj = 0; jj < 9; jj++) { Matrix xg = XMatrixgas.getMatrix(jj, jj, 0, 3); + * + * try { xcoef[jj] = aMatrix.solve(xg.transpose()); } catch (Exception e) { + * logger.error("error",e); } // logger.info("xcoef " + j); // xcoef.print(10, 10); + * //logger.info("dss: " +ds * dxds.get(speceq, 0)); // specVal = xcoef.get(0, 0) + sny * + * (xcoef.get(1, 0) + sny * (xcoef.get(2, 0) + sny * xcoef.get(3, 0))); // + * logger.info("vall" + vall); } } + */ + if (thermoSystem.hasPhaseType("oil") && acceptedFlash) { + int phaseNumb = thermoSystem.getPhaseNumberOfPhase("oil"); + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); + names[k] = "LIQUID DENSITY"; + units[k] = "KG/M3"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; + names[k] = "DRHOL/DP"; + units[k] = "S2/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); + names[k] = "DRHOL/DT"; + units[k] = "KG/M3-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); + names[k] = "LIQUID VISCOSITY"; + units[k] = "NS/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "LIQUID HEAT CAPACITY"; + units[k] = "J/KG-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEnthalpy() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "LIQUID ENTHALPY"; + units[k] = "J/KG"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "LIQUID ENTROPY"; + units[k] = "J/KG/K"; + k++; + + props[k][i][j] = + thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getConductivity(); + names[k] = "LIQUID THERMAL CONDUCTIVITY"; + units[k] = "W/M-K"; + k++; + hasOilValues = true; + } else { + if (continuousDerivativesExtrapolation && hasOilValues) { + do { + if (j > 1) { + props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) + / (temperatures[j - 1] - temperatures[j - 2]) + * (temperatures[j] - temperatures[j - 1]); + } + /* + * if (i < 2) { props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - + * props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * + * (temperatures[j] - temperatures[j - 1]); } else if (j < 2) { props[k][i][j] = + * props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) / (pressures[i - 1] + * - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); } else { props[k][i][j] = + * props[k][i - 1][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) / + * (temperatures[j - 1] - temperatures[j - 2]) * (temperatures[j] - temperatures[j - + * 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / (pressures[i - 1] - pressures[i - + * 2]) * (pressures[i] - pressures[i - 1]); } props[k][i][j] = 0.0; + */ + k++; + } while (k < 17); // names[k] = "GAS DENSITY"; + // units[k] = "KG/M3"; + } + // setOilProperties(); + // set gas properties } - return bubP; - } - /** - *

- * calcDewP. - *

- * - * @param temperatures an array of {@link double} objects - * @return an array of {@link double} objects - */ - public double[] calcDewP(double[] temperatures) { - double[] dewP = new double[temperatures.length]; - dewPLOG = new double[temperatures.length]; - for (int i = 0; i < temperatures.length; i++) { - thermoSystem.setTemperature(temperatures[i]); - try { - // thermoOps.dewPointPressureFlashHC(); - dewP[i] = thermoSystem.getPressure(); - dewPLOG[i] = dewP[i] * 1e5; - } catch (Exception e) { - logger.error("error", e); - dewP[i] = 0; - } + if (thermoSystem.hasPhaseType("aqueous") && acceptedFlash) { + int phaseNumb = thermoSystem.getPhaseNumberOfPhase("aqueous"); + + props[k][i][j] = thermoSystem.getPhase(0).getComponent("water").getx() + * thermoSystem.getPhase(0).getComponent("water").getMolarMass() + / thermoSystem.getPhase(0).getMolarMass(); + names[k] = "WATER VAPOR MASS FRACTION"; + units[k] = "-"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); + names[k] = "WATER DENSITY"; + units[k] = "KG/M3"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; + names[k] = "DRHOWAT/DP"; + units[k] = "S2/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); + names[k] = "DRHOWAT/DT"; + units[k] = "KG/M3-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); + names[k] = "WATER VISCOSITY"; + units[k] = "NS/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "WATER HEAT CAPACITY"; + units[k] = "J/KG-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEnthalpy() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "WATER ENTHALPY"; + units[k] = "J/KG"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "WATER ENTROPY"; + units[k] = "J/KG/K"; + k++; + + props[k][i][j] = + thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getConductivity(); + names[k] = "WATER THERMAL CONDUCTIVITY"; + units[k] = "W/M-K"; + k++; + hasWaterValues = true; + } else { + if (continuousDerivativesExtrapolation && hasWaterValues) { + do { + if (j > 1) { + props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) + / (temperatures[j - 1] - temperatures[j - 2]) + * (temperatures[j] - temperatures[j - 1]); + } + /* + * if (i < 2) { props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - + * props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * + * (temperatures[j] - temperatures[j - 1]); } else if (j < 2) { props[k][i][j] = + * props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) / (pressures[i - 1] + * - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); } else { props[k][i][j] = + * props[k][i - 1][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) / + * (temperatures[j - 1] - temperatures[j - 2]) * (temperatures[j] - temperatures[j - + * 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / (pressures[i - 1] - pressures[i - + * 2]) * (pressures[i] - pressures[i - 1]); } props[k][i][j] = 0.0; + */ + k++; + } while (k < 26); // names[k] = "GAS DENSITY"; + // units[k] = "KG/M3"; + } } - return dewP; - } - /** - *

- * calcBubT. - *

- * - * @param pressures an array of {@link double} objects - * @return an array of {@link double} objects - */ - public double[] calcBubT(double[] pressures) { - double[] bubTemps = new double[pressures.length]; - for (int i = 0; i < pressures.length; i++) { - thermoSystem.setPressure(pressures[i]); - try { - // thermoOps.bubblePointTemperatureFlash(); - bubT[i] = thermoSystem.getPressure(); - } catch (Exception e) { - logger.error("error", e); - bubT[i] = 0.0; + if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("oil") && acceptedFlash) { + props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( + thermoSystem.getPhaseNumberOfPhase("gas"), thermoSystem.getPhaseNumberOfPhase("oil")); + names[k] = "VAPOR-LIQUID SURFACE TENSION"; + units[k] = "N/M"; + k++; + } else { + if (continuousDerivativesExtrapolation) {// && (i >= 2 || j >= 2)) { + if (!thermoSystem.hasPhaseType("gas")) { + if (i > 2 && j >= 2) { + // props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - + // props[k][i][j - + // 2]) / (temperatures[j - 1] - temperatures[j - 2]) * + // (temperatures[j] - + // temperatures[j - 1]); + } + } else { + // props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - + // props[k][i - + // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - + // pressures[i + // - 1]); } - } - return bubTemps; - } - /** - *

- * initCalc. - *

- */ - public void initCalc() { - double stdTemp = 288.15, stdPres = 1.01325; - // double GOR, GLR; - double molfracs[] = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; - double MW[] = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; - double dens[] = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; - String components[] = new String[thermoSystem.getPhase(0).getNumberOfComponents()]; - - for (int i = 0; i < molfracs.length; i++) { - molfracs[i] = thermoSystem.getPhase(0).getComponent(i).getz(); - components[i] = thermoSystem.getPhase(0).getComponent(i).getComponentName(); - MW[i] = thermoSystem.getPhase(0).getComponent(i).getMolarMass() * 1000; - dens[i] = thermoSystem.getPhase(0).getComponent(i).getNormalLiquidDensity(); + /* + * else if (j < 2) { props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - + * props[k][i - 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - + * pressures[i - 1]); } else { props[k][i][j] = props[k][i - 1][j - 1] + (props[k][i][j + * - 1] - props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * + * (temperatures[j] - temperatures[j - 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / + * (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); } + * props[k][i][j] = 0.0; + */ + props[k][i][j] = 10.0e-3; + k++; + } else { + props[k][i][j] = 10.0e-3; + names[k] = "VAPOR-LIQUID SURFACE TENSION"; + units[k] = "N/M"; + k++; + } } - thermoSystem.setTemperature(stdTemp); - thermoSystem.setPressure(stdPres); - - thermoOps.TPflash(); + if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("aqueous") + && acceptedFlash) { + props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( + thermoSystem.getPhaseNumberOfPhase("gas"), + thermoSystem.getPhaseNumberOfPhase("aqueous")); + names[k] = "VAPOR-WATER SURFACE TENSION"; + units[k] = "N/M"; + k++; + } else { + if (continuousDerivativesExtrapolation) {// && (i >= 2 || j >= 2)) { + if (!thermoSystem.hasPhaseType("gas")) { + if (j >= 2) { + // props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - + // props[k][i][j - + // 2]) / (temperatures[j - 1] - temperatures[j - 2]) * + // (temperatures[j] - + // temperatures[j - 1]); + } + } else { + // props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - + // props[k][i - + // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - + // pressures[i + // - 1]); + } - // GOR = thermoSystem.getPhase(0).getTotalVolume() / - // thermoSystem.getPhase(1).getTotalVolume(); - // GLR = thermoSystem.getPhase(0).getTotalVolume() / - // thermoSystem.getPhase(1).getTotalVolume(); - } + if (i < 2) { + props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) + / (temperatures[j - 1] - temperatures[j - 2]) + * (temperatures[j] - temperatures[j - 1]); + } else if (j < 2) { + props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) + / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + } else { + props[k][i][j] = props[k][i - 1][j - 1] + + (props[k][i][j - 1] - props[k][i][j - 2]) + / (temperatures[j - 1] - temperatures[j - 2]) + * (temperatures[j] - temperatures[j - 1]) + + (props[k][i - 1][j] - props[k][i - 2][j]) + / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + } + props[k][i][j] = 60.0e-3; + // props[k][i][j] = 10.0e-3; + k++; + } else { + props[k][i][j] = 60.0e-3; + names[k] = "VAPOR-WATER SURFACE TENSION"; + units[k] = "N/M"; + k++; + } + } - /** - *

- * calcRSWTOB. - *

- */ - public void calcRSWTOB() { - thermoSystem.init(0); - thermoSystem.init(1); - if (thermoSystem.getPhase(0).hasComponent("water")) { - RSWTOB = thermoSystem.getPhase(0).getComponent("water").getNumberOfmoles() - * thermoSystem.getPhase(0).getComponent("water").getMolarMass() - / (thermoSystem.getTotalNumberOfMoles() * thermoSystem.getMolarMass()); + if (thermoSystem.hasPhaseType("oil") && thermoSystem.hasPhaseType("aqueous") + && acceptedFlash) { + props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( + thermoSystem.getPhaseNumberOfPhase("oil"), + thermoSystem.getPhaseNumberOfPhase("aqueous")); + names[k] = "LIQUID-WATER SURFACE TENSION"; + units[k] = "N/M"; + k++; } else { - RSWTOB = 0.0; + if (continuousDerivativesExtrapolation) {// && (i >= 2 || j >= 2)) { + if (i < 2) { + props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) + / (temperatures[j - 1] - temperatures[j - 2]) + * (temperatures[j] - temperatures[j - 1]); + } else if (j < 2) { + props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) + / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + } else { + props[k][i][j] = props[k][i - 1][j - 1] + + (props[k][i][j - 1] - props[k][i][j - 2]) + / (temperatures[j - 1] - temperatures[j - 2]) + * (temperatures[j] - temperatures[j - 1]) + + (props[k][i - 1][j] - props[k][i - 2][j]) + / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + } + props[k][i][j] = 20.0e-3; + k++; + } else { + props[k][i][j] = 20.0e-3; + names[k] = "LIQUID-WATER SURFACE TENSION"; + units[k] = "N/M"; + k++; + } } + } } - - /** {@inheritDoc} */ - @Override - public void run() { - calcRSWTOB(); - logger.info("RSWTOB " + RSWTOB); - nProps = 29; - props = new double[nProps][pressures.length][temperatures.length]; - units = new String[nProps]; - names = new String[nProps]; - - // int startGasTemperatures = 0; - boolean acceptedFlash = true; - for (int j = 0; j < temperatures.length; j++) { - thermoSystem.setTemperature(temperatures[j]); - for (int i = 0; i < pressures.length; i++) { - thermoSystem.setPressure(pressures[i]); - try { - // logger.info("TPflash... " + thermoSystem.getTemperature() + " pressure " + - // thermoSystem.getPressure()); - thermoOps.TPflash(); - // thermoSystem.createTable("test"); - thermoSystem.init(3); - thermoSystem.initPhysicalProperties(); - // if(thermoSystem.getPressure()>120){ - // thermoSystem.display(); - // } - // thermoSystem.display(); - acceptedFlash = true; - } catch (Exception e) { - acceptedFlash = false; - logger.info("fail temperature " + thermoSystem.getTemperature() - + " fail pressure " + thermoSystem.getPressure()); - - thermoSystem.display(); - logger.error("error", e); - } - - /* - * logger.info("water density " + - * thermoSystem.getPhase(2).getPhysicalProperties().getDensity()); - * logger.info("RSW " + thermoSystem.getPhase(0).getComponent("water").getx() * - * thermoSystem.getPhase(0).getComponent("water").getMolarMass() / - * thermoSystem.getPhase(0).getMolarMass()); logger.info("surf tens oil-water " + - * thermoSystem.getInterphaseProperties().getSurfaceTension(1, 2)); - * logger.info("surf tens gas-water " + - * thermoSystem.getInterphaseProperties().getSurfaceTension(0, 2)); - */ - int k = 0; - if (thermoSystem.hasPhaseType("gas") && acceptedFlash) { - int phaseNumb = thermoSystem.getPhaseNumberOfPhase("gas"); - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); - names[k] = "GAS DENSITY"; - units[k] = "KG/M3"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; - names[k] = "DRHOG/DP"; - units[k] = "S2/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); - names[k] = "DRHOG/DT"; - units[k] = "KG/M3-K"; - k++; - - if (thermoSystem.hasPhaseType("oil")) { - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getBeta() - * thermoSystem.getPhase(phaseNumb).getMolarMass() - / (thermoSystem.getPhase(phaseNumb).getBeta() - * thermoSystem.getPhase(phaseNumb).getMolarMass() - + thermoSystem.getPhase("oil").getBeta() - * thermoSystem.getPhase("oil").getMolarMass()); - } else { - props[k][i][j] = 1.0;// thermoSystem.getPhase(phaseNumb).getBeta() * - // thermoSystem.getPhase(phaseNumb).getMolarMass() / - // thermoSystem.getMolarMass(); - } - names[k] = "GAS MASS FRACTION"; - units[k] = "-"; - k++; - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); - names[k] = "GAS VISCOSITY"; - units[k] = "NS/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "GAS HEAT CAPACITY"; - units[k] = "J/KG-K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEnthalpy() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "GAS ENTHALPY"; - units[k] = "J/KG"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties() - .getConductivity(); - names[k] = "GAS THERMAL CONDUCTIVITY"; - units[k] = "W/M-K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "GAS ENTROPY"; - units[k] = "J/KG/K"; - k++; - hasGasValues = true; - // set gas properties - } else { - if (continuousDerivativesExtrapolation && hasGasValues) { - do { - if (i > 1) { - props[k][i][j] = props[k][i - 1][j] - + (props[k][i - 1][j] - props[k][i - 2][j]) - / (pressures[i - 1] - pressures[i - 2]) - * (pressures[i] - pressures[i - 1]); - // } //else if (j < 2) { - // props[k][i][j] = 0;//props[k][i - 1][j] + (props[k][i - 1][j] - - // props[k][i - - // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - - // pressures[i - // - 1]); - // } else { - // props[k][i][j] = 0;//props[k][i - 1][j - 1] + (props[k][i][j - 1] - // - - // props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - 2]) - // * - // (temperatures[j] - temperatures[j - 1]) + (props[k][i - 1][j] - - // props[k][i - - // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - - // pressures[i - // - 1]); - // double newTemp = pressures[i]; - // double vall = xcoef[k].get(0, 0) + newTemp * (xcoef[k].get(1, 0) - // + newTemp * - // (xcoef[k].get(2, 0) + newTemp * xcoef[k].get(3, 0))); - // props[k][i][j] = vall; - // if(i>0 && props[k][i-1][j]>1e-10) props[k][i][j] = - // props[k][i-1][j]*pressures[i]/pressures[i-1]; - } - if (names[k].equals("GAS MASS FRACTION") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - k++; - } while (k < 9);// names[k] = "GAS DENSITY"; - // units[k] = "KG/M3"; - } - /* - * else if (false && !hasGasValues) { startGasTemperatures = j; } - */ - } - /* - * double[] gasVals = new double[9]; for (int kk = 0; kk < 9; kk++) { gasVals[kk] = - * props[kk][i][j]; } Matrix gasVector = new Matrix(gasVals, 1).transpose(); - * XMatrixgas.setMatrix(0, 8, 0, 2, XMatrixgas.getMatrix(0, 8, 1, 3)); - * XMatrixgas.setMatrix(0, 8, 3, 3, gasVector); if (i > 3) { for (int ii = 0; ii < - * 4; ii++) { aMatrix.set(ii, 0, 1.0); aMatrix.set(ii, 1, pressures[i - ii]); - * aMatrix.set(ii, 2, pressures[i - ii] * pressures[i - ii]); aMatrix.set(ii, 3, - * pressures[i - ii] * pressures[i - ii] * pressures[i - ii]); } - * - * for (int jj = 0; jj < 9; jj++) { Matrix xg = XMatrixgas.getMatrix(jj, jj, 0, 3); - * - * try { xcoef[jj] = aMatrix.solve(xg.transpose()); } catch (Exception e) { - * logger.error("error",e); } // logger.info("xcoef " + j); // xcoef.print(10, 10); - * //logger.info("dss: " +ds * dxds.get(speceq, 0)); // specVal = xcoef.get(0, 0) + - * sny * (xcoef.get(1, 0) + sny * (xcoef.get(2, 0) + sny * xcoef.get(3, 0))); // - * logger.info("vall" + vall); } } - */ - if (thermoSystem.hasPhaseType("oil") && acceptedFlash) { - int phaseNumb = thermoSystem.getPhaseNumberOfPhase("oil"); - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); - names[k] = "LIQUID DENSITY"; - units[k] = "KG/M3"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; - names[k] = "DRHOL/DP"; - units[k] = "S2/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); - names[k] = "DRHOL/DT"; - units[k] = "KG/M3-K"; - k++; - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); - names[k] = "LIQUID VISCOSITY"; - units[k] = "NS/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "LIQUID HEAT CAPACITY"; - units[k] = "J/KG-K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEnthalpy() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "LIQUID ENTHALPY"; - units[k] = "J/KG"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "LIQUID ENTROPY"; - units[k] = "J/KG/K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties() - .getConductivity(); - names[k] = "LIQUID THERMAL CONDUCTIVITY"; - units[k] = "W/M-K"; - k++; - hasOilValues = true; - } else { - if (continuousDerivativesExtrapolation && hasOilValues) { - do { - if (j > 1) { - props[k][i][j] = props[k][i][j - 1] - + (props[k][i][j - 1] - props[k][i][j - 2]) - / (temperatures[j - 1] - temperatures[j - 2]) - * (temperatures[j] - temperatures[j - 1]); - } - /* - * if (i < 2) { props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - - * 1] - props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - - * 2]) * (temperatures[j] - temperatures[j - 1]); } else if (j < 2) { - * props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - - * props[k][i - 2][j]) / (pressures[i - 1] - pressures[i - 2]) * - * (pressures[i] - pressures[i - 1]); } else { props[k][i][j] = - * props[k][i - 1][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) / - * (temperatures[j - 1] - temperatures[j - 2]) * (temperatures[j] - - * temperatures[j - 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / - * (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - - * 1]); } props[k][i][j] = 0.0; - */ - k++; - } while (k < 17);// names[k] = "GAS DENSITY"; - // units[k] = "KG/M3"; - } - // setOilProperties(); - // set gas properties - } - - if (thermoSystem.hasPhaseType("aqueous") && acceptedFlash) { - int phaseNumb = thermoSystem.getPhaseNumberOfPhase("aqueous"); - - props[k][i][j] = thermoSystem.getPhase(0).getComponent("water").getx() - * thermoSystem.getPhase(0).getComponent("water").getMolarMass() - / thermoSystem.getPhase(0).getMolarMass(); - names[k] = "WATER VAPOR MASS FRACTION"; - units[k] = "-"; - k++; - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); - names[k] = "WATER DENSITY"; - units[k] = "KG/M3"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; - names[k] = "DRHOWAT/DP"; - units[k] = "S2/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); - names[k] = "DRHOWAT/DT"; - units[k] = "KG/M3-K"; - k++; - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); - names[k] = "WATER VISCOSITY"; - units[k] = "NS/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "WATER HEAT CAPACITY"; - units[k] = "J/KG-K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEnthalpy() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "WATER ENTHALPY"; - units[k] = "J/KG"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "WATER ENTROPY"; - units[k] = "J/KG/K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties() - .getConductivity(); - names[k] = "WATER THERMAL CONDUCTIVITY"; - units[k] = "W/M-K"; - k++; - hasWaterValues = true; - } else { - if (continuousDerivativesExtrapolation && hasWaterValues) { - do { - if (j > 1) { - props[k][i][j] = props[k][i][j - 1] - + (props[k][i][j - 1] - props[k][i][j - 2]) - / (temperatures[j - 1] - temperatures[j - 2]) - * (temperatures[j] - temperatures[j - 1]); - } - /* - * if (i < 2) { props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - - * 1] - props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - - * 2]) * (temperatures[j] - temperatures[j - 1]); } else if (j < 2) { - * props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - - * props[k][i - 2][j]) / (pressures[i - 1] - pressures[i - 2]) * - * (pressures[i] - pressures[i - 1]); } else { props[k][i][j] = - * props[k][i - 1][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) / - * (temperatures[j - 1] - temperatures[j - 2]) * (temperatures[j] - - * temperatures[j - 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / - * (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - - * 1]); } props[k][i][j] = 0.0; - */ - k++; - } while (k < 26);// names[k] = "GAS DENSITY"; - // units[k] = "KG/M3"; - } - } - - if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("oil") - && acceptedFlash) { - props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( - thermoSystem.getPhaseNumberOfPhase("gas"), - thermoSystem.getPhaseNumberOfPhase("oil")); - names[k] = "VAPOR-LIQUID SURFACE TENSION"; - units[k] = "N/M"; - k++; - } else { - if (continuousDerivativesExtrapolation) {// && (i >= 2 || j >= 2)) { - if (!thermoSystem.hasPhaseType("gas")) { - if (i > 2 && j >= 2) { - // props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - - // props[k][i][j - - // 2]) / (temperatures[j - 1] - temperatures[j - 2]) * - // (temperatures[j] - - // temperatures[j - 1]); - } - } else { - // props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - - // props[k][i - - // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - - // pressures[i - // - 1]); - } - - /* - * else if (j < 2) { props[k][i][j] = props[k][i - 1][j] + (props[k][i - - * 1][j] - props[k][i - 2][j]) / (pressures[i - 1] - pressures[i - 2]) * - * (pressures[i] - pressures[i - 1]); } else { props[k][i][j] = props[k][i - - * 1][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) / (temperatures[j - - * 1] - temperatures[j - 2]) * (temperatures[j] - temperatures[j - 1]) + - * (props[k][i - 1][j] - props[k][i - 2][j]) / (pressures[i - 1] - - * pressures[i - 2]) * (pressures[i] - pressures[i - 1]); } props[k][i][j] = - * 0.0; - */ - props[k][i][j] = 10.0e-3; - k++; - } else { - props[k][i][j] = 10.0e-3; - names[k] = "VAPOR-LIQUID SURFACE TENSION"; - units[k] = "N/M"; - k++; - } - } - - if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("aqueous") - && acceptedFlash) { - props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( - thermoSystem.getPhaseNumberOfPhase("gas"), - thermoSystem.getPhaseNumberOfPhase("aqueous")); - names[k] = "VAPOR-WATER SURFACE TENSION"; - units[k] = "N/M"; - k++; - } else { - if (continuousDerivativesExtrapolation) {// && (i >= 2 || j >= 2)) { - if (!thermoSystem.hasPhaseType("gas")) { - if (j >= 2) { - // props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - - // props[k][i][j - - // 2]) / (temperatures[j - 1] - temperatures[j - 2]) * - // (temperatures[j] - - // temperatures[j - 1]); - } - } else { - // props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - - // props[k][i - - // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - - // pressures[i - // - 1]); - } - - if (i < 2) { - props[k][i][j] = - props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) - / (temperatures[j - 1] - temperatures[j - 2]) - * (temperatures[j] - temperatures[j - 1]); - } else if (j < 2) { - props[k][i][j] = - props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) - / (pressures[i - 1] - pressures[i - 2]) - * (pressures[i] - pressures[i - 1]); - } else { - props[k][i][j] = props[k][i - 1][j - 1] - + (props[k][i][j - 1] - props[k][i][j - 2]) - / (temperatures[j - 1] - temperatures[j - 2]) - * (temperatures[j] - temperatures[j - 1]) - + (props[k][i - 1][j] - props[k][i - 2][j]) - / (pressures[i - 1] - pressures[i - 2]) - * (pressures[i] - pressures[i - 1]); - } - props[k][i][j] = 60.0e-3; - // props[k][i][j] = 10.0e-3; - k++; - } else { - props[k][i][j] = 60.0e-3; - names[k] = "VAPOR-WATER SURFACE TENSION"; - units[k] = "N/M"; - k++; - } - } - - if (thermoSystem.hasPhaseType("oil") && thermoSystem.hasPhaseType("aqueous") - && acceptedFlash) { - props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( - thermoSystem.getPhaseNumberOfPhase("oil"), - thermoSystem.getPhaseNumberOfPhase("aqueous")); - names[k] = "LIQUID-WATER SURFACE TENSION"; - units[k] = "N/M"; - k++; - } else { - if (continuousDerivativesExtrapolation) {// && (i >= 2 || j >= 2)) { - if (i < 2) { - props[k][i][j] = - props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) - / (temperatures[j - 1] - temperatures[j - 2]) - * (temperatures[j] - temperatures[j - 1]); - } else if (j < 2) { - props[k][i][j] = - props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) - / (pressures[i - 1] - pressures[i - 2]) - * (pressures[i] - pressures[i - 1]); - } else { - props[k][i][j] = props[k][i - 1][j - 1] - + (props[k][i][j - 1] - props[k][i][j - 2]) - / (temperatures[j - 1] - temperatures[j - 2]) - * (temperatures[j] - temperatures[j - 1]) - + (props[k][i - 1][j] - props[k][i - 2][j]) - / (pressures[i - 1] - pressures[i - 2]) - * (pressures[i] - pressures[i - 1]); - } - props[k][i][j] = 20.0e-3; - k++; - } else { - props[k][i][j] = 20.0e-3; - names[k] = "LIQUID-WATER SURFACE TENSION"; - units[k] = "N/M"; - k++; - } - } - } + logger.info("Finished TPflash..."); + if (thermoSystem.getPhase(0).hasComponent("water")) { + thermoSystem.removeComponent("water"); + } + bubP = calcBubP(temperatures); + dewP = calcDewP(temperatures); + // bubT = calcBubT(temperatures); + logger.info("Finished creating arrays"); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + logger.info("TC " + TC + " PC " + PC); + for (int i = 0; i < pressures.length; i++) { + thermoSystem.setPressure(pressures[i]); + for (int j = 0; j < temperatures.length; j++) { + logger.info("pressure " + pressureLOG[i] + " temperature " + temperatureLOG[j]); // + + // " + // ROG + // " + // + + // ROG[i][j] + // + + // " + // ROL + // " + // + + // ROL[i][j]); + } + } + writeOLGAinpFile(""); + } + + /** + *

+ * writeOLGAinpFile2. + *

+ * + * @param filename a {@link java.lang.String} object + */ + public void writeOLGAinpFile2(String filename) { + /* + * try { writer = new BufferedWriter(new OutputStreamWriter( new + * FileOutputStream("C:/Users/Kjetil Raul/Documents/Master KRB/javacode_ROG55.txt" ), "utf-8")); + * writer.write("GAS DENSITY (KG/M3) = ("); for (int i = 0; i < pressures.length; i++) { + * thermoSystem.setPressure(pressures[i]); for (int j = 0; j < temperatures.length; j++) { + * thermoSystem.setTemperature(temperatures[j]); writer.write(ROG[i][j] + ","); } } + * writer.write(")"); } catch (IOException ex) { // report } finally { try { } writer.close(); } + * catch (Exception ex) { } } + */ + try (Writer writer = new BufferedWriter( + new OutputStreamWriter(new FileOutputStream("C:/temp/temp.tab"), "utf-8"))) { + writer.write("'WATER-OPTION ENTROPY NONEQ '" + "\n"); + writer.write(pressures.length + " " + temperatures.length + " " + RSWTOB + "\n"); + int Pcounter = 0; + for (int i = 0; i < pressures.length; i++) { + if (Pcounter > 4) { + writer.write("\n"); + Pcounter = 0; } - logger.info("Finished TPflash..."); - if (thermoSystem.getPhase(0).hasComponent("water")) { - thermoSystem.removeComponent("water"); + writer.write(pressureLOG[i] + " "); + Pcounter++; + } + writer.write("\n"); + + int Tcounter = 0; + for (int i = 0; i < temperatures.length; i++) { + if (Tcounter > 4) { + writer.write("\n"); + Tcounter = 0; } - bubP = calcBubP(temperatures); - dewP = calcDewP(temperatures); - // bubT = calcBubT(temperatures); - logger.info("Finished creating arrays"); - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - logger.info("TC " + TC + " PC " + PC); + writer.write(temperatureLOG[i] + " "); + Tcounter++; + } + writer.write("\n"); + + int bubPcounter = 0; + for (int i = 0; i < temperatures.length; i++) { + if (bubPcounter > 4) { + writer.write("\n"); + bubPcounter = 0; + } + writer.write(bubPLOG[i] + " "); + bubPcounter++; + } + writer.write("\n"); + + int dewPcounter = 0; + for (int i = 0; i < temperatures.length; i++) { + if (dewPcounter > 4) { + writer.write("\n"); + dewPcounter = 0; + } + writer.write(dewPLOG[i] + " "); + dewPcounter++; + } + writer.write("\n"); + + for (int k = 0; k < nProps; k++) { + if (names[k] == null) { + continue; + } + logger.info("Writing variable: " + names[k]); + writer.write(names[k] + " (" + units[k] + ")\n"); for (int i = 0; i < pressures.length; i++) { - thermoSystem.setPressure(pressures[i]); - for (int j = 0; j < temperatures.length; j++) { - logger.info("pressure " + pressureLOG[i] + " temperature " + temperatureLOG[j]);// + - // " - // ROG - // " - // + - // ROG[i][j] - // + - // " - // ROL - // " - // + - // ROL[i][j]); + // thermoSystem.setPressure(pressures[i]); + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + // thermoSystem.setTemperature(temperatures[j]); + if (counter > 4) { + writer.write("\n"); + counter = 0; } + writer.write(props[k][i][j] + " "); + counter++; + } + writer.write("\n"); } - writeOLGAinpFile(""); + } + } catch (IOException ex) { + // report } - - /** - *

- * writeOLGAinpFile2. - *

- * - * @param filename a {@link java.lang.String} object + } + + /** + *

+ * writeOLGAinpFile. + *

+ * + * @param filename a {@link java.lang.String} object + */ + public void writeOLGAinpFile(String filename) { + /* + * try { writer = new BufferedWriter(new OutputStreamWriter( new + * FileOutputStream("C:/Users/Kjetil Raul/Documents/Master KRB/javacode_ROG55.txt" ), "utf-8")); + * writer.write("GAS DENSITY (KG/M3) = ("); for (int i = 0; i < pressures.length; i++) { + * thermoSystem.setPressure(pressures[i]); for (int j = 0; j < temperatures.length; j++) { + * thermoSystem.setTemperature(temperatures[j]); writer.write(ROG[i][j] + ","); } } + * writer.write(")"); } catch (IOException ex) { // report } finally { try { } writer.close(); } + * catch (Exception ex) { } } */ - public void writeOLGAinpFile2(String filename) { - /* - * try { writer = new BufferedWriter(new OutputStreamWriter( new - * FileOutputStream("C:/Users/Kjetil Raul/Documents/Master KRB/javacode_ROG55.txt" ), - * "utf-8")); writer.write("GAS DENSITY (KG/M3) = ("); for (int i = 0; i < pressures.length; - * i++) { thermoSystem.setPressure(pressures[i]); for (int j = 0; j < temperatures.length; - * j++) { thermoSystem.setTemperature(temperatures[j]); writer.write(ROG[i][j] + ","); } } - * writer.write(")"); } catch (IOException ex) { // report } finally { try { } - * writer.close(); } catch (Exception ex) { } } - */ - try (Writer writer = new BufferedWriter( - new OutputStreamWriter(new FileOutputStream("C:/temp/temp.tab"), "utf-8"))) { - writer.write("'WATER-OPTION ENTROPY NONEQ '" + "\n"); - writer.write(pressures.length + " " + temperatures.length + " " + RSWTOB + "\n"); - int Pcounter = 0; - for (int i = 0; i < pressures.length; i++) { - if (Pcounter > 4) { - writer.write("\n"); - Pcounter = 0; - } - writer.write(pressureLOG[i] + " "); - Pcounter++; - } + try (Writer writer = + new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName), "utf-8"))) { + writer.write("'WATER-OPTION ENTROPY NONEQ '" + "\n"); + + writer.write(pressures.length + " " + temperatures.length + " " + RSWTOB + "\n"); + int Pcounter = 0; + for (int i = 0; i < pressures.length; i++) { + if (Pcounter > 4) { + writer.write("\n"); + Pcounter = 0; + } + writer.write(pressureLOG[i] + " "); + Pcounter++; + } + writer.write("\n"); + + int Tcounter = 0; + for (int i = 0; i < temperatures.length; i++) { + if (Tcounter > 4) { + writer.write("\n"); + Tcounter = 0; + } + writer.write(temperatureLOG[i] + " "); + Tcounter++; + } + writer.write("\n"); + + int bubPcounter = 0; + for (int i = 0; i < temperatures.length; i++) { + if (bubPcounter > 4) { + writer.write("\n"); + bubPcounter = 0; + } + writer.write(bubPLOG[i] + " "); + bubPcounter++; + } + writer.write("\n"); + + int dewPcounter = 0; + for (int i = 0; i < temperatures.length; i++) { + if (dewPcounter > 4) { + writer.write("\n"); + dewPcounter = 0; + } + writer.write(dewPLOG[i] + " "); + dewPcounter++; + } + writer.write("\n"); + + writer.write("GAS DENSITY (KG/M3)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[0][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int Tcounter = 0; - for (int i = 0; i < temperatures.length; i++) { - if (Tcounter > 4) { - writer.write("\n"); - Tcounter = 0; - } - writer.write(temperatureLOG[i] + " "); - Tcounter++; - } + writer.write("LIQUID DENSITY (KG/M3)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[9][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int bubPcounter = 0; - for (int i = 0; i < temperatures.length; i++) { - if (bubPcounter > 4) { - writer.write("\n"); - bubPcounter = 0; - } - writer.write(bubPLOG[i] + " "); - bubPcounter++; - } + writer.write("WATER DENSITY (KG/M3)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[18][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int dewPcounter = 0; - for (int i = 0; i < temperatures.length; i++) { - if (dewPcounter > 4) { - writer.write("\n"); - dewPcounter = 0; - } - writer.write(dewPLOG[i] + " "); - dewPcounter++; - } + writer.write("DRHOG/DP (S2/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); - - for (int k = 0; k < nProps; k++) { - if (names[k] == null) { - continue; - } - logger.info("Writing variable: " + names[k]); - writer.write(names[k] + " (" + units[k] + ")\n"); - for (int i = 0; i < pressures.length; i++) { - // thermoSystem.setPressure(pressures[i]); - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - // thermoSystem.setTemperature(temperatures[j]); - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[k][i][j] + " "); - counter++; - } - writer.write("\n"); - } - } - } catch (IOException ex) { - // report + counter = 0; + } + writer.write(props[1][i][j] + " "); + counter++; } - } + writer.write("\n"); + } - /** - *

- * writeOLGAinpFile. - *

- * - * @param filename a {@link java.lang.String} object - */ - public void writeOLGAinpFile(String filename) { - /* - * try { writer = new BufferedWriter(new OutputStreamWriter( new - * FileOutputStream("C:/Users/Kjetil Raul/Documents/Master KRB/javacode_ROG55.txt" ), - * "utf-8")); writer.write("GAS DENSITY (KG/M3) = ("); for (int i = 0; i < pressures.length; - * i++) { thermoSystem.setPressure(pressures[i]); for (int j = 0; j < temperatures.length; - * j++) { thermoSystem.setTemperature(temperatures[j]); writer.write(ROG[i][j] + ","); } } - * writer.write(")"); } catch (IOException ex) { // report } finally { try { } - * writer.close(); } catch (Exception ex) { } } - */ - try (Writer writer = new BufferedWriter( - new OutputStreamWriter(new FileOutputStream(fileName), "utf-8"))) { - writer.write("'WATER-OPTION ENTROPY NONEQ '" + "\n"); - - writer.write(pressures.length + " " + temperatures.length + " " + RSWTOB + "\n"); - int Pcounter = 0; - for (int i = 0; i < pressures.length; i++) { - if (Pcounter > 4) { - writer.write("\n"); - Pcounter = 0; - } - writer.write(pressureLOG[i] + " "); - Pcounter++; - } + writer.write("DRHOL/DP (S2/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[10][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int Tcounter = 0; - for (int i = 0; i < temperatures.length; i++) { - if (Tcounter > 4) { - writer.write("\n"); - Tcounter = 0; - } - writer.write(temperatureLOG[i] + " "); - Tcounter++; - } + writer.write("DRHOWAT/DP (S2/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[19][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int bubPcounter = 0; - for (int i = 0; i < temperatures.length; i++) { - if (bubPcounter > 4) { - writer.write("\n"); - bubPcounter = 0; - } - writer.write(bubPLOG[i] + " "); - bubPcounter++; - } + writer.write("DRHOG/DT (KG/M3-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[2][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int dewPcounter = 0; - for (int i = 0; i < temperatures.length; i++) { - if (dewPcounter > 4) { - writer.write("\n"); - dewPcounter = 0; - } - writer.write(dewPLOG[i] + " "); - dewPcounter++; - } + writer.write("DRHOL/DT (KG/M3-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[11][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS DENSITY (KG/M3)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[0][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("LIQUID DENSITY (KG/M3)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[9][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("WATER DENSITY (KG/M3)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[18][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOG/DP (S2/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[1][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOL/DP (S2/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[10][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOWAT/DP (S2/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[19][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOG/DT (KG/M3-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[2][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOL/DT (KG/M3-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[11][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOWAT/DT (KG/M3-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[20][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("GAS MASS FRACTION (-)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[3][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("WATER VAPOR MASS FRACTION (-)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[17][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("DRHOWAT/DT (KG/M3-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[20][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS VISCOSITY (NS/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[4][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS MASS FRACTION (-)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[3][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID VISCOSITY (NS/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[12][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("WATER VAPOR MASS FRACTION (-)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[17][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("WATER VISCOSITY (NS/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[21][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS VISCOSITY (NS/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[4][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS HEAT CAPACITY (J/KG-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[5][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("LIQUID VISCOSITY (NS/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[12][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID HEAT CAPACITY (J/KG-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[13][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("WATER VISCOSITY (NS/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[21][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("WATER HEAT CAPACITY (J/KG-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[22][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS HEAT CAPACITY (J/KG-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[5][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS ENTHALPY (J/KG)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[6][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("LIQUID HEAT CAPACITY (J/KG-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[13][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID ENTHALPY (J/KG)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[14][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("WATER HEAT CAPACITY (J/KG-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[22][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("WATER ENTHALPY (J/KG)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[23][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS ENTHALPY (J/KG)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[6][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS THERMAL CONDUCTIVITY (W/M-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[7][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("LIQUID ENTHALPY (J/KG)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[14][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID THERMAL CONDUCTIVITY (W/M-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[16][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("WATER ENTHALPY (J/KG)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[23][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("WATER THERMAL CONDUCTIVITY (W/M-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[25][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS THERMAL CONDUCTIVITY (W/M-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[7][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("VAPOR-LIQUID SURFACE TENSION (N/M)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[26][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("LIQUID THERMAL CONDUCTIVITY (W/M-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[16][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("VAPOR-WATER SURFACE TENSION (N/M)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[27][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("WATER THERMAL CONDUCTIVITY (W/M-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[25][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID-WATER SURFACE TENSION (N/M)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[28][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("VAPOR-LIQUID SURFACE TENSION (N/M)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[26][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS ENTROPY (J/KG/K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[8][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("VAPOR-WATER SURFACE TENSION (N/M)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[27][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID ENTROPY (J/KG/K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[15][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("LIQUID-WATER SURFACE TENSION (N/M)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[28][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("WATER ENTROPY (J/KG/K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[24][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS ENTROPY (J/KG/K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[8][i][j] + " "); + counter++; + } + writer.write("\n"); + } - /* - * for (int k = 0; k < nProps; k++) { if (names[k] == null) { continue; } - * logger.info("Writing variable: " + names[k]); writer.write(names[k] + " (" + units[k] - * + ")\n"); for (int i = 0; i < pressures.length; i++) { - * //thermoSystem.setPressure(pressures[i]); int counter = 0; for (int j = 0; j < - * temperatures.length; j++) { // thermoSystem.setTemperature(temperatures[j]); if - * (counter > 4) { writer.write("\n"); counter = 0; } writer.write(props[k][i][j] + - * " "); counter++; } writer.write("\n"); } } - */ - } catch (IOException ex) { - // report + writer.write("LIQUID ENTROPY (J/KG/K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[15][i][j] + " "); + counter++; } - } + writer.write("\n"); + } - /** - *

- * extrapolateTable. - *

- */ - public void extrapolateTable() { + writer.write("WATER ENTROPY (J/KG/K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; for (int j = 0; j < temperatures.length; j++) { - for (int i = 0; i < pressures.length; i++) { - if (!hasValue[26][i][j]) { - } - } + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[24][i][j] + " "); + counter++; + } + writer.write("\n"); + } + + /* + * for (int k = 0; k < nProps; k++) { if (names[k] == null) { continue; } + * logger.info("Writing variable: " + names[k]); writer.write(names[k] + " (" + units[k] + + * ")\n"); for (int i = 0; i < pressures.length; i++) { + * //thermoSystem.setPressure(pressures[i]); int counter = 0; for (int j = 0; j < + * temperatures.length; j++) { // thermoSystem.setTemperature(temperatures[j]); if (counter > + * 4) { writer.write("\n"); counter = 0; } writer.write(props[k][i][j] + " "); counter++; } + * writer.write("\n"); } } + */ + } catch (IOException ex) { + // report + } + } + + /** + *

+ * extrapolateTable. + *

+ */ + public void extrapolateTable() { + for (int j = 0; j < temperatures.length; j++) { + for (int i = 0; i < pressures.length; i++) { + if (!hasValue[26][i][j]) { } + } } + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudents.java b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudents.java index 110c596b85..c774dc68df 100644 --- a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudents.java +++ b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudents.java @@ -22,1922 +22,1890 @@ * @version $Id: $Id */ public class OLGApropertyTableGeneratorWaterStudents - extends neqsim.thermodynamicOperations.BaseOperation { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(OLGApropertyTableGeneratorWaterStudents.class); - - SystemInterface thermoSystem = null, gasSystem = null, oilSystem = null, waterSystem = null; - ThermodynamicOperations thermoOps = null; - double[] pressures, temperatureLOG, temperatures, pressureLOG = null; - double[] bubP, bubT, dewP, bubPLOG, dewPLOG; - Matrix XMatrixgas, XMatrixoil, XMatrixwater; - double[][] ROG = null; - double maxPressure; - double minPressure; - double maxTemperature, TLC, GLW, GL, GW; // TLC = Top left corner. GOW=Gas+Liquid+Water, GO = - // Gas+Liquid, GW = - // Gas+Water - double minTemperature, VLS, VWS, LWS;; // VLS=Stop value for vapor-liqid surface tension. - // VWS=Stop value for - // vapor-water surface tension. LWS=Stop value for - // liquid-water surface - // tension - // double VLB, VLT, VWT, VWB, LWB, LWT; - // double[][] ROL, CPG, CPHL, HG, HHL, TCG, TCHL, VISG, - // VISHL, SIGGHL, SEG, - // SEHL, RS; - double TC, PC; - double RSWTOB; - double[][][] props; - int nProps; - String[] names; - Matrix[] xcoef = new Matrix[9]; - String[] units; - int temperatureSteps, pressureSteps; - boolean continuousDerivativesExtrapolation = true; - boolean hasGasValues = false; - boolean hasOilValues = false; - boolean hasWaterValues = false; - boolean[][][] hasValue; - Matrix aMatrix = new Matrix(4, 4); - Matrix s = new Matrix(1, 4); - String fileName = "c:/Appl/OLGAneqsim.tab"; - - /** - *

- * Constructor for OLGApropertyTableGeneratorWaterStudents. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public OLGApropertyTableGeneratorWaterStudents(SystemInterface system) { - this.thermoSystem = system; - thermoOps = new ThermodynamicOperations(thermoSystem); - - XMatrixgas = new Matrix(9, 4); - XMatrixoil = new Matrix(9, 4); - XMatrixwater = new Matrix(9, 4); - - gasSystem = new SystemSrkEos(298, 10); - gasSystem.addComponent("methane", 1); - // gasSystem.createDatabase(true); - gasSystem.init(0); - gasSystem.setNumberOfPhases(1); - - waterSystem = new SystemSrkCPAstatoil(298, 10); - waterSystem.addComponent("water", 1); - // waterSystem.createDatabase(true); - waterSystem.init(0); - waterSystem.setNumberOfPhases(1); - - oilSystem = new SystemSrkEos(298, 10); - oilSystem.addComponent("nC10", 1); - // oilSystem.createDatabase(true); - oilSystem.init(0); - oilSystem.setNumberOfPhases(1); + extends neqsim.thermodynamicOperations.BaseOperation { + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(OLGApropertyTableGeneratorWaterStudents.class); + + SystemInterface thermoSystem = null; + SystemInterface gasSystem = null; + SystemInterface oilSystem = null; + SystemInterface waterSystem = null; + ThermodynamicOperations thermoOps = null; + double[] pressures; + double[] temperatureLOG; + double[] temperatures; + double[] pressureLOG = null; + double[] bubP; + double[] bubT; + double[] dewP; + double[] bubPLOG; + double[] dewPLOG; + Matrix XMatrixgas; + Matrix XMatrixoil; + Matrix XMatrixwater; + double[][] ROG = null; + double maxPressure; + double minPressure; + double maxTemperature; + double TLC; + double GLW; + double GL; + double GW; + double minTemperature; + double VLS; + double VWS; + double LWS; + double TC; + double PC; + double RSWTOB; + double[][][] props; + int nProps; + String[] names; + Matrix[] xcoef = new Matrix[9]; + String[] units; + int temperatureSteps; + int pressureSteps; + boolean continuousDerivativesExtrapolation = true; + boolean hasGasValues = false; + boolean hasOilValues = false; + boolean hasWaterValues = false; + boolean[][][] hasValue; + Matrix aMatrix = new Matrix(4, 4); + Matrix s = new Matrix(1, 4); + String fileName = "c:/Appl/OLGAneqsim.tab"; + + /** + *

+ * Constructor for OLGApropertyTableGeneratorWaterStudents. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public OLGApropertyTableGeneratorWaterStudents(SystemInterface system) { + this.thermoSystem = system; + thermoOps = new ThermodynamicOperations(thermoSystem); + + XMatrixgas = new Matrix(9, 4); + XMatrixoil = new Matrix(9, 4); + XMatrixwater = new Matrix(9, 4); + + gasSystem = new SystemSrkEos(298, 10); + gasSystem.addComponent("methane", 1); + // gasSystem.createDatabase(true); + gasSystem.init(0); + gasSystem.setNumberOfPhases(1); + + waterSystem = new SystemSrkCPAstatoil(298, 10); + waterSystem.addComponent("water", 1); + // waterSystem.createDatabase(true); + waterSystem.init(0); + waterSystem.setNumberOfPhases(1); + + oilSystem = new SystemSrkEos(298, 10); + oilSystem.addComponent("nC10", 1); + // oilSystem.createDatabase(true); + oilSystem.init(0); + oilSystem.setNumberOfPhases(1); + } + + /** + *

+ * Setter for the field fileName. + *

+ * + * @param name a {@link java.lang.String} object + */ + public void setFileName(String name) { + fileName = name; + } + + /** + *

+ * setPressureRange. + *

+ * + * @param minPressure a double + * @param maxPressure a double + * @param numberOfSteps a int + */ + public void setPressureRange(double minPressure, double maxPressure, int numberOfSteps) { + pressures = new double[numberOfSteps]; + pressureLOG = new double[numberOfSteps]; + double step = (maxPressure - minPressure) / (numberOfSteps * 1.0 - 1.0); + for (int i = 0; i < numberOfSteps; i++) { + pressures[i] = minPressure + i * step; + pressureLOG[i] = pressures[i] * 1e5; } - - /** - *

- * Setter for the field fileName. - *

- * - * @param name a {@link java.lang.String} object - */ - public void setFileName(String name) { - fileName = name; + } + + /** + *

+ * setTemperatureRange. + *

+ * + * @param minTemperature a double + * @param maxTemperature a double + * @param numberOfSteps a int + */ + public void setTemperatureRange(double minTemperature, double maxTemperature, int numberOfSteps) { + temperatures = new double[numberOfSteps]; + temperatureLOG = new double[numberOfSteps]; + double step = (maxTemperature - minTemperature) / (numberOfSteps * 1.0 - 1.0); + for (int i = 0; i < numberOfSteps; i++) { + temperatures[i] = minTemperature + i * step; + temperatureLOG[i] = temperatures[i] - 273.15; + } + } + + /** + *

+ * calcPhaseEnvelope. + *

+ */ + public void calcPhaseEnvelope() { + try { + thermoOps.calcPTphaseEnvelope(); + TC = thermoSystem.getTC() - 273.15; + PC = thermoSystem.getPC() * 1e5; + } catch (Exception e) { + logger.error("error", e); } + } + + /** + *

+ * calcBubP. + *

+ * + * @param temperatures an array of {@link double} objects + * @return an array of {@link double} objects + */ + public double[] calcBubP(double[] temperatures) { + double[] bubP = new double[temperatures.length]; + bubPLOG = new double[temperatures.length]; + for (int i = 0; i < temperatures.length; i++) { + thermoSystem.setTemperature(temperatures[i]); + try { + thermoOps.bubblePointPressureFlash(false); + bubP[i] = thermoSystem.getPressure(); + } catch (Exception e) { + logger.error("error", e); + bubP[i] = 0; + return bubP; + } + bubPLOG[i] = bubP[i] * 1e5; + } + return bubP; + } + + /** + *

+ * calcDewP. + *

+ * + * @param temperatures an array of {@link double} objects + * @return an array of {@link double} objects + */ + public double[] calcDewP(double[] temperatures) { + double[] dewP = new double[temperatures.length]; + dewPLOG = new double[temperatures.length]; + for (int i = 0; i < temperatures.length; i++) { + thermoSystem.setTemperature(temperatures[i]); + try { + thermoOps.dewPointPressureFlashHC(); + dewP[i] = thermoSystem.getPressure(); + } catch (Exception e) { + logger.error("error", e); + dewP[i] = 0; + return dewP; + } - /** - *

- * setPressureRange. - *

- * - * @param minPressure a double - * @param maxPressure a double - * @param numberOfSteps a int - */ - public void setPressureRange(double minPressure, double maxPressure, int numberOfSteps) { - pressures = new double[numberOfSteps]; - pressureLOG = new double[numberOfSteps]; - double step = (maxPressure - minPressure) / (numberOfSteps * 1.0 - 1.0); - for (int i = 0; i < numberOfSteps; i++) { - pressures[i] = minPressure + i * step; - pressureLOG[i] = pressures[i] * 1e5; - } + dewPLOG[i] = dewP[i] * 1e5; + } + return dewP; + } + + /** + *

+ * calcBubT. + *

+ * + * @param pressures an array of {@link double} objects + * @return an array of {@link double} objects + */ + public double[] calcBubT(double[] pressures) { + double[] bubTemps = new double[pressures.length]; + for (int i = 0; i < pressures.length; i++) { + thermoSystem.setPressure(pressures[i]); + try { + thermoOps.bubblePointTemperatureFlash(); + bubT[i] = thermoSystem.getPressure(); + } catch (Exception e) { + logger.error("error", e); + bubT[i] = 0.0; + } + } + return bubTemps; + } + + /** + *

+ * initCalc. + *

+ */ + public void initCalc() { + double stdTemp = 288.15; + double stdPres = 1.01325; + // double GOR, GLR; + double[] molfracs = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; + double[] MW = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; + double[] dens = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; + String[] components = new String[thermoSystem.getPhase(0).getNumberOfComponents()]; + + for (int i = 0; i < molfracs.length; i++) { + molfracs[i] = thermoSystem.getPhase(0).getComponent(i).getz(); + components[i] = thermoSystem.getPhase(0).getComponent(i).getComponentName(); + MW[i] = thermoSystem.getPhase(0).getComponent(i).getMolarMass() * 1000; + dens[i] = thermoSystem.getPhase(0).getComponent(i).getNormalLiquidDensity(); } - /** - *

- * setTemperatureRange. - *

- * - * @param minTemperature a double - * @param maxTemperature a double - * @param numberOfSteps a int - */ - public void setTemperatureRange(double minTemperature, double maxTemperature, - int numberOfSteps) { - temperatures = new double[numberOfSteps]; - temperatureLOG = new double[numberOfSteps]; - double step = (maxTemperature - minTemperature) / (numberOfSteps * 1.0 - 1.0); - for (int i = 0; i < numberOfSteps; i++) { - temperatures[i] = minTemperature + i * step; - temperatureLOG[i] = temperatures[i] - 273.15; - } + thermoSystem.setTemperature(stdTemp); + thermoSystem.setPressure(stdPres); + + thermoOps.TPflash(); + + // GOR = thermoSystem.getPhase(0).getTotalVolume() / + // thermoSystem.getPhase(1).getTotalVolume(); + // GLR = thermoSystem.getPhase(0).getTotalVolume() / + // thermoSystem.getPhase(1).getTotalVolume(); + } + + /** + *

+ * calcRSWTOB. + *

+ */ + public void calcRSWTOB() { + thermoSystem.init(0); + thermoSystem.init(1); + if (thermoSystem.getPhase(0).hasComponent("water")) { + RSWTOB = thermoSystem.getPhase(0).getComponent("water").getNumberOfmoles() + * thermoSystem.getPhase(0).getComponent("water").getMolarMass() + / (thermoSystem.getTotalNumberOfMoles() * thermoSystem.getMolarMass()); + } else { + RSWTOB = 0.0; + } + } + + /** {@inheritDoc} */ + @Override + public void run() { + calcRSWTOB(); + logger.info("RSWTOB " + RSWTOB); + nProps = 29; + props = new double[nProps][pressures.length][temperatures.length]; + units = new String[nProps]; + names = new String[nProps]; + GLW = 0; + GL = 0; + GW = 0; + VLS = 0; + LWS = 0; + VWS = 0; + maxPressure = pressures[pressures.length - 1]; + minPressure = pressures[0]; + maxTemperature = temperatures[temperatures.length - 1]; + minTemperature = temperatures[0]; + thermoSystem.setTemperature(minTemperature); + thermoSystem.setPressure(maxPressure); + thermoOps.TPflash(); + if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("aqueous") + && thermoSystem.hasPhaseType("oil")) { + GLW = 1; + } + if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("aqueous")) { + GW = 1; + } + if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("oil")) { + GL = 1; } - /** - *

- * calcPhaseEnvelope. - *

- */ - public void calcPhaseEnvelope() { + // int startGasTemperatures = 0, startLiquid = 0, startWater = 0; + boolean acceptedFlash = true; + for (int j = 0; j < temperatures.length; j++) { + thermoSystem.setTemperature(temperatures[j]); + for (int i = 0; i < pressures.length; i++) { + thermoSystem.setPressure(pressures[i]); try { - thermoOps.calcPTphaseEnvelope(); - TC = thermoSystem.getTC() - 273.15; - PC = thermoSystem.getPC() * 1e5; + // logger.info("TPflash... " + thermoSystem.getTemperature() + " pressure " + + // thermoSystem.getPressure()); + thermoOps.TPflash(); + thermoSystem.init(3); + thermoSystem.initPhysicalProperties(); + acceptedFlash = true; } catch (Exception e) { - logger.error("error", e); + acceptedFlash = false; + logger.info("fail temperature " + thermoSystem.getTemperature() + " fail pressure " + + thermoSystem.getPressure()); + + thermoSystem.display(); + logger.error("error", e); } - } - /** - *

- * calcBubP. - *

- * - * @param temperatures an array of {@link double} objects - * @return an array of {@link double} objects - */ - public double[] calcBubP(double[] temperatures) { - double[] bubP = new double[temperatures.length]; - bubPLOG = new double[temperatures.length]; - for (int i = 0; i < temperatures.length; i++) { - thermoSystem.setTemperature(temperatures[i]); - try { - thermoOps.bubblePointPressureFlash(false); - bubP[i] = thermoSystem.getPressure(); - } catch (Exception e) { - logger.error("error", e); - bubP[i] = 0; - return bubP; + /* + * logger.info("water density " + + * thermoSystem.getPhase(2).getPhysicalProperties().getDensity()); logger.info("RSW " + + * thermoSystem.getPhase(0).getComponent("water").getx() * + * thermoSystem.getPhase(0).getComponent("water").getMolarMass() / + * thermoSystem.getPhase(0).getMolarMass()); logger.info("surf tens oil-water " + + * thermoSystem.getInterphaseProperties().getSurfaceTension(1, 2)); + * logger.info("surf tens gas-water " + + * thermoSystem.getInterphaseProperties().getSurfaceTension(0, 2)); + */ + int k = 0; + if (thermoSystem.hasPhaseType("gas") && acceptedFlash) { + int phaseNumb = thermoSystem.getPhaseNumberOfPhase("gas"); + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); + names[k] = "GAS DENSITY"; + units[k] = "KG/M3"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; + names[k] = "DRHOG/DP"; + units[k] = "S2/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); + names[k] = "DRHOG/DT"; + units[k] = "KG/M3-K"; + k++; + + if (thermoSystem.hasPhaseType("oil")) { + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getBeta() + * thermoSystem.getPhase(phaseNumb).getMolarMass() + / (thermoSystem.getPhase(phaseNumb).getBeta() + * thermoSystem.getPhase(phaseNumb).getMolarMass() + + thermoSystem.getPhase("oil").getBeta() + * thermoSystem.getPhase("oil").getMolarMass()); + } else { + props[k][i][j] = 1.0; // thermoSystem.getPhase(phaseNumb).getBeta() * + // thermoSystem.getPhase(phaseNumb).getMolarMass() / + // thermoSystem.getMolarMass(); + } + names[k] = "GAS MASS FRACTION"; + units[k] = "-"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); + names[k] = "GAS VISCOSITY"; + units[k] = "NS/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "GAS HEAT CAPACITY"; + units[k] = "J/KG-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEnthalpy() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "GAS ENTHALPY"; + units[k] = "J/KG"; + k++; + + props[k][i][j] = + thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getConductivity(); + names[k] = "GAS THERMAL CONDUCTIVITY"; + units[k] = "W/M-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "GAS ENTROPY"; + units[k] = "J/KG/K"; + k++; + hasGasValues = true; + // set gas properties + } else if (continuousDerivativesExtrapolation && hasGasValues) { + do { + /* + * if (j>1 && i>1) { props[k][i][j] = 0.5 * ((props[k][i][j - 1] + (props[k][i][j - 1] - + * props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * (temperatures[j] + * - temperatures[j - 1])) + (props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - + * 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]))); + * if (names[k].equals("GAS MASS FRACTION") && props[k][i][j] < 0) { props[k][i][j] = 0; + * } } + */ + + /* + * if (j > 1) { props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - + * props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * (temperatures[j] + * - temperatures[j - 1]); } + */ + if (i > 1) { + props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) + / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + // } //else if (j < 2) { + // props[k][i][j] = 0; //props[k][i - 1][j] + (props[k][i - 1][j] - + // props[k][i - + // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - + // pressures[i + // - 1]); + // } else { + // props[k][i][j] = 0; //props[k][i - 1][j - 1] + (props[k][i][j - 1] - + // props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * + // (temperatures[j] - temperatures[j - 1]) + (props[k][i - 1][j] - + // props[k][i - + // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - + // pressures[i + // - 1]); + // double newTemp = pressures[i]; + // double vall = xcoef[k].get(0, 0) + newTemp * (xcoef[k].get(1, 0) + + // newTemp * + // (xcoef[k].get(2, 0) + newTemp * xcoef[k].get(3, 0))); + // props[k][i][j] = vall; + // if(i>0 && props[k][i-1][j]>1e-10) props[k][i][j] = + // props[k][i-1][j]*pressures[i]/pressures[i-1]; + + if (names[k].equals("GAS MASS FRACTION") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("GAS DENSITY") && props[k][i][j] < 0) { + props[k][i][j] = 0.1; + } + if (names[k].equals("GAS VISCOSITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("GAS THERMAL CONDUCTIVITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + } + if (j > 1) { + props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) + / (temperatures[j - 1] - temperatures[j - 2]) + * (temperatures[j] - temperatures[j - 1]); + if (names[k].equals("GAS MASS FRACTION") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("GAS MASS FRACTION") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("GAS DENSITY") && props[k][i][j] <= 0) { + props[k][i][j] = 0.1; + } + if (names[k].equals("GAS VISCOSITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("GAS THERMAL CONDUCTIVITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("GAS HEAT CAPACITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } } - bubPLOG[i] = bubP[i] * 1e5; + k++; + } while (k < 9); // names[k] = "GAS DENSITY"; + // units[k] = "KG/M3"; + /* + * } else if (false && !hasGasValues) { startGasTemperatures = j; + */ + } else { + gasSystem.setTemperature(temperatures[j]); + gasSystem.setPressure(pressures[i]); + gasSystem.init(3); + gasSystem.initPhysicalProperties(); + // gasSystem.display(); + props[k][i][j] = gasSystem.getPhase(0).getPhysicalProperties().getDensity(); + names[k] = "GAS DENSITY"; + units[k] = "KG/M3"; + k++; + props[k][i][j] = gasSystem.getPhase(0).getdrhodP() / 1.0e5; + names[k] = "DRHOG/DP"; + units[k] = "S2/M2"; + k++; + props[k][i][j] = gasSystem.getPhase(0).getdrhodT(); + names[k] = "DRHOG/DT"; + units[k] = "KG/M3-K"; + k++; + + props[k][i][j] = 0.0; // thermoSystem.getPhase(phaseNumb).getBeta() * + // thermoSystem.getPhase(phaseNumb).getMolarMass() / + // thermoSystem.getMolarMass(); + names[k] = "GAS MASS FRACTION"; + units[k] = "-"; + k++; + + props[k][i][j] = gasSystem.getPhase(0).getPhysicalProperties().getViscosity(); + names[k] = "GAS VISCOSITY"; + units[k] = "NS/M2"; + k++; + + props[k][i][j] = + gasSystem.getPhase(0).getCp() / gasSystem.getPhase(0).getNumberOfMolesInPhase() + / gasSystem.getPhase(0).getMolarMass(); + names[k] = "GAS HEAT CAPACITY"; + units[k] = "J/KG-K"; + k++; + + props[k][i][j] = + gasSystem.getPhase(0).getEnthalpy() / gasSystem.getPhase(0).getNumberOfMolesInPhase() + / gasSystem.getPhase(0).getMolarMass(); + names[k] = "GAS ENTHALPY"; + units[k] = "J/KG"; + k++; + + props[k][i][j] = gasSystem.getPhase(0).getPhysicalProperties().getConductivity(); + names[k] = "GAS THERMAL CONDUCTIVITY"; + units[k] = "W/M-K"; + k++; + + props[k][i][j] = + gasSystem.getPhase(0).getEntropy() / gasSystem.getPhase(0).getNumberOfMolesInPhase() + / gasSystem.getPhase(0).getMolarMass(); + names[k] = "GAS ENTROPY"; + units[k] = "J/KG/K"; + k++; } - return bubP; - } - /** - *

- * calcDewP. - *

- * - * @param temperatures an array of {@link double} objects - * @return an array of {@link double} objects - */ - public double[] calcDewP(double[] temperatures) { - double[] dewP = new double[temperatures.length]; - dewPLOG = new double[temperatures.length]; - for (int i = 0; i < temperatures.length; i++) { - thermoSystem.setTemperature(temperatures[i]); - try { - thermoOps.dewPointPressureFlashHC(); - dewP[i] = thermoSystem.getPressure(); - } catch (Exception e) { - logger.error("error", e); - dewP[i] = 0; - return dewP; + if (thermoSystem.hasPhaseType("oil") && acceptedFlash) { + int phaseNumb = thermoSystem.getPhaseNumberOfPhase("oil"); + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); + names[k] = "LIQUID DENSITY"; + units[k] = "KG/M3"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; + names[k] = "DRHOL/DP"; + units[k] = "S2/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); + names[k] = "DRHOL/DT"; + units[k] = "KG/M3-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); + names[k] = "LIQUID VISCOSITY"; + units[k] = "NS/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "LIQUID HEAT CAPACITY"; + units[k] = "J/KG-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEnthalpy() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "LIQUID ENTHALPY"; + units[k] = "J/KG"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "LIQUID ENTROPY"; + units[k] = "J/KG/K"; + k++; + + props[k][i][j] = + thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getConductivity(); + names[k] = "LIQUID THERMAL CONDUCTIVITY"; + units[k] = "W/M-K"; + k++; + hasOilValues = true; + } else if (continuousDerivativesExtrapolation && hasOilValues) { + do { + // if (i>1) { + // props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - + // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - + // pressures[i + // - 1]); + // } + // if (j>1 && i>1) { + // props[k][i][j] = 0.5 * ((props[k][i - 1][j] + (props[k][i - 1][j] - + // props[k][i - 2][j]) / (temperatures[i - 1] - temperatures[i - 2]) * + // (temperatures[i] - temperatures[i - 1])) + (props[k][i - 1][j] + + // (props[k][i + // - 1][j] - props[k][i - 2][j]) / (pressures[i - 1] - pressures[i - 2]) * + // (pressures[i] - pressures[i - 1]))); + // } + /* + * if (j > 2) { props[k][i][j] = 0.5*((props[k][i][j - 1] + (props[k][i][j - 1] - + * props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * (temperatures[j] + * - temperatures[j - 1])) +(props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - + * 3]) / (temperatures[j - 1] - temperatures[j - 3]) * (temperatures[j] - temperatures[j + * - 1]))); } + */ + if (j < 2 && i < 2) { + if (names[k].equals("LIQUID DENSITY") && props[k][i][j] <= 0) { + props[k][i][j] = 100; + } + if (names[k].equals("LIQUID DENSITY") && props[k][i][j] > 900) { + props[k][i][j] = 900; + } + if (names[k].equals("LIQUID VISCOSITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("LIQUID THERMAL CONDUCTIVITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("LIQUID HEAT CAPACITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + } + if (j > 1) { + props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) + / (temperatures[j - 1] - temperatures[j - 2]) + * (temperatures[j] - temperatures[j - 1]); + if (names[k].equals("LIQUID DENSITY") && props[k][i][j] <= 0) { + props[k][i][j] = 100; + } + if (names[k].equals("LIQUID DENSITY") && props[k][i][j] > 900) { + props[k][i][j] = 900; + } + if (names[k].equals("LIQUID VISCOSITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("LIQUID THERMAL CONDUCTIVITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("LIQUID HEAT CAPACITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + } + if (i > 1) { + props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) + / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + if (names[k].equals("LIQUID DENSITY") && props[k][i][j] <= 0) { + props[k][i][j] = 100; + } + if (names[k].equals("LIQUID DENSITY") && props[k][i][j] > 900) { + props[k][i][j] = 900; + } + if (names[k].equals("LIQUID VISCOSITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("LIQUID THERMAL CONDUCTIVITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("LIQUID HEAT CAPACITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + } + + // if (j > 1 && TLC==3) { + // props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j + // - + // 2]) / (temperatures[j - 1] - temperatures[j - 2]) * (temperatures[j] - + // temperatures[j - 1]); + // if (j>1) { + // props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j + // - + // 2]) / (temperatures[j - 1] - temperatures[j - 2]) * (temperatures[j] - + // temperatures[j - 1]); + // } else if (j < 2) { + // props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - + // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - + // pressures[i + // - 1]); + // } else { + // props[k][i][j] = props[k][i - 1][j - 1] + (props[k][i][j - 1] - + // props[k][i][j + // - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * (temperatures[j] - + // temperatures[j - 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / + // (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - + // 1]); + // } + // props[k][i][j] = 0.0;*/ + // } + k++; + } while (k < 17); // names[k] = "GAS DENSITY"; + // units[k] = "KG/M3"; + } else { + oilSystem.setPhaseType(0, 0); + oilSystem.setTemperature(temperatures[j]); + oilSystem.setPressure(pressures[i]); + oilSystem.init(3); + oilSystem.initPhysicalProperties(); + + props[k][i][j] = oilSystem.getPhase(0).getPhysicalProperties().getDensity(); + names[k] = "LIQUID DENSITY"; + units[k] = "KG/M3"; + k++; + + props[k][i][j] = oilSystem.getPhase(0).getdrhodP() / 1.0e5; + names[k] = "DRHOL/DP"; + units[k] = "S2/M2"; + k++; + + props[k][i][j] = oilSystem.getPhase(0).getdrhodT(); + names[k] = "DRHOL/DT"; + units[k] = "KG/M3-K"; + k++; + + props[k][i][j] = oilSystem.getPhase(0).getPhysicalProperties().getViscosity(); + names[k] = "LIQUID VISCOSITY"; + units[k] = "NS/M2"; + k++; + + props[k][i][j] = + oilSystem.getPhase(0).getCp() / oilSystem.getPhase(0).getNumberOfMolesInPhase() + / oilSystem.getPhase(0).getMolarMass(); + names[k] = "LIQUID HEAT CAPACITY"; + units[k] = "J/KG-K"; + k++; + + props[k][i][j] = + oilSystem.getPhase(0).getEnthalpy() / oilSystem.getPhase(0).getNumberOfMolesInPhase() + / oilSystem.getPhase(0).getMolarMass(); + names[k] = "LIQUID ENTHALPY"; + units[k] = "J/KG"; + k++; + + props[k][i][j] = + oilSystem.getPhase(0).getEntropy() / oilSystem.getPhase(0).getNumberOfMolesInPhase() + / oilSystem.getPhase(0).getMolarMass(); + names[k] = "LIQUID ENTROPY"; + units[k] = "J/KG/K"; + k++; + + props[k][i][j] = oilSystem.getPhase(0).getPhysicalProperties().getConductivity(); + names[k] = "LIQUID THERMAL CONDUCTIVITY"; + units[k] = "W/M-K"; + k++; + } // setOilProperties(); + // set gas properties + + if (thermoSystem.hasPhaseType("aqueous") && acceptedFlash) { + int phaseNumb = thermoSystem.getPhaseNumberOfPhase("aqueous"); + if (thermoSystem.hasPhaseType("gas")) { + props[k][i][j] = thermoSystem.getPhase("gas").getComponent("water").getx() + * thermoSystem.getPhase("gas").getComponent("water").getMolarMass() + / thermoSystem.getPhase("gas").getMolarMass(); + } + if (thermoSystem.hasPhaseType("oil")) { + props[k][i][j] += thermoSystem.getPhase("oil").getComponent("water").getx() + * thermoSystem.getPhase("oil").getComponent("water").getMolarMass() + / thermoSystem.getPhase("oil").getMolarMass(); + } + names[k] = "WATER VAPOR MASS FRACTION"; + units[k] = "-"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); + names[k] = "WATER DENSITY"; + units[k] = "KG/M3"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; + names[k] = "DRHOWAT/DP"; + units[k] = "S2/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); + names[k] = "DRHOWAT/DT"; + units[k] = "KG/M3-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); + names[k] = "WATER VISCOSITY"; + units[k] = "NS/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "WATER HEAT CAPACITY"; + units[k] = "J/KG-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEnthalpy() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "WATER ENTHALPY"; + units[k] = "J/KG"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "WATER ENTROPY"; + units[k] = "J/KG/K"; + k++; + + props[k][i][j] = + thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getConductivity(); + names[k] = "WATER THERMAL CONDUCTIVITY"; + units[k] = "W/M-K"; + k++; + hasWaterValues = true; + } else if (continuousDerivativesExtrapolation && hasWaterValues) { + do { + /* + * if (j > 2) { props[k][i][j] = 0.5*((props[k][i][j - 1] + (props[k][i][j - 1] - + * props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * (temperatures[j] + * - temperatures[j - 1])) +(props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - + * 3]) / (temperatures[j - 1] - temperatures[j - 3]) * (temperatures[j] - temperatures[j + * - 1]))); if (names[k].equals("WATER VAPOR MASS FRACTION") && props[k][i][j] > 1) { + * props[k][i][j] = 1; } } + */ + if (j > 1) { + props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) + / (temperatures[j - 1] - temperatures[j - 2]) + * (temperatures[j] - temperatures[j - 1]); + if (names[k].equals("WATER VAPOR MASS FRACTION") && props[k][i][j] > 1) { + props[k][i][j] = 1; + } + if (names[k].equals("WATER DENSITY") && props[k][i][j] <= 0) { + props[k][i][j] = 1000; + } + if (names[k].equals("WATER VISCOSITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("WATER THERMAL CONDUCTIVITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("WATER VAPOR MASS FRACTION") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("WATER HEAT CAPACITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + } + /* + * if (j > 1 && TLC == 3) { props[k][i][j] = props[k][i][j-1] + (props[k][i][j-1] - + * props[k][i][j-2]) / (temperatures[j - 1] - temperatures[j - 2]) * (temperatures[j] - + * temperatures[j - 1]); if (j>1) { props[k][i][j] = props[k][i][j-1] + + * (props[k][i][j-1] - props[k][i][j-2]) / (temperatures[j - 1] - temperatures[j - 2]) * + * (temperatures[j] - temperatures[j - 1]); if + * (names[k].equals("WATER VAPOR MASS FRACTION") && props[k][i][j] > 1) { props[k][i][j] + * = 1; } } + */ + if (i > 1) { + props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) + / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + if (names[k].equals("WATER VAPOR MASS FRACTION") && props[k][i][j] > 1) { + props[k][i][j] = 1; + } + + if (names[k].equals("WATER DENSITY") && props[k][i][j] <= 0) { + props[k][i][j] = 1000; + } + if (names[k].equals("WATER VISCOSITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("WATER THERMAL CONDUCTIVITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("WATER VAPOR MASS FRACTION") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("WATER HEAT CAPACITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } } - dewPLOG[i] = dewP[i] * 1e5; + /* + * if (i < 2) { props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - + * props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * (temperatures[j] + * - temperatures[j - 1]); } else if (j < 2) { props[k][i][j] = props[k][i - 1][j] + + * (props[k][i - 1][j] - props[k][i - 2][j]) / (pressures[i - 1] - pressures[i - 2]) * + * (pressures[i] - pressures[i - 1]); } else { props[k][i][j] = props[k][i - 1][j - 1] + + * (props[k][i][j - 1] - props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - + * 2]) * (temperatures[j] - temperatures[j - 1]) + (props[k][i - 1][j] - props[k][i - + * 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); } + * props[k][i][j] = 0.0; + */ + k++; + } while (k < 26); // names[k] = "GAS DENSITY"; + // units[k] = "KG/M3"; + } else { + waterSystem.setTemperature(temperatures[j]); + waterSystem.setPressure(pressures[i]); + waterSystem.setPhaseType(0, 0); + waterSystem.init(3); + waterSystem.initPhysicalProperties(); + + if (thermoSystem.getPhase(0).hasComponent("water")) { + props[k][i][j] = thermoSystem.getPhase(0).getComponent("water").getz() + * thermoSystem.getPhase(0).getComponent("water").getMolarMass() + / thermoSystem.getPhase(0).getMolarMass();; + } else { + props[k][i][j] = 0.0; + } + names[k] = "WATER VAPOR MASS FRACTION"; + units[k] = "-"; + k++; + + props[k][i][j] = waterSystem.getPhase(0).getPhysicalProperties().getDensity(); + names[k] = "WATER DENSITY"; + units[k] = "KG/M3"; + k++; + + props[k][i][j] = waterSystem.getPhase(0).getdrhodP() / 1.0e5; + names[k] = "DRHOWAT/DP"; + units[k] = "S2/M2"; + k++; + + props[k][i][j] = waterSystem.getPhase(0).getdrhodT(); + names[k] = "DRHOWAT/DT"; + units[k] = "KG/M3-K"; + k++; + + props[k][i][j] = waterSystem.getPhase(0).getPhysicalProperties().getViscosity(); + names[k] = "WATER VISCOSITY"; + units[k] = "NS/M2"; + k++; + + props[k][i][j] = + waterSystem.getPhase(0).getCp() / waterSystem.getPhase(0).getNumberOfMolesInPhase() + / waterSystem.getPhase(0).getMolarMass(); + names[k] = "WATER HEAT CAPACITY"; + units[k] = "J/KG-K"; + k++; + + props[k][i][j] = waterSystem.getPhase(0).getEnthalpy() + / waterSystem.getPhase(0).getNumberOfMolesInPhase() + / waterSystem.getPhase(0).getMolarMass(); + names[k] = "WATER ENTHALPY"; + units[k] = "J/KG"; + k++; + + props[k][i][j] = waterSystem.getPhase(0).getEntropy() + / waterSystem.getPhase(0).getNumberOfMolesInPhase() + / waterSystem.getPhase(0).getMolarMass(); + names[k] = "WATER ENTROPY"; + units[k] = "J/KG/K"; + k++; + + props[k][i][j] = waterSystem.getPhase(0).getPhysicalProperties().getConductivity(); + names[k] = "WATER THERMAL CONDUCTIVITY"; + units[k] = "W/M-K"; + k++; } - return dewP; - } - /** - *

- * calcBubT. - *

- * - * @param pressures an array of {@link double} objects - * @return an array of {@link double} objects - */ - public double[] calcBubT(double[] pressures) { - double[] bubTemps = new double[pressures.length]; - for (int i = 0; i < pressures.length; i++) { - thermoSystem.setPressure(pressures[i]); - try { - thermoOps.bubblePointTemperatureFlash(); - bubT[i] = thermoSystem.getPressure(); - } catch (Exception e) { - logger.error("error", e); - bubT[i] = 0.0; + if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("oil") && acceptedFlash) { + props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( + thermoSystem.getPhaseNumberOfPhase("gas"), thermoSystem.getPhaseNumberOfPhase("oil")); + names[k] = "VAPOR-LIQUID SURFACE TENSION"; + units[k] = "N/M"; + k++; + } else { + if (continuousDerivativesExtrapolation && (i >= 2 || j >= 2)) { + if (VLS == 1) { + props[k][i][j] = 5.0e-3; + // k++; + } + // if (j>1 && thermoSystem.hasPhaseType("gas") && VLS==0 && acceptedFlash) { + if (j > 1 && (GLW == 1 || GL == 1) && VLS == 0) { + props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) + / (temperatures[j - 1] - temperatures[j - 2]) + * (temperatures[j] - temperatures[j - 1]); + /* + * if (names[k].equals("VAPOR-LIQUID SURFACE TENSION") && props[k][i][j] < 5.0e-3) { + * props[k][i][j] = 7.5e-3; VLS=1; } if + * (names[k].equals("VAPOR-LIQUID SURFACE TENSION") && props[k][i][j] > 30.0e-3) { + * props[k][i][j] = 20.0e-3; VLS=1; } + */ + if (props[k][i][j] < 5.0e-3) { + props[k][i][j] = 5.0e-3; + VLS = 1; + } + if (props[k][i][j] > 1.1 * props[k][i][j - 1]) { + props[k][i][j] = props[k][i][j - 1]; + } + if (props[k][i][j] < 0.9 * props[k][i][j - 1]) { + props[k][i][j] = props[k][i][j - 1]; + } + // } else if (i>1 && thermoSystem.hasPhaseType("oil") && VLS == 0 && + // acceptedFlash) { + // } else if (i > 1 && TLC < 3 && VLS==0) { + } else if (i > 1 && (GLW == 0 || GL == 0) && VLS == 0) { + props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) + / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + if (props[k][i][j] < 5.0e-3) { + props[k][i][j] = 5.0e-3; + VLS = 1; + } + if (props[k][i][j] > 1.1 * props[k][i - 1][j]) { + props[k][i][j] = props[k][i - 1][j]; + } + if (props[k][i][j] < 0.9 * props[k][i - 1][j]) { + props[k][i][j] = props[k][i - 1][j]; + } + } else if (j > 0 && i > 0) { + props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); + } else if (j > 0) { + props[k][i][j] = props[k][i][j - 1]; + } else if (i > 0) { + props[k][i][j] = props[k][i - 1][j]; + } else { + // props[k][i][j] = props[k][i - 1][j - 1] + (props[k][i][j - 1] - + // props[k][i][j + // - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * + // (temperatures[j] - + // temperatures[j - 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / + // (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - + // 1]); + props[k][i][j] = 10.0e-3; } - } - return bubTemps; - } - /** - *

- * initCalc. - *

- */ - public void initCalc() { - double stdTemp = 288.15, stdPres = 1.01325; - // double GOR, GLR; - double molfracs[] = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; - double MW[] = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; - double dens[] = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; - String components[] = new String[thermoSystem.getPhase(0).getNumberOfComponents()]; - - for (int i = 0; i < molfracs.length; i++) { - molfracs[i] = thermoSystem.getPhase(0).getComponent(i).getz(); - components[i] = thermoSystem.getPhase(0).getComponent(i).getComponentName(); - MW[i] = thermoSystem.getPhase(0).getComponent(i).getMolarMass() * 1000; - dens[i] = thermoSystem.getPhase(0).getComponent(i).getNormalLiquidDensity(); + // k++; + } else if (j > 0 && i > 0) { + props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); + // k++; + } else if (j > 0) { + props[k][i][j] = props[k][i][j - 1]; + // k++; + } else if (i > 0) { + props[k][i][j] = props[k][i - 1][j]; + // k++; + } else { + props[k][i][j] = 10.0e-3; + names[k] = "VAPOR-LIQUID SURFACE TENSION"; + units[k] = "N/M"; + // k++; + } + k++; } - thermoSystem.setTemperature(stdTemp); - thermoSystem.setPressure(stdPres); - - thermoOps.TPflash(); + if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("aqueous") + && acceptedFlash) { + props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( + thermoSystem.getPhaseNumberOfPhase("gas"), + thermoSystem.getPhaseNumberOfPhase("aqueous")); + names[k] = "VAPOR-WATER SURFACE TENSION"; + units[k] = "N/M"; + k++; + } else { + if (continuousDerivativesExtrapolation && (i >= 2 || j >= 2)) { + if (VWS == 1) { + props[k][i][j] = 5.0e-3; + // k++; + } + // if (j>1 && thermoSystem.hasPhaseType("gas") && VWS == 0 && acceptedFlash) + // { + // if (j > 1 && TLC==3 && VWS==0) { + if (j > 1 && (GLW == 1 || GW == 1) && VWS == 0) { + props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) + / (temperatures[j - 1] - temperatures[j - 2]) + * (temperatures[j] - temperatures[j - 1]); + /* + * if (names[k].equals("VAPOR-WATER SURFACE TENSION") && props[k][i][j] < 10.0e-3) { + * props[k][i][j] = 35.0e-3; VWS=1; } if + * (names[k].equals("VAPOR-WATER SURFACE TENSION") && props[k][i][j] > 150.0e-3) { + * props[k][i][j] = 105.0e-3; VWS=1; } + */ + if (props[k][i][j] < 5.0e-3) { + props[k][i][j] = 5.0e-3; + VWS = 1; + } + if (props[k][i][j] > 1.1 * props[k][i][j - 1]) { + props[k][i][j] = props[k][i][j - 1]; + } + if (props[k][i][j] < 0.9 * props[k][i][j - 1]) { + props[k][i][j] = props[k][i][j - 1]; + } + // } else if (j>1 && thermoSystem.hasPhaseType("aqueous") && VWS ==0 && + // acceptedFlash) { + // } else if (i > 1 && TLC < 3 && VWS==0) { + } else if (i > 1 && (GLW == 0 || GL == 0) && VWS == 0) { + props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) + / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + /* + * if (names[k].equals("VAPOR-WATER SURFACE TENSION") && props[k][i][j] < 10.0e-3) { + * props[k][i][j] = 35.0e-3; VWS=1; } if + * (names[k].equals("VAPOR-WATER SURFACE TENSION") && props[k][i][j] > 150.0e-3) { + * props[k][i][j] = 105.0e-3; VWS=1; } + */ + if (props[k][i][j] < 5.0e-3) { + props[k][i][j] = 5.0e-3; + VWS = 1; + } + if (props[k][i][j] > 1.1 * props[k][i - 1][j]) { + props[k][i][j] = props[k][i - 1][j]; + } + if (props[k][i][j] < 0.9 * props[k][i - 1][j]) { + props[k][i][j] = props[k][i - 1][j]; + } + } else if (j > 0 && i > 0) { + props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); + } else if (j > 0) { + props[k][i][j] = props[k][i][j - 1]; + } else if (i > 0) { + props[k][i][j] = props[k][i - 1][j]; + } else { + // props[k][i][j] = props[k][i - 1][j - 1] + (props[k][i][j - 1] - + // props[k][i][j + // - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * + // (temperatures[j] - + // temperatures[j - 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / + // (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - + // 1]); + props[k][i][j] = 60.0e-3; + } - // GOR = thermoSystem.getPhase(0).getTotalVolume() / - // thermoSystem.getPhase(1).getTotalVolume(); - // GLR = thermoSystem.getPhase(0).getTotalVolume() / - // thermoSystem.getPhase(1).getTotalVolume(); - } + // k++; + } else if (j > 0 && i > 0) { + props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); + // k++; + } else if (j > 0) { + props[k][i][j] = props[k][i][j - 1]; + // k++; + } else if (i > 0) { + props[k][i][j] = props[k][i - 1][j]; + // k++; + } else { + props[k][i][j] = 60.0e-3; + names[k] = "VAPOR-WATER SURFACE TENSION"; + units[k] = "N/M"; + // k++; + } + k++; + } - /** - *

- * calcRSWTOB. - *

- */ - public void calcRSWTOB() { - thermoSystem.init(0); - thermoSystem.init(1); - if (thermoSystem.getPhase(0).hasComponent("water")) { - RSWTOB = thermoSystem.getPhase(0).getComponent("water").getNumberOfmoles() - * thermoSystem.getPhase(0).getComponent("water").getMolarMass() - / (thermoSystem.getTotalNumberOfMoles() * thermoSystem.getMolarMass()); + if (thermoSystem.hasPhaseType("oil") && thermoSystem.hasPhaseType("aqueous") + && acceptedFlash) { + props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( + thermoSystem.getPhaseNumberOfPhase("oil"), + thermoSystem.getPhaseNumberOfPhase("aqueous")); + names[k] = "LIQUID-WATER SURFACE TENSION"; + units[k] = "N/M"; + k++; } else { - RSWTOB = 0.0; + if (continuousDerivativesExtrapolation && (i >= 2 || j >= 2)) { + if (LWS == 1) { + props[k][i][j] = 5.0e-3; + // k++; + } + if (j > 1 && LWS == 0) { + // if (j > 1 && TLC==3 && LWS==0) { + // if (j>1 && LWS==0 && acceptedFlash) { + props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) + / (temperatures[j - 1] - temperatures[j - 2]) + * (temperatures[j] - temperatures[j - 1]); + /* + * if (j > 2) { props[k][i][j] = 0.5*((props[k][i][j - 1] + (props[k][i][j - 1] - + * props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * + * (temperatures[j] - temperatures[j - 1])) +(props[k][i][j - 1] + (props[k][i][j - 1] + * - props[k][i][j - 3]) / (temperatures[j - 1] - temperatures[j - 3]) * + * (temperatures[j] - temperatures[j - 1]))); if + * (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] < 10.0e-3) { + * props[k][i][j] = 25.0e-3; LWS=1; } + * + * if (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] > 120.0e-3) { + * props[k][i][j] = 80.0e-3; LWS=1; } } + */ + + /* + * if (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] < 10.0e-3) { + * props[k][i][j] = 25.0e-3; LWS=1; } if + * (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] > 120.0e-3) { + * props[k][i][j] = 80.0e-3; LWS=1; } + */ + if (props[k][i][j] < 5.0e-3) { + props[k][i][j] = 5.0e-3; + LWS = 1; + } + if (props[k][i][j] > 1.1 * props[k][i][j - 1]) { + props[k][i][j] = props[k][i][j - 1]; + } + if (props[k][i][j] < 0.9 * props[k][i][j - 1]) { + props[k][i][j] = props[k][i][j - 1]; + } + // } else if (i > 1 && LWS==0 && acceptedFlash) { + // } else if (i > 1 && TLC < 3 && LWS==0) { + // props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - + // props[k][i - + // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - + // pressures[i + // - 1]); + /* + * if (i > 2) { props[k][i][j] = 0.5*((props[k][i - 1][j] + (props[k][i - 1][j] - + * props[k][i - 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - + * pressures[i - 1])) +(props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 3][j]) + * / (pressures[i - 1] - pressures[i - 3]) * (pressures[i] - pressures[i - 1]))); if + * (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] < 10.0e-3) { + * props[k][i][j] = 25.0e-3; LWS=1; } + * + * if (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] > 120.0e-3) { + * props[k][i][j] = 80.0e-3; LWS=1; } } + */ + + /* + * if (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] < 10.0e-3) { + * props[k][i][j] = 25.0e-3; LWS=1; } if + * (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] > 120.0e-3) { + * props[k][i][j] = 80.0e-3; LWS=1; } + */ + + /* + * if (props[k][i][j] < 5.0e-3) { props[k][i][j] = 5.0e-3; LWS = 1; } if + * (props[k][i][j] > 1.1* props[k][i - 1][j]) { props[k][i][j] = props[k][i - 1][j]; } + * if (props[k][i][j] < 0.9* props[k][i - 1][j]) { props[k][i][j] = props[k][i - + * 1][j]; } + */ + // } else if (j >0 && i > 0) { + // props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); + } else if (j > 0) { + props[k][i][j] = props[k][i][j - 1]; + } else if (i > 0) { + props[k][i][j] = props[k][i - 1][j]; + } else { + // props[k][i][j] = props[k][i - 1][j - 1] + (props[k][i][j - 1] - + // props[k][i][j + // - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * + // (temperatures[j] - + // temperatures[j - 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / + // (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - + // 1]); + props[k][i][j] = 40.0e-3; + } + + // k++; + // } else if (j >0 && i > 0) { + // props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); + // k++; + } else if (j > 0) { + props[k][i][j] = props[k][i][j - 1]; + // k++; + } else if (i > 0) { + props[k][i][j] = props[k][i - 1][j]; + // k++; + } else { + props[k][i][j] = 40.0e-3; + names[k] = "LIQUID-WATER SURFACE TENSION"; + units[k] = "N/M"; + // k++; + } + k++; } + } } - - /** {@inheritDoc} */ - @Override - public void run() { - calcRSWTOB(); - logger.info("RSWTOB " + RSWTOB); - nProps = 29; - props = new double[nProps][pressures.length][temperatures.length]; - units = new String[nProps]; - names = new String[nProps]; - GLW = 0; - GL = 0; - GW = 0; - VLS = 0; - LWS = 0; - VWS = 0; - maxPressure = pressures[pressures.length - 1]; - minPressure = pressures[0]; - maxTemperature = temperatures[temperatures.length - 1]; - minTemperature = temperatures[0]; - thermoSystem.setTemperature(minTemperature); - thermoSystem.setPressure(maxPressure); - thermoOps.TPflash(); - if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("aqueous") - && thermoSystem.hasPhaseType("oil")) { - GLW = 1; + logger.info("Finished TPflash..."); + if (thermoSystem.getPhase(0).hasComponent("water")) { + thermoSystem.removeComponent("water"); + } + bubP = calcBubP(temperatures); + dewP = calcDewP(temperatures); + // bubT = calcBubT(temperatures); + // logger.info("Finished creating arrays"); + // BicubicSplineInterpolatingFunction funcGasDens = + // interpolationFunc.interpolate(pressures, temperatures, props[0]); + // logger.info("interpolated value " + funcGasDens.value(40, 298.0)); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + // logger.info("TC " + TC + " PC " + PC); + // for (int i = 0; i < pressures.length; i++) { + // thermoSystem.setPressure(pressures[i]); + // for (int j = 0; j < temperatures.length; j++) { + // logger.info("pressure " + pressureLOG[i] + " temperature " + + // temperatureLOG[j]); // + " ROG " + ROG[i][j] + " ROL " + ROL[i][j]); + // } + // } + writeOLGAinpFile(fileName); + } + + /** + *

+ * writeOLGAinpFile2. + *

+ * + * @param filename a {@link java.lang.String} object + */ + public void writeOLGAinpFile2(String filename) { + /* + * try { writer = new BufferedWriter(new OutputStreamWriter( new + * FileOutputStream("C:/Users/Kjetil Raul/Documents/Master KRB/javacode_ROG55.txt" ), "utf-8")); + * writer.write("GAS DENSITY (KG/M3) = ("); for (int i = 0; i < pressures.length; i++) { + * thermoSystem.setPressure(pressures[i]); for (int j = 0; j < temperatures.length; j++) { + * thermoSystem.setTemperature(temperatures[j]); writer.write(ROG[i][j] + ","); } } + * writer.write(")"); } catch (IOException ex) { // report } finally { try { } writer.close(); } + * catch (Exception ex) { } } + */ + try (Writer writer = + new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName), "utf-8"))) { + writer.write("'WATER-OPTION ENTROPY NONEQ '" + "\n"); + + writer.write(pressures.length + " " + temperatures.length + " " + RSWTOB + "\n"); + int Pcounter = 0; + for (int i = 0; i < pressures.length; i++) { + if (Pcounter > 4) { + writer.write("\n"); + Pcounter = 0; } - if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("aqueous")) { - GW = 1; + writer.write(pressureLOG[i] + " "); + Pcounter++; + } + writer.write("\n"); + + int Tcounter = 0; + for (int i = 0; i < temperatures.length; i++) { + if (Tcounter > 4) { + writer.write("\n"); + Tcounter = 0; } - if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("oil")) { - GL = 1; + writer.write(temperatureLOG[i] + " "); + Tcounter++; + } + writer.write("\n"); + + int bubPcounter = 0; + for (int i = 0; i < temperatures.length; i++) { + if (bubPcounter > 4) { + writer.write("\n"); + bubPcounter = 0; } - - // int startGasTemperatures = 0, startLiquid = 0, startWater = 0; - boolean acceptedFlash = true; - for (int j = 0; j < temperatures.length; j++) { - thermoSystem.setTemperature(temperatures[j]); - for (int i = 0; i < pressures.length; i++) { - thermoSystem.setPressure(pressures[i]); - try { - // logger.info("TPflash... " + thermoSystem.getTemperature() + " pressure " + - // thermoSystem.getPressure()); - thermoOps.TPflash(); - thermoSystem.init(3); - thermoSystem.initPhysicalProperties(); - acceptedFlash = true; - } catch (Exception e) { - acceptedFlash = false; - logger.info("fail temperature " + thermoSystem.getTemperature() - + " fail pressure " + thermoSystem.getPressure()); - - thermoSystem.display(); - logger.error("error", e); - } - - /* - * logger.info("water density " + - * thermoSystem.getPhase(2).getPhysicalProperties().getDensity()); - * logger.info("RSW " + thermoSystem.getPhase(0).getComponent("water").getx() * - * thermoSystem.getPhase(0).getComponent("water").getMolarMass() / - * thermoSystem.getPhase(0).getMolarMass()); logger.info("surf tens oil-water " + - * thermoSystem.getInterphaseProperties().getSurfaceTension(1, 2)); - * logger.info("surf tens gas-water " + - * thermoSystem.getInterphaseProperties().getSurfaceTension(0, 2)); - */ - int k = 0; - if (thermoSystem.hasPhaseType("gas") && acceptedFlash) { - int phaseNumb = thermoSystem.getPhaseNumberOfPhase("gas"); - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); - names[k] = "GAS DENSITY"; - units[k] = "KG/M3"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; - names[k] = "DRHOG/DP"; - units[k] = "S2/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); - names[k] = "DRHOG/DT"; - units[k] = "KG/M3-K"; - k++; - - if (thermoSystem.hasPhaseType("oil")) { - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getBeta() - * thermoSystem.getPhase(phaseNumb).getMolarMass() - / (thermoSystem.getPhase(phaseNumb).getBeta() - * thermoSystem.getPhase(phaseNumb).getMolarMass() - + thermoSystem.getPhase("oil").getBeta() - * thermoSystem.getPhase("oil").getMolarMass()); - } else { - props[k][i][j] = 1.0;// thermoSystem.getPhase(phaseNumb).getBeta() * - // thermoSystem.getPhase(phaseNumb).getMolarMass() / - // thermoSystem.getMolarMass(); - } - names[k] = "GAS MASS FRACTION"; - units[k] = "-"; - k++; - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); - names[k] = "GAS VISCOSITY"; - units[k] = "NS/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "GAS HEAT CAPACITY"; - units[k] = "J/KG-K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEnthalpy() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "GAS ENTHALPY"; - units[k] = "J/KG"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties() - .getConductivity(); - names[k] = "GAS THERMAL CONDUCTIVITY"; - units[k] = "W/M-K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "GAS ENTROPY"; - units[k] = "J/KG/K"; - k++; - hasGasValues = true; - // set gas properties - } else if (continuousDerivativesExtrapolation && hasGasValues) { - do { - /* - * if (j>1 && i>1) { props[k][i][j] = 0.5 * ((props[k][i][j - 1] + - * (props[k][i][j - 1] - props[k][i][j - 2]) / (temperatures[j - 1] - - * temperatures[j - 2]) * (temperatures[j] - temperatures[j - 1])) + - * (props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) / - * (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - - * 1]))); if (names[k].equals("GAS MASS FRACTION") && props[k][i][j] < 0) { - * props[k][i][j] = 0; } } - */ - - /* - * if (j > 1) { props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - - * props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * - * (temperatures[j] - temperatures[j - 1]); } - */ - if (i > 1) { - props[k][i][j] = - props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) - / (pressures[i - 1] - pressures[i - 2]) - * (pressures[i] - pressures[i - 1]); - // } //else if (j < 2) { - // props[k][i][j] = 0;//props[k][i - 1][j] + (props[k][i - 1][j] - - // props[k][i - - // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - - // pressures[i - // - 1]); - // } else { - // props[k][i][j] = 0;//props[k][i - 1][j - 1] + (props[k][i][j - 1] - - // props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * - // (temperatures[j] - temperatures[j - 1]) + (props[k][i - 1][j] - - // props[k][i - - // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - - // pressures[i - // - 1]); - // double newTemp = pressures[i]; - // double vall = xcoef[k].get(0, 0) + newTemp * (xcoef[k].get(1, 0) + - // newTemp * - // (xcoef[k].get(2, 0) + newTemp * xcoef[k].get(3, 0))); - // props[k][i][j] = vall; - // if(i>0 && props[k][i-1][j]>1e-10) props[k][i][j] = - // props[k][i-1][j]*pressures[i]/pressures[i-1]; - - if (names[k].equals("GAS MASS FRACTION") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("GAS DENSITY") && props[k][i][j] < 0) { - props[k][i][j] = 0.1; - } - if (names[k].equals("GAS VISCOSITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("GAS THERMAL CONDUCTIVITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - } - if (j > 1) { - props[k][i][j] = - props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) - / (temperatures[j - 1] - temperatures[j - 2]) - * (temperatures[j] - temperatures[j - 1]); - if (names[k].equals("GAS MASS FRACTION") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("GAS MASS FRACTION") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("GAS DENSITY") && props[k][i][j] <= 0) { - props[k][i][j] = 0.1; - } - if (names[k].equals("GAS VISCOSITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("GAS THERMAL CONDUCTIVITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("GAS HEAT CAPACITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - } - k++; - } while (k < 9);// names[k] = "GAS DENSITY"; - // units[k] = "KG/M3"; - /* - * } else if (false && !hasGasValues) { startGasTemperatures = j; - */ - } else { - gasSystem.setTemperature(temperatures[j]); - gasSystem.setPressure(pressures[i]); - gasSystem.init(3); - gasSystem.initPhysicalProperties(); - // gasSystem.display(); - props[k][i][j] = gasSystem.getPhase(0).getPhysicalProperties().getDensity(); - names[k] = "GAS DENSITY"; - units[k] = "KG/M3"; - k++; - props[k][i][j] = gasSystem.getPhase(0).getdrhodP() / 1.0e5; - names[k] = "DRHOG/DP"; - units[k] = "S2/M2"; - k++; - props[k][i][j] = gasSystem.getPhase(0).getdrhodT(); - names[k] = "DRHOG/DT"; - units[k] = "KG/M3-K"; - k++; - - props[k][i][j] = 0.0;// thermoSystem.getPhase(phaseNumb).getBeta() * - // thermoSystem.getPhase(phaseNumb).getMolarMass() / - // thermoSystem.getMolarMass(); - names[k] = "GAS MASS FRACTION"; - units[k] = "-"; - k++; - - props[k][i][j] = gasSystem.getPhase(0).getPhysicalProperties().getViscosity(); - names[k] = "GAS VISCOSITY"; - units[k] = "NS/M2"; - k++; - - props[k][i][j] = gasSystem.getPhase(0).getCp() - / gasSystem.getPhase(0).getNumberOfMolesInPhase() - / gasSystem.getPhase(0).getMolarMass(); - names[k] = "GAS HEAT CAPACITY"; - units[k] = "J/KG-K"; - k++; - - props[k][i][j] = gasSystem.getPhase(0).getEnthalpy() - / gasSystem.getPhase(0).getNumberOfMolesInPhase() - / gasSystem.getPhase(0).getMolarMass(); - names[k] = "GAS ENTHALPY"; - units[k] = "J/KG"; - k++; - - props[k][i][j] = - gasSystem.getPhase(0).getPhysicalProperties().getConductivity(); - names[k] = "GAS THERMAL CONDUCTIVITY"; - units[k] = "W/M-K"; - k++; - - props[k][i][j] = gasSystem.getPhase(0).getEntropy() - / gasSystem.getPhase(0).getNumberOfMolesInPhase() - / gasSystem.getPhase(0).getMolarMass(); - names[k] = "GAS ENTROPY"; - units[k] = "J/KG/K"; - k++; - } - - if (thermoSystem.hasPhaseType("oil") && acceptedFlash) { - int phaseNumb = thermoSystem.getPhaseNumberOfPhase("oil"); - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); - names[k] = "LIQUID DENSITY"; - units[k] = "KG/M3"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; - names[k] = "DRHOL/DP"; - units[k] = "S2/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); - names[k] = "DRHOL/DT"; - units[k] = "KG/M3-K"; - k++; - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); - names[k] = "LIQUID VISCOSITY"; - units[k] = "NS/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "LIQUID HEAT CAPACITY"; - units[k] = "J/KG-K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEnthalpy() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "LIQUID ENTHALPY"; - units[k] = "J/KG"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "LIQUID ENTROPY"; - units[k] = "J/KG/K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties() - .getConductivity(); - names[k] = "LIQUID THERMAL CONDUCTIVITY"; - units[k] = "W/M-K"; - k++; - hasOilValues = true; - } else if (continuousDerivativesExtrapolation && hasOilValues) { - do { - // if (i>1) { - // props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - - // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - - // pressures[i - // - 1]); - // } - // if (j>1 && i>1) { - // props[k][i][j] = 0.5 * ((props[k][i - 1][j] + (props[k][i - 1][j] - - // props[k][i - 2][j]) / (temperatures[i - 1] - temperatures[i - 2]) * - // (temperatures[i] - temperatures[i - 1])) + (props[k][i - 1][j] + - // (props[k][i - // - 1][j] - props[k][i - 2][j]) / (pressures[i - 1] - pressures[i - 2]) * - // (pressures[i] - pressures[i - 1]))); - // } - /* - * if (j > 2) { props[k][i][j] = 0.5*((props[k][i][j - 1] + (props[k][i][j - - * 1] - props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * - * (temperatures[j] - temperatures[j - 1])) +(props[k][i][j - 1] + - * (props[k][i][j - 1] - props[k][i][j - 3]) / (temperatures[j - 1] - - * temperatures[j - 3]) * (temperatures[j] - temperatures[j - 1]))); } - */ - if (j < 2 && i < 2) { - if (names[k].equals("LIQUID DENSITY") && props[k][i][j] <= 0) { - props[k][i][j] = 100; - } - if (names[k].equals("LIQUID DENSITY") && props[k][i][j] > 900) { - props[k][i][j] = 900; - } - if (names[k].equals("LIQUID VISCOSITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("LIQUID THERMAL CONDUCTIVITY") - && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("LIQUID HEAT CAPACITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - } - if (j > 1) { - props[k][i][j] = - props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) - / (temperatures[j - 1] - temperatures[j - 2]) - * (temperatures[j] - temperatures[j - 1]); - if (names[k].equals("LIQUID DENSITY") && props[k][i][j] <= 0) { - props[k][i][j] = 100; - } - if (names[k].equals("LIQUID DENSITY") && props[k][i][j] > 900) { - props[k][i][j] = 900; - } - if (names[k].equals("LIQUID VISCOSITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("LIQUID THERMAL CONDUCTIVITY") - && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("LIQUID HEAT CAPACITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - } - if (i > 1) { - props[k][i][j] = - props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) - / (pressures[i - 1] - pressures[i - 2]) - * (pressures[i] - pressures[i - 1]); - if (names[k].equals("LIQUID DENSITY") && props[k][i][j] <= 0) { - props[k][i][j] = 100; - } - if (names[k].equals("LIQUID DENSITY") && props[k][i][j] > 900) { - props[k][i][j] = 900; - } - if (names[k].equals("LIQUID VISCOSITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("LIQUID THERMAL CONDUCTIVITY") - && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("LIQUID HEAT CAPACITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - } - - // if (j > 1 && TLC==3) { - // props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - // - - // 2]) / (temperatures[j - 1] - temperatures[j - 2]) * (temperatures[j] - - // temperatures[j - 1]); - // if (j>1) { - // props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - // - - // 2]) / (temperatures[j - 1] - temperatures[j - 2]) * (temperatures[j] - - // temperatures[j - 1]); - // } else if (j < 2) { - // props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - - // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - - // pressures[i - // - 1]); - // } else { - // props[k][i][j] = props[k][i - 1][j - 1] + (props[k][i][j - 1] - - // props[k][i][j - // - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * (temperatures[j] - - // temperatures[j - 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / - // (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - - // 1]); - // } - // props[k][i][j] = 0.0;*/ - // } - k++; - } while (k < 17);// names[k] = "GAS DENSITY"; - // units[k] = "KG/M3"; - } else { - oilSystem.setPhaseType(0, 0); - oilSystem.setTemperature(temperatures[j]); - oilSystem.setPressure(pressures[i]); - oilSystem.init(3); - oilSystem.initPhysicalProperties(); - - props[k][i][j] = oilSystem.getPhase(0).getPhysicalProperties().getDensity(); - names[k] = "LIQUID DENSITY"; - units[k] = "KG/M3"; - k++; - - props[k][i][j] = oilSystem.getPhase(0).getdrhodP() / 1.0e5; - names[k] = "DRHOL/DP"; - units[k] = "S2/M2"; - k++; - - props[k][i][j] = oilSystem.getPhase(0).getdrhodT(); - names[k] = "DRHOL/DT"; - units[k] = "KG/M3-K"; - k++; - - props[k][i][j] = oilSystem.getPhase(0).getPhysicalProperties().getViscosity(); - names[k] = "LIQUID VISCOSITY"; - units[k] = "NS/M2"; - k++; - - props[k][i][j] = oilSystem.getPhase(0).getCp() - / oilSystem.getPhase(0).getNumberOfMolesInPhase() - / oilSystem.getPhase(0).getMolarMass(); - names[k] = "LIQUID HEAT CAPACITY"; - units[k] = "J/KG-K"; - k++; - - props[k][i][j] = oilSystem.getPhase(0).getEnthalpy() - / oilSystem.getPhase(0).getNumberOfMolesInPhase() - / oilSystem.getPhase(0).getMolarMass(); - names[k] = "LIQUID ENTHALPY"; - units[k] = "J/KG"; - k++; - - props[k][i][j] = oilSystem.getPhase(0).getEntropy() - / oilSystem.getPhase(0).getNumberOfMolesInPhase() - / oilSystem.getPhase(0).getMolarMass(); - names[k] = "LIQUID ENTROPY"; - units[k] = "J/KG/K"; - k++; - - props[k][i][j] = - oilSystem.getPhase(0).getPhysicalProperties().getConductivity(); - names[k] = "LIQUID THERMAL CONDUCTIVITY"; - units[k] = "W/M-K"; - k++; - } // setOilProperties(); - // set gas properties - - if (thermoSystem.hasPhaseType("aqueous") && acceptedFlash) { - int phaseNumb = thermoSystem.getPhaseNumberOfPhase("aqueous"); - if (thermoSystem.hasPhaseType("gas")) { - props[k][i][j] = thermoSystem.getPhase("gas").getComponent("water").getx() - * thermoSystem.getPhase("gas").getComponent("water").getMolarMass() - / thermoSystem.getPhase("gas").getMolarMass(); - } - if (thermoSystem.hasPhaseType("oil")) { - props[k][i][j] += thermoSystem.getPhase("oil").getComponent("water").getx() - * thermoSystem.getPhase("oil").getComponent("water").getMolarMass() - / thermoSystem.getPhase("oil").getMolarMass(); - } - names[k] = "WATER VAPOR MASS FRACTION"; - units[k] = "-"; - k++; - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); - names[k] = "WATER DENSITY"; - units[k] = "KG/M3"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; - names[k] = "DRHOWAT/DP"; - units[k] = "S2/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); - names[k] = "DRHOWAT/DT"; - units[k] = "KG/M3-K"; - k++; - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); - names[k] = "WATER VISCOSITY"; - units[k] = "NS/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "WATER HEAT CAPACITY"; - units[k] = "J/KG-K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEnthalpy() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "WATER ENTHALPY"; - units[k] = "J/KG"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "WATER ENTROPY"; - units[k] = "J/KG/K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties() - .getConductivity(); - names[k] = "WATER THERMAL CONDUCTIVITY"; - units[k] = "W/M-K"; - k++; - hasWaterValues = true; - } else if (continuousDerivativesExtrapolation && hasWaterValues) { - do { - /* - * if (j > 2) { props[k][i][j] = 0.5*((props[k][i][j - 1] + (props[k][i][j - - * 1] - props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * - * (temperatures[j] - temperatures[j - 1])) +(props[k][i][j - 1] + - * (props[k][i][j - 1] - props[k][i][j - 3]) / (temperatures[j - 1] - - * temperatures[j - 3]) * (temperatures[j] - temperatures[j - 1]))); if - * (names[k].equals("WATER VAPOR MASS FRACTION") && props[k][i][j] > 1) { - * props[k][i][j] = 1; } } - */ - if (j > 1) { - props[k][i][j] = - props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) - / (temperatures[j - 1] - temperatures[j - 2]) - * (temperatures[j] - temperatures[j - 1]); - if (names[k].equals("WATER VAPOR MASS FRACTION") - && props[k][i][j] > 1) { - props[k][i][j] = 1; - } - if (names[k].equals("WATER DENSITY") && props[k][i][j] <= 0) { - props[k][i][j] = 1000; - } - if (names[k].equals("WATER VISCOSITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("WATER THERMAL CONDUCTIVITY") - && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("WATER VAPOR MASS FRACTION") - && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("WATER HEAT CAPACITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - } - /* - * if (j > 1 && TLC == 3) { props[k][i][j] = props[k][i][j-1] + - * (props[k][i][j-1] - props[k][i][j-2]) / (temperatures[j - 1] - - * temperatures[j - 2]) * (temperatures[j] - temperatures[j - 1]); if (j>1) - * { props[k][i][j] = props[k][i][j-1] + (props[k][i][j-1] - - * props[k][i][j-2]) / (temperatures[j - 1] - temperatures[j - 2]) * - * (temperatures[j] - temperatures[j - 1]); if - * (names[k].equals("WATER VAPOR MASS FRACTION") && props[k][i][j] > 1) { - * props[k][i][j] = 1; } } - */ - if (i > 1) { - props[k][i][j] = - props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) - / (pressures[i - 1] - pressures[i - 2]) - * (pressures[i] - pressures[i - 1]); - if (names[k].equals("WATER VAPOR MASS FRACTION") - && props[k][i][j] > 1) { - props[k][i][j] = 1; - } - - if (names[k].equals("WATER DENSITY") && props[k][i][j] <= 0) { - props[k][i][j] = 1000; - } - if (names[k].equals("WATER VISCOSITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("WATER THERMAL CONDUCTIVITY") - && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("WATER VAPOR MASS FRACTION") - && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("WATER HEAT CAPACITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - } - - /* - * if (i < 2) { props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - - * props[k][i][j - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * - * (temperatures[j] - temperatures[j - 1]); } else if (j < 2) { - * props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - - * 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - - * pressures[i - 1]); } else { props[k][i][j] = props[k][i - 1][j - 1] + - * (props[k][i][j - 1] - props[k][i][j - 2]) / (temperatures[j - 1] - - * temperatures[j - 2]) * (temperatures[j] - temperatures[j - 1]) + - * (props[k][i - 1][j] - props[k][i - 2][j]) / (pressures[i - 1] - - * pressures[i - 2]) * (pressures[i] - pressures[i - 1]); } props[k][i][j] = - * 0.0; - */ - k++; - } while (k < 26);// names[k] = "GAS DENSITY"; - // units[k] = "KG/M3"; - } else { - waterSystem.setTemperature(temperatures[j]); - waterSystem.setPressure(pressures[i]); - waterSystem.setPhaseType(0, 0); - waterSystem.init(3); - waterSystem.initPhysicalProperties(); - - if (thermoSystem.getPhase(0).hasComponent("water")) { - props[k][i][j] = thermoSystem.getPhase(0).getComponent("water").getz() - * thermoSystem.getPhase(0).getComponent("water").getMolarMass() - / thermoSystem.getPhase(0).getMolarMass();; - } else { - props[k][i][j] = 0.0; - } - names[k] = "WATER VAPOR MASS FRACTION"; - units[k] = "-"; - k++; - - props[k][i][j] = waterSystem.getPhase(0).getPhysicalProperties().getDensity(); - names[k] = "WATER DENSITY"; - units[k] = "KG/M3"; - k++; - - props[k][i][j] = waterSystem.getPhase(0).getdrhodP() / 1.0e5; - names[k] = "DRHOWAT/DP"; - units[k] = "S2/M2"; - k++; - - props[k][i][j] = waterSystem.getPhase(0).getdrhodT(); - names[k] = "DRHOWAT/DT"; - units[k] = "KG/M3-K"; - k++; - - props[k][i][j] = waterSystem.getPhase(0).getPhysicalProperties().getViscosity(); - names[k] = "WATER VISCOSITY"; - units[k] = "NS/M2"; - k++; - - props[k][i][j] = waterSystem.getPhase(0).getCp() - / waterSystem.getPhase(0).getNumberOfMolesInPhase() - / waterSystem.getPhase(0).getMolarMass(); - names[k] = "WATER HEAT CAPACITY"; - units[k] = "J/KG-K"; - k++; - - props[k][i][j] = waterSystem.getPhase(0).getEnthalpy() - / waterSystem.getPhase(0).getNumberOfMolesInPhase() - / waterSystem.getPhase(0).getMolarMass(); - names[k] = "WATER ENTHALPY"; - units[k] = "J/KG"; - k++; - - props[k][i][j] = waterSystem.getPhase(0).getEntropy() - / waterSystem.getPhase(0).getNumberOfMolesInPhase() - / waterSystem.getPhase(0).getMolarMass(); - names[k] = "WATER ENTROPY"; - units[k] = "J/KG/K"; - k++; - - props[k][i][j] = - waterSystem.getPhase(0).getPhysicalProperties().getConductivity(); - names[k] = "WATER THERMAL CONDUCTIVITY"; - units[k] = "W/M-K"; - k++; - } - - if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("oil") - && acceptedFlash) { - props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( - thermoSystem.getPhaseNumberOfPhase("gas"), - thermoSystem.getPhaseNumberOfPhase("oil")); - names[k] = "VAPOR-LIQUID SURFACE TENSION"; - units[k] = "N/M"; - k++; - } else { - if (continuousDerivativesExtrapolation && (i >= 2 || j >= 2)) { - if (VLS == 1) { - props[k][i][j] = 5.0e-3; - // k++; - } - // if (j>1 && thermoSystem.hasPhaseType("gas") && VLS==0 && acceptedFlash) { - if (j > 1 && (GLW == 1 || GL == 1) && VLS == 0) { - props[k][i][j] = - props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) - / (temperatures[j - 1] - temperatures[j - 2]) - * (temperatures[j] - temperatures[j - 1]); - /* - * if (names[k].equals("VAPOR-LIQUID SURFACE TENSION") && props[k][i][j] - * < 5.0e-3) { props[k][i][j] = 7.5e-3; VLS=1; } if - * (names[k].equals("VAPOR-LIQUID SURFACE TENSION") && props[k][i][j] > - * 30.0e-3) { props[k][i][j] = 20.0e-3; VLS=1; } - */ - if (props[k][i][j] < 5.0e-3) { - props[k][i][j] = 5.0e-3; - VLS = 1; - } - if (props[k][i][j] > 1.1 * props[k][i][j - 1]) { - props[k][i][j] = props[k][i][j - 1]; - } - if (props[k][i][j] < 0.9 * props[k][i][j - 1]) { - props[k][i][j] = props[k][i][j - 1]; - } - // } else if (i>1 && thermoSystem.hasPhaseType("oil") && VLS == 0 && - // acceptedFlash) { - // } else if (i > 1 && TLC < 3 && VLS==0) { - } else if (i > 1 && (GLW == 0 || GL == 0) && VLS == 0) { - props[k][i][j] = - props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) - / (pressures[i - 1] - pressures[i - 2]) - * (pressures[i] - pressures[i - 1]); - if (props[k][i][j] < 5.0e-3) { - props[k][i][j] = 5.0e-3; - VLS = 1; - } - if (props[k][i][j] > 1.1 * props[k][i - 1][j]) { - props[k][i][j] = props[k][i - 1][j]; - } - if (props[k][i][j] < 0.9 * props[k][i - 1][j]) { - props[k][i][j] = props[k][i - 1][j]; - } - } else if (j > 0 && i > 0) { - props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); - } else if (j > 0) { - props[k][i][j] = props[k][i][j - 1]; - } else if (i > 0) { - props[k][i][j] = props[k][i - 1][j]; - } else { - // props[k][i][j] = props[k][i - 1][j - 1] + (props[k][i][j - 1] - - // props[k][i][j - // - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * - // (temperatures[j] - - // temperatures[j - 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / - // (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - - // 1]); - props[k][i][j] = 10.0e-3; - } - - // k++; - } else if (j > 0 && i > 0) { - props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); - // k++; - } else if (j > 0) { - props[k][i][j] = props[k][i][j - 1]; - // k++; - } else if (i > 0) { - props[k][i][j] = props[k][i - 1][j]; - // k++; - } else { - props[k][i][j] = 10.0e-3; - names[k] = "VAPOR-LIQUID SURFACE TENSION"; - units[k] = "N/M"; - // k++; - } - k++; - } - - if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("aqueous") - && acceptedFlash) { - props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( - thermoSystem.getPhaseNumberOfPhase("gas"), - thermoSystem.getPhaseNumberOfPhase("aqueous")); - names[k] = "VAPOR-WATER SURFACE TENSION"; - units[k] = "N/M"; - k++; - } else { - if (continuousDerivativesExtrapolation && (i >= 2 || j >= 2)) { - if (VWS == 1) { - props[k][i][j] = 5.0e-3; - // k++; - } - // if (j>1 && thermoSystem.hasPhaseType("gas") && VWS == 0 && acceptedFlash) - // { - // if (j > 1 && TLC==3 && VWS==0) { - if (j > 1 && (GLW == 1 || GW == 1) && VWS == 0) { - props[k][i][j] = - props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) - / (temperatures[j - 1] - temperatures[j - 2]) - * (temperatures[j] - temperatures[j - 1]); - /* - * if (names[k].equals("VAPOR-WATER SURFACE TENSION") && props[k][i][j] - * < 10.0e-3) { props[k][i][j] = 35.0e-3; VWS=1; } if - * (names[k].equals("VAPOR-WATER SURFACE TENSION") && props[k][i][j] > - * 150.0e-3) { props[k][i][j] = 105.0e-3; VWS=1; } - */ - if (props[k][i][j] < 5.0e-3) { - props[k][i][j] = 5.0e-3; - VWS = 1; - } - if (props[k][i][j] > 1.1 * props[k][i][j - 1]) { - props[k][i][j] = props[k][i][j - 1]; - } - if (props[k][i][j] < 0.9 * props[k][i][j - 1]) { - props[k][i][j] = props[k][i][j - 1]; - } - // } else if (j>1 && thermoSystem.hasPhaseType("aqueous") && VWS ==0 && - // acceptedFlash) { - // } else if (i > 1 && TLC < 3 && VWS==0) { - } else if (i > 1 && (GLW == 0 || GL == 0) && VWS == 0) { - props[k][i][j] = - props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) - / (pressures[i - 1] - pressures[i - 2]) - * (pressures[i] - pressures[i - 1]); - /* - * if (names[k].equals("VAPOR-WATER SURFACE TENSION") && props[k][i][j] - * < 10.0e-3) { props[k][i][j] = 35.0e-3; VWS=1; } if - * (names[k].equals("VAPOR-WATER SURFACE TENSION") && props[k][i][j] > - * 150.0e-3) { props[k][i][j] = 105.0e-3; VWS=1; } - */ - if (props[k][i][j] < 5.0e-3) { - props[k][i][j] = 5.0e-3; - VWS = 1; - } - if (props[k][i][j] > 1.1 * props[k][i - 1][j]) { - props[k][i][j] = props[k][i - 1][j]; - } - if (props[k][i][j] < 0.9 * props[k][i - 1][j]) { - props[k][i][j] = props[k][i - 1][j]; - } - } else if (j > 0 && i > 0) { - props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); - } else if (j > 0) { - props[k][i][j] = props[k][i][j - 1]; - } else if (i > 0) { - props[k][i][j] = props[k][i - 1][j]; - } else { - // props[k][i][j] = props[k][i - 1][j - 1] + (props[k][i][j - 1] - - // props[k][i][j - // - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * - // (temperatures[j] - - // temperatures[j - 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / - // (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - - // 1]); - props[k][i][j] = 60.0e-3; - } - - // k++; - } else if (j > 0 && i > 0) { - props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); - // k++; - } else if (j > 0) { - props[k][i][j] = props[k][i][j - 1]; - // k++; - } else if (i > 0) { - props[k][i][j] = props[k][i - 1][j]; - // k++; - } else { - props[k][i][j] = 60.0e-3; - names[k] = "VAPOR-WATER SURFACE TENSION"; - units[k] = "N/M"; - // k++; - } - k++; - } - - if (thermoSystem.hasPhaseType("oil") && thermoSystem.hasPhaseType("aqueous") - && acceptedFlash) { - props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( - thermoSystem.getPhaseNumberOfPhase("oil"), - thermoSystem.getPhaseNumberOfPhase("aqueous")); - names[k] = "LIQUID-WATER SURFACE TENSION"; - units[k] = "N/M"; - k++; - } else { - if (continuousDerivativesExtrapolation && (i >= 2 || j >= 2)) { - if (LWS == 1) { - props[k][i][j] = 5.0e-3; - // k++; - } - if (j > 1 && LWS == 0) { - // if (j > 1 && TLC==3 && LWS==0) { - // if (j>1 && LWS==0 && acceptedFlash) { - props[k][i][j] = - props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) - / (temperatures[j - 1] - temperatures[j - 2]) - * (temperatures[j] - temperatures[j - 1]); - /* - * if (j > 2) { props[k][i][j] = 0.5*((props[k][i][j - 1] + - * (props[k][i][j - 1] - props[k][i][j - 2]) / (temperatures[j - 1] - - * temperatures[j - 2]) * (temperatures[j] - temperatures[j - 1])) - * +(props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 3]) / - * (temperatures[j - 1] - temperatures[j - 3]) * (temperatures[j] - - * temperatures[j - 1]))); if - * (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] < - * 10.0e-3) { props[k][i][j] = 25.0e-3; LWS=1; } - * - * if (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] - * > 120.0e-3) { props[k][i][j] = 80.0e-3; LWS=1; } } - */ - - /* - * if (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] - * < 10.0e-3) { props[k][i][j] = 25.0e-3; LWS=1; } if - * (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] > - * 120.0e-3) { props[k][i][j] = 80.0e-3; LWS=1; } - */ - if (props[k][i][j] < 5.0e-3) { - props[k][i][j] = 5.0e-3; - LWS = 1; - } - if (props[k][i][j] > 1.1 * props[k][i][j - 1]) { - props[k][i][j] = props[k][i][j - 1]; - } - if (props[k][i][j] < 0.9 * props[k][i][j - 1]) { - props[k][i][j] = props[k][i][j - 1]; - } - // } else if (i > 1 && LWS==0 && acceptedFlash) { - // } else if (i > 1 && TLC < 3 && LWS==0) { - // props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - - // props[k][i - - // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - - // pressures[i - // - 1]); - /* - * if (i > 2) { props[k][i][j] = 0.5*((props[k][i - 1][j] + (props[k][i - * - 1][j] - props[k][i - 2][j]) / (pressures[i - 1] - pressures[i - 2]) - * * (pressures[i] - pressures[i - 1])) +(props[k][i - 1][j] + - * (props[k][i - 1][j] - props[k][i - 3][j]) / (pressures[i - 1] - - * pressures[i - 3]) * (pressures[i] - pressures[i - 1]))); if - * (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] < - * 10.0e-3) { props[k][i][j] = 25.0e-3; LWS=1; } - * - * if (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] - * > 120.0e-3) { props[k][i][j] = 80.0e-3; LWS=1; } } - */ - - /* - * if (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] - * < 10.0e-3) { props[k][i][j] = 25.0e-3; LWS=1; } if - * (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] > - * 120.0e-3) { props[k][i][j] = 80.0e-3; LWS=1; } - */ - - /* - * if (props[k][i][j] < 5.0e-3) { props[k][i][j] = 5.0e-3; LWS = 1; } if - * (props[k][i][j] > 1.1* props[k][i - 1][j]) { props[k][i][j] = - * props[k][i - 1][j]; } if (props[k][i][j] < 0.9* props[k][i - 1][j]) { - * props[k][i][j] = props[k][i - 1][j]; } - */ - // } else if (j >0 && i > 0) { - // props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); - } else if (j > 0) { - props[k][i][j] = props[k][i][j - 1]; - } else if (i > 0) { - props[k][i][j] = props[k][i - 1][j]; - } else { - // props[k][i][j] = props[k][i - 1][j - 1] + (props[k][i][j - 1] - - // props[k][i][j - // - 2]) / (temperatures[j - 1] - temperatures[j - 2]) * - // (temperatures[j] - - // temperatures[j - 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / - // (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - - // 1]); - props[k][i][j] = 40.0e-3; - } - - // k++; - // } else if (j >0 && i > 0) { - // props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); - // k++; - } else if (j > 0) { - props[k][i][j] = props[k][i][j - 1]; - // k++; - } else if (i > 0) { - props[k][i][j] = props[k][i - 1][j]; - // k++; - } else { - props[k][i][j] = 40.0e-3; - names[k] = "LIQUID-WATER SURFACE TENSION"; - units[k] = "N/M"; - // k++; - } - k++; - } - } + writer.write(bubPLOG[i] + " "); + bubPcounter++; + } + writer.write("\n"); + + int dewPcounter = 0; + for (int i = 0; i < temperatures.length; i++) { + if (dewPcounter > 4) { + writer.write("\n"); + dewPcounter = 0; } - logger.info("Finished TPflash..."); - if (thermoSystem.getPhase(0).hasComponent("water")) { - thermoSystem.removeComponent("water"); + writer.write(dewPLOG[i] + " "); + dewPcounter++; + } + writer.write("\n"); + + for (int k = 0; k < nProps; k++) { + if (names[k] == null) { + continue; } - bubP = calcBubP(temperatures); - dewP = calcDewP(temperatures); - // bubT = calcBubT(temperatures); - // logger.info("Finished creating arrays"); - // BicubicSplineInterpolatingFunction funcGasDens = - // interpolationFunc.interpolate(pressures, temperatures, props[0]); - // logger.info("interpolated value " + funcGasDens.value(40, 298.0)); - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - // logger.info("TC " + TC + " PC " + PC); - // for (int i = 0; i < pressures.length; i++) { - // thermoSystem.setPressure(pressures[i]); - // for (int j = 0; j < temperatures.length; j++) { - // logger.info("pressure " + pressureLOG[i] + " temperature " + - // temperatureLOG[j]);// + " ROG " + ROG[i][j] + " ROL " + ROL[i][j]); - // } - // } - writeOLGAinpFile(fileName); + // logger.info("Writing variable: " + names[k]); + writer.write(names[k] + " (" + units[k] + ")\n"); + for (int i = 0; i < pressures.length; i++) { + // thermoSystem.setPressure(pressures[i]); + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + // thermoSystem.setTemperature(temperatures[j]); + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[k][i][j] + " "); + counter++; + } + writer.write("\n"); + } + } + } catch (IOException ex) { + ex.printStackTrace(); } - - /** - *

- * writeOLGAinpFile2. - *

- * - * @param filename a {@link java.lang.String} object + } + + /** + *

+ * writeOLGAinpFile. + *

+ * + * @param filename a {@link java.lang.String} object + */ + public void writeOLGAinpFile(String filename) { + /* + * try { writer = new BufferedWriter(new OutputStreamWriter( new + * FileOutputStream("C:/Users/Kjetil Raul/Documents/Master KRB/javacode_ROG55.txt" ), "utf-8")); + * writer.write("GAS DENSITY (KG/M3) = ("); for (int i = 0; i < pressures.length; i++) { + * thermoSystem.setPressure(pressures[i]); for (int j = 0; j < temperatures.length; j++) { + * thermoSystem.setTemperature(temperatures[j]); writer.write(ROG[i][j] + ","); } } + * writer.write(")"); } catch (IOException ex) { // report } finally { try { } writer.close(); } + * catch (Exception ex) { } } */ - public void writeOLGAinpFile2(String filename) { - /* - * try { writer = new BufferedWriter(new OutputStreamWriter( new - * FileOutputStream("C:/Users/Kjetil Raul/Documents/Master KRB/javacode_ROG55.txt" ), - * "utf-8")); writer.write("GAS DENSITY (KG/M3) = ("); for (int i = 0; i < pressures.length; - * i++) { thermoSystem.setPressure(pressures[i]); for (int j = 0; j < temperatures.length; - * j++) { thermoSystem.setTemperature(temperatures[j]); writer.write(ROG[i][j] + ","); } } - * writer.write(")"); } catch (IOException ex) { // report } finally { try { } - * writer.close(); } catch (Exception ex) { } } - */ - try (Writer writer = new BufferedWriter( - new OutputStreamWriter(new FileOutputStream(fileName), "utf-8"))) { - writer.write("'WATER-OPTION ENTROPY NONEQ '" + "\n"); - - writer.write(pressures.length + " " + temperatures.length + " " + RSWTOB + "\n"); - int Pcounter = 0; - for (int i = 0; i < pressures.length; i++) { - if (Pcounter > 4) { - writer.write("\n"); - Pcounter = 0; - } - writer.write(pressureLOG[i] + " "); - Pcounter++; - } + try (Writer writer = + new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename), "utf-8"))) { + writer.write("'WATER-OPTION ENTROPY NONEQ '" + "\n"); + + writer.write(pressures.length + " " + temperatures.length + " " + RSWTOB + "\n"); + int Pcounter = 0; + for (int i = 0; i < pressures.length; i++) { + if (Pcounter > 4) { + writer.write("\n"); + Pcounter = 0; + } + writer.write(pressureLOG[i] + " "); + Pcounter++; + } + writer.write("\n"); + + int Tcounter = 0; + for (int i = 0; i < temperatures.length; i++) { + if (Tcounter > 4) { + writer.write("\n"); + Tcounter = 0; + } + writer.write(temperatureLOG[i] + " "); + Tcounter++; + } + writer.write("\n"); + + int bubPcounter = 0; + for (int i = 0; i < temperatures.length; i++) { + if (bubPcounter > 4) { + writer.write("\n"); + bubPcounter = 0; + } + writer.write(bubPLOG[i] + " "); + bubPcounter++; + } + writer.write("\n"); + + int dewPcounter = 0; + for (int i = 0; i < temperatures.length; i++) { + if (dewPcounter > 4) { + writer.write("\n"); + dewPcounter = 0; + } + writer.write(dewPLOG[i] + " "); + dewPcounter++; + } + writer.write("\n"); + + writer.write("GAS DENSITY (KG/M3)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[0][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int Tcounter = 0; - for (int i = 0; i < temperatures.length; i++) { - if (Tcounter > 4) { - writer.write("\n"); - Tcounter = 0; - } - writer.write(temperatureLOG[i] + " "); - Tcounter++; - } + writer.write("LIQUID DENSITY (KG/M3)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[9][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int bubPcounter = 0; - for (int i = 0; i < temperatures.length; i++) { - if (bubPcounter > 4) { - writer.write("\n"); - bubPcounter = 0; - } - writer.write(bubPLOG[i] + " "); - bubPcounter++; - } + writer.write("WATER DENSITY (KG/M3)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[18][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int dewPcounter = 0; - for (int i = 0; i < temperatures.length; i++) { - if (dewPcounter > 4) { - writer.write("\n"); - dewPcounter = 0; - } - writer.write(dewPLOG[i] + " "); - dewPcounter++; - } + writer.write("DRHOG/DP (S2/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); - - for (int k = 0; k < nProps; k++) { - if (names[k] == null) { - continue; - } - // logger.info("Writing variable: " + names[k]); - writer.write(names[k] + " (" + units[k] + ")\n"); - for (int i = 0; i < pressures.length; i++) { - // thermoSystem.setPressure(pressures[i]); - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - // thermoSystem.setTemperature(temperatures[j]); - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[k][i][j] + " "); - counter++; - } - writer.write("\n"); - } - } - } catch (IOException ex) { - ex.printStackTrace(); + counter = 0; + } + writer.write(props[1][i][j] + " "); + counter++; } - } + writer.write("\n"); + } - /** - *

- * writeOLGAinpFile. - *

- * - * @param filename a {@link java.lang.String} object - */ - public void writeOLGAinpFile(String filename) { - /* - * try { writer = new BufferedWriter(new OutputStreamWriter( new - * FileOutputStream("C:/Users/Kjetil Raul/Documents/Master KRB/javacode_ROG55.txt" ), - * "utf-8")); writer.write("GAS DENSITY (KG/M3) = ("); for (int i = 0; i < pressures.length; - * i++) { thermoSystem.setPressure(pressures[i]); for (int j = 0; j < temperatures.length; - * j++) { thermoSystem.setTemperature(temperatures[j]); writer.write(ROG[i][j] + ","); } } - * writer.write(")"); } catch (IOException ex) { // report } finally { try { } - * writer.close(); } catch (Exception ex) { } } - */ - try (Writer writer = new BufferedWriter( - new OutputStreamWriter(new FileOutputStream(filename), "utf-8"))) { - writer.write("'WATER-OPTION ENTROPY NONEQ '" + "\n"); - - writer.write(pressures.length + " " + temperatures.length + " " + RSWTOB + "\n"); - int Pcounter = 0; - for (int i = 0; i < pressures.length; i++) { - if (Pcounter > 4) { - writer.write("\n"); - Pcounter = 0; - } - writer.write(pressureLOG[i] + " "); - Pcounter++; - } + writer.write("DRHOL/DP (S2/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[10][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int Tcounter = 0; - for (int i = 0; i < temperatures.length; i++) { - if (Tcounter > 4) { - writer.write("\n"); - Tcounter = 0; - } - writer.write(temperatureLOG[i] + " "); - Tcounter++; - } + writer.write("DRHOWAT/DP (S2/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[19][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int bubPcounter = 0; - for (int i = 0; i < temperatures.length; i++) { - if (bubPcounter > 4) { - writer.write("\n"); - bubPcounter = 0; - } - writer.write(bubPLOG[i] + " "); - bubPcounter++; - } + writer.write("DRHOG/DT (KG/M3-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[2][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int dewPcounter = 0; - for (int i = 0; i < temperatures.length; i++) { - if (dewPcounter > 4) { - writer.write("\n"); - dewPcounter = 0; - } - writer.write(dewPLOG[i] + " "); - dewPcounter++; - } + writer.write("DRHOL/DT (KG/M3-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[11][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS DENSITY (KG/M3)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[0][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("LIQUID DENSITY (KG/M3)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[9][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("WATER DENSITY (KG/M3)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[18][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOG/DP (S2/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[1][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOL/DP (S2/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[10][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOWAT/DP (S2/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[19][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOG/DT (KG/M3-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[2][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOL/DT (KG/M3-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[11][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOWAT/DT (KG/M3-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[20][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("GAS MASS FRACTION (-)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[3][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("WATER VAPOR MASS FRACTION (-)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[17][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("DRHOWAT/DT (KG/M3-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[20][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS VISCOSITY (NS/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[4][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS MASS FRACTION (-)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[3][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID VISCOSITY (NS/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[12][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("WATER VAPOR MASS FRACTION (-)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[17][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("WATER VISCOSITY (NS/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[21][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS VISCOSITY (NS/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[4][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS HEAT CAPACITY (J/KG-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[5][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("LIQUID VISCOSITY (NS/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[12][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID HEAT CAPACITY (J/KG-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[13][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("WATER VISCOSITY (NS/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[21][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("WATER HEAT CAPACITY (J/KG-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[22][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS HEAT CAPACITY (J/KG-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[5][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS ENTHALPY (J/KG)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[6][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("LIQUID HEAT CAPACITY (J/KG-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[13][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID ENTHALPY (J/KG)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[14][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("WATER HEAT CAPACITY (J/KG-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[22][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("WATER ENTHALPY (J/KG)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[23][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS ENTHALPY (J/KG)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[6][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS THERMAL CONDUCTIVITY (W/M-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[7][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("LIQUID ENTHALPY (J/KG)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[14][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID THERMAL CONDUCTIVITY (W/M-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[16][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("WATER ENTHALPY (J/KG)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[23][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("WATER THERMAL CONDUCTIVITY (W/M-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[25][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS THERMAL CONDUCTIVITY (W/M-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[7][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("VAPOR-LIQUID SURFACE TENSION (N/M)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[26][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("LIQUID THERMAL CONDUCTIVITY (W/M-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[16][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("VAPOR-WATER SURFACE TENSION (N/M)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[27][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("WATER THERMAL CONDUCTIVITY (W/M-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[25][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID-WATER SURFACE TENSION (N/M)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[28][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("VAPOR-LIQUID SURFACE TENSION (N/M)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[26][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS ENTROPY (J/KG/K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[8][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("VAPOR-WATER SURFACE TENSION (N/M)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[27][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID ENTROPY (J/KG/K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[15][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("LIQUID-WATER SURFACE TENSION (N/M)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[28][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("WATER ENTROPY (J/KG/K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < temperatures.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[24][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS ENTROPY (J/KG/K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[8][i][j] + " "); + counter++; + } + writer.write("\n"); + } - /* - * for (int k = 0; k < nProps; k++) { if (names[k] == null) { continue; } - * logger.info("Writing variable: " + names[k]); writer.write(names[k] + " (" + units[k] - * + ")\n"); for (int i = 0; i < pressures.length; i++) { - * //thermoSystem.setPressure(pressures[i]); int counter = 0; for (int j = 0; j < - * temperatures.length; j++) { // thermoSystem.setTemperature(temperatures[j]); if - * (counter > 4) { writer.write("\n"); counter = 0; } writer.write(props[k][i][j] + - * " "); counter++; } writer.write("\n"); } } - */ - } catch (IOException ex) { - // report + writer.write("LIQUID ENTROPY (J/KG/K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < temperatures.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[15][i][j] + " "); + counter++; } - } + writer.write("\n"); + } - /** - *

- * extrapolateTable. - *

- */ - public void extrapolateTable() { + writer.write("WATER ENTROPY (J/KG/K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; for (int j = 0; j < temperatures.length; j++) { - for (int i = 0; i < pressures.length; i++) { - if (!hasValue[26][i][j]) { - } - } + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[24][i][j] + " "); + counter++; + } + writer.write("\n"); + } + + /* + * for (int k = 0; k < nProps; k++) { if (names[k] == null) { continue; } + * logger.info("Writing variable: " + names[k]); writer.write(names[k] + " (" + units[k] + + * ")\n"); for (int i = 0; i < pressures.length; i++) { + * //thermoSystem.setPressure(pressures[i]); int counter = 0; for (int j = 0; j < + * temperatures.length; j++) { // thermoSystem.setTemperature(temperatures[j]); if (counter > + * 4) { writer.write("\n"); counter = 0; } writer.write(props[k][i][j] + " "); counter++; } + * writer.write("\n"); } } + */ + } catch (IOException ex) { + // report + } + } + + /** + *

+ * extrapolateTable. + *

+ */ + public void extrapolateTable() { + for (int j = 0; j < temperatures.length; j++) { + for (int i = 0; i < pressures.length; i++) { + if (!hasValue[26][i][j]) { } + } } + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudentsPH.java b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudentsPH.java index d9169a2ce2..2dd7467772 100644 --- a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudentsPH.java +++ b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudentsPH.java @@ -22,1917 +22,1880 @@ * @version $Id: $Id */ public class OLGApropertyTableGeneratorWaterStudentsPH - extends neqsim.thermodynamicOperations.BaseOperation { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(OLGApropertyTableGeneratorWaterStudentsPH.class); - - SystemInterface thermoSystem = null, gasSystem = null, oilSystem = null, waterSystem = null; - ThermodynamicOperations thermoOps = null; - double[] pressures, enthalpiesLOG, enthalpies, pressureLOG = null; - double[] bubP, bubT, dewP, bubPLOG, dewPLOG; - Matrix XMatrixgas, XMatrixoil, XMatrixwater; - double[][] ROG = null; - double maxPressure; - double minPressure; - double TLC, GLW, GL, GW; // TLC = Top left corner. GOW=Gas+Liquid+Water, GO = Gas+Liquid, GW = - // Gas+Water - double VLS, VWS, LWS;; // VLS=Stop value for vapor-liqid surface tension. VWS=Stop value for - // vapor-water surface tension. LWS=Stop value for liquid-water surface - // tension - // double VLB, VLT, VWT, VWB, LWB, LWT; - // double[][] ROL, CPG, CPHL, HG, HHL, TCG, TCHL, VISG, VISHL, SIGGHL, - // SEG, - // SEHL, RS; - double TC, PC; - double RSWTOB; - double[][][] props; - int nProps; - String[] names; - Matrix[] xcoef = new Matrix[9]; - String[] units; - int temperatureSteps, pressureSteps; - boolean continuousDerivativesExtrapolation = true; - boolean hasGasValues = false; - boolean hasOilValues = false; - boolean hasWaterValues = false; - boolean[][][] hasValue; - Matrix aMatrix = new Matrix(4, 4); - Matrix s = new Matrix(1, 4); - String fileName = "c:/Appl/OLGAneqsim.tab"; - - /** - *

- * Constructor for OLGApropertyTableGeneratorWaterStudentsPH. - *

- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public OLGApropertyTableGeneratorWaterStudentsPH(SystemInterface system) { - this.thermoSystem = system; - thermoOps = new ThermodynamicOperations(thermoSystem); - - XMatrixgas = new Matrix(9, 4); - XMatrixoil = new Matrix(9, 4); - XMatrixwater = new Matrix(9, 4); - - gasSystem = new SystemSrkEos(298, 10); - gasSystem.addComponent("methane", 1); - // gasSystem.createDatabase(true); - gasSystem.init(0); - gasSystem.setNumberOfPhases(1); - - waterSystem = new SystemSrkCPAstatoil(298, 10); - waterSystem.addComponent("water", 1); - // waterSystem.createDatabase(true); - waterSystem.init(0); - waterSystem.setNumberOfPhases(1); - - oilSystem = new SystemSrkEos(298, 10); - oilSystem.addComponent("nC10", 1); - // oilSystem.createDatabase(true); - oilSystem.init(0); - oilSystem.setNumberOfPhases(1); + extends neqsim.thermodynamicOperations.BaseOperation { + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(OLGApropertyTableGeneratorWaterStudentsPH.class); + + SystemInterface thermoSystem = null; + SystemInterface gasSystem = null; + SystemInterface oilSystem = null; + SystemInterface waterSystem = null; + ThermodynamicOperations thermoOps = null; + double[] pressures; + double[] enthalpiesLOG; + double[] enthalpies; + double[] pressureLOG = null; + double[] bubP; + double[] bubT; + double[] dewP; + double[] bubPLOG; + double[] dewPLOG; + Matrix XMatrixgas; + Matrix XMatrixoil; + Matrix XMatrixwater; + double[][] ROG = null; + double maxPressure; + double minPressure; + double TLC; + double GLW; + double GL; + double GW; + double VLS; + double VWS; + double LWS; + double TC; + double PC; + double RSWTOB; + double[][][] props; + int nProps; + String[] names; + Matrix[] xcoef = new Matrix[9]; + String[] units; + int temperatureSteps; + int pressureSteps; + boolean continuousDerivativesExtrapolation = true; + boolean hasGasValues = false; + boolean hasOilValues = false; + boolean hasWaterValues = false; + boolean[][][] hasValue; + Matrix aMatrix = new Matrix(4, 4); + Matrix s = new Matrix(1, 4); + String fileName = "c:/Appl/OLGAneqsim.tab"; + + /** + *

+ * Constructor for OLGApropertyTableGeneratorWaterStudentsPH. + *

+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public OLGApropertyTableGeneratorWaterStudentsPH(SystemInterface system) { + this.thermoSystem = system; + thermoOps = new ThermodynamicOperations(thermoSystem); + + XMatrixgas = new Matrix(9, 4); + XMatrixoil = new Matrix(9, 4); + XMatrixwater = new Matrix(9, 4); + + gasSystem = new SystemSrkEos(298, 10); + gasSystem.addComponent("methane", 1); + // gasSystem.createDatabase(true); + gasSystem.init(0); + gasSystem.setNumberOfPhases(1); + + waterSystem = new SystemSrkCPAstatoil(298, 10); + waterSystem.addComponent("water", 1); + // waterSystem.createDatabase(true); + waterSystem.init(0); + waterSystem.setNumberOfPhases(1); + + oilSystem = new SystemSrkEos(298, 10); + oilSystem.addComponent("nC10", 1); + // oilSystem.createDatabase(true); + oilSystem.init(0); + oilSystem.setNumberOfPhases(1); + } + + /** + *

+ * Setter for the field fileName. + *

+ * + * @param name a {@link java.lang.String} object + */ + public void setFileName(String name) { + fileName = name; + } + + /** + *

+ * setPressureRange. + *

+ * + * @param minPressure a double + * @param maxPressure a double + * @param numberOfSteps a int + */ + public void setPressureRange(double minPressure, double maxPressure, int numberOfSteps) { + pressures = new double[numberOfSteps]; + pressureLOG = new double[numberOfSteps]; + double step = (maxPressure - minPressure) / (numberOfSteps * 1.0 - 1.0); + for (int i = 0; i < numberOfSteps; i++) { + pressures[i] = minPressure + i * step; + pressureLOG[i] = pressures[i] * 1e5; } - - /** - *

- * Setter for the field fileName. - *

- * - * @param name a {@link java.lang.String} object - */ - public void setFileName(String name) { - fileName = name; + } + + /** + *

+ * setEnthalpyRange. + *

+ * + * @param minEnthalpy a double + * @param maxEnthalpy a double + * @param numberOfSteps a int + */ + public void setEnthalpyRange(double minEnthalpy, double maxEnthalpy, int numberOfSteps) { + enthalpies = new double[numberOfSteps]; + enthalpiesLOG = new double[numberOfSteps]; + double step = (maxEnthalpy - minEnthalpy) / (numberOfSteps * 1.0 - 1.0); + for (int i = 0; i < numberOfSteps; i++) { + enthalpies[i] = minEnthalpy + i * step; + enthalpiesLOG[i] = enthalpies[i]; + } + } + + /** + *

+ * calcPhaseEnvelope. + *

+ */ + public void calcPhaseEnvelope() { + try { + thermoOps.calcPTphaseEnvelope(); + TC = thermoSystem.getTC() - 273.15; + PC = thermoSystem.getPC() * 1e5; + } catch (Exception e) { + logger.error("error", e); } + } + + /** + *

+ * calcBubP. + *

+ * + * @param enthalpies an array of {@link double} objects + * @return an array of {@link double} objects + */ + public double[] calcBubP(double[] enthalpies) { + double[] bubP = new double[enthalpies.length]; + bubPLOG = new double[enthalpies.length]; + for (int i = 0; i < enthalpies.length; i++) { + thermoSystem.setTemperature(enthalpies[i]); + try { + thermoOps.bubblePointPressureFlash(false); + bubP[i] = thermoSystem.getPressure(); + } catch (Exception e) { + logger.error("error", e); + bubP[i] = 0; + return bubP; + } + bubPLOG[i] = bubP[i] * 1e5; + } + return bubP; + } + + /** + *

+ * calcDewP. + *

+ * + * @param enthalpies an array of {@link double} objects + * @return an array of {@link double} objects + */ + public double[] calcDewP(double[] enthalpies) { + double[] dewP = new double[enthalpies.length]; + dewPLOG = new double[enthalpies.length]; + for (int i = 0; i < enthalpies.length; i++) { + thermoSystem.setTemperature(enthalpies[i]); + try { + thermoOps.dewPointPressureFlashHC(); + dewP[i] = thermoSystem.getPressure(); + } catch (Exception e) { + logger.error("error", e); + dewP[i] = 0; + return dewP; + } - /** - *

- * setPressureRange. - *

- * - * @param minPressure a double - * @param maxPressure a double - * @param numberOfSteps a int - */ - public void setPressureRange(double minPressure, double maxPressure, int numberOfSteps) { - pressures = new double[numberOfSteps]; - pressureLOG = new double[numberOfSteps]; - double step = (maxPressure - minPressure) / (numberOfSteps * 1.0 - 1.0); - for (int i = 0; i < numberOfSteps; i++) { - pressures[i] = minPressure + i * step; - pressureLOG[i] = pressures[i] * 1e5; - } + dewPLOG[i] = dewP[i] * 1e5; + } + return dewP; + } + + /** + *

+ * calcBubT. + *

+ * + * @param pressures an array of {@link double} objects + * @return an array of {@link double} objects + */ + public double[] calcBubT(double[] pressures) { + double[] bubTemps = new double[pressures.length]; + for (int i = 0; i < pressures.length; i++) { + thermoSystem.setPressure(pressures[i]); + try { + thermoOps.bubblePointTemperatureFlash(); + bubT[i] = thermoSystem.getPressure(); + } catch (Exception e) { + logger.error("error", e); + bubT[i] = 0.0; + } + } + return bubTemps; + } + + /** + *

+ * initCalc. + *

+ */ + public void initCalc() { + double stdTemp = 288.15; + double stdPres = 1.01325; + // double GOR, GLR; + double[] molfracs = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; + double[] MW = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; + double[] dens = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; + String[] components = new String[thermoSystem.getPhase(0).getNumberOfComponents()]; + + for (int i = 0; i < molfracs.length; i++) { + molfracs[i] = thermoSystem.getPhase(0).getComponent(i).getz(); + components[i] = thermoSystem.getPhase(0).getComponent(i).getComponentName(); + MW[i] = thermoSystem.getPhase(0).getComponent(i).getMolarMass() * 1000; + dens[i] = thermoSystem.getPhase(0).getComponent(i).getNormalLiquidDensity(); } - /** - *

- * setEnthalpyRange. - *

- * - * @param minEnthalpy a double - * @param maxEnthalpy a double - * @param numberOfSteps a int - */ - public void setEnthalpyRange(double minEnthalpy, double maxEnthalpy, int numberOfSteps) { - enthalpies = new double[numberOfSteps]; - enthalpiesLOG = new double[numberOfSteps]; - double step = (maxEnthalpy - minEnthalpy) / (numberOfSteps * 1.0 - 1.0); - for (int i = 0; i < numberOfSteps; i++) { - enthalpies[i] = minEnthalpy + i * step; - enthalpiesLOG[i] = enthalpies[i]; - } + thermoSystem.setTemperature(stdTemp); + thermoSystem.setPressure(stdPres); + + thermoOps.TPflash(); + + // GOR = thermoSystem.getPhase(0).getTotalVolume() / + // thermoSystem.getPhase(1).getTotalVolume(); + // GLR = thermoSystem.getPhase(0).getTotalVolume() / + // thermoSystem.getPhase(1).getTotalVolume(); + } + + /** + *

+ * calcRSWTOB. + *

+ */ + public void calcRSWTOB() { + thermoSystem.init(0); + thermoSystem.init(1); + if (thermoSystem.getPhase(0).hasComponent("water")) { + RSWTOB = thermoSystem.getPhase(0).getComponent("water").getNumberOfmoles() + * thermoSystem.getPhase(0).getComponent("water").getMolarMass() + / (thermoSystem.getTotalNumberOfMoles() * thermoSystem.getMolarMass()); + } else { + RSWTOB = 0.0; + } + } + + /** {@inheritDoc} */ + @Override + public void run() { + calcRSWTOB(); + logger.info("RSWTOB " + RSWTOB); + nProps = 29; + props = new double[nProps][pressures.length][enthalpies.length]; + units = new String[nProps]; + names = new String[nProps]; + GLW = 0; + GL = 0; + GW = 0; + VLS = 0; + LWS = 0; + VWS = 0; + maxPressure = pressures[pressures.length - 1]; + minPressure = pressures[0]; + // maxTemperature = enthalpies[enthalpies.length - 1]; + // minTemperature = enthalpies[0]; + // thermoSystem.setTemperature(minTemperature); + thermoSystem.setPressure(maxPressure); + thermoOps.TPflash(); + if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("aqueous") + && thermoSystem.hasPhaseType("oil")) { + GLW = 1; + } + if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("aqueous")) { + GW = 1; + } + if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("oil")) { + GL = 1; } - /** - *

- * calcPhaseEnvelope. - *

- */ - public void calcPhaseEnvelope() { + // int startGasTemperatures = 0, startLiquid = 0, startWater = 0; + boolean acceptedFlash = true; + for (int j = 0; j < enthalpies.length; j++) { + // thermoSystem.setTemperature(enthalpies[j]); + for (int i = 0; i < pressures.length; i++) { + thermoSystem.setPressure(pressures[i]); try { - thermoOps.calcPTphaseEnvelope(); - TC = thermoSystem.getTC() - 273.15; - PC = thermoSystem.getPC() * 1e5; + logger.info("PHflash... " + thermoSystem.getTemperature() + " pressure " + + thermoSystem.getPressure()); + thermoOps.PHflash(enthalpies[j], 0); + logger + .info(" temperature " + thermoSystem.getTemperature() + " enthalpy " + enthalpies[j]); + thermoSystem.init(3); + thermoSystem.initPhysicalProperties(); + acceptedFlash = true; } catch (Exception e) { - logger.error("error", e); + acceptedFlash = false; + logger.info("fail temperature " + thermoSystem.getTemperature() + " fail pressure " + + thermoSystem.getPressure()); + + thermoSystem.display(); + logger.error("error", e); } - } - /** - *

- * calcBubP. - *

- * - * @param enthalpies an array of {@link double} objects - * @return an array of {@link double} objects - */ - public double[] calcBubP(double[] enthalpies) { - double[] bubP = new double[enthalpies.length]; - bubPLOG = new double[enthalpies.length]; - for (int i = 0; i < enthalpies.length; i++) { - thermoSystem.setTemperature(enthalpies[i]); - try { - thermoOps.bubblePointPressureFlash(false); - bubP[i] = thermoSystem.getPressure(); - } catch (Exception e) { - logger.error("error", e); - bubP[i] = 0; - return bubP; + /* + * logger.info("water density " + + * thermoSystem.getPhase(2).getPhysicalProperties().getDensity()); logger.info("RSW " + + * thermoSystem.getPhase(0).getComponent("water").getx() * + * thermoSystem.getPhase(0).getComponent("water").getMolarMass() / + * thermoSystem.getPhase(0).getMolarMass()); logger.info("surf tens oil-water " + + * thermoSystem.getInterphaseProperties().getSurfaceTension(1, 2)); + * logger.info("surf tens gas-water " + + * thermoSystem.getInterphaseProperties().getSurfaceTension(0, 2)); + */ + int k = 0; + if (thermoSystem.hasPhaseType("gas") && acceptedFlash) { + int phaseNumb = thermoSystem.getPhaseNumberOfPhase("gas"); + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); + names[k] = "GAS DENSITY"; + units[k] = "KG/M3"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; + names[k] = "DRHOG/DP"; + units[k] = "S2/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); + names[k] = "DRHOG/DT"; + units[k] = "KG/M3-K"; + k++; + + if (thermoSystem.hasPhaseType("oil")) { + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getBeta() + * thermoSystem.getPhase(phaseNumb).getMolarMass() + / (thermoSystem.getPhase(phaseNumb).getBeta() + * thermoSystem.getPhase(phaseNumb).getMolarMass() + + thermoSystem.getPhase("oil").getBeta() + * thermoSystem.getPhase("oil").getMolarMass()); + } else { + props[k][i][j] = 1.0; // thermoSystem.getPhase(phaseNumb).getBeta() * + // thermoSystem.getPhase(phaseNumb).getMolarMass() / + // thermoSystem.getMolarMass(); + } + names[k] = "GAS MASS FRACTION"; + units[k] = "-"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); + names[k] = "GAS VISCOSITY"; + units[k] = "NS/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "GAS HEAT CAPACITY"; + units[k] = "J/KG-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEnthalpy() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "GAS ENTHALPY"; + units[k] = "J/KG"; + k++; + + props[k][i][j] = + thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getConductivity(); + names[k] = "GAS THERMAL CONDUCTIVITY"; + units[k] = "W/M-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "GAS ENTROPY"; + units[k] = "J/KG/K"; + k++; + hasGasValues = true; + // set gas properties + } else if (continuousDerivativesExtrapolation && hasGasValues) { + do { + /* + * if (j>1 && i>1) { props[k][i][j] = 0.5 * ((props[k][i][j - 1] + (props[k][i][j - 1] - + * props[k][i][j - 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - + * enthalpies[j - 1])) + (props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) + * / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]))); if + * (names[k].equals("GAS MASS FRACTION") && props[k][i][j] < 0) { props[k][i][j] = 0; } + * } + */ + + /* + * if (j > 1) { props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - + * props[k][i][j - 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - + * enthalpies[j - 1]); } + */ + if (i > 1) { + props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) + / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + // } //else if (j < 2) { + // props[k][i][j] = 0; //props[k][i - 1][j] + (props[k][i - 1][j] - + // props[k][i - + // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - + // pressures[i + // - 1]); + // } else { + // props[k][i][j] = 0; //props[k][i - 1][j - 1] + (props[k][i][j - 1] - + // props[k][i][j - 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * + // (enthalpies[j] - enthalpies[j - 1]) + (props[k][i - 1][j] - + // props[k][i - + // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - + // pressures[i + // - 1]); + // double newTemp = pressures[i]; + // double vall = xcoef[k].get(0, 0) + newTemp * (xcoef[k].get(1, 0) + + // newTemp * + // (xcoef[k].get(2, 0) + newTemp * xcoef[k].get(3, 0))); + // props[k][i][j] = vall; + // if(i>0 && props[k][i-1][j]>1e-10) props[k][i][j] = + // props[k][i-1][j]*pressures[i]/pressures[i-1]; + + if (names[k].equals("GAS MASS FRACTION") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("GAS DENSITY") && props[k][i][j] < 0) { + props[k][i][j] = 0.1; + } + if (names[k].equals("GAS VISCOSITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("GAS THERMAL CONDUCTIVITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + } + if (j > 1) { + props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) + / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - enthalpies[j - 1]); + if (names[k].equals("GAS MASS FRACTION") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("GAS MASS FRACTION") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("GAS DENSITY") && props[k][i][j] <= 0) { + props[k][i][j] = 0.1; + } + if (names[k].equals("GAS VISCOSITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("GAS THERMAL CONDUCTIVITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("GAS HEAT CAPACITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } } - bubPLOG[i] = bubP[i] * 1e5; + k++; + } while (k < 9); // names[k] = "GAS DENSITY"; + // units[k] = "KG/M3"; + /* + * } else if (false && !hasGasValues) { startGasTemperatures = j; + */ + } else { + gasSystem.setTemperature(enthalpies[j]); + gasSystem.setPressure(pressures[i]); + gasSystem.init(3); + gasSystem.initPhysicalProperties(); + // gasSystem.display(); + props[k][i][j] = gasSystem.getPhase(0).getPhysicalProperties().getDensity(); + names[k] = "GAS DENSITY"; + units[k] = "KG/M3"; + k++; + props[k][i][j] = gasSystem.getPhase(0).getdrhodP() / 1.0e5; + names[k] = "DRHOG/DP"; + units[k] = "S2/M2"; + k++; + props[k][i][j] = gasSystem.getPhase(0).getdrhodT(); + names[k] = "DRHOG/DT"; + units[k] = "KG/M3-K"; + k++; + + props[k][i][j] = 0.0; // thermoSystem.getPhase(phaseNumb).getBeta() * + // thermoSystem.getPhase(phaseNumb).getMolarMass() / + // thermoSystem.getMolarMass(); + names[k] = "GAS MASS FRACTION"; + units[k] = "-"; + k++; + + props[k][i][j] = gasSystem.getPhase(0).getPhysicalProperties().getViscosity(); + names[k] = "GAS VISCOSITY"; + units[k] = "NS/M2"; + k++; + + props[k][i][j] = + gasSystem.getPhase(0).getCp() / gasSystem.getPhase(0).getNumberOfMolesInPhase() + / gasSystem.getPhase(0).getMolarMass(); + names[k] = "GAS HEAT CAPACITY"; + units[k] = "J/KG-K"; + k++; + + props[k][i][j] = + gasSystem.getPhase(0).getEnthalpy() / gasSystem.getPhase(0).getNumberOfMolesInPhase() + / gasSystem.getPhase(0).getMolarMass(); + names[k] = "GAS ENTHALPY"; + units[k] = "J/KG"; + k++; + + props[k][i][j] = gasSystem.getPhase(0).getPhysicalProperties().getConductivity(); + names[k] = "GAS THERMAL CONDUCTIVITY"; + units[k] = "W/M-K"; + k++; + + props[k][i][j] = + gasSystem.getPhase(0).getEntropy() / gasSystem.getPhase(0).getNumberOfMolesInPhase() + / gasSystem.getPhase(0).getMolarMass(); + names[k] = "GAS ENTROPY"; + units[k] = "J/KG/K"; + k++; } - return bubP; - } - /** - *

- * calcDewP. - *

- * - * @param enthalpies an array of {@link double} objects - * @return an array of {@link double} objects - */ - public double[] calcDewP(double[] enthalpies) { - double[] dewP = new double[enthalpies.length]; - dewPLOG = new double[enthalpies.length]; - for (int i = 0; i < enthalpies.length; i++) { - thermoSystem.setTemperature(enthalpies[i]); - try { - thermoOps.dewPointPressureFlashHC(); - dewP[i] = thermoSystem.getPressure(); - } catch (Exception e) { - logger.error("error", e); - dewP[i] = 0; - return dewP; + if (thermoSystem.hasPhaseType("oil") && acceptedFlash) { + int phaseNumb = thermoSystem.getPhaseNumberOfPhase("oil"); + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); + names[k] = "LIQUID DENSITY"; + units[k] = "KG/M3"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; + names[k] = "DRHOL/DP"; + units[k] = "S2/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); + names[k] = "DRHOL/DT"; + units[k] = "KG/M3-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); + names[k] = "LIQUID VISCOSITY"; + units[k] = "NS/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "LIQUID HEAT CAPACITY"; + units[k] = "J/KG-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEnthalpy() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "LIQUID ENTHALPY"; + units[k] = "J/KG"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "LIQUID ENTROPY"; + units[k] = "J/KG/K"; + k++; + + props[k][i][j] = + thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getConductivity(); + names[k] = "LIQUID THERMAL CONDUCTIVITY"; + units[k] = "W/M-K"; + k++; + hasOilValues = true; + } else if (continuousDerivativesExtrapolation && hasOilValues) { + do { + // if (i>1) { + // props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - + // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - + // pressures[i + // - 1]); + // } + // if (j>1 && i>1) { + // props[k][i][j] = 0.5 * ((props[k][i - 1][j] + (props[k][i - 1][j] - + // props[k][i - 2][j]) / (enthalpies[i - 1] - enthalpies[i - 2]) * + // (enthalpies[i] - enthalpies[i - 1])) + (props[k][i - 1][j] + (props[k][i + // - + // 1][j] - props[k][i - 2][j]) / (pressures[i - 1] - pressures[i - 2]) * + // (pressures[i] - pressures[i - 1]))); + // } + /* + * if (j > 2) { props[k][i][j] = 0.5*((props[k][i][j - 1] + (props[k][i][j - 1] - + * props[k][i][j - 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - + * enthalpies[j - 1])) +(props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 3]) + * / (enthalpies[j - 1] - enthalpies[j - 3]) * (enthalpies[j] - enthalpies[j - 1]))); } + */ + if (j < 2 && i < 2) { + if (names[k].equals("LIQUID DENSITY") && props[k][i][j] <= 0) { + props[k][i][j] = 100; + } + if (names[k].equals("LIQUID DENSITY") && props[k][i][j] > 900) { + props[k][i][j] = 900; + } + if (names[k].equals("LIQUID VISCOSITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("LIQUID THERMAL CONDUCTIVITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("LIQUID HEAT CAPACITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + } + if (j > 1) { + props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) + / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - enthalpies[j - 1]); + if (names[k].equals("LIQUID DENSITY") && props[k][i][j] <= 0) { + props[k][i][j] = 100; + } + if (names[k].equals("LIQUID DENSITY") && props[k][i][j] > 900) { + props[k][i][j] = 900; + } + if (names[k].equals("LIQUID VISCOSITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("LIQUID THERMAL CONDUCTIVITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("LIQUID HEAT CAPACITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + } + if (i > 1) { + props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) + / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + if (names[k].equals("LIQUID DENSITY") && props[k][i][j] <= 0) { + props[k][i][j] = 100; + } + if (names[k].equals("LIQUID DENSITY") && props[k][i][j] > 900) { + props[k][i][j] = 900; + } + if (names[k].equals("LIQUID VISCOSITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("LIQUID THERMAL CONDUCTIVITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("LIQUID HEAT CAPACITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + } + + // if (j > 1 && TLC==3) { + // props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j + // - + // 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - + // enthalpies[j + // - 1]); + // if (j>1) { + // props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j + // - + // 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - + // enthalpies[j + // - 1]); + // } else if (j < 2) { + // props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - + // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - + // pressures[i + // - 1]); + // } else { + // props[k][i][j] = props[k][i - 1][j - 1] + (props[k][i][j - 1] - + // props[k][i][j + // - 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - + // enthalpies[j - 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / + // (pressures[i + // - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + // } + // props[k][i][j] = 0.0;*/ + // } + k++; + } while (k < 17); // names[k] = "GAS DENSITY"; + // units[k] = "KG/M3"; + } else { + oilSystem.setPhaseType(0, 0); + // oilSystem.setTemperature(enthalpies[j]); + oilSystem.setPressure(pressures[i]); + oilSystem.init(3); + oilSystem.initPhysicalProperties(); + + props[k][i][j] = oilSystem.getPhase(0).getPhysicalProperties().getDensity(); + names[k] = "LIQUID DENSITY"; + units[k] = "KG/M3"; + k++; + + props[k][i][j] = oilSystem.getPhase(0).getdrhodP() / 1.0e5; + names[k] = "DRHOL/DP"; + units[k] = "S2/M2"; + k++; + + props[k][i][j] = oilSystem.getPhase(0).getdrhodT(); + names[k] = "DRHOL/DT"; + units[k] = "KG/M3-K"; + k++; + + props[k][i][j] = oilSystem.getPhase(0).getPhysicalProperties().getViscosity(); + names[k] = "LIQUID VISCOSITY"; + units[k] = "NS/M2"; + k++; + + props[k][i][j] = + oilSystem.getPhase(0).getCp() / oilSystem.getPhase(0).getNumberOfMolesInPhase() + / oilSystem.getPhase(0).getMolarMass(); + names[k] = "LIQUID HEAT CAPACITY"; + units[k] = "J/KG-K"; + k++; + + props[k][i][j] = oilSystem.getPhase(0).getTemperature() - 273.15; + names[k] = "LIQUID TEMPERATURE"; + units[k] = "C"; + k++; + + props[k][i][j] = + oilSystem.getPhase(0).getEntropy() / oilSystem.getPhase(0).getNumberOfMolesInPhase() + / oilSystem.getPhase(0).getMolarMass(); + names[k] = "LIQUID ENTROPY"; + units[k] = "J/KG/K"; + k++; + + props[k][i][j] = oilSystem.getPhase(0).getPhysicalProperties().getConductivity(); + names[k] = "LIQUID THERMAL CONDUCTIVITY"; + units[k] = "W/M-K"; + k++; + } // setOilProperties(); + // set gas properties + + if (thermoSystem.hasPhaseType("aqueous") && acceptedFlash) { + int phaseNumb = thermoSystem.getPhaseNumberOfPhase("aqueous"); + if (thermoSystem.hasPhaseType("gas")) { + props[k][i][j] = thermoSystem.getPhase("gas").getComponent("water").getx() + * thermoSystem.getPhase("gas").getComponent("water").getMolarMass() + / thermoSystem.getPhase("gas").getMolarMass(); + } + if (thermoSystem.hasPhaseType("oil")) { + props[k][i][j] += thermoSystem.getPhase("oil").getComponent("water").getx() + * thermoSystem.getPhase("oil").getComponent("water").getMolarMass() + / thermoSystem.getPhase("oil").getMolarMass(); + } + names[k] = "WATER VAPOR MASS FRACTION"; + units[k] = "-"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); + names[k] = "WATER DENSITY"; + units[k] = "KG/M3"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; + names[k] = "DRHOWAT/DP"; + units[k] = "S2/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); + names[k] = "DRHOWAT/DT"; + units[k] = "KG/M3-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); + names[k] = "WATER VISCOSITY"; + units[k] = "NS/M2"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "WATER HEAT CAPACITY"; + units[k] = "J/KG-K"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getTemperature() - 273.15; + names[k] = "WATER TEMPERATURE"; + units[k] = "C"; + k++; + + props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() + / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() + / thermoSystem.getPhase(phaseNumb).getMolarMass(); + names[k] = "WATER ENTROPY"; + units[k] = "J/KG/K"; + k++; + + props[k][i][j] = + thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getConductivity(); + names[k] = "WATER THERMAL CONDUCTIVITY"; + units[k] = "W/M-K"; + k++; + hasWaterValues = true; + } else if (continuousDerivativesExtrapolation && hasWaterValues) { + do { + /* + * if (j > 2) { props[k][i][j] = 0.5*((props[k][i][j - 1] + (props[k][i][j - 1] - + * props[k][i][j - 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - + * enthalpies[j - 1])) +(props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 3]) + * / (enthalpies[j - 1] - enthalpies[j - 3]) * (enthalpies[j] - enthalpies[j - 1]))); if + * (names[k].equals("WATER VAPOR MASS FRACTION") && props[k][i][j] > 1) { props[k][i][j] + * = 1; } } + */ + if (j > 1) { + props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) + / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - enthalpies[j - 1]); + if (names[k].equals("WATER VAPOR MASS FRACTION") && props[k][i][j] > 1) { + props[k][i][j] = 1; + } + if (names[k].equals("WATER DENSITY") && props[k][i][j] <= 0) { + props[k][i][j] = 1000; + } + if (names[k].equals("WATER VISCOSITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("WATER THERMAL CONDUCTIVITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("WATER VAPOR MASS FRACTION") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("WATER HEAT CAPACITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + } + /* + * if (j > 1 && TLC == 3) { props[k][i][j] = props[k][i][j-1] + (props[k][i][j-1] - + * props[k][i][j-2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - + * enthalpies[j - 1]); if (j>1) { props[k][i][j] = props[k][i][j-1] + (props[k][i][j-1] + * - props[k][i][j-2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - + * enthalpies[j - 1]); if (names[k].equals("WATER VAPOR MASS FRACTION") && + * props[k][i][j] > 1) { props[k][i][j] = 1; } } + */ + if (i > 1) { + props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) + / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + if (names[k].equals("WATER VAPOR MASS FRACTION") && props[k][i][j] > 1) { + props[k][i][j] = 1; + } + + if (names[k].equals("WATER DENSITY") && props[k][i][j] <= 0) { + props[k][i][j] = 1000; + } + if (names[k].equals("WATER VISCOSITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("WATER THERMAL CONDUCTIVITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("WATER VAPOR MASS FRACTION") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } + if (names[k].equals("WATER HEAT CAPACITY") && props[k][i][j] < 0) { + props[k][i][j] = 0; + } } - dewPLOG[i] = dewP[i] * 1e5; + /* + * if (i < 2) { props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - + * props[k][i][j - 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - + * enthalpies[j - 1]); } else if (j < 2) { props[k][i][j] = props[k][i - 1][j] + + * (props[k][i - 1][j] - props[k][i - 2][j]) / (pressures[i - 1] - pressures[i - 2]) * + * (pressures[i] - pressures[i - 1]); } else { props[k][i][j] = props[k][i - 1][j - 1] + + * (props[k][i][j - 1] - props[k][i][j - 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * + * (enthalpies[j] - enthalpies[j - 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / + * (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); } + * props[k][i][j] = 0.0; + */ + k++; + } while (k < 26); // names[k] = "GAS DENSITY"; + // units[k] = "KG/M3"; + } else { + waterSystem.setTemperature(enthalpies[j]); + waterSystem.setPressure(pressures[i]); + waterSystem.setPhaseType(0, 0); + waterSystem.init(3); + waterSystem.initPhysicalProperties(); + + if (thermoSystem.getPhase(0).hasComponent("water")) { + props[k][i][j] = thermoSystem.getPhase(0).getComponent("water").getz() + * thermoSystem.getPhase(0).getComponent("water").getMolarMass() + / thermoSystem.getPhase(0).getMolarMass();; + } else { + props[k][i][j] = 0.0; + } + names[k] = "WATER VAPOR MASS FRACTION"; + units[k] = "-"; + k++; + + props[k][i][j] = waterSystem.getPhase(0).getPhysicalProperties().getDensity(); + names[k] = "WATER DENSITY"; + units[k] = "KG/M3"; + k++; + + props[k][i][j] = waterSystem.getPhase(0).getdrhodP() / 1.0e5; + names[k] = "DRHOWAT/DP"; + units[k] = "S2/M2"; + k++; + + props[k][i][j] = waterSystem.getPhase(0).getdrhodT(); + names[k] = "DRHOWAT/DT"; + units[k] = "KG/M3-K"; + k++; + + props[k][i][j] = waterSystem.getPhase(0).getPhysicalProperties().getViscosity(); + names[k] = "WATER VISCOSITY"; + units[k] = "NS/M2"; + k++; + + props[k][i][j] = + waterSystem.getPhase(0).getCp() / waterSystem.getPhase(0).getNumberOfMolesInPhase() + / waterSystem.getPhase(0).getMolarMass(); + names[k] = "WATER HEAT CAPACITY"; + units[k] = "J/KG-K"; + k++; + + props[k][i][j] = waterSystem.getPhase(0).getTemperature(); + names[k] = "WATER TEMPERATURE"; + units[k] = "C"; + k++; + + props[k][i][j] = waterSystem.getPhase(0).getEntropy() + / waterSystem.getPhase(0).getNumberOfMolesInPhase() + / waterSystem.getPhase(0).getMolarMass(); + names[k] = "WATER ENTROPY"; + units[k] = "J/KG/K"; + k++; + + props[k][i][j] = waterSystem.getPhase(0).getPhysicalProperties().getConductivity(); + names[k] = "WATER THERMAL CONDUCTIVITY"; + units[k] = "W/M-K"; + k++; } - return dewP; - } - /** - *

- * calcBubT. - *

- * - * @param pressures an array of {@link double} objects - * @return an array of {@link double} objects - */ - public double[] calcBubT(double[] pressures) { - double[] bubTemps = new double[pressures.length]; - for (int i = 0; i < pressures.length; i++) { - thermoSystem.setPressure(pressures[i]); - try { - thermoOps.bubblePointTemperatureFlash(); - bubT[i] = thermoSystem.getPressure(); - } catch (Exception e) { - logger.error("error", e); - bubT[i] = 0.0; + if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("oil") && acceptedFlash) { + props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( + thermoSystem.getPhaseNumberOfPhase("gas"), thermoSystem.getPhaseNumberOfPhase("oil")); + names[k] = "VAPOR-LIQUID SURFACE TENSION"; + units[k] = "N/M"; + k++; + } else { + if (continuousDerivativesExtrapolation && (i >= 2 || j >= 2)) { + if (VLS == 1) { + props[k][i][j] = 5.0e-3; + // k++; + } + // if (j>1 && thermoSystem.hasPhaseType("gas") && VLS==0 && acceptedFlash) { + if (j > 1 && (GLW == 1 || GL == 1) && VLS == 0) { + props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) + / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - enthalpies[j - 1]); + /* + * if (names[k].equals("VAPOR-LIQUID SURFACE TENSION") && props[k][i][j] < 5.0e-3) { + * props[k][i][j] = 7.5e-3; VLS=1; } if + * (names[k].equals("VAPOR-LIQUID SURFACE TENSION") && props[k][i][j] > 30.0e-3) { + * props[k][i][j] = 20.0e-3; VLS=1; } + */ + if (props[k][i][j] < 5.0e-3) { + props[k][i][j] = 5.0e-3; + VLS = 1; + } + if (props[k][i][j] > 1.1 * props[k][i][j - 1]) { + props[k][i][j] = props[k][i][j - 1]; + } + if (props[k][i][j] < 0.9 * props[k][i][j - 1]) { + props[k][i][j] = props[k][i][j - 1]; + } + // } else if (i>1 && thermoSystem.hasPhaseType("oil") && VLS == 0 && + // acceptedFlash) { + // } else if (i > 1 && TLC < 3 && VLS==0) { + } else if (i > 1 && (GLW == 0 || GL == 0) && VLS == 0) { + props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) + / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + if (props[k][i][j] < 5.0e-3) { + props[k][i][j] = 5.0e-3; + VLS = 1; + } + if (props[k][i][j] > 1.1 * props[k][i - 1][j]) { + props[k][i][j] = props[k][i - 1][j]; + } + if (props[k][i][j] < 0.9 * props[k][i - 1][j]) { + props[k][i][j] = props[k][i - 1][j]; + } + } else if (j > 0 && i > 0) { + props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); + } else if (j > 0) { + props[k][i][j] = props[k][i][j - 1]; + } else if (i > 0) { + props[k][i][j] = props[k][i - 1][j]; + } else { + // props[k][i][j] = props[k][i - 1][j - 1] + (props[k][i][j - 1] - + // props[k][i][j + // - 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - + // enthalpies[j - 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / + // (pressures[i + // - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + props[k][i][j] = 10.0e-3; } - } - return bubTemps; - } - /** - *

- * initCalc. - *

- */ - public void initCalc() { - double stdTemp = 288.15, stdPres = 1.01325; - // double GOR, GLR; - double molfracs[] = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; - double MW[] = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; - double dens[] = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; - String components[] = new String[thermoSystem.getPhase(0).getNumberOfComponents()]; - - for (int i = 0; i < molfracs.length; i++) { - molfracs[i] = thermoSystem.getPhase(0).getComponent(i).getz(); - components[i] = thermoSystem.getPhase(0).getComponent(i).getComponentName(); - MW[i] = thermoSystem.getPhase(0).getComponent(i).getMolarMass() * 1000; - dens[i] = thermoSystem.getPhase(0).getComponent(i).getNormalLiquidDensity(); + // k++; + } else if (j > 0 && i > 0) { + props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); + // k++; + } else if (j > 0) { + props[k][i][j] = props[k][i][j - 1]; + // k++; + } else if (i > 0) { + props[k][i][j] = props[k][i - 1][j]; + // k++; + } else { + props[k][i][j] = 10.0e-3; + names[k] = "VAPOR-LIQUID SURFACE TENSION"; + units[k] = "N/M"; + // k++; + } + k++; } - thermoSystem.setTemperature(stdTemp); - thermoSystem.setPressure(stdPres); - - thermoOps.TPflash(); + if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("aqueous") + && acceptedFlash) { + props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( + thermoSystem.getPhaseNumberOfPhase("gas"), + thermoSystem.getPhaseNumberOfPhase("aqueous")); + names[k] = "VAPOR-WATER SURFACE TENSION"; + units[k] = "N/M"; + k++; + } else { + if (continuousDerivativesExtrapolation && (i >= 2 || j >= 2)) { + if (VWS == 1) { + props[k][i][j] = 5.0e-3; + // k++; + } + // if (j>1 && thermoSystem.hasPhaseType("gas") && VWS == 0 && acceptedFlash) + // { + // if (j > 1 && TLC==3 && VWS==0) { + if (j > 1 && (GLW == 1 || GW == 1) && VWS == 0) { + props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) + / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - enthalpies[j - 1]); + /* + * if (names[k].equals("VAPOR-WATER SURFACE TENSION") && props[k][i][j] < 10.0e-3) { + * props[k][i][j] = 35.0e-3; VWS=1; } if + * (names[k].equals("VAPOR-WATER SURFACE TENSION") && props[k][i][j] > 150.0e-3) { + * props[k][i][j] = 105.0e-3; VWS=1; } + */ + if (props[k][i][j] < 5.0e-3) { + props[k][i][j] = 5.0e-3; + VWS = 1; + } + if (props[k][i][j] > 1.1 * props[k][i][j - 1]) { + props[k][i][j] = props[k][i][j - 1]; + } + if (props[k][i][j] < 0.9 * props[k][i][j - 1]) { + props[k][i][j] = props[k][i][j - 1]; + } + // } else if (j>1 && thermoSystem.hasPhaseType("aqueous") && VWS ==0 && + // acceptedFlash) { + // } else if (i > 1 && TLC < 3 && VWS==0) { + } else if (i > 1 && (GLW == 0 || GL == 0) && VWS == 0) { + props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) + / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + /* + * if (names[k].equals("VAPOR-WATER SURFACE TENSION") && props[k][i][j] < 10.0e-3) { + * props[k][i][j] = 35.0e-3; VWS=1; } if + * (names[k].equals("VAPOR-WATER SURFACE TENSION") && props[k][i][j] > 150.0e-3) { + * props[k][i][j] = 105.0e-3; VWS=1; } + */ + if (props[k][i][j] < 5.0e-3) { + props[k][i][j] = 5.0e-3; + VWS = 1; + } + if (props[k][i][j] > 1.1 * props[k][i - 1][j]) { + props[k][i][j] = props[k][i - 1][j]; + } + if (props[k][i][j] < 0.9 * props[k][i - 1][j]) { + props[k][i][j] = props[k][i - 1][j]; + } + } else if (j > 0 && i > 0) { + props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); + } else if (j > 0) { + props[k][i][j] = props[k][i][j - 1]; + } else if (i > 0) { + props[k][i][j] = props[k][i - 1][j]; + } else { + // props[k][i][j] = props[k][i - 1][j - 1] + (props[k][i][j - 1] - + // props[k][i][j + // - 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - + // enthalpies[j - 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / + // (pressures[i + // - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + props[k][i][j] = 60.0e-3; + } - // GOR = thermoSystem.getPhase(0).getTotalVolume() / - // thermoSystem.getPhase(1).getTotalVolume(); - // GLR = thermoSystem.getPhase(0).getTotalVolume() / - // thermoSystem.getPhase(1).getTotalVolume(); - } + // k++; + } else if (j > 0 && i > 0) { + props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); + // k++; + } else if (j > 0) { + props[k][i][j] = props[k][i][j - 1]; + // k++; + } else if (i > 0) { + props[k][i][j] = props[k][i - 1][j]; + // k++; + } else { + props[k][i][j] = 60.0e-3; + names[k] = "VAPOR-WATER SURFACE TENSION"; + units[k] = "N/M"; + // k++; + } + k++; + } - /** - *

- * calcRSWTOB. - *

- */ - public void calcRSWTOB() { - thermoSystem.init(0); - thermoSystem.init(1); - if (thermoSystem.getPhase(0).hasComponent("water")) { - RSWTOB = thermoSystem.getPhase(0).getComponent("water").getNumberOfmoles() - * thermoSystem.getPhase(0).getComponent("water").getMolarMass() - / (thermoSystem.getTotalNumberOfMoles() * thermoSystem.getMolarMass()); + if (thermoSystem.hasPhaseType("oil") && thermoSystem.hasPhaseType("aqueous") + && acceptedFlash) { + props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( + thermoSystem.getPhaseNumberOfPhase("oil"), + thermoSystem.getPhaseNumberOfPhase("aqueous")); + names[k] = "LIQUID-WATER SURFACE TENSION"; + units[k] = "N/M"; + k++; } else { - RSWTOB = 0.0; + if (continuousDerivativesExtrapolation && (i >= 2 || j >= 2)) { + if (LWS == 1) { + props[k][i][j] = 5.0e-3; + // k++; + } + if (j > 1 && LWS == 0) { + // if (j > 1 && TLC==3 && LWS==0) { + // if (j>1 && LWS==0 && acceptedFlash) { + props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) + / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - enthalpies[j - 1]); + /* + * if (j > 2) { props[k][i][j] = 0.5*((props[k][i][j - 1] + (props[k][i][j - 1] - + * props[k][i][j - 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - + * enthalpies[j - 1])) +(props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - + * 3]) / (enthalpies[j - 1] - enthalpies[j - 3]) * (enthalpies[j] - enthalpies[j - + * 1]))); if (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] < + * 10.0e-3) { props[k][i][j] = 25.0e-3; LWS=1; } + * + * if (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] > 120.0e-3) { + * props[k][i][j] = 80.0e-3; LWS=1; } } + */ + + /* + * if (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] < 10.0e-3) { + * props[k][i][j] = 25.0e-3; LWS=1; } if + * (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] > 120.0e-3) { + * props[k][i][j] = 80.0e-3; LWS=1; } + */ + if (props[k][i][j] < 5.0e-3) { + props[k][i][j] = 5.0e-3; + LWS = 1; + } + if (props[k][i][j] > 1.1 * props[k][i][j - 1]) { + props[k][i][j] = props[k][i][j - 1]; + } + if (props[k][i][j] < 0.9 * props[k][i][j - 1]) { + props[k][i][j] = props[k][i][j - 1]; + } + // } else if (i > 1 && LWS==0 && acceptedFlash) { + // } else if (i > 1 && TLC < 3 && LWS==0) { + // props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - + // props[k][i - + // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - + // pressures[i + // - 1]); + /* + * if (i > 2) { props[k][i][j] = 0.5*((props[k][i - 1][j] + (props[k][i - 1][j] - + * props[k][i - 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - + * pressures[i - 1])) +(props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 3][j]) + * / (pressures[i - 1] - pressures[i - 3]) * (pressures[i] - pressures[i - 1]))); if + * (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] < 10.0e-3) { + * props[k][i][j] = 25.0e-3; LWS=1; } + * + * if (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] > 120.0e-3) { + * props[k][i][j] = 80.0e-3; LWS=1; } } + */ + + /* + * if (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] < 10.0e-3) { + * props[k][i][j] = 25.0e-3; LWS=1; } if + * (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] > 120.0e-3) { + * props[k][i][j] = 80.0e-3; LWS=1; } + */ + + /* + * if (props[k][i][j] < 5.0e-3) { props[k][i][j] = 5.0e-3; LWS = 1; } if + * (props[k][i][j] > 1.1* props[k][i - 1][j]) { props[k][i][j] = props[k][i - 1][j]; } + * if (props[k][i][j] < 0.9* props[k][i - 1][j]) { props[k][i][j] = props[k][i - + * 1][j]; } + */ + // } else if (j >0 && i > 0) { + // props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); + } else if (j > 0) { + props[k][i][j] = props[k][i][j - 1]; + } else if (i > 0) { + props[k][i][j] = props[k][i - 1][j]; + } else { + // props[k][i][j] = props[k][i - 1][j - 1] + (props[k][i][j - 1] - + // props[k][i][j + // - 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - + // enthalpies[j - 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / + // (pressures[i + // - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); + props[k][i][j] = 40.0e-3; + } + + // k++; + // } else if (j >0 && i > 0) { + // props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); + // k++; + } else if (j > 0) { + props[k][i][j] = props[k][i][j - 1]; + // k++; + } else if (i > 0) { + props[k][i][j] = props[k][i - 1][j]; + // k++; + } else { + props[k][i][j] = 40.0e-3; + names[k] = "LIQUID-WATER SURFACE TENSION"; + units[k] = "N/M"; + // k++; + } + k++; } + } } - - /** {@inheritDoc} */ - @Override - public void run() { - calcRSWTOB(); - logger.info("RSWTOB " + RSWTOB); - nProps = 29; - props = new double[nProps][pressures.length][enthalpies.length]; - units = new String[nProps]; - names = new String[nProps]; - GLW = 0; - GL = 0; - GW = 0; - VLS = 0; - LWS = 0; - VWS = 0; - maxPressure = pressures[pressures.length - 1]; - minPressure = pressures[0]; - // maxTemperature = enthalpies[enthalpies.length - 1]; - // minTemperature = enthalpies[0]; - // thermoSystem.setTemperature(minTemperature); - thermoSystem.setPressure(maxPressure); - thermoOps.TPflash(); - if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("aqueous") - && thermoSystem.hasPhaseType("oil")) { - GLW = 1; + logger.info("Finished TPflash..."); + if (thermoSystem.getPhase(0).hasComponent("water")) { + thermoSystem.removeComponent("water"); + } + // bubP = calcBubP(enthalpies); + // dewP = calcDewP(enthalpies); + // bubT = calcBubT(enthalpies); + logger.info("Finished creating arrays"); + // BicubicSplineInterpolatingFunction funcGasDens = + // interpolationFunc.interpolate(pressures, enthalpies, props[0]); + // logger.info("interpolated value " + funcGasDens.value(40, 298.0)); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + logger.info("TC " + TC + " PC " + PC); + for (int i = 0; i < pressures.length; i++) { + thermoSystem.setPressure(pressures[i]); + for (int j = 0; j < enthalpies.length; j++) { + logger.info("pressure " + pressureLOG[i] + " enthalpy " + enthalpiesLOG[j]); // + " + // ROG " + // + + // ROG[i][j] + // + " + // ROL " + // + + // ROL[i][j]); + } + } + writeOLGAinpFile(fileName); + } + + /** + *

+ * writeOLGAinpFile2. + *

+ * + * @param filename a {@link java.lang.String} object + */ + public void writeOLGAinpFile2(String filename) { + /* + * try { writer = new BufferedWriter(new OutputStreamWriter( new + * FileOutputStream("C:/Users/Kjetil Raul/Documents/Master KRB/javacode_ROG55.txt" ), "utf-8")); + * writer.write("GAS DENSITY (KG/M3) = ("); for (int i = 0; i < pressures.length; i++) { + * thermoSystem.setPressure(pressures[i]); for (int j = 0; j < enthalpies.length; j++) { + * thermoSystem.setTemperature(enthalpies[j]); writer.write(ROG[i][j] + ","); } } + * writer.write(")"); } catch (IOException ex) { // report } finally { try { } writer.close(); } + * catch (Exception ex) { } } + */ + try (Writer writer = + new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName), "utf-8"))) { + writer.write("'WATER-OPTION ENTROPY NONEQ '" + "\n"); + + writer.write(pressures.length + " " + enthalpies.length + " " + RSWTOB + "\n"); + int Pcounter = 0; + for (int i = 0; i < pressures.length; i++) { + if (Pcounter > 4) { + writer.write("\n"); + Pcounter = 0; } - if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("aqueous")) { - GW = 1; + writer.write(pressureLOG[i] + " "); + Pcounter++; + } + writer.write("\n"); + + int Tcounter = 0; + for (int i = 0; i < enthalpies.length; i++) { + if (Tcounter > 4) { + writer.write("\n"); + Tcounter = 0; } - if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("oil")) { - GL = 1; + writer.write(enthalpiesLOG[i] + " "); + Tcounter++; + } + writer.write("\n"); + + int bubPcounter = 0; + for (int i = 0; i < enthalpies.length; i++) { + if (bubPcounter > 4) { + writer.write("\n"); + bubPcounter = 0; } - - // int startGasTemperatures = 0, startLiquid = 0, startWater = 0; - boolean acceptedFlash = true; - for (int j = 0; j < enthalpies.length; j++) { - // thermoSystem.setTemperature(enthalpies[j]); - for (int i = 0; i < pressures.length; i++) { - thermoSystem.setPressure(pressures[i]); - try { - logger.info("PHflash... " + thermoSystem.getTemperature() + " pressure " - + thermoSystem.getPressure()); - thermoOps.PHflash(enthalpies[j], 0); - logger.info(" temperature " + thermoSystem.getTemperature() + " enthalpy " - + enthalpies[j]); - thermoSystem.init(3); - thermoSystem.initPhysicalProperties(); - acceptedFlash = true; - } catch (Exception e) { - acceptedFlash = false; - logger.info("fail temperature " + thermoSystem.getTemperature() - + " fail pressure " + thermoSystem.getPressure()); - - thermoSystem.display(); - logger.error("error", e); - } - - /* - * logger.info("water density " + - * thermoSystem.getPhase(2).getPhysicalProperties().getDensity()); - * logger.info("RSW " + thermoSystem.getPhase(0).getComponent("water").getx() * - * thermoSystem.getPhase(0).getComponent("water").getMolarMass() / - * thermoSystem.getPhase(0).getMolarMass()); logger.info("surf tens oil-water " + - * thermoSystem.getInterphaseProperties().getSurfaceTension(1, 2)); - * logger.info("surf tens gas-water " + - * thermoSystem.getInterphaseProperties().getSurfaceTension(0, 2)); - */ - int k = 0; - if (thermoSystem.hasPhaseType("gas") && acceptedFlash) { - int phaseNumb = thermoSystem.getPhaseNumberOfPhase("gas"); - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); - names[k] = "GAS DENSITY"; - units[k] = "KG/M3"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; - names[k] = "DRHOG/DP"; - units[k] = "S2/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); - names[k] = "DRHOG/DT"; - units[k] = "KG/M3-K"; - k++; - - if (thermoSystem.hasPhaseType("oil")) { - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getBeta() - * thermoSystem.getPhase(phaseNumb).getMolarMass() - / (thermoSystem.getPhase(phaseNumb).getBeta() - * thermoSystem.getPhase(phaseNumb).getMolarMass() - + thermoSystem.getPhase("oil").getBeta() - * thermoSystem.getPhase("oil").getMolarMass()); - } else { - props[k][i][j] = 1.0;// thermoSystem.getPhase(phaseNumb).getBeta() * - // thermoSystem.getPhase(phaseNumb).getMolarMass() / - // thermoSystem.getMolarMass(); - } - names[k] = "GAS MASS FRACTION"; - units[k] = "-"; - k++; - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); - names[k] = "GAS VISCOSITY"; - units[k] = "NS/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "GAS HEAT CAPACITY"; - units[k] = "J/KG-K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEnthalpy() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "GAS ENTHALPY"; - units[k] = "J/KG"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties() - .getConductivity(); - names[k] = "GAS THERMAL CONDUCTIVITY"; - units[k] = "W/M-K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "GAS ENTROPY"; - units[k] = "J/KG/K"; - k++; - hasGasValues = true; - // set gas properties - } else if (continuousDerivativesExtrapolation && hasGasValues) { - do { - /* - * if (j>1 && i>1) { props[k][i][j] = 0.5 * ((props[k][i][j - 1] + - * (props[k][i][j - 1] - props[k][i][j - 2]) / (enthalpies[j - 1] - - * enthalpies[j - 2]) * (enthalpies[j] - enthalpies[j - 1])) + (props[k][i - - * 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) / (pressures[i - 1] - - * pressures[i - 2]) * (pressures[i] - pressures[i - 1]))); if - * (names[k].equals("GAS MASS FRACTION") && props[k][i][j] < 0) { - * props[k][i][j] = 0; } } - */ - - /* - * if (j > 1) { props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - - * props[k][i][j - 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * - * (enthalpies[j] - enthalpies[j - 1]); } - */ - if (i > 1) { - props[k][i][j] = - props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) - / (pressures[i - 1] - pressures[i - 2]) - * (pressures[i] - pressures[i - 1]); - // } //else if (j < 2) { - // props[k][i][j] = 0;//props[k][i - 1][j] + (props[k][i - 1][j] - - // props[k][i - - // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - - // pressures[i - // - 1]); - // } else { - // props[k][i][j] = 0;//props[k][i - 1][j - 1] + (props[k][i][j - 1] - - // props[k][i][j - 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * - // (enthalpies[j] - enthalpies[j - 1]) + (props[k][i - 1][j] - - // props[k][i - - // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - - // pressures[i - // - 1]); - // double newTemp = pressures[i]; - // double vall = xcoef[k].get(0, 0) + newTemp * (xcoef[k].get(1, 0) + - // newTemp * - // (xcoef[k].get(2, 0) + newTemp * xcoef[k].get(3, 0))); - // props[k][i][j] = vall; - // if(i>0 && props[k][i-1][j]>1e-10) props[k][i][j] = - // props[k][i-1][j]*pressures[i]/pressures[i-1]; - - if (names[k].equals("GAS MASS FRACTION") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("GAS DENSITY") && props[k][i][j] < 0) { - props[k][i][j] = 0.1; - } - if (names[k].equals("GAS VISCOSITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("GAS THERMAL CONDUCTIVITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - } - if (j > 1) { - props[k][i][j] = - props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) - / (enthalpies[j - 1] - enthalpies[j - 2]) - * (enthalpies[j] - enthalpies[j - 1]); - if (names[k].equals("GAS MASS FRACTION") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("GAS MASS FRACTION") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("GAS DENSITY") && props[k][i][j] <= 0) { - props[k][i][j] = 0.1; - } - if (names[k].equals("GAS VISCOSITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("GAS THERMAL CONDUCTIVITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("GAS HEAT CAPACITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - } - k++; - } while (k < 9);// names[k] = "GAS DENSITY"; - // units[k] = "KG/M3"; - /* - * } else if (false && !hasGasValues) { startGasTemperatures = j; - */ - } else { - gasSystem.setTemperature(enthalpies[j]); - gasSystem.setPressure(pressures[i]); - gasSystem.init(3); - gasSystem.initPhysicalProperties(); - // gasSystem.display(); - props[k][i][j] = gasSystem.getPhase(0).getPhysicalProperties().getDensity(); - names[k] = "GAS DENSITY"; - units[k] = "KG/M3"; - k++; - props[k][i][j] = gasSystem.getPhase(0).getdrhodP() / 1.0e5; - names[k] = "DRHOG/DP"; - units[k] = "S2/M2"; - k++; - props[k][i][j] = gasSystem.getPhase(0).getdrhodT(); - names[k] = "DRHOG/DT"; - units[k] = "KG/M3-K"; - k++; - - props[k][i][j] = 0.0;// thermoSystem.getPhase(phaseNumb).getBeta() * - // thermoSystem.getPhase(phaseNumb).getMolarMass() / - // thermoSystem.getMolarMass(); - names[k] = "GAS MASS FRACTION"; - units[k] = "-"; - k++; - - props[k][i][j] = gasSystem.getPhase(0).getPhysicalProperties().getViscosity(); - names[k] = "GAS VISCOSITY"; - units[k] = "NS/M2"; - k++; - - props[k][i][j] = gasSystem.getPhase(0).getCp() - / gasSystem.getPhase(0).getNumberOfMolesInPhase() - / gasSystem.getPhase(0).getMolarMass(); - names[k] = "GAS HEAT CAPACITY"; - units[k] = "J/KG-K"; - k++; - - props[k][i][j] = gasSystem.getPhase(0).getEnthalpy() - / gasSystem.getPhase(0).getNumberOfMolesInPhase() - / gasSystem.getPhase(0).getMolarMass(); - names[k] = "GAS ENTHALPY"; - units[k] = "J/KG"; - k++; - - props[k][i][j] = - gasSystem.getPhase(0).getPhysicalProperties().getConductivity(); - names[k] = "GAS THERMAL CONDUCTIVITY"; - units[k] = "W/M-K"; - k++; - - props[k][i][j] = gasSystem.getPhase(0).getEntropy() - / gasSystem.getPhase(0).getNumberOfMolesInPhase() - / gasSystem.getPhase(0).getMolarMass(); - names[k] = "GAS ENTROPY"; - units[k] = "J/KG/K"; - k++; - } - - if (thermoSystem.hasPhaseType("oil") && acceptedFlash) { - int phaseNumb = thermoSystem.getPhaseNumberOfPhase("oil"); - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); - names[k] = "LIQUID DENSITY"; - units[k] = "KG/M3"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; - names[k] = "DRHOL/DP"; - units[k] = "S2/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); - names[k] = "DRHOL/DT"; - units[k] = "KG/M3-K"; - k++; - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); - names[k] = "LIQUID VISCOSITY"; - units[k] = "NS/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "LIQUID HEAT CAPACITY"; - units[k] = "J/KG-K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEnthalpy() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "LIQUID ENTHALPY"; - units[k] = "J/KG"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "LIQUID ENTROPY"; - units[k] = "J/KG/K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties() - .getConductivity(); - names[k] = "LIQUID THERMAL CONDUCTIVITY"; - units[k] = "W/M-K"; - k++; - hasOilValues = true; - } else if (continuousDerivativesExtrapolation && hasOilValues) { - do { - // if (i>1) { - // props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - - // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - - // pressures[i - // - 1]); - // } - // if (j>1 && i>1) { - // props[k][i][j] = 0.5 * ((props[k][i - 1][j] + (props[k][i - 1][j] - - // props[k][i - 2][j]) / (enthalpies[i - 1] - enthalpies[i - 2]) * - // (enthalpies[i] - enthalpies[i - 1])) + (props[k][i - 1][j] + (props[k][i - // - - // 1][j] - props[k][i - 2][j]) / (pressures[i - 1] - pressures[i - 2]) * - // (pressures[i] - pressures[i - 1]))); - // } - /* - * if (j > 2) { props[k][i][j] = 0.5*((props[k][i][j - 1] + (props[k][i][j - - * 1] - props[k][i][j - 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * - * (enthalpies[j] - enthalpies[j - 1])) +(props[k][i][j - 1] + - * (props[k][i][j - 1] - props[k][i][j - 3]) / (enthalpies[j - 1] - - * enthalpies[j - 3]) * (enthalpies[j] - enthalpies[j - 1]))); } - */ - if (j < 2 && i < 2) { - if (names[k].equals("LIQUID DENSITY") && props[k][i][j] <= 0) { - props[k][i][j] = 100; - } - if (names[k].equals("LIQUID DENSITY") && props[k][i][j] > 900) { - props[k][i][j] = 900; - } - if (names[k].equals("LIQUID VISCOSITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("LIQUID THERMAL CONDUCTIVITY") - && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("LIQUID HEAT CAPACITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - } - if (j > 1) { - props[k][i][j] = - props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) - / (enthalpies[j - 1] - enthalpies[j - 2]) - * (enthalpies[j] - enthalpies[j - 1]); - if (names[k].equals("LIQUID DENSITY") && props[k][i][j] <= 0) { - props[k][i][j] = 100; - } - if (names[k].equals("LIQUID DENSITY") && props[k][i][j] > 900) { - props[k][i][j] = 900; - } - if (names[k].equals("LIQUID VISCOSITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("LIQUID THERMAL CONDUCTIVITY") - && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("LIQUID HEAT CAPACITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - } - if (i > 1) { - props[k][i][j] = - props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) - / (pressures[i - 1] - pressures[i - 2]) - * (pressures[i] - pressures[i - 1]); - if (names[k].equals("LIQUID DENSITY") && props[k][i][j] <= 0) { - props[k][i][j] = 100; - } - if (names[k].equals("LIQUID DENSITY") && props[k][i][j] > 900) { - props[k][i][j] = 900; - } - if (names[k].equals("LIQUID VISCOSITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("LIQUID THERMAL CONDUCTIVITY") - && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("LIQUID HEAT CAPACITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - } - - // if (j > 1 && TLC==3) { - // props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - // - - // 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - - // enthalpies[j - // - 1]); - // if (j>1) { - // props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - // - - // 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - - // enthalpies[j - // - 1]); - // } else if (j < 2) { - // props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - - // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - - // pressures[i - // - 1]); - // } else { - // props[k][i][j] = props[k][i - 1][j - 1] + (props[k][i][j - 1] - - // props[k][i][j - // - 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - - // enthalpies[j - 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / - // (pressures[i - // - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); - // } - // props[k][i][j] = 0.0;*/ - // } - k++; - } while (k < 17);// names[k] = "GAS DENSITY"; - // units[k] = "KG/M3"; - } else { - oilSystem.setPhaseType(0, 0); - // oilSystem.setTemperature(enthalpies[j]); - oilSystem.setPressure(pressures[i]); - oilSystem.init(3); - oilSystem.initPhysicalProperties(); - - props[k][i][j] = oilSystem.getPhase(0).getPhysicalProperties().getDensity(); - names[k] = "LIQUID DENSITY"; - units[k] = "KG/M3"; - k++; - - props[k][i][j] = oilSystem.getPhase(0).getdrhodP() / 1.0e5; - names[k] = "DRHOL/DP"; - units[k] = "S2/M2"; - k++; - - props[k][i][j] = oilSystem.getPhase(0).getdrhodT(); - names[k] = "DRHOL/DT"; - units[k] = "KG/M3-K"; - k++; - - props[k][i][j] = oilSystem.getPhase(0).getPhysicalProperties().getViscosity(); - names[k] = "LIQUID VISCOSITY"; - units[k] = "NS/M2"; - k++; - - props[k][i][j] = oilSystem.getPhase(0).getCp() - / oilSystem.getPhase(0).getNumberOfMolesInPhase() - / oilSystem.getPhase(0).getMolarMass(); - names[k] = "LIQUID HEAT CAPACITY"; - units[k] = "J/KG-K"; - k++; - - props[k][i][j] = oilSystem.getPhase(0).getTemperature() - 273.15; - names[k] = "LIQUID TEMPERATURE"; - units[k] = "C"; - k++; - - props[k][i][j] = oilSystem.getPhase(0).getEntropy() - / oilSystem.getPhase(0).getNumberOfMolesInPhase() - / oilSystem.getPhase(0).getMolarMass(); - names[k] = "LIQUID ENTROPY"; - units[k] = "J/KG/K"; - k++; - - props[k][i][j] = - oilSystem.getPhase(0).getPhysicalProperties().getConductivity(); - names[k] = "LIQUID THERMAL CONDUCTIVITY"; - units[k] = "W/M-K"; - k++; - } // setOilProperties(); - // set gas properties - - if (thermoSystem.hasPhaseType("aqueous") && acceptedFlash) { - int phaseNumb = thermoSystem.getPhaseNumberOfPhase("aqueous"); - if (thermoSystem.hasPhaseType("gas")) { - props[k][i][j] = thermoSystem.getPhase("gas").getComponent("water").getx() - * thermoSystem.getPhase("gas").getComponent("water").getMolarMass() - / thermoSystem.getPhase("gas").getMolarMass(); - } - if (thermoSystem.hasPhaseType("oil")) { - props[k][i][j] += thermoSystem.getPhase("oil").getComponent("water").getx() - * thermoSystem.getPhase("oil").getComponent("water").getMolarMass() - / thermoSystem.getPhase("oil").getMolarMass(); - } - names[k] = "WATER VAPOR MASS FRACTION"; - units[k] = "-"; - k++; - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getDensity(); - names[k] = "WATER DENSITY"; - units[k] = "KG/M3"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodP() / 1.0e5; - names[k] = "DRHOWAT/DP"; - units[k] = "S2/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getdrhodT(); - names[k] = "DRHOWAT/DT"; - units[k] = "KG/M3-K"; - k++; - - props[k][i][j] = - thermoSystem.getPhase(phaseNumb).getPhysicalProperties().getViscosity(); - names[k] = "WATER VISCOSITY"; - units[k] = "NS/M2"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getCp() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "WATER HEAT CAPACITY"; - units[k] = "J/KG-K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getTemperature() - 273.15; - names[k] = "WATER TEMPERATURE"; - units[k] = "C"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getEntropy() - / thermoSystem.getPhase(phaseNumb).getNumberOfMolesInPhase() - / thermoSystem.getPhase(phaseNumb).getMolarMass(); - names[k] = "WATER ENTROPY"; - units[k] = "J/KG/K"; - k++; - - props[k][i][j] = thermoSystem.getPhase(phaseNumb).getPhysicalProperties() - .getConductivity(); - names[k] = "WATER THERMAL CONDUCTIVITY"; - units[k] = "W/M-K"; - k++; - hasWaterValues = true; - } else if (continuousDerivativesExtrapolation && hasWaterValues) { - do { - /* - * if (j > 2) { props[k][i][j] = 0.5*((props[k][i][j - 1] + (props[k][i][j - - * 1] - props[k][i][j - 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * - * (enthalpies[j] - enthalpies[j - 1])) +(props[k][i][j - 1] + - * (props[k][i][j - 1] - props[k][i][j - 3]) / (enthalpies[j - 1] - - * enthalpies[j - 3]) * (enthalpies[j] - enthalpies[j - 1]))); if - * (names[k].equals("WATER VAPOR MASS FRACTION") && props[k][i][j] > 1) { - * props[k][i][j] = 1; } } - */ - if (j > 1) { - props[k][i][j] = - props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) - / (enthalpies[j - 1] - enthalpies[j - 2]) - * (enthalpies[j] - enthalpies[j - 1]); - if (names[k].equals("WATER VAPOR MASS FRACTION") - && props[k][i][j] > 1) { - props[k][i][j] = 1; - } - if (names[k].equals("WATER DENSITY") && props[k][i][j] <= 0) { - props[k][i][j] = 1000; - } - if (names[k].equals("WATER VISCOSITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("WATER THERMAL CONDUCTIVITY") - && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("WATER VAPOR MASS FRACTION") - && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("WATER HEAT CAPACITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - } - /* - * if (j > 1 && TLC == 3) { props[k][i][j] = props[k][i][j-1] + - * (props[k][i][j-1] - props[k][i][j-2]) / (enthalpies[j - 1] - enthalpies[j - * - 2]) * (enthalpies[j] - enthalpies[j - 1]); if (j>1) { props[k][i][j] = - * props[k][i][j-1] + (props[k][i][j-1] - props[k][i][j-2]) / (enthalpies[j - * - 1] - enthalpies[j - 2]) * (enthalpies[j] - enthalpies[j - 1]); if - * (names[k].equals("WATER VAPOR MASS FRACTION") && props[k][i][j] > 1) { - * props[k][i][j] = 1; } } - */ - if (i > 1) { - props[k][i][j] = - props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) - / (pressures[i - 1] - pressures[i - 2]) - * (pressures[i] - pressures[i - 1]); - if (names[k].equals("WATER VAPOR MASS FRACTION") - && props[k][i][j] > 1) { - props[k][i][j] = 1; - } - - if (names[k].equals("WATER DENSITY") && props[k][i][j] <= 0) { - props[k][i][j] = 1000; - } - if (names[k].equals("WATER VISCOSITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("WATER THERMAL CONDUCTIVITY") - && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("WATER VAPOR MASS FRACTION") - && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - if (names[k].equals("WATER HEAT CAPACITY") && props[k][i][j] < 0) { - props[k][i][j] = 0; - } - } - - /* - * if (i < 2) { props[k][i][j] = props[k][i][j - 1] + (props[k][i][j - 1] - - * props[k][i][j - 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * - * (enthalpies[j] - enthalpies[j - 1]); } else if (j < 2) { props[k][i][j] = - * props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) / - * (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - - * 1]); } else { props[k][i][j] = props[k][i - 1][j - 1] + (props[k][i][j - - * 1] - props[k][i][j - 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * - * (enthalpies[j] - enthalpies[j - 1]) + (props[k][i - 1][j] - props[k][i - - * 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - - * pressures[i - 1]); } props[k][i][j] = 0.0; - */ - k++; - } while (k < 26);// names[k] = "GAS DENSITY"; - // units[k] = "KG/M3"; - } else { - waterSystem.setTemperature(enthalpies[j]); - waterSystem.setPressure(pressures[i]); - waterSystem.setPhaseType(0, 0); - waterSystem.init(3); - waterSystem.initPhysicalProperties(); - - if (thermoSystem.getPhase(0).hasComponent("water")) { - props[k][i][j] = thermoSystem.getPhase(0).getComponent("water").getz() - * thermoSystem.getPhase(0).getComponent("water").getMolarMass() - / thermoSystem.getPhase(0).getMolarMass();; - } else { - props[k][i][j] = 0.0; - } - names[k] = "WATER VAPOR MASS FRACTION"; - units[k] = "-"; - k++; - - props[k][i][j] = waterSystem.getPhase(0).getPhysicalProperties().getDensity(); - names[k] = "WATER DENSITY"; - units[k] = "KG/M3"; - k++; - - props[k][i][j] = waterSystem.getPhase(0).getdrhodP() / 1.0e5; - names[k] = "DRHOWAT/DP"; - units[k] = "S2/M2"; - k++; - - props[k][i][j] = waterSystem.getPhase(0).getdrhodT(); - names[k] = "DRHOWAT/DT"; - units[k] = "KG/M3-K"; - k++; - - props[k][i][j] = waterSystem.getPhase(0).getPhysicalProperties().getViscosity(); - names[k] = "WATER VISCOSITY"; - units[k] = "NS/M2"; - k++; - - props[k][i][j] = waterSystem.getPhase(0).getCp() - / waterSystem.getPhase(0).getNumberOfMolesInPhase() - / waterSystem.getPhase(0).getMolarMass(); - names[k] = "WATER HEAT CAPACITY"; - units[k] = "J/KG-K"; - k++; - - props[k][i][j] = waterSystem.getPhase(0).getTemperature(); - names[k] = "WATER TEMPERATURE"; - units[k] = "C"; - k++; - - props[k][i][j] = waterSystem.getPhase(0).getEntropy() - / waterSystem.getPhase(0).getNumberOfMolesInPhase() - / waterSystem.getPhase(0).getMolarMass(); - names[k] = "WATER ENTROPY"; - units[k] = "J/KG/K"; - k++; - - props[k][i][j] = - waterSystem.getPhase(0).getPhysicalProperties().getConductivity(); - names[k] = "WATER THERMAL CONDUCTIVITY"; - units[k] = "W/M-K"; - k++; - } - - if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("oil") - && acceptedFlash) { - props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( - thermoSystem.getPhaseNumberOfPhase("gas"), - thermoSystem.getPhaseNumberOfPhase("oil")); - names[k] = "VAPOR-LIQUID SURFACE TENSION"; - units[k] = "N/M"; - k++; - } else { - if (continuousDerivativesExtrapolation && (i >= 2 || j >= 2)) { - if (VLS == 1) { - props[k][i][j] = 5.0e-3; - // k++; - } - // if (j>1 && thermoSystem.hasPhaseType("gas") && VLS==0 && acceptedFlash) { - if (j > 1 && (GLW == 1 || GL == 1) && VLS == 0) { - props[k][i][j] = - props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) - / (enthalpies[j - 1] - enthalpies[j - 2]) - * (enthalpies[j] - enthalpies[j - 1]); - /* - * if (names[k].equals("VAPOR-LIQUID SURFACE TENSION") && props[k][i][j] - * < 5.0e-3) { props[k][i][j] = 7.5e-3; VLS=1; } if - * (names[k].equals("VAPOR-LIQUID SURFACE TENSION") && props[k][i][j] > - * 30.0e-3) { props[k][i][j] = 20.0e-3; VLS=1; } - */ - if (props[k][i][j] < 5.0e-3) { - props[k][i][j] = 5.0e-3; - VLS = 1; - } - if (props[k][i][j] > 1.1 * props[k][i][j - 1]) { - props[k][i][j] = props[k][i][j - 1]; - } - if (props[k][i][j] < 0.9 * props[k][i][j - 1]) { - props[k][i][j] = props[k][i][j - 1]; - } - // } else if (i>1 && thermoSystem.hasPhaseType("oil") && VLS == 0 && - // acceptedFlash) { - // } else if (i > 1 && TLC < 3 && VLS==0) { - } else if (i > 1 && (GLW == 0 || GL == 0) && VLS == 0) { - props[k][i][j] = - props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) - / (pressures[i - 1] - pressures[i - 2]) - * (pressures[i] - pressures[i - 1]); - if (props[k][i][j] < 5.0e-3) { - props[k][i][j] = 5.0e-3; - VLS = 1; - } - if (props[k][i][j] > 1.1 * props[k][i - 1][j]) { - props[k][i][j] = props[k][i - 1][j]; - } - if (props[k][i][j] < 0.9 * props[k][i - 1][j]) { - props[k][i][j] = props[k][i - 1][j]; - } - } else if (j > 0 && i > 0) { - props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); - } else if (j > 0) { - props[k][i][j] = props[k][i][j - 1]; - } else if (i > 0) { - props[k][i][j] = props[k][i - 1][j]; - } else { - // props[k][i][j] = props[k][i - 1][j - 1] + (props[k][i][j - 1] - - // props[k][i][j - // - 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - - // enthalpies[j - 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / - // (pressures[i - // - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); - props[k][i][j] = 10.0e-3; - } - - // k++; - } else if (j > 0 && i > 0) { - props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); - // k++; - } else if (j > 0) { - props[k][i][j] = props[k][i][j - 1]; - // k++; - } else if (i > 0) { - props[k][i][j] = props[k][i - 1][j]; - // k++; - } else { - props[k][i][j] = 10.0e-3; - names[k] = "VAPOR-LIQUID SURFACE TENSION"; - units[k] = "N/M"; - // k++; - } - k++; - } - - if (thermoSystem.hasPhaseType("gas") && thermoSystem.hasPhaseType("aqueous") - && acceptedFlash) { - props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( - thermoSystem.getPhaseNumberOfPhase("gas"), - thermoSystem.getPhaseNumberOfPhase("aqueous")); - names[k] = "VAPOR-WATER SURFACE TENSION"; - units[k] = "N/M"; - k++; - } else { - if (continuousDerivativesExtrapolation && (i >= 2 || j >= 2)) { - if (VWS == 1) { - props[k][i][j] = 5.0e-3; - // k++; - } - // if (j>1 && thermoSystem.hasPhaseType("gas") && VWS == 0 && acceptedFlash) - // { - // if (j > 1 && TLC==3 && VWS==0) { - if (j > 1 && (GLW == 1 || GW == 1) && VWS == 0) { - props[k][i][j] = - props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) - / (enthalpies[j - 1] - enthalpies[j - 2]) - * (enthalpies[j] - enthalpies[j - 1]); - /* - * if (names[k].equals("VAPOR-WATER SURFACE TENSION") && props[k][i][j] - * < 10.0e-3) { props[k][i][j] = 35.0e-3; VWS=1; } if - * (names[k].equals("VAPOR-WATER SURFACE TENSION") && props[k][i][j] > - * 150.0e-3) { props[k][i][j] = 105.0e-3; VWS=1; } - */ - if (props[k][i][j] < 5.0e-3) { - props[k][i][j] = 5.0e-3; - VWS = 1; - } - if (props[k][i][j] > 1.1 * props[k][i][j - 1]) { - props[k][i][j] = props[k][i][j - 1]; - } - if (props[k][i][j] < 0.9 * props[k][i][j - 1]) { - props[k][i][j] = props[k][i][j - 1]; - } - // } else if (j>1 && thermoSystem.hasPhaseType("aqueous") && VWS ==0 && - // acceptedFlash) { - // } else if (i > 1 && TLC < 3 && VWS==0) { - } else if (i > 1 && (GLW == 0 || GL == 0) && VWS == 0) { - props[k][i][j] = - props[k][i - 1][j] + (props[k][i - 1][j] - props[k][i - 2][j]) - / (pressures[i - 1] - pressures[i - 2]) - * (pressures[i] - pressures[i - 1]); - /* - * if (names[k].equals("VAPOR-WATER SURFACE TENSION") && props[k][i][j] - * < 10.0e-3) { props[k][i][j] = 35.0e-3; VWS=1; } if - * (names[k].equals("VAPOR-WATER SURFACE TENSION") && props[k][i][j] > - * 150.0e-3) { props[k][i][j] = 105.0e-3; VWS=1; } - */ - if (props[k][i][j] < 5.0e-3) { - props[k][i][j] = 5.0e-3; - VWS = 1; - } - if (props[k][i][j] > 1.1 * props[k][i - 1][j]) { - props[k][i][j] = props[k][i - 1][j]; - } - if (props[k][i][j] < 0.9 * props[k][i - 1][j]) { - props[k][i][j] = props[k][i - 1][j]; - } - } else if (j > 0 && i > 0) { - props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); - } else if (j > 0) { - props[k][i][j] = props[k][i][j - 1]; - } else if (i > 0) { - props[k][i][j] = props[k][i - 1][j]; - } else { - // props[k][i][j] = props[k][i - 1][j - 1] + (props[k][i][j - 1] - - // props[k][i][j - // - 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - - // enthalpies[j - 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / - // (pressures[i - // - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); - props[k][i][j] = 60.0e-3; - } - - // k++; - } else if (j > 0 && i > 0) { - props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); - // k++; - } else if (j > 0) { - props[k][i][j] = props[k][i][j - 1]; - // k++; - } else if (i > 0) { - props[k][i][j] = props[k][i - 1][j]; - // k++; - } else { - props[k][i][j] = 60.0e-3; - names[k] = "VAPOR-WATER SURFACE TENSION"; - units[k] = "N/M"; - // k++; - } - k++; - } - - if (thermoSystem.hasPhaseType("oil") && thermoSystem.hasPhaseType("aqueous") - && acceptedFlash) { - props[k][i][j] = thermoSystem.getInterphaseProperties().getSurfaceTension( - thermoSystem.getPhaseNumberOfPhase("oil"), - thermoSystem.getPhaseNumberOfPhase("aqueous")); - names[k] = "LIQUID-WATER SURFACE TENSION"; - units[k] = "N/M"; - k++; - } else { - if (continuousDerivativesExtrapolation && (i >= 2 || j >= 2)) { - if (LWS == 1) { - props[k][i][j] = 5.0e-3; - // k++; - } - if (j > 1 && LWS == 0) { - // if (j > 1 && TLC==3 && LWS==0) { - // if (j>1 && LWS==0 && acceptedFlash) { - props[k][i][j] = - props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 2]) - / (enthalpies[j - 1] - enthalpies[j - 2]) - * (enthalpies[j] - enthalpies[j - 1]); - /* - * if (j > 2) { props[k][i][j] = 0.5*((props[k][i][j - 1] + - * (props[k][i][j - 1] - props[k][i][j - 2]) / (enthalpies[j - 1] - - * enthalpies[j - 2]) * (enthalpies[j] - enthalpies[j - 1])) - * +(props[k][i][j - 1] + (props[k][i][j - 1] - props[k][i][j - 3]) / - * (enthalpies[j - 1] - enthalpies[j - 3]) * (enthalpies[j] - - * enthalpies[j - 1]))); if - * (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] < - * 10.0e-3) { props[k][i][j] = 25.0e-3; LWS=1; } - * - * if (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] - * > 120.0e-3) { props[k][i][j] = 80.0e-3; LWS=1; } } - */ - - /* - * if (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] - * < 10.0e-3) { props[k][i][j] = 25.0e-3; LWS=1; } if - * (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] > - * 120.0e-3) { props[k][i][j] = 80.0e-3; LWS=1; } - */ - if (props[k][i][j] < 5.0e-3) { - props[k][i][j] = 5.0e-3; - LWS = 1; - } - if (props[k][i][j] > 1.1 * props[k][i][j - 1]) { - props[k][i][j] = props[k][i][j - 1]; - } - if (props[k][i][j] < 0.9 * props[k][i][j - 1]) { - props[k][i][j] = props[k][i][j - 1]; - } - // } else if (i > 1 && LWS==0 && acceptedFlash) { - // } else if (i > 1 && TLC < 3 && LWS==0) { - // props[k][i][j] = props[k][i - 1][j] + (props[k][i - 1][j] - - // props[k][i - - // 2][j]) / (pressures[i - 1] - pressures[i - 2]) * (pressures[i] - - // pressures[i - // - 1]); - /* - * if (i > 2) { props[k][i][j] = 0.5*((props[k][i - 1][j] + (props[k][i - * - 1][j] - props[k][i - 2][j]) / (pressures[i - 1] - pressures[i - 2]) - * * (pressures[i] - pressures[i - 1])) +(props[k][i - 1][j] + - * (props[k][i - 1][j] - props[k][i - 3][j]) / (pressures[i - 1] - - * pressures[i - 3]) * (pressures[i] - pressures[i - 1]))); if - * (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] < - * 10.0e-3) { props[k][i][j] = 25.0e-3; LWS=1; } - * - * if (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] - * > 120.0e-3) { props[k][i][j] = 80.0e-3; LWS=1; } } - */ - - /* - * if (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] - * < 10.0e-3) { props[k][i][j] = 25.0e-3; LWS=1; } if - * (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] > - * 120.0e-3) { props[k][i][j] = 80.0e-3; LWS=1; } - */ - - /* - * if (props[k][i][j] < 5.0e-3) { props[k][i][j] = 5.0e-3; LWS = 1; } if - * (props[k][i][j] > 1.1* props[k][i - 1][j]) { props[k][i][j] = - * props[k][i - 1][j]; } if (props[k][i][j] < 0.9* props[k][i - 1][j]) { - * props[k][i][j] = props[k][i - 1][j]; } - */ - // } else if (j >0 && i > 0) { - // props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); - } else if (j > 0) { - props[k][i][j] = props[k][i][j - 1]; - } else if (i > 0) { - props[k][i][j] = props[k][i - 1][j]; - } else { - // props[k][i][j] = props[k][i - 1][j - 1] + (props[k][i][j - 1] - - // props[k][i][j - // - 2]) / (enthalpies[j - 1] - enthalpies[j - 2]) * (enthalpies[j] - - // enthalpies[j - 1]) + (props[k][i - 1][j] - props[k][i - 2][j]) / - // (pressures[i - // - 1] - pressures[i - 2]) * (pressures[i] - pressures[i - 1]); - props[k][i][j] = 40.0e-3; - } - - // k++; - // } else if (j >0 && i > 0) { - // props[k][i][j] = 0.5 * (props[k][i - 1][j] + props[k][i][j - 1]); - // k++; - } else if (j > 0) { - props[k][i][j] = props[k][i][j - 1]; - // k++; - } else if (i > 0) { - props[k][i][j] = props[k][i - 1][j]; - // k++; - } else { - props[k][i][j] = 40.0e-3; - names[k] = "LIQUID-WATER SURFACE TENSION"; - units[k] = "N/M"; - // k++; - } - k++; - } - } + writer.write(bubPLOG[i] + " "); + bubPcounter++; + } + writer.write("\n"); + + int dewPcounter = 0; + for (int i = 0; i < enthalpies.length; i++) { + if (dewPcounter > 4) { + writer.write("\n"); + dewPcounter = 0; } - logger.info("Finished TPflash..."); - if (thermoSystem.getPhase(0).hasComponent("water")) { - thermoSystem.removeComponent("water"); + writer.write(dewPLOG[i] + " "); + dewPcounter++; + } + writer.write("\n"); + + for (int k = 0; k < nProps; k++) { + if (names[k] == null) { + continue; } - // bubP = calcBubP(enthalpies); - // dewP = calcDewP(enthalpies); - // bubT = calcBubT(enthalpies); - logger.info("Finished creating arrays"); - // BicubicSplineInterpolatingFunction funcGasDens = - // interpolationFunc.interpolate(pressures, enthalpies, props[0]); - // logger.info("interpolated value " + funcGasDens.value(40, 298.0)); - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - logger.info("TC " + TC + " PC " + PC); + logger.info("Writing variable: " + names[k]); + writer.write(names[k] + " (" + units[k] + ")\n"); for (int i = 0; i < pressures.length; i++) { - thermoSystem.setPressure(pressures[i]); - for (int j = 0; j < enthalpies.length; j++) { - logger.info("pressure " + pressureLOG[i] + " enthalpy " + enthalpiesLOG[j]);// + " - // ROG " - // + - // ROG[i][j] - // + " - // ROL " - // + - // ROL[i][j]); + // thermoSystem.setPressure(pressures[i]); + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + // thermoSystem.setTemperature(enthalpies[j]); + if (counter > 4) { + writer.write("\n"); + counter = 0; } + writer.write(props[k][i][j] + " "); + counter++; + } + writer.write("\n"); } - writeOLGAinpFile(fileName); + } + } catch (IOException ex) { + // report } - - /** - *

- * writeOLGAinpFile2. - *

- * - * @param filename a {@link java.lang.String} object + } + + /** + *

+ * writeOLGAinpFile. + *

+ * + * @param filename a {@link java.lang.String} object + */ + public void writeOLGAinpFile(String filename) { + /* + * try { writer = new BufferedWriter(new OutputStreamWriter( new + * FileOutputStream("C:/Users/Kjetil Raul/Documents/Master KRB/javacode_ROG55.txt" ), "utf-8")); + * writer.write("GAS DENSITY (KG/M3) = ("); for (int i = 0; i < pressures.length; i++) { + * thermoSystem.setPressure(pressures[i]); for (int j = 0; j < enthalpies.length; j++) { + * thermoSystem.setTemperature(enthalpies[j]); writer.write(ROG[i][j] + ","); } } + * writer.write(")"); } catch (IOException ex) { // report } finally { try { } writer.close(); } + * catch (Exception ex) { } } */ - public void writeOLGAinpFile2(String filename) { - /* - * try { writer = new BufferedWriter(new OutputStreamWriter( new - * FileOutputStream("C:/Users/Kjetil Raul/Documents/Master KRB/javacode_ROG55.txt" ), - * "utf-8")); writer.write("GAS DENSITY (KG/M3) = ("); for (int i = 0; i < pressures.length; - * i++) { thermoSystem.setPressure(pressures[i]); for (int j = 0; j < enthalpies.length; - * j++) { thermoSystem.setTemperature(enthalpies[j]); writer.write(ROG[i][j] + ","); } } - * writer.write(")"); } catch (IOException ex) { // report } finally { try { } - * writer.close(); } catch (Exception ex) { } } - */ - try (Writer writer = new BufferedWriter( - new OutputStreamWriter(new FileOutputStream(fileName), "utf-8"))) { - writer.write("'WATER-OPTION ENTROPY NONEQ '" + "\n"); - - writer.write(pressures.length + " " + enthalpies.length + " " + RSWTOB + "\n"); - int Pcounter = 0; - for (int i = 0; i < pressures.length; i++) { - if (Pcounter > 4) { - writer.write("\n"); - Pcounter = 0; - } - writer.write(pressureLOG[i] + " "); - Pcounter++; - } + try (Writer writer = + new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename), "utf-8"))) { + writer.write("'WATER-OPTION ENTROPY NONEQ '" + "\n"); + + writer.write(pressures.length + " " + enthalpies.length + " " + RSWTOB + "\n"); + int Pcounter = 0; + for (int i = 0; i < pressures.length; i++) { + if (Pcounter > 4) { + writer.write("\n"); + Pcounter = 0; + } + writer.write(pressureLOG[i] + " "); + Pcounter++; + } + writer.write("\n"); + + int Tcounter = 0; + for (int i = 0; i < enthalpies.length; i++) { + if (Tcounter > 4) { + writer.write("\n"); + Tcounter = 0; + } + writer.write(enthalpiesLOG[i] + " "); + Tcounter++; + } + writer.write("\n"); + + int bubPcounter = 0; + for (int i = 0; i < enthalpies.length; i++) { + if (bubPcounter > 4) { + writer.write("\n"); + bubPcounter = 0; + } + writer.write(bubPLOG[i] + " "); + bubPcounter++; + } + writer.write("\n"); + + int dewPcounter = 0; + for (int i = 0; i < enthalpies.length; i++) { + if (dewPcounter > 4) { + writer.write("\n"); + dewPcounter = 0; + } + writer.write(dewPLOG[i] + " "); + dewPcounter++; + } + writer.write("\n"); + + writer.write("GAS DENSITY (KG/M3)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[0][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int Tcounter = 0; - for (int i = 0; i < enthalpies.length; i++) { - if (Tcounter > 4) { - writer.write("\n"); - Tcounter = 0; - } - writer.write(enthalpiesLOG[i] + " "); - Tcounter++; - } + writer.write("LIQUID DENSITY (KG/M3)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[9][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int bubPcounter = 0; - for (int i = 0; i < enthalpies.length; i++) { - if (bubPcounter > 4) { - writer.write("\n"); - bubPcounter = 0; - } - writer.write(bubPLOG[i] + " "); - bubPcounter++; - } + writer.write("WATER DENSITY (KG/M3)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[18][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int dewPcounter = 0; - for (int i = 0; i < enthalpies.length; i++) { - if (dewPcounter > 4) { - writer.write("\n"); - dewPcounter = 0; - } - writer.write(dewPLOG[i] + " "); - dewPcounter++; - } + writer.write("DRHOG/DP (S2/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { writer.write("\n"); - - for (int k = 0; k < nProps; k++) { - if (names[k] == null) { - continue; - } - logger.info("Writing variable: " + names[k]); - writer.write(names[k] + " (" + units[k] + ")\n"); - for (int i = 0; i < pressures.length; i++) { - // thermoSystem.setPressure(pressures[i]); - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - // thermoSystem.setTemperature(enthalpies[j]); - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[k][i][j] + " "); - counter++; - } - writer.write("\n"); - } - } - } catch (IOException ex) { - // report + counter = 0; + } + writer.write(props[1][i][j] + " "); + counter++; } - } + writer.write("\n"); + } - /** - *

- * writeOLGAinpFile. - *

- * - * @param filename a {@link java.lang.String} object - */ - public void writeOLGAinpFile(String filename) { - /* - * try { writer = new BufferedWriter(new OutputStreamWriter( new - * FileOutputStream("C:/Users/Kjetil Raul/Documents/Master KRB/javacode_ROG55.txt" ), - * "utf-8")); writer.write("GAS DENSITY (KG/M3) = ("); for (int i = 0; i < pressures.length; - * i++) { thermoSystem.setPressure(pressures[i]); for (int j = 0; j < enthalpies.length; - * j++) { thermoSystem.setTemperature(enthalpies[j]); writer.write(ROG[i][j] + ","); } } - * writer.write(")"); } catch (IOException ex) { // report } finally { try { } - * writer.close(); } catch (Exception ex) { } } - */ - try (Writer writer = new BufferedWriter( - new OutputStreamWriter(new FileOutputStream(filename), "utf-8"))) { - writer.write("'WATER-OPTION ENTROPY NONEQ '" + "\n"); - - writer.write(pressures.length + " " + enthalpies.length + " " + RSWTOB + "\n"); - int Pcounter = 0; - for (int i = 0; i < pressures.length; i++) { - if (Pcounter > 4) { - writer.write("\n"); - Pcounter = 0; - } - writer.write(pressureLOG[i] + " "); - Pcounter++; - } + writer.write("DRHOL/DP (S2/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[10][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int Tcounter = 0; - for (int i = 0; i < enthalpies.length; i++) { - if (Tcounter > 4) { - writer.write("\n"); - Tcounter = 0; - } - writer.write(enthalpiesLOG[i] + " "); - Tcounter++; - } + writer.write("DRHOWAT/DP (S2/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[19][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int bubPcounter = 0; - for (int i = 0; i < enthalpies.length; i++) { - if (bubPcounter > 4) { - writer.write("\n"); - bubPcounter = 0; - } - writer.write(bubPLOG[i] + " "); - bubPcounter++; - } + writer.write("DRHOG/DT (KG/M3-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[2][i][j] + " "); + counter++; + } + writer.write("\n"); + } - int dewPcounter = 0; - for (int i = 0; i < enthalpies.length; i++) { - if (dewPcounter > 4) { - writer.write("\n"); - dewPcounter = 0; - } - writer.write(dewPLOG[i] + " "); - dewPcounter++; - } + writer.write("DRHOL/DT (KG/M3-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { writer.write("\n"); + counter = 0; + } + writer.write(props[11][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS DENSITY (KG/M3)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[0][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("LIQUID DENSITY (KG/M3)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[9][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("WATER DENSITY (KG/M3)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[18][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOG/DP (S2/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[1][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOL/DP (S2/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[10][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOWAT/DP (S2/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[19][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOG/DT (KG/M3-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[2][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOL/DT (KG/M3-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[11][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("DRHOWAT/DT (KG/M3-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[20][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("GAS MASS FRACTION (-)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[3][i][j] + " "); - counter++; - } - writer.write("\n"); - } - - writer.write("WATER VAPOR MASS FRACTION (-)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[17][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("DRHOWAT/DT (KG/M3-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[20][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS VISCOSITY (NS/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[4][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS MASS FRACTION (-)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[3][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID VISCOSITY (NS/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[12][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("WATER VAPOR MASS FRACTION (-)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[17][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("WATER VISCOSITY (NS/M2)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[21][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS VISCOSITY (NS/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[4][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS HEAT CAPACITY (J/KG-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[5][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("LIQUID VISCOSITY (NS/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[12][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID HEAT CAPACITY (J/KG-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[13][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("WATER VISCOSITY (NS/M2)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[21][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("WATER HEAT CAPACITY (J/KG-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[22][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS HEAT CAPACITY (J/KG-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[5][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS ENTHALPY (J/KG)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[6][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("LIQUID HEAT CAPACITY (J/KG-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[13][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID ENTHALPY (J/KG)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[14][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("WATER HEAT CAPACITY (J/KG-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[22][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("WATER ENTHALPY (J/KG)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[23][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS ENTHALPY (J/KG)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[6][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS THERMAL CONDUCTIVITY (W/M-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[7][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("LIQUID ENTHALPY (J/KG)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[14][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID THERMAL CONDUCTIVITY (W/M-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[16][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("WATER ENTHALPY (J/KG)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[23][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("WATER THERMAL CONDUCTIVITY (W/M-K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[25][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS THERMAL CONDUCTIVITY (W/M-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[7][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("VAPOR-LIQUID SURFACE TENSION (N/M)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[26][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("LIQUID THERMAL CONDUCTIVITY (W/M-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[16][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("VAPOR-WATER SURFACE TENSION (N/M)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[27][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("WATER THERMAL CONDUCTIVITY (W/M-K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[25][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID-WATER SURFACE TENSION (N/M)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[28][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("VAPOR-LIQUID SURFACE TENSION (N/M)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[26][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("GAS ENTROPY (J/KG/K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[8][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("VAPOR-WATER SURFACE TENSION (N/M)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[27][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("LIQUID ENTROPY (J/KG/K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[15][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("LIQUID-WATER SURFACE TENSION (N/M)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[28][i][j] + " "); + counter++; + } + writer.write("\n"); + } - writer.write("WATER ENTROPY (J/KG/K)" + "\n"); - for (int i = 0; i < pressures.length; i++) { - int counter = 0; - for (int j = 0; j < enthalpies.length; j++) { - if (counter > 4) { - writer.write("\n"); - counter = 0; - } - writer.write(props[24][i][j] + " "); - counter++; - } - writer.write("\n"); - } + writer.write("GAS ENTROPY (J/KG/K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[8][i][j] + " "); + counter++; + } + writer.write("\n"); + } - /* - * for (int k = 0; k < nProps; k++) { if (names[k] == null) { continue; } - * logger.info("Writing variable: " + names[k]); writer.write(names[k] + " (" + units[k] - * + ")\n"); for (int i = 0; i < pressures.length; i++) { - * //thermoSystem.setPressure(pressures[i]); int counter = 0; for (int j = 0; j < - * enthalpies.length; j++) { // thermoSystem.setTemperature(enthalpies[j]); if (counter - * > 4) { writer.write("\n"); counter = 0; } writer.write(props[k][i][j] + " "); - * counter++; } writer.write("\n"); } } - */ - } catch (IOException ex) { - // report + writer.write("LIQUID ENTROPY (J/KG/K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; + for (int j = 0; j < enthalpies.length; j++) { + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[15][i][j] + " "); + counter++; } - } + writer.write("\n"); + } - /** - *

- * extrapolateTable. - *

- */ - public void extrapolateTable() { + writer.write("WATER ENTROPY (J/KG/K)" + "\n"); + for (int i = 0; i < pressures.length; i++) { + int counter = 0; for (int j = 0; j < enthalpies.length; j++) { - for (int i = 0; i < pressures.length; i++) { - if (!hasValue[26][i][j]) { - } - } + if (counter > 4) { + writer.write("\n"); + counter = 0; + } + writer.write(props[24][i][j] + " "); + counter++; + } + writer.write("\n"); + } + + /* + * for (int k = 0; k < nProps; k++) { if (names[k] == null) { continue; } + * logger.info("Writing variable: " + names[k]); writer.write(names[k] + " (" + units[k] + + * ")\n"); for (int i = 0; i < pressures.length; i++) { + * //thermoSystem.setPressure(pressures[i]); int counter = 0; for (int j = 0; j < + * enthalpies.length; j++) { // thermoSystem.setTemperature(enthalpies[j]); if (counter > 4) { + * writer.write("\n"); counter = 0; } writer.write(props[k][i][j] + " "); counter++; } + * writer.write("\n"); } } + */ + } catch (IOException ex) { + // report + } + } + + /** + *

+ * extrapolateTable. + *

+ */ + public void extrapolateTable() { + for (int j = 0; j < enthalpies.length; j++) { + for (int i = 0; i < pressures.length; i++) { + if (!hasValue[26][i][j]) { } + } } + } } diff --git a/src/test/java/neqsim/fluidMechanics/flowSystem/onePhaseFlowSystem/pipeFlowSystem/PipeFlowSystemTest.java b/src/test/java/neqsim/fluidMechanics/flowSystem/onePhaseFlowSystem/pipeFlowSystem/PipeFlowSystemTest.java index 8cc0da7b39..a92c66774d 100644 --- a/src/test/java/neqsim/fluidMechanics/flowSystem/onePhaseFlowSystem/pipeFlowSystem/PipeFlowSystemTest.java +++ b/src/test/java/neqsim/fluidMechanics/flowSystem/onePhaseFlowSystem/pipeFlowSystem/PipeFlowSystemTest.java @@ -92,7 +92,7 @@ void testSolveSteadyState() { void testSolveTransient() { testInit(); // transient solver - double[] times = {0, 10000, 20000};// , 30000, 40000, 50000};//, 60000, 70000, 80000, + double[] times = {0, 10000, 20000}; // , 30000, 40000, 50000}; //, 60000, 70000, 80000, // 90000}; pipe.getTimeSeries().setTimes(times); @@ -112,9 +112,9 @@ void testSolveTransient() { testSystem3.addComponent("ethane", 1221.10); testSystem3.init(0); - SystemInterface[] systems = {testSystem, testSystem2, testSystem2};// , testSystem2, + SystemInterface[] systems = {testSystem, testSystem2, testSystem2}; // , testSystem2, // testSystem2, - // testSystem2};//,testSystem2,testSystem2,testSystem2,testSystem2,testSystem2}; + // testSystem2}; //,testSystem2,testSystem2,testSystem2,testSystem2,testSystem2}; pipe.getTimeSeries().setInletThermoSystems(systems); pipe.getTimeSeries().setNumberOfTimeStepsInInterval(10); // double[] outletFlowRates = {0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, diff --git a/src/test/java/neqsim/physicalProperties/util/examples/TPflashTest.java b/src/test/java/neqsim/physicalProperties/util/examples/TPflashTest.java index a4405f92ea..eb3b4873c8 100644 --- a/src/test/java/neqsim/physicalProperties/util/examples/TPflashTest.java +++ b/src/test/java/neqsim/physicalProperties/util/examples/TPflashTest.java @@ -16,87 +16,87 @@ * @since 2.2.3 */ public class TPflashTest { - static Logger logger = LogManager.getLogger(TPflashTest.class); + static Logger logger = LogManager.getLogger(TPflashTest.class); - /** - *

- * main. - *

+ /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String args[]) { + SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 20, 30.0); + // SystemInterface testSystem = new SystemSrkCPAstatoil(273.15+20, 1.0); + // SystemInterface testSystem = new SystemPrEos1978(273.15+10, 12.0); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + + // testSystem.addComponent("TEG", 10.71); + testSystem.addComponent("methane", 14.01); + // testSystem.changeComponentName("methane", "methaneHYME"); + // testSystem.addComponent("ethane", 0.01); + // testSystem.addComponent("nitrogen", 1.1); + // testSystem.addComponent("n-heptane", 51); + // testSystem.addComponent("ethane", 8.53); + // testSystem.addComponent("methane", 82.7); + // testSystem.addComponent("ethane", 7.5); + // testSystem.addComponent("propane", 3.4); + // testSystem.addComponent("i-butane", 0.5); + // testSystem.addComponent("n-butane", 0.9); + // testSystem.addComponent("i-pentane", 10.24); + // testSystem.addComponent("water", 0.4); + testSystem.addComponent("MEG", 99.5); // , "kg/sec"); + testSystem.addComponent("water", 0.5); // , "kg/sec"); + // testSystem.addTBPfraction("C7", 10.36, 110.0 / 1000.0, 0.82); + // testSystem.addTBPfraction("C10", 5.31, 150.0 / 1000.0, 0.89); + // testSystem.addComponent("water", 1.1); + /* + * testSystem.addComponent("i-butane", 1.95); testSystem.addComponent("n-butane", 1.95); + * testSystem.addComponent("n-pentane", 0.95); testSystem.addComponent("i-pentane", 0.95); + * + * testSystem.addTBPfraction("C6",0.10,100.0/1000.0,0.8); + * testSystem.addTBPfraction("C7",0.060,110.0/1000.0,0.82); + * testSystem.addTBPfraction("C8",0.00453,120.0/1000.0,0.83); + * testSystem.addTBPfraction("C9",0.0031,130.0/1000.0,0.85); * - * @param args an array of {@link java.lang.String} objects + * // testSystem.addPlusFraction("C10+", 0.008201, 142.0/1000, 0.9); + * + * // testSystem.getCharacterization().characterisePlusFraction(); */ - @SuppressWarnings("unused") - public static void main(String args[]) { - SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 20, 30.0); - // SystemInterface testSystem = new SystemSrkCPAstatoil(273.15+20, 1.0); - // SystemInterface testSystem = new SystemPrEos1978(273.15+10, 12.0); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - - // testSystem.addComponent("TEG", 10.71); - testSystem.addComponent("methane", 14.01); - // testSystem.changeComponentName("methane", "methaneHYME"); - // testSystem.addComponent("ethane", 0.01); - // testSystem.addComponent("nitrogen", 1.1); - // testSystem.addComponent("n-heptane", 51); - // testSystem.addComponent("ethane", 8.53); - // testSystem.addComponent("methane", 82.7); - // testSystem.addComponent("ethane", 7.5); - // testSystem.addComponent("propane", 3.4); - // testSystem.addComponent("i-butane", 0.5); - // testSystem.addComponent("n-butane", 0.9); - // testSystem.addComponent("i-pentane", 10.24); - // testSystem.addComponent("water", 0.4); - testSystem.addComponent("MEG", 99.5);// , "kg/sec"); - testSystem.addComponent("water", 0.5);// , "kg/sec"); - // testSystem.addTBPfraction("C7", 10.36, 110.0 / 1000.0, 0.82); - // testSystem.addTBPfraction("C10", 5.31, 150.0 / 1000.0, 0.89); - // testSystem.addComponent("water", 1.1); - /* - * testSystem.addComponent("i-butane", 1.95); testSystem.addComponent("n-butane", 1.95); - * testSystem.addComponent("n-pentane", 0.95); testSystem.addComponent("i-pentane", 0.95); - * - * testSystem.addTBPfraction("C6",0.10,100.0/1000.0,0.8); - * testSystem.addTBPfraction("C7",0.060,110.0/1000.0,0.82); - * testSystem.addTBPfraction("C8",0.00453,120.0/1000.0,0.83); - * testSystem.addTBPfraction("C9",0.0031,130.0/1000.0,0.85); - * - * // testSystem.addPlusFraction("C10+", 0.008201, 142.0/1000, 0.9); - * - * // testSystem.getCharacterization().characterisePlusFraction(); - */ - testSystem.createDatabase(true); - testSystem.setMixingRule(10); - // testSystem.setMultiPhaseCheck(true); - // testSystem.setPhysicalPropertyModel(6); - // testSystem.initPhysicalProperties(); - // testSystem.getInterphaseProperties().setInterfacialTensionModel(3); - // testSystem.useVolumeCorrection(true); - try { - testOps.TPflash(); - // testSystem.tuneModel("viscosity",1.5e-4,0); - // testOps.bubblePointPressureFlash(false); - } catch (Exception e) { - logger.error(e.toString()); - } - - testSystem.initPhysicalProperties(); + testSystem.createDatabase(true); + testSystem.setMixingRule(10); + // testSystem.setMultiPhaseCheck(true); + // testSystem.setPhysicalPropertyModel(6); + // testSystem.initPhysicalProperties(); + // testSystem.getInterphaseProperties().setInterfacialTensionModel(3); + // testSystem.useVolumeCorrection(true); + try { + testOps.TPflash(); + // testSystem.tuneModel("viscosity",1.5e-4,0); + // testOps.bubblePointPressureFlash(false); + } catch (Exception e) { + logger.error(e.toString()); + } - try { - testOps.TPflash(); - // testSystem.tuneModel("viscosity",1.5e-4,0); - // testOps.bubblePointPressureFlash(false); - } catch (Exception e) { - logger.error(e.toString()); - } + testSystem.initPhysicalProperties(); - testSystem.initPhysicalProperties(); - // double a = - // testSystem.getPhase("oil").getPhysicalProperties().getDiffusionCoefficient(0, - // 1); - // testSystem.setPhysicalPropertyModel(6); - // testSystem.getPhase(0).initPhysicalProperties("viscosity"); - double visc = - testSystem.getPhase(1).getPhysicalProperties().getViscosityModel().calcViscosity(); - testSystem.display(); + try { + testOps.TPflash(); + // testSystem.tuneModel("viscosity",1.5e-4,0); + // testOps.bubblePointPressureFlash(false); + } catch (Exception e) { + logger.error(e.toString()); } + + testSystem.initPhysicalProperties(); + // double a = + // testSystem.getPhase("oil").getPhysicalProperties().getDiffusionCoefficient(0, + // 1); + // testSystem.setPhysicalPropertyModel(6); + // testSystem.getPhase(0).initPhysicalProperties("viscosity"); + double visc = + testSystem.getPhase(1).getPhysicalProperties().getViscosityModel().calcViscosity(); + testSystem.display(); + } } diff --git a/src/test/java/neqsim/physicalProperties/util/examples/TestSurfaceTenison.java b/src/test/java/neqsim/physicalProperties/util/examples/TestSurfaceTenison.java index aaa58b05ad..7c51190df1 100644 --- a/src/test/java/neqsim/physicalProperties/util/examples/TestSurfaceTenison.java +++ b/src/test/java/neqsim/physicalProperties/util/examples/TestSurfaceTenison.java @@ -16,96 +16,96 @@ * @since 2.2.3 */ public class TestSurfaceTenison { - static Logger logger = LogManager.getLogger(TestSurfaceTenison.class); + static Logger logger = LogManager.getLogger(TestSurfaceTenison.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - SystemInterface testSystem = new SystemSrkEos(273.15 + 28.66, 12.2); - // SystemInterface testSystem = new SystemPrEos(273.15 + 10.0, 50.0); - // testSystem.addComponent("CO2", 2.826); - // testSystem.addComponent("nitrogen", 0.546); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + SystemInterface testSystem = new SystemSrkEos(273.15 + 28.66, 12.2); + // SystemInterface testSystem = new SystemPrEos(273.15 + 10.0, 50.0); + // testSystem.addComponent("CO2", 2.826); + // testSystem.addComponent("nitrogen", 0.546); - // SystemInterface testSystem = new SystemPrEos(273.15 + 30, 1); - // SystemInterface testSystem = new SystemSrkCPAs(273.65, 30.3); - // testSystem.getCharacterization().setTBPModel("PedersenSRK");//(RiaziDaubert - // PedersenPR PedersenSRK - // testSystem.getCharacterization().setLumpingModel("no"); //"abLumping"; - // testSystem.getCharacterization().getLumpingModel().setNumberOfLumpedComponents(3); - testSystem.getCharacterization().setTBPModel("PedersenSRK"); - testSystem.addComponent("nitrogen", 0.037); - testSystem.addComponent("CO2", 0.475); - testSystem.addComponent("methane", 8.135); - testSystem.addComponent("ethane", 3.477); - testSystem.addComponent("propane", 1.64); - testSystem.addComponent("i-butane", 1.22); - testSystem.addComponent("n-butane", 6.857); - testSystem.addComponent("i-pentane", 6.492); - testSystem.addComponent("n-pentane", 7.515); - // testSystem.addTBPfraction("C6", 9.123, 84.9 / 1000.0, 0.6675); - testSystem.addTBPfraction("C7", 13.162, 90.0 / 1000.0, 0.7509); - // testSystem.addTBPfraction("C8", 12.641, 101.8 / 1000.0, 0.7782); - // testSystem.addTBPfraction("C9", 7.126, 115.3 / 1000.0, 0.7928); - // testSystem.addTBPfraction("C10", 22.098, 230.3 / 1000.0, 0.8454); - // testSystem.setHeavyTBPfractionAsPlusFraction(); - // testSystem.getCharacterization().characterisePlusFraction(); + // SystemInterface testSystem = new SystemPrEos(273.15 + 30, 1); + // SystemInterface testSystem = new SystemSrkCPAs(273.65, 30.3); + // testSystem.getCharacterization().setTBPModel("PedersenSRK"); //(RiaziDaubert + // PedersenPR PedersenSRK + // testSystem.getCharacterization().setLumpingModel("no"); //"abLumping"; + // testSystem.getCharacterization().getLumpingModel().setNumberOfLumpedComponents(3); + testSystem.getCharacterization().setTBPModel("PedersenSRK"); + testSystem.addComponent("nitrogen", 0.037); + testSystem.addComponent("CO2", 0.475); + testSystem.addComponent("methane", 8.135); + testSystem.addComponent("ethane", 3.477); + testSystem.addComponent("propane", 1.64); + testSystem.addComponent("i-butane", 1.22); + testSystem.addComponent("n-butane", 6.857); + testSystem.addComponent("i-pentane", 6.492); + testSystem.addComponent("n-pentane", 7.515); + // testSystem.addTBPfraction("C6", 9.123, 84.9 / 1000.0, 0.6675); + testSystem.addTBPfraction("C7", 13.162, 90.0 / 1000.0, 0.7509); + // testSystem.addTBPfraction("C8", 12.641, 101.8 / 1000.0, 0.7782); + // testSystem.addTBPfraction("C9", 7.126, 115.3 / 1000.0, 0.7928); + // testSystem.addTBPfraction("C10", 22.098, 230.3 / 1000.0, 0.8454); + // testSystem.setHeavyTBPfractionAsPlusFraction(); + // testSystem.getCharacterization().characterisePlusFraction(); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); - // testSystem.setMultiPhaseCheck(true); - // testSystem.useVolumeCorrection(true); - // testSystem.getInterphaseProperties().setInterfacialTensionModel(1); // GT == - // 1 Parac==0 + // testSystem.setMultiPhaseCheck(true); + // testSystem.useVolumeCorrection(true); + // testSystem.getInterphaseProperties().setInterfacialTensionModel(1); // GT == + // 1 Parac==0 - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - try { - // testOps.bubblePointPressureFlash(false); - // testOps.bubblePointTemperatureFlash(); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + try { + // testOps.bubblePointPressureFlash(false); + // testOps.bubblePointTemperatureFlash(); - testOps.TPflash(); - testSystem.display(); - // testSystem = testSystem.clone(); - testSystem.getInterphaseProperties().setInterfacialTensionModel("gas", "oil", - "Linear Gradient Theory"); - System.out.println("tension gas-oil " - + testSystem.getInterphaseProperties().getSurfaceTension(0, 1)); + testOps.TPflash(); + testSystem.display(); + // testSystem = testSystem.clone(); + testSystem.getInterphaseProperties().setInterfacialTensionModel("gas", "oil", + "Linear Gradient Theory"); + System.out.println( + "tension gas-oil " + testSystem.getInterphaseProperties().getSurfaceTension(0, 1)); - // testOps.TPflash(); - // testSystem.display(); - // testOps.dewPointMach("n-pentane", "dewPointTemperature", - // testSystem.getTemperature()); - // testOps.dewPointTemperatureFlash(); - } catch (Exception e) { - logger.error(e.toString()); - } - - // testSystem.getPhase(1).getComponent(1).getChemicalPotentialdNTV(0, - // testSystem.getPhase(0)); - // testSystem.getInterphaseProperties().setInterfacialTensionModel(2); // GT == - // 1 Parac==0 - // testSystem.initPhysicalProperties(); - // System.out.println("influence n-pentane " + ((GTSurfaceTension) - // testSystem.getInterphaseProperties().getSurfaceTensionModel(0)).getInfluenceParameter((2.74 - // * 1e-3), 1)); - // System.out.println("z " + ((GTSurfaceTension) - // testSystem.getInterphaseProperties().getSurfaceTensionModel(0)).getz()[40]); - // testSystem.getInterphaseProperties().getInterfacialTensionModel(i) - // testSystem.getInterphaseProperties().getSurfaceTensionModel(0).getMolarDensity(0); - // //density profile for comp 0 - // testSystem.getInterphaseProperties().getSurfaceTensionModel(0).getz(); - // //density profile for comp 0 - // testSystem.getInterphaseProperties().getSurfaceTensionModel(0).getPressure(); - // //pressure profile for comp 0 - // testSystem.getInterphaseProperties().getSurfaceTensionModel(0).getMolarDensityTotal(); - // //total density profile for comp 0 - testSystem.display(); - // System.out.println("tension gas-water " + - // testSystem.getInterphaseProperties().getSurfaceTension(0, 1)); + // testOps.TPflash(); + // testSystem.display(); + // testOps.dewPointMach("n-pentane", "dewPointTemperature", + // testSystem.getTemperature()); + // testOps.dewPointTemperatureFlash(); + } catch (Exception e) { + logger.error(e.toString()); } + + // testSystem.getPhase(1).getComponent(1).getChemicalPotentialdNTV(0, + // testSystem.getPhase(0)); + // testSystem.getInterphaseProperties().setInterfacialTensionModel(2); // GT == + // 1 Parac==0 + // testSystem.initPhysicalProperties(); + // System.out.println("influence n-pentane " + ((GTSurfaceTension) + // testSystem.getInterphaseProperties().getSurfaceTensionModel(0)).getInfluenceParameter((2.74 + // * 1e-3), 1)); + // System.out.println("z " + ((GTSurfaceTension) + // testSystem.getInterphaseProperties().getSurfaceTensionModel(0)).getz()[40]); + // testSystem.getInterphaseProperties().getInterfacialTensionModel(i) + // testSystem.getInterphaseProperties().getSurfaceTensionModel(0).getMolarDensity(0); + // //density profile for comp 0 + // testSystem.getInterphaseProperties().getSurfaceTensionModel(0).getz(); + // //density profile for comp 0 + // testSystem.getInterphaseProperties().getSurfaceTensionModel(0).getPressure(); + // //pressure profile for comp 0 + // testSystem.getInterphaseProperties().getSurfaceTensionModel(0).getMolarDensityTotal(); + // //total density profile for comp 0 + testSystem.display(); + // System.out.println("tension gas-water " + + // testSystem.getInterphaseProperties().getSurfaceTension(0, 1)); + } } diff --git a/src/test/java/neqsim/processSimulation/processEquipment/compressor/CompressorCalculationTest.java b/src/test/java/neqsim/processSimulation/processEquipment/compressor/CompressorCalculationTest.java index 9507edfc16..d6490bfbb6 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/compressor/CompressorCalculationTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/compressor/CompressorCalculationTest.java @@ -7,139 +7,126 @@ import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; -public class CompressorCalculationTest extends neqsim.NeqSimTest{ - Compressor comp1; - Stream stream_1; +public class CompressorCalculationTest extends neqsim.NeqSimTest { + Compressor comp1; + Stream stream_1; - @BeforeEach - public void setUp() { - SystemInterface testFluid = new SystemSrkEos(298.15, 50.0); + @BeforeEach + public void setUp() { + SystemInterface testFluid = new SystemSrkEos(298.15, 50.0); - testFluid.addComponent("nitrogen", 1.205); - testFluid.addComponent("CO2", 1.340); - testFluid.addComponent("methane", 87.974); - testFluid.addComponent("ethane", 5.258); - testFluid.addComponent("propane", 3.283); - testFluid.addComponent("i-butane", 0.082); - testFluid.addComponent("n-butane", 0.487); - testFluid.addComponent("i-pentane", 0.056); - testFluid.addComponent("n-pentane", 0.053); - testFluid.setMixingRule(2); - testFluid.setMultiPhaseCheck(true); + testFluid.addComponent("nitrogen", 1.205); + testFluid.addComponent("CO2", 1.340); + testFluid.addComponent("methane", 87.974); + testFluid.addComponent("ethane", 5.258); + testFluid.addComponent("propane", 3.283); + testFluid.addComponent("i-butane", 0.082); + testFluid.addComponent("n-butane", 0.487); + testFluid.addComponent("i-pentane", 0.056); + testFluid.addComponent("n-pentane", 0.053); + testFluid.setMixingRule(2); + testFluid.setMultiPhaseCheck(true); - testFluid.setTemperature(24.0, "C"); - testFluid.setPressure(48.0, "bara"); - testFluid.setTotalFlowRate(1.0, "MSm3/day"); + testFluid.setTemperature(24.0, "C"); + testFluid.setPressure(48.0, "bara"); + testFluid.setTotalFlowRate(1.0, "MSm3/day"); - stream_1 = new Stream("Stream1", testFluid); - comp1 = new Compressor("comp1", stream_1); - } + stream_1 = new Stream("Stream1", testFluid); + comp1 = new Compressor("comp1", stream_1); + } - private void setCurves() { - double[] chartConditions = new double[] { 0.3, 1.0, 1.0, 1.0 }; - double[] speed = new double[] { 12913, 12298, 11683, 11098, 10453, 9224, 8609, 8200 }; - double[][] flow = new double[][] { - { 2789.1285, 3174.0375, 3689.2288, 4179.4503, 4570.2768, 4954.7728, 5246.0329, - 5661.0331 }, - { 2571.1753, 2943.7254, 3440.2675, 3837.4448, 4253.0898, 4668.6643, 4997.1926, - 5387.4952 }, - { 2415.3793, 2763.0706, 3141.7095, 3594.7436, 4047.6467, 4494.1889, 4853.7353, - 5138.7858 }, - { 2247.2043, 2799.7342, 3178.3428, 3656.1551, 4102.778, 4394.1591, 4648.3224, - 4840.4998 }, - { 2072.8397, 2463.9483, 2836.4078, 3202.5266, 3599.6333, 3978.0203, 4257.0022, - 4517.345 }, - { 1835.9552, 2208.455, 2618.1322, 2940.8034, 3244.7852, 3530.1279, 3753.3738, - 3895.9746 }, - { 1711.3386, 1965.8848, 2356.9431, 2685.9247, 3008.5154, 3337.2855, 3591.5092 }, - { 1636.5807, 2002.8708, 2338.0319, 2642.1245, 2896.4894, 3113.6264, 3274.8764, - 3411.2977 } }; - double[][] head = new double[][] { - { 80.0375, 78.8934, 76.2142, 71.8678, 67.0062, 60.6061, 53.0499, 39.728 }, - { 72.2122, 71.8369, 68.9009, 65.8341, 60.7167, 54.702, 47.2749, 35.7471 }, - { 65.1576, 64.5253, 62.6118, 59.1619, 54.0455, 47.0059, 39.195, 31.6387 }, - { 58.6154, 56.9627, 54.6647, 50.4462, 44.4322, 38.4144, 32.9084, 28.8109 }, - { 52.3295, 51.0573, 49.5283, 46.3326, 42.3685, 37.2502, 31.4884, 25.598 }, - { 40.6578, 39.6416, 37.6008, 34.6603, 30.9503, 27.1116, 23.2713, 20.4546 }, - { 35.2705, 34.6359, 32.7228, 31.0645, 27.0985, 22.7482, 18.0113 }, - { 32.192, 31.1756, 29.1329, 26.833, 23.8909, 21.3324, 18.7726, 16.3403 }, }; - double[][] polyEff = new double[][] { - { 77.2452238409573, 79.4154186459363, 80.737960012489, 80.5229826589649, - 79.2210931638144, 75.4719133864634, 69.6034181197298, 58.7322388482707 }, - { 77.0107837113504, 79.3069974136389, 80.8941189021135, 80.7190194665918, - 79.5313242980328, 75.5912622896367, 69.6846136362097, 60.0043057990909 }, - { 77.0043065299874, 79.1690958847856, 80.8038169975675, 80.6543975614197, - 78.8532389102705, 73.6664774270613, 66.2735600426727, 57.671664571658 }, - { 77.0716623789093, 80.4629750233093, 81.1390811169072, 79.6374242667478, - 75.380928428817, 69.5332969549779, 63.7997587622339, 58.8120614497758 }, - { 76.9705872525642, 79.8335492585324, 80.9468133671171, 80.5806471927835, - 78.0462158225426, 73.0403707523258, 66.5572286338589, 59.8624822515064 }, - { 77.5063036680357, 80.2056198362559, 81.0339108025933, 79.6085962687939, - 76.3814534404405, 70.8027503005902, 64.6437367160571, 60.5299349982342 }, - { 77.8175271586685, 80.065165942218, 81.0631362122632, 79.8955051771299, - 76.1983240929369, 69.289982774309, 60.8567149372229 }, - { 78.0924334304045, 80.9353551568667, 80.7904437766234, 78.8639325223295, - 75.2170936751143, 70.3105081673411, 65.5507568533569, 61.0391468300337 } }; - comp1.getCompressorChart().setCurves(chartConditions, speed, flow, head, polyEff); + private void setCurves() { + double[] chartConditions = new double[] {0.3, 1.0, 1.0, 1.0}; + double[] speed = new double[] {12913, 12298, 11683, 11098, 10453, 9224, 8609, 8200}; + double[][] flow = new double[][] { + {2789.1285, 3174.0375, 3689.2288, 4179.4503, 4570.2768, 4954.7728, 5246.0329, 5661.0331}, + {2571.1753, 2943.7254, 3440.2675, 3837.4448, 4253.0898, 4668.6643, 4997.1926, 5387.4952}, + {2415.3793, 2763.0706, 3141.7095, 3594.7436, 4047.6467, 4494.1889, 4853.7353, 5138.7858}, + {2247.2043, 2799.7342, 3178.3428, 3656.1551, 4102.778, 4394.1591, 4648.3224, 4840.4998}, + {2072.8397, 2463.9483, 2836.4078, 3202.5266, 3599.6333, 3978.0203, 4257.0022, 4517.345}, + {1835.9552, 2208.455, 2618.1322, 2940.8034, 3244.7852, 3530.1279, 3753.3738, 3895.9746}, + {1711.3386, 1965.8848, 2356.9431, 2685.9247, 3008.5154, 3337.2855, 3591.5092}, + {1636.5807, 2002.8708, 2338.0319, 2642.1245, 2896.4894, 3113.6264, 3274.8764, 3411.2977}}; + double[][] head = + new double[][] {{80.0375, 78.8934, 76.2142, 71.8678, 67.0062, 60.6061, 53.0499, 39.728}, + {72.2122, 71.8369, 68.9009, 65.8341, 60.7167, 54.702, 47.2749, 35.7471}, + {65.1576, 64.5253, 62.6118, 59.1619, 54.0455, 47.0059, 39.195, 31.6387}, + {58.6154, 56.9627, 54.6647, 50.4462, 44.4322, 38.4144, 32.9084, 28.8109}, + {52.3295, 51.0573, 49.5283, 46.3326, 42.3685, 37.2502, 31.4884, 25.598}, + {40.6578, 39.6416, 37.6008, 34.6603, 30.9503, 27.1116, 23.2713, 20.4546}, + {35.2705, 34.6359, 32.7228, 31.0645, 27.0985, 22.7482, 18.0113}, + {32.192, 31.1756, 29.1329, 26.833, 23.8909, 21.3324, 18.7726, 16.3403},}; + double[][] polyEff = new double[][] { + {77.2452238409573, 79.4154186459363, 80.737960012489, 80.5229826589649, 79.2210931638144, + 75.4719133864634, 69.6034181197298, 58.7322388482707}, + {77.0107837113504, 79.3069974136389, 80.8941189021135, 80.7190194665918, 79.5313242980328, + 75.5912622896367, 69.6846136362097, 60.0043057990909}, + {77.0043065299874, 79.1690958847856, 80.8038169975675, 80.6543975614197, 78.8532389102705, + 73.6664774270613, 66.2735600426727, 57.671664571658}, + {77.0716623789093, 80.4629750233093, 81.1390811169072, 79.6374242667478, 75.380928428817, + 69.5332969549779, 63.7997587622339, 58.8120614497758}, + {76.9705872525642, 79.8335492585324, 80.9468133671171, 80.5806471927835, 78.0462158225426, + 73.0403707523258, 66.5572286338589, 59.8624822515064}, + {77.5063036680357, 80.2056198362559, 81.0339108025933, 79.6085962687939, 76.3814534404405, + 70.8027503005902, 64.6437367160571, 60.5299349982342}, + {77.8175271586685, 80.065165942218, 81.0631362122632, 79.8955051771299, 76.1983240929369, + 69.289982774309, 60.8567149372229}, + {78.0924334304045, 80.9353551568667, 80.7904437766234, 78.8639325223295, 75.2170936751143, + 70.3105081673411, 65.5507568533569, 61.0391468300337}}; + comp1.getCompressorChart().setCurves(chartConditions, speed, flow, head, polyEff); - comp1.getCompressorChart().setHeadUnit("kJ/kg"); + comp1.getCompressorChart().setHeadUnit("kJ/kg"); - double[] surgeflow = new double[] { 2789.0, 2550.0, 2500.0, 2200.0 }; - double[] surgehead = new double[] { 80.0, 72.0, 70.0, 65.0 }; - comp1.getCompressorChart().getSurgeCurve().setCurve(chartConditions, surgeflow, - surgehead); - // comp1.getAntiSurge().setActive(true); - comp1.getAntiSurge().setSurgeControlFactor(1.0); - } + double[] surgeflow = new double[] {2789.0, 2550.0, 2500.0, 2200.0}; + double[] surgehead = new double[] {80.0, 72.0, 70.0, 65.0}; + comp1.getCompressorChart().getSurgeCurve().setCurve(chartConditions, surgeflow, surgehead); + // comp1.getAntiSurge().setActive(true); + comp1.getAntiSurge().setSurgeControlFactor(1.0); + } - @Test - public void testCompressorChartEquals() { - Assertions.assertEquals(comp1, comp1.copy()); - setCurves(); - Assertions.assertEquals(comp1, comp1.copy()); - } + @Test + public void testCompressorChartEquals() { + Assertions.assertEquals(comp1, comp1.copy()); + setCurves(); + Assertions.assertEquals(comp1, comp1.copy()); + } - @Test - public void testRun() { - setCurves(); - comp1.setUsePolytropicCalc(true); - comp1.setSpeed(11918); - neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(stream_1); - operations.add(comp1); - operations.run(); + @Test + public void testRun() { + setCurves(); + comp1.setUsePolytropicCalc(true); + comp1.setSpeed(11918); + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(comp1); + operations.run(); - // System.out.println("power " + comp1.getPower()); - Assertions.assertEquals(1163805.2992826412, comp1.getPower(), 0.01); - Assertions.assertFalse(comp1.getAntiSurge().isSurge()); - Assertions.assertEquals(0.0, comp1.getAntiSurge().getCurrentSurgeFraction()); + // System.out.println("power " + comp1.getPower()); + Assertions.assertEquals(1163805.2992826412, comp1.getPower(), 0.01); + Assertions.assertFalse(comp1.getAntiSurge().isSurge()); + Assertions.assertEquals(0.0, comp1.getAntiSurge().getCurrentSurgeFraction()); - //System.out.println("Polytropic head from curve:" + comp1.getPolytropicHead()); + // System.out.println("Polytropic head from curve:" + comp1.getPolytropicHead()); - Assertions.assertEquals(55.40415411694987, comp1.getPolytropicHead(), 0.01); - //System.out.println("Polytropic eff from curve:" + comp1.getPolytropicEfficiency() * 100.0); - Assertions.assertEquals(0.43175024049749283, comp1.getPolytropicEfficiency(), 0.01); + Assertions.assertEquals(55.40415411694987, comp1.getPolytropicHead(), 0.01); + // System.out.println("Polytropic eff from curve:" + comp1.getPolytropicEfficiency() * 100.0); + Assertions.assertEquals(0.43175024049749283, comp1.getPolytropicEfficiency(), 0.01); - //System.out.println("flow " + stream_1.getThermoSystem().getFlowRate("m3/hr")); - //System.out.println("speed " + comp1.getCompressorChart().getSpeed( - // stream_1.getThermoSystem().getFlowRate("m3/hr") + 10.0, comp1.getPolytropicHead())); - //System.out.println("pressure out " + comp1.getOutletPressure()); - //System.out.println("temperature out " + (comp1.getOutTemperature() - 273.15) + " C"); - /* - * double temperatureOut = 273.15 + 84; - * comp1.setOutletPressure(96.0); - * comp1.setOutTemperature(temperatureOut); - * operations.run(); - * double polytropicHead = comp1.getPolytropicHead(); - * double flowRate = stream_1.getThermoSystem().getFlowRate("m3/hr"); - * double calcSpeed = comp1.getCompressorChart().getSpeed(flowRate, - * polytropicHead); - * System.out.println("polytopic head " + polytropicHead); - * System.out.println("polytopic efficiency " + - * comp1.getPolytropicEfficiency()); - * System.out.println("temperature out " + (comp1.getOutTemperature() - 273.15) - * + " C"); - * System.out.println("calculated speed " + calcSpeed); - */ - } + // System.out.println("flow " + stream_1.getThermoSystem().getFlowRate("m3/hr")); + // System.out.println("speed " + comp1.getCompressorChart().getSpeed( + // stream_1.getThermoSystem().getFlowRate("m3/hr") + 10.0, comp1.getPolytropicHead())); + // System.out.println("pressure out " + comp1.getOutletPressure()); + // System.out.println("temperature out " + (comp1.getOutTemperature() - 273.15) + " C"); + /* + * double temperatureOut = 273.15 + 84; comp1.setOutletPressure(96.0); + * comp1.setOutTemperature(temperatureOut); operations.run(); double polytropicHead = + * comp1.getPolytropicHead(); double flowRate = stream_1.getThermoSystem().getFlowRate("m3/hr"); + * double calcSpeed = comp1.getCompressorChart().getSpeed(flowRate, polytropicHead); + * System.out.println("polytopic head " + polytropicHead); + * System.out.println("polytopic efficiency " + comp1.getPolytropicEfficiency()); + * System.out.println("temperature out " + (comp1.getOutTemperature() - 273.15) + " C"); + * System.out.println("calculated speed " + calcSpeed); + */ + } } diff --git a/src/test/java/neqsim/processSimulation/processEquipment/compressor/CompressorTest.java b/src/test/java/neqsim/processSimulation/processEquipment/compressor/CompressorTest.java index 30f6ca1831..c71ed9b86f 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/compressor/CompressorTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/compressor/CompressorTest.java @@ -97,7 +97,9 @@ public void testCompressorSchultzMethod() { // System.out.println("schultz compressor power " + compressor1.getPower() / 1e6 // + " MW"); assertEquals(compressor1.getPower() / 1e6, 4.668373797540108,0.01); -// "Test case for compressor Schultz method polytropic calculation should return approximate 4.67 MW"); + // // "Test case for compressor Schultz method polytropic calculation should return + // approximate + // 4.67 MW"); } /** diff --git a/src/test/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchangerTest.java b/src/test/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchangerTest.java index 24c0fcead4..1756bf835e 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchangerTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchangerTest.java @@ -41,7 +41,7 @@ public static void test_Run1(String args[]) { HeatExchanger heatEx = new HeatExchanger("heatEx"); heatEx.setFeedStream(0, stream_Hot); - heatEx.setFeedStream(1, stream_Cold);// resyc.getOutStream()); + heatEx.setFeedStream(1, stream_Cold); // resyc.getOutStream()); Separator sep = new Separator("sep", stream_Hot); diff --git a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemTest.java b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemTest.java index f2e9d09bb7..baaa1cf436 100644 --- a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemTest.java +++ b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemTest.java @@ -450,7 +450,7 @@ public void runTEGProcessTest() { Heater bufferTank = new Heater("TEG buffer tank", stripper.getLiquidOutStream()); bufferTank.setOutTemperature(273.15 + 191.0); - Pump hotLeanTEGPump = new Pump("hot lean TEG pump", bufferTank.getOutletStream());// stripper.getSolventOutStream()); + Pump hotLeanTEGPump = new Pump("hot lean TEG pump", bufferTank.getOutletStream()); // stripper.getSolventOutStream()); hotLeanTEGPump.setOutletPressure(5.0); hotLeanTEGPump.setIsentropicEfficiency(0.6); diff --git a/src/test/java/neqsim/processSimulation/util/example/OnshoreProcess1.java b/src/test/java/neqsim/processSimulation/util/example/OnshoreProcess1.java index 7499f24fa8..2b2a45f480 100644 --- a/src/test/java/neqsim/processSimulation/util/example/OnshoreProcess1.java +++ b/src/test/java/neqsim/processSimulation/util/example/OnshoreProcess1.java @@ -16,504 +16,553 @@ import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; /** - *

OnshoreProcess1 class.

+ *

+ * OnshoreProcess1 class. + *

* * @author asmund * @version $Id: $Id * @since 2.2.3 */ public class OnshoreProcess1 { - /** - * This method is just meant to test the thermo package. - * - * @param args an array of {@link java.lang.String} objects - */ - @SuppressWarnings("unused") - public static void main(String args[]) { - try { - double totalProductionRate = 222.5808099 * 3600.0; // kg/time - double formationWater = 0.02; // m^3/day - double productionSplit = 0.999; // 1.0 means only snohvit - - // MEG injection rate - double injectionRate = 6.3;// m^3/time - double wtFracMEG = 0.9; - double molMEG = wtFracMEG * injectionRate * 1.117 * 1000.0 / 3600.0 / 0.062; - double molwater = (1.0 - wtFracMEG) * injectionRate * 1.0 * 1000.0 / 3600.0 / 0.018; - - // Snohvit reservoir system - double reservoirGasMolarMassSnohvit = 0.02186;// kg/mol - double reservoirGasFlowSnohvit = productionSplit * totalProductionRate; // kg/time - // Designbasis: - // 223.04 - // kg/sek - double reservoirTemperatureSnohvit = 273.15 + 91.4; // K - double reservoirPressureSnohvit = 264.4; // bar - double snohvitFormationWaterFlowRate = formationWater * 1000.0 / 3600.0 / 0.018 / 24.0; - // molefractions - double nitrogen_s = 2.525, CO2_s = 5.262, methane_s = 81.006, ethane_s = 5.027, - propane_s = 2.534, ibutane_s = 0.4, nbutane_s = 0.83, benzene_s = 0.078, - toluene_s = 0.09, mXylene_s = 0.061, water_s = 4.0; - double C6_s = 0.352, C7_s = 0.469, C8_s = 0.407, C9_s = 0.203, C10_s = 0.086, - C11_s = 0.063, C12_s = 0.062, C13_s = 0.049, C14_s = 0.033, C15_s = 0.025, - C16_s = 0.015, C17_s = 0.015, C18_s = 0.010, C19_s = 0.007, C20plus_s = 0.031; - double C6_M_s = 85.0, C7_M_s = 90.7, C8_M_s = 104.1, C9_M_s = 119.8, C10_M_s = 133.0, - C11_M_s = 147.0, C12_M_s = 159.0, C13_M_s = 173.0, C14_M_s = 188.0, - C15_M_s = 202.0, C16_M_s = 213.0, C17_M_s = 230.0, C18_M_s = 247.0, - C19_M_s = 258.0, C20plus_M_s = 315.0; - double C6_d_s = 0.668, C7_d_s = 0.745, C8_d_s = 0.767, C9_d_s = 0.776, C10_d_s = 0.783, - C11_d_s = 0.787, C12_d_s = 0.799, C13_d_s = 0.811, C14_d_s = 0.821, - C15_d_s = 0.828, C16_d_s = 0.836, C17_d_s = 0.834, C18_d_s = 0.835, - C19_d_s = 0.845, C20plus_d_s = 0.872; - - // Albatross reservoir system - double reservoirGasMolarMassAlbatross = 0.022;// kg/mol - double reservoirGasFlowAlbatross = (1.0 - productionSplit) * totalProductionRate; // kg/time - double reservoirTemperatureAlbatross = 273.15 + 65.0; // K - double reservoirPressureAlbatross = 210.0; // bar - // molefractions - double nitrogen_a = 0.1, CO2_a = 7.0, methane_a = 80.43, ethane_a = 4.99, - propane_a = 2.51, ibutane_a = 0.39, nbutane_a = 0.82, benzene_a = 0.077, - toluene_a = 0.089, mXylene_a = 0.06, water_a = 2.0; - double C6_a = 0.352, C7_a = 0.91, C8_a = 0.317, C9_a = 0.142, C10_a = 0.141, - C11_a = 0.063, C12_a = 0.062; - double C6_M_a = 85.0, C7_M_a = 90.7, C8_M_a = 104.1, C9_M_a = 119.8, C10_M_a = 133.0, - C11_M_a = 147.0, C12_M_a = 159.0; - double C6_d_a = 0.668, C7_d_a = 0.745, C8_d_a = 0.767, C9_d_a = 0.776, C10_d_a = 0.783, - C11_d_a = 0.787, C12_d_a = 0.799; - - neqsim.thermo.system.SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos( - reservoirTemperatureSnohvit, reservoirPressureSnohvit); - neqsim.thermo.system.SystemInterface testSystem3 = - new neqsim.thermo.system.SystemSrkEos(reservoirTemperatureSnohvit, - reservoirPressureSnohvit); - neqsim.thermo.system.SystemInterface testSystem2 = - new neqsim.thermo.system.SystemSrkEos(reservoirTemperatureAlbatross, - reservoirPressureAlbatross); - neqsim.thermo.system.SystemInterface testSystem4 = - new neqsim.thermo.system.SystemSrkEos(reservoirTemperatureAlbatross, - reservoirPressureAlbatross); - neqsim.thermo.system.SystemInterface snohvitFormationWater = - new neqsim.thermo.system.SystemSrkEos(reservoirTemperatureSnohvit, - reservoirPressureSnohvit); - - testSystem.addComponent("nitrogen", - nitrogen_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); - testSystem.addComponent("CO2", - CO2_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); - testSystem.addComponent("methane", - methane_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); - testSystem.addComponent("ethane", - ethane_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); - testSystem.addComponent("propane", - propane_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); - testSystem.addComponent("i-butane", - ibutane_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); - testSystem.addComponent("n-butane", - nbutane_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); - testSystem.addComponent("benzene", - benzene_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); - testSystem.addComponent("toluene", - toluene_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); - testSystem.addComponent("m-Xylene", - mXylene_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); - - testSystem.addTBPfraction("C6", - C6_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, - C6_M_s / 1000.0, C6_d_s); - testSystem.addTBPfraction("C7", - C7_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, - C7_M_s / 1000.0, C7_d_s); - testSystem.addTBPfraction("C8", - C8_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, - C8_M_s / 1000.0, C8_d_s); - testSystem.addTBPfraction("C9", - C9_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, - C9_M_s / 1000.0, C9_d_s); - testSystem.addTBPfraction("C10", - C10_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, - C10_M_s / 1000.0, C10_d_s); - testSystem.addTBPfraction("C11", - C11_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, - C11_M_s / 1000.0, C11_d_s); - testSystem.addTBPfraction("C12", - C12_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, - C12_M_s / 1000.0, C12_d_s); - testSystem.addTBPfraction("C13", - C13_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, - C13_M_s / 1000.0, C13_d_s); - testSystem.addTBPfraction("C14", - C14_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, - C14_M_s / 1000.0, C14_d_s); - testSystem.addTBPfraction("C15", - C15_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, - C15_M_s / 1000.0, C15_d_s); - testSystem.addTBPfraction("C16", - C16_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, - C16_M_s / 1000.0, C16_d_s); - testSystem.addTBPfraction("C17", - C17_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, - C17_M_s / 1000.0, C17_d_s); - testSystem.addTBPfraction("C18", - C18_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, - C18_M_s / 1000.0, C18_d_s); - testSystem.addTBPfraction("C19", - C19_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, - C19_M_s / 1000.0, C19_d_s); - testSystem.addTBPfraction("C20", - C20plus_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, - C20plus_M_s / 1000.0, C20plus_d_s); - - testSystem.addComponent("water", - water_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); - // //testSystem.addComponent("Fe++", - // 1e-10*reservoirGasFlowSnohvit/360000.0/reservoirGasMolarMassSnohvit); - // //testSystem.addComponent("Na+", - // 1e-10*reservoirGasFlowSnohvit/360000.0/reservoirGasMolarMassSnohvit); - // //testSystem.addComponent("OH-", - // 3e-10*reservoirGasFlowSnohvit/360000.0/reservoirGasMolarMassSnohvit); - testSystem.addComponent("MEG", - 1e-10 * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); - - // if(testSystem.characterizePlusFraction()){ - // testSystem.getCharacterization().setPseudocomponents(true); - // testSystem.getCharacterization().setNumberOfPseudocomponents(5); - // testSystem.getCharacterization().addCharacterizedPlusFraction(); - // } - - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - - testSystem2.addComponent("nitrogen", nitrogen_a * reservoirGasFlowAlbatross / 360000.0 - / reservoirGasMolarMassAlbatross); - testSystem2.addComponent("CO2", - CO2_a * reservoirGasFlowAlbatross / 360000.0 / reservoirGasMolarMassAlbatross); - testSystem2.addComponent("methane", methane_a * reservoirGasFlowAlbatross / 360000.0 - / reservoirGasMolarMassAlbatross); - testSystem2.addComponent("ethane", ethane_a * reservoirGasFlowAlbatross / 360000.0 - / reservoirGasMolarMassAlbatross); - testSystem2.addComponent("propane", propane_a * reservoirGasFlowAlbatross / 360000.0 - / reservoirGasMolarMassAlbatross); - testSystem2.addComponent("i-butane", ibutane_a * reservoirGasFlowAlbatross / 360000.0 - / reservoirGasMolarMassAlbatross); - testSystem2.addComponent("n-butane", nbutane_a * reservoirGasFlowAlbatross / 360000.0 - / reservoirGasMolarMassAlbatross); - testSystem2.addComponent("benzene", benzene_a * reservoirGasFlowAlbatross / 360000.0 - / reservoirGasMolarMassAlbatross); - testSystem2.addComponent("toluene", toluene_a * reservoirGasFlowAlbatross / 360000.0 - / reservoirGasMolarMassAlbatross); - testSystem2.addComponent("m-Xylene", mXylene_a * reservoirGasFlowAlbatross / 360000.0 - / reservoirGasMolarMassAlbatross); - - testSystem2.addComponent("water", water_a * reservoirGasFlowAlbatross / 360000.0 - / reservoirGasMolarMassAlbatross); - // testSystem2.addComponent("Fe++", - // 1e-10*reservoirGasFlowAlbatross/360000.0/reservoirGasMolarMassAlbatross); - // testSystem2.addComponent("Na+", - // 1e-10*reservoirGasFlowAlbatross/360000.0/reservoirGasMolarMassAlbatross); - // testSystem2.addComponent("OH-", - // 3e-10*reservoirGasFlowAlbatross/360000.0/reservoirGasMolarMassAlbatross); - testSystem2.addComponent("MEG", - 1e-10 * reservoirGasFlowAlbatross / 360000.0 / reservoirGasMolarMassAlbatross); - testSystem2.setMixingRule(2); - - testSystem3.addComponent("water", molwater); - // testSystem3.addComponent("Na+", (molwater+molMEG)/5000.0); - // testSystem3.addComponent("OH-", (molwater+molMEG)/5000.0); - testSystem3.addComponent("MEG", molMEG); - testSystem3.setMixingRule(2); - - snohvitFormationWater.addComponent("water", snohvitFormationWaterFlowRate); - snohvitFormationWater.setMixingRule(2); - - StreamInterface stream_1 = new Stream("Stream1", testSystem); - - ThreePhaseSeparator separator = new ThreePhaseSeparator("Separator 1", stream_1); - MeasurementDeviceInterface reservoirTemperaturTransmitter = - new TemperatureTransmitter(stream_1); - MeasurementDeviceInterface reservoirPressureTransmitter = - new PressureTransmitter(stream_1); - WaterContentAnalyser waterAnalyser = - new WaterContentAnalyser(separator.getGasOutStream()); - waterAnalyser.setName("Snohvit Total Water Analyser"); - MolarMassAnalyser molarMassAnalyser = - new MolarMassAnalyser(separator.getGasOutStream()); - molarMassAnalyser.setName("Snohvit molar mass analyser"); - StreamInterface stream_2 = separator.getGasOutStream(); - stream_2.setName("Gas From Snohvit Reservoir"); - - StreamInterface MEGstream_1 = new Stream("MEG Stream1", testSystem3); - StreamInterface snohvitFormationWaterStream = - new Stream("snohvitFormationWaterStream", snohvitFormationWater); - - Mixer MEGmixer1 = new Mixer("MEG Mixer 1"); - MEGmixer1.addStream(stream_2); - MEGmixer1.addStream(MEGstream_1); - MEGmixer1.addStream(snohvitFormationWaterStream); - - ThrottlingValve valve1 = - new ThrottlingValve("snohvit valve", MEGmixer1.getOutletStream()); - valve1.setOutletPressure(125.0); - - // Albatross reservoir stream - Stream stream_3 = new Stream("Stream2", testSystem2); - Separator separator2 = new Separator("Separator 2", stream_3); - WaterContentAnalyser waterAnalyser2 = - new WaterContentAnalyser(separator2.getGasOutStream()); - waterAnalyser2.setName("Albatross Total Water Analyser"); - MolarMassAnalyser molarMassAnalyser2 = - new MolarMassAnalyser(separator2.getGasOutStream()); - molarMassAnalyser2.setName("Albatross molar mass analyser"); - - StreamInterface stream_4 = separator2.getGasOutStream(); - stream_4.setName("Gas From Albatross Reservoir"); - - ThrottlingValve valve2 = new ThrottlingValve("albatross valve", stream_4); - valve2.setOutletPressure(125.0); - - // Field mixer - Mixer mixer1 = new Mixer("Field Mixer"); - mixer1.addStream(valve1.getOutletStream()); - mixer1.addStream(valve2.getOutletStream()); - - WaterContentAnalyser waterAnalyser3 = - new WaterContentAnalyser(mixer1.getOutletStream()); - waterAnalyser3.setName("Total Water Analyser"); - - // Pipeline - SimpleTPoutPipeline pipeLine1 = - new SimpleTPoutPipeline("snohvit pipeline", mixer1.getOutletStream()); - pipeLine1.setOutPressure(55.0); - pipeLine1.setOutTemperature(273.15 + 5.0); - pipeLine1.setNumberOfLegs(1); - pipeLine1.setPipeDiameters(new double[] {1.2, 1.2}); - pipeLine1.setLegPositions(new double[] {0, 150000.0}); - pipeLine1.setOuterTemperatures(new double[] {0.0, 0.0}); - - //// IronIonSaturationStream ironSatStream = new - // IronIonSaturationStream(pipeLine1.getOutStream()); - - // // Land plant - ThreePhaseSeparator slugCatcher = - new ThreePhaseSeparator("slugCatcher", pipeLine1.getOutletStream()); - - VolumeFlowTransmitter volumeTransmitter2 = - new VolumeFlowTransmitter(slugCatcher.getOilOutStream()); - volumeTransmitter2.setMeasuredPhaseNumber(0); - volumeTransmitter2.setName("Condensate Volume Flow From Slug Catcher"); - - VolumeFlowTransmitter volumeTransmitter1 = - new VolumeFlowTransmitter(slugCatcher.getWaterOutStream()); - volumeTransmitter1.setMeasuredPhaseNumber(0); - volumeTransmitter1.setName("MEG Volume FLow From Slug Catcher"); - - VolumeFlowTransmitter volumeTransmitter3 = - new VolumeFlowTransmitter(slugCatcher.getGasOutStream()); - volumeTransmitter3.setMeasuredPhaseNumber(0); - volumeTransmitter3.setName("Gas Volume FLow From Slug Catcher"); - - // Stream stream_5 = new Stream(slugCatcher.getWaterOutStream()); - // stream_5.setName("MEG stream from slugcatcher"); - - Heater condensateheater1 = - new Heater("Condensate heater1", slugCatcher.getOilOutStream()); - condensateheater1.setdT(23.4); - - // Heater gasHeater = new Heater(slugCatcher.getGasOutStream()); - // gasHeater.setName("Gas heater after slugcatcher"); - // gasHeater.setdT(30.0); - - ThreePhaseSeparator condensateSeparator = - new ThreePhaseSeparator("condensateSeparator", - condensateheater1.getOutletStream()); - - // Heater MEGheater1 = new Heater(stream_5); - // MEGheater1.setName("MEG heater1"); - // MEGheater1.setdT(23.4); - - // SnohvitCO2RemovalModule co2Module = new SnohvitCO2RemovalModule(); - // co2Module.addInputStream("streamToAbsorber", gasHeater.getOutStream()); - - // Heater MEGheater2 = new Heater(MEGheater1.getOutStream()); - // MEGheater2.setName("MEG heater2"); - // MEGheater2.setdT(20.0); - - // ThrottlingValve valve3 = new ThrottlingValve("MEG flash valve 1", - // MEGheater2.getOutStream()); - // valve3.setOutletPressure(1.4); - - // ThreePhaseSeparator separator3 = new ThreePhaseSeparator("MEG LP - // separator", valve3.getOutStream()); - - // VolumeFlowTransmitter volumeTransmitter5= new - // VolumeFlowTransmitter(separator3.getGasOutStream()); - // volumeTransmitter5.setName("MEG Valve 1 Gas Volume FLow"); - - // Heater MEGheater3 = new Heater(separator3.getWaterOutStream()); - // MEGheater3.setName("MEG heater3"); - // MEGheater3.setdT(-35.0); - - // ThrottlingValve valve4 = new ThrottlingValve("MEG flash valve 2", - // MEGheater3.getOutStream()); - // valve4.setOutletPressure(1.05); - - //// //ScalePotentialCheckStream stream_6 = new - // ScalePotentialCheckStream(valve4.getOutStream()); - - // Stream stream_7 = new Stream(valve4.getOutStream()); - - // ThreePhaseSeparator separator4 = new ThreePhaseSeparator("MEG Storage - // tank 13-TA-101", stream_7); - - // Stream stream_8 = new - // Stream(co2Module.getOutputStream("streamFromAbsorber")); - - // GasHeater.setName("Gas heater"); - // GasHeater.setdT(-35.0); - - // CO2-removal - // Stream streamToCO2removal = new Stream(slugCatcher.getGasOutStream()); - // streamToCO2removal.setName("Gas to CO2 removal"); - // VolumeFlowTransmitter volumeTransmitter_StreamToCO2removal = new - // VolumeFlowTransmitter(streamToCO2removal); - // volumeTransmitter_StreamToCO2removal.setUnit("Nm^3/day"); - // volumeTransmitter_StreamToCO2removal.setName("Stream to CO2 removal - // Volume FLow"); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(stream_1); - operations.add(reservoirTemperaturTransmitter); - operations.add(reservoirPressureTransmitter); - operations.add(separator); - operations.add(stream_2); - operations.add(MEGstream_1); - operations.add(snohvitFormationWaterStream); - operations.add(MEGmixer1); - operations.add(valve1); - - operations.add(stream_3); - operations.add(separator2); - operations.add(stream_4); - operations.add(valve2); - - operations.add(mixer1); - operations.add(pipeLine1); - ////// operations.add(ironSatStream); - operations.add(slugCatcher); - operations.add(condensateheater1); - // operations.add(gasHeater); - operations.add(condensateSeparator); - // operations.add(stream_5); - - // operations.add(MEGheater1); - // operations.add(co2Module); - // operations.add(MEGheater2); - - // operations.add(valve3); - // operations.add(separator3); - - //// operations.add(streamToCO2removal); - - // operations.add(MEGheater3); - // operations.add(valve4); - - //// operations.add(stream_6); - // operations.add(stream_7); - // operations.add(separator4); - // operations.add(stream_8); - - // add transmitters - // operations.add(waterAnalyser); - // operations.add(waterAnalyser2); - // operations.add(waterAnalyser3); - // operations.add(molarMassAnalyser); - // operations.add(molarMassAnalyser2); - operations.add(volumeTransmitter1); - operations.add(volumeTransmitter2); - operations.add(volumeTransmitter3); - // operations.add(volumeTransmitter_StreamToCO2removal); - - operations.run(); - operations.displayResult(); - operations.reportMeasuredValues(); - - double wateraqphase = - slugCatcher.getWaterOutStream().getThermoSystem().getTotalNumberOfMoles() - * slugCatcher.getWaterOutStream().getThermoSystem().getPhase(0) - .getComponent("water").getMolarMass() - * slugCatcher.getWaterOutStream().getThermoSystem().getPhase(0) - .getComponent("water").getx() - * 3600.0; - - System.out.println("kg water in gas phase from slug catcher " - + slugCatcher.getGasOutStream().getThermoSystem().getTotalNumberOfMoles() - * slugCatcher.getGasOutStream().getThermoSystem().getPhase(0) - .getComponent("water").getMolarMass() - * slugCatcher.getGasOutStream().getThermoSystem().getPhase(0) - .getComponent("water").getx() - * 3600.0 - + " kg/hr"); - System.out.println("kg water in condensate phase from slug catcher " - + slugCatcher.getOilOutStream().getThermoSystem().getTotalNumberOfMoles() - * slugCatcher.getOilOutStream().getThermoSystem().getPhase(0) - .getComponent("water").getMolarMass() - * slugCatcher.getOilOutStream().getThermoSystem().getPhase(0) - .getComponent("water").getx() - * 3600.0 - + " kg/hr"); - System.out.println( - "kg water in aqueous phase from slug catcher " + wateraqphase + " kg/hr"); - - double MEGaqphase = - slugCatcher.getWaterOutStream().getThermoSystem().getTotalNumberOfMoles() - * slugCatcher.getWaterOutStream().getThermoSystem().getPhase(0) - .getComponent("MEG").getMolarMass() - * slugCatcher.getWaterOutStream().getThermoSystem().getPhase(0) - .getComponent("MEG").getx() - * 3600.0; - System.out.println("kg MEG in gas phase from slug catcher " - + slugCatcher.getGasOutStream().getThermoSystem().getTotalNumberOfMoles() - * slugCatcher.getGasOutStream().getThermoSystem().getPhase(0) - .getComponent("MEG").getMolarMass() - * slugCatcher.getGasOutStream().getThermoSystem().getPhase(0) - .getComponent("MEG").getx() - * 3600.0 - + " kg/hr"); - System.out.println("kg MEG in condensate phase from slug catcher " - + slugCatcher.getOilOutStream().getThermoSystem().getTotalNumberOfMoles() - * slugCatcher.getOilOutStream().getThermoSystem().getPhase(0) - .getComponent("MEG").getMolarMass() - * slugCatcher.getOilOutStream().getThermoSystem().getPhase(0) - .getComponent("MEG").getx() - * 3600.0 - + " kg/hr"); - System.out - .println("kg MEG in aqueous phase from slug catcher " + MEGaqphase + " kg/hr"); - - System.out.println("wt% MEG " + MEGaqphase / (wateraqphase + MEGaqphase) * 100); - - volumeTransmitter3.setUnit("Sm^3/day"); - System.out.println("gas rate from slug catcher " - + volumeTransmitter3.getMeasuredValue() / 1.0e6 + " MSm^3/day"); - System.out.println("gas rate from slug catcher " - + volumeTransmitter3.getMeasuredValue() / 1.0e6 + " MSm^3/day"); - System.out.println("water in gas phase from slug catcher " - + slugCatcher.getGasOutStream().getThermoSystem().getTotalNumberOfMoles() - * slugCatcher.getGasOutStream().getThermoSystem().getPhase(0) - .getComponent("water").getMolarMass() - * slugCatcher.getGasOutStream().getThermoSystem().getPhase(0) - .getComponent("water").getx() - * 3600.0 / (volumeTransmitter3.getMeasuredValue() / 24.0) * 1000.0 - + " gr water/Sm^3 gas"); - System.out.println("gas rate " - + slugCatcher.getGasOutStream().getThermoSystem().getTotalNumberOfMoles() - * slugCatcher.getGasOutStream().getThermoSystem().getPhase(0) - .getMolarMass() - * 3600.0 - + " kg gas/hr"); - } catch (Exception e) { - e.printStackTrace(); - } + /** + * This method is just meant to test the thermo package. + * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String[] args) { + try { + double totalProductionRate = 222.5808099 * 3600.0; // kg/time + double formationWater = 0.02; // m^3/day + double productionSplit = 0.999; // 1.0 means only snohvit + + // MEG injection rate + double injectionRate = 6.3; // m^3/time + double wtFracMEG = 0.9; + double molMEG = wtFracMEG * injectionRate * 1.117 * 1000.0 / 3600.0 / 0.062; + double molwater = (1.0 - wtFracMEG) * injectionRate * 1.0 * 1000.0 / 3600.0 / 0.018; + + // Snohvit reservoir system + double reservoirGasMolarMassSnohvit = 0.02186; // kg/mol + double reservoirGasFlowSnohvit = productionSplit * totalProductionRate; // kg/time + // Designbasis: + // 223.04 + // kg/sek + double reservoirTemperatureSnohvit = 273.15 + 91.4; // K + double reservoirPressureSnohvit = 264.4; // bar + double snohvitFormationWaterFlowRate = formationWater * 1000.0 / 3600.0 / 0.018 / 24.0; + // molefractions + double nitrogen_s = 2.525; + double CO2_s = 5.262; + double methane_s = 81.006; + double ethane_s = 5.027; + double propane_s = 2.534; + double ibutane_s = 0.4; + double nbutane_s = 0.83; + double benzene_s = 0.078; + double toluene_s = 0.09; + double mXylene_s = 0.061; + double water_s = 4.0; + double C6_s = 0.352; + double C7_s = 0.469; + double C8_s = 0.407; + double C9_s = 0.203; + double C10_s = 0.086; + double C11_s = 0.063; + double C12_s = 0.062; + double C13_s = 0.049; + double C14_s = 0.033; + double C15_s = 0.025; + double C16_s = 0.015; + double C17_s = 0.015; + double C18_s = 0.010; + double C19_s = 0.007; + double C20plus_s = 0.031; + double C6_M_s = 85.0; + double C7_M_s = 90.7; + double C8_M_s = 104.1; + double C9_M_s = 119.8; + double C10_M_s = 133.0; + double C11_M_s = 147.0; + double C12_M_s = 159.0; + double C13_M_s = 173.0; + double C14_M_s = 188.0; + double C15_M_s = 202.0; + double C16_M_s = 213.0; + double C17_M_s = 230.0; + double C18_M_s = 247.0; + double C19_M_s = 258.0; + double C20plus_M_s = 315.0; + double C6_d_s = 0.668; + + double C7_d_s = 0.745; + double C8_d_s = 0.767; + double C9_d_s = 0.776; + double C10_d_s = 0.783; + double C11_d_s = 0.787; + double C12_d_s = 0.799; + double C13_d_s = 0.811; + double C14_d_s = 0.821; + double C15_d_s = 0.828; + double C16_d_s = 0.836; + double C17_d_s = 0.834; + double C18_d_s = 0.835; + double C19_d_s = 0.845; + double C20plus_d_s = 0.872; + // Albatross reservoir system + double reservoirGasMolarMassAlbatross = 0.022; // kg/mol + double reservoirGasFlowAlbatross = (1.0 - productionSplit) * totalProductionRate; // kg/time + double reservoirTemperatureAlbatross = 273.15 + 65.0; // K + double reservoirPressureAlbatross = 210.0; // bar + // molefractions + double nitrogen_a = 0.1; + double CO2_a = 7.0; + double methane_a = 80.43; + double ethane_a = 4.99; + double propane_a = 2.51; + double ibutane_a = 0.39; + double nbutane_a = 0.82; + double benzene_a = 0.077; + double toluene_a = 0.089; + double mXylene_a = 0.06; + double water_a = 2.0; + double C6_a = 0.352; + double C7_a = 0.91; + double C8_a = 0.317; + double C9_a = 0.142; + double C10_a = 0.141; + double C11_a = 0.063; + double C12_a = 0.062; + double C6_M_a = 85.0; + double C7_M_a = 90.7; + double C8_M_a = 104.1; + double C9_M_a = 119.8; + double C10_M_a = 133.0; + double C11_M_a = 147.0; + double C12_M_a = 159.0; + double C6_d_a = 0.668; + + double C7_d_a = 0.745; + double C8_d_a = 0.767; + double C9_d_a = 0.776; + double C10_d_a = 0.783; + double C11_d_a = 0.787; + double C12_d_a = 0.799; + neqsim.thermo.system.SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos( + reservoirTemperatureSnohvit, reservoirPressureSnohvit); + neqsim.thermo.system.SystemInterface testSystem3 = new neqsim.thermo.system.SystemSrkEos( + reservoirTemperatureSnohvit, reservoirPressureSnohvit); + neqsim.thermo.system.SystemInterface testSystem2 = new neqsim.thermo.system.SystemSrkEos( + reservoirTemperatureAlbatross, reservoirPressureAlbatross); + neqsim.thermo.system.SystemInterface testSystem4 = new neqsim.thermo.system.SystemSrkEos( + reservoirTemperatureAlbatross, reservoirPressureAlbatross); + neqsim.thermo.system.SystemInterface snohvitFormationWater = + new neqsim.thermo.system.SystemSrkEos(reservoirTemperatureSnohvit, + reservoirPressureSnohvit); + + testSystem.addComponent("nitrogen", + nitrogen_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); + testSystem.addComponent("CO2", + CO2_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); + testSystem.addComponent("methane", + methane_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); + testSystem.addComponent("ethane", + ethane_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); + testSystem.addComponent("propane", + propane_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); + testSystem.addComponent("i-butane", + ibutane_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); + testSystem.addComponent("n-butane", + nbutane_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); + testSystem.addComponent("benzene", + benzene_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); + testSystem.addComponent("toluene", + toluene_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); + testSystem.addComponent("m-Xylene", + mXylene_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); + + testSystem.addTBPfraction("C6", + C6_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, C6_M_s / 1000.0, + C6_d_s); + testSystem.addTBPfraction("C7", + C7_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, C7_M_s / 1000.0, + C7_d_s); + testSystem.addTBPfraction("C8", + C8_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, C8_M_s / 1000.0, + C8_d_s); + testSystem.addTBPfraction("C9", + C9_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, C9_M_s / 1000.0, + C9_d_s); + testSystem.addTBPfraction("C10", + C10_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, + C10_M_s / 1000.0, C10_d_s); + testSystem.addTBPfraction("C11", + C11_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, + C11_M_s / 1000.0, C11_d_s); + testSystem.addTBPfraction("C12", + C12_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, + C12_M_s / 1000.0, C12_d_s); + testSystem.addTBPfraction("C13", + C13_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, + C13_M_s / 1000.0, C13_d_s); + testSystem.addTBPfraction("C14", + C14_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, + C14_M_s / 1000.0, C14_d_s); + testSystem.addTBPfraction("C15", + C15_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, + C15_M_s / 1000.0, C15_d_s); + testSystem.addTBPfraction("C16", + C16_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, + C16_M_s / 1000.0, C16_d_s); + testSystem.addTBPfraction("C17", + C17_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, + C17_M_s / 1000.0, C17_d_s); + testSystem.addTBPfraction("C18", + C18_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, + C18_M_s / 1000.0, C18_d_s); + testSystem.addTBPfraction("C19", + C19_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, + C19_M_s / 1000.0, C19_d_s); + testSystem.addTBPfraction("C20", + C20plus_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit, + C20plus_M_s / 1000.0, C20plus_d_s); + + testSystem.addComponent("water", + water_s * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); + // //testSystem.addComponent("Fe++", + // 1e-10*reservoirGasFlowSnohvit/360000.0/reservoirGasMolarMassSnohvit); + // //testSystem.addComponent("Na+", + // 1e-10*reservoirGasFlowSnohvit/360000.0/reservoirGasMolarMassSnohvit); + // //testSystem.addComponent("OH-", + // 3e-10*reservoirGasFlowSnohvit/360000.0/reservoirGasMolarMassSnohvit); + testSystem.addComponent("MEG", + 1e-10 * reservoirGasFlowSnohvit / 360000.0 / reservoirGasMolarMassSnohvit); + + // if(testSystem.characterizePlusFraction()){ + // testSystem.getCharacterization().setPseudocomponents(true); + // testSystem.getCharacterization().setNumberOfPseudocomponents(5); + // testSystem.getCharacterization().addCharacterizedPlusFraction(); + // } + + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + + testSystem2.addComponent("nitrogen", + nitrogen_a * reservoirGasFlowAlbatross / 360000.0 / reservoirGasMolarMassAlbatross); + testSystem2.addComponent("CO2", + CO2_a * reservoirGasFlowAlbatross / 360000.0 / reservoirGasMolarMassAlbatross); + testSystem2.addComponent("methane", + methane_a * reservoirGasFlowAlbatross / 360000.0 / reservoirGasMolarMassAlbatross); + testSystem2.addComponent("ethane", + ethane_a * reservoirGasFlowAlbatross / 360000.0 / reservoirGasMolarMassAlbatross); + testSystem2.addComponent("propane", + propane_a * reservoirGasFlowAlbatross / 360000.0 / reservoirGasMolarMassAlbatross); + testSystem2.addComponent("i-butane", + ibutane_a * reservoirGasFlowAlbatross / 360000.0 / reservoirGasMolarMassAlbatross); + testSystem2.addComponent("n-butane", + nbutane_a * reservoirGasFlowAlbatross / 360000.0 / reservoirGasMolarMassAlbatross); + testSystem2.addComponent("benzene", + benzene_a * reservoirGasFlowAlbatross / 360000.0 / reservoirGasMolarMassAlbatross); + testSystem2.addComponent("toluene", + toluene_a * reservoirGasFlowAlbatross / 360000.0 / reservoirGasMolarMassAlbatross); + testSystem2.addComponent("m-Xylene", + mXylene_a * reservoirGasFlowAlbatross / 360000.0 / reservoirGasMolarMassAlbatross); + + testSystem2.addComponent("water", + water_a * reservoirGasFlowAlbatross / 360000.0 / reservoirGasMolarMassAlbatross); + // testSystem2.addComponent("Fe++", + // 1e-10*reservoirGasFlowAlbatross/360000.0/reservoirGasMolarMassAlbatross); + // testSystem2.addComponent("Na+", + // 1e-10*reservoirGasFlowAlbatross/360000.0/reservoirGasMolarMassAlbatross); + // testSystem2.addComponent("OH-", + // 3e-10*reservoirGasFlowAlbatross/360000.0/reservoirGasMolarMassAlbatross); + testSystem2.addComponent("MEG", + 1e-10 * reservoirGasFlowAlbatross / 360000.0 / reservoirGasMolarMassAlbatross); + testSystem2.setMixingRule(2); + + testSystem3.addComponent("water", molwater); + // testSystem3.addComponent("Na+", (molwater+molMEG)/5000.0); + // testSystem3.addComponent("OH-", (molwater+molMEG)/5000.0); + testSystem3.addComponent("MEG", molMEG); + testSystem3.setMixingRule(2); + + snohvitFormationWater.addComponent("water", snohvitFormationWaterFlowRate); + snohvitFormationWater.setMixingRule(2); + + StreamInterface stream_1 = new Stream("Stream1", testSystem); + + ThreePhaseSeparator separator = new ThreePhaseSeparator("Separator 1", stream_1); + MeasurementDeviceInterface reservoirTemperaturTransmitter = + new TemperatureTransmitter(stream_1); + MeasurementDeviceInterface reservoirPressureTransmitter = new PressureTransmitter(stream_1); + WaterContentAnalyser waterAnalyser = new WaterContentAnalyser(separator.getGasOutStream()); + waterAnalyser.setName("Snohvit Total Water Analyser"); + MolarMassAnalyser molarMassAnalyser = new MolarMassAnalyser(separator.getGasOutStream()); + molarMassAnalyser.setName("Snohvit molar mass analyser"); + StreamInterface stream_2 = separator.getGasOutStream(); + stream_2.setName("Gas From Snohvit Reservoir"); + + StreamInterface MEGstream_1 = new Stream("MEG Stream1", testSystem3); + StreamInterface snohvitFormationWaterStream = + new Stream("snohvitFormationWaterStream", snohvitFormationWater); + + Mixer MEGmixer1 = new Mixer("MEG Mixer 1"); + MEGmixer1.addStream(stream_2); + MEGmixer1.addStream(MEGstream_1); + MEGmixer1.addStream(snohvitFormationWaterStream); + + ThrottlingValve valve1 = new ThrottlingValve("snohvit valve", MEGmixer1.getOutletStream()); + valve1.setOutletPressure(125.0); + + // Albatross reservoir stream + Stream stream_3 = new Stream("Stream2", testSystem2); + Separator separator2 = new Separator("Separator 2", stream_3); + WaterContentAnalyser waterAnalyser2 = new WaterContentAnalyser(separator2.getGasOutStream()); + waterAnalyser2.setName("Albatross Total Water Analyser"); + MolarMassAnalyser molarMassAnalyser2 = new MolarMassAnalyser(separator2.getGasOutStream()); + molarMassAnalyser2.setName("Albatross molar mass analyser"); + + StreamInterface stream_4 = separator2.getGasOutStream(); + stream_4.setName("Gas From Albatross Reservoir"); + + ThrottlingValve valve2 = new ThrottlingValve("albatross valve", stream_4); + valve2.setOutletPressure(125.0); + + // Field mixer + Mixer mixer1 = new Mixer("Field Mixer"); + mixer1.addStream(valve1.getOutletStream()); + mixer1.addStream(valve2.getOutletStream()); + + WaterContentAnalyser waterAnalyser3 = new WaterContentAnalyser(mixer1.getOutletStream()); + waterAnalyser3.setName("Total Water Analyser"); + + // Pipeline + SimpleTPoutPipeline pipeLine1 = + new SimpleTPoutPipeline("snohvit pipeline", mixer1.getOutletStream()); + pipeLine1.setOutPressure(55.0); + pipeLine1.setOutTemperature(273.15 + 5.0); + pipeLine1.setNumberOfLegs(1); + pipeLine1.setPipeDiameters(new double[] {1.2, 1.2}); + pipeLine1.setLegPositions(new double[] {0, 150000.0}); + pipeLine1.setOuterTemperatures(new double[] {0.0, 0.0}); + + //// IronIonSaturationStream ironSatStream = new + // IronIonSaturationStream(pipeLine1.getOutStream()); + + // // Land plant + ThreePhaseSeparator slugCatcher = + new ThreePhaseSeparator("slugCatcher", pipeLine1.getOutletStream()); + + VolumeFlowTransmitter volumeTransmitter2 = + new VolumeFlowTransmitter(slugCatcher.getOilOutStream()); + volumeTransmitter2.setMeasuredPhaseNumber(0); + volumeTransmitter2.setName("Condensate Volume Flow From Slug Catcher"); + + VolumeFlowTransmitter volumeTransmitter1 = + new VolumeFlowTransmitter(slugCatcher.getWaterOutStream()); + volumeTransmitter1.setMeasuredPhaseNumber(0); + volumeTransmitter1.setName("MEG Volume FLow From Slug Catcher"); + + VolumeFlowTransmitter volumeTransmitter3 = + new VolumeFlowTransmitter(slugCatcher.getGasOutStream()); + volumeTransmitter3.setMeasuredPhaseNumber(0); + volumeTransmitter3.setName("Gas Volume FLow From Slug Catcher"); + + // Stream stream_5 = new Stream(slugCatcher.getWaterOutStream()); + // stream_5.setName("MEG stream from slugcatcher"); + + Heater condensateheater1 = new Heater("Condensate heater1", slugCatcher.getOilOutStream()); + condensateheater1.setdT(23.4); + + // Heater gasHeater = new Heater(slugCatcher.getGasOutStream()); + // gasHeater.setName("Gas heater after slugcatcher"); + // gasHeater.setdT(30.0); + + ThreePhaseSeparator condensateSeparator = + new ThreePhaseSeparator("condensateSeparator", condensateheater1.getOutletStream()); + + // Heater MEGheater1 = new Heater(stream_5); + // MEGheater1.setName("MEG heater1"); + // MEGheater1.setdT(23.4); + + // SnohvitCO2RemovalModule co2Module = new SnohvitCO2RemovalModule(); + // co2Module.addInputStream("streamToAbsorber", gasHeater.getOutStream()); + + // Heater MEGheater2 = new Heater(MEGheater1.getOutStream()); + // MEGheater2.setName("MEG heater2"); + // MEGheater2.setdT(20.0); + + // ThrottlingValve valve3 = new ThrottlingValve("MEG flash valve 1", + // MEGheater2.getOutStream()); + // valve3.setOutletPressure(1.4); + + // ThreePhaseSeparator separator3 = new ThreePhaseSeparator("MEG LP + // separator", valve3.getOutStream()); + + // VolumeFlowTransmitter volumeTransmitter5= new + // VolumeFlowTransmitter(separator3.getGasOutStream()); + // volumeTransmitter5.setName("MEG Valve 1 Gas Volume FLow"); + + // Heater MEGheater3 = new Heater(separator3.getWaterOutStream()); + // MEGheater3.setName("MEG heater3"); + // MEGheater3.setdT(-35.0); + + // ThrottlingValve valve4 = new ThrottlingValve("MEG flash valve 2", + // MEGheater3.getOutStream()); + // valve4.setOutletPressure(1.05); + + //// //ScalePotentialCheckStream stream_6 = new + // ScalePotentialCheckStream(valve4.getOutStream()); + + // Stream stream_7 = new Stream(valve4.getOutStream()); + + // ThreePhaseSeparator separator4 = new ThreePhaseSeparator("MEG Storage + // tank 13-TA-101", stream_7); + + // Stream stream_8 = new + // Stream(co2Module.getOutputStream("streamFromAbsorber")); + + // GasHeater.setName("Gas heater"); + // GasHeater.setdT(-35.0); + + // CO2-removal + // Stream streamToCO2removal = new Stream(slugCatcher.getGasOutStream()); + // streamToCO2removal.setName("Gas to CO2 removal"); + // VolumeFlowTransmitter volumeTransmitter_StreamToCO2removal = new + // VolumeFlowTransmitter(streamToCO2removal); + // volumeTransmitter_StreamToCO2removal.setUnit("Nm^3/day"); + // volumeTransmitter_StreamToCO2removal.setName("Stream to CO2 removal + // Volume FLow"); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(reservoirTemperaturTransmitter); + operations.add(reservoirPressureTransmitter); + operations.add(separator); + operations.add(stream_2); + operations.add(MEGstream_1); + operations.add(snohvitFormationWaterStream); + operations.add(MEGmixer1); + operations.add(valve1); + + operations.add(stream_3); + operations.add(separator2); + operations.add(stream_4); + operations.add(valve2); + + operations.add(mixer1); + operations.add(pipeLine1); + ////// operations.add(ironSatStream); + operations.add(slugCatcher); + operations.add(condensateheater1); + // operations.add(gasHeater); + operations.add(condensateSeparator); + // operations.add(stream_5); + + // operations.add(MEGheater1); + // operations.add(co2Module); + // operations.add(MEGheater2); + + // operations.add(valve3); + // operations.add(separator3); + + //// operations.add(streamToCO2removal); + + // operations.add(MEGheater3); + // operations.add(valve4); + + //// operations.add(stream_6); + // operations.add(stream_7); + // operations.add(separator4); + // operations.add(stream_8); + + // add transmitters + // operations.add(waterAnalyser); + // operations.add(waterAnalyser2); + // operations.add(waterAnalyser3); + // operations.add(molarMassAnalyser); + // operations.add(molarMassAnalyser2); + operations.add(volumeTransmitter1); + operations.add(volumeTransmitter2); + operations.add(volumeTransmitter3); + // operations.add(volumeTransmitter_StreamToCO2removal); + + operations.run(); + operations.displayResult(); + operations.reportMeasuredValues(); + + double wateraqphase = slugCatcher.getWaterOutStream().getThermoSystem() + .getTotalNumberOfMoles() + * slugCatcher.getWaterOutStream().getThermoSystem().getPhase(0).getComponent("water") + .getMolarMass() + * slugCatcher.getWaterOutStream().getThermoSystem().getPhase(0).getComponent("water") + .getx() + * 3600.0; + + System.out.println("kg water in gas phase from slug catcher " + slugCatcher.getGasOutStream() + .getThermoSystem().getTotalNumberOfMoles() + * slugCatcher.getGasOutStream().getThermoSystem().getPhase(0).getComponent("water") + .getMolarMass() + * slugCatcher.getGasOutStream().getThermoSystem().getPhase(0).getComponent("water") + .getx() + * 3600.0 + + " kg/hr"); + System.out.println("kg water in condensate phase from slug catcher " + slugCatcher + .getOilOutStream().getThermoSystem().getTotalNumberOfMoles() + * slugCatcher.getOilOutStream().getThermoSystem().getPhase(0).getComponent("water") + .getMolarMass() + * slugCatcher.getOilOutStream().getThermoSystem().getPhase(0).getComponent("water") + .getx() + * 3600.0 + + " kg/hr"); + System.out.println("kg water in aqueous phase from slug catcher " + wateraqphase + " kg/hr"); + + double MEGaqphase = slugCatcher.getWaterOutStream().getThermoSystem().getTotalNumberOfMoles() + * slugCatcher.getWaterOutStream().getThermoSystem().getPhase(0).getComponent("MEG") + .getMolarMass() + * slugCatcher.getWaterOutStream().getThermoSystem().getPhase(0).getComponent("MEG").getx() + * 3600.0; + System.out.println("kg MEG in gas phase from slug catcher " + slugCatcher.getGasOutStream() + .getThermoSystem().getTotalNumberOfMoles() + * slugCatcher.getGasOutStream().getThermoSystem().getPhase(0).getComponent("MEG") + .getMolarMass() + * slugCatcher.getGasOutStream().getThermoSystem().getPhase(0).getComponent("MEG") + .getx() + * 3600.0 + + " kg/hr"); + System.out.println("kg MEG in condensate phase from slug catcher " + slugCatcher + .getOilOutStream().getThermoSystem().getTotalNumberOfMoles() + * slugCatcher.getOilOutStream().getThermoSystem().getPhase(0).getComponent("MEG") + .getMolarMass() + * slugCatcher.getOilOutStream().getThermoSystem().getPhase(0).getComponent("MEG") + .getx() + * 3600.0 + + " kg/hr"); + System.out.println("kg MEG in aqueous phase from slug catcher " + MEGaqphase + " kg/hr"); + + System.out.println("wt% MEG " + MEGaqphase / (wateraqphase + MEGaqphase) * 100); + + volumeTransmitter3.setUnit("Sm^3/day"); + System.out.println("gas rate from slug catcher " + + volumeTransmitter3.getMeasuredValue() / 1.0e6 + " MSm^3/day"); + System.out.println("gas rate from slug catcher " + + volumeTransmitter3.getMeasuredValue() / 1.0e6 + " MSm^3/day"); + System.out.println("water in gas phase from slug catcher " + slugCatcher.getGasOutStream() + .getThermoSystem().getTotalNumberOfMoles() + * slugCatcher.getGasOutStream().getThermoSystem().getPhase(0).getComponent("water") + .getMolarMass() + * slugCatcher.getGasOutStream().getThermoSystem().getPhase(0).getComponent("water") + .getx() + * 3600.0 / (volumeTransmitter3.getMeasuredValue() / 24.0) * 1000.0 + + " gr water/Sm^3 gas"); + System.out.println("gas rate " + slugCatcher.getGasOutStream().getThermoSystem() + .getTotalNumberOfMoles() + * slugCatcher.getGasOutStream().getThermoSystem().getPhase(0).getMolarMass() * 3600.0 + + " kg gas/hr"); + } catch (Exception e) { + e.printStackTrace(); } + } } diff --git a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillation.java b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillation.java index 2eefd621ca..92ade32cf9 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillation.java +++ b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillation.java @@ -26,309 +26,297 @@ * @since 2.2.3 */ public class TEGdehydrationProcessDistillation { - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - @SuppressWarnings("unused") - public static void main(String[] args) { - // Create the input fluid to the TEG process and saturate it with water at - // scrubber conditions - neqsim.thermo.system.SystemInterface feedGas = - new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 42.0, 10.00); - feedGas.addComponent("nitrogen", 1.03); - feedGas.addComponent("CO2", 1.42); - feedGas.addComponent("methane", 83.88); - feedGas.addComponent("ethane", 8.07); - feedGas.addComponent("propane", 3.54); - feedGas.addComponent("i-butane", 0.54); - feedGas.addComponent("n-butane", 0.84); - feedGas.addComponent("i-pentane", 0.21); - feedGas.addComponent("n-pentane", 0.19); - feedGas.addComponent("n-hexane", 0.28); - feedGas.addComponent("water", 0.0); - feedGas.addComponent("TEG", 0); - feedGas.createDatabase(true); - feedGas.setMixingRule(10); - feedGas.setMultiPhaseCheck(true); - - Stream dryFeedGas = new Stream("dry feed gas", feedGas); - dryFeedGas.setFlowRate(11.23, "MSm3/day"); - dryFeedGas.setTemperature(30.4, "C"); - dryFeedGas.setPressure(52.21, "bara"); - - StreamSaturatorUtil saturatedFeedGas = - new StreamSaturatorUtil("water saturator", dryFeedGas); - - Stream waterSaturatedFeedGas = - new Stream("water saturated feed gas", saturatedFeedGas.getOutletStream()); - - neqsim.thermo.system.SystemInterface feedTEG = feedGas.clone(); - feedTEG.setMolarComposition( - new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.03, 0.97}); - - Stream TEGFeed = new Stream("lean TEG to absorber", feedTEG); - TEGFeed.setFlowRate(6862.5, "kg/hr"); - TEGFeed.setTemperature(43.0, "C"); - TEGFeed.setPressure(52.21, "bara"); - - SimpleTEGAbsorber absorber = new SimpleTEGAbsorber("TEG absorber"); - absorber.addGasInStream(waterSaturatedFeedGas); - absorber.addSolventInStream(TEGFeed); - absorber.setNumberOfStages(5); - absorber.setStageEfficiency(0.55); - - Stream dehydratedGas = new Stream("dry gas from absorber", absorber.getGasOutStream()); - Stream richTEG = new Stream("rich TEG from absorber", absorber.getSolventOutStream()); - - ThrottlingValve glycol_flash_valve = - new ThrottlingValve("Rich TEG HP flash valve", richTEG); - glycol_flash_valve.setOutletPressure(4.9); - - Heater richGLycolHeaterCondenser = - new Heater("rich TEG preheater", glycol_flash_valve.getOutletStream()); - - HeatExchanger heatEx2 = new HeatExchanger("rich TEG heat exchanger 1", - richGLycolHeaterCondenser.getOutletStream()); - heatEx2.setGuessOutTemperature(273.15 + 62.0); - heatEx2.setUAvalue(220.0); - - Separator flashSep = new Separator("degasing separator", heatEx2.getOutStream(0)); - - Stream flashGas = new Stream("gas from degasing separator", flashSep.getGasOutStream()); - - Stream flashLiquid = - new Stream("liquid from degasing separator", flashSep.getLiquidOutStream()); - - HeatExchanger heatEx = new HeatExchanger("rich TEG heat exchanger 2", flashLiquid); - heatEx.setGuessOutTemperature(273.15 + 130.0); - heatEx.setUAvalue(600.0); - - ThrottlingValve glycol_flash_valve2 = - new ThrottlingValve("LP flash valve", heatEx.getOutStream(0)); - glycol_flash_valve2.setName("Rich TEG LP flash valve"); - glycol_flash_valve2.setOutletPressure(1.23); - - neqsim.thermo.system.SystemInterface stripGas = feedGas.clone(); - stripGas.setMolarComposition( - new double[] {0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}); - - Stream strippingGas = new Stream("stripGas", stripGas); - strippingGas.setFlowRate(40.0, "Sm3/hr"); - strippingGas.setTemperature(80.0, "C"); - strippingGas.setPressure(1.23, "bara"); - - Stream gasToReboiler = strippingGas.clone(); - gasToReboiler.setName("gas to reboiler"); - - DistillationColumn column = new DistillationColumn(1, true, true); - column.setName("TEG regeneration column"); - column.addFeedStream(glycol_flash_valve2.getOutletStream(), 0); - column.getReboiler().setOutTemperature(273.15 + 206.6); - column.getCondenser().setOutTemperature(273.15 + 100.0); - column.getReboiler().addStream(gasToReboiler); - column.setTopPressure(1.0); - column.setBottomPressure(1.23); - - Heater coolerRegenGas = new Heater("regen gas cooler", column.getGasOutStream()); - coolerRegenGas.setOutTemperature(273.15 + 35.5); - - Separator sepregenGas = - new Separator("regen gas separator", coolerRegenGas.getOutletStream()); - - Stream gasToFlare = new Stream("gas to flare", sepregenGas.getGasOutStream()); - - Stream liquidToTrreatment = - new Stream("water to treatment", sepregenGas.getLiquidOutStream()); - - WaterStripperColumn stripper = new WaterStripperColumn("TEG stripper"); - stripper.addSolventInStream(column.getLiquidOutStream()); - stripper.addGasInStream(strippingGas); - stripper.setNumberOfStages(4); - stripper.setStageEfficiency(0.5); - - Recycle recycleGasFromStripper = new Recycle("stripping gas recirc"); - recycleGasFromStripper.addStream(stripper.getGasOutStream()); - recycleGasFromStripper.setOutletStream(gasToReboiler); - - Heater bufferTank = new Heater("TEG buffer tank", stripper.getSolventOutStream()); - bufferTank.setOutTemperature(273.15 + 185.0); - - Pump hotLeanTEGPump = new Pump("hot lean TEG pump", bufferTank.getOutletStream());// stripper.getSolventOutStream()); - hotLeanTEGPump.setOutletPressure(20.0); - hotLeanTEGPump.setIsentropicEfficiency(0.75); - - heatEx.setFeedStream(1, hotLeanTEGPump.getOutletStream()); - - heatEx2.setFeedStream(1, heatEx.getOutStream(1)); - - Heater coolerhOTteg3 = new Heater("lean TEG cooler",heatEx2.getOutStream(1)); - coolerhOTteg3.setOutTemperature(273.15 + 43.0); - - Pump hotLeanTEGPump2 = new Pump("lean TEG HP pump", coolerhOTteg3.getOutletStream()); - hotLeanTEGPump2.setOutletPressure(52.21); - hotLeanTEGPump2.setIsentropicEfficiency(0.75); - - Stream leanTEGtoabs = new Stream("lean TEG to absorber", hotLeanTEGPump2.getOutletStream()); - - neqsim.thermo.system.SystemInterface pureTEG = feedGas.clone(); - pureTEG.setMolarComposition( - new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}); - - Stream makeupTEG = new Stream("makeup TEG", pureTEG); - makeupTEG.setFlowRate(1e-6, "kg/hr"); - makeupTEG.setTemperature(43.0, "C"); - makeupTEG.setPressure(52.21, "bara"); - - Calculator makeupCalculator = new Calculator("TEG makeup calculator"); - makeupCalculator.addInputVariable(dehydratedGas); - makeupCalculator.addInputVariable(flashGas); - makeupCalculator.addInputVariable(gasToFlare); - makeupCalculator.addInputVariable(liquidToTrreatment); - makeupCalculator.setOutputVariable(makeupTEG); - - StaticMixer makeupMixer = new StaticMixer("makeup mixer"); - makeupMixer.addStream(leanTEGtoabs); - makeupMixer.addStream(makeupTEG); - - Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); - resycleLeanTEG.addStream(makeupMixer.getOutletStream()); - resycleLeanTEG.setOutletStream(TEGFeed); - resycleLeanTEG.setPriority(200); - resycleLeanTEG.setDownstreamProperty("flow rate"); - - richGLycolHeaterCondenser.setEnergyStream(column.getCondenser().getEnergyStream()); - // richGLycolHeater.isSetEnergyStream(); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(dryFeedGas); - operations.add(saturatedFeedGas); - operations.add(waterSaturatedFeedGas); - operations.add(TEGFeed); - operations.add(absorber); - operations.add(dehydratedGas); - operations.add(richTEG); - operations.add(glycol_flash_valve); - operations.add(richGLycolHeaterCondenser); - operations.add(heatEx2); - operations.add(flashSep); - operations.add(flashGas); - operations.add(flashLiquid); - operations.add(heatEx); - operations.add(glycol_flash_valve2); - operations.add(gasToReboiler); - operations.add(column); - operations.add(coolerRegenGas); - operations.add(sepregenGas); - operations.add(gasToFlare); - operations.add(liquidToTrreatment); - operations.add(strippingGas); - operations.add(stripper); - operations.add(recycleGasFromStripper); - operations.add(bufferTank); - operations.add(hotLeanTEGPump); - operations.add(coolerhOTteg3); - operations.add(hotLeanTEGPump2); - operations.add(leanTEGtoabs); - operations.add(makeupCalculator); - operations.add(makeupTEG); - operations.add(makeupMixer); - operations.add(resycleLeanTEG); - - operations.run(); - // operations.run(); - - operations.save("c:/temp/TEGprocessHX.neqsim"); - /// operations = ProcessSystem.open("c:/temp/TEGprocess.neqsim"); - // ((DistillationColumn)operations.getUnit("TEG regeneration - /// column")).setTopPressure(1.2); - // operations.run(); - // ((DistillationColumn)operations.getUnit("TEG regeneration - /// column")).setNumberOfTrays(2); - System.out.println( - "water in wet gas " + ((Stream) operations.getUnit("water saturated feed gas")) - .getFluid().getPhase(0).getComponent("water").getz() * 1.0e6 * 0.01802 - * 101325.0 / (8.314 * 288.15)); - System.out.println( - "water in dry gas " + ((Stream) operations.getUnit("dry gas from absorber")) - .getFluid().getPhase(0).getComponent("water").getz() * 1.0e6); - System.out.println("reboiler duty (KW) " - + ((Reboiler) ((DistillationColumn) operations.getUnit("TEG regeneration column")) - .getReboiler()).getDuty() / 1.0e3); - System.out.println("wt lean TEG " - + ((WaterStripperColumn) operations.getUnit("TEG stripper")).getSolventOutStream() - .getFluid().getPhase("aqueous").getWtFrac("TEG") * 100.0); - - double waterInWetGasppm = - waterSaturatedFeedGas.getFluid().getPhase(0).getComponent("water").getz() * 1.0e6; - double waterInWetGaskgMSm3 = waterInWetGasppm * 0.01802 * 101325.0 / (8.314 * 288.15); - double TEGfeedwt = TEGFeed.getFluid().getPhase("aqueous").getWtFrac("TEG"); - double TEGfeedflw = TEGFeed.getFlowRate("kg/hr"); - double waterInDehydratedGasppm = - dehydratedGas.getFluid().getPhase(0).getComponent("water").getz() * 1.0e6; - double waterInDryGaskgMSm3 = - waterInDehydratedGasppm * 0.01802 * 101325.0 / (8.314 * 288.15); - double richTEG2 = richTEG.getFluid().getPhase("aqueous").getWtFrac("TEG"); - System.out.println( - "reboiler duty (KW) " + ((Reboiler) column.getReboiler()).getDuty() / 1.0e3); - System.out.println("flow rate from reboiler " - + ((Reboiler) column.getReboiler()).getLiquidOutStream().getFlowRate("kg/hr")); - System.out.println("flow rate from stripping column " - + stripper.getLiquidOutStream().getFlowRate("kg/hr")); - System.out.println("flow rate from pump2 " - + hotLeanTEGPump2.getOutletStream().getFluid().getFlowRate("kg/hr")); - System.out.println("makeup TEG " + makeupTEG.getFluid().getFlowRate("kg/hr")); - - TEGFeed.getFluid().display(); - absorber.run(); - - System.out.println("pump power " + hotLeanTEGPump.getDuty()); - System.out.println("pump2 power " + hotLeanTEGPump2.getDuty()); - System.out.println("wt lean TEG after reboiler " - + column.getLiquidOutStream().getFluid().getPhase("aqueous").getWtFrac("TEG")); - System.out.println("temperature from pump " - + (hotLeanTEGPump2.getOutletStream().getTemperature() - 273.15)); - - System.out.println("flow rate from reboiler " - + ((Reboiler) column.getReboiler()).getLiquidOutStream().getFlowRate("kg/hr")); - System.out.println("flow rate from pump2 " - + hotLeanTEGPump2.getOutletStream().getFluid().getFlowRate("kg/hr")); - System.out.println("flow rate to flare " + gasToFlare.getFluid().getFlowRate("kg/hr")); - - System.out.println("condenser duty " - + ((Condenser) ((DistillationColumn) operations.getUnit("TEG regeneration column")) - .getCondenser()).getDuty() / 1.0e3); - System.out.println("richGLycolHeaterCondenser duty " - + richGLycolHeaterCondenser.getEnergyStream().getDuty() / 1.0e3); - System.out.println("richGLycolHeaterCondenser temperature out " - + richGLycolHeaterCondenser.getOutletStream().getTemperature("C")); - richGLycolHeaterCondenser.run(); - - hotLeanTEGPump.getOutletStream().displayResult(); - flashLiquid.displayResult(); - - System.out.println("Temperature rich TEG out of reflux condenser " - + richGLycolHeaterCondenser.getOutletStream().getTemperature("C")); - heatEx.displayResult(); - System.out.println("glycol out temperature " - + glycol_flash_valve2.getOutletStream().getFluid().getTemperature("C")); - System.out - .println("glycol out temperature2 " + heatEx2.getOutStream(0).getTemperature("C")); - System.out - .println("glycol out temperature2 " + heatEx2.getOutStream(1).getTemperature("C")); - - System.out.println("out water rate LP valve" + glycol_flash_valve2.getOutletStream() - .getFluid() - .getPhase(0).getComponent("water").getNumberOfmoles()); - System.out.println("glycol out water rate reboil " + ((Reboiler) column.getReboiler()) - .getLiquidOutStream().getFluid().getComponent("water").getNumberOfmoles()); - System.out.println("glycol out water rate condens " + ((Condenser) column.getCondenser()) - .getGasOutStream().getFluid().getComponent("water").getNumberOfmoles()); - System.out.println("recycle out water rate " + recycleGasFromStripper.getOutletStream() - .getFluid().getComponent("water").getNumberOfmoles()); - } + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String[] args) { + // Create the input fluid to the TEG process and saturate it with water at + // scrubber conditions + neqsim.thermo.system.SystemInterface feedGas = + new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 42.0, 10.00); + feedGas.addComponent("nitrogen", 1.03); + feedGas.addComponent("CO2", 1.42); + feedGas.addComponent("methane", 83.88); + feedGas.addComponent("ethane", 8.07); + feedGas.addComponent("propane", 3.54); + feedGas.addComponent("i-butane", 0.54); + feedGas.addComponent("n-butane", 0.84); + feedGas.addComponent("i-pentane", 0.21); + feedGas.addComponent("n-pentane", 0.19); + feedGas.addComponent("n-hexane", 0.28); + feedGas.addComponent("water", 0.0); + feedGas.addComponent("TEG", 0); + feedGas.createDatabase(true); + feedGas.setMixingRule(10); + feedGas.setMultiPhaseCheck(true); + + Stream dryFeedGas = new Stream("dry feed gas", feedGas); + dryFeedGas.setFlowRate(11.23, "MSm3/day"); + dryFeedGas.setTemperature(30.4, "C"); + dryFeedGas.setPressure(52.21, "bara"); + + StreamSaturatorUtil saturatedFeedGas = new StreamSaturatorUtil("water saturator", dryFeedGas); + + Stream waterSaturatedFeedGas = + new Stream("water saturated feed gas", saturatedFeedGas.getOutletStream()); + + neqsim.thermo.system.SystemInterface feedTEG = feedGas.clone(); + feedTEG.setMolarComposition( + new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.03, 0.97}); + + Stream TEGFeed = new Stream("lean TEG to absorber", feedTEG); + TEGFeed.setFlowRate(6862.5, "kg/hr"); + TEGFeed.setTemperature(43.0, "C"); + TEGFeed.setPressure(52.21, "bara"); + + SimpleTEGAbsorber absorber = new SimpleTEGAbsorber("TEG absorber"); + absorber.addGasInStream(waterSaturatedFeedGas); + absorber.addSolventInStream(TEGFeed); + absorber.setNumberOfStages(5); + absorber.setStageEfficiency(0.55); + + Stream dehydratedGas = new Stream("dry gas from absorber", absorber.getGasOutStream()); + Stream richTEG = new Stream("rich TEG from absorber", absorber.getSolventOutStream()); + + ThrottlingValve glycol_flash_valve = new ThrottlingValve("Rich TEG HP flash valve", richTEG); + glycol_flash_valve.setOutletPressure(4.9); + + Heater richGLycolHeaterCondenser = + new Heater("rich TEG preheater", glycol_flash_valve.getOutletStream()); + + HeatExchanger heatEx2 = + new HeatExchanger("rich TEG heat exchanger 1", richGLycolHeaterCondenser.getOutletStream()); + heatEx2.setGuessOutTemperature(273.15 + 62.0); + heatEx2.setUAvalue(220.0); + + Separator flashSep = new Separator("degasing separator", heatEx2.getOutStream(0)); + + Stream flashGas = new Stream("gas from degasing separator", flashSep.getGasOutStream()); + + Stream flashLiquid = + new Stream("liquid from degasing separator", flashSep.getLiquidOutStream()); + + HeatExchanger heatEx = new HeatExchanger("rich TEG heat exchanger 2", flashLiquid); + heatEx.setGuessOutTemperature(273.15 + 130.0); + heatEx.setUAvalue(600.0); + + ThrottlingValve glycol_flash_valve2 = + new ThrottlingValve("LP flash valve", heatEx.getOutStream(0)); + glycol_flash_valve2.setName("Rich TEG LP flash valve"); + glycol_flash_valve2.setOutletPressure(1.23); + + neqsim.thermo.system.SystemInterface stripGas = feedGas.clone(); + stripGas.setMolarComposition( + new double[] {0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}); + + Stream strippingGas = new Stream("stripGas", stripGas); + strippingGas.setFlowRate(40.0, "Sm3/hr"); + strippingGas.setTemperature(80.0, "C"); + strippingGas.setPressure(1.23, "bara"); + + Stream gasToReboiler = strippingGas.clone(); + gasToReboiler.setName("gas to reboiler"); + + DistillationColumn column = new DistillationColumn(1, true, true); + column.setName("TEG regeneration column"); + column.addFeedStream(glycol_flash_valve2.getOutletStream(), 0); + column.getReboiler().setOutTemperature(273.15 + 206.6); + column.getCondenser().setOutTemperature(273.15 + 100.0); + column.getReboiler().addStream(gasToReboiler); + column.setTopPressure(1.0); + column.setBottomPressure(1.23); + + Heater coolerRegenGas = new Heater("regen gas cooler", column.getGasOutStream()); + coolerRegenGas.setOutTemperature(273.15 + 35.5); + + Separator sepregenGas = new Separator("regen gas separator", coolerRegenGas.getOutletStream()); + + Stream gasToFlare = new Stream("gas to flare", sepregenGas.getGasOutStream()); + + Stream liquidToTrreatment = new Stream("water to treatment", sepregenGas.getLiquidOutStream()); + + WaterStripperColumn stripper = new WaterStripperColumn("TEG stripper"); + stripper.addSolventInStream(column.getLiquidOutStream()); + stripper.addGasInStream(strippingGas); + stripper.setNumberOfStages(4); + stripper.setStageEfficiency(0.5); + + Recycle recycleGasFromStripper = new Recycle("stripping gas recirc"); + recycleGasFromStripper.addStream(stripper.getGasOutStream()); + recycleGasFromStripper.setOutletStream(gasToReboiler); + + Heater bufferTank = new Heater("TEG buffer tank", stripper.getSolventOutStream()); + bufferTank.setOutTemperature(273.15 + 185.0); + + Pump hotLeanTEGPump = new Pump("hot lean TEG pump", bufferTank.getOutletStream()); // stripper.getSolventOutStream()); + hotLeanTEGPump.setOutletPressure(20.0); + hotLeanTEGPump.setIsentropicEfficiency(0.75); + + heatEx.setFeedStream(1, hotLeanTEGPump.getOutletStream()); + + heatEx2.setFeedStream(1, heatEx.getOutStream(1)); + + Heater coolerhOTteg3 = new Heater("lean TEG cooler", heatEx2.getOutStream(1)); + coolerhOTteg3.setOutTemperature(273.15 + 43.0); + + Pump hotLeanTEGPump2 = new Pump("lean TEG HP pump", coolerhOTteg3.getOutletStream()); + hotLeanTEGPump2.setOutletPressure(52.21); + hotLeanTEGPump2.setIsentropicEfficiency(0.75); + + Stream leanTEGtoabs = new Stream("lean TEG to absorber", hotLeanTEGPump2.getOutletStream()); + + neqsim.thermo.system.SystemInterface pureTEG = feedGas.clone(); + pureTEG.setMolarComposition( + new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}); + + Stream makeupTEG = new Stream("makeup TEG", pureTEG); + makeupTEG.setFlowRate(1e-6, "kg/hr"); + makeupTEG.setTemperature(43.0, "C"); + makeupTEG.setPressure(52.21, "bara"); + + Calculator makeupCalculator = new Calculator("TEG makeup calculator"); + makeupCalculator.addInputVariable(dehydratedGas); + makeupCalculator.addInputVariable(flashGas); + makeupCalculator.addInputVariable(gasToFlare); + makeupCalculator.addInputVariable(liquidToTrreatment); + makeupCalculator.setOutputVariable(makeupTEG); + + StaticMixer makeupMixer = new StaticMixer("makeup mixer"); + makeupMixer.addStream(leanTEGtoabs); + makeupMixer.addStream(makeupTEG); + + Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); + resycleLeanTEG.addStream(makeupMixer.getOutletStream()); + resycleLeanTEG.setOutletStream(TEGFeed); + resycleLeanTEG.setPriority(200); + resycleLeanTEG.setDownstreamProperty("flow rate"); + + richGLycolHeaterCondenser.setEnergyStream(column.getCondenser().getEnergyStream()); + // richGLycolHeater.isSetEnergyStream(); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(dryFeedGas); + operations.add(saturatedFeedGas); + operations.add(waterSaturatedFeedGas); + operations.add(TEGFeed); + operations.add(absorber); + operations.add(dehydratedGas); + operations.add(richTEG); + operations.add(glycol_flash_valve); + operations.add(richGLycolHeaterCondenser); + operations.add(heatEx2); + operations.add(flashSep); + operations.add(flashGas); + operations.add(flashLiquid); + operations.add(heatEx); + operations.add(glycol_flash_valve2); + operations.add(gasToReboiler); + operations.add(column); + operations.add(coolerRegenGas); + operations.add(sepregenGas); + operations.add(gasToFlare); + operations.add(liquidToTrreatment); + operations.add(strippingGas); + operations.add(stripper); + operations.add(recycleGasFromStripper); + operations.add(bufferTank); + operations.add(hotLeanTEGPump); + operations.add(coolerhOTteg3); + operations.add(hotLeanTEGPump2); + operations.add(leanTEGtoabs); + operations.add(makeupCalculator); + operations.add(makeupTEG); + operations.add(makeupMixer); + operations.add(resycleLeanTEG); + + operations.run(); + // operations.run(); + + operations.save("c:/temp/TEGprocessHX.neqsim"); + /// operations = ProcessSystem.open("c:/temp/TEGprocess.neqsim"); + // ((DistillationColumn)operations.getUnit("TEG regeneration + /// column")).setTopPressure(1.2); + // operations.run(); + // ((DistillationColumn)operations.getUnit("TEG regeneration + /// column")).setNumberOfTrays(2); + System.out.println("water in wet gas " + + ((Stream) operations.getUnit("water saturated feed gas")).getFluid().getPhase(0) + .getComponent("water").getz() * 1.0e6 * 0.01802 * 101325.0 / (8.314 * 288.15)); + System.out.println("water in dry gas " + ((Stream) operations.getUnit("dry gas from absorber")) + .getFluid().getPhase(0).getComponent("water").getz() * 1.0e6); + System.out.println("reboiler duty (KW) " + + ((Reboiler) ((DistillationColumn) operations.getUnit("TEG regeneration column")) + .getReboiler()).getDuty() / 1.0e3); + System.out.println("wt lean TEG " + ((WaterStripperColumn) operations.getUnit("TEG stripper")) + .getSolventOutStream().getFluid().getPhase("aqueous").getWtFrac("TEG") * 100.0); + + double waterInWetGasppm = + waterSaturatedFeedGas.getFluid().getPhase(0).getComponent("water").getz() * 1.0e6; + double waterInWetGaskgMSm3 = waterInWetGasppm * 0.01802 * 101325.0 / (8.314 * 288.15); + double TEGfeedwt = TEGFeed.getFluid().getPhase("aqueous").getWtFrac("TEG"); + double TEGfeedflw = TEGFeed.getFlowRate("kg/hr"); + double waterInDehydratedGasppm = + dehydratedGas.getFluid().getPhase(0).getComponent("water").getz() * 1.0e6; + double waterInDryGaskgMSm3 = waterInDehydratedGasppm * 0.01802 * 101325.0 / (8.314 * 288.15); + double richTEG2 = richTEG.getFluid().getPhase("aqueous").getWtFrac("TEG"); + System.out.println("reboiler duty (KW) " + ((Reboiler) column.getReboiler()).getDuty() / 1.0e3); + System.out.println("flow rate from reboiler " + + ((Reboiler) column.getReboiler()).getLiquidOutStream().getFlowRate("kg/hr")); + System.out.println( + "flow rate from stripping column " + stripper.getLiquidOutStream().getFlowRate("kg/hr")); + System.out.println("flow rate from pump2 " + + hotLeanTEGPump2.getOutletStream().getFluid().getFlowRate("kg/hr")); + System.out.println("makeup TEG " + makeupTEG.getFluid().getFlowRate("kg/hr")); + + TEGFeed.getFluid().display(); + absorber.run(); + + System.out.println("pump power " + hotLeanTEGPump.getDuty()); + System.out.println("pump2 power " + hotLeanTEGPump2.getDuty()); + System.out.println("wt lean TEG after reboiler " + + column.getLiquidOutStream().getFluid().getPhase("aqueous").getWtFrac("TEG")); + System.out.println( + "temperature from pump " + (hotLeanTEGPump2.getOutletStream().getTemperature() - 273.15)); + + System.out.println("flow rate from reboiler " + + ((Reboiler) column.getReboiler()).getLiquidOutStream().getFlowRate("kg/hr")); + System.out.println("flow rate from pump2 " + + hotLeanTEGPump2.getOutletStream().getFluid().getFlowRate("kg/hr")); + System.out.println("flow rate to flare " + gasToFlare.getFluid().getFlowRate("kg/hr")); + + System.out.println("condenser duty " + + ((Condenser) ((DistillationColumn) operations.getUnit("TEG regeneration column")) + .getCondenser()).getDuty() / 1.0e3); + System.out.println("richGLycolHeaterCondenser duty " + + richGLycolHeaterCondenser.getEnergyStream().getDuty() / 1.0e3); + System.out.println("richGLycolHeaterCondenser temperature out " + + richGLycolHeaterCondenser.getOutletStream().getTemperature("C")); + richGLycolHeaterCondenser.run(); + + hotLeanTEGPump.getOutletStream().displayResult(); + flashLiquid.displayResult(); + + System.out.println("Temperature rich TEG out of reflux condenser " + + richGLycolHeaterCondenser.getOutletStream().getTemperature("C")); + heatEx.displayResult(); + System.out.println("glycol out temperature " + + glycol_flash_valve2.getOutletStream().getFluid().getTemperature("C")); + System.out.println("glycol out temperature2 " + heatEx2.getOutStream(0).getTemperature("C")); + System.out.println("glycol out temperature2 " + heatEx2.getOutStream(1).getTemperature("C")); + + System.out.println("out water rate LP valve" + glycol_flash_valve2.getOutletStream().getFluid() + .getPhase(0).getComponent("water").getNumberOfmoles()); + System.out.println("glycol out water rate reboil " + ((Reboiler) column.getReboiler()) + .getLiquidOutStream().getFluid().getComponent("water").getNumberOfmoles()); + System.out.println("glycol out water rate condens " + ((Condenser) column.getCondenser()) + .getGasOutStream().getFluid().getComponent("water").getNumberOfmoles()); + System.out.println("recycle out water rate " + recycleGasFromStripper.getOutletStream() + .getFluid().getComponent("water").getNumberOfmoles()); + } } diff --git a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationAaHa.java b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationAaHa.java index caa29e84d7..e814066580 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationAaHa.java +++ b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationAaHa.java @@ -28,444 +28,437 @@ * @since 2.2.3 */ public class TEGdehydrationProcessDistillationAaHa { - /** - *

- * getProcess. - *

- * - * @return a {@link neqsim.processSimulation.processSystem.ProcessSystem} object + /** + *

+ * getProcess. + *

+ * + * @return a {@link neqsim.processSimulation.processSystem.ProcessSystem} object + */ + public static neqsim.processSimulation.processSystem.ProcessSystem getProcess() { + neqsim.thermo.system.SystemInterface feedGas = + new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 42.0, 10.00); + feedGas.addComponent("nitrogen", 1.42); + feedGas.addComponent("CO2", 0.5339); + feedGas.addComponent("methane", 95.2412); + feedGas.addComponent("ethane", 2.2029); + feedGas.addComponent("propane", 0.3231); + feedGas.addComponent("i-butane", 0.1341); + feedGas.addComponent("n-butane", 0.0827); + feedGas.addComponent("i-pentane", 0.0679); + feedGas.addComponent("n-pentane", 0.035); + feedGas.addComponent("n-hexane", 0.0176); + feedGas.addComponent("benzene", 0.0017); + feedGas.addComponent("toluene", 0.0043); + feedGas.addComponent("m-Xylene", 0.0031); + feedGas.addComponent("water", 0.0); + feedGas.addComponent("TEG", 0); + feedGas.setMixingRule(10); + feedGas.setMultiPhaseCheck(true); + + Stream dryFeedGas = new Stream("dry feed gas", feedGas); + dryFeedGas.setFlowRate(25.32, "MSm3/day"); + dryFeedGas.setTemperature(25.0, "C"); + dryFeedGas.setPressure(87.12, "bara"); + + StreamSaturatorUtil saturatedFeedGas = new StreamSaturatorUtil("water saturator", dryFeedGas); + + Stream waterSaturatedFeedGas = + new Stream("water saturated feed gas", saturatedFeedGas.getOutletStream()); + + HydrateEquilibriumTemperatureAnalyser hydrateTAnalyser = + new HydrateEquilibriumTemperatureAnalyser(waterSaturatedFeedGas); + hydrateTAnalyser.setName("hydrate temperature analyser"); + + neqsim.thermo.system.SystemInterface feedTEG = feedGas.clone(); + feedTEG.setMolarComposition( + new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.03, 0.97}); + + Heater feedTPsetterToAbsorber = new Heater("TP of gas to absorber", waterSaturatedFeedGas); + feedTPsetterToAbsorber.setOutPressure(87.12, "bara"); + feedTPsetterToAbsorber.setOutTemperature(27.93, "C"); + + Stream feedToAbsorber = + new Stream("feed to TEG absorber", feedTPsetterToAbsorber.getOutletStream()); + + Stream TEGFeed = new Stream("lean TEG to absorber", feedTEG); + TEGFeed.setFlowRate(14.68 * 1100.0, "kg/hr"); + TEGFeed.setTemperature(43.4, "C"); + TEGFeed.setPressure(87.12, "bara"); + + SimpleTEGAbsorber absorber = new SimpleTEGAbsorber("TEG absorber"); + absorber.addGasInStream(feedToAbsorber); + absorber.addSolventInStream(TEGFeed); + absorber.setNumberOfStages(5); + absorber.setStageEfficiency(0.5); + + Stream dehydratedGas = new Stream("dry gas from absorber", absorber.getGasOutStream()); + + Stream richTEG = new Stream("rich TEG from absorber", absorber.getSolventOutStream()); + /* + * WaterDewPointAnalyser waterDewPointAnalyser = new WaterDewPointAnalyser(dehydratedGas); + * waterDewPointAnalyser.setName("water dew point analyser"); */ - public static neqsim.processSimulation.processSystem.ProcessSystem getProcess() { - neqsim.thermo.system.SystemInterface feedGas = - new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 42.0, 10.00); - feedGas.addComponent("nitrogen", 1.42); - feedGas.addComponent("CO2", 0.5339); - feedGas.addComponent("methane", 95.2412); - feedGas.addComponent("ethane", 2.2029); - feedGas.addComponent("propane", 0.3231); - feedGas.addComponent("i-butane", 0.1341); - feedGas.addComponent("n-butane", 0.0827); - feedGas.addComponent("i-pentane", 0.0679); - feedGas.addComponent("n-pentane", 0.035); - feedGas.addComponent("n-hexane", 0.0176); - feedGas.addComponent("benzene", 0.0017); - feedGas.addComponent("toluene", 0.0043); - feedGas.addComponent("m-Xylene", 0.0031); - feedGas.addComponent("water", 0.0); - feedGas.addComponent("TEG", 0); - feedGas.setMixingRule(10); - feedGas.setMultiPhaseCheck(true); - - Stream dryFeedGas = new Stream("dry feed gas", feedGas); - dryFeedGas.setFlowRate(25.32, "MSm3/day"); - dryFeedGas.setTemperature(25.0, "C"); - dryFeedGas.setPressure(87.12, "bara"); - - StreamSaturatorUtil saturatedFeedGas = - new StreamSaturatorUtil("water saturator", dryFeedGas); - - Stream waterSaturatedFeedGas = - new Stream("water saturated feed gas", saturatedFeedGas.getOutletStream()); - - HydrateEquilibriumTemperatureAnalyser hydrateTAnalyser = - new HydrateEquilibriumTemperatureAnalyser(waterSaturatedFeedGas); - hydrateTAnalyser.setName("hydrate temperature analyser"); - - neqsim.thermo.system.SystemInterface feedTEG = feedGas.clone(); - feedTEG.setMolarComposition(new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.03, 0.97}); - - Heater feedTPsetterToAbsorber = new Heater("TP of gas to absorber", waterSaturatedFeedGas); - feedTPsetterToAbsorber.setOutPressure(87.12, "bara"); - feedTPsetterToAbsorber.setOutTemperature(27.93, "C"); - - Stream feedToAbsorber = - new Stream("feed to TEG absorber", feedTPsetterToAbsorber.getOutletStream()); - - Stream TEGFeed = new Stream("lean TEG to absorber", feedTEG); - TEGFeed.setFlowRate(14.68 * 1100.0, "kg/hr"); - TEGFeed.setTemperature(43.4, "C"); - TEGFeed.setPressure(87.12, "bara"); - - SimpleTEGAbsorber absorber = new SimpleTEGAbsorber("TEG absorber"); - absorber.addGasInStream(feedToAbsorber); - absorber.addSolventInStream(TEGFeed); - absorber.setNumberOfStages(5); - absorber.setStageEfficiency(0.5); - - Stream dehydratedGas = new Stream("dry gas from absorber", absorber.getGasOutStream()); - - Stream richTEG = new Stream("rich TEG from absorber", absorber.getSolventOutStream()); - /* - * WaterDewPointAnalyser waterDewPointAnalyser = new WaterDewPointAnalyser(dehydratedGas); - * waterDewPointAnalyser.setName("water dew point analyser"); - */ - HydrateEquilibriumTemperatureAnalyser waterDewPointAnalyser = - new HydrateEquilibriumTemperatureAnalyser(dehydratedGas); - waterDewPointAnalyser.setReferencePressure(70.0); - waterDewPointAnalyser.setName("water dew point analyser"); - - ThrottlingValve glycol_flash_valve = - new ThrottlingValve("Rich TEG HP flash valve", richTEG); - glycol_flash_valve.setOutletPressure(5.5); - - Heater richGLycolHeaterCondenser = - new Heater("rich TEG preheater", glycol_flash_valve.getOutletStream()); - - HeatExchanger heatEx2 = new HeatExchanger("rich TEG heat exchanger 1", - richGLycolHeaterCondenser.getOutletStream()); - heatEx2.setGuessOutTemperature(273.15 + 62.0); - heatEx2.setUAvalue(200.0); - - Separator flashSep = new Separator("degasing separator", heatEx2.getOutStream(0)); - - Stream flashGas = new Stream("gas from degasing separator", flashSep.getGasOutStream()); - - Stream flashLiquid = - new Stream("liquid from degasing separator", flashSep.getLiquidOutStream()); - - Filter fineFilter = new Filter("TEG fine filter", flashLiquid); - fineFilter.setDeltaP(0.05, "bara"); - - Filter carbonFilter = new Filter("activated carbon filter", fineFilter.getOutletStream()); - carbonFilter.setDeltaP(0.01, "bara"); - - HeatExchanger heatEx = - new HeatExchanger("rich TEG heat exchanger 2", carbonFilter.getOutletStream()); - heatEx.setGuessOutTemperature(273.15 + 130.0); - heatEx.setUAvalue(390.0); - - ThrottlingValve glycol_flash_valve2 = - new ThrottlingValve("LP flash valve", heatEx.getOutStream(0)); - glycol_flash_valve2.setName("Rich TEG LP flash valve"); - glycol_flash_valve2.setOutletPressure(1.23); - - neqsim.thermo.system.SystemInterface stripGas = feedGas.clone(); - // stripGas.setMolarComposition(new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, - // 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }); - - Stream strippingGas = new Stream("stripGas", stripGas); - strippingGas.setFlowRate(255.0, "Sm3/hr"); - strippingGas.setTemperature(80.0, "C"); - strippingGas.setPressure(1.02, "bara"); - - Stream gasToReboiler = strippingGas.clone(); - gasToReboiler.setName("gas to reboiler"); - - DistillationColumn column = new DistillationColumn(1, true, true); - column.setName("TEG regeneration column"); - column.addFeedStream(glycol_flash_valve2.getOutletStream(), 0); - column.getReboiler().setOutTemperature(273.15 + 201.0); - column.getCondenser().setOutTemperature(273.15 + 92.0); - column.getReboiler().addStream(gasToReboiler); - column.setTopPressure(1.01325); - column.setBottomPressure(1.02); - - Heater coolerRegenGas = new Heater("regen gas cooler", column.getGasOutStream()); - coolerRegenGas.setOutTemperature(273.15 + 7.5); - - Separator sepregenGas = - new Separator("regen gas separator", coolerRegenGas.getOutletStream()); - - Stream gasToFlare = new Stream("gas to flare", sepregenGas.getGasOutStream()); - - Stream liquidToTrreatment = - new Stream("water to treatment", sepregenGas.getLiquidOutStream()); - - WaterStripperColumn stripper = new WaterStripperColumn("TEG stripper"); - stripper.addSolventInStream(column.getLiquidOutStream()); - stripper.addGasInStream(strippingGas); - stripper.setNumberOfStages(4); - stripper.setStageEfficiency(0.5); - /* - * DistillationColumn stripper = new DistillationColumn(3, false, false); - * stripper.setName("TEG stripper"); stripper.addFeedStream(column.getLiquidOutStream(), 2); - * stripper.getTray(0).addStream(strippingGas); - */ - Recycle recycleGasFromStripper = new Recycle("stripping gas recirc"); - recycleGasFromStripper.addStream(stripper.getGasOutStream()); - recycleGasFromStripper.setOutletStream(gasToReboiler); - - Heater bufferTank = new Heater("TEG buffer tank", stripper.getLiquidOutStream()); - bufferTank.setOutTemperature(273.15 + 191.0); - - Pump hotLeanTEGPump = new Pump("hot lean TEG pump", bufferTank.getOutletStream());// stripper.getSolventOutStream()); - hotLeanTEGPump.setOutletPressure(5.0); - hotLeanTEGPump.setIsentropicEfficiency(0.6); - - heatEx.setFeedStream(1, hotLeanTEGPump.getOutletStream()); - - heatEx2.setFeedStream(1, heatEx.getOutStream(1)); - - Heater coolerhOTteg3 = new Heater("lean TEG cooler", heatEx2.getOutStream(1)); - coolerhOTteg3.setOutTemperature(273.15 + 35.41); - - Pump hotLeanTEGPump2 = new Pump("lean TEG HP pump", coolerhOTteg3.getOutletStream()); - hotLeanTEGPump2.setOutletPressure(87.2); - hotLeanTEGPump2.setIsentropicEfficiency(0.75); - - SetPoint pumpHPPresSet = - new SetPoint("HP pump set", hotLeanTEGPump2, "pressure", feedToAbsorber); - - Stream leanTEGtoabs = new Stream("lean TEG to absorber", hotLeanTEGPump2.getOutletStream()); - - neqsim.thermo.system.SystemInterface pureTEG = feedGas.clone(); - pureTEG.setMolarComposition(new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 1.0}); - - Stream makeupTEG = new Stream("makeup TEG", pureTEG); - makeupTEG.setFlowRate(1e-6, "kg/hr"); - makeupTEG.setTemperature(43.0, "C"); - makeupTEG.setPressure(52.21, "bara"); - - Calculator makeupCalculator = new Calculator("TEG makeup calculator"); - makeupCalculator.addInputVariable(dehydratedGas); - makeupCalculator.addInputVariable(flashGas); - makeupCalculator.addInputVariable(gasToFlare); - makeupCalculator.addInputVariable(liquidToTrreatment); - makeupCalculator.setOutputVariable(makeupTEG); - - StaticMixer makeupMixer = new StaticMixer("makeup mixer"); - makeupMixer.addStream(leanTEGtoabs); - makeupMixer.addStream(makeupTEG); - - Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); - resycleLeanTEG.addStream(makeupMixer.getOutletStream()); - resycleLeanTEG.setOutletStream(TEGFeed); - resycleLeanTEG.setPriority(200); - resycleLeanTEG.setDownstreamProperty("flow rate"); - - richGLycolHeaterCondenser.setEnergyStream(column.getCondenser().getEnergyStream()); - // richGLycolHeater.isSetEnergyStream(); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(dryFeedGas); - operations.add(saturatedFeedGas); - operations.add(waterSaturatedFeedGas); - operations.add(hydrateTAnalyser); - operations.add(feedTPsetterToAbsorber); - operations.add(feedToAbsorber); - operations.add(TEGFeed); - operations.add(absorber); - operations.add(dehydratedGas); - operations.add(waterDewPointAnalyser); - operations.add(richTEG); - operations.add(glycol_flash_valve); - operations.add(richGLycolHeaterCondenser); - operations.add(heatEx2); - operations.add(flashSep); - operations.add(flashGas); - - operations.add(flashLiquid); - operations.add(fineFilter); - operations.add(carbonFilter); - operations.add(heatEx); - operations.add(glycol_flash_valve2); - operations.add(gasToReboiler); - operations.add(column); - operations.add(coolerRegenGas); - operations.add(sepregenGas); - operations.add(gasToFlare); - operations.add(liquidToTrreatment); - operations.add(strippingGas); - operations.add(stripper); - operations.add(recycleGasFromStripper); - operations.add(bufferTank); - operations.add(hotLeanTEGPump); - operations.add(coolerhOTteg3); - operations.add(pumpHPPresSet); - operations.add(hotLeanTEGPump2); - operations.add(leanTEGtoabs); - operations.add(makeupCalculator); - operations.add(makeupTEG); - operations.add(makeupMixer); - operations.add(resycleLeanTEG); - return operations; - } - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects + HydrateEquilibriumTemperatureAnalyser waterDewPointAnalyser = + new HydrateEquilibriumTemperatureAnalyser(dehydratedGas); + waterDewPointAnalyser.setReferencePressure(70.0); + waterDewPointAnalyser.setName("water dew point analyser"); + + ThrottlingValve glycol_flash_valve = new ThrottlingValve("Rich TEG HP flash valve", richTEG); + glycol_flash_valve.setOutletPressure(5.5); + + Heater richGLycolHeaterCondenser = + new Heater("rich TEG preheater", glycol_flash_valve.getOutletStream()); + + HeatExchanger heatEx2 = + new HeatExchanger("rich TEG heat exchanger 1", richGLycolHeaterCondenser.getOutletStream()); + heatEx2.setGuessOutTemperature(273.15 + 62.0); + heatEx2.setUAvalue(200.0); + + Separator flashSep = new Separator("degasing separator", heatEx2.getOutStream(0)); + + Stream flashGas = new Stream("gas from degasing separator", flashSep.getGasOutStream()); + + Stream flashLiquid = + new Stream("liquid from degasing separator", flashSep.getLiquidOutStream()); + + Filter fineFilter = new Filter("TEG fine filter", flashLiquid); + fineFilter.setDeltaP(0.05, "bara"); + + Filter carbonFilter = new Filter("activated carbon filter", fineFilter.getOutletStream()); + carbonFilter.setDeltaP(0.01, "bara"); + + HeatExchanger heatEx = + new HeatExchanger("rich TEG heat exchanger 2", carbonFilter.getOutletStream()); + heatEx.setGuessOutTemperature(273.15 + 130.0); + heatEx.setUAvalue(390.0); + + ThrottlingValve glycol_flash_valve2 = + new ThrottlingValve("LP flash valve", heatEx.getOutStream(0)); + glycol_flash_valve2.setName("Rich TEG LP flash valve"); + glycol_flash_valve2.setOutletPressure(1.23); + + neqsim.thermo.system.SystemInterface stripGas = feedGas.clone(); + // stripGas.setMolarComposition(new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, + // 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }); + + Stream strippingGas = new Stream("stripGas", stripGas); + strippingGas.setFlowRate(255.0, "Sm3/hr"); + strippingGas.setTemperature(80.0, "C"); + strippingGas.setPressure(1.02, "bara"); + + Stream gasToReboiler = strippingGas.clone(); + gasToReboiler.setName("gas to reboiler"); + + DistillationColumn column = new DistillationColumn(1, true, true); + column.setName("TEG regeneration column"); + column.addFeedStream(glycol_flash_valve2.getOutletStream(), 0); + column.getReboiler().setOutTemperature(273.15 + 201.0); + column.getCondenser().setOutTemperature(273.15 + 92.0); + column.getReboiler().addStream(gasToReboiler); + column.setTopPressure(1.01325); + column.setBottomPressure(1.02); + + Heater coolerRegenGas = new Heater("regen gas cooler", column.getGasOutStream()); + coolerRegenGas.setOutTemperature(273.15 + 7.5); + + Separator sepregenGas = new Separator("regen gas separator", coolerRegenGas.getOutletStream()); + + Stream gasToFlare = new Stream("gas to flare", sepregenGas.getGasOutStream()); + + Stream liquidToTrreatment = new Stream("water to treatment", sepregenGas.getLiquidOutStream()); + + WaterStripperColumn stripper = new WaterStripperColumn("TEG stripper"); + stripper.addSolventInStream(column.getLiquidOutStream()); + stripper.addGasInStream(strippingGas); + stripper.setNumberOfStages(4); + stripper.setStageEfficiency(0.5); + /* + * DistillationColumn stripper = new DistillationColumn(3, false, false); + * stripper.setName("TEG stripper"); stripper.addFeedStream(column.getLiquidOutStream(), 2); + * stripper.getTray(0).addStream(strippingGas); */ - @SuppressWarnings("unused") - public static void main(String[] args) { - neqsim.processSimulation.processSystem.ProcessSystem operations = - TEGdehydrationProcessDistillationAaHa.getProcess(); - - operations.run(); - // operations.run(); - - // operations.save("c:/temp/TEGprocessAaHa.neqsim"); - // operations = ProcessSystem.open("c:/temp/TEGprocess.neqsim"); - // ((DistillationColumn)operations.getUnit("TEG regeneration - /// column")).setTopPressure(1.2); - // operations.run(); - // ((DistillationColumn)operations.getUnit("TEG regeneration - /// column")).setNumberOfTrays(2); - /* - * System.out.println("water in wet gas " + ((Stream) - * operations.getUnit("water saturated feed gas")).getFluid() - * .getPhase(0).getComponent("water").getz() * 1.0e6 * 0.01802 * 101325.0 / (8.314 * - * 288.15)); System.out.println("water in dry gas " + ((Stream) - * operations.getUnit("dry gas from absorber")).getFluid() - * .getPhase(0).getComponent("water").getz() * 1.0e6); - * System.out.println("reboiler duty (KW) " + ((Reboiler) ((DistillationColumn) - * operations.getUnit("TEG regeneration column")).getReboiler()) .getDuty() / 1.0e3); - * System.out.println("wt lean TEG " + ((WaterStripperColumn) - * operations.getUnit("TEG stripper")) - * .getSolventOutStream().getFluid().getPhase("aqueous").getWtFrac("TEG") * 100.0); - * - * double waterInWetGasppm = - * waterSaturatedFeedGas.getFluid().getPhase(0).getComponent("water").getz() * 1.0e6; double - * waterInWetGaskgMSm3 = waterInWetGasppm * 0.01802 * 101325.0 / (8.314 * 288.15); double - * TEGfeedwt = TEGFeed.getFluid().getPhase("aqueous").getWtFrac("TEG"); double TEGfeedflw = - * TEGFeed.getFlowRate("kg/hr"); double waterInDehydratedGasppm = - * dehydratedGas.getFluid().getPhase(0).getComponent("water").getz() * 1.0e6; double - * waterInDryGaskgMSm3 = waterInDehydratedGasppm * 0.01802 * 101325.0 / (8.314 * 288.15); - * double richTEG2 = richTEG.getFluid().getPhase("aqueous").getWtFrac("TEG"); double temp = - * ((Stream)operations.getUnit("feed to TEG absorber")).getFluid().getPhase(0). - * getComponent("water").getz()*1.0e6*0.01802*101325.0/(8.314*288.15); - * System.out.println("reboiler duty (KW) " + ((Reboiler) column.getReboiler()).getDuty() / - * 1.0e3); System.out.println("flow rate from reboiler " + ((Reboiler) - * column.getReboiler()).getLiquidOutStream().getFlowRate("kg/hr")); - * System.out.println("flow rate from stripping column " + - * stripper.getLiquidOutStream().getFlowRate("kg/hr")); - * System.out.println("flow rate from pump2 " + - * hotLeanTEGPump2.getOutStream().getFluid().getFlowRate("kg/hr")); - * System.out.println("makeup TEG " + makeupTEG.getFluid().getFlowRate("kg/hr")); - * - * TEGFeed.getFluid().display(); absorber.run(); - * - * System.out.println("pump power " + hotLeanTEGPump.getDuty()); - * System.out.println("pump2 power " + hotLeanTEGPump2.getDuty()); - * System.out.println("wt lean TEG after reboiler " + - * column.getLiquidOutStream().getFluid().getPhase("aqueous").getWtFrac("TEG")); - * System.out.println("temperature from pump " + - * (hotLeanTEGPump2.getOutStream().getTemperature() - 273.15)); - * - * System.out.println("flow rate from reboiler " + ((Reboiler) - * column.getReboiler()).getLiquidOutStream().getFlowRate("kg/hr")); - * System.out.println("flow rate from pump2 " + - * hotLeanTEGPump2.getOutStream().getFluid().getFlowRate("kg/hr")); - * System.out.println("flow rate to flare " + gasToFlare.getFluid().getFlowRate("kg/hr")); - * - * System.out.println("condenser duty " + ((Condenser) ((DistillationColumn) - * operations.getUnit("TEG regeneration column")).getCondenser()) .getDuty() / 1.0e3); - * System.out.println( "richGLycolHeaterCondenser duty " + - * richGLycolHeaterCondenser.getEnergyStream().getDuty() / 1.0e3); - * System.out.println("richGLycolHeaterCondenser temperature out " + - * richGLycolHeaterCondenser.getOutStream().getTemperature("C")); - * richGLycolHeaterCondenser.run(); - * - * hotLeanTEGPump.getOutStream().displayResult(); flashLiquid.displayResult(); - * - * System.out.println("Temperature rich TEG out of reflux condenser " + - * richGLycolHeaterCondenser.getOutStream().getTemperature("C")); heatEx.displayResult(); - * System.out.println("glycol out temperature " + - * glycol_flash_valve2.getOutStream().getFluid().getTemperature("C")); - * System.out.println("glycol out temperature2 " - * +heatEx2.getOutStream(0).getTemperature("C")); - * System.out.println("glycol out temperature2 " - * +heatEx2.getOutStream(1).getTemperature("C")); - * - * - * System.out.println("out water rate LP valve" + - * glycol_flash_valve2.getOutStream().getFluid().getPhase(0).getComponent( - * "water").getNumberOfmoles()); System.out.println("glycol out water rate reboil " + - * ((Reboiler) column.getReboiler()).getLiquidOutStream().getFluid().getComponent("water"). - * getNumberOfmoles()); System.out.println("glycol out water rate condens " + ((Condenser) - * column.getCondenser()).getGasOutStream().getFluid().getComponent("water"). - * getNumberOfmoles()); System.out.println("recycle out water rate " - * +recycleGasFromStripper.getOutletStream().getFluid().getComponent("water"). - * getNumberOfmoles()); - * - * System.out.println("water dew point of dry gas " + - * waterDewPointAnalyser.getMeasuredValue("C")); - * - * - * System.out.println("hydrocarbons in lean TEG " + (1.0- - * stripper.getLiquidOutStream().getFluid().getPhase(0).getWtFrac("TEG")- - * stripper.getLiquidOutStream().getFluid().getPhase(0).getWtFrac("water"))*1e6 + " mg/kg"); - * System.out.println("hydrocarbons in rich TEG " + (1.0- - * flashLiquid.getFluid().getPhase(0).getWtFrac("TEG")-flashLiquid.getFluid(). - * getPhase(0).getWtFrac("water"))*1e6 + " mg/kg"); - * - * //double dewT = ((WaterDewPointAnalyser)operations. - * getMeasurementDevice("water dew point analyser")).getMeasuredValue("C"); - * //waterDewPointAnalyser.setOnlineValue(measured, unit) - * //waterDewPointAnalyser.setOnlineSignal(isOnlineSignal, plantName, transmitterame); - * - * - * - * //Heat echanger test - * - * //Sabe and Open copy of model - * - * ProcessSystem locoperations = operations.copy(); - * //((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger 2")). - * getInStream(0).setTemperature(298.15, "C"); - * //((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger 2")). - * getInStream(1).setTemperature(363.15, "C"); - * //((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger 2")). - * getOutStream(0).setTemperature(298.15, "C"); - * //((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger 2")). - * getOutStream(1).setTemperature(333.15, "C"); - * //((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger 2")). - * runConditionAnalysis((HeatExchanger)operations. getUnit("rich TEG heat exchanger 2")); - * double eff = ((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger 2")). - * getThermalEffectiveness(); System.out.println("eff " + eff); //store fouling factor in - * dataframe - * - * - * dehydratedGas.getFluid().display(); - */ - - ConditionMonitor monitor = operations.getConditionMonitor(); - monitor.conditionAnalysis(); - - // Condition monitor TEG absorber - double xcalc = ((SimpleTEGAbsorber) monitor.getProcess().getUnit("TEG absorber")) - .getGasOutStream().getFluid().getPhase("gas").getComponent("water").getx() * 1.1; - ((SimpleTEGAbsorber) monitor.getProcess().getUnit("TEG absorber")).getGasOutStream() - .getFluid().getPhase("gas").getComponent("water").setx(xcalc); - monitor.conditionAnalysis("TEG absorber"); - System.out.println("number of theoretical stages " - + ((SimpleTEGAbsorber) monitor.getProcess().getUnit("TEG absorber")) - .getNumberOfTheoreticalStages()); - - // Condition monitor rich TEG heat exchanger - ((HeatExchanger) monitor.getProcess().getUnit("rich TEG heat exchanger 2")).getInStream(0) - .setTemperature(0.2, "C"); - double eff1 = ((HeatExchanger) monitor.getProcess().getUnit("rich TEG heat exchanger 2")) - .getThermalEffectiveness(); - double eff2 = ((HeatExchanger) operations.getUnit("rich TEG heat exchanger 2")) - .getThermalEffectiveness(); - double relativeEfficiency = eff1 / eff2; - - // Condition monitor water dew point analyser - ((HydrateEquilibriumTemperatureAnalyser) monitor.getProcess() - .getMeasurementDevice("water dew point analyser")).setOnlineMeasurementValue(-23.5, - "C"); - ((HydrateEquilibriumTemperatureAnalyser) monitor.getProcess() - .getMeasurementDevice("water dew point analyser")).runConditionAnalysis(); - - // Condition monitor TEG fine filter - ((Filter) monitor.getProcess().getUnit("TEG fine filter")).setDeltaP(0.2, "bara"); - monitor.conditionAnalysis("TEG fine filter"); - System.out.println("fine filter deltaP " - + ((Filter) monitor.getProcess().getUnit("TEG fine filter")).getDeltaP()); - System.out.println("fine filter deltaP2 " - + ((Filter) operations.getUnit("TEG fine filter")).getDeltaP()); - double relativeCv = ((Filter) monitor.getProcess().getUnit("TEG fine filter")).getCvFactor() - / ((Filter) operations.getUnit("TEG fine filter")).getCvFactor(); - - double filterCv1 = ((Filter) operations.getUnit("TEG fine filter")).getCvFactor(); - double filterCv2 = ((Filter) operations.getUnit("activated carbon filter")).getCvFactor(); - - System.out.println("filterCv1" + filterCv1 + " filterCv2 " + filterCv2); - } + Recycle recycleGasFromStripper = new Recycle("stripping gas recirc"); + recycleGasFromStripper.addStream(stripper.getGasOutStream()); + recycleGasFromStripper.setOutletStream(gasToReboiler); + + Heater bufferTank = new Heater("TEG buffer tank", stripper.getLiquidOutStream()); + bufferTank.setOutTemperature(273.15 + 191.0); + + Pump hotLeanTEGPump = new Pump("hot lean TEG pump", bufferTank.getOutletStream()); // stripper.getSolventOutStream()); + hotLeanTEGPump.setOutletPressure(5.0); + hotLeanTEGPump.setIsentropicEfficiency(0.6); + + heatEx.setFeedStream(1, hotLeanTEGPump.getOutletStream()); + + heatEx2.setFeedStream(1, heatEx.getOutStream(1)); + + Heater coolerhOTteg3 = new Heater("lean TEG cooler", heatEx2.getOutStream(1)); + coolerhOTteg3.setOutTemperature(273.15 + 35.41); + + Pump hotLeanTEGPump2 = new Pump("lean TEG HP pump", coolerhOTteg3.getOutletStream()); + hotLeanTEGPump2.setOutletPressure(87.2); + hotLeanTEGPump2.setIsentropicEfficiency(0.75); + + SetPoint pumpHPPresSet = + new SetPoint("HP pump set", hotLeanTEGPump2, "pressure", feedToAbsorber); + + Stream leanTEGtoabs = new Stream("lean TEG to absorber", hotLeanTEGPump2.getOutletStream()); + + neqsim.thermo.system.SystemInterface pureTEG = feedGas.clone(); + pureTEG.setMolarComposition( + new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}); + + Stream makeupTEG = new Stream("makeup TEG", pureTEG); + makeupTEG.setFlowRate(1e-6, "kg/hr"); + makeupTEG.setTemperature(43.0, "C"); + makeupTEG.setPressure(52.21, "bara"); + + Calculator makeupCalculator = new Calculator("TEG makeup calculator"); + makeupCalculator.addInputVariable(dehydratedGas); + makeupCalculator.addInputVariable(flashGas); + makeupCalculator.addInputVariable(gasToFlare); + makeupCalculator.addInputVariable(liquidToTrreatment); + makeupCalculator.setOutputVariable(makeupTEG); + + StaticMixer makeupMixer = new StaticMixer("makeup mixer"); + makeupMixer.addStream(leanTEGtoabs); + makeupMixer.addStream(makeupTEG); + + Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); + resycleLeanTEG.addStream(makeupMixer.getOutletStream()); + resycleLeanTEG.setOutletStream(TEGFeed); + resycleLeanTEG.setPriority(200); + resycleLeanTEG.setDownstreamProperty("flow rate"); + + richGLycolHeaterCondenser.setEnergyStream(column.getCondenser().getEnergyStream()); + // richGLycolHeater.isSetEnergyStream(); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(dryFeedGas); + operations.add(saturatedFeedGas); + operations.add(waterSaturatedFeedGas); + operations.add(hydrateTAnalyser); + operations.add(feedTPsetterToAbsorber); + operations.add(feedToAbsorber); + operations.add(TEGFeed); + operations.add(absorber); + operations.add(dehydratedGas); + operations.add(waterDewPointAnalyser); + operations.add(richTEG); + operations.add(glycol_flash_valve); + operations.add(richGLycolHeaterCondenser); + operations.add(heatEx2); + operations.add(flashSep); + operations.add(flashGas); + + operations.add(flashLiquid); + operations.add(fineFilter); + operations.add(carbonFilter); + operations.add(heatEx); + operations.add(glycol_flash_valve2); + operations.add(gasToReboiler); + operations.add(column); + operations.add(coolerRegenGas); + operations.add(sepregenGas); + operations.add(gasToFlare); + operations.add(liquidToTrreatment); + operations.add(strippingGas); + operations.add(stripper); + operations.add(recycleGasFromStripper); + operations.add(bufferTank); + operations.add(hotLeanTEGPump); + operations.add(coolerhOTteg3); + operations.add(pumpHPPresSet); + operations.add(hotLeanTEGPump2); + operations.add(leanTEGtoabs); + operations.add(makeupCalculator); + operations.add(makeupTEG); + operations.add(makeupMixer); + operations.add(resycleLeanTEG); + return operations; + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String[] args) { + neqsim.processSimulation.processSystem.ProcessSystem operations = + TEGdehydrationProcessDistillationAaHa.getProcess(); + + operations.run(); + // operations.run(); + + // operations.save("c:/temp/TEGprocessAaHa.neqsim"); + // operations = ProcessSystem.open("c:/temp/TEGprocess.neqsim"); + // ((DistillationColumn)operations.getUnit("TEG regeneration + /// column")).setTopPressure(1.2); + // operations.run(); + // ((DistillationColumn)operations.getUnit("TEG regeneration + /// column")).setNumberOfTrays(2); + /* + * System.out.println("water in wet gas " + ((Stream) + * operations.getUnit("water saturated feed gas")).getFluid() + * .getPhase(0).getComponent("water").getz() * 1.0e6 * 0.01802 * 101325.0 / (8.314 * 288.15)); + * System.out.println("water in dry gas " + ((Stream) + * operations.getUnit("dry gas from absorber")).getFluid() + * .getPhase(0).getComponent("water").getz() * 1.0e6); System.out.println("reboiler duty (KW) " + * + ((Reboiler) ((DistillationColumn) + * operations.getUnit("TEG regeneration column")).getReboiler()) .getDuty() / 1.0e3); + * System.out.println("wt lean TEG " + ((WaterStripperColumn) + * operations.getUnit("TEG stripper")) + * .getSolventOutStream().getFluid().getPhase("aqueous").getWtFrac("TEG") * 100.0); + * + * double waterInWetGasppm = + * waterSaturatedFeedGas.getFluid().getPhase(0).getComponent("water").getz() * 1.0e6; double + * waterInWetGaskgMSm3 = waterInWetGasppm * 0.01802 * 101325.0 / (8.314 * 288.15); double + * TEGfeedwt = TEGFeed.getFluid().getPhase("aqueous").getWtFrac("TEG"); double TEGfeedflw = + * TEGFeed.getFlowRate("kg/hr"); double waterInDehydratedGasppm = + * dehydratedGas.getFluid().getPhase(0).getComponent("water").getz() * 1.0e6; double + * waterInDryGaskgMSm3 = waterInDehydratedGasppm * 0.01802 * 101325.0 / (8.314 * 288.15); double + * richTEG2 = richTEG.getFluid().getPhase("aqueous").getWtFrac("TEG"); double temp = + * ((Stream)operations.getUnit("feed to TEG absorber")).getFluid().getPhase(0). + * getComponent("water").getz()*1.0e6*0.01802*101325.0/(8.314*288.15); + * System.out.println("reboiler duty (KW) " + ((Reboiler) column.getReboiler()).getDuty() / + * 1.0e3); System.out.println("flow rate from reboiler " + ((Reboiler) + * column.getReboiler()).getLiquidOutStream().getFlowRate("kg/hr")); + * System.out.println("flow rate from stripping column " + + * stripper.getLiquidOutStream().getFlowRate("kg/hr")); + * System.out.println("flow rate from pump2 " + + * hotLeanTEGPump2.getOutStream().getFluid().getFlowRate("kg/hr")); + * System.out.println("makeup TEG " + makeupTEG.getFluid().getFlowRate("kg/hr")); + * + * TEGFeed.getFluid().display(); absorber.run(); + * + * System.out.println("pump power " + hotLeanTEGPump.getDuty()); + * System.out.println("pump2 power " + hotLeanTEGPump2.getDuty()); + * System.out.println("wt lean TEG after reboiler " + + * column.getLiquidOutStream().getFluid().getPhase("aqueous").getWtFrac("TEG")); + * System.out.println("temperature from pump " + + * (hotLeanTEGPump2.getOutStream().getTemperature() - 273.15)); + * + * System.out.println("flow rate from reboiler " + ((Reboiler) + * column.getReboiler()).getLiquidOutStream().getFlowRate("kg/hr")); + * System.out.println("flow rate from pump2 " + + * hotLeanTEGPump2.getOutStream().getFluid().getFlowRate("kg/hr")); + * System.out.println("flow rate to flare " + gasToFlare.getFluid().getFlowRate("kg/hr")); + * + * System.out.println("condenser duty " + ((Condenser) ((DistillationColumn) + * operations.getUnit("TEG regeneration column")).getCondenser()) .getDuty() / 1.0e3); + * System.out.println( "richGLycolHeaterCondenser duty " + + * richGLycolHeaterCondenser.getEnergyStream().getDuty() / 1.0e3); + * System.out.println("richGLycolHeaterCondenser temperature out " + + * richGLycolHeaterCondenser.getOutStream().getTemperature("C")); + * richGLycolHeaterCondenser.run(); + * + * hotLeanTEGPump.getOutStream().displayResult(); flashLiquid.displayResult(); + * + * System.out.println("Temperature rich TEG out of reflux condenser " + + * richGLycolHeaterCondenser.getOutStream().getTemperature("C")); heatEx.displayResult(); + * System.out.println("glycol out temperature " + + * glycol_flash_valve2.getOutStream().getFluid().getTemperature("C")); + * System.out.println("glycol out temperature2 " +heatEx2.getOutStream(0).getTemperature("C")); + * System.out.println("glycol out temperature2 " +heatEx2.getOutStream(1).getTemperature("C")); + * + * + * System.out.println("out water rate LP valve" + + * glycol_flash_valve2.getOutStream().getFluid().getPhase(0).getComponent( + * "water").getNumberOfmoles()); System.out.println("glycol out water rate reboil " + + * ((Reboiler) column.getReboiler()).getLiquidOutStream().getFluid().getComponent("water"). + * getNumberOfmoles()); System.out.println("glycol out water rate condens " + ((Condenser) + * column.getCondenser()).getGasOutStream().getFluid().getComponent("water"). + * getNumberOfmoles()); System.out.println("recycle out water rate " + * +recycleGasFromStripper.getOutletStream().getFluid().getComponent("water"). + * getNumberOfmoles()); + * + * System.out.println("water dew point of dry gas " + + * waterDewPointAnalyser.getMeasuredValue("C")); + * + * + * System.out.println("hydrocarbons in lean TEG " + (1.0- + * stripper.getLiquidOutStream().getFluid().getPhase(0).getWtFrac("TEG")- + * stripper.getLiquidOutStream().getFluid().getPhase(0).getWtFrac("water"))*1e6 + " mg/kg"); + * System.out.println("hydrocarbons in rich TEG " + (1.0- + * flashLiquid.getFluid().getPhase(0).getWtFrac("TEG")-flashLiquid.getFluid(). + * getPhase(0).getWtFrac("water"))*1e6 + " mg/kg"); + * + * //double dewT = ((WaterDewPointAnalyser)operations. + * getMeasurementDevice("water dew point analyser")).getMeasuredValue("C"); + * //waterDewPointAnalyser.setOnlineValue(measured, unit) + * //waterDewPointAnalyser.setOnlineSignal(isOnlineSignal, plantName, transmitterame); + * + * + * + * //Heat echanger test + * + * //Sabe and Open copy of model + * + * ProcessSystem locoperations = operations.copy(); + * //((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger 2")). + * getInStream(0).setTemperature(298.15, "C"); + * //((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger 2")). + * getInStream(1).setTemperature(363.15, "C"); + * //((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger 2")). + * getOutStream(0).setTemperature(298.15, "C"); + * //((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger 2")). + * getOutStream(1).setTemperature(333.15, "C"); + * //((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger 2")). + * runConditionAnalysis((HeatExchanger)operations. getUnit("rich TEG heat exchanger 2")); double + * eff = ((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger 2")). + * getThermalEffectiveness(); System.out.println("eff " + eff); //store fouling factor in + * dataframe + * + * + * dehydratedGas.getFluid().display(); + */ + + ConditionMonitor monitor = operations.getConditionMonitor(); + monitor.conditionAnalysis(); + + // Condition monitor TEG absorber + double xcalc = ((SimpleTEGAbsorber) monitor.getProcess().getUnit("TEG absorber")) + .getGasOutStream().getFluid().getPhase("gas").getComponent("water").getx() * 1.1; + ((SimpleTEGAbsorber) monitor.getProcess().getUnit("TEG absorber")).getGasOutStream().getFluid() + .getPhase("gas").getComponent("water").setx(xcalc); + monitor.conditionAnalysis("TEG absorber"); + System.out.println("number of theoretical stages " + + ((SimpleTEGAbsorber) monitor.getProcess().getUnit("TEG absorber")) + .getNumberOfTheoreticalStages()); + + // Condition monitor rich TEG heat exchanger + ((HeatExchanger) monitor.getProcess().getUnit("rich TEG heat exchanger 2")).getInStream(0) + .setTemperature(0.2, "C"); + double eff1 = ((HeatExchanger) monitor.getProcess().getUnit("rich TEG heat exchanger 2")) + .getThermalEffectiveness(); + double eff2 = + ((HeatExchanger) operations.getUnit("rich TEG heat exchanger 2")).getThermalEffectiveness(); + double relativeEfficiency = eff1 / eff2; + + // Condition monitor water dew point analyser + ((HydrateEquilibriumTemperatureAnalyser) monitor.getProcess() + .getMeasurementDevice("water dew point analyser")).setOnlineMeasurementValue(-23.5, "C"); + ((HydrateEquilibriumTemperatureAnalyser) monitor.getProcess() + .getMeasurementDevice("water dew point analyser")).runConditionAnalysis(); + + // Condition monitor TEG fine filter + ((Filter) monitor.getProcess().getUnit("TEG fine filter")).setDeltaP(0.2, "bara"); + monitor.conditionAnalysis("TEG fine filter"); + System.out.println("fine filter deltaP " + + ((Filter) monitor.getProcess().getUnit("TEG fine filter")).getDeltaP()); + System.out.println( + "fine filter deltaP2 " + ((Filter) operations.getUnit("TEG fine filter")).getDeltaP()); + double relativeCv = ((Filter) monitor.getProcess().getUnit("TEG fine filter")).getCvFactor() + / ((Filter) operations.getUnit("TEG fine filter")).getCvFactor(); + + double filterCv1 = ((Filter) operations.getUnit("TEG fine filter")).getCvFactor(); + double filterCv2 = ((Filter) operations.getUnit("activated carbon filter")).getCvFactor(); + + System.out.println("filterCv1" + filterCv1 + " filterCv2 " + filterCv2); + } } diff --git a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationGFA.java b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationGFA.java index 1791694fc4..d6d4c7bdf0 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationGFA.java +++ b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationGFA.java @@ -31,553 +31,544 @@ * @since 2.2.3 */ public class TEGdehydrationProcessDistillationGFA { - /** - * The flow rate of gas from the scrubber controlling the dew point (MSm3/hr) + /** + * The flow rate of gas from the scrubber controlling the dew point (MSm3/hr). + */ + public double feedGasFlowRate = 11.23; + + /** + * The temperature of the gas from the scrubber controlling the dew point (Celsuis). + */ + public double feedGasTemperature = 30.4; + + /** + * The pressure of the gas from the scrubber controlling the dew point (bara). + */ + public double feedGasPressure = 52.21; + + /** + * The temperature of the gas entering the TEG absorption column (Celisuis). + */ + public double absorberFeedGasTemperature = 30.4; + + /** + * The pressure of the gas entering the TEG absorption column (bara). + */ + public double absorberFeedGasPressure = 52.21; + + /** + * The flow rate of lean TEG entering the absorption column (kg/hr). + */ + public double leanTEGFlowRate = 6786.0; + + /** + * The temperature of the lean TEG entering the absorption column (Celcius). + */ + public double leanTEGTemperature = 43.6; + + /** + * The pressure in the flash drum (bara). + */ + public double flashDrumPressure = 4.9; + + /** + * Number of equilibrium stages in TEG absorpber. + */ + public int numberOfEquilibriumStagesTEGabsorber = 5; + + /** + * Stage efficiency in TEG absorpber. + */ + public double stageEfficiencyStripper = 0.5; + + /** + * Number of equilibrium stages in TEG absorpber. + */ + public int numberOfEquilibriumStagesStripper = 4; + + /** + * Stage efficiency in TEG absorpber. + */ + public double stageEfficiencyTEGabsorber = 0.55; + + /** + * UA value of rich TEG heat exchanger 1. + */ + public double UAvalueRichTEGHeatExchanger_1 = 2900.0; + + /** + * UA value of rich TEG heat exchanger 2. + */ + public double UAvalueRichTEGHeatExchanger_2 = 8200.0; + + /** + * Pressure in reboiler (bara). + */ + public double reboilerPressure = 1.23; + + /** + * Temperature in condenser(Celcius). + */ + public double condenserTemperature = 93.6; + + /** + * Pressure in condenser (bara). + */ + public double condenserPressure = 1.2; + + /** + * Temperature in reboiler (Celcius). + */ + public double reboilerTemperature = 206.6; + + /** + * Stripping gas flow rate (Sm3/hr). + */ + public double strippingGasRate = 91.2; + + /** + * Stripping gas feed temperature (Celcius). + */ + public double strippingGasFeedTemperature = 80.0; + + /** + * TEG buffer tank temperature (Celcius). + */ + public double bufferTankTemperatureTEG = 190.4; + + /** + * temperature of after regeneration gas cooler (Celcius). + */ + public double regenerationGasCoolerTemperature = 35.0; + + /** + * isentropic efficiency of hot lean TEG pump (0.0-1.0). + */ + public double hotTEGpumpIsentropicEfficiency = 0.75; + + /** + * pressure after hot lean TEG pump (bara). + */ + public double hotTEGpumpPressure = 20.0; + + /** + * isentropic efficiency of cold lean TEG pump (0.0-1.0). + */ + public double coldTEGpumpIsentropicEfficiency = 0.75; + + /** + *

+ * getProcess. + *

+ * + * @return a {@link neqsim.processSimulation.processSystem.ProcessSystem} object + */ + public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { + // Create the input fluid to the TEG process and saturate it with water at + // scrubber conditions + neqsim.thermo.system.SystemInterface feedGas = + new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 42.0, 10.00); + feedGas.addComponent("nitrogen", 1.03); + feedGas.addComponent("CO2", 1.42); + feedGas.addComponent("methane", 83.88); + feedGas.addComponent("ethane", 8.07); + feedGas.addComponent("propane", 3.54); + feedGas.addComponent("i-butane", 0.54); + feedGas.addComponent("n-butane", 0.84); + feedGas.addComponent("i-pentane", 0.21); + feedGas.addComponent("n-pentane", 0.19); + feedGas.addComponent("n-hexane", 0.28); + feedGas.addComponent("water", 0.0); + feedGas.addComponent("TEG", 0); + feedGas.createDatabase(true); + feedGas.setMixingRule(10); + feedGas.setMultiPhaseCheck(false); + + Stream dryFeedGas = new Stream("dry feed gas", feedGas); + dryFeedGas.setFlowRate(feedGasFlowRate, "MSm3/day"); + dryFeedGas.setTemperature(feedGasTemperature, "C"); + dryFeedGas.setPressure(feedGasPressure, "bara"); + + StreamSaturatorUtil saturatedFeedGas = new StreamSaturatorUtil("water saturator", dryFeedGas); + + Stream waterSaturatedFeedGas = + new Stream("water saturated feed gas", saturatedFeedGas.getOutletStream()); + + HydrateEquilibriumTemperatureAnalyser hydrateTAnalyser = + new HydrateEquilibriumTemperatureAnalyser(waterSaturatedFeedGas); + hydrateTAnalyser.setName("hydrate temperature analyser"); + + neqsim.thermo.system.SystemInterface feedTEG = feedGas.clone(); + feedTEG.setMolarComposition( + new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.03, 0.97}); + + Heater feedTPsetterToAbsorber = new Heater("TP of gas to absorber", waterSaturatedFeedGas); + feedTPsetterToAbsorber.setOutPressure(absorberFeedGasPressure, "bara"); + feedTPsetterToAbsorber.setOutTemperature(absorberFeedGasTemperature, "C"); + + Stream feedToAbsorber = + new Stream("feed to TEG absorber", feedTPsetterToAbsorber.getOutletStream()); + + Stream TEGFeed = new Stream("lean TEG to absorber", feedTEG); + TEGFeed.setFlowRate(leanTEGFlowRate, "kg/hr"); + TEGFeed.setTemperature(leanTEGTemperature, "C"); + TEGFeed.setPressure(absorberFeedGasPressure, "bara"); + + SimpleTEGAbsorber absorber = new SimpleTEGAbsorber("TEG absorber"); + absorber.addGasInStream(feedToAbsorber); + absorber.addSolventInStream(TEGFeed); + absorber.setNumberOfStages(numberOfEquilibriumStagesTEGabsorber); + absorber.setStageEfficiency(stageEfficiencyTEGabsorber); + + Stream dehydratedGas = new Stream("dry gas from absorber", absorber.getGasOutStream()); + + Stream richTEG = new Stream("rich TEG from absorber", absorber.getSolventOutStream()); + + WaterDewPointAnalyser waterDewPointAnalyser2 = new WaterDewPointAnalyser(dehydratedGas); + waterDewPointAnalyser2.setName("water dew point analyser2"); + + HydrateEquilibriumTemperatureAnalyser waterDewPointAnalyser = + new HydrateEquilibriumTemperatureAnalyser(dehydratedGas); + waterDewPointAnalyser.setName("water dew point analyser"); + + ThrottlingValve glycol_flash_valve = new ThrottlingValve("Flash valve", richTEG); + glycol_flash_valve.setName("Rich TEG HP flash valve"); + glycol_flash_valve.setOutletPressure(flashDrumPressure); + + Heater richGLycolHeaterCondenser = + new Heater("rich TEG preheater", glycol_flash_valve.getOutletStream()); + + HeatExchanger heatEx2 = + new HeatExchanger("rich TEG heat exchanger 1", richGLycolHeaterCondenser.getOutletStream()); + heatEx2.setGuessOutTemperature(273.15 + 62.0); + heatEx2.setUAvalue(UAvalueRichTEGHeatExchanger_1); + + Separator flashSep = new Separator("degasing separator", heatEx2.getOutStream(0)); + + Stream flashGas = new Stream("gas from degasing separator", flashSep.getGasOutStream()); + + Stream flashLiquid = + new Stream("liquid from degasing separator", flashSep.getLiquidOutStream()); + + Filter filter = new Filter("filters", flashLiquid); + + HeatExchanger heatEx = new HeatExchanger("rich TEG heat exchanger 2", filter.getOutletStream()); + heatEx.setGuessOutTemperature(273.15 + 130.0); + heatEx.setUAvalue(UAvalueRichTEGHeatExchanger_2); + + ThrottlingValve glycol_flash_valve2 = + new ThrottlingValve("LP flash valve", heatEx.getOutStream(0)); + glycol_flash_valve2.setName("Rich TEG LP flash valve"); + glycol_flash_valve2.setOutletPressure(reboilerPressure); + + neqsim.thermo.system.SystemInterface stripGas = feedGas.clone(); + + Stream strippingGas = new Stream("stripGas", stripGas); + strippingGas.setFlowRate(strippingGasRate, "Sm3/hr"); + strippingGas.setTemperature(strippingGasFeedTemperature, "C"); + strippingGas.setPressure(reboilerPressure, "bara"); + + Stream gasToReboiler = strippingGas.clone(); + gasToReboiler.setName("gas to reboiler"); + + DistillationColumn column = new DistillationColumn(3, true, true); + column.setName("TEG regeneration column"); + column.addFeedStream(glycol_flash_valve2.getOutletStream(), 1); + column.getReboiler().setOutTemperature(273.15 + reboilerTemperature); + column.getCondenser().setOutTemperature(273.15 + condenserTemperature); + column.getReboiler().addStream(gasToReboiler); + column.setTopPressure(condenserPressure); + column.setBottomPressure(reboilerPressure); + + Heater coolerRegenGas = new Heater("regen gas cooler", column.getGasOutStream()); + coolerRegenGas.setOutTemperature(273.15 + regenerationGasCoolerTemperature); + + Separator sepregenGas = new Separator("regen gas separator", coolerRegenGas.getOutletStream()); + + Stream gasToFlare = new Stream("gas to flare", sepregenGas.getGasOutStream()); + + Stream liquidToTrreatment = new Stream("water to treatment", sepregenGas.getLiquidOutStream()); + + WaterStripperColumn stripper = new WaterStripperColumn("TEG stripper"); + stripper.addSolventInStream(column.getLiquidOutStream()); + stripper.addGasInStream(strippingGas); + stripper.setNumberOfStages(numberOfEquilibriumStagesStripper); + stripper.setStageEfficiency(stageEfficiencyStripper); + + Recycle recycleGasFromStripper = new Recycle("stripping gas recirc"); + recycleGasFromStripper.addStream(stripper.getGasOutStream()); + recycleGasFromStripper.setOutletStream(gasToReboiler); + + Heater bufferTank = new Heater("TEG buffer tank", stripper.getSolventOutStream()); + bufferTank.setOutTemperature(273.15 + bufferTankTemperatureTEG); + + Pump hotLeanTEGPump = new Pump("hot lean TEG pump", bufferTank.getOutletStream()); // stripper.getSolventOutStream()); + hotLeanTEGPump.setOutletPressure(hotTEGpumpPressure); + hotLeanTEGPump.setIsentropicEfficiency(hotTEGpumpIsentropicEfficiency); + + heatEx.setFeedStream(1, hotLeanTEGPump.getOutletStream()); + + heatEx2.setFeedStream(1, heatEx.getOutStream(1)); + + Heater coolerhOTteg3 = new Heater("lean TEG cooler", heatEx2.getOutStream(1)); + coolerhOTteg3.setOutTemperature(273.15 + leanTEGTemperature); + + Pump hotLeanTEGPump2 = new Pump("lean TEG HP pump", coolerhOTteg3.getOutletStream()); + hotLeanTEGPump2.setOutletPressure(absorberFeedGasPressure); + hotLeanTEGPump2.setIsentropicEfficiency(coldTEGpumpIsentropicEfficiency); + + SetPoint pumpHPPresSet = + new SetPoint("HP pump set", hotLeanTEGPump2, "pressure", feedToAbsorber); + + Stream leanTEGtoabs = new Stream("lean TEG to absorber", hotLeanTEGPump2.getOutletStream()); + + neqsim.thermo.system.SystemInterface pureTEG = feedGas.clone(); + pureTEG.setMolarComposition( + new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}); + + Stream makeupTEG = new Stream("makeup TEG", pureTEG); + makeupTEG.setFlowRate(1e-6, "kg/hr"); + makeupTEG.setTemperature(leanTEGTemperature, "C"); + makeupTEG.setPressure(absorberFeedGasPressure, "bara"); + + Calculator makeupCalculator = new Calculator("TEG makeup calculator"); + makeupCalculator.addInputVariable(dehydratedGas); + makeupCalculator.addInputVariable(flashGas); + makeupCalculator.addInputVariable(gasToFlare); + makeupCalculator.addInputVariable(liquidToTrreatment); + makeupCalculator.setOutputVariable(makeupTEG); + + StaticMixer makeupMixer = new StaticMixer("makeup mixer"); + makeupMixer.addStream(leanTEGtoabs); + makeupMixer.addStream(makeupTEG); + + Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); + resycleLeanTEG.addStream(makeupMixer.getOutletStream()); + resycleLeanTEG.setOutletStream(TEGFeed); + resycleLeanTEG.setPriority(200); + resycleLeanTEG.setDownstreamProperty("flow rate"); + + richGLycolHeaterCondenser.setEnergyStream(column.getCondenser().getEnergyStream()); + // richGLycolHeater.isSetEnergyStream(); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(dryFeedGas); + operations.add(saturatedFeedGas); + operations.add(waterSaturatedFeedGas); + operations.add(hydrateTAnalyser); + operations.add(feedTPsetterToAbsorber); + operations.add(feedToAbsorber); + operations.add(TEGFeed); + operations.add(absorber); + operations.add(dehydratedGas); + operations.add(waterDewPointAnalyser); + operations.add(waterDewPointAnalyser2); + operations.add(richTEG); + operations.add(glycol_flash_valve); + operations.add(richGLycolHeaterCondenser); + operations.add(heatEx2); + operations.add(flashSep); + operations.add(flashGas); + operations.add(flashLiquid); + operations.add(filter); + operations.add(heatEx); + operations.add(glycol_flash_valve2); + operations.add(gasToReboiler); + operations.add(column); + operations.add(coolerRegenGas); + operations.add(sepregenGas); + operations.add(gasToFlare); + operations.add(liquidToTrreatment); + operations.add(strippingGas); + operations.add(stripper); + operations.add(recycleGasFromStripper); + operations.add(bufferTank); + operations.add(hotLeanTEGPump); + operations.add(coolerhOTteg3); + operations.add(pumpHPPresSet); + operations.add(hotLeanTEGPump2); + operations.add(leanTEGtoabs); + operations.add(makeupCalculator); + operations.add(makeupTEG); + operations.add(makeupMixer); + operations.add(resycleLeanTEG); + return operations; + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String[] args) { + TEGdehydrationProcessDistillationGFA tempClass = new TEGdehydrationProcessDistillationGFA(); + neqsim.processSimulation.processSystem.ProcessSystem operations = tempClass.getProcess(); + operations.run(); + // operations.run(); + // operations = + // neqsim.processSimulation.processSystem.ProcessSystem.open("c:/temp/TEGprocessGFA.neqsim"); + + double richTEGtemperature = + ((Heater) operations.getUnit("rich TEG preheater")).getOutletStream().getTemperature("C"); + System.out.println("temp rich TEG " + richTEGtemperature); + System.out.println("condenser duty (KW) " + + ((Condenser) ((DistillationColumn) operations.getUnit("TEG regeneration column")) + .getCondenser()).getDuty() / 1.0e3); + System.out.println("reboiler duty (KW) " + + ((Reboiler) ((DistillationColumn) operations.getUnit("TEG regeneration column")) + .getReboiler()).getDuty() / 1.0e3); + + System.out.println("temp out rich TEG " + richTEGtemperature); + + double rich2TEGtemperature = ((HeatExchanger) operations.getUnit("rich TEG heat exchanger 1")) + .getOutStream(0).getTemperature("C"); + System.out.println("temp rich2 TEG " + rich2TEGtemperature); + + double rich22TEGtemperature = ((HeatExchanger) operations.getUnit("rich TEG heat exchanger 2")) + .getOutStream(0).getTemperature("C"); + System.out.println("temp rich2 to reboil TEG " + rich22TEGtemperature); + + double lean22TEGtemperature = ((HeatExchanger) operations.getUnit("rich TEG heat exchanger 2")) + .getOutStream(1).getTemperature("C"); + System.out.println("temp lean TEG to HX " + lean22TEGtemperature); + + // ((Stream)operations.getUnit("dry feed gas")).setFlowRate(10.23, "MSm3/day"); + // ((Stream)operations.getUnit("dry feed gas")).setTemperature(40.0, "C"); + // System.out.println("restart "); + // operations.run(); + operations.save("c:/temp/TEGprocessGFA.neqsim"); + double eff = + ((HeatExchanger) operations.getUnit("rich TEG heat exchanger 2")).getThermalEffectiveness(); + System.out.println("HX2 thermal efficiency " + eff); + /// operations = ProcessSystem.open("c:/temp/TEGprocess.neqsim"); + // ((DistillationColumn)operations.getUnit("TEG regeneration + /// column")).setTopPressure(1.2); + // operations.run(); + // ((DistillationColumn)operations.getUnit("TEG regeneration + /// column")).setNumberOfTrays(2); + /* + * System.out.println("water in wet gas " + ((Stream) + * operations.getUnit("water saturated feed gas")).getFluid() + * .getPhase(0).getComponent("water").getz() * 1.0e6 * 0.01802 * 101325.0 / (8.314 * 288.15)); + * System.out.println("water in dry gas " + ((Stream) + * operations.getUnit("dry gas from absorber")).getFluid() + * .getPhase(0).getComponent("water").getz() * 1.0e6); System.out.println("reboiler duty (KW) " + * + ((Reboiler) ((DistillationColumn) + * operations.getUnit("TEG regeneration column")).getReboiler()) .getDuty() / 1.0e3); + * System.out.println("wt lean TEG " + ((WaterStripperColumn) + * operations.getUnit("TEG stripper")) + * .getSolventOutStream().getFluid().getPhase("aqueous").getWtFrac("TEG") * 100.0); */ - public double feedGasFlowRate = 11.23; - - /** - * The temperature of the gas from the scrubber controlling the dew point (Celisuis) - */ - public double feedGasTemperature = 30.4; - - /** - * The pressure of the gas from the scrubber controlling the dew point (bara) - */ - public double feedGasPressure = 52.21; - - /** - * The temperature of the gas entering the TEG absorption column (Celisuis) - */ - public double absorberFeedGasTemperature = 30.4; - - /** - * The pressure of the gas entering the TEG absorption column (bara) - */ - public double absorberFeedGasPressure = 52.21; - - /** - * The flow rate of lean TEG entering the absorption column (kg/hr) - */ - public double leanTEGFlowRate = 6786.0; - - /** - * The temperature of the lean TEG entering the absorption column (Celcius) - */ - public double leanTEGTemperature = 43.6; - - /** - * The pressure in the flash drum (bara) - */ - public double flashDrumPressure = 4.9; - - /** - * Number of equilibrium stages in TEG absorpber - */ - public int numberOfEquilibriumStagesTEGabsorber = 5; - - /** - * Stage efficiency in TEG absorpber - */ - public double stageEfficiencyStripper = 0.5; - - /** - * Number of equilibrium stages in TEG absorpber - */ - public int numberOfEquilibriumStagesStripper = 4; - - /** - * Stage efficiency in TEG absorpber - */ - public double stageEfficiencyTEGabsorber = 0.55; - - /** - * UA value of rich TEG heat exchanger 1 - */ - public double UAvalueRichTEGHeatExchanger_1 = 2900.0; - - /** - * UA value of rich TEG heat exchanger 2 - */ - public double UAvalueRichTEGHeatExchanger_2 = 8200.0; - - /** - * Pressure in reboiler (bara) - */ - public double reboilerPressure = 1.23; - - /** - * Temperature in condenser(Celcius) - */ - public double condenserTemperature = 93.6; - - /** - * Pressure in condenser (bara) - */ - public double condenserPressure = 1.2; - - /** - * Temperature in reboiler (Celcius) - */ - public double reboilerTemperature = 206.6; - - /** - * Stripping gas flow rate (Sm3/hr) - */ - public double strippingGasRate = 91.2; - - /** - * Stripping gas feed temperature (Celcius) - */ - public double strippingGasFeedTemperature = 80.0; - - /** - * TEG buffer tank temperature (Celcius) - */ - public double bufferTankTemperatureTEG = 190.4; - - /** - * temperature of after regeneration gas cooler (Celcius) - */ - public double regenerationGasCoolerTemperature = 35.0; - - /** - * isentropic efficiency of hot lean TEG pump (0.0-1.0) - */ - public double hotTEGpumpIsentropicEfficiency = 0.75; - - /** - * pressure after hot lean TEG pump (bara) - */ - public double hotTEGpumpPressure = 20.0; - - /** - * isentropic efficiency of cold lean TEG pump (0.0-1.0) - */ - public double coldTEGpumpIsentropicEfficiency = 0.75; - - /** - *

- * getProcess. - *

- * - * @return a {@link neqsim.processSimulation.processSystem.ProcessSystem} object - */ - public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { - // Create the input fluid to the TEG process and saturate it with water at - // scrubber conditions - neqsim.thermo.system.SystemInterface feedGas = - new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 42.0, 10.00); - feedGas.addComponent("nitrogen", 1.03); - feedGas.addComponent("CO2", 1.42); - feedGas.addComponent("methane", 83.88); - feedGas.addComponent("ethane", 8.07); - feedGas.addComponent("propane", 3.54); - feedGas.addComponent("i-butane", 0.54); - feedGas.addComponent("n-butane", 0.84); - feedGas.addComponent("i-pentane", 0.21); - feedGas.addComponent("n-pentane", 0.19); - feedGas.addComponent("n-hexane", 0.28); - feedGas.addComponent("water", 0.0); - feedGas.addComponent("TEG", 0); - feedGas.createDatabase(true); - feedGas.setMixingRule(10); - feedGas.setMultiPhaseCheck(false); - - Stream dryFeedGas = new Stream("dry feed gas", feedGas); - dryFeedGas.setFlowRate(feedGasFlowRate, "MSm3/day"); - dryFeedGas.setTemperature(feedGasTemperature, "C"); - dryFeedGas.setPressure(feedGasPressure, "bara"); - - StreamSaturatorUtil saturatedFeedGas = - new StreamSaturatorUtil("water saturator", dryFeedGas); - - Stream waterSaturatedFeedGas = - new Stream("water saturated feed gas", saturatedFeedGas.getOutletStream()); - - HydrateEquilibriumTemperatureAnalyser hydrateTAnalyser = - new HydrateEquilibriumTemperatureAnalyser(waterSaturatedFeedGas); - hydrateTAnalyser.setName("hydrate temperature analyser"); - - neqsim.thermo.system.SystemInterface feedTEG = feedGas.clone(); - feedTEG.setMolarComposition( - new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.03, 0.97}); - - Heater feedTPsetterToAbsorber = new Heater("TP of gas to absorber", waterSaturatedFeedGas); - feedTPsetterToAbsorber.setOutPressure(absorberFeedGasPressure, "bara"); - feedTPsetterToAbsorber.setOutTemperature(absorberFeedGasTemperature, "C"); - - Stream feedToAbsorber = - new Stream("feed to TEG absorber", feedTPsetterToAbsorber.getOutletStream()); - - Stream TEGFeed = new Stream("lean TEG to absorber", feedTEG); - TEGFeed.setFlowRate(leanTEGFlowRate, "kg/hr"); - TEGFeed.setTemperature(leanTEGTemperature, "C"); - TEGFeed.setPressure(absorberFeedGasPressure, "bara"); - - SimpleTEGAbsorber absorber = new SimpleTEGAbsorber("TEG absorber"); - absorber.addGasInStream(feedToAbsorber); - absorber.addSolventInStream(TEGFeed); - absorber.setNumberOfStages(numberOfEquilibriumStagesTEGabsorber); - absorber.setStageEfficiency(stageEfficiencyTEGabsorber); - - Stream dehydratedGas = new Stream("dry gas from absorber", absorber.getGasOutStream()); - - Stream richTEG = new Stream("rich TEG from absorber", absorber.getSolventOutStream()); - - WaterDewPointAnalyser waterDewPointAnalyser2 = new WaterDewPointAnalyser(dehydratedGas); - waterDewPointAnalyser2.setName("water dew point analyser2"); - - HydrateEquilibriumTemperatureAnalyser waterDewPointAnalyser = - new HydrateEquilibriumTemperatureAnalyser(dehydratedGas); - waterDewPointAnalyser.setName("water dew point analyser"); - - ThrottlingValve glycol_flash_valve = new ThrottlingValve("Flash valve", richTEG); - glycol_flash_valve.setName("Rich TEG HP flash valve"); - glycol_flash_valve.setOutletPressure(flashDrumPressure); - - Heater richGLycolHeaterCondenser = - new Heater("rich TEG preheater", glycol_flash_valve.getOutletStream()); - - HeatExchanger heatEx2 = new HeatExchanger("rich TEG heat exchanger 1", - richGLycolHeaterCondenser.getOutletStream()); - heatEx2.setGuessOutTemperature(273.15 + 62.0); - heatEx2.setUAvalue(UAvalueRichTEGHeatExchanger_1); - - Separator flashSep = new Separator("degasing separator", heatEx2.getOutStream(0)); - - Stream flashGas = new Stream("gas from degasing separator", flashSep.getGasOutStream()); - - Stream flashLiquid = - new Stream("liquid from degasing separator", flashSep.getLiquidOutStream()); - - Filter filter = new Filter("filters", flashLiquid); - - HeatExchanger heatEx = - new HeatExchanger("rich TEG heat exchanger 2", filter.getOutletStream()); - heatEx.setGuessOutTemperature(273.15 + 130.0); - heatEx.setUAvalue(UAvalueRichTEGHeatExchanger_2); - - ThrottlingValve glycol_flash_valve2 = - new ThrottlingValve("LP flash valve", heatEx.getOutStream(0)); - glycol_flash_valve2.setName("Rich TEG LP flash valve"); - glycol_flash_valve2.setOutletPressure(reboilerPressure); - - neqsim.thermo.system.SystemInterface stripGas = feedGas.clone(); - - Stream strippingGas = new Stream("stripGas", stripGas); - strippingGas.setFlowRate(strippingGasRate, "Sm3/hr"); - strippingGas.setTemperature(strippingGasFeedTemperature, "C"); - strippingGas.setPressure(reboilerPressure, "bara"); - - Stream gasToReboiler = strippingGas.clone(); - gasToReboiler.setName("gas to reboiler"); - - DistillationColumn column = new DistillationColumn(3, true, true); - column.setName("TEG regeneration column"); - column.addFeedStream(glycol_flash_valve2.getOutletStream(), 1); - column.getReboiler().setOutTemperature(273.15 + reboilerTemperature); - column.getCondenser().setOutTemperature(273.15 + condenserTemperature); - column.getReboiler().addStream(gasToReboiler); - column.setTopPressure(condenserPressure); - column.setBottomPressure(reboilerPressure); - - Heater coolerRegenGas = new Heater("regen gas cooler", column.getGasOutStream()); - coolerRegenGas.setOutTemperature(273.15 + regenerationGasCoolerTemperature); - - Separator sepregenGas = - new Separator("regen gas separator", coolerRegenGas.getOutletStream()); - - Stream gasToFlare = new Stream("gas to flare", sepregenGas.getGasOutStream()); - - Stream liquidToTrreatment = - new Stream("water to treatment", sepregenGas.getLiquidOutStream()); - - WaterStripperColumn stripper = new WaterStripperColumn("TEG stripper"); - stripper.addSolventInStream(column.getLiquidOutStream()); - stripper.addGasInStream(strippingGas); - stripper.setNumberOfStages(numberOfEquilibriumStagesStripper); - stripper.setStageEfficiency(stageEfficiencyStripper); - - Recycle recycleGasFromStripper = new Recycle("stripping gas recirc"); - recycleGasFromStripper.addStream(stripper.getGasOutStream()); - recycleGasFromStripper.setOutletStream(gasToReboiler); - - Heater bufferTank = new Heater("TEG buffer tank", stripper.getSolventOutStream()); - bufferTank.setOutTemperature(273.15 + bufferTankTemperatureTEG); - - Pump hotLeanTEGPump = new Pump("hot lean TEG pump", bufferTank.getOutletStream());// stripper.getSolventOutStream()); - hotLeanTEGPump.setOutletPressure(hotTEGpumpPressure); - hotLeanTEGPump.setIsentropicEfficiency(hotTEGpumpIsentropicEfficiency); - - heatEx.setFeedStream(1, hotLeanTEGPump.getOutletStream()); - - heatEx2.setFeedStream(1, heatEx.getOutStream(1)); - - Heater coolerhOTteg3 = new Heater("lean TEG cooler", heatEx2.getOutStream(1)); - coolerhOTteg3.setOutTemperature(273.15 + leanTEGTemperature); - - Pump hotLeanTEGPump2 = new Pump("lean TEG HP pump", coolerhOTteg3.getOutletStream()); - hotLeanTEGPump2.setOutletPressure(absorberFeedGasPressure); - hotLeanTEGPump2.setIsentropicEfficiency(coldTEGpumpIsentropicEfficiency); - - SetPoint pumpHPPresSet = - new SetPoint("HP pump set", hotLeanTEGPump2, "pressure", feedToAbsorber); - - Stream leanTEGtoabs = new Stream("lean TEG to absorber", hotLeanTEGPump2.getOutletStream()); - - neqsim.thermo.system.SystemInterface pureTEG = feedGas.clone(); - pureTEG.setMolarComposition( - new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}); - - Stream makeupTEG = new Stream("makeup TEG", pureTEG); - makeupTEG.setFlowRate(1e-6, "kg/hr"); - makeupTEG.setTemperature(leanTEGTemperature, "C"); - makeupTEG.setPressure(absorberFeedGasPressure, "bara"); - - Calculator makeupCalculator = new Calculator("TEG makeup calculator"); - makeupCalculator.addInputVariable(dehydratedGas); - makeupCalculator.addInputVariable(flashGas); - makeupCalculator.addInputVariable(gasToFlare); - makeupCalculator.addInputVariable(liquidToTrreatment); - makeupCalculator.setOutputVariable(makeupTEG); - - StaticMixer makeupMixer = new StaticMixer("makeup mixer"); - makeupMixer.addStream(leanTEGtoabs); - makeupMixer.addStream(makeupTEG); - - Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); - resycleLeanTEG.addStream(makeupMixer.getOutletStream()); - resycleLeanTEG.setOutletStream(TEGFeed); - resycleLeanTEG.setPriority(200); - resycleLeanTEG.setDownstreamProperty("flow rate"); - - richGLycolHeaterCondenser.setEnergyStream(column.getCondenser().getEnergyStream()); - // richGLycolHeater.isSetEnergyStream(); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(dryFeedGas); - operations.add(saturatedFeedGas); - operations.add(waterSaturatedFeedGas); - operations.add(hydrateTAnalyser); - operations.add(feedTPsetterToAbsorber); - operations.add(feedToAbsorber); - operations.add(TEGFeed); - operations.add(absorber); - operations.add(dehydratedGas); - operations.add(waterDewPointAnalyser); - operations.add(waterDewPointAnalyser2); - operations.add(richTEG); - operations.add(glycol_flash_valve); - operations.add(richGLycolHeaterCondenser); - operations.add(heatEx2); - operations.add(flashSep); - operations.add(flashGas); - operations.add(flashLiquid); - operations.add(filter); - operations.add(heatEx); - operations.add(glycol_flash_valve2); - operations.add(gasToReboiler); - operations.add(column); - operations.add(coolerRegenGas); - operations.add(sepregenGas); - operations.add(gasToFlare); - operations.add(liquidToTrreatment); - operations.add(strippingGas); - operations.add(stripper); - operations.add(recycleGasFromStripper); - operations.add(bufferTank); - operations.add(hotLeanTEGPump); - operations.add(coolerhOTteg3); - operations.add(pumpHPPresSet); - operations.add(hotLeanTEGPump2); - operations.add(leanTEGtoabs); - operations.add(makeupCalculator); - operations.add(makeupTEG); - operations.add(makeupMixer); - operations.add(resycleLeanTEG); - return operations; - } - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects + double eff2 = + ((HeatExchanger) operations.getUnit("rich TEG heat exchanger 2")).getThermalEffectiveness(); + ((HeatExchanger) operations.getUnit("rich TEG heat exchanger 2")).run(); + ConditionMonitor monitor = operations.getConditionMonitor(); + // double prevTem= ((HeatExchanger)monitor.getProcess().getUnit("rich TEG heat exchanger + // 2")).getInStream(0).getTemperature("C"); + ((HeatExchanger) monitor.getProcess().getUnit("rich TEG heat exchanger 2")).getInStream(0) + .setTemperature(84.93, "C"); + monitor.conditionAnalysis("rich TEG heat exchanger 2"); + double eff3 = ((HeatExchanger) monitor.getProcess().getUnit("rich TEG heat exchanger 2")) + .getThermalEffectiveness(); + System.out.println("ef3 " + eff3); + + // System.out.println("temp inn "+ (prevTem)); + /* + * double waterInWetGasppm = + * waterSaturatedFeedGas.getFluid().getPhase(0).getComponent("water").getz() * 1.0e6; double + * waterInWetGaskgMSm3 = waterInWetGasppm * 0.01802 * 101325.0 / (8.314 * 288.15); double + * TEGfeedwt = TEGFeed.getFluid().getPhase("aqueous").getWtFrac("TEG"); double TEGfeedflw = + * TEGFeed.getFlowRate("kg/hr"); double waterInDehydratedGasppm = + * dehydratedGas.getFluid().getPhase(0).getComponent("water").getz() * 1.0e6; double + * waterInDryGaskgMSm3 = waterInDehydratedGasppm * 0.01802 * 101325.0 / (8.314 * 288.15); double + * richTEG2 = richTEG.getFluid().getPhase("aqueous").getWtFrac("TEG"); double temp = + * ((Stream)operations.getUnit("feed to TEG absorber")).getFluid().getPhase(0).getComponent( + * "water").getz()*1.0e6*0.01802*101325.0/(8.314*288.15); + * System.out.println("reboiler duty (KW) " + ((Reboiler) column.getReboiler()).getDuty() / + * 1.0e3); System.out.println("flow rate from reboiler " + ((Reboiler) + * column.getReboiler()).getLiquidOutStream().getFlowRate("kg/hr")); + * System.out.println("flow rate from stripping column " + + * stripper.getLiquidOutStream().getFlowRate("kg/hr")); + * System.out.println("flow rate from pump2 " + + * hotLeanTEGPump2.getOutStream().getFluid().getFlowRate("kg/hr")); + * System.out.println("makeup TEG " + makeupTEG.getFluid().getFlowRate("kg/hr")); + * + * TEGFeed.getFluid().display(); absorber.run(); + * + * System.out.println("pump power " + hotLeanTEGPump.getDuty()); + * System.out.println("pump2 power " + hotLeanTEGPump2.getDuty()); + * System.out.println("wt lean TEG after reboiler " + + * column.getLiquidOutStream().getFluid().getPhase("aqueous").getWtFrac("TEG")); + * System.out.println("temperature from pump " + + * (hotLeanTEGPump2.getOutStream().getTemperature() - 273.15)); + * + * System.out.println("flow rate from reboiler " + ((Reboiler) + * column.getReboiler()).getLiquidOutStream().getFlowRate("kg/hr")); + * System.out.println("flow rate from pump2 " + + * hotLeanTEGPump2.getOutStream().getFluid().getFlowRate("kg/hr")); + * System.out.println("flow rate to flare " + gasToFlare.getFluid().getFlowRate("kg/hr")); + * + * System.out.println("condenser duty " + ((Condenser) ((DistillationColumn) + * operations.getUnit("TEG regeneration column")).getCondenser()) .getDuty() / 1.0e3); + * System.out.println( "richGLycolHeaterCondenser duty " + + * richGLycolHeaterCondenser.getEnergyStream().getDuty() / 1.0e3); + * System.out.println("richGLycolHeaterCondenser temperature out " + + * richGLycolHeaterCondenser.getOutStream().getTemperature("C")); + * richGLycolHeaterCondenser.run(); + * + * hotLeanTEGPump.getOutStream().displayResult(); flashLiquid.displayResult(); + * + * System.out.println("Temperature rich TEG out of reflux condenser " + + * richGLycolHeaterCondenser.getOutStream().getTemperature("C")); heatEx.displayResult(); + * System.out.println("glycol out temperature " + + * glycol_flash_valve2.getOutStream().getFluid().getTemperature("C")); + * System.out.println("glycol out temperature2 " +heatEx2.getOutStream(0).getTemperature("C")); + * System.out.println("glycol out temperature2 " +heatEx2.getOutStream(1).getTemperature("C")); + * + * + * System.out.println("out water rate LP valve" + + * glycol_flash_valve2.getOutStream().getFluid().getPhase(0).getComponent("water"). + * getNumberOfmoles()); System.out.println("glycol out water rate reboil " + ((Reboiler) + * column.getReboiler()).getLiquidOutStream().getFluid().getComponent("water"). + * getNumberOfmoles()); System.out.println("glycol out water rate condens " + ((Condenser) + * column.getCondenser()).getGasOutStream().getFluid().getComponent("water"). + * getNumberOfmoles()); System.out.println("recycle out water rate " + * +recycleGasFromStripper.getOutletStream().getFluid().getComponent("water"). + * getNumberOfmoles()); + * + * System.out.println("water dew point of dry gas " + + * waterDewPointAnalyser.getMeasuredValue("C")); + * + * //double dewT = + * ((WaterDewPointAnalyser)operations.getMeasurementDevice("water dew point analyser")). + * getMeasuredValue("C"); //waterDewPointAnalyser.setOnlineValue(measured, unit) + * //waterDewPointAnalyser.setOnlineSignal(isOnlineSignal, plantName, transmitterame); + * + * + * + * //Heat exchanger test + * + * //Sabe and Open copy of model */ - @SuppressWarnings("unused") - public static void main(String[] args) { - TEGdehydrationProcessDistillationGFA tempClass = new TEGdehydrationProcessDistillationGFA(); - neqsim.processSimulation.processSystem.ProcessSystem operations = tempClass.getProcess(); - operations.run(); - // operations.run(); - // operations = - // neqsim.processSimulation.processSystem.ProcessSystem.open("c:/temp/TEGprocessGFA.neqsim"); - - double richTEGtemperature = ((Heater) operations.getUnit("rich TEG preheater")) - .getOutletStream().getTemperature("C"); - System.out.println("temp rich TEG " + richTEGtemperature); - System.out.println("condenser duty (KW) " - + ((Condenser) ((DistillationColumn) operations.getUnit("TEG regeneration column")) - .getCondenser()).getDuty() / 1.0e3); - System.out.println("reboiler duty (KW) " - + ((Reboiler) ((DistillationColumn) operations.getUnit("TEG regeneration column")) - .getReboiler()).getDuty() / 1.0e3); - - System.out.println("temp out rich TEG " + richTEGtemperature); - - double rich2TEGtemperature = - ((HeatExchanger) operations.getUnit("rich TEG heat exchanger 1")).getOutStream(0) - .getTemperature("C"); - System.out.println("temp rich2 TEG " + rich2TEGtemperature); - - double rich22TEGtemperature = - ((HeatExchanger) operations.getUnit("rich TEG heat exchanger 2")).getOutStream(0) - .getTemperature("C"); - System.out.println("temp rich2 to reboil TEG " + rich22TEGtemperature); - - double lean22TEGtemperature = - ((HeatExchanger) operations.getUnit("rich TEG heat exchanger 2")).getOutStream(1) - .getTemperature("C"); - System.out.println("temp lean TEG to HX " + lean22TEGtemperature); - - // ((Stream)operations.getUnit("dry feed gas")).setFlowRate(10.23, "MSm3/day"); - // ((Stream)operations.getUnit("dry feed gas")).setTemperature(40.0, "C"); - // System.out.println("restart "); - // operations.run(); - operations.save("c:/temp/TEGprocessGFA.neqsim"); - double eff = ((HeatExchanger) operations.getUnit("rich TEG heat exchanger 2")) - .getThermalEffectiveness(); - System.out.println("HX2 thermal efficiency " + eff); - /// operations = ProcessSystem.open("c:/temp/TEGprocess.neqsim"); - // ((DistillationColumn)operations.getUnit("TEG regeneration - /// column")).setTopPressure(1.2); - // operations.run(); - // ((DistillationColumn)operations.getUnit("TEG regeneration - /// column")).setNumberOfTrays(2); - /* - * System.out.println("water in wet gas " + ((Stream) - * operations.getUnit("water saturated feed gas")).getFluid() - * .getPhase(0).getComponent("water").getz() * 1.0e6 * 0.01802 * 101325.0 / (8.314 * - * 288.15)); System.out.println("water in dry gas " + ((Stream) - * operations.getUnit("dry gas from absorber")).getFluid() - * .getPhase(0).getComponent("water").getz() * 1.0e6); - * System.out.println("reboiler duty (KW) " + ((Reboiler) ((DistillationColumn) - * operations.getUnit("TEG regeneration column")).getReboiler()) .getDuty() / 1.0e3); - * System.out.println("wt lean TEG " + ((WaterStripperColumn) - * operations.getUnit("TEG stripper")) - * .getSolventOutStream().getFluid().getPhase("aqueous").getWtFrac("TEG") * 100.0); - */ - double eff2 = ((HeatExchanger) operations.getUnit("rich TEG heat exchanger 2")) - .getThermalEffectiveness(); - ((HeatExchanger) operations.getUnit("rich TEG heat exchanger 2")).run(); - ConditionMonitor monitor = operations.getConditionMonitor(); - // double prevTem= ((HeatExchanger)monitor.getProcess().getUnit("rich TEG heat exchanger - // 2")).getInStream(0).getTemperature("C"); - ((HeatExchanger) monitor.getProcess().getUnit("rich TEG heat exchanger 2")).getInStream(0) - .setTemperature(84.93, "C"); - monitor.conditionAnalysis("rich TEG heat exchanger 2"); - double eff3 = ((HeatExchanger) monitor.getProcess().getUnit("rich TEG heat exchanger 2")) - .getThermalEffectiveness(); - System.out.println("ef3 " + eff3); - - // System.out.println("temp inn "+ (prevTem)); - /* - * double waterInWetGasppm = - * waterSaturatedFeedGas.getFluid().getPhase(0).getComponent("water").getz() * 1.0e6; double - * waterInWetGaskgMSm3 = waterInWetGasppm * 0.01802 * 101325.0 / (8.314 * 288.15); double - * TEGfeedwt = TEGFeed.getFluid().getPhase("aqueous").getWtFrac("TEG"); double TEGfeedflw = - * TEGFeed.getFlowRate("kg/hr"); double waterInDehydratedGasppm = - * dehydratedGas.getFluid().getPhase(0).getComponent("water").getz() * 1.0e6; double - * waterInDryGaskgMSm3 = waterInDehydratedGasppm * 0.01802 * 101325.0 / (8.314 * 288.15); - * double richTEG2 = richTEG.getFluid().getPhase("aqueous").getWtFrac("TEG"); double temp = - * ((Stream)operations.getUnit("feed to TEG absorber")).getFluid().getPhase(0).getComponent( - * "water").getz()*1.0e6*0.01802*101325.0/(8.314*288.15); - * System.out.println("reboiler duty (KW) " + ((Reboiler) column.getReboiler()).getDuty() / - * 1.0e3); System.out.println("flow rate from reboiler " + ((Reboiler) - * column.getReboiler()).getLiquidOutStream().getFlowRate("kg/hr")); - * System.out.println("flow rate from stripping column " + - * stripper.getLiquidOutStream().getFlowRate("kg/hr")); - * System.out.println("flow rate from pump2 " + - * hotLeanTEGPump2.getOutStream().getFluid().getFlowRate("kg/hr")); - * System.out.println("makeup TEG " + makeupTEG.getFluid().getFlowRate("kg/hr")); - * - * TEGFeed.getFluid().display(); absorber.run(); - * - * System.out.println("pump power " + hotLeanTEGPump.getDuty()); - * System.out.println("pump2 power " + hotLeanTEGPump2.getDuty()); - * System.out.println("wt lean TEG after reboiler " + - * column.getLiquidOutStream().getFluid().getPhase("aqueous").getWtFrac("TEG")); - * System.out.println("temperature from pump " + - * (hotLeanTEGPump2.getOutStream().getTemperature() - 273.15)); - * - * System.out.println("flow rate from reboiler " + ((Reboiler) - * column.getReboiler()).getLiquidOutStream().getFlowRate("kg/hr")); - * System.out.println("flow rate from pump2 " + - * hotLeanTEGPump2.getOutStream().getFluid().getFlowRate("kg/hr")); - * System.out.println("flow rate to flare " + gasToFlare.getFluid().getFlowRate("kg/hr")); - * - * System.out.println("condenser duty " + ((Condenser) ((DistillationColumn) - * operations.getUnit("TEG regeneration column")).getCondenser()) .getDuty() / 1.0e3); - * System.out.println( "richGLycolHeaterCondenser duty " + - * richGLycolHeaterCondenser.getEnergyStream().getDuty() / 1.0e3); - * System.out.println("richGLycolHeaterCondenser temperature out " + - * richGLycolHeaterCondenser.getOutStream().getTemperature("C")); - * richGLycolHeaterCondenser.run(); - * - * hotLeanTEGPump.getOutStream().displayResult(); flashLiquid.displayResult(); - * - * System.out.println("Temperature rich TEG out of reflux condenser " + - * richGLycolHeaterCondenser.getOutStream().getTemperature("C")); heatEx.displayResult(); - * System.out.println("glycol out temperature " + - * glycol_flash_valve2.getOutStream().getFluid().getTemperature("C")); - * System.out.println("glycol out temperature2 " - * +heatEx2.getOutStream(0).getTemperature("C")); - * System.out.println("glycol out temperature2 " - * +heatEx2.getOutStream(1).getTemperature("C")); - * - * - * System.out.println("out water rate LP valve" + - * glycol_flash_valve2.getOutStream().getFluid().getPhase(0).getComponent("water"). - * getNumberOfmoles()); System.out.println("glycol out water rate reboil " + ((Reboiler) - * column.getReboiler()).getLiquidOutStream().getFluid().getComponent("water"). - * getNumberOfmoles()); System.out.println("glycol out water rate condens " + ((Condenser) - * column.getCondenser()).getGasOutStream().getFluid().getComponent("water"). - * getNumberOfmoles()); System.out.println("recycle out water rate " - * +recycleGasFromStripper.getOutletStream().getFluid().getComponent("water"). - * getNumberOfmoles()); - * - * System.out.println("water dew point of dry gas " + - * waterDewPointAnalyser.getMeasuredValue("C")); - * - * //double dewT = - * ((WaterDewPointAnalyser)operations.getMeasurementDevice("water dew point analyser")). - * getMeasuredValue("C"); //waterDewPointAnalyser.setOnlineValue(measured, unit) - * //waterDewPointAnalyser.setOnlineSignal(isOnlineSignal, plantName, transmitterame); - * - * - * - * //Heat exchanger test - * - * //Sabe and Open copy of model - */ - // ProcessSystem locoperations = operations.copy(); - // ((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger - // 2")).getInStream(0).setTemperature(298.15, "C"); - // ((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger - // 2")).getInStream(1).setTemperature(363.15, "C"); - // ((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger - // 2")).getOutStream(0).setTemperature(298.15, "C"); - // ((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger - // 2")).getOutStream(1).setTemperature(333.15, "C"); - // ((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger - // 2")).runConditionAnalysis((HeatExchanger)operations.getUnit("rich TEG heat exchanger - // 2")); - // double eff = ((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger - // 2")).getThermalEffectiveness(); - // System.out.println("eff " + eff); - // store fouling factor in dataframe - } + // ProcessSystem locoperations = operations.copy(); + // ((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger + // 2")).getInStream(0).setTemperature(298.15, "C"); + // ((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger + // 2")).getInStream(1).setTemperature(363.15, "C"); + // ((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger + // 2")).getOutStream(0).setTemperature(298.15, "C"); + // ((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger + // 2")).getOutStream(1).setTemperature(333.15, "C"); + // ((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger + // 2")).runConditionAnalysis((HeatExchanger)operations.getUnit("rich TEG heat exchanger + // 2")); + // double eff = ((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger + // 2")).getThermalEffectiveness(); + // System.out.println("eff " + eff); + // store fouling factor in dataframe + } } diff --git a/src/test/java/neqsim/processSimulation/util/example/TestNeqsim.java b/src/test/java/neqsim/processSimulation/util/example/TestNeqsim.java index b389ca1234..530e523c64 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TestNeqsim.java +++ b/src/test/java/neqsim/processSimulation/util/example/TestNeqsim.java @@ -6,156 +6,157 @@ import neqsim.thermo.system.SystemSrkEos; /** - *

TestNeqsim class.

+ *

+ * TestNeqsim class. + *

* * @author Administrator * @version $Id: $Id * @since 2.2.3 */ public class TestNeqsim { - /** - *

main.

- * - * @param args the command line arguments - */ - @SuppressWarnings("unused") - public static void main(String[] args) { - SystemInterface testFluid = new SystemSrkEos(298.15, 10.0);// SystemSrkCPAstatoil(298.1, - // 10.9); //298.15 K - - testFluid.addComponent("methane", 8.8316); - testFluid.addComponent("nitrogen", 0.0296682); - testFluid.addComponent("CO2", 0.0209667); - testFluid.addComponent("ethane", 0.28915); - testFluid.addComponent("propane", 0.116637); - testFluid.addComponent("i-butane", 0.0222488); - testFluid.addComponent("n-butane", 0.0315726); - testFluid.addComponent("i-pentane", 0.0097763); - testFluid.addComponent("n-pentane", 0.0104928); + /** + *

+ * main. + *

+ * + * @param args the command line arguments + */ + @SuppressWarnings("unused") + public static void main(String[] args) { + SystemInterface testFluid = new SystemSrkEos(298.15, 10.0); // SystemSrkCPAstatoil(298.1, + // 10.9); //298.15 K - // testFluid.addTBPfraction("C7", 0.0137641, 86.18 / 1000.0, 0.664); - // testFluid.addTBPfraction("C8", 0.025341, 96.46 / 1000.0, 0.7217); - // testFluid.addTBPfraction("C9", 0.023069, 124.66 / 1000.0, 0.7604); - // testFluid.addTBPfraction("C10", 0.0031771, 178.2 / 1000.0, 0.8021); - // testFluid.addTBPfraction("C11", 0.0000188549, 263.77 / 1000.0, 0.8416); + testFluid.addComponent("methane", 8.8316); + testFluid.addComponent("nitrogen", 0.0296682); + testFluid.addComponent("CO2", 0.0209667); + testFluid.addComponent("ethane", 0.28915); + testFluid.addComponent("propane", 0.116637); + testFluid.addComponent("i-butane", 0.0222488); + testFluid.addComponent("n-butane", 0.0315726); + testFluid.addComponent("i-pentane", 0.0097763); + testFluid.addComponent("n-pentane", 0.0104928); - testFluid.addComponent("water", 0.39944); - // testFluid.addComponent("MEG", 0.173083); + // testFluid.addTBPfraction("C7", 0.0137641, 86.18 / 1000.0, 0.664); + // testFluid.addTBPfraction("C8", 0.025341, 96.46 / 1000.0, 0.7217); + // testFluid.addTBPfraction("C9", 0.023069, 124.66 / 1000.0, 0.7604); + // testFluid.addTBPfraction("C10", 0.0031771, 178.2 / 1000.0, 0.8021); + // testFluid.addTBPfraction("C11", 0.0000188549, 263.77 / 1000.0, 0.8416); - testFluid.createDatabase(true); - testFluid.setMixingRule(2); // use 10 for CPA and 2 for SRK/PR - testFluid.setMultiPhaseCheck(true); - testFluid.initPhysicalProperties(); - double[] temperature = new double[10]; - double[] work = new double[10]; - double[] Cp_Vapour = new double[10]; - double[] Cp_liquid = new double[10]; - double[] Cp = new double[10]; - double[] Density_Vapour = new double[10]; - double[] Density_liquid = new double[10]; - double[] Density = new double[10]; + testFluid.addComponent("water", 0.39944); + // testFluid.addComponent("MEG", 0.173083); - // for(int i=0;i<10;i++){ - Stream stream1 = new Stream("stream1", testFluid); - Compressor compressor1 = new Compressor("compressor1", stream1); - compressor1.setOutletPressure(26.590909);// (20+5*i) - compressor1.setUsePolytropicCalc(true); - compressor1.setPolytropicEfficiency(0.64951); - Stream stream2 = new Stream("stream2", compressor1.getOutletStream()); + testFluid.createDatabase(true); + testFluid.setMixingRule(2); // use 10 for CPA and 2 for SRK/PR + testFluid.setMultiPhaseCheck(true); + testFluid.initPhysicalProperties(); + double[] temperature = new double[10]; + double[] work = new double[10]; + double[] Cp_Vapour = new double[10]; + double[] Cp_liquid = new double[10]; + double[] Cp = new double[10]; + double[] Density_Vapour = new double[10]; + double[] Density_liquid = new double[10]; + double[] Density = new double[10]; - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(stream1); - operations.add(compressor1); - operations.add(stream2); - operations.run(); - // compressor1.getOutStream().getThermoSystem().display(); + // for(int i=0;i<10;i++){ + Stream stream1 = new Stream("stream1", testFluid); + Compressor compressor1 = new Compressor("compressor1", stream1); + compressor1.setOutletPressure(26.590909); // (20+5*i) + compressor1.setUsePolytropicCalc(true); + compressor1.setPolytropicEfficiency(0.64951); + Stream stream2 = new Stream("stream2", compressor1.getOutletStream()); - double CpVapour = stream1.getThermoSystem().getPhase(0).getCp(); - double Cpliquid = stream1.getThermoSystem().getPhase(2).getCp(); - double CpOil = stream1.getThermoSystem().getPhase(1).getCp(); - double Cpone = stream1.getThermoSystem().getPhase(0).getBeta() * CpVapour - + stream1.getThermoSystem().getPhase(1).getBeta() * CpOil - + stream1.getThermoSystem().getPhase(2).getBeta() * Cpliquid; + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream1); + operations.add(compressor1); + operations.add(stream2); + operations.run(); + // compressor1.getOutStream().getThermoSystem().display(); - double DensityVapour = stream1.getThermoSystem().getPhase(0).getDensity(); - double Densityliquid = stream1.getThermoSystem().getPhase(2).getDensity(); - double DensityOil = stream1.getThermoSystem().getPhase(1).getDensity(); - double Density1 = stream1.getThermoSystem().getWtFraction(0) * DensityVapour - + stream1.getThermoSystem().getWtFraction(1) * DensityOil - + stream1.getThermoSystem().getWtFraction(2) * Densityliquid; - // operations.run(); - System.out.println("work " + compressor1.getTotalWork() + " density " + Density1 + " Cp " - + Cpone + " SPEED OF SOUND " - + stream1.getThermoSystem().getPhase(0).getSoundSpeed()); + double CpVapour = stream1.getThermoSystem().getPhase(0).getCp(); + double Cpliquid = stream1.getThermoSystem().getPhase(2).getCp(); + double CpOil = stream1.getThermoSystem().getPhase(1).getCp(); + double Cpone = stream1.getThermoSystem().getPhase(0).getBeta() * CpVapour + + stream1.getThermoSystem().getPhase(1).getBeta() * CpOil + + stream1.getThermoSystem().getPhase(2).getBeta() * Cpliquid; - compressor1.solveEfficiency(390.15); - compressor1.getOutletStream().displayResult(); - System.out.println("Hvap " + stream1.getThermoSystem().getHeatOfVaporization() + " POLI " - + compressor1.getPolytropicEfficiency() + " dentity " - + stream1.getThermoSystem().getDensity() + " cp " - + stream1.getThermoSystem().getCp()); - stream1.getThermoSystem().display(); + double DensityVapour = stream1.getThermoSystem().getPhase(0).getDensity(); + double Densityliquid = stream1.getThermoSystem().getPhase(2).getDensity(); + double DensityOil = stream1.getThermoSystem().getPhase(1).getDensity(); + double Density1 = stream1.getThermoSystem().getWtFraction(0) * DensityVapour + + stream1.getThermoSystem().getWtFraction(1) * DensityOil + + stream1.getThermoSystem().getWtFraction(2) * Densityliquid; + // operations.run(); + System.out.println("work " + compressor1.getTotalWork() + " density " + Density1 + " Cp " + + Cpone + " SPEED OF SOUND " + stream1.getThermoSystem().getPhase(0).getSoundSpeed()); - double massFlowGas = stream1.getThermoSystem().getPhase(0).getBeta() - * stream1.getThermoSystem().getPhase(0).getMolarMass(); - double massFlowLiq = stream1.getThermoSystem().getPhase(2).getBeta() - * stream1.getThermoSystem().getPhase(2).getMolarMass(); - double massFlowOil = stream1.getThermoSystem().getPhase(1).getBeta() - * stream1.getThermoSystem().getPhase(1).getMolarMass(); + compressor1.solveEfficiency(390.15); + compressor1.getOutletStream().displayResult(); + System.out.println("Hvap " + stream1.getThermoSystem().getHeatOfVaporization() + " POLI " + + compressor1.getPolytropicEfficiency() + " dentity " + + stream1.getThermoSystem().getDensity() + " cp " + stream1.getThermoSystem().getCp()); + stream1.getThermoSystem().display(); - double volFlowGas = massFlowGas / stream1.getThermoSystem().getPhase(0).getDensity(); - double volFlowLiq = massFlowLiq / stream1.getThermoSystem().getPhase(2).getDensity(); - double volFlowOil = massFlowOil / stream1.getThermoSystem().getPhase(1).getDensity(); + double massFlowGas = stream1.getThermoSystem().getPhase(0).getBeta() + * stream1.getThermoSystem().getPhase(0).getMolarMass(); + double massFlowLiq = stream1.getThermoSystem().getPhase(2).getBeta() + * stream1.getThermoSystem().getPhase(2).getMolarMass(); + double massFlowOil = stream1.getThermoSystem().getPhase(1).getBeta() + * stream1.getThermoSystem().getPhase(1).getMolarMass(); - double GMF = massFlowGas / (massFlowGas + massFlowOil + massFlowLiq); - double GVF = volFlowGas / (volFlowGas + volFlowOil + volFlowLiq); - System.out.println("inlet stream - GMF " + GMF + " GVF " + GVF + " Z IN " - + stream1.getThermoSystem().getZ() + " Z OUT " - + compressor1.getOutletStream().getThermoSystem().getZ()); - /* - * temperature[i] = compressor1.getOutStream().getTemperature(); work [i] = - * compressor1.getTotalWork(); - * - * Cp_Vapour [i] = compressor1.getOutStream().getThermoSystem().getPhase(0).getCp(); - * Cp_liquid [i] = compressor1.getOutStream().getThermoSystem().getPhase(1).getCp(); Cp [i] - * = compressor1.getOutStream().getThermoSystem().getPhase(0).getBeta() * Cp_Vapour [i] + - * compressor1.getOutStream().getThermoSystem().getPhase(1).getBeta()* Cp_liquid [i]; - * - * Density_Vapour [i] = - * compressor1.getOutStream().getThermoSystem().getPhase(0).getDensity(); Density_liquid [i] - * = compressor1.getOutStream().getThermoSystem().getPhase(1).getDensity(); Density [i] = - * compressor1.getOutStream().getThermoSystem().getWtFraction(0) * Density_Vapour [i] + - * compressor1.getOutStream().getThermoSystem().getWtFraction(1)* Density_liquid [i]; - */ - // } + double volFlowGas = massFlowGas / stream1.getThermoSystem().getPhase(0).getDensity(); + double volFlowLiq = massFlowLiq / stream1.getThermoSystem().getPhase(2).getDensity(); + double volFlowOil = massFlowOil / stream1.getThermoSystem().getPhase(1).getDensity(); - // System.out.println("poli"); - // stream2.displayResult(); - // operations.displayResult(); - // ThermodynamicOperations flash = new ThermodynamicOperations(testFluid); - // try{ - // flash.TPflash(); - } - // catch(Exception e){ + double GMF = massFlowGas / (massFlowGas + massFlowOil + massFlowLiq); + double GVF = volFlowGas / (volFlowGas + volFlowOil + volFlowLiq); + System.out.println( + "inlet stream - GMF " + GMF + " GVF " + GVF + " Z IN " + stream1.getThermoSystem().getZ() + + " Z OUT " + compressor1.getOutletStream().getThermoSystem().getZ()); /* - * System.out.println( "P_out" ); for (int i=0;i<10;i++ ) { System.out.println(20 + 5*i); - * - * } - * - * System.out.println( "Temperature" ); for (int i=0;i<10;i++ ) { System.out.println( - * temperature[i] ); + * temperature[i] = compressor1.getOutStream().getTemperature(); work [i] = + * compressor1.getTotalWork(); * - * } + * Cp_Vapour [i] = compressor1.getOutStream().getThermoSystem().getPhase(0).getCp(); Cp_liquid + * [i] = compressor1.getOutStream().getThermoSystem().getPhase(1).getCp(); Cp [i] = + * compressor1.getOutStream().getThermoSystem().getPhase(0).getBeta() * Cp_Vapour [i] + + * compressor1.getOutStream().getThermoSystem().getPhase(1).getBeta()* Cp_liquid [i]; * - * System.out.println( "Work" ); for (int i=0;i<10;i++ ) { System.out.println( work [i] ); - * - * } System.out.println( "Cp" ); for (int i=0;i<10;i++ ) { System.out.println( Cp [i] ); - * - * } - * - * System.out.println( "Density" ); for (int i=0;i<10;i++ ) { System.out.println( Density [i] ); + * Density_Vapour [i] = compressor1.getOutStream().getThermoSystem().getPhase(0).getDensity(); + * Density_liquid [i] = compressor1.getOutStream().getThermoSystem().getPhase(1).getDensity(); + * Density [i] = compressor1.getOutStream().getThermoSystem().getWtFraction(0) * Density_Vapour + * [i] + compressor1.getOutStream().getThermoSystem().getWtFraction(1)* Density_liquid [i]; */ + // } + + // System.out.println("poli"); + // stream2.displayResult(); + // operations.displayResult(); + // ThermodynamicOperations flash = new ThermodynamicOperations(testFluid); + // try{ + // flash.TPflash(); + } + // catch(Exception e){ + /* + * System.out.println( "P_out" ); for (int i=0;i<10;i++ ) { System.out.println(20 + 5*i); + * + * } + * + * System.out.println( "Temperature" ); for (int i=0;i<10;i++ ) { System.out.println( + * temperature[i] ); + * + * } + * + * System.out.println( "Work" ); for (int i=0;i<10;i++ ) { System.out.println( work [i] ); + * + * } System.out.println( "Cp" ); for (int i=0;i<10;i++ ) { System.out.println( Cp [i] ); + * + * } + * + * System.out.println( "Density" ); for (int i=0;i<10;i++ ) { System.out.println( Density [i] ); + */ } // } // testFluid.display(); diff --git a/src/test/java/neqsim/processSimulation/util/example/multiThreadTest.java b/src/test/java/neqsim/processSimulation/util/example/multiThreadTest.java index 21f56e15c6..d33fab864f 100644 --- a/src/test/java/neqsim/processSimulation/util/example/multiThreadTest.java +++ b/src/test/java/neqsim/processSimulation/util/example/multiThreadTest.java @@ -11,128 +11,130 @@ import neqsim.thermodynamicOperations.ThermodynamicOperations; /** - *

multiThreadTest class.

+ *

+ * multiThreadTest class. + *

* * @author asmund * @version $Id: $Id * @since 2.2.3 */ public class multiThreadTest { - /** - * This method is just meant to test the thermo package. - * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 20.00); - testSystem.addComponent("methane", 500.00); - testSystem.addComponent("ethane", 500.00); - testSystem.addComponent("CO2", 100.00); - testSystem.addComponent("water", 100.0); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - - Stream stream_1 = new Stream("Stream1", testSystem); - - MixerInterface mixer = new StaticMixer("Mixer 1"); - mixer.addStream(stream_1); - StreamInterface stream_3 = mixer.getOutletStream(); - stream_3.setName("stream3"); - - Separator separator = new Separator("Separator 1", stream_3); - StreamInterface stream_2 = separator.getGasOutStream(); - stream_2.setName("stream2"); - - Compressor comp1 = new Compressor("comp1", stream_2); - comp1.setOutletPressure(50.0); - - Cooler cooler1 = new Cooler("cooler1", comp1.getOutletStream()); - cooler1.setOutTemperature(283.15 + 30); - - // mixer.addStream(stream_2); - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(stream_1); - operations.add(stream_2); - operations.add(mixer); - operations.add(stream_3); - operations.add(separator); - operations.add(comp1); - operations.add(cooler1); - - neqsim.thermo.system.SystemInterface testSystem2 = - new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 20.00); - testSystem2.addComponent("methane", 400.00); - testSystem2.addComponent("ethane", 4.00); - testSystem2.addComponent("CO2", 100.00); - testSystem2.addComponent("water", 100.0); - testSystem2.createDatabase(true); - testSystem2.setMixingRule(2); - - ThermodynamicOperations testOps2 = new ThermodynamicOperations(testSystem2); - testOps2.TPflash(); - - Stream stream_22 = new Stream("Stream1", testSystem2); - - MixerInterface mixer2 = new StaticMixer("Mixer 1"); - mixer2.addStream(stream_22); - StreamInterface stream_32 = mixer2.getOutletStream(); - stream_32.setName("stream32"); - - Separator separator2 = new Separator("Separator 1", stream_32); - StreamInterface stream_222 = separator2.getGasOutStream(); - stream_222.setName("stream222"); - - Compressor comp12 = new Compressor("comp22", stream_222); - comp12.setOutletPressure(45.0); - - Cooler cooler12 = new Cooler("cooler12", comp12.getOutletStream()); - cooler12.setOutTemperature(283.15 + 30); - - Separator separator3 = new Separator("Separator 122", cooler12.getOutletStream()); - - Recycle resyc = new Recycle("resyc"); - resyc.addStream(separator3.getLiquidOutStream()); - - mixer2.addStream(resyc.getOutStream()); - - // mixer2.addStream(stream_222); - neqsim.processSimulation.processSystem.ProcessSystem operations2 = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations2.add(stream_22); - operations2.add(mixer2); - operations2.add(stream_32); - operations2.add(separator2); - operations2.add(comp12); - operations2.add(cooler12); - operations2.add(separator3); - operations2.add(resyc); - - long time = System.currentTimeMillis(); - - for (int i = 0; i < 1; i++) { - // operations.run(); - // operations2.run(); - Thread processThread1 = new Thread(operations); - Thread processThread2 = new Thread(operations2); - - processThread1.start(); - processThread2.start(); - - try { - processThread1.join(1000); - processThread2.join(1000); - } catch (Exception e) { - e.printStackTrace(); - } - } - // } while (processThread1.isAlive());// && processThread2.isAlive()); - - System.out.println("Time taken for simulation = " + (System.currentTimeMillis() - time)); - - ((Compressor) operations.getUnit("comp1")).displayResult(); - ((Compressor) operations2.getUnit("comp22")).displayResult(); - // operations2.displayResult(); + /** + * This method is just meant to test the thermo package. + * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 20.00); + testSystem.addComponent("methane", 500.00); + testSystem.addComponent("ethane", 500.00); + testSystem.addComponent("CO2", 100.00); + testSystem.addComponent("water", 100.0); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + + Stream stream_1 = new Stream("Stream1", testSystem); + + MixerInterface mixer = new StaticMixer("Mixer 1"); + mixer.addStream(stream_1); + StreamInterface stream_3 = mixer.getOutletStream(); + stream_3.setName("stream3"); + + Separator separator = new Separator("Separator 1", stream_3); + StreamInterface stream_2 = separator.getGasOutStream(); + stream_2.setName("stream2"); + + Compressor comp1 = new Compressor("comp1", stream_2); + comp1.setOutletPressure(50.0); + + Cooler cooler1 = new Cooler("cooler1", comp1.getOutletStream()); + cooler1.setOutTemperature(283.15 + 30); + + // mixer.addStream(stream_2); + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(stream_2); + operations.add(mixer); + operations.add(stream_3); + operations.add(separator); + operations.add(comp1); + operations.add(cooler1); + + neqsim.thermo.system.SystemInterface testSystem2 = + new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 20.00); + testSystem2.addComponent("methane", 400.00); + testSystem2.addComponent("ethane", 4.00); + testSystem2.addComponent("CO2", 100.00); + testSystem2.addComponent("water", 100.0); + testSystem2.createDatabase(true); + testSystem2.setMixingRule(2); + + ThermodynamicOperations testOps2 = new ThermodynamicOperations(testSystem2); + testOps2.TPflash(); + + Stream stream_22 = new Stream("Stream1", testSystem2); + + MixerInterface mixer2 = new StaticMixer("Mixer 1"); + mixer2.addStream(stream_22); + StreamInterface stream_32 = mixer2.getOutletStream(); + stream_32.setName("stream32"); + + Separator separator2 = new Separator("Separator 1", stream_32); + StreamInterface stream_222 = separator2.getGasOutStream(); + stream_222.setName("stream222"); + + Compressor comp12 = new Compressor("comp22", stream_222); + comp12.setOutletPressure(45.0); + + Cooler cooler12 = new Cooler("cooler12", comp12.getOutletStream()); + cooler12.setOutTemperature(283.15 + 30); + + Separator separator3 = new Separator("Separator 122", cooler12.getOutletStream()); + + Recycle resyc = new Recycle("resyc"); + resyc.addStream(separator3.getLiquidOutStream()); + + mixer2.addStream(resyc.getOutStream()); + + // mixer2.addStream(stream_222); + neqsim.processSimulation.processSystem.ProcessSystem operations2 = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations2.add(stream_22); + operations2.add(mixer2); + operations2.add(stream_32); + operations2.add(separator2); + operations2.add(comp12); + operations2.add(cooler12); + operations2.add(separator3); + operations2.add(resyc); + + long time = System.currentTimeMillis(); + + for (int i = 0; i < 1; i++) { + // operations.run(); + // operations2.run(); + Thread processThread1 = new Thread(operations); + Thread processThread2 = new Thread(operations2); + + processThread1.start(); + processThread2.start(); + + try { + processThread1.join(1000); + processThread2.join(1000); + } catch (Exception e) { + e.printStackTrace(); + } } + // } while (processThread1.isAlive()); // && processThread2.isAlive()); + + System.out.println("Time taken for simulation = " + (System.currentTimeMillis() - time)); + + ((Compressor) operations.getUnit("comp1")).displayResult(); + ((Compressor) operations2.getUnit("comp22")).displayResult(); + // operations2.displayResult(); + } } diff --git a/src/test/java/neqsim/standards/gasQuality/Standard_ISO6578Test.java b/src/test/java/neqsim/standards/gasQuality/Standard_ISO6578Test.java index 3a8f3b8473..b0d1c82b10 100644 --- a/src/test/java/neqsim/standards/gasQuality/Standard_ISO6578Test.java +++ b/src/test/java/neqsim/standards/gasQuality/Standard_ISO6578Test.java @@ -5,33 +5,33 @@ import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; -public class Standard_ISO6578Test extends neqsim.NeqSimTest{ - @Test - void testCalculate() { - SystemInterface testSystem = new SystemSrkEos(273.15 - 160.0, 1.0); - testSystem.addComponent("nitrogen", 0.006538); - testSystem.addComponent("methane", 0.91863); - testSystem.addComponent("ethane", 0.058382); - testSystem.addComponent("propane", 0.011993); - // testSystem.addComponent("i-butane", 0.00); - testSystem.addComponent("n-butane", 0.003255); - testSystem.addComponent("i-pentane", 0.000657); - testSystem.addComponent("n-pentane", 0.000545); +public class Standard_ISO6578Test extends neqsim.NeqSimTest { + @Test + void testCalculate() { + SystemInterface testSystem = new SystemSrkEos(273.15 - 160.0, 1.0); + testSystem.addComponent("nitrogen", 0.006538); + testSystem.addComponent("methane", 0.91863); + testSystem.addComponent("ethane", 0.058382); + testSystem.addComponent("propane", 0.011993); + // testSystem.addComponent("i-butane", 0.00); + testSystem.addComponent("n-butane", 0.003255); + testSystem.addComponent("i-pentane", 0.000657); + testSystem.addComponent("n-pentane", 0.000545); - testSystem.createDatabase(true); - // testSystem.setMultiphaseWaxCheck(true); - testSystem.setMixingRule(2); + testSystem.createDatabase(true); + // testSystem.setMultiphaseWaxCheck(true); + testSystem.setMixingRule(2); - testSystem.init(0); - Standard_ISO6578 standard = new Standard_ISO6578(testSystem);// testSystem); - standard.calculate(); - //testSystem.display(); + testSystem.init(0); + Standard_ISO6578 standard = new Standard_ISO6578(testSystem); // testSystem); + standard.calculate(); + // testSystem.display(); - Assertions.assertEquals(0.30930700620842033, standard.getCorrFactor1()); - // ((Standard_ISO6578) standard).useISO6578VolumeCorrectionFacotrs(false); + Assertions.assertEquals(0.30930700620842033, standard.getCorrFactor1()); + // ((Standard_ISO6578) standard).useISO6578VolumeCorrectionFacotrs(false); - standard.calculate(); - Assertions.assertEquals(0.30930700620842033, standard.getCorrFactor1()); - // testSystem.display(); - } + standard.calculate(); + Assertions.assertEquals(0.30930700620842033, standard.getCorrFactor1()); + // testSystem.display(); + } } diff --git a/src/test/java/neqsim/thermo/util/example/HeatOfVaporization.java b/src/test/java/neqsim/thermo/util/example/HeatOfVaporization.java index 2adbecc43b..dd20c39454 100644 --- a/src/test/java/neqsim/thermo/util/example/HeatOfVaporization.java +++ b/src/test/java/neqsim/thermo/util/example/HeatOfVaporization.java @@ -16,28 +16,30 @@ * @since 2.2.3 */ public class HeatOfVaporization { - static Logger logger = LogManager.getLogger(HeatOfVaporization.class); + static Logger logger = LogManager.getLogger(HeatOfVaporization.class); - /** - *

main.

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - SystemInterface testSystem = new SystemSrkCPAstatoil(288.15000000, 0.001);// - testSystem.addComponent("TEG", 1); - testSystem.createDatabase(true); - testSystem.setMixingRule(10); - testSystem.init(0); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - try { - testOps.bubblePointPressureFlash(false); - testSystem.display(); - double heatVap = testSystem.getHeatOfVaporization(); - logger.info("heat of vaporization " + heatVap + " J/mol"); - logger.info("heat of vaporization " + (heatVap / testSystem.getMolarMass()) + " J/kg"); - } catch (Exception e) { - logger.error(e.toString()); - } + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + SystemInterface testSystem = new SystemSrkCPAstatoil(288.15000000, 0.001); + testSystem.addComponent("TEG", 1); + testSystem.createDatabase(true); + testSystem.setMixingRule(10); + testSystem.init(0); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + try { + testOps.bubblePointPressureFlash(false); + testSystem.display(); + double heatVap = testSystem.getHeatOfVaporization(); + logger.info("heat of vaporization " + heatVap + " J/mol"); + logger.info("heat of vaporization " + (heatVap / testSystem.getMolarMass()) + " J/kg"); + } catch (Exception e) { + logger.error(e.toString()); } + } } diff --git a/src/test/java/neqsim/thermo/util/example/HydrateFlash.java b/src/test/java/neqsim/thermo/util/example/HydrateFlash.java index 725e8acd17..015b820cfe 100644 --- a/src/test/java/neqsim/thermo/util/example/HydrateFlash.java +++ b/src/test/java/neqsim/thermo/util/example/HydrateFlash.java @@ -7,166 +7,170 @@ import neqsim.thermodynamicOperations.ThermodynamicOperations; /** - *

HydrateFlash class.

+ *

+ * HydrateFlash class. + *

* * @author asmund * @version $Id: $Id * @since 2.2.3 */ public class HydrateFlash { - static Logger logger = LogManager.getLogger(HydrateFlash.class); + static Logger logger = LogManager.getLogger(HydrateFlash.class); + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + // SystemInterface testSystem = new SystemSrkCPAstatoil(288.15, 10.450); + SystemInterface testSystem = new SystemSrkEos(273.15 + 10.5, 51.0); + // SystemInterface testSystem = new SystemUMRPRUEos(273.15 - 10.5, 5.0); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + // testSystem.addComponent("CO2", 1.5); + // testSystem.addComponent("H2S", 1.5); + // testSystem.addComponent("nitrogen", 0); + testSystem.addComponent("methane", 10.0); + // testSystem.addComponent("ethane", 3.0); + // testSystem.addComponent("propane", 1.0); + /* + * testSystem.addComponent("propane", 1.88); testSystem.addComponent("i-butane", 0.08); + * testSystem.addComponent("n-butane", 0.12); testSystem.addComponent("n-pentane", 1.64); + * testSystem.addComponent("n-heptane", 1.64); + */ - /** - *

main.

+ // testSystem.addComponent("MEG", 1); + + testSystem.addTBPfraction("C6", 3.29, 86.178 / 1000.0, 0.6640); + testSystem.addTBPfraction("C7", 2.22, 96.0 / 1000.0, 0.7380); + testSystem.addTBPfraction("C8", 0.32, 107.0 / 1000.0, 0.7650); + testSystem.addTBPfraction("C9", 0.177, 121.0 / 1000.0, 0.7810); + // testSystem.addTBPfraction("C10", 1.22, 184.0 / 1000.0, 0.81020); + // testSystem.addTBPfraction("C11", 4.93, 147.0 / 1000.0, 0.7960); + // testSystem.addTBPfraction("C12", 3.84, 161.0 / 1000.0, 0.8100); + // testSystem.addTBPfraction("C13", 2.74, 175.0 / 1000.0, 0.8250); + testSystem.addTBPfraction("C14", 2.19, 290.0 / 1000.0, 0.8360); + + // testSystem.addTBPfraction("C15", 3.0, 291.0 / 1000.0, 0.85790282291); + // testSystem.addTBPfraction("C15", 2.64, 206.0 / 1000.0, 0.8420); + + // testSystem.addComponent("TEG", 0.5); + + // testSystem.addComponent("CO2", 1.5); + // testSystem.addComponent("MEG", 8.3); + + // testSystem.addComponent("NaCl", 12.4); + // testSystem.addComponent("Na+", 6.2); + // testSystem.addComponent("Cl-", 6.2); + // testSystem.addComponent("MEG", 1.517); + // testSystem.setSolidPhaseCheck("TEG"); + // testSystem.setSolidPhaseCheck("MEG"); + // testSystem.addSolidComplexPhase("MEG"); + // testSystem.addSolidComplexPhase("wax"); + testSystem.setHeavyTBPfractionAsPlusFraction(); + + testSystem.getCharacterization().getLumpingModel().setNumberOfLumpedComponents(8); + testSystem.getCharacterization().characterisePlusFraction(); + + // testSystem.addComponent("MEG", 1.015); + testSystem.addComponent("water", 10.015); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + // testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); + testSystem.setHydrateCheck(true); + // testSystem.setMultiPhaseCheck(true); + testSystem.init(0); + // testSystem = testSystem.autoSelectModel(); + testOps = new ThermodynamicOperations(testSystem); + // testSystem.setSolidPhaseCheck("water"); + + try { + // testOps.TPflash(); + testOps.hydrateFormationTemperature(); + // testOps.calcTOLHydrateFormationTemperature(); + // double[] temp = {288.15, 285.2, 283.5}; //, 277.3}; //, 285.15}; //, 284.0}; //, + // 283.5, 283.0}; //, 280.15}; // , 268.15, 288.0, 274.6, 274.2, 273.7, + // 273.15}; //, 297.8, 297.5}; + // double[] pres = {100.0, 100.0, 100.0, 100, 100, 100}; //, 100, 100, + // 100,100,100}; + // testOps.calcImobilePhaseHydrateTemperature(temp, pres); + // testOps.dewPointTemperatureFlash(); + // testSystem.init(0); + // testSystem.setHydrateCheck(true); + // testSystem.setMultiPhaseCheck(true); + // System.out.println("temperature1 " + (testSystem.getTemperature() - 273.15)); + // testOps.setRunAsThread(true); + + // // testSystem.setSolidPhaseCheck("water"); + // testOps.freezingPointTemperatureFlash(); + // testSystem.setSolidPhaseCheck(false); + // testSystem.setHydrateCheck(false); + // testSystem.init(0); + for (int i = 0; i < 1; i++) { + // testOps.hydrateFormationTemperature(); + } + // testOps.TPflash(); + // System.out.println("temperature2 " + (testSystem.getTemperature() - 273.15)); + // boolean isFinished = testOps.waitAndCheckForFinishedCalculation(1000000); + // System.out.println("finished? " + isFinished); + + // testOps.freezingPointTemperatureFlash(); + // testOps.calcSolidComlexTemperature(); + // testOps.TPflash(); + // testOps.calcWAT(); + // testOps.TPSolidflash(); + // testOps.dewPointTemperatureFlash(); + // testOps.waterDewPointTemperatureFlash(); + // testOps.hydrateFormationTemperature(0); + + // testOps.TPflash(); + // testOps.dewPointTemperatureFlash(); + // testOps.freezingPointTemperatureFlash(); + // testOps.bubblePointPressureFlash(false); + // testOps.hydrateFormationTemperature(1); + // testOps.waterPrecipitationTemperature(); + } catch (Exception e) { + logger.error(e.toString(), e); + } + testSystem.display(); + // System.out.println("temperature " + (testSystem.getTemperature() - 273.15)); + // System.out.println("activity coef water " + + // testSystem.getPhase(1).getActivityCoefficientSymetric(testSystem.getPhase(1).getComponent("water").getComponentNumber())); + + // System.out.println("wt% TEG " + 100 * + // testSystem.getPhase(1).getComponent("TEG").getx() * + // testSystem.getPhase(1).getComponent("TEG").getMolarMass() / + // (testSystem.getPhase(1).getComponent("TEG").getx() * + // testSystem.getPhase(1).getComponent("TEG").getMolarMass() + + // testSystem.getPhase(1).getComponent("water").getx() * + // testSystem.getPhase(1).getComponent("water").getMolarMass())); + // testSystem.display(); + // System.out.println("kg vann/MSm^3 gas " + + // (testSystem.getPhase(0).getComponent("water").getx() * + // testSystem.getPhase(0).getComponent("water").getMolarMass() * 101325.0 / + // 8.314 / 288.15) * 1.0e6); + // System.out.println("activity coef water " + + // testSystem.getPhase(1).getActivityCoefficientSymetric(1)); + // int n = testSystem.getNumberOfPhases()-1; + // double megwtfrac = + // testSystem.getPhase(n).getComponent("MEG").getMolarMass()*testSystem.getPhase(n).getComponent("MEG").getx()/testSystem.getPhase(n).getMolarMass(); + // System.out.println("wt % MEG " + megwtfrac*100); + /* + * SystemInterface testSystem2 = new SystemSrkCPAstatoil(273.0 - 12, 60.0); + * testSystem2.addComponent("methane", 1.0 - + * testSystem.getPhase(0).getComponent("water").getx()); testSystem2.addComponent("water", + * testSystem.getPhase(0).getComponent("water").getx()); testSystem2.createDatabase(true); + * + * testSystem2.setMixingRule(7); testSystem2.init(0); testSystem2.init(1); + * ThermodynamicOperations testOps2 = new ThermodynamicOperations(testSystem2); try { + * testOps2.waterDewPointTemperatureFlash(); + * + * } catch (Exception e) { e.printStackTrace(); System.out.println(e.toString()); } + * testSystem2.display(); * - * @param args an array of {@link java.lang.String} objects */ - public static void main(String args[]) { - // SystemInterface testSystem = new SystemSrkCPAstatoil(288.15, 10.450); - SystemInterface testSystem = new SystemSrkEos(273.15 + 10.5, 51.0); - // SystemInterface testSystem = new SystemUMRPRUEos(273.15 - 10.5, 5.0); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - // testSystem.addComponent("CO2", 1.5); - // testSystem.addComponent("H2S", 1.5); - // testSystem.addComponent("nitrogen", 0); - testSystem.addComponent("methane", 10.0); - // testSystem.addComponent("ethane", 3.0); - // testSystem.addComponent("propane", 1.0); - /* - * testSystem.addComponent("propane", 1.88); testSystem.addComponent("i-butane", 0.08); - * testSystem.addComponent("n-butane", 0.12); testSystem.addComponent("n-pentane", 1.64); - * testSystem.addComponent("n-heptane", 1.64); - */ - - // testSystem.addComponent("MEG", 1); - - testSystem.addTBPfraction("C6", 3.29, 86.178 / 1000.0, 0.6640); - testSystem.addTBPfraction("C7", 2.22, 96.0 / 1000.0, 0.7380); - testSystem.addTBPfraction("C8", 0.32, 107.0 / 1000.0, 0.7650); - testSystem.addTBPfraction("C9", 0.177, 121.0 / 1000.0, 0.7810); - // testSystem.addTBPfraction("C10", 1.22, 184.0 / 1000.0, 0.81020); - // testSystem.addTBPfraction("C11", 4.93, 147.0 / 1000.0, 0.7960); - // testSystem.addTBPfraction("C12", 3.84, 161.0 / 1000.0, 0.8100); - // testSystem.addTBPfraction("C13", 2.74, 175.0 / 1000.0, 0.8250); - testSystem.addTBPfraction("C14", 2.19, 290.0 / 1000.0, 0.8360); - - // testSystem.addTBPfraction("C15", 3.0, 291.0 / 1000.0, 0.85790282291); - // testSystem.addTBPfraction("C15", 2.64, 206.0 / 1000.0, 0.8420); - - // testSystem.addComponent("TEG", 0.5); - - // testSystem.addComponent("CO2", 1.5); - // testSystem.addComponent("MEG", 8.3); - - // testSystem.addComponent("NaCl", 12.4); - // testSystem.addComponent("Na+", 6.2); - // testSystem.addComponent("Cl-", 6.2); - // testSystem.addComponent("MEG", 1.517); - // testSystem.setSolidPhaseCheck("TEG"); - // testSystem.setSolidPhaseCheck("MEG"); - // testSystem.addSolidComplexPhase("MEG"); - // testSystem.addSolidComplexPhase("wax"); - testSystem.setHeavyTBPfractionAsPlusFraction(); - - testSystem.getCharacterization().getLumpingModel().setNumberOfLumpedComponents(8); - testSystem.getCharacterization().characterisePlusFraction(); - - // testSystem.addComponent("MEG", 1.015); - testSystem.addComponent("water", 10.015); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - // testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); - testSystem.setHydrateCheck(true); - // testSystem.setMultiPhaseCheck(true); - testSystem.init(0); - // testSystem = testSystem.autoSelectModel(); - testOps = new ThermodynamicOperations(testSystem); - // testSystem.setSolidPhaseCheck("water"); - - try { - // testOps.TPflash(); - testOps.hydrateFormationTemperature(); - // testOps.calcTOLHydrateFormationTemperature(); - // double[] temp = {288.15, 285.2, 283.5};//, 277.3};//, 285.15};//, 284.0};//, - // 283.5, 283.0};//, 280.15};// , 268.15, 288.0, 274.6, 274.2, 273.7, - // 273.15};//, 297.8, 297.5}; - // double[] pres = {100.0, 100.0, 100.0, 100, 100, 100};//, 100, 100, - // 100,100,100}; - // testOps.calcImobilePhaseHydrateTemperature(temp, pres); - // testOps.dewPointTemperatureFlash(); - // testSystem.init(0); - // testSystem.setHydrateCheck(true); - // testSystem.setMultiPhaseCheck(true); - // System.out.println("temperature1 " + (testSystem.getTemperature() - 273.15)); - // testOps.setRunAsThread(true); - - // // testSystem.setSolidPhaseCheck("water"); - // testOps.freezingPointTemperatureFlash(); - // testSystem.setSolidPhaseCheck(false); - // testSystem.setHydrateCheck(false); - // testSystem.init(0); - for (int i = 0; i < 1; i++) { - // testOps.hydrateFormationTemperature(); - } - // testOps.TPflash(); - // System.out.println("temperature2 " + (testSystem.getTemperature() - 273.15)); - // boolean isFinished = testOps.waitAndCheckForFinishedCalculation(1000000); - // System.out.println("finished? " + isFinished); - - // testOps.freezingPointTemperatureFlash(); - // testOps.calcSolidComlexTemperature(); - // testOps.TPflash(); - // testOps.calcWAT(); - // testOps.TPSolidflash(); - // testOps.dewPointTemperatureFlash(); - // testOps.waterDewPointTemperatureFlash(); - // testOps.hydrateFormationTemperature(0); - - // testOps.TPflash(); - // testOps.dewPointTemperatureFlash(); - // testOps.freezingPointTemperatureFlash(); - // testOps.bubblePointPressureFlash(false); - // testOps.hydrateFormationTemperature(1); - // testOps.waterPrecipitationTemperature(); - } catch (Exception e) { - logger.error(e.toString(), e); - } - testSystem.display(); - // System.out.println("temperature " + (testSystem.getTemperature() - 273.15)); - // System.out.println("activity coef water " + - // testSystem.getPhase(1).getActivityCoefficientSymetric(testSystem.getPhase(1).getComponent("water").getComponentNumber())); - - // System.out.println("wt% TEG " + 100 * - // testSystem.getPhase(1).getComponent("TEG").getx() * - // testSystem.getPhase(1).getComponent("TEG").getMolarMass() / - // (testSystem.getPhase(1).getComponent("TEG").getx() * - // testSystem.getPhase(1).getComponent("TEG").getMolarMass() + - // testSystem.getPhase(1).getComponent("water").getx() * - // testSystem.getPhase(1).getComponent("water").getMolarMass())); - // testSystem.display(); - // System.out.println("kg vann/MSm^3 gas " + - // (testSystem.getPhase(0).getComponent("water").getx() * - // testSystem.getPhase(0).getComponent("water").getMolarMass() * 101325.0 / - // 8.314 / 288.15) * 1.0e6); - // System.out.println("activity coef water " + - // testSystem.getPhase(1).getActivityCoefficientSymetric(1)); - // int n = testSystem.getNumberOfPhases()-1; - // double megwtfrac = - // testSystem.getPhase(n).getComponent("MEG").getMolarMass()*testSystem.getPhase(n).getComponent("MEG").getx()/testSystem.getPhase(n).getMolarMass(); - // System.out.println("wt % MEG " + megwtfrac*100); - /* - * SystemInterface testSystem2 = new SystemSrkCPAstatoil(273.0 - 12, 60.0); - * testSystem2.addComponent("methane", 1.0 - - * testSystem.getPhase(0).getComponent("water").getx()); testSystem2.addComponent("water", - * testSystem.getPhase(0).getComponent("water").getx()); testSystem2.createDatabase(true); - * - * testSystem2.setMixingRule(7); testSystem2.init(0); testSystem2.init(1); - * ThermodynamicOperations testOps2 = new ThermodynamicOperations(testSystem2); try { - * testOps2.waterDewPointTemperatureFlash(); - * - * } catch (Exception e) { e.printStackTrace(); System.out.println(e.toString()); } - * testSystem2.display(); - * - */ - } + } } diff --git a/src/test/java/neqsim/thermo/util/example/PhaseEnvelope.java b/src/test/java/neqsim/thermo/util/example/PhaseEnvelope.java index a7bb6ccb01..f9e4888d12 100644 --- a/src/test/java/neqsim/thermo/util/example/PhaseEnvelope.java +++ b/src/test/java/neqsim/thermo/util/example/PhaseEnvelope.java @@ -18,138 +18,137 @@ * @version $Id: $Id */ public class PhaseEnvelope { - static Logger logger = LogManager.getLogger(PhaseEnvelope.class); - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - @SuppressWarnings("unused") - public static void main(String args[]) { - // SystemInterface testSystem = new SystemUMRPRUEos(225.65, 1.00); - // SystemInterface testSystem = new SystemPrEos1978(223.15,50.00); - // SystemInterface testSystem = new SystemPrGassemEos(253.15,50.00); - SystemInterface testSystem = new SystemUMRPRUMCEos(280.0, 41.00); - // SystemInterface testSystem = new SystemPrDanesh(273.15+80.0,100.00); - // SystemInterface testSystem = new SystemPrEosDelft1998(223.15,50.00); - - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - - testSystem.addComponent("nitrogen", 1.1427); - testSystem.addComponent("CO2", 0.5364); - testSystem.addComponent("methane", 95.2399); - testSystem.addComponent("ethane", 2.2126); - testSystem.addComponent("propane", 0.3236); - testSystem.addComponent("i-butane", 0.1342); - testSystem.addComponent("n-butane", 0.0812); - // testSystem.addComponent("22-dim-C3", 1.7977); - testSystem.addComponent("i-pentane", 0.0684); - testSystem.addComponent("n-pentane", 0.0344); - // testSystem.addComponent("c-C5", 0.0112); - // testSystem.addComponent("22-dim-C4", 0.0022); - /// testSystem.addComponent("23-dim-C4", 0.0027); - testSystem.addComponent("2-m-C5", 0.0341); - testSystem.addComponent("3-m-C5", 0.0105); - testSystem.addComponent("n-hexane", 0.0172); - testSystem.addComponent("c-hexane", 0.0701); - testSystem.addComponent("benzene", 0.0016); - testSystem.addComponent("n-heptane", 0.0124); - testSystem.addComponent("toluene", 0.0042); - testSystem.addComponent("c-C7", 0.0504); - testSystem.addComponent("n-octane", 0.0037); - testSystem.addComponent("m-Xylene", 0.0032); - testSystem.addComponent("c-C8", 0.0095); - testSystem.addComponent("n-nonane", 0.0033); - // testSystem.addTBPfraction("C10", 0.0053, 134.0/1000.0, 0.79); - // testSystem.addTBPfraction("C11", 0.0004, 147.0/1000.0, 0.8); - - testSystem.addComponent("nC10", 0.0058); - testSystem.addComponent("nC11", 0.0005); - // testSystem.addComponent("nC12", 0.0004); - - // testSystem.addComponent("m-Xylene", 0.0000000000); - - // testSystem.addComponent("nC10", 1e-4); - - // testSystem.addComponent("n-octane", 0.027); - // testSystem.addComponent("nC13", .3); - // testSystem.addTBPfraction("C6", 1.587, 86.178 / 1000.0, 0.70255); - // testSystem.addTBPfraction("C7", 2.566, 91.5 / 1000.0, 0.738); - // testSystem.addTBPfraction("C8", 2.764, 101.2 / 1000.0, 0.765); - // testSystem.addTBPfraction("C9", 1.71, 119.1 / 1000.0, 0.781); - // testSystem.addTBPfraction("C10", 1.647, 254.9 / 1000.0, 0.894871); - - // testSystem.addComponent("water", 100.2); - // testSystem.addPlusFraction("C11", 0.01, 256.2 / 1000.0, 0.92787278398); - // testSystem.getCharacterization(). - - // testSystem.getCharacterization().getLumpingModel().setNumberOfLumpedComponents(12); - // testSystem.getCharacterization().characterisePlusFraction(); - - // testSystem.createDatabase(true); - - testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); - // testSystem.setMultiPhaseCheck(true); - // 1- orginal no interaction 2- classic w interaction - // 3- Huron-Vidal 4- Wong-Sandler - // testSystem.setMixingRule(2);//"UNIFAC_UMRPRU"); - // testSystem.setHydrateCheck(true); - // testSystem.setBmixType(0); - - // Calculates the phase envelope for the mixture - // testOps.calcPTphaseEnvelope(true); - - // Calculates the phase envelope for pashe fraction x and 1-x - // calcPTphaseEnvelope(minimum pressure, phase fraction); - try { - /* - * testOps.setRunAsThread(true); testOps.waterDewPointLine(10, 200); boolean isFinished - * = testOps.waitAndCheckForFinishedCalculation(50000); double[][] waterData = - * testOps.getData(); - * - * testOps.hydrateEquilibriumLine(10, 200); isFinished = - * testOps.waitAndCheckForFinishedCalculation(50000); double[][] hydData = - * testOps.getData(); - * - * testSystem.addComponent("water", - * -testSystem.getPhase(0).getComponent("water").getNumberOfmoles()); - */ - // testOps.calcPTphaseEnvelope();//true); - // testOps.displayResult(); - // logger.info("Cricondenbar " + testOps.get("cricondenbar")[0] + " " + - // testOps.get("cricondenbar")[1]); - // logger.info("Cricondentherm " + testOps.get("cricondentherm")[0] + " " + - // testOps.get("cricondentherm")[1]); - // isFinished = testOps.waitAndCheckForFinishedCalculation(10000); - // testOps.addData("water", waterData); - // testOps.addData("hydrate", hydData); - // testOps.calcPTphaseEnvelopeNew(); - // testOps.displayResult(); - - testSystem.setTemperature(273.15 - 0.0); - testSystem.setPressure(50.0); - SimulationInterface satPresSim = new SaturationPressure(testSystem); - satPresSim.run(); - satPresSim.getThermoSystem().display(); - // testOps.getJfreeChart(); - // testOps.dewPointPressureFlash(); - // testOps.bubblePointTemperatureFlash(); - // JFreeChart jfreeObj = testOps.getJfreeChart(); - // BufferedImage buf = jfreeObj.createBufferedImage(640, 400, null); - } catch (Exception e) { - logger.error("error", e); - } - - // testSystem.display(); - // testOps.get("DewT"); - // thermo.ThermodynamicModelTest testModel = new - // thermo.ThermodynamicModelTest(testSystem); - // testModel.runTest(); - - // System.out.println("tempeerature " + (testSystem.getTemperature() - 273.15)); - // testOps.displayResult(); + static Logger logger = LogManager.getLogger(PhaseEnvelope.class); + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String args[]) { + // SystemInterface testSystem = new SystemUMRPRUEos(225.65, 1.00); + // SystemInterface testSystem = new SystemPrEos1978(223.15,50.00); + // SystemInterface testSystem = new SystemPrGassemEos(253.15,50.00); + SystemInterface testSystem = new SystemUMRPRUMCEos(280.0, 41.00); + // SystemInterface testSystem = new SystemPrDanesh(273.15+80.0,100.00); + // SystemInterface testSystem = new SystemPrEosDelft1998(223.15,50.00); + + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + + testSystem.addComponent("nitrogen", 1.1427); + testSystem.addComponent("CO2", 0.5364); + testSystem.addComponent("methane", 95.2399); + testSystem.addComponent("ethane", 2.2126); + testSystem.addComponent("propane", 0.3236); + testSystem.addComponent("i-butane", 0.1342); + testSystem.addComponent("n-butane", 0.0812); + // testSystem.addComponent("22-dim-C3", 1.7977); + testSystem.addComponent("i-pentane", 0.0684); + testSystem.addComponent("n-pentane", 0.0344); + // testSystem.addComponent("c-C5", 0.0112); + // testSystem.addComponent("22-dim-C4", 0.0022); + /// testSystem.addComponent("23-dim-C4", 0.0027); + testSystem.addComponent("2-m-C5", 0.0341); + testSystem.addComponent("3-m-C5", 0.0105); + testSystem.addComponent("n-hexane", 0.0172); + testSystem.addComponent("c-hexane", 0.0701); + testSystem.addComponent("benzene", 0.0016); + testSystem.addComponent("n-heptane", 0.0124); + testSystem.addComponent("toluene", 0.0042); + testSystem.addComponent("c-C7", 0.0504); + testSystem.addComponent("n-octane", 0.0037); + testSystem.addComponent("m-Xylene", 0.0032); + testSystem.addComponent("c-C8", 0.0095); + testSystem.addComponent("n-nonane", 0.0033); + // testSystem.addTBPfraction("C10", 0.0053, 134.0/1000.0, 0.79); + // testSystem.addTBPfraction("C11", 0.0004, 147.0/1000.0, 0.8); + + testSystem.addComponent("nC10", 0.0058); + testSystem.addComponent("nC11", 0.0005); + // testSystem.addComponent("nC12", 0.0004); + + // testSystem.addComponent("m-Xylene", 0.0000000000); + + // testSystem.addComponent("nC10", 1e-4); + + // testSystem.addComponent("n-octane", 0.027); + // testSystem.addComponent("nC13", .3); + // testSystem.addTBPfraction("C6", 1.587, 86.178 / 1000.0, 0.70255); + // testSystem.addTBPfraction("C7", 2.566, 91.5 / 1000.0, 0.738); + // testSystem.addTBPfraction("C8", 2.764, 101.2 / 1000.0, 0.765); + // testSystem.addTBPfraction("C9", 1.71, 119.1 / 1000.0, 0.781); + // testSystem.addTBPfraction("C10", 1.647, 254.9 / 1000.0, 0.894871); + + // testSystem.addComponent("water", 100.2); + // testSystem.addPlusFraction("C11", 0.01, 256.2 / 1000.0, 0.92787278398); + // testSystem.getCharacterization(). + + // testSystem.getCharacterization().getLumpingModel().setNumberOfLumpedComponents(12); + // testSystem.getCharacterization().characterisePlusFraction(); + + // testSystem.createDatabase(true); + + testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); + // testSystem.setMultiPhaseCheck(true); + // 1- orginal no interaction 2- classic w interaction + // 3- Huron-Vidal 4- Wong-Sandler + // testSystem.setMixingRule(2); //"UNIFAC_UMRPRU"); + // testSystem.setHydrateCheck(true); + // testSystem.setBmixType(0); + + // Calculates the phase envelope for the mixture + // testOps.calcPTphaseEnvelope(true); + + // Calculates the phase envelope for pashe fraction x and 1-x + // calcPTphaseEnvelope(minimum pressure, phase fraction); + try { + /* + * testOps.setRunAsThread(true); testOps.waterDewPointLine(10, 200); boolean isFinished = + * testOps.waitAndCheckForFinishedCalculation(50000); double[][] waterData = + * testOps.getData(); + * + * testOps.hydrateEquilibriumLine(10, 200); isFinished = + * testOps.waitAndCheckForFinishedCalculation(50000); double[][] hydData = testOps.getData(); + * + * testSystem.addComponent("water", + * -testSystem.getPhase(0).getComponent("water").getNumberOfmoles()); + */ + // testOps.calcPTphaseEnvelope(); //true); + // testOps.displayResult(); + // logger.info("Cricondenbar " + testOps.get("cricondenbar")[0] + " " + + // testOps.get("cricondenbar")[1]); + // logger.info("Cricondentherm " + testOps.get("cricondentherm")[0] + " " + + // testOps.get("cricondentherm")[1]); + // isFinished = testOps.waitAndCheckForFinishedCalculation(10000); + // testOps.addData("water", waterData); + // testOps.addData("hydrate", hydData); + // testOps.calcPTphaseEnvelopeNew(); + // testOps.displayResult(); + + testSystem.setTemperature(273.15 - 0.0); + testSystem.setPressure(50.0); + SimulationInterface satPresSim = new SaturationPressure(testSystem); + satPresSim.run(); + satPresSim.getThermoSystem().display(); + // testOps.getJfreeChart(); + // testOps.dewPointPressureFlash(); + // testOps.bubblePointTemperatureFlash(); + // JFreeChart jfreeObj = testOps.getJfreeChart(); + // BufferedImage buf = jfreeObj.createBufferedImage(640, 400, null); + } catch (Exception e) { + logger.error("error", e); } + + // testSystem.display(); + // testOps.get("DewT"); + // thermo.ThermodynamicModelTest testModel = new + // thermo.ThermodynamicModelTest(testSystem); + // testModel.runTest(); + + // System.out.println("tempeerature " + (testSystem.getTemperature() - 273.15)); + // testOps.displayResult(); + } } diff --git a/src/test/java/neqsim/thermo/util/example/ReadFluidData.java b/src/test/java/neqsim/thermo/util/example/ReadFluidData.java index 3d17ec9235..5d76c57116 100644 --- a/src/test/java/neqsim/thermo/util/example/ReadFluidData.java +++ b/src/test/java/neqsim/thermo/util/example/ReadFluidData.java @@ -16,42 +16,42 @@ * @since 2.2.3 */ public class ReadFluidData { - static Logger logger = LogManager.getLogger(ReadFluidData.class); + static Logger logger = LogManager.getLogger(ReadFluidData.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - SystemInterface testSystem = new SystemSrkEos(273.15 + 25.0, 1.8);// - // testSystem.addComponent("nitrogen", 12.681146444); - testSystem.addComponent("methane", 90.681146444); - testSystem.addComponent("CO2", 12.185242497); - testSystem.addComponent("n-hexane", 100.681146444); - // testSystem.addComponent("water", 78.0590685); - testSystem.createDatabase(true); - // testSystem.init(0); - // testSystem.init(1); - testSystem.setMixingRule(2); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + SystemInterface testSystem = new SystemSrkEos(273.15 + 25.0, 1.8); + // testSystem.addComponent("nitrogen", 12.681146444); + testSystem.addComponent("methane", 90.681146444); + testSystem.addComponent("CO2", 12.185242497); + testSystem.addComponent("n-hexane", 100.681146444); + // testSystem.addComponent("water", 78.0590685); + testSystem.createDatabase(true); + // testSystem.init(0); + // testSystem.init(1); + testSystem.setMixingRule(2); - // testSystem.saveFluid(55); - // testSystem.readFluid("AsgardB"); - // testSystem = testSystem.readObject(55); - // testSystem.setMultiPhaseCheck(true); - // testSystem.getCharacterization().characterisePlusFraction(); + // testSystem.saveFluid(55); + // testSystem.readFluid("AsgardB"); + // testSystem = testSystem.readObject(55); + // testSystem.setMultiPhaseCheck(true); + // testSystem.getCharacterization().characterisePlusFraction(); - // testSystem.createDatabase(true); - // testSystem.setMixingRule(2); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + // testSystem.createDatabase(true); + // testSystem.setMixingRule(2); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - try { - testOps.calcPTphaseEnvelope(true); - testOps.displayResult(); - } catch (Exception e) { - logger.error(e.toString()); - } + try { + testOps.calcPTphaseEnvelope(true); + testOps.displayResult(); + } catch (Exception e) { + logger.error(e.toString()); } + } } diff --git a/src/test/java/neqsim/thermo/util/example/ScalePotentialCheck.java b/src/test/java/neqsim/thermo/util/example/ScalePotentialCheck.java index 6c8a75c2ba..38e9be4c92 100644 --- a/src/test/java/neqsim/thermo/util/example/ScalePotentialCheck.java +++ b/src/test/java/neqsim/thermo/util/example/ScalePotentialCheck.java @@ -49,13 +49,13 @@ public static void main(String[] args) { // testSystem.addComponent("MEG", 0.1); // testSystem.addComponent("MDEA", 1); testSystem.addComponent("water", 1, "kg/sec"); - // testSystem.addComponent("Mg++", 0.07);// * 24.31); + // testSystem.addComponent("Mg++", 0.07); // * 24.31); testSystem.addComponent("Na+", 4e-5); testSystem.addComponent("Cl-", 4e-5); // testSystem.addComponent("Hg++", 4e-7); testSystem.addComponent("OH-", 220e-5); testSystem.addComponent("Fe++", 110.1e-5); - // testSystem.addComponent("OH-", 0.07*2);// * 17.001); + // testSystem.addComponent("OH-", 0.07*2); // * 17.001); // testSystem.addComponent("Cl-", (1000 - 100) * 1e-3); // testSystem.addComponent("Ca++",0.002); // testSystem.addComponent("CO3--",14.0E-6); diff --git a/src/test/java/neqsim/thermo/util/example/TPflash2.java b/src/test/java/neqsim/thermo/util/example/TPflash2.java index a6aeb4e4cc..d593ecfd47 100644 --- a/src/test/java/neqsim/thermo/util/example/TPflash2.java +++ b/src/test/java/neqsim/thermo/util/example/TPflash2.java @@ -7,48 +7,52 @@ import neqsim.thermodynamicOperations.ThermodynamicOperations; /** - *

TPflash2 class.

+ *

+ * TPflash2 class. + *

* * @author esol * @version $Id: $Id * @since 2.2.3 */ public class TPflash2 { - static Logger logger = LogManager.getLogger(TPflash2.class); + static Logger logger = LogManager.getLogger(TPflash2.class); - /** - *

main.

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 80.0, 1.01325);// - testSystem.addComponent("nitrogen", 8.71604938); - // testSystem.addComponent("oxygen", 22.71604938); - testSystem.addComponent("water", 110.234567901); - testSystem.createDatabase(true); - testSystem.setMixingRule(10); - // testSystem.setMultiPhaseCheck(true); - SystemInterface testSystem2 = new SystemSrkCPAstatoil(273.15 + 80.0, 1.01325); - testSystem2.addComponent("nitrogen", 8.71604938); - // testSystem.addComponent("oxygen", 22.71604938); - testSystem2.addComponent("MEG", 110.234567901); - testSystem2.createDatabase(true); - testSystem2.setMixingRule(10); - testSystem.addFluid(testSystem2); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 80.0, 1.01325); + testSystem.addComponent("nitrogen", 8.71604938); + // testSystem.addComponent("oxygen", 22.71604938); + testSystem.addComponent("water", 110.234567901); + testSystem.createDatabase(true); + testSystem.setMixingRule(10); + // testSystem.setMultiPhaseCheck(true); + SystemInterface testSystem2 = new SystemSrkCPAstatoil(273.15 + 80.0, 1.01325); + testSystem2.addComponent("nitrogen", 8.71604938); + // testSystem.addComponent("oxygen", 22.71604938); + testSystem2.addComponent("MEG", 110.234567901); + testSystem2.createDatabase(true); + testSystem2.setMixingRule(10); + testSystem.addFluid(testSystem2); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - // testOps.TPflash(); + // testOps.TPflash(); - try { - testOps.TPflash(); - // testOps.waterDewPointTemperatureMultiphaseFlash(); - } catch (Exception e) { - logger.error("error", e); - } - // testSystem.init(0); - // testSystem.init(1); - - testSystem.display(); + try { + testOps.TPflash(); + // testOps.waterDewPointTemperatureMultiphaseFlash(); + } catch (Exception e) { + logger.error("error", e); } + // testSystem.init(0); + // testSystem.init(1); + + testSystem.display(); + } } diff --git a/src/test/java/neqsim/thermo/util/example/TPflashDehyd.java b/src/test/java/neqsim/thermo/util/example/TPflashDehyd.java index 0b7265e11e..5397233f08 100644 --- a/src/test/java/neqsim/thermo/util/example/TPflashDehyd.java +++ b/src/test/java/neqsim/thermo/util/example/TPflashDehyd.java @@ -17,197 +17,193 @@ * @since 2.2.3 */ public class TPflashDehyd { - static Logger logger = LogManager.getLogger(TPflashDehyd.class); + static Logger logger = LogManager.getLogger(TPflashDehyd.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - // SystemInterface testSystem = new SystemSrkEos(288.15 + 5, 165.01325);// - SystemInterface testSystem2 = new SystemSrkEos(298, 10);// - testSystem2 = testSystem2.readObject(30); - // testSystem2.addComponent("methane", 1.0, "kg/sec"); - // testSystem2.addComponent("ethane", 0.1, "kg/sec"); - // testSystem2.addComponent("water", 30.0e-6, "kg/sec"); - // testSystem2.addComponent("MEG", 30.0e-16, "kg/sec"); - testSystem2.createDatabase(true); - testSystem2.setMixingRule(10); - testSystem2.init(0); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + // SystemInterface testSystem = new SystemSrkEos(288.15 + 5, 165.01325); + SystemInterface testSystem2 = new SystemSrkEos(298, 10); // + testSystem2 = testSystem2.readObject(30); + // testSystem2.addComponent("methane", 1.0, "kg/sec"); + // testSystem2.addComponent("ethane", 0.1, "kg/sec"); + // testSystem2.addComponent("water", 30.0e-6, "kg/sec"); + // testSystem2.addComponent("MEG", 30.0e-16, "kg/sec"); + testSystem2.createDatabase(true); + testSystem2.setMixingRule(10); + testSystem2.init(0); - SystemInterface testSystem = new SystemSrkCPAstatoil(298, 10); - // testSystem.addComponent("methane", 1.0e-10, "kg/sec"); - testSystem = testSystem.readObject(37); - testSystem.addComponent("water", 0.5, "kg/sec"); - testSystem.addComponent("MEG", 9.5, "kg/sec"); - testSystem.createDatabase(true); - testSystem.setMixingRule(10); - testSystem.setMultiPhaseCheck(true); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + SystemInterface testSystem = new SystemSrkCPAstatoil(298, 10); + // testSystem.addComponent("methane", 1.0e-10, "kg/sec"); + testSystem = testSystem.readObject(37); + testSystem.addComponent("water", 0.5, "kg/sec"); + testSystem.addComponent("MEG", 9.5, "kg/sec"); + testSystem.createDatabase(true); + testSystem.setMixingRule(10); + testSystem.setMultiPhaseCheck(true); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - for (int i = 0; i < 24; i++) { - testSystem2.setTotalFlowRate(0.1 * 3600, "MSm3/day"); - testSystem2.init(1); - testSystem.addFluid(testSystem2); - testOps.TPflash(); - // testSystem.display(); - logger.info("ppm water" + testSystem.getPhase(0).getComponent("water").getx() * 1e6); - testSystem = testSystem.phaseToSystem(1); - testOps = new ThermodynamicOperations(testSystem); - logger.info("nuber of moles " + testSystem.getNumberOfMoles() + " moleFrac MEG " - + testSystem.getPhase(0).getComponent("MEG").getx()); - } - - // testSystem.display(); - // testSystem.display(); - // testSystem.init(3); - // thermo.ThermodynamicModelTest testModel = new - // thermo.ThermodynamicModelTest(testSystem); - // testModel.runTest(); - // testSystem.display(); - // System.out.println("water activity " + - // testSystem.getPhase(1).getActivityCoefficient(2)); - // testSystem.init(0); - // testSystem.setPhaseType(0, 1); - // testSystem.init(1); - /* - * testSystem.init(2); - * - * // testSystem.init(1); // testSystem.init(2); // testSystem.init(3); // - * System.out.println("heat cap " + (testSystem.getPhase(1).getCp())); // - * testOps.calcPTphaseEnvelope(); testSystem.display(); // testSystem.getPhase(0).getCp(); } - * catch (Exception e) { System.out.println(e.toString()); } - * - * /* System.out.println("gas density " + (testSystem.getPhase(0).getDensity())); - * System.out.println("gas density " + (1.0 / (testSystem.getPhase(0).getDensity() / - * testSystem.getPhase(0).getMolarMass()))); - * - * System.out.println("liq density " + (testSystem.getPhase(1).getDensity())); - * System.out.println("liq density " + (1.0 / (testSystem.getPhase(1).getDensity() / - * testSystem.getPhase(1).getMolarMass()))); - * - * testSystem.initPhysicalProperties(); testSystem.init(1); - * - * System.out.println("start....."); testSystem.removeMoles(); - * testSystem.setMolarComposition(new double[]{1.0, 1e-20, 1e-20}); testSystem.init(0, 0); - * testSystem.init(1); testSystem.display(); - * - * System.out.println("end....."); testSystem.setMolarComposition(new double[]{0.000001, - * 0.00001, 1e-20}); // testSystem.init(1); testSystem.init(0, 0); testSystem.init(1); // - * testSystem.display(); - * - * /* testSystem.initPhysicalProperties(); double rho1 = - * testSystem.getPhase(0).getPhysicalProperties().getDensity(); System.out.println("drhodP " - * + testSystem.getPhase(0).getdrhodP()); System.out.println("drhodT " + - * testSystem.getPhase(0).getdrhodP()); - * testSystem.setPressure(testSystem.getPressure()+0.01); - * testSystem.setPressure(testSystem.getPressure() + 0.001); testSystem.init(1); // - * testSystem.display(); // testSystem.initPhysicalProperties(); double rho2 = - * testSystem.getPhase(0).getPhysicalProperties().getDensity(); - * - * //System.out.println("drhodPnum " + (rho2 - rho1) / 0.01); - * System.out.println("drhodTnum " + (rho2 - rho1) / 0.001); - * - * testSystem.saveFluid(2327); testSystem.saveFluid(2301); // - * testSystem.setNumberOfPhases(1); // testSystem.setTemperature(299.0); // - * testSystem.init(1); // testSystem.getPhase(0).getEntropy(); // - * System.out.println("enthalpy " + testSystem.getPhase(0).getEntropy()); - * //testSystem.setTemperature(299.0); testSystem.init(1); - * System.out.println("water activity " + testSystem.getPhase(1).getActivityCoefficient(1)); - * // testSystem.getPhase(0).getEntropydP(); System.out.println("Cp " + - * testSystem.getPhase(0).getCp()); System.out.println("enthalpy " + - * testSystem.getPhase(0).getEnthalpy()); System.out.println("entropy " + - * testSystem.getPhase(0).getEntropy()); - * - * - * testSystem.init(2); System.out.println("Cp " + testSystem.getPhase(0).getCp()); - * System.out.println("enthalpy " + testSystem.getPhase(0).getEnthalpy()); - * System.out.println("entropy " + testSystem.getPhase(0).getEntropy()); testSystem.init(3); - * System.out.println("Cp " + testSystem.getPhase(0).getCp()); - * System.out.println("enthalpy " + testSystem.getPhase(0).getEnthalpy()); - * System.out.println("entropy " + testSystem.getPhase(0).getEntropy()); // - * testSystem.setPhysicalPropertyModel(4); //testSystem.setSolidPhaseCheck("CO2");9 // - * testSystem.getInterphaseProperties().setInterfacialTensionModel(3); testOps = new - * ThermodynamicOperations(testSystem); try { // testOps.freezingPointTemperatureFlash(); - * testOps.TPflash(); // testOps.calcPTphaseEnvelope(); // testOps.display(); // - * testSystem.display(); } catch (Exception e) { System.out.println(e.toString()); } - * - * /* double h1 = testSystem.getPhase(0).getEntropy(); System.out.println("H " + - * testSystem.getPhase(0).getEntropy()); System.out.println("H dP " + - * testSystem.getPhase(0).getEntropydT()); - * testSystem.setTemperature(testSystem.getTemperature() + 1); testSystem.init(3); double h2 - * = testSystem.getPhase(0).getEntropy(); System.out.println("H " + - * testSystem.getPhase(0).getEntropy()); System.out.println("H dP " + - * testSystem.getPhase(0).getEntropydT()); - */ - // System.out.println("dhdp " + (h2 - h1)); - /* - * double seletivity = testSystem.getPhase(1).getComponent("CO2").getx() / - * testSystem.getPhase(0).getComponent("CO2").getx() / - * (testSystem.getPhase(1).getComponent("methane").getx() / - * testSystem.getPhase(0).getComponent("methane").getx()); - * System.out.println("selectivity CO2/methane " + seletivity); - * - * double seletivity2 = testSystem.getPhase(1).getComponent("CO2").getx() / - * testSystem.getPhase(0).getComponent("CO2").getx() / - * (testSystem.getPhase(1).getComponent("ethane").getx() / - * testSystem.getPhase(0).getComponent("ethane").getx()); - * System.out.println("selectivity CO2/ethane " + seletivity2); - */ - // testSystem.saveObject(2201); - // System.out.println("activity coef MDEA " + - // testSystem.getPhase(1).getActivityCoefficient(1)); - /* - * testSystem.saveObject(928); testSystem.display(); System.out.println("wt " + - * testSystem.getPhase(2).getWtFraction(testSystem) + - * testSystem.getPhase(1).getWtFraction(testSystem) + - * testSystem.getPhase(0).getWtFraction(testSystem)); - * - * double a = testSystem.getPhase(0).getBeta() * testSystem.getPhase(0).getMolarMass() / - * testSystem.getMolarMass(); double seletivity = - * testSystem.getPhase(1).getComponent("CO2").getx() / - * testSystem.getPhase(0).getComponent("CO2").getx() / - * (testSystem.getPhase(1).getComponent("methane").getx() / - * testSystem.getPhase(0).getComponent("methane").getx()); - * - * - * double solubility = testSystem.getPhase(1).getComponent("CO2").getx() * 8.314 * 298.15 / - * 101325.0 / (testSystem.getPhase(1).getMolarMass()) * 1000; - * - * System.out.println("selectivity " + seletivity); System.out.println("CO2 solubility " + - * solubility); System.out.println("Z " + testSystem.getPhase(0).getZ()); // - * testSystem.getPhase(0).getComponentWithIndex(1); // testSystem.saveObject(300); // - * System.out.println("ethanol activity " + - * testSystem.getPhase(0).getActivityCoefficient(0)); - * - * //testSystem. // System.out.println("water activity " + - * testSystem.getPhase(1).getActivityCoefficient(1)); // System.out.println("TEG activity " - * + testSystem.getPhase(1).getActivityCoefficient(0)); // testSystem.display(); - * //System.out.println("fugacitycoefficient " + - * testSystem.getPhase(1).getComponent("water").getLogFugacityCoefficient()); /* - * System.out.println("fugacitycoefficientdp " + - * testSystem.getPhase(0).getComponent("MEG").getdfugdp()); - * System.out.println("fugacitycoefficientdp " + - * testSystem.getPhase(0).getComponent("water").getdfugdp()); - * System.out.println("fugacitycoefficientdt " + - * testSystem.getPhase(0).getComponent("MEG").getdfugdt()); - * System.out.println("fugacitycoefficientdt " + - * testSystem.getPhase(0).getComponent("water").getdfugdt()); - * System.out.println("fugacitycoefficientdn " + - * testSystem.getPhase(0).getComponent("MEG").getdfugdn(1)); - * System.out.println("fugacitycoefficientdn " + - * testSystem.getPhase(0).getComponent("water").getdfugdn(0)); - * - * System.out.println("Hres " + testSystem.getPhase(0).getHresTP() / - * thermo.ThermodynamicConstantsInterface.R); System.out.println("Sres " + - * testSystem.getPhase(0).getSresTP() / thermo.ThermodynamicConstantsInterface.R); - * System.out.println("Cpres " + testSystem.getPhase(0).getCpres() / - * thermo.ThermodynamicConstantsInterface.R); System.out.println("Gibbs gas " + - * testSystem.getPhase(0).getGibbsEnergy()); System.out.println("Gibbs liquid " + - * testSystem.getPhase(1).getGibbsEnergy()); - */ + for (int i = 0; i < 24; i++) { + testSystem2.setTotalFlowRate(0.1 * 3600, "MSm3/day"); + testSystem2.init(1); + testSystem.addFluid(testSystem2); + testOps.TPflash(); + // testSystem.display(); + logger.info("ppm water" + testSystem.getPhase(0).getComponent("water").getx() * 1e6); + testSystem = testSystem.phaseToSystem(1); + testOps = new ThermodynamicOperations(testSystem); + logger.info("nuber of moles " + testSystem.getNumberOfMoles() + " moleFrac MEG " + + testSystem.getPhase(0).getComponent("MEG").getx()); } + + // testSystem.display(); + // testSystem.display(); + // testSystem.init(3); + // thermo.ThermodynamicModelTest testModel = new + // thermo.ThermodynamicModelTest(testSystem); + // testModel.runTest(); + // testSystem.display(); + // System.out.println("water activity " + + // testSystem.getPhase(1).getActivityCoefficient(2)); + // testSystem.init(0); + // testSystem.setPhaseType(0, 1); + // testSystem.init(1); + /* + * testSystem.init(2); + * + * // testSystem.init(1); // testSystem.init(2); // testSystem.init(3); // + * System.out.println("heat cap " + (testSystem.getPhase(1).getCp())); // + * testOps.calcPTphaseEnvelope(); testSystem.display(); // testSystem.getPhase(0).getCp(); } + * catch (Exception e) { System.out.println(e.toString()); } + * + * /* System.out.println("gas density " + (testSystem.getPhase(0).getDensity())); + * System.out.println("gas density " + (1.0 / (testSystem.getPhase(0).getDensity() / + * testSystem.getPhase(0).getMolarMass()))); + * + * System.out.println("liq density " + (testSystem.getPhase(1).getDensity())); + * System.out.println("liq density " + (1.0 / (testSystem.getPhase(1).getDensity() / + * testSystem.getPhase(1).getMolarMass()))); + * + * testSystem.initPhysicalProperties(); testSystem.init(1); + * + * System.out.println("start....."); testSystem.removeMoles(); + * testSystem.setMolarComposition(new double[]{1.0, 1e-20, 1e-20}); testSystem.init(0, 0); + * testSystem.init(1); testSystem.display(); + * + * System.out.println("end....."); testSystem.setMolarComposition(new double[]{0.000001, + * 0.00001, 1e-20}); // testSystem.init(1); testSystem.init(0, 0); testSystem.init(1); // + * testSystem.display(); + * + * /* testSystem.initPhysicalProperties(); double rho1 = + * testSystem.getPhase(0).getPhysicalProperties().getDensity(); System.out.println("drhodP " + + * testSystem.getPhase(0).getdrhodP()); System.out.println("drhodT " + + * testSystem.getPhase(0).getdrhodP()); testSystem.setPressure(testSystem.getPressure()+0.01); + * testSystem.setPressure(testSystem.getPressure() + 0.001); testSystem.init(1); // + * testSystem.display(); // testSystem.initPhysicalProperties(); double rho2 = + * testSystem.getPhase(0).getPhysicalProperties().getDensity(); + * + * //System.out.println("drhodPnum " + (rho2 - rho1) / 0.01); System.out.println("drhodTnum " + + * (rho2 - rho1) / 0.001); + * + * testSystem.saveFluid(2327); testSystem.saveFluid(2301); // testSystem.setNumberOfPhases(1); + * // testSystem.setTemperature(299.0); // testSystem.init(1); // + * testSystem.getPhase(0).getEntropy(); // System.out.println("enthalpy " + + * testSystem.getPhase(0).getEntropy()); //testSystem.setTemperature(299.0); testSystem.init(1); + * System.out.println("water activity " + testSystem.getPhase(1).getActivityCoefficient(1)); // + * testSystem.getPhase(0).getEntropydP(); System.out.println("Cp " + + * testSystem.getPhase(0).getCp()); System.out.println("enthalpy " + + * testSystem.getPhase(0).getEnthalpy()); System.out.println("entropy " + + * testSystem.getPhase(0).getEntropy()); + * + * + * testSystem.init(2); System.out.println("Cp " + testSystem.getPhase(0).getCp()); + * System.out.println("enthalpy " + testSystem.getPhase(0).getEnthalpy()); + * System.out.println("entropy " + testSystem.getPhase(0).getEntropy()); testSystem.init(3); + * System.out.println("Cp " + testSystem.getPhase(0).getCp()); System.out.println("enthalpy " + + * testSystem.getPhase(0).getEnthalpy()); System.out.println("entropy " + + * testSystem.getPhase(0).getEntropy()); // testSystem.setPhysicalPropertyModel(4); + * //testSystem.setSolidPhaseCheck("CO2");9 // + * testSystem.getInterphaseProperties().setInterfacialTensionModel(3); testOps = new + * ThermodynamicOperations(testSystem); try { // testOps.freezingPointTemperatureFlash(); + * testOps.TPflash(); // testOps.calcPTphaseEnvelope(); // testOps.display(); // + * testSystem.display(); } catch (Exception e) { System.out.println(e.toString()); } + * + * /* double h1 = testSystem.getPhase(0).getEntropy(); System.out.println("H " + + * testSystem.getPhase(0).getEntropy()); System.out.println("H dP " + + * testSystem.getPhase(0).getEntropydT()); testSystem.setTemperature(testSystem.getTemperature() + * + 1); testSystem.init(3); double h2 = testSystem.getPhase(0).getEntropy(); + * System.out.println("H " + testSystem.getPhase(0).getEntropy()); System.out.println("H dP " + + * testSystem.getPhase(0).getEntropydT()); + */ + // System.out.println("dhdp " + (h2 - h1)); + /* + * double seletivity = testSystem.getPhase(1).getComponent("CO2").getx() / + * testSystem.getPhase(0).getComponent("CO2").getx() / + * (testSystem.getPhase(1).getComponent("methane").getx() / + * testSystem.getPhase(0).getComponent("methane").getx()); + * System.out.println("selectivity CO2/methane " + seletivity); + * + * double seletivity2 = testSystem.getPhase(1).getComponent("CO2").getx() / + * testSystem.getPhase(0).getComponent("CO2").getx() / + * (testSystem.getPhase(1).getComponent("ethane").getx() / + * testSystem.getPhase(0).getComponent("ethane").getx()); + * System.out.println("selectivity CO2/ethane " + seletivity2); + */ + // testSystem.saveObject(2201); + // System.out.println("activity coef MDEA " + + // testSystem.getPhase(1).getActivityCoefficient(1)); + /* + * testSystem.saveObject(928); testSystem.display(); System.out.println("wt " + + * testSystem.getPhase(2).getWtFraction(testSystem) + + * testSystem.getPhase(1).getWtFraction(testSystem) + + * testSystem.getPhase(0).getWtFraction(testSystem)); + * + * double a = testSystem.getPhase(0).getBeta() * testSystem.getPhase(0).getMolarMass() / + * testSystem.getMolarMass(); double seletivity = + * testSystem.getPhase(1).getComponent("CO2").getx() / + * testSystem.getPhase(0).getComponent("CO2").getx() / + * (testSystem.getPhase(1).getComponent("methane").getx() / + * testSystem.getPhase(0).getComponent("methane").getx()); + * + * + * double solubility = testSystem.getPhase(1).getComponent("CO2").getx() * 8.314 * 298.15 / + * 101325.0 / (testSystem.getPhase(1).getMolarMass()) * 1000; + * + * System.out.println("selectivity " + seletivity); System.out.println("CO2 solubility " + + * solubility); System.out.println("Z " + testSystem.getPhase(0).getZ()); // + * testSystem.getPhase(0).getComponentWithIndex(1); // testSystem.saveObject(300); // + * System.out.println("ethanol activity " + testSystem.getPhase(0).getActivityCoefficient(0)); + * + * //testSystem. // System.out.println("water activity " + + * testSystem.getPhase(1).getActivityCoefficient(1)); // System.out.println("TEG activity " + + * testSystem.getPhase(1).getActivityCoefficient(0)); // testSystem.display(); + * //System.out.println("fugacitycoefficient " + + * testSystem.getPhase(1).getComponent("water").getLogFugacityCoefficient()); /* + * System.out.println("fugacitycoefficientdp " + + * testSystem.getPhase(0).getComponent("MEG").getdfugdp()); + * System.out.println("fugacitycoefficientdp " + + * testSystem.getPhase(0).getComponent("water").getdfugdp()); + * System.out.println("fugacitycoefficientdt " + + * testSystem.getPhase(0).getComponent("MEG").getdfugdt()); + * System.out.println("fugacitycoefficientdt " + + * testSystem.getPhase(0).getComponent("water").getdfugdt()); + * System.out.println("fugacitycoefficientdn " + + * testSystem.getPhase(0).getComponent("MEG").getdfugdn(1)); + * System.out.println("fugacitycoefficientdn " + + * testSystem.getPhase(0).getComponent("water").getdfugdn(0)); + * + * System.out.println("Hres " + testSystem.getPhase(0).getHresTP() / + * thermo.ThermodynamicConstantsInterface.R); System.out.println("Sres " + + * testSystem.getPhase(0).getSresTP() / thermo.ThermodynamicConstantsInterface.R); + * System.out.println("Cpres " + testSystem.getPhase(0).getCpres() / + * thermo.ThermodynamicConstantsInterface.R); System.out.println("Gibbs gas " + + * testSystem.getPhase(0).getGibbsEnergy()); System.out.println("Gibbs liquid " + + * testSystem.getPhase(1).getGibbsEnergy()); + */ + } } diff --git a/src/test/java/neqsim/thermo/util/example/TPflashGR.java b/src/test/java/neqsim/thermo/util/example/TPflashGR.java index 7e51b97130..c008be3c0d 100644 --- a/src/test/java/neqsim/thermo/util/example/TPflashGR.java +++ b/src/test/java/neqsim/thermo/util/example/TPflashGR.java @@ -16,95 +16,96 @@ * @since 2.2.3 */ public class TPflashGR { - static Logger logger = LogManager.getLogger(TPflashGR.class); + static Logger logger = LogManager.getLogger(TPflashGR.class); - /** - *

main.

- * - * @param args an array of {@link java.lang.String} objects - */ - @SuppressWarnings("unused") - public static void main(String[] args) { - // String[] components = new String[]{"water", "nitrogen", "CO2", "methane", - // "ethane", "propane", "i-butane","n-butane","i-pentane", "n-pentane", - // "CHCmp_1", "CHCmp_2", "CHCmp_3", "CHCmp_4" - // ,"CHCmp_5","CHCmp_6","CHCmp_7","CHCmp_8","CHCmp_9","CHCmp_10","CHCmp_11","CHCmp_12","CHCmp_13"}; - // double[] fractions1 = new double[] {0.0304006958007813, 4.73001127829775E-07, - // 0.000380391739308834, 0.00102935172617435, 0.00350199580192566, - // 0.0149815678596497, 0.00698469817638397 , 0.0226067280769348, - // 0.0143046414852142, 0.0203909373283386, 0.0352155113220215, - // 0.0705802822113037,0.0850765609741211,0.0605201292037964, 0.1793018150329590, - // 0.1033354282379150, 0.0706664896011353, - // 0.0626348257064819,0.0488108015060425,0.0484040451049805,0.0417061710357666,0.0425787830352783,0.0365876793861389 - // }; - // double[] molarmass = new double[] {0.0386243104934692, 1.08263303991407E-05, - // 0.00019008457660675, 0.00305547803640366, 0.00200786963105202, - // 0.00389420658349991,0.00179276615381241 , 0.00255768150091171, - // 0.00205287128686905, 0.00117853358387947 , - // 0.0854749984741211,0.0890039978027344,0.1021979980468750,0.1156969985961910,0.1513029937744140,0.2105240020751950,0.2728500061035160,0.3172810058593750,0.3585450134277340,0.4076000061035160,0.4698110046386720,0.5629600219726560, - // 0.7858560180664060 }; - // double[] density = new double[] {0.0386243104934692, 1.08263303991407E-05, - // 0.00019008457660675, 0.00305547803640366, 0.00200786963105202, - // 0.00389420658349991,0.00179276615381241 , 0.00255768150091171, - // 0.00205287128686905, 0.00117853358387947, - // 0.664700031280518,0.757499992847443,0.778400003910065,0.792500019073486,0.82480001449585,0.869700014591217,0.881599962711334,0.89300000667572,0.90200001001358,0.911700010299683, - // 0.923400044441223,0.939900040626526,0.979299962520599}; + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String[] args) { + // String[] components = new String[]{"water", "nitrogen", "CO2", "methane", + // "ethane", "propane", "i-butane","n-butane","i-pentane", "n-pentane", + // "CHCmp_1", "CHCmp_2", "CHCmp_3", "CHCmp_4" + // ,"CHCmp_5","CHCmp_6","CHCmp_7","CHCmp_8","CHCmp_9","CHCmp_10","CHCmp_11","CHCmp_12","CHCmp_13"}; + // double[] fractions1 = new double[] {0.0304006958007813, 4.73001127829775E-07, + // 0.000380391739308834, 0.00102935172617435, 0.00350199580192566, + // 0.0149815678596497, 0.00698469817638397 , 0.0226067280769348, + // 0.0143046414852142, 0.0203909373283386, 0.0352155113220215, + // 0.0705802822113037,0.0850765609741211,0.0605201292037964, 0.1793018150329590, + // 0.1033354282379150, 0.0706664896011353, + // 0.0626348257064819,0.0488108015060425,0.0484040451049805,0.0417061710357666,0.0425787830352783,0.0365876793861389 + // }; + // double[] molarmass = new double[] {0.0386243104934692, 1.08263303991407E-05, + // 0.00019008457660675, 0.00305547803640366, 0.00200786963105202, + // 0.00389420658349991,0.00179276615381241 , 0.00255768150091171, + // 0.00205287128686905, 0.00117853358387947 , + // 0.0854749984741211,0.0890039978027344,0.1021979980468750,0.1156969985961910,0.1513029937744140,0.2105240020751950,0.2728500061035160,0.3172810058593750,0.3585450134277340,0.4076000061035160,0.4698110046386720,0.5629600219726560, + // 0.7858560180664060 }; + // double[] density = new double[] {0.0386243104934692, 1.08263303991407E-05, + // 0.00019008457660675, 0.00305547803640366, 0.00200786963105202, + // 0.00389420658349991,0.00179276615381241 , 0.00255768150091171, + // 0.00205287128686905, 0.00117853358387947, + // 0.664700031280518,0.757499992847443,0.778400003910065,0.792500019073486,0.82480001449585,0.869700014591217,0.881599962711334,0.89300000667572,0.90200001001358,0.911700010299683, + // 0.923400044441223,0.939900040626526,0.979299962520599}; - String[] components = new String[] {"water", "nitrogen", "CO2", "methane", "ethane", - "propane", "i-butane", "n-butane", "i-pentane", "n-pentane", "C6", "C7", "C8", "C9", - "C10"};// ,"CHCmp_6","CHCmp_7","CHCmp_8"};//,"CHCmp_9","CHCmp_10","CHCmp_11","CHCmp_12","CHCmp_13"}; - double[] fractions1 = new double[] {0.691986417509639, 0.001518413245518, 0.004876419074493, - 0.177034951950947, 0.016102566295901, 0.008162056735947, 0.002489557955828, - 0.008657117478144, 0.006116331881632, 0.007300146475110, 0.008772462741648, - 0.012794973584387, 0.012834050157103, 0.007273111871068, - 0.014261799565032 + 0.010199184799741 + 0.005722681071876 + 0.003897757605989}; - double[] molarmass = new double[] {18.0153, 28.0135, 44.0098, 16.0429, 30.0698, 44.0968, - 58.1239, 58.1239, 72.1510, 72.1510, 86.1776 / 1000.0, 90.1140 / 1000.0, - 102.0386 / 1000.0, 117.4548 / 1000.0, 205.5306 / 1000.0}; - double[] density = new double[] {1.0, -1.0000e+19, -1.0000e+19, -1.0000e+19, -1.0000e+19, - -1.0000e+19, -1.0000e+19, -1.0000e+19, -1.0000e+19, -1.0000e+19, 667.4991 / 1000.0, - 746.5672 / 1000.0, 787.1960 / 1000.0, 776.5150 / 1000.0, 849.9863 / 1000.0,}; + String[] components = new String[] {"water", "nitrogen", "CO2", "methane", "ethane", "propane", + "i-butane", "n-butane", "i-pentane", "n-pentane", "C6", "C7", "C8", "C9", "C10"}; // ,"CHCmp_6","CHCmp_7","CHCmp_8"}; + // //,"CHCmp_9","CHCmp_10","CHCmp_11","CHCmp_12","CHCmp_13"}; + double[] fractions1 = new double[] {0.691986417509639, 0.001518413245518, 0.004876419074493, + 0.177034951950947, 0.016102566295901, 0.008162056735947, 0.002489557955828, + 0.008657117478144, 0.006116331881632, 0.007300146475110, 0.008772462741648, + 0.012794973584387, 0.012834050157103, 0.007273111871068, + 0.014261799565032 + 0.010199184799741 + 0.005722681071876 + 0.003897757605989}; + double[] molarmass = new double[] {18.0153, 28.0135, 44.0098, 16.0429, 30.0698, 44.0968, + 58.1239, 58.1239, 72.1510, 72.1510, 86.1776 / 1000.0, 90.1140 / 1000.0, 102.0386 / 1000.0, + 117.4548 / 1000.0, 205.5306 / 1000.0}; + double[] density = new double[] {1.0, -1.0000e+19, -1.0000e+19, -1.0000e+19, -1.0000e+19, + -1.0000e+19, -1.0000e+19, -1.0000e+19, -1.0000e+19, -1.0000e+19, 667.4991 / 1000.0, + 746.5672 / 1000.0, 787.1960 / 1000.0, 776.5150 / 1000.0, 849.9863 / 1000.0,}; - double[] P_bar = new double[] {43.991, 1, 1, 1, 10, 10, 10, 10, 100, 100, 100, 100}; - double[] T_C = - new double[] {330.54 - 273.15, 0, 15, 30, 100, 0, 15, 30, 100, 0, 15, 30, 100}; + double[] P_bar = new double[] {43.991, 1, 1, 1, 10, 10, 10, 10, 100, 100, 100, 100}; + double[] T_C = new double[] {330.54 - 273.15, 0, 15, 30, 100, 0, 15, 30, 100, 0, 15, 30, 100}; - double[] enthalpy = new double[P_bar.length]; - double[] entropy = new double[P_bar.length]; + double[] enthalpy = new double[P_bar.length]; + double[] entropy = new double[P_bar.length]; - double[] errH = new double[P_bar.length]; - double[] errS = new double[P_bar.length]; - SystemInterface fluid1 = new SystemSrkEos(298.0, 10.0); - fluid1.getCharacterization().getLumpingModel().setNumberOfPseudoComponents(8); - for (int i = 0; i < components.length; i++) { - if (components[i].startsWith("C") && !components[i].startsWith("CO2")) { - fluid1.addTBPfraction(components[i], fractions1[i], molarmass[i], density[i]); - } else { - fluid1.addComponent(components[i], fractions1[i]); - } - } - fluid1.setHeavyTBPfractionAsPlusFraction(); - fluid1.getCharacterization().characterisePlusFraction(); + double[] errH = new double[P_bar.length]; + double[] errS = new double[P_bar.length]; + SystemInterface fluid1 = new SystemSrkEos(298.0, 10.0); + fluid1.getCharacterization().getLumpingModel().setNumberOfPseudoComponents(8); + for (int i = 0; i < components.length; i++) { + if (components[i].startsWith("C") && !components[i].startsWith("CO2")) { + fluid1.addTBPfraction(components[i], fractions1[i], molarmass[i], density[i]); + } else { + fluid1.addComponent(components[i], fractions1[i]); + } + } + fluid1.setHeavyTBPfractionAsPlusFraction(); + fluid1.getCharacterization().characterisePlusFraction(); - fluid1.createDatabase(true); - fluid1.setMixingRule(2); - fluid1.setMultiPhaseCheck(true); - ThermodynamicOperations thermoOps = new ThermodynamicOperations(fluid1); - for (int i = 0; i < P_bar.length; i++) { - fluid1.setTemperature(T_C[i] + 273.15); - fluid1.setPressure(P_bar[i]); - thermoOps.TPflash(); - fluid1.init(2); - fluid1.initPhysicalProperties(); - enthalpy[i] = fluid1.getEnthalpy(); - entropy[i] = fluid1.getEntropy(); - System.out.println("enthalpy " + enthalpy[i]); - fluid1.display(); - } - /* - * for (int i = 0; i < P_bar.length; i++) { fluid1.setPressure(P_bar[i]); - * thermoOps.PHflash(enthalpy[i]); errH[i] = fluid1.getTemperature() - T_C[i] - 273.15; - * System.out.println("err " + errH[i]); //assertTrue(Math.abs(errH[i]) < 1e-2); } - */ + fluid1.createDatabase(true); + fluid1.setMixingRule(2); + fluid1.setMultiPhaseCheck(true); + ThermodynamicOperations thermoOps = new ThermodynamicOperations(fluid1); + for (int i = 0; i < P_bar.length; i++) { + fluid1.setTemperature(T_C[i] + 273.15); + fluid1.setPressure(P_bar[i]); + thermoOps.TPflash(); + fluid1.init(2); + fluid1.initPhysicalProperties(); + enthalpy[i] = fluid1.getEnthalpy(); + entropy[i] = fluid1.getEntropy(); + System.out.println("enthalpy " + enthalpy[i]); + fluid1.display(); } + /* + * for (int i = 0; i < P_bar.length; i++) { fluid1.setPressure(P_bar[i]); + * thermoOps.PHflash(enthalpy[i]); errH[i] = fluid1.getTemperature() - T_C[i] - 273.15; + * System.out.println("err " + errH[i]); //assertTrue(Math.abs(errH[i]) < 1e-2); } + */ + } } diff --git a/src/test/java/neqsim/thermo/util/example/TestCharacterizationCondensate.java b/src/test/java/neqsim/thermo/util/example/TestCharacterizationCondensate.java index b5cee1661a..2a39b88162 100644 --- a/src/test/java/neqsim/thermo/util/example/TestCharacterizationCondensate.java +++ b/src/test/java/neqsim/thermo/util/example/TestCharacterizationCondensate.java @@ -16,104 +16,106 @@ * @since 2.2.3 */ public class TestCharacterizationCondensate { - static Logger logger = LogManager.getLogger(TestCharacterizationCondensate.class); + static Logger logger = LogManager.getLogger(TestCharacterizationCondensate.class); - /** - *

main.

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - SystemInterface testSystem = new SystemSrkEos(273.15 + 25.0, 50.0); - - testSystem.setFluidName("AsgardB"); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + SystemInterface testSystem = new SystemSrkEos(273.15 + 25.0, 50.0); - // testSystem.getCharacterization().setTBPModel("PedersenSRKHeavyOil");//(RiaziDaubert - // PedersenPR PedersenSRK - // testSystem.getCharacterization().setPlusFractionModel("heavyOil"); - // testSystem.getCharacterization().setLumpingModel("PVTlumpingModel"); - // //"abLumping"; - testSystem.getCharacterization().getLumpingModel().setNumberOfPseudoComponents(12); - // testSystem.addComponent("water", 0.5); - // testSystem.addComponent("TEG", 0.5); - testSystem.addComponent("nitrogen", 0.002); - testSystem.addComponent("CO2", 0.005); - testSystem.addComponent("methane", 0.4); - testSystem.addComponent("ethane", 0.03); - testSystem.addComponent("propane", 0.01); - testSystem.addComponent("n-butane", 0.002); - testSystem.addComponent("i-butane", 0.006); - testSystem.addComponent("n-pentane", 0.004); - testSystem.addComponent("i-pentane", 0.005); + testSystem.setFluidName("AsgardB"); - testSystem.addTBPfraction("C6", 0.004, 85.0253 / 1000.0, 0.667229); - testSystem.addTBPfraction("C7", 0.001, 90.3717 / 1000.0, 0.7463691); - testSystem.addTBPfraction("C8", 0.001, 102.46950 / 1000.0, 0.7709114); - testSystem.addTBPfraction("C9", 0.001, 115.6 / 1000.0, 0.7901); - testSystem.addTBPfraction("C10", 0.001, 125.5046 / 1000.0, 0.80411014); + // testSystem.getCharacterization().setTBPModel("PedersenSRKHeavyOil"); //(RiaziDaubert + // PedersenPR PedersenSRK + // testSystem.getCharacterization().setPlusFractionModel("heavyOil"); + // testSystem.getCharacterization().setLumpingModel("PVTlumpingModel"); + // //"abLumping"; + testSystem.getCharacterization().getLumpingModel().setNumberOfPseudoComponents(12); + // testSystem.addComponent("water", 0.5); + // testSystem.addComponent("TEG", 0.5); + testSystem.addComponent("nitrogen", 0.002); + testSystem.addComponent("CO2", 0.005); + testSystem.addComponent("methane", 0.4); + testSystem.addComponent("ethane", 0.03); + testSystem.addComponent("propane", 0.01); + testSystem.addComponent("n-butane", 0.002); + testSystem.addComponent("i-butane", 0.006); + testSystem.addComponent("n-pentane", 0.004); + testSystem.addComponent("i-pentane", 0.005); - testSystem.addTBPfraction("C11", 0.004, 135.0253 / 1000.0, 0.8167229); - testSystem.addTBPfraction("C12", 0.001, 145.3717 / 1000.0, 0.8263691); - testSystem.addTBPfraction("C13", 0.001, 158.46950 / 1000.0, 0.827709114); - testSystem.addTBPfraction("C14", 0.001, 168.6 / 1000.0, 0.827901); - testSystem.addTBPfraction("C15", 0.001, 172.5046 / 1000.0, 0.8311014); + testSystem.addTBPfraction("C6", 0.004, 85.0253 / 1000.0, 0.667229); + testSystem.addTBPfraction("C7", 0.001, 90.3717 / 1000.0, 0.7463691); + testSystem.addTBPfraction("C8", 0.001, 102.46950 / 1000.0, 0.7709114); + testSystem.addTBPfraction("C9", 0.001, 115.6 / 1000.0, 0.7901); + testSystem.addTBPfraction("C10", 0.001, 125.5046 / 1000.0, 0.80411014); - testSystem.addTBPfraction("C16", 0.004, 190.0253 / 1000.0, 0.83667229); - testSystem.addTBPfraction("C17", 0.001, 211.3717 / 1000.0, 0.8363691); - testSystem.addTBPfraction("C18", 0.001, 220.46950 / 1000.0, 0.827709114); - testSystem.addTBPfraction("C19", 0.001, 245.6 / 1000.0, 0.8401); - testSystem.addTBPfraction("C20", 0.03, 391.5046 / 1000.0, 0.8617411014); + testSystem.addTBPfraction("C11", 0.004, 135.0253 / 1000.0, 0.8167229); + testSystem.addTBPfraction("C12", 0.001, 145.3717 / 1000.0, 0.8263691); + testSystem.addTBPfraction("C13", 0.001, 158.46950 / 1000.0, 0.827709114); + testSystem.addTBPfraction("C14", 0.001, 168.6 / 1000.0, 0.827901); + testSystem.addTBPfraction("C15", 0.001, 172.5046 / 1000.0, 0.8311014); - // testSystem.addComponent("water", 10.87); - // testSystem.addPlusFraction("C11", 1.44, 231.0 / 1000, 0.87); - testSystem.setHeavyTBPfractionAsPlusFraction(); - testSystem.getCharacterization().characterisePlusFraction(); - // testSystem.setHydrateCheck(true); - testSystem.createDatabase(true); - logger.info("start benchmark TPflash......"); - long time = System.currentTimeMillis(); - testSystem.setMixingRule(2); - logger.info("Time taken for benchmark flash = " + (System.currentTimeMillis() - time)); - testSystem.setMultiPhaseCheck(true); - testSystem.setTotalFlowRate(1.0, "kg/sec"); - // testSystem.initPhysicalProperties(); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testSystem.addTBPfraction("C16", 0.004, 190.0253 / 1000.0, 0.83667229); + testSystem.addTBPfraction("C17", 0.001, 211.3717 / 1000.0, 0.8363691); + testSystem.addTBPfraction("C18", 0.001, 220.46950 / 1000.0, 0.827709114); + testSystem.addTBPfraction("C19", 0.001, 245.6 / 1000.0, 0.8401); + testSystem.addTBPfraction("C20", 0.03, 391.5046 / 1000.0, 0.8617411014); - try { - testOps.TPflash(); - // testOps.hydrateFormationTemperature(); - // testOps.dewPointTemperatureFlash(); - } catch (Exception e) { - logger.error(e.toString()); - } - testSystem.display(); + // testSystem.addComponent("water", 10.87); + // testSystem.addPlusFraction("C11", 1.44, 231.0 / 1000, 0.87); + testSystem.setHeavyTBPfractionAsPlusFraction(); + testSystem.getCharacterization().characterisePlusFraction(); + // testSystem.setHydrateCheck(true); + testSystem.createDatabase(true); + logger.info("start benchmark TPflash......"); + long time = System.currentTimeMillis(); + testSystem.setMixingRule(2); + logger.info("Time taken for benchmark flash = " + (System.currentTimeMillis() - time)); + testSystem.setMultiPhaseCheck(true); + testSystem.setTotalFlowRate(1.0, "kg/sec"); + // testSystem.initPhysicalProperties(); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - // double[] molaFrac = new double[]{0.01, 0.01, 0.6, 0.1, 0.02, 0.02, 0.01, - // 0.001, 0.002, 0.01, 0.001, 0.001,0.001, 0.4}; - // testSystem.setMolarCompositionPlus(molaFrac); - try { - testOps.TPflash(); - // testOps.hydrateFormationTemperature(); - // testOps.dewPointTemperatureFlash(); - } catch (Exception e) { - logger.error(e.toString()); - } - testSystem.display(); - // System.out.println("number of lumped components " + - // testSystem.getCharacterization().getLumpingModel().getNumberOfLumpedComponents()); - // System.out.println("number of pseudo components " + - // testSystem.getCharacterization().getLumpingModel().getNumberOfPseudoComponents()); - // System.out.println("lumped component " + - // testSystem.getCharacterization().getLumpingModel().getLumpedComponentName(3)); + try { + testOps.TPflash(); + // testOps.hydrateFormationTemperature(); + // testOps.dewPointTemperatureFlash(); + } catch (Exception e) { + logger.error(e.toString()); + } + testSystem.display(); - /* - * System.out.println("molar mass " - * +testSystem.getPhase(0).getComponent("PC4_PC").getMolarMass() ); - * - * testSystem.setMolarCompositionOfPlusFluid(new double[]{0.02, 0.005, 0.4, 0.01, 0.01, - * 0.02, 0.02, 0.01 ,0.01, 0.01, 0.01 ,0.01, 0.01, 0.2 }); try { testOps.TPflash(); // - * testOps.hydrateFormationTemperature(); // testOps.dewPointTemperatureFlash(); } catch - * (Exception e) { logger.error(e.toString()); } testSystem.display(); - */ + // double[] molaFrac = new double[]{0.01, 0.01, 0.6, 0.1, 0.02, 0.02, 0.01, + // 0.001, 0.002, 0.01, 0.001, 0.001,0.001, 0.4}; + // testSystem.setMolarCompositionPlus(molaFrac); + try { + testOps.TPflash(); + // testOps.hydrateFormationTemperature(); + // testOps.dewPointTemperatureFlash(); + } catch (Exception e) { + logger.error(e.toString()); } + testSystem.display(); + // System.out.println("number of lumped components " + + // testSystem.getCharacterization().getLumpingModel().getNumberOfLumpedComponents()); + // System.out.println("number of pseudo components " + + // testSystem.getCharacterization().getLumpingModel().getNumberOfPseudoComponents()); + // System.out.println("lumped component " + + // testSystem.getCharacterization().getLumpingModel().getLumpedComponentName(3)); + + /* + * System.out.println("molar mass " + * +testSystem.getPhase(0).getComponent("PC4_PC").getMolarMass() ); + * + * testSystem.setMolarCompositionOfPlusFluid(new double[]{0.02, 0.005, 0.4, 0.01, 0.01, 0.02, + * 0.02, 0.01 ,0.01, 0.01, 0.01 ,0.01, 0.01, 0.2 }); try { testOps.TPflash(); // + * testOps.hydrateFormationTemperature(); // testOps.dewPointTemperatureFlash(); } catch + * (Exception e) { logger.error(e.toString()); } testSystem.display(); + */ + } } diff --git a/src/test/java/neqsim/thermo/util/example/TestCharacterizationCondensate1.java b/src/test/java/neqsim/thermo/util/example/TestCharacterizationCondensate1.java index 98526d9b9c..bcb26aae18 100644 --- a/src/test/java/neqsim/thermo/util/example/TestCharacterizationCondensate1.java +++ b/src/test/java/neqsim/thermo/util/example/TestCharacterizationCondensate1.java @@ -17,74 +17,72 @@ * @since 2.2.3 */ public class TestCharacterizationCondensate1 { - static Logger logger = LogManager.getLogger(TestCharacterizationCondensate1.class); + static Logger logger = LogManager.getLogger(TestCharacterizationCondensate1.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - SystemInterface testSystem = new SystemSrkEos(273.15 + 30, 50); - // SystemInterface testSystem = new SystemSrkCPAs(293.65, 79.3); - testSystem.getCharacterization().setTBPModel("PedersenSRK");// (RiaziDaubert PedersenPR - // PedersenSRK - testSystem.getCharacterization().setPlusFractionModel("heavyOil"); - // testSystem.getCharacterization().setTBPModel("PedersenSRK");//(RiaziDaubert - // PedersenPR PedersenSRK + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + SystemInterface testSystem = new SystemSrkEos(273.15 + 30, 50); + // SystemInterface testSystem = new SystemSrkCPAs(293.65, 79.3); + testSystem.getCharacterization().setTBPModel("PedersenSRK"); // (RiaziDaubert PedersenPR + // PedersenSRK + testSystem.getCharacterization().setPlusFractionModel("heavyOil"); + // testSystem.getCharacterization().setTBPModel("PedersenSRK"); //(RiaziDaubert + // PedersenPR PedersenSRK - // testSystem.addComponent("C20", 0.006, 430, 12, 0.9); //TC PC OMEGA - // Haklang - testSystem.addComponent("methane", 50); - // testSystem.addComponent("PC-C6", 0.13); - // testSystem.addComponent("PC-C7", 0.22); - // testSystem.addComponent("PC-C8", 0.213); - // testSystem.addComponent("PC-C9", 0.096); - // testSystem.addComponent("PC-C10", 0.04); - /* - * testSystem.addComponent("PC-C11", 0.031); testSystem.addComponent("PC-C12", 0.025); - * testSystem.addComponent("PC-C13", 0.02); testSystem.addComponent("PC-C14", 0.016); - * testSystem.addComponent("PC-C15-C16", 0.023); testSystem.addComponent("PC-C17-C18", - * 0.014); testSystem.addComponent("PC-C19-C22", 0.015); - * testSystem.addComponent("PC-C23-C58", 0.01); - */ - testSystem.addPlusFraction("C7", 5, 100.0 / 1000.0, 0.72); - testSystem.addPlusFraction("C8", 50, 200.0 / 1000.0, 0.82); - testSystem.addPlusFraction("C8", 34, 200.0 / 1000.0, 0.82); - // testSystem.getCharacterization().getLumpingModel().setNumberOfLumpedComponents(12); - testSystem.getCharacterization().characterisePlusFraction(); - /* - * testSystem.getInterphaseProperties().setInterfacialTensionModel(0); - */ - testSystem.useVolumeCorrection(true); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - testSystem.setMultiPhaseCheck(true); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + // testSystem.addComponent("C20", 0.006, 430, 12, 0.9); //TC PC OMEGA + // Haklang + testSystem.addComponent("methane", 50); + // testSystem.addComponent("PC-C6", 0.13); + // testSystem.addComponent("PC-C7", 0.22); + // testSystem.addComponent("PC-C8", 0.213); + // testSystem.addComponent("PC-C9", 0.096); + // testSystem.addComponent("PC-C10", 0.04); + /* + * testSystem.addComponent("PC-C11", 0.031); testSystem.addComponent("PC-C12", 0.025); + * testSystem.addComponent("PC-C13", 0.02); testSystem.addComponent("PC-C14", 0.016); + * testSystem.addComponent("PC-C15-C16", 0.023); testSystem.addComponent("PC-C17-C18", 0.014); + * testSystem.addComponent("PC-C19-C22", 0.015); testSystem.addComponent("PC-C23-C58", 0.01); + */ + testSystem.addPlusFraction("C7", 5, 100.0 / 1000.0, 0.72); + testSystem.addPlusFraction("C8", 50, 200.0 / 1000.0, 0.82); + testSystem.addPlusFraction("C8", 34, 200.0 / 1000.0, 0.82); + // testSystem.getCharacterization().getLumpingModel().setNumberOfLumpedComponents(12); + testSystem.getCharacterization().characterisePlusFraction(); + /* + * testSystem.getInterphaseProperties().setInterfacialTensionModel(0); + */ + testSystem.useVolumeCorrection(true); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + testSystem.setMultiPhaseCheck(true); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - try { - testOps.TPflash(); - testSystem.display(); + try { + testOps.TPflash(); + testSystem.display(); - testSystem.resetCharacterisation(); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - testSystem.setMultiPhaseCheck(true); - testOps = new ThermodynamicOperations(testSystem); + testSystem.resetCharacterisation(); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + testSystem.setMultiPhaseCheck(true); + testOps = new ThermodynamicOperations(testSystem); - testOps.TPflash(); - testSystem.display(); - // testOps.hydrateFormationTemperature(); - // testOps.dewPointTemperatureFlash(); - } catch (Exception e) { - logger.error(e.toString()); - } - System.out.println( - "activity coefficient " + testSystem.getPhase(1).getActivityCoefficient(1)); - testSystem.display(); - ((PhaseEosInterface) testSystem.getPhase(0)).displayInteractionCoefficients(""); - testSystem.getPhase(0).getComponent(1).getAcentricFactor(); + testOps.TPflash(); + testSystem.display(); + // testOps.hydrateFormationTemperature(); + // testOps.dewPointTemperatureFlash(); + } catch (Exception e) { + logger.error(e.toString()); } + System.out.println("activity coefficient " + testSystem.getPhase(1).getActivityCoefficient(1)); + testSystem.display(); + ((PhaseEosInterface) testSystem.getPhase(0)).displayInteractionCoefficients(""); + testSystem.getPhase(0).getComponent(1).getAcentricFactor(); + } } diff --git a/src/test/java/neqsim/thermo/util/example/TestGEHenry.java b/src/test/java/neqsim/thermo/util/example/TestGEHenry.java index 5d1353cafb..7cdad62f06 100644 --- a/src/test/java/neqsim/thermo/util/example/TestGEHenry.java +++ b/src/test/java/neqsim/thermo/util/example/TestGEHenry.java @@ -7,38 +7,42 @@ import neqsim.thermodynamicOperations.ThermodynamicOperations; /** - *

TestGEHenry class.

+ *

+ * TestGEHenry class. + *

* * @author esol * @version $Id: $Id * @since 2.2.3 */ public class TestGEHenry { - static Logger logger = LogManager.getLogger(TestGEHenry.class); + static Logger logger = LogManager.getLogger(TestGEHenry.class); - /** - *

main.

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - SystemInterface testSystem = new SystemGEWilson(273.15 + 55.0, 1.301325); - // SystemInterface testSystem = new SystemNRTL(273.15 + 55.0,1.301325); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + SystemInterface testSystem = new SystemGEWilson(273.15 + 55.0, 1.301325); + // SystemInterface testSystem = new SystemNRTL(273.15 + 55.0,1.301325); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - testSystem.addComponent("methane", 10.0); - // testSystem.addComponent("methanol", 1.0); - testSystem.addComponent("water", 10.0); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - testSystem.init(0); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testSystem.addComponent("methane", 10.0); + // testSystem.addComponent("methanol", 1.0); + testSystem.addComponent("water", 10.0); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + testSystem.init(0); - try { - testOps.TPflash(); - // testOps.bubblePointPressureFlash(false);//(false); - } catch (Exception e) { - logger.error(e.toString(), e); - } - testSystem.display(); + try { + testOps.TPflash(); + // testOps.bubblePointPressureFlash(false); //(false); + } catch (Exception e) { + logger.error(e.toString(), e); } + testSystem.display(); + } } diff --git a/src/test/java/neqsim/thermo/util/example/TestPCSAFT1.java b/src/test/java/neqsim/thermo/util/example/TestPCSAFT1.java index 7641a00fca..7115cf1401 100644 --- a/src/test/java/neqsim/thermo/util/example/TestPCSAFT1.java +++ b/src/test/java/neqsim/thermo/util/example/TestPCSAFT1.java @@ -7,86 +7,89 @@ import neqsim.thermodynamicOperations.ThermodynamicOperations; /** - *

TestPCSAFT1 class.

+ *

+ * TestPCSAFT1 class. + *

* * @author esol * @version $Id: $Id * @since 2.2.3 */ public class TestPCSAFT1 { - static Logger logger = LogManager.getLogger(TestPCSAFT1.class); + static Logger logger = LogManager.getLogger(TestPCSAFT1.class); - /** - *

main.

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - double pressure = 0.0; - // String[] componentName = {"nitrogen", "CO2", "methane", "ethane", "propane", - // "i-butane", "n-butane", "22-dim-C3", "iC5", "n-pentane", "22-dim-C4", "c-C5", - // "23-dim-C4", "2-m-C5", "3-m-C5", "n-hexane", "n-heptane", "c-C6", "benzene", - // "n-octane", "c-C7", "toluene", "n-nonane", "c-C8", "m-Xylene"}; + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + double pressure = 0.0; + // String[] componentName = {"nitrogen", "CO2", "methane", "ethane", "propane", + // "i-butane", "n-butane", "22-dim-C3", "iC5", "n-pentane", "22-dim-C4", "c-C5", + // "23-dim-C4", "2-m-C5", "3-m-C5", "n-hexane", "n-heptane", "c-C6", "benzene", + // "n-octane", "c-C7", "toluene", "n-nonane", "c-C8", "m-Xylene"}; - // double[] compositions = {0.5108, 1.8922, 86.6295, 6.1903, 2.7941, 0.4635, - // 0.7524, 0.0160, 0.2109, 0.1837, 0.0055, 0.0164, 0.0094, 0.0402, 0.0221, - // 0.0503};//, 0.0297, 0.0866, 0.03262, 0.0039, 0.0317, 0.0209, 0.0006, 0.0008, - // 0.0023}; - // String[] componentName = {"nitrogen", "CO2", "methane", "ethane", "propane", - // "i-butane", "n-butane", "22-dim-C3", "iC5", "n-pentane", "22-dim-C4", "c-C5", - // "23-dim-C4", "2-m-C5", "3-m-C5", "n-hexane"};//, "n-heptane", "c-C6", - // "benzene", "n-octane", "c-C7", "toluene", "c-C8"}; + // double[] compositions = {0.5108, 1.8922, 86.6295, 6.1903, 2.7941, 0.4635, + // 0.7524, 0.0160, 0.2109, 0.1837, 0.0055, 0.0164, 0.0094, 0.0402, 0.0221, + // 0.0503}; //, 0.0297, 0.0866, 0.03262, 0.0039, 0.0317, 0.0209, 0.0006, 0.0008, + // 0.0023}; + // String[] componentName = {"nitrogen", "CO2", "methane", "ethane", "propane", + // "i-butane", "n-butane", "22-dim-C3", "iC5", "n-pentane", "22-dim-C4", "c-C5", + // "23-dim-C4", "2-m-C5", "3-m-C5", "n-hexane"}; //, "n-heptane", "c-C6", + // "benzene", "n-octane", "c-C7", "toluene", "c-C8"}; - String[] componentName = {"nitrogen", "CO2", "methane", "ethane", "propane", "i-butane", - "n-butane", "22-dim-C3", "iC5", "n-pentane", "22-dim-C4", "c-C5", "23-dim-C4", - "2-m-C5", "3-m-C5", "n-hexane"}; + String[] componentName = + {"nitrogen", "CO2", "methane", "ethane", "propane", "i-butane", "n-butane", "22-dim-C3", + "iC5", "n-pentane", "22-dim-C4", "c-C5", "23-dim-C4", "2-m-C5", "3-m-C5", "n-hexane"}; - double[] compositions = {1.6298, 0.3207, 93.2144, 3.7328, 0.5654, 0.2906, 0.0653, 0.0042, - 0.0483, 0.0167, 0.0042, 0.0092, 0.0065, 0.0165, 0.0089, 0.0038,}; + double[] compositions = {1.6298, 0.3207, 93.2144, 3.7328, 0.5654, 0.2906, 0.0653, 0.0042, + 0.0483, 0.0167, 0.0042, 0.0092, 0.0065, 0.0165, 0.0089, 0.0038,}; - double[] uncertcompositions = {0.0655, 0.0240, 1.061, 0.2144, 0.0968, 0.0217, 0.0353, - 0.0011, 0.011, 0.007, 0.0005, 0.0011, 0.0008, 0.0028, 0.0015, 0.0035, 0.0021, 0.006, - 0.0025, 0.0003, 0.0022, 0.0014, 0.0001, 0.0002, 0.0007}; - double[] runcompositions = new double[componentName.length]; - SystemInterface testSystem = new SystemSrkEos(273.14, pressure); - // SystemInterface testSystem = new SystemPCSAFT(273.14, pressure); - double pres = 0.0; - testSystem = new SystemSrkEos(testSystem.getTemperature(), pres); + double[] uncertcompositions = {0.0655, 0.0240, 1.061, 0.2144, 0.0968, 0.0217, 0.0353, 0.0011, + 0.011, 0.007, 0.0005, 0.0011, 0.0008, 0.0028, 0.0015, 0.0035, 0.0021, 0.006, 0.0025, 0.0003, + 0.0022, 0.0014, 0.0001, 0.0002, 0.0007}; + double[] runcompositions = new double[componentName.length]; + SystemInterface testSystem = new SystemSrkEos(273.14, pressure); + // SystemInterface testSystem = new SystemPCSAFT(273.14, pressure); + double pres = 0.0; + testSystem = new SystemSrkEos(testSystem.getTemperature(), pres); - for (int i = 0; i < componentName.length; i++) { - double newVar = - cern.jet.random.Normal.staticNextDouble(compositions[i], uncertcompositions[i]); - newVar = cern.jet.random.Normal.staticNextDouble(compositions[i], - uncertcompositions[i]); - runcompositions[i] = compositions[i] + 0 * newVar; - testSystem.addComponent(componentName[i], runcompositions[i]); - } - testSystem.addTBPfraction("C7", 0.0477, 88.435 / 1000.0, 746.9 / 1000.0); - testSystem.addTBPfraction("C8", 0.0147, 101.948 / 1000.0, 763.7 / 1000.0); - testSystem.addTBPfraction("C9", 0.0004, 116.170 / 1000.0, 783.9 / 1000.0); - testSystem.init(0); - testSystem.init(1); - // if (testSystem.characterize()) { - // testSystem.getCharacterization().removeTBPfraction(); - // testSystem.getCharacterization().addTBPFractions(); - // } - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - testSystem.init(0); - for (int p = 0; p < 1; p++) { - pres += 1.0; - testSystem.setPressure(pres); - try { - // testOps.dewPointTemperatureFlash(); - testOps.calcPTphaseEnvelope(false); - testOps.displayResult(); - // testSystem.display(); - logger.info("pressure " + testSystem.getPressure() + " dew point " - + testSystem.getTemperature()); - } catch (Exception e) { - logger.error(e.toString(), e); - } - } + for (int i = 0; i < componentName.length; i++) { + double newVar = + cern.jet.random.Normal.staticNextDouble(compositions[i], uncertcompositions[i]); + newVar = cern.jet.random.Normal.staticNextDouble(compositions[i], uncertcompositions[i]); + runcompositions[i] = compositions[i] + 0 * newVar; + testSystem.addComponent(componentName[i], runcompositions[i]); } + testSystem.addTBPfraction("C7", 0.0477, 88.435 / 1000.0, 746.9 / 1000.0); + testSystem.addTBPfraction("C8", 0.0147, 101.948 / 1000.0, 763.7 / 1000.0); + testSystem.addTBPfraction("C9", 0.0004, 116.170 / 1000.0, 783.9 / 1000.0); + testSystem.init(0); + testSystem.init(1); + // if (testSystem.characterize()) { + // testSystem.getCharacterization().removeTBPfraction(); + // testSystem.getCharacterization().addTBPFractions(); + // } + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testSystem.init(0); + for (int p = 0; p < 1; p++) { + pres += 1.0; + testSystem.setPressure(pres); + try { + // testOps.dewPointTemperatureFlash(); + testOps.calcPTphaseEnvelope(false); + testOps.displayResult(); + // testSystem.display(); + logger.info( + "pressure " + testSystem.getPressure() + " dew point " + testSystem.getTemperature()); + } catch (Exception e) { + logger.error(e.toString(), e); + } + } + } } diff --git a/src/test/java/neqsim/thermo/util/example/TestPSRK.java b/src/test/java/neqsim/thermo/util/example/TestPSRK.java index 9ec8a5c400..0f340279b4 100644 --- a/src/test/java/neqsim/thermo/util/example/TestPSRK.java +++ b/src/test/java/neqsim/thermo/util/example/TestPSRK.java @@ -16,55 +16,57 @@ * @since 2.2.3 */ public class TestPSRK { - static Logger logger = LogManager.getLogger(TestPSRK.class); + static Logger logger = LogManager.getLogger(TestPSRK.class); - /** - *

main.

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - // SystemInterface testSystem = new SystemSrkEos(325.8, 10.0); - // SystemInterface testSystem = new SystemCSPsrkEos(245.8, 70.0); - // SystemInterface testSystem = new SystemSrkEos(265.8, 20.0); - SystemInterface testSystem = new SystemPsrkEos(255.32, 5); - // SystemInterface testSystem = new SystemPrEos(240,50.0301325); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + // SystemInterface testSystem = new SystemSrkEos(325.8, 10.0); + // SystemInterface testSystem = new SystemCSPsrkEos(245.8, 70.0); + // SystemInterface testSystem = new SystemSrkEos(265.8, 20.0); + SystemInterface testSystem = new SystemPsrkEos(255.32, 5); + // SystemInterface testSystem = new SystemPrEos(240,50.0301325); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - // testSystem.addComponent("CO2", 84.29); - // testSystem.addComponent("MDEA", 10.09); - testSystem.addComponent("H2S", 0.99); - testSystem.addComponent("methane", 0.01); - // testSystem.addComponent("ethane", 0.02972); - // testSystem.addComponent("propane", 1.01008); - // testSystem.addComponent("i-butane", 0.0105); - // testSystem.addComponent("n-butane", 1.01465); - // testSystem.addComponent("nC10", 1.01465); + // testSystem.addComponent("CO2", 84.29); + // testSystem.addComponent("MDEA", 10.09); + testSystem.addComponent("H2S", 0.99); + testSystem.addComponent("methane", 0.01); + // testSystem.addComponent("ethane", 0.02972); + // testSystem.addComponent("propane", 1.01008); + // testSystem.addComponent("i-butane", 0.0105); + // testSystem.addComponent("n-butane", 1.01465); + // testSystem.addComponent("nC10", 1.01465); - // testSystem.addComponent("nitrogen", 10.2); - // testSystem.addComponent("nitrogen", 10.01); - // testSystem.addTBPfraction("C7", 1.01,100.0, 0.98); - // testSystem.addTBPfraction("C8", 1.01,120.0, 1.01); - testSystem.createDatabase(true); - // testSystem.setMixingRule(1); - // testSystem.set - testSystem.setMixingRule("HV", "UNIFAC_PSRK"); - // testSystem.setMixingRule("WS","UNIFAC_PSRK"); - testSystem.init(0); - testSystem.init(2); + // testSystem.addComponent("nitrogen", 10.2); + // testSystem.addComponent("nitrogen", 10.01); + // testSystem.addTBPfraction("C7", 1.01,100.0, 0.98); + // testSystem.addTBPfraction("C8", 1.01,120.0, 1.01); + testSystem.createDatabase(true); + // testSystem.setMixingRule(1); + // testSystem.set + testSystem.setMixingRule("HV", "UNIFAC_PSRK"); + // testSystem.setMixingRule("WS","UNIFAC_PSRK"); + testSystem.init(0); + testSystem.init(2); - // thermo.ThermodynamicModelTest testModel = new - // thermo.ThermodynamicModelTest(testSystem); - // testModel.runTest(); + // thermo.ThermodynamicModelTest testModel = new + // thermo.ThermodynamicModelTest(testSystem); + // testModel.runTest(); - try { - testOps.dewPointPressureFlash();// (false); - // testOps.dewPointTemperatureFlash(); - // testOps.calcPTphaseEnvelope(0.0005, 0.0001); testOps.displayResult(); - } catch (Exception e) { - logger.error(e.toString()); - } - testSystem.display(); - logger.info(testSystem.getTemperature() - 273.15); + try { + testOps.dewPointPressureFlash(); // (false); + // testOps.dewPointTemperatureFlash(); + // testOps.calcPTphaseEnvelope(0.0005, 0.0001); testOps.displayResult(); + } catch (Exception e) { + logger.error(e.toString()); } + testSystem.display(); + logger.info(testSystem.getTemperature() - 273.15); + } } diff --git a/src/test/java/neqsim/thermo/util/example/TestSRKWS.java b/src/test/java/neqsim/thermo/util/example/TestSRKWS.java index 743a2c06e0..d9a06d1465 100644 --- a/src/test/java/neqsim/thermo/util/example/TestSRKWS.java +++ b/src/test/java/neqsim/thermo/util/example/TestSRKWS.java @@ -16,40 +16,42 @@ * @since 2.2.3 */ public class TestSRKWS { - static Logger logger = LogManager.getLogger(TestSRKWS.class); + static Logger logger = LogManager.getLogger(TestSRKWS.class); - /** - *

main.

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - // SystemInterface testSystem = new SystemSrkEos(245.8, 50.0); - SystemInterface testSystem = new SystemPsrkEos(245.8, 50.0); - // SystemInterface testSystem = new SystemCSPsrkEos(245.8, 70.0); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + // SystemInterface testSystem = new SystemSrkEos(245.8, 50.0); + SystemInterface testSystem = new SystemPsrkEos(245.8, 50.0); + // SystemInterface testSystem = new SystemCSPsrkEos(245.8, 70.0); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - testSystem.addComponent("methane", 84.29); - testSystem.addComponent("ethane", 10.09); - testSystem.addComponent("propane", 4.0); - testSystem.addComponent("i-butane", 0.59); - testSystem.addComponent("n-butane", 1.02); + testSystem.addComponent("methane", 84.29); + testSystem.addComponent("ethane", 10.09); + testSystem.addComponent("propane", 4.0); + testSystem.addComponent("i-butane", 0.59); + testSystem.addComponent("n-butane", 1.02); - testSystem.createDatabase(true); - // testSystem.setMixingRule(2); - // testSystem.setMixingRule("HV","UNIFAC_PSRK"); - testSystem.setMixingRule("WS", "UNIFAC_PSRK"); - testSystem.init(0); - testSystem.init(3); + testSystem.createDatabase(true); + // testSystem.setMixingRule(2); + // testSystem.setMixingRule("HV","UNIFAC_PSRK"); + testSystem.setMixingRule("WS", "UNIFAC_PSRK"); + testSystem.init(0); + testSystem.init(3); - try { - testOps.dewPointTemperatureFlash();// (false); - // testOps.bubblePointTemperatureFlash(); - // testOps.calcPTphaseEnvelope(0.0005, 0.0001); testOps.displayResult(); - } catch (Exception e) { - logger.error(e.toString()); - } - testSystem.display(); - logger.info(testSystem.getTemperature() - 273.15); + try { + testOps.dewPointTemperatureFlash(); // (false); + // testOps.bubblePointTemperatureFlash(); + // testOps.calcPTphaseEnvelope(0.0005, 0.0001); testOps.displayResult(); + } catch (Exception e) { + logger.error(e.toString()); } + testSystem.display(); + logger.info(testSystem.getTemperature() - 273.15); + } } diff --git a/src/test/java/neqsim/thermo/util/example/TestUMRPRU.java b/src/test/java/neqsim/thermo/util/example/TestUMRPRU.java index 68114280fe..b18154cc50 100644 --- a/src/test/java/neqsim/thermo/util/example/TestUMRPRU.java +++ b/src/test/java/neqsim/thermo/util/example/TestUMRPRU.java @@ -16,94 +16,96 @@ * @since 2.2.3 */ public class TestUMRPRU { - static Logger logger = LogManager.getLogger(TestUMRPRU.class); + static Logger logger = LogManager.getLogger(TestUMRPRU.class); - /** - *

main.

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - // SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 - 3.5, 33.0); - // SystemInterface testSystem = new SystemUMRPRUMCEos(273.15 + 20.5, 70.0); - // SystemInterface testSystem = new SystemPsrkEos(273.15 - 133.85, 8.557); - SystemInterface testSystem = new SystemUMRPRUMCEos(273.15 + 15, 10.0); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - // testSystem.addComponent("nitrogen", 1); - // testSystem.addComponent("CO2", 1); - testSystem.addComponent("methane", 80); - // testSystem.addComponent("ethane", 15); - // testSystem.addComponent("propane", 1); - // testSystem.addComponent("i-butane", 0.1); - // testSystem.addComponent("n-butane", 0.1); - // testSystem.addComponent("i-pentane", 0.05); - // testSystem.addComponent("n-pentane", 0.05); - testSystem.addComponent("n-heptane", 22.05); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + // SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 - 3.5, 33.0); + // SystemInterface testSystem = new SystemUMRPRUMCEos(273.15 + 20.5, 70.0); + // SystemInterface testSystem = new SystemPsrkEos(273.15 - 133.85, 8.557); + SystemInterface testSystem = new SystemUMRPRUMCEos(273.15 + 15, 10.0); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + // testSystem.addComponent("nitrogen", 1); + // testSystem.addComponent("CO2", 1); + testSystem.addComponent("methane", 80); + // testSystem.addComponent("ethane", 15); + // testSystem.addComponent("propane", 1); + // testSystem.addComponent("i-butane", 0.1); + // testSystem.addComponent("n-butane", 0.1); + // testSystem.addComponent("i-pentane", 0.05); + // testSystem.addComponent("n-pentane", 0.05); + testSystem.addComponent("n-heptane", 22.05); - testSystem.addTBPfraction("C7", .0010, 85.5 / 1000.0, 0.66533); - testSystem.addTBPfraction("C8", .0010, 91.06 / 1000.0, 0.74433); - testSystem.addTBPfraction("C9", .0010, 103.61 / 1000.0, 0.76833); - testSystem.addTBPfraction("C10", 0.001, 117.2 / 1000.0, 0.785); - testSystem.addTBPfraction("C11", 0.001, 155.04 / 1000.0, 0.800); - testSystem.addTBPfraction("C12", .01, 249.98 / 1000.0, 0.84566); - testSystem.addTBPfraction("C13", .01, 458.76 / 1000.0, 0.89767); + testSystem.addTBPfraction("C7", .0010, 85.5 / 1000.0, 0.66533); + testSystem.addTBPfraction("C8", .0010, 91.06 / 1000.0, 0.74433); + testSystem.addTBPfraction("C9", .0010, 103.61 / 1000.0, 0.76833); + testSystem.addTBPfraction("C10", 0.001, 117.2 / 1000.0, 0.785); + testSystem.addTBPfraction("C11", 0.001, 155.04 / 1000.0, 0.800); + testSystem.addTBPfraction("C12", .01, 249.98 / 1000.0, 0.84566); + testSystem.addTBPfraction("C13", .01, 458.76 / 1000.0, 0.89767); - testSystem.addComponent("water", 10.1); - // testSystem.addComponent("MEG", 10.1); - // testSystem.addComponent("TEG", 10.1); - // testSystem.addTBPfraction("C10", 0.1, 117.2 / 1000.0, 0.785); - testSystem.createDatabase(true); - // testSystem.setMixingRule(2); + testSystem.addComponent("water", 10.1); + // testSystem.addComponent("MEG", 10.1); + // testSystem.addComponent("TEG", 10.1); + // testSystem.addTBPfraction("C10", 0.1, 117.2 / 1000.0, 0.785); + testSystem.createDatabase(true); + // testSystem.setMixingRule(2); - testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); - testSystem.setMultiPhaseCheck(true); - // testSystem.setMultiPhaseCheck(true); - // testSystem.setMixingRule("HV", "UNIFAC_PSRK"); - // testSystem.setMixingRule(2); - // testSystem.setBmixType(1); - testSystem.init(0); - // testSystem.saveObject(2043); - // testSystem.init(3,1); - try { - // testOps.dewPointTemperatureFlash(); - for (int i = 0; i < 1; i++) { - testOps.TPflash(); - } - // testSystem.display(); - // double enthalpy = testSystem.getEnthalpy(); - // testSystem.setPressure(20.0); - // testOps.PHflash(enthalpy, 0); - // testSystem.display(); - // testOps.setRunAsThread(true); - // testOps.calcPTphaseEnvelope(true);//true); - // boolean isFinished = testOps.waitAndCheckForFinishedCalculation(10000); + testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); + testSystem.setMultiPhaseCheck(true); + // testSystem.setMultiPhaseCheck(true); + // testSystem.setMixingRule("HV", "UNIFAC_PSRK"); + // testSystem.setMixingRule(2); + // testSystem.setBmixType(1); + testSystem.init(0); + // testSystem.saveObject(2043); + // testSystem.init(3,1); + try { + // testOps.dewPointTemperatureFlash(); + for (int i = 0; i < 1; i++) { + testOps.TPflash(); + } + // testSystem.display(); + // double enthalpy = testSystem.getEnthalpy(); + // testSystem.setPressure(20.0); + // testOps.PHflash(enthalpy, 0); + // testSystem.display(); + // testOps.setRunAsThread(true); + // testOps.calcPTphaseEnvelope(true); //true); + // boolean isFinished = testOps.waitAndCheckForFinishedCalculation(10000); - // testOps.displayResult(); - } catch (Exception e) { - logger.error(e.toString()); - } - // testSystem.saveObject(880); - // testSystem.saveFluid(30, "Norne"); - testSystem.display(); - testSystem.init(3); - double cp = testSystem.getPhase(1).getCp(); + // testOps.displayResult(); + } catch (Exception e) { + logger.error(e.toString()); + } + // testSystem.saveObject(880); + // testSystem.saveFluid(30, "Norne"); + testSystem.display(); + testSystem.init(3); + double cp = testSystem.getPhase(1).getCp(); - testSystem.setTemperature(testSystem.getTemperature() + 0.001); - testSystem.init(3); - double ent1 = testSystem.getPhase(1).getEnthalpy(); + testSystem.setTemperature(testSystem.getTemperature() + 0.001); + testSystem.init(3); + double ent1 = testSystem.getPhase(1).getEnthalpy(); - testSystem.setTemperature(testSystem.getTemperature() - 0.002); - testSystem.init(3); - double ent2 = testSystem.getPhase(1).getEnthalpy(); + testSystem.setTemperature(testSystem.getTemperature() - 0.002); + testSystem.init(3); + double ent2 = testSystem.getPhase(1).getEnthalpy(); - double numCp = (ent1 - ent2) / 0.002; + double numCp = (ent1 - ent2) / 0.002; - System.out.println("Cp " + cp + " numCp " + numCp); - System.out.println("entropy " + testSystem.getPhase(1).getEntropy()); + System.out.println("Cp " + cp + " numCp " + numCp); + System.out.println("entropy " + testSystem.getPhase(1).getEntropy()); - // thermo.ThermodynamicModelTest testModel = new - // thermo.ThermodynamicModelTest(testSystem); - // testModel.runTest(); - // testSystem.display(); - } + // thermo.ThermodynamicModelTest testModel = new + // thermo.ThermodynamicModelTest(testSystem); + // testModel.runTest(); + // testSystem.display(); + } } diff --git a/src/test/java/neqsim/thermo/util/example/TestUMRPRUMC.java b/src/test/java/neqsim/thermo/util/example/TestUMRPRUMC.java index dc453e4691..8ce6e10b57 100644 --- a/src/test/java/neqsim/thermo/util/example/TestUMRPRUMC.java +++ b/src/test/java/neqsim/thermo/util/example/TestUMRPRUMC.java @@ -16,110 +16,109 @@ * @since 2.2.3 */ public class TestUMRPRUMC { - static Logger logger = LogManager.getLogger(TestUMRPRUMC.class); + static Logger logger = LogManager.getLogger(TestUMRPRUMC.class); - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - // SystemInterface testSystem = new SystemUMRPRUMCEos(273.15 + 20, 10.0); - SystemInterface testSystem = new SystemSrkEos(273.15 + 20, 15.0); - // SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 20, 1.0); - // testSystem.getCharacterization().setTBPModel("PedersenPR");//(RiaziDaubert - // PedersenPR PedersenSRK - // testSystem.addComponent("CO2", 0.1) - testSystem.addComponent("nitrogen", 1.1472); - testSystem.addComponent("CO2", 0.5339); - testSystem.addComponent("methane", 95.2412); - testSystem.addComponent("ethane", 2.2029); - testSystem.addComponent("propane", 0.3231); - testSystem.addComponent("i-butane", 0.1341); - testSystem.addComponent("n-butane", 0.0827); - // testSystem.addComponent("22-dim-C3", 10.0); - // testSystem.addComponent("i-pentane", 0.0679); - // testSystem.addComponent("n-pentane", 0.0350); - // testSystem.addComponent("c-C5", 0.0291185); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + // SystemInterface testSystem = new SystemUMRPRUMCEos(273.15 + 20, 10.0); + SystemInterface testSystem = new SystemSrkEos(273.15 + 20, 15.0); + // SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 20, 1.0); + // testSystem.getCharacterization().setTBPModel("PedersenPR"); //(RiaziDaubert + // PedersenPR PedersenSRK + // testSystem.addComponent("CO2", 0.1) + testSystem.addComponent("nitrogen", 1.1472); + testSystem.addComponent("CO2", 0.5339); + testSystem.addComponent("methane", 95.2412); + testSystem.addComponent("ethane", 2.2029); + testSystem.addComponent("propane", 0.3231); + testSystem.addComponent("i-butane", 0.1341); + testSystem.addComponent("n-butane", 0.0827); + // testSystem.addComponent("22-dim-C3", 10.0); + // testSystem.addComponent("i-pentane", 0.0679); + // testSystem.addComponent("n-pentane", 0.0350); + // testSystem.addComponent("c-C5", 0.0291185); - // testSystem.addComponent("22-dim-C4", 0.00297); - // testSystem.addComponent("23-dim-C4", 0.00689); - // testSystem.addComponent("2-m-C5", 0.0352); - // testSystem.addComponent("3-m-C5", 0.0108); + // testSystem.addComponent("22-dim-C4", 0.00297); + // testSystem.addComponent("23-dim-C4", 0.00689); + // testSystem.addComponent("2-m-C5", 0.0352); + // testSystem.addComponent("3-m-C5", 0.0108); - // testSystem.addComponent("2-m-C5", 10.0); - // testSystem.addComponent("n-hexane", 0.0176); - // testSystem.addComponent("c-hexane", 0.0720); - // testSystem.addComponent("benzene", 0.0017); + // testSystem.addComponent("2-m-C5", 10.0); + // testSystem.addComponent("n-hexane", 0.0176); + // testSystem.addComponent("c-hexane", 0.0720); + // testSystem.addComponent("benzene", 0.0017); - // testSystem.addComponent("n-heptane", 0.0128); - // testSystem.addComponent("toluene", 0.0043); - // testSystem.addComponent("c-C7", 0.0518); - // testSystem.addComponent("n-octane", 0.0038); - // testSystem.addComponent("m-Xylene", 0.0031); - // testSystem.addComponent("c-C8", 0.0098); - // testSystem.addComponent("n-nonane", 0.0034); - // testSystem.addComponent("nC10", 0.0053); - // testSystem.addComponent("nC11", 0.0004); - /* - * testSystem.addComponent("c-hexane", 10.0); testSystem.addComponent("c-hexane", 10.0); - * testSystem.addComponent("223-TM-C4", 10.0); testSystem.addComponent("n-heptane", 10.0); - * testSystem.addComponent("n-heptane", 10.0); testSystem.addComponent("M-cy-C6", 10.0); - * testSystem.addComponent("toluene", 10.0); testSystem.addComponent("33-DM-C6", 10.0); - * testSystem.addComponent("n-octane", 10.0); testSystem.addComponent("ethylcyclohexane", - * 10.0); testSystem.addComponent("m-Xylene", 10.0); testSystem.addComponent("3-M-C8", - * 10.0); testSystem.addComponent("n-nonane", 10.0); testSystem.addComponent("n-Bcychexane", - * 10.0); testSystem.addComponent("Pent-CC6", 10.0); // testSystem.addComponent("methanol", - * 10.0); - */ - // testSystem.addComponent("water", 10.0); - // testSystem.addComponent("n-octane", 10.0); + // testSystem.addComponent("n-heptane", 0.0128); + // testSystem.addComponent("toluene", 0.0043); + // testSystem.addComponent("c-C7", 0.0518); + // testSystem.addComponent("n-octane", 0.0038); + // testSystem.addComponent("m-Xylene", 0.0031); + // testSystem.addComponent("c-C8", 0.0098); + // testSystem.addComponent("n-nonane", 0.0034); + // testSystem.addComponent("nC10", 0.0053); + // testSystem.addComponent("nC11", 0.0004); + /* + * testSystem.addComponent("c-hexane", 10.0); testSystem.addComponent("c-hexane", 10.0); + * testSystem.addComponent("223-TM-C4", 10.0); testSystem.addComponent("n-heptane", 10.0); + * testSystem.addComponent("n-heptane", 10.0); testSystem.addComponent("M-cy-C6", 10.0); + * testSystem.addComponent("toluene", 10.0); testSystem.addComponent("33-DM-C6", 10.0); + * testSystem.addComponent("n-octane", 10.0); testSystem.addComponent("ethylcyclohexane", 10.0); + * testSystem.addComponent("m-Xylene", 10.0); testSystem.addComponent("3-M-C8", 10.0); + * testSystem.addComponent("n-nonane", 10.0); testSystem.addComponent("n-Bcychexane", 10.0); + * testSystem.addComponent("Pent-CC6", 10.0); // testSystem.addComponent("methanol", 10.0); + */ + // testSystem.addComponent("water", 10.0); + // testSystem.addComponent("n-octane", 10.0); - // testSystem.addTBPfraction("C8", 1.0, 100.0 / 1000.0, 0.8); - // testSystem.addTBPfraction("LP_C17", 0.03, 238.779998779297 / 1000.0, - // 0.84325); - // testSystem.addComponent("ethane", 1.0); - // testSystem.addComponent("water", 7.0); - // testSystem.addComponent("CO2", 1.0e-10); - // testSystem.addComponent("MEG", 3.0); - // testSystem.addComponent("ethane", 0.375); - // // testSystem.addComponent("ethane", 99.9); - // testSystem.addComponent("nC27", 0.25); - testSystem.createDatabase(true); - // testSystem.setHydrateCheck(true); - // testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); - // testSystem.setMixingRule(2); - // testSystem.setMultiPhaseCheck(true); - testSystem.init(0); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + // testSystem.addTBPfraction("C8", 1.0, 100.0 / 1000.0, 0.8); + // testSystem.addTBPfraction("LP_C17", 0.03, 238.779998779297 / 1000.0, + // 0.84325); + // testSystem.addComponent("ethane", 1.0); + // testSystem.addComponent("water", 7.0); + // testSystem.addComponent("CO2", 1.0e-10); + // testSystem.addComponent("MEG", 3.0); + // testSystem.addComponent("ethane", 0.375); + // // testSystem.addComponent("ethane", 99.9); + // testSystem.addComponent("nC27", 0.25); + testSystem.createDatabase(true); + // testSystem.setHydrateCheck(true); + // testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); + // testSystem.setMixingRule(2); + // testSystem.setMultiPhaseCheck(true); + testSystem.init(0); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - // testSystem.setAttractiveTerm(13); - try { - testOps.TPflash(); - testSystem.display(); - // for (int i = 0; i < 1; i++) { - // testOps.TPflash(); - // testSystem.init(3); - // testOps.hydrateFormationTemperature(); - // testSystem.init(3); - // } - testOps.calcPTphaseEnvelope(); - testOps.displayResult(); - // testOps.bubblePointPressureFlash(false); - // testOps.dewPointTemperatureFlash(false); - // testOps.calcPTphaseEnvelope(false); + // testSystem.setAttractiveTerm(13); + try { + testOps.TPflash(); + testSystem.display(); + // for (int i = 0; i < 1; i++) { + // testOps.TPflash(); + // testSystem.init(3); + // testOps.hydrateFormationTemperature(); + // testSystem.init(3); + // } + testOps.calcPTphaseEnvelope(); + testOps.displayResult(); + // testOps.bubblePointPressureFlash(false); + // testOps.dewPointTemperatureFlash(false); + // testOps.calcPTphaseEnvelope(false); - // testOps.displayResult(); - } catch (Exception e) { - logger.error(e.toString()); - } - // System.out.println("activity coefficient water " + - // testSystem.getPhase(1).getActivityCoefficient(1)); - // testSystem.display(); - // testSystem.saveObjectToFile("C:\\Users\\esol\\AppData\\Roaming\\neqsim\\fluids\\testUMR.neqsim",""); - // testSystem.saveFluid(30); - // testSystem.saveObject(2187); + // testOps.displayResult(); + } catch (Exception e) { + logger.error(e.toString()); } + // System.out.println("activity coefficient water " + + // testSystem.getPhase(1).getActivityCoefficient(1)); + // testSystem.display(); + // testSystem.saveObjectToFile("C:\\Users\\esol\\AppData\\Roaming\\neqsim\\fluids\\testUMR.neqsim",""); + // testSystem.saveFluid(30); + // testSystem.saveObject(2187); + } } diff --git a/src/test/java/neqsim/thermo/util/example/TestUniSimsFlash.java b/src/test/java/neqsim/thermo/util/example/TestUniSimsFlash.java index 6058122fc1..9d7638f6e0 100644 --- a/src/test/java/neqsim/thermo/util/example/TestUniSimsFlash.java +++ b/src/test/java/neqsim/thermo/util/example/TestUniSimsFlash.java @@ -14,48 +14,48 @@ * @since 2.2.3 */ public class TestUniSimsFlash { - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - SystemInterface testSystem = new SystemSrkEos(288.15 + 5, 15.01325); - // SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 15.0, 25.0);// - testSystem.addComponent("CO2", 0.0214); - testSystem.addComponent("nitrogen", 0.00892); - testSystem.addComponent("methane", 0.858); - testSystem.addComponent("nC10", 0.00892); - testSystem.addComponent("water", 0.1); - - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - testSystem.setMultiPhaseCheck(true); - - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - - for (int i = 0; i < 1; i++) { - testOps.TPflash(); - } - testSystem.display(); - - double[] composition = new double[] {0.1, 0.0, 1.1, 1.0, 1.0}; - // testSystem.removeMoles(); - testSystem.setMolarComposition(composition); - testSystem.init(0); - // testSystem.setMultiPhaseCheck(true); - - for (int i = 0; i < 1; i++) { - testOps.TPflash(); - } - testSystem.display(); - - /* - * composition = new double[]{0.1, 0.0, 1.1, 1.0, 1.0}; testSystem.removeMoles(); - * testSystem.setMolarComposition(composition); for (int i = 0; i < 1; i++) { - * testOps.TPflash(); } testSystem.display(); - */ + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + SystemInterface testSystem = new SystemSrkEos(288.15 + 5, 15.01325); + // SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 15.0, 25.0); + testSystem.addComponent("CO2", 0.0214); + testSystem.addComponent("nitrogen", 0.00892); + testSystem.addComponent("methane", 0.858); + testSystem.addComponent("nC10", 0.00892); + testSystem.addComponent("water", 0.1); + + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + testSystem.setMultiPhaseCheck(true); + + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + + for (int i = 0; i < 1; i++) { + testOps.TPflash(); + } + testSystem.display(); + + double[] composition = new double[] {0.1, 0.0, 1.1, 1.0, 1.0}; + // testSystem.removeMoles(); + testSystem.setMolarComposition(composition); + testSystem.init(0); + // testSystem.setMultiPhaseCheck(true); + + for (int i = 0; i < 1; i++) { + testOps.TPflash(); } + testSystem.display(); + + /* + * composition = new double[]{0.1, 0.0, 1.1, 1.0, 1.0}; testSystem.removeMoles(); + * testSystem.setMolarComposition(composition); for (int i = 0; i < 1; i++) { testOps.TPflash(); + * } testSystem.display(); + */ + } } diff --git a/src/test/java/neqsim/thermo/util/example/longman/Problem280809LNGphaseEnvelope.java b/src/test/java/neqsim/thermo/util/example/longman/Problem280809LNGphaseEnvelope.java index 12a736c793..0663aff0d9 100644 --- a/src/test/java/neqsim/thermo/util/example/longman/Problem280809LNGphaseEnvelope.java +++ b/src/test/java/neqsim/thermo/util/example/longman/Problem280809LNGphaseEnvelope.java @@ -7,44 +7,48 @@ import neqsim.thermodynamicOperations.ThermodynamicOperations; /** - *

Problem280809LNGphaseEnvelope class.

+ *

+ * Problem280809LNGphaseEnvelope class. + *

* * @author lozhang * @version $Id: $Id * @since 2.2.3 */ public class Problem280809LNGphaseEnvelope { - static Logger logger = LogManager.getLogger(Problem280809LNGphaseEnvelope.class); + static Logger logger = LogManager.getLogger(Problem280809LNGphaseEnvelope.class); - /** - *

main.

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - SystemInterface testSystem = new SystemGERG2004Eos(230, 50.00); - testSystem.addComponent("methane", 0.80); - testSystem.addComponent("ethane", 0.05); - testSystem.addComponent("propane", 0.03); - testSystem.addComponent("CO2", 0.06); - testSystem.addComponent("nitrogen", 0.05); - // testSystem.addComponent("benzene",0.01); + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + SystemInterface testSystem = new SystemGERG2004Eos(230, 50.00); + testSystem.addComponent("methane", 0.80); + testSystem.addComponent("ethane", 0.05); + testSystem.addComponent("propane", 0.03); + testSystem.addComponent("CO2", 0.06); + testSystem.addComponent("nitrogen", 0.05); + // testSystem.addComponent("benzene",0.01); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - try { - testOps.calcPTphaseEnvelope(true);// 0.05, 0.000005); - testOps.displayResult(); - } catch (Exception e) { - logger.error("error", e); - } - testSystem.display(); - // System.out.println("tempeerature " + (testSystem.getTemperature() - 273.15)); - // testOps.displayResult(); - // System.out.println("Cricondenbar " + testOps.get("cricondenbar")[0] + " " + - // testOps.get("cricondenbar")[1]); + try { + testOps.calcPTphaseEnvelope(true); // 0.05, 0.000005); + testOps.displayResult(); + } catch (Exception e) { + logger.error("error", e); } + testSystem.display(); + // System.out.println("tempeerature " + (testSystem.getTemperature() - 273.15)); + // testOps.displayResult(); + // System.out.println("Cricondenbar " + testOps.get("cricondenbar")[0] + " " + + // testOps.get("cricondenbar")[1]); + } } diff --git a/src/test/java/neqsim/thermodynamicOperations/util/example/CompGradientFlash.java b/src/test/java/neqsim/thermodynamicOperations/util/example/CompGradientFlash.java index 3dccae1cd8..e712167995 100644 --- a/src/test/java/neqsim/thermodynamicOperations/util/example/CompGradientFlash.java +++ b/src/test/java/neqsim/thermodynamicOperations/util/example/CompGradientFlash.java @@ -16,45 +16,47 @@ * @since 2.2.3 */ public class CompGradientFlash { - static Logger logger = LogManager.getLogger(CompGradientFlash.class); - - /** - *

main.

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - SystemInterface testSystem = new SystemSrkEos(273.15 + 0, 80.0);// 30.01325); - - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - testSystem.addComponent("methane", 11.0); - // testSystem.addComponent("ethane", 4.0); - testSystem.addComponent("n-heptane", 0.03); - // testSystem.addComponent("n-octane", 0.0001); - - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - - testSystem.init(0); - testSystem.init(3); - logger.info("enthalpy " + testSystem.getPhase(1).getEnthalpy()); - - SystemInterface newSystem = null; - try { - testOps.dewPointTemperatureFlash(); - testSystem.display(); - double dewTemp = testSystem.getTemperature(); - testSystem.setTemperature(dewTemp + 10.1); - testSystem.init(0); - newSystem = testOps.TPgradientFlash(0.0001, dewTemp).phaseToSystem(0); - newSystem.init(0); - ThermodynamicOperations testOps2 = new ThermodynamicOperations(newSystem); - testOps2.dewPointTemperatureFlash(); - newSystem.display(); - - // testSystem.display(); - } catch (Exception e) { - logger.error(e.toString()); - } + static Logger logger = LogManager.getLogger(CompGradientFlash.class); + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + SystemInterface testSystem = new SystemSrkEos(273.15 + 0, 80.0); // 30.01325); + + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testSystem.addComponent("methane", 11.0); + // testSystem.addComponent("ethane", 4.0); + testSystem.addComponent("n-heptane", 0.03); + // testSystem.addComponent("n-octane", 0.0001); + + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + + testSystem.init(0); + testSystem.init(3); + logger.info("enthalpy " + testSystem.getPhase(1).getEnthalpy()); + + SystemInterface newSystem = null; + try { + testOps.dewPointTemperatureFlash(); + testSystem.display(); + double dewTemp = testSystem.getTemperature(); + testSystem.setTemperature(dewTemp + 10.1); + testSystem.init(0); + newSystem = testOps.TPgradientFlash(0.0001, dewTemp).phaseToSystem(0); + newSystem.init(0); + ThermodynamicOperations testOps2 = new ThermodynamicOperations(newSystem); + testOps2.dewPointTemperatureFlash(); + newSystem.display(); + + // testSystem.display(); + } catch (Exception e) { + logger.error(e.toString()); } + } }