Skip to content

Commit

Permalink
update test (#1020)
Browse files Browse the repository at this point in the history
* update test

* fixed bug

* update
  • Loading branch information
EvenSol authored May 26, 2024
1 parent 548d057 commit 0bc690d
Show file tree
Hide file tree
Showing 3 changed files with 481 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ public void calcSaturationConditions() {
* try { thermoOps.dewPointPressureFlash(); } catch (Exception ex) {
* logger.error(ex.getMessage(), ex); }
*/
saturationVolume = getThermoSystem().getVolume();
getThermoSystem().initPhysicalProperties("density");
saturationVolume = getThermoSystem().getCorrectedVolume();
saturationPressure = getThermoSystem().getPressure();
Zsaturation = getThermoSystem().getZ();
Zsaturation = getThermoSystem().getZvolcorr();
saturationConditionFound = true;
}

Expand All @@ -108,6 +109,8 @@ public void runCalc() {
Zgas = new double[pressures.length];
Zmix = new double[pressures.length];
liquidRelativeVolume = new double[pressures.length];
double oldVolCorr = 0.0;
double volumeCorrection = 0.0;
cummulativeMolePercDepleted = new double[pressures.length];
double totalNumberOfMoles = getThermoSystem().getTotalNumberOfMoles();
getThermoSystem().setTemperature(temperature, temperatureUnit);
Expand All @@ -119,8 +122,9 @@ public void runCalc() {
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
}
getThermoSystem().initPhysicalProperties("density");
// getThermoSystem().display();
totalVolume[i] = getThermoSystem().getVolume();
totalVolume[i] = getThermoSystem().getCorrectedVolume();
// System.out.println("volume " + totalVolume[i]);
cummulativeMolePercDepleted[i] =
100.0 - getThermoSystem().getTotalNumberOfMoles() / totalNumberOfMoles * 100;
Expand All @@ -130,36 +134,47 @@ public void runCalc() {
getThermoSystem().setPressure(pressures[i]);
try {
thermoOps.TPflash();
getThermoSystem().initPhysicalProperties("density");
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
}
}

// if (totalVolume[i] > saturationVolume) {
liquidVolume[i] = getThermoSystem().getPhase(1).getVolume();
liquidVolume[i] = getThermoSystem().getPhase(1).getCorrectedVolume();
liquidVolumeRelativeToVsat[i] = liquidVolume[i] / saturationVolume;
Zgas[i] = getThermoSystem().getPhase(0).getZ();
Zmix[i] = getThermoSystem().getZ();
if (getThermoSystem().getNumberOfPhases() > 1) {
liquidRelativeVolume[i] =
getThermoSystem().getPhase("oil").getVolume() / saturationVolume * 100;
}

double volumeCorrection = getThermoSystem().getVolume() - saturationVolume;
double test = volumeCorrection / getThermoSystem().getPhase(0).getMolarVolume();
Zgas[i] = getThermoSystem().getPhase(0).getZvolcorr();
Zmix[i] = getThermoSystem().getZvolcorr();
liquidRelativeVolume[i] =
getThermoSystem().getPhase("oil").getCorrectedVolume() / saturationVolume * 100;
oldVolCorr = volumeCorrection;
volumeCorrection = getThermoSystem().getCorrectedVolume() - saturationVolume;
double test =
(volumeCorrection - oldVolCorr) / getThermoSystem().getPhase(0).getCorrectedVolume();
double[] change = new double[getThermoSystem().getPhase(0).getNumberOfComponents()];
// System.out.println(test);

for (int j = 0; j < getThermoSystem().getPhase(0).getNumberOfComponents(); j++) {
try {
double change =
change[j] =
(test * getThermoSystem().getPhase(0).getComponent(j).getx() < getThermoSystem()
.getPhase(0).getComponent(j).getNumberOfMolesInPhase())
? test * getThermoSystem().getPhase(0).getComponent(j).getx()
: test * getThermoSystem().getPhase(0).getComponent(j).getx();
getThermoSystem().addComponent(j, -change);
: 0.0;

} catch (Exception e) {
logger.debug(e.getMessage());
}
}
for (int j = 0; j < getThermoSystem().getPhase(0).getNumberOfComponents(); j++) {
try {
getThermoSystem().addComponent(j, -change[j]);
} catch (Exception e) {
logger.debug(e.getMessage());
}
}
// getThermoSystem().init(0);
// getThermoSystem().init(1);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package neqsim.PVTsimulation.simulation;

import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
import org.junit.jupiter.api.Test;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;
import neqsim.thermodynamicOperations.ThermodynamicOperations;

public class ConstantVolumeDepletionTest {

@Test
void testRunCalc() {
SystemInterface tempSystem = new SystemSrkEos(298.0, 211.0);
Expand Down Expand Up @@ -38,6 +41,43 @@ void testRunCalc() {
new double[] {400, 300.0, 200.0, 100.0});
double[][] expData = {{0.95, 0.99, 1.0, 1.1}};
CVDsim.setExperimentalData(expData);
assertEquals(1.419637379033296, CVDsim.getRelativeVolume()[4], 0.001);
assertEquals(2.2458466, CVDsim.getRelativeVolume()[4], 0.001);
}

@Test
void testRunEclipseInput() {

File file = new File("src/test/java/neqsim/PVTsimulation/simulation");
String fileFluid1 = file.getAbsolutePath() + "/EclipseModel.e300";
SystemInterface fluid1 = neqsim.thermo.util.readwrite.EclipseFluidReadWrite.read(fileFluid1);
// TODO: check why not working with multiphase
fluid1.setMultiPhaseCheck(true);
fluid1.setTemperature(90.0, "C");

SaturationPressure satPres = new SaturationPressure(fluid1);
satPres.run();
assertEquals(199.4580707, fluid1.getPressure("bara"), 0.01);

ConstantVolumeDepletion CVDsim = new ConstantVolumeDepletion(fluid1);
CVDsim.setTemperature(90.0, "C");
CVDsim.setPressures(new double[] {220., 185.94064077, 151.88128153, 117.8219223});
CVDsim.runCalc();
CVDsim.getThermoSystem().initPhysicalProperties("density");
double gasdens = CVDsim.getThermoSystem().getPhase("gas").getDensity("kg/m3");
double oildens = CVDsim.getThermoSystem().getPhase("oil").getDensity("kg/m3");

SystemInterface gasFluid = CVDsim.getThermoSystem().phaseToSystem("gas");
gasFluid.initPhysicalProperties("density");
// gasFluid.prettyPrint();
assertEquals(gasdens, gasFluid.getDensity("kg/m3"), 0.01);

SystemInterface oilFluid = CVDsim.getThermoSystem().phaseToSystem("oil");
ThermodynamicOperations ops = new ThermodynamicOperations(oilFluid);
ops.TPflash();
oilFluid.initPhysicalProperties("density");

assertEquals(oildens, oilFluid.getDensity("kg/m3"), 0.1);


}
}
Loading

0 comments on commit 0bc690d

Please sign in to comment.