You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@sec-wave-pde2-Neumann, and @sec-wave-pde2-var-c][ in
54
-
[@Langtangen_deqbook_wave]][in
55
-
the document [Finite difference methods for wave motion](http://tinyurl.com/k3sdbuv/pub/wave)
56
-
[@Langtangen_deqbook_wave]].
50
+
@sec-wave-pde1-impl, @sec-wave-pde1-impl-vec,
51
+
@sec-wave-pde2-Neumann, and @sec-wave-pde2-var-c.
57
52
There are several quite advanced
58
53
constructs that will be commented upon later.
59
54
The code is lengthy, but that is because we provide a lot of
@@ -286,7 +281,7 @@ Such actions must be
286
281
taken care of outside the `solver` function, more precisely in the
287
282
`user_action` function that is called at every time level.
288
283
289
-
We have, in the [`wave1D_dn_vc.py`](https://github.com/hplgit/fdm-book/tree/master/src/wave/wave1D/wave1D_dn_vc.py)
284
+
We have, in the [`wave1D_dn_vc.py`](https://github.com/devitocodes/devito_book/tree/main/src/wave/wave1D/wave1D_dn_vc.py)
290
285
code, implemented the `user_action`
291
286
callback function as a class `PlotAndStoreSolution` with a
292
287
`__call__(self, x, t, t, n)` method for the `user_action` function.
@@ -357,7 +352,7 @@ The `hashed_input` argument, used to name the
357
352
resulting archive file with all solutions, is supposed to be a
358
353
hash reflecting all import parameters in the problem such that this
359
354
simulation has a unique name.
360
-
The `hashed_input` string is made in the [`solver`](https://github.com/hplgit/fdm-book/tree/master/src/wave/wave1D/wave1D_dn_vc.py) function, using the `hashlib`
355
+
The `hashed_input` string is made in the [`solver`](https://github.com/devitocodes/devito_book/tree/main/src/wave/wave1D/wave1D_dn_vc.py) function, using the `hashlib`
361
356
and `inspect` modules, based on the arguments to `solver`:
362
357
363
358
```python
@@ -419,10 +414,7 @@ solutions to machine precision. With Dirichlet boundary conditions
419
414
we can construct a function that is linear in $t$ and quadratic in
420
415
$x$ that is also an exact solution of the scheme, while with Neumann
421
416
conditions we are left with testing just a constant solution
422
-
(see comments in ref[Section @sec-wave-pde1-verify][ in
423
-
[@Langtangen_deqbook_wave]][in
424
-
the document [Finite difference methods for wave motion](http://tinyurl.com/k3sdbuv/pub/wave)
425
-
[@Langtangen_deqbook_wave]]).
417
+
(see comments in @sec-wave-pde1-verify).
426
418
427
419
### Convergence rates
428
420
@@ -435,9 +427,7 @@ $$
435
427
r = \frac{\ln(E_{i}/E_{i-1})}{\ln(h_{i}/h_{i-1})},
436
428
$$
437
429
where $E_i$ is the error corresponding to $h_i$ and $E_{i-1}$ corresponds to
438
-
$h_{i-1}$. ref[Section @sec-wave-pde2-fd-standing-waves][ in [@Langtangen_deqbook_wave]][The
439
-
section "Using an analytical solution of physical significance": ""
440
-
in [@Langtangen_deqbook_wave]] explains the details of this type of verification and how
430
+
$h_{i-1}$. @sec-wave-pde2-fd-standing-waves explains the details of this type of verification and how
441
431
we introduce the single discretization parameter $h=\Delta t = \hat c\Delta t$,
442
432
for some constant $\hat c$. To compute the error, we had to rely on
443
433
a global variable in the user action function. Below is an implementation
@@ -449,15 +439,12 @@ error (which is always considered an advantage).
449
439
```
450
440
451
441
The returned sequence `r` should converge to 2 since the error
452
-
analysis in ref[Section @sec-wave-pde1-analysis][in
453
-
[@Langtangen_deqbook_wave]][the section "Analysis of the difference
454
-
equations": "" in [@Langtangen_deqbook_wave]] predicts various error measures to behave
442
+
analysis in @sec-wave-pde1-analysis predicts various error measures to behave
455
443
like $\Oof{\Delta t^2} + \Oof{\Delta x^2}$. We can easily run
456
444
the case with standing waves and the analytical solution
457
445
$u(x,t) = \cos(\frac{2\pi}{L}t)\sin(\frac{2\pi}{L}x)$. The call will
458
446
be very similar to the one provided in the `test_convrate_sincos` function
459
-
in ref[Section @sec-wave-pde1-impl-verify-rate][ in [@Langtangen_deqbook_wave]][the section "Verification: convergence rates": "" in
460
-
[@Langtangen_deqbook_wave]], see the file [`wave1D_dn_vc.py`](https://github.com/hplgit/fdm-book/tree/master/src/wave/wave1D/wave1D_dn_vc.py) for details.
447
+
in @sec-wave-pde1-impl-verify-rate, see the file `src/wave/wave1D/wave1D_dn_vc.py` for details.
461
448
462
449
Many who know about class programming prefer to organize their software
463
450
in terms of classes. This gives a richer application programming interface
@@ -482,7 +469,7 @@ how this may be counteracted by introducing a super class `Parameters` that allo
482
469
code to be parameterized. In addition, it is convenient to collect the
483
470
arrays that describe the mesh in a special `Mesh` class and make
484
471
a class `Function` for a mesh function (mesh point values and its mesh).
485
-
All the following code is found in [`wave1D_oo.py`](https://github.com/hplgit/fdm-book/tree/master/src/softeng2/wave1D_oo.py).
472
+
All the following code is found in [`wave1D_oo.py`](https://github.com/devitocodes/devito_book/tree/main/src/softeng2/wave1D_oo.py).
486
473
487
474
## Class Parameters
488
475
@@ -1222,22 +1209,21 @@ is reproduced (within machine precision).
1222
1209
1223
1210
## Speeding up Cython code {#sec-wave2D3D-impl-Cython}
1224
1211
1225
-
We now consider the [`wave2D_u0.py`](https://github.com/hplgit/fdm-book/tree/master/src/wave/wave2D_u0/wave2D_u0.py)
1212
+
We now consider the [`wave2D_u0.py`](https://github.com/devitocodes/devito_book/tree/main/src/wave/wave2D_u0/wave2D_u0.py)
1226
1213
code for solving the 2D linear wave equation with constant wave
1227
1214
velocity and homogeneous Dirichlet boundary conditions $u=0$.
1228
1215
We shall in the present chapter extend this code with computational
1229
1216
modules written in other languages than Python. This extended version is
1230
-
called [`wave2D_u0_adv.py`](https://github.com/hplgit/fdm-book/tree/master/src/softeng2/wave2D_u0_adv.py).
1217
+
called [`wave2D_u0_adv.py`](https://github.com/devitocodes/devito_book/tree/main/src/softeng2/wave2D_u0_adv.py).
1231
1218
1232
1219
The `wave2D_u0.py` file contains a `solver` function, which calls an
1233
1220
`advance_*` function to advance the numerical scheme one level forward
1234
1221
in time. The function `advance_scalar` applies standard Python loops
1235
1222
to implement the scheme, while `advance_vectorized` performs
1236
1223
corresponding vectorized arithmetics with array slices. The statements
1237
-
of this solver are explained in ref[Section @sec-wave-2D3D-impl, in
1238
-
particular Sections @sec-wave2D3D-impl-scalar and
1239
-
@sec-wave2D3D-impl-vectorized][ in [@Langtangen_deqbook_wave]][in
1240
-
the document [Finite difference methods for wave motion](http://tinyurl.com/k3sdbuv/pub/wave) [@Langtangen_deqbook_wave]].
1224
+
of this solver are explained in @sec-wave-2D3D-impl, in
1225
+
particular @sec-wave2D3D-impl-scalar and
1226
+
@sec-wave2D3D-impl-vectorized.
1241
1227
1242
1228
Although vectorization can bring down the CPU time dramatically
1243
1229
compared with scalar code, there is still some factor 5-10 to win in
The truncation error consists of the terms after the first one ($u'$).
403
403
404
-
The module file [`trunc/truncation_errors.py`](https://github.com/hplgit/fdm-book/tree/master/src/trunc/truncation_errors.py) contains another class `DiffOp` with symbolic expressions for
404
+
The module file [`trunc/truncation_errors.py`](https://github.com/devitocodes/devito_book/tree/main/src/trunc/truncation_errors.py) contains another class `DiffOp` with symbolic expressions for
405
405
most of the truncation errors listed in the previous section.
406
406
For example:
407
407
@@ -777,7 +777,7 @@ we pick the rate $r_{m-2}$, which we believe is the best estimation since
The file [`diffu1D_u0.py`](https://github.com/hplgit/fdm-book/tree/master/src/diffu/diffu1D_u0.py)
198
+
The file [`diffu1D_u0.py`](https://github.com/devitocodes/devito_book/tree/main/src/diffu/diffu1D_u0.py)
199
199
contains a complete function `solver_FE_simple`
200
200
for solving the 1D diffusion equation with $u=0$ on the boundary
201
201
as specified in the algorithm above:
@@ -1015,7 +1015,7 @@ and a smooth Gaussian function,
1015
1015
$$
1016
1016
I(x) = e^{-\frac{1}{2\sigma^2}(x-L/2)^2}\tp
1017
1017
$$
1018
-
The functions `plug` and `gaussian` in [`diffu1D_u0.py`](https://github.com/hplgit/fdm-book/tree/master/src/diffu/diffu1D_u0.py) run the two cases,
1018
+
The functions `plug` and `gaussian` in [`diffu1D_u0.py`](https://github.com/devitocodes/devito_book/tree/main/src/diffu/diffu1D_u0.py) run the two cases,
1019
1019
respectively:
1020
1020
1021
1021
```python
@@ -1409,7 +1409,7 @@ The `scipy.sparse.linalg.spsolve` function utilizes the sparse storage
1409
1409
structure of `A` and performs, in this case, a very efficient Gaussian
1410
1410
elimination solve.
1411
1411
1412
-
The program [`diffu1D_u0.py`](https://github.com/hplgit/fdm-book/tree/master/src/diffu/diffu1D_u0.py)
1412
+
The program [`diffu1D_u0.py`](https://github.com/devitocodes/devito_book/tree/main/src/diffu/diffu1D_u0.py)
1413
1413
contains a function `solver_BE`, which implements the Backward Euler scheme
0 commit comments