@@ -66,7 +66,7 @@ values in FBS2e. |
66 | 66 |
|
67 | 67 | We begin by defining the dynamics of the system |
68 | 68 |
|
69 | | -.. code-block:: |
| 69 | +.. code-block:: python |
70 | 70 |
|
71 | 71 | import control |
72 | 72 | import numpy as np |
@@ -96,7 +96,7 @@ We begin by defining the dynamics of the system |
96 | 96 |
|
97 | 97 | We now create an input/output system using these dynamics: |
98 | 98 |
|
99 | | -.. code-block:: |
| 99 | +.. code-block:: python |
100 | 100 |
|
101 | 101 | io_predprey = control.NonlinearIOSystem( |
102 | 102 | predprey_rhs, None, inputs=('u'), outputs=('H', 'L'), |
@@ -108,7 +108,7 @@ will be used as the output of the system. |
108 | 108 | The `io_predprey` system can now be simulated to obtain the open loop dynamics |
109 | 109 | of the system: |
110 | 110 |
|
111 | | -.. code-block:: |
| 111 | +.. code-block:: python |
112 | 112 |
|
113 | 113 | X0 = [25, 20] # Initial H, L |
114 | 114 | T = np.linspace(0, 70, 500) # Simulation 70 years of time |
@@ -127,7 +127,7 @@ We can also create a feedback controller to stabilize a desired population of |
127 | 127 | the system. We begin by finding the (unstable) equilibrium point for the |
128 | 128 | system and computing the linearization about that point. |
129 | 129 |
|
130 | | -.. code-block:: |
| 130 | +.. code-block:: python |
131 | 131 |
|
132 | 132 | eqpt = control.find_eqpt(io_predprey, X0, 0) |
133 | 133 | xeq = eqpt[0] # choose the nonzero equilibrium point |
@@ -137,7 +137,7 @@ We next compute a controller that stabilizes the equilibrium point using |
137 | 137 | eigenvalue placement and computing the feedforward gain using the number of |
138 | 138 | lynxes as the desired output (following FBS2e, Example 7.5): |
139 | 139 |
|
140 | | -.. code-block:: |
| 140 | +.. code-block:: python |
141 | 141 |
|
142 | 142 | K = control.place(lin_predprey.A, lin_predprey.B, [-0.1, -0.2]) |
143 | 143 | A, B = lin_predprey.A, lin_predprey.B |
@@ -149,7 +149,7 @@ applies a corrective input based on deviations from the equilibrium point. |
149 | 149 | This system has no dynamics, since it is a static (affine) map, and can |
150 | 150 | constructed using the `~control.ios.NonlinearIOSystem` class: |
151 | 151 |
|
152 | | -.. code-block:: |
| 152 | +.. code-block:: python |
153 | 153 |
|
154 | 154 | io_controller = control.NonlinearIOSystem( |
155 | 155 | None, |
@@ -162,7 +162,7 @@ populations followed by the desired lynx population. |
162 | 162 | To connect the controller to the predatory-prey model, we create an |
163 | 163 | `InterconnectedSystem`: |
164 | 164 |
|
165 | | -.. code-block:: |
| 165 | +.. code-block:: python |
166 | 166 |
|
167 | 167 | io_closed = control.InterconnectedSystem( |
168 | 168 | (io_predprey, io_controller), # systems |
@@ -177,7 +177,7 @@ To connect the controller to the predatory-prey model, we create an |
177 | 177 | |
178 | 178 | Finally, we simulate the closed loop system: |
179 | 179 |
|
180 | | -.. code-block:: |
| 180 | +.. code-block:: python |
181 | 181 |
|
182 | 182 | # Simulate the system |
183 | 183 | t, y = control.input_output_response(io_closed, T, 30, [15, 20]) |
|