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