diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
new file mode 100644
index 0000000000..5397f69ac2
--- /dev/null
+++ b/.devcontainer/Dockerfile
@@ -0,0 +1,25 @@
+# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.224.3/containers/java/.devcontainer/base.Dockerfile
+
+# [Choice] Java version (use -bullseye variants on local arm64/Apple Silicon): 11, 17, 11-bullseye, 17-bullseye, 11-buster, 17-buster
+ARG VARIANT="17-bullseye"
+FROM mcr.microsoft.com/vscode/devcontainers/java:0-${VARIANT}
+
+# [Option] Install Maven
+ARG INSTALL_MAVEN="false"
+ARG MAVEN_VERSION=""
+# [Option] Install Gradle
+ARG INSTALL_GRADLE="false"
+ARG GRADLE_VERSION=""
+RUN if [ "${INSTALL_MAVEN}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install maven \"${MAVEN_VERSION}\""; fi \
+ && if [ "${INSTALL_GRADLE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install gradle \"${GRADLE_VERSION}\""; fi
+
+# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
+ARG NODE_VERSION="none"
+RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
+
+# [Optional] Uncomment this section to install additional OS packages.
+# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
+# && apt-get -y install --no-install-recommends
+ * PhaseSrkCPA class.
+ *
+ * Getter for the field
+ * Constructor for PhaseUMRCPA.
+ *
+ * initCPAMatrix.
+ *
+ * calcDelta.
+ *
+ * FCPA.
+ *
+ * dFCPAdV.
+ *
+ * dFCPAdVdV.
+ *
+ * dFCPAdVdVdV.
+ *
+ * dFCPAdT.
+ *
+ * dFCPAdTdT.
+ *
+ * dFCPAdTdV.
+ *
+ * calc_hCPA.
+ *
+ * calc_g.
+ *
+ * calc_lngV.
+ *
+ * calc_lngVV.
+ *
+ * calc_lngVVV.
+ *
+ * calcXsitedV.
+ *
+ * solveX.
+ *
+ * solveX2.
+ *
+ * calcRootVolFinder.
+ *
+ * molarVolumeChangePhase.
+ *
+ * Setter for the field
+ * croeneckerProduct.
+ *
+ * initOld2.
+ *
+ * initCPAMatrixOld.
+ *
+ * solveXOld.
+ *
+ * solveX2Old.
+ *
+ * molarVolumeOld.
+ *
- * SystemFurstElectrolyteEos class.
- *
- * SystemFurstElectrolyteEosMod2004 class.
- *
- * saveFluid.
- *
- * getComponentNameTag.
- *
- * setComponentNameTagOnNormalComponents.
- *
- * addPhaseFractionToPhase.
- *
- * addPhaseFractionToPhase.
- *
- * renameComponent.
- *
- * setComponentNameTag.
- *
+ * saveFluid.
+ *
+ * saveFluid.
+ *
+ * getComponentNameTag.
+ *
+ * setComponentNameTagOnNormalComponents.
+ *
+ * addPhaseFractionToPhase.
+ *
+ * addPhaseFractionToPhase.
+ *
+ * renameComponent.
+ *
+ * setComponentNameTag.
+ *
- * calcResultTable.
- *
- * Get number of components added to System.
- *
- * saveFluid.
- *
- * getMoleFractionsSum.
- *
- * removePhaseKeepTotalComposition.
- *
- * getInterfacialTension.
- *
- * getHeatOfVaporization.
- *
- * isForcePhaseTypes.
- *
- * setForcePhaseTypes.
- *
- * setMolarFlowRates.
- *
- * setComponentNames.
- *
- * calc_x_y_nonorm.
- *
- * saveObjectToFile.
- *
- * readObjectFromFile.
- *
- * getLiquidVolume.
- *
- * resetPhysicalProperties.
- *
- * phaseToSystem.
- *
- * changeComponentName.
- *
- * getWaxModel.
- *
- * getWaxCharacterisation.
- *
- * phaseToSystem.
- *
- * getPhase.
- *
- * getPhaseIndexOfPhase.
- *
- * setTotalFlowRate.
- *
- * Returns the overall mole composition vector in unit mole fraction
- *
- * getNumberOfOilFractionComponents.
- *
- * setHeavyTBPfractionAsPlusFraction.
- *
- * getCapeOpenProperties11.
- *
- * getCapeOpenProperties10.
- *
- * getLowestGibbsEnergyPhase.
- *
- * getOilFractionNormalBoilingPoints.
- *
- * getOilFractionLiquidDensityAt25C.
- *
- * getOilFractionMolecularMass.
- *
- * getOilFractionIDs.
- *
- * getMoleFraction.
- *
- * Getter for property characterization.
- *
- * readObject.
- *
- * getCompIDs.
- *
- * isImplementedCompositionDeriativesofFugacity.
- *
- * saveObject.
- *
- * getCASNumbers.
- *
- * getMolecularWeights.
- *
- * getNormalBoilingPointTemperatures.
- *
- * getCompFormulaes.
- *
- * getWtFraction.
- *
- * isMultiphaseWaxCheck.
- *
- * setMultiphaseWaxCheck.
- *
- * This method is used to set the total molar composition of a fluid. The total
- * flow rate will be kept constant. The input mole fractions will be normalized.
- *
- * setUseTVasIndependentVariables.
- *
- * addTBPfraction.
- *
- * addPlusFraction.
- *
- * addSalt.
- *
- * deleteFluidPhase.
- *
- * setBmixType.
- *
- * hasSolidPhase.
- *
- * addSolidComplexPhase.
- *
- * resetCharacterisation.
- *
- * getMaxNumberOfPhases.
- *
- * setMaxNumberOfPhases.
- *
- * getMixingRuleName.
- *
- * Getter for property modelName.
- *
- * tuneModel.
- *
- * addComponent.
- *
- * addComponent.
- *
- * addComponent.
- *
- * getBeta.
- *
- * save.
- *
- * setModel.
- *
- * removeComponent.
- *
- * setMixingRule.
- *
- * normalizeBeta.
- *
- * Indexed getter for property phaseIndex.
- *
- * Setter for property initType.
- *
- * checkStability.
- *
- * hasPlusFraction.
- *
- * checkStability.
- *
- * Getter for property initType.
- *
- * invertPhaseTypes.
- *
- * readFluid.
- *
- * calcKIJ.
- *
- * write.
- *
- * useVolumeCorrection.
- *
- * Getter for property numericDerivatives.
- *
- * Setter for property numericDerivatives.
- *
- * Getter for property info.
- *
- * Setter for property info.
- * .
- *
- * setPhaseIndex.
- *
- * Indexed setter for property phaseIndex.
- *
- * resetDatabase.
- *
- * Setter for property solidPhaseCheck.
- *
- * doSolidPhaseCheck.
- *
- * Getter for property multiPhaseCheck.
- *
- * display.
- *
- * addFluid.
- *
- * display.
- *
- * Getter for property hydrateCheck.
- *
- * Getter for property hydrateCheck.
- *
- * createTable.
- *
- * setHydrateCheck.
- *
- * calcBeta.
- *
- * setAllComponentsInPhase.
- *
- * initTotalNumberOfMoles.
- *
- * calc_x_y.
- *
- * getPhase.
- *
- * reset_x_y.
- *
- * isChemicalSystem.
- *
- * addPhase.
- *
- * setAttractiveTerm.
- *
- * setBeta.
- *
- * removePhase.
- *
- * phaseToSystem.
- *
- * method to set the temperature of a fluid (same temperature for all phases)
- *
- * setTemperature.
- *
- * reInitPhaseType.
- *
- * clearAll.
- *
- * method to return pressure of phase
- *
- * getChemicalReactionOperations.
- *
- * isChemicalSystem.
- *
- * calcInterfaceProperties.
- *
- * getInterphaseProperties.
- *
- * initBeta.
- *
- * init_x_y.
- *
- * getTemperature.
- *
- * getBeta.
- *
- * chemicalReactionInit.
- *
- * setBeta.
- *
- * method to set the phase type of a given phase
- *
- * setNumberOfPhases.
- *
- * getTC.
- *
- * getPC.
- *
- * setTC.
- *
- * setPC.
- *
- * getPhases.
- *
- * getNumberOfPhases.
- *
- * getGibbsEnergy.
- *
- * getHelmholtzEnergy.
- *
- * getComponent.
- *
- * getComponent.
- *
- * getNumberOfMoles.
- *
- * clone.
- *
- * getComponentNames.
- *
- * getdVdPtn.
- *
- * getdVdTpn.
- *
- * replacePhase.
- *
- * getGasPhase.
- *
- * getLiquidPhase.
- *
- * getKinematicViscosity.
- *
- * initRefPhases.
- *
- * getFluidName.
- *
- * setFluidName.
- *
- * setSolidPhaseCheck.
- *
- * Getter for property allowPhaseShift.
- *
- * Setter for property allowPhaseShift.
- *
- * setPhaseType.
- *
- * getProperty.
- *
- * getProperty.
- *
- * getProperty.
- *
- * Getter for property standard.
- *
- * Getter for property standard.
- *
- * Setter for property standard.
- *
- * saveToDataBase.
- *
- * generatePDF.
- *
- * displayPDF.
- *
- * getMixingRule.
- *
- * getResultTable.
- *
- * autoSelectModel.
- *
- * autoSelectMixingRule.
- *
- * addLiquidToGas.
- *
- * addGasToLiquid.
- *
- * setTotalNumberOfMoles.
- *
- * phaseToSystem.
- *
- * hasPhaseType.
- *
- * getPhaseNumberOfPhase.
- *
- * getEmptySystemClone.
- *
- * calcHenrysConstant.
- *
- * isImplementedTemperatureDeriativesofFugacity.
- *
- * setImplementedTemperatureDeriativesofFugacity.
- *
- * isImplementedPressureDeriativesofFugacity.
- *
- * setImplementedPressureDeriativesofFugacity.
- *
- * isImplementedCompositionDeriativesofFugacity.
- *
- * setImplementedCompositionDeriativesofFugacity.
- *
- * addCapeOpenProperty.
- *
+ * calcResultTable.
+ *
+ * getKinematicViscosity.
+ *
+ * Get number of components added to System.
+ *
+ * getMoleFractionsSum.
+ *
+ * removePhaseKeepTotalComposition.
+ *
+ * getInterfacialTension.
+ *
+ * method to set the temperature of a fluid (same temperature for all phases).
+ *
+ * setTemperature.
+ *
+ * getHeatOfVaporization.
+ *
+ * isForcePhaseTypes.
+ *
+ * setForcePhaseTypes.
+ *
+ * setMolarFlowRates.
+ *
+ * setComponentNames.
+ *
+ * calc_x_y_nonorm.
+ *
+ * saveObjectToFile.
+ *
+ * readObjectFromFile.
+ *
+ * getLiquidVolume.
+ *
+ * resetPhysicalProperties.
+ *
+ * phaseToSystem.
+ *
+ * phaseToSystem.
+ *
+ * phaseToSystem.
+ *
+ * phaseToSystem.
+ *
+ * changeComponentName.
+ *
+ * getWaxModel.
+ *
+ * getWaxCharacterisation.
+ *
+ * getPhase.
+ *
+ * getPhaseIndexOfPhase.
+ *
+ * setTotalFlowRate.
+ *
+ * Returns the overall mole composition vector in unit mole fraction.
+ *
+ * getNumberOfOilFractionComponents.
+ *
+ * setHeavyTBPfractionAsPlusFraction.
+ *
+ * getCapeOpenProperties11.
+ *
+ * getCapeOpenProperties10.
+ *
+ * getLowestGibbsEnergyPhase.
+ *
+ * getOilFractionNormalBoilingPoints.
+ *
+ * getOilFractionLiquidDensityAt25C.
+ *
+ * getOilFractionMolecularMass.
+ *
+ * getOilFractionIDs.
+ *
+ * getMoleFraction.
+ *
+ * Getter for property characterization.
+ *
+ * readObject.
+ *
+ * getCompIDs.
+ *
+ * saveObject.
+ *
+ * getCASNumbers.
+ *
+ * getMolecularWeights.
+ *
+ * getNormalBoilingPointTemperatures.
+ *
+ * getCompFormulaes.
+ *
+ * getWtFraction.
+ *
+ * isMultiphaseWaxCheck.
+ *
+ * setMultiphaseWaxCheck.
+ *
+ * This method is used to set the total molar composition of a fluid. The total flow rate will be
+ * kept constant. The input mole fractions will be normalized.
+ *
+ * setUseTVasIndependentVariables.
+ *
+ * addTBPfraction.
+ *
+ * addPlusFraction.
+ *
+ * addSalt.
+ *
+ * deleteFluidPhase.
+ *
+ * setBmixType.
+ *
+ * hasSolidPhase.
+ *
+ * addSolidComplexPhase.
+ *
+ * resetCharacterisation.
+ *
+ * getMaxNumberOfPhases.
+ *
+ * setMaxNumberOfPhases.
+ *
+ * getMixingRuleName.
+ *
+ * Getter for property modelName.
+ *
+ * tuneModel.
+ *
+ * addComponent.
+ *
+ * addComponent.
+ *
+ * addComponent.
+ *
+ * getBeta.
+ *
+ * getBeta.
+ *
+ * save.
+ *
+ * setModel.
+ *
+ * removeComponent.
+ *
+ * setMixingRule.
+ *
+ * normalizeBeta.
+ *
+ * Indexed getter for property phaseIndex.
+ *
+ * Setter for property initType.
+ *
+ * checkStability.
+ *
+ * checkStability.
+ *
+ * hasPlusFraction.
+ *
+ * Getter for property initType.
+ *
+ * invertPhaseTypes.
+ *
+ * readFluid.
+ *
+ * calcKIJ.
+ *
+ * write.
+ *
+ * useVolumeCorrection.
+ *
+ * Getter for property numericDerivatives.
+ *
+ * Setter for property numericDerivatives.
+ *
+ * Getter for property info.
+ *
+ * Setter for property info. .
+ *
+ * setPhaseIndex.
+ *
+ * Indexed setter for property phaseIndex.
+ *
+ * resetDatabase.
+ *
+ * Setter for property solidPhaseCheck.
+ *
+ * setSolidPhaseCheck.
+ *
+ * doSolidPhaseCheck.
+ *
+ * Getter for property multiPhaseCheck.
+ *
+ * display.
+ *
+ * display.
+ *
+ * addFluid.
+ *
+ * Getter for property hydrateCheck.
+ *
+ * Getter for property hydrateCheck.
+ *
+ * createTable.
+ *
+ * setHydrateCheck.
+ *
+ * calcBeta.
+ *
+ * setAllComponentsInPhase.
+ *
+ * initTotalNumberOfMoles.
+ *
+ * calc_x_y.
+ *
+ * reset_x_y.
+ *
+ * setAttractiveTerm.
+ *
+ * setBeta.
+ *
+ * setBeta.
+ *
+ * removePhase.
+ *
+ * method to return pressure of phase.
+ *
+ * reInitPhaseType.
+ *
+ * clearAll.
+ *
+ * getChemicalReactionOperations.
+ *
+ * isChemicalSystem.
+ *
+ * isChemicalSystem.
+ *
+ * calcInterfaceProperties.
+ *
+ * getInterphaseProperties.
+ *
+ * initBeta.
+ *
+ * init_x_y.
+ *
+ * getTemperature.
+ *
+ * chemicalReactionInit.
+ *
+ * method to set the phase type of a given phase.
+ *
+ * setPhaseType.
+ *
+ * setNumberOfPhases.
+ *
+ * getTC.
+ *
+ * getPC.
+ *
+ * setTC.
+ *
+ * setPC.
+ *
+ * getPhases.
+ *
+ * getNumberOfPhases.
+ *
+ * getGibbsEnergy.
+ *
+ * getHelmholtzEnergy.
+ *
+ * getComponent.
+ *
+ * getComponent.
+ *
+ * getNumberOfMoles.
+ *
+ * clone.
+ *
+ * getComponentNames.
+ *
+ * getdVdPtn.
+ *
+ * getdVdTpn.
+ *
+ * replacePhase.
+ *
+ * getGasPhase.
+ *
+ * getLiquidPhase.
+ *
+ * initRefPhases.
+ *
+ * getFluidName.
+ *
+ * setFluidName.
+ *
+ * Getter for property allowPhaseShift.
+ *
+ * Setter for property allowPhaseShift.
+ *
+ * getProperty.
+ *
+ * getProperty.
+ *
+ * getProperty.
+ *
+ * Getter for property standard.
+ *
+ * Getter for property standard.
+ *
+ * Setter for property standard.
+ *
+ * saveToDataBase.
+ *
+ * getMixingRule.
+ *
+ * getResultTable.
+ *
+ * autoSelectModel.
+ *
+ * autoSelectMixingRule.
+ *
+ * addLiquidToGas.
+ *
+ * addGasToLiquid.
+ *
+ * setTotalNumberOfMoles.
+ *
+ * hasPhaseType.
+ *
+ * getPhaseNumberOfPhase.
+ *
+ * getEmptySystemClone.
+ *
+ * calcHenrysConstant.
+ *
+ * isImplementedTemperatureDeriativesofFugacity.
+ *
+ * setImplementedTemperatureDeriativesofFugacity.
+ *
+ * isImplementedPressureDeriativesofFugacity.
+ *
+ * setImplementedPressureDeriativesofFugacity.
+ *
+ * isImplementedCompositionDeriativesofFugacity.
+ *
+ * isImplementedCompositionDeriativesofFugacity.
+ *
+ * setImplementedCompositionDeriativesofFugacity.
+ *
+ * addCapeOpenProperty.
+ *
- * SystemSrkTwuCoonStatoilEos class.
- * dFdNtemp
.
+ * gcpav
.
+ *
+ * setMixingRuleGEmodel. + *
+ * + * @param name a {@link java.lang.String} object + */ + public void setMixingRuleGEmodel(String name) { + for (PhaseInterface tmpPhase : phaseArray) { + if (tmpPhase != null) { + tmpPhase.setMixingRuleGEModel(name); + } + } + } + /** {@inheritDoc} */ @Override public final void setMixingRule(int type) { @@ -2268,20 +2369,6 @@ public final void setMixingRule(int type) { } } - /** - *- * setMixingRuleGEmodel. - *
- * - * @param name a {@link java.lang.String} object - */ - public void setMixingRuleGEmodel(String name) { - for (PhaseInterface tmpPhase : phaseArray) { - if (tmpPhase != null) - tmpPhase.setMixingRuleGEModel(name); - } - } - /** {@inheritDoc} */ @Override public void setMixingRule(String typename, String GEmodel) { @@ -2383,6 +2470,8 @@ public double getExergy(double temperatureOfSurroundings, String exergyUnit) { case "kJ/kg": conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0; break; + default: + break; } return refExergy * conversionFactor; } @@ -2422,6 +2511,8 @@ public double getEnthalpy(String unit) { case "kJ/kg": conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0; break; + default: + break; } return refEnthalpy * conversionFactor; } @@ -2561,6 +2652,8 @@ public double getInternalEnergy(String unit) { case "kJ/kg": conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0; break; + default: + break; } return refEnthalpy * conversionFactor; } @@ -2603,6 +2696,8 @@ public double getEntropy(String unit) { case "kJ/kgK": conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0; break; + default: + break; } return refEntropy * conversionFactor; } @@ -2622,8 +2717,7 @@ public double getMolarVolume() { public double getDensity() { double density = 0; for (int i = 0; i < numberOfPhases; i++) { - density += - 1.0e5 * (getPhase(i).getMolarMass() * beta[phaseIndex[i]] / getPhase(i).getMolarVolume()); + density += 1.0e5 * (getPhase(i).getMolarMass() * beta[phaseIndex[i]] / getPhase(i).getMolarVolume()); } return density; } @@ -2633,8 +2727,7 @@ public double getDensity() { public double getDensity(String unit) { double density = 0; for (int i = 0; i < getNumberOfPhases(); i++) { - density += - getPhase(i).getVolume() / getVolume() * getPhase(i).getPhysicalProperties().getDensity(); + density += getPhase(i).getVolume() / getVolume() * getPhase(i).getPhysicalProperties().getDensity(); } double refDensity = density; // density in kg/m3 double conversionFactor = 1.0; @@ -2679,8 +2772,7 @@ public double getMoleFractionsSum() { public double getMolarMass() { double tempVar = 0; for (int i = 0; i < phaseArray[0].getNumberOfComponents(); i++) { - tempVar += - phaseArray[0].getComponents()[i].getz() * phaseArray[0].getComponents()[i].getMolarMass(); + tempVar += phaseArray[0].getComponents()[i].getz() * phaseArray[0].getComponents()[i].getMolarMass(); } return tempVar; } @@ -2711,6 +2803,12 @@ public void setTemperature(double newTemperature) { } } + /** {@inheritDoc} */ + @Override + public final void setTemperature(double newTemperature, int phase) { + getPhase(phaseIndex[phase]).setTemperature(newTemperature); + } + /** {@inheritDoc} */ @Override public void setTemperature(double newTemperature, String unit) { @@ -2833,12 +2931,6 @@ public final void setPressure(double newPressure, String unit) { } } - /** {@inheritDoc} */ - @Override - public final void setTemperature(double newPressure, int phase) { - getPhase(phaseIndex[phase]).setTemperature(newPressure); - } - /** {@inheritDoc} */ @Override public final double getTemperature() { @@ -2908,10 +3000,12 @@ public final int getNumberOfPhases() { /** {@inheritDoc} */ @Override public final void setBeta(double b) { - if (b < 0) + if (b < 0) { b = neqsim.thermo.ThermodynamicModelSettings.phaseFractionMinimumLimit; - if (b > 1) + } + if (b > 1) { b = 1.0 - neqsim.thermo.ThermodynamicModelSettings.phaseFractionMinimumLimit; + } beta[0] = b; beta[1] = 1.0 - b; } @@ -2919,10 +3013,12 @@ public final void setBeta(double b) { /** {@inheritDoc} */ @Override public final void setBeta(int phase, double b) { - if (b < 0) + if (b < 0) { b = neqsim.thermo.ThermodynamicModelSettings.phaseFractionMinimumLimit; - if (b > 1) + } + if (b > 1) { b = 1.0 - neqsim.thermo.ThermodynamicModelSettings.phaseFractionMinimumLimit; + } beta[phaseIndex[phase]] = b; } @@ -2953,6 +3049,8 @@ public double getVolume(String unit) { case "m3/mol": conversionFactor = 1.0 / getTotalNumberOfMoles(); break; + default: + break; } return conversionFactor * getVolume() / 1.0e5; } @@ -2972,6 +3070,8 @@ public double getMass(String unit) { case "tons": conversionFactor = 1.0e-3; break; + default: + break; } return conversionFactor * getTotalNumberOfMoles() * getMolarMass(); } @@ -3026,7 +3126,6 @@ public double getdVdTpn() { return dVdT; } - /** {@inheritDoc} */ @Override public double getCp() { @@ -3055,6 +3154,8 @@ public double getCp(String unit) { case "kJ/kgK": conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0; break; + default: + break; } return refCp * conversionFactor; } @@ -3087,6 +3188,8 @@ public double getCv(String unit) { case "kJ/kgK": conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0; break; + default: + break; } return refCv * conversionFactor; } @@ -3094,9 +3197,10 @@ public double getCv(String unit) { /** * {@inheritDoc} * - * @Override + * @return kappa real gas kappa * - * method to return real gas isentropic exponent (kappa = - Cp/Cv*(v/p)*dp/dv + * method to return real gas isentropic exponent (kappa = - + * Cp/Cv*(v/p)*dp/dv */ public double getKappa() { return -getCp() / getCv() * getVolume() / getPressure() * getdPdVtn(); @@ -3108,13 +3212,6 @@ public double getGamma() { return getCp() / getCv(); } - /** {@inheritDoc} */ - @Override - public double getGamma2() { - double cp0 = getCp(); - return cp0 / (cp0 - ThermodynamicConstantsInterface.R * totalNumberOfMoles); - } - /** {@inheritDoc} */ @Override public void calcInterfaceProperties() { @@ -3150,18 +3247,6 @@ public double getInterfacialTension(String phase1, String phase2) { } } - /** - *- * write. - *
- * - * @return a {@link java.lang.String} object - */ - public String write() { - // create a String description of the system - return ""; - } - /** {@inheritDoc} */ @Override public void normalizeBeta() { @@ -3174,12 +3259,6 @@ public void normalizeBeta() { } } - /** {@inheritDoc} */ - @Override - public void display() { - display(this.getFluidName()); - } - /** {@inheritDoc} */ @Override public String[][] createTable(String name) { @@ -3227,49 +3306,45 @@ public String[][] createTable(String name) { table[j + 1][1] = nf.format(getPhase(0).getComponents()[j].getz(), buf, test).toString(); } buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 4][1] = - nf.format(getMolarMass() * 1000, buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 4][1] = nf.format(getMolarMass() * 1000, buf, test).toString(); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 9][1] = - nf.format(getEnthalpy() / (getTotalNumberOfMoles() * getMolarMass() * 1000), buf, test) - .toString(); + table[getPhases()[0].getNumberOfComponents() + 9][1] = nf + .format(getEnthalpy() / (getTotalNumberOfMoles() * getMolarMass() * 1000), buf, test) + .toString(); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 10][1] = - nf.format(getEntropy() / (getTotalNumberOfMoles() * getMolarMass() * 1000), buf, test) - .toString(); + table[getPhases()[0].getNumberOfComponents() + 10][1] = nf + .format(getEntropy() / (getTotalNumberOfMoles() * getMolarMass() * 1000), buf, test) + .toString(); for (int i = 0; i < numberOfPhases; i++) { for (int j = 0; j < getPhases()[0].getNumberOfComponents(); j++) { table[j + 1][0] = getPhases()[0].getComponents()[j].getName(); buf = new StringBuffer(); - table[j + 1][i + 2] = - nf.format(getPhase(i).getComponents()[j].getx(), buf, test).toString(); + table[j + 1][i + 2] = nf.format(getPhase(i).getComponents()[j].getx(), buf, test).toString(); table[j + 1][6] = "[mole fraction]"; } buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 2][0] = "Density"; - table[getPhases()[0].getNumberOfComponents() + 2][i + 2] = - nf.format(getPhase(i).getPhysicalProperties().getDensity(), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 2][i + 2] = nf + .format(getPhase(i).getPhysicalProperties().getDensity(), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 2][6] = "[kg/m^3]"; // Double.longValue(system.getPhase(i).getBeta()); buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 3][0] = "PhaseFraction"; - table[getPhases()[0].getNumberOfComponents() + 3][i + 2] = - nf.format(getPhase(i).getBeta(), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 3][i + 2] = nf.format(getPhase(i).getBeta(), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 3][6] = "[mole fraction]"; buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 4][0] = "MolarMass"; - table[getPhases()[0].getNumberOfComponents() + 4][i + 2] = - nf.format(getPhase(i).getMolarMass() * 1000, buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 4][i + 2] = nf.format(getPhase(i).getMolarMass() * 1000, buf, test) + .toString(); table[getPhases()[0].getNumberOfComponents() + 4][6] = "[kg/kmol]"; buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 5][0] = "Z factor"; - table[getPhases()[0].getNumberOfComponents() + 5][i + 2] = - nf.format(getPhase(i).getZ(), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 5][i + 2] = nf.format(getPhase(i).getZ(), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 5][6] = "[-]"; buf = new StringBuffer(); @@ -3290,8 +3365,8 @@ public String[][] createTable(String name) { buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 8][0] = "Speed of Sound"; - table[getPhases()[0].getNumberOfComponents() + 8][i + 2] = - nf.format((getPhase(i).getSoundSpeed()), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 8][i + 2] = nf.format((getPhase(i).getSoundSpeed()), buf, test) + .toString(); table[getPhases()[0].getNumberOfComponents() + 8][6] = "[m/sec]"; buf = new StringBuffer(); @@ -3312,47 +3387,47 @@ public String[][] createTable(String name) { buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 11][0] = "JT coefficient"; - table[getPhases()[0].getNumberOfComponents() + 11][i + 2] = - nf.format((getPhase(i).getJouleThomsonCoefficient()), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 11][i + 2] = nf + .format((getPhase(i).getJouleThomsonCoefficient()), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 11][6] = "[K/bar]"; buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 13][0] = "Viscosity"; - table[getPhases()[0].getNumberOfComponents() + 13][i + 2] = - nf.format((getPhase(i).getPhysicalProperties().getViscosity()), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 13][i + 2] = nf + .format((getPhase(i).getPhysicalProperties().getViscosity()), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 13][6] = "[kg/m*sec]"; buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 14][0] = "Conductivity"; - table[getPhases()[0].getNumberOfComponents() + 14][i + 2] = - nf.format(getPhase(i).getPhysicalProperties().getConductivity(), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 14][i + 2] = nf + .format(getPhase(i).getPhysicalProperties().getConductivity(), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 14][6] = "[W/m*K]"; buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 15][0] = "SurfaceTension"; try { if (i < numberOfPhases - 1) { - table[getPhases()[0].getNumberOfComponents() + 15][2] = - nf.format(getInterphaseProperties().getSurfaceTension(0, 1), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 15][2] = nf + .format(getInterphaseProperties().getSurfaceTension(0, 1), buf, test).toString(); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 15][3] = - nf.format(getInterphaseProperties().getSurfaceTension(0, 1), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 15][3] = nf + .format(getInterphaseProperties().getSurfaceTension(0, 1), buf, test).toString(); buf = new StringBuffer(); if (i == 1) { - table[getPhases()[0].getNumberOfComponents() + 17][2] = - nf.format(getInterphaseProperties().getSurfaceTension(0, 2), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 17][2] = nf + .format(getInterphaseProperties().getSurfaceTension(0, 2), buf, test).toString(); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 17][4] = - nf.format(getInterphaseProperties().getSurfaceTension(0, 2), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 17][4] = nf + .format(getInterphaseProperties().getSurfaceTension(0, 2), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 17][6] = "[N/m]"; } if (i == 1) { buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 16][3] = - nf.format(getInterphaseProperties().getSurfaceTension(1, 2), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 16][3] = nf + .format(getInterphaseProperties().getSurfaceTension(1, 2), buf, test).toString(); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 16][4] = - nf.format(getInterphaseProperties().getSurfaceTension(1, 2), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 16][4] = nf + .format(getInterphaseProperties().getSurfaceTension(1, 2), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 16][6] = "[N/m]"; } } @@ -3363,14 +3438,12 @@ public String[][] createTable(String name) { buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 19][0] = "Pressure"; - table[getPhases()[0].getNumberOfComponents() + 19][i + 2] = - Double.toString(getPhase(i).getPressure()); + table[getPhases()[0].getNumberOfComponents() + 19][i + 2] = Double.toString(getPhase(i).getPressure()); table[getPhases()[0].getNumberOfComponents() + 19][6] = "[bar]"; buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 20][0] = "Temperature"; - table[getPhases()[0].getNumberOfComponents() + 20][i + 2] = - Double.toString(getPhase(i).getTemperature()); + table[getPhases()[0].getNumberOfComponents() + 20][i + 2] = Double.toString(getPhase(i).getTemperature()); table[getPhases()[0].getNumberOfComponents() + 20][6] = "[K]"; Double.toString(getPhase(i).getTemperature()); @@ -3382,8 +3455,8 @@ public String[][] createTable(String name) { buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 23][0] = "Mixing Rule"; try { - table[getPhases()[0].getNumberOfComponents() + 23][i + 2] = - ((PhaseEosInterface) getPhase(i)).getMixingRuleName(); + table[getPhases()[0].getNumberOfComponents() + 23][i + 2] = ((PhaseEosInterface) getPhase(i)) + .getMixingRuleName(); } catch (Exception e) { table[getPhases()[0].getNumberOfComponents() + 23][i + 2] = "?"; // logger.error("error",e); @@ -3400,6 +3473,12 @@ public String[][] createTable(String name) { return table; } + /** {@inheritDoc} */ + @Override + public void display() { + display(this.getFluidName()); + } + /** {@inheritDoc} */ @Override public void display(String name) { @@ -3408,7 +3487,7 @@ public void display(String name) { Container dialogContentPane = dialog.getContentPane(); dialogContentPane.setLayout(new BorderLayout()); - String[] names = {"", "Feed", "Phase 1", "Phase 2", "Phase 3", "Phase 4", "Unit"}; + String[] names = { "", "Feed", "Phase 1", "Phase 2", "Phase 3", "Phase 4", "Unit" }; String[][] table = createTable(name); JTable Jtab = new JTable(table, names); JScrollPane scrollpane = new JScrollPane(Jtab); @@ -3424,12 +3503,23 @@ public void display(String name) { dialog.setVisible(true); } + /** + *+ * write. + *
+ * + * @return a {@link java.lang.String} object + */ + public String write() { + // create a String description of the system + return ""; + } + /** {@inheritDoc} */ @Override public void write(String name, String filename, boolean newfile) { String[][] table = createTable(name); - neqsim.dataPresentation.fileHandeling.createTextFile.TextFile file = - new neqsim.dataPresentation.fileHandeling.createTextFile.TextFile(); + neqsim.dataPresentation.fileHandeling.createTextFile.TextFile file = new neqsim.dataPresentation.fileHandeling.createTextFile.TextFile(); if (newfile) { file.newFile(filename); } @@ -3667,8 +3757,7 @@ public void save(String name) { public SystemInterface readObject(int ID) { ResultSet rs = null; SystemThermo tempSystem = null; - neqsim.util.database.NeqSimBlobDatabase database = - new neqsim.util.database.NeqSimBlobDatabase(); + neqsim.util.database.NeqSimBlobDatabase database = new neqsim.util.database.NeqSimBlobDatabase(); try { java.sql.Connection con = database.openConnection(); String sqlStr = "SELECT FLUID FROM fluid_blobdb WHERE ID=" + Integer.toString(ID); @@ -3676,8 +3765,7 @@ public SystemInterface readObject(int ID) { rs = ps.executeQuery(); if (rs.next()) { - try (ObjectInputStream ins = - new ObjectInputStream(new ByteArrayInputStream(rs.getBytes("FLUID")))) { + try (ObjectInputStream ins = new ObjectInputStream(new ByteArrayInputStream(rs.getBytes("FLUID")))) { tempSystem = (SystemThermo) ins.readObject(); } } @@ -3724,21 +3812,20 @@ public void saveObject(int ID, String text) { byte[] byteObject = fout.toByteArray(); ByteArrayInputStream inpStream = new ByteArrayInputStream(byteObject); - neqsim.util.database.NeqSimBlobDatabase database = - new neqsim.util.database.NeqSimBlobDatabase(); + neqsim.util.database.NeqSimBlobDatabase database = new neqsim.util.database.NeqSimBlobDatabase(); try { java.sql.Connection con = database.openConnection(); - java.sql.PreparedStatement ps = - con.prepareStatement("REPLACE INTO fluid_blobdb (ID, FLUID) VALUES (?,?)"); + java.sql.PreparedStatement ps = con.prepareStatement("REPLACE INTO fluid_blobdb (ID, FLUID) VALUES (?,?)"); ps.setInt(1, ID); ps.setBlob(2, inpStream); ps.executeUpdate(); /* * if (!text.isEmpty()) { ps = con.prepareStatement( - * "REPLACE INTO fluidinfo (ID, TEXT) VALUES (?,?)"); ps.setInt(1, ID); ps.setString(2, text); + * "REPLACE INTO fluidinfo (ID, TEXT) VALUES (?,?)"); ps.setInt(1, ID); + * ps.setString(2, text); * } * * ps.executeUpdate(); @@ -3775,8 +3862,7 @@ public void saveObjectToFile(String filePath, String fluidName) { @Override public SystemInterface readObjectFromFile(String filePath, String fluidName) { SystemThermo tempSystem = null; - try (ObjectInputStream objectinputstream = - new ObjectInputStream(new FileInputStream(filePath))) { + try (ObjectInputStream objectinputstream = new ObjectInputStream(new FileInputStream(filePath))) { tempSystem = (SystemThermo) objectinputstream.readObject(); } catch (Exception e) { logger.error(e.toString()); @@ -3813,18 +3899,19 @@ public java.lang.String getFluidName() { public void setFluidName(java.lang.String fluidName) { this.fluidName = fluidName; } - + public void addToComponentNames(java.lang.String name) { - for(int j=0;j- * Constructor for SystemUMRPRUMCEosNew. - *
- */ - public SystemUMRPRUMCEosNew() { - super(); - setBmixType(1); - modelName = "UMR-PRU-MC-EoS-New"; - } +import neqsim.thermo.phase.PhasePrEosvolcor; - /** - *- * Constructor for SystemUMRPRUMCEosNew. - *
- * - * @param T a double - * @param P a double - */ - public SystemUMRPRUMCEosNew(double T, double P) { - super(T, P); - modelName = "UMR-PRU-MC-EoS_new"; - attractiveTermNumber = 13; - } +/** + * This class defines a thermodynamic system using the UMR-PRU with MC paramters equation of state + */ +public class SystemUMRPRUMCEosNew extends SystemUMRPRUMCEos { - /** - *- * Constructor for SystemUMRPRUMCEosNew. - *
- * - * @param T a double - * @param P a double - * @param solidCheck a boolean - */ - public SystemUMRPRUMCEosNew(double T, double P, boolean solidCheck) { - super(T, P, solidCheck); + public SystemUMRPRUMCEosNew() { + super(); + modelName = "UMR-PRU-MC-EoS-New"; + attractiveTermNumber = 19; + useVolumeCorrection(false); + for (int i = 0; i < numberOfPhases; i++) { + phaseArray[i] = new PhasePrEosvolcor(); + phaseArray[i].setTemperature(298.15); + phaseArray[i].setPressure(1.0); + phaseArray[i].useVolumeCorrection(false); } + } - /** {@inheritDoc} */ - @Override - public SystemUMRPRUMCEos clone() { - SystemUMRPRUMCEos clonedSystem = null; - try { - clonedSystem = (SystemUMRPRUMCEosNew) super.clone(); - } catch (Exception e) { - logger.error("Cloning failed.", e); - } - - return clonedSystem; + public SystemUMRPRUMCEosNew(double T, double P) { + super(T, P); + modelName = "UMR-PRU-MC-EoS-New"; + attractiveTermNumber = 19; + useVolumeCorrection(false); + for (int i = 0; i < numberOfPhases; i++) { + phaseArray[i] = new PhasePrEosvolcor(); + phaseArray[i].setTemperature(T); + phaseArray[i].setPressure(P); + phaseArray[i].useVolumeCorrection(false); } + } + } diff --git a/src/main/java/neqsim/thermo/system/SystemUNIFAC.java b/src/main/java/neqsim/thermo/system/SystemUNIFAC.java index 29f5a82ac3..7a290e2825 100644 --- a/src/main/java/neqsim/thermo/system/SystemUNIFAC.java +++ b/src/main/java/neqsim/thermo/system/SystemUNIFAC.java @@ -5,8 +5,8 @@ import neqsim.thermo.phase.PhaseSrkEos; /** - * This class defines a thermodynamic system using the SRK equation of state for gas and Unifac for - * liquids + * This class defines a thermodynamic system using the Unifac for liquids with SRK equation of state + * for gas * * @author Even Solbraa */ diff --git a/src/main/java/neqsim/thermo/system/SystemUNIFACpsrk.java b/src/main/java/neqsim/thermo/system/SystemUNIFACpsrk.java index f39576eb98..f41a78ca7f 100644 --- a/src/main/java/neqsim/thermo/system/SystemUNIFACpsrk.java +++ b/src/main/java/neqsim/thermo/system/SystemUNIFACpsrk.java @@ -5,7 +5,7 @@ import neqsim.thermo.phase.PhaseSrkEos; /** - * This class defines a thermodynamic system using the SRK equation of state + * This class defines a thermodynamic system using the UNIFAC for liquid and PSRK EoS for gas * * @author Even Solbraa */ diff --git a/src/main/java/neqsim/thermo/util/GERG/DETAIL.java b/src/main/java/neqsim/thermo/util/GERG/DETAIL.java index 01197c6a68..e792dfb9ac 100644 --- a/src/main/java/neqsim/thermo/util/GERG/DETAIL.java +++ b/src/main/java/neqsim/thermo/util/GERG/DETAIL.java @@ -460,10 +460,10 @@ static void xTermsDetail(double[] x) { } /** - * @param T - * @param D - * @param x - * @param a0 + * @param T ... + * @param D ... + * @param x ... + * @param a0 ... */ static void Alpha0Detail(double T, double D, double[] x, doubleW[] a0) { // Private Sub Alpha0Detail(T, D, x, a0) @@ -534,11 +534,11 @@ static void Alpha0Detail(double T, double D, double[] x, doubleW[] a0) { } /** - * @param itau - * @param idel - * @param T - * @param D - * @param ar + * @param itau .... + * @param idel ... + * @param T ... + * @param D ... + * @param ar ... */ static void AlpharDetail(int itau, int idel, double T, double D, doubleW[][] ar) { // Private Sub AlpharDetail(itau, idel, T, D, ar) diff --git a/src/main/java/neqsim/thermo/util/GERG/GERG2008.java b/src/main/java/neqsim/thermo/util/GERG/GERG2008.java index 490572eb90..165928b8d1 100644 --- a/src/main/java/neqsim/thermo/util/GERG/GERG2008.java +++ b/src/main/java/neqsim/thermo/util/GERG/GERG2008.java @@ -428,9 +428,9 @@ public static void PropertiesGERG(double T, double D, double[] x, doubleW P, dou } /** - * @param x - * @param Tr - * @param Dr + * @param x ... + * @param Tr ... + * @param Dr ... */ // The following routines are low-level routines that should not be called outside of this code. static void ReducingParametersGERG(double[] x, doubleW Tr, doubleW Dr) { @@ -491,10 +491,10 @@ static void ReducingParametersGERG(double[] x, doubleW Tr, doubleW Dr) { } /** - * @param T - * @param D - * @param x - * @param a0 + * @param T ... + * @param D ... + * @param x ... + * @param a0 ... */ static void Alpha0GERG(double T, double D, double[] x, doubleW[] a0) { // Private Sub Alpha0GERG(T, D, x, a0) @@ -561,12 +561,12 @@ static void Alpha0GERG(double T, double D, double[] x, doubleW[] a0) { } /** - * @param itau - * @param idelta - * @param T - * @param D - * @param x - * @param ar + * @param itau ... + * @param idelta ... + * @param T ... + * @param D .... + * @param x .... + * @param ar ... */ static void AlpharGERG(int itau, int idelta, double T, double D, double[] x, doubleW[][] ar) { // Private Sub AlpharGERG(itau, idelta, T, D, x, ar) @@ -715,8 +715,8 @@ static void AlpharGERG(int itau, int idelta, double T, double D, double[] x, dou } /** - * @param lntau - * @param x + * @param lntau ... + * @param x .... */ static void tTermsGERG(double lntau, double[] x) { // Private Sub tTermsGERG(lntau, x) @@ -761,9 +761,9 @@ static void tTermsGERG(double lntau, double[] x) { } /** - * @param x - * @param Tcx - * @param Dcx + * @param x composition + * @param Tcx temperature in Kelvin + * @param Dcx density */ static void PseudoCriticalPointGERG(double[] x, doubleW Tcx, doubleW Dcx) { // PseudoCriticalPointGERG(x, Tcx, Dcx) diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/Procede/CH4CO2WaterMDEA/TestIonicInteractionParameterFittingCH4.java b/src/main/java/neqsim/thermo/util/parameterFitting/Procede/CH4CO2WaterMDEA/TestIonicInteractionParameterFittingCH4.java index 6365a16361..b37ddd59ca 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/Procede/CH4CO2WaterMDEA/TestIonicInteractionParameterFittingCH4.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/Procede/CH4CO2WaterMDEA/TestIonicInteractionParameterFittingCH4.java @@ -12,103 +12,105 @@ import neqsim.util.database.NeqSimDataBase; /** - *TestIonicInteractionParameterFittingCH4 class.
+ *+ * TestIonicInteractionParameterFittingCH4 class. + *
* * @author Even Solbraa * @version $Id: $Id */ public class TestIonicInteractionParameterFittingCH4 { - static Logger logger = LogManager.getLogger(TestIonicInteractionParameterFittingCH4.class); - - /** - *main.
- * - * @param args an array of {@link java.lang.String} objects - */ - @SuppressWarnings("unused") - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - @SuppressWarnings("unused") - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - LevenbergMarquardt optim = new LevenbergMarquardt(); - ArrayList+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList+ * Constructor for HydrateFunction. + *
+ */ + public HydrateFunction() { + // params = new double[3]; + } - /** {@inheritDoc} */ - @Override - public double calcValue(double[] dependentValues) { - try { - thermoOps.hydrateFormationTemperature(1); - // System.out.println("temperature " + system.getTemperature()); - } catch (Exception e) { - logger.error(e.toString()); - } - return system.getTemperature(); + /** {@inheritDoc} */ + @Override + public double calcValue(double[] dependentValues) { + try { + thermoOps.hydrateFormationTemperature(1); + // System.out.println("temperature " + system.getTemperature()); + } catch (Exception e) { + logger.error(e.toString()); } + return system.getTemperature(); + } - /** {@inheritDoc} */ - @Override - public double calcTrueValue(double val) { - return val; - } + /** {@inheritDoc} */ + @Override + public double calcTrueValue(double val) { + return val; + } - /** {@inheritDoc} */ - @Override - public void setFittingParams(int i, double value) { - int structure = 1; - params[i] = value; - // if(i==0) ((ComponentHydrate) - // system.getPhase(4).getComponent("water")).setDGfHydrate(value, structure); - // if(i==1) ((ComponentHydrate) - // system.getPhase(4).getComponent("water")).setDHfHydrate(value, structure); - // int k=0; + /** {@inheritDoc} */ + @Override + public void setFittingParams(int i, double value) { + // int structure = 1; + params[i] = value; + // if(i==0) ((ComponentHydrate) + // system.getPhase(4).getComponent("water")).setDGfHydrate(value, structure); + // if(i==1) ((ComponentHydrate) + // system.getPhase(4).getComponent("water")).setDHfHydrate(value, structure); + // int k=0; - // if(i==0) ((ComponentHydrate) - // system.getPhase(4).getComponent("water")).setEmptyHydrateVapourPressureConstant(0,0, - // value); - // if(i==1) ((ComponentHydrate) - // system.getPhase(4).getComponent("water")).setEmptyHydrateVapourPressureConstant(0,1, - // value); + // if(i==0) ((ComponentHydrate) + // system.getPhase(4).getComponent("water")).setEmptyHydrateVapourPressureConstant(0,0, + // value); + // if(i==1) ((ComponentHydrate) + // system.getPhase(4).getComponent("water")).setEmptyHydrateVapourPressureConstant(0,1, + // value); - // for(int k=0;k+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + LevenbergMarquardt optim = new LevenbergMarquardt(); + ArrayList- * Constructor for BaseOperation. - *
- */ - public BaseOperation() {} + /** + *+ * Constructor for BaseOperation. + *
+ */ + public BaseOperation() {} - /** {@inheritDoc} */ - @Override - public double[] get(String name) { - return new double[3]; - } + /** {@inheritDoc} */ + @Override + public double[] get(String name) { + return new double[3]; + } - /** {@inheritDoc} */ - @Override - public String[][] getResultTable() { - return new String[10][3]; - } + /** {@inheritDoc} */ + @Override + public String[][] getResultTable() { + return new String[10][3]; + } - /** {@inheritDoc} */ - @Override - public SystemInterface getThermoSystem() { - return null; - } + /** {@inheritDoc} */ + @Override + public SystemInterface getThermoSystem() { + return null; + } - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - return null; - } + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + return null; + } - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} - /** {@inheritDoc} */ - @Override - public void createNetCdfFile(String name) {} + /** {@inheritDoc} */ + @Override + public double[][] getPoints(int i) { + return null; + } - /** {@inheritDoc} */ - @Override - public double[][] getPoints(int i) { - return null; - } - - /** {@inheritDoc} */ - @Override - public void addData(String name, double[][] data) {} + /** {@inheritDoc} */ + @Override + public void addData(String name, double[][] data) {} } diff --git a/src/main/java/neqsim/thermodynamicOperations/OperationInterface.java b/src/main/java/neqsim/thermodynamicOperations/OperationInterface.java index 1d6cb4d2d3..18a6103b86 100644 --- a/src/main/java/neqsim/thermodynamicOperations/OperationInterface.java +++ b/src/main/java/neqsim/thermodynamicOperations/OperationInterface.java @@ -52,15 +52,6 @@ public interface OperationInterface extends Runnable, java.io.Serializable { */ public String[][] getResultTable(); - /** - *- * createNetCdfFile. - *
- * - * @param name a {@link java.lang.String} object - */ - public void createNetCdfFile(String name); - /** ** printToFile. diff --git a/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java b/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java index cf0f8773a7..0b4c4aaeb6 100644 --- a/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java +++ b/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java @@ -70,1965 +70,1971 @@ * @version $Id: $Id */ public class ThermodynamicOperations implements java.io.Serializable, Cloneable { - private static final long serialVersionUID = 1000; - - private Thread thermoOperationThread = new Thread(); - private OperationInterface operation = null; - SystemInterface system = null; - boolean writeFile = false; - String fileName = null; - private boolean runAsThread = false; - protected String[][] resultTable = null; - static Logger logger = LogManager.getLogger(ThermodynamicOperations.class); - - /** - *
- * Constructor for ThermodynamicOperations. - *
- */ - public ThermodynamicOperations() { - } - - /** - *- * Constructor for ThermodynamicOperations. - *
- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public ThermodynamicOperations(SystemInterface system) { - this.system = system; - } - - /** - *
- * Setter for the field system
.
- *
- * TPSolidflash. - *
- */ - public void TPSolidflash() { - operation = new SolidFlash1(system); - getOperation().run(); - } - - /** - * Method to perform a flash at given temperature, pressure and specified volume - * The number of - * moles in the system are changed to match the specified volume. - * - * @param volumeSpec is the specified volume - * @param unit Supported units are m3 - */ - public void TPVflash(double volumeSpec, String unit) { - unit = "m3"; - TPflash(); - double startVolume = system.getVolume(unit); - system.setTotalNumberOfMoles(system.getNumberOfMoles() * volumeSpec / startVolume); - system.init(3); - } - - /** - *- * TPflash. - *
- */ - public void TPflash() { - double flowRate = system.getTotalNumberOfMoles(); - double minimumFlowRate = 1e-50; - if (flowRate < 1e-3) { - system.setTotalNumberOfMoles(1.0); - } - operation = new neqsim.thermodynamicOperations.flashOps.TPflash(system, - system.doSolidPhaseCheck()); - if (!isRunAsThread()) { - getOperation().run(); - } else { - run(); - } - if (flowRate < 1e-3) { - if (flowRate < minimumFlowRate) { - system.setTotalNumberOfMoles(minimumFlowRate); - } else { - system.setTotalNumberOfMoles(flowRate); - } - system.init(2); - } - } - - /** - *- * saturateWithWater. - *
- */ - public void saturateWithWater() { - operation = new SaturateWithWater(system); - getOperation().run(); - } - - /** - *- * TPflash. - *
- * - * @param checkSolids a boolean - */ - public void TPflash(boolean checkSolids) { - operation = new neqsim.thermodynamicOperations.flashOps.TPflash(system, checkSolids); - getOperation().run(); - } - - /** - *- * TPgradientFlash. - *
- * - * @param height a double - * @param temperature a double - * @return a {@link neqsim.thermo.system.SystemInterface} object - */ - public SystemInterface TPgradientFlash(double height, double temperature) { - operation = new TPgradientFlash(system, height, temperature); - getOperation().run(); - return operation.getThermoSystem(); - } - - /** - *- * dTPflash. - *
- * - * @param comps an array of {@link java.lang.String} objects - */ - public void dTPflash(String[] comps) { - operation = new dTPflash(system, comps); - getOperation().run(); - } - - /** - *- * chemicalEquilibrium. - *
- */ - public void chemicalEquilibrium() { - if (system.isChemicalSystem()) { - operation = new neqsim.thermodynamicOperations.chemicalEquilibrium.ChemicalEquilibrium( - system); - getOperation().run(); - } - } - - /** - *- * PHflash. - *
- * - * @param Hspec a double - * @param type a int - */ - public void PHflash(double Hspec, int type) { - if (system.getPhase(0).getNumberOfComponents() == 1) { - operation = new PHflashSingleComp(system, Hspec, type); - } else { - operation = new PHflash(system, Hspec, type); - } - getOperation().run(); - } - - /** - * Method to perform a PH flash calculation - * - * @param Hspec is the enthalpy in the specified unit - * @param enthalpyUnit Supported units are J, J/mol, J/kg and kJ/kg - */ - public void PHflash(double Hspec, String enthalpyUnit) { - double conversionFactor = 1.0; - switch (enthalpyUnit) { - case "J": - conversionFactor = 1.0; - break; - case "J/mol": - conversionFactor = 1.0 / system.getTotalNumberOfMoles(); - break; - case "J/kg": - conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); - break; - case "kJ/kg": - conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; - break; - } - PHflash(Hspec / conversionFactor); - } - - /** - * Method to perform a PH flash calculation - * - * @param Hspec is the enthalpy in unit Joule to be held constant - */ - public void PHflash(double Hspec) { - this.PHflash(Hspec, 0); - } - - /** - * Method to perform a PH flash calculation based on GERG2008 EoS - * - * @param Hspec is the enthalpy in unit Joule to be held constant - */ - public void PHflashGERG2008(double Hspec) { - operation = new neqsim.thermodynamicOperations.flashOps.PHflashGERG2008(system, Hspec); - getOperation().run(); - } - - /** - *- * PUflash. - *
- * - * @param Uspec a double - */ - public void PUflash(double Uspec) { - operation = new neqsim.thermodynamicOperations.flashOps.PUflash(system, Uspec); - getOperation().run(); - } - - /** - *- * PUflash. - *
- * - * @param Pspec a double - * @param Uspec a double - * @param unitPressure a {@link java.lang.String} object - * @param unitEnergy a {@link java.lang.String} object - */ - public void PUflash(double Pspec, double Uspec, String unitPressure, String unitEnergy) { - system.setPressure(Pspec, unitPressure); - PUflash(Uspec, unitEnergy); - } - - /** - *- * PUflash. - *
- * - * @param Uspec a double - * @param unitEnergy a {@link java.lang.String} object - */ - public void PUflash(double Uspec, String unitEnergy) { - double conversionFactorEntr = 1.0; - switch (unitEnergy) { - case "J": - conversionFactorEntr = 1.0; - break; - case "J/mol": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles(); - break; - case "J/kg": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); - break; - case "kJ/kg": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; - break; - } - PUflash(Uspec / conversionFactorEntr); - } - - /** - *- * PHflash2. - *
- * - * @param Hspec a double - * @param type a int - */ - public void PHflash2(double Hspec, int type) { - operation = new PHflash(system, Hspec, type); - getOperation().run(); - } - - /** - *- * criticalPointFlash. - *
- */ - public void criticalPointFlash() { - operation = new CriticalPointFlash(system); - getOperation().run(); - } - - /** - *- * PHsolidFlash. - *
- * - * @param Hspec a double - */ - public void PHsolidFlash(double Hspec) { - operation = new PHsolidFlash(system, Hspec); - getOperation().run(); - } - - /** - * Method to perform a PS flash calculation for a specified entropy and pressure - * - * @param Sspec is the entropy in the specified unit - * @param unit Supported units are J/K, J/molK, J/kgK and kJ/kgK - */ - public void PSflash(double Sspec, String unit) { - double conversionFactor = 1.0; - switch (unit) { - case "J/K": - conversionFactor = 1.0; - break; - case "J/molK": - conversionFactor = 1.0 / system.getTotalNumberOfMoles(); - break; - case "J/kgK": - conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); - break; - case "kJ/kgK": - conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; - break; - } - PSflash(Sspec / conversionFactor); - } - - /** - * Method to perform a TS flash calculation for a specified entropy and pressure - * - * @param Sspec is the entropy in the specified unit - * @param unit Supported units are J/K, J/molK, J/kgK and kJ/kgK - */ - public void TSflash(double Sspec, String unit) { - double conversionFactor = 1.0; - switch (unit) { - case "J/K": - conversionFactor = 1.0; - break; - case "J/molK": - conversionFactor = 1.0 / system.getTotalNumberOfMoles(); - break; - case "J/kgK": - conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); - break; - case "kJ/kgK": - conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; - break; - } - TSflash(Sspec / conversionFactor); - } - - /** - *- * PSflash. - *
- * - * @param Sspec a double - */ - public void PSflash(double Sspec) { - if (system.getPhase(0).getNumberOfComponents() == 1) { - operation = new PSflashSingleComp(system, Sspec, 0); - } else { - operation = new PSFlash(system, Sspec, 0); - } - getOperation().run(); - } - - /** - *- * PSflashGERG2008. - *
- * Run a flash at constant pressure and entropy using the GERG2008 EoS - * - * @param Sspec is the specidfied entropy - */ - public void PSflashGERG2008(double Sspec) { - operation = new PSFlashGERG2008(system, Sspec); - getOperation().run(); - } - - /** - *- * TSflash. - *
- * - * @param Sspec a double - */ - public void TSflash(double Sspec) { - operation = new TSFlash(system, Sspec); - getOperation().run(); - } - - /** - *- * PSflash2. - *
- * - * @param Sspec a double - */ - public void PSflash2(double Sspec) { - operation = new PSFlash(system, Sspec, 0); - getOperation().run(); - } - - /** - *- * VSflash. - *
- * - * @param volume a double - * @param entropy a double - * @param unitVol a {@link java.lang.String} object - * @param unitEntropy a {@link java.lang.String} object - */ - public void VSflash(double volume, double entropy, String unitVol, String unitEntropy) { - double conversionFactorV = 1.0; - double conversionFactorEntr = 1.0; - - switch (unitVol) { - case "m3": - conversionFactorV = 1.0e5; - break; - } - - switch (unitEntropy) { - case "J/K": - conversionFactorEntr = 1.0; - break; - case "J/molK": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles(); - break; - case "J/kgK": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); - break; - case "kJ/kgK": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; - break; - } - VSflash(volume * conversionFactorV, entropy / conversionFactorEntr); - } - - /** - *- * VSflash. - *
- * - * @param volume a double - * @param entropy a double - */ - public void VSflash(double volume, double entropy) { - operation = new neqsim.thermodynamicOperations.flashOps.VSflash(system, volume, entropy); - getOperation().run(); - } - - /** - *- * TVflash. - *
- * - * @param Vspec a double - * @param unit a {@link java.lang.String} object - */ - public void TVflash(double Vspec, String unit) { - double conversionFactor = 1.0; - switch (unit) { - case "m3": - conversionFactor = 1.0e5; - break; - } - TVflash(Vspec * conversionFactor); - } - - /** - *- * TVflash. - *
- * - * @param Vspec a double - */ - public void TVflash(double Vspec) { - operation = new TVflash(system, Vspec); - getOperation().run(); - } - - /** - *- * PVrefluxFlash. - *
- * - * @param refluxspec a double - * @param refluxPhase a int - */ - public void PVrefluxFlash(double refluxspec, int refluxPhase) { - operation = new PVrefluxflash(system, refluxspec, refluxPhase); - getOperation().run(); - } - - /** - *- * VHflash. - *
- * - * @param Vspec a double - * @param Hspec a double - */ - public void VHflash(double Vspec, double Hspec) { - operation = new VHflashQfunc(system, Vspec, Hspec); - getOperation().run(); - } - - /** - *- * VHflash. - *
- * - * @param volume a double - * @param enthalpy a double - * @param unitVol a {@link java.lang.String} object - * @param unitEnthalpy a {@link java.lang.String} object - */ - public void VHflash(double volume, double enthalpy, String unitVol, String unitEnthalpy) { - double conversionFactorV = 1.0; - double conversionFactorEntr = 1.0; - - switch (unitVol) { - case "m3": - conversionFactorV = 1.0e5; - break; - } - - switch (unitEnthalpy) { - case "J/K": - conversionFactorEntr = 1.0; - break; - case "J/mol": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles(); - break; - case "J/kg": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); - break; - case "kJ/kg": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; - break; - } - VHflash(volume * conversionFactorV, enthalpy / conversionFactorEntr); - } - - /** - *- * VUflash. - *
- * - * @param volume a double - * @param energy a double - * @param unitVol a {@link java.lang.String} object - * @param unitEnergy a {@link java.lang.String} object - */ - public void VUflash(double volume, double energy, String unitVol, String unitEnergy) { - double conversionFactorV = 1.0; - double conversionFactorEntr = 1.0; - - switch (unitVol) { - case "m3": - conversionFactorV = 1.0e5; - break; - } - - switch (unitEnergy) { - case "J/K": - conversionFactorEntr = 1.0; - break; - case "J/mol": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles(); - break; - case "J/kg": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); - break; - case "kJ/kg": - conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; - break; - } - VUflash(volume * conversionFactorV, energy / conversionFactorEntr); - } - - /** - *- * VUflash. - *
- * - * @param Vspec a double - * @param Uspec a double - */ - public void VUflash(double Vspec, double Uspec) { - operation = new VUflashQfunc(system, Vspec, Uspec); - getOperation().run(); - } - - /** - *- * bubblePointTemperatureFlash. - *
- * - * @throws java.lang.Exception if any. - */ - public void bubblePointTemperatureFlash() throws Exception { - constantDutyFlashInterface operation = new bubblePointTemperatureNoDer(system); - operation.run(); - if (Double.isNaN(system.getTemperature()) || operation.isSuperCritical()) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "bubblePointTemperatureFlash", - "Could not find solution - possible no bubble point exists"); - } - } - - /** - *- * freezingPointTemperatureFlash. - *
- * - * @throws java.lang.Exception if any. - */ - public void freezingPointTemperatureFlash() throws Exception { - operation = new freezingPointTemperatureFlash(system); - getOperation().run(); - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "freezingPointTemperatureFlash", - "Could not find solution - possible no freezing point exists"); - } - } - - /** - *- * freezingPointTemperatureFlash. - *
- * - * @param phaseName a {@link java.lang.String} object - * @throws java.lang.Exception if any. - */ - public void freezingPointTemperatureFlash(String phaseName) throws Exception { - operation = new freezingPointTemperatureFlash(system); - getOperation().run(); - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "freezingPointTemperatureFlash", - "Could not find solution - possible no freezing point exists"); - } - } - - /** - *- * waterDewPointTemperatureFlash. - *
- * - * @throws java.lang.Exception if any. - */ - public void waterDewPointTemperatureFlash() throws Exception { - operation = new waterDewPointTemperatureFlash(system); - getOperation().run(); - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "waterDewPointTemperatureFlash", - "Could not find solution - possible no dew point exists"); - } - } - - /** - *- * waterDewPointTemperatureMultiphaseFlash. - *
- * - * @throws java.lang.Exception if any. - */ - public void waterDewPointTemperatureMultiphaseFlash() throws Exception { - operation = new waterDewPointTemperatureMultiphaseFlash(system); - getOperation().run(); - } - - /** - *- * waterPrecipitationTemperature. - *
- * - * @throws java.lang.Exception if any. - */ - public void waterPrecipitationTemperature() throws Exception { - double lowTemperature = 0.0; - dewPointTemperatureFlash(); - - if (system.getTemperature() > lowTemperature) { - lowTemperature = system.getTemperature(); - } - - // if(lowTemperature<273.15 && system.doSolidPhaseCheck()){ - // hydrateFormationTemperature(0); - // if(system.getTemperature()>lowTemperature) lowTemperature = - // system.getTemperature(); - // } - - // if(system.doHydrateCheck()){ - // hydrateFormationTemperature(1); - // if(system.getTemperature()>lowTemperature) lowTemperature = - // system.getTemperature(); - // hydrateFormationTemperature(2); - // if(system.getTemperature()>lowTemperature) lowTemperature = - // system.getTemperature(); - // } - - system.setTemperature(lowTemperature); - // TPflash(); - - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "waterPrecipitationTemperature", - "Could not find solution - possible no dew point exists"); - } - } - - /** - *- * calcSaltSaturation. - *
- * - * @param saltName a {@link java.lang.String} object - * @throws java.lang.Exception if any. - */ - public void calcSaltSaturation(String saltName) throws Exception { - operation = new calcSaltSatauration(system, saltName); - getOperation().run(); - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "calcSaltSaturation", "Could not find solution - possible no dew point exists"); - } - } - - /** - *- * checkScalePotential. - *
- * - * @param phaseNumber a int - * @throws java.lang.Exception if any. - */ - public void checkScalePotential(int phaseNumber) throws Exception { - operation = new checkScalePotential(system, phaseNumber); - getOperation().run(); - resultTable = getOperation().getResultTable(); - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "checkScalePotential", "Could not find solution - possible no dew point exists"); - } - } - - /** - *- * addIonToScaleSaturation. - *
- * - * @param phaseNumber a int - * @param scaleSaltName a {@link java.lang.String} object - * @param nameOfIonToBeAdded a {@link java.lang.String} object - * @throws java.lang.Exception if any. - */ - public void addIonToScaleSaturation(int phaseNumber, String scaleSaltName, - String nameOfIonToBeAdded) throws Exception { - operation = new addIonToScaleSaturation(system, phaseNumber, scaleSaltName, nameOfIonToBeAdded); - getOperation().run(); - resultTable = getOperation().getResultTable(); - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "addIonToScaleSaturation", "Could not find solution - possible no dew point exists"); - } - } - - /** - *- * hydrateFormationPressure. - *
- * - * @throws java.lang.Exception if any. - */ - public void hydrateFormationPressure() throws Exception { - operation = new HydrateFormationPressureFlash(system); - getOperation().run(); - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "hydrateFormationPressure", "Could not find solution - possible no dew point exists"); - } - } - - /** - *- * calcWAT. - *
- * - * @throws java.lang.Exception if any. - */ - public void calcWAT() throws Exception { - operation = new WATcalc(system); - getOperation().run(); - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), "calcWAT", - "Could not find solution - possible no dew point exists"); - } - } - - /** - *- * run. - *
- */ - public void run() { - setThermoOperationThread(new Thread(operation)); - getThermoOperationThread().start(); - } - - /** - *- * waitAndCheckForFinishedCalculation. - *
- * - * @param maxTime a int - * @return a boolean - */ - public boolean waitAndCheckForFinishedCalculation(int maxTime) { - try { - getThermoOperationThread().join(maxTime); - getThermoOperationThread().interrupt(); - } catch (Exception e) { - logger.error("error", e); - } - boolean didFinish = !getThermoOperationThread().isInterrupted(); - // getThermoOperationThread().stop(); - return didFinish; - } - - /** - *- * waitToFinishCalculation. - *
- */ - public void waitToFinishCalculation() { - try { - getThermoOperationThread().join(); - } catch (Exception e) { - logger.error("error", e); - } - } - - /** - *- * calcSolidComlexTemperature. - *
- * - * @throws java.lang.Exception if any. - */ - public void calcSolidComlexTemperature() throws Exception { - operation = new SolidComplexTemperatureCalc(system); - getOperation().run(); - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "calcSolidComlexTemperature", - "error in WAT() - could not find solution - possible no dew point exists"); - } - } - - /** - *- * calcSolidComlexTemperature. - *
- * - * @param comp1 a {@link java.lang.String} object - * @param comp2 a {@link java.lang.String} object - * @throws java.lang.Exception if any. - */ - public void calcSolidComlexTemperature(String comp1, String comp2) throws Exception { - if (operation == null) { - operation = new SolidComplexTemperatureCalc(system, comp1, comp2); - } - getOperation().run(); - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "calcSolidComlexTemperature", - "error in WAT() - could not find solution - possible no dew point exists"); - } - } - - /** - *- * calcImobilePhaseHydrateTemperature. - *
- * - * @param temperature an array of {@link double} objects - * @param pressure an array of {@link double} objects - * @return an array of {@link double} objects - */ - public double[] calcImobilePhaseHydrateTemperature(double[] temperature, double[] pressure) { - double[] hydTemps = new double[temperature.length]; - SystemInterface systemTemp; - ThermodynamicOperations opsTemp; - systemTemp = system.clone(); - - for (int i = 0; i < temperature.length; i++) { - /* - * opsTemp = new ThermodynamicOperations(systemTemp); - * systemTemp.setTemperature(temperature[i]); - * systemTemp.setPressure(pressure[i]); - * systemTemp.init(0); systemTemp.display(); try { - * opsTemp.hydrateFormationTemperature(); } catch (Exception e) { - * logger.error("error",e); } systemTemp.display(); hydTemps[i] = - * systemTemp.getTemperature(); - * - */ - opsTemp = new ThermodynamicOperations(systemTemp); - systemTemp.setTemperature(temperature[i]); - systemTemp.setPressure(pressure[i]); - - opsTemp.TPflash(); - systemTemp.display(); - systemTemp = systemTemp.phaseToSystem(0); - } - - opsTemp = new ThermodynamicOperations(systemTemp); - systemTemp.setHydrateCheck(true); - systemTemp.setMixingRule(9); - try { - opsTemp.hydrateFormationTemperature(); - } catch (Exception e) { - logger.error("error", e); - } - systemTemp.display(); - return hydTemps; - } - - /** - *- * calcTOLHydrateFormationTemperature. - *
- * - * @return a double - */ - public double calcTOLHydrateFormationTemperature() { - TPflash(); - - SystemInterface systemTemp = system.phaseToSystem(0); - ThermodynamicOperations opsTemp = new ThermodynamicOperations(systemTemp); - try { - opsTemp.hydrateFormationTemperature(); - } catch (Exception e) { - logger.error("error", e); - } - systemTemp.display(); - system.setTemperature(systemTemp.getTemperature()); - TPflash(); - return system.getTemperature(); - } - - /** - *- * hydrateInhibitorConcentration. - *
- * - * @param inhibitorName a {@link java.lang.String} object - * @param hydEqTemperature a double - * @throws java.lang.Exception if any. - */ - public void hydrateInhibitorConcentration(String inhibitorName, double hydEqTemperature) - throws Exception { - operation = new HydrateInhibitorConcentrationFlash(system, inhibitorName, hydEqTemperature); - operation.run(); - } - - /** - *- * hydrateInhibitorConcentrationSet. - *
- * - * @param inhibitorName a {@link java.lang.String} object - * @param wtfrac a double - * @throws java.lang.Exception if any. - */ - public void hydrateInhibitorConcentrationSet(String inhibitorName, double wtfrac) - throws Exception { - operation = new HydrateInhibitorwtFlash(system, inhibitorName, wtfrac); - operation.run(); - } - - /** - *- * hydrateFormationTemperature. - *
- * - * @param initialTemperatureGuess a double - * @throws java.lang.Exception if any. - */ - public void hydrateFormationTemperature(double initialTemperatureGuess) throws Exception { - system.setTemperature(initialTemperatureGuess); - operation = new HydrateFormationTemperatureFlash(system); - for (int i = 0; i < system.getPhase(4).getNumberOfComponents(); i++) { - ((ComponentHydrate) system.getPhase(4).getComponent(i)).getHydrateStructure(); - } - if (!isRunAsThread()) { - getOperation().run(); - } else { - run(); - } - } - - /** - *- * hydrateFormationTemperature. - *
- * - * @throws java.lang.Exception if any. - */ - public void hydrateFormationTemperature() throws Exception { - // guessing temperature - double factor = 1.0; - if (system.getPhase(0).hasComponent("methanol")) { - factor -= 2 * system.getPhase(0).getComponent("methanol").getz() - / system.getPhase(0).getComponent("water").getz(); - } - if (system.getPhase(0).hasComponent("MEG")) { - factor -= 2 * system.getPhase(0).getComponent("MEG").getz() - / system.getPhase(0).getComponent("water").getz(); - } - if (factor < 2) { - factor = 2; - } - - system.setTemperature(273.0 + system.getPressure() / 100.0 * 20.0 * factor - 20.0); - if (system.getTemperature() > 298.15) { - system.setTemperature(273.0 + 25.0); - } - // logger.info("guess hydrate temperature " + system.getTemperature()); - operation = new HydrateFormationTemperatureFlash(system); - - for (int i = 0; i < system.getPhase(4).getNumberOfComponents(); i++) { - ((ComponentHydrate) system.getPhase(4).getComponent(i)).getHydrateStructure(); - } - if (!isRunAsThread()) { - getOperation().run(); - } else { - run(); - } - // logger.info("Hydrate structure " + (((ComponentHydrate) - // system.getPhase(4).getComponent("water")).getHydrateStructure() + 1)); - } - - /** - *- * hydrateEquilibriumLine. - *
- * - * @param minimumPressure a double - * @param maximumPressure a double - * @throws java.lang.Exception if any. - */ - public void hydrateEquilibriumLine(double minimumPressure, double maximumPressure) - throws Exception { - operation = new HydrateEquilibriumLine(system, minimumPressure, maximumPressure); - if (!isRunAsThread()) { - getOperation().run(); - } else { - run(); - } - } - - /** - *- * calcCricoP. - *
- * - * @param cricondenBar an array of {@link double} objects - * @param cricondenBarX an array of {@link double} objects - * @param cricondenBarY an array of {@link double} objects - */ - public void calcCricoP(double[] cricondenBar, double[] cricondenBarX, double[] cricondenBarY) { - double phasefraction = 1.0 - 1e-10; - - operation = new CricondenBarFlash(system, fileName, phasefraction, cricondenBar, - cricondenBarX, cricondenBarY); - - getOperation().run(); - } - - /** - *- * calcCricoT. - *
- * - * @param cricondenTherm an array of {@link double} objects - * @param cricondenThermX an array of {@link double} objects - * @param cricondenThermY an array of {@link double} objects - */ - public void calcCricoT(double[] cricondenTherm, double[] cricondenThermX, - double[] cricondenThermY) { - double phasefraction = 1.0 - 1e-10; - - operation = new CricondenThermFlash(system, fileName, phasefraction, cricondenTherm, - cricondenThermX, cricondenThermY); - - getOperation().run(); - } - - /** - *- * waterDewPointLine. - *
- * - * @param minimumPressure a double - * @param maximumPressure a double - * @throws java.lang.Exception if any. - */ - public void waterDewPointLine(double minimumPressure, double maximumPressure) throws Exception { - operation = new WaterDewPointEquilibriumLine(system, minimumPressure, maximumPressure); - if (!isRunAsThread()) { - getOperation().run(); - } else { - run(); - } - } - - /** - *- * hydrateFormationTemperature. - *
- * - * @param structure a int - * @throws java.lang.Exception if any. - */ - public void hydrateFormationTemperature(int structure) throws Exception { - system.setTemperature(273.0 + 1.0); - if (structure == 0) { - system.setSolidPhaseCheck("water"); - system.setHydrateCheck(true); - operation = new freezingPointTemperatureFlash(system); - } else { - operation = new HydrateFormationTemperatureFlash(system); - } - - for (int i = 0; i < system.getPhase(4).getNumberOfComponents(); i++) { - ((ComponentHydrate) system.getPhases()[4].getComponent(i)) - .setHydrateStructure(structure - 1); - } - if (!isRunAsThread()) { - getOperation().run(); - } else { - run(); - } - - if (Double.isNaN(system.getTemperature())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "hydrateFormationTemperature", - "Could not find solution - possible no dew point exists"); - } - } - - /** - *- * calcCricondenBar. - *
- * - * @return a double - */ - public double calcCricondenBar() { - system.init(0); - operation = new cricondebarFlash(system); - // operation = new CricondenBarFlash(system); - - // operation = new cricondenBarTemp1(system); - operation.run(); - return system.getPressure(); - } - - /** - *- * bubblePointPressureFlash. - *
- * - * @throws java.lang.Exception if any. - */ - public void bubblePointPressureFlash() throws Exception { - system.init(0); - constantDutyFlashInterface operation = new constantDutyPressureFlash(system); - system.setBeta(1, 1.0 - 1e-10); - system.setBeta(0, 1e-10); - operation.run(); - if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "bubblePointPressureFlash", "Could not find solution - possible no dew point exists"); - } - } + private static final long serialVersionUID = 1000; + + private Thread thermoOperationThread = new Thread(); + private OperationInterface operation = null; + SystemInterface system = null; + boolean writeFile = false; + String fileName = null; + private boolean runAsThread = false; + protected String[][] resultTable = null; + static Logger logger = LogManager.getLogger(ThermodynamicOperations.class); + + /** + *+ * Constructor for ThermodynamicOperations. + *
+ */ + public ThermodynamicOperations() {} + + /** + *+ * Constructor for ThermodynamicOperations. + *
+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public ThermodynamicOperations(SystemInterface system) { + this.system = system; + } + + /** + *
+ * Setter for the field system
.
+ *
+ * TPSolidflash. + *
+ */ + public void TPSolidflash() { + operation = new SolidFlash1(system); + getOperation().run(); + } + + /** + * Method to perform a flash at given temperature, pressure and specified volume The number of + * moles in the system are changed to match the specified volume. + * + * @param volumeSpec is the specified volume + * @param unit Supported units are m3 + */ + public void TPVflash(double volumeSpec, String unit) { + unit = "m3"; + TPflash(); + double startVolume = system.getVolume(unit); + system.setTotalNumberOfMoles(system.getNumberOfMoles() * volumeSpec / startVolume); + system.init(3); + } + + /** + *+ * TPflash. + *
+ */ + public void TPflash() { + double flowRate = system.getTotalNumberOfMoles(); + double minimumFlowRate = 1e-50; + if (flowRate < 1e-3) { + system.setTotalNumberOfMoles(1.0); + system.init(1); + } + operation = + new neqsim.thermodynamicOperations.flashOps.TPflash(system, system.doSolidPhaseCheck()); + if (!isRunAsThread()) { + getOperation().run(); + } else { + run(); + } + if (flowRate < 1e-3) { + if (flowRate < minimumFlowRate) { + system.setTotalNumberOfMoles(minimumFlowRate); + } else { + system.setTotalNumberOfMoles(flowRate); + } + system.init(2); + } + } + + /** + *+ * TPflash. + *
+ * + * @param checkSolids a boolean + */ + public void TPflash(boolean checkSolids) { + operation = new neqsim.thermodynamicOperations.flashOps.TPflash(system, checkSolids); + getOperation().run(); + } + + /** + *+ * TPgradientFlash. + *
+ * + * @param height a double + * @param temperature a double + * @return a {@link neqsim.thermo.system.SystemInterface} object + */ + public SystemInterface TPgradientFlash(double height, double temperature) { + operation = new TPgradientFlash(system, height, temperature); + getOperation().run(); + return operation.getThermoSystem(); + } + + /** + *+ * dTPflash. + *
+ * + * @param comps an array of {@link java.lang.String} objects + */ + public void dTPflash(String[] comps) { + operation = new dTPflash(system, comps); + getOperation().run(); + } + + /** + *+ * saturateWithWater. + *
+ */ + public void saturateWithWater() { + operation = new SaturateWithWater(system); + getOperation().run(); + } + + /** + *+ * chemicalEquilibrium. + *
+ */ + public void chemicalEquilibrium() { + if (system.isChemicalSystem()) { + operation = + new neqsim.thermodynamicOperations.chemicalEquilibrium.ChemicalEquilibrium(system); + getOperation().run(); + } + } + + /** + *+ * PHflash. + *
+ * + * @param Hspec a double + * @param type a int + */ + public void PHflash(double Hspec, int type) { + if (system.getPhase(0).getNumberOfComponents() == 1) { + operation = new PHflashSingleComp(system, Hspec, type); + } else { + operation = new PHflash(system, Hspec, type); + } + getOperation().run(); + } + + /** + * Method to perform a PH flash calculation + * + * @param Hspec is the enthalpy in the specified unit + * @param enthalpyUnit Supported units are J, J/mol, J/kg and kJ/kg + */ + public void PHflash(double Hspec, String enthalpyUnit) { + double conversionFactor = 1.0; + switch (enthalpyUnit) { + case "J": + conversionFactor = 1.0; + break; + case "J/mol": + conversionFactor = 1.0 / system.getTotalNumberOfMoles(); + break; + case "J/kg": + conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); + break; + case "kJ/kg": + conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; + break; + default: + break; + } + PHflash(Hspec / conversionFactor); + } + + /** + * Method to perform a PH flash calculation + * + * @param Hspec is the enthalpy in unit Joule to be held constant + */ + public void PHflash(double Hspec) { + this.PHflash(Hspec, 0); + } + + /** + * Method to perform a PH flash calculation based on GERG2008 EoS + * + * @param Hspec is the enthalpy in unit Joule to be held constant + */ + public void PHflashGERG2008(double Hspec) { + operation = new neqsim.thermodynamicOperations.flashOps.PHflashGERG2008(system, Hspec); + getOperation().run(); + } + + /** + *+ * PUflash. + *
+ * + * @param Uspec a double + */ + public void PUflash(double Uspec) { + operation = new neqsim.thermodynamicOperations.flashOps.PUflash(system, Uspec); + getOperation().run(); + } + + /** + *+ * PUflash. + *
+ * + * @param Pspec a double + * @param Uspec a double + * @param unitPressure a {@link java.lang.String} object + * @param unitEnergy a {@link java.lang.String} object + */ + public void PUflash(double Pspec, double Uspec, String unitPressure, String unitEnergy) { + system.setPressure(Pspec, unitPressure); + PUflash(Uspec, unitEnergy); + } + + /** + *+ * PUflash. + *
+ * + * @param Uspec a double + * @param unitEnergy a {@link java.lang.String} object + */ + public void PUflash(double Uspec, String unitEnergy) { + double conversionFactorEntr = 1.0; + switch (unitEnergy) { + case "J": + conversionFactorEntr = 1.0; + break; + case "J/mol": + conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles(); + break; + case "J/kg": + conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); + break; + case "kJ/kg": + conversionFactorEntr = + 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; + break; + default: + break; + } + PUflash(Uspec / conversionFactorEntr); + } + + /** + *+ * PHflash2. + *
+ * + * @param Hspec a double + * @param type a int + */ + public void PHflash2(double Hspec, int type) { + operation = new PHflash(system, Hspec, type); + getOperation().run(); + } + + /** + *+ * criticalPointFlash. + *
+ */ + public void criticalPointFlash() { + operation = new CriticalPointFlash(system); + getOperation().run(); + } + + /** + *+ * PHsolidFlash. + *
+ * + * @param Hspec a double + */ + public void PHsolidFlash(double Hspec) { + operation = new PHsolidFlash(system, Hspec); + getOperation().run(); + } + + /** + *+ * PSflash. + *
+ * + * @param Sspec a double + */ + public void PSflash(double Sspec) { + if (system.getPhase(0).getNumberOfComponents() == 1) { + operation = new PSflashSingleComp(system, Sspec, 0); + } else { + operation = new PSFlash(system, Sspec, 0); + } + getOperation().run(); + } + + /** + * Method to perform a PS flash calculation for a specified entropy and pressure + * + * @param Sspec is the entropy in the specified unit + * @param unit Supported units are J/K, J/molK, J/kgK and kJ/kgK + */ + public void PSflash(double Sspec, String unit) { + double conversionFactor = 1.0; + switch (unit) { + case "J/K": + break; + case "J/molK": + conversionFactor = 1.0 / system.getTotalNumberOfMoles(); + break; + case "J/kgK": + conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); + break; + case "kJ/kgK": + conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; + break; + default: + break; + } + PSflash(Sspec / conversionFactor); + } + + /** + *+ * TSflash. + *
+ * + * @param Sspec a double + */ + public void TSflash(double Sspec) { + operation = new TSFlash(system, Sspec); + getOperation().run(); + } + + /** + * Method to perform a TS flash calculation for a specified entropy and pressure + * + * @param Sspec is the entropy in the specified unit + * @param unit Supported units are J/K, J/molK, J/kgK and kJ/kgK + */ + public void TSflash(double Sspec, String unit) { + double conversionFactor = 1.0; + switch (unit) { + case "J/K": + conversionFactor = 1.0; + break; + case "J/molK": + conversionFactor = 1.0 / system.getTotalNumberOfMoles(); + break; + case "J/kgK": + conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); + break; + case "kJ/kgK": + conversionFactor = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; + break; + default: + break; + } + TSflash(Sspec / conversionFactor); + } + + /** + *+ * PSflashGERG2008. + *
+ * Run a flash at constant pressure and entropy using the GERG2008 EoS + * + * @param Sspec is the specidfied entropy + */ + public void PSflashGERG2008(double Sspec) { + operation = new PSFlashGERG2008(system, Sspec); + getOperation().run(); + } + + /** + *+ * PSflash2. + *
+ * + * @param Sspec a double + */ + public void PSflash2(double Sspec) { + operation = new PSFlash(system, Sspec, 0); + getOperation().run(); + } + + /** + *+ * VSflash. + *
+ * + * @param volume a double + * @param entropy a double + * @param unitVol a {@link java.lang.String} object + * @param unitEntropy a {@link java.lang.String} object + */ + public void VSflash(double volume, double entropy, String unitVol, String unitEntropy) { + double conversionFactorV = 1.0; + double conversionFactorEntr = 1.0; + + switch (unitVol) { + case "m3": + conversionFactorV = 1.0e5; + break; + default: + break; + } + + switch (unitEntropy) { + case "J/K": + conversionFactorEntr = 1.0; + break; + case "J/molK": + conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles(); + break; + case "J/kgK": + conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); + break; + case "kJ/kgK": + conversionFactorEntr = + 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; + break; + default: + break; + } + VSflash(volume * conversionFactorV, entropy / conversionFactorEntr); + } + + /** + *+ * VSflash. + *
+ * + * @param volume a double + * @param entropy a double + */ + public void VSflash(double volume, double entropy) { + operation = new neqsim.thermodynamicOperations.flashOps.VSflash(system, volume, entropy); + getOperation().run(); + } + + /** + *+ * TVflash. + *
+ * + * @param Vspec a double + * @param unit a {@link java.lang.String} object + */ + public void TVflash(double Vspec, String unit) { + double conversionFactor = 1.0; + switch (unit) { + case "m3": + conversionFactor = 1.0e5; + break; + default: + break; + } + TVflash(Vspec * conversionFactor); + } + + /** + *+ * TVflash. + *
+ * + * @param Vspec a double + */ + public void TVflash(double Vspec) { + operation = new TVflash(system, Vspec); + getOperation().run(); + } + + /** + *+ * PVrefluxFlash. + *
+ * + * @param refluxspec a double + * @param refluxPhase a int + */ + public void PVrefluxFlash(double refluxspec, int refluxPhase) { + operation = new PVrefluxflash(system, refluxspec, refluxPhase); + getOperation().run(); + } + + /** + *+ * VHflash. + *
+ * + * @param Vspec a double + * @param Hspec a double + */ + public void VHflash(double Vspec, double Hspec) { + operation = new VHflashQfunc(system, Vspec, Hspec); + getOperation().run(); + } + + /** + *+ * VHflash. + *
+ * + * @param volume a double + * @param enthalpy a double + * @param unitVol a {@link java.lang.String} object + * @param unitEnthalpy a {@link java.lang.String} object + */ + public void VHflash(double volume, double enthalpy, String unitVol, String unitEnthalpy) { + double conversionFactorV = 1.0; + double conversionFactorEntr = 1.0; + + switch (unitVol) { + case "m3": + conversionFactorV = 1.0e5; + break; + default: + break; + } + + switch (unitEnthalpy) { + case "J/K": + conversionFactorEntr = 1.0; + break; + case "J/mol": + conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles(); + break; + case "J/kg": + conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); + break; + case "kJ/kg": + conversionFactorEntr = + 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; + break; + default: + break; + } + VHflash(volume * conversionFactorV, enthalpy / conversionFactorEntr); + } + + /** + *+ * VUflash. + *
+ * + * @param volume a double + * @param energy a double + * @param unitVol a {@link java.lang.String} object + * @param unitEnergy a {@link java.lang.String} object + */ + public void VUflash(double volume, double energy, String unitVol, String unitEnergy) { + double conversionFactorV = 1.0; + double conversionFactorEntr = 1.0; + + switch (unitVol) { + case "m3": + conversionFactorV = 1.0e5; + break; + default: + break; + } + + switch (unitEnergy) { + case "J/K": + conversionFactorEntr = 1.0; + break; + case "J/mol": + conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles(); + break; + case "J/kg": + conversionFactorEntr = 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass(); + break; + case "kJ/kg": + conversionFactorEntr = + 1.0 / system.getTotalNumberOfMoles() / system.getMolarMass() / 1000.0; + break; + default: + break; + } + VUflash(volume * conversionFactorV, energy / conversionFactorEntr); + } + + /** + *+ * VUflash. + *
+ * + * @param Vspec a double + * @param Uspec a double + */ + public void VUflash(double Vspec, double Uspec) { + operation = new VUflashQfunc(system, Vspec, Uspec); + getOperation().run(); + } + + /** + *+ * bubblePointTemperatureFlash. + *
+ * + * @throws java.lang.Exception if any. + */ + public void bubblePointTemperatureFlash() throws Exception { + constantDutyFlashInterface operation = new bubblePointTemperatureNoDer(system); + operation.run(); + if (Double.isNaN(system.getTemperature()) || operation.isSuperCritical()) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "bubblePointTemperatureFlash", + "Could not find solution - possible no bubble point exists"); + } + } + + /** + *+ * freezingPointTemperatureFlash. + *
+ * + * @throws java.lang.Exception if any. + */ + public void freezingPointTemperatureFlash() throws Exception { + operation = new freezingPointTemperatureFlash(system); + getOperation().run(); + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "freezingPointTemperatureFlash", + "Could not find solution - possible no freezing point exists"); + } + } + + /** + *+ * freezingPointTemperatureFlash. + *
+ * + * @param phaseName a {@link java.lang.String} object + * @throws java.lang.Exception if any. + */ + public void freezingPointTemperatureFlash(String phaseName) throws Exception { + operation = new freezingPointTemperatureFlash(system); + getOperation().run(); + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "freezingPointTemperatureFlash", + "Could not find solution - possible no freezing point exists"); + } + } + + /** + *+ * waterDewPointTemperatureFlash. + *
+ * + * @throws java.lang.Exception if any. + */ + public void waterDewPointTemperatureFlash() throws Exception { + operation = new waterDewPointTemperatureFlash(system); + getOperation().run(); + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "waterDewPointTemperatureFlash", + "Could not find solution - possible no dew point exists"); + } + } + + /** + *+ * waterDewPointTemperatureMultiphaseFlash. + *
+ * + * @throws java.lang.Exception if any. + */ + public void waterDewPointTemperatureMultiphaseFlash() throws Exception { + operation = new waterDewPointTemperatureMultiphaseFlash(system); + getOperation().run(); + } + + /** + *+ * waterPrecipitationTemperature. + *
+ * + * @throws java.lang.Exception if any. + */ + public void waterPrecipitationTemperature() throws Exception { + double lowTemperature = 0.0; + dewPointTemperatureFlash(); + + if (system.getTemperature() > lowTemperature) { + lowTemperature = system.getTemperature(); + } + + // if(lowTemperature<273.15 && system.doSolidPhaseCheck()){ + // hydrateFormationTemperature(0); + // if(system.getTemperature()>lowTemperature) lowTemperature = + // system.getTemperature(); + // } - /** - *- * constantPhaseFractionPressureFlash. - *
- * - * @param fraction a double - * @throws java.lang.Exception if any. - */ - public void constantPhaseFractionPressureFlash(double fraction) throws Exception { - system.init(0); - if (fraction < 1e-10) { - fraction = 1e-10; - } - if (fraction > 1.0 - 1e-10) { - fraction = 1.0 - 1.0e-10; - } - constantDutyFlashInterface operation = new constantDutyPressureFlash(system); - system.setBeta(1, 1.0 - fraction); - system.setBeta(0, fraction); - operation.run(); - if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "constantPhaseFractionPressureFlash", - "Could not find solution - possible no dew point exists"); - } - } + // if(system.doHydrateCheck()){ + // hydrateFormationTemperature(1); + // if(system.getTemperature()>lowTemperature) lowTemperature = + // system.getTemperature(); + // hydrateFormationTemperature(2); + // if(system.getTemperature()>lowTemperature) lowTemperature = + // system.getTemperature(); + // } - /** - *- * constantPhaseFractionTemperatureFlash. - *
- * - * @param fraction a double - * @throws java.lang.Exception if any. - */ - public void constantPhaseFractionTemperatureFlash(double fraction) throws Exception { + system.setTemperature(lowTemperature); + // TPflash(); + + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "waterPrecipitationTemperature", + "Could not find solution - possible no dew point exists"); + } + } + + /** + *+ * calcSaltSaturation. + *
+ * + * @param saltName a {@link java.lang.String} object + * @throws java.lang.Exception if any. + */ + public void calcSaltSaturation(String saltName) throws Exception { + operation = new calcSaltSatauration(system, saltName); + getOperation().run(); + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "calcSaltSaturation", "Could not find solution - possible no dew point exists"); + } + } + + /** + *+ * checkScalePotential. + *
+ * + * @param phaseNumber a int + * @throws java.lang.Exception if any. + */ + public void checkScalePotential(int phaseNumber) throws Exception { + operation = new checkScalePotential(system, phaseNumber); + getOperation().run(); + resultTable = getOperation().getResultTable(); + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "checkScalePotential", "Could not find solution - possible no dew point exists"); + } + } + + /** + *+ * addIonToScaleSaturation. + *
+ * + * @param phaseNumber a int + * @param scaleSaltName a {@link java.lang.String} object + * @param nameOfIonToBeAdded a {@link java.lang.String} object + * @throws java.lang.Exception if any. + */ + public void addIonToScaleSaturation(int phaseNumber, String scaleSaltName, + String nameOfIonToBeAdded) throws Exception { + operation = new addIonToScaleSaturation(system, phaseNumber, scaleSaltName, nameOfIonToBeAdded); + getOperation().run(); + resultTable = getOperation().getResultTable(); + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "addIonToScaleSaturation", "Could not find solution - possible no dew point exists"); + } + } + + /** + *+ * hydrateFormationPressure. + *
+ * + * @throws java.lang.Exception if any. + */ + public void hydrateFormationPressure() throws Exception { + operation = new HydrateFormationPressureFlash(system); + getOperation().run(); + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "hydrateFormationPressure", "Could not find solution - possible no dew point exists"); + } + } + + /** + *+ * calcWAT. + *
+ * + * @throws java.lang.Exception if any. + */ + public void calcWAT() throws Exception { + operation = new WATcalc(system); + getOperation().run(); + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), "calcWAT", + "Could not find solution - possible no dew point exists"); + } + } + + /** + *+ * run. + *
+ */ + public void run() { + setThermoOperationThread(new Thread(operation)); + getThermoOperationThread().start(); + } + + /** + *+ * waitAndCheckForFinishedCalculation. + *
+ * + * @param maxTime a int + * @return a boolean + */ + public boolean waitAndCheckForFinishedCalculation(int maxTime) { + try { + getThermoOperationThread().join(maxTime); + getThermoOperationThread().interrupt(); + } catch (Exception e) { + logger.error("error", e); + } + boolean didFinish = !getThermoOperationThread().isInterrupted(); + // getThermoOperationThread().stop(); + return didFinish; + } + + /** + *+ * waitToFinishCalculation. + *
+ */ + public void waitToFinishCalculation() { + try { + getThermoOperationThread().join(); + } catch (Exception e) { + logger.error("error", e); + } + } + + /** + *+ * calcSolidComlexTemperature. + *
+ * + * @throws java.lang.Exception if any. + */ + public void calcSolidComlexTemperature() throws Exception { + operation = new SolidComplexTemperatureCalc(system); + getOperation().run(); + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "calcSolidComlexTemperature", + "error in WAT() - could not find solution - possible no dew point exists"); + } + } + + /** + *+ * calcSolidComlexTemperature. + *
+ * + * @param comp1 a {@link java.lang.String} object + * @param comp2 a {@link java.lang.String} object + * @throws java.lang.Exception if any. + */ + public void calcSolidComlexTemperature(String comp1, String comp2) throws Exception { + if (operation == null) { + operation = new SolidComplexTemperatureCalc(system, comp1, comp2); + } + getOperation().run(); + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "calcSolidComlexTemperature", + "error in WAT() - could not find solution - possible no dew point exists"); + } + } + + /** + *+ * calcImobilePhaseHydrateTemperature. + *
+ * + * @param temperature an array of {@link double} objects + * @param pressure an array of {@link double} objects + * @return an array of {@link double} objects + */ + public double[] calcImobilePhaseHydrateTemperature(double[] temperature, double[] pressure) { + double[] hydTemps = new double[temperature.length]; + SystemInterface systemTemp; + ThermodynamicOperations opsTemp; + systemTemp = system.clone(); + + for (int i = 0; i < temperature.length; i++) { + /* + * opsTemp = new ThermodynamicOperations(systemTemp); + * systemTemp.setTemperature(temperature[i]); systemTemp.setPressure(pressure[i]); + * systemTemp.init(0); systemTemp.display(); try { opsTemp.hydrateFormationTemperature(); } + * catch (Exception e) { logger.error("error",e); } systemTemp.display(); hydTemps[i] = + * systemTemp.getTemperature(); + * + */ + opsTemp = new ThermodynamicOperations(systemTemp); + systemTemp.setTemperature(temperature[i]); + systemTemp.setPressure(pressure[i]); + + opsTemp.TPflash(); + systemTemp.display(); + systemTemp = systemTemp.phaseToSystem(0); + } + + opsTemp = new ThermodynamicOperations(systemTemp); + systemTemp.setHydrateCheck(true); + systemTemp.setMixingRule(9); + try { + opsTemp.hydrateFormationTemperature(); + } catch (Exception e) { + logger.error("error", e); + } + systemTemp.display(); + return hydTemps; + } + + /** + *+ * calcTOLHydrateFormationTemperature. + *
+ * + * @return a double + */ + public double calcTOLHydrateFormationTemperature() { + TPflash(); + + SystemInterface systemTemp = system.phaseToSystem(0); + ThermodynamicOperations opsTemp = new ThermodynamicOperations(systemTemp); + try { + opsTemp.hydrateFormationTemperature(); + } catch (Exception e) { + logger.error("error", e); + } + systemTemp.display(); + system.setTemperature(systemTemp.getTemperature()); + TPflash(); + return system.getTemperature(); + } + + /** + *+ * hydrateInhibitorConcentration. + *
+ * + * @param inhibitorName a {@link java.lang.String} object + * @param hydEqTemperature a double + * @throws java.lang.Exception if any. + */ + public void hydrateInhibitorConcentration(String inhibitorName, double hydEqTemperature) + throws Exception { + operation = new HydrateInhibitorConcentrationFlash(system, inhibitorName, hydEqTemperature); + operation.run(); + } + + /** + *+ * hydrateInhibitorConcentrationSet. + *
+ * + * @param inhibitorName a {@link java.lang.String} object + * @param wtfrac a double + * @throws java.lang.Exception if any. + */ + public void hydrateInhibitorConcentrationSet(String inhibitorName, double wtfrac) + throws Exception { + operation = new HydrateInhibitorwtFlash(system, inhibitorName, wtfrac); + operation.run(); + } + + /** + *+ * hydrateFormationTemperature. + *
+ * + * @param initialTemperatureGuess a double + * @throws java.lang.Exception if any. + */ + public void hydrateFormationTemperature(double initialTemperatureGuess) throws Exception { + system.setTemperature(initialTemperatureGuess); + operation = new HydrateFormationTemperatureFlash(system); + for (int i = 0; i < system.getPhase(4).getNumberOfComponents(); i++) { + ((ComponentHydrate) system.getPhase(4).getComponent(i)).getHydrateStructure(); + } + if (!isRunAsThread()) { + getOperation().run(); + } else { + run(); + } + } + + /** + *+ * hydrateFormationTemperature. + *
+ * + * @throws java.lang.Exception if any. + */ + public void hydrateFormationTemperature() throws Exception { + // guessing temperature + double factor = 1.0; + if (system.getPhase(0).hasComponent("methanol")) { + factor -= 2 * system.getPhase(0).getComponent("methanol").getz() + / system.getPhase(0).getComponent("water").getz(); + } + if (system.getPhase(0).hasComponent("MEG")) { + factor -= 2 * system.getPhase(0).getComponent("MEG").getz() + / system.getPhase(0).getComponent("water").getz(); + } + if (factor < 2) { + factor = 2; + } + + system.setTemperature(273.0 + system.getPressure() / 100.0 * 20.0 * factor - 20.0); + if (system.getTemperature() > 298.15) { + system.setTemperature(273.0 + 25.0); + } + // logger.info("guess hydrate temperature " + system.getTemperature()); + operation = new HydrateFormationTemperatureFlash(system); + + for (int i = 0; i < system.getPhase(4).getNumberOfComponents(); i++) { + ((ComponentHydrate) system.getPhase(4).getComponent(i)).getHydrateStructure(); + } + if (!isRunAsThread()) { + getOperation().run(); + } else { + run(); + } + // logger.info("Hydrate structure " + (((ComponentHydrate) + // system.getPhase(4).getComponent("water")).getHydrateStructure() + 1)); + } + + /** + *+ * hydrateFormationTemperature. + *
+ * + * @param structure a int + * @throws java.lang.Exception if any. + */ + public void hydrateFormationTemperature(int structure) throws Exception { + system.setTemperature(273.0 + 1.0); + if (structure == 0) { + system.setSolidPhaseCheck("water"); + system.setHydrateCheck(true); + operation = new freezingPointTemperatureFlash(system); + } else { + operation = new HydrateFormationTemperatureFlash(system); + } + + for (int i = 0; i < system.getPhase(4).getNumberOfComponents(); i++) { + ((ComponentHydrate) system.getPhases()[4].getComponent(i)).setHydrateStructure(structure - 1); + } + if (!isRunAsThread()) { + getOperation().run(); + } else { + run(); + } + + if (Double.isNaN(system.getTemperature())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "hydrateFormationTemperature", "Could not find solution - possible no dew point exists"); + } + } + + /** + *+ * hydrateEquilibriumLine. + *
+ * + * @param minimumPressure a double + * @param maximumPressure a double + * @throws java.lang.Exception if any. + */ + public void hydrateEquilibriumLine(double minimumPressure, double maximumPressure) + throws Exception { + operation = new HydrateEquilibriumLine(system, minimumPressure, maximumPressure); + if (!isRunAsThread()) { + getOperation().run(); + } else { + run(); + } + } + + /** + *+ * calcCricoP. + *
+ * + * @param cricondenBar an array of {@link double} objects + * @param cricondenBarX an array of {@link double} objects + * @param cricondenBarY an array of {@link double} objects + */ + public void calcCricoP(double[] cricondenBar, double[] cricondenBarX, double[] cricondenBarY) { + double phasefraction = 1.0 - 1e-10; + + operation = new CricondenBarFlash(system, fileName, phasefraction, cricondenBar, cricondenBarX, + cricondenBarY); + + getOperation().run(); + } + + /** + *+ * calcCricoT. + *
+ * + * @param cricondenTherm an array of {@link double} objects + * @param cricondenThermX an array of {@link double} objects + * @param cricondenThermY an array of {@link double} objects + */ + public void calcCricoT(double[] cricondenTherm, double[] cricondenThermX, + double[] cricondenThermY) { + double phasefraction = 1.0 - 1e-10; + + operation = new CricondenThermFlash(system, fileName, phasefraction, cricondenTherm, + cricondenThermX, cricondenThermY); + + getOperation().run(); + } + + /** + *+ * waterDewPointLine. + *
+ * + * @param minimumPressure a double + * @param maximumPressure a double + * @throws java.lang.Exception if any. + */ + public void waterDewPointLine(double minimumPressure, double maximumPressure) throws Exception { + operation = new WaterDewPointEquilibriumLine(system, minimumPressure, maximumPressure); + if (!isRunAsThread()) { + getOperation().run(); + } else { + run(); + } + } + + /** + *+ * calcCricondenBar. + *
+ * + * @return a double + */ + public double calcCricondenBar() { + system.init(0); + operation = new cricondebarFlash(system); + // operation = new CricondenBarFlash(system); + + // operation = new cricondenBarTemp1(system); + operation.run(); + return system.getPressure(); + } + + /** + *+ * bubblePointPressureFlash. + *
+ * + * @throws java.lang.Exception if any. + */ + public void bubblePointPressureFlash() throws Exception { + system.init(0); + constantDutyFlashInterface operation = new constantDutyPressureFlash(system); + system.setBeta(1, 1.0 - 1e-10); + system.setBeta(0, 1e-10); + operation.run(); + if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "bubblePointPressureFlash", "Could not find solution - possible no dew point exists"); + } + } + + /** + *+ * bubblePointPressureFlash. + *
+ * + * @param derivatives a boolean + * @throws java.lang.Exception if any. + */ + public void bubblePointPressureFlash(boolean derivatives) throws Exception { + constantDutyFlashInterface operation = null; + if (derivatives == true) { + operation = new bubblePointPressureFlashDer(system); + } else { + operation = new bubblePointPressureFlash(system); + } + operation.run(); + if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "bubblePointPressureFlash", "Could not find solution - possible no dew point exists"); + } + } + + /** + *+ * constantPhaseFractionPressureFlash. + *
+ * + * @param fraction a double + * @throws java.lang.Exception if any. + */ + public void constantPhaseFractionPressureFlash(double fraction) throws Exception { + system.init(0); + if (fraction < 1e-10) { + fraction = 1e-10; + } + if (fraction > 1.0 - 1e-10) { + fraction = 1.0 - 1.0e-10; + } + constantDutyFlashInterface operation = new constantDutyPressureFlash(system); + system.setBeta(1, 1.0 - fraction); + system.setBeta(0, fraction); + operation.run(); + if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "constantPhaseFractionPressureFlash", + "Could not find solution - possible no dew point exists"); + } + } + + /** + *+ * constantPhaseFractionTemperatureFlash. + *
+ * + * @param fraction a double + * @throws java.lang.Exception if any. + */ + public void constantPhaseFractionTemperatureFlash(double fraction) throws Exception { + system.init(0); + if (fraction < 1e-10) { + fraction = 1e-10; + } + if (fraction > 1.0 - 1e-10) { + fraction = 1.0 - 1.0e-10; + } + constantDutyFlashInterface operation = new constantDutyTemperatureFlash(system); + system.setBeta(1, fraction); + system.setBeta(0, fraction); + operation.run(); + if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "constantPhaseFractionTemperatureFlash", + "Could not find solution - possible no dew point exists"); + } + } + + /** + *+ * dewPointMach. + *
+ * + * @param componentName a {@link java.lang.String} object + * @param specification a {@link java.lang.String} object + * @param spec a double + * @throws java.lang.Exception if any. + */ + public void dewPointMach(String componentName, String specification, double spec) + throws Exception { + // int componentNumber = + // system.getPhase(0).getComponent(componentName).getComponentNumber(); + + double dn = 0; + if (system.getPhase(0).hasComponent(componentName)) { + dn = system.getNumberOfMoles() / 1.0e6; + system.addComponent(componentName, dn); + } else { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "dewPointMach", "Specified component is not present in mixture: " + componentName); + } + double newTemperature = system.getTemperature(); + double oldTemperature = newTemperature; + int iterations = 0; + if (specification.equals("dewPointTemperature")) { + // logger.info("new temperature " + newTemperature); + do { + iterations++; system.init(0); - if (fraction < 1e-10) { - fraction = 1e-10; - } - if (fraction > 1.0 - 1e-10) { - fraction = 1.0 - 1.0e-10; - } - constantDutyFlashInterface operation = new constantDutyTemperatureFlash(system); - system.setBeta(1, fraction); - system.setBeta(0, fraction); - operation.run(); - if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "constantPhaseFractionTemperatureFlash", - "Could not find solution - possible no dew point exists"); - } - } - - /** - *- * bubblePointPressureFlash. - *
- * - * @param derivatives a boolean - * @throws java.lang.Exception if any. - */ - public void bubblePointPressureFlash(boolean derivatives) throws Exception { - constantDutyFlashInterface operation = null; - if (derivatives == true) { - operation = new bubblePointPressureFlashDer(system); - } else { - operation = new bubblePointPressureFlash(system); - } - operation.run(); - if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "bubblePointPressureFlash", "Could not find solution - possible no dew point exists"); - } - } - - /** - *- * dewPointMach. - *
- * - * @param componentName a {@link java.lang.String} object - * @param specification a {@link java.lang.String} object - * @param spec a double - * @throws java.lang.Exception if any. - */ - public void dewPointMach(String componentName, String specification, double spec) - throws Exception { - // int componentNumber = - // system.getPhase(0).getComponent(componentName).getComponentNumber(); - - double dn = 0; - if (system.getPhase(0).hasComponent(componentName)) { - dn = system.getNumberOfMoles() / 1.0e6; - system.addComponent(componentName, dn); + dewPointTemperatureFlash(); + newTemperature = system.getTemperature(); + // logger.info("new temperature " + newTemperature); + double oldMoles = system.getPhase(0).getComponent(componentName).getNumberOfmoles(); + if (iterations > 1) { + system.addComponent(componentName, -(iterations / (30.0 + iterations)) + * (newTemperature - spec) / ((newTemperature - oldTemperature) / dn)); } else { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "dewPointMach", "Specified component is not present in mixture: " + componentName); - } - double newTemperature = system.getTemperature(), oldTemperature = newTemperature; - int iterations = 0; - if (specification.equals("dewPointTemperature")) { - // logger.info("new temperature " + newTemperature); - do { - iterations++; - system.init(0); - dewPointTemperatureFlash(); - newTemperature = system.getTemperature(); - // logger.info("new temperature " + newTemperature); - double oldMoles = system.getPhase(0).getComponent(componentName).getNumberOfmoles(); - if (iterations > 1) { - system.addComponent(componentName, -(iterations / (30.0 + iterations)) - * (newTemperature - spec) / ((newTemperature - oldTemperature) / dn)); - } else { - system.addComponent(componentName, system.getNumberOfMoles() / 1.0e6); - } - dn = system.getPhase(0).getComponent(componentName).getNumberOfmoles() - oldMoles; - oldTemperature = newTemperature; - } while (Math.abs( - dn / system.getPhase(0).getComponent(componentName).getNumberOfmoles()) > 1e-9 - || iterations < 5 || iterations > 105); - - dewPointTemperatureFlash(); - } - - if (Double.isNaN(system.getPressure())) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "dewPointMach", "Could not find solution - possible no dew point exists"); - } - } - - /** - *- * dewPointTemperatureFlash. - *
- * - * @throws java.lang.Exception if any. - */ - public void dewPointTemperatureFlash() throws Exception { - constantDutyFlashInterface operation = new neqsim.thermodynamicOperations.flashOps.saturationOps.dewPointTemperatureFlash( - system); - operation.run(); - if (Double.isNaN(system.getTemperature()) || operation.isSuperCritical()) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "dewPointTemperatureFlash", "Could not find solution - possible no dew point exists"); - } - } - - /** - *- * dewPointTemperatureFlash. - *
- * - * @param derivatives a boolean - * @throws java.lang.Exception if any. - */ - public void dewPointTemperatureFlash(boolean derivatives) throws Exception { - constantDutyFlashInterface operation = new neqsim.thermodynamicOperations.flashOps.saturationOps.dewPointTemperatureFlash( - system); - if (derivatives) { - operation = new dewPointTemperatureFlashDer(system); - } - operation.run(); - if (Double.isNaN(system.getTemperature()) || operation.isSuperCritical()) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "dewPointTemperatureFlash", "Could not find solution - possible no dew point exists"); - } + system.addComponent(componentName, system.getNumberOfMoles() / 1.0e6); + } + dn = system.getPhase(0).getComponent(componentName).getNumberOfmoles() - oldMoles; + oldTemperature = newTemperature; + } while (Math + .abs(dn / system.getPhase(0).getComponent(componentName).getNumberOfmoles()) > 1e-9 + || iterations < 5 || iterations > 105); + + dewPointTemperatureFlash(); + } + + if (Double.isNaN(system.getPressure())) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "dewPointMach", "Could not find solution - possible no dew point exists"); + } + } + + /** + *+ * dewPointTemperatureFlash. + *
+ * + * @throws java.lang.Exception if any. + */ + public void dewPointTemperatureFlash() throws Exception { + constantDutyFlashInterface operation = + new neqsim.thermodynamicOperations.flashOps.saturationOps.dewPointTemperatureFlash(system); + operation.run(); + if (Double.isNaN(system.getTemperature()) || operation.isSuperCritical()) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "dewPointTemperatureFlash", "Could not find solution - possible no dew point exists"); + } + } + + /** + *+ * dewPointTemperatureFlash. + *
+ * + * @param derivatives a boolean + * @throws java.lang.Exception if any. + */ + public void dewPointTemperatureFlash(boolean derivatives) throws Exception { + constantDutyFlashInterface operation = + new neqsim.thermodynamicOperations.flashOps.saturationOps.dewPointTemperatureFlash(system); + if (derivatives) { + operation = new dewPointTemperatureFlashDer(system); + } + operation.run(); + if (Double.isNaN(system.getTemperature()) || operation.isSuperCritical()) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "dewPointTemperatureFlash", "Could not find solution - possible no dew point exists"); + } + } + + /** + *+ * dewPointPressureFlashHC. + *
+ * + * @throws java.lang.Exception if any. + */ + public void dewPointPressureFlashHC() throws Exception { + // try{ + system.init(0); + constantDutyFlashInterface operation = new HCdewPointPressureFlash(system); + operation.run(); + if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "dewPointPressureFlashHC", "Could not find solution - possible no dew point exists"); } - - /** - *- * dewPointPressureFlashHC. - *
- * - * @throws java.lang.Exception if any. - */ - public void dewPointPressureFlashHC() throws Exception { - // try{ - system.init(0); - constantDutyFlashInterface operation = new HCdewPointPressureFlash(system); - operation.run(); - if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "dewPointPressureFlashHC", "Could not find solution - possible no dew point exists"); - } - // } - } - - /** - *- * dewPointPressureFlash. - *
- * - * @throws java.lang.Exception if any. - */ - public void dewPointPressureFlash() throws Exception { - // try{ - system.init(0); - constantDutyFlashInterface operation = new dewPointPressureFlash(system); - operation.run(); - if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "dewPointPressureFlash", "Could not find solution - possible no dew point exists"); - } - // } - } - - // public void dewPointPressureFlash(){ - // constantDutyFlashInterface operation = new constantDutyPressureFlash(system); - // operation.setBeta((1-1e-7)); - // operation.run(); // } - /** - *- * calcPTphaseEnvelope. - *
- */ - public void calcPTphaseEnvelope() { - operation = new pTphaseEnvelope(system, fileName, (1.0 - 1e-10), 1.0, false); - // thisThread = new Thread(operation); - // thisThread.start(); - getOperation().run(); - } - - /** - *- * calcPTphaseEnvelope. - *
- * - * @param bubfirst a boolean - * @param lowPres a double - */ - public void calcPTphaseEnvelope(boolean bubfirst, double lowPres) { - double phasefraction = 1.0 - 1e-10; - if (bubfirst) { - phasefraction = 1.0e-10; - } - operation = new pTphaseEnvelope(system, fileName, phasefraction, lowPres, bubfirst); - - // thisThread = new Thread(operation); - // thisThread.start(); - getOperation().run(); - } - - /** - *- * calcPTphaseEnvelope. - *
- * - * @param lowPres a double - */ - public void calcPTphaseEnvelope(double lowPres) { - operation = new pTphaseEnvelope(system, fileName, 1e-10, lowPres, true); - // thisThread = new Thread(operation); - // thisThread.start(); - getOperation().run(); - } - - /** - *- * calcPTphaseEnvelope. - *
- * - * @param bubfirst a boolean - */ - public void calcPTphaseEnvelope(boolean bubfirst) { - double phasefraction = 1.0 - 1e-10; - if (bubfirst) { - phasefraction = 1.0e-10; - } - operation = new pTphaseEnvelope(system, fileName, phasefraction, 1.0, bubfirst); - - // thisThread = new Thread(operation); - // thisThread.start(); - if (!isRunAsThread()) { - getOperation().run(); - } else { - run(); - } + } + + /** + *+ * dewPointPressureFlash. + *
+ * + * @throws java.lang.Exception if any. + */ + public void dewPointPressureFlash() throws Exception { + // try{ + system.init(0); + constantDutyFlashInterface operation = new dewPointPressureFlash(system); + operation.run(); + if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { + throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "dewPointPressureFlash", "Could not find solution - possible no dew point exists"); } - - /** - *- * getJfreeChart. - *
- * - * @return a {@link org.jfree.chart.JFreeChart} object - */ - public org.jfree.chart.JFreeChart getJfreeChart() { - return getOperation().getJFreeChart(""); - } - - /** - *- * calcPTphaseEnvelopeNew. - *
- */ - public void calcPTphaseEnvelopeNew() { - // double phasefraction = 1.0 - 1e-10; - // operation = new pTphaseEnvelope(system, fileName, phasefraction, 1.0); - getOperation().run(); - } - - /** - *- * calcPTphaseEnvelope. - *
- * - * @param lowPres a double - * @param phasefraction a double - */ - public void calcPTphaseEnvelope(double lowPres, double phasefraction) { - operation = new pTphaseEnvelope(system, fileName, phasefraction, lowPres, true); - - // thisThread = new Thread(operation); - // thisThread.start(); - getOperation().run(); - } - - /** - *- * OLGApropTable. - *
- * - * @param minTemp a double - * @param maxTemp a double - * @param temperatureSteps a int - * @param minPres a double - * @param maxPres a double - * @param pressureSteps a int - * @param filename a {@link java.lang.String} object - * @param TABtype a int - */ - public void OLGApropTable(double minTemp, double maxTemp, int temperatureSteps, double minPres, - double maxPres, int pressureSteps, String filename, int TABtype) { - operation = new OLGApropertyTableGeneratorWaterStudents(system); - ((OLGApropertyTableGeneratorWaterStudents) operation).setFileName(filename); - ((OLGApropertyTableGeneratorWaterStudents) operation).setPressureRange(minPres, maxPres, - pressureSteps); - ((OLGApropertyTableGeneratorWaterStudents) operation).setTemperatureRange(minTemp, maxTemp, - temperatureSteps); - getOperation().run(); - } - - /** - *- * OLGApropTablePH. - *
- * - * @param minEnthalpy a double - * @param maxEnthalpy a double - * @param enthalpySteps a int - * @param minPres a double - * @param maxPres a double - * @param pressureSteps a int - * @param filename a {@link java.lang.String} object - * @param TABtype a int - */ - public void OLGApropTablePH(double minEnthalpy, double maxEnthalpy, int enthalpySteps, - double minPres, double maxPres, int pressureSteps, String filename, int TABtype) { - operation = new OLGApropertyTableGeneratorWaterStudentsPH(system); - ((OLGApropertyTableGeneratorWaterStudentsPH) operation).setFileName(filename); - ((OLGApropertyTableGeneratorWaterStudentsPH) operation).setPressureRange(minPres, maxPres, - pressureSteps); - ((OLGApropertyTableGeneratorWaterStudentsPH) operation).setEnthalpyRange(minEnthalpy, - maxEnthalpy, enthalpySteps); - getOperation().run(); - } - - /** - *- * calcPloadingCurve. - *
- */ - public void calcPloadingCurve() { - operation = new pLoadingCurve2(system); - // thisThread = new Thread(operation); - // thisThread.start(); - getOperation().run(); - } - - /** - *- * calcHPTphaseEnvelope. - *
- */ - public void calcHPTphaseEnvelope() { - operation = new HPTphaseEnvelope(system); - // thisThread = new Thread(getOperation()); - // thisThread.start(); - operation.run(); - } - - /** - *- * printToFile. - *
- * - * @param name a {@link java.lang.String} object - */ - public void printToFile(String name) { - getOperation().printToFile(name); - } - - // public double[] get(String name){ - // return operation.get(name); // } - /** - *- * getData. - *
- * - * @return an array of {@link double} objects - */ - public double[][] getData() { - return getOperation().getPoints(0); - } - - /** - *- * getDataPoints. - *
- * - * @return an array of {@link java.lang.String} objects - */ - public String[][] getDataPoints() { - String[][] str = new String[getOperation() - .getPoints(0).length][getOperation().getPoints(0)[0].length]; - for (int i = 0; i < getOperation().getPoints(0).length; i++) { - for (int j = 0; j < getOperation().getPoints(0)[0].length; j++) { - str[i][j] = Double.toString(getOperation().getPoints(0)[i][j]); - } - } - return str; - } - - /** - *
- * Getter for the field resultTable
.
- *
- * dewPointTemperatureCondensationRate. - *
- * - * @return a double - */ - public double dewPointTemperatureCondensationRate() { - double dT = 1.1; - try { - dewPointTemperatureFlash(); - } catch (Exception e) { - logger.error("error", e); + } + + /** + *+ * getJfreeChart. + *
+ * + * @return a {@link org.jfree.chart.JFreeChart} object + */ + public org.jfree.chart.JFreeChart getJfreeChart() { + return getOperation().getJFreeChart(""); + } + + // public void dewPointPressureFlash(){ + // constantDutyFlashInterface operation = new constantDutyPressureFlash(system); + // operation.setBeta((1-1e-7)); + // operation.run(); + // } + /** + *+ * calcPTphaseEnvelope. + *
+ */ + public void calcPTphaseEnvelope() { + operation = new pTphaseEnvelope(system, fileName, (1.0 - 1e-10), 1.0, false); + // thisThread = new Thread(operation); + // thisThread.start(); + getOperation().run(); + } + + /** + *+ * calcPTphaseEnvelope. + *
+ * + * @param bubfirst a boolean + * @param lowPres a double + */ + public void calcPTphaseEnvelope(boolean bubfirst, double lowPres) { + double phasefraction = 1.0 - 1e-10; + if (bubfirst) { + phasefraction = 1.0e-10; + } + operation = new pTphaseEnvelope(system, fileName, phasefraction, lowPres, bubfirst); + + // thisThread = new Thread(operation); + // thisThread.start(); + getOperation().run(); + } + + /** + *+ * calcPTphaseEnvelope. + *
+ * + * @param lowPres a double + */ + public void calcPTphaseEnvelope(double lowPres) { + operation = new pTphaseEnvelope(system, fileName, 1e-10, lowPres, true); + // thisThread = new Thread(operation); + // thisThread.start(); + getOperation().run(); + } + + /** + *+ * calcPTphaseEnvelope. + *
+ * + * @param bubfirst a boolean + */ + public void calcPTphaseEnvelope(boolean bubfirst) { + double phasefraction = 1.0 - 1e-10; + if (bubfirst) { + phasefraction = 1.0e-10; + } + operation = new pTphaseEnvelope(system, fileName, phasefraction, 1.0, bubfirst); + + // thisThread = new Thread(operation); + // thisThread.start(); + if (!isRunAsThread()) { + getOperation().run(); + } else { + run(); + } + } + + /** + *+ * calcPTphaseEnvelope. + *
+ * + * @param lowPres a double + * @param phasefraction a double + */ + public void calcPTphaseEnvelope(double lowPres, double phasefraction) { + operation = new pTphaseEnvelope(system, fileName, phasefraction, lowPres, true); + + // thisThread = new Thread(operation); + // thisThread.start(); + getOperation().run(); + } + + /** + *+ * calcPTphaseEnvelopeNew. + *
+ */ + public void calcPTphaseEnvelopeNew() { + // double phasefraction = 1.0 - 1e-10; + // operation = new pTphaseEnvelope(system, fileName, phasefraction, 1.0); + getOperation().run(); + } + + /** + *+ * OLGApropTable. + *
+ * + * @param minTemp a double + * @param maxTemp a double + * @param temperatureSteps a int + * @param minPres a double + * @param maxPres a double + * @param pressureSteps a int + * @param filename a {@link java.lang.String} object + * @param TABtype a int + */ + public void OLGApropTable(double minTemp, double maxTemp, int temperatureSteps, double minPres, + double maxPres, int pressureSteps, String filename, int TABtype) { + operation = new OLGApropertyTableGeneratorWaterStudents(system); + ((OLGApropertyTableGeneratorWaterStudents) operation).setFileName(filename); + ((OLGApropertyTableGeneratorWaterStudents) operation).setPressureRange(minPres, maxPres, + pressureSteps); + ((OLGApropertyTableGeneratorWaterStudents) operation).setTemperatureRange(minTemp, maxTemp, + temperatureSteps); + getOperation().run(); + } + + /** + *+ * OLGApropTablePH. + *
+ * + * @param minEnthalpy a double + * @param maxEnthalpy a double + * @param enthalpySteps a int + * @param minPres a double + * @param maxPres a double + * @param pressureSteps a int + * @param filename a {@link java.lang.String} object + * @param TABtype a int + */ + public void OLGApropTablePH(double minEnthalpy, double maxEnthalpy, int enthalpySteps, + double minPres, double maxPres, int pressureSteps, String filename, int TABtype) { + operation = new OLGApropertyTableGeneratorWaterStudentsPH(system); + ((OLGApropertyTableGeneratorWaterStudentsPH) operation).setFileName(filename); + ((OLGApropertyTableGeneratorWaterStudentsPH) operation).setPressureRange(minPres, maxPres, + pressureSteps); + ((OLGApropertyTableGeneratorWaterStudentsPH) operation).setEnthalpyRange(minEnthalpy, + maxEnthalpy, enthalpySteps); + getOperation().run(); + } + + /** + *+ * calcPloadingCurve. + *
+ */ + public void calcPloadingCurve() { + operation = new pLoadingCurve2(system); + // thisThread = new Thread(operation); + // thisThread.start(); + getOperation().run(); + } + + /** + *+ * calcHPTphaseEnvelope. + *
+ */ + public void calcHPTphaseEnvelope() { + operation = new HPTphaseEnvelope(system); + // thisThread = new Thread(getOperation()); + // thisThread.start(); + operation.run(); + } + + /** + *+ * printToFile. + *
+ * + * @param name a {@link java.lang.String} object + */ + public void printToFile(String name) { + getOperation().printToFile(name); + } + + // public double[] get(String name){ + // return operation.get(name); + // } + /** + *+ * getData. + *
+ * + * @return an array of {@link double} objects + */ + public double[][] getData() { + return getOperation().getPoints(0); + } + + /** + *+ * getDataPoints. + *
+ * + * @return an array of {@link java.lang.String} objects + */ + public String[][] getDataPoints() { + String[][] str = + new String[getOperation().getPoints(0).length][getOperation().getPoints(0)[0].length]; + for (int i = 0; i < getOperation().getPoints(0).length; i++) { + for (int j = 0; j < getOperation().getPoints(0)[0].length; j++) { + str[i][j] = Double.toString(getOperation().getPoints(0)[i][j]); + } + } + return str; + } + + /** + *
+ * Getter for the field resultTable
.
+ *
+ * dewPointTemperatureCondensationRate. + *
+ * + * @return a double + */ + public double dewPointTemperatureCondensationRate() { + double dT = 1.1; + try { + dewPointTemperatureFlash(); + } catch (Exception e) { + logger.error("error", e); + } + system.setTemperature(system.getTemperature() - dT); + TPflash(); + double condensationRate = system.getPhase(1).getMass() / (system.getVolume() * 1.0e-5); + try { + dewPointTemperatureFlash(); + } catch (Exception e) { + logger.error("error", e); + } + return condensationRate / dT; + } + + /** + *+ * displayResult. + *
+ */ + public void displayResult() { + try { + getThermoOperationThread().join(); + } catch (Exception e) { + logger.error("Thread did not finish"); + } + getOperation().displayResult(); + } + + /** + *
+ * Setter for the field resultTable
.
+ *
+ * display. + *
+ */ + public void display() { + JFrame dialog = new JFrame("System-Report"); + Container dialogContentPane = dialog.getContentPane(); + dialogContentPane.setLayout(new BorderLayout()); + + String[] names = new String[resultTable[0].length];// {"", "", ""}; + for (int i = 0; i < names.length; i++) { + names[i] = ""; + } + JTable Jtab = new JTable(resultTable, names); + JScrollPane scrollpane = new JScrollPane(Jtab); + dialogContentPane.add(scrollpane); + dialog.pack(); + dialog.setVisible(true); + } + + /** + *+ * get. + *
+ * + * @param name a {@link java.lang.String} object + * @return an array of {@link double} objects + */ + public double[] get(String name) { + return getOperation().get(name); + } + + /** + *
+ * Getter for the field operation
.
+ *
+ * isRunAsThread. + *
+ * + * @return the runAsThread + */ + public boolean isRunAsThread() { + return runAsThread; + } + + /** + *
+ * Setter for the field runAsThread
.
+ *
+ * Getter for the field thermoOperationThread
.
+ *
+ * Setter for the field thermoOperationThread
.
+ *
+ * addData. + *
+ * + * @param name a {@link java.lang.String} object + * @param data an array of {@link double} objects + */ + public void addData(String name, double[][] data) { + operation.addData(name, data); + } + + /** + *+ * calcIonComposition. + *
+ * + * @param phaseNumber a int + */ + public void calcIonComposition(int phaseNumber) { + operation = new calcIonicComposition(system, phaseNumber); + getOperation().run(); + resultTable = getOperation().getResultTable(); + } + + /** + *+ * flash. + *
+ * + * @param flashType a {@link java.lang.String} object + * @param spec1 a double + * @param spec2 a double + * @param unitSpec1 a {@link java.lang.String} object + * @param unitSpec2 a {@link java.lang.String} object + */ + public void flash(String flashType, double spec1, double spec2, String unitSpec1, + String unitSpec2) { + if (flashType.equals("TP")) { + system.setTemperature(spec1, unitSpec1); + system.setPressure(spec2, unitSpec2); + } else if (flashType.equals("TV")) { + system.setTemperature(spec1, unitSpec1); + TVflash(spec2, unitSpec2); + } else if (flashType.equals("PH")) { + system.setPressure(spec1, unitSpec1); + PHflash(spec2, unitSpec2); + } else if (flashType.equals("TS")) { + system.setTemperature(spec1, unitSpec1); + TSflash(spec2, unitSpec2); + } + } + + /** + * Perform flashes and return System properties per set of Spec1 and Spec2. + * + * Possible to specify fractions for each value of Spec1. + * + * + * @param Spec1 Flash pressure in bar absolute. + * @param Spec2 Flash specification. Depends on FlashMode. Temperature in Kelvin, entalphy in + * J/mol or entropy in J/molK. + * @param FlashMode 1 - PT 2 - PH 3 - PS + * @param components Not yet in use. + * @param onlineFractions Specify fractions per sample instance or null to use static composition + * specified in system. + * @return Object CalculationResult object + */ + public CalculationResult propertyFlash(List- * displayResult. - *
- */ - public void displayResult() { - try { - getThermoOperationThread().join(); - } catch (Exception e) { - logger.error("Thread did not finish"); - } - getOperation().displayResult(); - } - - /** - *- * writeNetCDF. - *
- * - * @param name a {@link java.lang.String} object - */ - public void writeNetCDF(String name) { - fileName = name; - getOperation().createNetCdfFile(name); - } - - /** - *
- * Setter for the field resultTable
.
- *
- * display. - *
- */ - public void display() { - JFrame dialog = new JFrame("System-Report"); - Container dialogContentPane = dialog.getContentPane(); - dialogContentPane.setLayout(new BorderLayout()); - - String[] names = new String[resultTable[0].length];// {"", "", ""}; - for (int i = 0; i < names.length; i++) { - names[i] = ""; - } - JTable Jtab = new JTable(resultTable, names); - JScrollPane scrollpane = new JScrollPane(Jtab); - dialogContentPane.add(scrollpane); - dialog.pack(); - dialog.setVisible(true); - } - - /** - *- * get. - *
- * - * @param name a {@link java.lang.String} object - * @return an array of {@link double} objects - */ - public double[] get(String name) { - return getOperation().get(name); - } - - /** - *
- * Getter for the field operation
.
- *
- * isRunAsThread. - *
- * - * @return the runAsThread - */ - public boolean isRunAsThread() { - return runAsThread; - } - - /** - *
- * Setter for the field runAsThread
.
- *
- * Getter for the field thermoOperationThread
.
- *
- * Setter for the field thermoOperationThread
.
- *
- * addData. - *
- * - * @param name a {@link java.lang.String} object - * @param data an array of {@link double} objects - */ - public void addData(String name, double[][] data) { - operation.addData(name, data); - } - - /** - *- * calcIonComposition. - *
- * - * @param phaseNumber a int - */ - public void calcIonComposition(int phaseNumber) { - operation = new calcIonicComposition(system, phaseNumber); - getOperation().run(); - resultTable = getOperation().getResultTable(); - } - - /** - *- * flash. - *
- * - * @param flashType a {@link java.lang.String} object - * @param spec1 a double - * @param spec2 a double - * @param unitSpec1 a {@link java.lang.String} object - * @param unitSpec2 a {@link java.lang.String} object - */ - public void flash(String flashType, double spec1, double spec2, String unitSpec1, - String unitSpec2) { - if (flashType.equals("TP")) { - system.setTemperature(spec1, unitSpec1); - system.setPressure(spec2, unitSpec2); - } else if (flashType.equals("TV")) { - system.setTemperature(spec1, unitSpec1); - TVflash(spec2, unitSpec2); - } else if (flashType.equals("PH")) { - system.setPressure(spec1, unitSpec1); - PHflash(spec2, unitSpec2); - } else if (flashType.equals("TS")) { - system.setTemperature(spec1, unitSpec1); - TSflash(spec2, unitSpec2); - } - } - - /** - * Perform flashes and return System properties per set of Spec1 and Spec2. - * - * Possible to specify fractions for each value of Spec1. - * - * - * @param Spec1 Flash pressure in bar absolute. - * @param Spec2 Flash specification. Depends on FlashMode. Temperature in Kelvin, entalphy in - * J/mol or entropy in J/molK. - * @param FlashMode 1 - PT 2 - PH 3 - PS - * @param components Not yet in use. - * @param onlineFractions Specify fractions per sample instance or null to use static - * composition specified in system. - * @return - */ - public CalculationResult propertyFlash(List- * Constructor for ChemicalEquilibrium. - *
- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public ChemicalEquilibrium(SystemInterface system) { - this.system = system; - } + /** + *+ * Constructor for ChemicalEquilibrium. + *
+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public ChemicalEquilibrium(SystemInterface system) { + this.system = system; + } - /** {@inheritDoc} */ - @Override - public void run() { - double chemdev = 0; - int iter = 1; - if (system.isChemicalSystem()) { - double oldHeat = system.getChemicalReactionOperations().getReactionList() - .reacHeat(system.getPhase(1), "HCO3-"); - do { - iter++; - for (int phase = 1; phase < system.getNumberOfPhases(); phase++) { - chemdev = 0.0; - double xchem[] = new double[system.getPhases()[phase].getNumberOfComponents()]; + /** {@inheritDoc} */ + @Override + public void run() { + double chemdev = 0; + int iter = 1; + if (system.isChemicalSystem()) { + double oldHeat = system.getChemicalReactionOperations().getReactionList() + .reacHeat(system.getPhase(1), "HCO3-"); + do { + iter++; + for (int phase = 1; phase < system.getNumberOfPhases(); phase++) { + chemdev = 0.0; + double xchem[] = new double[system.getPhases()[phase].getNumberOfComponents()]; - for (int i = 0; i < system.getPhases()[phase].getNumberOfComponents(); i++) { - xchem[i] = system.getPhases()[phase].getComponents()[i].getx(); - } + for (int i = 0; i < system.getPhases()[phase].getNumberOfComponents(); i++) { + xchem[i] = system.getPhases()[phase].getComponents()[i].getx(); + } - system.init(1); - system.getChemicalReactionOperations().solveChemEq(phase); + system.init(1); + system.getChemicalReactionOperations().solveChemEq(phase); - for (int i = 0; i < system.getPhases()[phase].getNumberOfComponents(); i++) { - chemdev += Math.abs( - xchem[i] - system.getPhases()[phase].getComponents()[i].getx()); - } - } - } while (Math.abs(chemdev) > 1e-4 && iter < 100); - double newHeat = system.getChemicalReactionOperations().getReactionList() - .reacHeat(system.getPhase(1), "HCO3-"); - system.getChemicalReactionOperations().setDeltaReactionHeat(newHeat - oldHeat); - } - if (iter > 50) { - logger.info("iter : " + iter + " in chemicalequilibrium"); + for (int i = 0; i < system.getPhases()[phase].getNumberOfComponents(); i++) { + chemdev += Math.abs(xchem[i] - system.getPhases()[phase].getComponents()[i].getx()); + } } + } while (Math.abs(chemdev) > 1e-4 && iter < 100); + double newHeat = system.getChemicalReactionOperations().getReactionList() + .reacHeat(system.getPhase(1), "HCO3-"); + system.getChemicalReactionOperations().setDeltaReactionHeat(newHeat - oldHeat); } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - system.display(); + if (iter > 50) { + logger.info("iter : " + iter + " in chemicalequilibrium"); } + } - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} + /** {@inheritDoc} */ + @Override + public void displayResult() { + system.display(); + } - /** {@inheritDoc} */ - @Override - public void createNetCdfFile(String name) {} + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} - /** {@inheritDoc} */ - @Override - public double[][] getPoints(int i) { - return null; - } + /** {@inheritDoc} */ + @Override + public double[][] getPoints(int i) { + return null; + } - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - return null; - } + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + return null; + } - /** {@inheritDoc} */ - @Override - public String[][] getResultTable() { - return null; - } + /** {@inheritDoc} */ + @Override + public String[][] getResultTable() { + return null; + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java index 4d9fab4c6b..ec5b05aad1 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java @@ -15,463 +15,453 @@ * @author Even Solbraa */ abstract class Flash extends BaseOperation { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(Flash.class); - - SystemInterface system; - SystemInterface minimumGibbsEnergySystem; - - public double[] minGibsPhaseLogZ; - public double[] minGibsLogFugCoef; - int i = 0, j = 0, iterations = 0, maxNumberOfIterations = 100; - double gibbsEnergy = 0, gibbsEnergyOld = 0; - double Kold = 0, deviation = 0, g0 = 0, g1 = 0; - double lnOldOldOldK[], lnOldOldK[], lnK[], lnOldK[]; - double oldoldDeltalnK[], oldDeltalnK[], deltalnK[]; - double tm[]; - int lowestGibbsEnergyPhase = 0; - sysNewtonRhapsonTPflash secondOrderSolver; - protected boolean solidCheck = false, stabilityCheck = false; - boolean findLowesGibsPhaseIsChecked = false; - - /** - *- * Constructor for Flash. - *
- */ - public Flash() {} - - /** - *- * findLowestGibbsEnergyPhase. - *
- * - * @return a int - */ - public int findLowestGibbsEnergyPhase() { - if (!findLowesGibsPhaseIsChecked) { - minimumGibbsEnergySystem = system.clone(); - minimumGibbsEnergySystem.init(0); - minimumGibbsEnergySystem.init(1); - if ((minimumGibbsEnergySystem.getPhase(0).getGibbsEnergy() - * (1.0 - Math.signum(minimumGibbsEnergySystem.getPhase(0).getGibbsEnergy()) - * 1e-8)) < minimumGibbsEnergySystem.getPhase(1).getGibbsEnergy()) { - lowestGibbsEnergyPhase = 0; - } else { - lowestGibbsEnergyPhase = 1; - } - findLowesGibsPhaseIsChecked = true; - } - return lowestGibbsEnergyPhase; + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(Flash.class); + + SystemInterface system; + SystemInterface minimumGibbsEnergySystem; + + public double[] minGibsPhaseLogZ; + public double[] minGibsLogFugCoef; + int i = 0, j = 0, iterations = 0, maxNumberOfIterations = 100; + double gibbsEnergy = 0, gibbsEnergyOld = 0; + double Kold = 0, deviation = 0, g0 = 0, g1 = 0; + double lnOldOldOldK[], lnOldOldK[], lnK[], lnOldK[]; + double oldoldDeltalnK[], oldDeltalnK[], deltalnK[]; + double tm[]; + int lowestGibbsEnergyPhase = 0; + sysNewtonRhapsonTPflash secondOrderSolver; + protected boolean solidCheck = false, stabilityCheck = false; + boolean findLowesGibsPhaseIsChecked = false; + + /** + *+ * Constructor for Flash. + *
+ */ + public Flash() {} + + /** + *+ * findLowestGibbsEnergyPhase. + *
+ * + * @return a int + */ + public int findLowestGibbsEnergyPhase() { + if (!findLowesGibsPhaseIsChecked) { + minimumGibbsEnergySystem = system.clone(); + minimumGibbsEnergySystem.init(0); + minimumGibbsEnergySystem.init(1); + if ((minimumGibbsEnergySystem.getPhase(0).getGibbsEnergy() + * (1.0 - Math.signum(minimumGibbsEnergySystem.getPhase(0).getGibbsEnergy()) + * 1e-8)) < minimumGibbsEnergySystem.getPhase(1).getGibbsEnergy()) { + lowestGibbsEnergyPhase = 0; + } else { + lowestGibbsEnergyPhase = 1; + } + findLowesGibsPhaseIsChecked = true; + } + return lowestGibbsEnergyPhase; + } + + /** + *+ * stabilityAnalysis. + *
+ * + * @throws neqsim.util.exception.IsNaNException if any. + * @throws neqsim.util.exception.TooManyIterationsException if any. + */ + public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + double[] logWi = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] deltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] oldDeltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] oldoldDeltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; + double[][] Wi = new double[2][system.getPhases()[0].getNumberOfComponents()]; + double[] sumw = new double[2]; + boolean secondOrderStabilityAnalysis = false; + double[] oldlogw = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] oldoldlogw = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] oldoldoldlogw = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] d = new double[system.getPhases()[0].getNumberOfComponents()]; + double[][] x = new double[2][system.getPhases()[0].getNumberOfComponents()]; + double[] error = new double[2]; + tm = new double[system.getPhase(0).getNumberOfComponents()]; + double[] alpha = null; + Matrix f = new Matrix(system.getPhases()[0].getNumberOfComponents(), 1); + Matrix df = null; + int maxiterations = 50; + double fNorm = 1.0e10, fNormOld = 0.0; + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + d[i] = minGibsPhaseLogZ[i] + minGibsLogFugCoef[i]; } - /** - *- * stabilityAnalysis. - *
- * - * @throws neqsim.util.exception.IsNaNException if any. - * @throws neqsim.util.exception.TooManyIterationsException if any. - */ - public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - double[] logWi = new double[system.getPhases()[0].getNumberOfComponents()]; - double[] deltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; - double[] oldDeltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; - double[] oldoldDeltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; - double[][] Wi = new double[2][system.getPhases()[0].getNumberOfComponents()]; - double[] sumw = new double[2]; - boolean secondOrderStabilityAnalysis = false; - double[] oldlogw = new double[system.getPhases()[0].getNumberOfComponents()]; - double[] oldoldlogw = new double[system.getPhases()[0].getNumberOfComponents()]; - double[] oldoldoldlogw = new double[system.getPhases()[0].getNumberOfComponents()]; - double[] d = new double[system.getPhases()[0].getNumberOfComponents()]; - double[][] x = new double[2][system.getPhases()[0].getNumberOfComponents()]; - double[] error = new double[2]; - tm = new double[system.getPhase(0).getNumberOfComponents()]; - double[] alpha = null; - Matrix f = new Matrix(system.getPhases()[0].getNumberOfComponents(), 1); - Matrix df = null; - int maxiterations = 50; - double fNorm = 1.0e10, fNormOld = 0.0; - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - d[i] = minGibsPhaseLogZ[i] + minGibsLogFugCoef[i]; - } + SystemInterface clonedSystem = minimumGibbsEnergySystem; + clonedSystem.setTotalNumberOfMoles(1.0); + sumw[1] = 0.0; + sumw[0] = 0.0; - SystemInterface clonedSystem = minimumGibbsEnergySystem; - clonedSystem.setTotalNumberOfMoles(1.0); - sumw[1] = 0.0; - sumw[0] = 0.0; + for (int i = 0; i < clonedSystem.getPhase(0).getNumberOfComponents(); i++) { + sumw[1] += clonedSystem.getPhase(0).getComponent(i).getz() + / clonedSystem.getPhase(0).getComponent(i).getK(); + sumw[0] += clonedSystem.getPhase(0).getComponent(i).getK() + * clonedSystem.getPhase(0).getComponent(i).getz(); + } - for (int i = 0; i < clonedSystem.getPhase(0).getNumberOfComponents(); i++) { - sumw[1] += clonedSystem.getPhase(0).getComponent(i).getz() - / clonedSystem.getPhase(0).getComponent(i).getK(); - sumw[0] += clonedSystem.getPhase(0).getComponent(i).getK() - * clonedSystem.getPhase(0).getComponent(i).getz(); - } + // System.out.println("sumw0 " + sumw[0]); + // System.out.println("sumw1 " + sumw[1]); + + int start = 0; + int end = 1;// clonedSystem.getNumberOfPhases()-1; + int mult = 1; + // if (sumw[1] > sumw[0]) { + if (lowestGibbsEnergyPhase == 0) { + start = end; + end = 0; + mult = -1; + } - // System.out.println("sumw0 " + sumw[0]); - // System.out.println("sumw1 " + sumw[1]); - - int start = 0; - int end = 1;// clonedSystem.getNumberOfPhases()-1; - int mult = 1; - // if (sumw[1] > sumw[0]) { - if (lowestGibbsEnergyPhase == 0) { - start = end; - end = 0; - mult = -1; - } + for (int i = 0; i < clonedSystem.getPhase(0).getNumberOfComponents(); i++) { + clonedSystem.getPhase(1).getComponent(i).setx(clonedSystem.getPhase(0).getComponent(i).getz() + / clonedSystem.getPhase(0).getComponent(i).getK() / sumw[1]); + clonedSystem.getPhase(0).getComponent(i).setx(clonedSystem.getPhase(0).getComponent(i).getK() + * clonedSystem.getPhase(0).getComponent(i).getz() / sumw[0]); + } - for (int i = 0; i < clonedSystem.getPhase(0).getNumberOfComponents(); i++) { - clonedSystem.getPhase(1).getComponent(i) - .setx(clonedSystem.getPhase(0).getComponent(i).getz() - / clonedSystem.getPhase(0).getComponent(i).getK() / sumw[1]); - clonedSystem.getPhase(0).getComponent(i) - .setx(clonedSystem.getPhase(0).getComponent(i).getK() - * clonedSystem.getPhase(0).getComponent(i).getz() / sumw[0]); + // for (int j = 0; j < clonedSystem.getNumberOfPhases(); j++) { + for (int j = start; j >= end; j = j + mult) { + for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + Wi[j][i] = clonedSystem.getPhase(j).getComponent(i).getx(); + logWi[i] = Math.log(Wi[j][i]); + } + iterations = 0; + fNorm = 1.0e10; + + do { + iterations++; + error[j] = 0.0; + + for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + oldoldoldlogw[i] = oldoldlogw[i]; + oldoldlogw[i] = oldlogw[i]; + oldlogw[i] = logWi[i]; + + oldoldDeltalogWi[i] = oldoldlogw[i] - oldoldoldlogw[i]; + oldDeltalogWi[i] = oldlogw[i] - oldoldlogw[i]; } - // for (int j = 0; j < clonedSystem.getNumberOfPhases(); j++) { - for (int j = start; j >= end; j = j + mult) { - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { - Wi[j][i] = clonedSystem.getPhase(j).getComponent(i).getx(); - logWi[i] = Math.log(Wi[j][i]); - } - iterations = 0; - fNorm = 1.0e10; - - do { - iterations++; - error[j] = 0.0; - - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { - oldoldoldlogw[i] = oldoldlogw[i]; - oldoldlogw[i] = oldlogw[i]; - oldlogw[i] = logWi[i]; - - oldoldDeltalogWi[i] = oldoldlogw[i] - oldoldoldlogw[i]; - oldDeltalogWi[i] = oldlogw[i] - oldoldlogw[i]; - } - - if ((iterations <= maxiterations - 10) - || !system.isImplementedCompositionDeriativesofFugacity()) { - clonedSystem.init(1, j); - fNormOld = fNorm; - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { - f.set(i, 0, Math.sqrt(Wi[j][i]) * (Math.log(Wi[j][i]) + clonedSystem - .getPhase(j).getComponent(i).getLogFugacityCoefficient() - d[i])); - } - fNorm = f.norm2(); - if (fNorm > fNormOld && iterations > 3 || (iterations + 1) % 7 != 0) { - break; - } - if (iterations % 7 == 0 && fNorm < fNormOld && !secondOrderStabilityAnalysis) { - double vec1 = 0.0, vec2 = 0.0, prod1 = 0.0, prod2 = 0.0; - - for (i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { - vec1 = oldDeltalogWi[i] * oldoldDeltalogWi[i]; - vec2 = Math.pow(oldoldDeltalogWi[i], 2.0); - prod1 += vec1 * vec2; - prod2 += vec2 * vec2; - } - - double lambda = prod1 / prod2; - // logger.info("lambda " + lambda); - for (i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { - logWi[i] += lambda / (1.0 - lambda) * deltalogWi[i]; - error[j] += Math.abs((logWi[i] - oldlogw[i]) / oldlogw[i]); - Wi[j][i] = Math.exp(logWi[i]); - } - } else { - // succsessive substitution - for (int i = 0; i < clonedSystem.getPhases()[0] - .getNumberOfComponents(); i++) { - logWi[i] = d[i] - clonedSystem.getPhase(j).getComponent(i) - .getLogFugacityCoefficient(); - error[j] += Math.abs((logWi[i] - oldlogw[i]) / oldlogw[i]); - Wi[j][i] = Math.exp(logWi[i]); - } - } - } else { - if (!secondOrderStabilityAnalysis) { - alpha = new double[system.getPhases()[0].getNumberOfComponents()]; - df = new Matrix(system.getPhases()[0].getNumberOfComponents(), - system.getPhases()[0].getNumberOfComponents()); - secondOrderStabilityAnalysis = true; - } - - clonedSystem.init(3, j); - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { - alpha[i] = 2.0 * Math.sqrt(Wi[j][i]); - } - - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { - f.set(i, 0, Math.sqrt(Wi[j][i]) * (Math.log(Wi[j][i]) + clonedSystem - .getPhase(j).getComponent(i).getLogFugacityCoefficient() - d[i])); - for (int k = 0; k < clonedSystem.getPhases()[0] - .getNumberOfComponents(); k++) { - double kronDelt = (i == k) ? 1.5 : 0.0; // adding 0.5 to diagonal - df.set(i, k, kronDelt + Math.sqrt(Wi[j][k] * Wi[j][i]) - * clonedSystem.getPhase(j).getComponent(i).getdfugdn(k));// * - // clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); - } - } - - Matrix dx = df.solve(f).times(-1.0); - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { - Wi[j][i] = Math.pow((alpha[i] + dx.get(i, 0)) / 2.0, 2.0); - logWi[i] = Math.log(Wi[j][i]); - error[j] += Math.abs((logWi[i] - oldlogw[i]) / oldlogw[i]); - } - - // logger.info("err newton " + error[j]); - } - - // logger.info("norm f " + f.norm1()); - // clonedSystem.display(); - sumw[j] = 0.0; - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { - sumw[j] += Wi[j][i]; - } - - for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { - deltalogWi[i] = logWi[i] - oldlogw[i]; - clonedSystem.getPhase(j).getComponent(i).setx(Wi[j][i] / sumw[j]); - } - // logger.info("fnorm " + f.norm1() + " err " + error[j] + " iterations " + - // iterations + " phase " + j); - } while ((f.norm1() > 1e-6 && iterations < maxiterations) || (iterations % 7) == 0 - || iterations < 3); - // (error[j]- * stabilityCheck. - *
- * - * @return a boolean - */ - public boolean stabilityCheck() { - boolean stable = false; - // logger.info("starting stability analysis...."); - lowestGibbsEnergyPhase = findLowestGibbsEnergyPhase(); - if (system.getPhase(lowestGibbsEnergyPhase).getNumberOfComponents() > 1) { - try { - stabilityAnalysis(); - } catch (Exception e) { - logger.error("error ", e); - } + if (((tm[0] < -1e-4) || (tm[1] < -1e-4)) && !(Double.isNaN(tm[0]) || (Double.isNaN(tm[1])))) { + for (int i = 0; i < clonedSystem.getPhases()[0].getNumberOfComponents(); i++) { + if (system.getPhases()[1].getComponents()[i].getx() < 1e-100) { + continue; } - if (!(tm[0] < -1e-4) && !(tm[1] < -1e-4) - || system.getPhase(0).getNumberOfComponents() == 1) { - stable = true; - system.init(0); - // logger.info("system is stable"); - // logger.info("Stable phase is : " + lowestGibbsEnergyPhase); - system.setNumberOfPhases(1); - - if (lowestGibbsEnergyPhase == 0) { - system.setPhaseType(0, 1); - } else { - system.setPhaseType(0, 0); - } - system.init(1); - if (solidCheck && !system.doMultiPhaseCheck()) { - this.solidPhaseFlash(); - } + if (tm[0] < -1e-4) { + system.getPhases()[1].getComponents()[i] + .setK((Wi[0][i] / sumw[0]) / (Wi[1][i] / sumw[1])); + system.getPhases()[0].getComponents()[i] + .setK((Wi[0][i] / sumw[0]) / (Wi[1][i] / sumw[1])); + } else if (tm[1] < -1e-4) { + system.getPhases()[1].getComponents()[i] + .setK((Wi[0][i] / sumw[0]) / (Wi[1][i] / sumw[1])); + system.getPhases()[0].getComponents()[i] + .setK((Wi[0][i] / sumw[0]) / (Wi[1][i] / sumw[1])); } else { - try { - system.calcBeta(); - } catch (Exception e) { - logger.error("error", e); - } - system.calc_x_y(); - system.init(1); + logger.info("error in stability anlysis"); + system.init(0); } - return stable; + if (Double.isNaN(tm[j])) { + tm[j] = 0; + } + } } - /** {@inheritDoc} */ - @Override - public void displayResult() { - system.display(); + // logger.info("STABILITY ANALYSIS: "); + // logger.info("tm1: " + tm[0] + " tm2: " + tm[1]); + } + + /** + *+ * stabilityCheck. + *
+ * + * @return a boolean + */ + public boolean stabilityCheck() { + boolean stable = false; + // logger.info("starting stability analysis...."); + lowestGibbsEnergyPhase = findLowestGibbsEnergyPhase(); + if (system.getPhase(lowestGibbsEnergyPhase).getNumberOfComponents() > 1) { + try { + stabilityAnalysis(); + } catch (Exception e) { + logger.error("error ", e); + } + } + if (!(tm[0] < -1e-4) && !(tm[1] < -1e-4) || system.getPhase(0).getNumberOfComponents() == 1) { + stable = true; + system.init(0); + // logger.info("system is stable"); + // logger.info("Stable phase is : " + lowestGibbsEnergyPhase); + system.setNumberOfPhases(1); + + if (lowestGibbsEnergyPhase == 0) { + system.setPhaseType(0, 1); + } else { + system.setPhaseType(0, 0); + } + system.init(1); + if (solidCheck && !system.doMultiPhaseCheck()) { + this.solidPhaseFlash(); + } + } else { + try { + system.calcBeta(); + } catch (Exception e) { + logger.error("error", e); + } + system.calc_x_y(); + system.init(1); } - /** - *- * solidPhaseFlash. - *
- */ - public void solidPhaseFlash() { - boolean solidPhase = false; - double frac = 0; - int solid = 0; - double[] tempVar = new double[system.getPhases()[0].getNumberOfComponents()]; - - if (!system.hasSolidPhase()) { - system.setNumberOfPhases(system.getNumberOfPhases() + 1); - system.setPhaseIndex(system.getNumberOfPhases() - 1, 3); - } - // logger.info("numb " + system.getNumberOfPhases()); - system.init(1); - - for (int k = 0; k < system.getPhase(0).getNumberOfComponents(); k++) { - if (system.getPhase(0).getComponent(k).doSolidCheck()) { - tempVar[k] = system.getPhase(0).getComponents()[k].getz(); - for (int i = 0; i < system.getNumberOfPhases() - 1; i++) { - tempVar[k] -= system.getBeta(i) - * system.getPhases()[3].getComponent(k).getFugacityCoefficient() - / system.getPhase(i).getComponent(k).getFugacityCoefficient(); - } - - if (tempVar[k] > 0.0 && tempVar[k] > frac) { - solidPhase = true; - solid = k; - frac = tempVar[k]; - for (int p = 0; p < system.getPhases()[0].getNumberOfComponents(); p++) { - system.getPhases()[3].getComponents()[p].setx(1.0e-20); - } - system.getPhases()[3].getComponents()[solid].setx(1.0); - } - // logger.info("tempVar: " + tempVar[k]); - } + return stable; + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + system.display(); + } + + /** + *+ * solidPhaseFlash. + *
+ */ + public void solidPhaseFlash() { + boolean solidPhase = false; + double frac = 0; + int solid = 0; + double[] tempVar = new double[system.getPhases()[0].getNumberOfComponents()]; + + if (!system.hasSolidPhase()) { + system.setNumberOfPhases(system.getNumberOfPhases() + 1); + system.setPhaseIndex(system.getNumberOfPhases() - 1, 3); + } + // logger.info("numb " + system.getNumberOfPhases()); + system.init(1); + + for (int k = 0; k < system.getPhase(0).getNumberOfComponents(); k++) { + if (system.getPhase(0).getComponent(k).doSolidCheck()) { + tempVar[k] = system.getPhase(0).getComponents()[k].getz(); + for (int i = 0; i < system.getNumberOfPhases() - 1; i++) { + tempVar[k] -= + system.getBeta(i) * system.getPhases()[3].getComponent(k).getFugacityCoefficient() + / system.getPhase(i).getComponent(k).getFugacityCoefficient(); } - if (solidPhase) { - if (frac < system.getPhases()[0].getComponents()[solid].getz() + 1e10) { - for (int i = 0; i < system.getNumberOfPhases() - 1; i++) { - // system.getPhases()[i].getComponents()[solid].setx(1.0e-10); - } - system.init(1); - // logger.info("solid phase will form..." + system.getNumberOfPhases()); - // logger.info("freezing component " + solid); - system.setBeta(system.getNumberOfPhases() - 1, frac); - system.initBeta(); - system.setBeta(system.getNumberOfPhases() - 1, - system.getPhases()[3].getComponent(solid).getNumberOfmoles() - / system.getNumberOfMoles()); - // double phasetot=0.0; - // for(int ph=0;ph- * Constructor for TPflash. - *
- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - 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()]; + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(TPflash.class); + + SystemInterface clonedSystem; + double betaTolerance = neqsim.thermo.ThermodynamicModelSettings.phaseFractionMinimumLimit; + double presdiff = 1.0; + + /** + *+ * Constructor for TPflash. + *
+ */ + public TPflash() {} + + /** + *+ * Constructor for TPflash. + *
+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + 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()]; + } + + /** + *+ * Constructor for TPflash. + *
+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param solCheck a boolean + */ + public TPflash(SystemInterface system, boolean solCheck) { + this(system); + solidCheck = solCheck; + } + + /** + *+ * sucsSubs. + *
+ */ + public void sucsSubs() { + deviation = 0; + + for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { + Kold = system.getPhase(0).getComponent(i).getK(); + system.getPhase(0).getComponent(i).setK(1.0e-40); + system.getPhase(1).getComponent(i).setK(system.getPhase(0).getComponent(i).getK()); + } else { + Kold = system.getPhase(0).getComponent(i).getK(); + system.getPhase(0).getComponent(i) + .setK(system.getPhase(1).getComponent(i).getFugacityCoefficient() + / system.getPhase(0).getComponent(i).getFugacityCoefficient() * presdiff); + if (Double.isNaN(system.getPhase(0).getComponent(i).getK())) { + system.getPhase(0).getComponent(i).setK(Kold); + system.init(1); + } + system.getPhase(1).getComponent(i).setK(system.getPhase(0).getComponent(i).getK()); + deviation += Math.abs(Math.log(system.getPhase(0).getComponent(i).getK()) - Math.log(Kold)); + } } - /** - *- * Constructor for TPflash. - *
- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param solCheck a boolean - */ - public TPflash(SystemInterface system, boolean solCheck) { - this(system); - solidCheck = solCheck; + double oldBeta = system.getBeta(); + try { + system.calcBeta(); + } catch (Exception e) { + logger.error("error in beta calc" + e.toString()); + system.setBeta(oldBeta); + } + if (system.getBeta() > 1.0 - betaTolerance) { + system.setBeta(1.0 - betaTolerance); + } + if (system.getBeta() < betaTolerance) { + system.setBeta(betaTolerance); + } + system.calc_x_y(); + system.init(1); + } + + /** + *+ * accselerateSucsSubs. + *
+ */ + public void accselerateSucsSubs() { + double prod1 = 0.0, prod2 = 0.0; + + for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + prod1 += oldDeltalnK[i] * oldoldDeltalnK[i]; + prod2 += oldoldDeltalnK[i] * oldoldDeltalnK[i]; } - /** - *- * sucsSubs. - *
- */ - public void sucsSubs() { - deviation = 0; - - for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { - Kold = system.getPhase(0).getComponent(i).getK(); - system.getPhase(0).getComponent(i).setK(1.0e-40); - system.getPhase(1).getComponent(i).setK(system.getPhase(0).getComponent(i).getK()); - } else { - Kold = system.getPhase(0).getComponent(i).getK(); - system.getPhase(0).getComponent(i) - .setK(system.getPhase(1).getComponent(i).getFugacityCoefficient() - / system.getPhase(0).getComponent(i).getFugacityCoefficient() - * presdiff); - if (Double.isNaN(system.getPhase(0).getComponent(i).getK())) { - system.getPhase(0).getComponent(i).setK(Kold); - system.init(1); - } - system.getPhase(1).getComponent(i).setK(system.getPhase(0).getComponent(i).getK()); - deviation += Math - .abs(Math.log(system.getPhase(0).getComponent(i).getK()) - Math.log(Kold)); - } - } + double lambda = prod1 / prod2; - double oldBeta = system.getBeta(); - try { - system.calcBeta(); - } catch (Exception e) { - logger.error("error in beta calc" + e.toString()); - system.setBeta(oldBeta); - } - if (system.getBeta() > 1.0 - betaTolerance) { - system.setBeta(1.0 - betaTolerance); - } - if (system.getBeta() < betaTolerance) { - system.setBeta(betaTolerance); - } - system.calc_x_y(); - system.init(1); + for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + // lnK[i] = lnK[i] + lambda*lambda*oldoldDeltalnK[i]/(1.0-lambda); // byttet + + // til - + lnK[i] += lambda / (1.0 - lambda) * deltalnK[i]; + system.getPhase(0).getComponent(i).setK(Math.exp(lnK[i])); + system.getPhase(1).getComponent(i).setK(Math.exp(lnK[i])); + } + double oldBeta = system.getBeta(); + try { + system.calcBeta(); + } catch (Exception e) { + if (system.getBeta() > 1.0 - betaTolerance || system.getBeta() < betaTolerance) { + system.setBeta(oldBeta); + } + logger.info("temperature " + system.getTemperature() + " pressure " + system.getPressure()); + logger.error("error", e); } - /** - *- * accselerateSucsSubs. - *
- */ - public void accselerateSucsSubs() { - double prod1 = 0.0, prod2 = 0.0; - - for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - prod1 += oldDeltalnK[i] * oldoldDeltalnK[i]; - prod2 += oldoldDeltalnK[i] * oldoldDeltalnK[i]; - } + system.calc_x_y(); + system.init(1); + // sucsSubs(); + } + + /** + *+ * setNewK. + *
+ */ + public void setNewK() { + for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + lnOldOldOldK[i] = lnOldOldK[i]; + lnOldOldK[i] = lnOldK[i]; + lnOldK[i] = lnK[i]; + lnK[i] = Math.log(system.getPhase(1).getComponent(i).getFugacityCoefficient()) + - Math.log(system.getPhase(0).getComponents()[i].getFugacityCoefficient()); + + oldoldDeltalnK[i] = lnOldOldK[i] - lnOldOldOldK[i]; + oldDeltalnK[i] = lnOldK[i] - lnOldOldK[i]; + deltalnK[i] = lnK[i] - lnOldK[i]; + } + } + + /** + *+ * resetK. + *
+ */ + public void resetK() { + + for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + lnK[i] = lnOldK[i]; + system.getPhase(0).getComponents()[i].setK(Math.exp(lnK[i])); + system.getPhase(1).getComponents()[i].setK(Math.exp(lnK[i])); + } + try { + system.calcBeta(); + system.calc_x_y(); + system.init(1); + } catch (Exception e) { + logger.error("error", e); + } + } + + /** {@inheritDoc} */ + @Override + public void run() { + if (system.isForcePhaseTypes() && system.getMaxNumberOfPhases() == 1) { + system.setNumberOfPhases(1); + return; + } - double lambda = prod1 / prod2; + findLowesGibsPhaseIsChecked = false; + int minGibbsPhase = 0; + double minimumGibbsEnergy = 0; - for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - // lnK[i] = lnK[i] + lambda*lambda*oldoldDeltalnK[i]/(1.0-lambda); // byttet + - // til - - lnK[i] += lambda / (1.0 - lambda) * deltalnK[i]; - system.getPhase(0).getComponent(i).setK(Math.exp(lnK[i])); - system.getPhase(1).getComponent(i).setK(Math.exp(lnK[i])); - } - double oldBeta = system.getBeta(); - try { - system.calcBeta(); - } catch (Exception e) { - if (system.getBeta() > 1.0 - betaTolerance || system.getBeta() < betaTolerance) { - system.setBeta(oldBeta); - } - logger.info( - "temperature " + system.getTemperature() + " pressure " + system.getPressure()); - logger.error("error", e); - } + system.init(0); + system.init(1); - system.calc_x_y(); - system.init(1); - // sucsSubs(); + if (system.getPhase(0).getGibbsEnergy() < system.getPhase(1).getGibbsEnergy()) { + minimumGibbsEnergy = system.getPhase(0).getGibbsEnergy(); + } else { + minGibbsPhase = 1; + minimumGibbsEnergy = system.getPhase(1).getGibbsEnergy(); } - /** - *- * setNewK. - *
- */ - public void setNewK() { - for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - lnOldOldOldK[i] = lnOldOldK[i]; - lnOldOldK[i] = lnOldK[i]; - lnOldK[i] = lnK[i]; - lnK[i] = Math.log(system.getPhase(1).getComponent(i).getFugacityCoefficient()) - - Math.log(system.getPhase(0).getComponents()[i].getFugacityCoefficient()); - - oldoldDeltalnK[i] = lnOldOldK[i] - lnOldOldOldK[i]; - oldDeltalnK[i] = lnOldK[i] - lnOldOldK[i]; - deltalnK[i] = lnK[i] - lnOldK[i]; - } + if (system.getPhase(0).getNumberOfComponents() == 1 || system.getMaxNumberOfPhases() == 1) { + system.setNumberOfPhases(1); + if (minGibbsPhase == 0) { + system.setPhaseIndex(0, 0); + } else { + system.setPhaseIndex(0, 1); + } + if (solidCheck) { + ThermodynamicOperations operation = new ThermodynamicOperations(system); + operation.TPSolidflash(); + } + return; } - /** - *- * resetK. - *
- */ - public void resetK() { - for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - lnK[i] = lnOldK[i]; - system.getPhase(0).getComponents()[i].setK(Math.exp(lnK[i])); - system.getPhase(1).getComponents()[i].setK(Math.exp(lnK[i])); - } - try { - system.calcBeta(); - system.calc_x_y(); - system.init(1); - } catch (Exception e) { - logger.error("error", e); - } + minGibsPhaseLogZ = new double[system.getPhase(0).getNumberOfComponents()]; + minGibsLogFugCoef = new double[system.getPhase(0).getNumberOfComponents()]; + + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + minGibsPhaseLogZ[i] = Math.log(system.getPhase(minGibbsPhase).getComponent(i).getz()); + minGibsLogFugCoef[i] = + system.getPhase(minGibbsPhase).getComponent(i).getLogFugacityCoefficient(); } - /** {@inheritDoc} */ - @Override - public void run() { - if (system.isForcePhaseTypes() && system.getMaxNumberOfPhases() == 1) { - system.setNumberOfPhases(1); - return; - } + presdiff = system.getPhase(1).getPressure() / system.getPhase(0).getPressure(); + if (Math.abs(system.getPhase(0).getPressure() - system.getPhase(1).getPressure()) > 1e-12) { + for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + system.getPhase(0).getComponent(i) + .setK(system.getPhase(0).getComponent(i).getK() * presdiff); + system.getPhase(1).getComponent(i).setK(system.getPhase(0).getComponent(i).getK()); + } + } - findLowesGibsPhaseIsChecked = false; - int minGibbsPhase = 0; - double minimumGibbsEnergy = 0; + if (system.isChemicalSystem()) { + system.getChemicalReactionOperations().solveChemEq(1, 0); + system.getChemicalReactionOperations().solveChemEq(1, 1); + } - system.init(0); - system.init(1); + // Calculates phase fractions and initial composition based on Wilson K-factors + try { + system.calcBeta(); + } catch (Exception e) { + logger.error("error", e); + } + system.calc_x_y(); + system.init(1); + // If phase fraction using Wilson K factor returns pure gas or pure liquid, we + // try with another K value guess based on calculated fugacities. + // This solves some problems when we have high volumes of water and heavy + // hydrocarbons returning only one liquid phase (and this phase desolves all + // gas) + if (system.getBeta() > (1.0 - betaTolerance * 1.1) + || system.getBeta() < (betaTolerance * 1.1)) { + system.setBeta(0.5); + sucsSubs(); + } - if (system.getPhase(0).getGibbsEnergy() < system.getPhase(1).getGibbsEnergy()) { - minimumGibbsEnergy = system.getPhase(0).getGibbsEnergy(); - } else { - minGibbsPhase = 1; - minimumGibbsEnergy = system.getPhase(1).getGibbsEnergy(); + // Performs three iterations of successive substitution + for (int k = 0; k < 3; k++) { + if (system.getBeta() < (1.0 - betaTolerance * 1.1) + && system.getBeta() > (betaTolerance * 1.1)) { + sucsSubs(); + if ((system.getGibbsEnergy() - minimumGibbsEnergy) + / Math.abs(minimumGibbsEnergy) < -1e-12) { + break; } + } + } - if (system.getPhase(0).getNumberOfComponents() == 1 || system.getMaxNumberOfPhases() == 1) { - system.setNumberOfPhases(1); - if (minGibbsPhase == 0) { - system.setPhaseIndex(0, 0); - } else { - system.setPhaseIndex(0, 1); - } - if (solidCheck) { - ThermodynamicOperations operation = new ThermodynamicOperations(system); - operation.TPSolidflash(); - } - return; + // System.out.println("beta " + system.getBeta()); + + int totiter = 0; + double tpdx = 1.0; + double tpdy = 1.0; + double dgonRT = 1.0; + boolean passedTests = false; + if (system.getBeta() > (1.0 - 1.1 * betaTolerance) + || system.getBeta() < (1.1 * betaTolerance)) { + tpdx = 1.0; + tpdy = 1.0; + dgonRT = 1.0; + } else if (system.getGibbsEnergy() < (minimumGibbsEnergy * (1.0 - 1.0e-12))) { + tpdx = -1.0; + tpdy = -1.0; + dgonRT = -1.0; + } else { + for (i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + tpdy += system.getPhase(0).getComponent(i).getx() + * (Math.log(system.getPhase(0).getComponent(i).getFugacityCoefficient()) + + Math.log(system.getPhase(0).getComponents()[i].getx()) - minGibsPhaseLogZ[i] + - minGibsLogFugCoef[i]); + tpdx += system.getPhase(1).getComponent(i).getx() + * (Math.log(system.getPhase(1).getComponent(i).getFugacityCoefficient()) + + Math.log(system.getPhase(1).getComponents()[i].getx()) - minGibsPhaseLogZ[i] + - minGibsLogFugCoef[i]); + } + + dgonRT = system.getPhase(0).getBeta() * tpdy + (1.0 - system.getPhase(0).getBeta()) * tpdx; + + if (dgonRT > 0) { + if (tpdx < 0) { + for (i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + system.getPhase(0).getComponent(i) + .setK(Math.exp(Math.log(system.getPhase(1).getComponent(i).getFugacityCoefficient()) + - minGibsLogFugCoef[i]) * presdiff); + system.getPhase(1).getComponent(i).setK(system.getPhase(0).getComponent(i).getK()); + } + } else if (tpdy < 0) { + for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + system.getPhase(0).getComponents()[i].setK(Math + .exp(minGibsLogFugCoef[i] + - Math.log(system.getPhase(0).getComponent(i).getFugacityCoefficient())) + * presdiff); + system.getPhase(1).getComponent(i).setK(system.getPhase(0).getComponent(i).getK()); + } + } else { + passedTests = true; } + } + } - minGibsPhaseLogZ = new double[system.getPhase(0).getNumberOfComponents()]; - minGibsLogFugCoef = new double[system.getPhase(0).getNumberOfComponents()]; + if (passedTests || (dgonRT > 0 && tpdx > 0 && tpdy > 0) || Double.isNaN(system.getBeta())) { + if (system.checkStability()) { + if (stabilityCheck()) { + if (system.doMultiPhaseCheck()) { + // logger.info("one phase flash is stable - checking multiphase flash.... + // "); + TPmultiflash operation = new TPmultiflash(system, true); + operation.run(); + // commented out by Even Solbraa 6/2-2012k + // system.orderByDensity(); + // system.init(3); + } + if (solidCheck) { + this.solidPhaseFlash(); + } + if (system.isMultiphaseWaxCheck()) { + TPmultiflashWAX operation = new TPmultiflashWAX(system, true); + operation.run(); + } - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - minGibsPhaseLogZ[i] = Math.log(system.getPhase(minGibbsPhase).getComponent(i).getz()); - minGibsLogFugCoef[i] = - system.getPhase(minGibbsPhase).getComponent(i).getLogFugacityCoefficient(); + system.orderByDensity(); + system.init(1); + return; } + } + } - presdiff = system.getPhase(1).getPressure() / system.getPhase(0).getPressure(); - if (Math.abs(system.getPhase(0).getPressure() - system.getPhase(1).getPressure()) > 1e-12) { - for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - system.getPhase(0).getComponent(i) - .setK(system.getPhase(0).getComponent(i).getK() * presdiff); - system.getPhase(1).getComponent(i).setK(system.getPhase(0).getComponent(i).getK()); - } - } + setNewK(); - if (system.isChemicalSystem()) { - system.getChemicalReactionOperations().solveChemEq(1, 0); - system.getChemicalReactionOperations().solveChemEq(1, 1); - } + gibbsEnergy = system.getGibbsEnergy(); + gibbsEnergyOld = gibbsEnergy; - // Calculates phase fractions and initial composition based on Wilson K-factors - try { - system.calcBeta(); - } catch (Exception e) { - logger.error("error", e); - } - system.calc_x_y(); - system.init(1); - // If phase fraction using Wilson K factor returns pure gas or pure liquid, we - // try with another K value guess based on calculated fugacities. - // This solves some problems when we have high volumes of water and heavy - // hydrocarbons returning only one liquid phase (and this phase desolves all - // gas) - if (system.getBeta() > (1.0 - betaTolerance * 1.1) - || system.getBeta() < (betaTolerance * 1.1)) { - system.setBeta(0.5); - sucsSubs(); - } - - // Performs three iterations of successive substitution - for (int k = 0; k < 3; k++) { - if (system.getBeta() < (1.0 - betaTolerance * 1.1) - && system.getBeta() > (betaTolerance * 1.1)) { - sucsSubs(); - if ((system.getGibbsEnergy() - minimumGibbsEnergy) - / Math.abs(minimumGibbsEnergy) < -1e-12) { - break; - } - } - } + // Checks if gas or oil is the most stable phase + double gasgib = system.getPhase(0).getGibbsEnergy(); + system.setPhaseType(0, 0); + system.init(1, 0); + double liqgib = system.getPhase(0).getGibbsEnergy(); - // System.out.println("beta " + system.getBeta()); - - int totiter = 0; - double tpdx = 1.0; - double tpdy = 1.0; - double dgonRT = 1.0; - boolean passedTests = false; - if (system.getBeta() > (1.0 - 1.1 * betaTolerance) - || system.getBeta() < (1.1 * betaTolerance)) { - tpdx = 1.0; - tpdy = 1.0; - dgonRT = 1.0; - } else if (system.getGibbsEnergy() < (minimumGibbsEnergy * (1.0 - 1.0e-12))) { - tpdx = -1.0; - tpdy = -1.0; - dgonRT = -1.0; + if (gasgib * (1.0 - Math.signum(gasgib) * 1e-8) < liqgib) { + system.setPhaseType(0, 1); + } + system.init(1); + + int accelerateInterval = 7; + int newtonLimit = 20; + int timeFromLastGibbsFail = 0; + + double chemdev = 0, oldChemDiff = 1.0, diffChem = 1.0; + do { + iterations = 0; + do { + iterations++; + + if (iterations < newtonLimit || system.isChemicalSystem() + || !system.isImplementedCompositionDeriativesofFugacity()) { + if (timeFromLastGibbsFail > 6 && (iterations % accelerateInterval) == 0 + && !(system.isChemicalSystem() || system.doSolidPhaseCheck())) { + accselerateSucsSubs(); + } else { + sucsSubs(); + } + } 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()); + } + try { + deviation = secondOrderSolver.solve(); + } catch (Exception e) { + sucsSubs(); + } } else { - for (i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - tpdy += system.getPhase(0).getComponent(i).getx() - * (Math.log(system.getPhase(0).getComponent(i).getFugacityCoefficient()) - + Math.log(system.getPhase(0).getComponents()[i].getx()) - - minGibsPhaseLogZ[i] - minGibsLogFugCoef[i]); - tpdx += system.getPhase(1).getComponent(i).getx() - * (Math.log(system.getPhase(1).getComponent(i).getFugacityCoefficient()) - + Math.log(system.getPhase(1).getComponents()[i].getx()) - - minGibsPhaseLogZ[i] - minGibsLogFugCoef[i]); - } - - dgonRT = system.getPhase(0).getBeta() * tpdy - + (1.0 - system.getPhase(0).getBeta()) * tpdx; - - if (dgonRT > 0) { - if (tpdx < 0) { - for (i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - system.getPhase(0).getComponent(i) - .setK(Math.exp(Math.log( - system.getPhase(1).getComponent(i).getFugacityCoefficient()) - - minGibsLogFugCoef[i]) * presdiff); - system.getPhase(1).getComponent(i) - .setK(system.getPhase(0).getComponent(i).getK()); - } - } else if (tpdy < 0) { - for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - system.getPhase(0).getComponents()[i] - .setK(Math - .exp(minGibsLogFugCoef[i] - Math.log(system.getPhase(0) - .getComponent(i).getFugacityCoefficient())) - * presdiff); - system.getPhase(1).getComponent(i) - .setK(system.getPhase(0).getComponent(i).getK()); - } - } else { - passedTests = true; - } - } - } - - if (passedTests || (dgonRT > 0 && tpdx > 0 && tpdy > 0) || Double.isNaN(system.getBeta())) { - if (system.checkStability()) { - if (stabilityCheck()) { - if (system.doMultiPhaseCheck()) { - // logger.info("one phase flash is stable - checking multiphase flash.... - // "); - TPmultiflash operation = new TPmultiflash(system, true); - operation.run(); - // commented out by Even Solbraa 6/2-2012k - // system.orderByDensity(); - // system.init(3); - } - if (solidCheck) { - this.solidPhaseFlash(); - } - if (system.isMultiphaseWaxCheck()) { - TPmultiflashWAX operation = new TPmultiflashWAX(system, true); - operation.run(); - } - - system.orderByDensity(); - system.init(1); - return; - } - } + sucsSubs(); } - setNewK(); - - gibbsEnergy = system.getGibbsEnergy(); gibbsEnergyOld = gibbsEnergy; + gibbsEnergy = system.getGibbsEnergy(); - // Checks if gas or oil is the most stable phase - double gasgib = system.getPhase(0).getGibbsEnergy(); - system.setPhaseType(0, 0); - system.init(1, 0); - double liqgib = system.getPhase(0).getGibbsEnergy(); - - if (gasgib * (1.0 - Math.signum(gasgib) * 1e-8) < liqgib) { - system.setPhaseType(0, 1); - } - system.init(1); - - int accelerateInterval = 7; - int newtonLimit = 20; - int timeFromLastGibbsFail = 0; - - double chemdev = 0, oldChemDiff = 1.0, diffChem = 1.0; - do { - iterations = 0; - do { - iterations++; - - if (iterations < newtonLimit || system.isChemicalSystem() - || !system.isImplementedCompositionDeriativesofFugacity()) { - if (timeFromLastGibbsFail > 6 && (iterations % accelerateInterval) == 0 - && !(system.isChemicalSystem() || system.doSolidPhaseCheck())) { - accselerateSucsSubs(); - } else { - sucsSubs(); - } - } 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()); - } - try { - deviation = secondOrderSolver.solve(); - } catch (Exception e) { - sucsSubs(); - } - } else { - sucsSubs(); - } - - gibbsEnergyOld = gibbsEnergy; - gibbsEnergy = system.getGibbsEnergy(); - - if ((gibbsEnergy - gibbsEnergyOld) / Math.abs(gibbsEnergyOld) > 1e-3 - && !system.isChemicalSystem()) { - resetK(); - timeFromLastGibbsFail = 0; - // logger.info("gibbs decrease " + (gibbsEnergy - gibbsEnergyOld) / - // Math.abs(gibbsEnergyOld)); - // setNewK(); - // logger.info("reset K.."); - } else { - timeFromLastGibbsFail++; - setNewK(); - } - // logger.info("iterations " + iterations + " error " + deviation); - } while ((deviation > 1e-10) && (iterations < maxNumberOfIterations)); - // logger.info("iterations " + iterations + " error " + deviation); - if (system.isChemicalSystem()) { - oldChemDiff = chemdev; - chemdev = 0.0; - - double xchem[] = new double[system.getPhase(0).getNumberOfComponents()]; - - for (int phase = 1; phase < system.getNumberOfPhases(); phase++) { - for (i = 0; i < system.getPhases()[phase].getNumberOfComponents(); i++) { - xchem[i] = system.getPhase(phase).getComponent(i).getx(); - } - - system.init(1); - system.getChemicalReactionOperations().solveChemEq(phase, 1); - - for (i = 0; i < system.getPhases()[phase].getNumberOfComponents(); i++) { - chemdev += - Math.abs(xchem[i] - system.getPhase(phase).getComponent(i).getx()) - / xchem[i]; - } - } - diffChem = Math.abs(oldChemDiff - chemdev); - } - // logger.info("chemdev: " + chemdev + " iter: " + totiter); - totiter++; - } while ((diffChem > 1e-6 && chemdev > 1e-6 && totiter < 300) - || (system.isChemicalSystem() && totiter < 2)); - if (system.isChemicalSystem()) { - sucsSubs(); - } - - // Checks if gas or oil is the most stable phase - if (system.getPhase(0).getPhaseType() == 1) { - gasgib = system.getPhase(0).getGibbsEnergy(); - system.setPhaseType(0, 0); - system.init(1, 0); - liqgib = system.getPhase(0).getGibbsEnergy(); + if ((gibbsEnergy - gibbsEnergyOld) / Math.abs(gibbsEnergyOld) > 1e-3 + && !system.isChemicalSystem() && timeFromLastGibbsFail>0) { + resetK(); + timeFromLastGibbsFail = 0; + // logger.info("gibbs decrease " + (gibbsEnergy - gibbsEnergyOld) / + // Math.abs(gibbsEnergyOld)); + // setNewK(); + // logger.info("reset K.."); } else { - liqgib = system.getPhase(0).getGibbsEnergy(); - system.setPhaseType(0, 1); - system.init(1, 0); - gasgib = system.getPhase(0).getGibbsEnergy(); + timeFromLastGibbsFail++; + setNewK(); } - - if (gasgib * (1.0 - Math.signum(gasgib) * 1e-8) < liqgib) { - system.setPhaseType(0, 1); + // logger.info("iterations " + iterations + " error " + deviation); + } while ((deviation > 1e-10) && (iterations < maxNumberOfIterations)); + // logger.info("iterations " + iterations + " error " + deviation); + if (system.isChemicalSystem()) { + oldChemDiff = chemdev; + chemdev = 0.0; + + double xchem[] = new double[system.getPhase(0).getNumberOfComponents()]; + + for (int phase = 1; phase < system.getNumberOfPhases(); phase++) { + for (i = 0; i < system.getPhases()[phase].getNumberOfComponents(); i++) { + xchem[i] = system.getPhase(phase).getComponent(i).getx(); + } + + system.init(1); + system.getChemicalReactionOperations().solveChemEq(phase, 1); + + for (i = 0; i < system.getPhases()[phase].getNumberOfComponents(); i++) { + chemdev += + Math.abs(xchem[i] - system.getPhase(phase).getComponent(i).getx()) / xchem[i]; + } } + diffChem = Math.abs(oldChemDiff - chemdev); + } + // logger.info("chemdev: " + chemdev + " iter: " + totiter); + totiter++; + } while ((diffChem > 1e-6 && chemdev > 1e-6 && totiter < 300) + || (system.isChemicalSystem() && totiter < 2)); + if (system.isChemicalSystem()) { + sucsSubs(); + } + if (system.doMultiPhaseCheck()) { + TPmultiflash operation = new TPmultiflash(system, true); + operation.run(); + } else { + // Checks if gas or oil is the most stable phase + if (system.getPhase(0).getPhaseType() == 1) { + gasgib = system.getPhase(0).getGibbsEnergy(); + system.setPhaseType(0, 0); + system.init(1, 0); + liqgib = system.getPhase(0).getGibbsEnergy(); + } else { + liqgib = system.getPhase(0).getGibbsEnergy(); + system.setPhaseType(0, 1); + system.init(1, 0); + gasgib = system.getPhase(0).getGibbsEnergy(); + } - system.init(1); + if (gasgib * (1.0 - Math.signum(gasgib) * 1e-8) < liqgib) { + system.setPhaseType(0, 1); + } - if (system.doMultiPhaseCheck()) { - TPmultiflash operation = new TPmultiflash(system, true); - operation.run(); - } - if (solidCheck) { - this.solidPhaseFlash(); - } - if (system.isMultiphaseWaxCheck()) { - TPmultiflashWAX operation = new TPmultiflashWAX(system, true); - operation.run(); - } + system.init(1); + } - for (int i = 0; i < system.getNumberOfPhases(); i++) { - if (system.getBeta(i) < betaTolerance * 1.01) { - system.removePhase(i); - } - } - // system.initPhysicalProperties("density"); - system.orderByDensity(); - system.init(1); + if (solidCheck) { + this.solidPhaseFlash(); + } + if (system.isMultiphaseWaxCheck()) { + TPmultiflashWAX operation = new TPmultiflashWAX(system, true); + operation.run(); } - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - return null; + for (int i = 0; i < system.getNumberOfPhases(); i++) { + if (system.getBeta(i) < betaTolerance * 1.01) { + system.removePhase(i); + } } + // system.initPhysicalProperties("density"); + system.orderByDensity(); + system.init(1); + } + + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + return null; + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/TVflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/TVflash.java index 2499384fcb..556d816f73 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/TVflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/TVflash.java @@ -90,9 +90,7 @@ public double solveQ() { } system.setPressure(nyPres); tpFlash.run(); - // System.out.println(" dQdv " + calcdQdV() + " new pressure " + nyPres + " - // error " + Math.abs((nyPres-oldPres)/(nyPres)) + " - // numberofphases"+system.getNumberOfPhases()); + // System.out.println(" dQdv " + calcdQdV() + " new pressure " + nyPres + " error " + Math.abs((nyPres-oldPres)/(nyPres)) + " numberofphases "+system.getNumberOfPhases()); } while (Math.abs((nyPres - oldPres) / (nyPres)) > 1e-9 && iterations < 1000 || iterations < 3); return nyPres; diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/constantDutyFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/constantDutyFlash.java index f3a72e893e..07672189be 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/constantDutyFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/constantDutyFlash.java @@ -13,145 +13,138 @@ * @version $Id: $Id */ public abstract class constantDutyFlash implements constantDutyFlashInterface { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(constantDutyFlash.class); - - SystemInterface system; - protected boolean superCritical = false; - int i, j = 0, nummer = 0, iterations = 0, maxNumberOfIterations = 10000; - double gibbsEnergy = 0, gibbsEnergyOld = 0; - double Kold, deviation = 0, g0 = 0, g1 = 0; - double lnOldOldK[], lnK[]; - double lnOldK[]; - double oldDeltalnK[], deltalnK[]; - double tm[] = {1, 1}; - double beta = 1e-5; - int lowestGibbsEnergyPhase = 0; // lowestGibbsEnergyPhase - - /** - *- * Constructor for constantDutyFlash. - *
- */ - public constantDutyFlash() {} - - /** - *- * Constructor for constantDutyFlash. - *
- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public constantDutyFlash(SystemInterface system) { - this.system = system; - lnOldOldK = new double[system.getPhases()[0].getNumberOfComponents()]; - lnOldK = new double[system.getPhases()[0].getNumberOfComponents()]; - lnK = new double[system.getPhases()[0].getNumberOfComponents()]; - oldDeltalnK = new double[system.getPhases()[0].getNumberOfComponents()]; - deltalnK = new double[system.getPhases()[0].getNumberOfComponents()]; - } - - /** {@inheritDoc} */ - @Override - public void setBeta(double beta) { - this.beta = beta; - } - - /** {@inheritDoc} */ - @Override - public void run() { - system.init(0); - system.init(2); - - // int iterations = 0, maxNumberOfIterations = 10000; - // double yold = 0, ytotal = 1; - double deriv = 0, funk = 0, dkidt = 0, dyidt = 0, dxidt = 0, Told = 0; - - do { - // system.setBeta(beta+0.65); - system.init(2); - - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - system.getPhases()[0].getComponents()[i] - .setK(system.getPhases()[0].getComponents()[i].getFugacityCoefficient() - / system.getPhases()[1].getComponents()[i] - .getFugacityCoefficient()); - system.getPhases()[1].getComponents()[i] - .setK(system.getPhases()[0].getComponents()[i].getFugacityCoefficient() - / system.getPhases()[1].getComponents()[i] - .getFugacityCoefficient()); - } - - system.calc_x_y(); - - funk = 0e0; - deriv = 0e0; - - for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { - dkidt = (system.getPhases()[0].getComponents()[i].getdfugdt() - - system.getPhases()[1].getComponents()[i].getdfugdt()) - * system.getPhases()[0].getComponents()[i].getK(); - dxidt = -system.getPhases()[0].getComponents()[i].getx() - * system.getPhases()[0].getComponents()[i].getx() * 1.0 - / system.getPhases()[0].getComponents()[i].getz() * system.getBeta() - * dkidt; - dyidt = dkidt * system.getPhases()[0].getComponents()[i].getx() - + system.getPhases()[0].getComponents()[i].getK() * dxidt; - funk = funk + system.getPhases()[1].getComponents()[i].getx() - - system.getPhases()[0].getComponents()[i].getx(); - deriv = deriv + dyidt - dxidt; - } - - Told = system.getTemperature(); - system.setTemperature((Told - funk / deriv * 0.9)); - logger.info("Temp: " + system.getTemperature()); - } while (Math.abs((system.getTemperature() - Told) / system.getTemperature()) > 1e-7); - } - - /** {@inheritDoc} */ - @Override - public void createNetCdfFile(String name) {} - - /** {@inheritDoc} */ - @Override - public double[][] getPoints(int i) { - return null; - } - - /** {@inheritDoc} */ - @Override - public double[] get(String name) { - return null; - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - system.display(); - } - - /** {@inheritDoc} */ - @Override - public boolean isSuperCritical() { - return superCritical; - } - - /** - * Setter for property superCritical. - * - * @param superCritical New value of property superCritical. - */ - public void setSuperCritical(boolean superCritical) { - this.superCritical = superCritical; - } - - /** {@inheritDoc} */ - @Override - public String[][] getResultTable() { - return null; - } - - /** {@inheritDoc} */ - @Override - public void addData(String name, double[][] data) {} + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(constantDutyFlash.class); + + SystemInterface system; + protected boolean superCritical = false; + int i, j = 0, nummer = 0, iterations = 0, maxNumberOfIterations = 10000; + double gibbsEnergy = 0, gibbsEnergyOld = 0; + double Kold, deviation = 0, g0 = 0, g1 = 0; + double lnOldOldK[], lnK[]; + double lnOldK[]; + double oldDeltalnK[], deltalnK[]; + double tm[] = {1, 1}; + double beta = 1e-5; + int lowestGibbsEnergyPhase = 0; // lowestGibbsEnergyPhase + + /** + *+ * Constructor for constantDutyFlash. + *
+ */ + public constantDutyFlash() {} + + /** + *+ * Constructor for constantDutyFlash. + *
+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public constantDutyFlash(SystemInterface system) { + this.system = system; + lnOldOldK = new double[system.getPhases()[0].getNumberOfComponents()]; + lnOldK = new double[system.getPhases()[0].getNumberOfComponents()]; + lnK = new double[system.getPhases()[0].getNumberOfComponents()]; + oldDeltalnK = new double[system.getPhases()[0].getNumberOfComponents()]; + deltalnK = new double[system.getPhases()[0].getNumberOfComponents()]; + } + + /** {@inheritDoc} */ + @Override + public void setBeta(double beta) { + this.beta = beta; + } + + /** {@inheritDoc} */ + @Override + public void run() { + system.init(0); + system.init(2); + + // int iterations = 0, maxNumberOfIterations = 10000; + // double yold = 0, ytotal = 1; + double deriv = 0, funk = 0, dkidt = 0, dyidt = 0, dxidt = 0, Told = 0; + + do { + // system.setBeta(beta+0.65); + system.init(2); + + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + system.getPhases()[0].getComponents()[i] + .setK(system.getPhases()[0].getComponents()[i].getFugacityCoefficient() + / system.getPhases()[1].getComponents()[i].getFugacityCoefficient()); + system.getPhases()[1].getComponents()[i] + .setK(system.getPhases()[0].getComponents()[i].getFugacityCoefficient() + / system.getPhases()[1].getComponents()[i].getFugacityCoefficient()); + } + + system.calc_x_y(); + + funk = 0e0; + deriv = 0e0; + + for (int i = 0; i < system.getPhases()[0].getNumberOfComponents(); i++) { + dkidt = (system.getPhases()[0].getComponents()[i].getdfugdt() + - system.getPhases()[1].getComponents()[i].getdfugdt()) + * system.getPhases()[0].getComponents()[i].getK(); + dxidt = -system.getPhases()[0].getComponents()[i].getx() + * system.getPhases()[0].getComponents()[i].getx() * 1.0 + / system.getPhases()[0].getComponents()[i].getz() * system.getBeta() * dkidt; + dyidt = dkidt * system.getPhases()[0].getComponents()[i].getx() + + system.getPhases()[0].getComponents()[i].getK() * dxidt; + funk = funk + system.getPhases()[1].getComponents()[i].getx() + - system.getPhases()[0].getComponents()[i].getx(); + deriv = deriv + dyidt - dxidt; + } + + Told = system.getTemperature(); + system.setTemperature((Told - funk / deriv * 0.9)); + logger.info("Temp: " + system.getTemperature()); + } while (Math.abs((system.getTemperature() - Told) / system.getTemperature()) > 1e-7); + } + + /** {@inheritDoc} */ + @Override + public double[][] getPoints(int i) { + return null; + } + + /** {@inheritDoc} */ + @Override + public double[] get(String name) { + return null; + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + system.display(); + } + + /** {@inheritDoc} */ + @Override + public boolean isSuperCritical() { + return superCritical; + } + + /** + * Setter for property superCritical. + * + * @param superCritical New value of property superCritical. + */ + public void setSuperCritical(boolean superCritical) { + this.superCritical = superCritical; + } + + /** {@inheritDoc} */ + @Override + public String[][] getResultTable() { + return null; + } + + /** {@inheritDoc} */ + @Override + public void addData(String name, double[][] data) {} } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp1.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp1.java index da1d4a17e1..8569a03781 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp1.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp1.java @@ -236,15 +236,6 @@ public String[][] getResultTable() { return null; } - /** - *- * createNetCdfFile. - *
- * - * @param name a {@link java.lang.String} object - */ - public void createNetCdfFile(String name) {} - /** ** getThermoSystem. diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/HPTphaseEnvelope.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/HPTphaseEnvelope.java index a59ad23d66..bc8cf04432 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/HPTphaseEnvelope.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/HPTphaseEnvelope.java @@ -11,7 +11,6 @@ import javax.swing.JProgressBar; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import neqsim.dataPresentation.visAD.visAd3D.visAd3DPlot; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.BaseOperation; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -25,108 +24,100 @@ * @version $Id: $Id */ public class HPTphaseEnvelope extends BaseOperation { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - double[][] points = new double[10][10]; - SystemInterface system; - ThermodynamicOperations testOps; - JProgressBar monitor; - JFrame mainFrame; - JPanel mainPanel; - double startPressure = 1, endPressure = 0, startTemperature = 160, endTemperature = 0; - static Logger logger = LogManager.getLogger(HPTphaseEnvelope.class); + double[][] points = new double[10][10]; + SystemInterface system; + ThermodynamicOperations testOps; + JProgressBar monitor; + JFrame mainFrame; + JPanel mainPanel; + double startPressure = 1, endPressure = 0, startTemperature = 160, endTemperature = 0; + static Logger logger = LogManager.getLogger(HPTphaseEnvelope.class); - /** - *
- * Constructor for HPTphaseEnvelope. - *
- */ - public HPTphaseEnvelope() {} + /** + *+ * Constructor for HPTphaseEnvelope. + *
+ */ + public HPTphaseEnvelope() {} - /** - *- * Constructor for HPTphaseEnvelope. - *
- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public HPTphaseEnvelope(SystemInterface system) { - testOps = new ThermodynamicOperations(system); - this.system = system; - mainFrame = new JFrame("Progress Bar"); - mainPanel = new JPanel(); - mainPanel.setSize(200, 100); - mainFrame.getContentPane().setLayout(new FlowLayout()); - mainPanel.setLayout(new FlowLayout()); - mainFrame.setSize(200, 100); - monitor = new JProgressBar(0, 1000); - monitor.setSize(200, 100); - monitor.setStringPainted(true); - mainPanel.add(monitor); - mainFrame.getContentPane().add(mainPanel); - mainFrame.setVisible(true); - } + /** + *+ * Constructor for HPTphaseEnvelope. + *
+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public HPTphaseEnvelope(SystemInterface system) { + testOps = new ThermodynamicOperations(system); + this.system = system; + mainFrame = new JFrame("Progress Bar"); + mainPanel = new JPanel(); + mainPanel.setSize(200, 100); + mainFrame.getContentPane().setLayout(new FlowLayout()); + mainPanel.setLayout(new FlowLayout()); + mainFrame.setSize(200, 100); + monitor = new JProgressBar(0, 1000); + monitor.setSize(200, 100); + monitor.setStringPainted(true); + mainPanel.add(monitor); + mainFrame.getContentPane().add(mainPanel); + mainFrame.setVisible(true); + } - /** {@inheritDoc} */ - @Override - public void run() { - int np = 0; + /** {@inheritDoc} */ + @Override + public void run() { + int np = 0; - for (int i = 0; i < 10; i++) { - system.setPressure(i * 0.5 + startPressure); - for (int j = 0; j < 10; j++) { - np++; - if (np % 2 == 0) { - monitor.setValue(np); - monitor.setString("Calculated points: " + np); - } - - system.setTemperature(startTemperature + j); - testOps.TPflash(); - system.init(3); - points[i][j] = system.getEnthalpy(); - } + for (int i = 0; i < 10; i++) { + system.setPressure(i * 0.5 + startPressure); + for (int j = 0; j < 10; j++) { + np++; + if (np % 2 == 0) { + monitor.setValue(np); + monitor.setString("Calculated points: " + np); } - } - /** {@inheritDoc} */ - @Override - public void displayResult() { - try { - mainFrame.setVisible(false); - visAd3DPlot plot = - new visAd3DPlot("pressure[bar]", "temperature[K]", "enthalpy[J/mol]"); - plot.setXYvals(150, 160, 10, 10, 20, 10); - plot.setZvals(points); - plot.init(); - } catch (Exception e) { - logger.error("plotting failed"); - } + system.setTemperature(startTemperature + j); + testOps.TPflash(); + system.init(3); + points[i][j] = system.getEnthalpy(); + } } + } - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} + /** {@inheritDoc} */ + @Override + public void displayResult() { + /* + * try { mainFrame.setVisible(false); visAd3DPlot plot = new visAd3DPlot("pressure[bar]", + * "temperature[K]", "enthalpy[J/mol]"); plot.setXYvals(150, 160, 10, 10, 20, 10); + * plot.setZvals(points); plot.init(); } catch (Exception e) { logger.error("plotting failed"); + * } + */ + } - /** {@inheritDoc} */ - @Override - public double[][] getPoints(int i) { - return points; - } + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} - /** {@inheritDoc} */ - @Override - public void createNetCdfFile(String name) {} + /** {@inheritDoc} */ + @Override + public double[][] getPoints(int i) { + return points; + } - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - return null; - } + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + return null; + } - /** {@inheritDoc} */ - @Override - public String[][] getResultTable() { - return null; - } + /** {@inheritDoc} */ + @Override + public String[][] getResultTable() { + return null; + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope.java index 0d3a5d9061..d6a116ea16 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope.java @@ -42,8 +42,6 @@ public class pTphaseEnvelope extends BaseOperation { double[] cricondenBarX = new double[100]; double[] cricondenBarY = new double[100]; double phaseFraction = 1e-10; - neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D file1; - neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D file2; int i, j = 0, nummer = 0, iterations = 0, maxNumberOfIterations = 10000; double gibbsEnergy = 0, gibbsEnergyOld = 0; double Kold, deviation = 0, g0 = 0, g1 = 0, lowPres = 1.0; @@ -493,7 +491,7 @@ public void run() { // double nef = 0.; // logger.error("error", e2); } - +/* try { if (outputToFile) { // update this @@ -517,6 +515,7 @@ public void run() { // double nef = 0.; logger.error("error", e3); } + */ } catch (Exception e4) { // double nef = 0.; logger.error("error", e4); @@ -723,12 +722,6 @@ public double[] get(String name) { } } - /** {@inheritDoc} */ - @Override - public void createNetCdfFile(String name) { - fileName = name; - } - /** * Getter for property bubblePointFirst. * diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope1.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope1.java index dace93335a..ce360ac5d3 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope1.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope1.java @@ -21,460 +21,442 @@ * @version $Id: $Id */ public class pTphaseEnvelope1 extends BaseOperation { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(pTphaseEnvelope1.class); - - graph2b graph2 = null; - SystemInterface system; - boolean bubblePointFirst = true; - double[] cricondenTherm = new double[3]; - double[] cricondenBar = new double[3]; - double phaseFraction = 1e-10; - neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D file1; - neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D file2; - int i, j = 0, nummer = 0, iterations = 0, maxNumberOfIterations = 10000; - double gibbsEnergy = 0, gibbsEnergyOld = 0; - double Kold, deviation = 0, g0 = 0, g1 = 0, lowPres = 1.0; - double lnOldOldK[], lnK[]; - boolean outputToFile = false; - double lnOldK[]; - double oldDeltalnK[], deltalnK[]; - double tm[] = {1, 1}; - double beta = 1e-5; - int lowestGibbsEnergyPhase = 0; // lowestGibbsEnergyPhase - JProgressBar monitor; - JFrame mainFrame; - String fileName = "c:/file"; - JPanel mainPanel; - double temp = 0, pres = 0, startPres = 0; - double[][] points = new double[2][]; - double[] pointsH; - double[][] pointsH2 = new double[4][]; - double[] pointsV; - double[][] pointsV2 = new double[4][]; - double[] pointsS; - double[][] pointsS2 = new double[4][]; - public double[][] points2 = new double[4][]; - double[][] points3 = new double[8][]; - boolean moreLines = false; - int np = 0; - // points[2] = new double[1000]; - int speceq = 0; - - /** - *- * Constructor for pTphaseEnvelope1. - *
- */ - public pTphaseEnvelope1() {} - - /** - *- * Constructor for pTphaseEnvelope1. - *
- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param name a {@link java.lang.String} object - * @param phaseFraction a double - * @param lowPres a double - * @param bubfirst a boolean - */ - public pTphaseEnvelope1(SystemInterface system, String name, double phaseFraction, - double lowPres, boolean bubfirst) { - this.bubblePointFirst = bubfirst; - if (name != null) { - outputToFile = true; - fileName = name; - } - this.system = system; - this.phaseFraction = phaseFraction; - lnOldOldK = new double[system.getPhase(0).getNumberOfComponents()]; - lnOldK = new double[system.getPhase(0).getNumberOfComponents()]; - lnK = new double[system.getPhase(0).getNumberOfComponents()]; - this.lowPres = lowPres; - oldDeltalnK = new double[system.getPhase(0).getNumberOfComponents()]; - deltalnK = new double[system.getPhase(0).getNumberOfComponents()]; - mainFrame = new JFrame("Progress Bar"); - mainPanel = new JPanel(); - mainPanel.setSize(200, 100); - mainFrame.getContentPane().setLayout(new FlowLayout()); - mainPanel.setLayout(new FlowLayout()); - mainFrame.setSize(200, 100); - monitor = new JProgressBar(0, 00); - monitor.setSize(200, 100); - monitor.setStringPainted(true); - mainPanel.add(monitor); - mainFrame.getContentPane().add(mainPanel); - mainFrame.setVisible(true); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(pTphaseEnvelope1.class); + + graph2b graph2 = null; + SystemInterface system; + boolean bubblePointFirst = true; + double[] cricondenTherm = new double[3]; + double[] cricondenBar = new double[3]; + double phaseFraction = 1e-10; + int i, j = 0, nummer = 0, iterations = 0, maxNumberOfIterations = 10000; + double gibbsEnergy = 0, gibbsEnergyOld = 0; + double Kold, deviation = 0, g0 = 0, g1 = 0, lowPres = 1.0; + double lnOldOldK[], lnK[]; + boolean outputToFile = false; + double lnOldK[]; + double oldDeltalnK[], deltalnK[]; + double tm[] = {1, 1}; + double beta = 1e-5; + int lowestGibbsEnergyPhase = 0; // lowestGibbsEnergyPhase + JProgressBar monitor; + JFrame mainFrame; + String fileName = "c:/file"; + JPanel mainPanel; + double temp = 0, pres = 0, startPres = 0; + double[][] points = new double[2][]; + double[] pointsH; + double[][] pointsH2 = new double[4][]; + double[] pointsV; + double[][] pointsV2 = new double[4][]; + double[] pointsS; + double[][] pointsS2 = new double[4][]; + public double[][] points2 = new double[4][]; + double[][] points3 = new double[8][]; + boolean moreLines = false; + int np = 0; + // points[2] = new double[1000]; + int speceq = 0; + + /** + *+ * Constructor for pTphaseEnvelope1. + *
+ */ + public pTphaseEnvelope1() {} + + /** + *+ * Constructor for pTphaseEnvelope1. + *
+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param name a {@link java.lang.String} object + * @param phaseFraction a double + * @param lowPres a double + * @param bubfirst a boolean + */ + public pTphaseEnvelope1(SystemInterface system, String name, double phaseFraction, double lowPres, + boolean bubfirst) { + this.bubblePointFirst = bubfirst; + if (name != null) { + outputToFile = true; + fileName = name; } + this.system = system; + this.phaseFraction = phaseFraction; + lnOldOldK = new double[system.getPhase(0).getNumberOfComponents()]; + lnOldK = new double[system.getPhase(0).getNumberOfComponents()]; + lnK = new double[system.getPhase(0).getNumberOfComponents()]; + this.lowPres = lowPres; + oldDeltalnK = new double[system.getPhase(0).getNumberOfComponents()]; + deltalnK = new double[system.getPhase(0).getNumberOfComponents()]; + mainFrame = new JFrame("Progress Bar"); + mainPanel = new JPanel(); + mainPanel.setSize(200, 100); + mainFrame.getContentPane().setLayout(new FlowLayout()); + mainPanel.setLayout(new FlowLayout()); + mainFrame.setSize(200, 100); + monitor = new JProgressBar(0, 00); + monitor.setSize(200, 100); + monitor.setStringPainted(true); + mainPanel.add(monitor); + mainFrame.getContentPane().add(mainPanel); + mainFrame.setVisible(true); + } + + /** {@inheritDoc} */ + @Override + public void run() { + try { + points[0] = new double[10000]; + points[1] = new double[10000]; + + pointsH = new double[10000]; + pointsV = new double[10000]; + pointsS = new double[10000]; + system.init(0); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (system.getPhase(0).getComponent(i).getIonicCharge() == 0) { + if (system.getPhase(0).getComponents()[i].getTC() < system.getPhase(0).getComponents()[i] + .getTC()) { + speceq = system.getPhase(0).getComponent(i).getComponentNumber(); + } + } + } + + pres = lowPres; + temp = system.getPhase(0).getComponent(speceq).getAntoineVaporTemperature(pres); + // temp = system.getTemperature(); + system.setPressure(pres); - /** {@inheritDoc} */ - @Override - public void run() { + system.setBeta(1e-10); + + ThermodynamicOperations testOps = new ThermodynamicOperations(system); + + system.init(0); + for (int i = 0; i < 1000; i++) { + temp += i * 4; + system.setTemperature(temp); try { - points[0] = new double[10000]; - points[1] = new double[10000]; - - pointsH = new double[10000]; - pointsV = new double[10000]; - pointsS = new double[10000]; - system.init(0); - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - if (system.getPhase(0).getComponent(i).getIonicCharge() == 0) { - if (system.getPhase(0).getComponents()[i] - .getTC() < system.getPhase(0).getComponents()[i].getTC()) { - speceq = system.getPhase(0).getComponent(i).getComponentNumber(); - } - } - } - - pres = lowPres; - temp = system.getPhase(0).getComponent(speceq).getAntoineVaporTemperature(pres); - // temp = system.getTemperature(); - system.setPressure(pres); - - system.setBeta(1e-10); - - ThermodynamicOperations testOps = new ThermodynamicOperations(system); - - system.init(0); - for (int i = 0; i < 1000; i++) { - temp += i * 4; - system.setTemperature(temp); - try { - if (bubblePointFirst) { - testOps.bubblePointTemperatureFlash(); - } else { - testOps.dewPointTemperatureFlash(); - } - } catch (Exception e) { - e.toString(); - } - double tempNy = system.getTemperature(); - - if (!Double.isNaN(tempNy)) { - temp = tempNy; - break; - } - } - - system.setPressure(pres); - system.setTemperature(temp); - logger.info("temp: " + system.getTemperature()); - - system.setBeta(phaseFraction); - - sysNewtonRhapsonPhaseEnvelope nonLinSolver = new sysNewtonRhapsonPhaseEnvelope(system, - 2, system.getPhase(0).getNumberOfComponents()); - nonLinSolver.solve(1); - - startPres = system.getPressure(); - - for (np = 1; np < 9500; np++) { - if (np % 5 == 0) { - monitor.setValue(np); - monitor.setString("Calculated points: " + np); - } - - nonLinSolver.calcInc(np); - nonLinSolver.solve(np); - - if (system.getTemperature() > cricondenTherm[0]) { - cricondenTherm[1] = system.getPressure(); - cricondenTherm[0] = system.getTemperature(); - } - if (system.getPressure() > cricondenBar[1]) { - cricondenBar[0] = system.getTemperature(); - cricondenBar[1] = system.getPressure(); - } - - if (Double.isNaN(system.getTemperature()) || Double.isNaN(system.getTemperature()) - || system.getPressure() < startPres) { - points[0][np - 1] = points[0][np - 3]; - points[1][np - 1] = points[1][np - 3]; - pointsH[np - 1] = pointsH[np - 3]; - pointsV[np - 1] = pointsV[np - 3]; - pointsS[np - 1] = pointsS[np - 3]; - - // logger.info("avbryter" + np); - break; - } - // logger.info("Ideal pres: " + getPressure()); - // logger.info("temp: " + system.getTemperature()); - points[0][np - 1] = system.getTemperature(); - points[1][np - 1] = system.getPressure(); - pointsH[np - 1] = system.getPhase(1).getEnthalpy() - / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - pointsV[np - 1] = system.getPhase(1).getDensity(); - pointsS[np - 1] = system.getPhase(1).getEntropy() - / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - } - - int ncr = nonLinSolver.getNpCrit(); - int ncr2 = np - ncr; - - logger.info("ncr: " + ncr + " ncr2 . " + ncr2); - points2[0] = new double[ncr + 1]; - points2[1] = new double[ncr + 1]; - pointsH2[0] = new double[ncr + 1]; - pointsH2[1] = new double[ncr + 1]; - pointsS2[0] = new double[ncr + 1]; - pointsS2[1] = new double[ncr + 1]; - pointsV2[0] = new double[ncr + 1]; - pointsV2[1] = new double[ncr + 1]; - if (ncr2 > 2) { - points2[2] = new double[ncr2 - 2]; - points2[3] = new double[ncr2 - 2]; - pointsH2[2] = new double[ncr2 - 2]; - pointsH2[3] = new double[ncr2 - 2]; - pointsV2[2] = new double[ncr2 - 2]; - pointsV2[3] = new double[ncr2 - 2]; - pointsS2[2] = new double[ncr2 - 2]; - pointsS2[3] = new double[ncr2 - 2]; - } else { - points2[2] = new double[0]; - points2[3] = new double[0]; - pointsH2[2] = new double[0]; - pointsH2[3] = new double[0]; - pointsV2[2] = new double[0]; - pointsV2[3] = new double[0]; - pointsS2[2] = new double[0]; - pointsS2[3] = new double[0]; - } - - for (int i = 0; i < ncr; i++) { - points2[0][i] = points[0][i]; - points2[1][i] = points[1][i]; - - pointsH2[1][i] = points[1][i]; - pointsH2[0][i] = pointsH[i]; - - pointsS2[1][i] = points[1][i]; - pointsS2[0][i] = pointsS[i]; - - pointsV2[1][i] = points[1][i]; - pointsV2[0][i] = pointsV[i]; - } - - system.setTemperature(system.getTC() + 0.001); - system.setPressure(system.getPC() + 0.001); - system.init(3); - - points2[0][ncr] = system.getTC(); - points2[1][ncr] = system.getPC(); - - pointsH2[1][ncr] = system.getPC(); - pointsH2[0][ncr] = - system.getPhase(1).getEnthalpy() / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - - pointsS2[1][ncr] = system.getPC(); - pointsS2[0][ncr] = - system.getPhase(1).getEntropy() / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - - pointsV2[1][ncr] = system.getPC(); - pointsV2[0][ncr] = system.getPhase(1).getDensity(); - - if (ncr2 > 2) { - points2[2][0] = system.getTC(); - points2[3][0] = system.getPC(); - pointsH2[3][0] = system.getPC(); - pointsH2[2][0] = system.getPhase(1).getEnthalpy() - / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - pointsS2[3][0] = system.getPC(); - pointsS2[2][0] = system.getPhase(1).getEntropy() - / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - pointsV2[3][0] = system.getPC(); - pointsV2[2][0] = system.getPhase(1).getDensity(); - - for (int i = 1; i < (ncr2 - 2); i++) { - points2[2][i] = points[0][i + ncr - 1]; - points2[3][i] = points[1][i + ncr - 1]; - - pointsH2[3][i] = points[1][i + ncr - 1]; - pointsH2[2][i] = pointsH[i + ncr - 1]; - - pointsS2[3][i] = points[1][i + ncr - 1]; - pointsS2[2][i] = pointsS[i + ncr - 1]; - - pointsV2[3][i] = points[1][i + ncr - 1]; - pointsV2[2][i] = pointsV[i + ncr - 1]; - } - } - // monitor.close(); - mainFrame.setVisible(false); - - if (outputToFile) { - String name1 = new String(); - name1 = fileName + "Dew.nc"; - file1 = new neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); - file1.setOutputFileName(name1); - file1.setXvalues(points2[2], "temp", "sec"); - file1.setYvalues(points2[3], "pres", "meter"); - file1.createFile(); - - String name2 = new String(); - name2 = fileName + "Bub.nc"; - file2 = new neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); - file2.setOutputFileName(name2); - file2.setXvalues(points2[0], "temp", "sec"); - file2.setYvalues(points2[1], "pres", "meter"); - file2.createFile(); - } + if (bubblePointFirst) { + testOps.bubblePointTemperatureFlash(); + } else { + testOps.dewPointTemperatureFlash(); + } } catch (Exception e) { - logger.error("error", e); + e.toString(); } - } + double tempNy = system.getTemperature(); - /** {@inheritDoc} */ - @Override - public void displayResult() { - DecimalFormat nf = new DecimalFormat(); - nf.setMaximumFractionDigits(1); - nf.applyPattern("####.#"); - - double TC = system.getTC(); - double PC = system.getPC(); - logger.info("tc : " + TC + " PC : " + PC); - String[] navn = {"bubble point", "dew point", "bubble point", "dew point"}; - String title = "PT-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - String title3 = "PH-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - String title4 = "Density-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - String title5 = "PS-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - - // logger.info("start flash"); - // logger.info("Tferdig.."); - - graph2b graph3 = new graph2b(pointsH2, navn, title3, "Enthalpy [kJ/kg]", "Pressure [bara]"); - graph3.setVisible(true); - graph3.saveFigure((neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig4.png")); - - graph2b graph4 = new graph2b(pointsV2, navn, title4, "Density [kg/m^3]", "Pressure [bara]"); - graph4.setVisible(true); - graph4.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig2.png"); - - graph2b graph5 = - new graph2b(pointsS2, navn, title5, "Entropy [kJ/kg*K]", "Pressure [bara]"); - graph5.setVisible(true); - graph5.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig3.png"); - - graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); - graph2.setVisible(true); - graph2.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig1.png"); - - /* - * JDialog dialog = new JDialog(); Container dialogContentPane = dialog.getContentPane(); - * dialogContentPane.setLayout(new FlowLayout()); JFreeChartPanel chartPanel = - * graph4.getChartPanel(); dialogContentPane.add(chartPanel); dialog.show(); - */ - } + if (!Double.isNaN(tempNy)) { + temp = tempNy; + break; + } + } - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} - - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - DecimalFormat nf = new DecimalFormat(); - nf.setMaximumFractionDigits(1); - nf.applyPattern("####.#"); - - double TC = system.getTC(); - double PC = system.getPC(); - logger.info("tc : " + TC + " PC : " + PC); - String[] navn = {"bubble point", "dew point", "bubble point", "dew point"}; - String title = "PT-graph. TC=" + String.valueOf(nf.format(TC)) + "K, PC=" - + String.valueOf(nf.format(PC) + " bara"); - graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); - return graph2.getChart(); - } + system.setPressure(pres); + system.setTemperature(temp); + logger.info("temp: " + system.getTemperature()); - /** {@inheritDoc} */ - @Override - public double[][] getPoints(int i) { - return points2; - } + system.setBeta(phaseFraction); - /** {@inheritDoc} */ - @Override - public double[] get(String name) { - if (name.equals("bubT")) { - return points2[0]; - } - if (name.equals("bubP")) { - return points2[1]; - } - if (name.equals("dewT")) { - return points2[2]; - } - if (name.equals("dewP")) { - return points2[3]; - } - if (name.equals("dewH")) { - return pointsH2[2]; - } - if (name.equals("dewDens")) { - return pointsV2[2]; - } - if (name.equals("dewS")) { - return pointsS2[2]; - } - if (name.equals("bubH")) { - return pointsH2[0]; + sysNewtonRhapsonPhaseEnvelope nonLinSolver = + new sysNewtonRhapsonPhaseEnvelope(system, 2, system.getPhase(0).getNumberOfComponents()); + nonLinSolver.solve(1); + + startPres = system.getPressure(); + + for (np = 1; np < 9500; np++) { + if (np % 5 == 0) { + monitor.setValue(np); + monitor.setString("Calculated points: " + np); } - if (name.equals("bubDens")) { - return pointsV2[0]; + + nonLinSolver.calcInc(np); + nonLinSolver.solve(np); + + if (system.getTemperature() > cricondenTherm[0]) { + cricondenTherm[1] = system.getPressure(); + cricondenTherm[0] = system.getTemperature(); } - if (name.equals("bubS")) { - return pointsS2[0]; + if (system.getPressure() > cricondenBar[1]) { + cricondenBar[0] = system.getTemperature(); + cricondenBar[1] = system.getPressure(); } - if (name.equals("cricondentherm")) { - return cricondenTherm; + + if (Double.isNaN(system.getTemperature()) || Double.isNaN(system.getTemperature()) + || system.getPressure() < startPres) { + points[0][np - 1] = points[0][np - 3]; + points[1][np - 1] = points[1][np - 3]; + pointsH[np - 1] = pointsH[np - 3]; + pointsV[np - 1] = pointsV[np - 3]; + pointsS[np - 1] = pointsS[np - 3]; + + // logger.info("avbryter" + np); + break; } - if (name.equals("cricondenbar")) { - return cricondenBar; - } else { - return null; + // logger.info("Ideal pres: " + getPressure()); + // logger.info("temp: " + system.getTemperature()); + points[0][np - 1] = system.getTemperature(); + points[1][np - 1] = system.getPressure(); + pointsH[np - 1] = + system.getPhase(1).getEnthalpy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3; + pointsV[np - 1] = system.getPhase(1).getDensity(); + pointsS[np - 1] = + system.getPhase(1).getEntropy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3; + } + + int ncr = nonLinSolver.getNpCrit(); + int ncr2 = np - ncr; + + logger.info("ncr: " + ncr + " ncr2 . " + ncr2); + points2[0] = new double[ncr + 1]; + points2[1] = new double[ncr + 1]; + pointsH2[0] = new double[ncr + 1]; + pointsH2[1] = new double[ncr + 1]; + pointsS2[0] = new double[ncr + 1]; + pointsS2[1] = new double[ncr + 1]; + pointsV2[0] = new double[ncr + 1]; + pointsV2[1] = new double[ncr + 1]; + if (ncr2 > 2) { + points2[2] = new double[ncr2 - 2]; + points2[3] = new double[ncr2 - 2]; + pointsH2[2] = new double[ncr2 - 2]; + pointsH2[3] = new double[ncr2 - 2]; + pointsV2[2] = new double[ncr2 - 2]; + pointsV2[3] = new double[ncr2 - 2]; + pointsS2[2] = new double[ncr2 - 2]; + pointsS2[3] = new double[ncr2 - 2]; + } else { + points2[2] = new double[0]; + points2[3] = new double[0]; + pointsH2[2] = new double[0]; + pointsH2[3] = new double[0]; + pointsV2[2] = new double[0]; + pointsV2[3] = new double[0]; + pointsS2[2] = new double[0]; + pointsS2[3] = new double[0]; + } + + for (int i = 0; i < ncr; i++) { + points2[0][i] = points[0][i]; + points2[1][i] = points[1][i]; + + pointsH2[1][i] = points[1][i]; + pointsH2[0][i] = pointsH[i]; + + pointsS2[1][i] = points[1][i]; + pointsS2[0][i] = pointsS[i]; + + pointsV2[1][i] = points[1][i]; + pointsV2[0][i] = pointsV[i]; + } + + system.setTemperature(system.getTC() + 0.001); + system.setPressure(system.getPC() + 0.001); + system.init(3); + + points2[0][ncr] = system.getTC(); + points2[1][ncr] = system.getPC(); + + pointsH2[1][ncr] = system.getPC(); + pointsH2[0][ncr] = system.getPhase(1).getEnthalpy() + / system.getPhase(1).getNumberOfMolesInPhase() / system.getPhase(1).getMolarMass() / 1e3; + + pointsS2[1][ncr] = system.getPC(); + pointsS2[0][ncr] = system.getPhase(1).getEntropy() + / system.getPhase(1).getNumberOfMolesInPhase() / system.getPhase(1).getMolarMass() / 1e3; + + pointsV2[1][ncr] = system.getPC(); + pointsV2[0][ncr] = system.getPhase(1).getDensity(); + + if (ncr2 > 2) { + points2[2][0] = system.getTC(); + points2[3][0] = system.getPC(); + pointsH2[3][0] = system.getPC(); + pointsH2[2][0] = + system.getPhase(1).getEnthalpy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3; + pointsS2[3][0] = system.getPC(); + pointsS2[2][0] = + system.getPhase(1).getEntropy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3; + pointsV2[3][0] = system.getPC(); + pointsV2[2][0] = system.getPhase(1).getDensity(); + + for (int i = 1; i < (ncr2 - 2); i++) { + points2[2][i] = points[0][i + ncr - 1]; + points2[3][i] = points[1][i + ncr - 1]; + + pointsH2[3][i] = points[1][i + ncr - 1]; + pointsH2[2][i] = pointsH[i + ncr - 1]; + + pointsS2[3][i] = points[1][i + ncr - 1]; + pointsS2[2][i] = pointsS[i + ncr - 1]; + + pointsV2[3][i] = points[1][i + ncr - 1]; + pointsV2[2][i] = pointsV[i + ncr - 1]; } + } + // monitor.close(); + mainFrame.setVisible(false); + /* + * if (outputToFile) { String name1 = new String(); name1 = fileName + "Dew.nc"; file1 = new + * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); + * file1.setOutputFileName(name1); file1.setXvalues(points2[2], "temp", "sec"); + * file1.setYvalues(points2[3], "pres", "meter"); file1.createFile(); + * + * String name2 = new String(); name2 = fileName + "Bub.nc"; file2 = new + * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); + * file2.setOutputFileName(name2); file2.setXvalues(points2[0], "temp", "sec"); + * file2.setYvalues(points2[1], "pres", "meter"); file2.createFile(); } + */ + } catch (Exception e) { + logger.error("error", e); } - - /** {@inheritDoc} */ - @Override - public void createNetCdfFile(String name) { - fileName = name; - } - - /** - * Getter for property bubblePointFirst. - * - * @return Value of property bubblePointFirst. + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + DecimalFormat nf = new DecimalFormat(); + nf.setMaximumFractionDigits(1); + nf.applyPattern("####.#"); + + double TC = system.getTC(); + double PC = system.getPC(); + logger.info("tc : " + TC + " PC : " + PC); + String[] navn = {"bubble point", "dew point", "bubble point", "dew point"}; + String title = + "PT-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + String.valueOf(nf.format(PC)); + String title3 = + "PH-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + String.valueOf(nf.format(PC)); + String title4 = "Density-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + + String.valueOf(nf.format(PC)); + String title5 = + "PS-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + String.valueOf(nf.format(PC)); + + // logger.info("start flash"); + // logger.info("Tferdig.."); + + graph2b graph3 = new graph2b(pointsH2, navn, title3, "Enthalpy [kJ/kg]", "Pressure [bara]"); + graph3.setVisible(true); + graph3.saveFigure((neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig4.png")); + + graph2b graph4 = new graph2b(pointsV2, navn, title4, "Density [kg/m^3]", "Pressure [bara]"); + graph4.setVisible(true); + graph4.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig2.png"); + + graph2b graph5 = new graph2b(pointsS2, navn, title5, "Entropy [kJ/kg*K]", "Pressure [bara]"); + graph5.setVisible(true); + graph5.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig3.png"); + + graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); + graph2.setVisible(true); + graph2.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig1.png"); + + /* + * JDialog dialog = new JDialog(); Container dialogContentPane = dialog.getContentPane(); + * dialogContentPane.setLayout(new FlowLayout()); JFreeChartPanel chartPanel = + * graph4.getChartPanel(); dialogContentPane.add(chartPanel); dialog.show(); */ - public boolean isBubblePointFirst() { - return bubblePointFirst; + } + + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} + + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + DecimalFormat nf = new DecimalFormat(); + nf.setMaximumFractionDigits(1); + nf.applyPattern("####.#"); + + double TC = system.getTC(); + double PC = system.getPC(); + logger.info("tc : " + TC + " PC : " + PC); + String[] navn = {"bubble point", "dew point", "bubble point", "dew point"}; + String title = "PT-graph. TC=" + String.valueOf(nf.format(TC)) + "K, PC=" + + String.valueOf(nf.format(PC) + " bara"); + graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); + return graph2.getChart(); + } + + /** {@inheritDoc} */ + @Override + public double[][] getPoints(int i) { + return points2; + } + + /** {@inheritDoc} */ + @Override + public double[] get(String name) { + if (name.equals("bubT")) { + return points2[0]; } - - /** - * Setter for property bubblePointFirst. - * - * @param bubblePointFirst New value of property bubblePointFirst. - */ - public void setBubblePointFirst(boolean bubblePointFirst) { - this.bubblePointFirst = bubblePointFirst; + if (name.equals("bubP")) { + return points2[1]; } - - /** {@inheritDoc} */ - @Override - public String[][] getResultTable() { - return null; + if (name.equals("dewT")) { + return points2[2]; + } + if (name.equals("dewP")) { + return points2[3]; + } + if (name.equals("dewH")) { + return pointsH2[2]; + } + if (name.equals("dewDens")) { + return pointsV2[2]; + } + if (name.equals("dewS")) { + return pointsS2[2]; + } + if (name.equals("bubH")) { + return pointsH2[0]; + } + if (name.equals("bubDens")) { + return pointsV2[0]; + } + if (name.equals("bubS")) { + return pointsS2[0]; + } + if (name.equals("cricondentherm")) { + return cricondenTherm; + } + if (name.equals("cricondenbar")) { + return cricondenBar; + } else { + return null; } + } + + /** + * Getter for property bubblePointFirst. + * + * @return Value of property bubblePointFirst. + */ + public boolean isBubblePointFirst() { + return bubblePointFirst; + } + + /** + * Setter for property bubblePointFirst. + * + * @param bubblePointFirst New value of property bubblePointFirst. + */ + public void setBubblePointFirst(boolean bubblePointFirst) { + this.bubblePointFirst = bubblePointFirst; + } + + /** {@inheritDoc} */ + @Override + public String[][] getResultTable() { + return null; + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeMay.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeMay.java index da70ca2adf..02c54b233c 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeMay.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeMay.java @@ -20,777 +20,756 @@ * @version $Id: $Id */ public class pTphaseEnvelopeMay extends BaseOperation { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(pTphaseEnvelopeMay.class); - - double maxPressure = 1000.0; - double minPressure = 1.0; - double[][] copiedPoints = null; - graph2b graph2 = null; - SystemInterface system; - boolean bubblePointFirst = true; - boolean hascopiedPoints = false; - double[] cricondenTherm = new double[3]; - double[] cricondenBar = new double[3]; - double phaseFraction = 1e-10; - neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D file1; - neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D file2; - int i, j = 0, nummer = 0, iterations = 0, maxNumberOfIterations = 10000; - double gibbsEnergy = 0, gibbsEnergyOld = 0; - double Kold, deviation = 0, g0 = 0, g1 = 0, lowPres = 1.0; - double lnOldOldK[], lnK[]; - boolean outputToFile = false; - double lnOldK[]; - double lnKwil[]; - double oldDeltalnK[], deltalnK[]; - double tm[] = {1, 1}; - double beta = 1e-5; - int lowestGibbsEnergyPhase = 0; // lowestGibbsEnergyPhase - JProgressBar monitor; - JFrame mainFrame; - String fileName = "c:/file"; - JPanel mainPanel; - double temp = 0, pres = 0, startPres = 0; - double[][] points = new double[2][]; - double[] pointsH; - double[][] pointsH2 = new double[4][]; - double[] pointsV; - double[][] pointsV2 = new double[4][]; - double[] pointsS; - double[][] pointsS2 = new double[4][]; - public double[][] points2 = new double[4][]; - double[][] points3 = new double[8][]; - boolean moreLines = false; - boolean restart = true; - int np = 0; - // points[2] = new double[1000]; - int speceq = 0; - String[] navn = {"bubble point", "dew point", "bubble point", "dew point", "dew points"}; - int npfirst; - int ncrfirst; - double Tcfirst; - double Pcfirst; - double Tmin = 0.0; - - /** - *- * Constructor for pTphaseEnvelopeMay. - *
- */ - public pTphaseEnvelopeMay() {} - - /** - *- * Constructor for pTphaseEnvelopeMay. - *
- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param name a {@link java.lang.String} object - * @param phaseFraction a double - * @param lowPres a double - * @param bubfirst a boolean - */ - public pTphaseEnvelopeMay(SystemInterface system, String name, double phaseFraction, - double lowPres, boolean bubfirst) { - this.bubblePointFirst = bubfirst; - if (name != null) { - outputToFile = true; - fileName = name; - } - this.system = system; - this.phaseFraction = phaseFraction; - lnOldOldK = new double[system.getPhase(0).getNumberOfComponents()]; - lnOldK = new double[system.getPhase(0).getNumberOfComponents()]; - lnK = new double[system.getPhase(0).getNumberOfComponents()]; - this.lowPres = lowPres; - oldDeltalnK = new double[system.getPhase(0).getNumberOfComponents()]; - deltalnK = new double[system.getPhase(0).getNumberOfComponents()]; + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(pTphaseEnvelopeMay.class); + + double maxPressure = 1000.0; + double minPressure = 1.0; + double[][] copiedPoints = null; + graph2b graph2 = null; + SystemInterface system; + boolean bubblePointFirst = true; + boolean hascopiedPoints = false; + double[] cricondenTherm = new double[3]; + double[] cricondenBar = new double[3]; + double phaseFraction = 1e-10; + int i, j = 0, nummer = 0, iterations = 0, maxNumberOfIterations = 10000; + double gibbsEnergy = 0, gibbsEnergyOld = 0; + double Kold, deviation = 0, g0 = 0, g1 = 0, lowPres = 1.0; + double lnOldOldK[], lnK[]; + boolean outputToFile = false; + double lnOldK[]; + double lnKwil[]; + double oldDeltalnK[], deltalnK[]; + double tm[] = {1, 1}; + double beta = 1e-5; + int lowestGibbsEnergyPhase = 0; // lowestGibbsEnergyPhase + JProgressBar monitor; + JFrame mainFrame; + String fileName = "c:/file"; + JPanel mainPanel; + double temp = 0, pres = 0, startPres = 0; + double[][] points = new double[2][]; + double[] pointsH; + double[][] pointsH2 = new double[4][]; + double[] pointsV; + double[][] pointsV2 = new double[4][]; + double[] pointsS; + double[][] pointsS2 = new double[4][]; + public double[][] points2 = new double[4][]; + double[][] points3 = new double[8][]; + boolean moreLines = false; + boolean restart = true; + int np = 0; + // points[2] = new double[1000]; + int speceq = 0; + String[] navn = {"bubble point", "dew point", "bubble point", "dew point", "dew points"}; + int npfirst; + int ncrfirst; + double Tcfirst; + double Pcfirst; + double Tmin = 0.0; + + /** + *+ * Constructor for pTphaseEnvelopeMay. + *
+ */ + public pTphaseEnvelopeMay() {} + + /** + *+ * Constructor for pTphaseEnvelopeMay. + *
+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param name a {@link java.lang.String} object + * @param phaseFraction a double + * @param lowPres a double + * @param bubfirst a boolean + */ + public pTphaseEnvelopeMay(SystemInterface system, String name, double phaseFraction, + double lowPres, boolean bubfirst) { + this.bubblePointFirst = bubfirst; + if (name != null) { + outputToFile = true; + fileName = name; } - - /** {@inheritDoc} */ - @Override - public void run() { - speceq = 0; // initialization + this.system = system; + this.phaseFraction = phaseFraction; + lnOldOldK = new double[system.getPhase(0).getNumberOfComponents()]; + lnOldK = new double[system.getPhase(0).getNumberOfComponents()]; + lnK = new double[system.getPhase(0).getNumberOfComponents()]; + this.lowPres = lowPres; + oldDeltalnK = new double[system.getPhase(0).getNumberOfComponents()]; + deltalnK = new double[system.getPhase(0).getNumberOfComponents()]; + } + + /** {@inheritDoc} */ + @Override + public void run() { + speceq = 0; // initialization + try { + points[0] = new double[10000]; // declarations for points + points[1] = new double[10000]; // declarations for points + + pointsH = new double[10000]; // declarations for points + pointsV = new double[10000]; // declarations for points + pointsS = new double[10000]; // declarations for points + system.init(0); // initialization + + // selects the most volatile and least volatile component based on Tc values + // afterwards it uses them to define the speceq of the first point + // based on the desired first point, dew/bubble + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (system.getPhase(0).getComponent(i).getIonicCharge() == 0) { + if (bubblePointFirst == true && system.getPhase(0).getComponents()[speceq] + .getTC() > system.getPhase(0).getComponents()[i].getTC()) { + speceq = system.getPhase(0).getComponent(i).getComponentNumber(); + } + if (bubblePointFirst == false && system.getPhase(0).getComponents()[speceq] + .getTC() < system.getPhase(0).getComponents()[i].getTC()) { + speceq = system.getPhase(0).getComponent(i).getComponentNumber(); + } + } + } + + // initialized the first step of the phase envelope + // pressure is already defined + // temperature is the Antoine vapor pressure of the selected component + // (least or most volatile. + pres = lowPres; + // temp = + // system.getPhase(0).getComponent(speceq).getAntoineVaporTemperature(pres); + temp = tempKWilson(phaseFraction, pres); + + if (Double.isNaN(temp)) { + temp = system.getPhase(0).getComponent(speceq).getTC() - 20.0; + } + system.setTemperature(temp); + system.setPressure(pres); + + ThermodynamicOperations testOps = new ThermodynamicOperations(system); + + // this part converges the first phase envelope point. + // if the phase fraction is more than 0.5 it does a dew point initialization + // else a bubble point initialization + + for (int i = 0; i < 5; i++) { try { - points[0] = new double[10000]; // declarations for points - points[1] = new double[10000]; // declarations for points - - pointsH = new double[10000]; // declarations for points - pointsV = new double[10000]; // declarations for points - pointsS = new double[10000]; // declarations for points - system.init(0); // initialization - - // selects the most volatile and least volatile component based on Tc values - // afterwards it uses them to define the speceq of the first point - // based on the desired first point, dew/bubble - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - if (system.getPhase(0).getComponent(i).getIonicCharge() == 0) { - if (bubblePointFirst == true && system.getPhase(0).getComponents()[speceq] - .getTC() > system.getPhase(0).getComponents()[i].getTC()) { - speceq = system.getPhase(0).getComponent(i).getComponentNumber(); - } - if (bubblePointFirst == false && system.getPhase(0).getComponents()[speceq] - .getTC() < system.getPhase(0).getComponents()[i].getTC()) { - speceq = system.getPhase(0).getComponent(i).getComponentNumber(); - } - } - } - - // initialized the first step of the phase envelope - // pressure is already defined - // temperature is the Antoine vapor pressure of the selected component - // (least or most volatile. - pres = lowPres; - // temp = - // system.getPhase(0).getComponent(speceq).getAntoineVaporTemperature(pres); - temp = tempKWilson(phaseFraction, pres); - - if (Double.isNaN(temp)) { - temp = system.getPhase(0).getComponent(speceq).getTC() - 20.0; - } + if (phaseFraction < 0.5) { + temp += i * 2; system.setTemperature(temp); - system.setPressure(pres); - - ThermodynamicOperations testOps = new ThermodynamicOperations(system); - - // this part converges the first phase envelope point. - // if the phase fraction is more than 0.5 it does a dew point initialization - // else a bubble point initialization - - for (int i = 0; i < 5; i++) { - try { - if (phaseFraction < 0.5) { - temp += i * 2; - system.setTemperature(temp); - testOps.bubblePointTemperatureFlash(); - } else { - temp += i * 2; - system.setTemperature(temp); - testOps.dewPointTemperatureFlash(); - } - } catch (Exception e) { - e.toString(); - } - double tempNy = system.getTemperature(); - - if (!Double.isNaN(tempNy)) { - temp = tempNy; - break; - } - } - - // this part sets the first envelope point into the system - system.setBeta(phaseFraction); - system.setPressure(pres); + testOps.bubblePointTemperatureFlash(); + } else { + temp += i * 2; system.setTemperature(temp); + testOps.dewPointTemperatureFlash(); + } + } catch (Exception e) { + e.toString(); + } + double tempNy = system.getTemperature(); - sysNewtonRhapsonPhaseEnvelope nonLinSolver = new sysNewtonRhapsonPhaseEnvelope(system, - 2, system.getPhase(0).getNumberOfComponents()); - startPres = system.getPressure(); - nonLinSolver.setu(); - for (np = 1; np < 9980; np++) { - try { - // solves the np point of the envelope - nonLinSolver.calcInc(np); - nonLinSolver.solve(np); - - // double TT = system.getPhase(0).getTemperature(); - // double PP = system.getPhase(0).getPressure(); - } catch (Exception e0) { - // the envelope crushed. - // this part keeps the old values - // restarts the envelope from the other side - // and then stops - - if (restart) { - restart = false; - // keep values - Tmin = points[0][np - 2]; - npfirst = np - 1; - ncrfirst = nonLinSolver.getNpCrit(); - if (ncrfirst == 0) { - ncrfirst = npfirst; - } - Tcfirst = system.getTC(); - Pcfirst = system.getPC(); - hascopiedPoints = true; - copiedPoints = new double[5][np - 1]; - for (int i = 0; i < np - 1; i++) { - copiedPoints[0][i] = points[0][i]; - copiedPoints[1][i] = points[1][i]; - copiedPoints[2][i] = pointsH[i]; - copiedPoints[3][i] = pointsS[i]; - copiedPoints[4][i] = pointsV[i]; - } - // new settings - phaseFraction = 1.0 - phaseFraction; - if (bubblePointFirst) { - bubblePointFirst = false; - } else { - bubblePointFirst = true; - } - run(); - break; - } else { - np = np - 1; - break; - } - } - - // check for critical point - double Kvallc = system.getPhase(0).getComponent(nonLinSolver.lc).getx() - / system.getPhase(1).getComponent(nonLinSolver.lc).getx(); - double Kvalhc = system.getPhase(0).getComponent(nonLinSolver.hc).getx() - / system.getPhase(1).getComponent(nonLinSolver.hc).getx(); - // double densV = system.getPhase(0).getDensity(); - // double densL = system.getPhase(1).getDensity(); - - // System.out.println(np + " " + system.getTemperature() + " " + - // system.getPressure() + " " + densV + " " + densL ); - - if ((nonLinSolver.etterCP == false)) { - if (Kvallc < 1.05 && Kvalhc > 0.95) { - // close to the critical point - // invert phase types and find the CP Temp and Press - - // System.out.println("critical point"); - nonLinSolver.npCrit = np; - system.invertPhaseTypes(); - nonLinSolver.etterCP = true; - // the critical point is found from interpolation plynimials based on K=1 of - // the - // most or least volatile component - nonLinSolver.calcCrit(); - } - } - if (nonLinSolver.calcCP) { - nonLinSolver.calcCP = false; - nonLinSolver.npCrit = np; - nonLinSolver.calcCrit(); - } - - // stores cricondenbar and cricondentherm - // HERE the new cricoT and crico P values will be called instead - if (system.getTemperature() > cricondenTherm[0]) { - cricondenTherm[1] = system.getPressure(); - cricondenTherm[0] = system.getTemperature(); - } else { - nonLinSolver.ettercricoT = true; - } - if (system.getPressure() > cricondenBar[1]) { - cricondenBar[0] = system.getTemperature(); - cricondenBar[1] = system.getPressure(); - } - - // Exit criteria - if ((system.getPressure() < minPressure && nonLinSolver.ettercricoT)) { - break; - } - if (system.getPressure() > maxPressure) { - break; - } - if (system.getTemperature() > Tmin && !restart) { - break; - } - - // Keeps the calculated points - points[0][np - 1] = system.getTemperature(); - points[1][np - 1] = system.getPressure(); - pointsH[np - 1] = system.getPhase(1).getEnthalpy() - / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - pointsV[np - 1] = system.getPhase(1).getDensity(); - pointsS[np - 1] = system.getPhase(1).getEntropy() - / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; + if (!Double.isNaN(tempNy)) { + temp = tempNy; + break; + } + } + + // this part sets the first envelope point into the system + system.setBeta(phaseFraction); + system.setPressure(pres); + system.setTemperature(temp); + + sysNewtonRhapsonPhaseEnvelope nonLinSolver = + new sysNewtonRhapsonPhaseEnvelope(system, 2, system.getPhase(0).getNumberOfComponents()); + startPres = system.getPressure(); + nonLinSolver.setu(); + for (np = 1; np < 9980; np++) { + try { + // solves the np point of the envelope + nonLinSolver.calcInc(np); + nonLinSolver.solve(np); + + // double TT = system.getPhase(0).getTemperature(); + // double PP = system.getPhase(0).getPressure(); + } catch (Exception e0) { + // the envelope crushed. + // this part keeps the old values + // restarts the envelope from the other side + // and then stops + + if (restart) { + restart = false; + // keep values + Tmin = points[0][np - 2]; + npfirst = np - 1; + ncrfirst = nonLinSolver.getNpCrit(); + if (ncrfirst == 0) { + ncrfirst = npfirst; } - - try { - int ncr = nonLinSolver.getNpCrit(); - if (ncr == 0) { - ncr = np; - } - int ncr2 = np - ncr; - if (hascopiedPoints) { - // if it enters here the envelope crashed and restarted - // reallocate to have all values - points2 = new double[8][]; - pointsH2 = new double[8][]; - pointsS2 = new double[8][]; - pointsV2 = new double[8][]; - } - - // points2 are plotted - points2[0] = new double[ncr + 1]; - points2[1] = new double[ncr + 1]; - pointsH2[0] = new double[ncr + 1]; - pointsH2[1] = new double[ncr + 1]; - pointsS2[0] = new double[ncr + 1]; - pointsS2[1] = new double[ncr + 1]; - pointsV2[0] = new double[ncr + 1]; - pointsV2[1] = new double[ncr + 1]; - - if (ncr2 > 2) { - points2[2] = new double[ncr2 - 2]; - points2[3] = new double[ncr2 - 2]; - pointsH2[2] = new double[ncr2 - 2]; - pointsH2[3] = new double[ncr2 - 2]; - pointsS2[2] = new double[ncr2 - 2]; - pointsS2[3] = new double[ncr2 - 2]; - pointsV2[2] = new double[ncr2 - 2]; - pointsV2[3] = new double[ncr2 - 2]; - } else { - points2[2] = new double[0]; - points2[3] = new double[0]; - pointsH2[2] = new double[0]; - pointsH2[3] = new double[0]; - pointsS2[2] = new double[0]; - pointsS2[3] = new double[0]; - pointsV2[2] = new double[0]; - pointsV2[3] = new double[0]; - } - - for (int i = 0; i < ncr; i++) { - // second branch up to critical point - points2[0][i] = points[0][i]; - points2[1][i] = points[1][i]; - pointsH2[1][i] = points[1][i]; - pointsH2[0][i] = pointsH[i]; - pointsS2[1][i] = points[1][i]; - pointsS2[0][i] = pointsS[i]; - pointsV2[1][i] = points[1][i]; - pointsV2[0][i] = pointsV[i]; - } - if (ncr2 > 2) { - for (int i = 1; i < (ncr2 - 2); i++) { - // second branch after the critical point - points2[2][i] = points[0][i + ncr - 1]; - points2[3][i] = points[1][i + ncr - 1]; - pointsH2[3][i] = points[1][i + ncr - 1]; - pointsH2[2][i] = pointsH[i + ncr - 1]; - pointsS2[3][i] = points[1][i + ncr - 1]; - pointsS2[2][i] = pointsS[i + ncr - 1]; - pointsV2[3][i] = points[1][i + ncr - 1]; - pointsV2[2][i] = pointsV[i + ncr - 1]; - } - } - - if (hascopiedPoints) { - if (ncrfirst > npfirst) { - ncr = copiedPoints[0].length - 1; - ncr2 = npfirst - ncr; - npfirst = npfirst - 1; - } else { - ncr = ncrfirst; - ncr2 = npfirst - ncr; - } - - points2[4] = new double[ncr + 1]; - points2[5] = new double[ncr + 1]; - pointsH2[4] = new double[ncr + 1]; - pointsH2[5] = new double[ncr + 1]; - pointsS2[4] = new double[ncr + 1]; - pointsS2[5] = new double[ncr + 1]; - pointsV2[4] = new double[ncr + 1]; - pointsV2[5] = new double[ncr + 1]; - - if (ncr2 > 2) { - points2[6] = new double[ncr2 - 2]; - points2[7] = new double[ncr2 - 2]; - pointsH2[6] = new double[ncr2 - 2]; - pointsH2[7] = new double[ncr2 - 2]; - pointsS2[6] = new double[ncr2 - 2]; - pointsS2[7] = new double[ncr2 - 2]; - pointsV2[6] = new double[ncr2 - 2]; - pointsV2[7] = new double[ncr2 - 2]; - } else { - points2[6] = new double[0]; - points2[7] = new double[0]; - pointsH2[6] = new double[0]; - pointsH2[7] = new double[0]; - pointsS2[6] = new double[0]; - pointsS2[7] = new double[0]; - pointsV2[6] = new double[0]; - pointsV2[7] = new double[0]; - } - - for (int i = 0; i < ncr; i++) { - // first branch up to the critical point - points2[4][i] = copiedPoints[0][i]; - points2[5][i] = copiedPoints[1][i]; - pointsH2[5][i] = copiedPoints[1][i]; - pointsH2[4][i] = copiedPoints[2][i]; - pointsS2[5][i] = copiedPoints[1][i]; - pointsS2[4][i] = copiedPoints[3][i]; - pointsV2[5][i] = copiedPoints[1][i]; - pointsV2[4][i] = copiedPoints[4][i]; - } - if (ncr2 > 2) { - for (int i = 1; i < (ncr2 - 2); i++) { - // first branch after the critical point - points2[6][i] = copiedPoints[0][i + ncr - 1]; - points2[7][i] = copiedPoints[1][i + ncr - 1]; - pointsH2[7][i] = copiedPoints[1][i + ncr - 1]; - pointsH2[6][i] = copiedPoints[2][i + ncr - 1]; - pointsS2[7][i] = copiedPoints[1][i + ncr - 1]; - pointsS2[6][i] = copiedPoints[3][i + ncr - 1]; - pointsV2[7][i] = copiedPoints[1][i + ncr - 1]; - pointsV2[6][i] = copiedPoints[4][i + ncr - 1]; - } - } - } - - // critical point - system.setTemperature(system.getTC()); - system.setPressure(system.getPC()); - - system.init(3); - - points2[0][ncr] = system.getTC(); - points2[1][ncr] = system.getPC(); - - if (ncr2 > 2) { - points2[2][0] = system.getTC(); - points2[3][0] = system.getPC(); - } - } catch (Exception e2) { - // double nef = 0.; - logger.error("error", e2); + Tcfirst = system.getTC(); + Pcfirst = system.getPC(); + hascopiedPoints = true; + copiedPoints = new double[5][np - 1]; + for (int i = 0; i < np - 1; i++) { + copiedPoints[0][i] = points[0][i]; + copiedPoints[1][i] = points[1][i]; + copiedPoints[2][i] = pointsH[i]; + copiedPoints[3][i] = pointsS[i]; + copiedPoints[4][i] = pointsV[i]; } - - try { - if (outputToFile) { - // update this - String name1 = new String(); - name1 = fileName + "Dew.nc"; - file1 = new neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); - file1.setOutputFileName(name1); - file1.setXvalues(points2[2], "temp", "sec"); - file1.setYvalues(points2[3], "pres", "meter"); - file1.createFile(); - - String name2 = new String(); - name2 = fileName + "Bub.nc"; - file2 = new neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); - file2.setOutputFileName(name2); - file2.setXvalues(points2[0], "temp", "sec"); - file2.setYvalues(points2[1], "pres", "meter"); - file2.createFile(); - } - } catch (Exception e3) { - // double nef = 0.; - logger.error("error", e3); + // new settings + phaseFraction = 1.0 - phaseFraction; + if (bubblePointFirst) { + bubblePointFirst = false; + } else { + bubblePointFirst = true; } - } catch (Exception e4) { - // double nef = 0.; - logger.error("error", e4); + run(); + break; + } else { + np = np - 1; + break; + } } - } - /** - *- * calcHydrateLine. - *
- */ - public void calcHydrateLine() { - ThermodynamicOperations opsHyd = new ThermodynamicOperations(system); - try { - opsHyd.hydrateEquilibriumLine(10.0, 300.0); - } catch (Exception e) { - logger.error("error", e); + // check for critical point + double Kvallc = system.getPhase(0).getComponent(nonLinSolver.lc).getx() + / system.getPhase(1).getComponent(nonLinSolver.lc).getx(); + double Kvalhc = system.getPhase(0).getComponent(nonLinSolver.hc).getx() + / system.getPhase(1).getComponent(nonLinSolver.hc).getx(); + // double densV = system.getPhase(0).getDensity(); + // double densL = system.getPhase(1).getDensity(); + + // System.out.println(np + " " + system.getTemperature() + " " + + // system.getPressure() + " " + densV + " " + densL ); + + if ((nonLinSolver.etterCP == false)) { + if (Kvallc < 1.05 && Kvalhc > 0.95) { + // close to the critical point + // invert phase types and find the CP Temp and Press + + // System.out.println("critical point"); + nonLinSolver.npCrit = np; + system.invertPhaseTypes(); + nonLinSolver.etterCP = true; + // the critical point is found from interpolation plynimials based on K=1 of + // the + // most or least volatile component + nonLinSolver.calcCrit(); + } } - - // double[][] hydData = opsHyd.getData(); - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - DecimalFormat nf = new DecimalFormat(); - nf.setMaximumFractionDigits(1); - nf.applyPattern("####.#"); - if (bubblePointFirst) { - // bubble point side - navn[0] = "bubble point 2"; - navn[1] = "dew point 2"; - navn[2] = "dew point 1"; - navn[3] = "bubble point 1"; - } else { - // dew point side and does not crash - navn[0] = "dew point"; - navn[1] = "bubble point"; - navn[2] = "dew point"; - navn[3] = "bubbl point"; + if (nonLinSolver.calcCP) { + nonLinSolver.calcCP = false; + nonLinSolver.npCrit = np; + nonLinSolver.calcCrit(); } - double TC = system.getTC(); - double PC = system.getPC(); - - String title = "PT-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - String title3 = "PH-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - String title4 = "Density-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - String title5 = "PS-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - - graph2b graph3 = new graph2b(pointsH2, navn, title3, "Enthalpy [kJ/kg]", "Pressure [bara]"); - graph3.setVisible(true); - // graph3.saveFigure(new String(util.util.FileSystemSettings.tempDir + - // "NeqSimTempFig4.png")); - - graph2b graph4 = new graph2b(pointsV2, navn, title4, "Density [kg/m^3]", "Pressure [bara]"); - graph4.setVisible(true); - // graph4.saveFigure(util.util.FileSystemSettings.tempDir + - // "NeqSimTempFig2.png"); - - graph2b graph5 = - new graph2b(pointsS2, navn, title5, "Entropy [kJ/kg*K]", "Pressure [bara]"); - graph5.setVisible(true); - // graph5.saveFigure(util.util.FileSystemSettings.tempDir + - // "NeqSimTempFig3.png"); - - graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); - graph2.setVisible(true); - // graph2.saveFigure(util.util.FileSystemSettings.tempDir + - // "NeqSimTempFig1.png"); - - /* - * JDialog dialog = new JDialog(); Container dialogContentPane = dialog.getContentPane(); - * dialogContentPane.setLayout(new FlowLayout()); JFreeChartPanel chartPanel = - * graph4.getChartPanel(); dialogContentPane.add(chartPanel); dialog.show(); - */ - } - - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} - - /** {@inheritDoc} */ - @Override - public double[][] getPoints(int i) { - return points2; - } - - /** {@inheritDoc} */ - @Override - public void addData(String name, double[][] data) { - double[][] localPoints = new double[points2.length + data.length][]; - navn[localPoints.length / 2 - 1] = name; - System.arraycopy(points2, 0, localPoints, 0, points2.length); - System.arraycopy(data, 0, localPoints, points2.length, data.length); - points2 = localPoints; - } - - /** {@inheritDoc} */ - @Override - public double[] get(String name) { - if (name.equals("dewT")) { - return points2[0]; - } - if (name.equals("dewP")) { - return points2[1]; - } - if (name.equals("bubT")) { - return points2[2]; - } - if (name.equals("bubP")) { - return points2[3]; - } - if (name.equals("dewT2")) { - return points2[4]; - } - if (name.equals("dewP2")) { - return points2[5]; - } - if (name.equals("bubT2")) { - return points2[6]; + // stores cricondenbar and cricondentherm + // HERE the new cricoT and crico P values will be called instead + if (system.getTemperature() > cricondenTherm[0]) { + cricondenTherm[1] = system.getPressure(); + cricondenTherm[0] = system.getTemperature(); + } else { + nonLinSolver.ettercricoT = true; } - if (name.equals("bubP2")) { - return points2[7]; + if (system.getPressure() > cricondenBar[1]) { + cricondenBar[0] = system.getTemperature(); + cricondenBar[1] = system.getPressure(); } - if (name.equals("dewH")) { - return pointsH2[2]; + + // Exit criteria + if ((system.getPressure() < minPressure && nonLinSolver.ettercricoT)) { + break; } - if (name.equals("dewDens")) { - return pointsV2[2]; + if (system.getPressure() > maxPressure) { + break; } - if (name.equals("dewS")) { - return pointsS2[2]; + if (system.getTemperature() > Tmin && !restart) { + break; } - if (name.equals("bubH")) { - return pointsH2[0]; + + // Keeps the calculated points + points[0][np - 1] = system.getTemperature(); + points[1][np - 1] = system.getPressure(); + pointsH[np - 1] = + system.getPhase(1).getEnthalpy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3; + pointsV[np - 1] = system.getPhase(1).getDensity(); + pointsS[np - 1] = + system.getPhase(1).getEntropy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3; + } + + try { + int ncr = nonLinSolver.getNpCrit(); + if (ncr == 0) { + ncr = np; } - if (name.equals("bubDens")) { - return pointsV2[0]; + int ncr2 = np - ncr; + if (hascopiedPoints) { + // if it enters here the envelope crashed and restarted + // reallocate to have all values + points2 = new double[8][]; + pointsH2 = new double[8][]; + pointsS2 = new double[8][]; + pointsV2 = new double[8][]; } - if (name.equals("bubS")) { - return pointsS2[0]; + + // points2 are plotted + points2[0] = new double[ncr + 1]; + points2[1] = new double[ncr + 1]; + pointsH2[0] = new double[ncr + 1]; + pointsH2[1] = new double[ncr + 1]; + pointsS2[0] = new double[ncr + 1]; + pointsS2[1] = new double[ncr + 1]; + pointsV2[0] = new double[ncr + 1]; + pointsV2[1] = new double[ncr + 1]; + + if (ncr2 > 2) { + points2[2] = new double[ncr2 - 2]; + points2[3] = new double[ncr2 - 2]; + pointsH2[2] = new double[ncr2 - 2]; + pointsH2[3] = new double[ncr2 - 2]; + pointsS2[2] = new double[ncr2 - 2]; + pointsS2[3] = new double[ncr2 - 2]; + pointsV2[2] = new double[ncr2 - 2]; + pointsV2[3] = new double[ncr2 - 2]; + } else { + points2[2] = new double[0]; + points2[3] = new double[0]; + pointsH2[2] = new double[0]; + pointsH2[3] = new double[0]; + pointsS2[2] = new double[0]; + pointsS2[3] = new double[0]; + pointsV2[2] = new double[0]; + pointsV2[3] = new double[0]; } - if (name.equals("cricondentherm")) { - return cricondenTherm; + + for (int i = 0; i < ncr; i++) { + // second branch up to critical point + points2[0][i] = points[0][i]; + points2[1][i] = points[1][i]; + pointsH2[1][i] = points[1][i]; + pointsH2[0][i] = pointsH[i]; + pointsS2[1][i] = points[1][i]; + pointsS2[0][i] = pointsS[i]; + pointsV2[1][i] = points[1][i]; + pointsV2[0][i] = pointsV[i]; } - if (name.equals("cricondenbar")) { - return cricondenBar; + if (ncr2 > 2) { + for (int i = 1; i < (ncr2 - 2); i++) { + // second branch after the critical point + points2[2][i] = points[0][i + ncr - 1]; + points2[3][i] = points[1][i + ncr - 1]; + pointsH2[3][i] = points[1][i + ncr - 1]; + pointsH2[2][i] = pointsH[i + ncr - 1]; + pointsS2[3][i] = points[1][i + ncr - 1]; + pointsS2[2][i] = pointsS[i + ncr - 1]; + pointsV2[3][i] = points[1][i + ncr - 1]; + pointsV2[2][i] = pointsV[i + ncr - 1]; + } } - if (name.equals("criticalPoint1")) { - return new double[] {system.getTC(), system.getPC()}; + + if (hascopiedPoints) { + if (ncrfirst > npfirst) { + ncr = copiedPoints[0].length - 1; + ncr2 = npfirst - ncr; + npfirst = npfirst - 1; + } else { + ncr = ncrfirst; + ncr2 = npfirst - ncr; + } + + points2[4] = new double[ncr + 1]; + points2[5] = new double[ncr + 1]; + pointsH2[4] = new double[ncr + 1]; + pointsH2[5] = new double[ncr + 1]; + pointsS2[4] = new double[ncr + 1]; + pointsS2[5] = new double[ncr + 1]; + pointsV2[4] = new double[ncr + 1]; + pointsV2[5] = new double[ncr + 1]; + + if (ncr2 > 2) { + points2[6] = new double[ncr2 - 2]; + points2[7] = new double[ncr2 - 2]; + pointsH2[6] = new double[ncr2 - 2]; + pointsH2[7] = new double[ncr2 - 2]; + pointsS2[6] = new double[ncr2 - 2]; + pointsS2[7] = new double[ncr2 - 2]; + pointsV2[6] = new double[ncr2 - 2]; + pointsV2[7] = new double[ncr2 - 2]; + } else { + points2[6] = new double[0]; + points2[7] = new double[0]; + pointsH2[6] = new double[0]; + pointsH2[7] = new double[0]; + pointsS2[6] = new double[0]; + pointsS2[7] = new double[0]; + pointsV2[6] = new double[0]; + pointsV2[7] = new double[0]; + } + + for (int i = 0; i < ncr; i++) { + // first branch up to the critical point + points2[4][i] = copiedPoints[0][i]; + points2[5][i] = copiedPoints[1][i]; + pointsH2[5][i] = copiedPoints[1][i]; + pointsH2[4][i] = copiedPoints[2][i]; + pointsS2[5][i] = copiedPoints[1][i]; + pointsS2[4][i] = copiedPoints[3][i]; + pointsV2[5][i] = copiedPoints[1][i]; + pointsV2[4][i] = copiedPoints[4][i]; + } + if (ncr2 > 2) { + for (int i = 1; i < (ncr2 - 2); i++) { + // first branch after the critical point + points2[6][i] = copiedPoints[0][i + ncr - 1]; + points2[7][i] = copiedPoints[1][i + ncr - 1]; + pointsH2[7][i] = copiedPoints[1][i + ncr - 1]; + pointsH2[6][i] = copiedPoints[2][i + ncr - 1]; + pointsS2[7][i] = copiedPoints[1][i + ncr - 1]; + pointsS2[6][i] = copiedPoints[3][i + ncr - 1]; + pointsV2[7][i] = copiedPoints[1][i + ncr - 1]; + pointsV2[6][i] = copiedPoints[4][i + ncr - 1]; + } + } } - if (name.equals("criticalPoint2")) { - return new double[] {0, 0}; - } else { - return null; + + // critical point + system.setTemperature(system.getTC()); + system.setPressure(system.getPC()); + + system.init(3); + + points2[0][ncr] = system.getTC(); + points2[1][ncr] = system.getPC(); + + if (ncr2 > 2) { + points2[2][0] = system.getTC(); + points2[3][0] = system.getPC(); } + } catch (Exception e2) { + // double nef = 0.; + logger.error("error", e2); + } + /* + * try { if (outputToFile) { // update this String name1 = new String(); name1 = fileName + + * "Dew.nc"; file1 = new + * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); + * file1.setOutputFileName(name1); file1.setXvalues(points2[2], "temp", "sec"); + * file1.setYvalues(points2[3], "pres", "meter"); file1.createFile(); + * + * String name2 = new String(); name2 = fileName + "Bub.nc"; file2 = new + * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); + * file2.setOutputFileName(name2); file2.setXvalues(points2[0], "temp", "sec"); + * file2.setYvalues(points2[1], "pres", "meter"); file2.createFile(); } } catch (Exception e3) + * { // double nef = 0.; logger.error("error", e3); } + */ + } catch (Exception e4) { + // double nef = 0.; + logger.error("error", e4); } - - /** {@inheritDoc} */ - @Override - public void createNetCdfFile(String name) { - fileName = name; + } + + /** + *+ * calcHydrateLine. + *
+ */ + public void calcHydrateLine() { + ThermodynamicOperations opsHyd = new ThermodynamicOperations(system); + try { + opsHyd.hydrateEquilibriumLine(10.0, 300.0); + } catch (Exception e) { + logger.error("error", e); } - /** - * Getter for property bubblePointFirst. - * - * @return Value of property bubblePointFirst. - */ - public boolean isBubblePointFirst() { - return bubblePointFirst; + // double[][] hydData = opsHyd.getData(); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + DecimalFormat nf = new DecimalFormat(); + nf.setMaximumFractionDigits(1); + nf.applyPattern("####.#"); + if (bubblePointFirst) { + // bubble point side + navn[0] = "bubble point 2"; + navn[1] = "dew point 2"; + navn[2] = "dew point 1"; + navn[3] = "bubble point 1"; + } else { + // dew point side and does not crash + navn[0] = "dew point"; + navn[1] = "bubble point"; + navn[2] = "dew point"; + navn[3] = "bubbl point"; } - /** - * Setter for property bubblePointFirst. - * - * @param bubblePointFirst New value of property bubblePointFirst. + double TC = system.getTC(); + double PC = system.getPC(); + + String title = + "PT-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + String.valueOf(nf.format(PC)); + String title3 = + "PH-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + String.valueOf(nf.format(PC)); + String title4 = "Density-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + + String.valueOf(nf.format(PC)); + String title5 = + "PS-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + String.valueOf(nf.format(PC)); + + graph2b graph3 = new graph2b(pointsH2, navn, title3, "Enthalpy [kJ/kg]", "Pressure [bara]"); + graph3.setVisible(true); + // graph3.saveFigure(new String(util.util.FileSystemSettings.tempDir + + // "NeqSimTempFig4.png")); + + graph2b graph4 = new graph2b(pointsV2, navn, title4, "Density [kg/m^3]", "Pressure [bara]"); + graph4.setVisible(true); + // graph4.saveFigure(util.util.FileSystemSettings.tempDir + + // "NeqSimTempFig2.png"); + + graph2b graph5 = new graph2b(pointsS2, navn, title5, "Entropy [kJ/kg*K]", "Pressure [bara]"); + graph5.setVisible(true); + // graph5.saveFigure(util.util.FileSystemSettings.tempDir + + // "NeqSimTempFig3.png"); + + graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); + graph2.setVisible(true); + // graph2.saveFigure(util.util.FileSystemSettings.tempDir + + // "NeqSimTempFig1.png"); + + /* + * JDialog dialog = new JDialog(); Container dialogContentPane = dialog.getContentPane(); + * dialogContentPane.setLayout(new FlowLayout()); JFreeChartPanel chartPanel = + * graph4.getChartPanel(); dialogContentPane.add(chartPanel); dialog.show(); */ - public void setBubblePointFirst(boolean bubblePointFirst) { - this.bubblePointFirst = bubblePointFirst; + } + + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} + + /** {@inheritDoc} */ + @Override + public double[][] getPoints(int i) { + return points2; + } + + /** {@inheritDoc} */ + @Override + public void addData(String name, double[][] data) { + double[][] localPoints = new double[points2.length + data.length][]; + navn[localPoints.length / 2 - 1] = name; + System.arraycopy(points2, 0, localPoints, 0, points2.length); + System.arraycopy(data, 0, localPoints, points2.length, data.length); + points2 = localPoints; + } + + /** {@inheritDoc} */ + @Override + public double[] get(String name) { + if (name.equals("dewT")) { + return points2[0]; } - - /** {@inheritDoc} */ - @Override - public String[][] getResultTable() { - return null; + if (name.equals("dewP")) { + return points2[1]; + } + if (name.equals("bubT")) { + return points2[2]; + } + if (name.equals("bubP")) { + return points2[3]; + } + if (name.equals("dewT2")) { + return points2[4]; + } + if (name.equals("dewP2")) { + return points2[5]; + } + if (name.equals("bubT2")) { + return points2[6]; + } + if (name.equals("bubP2")) { + return points2[7]; + } + if (name.equals("dewH")) { + return pointsH2[2]; + } + if (name.equals("dewDens")) { + return pointsV2[2]; + } + if (name.equals("dewS")) { + return pointsS2[2]; + } + if (name.equals("bubH")) { + return pointsH2[0]; + } + if (name.equals("bubDens")) { + return pointsV2[0]; + } + if (name.equals("bubS")) { + return pointsS2[0]; + } + if (name.equals("cricondentherm")) { + return cricondenTherm; + } + if (name.equals("cricondenbar")) { + return cricondenBar; + } + if (name.equals("criticalPoint1")) { + return new double[] {system.getTC(), system.getPC()}; + } + if (name.equals("criticalPoint2")) { + return new double[] {0, 0}; + } else { + return null; + } + } + + /** + * Getter for property bubblePointFirst. + * + * @return Value of property bubblePointFirst. + */ + public boolean isBubblePointFirst() { + return bubblePointFirst; + } + + /** + * Setter for property bubblePointFirst. + * + * @param bubblePointFirst New value of property bubblePointFirst. + */ + public void setBubblePointFirst(boolean bubblePointFirst) { + this.bubblePointFirst = bubblePointFirst; + } + + /** {@inheritDoc} */ + @Override + public String[][] getResultTable() { + return null; + } + + /** + *+ * tempKWilson. + *
+ * + * @param beta a double + * @param P a double + * @return a double + */ + public double tempKWilson(double beta, double P) { + // Initiallizes the temperature of a saturation point for given pressure + // based on K values of Wilson + // see Michelsen book thermodynamics & computational aspects + + double initTc = 0.; + double initPc = 0.; + double initAc = 0.; + double Tstart = 0.; + double Tstartold = 0.; + double initT = 0; + double dinitT = 0; + int numberOfComponents = system.getPhase(0).getNumberOfComponents(); + int lc = 0; + int hc = 0; + + double[] Kwil = new double[numberOfComponents]; + + double min = 100000.; + double max = 0.; + + for (int i = 0; i < numberOfComponents; i++) { + if (system.getPhase(0).getComponents()[i].getTC() > max) { + max = system.getPhase(0).getComponents()[i].getTC(); + hc = i; + } + if (system.getPhase(0).getComponents()[i].getTC() < min) { + min = system.getPhase(0).getComponents()[i].getTC(); + lc = i; + } } - /** - *- * tempKWilson. - *
- * - * @param beta a double - * @param P a double - * @return a double - */ - public double tempKWilson(double beta, double P) { - // Initiallizes the temperature of a saturation point for given pressure - // based on K values of Wilson - // see Michelsen book thermodynamics & computational aspects - - double initTc = 0.; - double initPc = 0.; - double initAc = 0.; - double Tstart = 0.; - double Tstartold = 0.; - double initT = 0; - double dinitT = 0; - int numberOfComponents = system.getPhase(0).getNumberOfComponents(); - int lc = 0; - int hc = 0; - - double[] Kwil = new double[numberOfComponents]; - - double min = 100000.; - double max = 0.; - - for (int i = 0; i < numberOfComponents; i++) { - if (system.getPhase(0).getComponents()[i].getTC() > max) { - max = system.getPhase(0).getComponents()[i].getTC(); - hc = i; - } - if (system.getPhase(0).getComponents()[i].getTC() < min) { - min = system.getPhase(0).getComponents()[i].getTC(); - lc = i; - } - } - - if (beta <= 0.5) { - initTc = system.getPhase(0).getComponents()[lc].getTC(); // closer to bubble point get - // the lightest - // component - initPc = system.getPhase(0).getComponents()[lc].getPC(); - initAc = system.getPhase(0).getComponents()[lc].getAcentricFactor(); - } else if (beta > 0.5) { - initTc = system.getPhase(0).getComponents()[hc].getTC(); // closer to dew point get the - // heaviest component - initPc = system.getPhase(0).getComponents()[hc].getPC(); - initAc = system.getPhase(0).getComponents()[hc].getAcentricFactor(); + if (beta <= 0.5) { + initTc = system.getPhase(0).getComponents()[lc].getTC(); // closer to bubble point get + // the lightest + // component + initPc = system.getPhase(0).getComponents()[lc].getPC(); + initAc = system.getPhase(0).getComponents()[lc].getAcentricFactor(); + } else if (beta > 0.5) { + initTc = system.getPhase(0).getComponents()[hc].getTC(); // closer to dew point get the + // heaviest component + initPc = system.getPhase(0).getComponents()[hc].getPC(); + initAc = system.getPhase(0).getComponents()[hc].getAcentricFactor(); + } + Tstart = initTc * 5.373 * (1 + initAc) / (5.373 * (1 + initAc) - Math.log(P / initPc)); // initial + // T + // based + // on + // the + // lighterst/heaviest + // component + + // solve for Tstart with Newton + for (int i = 0; i < 1000; i++) { + initT = 0.; + dinitT = 0.; + for (int j = 0; j < numberOfComponents; j++) { + Kwil[j] = system.getPhase(0).getComponents()[j].getPC() / P + * Math.exp(5.373 * (1. + system.getPhase(0).getComponents()[j].getAcentricFactor()) + * (1. - system.getPhase(0).getComponents()[j].getTC() / Tstart)); + system.getPhases()[0].getComponents()[j].setK(Math.log(Kwil[j])); + } + + for (int j = 0; j < numberOfComponents; j++) { + if (beta < 0.5) { + initT = initT + system.getPhase(0).getComponents()[j].getz() * Kwil[j]; + dinitT = dinitT + system.getPhase(0).getComponents()[j].getz() * Kwil[j] * 5.373 + * (1 + system.getPhase(0).getComponents()[j].getAcentricFactor()) + * system.getPhase(0).getComponents()[j].getTC() / (Tstart * Tstart); + } else { + initT = initT + system.getPhase(0).getComponents()[j].getz() / Kwil[j]; + dinitT = dinitT - system.getPhase(0).getComponents()[j].getz() / Kwil[j] * 5.373 + * (1 + system.getPhase(0).getComponents()[j].getAcentricFactor()) + * system.getPhase(0).getComponents()[j].getTC() / (Tstart * Tstart); } - Tstart = initTc * 5.373 * (1 + initAc) / (5.373 * (1 + initAc) - Math.log(P / initPc)); // initial - // T - // based - // on - // the - // lighterst/heaviest - // component - - // solve for Tstart with Newton - for (int i = 0; i < 1000; i++) { - initT = 0.; - dinitT = 0.; - for (int j = 0; j < numberOfComponents; j++) { - Kwil[j] = system.getPhase(0).getComponents()[j].getPC() / P - * Math.exp(5.373 - * (1. + system.getPhase(0).getComponents()[j].getAcentricFactor()) - * (1. - system.getPhase(0).getComponents()[j].getTC() / Tstart)); - system.getPhases()[0].getComponents()[j].setK(Math.log(Kwil[j])); - } - - for (int j = 0; j < numberOfComponents; j++) { - if (beta < 0.5) { - initT = initT + system.getPhase(0).getComponents()[j].getz() * Kwil[j]; - dinitT = dinitT + system.getPhase(0).getComponents()[j].getz() * Kwil[j] * 5.373 - * (1 + system.getPhase(0).getComponents()[j].getAcentricFactor()) - * system.getPhase(0).getComponents()[j].getTC() / (Tstart * Tstart); - } else { - initT = initT + system.getPhase(0).getComponents()[j].getz() / Kwil[j]; - dinitT = dinitT - system.getPhase(0).getComponents()[j].getz() / Kwil[j] * 5.373 - * (1 + system.getPhase(0).getComponents()[j].getAcentricFactor()) - * system.getPhase(0).getComponents()[j].getTC() / (Tstart * Tstart); - } - } - - initT = initT - 1.; - if (Math.abs(initT / dinitT) > 0.1 * Tstart) { - Tstart = Tstart - 0.001 * initT / dinitT; - } else { - Tstart = Tstart - initT / dinitT; - } + } - if (Math.abs(Tstart - Tstartold) < 1.e-5) { - return Tstart; - } - Tstartold = Tstart; - } + initT = initT - 1.; + if (Math.abs(initT / dinitT) > 0.1 * Tstart) { + Tstart = Tstart - 0.001 * initT / dinitT; + } else { + Tstart = Tstart - initT / dinitT; + } + if (Math.abs(Tstart - Tstartold) < 1.e-5) { return Tstart; + } + Tstartold = Tstart; } - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - DecimalFormat nf = new DecimalFormat(); - nf.setMaximumFractionDigits(1); - nf.applyPattern("####.#"); - - double TC = system.getTC(); - double PC = system.getPC(); - logger.info("tc : " + TC + " PC : " + PC); - String[] navn = {"bubble point", "dew point", "bubble point", "dew point"}; - String title = "PT-graph. TC=" + String.valueOf(nf.format(TC)) + "K, PC=" - + String.valueOf(nf.format(PC) + " bara"); - graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); - return graph2.getChart(); - } + return Tstart; + } + + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + DecimalFormat nf = new DecimalFormat(); + nf.setMaximumFractionDigits(1); + nf.applyPattern("####.#"); + + double TC = system.getTC(); + double PC = system.getPC(); + logger.info("tc : " + TC + " PC : " + PC); + String[] navn = {"bubble point", "dew point", "bubble point", "dew point"}; + String title = "PT-graph. TC=" + String.valueOf(nf.format(TC)) + "K, PC=" + + String.valueOf(nf.format(PC) + " bara"); + graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); + return graph2.getChart(); + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeNew.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeNew.java index 49b90712b2..2e882d5c3f 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeNew.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeNew.java @@ -21,392 +21,374 @@ * @version $Id: $Id */ public class pTphaseEnvelopeNew extends BaseOperation { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(pTphaseEnvelopeNew.class); - - graph2b graph2 = null; - SystemInterface system; - double[] cricondenTherm = new double[3]; - double[] cricondenBar = new double[3]; - double phaseFraction = 1e-10; - neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D file1; - neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D file2; - int i, j = 0, nummer = 0, iterations = 0, maxNumberOfIterations = 10000; - double lowPres = 1.0; - boolean outputToFile = false; - JProgressBar monitor; - JFrame mainFrame; - String fileName = "c:/file"; - JPanel mainPanel; - double temp = 0, pres = 0; - double[][] points = new double[2][]; - double[] pointsH = new double[10000]; - double[][] pointsH2 = new double[4][]; - double[] pointsV = new double[10000]; - - ; - double[][] pointsV2 = new double[4][]; - double[] pointsS = new double[10000]; - double[][] pointsS2 = new double[4][]; - public double[][] points2 = new double[4][]; - int np = 0; - int speceq = 0; - - /** - *- * Constructor for pTphaseEnvelopeNew. - *
- */ - public pTphaseEnvelopeNew() {} - - /** - *- * Constructor for pTphaseEnvelopeNew. - *
- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param name a {@link java.lang.String} object - * @param phaseFraction a double - * @param lowPres a double - */ - public pTphaseEnvelopeNew(SystemInterface system, String name, double phaseFraction, - double lowPres) { - this.system = system; - this.phaseFraction = phaseFraction; + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(pTphaseEnvelopeNew.class); + + graph2b graph2 = null; + SystemInterface system; + double[] cricondenTherm = new double[3]; + double[] cricondenBar = new double[3]; + double phaseFraction = 1e-10; + int i, j = 0, nummer = 0, iterations = 0, maxNumberOfIterations = 10000; + double lowPres = 1.0; + boolean outputToFile = false; + JProgressBar monitor; + JFrame mainFrame; + String fileName = "c:/file"; + JPanel mainPanel; + double temp = 0, pres = 0; + double[][] points = new double[2][]; + double[] pointsH = new double[10000]; + double[][] pointsH2 = new double[4][]; + double[] pointsV = new double[10000]; + + ; + double[][] pointsV2 = new double[4][]; + double[] pointsS = new double[10000]; + double[][] pointsS2 = new double[4][]; + public double[][] points2 = new double[4][]; + int np = 0; + int speceq = 0; + + /** + *+ * Constructor for pTphaseEnvelopeNew. + *
+ */ + public pTphaseEnvelopeNew() {} + + /** + *+ * Constructor for pTphaseEnvelopeNew. + *
+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param name a {@link java.lang.String} object + * @param phaseFraction a double + * @param lowPres a double + */ + public pTphaseEnvelopeNew(SystemInterface system, String name, double phaseFraction, + double lowPres) { + this.system = system; + this.phaseFraction = phaseFraction; + + this.lowPres = lowPres; + + if (name != null) { + outputToFile = true; + fileName = name; + } + mainFrame = new JFrame("Progress Bar"); + mainPanel = new JPanel(); + mainPanel.setSize(200, 100); + mainFrame.getContentPane().setLayout(new FlowLayout()); + mainPanel.setLayout(new FlowLayout()); + mainFrame.setSize(200, 100); + monitor = new JProgressBar(0, 00); + monitor.setSize(200, 100); + monitor.setStringPainted(true); + mainPanel.add(monitor); + mainFrame.getContentPane().add(mainPanel); + mainFrame.setVisible(true); + } + + /** {@inheritDoc} */ + @Override + public void run() { + try { + points[0] = new double[10000]; + points[1] = new double[10000]; + + system.setPressure(lowPres); + + ThermodynamicOperations testOps = new ThermodynamicOperations(system); + + try { + testOps.bubblePointTemperatureFlash(); + } catch (Exception e) { + e.toString(); + return; + } + logger.info("temperature bubT = " + system.getTemperature()); + + sysNewtonRhapsonPhaseEnvelope2 nonLinSolver = new sysNewtonRhapsonPhaseEnvelope2(system); + nonLinSolver.solve(1); + nonLinSolver.calcInc(1); + + for (np = 1; np < 5; np++) { + if (np % 5 == 0) { + monitor.setValue(np); + monitor.setString("Calculated points: " + np); + } - this.lowPres = lowPres; + nonLinSolver.calcInc(np); + nonLinSolver.solve(np); - if (name != null) { - outputToFile = true; - fileName = name; + if (system.getTemperature() > cricondenTherm[0]) { + cricondenTherm[1] = system.getPressure(); + cricondenTherm[0] = system.getTemperature(); + } + if (system.getPressure() > cricondenBar[1]) { + cricondenBar[0] = system.getTemperature(); + cricondenBar[1] = system.getPressure(); } - mainFrame = new JFrame("Progress Bar"); - mainPanel = new JPanel(); - mainPanel.setSize(200, 100); - mainFrame.getContentPane().setLayout(new FlowLayout()); - mainPanel.setLayout(new FlowLayout()); - mainFrame.setSize(200, 100); - monitor = new JProgressBar(0, 00); - monitor.setSize(200, 100); - monitor.setStringPainted(true); - mainPanel.add(monitor); - mainFrame.getContentPane().add(mainPanel); - mainFrame.setVisible(true); - } - /** {@inheritDoc} */ - @Override - public void run() { - try { - points[0] = new double[10000]; - points[1] = new double[10000]; - - system.setPressure(lowPres); - - ThermodynamicOperations testOps = new ThermodynamicOperations(system); - - try { - testOps.bubblePointTemperatureFlash(); - } catch (Exception e) { - e.toString(); - return; - } - logger.info("temperature bubT = " + system.getTemperature()); - - sysNewtonRhapsonPhaseEnvelope2 nonLinSolver = - new sysNewtonRhapsonPhaseEnvelope2(system); - nonLinSolver.solve(1); - nonLinSolver.calcInc(1); - - for (np = 1; np < 5; np++) { - if (np % 5 == 0) { - monitor.setValue(np); - monitor.setString("Calculated points: " + np); - } - - nonLinSolver.calcInc(np); - nonLinSolver.solve(np); - - if (system.getTemperature() > cricondenTherm[0]) { - cricondenTherm[1] = system.getPressure(); - cricondenTherm[0] = system.getTemperature(); - } - if (system.getPressure() > cricondenBar[1]) { - cricondenBar[0] = system.getTemperature(); - cricondenBar[1] = system.getPressure(); - } - - if (Double.isNaN(system.getTemperature()) - || Double.isNaN(system.getTemperature())) {// || - // system.getPressure() - // < lowPres) { - points[0][np - 1] = points[0][np - 3]; - points[1][np - 1] = points[1][np - 3]; - pointsH[np - 1] = pointsH[np - 3]; - pointsV[np - 1] = pointsV[np - 3]; - pointsS[np - 1] = pointsS[np - 3]; - - // logger.info("avbryter" + np); - break; - } - // logger.info("Ideal pres: " + getPressure()); - // logger.info("temp: " + system.getTemperature()); - points[0][np - 1] = system.getTemperature(); - points[1][np - 1] = system.getPressure(); - pointsH[np - 1] = system.getPhase(1).getEnthalpy() - / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - pointsV[np - 1] = system.getPhase(1).getDensity(); - pointsS[np - 1] = system.getPhase(1).getEntropy() - / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - } - - int ncr = nonLinSolver.getNpCrit(); - int ncr2 = np - ncr; - - logger.info("ncr: " + ncr + " ncr2 . " + ncr2); - points2[0] = new double[ncr + 1]; - points2[1] = new double[ncr + 1]; - pointsH2[0] = new double[ncr + 1]; - pointsH2[1] = new double[ncr + 1]; - pointsS2[0] = new double[ncr + 1]; - pointsS2[1] = new double[ncr + 1]; - pointsV2[0] = new double[ncr + 1]; - pointsV2[1] = new double[ncr + 1]; - if (ncr2 > 2) { - points2[2] = new double[ncr2 - 2]; - points2[3] = new double[ncr2 - 2]; - pointsH2[2] = new double[ncr2 - 2]; - pointsH2[3] = new double[ncr2 - 2]; - pointsV2[2] = new double[ncr2 - 2]; - pointsV2[3] = new double[ncr2 - 2]; - pointsS2[2] = new double[ncr2 - 2]; - pointsS2[3] = new double[ncr2 - 2]; - } else { - points2[2] = new double[0]; - points2[3] = new double[0]; - pointsH2[2] = new double[0]; - pointsH2[3] = new double[0]; - pointsV2[2] = new double[0]; - pointsV2[3] = new double[0]; - pointsS2[2] = new double[0]; - pointsS2[3] = new double[0]; - } - - for (int i = 0; i < ncr; i++) { - points2[0][i] = points[0][i]; - points2[1][i] = points[1][i]; - - pointsH2[1][i] = points[1][i]; - pointsH2[0][i] = pointsH[i]; - - pointsS2[1][i] = points[1][i]; - pointsS2[0][i] = pointsS[i]; - - pointsV2[1][i] = points[1][i]; - pointsV2[0][i] = pointsV[i]; - } - - system.setTemperature(system.getTC() + 0.001); - system.setPressure(system.getPC() + 0.001); - system.init(3); - - points2[0][ncr] = system.getTC(); - points2[1][ncr] = system.getPC(); - - pointsH2[1][ncr] = system.getPC(); - pointsH2[0][ncr] = - system.getPhase(1).getEnthalpy() / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - - pointsS2[1][ncr] = system.getPC(); - pointsS2[0][ncr] = - system.getPhase(1).getEntropy() / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - - pointsV2[1][ncr] = system.getPC(); - pointsV2[0][ncr] = system.getPhase(1).getDensity(); - - if (ncr2 > 2) { - points2[2][0] = system.getTC(); - points2[3][0] = system.getPC(); - pointsH2[3][0] = system.getPC(); - pointsH2[2][0] = system.getPhase(1).getEnthalpy() - / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - pointsS2[3][0] = system.getPC(); - pointsS2[2][0] = system.getPhase(1).getEntropy() - / system.getPhase(1).getNumberOfMolesInPhase() - / system.getPhase(1).getMolarMass() / 1e3; - pointsV2[3][0] = system.getPC(); - pointsV2[2][0] = system.getPhase(1).getDensity(); - - for (int i = 1; i < (ncr2 - 2); i++) { - points2[2][i] = points[0][i + ncr - 1]; - points2[3][i] = points[1][i + ncr - 1]; - - pointsH2[3][i] = points[1][i + ncr - 1]; - pointsH2[2][i] = pointsH[i + ncr - 1]; - - pointsS2[3][i] = points[1][i + ncr - 1]; - pointsS2[2][i] = pointsS[i + ncr - 1]; - - pointsV2[3][i] = points[1][i + ncr - 1]; - pointsV2[2][i] = pointsV[i + ncr - 1]; - } - } - // monitor.close(); - mainFrame.setVisible(false); - - if (outputToFile) { - String name1 = new String(); - name1 = fileName + "Dew.nc"; - file1 = new neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); - file1.setOutputFileName(name1); - file1.setXvalues(points2[2], "temp", "sec"); - file1.setYvalues(points2[3], "pres", "meter"); - file1.createFile(); - - String name2 = new String(); - name2 = fileName + "Bub.nc"; - file2 = new neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); - file2.setOutputFileName(name2); - file2.setXvalues(points2[0], "temp", "sec"); - file2.setYvalues(points2[1], "pres", "meter"); - file2.createFile(); - } - } catch (Exception e) { - logger.error("error", e); + if (Double.isNaN(system.getTemperature()) || Double.isNaN(system.getTemperature())) {// || + // system.getPressure() + // < + // lowPres) + // { + points[0][np - 1] = points[0][np - 3]; + points[1][np - 1] = points[1][np - 3]; + pointsH[np - 1] = pointsH[np - 3]; + pointsV[np - 1] = pointsV[np - 3]; + pointsS[np - 1] = pointsS[np - 3]; + + // logger.info("avbryter" + np); + break; + } + // logger.info("Ideal pres: " + getPressure()); + // logger.info("temp: " + system.getTemperature()); + points[0][np - 1] = system.getTemperature(); + points[1][np - 1] = system.getPressure(); + pointsH[np - 1] = + system.getPhase(1).getEnthalpy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3; + pointsV[np - 1] = system.getPhase(1).getDensity(); + pointsS[np - 1] = + system.getPhase(1).getEntropy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3; + } + + int ncr = nonLinSolver.getNpCrit(); + int ncr2 = np - ncr; + + logger.info("ncr: " + ncr + " ncr2 . " + ncr2); + points2[0] = new double[ncr + 1]; + points2[1] = new double[ncr + 1]; + pointsH2[0] = new double[ncr + 1]; + pointsH2[1] = new double[ncr + 1]; + pointsS2[0] = new double[ncr + 1]; + pointsS2[1] = new double[ncr + 1]; + pointsV2[0] = new double[ncr + 1]; + pointsV2[1] = new double[ncr + 1]; + if (ncr2 > 2) { + points2[2] = new double[ncr2 - 2]; + points2[3] = new double[ncr2 - 2]; + pointsH2[2] = new double[ncr2 - 2]; + pointsH2[3] = new double[ncr2 - 2]; + pointsV2[2] = new double[ncr2 - 2]; + pointsV2[3] = new double[ncr2 - 2]; + pointsS2[2] = new double[ncr2 - 2]; + pointsS2[3] = new double[ncr2 - 2]; + } else { + points2[2] = new double[0]; + points2[3] = new double[0]; + pointsH2[2] = new double[0]; + pointsH2[3] = new double[0]; + pointsV2[2] = new double[0]; + pointsV2[3] = new double[0]; + pointsS2[2] = new double[0]; + pointsS2[3] = new double[0]; + } + + for (int i = 0; i < ncr; i++) { + points2[0][i] = points[0][i]; + points2[1][i] = points[1][i]; + + pointsH2[1][i] = points[1][i]; + pointsH2[0][i] = pointsH[i]; + + pointsS2[1][i] = points[1][i]; + pointsS2[0][i] = pointsS[i]; + + pointsV2[1][i] = points[1][i]; + pointsV2[0][i] = pointsV[i]; + } + + system.setTemperature(system.getTC() + 0.001); + system.setPressure(system.getPC() + 0.001); + system.init(3); + + points2[0][ncr] = system.getTC(); + points2[1][ncr] = system.getPC(); + + pointsH2[1][ncr] = system.getPC(); + pointsH2[0][ncr] = system.getPhase(1).getEnthalpy() + / system.getPhase(1).getNumberOfMolesInPhase() / system.getPhase(1).getMolarMass() / 1e3; + + pointsS2[1][ncr] = system.getPC(); + pointsS2[0][ncr] = system.getPhase(1).getEntropy() + / system.getPhase(1).getNumberOfMolesInPhase() / system.getPhase(1).getMolarMass() / 1e3; + + pointsV2[1][ncr] = system.getPC(); + pointsV2[0][ncr] = system.getPhase(1).getDensity(); + + if (ncr2 > 2) { + points2[2][0] = system.getTC(); + points2[3][0] = system.getPC(); + pointsH2[3][0] = system.getPC(); + pointsH2[2][0] = + system.getPhase(1).getEnthalpy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3; + pointsS2[3][0] = system.getPC(); + pointsS2[2][0] = + system.getPhase(1).getEntropy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3; + pointsV2[3][0] = system.getPC(); + pointsV2[2][0] = system.getPhase(1).getDensity(); + + for (int i = 1; i < (ncr2 - 2); i++) { + points2[2][i] = points[0][i + ncr - 1]; + points2[3][i] = points[1][i + ncr - 1]; + + pointsH2[3][i] = points[1][i + ncr - 1]; + pointsH2[2][i] = pointsH[i + ncr - 1]; + + pointsS2[3][i] = points[1][i + ncr - 1]; + pointsS2[2][i] = pointsS[i + ncr - 1]; + + pointsV2[3][i] = points[1][i + ncr - 1]; + pointsV2[2][i] = pointsV[i + ncr - 1]; } + } + // monitor.close(); + mainFrame.setVisible(false); + /* + * if (outputToFile) { String name1 = new String(); name1 = fileName + "Dew.nc"; file1 = new + * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); + * file1.setOutputFileName(name1); file1.setXvalues(points2[2], "temp", "sec"); + * file1.setYvalues(points2[3], "pres", "meter"); file1.createFile(); + * + * String name2 = new String(); name2 = fileName + "Bub.nc"; file2 = new + * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); + * file2.setOutputFileName(name2); file2.setXvalues(points2[0], "temp", "sec"); + * file2.setYvalues(points2[1], "pres", "meter"); file2.createFile(); } + */ + } catch (Exception e) { + logger.error("error", e); } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - DecimalFormat nf = new DecimalFormat(); - nf.setMaximumFractionDigits(1); - nf.applyPattern("####.#"); - - double TC = system.getTC(); - double PC = system.getPC(); - logger.info("tc : " + TC + " PC : " + PC); - String[] navn = {"bubble point", "dew point", "bubble point", "dew point"}; - String title = "PT-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - String title3 = "PH-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - String title4 = "Density-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - String title5 = "PS-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" - + String.valueOf(nf.format(PC)); - - // logger.info("start flash"); - // logger.info("Tferdig.."); - - graph2b graph3 = new graph2b(pointsH2, navn, title3, "Enthalpy [kJ/kg]", "Pressure [bara]"); - graph3.setVisible(true); - graph3.saveFigure((neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig4.png")); - - graph2b graph4 = new graph2b(pointsV2, navn, title4, "Density [kg/m^3]", "Pressure [bara]"); - graph4.setVisible(true); - graph4.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig2.png"); - - graph2b graph5 = - new graph2b(pointsS2, navn, title5, "Entropy [kJ/kg*K]", "Pressure [bara]"); - graph5.setVisible(true); - graph5.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig3.png"); - - graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); - graph2.setVisible(true); - graph2.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig1.png"); - - /* - * JDialog dialog = new JDialog(); Container dialogContentPane = dialog.getContentPane(); - * dialogContentPane.setLayout(new FlowLayout()); JFreeChartPanel chartPanel = - * graph4.getChartPanel(); dialogContentPane.add(chartPanel); dialog.show(); - */ + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + DecimalFormat nf = new DecimalFormat(); + nf.setMaximumFractionDigits(1); + nf.applyPattern("####.#"); + + double TC = system.getTC(); + double PC = system.getPC(); + logger.info("tc : " + TC + " PC : " + PC); + String[] navn = {"bubble point", "dew point", "bubble point", "dew point"}; + String title = + "PT-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + String.valueOf(nf.format(PC)); + String title3 = + "PH-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + String.valueOf(nf.format(PC)); + String title4 = "Density-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + + String.valueOf(nf.format(PC)); + String title5 = + "PS-graph TC=" + String.valueOf(nf.format(TC)) + " PC=" + String.valueOf(nf.format(PC)); + + // logger.info("start flash"); + // logger.info("Tferdig.."); + + graph2b graph3 = new graph2b(pointsH2, navn, title3, "Enthalpy [kJ/kg]", "Pressure [bara]"); + graph3.setVisible(true); + graph3.saveFigure((neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig4.png")); + + graph2b graph4 = new graph2b(pointsV2, navn, title4, "Density [kg/m^3]", "Pressure [bara]"); + graph4.setVisible(true); + graph4.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig2.png"); + + graph2b graph5 = new graph2b(pointsS2, navn, title5, "Entropy [kJ/kg*K]", "Pressure [bara]"); + graph5.setVisible(true); + graph5.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig3.png"); + + graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); + graph2.setVisible(true); + graph2.saveFigure(neqsim.util.util.FileSystemSettings.tempDir + "NeqSimTempFig1.png"); + + /* + * JDialog dialog = new JDialog(); Container dialogContentPane = dialog.getContentPane(); + * dialogContentPane.setLayout(new FlowLayout()); JFreeChartPanel chartPanel = + * graph4.getChartPanel(); dialogContentPane.add(chartPanel); dialog.show(); + */ + } + + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} + + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + DecimalFormat nf = new DecimalFormat(); + nf.setMaximumFractionDigits(1); + nf.applyPattern("####.#"); + + double TC = system.getTC(); + double PC = system.getPC(); + logger.info("tc : " + TC + " PC : " + PC); + String[] navn = {"bubble point", "dew point", "bubble point", "dew point"}; + String title = "PT-graph. TC=" + String.valueOf(nf.format(TC)) + "K, PC=" + + String.valueOf(nf.format(PC) + " bara"); + graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); + return graph2.getChart(); + } + + /** {@inheritDoc} */ + @Override + public double[][] getPoints(int i) { + return points2; + } + + /** {@inheritDoc} */ + @Override + public double[] get(String name) { + if (name.equals("bubT")) { + return points2[0]; } - - /** {@inheritDoc} */ - @Override - public void printToFile(String name) {} - - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - DecimalFormat nf = new DecimalFormat(); - nf.setMaximumFractionDigits(1); - nf.applyPattern("####.#"); - - double TC = system.getTC(); - double PC = system.getPC(); - logger.info("tc : " + TC + " PC : " + PC); - String[] navn = {"bubble point", "dew point", "bubble point", "dew point"}; - String title = "PT-graph. TC=" + String.valueOf(nf.format(TC)) + "K, PC=" - + String.valueOf(nf.format(PC) + " bara"); - graph2 = new graph2b(points2, navn, title, "Temperature [K]", "Pressure [bara]"); - return graph2.getChart(); + if (name.equals("bubP")) { + return points2[1]; } - - /** {@inheritDoc} */ - @Override - public double[][] getPoints(int i) { - return points2; + if (name.equals("dewT")) { + return points2[2]; } - - /** {@inheritDoc} */ - @Override - public double[] get(String name) { - if (name.equals("bubT")) { - return points2[0]; - } - if (name.equals("bubP")) { - return points2[1]; - } - if (name.equals("dewT")) { - return points2[2]; - } - if (name.equals("dewP")) { - return points2[3]; - } - if (name.equals("dewH")) { - return pointsH2[2]; - } - if (name.equals("dewDens")) { - return pointsV2[2]; - } - if (name.equals("dewS")) { - return pointsS2[2]; - } - if (name.equals("bubH")) { - return pointsH2[0]; - } - if (name.equals("bubDens")) { - return pointsV2[0]; - } - if (name.equals("bubS")) { - return pointsS2[0]; - } - if (name.equals("cricondentherm")) { - return cricondenTherm; - } - if (name.equals("cricondenbar")) { - return cricondenBar; - } else { - return null; - } + if (name.equals("dewP")) { + return points2[3]; } - - /** {@inheritDoc} */ - @Override - public void createNetCdfFile(String name) { - fileName = name; + if (name.equals("dewH")) { + return pointsH2[2]; } - - /** {@inheritDoc} */ - @Override - public String[][] getResultTable() { - return null; + if (name.equals("dewDens")) { + return pointsV2[2]; + } + if (name.equals("dewS")) { + return pointsS2[2]; + } + if (name.equals("bubH")) { + return pointsH2[0]; + } + if (name.equals("bubDens")) { + return pointsV2[0]; } + if (name.equals("bubS")) { + return pointsS2[0]; + } + if (name.equals("cricondentherm")) { + return cricondenTherm; + } + if (name.equals("cricondenbar")) { + return cricondenBar; + } else { + return null; + } + } + + /** {@inheritDoc} */ + @Override + public String[][] getResultTable() { + return null; + } } diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/reactiveCurves/pLoadingCurve.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/reactiveCurves/pLoadingCurve.java index 00e94673ae..d09724c10b 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/reactiveCurves/pLoadingCurve.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/reactiveCurves/pLoadingCurve.java @@ -8,7 +8,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.dataPresentation.JFreeChart.graph2b; -import neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.OperationInterface; @@ -148,23 +147,6 @@ public double[][] getPoints(int i) { return points; } - /** {@inheritDoc} */ - @Override - public void createNetCdfFile(String name) { - NetCdf2D file = new NetCdf2D(); - file.setOutputFileName(name); - file.setXvalues(points[0], "loading", ""); - file.setYvalues(points[1], "pressure", ""); - for (int k = 0; k < system.getPhases()[1].getNumberOfComponents(); k++) { - file.setYvalues(points[k + 2], - "mol frac " + system.getPhases()[1].getComponents()[k].getComponentName(), ""); - file.setYvalues(points[k + 2 + system.getPhases()[1].getNumberOfComponents()], - ("activity " + system.getPhases()[1].getComponents()[k].getComponentName()), - ""); - } - file.createFile(); - } - /** {@inheritDoc} */ @Override public double[] get(String name) { diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/reactiveCurves/pLoadingCurve2.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/reactiveCurves/pLoadingCurve2.java index e1f2ff6a36..aa2372274b 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/reactiveCurves/pLoadingCurve2.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/reactiveCurves/pLoadingCurve2.java @@ -8,7 +8,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.dataPresentation.JFreeChart.graph2b; -import neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.BaseOperation; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -22,181 +21,173 @@ * @version $Id: $Id */ public class pLoadingCurve2 extends BaseOperation { - private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(pLoadingCurve2.class); - - SystemInterface system; - int i, j = 0, nummer = 0, iterations = 0, maxNumberOfIterations = 10000; - double gibbsEnergy = 0, gibbsEnergyOld = 0; - double Kold, deviation = 0, g0 = 0, g1 = 0; - double lnOldOldK[], lnK[]; - double lnOldK[]; - double oldDeltalnK[], deltalnK[]; - double tm[] = {1, 1}; - double beta = 1e-5; - int lowestGibbsEnergyPhase = 0; // lowestGibbsEnergyPhase - JProgressBar monitor; - JFrame mainFrame; - JPanel mainPanel; - - double temp = 0, pres = 0, startPres = 0; - double[][] points = new double[35][]; - - boolean moreLines = false; - int np = 0; - // points[2] = new double[1000]; - int speceq = 0; - - /** - *- * Constructor for pLoadingCurve2. - *
- */ - public pLoadingCurve2() {} - - /** - *- * Constructor for pLoadingCurve2. - *
- * - * @param system a {@link neqsim.thermo.system.SystemInterface} object - */ - public pLoadingCurve2(SystemInterface system) { - this.system = system; - lnOldOldK = new double[system.getPhases()[0].getNumberOfComponents()]; - lnOldK = new double[system.getPhases()[0].getNumberOfComponents()]; - lnK = new double[system.getPhases()[0].getNumberOfComponents()]; - oldDeltalnK = new double[system.getPhases()[0].getNumberOfComponents()]; - deltalnK = new double[system.getPhases()[0].getNumberOfComponents()]; - mainFrame = new JFrame("Progress Bar"); - mainPanel = new JPanel(); - mainPanel.setSize(200, 100); - mainFrame.getContentPane().setLayout(new FlowLayout()); - mainPanel.setLayout(new FlowLayout()); - mainFrame.setSize(200, 100); - monitor = new JProgressBar(0, 1000); - monitor.setSize(200, 100); - monitor.setStringPainted(true); - mainPanel.add(monitor); - mainFrame.getContentPane().add(mainPanel); - mainFrame.setVisible(true); + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(pLoadingCurve2.class); + + SystemInterface system; + int i, j = 0, nummer = 0, iterations = 0, maxNumberOfIterations = 10000; + double gibbsEnergy = 0, gibbsEnergyOld = 0; + double Kold, deviation = 0, g0 = 0, g1 = 0; + double lnOldOldK[], lnK[]; + double lnOldK[]; + double oldDeltalnK[], deltalnK[]; + double tm[] = {1, 1}; + double beta = 1e-5; + int lowestGibbsEnergyPhase = 0; // lowestGibbsEnergyPhase + JProgressBar monitor; + JFrame mainFrame; + JPanel mainPanel; + + double temp = 0, pres = 0, startPres = 0; + double[][] points = new double[35][]; + + boolean moreLines = false; + int np = 0; + // points[2] = new double[1000]; + int speceq = 0; + + /** + *+ * Constructor for pLoadingCurve2. + *
+ */ + public pLoadingCurve2() {} + + /** + *+ * Constructor for pLoadingCurve2. + *
+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + */ + public pLoadingCurve2(SystemInterface system) { + this.system = system; + lnOldOldK = new double[system.getPhases()[0].getNumberOfComponents()]; + lnOldK = new double[system.getPhases()[0].getNumberOfComponents()]; + lnK = new double[system.getPhases()[0].getNumberOfComponents()]; + oldDeltalnK = new double[system.getPhases()[0].getNumberOfComponents()]; + deltalnK = new double[system.getPhases()[0].getNumberOfComponents()]; + mainFrame = new JFrame("Progress Bar"); + mainPanel = new JPanel(); + mainPanel.setSize(200, 100); + mainFrame.getContentPane().setLayout(new FlowLayout()); + mainPanel.setLayout(new FlowLayout()); + mainFrame.setSize(200, 100); + monitor = new JProgressBar(0, 1000); + monitor.setSize(200, 100); + monitor.setStringPainted(true); + mainPanel.add(monitor); + mainFrame.getContentPane().add(mainPanel); + mainFrame.setVisible(true); + } + + /** {@inheritDoc} */ + @Override + public void run() { + int numbPoints = 50; + double inscr = 0.2103842275; + points[0] = new double[numbPoints]; + points[1] = new double[numbPoints]; + points[2] = new double[numbPoints]; + ThermodynamicOperations testOps = new ThermodynamicOperations(system); + + for (int k = 0; k < system.getPhases()[1].getNumberOfComponents(); k++) { + points[k + 3] = new double[numbPoints]; + points[k + 3 + system.getPhases()[1].getNumberOfComponents()] = new double[numbPoints]; } - /** {@inheritDoc} */ - @Override - public void run() { - int numbPoints = 50; - double inscr = 0.2103842275; - points[0] = new double[numbPoints]; - points[1] = new double[numbPoints]; - points[2] = new double[numbPoints]; - ThermodynamicOperations testOps = new ThermodynamicOperations(system); - - for (int k = 0; k < system.getPhases()[1].getNumberOfComponents(); k++) { - points[k + 3] = new double[numbPoints]; - points[k + 3 + system.getPhases()[1].getNumberOfComponents()] = new double[numbPoints]; - } - - double molMDEA = system.getPhases()[1].getComponents()[2].getNumberOfMolesInPhase(); - system.getChemicalReactionOperations().solveChemEq(1); - - for (int i = 1; i < points[0].length; i++) { - system.initBeta(); - system.init_x_y(); - try { - testOps.bubblePointPressureFlash(false); - } catch (Exception e) { - logger.info(e.toString()); - } - logger.info("beta " + system.getBeta()); - points[0][i] = (inscr * (i - 1)) / molMDEA; - points[1][i] = (system.getPressure()); - points[2][i] = (system.getPressure() * system.getPhase(0).getComponent(0).getx()); - - for (int k = 0; k < system.getPhases()[1].getNumberOfComponents(); k++) { - points[k + 3][i] = system.getPhases()[1].getComponents()[k].getx(); - points[k + 3 + system.getPhases()[1].getNumberOfComponents()][i] = - system.getPhase(1).getActivityCoefficient(k, 1);// ,1); - } - logger.info("point: " + points[0][i] + " tot pres " + points[1][i] + " CO2 pres " - + points[2][i]); - system.setPressure(points[1][i]); - logger.info("ph: " + system.getPhases()[1].getpH()); - system.addComponent("CO2", inscr); - } - mainFrame.setVisible(false); - } - - /** {@inheritDoc} */ - @Override - public void displayResult() { - DecimalFormat nf = new DecimalFormat(); - nf.setMaximumFractionDigits(1); - nf.applyPattern("####.#"); - - double TC = system.getTC(); - double PC = system.getPC(); - logger.info("tc : " + TC + " PC : " + PC); - String[] navn = {"CO2 fugacity", "", "", ""}; - String title = "CO2 vapour pressure"; - - graph2b graph2 = new graph2b(points, navn, title, "loading [-]", "Fugacity CO2 [bar]"); - graph2.setVisible(true); - } - - /** {@inheritDoc} */ - @Override - public void printToFile(String name) { - neqsim.dataPresentation.dataHandeling printDat = - new neqsim.dataPresentation.dataHandeling(); - printDat.printToFile(points, name); - } - - /** {@inheritDoc} */ - @Override - public double[][] getPoints(int i) { - return points; - } - - /** {@inheritDoc} */ - @Override - public void createNetCdfFile(String name) { - NetCdf2D file = new NetCdf2D(); - file.setOutputFileName(name); - file.setXvalues(points[0], "loading", ""); - file.setYvalues(points[1], "total pressure", ""); - file.setYvalues(points[2], " CO2 pressure", ""); - for (int k = 0; k < system.getPhases()[1].getNumberOfComponents(); k++) { - file.setYvalues(points[k + 3], - "mol frac " + system.getPhases()[1].getComponents()[k].getComponentName(), ""); - file.setYvalues(points[k + 3 + system.getPhases()[1].getNumberOfComponents()], - ("activity " + system.getPhases()[1].getComponents()[k].getComponentName()), - ""); - } - file.createFile(); - } - - /** {@inheritDoc} */ - @Override - public double[] get(String name) { - return null; - } - - /** {@inheritDoc} */ - @Override - public org.jfree.chart.JFreeChart getJFreeChart(String name) { - return null; - } - - /** {@inheritDoc} */ - @Override - public String[][] getResultTable() { - return null; - } - - /** {@inheritDoc} */ - @Override - public SystemInterface getThermoSystem() { - return system; + double molMDEA = system.getPhases()[1].getComponents()[2].getNumberOfMolesInPhase(); + system.getChemicalReactionOperations().solveChemEq(1); + + for (int i = 1; i < points[0].length; i++) { + system.initBeta(); + system.init_x_y(); + try { + testOps.bubblePointPressureFlash(false); + } catch (Exception e) { + logger.info(e.toString()); + } + logger.info("beta " + system.getBeta()); + points[0][i] = (inscr * (i - 1)) / molMDEA; + points[1][i] = (system.getPressure()); + points[2][i] = (system.getPressure() * system.getPhase(0).getComponent(0).getx()); + + for (int k = 0; k < system.getPhases()[1].getNumberOfComponents(); k++) { + points[k + 3][i] = system.getPhases()[1].getComponents()[k].getx(); + points[k + 3 + system.getPhases()[1].getNumberOfComponents()][i] = + system.getPhase(1).getActivityCoefficient(k, 1);// ,1); + } + logger.info( + "point: " + points[0][i] + " tot pres " + points[1][i] + " CO2 pres " + points[2][i]); + system.setPressure(points[1][i]); + logger.info("ph: " + system.getPhases()[1].getpH()); + system.addComponent("CO2", inscr); } + mainFrame.setVisible(false); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + DecimalFormat nf = new DecimalFormat(); + nf.setMaximumFractionDigits(1); + nf.applyPattern("####.#"); + + double TC = system.getTC(); + double PC = system.getPC(); + logger.info("tc : " + TC + " PC : " + PC); + String[] navn = {"CO2 fugacity", "", "", ""}; + String title = "CO2 vapour pressure"; + + graph2b graph2 = new graph2b(points, navn, title, "loading [-]", "Fugacity CO2 [bar]"); + graph2.setVisible(true); + } + + /** {@inheritDoc} */ + @Override + public void printToFile(String name) { + neqsim.dataPresentation.dataHandeling printDat = new neqsim.dataPresentation.dataHandeling(); + printDat.printToFile(points, name); + } + + /** {@inheritDoc} */ + @Override + public double[][] getPoints(int i) { + return points; + } + + /* + * public void createNetCdfFile(String name) { NetCdf2D file = new NetCdf2D(); + * file.setOutputFileName(name); file.setXvalues(points[0], "loading", ""); + * file.setYvalues(points[1], "total pressure", ""); file.setYvalues(points[2], " CO2 pressure", + * ""); for (int k = 0; k < system.getPhases()[1].getNumberOfComponents(); k++) { + * file.setYvalues(points[k + 3], "mol frac " + + * system.getPhases()[1].getComponents()[k].getComponentName(), ""); file.setYvalues(points[k + 3 + * + system.getPhases()[1].getNumberOfComponents()], ("activity " + + * system.getPhases()[1].getComponents()[k].getComponentName()), ""); } file.createFile(); } + */ + + /** {@inheritDoc} */ + @Override + public double[] get(String name) { + return null; + } + + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + return null; + } + + /** {@inheritDoc} */ + @Override + public String[][] getResultTable() { + return null; + } + + /** {@inheritDoc} */ + @Override + public SystemInterface getThermoSystem() { + return system; + } } diff --git a/src/main/java/neqsim/util/NamedBaseClass.java b/src/main/java/neqsim/util/NamedBaseClass.java index 7f8e501103..8bb97a43bf 100644 --- a/src/main/java/neqsim/util/NamedBaseClass.java +++ b/src/main/java/neqsim/util/NamedBaseClass.java @@ -11,7 +11,7 @@ public abstract class NamedBaseClass implements NamedInterface, java.io.Serializ /** * Constructor for NamedBaseClass * - * @param name + * @param name the name of the class */ public NamedBaseClass(String name) { this.name = name; diff --git a/src/test/java/neqsim/NeqSimTest.java b/src/test/java/neqsim/NeqSimTest.java index e303d5776d..c7e802b7e0 100644 --- a/src/test/java/neqsim/NeqSimTest.java +++ b/src/test/java/neqsim/NeqSimTest.java @@ -1,17 +1,12 @@ -/** - * - */ package neqsim; -import org.junit.jupiter.api.BeforeAll; - /** * @author ESOL * */ public class NeqSimTest { public NeqSimTest() { - //Setting NeqSim to use test parameter database + // Setting NeqSim to use test parameter database neqsim.util.database.NeqSimDataBase .setConnectionString("jdbc:derby:classpath:data/neqsimtestdatabase"); } diff --git a/src/test/java/neqsim/fluidMechanics/flowSystem/onePhaseFlowSystem/pipeFlowSystem/PipeFlowSystemTest.java b/src/test/java/neqsim/fluidMechanics/flowSystem/onePhaseFlowSystem/pipeFlowSystem/PipeFlowSystemTest.java index cffefc00a8..8cc0da7b39 100644 --- a/src/test/java/neqsim/fluidMechanics/flowSystem/onePhaseFlowSystem/pipeFlowSystem/PipeFlowSystemTest.java +++ b/src/test/java/neqsim/fluidMechanics/flowSystem/onePhaseFlowSystem/pipeFlowSystem/PipeFlowSystemTest.java @@ -1,118 +1,130 @@ package neqsim.fluidMechanics.flowSystem.onePhaseFlowSystem.pipeFlowSystem; import java.util.Arrays; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; - import neqsim.fluidMechanics.flowSystem.FlowSystemInterface; import neqsim.thermo.system.SystemInterface; - -public class PipeFlowSystemTest extends neqsim.NeqSimTest{ - FlowSystemInterface pipe; - - @BeforeEach - void setUp() { - pipe = new PipeFlowSystem(); - - SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos(285.15, 200.0); - testSystem.addComponent("methane", 0.9); - testSystem.addComponent("ethane", 0.1); - testSystem.createDatabase(true); - testSystem.init(0); - testSystem.init(3); - testSystem.initPhysicalProperties(); - testSystem.setTotalFlowRate(60.0, "MSm3/day"); - - double[] height = { 0, 0, 0 }; // , 0, 0, 0, 0, 0, 0, 0, 0}; - double[] diameter = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}; - double[] roughness = {1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, - 1.0e-5, 1.0e-5, 1.0e-5}; - double[] outHeatCoef = {5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0}; - double[] wallHeacCoef = {15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0}; - - double[] length = - {0, 10000, 50000, 150000, 200000, 400000, 500000, 600000, 650000, 700000, 750000}; - double[] outerTemperature = - {278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0}; - - neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface[] pipeGeometry = - new neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData[height.length]; - - for (int i = 0; i < height.length; i++) { - pipeGeometry[i] = new neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData(); - pipeGeometry[i].setDiameter(diameter[i]); - pipeGeometry[i].setInnerSurfaceRoughness(roughness[i]); - } - pipe.setInletThermoSystem(testSystem); - pipe.setNumberOfLegs(height.length - 1); - pipe.setNumberOfNodesInLeg(20); - pipe.setEquipmentGeometry(pipeGeometry); - pipe.setLegHeights(height); - pipe.setLegPositions(Arrays.copyOfRange(length, 0, height.length)); - pipe.setLegOuterTemperatures(Arrays.copyOfRange(outerTemperature, 0, height.length)); - pipe.setLegWallHeatTransferCoefficients(Arrays.copyOfRange(wallHeacCoef, 0, height.length)); - pipe.setLegOuterHeatTransferCoefficients(Arrays.copyOfRange(outHeatCoef, 0, height.length)); - } - - - @Test - void testCreateSystem() { - pipe.createSystem(); +public class PipeFlowSystemTest extends neqsim.NeqSimTest { + FlowSystemInterface pipe; + + @BeforeEach + void setUp() { + pipe = new PipeFlowSystem(); + + SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos(285.15, 200.0); + testSystem.addComponent("methane", 0.9); + testSystem.addComponent("ethane", 0.1); + testSystem.createDatabase(true); + testSystem.init(0); + testSystem.init(3); + testSystem.initPhysicalProperties(); + testSystem.setTotalFlowRate(60.0, "MSm3/day"); + + double[] height = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + double[] diameter = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}; + double[] roughness = + {1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5}; + double[] outHeatCoef = {5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0}; + double[] wallHeacCoef = {15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0}; + + double[] length = + {0, 10000, 50000, 150000, 200000, 400000, 500000, 600000, 650000, 700000, 740000}; + double[] outerTemperature = + {278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0}; + + neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface[] pipeGeometry = + new neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData[height.length]; + + for (int i = 0; i < height.length; i++) { + pipeGeometry[i] = new neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData(); + pipeGeometry[i].setDiameter(diameter[i]); + pipeGeometry[i].setInnerSurfaceRoughness(roughness[i]); } - - @Test - void testInit() { - testCreateSystem(); - pipe.init(); + pipe.setInletThermoSystem(testSystem); + pipe.setNumberOfLegs(height.length - 1); + pipe.setNumberOfNodesInLeg(20); + pipe.setEquipmentGeometry(pipeGeometry); + pipe.setLegHeights(height); + pipe.setLegPositions(Arrays.copyOfRange(length, 0, height.length)); + pipe.setLegOuterTemperatures(Arrays.copyOfRange(outerTemperature, 0, height.length)); + pipe.setLegWallHeatTransferCoefficients(Arrays.copyOfRange(wallHeacCoef, 0, height.length)); + pipe.setLegOuterHeatTransferCoefficients(Arrays.copyOfRange(outHeatCoef, 0, height.length)); + } + + @Test + void testCreateSystem() { + pipe.createSystem(); + } + + @Test + void testInit() { + testCreateSystem(); + pipe.init(); + } + + @Test + void testSolveSteadyStateConstantFrictionFactor() { + testInit(); + for (int i = 0; i < pipe.getFlowNodes().length; i++) { + pipe.getNode(i).setWallFrictionFactor(0, 0.00725); } - - @Test - void testSolveSteadyState() { - testInit(); - pipe.solveSteadyState(10); - // pipe.print(); + pipe.solveSteadyState(10); + // System.out.println("pressure out set friction " + } + + @Test + void testSolveSteadyState() { + testInit(); + pipe.solveSteadyState(10); + for (int i = 0; i < pipe.getFlowNodes().length; i++) { + // System.out.println("wall friction " + pipe.getNode(i).getWallFrictionFactor(0)); } - @Test - void testSolveTransient() { - testInit(); - // transient solver - double[] times = {0, 10000, 20000};// , 30000, 40000, 50000};//, 60000, 70000, 80000, - // 90000}; - pipe.getTimeSeries().setTimes(times); - - SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos(285.15, 200.0); - testSystem.addComponent("methane", 0.9); - testSystem.addComponent("ethane", 0.1); - - SystemInterface testSystem2 = new neqsim.thermo.system.SystemSrkEos(315.15, 200.0); - testSystem2.addComponent("methane", 26000.0); - testSystem2.addComponent("ethane", 1.10); - testSystem2.init(0); - testSystem2.init(3); - testSystem2.initPhysicalProperties(); - - SystemInterface testSystem3 = new neqsim.thermo.system.SystemSrkEos(285.15, 200.0); - testSystem3.addComponent("methane", 29000.0); - testSystem3.addComponent("ethane", 1221.10); - testSystem3.init(0); - - SystemInterface[] systems = {testSystem, testSystem2, testSystem2};// , testSystem2, - // testSystem2, - // testSystem2};//,testSystem2,testSystem2,testSystem2,testSystem2,testSystem2}; - pipe.getTimeSeries().setInletThermoSystems(systems); - pipe.getTimeSeries().setNumberOfTimeStepsInInterval(10); - // double[] outletFlowRates = {0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, - // 0.01, 0.01, 0.01}; - // pipe.getTimeSeries().setOutletMolarFlowRate(outletFlowRates); - - // pipe.solveTransient(20); - // pipe.getDisplay().displayResult("composition"); - // pipe.getDisplay().displayResult("pressure"); - // pipe.getDisplay().displayResult("composition"); - // pipe.getDisplay().createNetCdfFile("c:/temp5.nc"); - // pipe.getDisplay(1).displayResult(); - } + // System.out.println("pressure out calc friction " + // + pipe.getNode(pipe.getFlowNodes().length - 1).getBulkSystem().getPressure() + " bara"); + + // pipe.print(); + } + + @Test + void testSolveTransient() { + testInit(); + // transient solver + double[] times = {0, 10000, 20000};// , 30000, 40000, 50000};//, 60000, 70000, 80000, + // 90000}; + pipe.getTimeSeries().setTimes(times); + + SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos(285.15, 200.0); + testSystem.addComponent("methane", 0.9); + testSystem.addComponent("ethane", 0.1); + + SystemInterface testSystem2 = new neqsim.thermo.system.SystemSrkEos(315.15, 200.0); + testSystem2.addComponent("methane", 26000.0); + testSystem2.addComponent("ethane", 1.10); + testSystem2.init(0); + testSystem2.init(3); + testSystem2.initPhysicalProperties(); + + SystemInterface testSystem3 = new neqsim.thermo.system.SystemSrkEos(285.15, 200.0); + testSystem3.addComponent("methane", 29000.0); + testSystem3.addComponent("ethane", 1221.10); + testSystem3.init(0); + + SystemInterface[] systems = {testSystem, testSystem2, testSystem2};// , testSystem2, + // testSystem2, + // testSystem2};//,testSystem2,testSystem2,testSystem2,testSystem2,testSystem2}; + pipe.getTimeSeries().setInletThermoSystems(systems); + pipe.getTimeSeries().setNumberOfTimeStepsInInterval(10); + // double[] outletFlowRates = {0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, + // 0.01, 0.01, 0.01}; + // pipe.getTimeSeries().setOutletMolarFlowRate(outletFlowRates); + + // pipe.solveTransient(20); + // pipe.getDisplay().displayResult("composition"); + // pipe.getDisplay().displayResult("pressure"); + // pipe.getDisplay().displayResult("composition"); + // pipe.getDisplay(1).displayResult(); + } } diff --git a/src/test/java/neqsim/fluidMechanics/util/example/WettedWall_CO2_water.java b/src/test/java/neqsim/fluidMechanics/util/example/WettedWall_CO2_water.java index 2c2dcf4b88..695fbd48b5 100644 --- a/src/test/java/neqsim/fluidMechanics/util/example/WettedWall_CO2_water.java +++ b/src/test/java/neqsim/fluidMechanics/util/example/WettedWall_CO2_water.java @@ -1,6 +1,5 @@ package neqsim.fluidMechanics.util.example; -import org.junit.jupiter.api.BeforeAll; import neqsim.processSimulation.processEquipment.pipeline.Pipeline; import neqsim.processSimulation.processEquipment.pipeline.TwoPhasePipeLine; import neqsim.processSimulation.processEquipment.stream.NeqStream; @@ -18,7 +17,7 @@ * @version $Id: $Id * @since 2.2.3 */ -public class WettedWall_CO2_water extends neqsim.NeqSimTest{ +public class WettedWall_CO2_water extends neqsim.NeqSimTest { /** * This method is just meant to test the thermo package. diff --git a/src/test/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/density/CostaldTest.java b/src/test/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/density/CostaldTest.java new file mode 100644 index 0000000000..8b2e8687f7 --- /dev/null +++ b/src/test/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/density/CostaldTest.java @@ -0,0 +1,29 @@ +package neqsim.physicalProperties.physicalPropertyMethods.liquidPhysicalProperties.density; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +public class CostaldTest { + + static neqsim.thermo.system.SystemInterface testSystem = null; + + @BeforeAll + public static void setUp() { + testSystem = new neqsim.thermo.system.SystemSrkEos(344.26, 689.47); + testSystem.addComponent("ethane", 70.0); + testSystem.addComponent("nC10", 30.0); + testSystem.setMixingRule("classic"); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + } + + @Test + void testCalcDensity() { + testSystem.getPhase("oil").getPhysicalProperties().setDensityModel("Costald"); + double costaldDensity = testSystem.getPhase("oil").getPhysicalProperties().calcDensity(); + double costaldVolume = costaldDensity; + assertEquals(628.6198, costaldVolume, 1e-3); + } +} diff --git a/src/test/java/neqsim/physicalProperties/util/examples/TestSurfaceTension2.java b/src/test/java/neqsim/physicalProperties/util/examples/TestSurfaceTension2.java index 63f88c9dfb..7f03d5ad6d 100644 --- a/src/test/java/neqsim/physicalProperties/util/examples/TestSurfaceTension2.java +++ b/src/test/java/neqsim/physicalProperties/util/examples/TestSurfaceTension2.java @@ -15,11 +15,12 @@ public class TestSurfaceTension2 { // John debug /** - *main.
+ *+ * main. + *
* * @param args an array of {@link java.lang.String} objects */ - @SuppressWarnings("unused") public static void main(String args[]) { int gtmethod = 1; // 2; John changed diff --git a/src/test/java/neqsim/processSimulation/measurementDevice/WellAllocatorTest.java b/src/test/java/neqsim/processSimulation/measurementDevice/WellAllocatorTest.java index 38b4396fe4..cb925ffaaf 100644 --- a/src/test/java/neqsim/processSimulation/measurementDevice/WellAllocatorTest.java +++ b/src/test/java/neqsim/processSimulation/measurementDevice/WellAllocatorTest.java @@ -1,9 +1,5 @@ -/** - * - */ package neqsim.processSimulation.measurementDevice; -import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import neqsim.processSimulation.processEquipment.separator.Separator; @@ -16,7 +12,7 @@ * @author ESOL * */ -class WellAllocatorTest extends neqsim.NeqSimTest{ +class WellAllocatorTest extends neqsim.NeqSimTest { /** * @throws java.lang.Exception @@ -25,7 +21,8 @@ class WellAllocatorTest extends neqsim.NeqSimTest{ static void setUpBeforeClass() throws Exception {} /** - * Test method for {@link neqsim.processSimulation.measurementDevice.WellAllocator#getMeasuredValue(java.lang.String)}. + * Test method for + * {@link neqsim.processSimulation.measurementDevice.WellAllocator#getMeasuredValue(java.lang.String)}. */ @Test void testGetMeasuredValueString() { @@ -43,23 +40,21 @@ void testGetMeasuredValueString() { testFluid.setMixingRule(2); testFluid.addToComponentNames("_well1"); - + testFluid.setTemperature(24.0, "C"); testFluid.setPressure(48.0, "bara"); testFluid.setTotalFlowRate(2500.0, "kg/hr"); - - - SystemInterface testFluid2 = testFluid.clone(); + SystemInterface testFluid2 = testFluid.clone(); testFluid.setTemperature(24.0, "C"); testFluid.setPressure(48.0, "bara"); testFluid.setTotalFlowRate(2500.0, "kg/hr"); Stream stream_1 = new Stream("Stream1", testFluid); - + Stream stream_2 = new Stream("Stream2", testFluid2); - + Separator sep1 = new Separator("sep1", stream_1); sep1.addStream(stream_2); @@ -80,15 +75,15 @@ void testGetMeasuredValueString() { operations.add(stream_oilExp); operations.add(wellAlloc); operations.run(); - + WellAllocatorResponse responsAl = new WellAllocatorResponse(wellAlloc); - + System.out.println("name " + responsAl.name); System.out.println("gas flow " + responsAl.gasExportRate); System.out.println("oil flow " + responsAl.oilExportRate); System.out.println("total flow " + responsAl.totalExportRate); - // stream_1.displayResult(); - // stream_1.displayResult(); + // stream_1.displayResult(); + // stream_1.displayResult(); } } diff --git a/src/test/java/neqsim/processSimulation/measurementDevice/pHProbeTest.java b/src/test/java/neqsim/processSimulation/measurementDevice/pHProbeTest.java new file mode 100644 index 0000000000..3e8741b2bc --- /dev/null +++ b/src/test/java/neqsim/processSimulation/measurementDevice/pHProbeTest.java @@ -0,0 +1,78 @@ +package neqsim.processSimulation.measurementDevice; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import neqsim.processSimulation.processEquipment.stream.Stream; +import neqsim.thermo.system.SystemInterface; +import neqsim.thermo.system.SystemSrkCPAstatoil; + +class pHProbeTest { + + @BeforeAll + static void setUpBeforeClass() throws Exception {} + + @Test + void testGetMeasuredValue() { + SystemInterface testFluid = new SystemSrkCPAstatoil(318.15, 50.0); + testFluid.addComponent("nitrogen", 1.205); + testFluid.addComponent("CO2", 1.340); + testFluid.addComponent("methane", 87.974); + testFluid.addComponent("ethane", 5.258); + testFluid.addComponent("propane", 3.283); + testFluid.addComponent("i-butane", 0.082); + testFluid.addComponent("n-butane", 0.487); + testFluid.addComponent("i-pentane", 0.056); + testFluid.addComponent("n-pentane", 1.053); + testFluid.addComponent("nC10", 14.053); + testFluid.addComponent("water", 141.053); + testFluid.setMixingRule(10); + testFluid.setMultiPhaseCheck(true); + + Stream stream_1 = new Stream("Stream1", testFluid); + stream_1.run(); + + pHProbe phmeasurement = new pHProbe(stream_1); + phmeasurement.run(); + System.out.println("pH " + phmeasurement.getMeasuredValue()); + assertEquals(4.079098133484792, phmeasurement.getMeasuredValue(),0.01); + } + + @Test + void testGetMeasuredValueWithAlkanility() { + SystemInterface testFluid = new SystemSrkCPAstatoil(318.15, 50.0); + testFluid.addComponent("nitrogen", 1.205); + testFluid.addComponent("CO2", 1.340); + testFluid.addComponent("methane", 87.974); + testFluid.addComponent("ethane", 5.258); + testFluid.addComponent("propane", 3.283); + testFluid.addComponent("i-butane", 0.082); + testFluid.addComponent("n-butane", 0.487); + testFluid.addComponent("i-pentane", 0.056); + testFluid.addComponent("n-pentane", 1.053); + testFluid.addComponent("nC10", 14.053); + testFluid.addComponent("water", 141.053); + testFluid.setMixingRule(10); + testFluid.setMultiPhaseCheck(true); + + Stream stream_1 = new Stream("Stream1", testFluid); + stream_1.run(); + + pHProbe phmeasurement = new pHProbe(stream_1); + phmeasurement.setAlkanility(50.0); + phmeasurement.run(); + System.out.println("pH " + phmeasurement.getMeasuredValue()); + assertEquals(5.629055432357595, phmeasurement.getMeasuredValue(),0.01); + } + + @Test + void testPHProbe() { + //fail("Not yet implemented"); + } + + @Test + void testPHProbeStreamInterface() { + //fail("Not yet implemented"); + } + +} diff --git a/src/test/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartTest.java b/src/test/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartTest.java new file mode 100644 index 0000000000..8f2fb0fb01 --- /dev/null +++ b/src/test/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartTest.java @@ -0,0 +1,161 @@ +package neqsim.processSimulation.processEquipment.compressor; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import neqsim.processSimulation.processEquipment.stream.Stream; +import neqsim.thermo.system.SystemInterface; +import neqsim.thermo.system.SystemSrkEos; + +public class CompressorChartTest { + public Compressor comp1; + + @BeforeEach + public void setUp() { + + SystemInterface testFluid = new SystemSrkEos(298.15, 50.0); + + // testFluid.addComponent("methane", 1.0); + // testFluid.setMixingRule(2); + // testFluid.setTotalFlowRate(0.635, "MSm3/day"); + + testFluid.addComponent("nitrogen", 1.205); + testFluid.addComponent("CO2", 1.340); + testFluid.addComponent("methane", 87.974); + testFluid.addComponent("ethane", 5.258); + testFluid.addComponent("propane", 3.283); + testFluid.addComponent("i-butane", 0.082); + testFluid.addComponent("n-butane", 0.487); + testFluid.addComponent("i-pentane", 0.056); + testFluid.addComponent("n-pentane", 0.053); + testFluid.setMixingRule(2); + testFluid.setMultiPhaseCheck(true); + + testFluid.setTemperature(24.0, "C"); + testFluid.setPressure(48.0, "bara"); + testFluid.setTotalFlowRate(1.0, "MSm3/day"); + + Stream stream_1 = new Stream("Stream1", testFluid); + comp1 = new Compressor("cmp1", stream_1); + comp1.setUsePolytropicCalc(true); + // comp1.getAntiSurge().setActive(true); + comp1.setSpeed(11918); + + double[] chartConditions = new double[] {0.3, 1.0, 1.0, 1.0}; + // double[] speed = new double[] { 1000.0, 2000.0, 3000.0, 4000.0 }; + // double[][] flow = new double[][] { { 453.2, 600.0, 750.0, 800.0 }, { 453.2, + // 600.0, 750.0, 800.0 + // }, { 453.2, 600.0, 750.0, 800.0 }, { 453.2, 600.0, 750.0, 800.0 } }; + // double[][] head = new double[][] { { 10000.0, 9000.0, 8000.0, 7500.0 }, { + // 10000.0, 9000.0, 8000.0, 7500.0 }, { 10000.0, 9000.0, 8000.0, 7500.0 }, { + // 10000.0, 9000.0, 8000.0, 7500.0 } }; + // double[][] polyEff = new double[][] { { + // 90.0, 91.0, 89.0, 88.0 }, { 90.0, 91.0, 89.0, 88.0 }, { 90.0, 91.0, 89.0, + // 88.1 }, { 90.0, 91.0, 89.0, 88.1 } }; + + double[] speed = new double[] {12913, 12298, 11683, 11098, 10453, 9224, 8609, 8200}; + double[][] flow = new double[][] { + {2789.1285, 3174.0375, 3689.2288, 4179.4503, 4570.2768, 4954.7728, 5246.0329, 5661.0331}, + {2571.1753, 2943.7254, 3440.2675, 3837.4448, 4253.0898, 4668.6643, 4997.1926, 5387.4952}, + {2415.3793, 2763.0706, 3141.7095, 3594.7436, 4047.6467, 4494.1889, 4853.7353, 5138.7858}, + {2247.2043, 2799.7342, 3178.3428, 3656.1551, 4102.778, 4394.1591, 4648.3224, 4840.4998}, + {2072.8397, 2463.9483, 2836.4078, 3202.5266, 3599.6333, 3978.0203, 4257.0022, 4517.345}, + {1835.9552, 2208.455, 2618.1322, 2940.8034, 3244.7852, 3530.1279, 3753.3738, 3895.9746}, + {1711.3386, 1965.8848, 2356.9431, 2685.9247, 3008.5154, 3337.2855, 3591.5092}, + {1636.5807, 2002.8708, 2338.0319, 2642.1245, 2896.4894, 3113.6264, 3274.8764, 3411.2977}}; + double[][] head = + new double[][] {{80.0375, 78.8934, 76.2142, 71.8678, 67.0062, 60.6061, 53.0499, 39.728}, + {72.2122, 71.8369, 68.9009, 65.8341, 60.7167, 54.702, 47.2749, 35.7471}, + {65.1576, 64.5253, 62.6118, 59.1619, 54.0455, 47.0059, 39.195, 31.6387}, + {58.6154, 56.9627, 54.6647, 50.4462, 44.4322, 38.4144, 32.9084, 28.8109}, + {52.3295, 51.0573, 49.5283, 46.3326, 42.3685, 37.2502, 31.4884, 25.598}, + {40.6578, 39.6416, 37.6008, 34.6603, 30.9503, 27.1116, 23.2713, 20.4546}, + {35.2705, 34.6359, 32.7228, 31.0645, 27.0985, 22.7482, 18.0113}, + {32.192, 31.1756, 29.1329, 26.833, 23.8909, 21.3324, 18.7726, 16.3403},}; + double[][] polyEff = new double[][] { + {77.2452238409573, 79.4154186459363, 80.737960012489, 80.5229826589649, 79.2210931638144, + 75.4719133864634, 69.6034181197298, 58.7322388482707}, + {77.0107837113504, 79.3069974136389, 80.8941189021135, 80.7190194665918, 79.5313242980328, + 75.5912622896367, 69.6846136362097, 60.0043057990909}, + {77.0043065299874, 79.1690958847856, 80.8038169975675, 80.6543975614197, 78.8532389102705, + 73.6664774270613, 66.2735600426727, 57.671664571658}, + {77.0716623789093, 80.4629750233093, 81.1390811169072, 79.6374242667478, 75.380928428817, + 69.5332969549779, 63.7997587622339, 58.8120614497758}, + {76.9705872525642, 79.8335492585324, 80.9468133671171, 80.5806471927835, 78.0462158225426, + 73.0403707523258, 66.5572286338589, 59.8624822515064}, + {77.5063036680357, 80.2056198362559, 81.0339108025933, 79.6085962687939, 76.3814534404405, + 70.8027503005902, 64.6437367160571, 60.5299349982342}, + {77.8175271586685, 80.065165942218, 81.0631362122632, 79.8955051771299, 76.1983240929369, + 69.289982774309, 60.8567149372229}, + {78.0924334304045, 80.9353551568667, 80.7904437766234, 78.8639325223295, 75.2170936751143, + 70.3105081673411, 65.5507568533569, 61.0391468300337}}; + + // double[] chartConditions = new double[] { 0.3, 1.0, 1.0, 1.0 }; + // double[] speed = new double[] { 13402.0 }; + // double[][] flow = new double[][] { { 1050.0, 1260.0, 1650.0, 1950.0 } }; + // double[][] head = new double[][] { { 8555.0, 8227.0, 6918.0, 5223.0 } }; + // double[][] head = new double[][] { { 85.0, 82.0, 69.0, 52.0 } }; + // double[][] polyEff = new double[][] { { 66.8, 69.0, 66.4, 55.6 } }; + comp1.getCompressorChart().setCurves(chartConditions, speed, flow, head, polyEff); + comp1.getCompressorChart().setHeadUnit("kJ/kg"); + + double[] surgeflow = new double[] {2789.0, 2550.0, 2500.0, 2200.0}; + double[] surgehead = new double[] {80.0, 72.0, 70.0, 65.0}; + comp1.getCompressorChart().getSurgeCurve().setCurve(chartConditions, surgeflow, surgehead); + // comp1.getAntiSurge().setActive(true); + comp1.getAntiSurge().setSurgeControlFactor(1.0); + /* + * double[] surgeflow = new double[] { 453.2, 550.0, 700.0, 800.0 }; double[] surgehead = new + * double[] { 6000.0, 7000.0, 8000.0, 10000.0 }; + * comp1.getCompressorChart().getSurgeCurve().setCurve(chartConditions, surgeflow, surgehead) + * double[] stoneWallflow = new double[] { 923.2, 950.0, 980.0, 1000.0 }; double[] stoneWallHead + * = new double[] { 6000.0, 7000.0, 8000.0, 10000.0 }; + * comp1.getCompressorChart().getStoneWallCurve().setCurve(chartConditions, stoneWallflow, + * stoneWallHead); + */ + } + + @Test + public void test_Run() { + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + Stream stream_1 = (Stream) comp1.getInletStream(); + operations.add(stream_1); + operations.add(comp1); + operations.run(); + // operations.displayResult(); + + /* + * System.out.println("power " + comp1.getPower()); System.out.println("is surge " + + * comp1.getAntiSurge().isSurge()); System.out .println("fraction in anti surge line " + + * comp1.getAntiSurge().getCurrentSurgeFraction()); + * System.out.println("Polytropic head from curve:" + comp1.getPolytropicHead()); + * System.out.println("Polytropic eff from curve:" + comp1.getPolytropicEfficiency() * 100.0); + * System.out.println("flow " + stream_1.getThermoSystem().getFlowRate("m3/hr")); + * + * System.out.println("speed " + comp1.getCompressorChart().getSpeed( + * stream_1.getThermoSystem().getFlowRate("m3/hr") + 10.0, comp1.getPolytropicHead())); + * System.out.println("pressure out " + comp1.getOutletPressure()); + * System.out.println("temperature out " + (comp1.getOutTemperature() - 273.15) + " C"); + */ + + double temperatureOut = 273.15 + 84; + comp1.setOutletPressure(96.0); + comp1.setOutTemperature(temperatureOut); + operations.run(); + double polytropicHead = comp1.getPolytropicHead(); + double flowRate = stream_1.getThermoSystem().getFlowRate("m3/hr"); + double calcSpeed = comp1.getCompressorChart().getSpeed(flowRate, polytropicHead); + + assertTrue(calcSpeed > 0); + /* + * System.out.println("polytopic head " + polytropicHead); + * System.out.println("polytopic efficiency " + comp1.getPolytropicEfficiency()); + * System.out.println("temperature out " + (comp1.getOutTemperature() - 273.15) + " C"); + * System.out.println("calculated speed " + calcSpeed); System.out.println("power " + + * comp1.getPower()); + */ + + // comp1.getCompressorChart().plot(); + } +} diff --git a/src/test/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchangerTest.java b/src/test/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchangerTest.java index 4f371b95b8..24c0fcead4 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchangerTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchangerTest.java @@ -51,7 +51,7 @@ public static void test_Run1(String args[]) { valv1.setOutletPressure(5.0); Recycle resyc = new Recycle("resyc"); - resyc.addStream(valv1.getOutStream()); + resyc.addStream(valv1.getOutletStream()); resyc.setOutletStream(stream_Cold); neqsim.processSimulation.processSystem.ProcessSystem operations = diff --git a/src/test/java/neqsim/processSimulation/processEquipment/mixer/MixerTest.java b/src/test/java/neqsim/processSimulation/processEquipment/mixer/MixerTest.java index 0912538e65..0485747fc1 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/mixer/MixerTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/mixer/MixerTest.java @@ -56,6 +56,7 @@ void testRun() { testMixer.addStream(gasStream); testMixer.addStream(waterStream); testMixer.run(); - assertEquals(testMixer.getOutStream().getFluid().getEnthalpy("kJ/kg"),-177.27666625251516, 1e-3); + assertEquals(testMixer.getOutletStream().getFluid().getEnthalpy("kJ/kg"), -177.27666625251516, + 1e-3); } } diff --git a/src/test/java/neqsim/processSimulation/processEquipment/separator/SeparatorTest.java b/src/test/java/neqsim/processSimulation/processEquipment/separator/SeparatorTest.java new file mode 100644 index 0000000000..c3206ced21 --- /dev/null +++ b/src/test/java/neqsim/processSimulation/processEquipment/separator/SeparatorTest.java @@ -0,0 +1,69 @@ +package neqsim.processSimulation.processEquipment.separator; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import neqsim.processSimulation.processEquipment.stream.Stream; +import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.processSimulation.processSystem.ProcessSystem; +import neqsim.thermo.system.SystemSrkCPAstatoil; + +/** + * @author ESOL + * + */ +class SeparatorTest extends neqsim.NeqSimTest { + static neqsim.thermo.system.SystemInterface testSystem = null; + double pressure_inlet = 55.0; + double temperature_inlet = 35.0; + double gasFlowRate = 5.0; + ProcessSystem processOps = null; + + /** + * @throws java.lang.Exception + */ + @BeforeEach + public void setUpBeforeClass() throws Exception { + testSystem = new SystemSrkCPAstatoil(298.0, 10.0); + testSystem.addComponent("methane", 100.0); + testSystem.addComponent("ethane", 10.0); + testSystem.addComponent("nC10", 10.0); + testSystem.addComponent("water", 10.0); + testSystem.setMixingRule(10); + testSystem.setMultiPhaseCheck(true); + + processOps = new ProcessSystem(); + + StreamInterface inletStream = new Stream("inlet stream", testSystem); + inletStream.setPressure(pressure_inlet, "bara"); + inletStream.setTemperature(temperature_inlet, "C"); + inletStream.setFlowRate(gasFlowRate, "MSm3/day"); + + Separator sep = new Separator("inlet separator"); + sep.setInletStream(inletStream); + + StreamInterface gasFromSep = new Stream("liquid from separator", sep.getLiquidOutStream()); + StreamInterface liqFromSep = new Stream("liquid from separator", sep.getLiquidOutStream()); + + processOps.add(inletStream); + processOps.add(sep); + // processOps.add(gasFromSep); + // processOps.add(liqFromSep); + + // processOps.run(); + } + + @Test + public void testFlow() { + ((StreamInterface) processOps.getUnit("inlet stream")).setFlowRate(0.01, "MSm3/day"); + processOps.run(); + } + + @Test + public void testOnePhase() { + ((StreamInterface) processOps.getUnit("inlet stream")).setFlowRate(1.0, "MSm3/day"); + ((StreamInterface) processOps.getUnit("inlet stream")).getFluid() + .setMolarComposition(new double[] {1.0, 0.0, 0.0, 0.0}); + + processOps.run(); + } +} diff --git a/src/test/java/neqsim/processSimulation/processEquipment/splitter/ComponentSplitterTest.java b/src/test/java/neqsim/processSimulation/processEquipment/splitter/ComponentSplitterTest.java new file mode 100644 index 0000000000..effb512df6 --- /dev/null +++ b/src/test/java/neqsim/processSimulation/processEquipment/splitter/ComponentSplitterTest.java @@ -0,0 +1,52 @@ +package neqsim.processSimulation.processEquipment.splitter; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import neqsim.processSimulation.processEquipment.stream.Stream; +import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.processSimulation.processSystem.ProcessSystem; +import neqsim.thermo.system.SystemSrkEos; + +class ComponentSplitterTest { + static neqsim.thermo.system.SystemInterface testSystem = null; + double pressure_inlet = 85.0; + double temperature_inlet = 35.0; + double gasFlowRate = 5.0; + ProcessSystem processOps = null; + + @BeforeEach + public void setUpBeforeClass() throws Exception { + testSystem = new SystemSrkEos(298.0, 10.0); + testSystem.addComponent("methane", 100.0); + testSystem.addComponent("ethane", 10.0); + testSystem.addComponent("propane", 10.0); + processOps = new ProcessSystem(); + Stream inletStream = new Stream("inletStream", testSystem); + inletStream.setName("inlet stream"); + inletStream.setPressure(pressure_inlet, "bara"); + inletStream.setTemperature(temperature_inlet, "C"); + inletStream.setFlowRate(gasFlowRate, "MSm3/day"); + + ComponentSplitter splitter = new ComponentSplitter("splitter", inletStream); + splitter.setSplitFactors(new double[] {1.00, 0.0, 0.0}); + + StreamInterface stream1 = new Stream("stream 1", splitter.getSplitStream(0)); + StreamInterface stream2 = new Stream("stream 2",splitter.getSplitStream(1)); + + processOps.add(inletStream); + processOps.add(splitter); + processOps.add(stream1); + processOps.add(stream2); + } + + @Test + public void testRun() { + processOps.run(); + //((StreamInterface)processOps.getUnit("stream 1")).displayResult(); + //((StreamInterface)processOps.getUnit("stream 2")).displayResult(); + assertEquals(((StreamInterface)processOps.getUnit("stream 1")).getFluid().getComponent("methane").getx(), 1.0, 1e-6); + assertEquals(((StreamInterface)processOps.getUnit("stream 2")).getFluid().getComponent("methane").getx(), 0.0, 1e-6); + } + +} diff --git a/src/test/java/neqsim/processSimulation/processSystem/GlycolRigTest.java b/src/test/java/neqsim/processSimulation/processSystem/GlycolRigTest.java new file mode 100644 index 0000000000..d8ba2ac96b --- /dev/null +++ b/src/test/java/neqsim/processSimulation/processSystem/GlycolRigTest.java @@ -0,0 +1,177 @@ +package neqsim.processSimulation.processSystem; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import neqsim.processSimulation.processEquipment.absorber.WaterStripperColumn; +import neqsim.processSimulation.processEquipment.compressor.Compressor; +import neqsim.processSimulation.processEquipment.distillation.DistillationColumn; +import neqsim.processSimulation.processEquipment.heatExchanger.Heater; +import neqsim.processSimulation.processEquipment.mixer.Mixer; +import neqsim.processSimulation.processEquipment.separator.Separator; +import neqsim.processSimulation.processEquipment.stream.Stream; +import neqsim.processSimulation.processEquipment.util.Recycle; + +public class GlycolRigTest extends neqsim.NeqSimTest { + ProcessSystem p; + String _name = "TestProcess"; + + @BeforeEach + public void setUp() { + p = new ProcessSystem(); + p.setName(_name); + } + + @Test + public void runTEGProcessTest() { + neqsim.thermo.system.SystemInterface feedTEG = + new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 145.0, 1.2); + feedTEG.addComponent("nitrogen", 0.00005); + feedTEG.addComponent("water", 0.19 - 1 * 0.00005); + feedTEG.addComponent("TEG", 0.8); + feedTEG.setMixingRule(10); + feedTEG.setMolarComposition(new double[] {0.00003, 0.2 - 1 * 0.00003, 0.8}); + + neqsim.thermo.system.SystemInterface strippingGasToStripperFluid = feedTEG.clone(); + strippingGasToStripperFluid.setMolarComposition(new double[] {1.0, 0.0, 0.0}); + + Stream strippingGas = new Stream("stripgas", strippingGasToStripperFluid); + strippingGas.setFlowRate(13.0, "kg/hr"); + strippingGas.setTemperature(55.0, "C"); + strippingGas.setPressure(0.2, "barg"); + + Stream gasToReboiler = strippingGas.clone(); + gasToReboiler.setName("gas to reboiler"); + + Stream TEGtoRegenerator = new Stream("feedTEG", feedTEG); + TEGtoRegenerator.setName("TEG to regenerator"); + TEGtoRegenerator.setFlowRate(400.0, "kg/hr"); + TEGtoRegenerator.setTemperature(145.0, "C"); + TEGtoRegenerator.setPressure(0.2, "barg"); + + DistillationColumn column = new DistillationColumn(1, true, true); + column.setName("TEG regeneration column"); + column.addFeedStream(TEGtoRegenerator, 1); + column.getReboiler().setOutTemperature(273.15 + 209.0); + column.getCondenser().setOutTemperature(273.15 + 94.0); + column.getReboiler().addStream(gasToReboiler); + column.setTopPressure(0.1 + 1.01325); + column.setBottomPressure(0.2 + 1.01325); + + WaterStripperColumn stripper = new WaterStripperColumn("TEG stripper"); + stripper.addSolventInStream(column.getLiquidOutStream()); + stripper.addGasInStream(strippingGas); + stripper.setNumberOfStages(2); + stripper.setStageEfficiency(0.7); + + Recycle recycleGasFromStripper = new Recycle("stripping gas recirc"); + recycleGasFromStripper.addStream(stripper.getGasOutStream()); + recycleGasFromStripper.setOutletStream(gasToReboiler); + + Heater coolerPipe = new Heater(column.getGasOutStream()); + coolerPipe.setName("heat loss cooling"); + coolerPipe.setOutTemperature(273.15 + 81.0); + + Heater coolerRegenGas = new Heater(coolerPipe.getOutStream()); + coolerRegenGas.setName("regen gas cooler"); + coolerRegenGas.setOutTemperature(273.15 + 25.0); + + Separator sepregenGas = new Separator(coolerRegenGas.getOutStream()); + sepregenGas.setName("regen gas separator"); + + Compressor blower = new Compressor(sepregenGas.getGasOutStream()); + blower.setOutletPressure(0.2, "barg"); + + Heater gasHeater = new Heater(blower.getOutStream()); + gasHeater.setOutTemperature(273.15 + 53.0); + + Recycle recycleGasfEED = new Recycle("FEED gas recirc"); + recycleGasfEED.addStream(gasHeater.getOutStream()); + recycleGasfEED.setOutletStream(strippingGas); + recycleGasfEED.setPriority(200); + + Heater coolerStripper = new Heater(stripper.getSolventOutStream()); + coolerStripper.setName("TEG cooler"); + coolerStripper.setOutTemperature(273.15 + 98.0); + + Stream liquidToTreatment = new Stream(sepregenGas.getLiquidOutStream()); + liquidToTreatment.setName("water to treatment"); + + Mixer TEGWaterMixer = new Mixer("TEG water mixer"); + TEGWaterMixer.addStream(coolerStripper.getOutStream()); + TEGWaterMixer.addStream(liquidToTreatment); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(TEGtoRegenerator); + operations.add(strippingGas); + operations.add(gasToReboiler); + operations.add(column); + operations.add(coolerPipe); + operations.add(coolerRegenGas); + operations.add(sepregenGas); + operations.add(blower); + operations.add(gasHeater); + operations.add(recycleGasfEED); + operations.add(liquidToTreatment); + operations.add(stripper); + operations.add(recycleGasFromStripper); + operations.add(coolerStripper); + operations.add(TEGWaterMixer); + + Thread runThr = operations.runAsThread(); + try { + runThr.join(100000); + } catch (Exception e) { + + } + double wtpWaterRichTEG = + TEGtoRegenerator.getFluid().getPhase("aqueous").getWtFrac("TEG") * 100.0; + double wtpWaterFromReboil = + column.getLiquidOutStream().getFluid().getPhase("aqueous").getWtFrac("TEG") * 100.0; + double wtpWaterFromStripper = + stripper.getSolventOutStream().getFluid().getPhase("aqueous").getWtFrac("TEG") * 100.0; + System.out.println("wtpRichTEG " + wtpWaterRichTEG); + System.out.println("wtpWaterFromReboil " + wtpWaterFromReboil); + System.out.println("wtpWaterFromStripper " + wtpWaterFromStripper); + // double wtpWaterFromReboiler = + // column.getLiquidOutStream().getFluid().getPhase("aqueous").getWtFrac("water")*100.0 + // double wtpTEGSeparatorOut = + // liquidToTreatment.getFluid().getPhase("aqueous").getWtFrac("TEG")*100.0 + // double flowrateLiquidSeparatorOut = liquidToTreatment.getFlowRate("kg/hr") + // double wtWaterFromStripper = + // stripper.getSolventOutStream().getFluid().getPhase("aqueous").getWtFrac("water")*100.0 + // double wtWaterBufferTank = + // liquidFromBufferTank.getFluid().getPhase("aqueous").getWtFrac("water")*100.0 + //TEGtoRegenerator.displayResult(); + System.out.println("water to regenerator " + + TEGtoRegenerator.getFluid().getComponent("water").getTotalFlowRate("kg/hr")); + System.out.println("TEG to regenerator " + + TEGtoRegenerator.getFluid().getComponent("TEG").getTotalFlowRate("kg/hr")); + // System.out.println("oxygen to regenerator " + // + TEGtoRegenerator.getFluid().getComponent("oxygen").getTotalFlowRate("kg/hr")); + System.out.println("nitrogen to regenerator " + + TEGtoRegenerator.getFluid().getComponent("nitrogen").getTotalFlowRate("kg/hr")); + + System.out.println("water liquid from regenerator " + + column.getLiquidOutStream().getFluid().getComponent("water").getTotalFlowRate("kg/hr")); + System.out.println("water gas from regenerator " + + column.getGasOutStream().getFluid().getComponent("water").getTotalFlowRate("kg/hr")); + + double waterBalanceColumn = + column.getLiquidOutStream().getFluid().getComponent("water").getTotalFlowRate("kg/hr") + + column.getGasOutStream().getFluid().getComponent("water").getTotalFlowRate("kg/hr") + - TEGtoRegenerator.getFluid().getComponent("water").getTotalFlowRate("kg/hr") + - gasToReboiler.getFluid().getComponent("water").getTotalFlowRate("kg/hr"); + System.out.println("water balance " + waterBalanceColumn); + + System.out.println("wt water to reboil " + + TEGtoRegenerator.getFluid().getPhase("aqueous").getWtFrac("water") * 100.0); + + System.out.println("wt water from mixer " + + TEGWaterMixer.getFluid().getPhase("aqueous").getWtFrac("water") * 100.0); + //strippingGas.displayResult(); + System.out.println("stripping gas rate " + strippingGas.getFlowRate("kg/hr")); + Assertions.assertEquals(0.0, waterBalanceColumn, 1e-3); + } +} diff --git a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemControllerTest.java b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemControllerTest.java new file mode 100644 index 0000000000..7e77bda81f --- /dev/null +++ b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemControllerTest.java @@ -0,0 +1,127 @@ +package neqsim.processSimulation.processSystem; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import neqsim.processSimulation.controllerDevice.ControllerDeviceBaseClass; +import neqsim.processSimulation.controllerDevice.ControllerDeviceInterface; +import neqsim.processSimulation.measurementDevice.VolumeFlowTransmitter; +import neqsim.processSimulation.processEquipment.separator.Separator; +import neqsim.processSimulation.processEquipment.stream.Stream; +import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; +import neqsim.thermo.system.SystemInterface; + +public class ProcessSystemControllerTest extends neqsim.NeqSimTest { + ProcessSystem p; + + @BeforeEach + public void setUp() { + p = new ProcessSystem(); + } + + @Test + public void testGetName() { + String name = "TestProsess"; + p.setName(name); + Assertions.assertEquals(name, p.getName()); + } + + @Test + void testGetTime() { + + } + + @Test + void testGetTimeStep() { + + } + + private SystemInterface getTestSystem() { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); + testSystem.addComponent("methane", 0.900); + testSystem.addComponent("ethane", 0.100); + testSystem.addComponent("n-heptane", 0.1); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + return testSystem; + } + + private double getRandomDistrurbanceFlowRate() { + double max = 5; + double min = -5; + double random_double = (int) Math.floor(Math.random() * (max - min + 1) + min); + return random_double; + } + + @Test + public void testStaticSimulationWithController() { + neqsim.thermo.system.SystemInterface testSystem = getTestSystem(); + + Stream stream_1 = new Stream("Stream1", testSystem); + stream_1.setFlowRate(100.0 + getRandomDistrurbanceFlowRate(), "kg/hr"); + stream_1.setPressure(10.0, "bara"); + + ThrottlingValve valve_1 = new ThrottlingValve("valve_1", stream_1); + valve_1.setOutletPressure(5.0); + + Separator separator_1 = new Separator("sep 1"); + separator_1.addStream(valve_1.getOutletStream()); + + VolumeFlowTransmitter flowTransmitter = + new VolumeFlowTransmitter(separator_1.getGasOutStream()); + flowTransmitter.setUnit("kg/hr"); + flowTransmitter.setMaximumValue(150.0); + flowTransmitter.setMinimumValue(10.0); + + ControllerDeviceInterface flowController = new ControllerDeviceBaseClass(); + flowController.setTransmitter(flowTransmitter); + flowController.setReverseActing(true); + flowController.setControllerSetPoint(65.0 + getRandomDistrurbanceFlowRate()); + flowController.setControllerParameters(0.5, 100.100, 0.0); + + p.add(stream_1); + p.add(valve_1); + p.add(separator_1); + p.add(flowTransmitter); + stream_1.setController(flowController); + + p.run(); + + // transient behaviour + p.setTimeStep(1.0); + for (int i = 0; i < 55; i++) { + flowController.setControllerSetPoint(65.0 + getRandomDistrurbanceFlowRate()); + p.runTransient(); + System.out.println( + "flow rate " + valve_1.getOutletStream().getFluid().getPhase("gas").getFlowRate("kg/hr") + + " controller response " + flowController.getResponse() + " valve opening " + + valve_1.getPercentValveOpening() + " pressure " + + separator_1.getGasOutStream().getPressure()); + } + + for (int i = 0; i < 100; i++) { + flowController.setControllerSetPoint(55.0 + getRandomDistrurbanceFlowRate()); + // stream_1.runTransient(1.0); + p.runTransient(); + System.out.println( + "flow rate " + valve_1.getOutletStream().getFluid().getPhase("gas").getFlowRate("kg/hr") + + " controller response " + flowController.getResponse() + " valve opening " + + valve_1.getPercentValveOpening() + " pressure " + + separator_1.getGasOutStream().getPressure()); + } + + // transient behaviour + p.setTimeStep(1.0); + for (int i = 0; i < 55; i++) { + flowController.setControllerSetPoint(75.0 + getRandomDistrurbanceFlowRate()); + p.runTransient(); + System.out.println( + "flow rate " + valve_1.getOutletStream().getFluid().getPhase("gas").getFlowRate("kg/hr") + + " controller response " + flowController.getResponse() + " valve opening " + + valve_1.getPercentValveOpening() + " pressure " + + separator_1.getGasOutStream().getPressure()); + // p.runTransient(); + } + } +} diff --git a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemRunTransientTest.java b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemRunTransientTest.java index d91daff9fe..2d0e9699ca 100644 --- a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemRunTransientTest.java +++ b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemRunTransientTest.java @@ -1,8 +1,10 @@ package neqsim.processSimulation.processSystem; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import neqsim.processSimulation.SimulationInterface; import neqsim.processSimulation.controllerDevice.ControllerDeviceBaseClass; import neqsim.processSimulation.controllerDevice.ControllerDeviceInterface; import neqsim.processSimulation.measurementDevice.LevelTransmitter; @@ -13,173 +15,203 @@ import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; import neqsim.thermo.system.SystemInterface; -public class ProcessSystemRunTransientTest extends neqsim.NeqSimTest{ - ProcessSystem p; - - @BeforeEach - public void setUp() { - p = new ProcessSystem(); +public class ProcessSystemRunTransientTest extends neqsim.NeqSimTest { + ProcessSystem p; + + @BeforeEach + public void setUp() { + p = new ProcessSystem(); + } + + @Test + public void testGetName() { + String name = "TestProsess"; + p.setName(name); + Assertions.assertEquals(name, p.getName()); + } + + @Test + void testGetTime() { + + } + + @Test + void testGetTimeStep() { + + } + + private SystemInterface getTestSystem() { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); + testSystem.addComponent("methane", 0.900); + testSystem.addComponent("ethane", 0.100); + testSystem.addComponent("n-heptane", 1.00); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + return testSystem; + } + + // @Test + public void testDynamicCalculation() { + neqsim.thermo.system.SystemInterface testSystem = getTestSystem(); + + Stream stream1 = new Stream("Stream1", testSystem); + stream1.setFlowRate(50.0, "kg/hr"); + stream1.setPressure(10.0, "bara"); + + ThrottlingValve valve1 = new ThrottlingValve("valve_1", stream1); + valve1.setOutletPressure(5.0); + valve1.setPercentValveOpening(50); + + Separator separator1 = new Separator("sep 1"); + separator1.addStream(valve1.getOutletStream()); + + ThrottlingValve valve2 = new ThrottlingValve("valve_2", separator1.getLiquidOutStream()); + valve2.setOutletPressure(1.0); + valve2.setPercentValveOpening(50); + + ThrottlingValve valve3 = new ThrottlingValve("valve_3", separator1.getGasOutStream()); + valve3.setOutletPressure(1.0); + valve3.setPercentValveOpening(50); + + VolumeFlowTransmitter flowTransmitter = new VolumeFlowTransmitter(stream1); + flowTransmitter.setUnit("kg/hr"); + flowTransmitter.setMaximumValue(100.0); + flowTransmitter.setMinimumValue(1.0); + + ControllerDeviceInterface flowController = new ControllerDeviceBaseClass(); + flowController.setTransmitter(flowTransmitter); + flowController.setReverseActing(true); + flowController.setControllerSetPoint(63.5); + flowController.setControllerParameters(0.1, 0.10, 0.0); + + p.add(stream1); + p.add(valve1); + p.add(separator1); + p.add(valve2); + p.add(valve3); + p.add(flowTransmitter); + valve1.setController(flowController); + + p.run(); + + // transient behaviour + p.setTimeStep(1.0); + for (int i = 0; i < 5; i++) { + // System.out.println("volume flow " + flowTransmitter.getMeasuredValue() + // + " valve opening " + valve_1.getPercentValveOpening() + " pressure " + // + separator_1.getGasOutStream().getPressure()); + p.runTransient(); + for (SimulationInterface sim : p.getUnitOperations()) { + assertEquals(sim.getCalculationIdentifier(), p.getCalculationIdentifier()); + } } - - @Test - public void testGetName() { - String name = "TestProsess"; - p.setName(name); - Assertions.assertEquals(name, p.getName()); + } + + @Test + public void testDynamicCalculation2() { + neqsim.thermo.system.SystemInterface testSystem2 = + new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); + testSystem2.addComponent("methane", 1.1); + testSystem2.addComponent("ethane", 0.10001); + testSystem2.addComponent("n-heptane", 1.001); + testSystem2.setMixingRule(2); + + Stream purgeStream = new Stream("Purge Stream", testSystem2); + ThrottlingValve purgeValve = new ThrottlingValve("purgeValve", purgeStream); + purgeValve.setOutletPressure(7.0); + purgeValve.setPercentValveOpening(50.0); + + neqsim.thermo.system.SystemInterface testSystem = getTestSystem(); + Stream stream1 = new Stream("Stream1", testSystem); + stream1.setCalculateSteadyState(false); + ThrottlingValve valve1 = new ThrottlingValve("valve_1", stream1); + valve1.setOutletPressure(7.0); + valve1.setPercentValveOpening(50); + + Separator separator1 = new Separator("separator_1"); + separator1.addStream(valve1.getOutletStream()); + separator1.addStream(purgeValve.getOutletStream()); + separator1.setCalculateSteadyState(true); + + ThrottlingValve valve2 = new ThrottlingValve("valve_2", separator1.getLiquidOutStream()); + valve2.setOutletPressure(5.0); + valve2.setPercentValveOpening(50); + valve2.setCalculateSteadyState(true); + // valve_2.setCv(10.0); + + ThrottlingValve valve3 = new ThrottlingValve("valve_3", separator1.getGasOutStream()); + valve3.setOutletPressure(5.0); + valve3.setPercentValveOpening(50); + valve3.setCalculateSteadyState(true); + // valve_3.setCv(10.0); + + LevelTransmitter separatorLevelTransmitter = new LevelTransmitter(separator1); + separatorLevelTransmitter.setName("separatorLevelTransmitter1"); + separatorLevelTransmitter.setUnit("meter"); + separatorLevelTransmitter.setMaximumValue(1.0); + separatorLevelTransmitter.setMinimumValue(0.0); + + ControllerDeviceInterface separatorLevelController = new ControllerDeviceBaseClass(); + separatorLevelController.setReverseActing(true); + separatorLevelController.setTransmitter(separatorLevelTransmitter); + separatorLevelController.setControllerSetPoint(0.3); + separatorLevelController.setControllerParameters(1, 1000.0, 0.0); + + PressureTransmitter separatorPressureTransmitter = + new PressureTransmitter(separator1.getGasOutStream()); + separatorPressureTransmitter.setUnit("bar"); + separatorPressureTransmitter.setMaximumValue(10.0); + separatorPressureTransmitter.setMinimumValue(1.0); + + ControllerDeviceInterface separatorPressureController = new ControllerDeviceBaseClass(); + separatorPressureController.setTransmitter(separatorPressureTransmitter); + separatorPressureController.setReverseActing(false); + separatorPressureController.setControllerSetPoint(7.0); + separatorPressureController.setControllerParameters(0.5, 10.0, 0.0); + + p.add(stream1); + p.add(valve1); + + p.add(purgeStream); + p.add(purgeValve); + p.add(separator1); + p.add(valve2); + p.add(valve3); + + // add transmitters + p.add(separatorLevelTransmitter); + valve2.setController(separatorLevelController); + + p.add(separatorPressureTransmitter); + valve3.setController(separatorPressureController); + + p.run(); + for (SimulationInterface sim : p.getUnitOperations()) { + assertEquals(sim.getCalculationIdentifier(), p.getCalculationIdentifier()); } - @Test - void testGetTime() { - + // p.displayResult(); + p.setTimeStep(0.01); + for (int i = 0; i < 500; i++) { + // System.out.println("pressure "+separator_1.getGasOutStream().getPressure()+ " flow "+ + // separator_1.getGasOutStream().getFlowRate("kg/hr") + " sepr height + // "+separatorLevelTransmitter.getMeasuredValue()); + p.runTransient(); + for (SimulationInterface sim : p.getUnitOperations()) { + assertEquals(p.getCalculationIdentifier(), sim.getCalculationIdentifier()); + } } - @Test - void testGetTimeStep() { - - } - - private SystemInterface getTestSystem() { - neqsim.thermo.system.SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); - testSystem.addComponent("methane", 0.900); - testSystem.addComponent("ethane", 0.100); - testSystem.addComponent("n-heptane", 1.00); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - return testSystem; - } - - // @Test - public void testDynamicCalculation() { - neqsim.thermo.system.SystemInterface testSystem = getTestSystem(); - - Stream stream_1 = new Stream("Stream1", testSystem); - stream_1.setFlowRate(50.0, "kg/hr"); - stream_1.setPressure(10.0, "bara"); - - ThrottlingValve valve_1 = new ThrottlingValve("valve_1", stream_1); - valve_1.setOutletPressure(5.0); - valve_1.setPercentValveOpening(50); - - Separator separator_1 = new Separator("sep 1"); - separator_1.addStream(valve_1.getOutStream()); - - ThrottlingValve valve_2 = new ThrottlingValve("valve_2", separator_1.getLiquidOutStream()); - valve_2.setOutletPressure(1.0); - valve_2.setPercentValveOpening(50); - - ThrottlingValve valve_3 = new ThrottlingValve("valve_3", separator_1.getGasOutStream()); - valve_3.setOutletPressure(1.0); - valve_3.setPercentValveOpening(50); - - VolumeFlowTransmitter flowTransmitter = new VolumeFlowTransmitter(stream_1); - flowTransmitter.setUnit("kg/hr"); - flowTransmitter.setMaximumValue(100.0); - flowTransmitter.setMinimumValue(1.0); - - ControllerDeviceInterface flowController = new ControllerDeviceBaseClass(); - flowController.setTransmitter(flowTransmitter); - flowController.setReverseActing(true); - flowController.setControllerSetPoint(63.5); - flowController.setControllerParameters(0.1, 0.10, 0.0); - - p.add(stream_1); - p.add(valve_1); - p.add(separator_1); - p.add(valve_2); - p.add(valve_3); - p.add(flowTransmitter); - valve_1.setController(flowController); - - p.run(); - - // transient behaviour - p.setTimeStep(1.0); - for (int i = 0; i < 5; i++) { - // System.out.println("volume flow " + flowTransmitter.getMeasuredValue() - // + " valve opening " + valve_1.getPercentValveOpening() + " pressure " - // + separator_1.getGasOutStream().getPressure()); - p.runTransient(); - } - } + valve1.setPercentValveOpening(60); - //@Test - public void testDynamicCalculation2() { - - neqsim.thermo.system.SystemInterface testSystem = getTestSystem(); - - neqsim.thermo.system.SystemInterface testSystem2 = new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), - 10.00); - testSystem2.addComponent("methane", 1.1); - testSystem2.addComponent("ethane", 0.10001); - testSystem2.addComponent("n-heptane", 1.001); - testSystem2.setMixingRule(2); - - Stream purgeStream = new Stream("Purge Stream", testSystem2); - ThrottlingValve purgeValve = new ThrottlingValve("purgeValve", purgeStream); - purgeValve.setOutletPressure(7.0); - purgeValve.setPercentValveOpening(50.0); - - Stream stream_1 = new Stream("Stream1", testSystem); - ThrottlingValve valve_1 = new ThrottlingValve("valve_1", stream_1); - valve_1.setOutletPressure(7.0); - valve_1.setPercentValveOpening(50); - - Separator separator_1 = new Separator("separator_1"); - separator_1.addStream(valve_1.getOutStream()); - separator_1.addStream(purgeValve.getOutStream()); - - ThrottlingValve valve_2 = new ThrottlingValve("valve_2", separator_1.getLiquidOutStream()); - valve_2.setOutletPressure(5.0); - valve_2.setPercentValveOpening(50); - // valve_2.setCv(10.0); - - ThrottlingValve valve_3 = new ThrottlingValve("valve_3", separator_1.getGasOutStream()); - valve_3.setOutletPressure(5.0); - valve_3.setPercentValveOpening(50); - // valve_3.setCv(10.0); - - LevelTransmitter separatorLevelTransmitter = new LevelTransmitter(separator_1); - separatorLevelTransmitter.setName("separatorLevelTransmitter1"); - separatorLevelTransmitter.setUnit("meter"); - separatorLevelTransmitter.setMaximumValue(1.0); - separatorLevelTransmitter.setMinimumValue(0.0); - - ControllerDeviceInterface separatorLevelController = new ControllerDeviceBaseClass(); - separatorLevelController.setReverseActing(false); - separatorLevelController.setTransmitter(separatorLevelTransmitter); - separatorLevelController.setControllerSetPoint(0.3); - separatorLevelController.setControllerParameters(1.0, 300.0, 10.0); - - PressureTransmitter separatorPressureTransmitter = new PressureTransmitter(separator_1.getGasOutStream()); - separatorPressureTransmitter.setUnit("bar"); - separatorPressureTransmitter.setMaximumValue(10.0); - separatorPressureTransmitter.setMinimumValue(1.0); - - ControllerDeviceInterface separatorPressureController = new ControllerDeviceBaseClass(); - separatorPressureController.setTransmitter(separatorPressureTransmitter); - separatorPressureController.setReverseActing(false); - separatorPressureController.setControllerSetPoint(7.0); - separatorPressureController.setControllerParameters(1.0, 300.0, 10.0); - - p.add(stream_1); - p.add(valve_1); - - p.add(purgeStream); - p.add(purgeValve); - p.add(separator_1); - p.add(valve_2); - p.add(valve_3); - - // add transmitters - p.add(separatorLevelTransmitter); - valve_2.setController(separatorLevelController); - - p.add(separatorPressureTransmitter); - valve_3.setController(separatorPressureController); - - p.run(); - // p.displayResult(); - p.setTimeStep(0.0001); - p.runTransient(); + for (int i = 0; i < 10; i++) { + // System.out.println("pressure "+separator_1.getGasOutStream().getPressure()+ " flow "+ + // separator_1.getGasOutStream().getFlowRate("kg/hr")); + p.runTransient(); + for (SimulationInterface sim : p.getUnitOperations()) { + assertEquals(p.getCalculationIdentifier(), sim.getCalculationIdentifier()); + } } + } } diff --git a/src/test/java/neqsim/processSimulation/util/example/LNGfilling.java b/src/test/java/neqsim/processSimulation/util/example/LNGfilling.java index e48aaf4d7f..ac0c2b8c52 100644 --- a/src/test/java/neqsim/processSimulation/util/example/LNGfilling.java +++ b/src/test/java/neqsim/processSimulation/util/example/LNGfilling.java @@ -59,6 +59,6 @@ public static void main(String args[]) { System.out.println("Volume Methane " + stream_1.getThermoSystem().getVolume()); System.out.println("Volume Nitrogen " + stream_2.getThermoSystem().getVolume()); System.out.println( - "Mixer Cooled Nitrogen " + mixer.getOutStream().getThermoSystem().getVolume()); + "Mixer Cooled Nitrogen " + mixer.getOutletStream().getThermoSystem().getVolume()); } } diff --git a/src/test/java/neqsim/processSimulation/util/example/LNGtankfilling.java b/src/test/java/neqsim/processSimulation/util/example/LNGtankfilling.java index 488514d3db..135589a1df 100644 --- a/src/test/java/neqsim/processSimulation/util/example/LNGtankfilling.java +++ b/src/test/java/neqsim/processSimulation/util/example/LNGtankfilling.java @@ -63,7 +63,7 @@ public static void main(String args[]) { valve.setOutletPressure(1.01325 + 0.110); Tank tank = new neqsim.processSimulation.processEquipment.tank.Tank("tank"); - tank.addStream(valve.getOutStream()); + tank.addStream(valve.getOutletStream()); // tank.addStream(stream_2); ValveInterface valve2 = new ThrottlingValve("valve2", tank.getGasOutStream()); diff --git a/src/test/java/neqsim/processSimulation/util/example/MEGinjection.java b/src/test/java/neqsim/processSimulation/util/example/MEGinjection.java index aa5f8e3d86..c5a9bc5020 100644 --- a/src/test/java/neqsim/processSimulation/util/example/MEGinjection.java +++ b/src/test/java/neqsim/processSimulation/util/example/MEGinjection.java @@ -68,11 +68,11 @@ public static void main(String[] args) { feedGasMEGmixer.addStream(feedGasStream); feedGasMEGmixer.addStream(MEGFeed); - Heater pipeline = new Heater("gas-MEG pipeline", feedGasMEGmixer.getOutStream()); + Heater pipeline = new Heater("gas-MEG pipeline", feedGasMEGmixer.getOutletStream()); pipeline.setOutTemperature(273.15 + 35.5); pipeline.setOutPressure(80.2); - Stream mixerStream = (Stream) pipeline.getOutStream(); + Stream mixerStream = (Stream) pipeline.getOutletStream(); mixerStream.setName("feed gas and MEG"); Adjuster adjuster = new Adjuster("MEG adjuster"); @@ -100,7 +100,7 @@ public static void main(String[] args) { onshoreChockeValve.setOutletPressure(70.3); ThreePhaseSeparator slugCatcher = - new ThreePhaseSeparator("slug catcher", onshoreChockeValve.getOutStream()); + new ThreePhaseSeparator("slug catcher", onshoreChockeValve.getOutletStream()); neqsim.thermo.system.SystemInterface feedMEGOnshore = feedGas.clone(); feedMEG.setMolarComposition(new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, @@ -119,7 +119,7 @@ public static void main(String[] args) { MEGmixer1.addStream(slugCatcher.getGasOutStream()); MEGmixer1.addStream(MEGsplitter.getSplitStream(0)); - ThrottlingValve DPvalve1 = new ThrottlingValve("DP valve 1", MEGmixer1.getOutStream()); + ThrottlingValve DPvalve1 = new ThrottlingValve("DP valve 1", MEGmixer1.getOutletStream()); DPvalve1.setOutletPressure(70.0); neqsim.processSimulation.processSystem.ProcessSystem onshoreOperations = diff --git a/src/test/java/neqsim/processSimulation/util/example/MasstransferMeOH.java b/src/test/java/neqsim/processSimulation/util/example/MasstransferMeOH.java index 5333aa1c8b..aca24ac7ba 100644 --- a/src/test/java/neqsim/processSimulation/util/example/MasstransferMeOH.java +++ b/src/test/java/neqsim/processSimulation/util/example/MasstransferMeOH.java @@ -45,7 +45,7 @@ public static void main(String[] args) { new StreamSaturatorUtil("water saturator", dryFeedGas); Stream waterSaturatedFeedGas = - new Stream("water saturated feed gas", saturatedFeedGas.getOutStream()); + new Stream("water saturated feed gas", saturatedFeedGas.getOutletStream()); neqsim.thermo.system.SystemInterface feedMeOH = feedGas.clone(); feedMeOH.setMolarComposition(new double[] {0.0, 0.0, 1.0}); @@ -61,7 +61,7 @@ public static void main(String[] args) { neqsim.processSimulation.processEquipment.util.NeqSimUnit pipeline = new neqsim.processSimulation.processEquipment.util.NeqSimUnit( - mainMixer.getOutStream(), "pipeline", "stratified"); + mainMixer.getOutletStream(), "pipeline", "stratified"); pipeline.setLength(123.01); GasScrubber scrubber = new GasScrubber("gas scrub", pipeline.getOutStream()); diff --git a/src/test/java/neqsim/processSimulation/util/example/OffshoreProcess.java b/src/test/java/neqsim/processSimulation/util/example/OffshoreProcess.java index 0b50bee2b6..29b99feb21 100644 --- a/src/test/java/neqsim/processSimulation/util/example/OffshoreProcess.java +++ b/src/test/java/neqsim/processSimulation/util/example/OffshoreProcess.java @@ -78,20 +78,20 @@ public static void main(String args[]) { Compressor compressor1 = new Compressor("compressor1", stream_2); compressor1.setOutletPressure(131.3); - StreamInterface stream_4 = compressor1.getOutStream(); + StreamInterface stream_4 = compressor1.getOutletStream(); stream_4.setName("gas compressor out stream"); Compressor compressor2 = new Compressor("compressor2", stream_3); compressor2.setOutletPressure(131.3); - StreamInterface stream_5 = compressor2.getOutStream(); + StreamInterface stream_5 = compressor2.getOutletStream(); stream_5.setName("liquid compressor out stream"); Mixer mixer = new StaticPhaseMixer("Mixer 1"); mixer.addStream(stream_4); mixer.addStream(stream_5); - NeqStream stream_6 = new NeqStream("after mixer stream", mixer.getOutStream()); + NeqStream stream_6 = new NeqStream("after mixer stream", mixer.getOutletStream()); Pipeline pipe = new TwoPhasePipeLine("pipe", stream_6); pipe.setOutputFileName("c:/tempAsgard.nc"); diff --git a/src/test/java/neqsim/processSimulation/util/example/OffshoreProcess3.java b/src/test/java/neqsim/processSimulation/util/example/OffshoreProcess3.java index 6b31dbee99..8eb232ef03 100644 --- a/src/test/java/neqsim/processSimulation/util/example/OffshoreProcess3.java +++ b/src/test/java/neqsim/processSimulation/util/example/OffshoreProcess3.java @@ -63,13 +63,13 @@ public static void main(String[] args) { inletTempControl.setOutPressure(55.21, "bara"); ThrottlingValve valve = - new ThrottlingValve("inlet choke valve", inletTempControl.getOutStream()); + new ThrottlingValve("inlet choke valve", inletTempControl.getOutletStream()); valve.setOutletPressure(35.21); Stream oilToInletSep = new Stream("oilToInletSep", fluid3.clone()); oilToInletSep.setFlowRate(1e-10, "kg/hr"); ThreePhaseSeparator inletSeparator = - new ThreePhaseSeparator("1st stage separator", valve.getOutStream()); + new ThreePhaseSeparator("1st stage separator", valve.getOutletStream()); inletSeparator.setEntrainment(0.005, "mass", "product", "aqueous", "oil"); inletSeparator.setEntrainment(500e-6, "mole", "product", "oil", "aqueous"); inletSeparator.addStream(oilToInletSep); @@ -78,7 +78,8 @@ public static void main(String[] args) { new Heater("oil cooler/heater to 2nd stage", inletSeparator.getOilOutStream()); heater1.setOutTemperature(85.0, "C"); - ThrottlingValve valve2 = new ThrottlingValve("oil HP to MP valve", heater1.getOutStream()); + ThrottlingValve valve2 = + new ThrottlingValve("oil HP to MP valve", heater1.getOutletStream()); valve2.setOutletPressure(7.0); ThrottlingValve waterDPvalve = @@ -86,7 +87,7 @@ public static void main(String[] args) { waterDPvalve.setOutletPressure(1.01325); Separator waterStabSep = - new Separator("water degasing separator", waterDPvalve.getOutStream()); + new Separator("water degasing separator", waterDPvalve.getOutletStream()); Stream waterToTreatment = new Stream("water to treatment", waterStabSep.getLiquidOutStream()); @@ -98,7 +99,7 @@ public static void main(String[] args) { oilToSep.setFlowRate(1e-10, "kg/hr"); ThreePhaseSeparator mpseparator = - new ThreePhaseSeparator("2nd stage separator", valve2.getOutStream()); + new ThreePhaseSeparator("2nd stage separator", valve2.getOutletStream()); mpseparator.addStream(oilToSep); ThrottlingValve valvempValve = @@ -106,7 +107,7 @@ public static void main(String[] args) { valvempValve.setOutletPressure(2.1); ThreePhaseSeparator lpseparator = - new ThreePhaseSeparator("3rd stage separator", valvempValve.getOutStream()); + new ThreePhaseSeparator("3rd stage separator", valvempValve.getOutletStream()); Stream stableOilStream = (Stream) lpseparator.getOilOutStream(); stableOilStream.setName("stable oil"); @@ -114,9 +115,9 @@ public static void main(String[] args) { new Compressor("1st stage recompressor", lpseparator.getGasOutStream()); // lpcompressor.setOutletPressure(15.0); SetPoint compressorPresSet2 = - new SetPoint("comp pres LP set", lpcompressor, "pressure", valve2.getOutStream()); + new SetPoint("comp pres LP set", lpcompressor, "pressure", valve2.getOutletStream()); - Cooler lpgasheater = new Cooler("1st stage gas cooler", lpcompressor.getOutStream()); + Cooler lpgasheater = new Cooler("1st stage gas cooler", lpcompressor.getOutletStream()); lpgasheater.setOutTemperature(35.0, "C"); neqsim.thermo.system.SystemInterface coolingWaterSYstm = fluid3.clone(); @@ -137,10 +138,10 @@ public static void main(String[] args) { */ Cooler lpHeatExchanger = - new Cooler("1st stage gas heat exchanger", lpcompressor.getOutStream()); + new Cooler("1st stage gas heat exchanger", lpcompressor.getOutletStream()); lpgasheater.setOutTemperature(35.0, "C"); - Separator lpscrubber = new Separator("2nd stage scrubber", lpgasheater.getOutStream()); + Separator lpscrubber = new Separator("2nd stage scrubber", lpgasheater.getOutletStream()); Stream liqFromlpscrubber = (Stream) lpscrubber.getLiquidOutStream(); Recycle lpscrubberResyc = new Recycle("mpscrubberRes"); @@ -152,7 +153,7 @@ public static void main(String[] args) { mixermp.addStream(mpseparator.getGasOutStream()); Compressor compressor2stage = - new Compressor("2nd stage recompressor", mixermp.getOutStream()); + new Compressor("2nd stage recompressor", mixermp.getOutletStream()); compressor2stage.setIsentropicEfficiency(0.75); // compressor2stage.setOutletPressure(75.0); @@ -160,22 +161,22 @@ public static void main(String[] args) { new SetPoint("comp pres set", compressor2stage, "pressure", inletSeparator); Heater secondndstagecooler = - new Heater("2nd stage cooler", compressor2stage.getOutStream()); + new Heater("2nd stage cooler", compressor2stage.getOutletStream()); secondndstagecooler.setOutTemperature(290.0); Separator scrubbberfrom2ndstage = - new Separator("scrubber of mix gas HP", secondndstagecooler.getOutStream()); + new Separator("scrubber of mix gas HP", secondndstagecooler.getOutletStream()); Mixer mixer = new Mixer("HP rich gas mixer"); mixer.addStream(inletSeparator.getGasOutStream()); mixer.addStream(scrubbberfrom2ndstage.getGasOutStream()); Heater dewPointScrubberCooler = - new Heater("dew point scrubber cooler2", mixer.getOutStream()); + new Heater("dew point scrubber cooler2", mixer.getOutletStream()); dewPointScrubberCooler.setOutTemperature(273.15 + 32.3); Separator mpscrubber = - new Separator("dew point control scrubber", dewPointScrubberCooler.getOutStream()); + new Separator("dew point control scrubber", dewPointScrubberCooler.getOutletStream()); Stream liqFrommpscrubber = (Stream) mpscrubber.getLiquidOutStream(); @@ -188,24 +189,27 @@ public static void main(String[] args) { new MoleFractionControllerUtil(mpscrubber.getGasOutStream()); waterRemoval.setMoleFraction("water", 10.0e-6); - Stream richGas = new Stream("rich gas",waterRemoval.getOutStream()); + Stream richGas = new Stream("rich gas", waterRemoval.getOutletStream()); Compressor exportGasCompressor = new Compressor("1st stage export compressor",richGas); exportGasCompressor.setIsentropicEfficiency(0.75); exportGasCompressor.setOutletPressure(richGas.getPressure() * 2.5); - Cooler exportGasCompressorCooler = new Cooler("1st stage export gas cooler",exportGasCompressor.getOutStream()); + Cooler exportGasCompressorCooler = + new Cooler("1st stage export gas cooler", exportGasCompressor.getOutletStream()); exportGasCompressorCooler.setOutTemperature(35.0, "C"); - Compressor exportGasCompressor2 = new Compressor("2nd stage export compressor",exportGasCompressorCooler.getOutStream()); + Compressor exportGasCompressor2 = new Compressor("2nd stage export compressor", + exportGasCompressorCooler.getOutletStream()); exportGasCompressor2.setIsentropicEfficiency(0.75); exportGasCompressor2.setOutletPressure( - exportGasCompressorCooler.getOutStream().getPressure() * 2.5 * 2.5); + exportGasCompressorCooler.getOutletStream().getPressure() * 2.5 * 2.5); - Cooler exportGasCompressorCooler2 = new Cooler("2nd stage export gas cooler",exportGasCompressor2.getOutStream()); + Cooler exportGasCompressorCooler2 = + new Cooler("2nd stage export gas cooler", exportGasCompressor2.getOutletStream()); exportGasCompressorCooler2.setOutTemperature(35.0, "C"); - Stream exportGas = new Stream("export gas",exportGasCompressorCooler2.getOutStream()); + Stream exportGas = new Stream("export gas", exportGasCompressorCooler2.getOutletStream()); neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem(); diff --git a/src/test/java/neqsim/processSimulation/util/example/OnshoreMEGprocess.java b/src/test/java/neqsim/processSimulation/util/example/OnshoreMEGprocess.java index ab8d2cd87e..89b4c0b187 100644 --- a/src/test/java/neqsim/processSimulation/util/example/OnshoreMEGprocess.java +++ b/src/test/java/neqsim/processSimulation/util/example/OnshoreMEGprocess.java @@ -60,18 +60,18 @@ public static void main(String[] args) { new StreamSaturatorUtil("water saturator", dryFeedGas); Stream waterSaturatedFeedGas = - new Stream("water saturated feed gas", saturatedFeedGas.getOutStream()); + new Stream("water saturated feed gas", saturatedFeedGas.getOutletStream()); Compressor inletCompressor = new Compressor("Compressor 1 - first stage", waterSaturatedFeedGas); inletCompressor.setOutletPressure(70.0, "bara"); Cooler interstageGasCooler = - new Cooler("Compressor 1 - interstage cooler", inletCompressor.getOutStream()); + new Cooler("Compressor 1 - interstage cooler", inletCompressor.getOutletStream()); interstageGasCooler.setOutTemperature(40.0, "C"); Compressor inletCompressor2ndstage = - new Compressor("Compressor 1 - second stage", interstageGasCooler.getOutStream()); + new Compressor("Compressor 1 - second stage", interstageGasCooler.getOutletStream()); inletCompressor2ndstage.setOutletPressure(105.0, "bara"); neqsim.thermo.system.SystemInterface feedMEG = feedGas.clone(); @@ -86,18 +86,18 @@ public static void main(String[] args) { MEGsplitter1.setSplitFactors(new double[] {0.01, 0.94, 0.05}); StaticMixer MEGmixer1 = new StaticMixer("MEG mixer 1"); - MEGmixer1.addStream(inletCompressor2ndstage.getOutStream()); + MEGmixer1.addStream(inletCompressor2ndstage.getOutletStream()); MEGmixer1.addStream(MEGsplitter1.getSplitStream(0)); - Cooler inletGasCooler = new Cooler("dehydration cooler", MEGmixer1.getOutStream()); + Cooler inletGasCooler = new Cooler("dehydration cooler", MEGmixer1.getOutletStream()); inletGasCooler.setOutTemperature(10.0, "C"); StaticMixer MEGmixer2 = new StaticMixer("MEG mixer 2"); - MEGmixer2.addStream(inletGasCooler.getOutStream()); + MEGmixer2.addStream(inletGasCooler.getOutletStream()); MEGmixer2.addStream(MEGsplitter1.getSplitStream(1)); HeatExchanger heatEx = - new HeatExchanger("gas-gas heat exchanger", MEGmixer2.getOutStream()); + new HeatExchanger("gas-gas heat exchanger", MEGmixer2.getOutletStream()); heatEx.setGuessOutTemperature(273.15 - 10.0); heatEx.setUAvalue(30000.0); @@ -105,11 +105,12 @@ public static void main(String[] args) { MEGmixer3.addStream(heatEx.getOutStream(0)); MEGmixer3.addStream(MEGsplitter1.getSplitStream(2)); - ThrottlingValve presRedValveLT = new ThrottlingValve("JT valve", MEGmixer3.getOutStream()); + ThrottlingValve presRedValveLT = + new ThrottlingValve("JT valve", MEGmixer3.getOutletStream()); presRedValveLT.setOutletPressure(92.0); ThreePhaseSeparator mpseparator = - new ThreePhaseSeparator("low temperature scrubber", presRedValveLT.getOutStream()); + new ThreePhaseSeparator("low temperature scrubber", presRedValveLT.getOutletStream()); Stream coldGasFromSep = new Stream("gas from cold scrubber", mpseparator.getGasOutStream()); @@ -124,14 +125,15 @@ public static void main(String[] args) { richMEGstreamHeater.setOutTemperature(15.0, "C"); Heater richMEGstreamHeater2 = - new Heater("column condenser HX", richMEGstreamHeater.getOutStream()); + new Heater("column condenser HX", richMEGstreamHeater.getOutletStream()); // richMEGstreamHeater2.setOutTemperature(22.0, "C"); ThrottlingValve presRedValve3 = - new ThrottlingValve("valve to flash drum", richMEGstreamHeater2.getOutStream()); + new ThrottlingValve("valve to flash drum", richMEGstreamHeater2.getOutletStream()); presRedValve3.setOutletPressure(3.9); - Separator flashDrumSep = new Separator("rich MEG flash drum", presRedValve3.getOutStream()); + Separator flashDrumSep = + new Separator("rich MEG flash drum", presRedValve3.getOutletStream()); Stream flashGasStream = new Stream("gas from flash drum", flashDrumSep.getGasOutStream()); @@ -149,7 +151,7 @@ public static void main(String[] args) { DistillationColumn column = new DistillationColumn(2, true, true); column.setName("MEG regeneration column"); - column.addFeedStream(presRedValve4.getOutStream(), 0); + column.addFeedStream(presRedValve4.getOutletStream(), 0); column.getReboiler().setOutTemperature(273.15 + 135.0); column.getCondenser().setOutTemperature(273.15 + 105.0); column.setTopPressure(1.0); @@ -160,7 +162,7 @@ public static void main(String[] args) { coolerRegenGas.setOutTemperature(273.15 + 20.0); Separator sepregenGas = - new Separator("overhead condenser scrubber", coolerRegenGas.getOutStream()); + new Separator("overhead condenser scrubber", coolerRegenGas.getOutletStream()); Stream gasToFlare = new Stream("gas to flare from regenerator", sepregenGas.getGasOutStream()); @@ -171,12 +173,12 @@ public static void main(String[] args) { Cooler bufferTank = new Cooler("MEG buffer tank", column.getLiquidOutStream()); bufferTank.setOutTemperature(273.15 + 130.0); - Pump hotLeanMEGPump = new Pump("hot lean MEG pump", bufferTank.getOutStream()); + Pump hotLeanMEGPump = new Pump("hot lean MEG pump", bufferTank.getOutletStream()); hotLeanMEGPump.setOutletPressure(105.0); hotLeanMEGPump.setIsentropicEfficiency(0.75); Stream streamHotPump = - new Stream("stream from hot lean MEG pump", hotLeanMEGPump.getOutStream()); + new Stream("stream from hot lean MEG pump", hotLeanMEGPump.getOutletStream()); columnPreHeater.setFeedStream(1, streamHotPump); @@ -184,7 +186,7 @@ public static void main(String[] args) { coolerHotMEG2.setOutTemperature(273.15 + 20.0); Stream leanMEGtoMixer = - new Stream("lean MEG to makeup mixer", coolerHotMEG2.getOutStream()); + new Stream("lean MEG to makeup mixer", coolerHotMEG2.getOutletStream()); neqsim.thermo.system.SystemInterface pureMEG = feedGas.clone(); pureMEG.setMolarComposition(new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}); @@ -205,7 +207,7 @@ public static void main(String[] args) { makeupMixer.addStream(leanMEGtoMixer); makeupMixer.addStream(makeupMEG); - Stream streamToResycle = new Stream("streamToResycle", makeupMixer.getOutStream()); + Stream streamToResycle = new Stream("streamToResycle", makeupMixer.getOutletStream()); Recycle resycleLeanMEG = new Recycle("lean MEG resycle"); resycleLeanMEG.addStream(streamToResycle); @@ -273,7 +275,7 @@ public static void main(String[] args) { System.out.println("MEG flow rate " + richMEGstream.getFluid().getFlowRate("kg/hr")); System.out.println("MEG feed to column rate " - + presRedValve4.getOutStream().getFluid().getFlowRate("kg/hr")); + + presRedValve4.getOutletStream().getFluid().getFlowRate("kg/hr")); System.out.println("MEG flow rate " + resycleLeanMEG.getFluid().getFlowRate("kg/hr")); System.out.println( @@ -297,9 +299,9 @@ public static void main(String[] args) { + column.getLiquidOutStream().getFluid().getPhase("aqueous").getWtFrac("MEG") * 100.0); System.out.println("hydrate temperature 1 " - + (inletGasCooler.getOutStream().getHydrateEquilibriumTemperature() - 273.15) + + (inletGasCooler.getOutletStream().getHydrateEquilibriumTemperature() - 273.15) + " wt% MEG " - + inletGasCooler.getOutStream().getFluid().getPhase("aqueous").getWtFrac("MEG") + + inletGasCooler.getOutletStream().getFluid().getPhase("aqueous").getWtFrac("MEG") * 100.0); operations.save("c:/temp/MEGdehydrationProcess.neqsim"); diff --git a/src/test/java/neqsim/processSimulation/util/example/OnshoreProcess1.java b/src/test/java/neqsim/processSimulation/util/example/OnshoreProcess1.java index 171ff55fa4..7499f24fa8 100644 --- a/src/test/java/neqsim/processSimulation/util/example/OnshoreProcess1.java +++ b/src/test/java/neqsim/processSimulation/util/example/OnshoreProcess1.java @@ -251,7 +251,8 @@ public static void main(String args[]) { MEGmixer1.addStream(MEGstream_1); MEGmixer1.addStream(snohvitFormationWaterStream); - ThrottlingValve valve1 = new ThrottlingValve("snohvit valve", MEGmixer1.getOutStream()); + ThrottlingValve valve1 = + new ThrottlingValve("snohvit valve", MEGmixer1.getOutletStream()); valve1.setOutletPressure(125.0); // Albatross reservoir stream @@ -272,15 +273,16 @@ public static void main(String args[]) { // Field mixer Mixer mixer1 = new Mixer("Field Mixer"); - mixer1.addStream(valve1.getOutStream()); - mixer1.addStream(valve2.getOutStream()); + mixer1.addStream(valve1.getOutletStream()); + mixer1.addStream(valve2.getOutletStream()); - WaterContentAnalyser waterAnalyser3 = new WaterContentAnalyser(mixer1.getOutStream()); + WaterContentAnalyser waterAnalyser3 = + new WaterContentAnalyser(mixer1.getOutletStream()); waterAnalyser3.setName("Total Water Analyser"); // Pipeline SimpleTPoutPipeline pipeLine1 = - new SimpleTPoutPipeline("snohvit pipeline", mixer1.getOutStream()); + new SimpleTPoutPipeline("snohvit pipeline", mixer1.getOutletStream()); pipeLine1.setOutPressure(55.0); pipeLine1.setOutTemperature(273.15 + 5.0); pipeLine1.setNumberOfLegs(1); @@ -293,7 +295,7 @@ public static void main(String args[]) { // // Land plant ThreePhaseSeparator slugCatcher = - new ThreePhaseSeparator("slugCatcher", pipeLine1.getOutStream()); + new ThreePhaseSeparator("slugCatcher", pipeLine1.getOutletStream()); VolumeFlowTransmitter volumeTransmitter2 = new VolumeFlowTransmitter(slugCatcher.getOilOutStream()); @@ -323,7 +325,7 @@ public static void main(String args[]) { ThreePhaseSeparator condensateSeparator = new ThreePhaseSeparator("condensateSeparator", - condensateheater1.getOutStream()); + condensateheater1.getOutletStream()); // Heater MEGheater1 = new Heater(stream_5); // MEGheater1.setName("MEG heater1"); diff --git a/src/test/java/neqsim/processSimulation/util/example/TEGAbsorberTest.java b/src/test/java/neqsim/processSimulation/util/example/TEGAbsorberTest.java index e1d28d4d9f..3646a97a4f 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TEGAbsorberTest.java +++ b/src/test/java/neqsim/processSimulation/util/example/TEGAbsorberTest.java @@ -61,7 +61,7 @@ public static void main(String args[]) { ThrottlingValve TEG_HPLP_valve = new ThrottlingValve("ventil", TEGStreamOut); TEG_HPLP_valve.setOutletPressure(10.0); - Separator MPseparator = new Separator("Separator_MP", TEG_HPLP_valve.getOutStream()); + Separator MPseparator = new Separator("Separator_MP", TEG_HPLP_valve.getOutletStream()); StreamInterface MPstreamGas = MPseparator.getGasOutStream(); MPstreamGas.setName("MPGasStream"); @@ -72,7 +72,7 @@ public static void main(String args[]) { ThrottlingValve LP_valve = new ThrottlingValve("LPventil", MPstreamLiq); LP_valve.setOutletPressure(1.5); - ReBoiler reboiler = new ReBoiler("reboiler", LP_valve.getOutStream()); + ReBoiler reboiler = new ReBoiler("reboiler", LP_valve.getOutletStream()); reboiler.setReboilerDuty(20000.0); neqsim.thermo.system.SystemSrkEos testSystem3 = @@ -86,10 +86,10 @@ public static void main(String args[]) { Stream mixStream = new Stream("mixStream", testSystem3); Mixer mix = new Mixer("mixer"); - mix.addStream(reboiler.getOutStream()); + mix.addStream(reboiler.getOutletStream()); mix.addStream(mixStream); - StreamInterface ReboilLiqStream = mix.getOutStream(); + StreamInterface ReboilLiqStream = mix.getOutletStream(); ReboilLiqStream.setName("ReboilLiqStream"); // Stream ReboilGasStream = reboiler.getOutStream(); diff --git a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcess2.java b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcess2.java index 25349a2bf2..0cec3f2957 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcess2.java +++ b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcess2.java @@ -58,7 +58,7 @@ public static void main(String[] args) { StreamSaturatorUtil saturatedFeedGas = new StreamSaturatorUtil("water saturator", dryFeedGas); Stream waterSaturatedFeedGas = - new Stream("waterSaturatedFeedGas", saturatedFeedGas.getOutStream()); + new Stream("waterSaturatedFeedGas", saturatedFeedGas.getOutletStream()); neqsim.thermo.system.SystemInterface feedTEG = feedGas.clone(); feedTEG.setMolarComposition( new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.02, 0.98}); @@ -82,14 +82,15 @@ public static void main(String[] args) { glycol_flash_valve.setOutletPressure(4.9); Heater richGLycolHeaterCondenser = - new Heater("rich TEG preheater", glycol_flash_valve.getOutStream()); + new Heater("rich TEG preheater", glycol_flash_valve.getOutletStream()); richGLycolHeaterCondenser.setOutTemperature(273.15 + 35.5); Heater richGLycolHeater = - new Heater("rich TEG heater HP", richGLycolHeaterCondenser.getOutStream()); + new Heater("rich TEG heater HP", richGLycolHeaterCondenser.getOutletStream()); richGLycolHeater.setOutTemperature(273.15 + 62.0); - Separator flashSep = new Separator("degasing separator", richGLycolHeater.getOutStream()); + Separator flashSep = + new Separator("degasing separator", richGLycolHeater.getOutletStream()); Stream flashGas = new Stream("gas from degasing separator", flashSep.getGasOutStream()); Stream flashLiquid = new Stream("liquid from degasing separator", flashSep.getLiquidOutStream()); @@ -99,12 +100,12 @@ public static void main(String[] args) { richGLycolHeater2.setOutPressure(1.23); Mixer mixerTOreboiler = new Mixer("reboil mxer"); - mixerTOreboiler.addStream(richGLycolHeater2.getOutStream()); + mixerTOreboiler.addStream(richGLycolHeater2.getOutletStream()); - Heater heaterToReboiler = new Heater("heaterToReboiler", mixerTOreboiler.getOutStream()); + Heater heaterToReboiler = new Heater("heaterToReboiler", mixerTOreboiler.getOutletStream()); heaterToReboiler.setOutTemperature(273.15 + 206.6); - Separator regenerator2 = new Separator("regenerator2", heaterToReboiler.getOutStream()); + Separator regenerator2 = new Separator("regenerator2", heaterToReboiler.getOutletStream()); Stream gasFromRegenerator = new Stream("gasFromRegenerator", regenerator2.getGasOutStream()); @@ -114,7 +115,7 @@ public static void main(String[] args) { sepregenGasCooler.setOutPressure(1.23); // sepregenGasCooler.setEnergyStream(richGLycolHeaterCondenser.getEnergyStream()); - Separator sepRegen = new Separator("sepRegen", sepregenGasCooler.getOutStream()); + Separator sepRegen = new Separator("sepRegen", sepregenGasCooler.getOutletStream()); Stream liquidRegenReflux = new Stream("liquidRegenReflux", sepRegen.getLiquidOutStream()); @@ -124,7 +125,7 @@ public static void main(String[] args) { Heater coolerRegenGas = new Heater("coolerRegenGas", sepRegen.getGasOutStream()); coolerRegenGas.setOutTemperature(273.15 + 35.5); - Separator sepregenGas = new Separator("sepregenGas", coolerRegenGas.getOutStream()); + Separator sepregenGas = new Separator("sepregenGas", coolerRegenGas.getOutletStream()); Stream gasToFlare = new Stream("gasToFlare", sepregenGas.getGasOutStream()); @@ -154,20 +155,20 @@ public static void main(String[] args) { Pump hotLeanTEGPump = new Pump("hot lean TEG pump", stripper.getSolventOutStream()); hotLeanTEGPump.setOutletPressure(20.0); - Heater coolerhOTteg = new Heater("hot lean TEG cooler", hotLeanTEGPump.getOutStream()); + Heater coolerhOTteg = new Heater("hot lean TEG cooler", hotLeanTEGPump.getOutletStream()); coolerhOTteg.setOutTemperature(273.15 + 116.8); Heater coolerhOTteg2 = - new Heater("medium hot lean TEG cooler", coolerhOTteg.getOutStream()); + new Heater("medium hot lean TEG cooler", coolerhOTteg.getOutletStream()); coolerhOTteg2.setOutTemperature(273.15 + 89.3); - Heater coolerhOTteg3 = new Heater("lean TEG cooler", coolerhOTteg2.getOutStream()); + Heater coolerhOTteg3 = new Heater("lean TEG cooler", coolerhOTteg2.getOutletStream()); coolerhOTteg3.setOutTemperature(273.15 + 44.85); - Pump hotLeanTEGPump2 = new Pump("lean TEG HP pump", coolerhOTteg3.getOutStream()); + Pump hotLeanTEGPump2 = new Pump("lean TEG HP pump", coolerhOTteg3.getOutletStream()); hotLeanTEGPump2.setOutletPressure(52.21); - Stream leanTEGtoabs = new Stream("lean TEG to absorber", hotLeanTEGPump2.getOutStream()); + Stream leanTEGtoabs = new Stream("lean TEG to absorber", hotLeanTEGPump2.getOutletStream()); neqsim.thermo.system.SystemInterface pureTEG = feedGas.clone(); pureTEG.setMolarComposition( @@ -190,7 +191,7 @@ public static void main(String[] args) { makeupMixer.addStream(makeupTEG); Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); - resycleLeanTEG.addStream(makeupMixer.getOutStream()); + resycleLeanTEG.addStream(makeupMixer.getOutletStream()); neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem(); @@ -238,7 +239,7 @@ public static void main(String[] args) { operations.add(resycleLeanTEG); operations.run(); - richGLycolHeater2.getOutStream().getFluid().display(); + richGLycolHeater2.getOutletStream().getFluid().display(); System.out.println("Energy reboiler " + heaterToReboiler.getDuty()); mixerTOreboiler.addStream(liquidRegenReflux); mixerTOreboiler.addStream(resycle3.getOutStream()); diff --git a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillation.java b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillation.java index fa1cbb6599..2eefd621ca 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillation.java +++ b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillation.java @@ -64,7 +64,7 @@ public static void main(String[] args) { new StreamSaturatorUtil("water saturator", dryFeedGas); Stream waterSaturatedFeedGas = - new Stream("water saturated feed gas", saturatedFeedGas.getOutStream()); + new Stream("water saturated feed gas", saturatedFeedGas.getOutletStream()); neqsim.thermo.system.SystemInterface feedTEG = feedGas.clone(); feedTEG.setMolarComposition( @@ -89,10 +89,10 @@ public static void main(String[] args) { glycol_flash_valve.setOutletPressure(4.9); Heater richGLycolHeaterCondenser = - new Heater("rich TEG preheater", glycol_flash_valve.getOutStream()); + new Heater("rich TEG preheater", glycol_flash_valve.getOutletStream()); HeatExchanger heatEx2 = new HeatExchanger("rich TEG heat exchanger 1", - richGLycolHeaterCondenser.getOutStream()); + richGLycolHeaterCondenser.getOutletStream()); heatEx2.setGuessOutTemperature(273.15 + 62.0); heatEx2.setUAvalue(220.0); @@ -126,7 +126,7 @@ public static void main(String[] args) { DistillationColumn column = new DistillationColumn(1, true, true); column.setName("TEG regeneration column"); - column.addFeedStream(glycol_flash_valve2.getOutStream(), 0); + column.addFeedStream(glycol_flash_valve2.getOutletStream(), 0); column.getReboiler().setOutTemperature(273.15 + 206.6); column.getCondenser().setOutTemperature(273.15 + 100.0); column.getReboiler().addStream(gasToReboiler); @@ -136,7 +136,8 @@ public static void main(String[] args) { Heater coolerRegenGas = new Heater("regen gas cooler", column.getGasOutStream()); coolerRegenGas.setOutTemperature(273.15 + 35.5); - Separator sepregenGas = new Separator("regen gas separator", coolerRegenGas.getOutStream()); + Separator sepregenGas = + new Separator("regen gas separator", coolerRegenGas.getOutletStream()); Stream gasToFlare = new Stream("gas to flare", sepregenGas.getGasOutStream()); @@ -156,22 +157,22 @@ public static void main(String[] args) { Heater bufferTank = new Heater("TEG buffer tank", stripper.getSolventOutStream()); bufferTank.setOutTemperature(273.15 + 185.0); - Pump hotLeanTEGPump = new Pump("hot lean TEG pump",bufferTank.getOutStream());// stripper.getSolventOutStream()); + Pump hotLeanTEGPump = new Pump("hot lean TEG pump", bufferTank.getOutletStream());// stripper.getSolventOutStream()); hotLeanTEGPump.setOutletPressure(20.0); hotLeanTEGPump.setIsentropicEfficiency(0.75); - heatEx.setFeedStream(1, hotLeanTEGPump.getOutStream()); + heatEx.setFeedStream(1, hotLeanTEGPump.getOutletStream()); heatEx2.setFeedStream(1, heatEx.getOutStream(1)); Heater coolerhOTteg3 = new Heater("lean TEG cooler",heatEx2.getOutStream(1)); coolerhOTteg3.setOutTemperature(273.15 + 43.0); - Pump hotLeanTEGPump2 = new Pump("lean TEG HP pump",coolerhOTteg3.getOutStream()); + Pump hotLeanTEGPump2 = new Pump("lean TEG HP pump", coolerhOTteg3.getOutletStream()); hotLeanTEGPump2.setOutletPressure(52.21); hotLeanTEGPump2.setIsentropicEfficiency(0.75); - Stream leanTEGtoabs = new Stream("lean TEG to absorber",hotLeanTEGPump2.getOutStream()); + Stream leanTEGtoabs = new Stream("lean TEG to absorber", hotLeanTEGPump2.getOutletStream()); neqsim.thermo.system.SystemInterface pureTEG = feedGas.clone(); pureTEG.setMolarComposition( @@ -194,7 +195,7 @@ public static void main(String[] args) { makeupMixer.addStream(makeupTEG); Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); - resycleLeanTEG.addStream(makeupMixer.getOutStream()); + resycleLeanTEG.addStream(makeupMixer.getOutletStream()); resycleLeanTEG.setOutletStream(TEGFeed); resycleLeanTEG.setPriority(200); resycleLeanTEG.setDownstreamProperty("flow rate"); @@ -279,7 +280,7 @@ public static void main(String[] args) { System.out.println("flow rate from stripping column " + stripper.getLiquidOutStream().getFlowRate("kg/hr")); System.out.println("flow rate from pump2 " - + hotLeanTEGPump2.getOutStream().getFluid().getFlowRate("kg/hr")); + + hotLeanTEGPump2.getOutletStream().getFluid().getFlowRate("kg/hr")); System.out.println("makeup TEG " + makeupTEG.getFluid().getFlowRate("kg/hr")); TEGFeed.getFluid().display(); @@ -290,12 +291,12 @@ public static void main(String[] args) { System.out.println("wt lean TEG after reboiler " + column.getLiquidOutStream().getFluid().getPhase("aqueous").getWtFrac("TEG")); System.out.println("temperature from pump " - + (hotLeanTEGPump2.getOutStream().getTemperature() - 273.15)); + + (hotLeanTEGPump2.getOutletStream().getTemperature() - 273.15)); System.out.println("flow rate from reboiler " + ((Reboiler) column.getReboiler()).getLiquidOutStream().getFlowRate("kg/hr")); System.out.println("flow rate from pump2 " - + hotLeanTEGPump2.getOutStream().getFluid().getFlowRate("kg/hr")); + + hotLeanTEGPump2.getOutletStream().getFluid().getFlowRate("kg/hr")); System.out.println("flow rate to flare " + gasToFlare.getFluid().getFlowRate("kg/hr")); System.out.println("condenser duty " @@ -304,23 +305,24 @@ public static void main(String[] args) { System.out.println("richGLycolHeaterCondenser duty " + richGLycolHeaterCondenser.getEnergyStream().getDuty() / 1.0e3); System.out.println("richGLycolHeaterCondenser temperature out " - + richGLycolHeaterCondenser.getOutStream().getTemperature("C")); + + richGLycolHeaterCondenser.getOutletStream().getTemperature("C")); richGLycolHeaterCondenser.run(); - hotLeanTEGPump.getOutStream().displayResult(); + hotLeanTEGPump.getOutletStream().displayResult(); flashLiquid.displayResult(); System.out.println("Temperature rich TEG out of reflux condenser " - + richGLycolHeaterCondenser.getOutStream().getTemperature("C")); + + richGLycolHeaterCondenser.getOutletStream().getTemperature("C")); heatEx.displayResult(); System.out.println("glycol out temperature " - + glycol_flash_valve2.getOutStream().getFluid().getTemperature("C")); + + glycol_flash_valve2.getOutletStream().getFluid().getTemperature("C")); System.out .println("glycol out temperature2 " + heatEx2.getOutStream(0).getTemperature("C")); System.out .println("glycol out temperature2 " + heatEx2.getOutStream(1).getTemperature("C")); - System.out.println("out water rate LP valve" + glycol_flash_valve2.getOutStream().getFluid() + System.out.println("out water rate LP valve" + glycol_flash_valve2.getOutletStream() + .getFluid() .getPhase(0).getComponent("water").getNumberOfmoles()); System.out.println("glycol out water rate reboil " + ((Reboiler) column.getReboiler()) .getLiquidOutStream().getFluid().getComponent("water").getNumberOfmoles()); diff --git a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillation3.java b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillation3.java index 0c862366e1..0da0ab4c06 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillation3.java +++ b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillation3.java @@ -64,7 +64,7 @@ public static void main(String[] args) { new StreamSaturatorUtil("water saturator", dryFeedGas); Stream waterSaturatedFeedGas = - new Stream("water saturated feed gas", saturatedFeedGas.getOutStream()); + new Stream("water saturated feed gas", saturatedFeedGas.getOutletStream()); neqsim.thermo.system.SystemInterface feedTEG = feedGas.clone(); feedTEG.setMolarComposition( @@ -89,13 +89,14 @@ public static void main(String[] args) { glycol_flash_valve.setOutletPressure(4.9); Heater richGLycolHeaterCondenser = - new Heater("rich TEG preheater", glycol_flash_valve.getOutStream()); + new Heater("rich TEG preheater", glycol_flash_valve.getOutletStream()); Heater richGLycolHeater = - new Heater("rich TEG heater HP", richGLycolHeaterCondenser.getOutStream()); + new Heater("rich TEG heater HP", richGLycolHeaterCondenser.getOutletStream()); richGLycolHeater.setOutTemperature(273.15 + 62.0); - Separator flashSep = new Separator("degasing separator", richGLycolHeater.getOutStream()); + Separator flashSep = + new Separator("degasing separator", richGLycolHeater.getOutletStream()); Stream flashGas = new Stream("gas from degasing separator", flashSep.getGasOutStream()); @@ -120,7 +121,7 @@ public static void main(String[] args) { DistillationColumn column = new DistillationColumn(1, true, true); column.setName("TEG regeneration column"); - column.addFeedStream(richGLycolHeater2.getOutStream(), 0); + column.addFeedStream(richGLycolHeater2.getOutletStream(), 0); column.getReboiler().setOutTemperature(273.15 + 206.6); column.getCondenser().setOutTemperature(273.15 + 101.0); column.getReboiler().addStream(gasToReboiler); @@ -130,7 +131,8 @@ public static void main(String[] args) { Heater coolerRegenGas = new Heater("regen gas cooler", column.getGasOutStream()); coolerRegenGas.setOutTemperature(273.15 + 35.5); - Separator sepregenGas = new Separator("regen gas separator", coolerRegenGas.getOutStream()); + Separator sepregenGas = + new Separator("regen gas separator", coolerRegenGas.getOutletStream()); Stream gasToFlare = new Stream("gas to flare", sepregenGas.getGasOutStream()); @@ -150,25 +152,25 @@ public static void main(String[] args) { Heater bufferTank = new Heater("TEG buffer tank", stripper.getSolventOutStream()); bufferTank.setOutTemperature(273.15 + 185.0); - Pump hotLeanTEGPump = new Pump("hot lean TEG pump", bufferTank.getOutStream()); + Pump hotLeanTEGPump = new Pump("hot lean TEG pump", bufferTank.getOutletStream()); hotLeanTEGPump.setOutletPressure(20.0); hotLeanTEGPump.setIsentropicEfficiency(0.75); - Heater coolerhOTteg = new Heater("hot lean TEG cooler", hotLeanTEGPump.getOutStream()); + Heater coolerhOTteg = new Heater("hot lean TEG cooler", hotLeanTEGPump.getOutletStream()); coolerhOTteg.setOutTemperature(273.15 + 116.8); Heater coolerhOTteg2 = - new Heater("medium hot lean TEG cooler", coolerhOTteg.getOutStream()); + new Heater("medium hot lean TEG cooler", coolerhOTteg.getOutletStream()); coolerhOTteg2.setOutTemperature(273.15 + 89.3); - Heater coolerhOTteg3 = new Heater("lean TEG cooler", coolerhOTteg2.getOutStream()); + Heater coolerhOTteg3 = new Heater("lean TEG cooler", coolerhOTteg2.getOutletStream()); coolerhOTteg3.setOutTemperature(273.15 + 43.0); - Pump hotLeanTEGPump2 = new Pump("lean TEG HP pump", coolerhOTteg3.getOutStream()); + Pump hotLeanTEGPump2 = new Pump("lean TEG HP pump", coolerhOTteg3.getOutletStream()); hotLeanTEGPump2.setOutletPressure(52.21); hotLeanTEGPump2.setIsentropicEfficiency(0.75); - Stream leanTEGtoabs = new Stream("lean TEG to absorber", hotLeanTEGPump2.getOutStream()); + Stream leanTEGtoabs = new Stream("lean TEG to absorber", hotLeanTEGPump2.getOutletStream()); neqsim.thermo.system.SystemInterface pureTEG = feedGas.clone(); pureTEG.setMolarComposition( @@ -191,7 +193,7 @@ public static void main(String[] args) { makeupMixer.addStream(makeupTEG); Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); - resycleLeanTEG.addStream(makeupMixer.getOutStream()); + resycleLeanTEG.addStream(makeupMixer.getOutletStream()); resycleLeanTEG.setOutletStream(TEGFeed); resycleLeanTEG.setPriority(200); resycleLeanTEG.setDownstreamProperty("flow rate"); @@ -277,7 +279,7 @@ public static void main(String[] args) { System.out.println("flow rate from stripping column " + stripper.getLiquidOutStream().getFlowRate("kg/hr")); System.out.println("flow rate from pump2 " - + hotLeanTEGPump2.getOutStream().getFluid().getFlowRate("kg/hr")); + + hotLeanTEGPump2.getOutletStream().getFluid().getFlowRate("kg/hr")); System.out.println("makeup TEG " + makeupTEG.getFluid().getFlowRate("kg/hr")); TEGFeed.getFluid().display(); @@ -288,26 +290,26 @@ public static void main(String[] args) { System.out.println("wt lean TEG after reboiler " + column.getLiquidOutStream().getFluid().getPhase("aqueous").getWtFrac("TEG")); System.out.println("temperature from pump " - + (hotLeanTEGPump2.getOutStream().getTemperature() - 273.15)); + + (hotLeanTEGPump2.getOutletStream().getTemperature() - 273.15)); System.out.println("flow rate from reboiler " + ((Reboiler) column.getReboiler()).getLiquidOutStream().getFlowRate("kg/hr")); System.out.println("flow rate from pump2 " - + hotLeanTEGPump2.getOutStream().getFluid().getFlowRate("kg/hr")); + + hotLeanTEGPump2.getOutletStream().getFluid().getFlowRate("kg/hr")); System.out.println("condenser duty " + ((Condenser) ((DistillationColumn) operations.getUnit("TEG regeneration column")) .getCondenser()).getDuty() / 1.0e3); System.out.println("richGLycolHeaterCondenser duty " + richGLycolHeaterCondenser.getEnergyStream().getDuty() / 1.0e3); System.out.println("richGLycolHeaterCondenser temperature out " - + richGLycolHeaterCondenser.getOutStream().getTemperature("C")); + + richGLycolHeaterCondenser.getOutletStream().getTemperature("C")); richGLycolHeaterCondenser.run(); - hotLeanTEGPump.getOutStream().displayResult(); + hotLeanTEGPump.getOutletStream().displayResult(); flashLiquid.displayResult(); HeatExchanger heatEx = - new HeatExchanger("heatEx", flashLiquid, hotLeanTEGPump.getOutStream()); + new HeatExchanger("heatEx", flashLiquid, hotLeanTEGPump.getOutletStream()); heatEx.setUAvalue(350.0); heatEx.run(); heatEx.displayResult(); diff --git a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationAaHa.java b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationAaHa.java index 6d50e6c621..caa29e84d7 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationAaHa.java +++ b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationAaHa.java @@ -65,7 +65,7 @@ public static neqsim.processSimulation.processSystem.ProcessSystem getProcess() new StreamSaturatorUtil("water saturator", dryFeedGas); Stream waterSaturatedFeedGas = - new Stream("water saturated feed gas", saturatedFeedGas.getOutStream()); + new Stream("water saturated feed gas", saturatedFeedGas.getOutletStream()); HydrateEquilibriumTemperatureAnalyser hydrateTAnalyser = new HydrateEquilibriumTemperatureAnalyser(waterSaturatedFeedGas); @@ -80,7 +80,7 @@ public static neqsim.processSimulation.processSystem.ProcessSystem getProcess() feedTPsetterToAbsorber.setOutTemperature(27.93, "C"); Stream feedToAbsorber = - new Stream("feed to TEG absorber", feedTPsetterToAbsorber.getOutStream()); + new Stream("feed to TEG absorber", feedTPsetterToAbsorber.getOutletStream()); Stream TEGFeed = new Stream("lean TEG to absorber", feedTEG); TEGFeed.setFlowRate(14.68 * 1100.0, "kg/hr"); @@ -110,10 +110,10 @@ public static neqsim.processSimulation.processSystem.ProcessSystem getProcess() glycol_flash_valve.setOutletPressure(5.5); Heater richGLycolHeaterCondenser = - new Heater("rich TEG preheater", glycol_flash_valve.getOutStream()); + new Heater("rich TEG preheater", glycol_flash_valve.getOutletStream()); HeatExchanger heatEx2 = new HeatExchanger("rich TEG heat exchanger 1", - richGLycolHeaterCondenser.getOutStream()); + richGLycolHeaterCondenser.getOutletStream()); heatEx2.setGuessOutTemperature(273.15 + 62.0); heatEx2.setUAvalue(200.0); @@ -127,11 +127,11 @@ public static neqsim.processSimulation.processSystem.ProcessSystem getProcess() Filter fineFilter = new Filter("TEG fine filter", flashLiquid); fineFilter.setDeltaP(0.05, "bara"); - Filter carbonFilter = new Filter("activated carbon filter", fineFilter.getOutStream()); + Filter carbonFilter = new Filter("activated carbon filter", fineFilter.getOutletStream()); carbonFilter.setDeltaP(0.01, "bara"); HeatExchanger heatEx = - new HeatExchanger("rich TEG heat exchanger 2", carbonFilter.getOutStream()); + new HeatExchanger("rich TEG heat exchanger 2", carbonFilter.getOutletStream()); heatEx.setGuessOutTemperature(273.15 + 130.0); heatEx.setUAvalue(390.0); @@ -154,7 +154,7 @@ public static neqsim.processSimulation.processSystem.ProcessSystem getProcess() DistillationColumn column = new DistillationColumn(1, true, true); column.setName("TEG regeneration column"); - column.addFeedStream(glycol_flash_valve2.getOutStream(), 0); + column.addFeedStream(glycol_flash_valve2.getOutletStream(), 0); column.getReboiler().setOutTemperature(273.15 + 201.0); column.getCondenser().setOutTemperature(273.15 + 92.0); column.getReboiler().addStream(gasToReboiler); @@ -164,7 +164,8 @@ public static neqsim.processSimulation.processSystem.ProcessSystem getProcess() Heater coolerRegenGas = new Heater("regen gas cooler", column.getGasOutStream()); coolerRegenGas.setOutTemperature(273.15 + 7.5); - Separator sepregenGas = new Separator("regen gas separator", coolerRegenGas.getOutStream()); + Separator sepregenGas = + new Separator("regen gas separator", coolerRegenGas.getOutletStream()); Stream gasToFlare = new Stream("gas to flare", sepregenGas.getGasOutStream()); @@ -188,25 +189,25 @@ public static neqsim.processSimulation.processSystem.ProcessSystem getProcess() Heater bufferTank = new Heater("TEG buffer tank", stripper.getLiquidOutStream()); bufferTank.setOutTemperature(273.15 + 191.0); - Pump hotLeanTEGPump = new Pump("hot lean TEG pump", bufferTank.getOutStream());// stripper.getSolventOutStream()); + Pump hotLeanTEGPump = new Pump("hot lean TEG pump", bufferTank.getOutletStream());// stripper.getSolventOutStream()); hotLeanTEGPump.setOutletPressure(5.0); hotLeanTEGPump.setIsentropicEfficiency(0.6); - heatEx.setFeedStream(1, hotLeanTEGPump.getOutStream()); + heatEx.setFeedStream(1, hotLeanTEGPump.getOutletStream()); heatEx2.setFeedStream(1, heatEx.getOutStream(1)); Heater coolerhOTteg3 = new Heater("lean TEG cooler", heatEx2.getOutStream(1)); coolerhOTteg3.setOutTemperature(273.15 + 35.41); - Pump hotLeanTEGPump2 = new Pump("lean TEG HP pump", coolerhOTteg3.getOutStream()); + Pump hotLeanTEGPump2 = new Pump("lean TEG HP pump", coolerhOTteg3.getOutletStream()); hotLeanTEGPump2.setOutletPressure(87.2); hotLeanTEGPump2.setIsentropicEfficiency(0.75); SetPoint pumpHPPresSet = new SetPoint("HP pump set", hotLeanTEGPump2, "pressure", feedToAbsorber); - Stream leanTEGtoabs = new Stream("lean TEG to absorber", hotLeanTEGPump2.getOutStream()); + Stream leanTEGtoabs = new Stream("lean TEG to absorber", hotLeanTEGPump2.getOutletStream()); neqsim.thermo.system.SystemInterface pureTEG = feedGas.clone(); pureTEG.setMolarComposition(new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, @@ -229,7 +230,7 @@ public static neqsim.processSimulation.processSystem.ProcessSystem getProcess() makeupMixer.addStream(makeupTEG); Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); - resycleLeanTEG.addStream(makeupMixer.getOutStream()); + resycleLeanTEG.addStream(makeupMixer.getOutletStream()); resycleLeanTEG.setOutletStream(TEGFeed); resycleLeanTEG.setPriority(200); resycleLeanTEG.setDownstreamProperty("flow rate"); diff --git a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationGFA.java b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationGFA.java index c53cbd185e..1791694fc4 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationGFA.java +++ b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationGFA.java @@ -193,7 +193,7 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { new StreamSaturatorUtil("water saturator", dryFeedGas); Stream waterSaturatedFeedGas = - new Stream("water saturated feed gas", saturatedFeedGas.getOutStream()); + new Stream("water saturated feed gas", saturatedFeedGas.getOutletStream()); HydrateEquilibriumTemperatureAnalyser hydrateTAnalyser = new HydrateEquilibriumTemperatureAnalyser(waterSaturatedFeedGas); @@ -208,7 +208,7 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { feedTPsetterToAbsorber.setOutTemperature(absorberFeedGasTemperature, "C"); Stream feedToAbsorber = - new Stream("feed to TEG absorber", feedTPsetterToAbsorber.getOutStream()); + new Stream("feed to TEG absorber", feedTPsetterToAbsorber.getOutletStream()); Stream TEGFeed = new Stream("lean TEG to absorber", feedTEG); TEGFeed.setFlowRate(leanTEGFlowRate, "kg/hr"); @@ -237,10 +237,10 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { glycol_flash_valve.setOutletPressure(flashDrumPressure); Heater richGLycolHeaterCondenser = - new Heater("rich TEG preheater", glycol_flash_valve.getOutStream()); + new Heater("rich TEG preheater", glycol_flash_valve.getOutletStream()); HeatExchanger heatEx2 = new HeatExchanger("rich TEG heat exchanger 1", - richGLycolHeaterCondenser.getOutStream()); + richGLycolHeaterCondenser.getOutletStream()); heatEx2.setGuessOutTemperature(273.15 + 62.0); heatEx2.setUAvalue(UAvalueRichTEGHeatExchanger_1); @@ -254,7 +254,7 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { Filter filter = new Filter("filters", flashLiquid); HeatExchanger heatEx = - new HeatExchanger("rich TEG heat exchanger 2", filter.getOutStream()); + new HeatExchanger("rich TEG heat exchanger 2", filter.getOutletStream()); heatEx.setGuessOutTemperature(273.15 + 130.0); heatEx.setUAvalue(UAvalueRichTEGHeatExchanger_2); @@ -275,7 +275,7 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { DistillationColumn column = new DistillationColumn(3, true, true); column.setName("TEG regeneration column"); - column.addFeedStream(glycol_flash_valve2.getOutStream(), 1); + column.addFeedStream(glycol_flash_valve2.getOutletStream(), 1); column.getReboiler().setOutTemperature(273.15 + reboilerTemperature); column.getCondenser().setOutTemperature(273.15 + condenserTemperature); column.getReboiler().addStream(gasToReboiler); @@ -285,7 +285,8 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { Heater coolerRegenGas = new Heater("regen gas cooler", column.getGasOutStream()); coolerRegenGas.setOutTemperature(273.15 + regenerationGasCoolerTemperature); - Separator sepregenGas = new Separator("regen gas separator", coolerRegenGas.getOutStream()); + Separator sepregenGas = + new Separator("regen gas separator", coolerRegenGas.getOutletStream()); Stream gasToFlare = new Stream("gas to flare", sepregenGas.getGasOutStream()); @@ -305,25 +306,25 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { Heater bufferTank = new Heater("TEG buffer tank", stripper.getSolventOutStream()); bufferTank.setOutTemperature(273.15 + bufferTankTemperatureTEG); - Pump hotLeanTEGPump = new Pump("hot lean TEG pump", bufferTank.getOutStream());// stripper.getSolventOutStream()); + Pump hotLeanTEGPump = new Pump("hot lean TEG pump", bufferTank.getOutletStream());// stripper.getSolventOutStream()); hotLeanTEGPump.setOutletPressure(hotTEGpumpPressure); hotLeanTEGPump.setIsentropicEfficiency(hotTEGpumpIsentropicEfficiency); - heatEx.setFeedStream(1, hotLeanTEGPump.getOutStream()); + heatEx.setFeedStream(1, hotLeanTEGPump.getOutletStream()); heatEx2.setFeedStream(1, heatEx.getOutStream(1)); Heater coolerhOTteg3 = new Heater("lean TEG cooler", heatEx2.getOutStream(1)); coolerhOTteg3.setOutTemperature(273.15 + leanTEGTemperature); - Pump hotLeanTEGPump2 = new Pump("lean TEG HP pump", coolerhOTteg3.getOutStream()); + Pump hotLeanTEGPump2 = new Pump("lean TEG HP pump", coolerhOTteg3.getOutletStream()); hotLeanTEGPump2.setOutletPressure(absorberFeedGasPressure); hotLeanTEGPump2.setIsentropicEfficiency(coldTEGpumpIsentropicEfficiency); SetPoint pumpHPPresSet = new SetPoint("HP pump set", hotLeanTEGPump2, "pressure", feedToAbsorber); - Stream leanTEGtoabs = new Stream("lean TEG to absorber", hotLeanTEGPump2.getOutStream()); + Stream leanTEGtoabs = new Stream("lean TEG to absorber", hotLeanTEGPump2.getOutletStream()); neqsim.thermo.system.SystemInterface pureTEG = feedGas.clone(); pureTEG.setMolarComposition( @@ -346,7 +347,7 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { makeupMixer.addStream(makeupTEG); Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); - resycleLeanTEG.addStream(makeupMixer.getOutStream()); + resycleLeanTEG.addStream(makeupMixer.getOutletStream()); resycleLeanTEG.setOutletStream(TEGFeed); resycleLeanTEG.setPriority(200); resycleLeanTEG.setDownstreamProperty("flow rate"); @@ -416,7 +417,7 @@ public static void main(String[] args) { // neqsim.processSimulation.processSystem.ProcessSystem.open("c:/temp/TEGprocessGFA.neqsim"); double richTEGtemperature = ((Heater) operations.getUnit("rich TEG preheater")) - .getOutStream().getTemperature("C"); + .getOutletStream().getTemperature("C"); System.out.println("temp rich TEG " + richTEGtemperature); System.out.println("condenser duty (KW) " + ((Condenser) ((DistillationColumn) operations.getUnit("TEG regeneration column")) diff --git a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationJS.java b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationJS.java index 566a260474..6e69ca0ab6 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationJS.java +++ b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationJS.java @@ -198,7 +198,7 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { new StreamSaturatorUtil("water saturator", dryFeedGas); Stream waterSaturatedFeedGas = - new Stream("water saturated feed gas", saturatedFeedGas.getOutStream()); + new Stream("water saturated feed gas", saturatedFeedGas.getOutletStream()); HydrateEquilibriumTemperatureAnalyser hydrateTAnalyser = new HydrateEquilibriumTemperatureAnalyser(waterSaturatedFeedGas); @@ -213,7 +213,7 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { feedTPsetterToAbsorber.setOutTemperature(absorberFeedGasTemperature, "C"); Stream feedToAbsorber = - new Stream("feed to TEG absorber", feedTPsetterToAbsorber.getOutStream()); + new Stream("feed to TEG absorber", feedTPsetterToAbsorber.getOutletStream()); Stream TEGFeed = new Stream("lean TEG to absorber", feedTEG); TEGFeed.setFlowRate(leanTEGFlowRate, "kg/hr"); @@ -238,10 +238,10 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { glycol_flash_valve.setOutletPressure(flashDrumPressure); Heater richGLycolHeaterCondenser = - new Heater("rich TEG preheater", glycol_flash_valve.getOutStream()); + new Heater("rich TEG preheater", glycol_flash_valve.getOutletStream()); HeatExchanger heatEx2 = new HeatExchanger("rich TEG heat exchanger 1", - richGLycolHeaterCondenser.getOutStream()); + richGLycolHeaterCondenser.getOutletStream()); heatEx2.setGuessOutTemperature(273.15 + 62.0); heatEx2.setUAvalue(UAvalueRichTEGHeatExchanger_1); @@ -255,11 +255,11 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { Filter fineFilter = new Filter("TEG fine filter", flashLiquid); fineFilter.setDeltaP(0.05, "bara"); - Filter carbonFilter = new Filter("activated carbon filter", fineFilter.getOutStream()); + Filter carbonFilter = new Filter("activated carbon filter", fineFilter.getOutletStream()); carbonFilter.setDeltaP(0.01, "bara"); HeatExchanger heatEx = - new HeatExchanger("rich TEG heat exchanger 2", carbonFilter.getOutStream()); + new HeatExchanger("rich TEG heat exchanger 2", carbonFilter.getOutletStream()); heatEx.setGuessOutTemperature(273.15 + 130.0); heatEx.setUAvalue(UAvalueRichTEGHeatExchanger_2); @@ -280,7 +280,7 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { DistillationColumn column = new DistillationColumn(1, true, true); column.setName("TEG regeneration column"); - column.addFeedStream(glycol_flash_valve2.getOutStream(), 0); + column.addFeedStream(glycol_flash_valve2.getOutletStream(), 0); column.getReboiler().setOutTemperature(273.15 + reboilerTemperature); column.getCondenser().setOutTemperature(273.15 + condenserTemperature); column.getReboiler().addStream(gasToReboiler); @@ -290,7 +290,8 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { Heater coolerRegenGas = new Heater("regen gas cooler", column.getGasOutStream()); coolerRegenGas.setOutTemperature(273.15 + regenerationGasCoolerTemperature); - Separator sepregenGas = new Separator("regen gas separator", coolerRegenGas.getOutStream()); + Separator sepregenGas = + new Separator("regen gas separator", coolerRegenGas.getOutletStream()); Stream gasToFlare = new Stream("gas to flare", sepregenGas.getGasOutStream()); @@ -310,25 +311,25 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { Heater bufferTank = new Heater("TEG buffer tank", stripper.getSolventOutStream()); bufferTank.setOutTemperature(273.15 + bufferTankTemperatureTEG); - Pump hotLeanTEGPump = new Pump("hot lean TEG pump", bufferTank.getOutStream()); + Pump hotLeanTEGPump = new Pump("hot lean TEG pump", bufferTank.getOutletStream()); hotLeanTEGPump.setOutletPressure(hotTEGpumpPressure); hotLeanTEGPump.setIsentropicEfficiency(hotTEGpumpIsentropicEfficiency); - heatEx.setFeedStream(1, hotLeanTEGPump.getOutStream()); + heatEx.setFeedStream(1, hotLeanTEGPump.getOutletStream()); heatEx2.setFeedStream(1, heatEx.getOutStream(1)); Heater coolerhOTteg3 = new Heater("lean TEG cooler", heatEx2.getOutStream(1)); coolerhOTteg3.setOutTemperature(273.15 + leanTEGTemperature); - Pump hotLeanTEGPump2 = new Pump("lean TEG HP pump", coolerhOTteg3.getOutStream()); + Pump hotLeanTEGPump2 = new Pump("lean TEG HP pump", coolerhOTteg3.getOutletStream()); hotLeanTEGPump2.setOutletPressure(absorberFeedGasPressure); hotLeanTEGPump2.setIsentropicEfficiency(coldTEGpumpIsentropicEfficiency); SetPoint pumpHPPresSet = new SetPoint("HP pump set", hotLeanTEGPump2, "pressure", feedToAbsorber); - Stream leanTEGtoabs = new Stream("lean TEG to absorber", hotLeanTEGPump2.getOutStream()); + Stream leanTEGtoabs = new Stream("lean TEG to absorber", hotLeanTEGPump2.getOutletStream()); neqsim.thermo.system.SystemInterface pureTEG = feedGas.clone(); pureTEG.setMolarComposition(new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, @@ -351,7 +352,7 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { makeupMixer.addStream(makeupTEG); Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); - resycleLeanTEG.addStream(makeupMixer.getOutStream()); + resycleLeanTEG.addStream(makeupMixer.getOutletStream()); resycleLeanTEG.setOutletStream(TEGFeed); resycleLeanTEG.setPriority(200); resycleLeanTEG.setDownstreamProperty("flow rate"); diff --git a/src/test/java/neqsim/processSimulation/util/example/TestNeqsim.java b/src/test/java/neqsim/processSimulation/util/example/TestNeqsim.java index b5005bb416..b389ca1234 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TestNeqsim.java +++ b/src/test/java/neqsim/processSimulation/util/example/TestNeqsim.java @@ -61,7 +61,7 @@ public static void main(String[] args) { compressor1.setOutletPressure(26.590909);// (20+5*i) compressor1.setUsePolytropicCalc(true); compressor1.setPolytropicEfficiency(0.64951); - Stream stream2 = new Stream("stream2", compressor1.getOutStream()); + Stream stream2 = new Stream("stream2", compressor1.getOutletStream()); neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem(); @@ -90,7 +90,7 @@ public static void main(String[] args) { + stream1.getThermoSystem().getPhase(0).getSoundSpeed()); compressor1.solveEfficiency(390.15); - compressor1.getOutStream().displayResult(); + compressor1.getOutletStream().displayResult(); System.out.println("Hvap " + stream1.getThermoSystem().getHeatOfVaporization() + " POLI " + compressor1.getPolytropicEfficiency() + " dentity " + stream1.getThermoSystem().getDensity() + " cp " @@ -112,7 +112,7 @@ public static void main(String[] args) { double GVF = volFlowGas / (volFlowGas + volFlowOil + volFlowLiq); System.out.println("inlet stream - GMF " + GMF + " GVF " + GVF + " Z IN " + stream1.getThermoSystem().getZ() + " Z OUT " - + compressor1.getOutStream().getThermoSystem().getZ()); + + compressor1.getOutletStream().getThermoSystem().getZ()); /* * temperature[i] = compressor1.getOutStream().getTemperature(); work [i] = * compressor1.getTotalWork(); diff --git a/src/test/java/neqsim/processSimulation/util/example/TestSeparationTrain.java b/src/test/java/neqsim/processSimulation/util/example/TestSeparationTrain.java index 32b591ce73..e3cbc2a179 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TestSeparationTrain.java +++ b/src/test/java/neqsim/processSimulation/util/example/TestSeparationTrain.java @@ -49,36 +49,36 @@ public static void main(String args[]) { liquidOutHeater.setOutTemperature(273.15 + 55.0); ThreePhaseSeparator firstStageSeparator = - new ThreePhaseSeparator("1st stage Separator", liquidOutHeater.getOutStream()); + new ThreePhaseSeparator("1st stage Separator", liquidOutHeater.getOutletStream()); ThrottlingValve valve1 = new ThrottlingValve("snohvit valve", firstStageSeparator.getOilOutStream()); valve1.setOutletPressure(secondstagePressure); ThreePhaseSeparator secondStageSeparator = - new ThreePhaseSeparator("2nd stage Separator", valve1.getOutStream()); + new ThreePhaseSeparator("2nd stage Separator", valve1.getOutletStream()); ThrottlingValve thirdStageValve = new ThrottlingValve("snohvit valve2", secondStageSeparator.getLiquidOutStream()); thirdStageValve.setOutletPressure(thirdstagePressure); ThreePhaseSeparator thirdStageSeparator = - new ThreePhaseSeparator("3rd stage Separator", thirdStageValve.getOutStream()); + new ThreePhaseSeparator("3rd stage Separator", thirdStageValve.getOutletStream()); Compressor thirdStageCompressor = new Compressor("thirdStageCompressor", thirdStageSeparator.getGasOutStream()); thirdStageCompressor.setOutletPressure(secondstagePressure); - Mixer thirdStageMixer = new Mixer(); - thirdStageMixer.addStream(thirdStageCompressor.getOutStream()); + Mixer thirdStageMixer = new Mixer("thirdStageMixer"); + thirdStageMixer.addStream(thirdStageCompressor.getOutletStream()); thirdStageMixer.addStream(secondStageSeparator.getGasOutStream()); Cooler thirdSstageCoooler = - new Cooler("thirdSstageCoooler", thirdStageMixer.getOutStream()); + new Cooler("thirdSstageCoooler", thirdStageMixer.getOutletStream()); thirdSstageCoooler.setOutTemperature(273.15 + 30.0); ThreePhaseSeparator thirdStageScrubber = new ThreePhaseSeparator( - "Third stage gas resirc scrubber", thirdSstageCoooler.getOutStream()); + "Third stage gas resirc scrubber", thirdSstageCoooler.getOutletStream()); secondStageSeparator.addStream(thirdStageScrubber.getOilOutStream()); secondStageSeparator.addStream(thirdStageScrubber.getWaterOutStream()); @@ -86,18 +86,18 @@ public static void main(String args[]) { new Compressor("secondStageCompressor", thirdStageScrubber.getGasOutStream()); secondStageCompressor.setOutletPressure(inletPressure); - Mixer HPgasMixer = new Mixer(); + Mixer HPgasMixer = new Mixer("HPgasMixer"); HPgasMixer.addStream(inletSeparator.getGasOutStream()); - HPgasMixer.addStream(secondStageCompressor.getOutStream()); + HPgasMixer.addStream(secondStageCompressor.getOutletStream()); Cooler oilCooler = new Cooler("oilCooler", thirdStageSeparator.getLiquidOutStream()); oilCooler.setOutTemperature(273.15 + 30.0); - Cooler inletGasCooler = new Cooler("inletGasCooler", HPgasMixer.getOutStream()); + Cooler inletGasCooler = new Cooler("inletGasCooler", HPgasMixer.getOutletStream()); inletGasCooler.setOutTemperature(273.15 + 30.0); Separator gasInletScrubber = - new Separator("Gas scrubber inlet", inletGasCooler.getOutStream()); + new Separator("Gas scrubber inlet", inletGasCooler.getOutletStream()); Recycle HPliquidRecycle = new Recycle("HPliquidRecycle"); double tolerance = 1e-10; diff --git a/src/test/java/neqsim/processSimulation/util/example/TestSlugcatcher.java b/src/test/java/neqsim/processSimulation/util/example/TestSlugcatcher.java index aa04fb8421..dae8ea8707 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TestSlugcatcher.java +++ b/src/test/java/neqsim/processSimulation/util/example/TestSlugcatcher.java @@ -52,7 +52,7 @@ public static void main(String args[]) { valve1.setOutletPressure(1.4); ThreePhaseSeparator separator2 = - new ThreePhaseSeparator("Separator 1", valve1.getOutStream()); + new ThreePhaseSeparator("Separator 1", valve1.getOutletStream()); Stream stream_2 = new Stream("stream_2", separator2.getGasOutStream()); VolumeFlowTransmitter volumeTransmitter3 = diff --git a/src/test/java/neqsim/processSimulation/util/example/TestTransientFlow.java b/src/test/java/neqsim/processSimulation/util/example/TestTransientFlow.java index 44daa14f16..d732ffee98 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TestTransientFlow.java +++ b/src/test/java/neqsim/processSimulation/util/example/TestTransientFlow.java @@ -57,8 +57,8 @@ public static void main(String args[]) { valve_1.setPercentValveOpening(50); Separator separator_1 = new Separator("separator_1"); - separator_1.addStream(valve_1.getOutStream()); - separator_1.addStream(purgeValve.getOutStream()); + separator_1.addStream(valve_1.getOutletStream()); + separator_1.addStream(purgeValve.getOutletStream()); ThrottlingValve valve_2 = new ThrottlingValve("valve_2", separator_1.getLiquidOutStream()); valve_2.setOutletPressure(5.0); diff --git a/src/test/java/neqsim/processSimulation/util/example/TestTransientFlow2.java b/src/test/java/neqsim/processSimulation/util/example/TestTransientFlow2.java index fbef3f1a5d..2e00c72ce3 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TestTransientFlow2.java +++ b/src/test/java/neqsim/processSimulation/util/example/TestTransientFlow2.java @@ -35,7 +35,7 @@ public static void main(String args[]) { valve_1.setPercentValveOpening(50); Separator separator_1 = new Separator("separator_1"); - separator_1.addStream(valve_1.getOutStream()); + separator_1.addStream(valve_1.getOutletStream()); ThrottlingValve valve_2 = new ThrottlingValve("valve_2", separator_1.getLiquidOutStream()); valve_2.setOutletPressure(1.0); diff --git a/src/test/java/neqsim/processSimulation/util/example/WellStreamMixer.java b/src/test/java/neqsim/processSimulation/util/example/WellStreamMixer.java index 2b8924c901..87cca5fbd0 100644 --- a/src/test/java/neqsim/processSimulation/util/example/WellStreamMixer.java +++ b/src/test/java/neqsim/processSimulation/util/example/WellStreamMixer.java @@ -72,7 +72,7 @@ public static void main(String[] args) { wellStramMixer.addStream(wellStream_1); wellStramMixer.addStream(wellStream_2); - Stream mixerdStream = new Stream("mixed stream", wellStramMixer.getOutStream()); + Stream mixerdStream = new Stream("mixed stream", wellStramMixer.getOutletStream()); neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem(); diff --git a/src/test/java/neqsim/processSimulation/util/example/compressorTest.java b/src/test/java/neqsim/processSimulation/util/example/compressorTest.java index 313b04326e..997421c0a1 100644 --- a/src/test/java/neqsim/processSimulation/util/example/compressorTest.java +++ b/src/test/java/neqsim/processSimulation/util/example/compressorTest.java @@ -35,7 +35,7 @@ public static void main(String args[]) { MixerInterface mixer = new StaticMixer("Mixer 1"); mixer.addStream(stream_1); - StreamInterface stream_3 = mixer.getOutStream(); + StreamInterface stream_3 = mixer.getOutletStream(); stream_3.setName("stream3"); Separator separator = new Separator("Separator 1", stream_3); diff --git a/src/test/java/neqsim/processSimulation/util/example/compressorTest_1.java b/src/test/java/neqsim/processSimulation/util/example/compressorTest_1.java index a2ae2b2c22..922fa4837c 100644 --- a/src/test/java/neqsim/processSimulation/util/example/compressorTest_1.java +++ b/src/test/java/neqsim/processSimulation/util/example/compressorTest_1.java @@ -51,17 +51,18 @@ public static void main(String args[]) { logger.info("power " + comp_1.getTotalWork()); logger.info("speed of sound " - + comp_1.getOutStream().getThermoSystem().getPhase(0).getSoundSpeed()); - logger.info("out temperature" + comp_1.getOutStream().getThermoSystem().getTemperature()); - logger.info("Cp " + comp_1.getOutStream().getThermoSystem().getPhase(0).getCp()); - logger.info("Cv " + comp_1.getOutStream().getThermoSystem().getPhase(0).getCv()); + + comp_1.getOutletStream().getThermoSystem().getPhase(0).getSoundSpeed()); + logger + .info("out temperature" + comp_1.getOutletStream().getThermoSystem().getTemperature()); + logger.info("Cp " + comp_1.getOutletStream().getThermoSystem().getPhase(0).getCp()); + logger.info("Cv " + comp_1.getOutletStream().getThermoSystem().getPhase(0).getCv()); logger.info( - "molarmass " + comp_1.getOutStream().getThermoSystem().getPhase(0).getMolarMass()); + "molarmass " + comp_1.getOutletStream().getThermoSystem().getPhase(0).getMolarMass()); double outTemp = 500.1; // temperature in Kelvin double efficiency = comp_1.solveEfficiency(outTemp); logger.info("compressor polytropic efficiency " + efficiency); - logger.info("compressor out temperature " + comp_1.getOutStream().getTemperature()); + logger.info("compressor out temperature " + comp_1.getOutletStream().getTemperature()); logger.info("compressor power " + comp_1.getPower() + " J/sec"); logger.info("compressor head " + comp_1.getPower() / comp_1.getThermoSystem().getTotalNumberOfMoles() + " J/mol"); diff --git a/src/test/java/neqsim/processSimulation/util/example/gasPipeline.java b/src/test/java/neqsim/processSimulation/util/example/gasPipeline.java index 6b7f77d038..8596677852 100644 --- a/src/test/java/neqsim/processSimulation/util/example/gasPipeline.java +++ b/src/test/java/neqsim/processSimulation/util/example/gasPipeline.java @@ -59,7 +59,7 @@ public static void main(String args[]) { // operations.add(simplePipeline2phase); operations.run(); - pipeline.getOutStream().displayResult(); + pipeline.getOutletStream().displayResult(); // simplePipeline.getOutStream().displayResult(); // simplePipeline2phase.getOutStream().displayResult(); diff --git a/src/test/java/neqsim/processSimulation/util/example/multiThreadTest.java b/src/test/java/neqsim/processSimulation/util/example/multiThreadTest.java index 5181625e44..21f56e15c6 100644 --- a/src/test/java/neqsim/processSimulation/util/example/multiThreadTest.java +++ b/src/test/java/neqsim/processSimulation/util/example/multiThreadTest.java @@ -37,7 +37,7 @@ public static void main(String args[]) { MixerInterface mixer = new StaticMixer("Mixer 1"); mixer.addStream(stream_1); - StreamInterface stream_3 = mixer.getOutStream(); + StreamInterface stream_3 = mixer.getOutletStream(); stream_3.setName("stream3"); Separator separator = new Separator("Separator 1", stream_3); @@ -47,7 +47,7 @@ public static void main(String args[]) { Compressor comp1 = new Compressor("comp1", stream_2); comp1.setOutletPressure(50.0); - Cooler cooler1 = new Cooler("cooler1", comp1.getOutStream()); + Cooler cooler1 = new Cooler("cooler1", comp1.getOutletStream()); cooler1.setOutTemperature(283.15 + 30); // mixer.addStream(stream_2); @@ -77,7 +77,7 @@ public static void main(String args[]) { MixerInterface mixer2 = new StaticMixer("Mixer 1"); mixer2.addStream(stream_22); - StreamInterface stream_32 = mixer2.getOutStream(); + StreamInterface stream_32 = mixer2.getOutletStream(); stream_32.setName("stream32"); Separator separator2 = new Separator("Separator 1", stream_32); @@ -87,10 +87,10 @@ public static void main(String args[]) { Compressor comp12 = new Compressor("comp22", stream_222); comp12.setOutletPressure(45.0); - Cooler cooler12 = new Cooler("cooler12", comp12.getOutStream()); + Cooler cooler12 = new Cooler("cooler12", comp12.getOutletStream()); cooler12.setOutTemperature(283.15 + 30); - Separator separator3 = new Separator("Separator 122", cooler12.getOutStream()); + Separator separator3 = new Separator("Separator 122", cooler12.getOutletStream()); Recycle resyc = new Recycle("resyc"); resyc.addStream(separator3.getLiquidOutStream()); diff --git a/src/test/java/neqsim/processSimulation/util/example/oxygenRemovalWater.java b/src/test/java/neqsim/processSimulation/util/example/oxygenRemovalWater.java index 7b36101a4b..6b75c72090 100644 --- a/src/test/java/neqsim/processSimulation/util/example/oxygenRemovalWater.java +++ b/src/test/java/neqsim/processSimulation/util/example/oxygenRemovalWater.java @@ -39,12 +39,12 @@ public static void main(String[] args) { mix.addStream(stream_air); // mix.addStream(stream_water); - Separator separator = new Separator("separator", mix.getOutStream()); + Separator separator = new Separator("separator", mix.getOutletStream()); Heater heater1 = new Heater("heater1", separator.getLiquidOutStream()); heater1.setOutTemperature(273.15 + 20); - ThrottlingValve LP_valve = new ThrottlingValve("LPventil", heater1.getOutStream()); + ThrottlingValve LP_valve = new ThrottlingValve("LPventil", heater1.getOutletStream()); LP_valve.setOutletPressure(30.0e-3); neqsim.processSimulation.processSystem.ProcessSystem operations = diff --git a/src/test/java/neqsim/processSimulation/util/example/process2.java b/src/test/java/neqsim/processSimulation/util/example/process2.java index 27e6515778..304d1116ac 100644 --- a/src/test/java/neqsim/processSimulation/util/example/process2.java +++ b/src/test/java/neqsim/processSimulation/util/example/process2.java @@ -39,9 +39,9 @@ public static void main(String args[]) { heater.setOutTemperature(310.0); MixerInterface mixer = new StaticMixer("Mixer 1"); - mixer.addStream(heater.getOutStream()); + mixer.addStream(heater.getOutletStream()); - StreamInterface stream_3 = mixer.getOutStream(); + StreamInterface stream_3 = mixer.getOutletStream(); stream_3.setName("stream3"); Separator separator = new Separator("Separator 1", stream_3); diff --git a/src/test/java/neqsim/processSimulation/util/example/propaneCoolingCycle.java b/src/test/java/neqsim/processSimulation/util/example/propaneCoolingCycle.java index 7067a4a088..d4292f91ed 100644 --- a/src/test/java/neqsim/processSimulation/util/example/propaneCoolingCycle.java +++ b/src/test/java/neqsim/processSimulation/util/example/propaneCoolingCycle.java @@ -38,15 +38,15 @@ public static void main(String args[]) { ThrottlingValve JTvalve = new ThrottlingValve("JTvalve", stream_1); JTvalve.setOutletPressure(1.11325); - Cooler cooler = new Cooler("cooler", JTvalve.getOutStream()); + Cooler cooler = new Cooler("cooler", JTvalve.getOutletStream()); // cooler.setPressureDrop(0.35); cooler.setSpecification("out stream"); - Stream stream_2 = new Stream("stream_2", cooler.getOutStream()); + Stream stream_2 = new Stream("stream_2", cooler.getOutletStream()); stream_2.setSpecification("dewP"); // stream_2.setTemperature(-40.0, "C"); - cooler.setOutStream(stream_2); + cooler.setOutletStream(stream_2); SetPoint setLPpressure = new SetPoint("set", JTvalve, "pressure", stream_2); @@ -56,10 +56,10 @@ public static void main(String args[]) { compressor1.setSpecification("out stream"); compressor1.setOutletPressure(stream_1.getPressure()); - Heater heater = new Heater("heater", compressor1.getOutStream()); + Heater heater = new Heater("heater", compressor1.getOutletStream()); heater.setPressureDrop(0.07); heater.setSpecification("out stream"); - heater.setOutStream(stream_1); + heater.setOutletStream(stream_1); neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem(); @@ -83,7 +83,7 @@ public static void main(String args[]) { // operations.displayResult(); cooler.run(); - JTvalve.getOutStream().displayResult(); + JTvalve.getOutletStream().displayResult(); stream_2.displayResult(); System.out.println("compressor work" + compressor1.getEnergy() / 1.0e3 + " kW " diff --git a/src/test/java/neqsim/processSimulation/util/example/propaneMultiStageCoolingCycle.java b/src/test/java/neqsim/processSimulation/util/example/propaneMultiStageCoolingCycle.java index 9b167603b6..b8ce31f4e9 100644 --- a/src/test/java/neqsim/processSimulation/util/example/propaneMultiStageCoolingCycle.java +++ b/src/test/java/neqsim/processSimulation/util/example/propaneMultiStageCoolingCycle.java @@ -62,7 +62,7 @@ public static void main(String args[]) { JTvalve1.setOutletPressure(5.0); HeatExchanger heatEx1_et = new HeatExchanger("heatEx1_et", stream_Ethane); - heatEx1_et.setFeedStream(1, JTvalve1.getOutStream()); + heatEx1_et.setFeedStream(1, JTvalve1.getOutletStream()); heatEx1_et.setSpecification("out stream"); Stream stream_Ethane_out = new Stream("stream_Ethane_out", heatEx1_et.getOutStream(0)); @@ -88,7 +88,7 @@ public static void main(String args[]) { JTvalve2.setOutletPressure(1.5); HeatExchanger heatEx2 = new HeatExchanger("heatEx2", heatEx1.getOutStream(0)); - heatEx2.setFeedStream(1, JTvalve2.getOutStream()); + heatEx2.setFeedStream(1, JTvalve2.getOutletStream()); heatEx2.setSpecification("out stream"); // Cooler cooler = new Cooler(heatEx2.getOutStream(1)); @@ -103,7 +103,7 @@ public static void main(String args[]) { new Stream("coldGasFromPropaneCooler", heatEx2.getOutStream(0)); HeatExchanger heatEx22 = new HeatExchanger("heatEx22", heatEx2.getOutStream(0)); - heatEx22.setFeedStream(1, JTvalve1_et.getOutStream()); + heatEx22.setFeedStream(1, JTvalve1_et.getOutletStream()); heatEx22.setSpecification("out stream"); Stream stream_22 = new Stream("stream_22", heatEx22.getOutStream(1)); @@ -142,7 +142,7 @@ public static void main(String args[]) { coldGasFromPropaneCooler.displayResult(); heatEx22stream.getFluid().display(); - JTvalve2.getOutStream().getFluid().display(); + JTvalve2.getOutletStream().getFluid().display(); stream_22.getFluid().display(); // JTvalve1.displayResult(); diff --git a/src/test/java/neqsim/processSimulation/util/example/propaneTwoStageCoolingCycle.java b/src/test/java/neqsim/processSimulation/util/example/propaneTwoStageCoolingCycle.java index 55a4cd4158..34fd89b352 100644 --- a/src/test/java/neqsim/processSimulation/util/example/propaneTwoStageCoolingCycle.java +++ b/src/test/java/neqsim/processSimulation/util/example/propaneTwoStageCoolingCycle.java @@ -36,37 +36,37 @@ public static void main(String args[]) { ThrottlingValve JTvalve1 = new ThrottlingValve("JTvalve1", stream_1); JTvalve1.setOutletPressure(3.0); - Separator medPresSep = new Separator("medPresSep", JTvalve1.getOutStream()); + Separator medPresSep = new Separator("medPresSep", JTvalve1.getOutletStream()); ThrottlingValve JTvalve2 = new ThrottlingValve("JTvalve2", medPresSep.getLiquidOutStream()); JTvalve2.setOutletPressure(1.11325); - StreamInterface lowHStream = new Stream("lowHStream", JTvalve2.getOutStream()); + StreamInterface lowHStream = new Stream("lowHStream", JTvalve2.getOutletStream()); - Cooler cooler2 = new Cooler("cooler2", JTvalve2.getOutStream()); + Cooler cooler2 = new Cooler("cooler2", JTvalve2.getOutletStream()); // cooler2.setPressureDrop(0.35); cooler2.setSpecification("out stream"); - Stream stream_3 = new Stream("stream_3", cooler2.getOutStream()); + Stream stream_3 = new Stream("stream_3", cooler2.getOutletStream()); stream_3.setSpecification("dewP"); // stream_3.setTemperature(-40.0, "C"); - cooler2.setOutStream(stream_3); + cooler2.setOutletStream(stream_3); StreamInterface lowHStream2 = new Stream("lowHStream2", stream_3); Compressor compressor1 = new Compressor("compressor1", stream_3); compressor1.setOutletPressure(JTvalve1.getOutletPressure()); - Mixer propMixer = new Mixer(); - propMixer.addStream(compressor1.getOutStream()); + Mixer propMixer = new Mixer("propMixer"); + propMixer.addStream(compressor1.getOutletStream()); propMixer.addStream(medPresSep.getGasOutStream()); - Compressor compressor2 = new Compressor("compressor2", propMixer.getOutStream()); + Compressor compressor2 = new Compressor("compressor2", propMixer.getOutletStream()); compressor2.setOutletPressure(stream_1.getPressure()); - Heater cooler3 = new Heater("Heater", compressor2.getOutStream()); + Heater cooler3 = new Heater("Heater", compressor2.getOutletStream()); cooler3.setSpecification("out stream"); - cooler3.setOutStream(stream_1); + cooler3.setOutletStream(stream_1); neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem(); @@ -91,7 +91,7 @@ public static void main(String args[]) { ThrottlingValve JTvalve3 = new ThrottlingValve("JTvalve3", medPresSep.getLiquidOutStream()); JTvalve3.setOutletPressure(2.03981146); JTvalve3.run(); - JTvalve3.getOutStream().displayResult(); + JTvalve3.getOutletStream().displayResult(); // JTvalve1.getOutStream().displayResult(); // JTvalve2.getOutStream().displayResult(); // medPresSep.displayResult(); @@ -120,12 +120,12 @@ public static void main(String args[]) { // System.out.println("compressor isentropic ef " + // compressor1.getIsentropicEfficiency()); System.out.println("cooler2 mass flow " - + cooler2.getOutStream().getFluid().getFlowRate("kg/hr") + " kg/hr"); + + cooler2.getOutletStream().getFluid().getFlowRate("kg/hr") + " kg/hr"); System.out.println("cooler3 mass flow " - + cooler3.getOutStream().getFluid().getFlowRate("kg/hr") + " kg/hr"); + + cooler3.getOutletStream().getFluid().getFlowRate("kg/hr") + " kg/hr"); System.out.println("delta enthalpy " + (stream_3.getFluid().getEnthalpy() - - JTvalve2.getOutStream().getFluid().getEnthalpy())); + - JTvalve2.getOutletStream().getFluid().getEnthalpy())); System.out.println("cooler2 duty " + cooler2.getEnergyInput() / 1.0e3 + " kW"); System.out.println("cooler3 duty " + cooler3.getEnergyInput() / 1.0e3 + " kW"); diff --git a/src/test/java/neqsim/processSimulation/util/example/simpleTopSideProcess.java b/src/test/java/neqsim/processSimulation/util/example/simpleTopSideProcess.java index 2cefd404a7..eb85cf345a 100644 --- a/src/test/java/neqsim/processSimulation/util/example/simpleTopSideProcess.java +++ b/src/test/java/neqsim/processSimulation/util/example/simpleTopSideProcess.java @@ -37,20 +37,20 @@ public static void main(String args[]) { Mixer mixerHP = new neqsim.processSimulation.processEquipment.mixer.StaticMixer("Mixer HP"); mixerHP.addStream(stream_1); - Separator separator = new Separator("Separator 1", mixerHP.getOutStream()); + Separator separator = new Separator("Separator 1", mixerHP.getOutletStream()); ThrottlingValve LP_valve = new ThrottlingValve("LPventil", separator.getLiquidOutStream()); LP_valve.setOutletPressure(5.0); - Separator LPseparator = new Separator("Separator 1", LP_valve.getOutStream()); + Separator LPseparator = new Separator("Separator 1", LP_valve.getOutletStream()); Compressor LPcompressor = new Compressor("LPcompressor", LPseparator.getGasOutStream()); LPcompressor.setOutletPressure(50.0); - Heater heaterLP = new Heater("heaterLP", LPcompressor.getOutStream()); + Heater heaterLP = new Heater("heaterLP", LPcompressor.getOutletStream()); heaterLP.setOutTemperature(270.25); - Stream stream_2 = new Stream("cooled gas", heaterLP.getOutStream()); + Stream stream_2 = new Stream("cooled gas", heaterLP.getOutletStream()); GasScrubberSimple gasScrubber = new GasScrubberSimple("Scrubber", stream_2); @@ -63,7 +63,7 @@ public static void main(String args[]) { mixer.addStream(separator.getGasOutStream()); mixer.addStream(gasScrubber.getGasOutStream()); - Compressor HPcompressor = new Compressor("HPcompressor", mixer.getOutStream()); + Compressor HPcompressor = new Compressor("HPcompressor", mixer.getOutletStream()); HPcompressor.setOutletPressure(200.0); neqsim.processSimulation.processSystem.ProcessSystem operations = diff --git a/src/test/java/neqsim/processSimulation/util/example/simpleTopSideProcess2.java b/src/test/java/neqsim/processSimulation/util/example/simpleTopSideProcess2.java index 595a0edba0..a25343fe69 100644 --- a/src/test/java/neqsim/processSimulation/util/example/simpleTopSideProcess2.java +++ b/src/test/java/neqsim/processSimulation/util/example/simpleTopSideProcess2.java @@ -32,7 +32,7 @@ public static void main(String args[]) { mixer_inlet.addStream(stream_inlet); ThreePhaseSeparator separator_inlet = - new ThreePhaseSeparator("Separator 1", mixer_inlet.getOutStream()); + new ThreePhaseSeparator("Separator 1", mixer_inlet.getOutletStream()); Stream stream_gasFromSep = new Stream("stream_gasFromSep", separator_inlet.getGasOutStream()); @@ -40,7 +40,7 @@ public static void main(String args[]) { Heater cooler1 = new Heater("cooler1", stream_gasFromSep); cooler1.setOutTemperature(285.25); - Separator scrubber = new Separator("Scrubber 1", cooler1.getOutStream()); + Separator scrubber = new Separator("Scrubber 1", cooler1.getOutletStream()); Recycle recyleOp = new Recycle("resyc"); recyleOp.addStream(scrubber.getLiquidOutStream()); diff --git a/src/test/java/neqsim/processSimulation/util/example/testGasScrubber.java b/src/test/java/neqsim/processSimulation/util/example/testGasScrubber.java index 507b867e82..1b1b59caba 100644 --- a/src/test/java/neqsim/processSimulation/util/example/testGasScrubber.java +++ b/src/test/java/neqsim/processSimulation/util/example/testGasScrubber.java @@ -57,7 +57,7 @@ public static void main(String args[]) { pipe.setDiameter(0.4); pipe.setLength(10); - StreamInterface stream_3 = pipe.getOutStream(); + StreamInterface stream_3 = pipe.getOutletStream(); neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem(); diff --git a/src/test/java/neqsim/processSimulation/util/example/threePhaseSeparation.java b/src/test/java/neqsim/processSimulation/util/example/threePhaseSeparation.java index c1f7d41753..b17acb4281 100644 --- a/src/test/java/neqsim/processSimulation/util/example/threePhaseSeparation.java +++ b/src/test/java/neqsim/processSimulation/util/example/threePhaseSeparation.java @@ -73,11 +73,11 @@ public static void main(String args[]) { // waterRemoval.getOutStream(); MoleFractionControllerUtil TEGsaturator = - new MoleFractionControllerUtil(waterRemoval.getOutStream()); + new MoleFractionControllerUtil(waterRemoval.getOutletStream()); TEGsaturator.setMoleFraction("water", 5.0e-6); // TEGsaturator.getOutStream(); - ThrottlingValve LP_valve = new ThrottlingValve("LPventil", TEGsaturator.getOutStream()); + ThrottlingValve LP_valve = new ThrottlingValve("LPventil", TEGsaturator.getOutletStream()); LP_valve.setOutletPressure(5.0); // ThreePhaseSeparator separator2 = new ThreePhaseSeparator("Separator LP", diff --git a/src/test/java/neqsim/standards/gasQuality/Standard_ISO6976Test.java b/src/test/java/neqsim/standards/gasQuality/Standard_ISO6976Test.java index 2078df96d2..ca24eaab67 100644 --- a/src/test/java/neqsim/standards/gasQuality/Standard_ISO6976Test.java +++ b/src/test/java/neqsim/standards/gasQuality/Standard_ISO6976Test.java @@ -15,111 +15,159 @@ * @author ESOL * */ -class Standard_ISO6976Test extends neqsim.NeqSimTest{ - static SystemInterface testSystem = null; - /** - * @throws java.lang.Exception - */ - @BeforeAll - static void setUpBeforeClass() throws Exception { - testSystem = new SystemSrkEos(273.15 + 20.0, 1.0); - testSystem.addComponent("methane", 0.931819); - testSystem.addComponent("ethane", 0.025618); - testSystem.addComponent("nitrogen", 0.010335); - testSystem.addComponent("CO2", 0.015391); - testSystem.setMixingRule("classic"); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - testOps.TPflash(); - } - - /** - * Test method for {@link neqsim.standards.gasQuality.Standard_ISO6976#calculate()}. - */ - @Test - void testCalculate() { - Standard_ISO6976 standard = new Standard_ISO6976(testSystem, 0, 15.55, "volume"); - standard.setReferenceState("real"); - standard.setReferenceType("volume"); - standard.calculate(); - double GCV = standard.getValue("GCV"); - double WI = standard.getValue("WI"); - assertEquals(39614.56783352743, GCV, 0.01); - assertEquals(44.61477915805513, WI, 0.01); - } - - @Test - void testCalculate2() { - SystemInterface testSystem = new SystemSrkEos(273.15 - 150.0, 1.0); - testSystem.addComponent("methane", 0.931819); - testSystem.addComponent("ethane", 0.025618); - testSystem.addComponent("nitrogen", 0.010335); - testSystem.addComponent("CO2", 0.015391); - - // ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - /* - * testSystem.addComponent("methane", 0.922393); testSystem.addComponent("ethane", - * 0.025358); testSystem.addComponent("propane", 0.01519); - * testSystem.addComponent("n-butane", 0.000523); testSystem.addComponent("i-butane", - * 0.001512); testSystem.addComponent("n-pentane", 0.002846); - * testSystem.addComponent("i-pentane", 0.002832); testSystem.addComponent("22-dim-C3", - * 0.001015); testSystem.addComponent("n-hexane", 0.002865); - * testSystem.addComponent("nitrogen", 0.01023); testSystem.addComponent("CO2", 0.015236); - * - */ - - /* - * - * testSystem.addComponent("methane", 0.9247); testSystem.addComponent("ethane", 0.035); - * testSystem.addComponent("propane", 0.0098); testSystem.addComponent("n-butane", 0.0022); - * testSystem.addComponent("i-butane", 0.0034); testSystem.addComponent("n-pentane", - * 0.0006); testSystem.addComponent("nitrogen", 0.0175); testSystem.addComponent("CO2", - * 0.0068); - * - */ - - // testSystem.addComponent("water", 0.016837); - - /* - * testSystem.addComponent("n-hexane", 0.0); testSystem.addComponent("n-heptane", 0.0); - * testSystem.addComponent("n-octane", 0.0); testSystem.addComponent("n-nonane", 0.0); - * testSystem.addComponent("nC10", 0.0); - * - * testSystem.addComponent("CO2", 0.68); testSystem.addComponent("H2S", 0.0); - * testSystem.addComponent("water", 0.0); testSystem.addComponent("oxygen", 0.0); - * testSystem.addComponent("carbonmonoxide", 0.0); testSystem.addComponent("nitrogen", - * 1.75); - */ - // testSystem.addComponent("MEG", 1.75); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - - testSystem.init(0); - Standard_ISO6976 standard = new Standard_ISO6976(testSystem, 0, 15.55, "volume"); - standard.setReferenceState("real"); - standard.setReferenceType("volume"); - standard.calculate(); - Assertions.assertEquals(0.9974432506378011, standard.getValue("CompressionFactor")); - Assertions.assertEquals(39614.56783352743, standard.getValue("SuperiorCalorificValue")); - Assertions.assertEquals(35693.92161464964, standard.getValue("InferiorCalorificValue")); - Assertions.assertEquals(39614.56783352743, standard.getValue("GCV")); - - Assertions.assertEquals(51701.01275822569, standard.getValue("SuperiorWobbeIndex")); - Assertions.assertEquals(46584.17339159412, standard.getValue("InferiorWobbeIndex")); - - Assertions.assertEquals(0.5870995452263126, standard.getValue("RelativeDensity")); - Assertions.assertEquals(0.9974432506378011, standard.getValue("CompressionFactor")); - Assertions.assertEquals(16.972142879156355, standard.getValue("MolarMass")); - - //standard.display("test"); - /* - * StandardInterface standardUK = new UKspecifications_ICF_SI(testSystem); - * standardUK.calculate(); System.out.println("ICF " + - * standardUK.getValue("IncompleteCombustionFactor", "")); - * - * System.out.println("HID " + testSystem.getPhase(0).getComponent("methane").getHID(273.15 - * - 150.0)); System.out.println("Hres " + - * testSystem.getPhase(0).getComponent("methane").getHresTP(273.15 - 150.0)); - */ - } +class Standard_ISO6976Test extends neqsim.NeqSimTest { + static SystemInterface testSystem = null; + + /** + * @throws java.lang.Exception + */ + @BeforeAll + static void setUpBeforeClass() throws Exception { + testSystem = new SystemSrkEos(273.15 + 20.0, 1.0); + testSystem.addComponent("methane", 0.931819); + testSystem.addComponent("ethane", 0.025618); + testSystem.addComponent("nitrogen", 0.010335); + testSystem.addComponent("CO2", 0.015391); + testSystem.setMixingRule("classic"); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + } + + /** + * Test method for {@link neqsim.standards.gasQuality.Standard_ISO6976#calculate()}. + */ + @Test + void testCalculate() { + Standard_ISO6976 standard = new Standard_ISO6976(testSystem, 0, 15.55, "volume"); + standard.setReferenceState("real"); + standard.setReferenceType("volume"); + standard.calculate(); + double GCV = standard.getValue("GCV"); + double WI = standard.getValue("WI"); + assertEquals(39614.56783352743, GCV, 0.01); + assertEquals(44.61477915805513, WI, 0.01); + } + + /** + * Test method for {@link neqsim.standards.gasQuality.Standard_ISO6976#calculate()} if wrong + * reference state is gven. Valid reference states should be 0, 15 and 20 C and 15F (15.55C). If + * wrong reference state is given, the program should use standard conditions (15C). + */ + @Test + void testCalculateWithWrongReferenceState() { + double volumeReferenceState = 0; + double energyReferenceState = 15.55; + Standard_ISO6976 standard = + new Standard_ISO6976(testSystem, volumeReferenceState, energyReferenceState, "volume"); + standard.setReferenceState("real"); + standard.setReferenceType("volume"); + standard.calculate(); + double GCV = standard.getValue("GCV"); + double WI = standard.getValue("WI"); + assertEquals(39614.56783352743, GCV, 0.01); + energyReferenceState = 15.15; // example of wrong reference condition + volumeReferenceState = 1.15; // example of wrong volume reference condition + standard.setEnergyRefT(energyReferenceState); + standard.setVolRefT(volumeReferenceState); + standard.calculate(); + GCV = standard.getValue("GCV"); + assertEquals(37499.35392575905, GCV, 0.01); + } + + /** + * Test method for {@link neqsim.standards.gasQuality.Standard_ISO6976#calculate()}. + */ + @Test + void testCalculateWithPSeudo() { + SystemSrkEos testSystem = new SystemSrkEos(273.15 + 20.0, 1.0); + testSystem.addComponent("methane", 0.931819); + testSystem.addComponent("ethane", 0.025618); + testSystem.addComponent("nitrogen", 0.010335); + testSystem.addComponent("CO2", 0.015391); + testSystem.addTBPfraction("C10", 0.015391, 90.0 / 1000.0, 0.82); + testSystem.setMixingRule("classic"); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + Standard_ISO6976 standard = new Standard_ISO6976(testSystem, 0, 15.55, "volume"); + standard.setReferenceState("real"); + standard.setReferenceType("volume"); + standard.calculate(); + double GCV = standard.getValue("GCV"); + double WI = standard.getValue("WI"); + assertEquals(42377.76099372482, GCV, 0.01); + } + + @Test + void testCalculate2() { + SystemInterface testSystem = new SystemSrkEos(273.15 - 150.0, 1.0); + testSystem.addComponent("methane", 0.931819); + testSystem.addComponent("ethane", 0.025618); + testSystem.addComponent("nitrogen", 0.010335); + testSystem.addComponent("CO2", 0.015391); + + // ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + /* + * testSystem.addComponent("methane", 0.922393); testSystem.addComponent("ethane", 0.025358); + * testSystem.addComponent("propane", 0.01519); testSystem.addComponent("n-butane", 0.000523); + * testSystem.addComponent("i-butane", 0.001512); testSystem.addComponent("n-pentane", + * 0.002846); testSystem.addComponent("i-pentane", 0.002832); + * testSystem.addComponent("22-dim-C3", 0.001015); testSystem.addComponent("n-hexane", + * 0.002865); testSystem.addComponent("nitrogen", 0.01023); testSystem.addComponent("CO2", + * 0.015236); + * + */ + + /* + * + * testSystem.addComponent("methane", 0.9247); testSystem.addComponent("ethane", 0.035); + * testSystem.addComponent("propane", 0.0098); testSystem.addComponent("n-butane", 0.0022); + * testSystem.addComponent("i-butane", 0.0034); testSystem.addComponent("n-pentane", 0.0006); + * testSystem.addComponent("nitrogen", 0.0175); testSystem.addComponent("CO2", 0.0068); + * + */ + + // testSystem.addComponent("water", 0.016837); + + /* + * testSystem.addComponent("n-hexane", 0.0); testSystem.addComponent("n-heptane", 0.0); + * testSystem.addComponent("n-octane", 0.0); testSystem.addComponent("n-nonane", 0.0); + * testSystem.addComponent("nC10", 0.0); + * + * testSystem.addComponent("CO2", 0.68); testSystem.addComponent("H2S", 0.0); + * testSystem.addComponent("water", 0.0); testSystem.addComponent("oxygen", 0.0); + * testSystem.addComponent("carbonmonoxide", 0.0); testSystem.addComponent("nitrogen", 1.75); + */ + // testSystem.addComponent("MEG", 1.75); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + + testSystem.init(0); + Standard_ISO6976 standard = new Standard_ISO6976(testSystem, 0, 15.55, "volume"); + standard.setReferenceState("real"); + standard.setReferenceType("volume"); + standard.calculate(); + Assertions.assertEquals(0.9974432506378011, standard.getValue("CompressionFactor")); + Assertions.assertEquals(39614.56783352743, standard.getValue("SuperiorCalorificValue")); + Assertions.assertEquals(35693.92161464964, standard.getValue("InferiorCalorificValue")); + Assertions.assertEquals(39614.56783352743, standard.getValue("GCV")); + + Assertions.assertEquals(51701.01275822569, standard.getValue("SuperiorWobbeIndex")); + Assertions.assertEquals(46584.17339159412, standard.getValue("InferiorWobbeIndex")); + + Assertions.assertEquals(0.5870995452263126, standard.getValue("RelativeDensity")); + Assertions.assertEquals(0.9974432506378011, standard.getValue("CompressionFactor")); + Assertions.assertEquals(16.972142879156355, standard.getValue("MolarMass")); + + // standard.display("test"); + /* + * StandardInterface standardUK = new UKspecifications_ICF_SI(testSystem); + * standardUK.calculate(); System.out.println("ICF " + + * standardUK.getValue("IncompleteCombustionFactor", "")); + * + * System.out.println("HID " + testSystem.getPhase(0).getComponent("methane").getHID(273.15 - + * 150.0)); System.out.println("Hres " + + * testSystem.getPhase(0).getComponent("methane").getHresTP(273.15 - 150.0)); + */ + } } diff --git a/src/test/java/neqsim/thermo/system/ModelBaseTest.java b/src/test/java/neqsim/thermo/system/ModelBaseTest.java index f6a98cd8dd..a9ae048a96 100644 --- a/src/test/java/neqsim/thermo/system/ModelBaseTest.java +++ b/src/test/java/neqsim/thermo/system/ModelBaseTest.java @@ -13,135 +13,135 @@ * @version $Id: $Id * @since 2.2.3 */ -public abstract class ModelBaseTest extends neqsim.NeqSimTest{ - static SystemInterface thermoSystem = null; - neqsim.thermo.ThermodynamicModelTest fugTest; +public abstract class ModelBaseTest extends neqsim.NeqSimTest { + public static SystemInterface thermoSystem = null; + neqsim.thermo.ThermodynamicModelTest fugTest; - /** - *- * testInit0. - *
- */ - @Test - public void testInit0() { - try { - thermoSystem.init(0); - } catch (Exception success) { - fail("Error running init0"); - } + /** + *+ * testInit0. + *
+ */ + @Test + public void testInit0() { + try { + thermoSystem.init(0); + } catch (Exception success) { + fail("Error running init0"); } + } - /** - *- * testInit1. - *
- */ - @Test - public void testInit1() { - try { - thermoSystem.init(1); - } catch (Exception success) { - fail("Error running init1"); - } + /** + *+ * testInit1. + *
+ */ + @Test + public void testInit1() { + try { + thermoSystem.init(1); + } catch (Exception success) { + fail("Error running init1"); } + } - /** - *- * testActivity. - *
- */ - @Test - public void testActivity() { - thermoSystem.init(0); - thermoSystem.init(1); - double activ1 = thermoSystem.getPhase(1).getActivityCoefficient(0); - thermoSystem.init(0); - thermoSystem.init(1); - double activ2 = thermoSystem.getPhase(1).getActivityCoefficient(0); - assertTrue(Math.abs((activ1 - activ2)) < 1e-6); - } + /** + *+ * testActivity. + *
+ */ + @Test + public void testActivity() { + thermoSystem.init(0); + thermoSystem.init(1); + double activ1 = thermoSystem.getPhase(1).getActivityCoefficient(0); + thermoSystem.init(0); + thermoSystem.init(1); + double activ2 = thermoSystem.getPhase(1).getActivityCoefficient(0); + assertTrue(Math.abs((activ1 - activ2)) < 1e-6); + } - /** - *- * testVolume. - *
- */ - @Test - public void testVolume() { - thermoSystem.init(0); - thermoSystem.init(1); - double dens1 = thermoSystem.getPhase(0).getDensity(); - thermoSystem.init(0); - thermoSystem.init(1); - double dens2 = thermoSystem.getPhase(1).getDensity(); - assertTrue(dens2 > dens1); - } + /** + *+ * testVolume. + *
+ */ + @Test + public void testVolume() { + thermoSystem.init(0); + thermoSystem.init(1); + double dens1 = thermoSystem.getPhase(0).getDensity(); + thermoSystem.init(0); + thermoSystem.init(1); + double dens2 = thermoSystem.getPhase(1).getDensity(); + assertTrue(dens2 > dens1); + } - /** - *- * testGibbs. - *
- */ - @Test - public void testGibbs() { - thermoSystem.init(0); - thermoSystem.init(1); - double gibbs1 = thermoSystem.getPhase(0).getGibbsEnergy(); - thermoSystem.init(0); - thermoSystem.init(1); - double gibbs2 = thermoSystem.getPhase(1).getGibbsEnergy(); - assertTrue(gibbs2 < gibbs1); - } + /** + *+ * testGibbs. + *
+ */ + @Test + public void testGibbs() { + thermoSystem.init(0); + thermoSystem.init(1); + double gibbs1 = thermoSystem.getPhase(0).getGibbsEnergy(); + thermoSystem.init(0); + thermoSystem.init(1); + double gibbs2 = thermoSystem.getPhase(1).getGibbsEnergy(); + assertTrue(gibbs2 < gibbs1); + } - /** - *- * testFugasities. - *
- */ - @Test - public void testFugasities() { - thermoSystem.init(0); - thermoSystem.init(1); - fugTest = new neqsim.thermo.ThermodynamicModelTest(thermoSystem); - assertTrue(fugTest.checkFugacityCoefficients()); - } + /** + *+ * testFugasities. + *
+ */ + @Test + public void testFugasities() { + thermoSystem.init(0); + thermoSystem.init(1); + fugTest = new neqsim.thermo.ThermodynamicModelTest(thermoSystem); + assertTrue(fugTest.checkFugacityCoefficients()); + } - /** - *- * testFugasitiesdT. - *
- */ - @Test - public void testFugasitiesdT() { - thermoSystem.init(0); - thermoSystem.init(3); - fugTest = new neqsim.thermo.ThermodynamicModelTest(thermoSystem); - assertTrue(fugTest.checkFugacityCoefficientsDT()); - } + /** + *+ * testFugasitiesdT. + *
+ */ + @Test + public void testFugasitiesdT() { + thermoSystem.init(0); + thermoSystem.init(3); + fugTest = new neqsim.thermo.ThermodynamicModelTest(thermoSystem); + assertTrue(fugTest.checkFugacityCoefficientsDT()); + } - /** - *- * testFugasitiesdP. - *
- */ - @Test - public void testFugasitiesdP() { - thermoSystem.init(0); - thermoSystem.init(3); - fugTest = new neqsim.thermo.ThermodynamicModelTest(thermoSystem); - assertTrue(fugTest.checkFugacityCoefficientsDP()); - } + /** + *+ * testFugasitiesdP. + *
+ */ + @Test + public void testFugasitiesdP() { + thermoSystem.init(0); + thermoSystem.init(3); + fugTest = new neqsim.thermo.ThermodynamicModelTest(thermoSystem); + assertTrue(fugTest.checkFugacityCoefficientsDP()); + } - /** - *- * testFugasitiesdn. - *
- */ - @Test - public void testFugasitiesdn() { - thermoSystem.init(0); - thermoSystem.init(3); - fugTest = new neqsim.thermo.ThermodynamicModelTest(thermoSystem); - assertTrue(fugTest.checkFugacityCoefficientsDn()); - } + /** + *+ * testFugasitiesdn. + *
+ */ + @Test + public void testFugasitiesdn() { + thermoSystem.init(0); + thermoSystem.init(3); + fugTest = new neqsim.thermo.ThermodynamicModelTest(thermoSystem); + assertTrue(fugTest.checkFugacityCoefficientsDn()); + } } diff --git a/src/test/java/neqsim/thermo/system/SystemPrEosTest.java b/src/test/java/neqsim/thermo/system/SystemPrEosTest.java index 63ff58f56e..8d30856733 100644 --- a/src/test/java/neqsim/thermo/system/SystemPrEosTest.java +++ b/src/test/java/neqsim/thermo/system/SystemPrEosTest.java @@ -2,11 +2,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; - import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; - import neqsim.thermodynamicOperations.ThermodynamicOperations; class SystemPrEoSTest extends neqsim.NeqSimTest{ @@ -41,6 +39,7 @@ public static void setUp() { @Test @DisplayName("test a TPflash2") public void testTPflash2() { + assertEquals(2, testSystem.getNumberOfPhases()); } diff --git a/src/test/java/neqsim/thermo/system/SystemThermoAddComponentTest.java b/src/test/java/neqsim/thermo/system/SystemThermoAddComponentTest.java index ae6c459dbe..7f5ffab634 100644 --- a/src/test/java/neqsim/thermo/system/SystemThermoAddComponentTest.java +++ b/src/test/java/neqsim/thermo/system/SystemThermoAddComponentTest.java @@ -20,7 +20,6 @@ void setup() { */ } - @Test void testAddComponent() { // Assure that System contains no components diff --git a/src/test/java/neqsim/thermo/system/SystemThermoSetMolarCompositionTest.java b/src/test/java/neqsim/thermo/system/SystemThermoSetMolarCompositionTest.java index 76eec2fa4a..3530ce5a2f 100644 --- a/src/test/java/neqsim/thermo/system/SystemThermoSetMolarCompositionTest.java +++ b/src/test/java/neqsim/thermo/system/SystemThermoSetMolarCompositionTest.java @@ -57,7 +57,7 @@ void testNoFlow() { sys.setMolarComposition(new double[] { 1, 1.5, 1.75 }); }); Assertions.assertEquals( - "neqsim.util.exception.InvalidInputException: Total flow can not be 0 when setting molar composition", + "neqsim.util.exception.InvalidInputException: SystemSrkEos:setMolarComposition - Input totalFlow must be larger than 0 (1e-100) when setting molar composition", thrown.getMessage()); } @@ -69,8 +69,8 @@ void testNoFlowPlus() { sys.setMolarCompositionPlus(new double[] { 1, 1.5, 1.75 }); }); Assertions.assertEquals( - "neqsim.util.exception.InvalidInputException: Total flow can not be 0 when setting molar composition", - thrown.getMessage()); + "neqsim.util.exception.InvalidInputException: SystemSrkEos:setMolarComposition - Input totalFlow must be larger than 0 (1e-100) when setting molar composition", + thrown.getMessage()); } @Test @@ -81,7 +81,7 @@ void testNoFlowPlusFluid() { sys.setMolarCompositionOfPlusFluid(new double[] { 1, 1.5, 1.75 }); }); Assertions.assertEquals( - "neqsim.util.exception.InvalidInputException: Total flow can not be 0 when setting molar composition", - thrown.getMessage()); + "neqsim.util.exception.InvalidInputException: SystemSrkEos:setMolarComposition - Input totalFlow must be larger than 0 (1e-100) when setting molar composition", + thrown.getMessage()); } } diff --git a/src/test/java/neqsim/thermo/system/SystemUMRCPAEoStest.java b/src/test/java/neqsim/thermo/system/SystemUMRCPAEoStest.java new file mode 100644 index 0000000000..920a9bbfbc --- /dev/null +++ b/src/test/java/neqsim/thermo/system/SystemUMRCPAEoStest.java @@ -0,0 +1,229 @@ +package neqsim.thermo.system; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +class SystemUMRCPAEoStest extends neqsim.NeqSimTest { + static neqsim.thermo.system.SystemInterface testSystem = null; + static neqsim.thermo.ThermodynamicModelTest testModel = null; + neqsim.thermo.ThermodynamicModelTest fugTest; + + /** + *+ * setUp. + *
+ */ + @BeforeAll + public static void setUp() { + // testSystem = new neqsim.thermo.system.SystemUMRPRUMCEos(298.0, 10.0); + //testSystem = new neqsim.thermo.system.SystemSrkCPA(400.0, 500.0); + //testSystem = new neqsim.thermo.system.SystemSrkCPA(400.0, 500.0); + testSystem = new neqsim.thermo.system.SystemUMRCPAEoS(800, 110); + // testSystem = new neqsim.thermo.system.SystemSrkEos(298.0, 10.0); + //testSystem.addComponent("nitrogen", 1); + testSystem.addComponent("water", 1); + //testSystem.addComponent("CO2", 0.01); + //testSystem.addComponent("methane", 0.68); + //testSystem.addComponent("ethane", 0.1); + // testSystem.addComponent("n-heptane", 0.2); + // testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); + //testSystem.setMixingRule(1); + testModel = new neqsim.thermo.ThermodynamicModelTest(testSystem); + // testModel = new neqsim.thermo.ThermodynamicModelTest(testSystem); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testSystem.init(0); + testOps.TPflash(); + testSystem.init(3); + //testSystem.initProperties(); + // testSystem.i + } + + /** + *+ * testFugasities. + *
+ */ + //@Test + public void testFugasities() { + testSystem.init(0); + testSystem.init(1); + fugTest = new neqsim.thermo.ThermodynamicModelTest(testSystem); + assertTrue(fugTest.checkFugacityCoefficients()); + + double fucoef = testSystem.getComponent(0).getLogFugacityCoefficient(); + + assertEquals(-0.002884922, fucoef, 1e-6); + + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + testSystem.initProperties(); + double molvol = testSystem.getMolarVolume(); + + assertEquals(247.09909107115, molvol, 1e-2); + } + + /** + *+ * testCompressibility. + *
+ */ + @Test + @DisplayName("test compressibility of gas phase") + public void testCompressibility() { + // testSystem = new neqsim.thermo.system.SystemPr(298.0, 10.0); + // testSystem = new SystemSrkEos(298.0, 10.0); + // testSystem = new neqsim.thermo.system.SystemUMRPRUMCEos(298.0, 10.0); + //testSystem = new neqsim.thermo.system.SystemSrkCPA(400, 500); + testSystem = new neqsim.thermo.system.SystemUMRCPAEoS(800, 110); + testSystem.addComponent("water", 1); + // testSystem.addComponent("CO2", 0.01); + //testSystem.addComponent("methane", 0.68); + //testSystem.addComponent("ethane", 0.1); + // testSystem.addComponent("n-heptane", 0.2); + //testSystem.setMixingRule(1); + testModel = new neqsim.thermo.ThermodynamicModelTest(testSystem); + // testModel = new neqsim.thermo.ThermodynamicModelTest(testSystem); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testSystem.init(0); + testOps.TPflash(); + testSystem.init(3); + testSystem.init(3); + System.out.println("molar volume gas+oil is " + testSystem.getMolarVolume()); + System.out.println("molar volume gas is " + testSystem.getPhase(0).getMolarVolume()); + System.out.println("fugacity of gas phase " + testSystem.getPhase(0).getFugacity(0)); + System.out.println("residual enthalpy of gas phase is " + testSystem.getPhase(0).getHresTP()); + System.out.println("isochoric heat capacity of gas phase is " + testSystem.getPhase(0).getCv("J/mol")); + System.out.println("isobaric heat capacity of gas phase is " + testSystem.getPhase(0).getCp("J/mol")); + System.out.println("internal energy of gas phase is " + testSystem.getPhase(0).getInternalEnergy()); + System.out.println("molar volume liquid is " + testSystem.getPhase(1).getMolarVolume()); + System.out.println("fugacity of gas phase " + testSystem.getPhase(1).getFugacity(0)); + System.out.println("enthalpy of gas phase is " + testSystem.getPhase(1).getEnthalpy("J/mol")); + System.out.println("isochoric heat capacity of gas phase is " + testSystem.getPhase(1).getCv("J/mol")); + //ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + //testOps.TPflash(); + + // testSystem.initProperties(); + // assertEquals(0.9711401538454589, testSystem.getPhase(0).getZ(), 0.001); + } + + /** + *+ * testTPflash2. + *
+ */ + @Disabled + @Test + @DisplayName("test a TPflash2") + public void testTPflash2() { + assertEquals(2, testSystem.getNumberOfPhases()); + } + + /** + *+ * testTPflash. + *
+ */ + @Disabled + @Test + @DisplayName("test a TPflash of the fluid (should return two phases)") + public void testTPflash() { + assertEquals(2, testSystem.getNumberOfPhases()); + } + + /** + *+ * testFugacityCoefficients. + *
+ */ + @Test + @DisplayName("test the fugacity coefficients calculated") + public void testFugacityCoefficients() { + assertTrue(testModel.checkFugacityCoefficients()); + + // System.out.println("molar volume liquid is " + testSystem.((PhasePrEosvolcor) + // phase).getFC()); + } + + /** + *+ * checkFugacityCoefficientsDP. + *
+ */ + @Test + @DisplayName("test derivative of fugacity coefficients with respect to pressure") + public void checkFugacityCoefficientsDP() { + //testSystem.init(0); + //testSystem.init(3); + assertTrue(testModel.checkFugacityCoefficientsDP()); + } + + /** + *+ * checkFugacityCoefficientsDT. + *
+ */ + + @Test + @DisplayName("test derivative of fugacity coefficients with respect to temperature") + public void checkFugacityCoefficientsDT() { + assertTrue(testModel.checkFugacityCoefficientsDT()); + } + + /** + *+ * checkFugacityCoefficientsDn. + *
+ */ + //@Test + @DisplayName("test derivative of fugacity coefficients with respect to composition") + public void checkFugacityCoefficientsDn() { + assertTrue(testModel.checkFugacityCoefficientsDn()); + } + + /** + *+ * checkFugacityCoefficientsDn2. + *
+ */ + //@Test + @DisplayName("test derivative of fugacity coefficients with respect to composition (2nd method)") + public void checkFugacityCoefficientsDn2() { + assertTrue(testModel.checkFugacityCoefficientsDn2()); + } + + /** + *+ * checkPhaseEnvelope. + *
+ * + * @throws Exception + */ + // @Test + @DisplayName("calculate phase envelope using UMR") + public void checkPhaseEnvelope() throws Exception { + testSystem = new neqsim.thermo.system.SystemUMRPRUMCEos(298.0, 10.0); + testSystem.addComponent("methane", 0.9); + testSystem.addComponent("ethane", 0.1); + testSystem.addComponent("propane", 0.1); + testSystem.addComponent("i-butane", 0.1); + testSystem.addComponent("n-butane", 0.1); + testSystem.addComponent("n-pentane", 0.1); + testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); + testSystem.init(0); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + try { + testOps.calcPTphaseEnvelope(); + System.out.println("Cricondenbar " + (testOps.get("cricondenbar")[0] - 273.15) + " " + + testOps.get("cricondenbar")[1]); + } catch (Exception e) { + assertTrue(false); + throw new Exception(e); + } + assertEquals(testOps.get("cricondenbar")[1], 130.686140727503, 0.02); + } +} diff --git a/src/test/java/neqsim/thermo/system/SystemUMRPRUMCEosNewTest.java b/src/test/java/neqsim/thermo/system/SystemUMRPRUMCEosNewTest.java index 4e58707d7f..8501bb81bb 100644 --- a/src/test/java/neqsim/thermo/system/SystemUMRPRUMCEosNewTest.java +++ b/src/test/java/neqsim/thermo/system/SystemUMRPRUMCEosNewTest.java @@ -3,160 +3,212 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import neqsim.thermodynamicOperations.ThermodynamicOperations; -class SystemUMRPRUMCEosNewTest extends neqsim.NeqSimTest{ - static neqsim.thermo.system.SystemInterface testSystem = null; - static neqsim.thermo.ThermodynamicModelTest testModel = null; - - /** - *- * setUp. - *
- */ - @BeforeAll - public static void setUp() { - testSystem = new neqsim.thermo.system.SystemUMRPRUMCEos(298.0, 10.0); - testSystem.addComponent("nitrogen", 0.01); - testSystem.addComponent("CO2", 0.01); - testSystem.addComponent("methane", 0.68); - testSystem.addComponent("ethane", 0.1); - testSystem.addComponent("n-heptane", 0.2); - testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); - testModel = new neqsim.thermo.ThermodynamicModelTest(testSystem); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - testOps.TPflash(); - testSystem.initProperties(); - } +class SystemUMRPRUMCEosNewTest extends neqsim.NeqSimTest { + static neqsim.thermo.system.SystemInterface testSystem = null; + static neqsim.thermo.ThermodynamicModelTest testModel = null; + neqsim.thermo.ThermodynamicModelTest fugTest; - /** - *- * testCompressibility. - *
- */ - @Test - @DisplayName("test compressibility of gas phase") - public void testCompressibility() { - testSystem = new neqsim.thermo.system.SystemUMRPRUMCEos(298.0, 10.0); - testSystem.addComponent("nitrogen", 0.01); - testSystem.addComponent("CO2", 0.01); - testSystem.addComponent("methane", 0.68); - testSystem.addComponent("ethane", 0.1); - testSystem.addComponent("n-heptane", 0.2); - testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - testOps.TPflash(); - testSystem.initProperties(); - assertEquals(testSystem.getPhase(0).getZ(), 0.9711401538454589, 0.001); - } + /** + *+ * setUp. + *
+ */ + @BeforeAll + public static void setUp() { + // testSystem = new neqsim.thermo.system.SystemUMRPRUMCEos(298.0, 10.0); + testSystem = new neqsim.thermo.system.SystemUMRPRUMCEosNew(298.0, 10.0); + //testSystem = new neqsim.thermo.system.SystemSrkEos(298.0, 10.0); + testSystem.addComponent("nitrogen", 0.7); + //testSystem.addComponent("CO2", 0.01); + //testSystem.addComponent("methane", 0.68); + testSystem.addComponent("ethane", 0.3); + // testSystem.addComponent("n-heptane", 0.2); + // testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); + // testSystem.setMixingRule(1); + testSystem.setMixingRule(1); + testModel = new neqsim.thermo.ThermodynamicModelTest(testSystem); + // testModel = new neqsim.thermo.ThermodynamicModelTest(testSystem); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + testSystem.init(0); + testSystem.init(3); + //testSystem.initProperties(); + // testSystem.i + } - /** - *- * testTPflash2. - *
- */ - @Test - @DisplayName("test a TPflash2") - public void testTPflash2() { - assertEquals(2, testSystem.getNumberOfPhases()); - } + /** + *+ * testFugasities. + *
+ */ + // @Test + public void testFugasities() { + testSystem.init(0); + testSystem.init(1); + fugTest = new neqsim.thermo.ThermodynamicModelTest(testSystem); + assertTrue(fugTest.checkFugacityCoefficients()); - /** - *- * testTPflash. - *
- */ - @Test - @DisplayName("test a TPflash of the fluid (should return two phases)") - public void testTPflash() { - assertEquals(2, testSystem.getNumberOfPhases()); - } + double fucoef = testSystem.getComponent(0).getLogFugacityCoefficient(); - /** - *- * testFugacityCoefficients. - *
- */ - @Test - @DisplayName("test the fugacity coefficients calculated") - public void testFugacityCoefficients() { - assertTrue(testModel.checkFugacityCoefficients()); - } + assertEquals(-0.002884922, fucoef, 1e-6); - /** - *- * checkFugacityCoefficientsDP. - *
- */ - @Test - @DisplayName("test derivative of fugacity coefficients with respect to pressure") - public void checkFugacityCoefficientsDP() { - assertTrue(testModel.checkFugacityCoefficientsDP()); - } + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + testSystem.initProperties(); + double molvol = testSystem.getMolarVolume(); - /** - *- * checkFugacityCoefficientsDT. - *
- */ - @Test - @DisplayName("test derivative of fugacity coefficients with respect to temperature") - public void checkFugacityCoefficientsDT() { - assertTrue(testModel.checkFugacityCoefficientsDT()); - } + assertEquals(247.09909107115, molvol, 1e-2); + } - /** - *- * checkFugacityCoefficientsDn. - *
- */ - @Test - @DisplayName("test derivative of fugacity coefficients with respect to composition") - public void checkFugacityCoefficientsDn() { - assertTrue(testModel.checkFugacityCoefficientsDn()); - } + /** + *+ * testCompressibility. + *
+ */ + @Test + @DisplayName("test compressibility of gas phase") + public void testCompressibility() { + // testSystem = new neqsim.thermo.system.SystemPr(298.0, 10.0); + // testSystem = new SystemSrkEos(298.0, 10.0); + // testSystem = new neqsim.thermo.system.SystemUMRPRUMCEos(298.0, 10.0); + testSystem = new neqsim.thermo.system.SystemUMRPRUMCEosNew(298, 10); + testSystem.addComponent("nitrogen", 0.7); + // testSystem.addComponent("CO2", 0.01); + //testSystem.addComponent("methane", 0.68); + testSystem.addComponent("ethane", 0.3); + // testSystem.addComponent("n-heptane", 0.2); + //testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); + testSystem.setMixingRule(0); + testSystem.init(0); + // testSystem.init(1); + testSystem.init(3); + System.out.println("molar volume gas+oil is " + testSystem.getMolarVolume()); + System.out.println("molar volume gas is " + testSystem.getPhase(0).getMolarVolume()); + System.out.println("molar volume liquid is " + testSystem.getPhase(1).getMolarVolume()); + // ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + // testOps.TPflash(); - /** - *- * checkFugacityCoefficientsDn2. - *
- */ - @Test - @DisplayName("test derivative of fugacity coefficients with respect to composition (2nd method)") - public void checkFugacityCoefficientsDn2() { - assertTrue(testModel.checkFugacityCoefficientsDn2()); - } + // testSystem.initProperties(); + // assertEquals(0.9711401538454589, testSystem.getPhase(0).getZ(), 0.001); + } + + /** + *+ * testTPflash2. + *
+ */ + @Disabled + @Test + @DisplayName("test a TPflash2") + public void testTPflash2() { + assertEquals(2, testSystem.getNumberOfPhases()); + } + + /** + *+ * testTPflash. + *
+ */ + @Disabled + @Test + @DisplayName("test a TPflash of the fluid (should return two phases)") + public void testTPflash() { + assertEquals(2, testSystem.getNumberOfPhases()); + } + + /** + *+ * testFugacityCoefficients. + *
+ */ + @Test + @DisplayName("test the fugacity coefficients calculated") + public void testFugacityCoefficients() { + assertTrue(testModel.checkFugacityCoefficients()); + + // System.out.println("molar volume liquid is " + testSystem.((PhasePrEosvolcor) + // phase).getFC()); + } + + /** + *+ * checkFugacityCoefficientsDP. + *
+ */ + @Test + @DisplayName("test derivative of fugacity coefficients with respect to pressure") + public void checkFugacityCoefficientsDP() { + + assertTrue(testModel.checkFugacityCoefficientsDP()); + } + + /** + *+ * checkFugacityCoefficientsDT. + *
+ */ + + @Test + @DisplayName("test derivative of fugacity coefficients with respect to temperature") + public void checkFugacityCoefficientsDT() { + assertTrue(testModel.checkFugacityCoefficientsDT()); + } + + /** + *+ * checkFugacityCoefficientsDn. + *
+ */ + @Test + @DisplayName("test derivative of fugacity coefficients with respect to composition") + public void checkFugacityCoefficientsDn() { + assertTrue(testModel.checkFugacityCoefficientsDn()); + } + + /** + *+ * checkFugacityCoefficientsDn2. + *
+ */ + @Test + @DisplayName("test derivative of fugacity coefficients with respect to composition (2nd method)") + public void checkFugacityCoefficientsDn2() { + assertTrue(testModel.checkFugacityCoefficientsDn2()); + } - /** - *- * checkPhaseEnvelope. - *
- * - * @throws Exception - */ - @Test - @DisplayName("calculate phase envelope using UMR") - public void checkPhaseEnvelope() throws Exception { - testSystem = new neqsim.thermo.system.SystemUMRPRUMCEos(298.0, 10.0); - testSystem.addComponent("methane", 0.9); - testSystem.addComponent("ethane", 0.1); - testSystem.addComponent("propane", 0.1); - testSystem.addComponent("i-butane", 0.1); - testSystem.addComponent("n-butane", 0.1); - testSystem.addComponent("n-pentane", 0.1); - testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); - testSystem.init(0); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - try { - testOps.calcPTphaseEnvelope(); - System.out.println("Cricondenbar " + (testOps.get("cricondenbar")[0] - 273.15) + " " - + testOps.get("cricondenbar")[1]); - } catch (Exception e) { - assertTrue(false); - throw new Exception(e); - } - assertEquals(testOps.get("cricondenbar")[1], 130.686140727503, 0.02); + /** + *+ * checkPhaseEnvelope. + *
+ * + * @throws Exception + */ + @Test + @DisplayName("calculate phase envelope using UMR") + public void checkPhaseEnvelope() throws Exception { + testSystem = new neqsim.thermo.system.SystemUMRPRUMCEos(298.0, 10.0); + testSystem.addComponent("methane", 0.9); + testSystem.addComponent("ethane", 0.1); + testSystem.addComponent("propane", 0.1); + testSystem.addComponent("i-butane", 0.1); + testSystem.addComponent("n-butane", 0.1); + testSystem.addComponent("n-pentane", 0.1); + testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); + testSystem.init(0); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + try { + testOps.calcPTphaseEnvelope(); + System.out.println("Cricondenbar " + (testOps.get("cricondenbar")[0] - 273.15) + " " + + testOps.get("cricondenbar")[1]); + } catch (Exception e) { + assertTrue(false); + throw new Exception(e); } + assertEquals(testOps.get("cricondenbar")[1], 130.686140727503, 0.02); + } } diff --git a/src/test/java/neqsim/thermo/util/example/ActivityCalc.java b/src/test/java/neqsim/thermo/util/example/ActivityCalc.java index c3ffdcce77..a1c15e1d87 100644 --- a/src/test/java/neqsim/thermo/util/example/ActivityCalc.java +++ b/src/test/java/neqsim/thermo/util/example/ActivityCalc.java @@ -41,7 +41,7 @@ public static void main(String args[]) { } catch (Exception e) { } - testSystem.display(); + //testSystem.display(); System.out.println("activity water " + testSystem.getPhase(1).getActivityCoefficient(1)); } } diff --git a/src/test/java/neqsim/thermo/util/example/ModelTest.java b/src/test/java/neqsim/thermo/util/example/ModelTest.java index 5fe82cf82e..01c0cec9e5 100644 --- a/src/test/java/neqsim/thermo/util/example/ModelTest.java +++ b/src/test/java/neqsim/thermo/util/example/ModelTest.java @@ -3,7 +3,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.thermo.system.SystemInterface; -import neqsim.thermo.system.SystemSrkCPAstatoil; +import neqsim.thermo.system.SystemSrkCPA; import neqsim.thermodynamicOperations.ThermodynamicOperations; /** @@ -24,8 +24,10 @@ public class ModelTest { public static void main(String args[]) { // SystemInterface testSystem = new SystemFurstElectrolyteEos(280.15,10.00); - // SystemInterface testSystem = new SystemSrkEos(298.15, 10.01325); - SystemInterface testSystem = new SystemSrkCPAstatoil(273.14 + 92, 42.0); + //SystemInterface testSystem = new SystemSrkEos(500, 1.0); + //SystemInterface testSystem = new SystemSrkCPAstatoil(273+150, 1.0); + SystemInterface testSystem = new SystemSrkCPA(273+150, 70); + //SystemInterface testSystem = new SystemSrkCPAs(273+150, 1.0); // SystemInterface testSystem = new SystemElectrolyteCPAstatoil(273.14 + 12, // 61.0); // SystemInterface testSystem = new SystemFurstElectrolyteEos(273.14 + 12, @@ -34,25 +36,25 @@ public static void main(String args[]) { // SystemInterface testSystem = new SystemSrkEos(298.15, 1.01325); ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - testSystem.addComponent("methane", 100); - testSystem.addComponent("n-heptane", 1); - // testSystem.addComponent("water", 100); - // testSystem.addComponent("methane", 1); - // testSystem.addComponent("ethane", 1); - // testSystem.addComponent("TEG", 9); - // testSystem.addComponent("MEG", 3.1); + //testSystem.addComponent("methane", 100); + //testSystem.addComponent("n-heptane", 1); + testSystem.addComponent("water", 50); + //testSystem.addComponent("methane", 10); + //testSystem.addComponent("ethane", 15); + testSystem.addComponent("TEG", 9); + testSystem.addComponent("MEG", 50); // testSystem.addComponent("n-octane", 3.1); // testSystem.addComponent("Na+", 0.1); // testSystem.addComponent("Cl-", 0.1); // testSystem.addComponent("MEG", 2.1); - // testSystem.addComponent("methanol", 5.3); + testSystem.addComponent("methanol", 20); /// testSystem.addComponent("MEG", 5.3); // testSystem.addComponent("MEG", 10.0); // testSystem.addTBPfraction("C8", 10.1, 90.0 / 1000.0, 0.8); - testSystem.addComponent("MEG", 10.5); + //testSystem.addComponent("MEG", 10.5); // testSystem.createDatabase(true); // testSystem.useVolumeCorrection(true); - testSystem.setMixingRule(2); + testSystem.setMixingRule(10); // testSystem.setMixingRule("HV", "NRTL"); // testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); // testSystem.setMixingRule(9); @@ -63,7 +65,7 @@ public static void main(String args[]) { neqsim.thermo.ThermodynamicModelTest testModel = new neqsim.thermo.ThermodynamicModelTest(testSystem); testModel.runTest(); - testSystem.display(); + // testSystem.display(); testSystem.init(3); double cp = testSystem.getPhase(1).getCp(); diff --git a/src/test/java/neqsim/thermo/util/example/PressureLoadingCurve.java b/src/test/java/neqsim/thermo/util/example/PressureLoadingCurve.java index 9488fab173..f59e5e74c5 100644 --- a/src/test/java/neqsim/thermo/util/example/PressureLoadingCurve.java +++ b/src/test/java/neqsim/thermo/util/example/PressureLoadingCurve.java @@ -7,68 +7,68 @@ import neqsim.thermodynamicOperations.ThermodynamicOperations; /** - *PressureLoadingCurve class.
+ *+ * PressureLoadingCurve class. + *
* * @author asmund * @version $Id: $Id * @since 2.2.3 */ public class PressureLoadingCurve { - static Logger logger = LogManager.getLogger(PressureLoadingCurve.class); + static Logger logger = LogManager.getLogger(PressureLoadingCurve.class); - /** - * This method is just meant to test the thermo package. - * - * @param args an array of {@link java.lang.String} objects - */ - @SuppressWarnings("unused") - public static void main(String args[]) { - double[][] points; - SystemInterface testSystem = new SystemFurstElectrolyteEos((273.15 + 75.0), 1.3); + /** + * This method is just meant to test the thermo package. + * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String args[]) { + double[][] points; + SystemInterface testSystem = new SystemFurstElectrolyteEos((273.15 + 75.0), 1.3); - double loading = 0.65; - double molProsMDEA = 11.21; - testSystem.addComponent("CO2", loading * molProsMDEA); - testSystem.addComponent("water", 100.0 - molProsMDEA - loading * molProsMDEA); - testSystem.addComponent("MDEA", molProsMDEA); - // testSystem.addComponent("Piperazine", loading*molProsMDEA*0.1); - testSystem.chemicalReactionInit(); - testSystem.createDatabase(true); - testSystem.setMixingRule(4); - testSystem.init(0); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - // testOps.calcPloadingCurve(); - long time = System.currentTimeMillis(); + double loading = 0.65; + double molProsMDEA = 11.21; + testSystem.addComponent("CO2", loading * molProsMDEA); + testSystem.addComponent("water", 100.0 - molProsMDEA - loading * molProsMDEA); + testSystem.addComponent("MDEA", molProsMDEA); + // testSystem.addComponent("Piperazine", loading*molProsMDEA*0.1); + testSystem.chemicalReactionInit(); + testSystem.createDatabase(true); + testSystem.setMixingRule(4); + testSystem.init(0); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + // testOps.calcPloadingCurve(); + long time = System.currentTimeMillis(); - try { - testOps.bubblePointPressureFlash(true); - } catch (Exception e) { - logger.error(e.toString()); - } - logger.info("Time taken for benchmark flash = " + (System.currentTimeMillis() - time)); - testSystem.display(); - logger.info("pressure " + testSystem.getPressure()); - int reactionNumber = 0; - logger.info("K " + testSystem.getChemicalReactionOperations().getReactionList() - .getReaction(reactionNumber).calcK(testSystem, 1)); - logger.info("Kx " + testSystem.getChemicalReactionOperations().getReactionList() - .getReaction(reactionNumber).calcKx(testSystem, 1)); - logger.info("Kgamma " + testSystem.getChemicalReactionOperations().getReactionList() - .getReaction(reactionNumber).calcKgamma(testSystem, 1)); - testSystem.setPressure(100.0); - testSystem.getChemicalReactionOperations().solveChemEq(1); - logger.info("K " + testSystem.getChemicalReactionOperations().getReactionList() - .getReaction(reactionNumber).calcK(testSystem, 1)); - logger.info("Kx " + testSystem.getChemicalReactionOperations().getReactionList() - .getReaction(reactionNumber).calcKx(testSystem, 1)); - logger.info("Kgamma " + testSystem.getChemicalReactionOperations().getReactionList() - .getReaction(reactionNumber).calcKgamma(testSystem, 1)); - - testSystem.display(); - // thermo.ThermodynamicModelTest testModel = new - // thermo.ThermodynamicModelTest(testSystem); - // testModel.runTest(); - // write data to netcdf - // testOps.writeNetCDF("c:/testloading.nc"); + try { + testOps.bubblePointPressureFlash(true); + } catch (Exception e) { + logger.error(e.toString()); } + logger.info("Time taken for benchmark flash = " + (System.currentTimeMillis() - time)); + testSystem.display(); + logger.info("pressure " + testSystem.getPressure()); + int reactionNumber = 0; + logger.info("K " + testSystem.getChemicalReactionOperations().getReactionList() + .getReaction(reactionNumber).calcK(testSystem, 1)); + logger.info("Kx " + testSystem.getChemicalReactionOperations().getReactionList() + .getReaction(reactionNumber).calcKx(testSystem, 1)); + logger.info("Kgamma " + testSystem.getChemicalReactionOperations().getReactionList() + .getReaction(reactionNumber).calcKgamma(testSystem, 1)); + testSystem.setPressure(100.0); + testSystem.getChemicalReactionOperations().solveChemEq(1); + logger.info("K " + testSystem.getChemicalReactionOperations().getReactionList() + .getReaction(reactionNumber).calcK(testSystem, 1)); + logger.info("Kx " + testSystem.getChemicalReactionOperations().getReactionList() + .getReaction(reactionNumber).calcKx(testSystem, 1)); + logger.info("Kgamma " + testSystem.getChemicalReactionOperations().getReactionList() + .getReaction(reactionNumber).calcKgamma(testSystem, 1)); + + testSystem.display(); + // thermo.ThermodynamicModelTest testModel = new + // thermo.ThermodynamicModelTest(testSystem); + // testModel.runTest(); + } } diff --git a/src/test/java/neqsim/thermo/util/example/TestNeqSimBug.java b/src/test/java/neqsim/thermo/util/example/TestNeqSimBug.java index 5d70047559..e63abe50bd 100644 --- a/src/test/java/neqsim/thermo/util/example/TestNeqSimBug.java +++ b/src/test/java/neqsim/thermo/util/example/TestNeqSimBug.java @@ -1,7 +1,6 @@ package neqsim.thermo.util.example; import java.util.Arrays; -import neqsim.api.ioc.CalculationResult; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -16,61 +15,53 @@ * @since 2.2.3 */ public class TestNeqSimBug { - /** - *- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - - // double[] spec1 = {1.0}; // salt water Pressure - // double[] spec2 = { -39678.555}; // salt water Enthalpy + /** + *+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { - SystemInterface fluid = new SystemSrkEos(273.15 + 55.0, 10.0); - fluid.addComponent("water", 0.0386243104934692); - fluid.addComponent("nitrogen", 1.08263303991407E-05); - fluid.addComponent("CO2", 0.00019008457660675); - fluid.addComponent("methane", 0.00305547803640366); - fluid.addComponent("ethane", 0.00200786963105202); - fluid.addComponent("propane", 0.00389420658349991); - fluid.addComponent("i-butane", 0.00179276615381241); - fluid.addComponent("n-butane", 0.00255768150091171); - fluid.addComponent("i-pentane", 0.00205287128686905); - fluid.addComponent("n-pentane", 0.00117853358387947); - fluid.addTBPfraction("CHCmp_1", 0.000867870151996613, 0.0810000000000000, 0.72122997045517); - fluid.addTBPfraction("CHCmp_2", 0.048198757171630900, 0.0987799987792969, - 0.754330039024353); - fluid.addTBPfraction("CHCmp_3", 0.097208471298217800, 0.1412200012207030, 0.81659996509552); - fluid.addTBPfraction("CHCmp_4", 0.165174083709717000, 0.1857899932861330, - 0.861050009727478); - fluid.addTBPfraction("CHCmp_5", 0.279571933746338000, 0.2410899963378910, - 0.902539968490601); - fluid.addTBPfraction("CHCmp_6", 0.240494251251221000, 0.4045100097656250, - 0.955269992351531); - fluid.addTBPfraction("CHCmp_7", 0.113120021820068000, 0.9069699707031250, 1.0074599981308); + // double[] spec1 = {1.0}; // salt water Pressure + // double[] spec2 = { -39678.555}; // salt water Enthalpy - fluid.createDatabase(true); - fluid.setMixingRule(2); - fluid.useVolumeCorrection(true); - fluid.setMultiPhaseCheck(true); + SystemInterface fluid = new SystemSrkEos(273.15 + 55.0, 10.0); + fluid.addComponent("water", 0.0386243104934692); + fluid.addComponent("nitrogen", 1.08263303991407E-05); + fluid.addComponent("CO2", 0.00019008457660675); + fluid.addComponent("methane", 0.00305547803640366); + fluid.addComponent("ethane", 0.00200786963105202); + fluid.addComponent("propane", 0.00389420658349991); + fluid.addComponent("i-butane", 0.00179276615381241); + fluid.addComponent("n-butane", 0.00255768150091171); + fluid.addComponent("i-pentane", 0.00205287128686905); + fluid.addComponent("n-pentane", 0.00117853358387947); + fluid.addTBPfraction("CHCmp_1", 0.000867870151996613, 0.0810000000000000, 0.72122997045517); + fluid.addTBPfraction("CHCmp_2", 0.048198757171630900, 0.0987799987792969, 0.754330039024353); + fluid.addTBPfraction("CHCmp_3", 0.097208471298217800, 0.1412200012207030, 0.81659996509552); + fluid.addTBPfraction("CHCmp_4", 0.165174083709717000, 0.1857899932861330, 0.861050009727478); + fluid.addTBPfraction("CHCmp_5", 0.279571933746338000, 0.2410899963378910, 0.902539968490601); + fluid.addTBPfraction("CHCmp_6", 0.240494251251221000, 0.4045100097656250, 0.955269992351531); + fluid.addTBPfraction("CHCmp_7", 0.113120021820068000, 0.9069699707031250, 1.0074599981308); - ThermodynamicOperations fluidOps = new ThermodynamicOperations(fluid); + fluid.createDatabase(true); + fluid.setMixingRule(2); + fluid.useVolumeCorrection(true); + fluid.setMultiPhaseCheck(true); - double spec1 = 73.22862045673597; // grane Pressure - double spec2 = -62179.7247076579; // Enthalpy + ThermodynamicOperations fluidOps = new ThermodynamicOperations(fluid); - CalculationResult s = - fluidOps.propertyFlash(Arrays.asList(spec1), Arrays.asList(spec2), 3, null, null); + double spec1 = 73.22862045673597; // grane Pressure + double spec2 = -62179.7247076579; // Enthalpy - Double[][] prop = s.fluidProperties; + fluidOps.propertyFlash(Arrays.asList(spec1), Arrays.asList(spec2), 3, null, null); - - /* - * for (int t = 0; t < 1; t++) { fluid.setPressure(spec1[t]); fluidOps.PHflash(spec2[t], - * "J/mol"); // fluidOps.TPflash(); fluid.init(2); fluid.initPhysicalProperties(); - */ - fluid.display(); - } + /* + * for (int t = 0; t < 1; t++) { fluid.setPressure(spec1[t]); fluidOps.PHflash(spec2[t], + * "J/mol"); // fluidOps.TPflash(); fluid.init(2); fluid.initPhysicalProperties(); + */ + fluid.display(); + } } diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTest.java new file mode 100644 index 0000000000..6ce26e05b3 --- /dev/null +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTest.java @@ -0,0 +1,103 @@ +/** + * + */ +package neqsim.thermodynamicOperations.flashOps; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +/** + * @author ESOL + * + */ +class TPFlashTest { + + static neqsim.thermo.system.SystemInterface testSystem = null; + static ThermodynamicOperations testOps = null; + + /** + * @throws java.lang.Exception + */ + @BeforeEach + void setUp() throws Exception { + testSystem = new neqsim.thermo.system.SystemPrEos(243.15, 300.0); + testSystem.addComponent("nitrogen", 1.0); + testSystem.addComponent("methane", 90.0); + testSystem.addComponent("ethane", 2.0); + testSystem.addComponent("propane", 1.0); + testSystem.addComponent("i-butane", 1.0); + testSystem.addComponent("n-butane", 1.0); + testSystem.addComponent("i-pentane", 1.0); + testSystem.addComponent("n-pentane", 1.0); + testSystem.addComponent("n-hexane", 1.0); + testSystem.addComponent("nC10", 1.0); + testSystem.addComponent("water", 10.0); + testSystem.setMixingRule("classic"); + testSystem.setMultiPhaseCheck(true); + } + + void testRun() { + testSystem.setMultiPhaseCheck(true); + testSystem.setPressure(10.0, "bara"); + testSystem.setTemperature(25.0, "C"); + testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + testSystem.initProperties(); + assertEquals(-430041.49312169873, testSystem.getEnthalpy(), 1e-2); + } + + @Test + void testRun2() { + testSystem.setMultiPhaseCheck(false); + testSystem.setPressure(10.0, "bara"); + testSystem.setTemperature(25.0, "C"); + testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + testSystem.initProperties(); + assertEquals(-359394.2117634512, testSystem.getEnthalpy(), 1e-2); + } + + @Test + void testRun3() { + testSystem.setMultiPhaseCheck(false); + testSystem.setPressure(500.0, "bara"); + testSystem.setTemperature(15.0, "C"); + testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + testSystem.initProperties(); + assertEquals(-552568.2810227782, testSystem.getEnthalpy(), 1e-2); + } + + // @Test + void testRun4() { + testSystem.setMultiPhaseCheck(true); + testSystem.setPressure(500.0, "bara"); + testSystem.setTemperature(15.0, "C"); + testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + testSystem.initProperties(); + assertEquals(-936973.1969586421, testSystem.getEnthalpy(), 1e-2); + } + + @Test + void testRun5() { + neqsim.thermo.system.SystemInterface testSystem5 = + new neqsim.thermo.system.SystemUMRPRUMCEos(243.15, 300.0); + testSystem5.addComponent("methane", 4.16683e-1); + testSystem5.addComponent("ethane", 1.7522e-1); + testSystem5.addComponent("n-pentane", 3.58009e-1); + testSystem5.addComponent("nC16", 5.00888e-2); + testSystem5.setMixingRule("classic"); + testSystem5.setMultiPhaseCheck(true); + testSystem5.setPressure(90.03461693, "bara"); + testSystem5.setTemperature(293.15, "K"); + testSystem5.setTotalFlowRate(4.925e-07, "kg/sec"); + testOps = new ThermodynamicOperations(testSystem5); + testOps.TPflash(); + testSystem5.initProperties(); + double beta = testSystem5.getBeta(); + assertEquals(6.272876522701802E-7, beta, 1e-5); + } +} diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTestWellFluid.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTestWellFluid.java new file mode 100644 index 0000000000..3af1b0eeb1 --- /dev/null +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTestWellFluid.java @@ -0,0 +1,79 @@ +/** + * + */ +package neqsim.thermodynamicOperations.flashOps; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +/** + * @author ESOL + * + */ +class TPFlashTestWellFluid { + + static neqsim.thermo.system.SystemInterface wellFluid = null; + static ThermodynamicOperations testOps = null; + + /** + * @throws java.lang.Exception + */ + @BeforeEach + void setUp() throws Exception { + wellFluid = new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 30.0, 65.00); + wellFluid.addComponent("oxygen", 0.0); + wellFluid.addComponent("H2S", 0.00008); + wellFluid.addComponent("nitrogen", 0.08); + wellFluid.addComponent("CO2", 3.56); + wellFluid.addComponent("methane", 87.36); + wellFluid.addComponent("ethane", 4.02); + wellFluid.addComponent("propane", 1.54); + wellFluid.addComponent("i-butane", 0.2); + wellFluid.addComponent("n-butane", 0.42); + wellFluid.addComponent("i-pentane", 0.15); + wellFluid.addComponent("n-pentane", 0.20); + + wellFluid.addTBPfraction("C6_Frigg", 0.24, 84.99 / 1000.0, 695.0 / 1000.0); + wellFluid.addTBPfraction("C7_Frigg", 0.34, 97.87 / 1000.0, 718.0 / 1000.0); + wellFluid.addTBPfraction("C8_Frigg", 0.33, 111.54 / 1000.0, 729.0 / 1000.0); + wellFluid.addTBPfraction("C9_Frigg", 0.19, 126.1 / 1000.0, 749.0 / 1000.0); + wellFluid.addTBPfraction("C10_Frigg", 0.15, 140.14 / 1000.0, 760.0 / 1000.0); + wellFluid.addTBPfraction("C11_Frigg", 0.69, 175.0 / 1000.0, 830.0 / 1000.0); + wellFluid.addTBPfraction("C12_Frigg", 0.5, 280.0 / 1000.0, 914.0 / 1000.0); + wellFluid.addTBPfraction("C13_Frigg", 0.103, 560.0 / 1000.0, 980.0 / 1000.0); + + wellFluid.addTBPfraction("C6_ML_WestCtrl", 0.0, 84.0 / 1000.0, 684.0 / 1000.0); + wellFluid.addTBPfraction("C7_ML_WestCtrl", 0.0, 97.9 / 1000.0, 742.0 / 1000.0); + wellFluid.addTBPfraction("C8_ML_WestCtrl", 0.0, 111.5 / 1000.0, 770.0 / 1000.0); + wellFluid.addTBPfraction("C9_ML_WestCtrl", 0.0, 126.1 / 1000.0, 790.0 / 1000.0); + wellFluid.addTBPfraction("C10_ML_WestCtrl", 0.0, 140.14 / 1000.0, 805.0 / 1000.0); + wellFluid.addTBPfraction("C11_ML_WestCtrl", 0.0, 175.0 / 1000.0, 815.0 / 1000.0); + wellFluid.addTBPfraction("C12_ML_WestCtrl", 0.0, 280.0 / 1000.0, 835.0 / 1000.0); + wellFluid.addTBPfraction("C13_ML_WestCtrl", 0.0, 450.0 / 1000.0, 850.0 / 1000.0); + wellFluid.addComponent("water", 12.01); + wellFluid.setMixingRule(10); + wellFluid.init(0); + wellFluid.setMultiPhaseCheck(true); + } + + @Test + void testTPflashComp1() { + testOps = new ThermodynamicOperations(wellFluid); + testOps.TPflash(); + } + + @Test + void testTPflashComp2() { + wellFluid.setTemperature(339.04); + wellFluid.setPressure(1.5); + wellFluid.setMolarComposition(new double[] {0.0, 4.76579e-6, 1.21459e-5, 1.3409e-3, 3.30439e-2, + 5.06e-3, 7.34e-3, 1.53e-3, 4.11e-3, 1.58e-3, 2.255e-3, 2.8779e-4, 8.58e-4, 8.73e-4, 8.5e-4, + 3.88e-3, 7.36e-2, 1.47e-1, 6.176e-2, 3.69e-2, 7.735e-3, 1.023e-2, 6.19e-3, 4.3e-3, 1.2e-2, + 8.96e-3, 1.539e-3, 5.9921e-1}); + testOps = new ThermodynamicOperations(wellFluid); + testOps.TPflash(); + assertEquals(1.4292538950216407, wellFluid.getPhase(0).getDensity(), 1e-5); + } +} diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/TVFlashTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/TVFlashTest.java new file mode 100644 index 0000000000..a396e02a5d --- /dev/null +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/TVFlashTest.java @@ -0,0 +1,72 @@ +/** + * + */ +package neqsim.thermodynamicOperations.flashOps; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +/** + * @author ESOL + * + */ +class TVFlashTest { + + static neqsim.thermo.system.SystemInterface testSystem = null; + static neqsim.thermo.system.SystemInterface testSystem2 = null; + static ThermodynamicOperations testOps = null; + + /** + * @throws java.lang.Exception + */ + @BeforeEach + void setUp() throws Exception { + testSystem = new neqsim.thermo.system.SystemUMRPRUMCEos(293.15, 0.1); + testSystem.addComponent("methane", 0.0); + testSystem.addComponent("ethane", 0.0); + testSystem.addComponent("n-pentane", 9E-1); + testSystem.addComponent("nC16", 1E-1); + testSystem.setMixingRule("classic"); + testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + testSystem.initProperties(); + testSystem.setTotalFlowRate(1.0, "kg/sec"); + testOps.TPflash(); + testSystem.initProperties(); + + testSystem2 = new neqsim.thermo.system.SystemUMRPRUMCEos(293.15, 0.1); + testSystem2.addComponent("methane", 8.5E-1); + testSystem2.addComponent("ethane", 1.5E-1); + testSystem2.addComponent("n-pentane", 0); + testSystem2.addComponent("nC16", 0); + testSystem2.setMixingRule("classic"); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem2); + testOps.TPflash(); + testSystem2.initProperties(); + testSystem2.setTotalFlowRate(0.3, "kg/sec"); + testOps.TPflash(); + testSystem2.initProperties(); + } + + @Test + void testTVflash() { + double total_rig_volume = 0.998; + + for(int i=0;i<50;i++) { + testSystem.addFluid(testSystem2); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + try { + testOps.TVflash(total_rig_volume, "m3"); + } + catch(Exception e) { + System.out.println("error iterations " + i); + e.printStackTrace(); + } + } + assertEquals(235263.80103781424, testSystem.getEnthalpy(), 1e-2); + } + + } + diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/WaxFlashTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/WaxFlashTest.java new file mode 100644 index 0000000000..f9b22040c6 --- /dev/null +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/WaxFlashTest.java @@ -0,0 +1,76 @@ +/** + * + */ +package neqsim.thermodynamicOperations.flashOps; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import neqsim.thermo.system.SystemInterface; +import neqsim.thermo.system.SystemSrkEos; +import neqsim.thermodynamicOperations.ThermodynamicOperations; +import neqsim.util.database.NeqSimDataBase; + +/** + * @author ESOL + * + */ +class WaxFlashTest { + + static neqsim.thermo.system.SystemInterface testSystem = null; + static ThermodynamicOperations testOps = null; + + /** + * @throws java.lang.Exception + */ + @BeforeEach + void setUp() throws Exception { + NeqSimDataBase.setConnectionString("jdbc:derby:C:/Users/esol/OneDrive - Equinor/programming/neqsim/src/main/resources/data/neqsimtestdatabase"); + NeqSimDataBase.setCreateTemporaryTables(true); + + testSystem = new SystemSrkEos(273.0 + 30, 50.0); + testSystem.addComponent("CO2", 0.018); + testSystem.addComponent("nitrogen", 0.333); + testSystem.addComponent("methane", 96.702); + testSystem.addComponent("ethane", 1.773); + testSystem.addComponent("propane", 0.496); + testSystem.addComponent("i-butane", 0.099); + testSystem.addComponent("n-butane", 0.115); + testSystem.addComponent("i-pentane", 0.004); + testSystem.addComponent("n-pentane", 0.024); + testSystem.addComponent("n-heptane", 0.324); + testSystem.addPlusFraction("C9", 0.095, 207.0 / 1000.0, 0.8331); + testSystem.getCharacterization().characterisePlusFraction(); + testSystem.getWaxModel().addTBPWax(); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + testSystem.addSolidComplexPhase("wax"); + // testSystem.setSolidPhaseCheck("nC14"); + testSystem.setMultiphaseWaxCheck(true); + NeqSimDataBase.setConnectionString("jdbc:derby:classpath:data/neqsimthermodatabase"); + NeqSimDataBase.setCreateTemporaryTables(false); + //testSystem.display(); + } + + /** + * Test method for {@link neqsim.thermodynamicOperations.flashOps.PHFlash#run()}. + */ + @Test + @Disabled + void testRun() { + testOps = new ThermodynamicOperations(testSystem); + try { + testOps.calcWAT(); + testOps.TPflash(); + } catch (Exception e) { + e.printStackTrace(); + } + double waxVolumeFrac = 0; + if (testSystem.hasPhaseType("wax")) { + waxVolumeFrac = testSystem.getWtFraction(testSystem.getPhaseIndexOfPhase("wax")); + } + } + +}