Solving the Duffing Equation with ODE45

  • Context: MATLAB 
  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    Ode45
Click For Summary
SUMMARY

The discussion focuses on solving the Duffing equation using MATLAB's ODE45 function to replicate a specific phase portrait. The parameters defined include damping (delta = 0.3), stiffness (alpha = -1), restoration nonlinearity (beta = 1), driving force angular frequency (OMEG = 1.2), and forcing (gamma = 0.2). The user identifies an issue with the initial conditions not aligning with the expected phase portrait, suggesting that the simulation must run for a longer duration to capture the cyclic behavior accurately.

PREREQUISITES
  • Understanding of the Duffing equation and its parameters
  • Familiarity with MATLAB programming and ODE45 function
  • Knowledge of phase portraits in dynamical systems
  • Basic concepts of initial conditions in differential equations
NEXT STEPS
  • Review MATLAB's ODE45 documentation for advanced usage
  • Explore the effects of varying parameters in the Duffing equation
  • Learn about phase portrait analysis in nonlinear dynamics
  • Investigate initial condition strategies for better simulation results
USEFUL FOR

Mathematicians, physicists, and engineers interested in nonlinear dynamics, particularly those working with differential equations and simulations in MATLAB.

member 428835
Hi PF

I am trying to replicate the phase portrait at the bottom right of this page: https://en.wikipedia.org/wiki/Duffing_equation

What I have is this:
Code:
global delta alpha beta gamma OMEG
delta   = 0.3;  % DAMPING
alpha   = -1;   % STIFFNESS
beta    = 1;    % RESTORATION NONLINEARITY
OMEG    = 1.2;  % DRIVING FORCE ANGULAR FREQ
gamma   = 0.2;  % FORCING

Fs = 100;       % Sampling frequency                    
T  = 1/Fs;      % Sampling period       
L  = 10000;     % Length of signal

[t, x]  = ode45(@duffing,(0:L-1)*T,[0 1]);

[~, idx] = min( abs( t-OMEG/(2*pi)*38 ) );

plot(x(1:idx,2),x(1:idx,1))
title('phase space')
xlabel('position')
ylabel('velocity')

and the function ode45 calls is

Code:
function xdot = duffing(t,x)
global delta alpha beta gamma OMEG
xdot(1) = -delta*x(1) - alpha*x(2) - beta*x(2)^3 + gamma*cos(OMEG*t);
xdot(2) = x(1);
xdot    = xdot';
end

For these parameter values I should get a cyclic phase portrait, but I don't. Can you see why?
 
Physics news on Phys.org
Sheesh don't know how to delete this but I just realized they must be going from a long time out, not t=0 as shown, since their IC doesn't align to the phase portrait.
 

Similar threads

  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K