This is an old revision of the document!
> cd > nano .bashrc module load new gcc/4.8.2 python/2.7.12 # include this line in the file > . .bashrc
To visualize an xyz file:
> ipython In : from ase.io import read In : from ase.visualize import view In : s=read("file.xyz") In : view(s)
At this point you can rotate the structure, select an atom, then two (you get the distance) or three (you get the angle)…
In the repository you will find the program “md.py” and the geometry file “fcc.xyz” The program md.py can perform a MD simulation for a system of Ar atoms interacting via Lennard-Jones potential.
Executing the command
the program will ask you to provide
At this point a window like that should open:
The program will show two graphs wile the MD simulation is running. The graph on the left contains the total energy of the system Etot that should remain constant along the simulation and the potential energy of the system “Epot”. Etot=Epot+Ekin where Ekin is the kinetic energy of the system.
At the end of execution the plot will be saved in the working directory as plots.png. You can visualize it by giving the command
> display plots.png
and data for the energy and temperature at each step will be saved on the file data.out. You can visualize the graphs using gnuplot: for the time vs. temperature:
> gnuplot gnuplot> plot 'data.out' u 2:7 w l
Is the total energy conserved? Is the temperature of the system conserved?
- Execute the program with input parameters
Is the total energy conserved?
Copy the program md.py into md_original.py and edit the file md.py (using nano). Have a look at the structure of the program At the beginning two functions are defined:
ekin(m,v) needs as input the mass of each atom and its velocity; computes the kinetic energy of the system.
forces_pot(pos,sigma,epsilon) needs as input the positions and the Lennard-Jones parameters to compute the potential energy of the system and the force on each atom. Then the program will:
Finally the main loop of the dynamics starts, and it contains a final block needed to produce the graphs.
Have a look at the function to compute the forces and the potential energy. A potentially very slow version of the algorithm is commented “#” (it would be very slow in an efficient fortran or C code that is compiled without optimization). The active version of the algorithm is supposed to be faster. Deactivate printing of data and production of the graphs by setting to False the two variables
execute three or four times the program and write down the execution time that you get as the only output. Now comment the lines for the “efficient” algorithm and uncomment the lines of the ”unefficient” one. Execute with 3-4 different timesteps. Is the execution time longer? Why do you think you get such a result?
Find the section of the code that removes the initial linear momentum. What could you do to remove the initial angular momentum? (no need to write down the code, just think how you could do)