1+ import numpy as np
12import os
23
34import dotenv
1011
1112
1213def test_2025_1 ():
13- range_ = 0.6
14- orientation_loc = - 286
1514
16- path_to_data = os .getenv ("TEST_DATA" )
17-
18- data = {
19- "a" : read_surface_points (f"{ path_to_data } /a.dat" ),
20- "b" : read_surface_points (f"{ path_to_data } /b.dat" ),
21- "c" : read_surface_points (f"{ path_to_data } /c.dat" ),
22- "d" : read_surface_points (f"{ path_to_data } /d.dat" ),
23- "e" : read_surface_points (f"{ path_to_data } /e.dat" ),
24- "f" : read_surface_points (f"{ path_to_data } /f.dat" ),
25- }
26-
27- color_generator = gp .data .ColorsGenerator ()
28- elements = []
29- for event , pts in data .items ():
30- orientations = gp .data .OrientationsTable .initialize_empty ()
31- element = gp .data .StructuralElement (
32- name = event ,
33- color = next (color_generator ),
34- surface_points = pts ,
35- orientations = orientations ,
36- )
37- elements .append (element )
15+ color_generator , elements = _read_data ()
3816
3917 group = gp .data .StructuralGroup (
4018 name = "Series1" ,
@@ -46,65 +24,277 @@ def test_2025_1():
4624 structural_groups = [group ], color_gen = color_generator
4725 )
4826
49- xmin = 525816
50- xmax = 543233
51- ymin = 5652470
52- ymax = 5657860
53- zmin = - 780
54- zmax = - 636
55-
56- # * Add 20% to extent
57- xmin -= 0.2 * (xmax - xmin )
58- xmax += 0.2 * (xmax - xmin )
59- ymin -= 0.2 * (ymax - ymin )
60- ymax += 0.2 * (ymax - ymin )
61- zmin -= 0.2 * (zmax - zmin )
62- zmax += 0.2 * (zmax - zmin )
63-
64- geo_model = gp .create_geomodel (
65- project_name = "test" ,
66- extent = [xmin , xmax , ymin , ymax , zmin , zmax ],
67- refinement = 5 ,
68- structural_frame = structural_frame ,
69- )
70-
71- if False :
72- gpv .plot_3d (
73- model = geo_model ,
74- ve = 10 ,
75- image = True ,
76- kwargs_pyvista_bounds = {
77- 'show_xlabels' : False ,
78- 'show_ylabels' : False ,
79- }
80- )
27+ print (structural_frame )
28+ geo_model = _init_model (structural_frame )
29+
30+ range_ = 0.5
31+ orientation_loc = - 601
32+ geo_model .input_transform .scale /= np .array ([1 , 1 , 80 ])
8133
8234 geo_model .interpolation_options .evaluation_options .number_octree_levels_surface = 4
8335 geo_model .interpolation_options .kernel_options .range = range_
36+ geo_model .interpolation_options .kernel_options .compute_condition_number = True
37+
38+ if True :
39+ a_element = geo_model .structural_frame .get_element_by_name ("a" )
40+ delete = np .delete (a_element .surface_points .data , [2 ])
41+ a_element .surface_points .data = delete
8442
8543 gp .add_orientations (
8644 geo_model = geo_model ,
8745 x = [525825 ],
8846 y = [5651315 ],
8947 z = [orientation_loc ], # * Moving the orientation further
9048 pole_vector = [[0 , 0 , 1 ]],
49+ nugget = [4. ],
9150 elements_names = ["a" ]
9251 )
52+
53+ solution = gp .compute_model (
54+ geo_model ,
55+ engine_config = gp .data .GemPyEngineConfig (
56+ backend = gp .data .AvailableBackends .PYTORCH
57+ ),
58+ validate_serialization = False
59+ )
60+
61+ gpv .plot_3d (
62+ model = geo_model ,
63+ ve = 40 ,
64+ show_lith = False ,
65+ image = False ,
66+ show_boundaries = True ,
67+ show_nugget_effect = True ,
68+ kwargs_pyvista_bounds = {
69+ 'show_xlabels' : False ,
70+ 'show_ylabels' : False ,
71+ 'show_zlabels' : False ,
72+ }
73+ )
74+
75+
76+ def test_2025_splitting_into_2_groups ():
77+ color_generator , elements = _read_data ()
78+
79+ group = gp .data .StructuralGroup (
80+ name = "Series1" ,
81+ elements = elements [:4 ],
82+ structural_relation = gp .data .StackRelationType .ERODE ,
83+ fault_relations = gp .data .FaultsRelationSpecialCase .OFFSET_FORMATIONS ,
84+ )
85+
86+ group2 = gp .data .StructuralGroup (
87+ name = "Series2" ,
88+ elements = elements [4 :6 ],
89+ structural_relation = gp .data .StackRelationType .ERODE ,
90+ fault_relations = gp .data .FaultsRelationSpecialCase .OFFSET_FORMATIONS ,
91+ )
92+
93+ structural_frame = gp .data .StructuralFrame (
94+ structural_groups = [
95+ group ,
96+ group2 ,
97+ # group3
98+ ], color_gen = color_generator
99+ )
100+
101+ print (structural_frame )
102+ geo_model = _init_model (structural_frame )
103+
104+ if REMOVE_OUTLIER := True :
105+ a_element = geo_model .structural_frame .get_element_by_name ("a" )
106+ delete = np .delete (a_element .surface_points .data , [2 ])
107+ a_element .surface_points .data = delete
108+
109+ range_ = 0.5
110+ orientation_loc = - 601
111+ anisotropy_z = 1
112+ geo_model .input_transform .scale /= np .array ([1 , 1 , 1 ])
113+
114+ n_groups = 2
115+ gp .add_orientations (
116+ geo_model = geo_model ,
117+ x = [525_825 ] * n_groups ,
118+ y = [5_651_315 ] * n_groups ,
119+ z = [orientation_loc ] * n_groups , # * Moving the orientation further
120+ pole_vector = [
121+ [0 , 0 , 1 ],
122+ [0 , 0 , 1 ],
123+ ],
124+ elements_names = [
125+ "a" ,
126+ "e" ,
127+ ]
128+ )
129+
130+ # geo_model.structural_frame.structural_groups = [geo_model.structural_frame.structural_groups[1]]
131+
132+ geo_model .interpolation_options .evaluation_options .number_octree_levels_surface = 6
133+ geo_model .interpolation_options .kernel_options .range = range_
134+ geo_model .interpolation_options .kernel_options .compute_condition_number = True
135+
93136 solution = gp .compute_model (
94137 geo_model ,
95138 engine_config = gp .data .GemPyEngineConfig (
96- backend = gp .data .AvailableBackends .numpy
139+ backend = gp .data .AvailableBackends .PYTORCH
97140 ),
141+ validate_serialization = False
98142 )
99143
100144 gpv .plot_3d (
101145 model = geo_model ,
102- ve = 10 ,
146+ ve = 40 ,
103147 show_lith = False ,
104- image = True ,
148+ image = False ,
149+ show_boundaries = True ,
150+ show_nugget_effect = True ,
105151 kwargs_pyvista_bounds = {
106152 'show_xlabels' : False ,
107153 'show_ylabels' : False ,
108154 'show_zlabels' : False ,
155+ },
156+ kwargs_plot_surfaces = {
157+ # "opacity": 0.5
109158 }
110159 )
160+ def test_2025_splitting_into_3_groups ():
161+ color_generator , elements = _read_data ()
162+
163+ group = gp .data .StructuralGroup (
164+ name = "Series1" ,
165+ elements = elements [:4 ],
166+ structural_relation = gp .data .StackRelationType .ERODE ,
167+ fault_relations = gp .data .FaultsRelationSpecialCase .OFFSET_FORMATIONS ,
168+ )
169+
170+ group2 = gp .data .StructuralGroup (
171+ name = "Series2" ,
172+ elements = elements [4 :5 ],
173+ structural_relation = gp .data .StackRelationType .ERODE ,
174+ fault_relations = gp .data .FaultsRelationSpecialCase .OFFSET_FORMATIONS ,
175+ )
176+
177+
178+ group3 = gp .data .StructuralGroup (
179+ name = "Series3" ,
180+ elements = elements [5 :],
181+ structural_relation = gp .data .StackRelationType .ERODE ,
182+ fault_relations = gp .data .FaultsRelationSpecialCase .OFFSET_FORMATIONS ,
183+ )
184+
185+ structural_frame = gp .data .StructuralFrame (
186+ structural_groups = [
187+ group ,
188+ group2 ,
189+ group3
190+ ], color_gen = color_generator
191+ )
192+
193+ print (structural_frame )
194+ geo_model = _init_model (structural_frame )
195+
196+ if REMOVE_OUTLIER := True :
197+ a_element = geo_model .structural_frame .get_element_by_name ("a" )
198+ delete = np .delete (a_element .surface_points .data , [2 ])
199+ a_element .surface_points .data = delete
200+
201+ range_ = 0.5
202+ orientation_loc = - 601
203+ anisotropy_z = 1
204+ geo_model .input_transform .scale /= np .array ([1 , 1 , 1 ])
205+
206+ n_groups = 3
207+ gp .add_orientations (
208+ geo_model = geo_model ,
209+ x = [525_825 ] * n_groups ,
210+ y = [5_651_315 ] * n_groups ,
211+ z = [orientation_loc ] * n_groups , # * Moving the orientation further
212+ pole_vector = [
213+ [0 , 0 , 1 ],
214+ [0 , 0 , 1 ],
215+ [0 , 0 , 1 ],
216+ ],
217+ elements_names = [
218+ "a" ,
219+ "e" ,
220+ "f"
221+ ]
222+ )
223+
224+ # geo_model.structural_frame.structural_groups = [geo_model.structural_frame.structural_groups[1]]
225+
226+ geo_model .interpolation_options .evaluation_options .number_octree_levels_surface = 6
227+ geo_model .interpolation_options .kernel_options .range = range_
228+ geo_model .interpolation_options .kernel_options .compute_condition_number = True
229+
230+ solution = gp .compute_model (
231+ geo_model ,
232+ engine_config = gp .data .GemPyEngineConfig (
233+ backend = gp .data .AvailableBackends .PYTORCH
234+ ),
235+ validate_serialization = False
236+ )
237+
238+ gpv .plot_3d (
239+ model = geo_model ,
240+ ve = 40 ,
241+ show_lith = False ,
242+ image = False ,
243+ show_boundaries = True ,
244+ show_nugget_effect = True ,
245+ kwargs_pyvista_bounds = {
246+ 'show_xlabels' : False ,
247+ 'show_ylabels' : False ,
248+ 'show_zlabels' : False ,
249+ },
250+ kwargs_plot_surfaces = {
251+ # "opacity": 0.5
252+ }
253+ )
254+
255+
256+ def _init_model (structural_frame ):
257+ xmin = 525_816
258+ xmax = 543_233
259+ ymin = 5_652_470
260+ ymax = 5_657_860
261+ zmin = - 780
262+ zmax = - 636
263+ # * Add 20% to extent
264+ xmin -= 0.2 * (xmax - xmin )
265+ xmax += 0.2 * (xmax - xmin )
266+ ymin -= 0.2 * (ymax - ymin )
267+ ymax += 0.2 * (ymax - ymin )
268+ zmin -= 0.2 * (zmax - zmin )
269+ zmax += 0.2 * (zmax - zmin )
270+ geo_model : gp .data .GeoModel = gp .create_geomodel (
271+ project_name = "test" ,
272+ extent = [xmin , xmax , ymin , ymax , zmin , zmax ],
273+ refinement = 5 ,
274+ structural_frame = structural_frame ,
275+ )
276+ return geo_model
277+
278+
279+ def _read_data ():
280+ path_to_data = os .getenv ("TEST_DATA" )
281+ data = {
282+ "a" : read_surface_points (f"{ path_to_data } /a.dat" ),
283+ "b" : read_surface_points (f"{ path_to_data } /b.dat" ),
284+ "c" : read_surface_points (f"{ path_to_data } /c.dat" ),
285+ "d" : read_surface_points (f"{ path_to_data } /d.dat" ),
286+ "e" : read_surface_points (f"{ path_to_data } /e.dat" ),
287+ "f" : read_surface_points (f"{ path_to_data } /f.dat" ),
288+ }
289+ color_generator = gp .data .ColorsGenerator ()
290+ elements = []
291+ for event , pts in data .items ():
292+ orientations = gp .data .OrientationsTable .initialize_empty ()
293+ element = gp .data .StructuralElement (
294+ name = event ,
295+ color = next (color_generator ),
296+ surface_points = pts ,
297+ orientations = orientations ,
298+ )
299+ elements .append (element )
300+ return color_generator , elements
0 commit comments