Skip to content

Commit

Permalink
changed code when low molecular weights of plus fraction (#1214)
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol authored Dec 17, 2024
1 parent 27bf800 commit 4d29db5
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,10 @@ public void characterisePlusFraction() {
plusFractionModel = plusFractionModelSelector.getModel("Pedersen Heavy Oil");
logger.info("changing to " + plusFractionModel.getName());
}
plusFractionModel.characterizePlusFraction(TBPfractionModel);
lumpingModel.generateLumpedComposition(this);
boolean couldCharacerize = plusFractionModel.characterizePlusFraction(TBPfractionModel);
if (couldCharacerize) {
lumpingModel.generateLumpedComposition(this);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package neqsim.thermo.characterization;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import neqsim.thermo.system.SystemInterface;

/**
Expand All @@ -11,6 +13,7 @@
* @version $Id: $Id
*/
public class PlusFractionModel implements java.io.Serializable {
static Logger logger = LogManager.getLogger(PlusFractionModel.class);
private static final long serialVersionUID = 1000;
private String name = "";
private SystemInterface system = null;
Expand Down Expand Up @@ -193,7 +196,7 @@ public boolean hasPlusFraction() {
}

@Override
public void characterizePlusFraction(TBPModelInterface TBPModel) {
public boolean characterizePlusFraction(TBPModelInterface TBPModel) {
system.init(0);
Integer firstPlusNumber = Integer.valueOf(0);
if (system.getPhase(0).getComponent(plusComponentNumber).getComponentName().substring(3, 4)
Expand All @@ -210,6 +213,10 @@ public void characterizePlusFraction(TBPModelInterface TBPModel) {

numberOfPlusPseudocomponents = lastPlusFractionNumber - firstPlusFractionNumber + 1;

if (PVTsimMolarMass[firstPlusFractionNumber - 6] > MPlus * 1000) {
logger.error("Plus fraction molar mass too light ");
return false;
}
// System.out.println("first plus fraction number " + firstPlusFractionNumber);
coefs[0] = 0.1;
coefs[1] = Math.log(zPlus) / getFirstPlusFractionNumber();
Expand All @@ -229,6 +236,7 @@ public void characterizePlusFraction(TBPModelInterface TBPModel) {
dens[i] = getCoef(2) + getCoef(3) * Math.log(i);
}
// System.out.println("z,m,dens " + z[i] + " " + M[i] + " " + dens[i]);
return true;
}

@Override
Expand Down Expand Up @@ -381,7 +389,7 @@ public void densityUOP() {
}

@Override
public void characterizePlusFraction(TBPModelInterface TBPModel) {
public boolean characterizePlusFraction(TBPModelInterface TBPModel) {
system.init(0);
double MWBU = Double.NaN;
double MWBL = Double.NaN;
Expand Down Expand Up @@ -427,6 +435,7 @@ public void characterizePlusFraction(TBPModelInterface TBPModel) {
for (int i = firstPlusFractionNumber; i < lastPlusFractionNumber; i++) {
zValues[i] *= zPlus / sumZ;
}
return true;
}

public void setGammaParameters(double shape, double minMW) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public interface PlusFractionModelInterface extends java.io.Serializable {
*
* @param model a {@link neqsim.thermo.characterization.TBPModelInterface} object
*/
public void characterizePlusFraction(TBPModelInterface model);
public boolean characterizePlusFraction(TBPModelInterface model);

/**
* <p>
Expand Down Expand Up @@ -73,7 +73,9 @@ public interface PlusFractionModelInterface extends java.io.Serializable {
public int getLastPlusFractionNumber();

/**
* <p>setLastPlusFractionNumber.</p>
* <p>
* setLastPlusFractionNumber.
* </p>
*
* @param fract a int
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,52 @@ void testGammaModelCharacterization() {
.getGammaParameters()[1];
assertEquals(90.0, minMW, 1e-4);
}

@Test
void testC6C7PlusModel() {
SystemInterface thermoSystem = null;
thermoSystem = new SystemSrkEos(298.0, 10.0);

thermoSystem.addComponent("CO2", 1.0);
thermoSystem.addComponent("methane", 51.0);
thermoSystem.addComponent("ethane", 1.0);
thermoSystem.addComponent("propane", 1.0);

thermoSystem.getCharacterization().setTBPModel("PedersenSRK"); // this need to be set before
// adding oil components

String[] componentNames = {"C7"};
double[] molarComposition = {0.15};
double[] molarMasses = {0.092};
double[] reldens = {0.82};

thermoSystem.getCharacterization().setTBPModel("PedersenSRK"); // this need to be set before

thermoSystem.addOilFractions(componentNames, molarComposition, molarMasses, reldens, true);

// In this case the molar mass of the plus fraction is set to 0.092 kg/mol an is too low to
// distribute the component into heavier components
assertEquals(5, thermoSystem.getNumberOfComponents());

thermoSystem = new SystemSrkEos(298.0, 10.0);

thermoSystem.addComponent("CO2", 1.0);
thermoSystem.addComponent("methane", 51.0);
thermoSystem.addComponent("ethane", 1.0);
thermoSystem.addComponent("propane", 1.0);

thermoSystem.getCharacterization().setTBPModel("PedersenSRK"); // this need to be set before
// adding oil components

molarMasses = new double[] {0.120};

thermoSystem.getCharacterization().setTBPModel("PedersenSRK"); // this need to be set before

thermoSystem.addOilFractions(componentNames, molarComposition, molarMasses, reldens, true);
// In this case the molar mass of the plus fraction is high enogh and can be characterized into
// heavier components

assertEquals(16, thermoSystem.getNumberOfComponents());

}
}

0 comments on commit 4d29db5

Please sign in to comment.