Dynamic Systems:
Natural Response
Table of Contents
$$
\begin{align*}
\frac{dx(t)}{dt} &= kx(t), \qquad x(0)=x_0 \\ \\
\rightarrow \; x(t) &= x_0e^{\,kt}
\end{align*}
$$
%%html
<center><iframe src="https://www.youtube.com/embed/4X0SGGrXDiI?start=399&end=459?rel=0"
width="560" height="315" frameborder="0" allowfullscreen></iframe></center>
% plot an analytic solution
k = -0.9;
x0 = 2;
t = linspace(0,5,100);
x = x0*exp(k*t);
plot(t,x);
xlabel('time [sec]')
ylabel('x(t)')
ylim([0,2])
% but, all we did is just plotting (not computing)
$$
\begin{align*}
\dot{u_1} &= \lambda_1 u_1 \implies u_1(t) = u_1(0) e^{\lambda_1 t}\\ \\
\dot{u_2} &= \lambda_2 u_2 \implies u_2(t) = u_2(0) e^{\lambda_2 t}
\end{align*}
$$
$$
\begin{align*}
\dot{u_1} &= a_{11} u_1 + a_{12} u_2\\
\dot{u_2} &= a_{21} u_1 + a_{22} u_2 \\\\
\dot{u} &= \begin{bmatrix}a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix} u = A u \\\\
u(t) &= \begin{bmatrix}u_1(t) \\ u_2(t) \end{bmatrix} = ?
\end{align*}
$$
$\quad\;$ (I will use mixed notations, $\vec{u}$ or $u$)
$$ \dot{\vec{u}} = A\vec{u}, \qquad \vec{u}(0) = \vec{u}_0$$
$\quad\;$ I.C.
$$ \begin{align*} u(0) &= v_1(0)x_1 + v_2(0)x_2 \\ &= \begin{bmatrix} x_1 & x_2 \end{bmatrix} \begin{bmatrix} v_1(0) \\ v_2(0) \end{bmatrix} = Sv(0) \end{align*} $$%%html
<center><iframe src="https://www.youtube.com/embed/YUjdyKhWt6E?rel=0"
width="560" height="315" frameborder="0" allowfullscreen></iframe></center>
%%html
<center><iframe src="https://www.youtube.com/embed/lXNXrLcoerU?rel=0"
width="420" height="315" frameborder="0" allowfullscreen></iframe></center>
$\quad \;$ where $$ \left[ {\begin{matrix} c_1 \\ c_2 \\ \end{matrix} } \right] = \left[ {\begin{array}{cc} \vec{x}_1 \, \, \vec{x}_2 \\ \end{array} } \right]^{-1} \left[ {\begin{array}{cc} u_1(0) \\ u_2(0) \\ \end{array} } \right]. $$
$\quad\;$ 1) Find the eigenvalues
$\quad\;$ 2) Find the corresponding eigenvectors
$$ \begin{align*} \begin{bmatrix} -1 & 1\\ 1 & -1 \end{bmatrix} \begin{bmatrix} x\\ y \end{bmatrix} = \begin{bmatrix} 0\\ 0 \end{bmatrix} &\implies \vec{x}_1 = \begin{bmatrix} 1\\ 1 \end{bmatrix} \qquad \text{for } \lambda_1\\ \begin{bmatrix} 1 & 1\\ 1 & 1 \end{bmatrix} \begin{bmatrix} x\\ y \end{bmatrix} = \begin{bmatrix} 0\\ 0 \end{bmatrix} &\implies \vec{x}_2 = \begin{bmatrix} 1\\ -1 \end{bmatrix} \qquad \text{for } \lambda_2 \end{align*} $$$\quad\;$ 3) Find $\vec{u}(t)$
$$ \begin{align*} \vec{u}(t) &= c_1\vec{x}_1e^{\lambda_1 t} + c_2\vec{x}_2e^{\lambda_2 t} \\ \\ &= c_1 \begin{bmatrix} 1 \\ 1 \end{bmatrix} e^{-2t} + c_2 \begin{bmatrix} 1 \\ -1 \end{bmatrix} e^{-4t} = \begin{bmatrix} c_1e^{-2t} + c_2e^{-4t} \\ c_1e^{-2t} - c_2e^{-4t} \\ \end{bmatrix} \end{align*} $$$\quad\;$ 4) Initial Condition
$$u(0) = c_1 \begin{bmatrix} 1 \\ 1 \end{bmatrix} + c_2 \begin{bmatrix} 1 \\ -1 \end{bmatrix}$$%plot -s 900,350
A = [-3 1;
1 -3];
%% eigen-analysis
[S,D] = eig(A);
[lamb,idx] = sort(diag(D),'descend');
S = S(:,idx);
x1 = S(:,1);
x2 = S(:,2);
u0 = [4;8];
C = inv(S)*u0;
t = 0:0.01:3;
u = C(1)*x1*exp(lamb(1)*t) + C(2)*x2*exp(lamb(2)*t);
% plot u1 and u2 as a function of time
plot(t,u(1,:),t,u(2,:))
xlabel('time')
legend('u_1', 'u_2')
Phase portrait
%%html
<center><iframe src="https://www.youtube.com/embed/e3FfmXtkppM?rel=0"
width="420" height="315" frameborder="0" allowfullscreen></iframe></center>
%plot -s 560,420
% plot eigenvectors (X1 and X2)
k = -20:0.1:20;
y1 = S(:,1)*k;
y2 = S(:,2)*k;
plot(y1(1,:), y1(2,:)); hold on
plot(y2(1,:), y2(2,:));
xlabel('u_1', 'fontsize', 12)
ylabel('u_2', 'fontsize', 12)
title('Trajectory', 'fontsize', 12)
axis equal
axis([-10 10 -10 10])
% plot a trajectory of u1 and u2
for i = 1:length(t)
plot(u(1,i), u(2,i), 'k.');
end
hold off
%plot -s 900,350
A = [-2 0;
0 -4];
%% eigen-analysis
[S,D] = eig(A);
[lamb,idx] = sort(diag(D),'descend');
S = S(:,idx);
x1 = S(:,1);
x2 = S(:,2);
u0 = [4;8];
C = inv(S)*u0;
t = 0:0.01:3;
u = C(1)*x1*exp(lamb(1)*t) + C(2)*x2*exp(lamb(2)*t);
% plot u1 and u2 as a function of time
plot(t,u(1,:),t,u(2,:))
xlabel('time')
%plot -s 560,420
% plot eigenvectors (X1 and X2)
k = -20:0.1:20;
y1 = S(:,1)*k;
y2 = S(:,2)*k;
plot(y1(1,:), y1(2,:)); hold on
plot(y2(1,:), y2(2,:));
xlabel('u_1', 'fontsize', 12)
ylabel('u_2', 'fontsize', 12)
title('Trajectory', 'fontsize', 12)
axis equal
axis([-10 10 -10 10])
% plot a trajectory of u1 and u2
for i = 1:length(t)
plot(u(1,i), u(2,i), 'k.');
end
hold off
%plot -s 900,350
A = [-2 0;
1 -4];
%% eigen-analysis
[S,D] = eig(A);
[lamb,idx] = sort(diag(D),'descend');
S = S(:,idx);
x1 = S(:,1);
x2 = S(:,2);
u0 = [4;8];
C = inv(S)*u0;
t = 0:0.01:3;
u = C(1)*x1*exp(lamb(1)*t) + C(2)*x2*exp(lamb(2)*t);
% plot u1 and u2 as a function of time
plot(t,u(1,:),t,u(2,:))
xlabel('time')
%plot -s 560,420
% plot eigenvectors (X1 and X2)
k = -20:0.1:20;
y1 = S(:,1)*k;
y2 = S(:,2)*k;
plot(y1(1,:), y1(2,:)); hold on
plot(y2(1,:), y2(2,:));
xlabel('u_1', 'fontsize', 12)
ylabel('u_2', 'fontsize', 12)
title('Trajectory', 'fontsize', 12)
axis equal
axis([-10 10 -10 10])
% plot a trajectory of u1 and u2
for i = 1:length(t)
plot(u(1,i), u(2,i), 'k.');
end
hold off
$\quad\;$ 1) Total amount of water
$$v_1 = 1u_1 + 2u_2$$$\quad \;$ 2) Difference in height
$$v_2 = u_1 - u_2$$%plot -s 900,350
A = [-2 2;
1 -1];
%% eigen-analysis
[S,D] = eig(A);
[lamb,idx] = sort(diag(D),'descend');
S = S(:,idx);
x1 = S(:,1);
x2 = S(:,2);
u0 = [0;6];
C = inv(S)*u0;
t = 0:0.01:3;
u = C(1)*x1*exp(lamb(1)*t) + C(2)*x2*exp(lamb(2)*t);
% plot u1 and u2 as a function of time
plot(t,u(1,:),t,u(2,:))
xlabel('time')
legend('u_1', 'u_2')
%plot -s 560,420
% plot eigenvectors (X1 and X2)
k = -20:0.1:20;
y1 = S(:,1)*k;
y2 = S(:,2)*k;
plot(y1(1,:), y1(2,:)); hold on
plot(y2(1,:), y2(2,:));
xlabel('u_1', 'fontsize', 12)
ylabel('u_2', 'fontsize', 12)
title('Trajectory', 'fontsize', 12)
axis equal
axis([-10 10 -10 10])
% plot a trajectory of u1 and u2
for i = 1:length(t)
plot(u(1,i), u(2,i), 'k.');
end
hold off
%plot -s 900,350
v = inv(S)*u;
plot(t,v(1,:),t,v(2,:))
xlabel('time')
legend('v_1', 'v_2')
%plot -s 560,420
q1 = inv(S)*y1;
q2 = inv(S)*y2;
plot(q1(1,:), q1(2,:)); hold on
plot(q2(1,:), q2(2,:));
for i = 1:length(t)
plot(v(1,i), v(2,i), 'k.'), hold on
end
hold off
axis equal
axis([-10 10 -10 10])
xlabel('v_1', 'fontsize', 12)
ylabel('v_2', 'fontsize', 12)
title('Trajectory', 'fontsize', 12)
What is the corresponding physical system?
%plot -s 900,350
A = [0 1;
-1 0];
%% eigen-analysis
[S,D] = eig(A);
lamb = diag(D)
x1 = S(:,1);
x2 = S(:,2);
u0 = [0;6];
C = inv(S)*u0;
t = 0:0.01:10;
u = C(1)*x1*exp(lamb(1)*t) + C(2)*x2*exp(lamb(2)*t);
% plot u1 and u2 as a function of time
plot(t,u(1,:),t,u(2,:),t,zeros(size(t)),'k--')
xlabel('time')
legend('u_1', 'u_2')
%plot -s 900,420
subplot(1,2,1)
% plot a trajectory of u1 and u2
for i = 1:length(t)
plot(u(1,i), u(2,i), 'k.'), hold on
end
hold off
axis equal
axis([-12 12 -12 12])
grid on
xlabel('u_1', 'fontsize', 12)
ylabel('u_2', 'fontsize', 12)
title('Trajectory', 'fontsize', 12)
subplot(1,2,2)
plot(real(lamb),imag(lamb),'o')
axis equal
grid on
axis([-4,4,-6,6])
xlabel('Re', 'fontsize', 12)
ylabel('Im', 'fontsize', 12)
title('Eigenvalues','fontsize',12)
%plot -s 900,350
A = [0 1;
-4 0];
%% eigen-analysis
[S,D] = eig(A);
lamb = diag(D)
x1 = S(:,1);
x2 = S(:,2);
u0 = [0;6];
C = inv(S)*u0;
t = 0:0.01:10;
u = C(1)*x1*exp(lamb(1)*t) + C(2)*x2*exp(lamb(2)*t);
% plot u1 and u2 as a function of time
plot(t,u(1,:),t,u(2,:),t,zeros(size(t)),'k--')
xlabel('time')
legend('u_1', 'u_2')
%plot -s 900,420
subplot(1,2,1)
% plot a trajectory of u1 and u2
for i = 1:length(t)
plot(u(1,i), u(2,i), 'k.'), hold on
end
hold off
axis equal
axis([-12 12 -12 12])
grid on
xlabel('u_1', 'fontsize', 12)
ylabel('u_2', 'fontsize', 12)
title('Trajectory', 'fontsize', 12)
subplot(1,2,2)
plot(real(lamb),imag(lamb),'o')
axis equal
grid on
axis([-4,4,-6,6])
xlabel('Re', 'fontsize', 12)
ylabel('Im', 'fontsize', 12)
title('Eigenvalues','fontsize',12)
%plot -s 900,350
A = [3 9;
-4 -3];
%% eigen-analysis
[S,D] = eig(A);
lamb = diag(D)
x1 = S(:,1);
x2 = S(:,2);
u0 = [0;6];
C = inv(S)*u0;
t = 0:0.01:10;
u = C(1)*x1*exp(lamb(1)*t) + C(2)*x2*exp(lamb(2)*t);
% plot u1 and u2 as a function of time
plot(t,u(1,:),t,u(2,:),t,zeros(size(t)),'k--')
xlabel('time')
legend('u_1', 'u_2')
%plot -s 900,420
subplot(1,2,1)
% plot a trajectory of u1 and u2
for i = 1:length(t)
plot(u(1,i), u(2,i), 'k.'), hold on
end
hold off
axis equal
axis([-12 12 -12 12])
grid on
xlabel('u_1', 'fontsize', 12)
ylabel('u_2', 'fontsize', 12)
title('Trajectory', 'fontsize', 12)
subplot(1,2,2)
plot(real(lamb),imag(lamb),'o')
axis equal
grid on
axis([-4,4,-6,6])
xlabel('Re', 'fontsize', 12)
ylabel('Im', 'fontsize', 12)
title('Eigenvalues','fontsize',12)
%plot -s 900,350
A = [-1 1;
-1 -1];
%% eigen-analysis
[S,D] = eig(A);
lamb = diag(D)
x1 = S(:,1);
x2 = S(:,2);
u0 = [0;6];
C = inv(S)*u0;
t = 0:0.01:10;
u = C(1)*x1*exp(lamb(1)*t) + C(2)*x2*exp(lamb(2)*t);
% plot u1 and u2 as a function of time
plot(t,u(1,:),t,u(2,:),t,zeros(size(t)),'k--')
xlabel('time')
legend('u_1', 'u_2')
%plot -s 900,420
subplot(1,2,1)
% plot a trajectory of u1 and u2
for i = 1:length(t)
plot(u(1,i), u(2,i), 'k.'), hold on
end
hold off
axis equal
axis([-12 12 -12 12])
grid on
xlabel('u_1', 'fontsize', 12)
ylabel('u_2', 'fontsize', 12)
title('Trajectory', 'fontsize', 12)
subplot(1,2,2)
plot(real(lamb),imag(lamb),'o')
axis equal
grid on
axis([-4,4,-6,6])
xlabel('Re', 'fontsize', 12)
ylabel('Im', 'fontsize', 12)
title('Eigenvalues','fontsize',12)
%%html
<center><iframe src="https://www.youtube.com/embed/xvTYUnqn2wY?rel=0"
width="560" height="315" frameborder="0" allowfullscreen></iframe></center>
Generic form
$$ a\frac{d^2x(t)}{dt^2} + b\frac{dx(t)}{dt} + cx(t) = 0, \qquad \dot{x}(0)=v_0, x(0)=x_0$$One of examples is the mass-spring-damper system
This notebook simluates the free vibration of a simple mass-spring-damper system. More specifically, we'll look at how system response to non-zero initial conditions.
The equation of motion for the system is:
We could also write this equation in terms of the damping ratio, $\zeta$, and natural frequency $\omega_n$.
where
$$ \begin{align*} \omega^2_n &= {k \over m}\\ 2\zeta\sqrt{k \over m} = {c \over m} \quad \implies \quad \zeta &= {1 \over 2} {c \over m} \sqrt{m \over k} = {1 \over 2}{c \over \sqrt{mk}} \end{align*} $$We'll use the solution to the differential equation that we developed in class to plot the response. The solution for the underdamped case is:
or
To use this equation, we need to solve for $a_1$ and $a_2$ or $b_1$ and $b_2$ using the initial conditions. Here, let's use the sin/cosine form. Solving the equation for generic intial velocity, $\dot{x} = v_0$, and a generic initial displacement, $x = x_0$, we find:
Experiment
%%html
<center><iframe src="https://www.youtube.com/embed/ZqedDWEAUN4?start=80&end=114?rel=0"
width="560" height="315" frameborder="0" allowfullscreen></iframe></center>
%%html
<center><iframe src="https://www.youtube.com/embed/pjzggPk8DO4?rel=0"
width="560" height="315" frameborder="0" allowfullscreen></iframe></center>
%plot -s 900,350
wn = 2; zeta = 0.1;
A = [0 1;-wn^2 -2*zeta*wn];
[S,D] = eig(A);
lamb = diag(D)
t = 0:0.01:10;
U0 = [2 10]';
C = inv(S)*U0;
u = C(1)*S(:,1)*exp(lamb(1)*t) + C(2)*S(:,2)*exp(lamb(2)*t);
% plot u1 and u2 as a function of time
plot(t,u(1,:),t,u(2,:),t,zeros(size(t)),'k--')
axis tight
legend('u_1','u_2')
%plot -s 900,420
subplot(1,2,1)
% plot a trajectory of u1 and u2
for i = 1:length(t)
plot(u(1,i), u(2,i), 'k.'), hold on
end
hold off
axis equal
axis([-12 12 -12 12])
grid on
xlabel('u_1', 'fontsize', 12)
ylabel('u_2', 'fontsize', 12)
title('Trajectory', 'fontsize', 12)
subplot(1,2,2)
plot(real(lamb),imag(lamb),'o')
axis equal
grid on
axis([-4,4,-6,6])
xlabel('Re', 'fontsize', 12)
ylabel('Im', 'fontsize', 12)
title('Eigenvalues','fontsize',12)
Always trying to figure out if the system "blows up" or not
Recall the control design objectives:
It is useful to start with scalar systems to get some intuition about what is going on
From scalars to mattices?
We cannot say that $A>0$, but we can do the next best thing - eigenvalues !
The eigenvalues tell us how the matrix $A$ 'acts' in different directions (eigenvectors)
%%javascript
$.getScript('https://kmahelona.github.io/ipython_notebook_goodies/ipython_notebook_toc.js')