Home | Syllabus |
Spring Semester 2015
Introduction to computational physics
Evolving Provisional Agenda
1) Monday August 24th
A) Short introduction to Unix
What an operating system is.
Unix is a family of operating systems and linux is one of its clones.
See this Introduction to Linux by Machtelt Garrels.
2) Wednesday August 26th
That's it, we got started and were able to play with basic unix commands.
I wrote a quick list of the commands we saw together
Together, we wrote a couple of scripts: mynameis and nthline . We turned them into executable files by using the command "chmod +x mynameis" for example.
Lab01: your mission. You will need this file. Here is the solution script wordcount
3) Monday August 31st
B) Short introduction to Unix
There are many tutorials and ressources online. Here is one of them.
In a directory Lab02, download the following files: intro.cpp and Makefile
We started editing the program intro.cpp and we ended up with this version in which I inserted a few comments for you to go back to: intro_2015_08_31.cpp
4) Wednesday September 2nd
We continued editing the program intro.cpp: intro_2015_09_02.cpp
*) Monday September 7th (Labor day)
5) Wednesday September 9th
Quick test (15 minutes) on Unix commands. Here are the answers to the test questions.
After the test, we continued working on our program. The current version is intro_2015_09_09.cpp.
At this point, you should now be working on the Lab02 mission.
Lab02: your mission. Here are my solutions. See functions factors and factorsbis
6) Monday September 14th
Command line arguments are for you too and we are going to see how to use them.
We did not do much on the code today. I just added the handeling of commande line argulments.
My current version of the code at this point is here: intro_2015_09_14.cpp
We spent most of the class helping with Lab02.
7) Wednesday September 16th
We take on a bigger project now and start coding a hangman game. The goal is to continue to learn more c-programming and at the same time to start breaking down a biggish project into simpler, independent, specialized tasks. For this we will start by going through the outline or organigram I prepared for this project.
In a folder "Lab03" download the following files:
As we started implementing this game, one of you asked about de Morgan law. It is worth reading this if you are not familiar with it.
Here is my code at the end of class with a bunch of comments added for your reference: hangman.cpp_2015_09_16
Lab03: your mission Solution: This guess.cpp is the file containing the number guessing game function. It is included in the hangman.cpp_2015_09_23 version of the hangman game.
8) Monday September 21st
We kept working on hangman.cpp. My code at the enf of class was hangman.cpp_2015_09_21
Lab03b: your mission solutions: readnthword.cpp
9) Wednesday September 23rd
Quick test on C-programming commands. Answers to the questions of the test are here.
After the test we completed the hangman game. My version is here: hangman.cpp_2015_09_23. The only missing element is the function readnthword() which you are writing as an exercise for Lab03b.
More details on variable declarations with examples in types.c
10) Monday September 28th
More details on variable declarations with examples in types.c continued.
Structures for more complex objects
We are going to write a number of functions to manipulate complex numbers. Here is the list of functions we will write: complex number functions list.
The functions implementing complex number operations we will write will be all collected in complex.cpp and they can be used in mandelbrot.cpp which can be compiled using this Makefile
In order to have everything look pretty, write your function in this template.
I collected all the functions you wrote and regrouped them in a file cmplx.cpp. I have not noticed any problem but this does not guaranty the reliability of these functions. Use them at your own risks.
11) Wednesday September 30th
We are going to produce images. In order to see how the PGM format works I have created this small 4 pixels by 5 pixels picture file by hand. You can view it using gimp. Using the PPM format, we can also deal with colour pictures and I wrote this example by hand.
We will then review a few functions I wrote to play with black and white pictures. You can find these functions here.
Lab04: Your mission. You will need the functions to deal with complex numbers which I will have posted by the time you need it. You will also need the functions to manipulate black and white images. You should be obtaining pictures looking like this one. By modifying my solution to this lab, I was able to produce this images of a region of the Mandelbrot set.
12) Monday October 5th
Mandelbrot set continued
Images can be chained in time to produce an animation or a movie such as this one representing a two dimentional Diffusion Limited Aggregation. The animation was produced by the program growth.cpp, which make use of pgmtools.h and pgmtools.c and can be compiled using Makefile.
13) Wednesday October 7th
Not so scarry pointers
We went through some illustrations of pointers while writing a little demonstration program starting from pointers_00.cpp. At the end of class, my program was like this and I added a few comments for your reference.
Linked lists provide a great opportunity to play with both structures and pointers. In your directory Lab05, download the following files list_example.cpp, linkedlist.h, linkedlist.cpp and Makefile. We will review linked lists and their implementation in these files.
*) Monday October 12th (Fall break)
*) Wednesday October 14th (Fall break)
14) Monday October 19th
Not so scarry pointers and linked lists: review to recover from the break
Lab05: Your mission and here is the solution linkedlist.cpp.
15) Wednesday October 21st
The ++ in C++
The main concept setting a difference between C++ ad plain good old C is the concept of class. To ilustrate what classes are, we are going to look at an example I wrote to manipulate colour images in the PPM format.The files I will be using for this are ppmtools.cpp, testppm.cpp and Makefile. The testppm.cpp program is revisinting the Mandelbrot set but this time it produces a colour picture wich as this one. This other more spectacular picture was produced by Cameron Gleed.
Lab06: your mission and here is the solution: particle.cpp.
16) Monday October 26th
17) Wednesday October 28th
Quick test on C-programming: structures and pointers: Test 03 and the answers are here.
C) Numerical methods
We first(quickly) look into producing graphs using gnuplot. Here is a gnuplot script for Lab08: plot.gp. The data it needs is produced by the program lagrange.cpp below.
Then, we start working on Lab07 with the evaluation of a polynomial whose coefficients are in the structure vect. All you need is in lagrange.cpp which can be compiled with Makefile
Next we will go over Lagrange polynomials for interpolation and you will have to write a function that evaluates such a Lagrange polynomial given a set of points it has to match.
Lab07: your mission and here is the solution: lagrange.cpp.
18) Monday November 2nd
19) Wednesday November 4th
Derivatives and integrals
Also, see Numerical differentiation, trapezoidal rule, Simpson's rule, Richardson extrapolation and Romberg's method
Files you will need: integrodiff.cpp and Makefile
Lab08: your mission and here is a solution: integrodiff_solved.cpp
20) Monday November 9th
Derivatives and integrals continued
Also see: fixed point method, bisection method, false-position method and Newton-Raphson method.
Files you will need: rootfind.cpp and Makefile
Lab09:your mission and here is the solution: rootfinding.cpp
21) Wednesday November 11th
Quick test on polynomials and integration (all on paper). Here are the solutions
22) Monday November 16th
Ordinary Differential equation: Simple pendulum
Notes. Also see Euler's method, modified Euler's method, Runge-Kutta methods
You will need the files pendulum.cpp and Makefile.
Lab10: your mission and here is the solution pendulum.cpp with the gnuplot script
trace.gp producing the graph trace.pdf and
the gnuplot script
perampl.gp producing the graph perampl.pdf.
23) Wednesday November 18th
Partial Differential Equations
In this lab, we are going to use ROOT. The features of ROOT you need to use are presented in an example program string.cpp which you can compile using Makefile. Follow the instructions in the Makefile to modifile your customs.cshrc file.
Lab11: your mission and here is the solution string.cpp and a gif animation of the vibrating strings
24) Monday November 23rd
25) Wednesday November 25th
Pseudo-random numbers and Monte-Carlo integration
Notes. Also see
Pseudorandom number generator,
middle square method,
Linear congruential generators,
Monte Carlo method,
inverse transform sampling,
We are going to use random numbers to estimate the
critical mass (or size) of a one dimensional sample of material with chain
reaction capability. In short, we are designing a one dimensional nuclear
bomb! Background information:
Nuclear chain reactions and
Files you will need to get started: boom.cpp and Makefile. Also, you will need linkedlist.cpp and linkedlis.h
Lab12: You mission and here is a solution: boom.cpp.
26) Monday November 30th
27) Wednesday December 2nd
Introduction to LaTeX by Takahiro Yamamoto
Notes, and also see the
APS Author Guide for REVTEX 4.1 and, in the
LaTeX Wikibook, you can read about:
labels and cross references,
floating objects, figures and captions and for error hadling, you can check
Takahiro's thesis is an excellent example of how nice of a ducument you can prepare using LaTeX.
Lab 13: You will be given your mission in class. You will need the following files:
28) Monday December 7th
Introduction to LaTeX by Takahiro Yamamoto continued
Lab 13: Submit your work by Friday December 11th using the command: submit p6720 Lab13 lab.tex lab.pdf
29) Wednesday December 9th
Introduction to python by Nolan Matthews continued
python (also check this
python syntax quick reference) and this tutorial. Then you can look at various tools:
NumPy (mathematical library),
SciPy (scientific computing),
matplotlib (2D graphics), and
ipython, an interactive platform to work with python.
Lab14: You will be gided by Nolan and the slides he prepared (pdf version here). Your starting point this python script: integral_demo.py as your starting point.
Thursday December 17th 2015 from 13:00 to 15:00 FINAL TEST in JFB101