Gar6more2D
%config Completer.use_jedi = False
%matplotlib inline
# Stdlib packages
import os
import pathlib
import shutil
import subprocess
# Third party packages
import matplotlib.pyplot as plt
import numpy as np
import obspy
import pyasdf
# Import things from SalvusFlow
from salvus.flow import api
# Configuration helpers from SalvusFlow.
import salvus.flow.simple_config as sc
# And some helper functions to run the integration tests.
from integration_test_mesh_helper import (
get_mesh,
Physics,
AnalyticCode,
read_gar6more,
)
# Number of processes SalvusCompute will run with.
# Get it from the environment or default to 4.
MPI_RANKS = int(os.environ.get("NUM_MPI_RANKS", 4))
# Choose on which site to run this.
SALVUS_FLOW_SITE_NAME = os.environ.get("SITE_NAME", "local")
# Set up the paths for the Gar6more2D data and binaries.
gar6more2d_base_path = pathlib.Path("gar6more2d")
gar6more2d_build_path = gar6more2d_base_path / "build"
gar6more2d_bin = gar6more2d_build_path / "Gar6more2D.out"
gar6more2d_par_file_path = gar6more2d_build_path / "Gar6more2D.dat"
# Compile Gar6more2D
os.makedirs(gar6more2d_build_path, exist_ok=True)
if not os.path.exists(gar6more2d_bin):
assert (
subprocess.run(["cmake", ".."], cwd=gar6more2d_build_path).returncode
== 0
)
assert subprocess.run(["make"], cwd=gar6more2d_build_path).returncode == 0
-- The C compiler identification is GNU 9.4.0 -- The CXX compiler identification is GNU 9.4.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Looking for sgemm_ -- Looking for sgemm_ - not found -- Looking for pthread.h -- Looking for pthread.h - found -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE -- Looking for sgemm_ -- Looking for sgemm_ - found -- Found BLAS: /usr/lib/x86_64-linux-gnu/libblas.so -- Looking for cheev_ -- Looking for cheev_ - not found -- Looking for cheev_ -- Looking for cheev_ - found -- A library with LAPACK API found. -- The Fortran compiler identification is GNU 9.4.0 -- Check for working Fortran compiler: /usr/bin/gfortran -- Check for working Fortran compiler: /usr/bin/gfortran -- works -- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done -- Checking whether /usr/bin/gfortran supports Fortran 90 -- Checking whether /usr/bin/gfortran supports Fortran 90 -- yes -- Found: /tmp/tmp3x5dl1s8/gar6more2d/mod/m_const.F90;/tmp/tmp3x5dl1s8/gar6more2d/mod/m_num.F90;/tmp/tmp3x5dl1s8/gar6more2d/mod/m_phys.F90;/tmp/tmp3x5dl1s8/gar6more2d/mod/m_result.F90;/tmp/tmp3x5dl1s8/gar6more2d/mod/m_sismo.F90;/tmp/tmp3x5dl1s8/gar6more2d/mod/m_source.F90 -- Found: /tmp/tmp3x5dl1s8/gar6more2d/lib/libacousacous/acousacous.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libacousacous/sub_incid_aa.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libacousacous/sub_reflex_aa.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libacousacous/sub_reflex_free_aa.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libacousacous/sub_reflex_wall_aa.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libacousacous/sub_transmit_aa.F90 -- Found: /tmp/tmp3x5dl1s8/gar6more2d/lib/libacouselasto/acouselasto.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libacouselasto/sub_incid_ae.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libacouselasto/sub_reflex_ae.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libacouselasto/sub_transmitp_ae.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libacouselasto/sub_transmits_ae.F90 -- Found: /tmp/tmp3x5dl1s8/gar6more2d/lib/libelastoelasto/calccoeffP_ee.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libelastoelasto/calccoeffS_ee.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libelastoelasto/elastoelasto.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libelastoelasto/sub_incidP_ee.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libelastoelasto/sub_incidS_ee.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libelastoelasto/sub_reflexPP_ee.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libelastoelasto/sub_reflexPP_free_ee.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libelastoelasto/sub_reflexPP_wall_ee.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libelastoelasto/sub_reflexPS_ee.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libelastoelasto/sub_reflexPS_free_ee.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libelastoelasto/sub_reflexPS_wall_ee.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libelastoelasto/sub_reflexSP_ee.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libelastoelasto/sub_reflexSP_free_ee.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libelastoelasto/sub_reflexSP_wall_ee.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libelastoelasto/sub_reflexSS_ee.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libelastoelasto/sub_reflexSS_free_ee.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libelastoelasto/sub_reflexSS_wall_ee.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libelastoelasto/sub_transmitPP_ee.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libelastoelasto/sub_transmitPS_ee.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libelastoelasto/sub_transmitSP_ee.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libelastoelasto/sub_transmitSS_ee.F90 -- Found: /tmp/tmp3x5dl1s8/gar6more2d/lib/libgeneral/arrivaltime.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libgeneral/derivee.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libgeneral/path.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libgeneral/source.F90 -- Found: /tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/calccoefff_free_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/calccoefff_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/calccoefff_wall_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/calccoeffs_free_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/calccoeffs_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/calccoeffs_wall_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/poroporo.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_incid_pp_f.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_incid_pp_s.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_reflexff_free_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_reflexff_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_reflexff_wall_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_reflexfpsi_free_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_reflexfpsi_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_reflexfpsi_wall_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_reflexfs_free_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_reflexfs_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_reflexfs_wall_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_reflexsf_free_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_reflexsf_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_reflexsf_wall_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_reflexspsi_free_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_reflexspsi_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_reflexspsi_wall_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_reflexss_free_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_reflexss_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_reflexss_wall_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_transmitff_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_transmitfpsi_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_transmitfs_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_transmitsf_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_transmitspsi_pp.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libporoporo/sub_transmitss_pp.F90 -- Found: /tmp/tmp3x5dl1s8/gar6more2d/lib/libacousporo/acousporo.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libacousporo/calccoeff_ap.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libacousporo/sub_incid_ap.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libacousporo/sub_reflex_ap.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libacousporo/sub_transmitf_ap.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libacousporo/sub_transmitpsi_ap.F90;/tmp/tmp3x5dl1s8/gar6more2d/lib/libacousporo/sub_transmits_ap.F90 -- Configuring done -- Generating done -- Build files have been written to: /tmp/tmp3x5dl1s8/gar6more2d/build Scanning dependencies of target mod [ 1%] Building Fortran object mod/CMakeFiles/mod.dir/m_const.F90.o [ 2%] Building Fortran object mod/CMakeFiles/mod.dir/m_num.F90.o [ 3%] Building Fortran object mod/CMakeFiles/mod.dir/m_phys.F90.o [ 4%] Building Fortran object mod/CMakeFiles/mod.dir/m_result.F90.o [ 5%] Building Fortran object mod/CMakeFiles/mod.dir/m_sismo.F90.o [ 6%] Building Fortran object mod/CMakeFiles/mod.dir/m_source.F90.o [ 7%] Linking Fortran static library libmod.a [ 7%] Built target mod Scanning dependencies of target acousporo [ 8%] Building Fortran object lib/libacousporo/CMakeFiles/acousporo.dir/acousporo.F90.o [ 9%] Building Fortran object lib/libacousporo/CMakeFiles/acousporo.dir/calccoeff_ap.F90.o [ 10%] Building Fortran object lib/libacousporo/CMakeFiles/acousporo.dir/sub_incid_ap.F90.o [ 12%] Building Fortran object lib/libacousporo/CMakeFiles/acousporo.dir/sub_reflex_ap.F90.o [ 13%] Building Fortran object lib/libacousporo/CMakeFiles/acousporo.dir/sub_transmitf_ap.F90.o [ 14%] Building Fortran object lib/libacousporo/CMakeFiles/acousporo.dir/sub_transmitpsi_ap.F90.o [ 15%] Building Fortran object lib/libacousporo/CMakeFiles/acousporo.dir/sub_transmits_ap.F90.o [ 16%] Linking Fortran static library libacousporo.a [ 16%] Built target acousporo Scanning dependencies of target acousacous [ 17%] Building Fortran object lib/libacousacous/CMakeFiles/acousacous.dir/acousacous.F90.o [ 18%] Building Fortran object lib/libacousacous/CMakeFiles/acousacous.dir/sub_incid_aa.F90.o [ 19%] Building Fortran object lib/libacousacous/CMakeFiles/acousacous.dir/sub_reflex_aa.F90.o [ 20%] Building Fortran object lib/libacousacous/CMakeFiles/acousacous.dir/sub_reflex_free_aa.F90.o [ 21%] Building Fortran object lib/libacousacous/CMakeFiles/acousacous.dir/sub_reflex_wall_aa.F90.o [ 23%] Building Fortran object lib/libacousacous/CMakeFiles/acousacous.dir/sub_transmit_aa.F90.o [ 24%] Linking Fortran static library libacousacous.a [ 24%] Built target acousacous Scanning dependencies of target acouselasto [ 25%] Building Fortran object lib/libacouselasto/CMakeFiles/acouselasto.dir/acouselasto.F90.o [ 26%] Building Fortran object lib/libacouselasto/CMakeFiles/acouselasto.dir/sub_incid_ae.F90.o [ 27%] Building Fortran object lib/libacouselasto/CMakeFiles/acouselasto.dir/sub_reflex_ae.F90.o
[ 28%] Building Fortran object lib/libacouselasto/CMakeFiles/acouselasto.dir/sub_transmitp_ae.F90.o [ 29%] Building Fortran object lib/libacouselasto/CMakeFiles/acouselasto.dir/sub_transmits_ae.F90.o [ 30%] Linking Fortran static library libacouselasto.a [ 30%] Built target acouselasto Scanning dependencies of target elastoelasto [ 31%] Building Fortran object lib/libelastoelasto/CMakeFiles/elastoelasto.dir/calccoeffP_ee.F90.o [ 32%] Building Fortran object lib/libelastoelasto/CMakeFiles/elastoelasto.dir/calccoeffS_ee.F90.o [ 34%] Building Fortran object lib/libelastoelasto/CMakeFiles/elastoelasto.dir/elastoelasto.F90.o [ 35%] Building Fortran object lib/libelastoelasto/CMakeFiles/elastoelasto.dir/sub_incidP_ee.F90.o [ 36%] Building Fortran object lib/libelastoelasto/CMakeFiles/elastoelasto.dir/sub_incidS_ee.F90.o [ 37%] Building Fortran object lib/libelastoelasto/CMakeFiles/elastoelasto.dir/sub_reflexPP_ee.F90.o [ 38%] Building Fortran object lib/libelastoelasto/CMakeFiles/elastoelasto.dir/sub_reflexPP_free_ee.F90.o [ 39%] Building Fortran object lib/libelastoelasto/CMakeFiles/elastoelasto.dir/sub_reflexPP_wall_ee.F90.o [ 40%] Building Fortran object lib/libelastoelasto/CMakeFiles/elastoelasto.dir/sub_reflexPS_ee.F90.o [ 41%] Building Fortran object lib/libelastoelasto/CMakeFiles/elastoelasto.dir/sub_reflexPS_free_ee.F90.o [ 42%] Building Fortran object lib/libelastoelasto/CMakeFiles/elastoelasto.dir/sub_reflexPS_wall_ee.F90.o [ 43%] Building Fortran object lib/libelastoelasto/CMakeFiles/elastoelasto.dir/sub_reflexSP_ee.F90.o [ 45%] Building Fortran object lib/libelastoelasto/CMakeFiles/elastoelasto.dir/sub_reflexSP_free_ee.F90.o [ 46%] Building Fortran object lib/libelastoelasto/CMakeFiles/elastoelasto.dir/sub_reflexSP_wall_ee.F90.o [ 47%] Building Fortran object lib/libelastoelasto/CMakeFiles/elastoelasto.dir/sub_reflexSS_ee.F90.o [ 48%] Building Fortran object lib/libelastoelasto/CMakeFiles/elastoelasto.dir/sub_reflexSS_free_ee.F90.o [ 49%] Building Fortran object lib/libelastoelasto/CMakeFiles/elastoelasto.dir/sub_reflexSS_wall_ee.F90.o [ 50%] Building Fortran object lib/libelastoelasto/CMakeFiles/elastoelasto.dir/sub_transmitPP_ee.F90.o [ 51%] Building Fortran object lib/libelastoelasto/CMakeFiles/elastoelasto.dir/sub_transmitPS_ee.F90.o [ 52%] Building Fortran object lib/libelastoelasto/CMakeFiles/elastoelasto.dir/sub_transmitSP_ee.F90.o [ 53%] Building Fortran object lib/libelastoelasto/CMakeFiles/elastoelasto.dir/sub_transmitSS_ee.F90.o [ 54%] Linking Fortran static library libelastoelasto.a [ 54%] Built target elastoelasto Scanning dependencies of target gene [ 56%] Building Fortran object lib/libgeneral/CMakeFiles/gene.dir/arrivaltime.F90.o [ 57%] Building Fortran object lib/libgeneral/CMakeFiles/gene.dir/derivee.F90.o [ 58%] Building Fortran object lib/libgeneral/CMakeFiles/gene.dir/path.F90.o [ 59%] Building Fortran object lib/libgeneral/CMakeFiles/gene.dir/source.F90.o [ 60%] Linking Fortran static library libgene.a [ 60%] Built target gene Scanning dependencies of target poroporo [ 61%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/calccoefff_free_pp.F90.o [ 62%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/calccoefff_pp.F90.o [ 63%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/calccoefff_wall_pp.F90.o [ 64%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/calccoeffs_free_pp.F90.o [ 65%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/calccoeffs_pp.F90.o [ 67%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/calccoeffs_wall_pp.F90.o [ 68%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/poroporo.F90.o [ 69%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_incid_pp_f.F90.o [ 70%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_incid_pp_s.F90.o [ 71%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_reflexff_free_pp.F90.o [ 72%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_reflexff_pp.F90.o [ 73%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_reflexff_wall_pp.F90.o [ 74%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_reflexfpsi_free_pp.F90.o [ 75%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_reflexfpsi_pp.F90.o [ 76%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_reflexfpsi_wall_pp.F90.o [ 78%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_reflexfs_free_pp.F90.o [ 79%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_reflexfs_pp.F90.o [ 80%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_reflexfs_wall_pp.F90.o [ 81%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_reflexsf_free_pp.F90.o [ 82%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_reflexsf_pp.F90.o [ 83%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_reflexsf_wall_pp.F90.o [ 84%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_reflexspsi_free_pp.F90.o [ 85%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_reflexspsi_pp.F90.o [ 86%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_reflexspsi_wall_pp.F90.o [ 87%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_reflexss_free_pp.F90.o [ 89%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_reflexss_pp.F90.o [ 90%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_reflexss_wall_pp.F90.o [ 91%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_transmitff_pp.F90.o [ 92%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_transmitfpsi_pp.F90.o [ 93%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_transmitfs_pp.F90.o [ 94%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_transmitsf_pp.F90.o [ 95%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_transmitspsi_pp.F90.o [ 96%] Building Fortran object lib/libporoporo/CMakeFiles/poroporo.dir/sub_transmitss_pp.F90.o [ 97%] Linking Fortran static library libporoporo.a [ 97%] Built target poroporo Scanning dependencies of target Gar6more2D.out [ 98%] Building Fortran object CMakeFiles/Gar6more2D.out.dir/lib/bin/Gar6more2D.F90.o [100%] Linking Fortran executable Gar6more2D.out [100%] Built target Gar6more2D.out
# Generate and write the parameter file.
amplitude = 1e2
time_step = 1e-4
center_frequency = 100.0
gar6more2d_par_file = """3 infinite medium (1), free surface (2), wall boundary (3) or bilayered medium(4)
1 first layer : acoustic (0) elastodynamic (1), poroelastic (2)
1d2 Central frequency of the source
1d9 Amplitude of the P source
0d0 Amplitude of the S source
2d-2 0d0 Delay of the source
250d0 Height of the source
50d0 Height of the line of receivers
-200d0 Abscissa of the first receiver
200d0 Abscissa of the last receiver
5 Numbers of receivers
0 Start time
1d-1 Stop time
1e-4 Time step
1000 Number of intervals for the numerical computation of the convolution
41600000000 4264000000 2600 mu, lambda and rho
"""
with open(gar6more2d_par_file_path, "w") as fh:
fh.write(gar6more2d_par_file)
obspy
stream object.# Run code.
gar6more2d_data_file_x = gar6more2d_build_path / "Ux.dat"
gar6more2d_data_file_y = gar6more2d_build_path / "Uy.dat"
if not os.path.exists(gar6more2d_data_file_x):
assert (
subprocess.run(
["./Gar6more2D.out"], cwd=gar6more2d_build_path
).returncode
== 0
)
# Read data.
gar6more2d_data_x = obspy.Stream(read_gar6more(gar6more2d_data_file_x))
gar6more2d_data_y = obspy.Stream(read_gar6more(gar6more2d_data_file_y))
Do you want - An infinite homogeneous medium (1); - A semi-infinite homogeneous media with a free surface boundary condition at it bottom (2): - A semi-infinite homogeneous media with a wall boundary condition at it bottom (3): - A bilayered infinite media with a plane interface (4): 3 Is the first medium acoustic (0), elastodynamic (1) or porous (2)? 1 Frequency of the source? 100.00000000000000 Amplitude of the P source? 1000000000.0000000 Amplitude of the S source? 0.0000000000000000 delay of the source (f(t)=0 if t>2tdelay)? 2.0000000000000000E-002 Height of the source? 250.00000000000000 Height of the line of receivers? 50.000000000000000 abscissa of the first receiver? -200.00000000000000 abscissa of the last receiver? 200.00000000000000 How many receivers? 5 dx= 100.00000000000000 At which time shall the seismo begin? 0.0000000000000000 At which time shall the seismo stop? 0.10000000000000001 What is the time-step? 1.0000000000000000E-004 1001 How many intervals are required for the numerical computation of the time convolution? 1000 mu,lambda,rho 41600000000.000000 4264000000.0000000 2600.0000000000000 Vp1, Vs1 5800.0000000000000 4000.0000000000000 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!WARNING!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! In the elastics case, the code does not really compute the displacement, but its integral (for some reasons related to the Cagniard-de Hoop method, see the documentation). Therefore, don't forget to replace the source by the derivative of the source function you are using. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Computation of the incident P wave Computation of the reflected PP wave Computation of the reflected PS wave
IntegrationTestMesh.py
module, which is shared between all integration test instances. Feel free to peak inside to see how the meshes are made -- or alternatively check out the meshing tutorials for a more in-depth explanation.# Adjust the scaling of the source term to be equivalent to what is
# used in GAR6MORE.
bulk_modulus = 8.7464e10
gar6more_scale = bulk_modulus / (2 * np.pi**2 * center_frequency**2)
source_amplitude = amplitude / gar6more_scale
SalvusFlow
to generate sources, receivers, and boundary conditions.source = sc.source.cartesian.MomentTensorPoint2D(
x=500.0,
y=250.0,
mxx=1e9,
myy=1e9,
mxy=0.0,
source_time_function=sc.source.stf.Ricker(
center_frequency=center_frequency
),
)
# Generate 5 cartesian receivers, spaced between X=300 and X=700 meters.
receivers = [
sc.receiver.cartesian.Point2D(
station_code=str(i), x=x, y=50, fields=["displacement"]
)
for i, x in enumerate(range(300, 701, 100))
]
boundary = sc.boundary.HomogeneousDirichlet(side_sets=["y0"])
output_dirs = []
# Run for a number of different orders.
for order in [1, 2, 4, 7]:
# Setup the mesh for this simulation.
mesh = get_mesh(
dimension=2,
analytic_code=AnalyticCode.Gar6more2D,
physics=Physics.ELASTIC,
n_elem_per_wavelength=2,
polynomial_order=max(4, order),
shape_order=min(4, order),
)
# Unique job name.
job_name = f"GAR6MORE2D_ELASTIC_ORDER_{order}"
output_dirs.append(pathlib.Path(job_name) / "output")
# Configure Salvus
w = sc.simulation.Waveform()
w.set_mesh(mesh)
w.physics.wave_equation.start_time_in_seconds = -2e-2
w.physics.wave_equation.end_time_in_seconds = 8e-2
w.physics.wave_equation.time_step_in_seconds = time_step
w.add_sources(source)
w.add_receivers(receivers)
w.add_boundary_conditions(boundary)
# The input files can optionally be already validated.
w.validate()
api.run(
site_name=SALVUS_FLOW_SITE_NAME,
output_folder=output_dirs[-1],
input_file=w,
ranks=MPI_RANKS,
get_all=True,
overwrite=True,
)
SalvusJob `job_2411151451447262_ae7ac34498` running on `local_f64` with 4 rank(s). Site information: * Salvus version: 2024.1.2 * Floating point size: 64
* Downloaded 106.7 KB of results to `GAR6MORE2D_ELASTIC_ORDER_1/output`. * Total run time: 1.45 seconds. * Pure simulation time: 0.84 seconds. SalvusJob `job_2411151451914450_e81e8deb47` running on `local_f64` with 4 rank(s). Site information: * Salvus version: 2024.1.2 * Floating point size: 64
* Downloaded 106.6 KB of results to `GAR6MORE2D_ELASTIC_ORDER_2/output`. * Total run time: 1.15 seconds. * Pure simulation time: 0.84 seconds. SalvusJob `job_2411151451107917_832c7da3a7` running on `local_f64` with 4 rank(s). Site information: * Salvus version: 2024.1.2 * Floating point size: 64
* Downloaded 106.6 KB of results to `GAR6MORE2D_ELASTIC_ORDER_4/output`. * Total run time: 1.15 seconds. * Pure simulation time: 0.92 seconds. SalvusJob `job_2411151451299974_5aeab24e8f` running on `local_f64` with 4 rank(s). Site information: * Salvus version: 2024.1.2 * Floating point size: 64
* Downloaded 106.6 KB of results to `GAR6MORE2D_ELASTIC_ORDER_7/output`. * Total run time: 1.15 seconds. * Pure simulation time: 0.93 seconds.
np.testing.assert_allclose
line to fail. If you encounter this, and would still like to see the effect of your changes on the seismograms, feel free to comment out that line.# Setup the figure.
f, ax = plt.subplots(5, 1, figsize=(15, 30), sharex=True)
ax[0].set_title("Integration Test (Gar6more2D // Elastic)")
# Plot analytic data.
for _i, (a, gx, gy) in enumerate(
zip(ax, gar6more2d_data_x, gar6more2d_data_y)
):
if _i != 2:
a.plot(
-gx.copy().differentiate().normalize().data, label="Gar6more2D [x]"
)
a.plot(-gy.copy().differentiate().normalize().data, label="Gar6more2D [y]")
# Read in the data produced by Salvus.
for output_dir in output_dirs:
with pyasdf.ASDFDataSet(output_dir / "receivers.h5", mode="r") as dataset:
# Loop over the receivers in both Gar6more2D and Salvus,
# and plot them overtop of one another.
for _i, (a, s, gx, gy) in enumerate(
zip(ax, dataset.waveforms, gar6more2d_data_x, gar6more2d_data_y)
):
# Get both solutions.
if _i != 2:
analytic_x = gx.copy().differentiate().normalize().data
analytic_y = -gy.copy().differentiate().normalize().data
salvus_x = s.displacement[0].copy().normalize().data
salvus_y = s.displacement[1].copy().normalize().data
# Plot (should deploy these to some server).
order = output_dir.parent.name.split("_")[-1][0]
if _i != 2:
a.plot(
salvus_x,
label=f"Salvus [x] (Shape order {order})",
ls="dashed",
)
a.plot(
salvus_y,
label=f"Salvus [y] (Shape order {order})",
ls="dashed",
)
a.set_xlabel("Time sample")
a.set_ylabel("Displacement (m)")
a.legend()
# Nodal line.
# if _i != 2:
# np.testing.assert_allclose(analytic_x, salvus_x, atol=1e1)
# np.testing.assert_allclose(analytic_y, salvus_y, atol=1e-1)
# plt.show()