Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[TEST] Breaking down tests
  • Loading branch information
Leguark committed Jun 12, 2025
commit 43773e744d654fc2303d5a556d77e6e42e01799d
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,61 @@
PLOT = True


def test_compute_at_computation_time():
def test_compute_time_topo_dense_grid():
geo_model: gp.data.GeoModel = _setup_model()

# Compute a solution for the model
geo_model.grid.active_grids = gp.data.Grid.GridTypes.TOPOGRAPHY
start_time = time.perf_counter()
gp.compute_model(geo_model)
print(f"Computing model on grids: {geo_model.grid.active_grids}")
end_time = time.perf_counter()
computation_time_topo = end_time - start_time


geo_model.grid.active_grids = gp.data.Grid.GridTypes.DENSE
start_time = time.perf_counter()
gp.compute_model(geo_model)
print(f"Computing model on grids: {geo_model.grid.active_grids}")
end_time = time.perf_counter()
computation_time_dense = end_time - start_time

# Recompute model as a new grid was added
geo_model.grid.active_grids = gp.data.Grid.GridTypes.TOPOGRAPHY | gp.data.Grid.GridTypes.DENSE
start_time = time.perf_counter()
gp.compute_model(geo_model)
print(f"Computing model on grids: {geo_model.grid.active_grids}")
end_time = time.perf_counter()
computation_time_topo_dense = end_time - start_time


print(f"Computation only model dense grid 125*50*50: {computation_time_dense:.2f} seconds")
print(f"Computation time with topography 125*50: {computation_time_topo:.2f} seconds")
print(f"Computation time with topography and dense grid 125*50*50: {computation_time_topo_dense:.2f} seconds")


def test_compute_time_custom_dense_grid():
geo_model: gp.data.GeoModel = _setup_model()

# numpy array with random coordinates within the extent of the model
custom_coordinates = np.random.uniform(
low=geo_model.grid.extent[:3],
high=geo_model.grid.extent[3:],
size=(1000, 3)
)

start_time = time.perf_counter()
gp.compute_model_at(geo_model, custom_coordinates)
end_time = time.perf_counter()
computation_time_at = end_time - start_time

print(f"Computation compute_at with 1000 custom points: {computation_time_at:.2f} seconds")


def _setup_model():
# Define the path to data
data_path = 'https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/'
path_to_data = data_path + "/data/input_data/jan_models/"

# Create a GeoModel instance
geo_model = gp.create_geomodel(
project_name='EGU_example',
Expand All @@ -22,53 +71,22 @@ def test_compute_at_computation_time():
path_to_surface_points=path_to_data + "model7_surface_points.csv"
)
)

# Map geological series to surfaces
gp.map_stack_to_surfaces(
gempy_model=geo_model,
mapping_object={
"Fault_Series": ('fault'),
"Strat_Series1": ('rock3'),
"Strat_Series2": ('rock2', 'rock1'),
"Fault_Series" : ('fault'),
"Strat_Series1": ('rock3'),
"Strat_Series2": ('rock2', 'rock1'),
}
)

# Define youngest structural group as fault
gp.set_is_fault(geo_model, ["Fault_Series"])

# Compute a solution for the model
start_time = time.perf_counter()
gp.compute_model(geo_model)
end_time = time.perf_counter()
computation_time_model = end_time - start_time

# Setting a randomly generated topography
gp.set_topography_from_random(
grid=geo_model.grid,
fractal_dimension=2,
d_z=np.array([700, 950]),
topography_resolution=np.array([125, 50])
)

# Recompute model as a new grid was added
start_time = time.perf_counter()
gp.compute_model(geo_model)
end_time = time.perf_counter()
computation_time_topo = end_time - start_time

# numpy array with random coordinates within the extent of the model
custom_coordinates = np.random.uniform(
low=geo_model.grid.extent[:3],
high=geo_model.grid.extent[3:],
size=(1000, 3)
)

start_time = time.perf_counter()
gp.compute_model_at(geo_model, custom_coordinates)
end_time = time.perf_counter()
computation_time_at = end_time - start_time

print(f"Computation only model dense grid 125*50*50: {computation_time_model:.2f} seconds")
print(f"Computation time with topography 125*50: {computation_time_topo:.2f} seconds")
print(f"Computation compute_at with 1000 custom points: {computation_time_at:.2f} seconds")

return geo_model