Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples: Fix opt arg-passing for elastic and TTI #1425

Merged
merged 1 commit into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions examples/seismic/acoustic/wavesolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def forward(self, src=None, rec=None, u=None, vp=None, save=None, **kwargs):
Stores the computed wavefield.
vp : Function or float, optional
The time-constant velocity.
save : int or Buffer, optional
The entire (unrolled) wavefield.
save : bool, optional
Whether or not to save the entire (unrolled) wavefield.

Returns
-------
Expand Down
5 changes: 4 additions & 1 deletion examples/seismic/elastic/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ def ForwardOperator(model, geometry, space_order=4, save=False, **kwargs):
"""

v = VectorTimeFunction(name='v', grid=model.grid,
save=geometry.nt if save else None,
space_order=space_order, time_order=1)
tau = TensorTimeFunction(name='tau', grid=model.grid,
save=geometry.nt if save else None,
space_order=space_order, time_order=1)

lam, mu, b = model.lam, model.mu, model.b
Expand All @@ -63,6 +65,7 @@ def ForwardOperator(model, geometry, space_order=4, save=False, **kwargs):
model.damp * dt * mu * (grad(v.forward) + grad(v.forward).T))

srcrec = src_rec(v, tau, model, geometry)
op = Operator([u_v] + [u_t] + srcrec, subs=model.spacing_map, name="ForwardElastic")
op = Operator([u_v] + [u_t] + srcrec, subs=model.spacing_map, name="ForwardElastic",
**kwargs)
# Substitute spacing terms to reduce flops
return op
4 changes: 2 additions & 2 deletions examples/seismic/elastic/wavesolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def forward(self, src=None, rec1=None, rec2=None, lam=None, mu=None, b=None,
The Shear modulus `(rho * vs*2)`.
b : Function, optional
The time-constant inverse density (b=1 for water).
save : int or Buffer, optional
Option to store the entire (unrolled) wavefield.
save : bool, optional
Whether or not to save the entire (unrolled) wavefield.

Returns
-------
Expand Down
12 changes: 4 additions & 8 deletions examples/seismic/self_adjoint/wavesolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def forward(self, src=None, rec=None, b=None, vp=None, damp=None, u=None,
The time-constant dissipation only attenuation w/Q field.
u : Function or float
Stores the computed wavefield.
save : int or Buffer
Whether (int nt) or not (None) to save the wavefield time history.
save : bool, optional
Whether or not to save the entire (unrolled) wavefield.

Returns
----------
Expand Down Expand Up @@ -146,8 +146,6 @@ def adjoint(self, rec, src=None, b=None, v=None, damp=None, vp=None,
The time-constant dissipation only attenuation w/Q field.
ua : Function or float
Stores the computed adjoint wavefield.
save : int or Buffer, optional
Whether (int nt) or not (None) to save the wavefield time history.

Returns
----------
Expand Down Expand Up @@ -195,8 +193,8 @@ def jacobian(self, dm, src=None, rec=None, b=None, vp=None, damp=None,
Stores the computed background wavefield.
du : Function or float
Stores the computed perturbed wavefield.
save : int or Buffer
Whether (int nt) or not (None) to save the wavefield time history.
save : bool, optional
Whether or not to save the entire (unrolled) wavefield.

Returns
----------
Expand Down Expand Up @@ -246,8 +244,6 @@ def jacobian_adjoint(self, rec, u0, b=None, vp=None, damp=None,
The perturbation to the velocity model.
du : Function or float
Stores the computed perturbed wavefield.
save : int or Buffer
Whether (int nt) or not (None) to save the wavefield time history.

Returns
----------
Expand Down
7 changes: 4 additions & 3 deletions examples/seismic/tti/tti_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@


def tti_setup(shape=(50, 50, 50), spacing=(20.0, 20.0, 20.0), tn=250.0,
space_order=4, nbl=10, preset='layers-tti', **kwargs):
kernel='centered', space_order=4, nbl=10, preset='layers-tti',
**kwargs):

# Two layer model for true velocity
model = demo_model(preset, shape=shape, spacing=spacing,
Expand All @@ -17,15 +18,15 @@ def tti_setup(shape=(50, 50, 50), spacing=(20.0, 20.0, 20.0), tn=250.0,
# Source and receiver geometries
geometry = setup_geometry(model, tn)

return AnisotropicWaveSolver(model, geometry, space_order=space_order)
return AnisotropicWaveSolver(model, geometry, space_order=space_order, **kwargs)
georgebisbas marked this conversation as resolved.
Show resolved Hide resolved


def run(shape=(50, 50, 50), spacing=(20.0, 20.0, 20.0), tn=250.0,
autotune=False, time_order=2, space_order=4, nbl=10,
kernel='centered', full_run=False, **kwargs):

solver = tti_setup(shape=shape, spacing=spacing, tn=tn, space_order=space_order,
nbl=nbl, **kwargs)
nbl=nbl, kernel=kernel, **kwargs)
info("Applying Forward")

rec, u, v, summary = solver.forward(autotune=autotune, kernel=kernel)
Expand Down
4 changes: 2 additions & 2 deletions examples/seismic/tti/wavesolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def forward(self, src=None, rec=None, u=None, v=None, vp=None,
The time-constant Dip angle (radians).
phi : Function or float, optional
The time-constant Azimuth angle (radians).
save : int or Buffer
Option to store the entire (unrolled) wavefield.
save : bool, optional
Whether or not to save the entire (unrolled) wavefield.
kernel : str, optional
Type of discretization, centered or shifted.

Expand Down
4 changes: 2 additions & 2 deletions examples/seismic/viscoacoustic/wavesolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def forward(self, src=None, rec=None, v=None, r=None, p=None, qp=None, b=None,
The time-constant inverse density.
vp : Function or float, optional
The time-constant velocity.
save : int or Buffer, optional
Option to store the entire (unrolled) wavefield.
save : bool, optional
Whether or not to save the entire (unrolled) wavefield.

Returns
-------
Expand Down
4 changes: 2 additions & 2 deletions examples/seismic/viscoelastic/wavesolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def forward(self, src=None, rec1=None, rec2=None, lam=None, qp=None, mu=None, qs
The S-wave quality factor (dimensionless).
b : Function, optional
The time-constant inverse density (1/rho=1 for water).
save : int or Buffer, optional
Option to store the entire (unrolled) wavefield.
save : bool, optional
Whether or not to save the entire (unrolled) wavefield.

Returns
-------
Expand Down