2023-10-26 12:29:06 +02:00
|
|
|
import os
|
|
|
|
|
import unittest
|
|
|
|
|
from pathlib import Path
|
2025-09-23 13:20:10 +02:00
|
|
|
from .pytest_common import pushd, create_black_oil_simulator, create_gas_water_simulator, create_onephase_simulator
|
2023-10-26 12:29:06 +02:00
|
|
|
|
|
|
|
|
class TestBasic(unittest.TestCase):
|
|
|
|
|
@classmethod
|
|
|
|
|
def setUpClass(cls):
|
|
|
|
|
test_dir = Path(os.path.dirname(__file__))
|
2025-08-27 11:10:02 +02:00
|
|
|
cls.data_dir_bo = test_dir.parent.joinpath("test_data/SPE1CASE1a")
|
2025-09-18 11:21:03 +02:00
|
|
|
cls.data_dir_op = test_dir.parent.joinpath("test_data/SPE1CASE1")
|
2025-08-27 11:10:02 +02:00
|
|
|
cls.data_dir_gw = test_dir.parent.joinpath("test_data/SPE1CASE2")
|
2023-10-26 12:29:06 +02:00
|
|
|
|
2025-08-27 11:53:53 +02:00
|
|
|
# IMPORTANT: Since all the python unittests run in the same process we must be
|
|
|
|
|
# careful to not call MPI_Init() more than once.
|
|
|
|
|
# Tests are run alphabetically, so we need to make sure that
|
|
|
|
|
# the the first test calls MPI_Init(), therefore the name of the tests
|
|
|
|
|
# have a numeric label like "01" in test_01_bo to ensure that they
|
|
|
|
|
# are run in a given order.
|
2023-10-26 12:29:06 +02:00
|
|
|
|
2025-08-27 11:53:53 +02:00
|
|
|
# IMPORTANT:This test must be run first since it calls MPI_Init()
|
|
|
|
|
def test_01_blackoil(self):
|
2025-08-27 11:10:02 +02:00
|
|
|
with pushd(self.data_dir_bo):
|
2025-09-23 05:09:20 +02:00
|
|
|
sim = create_black_oil_simulator(filename="SPE1CASE1.DATA")
|
2025-08-27 11:10:02 +02:00
|
|
|
sim.setup_mpi(True, False)
|
2023-10-26 12:29:06 +02:00
|
|
|
sim.step_init()
|
|
|
|
|
sim.step()
|
|
|
|
|
oil_pressure = sim.get_fluidstate_variable(name='po')
|
2024-08-16 09:37:11 +02:00
|
|
|
self.assertAlmostEqual(oil_pressure[0], 35795160.67, delta=1e4, msg='value of oil pressure')
|
2023-10-26 12:29:06 +02:00
|
|
|
gas_pressure = sim.get_fluidstate_variable(name='pg')
|
2024-08-16 09:37:11 +02:00
|
|
|
self.assertAlmostEqual(gas_pressure[0], 35795160.67, delta=1e4, msg='value of gas pressure')
|
2023-10-26 12:29:06 +02:00
|
|
|
water_pressure = sim.get_fluidstate_variable(name='pw')
|
2024-08-16 09:37:11 +02:00
|
|
|
self.assertAlmostEqual(water_pressure[0], 35795160.67, delta=1e4, msg='value of water pressure')
|
2023-10-26 12:29:06 +02:00
|
|
|
rho_w = sim.get_fluidstate_variable(name='rho_w')
|
2024-08-16 09:37:11 +02:00
|
|
|
self.assertAlmostEqual(rho_w[0], 998.9822355, places=3, msg='value of water density')
|
2023-10-26 12:29:06 +02:00
|
|
|
rho_g = sim.get_fluidstate_variable(name='rho_g')
|
2024-08-16 09:37:11 +02:00
|
|
|
self.assertAlmostEqual(rho_g[0], 241.36955087, places=2, msg='value of gas density')
|
2023-10-26 12:29:06 +02:00
|
|
|
rho_o = sim.get_fluidstate_variable(name='rho_o')
|
2024-08-28 13:27:46 +02:00
|
|
|
self.assertAlmostEqual(rho_o[0], 631.78674, places=2, msg='value of oil density')
|
2023-10-26 12:29:06 +02:00
|
|
|
Rs = sim.get_fluidstate_variable(name='Rs')
|
2024-08-16 09:37:11 +02:00
|
|
|
self.assertAlmostEqual(Rs[0], 226.19666048, places=5, msg='value of solution gas-oil ratio')
|
2023-10-26 12:29:06 +02:00
|
|
|
Rv = sim.get_fluidstate_variable(name='Rv')
|
2024-08-16 09:37:11 +02:00
|
|
|
self.assertAlmostEqual(Rv[0], 0.0, places=5, msg='value of volatile gas-oil ratio')
|
2023-10-26 12:29:06 +02:00
|
|
|
Sw = sim.get_fluidstate_variable(name='Sw')
|
2024-08-16 09:37:11 +02:00
|
|
|
self.assertAlmostEqual(Sw[0], 0.11969486712, places=5, msg='value of water saturation')
|
2023-10-26 12:29:06 +02:00
|
|
|
So = sim.get_fluidstate_variable(name='So')
|
2024-08-29 11:19:29 +02:00
|
|
|
self.assertAlmostEqual(So[0], 0.825129, places=3, msg='value of oil saturation')
|
2023-10-26 12:29:06 +02:00
|
|
|
Sg = sim.get_fluidstate_variable(name='Sg')
|
2024-08-29 11:19:29 +02:00
|
|
|
self.assertAlmostEqual(Sg[0], 0.055138968544, places=3, msg='value of gas saturation')
|
2023-10-26 12:29:06 +02:00
|
|
|
T = sim.get_fluidstate_variable(name='T')
|
|
|
|
|
self.assertAlmostEqual(T[0], 288.705, places=3, msg='value of temperature')
|
2025-08-27 11:10:02 +02:00
|
|
|
|
2025-09-18 11:21:03 +02:00
|
|
|
def test_02_onephase(self):
|
|
|
|
|
with pushd(self.data_dir_op):
|
2025-09-23 13:20:10 +02:00
|
|
|
sim = create_onephase_simulator("SPE1CASE1_WATER.DATA")
|
2025-09-18 11:21:03 +02:00
|
|
|
sim.setup_mpi(False, False)
|
|
|
|
|
sim.step_init()
|
|
|
|
|
sim.step()
|
|
|
|
|
water_pressure = sim.get_fluidstate_variable(name='pw')
|
|
|
|
|
self.assertAlmostEqual(water_pressure[0], 44780102.277570, delta=1e4, msg='value of water pressure')
|
|
|
|
|
rho_w = sim.get_fluidstate_variable(name='rho_w')
|
|
|
|
|
self.assertAlmostEqual(rho_w[0], 1003.182858, places=3, msg='value of water density')
|
|
|
|
|
Sw = sim.get_fluidstate_variable(name='Sw')
|
|
|
|
|
self.assertAlmostEqual(Sw[0], 1.0, places=5, msg='value of water saturation')
|
|
|
|
|
|
2025-08-27 11:53:53 +02:00
|
|
|
# IMPORTANT: This test must be run last since it calls MPI_Finalize()
|
|
|
|
|
def test_99_gaswater(self):
|
2025-08-27 11:10:02 +02:00
|
|
|
with pushd(self.data_dir_gw):
|
2025-09-23 05:09:20 +02:00
|
|
|
sim = create_gas_water_simulator(filename="SPE1CASE2_GASWATER.DATA")
|
2025-08-27 11:10:02 +02:00
|
|
|
sim.setup_mpi(False, True)
|
|
|
|
|
sim.step_init()
|
|
|
|
|
sim.step()
|
|
|
|
|
gas_pressure = sim.get_fluidstate_variable(name='pg')
|
|
|
|
|
self.assertAlmostEqual(gas_pressure[0], 32410549.874824, delta=1e4, msg='value of gas pressure')
|
|
|
|
|
water_pressure = sim.get_fluidstate_variable(name='pw')
|
|
|
|
|
self.assertAlmostEqual(water_pressure[0], 32410549.874824, delta=1e4, msg='value of water pressure')
|
|
|
|
|
rho_g = sim.get_fluidstate_variable(name='rho_g')
|
2025-09-19 14:18:22 +02:00
|
|
|
self.assertAlmostEqual(rho_g[0], 219.613424, delta=1e-2, msg='value of gas density')
|
2025-08-27 11:10:02 +02:00
|
|
|
rho_w = sim.get_fluidstate_variable(name='rho_w')
|
2025-09-19 14:18:22 +02:00
|
|
|
self.assertAlmostEqual(rho_w[0], 1047.849235, delta=1e-3, msg='value of water density')
|
2025-08-27 11:10:02 +02:00
|
|
|
Sg = sim.get_fluidstate_variable(name='Sg')
|
2025-09-19 14:18:22 +02:00
|
|
|
self.assertAlmostEqual(Sg[0], 0.708648, delta=1e-2, msg='value of gas saturation')
|
2025-08-27 11:10:02 +02:00
|
|
|
Sw = sim.get_fluidstate_variable(name='Sw')
|
2025-09-19 14:18:22 +02:00
|
|
|
self.assertAlmostEqual(Sw[0], 0.291351, delta=1e-2, msg='value of water saturation')
|