rock-physics-open 0.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.

Files changed (142) 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 +162 -0
  4. rock_physics_open/equinor_utilities/classification_functions/__init__.py +17 -0
  5. rock_physics_open/equinor_utilities/classification_functions/class_stats.py +58 -0
  6. rock_physics_open/equinor_utilities/classification_functions/lin_class.py +47 -0
  7. rock_physics_open/equinor_utilities/classification_functions/mahal_class.py +56 -0
  8. rock_physics_open/equinor_utilities/classification_functions/norm_class.py +65 -0
  9. rock_physics_open/equinor_utilities/classification_functions/poly_class.py +40 -0
  10. rock_physics_open/equinor_utilities/classification_functions/post_prob.py +26 -0
  11. rock_physics_open/equinor_utilities/classification_functions/two_step_classification.py +46 -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 +33 -0
  15. rock_physics_open/equinor_utilities/gen_utilities/dim_check_vector.py +83 -0
  16. rock_physics_open/equinor_utilities/gen_utilities/filter_input.py +126 -0
  17. rock_physics_open/equinor_utilities/gen_utilities/filter_output.py +78 -0
  18. rock_physics_open/equinor_utilities/machine_learning_utilities/__init__.py +14 -0
  19. rock_physics_open/equinor_utilities/machine_learning_utilities/dummy_vars.py +42 -0
  20. rock_physics_open/equinor_utilities/machine_learning_utilities/exponential_model.py +119 -0
  21. rock_physics_open/equinor_utilities/machine_learning_utilities/import_ml_models.py +61 -0
  22. rock_physics_open/equinor_utilities/machine_learning_utilities/run_regression.py +151 -0
  23. rock_physics_open/equinor_utilities/machine_learning_utilities/sigmoidal_model.py +188 -0
  24. rock_physics_open/equinor_utilities/snapshot_test_utilities/__init__.py +10 -0
  25. rock_physics_open/equinor_utilities/snapshot_test_utilities/compare_snapshots.py +145 -0
  26. rock_physics_open/equinor_utilities/snapshot_test_utilities/snapshots.py +54 -0
  27. rock_physics_open/equinor_utilities/std_functions/__init__.py +43 -0
  28. rock_physics_open/equinor_utilities/std_functions/backus_ave.py +53 -0
  29. rock_physics_open/equinor_utilities/std_functions/dvorkin_nur.py +69 -0
  30. rock_physics_open/equinor_utilities/std_functions/gassmann.py +140 -0
  31. rock_physics_open/equinor_utilities/std_functions/hashin_shtrikman.py +195 -0
  32. rock_physics_open/equinor_utilities/std_functions/hertz_mindlin.py +43 -0
  33. rock_physics_open/equinor_utilities/std_functions/moduli_velocity.py +51 -0
  34. rock_physics_open/equinor_utilities/std_functions/reflection_eq.py +98 -0
  35. rock_physics_open/equinor_utilities/std_functions/rho.py +59 -0
  36. rock_physics_open/equinor_utilities/std_functions/voigt_reuss_hill.py +128 -0
  37. rock_physics_open/equinor_utilities/std_functions/walton.py +38 -0
  38. rock_physics_open/equinor_utilities/std_functions/wood_brie.py +77 -0
  39. rock_physics_open/equinor_utilities/various_utilities/Equinor_logo.gif +0 -0
  40. rock_physics_open/equinor_utilities/various_utilities/Equinor_logo.ico +0 -0
  41. rock_physics_open/equinor_utilities/various_utilities/__init__.py +24 -0
  42. rock_physics_open/equinor_utilities/various_utilities/display_result_statistics.py +83 -0
  43. rock_physics_open/equinor_utilities/various_utilities/gassmann_dry_mod.py +37 -0
  44. rock_physics_open/equinor_utilities/various_utilities/gassmann_mod.py +37 -0
  45. rock_physics_open/equinor_utilities/various_utilities/gassmann_sub_mod.py +53 -0
  46. rock_physics_open/equinor_utilities/various_utilities/hs_average.py +40 -0
  47. rock_physics_open/equinor_utilities/various_utilities/pressure.py +88 -0
  48. rock_physics_open/equinor_utilities/various_utilities/reflectivity.py +85 -0
  49. rock_physics_open/equinor_utilities/various_utilities/timeshift.py +91 -0
  50. rock_physics_open/equinor_utilities/various_utilities/vp_vs_rho_set_statistics.py +154 -0
  51. rock_physics_open/equinor_utilities/various_utilities/vrh_3_min.py +61 -0
  52. rock_physics_open/fluid_models/__init__.py +9 -0
  53. rock_physics_open/fluid_models/brine_model/__init__.py +5 -0
  54. rock_physics_open/fluid_models/brine_model/brine_properties.py +143 -0
  55. rock_physics_open/fluid_models/gas_model/__init__.py +5 -0
  56. rock_physics_open/fluid_models/gas_model/gas_properties.py +277 -0
  57. rock_physics_open/fluid_models/oil_model/__init__.py +5 -0
  58. rock_physics_open/fluid_models/oil_model/dead_oil_density.py +60 -0
  59. rock_physics_open/fluid_models/oil_model/dead_oil_velocity.py +28 -0
  60. rock_physics_open/fluid_models/oil_model/live_oil_density.py +79 -0
  61. rock_physics_open/fluid_models/oil_model/live_oil_velocity.py +24 -0
  62. rock_physics_open/fluid_models/oil_model/oil_bubble_point.py +69 -0
  63. rock_physics_open/fluid_models/oil_model/oil_properties.py +114 -0
  64. rock_physics_open/sandstone_models/__init__.py +57 -0
  65. rock_physics_open/sandstone_models/cemented_shalysand_sandyshale_models.py +304 -0
  66. rock_physics_open/sandstone_models/constant_cement_models.py +204 -0
  67. rock_physics_open/sandstone_models/constant_cement_optimisation.py +122 -0
  68. rock_physics_open/sandstone_models/contact_cement_model.py +138 -0
  69. rock_physics_open/sandstone_models/curvefit_sandstone_models.py +143 -0
  70. rock_physics_open/sandstone_models/friable_models.py +178 -0
  71. rock_physics_open/sandstone_models/friable_optimisation.py +112 -0
  72. rock_physics_open/sandstone_models/friable_shalysand_sandyshale_models.py +235 -0
  73. rock_physics_open/sandstone_models/patchy_cement_fluid_substitution_model.py +477 -0
  74. rock_physics_open/sandstone_models/patchy_cement_model.py +286 -0
  75. rock_physics_open/sandstone_models/patchy_cement_optimisation.py +251 -0
  76. rock_physics_open/sandstone_models/unresolved_cemented_sandshale_models.py +134 -0
  77. rock_physics_open/sandstone_models/unresolved_friable_sandshale_models.py +126 -0
  78. rock_physics_open/shale_models/__init__.py +19 -0
  79. rock_physics_open/shale_models/dem.py +174 -0
  80. rock_physics_open/shale_models/dem_dual_por.py +61 -0
  81. rock_physics_open/shale_models/kus_tok.py +59 -0
  82. rock_physics_open/shale_models/multi_sca.py +133 -0
  83. rock_physics_open/shale_models/pq.py +102 -0
  84. rock_physics_open/shale_models/sca.py +90 -0
  85. rock_physics_open/shale_models/shale4_mineral.py +147 -0
  86. rock_physics_open/shale_models/shale4_mineral_dem_overlay.py +92 -0
  87. rock_physics_open/span_wagner/__init__.py +5 -0
  88. rock_physics_open/span_wagner/co2_properties.py +438 -0
  89. rock_physics_open/span_wagner/coefficients.py +165 -0
  90. rock_physics_open/span_wagner/equations.py +104 -0
  91. rock_physics_open/span_wagner/tables/__init__.py +0 -0
  92. rock_physics_open/span_wagner/tables/carbon_dioxide_density.npz +0 -0
  93. rock_physics_open/span_wagner/tables/lookup_table.py +33 -0
  94. rock_physics_open/t_matrix_models/Equinor_logo.ico +0 -0
  95. rock_physics_open/t_matrix_models/__init__.py +45 -0
  96. rock_physics_open/t_matrix_models/carbonate_pressure_substitution.py +124 -0
  97. rock_physics_open/t_matrix_models/curvefit_t_matrix_exp.py +124 -0
  98. rock_physics_open/t_matrix_models/curvefit_t_matrix_min.py +86 -0
  99. rock_physics_open/t_matrix_models/opt_subst_utilities.py +415 -0
  100. rock_physics_open/t_matrix_models/parse_t_matrix_inputs.py +297 -0
  101. rock_physics_open/t_matrix_models/run_t_matrix.py +243 -0
  102. rock_physics_open/t_matrix_models/t_matrix_C.py +210 -0
  103. rock_physics_open/t_matrix_models/t_matrix_opt_fluid_sub_exp.py +137 -0
  104. rock_physics_open/t_matrix_models/t_matrix_opt_fluid_sub_petec.py +163 -0
  105. rock_physics_open/t_matrix_models/t_matrix_opt_forward_model_exp.py +72 -0
  106. rock_physics_open/t_matrix_models/t_matrix_opt_forward_model_min.py +86 -0
  107. rock_physics_open/t_matrix_models/t_matrix_parameter_optimisation_exp.py +172 -0
  108. rock_physics_open/t_matrix_models/t_matrix_parameter_optimisation_min.py +159 -0
  109. rock_physics_open/t_matrix_models/t_matrix_vector/__init__.py +12 -0
  110. rock_physics_open/t_matrix_models/t_matrix_vector/array_functions.py +75 -0
  111. rock_physics_open/t_matrix_models/t_matrix_vector/calc_c_eff.py +163 -0
  112. rock_physics_open/t_matrix_models/t_matrix_vector/calc_isolated.py +95 -0
  113. rock_physics_open/t_matrix_models/t_matrix_vector/calc_kd.py +40 -0
  114. rock_physics_open/t_matrix_models/t_matrix_vector/calc_kd_eff.py +116 -0
  115. rock_physics_open/t_matrix_models/t_matrix_vector/calc_kd_uuv.py +18 -0
  116. rock_physics_open/t_matrix_models/t_matrix_vector/calc_pressure.py +140 -0
  117. rock_physics_open/t_matrix_models/t_matrix_vector/calc_t.py +71 -0
  118. rock_physics_open/t_matrix_models/t_matrix_vector/calc_td.py +42 -0
  119. rock_physics_open/t_matrix_models/t_matrix_vector/calc_theta.py +43 -0
  120. rock_physics_open/t_matrix_models/t_matrix_vector/calc_x.py +33 -0
  121. rock_physics_open/t_matrix_models/t_matrix_vector/calc_z.py +50 -0
  122. rock_physics_open/t_matrix_models/t_matrix_vector/check_and_tile.py +43 -0
  123. rock_physics_open/t_matrix_models/t_matrix_vector/g_tensor.py +140 -0
  124. rock_physics_open/t_matrix_models/t_matrix_vector/iso_av.py +60 -0
  125. rock_physics_open/t_matrix_models/t_matrix_vector/iso_ave_all.py +55 -0
  126. rock_physics_open/t_matrix_models/t_matrix_vector/pressure_input.py +44 -0
  127. rock_physics_open/t_matrix_models/t_matrix_vector/t_matrix_vec.py +278 -0
  128. rock_physics_open/t_matrix_models/t_matrix_vector/velocity_vti_angles.py +81 -0
  129. rock_physics_open/t_matrix_models/tmatrix_python.dll +0 -0
  130. rock_physics_open/t_matrix_models/tmatrix_python.so +0 -0
  131. rock_physics_open/ternary_plots/__init__.py +3 -0
  132. rock_physics_open/ternary_plots/gen_ternary_plot.py +73 -0
  133. rock_physics_open/ternary_plots/shale_prop_ternary.py +337 -0
  134. rock_physics_open/ternary_plots/ternary_patches.py +277 -0
  135. rock_physics_open/ternary_plots/ternary_plot_utilities.py +197 -0
  136. rock_physics_open/ternary_plots/unconventionals_ternary.py +75 -0
  137. rock_physics_open/version.py +21 -0
  138. rock_physics_open-0.0.dist-info/METADATA +92 -0
  139. rock_physics_open-0.0.dist-info/RECORD +142 -0
  140. rock_physics_open-0.0.dist-info/WHEEL +5 -0
  141. rock_physics_open-0.0.dist-info/licenses/LICENSE +165 -0
  142. rock_physics_open-0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,243 @@
1
+ import numpy as np
2
+
3
+ from .parse_t_matrix_inputs import parse_t_matrix_inputs
4
+ from .t_matrix_vector import calc_pressure_vec, pressure_input_utility
5
+
6
+
7
+ def run_t_matrix(
8
+ k_min,
9
+ mu_min,
10
+ rho_min,
11
+ k_fl,
12
+ rho_fl,
13
+ phi,
14
+ perm,
15
+ visco,
16
+ alpha,
17
+ v,
18
+ tau,
19
+ frequency,
20
+ angle,
21
+ frac_inc_con,
22
+ frac_inc_ani,
23
+ pressure=None,
24
+ scenario=None,
25
+ fcn=None,
26
+ ):
27
+ """Function to run T-Matrix in different flavours, with or without pressure steps included.
28
+ A frontend to running T-Matrix model, including testing of all input parameters in the parse_t_matrix_inputs.
29
+
30
+ Parameters
31
+ ----------
32
+ k_min : np.ndarray
33
+ N length numpy array, mineral bulk modulus [Pa].
34
+ mu_min : np.ndarray
35
+ N length numpy array, mineral shear modulus [Pa].
36
+ rho_min : np.ndarray
37
+ N length numpy array, mineral density [kg/m^3].
38
+ k_fl : np.ndarray
39
+ N length numpy array, fluid bulk modulus [Pa].
40
+ rho_fl : np.ndarray
41
+ N length numpy array, mineral density [kg/m^3].
42
+ phi : np.ndarray or float
43
+ N length numpy array, total porosity [ratio].
44
+ perm : np.ndarray or float
45
+ Float or N length numpy array, permeability [mD].
46
+ visco : np.ndarray or float
47
+ Float or N length numpy array, fluid viscosity [cP].
48
+ alpha : np.ndarray
49
+ M or NxM length numpy array, inclusion aspect ratio [ratio].
50
+ v : np.ndarray
51
+ M or NxM length numpy array, inclusion concentration [ratio].
52
+ tau : np.ndarray
53
+ M length numpy array, relaxation time [s].
54
+ frequency : float
55
+ Single float, signal frequency [Hz].
56
+ angle : float
57
+ Single float, angle of symmetry plane [degree].
58
+ frac_inc_con : np.ndarray or float
59
+ Single float or N length numpy array, fraction of connected inclusions [ratio].
60
+ frac_inc_ani : np.ndarray or float
61
+ Single float or N length numpy array, fraction of anisotropic inclusions [ratio].
62
+ pressure : [type], optional
63
+ > 1 value list or numpy array in ascending order, effective pressure [Pa], by default None.
64
+ scenario : int, optional
65
+ Pre-set scenarios for alpha, v and tau, by default None.
66
+ fcn : callable, optional
67
+ Function with which to run the T-Matrix model, by default None.
68
+
69
+ Returns
70
+ -------
71
+ tuple
72
+ vp, vsv, vsh, rho: (np.ndarray, np.ndarray, np.ndarray, np.ndarray).
73
+ """
74
+ # Check all input parameters and make sure that they are on expected format and shape
75
+ (
76
+ k_min,
77
+ mu_min,
78
+ rho_min,
79
+ k_fl,
80
+ rho_fl,
81
+ phi,
82
+ perm,
83
+ visco,
84
+ alpha,
85
+ v,
86
+ tau,
87
+ frequency,
88
+ angle,
89
+ frac_inc_con,
90
+ frac_inc_ani,
91
+ pressure,
92
+ fcn,
93
+ ctrl_connected,
94
+ ctrl_anisotropy,
95
+ ) = parse_t_matrix_inputs(
96
+ k_min,
97
+ mu_min,
98
+ rho_min,
99
+ k_fl,
100
+ rho_fl,
101
+ phi,
102
+ perm,
103
+ visco,
104
+ alpha,
105
+ v,
106
+ tau,
107
+ frequency,
108
+ angle,
109
+ frac_inc_con,
110
+ frac_inc_ani,
111
+ pressure,
112
+ scenario,
113
+ fcn,
114
+ )
115
+
116
+ # If there are no pressure steps to consider the whole task can be assigned to the T-Matrix function
117
+ if pressure is None:
118
+ vp, vsv, vsh, rho = fcn(
119
+ k_min,
120
+ mu_min,
121
+ rho_min,
122
+ k_fl,
123
+ rho_fl,
124
+ phi,
125
+ perm,
126
+ visco,
127
+ alpha,
128
+ v,
129
+ tau,
130
+ frequency,
131
+ angle,
132
+ frac_inc_con,
133
+ frac_inc_ani,
134
+ )
135
+ return vp, vsv, vsh, rho
136
+
137
+ # Pressure steps is mimicking depletion, and inclusion shape parameters can be changed
138
+ # In Remy's implementation it is generally possible to have different alpha's and v's for connected and
139
+ # isolated part, but this is not included directly in Calculo's implementation in C++. For the time being,
140
+ # this possibility is not included here
141
+
142
+ log_length = phi.shape[0]
143
+ pressure_steps = pressure.shape[0]
144
+ # It is the change from initial pressure (first value in the pressure vector) that is input to the function
145
+ # that estimates matrix pressure sensitivity
146
+ delta_pres = np.diff(pressure)
147
+
148
+ # Predefine output vectors
149
+ vp = np.zeros((log_length, pressure_steps))
150
+ vs_v = np.zeros((log_length, pressure_steps))
151
+ vs_h = np.zeros((log_length, pressure_steps))
152
+ rho_b_est = np.zeros((log_length, pressure_steps))
153
+
154
+ # Matrix properties needed as input to calc_pressure_vec
155
+ c0, s0, gd = pressure_input_utility(k_min, mu_min, log_length)
156
+
157
+ for i in range(pressure_steps):
158
+ vp[:, i], vs_v[:, i], vs_h[:, i], rho_b_est[:, i] = fcn(
159
+ k_min,
160
+ mu_min,
161
+ rho_min,
162
+ k_fl,
163
+ rho_fl,
164
+ phi,
165
+ perm,
166
+ visco,
167
+ alpha,
168
+ v,
169
+ tau,
170
+ frequency,
171
+ angle,
172
+ frac_inc_con,
173
+ frac_inc_ani,
174
+ )
175
+
176
+ if i != pressure_steps - 1:
177
+ # Need to check for extreme cases with all connected or all isolated
178
+ if ctrl_connected != 0:
179
+ v_con = v * (phi * frac_inc_con).reshape(log_length, 1)
180
+ else:
181
+ v_con = np.zeros(v.shape)
182
+ if ctrl_connected != 2:
183
+ v_iso = v * (phi * (1 - frac_inc_con)).reshape(log_length, 1)
184
+ else:
185
+ v_iso = np.zeros(v.shape)
186
+ alpha_con, v_con, alpha_iso, v_iso, tau, gamma = calc_pressure_vec(
187
+ alpha,
188
+ alpha,
189
+ v_con,
190
+ v_iso,
191
+ c0,
192
+ s0,
193
+ gd,
194
+ delta_pres[i],
195
+ tau,
196
+ np.zeros_like(tau),
197
+ k_fl,
198
+ ctrl_connected,
199
+ frac_inc_ani,
200
+ )
201
+
202
+ # Post-process outputs from calc_pressure_vec to match required inputs to the T-Matrix function
203
+ # frac_inc_con, v and alpha are inputs that need to be updated
204
+ # As mentioned: assume that there is no distinction between alpha_con and alpha_iso, that could only
205
+ # happen if they differed from the start
206
+
207
+ # v_con, alpha_con or v_iso, alpha_iso can be returned as None from calc_pressure_vec
208
+ if ctrl_connected == 0:
209
+ v_con = np.zeros_like(v_iso)
210
+ alpha = alpha_iso
211
+ elif ctrl_connected == 2:
212
+ alpha = alpha_con
213
+ v_iso = np.zeros_like(v_con)
214
+ else:
215
+ alpha = alpha_con
216
+ # Don't divide by zero
217
+ idx_zero = phi == 0
218
+ if np.any(idx_zero):
219
+ v = v_con + v_iso
220
+ no_zero = np.sum(idx_zero)
221
+ v[~idx_zero, :] = v[~idx_zero, :] / phi[~idx_zero].reshape(
222
+ log_length - no_zero, 1
223
+ )
224
+ else:
225
+ v = (v_con + v_iso) / phi.reshape(log_length, 1)
226
+
227
+ # frac_inc_con is close to a single value, only numerical difference in the range 10^-16, can safely
228
+ # take the average over the alphas to make it match expected input shape
229
+ frac_inc_con = np.mean(v_con / (v_con + v_iso), axis=1)
230
+
231
+ # Return variables for each pressure step
232
+ vp_out = []
233
+ vs_v_out = []
234
+ vs_h_out = []
235
+
236
+ # Only one rho is needed - no change
237
+ rho_out = rho_b_est[:, 0]
238
+
239
+ for i in range(pressure_steps):
240
+ vp_out.append(vp[:, i])
241
+ vs_v_out.append(vs_v[:, i])
242
+ vs_h_out.append(vs_h[:, i])
243
+ return vp_out + vs_v_out + vs_h_out + [rho_out]
@@ -0,0 +1,210 @@
1
+ import inspect
2
+ import sys
3
+ from ctypes import c_double, c_int
4
+
5
+ import numpy as np
6
+ import numpy.ctypeslib as npct
7
+ from tmatrix._tmatrix import tmatrix_porosity_noscenario
8
+
9
+ from rock_physics_open.equinor_utilities import gen_utilities
10
+
11
+ # Definition of input types for the T Matrix function
12
+ # this will affect the tests on the input data, dim_check_vector is therefore set up to
13
+ # return data on the specified format
14
+ array_1d_double = npct.ndpointer(dtype=c_double, ndim=1, flags="CONTIGUOUS")
15
+ array_1d_int = npct.ndpointer(dtype=c_int, ndim=1, flags="CONTIGUOUS")
16
+ array_2d_double = npct.ndpointer(dtype=c_double, ndim=2, flags="CONTIGUOUS")
17
+
18
+
19
+ # noinspection PyUnusedLocal
20
+ def T_matrix_porosity_C_scenario(*args):
21
+ """Deprecated."""
22
+ raise DeprecationWarning(
23
+ "{}: deprecated function, all T-Matrix runs should be parsed through run_t_matrix".format(
24
+ inspect.stack()[0][3]
25
+ )
26
+ )
27
+
28
+
29
+ def t_matrix_porosity_c_alpha_v(
30
+ k_min,
31
+ mu_min,
32
+ rho_min,
33
+ k_fl,
34
+ rho_fl,
35
+ phi,
36
+ perm,
37
+ visco,
38
+ alpha,
39
+ v,
40
+ tau,
41
+ frequency,
42
+ angle,
43
+ frac_inc_con,
44
+ frac_inc_ani,
45
+ ):
46
+ """This function can be called directly from top level, but the present recommendation is to go though the run_t_matrix
47
+ in order to check inputs. It is used directly from the optimisation functions for efficiency. This gives direct
48
+ access to the C++ compiled library for T-Matrix.
49
+
50
+ Parameters
51
+ ----------
52
+ k_min : np.ndarray
53
+ N length array, mineral bulk modulus [Pa]
54
+ mu_min: np.ndarray
55
+ N length array, mineral shear modulus [Pa]
56
+ rho_min: np.ndarray
57
+ N length array, mineral density [kg/m^3]
58
+ k_fl:np.ndarray
59
+ N length array, fluid bulk modulus [Pa]
60
+ rho_fl: np.ndarray
61
+ N length array, fluid density [kg/m^3]
62
+ phi:np.ndaray
63
+ N length array, porosity
64
+ perm: np.ndarray
65
+ N length array, permeability [mD]
66
+ visco: np.ndarray
67
+ N length array, viscosity [cP]
68
+ alpha: np.ndarray or float
69
+ aspect ratios for inclusions
70
+ v: np. ndarray or float
71
+ fraction of porosity with given aspect ratio
72
+ tau: float
73
+ relaxation time
74
+ frequency: float
75
+ float single value, signal frequency [Hz]
76
+ angle: float
77
+ float single value, angle of symmetry plane (0 = HTI, 90 = VTI medium) [deg]
78
+ frac_inc_con: np.ndarray or float
79
+ float single value or array, fraction of inclusions that are connected
80
+ frac_inc_ani: np.ndarray or float
81
+ float single value or array, fraction of inclusions that are anisotropic
82
+
83
+ Returns
84
+ -------
85
+ tuple
86
+ Tuple of np.ndarrays. Vp: Vertical P-wave velocity [m/s], Vsv: Vertical polarity S-wave velocity [m/s],
87
+ Vsh: Horizontal polarity S-wave velocity [m/s], Rhob [kg/m^3].
88
+ """
89
+
90
+ # ToDo: tau input is not used in the Calculo implementation of T-Matrix
91
+ del tau
92
+
93
+ # Make sure that what can be vectors are vectors of the same length.
94
+ # frac_inc_con and frac_inc_ani can either be the same length as the log, be constants or have the same length as
95
+ # alpha and v
96
+
97
+ # frac_inc_con and frac_inc_ani must be of the same length
98
+ frac_inc_con, frac_inc_ani = gen_utilities.dim_check_vector(
99
+ (frac_inc_con, frac_inc_ani)
100
+ )
101
+
102
+ # test for frac_inc_con and frac_inc_ani being of the same length as the logs
103
+ log_length = len(phi)
104
+ if frac_inc_con.shape[0] == log_length:
105
+ (
106
+ k_min,
107
+ mu_min,
108
+ rho_min,
109
+ k_fl,
110
+ rho_fl,
111
+ phi,
112
+ perm,
113
+ visco,
114
+ frac_inc_con,
115
+ frac_inc_ani,
116
+ ) = gen_utilities.dim_check_vector(
117
+ (
118
+ k_min,
119
+ mu_min,
120
+ rho_min,
121
+ k_fl,
122
+ rho_fl,
123
+ phi,
124
+ perm,
125
+ visco,
126
+ frac_inc_con,
127
+ frac_inc_ani,
128
+ ),
129
+ force_type=np.dtype("float64"),
130
+ )
131
+ frac_inc_length = log_length
132
+ else: # Single float value of frac_inc_con, frac_inc_ani or matching number of inclusions
133
+ (
134
+ k_min,
135
+ mu_min,
136
+ rho_min,
137
+ k_fl,
138
+ rho_fl,
139
+ phi,
140
+ perm,
141
+ visco,
142
+ ) = gen_utilities.dim_check_vector(
143
+ (k_min, mu_min, rho_min, k_fl, rho_fl, phi, perm, visco),
144
+ np.dtype("float64"),
145
+ )
146
+ frac_inc_length = frac_inc_ani.shape[0]
147
+
148
+ # Create output array, gather mineral and fluid properties in 2D arrays
149
+ out_arr = np.zeros((log_length, 4), dtype=float, order="C")
150
+ min_prop = np.stack([k_min, mu_min, rho_min], axis=1)
151
+ fl_prop = np.stack([k_fl, rho_fl, perm, visco], axis=1)
152
+
153
+ # Make sure that alpha and v are of the same shape - more about length of alpha further down
154
+ alpha_shape = alpha.shape
155
+ alpha, v = gen_utilities.dim_check_vector(
156
+ (alpha, v), force_type=np.dtype("float64")
157
+ )
158
+ alpha = alpha.reshape(alpha_shape)
159
+ v = v.reshape(alpha_shape)
160
+
161
+ # Number of alphas can vary from sample to sample - not used here, regular number of alphas for all
162
+ # samples. Need to declare the number of alphas per sample in an array. Alpha can also be a constant, in which case
163
+ # it should be expanded to an array of log_length. Both alpha and v should be a 2D array
164
+ if len(alpha) != log_length and len(alpha) < 5:
165
+ # Interpret alpha as a vector of aspect ratios
166
+ alpha_vec = (
167
+ np.ones((log_length, len(alpha)), dtype=float, order="c") * alpha.flatten()
168
+ )
169
+ v_vec = np.ones((log_length, len(alpha)), dtype=float, order="c") * v.flatten()
170
+ alpha = alpha_vec
171
+ v = v_vec
172
+
173
+ # Expect 2-dimensional input to t_mat_lib for alpha and v
174
+ if alpha.ndim == 1:
175
+ alpha = alpha.reshape((len(alpha), 1))
176
+ v = v.reshape((len(alpha), 1))
177
+
178
+ # Have to declare the number of alphas per sample, even if it is constant
179
+ alpha_length_array = np.ones(log_length, dtype=c_int, order="c") * alpha.shape[1]
180
+ alpha_length = alpha.shape[0]
181
+
182
+ try:
183
+ tmatrix_porosity_noscenario(
184
+ out_arr,
185
+ log_length,
186
+ min_prop,
187
+ fl_prop,
188
+ phi,
189
+ alpha,
190
+ v,
191
+ alpha_length_array,
192
+ alpha_length,
193
+ frequency,
194
+ angle,
195
+ frac_inc_con,
196
+ frac_inc_ani,
197
+ frac_inc_length,
198
+ )
199
+ except ValueError:
200
+ # Get more info in case this goes wrong
201
+ raise TypeError(
202
+ "tMatrix:t_matrix_porosity_c_alpha_v: {0}".format(str(sys.exc_info()))
203
+ )
204
+
205
+ vp = out_arr[:, 0]
206
+ vsv = out_arr[:, 1]
207
+ vsh = out_arr[:, 2]
208
+ rhob = out_arr[:, 3]
209
+
210
+ return vp, vsv, vsh, rhob
@@ -0,0 +1,137 @@
1
+ import numpy as np
2
+
3
+ from rock_physics_open.equinor_utilities import gen_utilities
4
+
5
+ from .curvefit_t_matrix_exp import curvefit_t_matrix_exp
6
+ from .opt_subst_utilities import (
7
+ gen_mod_routine,
8
+ gen_sub_routine,
9
+ load_opt_params,
10
+ opt_param_info,
11
+ )
12
+
13
+
14
+ def run_t_matrix_with_opt_params_exp(
15
+ fl_k_orig,
16
+ fl_rho_orig,
17
+ fl_k_sub,
18
+ fl_rho_sub,
19
+ vp,
20
+ vs,
21
+ rhob,
22
+ phi,
23
+ vsh,
24
+ angle,
25
+ perm,
26
+ visco,
27
+ tau,
28
+ freq,
29
+ f_name,
30
+ fluid_sub=True,
31
+ ):
32
+ """Based on the input file with parameters for the optimally fitted model, the correct modelling version is run.
33
+ Fluid substitution follows, in case it is selected. If not, the vp_sub and vs_sub will contain the same values as
34
+ the input logs.
35
+
36
+ Parameters
37
+ ----------
38
+ fl_k_orig : np.ndarray
39
+ Effective in situ fluid bulk modulus [Pa].
40
+ fl_rho_orig : np.ndarray
41
+ Effective in situ fluid density [kg/m^3].
42
+ fl_k_sub : np.ndarray
43
+ Effective substituted fluid bulk modulus [Pa].
44
+ fl_rho_sub : np.ndarray
45
+ Effective substituted density [kg/m^3].
46
+ vp : np.ndarray
47
+ Compressional velocity [m/s].
48
+ vs : np.ndarray
49
+ Shear velocity [m/s].
50
+ rhob : np.ndarray
51
+ Bulk density [kg/m^3].
52
+ phi : np.ndarray
53
+ Porosity [fraction].
54
+ vsh : np.ndarray
55
+ Shale volume [fraction].
56
+ angle : float
57
+ Angle of symmetry plane [degrees]
58
+ perm : float
59
+ Permeability [mD].
60
+ visco : float
61
+ Viscosity [cP].
62
+ tau : float
63
+ Relaxation time constant [s].
64
+ freq : float
65
+ Signal frequency [Hz].
66
+ f_name : str
67
+ File name for parameter file for optimal parameters.
68
+ fluid_sub : bool
69
+ Boolean parameter to perform fluid substitution.
70
+
71
+ Returns
72
+ -------
73
+ tuple
74
+ Tuple of np.ndarrays: vp and vs for pressure substituted case, vp, vs and density for fluid substituted case, vp and vs for
75
+ optimal fitted model, vp and vs residuals (observed logs minus modelled values).
76
+ """
77
+
78
+ opt_type, opt_params, opt_dict = load_opt_params(f_name)
79
+ y_data = np.stack([vp, vs], axis=1)
80
+ y_shape = y_data.shape
81
+ phi, angle, perm, visco, tau, freq, def_vpvs = gen_utilities.dim_check_vector(
82
+ (phi, angle, perm, visco, tau, freq, 1.0)
83
+ )
84
+
85
+ rho_sub = rhob + (fl_rho_sub - fl_rho_orig) * phi
86
+ # Set None values for inputs that will be defined in the different cases
87
+ x_data_new = None
88
+
89
+ opt_fcn = curvefit_t_matrix_exp
90
+ scale_val = opt_param_info()[1]
91
+ # Generate x_data according to method exp
92
+ x_data = np.stack(
93
+ (phi, vsh, fl_k_orig, fl_rho_orig, angle, perm, visco, tau, freq, def_vpvs),
94
+ axis=1,
95
+ )
96
+ if fluid_sub:
97
+ x_data_new = np.stack(
98
+ (phi, vsh, fl_k_sub, fl_rho_sub, angle, perm, visco, tau, freq, def_vpvs),
99
+ axis=1,
100
+ )
101
+ rho_mod = (
102
+ (1.0 - vsh) * opt_dict["rho_carb"] * scale_val["rho_carb"]
103
+ + vsh * opt_dict["rho_sh"] * scale_val["rho_sh"]
104
+ ) * (1.0 - phi) + phi * fl_rho_orig
105
+
106
+ if fluid_sub:
107
+ v_sub, v_mod, v_res = gen_sub_routine(
108
+ opt_fcn, x_data, x_data_new, y_data, opt_params
109
+ )
110
+ vp_sub, vs_sub = [arr.flatten() for arr in np.split(v_sub, 2, axis=1)]
111
+ vp_mod, vs_mod = [arr.flatten() for arr in np.split(v_mod, 2, axis=1)]
112
+ vp_res, vs_res = [arr.flatten() for arr in np.split(v_res, 2, axis=1)]
113
+ else:
114
+ v_mod = gen_mod_routine(opt_fcn, x_data, y_shape, opt_params)
115
+ vp_mod, vs_mod = [arr.flatten() for arr in np.split(v_mod, 2, axis=1)]
116
+ vp_sub = vp
117
+ vs_sub = vs
118
+ vp_res = vp_mod - vp
119
+ vs_res = vs_mod - vs
120
+
121
+ rho_res = rho_mod - rhob
122
+ ai_sub = vp_sub * rho_sub
123
+ vpvs_sub = vp_sub / vs_sub
124
+
125
+ return (
126
+ vp_sub,
127
+ vs_sub,
128
+ rho_sub,
129
+ ai_sub,
130
+ vpvs_sub,
131
+ vp_mod,
132
+ vs_mod,
133
+ rho_mod,
134
+ vp_res,
135
+ vs_res,
136
+ rho_res,
137
+ )