Phy 246, Computer labs
TA: Brad Marts
Melecular dynamics visualization
Checking your code is easiest if you can visualize the results. When writing my code, I wrote along with it a matlab function to help me visualize. Then you can easily check that your particles are obeying the periodic boundary conditions and interacting in qualitatively the right way.
I am putting a copy of the matlab function here for your use. You can download it to your directory using this link: moldyn_movie.m
To use this function, you will have to generate output in a specific (but easy to do) format. The first two lines of your output should look like this:
Npart = 64
Lbox = 15
Of course, with whatever actual numbers you have. The following lines should be x,y pairs for each particle, like this:
1.234 5.678
12.453 13.987
...
Put the file moldyn_movie.m in the directory with your output file. Run matlab from that directory. Then it's as simple as typing: moldyn_movie('outputfilename');
There are a couple other options with the moldyn_movie function, you can type "help moldyn_movie" in matlab to see more information.
Don't have matlab?? Do it in C!!
Major update: April 13th 9:30pm
A new version with new features! moldyn_view2.c
Compile command: gcc -lX11 -L/usr/X11R6/lib -o moldyn_view2 -g moldyn_view2.c -lm
Run it like this: ./moldyn_view 'moldyn_outputfile' -k 20 -t 40 -S 2
Everything after 'moldyn_outputfile' is optional. The number after -k sets the number of frames to skip, the number after -t sets the length of the tails, -S can be used to slow the movie down. There are default values for these options, and once you have run the program it will use the same values you used on the previous run. The options can come in any order, you can include or leave out any.
The old version will remain here if you want to stick with something simple
Last bug fix: April 13th, 11:29 AM EDT
Take this program: moldyn_view.c
Compile it like this: gcc -lX11 -L/usr/X11R6/lib -o moldyn_view -g moldyn_view.c -lm
Run it like this: ./moldyn_view 'moldyn_outputfile' 'skipframes'
Example: ./moldyn_view moldyn.movie 15
The skipframes argument is optional, but it will allow you to slow down or speed up the movie. The higher skipframes, the faster the movie plays, this number must be an integer.
This doesn't have the fancy options that the matlab one has, but at least it works if you don't have matlab. It does require you to have the right X11 libraries installed, but if you are at a physics machine running linux, this should work. It will also run faster than matlab, so you may like it for that reason.
Lab 3 handout available here as a PDF. Data and Matlab function required to complete the lab are below.
show_movie.m
small_movie -- A sample movie.
Lab 2 handout available here as a PDF. Data and scripts required to complete the lab are below.
three_point.com -- Grace script for 3 point derivatives.
five_point.com -- Grace script for 5 point derivatives.
delay.com -- Grace script for delay coordinates
sample.com -- Grace script to sample at driving frequency
shift.com -- Grace script to make theta_n vs. theta_n+1
Data set 1 -- Data set 1, three columns, Time, theta, and omega.
**Do not open this link. Right click and select Save as. Opening in your browser may cause problems** Data set 2 -- Data set 2, three columns, Time, theta, and omega.
The final plot of this lab should look something like this:
Lab 1 handout available here as a PDF. The
programs required to complete the lab are available below.
muldiv.c -- To compare multiplaction and division
addsub.c -- To compare addition and subtraction
pow.c -- To compare multiplication and pow(x,y)
Compile command: gcc <filename> -lm -o <output file>