From 0bc690df58a52d934695f6de3f9eb9055e271a8d Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Sun, 26 May 2024 23:13:58 +0200 Subject: [PATCH] update test (#1020) * update test * fixed bug * update --- .../simulation/ConstantVolumeDepletion.java | 47 +- .../ConstantVolumeDepletionTest.java | 42 +- .../simulation/EclipseModel.e300 | 409 ++++++++++++++++++ 3 files changed, 481 insertions(+), 17 deletions(-) create mode 100644 src/test/java/neqsim/PVTsimulation/simulation/EclipseModel.e300 diff --git a/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java b/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java index 683a9287e0..c8c7c4af42 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java @@ -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; } @@ -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); @@ -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; @@ -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); } } diff --git a/src/test/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletionTest.java b/src/test/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletionTest.java index 8ee021d442..8bf4519742 100644 --- a/src/test/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletionTest.java +++ b/src/test/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletionTest.java @@ -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); @@ -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); + + } } diff --git a/src/test/java/neqsim/PVTsimulation/simulation/EclipseModel.e300 b/src/test/java/neqsim/PVTsimulation/simulation/EclipseModel.e300 new file mode 100644 index 0000000000..404313f4a6 --- /dev/null +++ b/src/test/java/neqsim/PVTsimulation/simulation/EclipseModel.e300 @@ -0,0 +1,409 @@ +-- Dummy EOS for FluidMagic Test case +-- +-- Copyright (C) 2022 Equinor + +-- Units +METRIC +-- Number of components: +NCOMPS +22 / +-- Equation of state +EOS +PR / +PRCORR + +-- Reservoir temperature (C) +RTEMP + 90.00 / + +-- Standard Conditions (C and bara) +STCOND + 40.00000 15.00000 / + +-- Component names +CNAMES +N2 +CO2 +C1 +C2 +C3 +iC4 +C4 +iC5 +C5 +C6 +C7 +C8 +C9 +C10-C12 +C13-C14 +C15-C17 +C18-C21 +C22-C28 +C29-C36 +C37-C45 +C46-C58 +C59-C80 / +-- Tc (K) +TCRIT + 126.200 + 304.200 + 190.600 + 305.400 + 369.800 + 408.100 + 425.200 + 460.400 + 469.600 + 507.400 + 548.083 + 568.470 + 592.686 + 631.845 + 680.299 + 727.035 + 774.284 + 851.846 + 943.373 + 1038.592 + 1152.236 + 1317.304 / +-- Pc (Bar) +PCRIT + 33.9439 + 73.7646 + 46.0015 + 48.8387 + 42.4552 + 36.4770 + 37.9969 + 33.8426 + 33.7412 + 29.6882 + 29.4519 + 27.6423 + 25.5535 + 22.7296 + 20.0143 + 18.1224 + 16.7108 + 15.1759 + 14.0297 + 13.2891 + 12.7370 + 12.2645 +/ +-- Omega +ACF + 0.04000 + 0.22500 + 0.00800 + 0.09800 + 0.15200 + 0.17600 + 0.19300 + 0.22700 + 0.25100 + 0.29600 + 0.33744 + 0.37547 + 0.42325 + 0.50535 + 0.61393 + 0.72473 + 0.83712 + 1.00708 + 1.15740 + 1.21951 + 1.12382 + 0.62590 / +-- OmegaA +OMEGAA + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 / +-- OmegaB +OMEGAB + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 / +-- Molecular weights +MW + 28.0135 + 44.0098 + 16.0429 + 30.0698 + 44.0968 + 58.1237 + 58.1237 + 72.1507 + 72.1506 + 86.1776 + 96.0000 + 107.0000 + 121.0000 + 145.7094 + 181.9678 + 220.6919 + 264.4041 + 342.9118 + 447.3217 + 565.3735 + 714.4236 + 942.2227 / +-- Boiling points (K) +TBOIL + 77.400 + 194.650 + 111.600 + 184.600 + 231.100 + 261.400 + 272.700 + 301.000 + 309.200 + 341.900 + 365.100 + 389.900 + 415.400 + 459.042 + 509.712 + 555.777 + 599.945 + 669.261 + 738.465 + 799.356 + 865.446 + 950.674 / +-- Critical volumes (m3/kg-mole) +VCRIT + 0.08980 + 0.09400 + 0.09900 + 0.14800 + 0.20300 + 0.26300 + 0.25500 + 0.30600 + 0.30400 + 0.37000 + 0.47555 + 0.48784 + 0.52918 + 0.62175 + 0.75937 + 0.92679 + 1.12076 + 1.49307 + 2.00337 + 2.60288 + 3.39260 + 4.64881 / +-- Critical Z-factors +ZCRIT + 0.29049 + 0.27414 + 0.28737 + 0.28465 + 0.28029 + 0.28272 + 0.27406 + 0.27052 + 0.26270 + 0.26037 + 0.30733 + 0.28530 + 0.27440 + 0.26900 + 0.26869 + 0.27784 + 0.29091 + 0.31991 + 0.35833 + 0.40055 + 0.45103 + 0.52054 / +-- Volume translation/co-volume +SSHIFT + -0.175888 + -0.049181 + -0.194020 + -0.143142 + -0.112702 + -0.099214 + -0.089659 + -0.070455 + -0.056872 + 0.012573 + 0.074067 + 0.085121 + 0.081268 + 0.069060 + 0.048755 + 0.018239 + -0.017443 + -0.077518 + -0.156174 + -0.235730 + -0.320950 + -0.420868 / +-- Parachors (dyn/cm) +PARACHOR + 41.000 + 78.000 + 77.300 + 108.900 + 151.900 + 181.500 + 191.700 + 225.000 + 233.900 + 271.000 + 283.940 + 309.680 + 342.440 + 402.209 + 485.824 + 577.490 + 679.641 + 866.931 + 1111.372 + 1387.629 + 1739.859 + 2282.641 / +-- Overall dummy oil composition +ZI + 1.28109672e-02 + 4.07891587e-03 + 7.81998245e-01 + 8.05686771e-02 + 5.63365242e-02 + 6.57958977e-03 + 1.95042684e-02 + 5.10039805e-03 + 7.18322821e-03 + 6.77963664e-03 + 6.77524344e-03 + 5.42636362e-03 + 2.90020939e-03 + 2.43723835e-03 + 1.16773808e-03 + 2.42607452e-04 + 9.72372911e-05 + 1.20626522e-05 + 7.21492804e-07 + 6.58127085e-08 + 8.26216983e-09 + 5.38317669e-08 / +-- Binary interaction coefficients for PR +BIC + -0.0170 + 0.0311 0.1200 + 0.0515 0.1200 0.0000 + 0.0852 0.1200 0.0000 0.0000 + 0.1033 0.1200 0.0000 0.0000 0.0000 + 0.0800 0.1200 0.0000 0.0000 0.0000 0.0000 + 0.0922 0.1200 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.1000 0.1200 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1200 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 +/ +BICS + -0.0170 + 0.0311 0.1200 + 0.0515 0.1200 0.0000 + 0.0852 0.1200 0.0000 0.0000 + 0.1033 0.1200 0.0000 0.0000 0.0000 + 0.0800 0.1200 0.0000 0.0000 0.0000 0.0000 + 0.0922 0.1200 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.1000 0.1200 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1200 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 +/ +-- LBC coefficients +LBCCOEF + 0.1023000 0.0233640 0.0585330 -0.0407580 0.0093324 /