Physics 377: Computational Physics
Spring 2008 Exercises
Jump to exercise number
01 .
02 .
03 .
04 .
05 .
06 .
07 .
08 .
09 .
10 .
11 .
12 .
13 .
14 .
15
Exercise 1 due Tuesday 22 January 2008
In Xcode, write a simple C++ program that implements the Euler-Cromer algorithm for the simple harmonic oscillator. Print position as a function of time to the console. Cut & paste into Igor Pro and graph. Repeat after reversing the position and velocity updates. Compare. Revise the program to output the percent change in energy, which of course should be constant, for both techniques. Compare. What do you conclude?
Exercise 2 due Tuesday 29 January 2008
In Xcode, write a C++ program that implements the Euler-Cromer algorithm for a damped, forced Duffing oscillator. Scan in the forcing amplitude and frequency, as well as the number of sample points. Store the sampled position and velocity in arrays, create a unique file name from the input parameters, and write the samples to a file once at the end. Plot the data in Igor Pro. Demonstrate periodic and aperiodic (actually chaotic) behavior for different parameters. Compare the time to write 105 or 106 sampled points one line at at time versus once at the end. Overlay the output when updating time using t = n*dt and t += dt in the aperiodic (and chaotic) regime. What do you conclude?
Exercise 3 due Thursday 31 January 2008
In Xcode, write a C++ program that implements the Euler-Cromer algorithm for a damped, forced Duffing oscillator. Divide your program into small functions and header (.h) and implementation (.cpp) files. Scan in the forcing amplitude, frequency, and phase, as well as the option to output either a flow or section. Incorporate the input options into the output file name. Include a file header that Igor Pro can interpret as wave names. Plot a layout for a sequence of sections of strange attractors at different phases. Feel the wave.
Exercise 4 due Tuesday 5 February 2008
In Xcode, write a C++ program that implements the Euler-Cromer algorithm for the Kepler problem of the motion of a mass in a spherical 1/r2 gravitational force field. Use 2D arrays to hold the position and velocity components of the mass. Scan in the initial speed and number of data points. Output the components of the position for one period to a labelled file with a header. In Igor Pro, superimpose several orbits for slightly different initial speeds, coloring the the trajectory according to the time. Also output and plot the energy per unit mass and angular momentum magnitude per unit mass for large and small integration time steps to demonstrate convergence.
Repeat for a hypothetical 1/r3 force law.
Exercise 5 due Thursday 7 February 2008
In Xcode, write a C++ program that implements the Euler-Cromer algorithm for the Kepler problem. Use structures to store position and velocity components. Output the data in chunks. Print the time required for each run in the console. Experiment with a variable time step that reduces the integration step near the central force where speeds are high: Can you simultaneously increase the accuracy of the integration for an eccentric orbit and reduce the computation time?
Can the variable time step help the Euler algorithm?
Exercise 6 due Tuesday 12 February 2008
In Xcode, write a C++ program that implements the Euler-Cromer algorithm for the 3D motion of a tiny projectile in the gravity of a binary star system. This is the famous restricted 3-body problem. Assume the stars move in circular orbits and are unaffected by the gravity of the projectile. Release the projectile from rest directly above the center-of-mass of the stars. Scan in the release height. Use structures to store position and velocity components. While energy is not conserved in this model system, a pseudo-energy known as the Jacobi constant is, so use it to check the accuracy of your numerical integration. Create xy plots of the trajectories in Igor Pro and color them with a red-white-blue palette according to the z-coordinate. Demonstrate both convergence and chaos (extreme sensitivity to initial conditions).
Exercise 7 due Tuesday 19 February 2008
Use Xcode and Interface Builder, along with Obj-C++ and the Cocoa APIs, to write a professional-looking Calculate app. Create a single CalculateObject to coordinate the following
widgets: text fields, sliders, radio buttons, check boxes, plus one other widget of your choice.
To submit your project, delete the build folder, compress the rest (by choosing File → Compress in the Finder), and email it to
JLindner@Wooster.edu.
Exercise 8 due Tuesday 26 February 2008
Use Xcode and Interface Builder, along with Obj-C++ and the Cocoa APIs, to create a simulation of
waves on a string. Enable the user to pause or reset the
animation, toggle the
initial conditions between a stationary pulse and a solitary moving pulse, toggle the
boundary conditions between fixed or free, change the string colors and the background using
color wells, change the string width using a
slider.
To submit your project, delete the build folder, compress the rest (by choosing File → Compress in the Finder), and email it to
JLindner@Wooster.edu.
Exercise 9 due Tuesday 4 March 2008
Use Xcode and Interface Builder to create a dynamic simulation of energy
eigenvalues & eigenfunctions in a three-piece-wise constant potential. For each energy, numerically integrate the
time-independent Schrödinger equation to
shoot the wave function from left to right across the potential. Enable the user to dynamically reset the left, center, and right potentials, the energy level, and the wave function scaling, by
click-and-drag. Provide feedback by displaying the arrow, open hand, and closed hand
cursors, as appropriate.
Play a (short) sound each time the wave functions passes through a normalizable eigenfunction.
To submit your project, delete the build folder, compress the rest (by choosing File → Compress in the Finder), and email it to
JLindner@Wooster.edu.
Exercise 10 due Tuesday 25 March 2008
Use Xcode and Interface Builder to create an interactive simulation of a quantum wave packet
scattering from a three-piecewise-constant potential in 1+1 dimensions by numerically integrating the
time-dependent Schrödinger equation. Enable the user to vary the wave fuction scaling and animation speed, as well as the potential and the initial wave packet. Automatically reset the simulation before the wave packet is reflected from the walls of the universe, which is larger than the view. Enable the user to
resize and open and close the window. Add a custom
application icon and about box.
To submit your project, delete the build folder, compress the rest (by choosing File → Compress in the Finder), and email it to
JLindner@Wooster.edu.
Exercise 11 due Tuesday 1 April 2008
Use Xcode and Interface Builder to create an interactive simulation of the 2D
Ising Model of ferromagnetism by implementing the Monte Carlo
Metropolis algorithm. Enable the user to vary the temperature above and below the critical
Curie temperature. Perform and report timing tests comparing NSRectFill() drawing and
bitmap drawing, and implement the faster of the two. Enable the user to save the view as a PDF and save magnetization and energy as a function of time to a text file that can be easily read by Igor Pro. Add a custom
application icon and about box.
To submit your project, delete the build folder, compress the rest (by choosing File → Compress in the Finder), and email it to
JLindner@Wooster.edu. Report your drawing timing data in the body of your email.
Exercise 12 due Tuesday 8 April 2008
Use Xcode and Interface Builder to create an interactive simulation of a forced, damped
Duffing oscillator that displays the phase space flow once per period, a
Poincaré section. Animate the section as a function of the phase of the forcing. Enable the user to toggle among five different integration algorithms:
Euler-Cromer and first through fourth-order
Runge-Kutta. Add integer sliders with slaved text fields to control the transient, integration time step, number of points. Add floating point sliders with slaved text fields to control the drawing scale, and the amplitude and frequency of the forcing. Add a
circular slider to control the phase of the forcing and a linear slider to control the speed of the animation. Add a custom
application icon and about box.
To submit your project, delete the build folder, compress the rest (by choosing File → Compress in the Finder), and email it to
JLindner@Wooster.edu. Compare and contrast the speed and accuracy of the integration algorithms in the body of your email.
Exercise 13 due Tuesday 15 April 2008
Use Xcode and Interface Builder to create an interactive simulation of a precessing and nutating
symmetric top shaped like cone spinning on a point fixed in a plane of user-defined translucency. Create the animated graphics using
OpenGL APIs. Allow the user to rotate the graphics using a
virtual track-cylinder. Integrate the equations of motion using the Euler-Cromer algorithm with a user-defined integration time step. Enable the user to adjust the initial Euler angles (that control pitch, roll, and yaw) and their time rates of change using text fields. Enable the user to adjust the field of view, depth zoom, and animation rate using sliders. Add a custom
application icon and about box.
To submit your project, delete the build folder, compress the rest (by choosing File → Compress in the Finder), and email it to
JLindner@Wooster.edu.
Exercise 14 due Tuesday 22 April 2008
Use Xcode and Interface Builder to create an interactive simulation of a
bike wheel gyro. Use
OpenGL to carefully draw the bike wheel, including axle tip, shaft, and cap, tire, wheel, and spokes, all resting on a conical pivot and translucent plane. Make the axle and wheel shiny but the tire dull.
Implement 4th order
Runge-Kutta integration employing a derivatives method. Enable the user to save the parameters to a text file and reopen them later. Add a custom
application icon and about box.
To submit your project, delete the build folder, compress the rest (by choosing File → Compress in the Finder), and email it to
JLindner@Wooster.edu.
Exercise 15 due Tuesday 29 April 2008
Use Xcode and Interface Builder to create an interactive simulation of energy redistribution in an
anharmonic chain. This is the famous first modern computational experiment, devised by Fermi, Pasta, & Ulam and coded by Tsingou on the Los Alamos MANIAC computer. Enable the user to choose the initial linear mode of the chain and the nonlinearity of the coupling. Animate the chain to illustrate
recurrences. Optionally display the energy per mode as a
translucent histogram superimposed on the chain. Include a rich text formatted window with information on the FPU problem.
To submit your project, delete the build folder, compress the rest (by choosing File → Compress in the Finder), and email it to
JLindner@Wooster.edu.