Repository navigation
Expand file tree
/
Copy pathtest.py
More file actions
137 lines (103 loc) · 3.86 KB
/
Copy pathtest.py
File metadata and controls
137 lines (103 loc) · 3.86 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
#!/usr/bin/env python
# Copyright 2018-2020 John T. Foster
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
import numpy as np
import scipy.sparse
from assignment11 import OneDimReservoir
class TestSolution(unittest.TestCase):
def setUp(self):
self.inputs = {
'conversion factor': 6.33e-3,
'fluid': {
'water': {
'compressibility': 1e-6, #psi^{-1}
'viscosity': 1, #cp
'formation volume factor': 1,
},
},
'reservoir': {
'permeability': 50, #mD
'porosity': 0.2,
'length': 10000, #ft
'cross sectional area': 200000 #ft^2
},
'initial conditions': {
'pressure': 1000 #psi
},
'boundary conditions': {
'left': {
'type': 'prescribed pressure',
'value': 2000 #psi
},
'right': {
'type': 'prescribed flux',
'value': 0 #ft^3/day
}
},
'numerical': {
'solver': 'implicit',
'number of grids': {'x': 4},
'time step': 1, #day
'number of time steps' : 3
},
'plots': {
'frequency': 1
}
}
return
def test_compute_transmissibility(self):
problem = OneDimReservoir(self.inputs)
np.testing.assert_allclose(problem.compute_transmissibility(), 4000.0)
return
def test_compute_accumulation(self):
problem = OneDimReservoir(self.inputs)
np.testing.assert_allclose(problem.compute_accumulation(), 100.0)
return
def test_is_transmissiblity_matrix_sparse(self):
problem = OneDimReservoir(self.inputs)
assert scipy.sparse.issparse(problem.T)
return
def test_implicit_solve_one_step(self):
implicit = OneDimReservoir(self.inputs)
implicit.solve_one_step()
np.testing.assert_allclose(implicit.get_solution(),
np.array([1295.1463, 1051.1036, 1008.8921, 1001.7998]),
atol=0.5)
return
def test_explicit_solve_one_step(self):
self.inputs['numerical']['solver'] = 'explicit'
explicit = OneDimReservoir(self.inputs)
explicit.solve_one_step()
np.testing.assert_allclose(explicit.get_solution(),
np.array([ 1506., 1000., 1000., 1000.004]),
atol=0.5)
return
def test_implicit_solve(self):
implicit = OneDimReservoir(self.inputs)
implicit.solve()
np.testing.assert_allclose(implicit.get_solution(),
np.array([1582.9, 1184.8, 1051.5, 1015.9]),
atol=0.5)
return
def test_explicit_solve(self):
self.inputs['numerical']['solver'] = 'explicit'
explicit = OneDimReservoir(self.inputs)
explicit.solve()
np.testing.assert_allclose(explicit.get_solution(),
np.array([1689.8, 1222.3, 1032.4, 1000.0]),
atol=0.5)
return
if __name__ == '__main__':
unittest.main()