Chapter 3: Oscillatory Motion and Chaos

advertisement
PHY 410-505 Computational Physics I
Chapter 3: Oscillatory Motion and Chaos
Lecture 3
Monday September 24, 2007
1
LECTURE OUTLINE
LECTURE OUTLINE
Lecture Outline
Nonlinear, Damped and Driven Pendulum
Small oscillations – harmonic force . . . . . . . . . . . . . . . . .
Nonlinear pendulum . . . . . . . . . . . . . . . . . . . . . . . .
3
3
4
Numerical Codes
C++ Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Mathematica Code . . . . . . . . . . . . . . . . . . . . . . . . .
6
6
9
2
NONLINEAR, DAMPED AND DRIVEN PENDULUM
Nonlinear, Damped and Driven Pendulum
Small oscillations – harmonic force
• A more interesting pendulum model includes damping and driving forces
q is
FD
ΩD
d2θ
g
dθ
= − θ − q + FD sin(ΩD t)
2
`
dt
dt
a damping constant – represents friction and air resistance
is the amplitude of a periodic driving force
is the angular frequence of the driving force
• The damping force causes initial transient behavior
q
Ω2 − q 2/4 t + φ
θ(t) = θ0e−qt/2 sin
p
Ω = g/` is the natural frequency
Transient motion is
◦ underdamped if Ω > q/2
◦ critically damped if Ω = q/2
◦ overdamped if Ω < q/2
3
Nonlinear pendulum
NONLINEAR, DAMPED AND DRIVEN PENDULUM
• After transients have died out the motion is determined by driving force
which supplies energy to overcome frictional forces
• For the small oscillations (linear approximation) the equations can be
solved analytically:
FD sin (ΩD t + φ)
θ(t) = q
(Ω2 − Ω2D )2 + (qΩd)2
Nonlinear pendulum
• The pendulum model becomes even more interesting if the amplitude of
motion is not limited to small oscillation:
dθ
d2θ
g
= − sin θ − q + FD sin(ΩD t)
2
`
dt
dt
The pendulum has an equilibrium point at θ = 0 with the bob
vertically below the pivot point
θ = ±π is the unstable equilibrium point with the bob verically above
the pivot point
In addition to oscillations, the pendulum can now undergo rotational
motion
4
Nonlinear pendulum
NONLINEAR, DAMPED AND DRIVEN PENDULUM
• It is interesting to study the behavior of the pendulum as the driving
force is varied
For small FD , friction dominates and the motion is damped
For large FD , the driving force dominates and the motion is generally
periodic with period determined by ΩD
For intermediate values of FD , there is a complicated interaction
between driving, nonlinearity, and dissipation – for particular
parameter values, the motion becomes chaotic (numerically
unpredictable)
5
NUMERICAL CODES
Numerical Codes
C++ Code
• The following program uses the computational physics library cpl
An an adaptive Runge-Kutta ODE integration routine defined in the
odeint.hpp header file
Vectors defined in vector.hpp
pendulum.cpp
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
#include "vector.hpp"
#include "odeint.hpp"
using namespace cpl;
// vectors with components of type double
// ODE integration routines, Runge-Kutta ...
const double pi = 4 * atan(1.0);
6
C++ Code
NUMERICAL CODES
const double g = 9.8;
// acceleration of gravity
double L = 1.0;
double q = 0.5;
double Omega_D = 2.0/3.0;
double F_D = 0.9;
bool nonlinear;
//
//
//
//
//
length of pendulum
damping coefficient
frequency of driving force
amplitude of driving force
linear if false
Vector f(const Vector& x) { // extended derivative vector
double t = x[0];
double theta = x[1];
double omega = x[2];
Vector f(3);
// Vector with 3 components
f[0] = 1;
f[1] = omega;
if (nonlinear)
f[2] = - (g/L) * sin(theta) - q * omega + F_D * sin(Omega_D * t);
else
f[2] = - (g/L) * theta - q * omega + F_D * sin(Omega_D * t);
return f;
}
int main() {
cout << " Nonlinear damped driven pendulum\n"
<< " --------------------------------\n"
7
C++ Code
NUMERICAL CODES
<< " Enter linear or nonlinear: ";
string response;
cin >> response;
nonlinear = (response[0] == ’n’);
cout<< " Length of pendulum L: ";
cin >> L;
cout<< " Enter damping coefficient q: ";
cin >> q;
cout << " Enter driving frequencey Omega_D: ";
cin >> Omega_D;
cout << " Enter driving amplitude F_D: ";
cin >> F_D;
cout << " Enter theta(0) and omega(0): ";
double theta, omega, tMax;
cin >> theta >> omega;
cout << " Enter integration time t_max: ";
cin >> tMax;
double dt = 0.05;
double accuracy = 1e-6;
ofstream dataFile("pendulum.data");
double t = 0;
Vector x(3);
x[0] = t;
8
Mathematica Code
NUMERICAL CODES
x[1] = theta;
x[2] = omega;
while (t < tMax) {
adaptiveRK4Step(x, dt, accuracy, f);
t = x[0], theta = x[1], omega = x[2];
if (nonlinear) {
while (theta >= pi) theta -= 2 * pi;
while (theta < -pi) theta += 2 * pi;
}
dataFile << t << ’\t’ << theta << ’\t’ << omega << ’\n’;
}
cout << " Output data to file pendulum.data" << endl;
dataFile.close();
}
Mathematica Code
9
Download