-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# from mpi4py.MPI import COMM_WORLD | ||
# import debugpy | ||
# debugpy.listen(3000 + COMM_WORLD.rank) | ||
# debugpy.wait_for_client() | ||
import spyro | ||
import numpy as np | ||
|
||
|
||
def test_real_shot_record_generation_parallel(): | ||
dictionary = {} | ||
dictionary["absorving_boundary_conditions"] = { | ||
"pad_length": 2.0, # True or false | ||
} | ||
dictionary["mesh"] = { | ||
"h": 0.05, # mesh size in km | ||
} | ||
dictionary["polygon_options"] = { | ||
"water_layer_is_present": True, | ||
"upper_layer": 2.0, | ||
"middle_layer": 2.5, | ||
"lower_layer": 3.0, | ||
"polygon_layer_perturbation": 0.3, | ||
} | ||
dictionary["acquisition"] = { | ||
"source_locations": spyro.create_transect((-0.1, 0.1), (-0.1, 0.9), 4), | ||
"frequency": 5.0, | ||
"receiver_locations": spyro.create_transect((-0.16, 0.1), (-0.16, 0.9), 100), | ||
} | ||
dictionary["visualization"] = { | ||
"debug_output": True, | ||
} | ||
dictionary["time_axis"] = { | ||
"final_time": 1.0, # Final time for event | ||
"dt": 0.0005, # timestep size | ||
"amplitude": 1, # the Ricker has an amplitude of 1. | ||
"output_frequency": 500, # how frequently to output solution to pvds | ||
# how frequently to save solution to RAM | ||
"gradient_sampling_frequency": 1, | ||
} | ||
fwi = spyro.examples.Polygon_acoustic_FWI(dictionary=dictionary, periodic=True) | ||
fwi.generate_real_shot_record(plot_model=True, save_shot_record=True) | ||
|
||
dictionary["inversion"] = { | ||
"real_shot_record_files": "shots/shot_record_", | ||
} | ||
fwi2 = spyro.examples.Polygon_acoustic_FWI(dictionary=dictionary, periodic=True) | ||
|
||
max_value = np.max(fwi2.real_shot_record[:, fwi2.comm.ensemble_comm.rank*33]) | ||
test_core = np.isclose(max_value, 0.184, atol=1e-2) | ||
|
||
test_core_all = fwi2.comm.ensemble_comm.allgather(test_core) | ||
test = all(test_core_all) | ||
|
||
print(f"Correctly loaded shots: {test}", flush=True) | ||
|
||
assert test | ||
|
||
|
||
if __name__ == "__main__": | ||
test_real_shot_record_generation_parallel() |