Skip to content

Commit

Permalink
Merge pull request #83 from devitocodes/file_links
Browse files Browse the repository at this point in the history
Implement github links
  • Loading branch information
jakubbober authored Sep 22, 2020
2 parents ded6209 + 5cd36c8 commit 30405c3
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 140 deletions.
28 changes: 14 additions & 14 deletions fdm-devito-notebooks/01_vib/vib_undamped.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@
"with the aid of a calculator\n",
"and make a function for comparing these results with those from the `solver`\n",
"function. The `test_three_steps` function in\n",
"the file [`vib_undamped.py`](${src_vib}/vib_undamped.py)\n",
"the file [`vib_undamped.py`](https://github.com/devitocodes/devito_book/blob/master/fdm-devito-notebooks/01_vib/src-vib/vib_undamped.py)\n",
"shows the details of how we use the hand calculations to test the code:"
]
},
Expand Down Expand Up @@ -908,15 +908,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The complete code appears in the file [`vib_undamped.py`](src-vib/vib_undamped.py).\n",
"The complete code appears in the file [`vib_undamped.py`](https://github.com/devitocodes/devito_book/blob/master/fdm-devito-notebooks/01_vib/src-vib/vib_undamped.py).\n",
"\n",
"\n",
"### Visualizing convergence rates with slope markers\n",
"\n",
"Tony S. Yu has written a script [`plotslopes.py`](http://goo.gl/A4Utm7)\n",
"that is very useful to indicate the slope of a graph, especially\n",
"a graph like $\\ln E = r\\ln \\Delta t + \\ln C$ arising from the model\n",
"$E=C\\Delta t^r$. A copy of the script resides in the [`src-vib`](src-vib)\n",
"$E=C\\Delta t^r$. A copy of the script resides in the [`src-vib`](https://github.com/devitocodes/devito_book/tree/master/fdm-devito-notebooks/01_vib/src-vib)\n",
"directory. Let us use it to compare the original method for $u'' + \\omega^2u =0$\n",
"with the same method applied to the equation with a modified\n",
"$\\omega$. We make log-log plots of the error versus $\\Delta t$.\n",
Expand Down Expand Up @@ -1951,7 +1951,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The code segments are found in the file [`vib_empirical_analysis.py`](src-vib/vib_empirical_analysis.py).\n",
"The code segments are found in the file [`vib_empirical_analysis.py`](https://github.com/devitocodes/devito_book/blob/master/fdm-devito-notebooks/01_vib/src-vib/vib_empirical_analysis.py).\n",
"\n",
"Since `a[i]` and `p[i]` correspond to\n",
"the $i$-th amplitude estimate and the $i$-th period estimate, respectively,\n",
Expand Down Expand Up @@ -2367,7 +2367,7 @@
"[Figure](#vib:ode1:tildeomega:plot) plots the discrete frequency\n",
"([18](#vib:ode1:tildeomega)) and its approximation\n",
"([19](#vib:ode1:tildeomega:series)) for $\\omega =1$ (based on the\n",
"program [`vib_plot_freq.py`](src-vib/vib_plot_freq.py)).\n",
"program [`vib_plot_freq.py`](https://github.com/devitocodes/devito_book/blob/master/fdm-devito-notebooks/01_vib/src-vib/vib_plot_freq.py)).\n",
"Although $\\tilde\\omega$ is a function of $\\Delta t$ in\n",
"([19](#vib:ode1:tildeomega:series)), it is misleading to think of\n",
"$\\Delta t$ as the important discretization parameter. mathcal{I}_t is the\n",
Expand Down Expand Up @@ -3549,7 +3549,7 @@
"metadata": {},
"source": [
"There is quite some more code dealing with plots also, and we refer\n",
"to the source file [`vib_undamped_odespy.py`](src-vib/vib_undamped_odespy.py)\n",
"to the source file [`vib_undamped_odespy.py`](https://github.com/devitocodes/devito_book/blob/master/fdm-devito-notebooks/01_vib/src-vib/vib_undamped_odespy.py)\n",
"for details. Observe that keyword arguments in `f(u,t,w=1)` can\n",
"be supplied through a solver parameter `f_kwargs` (dictionary of\n",
"additional keyword arguments to `f`).\n",
Expand Down Expand Up @@ -4338,7 +4338,7 @@
"verification. The value of `e_E_norm` is also useful for comparing\n",
"schemes through their ability to preserve energy. Below is a table\n",
"demonstrating the relative error in total energy for various schemes\n",
"(computed by the [`vib_undamped_odespy.py`](src-vib/vib_undamped_odespy.py) program). The test problem is\n",
"(computed by the [`vib_undamped_odespy.py`](https://github.com/devitocodes/devito_book/blob/master/fdm-devito-notebooks/01_vib/src-vib/vib_undamped_odespy.py) program). The test problem is\n",
"$u^{\\prime\\prime} + 4\\pi^2 u =0$ with $u(0)=1$ and $u'(0)=0$, so the\n",
"period is 1 and $E(t)\\approx 4.93$. We clearly see that the\n",
"Crank-Nicolson and the Runge-Kutta schemes are superior to the Forward\n",
Expand Down Expand Up @@ -4802,7 +4802,7 @@
"\n",
"### Solver function\n",
"\n",
"The function below, found in [`vib_undamped_EulerCromer.py`](src-vib/vib_undamped_EulerCromer.py), implements the Euler-Cromer scheme\n",
"The function below, found in [`vib_undamped_EulerCromer.py`](https://github.com/devitocodes/devito_book/blob/master/fdm-devito-notebooks/01_vib/src-vib/vib_undamped_EulerCromer.py), implements the Euler-Cromer scheme\n",
"([54](#vib:model2x2:EulerCromer:veq1b))-([55](#vib:model2x2:EulerCromer:ueq1b)):"
]
},
Expand Down Expand Up @@ -4914,7 +4914,7 @@
"To verify the implementation of the Euler-Cromer method we can adjust\n",
"`v[1]` so that the computer-generated values can be compared with the\n",
"formula ([20](#vib:ode1:un:exact)) from in the section [Exact discrete solution](#vib:ode1:analysis:sol). This adjustment is done in an alternative\n",
"solver function, `solver_ic_fix` in [`vib_undamped_EulerCromer.py`](src-vib/vib_undamped_EulerCromer.py). Since we now\n",
"solver function, `solver_ic_fix` in [`vib_undamped_EulerCromer.py`](https://github.com/devitocodes/devito_book/blob/master/fdm-devito-notebooks/01_vib/src-vib/vib_undamped_EulerCromer.py). Since we now\n",
"have an exact solution of the discrete equations available, we can\n",
"write a test function `test_solver` for checking the equality of\n",
"computed values with the formula ([20](#vib:ode1:un:exact)):"
Expand Down Expand Up @@ -4958,9 +4958,9 @@
"### Convergence rates\n",
"\n",
"We may use the `convergence_rates` function in the file\n",
"[`vib_undamped.py`](src-vib/vib_undamped.py) to investigate the convergence rate of the\n",
"[`vib_undamped.py`](https://github.com/devitocodes/devito_book/blob/master/fdm-devito-notebooks/01_vib/src-vib/vib_undamped.py) to investigate the convergence rate of the\n",
"Euler-Cromer method, see the `convergence_rate` function in the file\n",
"[`vib_undamped_EulerCromer.py`](src-vib/vib_undamped_EulerCromer.py). Since we could eliminate $v$ to get a\n",
"[`vib_undamped_EulerCromer.py`](https://github.com/devitocodes/devito_book/blob/master/fdm-devito-notebooks/01_vib/src-vib/vib_undamped_EulerCromer.py). Since we could eliminate $v$ to get a\n",
"scheme for $u$ that is equivalent to the finite difference method for\n",
"the second-order equation in $u$, we would expect the convergence\n",
"rates to be the same, i.e., $r = 2$. However,\n",
Expand Down Expand Up @@ -5585,7 +5585,7 @@
"`vib_undamped.py` (which solves $u''+\\omega^2u=0$ directly). The\n",
"values should coincide to machine precision since the two numerical\n",
"methods are mathematically equivalent. We refer to the file\n",
"[`vib_undamped_staggered.py`](src-vib/vib_undamped_staggered.py)\n",
"[`vib_undamped_staggered.py`](https://github.com/devitocodes/devito_book/blob/master/fdm-devito-notebooks/01_vib/src-vib/vib_undamped_staggered.py)\n",
"for the details of a unit test (`test_staggered`) that checks this property.\n",
"\n",
"# Exercises and Problems\n",
Expand Down Expand Up @@ -8410,7 +8410,7 @@
"## Problem 15: Minimize memory usage of a general vibration solver\n",
"<div id=\"vib:exer:memsave\"></div>\n",
"\n",
"The program [`vib.py`](${src_vib}/vib.py) stores the complete\n",
"The program [`vib.py`](https://github.com/devitocodes/devito_book/blob/master/fdm-devito-notebooks/01_vib/src-vib/vib.py) stores the complete\n",
"solution $u^0,u^1,\\ldots,u^{N_t}$ in memory, which is convenient for\n",
"later plotting. Make a memory minimizing version of this program\n",
"where only the last three $u^{n+1}$, $u^n$, and $u^{n-1}$ values are\n",
Expand Down Expand Up @@ -9049,7 +9049,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.8.2"
}
},
"nbformat": 4,
Expand Down
10 changes: 5 additions & 5 deletions fdm-devito-notebooks/02_wave/wave1D_prog.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"When this function resides in the file [`wave1D_u0.py`](src-wave/wave1D/wave1D_u0.py), one can run\n",
"When this function resides in the file [`wave1D_u0.py`](https://github.com/devitocodes/devito_book/blob/master/fdm-devito-notebooks/02_wave/src-wave/wave1D/wave1D_u0.py), one can run\n",
"pytest to check that all test functions with names `test_*()`\n",
"in this file work:"
]
Expand Down Expand Up @@ -718,7 +718,7 @@
"`n` can be divided by 13 without a remainder. That is, the `if` test\n",
"is true when `n` equals $0, 13, 26, 39, ..., 780, 801$. The associated\n",
"code is included in the `plot_u` function, inside the `viz` function,\n",
"in the file [`wave1D_u0.py`](src-wave/wave1D/wave1D_u0.py).\n",
"in the file [`wave1D_u0.py`](https://github.com/devitocodes/devito_book/blob/master/fdm-devito-notebooks/02_wave/src-wave/wave1D/wave1D_u0.py).\n",
"\n",
"## Running a case\n",
"<div id=\"wave:pde1:guitar:data\"></div>\n",
Expand Down Expand Up @@ -806,7 +806,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The associated program has the name [`wave1D_u0.py`](src-wave/wave1D/wave1D_u0.py). Run\n",
"The associated program has the name [`wave1D_u0.py`](https://github.com/devitocodes/devito_book/blob/master/fdm-devito-notebooks/02_wave/src-wave/wave1D/wave1D_u0.py). Run\n",
"the program and watch the [movie of the vibrating string](mov-wave/guitar_C0.8/movie.html).\n",
"The string should ideally consist of straight segments, but these are\n",
"somewhat wavy due to numerical approximation. Run the case with the\n",
Expand Down Expand Up @@ -2586,9 +2586,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.8.2"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
}
4 changes: 2 additions & 2 deletions fdm-devito-notebooks/03_diffu/diffu_rw.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@
"run, and it can be very difficult to spot bugs through averaged statistical\n",
"quantities.\n",
"\n",
"A full test suite for this notebook, along with the rest of the functions for random walks, can be found in [`random_walk.py`](src-diffu/random_walk.py).\n",
"A full test suite for this notebook, along with the rest of the functions for random walks, can be found in [`random_walk.py`](https://github.com/devitocodes/devito_book/blob/master/fdm-devito-notebooks/03_diffu/src-diffu/random_walk.py).\n",
"\n",
"## Demonstration of multiple walks\n",
"\n",
Expand Down Expand Up @@ -1315,7 +1315,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.8.2"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions fdm-devito-notebooks/04_advec/advec.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@
"source": [
"A special scheme is needed to compute $u^1$, but we leave that problem for\n",
"now. Anyway, this special scheme can be found in \n",
"[`advec1D.py`](src-advec/advec1D.py).\n",
"[`advec1D.py`](https://github.com/devitocodes/devito_book/blob/master/fdm-devito-notebooks/04_advec/src-advec/advec1D.py).\n",
"\n",
"### Implementation\n",
"\n",
Expand Down Expand Up @@ -1405,7 +1405,7 @@
"metadata": {},
"source": [
"The complete code is found in the file\n",
"[`advec1D.py`](src-advec/advec1D.py).\n",
"[`advec1D.py`](https://github.com/devitocodes/devito_book/blob/master/fdm-devito-notebooks/04_advec/src-advec/advec1D.py).\n",
"\n",
"## A Crank-Nicolson discretization in time and centered differences in space\n",
"<div id=\"advec:1D:CN\"></div>\n",
Expand Down
Loading

0 comments on commit 30405c3

Please sign in to comment.