forked from equinor/pyscal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_wateroilgas.py
More file actions
207 lines (178 loc) · 5.23 KB
/
Copy pathtest_wateroilgas.py
File metadata and controls
207 lines (178 loc) · 5.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
"""Test module for the WaterOilGas object"""
import os
from pathlib import Path
import pytest
from pyscal import GasOil, WaterOil, WaterOilGas
from pyscal.utils.testing import sat_table_str_ok
try:
import opm.io
HAVE_OPM = True
except ImportError:
HAVE_OPM = False
def test_wateroilgas_constructor():
"""Test that constructor properties are available as aattributes"""
wog = WaterOilGas(swirr=0.01, swl=0.02, sorg=0.03, sorw=0.04, tag="Foo")
assert wog.swirr == 0.01
assert wog.swl == 0.02
assert wog.sorg == 0.03
assert wog.tag == "Foo"
assert wog.sorw == 0.04
# Manipulate the tag in the underlying GasOil object:
wog.gasoil.tag = "Bar"
assert wog.tag == "Foo Bar" # Different tags are concatenated.
def test_wateroilgas_simple():
"""Test that default curves will give valid include strings"""
wog = WaterOilGas()
# Add default curves:
wog.wateroil.add_corey_water()
wog.wateroil.add_corey_oil()
wog.gasoil.add_corey_gas()
wog.gasoil.add_corey_oil()
with pytest.raises(AssertionError):
# Testing test code:
sat_table_str_ok("")
sat_table_str_ok(wog.SWOF())
sat_table_str_ok(wog.SGOF())
sat_table_str_ok(wog.SLGOF())
sat_table_str_ok(wog.SOF3())
sat_table_str_ok(wog.SGFN())
sat_table_str_ok(wog.SWFN())
def test_threephasecheck():
"""Test three phase consistency checks"""
wog = WaterOilGas()
assert not wog.selfcheck()
wog.wateroil.add_corey_water(nw=2)
wog.wateroil.add_corey_oil(now=2, kroend=0.9)
wog.gasoil.add_corey_gas(ng=2)
wog.gasoil.add_corey_oil(nog=2, kroend=1)
assert not wog.threephaseconsistency()
def test_empty():
"""Empty object should give empty strings (and logged errors)"""
wog = WaterOilGas()
assert wog.SWOF() == ""
assert wog.SGOF() == ""
assert wog.SOF3() == ""
assert wog.SLGOF() == ""
assert wog.SWFN() == ""
assert wog.SGFN() == ""
def test_manipulated_attributes_none():
"""It is allowed to manipulate the WaterOilGas by setting the wateroil
and/or the gasoil attributes to None, this is performed in
SCALrecommendation.interpolate() for example. Test this behaviour."""
wog_go = WaterOilGas(tag="gasoilonly")
# Make it into a two-phase object:
wog_go.wateroil = None
wog_go.gasoil.add_corey_gas()
wog_go.gasoil.add_corey_oil()
assert wog_go.SWFN() == ""
assert wog_go.SWOF() == ""
assert wog_go.SOF3() == ""
with pytest.raises(ValueError, match="wateroil is None in WaterOilGas"):
wog_go.swirr
with pytest.raises(ValueError, match="wateroil is None in WaterOilGas"):
wog_go.swl
with pytest.raises(ValueError, match="wateroil is None in WaterOilGas"):
wog_go.sorw
assert wog_go.tag == "gasoilonly"
assert wog_go.threephaseconsistency() is True
wog_wo = WaterOilGas(tag="wateroilonly")
wog_wo.gasoil = None
wog_wo.wateroil.add_corey_water()
wog_wo.wateroil.add_corey_oil()
assert wog_wo.SLGOF() == ""
assert wog_wo.SGFN() == ""
assert wog_wo.SOF3() == ""
assert wog_wo.SGOF() == ""
with pytest.raises(ValueError, match="gasoil is None in WaterOilGas"):
wog_wo.sorg
assert wog_wo.tag == "wateroilonly"
assert wog_wo.threephaseconsistency() is True
wog_nones = WaterOilGas()
wog_nones.wateroil = None
wog_nones.gasoil = None
wog_nones.tag == ""
assert wog_nones.threephaseconsistency() is True
assert wog_nones.SWOF() == ""
assert wog_nones.SGOF() == ""
assert wog_nones.selfcheck() is False
with pytest.raises(ValueError, match="wateroil is None"):
wog_nones.swirr
def test_not_threephase_consistency():
"""Mock a WaterOilGas object that fails threephase consistency"""
wog = WaterOilGas()
# To trigger this, we need to hack the WaterOilGas object
# by overriding the effect of its __init__
wog.wateroil = WaterOil(swl=0.4)
wog.gasoil = GasOil(swl=0.2)
wog.wateroil.add_corey_water(nw=2)
wog.wateroil.add_corey_oil(now=2, kroend=0.9)
wog.gasoil.add_corey_gas(ng=2)
wog.gasoil.add_corey_oil(nog=2, kroend=1)
assert not wog.threephaseconsistency()
@pytest.mark.skipif(
not HAVE_OPM, reason="Opm not installed. See https://pypi.org/project/opm/"
)
def test_parse_with_opm(tmp_path):
"""Test that the SWOF+SGOF output from pyscal can be
injected into a valid Eclipse deck"""
wog = WaterOilGas()
wog.wateroil.add_corey_water(nw=2)
wog.wateroil.add_corey_oil(now=2, kroend=0.9)
wog.gasoil.add_corey_gas(ng=2)
wog.gasoil.add_corey_oil(nog=2, kroend=1)
ecldeck = (
"""RUNSPEC
DIMENS
1 1 1 /
OIL
WATER
GAS
START
1 'JAN' 2100 /
TABDIMS
2* 10000 /
EQLDIMS
1 /
GRID
DX
10 /
DY
10 /
DZ
50 /
TOPS
1000 /
PORO
0.3 /
PERMX
100 /
PERMY
100 /
PERMZ
100 /
PROPS
"""
+ wog.SWOF()
+ wog.SGOF()
+ """
DENSITY
800 1000 1.2 /
PVTW
1 1 0.0001 0.2 0.00001 /
PVDO
100 1 1
150 0.9 1 /
PVDG
100 1 1
150 0.9 1 /
ROCK
100 0.0001 /
SOLUTION
EQUIL
1000 100 1040 0 1010 0 /"""
)
os.chdir(tmp_path)
Path("RELPERMTEST.DATA").write_text(ecldeck, encoding="utf8")
deck = opm.io.Parser().parse("RELPERMTEST.DATA")
assert "SWOF" in deck
assert "SGOF" in deck