From d03cb9c394b4e67eccb847ce2093cef33bcb95a8 Mon Sep 17 00:00:00 2001 From: George BIsbas Date: Mon, 24 Aug 2020 18:20:38 +0300 Subject: [PATCH] examples: Add kwargs to operators and wavesolvers --- examples/seismic/acoustic/wavesolver.py | 4 ++-- examples/seismic/elastic/operators.py | 5 ++++- examples/seismic/elastic/wavesolver.py | 4 ++-- examples/seismic/self_adjoint/wavesolver.py | 12 ++++-------- examples/seismic/tti/tti_example.py | 7 ++++--- examples/seismic/tti/wavesolver.py | 4 ++-- examples/seismic/viscoacoustic/wavesolver.py | 4 ++-- examples/seismic/viscoelastic/wavesolver.py | 4 ++-- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/examples/seismic/acoustic/wavesolver.py b/examples/seismic/acoustic/wavesolver.py index 1adfefb13c..97df62bf01 100644 --- a/examples/seismic/acoustic/wavesolver.py +++ b/examples/seismic/acoustic/wavesolver.py @@ -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 ------- diff --git a/examples/seismic/elastic/operators.py b/examples/seismic/elastic/operators.py index fe077194b9..62955d776e 100644 --- a/examples/seismic/elastic/operators.py +++ b/examples/seismic/elastic/operators.py @@ -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 @@ -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 diff --git a/examples/seismic/elastic/wavesolver.py b/examples/seismic/elastic/wavesolver.py index ae2b5c2ddf..f993711ab6 100644 --- a/examples/seismic/elastic/wavesolver.py +++ b/examples/seismic/elastic/wavesolver.py @@ -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 ------- diff --git a/examples/seismic/self_adjoint/wavesolver.py b/examples/seismic/self_adjoint/wavesolver.py index acde117b19..f42923fa13 100644 --- a/examples/seismic/self_adjoint/wavesolver.py +++ b/examples/seismic/self_adjoint/wavesolver.py @@ -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 ---------- @@ -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 ---------- @@ -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 ---------- @@ -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 ---------- diff --git a/examples/seismic/tti/tti_example.py b/examples/seismic/tti/tti_example.py index c0bbc207b8..02d8077ecb 100644 --- a/examples/seismic/tti/tti_example.py +++ b/examples/seismic/tti/tti_example.py @@ -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, @@ -17,7 +18,7 @@ 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) def run(shape=(50, 50, 50), spacing=(20.0, 20.0, 20.0), tn=250.0, @@ -25,7 +26,7 @@ def run(shape=(50, 50, 50), spacing=(20.0, 20.0, 20.0), tn=250.0, 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) diff --git a/examples/seismic/tti/wavesolver.py b/examples/seismic/tti/wavesolver.py index 0f1b558e5a..e1f197da22 100644 --- a/examples/seismic/tti/wavesolver.py +++ b/examples/seismic/tti/wavesolver.py @@ -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. diff --git a/examples/seismic/viscoacoustic/wavesolver.py b/examples/seismic/viscoacoustic/wavesolver.py index d7894920a2..e1daad15e9 100755 --- a/examples/seismic/viscoacoustic/wavesolver.py +++ b/examples/seismic/viscoacoustic/wavesolver.py @@ -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 ------- diff --git a/examples/seismic/viscoelastic/wavesolver.py b/examples/seismic/viscoelastic/wavesolver.py index 7bda7ec9ca..56803d9215 100644 --- a/examples/seismic/viscoelastic/wavesolver.py +++ b/examples/seismic/viscoelastic/wavesolver.py @@ -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 -------