Skip to content

Commit

Permalink
deploy: 01b12cb
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziaeemehr committed Aug 14, 2024
0 parents commit 3afed52
Show file tree
Hide file tree
Showing 75 changed files with 11,526 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +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: 5921dd7b91f7d211fa499d73fb08bb19
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file added .doctrees/environment.pickle
Binary file not shown.
Binary file added .doctrees/examples/chap_03.doctree
Binary file not shown.
Binary file added .doctrees/examples/chap_04.doctree
Binary file not shown.
Binary file added .doctrees/examples/chap_05.doctree
Binary file not shown.
Binary file added .doctrees/examples/chap_06.doctree
Binary file not shown.
Binary file added .doctrees/index.doctree
Binary file not shown.
484 changes: 484 additions & 0 deletions .doctrees/nbsphinx/examples/chap_03.ipynb

Large diffs are not rendered by default.

437 changes: 437 additions & 0 deletions .doctrees/nbsphinx/examples/chap_04.ipynb

Large diffs are not rendered by default.

300 changes: 300 additions & 0 deletions .doctrees/nbsphinx/examples/chap_05.ipynb

Large diffs are not rendered by default.

546 changes: 546 additions & 0 deletions .doctrees/nbsphinx/examples/chap_06.ipynb

Large diffs are not rendered by default.

Binary file added .doctrees/nbsphinx/examples_chap_03_12_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .doctrees/nbsphinx/examples_chap_03_15_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .doctrees/nbsphinx/examples_chap_03_9_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .doctrees/nbsphinx/examples_chap_04_11_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .doctrees/nbsphinx/examples_chap_04_9_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .doctrees/nbsphinx/examples_chap_05_13_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .doctrees/nbsphinx/examples_chap_05_6_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .doctrees/nbsphinx/examples_chap_05_6_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .doctrees/nbsphinx/examples_chap_05_9_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .doctrees/nbsphinx/examples_chap_06_12_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .doctrees/nbsphinx/examples_chap_06_13_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .doctrees/nbsphinx/examples_chap_06_13_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .doctrees/nbsphinx/examples_chap_06_6_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .doctrees/nbsphinx/examples_chap_06_8_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added .nojekyll
Empty file.
Binary file added _images/examples_chap_03_12_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/examples_chap_03_15_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/examples_chap_03_9_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/examples_chap_04_11_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/examples_chap_04_9_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/examples_chap_05_13_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/examples_chap_05_6_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/examples_chap_05_9_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/examples_chap_06_6_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/examples_chap_06_8_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 81 additions & 0 deletions _modules/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<!DOCTYPE html>

<html lang="en" data-content_root="../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Overview: module code &#8212; spikes 0.1.dev1+g01b12cb documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=82a976d7" />
<link rel="stylesheet" type="text/css" href="../_static/nature.css?v=0f882399" />
<link rel="stylesheet" type="text/css" href="../_static/graphviz.css?v=fd3f3429" />
<script src="../_static/documentation_options.js?v=71a5a677"></script>
<script src="../_static/doctools.js?v=9a2dae69"></script>
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
<script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
</head><body>
<div class="related" role="navigation" aria-label="Related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">spikes 0.1.dev1+g01b12cb documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Overview: module code</a></li>
</ul>
</div>

<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">

<h1>All modules for which code is available</h1>
<ul><li><a href="spikes/plot.html">spikes.plot</a></li>
<li><a href="spikes/solver.html">spikes.solver</a></li>
<li><a href="spikes/utils.html">spikes.utils</a></li>
</ul>

<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="Main">
<div class="sphinxsidebarwrapper">
<search id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="Related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">spikes 0.1.dev1+g01b12cb documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Overview: module code</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2024, Abolfazl Ziaeemehr.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.4.7.
</div>
</body>
</html>
247 changes: 247 additions & 0 deletions _modules/spikes/plot.html

Large diffs are not rendered by default.

272 changes: 272 additions & 0 deletions _modules/spikes/solver.html

Large diffs are not rendered by default.

158 changes: 158 additions & 0 deletions _modules/spikes/utils.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<!DOCTYPE html>

<html lang="en" data-content_root="../../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>spikes.utils &#8212; spikes 0.1.dev1+g01b12cb documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=82a976d7" />
<link rel="stylesheet" type="text/css" href="../../_static/nature.css?v=0f882399" />
<link rel="stylesheet" type="text/css" href="../../_static/graphviz.css?v=fd3f3429" />
<script src="../../_static/documentation_options.js?v=71a5a677"></script>
<script src="../../_static/doctools.js?v=9a2dae69"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
</head><body>
<div class="related" role="navigation" aria-label="Related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../../index.html">spikes 0.1.dev1+g01b12cb documentation</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../index.html" accesskey="U">Module code</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">spikes.utils</a></li>
</ul>
</div>

<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">

<h1>Source code for spikes.utils</h1><div class="highlight"><pre>
<span></span><span class="kn">import</span> <span class="nn">spikes</span>
<span class="kn">import</span> <span class="nn">sympy</span>

<div class="viewcode-block" id="characteristic_polynomial">
<a class="viewcode-back" href="../../index.html#spikes.utils.characteristic_polynomial">[docs]</a>
<span class="k">def</span> <span class="nf">characteristic_polynomial</span><span class="p">(</span><span class="n">matrix</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Computes the characteristic polynomial of a given matrix.</span>

<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> matrix: (list of lists) </span>
<span class="sd"> A 2D list representing the matrix.</span>

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> sympy.Poly: </span>
<span class="sd"> The characteristic polynomial of the matrix.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># Define the symbolic variable</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">sympy</span><span class="o">.</span><span class="n">Symbol</span><span class="p">(</span><span class="s1">&#39;x&#39;</span><span class="p">)</span>

<span class="c1"># Convert the input matrix to a sympy.Matrix</span>
<span class="n">A</span> <span class="o">=</span> <span class="n">sympy</span><span class="o">.</span><span class="n">Matrix</span><span class="p">(</span><span class="n">matrix</span><span class="p">)</span>

<span class="c1"># Compute the characteristic polynomial</span>
<span class="n">char_poly</span> <span class="o">=</span> <span class="n">A</span><span class="o">.</span><span class="n">charpoly</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>

<span class="c1"># Get the polynomial coefficients</span>
<span class="n">coefficients</span> <span class="o">=</span> <span class="n">char_poly</span><span class="o">.</span><span class="n">all_coeffs</span><span class="p">()</span>

<span class="c1"># Create the polynomial using sympy.Poly</span>
<span class="n">p</span> <span class="o">=</span> <span class="n">sympy</span><span class="o">.</span><span class="n">Poly</span><span class="p">(</span><span class="n">coefficients</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>

<span class="k">return</span> <span class="n">p</span></div>



<div class="viewcode-block" id="routh">
<a class="viewcode-back" href="../../index.html#spikes.utils.routh">[docs]</a>
<span class="k">def</span> <span class="nf">routh</span><span class="p">(</span><span class="n">p</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot; Construct the Routh-Hurwitz array given a polynomial in s</span>

<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> p: sympy.Poly</span>
<span class="sd"> The characteristic polynomial of coefficient matrix</span>
<span class="sd"> </span>
<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> value: sympy.Matrix</span>
<span class="sd"> The Routh-Hurwitz array</span>
<span class="sd"> </span>
<span class="sd"> References https://github.com/alchemyst/Dynamics-and-Control/blob/master/tbcontrol/symbolic.py</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">coefficients</span> <span class="o">=</span> <span class="n">p</span><span class="o">.</span><span class="n">all_coeffs</span><span class="p">()</span>
<span class="n">N</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">coefficients</span><span class="p">)</span>
<span class="n">M</span> <span class="o">=</span> <span class="n">sympy</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">N</span><span class="p">,</span> <span class="p">(</span><span class="n">N</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span><span class="o">//</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>

<span class="n">r1</span> <span class="o">=</span> <span class="n">coefficients</span><span class="p">[</span><span class="mi">0</span><span class="p">::</span><span class="mi">2</span><span class="p">]</span>
<span class="n">r2</span> <span class="o">=</span> <span class="n">coefficients</span><span class="p">[</span><span class="mi">1</span><span class="p">::</span><span class="mi">2</span><span class="p">]</span>
<span class="n">M</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="p">:</span><span class="nb">len</span><span class="p">(</span><span class="n">r1</span><span class="p">)]</span> <span class="o">=</span> <span class="p">[</span><span class="n">r1</span><span class="p">]</span>
<span class="n">M</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="p">:</span><span class="nb">len</span><span class="p">(</span><span class="n">r2</span><span class="p">)]</span> <span class="o">=</span> <span class="p">[</span><span class="n">r2</span><span class="p">]</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="n">N</span><span class="p">):</span>
<span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">N</span><span class="o">//</span><span class="mi">2</span><span class="p">):</span>
<span class="n">S</span> <span class="o">=</span> <span class="n">M</span><span class="p">[[</span><span class="n">i</span><span class="o">-</span><span class="mi">2</span><span class="p">,</span> <span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="n">j</span><span class="o">+</span><span class="mi">1</span><span class="p">]]</span>
<span class="n">M</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">]</span> <span class="o">=</span> <span class="n">sympy</span><span class="o">.</span><span class="n">simplify</span><span class="p">(</span><span class="o">-</span><span class="n">S</span><span class="o">.</span><span class="n">det</span><span class="p">()</span><span class="o">/</span><span class="n">M</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">])</span>
<span class="c1"># If a row of the routh table becomes zero,Take the derivative of the previous row and substitute it instead</span>
<span class="c1"># Ref: Norman S. Nise, Control Systems Engineering, 8th Edition, Chapter 6, Section 3</span>
<span class="k">if</span> <span class="n">M</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="p">:]</span> <span class="o">==</span> <span class="n">sympy</span><span class="o">.</span><span class="n">Matrix</span><span class="p">([[</span><span class="mi">0</span><span class="p">]</span><span class="o">*</span><span class="p">(</span><span class="n">M</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">])]):</span>
<span class="c1"># Find the coefficients on taking the derivative of the Auxiliary polynomial</span>
<span class="n">diff_arr</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="n">N</span><span class="o">-</span><span class="n">i</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">2</span><span class="p">))</span>
<span class="n">diff_arr</span><span class="o">.</span><span class="n">extend</span><span class="p">([</span><span class="mi">0</span><span class="p">]</span><span class="o">*</span><span class="p">(</span><span class="n">M</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">diff_arr</span><span class="p">)))</span>
<span class="n">diff_arr</span> <span class="o">=</span> <span class="n">sympy</span><span class="o">.</span><span class="n">Matrix</span><span class="p">([</span><span class="n">diff_arr</span><span class="p">])</span>
<span class="c1"># Multiply the coefficients with the value in previous row</span>
<span class="n">M</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="p">:]</span> <span class="o">=</span> <span class="n">sympy</span><span class="o">.</span><span class="n">matrix_multiply_elementwise</span><span class="p">(</span><span class="n">diff_arr</span><span class="p">,</span> <span class="n">M</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="p">:])</span>
<span class="k">return</span> <span class="n">M</span><span class="p">[:,</span> <span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span></div>

</pre></div>

<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="Main">
<div class="sphinxsidebarwrapper">
<search id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="Related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../../index.html">spikes 0.1.dev1+g01b12cb documentation</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../index.html" >Module code</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">spikes.utils</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2024, Abolfazl Ziaeemehr.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.4.7.
</div>
</body>
</html>
Loading

0 comments on commit 3afed52

Please sign in to comment.