The customized coefficients for the staggered grid FD are not correctly substituted, at least for the items, tau_zz.dz, vx.dx, vy.dy, vz.dz, for isotropic elastic case. For VTI/TTI, we should double-check again.
The MFE:
from devito import Eq, Operator, VectorTimeFunction, TensorTimeFunction, Grid
from devito import div, grad, diag, solve
import numpy as np
from devito import Coefficient, Substitutions
# set up the model
space_order = 4
shape = (51, 51, 51)
spacing = (10., 10., 10.)
extent = (500, 500, 500)
grid = Grid(shape=shape, extent= extent)
# first-order particle-velocity/strain elastic wave equation
v = VectorTimeFunction(name='v', grid=grid,
save=None,
space_order=space_order, time_order=1,
coefficients='symbolic') # the customized coefficients
tau = TensorTimeFunction(name='tau', grid=grid,
save=None,
space_order=space_order, time_order=1,
coefficients='symbolic') # the customized coefficients
# customized FD coefficients
# weights_opt = np.array([0.4304542E-1, -0.1129136E+1, 0.1129136E+1, -0.4304542E-12])
# weights_opt = np.array([0.1, -1, 1, -0.1])
weights_opt = np.array([0, 0, 0, 0])
x, y, z = grid.dimensions
list_subs_coef = []
for u in v.flat():
for idim, idim_symbol in enumerate(grid.dimensions):
list_subs_coef.append(Coefficient(
1, u, idim_symbol, weights_opt/idim_symbol.spacing))
coeffs_v = Substitutions(*list_subs_coef)
list_subs_coef = []
for u in tau.flat():
for idim, idim_symbol in enumerate(grid.dimensions):
list_subs_coef.append(Coefficient(
1, u, idim_symbol, weights_opt/idim_symbol.spacing))
coeffs_t = Substitutions(*list_subs_coef)
lam = 1.
mu = 1.
b = 1.
# Particle velocity
eq_v = v.dt - b * div(tau)
# Stress
e = (grad(v.forward) + grad(v.forward).T)
eq_tau = tau.dt - lam * diag(div(v.forward)) - mu * e
u_v = Eq(v.forward, solve(eq_v, v.forward),
coefficients=coeffs_v)
print(u_v.evaluate)
u_tau = Eq(tau.forward, solve(eq_tau, tau.forward),
coefficients=coeffs_t)
print(u_tau.evaluate)
OP = Operator([u_v, u_tau])
print(OP)
The coefficients for items, tau_zz.dz, vx.dx, vy.dy, vz.dz are not correctly substituted from the generated C code:
The customized coefficients for the staggered grid FD are not correctly substituted, at least for the items, tau_zz.dz, vx.dx, vy.dy, vz.dz, for isotropic elastic case. For VTI/TTI, we should double-check again.
The MFE:
The coefficients for items, tau_zz.dz, vx.dx, vy.dy, vz.dz are not correctly substituted from the generated C code: