Figure 5.9: Phase portrait and time domain simulation for a system with a single unstable equilibrium point

From FBSwiki
Revision as of 16:18, 7 April 2024 by Murray (talk | contribs) (Created page with "{{Figure |Chapter=Dynamic Behavior |Figure number=5.9 |Sort key=509 |Figure title=Phase portrait and time domain simulation for a system with a single unstable equilibrium poi...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Chapter Dynamic Behavior
Figure number 5.9
Figure title Phase portrait and time domain simulation for a system with a single unstable equilibrium point
GitHub URL https://github.com/murrayrm/fbs2e-python/blob/main/figure-5.9-unstable-eqpt.py
Requires python-control
Figure-5.9-unstable eqpt-pp.png
Figure-5.9-untable eqpt-time.png

Figure 5.9: Phase portrait and time domain simulation for a system with a single unstable equilibrium point. The equilibrium point $x_\text{e}$ at the origin is unstable since not all trajectories that start near $x_\text{e}$ stay near $x_\text{e}$. The sample trajectory on the right shows that the trajectories very quickly depart from zero.


# unstable_eqpt.py - plots for stable equlibrium point
# RMM, 7 Apr 2024

import matplotlib.pyplot as plt
import numpy as np
import control as ct
import fbs                      # FBS plotting customizations

saddle = ct.ss([[1, -3], [-3, 1]], [[0], [1]], np.eye(2), 0)

# Draw the phase portrait
fbs.figure()
ct.phase_plane_plot(
    saddle, [-1, 1, -1, 1], 0.4,
    gridtype='meshgrid', gridspec=[6, 6])
plt.gca().set_aspect('equal')
plt.suptitle("")
fbs.savefig('figure-5.9-unystable_eqpt-pp.png')

fbs.figure('321')
plt.axis([0, 3, -100, 100])
timepts = np.linspace(0, 3)
response = ct.input_output_response(saddle, timepts, 0, [1, 0])
plt.plot(response.time, response.outputs[0], 'b', label="$x_1$")
plt.plot(response.time, response.outputs[1], 'r--', label="$x_2$")
plt.xlabel("Time $t$")
plt.ylabel("$x_1, x_2$")
plt.legend(loc='upper right', ncols=1, frameon=False)
fbs.savefig('figure-5.9-unstable_eqpt-time.png')