CLASSICAL SIMULATIONS – INTRODUCTORY LAB Overview During this lab we’re going to practice. We will perform a simulation of one of the simplest physical systems – argon, described by one of the simplest potentials – the Lennard-Jones potential. Admittedly, argon is a not a very fascinating element, it is only appealing, because it’s so simple to study – just what we need for an introductory lab. Later on we are going to work with something more ambitious. We will perform our simulation with a popular program called DL_POLY. The program is free for academic use and anyone can get access, but registration is required. After having registered, one obtains the source code in FORTRAN-90 and a manual. The source code can be compiled into an executable suitable for running on a serial (“desktop”) machine or into an executable which can run in parallel (using MPI) on a computing cluster. For the introductory lab we will use the simpler, serial version, which has already been compiled. To run it, you simply have to type in DL_POLY (please don’t do this now, we will have to prepare input files first). You may find the manual for DL_POLY at http://tiny.pl/hhpt6. In our first simulation we will simulate the behaviour of argon at the temperature of 30 K. Although argon is most often encountered as a gas, at such a low temperature it is a solid, with an fcc (face-centred-cubic) structure. Fig. 1: A small fragment of an fcc crystal. To make the computation simple we will study a small system – 500 atoms of argon, that is a 5x5x5 repetition of a four-atom primitive cell of the fcc lattice. We will employ periodic boundary conditions; by doing so we will simulate a bulk, infinitely large crystal and not just a small 500-atom cluster. Set-up Refer to the instructions displayed on the overhead projector to log in to the correct machine. Once you are there, start by creating a directory named lab0 and changing into that directory. In this way you will keep your files separate from the files for the next laboratory. Computational Nanotechnology www.co-nan.eu Materials prepared by Jacek Dziedzic, [email protected] Generating input files – FIELD The DL_POLY program requires three input files, which we will have to create before we run the simulation. The first file is called FIELD and it describes the interatomic potential that will be used in the simulation. Noble gases, such as argon, are well-described by one of the simplest potentials – the Lennard-Jones potential: U The Lennard-Jones potential can be decomposed into pair terms. This can be done for simpler („pairwise”) potentials, but not for more complex („many-body”) potentials. r Image source: Wikipedia. Fig. 2: The Lennard-Jones potential is a good approximation to the empirically determined potential, for noble gases. Here: rij – is the distance between atoms i and j. σ – is a parameter of the potential, which has different values for different elements. For argon, it is 3.4 Å. ε – is another parameter of the potential. For argon it is 1.005 kJ/mol. The plot shows how the potential energy of a pair of argon atoms (a dimer) changes with the distance between the atoms. The negative of the gradient of the potential, with respect to the coordinates of atom i, is the force acting on atom i from atom j. • • • • What is the direction of the force acting on atoms i and j? When is the force repulsive and when is it attractive? At what atomic separation does the force disappear? What is the force when the atoms are infinitely separated? Now that we know a bit about the L-J potential, let’s prepare DL_POLY for a simulation that will use it. The information on the potential and the kinds of molecules that will take part in the simulation is stored in a file called FIELD. Take a look at the DL_POLY manual (section 5.1.3) to see how the file is formatted. Create an empty FIELD file, then edit it and type in the following: Line 1: A comment (description), which you can use as desired. Line 2: units kJ (this tells DL_POLY that energies are expressed in kJ/mol). Line 3: molecules 1 (tells DL_POLY how many kinds of substances we have; here there’s only one – argon). Line 4: A full name of the substance, argon will be OK. In subsequent lines we should type in the number of molecules and describe every molecule. This will be easiest if we assume that each molecule is simply a single Ar atom. We then have 500 one-atom molecules, this can’t get any simpler. The number of molecules is declared using the nummols directive. The number of atoms in a molecule – using the atoms directive. Then we should describe all the atoms in the molecule, which in our case is just a single atom. The syntax of the description is: chemical_symbol atomic_mass charge Computational Nanotechnology www.co-nan.eu Materials prepared by Jacek Dziedzic, [email protected] The (chemical) symbol of argon you know. The atomic mass of argon (in atomic mass units) – google for it. The charge is, obviously, zero, because an argon atom is neutral. In the next line type in finish, which is a signal for DL_POLY that you have finished describing the molecules and atoms in the simulation. Now it’s time to describe the potentials. We only have one potential, which belongs to the class of pairwise shortrange potentials (the DL_POLY manual calls them van der Waals potentials) (see section 2.3.1). Tell it to DL_POLY, by typing vdw 1 in the next line. Then, for all the pairs of atoms that appear in the simulation, type in a line using the following syntax: chemical_symbol chemical_symbol potential_name potential_parameter1 potential_parameter2 ... Since we are only dealing with argon, there is only one possible pair: Ar-Ar. Find the right name of the potential by consulting section 2.3.1 in the manual. Then give the parameters of the potential (first ε, then σ). Finally, on a separate line, type in close which must be the last directive in a FIELD file. Good job! You have described the molecules, atoms and potentials that take part in our simulation. Generating input files – CONFIG This file describes the initial state of the simulated system. It is up to us to define where the atoms are at t = 0. If desired, we may also define the initial velocities. If not, they will be drawn from the appropriate distribution, so that they are right for the temperature that we specify (we’re OK with that). In DL_POLY the location of all atoms is given explicitly, simply by typing the coordinates of all atoms into an input file called CONFIG. Of course we will not have to type in the coordinates of 500 atoms :) – they will be generated by a utility program. To use the program, you will have to know the lattice constant of argon. This will need to be calculated. Experimental data tells us that around 30 K, the density of argon is 1.70 g/cm3. Using the following questions as a guideline, calculate the lattice constant of argon. Be careful with the units – you don’t want to be off by 1000x or 0.001x :). Fig. 3: A fragment of an fcc lattice. a – lattice constant, d – nearest-neighbour distance. How many kg does 500 argon atoms weigh? (1 atomic mass unit is 1.6605 × 10−27 kg ) .......................................................................................................................................................................................... ............................................................................................................................................................................................ ............................................................................................................................................................................................ ............................................................................................................................................................................................ Knowing the density, what volume does a crystal of 500 argon atoms occupy? ............................................................................................................................................................................................ ............................................................................................................................................................................................ ............................................................................................................................................................................................ Computational Nanotechnology www.co-nan.eu Materials prepared by Jacek Dziedzic, [email protected] Assuming the simulation box is cubic, what is the edge of the cube corresponding to the volume calculated? ............................................................................................................................................................................................ ............................................................................................................................................................................................ Every edge of this cube is 5 lattice constants. What is the lattice constant (a)? What is the nearest-neighbour distance (d)? How does this compare with the distance for which the interatomic potential is at minimum (measure by eye from the graph or, better, find the zero of the derivative). You should arrive at the same value, up to 0.5%. If not (we are expecting a value of d = about 3.80 Å), carefully review your calculation. ........................................................................................................................................................................................... ........................................................................................................................................................................................... ........................................................................................................................................................................................... ........................................................................................................................................................................................... ........................................................................................................................................................................................... ........................................................................................................................................................................................... ........................................................................................................................................................................................ Now that you know the lattice constant for argon at 30 K, use the ready-made program genfcc (just type its name in the console), which generates the positions of the atoms after you supply the dimensions of the system, the lattice constant, and some more details. As a result, you should obtain a CONFIG file, ready for DL_POLY. Take a quick look at the file (mcedit CONFIG) to see if it looks fine. The format of the CONFIG file is similar, but not identical, to that of a xyz file. Let’s make sure that the arrangement of atoms we have just defined is as expected. To view the file inside rasmol, type show CONFIG ... instead of running rasmol directly. This is because the rasmol program expects its input in the xyz format. The show script converts the DL_POLY format to the xyz format and then runs rasmol. Fig. 4: The rasmol program is used to visualize the input configuration. Try moving the mouse while holding combinations of the left and right mouse buttons and the shift and alt keys to get accustomed to the rasmol program. Try to learn how the view can be enlarged and made smaller, rotated and shifted. NB: if you accidentally press ctrl while moving the mouse, you will switch the program into a mode in which cross-sections through the system are shown – you will notice that, because “parts of atoms” will be shown. To turn this off, use Options/Slab Mode from the menu. Computational Nanotechnology www.co-nan.eu Materials prepared by Jacek Dziedzic, [email protected] Generating input files – CONTROL The last file that we need is called CONTROL, because it controls the simulation. It is a text file containing directives for the DL_POLY program, which are used to control temperature, the number of steps of the simulation, the length of one step and many less important details. If you want to, section 5.1.1 of the DL_POLY manual gives all the details on the CONTROL file and a list of all directives and their parameters. An example CONTROL file is also shown. The format of the CONTROL file is as follows. The first line is reserved for a comment and will be ignored. For this reason, be sure not to type any directives on the first line, just a comment. Each following line is either empty or contains one directive, which may take parameters. The last directive to appear in the file is the finish directive. All empty lines and lines beginning with a # character are ignored. Create an empty CONTROL file and type in the mandatory (obligatory) directives. These are: temp – describes the temperature (in K) used for the simulation. We want 30 K. timestep – specifies the length of one time step with which the equations of motion are integrated. A safe value is 2 fs, just make sure in the manual what unit DL_POLY expects and convert the value. steps – is the number of steps in the simulation. For starters, let’s take 10000 steps. no electrostatics – instructs DL_POLY that we are not interested in coulombic interactions between the atoms (this is true, because we only have neutral argon atoms). cutoff – the cut-off radius for the potential. You might remember from the lecture, that we don’t want to waste time calculating interactions between all the atoms – we assume that beyond some distance (e.g. above 8 Å, consult the graph in Fig. 2) the forces are zero. If you take too much, you will slow down the computations. If you take too little, this will influence the results – we would ignore interactions that are not really close to zero. Assume a safe value of 9 Å. Check with the manual to see what unit DL_POLY expects. delr – a parameter of little importance, you may check the manual to see what it controls. 1.0 is a fine value. finish – must come last. Normally we would also need to select the right thermodynamical ensemble. If we don’t, DL_POLY will choose the microcanonical (NVE) ensemble for us. That means that the number of atoms (N), volume of the simulation box (V) and the total energy (E) will be constant. Finally, add several directives that are not mandatory, but will be useful in our simulation. These must be added before the finish directive: job time – specifies the maximum time after which the program should terminate. With longer simulations it is important to stop the program in a controlled way before it is forcibly killed from the outside (by the admin, the queueing system or the OS). In this way DL_POLY may write out all the information needed to restart the simulation at a later time. Some versions of DL_POLY are broken – if we do not specify job time, it defaults to 0 and the program closes immediately after starting. Put in some sensible value, like 600 seconds. rdf – specifies how often the statistics needed to produce the Radial Distribution Function are gathered. This is a fast procedure, so you can use a value of several steps, like 5 or 10. To make sure the RDF is written out to a file, make sure to add the print rdf directive (this one does not take parameters). stats – specifies how often the statistics (temperature, pressure, etc.) are computed. Assume a value of 10 (every 10 steps). traj – this turns on a feature in which the system trajectory (positions, velocities and accelerations of all atoms) is written out to a file called HISTORY. Type in traj 0 100 1 – this means we want only the positions and velocities, every 100 steps, starting from step 0. Computational Nanotechnology www.co-nan.eu Materials prepared by Jacek Dziedzic, [email protected] equil and scale – you might remember from the lecture, that at the beginning of a simulation we want to equilibrate the system. During equilibration we control the temperature of the system by scaling velocities of the atoms. It is also important not to collect statistics during this initial stage. With the equil directive we specify the number of steps used for equilibration, let’s use 2000 steps. The scale directive tells DL_POLY how often the velocities are scaled, let’s assume every 50 steps. Finally, all the files necessary to perform the simulation are ready! Running the simulation and a first look at the output files To start the simulation, simply type in DL_POLY. If everything went fine, the simulation should be complete after about a minute. If the program finishes immediately (within a second or two), something went wrong. Take a look at the OUTPUT file – this a file to which DL_POLY writes out basic information about the simulation, including error messages, placed at the end of the file, if something goes wrong. If you see an error, try to fix it and re-run the simulation. If you don’t know how to fix the error – ask me. Take a quick look at the OUTPUT file – if, instead of numbers, you see infinities (INF) or not-a-number (NaN) – something definitely went wrong. Try to find out what or ask for help. Apart from the OUTPUT file, you should find the following files: RDFDAT, HISTORY, STATIS, REVCON and REVIVE – these are the results of your simulation. OUTPUT – this file contains basic information about the simulation, in human-readable form. First, there is a summary of the simulation’s parameters – you may want to check if they meet your expectations – if not, you’ve probably made a mistake in the CONTROL file. Then there is a sample of the initial configuration – positions and velocities of some of the atoms, this will not be useful for us. The next section, usually rather long one, contains a printout of most important physical quantities, written out every 100 steps in our case. The more important values are: step – step number, time (ps) – time in the simulation, cpu (s) – time it took for the computation (“walltime”), eng_tot – total energy of the system, temp_tot – system temperature, eng_cfg – potential energy of the system, eng_cou – coulombic energy (zero in our case, because the atoms are neutral), volume – the system volume (constant in our case), press – system pressure (in kbar, that is, more or less, 1000 atm or 108 Pa). Apart from the values, the table shows their running averages over 100 steps. For now, verify that the temperature is close to 30 K, this is, after all, what we wanted. After the long printout, there is some more information. One of the more important is the approximate diffusion coefficient (D) – it lets us check if the system is solid or liquid. Values above, roughly, 10-5 cm2/s indicate a liquid. For solids we expect zero or something very close to zero. Check to see if your argon at 30 K is a solid or a liquid. Google for the melting temperature of argon and see if your expectations are met. Conclusions: .............................................................................................................................................. ................................................................................................................................................................. ................................................................................................................................................................. Further on, the OUTPUT file contains other information, which will not be of use to us. STATIS – this file contains the statistics of the simulated system – averages of interesting physical quantities. Most of the results are contained here. As you can see, the file is composed of blocks – every block contains information on 37 physical quantities and the header of the block gives the step number (10, 20, 30, ...) and the time (in ps) to which the block corresponds. To see anything interesting, we will have to extract relevant information from this file. If you want to know which of the 37 numbers correspond to which quantities, consult the manual, section 5.2.8. Computational Nanotechnology www.co-nan.eu Materials prepared by Jacek Dziedzic, [email protected] HISTORY – contains the trajectory of the system, that is a “dump” of all the positions and velocities of all the atoms. Normally it also contains accelerations, but we’ve turned that off to save disk space. The “dump” is written out every 100 steps, as specified in the traj directive. The format of this file is the same as for the CONFIG file, it just contains more frames (snapshots). We will be interested in this file later on. RDFDAT – here the Radial Distribution Function is written out, averaged over all the steps in the simulation except the equilibration stage. REVCON – this file is formatted just like the CONFIG file, but it contains the final configuration of our system, including velocities and accelerations. It is useful if you want to see the at what configuration the system arrived. It also finds use when you want to restart (continue) the simulation – then this file can be renamed to CONFIG and serve as a new starting configuration. To see the final configuration in rasmol, type show REVCON REVIVE – contains all the information necessary to restart (continue) the simulation, if necessary. The information is written out in binary format, which is not human-readable. DL_POLY, however, will be able to interpret the contents of the file if you need to restart the simulation. Examining the results – system temperature We will start our analysis from taking a look at how the temperature changed in our simulation. The temperature, calculated from the kinetic energy of the atoms, can be found in the STATIS file. We will use a utility called extract, which extracts the temperature data from the STATIS file. Simply type extract temperature ...and you will get a file called temperature. Take a look at the contents – in the first column you should see the step number, in the second column – current temperature, which should be close to 30 K. Use gnuplot to plot this and verify if it meets your expectations. Why, do you think, is the temperature not constant at exactly 30 K? ................................................................................................................................................................ ................................................................................................................................................................ Plot the temperature for steps 1-2000 and then for steps 2001-10000. Is the nature of the temperature changes different? Why is that? Recall the equilibration stage. ................................................................................................................................................................ ................................................................................................................................................................ ................................................................................................................................................................ Examining the results – total energy Now we will take a look at the total energy of our argon system. Remember – when simulating in the NVE ensemble, the total energy is supposed to be conserved (constant). Make sure this is the case. Use the extract utility again, this time extracting engtot and not temperature. Plot the resultant file and try to answer the following: During the equilibration stage, why is total energy changing? ................................................................................................................................................................. ................................................................................................................................................................. Computational Nanotechnology www.co-nan.eu Materials prepared by Jacek Dziedzic, [email protected] After equilibration is complete, the energy should definitely be constant, but it changes very slightly. Why? ................................................................................................................................................................. ................................................................................................................................................................. ................................................................................................................................................................. A measure of how well the energy is conserved is |ΔE/E|, that is the change in energy between two timesteps divided by the current energy. Take a look at the engtot file, skip to after the equilibration and try to estimate |ΔE/E|. Energy is well-conserved if |ΔE/E| is in the order of 10-7-10-6 or better. Remember, however, that we only have energy values for every 10 steps, not for every step. For this reason 10-5 will be fine. If the value is larger, something is definitely wrong. So what is the order of |ΔE/E| in our simulation? ................................................................................................................................................................ ................................................................................................................................................................ Do you have any ideas for how we could improve the conservation of energy, if it turns out that the jumps in energy are unacceptably large? ................................................................................................................................................................ ................................................................................................................................................................ If the total energy drifts continually (increases or decreases monotonically), something must be wrong (if this is the NVE ensemble) – for energy either appears from nowhere or disappears into nothingness. Make sure there is no significant energy drift, by computing the difference between the final energy and the energy at the first step after the equilibration: E2010-E10000 = ............................................................................................................................................ Examining the results – Radial Distribution Function, g(r) The DL_POLY program automatically calculates g(r) for us and writes it to the RDFDAT file. Edit the file and delete the first three lines, otherwise you won’t be able to plot the file with gnuplot. Save the modified file and plot it using gnuplot. You have obtained a plot of the RDF. The peaks in g(r) correspond to distances for which there is an increase in density. Looking closely at the graph (point with the mouse!) or by examining the RDFDAT file estimate the position of the first five peaks, to an error of 0.1 Å. Write them down below. Below you see a fragment of an fcc crystal. Mark the characteristic Peak #1: r1 = ........... Å. distances r1..r5 in a convienient place on the crystal diagram. Peak #2: r2 = ........... Å. Peak #3: r3 = ........... Å. Peak #4: r4 = ........... Å. Peak #5: r5 = ........... Å. Do you remember why the peaks are blurry and not very concentrated? ................................................................................................................................................................. ................................................................................................................................................................. Computational Nanotechnology www.co-nan.eu Materials prepared by Jacek Dziedzic, [email protected] Beyond solid argon – what happens at higher temperatures? OK, that was easy. We have observed the behaviour of crystalline Ar. Let’s see what happens if we heat it a little, say, to 90 K. Google for the melting point of argon. Better still, use Wolfram|Alpha to find out what the melting point of argon is. To do this, visit http://www.wolframalpha.com/ and enter “melting point of argon” into the form. Do you expect it to be a solid, liquid or a gas at 90 K? .................................................................. We will need a new simulation – to do this, create a new directory so that you don’t overwrite your old files. Copy the input files (FIELD, CONTROL, CONFIG) to the new directory. Edit CONTROL to change the temperature to 90 K. To give the system more time to melt, increase the number of steps to 50000. Run the simulation. It should take about 7 minutes to complete, maybe it’s time for a coffee 1 :)? Using the techniques learned earlier (plot of the RDF, visual inspection of the final configuration in REVCON), do you find the system to have melted into a liquid, a gas, or is it still a solid? Does the situation agree with what you have googled or found by Wolfram|Alpha? Expected system state: [ ] solid [ ] solid turning into liquid [ ] liquid [ ] liquid turning into gas [ ] gas Observed system state (interpretation of simulation): [ ] solid [ ] solid turning into liquid [ ] liquid [ ] liquid turning into gas [ ] gas how do you know?................................................ ............................................................................. Likely, your expectations did not match the findings of the simulation. This is an important lesson: • you should not trust your results blindly, • the conditions of the simulation should be as close as possible to the experimental conditions with which you compare your results. What could be the reason for the simulation predicting something different from the “official” result? Try plotting the system pressure. Use the extract utility to extract the pressure data from STATIS, just like you did earlier for the temperature and the total energy. Then plot the system pressure in gnuplot. The pressure in DL_POLY is expressed in kbar, roughly a thousand times the atmospheric pressure. Try typing “... kbar” (type the value observed in the pressure file value instead of ...) into Wolfram|Alpha to realize if it’s a lot or not. It is quite possible that at a pressure like that argon doesn’t really turn into a gas – the observed pressure is very far from the atmospheric pressure (which is .......................... kbar). The reason for the extremely high pressure that you observed was that the volume of the simulation box was constant. For a solid, crystalline argon this was OK, but a phase change is typically accompanied by a change in density. In an experiment a solid turning into a liquid or into 1 If you are Italian, you will find the coffee in the cofee vending machine to be rather bad. Computational Nanotechnology www.co-nan.eu Materials prepared by Jacek Dziedzic, [email protected] gas would change volume (typically expand by several percent), the change in volume would allow the pressure to relax to the atmospheric pressure. In our simulation the volume was fixed, which prevented the system from relaxing the pressure. Because of this the pressure rose as high as ............. kbar (roughly ............... Pa or .......... atm). Can the large pressure make argon behave quite differently than it does at atmospheric pressure? For a more realistic simulation, we could allow the volume of the simulation box to change. To do this, edit the CONTROL file and add the following two directives: ensemble npt press 0 The first directive tells DL_POLY that we change the ensemble from NVE to NPT (constant number of particles (N), pressure (P) and temperature (T)). In this way we switch from constant volume to constant pressure. Note that now the total energy will not be conserved, the effort will be to keep the pressure and temperature constant. The press 0 directive sets the external pressure to zero (which is very close to atmospheric pressure, when compared with the magnitude of pressures we’ve just seen). Before you run the simulation with the new version, copy the old RDFDAT file and the pressure file to a new name for comparison later. Extract and plot the pressure in the new simulation. How does the pressure compare with the pressure in the fixedvolume simulation? .............................................................................................................................................. Plot both the new RDFDAT (remember to get rid of the first three lines) and the old RDFDAT on the same plot. Did relaxing the volume change the structure of the obtained system? What state (phase) is it in? Expected system state: [ ] solid [ ] solid turning into liquid [ ] liquid [ ] liquid turning into gas [ ] gas Observed system state (interpretation of simulation): [ ] solid [ ] solid turning into liquid [ ] liquid [ ] liquid turning into gas [ ] gas how do you know?................................................ ............................................................................. Whoever got this far... It’s likely time to relax. If you are not in the mood to relax or if you’ve had too much coffee, you may try to repeat the simulation for different temperatures and try to see what the predicted melting temperature of argon is. This can be compared with the “known” (experimental) value. Melting temperature of Ar, as predicted from a simulation with the Lennard-Jones potential: Melting temperature of Ar, as predicted from experiment: ................................................................................... ........................................................................... The Lennard-Jones potential is very simple – don’t expect it to give astonishingly good conformance with empirical results. Source: ............................................................................. Some potentials do better at certain properties of the system and for other properties give predictions that are not as good. Computational Nanotechnology www.co-nan.eu Materials prepared by Jacek Dziedzic, [email protected]
© Copyright 2026 Paperzz