-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from NDF-Poli-USP/issue_0130_stacey
Implement Stacey boundary condition
- Loading branch information
Showing
7 changed files
with
364 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import numpy as np | ||
import spyro | ||
|
||
|
||
output_dir = "results" | ||
|
||
L = 3000 # Edge size [m] | ||
n = 60 # Number of elements in each direction | ||
h = L/n # Element size [m] | ||
|
||
rho = 2700 # Density [kg/m3] | ||
Vp = 3000 # P wave velocity [m/s] | ||
Vs = 1732 # S wave velocity [m/s] | ||
|
||
smag = 1e6 | ||
freq = 10 # Central frequency of Ricker wavelet [Hz] | ||
source_locations = [[-L/2, L/2]] | ||
|
||
time_step = 2e-4 # [s] | ||
final_time = 2.0 # [s] | ||
out_freq = int(0.01/time_step) | ||
|
||
|
||
def build_solver(local_abc, dt_scheme): | ||
d = {} | ||
|
||
d["options"] = { | ||
"cell_type": "T", | ||
"variant": "lumped", | ||
"degree": 4, | ||
"dimension": 2, | ||
} | ||
|
||
d["parallelism"] = { | ||
"type": "automatic", | ||
} | ||
|
||
d["mesh"] = { | ||
"Lz": L, | ||
"Lx": L, | ||
"Ly": 0, | ||
"h": h, | ||
"mesh_file": None, | ||
"mesh_type": "firedrake_mesh", | ||
} | ||
|
||
d["acquisition"] = { | ||
"source_type": "ricker", | ||
"source_locations": source_locations, | ||
"frequency": freq, | ||
"delay": 1.5, | ||
"delay_type": "multiples_of_minimun", | ||
"amplitude": smag * np.array([0, 1]), | ||
"receiver_locations": [], | ||
} | ||
|
||
d["synthetic_data"] = { | ||
"type": "object", | ||
"density": rho, | ||
"p_wave_velocity": Vp, | ||
"s_wave_velocity": Vs, | ||
"real_velocity_file": None, | ||
} | ||
|
||
d["time_axis"] = { | ||
"initial_time": 0, | ||
"final_time": final_time, | ||
"dt": time_step, | ||
"output_frequency": out_freq, | ||
"gradient_sampling_frequency": 1, | ||
} | ||
|
||
d["visualization"] = { | ||
"forward_output": False, | ||
"time": True, | ||
"time_filename": f"{output_dir}/time.npy", | ||
"mechanical_energy": True, | ||
"mechanical_energy_filename": f"{output_dir}/mechanical_energy_{local_abc}_{dt_scheme}.npy", | ||
} | ||
|
||
if local_abc is not None: | ||
d["absorving_boundary_conditions"] = { | ||
"status": True, | ||
"damping_type": "local", | ||
"local": { | ||
"type": local_abc, | ||
"dt_scheme": dt_scheme, | ||
}, | ||
} | ||
|
||
wave = spyro.IsotropicWave(d) | ||
wave.set_mesh(mesh_parameters={'dx': h}) | ||
|
||
return wave |
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
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,21 @@ | ||
from firedrake import (Constant, div, dx, grad, inner) | ||
|
||
|
||
def mechanical_energy_form(wave): | ||
u_nm1 = wave.u_nm1 | ||
u_n = wave.u_n | ||
|
||
dt = Constant(wave.dt) | ||
rho = wave.rho | ||
lmbda = wave.lmbda | ||
mu = wave.mu | ||
|
||
# Kinetic energy | ||
v = (u_n - u_nm1)/dt | ||
K = (rho/2)*inner(v, v)*dx | ||
|
||
# Strain energy | ||
eps = lambda v: 0.5*(grad(v) + grad(v).T) | ||
U = (lmbda*div(u_n)*div(u_n) + 2*mu*inner(eps(u_n), eps(u_n)))*dx | ||
|
||
return K + U |
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.