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,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
+ from rock_physics_open.equinor_utilities.optimisation_utilities import (
5
+ gen_mod_routine,
6
+ gen_sub_routine,
7
+ load_opt_params,
8
+ opt_param_info,
9
+ )
10
+
11
+ from .curvefit_t_matrix_exp import curvefit_t_matrix_exp
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
+ )
@@ -0,0 +1,167 @@
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_mod_routine,
6
+ gen_sub_routine,
7
+ load_opt_params,
8
+ )
9
+
10
+ from .curvefit_t_matrix_min import curve_fit_2_inclusion_sets
11
+
12
+
13
+ def run_t_matrix_with_opt_params_petec(
14
+ min_k,
15
+ min_mu,
16
+ min_rho,
17
+ fl_k_orig,
18
+ fl_rho_orig,
19
+ fl_k_sub,
20
+ fl_rho_sub,
21
+ vp,
22
+ vs,
23
+ rhob,
24
+ phi,
25
+ angle,
26
+ perm,
27
+ visco,
28
+ tau,
29
+ freq,
30
+ f_name,
31
+ fluid_sub=True,
32
+ ):
33
+ """
34
+ Based on the input file with parameters for the optimally fitted model, the correct modelling version is run.
35
+ Fluid substitution follows, in case it is selected. If not, the vp_sub and vs_sub will contain the same values as
36
+ the input logs.
37
+ def run_t_matrix_with_opt_params_exp(fl_k_orig, fl_rho_orig, fl_k_sub, fl_rho_sub,
38
+ vp, vs, rhob,
39
+ phi, vsh,
40
+ angle, perm, visco, tau, freq,
41
+ f_name, fluid_sub=True):
42
+ Parameters
43
+ ----------
44
+ min_k : np.ndarray
45
+ Effective mineral bulk modulus [Pa].
46
+ min_mu : np.ndarray
47
+ Effective mineral shear modulus [Pa].
48
+ min_rho : np.ndarray
49
+ Effective mineral density [kg/m^3].
50
+ fl_k_orig : np.ndarray
51
+ Effective in situ fluid bulk modulus [Pa].
52
+ fl_rho_orig : np.ndarray
53
+ Effective in situ fluid density [kg/m^3].
54
+ fl_k_sub : np.ndarray
55
+ Effective substituted fluid bulk modulus [Pa].
56
+ fl_rho_sub : Effective substituted density [kg/m^3].
57
+ vp : np.ndarray
58
+ Compressional velocity [m/s].
59
+ vs : np.ndarray
60
+ Shear velocity [m/s].
61
+ rhob : np.ndarray
62
+ Bulk density [kg/m^3].
63
+ phi : np.ndarray
64
+ Porosity [fraction].
65
+ angle : float
66
+ Angle of symmetry plane [degrees]
67
+ perm : float
68
+ Permeability [mD].
69
+ visco : float
70
+ Viscosity [cP].
71
+ tau : float
72
+ Relaxation time constant [s].
73
+ freq : float
74
+ Signal frequency [Hz].
75
+ f_name : str
76
+ File name for parameter file for optimal parameters.
77
+ fluid_sub : bool
78
+ Boolean parameter to perform fluid substitution.
79
+
80
+ Returns
81
+ -------
82
+ tuple
83
+ Tuple of np.ndarrays: vp and vs for pressure substituted case, vp, vs and density for fluid substituted case, vp and vs for
84
+ optimal fitted model, vp and vs residuals (observed logs minus modelled values).
85
+ """
86
+ opt_type, opt_params, opt_dict = load_opt_params(f_name)
87
+ y_data = np.stack([vp, vs], axis=1)
88
+ y_shape = y_data.shape
89
+ phi, angle, perm, visco, tau, freq, def_vpvs = gen_utilities.dim_check_vector(
90
+ (phi, angle, perm, visco, tau, freq, 1.0)
91
+ )
92
+
93
+ rho_sub = rhob + (fl_rho_sub - fl_rho_orig) * phi
94
+ # Set None values for inputs that will be defined in the different cases
95
+ x_data_new = None
96
+
97
+ opt_fcn = curve_fit_2_inclusion_sets
98
+ # Generate x_data according to method min
99
+ x_data = np.stack(
100
+ (
101
+ phi,
102
+ min_k,
103
+ min_mu,
104
+ min_rho,
105
+ fl_k_orig,
106
+ fl_rho_orig,
107
+ angle,
108
+ perm,
109
+ visco,
110
+ tau,
111
+ freq,
112
+ def_vpvs,
113
+ ),
114
+ axis=1,
115
+ )
116
+ if fluid_sub:
117
+ x_data_new = np.stack(
118
+ (
119
+ phi,
120
+ min_k,
121
+ min_mu,
122
+ min_rho,
123
+ fl_k_sub,
124
+ fl_rho_sub,
125
+ angle,
126
+ perm,
127
+ visco,
128
+ tau,
129
+ freq,
130
+ def_vpvs,
131
+ ),
132
+ axis=1,
133
+ )
134
+ rho_mod = min_rho * (1.0 - phi) + fl_rho_orig * phi
135
+
136
+ if fluid_sub:
137
+ v_sub, v_mod, v_res = gen_sub_routine(
138
+ opt_fcn, x_data, x_data_new, y_data, opt_params
139
+ )
140
+ vp_sub, vs_sub = [arr.flatten() for arr in np.split(v_sub, 2, axis=1)]
141
+ vp_mod, vs_mod = [arr.flatten() for arr in np.split(v_mod, 2, axis=1)]
142
+ vp_res, vs_res = [arr.flatten() for arr in np.split(v_res, 2, axis=1)]
143
+ else:
144
+ v_mod = gen_mod_routine(opt_fcn, x_data, y_shape, opt_params)
145
+ vp_mod, vs_mod = [arr.flatten() for arr in np.split(v_mod, 2, axis=1)]
146
+ vp_sub = vp
147
+ vs_sub = vs
148
+ vp_res = vp_mod - vp
149
+ vs_res = vs_mod - vs
150
+
151
+ rho_res = rho_mod - rhob
152
+ ai_sub = vp_sub * rho_sub
153
+ vpvs_sub = vp_sub / vs_sub
154
+
155
+ return (
156
+ vp_sub,
157
+ vs_sub,
158
+ rho_sub,
159
+ ai_sub,
160
+ vpvs_sub,
161
+ vp_mod,
162
+ vs_mod,
163
+ rho_mod,
164
+ vp_res,
165
+ vs_res,
166
+ rho_res,
167
+ )
@@ -0,0 +1,76 @@
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_mod_routine,
6
+ load_opt_params,
7
+ opt_param_info,
8
+ )
9
+
10
+ from .curvefit_t_matrix_exp import curvefit_t_matrix_exp
11
+
12
+
13
+ def run_t_matrix_forward_model_with_opt_params_exp(
14
+ fl_k, fl_rho, phi, vsh, angle, perm, visco, tau, freq, f_name
15
+ ):
16
+ """Based on the input file with parameters for the optimally fitted model, a forward modelling is done
17
+ with inputs of mineral properties, fluid properties and porosity per sample. Other parameters (constants)
18
+ can also be varied from their setting when the optimal parameters were found.
19
+
20
+ Parameters
21
+ ----------
22
+ fl_k : np.ndarray.
23
+ Effective in situ fluid bulk modulus [Pa].
24
+ fl_rho : np.ndarray
25
+ Effective in situ fluid density [kg/m^3].
26
+ phi : np.ndarray
27
+ Porosity [fraction].
28
+ vsh : np.ndarray
29
+ Shale volume [fraction].
30
+ angle : float
31
+ Angle of symmetry plane
32
+ perm : float
33
+ Permeability [mD].
34
+ visco : float
35
+ Viscosity [cP].
36
+ tau : float
37
+ Relaxation time constant [s].
38
+ freq : float
39
+ Signal frequency [Hz].
40
+ f_name : str
41
+ File name for parameter file for optimal parameters.
42
+
43
+ Returns
44
+ -------
45
+ tuple
46
+ Tuple of np.ndarrays: vp [m/s], vs [m/s], rho [kg/m^3], ai [kg/m^3 x m/s], vp/vs [fraction] for forward model.
47
+ """
48
+ opt_type, opt_params, opt_dict = load_opt_params(f_name)
49
+ scale_val = opt_param_info()[1]
50
+ phi, angle, perm, visco, tau, freq, def_vpvs = gen_utilities.dim_check_vector(
51
+ (phi, angle, perm, visco, tau, freq, 1.0)
52
+ )
53
+ rho_mod = (
54
+ (1.0 - vsh) * opt_dict["rho_carb"] * scale_val["rho_carb"]
55
+ + vsh * opt_dict["rho_sh"] * scale_val["rho_sh"]
56
+ ) * (1.0 - phi) + phi * fl_rho
57
+ y_shape = (phi.shape[0], 2)
58
+
59
+ if opt_type != "exp":
60
+ raise ValueError(
61
+ f"{__file__}: incorrect type of optimal parameter input file, must come from EXP "
62
+ f"optimisation"
63
+ )
64
+ # No Need for preprocessing
65
+ opt_fcn = curvefit_t_matrix_exp
66
+ # Generate x_data according to method min
67
+ x_data = np.stack(
68
+ (phi, vsh, fl_k, fl_rho, angle, perm, visco, tau, freq, def_vpvs), axis=1
69
+ )
70
+ v_mod = gen_mod_routine(opt_fcn, x_data, y_shape, opt_params)
71
+ if not isinstance(v_mod, np.ndarray):
72
+ raise ValueError(f"{__file__}: no solution to forward model")
73
+ vp_mod, vs_mod = [arr.flatten() for arr in np.split(v_mod, 2, axis=1)]
74
+ vpvs_mod = vp_mod / vs_mod
75
+ ai_mod = vp_mod * rho_mod
76
+ return vp_mod, vs_mod, rho_mod, ai_mod, vpvs_mod
@@ -0,0 +1,89 @@
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_mod_routine,
6
+ load_opt_params,
7
+ )
8
+
9
+ from .curvefit_t_matrix_min import curve_fit_2_inclusion_sets
10
+
11
+
12
+ def run_t_matrix_forward_model_with_opt_params_petec(
13
+ min_k, min_mu, min_rho, fl_k, fl_rho, phi, angle, perm, visco, tau, freq, f_name
14
+ ):
15
+ """Based on the input file with parameters for the optimally fitted model, a forward modelling is done
16
+ with inputs of mineral properties, fluid properties and porosity per sample. Other parameters (constants)
17
+ can also be varied from their setting when the optimal parameters were found.
18
+
19
+ Parameters
20
+ ----------
21
+ min_k : np.ndarray
22
+ Effective mineral bulk modulus [Pa].
23
+ min_mu : np.ndarray
24
+ Effective mineral shear modulus [Pa].
25
+ min_rho : np.ndarray
26
+ Effective mineral density [kg/m^3].
27
+ fl_k : np.ndarray
28
+ Effective in situ fluid bulk modulus [Pa].
29
+ fl_rho : np.ndarray
30
+ Effective in situ fluid density [kg/m^3].
31
+ phi : np.ndarray
32
+ Porosity [fraction].
33
+ angle : float
34
+ Angle of symmetry plane [degrees]
35
+ perm : float
36
+ Permeability [mD].
37
+ visco : float
38
+ Viscosity [cP].
39
+ tau : float
40
+ Relaxation time constant [s].
41
+ freq : float
42
+ Signal frequency [Hz].
43
+ f_name : str
44
+ File name for parameter file for optimal parameters.
45
+
46
+ Returns
47
+ -------
48
+ tuple
49
+ Tuple of np.ndarrays: vp [m/s], vs [m/s], rho [kg/m^3], ai [kg/m^3 x m/s], vp/vs [fraction] for forward model.
50
+ """
51
+ opt_type, opt_params, opt_dict = load_opt_params(f_name)
52
+ phi, angle, perm, visco, tau, freq, def_vpvs = gen_utilities.dim_check_vector(
53
+ (phi, angle, perm, visco, tau, freq, 1.0)
54
+ )
55
+ rho_mod = min_rho * (1.0 - phi) + fl_rho * phi
56
+ y_shape = (phi.shape[0], 2)
57
+
58
+ if opt_type != "min":
59
+ raise ValueError(
60
+ f"{__file__}: incorrect type of optimal parameter input file, must come from PETEC "
61
+ f"optimisation"
62
+ )
63
+ # No Need for preprocessing
64
+ opt_fcn = curve_fit_2_inclusion_sets
65
+ # Generate x_data according to method min
66
+ x_data = np.stack(
67
+ (
68
+ phi,
69
+ min_k,
70
+ min_mu,
71
+ min_rho,
72
+ fl_k,
73
+ fl_rho,
74
+ angle,
75
+ perm,
76
+ visco,
77
+ tau,
78
+ freq,
79
+ def_vpvs,
80
+ ),
81
+ axis=1,
82
+ )
83
+ v_mod = gen_mod_routine(opt_fcn, x_data, y_shape, opt_params)
84
+ if not isinstance(v_mod, np.ndarray):
85
+ raise ValueError(f"{__file__}: no solution to forward model")
86
+ vp_mod, vs_mod = [arr.flatten() for arr in np.split(v_mod, 2, axis=1)]
87
+ vpvs_mod = vp_mod / vs_mod
88
+ ai_mod = vp_mod * rho_mod
89
+ return vp_mod, vs_mod, rho_mod, ai_mod, vpvs_mod