##
Physics 230: Computational Physics

Spring 2011 Assignments (Tentative)

To submit your Assignments, delete the Xcode build folder (if there is one), compress the rest (by choosing File → Compress in the Finder), and email it to

JLindner@Wooster.edu.

Jump to Assignment number

0 .

1 .

2 .

3 .

4 .

5 .

6 .

7 .

8 .

9 .

10 .

11 .

12 .

13 .

14

### Assignment 0 due Wednesday 19 January 2011 (Simulation 1)

In the Pico/Nano UNIX text editor, write C and C++ "Hello world" programs and compile them to exectubles in the Bash UNIX shell. Similarly, write a C++ program that implements the **Euler-Cromer algorithm** for the simple **harmonic oscillator**. Print position as a function of time to the console. Copy & paste into **Igor Pro** and graph.

### Assignment 1 due Monday 24 January 2011 (Simulation 1)

In Xcode, write a simple C++ program that implements the **Euler-Cromer algorithm** for the simple **harmonic oscillator**. Use the **math library** to compute the integration time step and total time as fractions of the oscillator period. Print position and velocity as a function of time to the console. Copy & paste into **Igor Pro** and graph time series and phase space. Repeat after reversing the position and velocity updates. Compare. Write a **function** to compute the oscillator energy. Revise the program to output the percent change in energy, which of course should be constant, for both techniques. Compare. What do you conclude?

### Assignment 2 due Monday 31 January 2011 (Simulation 2)

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 10^{5} or 10^{6} 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?

### Assignment 3 due Monday 7 February 2011 (Simulation 2)

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*.

### Assignment 4 due Wednesday 9 February 2011 (Simulation 3)

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/*r*^{2} 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**.

### Assignment 5 due Monday 14 February 2011 (Simulation 3)

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?

Repeat for a hypothetical 1/*r*^{3} force law.

### Assignment 6 due Monday 21 February 2011 (Simulation 4)

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, where red represents *z*<0, and so on. Demonstrate both **convergence** and **chaos** (extreme sensitivity to initial conditions).

### Assignment 7 due Monday 28 February 2011 (Simulation 5)

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**.

### Assignment 8 due Monday 7 March 2011 (Simulation 6)

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.

### Assignment 9 due Monday 28 March 2011 (Simulation 7)

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.

### Assignment 10 due Monday 4 April 2011 (Simulation 8)

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.

### Assignment 11 due Monday 11 April 2011 (Simulation 9)

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.

### Assignment 12 due Monday 18 April 2011 (Simulation 10)

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.

### Assignment 13 due Monday 25 April 2011 (Simulation 11)

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.

### Assignment 14 due Monday 2 April 2011 (Simulation 12)

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.