Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
core-man committed Aug 8, 2021
0 parents commit e992c1c
Show file tree
Hide file tree
Showing 37 changed files with 9,807 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# GMT
gmt.conf
gmt.history

# Visual Studio Code
.vscode

# macOS
.DS_Store

# vim
*~
.*.swp
25 changes: 25 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright (c) 2021 by Tong Ping
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the developers nor the names of any contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
141 changes: 141 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# Adjoint-state Traveltime Tomography (Trainning Version)

![Repository size](https://img.shields.io/github/repo-size/MIGG-NTU/ATT_Training)

The code is for adjoint-state traveltime tomography in the Cartesian coordinates.
This version is for trainning purpose only.

## Requirements

In order to run the codes, you have to install the following software:

1. [GNU Fortran](https://gcc.gnu.org/fortran/) [[Operating system setup tutorials in Chinese](https://seismo-learn.org/seismology101/computer/setup/)]

```
# Fedora
$ sudo dnf install gcc-gfortran
# CentOS
$ sudo yum install gfortran
# Ubuntu/Debian
$ sudo apt install gfortran
# macOS
$ brew install gfortran
```
2. [Generic Mapping Tools (GMT)](https://www.generic-mapping-tools.org/) [[GMT reference book in Chinese](https://docs.gmt-china.org/latest/install/)]
## Part I: Data
```
$ cd data
```
Prepare your data in `dataInFormat_D_xyz` following the designed format.
I use `syntheticData.f90` to generate synthetic earthquakes and seismic stations.
```
$ cd dataSelection/0_commandCenter/
```
Set the parameters in `parametersData.F90`.
You can select the regions for earthquakes and seismic stations.
The two regions can be different.
```
$ ./workflowStep.sh
```
## Part II: CommandCenter
```
$ cd ../../../commandCenter
```
You should have the following files ready at `../data/`:
1. `sources`
2. `receivers`
3. `nevtstaray`
4. `evtstaminmax`
5. `traveltimeReceiverGathers`
Set the parameters in `parametersGenerator.F90`. The dimension of the forward grid,
number of multiple grids, iteration number and some others can be defined here.
You can compile and execute `parametersGenerator.F90` at this time.
```
$ gfortran -o xpara parametersGenerator.F90
$ ./xpara
$ rm xpara
```
## Part III: Model
```
cd ../model
```
If this is for a recovery test, you can set up the target velocity model by editing `velocity3d_true.F90`.
```
$ gfortran -o xvel velocity3d_true.F90
$ ./xvel
$ rm xvel
```
Otherwise, just define the initial model for seismic tomography by editing `velocity3d.F90`.
```
$ gfortran -o xvel velocity3d.F90
$ ./xvel
$ rm xvel
```
## Part IV: Mesh
```
cd ../mesh
```
Edit `memeshgenerator.F90` to adjust the size of the inversion grid.
The following three parameters should be properly set.
```Fortran
invx = 12
invy = 3
invz = 11
```

In general, we sample one-wavelength anomaly by 5 grid points or the grid interval
is about one fourth of the anomaly wavelength.

```
$ gfortran -o xmesh meshgenerator.F90
$ ./xmesh
$ rm xmesh regmesh.mod
```

## Part V: CommandCenter

```
cd ../commandCenter
# Run it if this is a recovery test
$ ./workflow_obstime.sh
$ ./workflow_inversion.sh
```

The obtained velocity model is located at `../inversion/` as `velocity3d015`.

## Part VI: Figure

You can display the results along the cross-section set by `lineEnds`:

```
$ ./plot-cross-section.sh
```

The Bash script will call `zCutVelocity.f90` and the gmt script `vcut.gmt`.
55 changes: 55 additions & 0 deletions commandCenter/parametersGenerator.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

program param
implicit none
include "../data/evtstaminmax"
double precision,parameter :: eps = 1.0E-8
double precision,parameter :: zbeg=-36.0,zend=2.0
double precision,parameter :: dx=0.40,dy= 0.4,dz=0.4 ! x -> longitude, y -> latitude
double precision :: xbeg,xend,ybeg,yend
integer,parameter :: next=5
integer :: nx,ny,nz

! (0) How many iterations will you conduct? (start from 1)
integer,parameter :: niter = 15

! the maximum ratio of traveltime residual over obs and the absolute residual are bounded by tbd and tabs
double precision,parameter :: tbd=0.50,tabs=5.0

double precision,parameter :: updatemax=0.02

! (6) how many sets of inversion grid for velocity inversion (you should prepare the meshes)
integer,parameter :: ngrid = 5


open(11,file='gridnumber')
write(11,'(A26,I5)') "integer,parameter :: nset=",ngrid
close(11)

open(40,file='../inversion/parameter_inversion')
write(40,'(A27,I6)') "integer,parameter :: niter=",niter
write(40,'(A34,F12.5,A7,F12.5)') &
"double precision,parameter :: tbd=",tbd,", tabs=",tabs
write(40,'(A40,F12.5)') "double precision,parameter :: updatemax=",updatemax
close(40)


xbeg = xmin - next*dx
xend = xmax + next*dx
ybeg = ymin - next*dy
yend = ymax + next*dy

nx = max(ifix(real((xend + eps - xbeg)/dx))+1,2)
ny = max(ifix(real((yend + eps - ybeg)/dy))+1,2)
nz = max(ifix(real((zend + eps - zbeg)/dz))+1,2)

open(10,file='region')
write(10,'(A35,F12.5,A7,F12.5)') "double precision,parameter :: xbeg=",xbeg,", xend=",xbeg+(nx-1)*dx
write(10,'(A35,F12.5,A7,F12.5)') "double precision,parameter :: ybeg=",ybeg,", yend=",ybeg+(ny-1)*dy
write(10,'(A35,F12.5,A7,F12.5)') "double precision,parameter :: zbeg=",zbeg,", zend=",zbeg+(nz-1)*dz
write(10,'(A33,F12.5,A5,F12.5,A5,F12.5)') "double precision,parameter :: dx=",dx,", dy=",dy,", dz=",dz
write(10,'(A24,I5,A5,I5,A5,I5)') "integer,parameter :: nx=",nx,", ny=",ny,", nz=",nz
close(10)


stop
end
5 changes: 5 additions & 0 deletions commandCenter/region
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
double precision,parameter :: xbeg= -2.00000, xend= 242.00000
double precision,parameter :: ybeg= -2.00000, yend= 2.00000
double precision,parameter :: zbeg= -36.00000, zend= 2.00000
double precision,parameter :: dx= 0.40000, dy= 0.40000, dz= 0.40000
integer,parameter :: nx= 611, ny= 11, nz= 96
28 changes: 28 additions & 0 deletions commandCenter/workflow_inversion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

gfortran -o xpara parametersGenerator.F90
./xpara
rm xpara

##################### model ##################
cd ../model/
gfortran -o xvel velocity3d.F90
./xvel
rm xvel
cd ../commandCenter/

###################### mesh ##################
cd ../mesh/
gfortran -o xmesh meshgenerator.F90
./xmesh
rm xmesh regmesh.mod
cd ../commandCenter/

###################### data ###################
cd ../inversion/
gfortran -o xinv inversion.F90
./xinv
rm xinv parameter_inversion mesh.mod velmodel.mod

cd ../commandCenter/
rm gridnumber
22 changes: 22 additions & 0 deletions commandCenter/workflow_obstime.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

gfortran -o xpara parametersGenerator.F90
./xpara
rm xpara

################# model ##############
cd ../model/
gfortran -o xvel velocity3d_true.F90
./xvel
rm xvel
cd ../commandCenter/

################## data ##############
cd ../inversion/
gfortran -o xsyn syntheticTraveltimes.f90
./xsyn
rm xsyn velmodel.mod

cd ../data
cp traveltimeReceiverGathers_synthetic traveltimeReceiverGathers
cd ../commandCenter/
Loading

0 comments on commit e992c1c

Please sign in to comment.