reproductions/Example/Example_06_02.ipynb
{
"cells": [
{
"cell_type": "code",
"metadata": {},
"source": [
"from __future__ import print_function\n",
"import numpy as np\n",
"\n",
"from robustcontrol.utils import pole_zero_directions, BoundST, tf, mimotf, RHPonly\n",
"from robustcontrol.reporting import display_export_data\n",
"\n",
"s = tf([1, 0])\n",
"\n",
"p = 3\n",
"z = 2\n",
"d = 30. / 180. * np.pi\n",
"g1 = mimotf([[1 / (s - p), 0],\n",
" [0, 1 / (s + 3)]])\n",
"g2 = mimotf([[np.cos(d), -np.sin(d)],\n",
" [np.sin(d), np.cos(d)]])\n",
"g3 = mimotf([[(s - z) / (0.1 * s + 1), 0],\n",
" [0, (s + 2) / (0.1 * s + 1)]])\n",
"G = g1 * g2 * g3\n",
"\n",
"p = G.poles()\n",
"z = G.zeros()\n",
"print('All Poles: {0}'.format(p))\n",
"print('All Zeros: {0}\\n'.format(z))\n",
"\n",
"RHPzeros = RHPonly(z)\n",
"RHPpoles = RHPonly(p)\n",
"print(\"RHP poles only: \", RHPpoles)\n",
"print(\"RHP zeros only: \", RHPzeros)\n",
"\n",
"# selected p & z\n",
"p = [3.]\n",
"z = [2.]\n",
"\n",
"pdata = pole_zero_directions(G, p, 'p')\n",
"zdata = pole_zero_directions(G, z, 'z')\n",
"rowhead = ['u','y','e ']\n",
"display_export_data(pdata, 'Poles', rowhead)\n",
"display_export_data(zdata, 'Zeros', rowhead)\n",
"\n",
"zdata,_ = pole_zero_directions(G, z, 'z', 'y')\n",
"print('M_S,min = M_T,min = {:.2f}'.format(BoundST(G, p, z)))\n",
"\n",
"# TODO fix BoundST with deadtime\n",
"print('\\nPeak example for deadtime:')\n",
"deadtime = np.matrix([[-1, 0],\n",
" [-2., -3]])\n",
" \n",
"print('M_T,min = {:.2f}'.format(BoundST(G, p, z, deadtime)))\n"
],
"outputs": [],
"execution_count": null
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
}
},
"nbformat": 4,
"nbformat_minor": 1
}