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
Copy file name to clipboardExpand all lines: doc/.src/chapters/vib/vib_undamped.do.txt
+14-37Lines changed: 14 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -87,8 +87,8 @@ in electrical circuits.
87
87
label{vib:ode1:fdm}
88
88
89
89
To formulate a finite difference method for the model
90
-
problem (ref{vib:ode1}) we follow the ref[four steps explained in Section
91
-
ref{decay:schemes:FE}][ in cite{Langtangen_decay}]["four steps": "${doc_notes}/sphinx-decay/main_decay.html#the-forward-euler-scheme" explained in cite{Langtangen_decay}].
90
+
problem (ref{vib:ode1}), we follow the four steps explained in Section 1.1.2
91
+
in cite{Langtangen_decay}.
92
92
93
93
idx{mesh!finite differences} idx{mesh function} idx{discretization of domain}
94
94
@@ -246,8 +246,7 @@ We may write the scheme using a compact difference notation
246
246
% if BOOK == "book":
247
247
listed in Appendix ref{sec:form:fdop}
248
248
% endif
249
-
(see also ref[Section ref{decay:fd:op}][ in cite{Langtangen_decay}][
250
-
"examples": "${doc_notes}/sphinx-decay/main_decay.html#compact-operator-notation-for-finite-differences" in cite{Langtangen_decay}]).
249
+
(see also Section 1.1.8 in cite{Langtangen_decay}).
251
250
The difference (ref{vib:ode1:step3}) has the operator
252
251
notation $[D_tD_t u]^n$ such that we can write:
253
252
@@ -309,10 +308,8 @@ computing community and a good programming habit (since we explicitly
309
308
see where the different functions come from). An alternative is to do
310
309
`from numpy import *` and a similar ``import all'' for Matplotlib to
311
310
avoid the `np` and `plt` prefixes and make the code as close as
312
-
possible to MATLAB. (See ref[Section ref{softeng1:basic:modprefix}][ in
313
-
cite{Langtangen_decay}][the section
314
-
"Prefixing imported functions by the module name": "http://hplgit.github.io/decay-book/doc/pub/book/html/._decay-book009.html#softeng1:basic:modprefix" in the book
315
-
"Finite Difference Computing with Exponential Decay Models": "http://tinyurl.com/nclmcng/web" cite{Langtangen_decay}] for a discussion of the two
311
+
possible to MATLAB. (See Section 5.1.4 in
312
+
cite{Langtangen_decay} for a discussion of the two
316
313
types of import in Python.)
317
314
318
315
A function for plotting the numerical and the exact solution is also
I, w, dt, num_periods = a.I, a.w, a.dt, a.num_periods
350
347
!ec
351
-
Such parsing of the command line is explained in more detail in
352
-
ref[Section ref{softeng1:basic:UI:options_cml}][ in cite{Langtangen_decay}][ the
353
-
section "Option-value pairs on the command line": "${decay_book_url}/html/._decay-book009.html#softeng1:basic:UI:options_cml" in "Finite Difference Computing with Exponential Decay Models": "http://tinyurl.com/nclmcng/web" cite{Langtangen_decay}].
348
+
Such parsing of the command line is explained in more detail in Section 5.2.3 in
349
+
cite{Langtangen_decay}.
354
350
355
351
A typical execution goes like
356
352
@@ -394,12 +390,7 @@ v[-1] = (u[-1] - u[-2])/dt
394
390
!ec
395
391
Since the loop is slow for large $N_t$, we can get rid of the loop by
396
392
vectorizing the central difference. The above code segment goes as
397
-
follows in its vectorized version (see ref[Problem
398
-
ref{decay:exer:dudt}][ in cite{Langtangen_decay}][the problem
399
-
"Differentiate a function":
400
-
"${decay_book_url}/html/._decay-book005.html#decay:exer:dudt" in "Finite
401
-
Difference Computing with Exponential Decay Models":
402
-
"http://tinyurl.com/nclmcng/web" cite{Langtangen_decay}] for
393
+
follows in its vectorized version (see Problem 1.2 in cite{Langtangen_decay} for
403
394
explanation of details):
404
395
405
396
!bc pycod
@@ -443,9 +434,7 @@ framework for Python code, because
443
434
We shall in this book implement all software verification via such
444
435
proper test functions, also known as unit testing.
445
436
% endif
446
-
See ref[Section ref{softeng1:verify:pytest}][ in cite{Langtangen_decay}][the
447
-
section "Unit tests and test functions": "${decay_book_url}/html/._decay-book009.html#softeng1:verify:pytest" in
448
-
"Finite Difference Computing with Exponential Decay Models": "http://tinyurl.com/nclmcng/web" cite{Langtangen_decay}]
437
+
See Section 5.3.2 in cite{Langtangen_decay}
449
438
for more details on how to construct test functions and utilize nose
450
439
or pytest for automatic execution of tests. Our recommendation is to
451
440
use pytest. With this choice, you can
@@ -490,12 +479,7 @@ idx{error norm}
490
479
491
480
Empirical computation of convergence rates yields a good method for
492
481
verification. The method and its computational details are explained
493
-
in detail ref[in Section ref{decay:convergence:rate}][ in
494
-
cite{Langtangen_decay}][for a simple ODE model in the section
To formulate a finite difference method for the model
725
-
problem <a href="#mjx-eqn-1">(1)</a> we follow the <a href="http://tinyurl.com/pu5uyfn/pub/sphinx-decay/main_decay.html#the-forward-euler-scheme" target="_self">four steps</a> explained in <a href="._vib-sol003.html#Langtangen_decay">[1]</a>.
725
+
problem <a href="#mjx-eqn-1">(1)</a>, we follow the four steps explained in Section 1.1.2
726
+
in <a href="._vib-sol003.html#Langtangen_decay">[1]</a>.
726
727
727
728
<h3 id="___sec3">Step 1: Discretizing the domain </h3>
We may write the scheme using a compact difference notation
883
-
(see also
884
-
<a href="http://tinyurl.com/pu5uyfn/pub/sphinx-decay/main_decay.html#compact-operator-notation-for-finite-differences" target="_self">examples</a> in <a href="._vib-sol003.html#Langtangen_decay">[1]</a>).
884
+
(see also Section 1.1.8 in <a href="._vib-sol003.html#Langtangen_decay">[1]</a>).
885
885
The difference <a href="#mjx-eqn-4">(4)</a> has the operator
886
886
notation \( [D_tD_t u]^n \) such that we can write:
887
887
@@ -963,9 +963,8 @@ <h2 id="vib:impl1:solver">Making a solver function</h2>
963
963
see where the different functions come from). An alternative is to do
964
964
<code>from numpy import *</code> and a similar "import all" for Matplotlib to
965
965
avoid the <code>np</code> and <code>plt</code> prefixes and make the code as close as
966
-
possible to MATLAB. (See the section
967
-
<a href="http://hplgit.github.io/decay-book/doc/pub/book/html/._decay-book009.html#softeng1:basic:modprefix" target="_self">Prefixing imported functions by the module name</a> in the book
968
-
<a href="http://tinyurl.com/nclmcng/web" target="_self">Finite Difference Computing with Exponential Decay Models</a> <a href="._vib-sol003.html#Langtangen_decay">[1]</a> for a discussion of the two
966
+
possible to MATLAB. (See Section 5.1.4 in
967
+
<a href="._vib-sol003.html#Langtangen_decay">[1]</a> for a discussion of the two
969
968
types of import in Python.)
970
969
971
970
<p>
@@ -1028,9 +1027,8 @@ <h2 id="vib:impl1:solver">Making a solver function</h2>
Since the loop is slow for large \( N_t \), we can get rid of the loop by
1082
1080
vectorizing the central difference. The above code segment goes as
1083
-
follows in its vectorized version (see the problem
1084
-
<a href="http://hplgit.github.io/decay-book/doc/pub/book/html/._decay-book005.html#decay:exer:dudt" target="_self">Differentiate a function</a> in <a href="http://tinyurl.com/nclmcng/web" target="_self">Finite
1085
-
Difference Computing with Exponential Decay Models</a> <a href="._vib-sol003.html#Langtangen_decay">[1]</a> for
1081
+
follows in its vectorized version (see Problem 1.2 in <a href="._vib-sol003.html#Langtangen_decay">[1]</a> for
<li> the test is formulated as a boolean condition and executed by <code>assert</code></li>
1133
1129
</ul>
1134
1130
1135
-
See the
1136
-
section <a href="http://hplgit.github.io/decay-book/doc/pub/book/html/._decay-book009.html#softeng1:verify:pytest" target="_self">Unit tests and test functions</a> in
in <a href="http://tinyurl.com/nclmcng/web" target="_self">Finite Difference Computing with Exponential Decay Models</a> <a href="._vib-sol003.html#Langtangen_decay">[1]</a>. Readers not
1173
+
in detail in Section 3.1.6 in <a href="._vib-sol003.html#Langtangen_decay">[1]</a>. Readers not
1182
1174
familiar with the concept should look up this reference before
1183
1175
proceeding.
1184
1176
@@ -1333,10 +1325,8 @@ <h2 id="___sec18">Scaled model </h2>
1333
1325
because fewer parameters need to be set. The present problem is made
1334
1326
dimensionless by introducing dimensionless variables \( \bar t = t/t_c \)
1335
1327
and \( \bar u = u/u_c \), where \( t_c \) and \( u_c \) are characteristic scales
1336
-
for \( t \) and \( u \), respectively. We refer to the section
1337
-
<a href="http://hplgit.github.io/scaling-book/doc/pub/book/html/._scaling-book006.html#sec:scale:vib:undamped" target="_self">Undamped vibrations without forcing</a>
1338
-
in the book <a href="http://tinyurl.com/qfjgxmf/web" target="_self">Scaling of differential equations</a> <a href="._vib-sol003.html#Langtangen_scaling">[2]</a> for all
1339
-
details about this scaling.
1328
+
for \( t \) and \( u \), respectively. We refer to Section 2.2.1 in
1329
+
<a href="._vib-sol003.html#Langtangen_scaling">[2]</a> for all details about this scaling.
1340
1330
1341
1331
<p>
1342
1332
The scaled ODE problem reads
@@ -4691,9 +4681,8 @@ <h2 id="vib:exer:undamped:adaptive">Exercise 4: See if adaptive methods improve
4691
4681
Adaptive methods for solving ODEs aim at adjusting \( \Delta t \) such
4692
4682
that the error is within a user-prescribed tolerance. Implement the
4693
4683
equation \( u^{\prime\prime}+u=0 \) in the <a href="https://github.com/hplgit/odespy" target="_self">Odespy</a>
4694
-
software. Use the example <a href="http://hplgit.github.io/decay-book/doc/pub/book/sphinx/._book006.html#example-adaptive-runge-kutta-methods" target="_self">on adaptive
4695
-
schemes</a>
4696
-
in <a href="._vib-sol003.html#Langtangen_decay">[1]</a>. Run the scheme with a very low
4684
+
software. Use the example from Section 3.2.11 in <a href="._vib-sol003.html#Langtangen_decay">[1]</a>.
4685
+
Run the scheme with a very low
4697
4686
tolerance (say \( 10^{-14} \)) and for a long time, check the number of
4698
4687
time points in the solver's mesh (<code>len(solver.t_all)</code>), and compare
4699
4688
the phase error with that produced by the simple finite difference
0 commit comments