|
20 | 20 | "outputs": [], |
21 | 21 | "source": [ |
22 | 22 | "from devito import *\n", |
| 23 | + "\n", |
23 | 24 | "from examples.seismic import demo_model, AcquisitionGeometry, plot_velocity\n", |
24 | 25 | "from examples.seismic.acoustic import AcousticWaveSolver\n", |
25 | | - "import numpy as np\n", |
| 26 | + "\n", |
26 | 27 | "import matplotlib.pyplot as plt" |
27 | 28 | ] |
28 | 29 | }, |
|
42 | 43 | } |
43 | 44 | ], |
44 | 45 | "source": [ |
| 46 | + "#NBVAL_IGNORE_OUTPUT\n", |
45 | 47 | "model = demo_model('layers-isotropic', vp=3.0, origin=(0., 0.), shape=(101, 101), spacing=(10., 10.), nbl=40, nlayers=4)" |
46 | 48 | ] |
47 | 49 | }, |
|
62 | 64 | } |
63 | 65 | ], |
64 | 66 | "source": [ |
| 67 | + "#NBVAL_IGNORE_OUTPUT\n", |
65 | 68 | "plot_velocity(model)" |
66 | 69 | ] |
67 | 70 | }, |
|
114 | 117 | "execution_count": 5, |
115 | 118 | "metadata": {}, |
116 | 119 | "outputs": [ |
117 | | - { |
118 | | - "name": "stdout", |
119 | | - "output_type": "stream", |
120 | | - "text": [ |
121 | | - "damp(x, y)*Derivative(u(t, x, y), t) - Derivative(u(t, x, y), (x, 2)) - Derivative(u(t, x, y), (y, 2)) + Derivative(u(t, x, y), (t, 2))/vp(x, y)**2\n" |
122 | | - ] |
123 | | - }, |
124 | 120 | { |
125 | 121 | "data": { |
126 | 122 | "text/latex": [ |
|
147 | 143 | "# We can now write the PDE\n", |
148 | 144 | "pde = model.m * u.dt2 - u.laplace + model.damp * u.dt\n", |
149 | 145 | "\n", |
150 | | - "# The PDE representation is as on paper\n", |
151 | | - "print(pde)\n", |
152 | 146 | "\n", |
153 | 147 | "# Stencil update\n", |
154 | 148 | "stencil = Eq(u.forward, solve(pde, u.forward))\n", |
|
209 | 203 | "data": { |
210 | 204 | "text/plain": [ |
211 | 205 | "PerformanceSummary([(PerfKey(name='section0', rank=None),\n", |
212 | | - " PerfEntry(time=0.016828, gflopss=0.0, gpointss=0.0, oi=0.0, ops=0, itershapes=[])),\n", |
| 206 | + " PerfEntry(time=0.01551399999999999, gflopss=0.0, gpointss=0.0, oi=0.0, ops=0, itershapes=[])),\n", |
213 | 207 | " (PerfKey(name='section1', rank=None),\n", |
214 | | - " PerfEntry(time=0.002213999999999991, gflopss=0.0, gpointss=0.0, oi=0.0, ops=0, itershapes=[])),\n", |
| 208 | + " PerfEntry(time=0.0023819999999999913, gflopss=0.0, gpointss=0.0, oi=0.0, ops=0, itershapes=[])),\n", |
215 | 209 | " (PerfKey(name='section2', rank=None),\n", |
216 | | - " PerfEntry(time=0.0021949999999999943, gflopss=0.0, gpointss=0.0, oi=0.0, ops=0, itershapes=[]))])" |
| 210 | + " PerfEntry(time=0.002333999999999994, gflopss=0.0, gpointss=0.0, oi=0.0, ops=0, itershapes=[]))])" |
217 | 211 | ] |
218 | 212 | }, |
219 | 213 | "execution_count": 9, |
|
222 | 216 | } |
223 | 217 | ], |
224 | 218 | "source": [ |
| 219 | + "#NBVAL_IGNORE_OUTPUT\n", |
225 | 220 | "op(dt=model.critical_dt)" |
226 | 221 | ] |
227 | 222 | }, |
|
242 | 237 | } |
243 | 238 | ], |
244 | 239 | "source": [ |
| 240 | + "#NBVAL_IGNORE_OUTPUT\n", |
245 | 241 | "plt.figure(figsize=(12, 6))\n", |
246 | 242 | "plt.subplot(1, 2, 1)\n", |
247 | 243 | "plt.imshow(np.real(freq_mode.data.T), cmap='seismic', vmin=-1e2, vmax=1e2)\n", |
|
251 | 247 | "plt.colorbar()\n", |
252 | 248 | "plt.show()" |
253 | 249 | ] |
| 250 | + }, |
| 251 | + { |
| 252 | + "cell_type": "code", |
| 253 | + "execution_count": 11, |
| 254 | + "metadata": {}, |
| 255 | + "outputs": [], |
| 256 | + "source": [ |
| 257 | + "assert np.isclose(norm(freq_mode), 13873.049, atol=0, rtol=1e-4)\n", |
| 258 | + "assert np.isclose(norm(u), 323.74207, atol=0, rtol=1e-4)" |
| 259 | + ] |
254 | 260 | } |
255 | 261 | ], |
256 | 262 | "metadata": { |
|
0 commit comments