Files
pylib/docs/build/html/pylib.numerical.ode.html

357 lines
18 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>pylib.numerical.ode module &#8212; pylib 2019.12.21 documentation</title>
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="pylib.numerical.ode_model module" href="pylib.numerical.ode_model.html" />
<link rel="prev" title="pylib.numerical.integration module" href="pylib.numerical.integration.html" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="module-pylib.numerical.ode">
<span id="pylib-numerical-ode-module"></span><h1>pylib.numerical.ode module<a class="headerlink" href="#module-pylib.numerical.ode" title="Permalink to this headline"></a></h1>
<p>Numerical solver of ordinary differential equations.</p>
<p>Solves the initial value problem for systems of first order
ordinary differential equations.</p>
<dl class="field-list simple">
<dt class="field-odd">Date</dt>
<dd class="field-odd"><p>2015-09-21</p>
</dd>
</dl>
<span class="target" id="module-ode"></span><dl class="function">
<dt id="pylib.numerical.ode.e1">
<code class="sig-name descname">e1</code><span class="sig-paren">(</span><em class="sig-param">f</em>, <em class="sig-param">x0</em>, <em class="sig-param">t</em>, <em class="sig-param">*p</em>, <em class="sig-param">verbose=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/numerical/ode.html#e1"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.numerical.ode.e1" title="Permalink to this definition"></a></dt>
<dd><p>Explicit first-order method /
(standard, or forward) Euler method /
Runge-Kutta 1st order method.</p>
<p>de:
Eulersche Polygonzugverfahren / explizite Euler-Verfahren /
Euler-Cauchy-Verfahren / Euler-vorwärts-Verfahren</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>f</strong> (<em>function</em>) the function to solve</p></li>
<li><p><strong>x0</strong> (<em>list</em>) initial condition</p></li>
<li><p><strong>t</strong> (<em>list</em>) time</p></li>
<li><p><strong>*p</strong> parameters of the function (thickness, diameter,
…)</p></li>
<li><p><strong>verbose</strong> (<em>bool</em>) print information (default = False)</p></li>
</ul>
</dd>
</dl>
<p>Approximate the solution of the initial value problem</p>
<div class="math notranslate nohighlight">
\[\begin{split}\dot{x} &amp;= f(t,x) \\
x(t_0) &amp;= x_0\end{split}\]</div>
<p>Choose a value h for the size of every step and set</p>
<div class="math notranslate nohighlight">
\[t_i = t_0 + i h ~,\quad i=1,2,\ldots,n\]</div>
<p>The derivative of the solution is approximated as the forward
difference equation</p>
<div class="math notranslate nohighlight">
\[\dot{x}_i = f(t_i, x_i) = \frac{x_{i+1} - x_i}{t_{i+1}-t_i}\]</div>
<p>Therefore one step <span class="math notranslate nohighlight">\(h\)</span> of the Euler method from
<span class="math notranslate nohighlight">\(t_i\)</span> to <span class="math notranslate nohighlight">\(t_{i+1}\)</span> is</p>
<div class="math notranslate nohighlight">
\[\begin{split}x_{i+1} &amp;= x_i + (t_{i+1}-t_i) f(t_i, x_i) \\
x_{i+1} &amp;= x_i + h f(t_i, x_i) \\\end{split}\]</div>
<p>Example 1:</p>
<div class="math notranslate nohighlight">
\[\begin{split}m\ddot{u} + d\dot{u} + ku = f(t) \\
\ddot{u} = m^{-1}(f(t) - d\dot{u} - ku) \\\end{split}\]</div>
<p>with</p>
<div class="math notranslate nohighlight">
\[\begin{split}x_1 &amp;= u &amp;\quad \dot{x}_1 = \dot{u} = x_2 \\
x_2 &amp;= \dot{u} &amp;\quad \dot{x}_2 = \ddot{u} \\\end{split}\]</div>
<p>becomes</p>
<div class="math notranslate nohighlight">
\[\begin{split}\dot{x}_1 &amp;= x_2 \\
\dot{x}_2 &amp;= m^{-1}(f(t) - d x_2 - k x_1) \\\end{split}\]</div>
<p>or</p>
<div class="math notranslate nohighlight">
\[\begin{split}\dot{x} &amp;= f(t,x) \\
\begin{bmatrix} \dot{x}_1 \\ \dot{x}_2 \end{bmatrix} &amp;=
\begin{bmatrix} x_2 \\ m^{-1}(f(t) - d x_2 - k x_1)
\end{bmatrix} \\
&amp;=
\begin{bmatrix} 0 \\ m^{-1} f(t) \end{bmatrix} +
\begin{bmatrix} 0 &amp; 1 \\ -m^{-1} k &amp; -m^{-1} d \end{bmatrix}
\begin{bmatrix} x_1 \\ x_2 \end{bmatrix}\end{split}\]</div>
<p>Example 2:</p>
<div class="math notranslate nohighlight">
\[\begin{split}m(u)\ddot{u} + d(u,\dot{u})\dot{u} + k(u)u = f(t) \\
\ddot{u} = m^{-1}(u)(f(t) - d(u,\dot{u})\dot{u} - k(u)u) \\\end{split}\]</div>
<p>with</p>
<div class="math notranslate nohighlight">
\[\begin{split}x_1 &amp;= u &amp;\quad \dot{x}_1 = \dot{u} = x_2 \\
x_2 &amp;= \dot{u} &amp;\quad \dot{x}_2 = \ddot{u} \\\end{split}\]</div>
<p>becomes</p>
<div class="math notranslate nohighlight">
\[\begin{split}\dot{x}_1 &amp;= x_2 \\
\dot{x}_2 &amp;=
m^{-1}(x_1)(f(t) - d(x_1,x_2) x_2 - k(x_1) x_1) \\\end{split}\]</div>
<p>or</p>
<div class="math notranslate nohighlight">
\[\begin{split}\dot{x} &amp;= f(t,x) \\
\begin{bmatrix} \dot{x}_1 \\ \dot{x}_2 \end{bmatrix} &amp;=
\begin{bmatrix}
x_2 \\ m^{-1}(x_1)(f(t) - d(x_1,x_2) x_2 - k(x_1) x_1)
\end{bmatrix} \\
&amp;=
\begin{bmatrix} 0 \\ m^{-1}(x_1) f(t) \end{bmatrix} +
\begin{bmatrix}
0 &amp; 1 \\ -m^{-1}(x_1) k(x_1) &amp; -m^{-1} d(x_1,x_2)
\end{bmatrix}
\begin{bmatrix} x_1 \\ x_2 \end{bmatrix}\end{split}\]</div>
<p>The Euler method is a first-order method, which means that the
local error (error per step) is proportional to the square of
the step size, and the global error (error at a given time) is
proportional to the step size.</p>
</dd></dl>
<dl class="function">
<dt id="pylib.numerical.ode.e2">
<code class="sig-name descname">e2</code><span class="sig-paren">(</span><em class="sig-param">f</em>, <em class="sig-param">x0</em>, <em class="sig-param">t</em>, <em class="sig-param">*p</em>, <em class="sig-param">verbose=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/numerical/ode.html#e2"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.numerical.ode.e2" title="Permalink to this definition"></a></dt>
<dd><p>Explicit second-order method / Runge-Kutta 2nd order method.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>f</strong> (<em>function</em>) the function to solve</p></li>
<li><p><strong>x0</strong> (<em>list</em>) initial condition</p></li>
<li><p><strong>t</strong> (<em>list</em>) time</p></li>
<li><p><strong>*p</strong> parameters of the function (thickness, diameter,
…)</p></li>
<li><p><strong>verbose</strong> (<em>bool</em>) print information (default = False)</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pylib.numerical.ode.e4">
<code class="sig-name descname">e4</code><span class="sig-paren">(</span><em class="sig-param">f</em>, <em class="sig-param">x0</em>, <em class="sig-param">t</em>, <em class="sig-param">*p</em>, <em class="sig-param">verbose=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/numerical/ode.html#e4"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.numerical.ode.e4" title="Permalink to this definition"></a></dt>
<dd><p>Explicit fourth-order method / Runge-Kutta 4th order method.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>f</strong> (<em>function</em>) the function to solve</p></li>
<li><p><strong>x0</strong> (<em>list</em>) initial condition</p></li>
<li><p><strong>t</strong> (<em>list</em>) time</p></li>
<li><p><strong>*p</strong> parameters of the function (thickness, diameter,
…)</p></li>
<li><p><strong>verbose</strong> (<em>bool</em>) print information (default = False)</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pylib.numerical.ode.fpi">
<code class="sig-name descname">fpi</code><span class="sig-paren">(</span><em class="sig-param">f</em>, <em class="sig-param">xi</em>, <em class="sig-param">ti</em>, <em class="sig-param">ti1</em>, <em class="sig-param">*p</em>, <em class="sig-param">max_iterations=1000</em>, <em class="sig-param">tol=1e-09</em>, <em class="sig-param">verbose=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/numerical/ode.html#fpi"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.numerical.ode.fpi" title="Permalink to this definition"></a></dt>
<dd><p>Fixed-point iteration.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>f</strong> (<em>function</em>) the function to iterate <span class="math notranslate nohighlight">\(f = \dot{x}(x,t)\)</span></p></li>
<li><p><strong>xi</strong> (<em>list</em>) initial condition <span class="math notranslate nohighlight">\(x_i\)</span></p></li>
<li><p><strong>ti</strong> (<em>float</em>) time <span class="math notranslate nohighlight">\(t_i\)</span></p></li>
<li><p><strong>ti1</strong> (<em>float</em>) time <span class="math notranslate nohighlight">\(t_{i+1}\)</span></p></li>
<li><p><strong>*p</strong> parameters of the function (thickness, diameter,
…)</p></li>
<li><p><strong>max_iterations</strong> (<em>int</em>) maximum number of iterations</p></li>
<li><p><strong>tol</strong> (<em>float</em>) tolerance against residuum <span class="math notranslate nohighlight">\(\varepsilon\)</span>
(default = 1e-9)</p></li>
<li><p><strong>verbose</strong> (<em>bool</em>) print information (default = False)</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><span class="math notranslate nohighlight">\(x_{i}\)</span></p>
</dd>
</dl>
<div class="math notranslate nohighlight">
\[x_{i,j=0} = x_{i}\]</div>
<div class="math notranslate nohighlight">
\[x_{i,j+1} = x_i + \dot{x}(x_{i,j}, t_{i+1})\cdot(t_{i+1}-t_i)\]</div>
<div class="math notranslate nohighlight">
\[\text{residuum} = \frac{\lVert x_{i,j+1}-x_{i,j}\rVert}
{\lVert x_{i,j+1} \rVert} &lt; \varepsilon\]</div>
<div class="math notranslate nohighlight">
\[x_{i} = x_{i,j=\text{end}}\]</div>
</dd></dl>
<dl class="function">
<dt id="pylib.numerical.ode.i1">
<code class="sig-name descname">i1</code><span class="sig-paren">(</span><em class="sig-param">f</em>, <em class="sig-param">x0</em>, <em class="sig-param">t</em>, <em class="sig-param">*p</em>, <em class="sig-param">max_iterations=1000</em>, <em class="sig-param">tol=1e-09</em>, <em class="sig-param">verbose=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/numerical/ode.html#i1"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.numerical.ode.i1" title="Permalink to this definition"></a></dt>
<dd><p>Implicite first-order method / backward Euler method.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>f</strong> (<em>function</em>) the function to solve</p></li>
<li><p><strong>x0</strong> (<em>list</em>) initial condition</p></li>
<li><p><strong>t</strong> (<em>list</em>) time</p></li>
<li><p><strong>*p</strong> parameters of the function (thickness, diameter,
…)</p></li>
<li><p><strong>max_iterations</strong> (<em>int</em>) maximum number of iterations</p></li>
<li><p><strong>tol</strong> (<em>float</em>) tolerance against residuum (default = 1e-9)</p></li>
<li><p><strong>verbose</strong> (<em>bool</em>) print information (default = False)</p></li>
</ul>
</dd>
</dl>
<p>The backward Euler method has order one and is A-stable.</p>
</dd></dl>
<dl class="function">
<dt id="pylib.numerical.ode.newmark_newtonraphson">
<code class="sig-name descname">newmark_newtonraphson</code><span class="sig-paren">(</span><em class="sig-param">f</em>, <em class="sig-param">x0</em>, <em class="sig-param">xp0</em>, <em class="sig-param">xpp0</em>, <em class="sig-param">t</em>, <em class="sig-param">*p</em>, <em class="sig-param">gamma=0.5</em>, <em class="sig-param">beta=0.25</em>, <em class="sig-param">max_iterations=1000</em>, <em class="sig-param">tol=1e-09</em>, <em class="sig-param">verbose=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/numerical/ode.html#newmark_newtonraphson"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.numerical.ode.newmark_newtonraphson" title="Permalink to this definition"></a></dt>
<dd><p>Newmark method.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>f</strong> (<em>function</em>) the function to solve</p></li>
<li><p><strong>x0</strong> (<em>list</em>) initial condition</p></li>
<li><p><strong>xp0</strong> (<em>list</em>) initial condition</p></li>
<li><p><strong>xpp0</strong> (<em>list</em>) initial condition</p></li>
<li><p><strong>t</strong> (<em>list</em>) time</p></li>
<li><p><strong>*p</strong> parameters of the function (thickness, diameter,
…)</p></li>
<li><p><strong>gamma</strong> (<em>float</em>) newmark parameter for velocity (default = 0.5)</p></li>
<li><p><strong>beta</strong> (<em>float</em>) newmark parameter for displacement (default = 0.25)</p></li>
<li><p><strong>max_iterations</strong> (<em>int</em>) maximum number of iterations</p></li>
<li><p><strong>tol</strong> (<em>float</em>) tolerance against residuum (default = 1e-9)</p></li>
<li><p><strong>verbose</strong> (<em>bool</em>) print information (default = False)</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pylib.numerical.ode.newmark_newtonraphson_rdk">
<code class="sig-name descname">newmark_newtonraphson_rdk</code><span class="sig-paren">(</span><em class="sig-param">fnm</em>, <em class="sig-param">x0</em>, <em class="sig-param">xp0</em>, <em class="sig-param">xpp0</em>, <em class="sig-param">t</em>, <em class="sig-param">*p</em>, <em class="sig-param">gamma=0.5</em>, <em class="sig-param">beta=0.25</em>, <em class="sig-param">max_iterations=1000</em>, <em class="sig-param">tol=1e-09</em>, <em class="sig-param">verbose=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/numerical/ode.html#newmark_newtonraphson_rdk"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.numerical.ode.newmark_newtonraphson_rdk" title="Permalink to this definition"></a></dt>
<dd><p>Newmark method.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>f</strong> (<em>function</em>) the function to solve</p></li>
<li><p><strong>x0</strong> (<em>list</em>) initial condition</p></li>
<li><p><strong>xp0</strong> (<em>list</em>) initial condition</p></li>
<li><p><strong>xpp0</strong> (<em>list</em>) initial condition</p></li>
<li><p><strong>t</strong> (<em>list</em>) time</p></li>
<li><p><strong>*p</strong> parameters of the function (thickness, diameter,
…)</p></li>
<li><p><strong>gamma</strong> (<em>float</em>) newmark parameter for velocity (default = 0.5)</p></li>
<li><p><strong>beta</strong> (<em>float</em>) newmark parameter for displacement (default = 0.25)</p></li>
<li><p><strong>max_iterations</strong> (<em>int</em>) maximum number of iterations</p></li>
<li><p><strong>tol</strong> (<em>float</em>) tolerance against residuum (default = 1e-9)</p></li>
<li><p><strong>verbose</strong> (<em>bool</em>) print information (default = False)</p></li>
</ul>
</dd>
</dl>
</dd></dl>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="index.html">pylib</a></h1>
<h3>Navigation</h3>
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="modules.html">pylib</a><ul class="current">
<li class="toctree-l2 current"><a class="reference internal" href="pylib.html">pylib package</a></li>
</ul>
</li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="index.html">Documentation overview</a><ul>
<li><a href="modules.html">pylib</a><ul>
<li><a href="pylib.html">pylib package</a><ul>
<li><a href="pylib.numerical.html">pylib.numerical package</a><ul>
<li>Previous: <a href="pylib.numerical.integration.html" title="previous chapter">pylib.numerical.integration module</a></li>
<li>Next: <a href="pylib.numerical.ode_model.html" title="next chapter">pylib.numerical.ode_model module</a></li>
</ul></li>
</ul></li>
</ul></li>
</ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, Daniel Weschke.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 2.2.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="_sources/pylib.numerical.ode.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>