5
5
6
6
PLOT = True
7
7
8
+ def test_compute_time_dense_dense ():
8
9
9
- def test_compute_time_topo_dense_grid ():
10
10
geo_model : gp .data .GeoModel = _setup_model ()
11
11
12
- # Compute a solution for the model
13
- geo_model .grid .active_grids = gp .data .Grid .GridTypes .TOPOGRAPHY
12
+ geo_model .grid .active_grids = gp .data .Grid .GridTypes .DENSE
14
13
start_time = time .perf_counter ()
15
14
gp .compute_model (geo_model )
16
15
print (f"Computing model on grids: { geo_model .grid .active_grids } " )
17
16
end_time = time .perf_counter ()
18
- computation_time_topo = end_time - start_time
17
+ computation_time_dense_I = end_time - start_time
18
+
19
+
20
+ start_time = time .perf_counter ()
21
+ gp .compute_model (geo_model )
22
+ print (f"Computing model on grids: { geo_model .grid .active_grids } " )
23
+ end_time = time .perf_counter ()
24
+ computation_time_dense_II = end_time - start_time
25
+
26
+
27
+ start_time = time .perf_counter ()
28
+ gp .compute_model (geo_model )
29
+ print (f"Computing model on grids: { geo_model .grid .active_grids } " )
30
+ end_time = time .perf_counter ()
31
+ computation_time_dense_III = end_time - start_time
32
+
33
+ print (f"Computation only model dense grid 125*50*50: { computation_time_dense_I :.2f} seconds" )
34
+ print (f"Computation only model dense grid 125*50*50: { computation_time_dense_II :.2f} seconds" )
35
+ print (f"Computation only model dense grid 125*50*50: { computation_time_dense_III :.2f} seconds" )
19
36
20
37
38
+ def test_compute_time_topo_dense_grid ():
39
+ geo_model : gp .data .GeoModel = _setup_model ()
40
+
21
41
geo_model .grid .active_grids = gp .data .Grid .GridTypes .DENSE
22
42
start_time = time .perf_counter ()
23
43
gp .compute_model (geo_model )
24
44
print (f"Computing model on grids: { geo_model .grid .active_grids } " )
25
45
end_time = time .perf_counter ()
26
46
computation_time_dense = end_time - start_time
47
+
48
+ # Compute a solution for the model
49
+ geo_model .grid .active_grids = gp .data .Grid .GridTypes .TOPOGRAPHY
50
+ start_time = time .perf_counter ()
51
+ gp .compute_model (geo_model )
52
+ print (f"Computing model on grids: { geo_model .grid .active_grids } " )
53
+ end_time = time .perf_counter ()
54
+ computation_time_topo = end_time - start_time
55
+
27
56
28
57
# Recompute model as a new grid was added
29
58
geo_model .grid .active_grids = gp .data .Grid .GridTypes .TOPOGRAPHY | gp .data .Grid .GridTypes .DENSE
@@ -37,6 +66,11 @@ def test_compute_time_topo_dense_grid():
37
66
print (f"Computation only model dense grid 125*50*50: { computation_time_dense :.2f} seconds" )
38
67
print (f"Computation time with topography 125*50: { computation_time_topo :.2f} seconds" )
39
68
print (f"Computation time with topography and dense grid 125*50*50: { computation_time_topo_dense :.2f} seconds" )
69
+ """
70
+ Computation only model dense grid 125*50*50: 79.56 seconds
71
+ Computation time with topography 125*50: 5.34 seconds
72
+ Computation time with topography and dense grid 125*50*50: 59.24 seconds
73
+ """
40
74
41
75
42
76
def test_compute_time_custom_dense_grid ():
@@ -57,6 +91,85 @@ def test_compute_time_custom_dense_grid():
57
91
print (f"Computation compute_at with 1000 custom points: { computation_time_at :.2f} seconds" )
58
92
59
93
94
+ def test_compute_at_computation_time ():
95
+
96
+ # Define the path to data
97
+ data_path = 'https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/'
98
+ path_to_data = data_path + "/data/input_data/jan_models/"
99
+
100
+ # Create a GeoModel instance
101
+ geo_model = gp .create_geomodel (
102
+ project_name = 'EGU_example' ,
103
+ extent = [0 , 2500 , 0 , 1000 , 0 , 1000 ],
104
+ resolution = [125 , 50 , 50 ],
105
+ importer_helper = gp .data .ImporterHelper (
106
+ path_to_orientations = path_to_data + "model7_orientations.csv" ,
107
+ path_to_surface_points = path_to_data + "model7_surface_points.csv"
108
+ )
109
+ )
110
+
111
+ # Map geological series to surfaces
112
+ gp .map_stack_to_surfaces (
113
+ gempy_model = geo_model ,
114
+ mapping_object = {
115
+ "Fault_Series" : ('fault' ),
116
+ "Strat_Series1" : ('rock3' ),
117
+ "Strat_Series2" : ('rock2' , 'rock1' ),
118
+ }
119
+ )
120
+
121
+ # Define youngest structural group as fault
122
+ gp .set_is_fault (geo_model , ["Fault_Series" ])
123
+
124
+ # Compute a solution for the model
125
+ start_time = time .perf_counter ()
126
+ gp .compute_model (geo_model )
127
+ print (f"Computing model on grids: { geo_model .grid .active_grids } " )
128
+ end_time = time .perf_counter ()
129
+ computation_time_model = end_time - start_time
130
+
131
+ return
132
+
133
+ # Setting a randomly generated topography
134
+ gp .set_topography_from_random (
135
+ grid = geo_model .grid ,
136
+ fractal_dimension = 2 ,
137
+ d_z = np .array ([700 , 950 ]),
138
+ topography_resolution = np .array ([125 , 50 ])
139
+ )
140
+
141
+ # Recompute model as a new grid was added
142
+ start_time = time .perf_counter ()
143
+ gp .compute_model (geo_model )
144
+ print (f"Computing model on grids: { geo_model .grid .active_grids } " )
145
+ end_time = time .perf_counter ()
146
+ computation_time_topo = end_time - start_time
147
+
148
+ # numpy array with random coordinates within the extent of the model
149
+ custom_coordinates = np .random .uniform (
150
+ low = geo_model .grid .extent [:3 ],
151
+ high = geo_model .grid .extent [3 :],
152
+ size = (1000 , 3 )
153
+ )
154
+
155
+ start_time = time .perf_counter ()
156
+ gp .compute_model_at (geo_model , custom_coordinates )
157
+ print (f"Computing model on grids: { geo_model .grid .active_grids } " )
158
+ end_time = time .perf_counter ()
159
+ computation_time_at = end_time - start_time
160
+
161
+ print (f"Computation only model dense grid 125*50*50: { computation_time_model :.2f} seconds" )
162
+ print (f"Computation time with topography 125*50: { computation_time_topo :.2f} seconds" )
163
+ print (f"Computation compute_at with 1000 custom points: { computation_time_at :.2f} seconds" )
164
+
165
+ """
166
+ Computation only model dense grid 125*50*50: 19.96 seconds
167
+ Computation time with topography 125*50: 60.75 seconds
168
+ Computation compute_at with 1000 custom points: 7.88 seconds
169
+ """
170
+
171
+
172
+
60
173
def _setup_model ():
61
174
# Define the path to data
62
175
data_path = 'https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/'
0 commit comments