-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3afed52
Showing
75 changed files
with
11,526 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 — 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> »</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> »</li> | ||
<li class="nav-item nav-item-this"><a href="">Overview: module code</a></li> | ||
</ul> | ||
</div> | ||
<div class="footer" role="contentinfo"> | ||
© Copyright 2024, Abolfazl Ziaeemehr. | ||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.4.7. | ||
</div> | ||
</body> | ||
</html> |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 — 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> »</li> | ||
<li class="nav-item nav-item-1"><a href="../index.html" accesskey="U">Module code</a> »</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">"""</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"> """</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">'x'</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">""" 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"> """</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> »</li> | ||
<li class="nav-item nav-item-1"><a href="../index.html" >Module code</a> »</li> | ||
<li class="nav-item nav-item-this"><a href="">spikes.utils</a></li> | ||
</ul> | ||
</div> | ||
<div class="footer" role="contentinfo"> | ||
© Copyright 2024, Abolfazl Ziaeemehr. | ||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.4.7. | ||
</div> | ||
</body> | ||
</html> |
Oops, something went wrong.