Skip to content

Commit 4d29db5

Browse files
authored
changed code when low molecular weights of plus fraction (#1214)
1 parent 27bf800 commit 4d29db5

File tree

4 files changed

+67
-6
lines changed

4 files changed

+67
-6
lines changed

src/main/java/neqsim/thermo/characterization/Characterise.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,10 @@ public void characterisePlusFraction() {
159159
plusFractionModel = plusFractionModelSelector.getModel("Pedersen Heavy Oil");
160160
logger.info("changing to " + plusFractionModel.getName());
161161
}
162-
plusFractionModel.characterizePlusFraction(TBPfractionModel);
163-
lumpingModel.generateLumpedComposition(this);
162+
boolean couldCharacerize = plusFractionModel.characterizePlusFraction(TBPfractionModel);
163+
if (couldCharacerize) {
164+
lumpingModel.generateLumpedComposition(this);
165+
}
164166
}
165167
}
166168

src/main/java/neqsim/thermo/characterization/PlusFractionModel.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package neqsim.thermo.characterization;
22

3+
import org.apache.logging.log4j.LogManager;
4+
import org.apache.logging.log4j.Logger;
35
import neqsim.thermo.system.SystemInterface;
46

57
/**
@@ -11,6 +13,7 @@
1113
* @version $Id: $Id
1214
*/
1315
public class PlusFractionModel implements java.io.Serializable {
16+
static Logger logger = LogManager.getLogger(PlusFractionModel.class);
1417
private static final long serialVersionUID = 1000;
1518
private String name = "";
1619
private SystemInterface system = null;
@@ -193,7 +196,7 @@ public boolean hasPlusFraction() {
193196
}
194197

195198
@Override
196-
public void characterizePlusFraction(TBPModelInterface TBPModel) {
199+
public boolean characterizePlusFraction(TBPModelInterface TBPModel) {
197200
system.init(0);
198201
Integer firstPlusNumber = Integer.valueOf(0);
199202
if (system.getPhase(0).getComponent(plusComponentNumber).getComponentName().substring(3, 4)
@@ -210,6 +213,10 @@ public void characterizePlusFraction(TBPModelInterface TBPModel) {
210213

211214
numberOfPlusPseudocomponents = lastPlusFractionNumber - firstPlusFractionNumber + 1;
212215

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

234242
@Override
@@ -381,7 +389,7 @@ public void densityUOP() {
381389
}
382390

383391
@Override
384-
public void characterizePlusFraction(TBPModelInterface TBPModel) {
392+
public boolean characterizePlusFraction(TBPModelInterface TBPModel) {
385393
system.init(0);
386394
double MWBU = Double.NaN;
387395
double MWBL = Double.NaN;
@@ -427,6 +435,7 @@ public void characterizePlusFraction(TBPModelInterface TBPModel) {
427435
for (int i = firstPlusFractionNumber; i < lastPlusFractionNumber; i++) {
428436
zValues[i] *= zPlus / sumZ;
429437
}
438+
return true;
430439
}
431440

432441
public void setGammaParameters(double shape, double minMW) {

src/main/java/neqsim/thermo/characterization/PlusFractionModelInterface.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public interface PlusFractionModelInterface extends java.io.Serializable {
2525
*
2626
* @param model a {@link neqsim.thermo.characterization.TBPModelInterface} object
2727
*/
28-
public void characterizePlusFraction(TBPModelInterface model);
28+
public boolean characterizePlusFraction(TBPModelInterface model);
2929

3030
/**
3131
* <p>
@@ -73,7 +73,9 @@ public interface PlusFractionModelInterface extends java.io.Serializable {
7373
public int getLastPlusFractionNumber();
7474

7575
/**
76-
* <p>setLastPlusFractionNumber.</p>
76+
* <p>
77+
* setLastPlusFractionNumber.
78+
* </p>
7779
*
7880
* @param fract a int
7981
*/

src/test/java/neqsim/thermo/characterization/PlusFractionModelTest.java

+48
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,52 @@ void testGammaModelCharacterization() {
144144
.getGammaParameters()[1];
145145
assertEquals(90.0, minMW, 1e-4);
146146
}
147+
148+
@Test
149+
void testC6C7PlusModel() {
150+
SystemInterface thermoSystem = null;
151+
thermoSystem = new SystemSrkEos(298.0, 10.0);
152+
153+
thermoSystem.addComponent("CO2", 1.0);
154+
thermoSystem.addComponent("methane", 51.0);
155+
thermoSystem.addComponent("ethane", 1.0);
156+
thermoSystem.addComponent("propane", 1.0);
157+
158+
thermoSystem.getCharacterization().setTBPModel("PedersenSRK"); // this need to be set before
159+
// adding oil components
160+
161+
String[] componentNames = {"C7"};
162+
double[] molarComposition = {0.15};
163+
double[] molarMasses = {0.092};
164+
double[] reldens = {0.82};
165+
166+
thermoSystem.getCharacterization().setTBPModel("PedersenSRK"); // this need to be set before
167+
168+
thermoSystem.addOilFractions(componentNames, molarComposition, molarMasses, reldens, true);
169+
170+
// In this case the molar mass of the plus fraction is set to 0.092 kg/mol an is too low to
171+
// distribute the component into heavier components
172+
assertEquals(5, thermoSystem.getNumberOfComponents());
173+
174+
thermoSystem = new SystemSrkEos(298.0, 10.0);
175+
176+
thermoSystem.addComponent("CO2", 1.0);
177+
thermoSystem.addComponent("methane", 51.0);
178+
thermoSystem.addComponent("ethane", 1.0);
179+
thermoSystem.addComponent("propane", 1.0);
180+
181+
thermoSystem.getCharacterization().setTBPModel("PedersenSRK"); // this need to be set before
182+
// adding oil components
183+
184+
molarMasses = new double[] {0.120};
185+
186+
thermoSystem.getCharacterization().setTBPModel("PedersenSRK"); // this need to be set before
187+
188+
thermoSystem.addOilFractions(componentNames, molarComposition, molarMasses, reldens, true);
189+
// In this case the molar mass of the plus fraction is high enogh and can be characterized into
190+
// heavier components
191+
192+
assertEquals(16, thermoSystem.getNumberOfComponents());
193+
194+
}
147195
}

0 commit comments

Comments
 (0)