Wednesday 3:30-5:30, 201 VAN

2 units

This Fall 2008 I will teach a course on programming in C++ for physics, which will be offered as 029:103, Reading in Physics, and open to both undergraduate and graduate students. It will be primarily a course in programming as opposed to algorithms for solving problems, and as such will be complementary to the Computational Physics course offered in Spring 2009. The course will focus on practical C++ programming to solve computationally challenging physics problems. In addition to the C++ language, we will cover debugging, performance, and optimization. Depending on student interest, we may also cover more advanced topics such as parallel programming.


Book: There is no required text, but I recommend "C++ and Object-Oriented Numeric Computing for Scientists and Engineers" by Daoqi Yang.

Assignments: There will be programming assignments due every two weeks, in keeping with the 2 units of credit for the course.

Class materials:
Homework assignments
  • hw2
  • hw3
  • hw4: using pmain.cc with Particle.h plot trajectories x(t) as a function of the time step
  • hw5: Write a program to compute the motion of Earth around the Sun by integration of the equations of motion in 3D. Read the initial conditions from a file. For initial conditions with z=0, v_z = 0, output the trajectory to a file with 2 columns x(t) y(t), and plot the result.
  • hw6: Write classes Field and Site to use with this program. Modify the program to solve Poisson’s equation using relaxation by computingPasted Graphic 1 at each site in the grid, and then repeating until the solution changes by less that some amount that you specify. In the equation above, D is the number of dimensions, Pasted Graphic 2is the grid spacing, Pasted Graphic 3 is the dielectric constant, Pasted Graphic 5 is the charge density, and Pasted Graphic 4 is the potential being solved for. The main.cc above includes functions to initialize the charge density, and print V(x) along a line.