*Handouts:* Excerpts from Chaps. 9 and 11 on the nonlinear
oscillator and excerpts from Chap. 14 on chaos, diffeq_oscillations.cpp
printout.

Now that we've got routines to solve differential equations, we're going
to explore some interesting one: nonlinear oscillators. Today we'll
play with a program that solves for the time dependence of such an
oscillator.

*
Your goals for today (and ...):
*

- Finish the plot from Session 6 of relative error at t=1 vs. mesh size h.
- Run a code that solves the differential equation for a (driven) nonlinear oscillator and explore how the time dependence changes as various input parameters change.
- Add friction (damping) to the code.
- Use phase space plots as a tool to analyze the behavior of the oscillator.

Please work in pairs (more or less). The instructors will bounce around 1094 and answer questions.

Spend at most 30 minutes on this.

**Integrating a First-Order Differential Equation.**Do part 7. If you find that the errors for Euler and Runge-Kutta lie on top of each other, most likely you have not evaluated the exact answer at precisely the same time as the last points. If you get stuck, ask an instructor.

The handout with excerpts from Chapters 9 and 11 describe the driven nonlinear oscillator that is coded in diffeq_oscillations.cpp. Note that the force depends on k and an exponent p, the external force has a magnitude f_ext, a frequency w_ext, and a phase phi_ext. The initial conditions in position and velocity are designated x0 and v0. You also have control over the time interval (increase t_end to see longer times), the step size h, and how often points are printed to the file (plot_skip).

- Use make_diffeq_oscillator to create diffeq_oscillator. This
code outputs to the file diffeq_oscillator.dat five columns of
data: t, x(t), v(t), kinetic energy, and potential energy. There are
four gnuplot plot files provided (diffeq_oscillations1.plt, etc.), each
of which generates a different type of plot. Run diffeq_oscillator
with the default values (enter "0" when it says "What do you want to
change?") to calculate a data set.
Start gnuplot and "load diffeq_oscillations1.plt" and then "load
diffeq_oscillations2.plt". (Once you've given these commands
once, you can use just use the arrows to go back and forth.)
Explain the plots to your
partner (i.e., check that you know what is shown in each one and if
they make sense).

- Wouldn't it be convenient to generate all four plots at once in separate files? Load "diffeq_oscillations_all.plt"!
- It's always a question whether or not you have coded a problem
correctly, so you should always seek ways to check your results.
One possibility is if we have a known solution. This works for p=2
(simple harmonic oscillator). What about other p? Another check
is to identify a quantity that shouldn't change with time. Create a
plot of such a quantity (you'll want to increase t_end)
and observe the effect of changing the step size
h to a larger value [e.g., try 10 and 100 times larger].
How do you decide on a reasonable h to use?

(The "plot_skip" parameter indicates how often a point is written to the output file. So plot_skip=10 means that every 10 points is output.) - Verify that different amplitudes (e.g., different initial
conditions determined by x0 and v0) lead to different periods for
an anharmonic oscillator (p<2 or p>2). [Hint: You might find the
"append" option useful.] Can you identify a
qualitative rule? E.g., does larger amplitude mean shorter or
longer period always? Can you explain the rule?

- Go back to the original parameters (quit the program and start
it again), which has p=2.
Now add a driving force
f_ext=10 with w_ext=1 and look at the time dependence and phase-space
plots. Then increase w_ext to 3.14 and then to w_ext=6.28. What
are you observing? Now repeat with p=3 (starting with f=0).
Can you find resonant behavior?

Real-world systems have friction, which means the motion will be damped.
On page 150 of the text (see the back page of the Chap. 9/11 handout)
is a list of three simple models for friction. We'll implement
viscous damping: F_{f} = -b*v, where v(t) is the velocity.

- Introduce the damping parameter "b" into the code:
- add it to the force_parameters structure (with a comment!);
- add it to the list of local force parameters in the main program;
- give it an initial value;
- add a menu item (e.g., [13]) and a case statement to get a new value.

- Modify the "rhs" routine to include damping (you're on your own here!).
- Test your routine starting with p=2 and a small damping and look at both the time dependence and the phase-space plots. Then try some other p values.
- Identify the three regimes described on page 150: underdamped, critically damped, and overdamped.

Now we want to put it all together: a damped, driven, nonlinear oscillator. The excerpt from chapter 14 describes a different system, namely a realistic pendulum, but it has the same basic features.

- On page 191, there is a list of characteristic structures that can be found in phase space, with sample pictures on page 190. Can you find combinations of parameters that produce pictures like these? (Try to imitate the x(t) vs. t pictures first.)

furnstahl.1@osu.edu