change data, mathematics, function, geometry and geometry_plot_pylab. add data_step, data_step_std and helper. add an example and more documentation.

inside the data module rename read to read_columns add add new read function to read the whole file as string. add print_list function to print one element per line. add unique_list and unique_list_hashable to reduce the list into a unique list with same order. add find_last, str_between, str_to_list functions.

inside the mathematics module for vector add normalized creating a new object (normalize will change the object), isclose and iscloseto, change ang to round internal number. for matrix improve slicing and add transposed creating a new object (transpose will change object).

inside the function module add b_spline_basis, b_spline_curve_with_knots and b_spline_knots functions. add sample_hal_open and sample_half_open_seq. add circle and ellipse.

inside the geometry module change CS init from using lists to Directions and add new constructor CS.init_xzy using lists. rename Wireframe to Polyline. add classes B_spline_curve_with_knots, Ellipse, ArcCircle, ArcEllipse, ArcBSplineCurveWithKnots. add function sample_half_open to create a list of Points.

inside the geometry_plot_pylab module change the help text.

add step_and data data_step_std module to read a step file to list and draw the content.

add helper module with context manager and decorator timeit to meassure the time for a section or function.

add example for b_spline function.
This commit is contained in:
2020-01-08 21:59:53 +01:00
parent 4b42d7b508
commit 4fc4903dc2
56 changed files with 8756 additions and 947 deletions

View File

@@ -37,78 +37,123 @@
<div class="section" id="module-pylib.numerical.ode_model">
<span id="pylib-numerical-ode-model-module"></span><h1>pylib.numerical.ode_model module<a class="headerlink" href="#module-pylib.numerical.ode_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>
<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 class="field-odd"><p>2020-01-08</p>
</dd>
</dl>
<span class="target" id="module-ode_model"></span><dl class="function">
<dt id="pylib.numerical.ode_model.disk">
<code class="sig-name descname">disk</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">t</em>, <em class="sig-param">*p</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/numerical/ode_model.html#disk"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.numerical.ode_model.disk" title="Permalink to this definition"></a></dt>
<code class="sig-name descname">disk</code><span class="sig-paren">(</span><em class="sig-param">d</em>, <em class="sig-param">e</em>, <em class="sig-param">T</em>, <em class="sig-param">method=''</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/numerical/ode_model.html#disk"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.numerical.ode_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>
<li><p><strong>d</strong> (<em>float</em>) diameter</p></li>
<li><p><strong>e</strong> (<em>float</em>) eccentricity</p></li>
<li><p><strong>T</strong> (<em>float</em>) torque</p></li>
<li><p><strong>method</strong> the method to use, default = .</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pylib.numerical.ode_model.disk_nm">
<code class="sig-name descname">disk_nm</code><span class="sig-paren">(</span><em class="sig-param">xn</em>, <em class="sig-param">xpn</em>, <em class="sig-param">xppn</em>, <em class="sig-param">t</em>, <em class="sig-param">*p</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/numerical/ode_model.html#disk_nm"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.numerical.ode_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="pylib.numerical.ode_model.disk_nmmdk">
<code class="sig-name descname">disk_nmmdk</code><span class="sig-paren">(</span><em class="sig-param">xn</em>, <em class="sig-param">xpn</em>, <em class="sig-param">xppn</em>, <em class="sig-param">t</em>, <em class="sig-param">*p</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/numerical/ode_model.html#disk_nmmdk"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.numerical.ode_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>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><p>disk function. This function is independent of the time.</p>
<ul class="simple">
<li><p>For method = : f(x, t=0) -&gt; (xp1, xp2, xp3, xp4, xp5, xp6).
x is (x, y, phi, x, y, phi) and the return values are (x,
y, phi, x, y, phi)</p></li>
<li><p>For method = nm: f(xn, xpn, xppn, t=0) -&gt; (N, dN, dNp, dNpp).
xn are the values of the function (x, y, phi), xpn are first
derivative values of the function (x, y, phi) and xppn are
the second derivative values of the function (x, y, phi).
The return values are (N, dN, dNp, dNpp)</p></li>
<li><p>For method = nmmdk: f(xn, xpn, xppn, t=0) -&gt;
(rm, rmx, rmxpp, rd, rdx, rdxp, rk, rkx, f).
xn are the values of the function (x, y, phi), xpn are first
derivative values of the function (x, y, phi) and xppn are
the second derivative values of the function (x, y, phi).
The return values are (rm, rmx, rmxpp, rd, rdx, rdxp, rk, rkx,
f)</p></li>
</ul>
</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>function</p>
</dd>
</dl>
<p>Model</p>
<blockquote>
<div><div class="math notranslate nohighlight">
\[\begin{split}\begin{vmatrix}
\ddot{x} + \cos(\varphi)\ddot{\varphi} + 2d \,\dot{x} - \sin(\varphi) \,\dot{\varphi}^2 + 2d\cos(\varphi)\, \dot{\varphi} + x &amp;=&amp;
0 \\
\ddot{y} - \sin(\varphi)\ddot{\varphi} + 2d \,\dot{y} - \cos(\varphi) \,\dot{\varphi}^2 + 2d\sin(\varphi)\, \dot{\varphi} + y &amp;=&amp;
0 \\
\ddot{\varphi} + e\,y\sin(\varphi) - e\,x\cos(\varphi) &amp;=&amp; t
\end{vmatrix}
\\
\begin{vmatrix}
\ddot{x} + \cos(\varphi)\ddot{\varphi} &amp;=&amp;
-2d \,\dot{x} + \sin(\varphi) \,\dot{\varphi}^2 -2d\cos(\varphi)\, \dot{\varphi} - x \\
\ddot{y} - \sin(\varphi)\ddot{\varphi} &amp;=&amp;
-2d \,\dot{y} + \cos(\varphi) \,\dot{\varphi}^2 -2d\sin(\varphi)\, \dot{\varphi} - y \\
\ddot{\varphi} &amp;=&amp; t - e\,y\sin(\varphi) + e\,x\cos(\varphi)
\end{vmatrix}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}\mathbf{M}(\mathbf{x}) \cdot \mathbf{\ddot{x}} &amp;=
\mathbf{f}(\mathbf{x}, \mathbf{\dot{x}})
\\
\begin{bmatrix}
1 &amp; 0 &amp; \cos \varphi \\
0 &amp; 1 &amp; -\sin \varphi \\
0 &amp; 0 &amp; 1
\end{bmatrix} \cdot
\begin{bmatrix}
\ddot{x} \\ \ddot{y} \\ \ddot{\varphi}
\end{bmatrix} &amp;= \begin{bmatrix}
-2d \,\dot{x} + \sin(\varphi) \,\dot{\varphi}^2 -2d\cos(\varphi)\, \dot{\varphi} - x \\
-2d \,\dot{y} + \cos(\varphi) \,\dot{\varphi}^2 -2d\sin(\varphi)\, \dot{\varphi} - y \\
t - e\,y\sin(\varphi) + e\,x\cos(\varphi)
\end{bmatrix}\end{split}\]</div>
</div></blockquote>
<p>returns</p>
<blockquote>
<div><div class="math notranslate nohighlight">
\[\begin{split}x_1 &amp;= x &amp;\quad x_4 &amp;= \dot{x}_1 = \dot{x} &amp;\quad \dot{x}_4 &amp;= \ddot{x} \\
x_2 &amp;= y &amp;\quad x_5 &amp;= \dot{x}_2 = \dot{y} &amp;\quad \dot{x}_5 &amp;= \ddot{y} \\
x_3 &amp;= \varphi &amp;\quad x_6 &amp;= \dot{x}_3 = \dot{\varphi} &amp;\quad \dot{x}_6 &amp;= \ddot{\varphi} \\\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}\dot{q} &amp;= f(x) \\
\begin{bmatrix}
\dot{x}_1 \\
\dot{x}_2 \\
\dot{x}_3 \\
\dot{x}_4 \\
\dot{x}_5 \\
\dot{x}_6
\end{bmatrix} &amp;= \begin{bmatrix}
x_4 \\
x_5 \\
x_6 \\
\begin{bmatrix}
1 &amp; 0 &amp; \cos x_3 \\
0 &amp; 1 &amp; -\sin x_3 \\
0 &amp; 0 &amp; 1
\end{bmatrix}^{-1} \cdot \begin{bmatrix}
-2d \,x_4 + \sin(x_3) \,x_6^2 -2d\cos(x_3)\, x_6 - x_1 \\
-2d \,x_5 + \cos(x_3) \,x_6^2 -2d\sin(x_3)\, x_6 - x_2 \\
t - e\,x_2\sin(x_3) + e\,x_1\cos(x_3)
\end{bmatrix}
\end{bmatrix}\end{split}\]</div>
</div></blockquote>
<p>Three explicit differential equations of order 2 reducted to a
system of 3x2 first-order differential equations.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="pylib.numerical.ode.html#pylib.numerical.ode.newmark_newtonraphson" title="pylib.numerical.ode.newmark_newtonraphson"><code class="xref py py-meth docutils literal notranslate"><span class="pre">pylib.numerical.ode.newmark_newtonraphson()</span></code></a> and
<a class="reference internal" href="pylib.numerical.ode.html#pylib.numerical.ode.newmark_newtonraphson_mdk" title="pylib.numerical.ode.newmark_newtonraphson_mdk"><code class="xref py py-meth docutils literal notranslate"><span class="pre">pylib.numerical.ode.newmark_newtonraphson_mdk()</span></code></a></p>
</div>
</dd></dl>
</div>