Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add 5 comp PR #1040

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 153 additions & 0 deletions src/main/java/neqsim/thermo/component/ComponentPR_5CompModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
package neqsim.thermo.component;

import neqsim.thermo.component.attractiveEosTerm.AttractiveTermPr1978;

/**
* <p>
* ComponentPR_5CompModel class.
* </p>
*
* @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;

/**
* <p>
* Constructor for ComponentPR_5CompModel.
* </p>
*
* @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));
}

/**
* <p>
* Constructor for ComponeComponentPR_5CompModelntPR.
* </p>
*
* @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;
}

}
47 changes: 47 additions & 0 deletions src/main/java/neqsim/thermo/phase/PhasePrEoS_5CompModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package neqsim.thermo.phase;

import neqsim.thermo.component.ComponentPR_5CompModel;

/**
* <p>
* PhasePrEos class.
* </p>
*
* @author Even Solbraa
* @version $Id: $Id
*/
public class PhasePrEoS_5CompModel extends PhasePrEos {
private static final long serialVersionUID = 1000;



/**
* <p>
* Constructor for PhasePrEoS_5CompModel.
* </p>
*/
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);
}
}
68 changes: 68 additions & 0 deletions src/main/java/neqsim/thermo/system/SystemPrEos5CompModel.java
Original file line number Diff line number Diff line change
@@ -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;

/**
* <p>
* Constructor for SystemPrEos5CompModel.
* </p>
*/
public SystemPrEos5CompModel() {
this(298.15, 1.0, false);
}

/**
* <p>
* Constructor for SystemPrEos_5CompModel.
* </p>
*
* @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);
}

/**
* <p>
* Constructor for mSystemPrEos5CompModel.
* </p>
*
* @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;
}
}
Original file line number Diff line number Diff line change
@@ -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 {

/**
* <p>
* testDensity.
* </p>
*/
@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);
}


}