-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/tduretz/SeismicQ
- Loading branch information
Showing
18 changed files
with
1,150 additions
and
8 deletions.
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# SeismicQ | ||
|
||
<h1> <img src="docs/src/assets/logo.png" alt="SeismicQ.jl" width="50"> SeismicQ </h1> | ||
|
||
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://tduretz.github.io/SeismicQ/dev/) | ||
[![Build Status](https://github.com/tduretz/SeismicQ/workflows/CI/badge.svg)](https://github.com/tduretz/SeismicQ/actions) | ||
|
||
<h1> <img src="docs/src/assets/visuel_ecocup2.png" alt="SeismicQ.jl" width="500"> </h1> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
|
@@ -8,4 +8,7 @@ Ricker | |
``` | ||
```@docs | ||
f_bulk | ||
Spec | ||
ComputeQgraph | ||
Getfreq | ||
``` |
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,89 @@ | ||
# Function that generates a seismic trace (Ricker function), attenuating along time, | ||
# and plot a receiver gather (received waves at different geophone positions) | ||
|
||
using SeismicQ, Plots, SpecialFunctions, LinearAlgebra, Printf | ||
|
||
function main() | ||
|
||
# Functtion that create a vector of time and | ||
function FausseTrace(x,Ξt,Nt,t,Vp,Vs,Ξ±p,Ξ±s,πβ,tβ) | ||
|
||
tβp = x/Vp | ||
tβs = x/Vs | ||
|
||
# Storage | ||
time = zeros(Nt) | ||
acc = zeros(Nt) | ||
|
||
# Time loop | ||
for it=1:Nt | ||
|
||
# Compute Ricker function | ||
t += Ξt | ||
a = 0.5 * exp(-Ξ±p*x)*Ricker(t, tβp+tβ, πβ)+ 0.5 * exp(-Ξ±s*x)*Ricker(t, tβs+tβ, πβ) | ||
|
||
# For visualisation purpose | ||
time[it] = t | ||
acc[it] = a | ||
end | ||
|
||
return(time',acc') | ||
|
||
end | ||
|
||
# Geophone position [m] | ||
listβ = 0:100:5000; | ||
|
||
# Time domain | ||
Ξt = 1e-3 | ||
Nt = 2000 | ||
# Central frequency of the source [Hz] | ||
πβ = 10. | ||
tβ = 1.0/πβ | ||
t = -tβ | ||
|
||
# Velocities | ||
Vp = 7000 # m/s | ||
Vs = 4000 | ||
Ξ±p = 2e-4 | ||
Ξ±s = 4e-4 # (Ο * f)/ (Q * V) | ||
|
||
time_axis = t:(Ξt*Nt-t)/(Nt-1):Ξt*Nt ; | ||
time_vec = zeros(size(listβ,1),Nt); | ||
acc_vec = zeros(size(listβ,1),Nt); | ||
time_vec[1,:],acc_vec[1,:]= FausseTrace(listβ[1,1],Ξt,Nt,t,Vp,Vs,Ξ±p,Ξ±s,πβ,tβ); | ||
dist_axis = 0:1: size(listβ,1)-1; # distances des geophones pour l instant 1,2,3,... | ||
|
||
for i=1:size(listβ,1)-1 | ||
time_vec[i+1,:],acc_vec[i+1,:] = FausseTrace(listβ[i+1,1],Ξt,Nt,t,Vp,Vs,Ξ±p,Ξ±s,πβ,tβ) | ||
end | ||
|
||
seismic_matrix = hcat(listβ,acc_vec); | ||
@show size(seismic_matrix) | ||
#= | ||
# Visualisation si peu de positions | ||
fig1 = plot(layout = (size(listβ,1),1)) | ||
p1 = plot!(fig1[1],time_vec[1,:], acc_vec[1,:], xlabel="t", ylabel="a") | ||
for i=1:size(listβ,1)-1 | ||
p1 = plot!(fig1[i+1],time_vec[i+1,:], acc_vec[i+1,:], xlabel="t", ylabel="a") | ||
end | ||
display(fig1) | ||
=# | ||
|
||
# Visualisation of receiver gather | ||
#p2 = heatmap(dist_axis,time_axis,acc_vec', | ||
p2 = heatmap(listβ,time_axis,acc_vec', | ||
color=palette(:RdBu, 100, rev=true), | ||
clim=(-0.5, 0.5), | ||
cbar=true, | ||
label=" ", | ||
yflip=true, | ||
title = "Receiver gather", | ||
xlabel = "Geophone position [m]", | ||
ylabel = "Time [s]") | ||
display(plot(p2)) # equivalent du drawnow | ||
|
||
|
||
end | ||
main() |
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,86 @@ | ||
using SeismicQ,Plots | ||
|
||
function main() | ||
|
||
#P and S velocities | ||
Vp=7000 | ||
Vs=4000 | ||
|
||
SeismicMatrix=GenMatrix(Vp,Vs) | ||
|
||
#distances from source | ||
d1=3000 | ||
d2=5000 | ||
|
||
#Number of samples and time increment of traces | ||
Nt=2000 | ||
dt=1e-3 | ||
|
||
#min and max frequencies to compute Q | ||
fqmin=5.0 | ||
fqmax=20.0 | ||
|
||
Tmax=dt*Nt | ||
time=[dt*i for i=1:Nt] | ||
|
||
println("Trace length is $Tmax s using $Nt samples") | ||
|
||
ind1=Int(trunc(d1/100)) | ||
ind2=Int(trunc(d2/100)) | ||
|
||
rec1=SeismicMatrix[ind1,2:Nt+1] | ||
rec2=SeismicMatrix[ind2,2:Nt+1] | ||
|
||
println("Trace 1 at offset $d1 m is found at index $ind1") | ||
println("Trace 2 at offset $d2 m is found at index $ind2") | ||
|
||
ampmin=-0.15 | ||
ampmax=0.3 | ||
|
||
p1=plot(time,rec1,xlabel="time (s)",ylabel="acc. (m.sβ»Β²)",ylim=(ampmin,ampmax),c=:"blue") | ||
p2=plot(time,rec2,xlabel="time (s)",ylabel="acc. (m.sβ»Β²)",ylim=(ampmin,ampmax),c=:"red") | ||
|
||
# second part rec1: | ||
println("Trace 1:") | ||
|
||
ampP,ampS,frequP,frequS=Spec(rec1,0.1,dt,Nt,0.4,0.75,0.35) | ||
|
||
ymax=maximum(ampP) | ||
|
||
p3=plot(frequP,ampP,title="P",xlabel="f(Hz)",ylabel="Amp",ylim=(0,ymax),c=:"blue") | ||
p4=plot(frequS,ampS,title="S",xlabel="f(Hz)",ylabel="Amp",ylim=(0,ymax),c=:"blue") | ||
|
||
#plot(p1,p3,p4,layout=(2,2)) | ||
|
||
# second part rec2: | ||
println("Trace 2:") | ||
|
||
ampP2,ampS2,frequP2,frequS2=Spec(rec2,0.1,dt,Nt,0.7,1.25,0.35) | ||
|
||
p5=plot(frequP2,ampP2,title="P2",xlabel="f(Hz)",ylabel="Amp",ylim=(0,ymax),c=:"red") | ||
p6=plot(frequS2,ampS2,title="S2",xlabel="f(Hz)",ylabel="Amp",ylim=(0,ymax),c=:"red") | ||
|
||
|
||
@show frequP | ||
indf=findall(x->x>fqmin && x<fqmax,frequP) | ||
@show indf | ||
|
||
#Qp=zeros(length(indf)) | ||
|
||
xp,yp=ComputeQgraph(ampP,ampP2,frequP,indf,d1,d2,Vp) | ||
|
||
p7=plot(xp,yp,xlabel="f(Hz)",ylim=(-1.0,0.),title="Qgraph for P phase",c=:"green") | ||
|
||
xs,ys=ComputeQgraph(ampS,ampS2,frequS,indf,d1,d2,Vs) | ||
|
||
@show xs,ys | ||
|
||
p8=plot(xs,ys,xlabel="f(Hz)",ylim=(-1.0,0.),title="Qgraph for S phase",c=:"green") | ||
|
||
|
||
plot(p1,p2,p3,p5,p4,p6,p7,p8,layout=(4,2),legend=false) | ||
#plot(p7,legend=false) | ||
|
||
end | ||
|
||
main() |
File renamed without changes.
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,128 @@ | ||
using SeismicQ, Plots | ||
|
||
function MainSource() | ||
|
||
# Spatial extent | ||
Lx = 50.0 | ||
|
||
# Mechanical parameters | ||
Οβ = 1500.0 | ||
Kβ = 1.e9 | ||
Gβ = 1.e8 | ||
cβ = sqrt((Kβ+4/3*Gβ)/Οβ) | ||
|
||
# Discretization | ||
Ncx = 200 | ||
Ξx = Lx/Ncx | ||
xv = LinRange(0,Lx,Ncx+1) | ||
xc = LinRange(0-Ξx/2,Lx+Ξx/2,Ncx+2) | ||
|
||
# Source parameters | ||
πβ = 200 # Central frequency of the source [Hz] | ||
tβ = 1.2/πβ | ||
isrc = Int((Ncx/2)+1) | ||
|
||
# Time domain | ||
Ξt = min(1e10, Ξx/cβ) # Courant criteria from wavespeed | ||
Nt = 100 | ||
Nout = 10 | ||
t = 0.0#-tβ | ||
|
||
# Parameters for Sismo. | ||
Xs = 25:0.5:50 # x_coordinates [m] | ||
Ns = size(Xs,1) | ||
ds = zeros(size(Xs)) | ||
@. ds = abs(Xs-xv[isrc]) | ||
velocity_matrix = zeros(Ns, Nt) | ||
time = zeros(Nt) | ||
|
||
# Storage on centers # +2 for ghost nodes for BCs | ||
szv = (Ncx+1,) | ||
szc = (Ncx+2,) | ||
# Storage on centroids | ||
K = ones(szc)*Kβ | ||
G = ones(szc)*Gβ | ||
Ξ΅Μ = ( xx=zeros(szc), yy=zeros(szc), zz=zeros(szc), xy=zeros(szc), yz=zeros(szc), xz=zeros(szc) ) | ||
βV = zeros(Ncx+2) | ||
P = zeros(Ncx+2) | ||
Ο = ( xx=zeros(szc), yy=zeros(szc), zz=zeros(szc), xy=zeros(szc), yz=zeros(szc), xz=zeros(szc) ) | ||
βVxβx = zeros(szc) | ||
# Storage on vertices | ||
V = ( x=zeros(szv), y=zeros(szv), z=zeros(szv)) | ||
Ο = ones(szv)*Οβ | ||
f_ext = zeros(szv) | ||
|
||
# BC | ||
Lbc = 2. | ||
bc_filtW_v = 1.0 .- exp.(-(xv.-0Lx).^2/Lbc.^2) | ||
bc_filtW_c = 1.0 .- exp.(-(xc.-0Lx).^2/Lbc.^2) | ||
bc_filtE_v = 1.0 .- exp.(-(xv.- Lx).^2/Lbc.^2) | ||
bc_filtE_c = 1.0 .- exp.(-(xc.- Lx).^2/Lbc.^2) | ||
|
||
# Time loop | ||
@time for it=1:Nt | ||
|
||
# Compute Ricker function | ||
t += Ξt | ||
a = Ricker(t, tβ, πβ) | ||
f_ext[isrc] = Ο[isrc]*a | ||
|
||
# Velocity gradient components | ||
@. βVxβx[2:end-1] = (V.x[2:end] - V.x[1:end-1])/Ξx | ||
|
||
# Divergence | ||
@. βV = βVxβx | ||
|
||
# Deviatoric strain rate | ||
@. Ξ΅Μ.xx = βVxβx - 1/3*βV | ||
|
||
# Stress update | ||
@. Ο.xx = f_shear(G)*Ξt*(Ξ΅Μ.xx) + f_relax(G)*Ο.xx | ||
|
||
# Pressure update | ||
@. P = P - Ξt*f_bulk(K)*βV | ||
|
||
# Linear momentum balance | ||
@. V.x[2:end-1] = V.x[2:end-1] + Ξt/Ο[2:end-1]*((Ο.xx[3:end-1]-Ο.xx[2:end-2])/Ξx - (P[3:end-1]-P[2:end-2])/Ξx - f_ext[2:end-1]) | ||
|
||
# Absorbing boundary Cerjean et al. (1985) | ||
@. V.x = V.x * bc_filtW_v | ||
@. P = P * bc_filtW_c | ||
@. Ο.xx = Ο.xx * bc_filtW_c | ||
@. V.x = V.x * bc_filtE_v | ||
@. P = P * bc_filtE_c | ||
@. Ο.xx = Ο.xx * bc_filtE_c | ||
|
||
# Visualisation | ||
if mod(it, Nout)==0 | ||
display(plot(xv, V.x, ylim=(-2e-4, 2e-4))) | ||
sleep(0.1) | ||
end | ||
|
||
# Extract sismo data: | ||
time[it] = t | ||
@. velocity_matrix[:,it] = V.x[Int(Xs[:]/Ξx)+1] | ||
|
||
end | ||
|
||
# Visualization Receiver Gather: | ||
valim = max(abs(maximum(velocity_matrix)),abs(minimum(velocity_matrix))) | ||
p = heatmap(ds,time,velocity_matrix',color=palette(:RdBu,100,rev=true), | ||
title="Receiver gather", xlabel="distance to the source [m]", | ||
ylabel="time [s]",yflip=true,clim=(-valim,+valim)) | ||
display(p) | ||
|
||
end | ||
|
||
function f_bulk(K) | ||
return K | ||
end | ||
|
||
function f_shear(G) | ||
return 2*G | ||
end | ||
function f_relax(G) | ||
return 1. | ||
end | ||
|
||
MainSource() |
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
Oops, something went wrong.