6
6
PLOT = True
7
7
8
8
9
- def test_compute_at_computation_time ():
9
+ def test_compute_time_topo_dense_grid ():
10
+ geo_model : gp .data .GeoModel = _setup_model ()
10
11
12
+ # Compute a solution for the model
13
+ geo_model .grid .active_grids = gp .data .Grid .GridTypes .TOPOGRAPHY
14
+ start_time = time .perf_counter ()
15
+ gp .compute_model (geo_model )
16
+ print (f"Computing model on grids: { geo_model .grid .active_grids } " )
17
+ end_time = time .perf_counter ()
18
+ computation_time_topo = end_time - start_time
19
+
20
+
21
+ geo_model .grid .active_grids = gp .data .Grid .GridTypes .DENSE
22
+ start_time = time .perf_counter ()
23
+ gp .compute_model (geo_model )
24
+ print (f"Computing model on grids: { geo_model .grid .active_grids } " )
25
+ end_time = time .perf_counter ()
26
+ computation_time_dense = end_time - start_time
27
+
28
+ # Recompute model as a new grid was added
29
+ geo_model .grid .active_grids = gp .data .Grid .GridTypes .TOPOGRAPHY | gp .data .Grid .GridTypes .DENSE
30
+ start_time = time .perf_counter ()
31
+ gp .compute_model (geo_model )
32
+ print (f"Computing model on grids: { geo_model .grid .active_grids } " )
33
+ end_time = time .perf_counter ()
34
+ computation_time_topo_dense = end_time - start_time
35
+
36
+
37
+ print (f"Computation only model dense grid 125*50*50: { computation_time_dense :.2f} seconds" )
38
+ print (f"Computation time with topography 125*50: { computation_time_topo :.2f} seconds" )
39
+ print (f"Computation time with topography and dense grid 125*50*50: { computation_time_topo_dense :.2f} seconds" )
40
+
41
+
42
+ def test_compute_time_custom_dense_grid ():
43
+ geo_model : gp .data .GeoModel = _setup_model ()
44
+
45
+ # numpy array with random coordinates within the extent of the model
46
+ custom_coordinates = np .random .uniform (
47
+ low = geo_model .grid .extent [:3 ],
48
+ high = geo_model .grid .extent [3 :],
49
+ size = (1000 , 3 )
50
+ )
51
+
52
+ start_time = time .perf_counter ()
53
+ gp .compute_model_at (geo_model , custom_coordinates )
54
+ end_time = time .perf_counter ()
55
+ computation_time_at = end_time - start_time
56
+
57
+ print (f"Computation compute_at with 1000 custom points: { computation_time_at :.2f} seconds" )
58
+
59
+
60
+ def _setup_model ():
11
61
# Define the path to data
12
62
data_path = 'https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/'
13
63
path_to_data = data_path + "/data/input_data/jan_models/"
14
-
15
64
# Create a GeoModel instance
16
65
geo_model = gp .create_geomodel (
17
66
project_name = 'EGU_example' ,
@@ -22,53 +71,22 @@ def test_compute_at_computation_time():
22
71
path_to_surface_points = path_to_data + "model7_surface_points.csv"
23
72
)
24
73
)
25
-
26
74
# Map geological series to surfaces
27
75
gp .map_stack_to_surfaces (
28
76
gempy_model = geo_model ,
29
77
mapping_object = {
30
- "Fault_Series" : ('fault' ),
31
- "Strat_Series1" : ('rock3' ),
32
- "Strat_Series2" : ('rock2' , 'rock1' ),
78
+ "Fault_Series" : ('fault' ),
79
+ "Strat_Series1" : ('rock3' ),
80
+ "Strat_Series2" : ('rock2' , 'rock1' ),
33
81
}
34
82
)
35
-
36
83
# Define youngest structural group as fault
37
84
gp .set_is_fault (geo_model , ["Fault_Series" ])
38
-
39
- # Compute a solution for the model
40
- start_time = time .perf_counter ()
41
- gp .compute_model (geo_model )
42
- end_time = time .perf_counter ()
43
- computation_time_model = end_time - start_time
44
-
45
85
# Setting a randomly generated topography
46
86
gp .set_topography_from_random (
47
87
grid = geo_model .grid ,
48
88
fractal_dimension = 2 ,
49
89
d_z = np .array ([700 , 950 ]),
50
90
topography_resolution = np .array ([125 , 50 ])
51
91
)
52
-
53
- # Recompute model as a new grid was added
54
- start_time = time .perf_counter ()
55
- gp .compute_model (geo_model )
56
- end_time = time .perf_counter ()
57
- computation_time_topo = end_time - start_time
58
-
59
- # numpy array with random coordinates within the extent of the model
60
- custom_coordinates = np .random .uniform (
61
- low = geo_model .grid .extent [:3 ],
62
- high = geo_model .grid .extent [3 :],
63
- size = (1000 , 3 )
64
- )
65
-
66
- start_time = time .perf_counter ()
67
- gp .compute_model_at (geo_model , custom_coordinates )
68
- end_time = time .perf_counter ()
69
- computation_time_at = end_time - start_time
70
-
71
- print (f"Computation only model dense grid 125*50*50: { computation_time_model :.2f} seconds" )
72
- print (f"Computation time with topography 125*50: { computation_time_topo :.2f} seconds" )
73
- print (f"Computation compute_at with 1000 custom points: { computation_time_at :.2f} seconds" )
74
-
92
+ return geo_model
0 commit comments