The executable code you need is in ~p6730/exercises/ode. It is already compiled.
This code solves the differential equation
d2y/dt2 = -sin(y) - 1/q dy/dt + g cos(wd t).
The variable y is the angle of the pendulum from vertical
(downward) equilibrium. dy/dt is the angular velocity. The
coefficients q, g, and
wd come respectively from the damping, driving
strength (not to be confused with gravitational acceleration), and
driving frequency. The initial conditions are specified by the
starting angle and angular velocity at time t = 0. We are
interested in finding the angle at some later time Tmax. We
might also be interested in knowing the angle at all times between
t = 0 and t = Tmax.
q g wd y(0) dy/dt(0) Tmax dt epswhere eps controls the desired accuracy (used only for anhrkqc and anhbust).
So you can visualize the result, run it like this:
anhrk4 < data_chaos > out.rk4
The output file out.rk4 has three values per line. The first
is the current time, the second, the current value of y, and
the third, the current value of dy/dt. Use gnuplot to
plot y vs t.
Describe what you see. How does this behavior differ from the usual transient decay to a steady state behavior for a driven, damped oscillator?
What differences do you see between the results? What are the final values of y and dy/dt? Report these numbers in your answer file. How many steps were taken? Report these numbers. What about the number of calls to anhderivs, which evaluates the rhs of the ODE? This is a measure of the computational effort. Report this number. Try comparing two plots by using the gnuplot command
plot 'out.bust' using 1:2 with lines, 'out.rk4' using 1:2Notice that the anhbust integration is tracking the rk4 solution quite well, but with much bigger jumps.
For a different perspective, try a phase space plot of y vs dy/dt with
plot 'out.bust' using 2:3 with lines, 'out.rk4' using 2:3