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:
- lecture 2 slides
- lecture 3 sample code
- lecture 4 sample code
- lecture 5 sample code: Vec3.h vector.h vector.cc ode.cc
- lecture 6 sample code: multiplication without temporary objects: Sax.h SaxMain.cc
- lecture 7: sorting: sort.cc buffer: bmain.cc Buffer.h
- lecture 8: e1.cc e2.cc e3.cc e4.cc e5.cc e6.cc multin.cc p1.cc f1.cc
- lecture 11: main11.cc Particle.h Extrap.h
- lecture 12: iostreams.cc fstream-1.cc fstream-2.cc fstream-3.cc stringstream.cc binary.cc string.cc
- lecture 14: ising.cc LCG.h
- lecture 15: MCAccumulator.h CircularBuffer.h
- 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 computing
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,
is the grid spacing,
is the dielectric constant,
is the charge density, and
is the potential being solved for. The main.cc above includes functions to initialize the charge density, and print V(x) along a line.
