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,163 @@
1
+ import numpy as np
2
+
3
+ from rock_physics_open.equinor_utilities import gen_utilities
4
+
5
+ from .curvefit_t_matrix_min import curve_fit_2_inclusion_sets
6
+ from .opt_subst_utilities import gen_mod_routine, gen_sub_routine, load_opt_params
7
+
8
+
9
+ def run_t_matrix_with_opt_params_petec(
10
+ min_k,
11
+ min_mu,
12
+ min_rho,
13
+ fl_k_orig,
14
+ fl_rho_orig,
15
+ fl_k_sub,
16
+ fl_rho_sub,
17
+ vp,
18
+ vs,
19
+ rhob,
20
+ phi,
21
+ angle,
22
+ perm,
23
+ visco,
24
+ tau,
25
+ freq,
26
+ f_name,
27
+ fluid_sub=True,
28
+ ):
29
+ """
30
+ Based on the input file with parameters for the optimally fitted model, the correct modelling version is run.
31
+ Fluid substitution follows, in case it is selected. If not, the vp_sub and vs_sub will contain the same values as
32
+ the input logs.
33
+ def run_t_matrix_with_opt_params_exp(fl_k_orig, fl_rho_orig, fl_k_sub, fl_rho_sub,
34
+ vp, vs, rhob,
35
+ phi, vsh,
36
+ angle, perm, visco, tau, freq,
37
+ f_name, fluid_sub=True):
38
+ Parameters
39
+ ----------
40
+ min_k : np.ndarray
41
+ Effective mineral bulk modulus [Pa].
42
+ min_mu : np.ndarray
43
+ Effective mineral shear modulus [Pa].
44
+ min_rho : np.ndarray
45
+ Effective mineral density [kg/m^3].
46
+ fl_k_orig : np.ndarray
47
+ Effective in situ fluid bulk modulus [Pa].
48
+ fl_rho_orig : np.ndarray
49
+ Effective in situ fluid density [kg/m^3].
50
+ fl_k_sub : np.ndarray
51
+ Effective substituted fluid bulk modulus [Pa].
52
+ fl_rho_sub : Effective substituted density [kg/m^3].
53
+ vp : np.ndarray
54
+ Compressional velocity [m/s].
55
+ vs : np.ndarray
56
+ Shear velocity [m/s].
57
+ rhob : np.ndarray
58
+ Bulk density [kg/m^3].
59
+ phi : np.ndarray
60
+ Porosity [fraction].
61
+ angle : float
62
+ Angle of symmetry plane [degrees]
63
+ perm : float
64
+ Permeability [mD].
65
+ visco : float
66
+ Viscosity [cP].
67
+ tau : float
68
+ Relaxation time constant [s].
69
+ freq : float
70
+ Signal frequency [Hz].
71
+ f_name : str
72
+ File name for parameter file for optimal parameters.
73
+ fluid_sub : bool
74
+ Boolean parameter to perform fluid substitution.
75
+
76
+ Returns
77
+ -------
78
+ tuple
79
+ Tuple of np.ndarrays: vp and vs for pressure substituted case, vp, vs and density for fluid substituted case, vp and vs for
80
+ optimal fitted model, vp and vs residuals (observed logs minus modelled values).
81
+ """
82
+ opt_type, opt_params, opt_dict = load_opt_params(f_name)
83
+ y_data = np.stack([vp, vs], axis=1)
84
+ y_shape = y_data.shape
85
+ phi, angle, perm, visco, tau, freq, def_vpvs = gen_utilities.dim_check_vector(
86
+ (phi, angle, perm, visco, tau, freq, 1.0)
87
+ )
88
+
89
+ rho_sub = rhob + (fl_rho_sub - fl_rho_orig) * phi
90
+ # Set None values for inputs that will be defined in the different cases
91
+ x_data_new = None
92
+
93
+ opt_fcn = curve_fit_2_inclusion_sets
94
+ # Generate x_data according to method min
95
+ x_data = np.stack(
96
+ (
97
+ phi,
98
+ min_k,
99
+ min_mu,
100
+ min_rho,
101
+ fl_k_orig,
102
+ fl_rho_orig,
103
+ angle,
104
+ perm,
105
+ visco,
106
+ tau,
107
+ freq,
108
+ def_vpvs,
109
+ ),
110
+ axis=1,
111
+ )
112
+ if fluid_sub:
113
+ x_data_new = np.stack(
114
+ (
115
+ phi,
116
+ min_k,
117
+ min_mu,
118
+ min_rho,
119
+ fl_k_sub,
120
+ fl_rho_sub,
121
+ angle,
122
+ perm,
123
+ visco,
124
+ tau,
125
+ freq,
126
+ def_vpvs,
127
+ ),
128
+ axis=1,
129
+ )
130
+ rho_mod = min_rho * (1.0 - phi) + fl_rho_orig * phi
131
+
132
+ if fluid_sub:
133
+ v_sub, v_mod, v_res = gen_sub_routine(
134
+ opt_fcn, x_data, x_data_new, y_data, opt_params
135
+ )
136
+ vp_sub, vs_sub = [arr.flatten() for arr in np.split(v_sub, 2, axis=1)]
137
+ vp_mod, vs_mod = [arr.flatten() for arr in np.split(v_mod, 2, axis=1)]
138
+ vp_res, vs_res = [arr.flatten() for arr in np.split(v_res, 2, axis=1)]
139
+ else:
140
+ v_mod = gen_mod_routine(opt_fcn, x_data, y_shape, opt_params)
141
+ vp_mod, vs_mod = [arr.flatten() for arr in np.split(v_mod, 2, axis=1)]
142
+ vp_sub = vp
143
+ vs_sub = vs
144
+ vp_res = vp_mod - vp
145
+ vs_res = vs_mod - vs
146
+
147
+ rho_res = rho_mod - rhob
148
+ ai_sub = vp_sub * rho_sub
149
+ vpvs_sub = vp_sub / vs_sub
150
+
151
+ return (
152
+ vp_sub,
153
+ vs_sub,
154
+ rho_sub,
155
+ ai_sub,
156
+ vpvs_sub,
157
+ vp_mod,
158
+ vs_mod,
159
+ rho_mod,
160
+ vp_res,
161
+ vs_res,
162
+ rho_res,
163
+ )
@@ -0,0 +1,72 @@
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 gen_mod_routine, load_opt_params, opt_param_info
7
+
8
+
9
+ def run_t_matrix_forward_model_with_opt_params_exp(
10
+ fl_k, fl_rho, phi, vsh, angle, perm, visco, tau, freq, f_name
11
+ ):
12
+ """Based on the input file with parameters for the optimally fitted model, a forward modelling is done
13
+ with inputs of mineral properties, fluid properties and porosity per sample. Other parameters (constants)
14
+ can also be varied from their setting when the optimal parameters were found.
15
+
16
+ Parameters
17
+ ----------
18
+ fl_k : np.ndarray.
19
+ Effective in situ fluid bulk modulus [Pa].
20
+ fl_rho : np.ndarray
21
+ Effective in situ fluid density [kg/m^3].
22
+ phi : np.ndarray
23
+ Porosity [fraction].
24
+ vsh : np.ndarray
25
+ Shale volume [fraction].
26
+ angle : float
27
+ Angle of symmetry plane
28
+ perm : float
29
+ Permeability [mD].
30
+ visco : float
31
+ Viscosity [cP].
32
+ tau : float
33
+ Relaxation time constant [s].
34
+ freq : float
35
+ Signal frequency [Hz].
36
+ f_name : str
37
+ File name for parameter file for optimal parameters.
38
+
39
+ Returns
40
+ -------
41
+ tuple
42
+ 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.
43
+ """
44
+ opt_type, opt_params, opt_dict = load_opt_params(f_name)
45
+ scale_val = opt_param_info()[1]
46
+ phi, angle, perm, visco, tau, freq, def_vpvs = gen_utilities.dim_check_vector(
47
+ (phi, angle, perm, visco, tau, freq, 1.0)
48
+ )
49
+ rho_mod = (
50
+ (1.0 - vsh) * opt_dict["rho_carb"] * scale_val["rho_carb"]
51
+ + vsh * opt_dict["rho_sh"] * scale_val["rho_sh"]
52
+ ) * (1.0 - phi) + phi * fl_rho
53
+ y_shape = (phi.shape[0], 2)
54
+
55
+ if opt_type != "exp":
56
+ raise ValueError(
57
+ f"{__file__}: incorrect type of optimal parameter input file, must come from EXP "
58
+ f"optimisation"
59
+ )
60
+ # No Need for preprocessing
61
+ opt_fcn = curvefit_t_matrix_exp
62
+ # Generate x_data according to method min
63
+ x_data = np.stack(
64
+ (phi, vsh, fl_k, fl_rho, angle, perm, visco, tau, freq, def_vpvs), axis=1
65
+ )
66
+ v_mod = gen_mod_routine(opt_fcn, x_data, y_shape, opt_params)
67
+ if not isinstance(v_mod, np.ndarray):
68
+ raise ValueError(f"{__file__}: no solution to forward model")
69
+ vp_mod, vs_mod = [arr.flatten() for arr in np.split(v_mod, 2, axis=1)]
70
+ vpvs_mod = vp_mod / vs_mod
71
+ ai_mod = vp_mod * rho_mod
72
+ return vp_mod, vs_mod, rho_mod, ai_mod, vpvs_mod
@@ -0,0 +1,86 @@
1
+ import numpy as np
2
+
3
+ from rock_physics_open.equinor_utilities import gen_utilities
4
+
5
+ from .curvefit_t_matrix_min import curve_fit_2_inclusion_sets
6
+ from .opt_subst_utilities import gen_mod_routine, load_opt_params
7
+
8
+
9
+ def run_t_matrix_forward_model_with_opt_params_petec(
10
+ min_k, min_mu, min_rho, fl_k, fl_rho, phi, angle, perm, visco, tau, freq, f_name
11
+ ):
12
+ """Based on the input file with parameters for the optimally fitted model, a forward modelling is done
13
+ with inputs of mineral properties, fluid properties and porosity per sample. Other parameters (constants)
14
+ can also be varied from their setting when the optimal parameters were found.
15
+
16
+ Parameters
17
+ ----------
18
+ min_k : np.ndarray
19
+ Effective mineral bulk modulus [Pa].
20
+ min_mu : np.ndarray
21
+ Effective mineral shear modulus [Pa].
22
+ min_rho : np.ndarray
23
+ Effective mineral density [kg/m^3].
24
+ fl_k : np.ndarray
25
+ Effective in situ fluid bulk modulus [Pa].
26
+ fl_rho : np.ndarray
27
+ Effective in situ fluid density [kg/m^3].
28
+ phi : np.ndarray
29
+ Porosity [fraction].
30
+ angle : float
31
+ Angle of symmetry plane [degrees]
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
+ phi, angle, perm, visco, tau, freq, def_vpvs = gen_utilities.dim_check_vector(
50
+ (phi, angle, perm, visco, tau, freq, 1.0)
51
+ )
52
+ rho_mod = min_rho * (1.0 - phi) + fl_rho * phi
53
+ y_shape = (phi.shape[0], 2)
54
+
55
+ if opt_type != "min":
56
+ raise ValueError(
57
+ f"{__file__}: incorrect type of optimal parameter input file, must come from PETEC "
58
+ f"optimisation"
59
+ )
60
+ # No Need for preprocessing
61
+ opt_fcn = curve_fit_2_inclusion_sets
62
+ # Generate x_data according to method min
63
+ x_data = np.stack(
64
+ (
65
+ phi,
66
+ min_k,
67
+ min_mu,
68
+ min_rho,
69
+ fl_k,
70
+ fl_rho,
71
+ angle,
72
+ perm,
73
+ visco,
74
+ tau,
75
+ freq,
76
+ def_vpvs,
77
+ ),
78
+ axis=1,
79
+ )
80
+ v_mod = gen_mod_routine(opt_fcn, x_data, y_shape, opt_params)
81
+ if not isinstance(v_mod, np.ndarray):
82
+ raise ValueError(f"{__file__}: no solution to forward model")
83
+ vp_mod, vs_mod = [arr.flatten() for arr in np.split(v_mod, 2, axis=1)]
84
+ vpvs_mod = vp_mod / vs_mod
85
+ ai_mod = vp_mod * rho_mod
86
+ return vp_mod, vs_mod, rho_mod, ai_mod, vpvs_mod
@@ -0,0 +1,172 @@
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 gen_opt_routine, opt_param_info, save_opt_params
7
+ from .t_matrix_parameter_optimisation_min import DEF_VP_VS_RATIO
8
+
9
+
10
+ def t_matrix_optimisation_exp(
11
+ k_fl: np.ndarray,
12
+ rho_fl: np.ndarray,
13
+ por: np.ndarray,
14
+ vsh: np.ndarray,
15
+ vp: np.ndarray,
16
+ vs: np.ndarray,
17
+ rhob: np.ndarray,
18
+ angle: float = 0.0,
19
+ k_r: float = 50.0,
20
+ eta_f: float = 1.0,
21
+ tau: float = 1.0e-7,
22
+ freq: float = 1.0e3,
23
+ file_out_str: str = "opt_params_exp.pkl",
24
+ display_results: bool = False,
25
+ well_name: str = "Unknown well",
26
+ **opt_kwargs,
27
+ ):
28
+ """T-Matrix optimisation adapted to an exploration setting, where detailed well information is generally not known.
29
+ Inclusion parameters are optimised for the whole well.
30
+
31
+ Parameters
32
+ ----------
33
+ por :
34
+ Inclusion porosity [ratio].
35
+ vsh :
36
+ Shale volume [ratio].
37
+ k_fl :
38
+ Fluid bulk modulus [Pa].
39
+ rho_fl :
40
+ Fluid density [kg/m^3].
41
+ vp :
42
+ Compressional velocity log [m/s].
43
+ vs :
44
+ Shear velocity log [m/s].
45
+ rhob :
46
+ Bulk density log [kg/m^3].
47
+ angle : float
48
+ Angle of symmetry plane [degrees]
49
+ k_r :
50
+ Permeability [mD].
51
+ eta_f :
52
+ Fluid viscosity [cP].
53
+ tau :
54
+ Relaxation time constant [s].
55
+ freq :
56
+ Signal frequency [Hz].
57
+ file_out_str :
58
+ Output file name (string) to store optimal parameters (pickle format).
59
+ display_results :
60
+ D isplay optimal parameters in a window after run.
61
+ well_name :
62
+ Name of well to be displayed in info box title.
63
+ opt_kwargs :
64
+ Additional keywords to be passed to optimisation function
65
+
66
+ Returns
67
+ -------
68
+ tuple
69
+ vp_mod, vs_mod - modelled logs, vp_res, vs_res - residual logs.
70
+ """
71
+ # 1. Preparation that is independent of search for minimum possible aspect ratio for second inclusion set
72
+
73
+ # Optimisation function for selected parameters
74
+ opt_fun = curvefit_t_matrix_exp
75
+ # rho_min = (rhob - por * rho_fl) / (1 - por)
76
+ # EXP adapted inputs: include fluid data and other params in x_data
77
+ # expand single value parameters to match logs length
78
+ por, angle, k_r, eta_f, tau, freq, def_vpvs = gen_utilities.dim_check_vector(
79
+ (por, angle, k_r, eta_f, tau, freq, DEF_VP_VS_RATIO)
80
+ )
81
+ x_data = np.stack(
82
+ (por, vsh, k_fl, rho_fl, angle, k_r, eta_f, tau, freq, def_vpvs), axis=1
83
+ )
84
+ # Set weight to vs to give vp and vs similar influence on optimisation
85
+ y_data = np.stack([vp, vs * DEF_VP_VS_RATIO], axis=1)
86
+
87
+ # 2. Search for minimum aspect ratio of inclusion set no. 2, given that inclusion set no. 1 will at least represent
88
+ # 50% of inclusions. Minimum aspect ratio is linked to the porosity, and the most conservative estimate is to use
89
+ # the maximum value. This is likely to deteriorate the optimisation results, so a search for a more appropriate
90
+ # value that still produces valid results is made
91
+ percentiles = [50, 75, 80, 85, 90, 95, 99, 100]
92
+ valid_result = False
93
+ vel_mod = None
94
+ vel_res = None
95
+ opt_params = None
96
+ scale_val = opt_param_info()[1]
97
+ while not valid_result and percentiles:
98
+ try:
99
+ # Make sure that parameters are not in conflict with T Matrix assumptions
100
+ min_v1 = 0.5
101
+ max_por = np.percentile(por, percentiles[0])
102
+ min_a2 = (1.0 - min_v1) * max_por
103
+ # Test with all parameters in the range 0.0 - 1.0
104
+ # Params: f_ani f_con a1 a2 v1 k_carb mu_carb rho_carb k_sh mu_sh rho_sh
105
+ lower_bound = np.array(
106
+ [
107
+ 0.0,
108
+ 0.0,
109
+ 0.5,
110
+ min_a2,
111
+ min_v1, # f_ani f_con a1 a2 v1
112
+ 35.0 / scale_val["k_carb"],
113
+ 30.0 / scale_val["mu_carb"],
114
+ 2650.0 / scale_val["rho_carb"], # k_carb, mu_carb, rho_carb
115
+ 15.0 / scale_val["k_sh"],
116
+ 7.0 / scale_val["mu_sh"],
117
+ 2500.0 / scale_val["rho_sh"],
118
+ ],
119
+ dtype=float,
120
+ ) # k_sh, mu_sh, rho_sh
121
+ upper_bound = np.array(
122
+ [
123
+ 1.0,
124
+ 1.0,
125
+ 1.0,
126
+ 0.30,
127
+ 1.0, # f_ani f_con a1 a2 v1
128
+ 1.0,
129
+ 1.0,
130
+ 1.0, # k_carb, mu_carb, rho_carb
131
+ 1.0,
132
+ 1.0,
133
+ 1.0,
134
+ ],
135
+ dtype=float,
136
+ ) # k_sh, mu_sh, rho_sh
137
+ x0 = (upper_bound + lower_bound) / 2.0
138
+ # Optimisation step without fluid substitution
139
+ vel_mod, vel_res, opt_params = gen_opt_routine(
140
+ opt_fun, x_data, y_data, x0, lower_bound, upper_bound, **opt_kwargs
141
+ )
142
+ valid_result = True
143
+ except ValueError:
144
+ percentiles.pop(0)
145
+ valid_result = False
146
+
147
+ if not valid_result:
148
+ raise ValueError(
149
+ f"{__file__}: unable to find stable value for T Matrix optimisation, second inclusion"
150
+ )
151
+
152
+ # Reshape outputs and remove weight from vs
153
+ vp_mod, vs_mod = [arr.flatten() for arr in np.split(vel_mod, 2, axis=1)]
154
+ vp_res, vs_res = [arr.flatten() for arr in np.split(vel_res, 2, axis=1)]
155
+ vs_mod = vs_mod / DEF_VP_VS_RATIO
156
+ vs_res = vs_res / DEF_VP_VS_RATIO
157
+ vpvs_mod = vp_mod / vs_mod
158
+ # Calculate the modelled density
159
+ rhob_mod = (
160
+ (1.0 - vsh) * opt_params[7] * scale_val["rho_carb"]
161
+ + vsh * opt_params[10] * scale_val["rho_sh"]
162
+ ) * (1.0 - por) + por * rho_fl
163
+ ai_mod = vp_mod * rhob_mod
164
+ rhob_res = rhob_mod - rhob
165
+ # Save the optimal parameters
166
+ save_opt_params("exp", opt_params, file_out_str, well_name=well_name)
167
+ if display_results:
168
+ from .opt_subst_utilities import opt_param_to_ascii
169
+
170
+ opt_param_to_ascii(file_out_str, well_name=well_name)
171
+
172
+ return vp_mod, vs_mod, rhob_mod, ai_mod, vpvs_mod, vp_res, vs_res, rhob_res
@@ -0,0 +1,159 @@
1
+ import numpy as np
2
+
3
+ from rock_physics_open.equinor_utilities import gen_utilities
4
+
5
+ from .curvefit_t_matrix_min import curve_fit_2_inclusion_sets
6
+ from .opt_subst_utilities import gen_opt_routine, save_opt_params
7
+
8
+ # Trade-off between calcite, dolomite and quartz, vs is weighted by this in order to make it count as much as vp
9
+ # in the optimisation
10
+ DEF_VP_VS_RATIO = 1.8
11
+
12
+
13
+ def t_matrix_optimisation_petec(
14
+ k_min: np.ndarray,
15
+ mu_min: np.ndarray,
16
+ rho_min: np.ndarray,
17
+ k_fl: np.ndarray,
18
+ rho_fl: np.ndarray,
19
+ por: np.ndarray,
20
+ vp: np.ndarray,
21
+ vs: np.ndarray,
22
+ rhob: np.ndarray,
23
+ angle: float = 0.0,
24
+ k_r: float = 50.0,
25
+ eta_f: float = 1.0,
26
+ tau: float = 1.0e-7,
27
+ freq: float = 1.0e3,
28
+ file_out_str: str = "opt_params_min.pkl",
29
+ display_results: bool = False,
30
+ well_name: str = "Unknown well",
31
+ **opt_kwargs,
32
+ ):
33
+ """T-Matrix optimisation adapted to a case with detailed information available, such as in a development or production
34
+ setting. Mineral and fluid composition should be known on a sample basis. Inclusion parameters are regarded as
35
+ unknown and they are optimised for.
36
+
37
+ Parameters
38
+ ----------
39
+ k_min :
40
+ Effective mineral bulk modulus [Pa].
41
+ mu_min :
42
+ Effective mineral shear modulus [Pa].
43
+ rho_min :
44
+ Effective mineral bulk density [kg/m^3].
45
+ k_fl :
46
+ Effective fluid bulk modulud [Pa].
47
+ rho_fl :
48
+ Effective fluid density [kg/m^3].
49
+ por :
50
+ Inclusion porosity [ratio].
51
+ vp :
52
+ Compressional velocity log [m/s].
53
+ vs :
54
+ Shear velocity log [m/s].
55
+ rhob :
56
+ Bulk density log [kg/m^3].
57
+ angle : float
58
+ Angle of symmetry plane [degrees]
59
+ k_r :
60
+ Permeability [mD].
61
+ eta_f :
62
+ Fluid viscosity [cP].
63
+ tau :
64
+ Relaxation time constant [s].
65
+ freq :
66
+ Signal frequency [Hz].
67
+ file_out_str :
68
+ Output file name (string) to store optimal parameters (pickle format).
69
+ display_results :
70
+ Display optimal parameters in a window after run.
71
+ well_name:
72
+ Name of well to be displayed in info box title.
73
+ opt_kwargs:
74
+ Additional keywords to be passed to optimisation function
75
+
76
+ Returns
77
+ -------
78
+ tuple
79
+ vp_mod, vs_mod, rho_mod, ai_mod, vpvs_mod - modelled logs, vp_res, vs_res, rho_res - residual logs.
80
+ """
81
+ # 1. Preparation that is independent of search for minimum possible aspect ratio for second inclusion set
82
+
83
+ # Optimisation function for selected parameters, with effective mineral properties known and 2 inclusion sets
84
+ opt_fun = curve_fit_2_inclusion_sets
85
+ rhob_mod = rho_min * (1 - por) + rho_fl * por
86
+ rhob_res = rhob - rhob_mod
87
+ # PETEC adapted inputs: include fluid data and other params in x_data
88
+ por, angle, k_r, eta_f, tau, freq, def_vp_vs_ratio = gen_utilities.dim_check_vector(
89
+ (por, angle, k_r, eta_f, tau, freq, DEF_VP_VS_RATIO)
90
+ )
91
+ x_data = np.stack(
92
+ (
93
+ por,
94
+ k_min,
95
+ mu_min,
96
+ rho_min,
97
+ k_fl,
98
+ rho_fl,
99
+ angle,
100
+ k_r,
101
+ eta_f,
102
+ tau,
103
+ freq,
104
+ def_vp_vs_ratio,
105
+ ),
106
+ axis=1,
107
+ )
108
+ # Set weight to vs to give vp and vs similar influence on optimisation
109
+ y_data = np.stack([vp, vs * DEF_VP_VS_RATIO], axis=1)
110
+
111
+ # 2. Search for minimum aspect ratio of inclusion set no. 2, given that inclusion set no. 1 will at least represent
112
+ # 50% of inclusions. Minimum aspect ratio is linked to the porosity, and the most conservative estimate is to use
113
+ # the maximum value. This is likely to deteriorate the optimisation results, so a search for a more appropriate
114
+ # value that still produces valid results is made
115
+ percentiles = [50, 75, 80, 85, 90, 95, 99, 100]
116
+ valid_result = False
117
+ vel_mod = None
118
+ vel_res = None
119
+ opt_params = None
120
+ while not valid_result and percentiles:
121
+ try:
122
+ # Make sure that parameters are not in conflict with T Matrix assumptions
123
+ min_v1 = 0.5
124
+ max_por = np.percentile(por, percentiles[0])
125
+ min_a2 = (1.0 - min_v1) * max_por
126
+ # Test with all parameters in the range 0.0 - 1.0 for best optimiser performance
127
+ # Params: f_ani f_con a1 a2 v1
128
+ lower_bound = np.array([0.0, 0.0, 0.5, min_a2, min_v1], dtype=float)
129
+ upper_bound = np.array([1.0, 1.0, 1.0, 0.30, 1.0], dtype=float)
130
+ x0 = (upper_bound + lower_bound) / 2.0
131
+ # Optimisation step without fluid substitution
132
+ vel_mod, vel_res, opt_params = gen_opt_routine(
133
+ opt_fun, x_data, y_data, x0, lower_bound, upper_bound, **opt_kwargs
134
+ )
135
+ valid_result = True
136
+ except ValueError:
137
+ percentiles.pop(0)
138
+ valid_result = False
139
+
140
+ if not valid_result:
141
+ raise ValueError(
142
+ f"{__file__}: unable to find stable value for T Matrix optimisation, second inclusion"
143
+ )
144
+
145
+ # Reshape outputs and remove weight from vs
146
+ vp_mod, vs_mod = [arr.flatten() for arr in np.split(vel_mod, 2, axis=1)]
147
+ ai_mod = vp_mod * rhob_mod
148
+ vp_res, vs_res = [arr.flatten() for arr in np.split(vel_res, 2, axis=1)]
149
+ vs_mod = vs_mod / DEF_VP_VS_RATIO
150
+ vs_res = vs_res / DEF_VP_VS_RATIO
151
+ vpvs_mod = vp_mod / vs_mod
152
+ # Save the optimal parameters
153
+ save_opt_params("min", opt_params, file_out_str, well_name=well_name)
154
+ if display_results:
155
+ from .opt_subst_utilities import opt_param_to_ascii
156
+
157
+ opt_param_to_ascii(file_out_str, well_name=well_name)
158
+
159
+ return vp_mod, vs_mod, rhob_mod, ai_mod, vpvs_mod, vp_res, vs_res, rhob_res
@@ -0,0 +1,12 @@
1
+ from .array_functions import array_inverse, array_matrix_mult
2
+ from .calc_pressure import calc_pressure_vec
3
+ from .pressure_input import pressure_input_utility
4
+ from .t_matrix_vec import t_matrix_porosity_vectorised
5
+
6
+ __all__ = [
7
+ "array_inverse",
8
+ "array_matrix_mult",
9
+ "calc_pressure_vec",
10
+ "pressure_input_utility",
11
+ "t_matrix_porosity_vectorised",
12
+ ]