Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

Babol Noshirvani University of Technology

Faculty of Mechanical Engineering


Department of Applied Design

Homework solutions
For
( Nonlinear Vibration )

Mustafa Alajrawee
Student No.
40240413006

Dr. Dardall
Mustafa Alajrawee Student No. 40240413006
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Question (1)
Find the linear behavior in the vicinity of each of the following systems. Are they
stable or unstable? Local behavior. Review and draw the phase plane.
System 1: x ̇=y-x^2+2 ,y ̇=2y^2-2xy
System 2: : x ̇=-4x-2y+4 ,y ̇=xy

Solution
The MatLab Code
clear;
figure;
%% Define the first system
sys1 = @(t,x) [x(2) - x(1)^2 + 2; 2*(x(2)^2) - 2*x(1)*x(2)];
%% Define the second system
sys2 = @(t,x) [2*x(1)+x(2); x(1)+2*x(2)];
%% Define the range and step for initial conditions
xmin = -3;
xmax = 4;
sep = 0.9;
%% Plot the first system
subplot(1,2,1);
hold on;
for x0 = xmin:sep:xmax
for y0 = xmin:sep:xmax
% Solve the ODEs for positive time
[ts1, xs1] = ode45(sys1, [0 10], [x0 y0]);
plot(xs1(:,1), xs1(:,2))
end
end
for x0 = xmin:sep:xmax
for y0 = xmin:sep:xmax
% Solve the ODEs for negative time
[ts1, xs1] = ode45(sys1, [0 -10], [x0 y0]);
plot(xs1(:,1), xs1(:,2))
end
end

axis([xmin xmax xmin xmax])


fsize=15;
equation1 = '$\dot{x} = y - x^2 + 2$, $\dot{y} = 2y^2 - 2xy$';
title(['Phase Portrait for System 1: ', equation1], 'Interpreter', 'latex')
set(gca,'XTick',xmin:sep:xmax,'FontSize',fsize)
set(gca,'YTick',xmin:sep:xmax,'FontSize',fsize)
xlabel('x(t)','FontSize',fsize)
ylabel('y(t)','FontSize',fsize)
hold off;
%% Plot the second system
subplot(1,2,2);
hold on;
Mustafa Alajrawee Student No. 40240413006
-------------------------------------------------------------------------------------------------------------------------------------------------------------
for x0 = -3:1.5:3
for y0 = -3:1.5:3
[ts, xs] = ode45(sys2, [0 5], [x0 y0]);
plot(xs(:,1), xs(:,2))
end
end
for x0 = -3:1.5:3
for y0 = -3:1.5:3
[ts, xs] = ode45(sys2, [0 -5], [x0 y0]);
plot(xs(:,1), xs(:,2))
end
end
axis([-3 3 -3 3])
fsize = 15;
equation2 = '$\dot{x} = 2x + y$, $\dot{y} = x + 2y$';
title(['Phase Portrait for System 2: ', equation2], 'Interpreter', 'latex')
set(gca, 'XTick', -3:1:3, 'FontSize', fsize)
set(gca, 'YTick', -3:1:3, 'FontSize', fsize)
xlabel('x(t)', 'FontSize', fsize)
ylabel('y(t)', 'FontSize', fsize)
hold off;
Mustafa Alajrawee Student No. 40240413006
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Question (2)
For the following systems of equations:

1. 𝑥̇ = 𝑥 (𝑦 + 2𝑥 − 2) , 𝑦̇ = 𝑦(𝑦 − 1)
2. 𝑥̇ = 𝑥 (𝑦 + 2𝑥 − 2) , 𝑦̇ = 𝑦(𝑦 + 𝑥 − 3)
3. 𝑥̇ = 𝑥 (2 − 𝑦 − 2𝑥 ) , 𝑦̇ = 𝑦(3 − 3𝑦 − 𝑥)
4. 𝑥̇ = 𝑥 (2 − 𝑦 − 2𝑥 ) , , 𝑦̇ = 𝑦(3 − 𝑦 − 4𝑥)
5. 𝑥̇ = 𝑥 (2500 − 𝑥 − 𝑦 ) , 𝑦̇ = 𝑦(70 − 𝑦 − 𝑥)

Find:

 The equilibrium points


 The eigenvalues
 The eigenvectors
 The transformation of equations to modal space
 Draw phase space diagrams around equilibrium points by MatLab

Solution

First System:
1. Equilibrium Points:
 (0,0)(0,0) and (1,1)(1,1)
2. Eigenvalues:
 𝜆1=−2, λ1=−2 and 𝜆2=−1, λ2=−1
3. Eigenvectors:
 𝑣1=(0,1), v1=(0,1) and 𝑣2=(1,0), v2=(1,0)
4. Transformation to Modal Space:
 𝑥=𝑐1𝑣1𝑒^𝜆1𝑡+𝑐2𝑣2𝑒^𝜆2𝑡, x=c1v1e^λ1t+c2v2e^λ2t
Second System:
1. Equilibrium Points:
Mustafa Alajrawee Student No. 40240413006
-------------------------------------------------------------------------------------------------------------------------------------------------------------
 (0,0)(0,0) and (1,3)(1,3)
2. Eigenvalues:
 𝜆1=−2, λ1=−2 and 𝜆2=−3, λ2=−3
3. Eigenvectors:
 𝑣1=(0,1), v1=(0,1) and 𝑣2=(1,1), v2=(1,1)
4. Transformation to Modal Space:
 𝑥=𝑐1𝑣1𝑒^𝜆1𝑡+𝑐2𝑣2𝑒^𝜆2𝑡, x=c1v1e^λ1t+c2v2e^λ2t
Third System:
1. Equilibrium Points:
 (0,0)(0,0) and (1,1)(1,1)
2. Eigenvalues:
 𝜆1=2, λ1=2 and 𝜆2=3, λ2=3
3. Eigenvectors:
 𝑣1=(1,0), v1=(1,0) and 𝑣2=(0,1), v2=(0,1)
4. Transformation to Modal Space:
 𝑥=𝑐1𝑣1𝑒^𝜆1𝑡+𝑐2𝑣2𝑒^𝜆2𝑡, x=c1v1e^λ1t+c2v2e^λ2t
Fourth System:
1. Equilibrium Points:
 (0,0)(0,0) and (1,3)(1,3)
2. Eigenvalues:
 𝜆1=2, λ1=2 and 𝜆2=3, λ2=3
3. Eigenvectors:
 𝑣1=(1,0), v1=(1,0) and 𝑣2=(0,1), v2=(0,1)
4. Transformation to Modal Space:
Mustafa Alajrawee Student No. 40240413006
-------------------------------------------------------------------------------------------------------------------------------------------------------------
 𝑥=𝑐1𝑣1𝑒^𝜆1𝑡+𝑐2𝑣2𝑒^𝜆2𝑡, x=c1v1e^λ1t+c2v2e^λ2t
Fifth System:
1. Equilibrium Points:
 (0,0)(0,0), (50,0)(50,0), (0,70)(0,70), and (50,70)(50,70)
2. Eigenvalues:
 For (0,0)(0,0): 𝜆1=2500, λ1=2500 and 𝜆2=70, λ2=70
 For (50,0)(50,0): 𝜆1=−2500, λ1=−2500 and 𝜆2=20, λ2=20
 For (0,70)(0,70): 𝜆1=−2500, λ1=−2500 and 𝜆2=−70, λ2=−70
 For (50,70)(50,70): 𝜆1=−2500, λ1=−2500 and 𝜆2=−120, λ2=−120
3. Eigenvectors:
 For (0,0)(0,0): 𝑣1=(1,0), v1=(1,0) and 𝑣2=(0,1), v2=(0,1)
 For (50,0)(50,0): 𝑣1=(−1,0), v1=(−1,0) and 𝑣2=(1,0), v2=(1,0)
 For (0,70)(0,70): 𝑣1=(0,1), v1=(0,1) and 𝑣2=(−1,0), v2=(−1,0)
 For (50,70)(50,70): 𝑣1=(−1,−1), v1=(−1,−1) and 𝑣2=(1,−1), v2=(1,−1)
4. Transformation to Modal Space:
 The calculated eigenvectors are used to write the final equation.
The MatLab Code

clear;
figure;

% define sys1
sys1 = @(t,x) [x(1)*(x(2)+2*x(1)-2); x(2)*(x(2)-1)];
eqn1 = 'x? = x(y+2x-2), y? = y(y-1)';

%define sys2
sys2 = @(t,x) [x(1)*(x(2)+2*x(1)-2); x(2)*(x(2)+x(1)-3)];
eqn2 = 'x? = x(y+2x-2), y? = y(y+x-3)';

%define sys3
sys3 = @(t,x) [x(1)*(2-x(2)-2*x(1)); x(2)*(3-3*x(2)-x(1))];
eqn3 = 'x? = x(2-y-2x), y? = y(3-3y-x)';
Mustafa Alajrawee Student No. 40240413006
-------------------------------------------------------------------------------------------------------------------------------------------------------------
%define sys4
sys4 = @(t,x) [x(1)*(2-x(2)-2*x(1)); x(2)*(3-x(2)-4*x(1))];
eqn4 = 'x? = x(2-y-2x), y? = y(3-y-4x)';

%define sys5
sys5 = @(t,x) [x(1)*(2500-x(1)^2-x(2)^2); x(2)*(70-x(2)-x(1))];
eqn5 = 'x? = x(2500-x^2-y^2), y? = y(70-y-x)';

%The axis boundaries and the interval between the initial conditions
xmin = -10;
xmax = 10;
sep = 0.9;

%systems number
num_sys = 5;

% Set interface dimensions


rows = ceil(sqrt(num_sys));
cols = ceil(num_sys / rows);

for i = 1:num_sys
subplot(rows, cols, i);
hold on;
grid on;

% Draw each system


switch i
case 1
sys = sys1;
eqn = eqn1;
title('System 1');
case 2
sys = sys2;
eqn = eqn2;
title('System 2');
case 3
sys = sys3;
eqn = eqn3;
title('System 3');
case 4
sys = sys4;
eqn = eqn4;
title('System 4');
case 5
sys = sys5;
eqn = eqn5;
title('System 5');
end

% Add the equation as a title


eqn_text = sprintf('Equation: %s', eqn);
title_with_eqn = sprintf('%s\n%s', get(get(gca, 'title'), 'String'), eqn_text);
title(title_with_eqn, 'Interpreter', 'none');

% Draw paths for the current system


if i ~= 5
for x0 = xmin:sep:xmax
for y0 = xmin:sep:xmax
Mustafa Alajrawee Student No. 40240413006
-------------------------------------------------------------------------------------------------------------------------------------------------------------
options = odeset('MaxStep', 0.1);
[ts, xs] = ode45(sys, [0 10], [x0 y0], options);
plot(xs(:,1), xs(:,2));
end
end
else
%Drawing paths for the fifth system
for x0 = xmin:sep:xmax
for y0 = xmin:sep:xmax
options = odeset('MaxStep', 0.1);
[ts, xs] = ode15s(sys, [0 10], [x0 y0], options);
plot(xs(:,1), xs(:,2));
end
end
end

% Set the chart size and label the axes


axis([xmin xmax xmin xmax]);
xlabel('x(t)');
ylabel('y(t)');
end

sgtitle('Phase Portrait of Nonlinear Systems with Equations by Mostafa Alajrawi');


Mustafa Alajrawee Student No. 40240413006
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Question (3)
Plot the phase curve of the system for 0 > a. What qualitative change occurs when
this parameter tends from a negative value to a positive value?

𝑥̇ = 𝑥 − 1 , 𝑦̇ = −𝑥𝑦 + 𝑎(𝑥 − 1)

Solution
The MatLab Code
% Phase Portrait of a Nonlinear System with parameter a.

clear; figure;

% Define the system with parameter a


sys = @(t,x,a) [x(1)^2 - 1; -x(1)*x(2) + a*(x(1)^2 - 1)];

xmin = -3;
xmax = 3;
sep = 0.5;
a = -0.5; % You can change the value of a here

hold on

% Plot phase curve for positive a


for x0 = xmin:sep:xmax
for y0 = xmin:sep:xmax
[ts, xs] = ode45(@(t,x) sys(t,x,a), [0 10], [x0 y0]);
plot(xs(:,1), xs(:,2))
end
end

% Plot phase curve for negative a


for x0 = xmin:sep:xmax
for y0 = xmin:sep:xmax
[ts, xs] = ode45(@(t,x) sys(t,x,a), [0 -10], [x0 y0]);
plot(xs(:,1), xs(:,2))
end
end

hold off

axis([xmin xmax xmin xmax])

fsize = 15;
title('Phase Portrait of the Nonlinear System: (x?= x^2-1 , y?= -xy+a(x^2-1))')
set(gca,'XTick',xmin:sep:xmax,'FontSize',fsize)
set(gca,'YTick',xmin:sep:xmax,'FontSize',fsize)
xlabel('x(t)','FontSize',fsize)
ylabel('y(t)','FontSize',fsize)
Mustafa Alajrawee Student No. 40240413006
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Mustafa Alajrawee Student No. 40240413006
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Question (4)
Consider the following system of differential equations:

𝑥̇ = 𝑥 (−𝑥 − 𝑦 − 1) , 𝑦̇ = 𝑦(−𝑎𝑥 − 𝑡 + 𝑏)

where a and b are parameters with 0 < ab. Assume that this system is defined only
for 0 ≤ x, y ≤ 2.

Using nullclines, draw the phase portrait of this system for different values of a
and b.Determine the values of a and b for which bifurcation occurs.

Determine the regions of the ab plane in which the system has qualitatively similar
phase portraits and identify the bifurcations that occur as the parameters cross
these boundaries.

Solution
The MatLab Code
clear;
figure;
a = 0.5; % ???? a
b = 0.3; % ???? b
sys = @(t, x) [x(1) * (-x(1) - x(2) - 1); x(2) * (-a * x(1) - t + b)]; % ????
?????????
xmin = 0;
xmax = 2;
sep = 0.1; % ????? ??????

hold on
for x0 = xmin:sep:xmax
for y0 = xmin:sep:xmax
[ts, xs] = ode45(sys, [0, 10], [x0, y0]); % ??
plot(xs(:, 1), xs(:, 2))
end
end
for x0 = xmin:sep:xmax
for y0 = xmin:sep:xmax
[ts, xs] = ode45(sys, [0, -10], [x0, y0]); % ?? ????????
plot(xs(:, 1), xs(:, 2))
end
end

xlabel('x(t)');
ylabel('y(t)');
title('Phase Portrait');
hold off
Mustafa Alajrawee Student No. 40240413006
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Mustafa Alajrawee Student No. 40240413006
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Question (5)
Lyapunov function for the equilibrium point (0,0) of the system with equations
𝑥̇ = −2𝑥 − 𝑦 , 𝑦̇ = −𝑦 − 𝑥
Determine the following. Determine the radius of the disk for which the point
(0,0) is in the domain of attraction.

Solution
The MatLab Code
clear; figure;
% Define the system of equations
sys = @(t,x) [-2*x(1) - x(2)^2; -x(1)^2 - x(2)];

% Plot the phase portrait


xmin = -3; xmax = 3; sep = 0.5;
hold on
for x0 = xmin:sep:xmax
for y0 = xmin:sep:xmax
[ts, xs] = ode45(sys, [0, 10], [x0, y0]);
plot(xs(:,1), xs(:,2))
end
end
for x0 = xmin:sep:xmax
for y0 = xmin:sep:xmax
[ts, xs] = ode45(sys, [0, -10], [x0, y0]);
plot(xs(:,1), xs(:,2))
end
end

% Calculate and plot the Lyapunov function


V = @(x, y) 0.5 * (x.^2 + y.^2); % Lyapunov function

% Plot the level sets of the Lyapunov function


x_range = linspace(xmin, xmax, 100);
y_range = linspace(xmin, xmax, 100);
[X, Y] = meshgrid(x_range, y_range);
Z = V(X, Y);
contour(X, Y, Z, 'LineColor', [0.8, 0.8, 0.8]);

% Plot equilibrium point


plot(0, 0, 'ro', 'MarkerSize', 8, 'MarkerFaceColor', 'r');

% Set plot properties


axis equal;
axis([xmin, xmax, xmin, xmax]);
title('Phase Portrait and Lyapunov Function');
xlabel('x');
ylabel('y');
hold off;
Mustafa Alajrawee Student No. 40240413006
-------------------------------------------------------------------------------------------------------------------------------------------------------------

You might also like