initial upload
This commit is contained in:
52
test/old_tests/only_source/README.md
Normal file
52
test/old_tests/only_source/README.md
Normal file
@@ -0,0 +1,52 @@
|
||||
# Example for Solver only mode
|
||||
|
||||
This example shows how to use the Solver only mode of the tool.
|
||||
|
||||
## compile TOMOATT with solver_only executable
|
||||
|
||||
Uncomment "src/TOMOATT_solver_only.cxx" and "src/TOMOATT_2d_precalc.cxx" in CMakeLists.txt to compile the solver_only executable as below.
|
||||
|
||||
```cmake
|
||||
# add one by one
|
||||
set(APP_SOURCES
|
||||
src/TOMOATT.cxx
|
||||
src/TOMOATT_solver_only.cxx
|
||||
src/TOMOATT_2d_precalc.cxx
|
||||
#src/SrcRecWeight.cxx
|
||||
)
|
||||
```
|
||||
|
||||
Then recompile the code in the build directory.
|
||||
|
||||
|
||||
## pre calculation of source boudary conditions
|
||||
|
||||
As the 2d solver is not parallelized for one single teleseismic source yet, what user can do is calculate multiple teleseismic sources at the same time using simultaneous run.
|
||||
The precalculation of source boundary conditions can be done by running the following command:
|
||||
|
||||
```bash
|
||||
mpirun -n 8 ../../build/bin/TOMOATT_2d_precalc -i input_params_pre.yml
|
||||
```
|
||||
|
||||
## run the solver_only executable
|
||||
|
||||
Before running the solver_only executable, you need to prepare the input files by running:
|
||||
|
||||
```python
|
||||
python make_test_model.py
|
||||
```
|
||||
|
||||
This creates a src_only_test.dat which includes 8 sources without any receiver.
|
||||
|
||||
Then run the solver_only executable as below.
|
||||
|
||||
```bash
|
||||
mpirun -n 8 ../../build/bin/TOMOATT_solver_only -i src_only_test.dat
|
||||
```
|
||||
|
||||
## check the output files
|
||||
The result file can be visualize with paraview:
|
||||
```bash
|
||||
paraview OUTPUT_FILES/out_data_sim.xmf
|
||||
```
|
||||
or directly open with python etc. Please refer the check_3d_out.ipynb for more details.
|
||||
91
test/old_tests/only_source/check_3d_out.ipynb
Normal file
91
test/old_tests/only_source/check_3d_out.ipynb
Normal file
File diff suppressed because one or more lines are too long
33
test/old_tests/only_source/input_params.yml
Normal file
33
test/old_tests/only_source/input_params.yml
Normal file
@@ -0,0 +1,33 @@
|
||||
version : 2
|
||||
|
||||
domain :
|
||||
min_max_dep : [-10.0, 10.0] # depth in km
|
||||
min_max_lat : [37.7,42.3] # latitude in degree
|
||||
min_max_lon : [22.7,27.3] # longitude in degree
|
||||
n_rtp : [10,50,50] # number of nodes
|
||||
|
||||
source :
|
||||
src_rec_file : 'src_only_test.dat' # source receiver file (if found, src_dep_lat_lon is ignored)
|
||||
swap_src_rec : 0 # swap source and receiver # SHOLD BE 0 FOR SOURCE ONLY RUN
|
||||
|
||||
model :
|
||||
init_model_path : './test_model_true.h5' # path to initial model file (ignored if init_model_type is '1d_*')
|
||||
|
||||
inversion :
|
||||
run_mode : 0 # 0 for forward simulation only, 1 for inversion
|
||||
|
||||
parallel :
|
||||
n_sims : 1 # number of simultaneous run
|
||||
ndiv_rtp : [2,1,1] # number of subdomains
|
||||
nproc_sub : 2 # number of subprocess used for each subdomain
|
||||
|
||||
calculation :
|
||||
convergence_tolerance : 1e-4
|
||||
max_iterations : 500
|
||||
stencil_order : 3 # 1 or 3
|
||||
sweep_type : 1 # 0: legacy, 1: cuthill-mckee with shm parallelization
|
||||
|
||||
output_setting :
|
||||
is_output_source_field : 1 # output the calculated field of all sources 1 for yes; 0 for no; default: 1
|
||||
is_verbose_output : 0 # output internal parameters, if no, only model parameters are out. 1 for yes; 0 for no; default: 0
|
||||
is_output_model_dat : 0 # output model_parameters_inv_0000.dat or not. 1 for yes; 0 for no; default: 1
|
||||
33
test/old_tests/only_source/input_params_pre.yml
Normal file
33
test/old_tests/only_source/input_params_pre.yml
Normal file
@@ -0,0 +1,33 @@
|
||||
version : 2
|
||||
|
||||
domain :
|
||||
min_max_dep : [-10.0, 10.0] # depth in km
|
||||
min_max_lat : [37.7,42.3] # latitude in degree
|
||||
min_max_lon : [22.7,27.3] # longitude in degree
|
||||
n_rtp : [10,50,50] # number of nodes
|
||||
|
||||
source :
|
||||
src_rec_file : 'src_only_test.dat' # source receiver file (if found, src_dep_lat_lon is ignored)
|
||||
swap_src_rec : 0 # swap source and receiver # SHOLD BE 0 FOR SOURCE ONLY RUN
|
||||
|
||||
model :
|
||||
init_model_path : './test_model_true.h5' # path to initial model file (ignored if init_model_type is '1d_*')
|
||||
|
||||
inversion :
|
||||
run_mode : 0 # 0 for forward simulation only, 1 for inversion
|
||||
|
||||
parallel : # no mean for 2d pre calculation
|
||||
n_sims : 8 # number of simultaneous run. use as much as possible for 2d source preparation
|
||||
ndiv_rtp : [1,1,1] # number of subdomains
|
||||
nproc_sub : 1 # number of subprocess used for each subdomain
|
||||
|
||||
calculation :
|
||||
convergence_tolerance : 1e-4
|
||||
max_iterations : 500
|
||||
stencil_order : 3 # 1 or 3
|
||||
sweep_type : 1 # 0: legacy, 1: cuthill-mckee with shm parallelization
|
||||
|
||||
output_setting :
|
||||
is_output_source_field : 1 # output the calculated field of all sources 1 for yes; 0 for no; default: 1
|
||||
is_verbose_output : 0 # output internal parameters, if no, only model parameters are out. 1 for yes; 0 for no; default: 0
|
||||
is_output_model_dat : 0 # output model_parameters_inv_0000.dat or not. 1 for yes; 0 for no; default: 1
|
||||
200
test/old_tests/only_source/make_test_model.py
Normal file
200
test/old_tests/only_source/make_test_model.py
Normal file
@@ -0,0 +1,200 @@
|
||||
# %% [markdown]
|
||||
# # notebook for create init and true test model
|
||||
|
||||
# %%
|
||||
import numpy as np
|
||||
import math
|
||||
|
||||
# grid
|
||||
R_earth = 6371.0
|
||||
|
||||
rr1=6361
|
||||
rr2=6381
|
||||
tt1=(38.0-0.3)/180*math.pi
|
||||
tt2=(42.0+0.3)/180*math.pi
|
||||
pp1=(23.0-0.3)/180*math.pi
|
||||
pp2=(27.0+0.3)/180*math.pi
|
||||
|
||||
n_rtp = [10,50,50]
|
||||
dr = (rr2-rr1)/(n_rtp[0]-1)
|
||||
dt = (tt2-tt1)/(n_rtp[1]-1)
|
||||
dp = (pp2-pp1)/(n_rtp[2]-1)
|
||||
rr = np.array([rr1 + x*dr for x in range(n_rtp[0])])
|
||||
tt = np.array([tt1 + x*dt for x in range(n_rtp[1])])
|
||||
pp = np.array([pp1 + x*dp for x in range(n_rtp[2])])
|
||||
|
||||
# initial model
|
||||
gamma = 0.0
|
||||
s0 = 1.0/6.0
|
||||
slow_p=0.06
|
||||
ani_p=0.04
|
||||
|
||||
eta_init = np.zeros(n_rtp)
|
||||
xi_init = np.zeros(n_rtp)
|
||||
zeta_init = np.zeros(n_rtp)
|
||||
fun_init = np.zeros(n_rtp)
|
||||
vel_init = np.zeros(n_rtp)
|
||||
|
||||
# true model
|
||||
eta_true = np.zeros(n_rtp)
|
||||
xi_true = np.zeros(n_rtp)
|
||||
zeta_true = np.zeros(n_rtp)
|
||||
fun_true = np.zeros(n_rtp)
|
||||
vel_true = np.zeros(n_rtp)
|
||||
|
||||
c=0
|
||||
for ir in range(n_rtp[0]):
|
||||
for it in range(n_rtp[1]):
|
||||
for ip in range(n_rtp[2]):
|
||||
# already initialized above
|
||||
#eta_init[ir,it,ip] = 0.0
|
||||
#xi_init[ir,it,ip] = 0.0
|
||||
zeta_init[ir,it,ip] = gamma*math.sqrt(eta_init[ir,it,ip]**2 + xi_init[ir,it,ip]**2)
|
||||
fun_init[ir,it,ip] = s0
|
||||
vel_init[ir,it,ip] = 1.0/s0
|
||||
|
||||
# true model
|
||||
if (tt[it] >= 38.0/180.0*math.pi and tt[it] <= 42.0/180.0*math.pi \
|
||||
and pp[ip] >= 23.0/180.0*math.pi and pp[ip] <= 27.0/180.0*math.pi):
|
||||
c+=1
|
||||
sigma = math.sin(2.0*math.pi*(tt[it]-38.0/180.0*math.pi)/(4.0/180.0*math.pi))*math.sin(2.0*math.pi*(pp[ip]-23.0/180.0*math.pi)/(4.0/180.0*math.pi))
|
||||
else:
|
||||
sigma = 0.0
|
||||
|
||||
if sigma < 0:
|
||||
psi = 60.0/180.0*math.pi
|
||||
elif sigma > 0:
|
||||
psi = 120.0/180.0*math.pi
|
||||
else:
|
||||
psi = 0.0
|
||||
|
||||
eta_true[ir,it,ip] = ani_p*abs(sigma)*math.sin(2.0*psi)
|
||||
xi_true[ir,it,ip] = ani_p*abs(sigma)*math.cos(2.0*psi)
|
||||
zeta_true[ir,it,ip] = gamma*math.sqrt(eta_true[ir,it,ip]**2 + xi_true[ir,it,ip]**2)
|
||||
fun_true[ir,it,ip] = s0/(1.0+sigma*slow_p)
|
||||
vel_true[ir,it,ip] = 1.0/fun_true[ir,it,ip]
|
||||
|
||||
|
||||
#r_earth = 6378.1370
|
||||
print("depminmax {} {}".format(R_earth-rr1,R_earth-rr2))
|
||||
print(c)
|
||||
|
||||
|
||||
# %%
|
||||
# write out in hdf5 format
|
||||
import h5py
|
||||
|
||||
fout_init = h5py.File('test_model_init.h5', 'w')
|
||||
fout_true = h5py.File('test_model_true.h5', 'w')
|
||||
|
||||
# write out the arrays eta_init, xi_init, zeta_init, fun_init, a_init, b_init, c_init, f_init
|
||||
fout_init.create_dataset('eta', data=eta_init)
|
||||
fout_init.create_dataset('xi', data=xi_init)
|
||||
fout_init.create_dataset('zeta', data=zeta_init)
|
||||
fout_init.create_dataset('vel', data=vel_init)
|
||||
|
||||
# writeout the arrays eta_true, xi_true, zeta_true, fun_true, a_true, b_true, c_true, f_true
|
||||
fout_true.create_dataset('eta', data=eta_true)
|
||||
fout_true.create_dataset('xi', data=xi_true)
|
||||
fout_true.create_dataset('zeta', data=zeta_true)
|
||||
fout_true.create_dataset('vel', data=vel_true)
|
||||
|
||||
fout_init.close()
|
||||
fout_true.close()
|
||||
|
||||
|
||||
# %% [markdown]
|
||||
# # prepare src station file
|
||||
#
|
||||
# The following code creates a src_rec_file for the inversion, which describes the source and receiver positions and arrival times.
|
||||
# Format is as follows:
|
||||
#
|
||||
# ```
|
||||
# 26 1992 1 1 2 43 56.900 1.8000 98.9000 137.00 2.80 8 305644 <- src : id_src year month day hour min sec lat lon dep_km mag num_recs id_event
|
||||
# 26 1 PCBI 1.8900 98.9253 1000.0000 P 10.40 18.000 <- arrival : id_src id_rec name_rec lat lon elevation_m phase epicentral_distance_km arrival_time_sec
|
||||
# 26 2 MRPI 1.6125 99.3172 1100.0000 P 50.84 19.400
|
||||
# 26 3 HUTI 2.3153 98.9711 1600.0000 P 57.84 19.200
|
||||
# ....
|
||||
#
|
||||
# ```
|
||||
|
||||
# %%
|
||||
import random
|
||||
random.seed(1145141919810)
|
||||
|
||||
# dummys
|
||||
year_dummy = 1998
|
||||
month_dummy = 1
|
||||
day_dummy = 1
|
||||
hour_dummy = 0
|
||||
minute_dummy = 0
|
||||
second_dummy = 0
|
||||
mag_dummy = 3.0
|
||||
id_dummy = 1000
|
||||
st_name_dummy = 'AAAA'
|
||||
phase_dummy = 'P'
|
||||
arriv_t_dummy = 0.0
|
||||
|
||||
tt1deg = tt1 * 180.0/math.pi
|
||||
tt2deg = tt2 * 180.0/math.pi
|
||||
pp1deg = pp1 * 180.0/math.pi
|
||||
pp2deg = pp2 * 180.0/math.pi
|
||||
|
||||
|
||||
n_srcs = 8 # source will be placed around the domain
|
||||
r_src = 15 # radius of the source in degree
|
||||
|
||||
lines = []
|
||||
|
||||
#nij_rec = math.sqrt(n_rec[0])
|
||||
|
||||
pos_src=[]
|
||||
#pos_rec=[]
|
||||
|
||||
# center of the domain
|
||||
lon_c = (pp1deg+pp2deg)/2.0
|
||||
lat_c = (tt1deg+tt2deg)/2.0
|
||||
|
||||
# step of angle in degree = 360.0/n_srcs
|
||||
d_deg = 360.0/n_srcs
|
||||
|
||||
for i_src in range(n_srcs):
|
||||
|
||||
i_deg = i_src*d_deg
|
||||
lon = lon_c + r_src*math.cos(i_deg/180.0*math.pi)
|
||||
lat = lat_c + r_src*math.sin(i_deg/180.0*math.pi)
|
||||
# depth of the source
|
||||
dep = 10.0 + 0.5*i_src
|
||||
|
||||
src = [i_src, year_dummy, month_dummy, day_dummy, hour_dummy, minute_dummy, second_dummy, lat, lon, dep, mag_dummy, 0, id_dummy]
|
||||
lines.append(src)
|
||||
|
||||
pos_src.append([lon,lat,dep])
|
||||
|
||||
|
||||
# write out ev_arrivals file
|
||||
fname = 'src_only_test.dat'
|
||||
|
||||
with open(fname, 'w') as f:
|
||||
for line in lines:
|
||||
for elem in line:
|
||||
f.write('{} '.format(elem))
|
||||
f.write('\n')
|
||||
|
||||
|
||||
# %%
|
||||
# draw src and rec positions
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
for i_src in range(n_srcs):
|
||||
plt.scatter(pos_src[i_src][1],pos_src[i_src][0],c='r',marker='o')
|
||||
|
||||
# %%
|
||||
# plot receivers
|
||||
#for i_rec in range(n_rec[0]):
|
||||
# plt.scatter(pos_rec[i_rec][1],pos_rec[i_rec][0],c='b',marker='o')
|
||||
|
||||
# %%
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user