From 2a24ca1d879a72f4ee755c418de9ec66979c9ea7 Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Tue, 2 Jul 2024 22:39:13 +0000 Subject: [PATCH] add 5 comp PR --- .../component/ComponentPR_5CompModel.java | 153 ++++++++++++++++++ .../thermo/phase/PhasePrEoS_5CompModel.java | 47 ++++++ .../thermo/system/SystemPrEos5CompModel.java | 68 ++++++++ .../system/SystemPrEos5CompModelTest.java | 39 +++++ 4 files changed, 307 insertions(+) create mode 100644 src/main/java/neqsim/thermo/component/ComponentPR_5CompModel.java create mode 100644 src/main/java/neqsim/thermo/phase/PhasePrEoS_5CompModel.java create mode 100644 src/main/java/neqsim/thermo/system/SystemPrEos5CompModel.java create mode 100644 src/test/java/neqsim/thermo/system/SystemPrEos5CompModelTest.java diff --git a/src/main/java/neqsim/thermo/component/ComponentPR_5CompModel.java b/src/main/java/neqsim/thermo/component/ComponentPR_5CompModel.java new file mode 100644 index 0000000000..f3a9c59895 --- /dev/null +++ b/src/main/java/neqsim/thermo/component/ComponentPR_5CompModel.java @@ -0,0 +1,153 @@ +package neqsim.thermo.component; + +import neqsim.thermo.component.attractiveEosTerm.AttractiveTermPr1978; + +/** + *
+ * ComponentPR_5CompModel class. + *
+ * + * @author Even Solbraa + * @version $Id: $Id + */ +public class ComponentPR_5CompModel extends ComponentPR { + private static final long serialVersionUID = 1000; + private double omegaA = .457243333330; + + + private double omegaB = .077803333; + + /** + *+ * Constructor for ComponentPR_5CompModel. + *
+ * + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. + */ + public ComponentPR_5CompModel(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); + + if (name.equals("CO2")) { + setMolarMass(44.01, "lbm/lbmol"); + setTC(574.0, "R"); + setPC(1069.51, "psia"); + setAcentricFactor(0.12256); + setVolumeCorrectionConst(-0.27593 * 6.242796057614462E-05 * b); + setOmegaA(0.427705); + setOmegaB(0.0696460); + } else if (name.equals("H2S")) { + setMolarMass(34.082, "lbm/lbmol"); + setTC(672.12, "R"); + setPC(1299.97, "psia"); + setAcentricFactor(0.04916); + setVolumeCorrectionConst(-0.22896 * 6.242796057614462E-05 * b); + setOmegaA(0.436743); + setOmegaB(0.0724373); + } else if (name.equals("nitrogen")) { + setMolarMass(28.014, "lbm/lbmol"); + setTC(227.16, "R"); + setPC(492.84, "psia"); + setAcentricFactor(0.03700); + setVolumeCorrectionConst(-0.21067 * 6.242796057614462E-05 * b); + setOmegaA(0.457236); + setOmegaB(0.0777961); + } else { + + double Tca = 0.1; + double Tcb = 0.1; + double Tcc = 0.1; + + double Pca = -0.00273458; + double Pcb = 0.1; + double Pcc = 0.1; + + setTC(227.16, "R"); + setPC(492.84, "psia"); + setAcentricFactor(0.03700); + setVolumeCorrectionConst(-0.21067 * 6.242796057614462E-05 * b); + setOmegaA(0.457236); + setOmegaB(0.0777961); + } + + a = getOmegaA() * R * R * criticalTemperature * criticalTemperature / criticalPressure; + b = getOmegaB() * R * criticalTemperature / criticalPressure; + + setAttractiveParameter(new AttractiveTermPr1978(this)); + } + + /** + *+ * Constructor for ComponeComponentPR_5CompModelntPR. + *
+ * + * @param number a int + * @param TC Critical temperature + * @param PC Critical pressure + * @param M Molar mass + * @param a Acentric factor + * @param moles Number of moles + */ + public ComponentPR_5CompModel(int number, double TC, double PC, double M, double a, + double moles) { + super(number, TC, PC, M, a, moles); + } + + /** {@inheritDoc} */ + @Override + public ComponentPR_5CompModel clone() { + ComponentPR_5CompModel clonedComponent = null; + try { + clonedComponent = (ComponentPR_5CompModel) super.clone(); + } catch (Exception ex) { + logger.error("Cloning failed.", ex); + } + + return clonedComponent; + } + + /** {@inheritDoc} */ + @Override + public double calca() { + return getOmegaA() * R * R * criticalTemperature * criticalTemperature / criticalPressure; + } + + /** {@inheritDoc} */ + @Override + public double calcb() { + return getOmegaB() * R * criticalTemperature / criticalPressure; + } + + /** {@inheritDoc} */ + @Override + public double getVolumeCorrection() { + if (ionicCharge != 0) { + return 0.0; + } + if (Math.abs(getVolumeCorrectionConst()) > 1.0e-10) { + return getVolumeCorrectionConst() * b; + } else if (Math.abs(this.getRacketZ()) < 1e-10) { + racketZ = 0.29056 - 0.08775 * getAcentricFactor(); + } + return 0.50033 * (0.25969 - this.getRacketZ()) * R * criticalTemperature / criticalPressure; + } + + public double getOmegaA() { + return omegaA; + } + + public void setOmegaA(double omegaA) { + this.omegaA = omegaA; + } + + public double getOmegaB() { + return omegaB; + } + + public void setOmegaB(double omegaB) { + this.omegaB = omegaB; + } + +} diff --git a/src/main/java/neqsim/thermo/phase/PhasePrEoS_5CompModel.java b/src/main/java/neqsim/thermo/phase/PhasePrEoS_5CompModel.java new file mode 100644 index 0000000000..5408713e25 --- /dev/null +++ b/src/main/java/neqsim/thermo/phase/PhasePrEoS_5CompModel.java @@ -0,0 +1,47 @@ +package neqsim.thermo.phase; + +import neqsim.thermo.component.ComponentPR_5CompModel; + +/** + *+ * PhasePrEos class. + *
+ * + * @author Even Solbraa + * @version $Id: $Id + */ +public class PhasePrEoS_5CompModel extends PhasePrEos { + private static final long serialVersionUID = 1000; + + + + /** + *+ * Constructor for PhasePrEoS_5CompModel. + *
+ */ + public PhasePrEoS_5CompModel() { + super(); + thermoPropertyModelName = "PR-EoS-5-Component"; + } + + /** {@inheritDoc} */ + @Override + public PhasePrEoS_5CompModel clone() { + PhasePrEoS_5CompModel clonedPhase = null; + try { + clonedPhase = (PhasePrEoS_5CompModel) super.clone(); + } catch (Exception ex) { + logger.error("Cloning failed.", ex); + } + + return clonedPhase; + } + + /** {@inheritDoc} */ + @Override + public void addComponent(String name, double moles, double molesInPhase, int compNumber) { + super.addComponent(name, molesInPhase, compNumber); + componentArray[compNumber] = new ComponentPR_5CompModel(name, moles, molesInPhase, compNumber); + } +} diff --git a/src/main/java/neqsim/thermo/system/SystemPrEos5CompModel.java b/src/main/java/neqsim/thermo/system/SystemPrEos5CompModel.java new file mode 100644 index 0000000000..a06cc207a9 --- /dev/null +++ b/src/main/java/neqsim/thermo/system/SystemPrEos5CompModel.java @@ -0,0 +1,68 @@ +package neqsim.thermo.system; + +import neqsim.thermo.phase.PhasePrEoS_5CompModel; + +/** + * This class defines a thermodynamic system using the Peng Robinson 5 component model + * + * @author Even Solbraa + * @version $Id: $Id + */ +public class SystemPrEos5CompModel extends SystemPrEos1978 { + private static final long serialVersionUID = 1000; + + /** + *+ * Constructor for SystemPrEos5CompModel. + *
+ */ + public SystemPrEos5CompModel() { + this(298.15, 1.0, false); + } + + /** + *+ * Constructor for SystemPrEos_5CompModel. + *
+ * + * @param T The temperature in unit Kelvin + * @param P The pressure in unit bara (absolute pressure) + */ + public SystemPrEos5CompModel(double T, double P) { + this(T, P, false); + } + + /** + *+ * Constructor for mSystemPrEos5CompModel. + *
+ * + * @param T The temperature in unit Kelvin + * @param P The pressure in unit bara (absolute pressure) + * @param checkForSolids Set true to do solid phase check and calculations + */ + public SystemPrEos5CompModel(double T, double P, boolean checkForSolids) { + super(T, P, checkForSolids); + attractiveTermNumber = 6; + modelName = "PR78-EoS-5-component-model"; + + for (int i = 0; i < numberOfPhases; i++) { + phaseArray[i] = new PhasePrEoS_5CompModel(); + phaseArray[i].setTemperature(T); + phaseArray[i].setPressure(P); + } + } + + /** {@inheritDoc} */ + @Override + public SystemPrEos5CompModel clone() { + SystemPrEos5CompModel clonedSystem = null; + try { + clonedSystem = (SystemPrEos5CompModel) super.clone(); + } catch (Exception ex) { + logger.error("Cloning failed.", ex); + } + + return clonedSystem; + } +} diff --git a/src/test/java/neqsim/thermo/system/SystemPrEos5CompModelTest.java b/src/test/java/neqsim/thermo/system/SystemPrEos5CompModelTest.java new file mode 100644 index 0000000000..fd2c474c37 --- /dev/null +++ b/src/test/java/neqsim/thermo/system/SystemPrEos5CompModelTest.java @@ -0,0 +1,39 @@ +package neqsim.thermo.system; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import neqsim.thermo.component.ComponentPR_5CompModel; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +public class SystemPrEos5CompModelTest { + + /** + *+ * testDensity. + *
+ */ + @Test + void testDensity() { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemPrEos5CompModel(273.15 + 177, 50.0); + testSystem.addComponent("CO2", 1.0); + testSystem.setMixingRule("classic"); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + testSystem.initProperties(); + Assertions.assertEquals(45.7388, testSystem.getComponent("CO2").getTC("C"), 0.01); + Assertions.assertEquals(1069.51, testSystem.getComponent("CO2").getPC("psia"), 0.01); + Assertions.assertEquals(0.12256, testSystem.getComponent("CO2").getAcentricFactor(), 0.01); + + Assertions.assertEquals(0.12256, testSystem.getComponent("CO2").getAcentricFactor(), 0.01); + Assertions.assertEquals(0.427705, + ((ComponentPR_5CompModel) testSystem.getComponent("CO2")).getOmegaA(), 0.01); + Assertions.assertEquals(0.0696460, + ((ComponentPR_5CompModel) testSystem.getComponent("CO2")).getOmegaB(), 0.01); + Assertions.assertEquals(44.01, testSystem.getComponent("CO2").getMolarMass("gr/mol"), 0.01); + Assertions.assertEquals(0.919497398, testSystem.getZvolcorr(), 0.001); + Assertions.assertEquals(63.94100, testSystem.getDensity("kg/m3"), 0.001); + } + + +}