rock-physics-open 0.2.3__py3-none-any.whl → 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rock-physics-open might be problematic. Click here for more details.
- rock_physics_open/equinor_utilities/gen_utilities/dict_to_float.py +6 -1
- rock_physics_open/equinor_utilities/gen_utilities/dim_check_vector.py +35 -5
- rock_physics_open/equinor_utilities/gen_utilities/filter_input.py +11 -6
- rock_physics_open/equinor_utilities/gen_utilities/filter_output.py +29 -19
- rock_physics_open/equinor_utilities/machine_learning_utilities/__init__.py +18 -5
- rock_physics_open/equinor_utilities/machine_learning_utilities/base_pressure_model.py +172 -0
- rock_physics_open/equinor_utilities/machine_learning_utilities/exponential_model.py +100 -86
- rock_physics_open/equinor_utilities/machine_learning_utilities/friable_pressure_models.py +230 -0
- rock_physics_open/equinor_utilities/machine_learning_utilities/import_ml_models.py +23 -4
- rock_physics_open/equinor_utilities/machine_learning_utilities/patchy_cement_pressure_models.py +280 -0
- rock_physics_open/equinor_utilities/machine_learning_utilities/polynomial_model.py +128 -0
- rock_physics_open/equinor_utilities/machine_learning_utilities/sigmoidal_model.py +204 -155
- rock_physics_open/equinor_utilities/optimisation_utilities/__init__.py +19 -0
- rock_physics_open/equinor_utilities/snapshot_test_utilities/compare_snapshots.py +1 -2
- rock_physics_open/fluid_models/brine_model/brine_properties.py +70 -35
- rock_physics_open/fluid_models/gas_model/gas_properties.py +79 -37
- rock_physics_open/fluid_models/oil_model/dead_oil_density.py +21 -16
- rock_physics_open/fluid_models/oil_model/dead_oil_velocity.py +9 -7
- rock_physics_open/fluid_models/oil_model/live_oil_density.py +16 -13
- rock_physics_open/fluid_models/oil_model/live_oil_velocity.py +3 -3
- rock_physics_open/fluid_models/oil_model/oil_properties.py +59 -29
- rock_physics_open/sandstone_models/__init__.py +2 -0
- rock_physics_open/sandstone_models/constant_cement_optimisation.py +4 -1
- rock_physics_open/sandstone_models/friable_optimisation.py +4 -1
- rock_physics_open/sandstone_models/patchy_cement_model.py +89 -6
- rock_physics_open/sandstone_models/patchy_cement_optimisation.py +4 -1
- rock_physics_open/t_matrix_models/__init__.py +0 -10
- rock_physics_open/t_matrix_models/carbonate_pressure_substitution.py +1 -1
- rock_physics_open/t_matrix_models/curvefit_t_matrix_exp.py +1 -2
- rock_physics_open/t_matrix_models/t_matrix_opt_fluid_sub_exp.py +3 -3
- rock_physics_open/t_matrix_models/t_matrix_opt_fluid_sub_petec.py +5 -1
- rock_physics_open/t_matrix_models/t_matrix_opt_forward_model_exp.py +5 -1
- rock_physics_open/t_matrix_models/t_matrix_opt_forward_model_min.py +4 -1
- rock_physics_open/t_matrix_models/t_matrix_parameter_optimisation_exp.py +5 -1
- rock_physics_open/t_matrix_models/t_matrix_parameter_optimisation_min.py +4 -1
- rock_physics_open/version.py +2 -2
- {rock_physics_open-0.2.3.dist-info → rock_physics_open-0.3.0.dist-info}/METADATA +4 -8
- {rock_physics_open-0.2.3.dist-info → rock_physics_open-0.3.0.dist-info}/RECORD +42 -37
- /rock_physics_open/{t_matrix_models → equinor_utilities/optimisation_utilities}/opt_subst_utilities.py +0 -0
- {rock_physics_open-0.2.3.dist-info → rock_physics_open-0.3.0.dist-info}/WHEEL +0 -0
- {rock_physics_open-0.2.3.dist-info → rock_physics_open-0.3.0.dist-info}/licenses/LICENSE +0 -0
- {rock_physics_open-0.2.3.dist-info → rock_physics_open-0.3.0.dist-info}/top_level.txt +0 -0
|
@@ -1,188 +1,237 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
import pickle
|
|
2
|
-
from
|
|
3
|
-
from typing import Union
|
|
4
|
+
from typing import Any
|
|
4
5
|
|
|
5
6
|
import numpy as np
|
|
6
7
|
|
|
8
|
+
from .base_pressure_model import BasePressureModel
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class SigmoidalPressureModel(BasePressureModel):
|
|
12
|
+
"""
|
|
13
|
+
Sigmoidal pressure sensitivity model for velocity prediction.
|
|
14
|
+
|
|
15
|
+
Uses nested sigmoid functions: velocity amplitude varies with porosity,
|
|
16
|
+
and velocity varies sigmoidally with effective pressure using the amplitude.
|
|
17
|
+
|
|
18
|
+
Input format (n,3): [porosity, p_eff_in_situ, p_eff_depleted]
|
|
19
|
+
|
|
20
|
+
The model applies two sigmoid transformations:
|
|
21
|
+
1. Porosity -> velocity amplitude using phi_model parameters
|
|
22
|
+
2. Effective pressure -> velocity using p_eff_model parameters and amplitude
|
|
23
|
+
"""
|
|
7
24
|
|
|
8
|
-
class Sigmoid:
|
|
9
25
|
def __init__(
|
|
10
26
|
self,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
27
|
+
phi_amplitude: float,
|
|
28
|
+
phi_median_point: float,
|
|
29
|
+
phi_x_scaling: float,
|
|
30
|
+
phi_bias: float,
|
|
31
|
+
p_eff_median_point: float,
|
|
32
|
+
p_eff_x_scaling: float,
|
|
33
|
+
p_eff_bias: float,
|
|
34
|
+
model_max_pressure: float | None = None,
|
|
35
|
+
description: str = "",
|
|
16
36
|
):
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
"""
|
|
38
|
+
Initialize sigmoidal pressure model.
|
|
39
|
+
|
|
40
|
+
Parameters
|
|
41
|
+
----------
|
|
42
|
+
phi_amplitude : float
|
|
43
|
+
Amplitude parameter for porosity sigmoid [m/s].
|
|
44
|
+
phi_median_point : float
|
|
45
|
+
Median point for porosity sigmoid [fraction].
|
|
46
|
+
phi_x_scaling : float
|
|
47
|
+
X-scaling parameter for porosity sigmoid [unitless].
|
|
48
|
+
phi_bias : float
|
|
49
|
+
Bias parameter for porosity sigmoid [m/s].
|
|
50
|
+
p_eff_median_point : float
|
|
51
|
+
Median point for pressure sigmoid [Pa].
|
|
52
|
+
p_eff_x_scaling : float
|
|
53
|
+
X-scaling parameter for pressure sigmoid [1/Pa].
|
|
54
|
+
p_eff_bias : float
|
|
55
|
+
Bias parameter for pressure sigmoid [m/s].
|
|
56
|
+
model_max_pressure : float | None
|
|
57
|
+
Maximum pressure for predict_max method [Pa].
|
|
58
|
+
description : str
|
|
59
|
+
Model description.
|
|
60
|
+
"""
|
|
61
|
+
super().__init__(model_max_pressure, description)
|
|
62
|
+
# Porosity model parameters
|
|
63
|
+
self._phi_amplitude = phi_amplitude
|
|
64
|
+
self._phi_median_point = phi_median_point
|
|
65
|
+
self._phi_x_scaling = phi_x_scaling
|
|
66
|
+
self._phi_bias = phi_bias
|
|
67
|
+
# Pressure model parameters
|
|
68
|
+
self._p_eff_median_point = p_eff_median_point
|
|
69
|
+
self._p_eff_x_scaling = p_eff_x_scaling
|
|
70
|
+
self._p_eff_bias = p_eff_bias
|
|
31
71
|
|
|
32
72
|
@property
|
|
33
|
-
def
|
|
34
|
-
|
|
73
|
+
def phi_amplitude(self) -> float:
|
|
74
|
+
"""Porosity sigmoid amplitude."""
|
|
75
|
+
return self._phi_amplitude
|
|
35
76
|
|
|
36
77
|
@property
|
|
37
|
-
def
|
|
38
|
-
|
|
78
|
+
def phi_median_point(self) -> float:
|
|
79
|
+
"""Porosity sigmoid median point."""
|
|
80
|
+
return self._phi_median_point
|
|
39
81
|
|
|
40
82
|
@property
|
|
41
|
-
def
|
|
42
|
-
|
|
83
|
+
def phi_x_scaling(self) -> float:
|
|
84
|
+
"""Porosity sigmoid x-scaling."""
|
|
85
|
+
return self._phi_x_scaling
|
|
43
86
|
|
|
44
87
|
@property
|
|
45
|
-
def
|
|
46
|
-
|
|
88
|
+
def phi_bias(self) -> float:
|
|
89
|
+
"""Porosity sigmoid bias."""
|
|
90
|
+
return self._phi_bias
|
|
47
91
|
|
|
48
92
|
@property
|
|
49
|
-
def
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def predict(self, x):
|
|
53
|
-
if isinstance(x, list):
|
|
54
|
-
x = np.array(x)
|
|
55
|
-
if not self._valid():
|
|
56
|
-
return None
|
|
57
|
-
return (
|
|
58
|
-
self._amplitude / (1 + np.exp(-self._x_scaling * (x - self._median_point)))
|
|
59
|
-
+ self._bias
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
def predict_amp(self, x, amp):
|
|
63
|
-
if isinstance(x, list):
|
|
64
|
-
x = np.array(x)
|
|
65
|
-
if isinstance(amp, list):
|
|
66
|
-
amp = np.array(amp)
|
|
67
|
-
if not self._valid(variant="amp"):
|
|
68
|
-
return None
|
|
69
|
-
return (
|
|
70
|
-
amp / (1 + np.exp(-self._x_scaling * (x - self._median_point))) + self._bias
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
@classmethod
|
|
74
|
-
def save(cls, file):
|
|
75
|
-
with open(file, "wb") as f_out:
|
|
76
|
-
pickle.dump(cls, f_out)
|
|
77
|
-
|
|
78
|
-
@classmethod
|
|
79
|
-
def load(cls, file):
|
|
80
|
-
with open(file, "rb") as f_in:
|
|
81
|
-
return pickle.load(f_in)
|
|
82
|
-
|
|
83
|
-
def _valid(self, variant=None):
|
|
84
|
-
if variant is None and self.amplitude is None:
|
|
85
|
-
raise ValueError('object field "variant" is not set')
|
|
86
|
-
if self.median_point is None:
|
|
87
|
-
raise ValueError('object field "median_point" is not set')
|
|
88
|
-
if self.x_scaling is None:
|
|
89
|
-
raise ValueError('object field "x_scaling" is not set')
|
|
90
|
-
if self.bias is None:
|
|
91
|
-
raise ValueError('object field "bias" is not set')
|
|
92
|
-
return True
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
class CarbonateSigmoidalPressure:
|
|
96
|
-
def __init__(
|
|
97
|
-
self,
|
|
98
|
-
phi_model: Union[dict, Sigmoid] = None,
|
|
99
|
-
p_eff_model: Union[dict, Sigmoid] = None,
|
|
100
|
-
):
|
|
101
|
-
if isinstance(phi_model, Sigmoid):
|
|
102
|
-
self._phi_model = phi_model
|
|
103
|
-
elif isinstance(phi_model, dict):
|
|
104
|
-
self._phi_model = Sigmoid(**phi_model)
|
|
105
|
-
else:
|
|
106
|
-
self._phi_model = None
|
|
107
|
-
if isinstance(p_eff_model, Sigmoid):
|
|
108
|
-
self._p_eff_model = p_eff_model
|
|
109
|
-
elif isinstance(p_eff_model, dict):
|
|
110
|
-
self._p_eff_model = Sigmoid(**p_eff_model)
|
|
111
|
-
else:
|
|
112
|
-
self._p_eff_model = None
|
|
93
|
+
def p_eff_median_point(self) -> float:
|
|
94
|
+
"""Pressure sigmoid median point."""
|
|
95
|
+
return self._p_eff_median_point
|
|
113
96
|
|
|
114
97
|
@property
|
|
115
|
-
def
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
@phi_model.setter
|
|
119
|
-
def phi_model(self, phi_mod):
|
|
120
|
-
if isinstance(phi_mod, Sigmoid):
|
|
121
|
-
self._phi_model = phi_mod
|
|
122
|
-
else:
|
|
123
|
-
raise ValueError(
|
|
124
|
-
f"{type(self)}: expected input Sigmoid object, received {type(phi_mod)}"
|
|
125
|
-
)
|
|
98
|
+
def p_eff_x_scaling(self) -> float:
|
|
99
|
+
"""Pressure sigmoid x-scaling."""
|
|
100
|
+
return self._p_eff_x_scaling
|
|
126
101
|
|
|
127
102
|
@property
|
|
128
|
-
def
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
def
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
103
|
+
def p_eff_bias(self) -> float:
|
|
104
|
+
"""Pressure sigmoid bias."""
|
|
105
|
+
return self._p_eff_bias
|
|
106
|
+
|
|
107
|
+
def validate_input(self, inp_arr: np.ndarray) -> np.ndarray:
|
|
108
|
+
"""
|
|
109
|
+
Validate input for sigmoidal model.
|
|
110
|
+
|
|
111
|
+
Parameters
|
|
112
|
+
----------
|
|
113
|
+
inp_arr : np.ndarray
|
|
114
|
+
Input array to validate.
|
|
115
|
+
|
|
116
|
+
Returns
|
|
117
|
+
-------
|
|
118
|
+
np.ndarray
|
|
119
|
+
Validated input array.
|
|
120
|
+
|
|
121
|
+
Raises
|
|
122
|
+
------
|
|
123
|
+
ValueError
|
|
124
|
+
If input format is invalid.
|
|
125
|
+
"""
|
|
126
|
+
if not isinstance(inp_arr, np.ndarray):
|
|
127
|
+
raise ValueError("Input must be numpy ndarray.")
|
|
128
|
+
if inp_arr.ndim != 2 or inp_arr.shape[1] != 3:
|
|
136
129
|
raise ValueError(
|
|
137
|
-
|
|
130
|
+
"Input must be (n,3): [porosity, p_eff_in_situ, p_eff_depleted]"
|
|
138
131
|
)
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
132
|
+
return inp_arr
|
|
133
|
+
|
|
134
|
+
def _sigmoid_phi(self, phi: np.ndarray) -> np.ndarray:
|
|
135
|
+
"""
|
|
136
|
+
Calculate velocity amplitude from porosity using sigmoid function.
|
|
137
|
+
|
|
138
|
+
Parameters
|
|
139
|
+
----------
|
|
140
|
+
phi : np.ndarray
|
|
141
|
+
Porosity values [fraction].
|
|
142
|
+
|
|
143
|
+
Returns
|
|
144
|
+
-------
|
|
145
|
+
np.ndarray
|
|
146
|
+
Velocity amplitude values [m/s].
|
|
147
|
+
"""
|
|
148
|
+
return (
|
|
149
|
+
self._phi_amplitude
|
|
150
|
+
/ (1 + np.exp(-self._phi_x_scaling * (phi - self._phi_median_point)))
|
|
151
|
+
+ self._phi_bias
|
|
147
152
|
)
|
|
148
|
-
|
|
149
|
-
|
|
153
|
+
|
|
154
|
+
def _sigmoid_p_eff(self, p_eff: np.ndarray, amplitude: np.ndarray) -> np.ndarray:
|
|
155
|
+
"""
|
|
156
|
+
Calculate velocity from effective pressure using sigmoid function with amplitude.
|
|
157
|
+
|
|
158
|
+
Parameters
|
|
159
|
+
----------
|
|
160
|
+
p_eff : np.ndarray
|
|
161
|
+
Effective pressure values [Pa].
|
|
162
|
+
amplitude : np.ndarray
|
|
163
|
+
Velocity amplitude values [m/s].
|
|
164
|
+
|
|
165
|
+
Returns
|
|
166
|
+
-------
|
|
167
|
+
np.ndarray
|
|
168
|
+
Velocity values [m/s].
|
|
169
|
+
"""
|
|
170
|
+
return (
|
|
171
|
+
amplitude
|
|
172
|
+
/ (1 + np.exp(-self._p_eff_x_scaling * (p_eff - self._p_eff_median_point)))
|
|
173
|
+
+ self._p_eff_bias
|
|
150
174
|
)
|
|
151
|
-
return velocity_depl - velocity_init
|
|
152
175
|
|
|
153
176
|
def predict_abs(self, inp_arr: np.ndarray, case: str = "in_situ") -> np.ndarray:
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
177
|
+
"""
|
|
178
|
+
Calculate absolute velocity for specified pressure case.
|
|
179
|
+
|
|
180
|
+
Parameters
|
|
181
|
+
----------
|
|
182
|
+
inp_arr : np.ndarray
|
|
183
|
+
Validated input array (n,3).
|
|
184
|
+
case : str
|
|
185
|
+
Pressure case: "in_situ" or "depleted".
|
|
186
|
+
|
|
187
|
+
Returns
|
|
188
|
+
-------
|
|
189
|
+
np.ndarray
|
|
190
|
+
Velocity values [m/s].
|
|
191
|
+
"""
|
|
192
|
+
arr = self.validate_input(inp_arr)
|
|
193
|
+
|
|
194
|
+
phi = arr[:, 0]
|
|
195
|
+
p_in_situ = arr[:, 1]
|
|
196
|
+
p_depleted = arr[:, 2]
|
|
197
|
+
|
|
198
|
+
# Calculate velocity amplitude from porosity
|
|
199
|
+
velocity_amplitude = self._sigmoid_phi(phi)
|
|
200
|
+
|
|
201
|
+
# Select pressure based on case
|
|
202
|
+
p_eff = p_in_situ if case == "in_situ" else p_depleted
|
|
203
|
+
|
|
204
|
+
# Calculate velocity from effective pressure and amplitude
|
|
205
|
+
return self._sigmoid_p_eff(p_eff, velocity_amplitude)
|
|
206
|
+
|
|
207
|
+
def todict(self) -> dict[str, Any]:
|
|
208
|
+
"""Convert model to dictionary."""
|
|
173
209
|
return {
|
|
174
|
-
"
|
|
175
|
-
"
|
|
210
|
+
"phi_amplitude": self._phi_amplitude,
|
|
211
|
+
"phi_median_point": self._phi_median_point,
|
|
212
|
+
"phi_x_scaling": self._phi_x_scaling,
|
|
213
|
+
"phi_bias": self._phi_bias,
|
|
214
|
+
"p_eff_median_point": self._p_eff_median_point,
|
|
215
|
+
"p_eff_x_scaling": self._p_eff_x_scaling,
|
|
216
|
+
"p_eff_bias": self._p_eff_bias,
|
|
217
|
+
"model_max_pressure": self._model_max_pressure,
|
|
218
|
+
"description": self._description,
|
|
176
219
|
}
|
|
177
220
|
|
|
178
|
-
def save(self, file: Union[str, BufferedIOBase]):
|
|
179
|
-
with open(file, "wb") as f_out:
|
|
180
|
-
pickle.dump(self.todict(), f_out)
|
|
181
|
-
|
|
182
221
|
@classmethod
|
|
183
|
-
def load(cls, file:
|
|
222
|
+
def load(cls, file: str | bytes) -> "SigmoidalPressureModel":
|
|
223
|
+
"""Load sigmoidal model from pickle file."""
|
|
184
224
|
with open(file, "rb") as f_in:
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
225
|
+
d = pickle.load(f_in)
|
|
226
|
+
|
|
227
|
+
return cls(
|
|
228
|
+
phi_amplitude=d["phi_amplitude"],
|
|
229
|
+
phi_median_point=d["phi_median_point"],
|
|
230
|
+
phi_x_scaling=d["phi_x_scaling"],
|
|
231
|
+
phi_bias=d["phi_bias"],
|
|
232
|
+
p_eff_median_point=d["p_eff_median_point"],
|
|
233
|
+
p_eff_x_scaling=d["p_eff_x_scaling"],
|
|
234
|
+
p_eff_bias=d["p_eff_bias"],
|
|
235
|
+
model_max_pressure=d["model_max_pressure"],
|
|
236
|
+
description=d["description"],
|
|
237
|
+
)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from .opt_subst_utilities import (
|
|
2
|
+
gen_mod_routine,
|
|
3
|
+
gen_opt_routine,
|
|
4
|
+
gen_sub_routine,
|
|
5
|
+
load_opt_params,
|
|
6
|
+
opt_param_info,
|
|
7
|
+
opt_param_to_ascii,
|
|
8
|
+
save_opt_params,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
"gen_mod_routine",
|
|
13
|
+
"gen_sub_routine",
|
|
14
|
+
"gen_opt_routine",
|
|
15
|
+
"opt_param_to_ascii",
|
|
16
|
+
"opt_param_info",
|
|
17
|
+
"save_opt_params",
|
|
18
|
+
"load_opt_params",
|
|
19
|
+
]
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import inspect
|
|
2
2
|
import math
|
|
3
3
|
import re
|
|
4
|
-
from typing import Union
|
|
5
4
|
from warnings import warn
|
|
6
5
|
|
|
7
6
|
import numpy as np
|
|
@@ -13,7 +12,7 @@ from .snapshots import get_snapshot_name
|
|
|
13
12
|
|
|
14
13
|
|
|
15
14
|
def compare_snapshots(
|
|
16
|
-
test_results:
|
|
15
|
+
test_results: np.ndarray | tuple | DataFrame,
|
|
17
16
|
saved_results: tuple,
|
|
18
17
|
name_arr=None,
|
|
19
18
|
display_results: bool = False,
|
|
@@ -14,16 +14,16 @@ def brine_properties(
|
|
|
14
14
|
p_cacl: np.ndarray | float | None = None,
|
|
15
15
|
) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
|
|
16
16
|
"""
|
|
17
|
-
:param salinity: Salinity of solution as ppm of NaCl.
|
|
18
|
-
:param pressure: Pressure
|
|
19
|
-
:param temperature: Temperature
|
|
17
|
+
:param salinity: Salinity of solution as [ppm] of NaCl.
|
|
18
|
+
:param pressure: Pressure [Pa]
|
|
19
|
+
:param temperature: Temperature [°C]
|
|
20
20
|
:param p_nacl: NaCl percentage, for future use
|
|
21
21
|
:param p_kcl: KCl percentage, for future use
|
|
22
22
|
:param p_cacl: CaCl percentage, for future use
|
|
23
|
-
:return: vel_b [m/s], den_b [kg/m^3], k_b [Pa]
|
|
23
|
+
:return: Brine velocity vel_b [m/s], brine density den_b [kg/m^3], brine bulk modulus k_b [Pa]
|
|
24
24
|
"""
|
|
25
|
-
vel_b = brine_primary_velocity(temperature, pressure
|
|
26
|
-
den_b = brine_density(temperature, pressure
|
|
25
|
+
vel_b = brine_primary_velocity(temperature, pressure, salinity)
|
|
26
|
+
den_b = brine_density(temperature, pressure, salinity)
|
|
27
27
|
k_b = vel_b**2 * den_b
|
|
28
28
|
return vel_b, den_b, k_b
|
|
29
29
|
|
|
@@ -35,19 +35,27 @@ def brine_density(
|
|
|
35
35
|
) -> np.ndarray | float:
|
|
36
36
|
"""
|
|
37
37
|
density of sodium chloride solutions, equation 27 in Batzle & Wang [1].
|
|
38
|
-
:param salinity: Salinity of solution
|
|
39
|
-
|
|
40
|
-
:param
|
|
41
|
-
:
|
|
42
|
-
:return: density of solution in g/cc.
|
|
38
|
+
:param salinity: Salinity of solution in ppm
|
|
39
|
+
:param pressure: Pressure [Pa]
|
|
40
|
+
:param temperature: Temperature [°C]
|
|
41
|
+
:return: density of solution in [kg/m^3].
|
|
43
42
|
"""
|
|
43
|
+
# Change unit of pressure to MPa
|
|
44
|
+
pressure_mpa = pressure / 1.0e6
|
|
45
|
+
# Change unit of salinity to fraction
|
|
46
|
+
salinity_frac = salinity / 1.0e6
|
|
47
|
+
|
|
44
48
|
coefficients = [
|
|
45
49
|
[[0.668, 3e-4], [8e-5, -13e-6], [3e-6, 0.0]],
|
|
46
50
|
[[0.44, -24e-4], [-33e-4, 47e-6], [0.0, 0.0]],
|
|
47
51
|
]
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
water_den = water_density(temperature, pressure)
|
|
53
|
+
brine_correction = (
|
|
54
|
+
salinity_frac
|
|
55
|
+
* polyval3d(salinity_frac, temperature, pressure_mpa, coefficients)
|
|
56
|
+
* 1000.0
|
|
50
57
|
)
|
|
58
|
+
return water_den + brine_correction
|
|
51
59
|
|
|
52
60
|
|
|
53
61
|
def brine_primary_velocity(
|
|
@@ -58,12 +66,16 @@ def brine_primary_velocity(
|
|
|
58
66
|
"""
|
|
59
67
|
Primary wave velocity of sodium chloride solutions, equation 29 in Batzle & Wang [1]
|
|
60
68
|
|
|
61
|
-
:param salinity: Salinity of solution as
|
|
62
|
-
|
|
63
|
-
:param
|
|
64
|
-
:param temperature: Temperature (Celsius) of oil.
|
|
69
|
+
:param salinity: Salinity of solution as [ppm] of sodium chloride
|
|
70
|
+
:param pressure: Pressure [Pa]
|
|
71
|
+
:param temperature: Temperature [°C]
|
|
65
72
|
:return: velocity of solution in m/s.
|
|
66
73
|
"""
|
|
74
|
+
# Change unit for salinity from ppm to fraction
|
|
75
|
+
salinity_frac = salinity / 1.0e6
|
|
76
|
+
# Change the unit for pressure from Pa to MPa
|
|
77
|
+
pressure_mpa = pressure / 1.0e6
|
|
78
|
+
|
|
67
79
|
coefficients = np.zeros((3, 4, 3))
|
|
68
80
|
coefficients[0, 0, 0] = 1170
|
|
69
81
|
coefficients[0, 1, 0] = -9.6
|
|
@@ -77,8 +89,8 @@ def brine_primary_velocity(
|
|
|
77
89
|
coefficients[1, 0, 2] = 0.16
|
|
78
90
|
coefficients[2, 0, 0] = -820
|
|
79
91
|
|
|
80
|
-
return water_primary_velocity(temperature, pressure) +
|
|
81
|
-
sqrt(
|
|
92
|
+
return water_primary_velocity(temperature, pressure) + salinity_frac * polyval3d(
|
|
93
|
+
sqrt(salinity_frac), temperature, pressure_mpa, coefficients
|
|
82
94
|
)
|
|
83
95
|
|
|
84
96
|
|
|
@@ -88,17 +100,20 @@ def water_density(
|
|
|
88
100
|
) -> np.ndarray | float:
|
|
89
101
|
"""
|
|
90
102
|
Density of water,, equation 27a in Batzle & Wang [1].
|
|
91
|
-
:param pressure: Pressure
|
|
92
|
-
:param temperature: Temperature
|
|
93
|
-
:return: Density of water in
|
|
103
|
+
:param pressure: Pressure [Pa]
|
|
104
|
+
:param temperature: Temperature [°C]
|
|
105
|
+
:return: Density of water in [kg/m^3].
|
|
94
106
|
"""
|
|
107
|
+
# Change unit of pressure from Pa to MPa
|
|
108
|
+
pressure_mpa = pressure / 1.0e6
|
|
109
|
+
|
|
95
110
|
coefficients = [
|
|
96
111
|
[1.0, 489e-6, -333e-9],
|
|
97
112
|
[-8e-5, -2e-6, -2e-09],
|
|
98
113
|
[-33e-7, 16e-9, 0.0],
|
|
99
114
|
[1.75e-9, -13e-12, 0.0],
|
|
100
115
|
]
|
|
101
|
-
return polyval2d(temperature,
|
|
116
|
+
return polyval2d(temperature, pressure_mpa, coefficients) * 1000.0
|
|
102
117
|
|
|
103
118
|
|
|
104
119
|
def water_primary_velocity(
|
|
@@ -107,11 +122,14 @@ def water_primary_velocity(
|
|
|
107
122
|
) -> np.ndarray | float:
|
|
108
123
|
"""
|
|
109
124
|
Primary wave velocity of water, table 1 and equation 28 in Batzle & Wang [1].
|
|
110
|
-
:param pressure: Pressure
|
|
111
|
-
:param temperature: Temperature
|
|
125
|
+
:param pressure: Pressure [Pa]
|
|
126
|
+
:param temperature: Temperature [°C]
|
|
112
127
|
:return: primary wave velocity of water in m/s.
|
|
113
128
|
"""
|
|
114
|
-
|
|
129
|
+
# Change unit of pressure from Pa to MPa
|
|
130
|
+
pressure_mpa = pressure / 1.0e6
|
|
131
|
+
|
|
132
|
+
if np.any(pressure_mpa > 100):
|
|
115
133
|
warnings.warn(
|
|
116
134
|
"Calculations for water velocity is not precise for\n"
|
|
117
135
|
+ "pressure outside [0,100]MPa"
|
|
@@ -125,19 +143,36 @@ def water_primary_velocity(
|
|
|
125
143
|
[1.487e-4, -6.503e-7, -1.455e-8, 1.327e-10],
|
|
126
144
|
[-2.197e-7, 7.987e-10, 5.23e-11, -4.614e-13],
|
|
127
145
|
]
|
|
128
|
-
return polyval2d(temperature,
|
|
146
|
+
return polyval2d(temperature, pressure_mpa, coefficients)
|
|
129
147
|
|
|
130
148
|
|
|
131
149
|
def water(
|
|
132
150
|
temperature: np.ndarray | float, pressure: np.ndarray | float
|
|
133
151
|
) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
|
|
134
152
|
"""
|
|
135
|
-
:param pressure: Pressure
|
|
136
|
-
:param temperature: Temperature
|
|
137
|
-
:return:
|
|
153
|
+
:param pressure: Pressure [Pa]
|
|
154
|
+
:param temperature: Temperature [°C]
|
|
155
|
+
:return: water_velocity [m/s], water_density [kg/m^3], water_bulk_modulus [Pa]
|
|
138
156
|
"""
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
157
|
+
water_den = water_density(temperature, pressure)
|
|
158
|
+
water_vel = water_primary_velocity(temperature, pressure)
|
|
159
|
+
water_k = water_vel**2 * water_den
|
|
160
|
+
return water_vel, water_den, water_k
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def brine_viscosity(
|
|
164
|
+
temperature: np.ndarray | float,
|
|
165
|
+
salinity: np.ndarray | float,
|
|
166
|
+
) -> np.ndarray | float:
|
|
167
|
+
"""
|
|
168
|
+
Brine viscosity according to Batzle & Wang [1].
|
|
169
|
+
|
|
170
|
+
Based on equation 32.
|
|
171
|
+
"""
|
|
172
|
+
salinity_frac = salinity / 1.0e6
|
|
173
|
+
return (
|
|
174
|
+
0.1
|
|
175
|
+
+ 0.333 * salinity_frac
|
|
176
|
+
+ (1.65 + 91.9 * salinity_frac**3)
|
|
177
|
+
* np.exp(-(0.42 * (salinity_frac**0.8 - 0.17) ** 2 + 0.045) * temperature**0.8)
|
|
178
|
+
)
|