Duff Ing
Duff Ing
The Duffing equation is an externally forced and damped oscillator equation. It is given by
.
We will investigate the equation by turning on a few constants at a time. We begin with simple harmonic motion:
0.
clear
alpha = 1; delta = 0; beta = 0; % SHM
duffing = @(t,y) [y(2); -delta*y(2)-alpha*y(1)-beta*y(1).^3];
tspan = [0 30];
y0 = [0 0.01]';
[t,y] = ode45(duffing,tspan,y0);
plot(t,y)
legend({'y','dy/dt'})
xlabel('t')
ylabel('y')
title('Simple Harmonic Motion')
figure
plot(y(:,1),y(:,2))
xlabel('x')
1
ylabel('y')
title('SHM Trajectory')
axis equal
clear
alpha = 1; delta = 0.1; beta = 0; % damped SHM
duffing = @(t,y) [y(2); -delta*y(2)-alpha*y(1)-beta*y(1).^3];
tspan = [0 30]; % tspan = 0:.1:30; % Makes solution smoother
y0 = [0 0.1]';
[t,y] = ode45(duffing,tspan,y0);
plot(t,y)
legend({'y','dy/dt'})
xlabel('t')
ylabel('y')
title('Damped Simple Harmonic Motion')
2
figure
plot(y(:,1),y(:,2))
xlabel('x')
ylabel('y')
title('Damped SHM Trajectory')
axis equal
3
Now, consider the undamped Duffing equation As a first order system, we have
clear
alpha = -1; delta = 0; beta = 1; % Undamped Duffing Equation
duffing = @(t,y) [y(2); -delta*y(2)-alpha*y(1)-beta*y(1).^3];
tspan = [0 10];
y0 = [1 1]';
[t,y] = ode45(duffing,tspan,y0);
plot(t,y)
legend({'y','dy/dt'})
xlabel('t')
ylabel('y')
title('Undamped, Unforced Duffing Equation')
4
figure
plot(y(:,1),y(:,2))
xlabel('x')
ylabel('y')
title('Duffing Equation Trajectory')
axis equal
5
Its useful to look at the phase plot using the quiver function. N is used to normalize the arrows in the direction
field. The first plot shows one trajectory.
hold on
plot(y(:,1),y(:,2),'r')
hold off
xlabel('x')
ylabel('y')
title('Duffing Equation Quiver Plot')
6
The following shows how to add several trajectories.
hold on
for j=1:5
y0 = [1 j/5]';
[t,y] = ode45(duffing,tspan,y0);
plot(y(:,1),y(:,2),'r')
end
hold off
7
Now, we add back some damping. Changing the initial condition, y0 = [1 1]'; will reveal different types of
behavior.
clear
alpha = -1; delta = 0.1; beta = 1; % Damped Duffing Equation
duffing = @(t,y) [y(2); -delta*y(2)-alpha*y(1)-beta*y(1).^3];
tspan = [0 30];
y0 = [1 1]';
[t,y] = ode45(duffing,tspan,y0);
plot(t,y)
legend({'y','dy/dt'})
xlabel('t')
ylabel('y')
title('Damped Duffing Equation')
8
figure
plot(y(:,1),y(:,2))
xlabel('x')
ylabel('y')
title('Duffing Equation Trajectory')
axis equal
9
Here we add the forcing.
clear
alpha = -1; delta = 0.1; beta = 1; gamma = .1; omega=1.4; % Forced DE
duffing = @(t,y) [y(2); -delta*y(2)-alpha*y(1)-beta*y(1).^3+gamma*cos(omega*t)];
tspan = 0:0.1:200;
y0 = [0,0]';
[t,y] = ode45(duffing,tspan,y0);
plot(t,y)
legend({'y','dy/dt'})
xlabel('t')
ylabel('y')
title('Damped, forced Duffing Equation')
10
figure
plot(y(:,1),y(:,2))
xlabel('x')
ylabel('y')
title('Duffing Equation Trajectory')
axis equal
11
We can examine the tail of the trajectory and notice a periodic behavior with period
12
T=2*pi/omega
T = 4.4880
13
figure
plot(y(:,1),y(:,2))
xlabel('x')
ylabel('y')
title('Duffing Equation Trajectory')
axis equal
14
% Plot tail of trajectory
figure
L=length(y(:,1));
Npts=180; % Npts+1 points of the tail
%plot(y(L-Npts:L,1),y(L-Npts:L,2))
plot(y(L-90:L,1),y(L-90:L,2)) % 90*.1=period - double before
xlabel('x')
ylabel('y')
title(['Tail of Trajectory \gamma = ',num2str(gamma)])
axis equal
15
% Try gamma = 0.338 but 0.35 is chaotic region
figure
L=length(y(:,1));
Npts=180; % Npts+1 points of the tail
plot(y(L-Npts:L,1),y(L-Npts:L,2))
xlabel('x')
ylabel('y')
title(['Tail of Trajectory \gamma = ',num2str(gamma)])
axis equal
16
Can we find period 8? Maybe near
figure
L=length(y(:,1));
Npts=360; % Npts+1 points of the tail
plot(y(L-Npts:L,1),y(L-Npts:L,2))
xlabel('x')
ylabel('y')
title(['Tail of Trajectory \gamma = ',num2str(gamma)])
axis equal
17
Possibly for there is only chaos.
clear % - Chaos?
alpha = -1; delta = 0.1; beta = 1; gamma = .35; omega=1.4; % Forced DE
duffing = @(t,y) [y(2); -delta*y(2)-alpha*y(1)-beta*y(1).^3+gamma*cos(omega*t)];
NT = 10000;
tspan = 0:0.1:NT;
y0 = [0,0]';
[t,y] = ode45(duffing,tspan,y0);
figure
L=length(y(:,1));
Npts=NT; % Npts+1 points of the tail
plot(y(L-Npts:L,1),y(L-Npts:L,2))
xlabel('x')
ylabel('y')
title(['Tail of Trajectory \gamma = ',num2str(gamma)])
axis equal
18
Let's look at a Poincaré Surface of Section for .
% Strange Attractor
clear
alpha = -1; delta = 0.1; beta = 1; gamma = .35; omega=1.4;
%alpha = -1; delta = 0.25; beta = 1; gamma = .40; omega=1; % Standard Shape
%alpha = -1; delta = 0.2; beta = 1; gamma = .30; omega=1; % Standard Shape
figure
scatter(P_x,P_y,'.')
xlabel('Position');
ylabel('Velocity');
title('Poincaré Surface of Section');
19
Here we add more initial conditions and find the same attractor. In fact, it is a strange attractor.
20
A more standard strange attractor for the Duffing equation is found using a unit amplidute. Here are two
possibles cases with varying parameters.
% Strange Attractor
clear
alpha = -1; delta = 0.25; beta = 1; gamma = .40; omega=1; % Standard Shape
%alpha = -1; delta = 0.2; beta = 1; gamma = .30; omega=1; % Standard Shape
figure
scatter(P_x,P_y,'.')
xlabel('Position');
ylabel('Velocity');
title('Poincaré Surface of Section');
21
22