rock-physics-open 0.3.2__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.
Files changed (145) hide show
  1. rock_physics_open/__init__.py +0 -0
  2. rock_physics_open/equinor_utilities/__init__.py +0 -0
  3. rock_physics_open/equinor_utilities/anisotropy.py +211 -0
  4. rock_physics_open/equinor_utilities/classification_functions/__init__.py +17 -0
  5. rock_physics_open/equinor_utilities/classification_functions/class_stats.py +68 -0
  6. rock_physics_open/equinor_utilities/classification_functions/lin_class.py +53 -0
  7. rock_physics_open/equinor_utilities/classification_functions/mahal_class.py +63 -0
  8. rock_physics_open/equinor_utilities/classification_functions/norm_class.py +73 -0
  9. rock_physics_open/equinor_utilities/classification_functions/poly_class.py +45 -0
  10. rock_physics_open/equinor_utilities/classification_functions/post_prob.py +27 -0
  11. rock_physics_open/equinor_utilities/classification_functions/two_step_classification.py +60 -0
  12. rock_physics_open/equinor_utilities/conversions.py +10 -0
  13. rock_physics_open/equinor_utilities/gen_utilities/__init__.py +11 -0
  14. rock_physics_open/equinor_utilities/gen_utilities/dict_to_float.py +38 -0
  15. rock_physics_open/equinor_utilities/gen_utilities/dim_check_vector.py +113 -0
  16. rock_physics_open/equinor_utilities/gen_utilities/filter_input.py +131 -0
  17. rock_physics_open/equinor_utilities/gen_utilities/filter_output.py +88 -0
  18. rock_physics_open/equinor_utilities/machine_learning_utilities/__init__.py +15 -0
  19. rock_physics_open/equinor_utilities/machine_learning_utilities/base_pressure_model.py +170 -0
  20. rock_physics_open/equinor_utilities/machine_learning_utilities/dummy_vars.py +53 -0
  21. rock_physics_open/equinor_utilities/machine_learning_utilities/exponential_model.py +137 -0
  22. rock_physics_open/equinor_utilities/machine_learning_utilities/import_ml_models.py +77 -0
  23. rock_physics_open/equinor_utilities/machine_learning_utilities/polynomial_model.py +132 -0
  24. rock_physics_open/equinor_utilities/machine_learning_utilities/run_regression.py +209 -0
  25. rock_physics_open/equinor_utilities/machine_learning_utilities/sigmoidal_model.py +241 -0
  26. rock_physics_open/equinor_utilities/optimisation_utilities/__init__.py +19 -0
  27. rock_physics_open/equinor_utilities/optimisation_utilities/opt_subst_utilities.py +455 -0
  28. rock_physics_open/equinor_utilities/snapshot_test_utilities/__init__.py +10 -0
  29. rock_physics_open/equinor_utilities/snapshot_test_utilities/compare_snapshots.py +184 -0
  30. rock_physics_open/equinor_utilities/snapshot_test_utilities/snapshots.py +97 -0
  31. rock_physics_open/equinor_utilities/std_functions/__init__.py +43 -0
  32. rock_physics_open/equinor_utilities/std_functions/backus_ave.py +68 -0
  33. rock_physics_open/equinor_utilities/std_functions/dvorkin_nur.py +77 -0
  34. rock_physics_open/equinor_utilities/std_functions/gassmann.py +165 -0
  35. rock_physics_open/equinor_utilities/std_functions/hashin_shtrikman.py +224 -0
  36. rock_physics_open/equinor_utilities/std_functions/hertz_mindlin.py +51 -0
  37. rock_physics_open/equinor_utilities/std_functions/moduli_velocity.py +67 -0
  38. rock_physics_open/equinor_utilities/std_functions/reflection_eq.py +120 -0
  39. rock_physics_open/equinor_utilities/std_functions/rho.py +69 -0
  40. rock_physics_open/equinor_utilities/std_functions/voigt_reuss_hill.py +149 -0
  41. rock_physics_open/equinor_utilities/std_functions/walton.py +45 -0
  42. rock_physics_open/equinor_utilities/std_functions/wood_brie.py +94 -0
  43. rock_physics_open/equinor_utilities/various_utilities/Equinor_logo.gif +0 -0
  44. rock_physics_open/equinor_utilities/various_utilities/Equinor_logo.ico +0 -0
  45. rock_physics_open/equinor_utilities/various_utilities/__init__.py +24 -0
  46. rock_physics_open/equinor_utilities/various_utilities/display_result_statistics.py +90 -0
  47. rock_physics_open/equinor_utilities/various_utilities/gassmann_dry_mod.py +56 -0
  48. rock_physics_open/equinor_utilities/various_utilities/gassmann_mod.py +56 -0
  49. rock_physics_open/equinor_utilities/various_utilities/gassmann_sub_mod.py +64 -0
  50. rock_physics_open/equinor_utilities/various_utilities/hs_average.py +59 -0
  51. rock_physics_open/equinor_utilities/various_utilities/pressure.py +96 -0
  52. rock_physics_open/equinor_utilities/various_utilities/reflectivity.py +101 -0
  53. rock_physics_open/equinor_utilities/various_utilities/timeshift.py +104 -0
  54. rock_physics_open/equinor_utilities/various_utilities/vp_vs_rho_set_statistics.py +170 -0
  55. rock_physics_open/equinor_utilities/various_utilities/vrh_3_min.py +83 -0
  56. rock_physics_open/fluid_models/__init__.py +9 -0
  57. rock_physics_open/fluid_models/brine_model/__init__.py +5 -0
  58. rock_physics_open/fluid_models/brine_model/brine_properties.py +178 -0
  59. rock_physics_open/fluid_models/gas_model/__init__.py +5 -0
  60. rock_physics_open/fluid_models/gas_model/gas_properties.py +319 -0
  61. rock_physics_open/fluid_models/oil_model/__init__.py +5 -0
  62. rock_physics_open/fluid_models/oil_model/dead_oil_density.py +65 -0
  63. rock_physics_open/fluid_models/oil_model/dead_oil_velocity.py +30 -0
  64. rock_physics_open/fluid_models/oil_model/live_oil_density.py +82 -0
  65. rock_physics_open/fluid_models/oil_model/live_oil_velocity.py +24 -0
  66. rock_physics_open/fluid_models/oil_model/oil_bubble_point.py +69 -0
  67. rock_physics_open/fluid_models/oil_model/oil_properties.py +146 -0
  68. rock_physics_open/sandstone_models/__init__.py +59 -0
  69. rock_physics_open/sandstone_models/cemented_shalysand_sandyshale_models.py +304 -0
  70. rock_physics_open/sandstone_models/constant_cement_models.py +204 -0
  71. rock_physics_open/sandstone_models/constant_cement_optimisation.py +125 -0
  72. rock_physics_open/sandstone_models/contact_cement_model.py +138 -0
  73. rock_physics_open/sandstone_models/curvefit_sandstone_models.py +143 -0
  74. rock_physics_open/sandstone_models/friable_models.py +177 -0
  75. rock_physics_open/sandstone_models/friable_optimisation.py +115 -0
  76. rock_physics_open/sandstone_models/friable_shalysand_sandyshale_models.py +235 -0
  77. rock_physics_open/sandstone_models/patchy_cement_fluid_substitution_model.py +477 -0
  78. rock_physics_open/sandstone_models/patchy_cement_model.py +384 -0
  79. rock_physics_open/sandstone_models/patchy_cement_optimisation.py +254 -0
  80. rock_physics_open/sandstone_models/unresolved_cemented_sandshale_models.py +134 -0
  81. rock_physics_open/sandstone_models/unresolved_friable_sandshale_models.py +126 -0
  82. rock_physics_open/shale_models/__init__.py +19 -0
  83. rock_physics_open/shale_models/dem.py +174 -0
  84. rock_physics_open/shale_models/dem_dual_por.py +61 -0
  85. rock_physics_open/shale_models/kus_tok.py +59 -0
  86. rock_physics_open/shale_models/multi_sca.py +133 -0
  87. rock_physics_open/shale_models/pq.py +102 -0
  88. rock_physics_open/shale_models/sca.py +90 -0
  89. rock_physics_open/shale_models/shale4_mineral.py +147 -0
  90. rock_physics_open/shale_models/shale4_mineral_dem_overlay.py +92 -0
  91. rock_physics_open/span_wagner/__init__.py +5 -0
  92. rock_physics_open/span_wagner/co2_properties.py +444 -0
  93. rock_physics_open/span_wagner/coefficients.py +165 -0
  94. rock_physics_open/span_wagner/equations.py +104 -0
  95. rock_physics_open/span_wagner/tables/__init__.py +0 -0
  96. rock_physics_open/span_wagner/tables/carbon_dioxide_density.npz +0 -0
  97. rock_physics_open/span_wagner/tables/lookup_table.py +33 -0
  98. rock_physics_open/t_matrix_models/Equinor_logo.ico +0 -0
  99. rock_physics_open/t_matrix_models/__init__.py +35 -0
  100. rock_physics_open/t_matrix_models/carbonate_pressure_substitution.py +124 -0
  101. rock_physics_open/t_matrix_models/curvefit_t_matrix_exp.py +123 -0
  102. rock_physics_open/t_matrix_models/curvefit_t_matrix_min.py +86 -0
  103. rock_physics_open/t_matrix_models/parse_t_matrix_inputs.py +297 -0
  104. rock_physics_open/t_matrix_models/run_t_matrix.py +243 -0
  105. rock_physics_open/t_matrix_models/t_matrix_C.py +210 -0
  106. rock_physics_open/t_matrix_models/t_matrix_opt_fluid_sub_exp.py +137 -0
  107. rock_physics_open/t_matrix_models/t_matrix_opt_fluid_sub_petec.py +167 -0
  108. rock_physics_open/t_matrix_models/t_matrix_opt_forward_model_exp.py +76 -0
  109. rock_physics_open/t_matrix_models/t_matrix_opt_forward_model_min.py +89 -0
  110. rock_physics_open/t_matrix_models/t_matrix_parameter_optimisation_exp.py +176 -0
  111. rock_physics_open/t_matrix_models/t_matrix_parameter_optimisation_min.py +162 -0
  112. rock_physics_open/t_matrix_models/t_matrix_vector/__init__.py +12 -0
  113. rock_physics_open/t_matrix_models/t_matrix_vector/array_functions.py +75 -0
  114. rock_physics_open/t_matrix_models/t_matrix_vector/calc_c_eff.py +163 -0
  115. rock_physics_open/t_matrix_models/t_matrix_vector/calc_isolated.py +95 -0
  116. rock_physics_open/t_matrix_models/t_matrix_vector/calc_kd.py +40 -0
  117. rock_physics_open/t_matrix_models/t_matrix_vector/calc_kd_eff.py +116 -0
  118. rock_physics_open/t_matrix_models/t_matrix_vector/calc_kd_uuv.py +18 -0
  119. rock_physics_open/t_matrix_models/t_matrix_vector/calc_pressure.py +140 -0
  120. rock_physics_open/t_matrix_models/t_matrix_vector/calc_t.py +71 -0
  121. rock_physics_open/t_matrix_models/t_matrix_vector/calc_td.py +42 -0
  122. rock_physics_open/t_matrix_models/t_matrix_vector/calc_theta.py +43 -0
  123. rock_physics_open/t_matrix_models/t_matrix_vector/calc_x.py +33 -0
  124. rock_physics_open/t_matrix_models/t_matrix_vector/calc_z.py +50 -0
  125. rock_physics_open/t_matrix_models/t_matrix_vector/check_and_tile.py +43 -0
  126. rock_physics_open/t_matrix_models/t_matrix_vector/g_tensor.py +140 -0
  127. rock_physics_open/t_matrix_models/t_matrix_vector/iso_av.py +60 -0
  128. rock_physics_open/t_matrix_models/t_matrix_vector/iso_ave_all.py +55 -0
  129. rock_physics_open/t_matrix_models/t_matrix_vector/pressure_input.py +44 -0
  130. rock_physics_open/t_matrix_models/t_matrix_vector/t_matrix_vec.py +278 -0
  131. rock_physics_open/t_matrix_models/t_matrix_vector/velocity_vti_angles.py +81 -0
  132. rock_physics_open/t_matrix_models/tmatrix_python.dll +0 -0
  133. rock_physics_open/t_matrix_models/tmatrix_python.so +0 -0
  134. rock_physics_open/ternary_plots/__init__.py +3 -0
  135. rock_physics_open/ternary_plots/gen_ternary_plot.py +73 -0
  136. rock_physics_open/ternary_plots/shale_prop_ternary.py +337 -0
  137. rock_physics_open/ternary_plots/ternary_patches.py +277 -0
  138. rock_physics_open/ternary_plots/ternary_plot_utilities.py +197 -0
  139. rock_physics_open/ternary_plots/unconventionals_ternary.py +75 -0
  140. rock_physics_open/version.py +34 -0
  141. rock_physics_open-0.3.2.dist-info/METADATA +90 -0
  142. rock_physics_open-0.3.2.dist-info/RECORD +145 -0
  143. rock_physics_open-0.3.2.dist-info/WHEEL +5 -0
  144. rock_physics_open-0.3.2.dist-info/licenses/LICENSE +165 -0
  145. rock_physics_open-0.3.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,384 @@
1
+ import numpy as np
2
+
3
+ from rock_physics_open.equinor_utilities import std_functions
4
+ from rock_physics_open.equinor_utilities.gen_utilities import (
5
+ dim_check_vector,
6
+ filter_input_log,
7
+ filter_output,
8
+ )
9
+
10
+ from .constant_cement_models import constant_cement_model_dry
11
+ from .friable_models import friable_model_dry
12
+
13
+ FRAC_CEM_UP = 0.1
14
+ P_EFF_LOW = 20.0e6
15
+
16
+
17
+ def constant_cement_model_pcm(
18
+ kmin, mymin, kcem, mycem, kzero, myzero, phi, cem_frac, phic, n, red_shear
19
+ ):
20
+ """
21
+ kdry, mydry = contantcementmodel_pcm(kmin, mymin, kcem, mycem, kzero, myzero, phi, cem_frac, phic, n, red_shear)
22
+ """
23
+
24
+ # Contact cement model (Dvorkin-Nur)for given cem_frac
25
+ kcc, mycc = std_functions.dvorkin_contact_cement(
26
+ cem_frac, phic, mymin, kmin, mycem, kcem, red_shear, n
27
+ )
28
+
29
+ # Fraction of zero-porosity end member
30
+ f1 = 1 - phi / (phic - cem_frac)
31
+
32
+ # Interpolating using Hashin -Shtrikman lower bound = Constant cement model.
33
+ # Same mineral point as upper and lower bound in patchy cement model
34
+ kdry, mydry = std_functions.hashin_shtrikman_walpole(
35
+ kzero, myzero, kcc, mycc, f1, bound="lower"
36
+ )
37
+
38
+ return kdry, mydry
39
+
40
+
41
+ def patchy_cement_model_weight(
42
+ k_min,
43
+ mu_min,
44
+ rho_min,
45
+ k_cem,
46
+ mu_cem,
47
+ rho_cem,
48
+ k_fl,
49
+ rho_fl,
50
+ phi,
51
+ p_eff,
52
+ frac_cem,
53
+ phi_c,
54
+ coord_num_func,
55
+ n,
56
+ shear_red,
57
+ weight_k,
58
+ weight_mu,
59
+ ):
60
+ """
61
+ Patchy cement model for sands that are a combination of friable model and constant cement model. No fluid or
62
+ pressure substitution. Input variables for weight of K and Mu determine the model's position between upper and
63
+ lower bound.
64
+
65
+ Parameters
66
+ ----------
67
+ k_min : np.ndarray
68
+ Mineral bulk modulus [Pa].
69
+ mu_min : np.ndarray
70
+ Mineral shear modulus [Pa].
71
+ rho_min : np.ndarray
72
+ Mineral bulk density [kg/m^3].
73
+ k_cem : np.ndarray
74
+ Sandstone cement bulk modulus [Pa].
75
+ mu_cem : np.ndarray
76
+ Sandstone cement shear modulus [Pa].
77
+ rho_cem : np.ndarray
78
+ Cement bulk density [kg/m^3].
79
+ k_fl : np.ndarray
80
+ Fluid bulk modulus [Pa].
81
+ rho_fl : np.ndarray
82
+ Fluid bulk density [kg/m^3].
83
+ phi : np.ndarray
84
+ Total porosity [fraction].
85
+ p_eff : np.ndarray
86
+ Effective pressure [Pa].
87
+ frac_cem : float
88
+ Upper bound cement volume fraction [fraction].
89
+ shear_red : float
90
+ Shear reduction factor for sandstone [fraction].
91
+ phi_c : float
92
+ Critical porosity [fraction].
93
+ n : float
94
+ Coordination number [unitless].
95
+ coord_num_func : str
96
+ Indication if coordination number should be calculated from porosity or kept constant.
97
+ weight_k : float
98
+ Weight between friable and cemented model for bulk modulus.
99
+ weight_mu : float
100
+ Weight between friable and cemented model for shear modulus.
101
+
102
+ Returns
103
+ -------
104
+ tuple
105
+ k, mu, rhob, vp, vs : (np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray).
106
+ vp :Saturated P-velocity [m/s] after fluid and pressure substitution,
107
+ vs : Saturated S-velocity [m/s] after fluid and pressure substitution,
108
+ rhob : Saturated density [kg/m3] after fluid and pressure substitution,
109
+ k : Saturated rock bulk modulus [Pa],
110
+ mu : Shear modulus [Pa].
111
+ """
112
+
113
+ k_zero, mu_zero = std_functions.hashin_shtrikman_walpole(
114
+ k_cem, mu_cem, k_min, mu_min, frac_cem, bound="lower"
115
+ )
116
+
117
+ # In this implementation of the patchy cement model the given cement fraction for the constant cement model defines
118
+ # the upper bound, and the effective pressure for the friable model defines the lower bound
119
+
120
+ k_fri, mu_fri = friable_model_dry(
121
+ k_zero, mu_zero, phi, p_eff, phi_c, coord_num_func, n, shear_red
122
+ )[0:2]
123
+
124
+ k_up, mu_up = constant_cement_model_dry(
125
+ k_min,
126
+ mu_min,
127
+ k_cem,
128
+ mu_cem,
129
+ phi,
130
+ frac_cem,
131
+ phi_c,
132
+ n,
133
+ shear_red,
134
+ extrapolate_to_max_phi=True,
135
+ )[0:2]
136
+
137
+ k_dry = k_fri + weight_k * (k_up - k_fri)
138
+ mu = mu_fri + weight_mu * (mu_up - mu_fri)
139
+
140
+ k = std_functions.gassmann(k_dry, phi, k_fl, k_zero)
141
+
142
+ weight_rho = 0.5 * (weight_k + weight_mu)
143
+ rhob = (
144
+ phi * rho_fl
145
+ + (1 - phi - frac_cem * weight_rho) * rho_min
146
+ + frac_cem * weight_rho * rho_cem
147
+ )
148
+
149
+ vp, vs, ai, vpvs = std_functions.velocity(k, mu, rhob)
150
+
151
+ return vp, vs, rhob, ai, vpvs
152
+
153
+
154
+ def patchy_cement_model_cem_frac(
155
+ k_min,
156
+ mu_min,
157
+ rho_min,
158
+ k_cem,
159
+ mu_cem,
160
+ rho_cem,
161
+ k_fl,
162
+ rho_fl,
163
+ phi,
164
+ p_eff,
165
+ frac_cem,
166
+ phi_c,
167
+ coord_num_func,
168
+ n,
169
+ shear_red,
170
+ ):
171
+ """
172
+ Patchy cement model for sands that are a combination of friable model and constant cement model. No fluid or
173
+ pressure substitution. In this implementation of the patchy cement model the given cement fraction for the constant
174
+ cement model defines the upper bound, and the effective pressure for the friable model defines the lower bound
175
+
176
+ Parameters
177
+ ----------
178
+ k_min : np.ndarray
179
+ Mineral bulk modulus [Pa].
180
+ mu_min : np.ndarray
181
+ Mineral shear modulus [Pa].
182
+ rho_min : np.ndarray
183
+ Mineral bulk density [kg/m^3].
184
+ k_cem : np.ndarray
185
+ Sandstone cement bulk modulus [Pa].
186
+ mu_cem : np.ndarray
187
+ Sandstone cement shear modulus [Pa].
188
+ rho_cem : np.ndarray
189
+ Cement bulk density [kg/m^3].
190
+ k_fl : np.ndarray
191
+ Fluid bulk modulus [Pa].
192
+ rho_fl : np.ndarray
193
+ Fluid bulk density [kg/m^3].
194
+ phi : np.ndarray
195
+ Total porosity [fraction].
196
+ p_eff : np.ndarray
197
+ Effective pressure [Pa].
198
+ frac_cem : float
199
+ Upper bound cement volume fraction [fraction].
200
+ shear_red : float
201
+ Shear reduction factor for sandstone [fraction].
202
+ phi_c : float
203
+ Critical porosity [fraction].
204
+ n : float
205
+ Coordination number [unitless].
206
+ coord_num_func : str
207
+ Indication if coordination number should be calculated from porosity or kept constant, either "ConstVal" or
208
+ "PoreBased" [default]
209
+
210
+ Returns
211
+ -------
212
+ tuple
213
+ vp, vs, rhob, ai, vpvs : (np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray).
214
+ vp :Saturated P-velocity [m/s] after fluid and pressure substitution,
215
+ vs : Saturated S-velocity [m/s] after fluid and pressure substitution,
216
+ rhob : Saturated density [kg/m3] after fluid and pressure substitution,
217
+ ai : Saturated rock acoustic impedance [kg/m3 * m/s] after fluid and pressure substitution,
218
+ vpvs : Saturated rock velocity ratio [ratio].
219
+ """
220
+
221
+ k_dry, mu, _ = patchy_cement_model_dry(
222
+ k_min,
223
+ mu_min,
224
+ rho_min,
225
+ k_cem,
226
+ mu_cem,
227
+ rho_cem,
228
+ phi,
229
+ p_eff,
230
+ frac_cem,
231
+ phi_c,
232
+ coord_num_func,
233
+ n,
234
+ shear_red,
235
+ )
236
+ k_zero, mu_zero = std_functions.hashin_shtrikman_walpole(
237
+ k_cem, mu_cem, k_min, mu_min, FRAC_CEM_UP, bound="lower"
238
+ )
239
+
240
+ k = std_functions.gassmann(k_dry, phi, k_fl, k_zero)
241
+
242
+ rhob = phi * rho_fl + (1 - phi - frac_cem) * rho_min + frac_cem * rho_cem
243
+
244
+ vp, vs, ai, vpvs = std_functions.velocity(k, mu, rhob)
245
+
246
+ return vp, vs, rhob, ai, vpvs
247
+
248
+
249
+ def patchy_cement_model_dry(
250
+ k_min,
251
+ mu_min,
252
+ rho_min,
253
+ k_cem,
254
+ mu_cem,
255
+ rho_cem,
256
+ phi,
257
+ p_eff,
258
+ frac_cem,
259
+ phi_c,
260
+ coord_num_func,
261
+ n,
262
+ shear_red,
263
+ ):
264
+ """
265
+ Patchy cement model for sands that are a combination of friable model and constant cement model. No fluid or
266
+ pressure substitution. In this implementation of the patchy cement model the given cement fraction for the constant
267
+ cement model defines the upper bound, and the effective pressure for the friable model defines the lower bound
268
+
269
+ Parameters
270
+ ----------
271
+ k_min : np.ndarray
272
+ Mineral bulk modulus [Pa].
273
+ mu_min : np.ndarray
274
+ Mineral shear modulus [Pa].
275
+ rho_min : np.ndarray
276
+ Mineral bulk density [kg/m^3].
277
+ k_cem : np.ndarray
278
+ Sandstone cement bulk modulus [Pa].
279
+ mu_cem : np.ndarray
280
+ Sandstone cement shear modulus [Pa].
281
+ rho_cem : np.ndarray
282
+ Cement bulk density [kg/m^3].
283
+ phi : np.ndarray
284
+ Total porosity [fraction].
285
+ p_eff : np.ndarray
286
+ Effective pressure [Pa].
287
+ frac_cem : float
288
+ Upper bound cement volume fraction [fraction].
289
+ shear_red : float
290
+ Shear reduction factor for sandstone [fraction].
291
+ phi_c : float
292
+ Critical porosity [fraction].
293
+ n : float
294
+ Coordination number [unitless].
295
+ coord_num_func : str
296
+ Indication if coordination number should be calculated from porosity or kept constant, either "ConstVal" or
297
+ "PoreBased" [default]
298
+
299
+ Returns
300
+ -------
301
+ tuple
302
+ k:dry, mu, rho_dry : (np.ndarray, np.ndarray, np.ndarray).
303
+ k_dry: dry rock bulk modulus [Pa],
304
+ mu : dry rock shear modulus [Pa],
305
+ rho_dry : dry rock density [kg/m3].,
306
+ """
307
+ # There are cases which suffer from a lack of consistency check at this stage,
308
+ # add dim_check_vector and filter input/output
309
+ phi, k_min, mu_min, rho_min, k_cem, mu_cem, rho_cem, p_eff = dim_check_vector(
310
+ (phi, k_min, mu_min, rho_min, k_cem, mu_cem, rho_cem, p_eff)
311
+ )
312
+ (idx, (phi, k_min, mu_min, rho_min, k_cem, mu_cem, rho_cem, p_eff)) = (
313
+ filter_input_log((phi, k_min, mu_min, rho_min, k_cem, mu_cem, rho_cem, p_eff))
314
+ )
315
+
316
+ k_zero, mu_zero = std_functions.hashin_shtrikman_walpole(
317
+ k_cem, mu_cem, k_min, mu_min, FRAC_CEM_UP, bound="lower"
318
+ )
319
+
320
+ k_low, mu_low = friable_model_dry(
321
+ k_zero,
322
+ mu_zero,
323
+ phi,
324
+ P_EFF_LOW * np.ones_like(phi),
325
+ phi_c,
326
+ coord_num_func,
327
+ n,
328
+ shear_red,
329
+ )[0:2]
330
+
331
+ k_fri, mu_fri = friable_model_dry(
332
+ k_zero, mu_zero, phi, p_eff, phi_c, coord_num_func, n, shear_red
333
+ )[0:2]
334
+
335
+ k_up, mu_up = constant_cement_model_dry(
336
+ k_min,
337
+ mu_min,
338
+ k_cem,
339
+ mu_cem,
340
+ phi,
341
+ FRAC_CEM_UP,
342
+ phi_c,
343
+ n,
344
+ shear_red,
345
+ extrapolate_to_max_phi=True,
346
+ )[0:2]
347
+
348
+ # Special case for the constant cement model that represents the mean of the data
349
+ k_cc, mu_cc = constant_cement_model_pcm(
350
+ k_min,
351
+ mu_min,
352
+ k_cem,
353
+ mu_cem,
354
+ k_zero,
355
+ mu_zero,
356
+ phi,
357
+ frac_cem,
358
+ phi_c,
359
+ n,
360
+ shear_red,
361
+ )[0:2]
362
+
363
+ idwk = k_up == k_low
364
+ idwmu = mu_up == mu_low
365
+
366
+ weight_k = np.ones(k_zero.shape)
367
+ weight_mu = np.ones(mu_zero.shape)
368
+
369
+ weight_k[~idwk] = (k_cc[~idwk] - k_low[~idwk]) / (k_up[~idwk] - k_low[~idwk])
370
+ weight_mu[~idwmu] = (mu_cc[~idwmu] - mu_low[~idwmu]) / (
371
+ mu_up[~idwmu] - mu_low[~idwmu]
372
+ )
373
+
374
+ weight_mu = np.clip(weight_mu, 0.0, 1.0)
375
+ weight_k = np.clip(weight_k, 0.0, 1.0)
376
+
377
+ k_dry = k_fri + weight_k * (k_up - k_fri)
378
+ mu = mu_fri + weight_mu * (mu_up - mu_fri)
379
+
380
+ rho_dry = (1 - phi - frac_cem) * rho_min + frac_cem * rho_cem
381
+
382
+ k_dry, mu, rho_dry = filter_output(idx, (k_dry, mu, rho_dry))
383
+
384
+ return k_dry, mu, rho_dry
@@ -0,0 +1,254 @@
1
+ import numpy as np
2
+
3
+ from rock_physics_open.equinor_utilities import gen_utilities
4
+ from rock_physics_open.equinor_utilities.optimisation_utilities import (
5
+ gen_opt_routine,
6
+ save_opt_params,
7
+ )
8
+
9
+ from .curvefit_sandstone_models import (
10
+ curvefit_patchy_cement,
11
+ patchy_cement_model_weight,
12
+ )
13
+
14
+
15
+ def patchy_cement_model_optimisation(
16
+ k_min: np.ndarray,
17
+ mu_min: np.ndarray,
18
+ rho_min: np.ndarray,
19
+ k_cem: np.ndarray,
20
+ mu_cem: np.ndarray,
21
+ rho_cem: np.ndarray,
22
+ k_fl: np.ndarray,
23
+ rho_fl: np.ndarray,
24
+ por: np.ndarray,
25
+ p_eff: np.ndarray,
26
+ vp: np.ndarray,
27
+ vs: np.ndarray,
28
+ rhob: np.ndarray,
29
+ phi_c,
30
+ file_out_str: str = "patchy_cement_optimal_params.pkl",
31
+ display_results: bool = False,
32
+ well_name: str = "Unknown well",
33
+ opt_params_only=False,
34
+ ):
35
+ """Patchy cement model with optimisation for a selection of parameters.
36
+
37
+ Parameters
38
+ ----------
39
+ k_min :
40
+ Cement bulk modulus [Pa].
41
+ mu_min :
42
+ Cement shear modulus [Pa].
43
+ rho_min :
44
+ Cement density [kg/m^3].
45
+ k_cem :
46
+ Cement bulk modulus [Pa].
47
+ mu_cem :
48
+ Cement shear modulus [Pa].
49
+ rho_cem :
50
+ Cement density [kg/m^3].
51
+ k_fl :
52
+ Fluid bulk modulus [Pa].
53
+ rho_fl :
54
+ Fluid density [kg/m^3].
55
+ por :
56
+ Inclusion porosity [ratio].
57
+ vp :
58
+ Compressional velocity log [m/s].
59
+ vs :
60
+ Shear velocity log [m/s].
61
+ rhob :
62
+ Bulk density log [kg/m^3].
63
+ p_eff :
64
+ Effective pressure log [Pa].
65
+ file_out_str :
66
+ Output file name (string) to store optimal parameters (pickle format).
67
+ phi_c : float
68
+ Critical porosity [fraction]
69
+ display_results :
70
+ Display optimal parameters in a window after run.
71
+ well_name : str
72
+ Name of well to be displayed in info box title.
73
+ opt_params_only : bool
74
+ return parameters from optimisation only
75
+ Returns
76
+ -------
77
+ tuple
78
+ vp_mod, vs_mod, rho_mod, ai_mod, vpvs_mod - modelled logs,
79
+ vp_res, vs_res, rho_res - residual logs.
80
+ """
81
+
82
+ # Skip hardcoded Vp/Vs ratio
83
+ def_vpvs = np.mean(vp / vs)
84
+ # Set weight to vs to give vp and vs similar influence on optimisation
85
+ y_data = np.stack([vp, vs * def_vpvs], axis=1)
86
+ # Optimisation function for selected parameters
87
+ opt_fun = curvefit_patchy_cement
88
+ # expand single value parameters to match logs length
89
+ por, phi_c, def_vpvs = gen_utilities.dim_check_vector((por, phi_c, def_vpvs))
90
+ x_data = np.stack(
91
+ (
92
+ k_min,
93
+ mu_min,
94
+ rho_min,
95
+ k_cem,
96
+ mu_cem,
97
+ rho_cem,
98
+ k_fl,
99
+ rho_fl,
100
+ por,
101
+ p_eff,
102
+ def_vpvs,
103
+ phi_c,
104
+ ),
105
+ axis=1,
106
+ )
107
+
108
+ # Params: weight_k, weight_mu, shear_red, frac_cem
109
+ lower_bound = np.array(
110
+ [
111
+ 0.0, # weight_k
112
+ 0.0, # weight_mu
113
+ 0.0, # shear_red
114
+ 0.01, # frac_cem
115
+ ],
116
+ dtype=float,
117
+ )
118
+ upper_bound = np.array(
119
+ [
120
+ 1.0, # weight_k
121
+ 1.0, # weight_mu
122
+ 1.0, # shear_red
123
+ 0.1, # frac_cem
124
+ ],
125
+ dtype=float,
126
+ )
127
+ x0 = (upper_bound + lower_bound) / 2.0
128
+ # Optimisation step without fluid substitution
129
+ vel_mod, vel_res, opt_params = gen_opt_routine(
130
+ opt_fun, x_data, y_data, x0, lower_bound, upper_bound
131
+ )
132
+
133
+ # Reshape outputs and remove weight from vs
134
+ vp_mod, vs_mod = [arr.flatten() for arr in np.split(vel_mod, 2, axis=1)]
135
+ vp_res, vs_res = [arr.flatten() for arr in np.split(vel_res, 2, axis=1)]
136
+ vs_mod = vs_mod / def_vpvs
137
+ vs_res = vs_res / def_vpvs
138
+ vpvs_mod = vp_mod / vs_mod
139
+ # Calculate the modelled density
140
+ # rho_cem??
141
+ rhob_mod = rho_min * (1.0 - por) + por * rho_fl
142
+ ai_mod = vp_mod * rhob_mod
143
+ rhob_res = rhob_mod - rhob
144
+ # Save the optimal parameters
145
+ save_opt_params("pat_cem", opt_params, file_out_str, well_name=well_name)
146
+ if display_results:
147
+ from rock_physics_open.t_matrix_models import opt_param_to_ascii
148
+
149
+ opt_param_to_ascii(file_out_str, well_name=well_name)
150
+
151
+ if opt_params_only:
152
+ return opt_params
153
+ return vp_mod, vs_mod, rhob_mod, ai_mod, vpvs_mod, vp_res, vs_res, rhob_res
154
+
155
+
156
+ def patchy_cement_model_optimisation_multiwell(
157
+ k_min,
158
+ mu_min,
159
+ rho_min,
160
+ k_cem,
161
+ mu_cem,
162
+ rho_cem,
163
+ k_fl,
164
+ rho_fl,
165
+ por,
166
+ p_eff,
167
+ vp,
168
+ vs,
169
+ rhob,
170
+ phi_c,
171
+ file_out_str: str = "pat_cem.pkl",
172
+ display_results: bool = False,
173
+ well_name: str = "Unknown well",
174
+ ):
175
+ # First: perform a calibration with all data, return optimal parameters only. Concatenate all list of arrays to
176
+ # make a single set of input arrays
177
+ k_min_all = np.concatenate(k_min, axis=0)
178
+ mu_min_all = np.concatenate(mu_min, axis=0)
179
+ rho_min_all = np.concatenate(rho_min, axis=0)
180
+ k_cem_all = np.concatenate(k_cem, axis=0)
181
+ mu_cem_all = np.concatenate(mu_cem, axis=0)
182
+ rho_cem_all = np.concatenate(rho_cem, axis=0)
183
+ k_fl_all = np.concatenate(k_fl, axis=0)
184
+ rho_fl_all = np.concatenate(rho_fl, axis=0)
185
+ por_all = np.concatenate(por, axis=0)
186
+ p_eff_all = np.concatenate(p_eff, axis=0)
187
+ vp_all = np.concatenate(vp, axis=0)
188
+ vs_all = np.concatenate(vs, axis=0)
189
+ rhob_all = np.concatenate(rhob, axis=0)
190
+
191
+ opt_param = patchy_cement_model_optimisation(
192
+ k_min_all,
193
+ mu_min_all,
194
+ rho_min_all,
195
+ k_cem_all,
196
+ mu_cem_all,
197
+ rho_cem_all,
198
+ k_fl_all,
199
+ rho_fl_all,
200
+ por_all,
201
+ p_eff_all,
202
+ vp_all,
203
+ vs_all,
204
+ rhob_all,
205
+ phi_c,
206
+ file_out_str=file_out_str,
207
+ display_results=display_results,
208
+ well_name=well_name,
209
+ opt_params_only=True,
210
+ )
211
+
212
+ # Next: run patchy cement model for all wells using the optimal parameters
213
+ weight_k = opt_param[0]
214
+ weight_mu = opt_param[1]
215
+ shear_red = opt_param[2]
216
+ frac_cem = opt_param[3]
217
+ vp_mod = []
218
+ vs_mod = []
219
+ rhob_mod = []
220
+ ai_mod = []
221
+ vpvs_mod = []
222
+ vp_res = []
223
+ vs_res = []
224
+ rhob_res = []
225
+ for i in range(len(k_min)):
226
+ vp_tmp, vs_tmp, rhob_tmp = patchy_cement_model_weight(
227
+ k_min[i],
228
+ mu_min[i],
229
+ rho_min[i],
230
+ k_cem[i],
231
+ mu_cem[i],
232
+ rho_cem[i],
233
+ k_fl[i],
234
+ rho_fl[i],
235
+ por[i],
236
+ p_eff[i],
237
+ frac_cem,
238
+ phi_c,
239
+ "por_based",
240
+ 9,
241
+ shear_red,
242
+ weight_k,
243
+ weight_mu,
244
+ )[0:3]
245
+ vp_mod.append(vp_tmp)
246
+ vs_mod.append(vs_tmp)
247
+ rhob_mod.append(rhob_tmp)
248
+ ai_mod.append(vp_tmp * rhob_tmp)
249
+ vpvs_mod.append(vp_tmp / vs_tmp)
250
+ vp_res.append(vp_tmp - vp[i])
251
+ vs_res.append(vs_tmp - vs[i])
252
+ rhob_res.append(rhob_tmp - rhob[i])
253
+
254
+ return vp_mod, vs_mod, rhob_mod, ai_mod, vpvs_mod, vp_res, vs_res, rhob_res