Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0741bd6
NOT FINISH
Dengda98 Feb 23, 2025
e301175
Merge branch 'main' into test_static
Dengda98 Feb 28, 2025
2a667a7
move files about `static` to directory
Dengda98 Mar 3, 2025
2c08d3b
Merge branch 'main' into test_static
Dengda98 Apr 1, 2025
79920c2
FEAT: add DEG1 in `const.h`
Dengda98 Apr 3, 2025
e0278bd
REFAC: rearrange some functions into 'common/' folder, and add .h, .c…
Dengda98 Apr 4, 2025
c578488
FEAT: set -O to be mandatory in `grt_main.c`
Dengda98 Apr 4, 2025
bc81dca
FEAT: add `stgrt` program to support static Green's Funcions calculation
Dengda98 Apr 6, 2025
567dddf
FIX: add `-O` mandatory check in `stgrt`
Dengda98 Apr 6, 2025
a4e300a
FIX: use different dk for different r in PTAM
Dengda98 Apr 7, 2025
339da07
FIX: move dwm, fim and ptam to `common/`, add function pointer `Kerne…
Dengda98 Apr 9, 2025
c2a3f87
FIX: change original source radiation function to `set_source_radiati…
Dengda98 Apr 9, 2025
4bbdf03
FIX: include "dynamic/propagate.h"
Dengda98 Apr 9, 2025
76a45b0
FIX: include new header, use new API
Dengda98 Apr 9, 2025
e841bd0
FIX: add 1e-5 factor about distance in stress/strain calculation, cha…
Dengda98 Apr 9, 2025
887d8e5
DOC: add API doc of `calc_uiz_R_EV`
Dengda98 Apr 9, 2025
ed5e646
FEAT: add some functions about rotation
Dengda98 Apr 10, 2025
44ef593
FEAT: support static displacement, strain, stress calculation
Dengda98 Apr 10, 2025
a73e5ba
FEAT: add source property in SAC header
Dengda98 Apr 10, 2025
e1b29fa
FEAT: add rotation support to ZNE
Dengda98 Apr 10, 2025
afa23d1
REFAC: remove some unused variables
Dengda98 Apr 10, 2025
f3ce230
FEAT: Fix the rotation condition in the static stress calculation and…
Dengda98 Apr 10, 2025
0c40aa1
TEST: add check_upar example
Dengda98 Apr 10, 2025
b689455
TEST: add compute_strain_stress example
Dengda98 Apr 10, 2025
1ef1b39
TEST: add static_disp example
Dengda98 Apr 10, 2025
894a3dc
TEST: add view_integ_stats example
Dengda98 Apr 10, 2025
a37012a
CI: add some tests
Dengda98 Apr 10, 2025
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
12 changes: 12 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,18 @@ jobs:
python plot_compare_pygrt.py
continue-on-error: true # 即使失败,仍然标记为成功

- name: Test strain stress (dynamic)
working-directory: ${{ env.EXAMPLE_COPY_PATH }}/compute_strain_stress/dynamic
run: |
chmod +x *.sh
./run_grt.sh

- name: Test static displacement (static)
working-directory: ${{ env.EXAMPLE_COPY_PATH }}/compute_strain_stress/static
run: |
chmod +x *.sh
./run_stgrt.sh

- name: Remove the test files
run: |
rm -rf ${{ env.EXAMPLE_COPY_PATH }}
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/testbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,18 @@ jobs:
./run_grt.sh
python run_pygrt.py

- name: Test strain stress (dynamic)
working-directory: ${{ env.EXAMPLE_COPY_PATH }}/compute_strain_stress/dynamic
run: |
chmod +x *.sh
./run_grt.sh

- name: Test static displacement (static)
working-directory: ${{ env.EXAMPLE_COPY_PATH }}/compute_strain_stress/static
run: |
chmod +x *.sh
./run_stgrt.sh

- name: Remove the test files
run: |
rm -rf ${{ env.EXAMPLE_COPY_PATH }}
Expand Down
1 change: 1 addition & 0 deletions example/check_upar/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use difference to check spatial derivatives calculation.
Binary file added example/check_upar/compare_uir.pdf
Binary file not shown.
Binary file added example/check_upar/compare_uiz.pdf
Binary file not shown.
9 changes: 9 additions & 0 deletions example/check_upar/milrow
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
0.2 3.4 1.7 2.3 9e10 9e10
0.6 3.7 1.9 2.4 9e10 9e10
0.5 4.2 2.1 2.4 9e10 9e10
0.5 4.6 2.3 2.5 9e10 9e10
0.7 4.9 2.8 2.6 9e10 9e10
0.5 5.1 2.9 2.7 9e10 9e10
6.0 5.9 3.3 2.7 9e10 9e10
28. 6.9 4.0 2.8 9e10 9e10
-0.1 8.2 4.7 3.2 9e10 9e10
69 changes: 69 additions & 0 deletions example/check_upar/plot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

SAC_DISPLAY_COPYRIGHT=0

out="compare_pdf"
rm -rf $out
mkdir -p $out

diff=0.001
depsrc=2
deprcv=3.2
deprcv2=`echo $deprcv+$diff | bc | awk '{printf("%.3f", $1)}'`
dist=10
dist2=`echo $dist+$diff | bc | awk '{printf("%.3f", $1)}'`

GRN="GRN"

# --------------------- ui_z --------------------------------------
for ch in $(ls $GRN/milrow_${depsrc}_${deprcv2}_${dist}); do
echo $ch
sac <<EOF
r $GRN/milrow_${depsrc}_${deprcv2}_${dist}/$ch
subf $GRN/milrow_${depsrc}_${deprcv}_${dist}/$ch
div -$diff
w uiz_diff.sac
r uiz_diff.sac
r more $GRN/milrow_${depsrc}_${deprcv}_${dist}/z${ch:0:3}.sac
int
qdp off
color red inc list blue red
p2
saveimg $out/compare_$ch.pdf
q
EOF

done

rm uiz_diff.sac

pdftk $out/* cat output compare_uiz.pdf

rm -rf $out
mkdir -p $out

# --------------------- ui_z --------------------------------------
for ch in $(ls $GRN/milrow_${depsrc}_${deprcv}_${dist2}); do
echo $ch
sac <<EOF
r $GRN/milrow_${depsrc}_${deprcv}_${dist2}/$ch
subf $GRN/milrow_${depsrc}_${deprcv}_${dist}/$ch
div $diff
w uir_diff.sac
r uir_diff.sac
r more $GRN/milrow_${depsrc}_${deprcv}_${dist}/r${ch:0:3}.sac
int
qdp off
color red inc list blue red
p2
saveimg $out/compare_$ch.pdf
q
EOF

done

rm uir_diff.sac

pdftk $out/* cat output compare_uir.pdf

rm -rf $out
19 changes: 19 additions & 0 deletions example/check_upar/run_grt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

depsrc=2
nt=1024
dt=0.01

modname="milrow"
out="GRN"


diff=0.001
deprcv=3.2
deprcv2=`echo $deprcv+$diff | bc | awk '{printf("%.3f", $1)}'`
dist=10
dist2=`echo $dist+$diff | bc | awk '{printf("%.3f", $1)}'`

grt -M${modname} -O${out} -N${nt}/${dt} -D${depsrc}/$deprcv -R$dist -e
grt -M${modname} -O${out} -N${nt}/${dt} -D${depsrc}/$deprcv2 -R$dist
grt -M${modname} -O${out} -N${nt}/${dt} -D${depsrc}/$deprcv -R$dist2
9 changes: 9 additions & 0 deletions example/compute_strain_stress/dynamic/milrow
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
0.2 3.4 1.7 2.3 9e10 9e10
0.6 3.7 1.9 2.4 9e10 9e10
0.5 4.2 2.1 2.4 9e10 9e10
0.5 4.6 2.3 2.5 9e10 9e10
0.7 4.9 2.8 2.6 9e10 9e10
0.5 5.1 2.9 2.7 9e10 9e10
6.0 5.9 3.3 2.7 9e10 9e10
28. 6.9 4.0 2.8 9e10 9e10
-0.1 8.2 4.7 3.2 9e10 9e10
26 changes: 26 additions & 0 deletions example/compute_strain_stress/dynamic/run_grt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash


dist=10
depsrc=2
deprcv=0

nt=1024
dt=0.01

modname="milrow"
out="GRN"

grt -M${modname} -O${out} -N${nt}/${dt} -D${depsrc}/${deprcv} -R${dist} -e

# Fault
S="u1e8"
stk=77
dip=88
rak=99
az=30
grt.syn -G${out}/${modname}_${depsrc}_${deprcv}_${dist} -A$az -S$S -M$stk/$dip/$rak -Dp/0.6 -Osyn_dc -e


grt.strain syn_dc/out
grt.stress syn_dc/out
9 changes: 9 additions & 0 deletions example/compute_strain_stress/static/milrow
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
0.2 3.4 1.7 2.3 9e10 9e10
0.6 3.7 1.9 2.4 9e10 9e10
0.5 4.2 2.1 2.4 9e10 9e10
0.5 4.6 2.3 2.5 9e10 9e10
0.7 4.9 2.8 2.6 9e10 9e10
0.5 5.1 2.9 2.7 9e10 9e10
6.0 5.9 3.3 2.7 9e10 9e10
28. 6.9 4.0 2.8 9e10 9e10
-0.1 8.2 4.7 3.2 9e10 9e10
24 changes: 24 additions & 0 deletions example/compute_strain_stress/static/run_stgrt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

depsrc=2
deprcv=0

x1=-3
x2=3
nx=10

y1=-3
y2=3
ny=10

stgrt -Mmilrow -D${depsrc}/${deprcv} -X$x1/$x2/$nx -Y$y1/$y2/$ny -e > grn

# Fault
S="u1e8"
stk=77
dip=88
rak=99
stgrt.syn -S$S -M$stk/$dip/$rak -e -N < grn > syn

stgrt.strain < syn > strain
stgrt.stress < syn > stress
2 changes: 2 additions & 0 deletions example/compute_strain_stress/static2/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
结果对比:
郝金来, 姚振兴, 2012. 均匀弹性分层介质模型中的同震位移、应变以及应力[J]. 地球物理学报, 55(5): 1682-1694.
1 change: 1 addition & 0 deletions example/compute_strain_stress/static2/halfspace2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0 4.0 2.7 2.5 9e30 9e30
5 changes: 5 additions & 0 deletions example/compute_strain_stress/static2/mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
20 5.8 3.35 2.7 9e30 9e30
20 6.8 3.90 2.8 9e30 9e30
20 7.8 4.45 2.9 9e30 9e30
20 8.8 5.00 3.0 9e30 9e30
20 9.8 5.55 3.1 9e30 9e30
176 changes: 176 additions & 0 deletions example/compute_strain_stress/static2/plot.ipynb

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions example/compute_strain_stress/static2/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash


mod="halfspace2"
stgrt -M$mod -D20/16 -X3/3/1 -Y-10/10/41 -e > grn1

stgrt.syn -M0/70/0 -Su1e6 -e -N < grn1 > syn_1_stkslip
stgrt.stress < syn_1_stkslip > stress_1_stkslip

stgrt.syn -M0/70/90 -Su1e6 -e -N < grn1 > syn_1_dipslip
stgrt.stress < syn_1_dipslip > stress_1_dipslip



stgrt -M$mod -D10/14 -X3/3/1 -Y-10/10/41 -e > grn2

stgrt.syn -M0/70/0 -Su1e6 -e -N < grn2 > syn_2_stkslip
stgrt.stress < syn_2_stkslip > stress_2_stkslip

stgrt.syn -M0/70/90 -Su1e6 -e -N < grn2 > syn_2_dipslip
stgrt.stress < syn_2_dipslip > stress_2_dipslip


mod="mod"
stgrt -M$mod -D5/0 -X3/3/1 -Y-10/10/41 -e > grn3

stgrt.syn -M0/70/0 -Su1e6 -e -N < grn3 > syn_3_stkslip
stgrt.stress < syn_3_stkslip > stress_3_stkslip

stgrt.syn -M0/70/90 -Su1e6 -e -N < grn3 > syn_3_dipslip
stgrt.stress < syn_3_dipslip > stress_3_dipslip
Binary file added example/static_disp/disp_dc.pdf
Binary file not shown.
Binary file added example/static_disp/disp_exp.pdf
Binary file not shown.
Binary file added example/static_disp/disp_sf.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions example/static_disp/halfspace2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0 4.0 2.7 2.5 9e30 9e30
73 changes: 73 additions & 0 deletions example/static_disp/run_stgrt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash

depsrc=2
deprcv=0

x1=-3
x2=3
nx=20

y1=-3
y2=3
ny=20

stgrt -Mhalfspace2 -D${depsrc}/${deprcv} -X$x1/$x2/$nx -Y$y1/$y2/$ny > grn

# Fault
S="1e23"
stk=60
dip=90
rak=0
stgrt.syn -S$S -M$stk/$dip/$rak -N < grn > syn

gmt set FONT_TITLE 9p
gmt begin disp_dc pdf
gmt xyz2grd syn -GsynZ.nc -R$y1/$y2/$x1/$x2 -I$ny+n/$nx+n -i0,1,2 -:
gmt xyz2grd syn -GsynN.nc -R$y1/$y2/$x1/$x2 -I$ny+n/$nx+n -i0,1,3 -:
gmt xyz2grd syn -GsynE.nc -R$y1/$y2/$x1/$x2 -I$ny+n/$nx+n -i0,1,4 -:

gmt basemap -Baf -BWSen+t"Fault, $stk/$dip/$rak, $S" -JX5c/5c -R$y1/$y2/$x1/$x2
gmt grdimage synZ.nc
gmt grdvector synE.nc synN.nc -Q0.1c+e+jc+h1+gblack -Si0.3c

gmt meca -Sa0.5c <<EOF
0 0 $deprcv $stk $dip $rak 5
EOF

gmt colorbar -Bx+l"Z (cm)"
gmt end


# Single Force
S="1e17"
fn=1
fe=1
fz=0
stgrt.syn -S$S -F$fn/$fe/$fz -N < grn > syn
gmt begin disp_sf pdf
gmt xyz2grd syn -GsynZ.nc -R$y1/$y2/$x1/$x2 -I$ny+n/$nx+n -i0,1,2 -:
gmt xyz2grd syn -GsynN.nc -R$y1/$y2/$x1/$x2 -I$ny+n/$nx+n -i0,1,3 -:
gmt xyz2grd syn -GsynE.nc -R$y1/$y2/$x1/$x2 -I$ny+n/$nx+n -i0,1,4 -:

gmt basemap -Baf -BWSen+t"Force, $fn/$fe/$fz, $S" -JX5c/5c -R$y1/$y2/$x1/$x2
gmt grdimage synZ.nc
gmt grdvector synE.nc synN.nc -Q0.1c+e+jc+h1+gblack -Si0.5c

gmt colorbar -Bx+l"Z (cm)"
gmt end

# Explosion
S="1e23"
stgrt.syn -S$S -N < grn > syn
gmt begin disp_exp pdf
gmt xyz2grd syn -GsynZ.nc -R$y1/$y2/$x1/$x2 -I$ny+n/$nx+n -i0,1,2 -:
gmt xyz2grd syn -GsynN.nc -R$y1/$y2/$x1/$x2 -I$ny+n/$nx+n -i0,1,3 -:
gmt xyz2grd syn -GsynE.nc -R$y1/$y2/$x1/$x2 -I$ny+n/$nx+n -i0,1,4 -:

gmt basemap -Baf -BWSen+t"Explosion, $S" -JX5c/5c -R$y1/$y2/$x1/$x2
gmt grdimage synZ.nc
gmt grdvector synE.nc synN.nc -Q0.1c+e+jc+h1+gblack -Si0.3c

gmt colorbar -Bx+l"Z (cm)"
gmt end

1 change: 1 addition & 0 deletions example/view_integ_stats/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
View slow convergency when source and receiver are at close or same depth.
1 change: 1 addition & 0 deletions example/view_integ_stats/halfspace2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0 4.0 2.7 2.5 9e30 9e30
4 changes: 4 additions & 0 deletions example/view_integ_stats/run_stgrt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash


stgrt -Mhalfspace2 -D0.1/0 -X-3/3/10 -Y-5/5/20 -e -S
97 changes: 97 additions & 0 deletions example/view_integ_stats/view.ipynb

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions pygrt/C_extension/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ CFLAGS := $(LINK_STATIC) $(LFFT_FLAGS) -lm -O3 \
SUBDIRS = \
src/common \
src/dynamic \
src/static \
src/travt


Expand All @@ -56,12 +57,12 @@ all: objs progs libs

objs:
for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir CC="$(CC)" CFLAGS="$(CFLAGS)" objs; \
$(MAKE) -C $$dir CC="$(CC)" CFLAGS="$(CFLAGS)" objs || exit 1; \
done

progs: objs
for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir CC="$(CC)" CFLAGS="$(CFLAGS)" progs; \
$(MAKE) -C $$dir CC="$(CC)" CFLAGS="$(CFLAGS)" progs || exit 1; \
done


Expand Down
6 changes: 4 additions & 2 deletions pygrt/C_extension/include/common/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ typedef int MYINT; ///< 整数
#define FIVEQUARTERPI 3.92699082f ///< \f$ \frac{5\pi}{4} \f$
#define SEVENQUARTERPI 5.49778714f ///< \f$ \frac{7\pi}{4} \f$
#define INV_SQRT_TWO 0.70710678f ///< \f$ \frac{1}{\sqrt{2}} \f$

#define DEG1 0.017453293f ///< \f$ \frac{\pi}{180} \f$

#else
typedef double _Complex MYCOMPLEX;
typedef double MYREAL;
Expand Down Expand Up @@ -109,7 +110,8 @@ typedef int MYINT; ///< 整数
#define FIVEQUARTERPI 3.9269908169872414 ///< \f$ \frac{5\pi}{4} \f$
#define SEVENQUARTERPI 5.497787143782138 ///< \f$ \frac{7\pi}{4} \f$
#define INV_SQRT_TWO 0.7071067811865475 ///< \f$ \frac{1}{\sqrt{2}} \f$

#define DEG1 0.017453292519943295 ///< \f$ \frac{\pi}{180} \f$

#endif

#define CZERO CMPLX(RZERO, RZERO) ///< 0.0 + j0.0
Expand Down
Loading