add ode solver, tests and update docs
This commit is contained in:
2
docs/build/html/.buildinfo
vendored
2
docs/build/html/.buildinfo
vendored
@@ -1,4 +1,4 @@
|
||||
# Sphinx build info version 1
|
||||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
|
||||
config: 09cf9ce4470e7ee74b6ce2abe5e4453a
|
||||
config: 94375f4299332632f508e2242b7c30d8
|
||||
tags: 645f666f9bcd5a90fca523b33c5a78b7
|
||||
|
||||
2
docs/build/html/_sources/modules.rst.txt
vendored
2
docs/build/html/_sources/modules.rst.txt
vendored
@@ -8,3 +8,5 @@ src
|
||||
date
|
||||
fit
|
||||
geometry
|
||||
solver
|
||||
solver_model
|
||||
|
||||
7
docs/build/html/_sources/solver.rst.txt
vendored
Normal file
7
docs/build/html/_sources/solver.rst.txt
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
solver module
|
||||
=============
|
||||
|
||||
.. automodule:: solver
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
7
docs/build/html/_sources/solver_model.rst.txt
vendored
Normal file
7
docs/build/html/_sources/solver_model.rst.txt
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
solver\_model module
|
||||
====================
|
||||
|
||||
.. automodule:: solver_model
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
46
docs/build/html/_sources/src.rst.txt
vendored
46
docs/build/html/_sources/src.rst.txt
vendored
@@ -1,46 +0,0 @@
|
||||
src package
|
||||
===========
|
||||
|
||||
Submodules
|
||||
----------
|
||||
|
||||
src.data module
|
||||
---------------
|
||||
|
||||
.. automodule:: src.data
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
src.date module
|
||||
---------------
|
||||
|
||||
.. automodule:: src.date
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
src.fit module
|
||||
--------------
|
||||
|
||||
.. automodule:: src.fit
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
src.geometry module
|
||||
-------------------
|
||||
|
||||
.. automodule:: src.geometry
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
|
||||
Module contents
|
||||
---------------
|
||||
|
||||
.. automodule:: src
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
4
docs/build/html/_static/alabaster.css
vendored
4
docs/build/html/_static/alabaster.css
vendored
@@ -310,8 +310,8 @@ div.hint {
|
||||
}
|
||||
|
||||
div.seealso {
|
||||
background-color: #EEE;
|
||||
border: 1px solid #CCC;
|
||||
background-color: #3c3c3c;
|
||||
border: 1px solid #2C2C2C;
|
||||
}
|
||||
|
||||
div.topic {
|
||||
|
||||
50
docs/build/html/data.html
vendored
50
docs/build/html/data.html
vendored
@@ -13,6 +13,7 @@
|
||||
<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" />
|
||||
|
||||
@@ -33,28 +34,67 @@
|
||||
|
||||
<div class="section" id="module-data">
|
||||
<span id="data-module"></span><h1>data module<a class="headerlink" href="#module-data" title="Permalink to this headline">¶</a></h1>
|
||||
<dl class="function">
|
||||
<p>Read and write data to or from file.</p>
|
||||
<span class="target" id="module-data"></span><dl class="function">
|
||||
<dt id="data.data_load">
|
||||
<code class="descname">data_load</code><span class="sig-paren">(</span><em>file_name</em>, <em>verbose=False</em><span class="sig-paren">)</span><a class="headerlink" href="#data.data_load" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>load stored program objects from binary file</p>
|
||||
<dd><p>Load stored program objects from binary file.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><ul class="simple">
|
||||
<li><p><strong>file_name</strong> (<em>str</em>) – file to load</p></li>
|
||||
<li><p><strong>verbose</strong> (<em>bool</em>) – verbose information (default = False)</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt class="field-even">Returns</dt>
|
||||
<dd class="field-even"><p>loaded data</p>
|
||||
</dd>
|
||||
<dt class="field-odd">Return type</dt>
|
||||
<dd class="field-odd"><p>object</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="data.data_read">
|
||||
<code class="descname">data_read</code><span class="sig-paren">(</span><em>file_name</em>, <em>x_column</em>, <em>y_column</em><span class="sig-paren">)</span><a class="headerlink" href="#data.data_read" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>read ascii data file</p>
|
||||
<dd><p>Read ascii data file.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><ul class="simple">
|
||||
<li><p><strong>filename</strong> (<em>str</em>) – file to read</p></li>
|
||||
<li><p><strong>x_column</strong> (<em>int</em>) – column index for the x data (first column is 0)</p></li>
|
||||
<li><p><strong>y_column</strong> (<em>int</em>) – column index for the y data (first column is 0)</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt class="field-even">Returns</dt>
|
||||
<dd class="field-even"><p>x and y</p>
|
||||
</dd>
|
||||
<dt class="field-odd">Return type</dt>
|
||||
<dd class="field-odd"><p>tuple(list, list)</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="data.data_store">
|
||||
<code class="descname">data_store</code><span class="sig-paren">(</span><em>file_name</em>, <em>object_data</em><span class="sig-paren">)</span><a class="headerlink" href="#data.data_store" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>store program objects to binary file</p>
|
||||
<dd><p>Store program objects to binary file.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><ul class="simple">
|
||||
<li><p><strong>file_name</strong> (<em>str</em>) – file to store</p></li>
|
||||
<li><p><strong>object_data</strong> (<em>object</em>) – data to store</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="data.main">
|
||||
<code class="descname">main</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#data.main" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
<dd><p>Main function.</p>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
99
docs/build/html/date.html
vendored
99
docs/build/html/date.html
vendored
@@ -13,6 +13,7 @@
|
||||
<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" />
|
||||
|
||||
@@ -33,15 +34,25 @@
|
||||
|
||||
<div class="section" id="module-date">
|
||||
<span id="date-module"></span><h1>date module<a class="headerlink" href="#module-date" title="Permalink to this headline">¶</a></h1>
|
||||
<p>Created on Mon Jan 15 21:52:34 2018</p>
|
||||
<p>@author: Daniel Weschke</p>
|
||||
<dl class="function">
|
||||
<p>Calculate spacial dates.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Date</dt>
|
||||
<dd class="field-odd"><p>2018-01-15</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<span class="target" id="module-date"></span><dl class="function">
|
||||
<dt id="date.ascension_of_jesus">
|
||||
<code class="descname">ascension_of_jesus</code><span class="sig-paren">(</span><em>year</em><span class="sig-paren">)</span><a class="headerlink" href="#date.ascension_of_jesus" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Ascension of Jesus.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Returns</dt>
|
||||
<dd class="field-odd"><p>datetime.date – the day of ascension of Jesus</p>
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><p><strong>year</strong> (<em>int</em>) – the year to calculate the ascension of Jesus</p>
|
||||
</dd>
|
||||
<dt class="field-even">Returns</dt>
|
||||
<dd class="field-even"><p>the day of ascension of Jesus</p>
|
||||
</dd>
|
||||
<dt class="field-odd">Return type</dt>
|
||||
<dd class="field-odd"><p>datetime.date</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
@@ -51,8 +62,14 @@
|
||||
<code class="descname">easter_friday</code><span class="sig-paren">(</span><em>year</em><span class="sig-paren">)</span><a class="headerlink" href="#date.easter_friday" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Easter Friday.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Returns</dt>
|
||||
<dd class="field-odd"><p>datetime.date – the day of Easter Friday</p>
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><p><strong>year</strong> (<em>int</em>) – the year to calculate the Easter Friday</p>
|
||||
</dd>
|
||||
<dt class="field-even">Returns</dt>
|
||||
<dd class="field-even"><p>the day of Easter Friday</p>
|
||||
</dd>
|
||||
<dt class="field-odd">Return type</dt>
|
||||
<dd class="field-odd"><p>datetime.date</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
@@ -62,8 +79,14 @@
|
||||
<code class="descname">easter_monday</code><span class="sig-paren">(</span><em>year</em><span class="sig-paren">)</span><a class="headerlink" href="#date.easter_monday" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Easter Monday.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Returns</dt>
|
||||
<dd class="field-odd"><p>datetime.date – the day of Easter Monday</p>
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><p><strong>year</strong> (<em>int</em>) – the year to calculate the Easter Monday</p>
|
||||
</dd>
|
||||
<dt class="field-even">Returns</dt>
|
||||
<dd class="field-even"><p>the day of Easter Monday</p>
|
||||
</dd>
|
||||
<dt class="field-odd">Return type</dt>
|
||||
<dd class="field-odd"><p>datetime.date</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
@@ -73,8 +96,14 @@
|
||||
<code class="descname">easter_sunday</code><span class="sig-paren">(</span><em>year</em><span class="sig-paren">)</span><a class="headerlink" href="#date.easter_sunday" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Easter Sunday.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Returns</dt>
|
||||
<dd class="field-odd"><p>datetime.date – the day of Easter Sunday</p>
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><p><strong>year</strong> (<em>int</em>) – the year to calculate the Easter Sunday</p>
|
||||
</dd>
|
||||
<dt class="field-even">Returns</dt>
|
||||
<dd class="field-even"><p>the day of Easter Sunday</p>
|
||||
</dd>
|
||||
<dt class="field-odd">Return type</dt>
|
||||
<dd class="field-odd"><p>datetime.date</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
@@ -84,24 +113,32 @@
|
||||
<code class="descname">gaußsche_osterformel</code><span class="sig-paren">(</span><em>year</em><span class="sig-paren">)</span><a class="headerlink" href="#date.gaußsche_osterformel" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Gaußsche Osterformel.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Returns</dt>
|
||||
<dd class="field-odd"><p>int – the day of Easter Sunday as a day in march.</p>
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><p><strong>year</strong> (<em>int</em>) – the year to calculate the Easter Sunday</p>
|
||||
</dd>
|
||||
<dt class="field-even">Returns</dt>
|
||||
<dd class="field-even"><p>the day of Easter Sunday as a day in march.</p>
|
||||
</dd>
|
||||
<dt class="field-odd">Return type</dt>
|
||||
<dd class="field-odd"><p>int</p>
|
||||
</dd>
|
||||
<dt class="field-even">Variables</dt>
|
||||
<dd class="field-even"><ul class="simple">
|
||||
<li><p><strong>X</strong> (<em>int</em>) – Das Jahr / year</p></li>
|
||||
<li><p><strong>K</strong><strong>(</strong><strong>X</strong><strong>)</strong> (<em>int</em>) – Die Säkularzahl</p></li>
|
||||
<li><p><strong>M</strong><strong>(</strong><strong>X</strong><strong>)</strong> (<em>int</em>) – Die säkulare Mondschaltung</p></li>
|
||||
<li><p><strong>S</strong><strong>(</strong><strong>K</strong><strong>)</strong> (<em>int</em>) – Die säkulare Sonnenschaltung</p></li>
|
||||
<li><p><strong>A</strong><strong>(</strong><strong>X</strong><strong>)</strong> (<em>int</em>) – Den Mondparameter</p></li>
|
||||
<li><p><strong>D</strong><strong>(</strong><strong>A</strong><strong>,</strong><strong>M</strong><strong>)</strong> (<em>int</em>) – Den Keim für den ersten Vollmond im Frühling</p></li>
|
||||
<li><p><strong>R</strong><strong>(</strong><strong>D</strong><strong>,</strong><strong>A</strong><strong>)</strong> (<em>int</em>) – Die kalendarische Korrekturgröße</p></li>
|
||||
<li><p><strong>OG</strong><strong>(</strong><strong>D</strong><strong>,</strong><strong>R</strong><strong>)</strong> (<em>int</em>) – Die Ostergrenze</p></li>
|
||||
<li><p><strong>SZ</strong><strong>(</strong><strong>X</strong><strong>,</strong><strong>S</strong><strong>)</strong> (<em>int</em>) – Den ersten Sonntag im März</p></li>
|
||||
<li><p><strong>OE</strong><strong>(</strong><strong>OG</strong><strong>,</strong><strong>SZ</strong><strong>)</strong> (<em>int</em>) – Die Entfernung des Ostersonntags von der Ostergrenze (Osterentfernung in Tagen)</p></li>
|
||||
<li><p><strong>OS</strong><strong>(</strong><strong>OG</strong><strong>,</strong><strong>OE</strong><strong>)</strong> (<em>int</em>) – Das Datum des Ostersonntags als Märzdatum (32. März = 1. April usw.)</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
<p>Algorithmus gilt für den Gregorianischen Kalender.</p>
|
||||
<ul class="simple">
|
||||
<li><p>X – Das Jahr / year</p></li>
|
||||
<li><p>K(X) – Die Säkularzahl</p></li>
|
||||
<li><p>M(K) – Die säkulare Mondschaltung</p></li>
|
||||
<li><p>S(K) – Die säkulare Sonnenschaltung</p></li>
|
||||
<li><p>A(X) – Den Mondparameter</p></li>
|
||||
<li><p>D(A,M) – Den Keim für den ersten Vollmond im Frühling</p></li>
|
||||
<li><p>R(D,A) – Die kalendarische Korrekturgröße</p></li>
|
||||
<li><p>OG(D,R) – Die Ostergrenze</p></li>
|
||||
<li><p>SZ(X,S) – Den ersten Sonntag im März</p></li>
|
||||
<li><p>OE(OG,SZ) – Die Entfernung des Ostersonntags von der Ostergrenze (Osterentfernung in Tagen)</p></li>
|
||||
<li><p>OS(OG,OE) – Das Datum des Ostersonntags als Märzdatum (32. März = 1. April usw.)</p></li>
|
||||
</ul>
|
||||
<p>source: <a class="reference external" href="https://de.wikipedia.org/wiki/Gau%C3%9Fsche_Osterformel">https://de.wikipedia.org/wiki/Gau%C3%9Fsche_Osterformel</a></p>
|
||||
</dd></dl>
|
||||
|
||||
@@ -110,8 +147,14 @@
|
||||
<code class="descname">pentecost</code><span class="sig-paren">(</span><em>year</em><span class="sig-paren">)</span><a class="headerlink" href="#date.pentecost" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Pentecost.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Returns</dt>
|
||||
<dd class="field-odd"><p>datetime.date – the day of Pentecost</p>
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><p><strong>year</strong> (<em>int</em>) – the year to calculate the Pentecost</p>
|
||||
</dd>
|
||||
<dt class="field-even">Returns</dt>
|
||||
<dd class="field-even"><p>the day of Pentecost</p>
|
||||
</dd>
|
||||
<dt class="field-odd">Return type</dt>
|
||||
<dd class="field-odd"><p>datetime.date</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
47
docs/build/html/fit.html
vendored
47
docs/build/html/fit.html
vendored
@@ -13,6 +13,7 @@
|
||||
<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" />
|
||||
|
||||
@@ -33,26 +34,32 @@
|
||||
|
||||
<div class="section" id="module-fit">
|
||||
<span id="fit-module"></span><h1>fit module<a class="headerlink" href="#module-fit" title="Permalink to this headline">¶</a></h1>
|
||||
<dl class="function">
|
||||
<p>Function and approximation.</p>
|
||||
<span class="target" id="module-fit"></span><dl class="function">
|
||||
<dt id="fit.gauss">
|
||||
<code class="descname">gauss</code><span class="sig-paren">(</span><em>x</em>, <em>*p</em><span class="sig-paren">)</span><a class="headerlink" href="#fit.gauss" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Gauss distribution function.</p>
|
||||
<div class="math notranslate nohighlight">
|
||||
\[f(x)=ae^{-(x-b)^{2}/(2c^{2})}\]</div>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><ul class="simple">
|
||||
<li><p><strong>x</strong> – positions where the gauss function will be calculated</p></li>
|
||||
<li><p><strong>p</strong> – <p>gauss parameters [a, b, c, d]:</p>
|
||||
<li><p><strong>x</strong> (<em>int</em><em> or </em><em>float</em><em> or </em><em>list</em><em> or </em><em>numpy.ndarray</em>) – positions where the gauss function will be calculated</p></li>
|
||||
<li><p><strong>p</strong> (<em>list</em>) – <p>gauss parameters [a, b, c, d]:</p>
|
||||
<ul>
|
||||
<li><p>a – amplitude (integral = 1 if a = 1/(c*sqrt(2*pi)))</p></li>
|
||||
<li><p>b – expected value mu (position of maximum, default = 0)</p></li>
|
||||
<li><p>c – standard deviation sigma (variance sigma**2 = c**2)</p></li>
|
||||
<li><p>a – amplitude (<span class="math notranslate nohighlight">\(\int y \,\mathrm{d}x=1 \Leftrightarrow a=1/(c\sqrt{2\pi})\)</span> )</p></li>
|
||||
<li><p>b – expected value <span class="math notranslate nohighlight">\(\mu\)</span> (position of maximum, default = 0)</p></li>
|
||||
<li><p>c – standard deviation <span class="math notranslate nohighlight">\(\sigma\)</span> (variance <span class="math notranslate nohighlight">\(\sigma^2=c^2\)</span>)</p></li>
|
||||
<li><p>d – vertical offset (default = 0)</p></li>
|
||||
</ul>
|
||||
</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt class="field-even">Returns</dt>
|
||||
<dd class="field-even"><p>array – gauss values at given positions x</p>
|
||||
<dd class="field-even"><p>gauss values at given positions x</p>
|
||||
</dd>
|
||||
<dt class="field-odd">Return type</dt>
|
||||
<dd class="field-odd"><p>numpy.ndarray</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
@@ -64,22 +71,32 @@
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><ul class="simple">
|
||||
<li><p><strong>x</strong> – positions</p></li>
|
||||
<li><p><strong>y</strong> – values</p></li>
|
||||
<li><p><strong>e</strong> – error values</p></li>
|
||||
<li><p><strong>x_fit</strong> – positions of fitted function (default steps is 3*len(x) but min 150)</p></li>
|
||||
<li><p><strong>x</strong> (<em>int</em><em> or </em><em>float</em><em> or </em><em>list</em><em> or </em><em>numpy.ndarray</em>) – positions</p></li>
|
||||
<li><p><strong>y</strong> (<em>int</em><em> or </em><em>float</em><em> or </em><em>list</em><em> or </em><em>numpy.ndarray</em>) – values</p></li>
|
||||
<li><p><strong>e</strong> (<em>int</em><em> or </em><em>float</em><em> or </em><em>list</em><em> or </em><em>numpy.ndarray</em>) – error values (default = None)</p></li>
|
||||
<li><p><strong>x_fit</strong> (<em>int</em><em> or </em><em>float</em><em> or </em><em>list</em><em> or </em><em>numpy.ndarray</em>) – positions of fitted function (default = None, if None then x
|
||||
is used)</p></li>
|
||||
<li><p><strong>verbose</strong> (<em>bool</em>) – verbose information (default = False)</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt class="field-even">Returns</dt>
|
||||
<dd class="field-even"><p><ul class="simple">
|
||||
<li><p>y_fit – values</p></li>
|
||||
<li><p>popt – parameters of gauss distribution function (amplitude a, expected
|
||||
value mu, standard deviation sigma, vertical offset d)</p></li>
|
||||
<li><p>FWHM – full width at half maximum</p></li>
|
||||
<li><p>numpy.ndarray – fitted values (y_fit)</p></li>
|
||||
<li><p>numpy.ndarray – parameters of gauss distribution function (popt:
|
||||
amplitude a, expected value <span class="math notranslate nohighlight">\(\mu\)</span>, standard deviation
|
||||
<span class="math notranslate nohighlight">\(\sigma\)</span>, vertical offset d)</p></li>
|
||||
<li><p>numpy.float64 – full width at half maximum (FWHM)</p></li>
|
||||
</ul>
|
||||
</p>
|
||||
</dd>
|
||||
<dt class="field-odd">Return type</dt>
|
||||
<dd class="field-odd"><p>tuple</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="admonition seealso">
|
||||
<p class="admonition-title">See also</p>
|
||||
<p><a class="reference internal" href="#fit.gauss" title="fit.gauss"><code class="xref py py-meth docutils literal notranslate"><span class="pre">gauss()</span></code></a></p>
|
||||
</div>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
|
||||
55
docs/build/html/genindex.html
vendored
55
docs/build/html/genindex.html
vendored
@@ -14,6 +14,7 @@
|
||||
<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="#" />
|
||||
<link rel="search" title="Search" href="search.html" />
|
||||
|
||||
@@ -42,8 +43,10 @@
|
||||
| <a href="#E"><strong>E</strong></a>
|
||||
| <a href="#F"><strong>F</strong></a>
|
||||
| <a href="#G"><strong>G</strong></a>
|
||||
| <a href="#I"><strong>I</strong></a>
|
||||
| <a href="#L"><strong>L</strong></a>
|
||||
| <a href="#M"><strong>M</strong></a>
|
||||
| <a href="#N"><strong>N</strong></a>
|
||||
| <a href="#P"><strong>P</strong></a>
|
||||
| <a href="#R"><strong>R</strong></a>
|
||||
| <a href="#S"><strong>S</strong></a>
|
||||
@@ -73,17 +76,23 @@
|
||||
<h2 id="D">D</h2>
|
||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="data.html#module-data">data (module)</a>
|
||||
<li><a href="data.html#module-data">data (module)</a>, <a href="data.html#module-data">[1]</a>
|
||||
</li>
|
||||
<li><a href="data.html#data.data_load">data_load() (in module data)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="data.html#data.data_read">data_read() (in module data)</a>
|
||||
</li>
|
||||
<li><a href="data.html#data.data_store">data_store() (in module data)</a>
|
||||
</li>
|
||||
<li><a href="date.html#module-date">date (module)</a>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="date.html#module-date">date (module)</a>, <a href="date.html#module-date">[1]</a>
|
||||
</li>
|
||||
<li><a href="solver_model.html#solver_model.disk">disk() (in module solver_model)</a>
|
||||
</li>
|
||||
<li><a href="solver_model.html#solver_model.disk_nm">disk_nm() (in module solver_model)</a>
|
||||
</li>
|
||||
<li><a href="solver_model.html#solver_model.disk_nmmdk">disk_nmmdk() (in module solver_model)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
</tr></table>
|
||||
@@ -91,10 +100,16 @@
|
||||
<h2 id="E">E</h2>
|
||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="date.html#date.easter_friday">easter_friday() (in module date)</a>
|
||||
<li><a href="solver.html#solver.e1">e1() (in module solver)</a>
|
||||
</li>
|
||||
<li><a href="solver.html#solver.e2">e2() (in module solver)</a>
|
||||
</li>
|
||||
<li><a href="solver.html#solver.e4">e4() (in module solver)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="date.html#date.easter_friday">easter_friday() (in module date)</a>
|
||||
</li>
|
||||
<li><a href="date.html#date.easter_monday">easter_monday() (in module date)</a>
|
||||
</li>
|
||||
<li><a href="date.html#date.easter_sunday">easter_sunday() (in module date)</a>
|
||||
@@ -105,7 +120,7 @@
|
||||
<h2 id="F">F</h2>
|
||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="fit.html#module-fit">fit (module)</a>
|
||||
<li><a href="fit.html#module-fit">fit (module)</a>, <a href="fit.html#module-fit">[1]</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
</tr></table>
|
||||
@@ -121,7 +136,15 @@
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="date.html#date.gaußsche_osterformel">gaußsche_osterformel() (in module date)</a>
|
||||
</li>
|
||||
<li><a href="geometry.html#module-geometry">geometry (module)</a>
|
||||
<li><a href="geometry.html#module-geometry">geometry (module)</a>, <a href="geometry.html#module-geometry">[1]</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
</tr></table>
|
||||
|
||||
<h2 id="I">I</h2>
|
||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="solver.html#solver.i1">i1() (in module solver)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
</tr></table>
|
||||
@@ -146,6 +169,18 @@
|
||||
</ul></td>
|
||||
</tr></table>
|
||||
|
||||
<h2 id="N">N</h2>
|
||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="solver.html#solver.newmark_newtonraphson">newmark_newtonraphson() (in module solver)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="solver.html#solver.newmark_newtonraphson_rdk">newmark_newtonraphson_rdk() (in module solver)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
</tr></table>
|
||||
|
||||
<h2 id="P">P</h2>
|
||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
@@ -175,6 +210,12 @@
|
||||
<h2 id="S">S</h2>
|
||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="solver.html#module-solver">solver (module)</a>, <a href="solver.html#module-solver">[1]</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="solver_model.html#module-solver_model">solver_model (module)</a>, <a href="solver_model.html#module-solver_model">[1]</a>
|
||||
</li>
|
||||
<li><a href="geometry.html#geometry.square">square() (in module geometry)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
|
||||
188
docs/build/html/geometry.html
vendored
188
docs/build/html/geometry.html
vendored
@@ -13,6 +13,7 @@
|
||||
<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" />
|
||||
|
||||
@@ -33,32 +34,81 @@
|
||||
|
||||
<div class="section" id="module-geometry">
|
||||
<span id="geometry-module"></span><h1>geometry module<a class="headerlink" href="#module-geometry" title="Permalink to this headline">¶</a></h1>
|
||||
<p>2D</p>
|
||||
<p>@date: 2019-03-21
|
||||
@author: Daniel Weschke</p>
|
||||
<dl class="function">
|
||||
<p>2D geometry objects.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Date</dt>
|
||||
<dd class="field-odd"><p>2019-03-21</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<span class="target" id="module-geometry"></span><dl class="function">
|
||||
<dt id="geometry.cubic">
|
||||
<code class="descname">cubic</code><span class="sig-paren">(</span><em>point1</em>, <em>angle1</em>, <em>point2</em>, <em>angle2</em>, <em>samples=50</em><span class="sig-paren">)</span><a class="headerlink" href="#geometry.cubic" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>returns
|
||||
([sample_point1_x, sample_point2_x, …], [sample_points1_y, sample_point2_y, …])</p>
|
||||
<dd><dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><ul class="simple">
|
||||
<li><p><strong>point1</strong> (<em>tuple</em>) – one end point</p></li>
|
||||
<li><p><strong>angle1</strong> (<em>int</em><em> or </em><em>float</em>) – the slope at the one end point</p></li>
|
||||
<li><p><strong>point2</strong> (<em>tuple</em>) – other end point</p></li>
|
||||
<li><p><strong>angle2</strong> (<em>int</em><em> or </em><em>float</em>) – the slope at the other end point</p></li>
|
||||
<li><p><strong>samples</strong> (<em>int</em>) – number of sampling points</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt class="field-even">Returns</dt>
|
||||
<dd class="field-even"><p>([sample_point1_x, sample_point2_x, …],
|
||||
[sample_points1_y, sample_point2_y, …])</p>
|
||||
</dd>
|
||||
<dt class="field-odd">Return type</dt>
|
||||
<dd class="field-odd"><p>tuple</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="geometry.cubic_deg">
|
||||
<code class="descname">cubic_deg</code><span class="sig-paren">(</span><em>point1</em>, <em>angle1</em>, <em>point2</em>, <em>angle2</em><span class="sig-paren">)</span><a class="headerlink" href="#geometry.cubic_deg" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>returns
|
||||
([sample_point1_x, sample_point2_x, …], [sample_points1_y, sample_point2_y, …])</p>
|
||||
<dd><dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><ul class="simple">
|
||||
<li><p><strong>point1</strong> (<em>tuple</em>) – one end point</p></li>
|
||||
<li><p><strong>angle1</strong> (<em>int</em><em> or </em><em>float</em>) – the slope at the one end point</p></li>
|
||||
<li><p><strong>point2</strong> (<em>tuple</em>) – other end point</p></li>
|
||||
<li><p><strong>angle2</strong> (<em>int</em><em> or </em><em>float</em>) – the slope at the other end point</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt class="field-even">Returns</dt>
|
||||
<dd class="field-even"><p>([sample_point1_x, sample_point2_x, …],
|
||||
[sample_points1_y, sample_point2_y, …])</p>
|
||||
</dd>
|
||||
<dt class="field-odd">Return type</dt>
|
||||
<dd class="field-odd"><p>tuple</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="admonition seealso">
|
||||
<p class="admonition-title">See also</p>
|
||||
<p><a class="reference internal" href="#geometry.cubic" title="geometry.cubic"><code class="xref py py-meth docutils literal notranslate"><span class="pre">cubic()</span></code></a></p>
|
||||
</div>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="geometry.line">
|
||||
<code class="descname">line</code><span class="sig-paren">(</span><em>point1</em>, <em>point2</em>, <em>samples=2</em><span class="sig-paren">)</span><a class="headerlink" href="#geometry.line" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>samples: number of sampling points</p>
|
||||
<p>y = (y2-y1)/(x2-x1)*(x-x1) + y1</p>
|
||||
<dl class="simple">
|
||||
<dt>returns</dt><dd><p>((point1_x, point2_x), (points1_y, point2_y))
|
||||
or
|
||||
([sample_point1_x, sample_point2_x, …], [sample_points1_y, sample_point2_y, …])</p>
|
||||
<dd><div class="math notranslate nohighlight">
|
||||
\[y = \frac{y_2-y_1}{x_2-x_1}(x-x_1) + y_1\]</div>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><ul class="simple">
|
||||
<li><p><strong>point1</strong> (<em>tuple</em>) – one end point</p></li>
|
||||
<li><p><strong>point2</strong> (<em>tuple</em>) – other end point</p></li>
|
||||
<li><p><strong>samples</strong> (<em>int</em>) – number of sampling points</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt class="field-even">Returns</dt>
|
||||
<dd class="field-even"><p>((point1_x, point2_x), (points1_y, point2_y)) or
|
||||
([sample_point1_x, sample_point2_x, …],
|
||||
[sample_points1_y, sample_point2_y, …])</p>
|
||||
</dd>
|
||||
<dt class="field-odd">Return type</dt>
|
||||
<dd class="field-odd"><p>tuple</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
@@ -66,26 +116,57 @@ or
|
||||
<dl class="function">
|
||||
<dt id="geometry.points">
|
||||
<code class="descname">points</code><span class="sig-paren">(</span><em>*pts</em><span class="sig-paren">)</span><a class="headerlink" href="#geometry.points" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>returns
|
||||
((point1_x, point2_x), (point1_y, point2_y), …)</p>
|
||||
<dd><dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><p><strong>*pts</strong> – points to rearrange</p>
|
||||
</dd>
|
||||
<dt class="field-even">Returns</dt>
|
||||
<dd class="field-even"><p>((point1_x, point2_x), (point1_y, point2_y), …)</p>
|
||||
</dd>
|
||||
<dt class="field-odd">Return type</dt>
|
||||
<dd class="field-odd"><p>tuple</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="geometry.rectangle">
|
||||
<code class="descname">rectangle</code><span class="sig-paren">(</span><em>width</em>, <em>height</em><span class="sig-paren">)</span><a class="headerlink" href="#geometry.rectangle" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>returns
|
||||
(point1, point2, point3, point4)</p>
|
||||
<dd><dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><ul class="simple">
|
||||
<li><p><strong>width</strong> (<em>int</em><em> or </em><em>float</em>) – the width of the rectangle</p></li>
|
||||
<li><p><strong>height</strong> (<em>int</em><em> or </em><em>float</em>) – the height of the rectangle</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt class="field-even">Returns</dt>
|
||||
<dd class="field-even"><p>(point1, point2, point3, point4)</p>
|
||||
</dd>
|
||||
<dt class="field-odd">Return type</dt>
|
||||
<dd class="field-odd"><p>tuple</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="geometry.rotate">
|
||||
<code class="descname">rotate</code><span class="sig-paren">(</span><em>origin</em>, <em>angle</em>, <em>*pts</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#geometry.rotate" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Rotate a point or polygon counterclockwise by a given angle around a given origin.</p>
|
||||
<p>The angle should be given in radians.</p>
|
||||
<dl class="simple">
|
||||
<dt>returns</dt><dd><p>(point_x, point_y)
|
||||
or
|
||||
(point1, point2, …)</p>
|
||||
<dd><p>Rotate a point or polygon counterclockwise by a given angle around a given
|
||||
origin. The angle should be given in radians.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><ul class="simple">
|
||||
<li><p><strong>origin</strong> (<em>tuple</em>) – the center of rotation</p></li>
|
||||
<li><p><strong>angle</strong> (<em>int</em><em> or </em><em>float</em>) – the rotation angle</p></li>
|
||||
<li><p><strong>*pts</strong> – points to rotate</p></li>
|
||||
<li><p><strong>**kwargs</strong> – options</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt class="field-even">Returns</dt>
|
||||
<dd class="field-even"><p>(point_x, point_y) or (point1, point2, …)</p>
|
||||
</dd>
|
||||
<dt class="field-odd">Return type</dt>
|
||||
<dd class="field-odd"><p>tuple</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
@@ -93,31 +174,66 @@ or
|
||||
<dl class="function">
|
||||
<dt id="geometry.rotate_deg">
|
||||
<code class="descname">rotate_deg</code><span class="sig-paren">(</span><em>origin</em>, <em>angle</em>, <em>*pts</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#geometry.rotate_deg" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Rotate a point or polygon counterclockwise by a given angle around a given origin.</p>
|
||||
<p>The angle should be given in degrees.</p>
|
||||
<dl class="simple">
|
||||
<dt>returns</dt><dd><p>(point_x, point_y)
|
||||
or
|
||||
(point1, point2, …)</p>
|
||||
<dd><p>Rotate a point or polygon counterclockwise by a given angle around a given
|
||||
origin. The angle should be given in degrees.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><ul class="simple">
|
||||
<li><p><strong>origin</strong> (<em>tuple</em>) – the center of rotation</p></li>
|
||||
<li><p><strong>angle</strong> (<em>int</em><em> or </em><em>float</em>) – the rotation angle</p></li>
|
||||
<li><p><strong>*pts</strong> – points to rotate</p></li>
|
||||
<li><p><strong>**kwargs</strong> – options</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt class="field-even">Returns</dt>
|
||||
<dd class="field-even"><p>(point_x, point_y) or (point1, point2, …)</p>
|
||||
</dd>
|
||||
<dt class="field-odd">Return type</dt>
|
||||
<dd class="field-odd"><p>tuple</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="admonition seealso">
|
||||
<p class="admonition-title">See also</p>
|
||||
<p><a class="reference internal" href="#geometry.rotate" title="geometry.rotate"><code class="xref py py-meth docutils literal notranslate"><span class="pre">rotate()</span></code></a></p>
|
||||
</div>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="geometry.square">
|
||||
<code class="descname">square</code><span class="sig-paren">(</span><em>width</em><span class="sig-paren">)</span><a class="headerlink" href="#geometry.square" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>returns
|
||||
(point1, point2, point3, point4)</p>
|
||||
<dd><dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><p><strong>width</strong> (<em>int</em><em> or </em><em>float</em>) – the edge size of the square</p>
|
||||
</dd>
|
||||
<dt class="field-even">Returns</dt>
|
||||
<dd class="field-even"><p>(point1, point2, point3, point4)</p>
|
||||
</dd>
|
||||
<dt class="field-odd">Return type</dt>
|
||||
<dd class="field-odd"><p>tuple</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="admonition seealso">
|
||||
<p class="admonition-title">See also</p>
|
||||
<p><a class="reference internal" href="#geometry.rectangle" title="geometry.rectangle"><code class="xref py py-meth docutils literal notranslate"><span class="pre">rectangle()</span></code></a></p>
|
||||
</div>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="geometry.translate">
|
||||
<code class="descname">translate</code><span class="sig-paren">(</span><em>vec</em>, <em>*pts</em><span class="sig-paren">)</span><a class="headerlink" href="#geometry.translate" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Translate a point or polygon by a given vector.</p>
|
||||
<dl class="simple">
|
||||
<dt>returns</dt><dd><p>(point_x, point_y)
|
||||
or
|
||||
(point1, point2, …)</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><ul class="simple">
|
||||
<li><p><strong>vec</strong> (<em>tuple</em>) – translation vector</p></li>
|
||||
<li><p><strong>*pts</strong> – points to translate</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt class="field-even">Returns</dt>
|
||||
<dd class="field-even"><p>(point_x, point_y) or (point1, point2, …)</p>
|
||||
</dd>
|
||||
<dt class="field-odd">Return type</dt>
|
||||
<dd class="field-odd"><p>tuple</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
1
docs/build/html/index.html
vendored
1
docs/build/html/index.html
vendored
@@ -13,6 +13,7 @@
|
||||
<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" />
|
||||
|
||||
|
||||
3
docs/build/html/modules.html
vendored
3
docs/build/html/modules.html
vendored
@@ -13,6 +13,7 @@
|
||||
<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" />
|
||||
|
||||
@@ -39,6 +40,8 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="date.html">date module</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="fit.html">fit module</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="geometry.html">geometry module</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="solver.html">solver module</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="solver_model.html">solver_model module</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
13
docs/build/html/objects.inv
vendored
13
docs/build/html/objects.inv
vendored
@@ -2,9 +2,10 @@
|
||||
# Project: pylib
|
||||
# Version:
|
||||
# The remainder of this file is compressed using zlib.
|
||||
xڕ<EFBFBD>AN<EFBFBD>0E<>9<EFBFBD>lS<6C><53>7`<60><>Ăe4<65>'<27><><EFBFBD><EFBFBD>ǑȎk<C88E><6B>0܄<30>`<60>I7U<37>l"{<7B><><EFBFBD><EFBFBD><EFBFBD>#<23>k<>mmD<6D><44><EFBFBD>3<EFBFBD><03><><EFBFBD><EFBFBD>m<0C>w,<2C><0E><>)<29><11><><EFBFBD><EFBFBD>I<EFBFBD><49><EFBFBD>$#E-.F<><19><><EFBFBD><1A><>F<EFBFBD><46>m<EFBFBD><6D>mp<03>Q<EFBFBD>)LY<4C>!<21>4W<34>Ty<54>@mQZ)<29>[<5B><>F<EFBFBD><46><EFBFBD>]<5D>W<EFBFBD><57><EFBFBD><10>caB^il<69><6C>zZ<7A><5A>!<21>)<17>R<EFBFBD><52><EFBFBD>~?kc<6B>ytڸ<74>M<EFBFBD><4D><EFBFBD><EFBFBD><04><><EFBFBD> S<><53><EFBFBD><EFBFBD>.<2E>6g<><67><03><>$?<3F>M<EFBFBD><4D>x!<21>Z<EFBFBD><5A><EFBFBD><EFBFBD><EFBFBD>tc<74>v<EFBFBD><76><EFBFBD><EFBFBD><1D>J<EFBFBD>(a<><61>Ga
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>т]Q<>YФ<59><D0A4>
|
||||
C<EFBFBD>ȉ<EFBFBD>0<EFBFBD><EFBFBD><EFBFBD>!?<3F>X<EFBFBD><58>q<EFBFBD>S
|
||||
G
|
||||
*<<3C> 4<><34><EFBFBD><18>
|
||||
<EFBFBD><EFBFBD>?<0F><><EFBFBD><1F><؊ш?<3F><><EFBFBD>N<13><>n<EFBFBD>>
|
||||
xڥ<EFBFBD>Mr<EFBFBD> <10><>s
|
||||
R<EFBFBD>VS<EFBFBD>++<2B> <20>T<EFBFBD>ʋ,)Zb~%<25><><EFBFBD><EFBFBD><EFBFBD><0F><><EFBFBD>$<24>A<1A><>xP<78><50>A<EFBFBD><41>^C<>Z<EFBFBD>yF<79>ӝ<EFBFBD>bP@<40><02><><EFBFBD><EFBFBD>m
|
||||
5<EFBFBD>H<EFBFBD>;<07>U<><55>ȷ<EFBFBD><C8B7>^ZCn2E<32>:<3A>F<EFBFBD>[<07>Yͤ<59>F<EFBFBD>|7<><37><1B>3<EFBFBD>`0<>P<EFBFBD>ү<EFBFBD>.<2E><>t<EFBFBD>C<0F><>N
|
||||
v<EFBFBD>Ƶ5[p<1C><><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><1F>ڨk<DAA8>Ӡ<EFBFBD><D3A0>z0x<><78><EFBFBD><EFBFBD><EFBFBD>uϋ2<CF8B>XX<04>wa<0B><><EFBFBD><EFBFBD><EFBFBD>+<2B>[0X
|
||||
ޝ<EFBFBD><EFBFBD>M<EFBFBD><EFBFBD><EFBFBD>.|8H><3E>-UK<55>
|
||||
<EFBFBD><EFBFBD>%J<1A><>{+<2B><>z<EFBFBD><01><>tjC
|
||||
33
docs/build/html/py-modindex.html
vendored
33
docs/build/html/py-modindex.html
vendored
@@ -13,6 +13,7 @@
|
||||
<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" />
|
||||
|
||||
@@ -44,7 +45,8 @@
|
||||
<div class="modindex-jumpbox">
|
||||
<a href="#cap-d"><strong>d</strong></a> |
|
||||
<a href="#cap-f"><strong>f</strong></a> |
|
||||
<a href="#cap-g"><strong>g</strong></a>
|
||||
<a href="#cap-g"><strong>g</strong></a> |
|
||||
<a href="#cap-s"><strong>s</strong></a>
|
||||
</div>
|
||||
|
||||
<table class="indextable modindextable">
|
||||
@@ -54,29 +56,42 @@
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<a href="data.html#module-data"><code class="xref">data</code></a></td><td>
|
||||
<em></em></td></tr>
|
||||
<a href="data.html#module-data"><code class="xref">data</code></a> <em>(*nix, Windows)</em></td><td>
|
||||
<em>Handle data files.</em></td></tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<a href="date.html#module-date"><code class="xref">date</code></a></td><td>
|
||||
<em></em></td></tr>
|
||||
<a href="date.html#module-date"><code class="xref">date</code></a> <em>(*nix, Windows)</em></td><td>
|
||||
<em>Special dates.</em></td></tr>
|
||||
<tr class="pcap"><td></td><td> </td><td></td></tr>
|
||||
<tr class="cap" id="cap-f"><td></td><td>
|
||||
<strong>f</strong></td><td></td></tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<a href="fit.html#module-fit"><code class="xref">fit</code></a></td><td>
|
||||
<em></em></td></tr>
|
||||
<a href="fit.html#module-fit"><code class="xref">fit</code></a> <em>(*nix, Windows)</em></td><td>
|
||||
<em>Function and approximation.</em></td></tr>
|
||||
<tr class="pcap"><td></td><td> </td><td></td></tr>
|
||||
<tr class="cap" id="cap-g"><td></td><td>
|
||||
<strong>g</strong></td><td></td></tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<a href="geometry.html#module-geometry"><code class="xref">geometry</code></a></td><td>
|
||||
<em></em></td></tr>
|
||||
<a href="geometry.html#module-geometry"><code class="xref">geometry</code></a> <em>(*nix, Windows)</em></td><td>
|
||||
<em>Geometry objects.</em></td></tr>
|
||||
<tr class="pcap"><td></td><td> </td><td></td></tr>
|
||||
<tr class="cap" id="cap-s"><td></td><td>
|
||||
<strong>s</strong></td><td></td></tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<a href="solver.html#module-solver"><code class="xref">solver</code></a> <em>(*nix, Windows)</em></td><td>
|
||||
<em>Numerical solver.</em></td></tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<a href="solver_model.html#module-solver_model"><code class="xref">solver_model</code></a> <em>(*nix, Windows)</em></td><td>
|
||||
<em>Mechanical models.</em></td></tr>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
1
docs/build/html/search.html
vendored
1
docs/build/html/search.html
vendored
@@ -14,6 +14,7 @@
|
||||
<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>
|
||||
<script type="text/javascript" src="_static/searchtools.js"></script>
|
||||
<link rel="index" title="Index" href="genindex.html" />
|
||||
<link rel="search" title="Search" href="#" />
|
||||
|
||||
2
docs/build/html/searchindex.js
vendored
2
docs/build/html/searchindex.js
vendored
@@ -1 +1 @@
|
||||
Search.setIndex({docnames:["data","date","fit","geometry","index","modules","src"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.cpp":1,"sphinx.domains.javascript":1,"sphinx.domains.math":2,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,sphinx:56},filenames:["data.rst","date.rst","fit.rst","geometry.rst","index.rst","modules.rst","src.rst"],objects:{"":{data:[0,0,0,"-"],date:[1,0,0,"-"],fit:[2,0,0,"-"],geometry:[3,0,0,"-"]},data:{data_load:[0,1,1,""],data_read:[0,1,1,""],data_store:[0,1,1,""],main:[0,1,1,""]},date:{"gau\u00dfsche_osterformel":[1,1,1,""],ascension_of_jesus:[1,1,1,""],easter_friday:[1,1,1,""],easter_monday:[1,1,1,""],easter_sunday:[1,1,1,""],pentecost:[1,1,1,""]},fit:{gauss:[2,1,1,""],gauss_fit:[2,1,1,""],main:[2,1,1,""]},geometry:{cubic:[3,1,1,""],cubic_deg:[3,1,1,""],line:[3,1,1,""],points:[3,1,1,""],rectangle:[3,1,1,""],rotate:[3,1,1,""],rotate_deg:[3,1,1,""],square:[3,1,1,""],translate:[3,1,1,""]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"]},objtypes:{"0":"py:module","1":"py:function"},terms:{"9fsche_osterformel":1,"default":2,"f\u00fcr":1,"fr\u00fchling":1,"function":2,"gau\u00dfsch":1,"gau\u00dfsche_osterformel":1,"int":1,"korrekturgr\u00f6\u00df":1,"m\u00e4rz":1,"m\u00e4rzdatum":1,"return":[1,2,3],"s\u00e4kular":1,"s\u00e4kularzahl":1,Das:1,The:3,algorithmu:1,als:1,amplitud:2,angl:3,angle1:3,angle2:3,april:1,around:3,arrai:2,ascens:1,ascension_of_jesu:1,ascii:0,author:[1,3],binari:0,calcul:2,counterclockwis:3,creat:1,cubic:3,cubic_deg:3,dai:1,daniel:[1,3],data:[2,5],data_load:0,data_read:0,data_stor:0,date:[3,5],datetim:1,datum:1,degre:3,den:1,der:1,des:1,deviat:2,die:1,distribut:2,easter:1,easter_fridai:1,easter_mondai:1,easter_sundai:1,entfernung:1,error:2,ersten:1,expect:2,fals:[0,2],file:0,file_nam:0,fit:5,frac:[],fridai:1,from:0,full:2,fwhm:2,gau:1,gauss:2,gauss_fit:2,geometri:5,gilt:1,given:[2,3],gregorianischen:1,half:2,height:3,http:1,index:4,integr:2,jahr:1,jan:1,jesu:1,kalend:1,kalendarisch:1,keim:1,kwarg:3,len:2,line:3,load:0,main:[0,2],march:1,maximum:2,min:2,modul:[4,5],mon:1,mondai:1,mondparamet:1,mondschaltung:1,none:2,number:3,object:0,object_data:0,offset:2,org:1,origin:3,osterentfernung:1,osterformel:1,ostergrenz:1,ostersonntag:1,page:4,paramet:2,pentecost:1,point1:3,point1_i:3,point1_x:3,point2:3,point2_i:3,point2_x:3,point3:3,point4:3,point:3,point_i:3,point_x:3,points1_i:3,polygon:3,popt:2,posit:2,program:0,pts:3,rac:[],radian:3,read:0,rectangl:3,rotat:3,rotate_deg:3,sampl:3,sample_point1_x:3,sample_point2_i:3,sample_point2_x:3,sample_points1_i:3,search:4,should:3,sigma:2,sonnenschaltung:1,sonntag:1,sourc:1,sqrt:2,squar:3,standard:2,step:2,store:0,sum_:[],sundai:1,tagen:1,test:2,translat:3,usw:1,valu:2,varianc:2,vec:3,vector:3,verbos:[0,2],vertic:2,vollmond:1,von:1,weschk:[1,3],where:2,width:[2,3],wiki:1,wikipedia:1,x_column:0,x_fit:2,y_column:0,y_fit:2,year:1},titles:["data module","date module","fit module","geometry module","Welcome to pylib\u2019s documentation!","src","src package"],titleterms:{content:6,data:[0,6],date:[1,6],document:4,fit:[2,6],geometri:[3,6],indic:4,modul:[0,1,2,3,6],packag:6,pylib:4,src:[5,6],submodul:6,tabl:4,welcom:4}})
|
||||
Search.setIndex({docnames:["data","date","fit","geometry","index","modules","solver","solver_model"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.cpp":1,"sphinx.domains.javascript":1,"sphinx.domains.math":2,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,sphinx:56},filenames:["data.rst","date.rst","fit.rst","geometry.rst","index.rst","modules.rst","solver.rst","solver_model.rst"],objects:{"":{data:[0,0,0,"-"],date:[1,0,0,"-"],fit:[2,0,0,"-"],geometry:[3,0,0,"-"],solver:[6,0,0,"-"],solver_model:[7,0,0,"-"]},data:{data_load:[0,1,1,""],data_read:[0,1,1,""],data_store:[0,1,1,""],main:[0,1,1,""]},date:{"gau\u00dfsche_osterformel":[1,1,1,""],ascension_of_jesus:[1,1,1,""],easter_friday:[1,1,1,""],easter_monday:[1,1,1,""],easter_sunday:[1,1,1,""],pentecost:[1,1,1,""]},fit:{gauss:[2,1,1,""],gauss_fit:[2,1,1,""],main:[2,1,1,""]},geometry:{cubic:[3,1,1,""],cubic_deg:[3,1,1,""],line:[3,1,1,""],points:[3,1,1,""],rectangle:[3,1,1,""],rotate:[3,1,1,""],rotate_deg:[3,1,1,""],square:[3,1,1,""],translate:[3,1,1,""]},solver:{e1:[6,1,1,""],e2:[6,1,1,""],e4:[6,1,1,""],i1:[6,1,1,""],newmark_newtonraphson:[6,1,1,""],newmark_newtonraphson_rdk:[6,1,1,""]},solver_model:{disk:[7,1,1,""],disk_nm:[7,1,1,""],disk_nmmdk:[7,1,1,""]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"]},objtypes:{"0":"py:module","1":"py:function"},terms:{"1st":6,"1th":[],"2nd":6,"4th":6,"9fsche_osterformel":1,"default":[0,2,6],"f\u00fcr":1,"float":[2,3,6],"fr\u00fchling":1,"function":[0,2,6,7],"gau\u00dfsch":1,"gau\u00dfsche_osterformel":1,"int":[0,1,2,3,6],"korrekturgr\u00f6\u00df":1,"m\u00e4rz":1,"m\u00e4rzdatum":1,"return":[0,1,2,3],"s\u00e4kular":1,"s\u00e4kularzahl":1,"vorw\u00e4rt":6,Das:1,One:6,The:[3,6],against:6,algorithmu:1,als:1,amplitud:2,angl:3,angle1:3,angle2:3,approxim:[2,6],april:1,around:3,ascens:1,ascension_of_jesu:1,ascii:0,backward:6,becom:6,begin:6,beta:6,binari:0,bmatrix:6,bool:[0,2,6],calcul:[1,2],cauchi:6,center:3,choos:6,column:0,condit:6,counterclockwis:3,cubic:3,cubic_deg:3,dai:1,data:[2,5],data_load:0,data_read:0,data_stor:0,date:[3,5,6,7],datetim:1,datum:1,ddot:6,degre:3,den:1,der:1,deriv:7,des:1,describ:7,deviat:2,diamet:[6,7],die:1,differenti:[6,7],disk:7,disk_nm:7,disk_nmmdk:7,displac:6,distribut:2,dot:6,easter:1,easter_fridai:1,easter_mondai:1,easter_sundai:1,eccentr:7,edg:3,end:[3,6],entfernung:1,equat:[6,7],error:[2,6],ersten:1,euler:6,everi:6,exampl:6,expect:2,explicit:6,explizit:6,fals:[0,2,6],file:0,file_nam:0,filenam:0,first:[0,6,7],fit:5,float64:2,fnm:6,forward:6,fourth:6,frac:3,fridai:1,from:[0,6],full:2,fwhm:2,gamma:6,gau:1,gauss:2,gauss_fit:2,geometri:5,gilt:1,given:[2,3,6],global:6,govern:7,gregorianischen:1,half:2,has:6,height:3,http:1,implicit:6,index:[0,4],inform:[0,2,6],initi:[6,7],iter:6,jahr:1,jesu:1,kalend:1,kalendarisch:1,keim:1,kutta:6,kwarg:3,ldot:6,leftrightarrow:2,line:3,list:[0,2,6,7],load:0,local:6,main:[0,2],march:1,mathmat:7,mathrm:2,max_iter:6,maximum:[2,6],maxiter:6,mean:6,mechan:[],method:6,model:7,modul:[4,5],mondai:1,mondparamet:1,mondschaltung:1,ndarrai:2,newmark:6,newmark_newtonraphson:6,newmark_newtonraphson_rdk:6,none:2,number:[3,6],numer:6,numpi:2,object:[0,3],object_data:0,ode1back:[],offset:2,one:[3,6],option:3,order:[6,7],ordinari:[6,7],org:1,origin:3,osterentfernung:1,osterformel:1,ostergrenz:1,ostersonntag:1,other:3,page:4,param:[],paramet:[0,1,2,3,6,7],pentecost:1,per:6,point1:3,point1_i:3,point1_x:3,point2:3,point2_i:3,point2_x:3,point3:3,point4:3,point:3,point_i:3,point_x:3,points1_i:3,polygon:3,polygonzugverfahren:6,popt:2,posit:2,print:6,printmessg:[],problem:[6,7],program:0,proport:6,pts:3,quad:6,radian:3,read:0,rearrang:3,rectangl:3,residuum:6,rk2:[],rk4:[],rotat:[3,7],rotate_deg:3,rung:6,sampl:3,sample_point1_x:3,sample_point2_i:3,sample_point2_x:3,sample_points1_i:3,sche:6,search:4,second:[6,7],set:6,should:3,sigma:2,size:[3,6],slope:3,solut:6,solv:6,solver:5,solver_model:5,sonnenschaltung:1,sonntag:1,sourc:1,spacial:1,sqrt:2,squar:[3,6],stabl:6,standard:[2,6],step:6,store:0,str:0,sundai:1,system:[6,7],t_0:6,t_i:6,tagen:1,test:2,thick:6,time:[6,7],tol:6,toler:6,torqu:7,translat:3,tupl:[0,2,3],type:[0,1,2,3],used:2,usw:1,valu:[2,6,7],variabl:1,varianc:2,vec:3,vector:3,veloc:6,verbos:[0,2,6],verfahren:6,vertic:2,vollmond:1,von:1,where:2,which:6,width:[2,3],wiki:1,wikipedia:1,write:0,x_0:6,x_1:[3,6],x_2:[3,6],x_column:0,x_fit:2,x_i:6,xp0:6,xpn:7,xpp0:6,xppn:7,y_1:3,y_2:3,y_column:0,y_fit:2,year:1},titles:["data module","date module","fit module","geometry module","Welcome to pylib\u2019s documentation!","src","solver module","solver_model module"],titleterms:{data:0,date:1,document:4,fit:2,geometri:3,indic:4,modul:[0,1,2,3,6,7],pylib:4,solver:6,solver_model:7,src:5,tabl:4,welcom:4}})
|
||||
289
docs/build/html/solver.html
vendored
Normal file
289
docs/build/html/solver.html
vendored
Normal file
@@ -0,0 +1,289 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>solver module — pylib 2019.5.19 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="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-solver">
|
||||
<span id="solver-module"></span><h1>solver module<a class="headerlink" href="#module-solver" 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-solver"></span><dl class="function">
|
||||
<dt id="solver.e1">
|
||||
<code class="descname">e1</code><span class="sig-paren">(</span><em>f</em>, <em>x0</em>, <em>t</em>, <em>*p</em>, <em>verbose=False</em><span class="sig-paren">)</span><a class="headerlink" href="#solver.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:
|
||||
Euler’sche 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} &= f(t,x) \\
|
||||
x(t_0) &= 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>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} &= x_i + (t_{i+1}-t_i) f(t_i, x_i) \\
|
||||
x_{i+1} &= 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 &= u &\quad \dot{x}_1 = \dot{u} = x_2 \\
|
||||
x_2 &= \dot{u} &\quad \dot{x}_2 = \ddot{u} \\\end{split}\]</div>
|
||||
<p>becomes</p>
|
||||
<div class="math notranslate nohighlight">
|
||||
\[\begin{split}\dot{x}_1 &= x_2 \\
|
||||
\dot{x}_2 &= 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} &= f(t,x) \\
|
||||
\begin{bmatrix} \dot{x}_1 \\ \dot{x}_1 \end{bmatrix} &=
|
||||
\begin{bmatrix} x_2 \\ m^{-1}(f(t) - d x_2 - k x_1) \end{bmatrix} \\
|
||||
&=
|
||||
\begin{bmatrix} 0 \\ m^{-1} f(t) \end{bmatrix} +
|
||||
\begin{bmatrix} 0 & 1 \\ -m^{-1} k & -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 &= u &\quad \dot{x}_1 = \dot{u} = x_2 \\
|
||||
x_2 &= \dot{u} &\quad \dot{x}_2 = \ddot{u} \\\end{split}\]</div>
|
||||
<p>becomes</p>
|
||||
<div class="math notranslate nohighlight">
|
||||
\[\begin{split}\dot{x}_1 &= x_2 \\
|
||||
\dot{x}_2 &= 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} &= f(t,x) \\
|
||||
\begin{bmatrix} \dot{x}_1 \\ \dot{x}_2 \end{bmatrix} &=
|
||||
\begin{bmatrix} x_2 \\ m^{-1}(x_1)(f(t) - d(x_1,x_2) x_2 - k(x_1) x_1) \end{bmatrix} \\
|
||||
&=
|
||||
\begin{bmatrix} 0 \\ m^{-1}(x_1) f(t) \end{bmatrix} +
|
||||
\begin{bmatrix} 0 & 1 \\ -m^{-1}(x_1) k(x_1) & -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="solver.e2">
|
||||
<code class="descname">e2</code><span class="sig-paren">(</span><em>f</em>, <em>x0</em>, <em>t</em>, <em>*p</em>, <em>verbose=False</em><span class="sig-paren">)</span><a class="headerlink" href="#solver.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="solver.e4">
|
||||
<code class="descname">e4</code><span class="sig-paren">(</span><em>f</em>, <em>x0</em>, <em>t</em>, <em>*p</em>, <em>verbose=False</em><span class="sig-paren">)</span><a class="headerlink" href="#solver.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="solver.i1">
|
||||
<code class="descname">i1</code><span class="sig-paren">(</span><em>f</em>, <em>x0</em>, <em>t</em>, <em>*p</em>, <em>max_iterations=1000</em>, <em>tol=1e-09</em>, <em>verbose=False</em><span class="sig-paren">)</span><a class="headerlink" href="#solver.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="solver.newmark_newtonraphson">
|
||||
<code class="descname">newmark_newtonraphson</code><span class="sig-paren">(</span><em>f</em>, <em>x0</em>, <em>xp0</em>, <em>xpp0</em>, <em>t</em>, <em>*p</em>, <em>gamma=0.5</em>, <em>beta=0.25</em>, <em>max_iterations=1000</em>, <em>tol=1e-09</em>, <em>verbose=False</em><span class="sig-paren">)</span><a class="headerlink" href="#solver.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="solver.newmark_newtonraphson_rdk">
|
||||
<code class="descname">newmark_newtonraphson_rdk</code><span class="sig-paren">(</span><em>fnm</em>, <em>x0</em>, <em>xp0</em>, <em>xpp0</em>, <em>t</em>, <em>*p</em>, <em>gamma=0.5</em>, <em>beta=0.25</em>, <em>maxIterations=1000</em>, <em>tol=1e-09</em>, <em>verbose=False</em><span class="sig-paren">)</span><a class="headerlink" href="#solver.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>
|
||||
|
||||
<div class="relations">
|
||||
<h3>Related Topics</h3>
|
||||
<ul>
|
||||
<li><a href="index.html">Documentation overview</a><ul>
|
||||
</ul></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3>Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="search.html" method="get">
|
||||
<input type="text" name="q" />
|
||||
<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">
|
||||
©2019, Daniel Weschke.
|
||||
|
||||
|
|
||||
Powered by <a href="http://sphinx-doc.org/">Sphinx 2.0.1</a>
|
||||
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
||||
|
||||
|
|
||||
<a href="_sources/solver.rst.txt"
|
||||
rel="nofollow">Page source</a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
177
docs/build/html/solver_model.html
vendored
Normal file
177
docs/build/html/solver_model.html
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>solver_model module — pylib 2019.5.19 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="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-solver_model">
|
||||
<span id="solver-model-module"></span><h1>solver_model module<a class="headerlink" href="#module-solver_model" title="Permalink to this headline">¶</a></h1>
|
||||
<p>Mathmatical models governed by ordinary differential equations.</p>
|
||||
<p>Describes initial value problems as systems of first order ordinary differential
|
||||
equations.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Date</dt>
|
||||
<dd class="field-odd"><p>2019-05-25</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<span class="target" id="module-solver_model"></span><dl class="function">
|
||||
<dt id="solver_model.disk">
|
||||
<code class="descname">disk</code><span class="sig-paren">(</span><em>x</em>, <em>t</em>, <em>*p</em><span class="sig-paren">)</span><a class="headerlink" href="#solver_model.disk" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Rotation of an eccentric disk.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><ul class="simple">
|
||||
<li><p><strong>x</strong> (<em>list</em>) – values of the function</p></li>
|
||||
<li><p><strong>t</strong> (<em>list</em>) – time</p></li>
|
||||
<li><p><strong>*p</strong> – <p>parameters of the function</p>
|
||||
<ul>
|
||||
<li><p>diameter</p></li>
|
||||
<li><p>eccentricity</p></li>
|
||||
<li><p>torque</p></li>
|
||||
</ul>
|
||||
</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="solver_model.disk_nm">
|
||||
<code class="descname">disk_nm</code><span class="sig-paren">(</span><em>xn</em>, <em>xpn</em>, <em>xppn</em>, <em>t</em>, <em>*p</em><span class="sig-paren">)</span><a class="headerlink" href="#solver_model.disk_nm" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Rotation of an eccentric disk.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><ul class="simple">
|
||||
<li><p><strong>xn</strong> (<em>list</em>) – values of the function</p></li>
|
||||
<li><p><strong>xpn</strong> (<em>list</em>) – first derivative values of the function</p></li>
|
||||
<li><p><strong>xppn</strong> (<em>list</em>) – second derivative values of the function</p></li>
|
||||
<li><p><strong>t</strong> (<em>list</em>) – time</p></li>
|
||||
<li><p><strong>*p</strong> – <p>parameters of the function</p>
|
||||
<ul>
|
||||
<li><p>diameter</p></li>
|
||||
<li><p>eccentricity</p></li>
|
||||
<li><p>torque</p></li>
|
||||
</ul>
|
||||
</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="solver_model.disk_nmmdk">
|
||||
<code class="descname">disk_nmmdk</code><span class="sig-paren">(</span><em>xn</em>, <em>xpn</em>, <em>xppn</em>, <em>t</em>, <em>*p</em><span class="sig-paren">)</span><a class="headerlink" href="#solver_model.disk_nmmdk" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Rotation of an eccentric disk.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><ul class="simple">
|
||||
<li><p><strong>xn</strong> (<em>list</em>) – values of the function</p></li>
|
||||
<li><p><strong>xpn</strong> (<em>list</em>) – derivative values of the function</p></li>
|
||||
<li><p><strong>xppn</strong> (<em>list</em>) – second derivative values of the function</p></li>
|
||||
<li><p><strong>t</strong> (<em>list</em>) – time</p></li>
|
||||
<li><p><strong>*p</strong> – <p>parameters of the function</p>
|
||||
<ul>
|
||||
<li><p>diameter</p></li>
|
||||
<li><p>eccentricity</p></li>
|
||||
<li><p>torque</p></li>
|
||||
</ul>
|
||||
</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>
|
||||
|
||||
<div class="relations">
|
||||
<h3>Related Topics</h3>
|
||||
<ul>
|
||||
<li><a href="index.html">Documentation overview</a><ul>
|
||||
</ul></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3>Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="search.html" method="get">
|
||||
<input type="text" name="q" />
|
||||
<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">
|
||||
©2019, Daniel Weschke.
|
||||
|
||||
|
|
||||
Powered by <a href="http://sphinx-doc.org/">Sphinx 2.0.1</a>
|
||||
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
||||
|
||||
|
|
||||
<a href="_sources/solver_model.rst.txt"
|
||||
rel="nofollow">Page source</a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
119
docs/build/html/src.html
vendored
119
docs/build/html/src.html
vendored
@@ -1,119 +0,0 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>src package — pylib 2019.5.19 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>
|
||||
<link rel="index" title="Index" href="genindex.html" />
|
||||
<link rel="search" title="Search" href="search.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="src-package">
|
||||
<h1>src package<a class="headerlink" href="#src-package" title="Permalink to this headline">¶</a></h1>
|
||||
<div class="section" id="submodules">
|
||||
<h2>Submodules<a class="headerlink" href="#submodules" title="Permalink to this headline">¶</a></h2>
|
||||
</div>
|
||||
<div class="section" id="src-data-module">
|
||||
<h2>src.data module<a class="headerlink" href="#src-data-module" title="Permalink to this headline">¶</a></h2>
|
||||
</div>
|
||||
<div class="section" id="src-date-module">
|
||||
<h2>src.date module<a class="headerlink" href="#src-date-module" title="Permalink to this headline">¶</a></h2>
|
||||
</div>
|
||||
<div class="section" id="src-fit-module">
|
||||
<h2>src.fit module<a class="headerlink" href="#src-fit-module" title="Permalink to this headline">¶</a></h2>
|
||||
</div>
|
||||
<div class="section" id="src-geometry-module">
|
||||
<h2>src.geometry module<a class="headerlink" href="#src-geometry-module" title="Permalink to this headline">¶</a></h2>
|
||||
</div>
|
||||
<div class="section" id="module-contents">
|
||||
<h2>Module contents<a class="headerlink" href="#module-contents" title="Permalink to this headline">¶</a></h2>
|
||||
</div>
|
||||
</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>
|
||||
|
||||
<div class="relations">
|
||||
<h3>Related Topics</h3>
|
||||
<ul>
|
||||
<li><a href="index.html">Documentation overview</a><ul>
|
||||
</ul></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3>Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="search.html" method="get">
|
||||
<input type="text" name="q" />
|
||||
<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">
|
||||
©2019, Daniel Weschke.
|
||||
|
||||
|
|
||||
Powered by <a href="http://sphinx-doc.org/">Sphinx 2.0.1</a>
|
||||
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
||||
|
||||
|
|
||||
<a href="_sources/src.rst.txt"
|
||||
rel="nofollow">Page source</a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -76,4 +76,6 @@ html_theme_options = {
|
||||
'highlight_bg': '#444F65',
|
||||
'xref_bg': 'transparent',
|
||||
'xref_border': 'transparent',
|
||||
'seealso_bg': '#3c3c3c',
|
||||
'seealso_border': '#2C2C2C',
|
||||
}
|
||||
|
||||
@@ -8,3 +8,5 @@ src
|
||||
date
|
||||
fit
|
||||
geometry
|
||||
solver
|
||||
solver_model
|
||||
|
||||
7
docs/source/solver.rst
Normal file
7
docs/source/solver.rst
Normal file
@@ -0,0 +1,7 @@
|
||||
solver module
|
||||
=============
|
||||
|
||||
.. automodule:: solver
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
7
docs/source/solver_model.rst
Normal file
7
docs/source/solver_model.rst
Normal file
@@ -0,0 +1,7 @@
|
||||
solver\_model module
|
||||
====================
|
||||
|
||||
.. automodule:: solver_model
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
@@ -1,46 +0,0 @@
|
||||
src package
|
||||
===========
|
||||
|
||||
Submodules
|
||||
----------
|
||||
|
||||
src.data module
|
||||
---------------
|
||||
|
||||
.. automodule:: src.data
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
src.date module
|
||||
---------------
|
||||
|
||||
.. automodule:: src.date
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
src.fit module
|
||||
--------------
|
||||
|
||||
.. automodule:: src.fit
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
src.geometry module
|
||||
-------------------
|
||||
|
||||
.. automodule:: src.geometry
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
|
||||
Module contents
|
||||
---------------
|
||||
|
||||
.. automodule:: src
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
43
src/data.py
43
src/data.py
@@ -1,8 +1,29 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Read and write data to or from file.
|
||||
|
||||
.. module:: data
|
||||
:platform: *nix, Windows
|
||||
:synopsis: Handle data files.
|
||||
|
||||
.. moduleauthor:: Daniel Weschke <daniel.weschke@directbox.de>
|
||||
"""
|
||||
from __future__ import print_function
|
||||
import pickle
|
||||
|
||||
def data_read(file_name, x_column, y_column):
|
||||
"""read ascii data file"""
|
||||
"""Read ascii data file.
|
||||
|
||||
:param filename: file to read
|
||||
:type filename: str
|
||||
:param x_column: column index for the x data (first column is 0)
|
||||
:type x_column: int
|
||||
:param y_column: column index for the y data (first column is 0)
|
||||
:type y_column: int
|
||||
|
||||
:returns: x and y
|
||||
:rtype: tuple(list, list)
|
||||
"""
|
||||
import re
|
||||
file = open(file_name)
|
||||
x = []
|
||||
@@ -15,7 +36,16 @@ def data_read(file_name, x_column, y_column):
|
||||
return x, y
|
||||
|
||||
def data_load(file_name, verbose=False):
|
||||
"""load stored program objects from binary file"""
|
||||
"""Load stored program objects from binary file.
|
||||
|
||||
:param file_name: file to load
|
||||
:type file_name: str
|
||||
:param verbose: verbose information (default = False)
|
||||
:type verbose: bool
|
||||
|
||||
:returns: loaded data
|
||||
:rtype: object
|
||||
"""
|
||||
if verbose:
|
||||
print('check if data is available')
|
||||
try:
|
||||
@@ -31,11 +61,18 @@ def data_load(file_name, verbose=False):
|
||||
return object_data
|
||||
|
||||
def data_store(file_name, object_data):
|
||||
"""store program objects to binary file"""
|
||||
"""Store program objects to binary file.
|
||||
|
||||
:param file_name: file to store
|
||||
:type file_name: str
|
||||
:param object_data: data to store
|
||||
:type object_data: object
|
||||
"""
|
||||
with open(file_name, 'wb') as output:
|
||||
pickle.dump(object_data, output, pickle.HIGHEST_PROTOCOL) # every dump needs a load
|
||||
|
||||
def main():
|
||||
"""Main function."""
|
||||
file_name = "slit_test_scan.dat"
|
||||
x, y = data_read(file_name, 3, 2)
|
||||
print(x)
|
||||
|
||||
82
src/date.py
82
src/date.py
@@ -1,31 +1,51 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Mon Jan 15 21:52:34 2018
|
||||
"""Calculate spacial dates.
|
||||
|
||||
@author: Daniel Weschke
|
||||
:Date: 2018-01-15
|
||||
|
||||
.. module:: date
|
||||
:platform: *nix, Windows
|
||||
:synopsis: Special dates.
|
||||
|
||||
.. moduleauthor:: Daniel Weschke <daniel.weschke@directbox.de>
|
||||
"""
|
||||
from __future__ import division, print_function, unicode_literals
|
||||
|
||||
def gaußsche_osterformel(year):
|
||||
"""Gaußsche Osterformel.
|
||||
|
||||
:returns: int -- the day of Easter Sunday as a day in march.
|
||||
:param year: the year to calculate the Easter Sunday
|
||||
:type year: int
|
||||
|
||||
:returns: the day of Easter Sunday as a day in march.
|
||||
:rtype: int
|
||||
|
||||
:ivar X: Das Jahr / year
|
||||
:vartype X: int
|
||||
:ivar K(X): Die Säkularzahl
|
||||
:vartype K(X): int
|
||||
:ivar M(X): Die säkulare Mondschaltung
|
||||
:vartype M(X): int
|
||||
:ivar S(K): Die säkulare Sonnenschaltung
|
||||
:vartype S(K): int
|
||||
:ivar A(X): Den Mondparameter
|
||||
:vartype A(X): int
|
||||
:ivar D(A,M): Den Keim für den ersten Vollmond im Frühling
|
||||
:vartype D(A,M): int
|
||||
:ivar R(D,A): Die kalendarische Korrekturgröße
|
||||
:vartype R(D,A): int
|
||||
:ivar OG(D,R): Die Ostergrenze
|
||||
:vartype OG(D,R): int
|
||||
:ivar SZ(X,S): Den ersten Sonntag im März
|
||||
:vartype SZ(X,S): int
|
||||
:ivar OE(OG,SZ): Die Entfernung des Ostersonntags von der Ostergrenze (Osterentfernung in Tagen)
|
||||
:vartype OE(OG,SZ): int
|
||||
:ivar OS(OG,OE): Das Datum des Ostersonntags als Märzdatum (32. März = 1. April usw.)
|
||||
:vartype OS(OG,OE): int
|
||||
|
||||
Algorithmus gilt für den Gregorianischen Kalender.
|
||||
|
||||
* X -- Das Jahr / year
|
||||
* K(X) -- Die Säkularzahl
|
||||
* M(K) -- Die säkulare Mondschaltung
|
||||
* S(K) -- Die säkulare Sonnenschaltung
|
||||
* A(X) -- Den Mondparameter
|
||||
* D(A,M) -- Den Keim für den ersten Vollmond im Frühling
|
||||
* R(D,A) -- Die kalendarische Korrekturgröße
|
||||
* OG(D,R) -- Die Ostergrenze
|
||||
* SZ(X,S) -- Den ersten Sonntag im März
|
||||
* OE(OG,SZ) -- Die Entfernung des Ostersonntags von der Ostergrenze (Osterentfernung in Tagen)
|
||||
* OS(OG,OE) -- Das Datum des Ostersonntags als Märzdatum (32. März = 1. April usw.)
|
||||
|
||||
source: https://de.wikipedia.org/wiki/Gau%C3%9Fsche_Osterformel
|
||||
"""
|
||||
x = year
|
||||
@@ -44,7 +64,11 @@ def gaußsche_osterformel(year):
|
||||
def easter_sunday(year):
|
||||
"""Easter Sunday.
|
||||
|
||||
:returns: datetime.date -- the day of Easter Sunday"""
|
||||
:param year: the year to calculate the Easter Sunday
|
||||
:type year: int
|
||||
|
||||
:returns: the day of Easter Sunday
|
||||
:rtype: datetime.date"""
|
||||
import datetime
|
||||
march = datetime.date(year, 3, 1)
|
||||
day = march + datetime.timedelta(days=gaußsche_osterformel(year))
|
||||
@@ -53,7 +77,11 @@ def easter_sunday(year):
|
||||
def easter_friday(year):
|
||||
"""Easter Friday.
|
||||
|
||||
:returns: datetime.date -- the day of Easter Friday"""
|
||||
:param year: the year to calculate the Easter Friday
|
||||
:type year: int
|
||||
|
||||
:returns: the day of Easter Friday
|
||||
:rtype: datetime.date"""
|
||||
import datetime
|
||||
day = easter_sunday(year) + datetime.timedelta(days=-2)
|
||||
return day
|
||||
@@ -61,7 +89,11 @@ def easter_friday(year):
|
||||
def easter_monday(year):
|
||||
"""Easter Monday.
|
||||
|
||||
:returns: datetime.date -- the day of Easter Monday"""
|
||||
:param year: the year to calculate the Easter Monday
|
||||
:type year: int
|
||||
|
||||
:returns: the day of Easter Monday
|
||||
:rtype: datetime.date"""
|
||||
import datetime
|
||||
day = easter_sunday(year) + datetime.timedelta(days=+1)
|
||||
return day
|
||||
@@ -69,7 +101,11 @@ def easter_monday(year):
|
||||
def ascension_of_jesus(year):
|
||||
"""Ascension of Jesus.
|
||||
|
||||
:returns: datetime.date -- the day of ascension of Jesus"""
|
||||
:param year: the year to calculate the ascension of Jesus
|
||||
:type year: int
|
||||
|
||||
:returns: the day of ascension of Jesus
|
||||
:rtype: datetime.date"""
|
||||
import datetime
|
||||
day = easter_sunday(year) + datetime.timedelta(days=+39)
|
||||
return day
|
||||
@@ -77,7 +113,11 @@ def ascension_of_jesus(year):
|
||||
def pentecost(year):
|
||||
"""Pentecost.
|
||||
|
||||
:returns: datetime.date -- the day of Pentecost"""
|
||||
:param year: the year to calculate the Pentecost
|
||||
:type year: int
|
||||
|
||||
:returns: the day of Pentecost
|
||||
:rtype: datetime.date"""
|
||||
import datetime
|
||||
day = easter_sunday(year) + datetime.timedelta(days=+49)
|
||||
return day
|
||||
|
||||
48
src/fit.py
48
src/fit.py
@@ -1,3 +1,13 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Function and approximation.
|
||||
|
||||
.. module:: fit
|
||||
:platform: *nix, Windows
|
||||
:synopsis: Function and approximation.
|
||||
|
||||
.. moduleauthor:: Daniel Weschke <daniel.weschke@directbox.de>
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from pylab import array, argmax, subplot, plot, title, xlim, show, gradient, exp, sqrt, log, linspace
|
||||
from scipy.optimize import curve_fit
|
||||
@@ -6,15 +16,21 @@ from data import *
|
||||
def gauss(x, *p):
|
||||
"""Gauss distribution function.
|
||||
|
||||
.. math::
|
||||
f(x)=ae^{-(x-b)^{2}/(2c^{2})}
|
||||
|
||||
:param x: positions where the gauss function will be calculated
|
||||
:type x: int or float or list or numpy.ndarray
|
||||
:param p: gauss parameters [a, b, c, d]:
|
||||
|
||||
* a -- amplitude (integral = 1 if a = 1/(c*sqrt(2*pi)))
|
||||
* b -- expected value mu (position of maximum, default = 0)
|
||||
* c -- standard deviation sigma (variance sigma**2 = c**2)
|
||||
* a -- amplitude (:math:`\int y \\,\\mathrm{d}x=1 \Leftrightarrow a=1/(c\\sqrt{2\\pi})` )
|
||||
* b -- expected value :math:`\\mu` (position of maximum, default = 0)
|
||||
* c -- standard deviation :math:`\\sigma` (variance :math:`\\sigma^2=c^2`)
|
||||
* d -- vertical offset (default = 0)
|
||||
:type p: list
|
||||
|
||||
:returns: array -- gauss values at given positions x
|
||||
:returns: gauss values at given positions x
|
||||
:rtype: numpy.ndarray
|
||||
"""
|
||||
x = array(x) # cast e. g. list to numpy array
|
||||
a, b, c, d = p
|
||||
@@ -24,15 +40,27 @@ def gauss_fit(x, y, e=None, x_fit=None, verbose=False):
|
||||
"""Fit Gauss distribution function to data.
|
||||
|
||||
:param x: positions
|
||||
:type x: int or float or list or numpy.ndarray
|
||||
:param y: values
|
||||
:param e: error values
|
||||
:param x_fit: positions of fitted function (default steps is 3*len(x) but min 150)
|
||||
:type y: int or float or list or numpy.ndarray
|
||||
:param e: error values (default = None)
|
||||
:type e: int or float or list or numpy.ndarray
|
||||
:param x_fit: positions of fitted function (default = None, if None then x
|
||||
is used)
|
||||
:type x_fit: int or float or list or numpy.ndarray
|
||||
:param verbose: verbose information (default = False)
|
||||
:type verbose: bool
|
||||
|
||||
:returns:
|
||||
* y_fit -- values
|
||||
* popt -- parameters of gauss distribution function (amplitude a, expected
|
||||
value mu, standard deviation sigma, vertical offset d)
|
||||
* FWHM -- full width at half maximum
|
||||
* numpy.ndarray -- fitted values (y_fit)
|
||||
* numpy.ndarray -- parameters of gauss distribution function (popt:
|
||||
amplitude a, expected value :math:`\\mu`, standard deviation
|
||||
:math:`\\sigma`, vertical offset d)
|
||||
* numpy.float64 -- full width at half maximum (FWHM)
|
||||
:rtype: tuple
|
||||
|
||||
.. seealso::
|
||||
:meth:`gauss`
|
||||
"""
|
||||
x = array(x) # cast e. g. list to numpy array
|
||||
y = array(y) # cast e. g. list to numpy array
|
||||
|
||||
139
src/geometry.py
139
src/geometry.py
@@ -1,37 +1,46 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
2D
|
||||
"""2D geometry objects.
|
||||
|
||||
@date: 2019-03-21
|
||||
@author: Daniel Weschke
|
||||
:Date: 2019-03-21
|
||||
|
||||
.. module:: geometry
|
||||
:platform: *nix, Windows
|
||||
:synopsis: Geometry objects.
|
||||
|
||||
.. moduleauthor:: Daniel Weschke <daniel.weschke@directbox.de>
|
||||
"""
|
||||
import math
|
||||
import numpy as np
|
||||
|
||||
|
||||
def translate(vec, *pts):
|
||||
"""\
|
||||
Translate a point or polygon by a given vector.
|
||||
"""Translate a point or polygon by a given vector.
|
||||
|
||||
returns
|
||||
(point_x, point_y)
|
||||
or
|
||||
(point1, point2, ...)
|
||||
:param vec: translation vector
|
||||
:type vec: tuple
|
||||
:param `*pts`: points to translate
|
||||
|
||||
:returns: (point_x, point_y) or (point1, point2, ...)
|
||||
:rtype: tuple
|
||||
"""
|
||||
vx, vy = vec
|
||||
return tuple([(x+vx, y+vy) for (x, y) in pts])
|
||||
|
||||
|
||||
def rotate(origin, angle, *pts, **kwargs):
|
||||
"""\
|
||||
Rotate a point or polygon counterclockwise by a given angle around a given origin.
|
||||
"""Rotate a point or polygon counterclockwise by a given angle around a given
|
||||
origin. The angle should be given in radians.
|
||||
|
||||
The angle should be given in radians.
|
||||
:param origin: the center of rotation
|
||||
:type origin: tuple
|
||||
:param angle: the rotation angle
|
||||
:type angle: int or float
|
||||
:param `*pts`: points to rotate
|
||||
:param `**kwargs`: options
|
||||
|
||||
returns
|
||||
(point_x, point_y)
|
||||
or
|
||||
(point1, point2, ...)
|
||||
:returns: (point_x, point_y) or (point1, point2, ...)
|
||||
:rtype: tuple
|
||||
"""
|
||||
ox, oy = origin
|
||||
|
||||
@@ -50,23 +59,34 @@ def rotate(origin, angle, *pts, **kwargs):
|
||||
|
||||
|
||||
def rotate_deg(origin, angle, *pts, **kwargs):
|
||||
"""\
|
||||
Rotate a point or polygon counterclockwise by a given angle around a given origin.
|
||||
"""Rotate a point or polygon counterclockwise by a given angle around a given
|
||||
origin. The angle should be given in degrees.
|
||||
|
||||
The angle should be given in degrees.
|
||||
:param origin: the center of rotation
|
||||
:type origin: tuple
|
||||
:param angle: the rotation angle
|
||||
:type angle: int or float
|
||||
:param `*pts`: points to rotate
|
||||
:param `**kwargs`: options
|
||||
|
||||
returns
|
||||
(point_x, point_y)
|
||||
or
|
||||
(point1, point2, ...)
|
||||
:returns: (point_x, point_y) or (point1, point2, ...)
|
||||
:rtype: tuple
|
||||
|
||||
.. seealso::
|
||||
:meth:`rotate`
|
||||
"""
|
||||
return rotate(origin, angle*math.pi/180, *pts, **kwargs)
|
||||
|
||||
|
||||
def rectangle(width, height):
|
||||
"""\
|
||||
returns
|
||||
(point1, point2, point3, point4)
|
||||
:param width: the width of the rectangle
|
||||
:type width: int or float
|
||||
:param height: the height of the rectangle
|
||||
:type height: int or float
|
||||
|
||||
:returns: (point1, point2, point3, point4)
|
||||
:rtype: tuple
|
||||
"""
|
||||
pt1 = (-width/2, -height/2)
|
||||
pt2 = (width/2, -height/2)
|
||||
@@ -77,8 +97,14 @@ def rectangle(width, height):
|
||||
|
||||
def square(width):
|
||||
"""\
|
||||
returns
|
||||
(point1, point2, point3, point4)
|
||||
:param width: the edge size of the square
|
||||
:type width: int or float
|
||||
|
||||
:returns: (point1, point2, point3, point4)
|
||||
:rtype: tuple
|
||||
|
||||
.. seealso::
|
||||
:meth:`rectangle`
|
||||
"""
|
||||
return rectangle(width, width)
|
||||
|
||||
@@ -89,22 +115,30 @@ def square(width):
|
||||
|
||||
def points(*pts):
|
||||
"""\
|
||||
returns
|
||||
((point1_x, point2_x), (point1_y, point2_y), ...)
|
||||
:param `*pts`: points to rearrange
|
||||
|
||||
:returns: ((point1_x, point2_x), (point1_y, point2_y), ...)
|
||||
:rtype: tuple
|
||||
"""
|
||||
return zip(*pts)
|
||||
|
||||
|
||||
def line(point1, point2, samples=2):
|
||||
"""\
|
||||
samples: number of sampling points
|
||||
.. math::
|
||||
y = \\frac{y_2-y_1}{x_2-x_1}(x-x_1) + y_1
|
||||
|
||||
y = (y2-y1)/(x2-x1)*(x-x1) + y1
|
||||
:param point1: one end point
|
||||
:type point1: tuple
|
||||
:param point2: other end point
|
||||
:type point2: tuple
|
||||
:param samples: number of sampling points
|
||||
:type samples: int
|
||||
|
||||
returns
|
||||
((point1_x, point2_x), (points1_y, point2_y))
|
||||
or
|
||||
([sample_point1_x, sample_point2_x, ...], [sample_points1_y, sample_point2_y, ...])
|
||||
:returns: ((point1_x, point2_x), (points1_y, point2_y)) or
|
||||
([sample_point1_x, sample_point2_x, ...],
|
||||
[sample_points1_y, sample_point2_y, ...])
|
||||
:rtype: tuple
|
||||
"""
|
||||
p1x, p1y = point1
|
||||
p2x, p2y = point2
|
||||
@@ -122,8 +156,20 @@ def line(point1, point2, samples=2):
|
||||
|
||||
def cubic(point1, angle1, point2, angle2, samples=50):
|
||||
"""\
|
||||
returns
|
||||
([sample_point1_x, sample_point2_x, ...], [sample_points1_y, sample_point2_y, ...])
|
||||
:param point1: one end point
|
||||
:type point1: tuple
|
||||
:param angle1: the slope at the one end point
|
||||
:type angle1: int or float
|
||||
:param point2: other end point
|
||||
:type point2: tuple
|
||||
:param angle2: the slope at the other end point
|
||||
:type angle2: int or float
|
||||
:param samples: number of sampling points
|
||||
:type samples: int
|
||||
|
||||
:returns: ([sample_point1_x, sample_point2_x, ...],
|
||||
[sample_points1_y, sample_point2_y, ...])
|
||||
:rtype: tuple
|
||||
"""
|
||||
p1x, p1y = point1
|
||||
p2x, p2y = point2
|
||||
@@ -142,7 +188,20 @@ def cubic(point1, angle1, point2, angle2, samples=50):
|
||||
|
||||
def cubic_deg(point1, angle1, point2, angle2):
|
||||
"""\
|
||||
returns
|
||||
([sample_point1_x, sample_point2_x, ...], [sample_points1_y, sample_point2_y, ...])
|
||||
:param point1: one end point
|
||||
:type point1: tuple
|
||||
:param angle1: the slope at the one end point
|
||||
:type angle1: int or float
|
||||
:param point2: other end point
|
||||
:type point2: tuple
|
||||
:param angle2: the slope at the other end point
|
||||
:type angle2: int or float
|
||||
|
||||
:returns: ([sample_point1_x, sample_point2_x, ...],
|
||||
[sample_points1_y, sample_point2_y, ...])
|
||||
:rtype: tuple
|
||||
|
||||
.. seealso::
|
||||
:meth:`cubic`
|
||||
"""
|
||||
return cubic(point1, angle1 * math.pi/180, point2, angle2 * math.pi/180)
|
||||
|
||||
357
src/solver.py
Normal file
357
src/solver.py
Normal file
@@ -0,0 +1,357 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Numerical solver of ordinary differential equations.
|
||||
|
||||
Solves the initial value problem for systems of first order ordinary differential
|
||||
equations.
|
||||
|
||||
:Date: 2015-09-21
|
||||
|
||||
.. module:: solver
|
||||
:platform: *nix, Windows
|
||||
:synopsis: Numerical solver.
|
||||
|
||||
.. moduleauthor:: Daniel Weschke <daniel.weschke@directbox.de>
|
||||
"""
|
||||
|
||||
from __future__ import division, print_function
|
||||
from numpy import array, isnan, sum, zeros, dot
|
||||
from numpy.linalg import norm, inv
|
||||
|
||||
def e1(f, x0, t, *p, verbose=False):
|
||||
r"""Explicit first-order method /
|
||||
(standard, or forward) Euler method /
|
||||
Runge-Kutta 1st order method.
|
||||
|
||||
de:
|
||||
Euler'sche Polygonzugverfahren / explizite Euler-Verfahren /
|
||||
Euler-Cauchy-Verfahren / Euler-vorwärts-Verfahren
|
||||
|
||||
:param f: the function to solve
|
||||
:type f: function
|
||||
:param x0: initial condition
|
||||
:type x0: list
|
||||
:param t: time
|
||||
:type t: list
|
||||
:param `*p`: parameters of the function (thickness, diameter, ...)
|
||||
:param verbose: print information (default = False)
|
||||
:type verbose: bool
|
||||
|
||||
Approximate the solution of the initial value problem
|
||||
|
||||
.. math ::
|
||||
\dot{x} &= f(t,x) \\
|
||||
x(t_0) &= x_0
|
||||
|
||||
Choose a value h for the size of every step and set
|
||||
|
||||
.. math ::
|
||||
t_i = t_0 + i h ~,\quad i=1,2,\ldots,n
|
||||
|
||||
One step :math:`h` of the Euler method from :math:`t_i` to :math:`t_{i+1}` is
|
||||
|
||||
.. math ::
|
||||
x_{i+1} &= x_i + (t_{i+1}-t_i) f(t_i, x_i) \\
|
||||
x_{i+1} &= x_i + h f(t_i, x_i) \\
|
||||
|
||||
Example 1:
|
||||
|
||||
.. math ::
|
||||
m\ddot{u} + d\dot{u} + ku = f(t) \\
|
||||
\ddot{u} = m^{-1}(f(t) - d\dot{u} - ku) \\
|
||||
|
||||
with
|
||||
|
||||
.. math ::
|
||||
x_1 &= u &\quad \dot{x}_1 = \dot{u} = x_2 \\
|
||||
x_2 &= \dot{u} &\quad \dot{x}_2 = \ddot{u} \\
|
||||
|
||||
becomes
|
||||
|
||||
.. math ::
|
||||
\dot{x}_1 &= x_2 \\
|
||||
\dot{x}_2 &= m^{-1}(f(t) - d x_2 - k x_1) \\
|
||||
|
||||
or
|
||||
|
||||
.. math ::
|
||||
\dot{x} &= f(t,x) \\
|
||||
\begin{bmatrix} \dot{x}_1 \\ \dot{x}_1 \end{bmatrix} &=
|
||||
\begin{bmatrix} x_2 \\ m^{-1}(f(t) - d x_2 - k x_1) \end{bmatrix} \\
|
||||
&=
|
||||
\begin{bmatrix} 0 \\ m^{-1} f(t) \end{bmatrix} +
|
||||
\begin{bmatrix} 0 & 1 \\ -m^{-1} k & -m^{-1} d \end{bmatrix}
|
||||
\begin{bmatrix} x_1 \\ x_2 \end{bmatrix}
|
||||
|
||||
Example 2:
|
||||
|
||||
.. math ::
|
||||
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) \\
|
||||
|
||||
with
|
||||
|
||||
.. math ::
|
||||
x_1 &= u &\quad \dot{x}_1 = \dot{u} = x_2 \\
|
||||
x_2 &= \dot{u} &\quad \dot{x}_2 = \ddot{u} \\
|
||||
|
||||
becomes
|
||||
|
||||
.. math ::
|
||||
\dot{x}_1 &= x_2 \\
|
||||
\dot{x}_2 &= m^{-1}(x_1)(f(t) - d(x_1,x_2) x_2 - k(x_1) x_1) \\
|
||||
|
||||
or
|
||||
|
||||
.. math ::
|
||||
\dot{x} &= f(t,x) \\
|
||||
\begin{bmatrix} \dot{x}_1 \\ \dot{x}_2 \end{bmatrix} &=
|
||||
\begin{bmatrix} x_2 \\ m^{-1}(x_1)(f(t) - d(x_1,x_2) x_2 - k(x_1) x_1) \end{bmatrix} \\
|
||||
&=
|
||||
\begin{bmatrix} 0 \\ m^{-1}(x_1) f(t) \end{bmatrix} +
|
||||
\begin{bmatrix} 0 & 1 \\ -m^{-1}(x_1) k(x_1) & -m^{-1} d(x_1,x_2) \end{bmatrix}
|
||||
\begin{bmatrix} x_1 \\ x_2 \end{bmatrix}
|
||||
|
||||
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.
|
||||
"""
|
||||
x = zeros((len(t), len(x0))) # Preallocate array
|
||||
x[0,:] = x0 # Initial condition gives solution at t=0.
|
||||
for i in range(len(t)-1):
|
||||
Dt = t[i+1]-t[i]
|
||||
dxdt = array(f(x[i,:], t[i], *p))
|
||||
x[i+1,:] = x[i,:] + dxdt*Dt # Approximate solution at next value of x
|
||||
if verbose:
|
||||
print('Numerical integration of ODE using explicit first-order method (Euler / Runge-Kutta) was successful.')
|
||||
return x
|
||||
|
||||
def e2(f, x0, t, *p, verbose=False):
|
||||
r"""Explicit second-order method / Runge-Kutta 2nd order method.
|
||||
|
||||
:param f: the function to solve
|
||||
:type f: function
|
||||
:param x0: initial condition
|
||||
:type x0: list
|
||||
:param t: time
|
||||
:type t: list
|
||||
:param `*p`: parameters of the function (thickness, diameter, ...)
|
||||
:param verbose: print information (default = False)
|
||||
:type verbose: bool
|
||||
"""
|
||||
x = zeros((len(t), len(x0)))
|
||||
x[0,:] = x0 # initial condition
|
||||
for i in range(len(t)-1): # calculation loop
|
||||
Dt = t[i+1]-t[i]
|
||||
k_1 = array(f(x[i,:], t[i], *p))
|
||||
k_2 = array(f(x[i,:]+0.5*Dt*k_1, t[i]+0.5*Dt, *p))
|
||||
x[i+1,:] = x[i,:] + k_2*Dt # main equation
|
||||
if verbose:
|
||||
print('Numerical integration of ODE using explicit 2th-order method (Runge-Kutta) was successful.')
|
||||
return x
|
||||
|
||||
def e4(f, x0, t, *p, verbose=False):
|
||||
r"""Explicit fourth-order method / Runge-Kutta 4th order method.
|
||||
|
||||
:param f: the function to solve
|
||||
:type f: function
|
||||
:param x0: initial condition
|
||||
:type x0: list
|
||||
:param t: time
|
||||
:type t: list
|
||||
:param `*p`: parameters of the function (thickness, diameter, ...)
|
||||
:param verbose: print information (default = False)
|
||||
:type verbose: bool
|
||||
"""
|
||||
x = zeros((len(t), len(x0))) # Preallocate array
|
||||
x[0,:] = x0 # Initial condition gives solution at t=0.
|
||||
for i in range(len(t)-1): # calculation loop
|
||||
Dt = t[i+1]-t[i]
|
||||
k_1 = array(f(x[i,:], t[i], *p))
|
||||
k_2 = array(f(x[i,:]+0.5*Dt*k_1, t[i]+0.5*Dt, *p))
|
||||
k_3 = array(f(x[i,:]+0.5*Dt*k_2, t[i]+0.5*Dt, *p))
|
||||
k_4 = array(f(x[i,:]+k_3*Dt, t[i]+Dt, *p))
|
||||
x[i+1,:] = x[i,:] + 1./6*(k_1+2*k_2+2*k_3+k_4)*Dt # main equation
|
||||
if verbose:
|
||||
print('Numerical integration of ODE using explicit 4th-order method (Runge-Kutta) was successful.')
|
||||
return x
|
||||
|
||||
def i1(f, x0, t, *p, max_iterations=1000, tol=1e-9, verbose=False):
|
||||
r"""Implicite first-order method / backward Euler method.
|
||||
|
||||
:param f: the function to solve
|
||||
:type f: function
|
||||
:param x0: initial condition
|
||||
:type x0: list
|
||||
:param t: time
|
||||
:type t: list
|
||||
:param `*p`: parameters of the function (thickness, diameter, ...)
|
||||
:param max_iterations: maximum number of iterations
|
||||
:type max_iterations: int
|
||||
:param tol: tolerance against residuum (default = 1e-9)
|
||||
:type tol: float
|
||||
:param verbose: print information (default = False)
|
||||
:type verbose: bool
|
||||
|
||||
The backward Euler method has order one and is A-stable.
|
||||
"""
|
||||
iterations = zeros((len(t), 1))
|
||||
x = zeros((len(t), len(x0))) # Preallocate array
|
||||
x[0,:] = x0 # Initial condition gives solution at t=0.
|
||||
for i in range(len(t)-1):
|
||||
Dt = t[i+1]-t[i]
|
||||
x1 = x[i,:]
|
||||
for j in range(max_iterations): # fixed-point iteration
|
||||
dxdt = array(f(x1, t[i+1], *p))
|
||||
x11 = x[i,:] + dxdt*Dt # Approximate solution at next value of x
|
||||
residuum = norm(x11-x1)/norm(x11)
|
||||
x1 = x11
|
||||
if residuum < tol:
|
||||
break
|
||||
iterations[i] = j+1
|
||||
x[i+1,:] = x1
|
||||
if verbose:
|
||||
print('Numerical integration of ODE using implicite first-order method (Euler) was successful.')
|
||||
return x, iterations
|
||||
|
||||
def newmark_newtonraphson(f, x0, xp0, xpp0, t, *p, gamma=.5, beta=.25, max_iterations=1000, tol=1e-9, verbose=False):
|
||||
r"""Newmark method.
|
||||
|
||||
:param f: the function to solve
|
||||
:type f: function
|
||||
:param x0: initial condition
|
||||
:type x0: list
|
||||
:param xp0: initial condition
|
||||
:type xp0: list
|
||||
:param xpp0: initial condition
|
||||
:type xpp0: list
|
||||
:param t: time
|
||||
:type t: list
|
||||
:param `*p`: parameters of the function (thickness, diameter, ...)
|
||||
:param gamma: newmark parameter for velocity (default = 0.5)
|
||||
:type gamma: float
|
||||
:param beta: newmark parameter for displacement (default = 0.25)
|
||||
:type beta: float
|
||||
:param max_iterations: maximum number of iterations
|
||||
:type max_iterations: int
|
||||
:param tol: tolerance against residuum (default = 1e-9)
|
||||
:type tol: float
|
||||
:param verbose: print information (default = False)
|
||||
:type verbose: bool
|
||||
"""
|
||||
iterations = zeros((len(t), 1))
|
||||
x = zeros((len(t), len(x0))) # Preallocate array
|
||||
xp = zeros((len(t), len(xp0))) # Preallocate array
|
||||
xpp = zeros((len(t), len(xpp0))) # Preallocate array
|
||||
x[0,:] = x0 # Initial condition gives solution at t=0.
|
||||
xp[0,:] = xp0 # Initial condition gives solution at t=0.
|
||||
xpp[0,:] = xpp0 # Initial condition gives solution at t=0.
|
||||
for i in range(len(t)-1):
|
||||
Dt = t[i+1]-t[i]
|
||||
|
||||
xi = x[i,:].reshape(3,1)
|
||||
xpi = xp[i,:].reshape(3,1)
|
||||
xppi = xpp[i,:].reshape(3,1)
|
||||
x1 = xi
|
||||
xp1 = xpi
|
||||
xpp1 = xppi
|
||||
j = 0
|
||||
for j in range(max_iterations): # fixed-point iteration
|
||||
#dxdt = array(f(t[i+1], x1, p))
|
||||
#x11 = x[i,:] + dxdt*Dt # Approximate solution at next value of x
|
||||
|
||||
N, dN, dNp, dNpp = f(x1.reshape(-1,).tolist(),
|
||||
xp1.reshape(-1,).tolist(), xpp1.reshape(-1,).tolist(),
|
||||
t[i], *p)
|
||||
if isnan(sum(dN)) or isnan(sum(dNp)) or isnan(sum(dNpp)):
|
||||
print('divergiert')
|
||||
break
|
||||
|
||||
xpp11 = xpp1 - dot(inv(dNpp), (N + dot(dN, (x1-xi)) + dot(dNp, (xp1-xpi))))
|
||||
xp1 = xpi + Dt*( (1-gamma)*xppi + gamma*xpp11 )
|
||||
x1 = xi + Dt*xpi + Dt**2*( (.5-beta)*xppi + beta*xpp11 )
|
||||
|
||||
residuum = norm(xpp11-xpp1)/norm(xpp11)
|
||||
xpp1 = xpp11
|
||||
if residuum < tol:
|
||||
break
|
||||
iterations[i] = j+1
|
||||
|
||||
xpp[i+1,:] = xpp1.reshape(-1,).tolist()
|
||||
xp[i+1,:] = xp1.reshape(-1,).tolist()
|
||||
x[i+1,:] = x1.reshape(-1,).tolist()
|
||||
if verbose:
|
||||
print('Numerical integration of ODE using explicite newmark method was successful.')
|
||||
return x, xp, xpp, iterations
|
||||
# x = concatenate((x, xp, xpp), axis=1)
|
||||
|
||||
def newmark_newtonraphson_rdk(fnm, x0, xp0, xpp0, t, *p, gamma=.5, beta=.25, maxIterations=1000, tol=1e-9, verbose=False):
|
||||
r"""Newmark method.
|
||||
|
||||
:param f: the function to solve
|
||||
:type f: function
|
||||
:param x0: initial condition
|
||||
:type x0: list
|
||||
:param xp0: initial condition
|
||||
:type xp0: list
|
||||
:param xpp0: initial condition
|
||||
:type xpp0: list
|
||||
:param t: time
|
||||
:type t: list
|
||||
:param `*p`: parameters of the function (thickness, diameter, ...)
|
||||
:param gamma: newmark parameter for velocity (default = 0.5)
|
||||
:type gamma: float
|
||||
:param beta: newmark parameter for displacement (default = 0.25)
|
||||
:type beta: float
|
||||
:param max_iterations: maximum number of iterations
|
||||
:type max_iterations: int
|
||||
:param tol: tolerance against residuum (default = 1e-9)
|
||||
:type tol: float
|
||||
:param verbose: print information (default = False)
|
||||
:type verbose: bool
|
||||
"""
|
||||
iterations = zeros((len(t), 1))
|
||||
x = zeros((len(t), len(x0))) # Preallocate array
|
||||
xp = zeros((len(t), len(xp0))) # Preallocate array
|
||||
xpp = zeros((len(t), len(xpp0))) # Preallocate array
|
||||
x[0,:] = x0 # Initial condition gives solution at t=0.
|
||||
xp[0,:] = xp0 # Initial condition gives solution at t=0.
|
||||
xpp[0,:] = xpp0 # Initial condition gives solution at t=0.
|
||||
for i in range(len(t)-1):
|
||||
Dt = t[i+1]-t[i]
|
||||
|
||||
rm, rmx, rmxpp, rd, rdx, rdxp, rk, rkx, f = fnm(x[i,:], xp[i,:], xpp[i,:], t[i], *p)
|
||||
|
||||
xi = x[i,:].reshape(3,1)
|
||||
xpi = xp[i,:].reshape(3,1)
|
||||
xppi = xpp[i,:].reshape(3,1)
|
||||
x1 = xi
|
||||
xp1 = xpi
|
||||
xpp1 = xppi
|
||||
j = 0
|
||||
for j in range(maxIterations): # fixed-point iteration
|
||||
#dxdt = array(f(t[i+1], x1, p))
|
||||
#x11 = x[i,:] + dxdt*Dt # Approximate solution at next value of x
|
||||
|
||||
r = (rmx+rdx+rkx)*Dt**2./4 + rdxp*Dt/2 + rmxpp
|
||||
rp = f - (rm + dot(rmx, (Dt*xpi+Dt**2./4*xppi)) - dot(rmxpp, xppi) + \
|
||||
rd + dot(rdx, (Dt*xpi+Dt**2./4*xppi)) + dot(rdxp, Dt/2*xppi) + \
|
||||
rk + dot(rkx, (Dt*xpi+Dt**2./4*xppi)) )
|
||||
xpp11 = dot(inv(r), rp)
|
||||
xp1 = xpi + Dt*( (1-gamma)*xppi + gamma*xpp11 )
|
||||
x1 = xi + Dt*xpi + Dt**2*( (.5-beta)*xppi + beta*xpp11 )
|
||||
|
||||
residuum = norm(xpp11-xpp1)/norm(xpp11)
|
||||
xpp1 = xpp11
|
||||
if residuum < tol:
|
||||
break
|
||||
iterations[i] = j+1
|
||||
|
||||
xpp[i+1,:] = xpp1.reshape(-1,).tolist()
|
||||
xp[i+1,:] = xp1.reshape(-1,).tolist()
|
||||
x[i+1,:] = x1.reshape(-1,).tolist()
|
||||
if verbose:
|
||||
print('Numerical integration of ODE using explicite newmark method was successful.')
|
||||
return x, xp, xpp, iterations
|
||||
# x = concatenate((x, xp, xpp), axis=1)
|
||||
120
src/solver_model.py
Normal file
120
src/solver_model.py
Normal file
@@ -0,0 +1,120 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Mathmatical models governed by ordinary differential equations.
|
||||
|
||||
Describes initial value problems as systems of first order ordinary differential
|
||||
equations.
|
||||
|
||||
:Date: 2019-05-25
|
||||
|
||||
.. module:: solver_model
|
||||
:platform: *nix, Windows
|
||||
:synopsis: Mechanical models.
|
||||
|
||||
.. moduleauthor:: Daniel Weschke <daniel.weschke@directbox.de>
|
||||
"""
|
||||
from __future__ import division, print_function
|
||||
from numpy import array, cos, sin, dot, square
|
||||
from numpy.linalg import inv
|
||||
|
||||
def disk(x, t, *p):
|
||||
"""Rotation of an eccentric disk.
|
||||
|
||||
:param x: values of the function
|
||||
:type x: list
|
||||
:param t: time
|
||||
:type t: list
|
||||
:param `*p`: parameters of the function
|
||||
|
||||
* diameter
|
||||
* eccentricity
|
||||
* torque
|
||||
"""
|
||||
qp1 = x[3]
|
||||
qp2 = x[4]
|
||||
qp3 = x[5]
|
||||
M = array([[1, 0, cos(x[2])], [0, 1, -sin(x[2])], [0, 0, 1]])
|
||||
y = array([[-2*p[0]*x[3]+sin(x[2])*x[5]**2-2*p[0]*cos(x[2])*x[5]-x[0]], \
|
||||
[-2*p[0]*x[4]+cos(x[2])*x[5]**2-2*p[0]*sin(x[2])*x[5]-x[1]], \
|
||||
[p[2]-p[1]*x[1]*sin(x[2])+p[1]*x[0]*cos(x[2])]])
|
||||
qp46 = dot(inv(M), y)
|
||||
qp4, qp5, qp6 = qp46.reshape(-1,).tolist() # 2d array to 1d array to list
|
||||
return qp1, qp2, qp3, qp4, qp5, qp6
|
||||
|
||||
def disk_nm(xn, xpn, xppn, t, *p):
|
||||
"""Rotation of an eccentric disk.
|
||||
|
||||
:param xn: values of the function
|
||||
:type xn: list
|
||||
:param xpn: first derivative values of the function
|
||||
:type xpn: list
|
||||
:param xppn: second derivative values of the function
|
||||
:type xppn: list
|
||||
:param t: time
|
||||
:type t: list
|
||||
:param `*p`: parameters of the function
|
||||
|
||||
* diameter
|
||||
* eccentricity
|
||||
* torque
|
||||
"""
|
||||
N = array([[xppn[0]+cos(xn[2])*xppn[2]+2*p[0]*xpn[0]+2*p[0]*cos(xn[2])*xpn[2]-sin(xn[2])*square(xpn[2])+xn[0]],
|
||||
[xppn[1]-sin(xn[2])*xppn[2]+2*p[0]*xpn[1]-2*p[0]*sin(xn[2])*xpn[2]-cos(xn[2])*square(xpn[2])+xn[1]],
|
||||
[xppn[2]+p[1]*(-cos(xn[2])*xn[0]+sin(xn[2])*xn[1])-p[2]]])
|
||||
dN = array([[1, 0, -sin(xn[2]*xppn[2])-2*p[0]*sin(xn[2])*xpn[2]-cos(xn[2])*square(xpn[2])],
|
||||
[0, 1, -cos(xn[2]*xppn[2])-2*p[0]*cos(xn[2])*xpn[2]+sin(xn[2])*square(xpn[2])],
|
||||
[-p[1]*cos(xn[2]), p[1]*cos(xn[2]), p[1]*(sin(xn[2])*xn[0]+cos(xn[2])*xn[1])]])
|
||||
dNp = array([[2*p[0], 0, 2*p[0]*cos(xn[2])-2*sin(xn[2])*xpn[2]],
|
||||
[0, 2*p[0], -2*p[0]*sin(xn[2])-2*cos(xn[2])*xpn[2]],
|
||||
[0, 0, 0]])
|
||||
dNpp = array([[1, 0, cos(xn[2])],
|
||||
[0, 1, -sin(xn[2])],
|
||||
[0, 0, 1]])
|
||||
return N, dN, dNp, dNpp
|
||||
|
||||
def disk_nmmdk(xn, xpn, xppn, t, *p):
|
||||
"""Rotation of an eccentric disk.
|
||||
|
||||
:param xn: values of the function
|
||||
:type xn: list
|
||||
:param xpn: derivative values of the function
|
||||
:type xpn: list
|
||||
:param xppn: second derivative values of the function
|
||||
:type xppn: list
|
||||
:param t: time
|
||||
:type t: list
|
||||
:param `*p`: parameters of the function
|
||||
|
||||
* diameter
|
||||
* eccentricity
|
||||
* torque
|
||||
"""
|
||||
rm = array([[xppn[0]+cos(xn[2])*xppn[2]],
|
||||
[xppn[1]-sin(xn[2])*xppn[2]],
|
||||
[xppn[2]]])
|
||||
rmx = array([[0, 0, -sin(xn[2]*xppn[2])],
|
||||
[0, 0, -cos(xn[2]*xppn[2])],
|
||||
[0, 0, 0]])
|
||||
rmxpp = array([[1, 0, cos(xn[2])],
|
||||
[0, 1, -sin(xn[2])],
|
||||
[0, 0, 1]])
|
||||
rd = array([[2*p[0]*xpn[0]+2*p[0]*cos(xn[2])*xpn[2]-sin(xn[2])*square(xpn[2])],
|
||||
[2*p[0]*xpn[1]-2*p[0]*sin(xn[2])*xpn[2]-cos(xn[2])*square(xpn[2])],
|
||||
[0]])
|
||||
rdx = array([[0, 0, -2*p[0]*sin(xn[2])*xpn[2]-cos(xn[2])*square(xpn[2])],
|
||||
[0, 0, -2*p[0]*cos(xn[2])*xpn[2]+sin(xn[2])*square(xpn[2])],
|
||||
[0, 0, 0]])
|
||||
rdxp = array([[2*p[0], 0, 2*p[0]*cos(xn[2])-2*sin(xn[2])*xpn[2]],
|
||||
[0, 2*p[0], -2*p[0]*sin(xn[2])-2*cos(xn[2])*xpn[2]],
|
||||
[0, 0, 0]])
|
||||
rk = array([[xn[0]],
|
||||
[xn[1]],
|
||||
[p[1]*(-cos(xn[2])*xn[0]+sin(xn[2])*xn[1])]])
|
||||
rkx = array([[ 1, 0, 0],
|
||||
[ 0, 1, 0],
|
||||
[-p[1]*cos(xn[2]), p[1]*cos(xn[2]), p[1]*(sin(xn[2])*xn[0]+cos(xn[2])*xn[1])]])
|
||||
f = array([[0], [0], [p[2]]])
|
||||
return rm, rmx, rmxpp, rd, rdx, rdxp, rk, rkx, f
|
||||
|
||||
if __name__ == '__main__':
|
||||
0
|
||||
16
tests/test_fit.py
Normal file
16
tests/test_fit.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import unittest
|
||||
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, os.path.abspath('../src'))
|
||||
import fit
|
||||
|
||||
|
||||
class TestFit(unittest.TestCase):
|
||||
|
||||
def test_property(self):
|
||||
self.assertEqual()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
201
tests/test_solver.py
Normal file
201
tests/test_solver.py
Normal file
@@ -0,0 +1,201 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Numerical solver.
|
||||
|
||||
:Date: 2019-05-25
|
||||
|
||||
.. module:: solver
|
||||
:platform: *nix, Windows
|
||||
:synopsis: Numerical solver.
|
||||
|
||||
.. moduleauthor:: Daniel Weschke <daniel.weschke@directbox.de>
|
||||
"""
|
||||
from __future__ import division, print_function
|
||||
import unittest
|
||||
import math
|
||||
from numpy import linspace, allclose
|
||||
from numpy.linalg import inv
|
||||
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, os.path.abspath('../src'))
|
||||
import solver
|
||||
import solver_model
|
||||
|
||||
#### Post processing
|
||||
from matplotlib.pyplot import figure, subplots, plot, show
|
||||
from numpy import sqrt, square, concatenate
|
||||
|
||||
def plotx1rphi(x, t, title):
|
||||
"""Plot plane rotation (x, y, phi)
|
||||
"""
|
||||
x1 = x[:, 0]
|
||||
x2 = x[:, 1]
|
||||
x3 = x[:, 2]
|
||||
xp1 = x[:, 3]
|
||||
xp2 = x[:, 4]
|
||||
xp3 = x[:, 5]
|
||||
fig, ax1 = subplots()
|
||||
ax1.set_title(title)
|
||||
ax1.plot(t, x1, 'b-')
|
||||
#ax1.plot(t, x3, 'b-')
|
||||
ax1.set_xlabel('time t in s')
|
||||
# Make the y-axis label and tick labels match the line color.
|
||||
ax1.set_ylabel('x_1', color='b')
|
||||
for tl in ax1.get_yticklabels():
|
||||
tl.set_color('b')
|
||||
envelope = sqrt(square(x1)+square(x2))
|
||||
ax1.plot(t, envelope, 'b--', t, -envelope, 'b--')
|
||||
ax2 = ax1.twinx()
|
||||
ax2.plot(t, xp3, 'r')
|
||||
ax2.set_ylabel('phi', color='r')
|
||||
for tl in ax2.get_yticklabels():
|
||||
tl.set_color('r')
|
||||
if max(xp3) < 2:
|
||||
ax2.set_ylim([0,2])
|
||||
|
||||
f = solver_model.disk
|
||||
fnm = solver_model.disk_nm
|
||||
fnmmdk = solver_model.disk_nmmdk
|
||||
|
||||
|
||||
class TestSolver(unittest.TestCase):
|
||||
|
||||
Dt = .01 # Delta t
|
||||
tend = .1 # t_end
|
||||
#tend = 300
|
||||
nt = math.ceil(tend/Dt) # number of timesteps
|
||||
t = linspace(0., tend, nt+1) # time vector
|
||||
x0 = 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 # initial conditions
|
||||
p = .01, .002, .015 # parameter of the model
|
||||
|
||||
def test_e1(self):
|
||||
xe1 = solver.e1(f, self.x0, self.t, *self.p)
|
||||
#plotx1rphi(xe1, self.t, ("Euler (Runge-Kutta 1th order), increments: %d" % self.nt))
|
||||
#show()
|
||||
self.assertTrue(allclose(xe1[:, 5],
|
||||
[0., 0.00015, 0.0003, 0.00045, 0.0006, 0.00075, 0.0009, 0.00105, 0.0012,
|
||||
0.00135, 0.0015 ]))
|
||||
|
||||
Dt_2 = Dt/5.
|
||||
nt_2 = math.ceil(tend/Dt_2)
|
||||
t_2 = linspace(0., tend, nt_2+1)
|
||||
|
||||
def test_e1_2(self):
|
||||
xe1_2 = solver.e1(f, self.x0, self.t_2, *self.p)
|
||||
#plotx1rphi(xe1_2, self.t_2, ("Euler (Runge-Kutta 1th order), increments: %d" % self.nt_2))
|
||||
#show()
|
||||
self.assertTrue(allclose(xe1_2[:, 5],
|
||||
[0.00000000e+00, 3.00000000e-05, 6.00000000e-05, 8.99999998e-05,
|
||||
1.19999999e-04, 1.49999998e-04, 1.79999995e-04, 2.09999992e-04,
|
||||
2.39999987e-04, 2.69999980e-04, 2.99999971e-04, 3.29999960e-04,
|
||||
3.59999947e-04, 3.89999931e-04, 4.19999913e-04, 4.49999891e-04,
|
||||
4.79999866e-04, 5.09999837e-04, 5.39999804e-04, 5.69999767e-04,
|
||||
5.99999726e-04, 6.29999681e-04, 6.59999630e-04, 6.89999575e-04,
|
||||
7.19999514e-04, 7.49999448e-04, 7.79999376e-04, 8.09999298e-04,
|
||||
8.39999214e-04, 8.69999123e-04, 8.99999026e-04, 9.29998921e-04,
|
||||
9.59998810e-04, 9.89998691e-04, 1.01999856e-03, 1.04999843e-03,
|
||||
1.07999829e-03, 1.10999814e-03, 1.13999798e-03, 1.16999781e-03,
|
||||
1.19999763e-03, 1.22999744e-03, 1.25999725e-03, 1.28999704e-03,
|
||||
1.31999682e-03, 1.34999660e-03, 1.37999636e-03, 1.40999611e-03,
|
||||
1.43999585e-03, 1.46999558e-03, 1.49999530e-03]
|
||||
))
|
||||
|
||||
maxIterations = 1000
|
||||
tol = 1e-9 # against residuum
|
||||
|
||||
def test_e2(self):
|
||||
xe2 = solver.e2(f, self.x0, self.t, *self.p)
|
||||
#plotx1rphi(xe2, self.t, ("Runge-Kutta 2th order, increments: %d" % self.nt))
|
||||
#show()
|
||||
self.assertTrue(allclose(xe2[:, 5],
|
||||
[0., 0.00015, 0.0003, 0.00045, 0.0006, 0.00075, 0.0009, 0.00105, 0.0012,
|
||||
0.00135, 0.0015 ]))
|
||||
|
||||
def test_e4(self):
|
||||
xe4 = solver.e4(f, self.x0, self.t, *self.p)
|
||||
#plotx1rphi(xe4, self.t, ("Runge-Kutta 4th order, increments: %d" % self.nt))
|
||||
#show()
|
||||
self.assertTrue(allclose(xe4[:, 5],
|
||||
[0., 0.00015, 0.0003, 0.00045, 0.0006, 0.00075, 0.0009, 0.00105, 0.0012,
|
||||
0.00135, 0.0015 ]))
|
||||
|
||||
def test_i1(self):
|
||||
xi1, iterations = solver.i1(f, self.x0, self.t, *self.p, self.maxIterations, self.tol)
|
||||
#plotx1rphi(xi1, self.t, ("Backward Euler, increments: %d, iterations: %d" % (self.nt, sum(iterations))))
|
||||
#show()
|
||||
self.assertTrue(allclose(xi1[:, 5],
|
||||
[0., 0.00015, 0.0003, 0.00045, 0.0006, 0.00075, 0.0009, 0.00105, 0.0012,
|
||||
0.00135, 0.0015 ]))
|
||||
|
||||
gamma = .5 # newmark parameter for velocity
|
||||
beta = .25 # newmark parameter for displacement
|
||||
|
||||
def test_nm(self):
|
||||
xnm, xpnm, xppnm, iterations = solver.newmark_newtonraphson(fnm,
|
||||
(0,0,0), (0,0,0), (0,0,0), self.t, *self.p,
|
||||
self.gamma, self.beta, 1, self.tol)
|
||||
#print(xnm)
|
||||
#print(xpnm)
|
||||
x = concatenate((xnm, xpnm), axis=1)
|
||||
#plotx1rphi(x, self.t, ("Newmark, increments: %d, iterations: %d" % (self.nt, sum(iterations))))
|
||||
#show()
|
||||
self.assertTrue(allclose(x[:, 5],
|
||||
[0.00000000e+00, 7.49999925e-05, 2.24999951e-04, 3.74999839e-04,
|
||||
5.24999621e-04, 6.74999269e-04, 8.24998752e-04, 9.74998039e-04,
|
||||
1.12499710e-03, 1.27499591e-03, 1.42499444e-03]
|
||||
))
|
||||
|
||||
def test_nm_2(self):
|
||||
xnm, xpnm, xppnm, iterations = solver.newmark_newtonraphson(fnm,
|
||||
(0,0,0), (0,0,0), (0,0,0), self.t, *self.p,
|
||||
self.gamma, self.beta, self.maxIterations, self.tol)
|
||||
#print(xnm)
|
||||
#print(xpnm)
|
||||
x = concatenate((xnm, xpnm), axis=1)
|
||||
#plotx1rphi(x, self.t, ("Newmark, increments: %d, iterations: %d" % (self.nt, sum(iterations))))
|
||||
#show()
|
||||
self.assertTrue(allclose(x[:, 5],
|
||||
[0.00000000e+00, 7.49999925e-05, 2.24999951e-04, 3.74999839e-04,
|
||||
5.24999621e-04, 6.74999269e-04, 8.24998752e-04, 9.74998039e-04,
|
||||
1.12499710e-03, 1.27499591e-03, 1.42499444e-03]
|
||||
))
|
||||
|
||||
def test_nmmdk(self):
|
||||
xnm, xpnm, xppnm, iterations = solver.newmark_newtonraphson_rdk(fnmmdk,
|
||||
(0,0,0), (0,0,0), (0,0,0), self.t, *self.p,
|
||||
self.gamma, self.beta, 1, self.tol)
|
||||
#print(xnm)
|
||||
#print(xpnm)
|
||||
x = concatenate((xnm, xpnm), axis=1)
|
||||
#plotx1rphi(x, self.t, ("Newmark, increments: %d, iterations: %d" % (self.nt, sum(iterations))))
|
||||
#show()
|
||||
self.assertTrue(allclose(x[:, 5],
|
||||
[0.00000000e+00, 7.49999963e-05, 2.24999974e-04, 3.74999906e-04,
|
||||
5.24999764e-04, 6.74999516e-04, 8.24999134e-04, 9.74998586e-04,
|
||||
1.12499784e-03, 1.27499688e-03, 1.42499566e-03]
|
||||
))
|
||||
|
||||
def test_nmmdk_2(self):
|
||||
xnm, xpnm, xppnm, iterations = solver.newmark_newtonraphson_rdk(fnmmdk,
|
||||
(0,0,0), (0,0,0), (0,0,0), self.t, *self.p,
|
||||
self.gamma, self.beta, 100, self.tol)
|
||||
#print(xnm)
|
||||
#print(xpnm)
|
||||
x = concatenate((xnm, xpnm), axis=1)
|
||||
#plotx1rphi(x, self.t, ("Newmark, increments: %d, iterations: %d" % (self.nt, sum(iterations))))
|
||||
#show()
|
||||
self.assertTrue(allclose(x[:, 5],
|
||||
[0.00000000e+00, 7.49999963e-05, 2.24999974e-04, 3.74999906e-04,
|
||||
5.24999764e-04, 6.74999516e-04, 8.24999134e-04, 9.74998586e-04,
|
||||
1.12499784e-03, 1.27499688e-03, 1.42499566e-03]
|
||||
))
|
||||
|
||||
#from scipy.integrate import odeint
|
||||
#xode = odeint(solver_model.disk, x0, t, p, printmessg=True)
|
||||
#plotx1rphi(xode, t, ("ODE, Inkremente: %d" % nt))
|
||||
#show()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user