Physics 503

Scientific Computing
Dr. Gladden
Course News and Homework Assignments

Note: If your having trouble viewing the pdf files linked here, try right-clicking the link and select
"Save link as ..." to copy the file onto your local hard drive.  Then open it up in Acrobat.
You also may want to update your Internet Explorer and/or Acrobat Reader -
or try a different browser like Firefox!
Don't forget to click "Reload" in your browser to make sure you are viewing the latest information!


Date Posted
Date Due
Comment, Assignment, or News
4/23 -- There will be no homework for next week.  Get to work on your final projects!!

Here are links to a good general introduction to Parallel Computing which is put out by Lawrence Livermore National Lab. ( LLNL weblink , get the PDF )

Here is a link to a python implementaion of MPI called pyMPI  ( to download, documentation )
4/17 -- I am posting the object oriented scripts we looked at yesterday.  Take a close look at the super and subclasses example in the "shapes.py" file and it's related test script.  I got the inheritance fixed up.  

 HW8 on the Vector object will be due next Wednesday.

Don't forget to be thinking about what topics you'd like to see in the remaining few weeks.  Email them to me soon so I can prepare.  Some options are: parallel programming, tour of Mathematica, molecular dynamics simulations (this is complicated, but I can show you the basics of a standard MD package), or we can expand on a topic we've already discussed, ....

Finally, please get a 1 paragraph description of your ideas on a final project to me by next Wednesday.  
The final project will be due by the end of exam week.
4/9 -- Someone had asked me about the Gnuplot script for plotting the "error surface" I showed you in class as an example to surface plots in Gnuplot.  Here it is: err_surf.plt.  Open Gnuplot and load this script (from File menu or as: load 'err_surf.plt' at the gnuplot prompt.

Again, if you have opinions or thoughts on topics you'd like to see for the remaining weeks, let me know!  (see some ideas below)
4/9 -- Here is the gausselim.py script we looked at in class.  You can either import it from another script or run it from within ipython and then play with gausselim(a,b) function.

I've also fixed that bug in the gendata script (linked below).

For HW due next Wed., in Kiusalaas do Excercises 1, 4, 5, 6 in Problem set 2.1.
Also, find some problem in you field in which you must solve multiple equations for multiple unkowns and the gausselim to solve it.  Examples might be currents in a complicated circuit, or fixed points in a set of ODEs.
4/2 4/9 Here is a new HW assignment on Nonlinear fitting and fourier transforms.  Some related programs you might find helpful are:
  • fitting1.py - Python nonlinear fitting (Requires Scientific module)
  • gnuplot_nlfitting.plt - a Gnuplot script to perform a nonlinear fit (see comments)
  • fft.py - Python program to compute the FFT and Power spectrum of a time based data set.
Here are links to download and get info on:

If you have not yet turned in your midterm project, get it to me ASAP!
3/26 Here are the regression related scripts we worked on today:
  • gendata.py - generates noisy data and dumps to a file.  I fixed the argument parsing.  Type 'python gendata.py -h' to see the options (or look at the code).
  • linfit.py - my version of the program you wrote in class today
  • fitting1.py - example of a non-linear fit of a damped SHM data using the fitting module provided  by Scientific Python (their website).  You'll need this data file.
Don't forget you need to turn in you project next Wednsday.  I'm holding off on HW until the projects are done.
3/19 Here is the roots module for computing the roots of an equation.
3/5 -- Here are the Pendulum (verlet), Lotka-Volterra, and Lorenz programs.
2/22 2/27 I have posted the scripts we looked at in class on the Romberg Method and Euler Method for initial value problems.

For HW due Wednesday, do the following:
  1. Write a script comparing the timing (use the "time" module) and accuracy of the romberg method versus the regular trapeziod method.  Try it out for several functions of your choosing.
  2. Use the Euler-Cromer method to compute the angular displacement as a function of time for a simple pendulum for a range of amplitudes (5 - 120 degrees). In Euler-Cromer, you simply update the position at each time step with the newly updated velocity rather than the old velocity (see the Euler script above).  Compare the results with the small angle approximation for a pendulum. You may want to normalize your displacements with respect to the amplitude when plotting curves for comparison.
2/14 -- I have posted some of the scripts we've been looking at in class:

For HW04, do the following problems in the book from Problem set 6.1 (p.212):
  1. # 5 - Use the trapezoid and Simp. 1/3 methods to solve the problem with the Force(displacement) data provided.  Also, use polyfit() to fit that data with a polynomial and compute the analytical integral.  Compare the results.
  2. # 11 
  3. # 13
As usual, these will be due by the beginning of class next Wed.

Please make sure to get me any overdue homeworks - even if they are not working exactly as you would like.  I know many of you have been having trouble with the animations - don't worry about that.  You script should still be able to write the frames to a series of files.
2/8 -- Here is some of the numerical derivative code we were looking at in class:
(right click on these links and choose "Save File..." to save to your disk)

derivs.py
derivs2.py
derivs3.py
2/7 Here is HW#3 (download a PDF).

I also have posted my solutions to HW02.

You should be reading Chap. 5 on Numerical Differentiation.
1/30 2/6 HW#2 was handed out in class, due 2/6 by beginning of class.  Here it is:

  1. If you did not get HW1 completely working, get all parts of that done. Add a timing profile using the 'time' module.

  2. Write programs to:

    • Plot 2 different functions in a 2x1 subplot. You choose the functions, but don't use the ones done in class. Make sure the plots each have titles and labeled axes and specify different colors and markers (or line types) for each plot.
      Add a second Figure which is a polar plot of two different ellipses with different eccentricities and include a legend (you will need to fiddle with this to get a good position).

    • Plot an animation (over two full cycles) of a simple wave on a string fixed at both ends. Have an option to save each frame as a 'png' file for later playback.

    • Plot a vector plot showing the electric field of a dipole. Use color coding to indicate the magnitude of the E field.

I have also posted (and will post) the code snippets I show you in class.  These files are NOT full programs, just snippets of code to copy and paste and run.

1/23 1/30 I will hand out HW#1 in class today, but here it is if you lose the sheet.

email your working code to jgladden_at_phy.olemiss.edu


HW#1

Write functions to:

  1. generate a list of N random numbers with a Gaussian distribution.
    (use the random module)

  2. compute the standard deviation of those numbers.

  3. generate a histogram of a list of numbers.
    (args-> list of numbers, bin size, optional -> low and high cutoffs)

Document all functions with doc strings!!

You MAY NOT use the built in histogram functions in pylab (or other packages).

Write the histogram data to a tab deliminated text file for 4 different lists with different standard deviations, but the same number of total points and same average value.
(This could be 4 different files or 1 file with multiple columns)


You MAY use the built in “save” and “load” functions in pylab.

Read the all the histogram data into Python arrays and plot the 4 histograms with different colors on one plot. Include x and y labels, a title, and a legend indicating the appropriate stdev.


1/17 We have devided to meet for one 2 hour chuck each week.  We'll meet Wed. 3:00 - 5:00 in the Astro Lab (Lewis 1).

Go ahead and get a copy of the textbook if you haven't already.  It's a pretty good book to have on your shelf.

Before we meet next week, read through Chap. 1 in the book on Python basics and work through and expand some of the examples in that chapter.  Try to write a simple python function which takes an array of numbers and returns their average.

You can load Python on your computer (along with the other libraries we'll be using).  I posted links to these sites on the Resources page for this course.  Also posted there are several general Python reference guides and other useful stuff.

1/16           


Welcome to "Introduction to Scientific Computing" with Dr. Gladden! This is the page to which you should refer most often.  It is where I will post homework assignments, make announcements,  and will be my primary mode of communication with you (other than lectures of course!).  Make sure to take a good look at the course syllabus and let me know if there is anything you do  not understand.