From ec36cf4134ad68158aa9ada70d13fe6dc85513c9 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 Nov 2024 15:15:53 +0100 Subject: [PATCH] refact: getPhases()[k] -> getPhase(k) --- .../ChemicalReactionOperations.java | 2 +- .../ChemicalEquilibrium.java | 8 +- .../LinearProgrammingChemicalEquilibrium.java | 2 +- .../chemicalreaction/ChemicalReaction.java | 4 +- .../ChemicalReactionList.java | 8 +- .../fluidmechanics/flownode/FlowNode.java | 82 ++-- .../heatmasstransfercalc/FluidBoundary.java | 36 +- .../EquilibriumFluidBoundary.java | 2 +- .../FluidBoundarySolver.java | 81 ++-- .../NonEquilibriumFluidBoundary.java | 382 +++++++++--------- .../KrishnaStandartFilmModel.java | 22 +- .../ReactiveFluidBoundary.java | 364 ++++++++--------- .../enhancementfactor/EnhancementFactor.java | 8 +- .../InterphasePipeFlow.java | 5 +- .../InterphaseStirredCellFlow.java | 11 +- .../multiphasenode/MultiPhaseFlowNode.java | 74 ++-- .../waxnode/WaxDepositionFlowNode.java | 6 +- .../onephasenode/onePhaseFlowNode.java | 34 +- .../onePhasePipeFlowNode.java | 2 +- .../twophasenode/TwoPhaseFlowNode.java | 88 ++-- .../twophasepipeflownode/AnnularFlow.java | 6 +- .../twophasepipeflownode/BubbleFlowNode.java | 6 +- .../twophasepipeflownode/DropletFlowNode.java | 6 +- .../StratifiedFlowNode.java | 6 +- .../TwoPhasePackedBedFlowNode.java | 20 +- .../TwoPhaseTrayTowerFlowNode.java | 10 +- .../StirredCellNode.java | 20 +- .../OnePhaseFixedStaggeredGrid.java | 141 ++++--- .../OnePhasePipeFlowSolver.java | 5 +- .../stirredcellsolver/StirredCellSolver.java | 62 ++- .../TwoPhaseFixedStaggeredGridSolver.java | 82 ++-- .../TwoPhasePipeFlowSolver.java | 4 +- .../fluidmechanics/flowsystem/FlowSystem.java | 6 +- .../FlowNodeVisualization.java | 10 +- .../OnePhasePipeFlowNodeVisualization.java | 6 +- .../TwoPhaseFlowNodeVisualization.java | 25 +- .../nonlinearsolver/SysNewtonRhapson.java | 47 ++- .../FirozabadiRamleyInterfaceTension.java | 14 +- .../ParachorSurfaceTension.java | 19 +- .../ParachorFunction.java | 4 +- .../chungmethod/ChungFunction.java | 6 +- .../linearliquidmodel/ViscosityFunction.java | 6 +- .../equipment/absorber/SimpleTEGAbsorber.java | 107 +++-- .../absorber/WaterStripperColumn.java | 107 +++-- .../equipment/compressor/Compressor.java | 245 ++++++----- .../equipment/expander/ExpanderOld.java | 86 ++-- .../equipment/heatexchanger/Heater.java | 12 +- .../neqsim/process/equipment/mixer/Mixer.java | 87 ++-- .../process/equipment/mixer/StaticMixer.java | 20 +- .../equipment/mixer/StaticNeqMixer.java | 18 +- .../equipment/mixer/StaticPhaseMixer.java | 16 +- .../neqsim/process/equipment/pump/Pump.java | 86 ++-- .../equipment/separator/Hydrocyclone.java | 2 +- .../equipment/separator/NeqGasScrubber.java | 8 +- .../equipment/separator/Separator.java | 4 +- .../separator/ThreePhaseSeparator.java | 2 +- .../separator/TwoPhaseSeparator.java | 8 +- .../neqsim/process/equipment/tank/Tank.java | 4 +- src/main/java/neqsim/standards/Standard.java | 10 +- .../standards/gasquality/Draft_GERG2004.java | 28 +- .../gasquality/Standard_ISO6976.java | 96 +++-- .../WettedWallColumnSampleCreator.java | 6 +- .../neqsim/thermo/ThermodynamicModelTest.java | 106 ++--- .../thermo/mixingrule/EosMixingRules.java | 2 +- .../neqsim/thermo/system/SystemThermo.java | 262 ++++++------ .../ThermodynamicOperations.java | 2 +- .../flashops/Flash.java | 89 ++-- .../flashops/PHflash.java | 2 +- .../flashops/PHflashSingleComp.java | 2 +- .../flashops/PSFlash.java | 2 +- .../flashops/QfuncFlash.java | 15 +- .../flashops/SolidFlash.java | 21 +- .../flashops/SolidFlash1.java | 55 ++- .../flashops/SolidFlash12.java | 37 +- .../flashops/SysNewtonRhapsonPHflash.java | 8 +- .../flashops/SysNewtonRhapsonTPflashNew.java | 52 +-- .../flashops/TPflash.java | 22 +- .../flashops/TPgradientFlash.java | 22 +- .../flashops/TPmultiflash.java | 128 +++--- .../flashops/TPmultiflashWAX.java | 6 +- .../flashops/TPmultiflash_1.java | 108 ++--- .../BubblePointPressureFlash.java | 69 ++-- .../BubblePointPressureFlashDer.java | 83 ++-- .../BubblePointTemperatureFlash.java | 46 +-- .../BubblePointTemperatureNoDer.java | 61 ++- .../saturationops/ConstantDutyFlash.java | 46 +-- .../ConstantDutyPressureFlash.java | 33 +- .../ConstantDutyTemperatureFlash.java | 43 +- .../saturationops/CricondebarFlash.java | 40 +- .../saturationops/CricondenBarTemp.java | 33 +- .../saturationops/CricondenBarTemp1.java | 29 +- .../saturationops/DewPointPressureFlash.java | 53 ++- .../DewPointTemperatureFlash.java | 65 ++- .../DewPointTemperatureFlashDer.java | 76 ++-- .../flashops/saturationops/FreezeOut.java | 10 +- .../FreezingPointTemperatureFlash.java | 14 +- .../FreezingPointTemperatureFlashOld.java | 24 +- .../FreezingPointTemperatureFlashTR.java | 29 +- .../flashops/saturationops/FugTestConstP.java | 8 +- .../HCdewPointPressureFlash.java | 53 ++- .../SolidComplexTemperatureCalc.java | 14 +- .../flashops/saturationops/WATcalc.java | 6 +- .../WaterDewPointTemperatureFlash.java | 26 +- .../PTphaseEnvelope.java | 2 +- .../PTphaseEnvelopeMay.java | 2 +- .../PTphaseEnvelopeNew2.java | 2 +- .../reactivecurves/PloadingCurve.java | 30 +- .../reactivecurves/PloadingCurve2.java | 32 +- .../separator/ThreePhaseSeparatorTest.java | 69 ++-- .../processmodel/GlycolModulesTest.java | 56 +-- 110 files changed, 2316 insertions(+), 2363 deletions(-) diff --git a/src/main/java/neqsim/chemicalreactions/ChemicalReactionOperations.java b/src/main/java/neqsim/chemicalreactions/ChemicalReactionOperations.java index be76c0176..faebb1a9f 100644 --- a/src/main/java/neqsim/chemicalreactions/ChemicalReactionOperations.java +++ b/src/main/java/neqsim/chemicalreactions/ChemicalReactionOperations.java @@ -178,7 +178,7 @@ public void setReactiveComponents() { if (name.equals(allComponentNames[i])) { components[k++] = system.getPhase(phase).getComponent(j); // System.out.println("reactive comp " + - // system.getPhases()[1].getComponent(j).getName()); + // system.getPhase(1).getComponent(j).getName()); } } } diff --git a/src/main/java/neqsim/chemicalreactions/chemicalequilibrium/ChemicalEquilibrium.java b/src/main/java/neqsim/chemicalreactions/chemicalequilibrium/ChemicalEquilibrium.java index 62499ec23..061c4804f 100644 --- a/src/main/java/neqsim/chemicalreactions/chemicalequilibrium/ChemicalEquilibrium.java +++ b/src/main/java/neqsim/chemicalreactions/chemicalequilibrium/ChemicalEquilibrium.java @@ -411,10 +411,10 @@ public double 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() + // Math.log(system.getPhase(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() + // Math.log(system.getPhase(1).getComponents()[components[i].getComponentNumber()].getFugacityCoefficient() // / chem_pot_pure[i])); if (system.getPhase(phasenumb).getComponents()[components[i].getComponentNumber()] @@ -426,7 +426,7 @@ public double step() { - 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() + // system.getPhase(1).getComponents()[components[i].getComponentNumber()].getFugacityCoefficient() // / chem_pot_pure[i]); } else { chem_pot[i] = R * system.getPhase(phasenumb).getTemperature() @@ -436,7 +436,7 @@ public double step() { - 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() + // system.getPhase(1).getComponents()[components[i].getComponentNumber()].getFugacityCoefficient() // / chem_pot_dilute[i]); } chem_pot_omega[i] = R * system.getPhase(phasenumb).getTemperature() diff --git a/src/main/java/neqsim/chemicalreactions/chemicalequilibrium/LinearProgrammingChemicalEquilibrium.java b/src/main/java/neqsim/chemicalreactions/chemicalequilibrium/LinearProgrammingChemicalEquilibrium.java index bdf101c55..b128ab060 100644 --- a/src/main/java/neqsim/chemicalreactions/chemicalequilibrium/LinearProgrammingChemicalEquilibrium.java +++ b/src/main/java/neqsim/chemicalreactions/chemicalequilibrium/LinearProgrammingChemicalEquilibrium.java @@ -280,7 +280,7 @@ public void changePrimaryComponents() { * * double[] nEts = new double[atemp.getColumnDimension()]; double totm=0.0; for(int * k=0;k */ public void initMatrix() { - for (int j = 0; j < boundary.getNode(0).getBulkSystem().getPhases()[0] + for (int j = 0; j < boundary.getNode(0).getBulkSystem().getPhase(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].getComponent(j).getx()); + boundary.getNode(i).getBulkSystem().getPhase(1).getComponent(j).getx()); } } } @@ -144,12 +143,12 @@ public void initMatrix() { */ public void initComposition(int iter) { for (int j = 0; j < boundary.getNumberOfNodes(); j++) { - for (int p = 0; p < boundary.getNode(0).getBulkSystem().getPhases()[0] + for (int p = 0; p < boundary.getNode(0).getBulkSystem().getPhase(0) .getNumberOfComponents(); p++) { - boundary.getNode(j).getBulkSystem().getPhases()[1].getComponent(p) + boundary.getNode(j).getBulkSystem().getPhase(1).getComponent(p) .setx(solMatrix[p].get(j, 0)); } - boundary.getNode(j).getBulkSystem().getPhases()[0].normalize(); + boundary.getNode(j).getBulkSystem().getPhase(0).normalize(); boundary.getNode(j).getBulkSystem().init(3); } } @@ -163,8 +162,8 @@ public void initComposition(int iter) { */ 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() + boundary.getNode(i).getBulkSystem().getPhase(1).initPhysicalProperties(); + boundary.getNode(i).getBulkSystem().getPhase(1).getPhysicalProperties() .calcEffectiveDiffusionCoefficients(); // if(reactive) // boundary.getNode(i).getBulkSystem().getChemicalReactionOperations().calcReacRates(1); @@ -172,23 +171,22 @@ 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(); - r[0] = - boundary.getNode(0).getBulkSystem().getPhases()[1].getComponents()[componentNumber].getx(); + b[0] = 1.0; // boundary.getNode(0).getBulkSystem().getPhase(1).getComponents()[componentNumber].getx(); + r[0] = boundary.getNode(0).getBulkSystem().getPhase(1).getComponents()[componentNumber].getx(); System.out.println("b0 :" + b[0]); // setter ligningen paa rett form a[0] = -a[0]; c[0] = -c[0]; for (int i = 1; i < boundary.getNumberOfNodes() - 1; i++) { - double Dw = (boundary.getNode(i - 1).getBulkSystem().getPhases()[1].getPhysicalProperties() + double Dw = (boundary.getNode(i - 1).getBulkSystem().getPhase(1).getPhysicalProperties() .getEffectiveDiffusionCoefficient(componentNumber) - + boundary.getNode(i).getBulkSystem().getPhases()[1].getPhysicalProperties() + + boundary.getNode(i).getBulkSystem().getPhase(1).getPhysicalProperties() .getEffectiveDiffusionCoefficient(componentNumber)) / 2.0; - double De = (boundary.getNode(i).getBulkSystem().getPhases()[1].getPhysicalProperties() + double De = (boundary.getNode(i).getBulkSystem().getPhase(1).getPhysicalProperties() .getEffectiveDiffusionCoefficient(componentNumber) - + boundary.getNode(i + 1).getBulkSystem().getPhases()[1].getPhysicalProperties() + + boundary.getNode(i + 1).getBulkSystem().getPhase(1).getPhysicalProperties() .getEffectiveDiffusionCoefficient(componentNumber)) / 2.0; @@ -205,9 +203,8 @@ 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(); - r[i] = - boundary.getNode(i).getBulkSystem().getPhases()[1].getComponents()[componentNumber].getx(); + b[i] = 1.0; // boundary.getNode(i).getBulkSystem().getPhase(1).getComponents()[componentNumber].getx(); + r[i] = boundary.getNode(i).getBulkSystem().getPhase(1).getComponents()[componentNumber].getx(); System.out.println("bn :" + b[i]); // setter ligningen paa rett form a[i] = -a[i]; @@ -222,11 +219,10 @@ public double getMolarFlux(int componentNumber) { temp = 2.1; } return temp - * boundary.getNode(0).getBulkSystem().getPhases()[1].getPhysicalProperties() + * boundary.getNode(0).getBulkSystem().getPhase(1).getPhysicalProperties() .getEffectiveDiffusionCoefficient(componentNumber) - * (boundary.getNode(0).getBulkSystem().getPhases()[1].getComponents()[componentNumber] - .getx() - - boundary.getNode(1).getBulkSystem().getPhases()[1].getComponents()[componentNumber] + * (boundary.getNode(0).getBulkSystem().getPhase(1).getComponents()[componentNumber].getx() + - boundary.getNode(1).getBulkSystem().getPhase(1).getComponents()[componentNumber] .getx()) / boundary.getNodeLength(); } @@ -238,14 +234,13 @@ public void solve() { // double maxDiffOld = 0; double diff = 0; - xNew = new double[boundary.getNode(0).getBulkSystem().getPhases()[0] + xNew = new double[boundary.getNode(0).getBulkSystem().getPhase(0) .getNumberOfComponents()][boundary.getNumberOfNodes()]; initProfiles(); initMatrix(); initComposition(1); - System.out - .println(" vol " + boundary.getNode(2).getBulkSystem().getPhases()[0].getMolarVolume()); + System.out.println(" vol " + boundary.getNode(2).getBulkSystem().getPhase(0).getMolarVolume()); int iter = 0; int iterTop = 0; @@ -258,7 +253,7 @@ public void solve() { do { iter++; - for (int p = 0; p < boundary.getNode(0).getBulkSystem().getPhases()[1] + for (int p = 0; p < boundary.getNode(0).getBulkSystem().getPhase(1) .getNumberOfComponents(); p++) { setComponentConservationMatrix(p); Matrix solOld = solMatrix[p].copy(); 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 32a161670..f946897d0 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 @@ -35,23 +35,22 @@ public abstract class NonEquilibriumFluidBoundary */ public NonEquilibriumFluidBoundary(SystemInterface system) { super(system); - neq = 3 * bulkSystem.getPhases()[0].getNumberOfComponents(); + neq = 3 * bulkSystem.getPhase(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); + new Matrix(getBulkSystem().getPhase(0).getNumberOfComponents() - 1, + getBulkSystem().getPhase(0).getNumberOfComponents() - 1); massTransferCoefficientMatrix[1] = - new Matrix(getBulkSystem().getPhases()[0].getNumberOfComponents() - 1, - getBulkSystem().getPhases()[0].getNumberOfComponents() - 1); + new Matrix(getBulkSystem().getPhase(0).getNumberOfComponents() - 1, + getBulkSystem().getPhase(0).getNumberOfComponents() - 1); totalMassTransferCoefficientMatrix[0] = - new Matrix(getBulkSystem().getPhases()[0].getNumberOfComponents() - 1, - getBulkSystem().getPhases()[0].getNumberOfComponents() - 1); + new Matrix(getBulkSystem().getPhase(0).getNumberOfComponents() - 1, + getBulkSystem().getPhase(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]; + new Matrix(getBulkSystem().getPhase(0).getNumberOfComponents() - 1, + getBulkSystem().getPhase(0).getNumberOfComponents() - 1); + molFractionDifference = new double[2][getBulkSystem().getPhase(0).getNumberOfComponents() - 1]; // interphaseSystem = bulkSystem.clone(); // interphaseOps = new ThermodynamicOperations(interphaseSystem); // interphaseOps.TPflash(); @@ -67,24 +66,23 @@ public NonEquilibriumFluidBoundary(SystemInterface system) { */ public NonEquilibriumFluidBoundary(FlowNodeInterface flowNode) { super(flowNode); - neq = 3 * bulkSystem.getPhases()[0].getNumberOfComponents(); + neq = 3 * bulkSystem.getPhase(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); + new Matrix(getBulkSystem().getPhase(0).getNumberOfComponents() - 1, + getBulkSystem().getPhase(0).getNumberOfComponents() - 1); massTransferCoefficientMatrix[1] = - new Matrix(getBulkSystem().getPhases()[0].getNumberOfComponents() - 1, - getBulkSystem().getPhases()[0].getNumberOfComponents() - 1); + new Matrix(getBulkSystem().getPhase(0).getNumberOfComponents() - 1, + getBulkSystem().getPhase(0).getNumberOfComponents() - 1); totalMassTransferCoefficientMatrix[0] = - new Matrix(getBulkSystem().getPhases()[0].getNumberOfComponents() - 1, - getBulkSystem().getPhases()[0].getNumberOfComponents() - 1); + new Matrix(getBulkSystem().getPhase(0).getNumberOfComponents() - 1, + getBulkSystem().getPhase(0).getNumberOfComponents() - 1); totalMassTransferCoefficientMatrix[1] = - new Matrix(getBulkSystem().getPhases()[0].getNumberOfComponents() - 1, - getBulkSystem().getPhases()[0].getNumberOfComponents() - 1); + new Matrix(getBulkSystem().getPhase(0).getNumberOfComponents() - 1, + getBulkSystem().getPhase(0).getNumberOfComponents() - 1); // interphaseSystem = bulkSystem.clone(); - molFractionDifference = - new double[2][getBulkSystem().getPhases()[0].getNumberOfComponents() - 1]; + molFractionDifference = new double[2][getBulkSystem().getPhase(0).getNumberOfComponents() - 1]; // interphaseOps = new ThermodynamicOperations(interphaseSystem); // interphaseOps.TPflash(); // // interphaseOps.displayResult(); @@ -112,35 +110,35 @@ public NonEquilibriumFluidBoundary clone() { public void setfvecMassTrans() { double sumx = 0; double sumy = 0; - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfComponents(); i++) { fvec.set(i, 0, - Math.log((interphaseSystem.getPhases()[0].getComponent(i).getFugacityCoefficient() - * interphaseSystem.getPhases()[0].getComponent(i).getx())) - - Math.log((interphaseSystem.getPhases()[1].getComponent(i).getFugacityCoefficient() - * interphaseSystem.getPhases()[1].getComponent(i).getx()))); - sumx += interphaseSystem.getPhases()[0].getComponent(i).getx(); - sumy += interphaseSystem.getPhases()[1].getComponent(i).getx(); + Math.log((interphaseSystem.getPhase(0).getComponent(i).getFugacityCoefficient() + * interphaseSystem.getPhase(0).getComponent(i).getx())) + - Math.log((interphaseSystem.getPhase(1).getComponent(i).getFugacityCoefficient() + * interphaseSystem.getPhase(1).getComponent(i).getx()))); + sumx += interphaseSystem.getPhase(0).getComponent(i).getx(); + sumy += interphaseSystem.getPhase(1).getComponent(i).getx(); } - fvec.set(bulkSystem.getPhases()[0].getNumberOfComponents() - 1, 0, 1.0 - sumx); - fvec.set(bulkSystem.getPhases()[0].getNumberOfComponents(), 0, 1.0 - sumy); + fvec.set(bulkSystem.getPhase(0).getNumberOfComponents() - 1, 0, 1.0 - sumx); + fvec.set(bulkSystem.getPhase(0).getNumberOfComponents(), 0, 1.0 - sumy); - for (int i = bulkSystem.getPhases()[0].getNumberOfComponents() + 1; i < (2 - * bulkSystem.getPhases()[0].getNumberOfComponents()); i++) { + for (int i = bulkSystem.getPhase(0).getNumberOfComponents() + 1; i < (2 + * bulkSystem.getPhase(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()) + i - (bulkSystem.getPhase(0).getNumberOfComponents() + 1), + i - (bulkSystem.getPhase(0).getNumberOfComponents() + 1)) + * (bulkSystem.getPhase(0).getComponents()[i + - (bulkSystem.getPhase(0).getNumberOfComponents() + 1)].getx() + - interphaseSystem.getPhase(0).getComponents()[i + - (bulkSystem.getPhase(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())))); + i - (bulkSystem.getPhase(0).getNumberOfComponents() + 1), + i - (bulkSystem.getPhase(0).getNumberOfComponents() + 1)) + * (bulkSystem.getPhase(1).getComponents()[i + - (bulkSystem.getPhase(0).getNumberOfComponents() + 1)].getx() + - interphaseSystem.getPhase(1).getComponents()[i + - (bulkSystem.getPhase(0).getNumberOfComponents() + 1)].getx())))); } } @@ -152,46 +150,46 @@ public void setfvecMassTrans() { public void setfvecMassTrans2() { double sumx = 0.0; double sumy = 0.0; - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfComponents(); i++) { fvec.set(i, 0, - Math.log((interphaseSystem.getPhases()[0].getComponent(i).getFugacityCoefficient() - * interphaseSystem.getPhases()[0].getComponent(i).getx())) - - Math.log((interphaseSystem.getPhases()[1].getComponent(i).getFugacityCoefficient() - * interphaseSystem.getPhases()[1].getComponent(i).getx()))); - sumx += interphaseSystem.getPhases()[1].getComponent(i).getx(); - sumy += interphaseSystem.getPhases()[0].getComponent(i).getx(); + Math.log((interphaseSystem.getPhase(0).getComponent(i).getFugacityCoefficient() + * interphaseSystem.getPhase(0).getComponent(i).getx())) + - Math.log((interphaseSystem.getPhase(1).getComponent(i).getFugacityCoefficient() + * interphaseSystem.getPhase(1).getComponent(i).getx()))); + sumx += interphaseSystem.getPhase(1).getComponent(i).getx(); + sumy += interphaseSystem.getPhase(0).getComponent(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].getComponent(i).getx() - - interphaseSystem.getPhases()[0].getComponent(i).getx())); - dx.set(0, i, (bulkSystem.getPhases()[1].getComponent(i).getx() - - interphaseSystem.getPhases()[1].getComponent(i).getx())); - y.set(0, i, (bulkSystem.getPhases()[0].getComponent(i).getx())); - x.set(0, i, (bulkSystem.getPhases()[1].getComponent(i).getx())); + fvec.set(bulkSystem.getPhase(0).getNumberOfComponents(), 0, 1.0 - sumx); + fvec.set(bulkSystem.getPhase(0).getNumberOfComponents() + 1, 0, 1.0 - sumy); + + Matrix dx = new Matrix(1, bulkSystem.getPhase(0).getNumberOfComponents() - 1); + Matrix dy = new Matrix(1, bulkSystem.getPhase(0).getNumberOfComponents() - 1); + Matrix x = new Matrix(1, bulkSystem.getPhase(0).getNumberOfComponents() - 1); + Matrix y = new Matrix(1, bulkSystem.getPhase(0).getNumberOfComponents() - 1); + + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfComponents() - 1; i++) { + dy.set(0, i, (bulkSystem.getPhase(0).getComponent(i).getx() + - interphaseSystem.getPhase(0).getComponent(i).getx())); + dx.set(0, i, (bulkSystem.getPhase(1).getComponent(i).getx() + - interphaseSystem.getPhase(1).getComponent(i).getx())); + y.set(0, i, (bulkSystem.getPhase(0).getComponent(i).getx())); + x.set(0, i, (bulkSystem.getPhase(1).getComponent(i).getx())); } Matrix fluxX = totalMassTransferCoefficientMatrix[1].times(dx.transpose()) - .times(bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[1].getMolarMass()); + .times(bulkSystem.getPhase(1).getPhysicalProperties().getDensity() + / bulkSystem.getPhase(1).getMolarMass()); Matrix fluxY = totalMassTransferCoefficientMatrix[0].times(dy.transpose()) - .times(bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[0].getMolarMass()); + .times(bulkSystem.getPhase(0).getPhysicalProperties().getDensity() + / bulkSystem.getPhase(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); + // nFlux.getMatrix(0,bulkSystem.getPhase(1).getNumberOfComponents()-2,0,0).print(10,10); // System.out.println("j gas flux"); // fluxY.print(10,10); // System.out.println("j gliq flux"); @@ -201,16 +199,16 @@ public void setfvecMassTrans2() { // 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) + Matrix errX = nFlux.getMatrix(0, bulkSystem.getPhase(1).getNumberOfComponents() - 2, 0, 0) .plus(fluxX).minus(x.transpose().times(totalFlux)); - Matrix errY = nFlux.getMatrix(0, bulkSystem.getPhases()[0].getNumberOfComponents() - 2, 0, 0) + Matrix errY = nFlux.getMatrix(0, bulkSystem.getPhase(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)); + for (int i = bulkSystem.getPhase(0).getNumberOfComponents() + + 2; i < (2 * bulkSystem.getPhase(0).getNumberOfComponents() + 1); i++) { + fvec.set(i, 0, errX.get((i - (bulkSystem.getPhase(0).getNumberOfComponents() + 2)), 0)); + fvec.set((i + (bulkSystem.getPhase(0).getNumberOfComponents() - 1)), 0, + errY.get((i - (bulkSystem.getPhase(0).getNumberOfComponents() + 2)), 0)); } /* @@ -231,60 +229,60 @@ public void setJacMassTrans() { 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++) { + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfComponents() - 1; i++) { + for (int j = 0; j < bulkSystem.getPhase(0).getNumberOfComponents(); j++) { dij = i == j ? 1.0 : 0.0; // Kroneckers delta - tempJ = dij * 1.0 / interphaseSystem.getPhases()[0].getComponent(i).getx() - + interphaseSystem.getPhases()[0].getComponent(i).getdfugdx(j); + tempJ = dij * 1.0 / interphaseSystem.getPhase(0).getComponent(i).getx() + + interphaseSystem.getPhase(0).getComponent(i).getdfugdx(j); // tempJ= - // dij*interphaseSystem.getPhases()[0].getComponent(i).getFugacityCoefficient()+interphaseSystem.getPhases()[0].getComponent(i).getx()*interphaseSystem.getPhases()[0].getComponent(i).getdfugdx(j); + // dij*interphaseSystem.getPhase(0).getComponent(i).getFugacityCoefficient()+interphaseSystem.getPhase(0).getComponent(i).getx()*interphaseSystem.getPhase(0).getComponent(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.getPhase(0).getNumberOfComponents(); i++) { + Jac.set(bulkSystem.getPhase(0).getNumberOfComponents() - 1, i, -1.0); + Jac.set(bulkSystem.getPhase(0).getNumberOfComponents() - 1, + bulkSystem.getPhase(0).getNumberOfComponents() + i, 0.0); + Jac.set(bulkSystem.getPhase(0).getNumberOfComponents(), i, 0.0); + Jac.set(bulkSystem.getPhase(0).getNumberOfComponents(), + bulkSystem.getPhase(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++) { + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfComponents() - 1; i++) { + for (int j = 0; j < bulkSystem.getPhase(0).getNumberOfComponents(); j++) { dij = i == j ? 1.0 : 0.0; // Kroneckers delta - tempJ = dij * 1.0 / interphaseSystem.getPhases()[1].getComponent(i).getx() - + interphaseSystem.getPhases()[1].getComponent(i).getdfugdx(j); + tempJ = dij * 1.0 / interphaseSystem.getPhase(1).getComponent(i).getx() + + interphaseSystem.getPhase(1).getComponent(i).getdfugdx(j); // tempJ= - // dij*interphaseSystem.getPhases()[1].getComponent(i).getFugacityCoefficient()+interphaseSystem.getPhases()[1].getComponent(i).getx()*interphaseSystem.getPhases()[1].getComponent(i).getdfugdx(j); - Jac.set(i, j + bulkSystem.getPhases()[0].getNumberOfComponents(), -tempJ); + // dij*interphaseSystem.getPhase(1).getComponent(i).getFugacityCoefficient()+interphaseSystem.getPhase(1).getComponent(i).getx()*interphaseSystem.getPhase(1).getComponent(i).getdfugdx(j); + Jac.set(i, j + bulkSystem.getPhase(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; + for (int i = bulkSystem.getPhase(0).getNumberOfComponents(); i < 2 + * bulkSystem.getPhase(0).getNumberOfComponents() - 1; i++) { + for (int j = 0; j < bulkSystem.getPhase(0).getNumberOfComponents(); j++) { + dij = i == (j + bulkSystem.getPhase(0).getNumberOfComponents()) ? 1.0 : 0.0; tempJ = -dij * (totalMassTransferCoefficientMatrix[1].get( - i - bulkSystem.getPhases()[0].getNumberOfComponents(), - i - bulkSystem.getPhases()[0].getNumberOfComponents())); + i - bulkSystem.getPhase(0).getNumberOfComponents(), + i - bulkSystem.getPhase(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++) { + for (int i = bulkSystem.getPhase(0).getNumberOfComponents(); i < 2 + * bulkSystem.getPhase(0).getNumberOfComponents() - 1; i++) { + for (int j = bulkSystem.getPhase(0).getNumberOfComponents(); j < 2 + * bulkSystem.getPhase(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())); + i - bulkSystem.getPhase(0).getNumberOfComponents(), + i - bulkSystem.getPhase(0).getNumberOfComponents())); Jac.set(i + 1, j, tempJ); } } @@ -300,81 +298,81 @@ public void setJacMassTrans2() { 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++) { + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfComponents(); i++) { + for (int j = 0; j < bulkSystem.getPhase(0).getNumberOfComponents(); j++) { dij = i == j ? 1.0 : 0.0; // Kroneckers delta - tempJ = dij * 1.0 / interphaseSystem.getPhases()[0].getComponent(i).getx() - + interphaseSystem.getPhases()[0].getComponent(i).getdfugdx(j); + tempJ = dij * 1.0 / interphaseSystem.getPhase(0).getComponent(i).getx() + + interphaseSystem.getPhase(0).getComponent(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.getPhase(0).getNumberOfComponents(); i++) { + Jac.set(bulkSystem.getPhase(0).getNumberOfComponents(), i, 0.0); + Jac.set(bulkSystem.getPhase(0).getNumberOfComponents(), + bulkSystem.getPhase(0).getNumberOfComponents() + i, -1.0); + Jac.set(bulkSystem.getPhase(0).getNumberOfComponents() + 1, i, -1.0); + Jac.set(bulkSystem.getPhase(0).getNumberOfComponents() + 1, + bulkSystem.getPhase(0).getNumberOfComponents() + i, 0.0); } - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { - for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfComponents(); j++) { + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfComponents(); i++) { + for (int j = 0; j < bulkSystem.getPhase(0).getNumberOfComponents(); j++) { dij = i == j ? 1.0 : 0.0; // Kroneckers delta - tempJ = dij * 1.0 / interphaseSystem.getPhases()[1].getComponent(i).getx() - + interphaseSystem.getPhases()[1].getComponent(i).getdfugdx(j); - Jac.set(i, j + bulkSystem.getPhases()[0].getNumberOfComponents(), -tempJ); + tempJ = dij * 1.0 / interphaseSystem.getPhase(1).getComponent(i).getx() + + interphaseSystem.getPhase(1).getComponent(i).getdfugdx(j); + Jac.set(i, j + bulkSystem.getPhase(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; + for (int i = bulkSystem.getPhase(0).getNumberOfComponents(); i < 2 + * bulkSystem.getPhase(0).getNumberOfComponents() - 1; i++) { + for (int j = 0; j < bulkSystem.getPhase(0).getNumberOfComponents(); j++) { + dij = i == (j + bulkSystem.getPhase(0).getNumberOfComponents()) ? 1.0 : 0.0; // tempJ = - // -dij*(totalMassTransferCoefficientMatrix[1].get(i-bulkSystem.getPhases()[0].getNumberOfComponents(), - // i-bulkSystem.getPhases()[0].getNumberOfComponents())); + // -dij*(totalMassTransferCoefficientMatrix[1].get(i-bulkSystem.getPhase(0).getNumberOfComponents(), + // i-bulkSystem.getPhase(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[0].getRowSum(i-bulkSystem.getPhase(0).getNumberOfComponents()); + // Jac.set(i+2,j+2*bulkSystem.getPhase(0).getNumberOfComponents()-1, - + // interphaseSystem.getPhase(0).getComponents()[i-bulkSystem.getPhase(0).getNumberOfComponents()].getx()); + if (j != bulkSystem.getPhase(0).getNumberOfComponents() - 1) { + Jac.set(i + 2, j + bulkSystem.getPhase(0).getNumberOfComponents(), -totalMassTransferCoefficientMatrix[1] - .get(i - bulkSystem.getPhases()[0].getNumberOfComponents(), j) - * bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[1].getMolarMass()); // tempJ); + .get(i - bulkSystem.getPhase(0).getNumberOfComponents(), j) + * bulkSystem.getPhase(1).getPhysicalProperties().getDensity() + / bulkSystem.getPhase(1).getMolarMass()); // tempJ); } - Jac.set(i + 2, j + 2 * bulkSystem.getPhases()[0].getNumberOfComponents(), - dij - bulkSystem.getPhases()[1].getComponents()[i - - bulkSystem.getPhases()[0].getNumberOfComponents()].getx()); + Jac.set(i + 2, j + 2 * bulkSystem.getPhase(0).getNumberOfComponents(), + dij - bulkSystem.getPhase(1).getComponents()[i + - bulkSystem.getPhase(0).getNumberOfComponents()].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++) { + for (int i = bulkSystem.getPhase(0).getNumberOfComponents(); i < 2 + * bulkSystem.getPhase(0).getNumberOfComponents() - 1; i++) { + for (int j = bulkSystem.getPhase(0).getNumberOfComponents(); j < 2 + * bulkSystem.getPhase(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())); + // -dij*(totalMassTransferCoefficientMatrix[1].get(i-bulkSystem.getPhase(0).getNumberOfComponents(), + // i-bulkSystem.getPhase(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[1].getRowSum(i-bulkSystem.getPhase(0).getNumberOfComponents()*1.0/bulkSystem.getPhase(1).getMolarVolume()); + if (j != 2 * bulkSystem.getPhase(0).getNumberOfComponents() - 1) { + Jac.set(i + 1 + bulkSystem.getPhase(0).getNumberOfComponents(), + j - bulkSystem.getPhase(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); + i - bulkSystem.getPhase(0).getNumberOfComponents(), + j - bulkSystem.getPhase(0).getNumberOfComponents()) + * bulkSystem.getPhase(0).getPhysicalProperties().getDensity() + / bulkSystem.getPhase(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()); + Jac.set(i + 1 + bulkSystem.getPhase(0).getNumberOfComponents(), + j + bulkSystem.getPhase(0).getNumberOfComponents(), dij - bulkSystem.getPhase(0) + .getComponents()[i - bulkSystem.getPhase(0).getNumberOfComponents()].getx()); } } // System.out.println("jac"); @@ -389,15 +387,15 @@ public void setJacMassTrans2() { *

*/ public void setuMassTrans() { - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { - uMassTrans.set(i, 0, interphaseSystem.getPhases()[0].getComponent(i).getx()); - uMassTrans.set(i + bulkSystem.getPhases()[0].getNumberOfComponents(), 0, - interphaseSystem.getPhases()[1].getComponent(i).getx()); + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfComponents(); i++) { + uMassTrans.set(i, 0, interphaseSystem.getPhase(0).getComponent(i).getx()); + uMassTrans.set(i + bulkSystem.getPhase(0).getNumberOfComponents(), 0, + interphaseSystem.getPhase(1).getComponent(i).getx()); } - 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 = 2 * bulkSystem.getPhase(0).getNumberOfComponents(); i < 3 + * bulkSystem.getPhase(0).getNumberOfComponents(); i++) { + uMassTrans.set(i, 0, nFlux.get(i - 2 * bulkSystem.getPhase(0).getNumberOfComponents(), 0)); } } @@ -407,15 +405,15 @@ public void setuMassTrans() { *

*/ public void updateMassTrans() { - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { - interphaseSystem.getPhases()[0].getComponent(i).setx(uMassTrans.get(i, 0)); - interphaseSystem.getPhases()[1].getComponent(i) - .setx(uMassTrans.get(i + bulkSystem.getPhases()[0].getNumberOfComponents(), 0)); + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfComponents(); i++) { + interphaseSystem.getPhase(0).getComponent(i).setx(uMassTrans.get(i, 0)); + interphaseSystem.getPhase(1).getComponent(i) + .setx(uMassTrans.get(i + bulkSystem.getPhase(0).getNumberOfComponents(), 0)); } - 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)); + for (int i = 2 * bulkSystem.getPhase(0).getNumberOfComponents(); i < 3 + * bulkSystem.getPhase(0).getNumberOfComponents(); i++) { + nFlux.set(i - 2 * bulkSystem.getPhase(0).getNumberOfComponents(), 0, uMassTrans.get(i, 0)); } } @@ -425,11 +423,11 @@ public void updateMassTrans() { *

*/ public void calcMolFractionDifference() { - for (int i = 0; i < getBulkSystem().getPhases()[0].getNumberOfComponents() - 1; i++) { - molFractionDifference[0][i] = bulkSystem.getPhases()[0].getComponent(i).getx() - - interphaseSystem.getPhases()[0].getComponent(i).getx(); - molFractionDifference[1][i] = bulkSystem.getPhases()[1].getComponent(i).getx() - - interphaseSystem.getPhases()[1].getComponent(i).getx(); + for (int i = 0; i < getBulkSystem().getPhase(0).getNumberOfComponents() - 1; i++) { + molFractionDifference[0][i] = bulkSystem.getPhase(0).getComponent(i).getx() + - interphaseSystem.getPhase(0).getComponent(i).getx(); + molFractionDifference[1][i] = bulkSystem.getPhase(1).getComponent(i).getx() + - interphaseSystem.getPhase(1).getComponent(i).getx(); } } @@ -461,13 +459,13 @@ public void calcHeatTransferCoefficients(int phaseNum) { */ public void calcHeatTransferCorrection(int phaseNum) { double temp = 1.0e-20; - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfComponents(); i++) { if (Math.abs(nFlux.get(i, 0)) < 1e-20) { temp += 0.0; } else { temp += nFlux.get(i, 0) * getBulkSystem().getPhase(phaseNum).getCp() / getBulkSystem().getPhase(phaseNum).getNumberOfMolesInPhase() - / heatTransferCoefficient[phaseNum]; // bulkSystem.getPhases()[0].getComponent(i).getNumberOfMolesInPhase()* + / heatTransferCoefficient[phaseNum]; // bulkSystem.getPhase(0).getComponent(i).getNumberOfMolesInPhase()* } } // System.out.println("temp eat " + temp); @@ -509,20 +507,20 @@ public void heatTransSolve() { do { iter++; dhtot = 0.0; - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { - dhtot += nFlux.get(i, 0) * (bulkSystem.getPhases()[0].getComponent(i) - .getEnthalpy(bulkSystem.getPhases()[0].getTemperature()) - / bulkSystem.getPhases()[0].getComponent(i).getNumberOfMolesInPhase() - - bulkSystem.getPhases()[1].getComponent(i) - .getEnthalpy(bulkSystem.getPhases()[1].getTemperature()) - / bulkSystem.getPhases()[1].getComponent(i).getNumberOfMolesInPhase()); + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfComponents(); i++) { + dhtot += nFlux.get(i, 0) * (bulkSystem.getPhase(0).getComponent(i) + .getEnthalpy(bulkSystem.getPhase(0).getTemperature()) + / bulkSystem.getPhase(0).getComponent(i).getNumberOfMolesInPhase() + - bulkSystem.getPhase(1).getComponent(i) + .getEnthalpy(bulkSystem.getPhase(1).getTemperature()) + / bulkSystem.getPhase(1).getComponent(i).getNumberOfMolesInPhase()); } // System.out.println("dhtot " + dhtot + " heat coef " + // heatTransferCoefficient[0]); f = heatTransferCoefficient[0] * heatTransferCorrection[0] - * (bulkSystem.getPhases()[0].getTemperature() - interphaseSystem.getTemperature()) + * (bulkSystem.getPhase(0).getTemperature() - interphaseSystem.getTemperature()) + heatTransferCoefficient[1] * heatTransferCorrection[1] - * (bulkSystem.getPhases()[1].getTemperature() - interphaseSystem.getTemperature()) + * (bulkSystem.getPhase(1).getTemperature() - interphaseSystem.getTemperature()) + dhtot; df = -heatTransferCoefficient[0] * heatTransferCorrection[0] @@ -535,9 +533,9 @@ public void heatTransSolve() { } while (Math.abs(f) > 1e-6 && iter < 100); interphaseHeatFlux[0] = -heatTransferCoefficient[0] * heatTransferCorrection[0] - * (bulkSystem.getPhases()[0].getTemperature() - interphaseSystem.getTemperature()); + * (bulkSystem.getPhase(0).getTemperature() - interphaseSystem.getTemperature()); interphaseHeatFlux[1] = -heatTransferCoefficient[1] * heatTransferCorrection[1] - * (bulkSystem.getPhases()[1].getTemperature() - interphaseSystem.getTemperature()); + * (bulkSystem.getPhase(1).getTemperature() - interphaseSystem.getTemperature()); // System.out.println("heat flox here " + getInterphaseHeatFlux(0) + " heatflux2 // " + getInterphaseHeatFlux(1)); } @@ -577,7 +575,7 @@ public void massTransSolve() { public double[] calcFluxes() { double sum = 0.0; // System.out.println("starter..."); - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfComponents(); i++) { sum += nFlux.get(i, 0); } diff --git a/src/main/java/neqsim/fluidmechanics/flownode/fluidboundary/heatmasstransfercalc/nonequilibriumfluidboundary/filmmodelboundary/KrishnaStandartFilmModel.java b/src/main/java/neqsim/fluidmechanics/flownode/fluidboundary/heatmasstransfercalc/nonequilibriumfluidboundary/filmmodelboundary/KrishnaStandartFilmModel.java index 6d7584dee..2c8af5f85 100644 --- a/src/main/java/neqsim/fluidmechanics/flownode/fluidboundary/heatmasstransfercalc/nonequilibriumfluidboundary/filmmodelboundary/KrishnaStandartFilmModel.java +++ b/src/main/java/neqsim/fluidmechanics/flownode/fluidboundary/heatmasstransfercalc/nonequilibriumfluidboundary/filmmodelboundary/KrishnaStandartFilmModel.java @@ -37,10 +37,10 @@ public class KrishnaStandartFilmModel extends */ public KrishnaStandartFilmModel(SystemInterface system) { super(system); - binaryMassTransferCoefficient = new double[2][getBulkSystem().getPhases()[0] - .getNumberOfComponents()][getBulkSystem().getPhases()[0].getNumberOfComponents()]; - binarySchmidtNumber = new double[2][getBulkSystem().getPhases()[0] - .getNumberOfComponents()][getBulkSystem().getPhases()[0].getNumberOfComponents()]; + binaryMassTransferCoefficient = new double[2][getBulkSystem().getPhase(0) + .getNumberOfComponents()][getBulkSystem().getPhase(0).getNumberOfComponents()]; + binarySchmidtNumber = new double[2][getBulkSystem().getPhase(0) + .getNumberOfComponents()][getBulkSystem().getPhase(0).getNumberOfComponents()]; uMassTrans = new Matrix(neq, 1); Xgij = new Matrix(neq, 4); this.setuMassTrans(); @@ -56,17 +56,17 @@ public KrishnaStandartFilmModel(SystemInterface system) { */ public KrishnaStandartFilmModel(FlowNodeInterface flowNode) { super(flowNode); - binaryMassTransferCoefficient = new double[2][getBulkSystem().getPhases()[0] - .getNumberOfComponents()][getBulkSystem().getPhases()[0].getNumberOfComponents()]; - binarySchmidtNumber = new double[2][getBulkSystem().getPhases()[0] - .getNumberOfComponents()][getBulkSystem().getPhases()[0].getNumberOfComponents()]; + binaryMassTransferCoefficient = new double[2][getBulkSystem().getPhase(0) + .getNumberOfComponents()][getBulkSystem().getPhase(0).getNumberOfComponents()]; + binarySchmidtNumber = new double[2][getBulkSystem().getPhase(0) + .getNumberOfComponents()][getBulkSystem().getPhase(0).getNumberOfComponents()]; uMassTrans = new Matrix(neq, 1); Xgij = new Matrix(neq, 4); this.setuMassTrans(); uMassTransold = uMassTrans.copy(); - phiMatrix = new Matrix(getBulkSystem().getPhases()[0].getNumberOfComponents() - 1, - getBulkSystem().getPhases()[0].getNumberOfComponents() - 1); - redCorrectionMatrix = new Matrix(getBulkSystem().getPhases()[0].getNumberOfComponents() - 1, 1); + phiMatrix = new Matrix(getBulkSystem().getPhase(0).getNumberOfComponents() - 1, + getBulkSystem().getPhase(0).getNumberOfComponents() - 1); + redCorrectionMatrix = new Matrix(getBulkSystem().getPhase(0).getNumberOfComponents() - 1, 1); } /** {@inheritDoc} */ 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 6738f5a36..320cace87 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 @@ -35,20 +35,20 @@ public abstract class ReactiveFluidBoundary extends KrishnaStandartFilmModel { */ public ReactiveFluidBoundary(SystemInterface system) { super(system); - neq = 3 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); + neq = 3 * bulkSystem.getPhase(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); + // Matrix(getBulkSystem().getPhase(0).getNumberOfMolecularComponents()-1,getBulkSystem().getPhase(0).getNumberOfMolecularComponents()-1); // massTransferCoefficientMatrix[1] = new - // Matrix(getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1,getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1); + // Matrix(getBulkSystem().getPhase(0).getNumberOfMolecularComponents()-1,getBulkSystem().getPhase(0).getNumberOfMolecularComponents()-1); // totalMassTransferCoefficientMatrix[0] = new - // Matrix(getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1,getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1); + // Matrix(getBulkSystem().getPhase(0).getNumberOfMolecularComponents()-1,getBulkSystem().getPhase(0).getNumberOfMolecularComponents()-1); // totalMassTransferCoefficientMatrix[1] = new - // Matrix(getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1,getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1); + // Matrix(getBulkSystem().getPhase(0).getNumberOfMolecularComponents()-1,getBulkSystem().getPhase(0).getNumberOfMolecularComponents()-1); // molFractionDifference = new - // double[2][getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1]; + // double[2][getBulkSystem().getPhase(0).getNumberOfMolecularComponents()-1]; } /** @@ -60,21 +60,21 @@ public ReactiveFluidBoundary(SystemInterface system) { */ public ReactiveFluidBoundary(FlowNodeInterface flowNode) { super(flowNode); - neq = 3 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); + neq = 3 * bulkSystem.getPhase(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); + // Matrix(getBulkSystem().getPhase(0).getNumberOfMolecularComponents()-1,getBulkSystem().getPhase(0).getNumberOfMolecularComponents()-1); // massTransferCoefficientMatrix[1] = new - // Matrix(getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1,getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1); + // Matrix(getBulkSystem().getPhase(0).getNumberOfMolecularComponents()-1,getBulkSystem().getPhase(0).getNumberOfMolecularComponents()-1); // totalMassTransferCoefficientMatrix[0] = new - // Matrix(getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1,getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1); + // Matrix(getBulkSystem().getPhase(0).getNumberOfMolecularComponents()-1,getBulkSystem().getPhase(0).getNumberOfMolecularComponents()-1); // totalMassTransferCoefficientMatrix[1] = new - // Matrix(getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1,getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1); + // Matrix(getBulkSystem().getPhase(0).getNumberOfMolecularComponents()-1,getBulkSystem().getPhase(0).getNumberOfMolecularComponents()-1); // interphaseSystem = bulkSystem.clone(); // molFractionDifference = new - // double[2][getBulkSystem().getPhases()[0].getNumberOfMolecularComponents()-1]; + // double[2][getBulkSystem().getPhase(0).getNumberOfMolecularComponents()-1]; } /** {@inheritDoc} */ @@ -96,35 +96,35 @@ public ReactiveFluidBoundary clone() { public void setfvecMassTrans() { double sumx = 0; double sumy = 0; - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfMolecularComponents(); i++) { fvec.set(i, 0, - Math.log((interphaseSystem.getPhases()[0].getComponent(i).getFugacityCoefficient() - * interphaseSystem.getPhases()[0].getComponent(i).getx())) - - Math.log((interphaseSystem.getPhases()[1].getComponent(i).getFugacityCoefficient() - * interphaseSystem.getPhases()[1].getComponent(i).getx()))); - sumx += interphaseSystem.getPhases()[0].getComponent(i).getx(); - sumy += interphaseSystem.getPhases()[1].getComponent(i).getx(); + Math.log((interphaseSystem.getPhase(0).getComponent(i).getFugacityCoefficient() + * interphaseSystem.getPhase(0).getComponent(i).getx())) + - Math.log((interphaseSystem.getPhase(1).getComponent(i).getFugacityCoefficient() + * interphaseSystem.getPhase(1).getComponent(i).getx()))); + sumx += interphaseSystem.getPhase(0).getComponent(i).getx(); + sumy += interphaseSystem.getPhase(1).getComponent(i).getx(); } - fvec.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 1, 0, 1 - sumx); - fvec.set(bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), 0, 1 - sumy); + fvec.set(bulkSystem.getPhase(0).getNumberOfMolecularComponents() - 1, 0, 1 - sumx); + fvec.set(bulkSystem.getPhase(0).getNumberOfMolecularComponents(), 0, 1 - sumy); - for (int i = bulkSystem.getPhases()[0].getNumberOfMolecularComponents() + 1; i < (2 - * bulkSystem.getPhases()[0].getNumberOfMolecularComponents()); i++) { + for (int i = bulkSystem.getPhase(0).getNumberOfMolecularComponents() + 1; i < (2 + * bulkSystem.getPhase(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()) + i - (bulkSystem.getPhase(0).getNumberOfMolecularComponents() + 1), + i - (bulkSystem.getPhase(0).getNumberOfMolecularComponents() + 1)) + * (bulkSystem.getPhase(0).getComponents()[i + - (bulkSystem.getPhase(0).getNumberOfMolecularComponents() + 1)].getx() + - interphaseSystem.getPhase(0).getComponents()[i + - (bulkSystem.getPhase(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)] + i - (bulkSystem.getPhase(0).getNumberOfMolecularComponents() + 1), + i - (bulkSystem.getPhase(0).getNumberOfMolecularComponents() + 1)) + * (bulkSystem.getPhase(1).getComponents()[i + - (bulkSystem.getPhase(0).getNumberOfMolecularComponents() + 1)].getx() + - interphaseSystem.getPhase(1).getComponents()[i + - (bulkSystem.getPhase(0).getNumberOfMolecularComponents() + 1)] .getx())))); } } @@ -134,46 +134,46 @@ public void setfvecMassTrans() { public void setfvecMassTrans2() { double sumx = 0.0; double sumy = 0.0; - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfMolecularComponents(); i++) { fvec.set(i, 0, - Math.log((interphaseSystem.getPhases()[0].getComponent(i).getFugacityCoefficient() - * interphaseSystem.getPhases()[0].getComponent(i).getx())) - - Math.log((interphaseSystem.getPhases()[1].getComponent(i).getFugacityCoefficient() - * interphaseSystem.getPhases()[1].getComponent(i).getx()))); - sumx += interphaseSystem.getPhases()[1].getComponent(i).getx(); - sumy += interphaseSystem.getPhases()[0].getComponent(i).getx(); + Math.log((interphaseSystem.getPhase(0).getComponent(i).getFugacityCoefficient() + * interphaseSystem.getPhase(0).getComponent(i).getx())) + - Math.log((interphaseSystem.getPhase(1).getComponent(i).getFugacityCoefficient() + * interphaseSystem.getPhase(1).getComponent(i).getx()))); + sumx += interphaseSystem.getPhase(1).getComponent(i).getx(); + sumy += interphaseSystem.getPhase(0).getComponent(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].getComponent(i).getx() - - interphaseSystem.getPhases()[0].getComponent(i).getx())); - dx.set(0, i, (bulkSystem.getPhases()[1].getComponent(i).getx() - - interphaseSystem.getPhases()[1].getComponent(i).getx())); - y.set(0, i, (bulkSystem.getPhases()[0].getComponent(i).getx())); - x.set(0, i, (bulkSystem.getPhases()[1].getComponent(i).getx())); + fvec.set(bulkSystem.getPhase(0).getNumberOfMolecularComponents(), 0, 1.0 - sumx); + fvec.set(bulkSystem.getPhase(0).getNumberOfMolecularComponents() + 1, 0, 1.0 - sumy); + + Matrix dx = new Matrix(1, bulkSystem.getPhase(0).getNumberOfMolecularComponents() - 1); + Matrix dy = new Matrix(1, bulkSystem.getPhase(0).getNumberOfMolecularComponents() - 1); + Matrix x = new Matrix(1, bulkSystem.getPhase(0).getNumberOfMolecularComponents() - 1); + Matrix y = new Matrix(1, bulkSystem.getPhase(0).getNumberOfMolecularComponents() - 1); + + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfMolecularComponents() - 1; i++) { + dy.set(0, i, (bulkSystem.getPhase(0).getComponent(i).getx() + - interphaseSystem.getPhase(0).getComponent(i).getx())); + dx.set(0, i, (bulkSystem.getPhase(1).getComponent(i).getx() + - interphaseSystem.getPhase(1).getComponent(i).getx())); + y.set(0, i, (bulkSystem.getPhase(0).getComponent(i).getx())); + x.set(0, i, (bulkSystem.getPhase(1).getComponent(i).getx())); } Matrix fluxX = totalMassTransferCoefficientMatrix[1].times(dx.transpose()) - .times(bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[1].getMolarMass()); + .times(bulkSystem.getPhase(1).getPhysicalProperties().getDensity() + / bulkSystem.getPhase(1).getMolarMass()); Matrix fluxY = totalMassTransferCoefficientMatrix[0].times(dy.transpose()) - .times(bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[0].getMolarMass()); + .times(bulkSystem.getPhase(0).getPhysicalProperties().getDensity() + / bulkSystem.getPhase(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); + // nFlux.getMatrix(0,bulkSystem.getPhase(1).getNumberOfMolecularComponents()-2,0,0).print(10,10); // System.out.println("j gas flux"); // fluxY.print(10,10); // System.out.println("j gliq flux"); @@ -184,18 +184,18 @@ public void setfvecMassTrans2() { // x.transpose().times(totalFlux).print(10,10); Matrix errX = - nFlux.getMatrix(0, bulkSystem.getPhases()[1].getNumberOfMolecularComponents() - 2, 0, 0) + nFlux.getMatrix(0, bulkSystem.getPhase(1).getNumberOfMolecularComponents() - 2, 0, 0) .plus(fluxX).minus(x.transpose().times(totalFlux)); Matrix errY = - nFlux.getMatrix(0, bulkSystem.getPhases()[0].getNumberOfMolecularComponents() - 2, 0, 0) + nFlux.getMatrix(0, bulkSystem.getPhase(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++) { + for (int i = bulkSystem.getPhase(0).getNumberOfMolecularComponents() + + 2; i < (2 * bulkSystem.getPhase(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)); + errX.get((i - (bulkSystem.getPhase(0).getNumberOfMolecularComponents() + 2)), 0)); + fvec.set((i + (bulkSystem.getPhase(0).getNumberOfMolecularComponents() - 1)), 0, + errY.get((i - (bulkSystem.getPhase(0).getNumberOfMolecularComponents() + 2)), 0)); } /* @@ -213,60 +213,60 @@ public void setJacMassTrans() { 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++) { + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfMolecularComponents() - 1; i++) { + for (int j = 0; j < bulkSystem.getPhase(0).getNumberOfMolecularComponents(); j++) { dij = i == j ? 1.0 : 0.0; // Kroneckers delta - tempJ = dij * 1.0 / interphaseSystem.getPhases()[0].getComponent(i).getx() - + interphaseSystem.getPhases()[0].getComponent(i).getdfugdx(j); + tempJ = dij * 1.0 / interphaseSystem.getPhase(0).getComponent(i).getx() + + interphaseSystem.getPhase(0).getComponent(i).getdfugdx(j); // tempJ= - // dij*interphaseSystem.getPhases()[0].getComponent(i).getFugacityCoefficient()+interphaseSystem.getPhases()[0].getComponent(i).getx()*interphaseSystem.getPhases()[0].getComponent(i).getdfugdx(j); + // dij*interphaseSystem.getPhase(0).getComponent(i).getFugacityCoefficient()+interphaseSystem.getPhase(0).getComponent(i).getx()*interphaseSystem.getPhase(0).getComponent(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.getPhase(0).getNumberOfMolecularComponents(); i++) { + Jac.set(bulkSystem.getPhase(0).getNumberOfMolecularComponents() - 1, i, -1.0); + Jac.set(bulkSystem.getPhase(0).getNumberOfMolecularComponents() - 1, + bulkSystem.getPhase(0).getNumberOfMolecularComponents() + i, 0.0); + Jac.set(bulkSystem.getPhase(0).getNumberOfMolecularComponents(), i, 0.0); + Jac.set(bulkSystem.getPhase(0).getNumberOfMolecularComponents(), + bulkSystem.getPhase(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++) { + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfMolecularComponents() - 1; i++) { + for (int j = 0; j < bulkSystem.getPhase(0).getNumberOfMolecularComponents(); j++) { dij = i == j ? 1.0 : 0.0; // Kroneckers delta - tempJ = dij * 1.0 / interphaseSystem.getPhases()[1].getComponent(i).getx() - + interphaseSystem.getPhases()[1].getComponent(i).getdfugdx(j); + tempJ = dij * 1.0 / interphaseSystem.getPhase(1).getComponent(i).getx() + + interphaseSystem.getPhase(1).getComponent(i).getdfugdx(j); // tempJ= - // dij*interphaseSystem.getPhases()[1].getComponent(i).getFugacityCoefficient()+interphaseSystem.getPhases()[1].getComponent(i).getx()*interphaseSystem.getPhases()[1].getComponent(i).getdfugdx(j); - Jac.set(i, j + bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), -tempJ); + // dij*interphaseSystem.getPhase(1).getComponent(i).getFugacityCoefficient()+interphaseSystem.getPhase(1).getComponent(i).getx()*interphaseSystem.getPhase(1).getComponent(i).getdfugdx(j); + Jac.set(i, j + bulkSystem.getPhase(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; + for (int i = bulkSystem.getPhase(0).getNumberOfMolecularComponents(); i < 2 + * bulkSystem.getPhase(0).getNumberOfMolecularComponents() - 1; i++) { + for (int j = 0; j < bulkSystem.getPhase(0).getNumberOfMolecularComponents(); j++) { + dij = i == (j + bulkSystem.getPhase(0).getNumberOfMolecularComponents()) ? 1.0 : 0.0; tempJ = -dij * (totalMassTransferCoefficientMatrix[1].get( - i - bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), - i - bulkSystem.getPhases()[0].getNumberOfMolecularComponents())); + i - bulkSystem.getPhase(0).getNumberOfMolecularComponents(), + i - bulkSystem.getPhase(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++) { + for (int i = bulkSystem.getPhase(0).getNumberOfMolecularComponents(); i < 2 + * bulkSystem.getPhase(0).getNumberOfMolecularComponents() - 1; i++) { + for (int j = bulkSystem.getPhase(0).getNumberOfMolecularComponents(); j < 2 + * bulkSystem.getPhase(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())); + i - bulkSystem.getPhase(0).getNumberOfMolecularComponents(), + i - bulkSystem.getPhase(0).getNumberOfMolecularComponents())); Jac.set(i + 1, j, tempJ); } } @@ -279,83 +279,83 @@ public void setJacMassTrans2() { 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++) { + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfMolecularComponents(); i++) { + for (int j = 0; j < bulkSystem.getPhase(0).getNumberOfMolecularComponents(); j++) { dij = i == j ? 1.0 : 0.0; // Kroneckers delta - tempJ = dij * 1.0 / interphaseSystem.getPhases()[0].getComponent(i).getx() - + interphaseSystem.getPhases()[0].getComponent(i).getdfugdx(j); + tempJ = dij * 1.0 / interphaseSystem.getPhase(0).getComponent(i).getx() + + interphaseSystem.getPhase(0).getComponent(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.getPhase(0).getNumberOfMolecularComponents(); i++) { + Jac.set(bulkSystem.getPhase(0).getNumberOfMolecularComponents(), i, 0.0); + Jac.set(bulkSystem.getPhase(0).getNumberOfMolecularComponents(), + bulkSystem.getPhase(0).getNumberOfMolecularComponents() + i, -1.0); + Jac.set(bulkSystem.getPhase(0).getNumberOfMolecularComponents() + 1, i, -1.0); + Jac.set(bulkSystem.getPhase(0).getNumberOfMolecularComponents() + 1, + bulkSystem.getPhase(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++) { + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfMolecularComponents(); i++) { + for (int j = 0; j < bulkSystem.getPhase(0).getNumberOfMolecularComponents(); j++) { dij = i == j ? 1.0 : 0.0; // Kroneckers delta - tempJ = dij * 1.0 / interphaseSystem.getPhases()[1].getComponent(i).getx() - + interphaseSystem.getPhases()[1].getComponent(i).getdfugdx(j); - Jac.set(i, j + bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), -tempJ); + tempJ = dij * 1.0 / interphaseSystem.getPhase(1).getComponent(i).getx() + + interphaseSystem.getPhase(1).getComponent(i).getdfugdx(j); + Jac.set(i, j + bulkSystem.getPhase(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; + for (int i = bulkSystem.getPhase(0).getNumberOfMolecularComponents(); i < 2 + * bulkSystem.getPhase(0).getNumberOfMolecularComponents() - 1; i++) { + for (int j = 0; j < bulkSystem.getPhase(0).getNumberOfMolecularComponents(); j++) { + dij = i == (j + bulkSystem.getPhase(0).getNumberOfMolecularComponents()) ? 1.0 : 0.0; // tempJ = - // -dij*(totalMassTransferCoefficientMatrix[1].get(i-bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), - // i-bulkSystem.getPhases()[0].getNumberOfMolecularComponents())); + // -dij*(totalMassTransferCoefficientMatrix[1].get(i-bulkSystem.getPhase(0).getNumberOfMolecularComponents(), + // i-bulkSystem.getPhase(0).getNumberOfMolecularComponents())); // tempJ = dij * - // totalMassTransferCoefficientMatrix[0].getRowSum(i-bulkSystem.getPhases()[0].getNumberOfMolecularComponents()); - // Jac.set(i+2,j+2*bulkSystem.getPhases()[0].getNumberOfMolecularComponents()-1, + // totalMassTransferCoefficientMatrix[0].getRowSum(i-bulkSystem.getPhase(0).getNumberOfMolecularComponents()); + // Jac.set(i+2,j+2*bulkSystem.getPhase(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(), + // interphaseSystem.getPhase(0).getComponents()[i-bulkSystem.getPhase(0).getNumberOfMolecularComponents()].getx()); + if (j != bulkSystem.getPhase(0).getNumberOfMolecularComponents() - 1) { + Jac.set(i + 2, j + bulkSystem.getPhase(0).getNumberOfMolecularComponents(), -totalMassTransferCoefficientMatrix[1] - .get(i - bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), j) - * bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[1].getMolarMass()); // tempJ); + .get(i - bulkSystem.getPhase(0).getNumberOfMolecularComponents(), j) + * bulkSystem.getPhase(1).getPhysicalProperties().getDensity() + / bulkSystem.getPhase(1).getMolarMass()); // tempJ); } - Jac.set(i + 2, j + 2 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), - dij - bulkSystem.getPhases()[1].getComponents()[i - - bulkSystem.getPhases()[0].getNumberOfMolecularComponents()].getx()); + Jac.set(i + 2, j + 2 * bulkSystem.getPhase(0).getNumberOfMolecularComponents(), + dij - bulkSystem.getPhase(1).getComponents()[i + - bulkSystem.getPhase(0).getNumberOfMolecularComponents()].getx()); } } - 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++) { + for (int i = bulkSystem.getPhase(0).getNumberOfMolecularComponents(); i < 2 + * bulkSystem.getPhase(0).getNumberOfMolecularComponents() - 1; i++) { + for (int j = bulkSystem.getPhase(0).getNumberOfMolecularComponents(); j < 2 + * bulkSystem.getPhase(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())); + // -dij*(totalMassTransferCoefficientMatrix[1].get(i-bulkSystem.getPhase(0).getNumberOfMolecularComponents(), + // i-bulkSystem.getPhase(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[1].getRowSum(i-bulkSystem.getPhase(0).getNumberOfMolecularComponents()*1.0/bulkSystem.getPhase(1).getMolarVolume()); + if (j != 2 * bulkSystem.getPhase(0).getNumberOfMolecularComponents() - 1) { + Jac.set(i + 1 + bulkSystem.getPhase(0).getNumberOfMolecularComponents(), + j - bulkSystem.getPhase(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); + i - bulkSystem.getPhase(0).getNumberOfMolecularComponents(), + j - bulkSystem.getPhase(0).getNumberOfMolecularComponents()) + * bulkSystem.getPhase(0).getPhysicalProperties().getDensity() + / bulkSystem.getPhase(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()); + Jac.set(i + 1 + bulkSystem.getPhase(0).getNumberOfMolecularComponents(), + j + bulkSystem.getPhase(0).getNumberOfMolecularComponents(), + dij - bulkSystem.getPhase(0).getComponents()[i + - bulkSystem.getPhase(0).getNumberOfMolecularComponents()].getx()); } } // System.out.println("jac"); @@ -366,32 +366,32 @@ public void setJacMassTrans2() { /** {@inheritDoc} */ @Override public void setuMassTrans() { - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfMolecularComponents(); i++) { // System.out.println("i"); - uMassTrans.set(i, 0, interphaseSystem.getPhases()[0].getComponent(i).getx()); - uMassTrans.set(i + bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), 0, - interphaseSystem.getPhases()[1].getComponent(i).getx()); + uMassTrans.set(i, 0, interphaseSystem.getPhase(0).getComponent(i).getx()); + uMassTrans.set(i + bulkSystem.getPhase(0).getNumberOfMolecularComponents(), 0, + interphaseSystem.getPhase(1).getComponent(i).getx()); } - for (int i = 2 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i < 3 - * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { + for (int i = 2 * bulkSystem.getPhase(0).getNumberOfMolecularComponents(); i < 3 + * bulkSystem.getPhase(0).getNumberOfMolecularComponents(); i++) { uMassTrans.set(i, 0, - nFlux.get(i - 2 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), 0)); + nFlux.get(i - 2 * bulkSystem.getPhase(0).getNumberOfMolecularComponents(), 0)); } } /** {@inheritDoc} */ @Override public void updateMassTrans() { - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { - interphaseSystem.getPhases()[0].getComponent(i).setx(uMassTrans.get(i, 0)); - interphaseSystem.getPhases()[1].getComponent(i) - .setx(uMassTrans.get(i + bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), 0)); + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfMolecularComponents(); i++) { + interphaseSystem.getPhase(0).getComponent(i).setx(uMassTrans.get(i, 0)); + interphaseSystem.getPhase(1).getComponent(i) + .setx(uMassTrans.get(i + bulkSystem.getPhase(0).getNumberOfMolecularComponents(), 0)); } - for (int i = 2 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i < 3 - * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { - nFlux.set(i - 2 * bulkSystem.getPhases()[0].getNumberOfMolecularComponents(), 0, + for (int i = 2 * bulkSystem.getPhase(0).getNumberOfMolecularComponents(); i < 3 + * bulkSystem.getPhase(0).getNumberOfMolecularComponents(); i++) { + nFlux.set(i - 2 * bulkSystem.getPhase(0).getNumberOfMolecularComponents(), 0, uMassTrans.get(i, 0)); } } @@ -399,11 +399,11 @@ public void updateMassTrans() { /** {@inheritDoc} */ @Override public void calcMolFractionDifference() { - for (int i = 0; i < getBulkSystem().getPhases()[0].getNumberOfMolecularComponents() - 1; i++) { - molFractionDifference[0][i] = bulkSystem.getPhases()[0].getComponent(i).getx() - - interphaseSystem.getPhases()[0].getComponent(i).getx(); - molFractionDifference[1][i] = bulkSystem.getPhases()[1].getComponent(i).getx() - - interphaseSystem.getPhases()[1].getComponent(i).getx(); + for (int i = 0; i < getBulkSystem().getPhase(0).getNumberOfMolecularComponents() - 1; i++) { + molFractionDifference[0][i] = bulkSystem.getPhase(0).getComponent(i).getx() + - interphaseSystem.getPhase(0).getComponent(i).getx(); + molFractionDifference[1][i] = bulkSystem.getPhase(1).getComponent(i).getx() + - interphaseSystem.getPhase(1).getComponent(i).getx(); } } @@ -421,8 +421,8 @@ public void calcHeatTransferCoefficients(int phaseNum) { @Override public void calcHeatTransferCorrection(int phaseNum) { double temp = 0; - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { - temp += bulkSystem.getPhases()[0].getComponent(i).getNumberOfMolesInPhase() + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfMolecularComponents(); i++) { + temp += bulkSystem.getPhase(0).getComponent(i).getNumberOfMolesInPhase() * getBulkSystem().getPhase(phaseNum).getCp() / heatTransferCoefficient[phaseNum]; } heatTransferCorrection[phaseNum] = temp; @@ -455,17 +455,17 @@ public void heatTransSolve() { 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].getComponent(i) - .getEnthalpy(bulkSystem.getPhases()[0].getTemperature()) - - bulkSystem.getPhases()[1].getComponent(i) - .getEnthalpy(bulkSystem.getPhases()[1].getTemperature())); + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfMolecularComponents(); i++) { + dhtot += nFlux.get(i, 0) * (bulkSystem.getPhase(0).getComponent(i) + .getEnthalpy(bulkSystem.getPhase(0).getTemperature()) + - bulkSystem.getPhase(1).getComponent(i) + .getEnthalpy(bulkSystem.getPhase(1).getTemperature())); } f = heatTransferCoefficient[0] * heatTransferCorrection[0] - * (bulkSystem.getPhases()[0].getTemperature() - interphaseSystem.getTemperature()) + * (bulkSystem.getPhase(0).getTemperature() - interphaseSystem.getTemperature()) + heatTransferCoefficient[1] * heatTransferCorrection[1] - * (bulkSystem.getPhases()[1].getTemperature() - interphaseSystem.getTemperature()) + * (bulkSystem.getPhase(1).getTemperature() - interphaseSystem.getTemperature()) + dhtot; df = -heatTransferCoefficient[0] * heatTransferCorrection[0] @@ -474,8 +474,8 @@ public void heatTransSolve() { // 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()); + // System.out.println("gas temp " + bulkSystem.getPhase(0).getTemperature()); + // System.out.println("liq temp " + bulkSystem.getPhase(1).getTemperature()); } while (Math.abs(f) > 1e-10); } @@ -510,7 +510,7 @@ public void massTransSolve() { public double[] calcFluxes() { double sum = 0.0; // System.out.println("starter..."); - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfMolecularComponents(); i++) { sum += nFlux.get(i, 0); } @@ -528,7 +528,7 @@ public double[] calcFluxes() { public double[] calcFluxes2() { double sum = 0.0; // System.out.println("starter..."); - for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) { + for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfMolecularComponents(); i++) { sum += nFlux.get(i, 0); // System.out.println("n " + nFlux.get(i,0) ); } diff --git a/src/main/java/neqsim/fluidmechanics/flownode/fluidboundary/heatmasstransfercalc/nonequilibriumfluidboundary/filmmodelboundary/reactivefilmmodel/enhancementfactor/EnhancementFactor.java b/src/main/java/neqsim/fluidmechanics/flownode/fluidboundary/heatmasstransfercalc/nonequilibriumfluidboundary/filmmodelboundary/reactivefilmmodel/enhancementfactor/EnhancementFactor.java index 29a31c257..e533d691d 100644 --- a/src/main/java/neqsim/fluidmechanics/flownode/fluidboundary/heatmasstransfercalc/nonequilibriumfluidboundary/filmmodelboundary/reactivefilmmodel/enhancementfactor/EnhancementFactor.java +++ b/src/main/java/neqsim/fluidmechanics/flownode/fluidboundary/heatmasstransfercalc/nonequilibriumfluidboundary/filmmodelboundary/reactivefilmmodel/enhancementfactor/EnhancementFactor.java @@ -21,7 +21,8 @@ public class EnhancementFactor implements EnhancementFactorInterface { protected double[] enhancementVec = null; protected double[] hattaNumber = null; protected FluidBoundaryInterface fluidBoundary; - protected FluidBoundarySystemInterface nonReactiveInterface, reactiveInterface; + protected FluidBoundarySystemInterface nonReactiveInterface; + protected FluidBoundarySystemInterface reactiveInterface; /** *

@@ -42,9 +43,8 @@ public EnhancementFactor() {} public EnhancementFactor(FluidBoundaryInterface fluidBoundary) { this(); this.fluidBoundary = fluidBoundary; - enhancementVec = - new double[fluidBoundary.getBulkSystem().getPhases()[0].getNumberOfComponents()]; - hattaNumber = new double[fluidBoundary.getBulkSystem().getPhases()[0].getNumberOfComponents()]; + enhancementVec = new double[fluidBoundary.getBulkSystem().getPhase(0).getNumberOfComponents()]; + hattaNumber = new double[fluidBoundary.getBulkSystem().getPhase(0).getNumberOfComponents()]; } /** diff --git a/src/main/java/neqsim/fluidmechanics/flownode/fluidboundary/interphasetransportcoefficient/interphaseonephase/interphasepipeflow/InterphasePipeFlow.java b/src/main/java/neqsim/fluidmechanics/flownode/fluidboundary/interphasetransportcoefficient/interphaseonephase/interphasepipeflow/InterphasePipeFlow.java index 7196d69a0..093a56fb1 100644 --- a/src/main/java/neqsim/fluidmechanics/flownode/fluidboundary/interphasetransportcoefficient/interphaseonephase/interphasepipeflow/InterphasePipeFlow.java +++ b/src/main/java/neqsim/fluidmechanics/flownode/fluidboundary/interphasetransportcoefficient/interphaseonephase/interphasepipeflow/InterphasePipeFlow.java @@ -54,9 +54,8 @@ public double calcWallHeatTransferCoefficient(int phaseNum, double prandtlNumber if (Math.abs(node.getReynoldsNumber()) < 2000) { return 3.66 / node.getGeometry().getDiameter() * node.getBulkSystem().getPhase(phaseNum).getPhysicalProperties().getConductivity(); - } - // if turbulent - use chilton colburn analogy - else { + } else { + // if turbulent - use chilton colburn analogy double temp = node.getBulkSystem().getPhase(phaseNum).getCp() / node.getBulkSystem().getPhase(phaseNum).getMolarMass() / node.getBulkSystem().getPhase(phaseNum).getNumberOfMolesInPhase() diff --git a/src/main/java/neqsim/fluidmechanics/flownode/fluidboundary/interphasetransportcoefficient/interphasetwophase/stirredcell/InterphaseStirredCellFlow.java b/src/main/java/neqsim/fluidmechanics/flownode/fluidboundary/interphasetransportcoefficient/interphasetwophase/stirredcell/InterphaseStirredCellFlow.java index 925e31606..086986001 100644 --- a/src/main/java/neqsim/fluidmechanics/flownode/fluidboundary/interphasetransportcoefficient/interphasetwophase/stirredcell/InterphaseStirredCellFlow.java +++ b/src/main/java/neqsim/fluidmechanics/flownode/fluidboundary/interphasetransportcoefficient/interphasetwophase/stirredcell/InterphaseStirredCellFlow.java @@ -89,9 +89,12 @@ public double calcWallMassTransferCoefficient(int phaseNum, double schmidtNumber @Override public double calcInterphaseMassTransferCoefficient(int phaseNum, double schmidtNumber, FlowNodeInterface node) { - double redMassTrans = 0.0, massTrans = 0.0; + double redMassTrans = 0.0; + double massTrans = 0.0; if (phaseNum == 0) { - double c2 = 0.46, c3 = 0.68, c4 = 0.5; + double c2 = 0.46; + double c3 = 0.68; + double c4 = 0.5; redMassTrans = c2 * Math.pow(node.getReynoldsNumber(phaseNum), c3) * Math.pow(schmidtNumber, c4); // System.out.println("red gas " + @@ -102,7 +105,9 @@ public double calcInterphaseMassTransferCoefficient(int phaseNum, double schmidt / schmidtNumber / node.getGeometry().getDiameter(); } if (phaseNum == 1) { - double c2 = 0.181, c3 = 0.72, c4 = 0.33; + double c2 = 0.181; + double c3 = 0.72; + double c4 = 0.33; redMassTrans = c2 * Math.pow(node.getReynoldsNumber(phaseNum), c3) * Math.pow(schmidtNumber, c4); // System.out.println("red liq" + diff --git a/src/main/java/neqsim/fluidmechanics/flownode/multiphasenode/MultiPhaseFlowNode.java b/src/main/java/neqsim/fluidmechanics/flownode/multiphasenode/MultiPhaseFlowNode.java index c2764c2a0..315c29819 100644 --- a/src/main/java/neqsim/fluidmechanics/flownode/multiphasenode/MultiPhaseFlowNode.java +++ b/src/main/java/neqsim/fluidmechanics/flownode/multiphasenode/MultiPhaseFlowNode.java @@ -62,14 +62,14 @@ public TwoPhaseFlowNode clone() { 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(); + molarFlowRate[1] = getBulkSystem().getPhase(1).getNumberOfMolesInPhase(); + molarFlowRate[0] = getBulkSystem().getPhase(0).getNumberOfMolesInPhase(); + massFlowRate[1] = molarFlowRate[1] * getBulkSystem().getPhase(1).getMolarMass(); + massFlowRate[0] = molarFlowRate[0] * getBulkSystem().getPhase(0).getMolarMass(); volumetricFlowRate[0] = - massFlowRate[0] / getBulkSystem().getPhases()[0].getPhysicalProperties().getDensity(); + massFlowRate[0] / getBulkSystem().getPhase(0).getPhysicalProperties().getDensity(); volumetricFlowRate[1] = - massFlowRate[1] / getBulkSystem().getPhases()[1].getPhysicalProperties().getDensity(); + massFlowRate[1] / getBulkSystem().getPhase(1).getPhysicalProperties().getDensity(); velocity[0] = volumetricFlowRate[0] / (phaseFraction[0] * pipe.getArea()); velocity[1] = volumetricFlowRate[1] / (phaseFraction[1] * pipe.getArea()); return velocity[1]; @@ -98,27 +98,27 @@ public void initFlowCalc() { 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() + double Fg = + 0.5 * bulkSystem.getPhase(0).getPhysicalProperties().getDensity() * wallFrictionFactor[0] + * Math.pow(velocity[0], 2.0) * wallContactLength[0] / (pipe.getArea() * 4.0); + double Fl = + 0.5 * bulkSystem.getPhase(1).getPhysicalProperties().getDensity() * wallFrictionFactor[1] + * Math.pow(velocity[1], 2.0) * wallContactLength[1] / (pipe.getArea() * 4.0); + double Fi = 0.5 * bulkSystem.getPhase(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()) + * (bulkSystem.getPhase(1).getPhysicalProperties().getDensity() + - bulkSystem.getPhase(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] + * df = -Fl - Fg + (bulkSystem.getPhase(1).getPhysicalProperties().getDensity() - + * bulkSystem.getPhase(0).getPhysicalProperties().getDensity()) gravity * inclination - + * Math.pow(phaseFraction[0], 2.0) * (bulkSystem.getPhase(1) * .getPhysicalProperties().getDensity() - - * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity()) gravity * inclination; + * bulkSystem.getPhase(0).getPhysicalProperties().getDensity()) gravity * inclination; */ if (f > 0) { @@ -163,11 +163,11 @@ public double calcHydraulicDiameter() { */ public double calcReynoldNumber() { reynoldsNumber[1] = velocity[1] * hydraulicDiameter[1] - * bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[1].getPhysicalProperties().getViscosity(); + * bulkSystem.getPhase(1).getPhysicalProperties().getDensity() + / bulkSystem.getPhase(1).getPhysicalProperties().getViscosity(); reynoldsNumber[0] = velocity[0] * hydraulicDiameter[0] - * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[0].getPhysicalProperties().getViscosity(); + * bulkSystem.getPhase(0).getPhysicalProperties().getDensity() + / bulkSystem.getPhase(0).getPhysicalProperties().getViscosity(); return reynoldsNumber[1]; } @@ -191,12 +191,12 @@ public double calcWallFrictionFactor() { /** {@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]); + for (int i = 0; i < getBulkSystem().getPhase(0).getNumberOfComponents(); i++) { + getBulkSystem().getPhase(0).addMoles(i, -dn[i]); + getBulkSystem().getPhase(1).addMoles(i, +dn[i]); - getInterphaseSystem().getPhases()[0].addMoles(i, -dn[i]); - getInterphaseSystem().getPhases()[1].addMoles(i, +dn[i]); + getInterphaseSystem().getPhase(0).addMoles(i, -dn[i]); + getInterphaseSystem().getPhase(1).addMoles(i, +dn[i]); } } @@ -204,7 +204,7 @@ public void setFluxes(double[] dn) { @Override public void updateMolarFlow() { for (int phaseNum = 0; phaseNum < 2; phaseNum++) { - for (int i = 0; i < getBulkSystem().getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < getBulkSystem().getPhase(0).getNumberOfComponents(); i++) { getBulkSystem().getPhase(phaseNum).addMoles(i, (getBulkSystem().getPhase(phaseNum).getComponent(i).getx() * (molarFlowRate[phaseNum] - getBulkSystem().getPhase(phaseNum).getNumberOfMolesInPhase()))); @@ -228,14 +228,12 @@ public double calcContactLength() { @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(); + massFlowRate[0] = velocity[0] * getBulkSystem().getPhase(0).getPhysicalProperties().getDensity() + * pipe.getArea() * phaseFraction[0]; + massFlowRate[1] = velocity[1] * getBulkSystem().getPhase(1).getPhysicalProperties().getDensity() + * pipe.getArea() * phaseFraction[1]; + molarFlowRate[0] = massFlowRate[0] / getBulkSystem().getPhase(0).getMolarMass(); + molarFlowRate[1] = massFlowRate[1] / getBulkSystem().getPhase(1).getMolarMass(); superficialVelocity[0] = velocity[0] * phaseFraction[0]; superficialVelocity[1] = velocity[1] * phaseFraction[1]; volumetricFlowRate[0] = superficialVelocity[0] * pipe.getArea(); @@ -332,7 +330,7 @@ public void update() { getBulkSystem().getPhase(0) .setTemperature(getBulkSystem().getPhase(0).getTemperature() + gas_dT); - for (int componentNumber = 0; componentNumber < getBulkSystem().getPhases()[0] + for (int componentNumber = 0; componentNumber < getBulkSystem().getPhase(0) .getNumberOfComponents(); componentNumber++) { double liquidMolarRate = getFluidBoundary().getInterphaseMolarFlux(componentNumber) * getInterphaseContactArea(); // getInterphaseContactLength(0)*getGeometry().getNodeLength(); diff --git a/src/main/java/neqsim/fluidmechanics/flownode/multiphasenode/waxnode/WaxDepositionFlowNode.java b/src/main/java/neqsim/fluidmechanics/flownode/multiphasenode/waxnode/WaxDepositionFlowNode.java index 572467e8e..d6670ceb2 100644 --- a/src/main/java/neqsim/fluidmechanics/flownode/multiphasenode/waxnode/WaxDepositionFlowNode.java +++ b/src/main/java/neqsim/fluidmechanics/flownode/multiphasenode/waxnode/WaxDepositionFlowNode.java @@ -104,9 +104,9 @@ public double calcContactLength() { public FlowNodeInterface getNextNode() { StratifiedFlowNode newNode = this.clone(); - 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]); + for (int i = 0; i < getBulkSystem().getPhase(0).getNumberOfComponents(); i++) { + // newNode.getBulkSystem().getPhase(0).addMoles(i, -molarMassTransfer[i]); + // newNode.getBulkSystem().getPhase(1).addMoles(i, +molarMassTransfer[i]); } return newNode; diff --git a/src/main/java/neqsim/fluidmechanics/flownode/onephasenode/onePhaseFlowNode.java b/src/main/java/neqsim/fluidmechanics/flownode/onephasenode/onePhaseFlowNode.java index 4d2603309..a08fb4792 100644 --- a/src/main/java/neqsim/fluidmechanics/flownode/onephasenode/onePhaseFlowNode.java +++ b/src/main/java/neqsim/fluidmechanics/flownode/onephasenode/onePhaseFlowNode.java @@ -60,9 +60,9 @@ public onePhaseFlowNode clone() { /** {@inheritDoc} */ @Override public void increaseMolarRate(double moles) { - for (int i = 0; i < getBulkSystem().getPhases()[0].getNumberOfComponents(); i++) { - double diff = (getBulkSystem().getPhases()[0].getComponent(i).getx() - * (molarFlowRate[0] - getBulkSystem().getPhases()[0].getNumberOfMolesInPhase())); + for (int i = 0; i < getBulkSystem().getPhase(0).getNumberOfComponents(); i++) { + double diff = (getBulkSystem().getPhase(0).getComponent(i).getx() + * (molarFlowRate[0] - getBulkSystem().getPhase(0).getNumberOfMolesInPhase())); getBulkSystem().addComponent(getBulkSystem().getPhase(0).getComponent(i).getComponentName(), diff); } @@ -74,10 +74,10 @@ public void increaseMolarRate(double moles) { @Override public void initFlowCalc() { initBulkSystem(); - molarFlowRate[0] = getBulkSystem().getPhases()[0].getNumberOfMolesInPhase(); - massFlowRate[0] = molarFlowRate[0] * getBulkSystem().getPhases()[0].getMolarMass(); + molarFlowRate[0] = getBulkSystem().getPhase(0).getNumberOfMolesInPhase(); + massFlowRate[0] = molarFlowRate[0] * getBulkSystem().getPhase(0).getMolarMass(); volumetricFlowRate[0] = - massFlowRate[0] / getBulkSystem().getPhases()[0].getPhysicalProperties().getDensity(); + massFlowRate[0] / getBulkSystem().getPhase(0).getPhysicalProperties().getDensity(); superficialVelocity[0] = volumetricFlowRate[0] / pipe.getArea(); velocity[0] = superficialVelocity[0]; this.init(); @@ -86,9 +86,9 @@ public void initFlowCalc() { /** {@inheritDoc} */ @Override public void updateMolarFlow() { - for (int i = 0; i < getBulkSystem().getPhases()[0].getNumberOfComponents(); i++) { - double diff = (getBulkSystem().getPhases()[0].getComponent(i).getx() - * (molarFlowRate[0] - getBulkSystem().getPhases()[0].getNumberOfMolesInPhase())); + for (int i = 0; i < getBulkSystem().getPhase(0).getNumberOfComponents(); i++) { + double diff = (getBulkSystem().getPhase(0).getComponent(i).getx() + * (molarFlowRate[0] - getBulkSystem().getPhase(0).getNumberOfMolesInPhase())); getBulkSystem().addComponent(getBulkSystem().getPhase(0).getComponent(i).getComponentName(), diff); } @@ -98,11 +98,11 @@ public void updateMolarFlow() { // public double initVelocity(){ // initBulkSystem(); - // molarFlowRate[0] = getBulkSystem().getPhases()[0].getNumberOfMolesInPhase(); + // molarFlowRate[0] = getBulkSystem().getPhase(0).getNumberOfMolesInPhase(); // massFlowRate[0] = - // molarFlowRate[0]*getBulkSystem().getPhases()[0].getMolarMass(); + // molarFlowRate[0]*getBulkSystem().getPhase(0).getMolarMass(); // volumetricFlowRate[0] = - // massFlowRate[0]/getBulkSystem().getPhases()[0].getPhysicalProperties().getDensity(); + // massFlowRate[0]/getBulkSystem().getPhase(0).getPhysicalProperties().getDensity(); // superficialVelocity[0] = volumetricFlowRate[0]/pipe.getArea(); // velocity[0] = superficialVelocity[0]; // return velocity[0]; @@ -117,7 +117,7 @@ public void updateMolarFlow() { */ public double calcReynoldsNumber() { reynoldsNumber[0] = getVelocity() * pipe.getDiameter() - / getBulkSystem().getPhases()[0].getPhysicalProperties().getKinematicViscosity(); + / getBulkSystem().getPhase(0).getPhysicalProperties().getKinematicViscosity(); return reynoldsNumber[0]; } @@ -125,14 +125,14 @@ public double calcReynoldsNumber() { @Override public void init() { super.init(); - massFlowRate[0] = velocity[0] - * getBulkSystem().getPhases()[0].getPhysicalProperties().getDensity() * pipe.getArea(); + massFlowRate[0] = velocity[0] * getBulkSystem().getPhase(0).getPhysicalProperties().getDensity() + * pipe.getArea(); superficialVelocity[0] = velocity[0]; - molarFlowRate[0] = massFlowRate[0] / getBulkSystem().getPhases()[0].getMolarMass(); + molarFlowRate[0] = massFlowRate[0] / getBulkSystem().getPhase(0).getMolarMass(); volumetricFlowRate[0] = superficialVelocity[0] * pipe.getArea(); this.updateMolarFlow(); calcReynoldsNumber(); - //System.out.println("specifiedFrictionFactor " +specifiedFrictionFactor[0]); + // System.out.println("specifiedFrictionFactor " +specifiedFrictionFactor[0]); if (specifiedFrictionFactor[0] == null) { wallFrictionFactor[0] = interphaseTransportCoefficient.calcWallFrictionFactor(this); } else { diff --git a/src/main/java/neqsim/fluidmechanics/flownode/onephasenode/onephasepipeflownode/onePhasePipeFlowNode.java b/src/main/java/neqsim/fluidmechanics/flownode/onephasenode/onephasepipeflownode/onePhasePipeFlowNode.java index 5ae2b7869..13e6be14b 100644 --- a/src/main/java/neqsim/fluidmechanics/flownode/onephasenode/onephasepipeflownode/onePhasePipeFlowNode.java +++ b/src/main/java/neqsim/fluidmechanics/flownode/onephasenode/onephasepipeflownode/onePhasePipeFlowNode.java @@ -61,7 +61,7 @@ public onePhasePipeFlowNode clone() { @Override public double calcReynoldsNumber() { reynoldsNumber[0] = getVelocity() * pipe.getDiameter() - / getBulkSystem().getPhases()[0].getPhysicalProperties().getKinematicViscosity(); + / getBulkSystem().getPhase(0).getPhysicalProperties().getKinematicViscosity(); return reynoldsNumber[0]; } diff --git a/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/TwoPhaseFlowNode.java b/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/TwoPhaseFlowNode.java index e14c0e891..57c01dc10 100644 --- a/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/TwoPhaseFlowNode.java +++ b/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/TwoPhaseFlowNode.java @@ -38,13 +38,13 @@ public TwoPhaseFlowNode(SystemInterface system, GeometryDefinitionInterface pipe super(system, pipe); // gasPrandtlNumber = new - // double[getBulkSystem().getPhases()[0].getNumberOfComponents()][getBulkSystem().getPhases()[0].getNumberOfComponents()]; + // double[getBulkSystem().getPhase(0).getNumberOfComponents()][getBulkSystem().getPhase(0).getNumberOfComponents()]; // liquidPrandtlNumber = new - // double[getBulkSystem().getPhases()[0].getNumberOfComponents()][getBulkSystem().getPhases()[0].getNumberOfComponents()]; + // double[getBulkSystem().getPhase(0).getNumberOfComponents()][getBulkSystem().getPhase(0).getNumberOfComponents()]; // molarMassTransferFlux = new - // double[getBulkSystem().getPhases()[0].getNumberOfComponents()]; + // double[getBulkSystem().getPhase(0).getNumberOfComponents()]; // molarMassTransfer = new - // double[getBulkSystem().getPhases()[0].getNumberOfComponents()]; + // double[getBulkSystem().getPhase(0).getNumberOfComponents()]; getBulkSystem().initBeta(); getBulkSystem().init_x_y(); } @@ -77,14 +77,14 @@ public TwoPhaseFlowNode clone() { 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(); + molarFlowRate[1] = getBulkSystem().getPhase(1).getNumberOfMolesInPhase(); + molarFlowRate[0] = getBulkSystem().getPhase(0).getNumberOfMolesInPhase(); + massFlowRate[1] = molarFlowRate[1] * getBulkSystem().getPhase(1).getMolarMass(); + massFlowRate[0] = molarFlowRate[0] * getBulkSystem().getPhase(0).getMolarMass(); volumetricFlowRate[0] = - massFlowRate[0] / getBulkSystem().getPhases()[0].getPhysicalProperties().getDensity(); + massFlowRate[0] / getBulkSystem().getPhase(0).getPhysicalProperties().getDensity(); volumetricFlowRate[1] = - massFlowRate[1] / getBulkSystem().getPhases()[1].getPhysicalProperties().getDensity(); + massFlowRate[1] / getBulkSystem().getPhase(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]); @@ -114,28 +114,28 @@ public void initFlowCalc() { 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() + double Fg = + 0.5 * bulkSystem.getPhase(0).getPhysicalProperties().getDensity() * wallFrictionFactor[0] + * Math.pow(velocity[0], 2.0) * wallContactLength[0] / (pipe.getArea() * 4.0); + double Fl = + 0.5 * bulkSystem.getPhase(1).getPhysicalProperties().getDensity() * wallFrictionFactor[1] + * Math.pow(velocity[1], 2.0) * wallContactLength[1] / (pipe.getArea() * 4.0); + double Fi = 0.5 * bulkSystem.getPhase(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()) + * (bulkSystem.getPhase(1).getPhysicalProperties().getDensity() + - bulkSystem.getPhase(0).getPhysicalProperties().getDensity()) * gravity * inclination; /* - * df = -Fl - Fg + (bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - - * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity()) * gravity * inclination - + * df = -Fl - Fg + (bulkSystem.getPhase(1).getPhysicalProperties().getDensity() - + * bulkSystem.getPhase(0).getPhysicalProperties().getDensity()) * gravity * inclination - * Math.pow(phaseFraction[0], 2.0) - * (bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - - * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity()) gravity * inclination; + * (bulkSystem.getPhase(1).getPhysicalProperties().getDensity() - + * bulkSystem.getPhase(0).getPhysicalProperties().getDensity()) gravity * inclination; */ if (f > 0) { @@ -149,9 +149,9 @@ public void initFlowCalc() { } 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 < 100); // while (Math.abs(f) > 1e-6 && iterations < 100); - while (Math.abs((f - fOld) / f) > 1e-8 && iterations < 100); + if (iterations == 10000) { System.out.println("error in void init calc"); @@ -184,11 +184,11 @@ public double calcHydraulicDiameter() { */ public double calcReynoldNumber() { reynoldsNumber[1] = velocity[1] * hydraulicDiameter[1] - * bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[1].getPhysicalProperties().getViscosity(); + * bulkSystem.getPhase(1).getPhysicalProperties().getDensity() + / bulkSystem.getPhase(1).getPhysicalProperties().getViscosity(); reynoldsNumber[0] = velocity[0] * hydraulicDiameter[0] - * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[0].getPhysicalProperties().getViscosity(); + * bulkSystem.getPhase(0).getPhysicalProperties().getDensity() + / bulkSystem.getPhase(0).getPhysicalProperties().getViscosity(); return reynoldsNumber[1]; } @@ -212,12 +212,12 @@ public double calcWallFrictionFactor() { /** {@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]); + for (int i = 0; i < getBulkSystem().getPhase(0).getNumberOfComponents(); i++) { + getBulkSystem().getPhase(0).addMoles(i, -dn[i]); + getBulkSystem().getPhase(1).addMoles(i, +dn[i]); - getInterphaseSystem().getPhases()[0].addMoles(i, -dn[i]); - getInterphaseSystem().getPhases()[1].addMoles(i, +dn[i]); + getInterphaseSystem().getPhase(0).addMoles(i, -dn[i]); + getInterphaseSystem().getPhase(1).addMoles(i, +dn[i]); } } @@ -225,7 +225,7 @@ public void setFluxes(double[] dn) { @Override public void updateMolarFlow() { for (int phaseNum = 0; phaseNum < 2; phaseNum++) { - for (int i = 0; i < getBulkSystem().getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < getBulkSystem().getPhase(0).getNumberOfComponents(); i++) { if (molarFlowRate[phaseNum] > 1e-100) { getBulkSystem().getPhase(phaseNum).addMoles(i, (getBulkSystem().getPhase(phaseNum).getComponent(i).getx() * (molarFlowRate[phaseNum] @@ -253,14 +253,12 @@ public double calcContactLength() { @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(); + massFlowRate[0] = velocity[0] * getBulkSystem().getPhase(0).getPhysicalProperties().getDensity() + * pipe.getArea() * phaseFraction[0]; + massFlowRate[1] = velocity[1] * getBulkSystem().getPhase(1).getPhysicalProperties().getDensity() + * pipe.getArea() * phaseFraction[1]; + molarFlowRate[0] = massFlowRate[0] / getBulkSystem().getPhase(0).getMolarMass(); + molarFlowRate[1] = massFlowRate[1] / getBulkSystem().getPhase(1).getMolarMass(); superficialVelocity[0] = velocity[0] * phaseFraction[0]; superficialVelocity[1] = velocity[1] * phaseFraction[1]; volumetricFlowRate[0] = superficialVelocity[0] * pipe.getArea(); @@ -376,7 +374,7 @@ public void update() { // System.out.println("liquid velocity " + getSuperficialVelocity(1)); // System.out.println("gas velocity " + getSuperficialVelocity(0)); - for (int componentNumber = 0; componentNumber < getBulkSystem().getPhases()[0] + for (int componentNumber = 0; componentNumber < getBulkSystem().getPhase(0) .getNumberOfComponents(); componentNumber++) { double liquidMolarRate = getFluidBoundary().getInterphaseMolarFlux(componentNumber) * getInterphaseContactArea(); // getInterphaseContactLength(0)*getGeometry().getNodeLength(); @@ -408,7 +406,7 @@ public void update() { * @param deltaTime a double */ public void update(double deltaTime) { - for (int componentNumber = 0; componentNumber < getBulkSystem().getPhases()[0] + for (int componentNumber = 0; componentNumber < getBulkSystem().getPhase(0) .getNumberOfComponents(); componentNumber++) { double liquidMolarRate = getFluidBoundary().getInterphaseMolarFlux(componentNumber) * getInterphaseContactArea(); // getInterphaseContactLength(0)*getGeometry().getNodeLength(); diff --git a/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasepipeflownode/AnnularFlow.java b/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasepipeflownode/AnnularFlow.java index 6084d82b8..6bee3d440 100644 --- a/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasepipeflownode/AnnularFlow.java +++ b/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasepipeflownode/AnnularFlow.java @@ -109,9 +109,9 @@ public double calcContactLength() { public FlowNodeInterface getNextNode() { AnnularFlow newNode = this.clone(); - 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]); + for (int i = 0; i < getBulkSystem().getPhase(0).getNumberOfComponents(); i++) { + // newNode.getBulkSystem().getPhase(0).addMoles(i, -molarMassTransfer[i]); + // newNode.getBulkSystem().getPhase(1).addMoles(i, +molarMassTransfer[i]); } return newNode; } diff --git a/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasepipeflownode/BubbleFlowNode.java b/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasepipeflownode/BubbleFlowNode.java index d3e3af1cd..dddffc7d8 100644 --- a/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasepipeflownode/BubbleFlowNode.java +++ b/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasepipeflownode/BubbleFlowNode.java @@ -135,9 +135,9 @@ public double calcContactLength() { public FlowNodeInterface getNextNode() { BubbleFlowNode newNode = this.clone(); - 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]); + for (int i = 0; i < getBulkSystem().getPhase(0).getNumberOfComponents(); i++) { + // newNode.getBulkSystem().getPhase(0).addMoles(i, -molarMassTransfer[i]); + // newNode.getBulkSystem().getPhase(1).addMoles(i, +molarMassTransfer[i]); } return newNode; diff --git a/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasepipeflownode/DropletFlowNode.java b/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasepipeflownode/DropletFlowNode.java index a1203f428..45b47cc1b 100644 --- a/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasepipeflownode/DropletFlowNode.java +++ b/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasepipeflownode/DropletFlowNode.java @@ -135,9 +135,9 @@ public double calcContactLength() { public FlowNodeInterface getNextNode() { DropletFlowNode newNode = this.clone(); - 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]); + for (int i = 0; i < getBulkSystem().getPhase(0).getNumberOfComponents(); i++) { + // newNode.getBulkSystem().getPhase(0).addMoles(i, -molarMassTransfer[i]); + // newNode.getBulkSystem().getPhase(1).addMoles(i, +molarMassTransfer[i]); } return newNode; diff --git a/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasepipeflownode/StratifiedFlowNode.java b/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasepipeflownode/StratifiedFlowNode.java index e1dc967ba..7a590e0d3 100644 --- a/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasepipeflownode/StratifiedFlowNode.java +++ b/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasepipeflownode/StratifiedFlowNode.java @@ -107,9 +107,9 @@ public double calcContactLength() { public FlowNodeInterface getNextNode() { StratifiedFlowNode newNode = this.clone(); - 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]); + for (int i = 0; i < getBulkSystem().getPhase(0).getNumberOfComponents(); i++) { + // newNode.getBulkSystem().getPhase(0).addMoles(i, -molarMassTransfer[i]); + // newNode.getBulkSystem().getPhase(1).addMoles(i, +molarMassTransfer[i]); } return newNode; 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 6c698b3f4..d569fbc3a 100644 --- a/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasereactorflownode/TwoPhasePackedBedFlowNode.java +++ b/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasereactorflownode/TwoPhasePackedBedFlowNode.java @@ -110,12 +110,12 @@ public double calcHydraulicDiameter() { public double calcReynoldNumber() { reynoldsNumber[1] = getSuperficialVelocity(1) / getGeometry().getPacking().getSurfaceAreaPrVolume() - * bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[1].getPhysicalProperties().getViscosity(); + * bulkSystem.getPhase(1).getPhysicalProperties().getDensity() + / bulkSystem.getPhase(1).getPhysicalProperties().getViscosity(); reynoldsNumber[0] = getSuperficialVelocity(0) / getGeometry().getPacking().getSurfaceAreaPrVolume() - * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[0].getPhysicalProperties().getViscosity(); + * bulkSystem.getPhase(0).getPhysicalProperties().getDensity() + / bulkSystem.getPhase(0).getPhysicalProperties().getViscosity(); System.out.println("rey liq " + reynoldsNumber[1]); System.out.println("rey gas " + reynoldsNumber[0]); return reynoldsNumber[1]; @@ -140,9 +140,9 @@ public double calcGasLiquidContactArea() { public FlowNodeInterface getNextNode() { TwoPhasePackedBedFlowNode newNode = this.clone(); - 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]); + for (int i = 0; i < getBulkSystem().getPhase(0).getNumberOfComponents(); i++) { + // newNode.getBulkSystem().getPhase(0).addMoles(i, -molarMassTransfer[i]); + // newNode.getBulkSystem().getPhase(1).addMoles(i, +molarMassTransfer[i]); } return newNode; @@ -151,7 +151,7 @@ public FlowNodeInterface getNextNode() { /** {@inheritDoc} */ @Override public void update() { - for (int componentNumber = 0; componentNumber < getBulkSystem().getPhases()[0] + for (int componentNumber = 0; componentNumber < getBulkSystem().getPhase(0) .getNumberOfComponents(); componentNumber++) { if (componentNumber == 1) { double liquidMolarRate = @@ -237,8 +237,8 @@ public static void main(String[] args) { testSystem.addComponent("CO2", 2000.11152181, "Nlitre/min", 0); testSystem.setPhysicalPropertyModel(PhysicalPropertyModel.AMINE); testSystem.init_x_y(); - testSystem.getPhases()[1].setTemperature(313.0); - testSystem.getPhases()[0].setTemperature(325.0); + testSystem.getPhase(1).setTemperature(313.0); + testSystem.getPhase(0).setTemperature(325.0); FlowNodeInterface test = new TwoPhasePackedBedFlowNode(testSystem, pipe1); test.setLengthOfNode(0.1); diff --git a/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasereactorflownode/TwoPhaseTrayTowerFlowNode.java b/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasereactorflownode/TwoPhaseTrayTowerFlowNode.java index c04cee9a7..aef7a2f0e 100644 --- a/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasereactorflownode/TwoPhaseTrayTowerFlowNode.java +++ b/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasereactorflownode/TwoPhaseTrayTowerFlowNode.java @@ -112,9 +112,9 @@ public double calcContactLength() { public FlowNodeInterface getNextNode() { TwoPhaseTrayTowerFlowNode newNode = this.clone(); - 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]); + for (int i = 0; i < getBulkSystem().getPhase(0).getNumberOfComponents(); i++) { + // newNode.getBulkSystem().getPhase(0).addMoles(i, -molarMassTransfer[i]); + // newNode.getBulkSystem().getPhase(1).addMoles(i, +molarMassTransfer[i]); } return newNode; @@ -156,8 +156,8 @@ public static void main(String[] args) { // testSystem.init(0); testSystem.init_x_y(); - // testSystem.getPhases()[1].setTemperature(294.0); - // testSystem.getPhases()[0].setTemperature(299.0); + // testSystem.getPhase(1).setTemperature(294.0); + // testSystem.getPhase(0).setTemperature(299.0); FlowNodeInterface test = new TwoPhaseTrayTowerFlowNode(testSystem, pipe1); test.setInterphaseModelType(1); diff --git a/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasestirredcellnode/StirredCellNode.java b/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasestirredcellnode/StirredCellNode.java index 61e93cb4d..0fc1106df 100644 --- a/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasestirredcellnode/StirredCellNode.java +++ b/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasestirredcellnode/StirredCellNode.java @@ -82,11 +82,11 @@ public double calcHydraulicDiameter() { @Override public double calcReynoldNumber() { reynoldsNumber[1] = Math.pow(stirrerDiameter[1], 2.0) * stirrerRate[1] - * bulkSystem.getPhases()[1].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[1].getPhysicalProperties().getViscosity(); + * bulkSystem.getPhase(1).getPhysicalProperties().getDensity() + / bulkSystem.getPhase(1).getPhysicalProperties().getViscosity(); reynoldsNumber[0] = Math.pow(stirrerDiameter[0], 2.0) * stirrerRate[0] - * bulkSystem.getPhases()[0].getPhysicalProperties().getDensity() - / bulkSystem.getPhases()[0].getPhysicalProperties().getViscosity(); + * bulkSystem.getPhase(0).getPhysicalProperties().getDensity() + / bulkSystem.getPhase(0).getPhysicalProperties().getViscosity(); return reynoldsNumber[1]; } @@ -137,15 +137,15 @@ public double calcGasLiquidContactArea() { /** {@inheritDoc} */ @Override public void update() { - for (int componentNumber = 0; componentNumber < getBulkSystem().getPhases()[0] + for (int componentNumber = 0; componentNumber < getBulkSystem().getPhase(0) .getNumberOfComponents(); componentNumber++) { double liquidMolarRate = getFluidBoundary().getInterphaseMolarFlux(componentNumber) * getInterphaseContactArea() * getDt(); double gasMolarRate = -getFluidBoundary().getInterphaseMolarFlux(componentNumber) * getInterphaseContactArea() * getDt(); // System.out.println("liquidMolarRate" + liquidMolarRate); - getBulkSystem().getPhases()[0].addMoles(componentNumber, gasMolarRate); - getBulkSystem().getPhases()[1].addMoles(componentNumber, liquidMolarRate); + getBulkSystem().getPhase(0).addMoles(componentNumber, gasMolarRate); + getBulkSystem().getPhase(1).addMoles(componentNumber, liquidMolarRate); } // getBulkSystem().initBeta(); getBulkSystem().init_x_y(); @@ -161,9 +161,9 @@ public void update() { @Override public FlowNodeInterface getNextNode() { StirredCellNode newNode = this.clone(); - 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]); + for (int i = 0; i < getBulkSystem().getPhase(0).getNumberOfComponents(); i++) { + // newNode.getBulkSystem().getPhase(0).addMoles(i, -molarMassTransfer[i]); + // newNode.getBulkSystem().getPhase(1).addMoles(i, +molarMassTransfer[i]); } return newNode; } 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 198da3b5d..767c5fff6 100644 --- a/src/main/java/neqsim/fluidmechanics/flowsolver/onephaseflowsolver/onephasepipeflowsolver/OnePhaseFixedStaggeredGrid.java +++ b/src/main/java/neqsim/fluidmechanics/flowsolver/onephaseflowsolver/onephasepipeflowsolver/OnePhaseFixedStaggeredGrid.java @@ -61,14 +61,13 @@ public OnePhaseFixedStaggeredGrid( oldMass = new double[nodes]; oldComp = new double[nodes]; oldImpuls = new double[nodes]; - diff4Matrix = - new Matrix[pipe.getNode(0).getBulkSystem().getPhases()[0].getNumberOfComponents()]; + diff4Matrix = new Matrix[pipe.getNode(0).getBulkSystem().getPhase(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]; + new double[pipe.getNode(0).getBulkSystem().getPhase(0).getNumberOfComponents()][nodes]; numberOfVelocityNodes = nodes; } @@ -107,14 +106,14 @@ public void initProfiles() { 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).getBulkSystem().getPhase(0).getTemperature()) + / (pipe.getNode(i).getBulkSystem().getPhase(0).getCp() + / pipe.getNode(i).getBulkSystem().getPhase(0).getNumberOfMolesInPhase() + / pipe.getNode(i).getBulkSystem().getPhase(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() + * pipe.getNode(i + 1).getBulkSystem().getPhase(0).getDensity()) + + pipe.getNode(i + 1).getBulkSystem().getPhase(0).getJouleThomsonCoefficient() * dpdx) * (pipe.getNode(i + 1).getGeometry().getNodeLength() + pipe.getNode(i).getGeometry().getNodeLength()) @@ -132,11 +131,11 @@ public void initProfiles() { 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).getBulkSystem().getPhase(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() + - gravity * pipe.getNode(i).getBulkSystem().getPhase(0).getDensity() * (pipe.getNode(i + 1).getVerticalPositionOfNode() - pipe.getNode(i).getVerticalPositionOfNode()) / 1e5 @@ -155,7 +154,7 @@ public void initProfiles() { * 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()); + * + 1).getBulkSystem().getPhase(0) .getJouleThomsonCoefficient()); */ // setting velocities pipe.getNode(i + 1).setVelocityIn(pipe.getNode(i + 1).getVelocity()); @@ -175,18 +174,18 @@ public void initProfiles() { 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(); + double enthalpy = pipe.getNode(i).getBulkSystem().getPhase(0).getEnthalpy() + / pipe.getNode(i).getBulkSystem().getPhase(0).getNumberOfMolesInPhase() + / pipe.getNode(i).getBulkSystem().getPhase(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] + sol2Matrix.set(i, 0, pipe.getNode(i).getBulkSystem().getPhase(0).getDensity()); + for (int j = 0; j < pipe.getNode(i).getBulkSystem().getPhase(0) .getNumberOfComponents(); j++) { sol4Matrix[j].set(i, 0, - pipe.getNode(i).getBulkSystem().getPhases()[0].getComponent(j).getx() - * pipe.getNode(i).getBulkSystem().getPhases()[0].getComponent(j).getMolarMass() - / pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass()); + pipe.getNode(i).getBulkSystem().getPhase(0).getComponent(j).getx() + * pipe.getNode(i).getBulkSystem().getPhase(0).getComponent(j).getMolarMass() + / pipe.getNode(i).getBulkSystem().getPhase(0).getMolarMass()); } } } @@ -204,7 +203,7 @@ public void initPressure(int iteration) { // 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().getPhase(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, @@ -260,15 +259,15 @@ public void initTemperature(int iteration) { 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).getBulkSystem().getPhase(0).getCp() + / pipe.getNode(i).getBulkSystem().getPhase(0).getNumberOfMolesInPhase() + / pipe.getNode(i).getBulkSystem().getPhase(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())); + // (pipe.getNode(i).getBulkSystem().getPhase(0).getCp() / + // pipe.getNode(i).getBulkSystem().getPhase(0).getNumberOfMolesInPhase() / + // pipe.getNode(i).getBulkSystem().getPhase(0).getMolarMass())); } } @@ -281,16 +280,16 @@ public void initTemperature(int iteration) { */ public void initComposition(int iter) { for (int j = 1; j < numberOfNodes; j++) { - for (int p = 0; p < pipe.getNode(0).getBulkSystem().getPhases()[0] + for (int p = 0; p < pipe.getNode(0).getBulkSystem().getPhase(0) .getNumberOfComponents(); p++) { - pipe.getNode(j).getBulkSystem().getPhases()[0].getComponent(p).setx( - sol4Matrix[p].get(j, 0) * pipe.getNode(j).getBulkSystem().getPhases()[0].getMolarMass() - / pipe.getNode(j).getBulkSystem().getPhases()[0].getComponent(p).getMolarMass()); - // pipe.getNode(j).getBulkSystem().getPhases()[0].getComponent(p).getx() + + pipe.getNode(j).getBulkSystem().getPhase(0).getComponent(p).setx( + sol4Matrix[p].get(j, 0) * pipe.getNode(j).getBulkSystem().getPhase(0).getMolarMass() + / pipe.getNode(j).getBulkSystem().getPhase(0).getComponent(p).getMolarMass()); + // pipe.getNode(j).getBulkSystem().getPhase(0).getComponent(p).getx() + // 0.5*diff4Matrix[p].get(j,0)); } - pipe.getNode(j).getBulkSystem().getPhases()[0].normalize(); + pipe.getNode(j).getBulkSystem().getPhase(0).normalize(); pipe.getNode(j).init(); } } @@ -306,7 +305,7 @@ public void setMassConservationMatrixTDMA() { a[0] = 0; b[0] = 1.0; c[0] = 0; - SU = pipe.getNode(0).getBulkSystem().getPhases()[0].getDensity(); + SU = pipe.getNode(0).getBulkSystem().getPhase(0).getDensity(); r[0] = SU; } else { double Ae = pipe.getNode(1).getGeometry().getArea(); @@ -405,8 +404,8 @@ public void setImpulsMatrixTDMA() { 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 meanDensity = (pipe.getNode(i).getBulkSystem().getPhase(0).getDensity() + + pipe.getNode(i - 1).getBulkSystem().getPhase(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; @@ -421,11 +420,11 @@ public void setImpulsMatrixTDMA() { + 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() + Fw = Aw * pipe.getNode(i - 1).getBulkSystem().getPhase(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() + Fe = Ae * pipe.getNode(i).getBulkSystem().getPhase(0).getDensity() * (pipe.getNode(i).getVelocityIn().doubleValue() + pipe.getNode(i).getVelocityOut().doubleValue()) / 2.0; @@ -452,7 +451,7 @@ public void setImpulsMatrixTDMA() { 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 meanDensity = pipe.getNode(i - 1).getBulkSystem().getPhase(0).getDensity(); double oldMeanDensity = oldDensity[i - 1]; double meanVelocity = pipe.getNode(i - 1).getVelocity(); double vertposchange = pipe.getNode(i).getVerticalPositionOfNode() @@ -466,11 +465,11 @@ public void setImpulsMatrixTDMA() { + 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() + Fw = Aw * pipe.getNode(i - 1).getBulkSystem().getPhase(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() + Fe = Ae * pipe.getNode(i).getBulkSystem().getPhase(0).getDensity() * (pipe.getNode(i).getVelocityIn().doubleValue() + pipe.getNode(i).getVelocityOut().doubleValue()) / 2.0; @@ -500,9 +499,9 @@ 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(); + double SU = pipe.getNode(0).getBulkSystem().getPhase(0).getEnthalpy() + / pipe.getNode(0).getBulkSystem().getPhase(0).getNumberOfMolesInPhase() + / pipe.getNode(0).getBulkSystem().getPhase(0).getMolarMass(); r[0] = SU; for (int i = 1; i < numberOfNodes - 1; i++) { @@ -521,8 +520,8 @@ public void setEnergyMatrixTDMA() { - 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).getBulkSystem().getPhase(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() @@ -530,9 +529,9 @@ public void setEnergyMatrixTDMA() { / (pipe.getNode(i).getGeometry().getDiameter()) * pipe.getNode(i).getGeometry().getNodeLength(); double SP = 0; - double Fw = Aw * pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getDensity() + double Fw = Aw * pipe.getNode(i - 1).getBulkSystem().getPhase(0).getDensity() * pipe.getNode(i).getVelocityIn().doubleValue(); - double Fe = Ae * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() + double Fe = Ae * pipe.getNode(i).getBulkSystem().getPhase(0).getDensity() * pipe.getNode(i).getVelocityOut().doubleValue(); if (dynamic) { @@ -569,8 +568,8 @@ public void setEnergyMatrixTDMA() { - 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).getBulkSystem().getPhase(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() @@ -582,9 +581,9 @@ public void setEnergyMatrixTDMA() { // 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() + double Fw = Aw * pipe.getNode(i - 1).getBulkSystem().getPhase(0).getDensity() * pipe.getNode(i).getVelocityIn().doubleValue(); - double Fe = Ae * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() + double Fe = Ae * pipe.getNode(i).getBulkSystem().getPhase(0).getDensity() * pipe.getNode(i).getVelocity(); if (dynamic) { @@ -613,10 +612,10 @@ public void setComponentConservationMatrix(int componentNumber) { 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] + SU = pipe.getNode(0).getBulkSystem().getPhase(0).getComponents()[componentNumber].getx() + * pipe.getNode(0).getBulkSystem().getPhase(0).getComponents()[componentNumber] .getMolarMass() - / pipe.getNode(0).getBulkSystem().getPhases()[0].getMolarMass(); + / pipe.getNode(0).getBulkSystem().getPhase(0).getMolarMass(); r[0] = SU; for (int i = 1; i < numberOfNodes - 1; i++) { @@ -624,15 +623,15 @@ public void setComponentConservationMatrix(int componentNumber) { double Aw = pipe.getNode(i - 1).getGeometry().getArea(); double Fe = pipe.getNode(i).getVelocityOut().doubleValue() - * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() * Ae; + * pipe.getNode(i).getBulkSystem().getPhase(0).getDensity() * Ae; double Fw = pipe.getNode(i).getVelocityIn().doubleValue() - * pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getDensity() * Aw; + * pipe.getNode(i - 1).getBulkSystem().getPhase(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(); + * pipe.getNode(i).getBulkSystem().getPhase(0).getDensity(); } else { oldComp[i] = 0.0; } @@ -654,14 +653,14 @@ public void setComponentConservationMatrix(int componentNumber) { double Aw = pipe.getNode(i - 1).getGeometry().getArea(); double Fe = pipe.getNode(i).getVelocity() - * pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity() * Ae; + * pipe.getNode(i).getBulkSystem().getPhase(0).getDensity() * Ae; double Fw = pipe.getNode(i).getVelocityIn().doubleValue() - * pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getDensity() * Aw; + * pipe.getNode(i - 1).getBulkSystem().getPhase(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(); + * pipe.getNode(i).getBulkSystem().getPhase(0).getDensity(); } else { oldComp[i] = 0.0; } @@ -682,17 +681,17 @@ public void setComponentConservationMatrix(int componentNumber) { 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(); + oldDensity[i] = pipe.getNode(i).getBulkSystem().getPhase(0).getDensity(); + oldInternalEnergy[i] = pipe.getNode(i).getBulkSystem().getPhase(0).getEnthalpy() + / pipe.getNode(i).getBulkSystem().getPhase(0).getNumberOfMolesInPhase() + / pipe.getNode(i).getBulkSystem().getPhase(0).getMolarMass(); - for (int j = 0; j < pipe.getNode(i).getBulkSystem().getPhases()[0] + for (int j = 0; j < pipe.getNode(i).getBulkSystem().getPhase(0) .getNumberOfComponents(); j++) { oldComposition[j][i] = sol4Matrix[j].get(i, 0); - // pipe.getNode(i).getBulkSystem().getPhases()[0].getComponent(j).getx() * - // pipe.getNode(i).getBulkSystem().getPhases()[0].getComponent(j).getMolarMass() / - // pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass(); + // pipe.getNode(i).getBulkSystem().getPhase(0).getComponent(j).getx() * + // pipe.getNode(i).getBulkSystem().getPhase(0).getComponent(j).getMolarMass() / + // pipe.getNode(i).getBulkSystem().getPhase(0).getMolarMass(); } } } @@ -705,7 +704,7 @@ public void solveTDMA() { int iterTop = 0; double maxDiff = 1.0; double diff = 0; - xNew = new double[pipe.getNode(0).getBulkSystem().getPhases()[0] + xNew = new double[pipe.getNode(0).getBulkSystem().getPhase(0) .getNumberOfComponents()][numberOfNodes]; if (!dynamic) { initProfiles(); @@ -788,7 +787,7 @@ public void solveTDMA() { iter = 0; do { iter++; - for (int p = 0; p < pipe.getNode(0).getBulkSystem().getPhases()[0] + for (int p = 0; p < pipe.getNode(0).getBulkSystem().getPhase(0) .getNumberOfComponents(); p++) { setComponentConservationMatrix(p); Matrix sol4Old = sol4Matrix[p].copy(); 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 67d2b49e1..0b690d6cd 100644 --- a/src/main/java/neqsim/fluidmechanics/flowsolver/onephaseflowsolver/onephasepipeflowsolver/OnePhasePipeFlowSolver.java +++ b/src/main/java/neqsim/fluidmechanics/flowsolver/onephaseflowsolver/onephasepipeflowsolver/OnePhasePipeFlowSolver.java @@ -59,9 +59,8 @@ public OnePhasePipeFlowSolver(PipeFlowSystem pipe, double length, int 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 = new Matrix[pipe.getNode(0).getBulkSystem().getPhase(0).getNumberOfComponents()]; + for (int k = 0; k < pipe.getNode(0).getBulkSystem().getPhase(0).getNumberOfComponents(); k++) { sol4Matrix[k] = new Matrix(PbArray, 1).transpose(); } a = new double[nodes]; 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 89bc531d9..13df7fbf0 100644 --- a/src/main/java/neqsim/fluidmechanics/flowsolver/twophaseflowsolver/stirredcellsolver/StirredCellSolver.java +++ b/src/main/java/neqsim/fluidmechanics/flowsolver/twophaseflowsolver/stirredcellsolver/StirredCellSolver.java @@ -68,14 +68,13 @@ public StirredCellSolver(FlowSystemInterface pipe, double length, int nodes, boo 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()]; + diff4Matrix = new Matrix[pipe.getNode(0).getBulkSystem().getPhase(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]; + oldComposition = + new double[2][pipe.getNode(0).getBulkSystem().getPhase(0).getNumberOfComponents()][nodes]; numberOfVelocityNodes = nodes; } @@ -102,9 +101,8 @@ public void initProfiles() { testOps.TPflash(); testOps.displayResult(); - double[][][] molDiff = - new double[numberOfNodes][2][pipe.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents()]; + double[][][] molDiff = new double[numberOfNodes][2][pipe.getNode(0).getBulkSystem().getPhase(0) + .getNumberOfComponents()]; pipe.getNode(0).init(); pipe.getNode(0).calcFluxes(); @@ -112,7 +110,7 @@ public void initProfiles() { pipe.getNode(i).init(); pipe.getNode(i).calcFluxes(); - for (int componentNumber = 0; componentNumber < pipe.getNode(0).getBulkSystem().getPhases()[0] + for (int componentNumber = 0; componentNumber < pipe.getNode(0).getBulkSystem().getPhase(0) .getNumberOfComponents(); componentNumber++) { double liquidMolarRate = pipe.getNode(i).getFluidBoundary().getInterphaseMolarFlux(componentNumber) @@ -135,9 +133,9 @@ public void initProfiles() { 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, + pipe.getNode(i + 1).getBulkSystem().getPhase(0).addMoles(componentNumber, molDiff[i][0][componentNumber]); - pipe.getNode(i + 1).getBulkSystem().getPhases()[1].addMoles(componentNumber, + pipe.getNode(i + 1).getBulkSystem().getPhase(1).addMoles(componentNumber, molDiff[i][1][componentNumber]); pipe.getNode(i + 1).getBulkSystem().getPhase(0) @@ -150,14 +148,14 @@ public void initProfiles() { pipe.getNode(i + 1).getBulkSystem().init_x_y(); pipe.getNode(i + 1).initFlowCalc(); - System.out.println( - "x " + pipe.getNode(i - 1).getBulkSystem().getPhases()[1].getComponent(0).getx()); - System.out.println( - "x " + pipe.getNode(i - 1).getBulkSystem().getPhases()[1].getComponent(1).getx()); - System.out.println( - "y " + pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getComponent(0).getx()); - System.out.println( - "y " + pipe.getNode(i - 1).getBulkSystem().getPhases()[0].getComponent(1).getx()); + System.out + .println("x " + pipe.getNode(i - 1).getBulkSystem().getPhase(1).getComponent(0).getx()); + System.out + .println("x " + pipe.getNode(i - 1).getBulkSystem().getPhase(1).getComponent(1).getx()); + System.out + .println("y " + pipe.getNode(i - 1).getBulkSystem().getPhase(0).getComponent(0).getx()); + System.out + .println("y " + pipe.getNode(i - 1).getBulkSystem().getPhase(0).getComponent(1).getx()); } pipe.getNode(numberOfNodes - 1).init(); pipe.getNode(numberOfNodes - 1).calcFluxes(); @@ -173,12 +171,12 @@ public void initProfiles() { 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(); + double enthalpy0 = pipe.getNode(i).getBulkSystem().getPhase(0).getEnthalpy() + / pipe.getNode(i).getBulkSystem().getPhase(0).getNumberOfMolesInPhase() + / pipe.getNode(i).getBulkSystem().getPhase(0).getMolarMass(); + double enthalpy1 = pipe.getNode(i).getBulkSystem().getPhase(1).getEnthalpy() + / pipe.getNode(i).getBulkSystem().getPhase(1).getNumberOfMolesInPhase() + / pipe.getNode(i).getBulkSystem().getPhase(1).getMolarMass(); solMatrix[0].set(i, 0, pipe.getNode(i).getVelocityIn(0).doubleValue()); solMatrix[1].set(i, 0, pipe.getNode(i).getVelocityIn(1).doubleValue()); @@ -187,11 +185,11 @@ public void initMatrix() { sol3Matrix[1].set(i, 0, enthalpy1); solPhaseConsMatrix[0].set(i, 0, - pipe.getNode(i).getBulkSystem().getPhases()[0].getPhysicalProperties().getDensity()); + pipe.getNode(i).getBulkSystem().getPhase(0).getPhysicalProperties().getDensity()); solPhaseConsMatrix[1].set(i, 0, pipe.getNode(i).getPhaseFraction(1)); for (int phaseNum = 0; phaseNum < 2; phaseNum++) { - for (int j = 0; j < pipe.getNode(i).getBulkSystem().getPhases()[0] + for (int j = 0; j < pipe.getNode(i).getBulkSystem().getPhase(0) .getNumberOfComponents(); j++) { solMolFracMatrix[phaseNum][j].set(i, 0, pipe.getNode(i).getBulkSystem().getPhase(phaseNum).getComponent(j).getx() @@ -304,7 +302,7 @@ public void initComposition(int phaseNum, int comp) { * pipe.getNode(j).getBulkSystem().getPhase(phaseNum).getMolarMass() / pipe.getNode(j).getBulkSystem().getPhase(phaseNum).getComponents()[comp] .getMolarMass()); - // pipe.getNode(j).getBulkSystem().getPhases()[0].getComponent(p).getx() + + // pipe.getNode(j).getBulkSystem().getPhase(0).getComponent(p).getx() + // 0.5*diff4Matrix[p].get(j,0)); } @@ -331,12 +329,12 @@ 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(); + pipe.getNode(i).getBulkSystem().getPhase(0).getPhysicalProperties().getDensity(); + oldInternalEnergy[phase][i] = pipe.getNode(i).getBulkSystem().getPhase(0).getEnthalpy() + / pipe.getNode(i).getBulkSystem().getPhase(0).getNumberOfMolesInPhase() + / pipe.getNode(i).getBulkSystem().getPhase(0).getMolarMass(); - for (int j = 0; j < pipe.getNode(i).getBulkSystem().getPhases()[0] + for (int j = 0; j < pipe.getNode(i).getBulkSystem().getPhase(0) .getNumberOfComponents(); j++) { oldComposition[phase][j][i] = xNew[phase][j][i]; } 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 47cd5d93f..6aa38cb8c 100644 --- a/src/main/java/neqsim/fluidmechanics/flowsolver/twophaseflowsolver/twophasepipeflowsolver/TwoPhaseFixedStaggeredGridSolver.java +++ b/src/main/java/neqsim/fluidmechanics/flowsolver/twophaseflowsolver/twophasepipeflowsolver/TwoPhaseFixedStaggeredGridSolver.java @@ -66,14 +66,13 @@ public TwoPhaseFixedStaggeredGridSolver(FlowSystemInterface pipe, double length, 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()]; + diff4Matrix = new Matrix[pipe.getNode(0).getBulkSystem().getPhase(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]; + oldComposition = + new double[2][pipe.getNode(0).getBulkSystem().getPhase(0).getNumberOfComponents()][nodes]; numberOfVelocityNodes = nodes; } @@ -97,9 +96,8 @@ public TwoPhaseFixedStaggeredGridSolver clone() { 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()]; + double[][][] molDiff = new double[numberOfNodes][2][pipe.getNode(0).getBulkSystem().getPhase(0) + .getNumberOfComponents()]; pipe.getNode(0).getBulkSystem().initBeta(); pipe.getNode(0).getBulkSystem().init_x_y(); pipe.getNode(0).initFlowCalc(); @@ -126,7 +124,7 @@ public void initProfiles() { 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] + for (int componentNumber = 0; componentNumber < pipe.getNode(0).getBulkSystem().getPhase(0) .getNumberOfComponents(); componentNumber++) { double liquidMolarRate = pipe.getNode(i).getFluidBoundary().getInterphaseMolarFlux(componentNumber) @@ -140,9 +138,9 @@ public void initProfiles() { 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, + pipe.getNode(i + 1).getBulkSystem().getPhase(0).addMoles(componentNumber, molDiff[i - 1][0][componentNumber]); - pipe.getNode(i + 1).getBulkSystem().getPhases()[1].addMoles(componentNumber, + pipe.getNode(i + 1).getBulkSystem().getPhase(1).addMoles(componentNumber, molDiff[i - 1][1][componentNumber]); } } @@ -161,22 +159,22 @@ public void initProfiles() { * getBulkSystem().getPressure())/((pipe.getNode(i+1).getGeometry(). * getNodeLength()+pipe.getNode(i).getGeometry().getNodeLength())*0.5); * pipe.getNode(i+1).getBulkSystem().setTemperature((4.0*12.0*(278.0 - - * pipe.getNode(i).getBulkSystem().getPhases()[0].getTemperature())/ - * (pipe.getNode(i+1).getBulkSystem().getPhases()[0].getCp()/pipe.getNode(i+1). - * getBulkSystem().getPhases()[0].getNumberOfMolesInPhase()/pipe.getNode(i+1). - * getBulkSystem().getPhases()[0].getMolarMass()*pipe.getNode(i+1).getVelocity() + * pipe.getNode(i).getBulkSystem().getPhase(0).getTemperature())/ + * (pipe.getNode(i+1).getBulkSystem().getPhase(0).getCp()/pipe.getNode(i+1). + * getBulkSystem().getPhase(0).getNumberOfMolesInPhase()/pipe.getNode(i+1). + * getBulkSystem().getPhase(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). + * getBulkSystem().getPhase(0).getDensity())+pipe.getNode(i+1).getBulkSystem( + * ).getPhase(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).init(); * * // setting pressures 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.velocity[i]* + * pipe.getNode(i).getBulkSystem().getPhase(0).getDensity()*pipe.velocity[i]* * pipe.velocity[i]/pipe.getNode(i).getGeometry().getDiameter()/2.0*(pipe. * getNode(i).getGeometry().getNodeLength())/1e5 - - * gravity*pipe.getNode(i).getBulkSystem().getPhases()[0].getDensity()*(pipe. + * gravity*pipe.getNode(i).getBulkSystem().getPhase(0).getDensity()*(pipe. * getNode(i+1).getVerticalPositionOfNode() - pipe.getNode(i).getVerticalPositionOfNode() )/1e5 * + pipe.getNode(i).getBulkSystem().getPressure()); err = * err+(oldPres-pipe.getNode(i+1).getBulkSystem().getPressure()); pipe.getNode(i+1).init(); // @@ -194,12 +192,12 @@ public void initProfiles() { 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(); + double enthalpy0 = pipe.getNode(i).getBulkSystem().getPhase(0).getEnthalpy() + / pipe.getNode(i).getBulkSystem().getPhase(0).getNumberOfMolesInPhase() + / pipe.getNode(i).getBulkSystem().getPhase(0).getMolarMass(); + double enthalpy1 = pipe.getNode(i).getBulkSystem().getPhase(1).getEnthalpy() + / pipe.getNode(i).getBulkSystem().getPhase(1).getNumberOfMolesInPhase() + / pipe.getNode(i).getBulkSystem().getPhase(1).getMolarMass(); solMatrix[0].set(i, 0, pipe.getNode(i).getVelocityIn(0).doubleValue()); solMatrix[1].set(i, 0, pipe.getNode(i).getVelocityIn(1).doubleValue()); @@ -208,11 +206,11 @@ public void initMatrix() { sol3Matrix[1].set(i, 0, enthalpy1); solPhaseConsMatrix[0].set(i, 0, - pipe.getNode(i).getBulkSystem().getPhases()[0].getPhysicalProperties().getDensity()); + pipe.getNode(i).getBulkSystem().getPhase(0).getPhysicalProperties().getDensity()); solPhaseConsMatrix[1].set(i, 0, pipe.getNode(i).getPhaseFraction(1)); for (int phaseNum = 0; phaseNum < 2; phaseNum++) { - for (int j = 0; j < pipe.getNode(i).getBulkSystem().getPhases()[0] + for (int j = 0; j < pipe.getNode(i).getBulkSystem().getPhase(0) .getNumberOfComponents(); j++) { solMolFracMatrix[phaseNum][j].set(i, 0, pipe.getNode(i).getBulkSystem().getPhase(phaseNum).getComponent(j).getx() @@ -325,7 +323,7 @@ public void initComposition(int phaseNum, int comp) { * pipe.getNode(j).getBulkSystem().getPhase(phaseNum).getMolarMass() / pipe.getNode(j).getBulkSystem().getPhase(phaseNum).getComponents()[comp] .getMolarMass()); - // pipe.getNode(j).getBulkSystem().getPhases()[0].getComponent(p).getx() + // pipe.getNode(j).getBulkSystem().getPhase(0).getComponent(p).getx() // + 0.5*diff4Matrix[p].get(j,0)); } @@ -785,9 +783,9 @@ public void setComponentConservationMatrix2(int phaseNum, int componentNumber) { c[0] = 0; SU = pipe.getNode(0).getBulkSystem().getPhase(phaseNum).getComponents()[componentNumber].getx(); // System.out.println("phase x0: " - // +pipe.getNode(0).getBulkSystem().getPhases()[0].getComponents()[componentNumber].getx()); + // +pipe.getNode(0).getBulkSystem().getPhase(0).getComponents()[componentNumber].getx()); // System.out.println("phase x1: " - // +pipe.getNode(0).getBulkSystem().getPhases()[1].getComponents()[componentNumber].getx()); + // +pipe.getNode(0).getBulkSystem().getPhase(1).getComponents()[componentNumber].getx()); r[0] = SU; for (int i = 1; i < numberOfNodes - 1; i++) { @@ -952,17 +950,17 @@ 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(); + pipe.getNode(i).getBulkSystem().getPhase(0).getPhysicalProperties().getDensity(); + oldInternalEnergy[phase][i] = pipe.getNode(i).getBulkSystem().getPhase(0).getEnthalpy() + / pipe.getNode(i).getBulkSystem().getPhase(0).getNumberOfMolesInPhase() + / pipe.getNode(i).getBulkSystem().getPhase(0).getMolarMass(); - for (int j = 0; j < pipe.getNode(i).getBulkSystem().getPhases()[0] + for (int j = 0; j < pipe.getNode(i).getBulkSystem().getPhase(0) .getNumberOfComponents(); j++) { oldComposition[phase][j][i] = xNew[phase][j][i]; - // pipe.getNode(i).getBulkSystem().getPhases()[0].getComponent(j).getx() * - // pipe.getNode(i).getBulkSystem().getPhases()[0].getComponent(j).getMolarMass() / - // pipe.getNode(i).getBulkSystem().getPhases()[0].getMolarMass(); + // pipe.getNode(i).getBulkSystem().getPhase(0).getComponent(j).getx() * + // pipe.getNode(i).getBulkSystem().getPhase(0).getComponent(j).getMolarMass() / + // pipe.getNode(i).getBulkSystem().getPhase(0).getMolarMass(); } } } @@ -1000,9 +998,9 @@ public void solveTDMA() { double diff = 0; System.out.println("starting...:"); initProfiles(); - dn = new double[numberOfNodes][pipe.getNode(0).getBulkSystem().getPhases()[0] + dn = new double[numberOfNodes][pipe.getNode(0).getBulkSystem().getPhase(0) .getNumberOfComponents()]; - xNew = new double[2][pipe.getNode(0).getBulkSystem().getPhases()[0] + xNew = new double[2][pipe.getNode(0).getBulkSystem().getPhase(0) .getNumberOfComponents()][numberOfNodes]; initMatrix(); @@ -1103,8 +1101,8 @@ public void solveTDMA() { compIter++; for (int phaseNum = 0; phaseNum < 2; phaseNum++) { iter = 0; - for (int p = 0; p < pipe.getNode(0).getBulkSystem().getPhases()[0] - .getNumberOfComponents() - 1; p++) { + for (int p = 0; p < pipe.getNode(0).getBulkSystem().getPhase(0).getNumberOfComponents() + - 1; p++) { do { iter++; setComponentConservationMatrix(phaseNum, p); @@ -1137,7 +1135,7 @@ public void solveTDMA() { } while (Math.abs(maxDiff) > 1e-7 && iterTop < 1); // diffMatrix.norm2()/sol2Matrix.norm2())>0.1); for (int phaseNum = 0; phaseNum < 2; phaseNum++) { - for (int p = 0; p < pipe.getNode(0).getBulkSystem().getPhases()[0].getNumberOfComponents() + for (int p = 0; p < pipe.getNode(0).getBulkSystem().getPhase(0).getNumberOfComponents() - 1; p++) { Matrix dmat = new Matrix(xNew[phaseNum][p], 1); dmat.print(10, 10); diff --git a/src/main/java/neqsim/fluidmechanics/flowsolver/twophaseflowsolver/twophasepipeflowsolver/TwoPhasePipeFlowSolver.java b/src/main/java/neqsim/fluidmechanics/flowsolver/twophaseflowsolver/twophasepipeflowsolver/TwoPhasePipeFlowSolver.java index 3e85c7140..963496013 100644 --- a/src/main/java/neqsim/fluidmechanics/flowsolver/twophaseflowsolver/twophasepipeflowsolver/TwoPhasePipeFlowSolver.java +++ b/src/main/java/neqsim/fluidmechanics/flowsolver/twophaseflowsolver/twophasepipeflowsolver/TwoPhasePipeFlowSolver.java @@ -56,11 +56,11 @@ public TwoPhasePipeFlowSolver(FlowSystemInterface pipe, double length, int nodes sol3Matrix = new Matrix[2]; solPhaseConsMatrix = new Matrix[2]; solMolFracMatrix = - new Matrix[2][pipe.getNode(0).getBulkSystem().getPhases()[0].getNumberOfComponents()]; + new Matrix[2][pipe.getNode(0).getBulkSystem().getPhase(0).getNumberOfComponents()]; solMatrix[0] = new Matrix(PbArray, 1).transpose(); solMatrix[1] = new Matrix(PbArray, 1).transpose(); for (int phaseNum = 0; phaseNum < 2; phaseNum++) { - for (int i = 0; i < pipe.getNode(0).getBulkSystem().getPhases()[0] + for (int i = 0; i < pipe.getNode(0).getBulkSystem().getPhase(0) .getNumberOfComponents(); i++) { solMolFracMatrix[phaseNum][i] = new Matrix(PbArray, 1).transpose(); } diff --git a/src/main/java/neqsim/fluidmechanics/flowsystem/FlowSystem.java b/src/main/java/neqsim/fluidmechanics/flowsystem/FlowSystem.java index 31e43cffa..5aa2f1fee 100644 --- a/src/main/java/neqsim/fluidmechanics/flowsystem/FlowSystem.java +++ b/src/main/java/neqsim/fluidmechanics/flowsystem/FlowSystem.java @@ -306,12 +306,12 @@ public double[] getLegHeights() { 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].getBulkSystem().getPhase(0).getPressure() + " temperature: " + + flowNode[i].getBulkSystem().getPhase(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].getComponent(1).getx()); + + flowNode[i].getBulkSystem().getPhase(0).getComponent(1).getx()); } } 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 181c90c7d..3a599e01a 100644 --- a/src/main/java/neqsim/fluidmechanics/util/fluidmechanicsvisualization/flownodevisualization/FlowNodeVisualization.java +++ b/src/main/java/neqsim/fluidmechanics/util/fluidmechanicsvisualization/flownodevisualization/FlowNodeVisualization.java @@ -41,17 +41,17 @@ 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(); + temperature[0] = node.getBulkSystem().getPhase(0).getTemperature(); + temperature[1] = node.getBulkSystem().getPhase(1).getTemperature(); + pressure[0] = node.getBulkSystem().getPhase(0).getPressure(); + pressure[1] = node.getBulkSystem().getPhase(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(); + numberOfComponents = node.getBulkSystem().getPhase(0).getNumberOfComponents(); nodeCenter = node.getDistanceToCenterOfNode(); } 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 72fe0f7dc..5af8a53a6 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 @@ -29,10 +29,10 @@ public OnePhasePipeFlowNodeVisualization() {} @Override public void setData(FlowNodeInterface node) { super.setData(node); - bulkComposition = new double[2][node.getBulkSystem().getPhases()[0].getNumberOfComponents()]; + bulkComposition = new double[2][node.getBulkSystem().getPhase(0).getNumberOfComponents()]; - for (int i = 0; i < node.getBulkSystem().getPhases()[0].getNumberOfComponents(); i++) { - bulkComposition[0][i] = node.getBulkSystem().getPhases()[0].getComponent(i).getx(); + for (int i = 0; i < node.getBulkSystem().getPhase(0).getNumberOfComponents(); i++) { + bulkComposition[0][i] = node.getBulkSystem().getPhase(0).getComponent(i).getx(); } } } diff --git a/src/main/java/neqsim/fluidmechanics/util/fluidmechanicsvisualization/flownodevisualization/twophaseflownodevisualization/TwoPhaseFlowNodeVisualization.java b/src/main/java/neqsim/fluidmechanics/util/fluidmechanicsvisualization/flownodevisualization/twophaseflownodevisualization/TwoPhaseFlowNodeVisualization.java index 262652a75..49d2dd8f3 100644 --- a/src/main/java/neqsim/fluidmechanics/util/fluidmechanicsvisualization/flownodevisualization/twophaseflownodevisualization/TwoPhaseFlowNodeVisualization.java +++ b/src/main/java/neqsim/fluidmechanics/util/fluidmechanicsvisualization/flownodevisualization/twophaseflownodevisualization/TwoPhaseFlowNodeVisualization.java @@ -23,18 +23,17 @@ public TwoPhaseFlowNodeVisualization() {} @Override public void setData(FlowNodeInterface node) { super.setData(node); - bulkComposition = new double[2][node.getBulkSystem().getPhases()[0].getNumberOfComponents()]; + bulkComposition = new double[2][node.getBulkSystem().getPhase(0).getNumberOfComponents()]; effectiveMassTransferCoefficient = - new double[2][node.getBulkSystem().getPhases()[0].getNumberOfComponents()]; + new double[2][node.getBulkSystem().getPhase(0).getNumberOfComponents()]; effectiveSchmidtNumber = - new double[2][node.getBulkSystem().getPhases()[0].getNumberOfComponents()]; - interfaceComposition = - new double[2][node.getBulkSystem().getPhases()[0].getNumberOfComponents()]; - molarFlux = new double[2][node.getBulkSystem().getPhases()[0].getNumberOfComponents()]; + new double[2][node.getBulkSystem().getPhase(0).getNumberOfComponents()]; + interfaceComposition = new double[2][node.getBulkSystem().getPhase(0).getNumberOfComponents()]; + molarFlux = new double[2][node.getBulkSystem().getPhase(0).getNumberOfComponents()]; - for (int i = 0; i < node.getBulkSystem().getPhases()[0].getNumberOfComponents(); i++) { - bulkComposition[0][i] = node.getBulkSystem().getPhases()[0].getComponent(i).getx(); - bulkComposition[1][i] = node.getBulkSystem().getPhases()[1].getComponent(i).getx(); + for (int i = 0; i < node.getBulkSystem().getPhase(0).getNumberOfComponents(); i++) { + bulkComposition[0][i] = node.getBulkSystem().getPhase(0).getComponent(i).getx(); + bulkComposition[1][i] = node.getBulkSystem().getPhase(1).getComponent(i).getx(); effectiveMassTransferCoefficient[1][i] = node.getFluidBoundary().getEffectiveMassTransferCoefficient(1, i); effectiveMassTransferCoefficient[0][i] = @@ -43,9 +42,9 @@ public void setData(FlowNodeInterface node) { effectiveSchmidtNumber[1][i] = node.getEffectiveSchmidtNumber(1, i); // System.out.println("sc " + effectiveSchmidtNumber[1][i]); interfaceComposition[0][i] = - node.getFluidBoundary().getInterphaseSystem().getPhases()[0].getComponent(i).getx(); + node.getFluidBoundary().getInterphaseSystem().getPhase(0).getComponent(i).getx(); interfaceComposition[1][i] = - node.getFluidBoundary().getInterphaseSystem().getPhases()[1].getComponent(i).getx(); + node.getFluidBoundary().getInterphaseSystem().getPhase(1).getComponent(i).getx(); molarFlux[0][i] = node.getFluidBoundary().getInterphaseMolarFlux(i); molarFlux[1][i] = node.getFluidBoundary().getInterphaseMolarFlux(i); } @@ -55,8 +54,8 @@ public void setData(FlowNodeInterface node) { phaseFraction[0] = node.getPhaseFraction(0); phaseFraction[1] = node.getPhaseFraction(1); interfaceTemperature[0] = - node.getFluidBoundary().getInterphaseSystem().getPhases()[0].getTemperature(); + node.getFluidBoundary().getInterphaseSystem().getPhase(0).getTemperature(); interfaceTemperature[1] = - node.getFluidBoundary().getInterphaseSystem().getPhases()[1].getTemperature(); + node.getFluidBoundary().getInterphaseSystem().getPhase(1).getTemperature(); } } diff --git a/src/main/java/neqsim/mathlib/nonlinearsolver/SysNewtonRhapson.java b/src/main/java/neqsim/mathlib/nonlinearsolver/SysNewtonRhapson.java index 2d4f86719..8e30b49c7 100644 --- a/src/main/java/neqsim/mathlib/nonlinearsolver/SysNewtonRhapson.java +++ b/src/main/java/neqsim/mathlib/nonlinearsolver/SysNewtonRhapson.java @@ -86,13 +86,13 @@ public SysNewtonRhapson(SystemInterface system, int numberOfPhases, int numberOf public void setfvec() { for (int i = 0; i < numberOfComponents; i++) { fvec.set(i, 0, - u.get(i, 0) + Math.log(system.getPhases()[1].getComponent(i).getFugacityCoefficient() - / system.getPhases()[0].getComponent(i).getFugacityCoefficient())); + u.get(i, 0) + Math.log(system.getPhase(1).getComponent(i).getFugacityCoefficient() + / system.getPhase(0).getComponent(i).getFugacityCoefficient())); } double fsum = 0.0; for (int i = 0; i < numberOfComponents; i++) { - fsum = fsum + system.getPhases()[1].getComponent(i).getx() - - system.getPhases()[0].getComponent(i).getx(); + fsum = fsum + system.getPhase(1).getComponent(i).getx() + - system.getPhase(0).getComponent(i).getx(); } fvec.set(numberOfComponents, 0, fsum); fvec.set(numberOfComponents + 1, 0, 0.0); @@ -110,17 +110,17 @@ public void findSpecEqInit() { int speceqmin = 0; for (int i = 0; i < numberOfComponents; i++) { - if (system.getPhases()[0].getComponent(i).getTC() > system.getPhases()[0].getComponent(speceq) + if (system.getPhase(0).getComponent(i).getTC() > system.getPhase(0).getComponent(speceq) .getTC()) { - speceq = system.getPhases()[0].getComponent(i).getComponentNumber(); + speceq = system.getPhase(0).getComponent(i).getComponentNumber(); } - if (system.getPhases()[0].getComponent(i).getTC() < system.getPhases()[0].getComponent(speceq) + if (system.getPhase(0).getComponent(i).getTC() < system.getPhase(0).getComponent(speceq) .getTC()) { - speceqmin = system.getPhases()[0].getComponent(i).getComponentNumber(); + speceqmin = system.getPhase(0).getComponent(i).getComponentNumber(); } } - avscp = (system.getPhases()[0].getComponent(speceq).getTC() - - system.getPhases()[0].getComponent(speceqmin).getTC()) / 2000; + avscp = (system.getPhase(0).getComponent(speceq).getTC() + - system.getPhase(0).getComponent(speceqmin).getTC()) / 2000; System.out.println("avscp: " + avscp); dTmax = avscp * 3; dPmax = avscp * 1.5; @@ -154,26 +154,25 @@ public void setJac() { double tempJ = 0.0; int nofc = numberOfComponents; for (int i = 0; i < numberOfComponents; i++) { - dxidlnk[i] = -system.getBeta() * system.getPhases()[0].getComponent(i).getx() - * system.getPhases()[1].getComponent(i).getx() - / system.getPhases()[0].getComponent(i).getz(); - dyidlnk[i] = system.getPhases()[1].getComponent(i).getx() - + system.getPhases()[0].getComponent(i).getK() * dxidlnk[i]; + dxidlnk[i] = -system.getBeta() * system.getPhase(0).getComponent(i).getx() + * system.getPhase(1).getComponent(i).getx() / system.getPhase(0).getComponent(i).getz(); + dyidlnk[i] = system.getPhase(1).getComponent(i).getx() + + system.getPhase(0).getComponent(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].getComponent(i).getdfugdx(j) * dyidlnk[j] - - system.getPhases()[0].getComponent(i).getdfugdx(j) * dxidlnk[j]; + tempJ = dij + system.getPhase(1).getComponent(i).getdfugdx(j) * dyidlnk[j] + - system.getPhase(0).getComponent(i).getdfugdx(j) * dxidlnk[j]; Jac.set(i, j, tempJ); } - tempJ = system.getTemperature() * (system.getPhases()[1].getComponent(i).getdfugdt() - - system.getPhases()[0].getComponent(i).getdfugdt()); + tempJ = system.getTemperature() * (system.getPhase(1).getComponent(i).getdfugdt() + - system.getPhase(0).getComponent(i).getdfugdt()); Jac.set(i, nofc, tempJ); - tempJ = system.getPressure() * (system.getPhases()[1].getComponent(i).getdfugdp() - - system.getPhases()[0].getComponent(i).getdfugdp()); + tempJ = system.getPressure() * (system.getPhase(1).getComponent(i).getdfugdp() + - system.getPhase(0).getComponent(i).getdfugdp()); Jac.set(i, nofc + 1, tempJ); Jac.set(nofc, i, dyidlnk[i] - dxidlnk[i]); } @@ -187,7 +186,7 @@ public void setJac() { */ public void setu() { for (int i = 0; i < numberOfComponents; i++) { - u.set(i, 0, Math.log(system.getPhases()[0].getComponent(i).getK())); + u.set(i, 0, Math.log(system.getPhase(0).getComponent(i).getK())); } u.set(numberOfComponents, 0, Math.log(system.getTemperature())); u.set(numberOfComponents + 1, 0, Math.log(system.getPressure())); @@ -200,8 +199,8 @@ public void setu() { */ public void init() { for (int i = 0; i < numberOfComponents; i++) { - system.getPhases()[0].getComponent(i).setK(Math.exp(u.get(i, 0))); - system.getPhases()[1].getComponent(i).setK(Math.exp(u.get(i, 0))); + system.getPhase(0).getComponent(i).setK(Math.exp(u.get(i, 0))); + system.getPhase(1).getComponent(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))); diff --git a/src/main/java/neqsim/physicalproperties/interfaceproperties/surfacetension/FirozabadiRamleyInterfaceTension.java b/src/main/java/neqsim/physicalproperties/interfaceproperties/surfacetension/FirozabadiRamleyInterfaceTension.java index 42c5ebdbe..08faccc1d 100644 --- a/src/main/java/neqsim/physicalproperties/interfaceproperties/surfacetension/FirozabadiRamleyInterfaceTension.java +++ b/src/main/java/neqsim/physicalproperties/interfaceproperties/surfacetension/FirozabadiRamleyInterfaceTension.java @@ -41,13 +41,13 @@ public FirozabadiRamleyInterfaceTension(SystemInterface system) { @Override public double calcPureComponentSurfaceTension(int componentNumber) { return 1.0e-3 * Math - .pow(system.getPhases()[0].getComponents()[componentNumber].getParachorParameter() * 1.0e-6 - * (system.getPhases()[1].getPhysicalProperties().getDensity() - / system.getPhases()[1].getMolarMass() - * system.getPhases()[1].getComponents()[componentNumber].getx() - - system.getPhases()[0].getPhysicalProperties().getDensity() - / system.getPhases()[0].getMolarMass() - * system.getPhases()[0].getComponents()[componentNumber].getx()), + .pow(system.getPhase(0).getComponents()[componentNumber].getParachorParameter() * 1.0e-6 + * (system.getPhase(1).getPhysicalProperties().getDensity() + / system.getPhase(1).getMolarMass() + * system.getPhase(1).getComponents()[componentNumber].getx() + - system.getPhase(0).getPhysicalProperties().getDensity() + / system.getPhase(0).getMolarMass() + * system.getPhase(0).getComponents()[componentNumber].getx()), 4.0); } diff --git a/src/main/java/neqsim/physicalproperties/interfaceproperties/surfacetension/ParachorSurfaceTension.java b/src/main/java/neqsim/physicalproperties/interfaceproperties/surfacetension/ParachorSurfaceTension.java index 0e36241e7..3d8fc459a 100644 --- a/src/main/java/neqsim/physicalproperties/interfaceproperties/surfacetension/ParachorSurfaceTension.java +++ b/src/main/java/neqsim/physicalproperties/interfaceproperties/surfacetension/ParachorSurfaceTension.java @@ -40,15 +40,14 @@ public ParachorSurfaceTension(SystemInterface system) { */ @Override public double calcPureComponentSurfaceTension(int componentNumber) { - return 1.0e-3 * Math.pow(system.getPhases()[0].getComponents()[componentNumber] - .getParachorParameter() - * 1.0e-6 - * (system.getPhases()[1].getPhysicalProperties().getDensity() - / system.getPhases()[1].getMolarMass() - * system.getPhases()[1].getComponents()[componentNumber].getx() - - system.getPhases()[0].getPhysicalProperties().getDensity() - / system.getPhases()[0].getMolarMass() - * system.getPhases()[0].getComponents()[componentNumber].getx()), + return 1.0e-3 * Math + .pow(system.getPhase(0).getComponents()[componentNumber].getParachorParameter() * 1.0e-6 + * (system.getPhase(1).getPhysicalProperties().getDensity() + / system.getPhase(1).getMolarMass() + * system.getPhase(1).getComponents()[componentNumber].getx() + - system.getPhase(0).getPhysicalProperties().getDensity() + / system.getPhase(0).getMolarMass() + * system.getPhase(0).getComponents()[componentNumber].getx()), 4.0); } @@ -68,7 +67,7 @@ public double calcSurfaceTension(int interface1, int interface2) { // if(interface1>=2 || interface2>=2) return 0.0; // return 0.0; try { - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { // System.out.println("density1 parachor " + // system.getPhase(interface1).getPhysicalProperties().getDensity()); // System.out.println("density2 parachor " + diff --git a/src/main/java/neqsim/physicalproperties/util/parameterfitting/purecomponentparameterfitting/purecompinterfacetension/ParachorFunction.java b/src/main/java/neqsim/physicalproperties/util/parameterfitting/purecomponentparameterfitting/purecompinterfacetension/ParachorFunction.java index 53b513eb0..e66e48f0c 100644 --- a/src/main/java/neqsim/physicalproperties/util/parameterfitting/purecomponentparameterfitting/purecompinterfacetension/ParachorFunction.java +++ b/src/main/java/neqsim/physicalproperties/util/parameterfitting/purecomponentparameterfitting/purecompinterfacetension/ParachorFunction.java @@ -41,7 +41,7 @@ public double calcValue(double[] dependentValues) { @Override public void setFittingParams(int i, double value) { params[i] = value; - system.getPhases()[0].getComponent(0).setParachorParameter(value); - system.getPhases()[1].getComponent(0).setParachorParameter(value); + system.getPhase(0).getComponent(0).setParachorParameter(value); + system.getPhase(1).getComponent(0).setParachorParameter(value); } } diff --git a/src/main/java/neqsim/physicalproperties/util/parameterfitting/purecomponentparameterfitting/purecompviscosity/chungmethod/ChungFunction.java b/src/main/java/neqsim/physicalproperties/util/parameterfitting/purecomponentparameterfitting/purecompviscosity/chungmethod/ChungFunction.java index 40281c278..98fd649a6 100644 --- a/src/main/java/neqsim/physicalproperties/util/parameterfitting/purecomponentparameterfitting/purecompviscosity/chungmethod/ChungFunction.java +++ b/src/main/java/neqsim/physicalproperties/util/parameterfitting/purecomponentparameterfitting/purecompviscosity/chungmethod/ChungFunction.java @@ -26,14 +26,14 @@ public double calcValue(double[] dependentValues) { system.setTemperature(dependentValues[0]); system.init(1); system.initPhysicalProperties(); - return system.getPhases()[1].getPhysicalProperties().getViscosity(); + return system.getPhase(1).getPhysicalProperties().getViscosity(); } /** {@inheritDoc} */ @Override public void setFittingParams(int i, double value) { params[i] = value; - system.getPhases()[0].getComponent(i).setViscosityAssociationFactor(value); - system.getPhases()[1].getComponent(i).setViscosityAssociationFactor(value); + system.getPhase(0).getComponent(i).setViscosityAssociationFactor(value); + system.getPhase(1).getComponent(i).setViscosityAssociationFactor(value); } } 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 ba51ae057..68672bcd0 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 @@ -29,14 +29,14 @@ public ViscosityFunction() {} public double calcValue(double[] dependentValues) { system.init(1); system.initPhysicalProperties(); - return system.getPhases()[1].getPhysicalProperties().getViscosity() * 1e3; + return system.getPhase(1).getPhysicalProperties().getViscosity() * 1e3; } /** {@inheritDoc} */ @Override public void setFittingParams(int i, double value) { params[i] = value; - system.getPhases()[0].getComponent(0).setLiquidViscosityParameter(value, i); - system.getPhases()[1].getComponent(0).setLiquidViscosityParameter(value, i); + system.getPhase(0).getComponent(0).setLiquidViscosityParameter(value, i); + system.getPhase(1).getComponent(0).setLiquidViscosityParameter(value, i); } } diff --git a/src/main/java/neqsim/process/equipment/absorber/SimpleTEGAbsorber.java b/src/main/java/neqsim/process/equipment/absorber/SimpleTEGAbsorber.java index 198dbd30a..b0dd67a3c 100644 --- a/src/main/java/neqsim/process/equipment/absorber/SimpleTEGAbsorber.java +++ b/src/main/java/neqsim/process/equipment/absorber/SimpleTEGAbsorber.java @@ -126,24 +126,24 @@ 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] + for (int i = 0; i < streams.get(k).getThermoSystem().getPhase(0) .getNumberOfComponents(); i++) { boolean gotComponent = false; String componentName = - streams.get(k).getThermoSystem().getPhases()[0].getComponent(i).getName(); + streams.get(k).getThermoSystem().getPhase(0).getComponent(i).getName(); // System.out.println("adding: " + componentName); double moles = - streams.get(k).getThermoSystem().getPhases()[0].getComponent(i).getNumberOfmoles(); + streams.get(k).getThermoSystem().getPhase(0).getComponent(i).getNumberOfmoles(); // System.out.println("moles: " + moles + " " + - // mixedStream.getThermoSystem().getPhases()[0].getNumberOfComponents()); - for (int p = 0; p < mixedStream.getThermoSystem().getPhases()[0] + // mixedStream.getThermoSystem().getPhase(0).getNumberOfComponents()); + for (int p = 0; p < mixedStream.getThermoSystem().getPhase(0) .getNumberOfComponents(); p++) { - if (mixedStream.getThermoSystem().getPhases()[0].getComponent(p).getName() + if (mixedStream.getThermoSystem().getPhase(0).getComponent(p).getName() .equals(componentName)) { gotComponent = true; - compName = streams.get(0).getThermoSystem().getPhases()[0].getComponent(p) - .getComponentName(); + compName = + streams.get(0).getThermoSystem().getPhase(0).getComponent(p).getComponentName(); } } @@ -369,14 +369,14 @@ public void run(UUID id) { // stream.getThermoSystem().display(); SystemInterface tempSystem = mixedStream.getThermoSystem().clone(); - SystemInterface gasTemp = tempSystem.phaseToSystem(tempSystem.getPhases()[0]); + SystemInterface gasTemp = tempSystem.phaseToSystem(tempSystem.getPhase(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]); + SystemInterface liqTemp = tempSystem.phaseToSystem(tempSystem.getPhase(1)); liqTemp.init(2); solventOutStream.setThermoSystem(liqTemp); // System.out.println("solvent total number of water " + @@ -447,74 +447,73 @@ public void displayResult() { 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].getComponent(j).getName(); + for (int j = 0; j < thermoSystem.getPhase(0).getNumberOfComponents(); j++) { + table[j + 1][0] = thermoSystem.getPhase(0).getComponent(j).getName(); buf = new StringBuffer(); table[j + 1][i + 1] = - nf.format(thermoSystem.getPhases()[i].getComponent(j).getx(), buf, test).toString(); + nf.format(thermoSystem.getPhase(i).getComponent(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) + table[thermoSystem.getPhase(0).getNumberOfComponents() + 2][0] = "Density"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 2][i + 1] = + nf.format(thermoSystem.getPhase(i).getPhysicalProperties().getDensity(), buf, test) .toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 2][4] = "[kg/m^3]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 2][4] = "[kg/m^3]"; - // Double.longValue(thermoSystem.getPhases()[i].getBeta()); + // Double.longValue(thermoSystem.getPhase(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] = "[-]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 3][0] = "PhaseFraction"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 3][i + 1] = + nf.format(thermoSystem.getPhase(i).getBeta(), buf, test).toString(); + table[thermoSystem.getPhase(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]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 4][0] = "MolarMass"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 4][i + 1] = + nf.format(thermoSystem.getPhase(i).getMolarMass() * 1000, buf, test).toString(); + table[thermoSystem.getPhase(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]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 5][0] = "Cp"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 5][i + 1] = nf.format( + (thermoSystem.getPhase(i).getCp() / (thermoSystem.getPhase(i).getNumberOfMolesInPhase() + * thermoSystem.getPhase(i).getMolarMass() * 1000)), + buf, test).toString(); + table[thermoSystem.getPhase(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) + table[thermoSystem.getPhase(0).getNumberOfComponents() + 7][0] = "Viscosity"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 7][i + 1] = + nf.format((thermoSystem.getPhase(i).getPhysicalProperties().getViscosity()), buf, test) .toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 7][4] = "[kg/m*sec]"; + table[thermoSystem.getPhase(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]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 8][0] = "Conductivity"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 8][i + 1] = + nf.format(thermoSystem.getPhase(i).getPhysicalProperties().getConductivity(), buf, test) + .toString(); + table[thermoSystem.getPhase(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]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 10][0] = "Pressure"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 10][i + 1] = + Double.toString(thermoSystem.getPhase(i).getPressure()); + table[thermoSystem.getPhase(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()); + table[thermoSystem.getPhase(0).getNumberOfComponents() + 11][0] = "Temperature"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 11][i + 1] = + Double.toString(thermoSystem.getPhase(i).getTemperature()); + table[thermoSystem.getPhase(0).getNumberOfComponents() + 11][4] = "[K]"; + Double.toString(thermoSystem.getPhase(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] = "-"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 13][0] = "Stream"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 13][i + 1] = getName(); + table[thermoSystem.getPhase(0).getNumberOfComponents() + 13][4] = "-"; } JTable Jtab = new JTable(table, names); diff --git a/src/main/java/neqsim/process/equipment/absorber/WaterStripperColumn.java b/src/main/java/neqsim/process/equipment/absorber/WaterStripperColumn.java index 9d8e74bc3..2d5c98cf9 100644 --- a/src/main/java/neqsim/process/equipment/absorber/WaterStripperColumn.java +++ b/src/main/java/neqsim/process/equipment/absorber/WaterStripperColumn.java @@ -125,25 +125,25 @@ 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] + for (int i = 0; i < streams.get(k).getThermoSystem().getPhase(0) .getNumberOfComponents(); i++) { boolean gotComponent = false; String componentName = - streams.get(k).getThermoSystem().getPhases()[0].getComponent(i).getName(); + streams.get(k).getThermoSystem().getPhase(0).getComponent(i).getName(); // System.out.println("adding: " + componentName); double moles = - streams.get(k).getThermoSystem().getPhases()[0].getComponent(i).getNumberOfmoles(); + streams.get(k).getThermoSystem().getPhase(0).getComponent(i).getNumberOfmoles(); // System.out.println("moles: " + moles + " " + - // mixedStream.getThermoSystem().getPhases()[0].getNumberOfComponents()); - for (int p = 0; p < mixedStream.getThermoSystem().getPhases()[0] + // mixedStream.getThermoSystem().getPhase(0).getNumberOfComponents()); + for (int p = 0; p < mixedStream.getThermoSystem().getPhase(0) .getNumberOfComponents(); p++) { - if (mixedStream.getThermoSystem().getPhases()[0].getComponent(p).getName() + if (mixedStream.getThermoSystem().getPhase(0).getComponent(p).getName() .equals(componentName)) { gotComponent = true; - compName = streams.get(0).getThermoSystem().getPhases()[0].getComponent(p) - .getComponentName(); + compName = + streams.get(0).getThermoSystem().getPhase(0).getComponent(p).getComponentName(); } } @@ -350,13 +350,13 @@ public void run(UUID id) { // stream.getThermoSystem().display(); SystemInterface tempSystem = mixedStream.getThermoSystem().clone(); - SystemInterface gasTemp = tempSystem.phaseToSystem(tempSystem.getPhases()[0]); + SystemInterface gasTemp = tempSystem.phaseToSystem(tempSystem.getPhase(0)); gasTemp.init(2); gasOutStream.setThermoSystem(gasTemp); gasOutStream.setCalculationIdentifier(id); tempSystem = mixedStream.getThermoSystem().clone(); - SystemInterface liqTemp = tempSystem.phaseToSystem(tempSystem.getPhases()[1]); + SystemInterface liqTemp = tempSystem.phaseToSystem(tempSystem.getPhase(1)); liqTemp.init(2); solventOutStream.setThermoSystem(liqTemp); solventOutStream.run(id); @@ -399,74 +399,73 @@ public void displayResult() { 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].getComponent(j).getName(); + for (int j = 0; j < thermoSystem.getPhase(0).getNumberOfComponents(); j++) { + table[j + 1][0] = thermoSystem.getPhase(0).getComponent(j).getName(); buf = new StringBuffer(); table[j + 1][i + 1] = - nf.format(thermoSystem.getPhases()[i].getComponent(j).getx(), buf, test).toString(); + nf.format(thermoSystem.getPhase(i).getComponent(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) + table[thermoSystem.getPhase(0).getNumberOfComponents() + 2][0] = "Density"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 2][i + 1] = + nf.format(thermoSystem.getPhase(i).getPhysicalProperties().getDensity(), buf, test) .toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 2][4] = "[kg/m^3]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 2][4] = "[kg/m^3]"; - // Double.longValue(thermoSystem.getPhases()[i].getBeta()); + // Double.longValue(thermoSystem.getPhase(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] = "[-]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 3][0] = "PhaseFraction"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 3][i + 1] = + nf.format(thermoSystem.getPhase(i).getBeta(), buf, test).toString(); + table[thermoSystem.getPhase(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]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 4][0] = "MolarMass"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 4][i + 1] = + nf.format(thermoSystem.getPhase(i).getMolarMass() * 1000, buf, test).toString(); + table[thermoSystem.getPhase(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]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 5][0] = "Cp"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 5][i + 1] = nf.format( + (thermoSystem.getPhase(i).getCp() / (thermoSystem.getPhase(i).getNumberOfMolesInPhase() + * thermoSystem.getPhase(i).getMolarMass() * 1000)), + buf, test).toString(); + table[thermoSystem.getPhase(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) + table[thermoSystem.getPhase(0).getNumberOfComponents() + 7][0] = "Viscosity"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 7][i + 1] = + nf.format((thermoSystem.getPhase(i).getPhysicalProperties().getViscosity()), buf, test) .toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 7][4] = "[kg/m*sec]"; + table[thermoSystem.getPhase(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]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 8][0] = "Conductivity"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 8][i + 1] = + nf.format(thermoSystem.getPhase(i).getPhysicalProperties().getConductivity(), buf, test) + .toString(); + table[thermoSystem.getPhase(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]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 10][0] = "Pressure"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 10][i + 1] = + Double.toString(thermoSystem.getPhase(i).getPressure()); + table[thermoSystem.getPhase(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()); + table[thermoSystem.getPhase(0).getNumberOfComponents() + 11][0] = "Temperature"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 11][i + 1] = + Double.toString(thermoSystem.getPhase(i).getTemperature()); + table[thermoSystem.getPhase(0).getNumberOfComponents() + 11][4] = "[K]"; + Double.toString(thermoSystem.getPhase(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] = "-"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 13][0] = "Stream"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 13][i + 1] = name; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 13][4] = "-"; } JTable Jtab = new JTable(table, names); diff --git a/src/main/java/neqsim/process/equipment/compressor/Compressor.java b/src/main/java/neqsim/process/equipment/compressor/Compressor.java index e97c295d9..373ea8a6a 100644 --- a/src/main/java/neqsim/process/equipment/compressor/Compressor.java +++ b/src/main/java/neqsim/process/equipment/compressor/Compressor.java @@ -81,9 +81,8 @@ public Compressor(String name) { * Constructor for Compressor. *

* - * @param name a {@link java.lang.String} object - * @param inletStream a {@link neqsim.process.equipment.stream.StreamInterface} - * object + * @param name a {@link java.lang.String} object + * @param inletStream a {@link neqsim.process.equipment.stream.StreamInterface} object */ public Compressor(String name, StreamInterface inletStream) { this(name); @@ -95,7 +94,7 @@ public Compressor(String name, StreamInterface inletStream) { * Constructor for Compressor. *

* - * @param name Name of compressor + * @param name Name of compressor * @param interpolateMapLookup a boolean */ public Compressor(String name, boolean interpolateMapLookup) { @@ -151,7 +150,7 @@ public void setOutletPressure(double pressure) { *

* * @param pressure a double - * @param unit a {@link java.lang.String} object + * @param unit a {@link java.lang.String} object */ public void setOutletPressure(double pressure, String unit) { this.pressure = pressure; @@ -261,8 +260,8 @@ public double solveEfficiency(double outTemperature) { * findOutPressure. *

* - * @param hinn a double - * @param hout a double + * @param hinn a double + * @param hout a double * @param polytropicEfficiency a double * @return a double */ @@ -331,7 +330,8 @@ public void run(UUID id) { polytropicHead = getPower() / getThermoSystem().getFlowRate("kg/sec") / 1000.0 * getPolytropicEfficiency(); polytropicFluidHead = polytropicHead; - polytropicHeadMeter = polytropicFluidHead * 1000.0 / ThermodynamicConstantsInterface.gravity; + polytropicHeadMeter = + polytropicFluidHead * 1000.0 / ThermodynamicConstantsInterface.gravity; return; } else { double MW = thermoSystem.getMolarMass(); @@ -347,7 +347,8 @@ public void run(UUID id) { double[] gergProps; gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008(); densOutIsentropic = getThermoSystem().getPhase(0).getDensity_GERG2008(); - enthalpyOutIsentropic = gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); + enthalpyOutIsentropic = + gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); } thermoSystem.setTemperature(outTemperature); thermoOps.TPflash(); @@ -434,13 +435,15 @@ public void run(UUID id) { z_inlet = gergProps[1]; } - double polytropEff = getCompressorChart().getPolytropicEfficiency(actualFlowRate, currentSpeed); + double polytropEff = + getCompressorChart().getPolytropicEfficiency(actualFlowRate, currentSpeed); setPolytropicEfficiency(polytropEff / 100.0); polytropicHead = getCompressorChart().getPolytropicHead(actualFlowRate, currentSpeed); double temperature_inlet = thermoSystem.getTemperature(); double n = 1.0 / (1.0 - (kappa - 1.0) / kappa * 1.0 / (polytropEff / 100.0)); - polytropicFluidHead = (getCompressorChart().getHeadUnit().equals("meter")) ? polytropicHead / 1000.0 * 9.81 - : polytropicHead; + polytropicFluidHead = + (getCompressorChart().getHeadUnit().equals("meter")) ? polytropicHead / 1000.0 * 9.81 + : polytropicHead; double pressureRatio = Math.pow((polytropicFluidHead * 1000.0 + (n / (n - 1.0) * z_inlet * ThermodynamicConstantsInterface.R * (temperature_inlet) / MW)) / (n / (n - 1.0) * z_inlet * ThermodynamicConstantsInterface.R * (temperature_inlet) @@ -451,17 +454,18 @@ public void run(UUID id) { // Calculate the derivative of pressure with respect to speed double polytropEffDelta = getCompressorChart().getPolytropicEfficiency(actualFlowRate, currentSpeed + deltaSpeed); - double polytropicHeadDelta = getCompressorChart().getPolytropicHead(actualFlowRate, - currentSpeed + deltaSpeed); + double polytropicHeadDelta = + getCompressorChart().getPolytropicHead(actualFlowRate, currentSpeed + deltaSpeed); double nDelta = 1.0 / (1.0 - (kappa - 1.0) / kappa * 1.0 / (polytropEffDelta / 100.0)); double polytropicFluidHeadDelta = (getCompressorChart().getHeadUnit().equals("meter")) ? polytropicHeadDelta / 1000.0 * 9.81 : polytropicHeadDelta; - double pressureRatioDelta = Math.pow((polytropicFluidHeadDelta * 1000.0 + (nDelta / (nDelta - 1.0) * z_inlet - * ThermodynamicConstantsInterface.R * (temperature_inlet) / MW)) - / (nDelta / (nDelta - 1.0) * z_inlet * ThermodynamicConstantsInterface.R - * (temperature_inlet) / MW), - nDelta / (nDelta - 1.0)); + double pressureRatioDelta = + Math.pow((polytropicFluidHeadDelta * 1000.0 + (nDelta / (nDelta - 1.0) * z_inlet + * ThermodynamicConstantsInterface.R * (temperature_inlet) / MW)) + / (nDelta / (nDelta - 1.0) * z_inlet * ThermodynamicConstantsInterface.R + * (temperature_inlet) / MW), + nDelta / (nDelta - 1.0)); double pressureDelta = thermoSystem.getPressure() * pressureRatioDelta; double dPressure_dSpeed = (pressureDelta - currentPressure) / deltaSpeed; @@ -510,7 +514,8 @@ public void run(UUID id) { z_inlet = gergProps[1]; } - double polytropEff = getCompressorChart().getPolytropicEfficiency(actualFlowRate, getSpeed()); + double polytropEff = + getCompressorChart().getPolytropicEfficiency(actualFlowRate, getSpeed()); setPolytropicEfficiency(polytropEff / 100.0); polytropicHead = getCompressorChart().getPolytropicHead(actualFlowRate, getSpeed()); double temperature_inlet = thermoSystem.getTemperature(); @@ -608,9 +613,11 @@ public void run(UUID id) { } } } else if (polytropicMethod.equals("schultz")) { - double schultzX = thermoSystem.getTemperature() / thermoSystem.getVolume() * thermoSystem.getdVdTpn() - - 1.0; - double schultzY = -thermoSystem.getPressure() / thermoSystem.getVolume() * thermoSystem.getdVdPtn(); + 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(); @@ -621,10 +628,11 @@ public void run(UUID id) { double[] gergProps; gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008(); densOutIsentropic = getThermoSystem().getPhase(0).getDensity_GERG2008(); - enthalpyOutIsentropic = gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); + enthalpyOutIsentropic = + gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); } - double isenthalpicvolumeexponent = Math.log(getOutletPressure() / presinn) - / Math.log(densOutIsentropic / densInn); + 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)); @@ -651,10 +659,11 @@ public void run(UUID id) { double[] gergProps; gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008(); densOutIsentropic = getThermoSystem().getPhase(0).getDensity_GERG2008(); - enthalpyOutIsentropic = gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); + enthalpyOutIsentropic = + gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase(); } - double isenthalpicvolumeexponent = Math.log(getOutletPressure() / presinn) - / Math.log(densOutIsentropic / densInn); + double isenthalpicvolumeexponent = + Math.log(getOutletPressure() / presinn) / Math.log(densOutIsentropic / densInn); double term = isenthalpicvolumeexponent / (isenthalpicvolumeexponent - 1.0) * (polytropicEfficiency); double term2 = 1e5 * (getOutletPressure() / densOutIsentropic - presinn / densInn); @@ -711,7 +720,8 @@ public void run(UUID id) { outStream.setThermoSystem(getThermoSystem()); outStream.setCalculationIdentifier(id); - polytropicFluidHead = getPower() / getThermoSystem().getFlowRate("kg/sec") / 1000.0 * getPolytropicEfficiency(); + polytropicFluidHead = + getPower() / getThermoSystem().getFlowRate("kg/sec") / 1000.0 * getPolytropicEfficiency(); polytropicHeadMeter = polytropicFluidHead * 1000.0 / 9.81; actualCompressionRatio = getOutletPressure() / presinn; setCalculationIdentifier(id); @@ -753,7 +763,8 @@ public void runTransient(double dt, UUID id) { thermoSystem = outStream.getThermoSystem().clone(); thermoSystem.initPhysicalProperties(PhysicalPropertyType.MASS_DENSITY); - polytropicEfficiency = compressorChart.getPolytropicEfficiency(inStream.getFlowRate("m3/hr"), speed) / 100.0; + polytropicEfficiency = + compressorChart.getPolytropicEfficiency(inStream.getFlowRate("m3/hr"), speed) / 100.0; polytropicFluidHead = head * polytropicEfficiency; dH = polytropicFluidHead * 1000.0 * thermoSystem.getMolarMass() / getPolytropicEfficiency() * inStream.getThermoSystem().getTotalNumberOfMoles(); @@ -768,17 +779,17 @@ public void runTransient(double dt, UUID id) { 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[] 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 } }; + {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++) { @@ -786,14 +797,15 @@ public void generateCompressorCurves() { } } - 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[][] 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++) { @@ -801,22 +813,22 @@ public void generateCompressorCurves() { } } 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 } }; + {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"); @@ -836,7 +848,7 @@ public void displayResult() { getThermoSystem().initPhysicalProperties(); String[][] table = new String[50][5]; - String[] names = { "", "Phase 1", "Phase 2", "Phase 3", "Unit" }; + String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"}; table[0][0] = ""; table[0][1] = ""; table[0][2] = ""; @@ -845,68 +857,93 @@ public void displayResult() { 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].getComponent(j).getName(); + for (int j = 0; j < getThermoSystem().getPhase(0).getNumberOfComponents(); j++) { + table[j + 1][0] = getThermoSystem().getPhase(0).getComponent(j).getName(); buf = new StringBuffer(); - table[j + 1][i + 1] = nf - .format(getThermoSystem().getPhases()[i].getComponent(j).getx(), buf, test).toString(); + table[j + 1][i + 1] = + nf.format(getThermoSystem().getPhase(i).getComponent(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) + table[getThermoSystem().getPhase(0).getNumberOfComponents() + 2][0] = "Density"; + table[getThermoSystem().getPhase(0).getNumberOfComponents() + 2][i + 1] = + nf.format(getThermoSystem().getPhase(i).getPhysicalProperties().getDensity(), buf, test) + .toString(); + table[getThermoSystem().getPhase(0).getNumberOfComponents() + 2][4] = "[kg/m^3]"; + + // Double.longValue(thermoSystem.getPhase(i).getBeta()); + buf = new StringBuffer(); + table[getThermoSystem().getPhase(0).getNumberOfComponents() + 3][0] = "PhaseFraction"; + table[getThermoSystem().getPhase(0).getNumberOfComponents() + 3][i + 1] = + nf.format(getThermoSystem().getPhase(i).getBeta(), buf, test).toString(); + table[getThermoSystem().getPhase(0).getNumberOfComponents() + 3][4] = "[-]"; + + buf = new StringBuffer(); + table[getThermoSystem().getPhase(0).getNumberOfComponents() + 4][0] = "MolarMass"; + table[getThermoSystem().getPhase(0).getNumberOfComponents() + 4][i + 1] = + nf.format(getThermoSystem().getPhase(i).getMolarMass() * 1000, buf, test).toString(); + table[getThermoSystem().getPhase(0).getNumberOfComponents() + 4][4] = "[kg/kmol]"; + + buf = new StringBuffer(); + table[getThermoSystem().getPhase(0).getNumberOfComponents() + 5][0] = "Cp"; + table[getThermoSystem().getPhase(0).getNumberOfComponents() + 5][i + 1] = + nf.format((getThermoSystem().getPhase(i).getCp() + / getThermoSystem().getPhase(i).getNumberOfMolesInPhase() * 1.0 + / getThermoSystem().getPhase(i).getMolarMass() * 1000), buf, test).toString(); + table[getThermoSystem().getPhase(0).getNumberOfComponents() + 5][4] = "[kJ/kg*K]"; + + buf = new StringBuffer(); + table[getThermoSystem().getPhase(0).getNumberOfComponents() + 7][0] = "Viscosity"; + table[getThermoSystem().getPhase(0).getNumberOfComponents() + 7][i + 1] = nf + .format((getThermoSystem().getPhase(i).getPhysicalProperties().getViscosity()), 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][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][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() + 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(); + / 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][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][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][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][i + 1] = + Double.toString(getThermoSystem().getPhases()[i].getTemperature()); table[getThermoSystem().getPhases()[0].getNumberOfComponents() + 11][4] = "[K]"; Double.toString(getThermoSystem().getPhases()[i].getTemperature()); @@ -1008,9 +1045,7 @@ public SystemInterface getThermoSystem() { * Getter for the field compressorChart. *

* - * @return a - * {@link neqsim.process.equipment.compressor.CompressorChartInterface} - * object + * @return a {@link neqsim.process.equipment.compressor.CompressorChartInterface} object */ public CompressorChartInterface getCompressorChart() { return compressorChart; @@ -1021,9 +1056,7 @@ public CompressorChartInterface getCompressorChart() { * Setter for the field compressorChart. *

* - * @param compressorChart a - * {@link neqsim.process.equipment.compressor.CompressorChart} - * object + * @param compressorChart a {@link neqsim.process.equipment.compressor.CompressorChart} object */ public void setCompressorChart(CompressorChart compressorChart) { this.compressorChart = compressorChart; @@ -1087,8 +1120,7 @@ public boolean isStoneWall(double flow, double head) { * Setter for the field antiSurge. *

* - * @param antiSurge a {@link neqsim.process.equipment.compressor.AntiSurge} - * object + * @param antiSurge a {@link neqsim.process.equipment.compressor.AntiSurge} object */ public void setAntiSurge(AntiSurge antiSurge) { this.antiSurge = antiSurge; @@ -1283,7 +1315,7 @@ public void setPressure(double pressure) { *

* * @param pressure a double - * @param unit a {@link java.lang.String} object + * @param unit a {@link java.lang.String} object */ public void setPressure(double pressure, String unit) { setOutletPressure(pressure); @@ -1349,9 +1381,7 @@ public void setUseGERG2008(boolean useGERG2008) { * Getter for the field propertyProfile. *

* - * @return a - * {@link neqsim.process.equipment.compressor.CompressorPropertyProfile} - * object + * @return a {@link neqsim.process.equipment.compressor.CompressorPropertyProfile} object */ public CompressorPropertyProfile getPropertyProfile() { return propertyProfile; @@ -1362,9 +1392,8 @@ public CompressorPropertyProfile getPropertyProfile() { * Setter for the field propertyProfile. *

* - * @param propertyProfile a - * {@link neqsim.process.equipment.compressor.CompressorPropertyProfile} - * object + * @param propertyProfile a {@link neqsim.process.equipment.compressor.CompressorPropertyProfile} + * object */ public void setPropertyProfile(CompressorPropertyProfile propertyProfile) { this.propertyProfile = propertyProfile; diff --git a/src/main/java/neqsim/process/equipment/expander/ExpanderOld.java b/src/main/java/neqsim/process/equipment/expander/ExpanderOld.java index 89905e79e..758e75b5e 100644 --- a/src/main/java/neqsim/process/equipment/expander/ExpanderOld.java +++ b/src/main/java/neqsim/process/equipment/expander/ExpanderOld.java @@ -115,72 +115,72 @@ public void displayResult() { 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].getComponent(j).getName(); + for (int j = 0; j < thermoSystem.getPhase(0).getNumberOfComponents(); j++) { + table[j + 1][0] = thermoSystem.getPhase(0).getComponent(j).getName(); buf = new StringBuffer(); table[j + 1][i + 1] = - nf.format(thermoSystem.getPhases()[i].getComponent(j).getx(), buf, test).toString(); + nf.format(thermoSystem.getPhase(i).getComponent(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) + table[thermoSystem.getPhase(0).getNumberOfComponents() + 2][0] = "Density"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 2][i + 1] = + nf.format(thermoSystem.getPhase(i).getPhysicalProperties().getDensity(), buf, test) .toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 2][4] = "[kg/m^3]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 2][4] = "[kg/m^3]"; - // Double.longValue(thermoSystem.getPhases()[i].getBeta()); + // Double.longValue(thermoSystem.getPhase(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] = "[-]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 3][0] = "PhaseFraction"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 3][i + 1] = + nf.format(thermoSystem.getPhase(i).getBeta(), buf, test).toString(); + table[thermoSystem.getPhase(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]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 4][0] = "MolarMass"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 4][i + 1] = + nf.format(thermoSystem.getPhase(i).getMolarMass() * 1000, buf, test).toString(); + table[thermoSystem.getPhase(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() * 1.0 - / thermoSystem.getPhases()[i].getMolarMass() * 1000), buf, test).toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 5][4] = "[kJ/kg*K]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 5][0] = "Cp"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 5][i + 1] = nf.format( + (thermoSystem.getPhase(i).getCp() / thermoSystem.getPhase(i).getNumberOfMolesInPhase() + * 1.0 / thermoSystem.getPhase(i).getMolarMass() * 1000), + buf, test).toString(); + table[thermoSystem.getPhase(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) + table[thermoSystem.getPhase(0).getNumberOfComponents() + 7][0] = "Viscosity"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 7][i + 1] = + nf.format((thermoSystem.getPhase(i).getPhysicalProperties().getViscosity()), buf, test) .toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 7][4] = "[kg/m*sec]"; + table[thermoSystem.getPhase(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]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 8][0] = "Conductivity"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 8][i + 1] = + nf.format(thermoSystem.getPhase(i).getPhysicalProperties().getConductivity(), buf, test) + .toString(); + table[thermoSystem.getPhase(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]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 10][0] = "Pressure"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 10][i + 1] = + Double.toString(thermoSystem.getPhase(i).getPressure()); + table[thermoSystem.getPhase(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()); + table[thermoSystem.getPhase(0).getNumberOfComponents() + 11][0] = "Temperature"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 11][i + 1] = + Double.toString(thermoSystem.getPhase(i).getTemperature()); + table[thermoSystem.getPhase(0).getNumberOfComponents() + 11][4] = "[K]"; + Double.toString(thermoSystem.getPhase(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] = "-"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 13][0] = "Stream"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 13][i + 1] = name; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 13][4] = "-"; } String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"}; diff --git a/src/main/java/neqsim/process/equipment/heatexchanger/Heater.java b/src/main/java/neqsim/process/equipment/heatexchanger/Heater.java index 636004026..407aa3ebe 100644 --- a/src/main/java/neqsim/process/equipment/heatexchanger/Heater.java +++ b/src/main/java/neqsim/process/equipment/heatexchanger/Heater.java @@ -27,9 +27,17 @@ public class Heater extends TwoPortEquipment implements HeaterInterface { private static final long serialVersionUID = 1000; - boolean setTemperature = false, setOutPressure = false; + boolean setTemperature = false; + + boolean setOutPressure = false; + SystemInterface system; - protected double temperatureOut = 0, dT = 0.0, pressureOut = 0; + protected double temperatureOut = 0; + + protected double dT = 0.0; + + protected double pressureOut = 0; + private boolean setEnergyInput = false; private double energyInput = 0.0; private double pressureDrop = 0.0; diff --git a/src/main/java/neqsim/process/equipment/mixer/Mixer.java b/src/main/java/neqsim/process/equipment/mixer/Mixer.java index 4bcd20f34..33f318212 100644 --- a/src/main/java/neqsim/process/equipment/mixer/Mixer.java +++ b/src/main/java/neqsim/process/equipment/mixer/Mixer.java @@ -275,74 +275,73 @@ public void displayResult() { 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].getComponent(j).getName(); + for (int j = 0; j < thermoSystem.getPhase(0).getNumberOfComponents(); j++) { + table[j + 1][0] = thermoSystem.getPhase(0).getComponent(j).getName(); buf = new StringBuffer(); table[j + 1][i + 1] = - nf.format(thermoSystem.getPhases()[i].getComponent(j).getx(), buf, test).toString(); + nf.format(thermoSystem.getPhase(i).getComponent(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) + table[thermoSystem.getPhase(0).getNumberOfComponents() + 2][0] = "Density"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 2][i + 1] = + nf.format(thermoSystem.getPhase(i).getPhysicalProperties().getDensity(), buf, test) .toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 2][4] = "[kg/m^3]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 2][4] = "[kg/m^3]"; - // Double.longValue(thermoSystem.getPhases()[i].getBeta()); + // Double.longValue(thermoSystem.getPhase(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] = "[-]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 3][0] = "PhaseFraction"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 3][i + 1] = + nf.format(thermoSystem.getPhase(i).getBeta(), buf, test).toString(); + table[thermoSystem.getPhase(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]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 4][0] = "MolarMass"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 4][i + 1] = + nf.format(thermoSystem.getPhase(i).getMolarMass() * 1000, buf, test).toString(); + table[thermoSystem.getPhase(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]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 5][0] = "Cp"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 5][i + 1] = nf.format( + (thermoSystem.getPhase(i).getCp() / (thermoSystem.getPhase(i).getNumberOfMolesInPhase() + * thermoSystem.getPhase(i).getMolarMass() * 1000)), + buf, test).toString(); + table[thermoSystem.getPhase(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) + table[thermoSystem.getPhase(0).getNumberOfComponents() + 7][0] = "Viscosity"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 7][i + 1] = + nf.format((thermoSystem.getPhase(i).getPhysicalProperties().getViscosity()), buf, test) .toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 7][4] = "[kg/m*sec]"; + table[thermoSystem.getPhase(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]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 8][0] = "Conductivity"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 8][i + 1] = + nf.format(thermoSystem.getPhase(i).getPhysicalProperties().getConductivity(), buf, test) + .toString(); + table[thermoSystem.getPhase(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]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 10][0] = "Pressure"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 10][i + 1] = + Double.toString(thermoSystem.getPhase(i).getPressure()); + table[thermoSystem.getPhase(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()); + table[thermoSystem.getPhase(0).getNumberOfComponents() + 11][0] = "Temperature"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 11][i + 1] = + Double.toString(thermoSystem.getPhase(i).getTemperature()); + table[thermoSystem.getPhase(0).getNumberOfComponents() + 11][4] = "[K]"; + Double.toString(thermoSystem.getPhase(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] = "-"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 13][0] = "Stream"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 13][i + 1] = name; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 13][4] = "-"; } String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"}; diff --git a/src/main/java/neqsim/process/equipment/mixer/StaticMixer.java b/src/main/java/neqsim/process/equipment/mixer/StaticMixer.java index 912eecd3e..fb91205a2 100644 --- a/src/main/java/neqsim/process/equipment/mixer/StaticMixer.java +++ b/src/main/java/neqsim/process/equipment/mixer/StaticMixer.java @@ -37,25 +37,25 @@ 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] + for (int i = 0; i < streams.get(k).getThermoSystem().getPhase(0) .getNumberOfComponents(); i++) { boolean gotComponent = false; String componentName = - streams.get(k).getThermoSystem().getPhases()[0].getComponent(i).getName(); + streams.get(k).getThermoSystem().getPhase(0).getComponent(i).getName(); // System.out.println("adding: " + componentName); double moles = - streams.get(k).getThermoSystem().getPhases()[0].getComponent(i).getNumberOfmoles(); + streams.get(k).getThermoSystem().getPhase(0).getComponent(i).getNumberOfmoles(); // System.out.println("moles: " + moles + " " + - // mixedStream.getThermoSystem().getPhases()[0].getNumberOfComponents()); - for (int p = 0; p < mixedStream.getThermoSystem().getPhases()[0] + // mixedStream.getThermoSystem().getPhase(0).getNumberOfComponents()); + for (int p = 0; p < mixedStream.getThermoSystem().getPhase(0) .getNumberOfComponents(); p++) { - if (mixedStream.getThermoSystem().getPhases()[0].getComponent(p).getName() + if (mixedStream.getThermoSystem().getPhase(0).getComponent(p).getName() .equals(componentName)) { gotComponent = true; - index = streams.get(0).getThermoSystem().getPhases()[0].getComponent(p) - .getComponentNumber(); - compName = streams.get(0).getThermoSystem().getPhases()[0].getComponent(p) - .getComponentName(); + index = + streams.get(0).getThermoSystem().getPhase(0).getComponent(p).getComponentNumber(); + compName = + streams.get(0).getThermoSystem().getPhase(0).getComponent(p).getComponentName(); } } diff --git a/src/main/java/neqsim/process/equipment/mixer/StaticNeqMixer.java b/src/main/java/neqsim/process/equipment/mixer/StaticNeqMixer.java index ff5c18a77..2b5068c61 100644 --- a/src/main/java/neqsim/process/equipment/mixer/StaticNeqMixer.java +++ b/src/main/java/neqsim/process/equipment/mixer/StaticNeqMixer.java @@ -39,29 +39,29 @@ 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] + for (int i = 0; i < streams.get(k).getThermoSystem().getPhase(0) .getNumberOfComponents(); i++) { boolean gotComponent = false; String componentName = - streams.get(k).getThermoSystem().getPhases()[0].getComponent(i).getName(); + streams.get(k).getThermoSystem().getPhase(0).getComponent(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].getComponent(i) + moles[p] = streams.get(k).getThermoSystem().getPhase(p).getComponent(i) .getNumberOfMolesInPhase(); } - for (int p = 0; p < mixedStream.getThermoSystem().getPhases()[0] + for (int p = 0; p < mixedStream.getThermoSystem().getPhase(0) .getNumberOfComponents(); p++) { - if (mixedStream.getThermoSystem().getPhases()[0].getComponent(p).getName() + if (mixedStream.getThermoSystem().getPhase(0).getComponent(p).getName() .equals(componentName)) { gotComponent = true; - index = streams.get(0).getThermoSystem().getPhases()[0].getComponent(p) - .getComponentNumber(); - compName = streams.get(0).getThermoSystem().getPhases()[0].getComponent(p) - .getComponentName(); + index = + streams.get(0).getThermoSystem().getPhase(0).getComponent(p).getComponentNumber(); + compName = + streams.get(0).getThermoSystem().getPhase(0).getComponent(p).getComponentName(); } } diff --git a/src/main/java/neqsim/process/equipment/mixer/StaticPhaseMixer.java b/src/main/java/neqsim/process/equipment/mixer/StaticPhaseMixer.java index ec1fa6476..348ca2afa 100644 --- a/src/main/java/neqsim/process/equipment/mixer/StaticPhaseMixer.java +++ b/src/main/java/neqsim/process/equipment/mixer/StaticPhaseMixer.java @@ -32,11 +32,11 @@ 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] + for (int i = 0; i < streams.get(k).getThermoSystem().getPhase(0) .getNumberOfComponents(); i++) { boolean gotComponent = false; String componentName = - streams.get(k).getThermoSystem().getPhases()[0].getComponent(i).getName(); + streams.get(k).getThermoSystem().getPhase(0).getComponent(i).getName(); System.out.println("adding: " + componentName); int numberOfPhases = streams.get(k).getThermoSystem().getNumberOfPhases(); double[] moles = new double[numberOfPhases]; @@ -55,15 +55,15 @@ public void mixStream() { .setTemperature(streams.get(k).getThermoSystem().getTemperature()); } - for (int p = 0; p < mixedStream.getThermoSystem().getPhases()[0] + for (int p = 0; p < mixedStream.getThermoSystem().getPhase(0) .getNumberOfComponents(); p++) { - if (mixedStream.getThermoSystem().getPhases()[0].getComponent(p).getName() + if (mixedStream.getThermoSystem().getPhase(0).getComponent(p).getName() .equals(componentName)) { gotComponent = true; - index = streams.get(0).getThermoSystem().getPhases()[0].getComponent(p) - .getComponentNumber(); - compName = streams.get(0).getThermoSystem().getPhases()[0].getComponent(p) - .getComponentName(); + index = + streams.get(0).getThermoSystem().getPhase(0).getComponent(p).getComponentNumber(); + compName = + streams.get(0).getThermoSystem().getPhase(0).getComponent(p).getComponentName(); } } diff --git a/src/main/java/neqsim/process/equipment/pump/Pump.java b/src/main/java/neqsim/process/equipment/pump/Pump.java index 43568fab0..8d695d4ac 100644 --- a/src/main/java/neqsim/process/equipment/pump/Pump.java +++ b/src/main/java/neqsim/process/equipment/pump/Pump.java @@ -212,72 +212,72 @@ public void displayResult() { 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].getComponent(j).getName(); + for (int j = 0; j < thermoSystem.getPhase(0).getNumberOfComponents(); j++) { + table[j + 1][0] = thermoSystem.getPhase(0).getComponent(j).getName(); buf = new StringBuffer(); table[j + 1][i + 1] = - nf.format(thermoSystem.getPhases()[i].getComponent(j).getx(), buf, test).toString(); + nf.format(thermoSystem.getPhase(i).getComponent(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) + table[thermoSystem.getPhase(0).getNumberOfComponents() + 2][0] = "Density"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 2][i + 1] = + nf.format(thermoSystem.getPhase(i).getPhysicalProperties().getDensity(), buf, test) .toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 2][4] = "[kg/m^3]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 2][4] = "[kg/m^3]"; - // Double.longValue(thermoSystem.getPhases()[i].getBeta()); + // Double.longValue(thermoSystem.getPhase(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] = "[-]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 3][0] = "PhaseFraction"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 3][i + 1] = + nf.format(thermoSystem.getPhase(i).getBeta(), buf, test).toString(); + table[thermoSystem.getPhase(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]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 4][0] = "MolarMass"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 4][i + 1] = + nf.format(thermoSystem.getPhase(i).getMolarMass() * 1000, buf, test).toString(); + table[thermoSystem.getPhase(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() * 1.0 - / thermoSystem.getPhases()[i].getMolarMass() * 1000), buf, test).toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 5][4] = "[kJ/kg*K]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 5][0] = "Cp"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 5][i + 1] = nf.format( + (thermoSystem.getPhase(i).getCp() / thermoSystem.getPhase(i).getNumberOfMolesInPhase() + * 1.0 / thermoSystem.getPhase(i).getMolarMass() * 1000), + buf, test).toString(); + table[thermoSystem.getPhase(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) + table[thermoSystem.getPhase(0).getNumberOfComponents() + 7][0] = "Viscosity"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 7][i + 1] = + nf.format((thermoSystem.getPhase(i).getPhysicalProperties().getViscosity()), buf, test) .toString(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 7][4] = "[kg/m*sec]"; + table[thermoSystem.getPhase(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]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 8][0] = "Conductivity"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 8][i + 1] = + nf.format(thermoSystem.getPhase(i).getPhysicalProperties().getConductivity(), buf, test) + .toString(); + table[thermoSystem.getPhase(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]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 10][0] = "Pressure"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 10][i + 1] = + Double.toString(thermoSystem.getPhase(i).getPressure()); + table[thermoSystem.getPhase(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()); + table[thermoSystem.getPhase(0).getNumberOfComponents() + 11][0] = "Temperature"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 11][i + 1] = + Double.toString(thermoSystem.getPhase(i).getTemperature()); + table[thermoSystem.getPhase(0).getNumberOfComponents() + 11][4] = "[K]"; + Double.toString(thermoSystem.getPhase(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] = "-"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 13][0] = "Stream"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 13][i + 1] = name; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 13][4] = "-"; } JTable Jtab = new JTable(table, names); diff --git a/src/main/java/neqsim/process/equipment/separator/Hydrocyclone.java b/src/main/java/neqsim/process/equipment/separator/Hydrocyclone.java index 357ee7201..8eeb3424b 100644 --- a/src/main/java/neqsim/process/equipment/separator/Hydrocyclone.java +++ b/src/main/java/neqsim/process/equipment/separator/Hydrocyclone.java @@ -52,7 +52,7 @@ public void setInletStream(StreamInterface inletStream) { super.setInletStream(inletStream); thermoSystem = inletStream.getThermoSystem().clone(); - waterSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]); + waterSystem = thermoSystem.phaseToSystem(thermoSystem.getPhase(1)); waterOutStream = new Stream("waterOutStream", waterSystem); } diff --git a/src/main/java/neqsim/process/equipment/separator/NeqGasScrubber.java b/src/main/java/neqsim/process/equipment/separator/NeqGasScrubber.java index 0a63d3a72..c1541bf20 100644 --- a/src/main/java/neqsim/process/equipment/separator/NeqGasScrubber.java +++ b/src/main/java/neqsim/process/equipment/separator/NeqGasScrubber.java @@ -74,11 +74,11 @@ public void setInletStream(StreamInterface inletStream) { this.inletStream = inletStream; thermoSystem = inletStream.getThermoSystem().clone(); - gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[0]); + gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhase(0)); gasOutStream = new Stream("gasOutStream", gasSystem); thermoSystem = inletStream.getThermoSystem().clone(); - liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]); + liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhase(1)); liquidOutStream = new Stream("liquidOutStream", liquidSystem); } @@ -121,12 +121,12 @@ public StreamInterface getLiquid() { @Override public void run(UUID id) { thermoSystem = inletStream.getThermoSystem().clone(); - gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[0]); + gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhase(0)); gasSystem.setNumberOfPhases(1); gasOutStream.setThermoSystem(gasSystem); thermoSystem = inletStream.getThermoSystem().clone(); - liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]); + liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhase(1)); liquidSystem.setNumberOfPhases(1); liquidOutStream.setThermoSystem(liquidSystem); setCalculationIdentifier(id); diff --git a/src/main/java/neqsim/process/equipment/separator/Separator.java b/src/main/java/neqsim/process/equipment/separator/Separator.java index e78983e8e..9712b56ca 100644 --- a/src/main/java/neqsim/process/equipment/separator/Separator.java +++ b/src/main/java/neqsim/process/equipment/separator/Separator.java @@ -122,11 +122,11 @@ public void initMechanicalDesign() { public void setInletStream(StreamInterface inletStream) { inletStreamMixer.addStream(inletStream); thermoSystem = inletStream.getThermoSystem().clone(); - gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[0]); + gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhase(0)); gasOutStream = new Stream("gasOutStream", gasSystem); thermoSystem = inletStream.getThermoSystem().clone(); - liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]); + liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhase(1)); liquidOutStream = new Stream("liquidOutStream", liquidSystem); } diff --git a/src/main/java/neqsim/process/equipment/separator/ThreePhaseSeparator.java b/src/main/java/neqsim/process/equipment/separator/ThreePhaseSeparator.java index f10c38358..d7c9c2c17 100644 --- a/src/main/java/neqsim/process/equipment/separator/ThreePhaseSeparator.java +++ b/src/main/java/neqsim/process/equipment/separator/ThreePhaseSeparator.java @@ -113,7 +113,7 @@ public void setInletStream(StreamInterface inletStream) { super.setInletStream(inletStream); thermoSystem = inletStream.getThermoSystem().clone(); - waterSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]); + waterSystem = thermoSystem.phaseToSystem(thermoSystem.getPhase(1)); waterOutStream = new Stream("waterOutStream", waterSystem); } diff --git a/src/main/java/neqsim/process/equipment/separator/TwoPhaseSeparator.java b/src/main/java/neqsim/process/equipment/separator/TwoPhaseSeparator.java index d3c53f311..417e2962f 100644 --- a/src/main/java/neqsim/process/equipment/separator/TwoPhaseSeparator.java +++ b/src/main/java/neqsim/process/equipment/separator/TwoPhaseSeparator.java @@ -55,11 +55,11 @@ public void setInletStream(StreamInterface inletStream) { this.inletStream = inletStream; thermoSystem = inletStream.getThermoSystem().clone(); - gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[0]); + gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhase(0)); gasOutStream = new Stream("gasOutStream", gasSystem); thermoSystem = inletStream.getThermoSystem().clone(); - liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]); + liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhase(1)); liquidOutStream = new Stream("liquidOutStream", liquidSystem); } @@ -91,12 +91,12 @@ public StreamInterface getLiquid() { @Override public void run(UUID id) { thermoSystem = inletStream.getThermoSystem().clone(); - gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[0]); + gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhase(0)); gasSystem.setNumberOfPhases(1); gasOutStream.setThermoSystem(gasSystem); thermoSystem = inletStream.getThermoSystem().clone(); - liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]); + liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhase(1)); liquidSystem.setNumberOfPhases(1); liquidOutStream.setThermoSystem(liquidSystem); setCalculationIdentifier(id); diff --git a/src/main/java/neqsim/process/equipment/tank/Tank.java b/src/main/java/neqsim/process/equipment/tank/Tank.java index b87ecacf3..999476d47 100644 --- a/src/main/java/neqsim/process/equipment/tank/Tank.java +++ b/src/main/java/neqsim/process/equipment/tank/Tank.java @@ -79,11 +79,11 @@ public Tank(String name, StreamInterface inletStream) { public void setInletStream(StreamInterface inletStream) { inletStreamMixer.addStream(inletStream); thermoSystem = inletStream.getThermoSystem().clone(); - gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[0]); + gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhase(0)); gasOutStream = new Stream("gasOutStream", gasSystem); thermoSystem = inletStream.getThermoSystem().clone(); - liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]); + liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhase(1)); liquidOutStream = new Stream("liquidOutStream", liquidSystem); } diff --git a/src/main/java/neqsim/standards/Standard.java b/src/main/java/neqsim/standards/Standard.java index 85f698349..0de05e0da 100644 --- a/src/main/java/neqsim/standards/Standard.java +++ b/src/main/java/neqsim/standards/Standard.java @@ -123,12 +123,12 @@ public String[][] createTable(String name) { nf.setMaximumFractionDigits(5); nf.applyPattern("#.#####E0"); - int rows = thermoSystem.getPhases()[0].getNumberOfComponents() + 30; + int rows = thermoSystem.getPhase(0).getNumberOfComponents() + 30; String[][] table = new String[rows][6]; // String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"}; - table[0][0] = ""; // getPhases()[0].getType(); //""; + table[0][0] = ""; // getPhase(0).getType(); //""; - for (int i = 0; i < thermoSystem.getPhases()[0].getNumberOfComponents() + 30; i++) { + for (int i = 0; i < thermoSystem.getPhase(0).getNumberOfComponents() + 30; i++) { for (int j = 0; j < 6; j++) { table[i][j] = ""; } @@ -140,8 +140,8 @@ public String[][] createTable(String name) { 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].getComponent(j).getName(); + for (int j = 0; j < thermoSystem.getPhase(0).getNumberOfComponents(); j++) { + table[j + 1][0] = thermoSystem.getPhase(0).getComponent(j).getName(); buf = new StringBuffer(); table[j + 1][i + 1] = nf.format(thermoSystem.getPhase(thermoSystem.getPhaseIndex(i)).getComponent(j).getx(), diff --git a/src/main/java/neqsim/standards/gasquality/Draft_GERG2004.java b/src/main/java/neqsim/standards/gasquality/Draft_GERG2004.java index 9254e8136..7b0a4807c 100644 --- a/src/main/java/neqsim/standards/gasquality/Draft_GERG2004.java +++ b/src/main/java/neqsim/standards/gasquality/Draft_GERG2004.java @@ -118,13 +118,13 @@ public String[][] createTable(String name) { return table; } - rows = thermoSystem.getPhases()[0].getNumberOfComponents() + 30; + rows = thermoSystem.getPhase(0).getNumberOfComponents() + 30; String[][] table = new String[rows][6]; // String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"}; - table[0][0] = ""; // getPhases()[0].getType(); //""; + table[0][0] = ""; // getPhase(0).getType(); //""; - for (int i = 0; i < thermoSystem.getPhases()[0].getNumberOfComponents() + 30; i++) { + for (int i = 0; i < thermoSystem.getPhase(0).getNumberOfComponents() + 30; i++) { for (int j = 0; j < 6; j++) { table[i][j] = ""; } @@ -136,8 +136,8 @@ public String[][] createTable(String name) { 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].getComponent(j).getName(); + for (int j = 0; j < thermoSystem.getPhase(0).getNumberOfComponents(); j++) { + table[j + 1][0] = thermoSystem.getPhase(0).getComponent(j).getName(); buf = new StringBuffer(); table[j + 1][i + 1] = nf.format(thermoSystem.getPhase(thermoSystem.getPhaseIndex(i)).getComponent(j).getx(), @@ -146,10 +146,10 @@ public String[][] createTable(String name) { } buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 3][0] = "Compressibility Factor"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 3][i + 1] = + table[thermoSystem.getPhase(0).getNumberOfComponents() + 3][0] = "Compressibility Factor"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 3][i + 1] = nf.format(thermoSystem.getPhase(i).getZ()); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 3][4] = "[-]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 3][4] = "[-]"; buf = new StringBuffer(); table[thermoSystem.getPhase(thermoSystem.getPhaseIndex(i)).getNumberOfComponents() + 4][0] = @@ -197,16 +197,16 @@ public String[][] createTable(String name) { "[kJ/kg*K]"; buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 10][0] = "Pressure"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 10][i + 1] = + table[thermoSystem.getPhase(0).getNumberOfComponents() + 10][0] = "Pressure"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 10][i + 1] = Double.toString(thermoSystem.getPhase(thermoSystem.getPhaseIndex(i)).getPressure()); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 10][4] = "[bar]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 10][4] = "[bar]"; buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 11][0] = "Temperature"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 11][i + 1] = + table[thermoSystem.getPhase(0).getNumberOfComponents() + 11][0] = "Temperature"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 11][i + 1] = Double.toString(thermoSystem.getPhase(thermoSystem.getPhaseIndex(i)).getTemperature()); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 11][4] = "[K]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 11][4] = "[K]"; Double.toString(thermoSystem.getPhase(thermoSystem.getPhaseIndex(i)).getTemperature()); } diff --git a/src/main/java/neqsim/standards/gasquality/Standard_ISO6976.java b/src/main/java/neqsim/standards/gasquality/Standard_ISO6976.java index 4198aee66..473eb3f1e 100644 --- a/src/main/java/neqsim/standards/gasquality/Standard_ISO6976.java +++ b/src/main/java/neqsim/standards/gasquality/Standard_ISO6976.java @@ -367,6 +367,12 @@ public double getValue(String returnParameter, String returnUnit) { } } + /** {@inheritDoc} */ + @Override + public double getValue(String returnParameter) { + return getValue(returnParameter, ""); + } + /** *

* checkReferenceCondition. @@ -385,12 +391,6 @@ public void checkReferenceCondition() { } } - /** {@inheritDoc} */ - @Override - public double getValue(String returnParameter) { - return getValue(returnParameter, ""); - } - /** {@inheritDoc} */ @Override public String getUnit(String returnParameter) { @@ -424,13 +424,13 @@ public String[][] createTable(String name) { return table; } - rows = thermoSystem.getPhases()[0].getNumberOfComponents() + 30; + rows = thermoSystem.getPhase(0).getNumberOfComponents() + 30; String[][] table = new String[rows][6]; // String[] names = { "", "Phase 1", "Phase 2", "Phase 3", "Unit" }; - table[0][0] = ""; // getPhases()[0].getType(); //""; + table[0][0] = ""; // getPhase(0).getType(); //""; - for (int i = 0; i < thermoSystem.getPhases()[0].getNumberOfComponents() + 30; i++) { + for (int i = 0; i < thermoSystem.getPhase(0).getNumberOfComponents() + 30; i++) { for (int j = 0; j < 6; j++) { table[i][j] = ""; } @@ -451,8 +451,8 @@ public String[][] createTable(String name) { referenceTypeUnit = "mol"; } 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].getComponent(j).getName(); + for (int j = 0; j < thermoSystem.getPhase(0).getNumberOfComponents(); j++) { + table[j + 1][0] = thermoSystem.getPhase(0).getComponent(j).getName(); buf = new StringBuffer(); table[j + 1][i + 1] = nf.format(thermoSystem.getPhase(thermoSystem.getPhaseIndex(i)).getComponent(j).getx(), @@ -461,77 +461,75 @@ public String[][] createTable(String name) { } buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 3][0] = "Compressibility Factor"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 3][i + 1] = + table[thermoSystem.getPhase(0).getNumberOfComponents() + 3][0] = "Compressibility Factor"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 3][i + 1] = nf.format(getValue("CompressionFactor")); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 3][4] = "[-]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 3][4] = "[-]"; buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 4][0] = - "Superior Calorific Value"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 4][i + 1] = + table[thermoSystem.getPhase(0).getNumberOfComponents() + 4][0] = "Superior Calorific Value"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 4][i + 1] = nf.format(getValue("SuperiorCalorificValue")); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 4][4] = + table[thermoSystem.getPhase(0).getNumberOfComponents() + 4][4] = "[kJ/" + referenceTypeUnit + "]"; buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 5][0] = - "Inferior Calorific Value"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 5][i + 1] = + table[thermoSystem.getPhase(0).getNumberOfComponents() + 5][0] = "Inferior Calorific Value"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 5][i + 1] = nf.format(getValue("InferiorCalorificValue")); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 5][4] = + table[thermoSystem.getPhase(0).getNumberOfComponents() + 5][4] = "[kJ/" + referenceTypeUnit + "]"; buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 6][0] = "Superior Wobbe Index"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 6][i + 1] = + table[thermoSystem.getPhase(0).getNumberOfComponents() + 6][0] = "Superior Wobbe Index"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 6][i + 1] = nf.format(getValue("SuperiorWobbeIndex") / 3600.0); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 6][4] = + table[thermoSystem.getPhase(0).getNumberOfComponents() + 6][4] = "[kWh/" + referenceTypeUnit + "]"; buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 7][0] = "Superior Wobbe Index"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 7][i + 1] = + table[thermoSystem.getPhase(0).getNumberOfComponents() + 7][0] = "Superior Wobbe Index"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 7][i + 1] = nf.format(getValue("SuperiorWobbeIndex")); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 7][4] = + table[thermoSystem.getPhase(0).getNumberOfComponents() + 7][4] = "[kJ/" + referenceTypeUnit + "]"; buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 8][0] = "Inferior Wobbe Index"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 8][i + 1] = + table[thermoSystem.getPhase(0).getNumberOfComponents() + 8][0] = "Inferior Wobbe Index"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 8][i + 1] = nf.format(getValue("InferiorWobbeIndex")); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 8][4] = + table[thermoSystem.getPhase(0).getNumberOfComponents() + 8][4] = "[kJ/" + referenceTypeUnit + "]"; buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 9][0] = "Relative Density"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 9][i + 1] = + table[thermoSystem.getPhase(0).getNumberOfComponents() + 9][0] = "Relative Density"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 9][i + 1] = nf.format(getValue("RelativeDensity")); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 9][4] = "[-]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 9][4] = "[-]"; buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 10][0] = "Molar Mass"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 10][i + 1] = + table[thermoSystem.getPhase(0).getNumberOfComponents() + 10][0] = "Molar Mass"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 10][i + 1] = nf.format(getValue("MolarMass")); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 10][4] = "[gr/mol]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 10][4] = "[gr/mol]"; buf = new StringBuffer(); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 11][0] = "Density"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 11][i + 1] = + table[thermoSystem.getPhase(0).getNumberOfComponents() + 11][0] = "Density"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 11][i + 1] = nf.format(getValue("DensityReal")); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 11][4] = "[kg/m^3]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 11][4] = "[kg/m^3]"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 13][0] = + table[thermoSystem.getPhase(0).getNumberOfComponents() + 13][0] = "Reference Temperature Combustion"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 13][i + 1] = + table[thermoSystem.getPhase(0).getNumberOfComponents() + 13][i + 1] = Double.toString(getEnergyRefT()); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 13][4] = "[C]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 13][4] = "[C]"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 14][0] = + table[thermoSystem.getPhase(0).getNumberOfComponents() + 14][0] = "Reference Temperature Volume"; - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 14][i + 1] = + table[thermoSystem.getPhase(0).getNumberOfComponents() + 14][i + 1] = Double.toString(getVolRefT()); - table[thermoSystem.getPhases()[0].getNumberOfComponents() + 14][4] = "[C]"; + table[thermoSystem.getPhase(0).getNumberOfComponents() + 14][4] = "[C]"; } resultTable = table; @@ -624,7 +622,7 @@ public ArrayList getComponentsNotDefinedByStandard() { */ public double getTotalMolesOfInerts() { double inerts = 0.0; - for (int j = 0; j < thermoSystem.getPhases()[0].getNumberOfComponents(); j++) { + for (int j = 0; j < thermoSystem.getPhase(0).getNumberOfComponents(); j++) { if (carbonNumber[j] == 0) { inerts += thermoSystem.getPhase(0).getComponent(j).getNumberOfmoles(); } @@ -639,7 +637,7 @@ public double getTotalMolesOfInerts() { *

*/ public void removeInertsButNitrogen() { - for (int j = 0; j < thermoSystem.getPhases()[0].getNumberOfComponents(); j++) { + for (int j = 0; j < thermoSystem.getPhase(0).getNumberOfComponents(); j++) { if (carbonNumber[j] == 0 && !thermoSystem.getPhase(0).getComponent(j).getName().equals("nitrogen")) { thermoSystem.addComponent("nitrogen", @@ -660,7 +658,7 @@ public void removeInertsButNitrogen() { public double getAverageCarbonNumber() { double inerts = getTotalMolesOfInerts(); averageCarbonNumber = 0; - for (int j = 0; j < thermoSystem.getPhases()[0].getNumberOfComponents(); j++) { + for (int j = 0; j < thermoSystem.getPhase(0).getNumberOfComponents(); j++) { averageCarbonNumber += carbonNumber[j] * thermoSystem.getPhase(0).getComponent(j).getNumberOfmoles() / (thermoSystem.getTotalNumberOfMoles() - inerts); 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 c340851c2..ca8a45b0d 100644 --- a/src/main/java/neqsim/statistics/experimentalsamplecreation/samplecreator/wettedwallcolumnsamplecreator/WettedWallColumnSampleCreator.java +++ b/src/main/java/neqsim/statistics/experimentalsamplecreation/samplecreator/wettedwallcolumnsamplecreator/WettedWallColumnSampleCreator.java @@ -174,12 +174,12 @@ public void calcdPdt() { for (int i = 1; i < (reader.getSampleObjectList().size() - 3); i++) { system.setTemperature(smoothedInletLiquidTemperature[i]); system.setPressure(smoothedPressure[i]); - system.getPhases()[0].addMoles(1, dNdt[i] * (time[i] - time[i - 1])); - system.getPhases()[1].addMoles(1, -dNdt[i] * (time[i] - time[i - 1])); + system.getPhase(0).addMoles(1, dNdt[i] * (time[i] - time[i - 1])); + system.getPhase(1).addMoles(1, -dNdt[i] * (time[i] - time[i - 1])); system.init(1); // her bor det komme en funksjon som finer nummeret til Co2! dPdt[i] = (smoothedPressure[i + 1] - smoothedPressure[i - 1]) / (time[i + 1] - time[i - 1]); - // dPdn[i] = system.getPhases()[1].getdPdn(1); + // dPdn[i] = system.getPhase(1).getdPdn(1); } dNdt[0] = 0; diff --git a/src/main/java/neqsim/thermo/ThermodynamicModelTest.java b/src/main/java/neqsim/thermo/ThermodynamicModelTest.java index 728f74912..c543aaaa1 100644 --- a/src/main/java/neqsim/thermo/ThermodynamicModelTest.java +++ b/src/main/java/neqsim/thermo/ThermodynamicModelTest.java @@ -99,7 +99,7 @@ public boolean checkFugacityCoefficients() { // logger.info("number of phases " + system.getNumberOfPhases()); // logger.info("number of components " + system.getNumberOfComponents()); // temp1 -= system.getPhase(j).getGresTP() / (R * system.getTemperature()); - // temp2 -= system.getPhases()[1].getGresTP() / (R * system.getTemperature()); + // temp2 -= system.getPhase(1).getGresTP() / (R * system.getTemperature()); double sum = Math.abs(temp1); // logger.info("Diffference fug gas : " + temp1); // logger.info("Difference fug liq : " + temp2); @@ -124,20 +124,20 @@ public boolean checkFugacityCoefficientsDn() { temp1 = 0; // temp2 = 0; // temp1 += - // Math.log(system.getPhases()[0].getComponent(j).getFugacityCoefficient()); + // Math.log(system.getPhase(0).getComponent(j).getFugacityCoefficient()); // temp2 += - // Math.log(system.getPhases()[1].getComponent(j).getFugacityCoefficient()); + // Math.log(system.getPhase(1).getComponent(j).getFugacityCoefficient()); for (int i = 0; i < system.getPhase(k).getNumberOfComponents(); i++) { temp1 += system.getPhase(k).getComponent(i).getNumberOfMolesInPhase() * system.getPhase(k).getComponent(i).getdfugdn(j); - // temp2 += system.getPhases()[1].getComponent(i).getNumberOfMolesInPhase() - // * system.getPhases()[1].getComponent(i).getdfugdn(j); + // temp2 += system.getPhase(1).getComponent(i).getNumberOfMolesInPhase() + // * system.getPhase(1).getComponent(i).getdfugdn(j); // logger.info("fug " + - // system.getPhases()[1].getComponent(i).getNumberOfMolesInPhase()*system.getPhases()[1].getComponent(i).getdfugdn(j)); + // system.getPhase(1).getComponent(i).getNumberOfMolesInPhase()*system.getPhase(1).getComponent(i).getdfugdn(j)); } // logger.info("test fugdn gas : " + j + " " + temp1 + " name " + - // system.getPhases()[0].getComponent(j).getComponentName()); + // system.getPhase(0).getComponent(j).getComponentName()); // logger.info("test fugdn liq : " + j + " " + temp2); } } @@ -167,14 +167,14 @@ public boolean checkFugacityCoefficientsDn2() { temp1 = 0; // temp2 = 0; // temp1 += - // Math.log(system.getPhases()[0].getComponent(j).getFugacityCoefficient()); + // Math.log(system.getPhase(0).getComponent(j).getFugacityCoefficient()); // temp2 += - // Math.log(system.getPhases()[1].getComponent(j).getFugacityCoefficient()); + // Math.log(system.getPhase(1).getComponent(j).getFugacityCoefficient()); for (int i = 0; i < system.getPhase(k).getNumberOfComponents(); i++) { temp1 += system.getPhase(k).getComponent(i).getdfugdn(j) - system.getPhase(k).getComponent(j).getdfugdn(i); - // temp2 += system.getPhases()[1].getComponent(i).getdfugdn(j) - // - system.getPhases()[1].getComponent(j).getdfugdn(i); + // temp2 += system.getPhase(1).getComponent(i).getdfugdn(j) + // - system.getPhase(1).getComponent(j).getdfugdn(i); } // sum += Math.abs(temp1) + Math.abs(temp2); // logger.info("test fugdn gas : " + j + " " + temp1); @@ -240,15 +240,15 @@ public boolean checkFugacityCoefficientsDT() { for (int i = 0; i < system.getPhase(j).getNumberOfComponents(); i++) { temp1 += system.getPhase(j).getComponent(i).getNumberOfMolesInPhase() * system.getPhase(j).getComponent(i).getdfugdt(); - // temp2 += system.getPhases()[1].getComponent(i).getNumberOfMolesInPhase() - // * system.getPhases()[1].getComponent(i).getdfugdt(); + // temp2 += system.getPhase(1).getComponent(i).getNumberOfMolesInPhase() + // * system.getPhase(1).getComponent(i).getdfugdt(); } temp1 += system.getPhase(j).getHresTP() / (R * Math.pow(system.getTemperature(), 2.0)); - // temp2 += system.getPhases()[1].getHresTP() / (R * Math.pow(system.getTemperature(), 2.0)); + // temp2 += system.getPhase(1).getHresTP() / (R * Math.pow(system.getTemperature(), 2.0)); } // sum = Math.abs(temp1) + Math.abs(temp2); sum = Math.abs(temp1); - // logger.info("test fugdp gas : " + system.getPhases()[0].getHresTP()); + // logger.info("test fugdp gas : " + system.getPhase(0).getHresTP()); // logger.info("test fugdp liq : " + temp2); logger.info("Testing temperature derivatives of fugacity coefficients..................."); logger.info("Error : " + sum); @@ -266,26 +266,26 @@ public boolean checkFugacityCoefficientsDT() { * @return a boolean */ public boolean checkNumerically() { - double[][] gasfug = new double[2][system.getPhases()[0].getNumberOfComponents()]; - double[][] liqfug = new double[2][system.getPhases()[0].getNumberOfComponents()]; - double[][] gasnumericDfugdt = new double[2][system.getPhases()[0].getNumberOfComponents()]; - double[][] liqnumericDfugdt = new double[2][system.getPhases()[0].getNumberOfComponents()]; - double[][] gasnumericDfugdp = new double[2][system.getPhases()[0].getNumberOfComponents()]; - double[][] liqnumericDfugdp = new double[2][system.getPhases()[0].getNumberOfComponents()]; - double[][][] gasnumericDfugdn = new double[2][system.getPhases()[0] - .getNumberOfComponents()][system.getPhases()[0].getNumberOfComponents()]; - double[][][] liqnumericDfugdn = new double[2][system.getPhases()[0] - .getNumberOfComponents()][system.getPhases()[0].getNumberOfComponents()]; + double[][] gasfug = new double[2][system.getPhase(0).getNumberOfComponents()]; + double[][] liqfug = new double[2][system.getPhase(0).getNumberOfComponents()]; + double[][] gasnumericDfugdt = new double[2][system.getPhase(0).getNumberOfComponents()]; + double[][] liqnumericDfugdt = new double[2][system.getPhase(0).getNumberOfComponents()]; + double[][] gasnumericDfugdp = new double[2][system.getPhase(0).getNumberOfComponents()]; + double[][] liqnumericDfugdp = new double[2][system.getPhase(0).getNumberOfComponents()]; + double[][][] gasnumericDfugdn = new double[2][system.getPhase(0).getNumberOfComponents()][system + .getPhase(0).getNumberOfComponents()]; + double[][][] liqnumericDfugdn = new double[2][system.getPhase(0).getNumberOfComponents()][system + .getPhase(0).getNumberOfComponents()]; system.init(3); - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - gasnumericDfugdt[0][i] = system.getPhases()[0].getComponent(i).getdfugdt(); - gasnumericDfugdp[0][i] = system.getPhases()[0].getComponent(i).getdfugdp(); - liqnumericDfugdt[0][i] = system.getPhases()[1].getComponent(i).getdfugdt(); - liqnumericDfugdp[0][i] = system.getPhases()[1].getComponent(i).getdfugdp(); - for (int k = 0; k < system.getPhases()[0].getNumberOfComponents(); k++) { - gasnumericDfugdn[0][i][k] = system.getPhases()[0].getComponent(i).getdfugdn(k); - liqnumericDfugdn[0][i][k] = system.getPhases()[1].getComponent(i).getdfugdn(k); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + gasnumericDfugdt[0][i] = system.getPhase(0).getComponent(i).getdfugdt(); + gasnumericDfugdp[0][i] = system.getPhase(0).getComponent(i).getdfugdp(); + liqnumericDfugdt[0][i] = system.getPhase(1).getComponent(i).getdfugdt(); + liqnumericDfugdp[0][i] = system.getPhase(1).getComponent(i).getdfugdp(); + for (int k = 0; k < system.getPhase(0).getNumberOfComponents(); k++) { + gasnumericDfugdn[0][i][k] = system.getPhase(0).getComponent(i).getdfugdn(k); + liqnumericDfugdn[0][i][k] = system.getPhase(1).getComponent(i).getdfugdn(k); } } @@ -293,20 +293,20 @@ public boolean checkNumerically() { system.setTemperature(system.getTemperature() + dt); system.init(3); - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - gasfug[0][i] = Math.log(system.getPhases()[0].getComponent(i).getFugacityCoefficient()); - liqfug[0][i] = Math.log(system.getPhases()[1].getComponent(i).getFugacityCoefficient()); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + gasfug[0][i] = Math.log(system.getPhase(0).getComponent(i).getFugacityCoefficient()); + liqfug[0][i] = Math.log(system.getPhase(1).getComponent(i).getFugacityCoefficient()); } system.setTemperature(system.getTemperature() - 2 * dt); system.init(3); - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - gasfug[1][i] = Math.log(system.getPhases()[0].getComponent(i).getFugacityCoefficient()); - liqfug[1][i] = Math.log(system.getPhases()[1].getComponent(i).getFugacityCoefficient()); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + gasfug[1][i] = Math.log(system.getPhase(0).getComponent(i).getFugacityCoefficient()); + liqfug[1][i] = Math.log(system.getPhase(1).getComponent(i).getFugacityCoefficient()); } - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { logger.info("dt: gas phase comp " + i + " % error " + ((gasfug[0][i] - gasfug[1][i]) / (2 * dt) - gasnumericDfugdt[0][i]) / gasnumericDfugdt[0][i] * 100.0); @@ -326,20 +326,20 @@ public boolean checkNumerically() { system.setPressure(system.getPressure() + dp); system.init(3); - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - gasfug[0][i] = Math.log(system.getPhases()[0].getComponent(i).getFugacityCoefficient()); - liqfug[0][i] = Math.log(system.getPhases()[1].getComponent(i).getFugacityCoefficient()); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + gasfug[0][i] = Math.log(system.getPhase(0).getComponent(i).getFugacityCoefficient()); + liqfug[0][i] = Math.log(system.getPhase(1).getComponent(i).getFugacityCoefficient()); } system.setPressure(system.getPressure() - 2 * dp); system.init(3); - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - gasfug[1][i] = Math.log(system.getPhases()[0].getComponent(i).getFugacityCoefficient()); - liqfug[1][i] = Math.log(system.getPhases()[1].getComponent(i).getFugacityCoefficient()); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + gasfug[1][i] = Math.log(system.getPhase(0).getComponent(i).getFugacityCoefficient()); + liqfug[1][i] = Math.log(system.getPhase(1).getComponent(i).getFugacityCoefficient()); } - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { logger.info("dp: gas phase comp " + i + " % error " + ((gasfug[0][i] - gasfug[1][i]) / (2 * dp) - gasnumericDfugdp[0][i]) / gasnumericDfugdp[0][i] * 100.0); @@ -356,7 +356,7 @@ public boolean checkNumerically() { system.init(3); for (int phaseNum = 0; phaseNum < 2; phaseNum++) { - for (int k = 0; k < system.getPhases()[0].getNumberOfComponents(); k++) { + for (int k = 0; k < system.getPhase(0).getNumberOfComponents(); k++) { double dn = system.getPhase(phaseNum).getComponent(k).getNumberOfMolesInPhase() / 1.0e5; logger .info("component name " + system.getPhase(phaseNum).getComponent(k).getComponentName()); @@ -372,9 +372,9 @@ public boolean checkNumerically() { system.init_x_y(); system.init(3); - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { // gasfug[0][i] = - // Math.log(system.getPhases()[0].getComponent(i).getFugacityCoefficient()); + // Math.log(system.getPhase(0).getComponent(i).getFugacityCoefficient()); liqfug[0][i] = Math.log(system.getPhase(phaseNum).getComponent(i).getFugacityCoefficient()); } @@ -384,14 +384,14 @@ public boolean checkNumerically() { system.init_x_y(); system.init(3); - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { // gasfug[1][i] = - // Math.log(system.getPhases()[0].getComponent(i).getFugacityCoefficient()); + // Math.log(system.getPhase(0).getComponent(i).getFugacityCoefficient()); liqfug[1][i] = Math.log(system.getPhase(phaseNum).getComponent(i).getFugacityCoefficient()); } - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { if (phaseNum == 0) { logger.info("dn: gas phase comp " + i + " % error " + ((liqfug[0][i] - liqfug[1][i]) / (2 * dn) - gasnumericDfugdn[0][i][k]) diff --git a/src/main/java/neqsim/thermo/mixingrule/EosMixingRules.java b/src/main/java/neqsim/thermo/mixingrule/EosMixingRules.java index 90589ebeb..b2df4d9ac 100644 --- a/src/main/java/neqsim/thermo/mixingrule/EosMixingRules.java +++ b/src/main/java/neqsim/thermo/mixingrule/EosMixingRules.java @@ -2708,7 +2708,7 @@ public void displayInteractionCoefficients(String intType, PhaseInterface phase) nf.setMaximumFractionDigits(5); nf.applyPattern("#.#####E0"); - // String[][] table = new String[getPhases()[0].getNumberOfComponents() + + // String[][] table = new String[getPhase(0).getNumberOfComponents() + // 30][7]; String[] names = new String[phase.getNumberOfComponents() + 1]; names[0] = ""; diff --git a/src/main/java/neqsim/thermo/system/SystemThermo.java b/src/main/java/neqsim/thermo/system/SystemThermo.java index 3f2249f1a..eb378e445 100644 --- a/src/main/java/neqsim/thermo/system/SystemThermo.java +++ b/src/main/java/neqsim/thermo/system/SystemThermo.java @@ -1440,14 +1440,14 @@ public String[][] createTable(String name) { nf.setMaximumFractionDigits(5); nf.applyPattern("#.#####E0"); - // String[][] table = new String[getPhases()[0].getNumberOfComponents() + + // String[][] table = new String[getPhase(0).getNumberOfComponents() + // 30][7]; // String[] names = {"", "Feed", "Phase 1", "Phase 2", "Phase 3", "Phase 4", // "Unit"}; - String[][] table = new String[getPhases()[0].getNumberOfComponents() + 30][7]; - table[0][0] = ""; // getPhases()[0].getType(); //""; + String[][] table = new String[getPhase(0).getNumberOfComponents() + 30][7]; + table[0][0] = ""; // getPhase(0).getType(); //""; - for (int i = 0; i < getPhases()[0].getNumberOfComponents() + 30; i++) { + for (int i = 0; i < getPhase(0).getNumberOfComponents() + 30; i++) { for (int j = 0; j < 7; j++) { table[i][j] = ""; } @@ -1459,179 +1459,177 @@ public String[][] createTable(String name) { StringBuffer buf = new StringBuffer(); java.text.FieldPosition test = new java.text.FieldPosition(0); - for (int j = 0; j < getPhases()[0].getNumberOfComponents(); j++) { + for (int j = 0; j < getPhase(0).getNumberOfComponents(); j++) { buf = new StringBuffer(); table[j + 1][1] = nf.format(getPhase(0).getComponent(j).getz(), buf, test).toString(); } buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 4][1] = + table[getPhase(0).getNumberOfComponents() + 4][1] = nf.format(getMolarMass(Units.getSymbol("Molar Mass")), buf, test).toString(); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 9][1] = + table[getPhase(0).getNumberOfComponents() + 9][1] = nf.format(getEnthalpy(Units.getSymbol("enthalpy")), buf, test).toString(); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 10][1] = + table[getPhase(0).getNumberOfComponents() + 10][1] = nf.format(getEntropy(Units.getSymbol("entropy")), 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].getComponent(j).getName(); + for (int j = 0; j < getPhase(0).getNumberOfComponents(); j++) { + table[j + 1][0] = getPhase(0).getComponent(j).getName(); buf = new StringBuffer(); table[j + 1][i + 2] = nf.format(getPhase(i).getComponent(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] = + table[getPhase(0).getNumberOfComponents() + 2][0] = "Density"; + table[getPhase(0).getNumberOfComponents() + 2][i + 2] = nf.format(getPhase(i).getDensity(Units.activeUnits.get("density").symbol), buf, test) .toString(); - table[getPhases()[0].getNumberOfComponents() + 2][6] = - Units.activeUnits.get("density").symbol; + table[getPhase(0).getNumberOfComponents() + 2][6] = Units.activeUnits.get("density").symbol; // Double.longValue(system.getPhase(i).getBeta()); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 3][0] = "Phase Fraction"; - table[getPhases()[0].getNumberOfComponents() + 3][i + 2] = + table[getPhase(0).getNumberOfComponents() + 3][0] = "Phase Fraction"; + table[getPhase(0).getNumberOfComponents() + 3][i + 2] = nf.format(getPhase(i).getBeta(), buf, test).toString(); - table[getPhases()[0].getNumberOfComponents() + 3][6] = "[mole fraction]"; + table[getPhase(0).getNumberOfComponents() + 3][6] = "[mole fraction]"; buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 4][0] = "Molar Mass"; - table[getPhases()[0].getNumberOfComponents() + 4][i + 2] = + table[getPhase(0).getNumberOfComponents() + 4][0] = "Molar Mass"; + table[getPhase(0).getNumberOfComponents() + 4][i + 2] = nf.format(getPhase(i).getMolarMass(Units.activeUnits.get("Molar Mass").symbol), buf, test) .toString(); - table[getPhases()[0].getNumberOfComponents() + 4][6] = + table[getPhase(0).getNumberOfComponents() + 4][6] = Units.activeUnits.get("Molar Mass").symbol; buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 5][0] = "Z factor"; - table[getPhases()[0].getNumberOfComponents() + 5][i + 2] = + table[getPhase(0).getNumberOfComponents() + 5][0] = "Z factor"; + table[getPhase(0).getNumberOfComponents() + 5][i + 2] = nf.format(getPhase(i).getZvolcorr(), buf, test).toString(); - table[getPhases()[0].getNumberOfComponents() + 5][6] = "[-]"; + table[getPhase(0).getNumberOfComponents() + 5][6] = "[-]"; buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 6][0] = "Heat Capacity (Cp)"; - table[getPhases()[0].getNumberOfComponents() + 6][i + 2] = + table[getPhase(0).getNumberOfComponents() + 6][0] = "Heat Capacity (Cp)"; + table[getPhase(0).getNumberOfComponents() + 6][i + 2] = nf.format((getPhase(i).getCp(Units.activeUnits.get("Heat Capacity (Cp)").symbol)), buf, test).toString(); - table[getPhases()[0].getNumberOfComponents() + 6][6] = + table[getPhase(0).getNumberOfComponents() + 6][6] = Units.activeUnits.get("Heat Capacity (Cp)").symbol; buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 7][0] = "Heat Capacity (Cv)"; - table[getPhases()[0].getNumberOfComponents() + 7][i + 2] = + table[getPhase(0).getNumberOfComponents() + 7][0] = "Heat Capacity (Cv)"; + table[getPhase(0).getNumberOfComponents() + 7][i + 2] = nf.format((getPhase(i).getCv(Units.activeUnits.get("Heat Capacity (Cv)").symbol)), buf, test).toString(); - table[getPhases()[0].getNumberOfComponents() + 7][6] = + table[getPhase(0).getNumberOfComponents() + 7][6] = Units.activeUnits.get("Heat Capacity (Cv)").symbol; buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 8][0] = "Speed of Sound"; - table[getPhases()[0].getNumberOfComponents() + 8][i + 2] = + table[getPhase(0).getNumberOfComponents() + 8][0] = "Speed of Sound"; + table[getPhase(0).getNumberOfComponents() + 8][i + 2] = nf.format((getPhase(i).getSoundSpeed(Units.getSymbol("speed of sound"))), buf, test) .toString(); - table[getPhases()[0].getNumberOfComponents() + 8][6] = Units.getSymbol("speed of sound"); + table[getPhase(0).getNumberOfComponents() + 8][6] = Units.getSymbol("speed of sound"); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 9][0] = "Enthalpy"; - table[getPhases()[0].getNumberOfComponents() + 9][i + 2] = + table[getPhase(0).getNumberOfComponents() + 9][0] = "Enthalpy"; + table[getPhase(0).getNumberOfComponents() + 9][i + 2] = nf.format((getPhase(i).getEnthalpy(Units.getSymbol("enthalpy"))), buf, test).toString(); - table[getPhases()[0].getNumberOfComponents() + 9][6] = Units.getSymbol("enthalpy"); + table[getPhase(0).getNumberOfComponents() + 9][6] = Units.getSymbol("enthalpy"); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 10][0] = "Entropy"; - table[getPhases()[0].getNumberOfComponents() + 10][i + 2] = + table[getPhase(0).getNumberOfComponents() + 10][0] = "Entropy"; + table[getPhase(0).getNumberOfComponents() + 10][i + 2] = nf.format((getPhase(i).getEntropy(Units.getSymbol("entropy"))), buf, test).toString(); - table[getPhases()[0].getNumberOfComponents() + 10][6] = Units.getSymbol("entropy"); + table[getPhase(0).getNumberOfComponents() + 10][6] = Units.getSymbol("entropy"); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 11][0] = "JT coefficient"; - table[getPhases()[0].getNumberOfComponents() + 11][i + 2] = + table[getPhase(0).getNumberOfComponents() + 11][0] = "JT coefficient"; + table[getPhase(0).getNumberOfComponents() + 11][i + 2] = nf.format((getPhase(i).getJouleThomsonCoefficient(Units.getSymbol("JT coefficient"))), buf, test).toString(); - table[getPhases()[0].getNumberOfComponents() + 11][6] = Units.getSymbol("JT coefficient"); + table[getPhase(0).getNumberOfComponents() + 11][6] = Units.getSymbol("JT coefficient"); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 13][0] = "Viscosity"; - table[getPhases()[0].getNumberOfComponents() + 13][i + 2] = + table[getPhase(0).getNumberOfComponents() + 13][0] = "Viscosity"; + table[getPhase(0).getNumberOfComponents() + 13][i + 2] = nf.format((getPhase(i).getViscosity(Units.getSymbol("viscosity"))), buf, test).toString(); - table[getPhases()[0].getNumberOfComponents() + 13][6] = Units.getSymbol("viscosity"); + table[getPhase(0).getNumberOfComponents() + 13][6] = Units.getSymbol("viscosity"); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 14][0] = "Thermal Conductivity"; - table[getPhases()[0].getNumberOfComponents() + 14][i + 2] = + table[getPhase(0).getNumberOfComponents() + 14][0] = "Thermal Conductivity"; + table[getPhase(0).getNumberOfComponents() + 14][i + 2] = nf.format(getPhase(i).getThermalConductivity(Units.getSymbol("thermal conductivity")), buf, test).toString(); - table[getPhases()[0].getNumberOfComponents() + 14][6] = - Units.getSymbol("thermal conductivity"); + table[getPhase(0).getNumberOfComponents() + 14][6] = Units.getSymbol("thermal conductivity"); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 15][0] = "Surface Tension"; + table[getPhase(0).getNumberOfComponents() + 15][0] = "Surface Tension"; try { if (i < numberOfPhases - 1) { - table[getPhases()[0].getNumberOfComponents() + 15][2] = + table[getPhase(0).getNumberOfComponents() + 15][2] = nf.format(getInterphaseProperties().getSurfaceTension(0, 1), buf, test).toString(); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 15][3] = + table[getPhase(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] = + table[getPhase(0).getNumberOfComponents() + 17][2] = nf.format(getInterphaseProperties().getSurfaceTension(0, 2), buf, test).toString(); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 17][4] = + table[getPhase(0).getNumberOfComponents() + 17][4] = nf.format(getInterphaseProperties().getSurfaceTension(0, 2), buf, test).toString(); - table[getPhases()[0].getNumberOfComponents() + 17][6] = "[N/m]"; + table[getPhase(0).getNumberOfComponents() + 17][6] = "[N/m]"; } if (i == 1) { buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 16][3] = + table[getPhase(0).getNumberOfComponents() + 16][3] = nf.format(getInterphaseProperties().getSurfaceTension(1, 2), buf, test).toString(); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 16][4] = + table[getPhase(0).getNumberOfComponents() + 16][4] = nf.format(getInterphaseProperties().getSurfaceTension(1, 2), buf, test).toString(); - table[getPhases()[0].getNumberOfComponents() + 16][6] = "[N/m]"; + table[getPhase(0).getNumberOfComponents() + 16][6] = "[N/m]"; } } } catch (Exception ex) { logger.error(ex.getMessage(), ex); } - table[getPhases()[0].getNumberOfComponents() + 15][6] = "[N/m]"; + table[getPhase(0).getNumberOfComponents() + 15][6] = "[N/m]"; buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 19][0] = "Pressure"; - table[getPhases()[0].getNumberOfComponents() + 19][i + 2] = + table[getPhase(0).getNumberOfComponents() + 19][0] = "Pressure"; + table[getPhase(0).getNumberOfComponents() + 19][i + 2] = Double.toString(getPhase(i).getPressure(Units.getSymbol("pressure"))); - table[getPhases()[0].getNumberOfComponents() + 19][6] = Units.getSymbol("pressure"); + table[getPhase(0).getNumberOfComponents() + 19][6] = Units.getSymbol("pressure"); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 20][0] = "Temperature"; - table[getPhases()[0].getNumberOfComponents() + 20][i + 2] = + table[getPhase(0).getNumberOfComponents() + 20][0] = "Temperature"; + table[getPhase(0).getNumberOfComponents() + 20][i + 2] = Double.toString(getPhase(i).getTemperature(Units.getSymbol("temperature"))); - table[getPhases()[0].getNumberOfComponents() + 20][6] = Units.getSymbol("temperature"); + table[getPhase(0).getNumberOfComponents() + 20][6] = Units.getSymbol("temperature"); Double.toString(getPhase(i).getTemperature()); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 22][0] = "Model"; - table[getPhases()[0].getNumberOfComponents() + 22][i + 2] = getModelName(); - table[getPhases()[0].getNumberOfComponents() + 22][6] = "-"; + table[getPhase(0).getNumberOfComponents() + 22][0] = "Model"; + table[getPhase(0).getNumberOfComponents() + 22][i + 2] = getModelName(); + table[getPhase(0).getNumberOfComponents() + 22][6] = "-"; buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 23][0] = "Mixing Rule"; + table[getPhase(0).getNumberOfComponents() + 23][0] = "Mixing Rule"; try { - table[getPhases()[0].getNumberOfComponents() + 23][i + 2] = + table[getPhase(0).getNumberOfComponents() + 23][i + 2] = ((PhaseEosInterface) getPhase(i)).getMixingRuleName(); } catch (Exception ex) { - table[getPhases()[0].getNumberOfComponents() + 23][i + 2] = "?"; + table[getPhase(0).getNumberOfComponents() + 23][i + 2] = "?"; // logger.error(ex.getMessage(),e); } - table[getPhases()[0].getNumberOfComponents() + 23][6] = "-"; + table[getPhase(0).getNumberOfComponents() + 23][6] = "-"; buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 25][0] = "Stream"; - table[getPhases()[0].getNumberOfComponents() + 25][i + 2] = name; - table[getPhases()[0].getNumberOfComponents() + 25][6] = "-"; + table[getPhase(0).getNumberOfComponents() + 25][0] = "Stream"; + table[getPhase(0).getNumberOfComponents() + 25][i + 2] = name; + table[getPhase(0).getNumberOfComponents() + 25][6] = "-"; } resultTable = table; @@ -3325,32 +3323,32 @@ public final void initBeta() { /** {@inheritDoc} */ @Override public void initNumeric() { - double[][] gasfug = new double[2][getPhases()[0].getNumberOfComponents()]; - double[][] liqfug = new double[2][getPhases()[0].getNumberOfComponents()]; - double[][] gasnumericDfugdt = new double[2][getPhases()[0].getNumberOfComponents()]; - double[][] liqnumericDfugdt = new double[2][getPhases()[0].getNumberOfComponents()]; - double[][] gasnumericDfugdp = new double[2][getPhases()[0].getNumberOfComponents()]; - double[][] liqnumericDfugdp = new double[2][getPhases()[0].getNumberOfComponents()]; - double[][][] gasnumericDfugdn = new double[2][getPhases()[0] - .getNumberOfComponents()][getPhases()[0].getNumberOfComponents()]; - double[][][] liqnumericDfugdn = new double[2][getPhases()[0] - .getNumberOfComponents()][getPhases()[0].getNumberOfComponents()]; + double[][] gasfug = new double[2][getPhase(0).getNumberOfComponents()]; + double[][] liqfug = new double[2][getPhase(0).getNumberOfComponents()]; + double[][] gasnumericDfugdt = new double[2][getPhase(0).getNumberOfComponents()]; + double[][] liqnumericDfugdt = new double[2][getPhase(0).getNumberOfComponents()]; + double[][] gasnumericDfugdp = new double[2][getPhase(0).getNumberOfComponents()]; + double[][] liqnumericDfugdp = new double[2][getPhase(0).getNumberOfComponents()]; + double[][][] gasnumericDfugdn = + new double[2][getPhase(0).getNumberOfComponents()][getPhase(0).getNumberOfComponents()]; + double[][][] liqnumericDfugdn = + new double[2][getPhase(0).getNumberOfComponents()][getPhase(0).getNumberOfComponents()]; double dt = getTemperature() / 1e5; setTemperature(getTemperature() + dt); init(1); - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - gasfug[0][i] = Math.log(getPhases()[0].getComponent(i).getFugacityCoefficient()); - liqfug[0][i] = Math.log(getPhases()[1].getComponent(i).getFugacityCoefficient()); + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { + gasfug[0][i] = Math.log(getPhase(0).getComponent(i).getFugacityCoefficient()); + liqfug[0][i] = Math.log(getPhase(1).getComponent(i).getFugacityCoefficient()); } setTemperature(getTemperature() - 2 * dt); init(1); - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - gasfug[1][i] = Math.log(getPhases()[0].getComponent(i).getFugacityCoefficient()); - liqfug[1][i] = Math.log(getPhases()[1].getComponent(i).getFugacityCoefficient()); + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { + gasfug[1][i] = Math.log(getPhase(0).getComponent(i).getFugacityCoefficient()); + liqfug[1][i] = Math.log(getPhase(1).getComponent(i).getFugacityCoefficient()); gasnumericDfugdt[0][i] = (gasfug[0][i] - gasfug[1][i]) / (2 * dt); liqnumericDfugdt[0][i] = (liqfug[0][i] - liqfug[1][i]) / (2 * dt); phaseArray[0].getComponent(i).setdfugdt(gasnumericDfugdt[0][i]); @@ -3363,17 +3361,17 @@ public void initNumeric() { setPressure(getPressure() + dp); init(1); - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - gasfug[0][i] = Math.log(getPhases()[0].getComponent(i).getFugacityCoefficient()); - liqfug[0][i] = Math.log(getPhases()[1].getComponent(i).getFugacityCoefficient()); + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { + gasfug[0][i] = Math.log(getPhase(0).getComponent(i).getFugacityCoefficient()); + liqfug[0][i] = Math.log(getPhase(1).getComponent(i).getFugacityCoefficient()); } setPressure(getPressure() - 2 * dp); init(1); - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - gasfug[1][i] = Math.log(getPhases()[0].getComponent(i).getFugacityCoefficient()); - liqfug[1][i] = Math.log(getPhases()[1].getComponent(i).getFugacityCoefficient()); + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { + gasfug[1][i] = Math.log(getPhase(0).getComponent(i).getFugacityCoefficient()); + liqfug[1][i] = Math.log(getPhase(1).getComponent(i).getFugacityCoefficient()); gasnumericDfugdp[0][i] = (gasfug[0][i] - gasfug[1][i]) / (2 * dp); liqnumericDfugdp[0][i] = (liqfug[0][i] - liqfug[1][i]) / (2 * dp); phaseArray[0].getComponent(i).setdfugdp(gasnumericDfugdp[0][i]); @@ -3384,7 +3382,7 @@ public void initNumeric() { init(1); for (int phaseNum = 0; phaseNum < 2; phaseNum++) { - for (int k = 0; k < getPhases()[0].getNumberOfComponents(); k++) { + for (int k = 0; k < getPhase(0).getNumberOfComponents(); k++) { double dn = getPhase(phaseNum).getComponent(k).getNumberOfMolesInPhase() / 1.0e6; if (dn < 1e-12) { dn = 1e-12; @@ -3395,7 +3393,7 @@ public void initNumeric() { init_x_y(); init(1); - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { liqfug[0][i] = Math.log(getPhase(phaseNum).getComponent(i).getFugacityCoefficient()); } @@ -3404,13 +3402,13 @@ public void initNumeric() { init_x_y(); init(1); - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { // gasfug[1][i] = - // Math.log(getPhases()[0].getComponent(i).getFugacityCoefficient()); + // Math.log(getPhase(0).getComponent(i).getFugacityCoefficient()); liqfug[1][i] = Math.log(getPhase(phaseNum).getComponent(i).getFugacityCoefficient()); } - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { if (phaseNum == 0) { gasnumericDfugdn[0][k][i] = (liqfug[0][i] - liqfug[1][i]) / (2 * dn); phaseArray[0].getComponent(i).setdfugdn(k, gasnumericDfugdn[0][k][i]); @@ -3457,27 +3455,27 @@ public void initNumeric(int initType, int phasen) { if (initType < 2) { initAnalytic(initType); } else { - double[][] gasfug = new double[2][getPhases()[0].getNumberOfComponents()]; - double[][] liqfug = new double[2][getPhases()[0].getNumberOfComponents()]; + double[][] gasfug = new double[2][getPhase(0).getNumberOfComponents()]; + double[][] liqfug = new double[2][getPhase(0).getNumberOfComponents()]; double dt = getTemperature() / 1.0e6; setTemperature(getTemperature() + dt); init(1); - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - gasfug[0][i] = Math.log(getPhases()[0].getComponent(i).getFugacityCoefficient()); - liqfug[0][i] = Math.log(getPhases()[1].getComponent(i).getFugacityCoefficient()); + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { + gasfug[0][i] = Math.log(getPhase(0).getComponent(i).getFugacityCoefficient()); + liqfug[0][i] = Math.log(getPhase(1).getComponent(i).getFugacityCoefficient()); } setTemperature(getTemperature() - 2 * dt); init(1); - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - gasfug[1][i] = Math.log(getPhases()[0].getComponent(i).getFugacityCoefficient()); - liqfug[1][i] = Math.log(getPhases()[1].getComponent(i).getFugacityCoefficient()); + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { + gasfug[1][i] = Math.log(getPhase(0).getComponent(i).getFugacityCoefficient()); + liqfug[1][i] = Math.log(getPhase(1).getComponent(i).getFugacityCoefficient()); } - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { getPhase(0).getComponent(i).setdfugdt((gasfug[0][i] - gasfug[1][i]) / (2 * dt)); getPhase(1).getComponent(i).setdfugdt((liqfug[0][i] - liqfug[1][i]) / (2 * dt)); } @@ -3488,20 +3486,20 @@ public void initNumeric(int initType, int phasen) { setPressure(getPressure() + dp); init(1); - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - gasfug[0][i] = Math.log(getPhases()[0].getComponent(i).getFugacityCoefficient()); - liqfug[0][i] = Math.log(getPhases()[1].getComponent(i).getFugacityCoefficient()); + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { + gasfug[0][i] = Math.log(getPhase(0).getComponent(i).getFugacityCoefficient()); + liqfug[0][i] = Math.log(getPhase(1).getComponent(i).getFugacityCoefficient()); } setPressure(getPressure() - 2 * dp); init(1); - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - gasfug[1][i] = Math.log(getPhases()[0].getComponent(i).getFugacityCoefficient()); - liqfug[1][i] = Math.log(getPhases()[1].getComponent(i).getFugacityCoefficient()); + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { + gasfug[1][i] = Math.log(getPhase(0).getComponent(i).getFugacityCoefficient()); + liqfug[1][i] = Math.log(getPhase(1).getComponent(i).getFugacityCoefficient()); } - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { getPhase(0).getComponent(i).setdfugdp((gasfug[0][i] - gasfug[1][i]) / (2 * dp)); getPhase(1).getComponent(i).setdfugdp((liqfug[0][i] - liqfug[1][i]) / (2 * dp)); } @@ -3511,7 +3509,7 @@ public void initNumeric(int initType, int phasen) { if (initType == 3) { for (int phaseNum = 0; phaseNum < 2; phaseNum++) { - for (int k = 0; k < getPhases()[0].getNumberOfComponents(); k++) { + for (int k = 0; k < getPhase(0).getNumberOfComponents(); k++) { double dn = getPhase(phaseNum).getComponent(k).getNumberOfMolesInPhase() / 1.0e6; addComponent(k, dn, phaseNum); @@ -3519,7 +3517,7 @@ public void initNumeric(int initType, int phasen) { init_x_y(); init(1); - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { liqfug[0][i] = Math.log(getPhase(phaseNum).getComponent(i).getFugacityCoefficient()); } @@ -3528,16 +3526,16 @@ public void initNumeric(int initType, int phasen) { init_x_y(); init(1); - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { // gasfug[1][i] = - // Math.log(getPhases()[0].getComponent(i).getFugacityCoefficient()); + // Math.log(getPhase(0).getComponent(i).getFugacityCoefficient()); liqfug[1][i] = Math.log(getPhase(phaseNum).getComponent(i).getFugacityCoefficient()); } addComponent(k, dn, phaseNum); init_x_y(); init(1); - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { getPhase(phaseNum).getComponent(k).setdfugdn(i, (liqfug[0][i] - liqfug[1][i]) / (2 * dn)); getPhase(phaseNum).getComponent(k).setdfugdx(i, (liqfug[0][i] - liqfug[1][i]) @@ -3776,12 +3774,12 @@ public SystemInterface phaseToSystem(int phaseNumber) { public SystemInterface phaseToSystem(int phaseNumber1, int phaseNumber2) { SystemInterface newSystem = this.clone(); - for (int j = 0; j < getMaxNumberOfPhases(); j++) { - for (int i = 0; i < getPhase(j).getNumberOfComponents(); i++) { - newSystem.getPhases()[j].getComponent(i) + for (int phaseNum = 0; phaseNum < getMaxNumberOfPhases(); phaseNum++) { + for (int i = 0; i < getPhase(phaseNum).getNumberOfComponents(); i++) { + newSystem.getPhase(phaseNum).getComponent(i) .setNumberOfmoles(getPhase(phaseNumber1).getComponent(i).getNumberOfMolesInPhase() + getPhase(phaseNumber2).getComponent(i).getNumberOfMolesInPhase()); - newSystem.getPhases()[j].getComponent(i).setNumberOfMolesInPhase( + newSystem.getPhase(phaseNum).getComponent(i).setNumberOfMolesInPhase( getPhase(phaseNumber1).getComponent(i).getNumberOfMolesInPhase() + getPhase(phaseNumber2).getComponent(i).getNumberOfMolesInPhase()); } @@ -4829,7 +4827,7 @@ public void setSolidPhaseCheck(boolean solidPhaseCheck) { // init(0); for (int phaseNum = 0; phaseNum < numberOfPhases; phaseNum++) { - for (int k = 0; k < getPhases()[0].getNumberOfComponents(); k++) { + for (int k = 0; k < getPhase(0).getNumberOfComponents(); k++) { getPhase(phaseNum).getComponent(k).setSolidCheck(solidPhaseCheck); getPhase(3).getComponent(k).setSolidCheck(solidPhaseCheck); } @@ -4881,7 +4879,7 @@ public final void setTC(double TC) { @Override public void setTemperature(double newTemperature) { for (int i = 0; i < getMaxNumberOfPhases(); i++) { - getPhases()[i].setTemperature(newTemperature); + getPhase(i).setTemperature(newTemperature); } } @@ -4897,16 +4895,16 @@ public void setTemperature(double newTemperature, String unit) { for (int i = 0; i < getMaxNumberOfPhases(); i++) { if (unit.equals("K")) { // Direct setting as Kelvin - getPhases()[i].setTemperature(newTemperature); + getPhase(i).setTemperature(newTemperature); } else if (unit.equals("C")) { // Convert Celsius to Kelvin - getPhases()[i].setTemperature(newTemperature + 273.15); + getPhase(i).setTemperature(newTemperature + 273.15); } else if (unit.equals("F")) { // Convert Fahrenheit to Kelvin - getPhases()[i].setTemperature((newTemperature - 32) * 5.0 / 9.0 + 273.15); + getPhase(i).setTemperature((newTemperature - 32) * 5.0 / 9.0 + 273.15); } else if (unit.equals("R")) { // Convert Rankine to Kelvin - getPhases()[i].setTemperature(newTemperature * 5.0 / 9.0); + getPhase(i).setTemperature(newTemperature * 5.0 / 9.0); } else { // Exception for unsupported units throw new RuntimeException("Unit not supported: " + unit); diff --git a/src/main/java/neqsim/thermodynamicoperations/ThermodynamicOperations.java b/src/main/java/neqsim/thermodynamicoperations/ThermodynamicOperations.java index 61ed084e1..d82a6e5fb 100644 --- a/src/main/java/neqsim/thermodynamicoperations/ThermodynamicOperations.java +++ b/src/main/java/neqsim/thermodynamicoperations/ThermodynamicOperations.java @@ -1184,7 +1184,7 @@ public void hydrateFormationTemperature(int structure) throws IsNaNException { } for (int i = 0; i < system.getPhase(4).getNumberOfComponents(); i++) { - ((ComponentHydrate) system.getPhases()[4].getComponent(i)).setHydrateStructure(structure - 1); + ((ComponentHydrate) system.getPhase(4).getComponent(i)).setHydrateStructure(structure - 1); } if (!isRunAsThread()) { getOperation().run(); diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/Flash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/Flash.java index 2b05682a3..4892cf681 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/Flash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/Flash.java @@ -87,27 +87,27 @@ public int findLowestGibbsEnergyPhase() { */ 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[] logWi = new double[system.getPhase(0).getNumberOfComponents()]; + double[] deltalogWi = new double[system.getPhase(0).getNumberOfComponents()]; + double[] oldDeltalogWi = new double[system.getPhase(0).getNumberOfComponents()]; + double[] oldoldDeltalogWi = new double[system.getPhase(0).getNumberOfComponents()]; + double[][] Wi = new double[2][system.getPhase(0).getNumberOfComponents()]; 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[] oldlogw = new double[system.getPhase(0).getNumberOfComponents()]; + double[] oldoldlogw = new double[system.getPhase(0).getNumberOfComponents()]; + double[] oldoldoldlogw = new double[system.getPhase(0).getNumberOfComponents()]; + double[] d = new double[system.getPhase(0).getNumberOfComponents()]; + double[][] x = new double[2][system.getPhase(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 f = new Matrix(system.getPhase(0).getNumberOfComponents(), 1); Matrix df = null; int maxiterations = 50; double fNorm = 1.0e10; double fNormOld = 0.0; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { d[i] = minGibsPhaseLogZ[i] + minGibsLogFugCoef[i]; } @@ -146,7 +146,7 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException, // 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++) { + for (int i = 0; i < clonedSystem.getPhase(0).getNumberOfComponents(); i++) { Wi[j][i] = clonedSystem.getPhase(j).getComponent(i).getx(); logWi[i] = Math.log(Wi[j][i]); } @@ -157,7 +157,7 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException, iterations++; error[j] = 0.0; - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < clonedSystem.getPhase(0).getNumberOfComponents(); i++) { oldoldoldlogw[i] = oldoldlogw[i]; oldoldlogw[i] = oldlogw[i]; oldlogw[i] = logWi[i]; @@ -170,7 +170,7 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException, || !system.isImplementedCompositionDeriativesofFugacity()) { clonedSystem.init(1, j); fNormOld = fNorm; - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < clonedSystem.getPhase(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])); } @@ -184,7 +184,7 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException, double vec2 = 0.0; double prod1 = 0.0; double prod2 = 0.0; - for (i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + for (i = 0; i < clonedSystem.getPhase(0).getNumberOfComponents(); i++) { vec1 = oldDeltalogWi[i] * oldoldDeltalogWi[i]; vec2 = Math.pow(oldoldDeltalogWi[i], 2.0); prod1 += vec1 * vec2; @@ -193,14 +193,14 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException, double lambda = prod1 / prod2; // logger.info("lambda " + lambda); - for (i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + for (i = 0; i < clonedSystem.getPhase(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++) { + for (int i = 0; i < clonedSystem.getPhase(0).getNumberOfComponents(); i++) { logWi[i] = d[i] - clonedSystem.getPhase(j).getComponent(i).getLogFugacityCoefficient(); error[j] += Math.abs((logWi[i] - oldlogw[i]) / oldlogw[i]); @@ -209,30 +209,30 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException, } } else { if (!secondOrderStabilityAnalysis) { - alpha = new double[system.getPhases()[0].getNumberOfComponents()]; - df = new Matrix(system.getPhases()[0].getNumberOfComponents(), - system.getPhases()[0].getNumberOfComponents()); + alpha = new double[system.getPhase(0).getNumberOfComponents()]; + df = new Matrix(system.getPhase(0).getNumberOfComponents(), + system.getPhase(0).getNumberOfComponents()); secondOrderStabilityAnalysis = true; } clonedSystem.init(3, j); - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < clonedSystem.getPhase(0).getNumberOfComponents(); i++) { alpha[i] = 2.0 * Math.sqrt(Wi[j][i]); } - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < clonedSystem.getPhase(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++) { + for (int k = 0; k < clonedSystem.getPhase(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()); + // clonedSystem.getPhase(j).getNumberOfMolesInPhase()); } } Matrix dx = df.solve(f).times(-1.0); - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < clonedSystem.getPhase(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]); @@ -244,11 +244,11 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException, logger.info("norm f " + f.norm1()); // clonedSystem.display(); sumw[j] = 0.0; - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < clonedSystem.getPhase(0).getNumberOfComponents(); i++) { sumw[j] += Wi[j][i]; } - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < clonedSystem.getPhase(0).getNumberOfComponents(); i++) { deltalogWi[i] = logWi[i] - oldlogw[i]; clonedSystem.getPhase(j).getComponent(i).setx(Wi[j][i] / sumw[j]); } @@ -266,7 +266,7 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException, } tm[j] = 1.0; - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < clonedSystem.getPhase(0).getNumberOfComponents(); i++) { tm[j] -= Wi[j][i]; x[j][i] = clonedSystem.getPhase(j).getComponent(i).getx(); } @@ -289,16 +289,16 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException, } 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].getComponent(i).getx() < 1e-100) { + for (int i = 0; i < clonedSystem.getPhase(0).getNumberOfComponents(); i++) { + if (system.getPhase(1).getComponent(i).getx() < 1e-100) { continue; } if (tm[0] < -1e-4) { - system.getPhases()[1].getComponent(i).setK((Wi[0][i] / sumw[0]) / (Wi[1][i] / sumw[1])); - system.getPhases()[0].getComponent(i).setK((Wi[0][i] / sumw[0]) / (Wi[1][i] / sumw[1])); + system.getPhase(1).getComponent(i).setK((Wi[0][i] / sumw[0]) / (Wi[1][i] / sumw[1])); + system.getPhase(0).getComponent(i).setK((Wi[0][i] / sumw[0]) / (Wi[1][i] / sumw[1])); } else if (tm[1] < -1e-4) { - system.getPhases()[1].getComponent(i).setK((Wi[0][i] / sumw[0]) / (Wi[1][i] / sumw[1])); - system.getPhases()[0].getComponent(i).setK((Wi[0][i] / sumw[0]) / (Wi[1][i] / sumw[1])); + system.getPhase(1).getComponent(i).setK((Wi[0][i] / sumw[0]) / (Wi[1][i] / sumw[1])); + system.getPhase(0).getComponent(i).setK((Wi[0][i] / sumw[0]) / (Wi[1][i] / sumw[1])); } else { logger.info("error in stability anlysis"); system.init(0); @@ -383,7 +383,7 @@ public void solidPhaseFlash() { boolean solidPhase = false; double frac = 0; int solid = 0; - double[] tempVar = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] tempVar = new double[system.getPhase(0).getNumberOfComponents()]; if (!system.hasSolidPhase()) { system.setNumberOfPhases(system.getNumberOfPhases() + 1); @@ -397,7 +397,7 @@ public void solidPhaseFlash() { tempVar[k] = system.getPhase(0).getComponent(k).getz(); for (int i = 0; i < system.getNumberOfPhases() - 1; i++) { tempVar[k] -= - system.getBeta(i) * system.getPhases()[3].getComponent(k).getFugacityCoefficient() + system.getBeta(i) * system.getPhase(3).getComponent(k).getFugacityCoefficient() / system.getPhase(i).getComponent(k).getFugacityCoefficient(); } @@ -405,19 +405,19 @@ public void solidPhaseFlash() { solidPhase = true; solid = k; frac = tempVar[k]; - for (int p = 0; p < system.getPhases()[0].getNumberOfComponents(); p++) { - system.getPhases()[3].getComponent(p).setx(1.0e-20); + for (int p = 0; p < system.getPhase(0).getNumberOfComponents(); p++) { + system.getPhase(3).getComponent(p).setx(1.0e-20); } - system.getPhases()[3].getComponents()[solid].setx(1.0); + system.getPhase(3).getComponents()[solid].setx(1.0); } // logger.info("tempVar: " + tempVar[k]); } } if (solidPhase) { - if (frac < system.getPhases()[0].getComponents()[solid].getz() + 1e10) { + if (frac < system.getPhase(0).getComponents()[solid].getz() + 1e10) { for (int i = 0; i < system.getNumberOfPhases() - 1; i++) { - // system.getPhases()[i].getComponents()[solid].setx(1.0e-10); + // system.getPhase(i).getComponents()[solid].setx(1.0e-10); } system.init(1); // logger.info("solid phase will form..." + system.getNumberOfPhases()); @@ -425,8 +425,7 @@ public void solidPhaseFlash() { system.setBeta(system.getNumberOfPhases() - 1, frac); system.initBeta(); system.setBeta(system.getNumberOfPhases() - 1, - system.getPhases()[3].getComponent(solid).getNumberOfmoles() - / system.getNumberOfMoles()); + system.getPhase(3).getComponent(solid).getNumberOfmoles() / system.getNumberOfMoles()); // double phasetot=0.0; // for(int ph=0;ph solidEnthalpy) { double solidbeta = (Hspec - liqEnthalpy) diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/PSFlash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/PSFlash.java index db4104aa8..caac00677 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/PSFlash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/PSFlash.java @@ -122,7 +122,7 @@ public void run() { solveQ(); } else { SysNewtonRhapsonPHflash secondOrderSolver = - new SysNewtonRhapsonPHflash(system, 2, system.getPhases()[0].getNumberOfComponents(), 1); + new SysNewtonRhapsonPHflash(system, 2, system.getPhase(0).getNumberOfComponents(), 1); secondOrderSolver.setSpec(Sspec); secondOrderSolver.solve(1); } diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/QfuncFlash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/QfuncFlash.java index 1bc27985f..5f70629a9 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/QfuncFlash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/QfuncFlash.java @@ -2,7 +2,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import neqsim.thermo.system.SystemInterface; /** @@ -26,8 +25,7 @@ public class QfuncFlash extends Flash { * Constructor for QfuncFlash. *

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

@@ -35,8 +33,8 @@ public QfuncFlash() { *

* * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param Hspec a double - * @param type a int + * @param Hspec a double + * @param type a int */ public QfuncFlash(SystemInterface system, double Hspec, int type) { this.system = system; @@ -77,7 +75,8 @@ public double calcdQdT() { * @return a double */ public double solveQ() { - double oldTemp = 1.0 / system.getTemperature(), nyTemp = 1.0 / system.getTemperature(); + double oldTemp = 1.0 / system.getTemperature(); + double nyTemp = 1.0 / system.getTemperature(); double iterations = 1; do { iterations++; @@ -95,8 +94,8 @@ public double solveQ() { public void run() { tpFlash.run(); logger.info("entropy: " + system.getEntropy()); - SysNewtonRhapsonPHflash secondOrderSolver = new SysNewtonRhapsonPHflash(system, 2, - system.getPhases()[0].getNumberOfComponents(), type); + SysNewtonRhapsonPHflash secondOrderSolver = + new SysNewtonRhapsonPHflash(system, 2, system.getPhase(0).getNumberOfComponents(), type); secondOrderSolver.setSpec(Hspec); secondOrderSolver.solve(1); } diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash.java index b8711ad3b..6ee6611a1 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash.java @@ -76,7 +76,7 @@ public void calcMultiPhaseBeta() {} */ public void setXY() { for (int k = 0; k < system.getNumberOfPhases() - 1; k++) { - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { system.getPhase(k).getComponent(i).setx(system.getPhase(0).getComponent(i).getz() / E[i] / system.getPhase(k).getComponent(i).getFugacityCoefficient()); /* @@ -98,7 +98,7 @@ public void setXY() { 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++) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { x += system.getPhase(k).getComponent(i).getx(); } // logger.info("x tot " + x + " PHASE " + k); @@ -123,9 +123,9 @@ public void checkX() { *

*/ public void calcE() { - E = new double[system.getPhases()[0].getNumberOfComponents()]; + E = new double[system.getPhase(0).getNumberOfComponents()]; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { E[i] = 0.0; for (int k = 0; k < system.getNumberOfPhases() - 1; k++) { E[i] += system.getBeta(k) / system.getPhase(k).getComponent(i).getFugacityCoefficient(); @@ -137,7 +137,7 @@ public void calcE() { // system.getBeta(system.getNumberOfPhases()-1) / // system.getPhase(3).getComponent(solidComponent).getFugacityCoefficient(); E[solidComponent] = system.getPhase(0).getComponent(solidComponent).getz() - / system.getPhases()[3].getComponents()[solidComponent].getFugacityCoefficient(); + / system.getPhase(3).getComponents()[solidComponent].getFugacityCoefficient(); // logger.info("Ei " +E[solidComponent]); // logger.info("fug " // +system.getPhase(3).getComponent(solidComponent).getFugacityCoefficient()); @@ -162,15 +162,14 @@ public double calcQ() { } Q = betaTotal; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + 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 < system.getNumberOfPhases() - 1; k++) { - dQdbeta[k] = - 1.0 - system.getPhases()[3].getComponents()[solidComponent].getFugacityCoefficient() - / system.getPhase(k).getComponent(solidComponent).getFugacityCoefficient(); - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + dQdbeta[k] = 1.0 - system.getPhase(3).getComponents()[solidComponent].getFugacityCoefficient() + / system.getPhase(k).getComponent(solidComponent).getFugacityCoefficient(); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { if (i != solidComponent) { dQdbeta[k] -= system.getPhase(0).getComponent(i).getz() * 1.0 / E[i] / system.getPhase(k).getComponent(i).getFugacityCoefficient(); @@ -184,7 +183,7 @@ public double calcQ() { if (i != j) { Qmatrix[i][j] = 0; } - for (int k = 0; k < system.getPhases()[0].getNumberOfComponents(); k++) { + for (int k = 0; k < system.getPhase(0).getNumberOfComponents(); k++) { if (k != solidComponent) { Qmatrix[i][j] += system.getPhase(0).getComponent(k).getz() / (E[k] * E[k] * system.getPhase(j).getComponent(k).getFugacityCoefficient() diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash1.java b/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash1.java index 531874987..7844b5595 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash1.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash1.java @@ -55,13 +55,13 @@ public void calcMultiPhaseBeta() {} */ public void setXY() { for (int k = 0; k < system.getNumberOfPhases() - solidsNumber; k++) { - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(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() + .setx(system.getPhase(3).getComponent(i).getFugacityCoefficient() / system.getPhase(k).getComponent(i).getFugacityCoefficient()); } } @@ -76,7 +76,7 @@ public void setXY() { 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++) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { x += system.getPhase(k).getComponent(i).getx(); } // logger.info("x tot " + x + " PHASE " + k); @@ -101,9 +101,9 @@ public void checkX() { *

*/ public void calcE() { - E = new double[system.getPhases()[0].getNumberOfComponents()]; + E = new double[system.getPhase(0).getNumberOfComponents()]; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(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(); @@ -130,7 +130,7 @@ public double calcQ() { } Q = betaTotal; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { if (i != solidIndex) { Q -= Math.log(E[i]) * system.getPhase(0).getComponent(i).getz(); } @@ -138,10 +138,10 @@ public double calcQ() { 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())); + / system.getPhase(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(3).getComponent(solidIndex).getFugacityCoefficient() / system.getPhase(j).getComponent(solidIndex).getFugacityCoefficient(); } } @@ -156,9 +156,9 @@ public double calcQ() { public void calcQbeta() { for (int k = 0; k < system.getNumberOfPhases() - solidsNumber; k++) { dQdbeta[k] = 1.0; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { if (i == solidIndex) { - dQdbeta[k] -= system.getPhases()[3].getComponents()[solidIndex].getFugacityCoefficient() + dQdbeta[k] -= system.getPhase(3).getComponents()[solidIndex].getFugacityCoefficient() / system.getPhase(k).getComponent(solidIndex).getFugacityCoefficient(); } else { dQdbeta[k] -= system.getPhase(0).getComponent(i).getz() / E[i] @@ -180,9 +180,9 @@ public void calcGradientAndHesian() { for (int k = 0; k < system.getNumberOfPhases() - solidsNumber; k++) { dQdbeta[k] = 1.0; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { if (i == solidIndex) { - dQdbeta[k] -= system.getPhases()[3].getComponent(solidIndex).getFugacityCoefficient() + dQdbeta[k] -= system.getPhase(3).getComponent(solidIndex).getFugacityCoefficient() / system.getPhase(k).getComponent(solidIndex).getFugacityCoefficient(); } else { dQdbeta[k] -= system.getPhase(0).getComponent(i).getz() / E[i] @@ -194,7 +194,7 @@ public void calcGradientAndHesian() { for (int i = 0; i < system.getNumberOfPhases() - solidsNumber; i++) { Qmatrix[i][i] = 0; for (int j = 0; j < system.getNumberOfPhases() - solidsNumber; j++) { - for (int k = 0; k < system.getPhases()[0].getNumberOfComponents(); k++) { + for (int k = 0; k < system.getPhase(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() @@ -364,9 +364,9 @@ public double calcSolidBeta() { // double beta = 1.0; for (int i = 0; i < system.getNumberOfPhases() - solidsNumber; i++) { if (FluidPhaseActiveDescriptors[i] == 1) { - tempVar -= system.getBeta(i) - * system.getPhases()[3].getComponent(solidIndex).getFugacityCoefficient() - / system.getPhase(i).getComponent(solidIndex).getFugacityCoefficient(); + tempVar -= + system.getBeta(i) * system.getPhase(3).getComponent(solidIndex).getFugacityCoefficient() + / system.getPhase(i).getComponent(solidIndex).getFugacityCoefficient(); // beta -= system.getBeta(i); } } @@ -398,7 +398,7 @@ public void run() { } if (system.getPhase(0).getNumberOfComponents() == 1) { system.init(1); - if (system.getPhase(0).getFugacity(0) > system.getPhases()[3].getFugacity(0)) { + if (system.getPhase(0).getFugacity(0) > system.getPhase(3).getFugacity(0)) { system.setPhaseIndex(0, 3); } else { } @@ -445,7 +445,7 @@ public void run() { * @return a int */ public int checkAndAddSolidPhase() { - double[] solidCandidate = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] solidCandidate = new double[system.getPhase(0).getNumberOfComponents()]; for (int k = 0; k < system.getPhase(0).getNumberOfComponents(); k++) { if (system.getTemperature() > system.getPhase(0).getComponent(k) @@ -453,13 +453,13 @@ public int checkAndAddSolidPhase() { solidCandidate[k] = 0; } else { solidCandidate[k] = system.getPhase(0).getComponent(k).getz(); - system.getPhases()[3].getComponent(k).setx(1.0); + system.getPhase(3).getComponent(k).setx(1.0); for (int i = 0; i < system.getNumberOfPhases(); i++) { // double e = system.getBeta(i)* - // system.getPhases()[3].getComponent(k).fugcoef(system.getPhases()[3]); - solidCandidate[k] -= system.getBeta(i) - * system.getPhases()[3].getComponent(k).fugcoef(system.getPhases()[3]) - / system.getPhase(i).getComponent(k).getFugacityCoefficient(); + // system.getPhase(3).getComponent(k).fugcoef(system.getPhase(3)); + solidCandidate[k] -= + system.getBeta(i) * system.getPhase(3).getComponent(k).fugcoef(system.getPhase(3)) + / system.getPhase(i).getComponent(k).getFugacityCoefficient(); } } } @@ -468,12 +468,12 @@ public int checkAndAddSolidPhase() { totalSolidFrac = 0; for (int i = 0; i < solidCandidate.length; i++) { if (solidCandidate[i] > 1e-20) { - system.getPhases()[3].getComponent(i).setx(1.0); + system.getPhase(3).getComponent(i).setx(1.0); solidIndex = i; solidsNumber++; totalSolidFrac += solidCandidate[i]; } else { - system.getPhases()[3].getComponent(i).setx(0.0); + system.getPhase(3).getComponent(i).setx(0.0); } } for (int i = oldSolidsNumber; i < solidsNumber; i++) { @@ -513,9 +513,8 @@ public double solvebeta1() { 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(); + solidCandidate -= system.getPhase(3).getComponent(solidIndex).fugcoef(system.getPhase(3)) + / system.getPhase(i).getComponent(solidIndex).getFugacityCoefficient(); } double dsoliddn = (solidCandidate - solidCandidateOld) / dn; dn = -0.5 * solidCandidate / dsoliddn; diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash12.java b/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash12.java index 6ab902d50..889b33343 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash12.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash12.java @@ -59,13 +59,13 @@ public void calcMultiPhaseBeta() {} */ public void setXY() { for (int k = 0; k < system.getNumberOfPhases() - solidsNumber; k++) { - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(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() + .setx(system.getPhase(3).getComponent(i).getFugacityCoefficient() / system.getPhase(k).getComponent(i).getFugacityCoefficient()); } } @@ -80,7 +80,7 @@ public void setXY() { 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++) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { x += system.getPhase(k).getComponent(i).getx(); } logger.info("x tot " + x + " PHASE " + k); @@ -105,9 +105,9 @@ public void checkX() { *

*/ public void calcE() { - E = new double[system.getPhases()[0].getNumberOfComponents()]; + E = new double[system.getPhase(0).getNumberOfComponents()]; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(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(); @@ -134,7 +134,7 @@ public double calcQ() { } Q = betaTotal; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { if (i != solidIndex) { Q -= Math.log(E[i]) * system.getPhase(0).getComponent(i).getz(); } @@ -143,19 +143,19 @@ public double calcQ() { 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())); + / system.getPhase(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(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++) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { if (i == solidIndex) { - dQdbeta[k] -= system.getPhases()[3].getComponents()[solidIndex].getFugacityCoefficient() + dQdbeta[k] -= system.getPhase(3).getComponents()[solidIndex].getFugacityCoefficient() / system.getPhase(k).getComponent(solidIndex).getFugacityCoefficient(); } else { dQdbeta[k] -= system.getPhase(0).getComponent(i).getz() / E[i] @@ -167,7 +167,7 @@ public double calcQ() { 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++) { + for (int k = 0; k < system.getPhase(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() @@ -329,7 +329,7 @@ public void run() { * @return a int */ public int checkAndAddSolidPhase() { - double[] solidCandidate = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] solidCandidate = new double[system.getPhase(0).getNumberOfComponents()]; for (int k = 0; k < system.getPhase(0).getNumberOfComponents(); k++) { if (system.getTemperature() > system.getPhase(0).getComponent(k) @@ -337,10 +337,10 @@ public int checkAndAddSolidPhase() { solidCandidate[k] = -10; } else { solidCandidate[k] = system.getPhase(0).getComponent(k).getz(); - system.getPhases()[3].getComponent(k).setx(1.0); + system.getPhase(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]) + solidCandidate[k] -= system.getPhase(3).getComponent(k).fugcoef(system.getPhase(3)) / system.getPhase(i).getComponent(k).getFugacityCoefficient(); } } @@ -348,11 +348,11 @@ public int checkAndAddSolidPhase() { for (int i = 0; i < solidCandidate.length; i++) { if (solidCandidate[i] > 0.0) { - system.getPhases()[3].getComponent(i).setx(1.0); + system.getPhase(3).getComponent(i).setx(1.0); solidIndex = i; solidsNumber++; } else { - system.getPhases()[3].getComponent(i).setx(0.0); + system.getPhase(3).getComponent(i).setx(0.0); } } @@ -392,9 +392,8 @@ public double solvebeta1() { 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(); + solidCandidate -= system.getPhase(3).getComponent(solidIndex).fugcoef(system.getPhase(3)) + / system.getPhase(i).getComponent(solidIndex).getFugacityCoefficient(); } double dsoliddn = (solidCandidate - solidCandidateOld) / dn; dn = -0.5 * solidCandidate / dsoliddn; diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/SysNewtonRhapsonPHflash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/SysNewtonRhapsonPHflash.java index d3a44c37e..40bf2ec01 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/SysNewtonRhapsonPHflash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/SysNewtonRhapsonPHflash.java @@ -164,10 +164,10 @@ public void setJac() { double[] gP = new double[numberOfComponents]; for (int i = 0; i < numberOfComponents; i++) { - gT[i] = system.getTemperature() * (system.getPhases()[0].getComponent(i).getdfugdt() - - system.getPhases()[1].getComponent(i).getdfugdt()); - gP[i] = system.getPressure() * (system.getPhases()[0].getComponent(i).getdfugdp() - - system.getPhases()[1].getComponent(i).getdfugdp()); + gT[i] = system.getTemperature() * (system.getPhase(0).getComponent(i).getdfugdt() + - system.getPhase(1).getComponent(i).getdfugdt()); + gP[i] = system.getPressure() * (system.getPhase(0).getComponent(i).getdfugdp() + - system.getPhase(1).getComponent(i).getdfugdp()); Jac.set(numberOfComponents, i, gT[i]); Jac.set(i, numberOfComponents, gT[i]); diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/SysNewtonRhapsonTPflashNew.java b/src/main/java/neqsim/thermodynamicoperations/flashops/SysNewtonRhapsonTPflashNew.java index 8dcc7eec6..d8e5901f6 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/SysNewtonRhapsonTPflashNew.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/SysNewtonRhapsonTPflashNew.java @@ -78,14 +78,14 @@ 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].getComponent(i).getFugacityCoefficient() - / system.getPhases()[0].getComponent(i).getFugacityCoefficient())); + u.get(i, 0) + Math.log(system.getPhase(1).getComponent(i).getFugacityCoefficient() + / system.getPhase(0).getComponent(i).getFugacityCoefficient())); } double fsum = 0.0; for (int i = 0; i < numberOfComponents; i++) { - fsum = fsum + system.getPhases()[1].getComponent(i).getx() - - system.getPhases()[0].getComponent(i).getx(); + fsum = fsum + system.getPhase(1).getComponent(i).getx() + - system.getPhase(0).getComponent(i).getx(); } fvec.set(numberOfComponents, 0, fsum); // fvec.print(0,20); @@ -110,21 +110,21 @@ public void setJac() { double sumdxidbeta = 0; int nofc = numberOfComponents; for (int i = 0; i < numberOfComponents; i++) { - dxidlnk[i] = -system.getBeta() * system.getPhases()[0].getComponent(i).getx() - * system.getPhases()[1].getComponent(i).getx() - / system.getPhases()[0].getComponent(i).getz(); - dyidlnk[i] = system.getPhases()[1].getComponent(i).getx() - + system.getPhases()[0].getComponent(i).getK() * dxidlnk[i]; - - dyidbeta[i] = (system.getPhases()[0].getComponent(i).getK() - * system.getPhases()[0].getComponent(i).getz() - * (1 - system.getPhases()[0].getComponent(i).getK())) - / Math.pow(1 - system.getBeta() - + system.getBeta() * system.getPhases()[0].getComponent(i).getK(), 2); - dxidbeta[i] = (system.getPhases()[0].getComponent(i).getz() - * (1 - system.getPhases()[0].getComponent(i).getK())) - / Math.pow(1 - system.getBeta() - + system.getBeta() * system.getPhases()[0].getComponent(i).getK(), 2); + dxidlnk[i] = -system.getBeta() * system.getPhase(0).getComponent(i).getx() + * system.getPhase(1).getComponent(i).getx() / system.getPhase(0).getComponent(i).getz(); + dyidlnk[i] = system.getPhase(1).getComponent(i).getx() + + system.getPhase(0).getComponent(i).getK() * dxidlnk[i]; + + dyidbeta[i] = + (system.getPhase(0).getComponent(i).getK() * system.getPhase(0).getComponent(i).getz() + * (1 - system.getPhase(0).getComponent(i).getK())) + / Math.pow(1 - system.getBeta() + + system.getBeta() * system.getPhase(0).getComponent(i).getK(), 2); + dxidbeta[i] = (system.getPhase(0).getComponent(i).getz() + * (1 - system.getPhase(0).getComponent(i).getK())) + / Math.pow( + 1 - system.getBeta() + system.getBeta() * system.getPhase(0).getComponent(i).getK(), + 2); sumdyidbeta += dyidbeta[i]; sumdxidbeta += dxidbeta[i]; @@ -133,12 +133,12 @@ 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 - tempJ = dij + system.getPhases()[1].getComponent(i).getdfugdx(j) * dyidlnk[j] - - system.getPhases()[0].getComponent(i).getdfugdx(j) * dxidlnk[j]; + tempJ = dij + system.getPhase(1).getComponent(i).getdfugdx(j) * dyidlnk[j] + - system.getPhase(0).getComponent(i).getdfugdx(j) * dxidlnk[j]; Jac.set(i, j, tempJ); } - Jac.set(i, nofc, system.getPhases()[1].getComponent(i).getdfugdx(i) * dyidbeta[i] - - system.getPhases()[0].getComponent(i).getdfugdx(i) * dxidbeta[i]); + Jac.set(i, nofc, system.getPhase(1).getComponent(i).getdfugdx(i) * dyidbeta[i] + - system.getPhase(0).getComponent(i).getdfugdx(i) * dxidbeta[i]); Jac.set(nofc, i, dyidlnk[i] - dxidlnk[i]); } @@ -152,7 +152,7 @@ public void setJac() { */ public void setu() { for (int i = 0; i < numberOfComponents; i++) { - u.set(i, 0, Math.log(system.getPhases()[0].getComponent(i).getK())); + u.set(i, 0, Math.log(system.getPhase(0).getComponent(i).getK())); } u.set(numberOfComponents, 0, system.getBeta()); @@ -165,8 +165,8 @@ public void setu() { */ public void init() { for (int i = 0; i < numberOfComponents; i++) { - system.getPhases()[0].getComponent(i).setK(Math.exp(u.get(i, 0))); - system.getPhases()[1].getComponent(i).setK(Math.exp(u.get(i, 0))); + system.getPhase(0).getComponent(i).setK(Math.exp(u.get(i, 0))); + system.getPhase(1).getComponent(i).setK(Math.exp(u.get(i, 0))); } system.setBeta(u.get(numberOfComponents, 0)); system.calc_x_y(); diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/TPflash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/TPflash.java index eeb6aca42..4991f3f97 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/TPflash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/TPflash.java @@ -40,13 +40,13 @@ public TPflash() {} */ public TPflash(SystemInterface system) { this.system = system; - lnOldOldOldK = new double[system.getPhases()[0].getNumberOfComponents()]; - lnOldOldK = new double[system.getPhases()[0].getNumberOfComponents()]; - lnOldK = new double[system.getPhases()[0].getNumberOfComponents()]; - lnK = new double[system.getPhases()[0].getNumberOfComponents()]; - oldoldDeltalnK = new double[system.getPhases()[0].getNumberOfComponents()]; - oldDeltalnK = new double[system.getPhases()[0].getNumberOfComponents()]; - deltalnK = new double[system.getPhases()[0].getNumberOfComponents()]; + lnOldOldOldK = new double[system.getPhase(0).getNumberOfComponents()]; + lnOldOldK = new double[system.getPhase(0).getNumberOfComponents()]; + lnOldK = new double[system.getPhase(0).getNumberOfComponents()]; + lnK = new double[system.getPhase(0).getNumberOfComponents()]; + oldoldDeltalnK = new double[system.getPhase(0).getNumberOfComponents()]; + oldDeltalnK = new double[system.getPhase(0).getNumberOfComponents()]; + deltalnK = new double[system.getPhase(0).getNumberOfComponents()]; } /** @@ -303,7 +303,7 @@ public void run() { tpdy = -1.0; dgonRT = -1.0; } else { - for (i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { if (system.getComponent(i).getz() > 1e-50) { tpdy += system.getPhase(0).getComponent(i).getx() * (Math.log(system.getPhase(0).getComponent(i).getFugacityCoefficient()) @@ -320,7 +320,7 @@ public void run() { if (dgonRT > 0) { if (tpdx < 0) { - for (i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { system.getPhase(0).getComponent(i) .setK(Math.exp(Math.log(system.getPhase(1).getComponent(i).getFugacityCoefficient()) - minGibsLogFugCoef[i]) * presdiff); @@ -403,8 +403,8 @@ public void run() { } else if (iterations >= newtonLimit && Math .abs(system.getPhase(0).getPressure() - system.getPhase(1).getPressure()) < 1e-5) { if (iterations == newtonLimit) { - secondOrderSolver = new SysNewtonRhapsonTPflash(system, 2, - system.getPhases()[0].getNumberOfComponents()); + secondOrderSolver = + new SysNewtonRhapsonTPflash(system, 2, system.getPhase(0).getNumberOfComponents()); } try { deviation = secondOrderSolver.solve(); diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/TPgradientFlash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/TPgradientFlash.java index f6b608a9f..6db71251c 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/TPgradientFlash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/TPgradientFlash.java @@ -71,8 +71,8 @@ public void setfvec() { fvec.set(i, 0, logTerm - - Math.log(tempSystem.getPhases()[0].getComponent(i).getFugacityCoefficient() - * tempSystem.getPhases()[0].getComponent(i).getx() * tempSystem.getPressure()) + - Math.log(tempSystem.getPhase(0).getComponent(i).getFugacityCoefficient() + * tempSystem.getPhase(0).getComponent(i).getx() * tempSystem.getPressure()) - molarMassTerm); sumx += componentX; } @@ -90,15 +90,13 @@ public void setJac() { for (int i = 0; i < numComponents; i++) { for (int j = 0; j < numComponents; j++) { double dij = (i == j) ? 1.0 : 0.0; // Kronecker delta - double fugacityCoeff = - localSystem.getPhases()[0].getComponent(i).getFugacityCoefficient(); - double componentX = localSystem.getPhases()[0].getComponent(i).getx(); + double fugacityCoeff = localSystem.getPhase(0).getComponent(i).getFugacityCoefficient(); + double componentX = localSystem.getPhase(0).getComponent(i).getx(); double pressure = localSystem.getPressure(); - double tempJ = 1.0 / (fugacityCoeff * componentX * pressure) - * (fugacityCoeff * dij * pressure - + localSystem.getPhases()[0].getComponent(i).getdfugdx(j) * componentX - * pressure); + double tempJ = + 1.0 / (fugacityCoeff * componentX * pressure) * (fugacityCoeff * dij * pressure + + localSystem.getPhase(0).getComponent(i).getdfugdx(j) * componentX * pressure); Jac.set(i, j, tempJ); } } @@ -109,12 +107,12 @@ public void setJac() { } for (int i = 0; i < numComponents; i++) { - double fugacityCoeff = localSystem.getPhases()[0].getComponent(i).getFugacityCoefficient(); - double componentX = localSystem.getPhases()[0].getComponent(i).getx(); + double fugacityCoeff = localSystem.getPhase(0).getComponent(i).getFugacityCoefficient(); + double componentX = localSystem.getPhase(0).getComponent(i).getx(); double pressure = localSystem.getPressure(); double tempJ = 1.0 / (fugacityCoeff * componentX * pressure) - * (localSystem.getPhases()[0].getComponent(i).getdfugdp() * componentX * pressure + * (localSystem.getPhase(0).getComponent(i).getdfugdp() * componentX * pressure + fugacityCoeff * componentX); Jac.set(i, numComponents, tempJ); } diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/TPmultiflash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/TPmultiflash.java index 4ed67c1c1..ddcc724ce 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/TPmultiflash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/TPmultiflash.java @@ -233,14 +233,14 @@ public void stabilityAnalysis() { 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[] deltalogWi = new double[system.getPhase(0).getNumberOfComponents()]; + double[] oldDeltalogWi = new double[system.getPhase(0).getNumberOfComponents()]; + double[] oldoldDeltalogWi = new double[system.getPhase(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[] oldoldlogw = new double[system.getPhase(0).getNumberOfComponents()]; + double[] oldoldoldlogw = new double[system.getPhase(0).getNumberOfComponents()]; double[] d = new double[system.getPhase(0).getNumberOfComponents()]; double[][] x = new double[system.getPhase(0).getNumberOfComponents()][system.getPhase(0) .getNumberOfComponents()]; @@ -285,14 +285,14 @@ public void stabilityAnalysis() { * (system.getPhase(0).getComponent(k).getx() > 1e-100) { d[k] = * Math.log(system.getPhase(0).getComponent(k).getx()) + * system.getPhase(0).getComponent(k).getLogFugacityCoefficient(); - * if(minimumGibbsEnergySystem.getPhases()[lowestGibbsEnergyPhase].getComponents + * if(minimumGibbsEnergySystem.getPhase(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).getComponent(k).getx()) + system.getPhase(0).getComponent(k).getLogFugacityCoefficient(); - // if(minimumGibbsEnergySystem.getPhases()[lowestGibbsEnergyPhase].getComponent(k).getIonicCharge()!=0) + // if(minimumGibbsEnergySystem.getPhase(lowestGibbsEnergyPhase).getComponent(k).getIonicCharge()!=0) // d[k]=0; } } @@ -429,7 +429,7 @@ public void stabilityAnalysis() { } } } else { - SimpleMatrix f = new SimpleMatrix(system.getPhases()[0].getNumberOfComponents(), 1); + SimpleMatrix f = new SimpleMatrix(system.getPhase(0).getNumberOfComponents(), 1); SimpleMatrix df = null; SimpleMatrix identitytimesConst = null; // if (!secondOrderStabilityAnalysis) { @@ -441,34 +441,35 @@ public void stabilityAnalysis() { 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()); + alpha = new double[clonedSystem.get(0).getPhase(0).getNumberOfComponents()]; + df = new SimpleMatrix(system.getPhase(0).getNumberOfComponents(), + system.getPhase(0).getNumberOfComponents()); + identitytimesConst = SimpleMatrix.identity(system.getPhase(0).getNumberOfComponents()); // , - // system.getPhases()[0].getNumberOfComponents()); + // system.getPhase(0).getNumberOfComponents()); // secondOrderStabilityAnalysis = true; // } - for (int i = 0; i < clonedSystem.get(0).getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < clonedSystem.get(0).getPhase(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].getComponent(i).getLogFugacityCoefficient() - - d[i])); + f.set(i, 0, + Math.sqrt(Wi[j][i]) * (Math.log(Wi[j][i]) + + clonedSystem.get(0).getPhase(1).getComponent(i).getLogFugacityCoefficient() + - d[i])); } - for (int k = 0; k < clonedSystem.get(0).getPhases()[0].getNumberOfComponents(); k++) { + for (int k = 0; k < clonedSystem.get(0).getPhase(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].getComponent(i).getdfugdn(k)); - // * clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); + * clonedSystem.get(0).getPhase(1).getComponent(i).getdfugdn(k)); + // * clonedSystem.getPhase(j).getNumberOfMolesInPhase()); } else { df.set(i, k, 0); - // * clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); + // * clonedSystem.getPhase(j).getNumberOfMolesInPhase()); } } } @@ -553,7 +554,7 @@ public void stabilityAnalysis() { for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { system.getPhase(system.getNumberOfPhases() - 1).getComponent(i).setx(x[k][i]); } - system.getPhases()[system.getNumberOfPhases() - 1].normalize(); + system.getPhase(system.getNumberOfPhases() - 1).normalize(); multiPhaseTest = true; system.setBeta(system.getNumberOfPhases() - 1, system.getPhase(0).getComponent(unstabcomp).getz()); @@ -583,14 +584,14 @@ public void stabilityAnalysis3() { 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[] deltalogWi = new double[system.getPhase(0).getNumberOfComponents()]; + double[] oldDeltalogWi = new double[system.getPhase(0).getNumberOfComponents()]; + double[] oldoldDeltalogWi = new double[system.getPhase(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[] oldoldlogw = new double[system.getPhase(0).getNumberOfComponents()]; + double[] oldoldoldlogw = new double[system.getPhase(0).getNumberOfComponents()]; double[] d = new double[system.getPhase(0).getNumberOfComponents()]; double[][] x = new double[system.getPhase(0).getNumberOfComponents()][system.getPhase(0) .getNumberOfComponents()]; @@ -635,14 +636,14 @@ public void stabilityAnalysis3() { * (system.getPhase(0).getComponent(k).getx() > 1e-100) { d[k] = * Math.log(system.getPhase(0).getComponent(k).getx()) + * system.getPhase(0).getComponent(k).getLogFugacityCoefficient(); - * if(minimumGibbsEnergySystem.getPhases()[lowestGibbsEnergyPhase].getComponents + * if(minimumGibbsEnergySystem.getPhase(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).getComponent(k).getx()) + system.getPhase(0).getComponent(k).getLogFugacityCoefficient(); - // if(minimumGibbsEnergySystem.getPhases()[lowestGibbsEnergyPhase].getComponent(k).getIonicCharge()!=0) + // if(minimumGibbsEnergySystem.getPhase(lowestGibbsEnergyPhase).getComponent(k).getIonicCharge()!=0) // d[k]=0; } } @@ -779,7 +780,7 @@ public void stabilityAnalysis3() { } } } else { - SimpleMatrix f = new SimpleMatrix(system.getPhases()[0].getNumberOfComponents(), 1); + SimpleMatrix f = new SimpleMatrix(system.getPhase(0).getNumberOfComponents(), 1); SimpleMatrix df = null; SimpleMatrix identitytimesConst = null; // if (!secondOrderStabilityAnalysis) { @@ -791,34 +792,35 @@ public void stabilityAnalysis3() { 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()); + alpha = new double[clonedSystem.get(0).getPhase(0).getNumberOfComponents()]; + df = new SimpleMatrix(system.getPhase(0).getNumberOfComponents(), + system.getPhase(0).getNumberOfComponents()); + identitytimesConst = SimpleMatrix.identity(system.getPhase(0).getNumberOfComponents()); // , - // system.getPhases()[0].getNumberOfComponents()); + // system.getPhase(0).getNumberOfComponents()); // secondOrderStabilityAnalysis = true; // } - for (int i = 0; i < clonedSystem.get(0).getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < clonedSystem.get(0).getPhase(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].getComponent(i).getLogFugacityCoefficient() - - d[i])); + f.set(i, 0, + Math.sqrt(Wi[j][i]) * (Math.log(Wi[j][i]) + + clonedSystem.get(0).getPhase(1).getComponent(i).getLogFugacityCoefficient() + - d[i])); } - for (int k = 0; k < clonedSystem.get(0).getPhases()[0].getNumberOfComponents(); k++) { + for (int k = 0; k < clonedSystem.get(0).getPhase(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].getComponent(i).getdfugdn(k)); - // * clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); + * clonedSystem.get(0).getPhase(1).getComponent(i).getdfugdn(k)); + // * clonedSystem.getPhase(j).getNumberOfMolesInPhase()); } else { df.set(i, k, 0); - // * clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); + // * clonedSystem.getPhase(j).getNumberOfMolesInPhase()); } } } @@ -903,7 +905,7 @@ public void stabilityAnalysis3() { for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { system.getPhase(system.getNumberOfPhases() - 1).getComponent(i).setx(x[k][i]); } - system.getPhases()[system.getNumberOfPhases() - 1].normalize(); + system.getPhase(system.getNumberOfPhases() - 1).normalize(); multiPhaseTest = true; system.setBeta(system.getNumberOfPhases() - 1, system.getPhase(0).getComponent(unstabcomp).getz()); @@ -933,14 +935,14 @@ public void stabilityAnalysis2() { 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[] deltalogWi = new double[system.getPhase(0).getNumberOfComponents()]; + double[] oldDeltalogWi = new double[system.getPhase(0).getNumberOfComponents()]; + double[] oldoldDeltalogWi = new double[system.getPhase(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[] oldoldlogw = new double[system.getPhase(0).getNumberOfComponents()]; + double[] oldoldoldlogw = new double[system.getPhase(0).getNumberOfComponents()]; double[] d = new double[system.getPhase(0).getNumberOfComponents()]; double[][] x = new double[system.getPhase(0).getNumberOfComponents()][system.getPhase(0) .getNumberOfComponents()]; @@ -998,7 +1000,7 @@ public void stabilityAnalysis2() { if (system.getPhase(0).getComponent(k).getx() > 1e-100) { d[k] = Math.log(system.getPhase(0).getComponent(k).getx()) + system.getPhase(0).getComponent(k).getLogFugacityCoefficient(); - // if(minimumGibbsEnergySystem.getPhases()[lowestGibbsEnergyPhase].getComponent(k).getIonicCharge()!=0) + // if(minimumGibbsEnergySystem.getPhase(lowestGibbsEnergyPhase).getComponent(k).getIonicCharge()!=0) // d[k]=0; } // logger.info("dk: " + d[k]); @@ -1112,7 +1114,7 @@ public void stabilityAnalysis2() { } } } else { - SimpleMatrix f = new SimpleMatrix(system.getPhases()[0].getNumberOfComponents(), 1); + SimpleMatrix f = new SimpleMatrix(system.getPhase(0).getNumberOfComponents(), 1); SimpleMatrix df = null; SimpleMatrix identitytimesConst = null; // if (!secondOrderStabilityAnalysis) { @@ -1124,35 +1126,35 @@ public void stabilityAnalysis2() { 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()); + alpha = new double[(clonedSystem.get(j)).getPhase(0).getNumberOfComponents()]; + df = new SimpleMatrix(system.getPhase(0).getNumberOfComponents(), + system.getPhase(0).getNumberOfComponents()); + identitytimesConst = SimpleMatrix.identity(system.getPhase(0).getNumberOfComponents()); + // , system.getPhase(0).getNumberOfComponents()); // secondOrderStabilityAnalysis = true; // } - for (int i = 0; i < (clonedSystem.get(j)).getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < (clonedSystem.get(j)).getPhase(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].getComponent(i).getLogFugacityCoefficient() + + (clonedSystem.get(j)).getPhase(1).getComponent(i).getLogFugacityCoefficient() - d[i])); } - for (int k = 0; k < (clonedSystem.get(j)).getPhases()[0].getNumberOfComponents(); k++) { + for (int k = 0; k < (clonedSystem.get(j)).getPhase(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].getComponent(i).getdfugdn(k)); + * (clonedSystem.get(j)).getPhase(1).getComponent(i).getdfugdn(k)); // * - // clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); + // clonedSystem.getPhase(j).getNumberOfMolesInPhase()); } else { df.set(i, k, 0); // * - // clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); + // clonedSystem.getPhase(j).getNumberOfMolesInPhase()); } } } @@ -1235,7 +1237,7 @@ public void stabilityAnalysis2() { for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { system.getPhase(system.getNumberOfPhases() - 1).getComponent(i).setx(x[k][i]); } - system.getPhases()[system.getNumberOfPhases() - 1].normalize(); + system.getPhase(system.getNumberOfPhases() - 1).normalize(); multiPhaseTest = true; system.setBeta(system.getNumberOfPhases() - 1, system.getPhase(0).getComponent(unstabcomp).getz()); diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/TPmultiflashWAX.java b/src/main/java/neqsim/thermodynamicoperations/flashops/TPmultiflashWAX.java index b8ab9e936..fcec2899d 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/TPmultiflashWAX.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/TPmultiflashWAX.java @@ -270,9 +270,9 @@ public void stabilityAnalysis() { } if (system.getPhase(0).getComponent(k).getx() > 1e-100) { - d[k] = Math.log( - minimumGibbsEnergySystem.getPhases()[lowestGibbsEnergyPhase].getComponent(k).getx()) - + minimumGibbsEnergySystem.getPhases()[lowestGibbsEnergyPhase].getComponent(k) + d[k] = Math + .log(minimumGibbsEnergySystem.getPhase(lowestGibbsEnergyPhase).getComponent(k).getx()) + + minimumGibbsEnergySystem.getPhase(lowestGibbsEnergyPhase).getComponent(k) .getLogFugacityCoefficient(); } } diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/TPmultiflash_1.java b/src/main/java/neqsim/thermodynamicoperations/flashops/TPmultiflash_1.java index 456276f26..8aaa61f1d 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/TPmultiflash_1.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/TPmultiflash_1.java @@ -68,9 +68,9 @@ public void calcMultiPhaseBeta() {} */ public void setXY() { for (int k = 0; k < system.getNumberOfPhases(); k++) { - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - system.getPhases()[k].getComponent(i).setx(system.getPhases()[k].getComponent(i).getz() - / E[i] / system.getPhases()[k].getComponent(i).getFugacityCoefficient()); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + system.getPhase(k).getComponent(i).setx(system.getPhase(k).getComponent(i).getz() / E[i] + / system.getPhase(k).getComponent(i).getFugacityCoefficient()); } } } @@ -81,12 +81,12 @@ public void setXY() { *

*/ public void calcE() { - E = new double[system.getPhases()[0].getNumberOfComponents()]; + E = new double[system.getPhase(0).getNumberOfComponents()]; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { for (int k = 0; k < system.getNumberOfPhases(); k++) { - E[i] += system.getPhases()[k].getBeta() - / system.getPhases()[k].getComponent(i).getFugacityCoefficient(); + E[i] += system.getPhase(k).getBeta() + / system.getPhase(k).getComponent(i).getFugacityCoefficient(); } } } @@ -105,31 +105,31 @@ public double calcQ() { Qmatrix = new double[system.getNumberOfPhases()][system.getNumberOfPhases()]; for (int k = 0; k < system.getNumberOfPhases(); k++) { - betaTotal += system.getPhases()[k].getBeta(); + betaTotal += system.getPhase(k).getBeta(); } Q = betaTotal; this.calcE(); - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - Q -= Math.log(E[i]) * system.getPhases()[0].getComponent(i).getz(); + 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 < system.getNumberOfPhases(); k++) { dQdbeta[k] = 1.0; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - dQdbeta[k] -= system.getPhases()[0].getComponent(i).getz() * 1.0 / E[i] - / system.getPhases()[k].getComponent(i).getFugacityCoefficient(); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + dQdbeta[k] -= system.getPhase(0).getComponent(i).getz() * 1.0 / E[i] + / 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; - for (int k = 0; k < system.getPhases()[0].getNumberOfComponents(); k++) { - Qmatrix[i][j] += system.getPhases()[0].getComponent(k).getz() - / (E[k] * E[k] * system.getPhases()[j].getComponent(k).getFugacityCoefficient() - * system.getPhases()[i].getComponent(k).getFugacityCoefficient()); + for (int k = 0; k < system.getPhase(0).getNumberOfComponents(); k++) { + 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()); } } } @@ -150,7 +150,7 @@ public void solveBeta() { do { iter++; for (int k = 0; k < system.getNumberOfPhases(); k++) { - oldBeta[k] = system.getPhases()[k].getBeta(); + oldBeta[k] = system.getPhase(k).getBeta(); } calcQ(); @@ -183,14 +183,14 @@ public void solveBeta() { /** {@inheritDoc} */ @Override public void stabilityAnalysis() { - double[] logWi = new double[system.getPhases()[1].getNumberOfComponents()]; - double[][] Wi = new double[system.getPhases()[1].getNumberOfComponents()][system.getPhases()[0] + double[] logWi = new double[system.getPhase(1).getNumberOfComponents()]; + double[][] Wi = new double[system.getPhase(1).getNumberOfComponents()][system.getPhase(0) .getNumberOfComponents()]; - double[] sumw = new double[system.getPhases()[1].getNumberOfComponents()]; + double[] sumw = new double[system.getPhase(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] + double[] oldlogw = new double[system.getPhase(1).getNumberOfComponents()]; + double[] d = new double[system.getPhase(1).getNumberOfComponents()]; + double[][] x = new double[system.getPhase(1).getNumberOfComponents()][system.getPhase(0) .getNumberOfComponents()]; SystemInterface minimumGibbsEnergySystem; @@ -198,13 +198,13 @@ public void stabilityAnalysis() { minimumGibbsEnergySystem = system.clone(); - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(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++) { + for (int j = 0; j < system.getPhase(1).getNumberOfComponents(); j++) { numb = i == j ? 1.0 : 1.0e-3; - (clonedSystem.get(i)).getPhases()[1].getComponent(j).setx(numb); + (clonedSystem.get(i)).getPhase(1).getComponent(j).setx(numb); } (clonedSystem.get(i)).init(1); } @@ -213,70 +213,70 @@ public void stabilityAnalysis() { // logger.info("low gibbs phase " + lowestGibbsEnergyPhase); - for (int k = 0; k < minimumGibbsEnergySystem.getPhases()[1].getNumberOfComponents(); k++) { - // sumz += minimumGibbsEnergySystem.getPhases()[1].getComponent(k).getz(); - for (int i = 0; i < minimumGibbsEnergySystem.getPhases()[1].getNumberOfComponents(); i++) { - sumw[k] += (clonedSystem.get(k)).getPhases()[1].getComponent(i).getx(); + for (int k = 0; k < minimumGibbsEnergySystem.getPhase(1).getNumberOfComponents(); k++) { + // sumz += minimumGibbsEnergySystem.getPhase(1).getComponent(k).getz(); + for (int i = 0; i < minimumGibbsEnergySystem.getPhase(1).getNumberOfComponents(); i++) { + sumw[k] += (clonedSystem.get(k)).getPhase(1).getComponent(i).getx(); } } - 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].getComponent(i) - .setx((clonedSystem.get(k)).getPhases()[1].getComponent(i).getx() / sumw[0]); + for (int k = 0; k < minimumGibbsEnergySystem.getPhase(1).getNumberOfComponents(); k++) { + for (int i = 0; i < minimumGibbsEnergySystem.getPhase(1).getNumberOfComponents(); i++) { + (clonedSystem.get(k)).getPhase(1).getComponent(i) + .setx((clonedSystem.get(k)).getPhase(1).getComponent(i).getx() / sumw[0]); // logger.info("x: " + ( - // clonedSystem.get(k)).getPhases()[0].getComponent(i).getx()); + // clonedSystem.get(k)).getPhase(0).getComponent(i).getx()); } - d[k] = Math - .log(minimumGibbsEnergySystem.getPhases()[lowestGibbsEnergyPhase].getComponent(k).getx()) - + Math.log(minimumGibbsEnergySystem.getPhases()[lowestGibbsEnergyPhase].getComponent(k) - .getFugacityCoefficient()); + d[k] = + Math.log(minimumGibbsEnergySystem.getPhase(lowestGibbsEnergyPhase).getComponent(k).getx()) + + Math.log(minimumGibbsEnergySystem.getPhase(lowestGibbsEnergyPhase).getComponent(k) + .getFugacityCoefficient()); // logger.info("dk: " + d[k]); } - for (int j = 0; j < minimumGibbsEnergySystem.getPhases()[1].getNumberOfComponents(); j++) { + for (int j = 0; j < minimumGibbsEnergySystem.getPhase(1).getNumberOfComponents(); j++) { logWi[j] = 1; } - for (int j = 0; j < system.getPhases()[1].getNumberOfComponents(); j++) { + for (int j = 0; j < system.getPhase(1).getNumberOfComponents(); j++) { do { err = 0; (clonedSystem.get(j)).init(1); - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { oldlogw[i] = logWi[i]; logWi[i] = d[i] - Math - .log((clonedSystem.get(j)).getPhases()[1].getComponent(i).getFugacityCoefficient()); + .log((clonedSystem.get(j)).getPhase(1).getComponent(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++) { + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { sumw[j] += Math.exp(logWi[i]); } - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - (clonedSystem.get(j)).getPhases()[1].getComponent(i).setx(Math.exp(logWi[i]) / sumw[j]); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + (clonedSystem.get(j)).getPhase(1).getComponent(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++) { + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { tm[j] -= Math.exp(logWi[i]); - x[j][i] = (clonedSystem.get(j)).getPhases()[1].getComponent(i).getx(); + x[j][i] = (clonedSystem.get(j)).getPhase(1).getComponent(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++) { + for (int k = 0; k < system.getPhase(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].getComponent(i).setx(x[k][i]); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + system.getPhase(2).getComponent(i).setx(x[k][i]); } multiPhaseTest = true; system.setBeta(system.getNumberOfPhases() - 1, @@ -306,14 +306,14 @@ public void run() { chemdev = 0.0; double[] xchem = new double[system.getPhase(phaseNum).getNumberOfComponents()]; - for (i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { xchem[i] = system.getPhase(phaseNum).getComponent(i).getx(); } system.init(1); system.getChemicalReactionOperations().solveChemEq(phaseNum, 1); - for (i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { chemdev += Math.abs(xchem[i] - system.getPhase(phaseNum).getComponent(i).getx()); } logger.info("chemdev: " + chemdev); diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/BubblePointPressureFlash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/BubblePointPressureFlash.java index 134fd39c1..b902cba2a 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/BubblePointPressureFlash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/BubblePointPressureFlash.java @@ -55,21 +55,19 @@ public void run() { system.getChemicalReactionOperations().solveChemEq(1, 1); } - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - system.getPhases()[1].getComponent(i) - .setx(system.getPhases()[0].getComponent(i).getz()); - if (system.getPhases()[0].getComponent(i).getIonicCharge() != 0) { - system.getPhases()[0].getComponent(i).setx(1e-40); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + system.getPhase(1).getComponent(i).setx(system.getPhase(0).getComponent(i).getz()); + if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { + system.getPhase(0).getComponent(i).setx(1e-40); } else { - system.getPhases()[0].getComponent(i) - .setx(system.getPhases()[0].getComponent(i).getK() - * system.getPhases()[1].getComponent(i).getz()); + system.getPhase(0).getComponent(i).setx( + system.getPhase(0).getComponent(i).getK() * system.getPhase(1).getComponent(i).getz()); } } ytotal = 0.0; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - ytotal += system.getPhases()[0].getComponent(i).getx(); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + ytotal += system.getPhase(0).getComponent(i).getx(); } double ktot = 0.0; @@ -81,42 +79,39 @@ public void run() { iterations = 0; do { iterations++; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - system.getPhases()[0].getComponent(i) - .setx(system.getPhases()[0].getComponent(i).getx() / ytotal); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + system.getPhase(0).getComponent(i) + .setx(system.getPhase(0).getComponent(i).getx() / ytotal); } system.init(3); oldPres = system.getPressure(); ktot = 0.0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { do { - yold = system.getPhases()[0].getComponent(i).getx(); - if (!Double.isNaN(Math.exp( - Math.log(system.getPhases()[1].getComponent(i).getFugacityCoefficient()) - Math - .log(system.getPhases()[0].getComponent(i).getFugacityCoefficient())))) { + yold = system.getPhase(0).getComponent(i).getx(); + if (!Double.isNaN( + Math.exp(Math.log(system.getPhase(1).getComponent(i).getFugacityCoefficient()) + - Math.log(system.getPhase(0).getComponent(i).getFugacityCoefficient())))) { if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { - system.getPhases()[0].getComponent(i).setK(1e-40); + system.getPhase(0).getComponent(i).setK(1e-40); } else { - system.getPhases()[0].getComponent(i).setK(Math.exp(Math - .log(system.getPhases()[1].getComponent(i).getFugacityCoefficient()) - - Math.log(system.getPhases()[0].getComponent(i).getFugacityCoefficient()))); + system.getPhase(0).getComponent(i).setK( + Math.exp(Math.log(system.getPhase(1).getComponent(i).getFugacityCoefficient()) + - Math.log(system.getPhase(0).getComponent(i).getFugacityCoefficient()))); } } - system.getPhases()[1].getComponent(i) - .setK(system.getPhases()[0].getComponent(i).getK()); - system.getPhases()[0].getComponent(i) - .setx(system.getPhases()[0].getComponent(i).getK() - * system.getPhases()[1].getComponent(i).getz()); + system.getPhase(1).getComponent(i).setK(system.getPhase(0).getComponent(i).getK()); + system.getPhase(0).getComponent(i).setx(system.getPhase(0).getComponent(i).getK() + * system.getPhase(1).getComponent(i).getz()); // logger.info("y err " + - // Math.abs(system.getPhases()[0].getComponent(i).getx()-yold)); - } while (Math.abs(system.getPhases()[0].getComponent(i).getx() - yold) / yold > 1e-8); - ktot += Math.abs(system.getPhases()[1].getComponent(i).getK() - 1.0); + // Math.abs(system.getPhase(0).getComponent(i).getx()-yold)); + } while (Math.abs(system.getPhase(0).getComponent(i).getx() - yold) / yold > 1e-8); + ktot += Math.abs(system.getPhase(1).getComponent(i).getK() - 1.0); } - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - if (!Double.isNaN(system.getPhases()[0].getComponent(i).getK())) { - system.getPhases()[0].getComponent(i) - .setx(system.getPhases()[0].getComponent(i).getK() - * system.getPhases()[1].getComponent(i).getz()); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (!Double.isNaN(system.getPhase(0).getComponent(i).getK())) { + system.getPhase(0).getComponent(i).setx(system.getPhase(0).getComponent(i).getK() + * system.getPhase(1).getComponent(i).getz()); } else { system.init(0); logger.error("k err. : nan"); @@ -124,8 +119,8 @@ public void run() { } ytotal = 0.0; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - ytotal += system.getPhases()[0].getComponent(i).getx(); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + ytotal += system.getPhase(0).getComponent(i).getx(); } // zlogger.info("ytot " + ytotal + " pres " + system.getPressure()); diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/BubblePointPressureFlashDer.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/BubblePointPressureFlashDer.java index 7f4e10c47..30c47b07e 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/BubblePointPressureFlashDer.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/BubblePointPressureFlashDer.java @@ -55,21 +55,19 @@ public void run() { system.getChemicalReactionOperations().solveChemEq(1, 0); } - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - system.getPhases()[1].getComponent(i) - .setx(system.getPhases()[0].getComponent(i).getz()); - if (system.getPhases()[0].getComponent(i).getIonicCharge() != 0) { - system.getPhases()[0].getComponent(i).setx(1e-40); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + system.getPhase(1).getComponent(i).setx(system.getPhase(0).getComponent(i).getz()); + if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { + system.getPhase(0).getComponent(i).setx(1e-40); } else { - system.getPhases()[0].getComponent(i) - .setx(system.getPhases()[0].getComponent(i).getK() - * system.getPhases()[1].getComponent(i).getz()); + system.getPhase(0).getComponent(i).setx( + system.getPhase(0).getComponent(i).getK() * system.getPhase(1).getComponent(i).getz()); } } ytotal = 0.0; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - ytotal += system.getPhases()[0].getComponent(i).getx(); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + ytotal += system.getPhase(0).getComponent(i).getx(); } double ktot = 0.0; @@ -81,42 +79,39 @@ public void run() { iterations = 0; do { iterations++; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - system.getPhases()[0].getComponent(i) - .setx(system.getPhases()[0].getComponent(i).getx() / ytotal); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + system.getPhase(0).getComponent(i) + .setx(system.getPhase(0).getComponent(i).getx() / ytotal); } system.init(1); oldPres = system.getPressure(); ktot = 0.0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { do { - yold = system.getPhases()[0].getComponent(i).getx(); - if (!Double.isNaN(Math.exp( - Math.log(system.getPhases()[1].getComponent(i).getFugacityCoefficient()) - Math - .log(system.getPhases()[0].getComponent(i).getFugacityCoefficient())))) { + yold = system.getPhase(0).getComponent(i).getx(); + if (!Double.isNaN( + Math.exp(Math.log(system.getPhase(1).getComponent(i).getFugacityCoefficient()) + - Math.log(system.getPhase(0).getComponent(i).getFugacityCoefficient())))) { if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { - system.getPhases()[0].getComponent(i).setK(1e-40); + system.getPhase(0).getComponent(i).setK(1e-40); } else { - system.getPhases()[0].getComponent(i).setK(Math.exp(Math - .log(system.getPhases()[1].getComponent(i).getFugacityCoefficient()) - - Math.log(system.getPhases()[0].getComponent(i).getFugacityCoefficient()))); + system.getPhase(0).getComponent(i).setK( + Math.exp(Math.log(system.getPhase(1).getComponent(i).getFugacityCoefficient()) + - Math.log(system.getPhase(0).getComponent(i).getFugacityCoefficient()))); } } - system.getPhases()[1].getComponent(i) - .setK(system.getPhases()[0].getComponent(i).getK()); - system.getPhases()[0].getComponent(i) - .setx(system.getPhases()[0].getComponent(i).getK() - * system.getPhases()[1].getComponent(i).getz()); + system.getPhase(1).getComponent(i).setK(system.getPhase(0).getComponent(i).getK()); + system.getPhase(0).getComponent(i).setx(system.getPhase(0).getComponent(i).getK() + * system.getPhase(1).getComponent(i).getz()); // logger.info("y err " + - // Math.abs(system.getPhases()[0].getComponent(i).getx()-yold)); - } while (Math.abs(system.getPhases()[0].getComponent(i).getx() - yold) / yold > 1e-8); - ktot += Math.abs(system.getPhases()[1].getComponent(i).getK() - 1.0); + // Math.abs(system.getPhase(0).getComponent(i).getx()-yold)); + } while (Math.abs(system.getPhase(0).getComponent(i).getx() - yold) / yold > 1e-8); + ktot += Math.abs(system.getPhase(1).getComponent(i).getK() - 1.0); } - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - if (!Double.isNaN(system.getPhases()[0].getComponent(i).getK())) { - system.getPhases()[0].getComponent(i) - .setx(system.getPhases()[0].getComponent(i).getK() - * system.getPhases()[1].getComponent(i).getz()); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (!Double.isNaN(system.getPhase(0).getComponent(i).getK())) { + system.getPhase(0).getComponent(i).setx(system.getPhase(0).getComponent(i).getK() + * system.getPhase(1).getComponent(i).getz()); } else { system.init(0); logger.error("K error : nan"); @@ -126,21 +121,21 @@ public void run() { ytotal = 0.0; deriv = 0.0; funk = 0.0; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - ytotal += system.getPhases()[0].getComponent(i).getx(); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + ytotal += system.getPhase(0).getComponent(i).getx(); // Following lines added by Neeraj - funk += system.getPhases()[1].getComponent(i).getx() - * system.getPhases()[1].getComponent(i).getK(); - deriv += system.getPhases()[1].getComponent(i).getx() - * system.getPhases()[1].getComponent(i).getK() - * (system.getPhases()[1].getComponent(i).logfugcoefdP(this.system.getPhase(1)) - - system.getPhases()[0].getComponent(i).logfugcoefdP(this.system.getPhase(0))); + funk += + system.getPhase(1).getComponent(i).getx() * system.getPhase(1).getComponent(i).getK(); + deriv += + system.getPhase(1).getComponent(i).getx() * system.getPhase(1).getComponent(i).getK() + * (system.getPhase(1).getComponent(i).logfugcoefdP(this.system.getPhase(1)) + - system.getPhase(0).getComponent(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))); + // "+system.getPhase(0).getComponents()[3].logfugcoefdP(this.system.getPhase(0))); // logger.info("ytot "+ytotal); if (ytotal > 1.5) { ytotal = 1.5; diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/BubblePointTemperatureFlash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/BubblePointTemperatureFlash.java index 1fde945f6..de47a4af6 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/BubblePointTemperatureFlash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/BubblePointTemperatureFlash.java @@ -37,11 +37,10 @@ public void run() { double deriv = 0; double funk = 0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - system.getPhases()[1].getComponent(i) - .setx(system.getPhases()[0].getComponent(i).getz()); - system.getPhases()[0].getComponent(i).setx(system.getPhases()[0].getComponent(i).getK() - * system.getPhases()[1].getComponent(i).getx()); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + system.getPhase(1).getComponent(i).setx(system.getPhase(0).getComponent(i).getz()); + system.getPhase(0).getComponent(i).setx( + system.getPhase(0).getComponent(i).getK() * system.getPhase(1).getComponent(i).getx()); } system.setNumberOfPhases(2); do { @@ -51,30 +50,29 @@ public void run() { deriv = 0; ytotal = 0; system.init(2); - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { do { iterations++; - yold = system.getPhases()[0].getComponent(i).getx(); - system.getPhases()[0].getComponent(i) - .setK(system.getPhases()[1].getComponent(i).getFugacityCoefficient() - / system.getPhases()[0].getComponent(i).getFugacityCoefficient()); - system.getPhases()[1].getComponent(i) - .setK(system.getPhases()[0].getComponent(i).getK()); - system.getPhases()[0].getComponent(i) - .setx(system.getPhases()[1].getComponent(i).getx() - * system.getPhases()[1].getComponent(i).getFugacityCoefficient() - / system.getPhases()[0].getComponent(i).getFugacityCoefficient()); - } while ((Math.abs(yold - system.getPhases()[1].getComponent(i).getx()) > 1e-10) + yold = system.getPhase(0).getComponent(i).getx(); + system.getPhase(0).getComponent(i) + .setK(system.getPhase(1).getComponent(i).getFugacityCoefficient() + / system.getPhase(0).getComponent(i).getFugacityCoefficient()); + system.getPhase(1).getComponent(i).setK(system.getPhase(0).getComponent(i).getK()); + system.getPhase(0).getComponent(i) + .setx(system.getPhase(1).getComponent(i).getx() + * system.getPhase(1).getComponent(i).getFugacityCoefficient() + / system.getPhase(0).getComponent(i).getFugacityCoefficient()); + } while ((Math.abs(yold - system.getPhase(1).getComponent(i).getx()) > 1e-10) && (iterations < maxNumberOfIterations)); - ytotal += system.getPhases()[0].getComponent(i).getx(); - funk += system.getPhases()[1].getComponent(i).getx() - * system.getPhases()[1].getComponent(i).getK(); - deriv += system.getPhases()[1].getComponent(i).getx() - * system.getPhases()[1].getComponent(i).getK() - * (system.getPhases()[1].getComponent(i).getdfugdt() - - system.getPhases()[0].getComponent(i).getdfugdt()); + ytotal += system.getPhase(0).getComponent(i).getx(); + funk += + system.getPhase(1).getComponent(i).getx() * system.getPhase(1).getComponent(i).getK(); + deriv += + system.getPhase(1).getComponent(i).getx() * system.getPhase(1).getComponent(i).getK() + * (system.getPhase(1).getComponent(i).getdfugdt() + - system.getPhase(0).getComponent(i).getdfugdt()); } // logger.info("FUNK: " + funk); diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/BubblePointTemperatureNoDer.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/BubblePointTemperatureNoDer.java index 3e7cd91a7..60a8462e0 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/BubblePointTemperatureNoDer.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/BubblePointTemperatureNoDer.java @@ -65,27 +65,26 @@ public void run() { system.getChemicalReactionOperations().solveChemEq(1); } - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - system.getPhases()[1].getComponent(i).setx(system.getPhases()[0].getComponent(i).getz()); - if (system.getPhases()[0].getComponent(i).getIonicCharge() != 0) { - system.getPhases()[0].getComponent(i).setx(1e-40); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + system.getPhase(1).getComponent(i).setx(system.getPhase(0).getComponent(i).getz()); + if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { + system.getPhase(0).getComponent(i).setx(1e-40); } else { - system.getPhases()[0].getComponent(i).setx(system.getPhases()[0].getComponent(i).getK() - * system.getPhases()[1].getComponent(i).getz()); + system.getPhase(0).getComponent(i).setx( + system.getPhase(0).getComponent(i).getK() * system.getPhase(1).getComponent(i).getz()); } } ytotal = 0.0; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - ytotal += system.getPhases()[0].getComponent(i).getx(); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + ytotal += system.getPhase(0).getComponent(i).getx(); } double oldTemp = 10.0; double ktot = 0.0; do { iterations++; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - system.getPhases()[0].getComponent(i) - .setx(system.getPhases()[0].getComponent(i).getx() / ytotal); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + system.getPhase(0).getComponent(i).setx(system.getPhase(0).getComponent(i).getx() / ytotal); } if (system.isChemicalSystem() && (iterations % 2) == 0) { system.getChemicalReactionOperations().solveChemEq(1); @@ -93,28 +92,28 @@ public void run() { system.init(1); oldTemp = system.getTemperature(); ktot = 0.0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { do { - yold = system.getPhases()[0].getComponent(i).getx(); + yold = system.getPhase(0).getComponent(i).getx(); if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { - system.getPhases()[0].getComponent(i).setK(1e-40); + system.getPhase(0).getComponent(i).setK(1e-40); } else { - system.getPhases()[0].getComponent(i).setK( - Math.exp(Math.log(system.getPhases()[1].getComponent(i).getFugacityCoefficient()) - - Math.log(system.getPhases()[0].getComponent(i).getFugacityCoefficient()))); + system.getPhase(0).getComponent(i) + .setK(Math.exp(Math.log(system.getPhase(1).getComponent(i).getFugacityCoefficient()) + - Math.log(system.getPhase(0).getComponent(i).getFugacityCoefficient()))); } - system.getPhases()[1].getComponent(i).setK(system.getPhases()[0].getComponent(i).getK()); - system.getPhases()[0].getComponent(i).setx(system.getPhases()[0].getComponent(i).getK() - * system.getPhases()[1].getComponent(i).getz()); + system.getPhase(1).getComponent(i).setK(system.getPhase(0).getComponent(i).getK()); + system.getPhase(0).getComponent(i).setx(system.getPhase(0).getComponent(i).getK() + * system.getPhase(1).getComponent(i).getz()); // logger.info("y err " + - // Math.abs(system.getPhases()[0].getComponent(i).getx()-yold)); - } while (Math.abs(system.getPhases()[0].getComponent(i).getx() - yold) > 1e-4); + // Math.abs(system.getPhase(0).getComponent(i).getx()-yold)); + } while (Math.abs(system.getPhase(0).getComponent(i).getx() - yold) > 1e-4); - ktot += Math.abs(system.getPhases()[1].getComponent(i).getK() - 1.0); + ktot += Math.abs(system.getPhase(1).getComponent(i).getK() - 1.0); } ytotal = 0.0; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - ytotal += system.getPhases()[0].getComponent(i).getx(); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + ytotal += system.getPhase(0).getComponent(i).getx(); } if (ytotal > 1.2) { ytotal = 1.2; @@ -128,11 +127,11 @@ public void run() { // 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) @@ -144,8 +143,8 @@ public void run() { setSuperCritical(true); } if (system.getPhase(0).getNumberOfComponents() == 1 - && Math.abs(system.getPhases()[1].getComponent(0).getFugacityCoefficient() - / system.getPhases()[0].getComponent(0).getFugacityCoefficient() - 1.0) < 1e-20) { + && Math.abs(system.getPhase(1).getComponent(0).getFugacityCoefficient() + / system.getPhase(0).getComponent(0).getFugacityCoefficient() - 1.0) < 1e-20) { setSuperCritical(true); } } diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/ConstantDutyFlash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/ConstantDutyFlash.java index a98cf1bc3..ddb1ee893 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/ConstantDutyFlash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/ConstantDutyFlash.java @@ -54,11 +54,11 @@ public ConstantDutyFlash() {} */ 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()]; + lnOldOldK = new double[system.getPhase(0).getNumberOfComponents()]; + lnOldK = new double[system.getPhase(0).getNumberOfComponents()]; + lnK = new double[system.getPhase(0).getNumberOfComponents()]; + oldDeltalnK = new double[system.getPhase(0).getNumberOfComponents()]; + deltalnK = new double[system.getPhase(0).getNumberOfComponents()]; } /** {@inheritDoc} */ @@ -79,13 +79,13 @@ public void run() { do { system.init(2); - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - system.getPhases()[0].getComponent(i) - .setK(system.getPhases()[0].getComponent(i).getFugacityCoefficient() - / system.getPhases()[1].getComponent(i).getFugacityCoefficient()); - system.getPhases()[1].getComponent(i) - .setK(system.getPhases()[0].getComponent(i).getFugacityCoefficient() - / system.getPhases()[1].getComponent(i).getFugacityCoefficient()); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + system.getPhase(0).getComponent(i) + .setK(system.getPhase(0).getComponent(i).getFugacityCoefficient() + / system.getPhase(1).getComponent(i).getFugacityCoefficient()); + system.getPhase(1).getComponent(i) + .setK(system.getPhase(0).getComponent(i).getFugacityCoefficient() + / system.getPhase(1).getComponent(i).getFugacityCoefficient()); } system.calc_x_y(); @@ -93,17 +93,17 @@ public void run() { funk = 0e0; deriv = 0e0; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - dkidt = (system.getPhases()[0].getComponent(i).getdfugdt() - - system.getPhases()[1].getComponent(i).getdfugdt()) - * system.getPhases()[0].getComponent(i).getK(); - dxidt = -system.getPhases()[0].getComponent(i).getx() - * system.getPhases()[0].getComponent(i).getx() * 1.0 - / system.getPhases()[0].getComponent(i).getz() * system.getBeta() * dkidt; - dyidt = dkidt * system.getPhases()[0].getComponent(i).getx() - + system.getPhases()[0].getComponent(i).getK() * dxidt; - funk = funk + system.getPhases()[1].getComponent(i).getx() - - system.getPhases()[0].getComponent(i).getx(); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + dkidt = (system.getPhase(0).getComponent(i).getdfugdt() + - system.getPhase(1).getComponent(i).getdfugdt()) + * system.getPhase(0).getComponent(i).getK(); + dxidt = + -system.getPhase(0).getComponent(i).getx() * system.getPhase(0).getComponent(i).getx() + * 1.0 / system.getPhase(0).getComponent(i).getz() * system.getBeta() * dkidt; + dyidt = dkidt * system.getPhase(0).getComponent(i).getx() + + system.getPhase(0).getComponent(i).getK() * dxidt; + funk = funk + system.getPhase(1).getComponent(i).getx() + - system.getPhase(0).getComponent(i).getx(); deriv = deriv + dyidt - dxidt; } diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/ConstantDutyPressureFlash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/ConstantDutyPressureFlash.java index 16820568d..d7ff20106 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/ConstantDutyPressureFlash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/ConstantDutyPressureFlash.java @@ -46,12 +46,11 @@ public void run() { // system.setBeta(beta+0.65); system.init(2); iterations++; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - system.getPhases()[0].getComponent(i) - .setK(system.getPhases()[1].getComponent(i).getFugacityCoefficient() - / system.getPhases()[0].getComponent(i).getFugacityCoefficient()); - system.getPhases()[1].getComponent(i) - .setK(system.getPhases()[0].getComponent(i).getK()); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + system.getPhase(0).getComponent(i) + .setK(system.getPhase(1).getComponent(i).getFugacityCoefficient() + / system.getPhase(0).getComponent(i).getFugacityCoefficient()); + system.getPhase(1).getComponent(i).setK(system.getPhase(0).getComponent(i).getK()); } system.calc_x_y_nonorm(); @@ -59,17 +58,17 @@ public void run() { funk = 0.0; deriv = 0.0; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - dkidp = (system.getPhases()[1].getComponent(i).getdfugdp() - - system.getPhases()[0].getComponent(i).getdfugdp()) - * system.getPhases()[1].getComponent(i).getK(); - dxidp = -system.getPhases()[1].getComponent(i).getz() * system.getBeta() * dkidp - / Math.pow(1.0 - system.getBeta() - + system.getBeta() * system.getPhases()[1].getComponent(i).getK(), 2.0); - dyidp = dkidp * system.getPhases()[1].getComponent(i).getx() - + system.getPhases()[1].getComponent(i).getK() * dxidp; - funk += system.getPhases()[0].getComponent(i).getx() - - system.getPhases()[1].getComponent(i).getx(); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + dkidp = (system.getPhase(1).getComponent(i).getdfugdp() + - system.getPhase(0).getComponent(i).getdfugdp()) + * system.getPhase(1).getComponent(i).getK(); + dxidp = -system.getPhase(1).getComponent(i).getz() * system.getBeta() * dkidp / Math.pow( + 1.0 - system.getBeta() + system.getBeta() * system.getPhase(1).getComponent(i).getK(), + 2.0); + dyidp = dkidp * system.getPhase(1).getComponent(i).getx() + + system.getPhase(1).getComponent(i).getK() * dxidp; + funk += + system.getPhase(0).getComponent(i).getx() - system.getPhase(1).getComponent(i).getx(); deriv += dyidp - dxidp; } diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/ConstantDutyTemperatureFlash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/ConstantDutyTemperatureFlash.java index 5118154ed..c111c62e9 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/ConstantDutyTemperatureFlash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/ConstantDutyTemperatureFlash.java @@ -18,8 +18,7 @@ public class ConstantDutyTemperatureFlash extends ConstantDutyFlash { * Constructor for constantDutyTemperatureFlash. *

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

@@ -51,13 +50,13 @@ public void run() { // system.setBeta(beta+0.65); system.init(2); - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - system.getPhases()[0].getComponent(i) - .setK(system.getPhases()[0].getComponent(i).getFugacityCoefficient() - / system.getPhases()[1].getComponent(i).getFugacityCoefficient()); - system.getPhases()[1].getComponent(i) - .setK(system.getPhases()[0].getComponent(i).getFugacityCoefficient() - / system.getPhases()[1].getComponent(i).getFugacityCoefficient()); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + system.getPhase(0).getComponent(i) + .setK(system.getPhase(0).getComponent(i).getFugacityCoefficient() + / system.getPhase(1).getComponent(i).getFugacityCoefficient()); + system.getPhase(1).getComponent(i) + .setK(system.getPhase(0).getComponent(i).getFugacityCoefficient() + / system.getPhase(1).getComponent(i).getFugacityCoefficient()); } system.calc_x_y_nonorm(); @@ -65,19 +64,19 @@ public void run() { funk = 0e0; deriv = 0e0; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - dkidt = (system.getPhases()[0].getComponent(i).getdfugdt() - - system.getPhases()[1].getComponent(i).getdfugdt()) - * system.getPhases()[0].getComponent(i).getK(); - // dxidt=-system.getPhases()[0].getComponent(i).getx() * - // system.getPhases()[0].getComponent(i).getx()*1.0/system.getPhases()[0].getComponent(i).getz()*system.getBeta()*dkidt; - dxidt = -system.getPhases()[0].getComponent(i).getz() * system.getBeta() * dkidt - / Math.pow(1.0 - system.getBeta() - + system.getBeta() * system.getPhases()[0].getComponent(i).getK(), 2); - dyidt = dkidt * system.getPhases()[0].getComponent(i).getx() - + system.getPhases()[0].getComponent(i).getK() * dxidt; - funk = funk + system.getPhases()[1].getComponent(i).getx() - - system.getPhases()[0].getComponent(i).getx(); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + dkidt = (system.getPhase(0).getComponent(i).getdfugdt() + - system.getPhase(1).getComponent(i).getdfugdt()) + * system.getPhase(0).getComponent(i).getK(); + // dxidt=-system.getPhase(0).getComponent(i).getx() * + // system.getPhase(0).getComponent(i).getx()*1.0/system.getPhase(0).getComponent(i).getz()*system.getBeta()*dkidt; + dxidt = -system.getPhase(0).getComponent(i).getz() * system.getBeta() * dkidt / Math.pow( + 1.0 - system.getBeta() + system.getBeta() * system.getPhase(0).getComponent(i).getK(), + 2); + dyidt = dkidt * system.getPhase(0).getComponent(i).getx() + + system.getPhase(0).getComponent(i).getK() * dxidt; + funk = funk + system.getPhase(1).getComponent(i).getx() + - system.getPhase(0).getComponent(i).getx(); deriv = deriv + dyidt - dxidt; } diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/CricondebarFlash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/CricondebarFlash.java index 4a3b7b599..7698184a6 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/CricondebarFlash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/CricondebarFlash.java @@ -44,21 +44,19 @@ public CricondebarFlash(SystemInterface system) { */ public double calcx() { double xtotal = 0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - system.getPhases()[0].getComponent(i) - .setK(Math.exp(system.getPhases()[1].getComponent(i).getLogFugacityCoefficient() - - system.getPhases()[0].getComponent(i).getLogFugacityCoefficient())); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + system.getPhase(0).getComponent(i) + .setK(Math.exp(system.getPhase(1).getComponent(i).getLogFugacityCoefficient() + - system.getPhase(0).getComponent(i).getLogFugacityCoefficient())); - system.getPhases()[1].getComponent(i) - .setK(system.getPhases()[0].getComponent(i).getK()); - system.getPhases()[1].getComponent(i) - .setx(1.0 / system.getPhases()[0].getComponent(i).getK() - * system.getPhases()[1].getComponent(i).getz()); - // ktot += Math.abs(system.getPhases()[1].getComponent(i).getK() - 1.0); + system.getPhase(1).getComponent(i).setK(system.getPhase(0).getComponent(i).getK()); + system.getPhase(1).getComponent(i).setx(1.0 / system.getPhase(0).getComponent(i).getK() + * system.getPhase(1).getComponent(i).getz()); + // ktot += Math.abs(system.getPhase(1).getComponent(i).getK() - 1.0); } xtotal = 0.0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - xtotal += system.getPhases()[1].getComponent(i).getx(); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + xtotal += system.getPhase(1).getComponent(i).getx(); } return xtotal; } @@ -249,12 +247,12 @@ public void run() { public void setfvec() { double sumxx = 0; for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - sumxx += system.getPhases()[1].getComponent(i).getx(); + sumxx += system.getPhase(1).getComponent(i).getx(); fvec.set(i, 0, - Math.log(system.getPhases()[0].getComponent(i).getFugacityCoefficient() - * system.getPhases()[0].getComponent(i).getz() * system.getPressure()) - - Math.log(system.getPhases()[1].getComponent(i).getFugacityCoefficient() - * system.getPhases()[1].getComponent(i).getx() * system.getPressure())); + Math.log(system.getPhase(0).getComponent(i).getFugacityCoefficient() + * system.getPhase(0).getComponent(i).getz() * system.getPressure()) + - Math.log(system.getPhase(1).getComponent(i).getFugacityCoefficient() + * system.getPhase(1).getComponent(i).getx() * system.getPressure())); } fvec.set(system.getPhase(0).getNumberOfComponents(), 0, 1.0 - sumxx); // logger.info("sumx" + sumxx); @@ -274,8 +272,8 @@ 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 - tempJ = -dij * 1.0 / system.getPhases()[1].getComponent(i).getx() - - system.getPhases()[1].getComponent(i).getdfugdx(j); + tempJ = -dij * 1.0 / system.getPhase(1).getComponent(i).getx() + - system.getPhase(1).getComponent(i).getdfugdx(j); Jac.set(i, j, tempJ); } } @@ -285,8 +283,8 @@ public void setJac() { } for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { Jac.set(i, system.getPhase(0).getNumberOfComponents(), - system.getPhases()[0].getComponent(i).getdfugdp() - - system.getPhases()[1].getComponent(i).getdfugdp()); + system.getPhase(0).getComponent(i).getdfugdp() + - system.getPhase(1).getComponent(i).getdfugdp()); } } diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/CricondenBarTemp.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/CricondenBarTemp.java index 559502e8b..0af7a39e8 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/CricondenBarTemp.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/CricondenBarTemp.java @@ -72,10 +72,10 @@ public CricondenBarTemp(SystemInterface system, int numberOfPhases, int numberOf public void setfvec() { for (int i = 0; i < numberOfComponents; i++) { fvec.set(i, 0, - Math.log(system.getPhases()[0].getComponent(i).getFugacityCoefficient() - * system.getPhases()[0].getComponent(i).getx() * system.getPressure()) - - Math.log(system.getPhases()[1].getComponent(i).getFugacityCoefficient() - * system.getPhases()[1].getComponent(i).getx() * system.getPressure())); + Math.log(system.getPhase(0).getComponent(i).getFugacityCoefficient() + * system.getPhase(0).getComponent(i).getx() * system.getPressure()) + - Math.log(system.getPhase(1).getComponent(i).getFugacityCoefficient() + * system.getPhase(1).getComponent(i).getx() * system.getPressure())); } } @@ -93,11 +93,10 @@ public void setJac() { 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].getComponent(i).getx() - 1.0 - + system.getPhases()[0].getComponent(i).getdfugdx(j)) - + 1.0 / (1.0 - system.getBeta()) - * (dij / system.getPhases()[1].getComponent(i).getx() - 1.0 - + system.getPhases()[1].getComponent(i).getdfugdx(j)); + * (dij / system.getPhase(0).getComponent(i).getx() - 1.0 + + system.getPhase(0).getComponent(i).getdfugdx(j)) + + 1.0 / (1.0 - system.getBeta()) * (dij / system.getPhase(1).getComponent(i).getx() + - 1.0 + system.getPhase(1).getComponent(i).getdfugdx(j)); Jac.set(i, j, tempJ); } } @@ -110,7 +109,7 @@ public void setJac() { */ public void setu() { for (int i = 0; i < numberOfComponents; i++) { - u.set(i, 0, system.getBeta() * system.getPhases()[0].getComponent(i).getx()); + u.set(i, 0, system.getBeta() * system.getPhase(0).getComponent(i).getx()); } } @@ -128,14 +127,12 @@ public void init() { system.setBeta(temp); for (int i = 0; i < numberOfComponents; i++) { - system.getPhases()[0].getComponent(i).setx(u.get(i, 0) / system.getBeta()); - system.getPhases()[1].getComponent(i) - .setx((system.getPhases()[0].getComponent(i).getz() - u.get(i, 0)) - / (1.0 - system.getBeta())); - system.getPhases()[0].getComponent(i).setK(system.getPhases()[0].getComponent(i).getx() - / system.getPhases()[1].getComponent(i).getx()); - system.getPhases()[1].getComponent(i) - .setK(system.getPhases()[0].getComponent(i).getK()); + system.getPhase(0).getComponent(i).setx(u.get(i, 0) / system.getBeta()); + system.getPhase(1).getComponent(i).setx( + (system.getPhase(0).getComponent(i).getz() - u.get(i, 0)) / (1.0 - system.getBeta())); + system.getPhase(0).getComponent(i).setK( + system.getPhase(0).getComponent(i).getx() / system.getPhase(1).getComponent(i).getx()); + system.getPhase(1).getComponent(i).setK(system.getPhase(0).getComponent(i).getK()); } system.init(3); diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/CricondenBarTemp1.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/CricondenBarTemp1.java index 3f577362d..fa0ecebc8 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/CricondenBarTemp1.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/CricondenBarTemp1.java @@ -81,8 +81,8 @@ public void setfvec() { fvec.set(i, 0, Math.log(system.getPhase(0).getComponent(i).getFugacityCoefficient() * system.getPhase(0).getComponent(i).getz() * system.getPressure()) - - Math.log(system.getPhases()[1].getComponent(i).getFugacityCoefficient() - * system.getPhases()[1].getComponent(i).getx() * system.getPressure())); + - Math.log(system.getPhase(1).getComponent(i).getFugacityCoefficient() + * system.getPhase(1).getComponent(i).getx() * system.getPressure())); } fvec.set(numberOfComponents, 0, 1.0 - xtot); fvec.set(numberOfComponents + 1, 0, dQdT); @@ -105,11 +105,10 @@ public void setJac() { 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].getComponent(i).getx() - 1.0 - + system.getPhases()[0].getComponent(i).getdfugdx(j)) - + 1.0 / (1.0 - system.getBeta()) - * (dij / system.getPhases()[1].getComponent(i).getx() - 1.0 - + system.getPhases()[1].getComponent(i).getdfugdx(j)); + * (dij / system.getPhase(0).getComponent(i).getx() - 1.0 + + system.getPhase(0).getComponent(i).getdfugdx(j)) + + 1.0 / (1.0 - system.getBeta()) * (dij / system.getPhase(1).getComponent(i).getx() + - 1.0 + system.getPhase(1).getComponent(i).getdfugdx(j)); Jac.set(i, j, tempJ); } } @@ -122,7 +121,7 @@ public void setJac() { */ public void setu() { for (int i = 0; i < numberOfComponents; i++) { - u.set(i, 0, system.getBeta() * system.getPhases()[0].getComponent(i).getx()); + u.set(i, 0, system.getBeta() * system.getPhase(0).getComponent(i).getx()); } } @@ -140,14 +139,12 @@ public void init() { system.setBeta(temp); for (int i = 0; i < numberOfComponents; i++) { - system.getPhases()[0].getComponent(i).setx(u.get(i, 0) / system.getBeta()); - system.getPhases()[1].getComponent(i) - .setx((system.getPhases()[0].getComponent(i).getz() - u.get(i, 0)) - / (1.0 - system.getBeta())); - system.getPhases()[0].getComponent(i).setK(system.getPhases()[0].getComponent(i).getx() - / system.getPhases()[1].getComponent(i).getx()); - system.getPhases()[1].getComponent(i) - .setK(system.getPhases()[0].getComponent(i).getK()); + system.getPhase(0).getComponent(i).setx(u.get(i, 0) / system.getBeta()); + system.getPhase(1).getComponent(i).setx( + (system.getPhase(0).getComponent(i).getz() - u.get(i, 0)) / (1.0 - system.getBeta())); + system.getPhase(0).getComponent(i).setK( + system.getPhase(0).getComponent(i).getx() / system.getPhase(1).getComponent(i).getx()); + system.getPhase(1).getComponent(i).setK(system.getPhase(0).getComponent(i).getK()); } system.init(3); diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/DewPointPressureFlash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/DewPointPressureFlash.java index 5cd619b54..ffa857d6b 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/DewPointPressureFlash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/DewPointPressureFlash.java @@ -47,51 +47,48 @@ public void run() { system.getChemicalReactionOperations().solveChemEq(1); } - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - system.getPhases()[0].getComponent(i).setx(system.getPhases()[0].getComponent(i).getz()); - if (system.getPhases()[0].getComponent(i).getIonicCharge() != 0) { - system.getPhases()[0].getComponent(i).setx(1e-40); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + system.getPhase(0).getComponent(i).setx(system.getPhase(0).getComponent(i).getz()); + if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { + system.getPhase(0).getComponent(i).setx(1e-40); } else { - system.getPhases()[1].getComponent(i) - .setx(1.0 / system.getPhases()[0].getComponent(i).getK() - * system.getPhases()[1].getComponent(i).getz()); + system.getPhase(1).getComponent(i).setx(1.0 / system.getPhase(0).getComponent(i).getK() + * system.getPhase(1).getComponent(i).getz()); } } - // system.setPressure(system.getPhases()[0].getAntoineVaporPressure(system.getTemperature())); + // system.setPressure(system.getPhase(0).getAntoineVaporPressure(system.getTemperature())); xtotal = 0.0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - xtotal += system.getPhases()[1].getComponent(i).getx(); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + xtotal += system.getPhase(1).getComponent(i).getx(); } double ktot = 0.0; do { iterations++; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - system.getPhases()[1].getComponent(i) - .setx(system.getPhases()[1].getComponent(i).getx() / xtotal); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + system.getPhase(1).getComponent(i).setx(system.getPhase(1).getComponent(i).getx() / xtotal); } system.init(1); ktot = 0.0; oldPres = system.getPressure(); - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { do { - xold = system.getPhases()[1].getComponent(i).getx(); + xold = system.getPhase(1).getComponent(i).getx(); if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { - system.getPhases()[0].getComponent(i).setK(1e-40); + system.getPhase(0).getComponent(i).setK(1e-40); } else { - system.getPhases()[0].getComponent(i).setK( - Math.exp(Math.log(system.getPhases()[1].getComponent(i).getFugacityCoefficient()) - - Math.log(system.getPhases()[0].getComponent(i).getFugacityCoefficient()))); + system.getPhase(0).getComponent(i) + .setK(Math.exp(Math.log(system.getPhase(1).getComponent(i).getFugacityCoefficient()) + - Math.log(system.getPhase(0).getComponent(i).getFugacityCoefficient()))); } - system.getPhases()[1].getComponent(i).setK(system.getPhases()[0].getComponent(i).getK()); - system.getPhases()[1].getComponent(i) - .setx(1.0 / system.getPhases()[0].getComponent(i).getK() - * system.getPhases()[1].getComponent(i).getz()); - } while (Math.abs(system.getPhases()[1].getComponent(i).getx() - xold) > 1e-4); - ktot += Math.abs(system.getPhases()[1].getComponent(i).getK() - 1.0); + system.getPhase(1).getComponent(i).setK(system.getPhase(0).getComponent(i).getK()); + system.getPhase(1).getComponent(i).setx(1.0 / system.getPhase(0).getComponent(i).getK() + * system.getPhase(1).getComponent(i).getz()); + } while (Math.abs(system.getPhase(1).getComponent(i).getx() - xold) > 1e-4); + ktot += Math.abs(system.getPhase(1).getComponent(i).getK() - 1.0); } xtotal = 0.0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - xtotal += system.getPhases()[1].getComponent(i).getx(); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + xtotal += system.getPhase(1).getComponent(i).getx(); } system.setPressure(oldPres + 0.1 * (system.getPressure() / xtotal - oldPres)); // System.out.println("iter " + iterations + " pressure " @@ -100,7 +97,7 @@ public void run() { || Math.abs(oldPres - system.getPressure()) / oldPres > 1e-9) && (iterations < maxNumberOfIterations)); // System.out.println("iter " + iterations + " XTOT " +xtotal + " k " - // +system.getPhases()[1].getComponent(0).getK()); + // +system.getPhase(1).getComponent(0).getK()); if (Math.abs(xtotal - 1.0) >= 1e-5 || ktot < 1e-3 && system.getPhase(0).getNumberOfComponents() > 1) { setSuperCritical(true); diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/DewPointTemperatureFlash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/DewPointTemperatureFlash.java index 19b2c3046..08ea040c0 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/DewPointTemperatureFlash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/DewPointTemperatureFlash.java @@ -49,61 +49,56 @@ public void run() { system.getChemicalReactionOperations().solveChemEq(1); } - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - system.getPhases()[0].getComponent(i) - .setx(system.getPhases()[0].getComponent(i).getz()); - if (system.getPhases()[0].getComponent(i).getIonicCharge() != 0) { - system.getPhases()[0].getComponent(i).setx(1e-40); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + system.getPhase(0).getComponent(i).setx(system.getPhase(0).getComponent(i).getz()); + if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { + system.getPhase(0).getComponent(i).setx(1e-40); } else { - if (system.getPhases()[1].getComponent(i).getName().equals("water")) { - system.getPhases()[1].getComponent(i).setx(1.0); - } else if (system.getPhases()[1].hasComponent("water")) { - system.getPhases()[1].getComponent(i).setx(1.0e-10); + if (system.getPhase(1).getComponent(i).getName().equals("water")) { + system.getPhase(1).getComponent(i).setx(1.0); + } else if (system.getPhase(1).hasComponent("water")) { + system.getPhase(1).getComponent(i).setx(1.0e-10); } else { - system.getPhases()[1].getComponent(i) - .setx(1.0 / system.getPhases()[0].getComponent(i).getK() - * system.getPhases()[1].getComponent(i).getz()); + system.getPhase(1).getComponent(i).setx(1.0 / system.getPhase(0).getComponent(i).getK() + * system.getPhase(1).getComponent(i).getz()); } } } - // system.setPressure(system.getPhases()[0].getAntoineVaporPressure(system.getTemperature())); + // system.setPressure(system.getPhase(0).getAntoineVaporPressure(system.getTemperature())); xtotal = 0.0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - xtotal += system.getPhases()[1].getComponent(i).getx(); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + xtotal += system.getPhase(1).getComponent(i).getx(); } double ktot = 0.0; double oldTemperature = 0.0; double fold = 0; do { - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - system.getPhases()[1].getComponent(i) - .setx(system.getPhases()[1].getComponent(i).getx() / xtotal); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + system.getPhase(1).getComponent(i).setx(system.getPhase(1).getComponent(i).getx() / xtotal); } system.init(1); oldTemp = system.getTemperature(); iterations++; ktot = 0.0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { do { - xold = system.getPhases()[1].getComponent(i).getx(); + xold = system.getPhase(1).getComponent(i).getx(); if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { - system.getPhases()[0].getComponent(i).setK(1e-40); + system.getPhase(0).getComponent(i).setK(1e-40); } else { - system.getPhases()[0].getComponent(i) - .setK(Math.exp(system.getPhases()[1].getComponent(i).getLogFugacityCoefficient() - - system.getPhases()[0].getComponent(i).getLogFugacityCoefficient())); + system.getPhase(0).getComponent(i) + .setK(Math.exp(system.getPhase(1).getComponent(i).getLogFugacityCoefficient() + - system.getPhase(0).getComponent(i).getLogFugacityCoefficient())); } - system.getPhases()[1].getComponent(i) - .setK(system.getPhases()[0].getComponent(i).getK()); - system.getPhases()[1].getComponent(i) - .setx(1.0 / system.getPhases()[0].getComponent(i).getK() - * system.getPhases()[1].getComponent(i).getz()); - } while (Math.abs(system.getPhases()[1].getComponent(i).getx() - xold) > 1e-6); - ktot += Math.abs(system.getPhases()[1].getComponent(i).getK() - 1.0); + system.getPhase(1).getComponent(i).setK(system.getPhase(0).getComponent(i).getK()); + system.getPhase(1).getComponent(i).setx(1.0 / system.getPhase(0).getComponent(i).getK() + * system.getPhase(1).getComponent(i).getz()); + } while (Math.abs(system.getPhase(1).getComponent(i).getx() - xold) > 1e-6); + ktot += Math.abs(system.getPhase(1).getComponent(i).getK() - 1.0); } xtotal = 0.0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - xtotal += system.getPhases()[1].getComponent(i).getx(); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + xtotal += system.getPhase(1).getComponent(i).getx(); } double f = xtotal - 1.0; @@ -122,8 +117,8 @@ public void run() { .setTemperature(system.getTemperature() - iterations / (iterations + 10.0) * f / dfdT); } // System.out.println("temperature " + system.getTemperature()); - // for (int i=0;i 1e-10) || Math.abs(oldTemp - system.getTemperature()) / oldTemp > 1e-8) diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/DewPointTemperatureFlashDer.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/DewPointTemperatureFlashDer.java index 2eb754f60..81233aaf5 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/DewPointTemperatureFlashDer.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/DewPointTemperatureFlashDer.java @@ -45,32 +45,29 @@ public void run() { system.getChemicalReactionOperations().solveChemEq(1); } - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - system.getPhases()[0].getComponent(i) - .setx(system.getPhases()[0].getComponent(i).getz()); - if (system.getPhases()[0].getComponent(i).getIonicCharge() != 0) { - system.getPhases()[0].getComponent(i).setx(1e-40); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + system.getPhase(0).getComponent(i).setx(system.getPhase(0).getComponent(i).getz()); + if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { + system.getPhase(0).getComponent(i).setx(1e-40); } else { - if (system.getPhases()[1].getComponent(i).getName().equals("water")) { - system.getPhases()[1].getComponent(i).setx(1.0); - } else if (system.getPhases()[1].hasComponent("water")) { - system.getPhases()[1].getComponent(i).setx(1.0e-10); + if (system.getPhase(1).getComponent(i).getName().equals("water")) { + system.getPhase(1).getComponent(i).setx(1.0); + } else if (system.getPhase(1).hasComponent("water")) { + system.getPhase(1).getComponent(i).setx(1.0e-10); } else { - system.getPhases()[1].getComponent(i) - .setx(1.0 / system.getPhases()[0].getComponent(i).getK() - * system.getPhases()[1].getComponent(i).getz()); + system.getPhase(1).getComponent(i).setx(1.0 / system.getPhase(0).getComponent(i).getK() + * system.getPhase(1).getComponent(i).getz()); } } } - // system.setPressure(system.getPhases()[0].getAntoineVaporPressure(system.getTemperature())); + // system.setPressure(system.getPhase(0).getAntoineVaporPressure(system.getTemperature())); double xtotal = 0.0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - xtotal += system.getPhases()[1].getComponent(i).getx(); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + xtotal += system.getPhase(1).getComponent(i).getx(); } - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - system.getPhases()[1].getComponent(i) - .setx(system.getPhases()[1].getComponent(i).getx() / xtotal); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + system.getPhase(1).getComponent(i).setx(system.getPhase(1).getComponent(i).getx() / xtotal); } int iterations = 0; @@ -83,13 +80,13 @@ public void run() { xtotal = 0.0; double dfdT = 0.0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - xtotal += 1.0 / system.getPhases()[0].getComponent(i).getK() - * system.getPhases()[1].getComponent(i).getz(); - dfdT -= 1.0 / system.getPhases()[0].getComponent(i).getK() - * system.getPhases()[1].getComponent(i).getz() - * (system.getPhases()[1].getComponent(i).getdfugdt() - - system.getPhases()[0].getComponent(i).getdfugdt()); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + xtotal += 1.0 / system.getPhase(0).getComponent(i).getK() + * system.getPhase(1).getComponent(i).getz(); + dfdT -= 1.0 / system.getPhase(0).getComponent(i).getK() + * system.getPhase(1).getComponent(i).getz() + * (system.getPhase(1).getComponent(i).getdfugdt() + - system.getPhase(0).getComponent(i).getdfugdt()); } double f = xtotal - 1.0; // fold = f; @@ -109,31 +106,28 @@ public void run() { system.init(1); ktot = 0.0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { - system.getPhases()[0].getComponent(i).setK(1e-40); + system.getPhase(0).getComponent(i).setK(1e-40); } else { - system.getPhases()[0].getComponent(i) - .setK(Math.exp(system.getPhases()[1].getComponent(i).getLogFugacityCoefficient() - - system.getPhases()[0].getComponent(i).getLogFugacityCoefficient())); + system.getPhase(0).getComponent(i) + .setK(Math.exp(system.getPhase(1).getComponent(i).getLogFugacityCoefficient() + - system.getPhase(0).getComponent(i).getLogFugacityCoefficient())); } - system.getPhases()[1].getComponent(i) - .setK(system.getPhases()[0].getComponent(i).getK()); - system.getPhases()[1].getComponent(i) - .setx(1.0 / system.getPhases()[0].getComponent(i).getK() - * system.getPhases()[1].getComponent(i).getz()); - ktot += Math.abs(system.getPhases()[1].getComponent(i).getK() - 1.0); + system.getPhase(1).getComponent(i).setK(system.getPhase(0).getComponent(i).getK()); + system.getPhase(1).getComponent(i).setx(1.0 / system.getPhase(0).getComponent(i).getK() + * system.getPhase(1).getComponent(i).getz()); + ktot += Math.abs(system.getPhase(1).getComponent(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].getComponent(i).getx(); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + xtotal += system.getPhase(1).getComponent(i).getx(); } // System.out.println("xtotal " + xtotal); - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - system.getPhases()[1].getComponent(i) - .setx(system.getPhases()[1].getComponent(i).getx() / xtotal); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + system.getPhase(1).getComponent(i).setx(system.getPhase(1).getComponent(i).getx() / xtotal); } } while (((Math.abs(xtotal - 1.0) > 1e-6) || Math.abs(oldTemp - system.getTemperature()) / oldTemp > 1e-4) diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FreezeOut.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FreezeOut.java index fcf7de0d1..d885b6782 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FreezeOut.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FreezeOut.java @@ -71,7 +71,7 @@ public void run() { for (int k = 0; k < testSystem.getPhase(0).getNumberOfComponents(); k++) { FCompNames[k] = testSystem.getPhase(0).getComponent(k).getComponentName(); if (testSystem.getPhase(0).getComponent(k).doSolidCheck()) { - trpTemp = testSystem.getPhases()[0].getComponent(k).getTriplePointTemperature(); + trpTemp = testSystem.getPhase(0).getComponent(k).getTriplePointTemperature(); if (noFreezeFlash) { testSystem.setTemperature(trpTemp); logger.info("Starting at Triple point temperature " @@ -94,7 +94,7 @@ public void run() { iterations = 0; half = false; T2high = trpTemp + 0.1; - if (Math.abs(testSystem.getPhases()[0].getComponent(k).getHsub()) < 1) { + if (Math.abs(testSystem.getPhase(0).getComponent(k).getHsub()) < 1) { CCequation = false; } do { @@ -198,7 +198,7 @@ public void run() { /** {@inheritDoc} */ @Override public void printToFile(String name) { - for (int n = 0; n < system.getPhases()[0].getNumberOfComponents(); n++) { + for (int n = 0; n < system.getPhase(0).getNumberOfComponents(); n++) { name = name + "_" + system.getPhase(0).getComponent(n).getComponentName(); } @@ -208,11 +208,11 @@ public void printToFile(String name) { pr_writer.println("name,freezeT,freezeP,z,iterations"); pr_writer.flush(); - for (int k = 0; k < system.getPhases()[0].getNumberOfComponents(); k++) { + for (int k = 0; k < system.getPhase(0).getNumberOfComponents(); k++) { // print line to output file pr_writer.println(FCompNames[k] + "," + java.lang.Double.toString(FCompTemp[k]) + "," + system.getPressure() + "," - + java.lang.Double.toString(system.getPhases()[0].getComponent(k).getz())); + + java.lang.Double.toString(system.getPhase(0).getComponent(k).getz())); pr_writer.flush(); } } catch (SecurityException ex) { diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FreezingPointTemperatureFlash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FreezingPointTemperatureFlash.java index a75ef13dd..4c23e4f64 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FreezingPointTemperatureFlash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FreezingPointTemperatureFlash.java @@ -63,13 +63,13 @@ public double calcFunc() { // double deriv = 0, funkOld = 0; double funk = 0; double SolidFugCoeff = 0.0; - int numbComponents = system.getPhases()[0].getNumberOfComponents(); + int numbComponents = system.getPhase(0).getNumberOfComponents(); for (int k = 0; k < numbComponents; k++) { // logger.info("Checking all the components " + k); if (system.getPhase(0).getComponent(k).doSolidCheck()) { ops.TPflash(false); - SolidFugCoeff = system.getPhases()[3].getComponent(k).fugcoef(system.getPhases()[3]); + SolidFugCoeff = system.getPhase(3).getComponent(k).fugcoef(system.getPhase(3)); funk = system.getPhase(0).getComponent(k).getz(); for (int i = 0; i < system.getNumberOfPhases(); i++) { funk -= system.getPhase(i).getBeta() * SolidFugCoeff @@ -94,7 +94,7 @@ public void run() { double oldTemperature = 0.0; double newTemp = 0.0; double SolidFugCoeff = 0.0; - int numbComponents = system.getPhases()[0].getNumberOfComponents(); + int numbComponents = system.getPhase(0).getNumberOfComponents(); String[] FCompNames = new String[numbComponents]; double[] FCompTemp = new double[numbComponents]; boolean SolidForms = false; @@ -120,7 +120,7 @@ public void run() { iterations++; // oldPhaseType = system.getPhase(0).getType(); ops.TPflash(false); - SolidFugCoeff = system.getPhases()[3].getComponent(k).fugcoef(system.getPhases()[3]); + SolidFugCoeff = system.getPhase(3).getComponent(k).fugcoef(system.getPhase(3)); funk = system.getPhase(0).getComponent(k).getz(); for (int i = 0; i < system.getNumberOfPhases(); i++) { funk -= system.getPhase(i).getBeta() * SolidFugCoeff @@ -172,7 +172,7 @@ public void run() { * @param FCompTemp an array of type double */ public void printToFile(String name, String[] FCompNames, double[] FCompTemp) { - for (int n = 0; n < system.getPhases()[0].getNumberOfComponents(); n++) { + for (int n = 0; n < system.getPhase(0).getNumberOfComponents(); n++) { name = name + "_" + system.getPhase(0).getComponent(n).getComponentName(); } @@ -182,11 +182,11 @@ public void printToFile(String name, String[] FCompNames, double[] FCompTemp) { pr_writer.println("name,freezeT,freezeP,z,iterations"); pr_writer.flush(); - for (int k = 0; k < system.getPhases()[0].getNumberOfComponents(); k++) { + for (int k = 0; k < system.getPhase(0).getNumberOfComponents(); k++) { // print line to output file pr_writer.println(FCompNames[k] + "," + java.lang.Double.toString(FCompTemp[k]) + "," + system.getPressure() + "," - + java.lang.Double.toString(system.getPhases()[0].getComponent(k).getz()) + "," + + java.lang.Double.toString(system.getPhase(0).getComponent(k).getz()) + "," + Niterations); pr_writer.flush(); } diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FreezingPointTemperatureFlashOld.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FreezingPointTemperatureFlashOld.java index 3e53d6bf5..8a9b10438 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FreezingPointTemperatureFlashOld.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FreezingPointTemperatureFlashOld.java @@ -42,11 +42,11 @@ public void run() { double maxTemperature = 0; double minTemperature = 1e6; double oldTemperature = 0.0; - for (int k = 0; k < system.getPhases()[0].getNumberOfComponents(); k++) { + for (int k = 0; k < system.getPhase(0).getNumberOfComponents(); k++) { if (system.getPhase(3).getComponent(k).fugcoef(system.getPhase(3)) < 9e4 && system.getPhase(3).getComponent(k).doSolidCheck()) { // checks if solid can be formed from component k - system.setTemperature(system.getPhases()[0].getComponent(k).getMeltingPointTemperature()); + system.setTemperature(system.getPhase(0).getComponent(k).getMeltingPointTemperature()); system.init(0); system.init(1); iterations = 0; @@ -58,19 +58,19 @@ public void run() { ops.TPflash(); system.getPhase(3).getComponent(k).fugcoef(system.getPhase(3)); - funk = system.getPhases()[0].getComponent(k).getz(); + funk = system.getPhase(0).getComponent(k).getz(); logger.info("phase " + system.getNumberOfPhases()); for (int i = 0; i < system.getNumberOfPhases(); i++) { - funk -= system.getPhases()[i].getBeta() - * system.getPhases()[3].getComponent(k).getFugacityCoefficient() - / system.getPhases()[i].getComponent(k).getFugacityCoefficient(); - deriv -= 0.01 * system.getPhases()[i].getBeta() - * (system.getPhases()[3].getComponent(k).getFugacityCoefficient() - * Math.exp(system.getPhases()[i].getComponent(k).getdfugdt()) * -1.0 - / Math.pow(system.getPhases()[i].getComponent(k).getFugacityCoefficient(), 2.0) - + Math.exp(system.getPhases()[3].getComponent(k).getdfugdt()) - / system.getPhases()[i].getComponent(k).getFugacityCoefficient()); + funk -= system.getPhase(i).getBeta() + * system.getPhase(3).getComponent(k).getFugacityCoefficient() + / system.getPhase(i).getComponent(k).getFugacityCoefficient(); + deriv -= 0.01 * system.getPhase(i).getBeta() + * (system.getPhase(3).getComponent(k).getFugacityCoefficient() + * Math.exp(system.getPhase(i).getComponent(k).getdfugdt()) * -1.0 + / Math.pow(system.getPhase(i).getComponent(k).getFugacityCoefficient(), 2.0) + + Math.exp(system.getPhase(3).getComponent(k).getdfugdt()) + / system.getPhase(i).getComponent(k).getFugacityCoefficient()); } if (iterations >= 2) { deriv = -(funk - funkOld) / (system.getTemperature() - oldTemperature); diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FreezingPointTemperatureFlashTR.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FreezingPointTemperatureFlashTR.java index ccc1cfd2c..fe19af74e 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FreezingPointTemperatureFlashTR.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FreezingPointTemperatureFlashTR.java @@ -92,7 +92,7 @@ public void run() { double soldens = 0.0; double trpTemp = 0.0; - // for(int k=0;k= 2) { deriv = -(funk - funkOld) / (system.getTemperature() - oldTemperature); @@ -191,8 +192,8 @@ public void run() { } logger.info("newTEmp " + newTemp); if (newTemp > (trpTemp + 5)) { - system.setTemperature( - system.getPhases()[0].getComponent(k).getTriplePointTemperature() + 0.4); + system + .setTemperature(system.getPhase(0).getComponent(k).getTriplePointTemperature() + 0.4); } else if (newTemp < 1) { system.setTemperature(oldTemperature + 2); // } else if(newTemp=="NaN") { system.setTemperature(oldTemperature*0.9374); @@ -228,7 +229,7 @@ public void run() { /** {@inheritDoc} */ @Override public void printToFile(String name) { - for (int n = 0; n < system.getPhases()[0].getNumberOfComponents(); n++) { + for (int n = 0; n < system.getPhase(0).getNumberOfComponents(); n++) { name = name + "_" + system.getPhase(0).getComponent(n).getComponentName(); } @@ -238,11 +239,11 @@ public void printToFile(String name) { pr_writer.println("name,freezeT,freezeP,z,iterations"); pr_writer.flush(); - for (int k = 0; k < system.getPhases()[0].getNumberOfComponents(); k++) { + for (int k = 0; k < system.getPhase(0).getNumberOfComponents(); k++) { // print line to output file pr_writer.println(FCompNames[k] + "," + java.lang.Double.toString(FCompTemp[k]) + "," + system.getPressure() + "," - + java.lang.Double.toString(system.getPhases()[0].getComponent(k).getz()) + "," + + java.lang.Double.toString(system.getPhase(0).getComponent(k).getz()) + "," + Niterations); pr_writer.flush(); } diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FugTestConstP.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FugTestConstP.java index 0d578c6b5..0cce36688 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FugTestConstP.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FugTestConstP.java @@ -90,12 +90,12 @@ public void run() { // int vapPhase = 0; // double Xivapor; - for (int k = 0; k < testSystem.getPhases()[0].getNumberOfComponents(); k++) { + for (int k = 0; k < testSystem.getPhase(0).getNumberOfComponents(); k++) { if (testSystem.getPhase(0).getComponent(k).doSolidCheck()) { this.compName = testSystem.getPhase(0).getComponent(k).getComponentName(); - trpTemp = testSystem.getPhases()[0].getComponent(k).getTriplePointTemperature(); + trpTemp = testSystem.getPhase(0).getComponent(k).getTriplePointTemperature(); this.initTestSystem2(k); - if (Math.abs(testSystem.getPhases()[0].getComponent(k).getHsub()) < 0.000001) { + if (Math.abs(testSystem.getPhase(0).getComponent(k).getHsub()) < 0.000001) { CCequation = false; } for (int i = 0; i < 20; i++) { @@ -172,7 +172,7 @@ public void PrintToFile(String FileName) { // try (PrintWriter pr_writer = new PrintWriter(new FileWriter(myFile, true))){ // // print line to output file // pr_writer.println( - // testSystem.getPhases()[0].getComponent(k).getComponentName()+" " + + // testSystem.getPhase(0).getComponent(k).getComponentName()+" " + // java.lang.Double.toString(Fug[0+k*6][i])+" // "+java.lang.Double.toString(Fug[1+k*6][i])+" // "+java.lang.Double.toString(Fug[3+k*6][i]) +" "+ diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/HCdewPointPressureFlash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/HCdewPointPressureFlash.java index 30f338c6f..022997992 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/HCdewPointPressureFlash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/HCdewPointPressureFlash.java @@ -51,56 +51,53 @@ public void run() { system.getChemicalReactionOperations().solveChemEq(1); } - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - system.getPhases()[0].getComponent(i).setx(system.getPhases()[0].getComponent(i).getz()); - if (system.getPhases()[0].getComponent(i).getIonicCharge() != 0) { - system.getPhases()[0].getComponent(i).setx(1e-40); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + system.getPhase(0).getComponent(i).setx(system.getPhase(0).getComponent(i).getz()); + if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { + system.getPhase(0).getComponent(i).setx(1e-40); } else { - system.getPhases()[1].getComponent(i) - .setx(1.0 / system.getPhases()[0].getComponent(i).getK() - * system.getPhases()[1].getComponent(i).getz()); + system.getPhase(1).getComponent(i).setx(1.0 / system.getPhase(0).getComponent(i).getK() + * system.getPhase(1).getComponent(i).getz()); } } - // system.setPressure(system.getPhases()[0].getAntoineVaporPressure(system.getTemperature())); + // system.setPressure(system.getPhase(0).getAntoineVaporPressure(system.getTemperature())); xtotal = 0.0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - xtotal += system.getPhases()[1].getComponent(i).getx(); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + xtotal += system.getPhase(1).getComponent(i).getx(); } double ktot = 0.0; double xTotOld = 0.0; double presoldold = 0; do { iterations++; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - system.getPhases()[1].getComponent(i) - .setx(system.getPhases()[1].getComponent(i).getx() / xtotal); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + system.getPhase(1).getComponent(i).setx(system.getPhase(1).getComponent(i).getx() / xtotal); } system.init(1); ktot = 0.0; presoldold = oldPres; oldPres = system.getPressure(); - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { do { - xold = system.getPhases()[1].getComponent(i).getx(); + xold = system.getPhase(1).getComponent(i).getx(); if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { - system.getPhases()[0].getComponent(i).setK(1e-40); + system.getPhase(0).getComponent(i).setK(1e-40); } else { - system.getPhases()[0].getComponent(i).setK( - Math.exp(Math.log(system.getPhases()[1].getComponent(i).getFugacityCoefficient()) - - Math.log(system.getPhases()[0].getComponent(i).getFugacityCoefficient()))); + system.getPhase(0).getComponent(i) + .setK(Math.exp(Math.log(system.getPhase(1).getComponent(i).getFugacityCoefficient()) + - Math.log(system.getPhase(0).getComponent(i).getFugacityCoefficient()))); } - system.getPhases()[1].getComponent(i).setK(system.getPhases()[0].getComponent(i).getK()); - system.getPhases()[1].getComponent(i) - .setx(1.0 / system.getPhases()[0].getComponent(i).getK() - * system.getPhases()[1].getComponent(i).getz()); - } while (Math.abs(system.getPhases()[1].getComponent(i).getx() - xold) > 1e-4); - ktot += Math.abs(system.getPhases()[1].getComponent(i).getK() - 1.0); + system.getPhase(1).getComponent(i).setK(system.getPhase(0).getComponent(i).getK()); + system.getPhase(1).getComponent(i).setx(1.0 / system.getPhase(0).getComponent(i).getK() + * system.getPhase(1).getComponent(i).getz()); + } while (Math.abs(system.getPhase(1).getComponent(i).getx() - xold) > 1e-4); + ktot += Math.abs(system.getPhase(1).getComponent(i).getK() - 1.0); } xoldold = xTotOld; xTotOld = xtotal; xtotal = 0.0; - for (int i = 0; i < system.getPhases()[1].getNumberOfComponents(); i++) { - xtotal += system.getPhases()[1].getComponent(i).getx(); + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + xtotal += system.getPhase(1).getComponent(i).getx(); } double newPres = 0; @@ -119,7 +116,7 @@ public void run() { || Math.abs(oldPres - system.getPressure()) / oldPres > 1e-9) && (iterations < maxNumberOfIterations)); // logger.info("iter " + iterations + " XTOT " +xtotal + " k " - // +system.getPhases()[1].getComponent(0).getK()); + // +system.getPhase(1).getComponent(0).getK()); if (Math.abs(xtotal - 1.0) >= 1e-5 || ktot < 1e-3 && system.getPhase(0).getNumberOfComponents() > 1) { setSuperCritical(true); diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/SolidComplexTemperatureCalc.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/SolidComplexTemperatureCalc.java index 6faec09da..4d5c30b41 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/SolidComplexTemperatureCalc.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/SolidComplexTemperatureCalc.java @@ -93,21 +93,21 @@ public void runOld() { iter++; ops.TPflash(); for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - if (system.getPhases()[5].getComponent(i).getName().equals("water") - || system.getPhases()[5].getComponent(i).getName().equals("MEG")) { - system.getPhases()[5].getComponent(i).setx(0.5); + if (system.getPhase(5).getComponent(i).getName().equals("water") + || system.getPhase(5).getComponent(i).getName().equals("MEG")) { + system.getPhase(5).getComponent(i).setx(0.5); } else { - system.getPhases()[5].getComponent(i).setx(1e-20); + system.getPhase(5).getComponent(i).setx(1e-20); } } logger.info("Temperaure " + system.getTemperature() + " sumx " + sumx); sumx = 0.0; for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - // system.getPhases()[5].getComponent(i).setx(Ksolid[i] * + // system.getPhase(5).getComponent(i).setx(Ksolid[i] * // system.getPhase(0).getComponent(i).getx()); - // if (system.getPhases()[5].getComponent(i).getx() > 0.000001) { + // if (system.getPhase(5).getComponent(i).getx() > 0.000001) { Ksolid[i] = system.getPhase(0).getComponent(i).getFugacityCoefficient() - / system.getPhases()[5].getComponent(i).fugcoef(system.getPhases()[5]); + / system.getPhase(5).getComponent(i).fugcoef(system.getPhase(5)); sumx += Ksolid[i] * system.getPhase(0).getComponent(i).getx(); // } } diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/WATcalc.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/WATcalc.java index 1e29556fa..0b6c9bee2 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/WATcalc.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/WATcalc.java @@ -39,7 +39,7 @@ public void run() { double deltaT = 1.0; double[] Ksolid = new double[system.getPhase(0).getNumberOfComponents()]; for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - system.getPhases()[5].getComponent(i).setx(1.0); + system.getPhase(5).getComponent(i).setx(1.0); Ksolid[i] = 1.0; } do { @@ -48,10 +48,10 @@ public void run() { sumx = 0.0; for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - system.getPhases()[5].getComponent(i) + system.getPhase(5).getComponent(i) .setx(Ksolid[i] * system.getPhase(0).getComponent(i).getx()); Ksolid[i] = system.getPhase(0).getComponent(i).getFugacityCoefficient() - / system.getPhases()[5].getComponent(i).fugcoef(system.getPhases()[5]); + / system.getPhase(5).getComponent(i).fugcoef(system.getPhase(5)); sumx += Ksolid[i] * system.getPhase(0).getComponent(i).getx(); } double funk = sumx - 1.0; diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/WaterDewPointTemperatureFlash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/WaterDewPointTemperatureFlash.java index accc16d31..9ceebc6ce 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/WaterDewPointTemperatureFlash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/WaterDewPointTemperatureFlash.java @@ -42,11 +42,11 @@ public void run() { system.setNumberOfPhases(2); - for (int k = 0; k < system.getPhases()[0].getNumberOfComponents(); k++) { + for (int k = 0; k < system.getPhase(0).getNumberOfComponents(); k++) { if (system.getPhase(0).getComponent(k).getComponentName().equals("water") || system.getPhase(0).getComponent(k).getComponentName().equals("MEG")) { - system.setTemperature(system.getPhases()[0].getComponent(k).getMeltingPointTemperature()); - for (int l = 0; l < system.getPhases()[0].getNumberOfComponents(); l++) { + system.setTemperature(system.getPhase(0).getComponent(k).getMeltingPointTemperature()); + for (int l = 0; l < system.getPhase(0).getNumberOfComponents(); l++) { system.getPhase(1).getComponent(l).setx(1e-30); // logger.info("here"); } @@ -59,20 +59,20 @@ public void run() { // deriv = 0.0; iterations++; system.init(3); - funk = system.getPhases()[0].getComponent(k).getz(); + funk = system.getPhase(0).getComponent(k).getz(); - funk -= system.getPhases()[0].getBeta() - * system.getPhases()[1].getComponent(k).getFugacityCoefficient() - / system.getPhases()[0].getComponent(k).getFugacityCoefficient(); + funk -= system.getPhase(0).getBeta() + * system.getPhase(1).getComponent(k).getFugacityCoefficient() + / system.getPhase(0).getComponent(k).getFugacityCoefficient(); // logger.info("funk " + funk); /* - * deriv -= system.getPhases()[0].getBeta() - * (system.getPhases()[1].getComponent(k).getFugacityCoefficient() - * system.getPhases()[0].getComponent(k).getdfugdt() * -1.0 / - * Math.pow(system.getPhases()[0].getComponent(k) .getFugacityCoefficient(), 2.0) + - * system.getPhases()[1].getComponent(k).getdfugdt() / - * system.getPhases()[i].getComponent(k) .getFugacityCoefficient()); + * deriv -= system.getPhase(0).getBeta() + * (system.getPhase(1).getComponent(k).getFugacityCoefficient() + * system.getPhase(0).getComponent(k).getdfugdt() * -1.0 / + * Math.pow(system.getPhase(0).getComponent(k) .getFugacityCoefficient(), 2.0) + + * system.getPhase(1).getComponent(k).getdfugdt() / system.getPhase(i).getComponent(k) + * .getFugacityCoefficient()); * * system.setTemperature(system.getTemperature() - funk/deriv); */ diff --git a/src/main/java/neqsim/thermodynamicoperations/phaseenvelopeops/multicomponentenvelopeops/PTphaseEnvelope.java b/src/main/java/neqsim/thermodynamicoperations/phaseenvelopeops/multicomponentenvelopeops/PTphaseEnvelope.java index a34d24dfc..983cd239e 100644 --- a/src/main/java/neqsim/thermodynamicoperations/phaseenvelopeops/multicomponentenvelopeops/PTphaseEnvelope.java +++ b/src/main/java/neqsim/thermodynamicoperations/phaseenvelopeops/multicomponentenvelopeops/PTphaseEnvelope.java @@ -805,7 +805,7 @@ public double tempKWilson(double beta, double P) { Kwil[j] = system.getPhase(0).getComponent(j).getPC() / P * Math.exp(5.373 * (1. + system.getPhase(0).getComponent(j).getAcentricFactor()) * (1. - system.getPhase(0).getComponent(j).getTC() / Tstart)); - // system.getPhases()[0].getComponent(j).setK(Kwil[j]); + // system.getPhase(0).getComponent(j).setK(Kwil[j]); } for (int j = 0; j < numberOfComponents; j++) { diff --git a/src/main/java/neqsim/thermodynamicoperations/phaseenvelopeops/multicomponentenvelopeops/PTphaseEnvelopeMay.java b/src/main/java/neqsim/thermodynamicoperations/phaseenvelopeops/multicomponentenvelopeops/PTphaseEnvelopeMay.java index f75437e50..d3f75aa3c 100644 --- a/src/main/java/neqsim/thermodynamicoperations/phaseenvelopeops/multicomponentenvelopeops/PTphaseEnvelopeMay.java +++ b/src/main/java/neqsim/thermodynamicoperations/phaseenvelopeops/multicomponentenvelopeops/PTphaseEnvelopeMay.java @@ -724,7 +724,7 @@ public double tempKWilson(double beta, double P) { Kwil[j] = system.getPhase(0).getComponent(j).getPC() / P * Math.exp(5.373 * (1. + system.getPhase(0).getComponent(j).getAcentricFactor()) * (1. - system.getPhase(0).getComponent(j).getTC() / Tstart)); - system.getPhases()[0].getComponent(j).setK(Math.log(Kwil[j])); + system.getPhase(0).getComponent(j).setK(Math.log(Kwil[j])); } for (int j = 0; j < numberOfComponents; j++) { diff --git a/src/main/java/neqsim/thermodynamicoperations/phaseenvelopeops/multicomponentenvelopeops/PTphaseEnvelopeNew2.java b/src/main/java/neqsim/thermodynamicoperations/phaseenvelopeops/multicomponentenvelopeops/PTphaseEnvelopeNew2.java index 3f42474d0..6a463a60c 100644 --- a/src/main/java/neqsim/thermodynamicoperations/phaseenvelopeops/multicomponentenvelopeops/PTphaseEnvelopeNew2.java +++ b/src/main/java/neqsim/thermodynamicoperations/phaseenvelopeops/multicomponentenvelopeops/PTphaseEnvelopeNew2.java @@ -554,7 +554,7 @@ public double tempKWilson(double beta, double P) { Kwil[j] = system.getPhase(0).getComponent(j).getPC() / P * Math.exp(5.373 * (1. + system.getPhase(0).getComponent(j).getAcentricFactor()) * (1. - system.getPhase(0).getComponent(j).getTC() / Tstart)); - // system.getPhases()[0].getComponent(j).setK(Kwil[j]); + // system.getPhase(0).getComponent(j).setK(Kwil[j]); } for (int j = 0; j < numberOfComponents; j++) { diff --git a/src/main/java/neqsim/thermodynamicoperations/phaseenvelopeops/reactivecurves/PloadingCurve.java b/src/main/java/neqsim/thermodynamicoperations/phaseenvelopeops/reactivecurves/PloadingCurve.java index 3e923d480..aeef58805 100644 --- a/src/main/java/neqsim/thermodynamicoperations/phaseenvelopeops/reactivecurves/PloadingCurve.java +++ b/src/main/java/neqsim/thermodynamicoperations/phaseenvelopeops/reactivecurves/PloadingCurve.java @@ -73,11 +73,11 @@ public PloadingCurve() {} */ public PloadingCurve(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()]; + lnOldOldK = new double[system.getPhase(0).getNumberOfComponents()]; + lnOldK = new double[system.getPhase(0).getNumberOfComponents()]; + lnK = new double[system.getPhase(0).getNumberOfComponents()]; + 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); @@ -100,12 +100,12 @@ public void run() { points[0] = new double[numbPoints]; points[1] = new double[numbPoints]; - for (int k = 0; k < system.getPhases()[1].getNumberOfComponents(); k++) { + for (int k = 0; k < system.getPhase(1).getNumberOfComponents(); k++) { points[k + 2] = new double[numbPoints]; - points[k + 2 + system.getPhases()[1].getNumberOfComponents()] = new double[numbPoints]; + points[k + 2 + system.getPhase(1).getNumberOfComponents()] = new double[numbPoints]; } - double molMDEA = system.getPhases()[1].getComponents()[2].getNumberOfMolesInPhase(); + double molMDEA = system.getPhase(1).getComponents()[2].getNumberOfMolesInPhase(); system.getChemicalReactionOperations().solveChemEq(0); for (int i = 1; i < points[0].length; i++) { @@ -113,17 +113,17 @@ public void run() { system.getChemicalReactionOperations().solveChemEq(1); points[0][i] = (inscr * (i - 1)) / molMDEA; - points[1][i] = (system.getPhases()[1].getComponent(0).getFugacityCoefficient() - * system.getPhases()[1].getComponent(0).getx() * system.getPressure()); + points[1][i] = (system.getPhase(1).getComponent(0).getFugacityCoefficient() + * system.getPhase(1).getComponent(0).getx() * system.getPressure()); - for (int k = 0; k < system.getPhases()[1].getNumberOfComponents(); k++) { - points[k + 2][i] = system.getPhases()[1].getComponent(k).getx(); - points[k + 2 + system.getPhases()[1].getNumberOfComponents()][i] = - system.getPhases()[1].getActivityCoefficient(k, 1); + for (int k = 0; k < system.getPhase(1).getNumberOfComponents(); k++) { + points[k + 2][i] = system.getPhase(1).getComponent(k).getx(); + points[k + 2 + system.getPhase(1).getNumberOfComponents()][i] = + system.getPhase(1).getActivityCoefficient(k, 1); } logger.info("point: " + points[0][i] + " " + points[1][i]); system.setPressure(points[1][i]); - logger.info("ph: " + system.getPhases()[1].getpH()); + logger.info("ph: " + system.getPhase(1).getpH()); system.addComponent(0, inscr, 1); } mainFrame.setVisible(false); diff --git a/src/main/java/neqsim/thermodynamicoperations/phaseenvelopeops/reactivecurves/PloadingCurve2.java b/src/main/java/neqsim/thermodynamicoperations/phaseenvelopeops/reactivecurves/PloadingCurve2.java index de40c8e8b..287ea2082 100644 --- a/src/main/java/neqsim/thermodynamicoperations/phaseenvelopeops/reactivecurves/PloadingCurve2.java +++ b/src/main/java/neqsim/thermodynamicoperations/phaseenvelopeops/reactivecurves/PloadingCurve2.java @@ -68,11 +68,11 @@ public class PloadingCurve2 extends BaseOperation { */ 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()]; + lnOldOldK = new double[system.getPhase(0).getNumberOfComponents()]; + lnOldK = new double[system.getPhase(0).getNumberOfComponents()]; + lnK = new double[system.getPhase(0).getNumberOfComponents()]; + 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); @@ -97,12 +97,12 @@ public void run() { points[2] = new double[numbPoints]; ThermodynamicOperations testOps = new ThermodynamicOperations(system); - for (int k = 0; k < system.getPhases()[1].getNumberOfComponents(); k++) { + for (int k = 0; k < system.getPhase(1).getNumberOfComponents(); k++) { points[k + 3] = new double[numbPoints]; - points[k + 3 + system.getPhases()[1].getNumberOfComponents()] = new double[numbPoints]; + points[k + 3 + system.getPhase(1).getNumberOfComponents()] = new double[numbPoints]; } - double molMDEA = system.getPhases()[1].getComponents()[2].getNumberOfMolesInPhase(); + double molMDEA = system.getPhase(1).getComponents()[2].getNumberOfMolesInPhase(); system.getChemicalReactionOperations().solveChemEq(1); for (int i = 1; i < points[0].length; i++) { @@ -118,15 +118,15 @@ public void run() { 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].getComponent(k).getx(); - points[k + 3 + system.getPhases()[1].getNumberOfComponents()][i] = + for (int k = 0; k < system.getPhase(1).getNumberOfComponents(); k++) { + points[k + 3][i] = system.getPhase(1).getComponent(k).getx(); + points[k + 3 + system.getPhase(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()); + logger.info("ph: " + system.getPhase(1).getpH()); system.addComponent("CO2", inscr); } mainFrame.setVisible(false); @@ -167,11 +167,11 @@ public double[][] getPoints(int i) { * 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++) { + * ""); for (int k = 0; k < system.getPhase(1).getNumberOfComponents(); k++) { * file.setYvalues(points[k + 3], "mol frac " + - * system.getPhases()[1].getComponent(k).getComponentName(), ""); file.setYvalues(points[k + 3 + - * system.getPhases()[1].getNumberOfComponents()], ("activity " + - * system.getPhases()[1].getComponent(k).getComponentName()), ""); } file.createFile(); } + * system.getPhase(1).getComponent(k).getComponentName(), ""); file.setYvalues(points[k + 3 + + * system.getPhase(1).getNumberOfComponents()], ("activity " + + * system.getPhase(1).getComponent(k).getComponentName()), ""); } file.createFile(); } */ /** {@inheritDoc} */ diff --git a/src/test/java/neqsim/process/equipment/separator/ThreePhaseSeparatorTest.java b/src/test/java/neqsim/process/equipment/separator/ThreePhaseSeparatorTest.java index 8b2e32f92..28cdf6e0c 100644 --- a/src/test/java/neqsim/process/equipment/separator/ThreePhaseSeparatorTest.java +++ b/src/test/java/neqsim/process/equipment/separator/ThreePhaseSeparatorTest.java @@ -2,12 +2,10 @@ import java.util.ArrayList; import java.util.List; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import neqsim.process.equipment.heatexchanger.Heater; -import neqsim.process.equipment.separator.ThreePhaseSeparator; import neqsim.process.equipment.stream.Stream; import neqsim.thermo.phase.PhaseEosInterface; import neqsim.thermodynamicoperations.ThermodynamicOperations; @@ -45,7 +43,8 @@ void setUp() { @Disabled @Test void testRun() { - neqsim.thermo.system.SystemInterface fluid1 = new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 42.0, 10.00); + neqsim.thermo.system.SystemInterface fluid1 = + new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 42.0, 10.00); fluid1.addComponent("nitrogen", 0.110282450914383); fluid1.addComponent("CO2", 8.92014980316162); @@ -66,7 +65,7 @@ void testRun() { testOps.TPflash(); - double[] intParameter = { -0.24, // "CO2" + double[] intParameter = {-0.24, // "CO2" -0.721, // "methane" 0.11, // "ethane" 0.205, // "propane" @@ -86,10 +85,10 @@ void testRun() { int waterIndex = findComponentIndex(componentNames, "water"); if (componentIndex != -1 && waterIndex != -1) { - ((PhaseEosInterface) fluid1.getPhases()[0]).getMixingRule() + ((PhaseEosInterface) fluid1.getPhase(0)).getMixingRule() .setBinaryInteractionParameter(componentIndex, waterIndex, intParameter[i]); - ((PhaseEosInterface) fluid1.getPhases()[1]).getMixingRule() + ((PhaseEosInterface) fluid1.getPhase(1)).getMixingRule() .setBinaryInteractionParameter(componentIndex, waterIndex, intParameter[i]); } else { } @@ -112,26 +111,25 @@ void testRun() { molarComposition.add(2.732003176453634); molarComposition.add(27.978388438425913); - double[] molarCompositionArray = molarComposition.stream().mapToDouble(Double::doubleValue).toArray(); + double[] molarCompositionArray = + molarComposition.stream().mapToDouble(Double::doubleValue).toArray(); neqsim.thermo.system.SystemInterface fluid_test_separator = fluid1.clone(); fluid_test_separator.setMolarComposition(molarCompositionArray); - Stream inlet_stream_test_sep = new Stream( - "TEST_SEPARATOR_INLET", - fluid_test_separator); + Stream inlet_stream_test_sep = new Stream("TEST_SEPARATOR_INLET", fluid_test_separator); inlet_stream_test_sep.setTemperature(72.6675872802734, "C"); inlet_stream_test_sep.setPressure(10.6767892837524, "bara"); inlet_stream_test_sep.setFlowRate(721.3143271348611, "kg/hr"); inlet_stream_test_sep.run(); - ThreePhaseSeparator test_separator = new ThreePhaseSeparator( - "TEST_SEPARATOR", inlet_stream_test_sep); + ThreePhaseSeparator test_separator = + new ThreePhaseSeparator("TEST_SEPARATOR", inlet_stream_test_sep); test_separator.run(); test_separator.getWaterOutStream().getThermoSystem().prettyPrint(); - Heater heater_TP_setter_test_stream = new Heater( - "TP_SETTER_FOR_THE_DEGASSER_TEST_SEP_STREAM", test_separator.getWaterOutStream()); + Heater heater_TP_setter_test_stream = new Heater("TP_SETTER_FOR_THE_DEGASSER_TEST_SEP_STREAM", + test_separator.getWaterOutStream()); heater_TP_setter_test_stream.setOutPressure(5.9061164855957 - 0.01, "bara"); heater_TP_setter_test_stream.setOutTemperature(79.8487854003906, "C"); heater_TP_setter_test_stream.run(); @@ -140,8 +138,8 @@ void testRun() { // .getFluid().getPhase("gas").getFlowRate("kg/hr")); heater_TP_setter_test_stream.getOutletStream().getThermoSystem().prettyPrint(); - Heater heater_TP_setter_test_stream2 = new Heater( - "TP_SETTER_FOR_THE_DEGASSER_TEST_SEP_STREAM", test_separator.getWaterOutStream()); + Heater heater_TP_setter_test_stream2 = new Heater("TP_SETTER_FOR_THE_DEGASSER_TEST_SEP_STREAM", + test_separator.getWaterOutStream()); heater_TP_setter_test_stream2.setOutPressure(5.9061164855957, "bara"); heater_TP_setter_test_stream2.setOutTemperature(79.8487854003906, "C"); heater_TP_setter_test_stream2.run(); @@ -167,41 +165,28 @@ private int findComponentIndex(String[] componentNames, String componentName) { @Disabled void testRun2() { /* - * XStream xstream = new XStream(); - * xstream.addPermission(AnyTypePermission.ANY); // Specify the + * XStream xstream = new XStream(); xstream.addPermission(AnyTypePermission.ANY); // Specify the * file path to read Path filePath = Paths.get( - * "/workspaces/neqsim/src/test/java/neqsim/thermodynamicOperations/flashOps/my_process.xml" - * ); - * String xmlContents = ""; try { //xmlContents = Files.readString(filePath); } - * catch + * "/workspaces/neqsim/src/test/java/neqsim/thermodynamicOperations/flashOps/my_process.xml" ); + * String xmlContents = ""; try { //xmlContents = Files.readString(filePath); } catch * (IOException e) { e.printStackTrace(); } * - * // Deserialize from xml neqsim.processSimulation.processSystem.ProcessSystem - * operationsCopy = - * (neqsim.processSimulation.processSystem.ProcessSystem) - * xstream.fromXML(xmlContents); - * operationsCopy.run(); - * neqsim.processSimulation.processEquipment.separator.Separator - * VD02Separator = - * (neqsim.processSimulation.processEquipment.separator.Separator) + * // Deserialize from xml neqsim.processSimulation.processSystem.ProcessSystem operationsCopy = + * (neqsim.processSimulation.processSystem.ProcessSystem) xstream.fromXML(xmlContents); + * operationsCopy.run(); neqsim.processSimulation.processEquipment.separator.Separator + * VD02Separator = (neqsim.processSimulation.processEquipment.separator.Separator) * operationsCopy .getUnit("Separator after CFU gas"); * neqsim.processSimulation.processEquipment.separator.Separator VD01Separator = - * (neqsim.processSimulation.processEquipment.separator.Separator) - * operationsCopy + * (neqsim.processSimulation.processEquipment.separator.Separator) operationsCopy * .getUnit("Separator after degasser gas"); * neqsim.processSimulation.processEquipment.separator.Separator Degasser = - * (neqsim.processSimulation.processEquipment.separator.Separator) - * operationsCopy - * .getUnit("Degasser"); - * System.out. - * println("The gas flow rate should be < 200 kg/hr, the actual value is " + - * Degasser.getGasOutStream().getFlowRate("kg/hr")); - * System.out. + * (neqsim.processSimulation.processEquipment.separator.Separator) operationsCopy + * .getUnit("Degasser"); System.out. * println("The gas flow rate should be < 200 kg/hr, the actual value is " + - * VD01Separator.getGasOutStream().getFlowRate("kg/hr")); - * VD02Separator.getGasOutStream().run(); - * System.out. + * Degasser.getGasOutStream().getFlowRate("kg/hr")); System.out. * println("The gas flow rate should be < 200 kg/hr, the actual value is " + + * VD01Separator.getGasOutStream().getFlowRate("kg/hr")); VD02Separator.getGasOutStream().run(); + * System.out. println("The gas flow rate should be < 200 kg/hr, the actual value is " + * VD02Separator.getGasOutStream().getFlowRate("kg/hr")); */ } diff --git a/src/test/java/neqsim/process/processmodel/GlycolModulesTest.java b/src/test/java/neqsim/process/processmodel/GlycolModulesTest.java index 2e8ba2e02..87bd5c7d2 100644 --- a/src/test/java/neqsim/process/processmodel/GlycolModulesTest.java +++ b/src/test/java/neqsim/process/processmodel/GlycolModulesTest.java @@ -47,37 +47,37 @@ public void runProcessTEG() throws InterruptedException { ThermodynamicOperations testOps = new ThermodynamicOperations(feedGas); testOps.TPflash(); - ((PhaseEosInterface) feedGas.getPhases()[0]).getMixingRule().setBinaryInteractionParameterji(2, - 15, 0.13); - ((PhaseEosInterface) feedGas.getPhases()[1]).getMixingRule().setBinaryInteractionParameterji(2, - 15, 0.13); // methane - ((PhaseEosInterface) feedGas.getPhases()[0]).getMixingRule().setBinaryInteractionParameterji(5, - 15, 0.13); - ((PhaseEosInterface) feedGas.getPhases()[1]).getMixingRule().setBinaryInteractionParameterji(5, - 15, 0.13); // i-butane - ((PhaseEosInterface) feedGas.getPhases()[0]).getMixingRule().setBinaryInteractionParameterji(6, - 15, 0.157); - ((PhaseEosInterface) feedGas.getPhases()[1]).getMixingRule().setBinaryInteractionParameterji(6, - 15, 0.157); // n-butane - ((PhaseEosInterface) feedGas.getPhases()[0]).getMixingRule().setBinaryInteractionParameterji(7, - 15, 0.055); - ((PhaseEosInterface) feedGas.getPhases()[1]).getMixingRule().setBinaryInteractionParameterji(7, - 15, 0.055); // i-pentane - ((PhaseEosInterface) feedGas.getPhases()[0]).getMixingRule().setBinaryInteractionParameterji(8, - 15, 0.095); - ((PhaseEosInterface) feedGas.getPhases()[1]).getMixingRule().setBinaryInteractionParameterji(8, - 15, 0.095); // n-pentane - ((PhaseEosInterface) feedGas.getPhases()[0]).getMixingRule().setBinaryInteractionParameterji(9, - 15, -0.02); - ((PhaseEosInterface) feedGas.getPhases()[1]).getMixingRule().setBinaryInteractionParameterji(9, - 15, -0.02); // n-hexane - ((PhaseEosInterface) feedGas.getPhases()[0]).getMixingRule().setBinaryInteractionParameterji(10, + ((PhaseEosInterface) feedGas.getPhase(0)).getMixingRule().setBinaryInteractionParameterji(2, 15, + 0.13); + ((PhaseEosInterface) feedGas.getPhase(1)).getMixingRule().setBinaryInteractionParameterji(2, 15, + 0.13); // methane + ((PhaseEosInterface) feedGas.getPhase(0)).getMixingRule().setBinaryInteractionParameterji(5, 15, + 0.13); + ((PhaseEosInterface) feedGas.getPhase(1)).getMixingRule().setBinaryInteractionParameterji(5, 15, + 0.13); // i-butane + ((PhaseEosInterface) feedGas.getPhase(0)).getMixingRule().setBinaryInteractionParameterji(6, 15, + 0.157); + ((PhaseEosInterface) feedGas.getPhase(1)).getMixingRule().setBinaryInteractionParameterji(6, 15, + 0.157); // n-butane + ((PhaseEosInterface) feedGas.getPhase(0)).getMixingRule().setBinaryInteractionParameterji(7, 15, + 0.055); + ((PhaseEosInterface) feedGas.getPhase(1)).getMixingRule().setBinaryInteractionParameterji(7, 15, + 0.055); // i-pentane + ((PhaseEosInterface) feedGas.getPhase(0)).getMixingRule().setBinaryInteractionParameterji(8, 15, + 0.095); + ((PhaseEosInterface) feedGas.getPhase(1)).getMixingRule().setBinaryInteractionParameterji(8, 15, + 0.095); // n-pentane + ((PhaseEosInterface) feedGas.getPhase(0)).getMixingRule().setBinaryInteractionParameterji(9, 15, + -0.02); + ((PhaseEosInterface) feedGas.getPhase(1)).getMixingRule().setBinaryInteractionParameterji(9, 15, + -0.02); // n-hexane + ((PhaseEosInterface) feedGas.getPhase(0)).getMixingRule().setBinaryInteractionParameterji(10, 15, 0.08); - ((PhaseEosInterface) feedGas.getPhases()[1]).getMixingRule().setBinaryInteractionParameterji(10, + ((PhaseEosInterface) feedGas.getPhase(1)).getMixingRule().setBinaryInteractionParameterji(10, 15, 0.08); // n-heptane - ((PhaseEosInterface) feedGas.getPhases()[0]).getMixingRule().setBinaryInteractionParameterji(11, + ((PhaseEosInterface) feedGas.getPhase(0)).getMixingRule().setBinaryInteractionParameterji(11, 15, 0.087); - ((PhaseEosInterface) feedGas.getPhases()[1]).getMixingRule().setBinaryInteractionParameterji(11, + ((PhaseEosInterface) feedGas.getPhase(1)).getMixingRule().setBinaryInteractionParameterji(11, 15, 0.087); // benzene testOps.TPflash(); // feedGas.setMolarComposition(new double[] { liftGas_N2, liftGas_CO2, liftGas_Methane,