Skip to content

Commit 2b8e5b4

Browse files
committed
Tests for OnePhaseSimulator
1 parent 686bc91 commit 2b8e5b4

File tree

4 files changed

+266
-3
lines changed

4 files changed

+266
-3
lines changed

python/test/test_basic.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import os
22
import unittest
33
from pathlib import Path
4-
from opm.simulators import BlackOilSimulator, GasWaterSimulator
4+
from opm.simulators import BlackOilSimulator, GasWaterSimulator, OnePhaseSimulator
55
from .pytest_common import pushd
66

77
class TestBasic(unittest.TestCase):
88
@classmethod
99
def setUpClass(cls):
1010
test_dir = Path(os.path.dirname(__file__))
1111
cls.data_dir_bo = test_dir.parent.joinpath("test_data/SPE1CASE1a")
12+
cls.data_dir_op = test_dir.parent.joinpath("test_data/SPE1CASE1")
1213
cls.data_dir_gw = test_dir.parent.joinpath("test_data/SPE1CASE2")
1314

1415
# IMPORTANT: Since all the python unittests run in the same process we must be
@@ -44,6 +45,26 @@ def test_01_blackoil(self):
4445
sim.step()
4546
poro2 = sim.get_porosity()
4647
self.assertAlmostEqual(poro2[0], 0.285, places=7, msg='value of porosity 2')
48+
49+
def test_02_onephase(self):
50+
with pushd(self.data_dir_op):
51+
sim = OnePhaseSimulator(args=['--linear-solver=ilu0'], filename="SPE1CASE1_WATER.DATA")
52+
sim.setup_mpi(init=False, finalize=False)
53+
sim.step_init()
54+
sim.step()
55+
dt = sim.get_dt() # 31 days = 31 * 24 * 60 * 60 = 2678400 seconds
56+
self.assertAlmostEqual(dt, 2678400., places=7, msg='value of timestep')
57+
vol = sim.get_cell_volumes()
58+
self.assertEqual(len(vol), 300, 'length of volume vector')
59+
self.assertAlmostEqual(vol[0], 566336.93, places=2, msg='value of volume')
60+
poro = sim.get_porosity()
61+
self.assertEqual(len(poro), 300, 'length of porosity vector')
62+
self.assertAlmostEqual(poro[0], 0.3, places=7, msg='value of porosity')
63+
poro = poro *.95
64+
sim.set_porosity(poro)
65+
sim.step()
66+
poro2 = sim.get_porosity()
67+
self.assertAlmostEqual(poro2[0], 0.285, places=7, msg='value of porosity 2')
4768

4869
# IMPORTANT: This test must be run last since it calls MPI_Finalize()
4970
def test_99_gaswater(self):

python/test/test_fluidstate_variables.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import os
22
import unittest
33
from pathlib import Path
4-
from opm.simulators import BlackOilSimulator, GasWaterSimulator
4+
from opm.simulators import BlackOilSimulator, GasWaterSimulator, OnePhaseSimulator
55
from .pytest_common import pushd
66

77
class TestBasic(unittest.TestCase):
88
@classmethod
99
def setUpClass(cls):
1010
test_dir = Path(os.path.dirname(__file__))
1111
cls.data_dir_bo = test_dir.parent.joinpath("test_data/SPE1CASE1a")
12+
cls.data_dir_op = test_dir.parent.joinpath("test_data/SPE1CASE1")
1213
cls.data_dir_gw = test_dir.parent.joinpath("test_data/SPE1CASE2")
1314

1415
# IMPORTANT: Since all the python unittests run in the same process we must be
@@ -50,6 +51,19 @@ def test_01_blackoil(self):
5051
T = sim.get_fluidstate_variable(name='T')
5152
self.assertAlmostEqual(T[0], 288.705, places=3, msg='value of temperature')
5253

54+
def test_02_onephase(self):
55+
with pushd(self.data_dir_op):
56+
sim = OnePhaseSimulator("SPE1CASE1_WATER.DATA")
57+
sim.setup_mpi(False, False)
58+
sim.step_init()
59+
sim.step()
60+
water_pressure = sim.get_fluidstate_variable(name='pw')
61+
self.assertAlmostEqual(water_pressure[0], 44780102.277570, delta=1e4, msg='value of water pressure')
62+
rho_w = sim.get_fluidstate_variable(name='rho_w')
63+
self.assertAlmostEqual(rho_w[0], 1003.182858, places=3, msg='value of water density')
64+
Sw = sim.get_fluidstate_variable(name='Sw')
65+
self.assertAlmostEqual(Sw[0], 1.0, places=5, msg='value of water saturation')
66+
5367
# IMPORTANT: This test must be run last since it calls MPI_Finalize()
5468
def test_99_gaswater(self):
5569
with pushd(self.data_dir_gw):

python/test/test_primary_variables.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import unittest
33
from pathlib import Path
4-
from opm.simulators import BlackOilSimulator, GasWaterSimulator
4+
from opm.simulators import BlackOilSimulator, GasWaterSimulator, OnePhaseSimulator
55
from .pytest_common import pushd
66

77
class TestBasic(unittest.TestCase):
@@ -12,6 +12,7 @@ def setUpClass(cls):
1212
# it up in multiple test functions
1313
test_dir = Path(os.path.dirname(__file__))
1414
cls.data_dir_bo = test_dir.parent.joinpath("test_data/SPE1CASE1a")
15+
cls.data_dir_op = test_dir.parent.joinpath("test_data/SPE1CASE1")
1516
cls.data_dir_gw = test_dir.parent.joinpath("test_data/SPE1CASE2")
1617

1718
# IMPORTANT: Since all the python unittests run in the same process we must be
@@ -51,6 +52,30 @@ def test_01_blackoil(self):
5152
variable='brine')
5253
self.assertEqual(brine_meaning[0], brine_meaning_map["Disabled"])
5354

55+
def test_02_onephase(self):
56+
with pushd(self.data_dir_op):
57+
sim = OnePhaseSimulator("SPE1CASE1_WATER.DATA")
58+
sim.setup_mpi(False, False)
59+
sim.step_init()
60+
sim.step()
61+
pressure = sim.get_primary_variable(variable='pressure')
62+
self.assertAlmostEqual(pressure[0], 44780102.277570, delta=1e4, msg='value of pressure')
63+
pressure_meaning = sim.get_primary_variable_meaning(
64+
variable='pressure')
65+
pressure_meaning_map = sim.get_primary_variable_meaning_map(
66+
variable='pressure')
67+
self.assertEqual(pressure_meaning[0], pressure_meaning_map["Pw"])
68+
water_meaning = sim.get_primary_variable_meaning(
69+
variable='water')
70+
water_meaning_map = sim.get_primary_variable_meaning_map(
71+
variable='water')
72+
self.assertEqual(water_meaning[0], water_meaning_map["Disabled"])
73+
brine_meaning = sim.get_primary_variable_meaning(
74+
variable='brine')
75+
brine_meaning_map = sim.get_primary_variable_meaning_map(
76+
variable='brine')
77+
self.assertEqual(brine_meaning[0], brine_meaning_map["Disabled"])
78+
5479
# IMPORTANT: This test must be run last since it calls MPI_Finalize()
5580
def test_99_gaswater(self):
5681
with pushd(self.data_dir_gw):
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
-- This reservoir simulation deck is made available under the Open Database
2+
-- License: http://opendatacommons.org/licenses/odbl/1.0/. Any rights in
3+
-- individual contents of the database are licensed under the Database Contents
4+
-- License: http://opendatacommons.org/licenses/dbcl/1.0/
5+
6+
-- Copyright (C) 2019 SINTEF
7+
-- Copyright (C) 2020 Equinor
8+
9+
-- This simulation deck is for flow_onephase
10+
-- to simulate water injection/production
11+
-- in a water single-phase system
12+
13+
---------------------------------------------------------------------------
14+
------------------------ SPE1 - CASE 1 ------------------------------------
15+
---------------------------------------------------------------------------
16+
17+
RUNSPEC
18+
-- -------------------------------------------------------------------------
19+
20+
TITLE
21+
SPE1 - CASE 1
22+
23+
DIMENS
24+
10 10 3 /
25+
26+
-- The number of equilibration regions is inferred from the EQLDIMS
27+
-- keyword.
28+
EQLDIMS
29+
/
30+
31+
-- The number of PVTW tables is inferred from the TABDIMS keyword;
32+
-- when no data is included in the keyword the default values are used.
33+
TABDIMS
34+
/
35+
36+
WATER
37+
38+
39+
FIELD
40+
41+
START
42+
1 'JAN' 2015 /
43+
44+
WELLDIMS
45+
-- Item 1: maximum number of wells in the model
46+
-- - there are two wells in the problem; injector and producer
47+
-- Item 2: maximum number of grid blocks connected to any one well
48+
-- - must be one as the wells are located at specific grid blocks
49+
-- Item 3: maximum number of groups in the model
50+
-- - we are dealing with only one 'group'
51+
-- Item 4: maximum number of wells in any one group
52+
-- - there must be two wells in a group as there are two wells in total
53+
2 1 1 2 /
54+
55+
UNIFIN
56+
UNIFOUT
57+
58+
GRID
59+
60+
-- The INIT keyword is used to request an .INIT file. The .INIT file
61+
-- is written before the simulation actually starts, and contains grid
62+
-- properties and saturation tables as inferred from the input
63+
-- deck. There are no other keywords which can be used to configure
64+
-- exactly what is written to the .INIT file.
65+
INIT
66+
67+
68+
-- -------------------------------------------------------------------------
69+
NOECHO
70+
71+
DX
72+
-- There are in total 300 cells with length 1000ft in x-direction
73+
300*1000 /
74+
DY
75+
-- There are in total 300 cells with length 1000ft in y-direction
76+
300*1000 /
77+
DZ
78+
-- The layers are 20, 30 and 50 ft thick, in each layer there are 100 cells
79+
100*20 100*30 100*50 /
80+
81+
TOPS
82+
-- The depth of the top of each grid block
83+
100*8325 /
84+
85+
PORO
86+
-- Constant porosity of 0.3 throughout all 300 grid cells
87+
300*0.3 /
88+
89+
PERMX
90+
-- The layers have perm. 500mD, 50mD and 200mD, respectively.
91+
100*500 100*50 100*200 /
92+
93+
PERMY
94+
-- Equal to PERMX
95+
100*500 100*50 100*200 /
96+
97+
PERMZ
98+
100*500 100*50 100*200 /
99+
ECHO
100+
101+
PROPS
102+
-- -------------------------------------------------------------------------
103+
104+
PVTW
105+
-- Item 1: pressure reference (psia)
106+
-- Item 2: water FVF (rb per bbl or rb per stb)
107+
-- Item 3: water compressibility (psi^{-1})
108+
-- Item 4: water viscosity (cp)
109+
-- Item 5: water 'viscosibility' (psi^{-1})
110+
111+
-- Using values from Norne:
112+
-- In METRIC units:
113+
-- 277.0 1.038 4.67E-5 0.318 0.0 /
114+
-- In FIELD units:
115+
4017.55 1.038 3.22E-6 0.318 0.0 /
116+
117+
ROCK
118+
-- Item 1: reference pressure (psia)
119+
-- Item 2: rock compressibility (psi^{-1})
120+
121+
-- Using values from table 1 in Odeh:
122+
14.7 3E-6 /
123+
124+
DENSITY
125+
-- Density (lb per ft³) at surface cond. of
126+
-- oil, water and gas, respectively (in that order)
127+
128+
-- Using values from Norne:
129+
-- In METRIC units:
130+
-- 859.5 1033.0 0.854 /
131+
-- In FIELD units:
132+
53.66 64.49 0.0533 /
133+
134+
SOLUTION
135+
-- -------------------------------------------------------------------------
136+
PRESSURE
137+
300*4800
138+
/
139+
140+
SUMMARY
141+
-- -------------------------------------------------------------------------
142+
WBHP
143+
'INJ'
144+
'PROD'
145+
/
146+
WWIR
147+
'INJ'
148+
/
149+
WWIT
150+
'INJ'
151+
/
152+
WWPR
153+
'PROD'
154+
/
155+
WWPT
156+
'PROD'
157+
/
158+
SCHEDULE
159+
-- -------------------------------------------------------------------------
160+
RPTSCHED
161+
'PRES' /
162+
163+
RPTRST
164+
'BASIC=1' /
165+
166+
WELSPECS
167+
-- Item #: 1 2 3 4 5 6
168+
'PROD' 'G1' 10 10 8400 'WATER' /
169+
'INJ' 'G1' 1 1 8335 'WATER' /
170+
/
171+
-- Coordinates in item 3-4 are retrieved from Odeh's figure 1 and 2
172+
-- Note that the depth at the midpoint of the well grid blocks
173+
-- has been used as reference depth for bottom hole pressure in item 5
174+
175+
COMPDAT
176+
-- Item #: 1 2 3 4 5 6 7 8 9
177+
'PROD' 10 10 3 3 'OPEN' 1* 1* 0.5 /
178+
'INJ' 1 1 1 1 'OPEN' 1* 1* 0.5 /
179+
/
180+
-- Coordinates in item 2-5 are retreived from Odeh's figure 1 and 2
181+
-- Item 9 is the well bore internal diameter,
182+
-- the radius is given to be 0.25ft in Odeh's paper
183+
184+
185+
WCONPROD
186+
-- Item #:1 2 3 4 5 9
187+
'PROD' 'OPEN' 'BHP' 1* 1* 1* 1* 1* 1000 /
188+
/
189+
190+
191+
WCONINJE
192+
-- Item #:1 2 3 4 5 6 7
193+
'INJ' 'WATER' 'OPEN' 'RATE' 100000 1* 9014 /
194+
/
195+
-- Stated in Odeh that gas inj. rate (item 5) is 100MMscf per day
196+
-- BHP upper limit (item 7) should not be exceeding the highest
197+
-- pressure in the PVT table=9014.7psia (default is 100 000psia)
198+
199+
TSTEP
200+
--Advance the simulater once a month for ONE years:
201+
31 28 31 30 31 30 31 31 30 31 30 31 /
202+
203+
END

0 commit comments

Comments
 (0)