<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://chemwiki.ch.ic.ac.uk/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Otr12</id>
	<title>ChemWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://chemwiki.ch.ic.ac.uk/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Otr12"/>
	<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/wiki/Special:Contributions/Otr12"/>
	<updated>2026-05-16T05:40:28Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Programming_a_2D_Ising_Model&amp;diff=794567</id>
		<title>Programming a 2D Ising Model</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Programming_a_2D_Ising_Model&amp;diff=794567"/>
		<updated>2019-09-26T08:18:56Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Getting Help */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;This is the compulsory experiment for students taking the chemistry with molecular physics option. If you are looking for the optional simulation experiment for other third year chemistry students, you will find it [[Third_year_simulation_experiment|here]].&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Last year, you were introduced to [https://www.python.org/ Python], a scripting language which is rapidly becoming the de facto language for everyday scientific programming. Python is an interpreted, rather than compiled language, and is rather more forgiving than older languages such as C or FORTRAN. This reduces the amount of time that we need to spend programming and debugging. The downside to all this is that the execution of a Python program is much slower than a compiled equivalent. As a compromise, we usually let large codes written in a compiled language (usually C/C++) do the hefty numerical work for us, and then use scripting languages like Python to analyse the results.&lt;br /&gt;
&lt;br /&gt;
These large codes for numerical work (you may have already used GAUSSIAN for electronic structure calculations) typically take arcane text files as input, and produce equally arcane text files as output. If, for the sake of example, you run twenty different molecular dynamics simulations, and each of them produces an output file which contains information about the density of the system, then extracting this information by hand would be very tedious (and if you run hundreds or thousands of simulations, virtually impossible), but this sort of task is the thing at which languages like Python really excel.&lt;br /&gt;
&lt;br /&gt;
In this exercise, you are going to use the Python that you learned last year to write a code perform Monte-Carlo simulations of the 2D [http://en.wikipedia.org/wiki/Ising_model Ising model], a set of spins on a lattice which is used to model ferromagnetic behaviour, and also to analyse the results of the simulation to find the heat capacity of the system and the Curie temperature &amp;amp;mdash; the temperature below which the system is able to maintain a spontaneous magnetisation.&lt;br /&gt;
&lt;br /&gt;
==Assessment==&lt;br /&gt;
&lt;br /&gt;
At the end of this experiment you must submit a &amp;quot;report&amp;quot; in wiki form. You can find instructions on how to create the wiki page and edit it in the &amp;quot;Report Preparation&amp;quot; section of [[Mod:writeup#Report_Preparation|this page]]. Each section of the experiment has a number of tasks that you should complete, labelled &#039;&#039;&#039;&amp;lt;big&amp;gt;TASK&amp;lt;/big&amp;gt;&#039;&#039;&#039;. If this is a mathematical exercise, your report should contain a short summary of the solution. If it is a graphical exercise, you should include the relevant image. Your report should explain briefly what you did in each stage of the experiment, and what your findings were.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;YOU MUST SUBMIT YOUR WIKI REPORT BY 12 NOON ON THE WEDNESDAY FOLLOWING THE EXPERIMENT.&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;YOU MUST SUBMIT YOUR WIKI REPORT USING BLACKBOARD - INSTRUCTIONS WILL BE PROVIDED BY EMAIL BEFORE THE DEADLINE.&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Your report should contain the source code to *any* Python scripts that you write during the experiment, annotated with comments.&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you wish, you are welcome to do the experiment on your own computer. You will need the [https://store.continuum.io/cshop/anaconda/ Anaconda] scientific Python distribution (if you are a Windows or Mac user). You may ask for help with installing this, but it is not part of the experiment &amp;amp;mdash; students who have scientific questions will take priority.&lt;br /&gt;
&lt;br /&gt;
==Getting Help==&lt;br /&gt;
&lt;br /&gt;
The demonstrators for this exercise are Ollie Robotham (otr12@ic.ac.uk) and Dr. Juan Olarte-Plata (j.olarte@imperial.ac.uk). The assessor will be Prof. Fernando Bresme. The demonstrators will be available in the second floor chemistry computer room between 2pm and 3pm on each day of the experiment (&#039;&#039;&#039;Note: the experiment does not &amp;quot;run&amp;quot; on Wednesdays&#039;&#039;&#039;). If you have questions outside of these times, you are of course welcome to send them by e-mail.&lt;br /&gt;
&lt;br /&gt;
The member of academic staff responsible for this exercise is Prof. Fernando Bresme (f.bresme@imperial.ac.uk).&lt;br /&gt;
&lt;br /&gt;
==Structure of this Experiment==&lt;br /&gt;
&lt;br /&gt;
This experimental manual has been broken up into a number of subsections. Direct links to each of them may be found below. You should attempt them in order, and you should complete all of them to finish the experiment.&lt;br /&gt;
&lt;br /&gt;
# [[Third_year_CMP_compulsory_experiment/Introduction_to_the_Ising_model|Introduction to the Ising model]]&lt;br /&gt;
# [[Third_year_CMP_compulsory_experiment/Calculating the energy and magnetisation|Calculating the energy and magnetisation]]&lt;br /&gt;
# [[Third_year_CMP_compulsory_experiment/Introduction to Monte Carlo simulation|Introduction to the Monte Carlo simulation]]&lt;br /&gt;
# [[Third_year_CMP_compulsory_experiment/Accelerating the code|Accelerating the code]]&lt;br /&gt;
# [[Third_year_CMP_compulsory_experiment/The effect of temperature|The effect of temperature]]&lt;br /&gt;
# [[Third_year_CMP_compulsory_experiment/The effect of system size|The effect of system size]]&lt;br /&gt;
# [[Third_year_CMP_compulsory_experiment/Determining the heat capacity|Determining the heat capacity]]&lt;br /&gt;
# [[Third_year_CMP_compulsory_experiment/Locating the Curie temperature|Locating the Curie temperature]]&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Programming_a_2D_Ising_Model&amp;diff=794566</id>
		<title>Programming a 2D Ising Model</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Programming_a_2D_Ising_Model&amp;diff=794566"/>
		<updated>2019-09-26T08:18:08Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Getting Help */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;This is the compulsory experiment for students taking the chemistry with molecular physics option. If you are looking for the optional simulation experiment for other third year chemistry students, you will find it [[Third_year_simulation_experiment|here]].&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Last year, you were introduced to [https://www.python.org/ Python], a scripting language which is rapidly becoming the de facto language for everyday scientific programming. Python is an interpreted, rather than compiled language, and is rather more forgiving than older languages such as C or FORTRAN. This reduces the amount of time that we need to spend programming and debugging. The downside to all this is that the execution of a Python program is much slower than a compiled equivalent. As a compromise, we usually let large codes written in a compiled language (usually C/C++) do the hefty numerical work for us, and then use scripting languages like Python to analyse the results.&lt;br /&gt;
&lt;br /&gt;
These large codes for numerical work (you may have already used GAUSSIAN for electronic structure calculations) typically take arcane text files as input, and produce equally arcane text files as output. If, for the sake of example, you run twenty different molecular dynamics simulations, and each of them produces an output file which contains information about the density of the system, then extracting this information by hand would be very tedious (and if you run hundreds or thousands of simulations, virtually impossible), but this sort of task is the thing at which languages like Python really excel.&lt;br /&gt;
&lt;br /&gt;
In this exercise, you are going to use the Python that you learned last year to write a code perform Monte-Carlo simulations of the 2D [http://en.wikipedia.org/wiki/Ising_model Ising model], a set of spins on a lattice which is used to model ferromagnetic behaviour, and also to analyse the results of the simulation to find the heat capacity of the system and the Curie temperature &amp;amp;mdash; the temperature below which the system is able to maintain a spontaneous magnetisation.&lt;br /&gt;
&lt;br /&gt;
==Assessment==&lt;br /&gt;
&lt;br /&gt;
At the end of this experiment you must submit a &amp;quot;report&amp;quot; in wiki form. You can find instructions on how to create the wiki page and edit it in the &amp;quot;Report Preparation&amp;quot; section of [[Mod:writeup#Report_Preparation|this page]]. Each section of the experiment has a number of tasks that you should complete, labelled &#039;&#039;&#039;&amp;lt;big&amp;gt;TASK&amp;lt;/big&amp;gt;&#039;&#039;&#039;. If this is a mathematical exercise, your report should contain a short summary of the solution. If it is a graphical exercise, you should include the relevant image. Your report should explain briefly what you did in each stage of the experiment, and what your findings were.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;YOU MUST SUBMIT YOUR WIKI REPORT BY 12 NOON ON THE WEDNESDAY FOLLOWING THE EXPERIMENT.&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;YOU MUST SUBMIT YOUR WIKI REPORT USING BLACKBOARD - INSTRUCTIONS WILL BE PROVIDED BY EMAIL BEFORE THE DEADLINE.&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Your report should contain the source code to *any* Python scripts that you write during the experiment, annotated with comments.&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you wish, you are welcome to do the experiment on your own computer. You will need the [https://store.continuum.io/cshop/anaconda/ Anaconda] scientific Python distribution (if you are a Windows or Mac user). You may ask for help with installing this, but it is not part of the experiment &amp;amp;mdash; students who have scientific questions will take priority.&lt;br /&gt;
&lt;br /&gt;
==Getting Help==&lt;br /&gt;
&lt;br /&gt;
The demonstrators for this exercise are Ollie Robotham (otr12@ic.ac.uk) and Dr. Juan Olarte-Plata. The assessor will be Prof. Fernando Bresme. The demonstrators will be available in the second floor chemistry computer room between 2pm and 3pm on each day of the experiment (&#039;&#039;&#039;Note: the experiment does not &amp;quot;run&amp;quot; on Wednesdays&#039;&#039;&#039;). If you have questions outside of these times, you are of course welcome to send them by e-mail.&lt;br /&gt;
&lt;br /&gt;
The member of academic staff responsible for this exercise is Prof. Fernando Bresme (f.bresme@imperial.ac.uk).&lt;br /&gt;
&lt;br /&gt;
==Structure of this Experiment==&lt;br /&gt;
&lt;br /&gt;
This experimental manual has been broken up into a number of subsections. Direct links to each of them may be found below. You should attempt them in order, and you should complete all of them to finish the experiment.&lt;br /&gt;
&lt;br /&gt;
# [[Third_year_CMP_compulsory_experiment/Introduction_to_the_Ising_model|Introduction to the Ising model]]&lt;br /&gt;
# [[Third_year_CMP_compulsory_experiment/Calculating the energy and magnetisation|Calculating the energy and magnetisation]]&lt;br /&gt;
# [[Third_year_CMP_compulsory_experiment/Introduction to Monte Carlo simulation|Introduction to the Monte Carlo simulation]]&lt;br /&gt;
# [[Third_year_CMP_compulsory_experiment/Accelerating the code|Accelerating the code]]&lt;br /&gt;
# [[Third_year_CMP_compulsory_experiment/The effect of temperature|The effect of temperature]]&lt;br /&gt;
# [[Third_year_CMP_compulsory_experiment/The effect of system size|The effect of system size]]&lt;br /&gt;
# [[Third_year_CMP_compulsory_experiment/Determining the heat capacity|Determining the heat capacity]]&lt;br /&gt;
# [[Third_year_CMP_compulsory_experiment/Locating the Curie temperature|Locating the Curie temperature]]&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation&amp;diff=734701</id>
		<title>Third year simulation experiment/Introduction to molecular dynamics simulation</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation&amp;diff=734701"/>
		<updated>2018-11-12T09:59:17Z</updated>

		<summary type="html">&lt;p&gt;Otr12: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the second section of the third year simulation experiment. You can return to the previous section, [[Third year simulation experiment/Files to download|Downloading Files]], or jump ahead to the next section, [[Third year simulation experiment/Equilibration|Equilibration]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;This section contains background information about the theory of molecular dynamics simulations. It contains a number of relatively short exercises that you must complete as part of your lab write-up. These are labelled in bold and preceded by the word TASK in large print. It is recommended that you read the information on this page before carrying on with the rest of the experiment, but you are encouraged to save the TASKS for later; you can attempt them while you wait for long simulations to finish.&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this section, we briefly discuss the theory behind molecular dynamics (MD) simulations. When we perform MD, we calculate how a particular set of atoms move over time. Using statistical physics, we can use the positions, velocities, and forces, of the atoms to calculate thermodynamic quantities like temperature and pressure.&lt;br /&gt;
&lt;br /&gt;
==Theory==&lt;br /&gt;
&lt;br /&gt;
===The Classical Particle Approximation===&lt;br /&gt;
&lt;br /&gt;
As you may remember from your quantum chemistry lectures, it is very straightforward to write down the Schroedinger equation that describes the behaviour of any particular chemical system. For anything more complicated than a hydrogen atom, however, it is impossible to solve exactly. Even approximate solutions can be extremely computationally demanding. To be able to simulate a real system, we have to make some approximations.&lt;br /&gt;
&lt;br /&gt;
It turns out that, to a very good approximation, we can assume that atoms behave as classical particles. Imagine a collection of &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms. Each one of them will interact with all of the others, and so each atom will feel a force. Newton&#039;s second law tell us that that force causes the atom to accelerate.&lt;br /&gt;
&lt;br /&gt;
Throughout this section, we are going to use the following notation:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathbf{F}_i&amp;lt;/math&amp;gt; is the force acting on atom i.&lt;br /&gt;
* &amp;lt;math&amp;gt;m_i&amp;lt;/math&amp;gt; is the mass of atom i.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathbf{a}_i&amp;lt;/math&amp;gt; is the acceleration of atom i, the rate of change of its velocity.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathbf{v}_i&amp;lt;/math&amp;gt; is the velocity of atom i.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathbf{x}_i&amp;lt;/math&amp;gt; is the position of atom i.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{F}_i = m_i \mathbf{a}_i = m_i \frac{\mathrm{d}\mathbf{v}_i}{\mathrm{d}t} = m_i \frac{\mathrm{d}^2 \mathbf{x}_i}{\mathrm{d}t^2} \ \ (1)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a second order differential equation for the positions of the atoms &amp;amp;mdash; if we know how the force, &amp;lt;math&amp;gt;\mathbf{F}_i&amp;lt;/math&amp;gt;, behaves as a function of time, then we can determine the atomic positions and velocities at any time we like. Our system of &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms has &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; of these equations, one for each atom. This is one of the reasons that computer simulations are needed &amp;amp;mdash; if we want to model the behaviour of a liquid, we can hardly solve the necessary number of equations by hand.&lt;br /&gt;
&lt;br /&gt;
===Numerical Integration===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Numerical integration is a rather complex topic. In particular, the notation used below can be quite intimidating. Remember that you are encouraged to ask for help from the demonstrator if you want to discuss any part of this experiment!&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are a number of numerical algorithms to perform a molecular dynamics simulation, two are presented here- The Classical Verlet algorithm and The Velocity-Verlet algorithm.&lt;br /&gt;
&lt;br /&gt;
====Verlet Algorithm====&lt;br /&gt;
&lt;br /&gt;
To solve these equations numerically we have to &#039;&#039;discretise&#039;&#039; the problem: rather than treating the atomic positions, velocities, and forces as continuous functions of time, we break our simulation up into a sequence of &#039;&#039;&#039;timesteps&#039;&#039;&#039;, each of length &amp;lt;math&amp;gt;\delta t&amp;lt;/math&amp;gt;. This process is illustrated for a simple function in &#039;&#039;&#039;figure 1&#039;&#039;&#039;. The method that we are going to use to solve Newton&#039;s law for our atoms is usually called the Verlet algorithm (although it is an old method, and has been &#039;rediscovered&#039; many times!). To understand its origin, we will begin with a brief derivation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-Discretisation.png|300px|thumb|center|&#039;&#039;&#039;Figure 1&#039;&#039;&#039;: Discretisation of sin(x) between 0 and &amp;lt;math&amp;gt;2\pi&amp;lt;/math&amp;gt;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We denote the position of an atom, &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;, at time &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;\mathbf{x}_i \left(t\right)&amp;lt;/math&amp;gt;. Similarly, &amp;lt;math&amp;gt;\mathbf{v}_i \left(t\right)&amp;lt;/math&amp;gt; is the velocity of that atom at the same time. What we want to know is the position of the atoms at the next timestep, &amp;lt;math&amp;gt;t + \delta t&amp;lt;/math&amp;gt;. The basic Verlet algorithm is shown in &#039;&#039;&#039;figure 2&#039;&#039;&#039; - knowing a set of initial conditions the algorithm calculates forces and by Newton&#039;s second law, we can update the positions of a set of particles are a time &amp;lt;math&amp;gt;t + \delta t&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-Verlet-flowchart.svg|300px|thumb|center|&#039;&#039;&#039;Figure 2&#039;&#039;&#039;: Steps to implement the classic Verlet algorithm.]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt; TASK 1: By taking Taylor expansions of  &amp;lt;math&amp;gt;x(t + \delta t)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;x(t - \delta t)&amp;lt;/math&amp;gt;, write general expressions for them up to the fourth order &amp;lt;math&amp;gt;\mathcal{O}\left(\delta t^4\right)&amp;lt;/math&amp;gt; &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt; Having written these expressions, derive the formula in figure 2 to update positions as used in the classical Verlet algorithm &amp;lt;math&amp;gt; x(t + \delta t) \approx 2x_{i}(t) - x_{i}(t-\delta t) + \frac{F_{i}(t)}{m} \delta t^{2}&amp;lt;/math&amp;gt; by using Newton&#039;s second law to replace &amp;lt;math&amp;gt;\frac{\mathrm{d}^2\mathbf{x}_i\left(t\right)}{\mathrm{d}t^2}&amp;lt;/math&amp;gt; [6 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Using this last equation, we can use a sequence of steps like those shown in &#039;&#039;&#039;figure 2&#039;&#039;&#039; to get the positions. At no point are the velocities calculated in this method!&lt;br /&gt;
&lt;br /&gt;
====Velocity Verlet Algorithm====&lt;br /&gt;
&lt;br /&gt;
If we assume that the acceleration of an atom depends only on its position and not its velocity, then we are able to come up with a new algorithm that lets us calculate atomic velocities explicitly as shown in &#039;&#039;&#039;figure 3&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-VelocityVerlet-flowchart.svg|300px|thumb|center|&#039;&#039;&#039;Figure 3&#039;&#039;&#039;: Steps to implement the velocity Verlet algorithm.]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We start by noting that&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{v}_i\left(t + \delta t\right) = \mathbf{v}_i\left(t\right) + \frac{\mathbf{a}_i\left(t\right) + \mathbf{a}_i\left(t + \delta t\right)}{2}\delta t \ \ (6)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can Taylor expand the velocity by half a step, instead of a full step.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{v}_i\left(t + \frac{1}{2}\delta t\right) = \mathbf{v}_i\left(t\right) + \frac{1}{2} \mathbf{a}_i\left(t\right)\delta t \ \ (7)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then substitute this into your expansion for &amp;lt;math&amp;gt; x_{i} (t + \delta t) &amp;lt;/math&amp;gt; to obtain an accuracy up to &amp;lt;math&amp;gt; \delta t ^{2} &amp;lt;/math&amp;gt;. Notice that terms up to &amp;lt;math&amp;gt; \delta t ^{2} &amp;lt;/math&amp;gt; in your expansion can be written:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; \mathbf{x}_{i} (t + \delta t) = \mathbf{x}_{i} (t) + \mathbf{v}(t) \delta t + \frac{1}{2} \mathbf{a}(t) \delta t ^{2} &amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{x}_i\left(t + \delta t\right) = \mathbf{x}_i\left(t\right) + \mathbf{v}_i\left(t + \frac{1}{2}\delta t\right)\delta t \ \ (8)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When we know the updated atomic positions, we can calculate new forces, &amp;lt;math&amp;gt;\mathbf{a}_i\left(t + \delta t\right)&amp;lt;/math&amp;gt;. Finally, we substitute equation (7) into equation (6) to get the new velocities &amp;lt;math&amp;gt;\mathbf{v}_i\left(t + \delta t\right)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{v}_i\left(t + \delta t\right) = \mathbf{v}_i\left(t + \frac{1}{2}\delta t\right) + \frac{1}{2}\mathbf{a}_i\left(t + \delta t\right)\delta t \ \ (9)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that for both numerical integration algorithms, the first step is &amp;quot;specify initial conditions&amp;quot;. When using the Verlet algorithm, we need to know the starting positions of the atoms (&amp;lt;math&amp;gt;\mathbf{x}_i\left(0\right)&amp;lt;/math&amp;gt;), and their positions one timestep in the past (&amp;lt;math&amp;gt;\mathbf{x}_i\left(-\delta t\right)&amp;lt;/math&amp;gt;). If the velocity-Verlet algorithm is used, then we have to know the  the starting positions of the atoms (&amp;lt;math&amp;gt;\mathbf{x}_i\left(0\right)&amp;lt;/math&amp;gt;) and their velocities at the same time (&amp;lt;math&amp;gt;\mathbf{v}_i\left(0\right)&amp;lt;/math&amp;gt;). For this reason, we often start new simulations by using the output of older ones. If, however, you are performing your first simulations of a system (as we are now), then you must choose your initial conditions. The simulation software that we will use is able to do this for us, and this will be explained in the next section.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt; TASK 2: What could be an advantage of the Velocity-Verlet algorithm over the classical Verlet algorithm? [1 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Atomic Forces===&lt;br /&gt;
&lt;br /&gt;
Since we can&#039;t reasonably solve the equations from quantum physics necessary to determine the forces acting on a given configuration of atoms, we have to make approximations. We know from classical physics that the force acting on an object is determined by the potential that it experiences:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{F}_i = - \frac{\mathrm{d}U\left(\mathbf{r}^N\right)}{\mathrm{d}\mathbf{r}_i}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The shorthand notation &amp;lt;math&amp;gt;\mathbf{r}^N&amp;lt;/math&amp;gt; stands for the position vectors of &#039;&#039;&#039;every&#039;&#039;&#039; atom in system. In principle, the force that a single atom feels is determined by the position of every other atom in the simulation. All we then need to do is to find a function &amp;lt;math&amp;gt;U&amp;lt;/math&amp;gt; that captures all the key physics of the interatomic interactions in the system. For many simple liquids, it turns out that we can model the interactions between each pair of atoms extremely well using the Lennard-Jones potential. Overall, U takes the form:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;U\left(\mathbf{r}^N\right) = \sum_i^N \sum_{i \neq j}^{N} \left\{ 4\epsilon \left( \frac{\sigma^{12}}{r_{ij}^{12}} - \frac{\sigma^6}{r_{ij}^6} \right) \right\} \ \ (10)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 3: For a single Lennard-Jones interaction, &amp;lt;math&amp;gt;\phi\left(r\right) = 4\epsilon \left( \frac{\sigma^{12}}{r^{12}} - \frac{\sigma^6}{r^6} \right)&amp;lt;/math&amp;gt;, find the separation, &amp;lt;math&amp;gt;r_0&amp;lt;/math&amp;gt;, at which the potential energy is zero. What is the force at this separation? Find the equilibrium separation, &amp;lt;math&amp;gt;r_{eq}&amp;lt;/math&amp;gt;, and work out the well depth (&amp;lt;math&amp;gt;\phi\left(r_{eq}\right)&amp;lt;/math&amp;gt;). Evaluate the integrals &amp;lt;math&amp;gt;\int_{2\sigma}^\infty \phi\left(r\right)\mathrm{d}r&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\int_{2.5\sigma}^\infty \phi\left(r\right)\mathrm{d}r&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\int_{3\sigma}^\infty \phi\left(r\right)\mathrm{d}r&amp;lt;/math&amp;gt; when &amp;lt;math&amp;gt;\sigma = \epsilon = 1.0&amp;lt;/math&amp;gt; [4 marks]&amp;lt;/big&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
====Periodic Boundary Conditions====&lt;br /&gt;
&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-Box.png|200px|thumb|right|&#039;&#039;&#039;Figure 4&#039;&#039;&#039;: Diagram of a simulation box containing 2139 atoms. The blue lines indicate the boundaries of the box.]]&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-Periodic.svg|300px|thumb|left|&#039;&#039;&#039;Figure 5&#039;&#039;&#039;: Periodic boundary conditions in two dimensions.]]&lt;br /&gt;
&lt;br /&gt;
We cannot simulate realistic volumes of liquid. In fact, in our simulations, &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; will be between &amp;lt;math&amp;gt;1000&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;10000&amp;lt;/math&amp;gt;. The following task should illustrate why this must be so.&lt;br /&gt;
&lt;br /&gt;
In order for our simulations to approximate a bulk liquid, we have to use a computational trick. The atoms in the simulation are enclosed in a simulation box, of fixed dimensions (&#039;&#039;&#039;figure 4&#039;&#039;&#039;). This box is very often a cuboid, but parallelepipeds can also be used (and this can be very useful when simulating crystal structures). We pretend that we have repeated our box infinitely in all directions, so that the atoms at the very edges are not exposed to a vacuum. This is illustrated in two dimensions in &#039;&#039;&#039;figure 5&#039;&#039;&#039;. The darker coloured atoms in the central box are the &amp;quot;real&amp;quot; atoms. The faded atoms in the outer four boxes are the replicas. When an atom crosses the boundary of the box, one of its replicas enters the box through the opposite face. In this way, the number of atoms inside the box is always constant.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 4: Consider an atom at position &amp;lt;math&amp;gt;\left(0.5, 0.5, 0.5\right)&amp;lt;/math&amp;gt; in a cubic simulation box which runs from &amp;lt;math&amp;gt;\left(0, 0, 0\right)&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;\left(1, 1, 1\right)&amp;lt;/math&amp;gt;. In a single timestep, it moves along the vector &amp;lt;math&amp;gt;\left(0.7, 0.6, 0.2\right)&amp;lt;/math&amp;gt;. At what point does it end up, &#039;&#039;after the periodic boundary conditions have been applied&#039;&#039;? [1 marks]&#039;&#039;&#039; &amp;lt;/big&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
====Truncation====&lt;br /&gt;
&lt;br /&gt;
Periodic boundary conditions introduce their own problems. When we defined our potential function (equation 10), we specified that it depended on all possible pairs of atoms. If we have an infinite number of replicas of our system, how can we avoid calculating an infinite number of pair interactions?&lt;br /&gt;
&lt;br /&gt;
Think about the three integrals you calculated for the Lennard-Jones potential task. They represent the area under the Lennard-Jones potential curve between some specified distance (&amp;lt;math&amp;gt;2\sigma&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;2.5\sigma&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;3\sigma&amp;lt;/math&amp;gt;), and infinite separation (where there is no interaction). You should find that this value becomes rather small as the near distance is increased! The attractive &amp;lt;math&amp;gt;\frac{1}{r^6}&amp;lt;/math&amp;gt; part of the potential dominates here, and this decays rapidly with &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. We assume that this means that there is a distance beyond which the interaction is so small that we can safely ignore it. In fact, in most simulations this is chosen to be something close to &amp;lt;math&amp;gt;2.5\sigma&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;3\sigma&amp;lt;/math&amp;gt;. When the forces are calculated, we only calculate interactions between a pair of atoms if their separation is less than this cutoff.&lt;br /&gt;
&lt;br /&gt;
====Reduced Units====&lt;br /&gt;
&lt;br /&gt;
It is typical when using Lennard-Jones interactions to work in reduced units. By this, we mean that all quantities in our simulation are divided by scaling factors &amp;amp;mdash; for example, distances are divided by &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt;. The result of this is that the values become more manageable: all values that we might work out are typically around 1, rather than &amp;lt;math&amp;gt;1\times 10^{-10}&amp;lt;/math&amp;gt; (in the case of distance), &amp;lt;math&amp;gt;300&amp;lt;/math&amp;gt; (in the case of temperature), or &amp;lt;math&amp;gt;1\times 10^{-19}&amp;lt;/math&amp;gt; (in the case of energy).&lt;br /&gt;
&lt;br /&gt;
We denote these reduced quantities by a star, and they take the following conversion factors:&lt;br /&gt;
&lt;br /&gt;
* distance &amp;lt;math&amp;gt;r^* = \frac{r}{\sigma}&amp;lt;/math&amp;gt;&lt;br /&gt;
* energy &amp;lt;math&amp;gt;E^* = \frac{E}{\epsilon}&amp;lt;/math&amp;gt;&lt;br /&gt;
* temperature &amp;lt;math&amp;gt;T^* = \frac{k_BT}{\epsilon}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 5: The Lennard-Jones parameters for argon are &amp;lt;math&amp;gt;\sigma = 0.34\mathrm{nm}, \epsilon\ /\ k_B= 120 \mathrm{K}&amp;lt;/math&amp;gt;. If the LJ cutoff is &amp;lt;math&amp;gt;r^* = 3.2&amp;lt;/math&amp;gt;, what is it in real units? What is the well depth in &amp;lt;math&amp;gt;\mathrm{kJ\ mol}^{-1}&amp;lt;/math&amp;gt;? What is the reduced temperature &amp;lt;math&amp;gt;T^* = 1.5&amp;lt;/math&amp;gt; in real units? [1 marks]&amp;lt;/big&amp;gt; &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the second section of the third year simulation experiment. You can return to the previous section, [[Third year simulation experiment/Running your first simulation|Files to Download]], or jump ahead to the next section, [[Third year simulation experiment/Equilibration|Equilibration]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Structural_properties_and_the_radial_distribution_function&amp;diff=734700</id>
		<title>Third year simulation experiment/Structural properties and the radial distribution function</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Structural_properties_and_the_radial_distribution_function&amp;diff=734700"/>
		<updated>2018-11-09T16:50:23Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Simulations in this section */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the fifth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Running_simulations_under_specific_conditions|Running simulations under specific conditions]], or jump ahead to the next section, [[Third year simulation experiment/Dynamical properties and the diffusion coefficient|Dynamical properties and the diffusion coefficient]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
We can characterise the structure of systems that we simulate using [http://en.wikipedia.org/wiki/Radial_distribution_function radial distribution functions], which we denote &amp;lt;math&amp;gt;g(r)&amp;lt;/math&amp;gt;. Calculating the RDF for a simulation is very useful &amp;amp;mdash; it can tell us the distances from an atom at which we will find it&#039;s nearest neighbour, second nearest neighbour, and so on; it is also a quantity that can be accessed experimentally, and so provides a good check that the forcefield in our simulation is correctly reproducing the structural features.&lt;br /&gt;
&lt;br /&gt;
In this section, you are going to use VMD to calculate the radial distribution function for the solid, liquid, and vapour phases of the Lennard-Jones fluid.&lt;br /&gt;
&lt;br /&gt;
===Simulations in this section===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;RDF&#039;&#039;&#039; subfolder contains an example input script that you can use to record an atomic trajectory to generate RDFs for the solid, liquid, and vapour phase Lennard Jones systems. Make three copies of that script (one for each phase), and modify the density and temperature parameters to give the phase that you want (a phase diagram for the Lennard-Jones system can be found [http://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151 here]). &amp;lt;big&amp;gt;&#039;&#039;&#039;Note: when simulating the solid, you will need to change the lattice type in the lattice command to fcc, rather than sc.&#039;&#039;&#039;&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 9: perform simulations of the Lennard-Jones system in the three phases. When each is complete, download the trajectory and calculate &amp;lt;math&amp;gt;g(r)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;4\pi \int g(r) r^{2}\mathrm{d}r&amp;lt;/math&amp;gt;. Plot the RDFs for the three systems on the same axes, and attach a copy to your report. Discuss qualitatively the differences between the three RDFs, and what this tells you about the structure of the system in each phase. In the solid case, illustrate which lattice sites the first three peaks correspond to. What is the lattice spacing? What is the coordination number for each of the first three peaks? [15 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the sixth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Running simulations under specific conditions|Running simulations under specific conditions]], or jump ahead to the next section, [[Third year simulation experiment/Dynamical properties and the diffusion coefficient|Dynamical properties and the diffusion coefficient]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Calculating &amp;lt;math&amp;gt;g(r)&amp;lt;/math&amp;gt; in VMD===&lt;br /&gt;
&lt;br /&gt;
# Start VMD as before and load the trajectory that you want to analyse.&lt;br /&gt;
# Select &#039;&#039;&#039;Extensions&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Analysis&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Radial Pair Distribution Function g(r)&#039;&#039;&#039;&lt;br /&gt;
# Set &#039;&#039;&#039;Selection 1&#039;&#039;&#039; to &#039;&#039;&#039;all&#039;&#039;&#039; and &#039;&#039;&#039;Selection 2&#039;&#039;&#039; to &#039;&#039;&#039;all&#039;&#039;&#039;&lt;br /&gt;
# Change &#039;&#039;&#039;delta r&#039;&#039;&#039; to &#039;&#039;&#039;0.05&#039;&#039;&#039; &amp;amp;mdash; this is the distance between points in the generated RDF.&lt;br /&gt;
# Ensure that &#039;&#039;&#039;Use PBC&#039;&#039;&#039;, &#039;&#039;&#039;Display g(r)&#039;&#039;&#039;, &#039;&#039;&#039;Display Int(g(r))&#039;&#039;&#039;, and &#039;&#039;&#039;Save to File&#039;&#039;&#039; are checked&lt;br /&gt;
# Click &#039;&#039;&#039;Compute g(r)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After a short pause while it performs the calculation, VMD will display both the RDF, and its running integral. You will then be prompted to save this data &amp;amp;mdash; choose a location for the file that you will be able to find easily later.&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Structural_properties_and_the_radial_distribution_function&amp;diff=734699</id>
		<title>Third year simulation experiment/Structural properties and the radial distribution function</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Structural_properties_and_the_radial_distribution_function&amp;diff=734699"/>
		<updated>2018-11-09T16:50:08Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Simulations in this section */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the fifth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Running_simulations_under_specific_conditions|Running simulations under specific conditions]], or jump ahead to the next section, [[Third year simulation experiment/Dynamical properties and the diffusion coefficient|Dynamical properties and the diffusion coefficient]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
We can characterise the structure of systems that we simulate using [http://en.wikipedia.org/wiki/Radial_distribution_function radial distribution functions], which we denote &amp;lt;math&amp;gt;g(r)&amp;lt;/math&amp;gt;. Calculating the RDF for a simulation is very useful &amp;amp;mdash; it can tell us the distances from an atom at which we will find it&#039;s nearest neighbour, second nearest neighbour, and so on; it is also a quantity that can be accessed experimentally, and so provides a good check that the forcefield in our simulation is correctly reproducing the structural features.&lt;br /&gt;
&lt;br /&gt;
In this section, you are going to use VMD to calculate the radial distribution function for the solid, liquid, and vapour phases of the Lennard-Jones fluid.&lt;br /&gt;
&lt;br /&gt;
===Simulations in this section===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;RDF&#039;&#039;&#039; subfolder contains an example input script that you can use to record an atomic trajectory to generate RDFs for the solid, liquid, and vapour phase Lennard Jones systems. Make three copies of that script (one for each phase), and modify the density and temperature parameters to give the phase that you want (a phase diagram for the Lennard-Jones system can be found [http://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151 here]). &amp;lt;big&amp;gt;&#039;&#039;&#039;Note: when simulating the solid, you will need to change the lattice type in the lattice command to fcc, rather than sc.&#039;&#039;&#039;&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 9: perform simulations of the Lennard-Jones system in the three phases. When each is complete, download the trajectory and calculate &amp;lt;math&amp;gt;g(r)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;4\pi \int r^{2}g(r)\mathrm{d}r&amp;lt;/math&amp;gt;. Plot the RDFs for the three systems on the same axes, and attach a copy to your report. Discuss qualitatively the differences between the three RDFs, and what this tells you about the structure of the system in each phase. In the solid case, illustrate which lattice sites the first three peaks correspond to. What is the lattice spacing? What is the coordination number for each of the first three peaks? [15 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the sixth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Running simulations under specific conditions|Running simulations under specific conditions]], or jump ahead to the next section, [[Third year simulation experiment/Dynamical properties and the diffusion coefficient|Dynamical properties and the diffusion coefficient]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Calculating &amp;lt;math&amp;gt;g(r)&amp;lt;/math&amp;gt; in VMD===&lt;br /&gt;
&lt;br /&gt;
# Start VMD as before and load the trajectory that you want to analyse.&lt;br /&gt;
# Select &#039;&#039;&#039;Extensions&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Analysis&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Radial Pair Distribution Function g(r)&#039;&#039;&#039;&lt;br /&gt;
# Set &#039;&#039;&#039;Selection 1&#039;&#039;&#039; to &#039;&#039;&#039;all&#039;&#039;&#039; and &#039;&#039;&#039;Selection 2&#039;&#039;&#039; to &#039;&#039;&#039;all&#039;&#039;&#039;&lt;br /&gt;
# Change &#039;&#039;&#039;delta r&#039;&#039;&#039; to &#039;&#039;&#039;0.05&#039;&#039;&#039; &amp;amp;mdash; this is the distance between points in the generated RDF.&lt;br /&gt;
# Ensure that &#039;&#039;&#039;Use PBC&#039;&#039;&#039;, &#039;&#039;&#039;Display g(r)&#039;&#039;&#039;, &#039;&#039;&#039;Display Int(g(r))&#039;&#039;&#039;, and &#039;&#039;&#039;Save to File&#039;&#039;&#039; are checked&lt;br /&gt;
# Click &#039;&#039;&#039;Compute g(r)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After a short pause while it performs the calculation, VMD will display both the RDF, and its running integral. You will then be prompted to save this data &amp;amp;mdash; choose a location for the file that you will be able to find easily later.&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Running_simulations_under_specific_conditions&amp;diff=734688</id>
		<title>Third year simulation experiment/Running simulations under specific conditions</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Running_simulations_under_specific_conditions&amp;diff=734688"/>
		<updated>2018-10-31T11:47:13Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Temperature and Pressure Control */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the fourth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Equilibration|Equilibration]], or jump ahead to the next section, [[Third_year_simulation_experiment/Structural_properties_and_the_radial_distribution_function| Structural Properties and the Radial Distribution Functions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;THE FILES THAT YOU NEED FOR THIS SECTION ARE FOUND IN THE &amp;quot;NpT&amp;quot; SUBFOLDER.&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Changing Ensemble==&lt;br /&gt;
&lt;br /&gt;
So far, we have been able to do some simulations in which the number of particles and the volume of the simulation cell are held constant. The energy is also constant (within a certain degree of error, which is introduced by the approximations that we make to do the simulation). If the simulation is a working properly, then the pressure and temperature of the system should also reach a constant &#039;&#039;average&#039;&#039; value (although there will again be fluctuations). In the statistical thermodynamics lectures, you met the concept of ensembles, which are used in statistical mechanics to represent different sorts of experimental conditions. The simulations we have done so far are described by the &#039;&#039;microcanonical&#039;&#039;, or NVE ensemble (the letters represent those thermodynamic quantities which are constant).&lt;br /&gt;
&lt;br /&gt;
As chemists, we often want to understand what happens under particular experimental conditions &amp;amp;mdash; at 298K under 1 atmosphere of pressure, for example. These sorts of conditions are described by different ensembles in statistical mechanics, such as the NVT (&#039;&#039;canonical&#039;&#039;) or NpT (&#039;&#039;isobaric-isothermal&#039;&#039;) ensembles.&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to modify our simulations from the previous section to run under NpT conditions, and sketch an equation of state for our model fluid at atmospheric pressure.&lt;br /&gt;
&lt;br /&gt;
==Temperature and Pressure Control==&lt;br /&gt;
&lt;br /&gt;
The file npt.in can be used to perform a constant temperature/pressure simulation of our model fluid. It starts by melting a simple cubic crystal, just as before, so much of this file will look familiar to you. You will notice a new section near the top, however, called &#039;&#039;&#039;### SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&#039;&#039;&#039;. It contains three &#039;&#039;variables&#039;&#039; &amp;amp;mdash; these are used by the script later on to define the desired temperature, pressure, and timestep. The ellipses need to be replaced by the actual temperature, pressure and timestep that you want to use, so&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
variable T equal 0.5&lt;br /&gt;
variable p equal 1.0&lt;br /&gt;
variable timestep equal 0.75&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
would run a simulation at &amp;lt;math&amp;gt;T=0.5,\  p=1.0,\  \delta t=0.75&amp;lt;/math&amp;gt;. You should remember from the [[Third_year_simulation_experiment/Equilibration|Equilibration]] section that this is a poor choice of timestep!&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 8: Choose 5 temperatures (above the critical temperature &amp;lt;math&amp;gt;T^* = 1.5&amp;lt;/math&amp;gt;), and two pressures (you can get a good idea of what a reasonable pressure is in Lennard-Jones units by looking at the average pressure of your simulations from the last section). This gives ten phase points &amp;amp;mdash; five temperatures at each pressure. Create 10 copies of npt.in, and modify each to run a simulation at one of your chosen &amp;lt;math&amp;gt;\left(p, T\right)&amp;lt;/math&amp;gt; points. You should be able to use the results of the previous section to choose a timestep. Submit these ten jobs to the HPC portal. When your simulations have finished, download the log files as before. At the end of the log file, LAMMPS will output the values and errors for the pressure, temperature, and density &amp;lt;math&amp;gt;\left(\frac{N}{V}\right)&amp;lt;/math&amp;gt;. Use software of your choice to plot the density as a function of temperature for both of the pressures that you simulated.  Your graph(s) should include error bars in both the x and y directions. You should also include a line corresponding to the density predicted by the ideal gas law at that pressure. Is your simulated density lower or higher? Justify this. Does the discrepancy increase or decrease with pressure? [10 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Thermostats and Barostats - controlling the thermodynamic properties===&lt;br /&gt;
The statistical thermodynamics lectures will have introduced you to the &#039;&#039;equipartition theorem&#039;&#039;, which states that, on average, every degree of freedom in a system at equilibrium will have &amp;lt;math&amp;gt;\frac{1}{2}k_B T&amp;lt;/math&amp;gt; of energy. In our system with &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms, each with 3 degrees of freedom, we can write&lt;br /&gt;
&amp;lt;math&amp;gt;E_K = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i v_i^2 = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end of every timestep, we use the left hand side of this equation to calculate the kinetic energy, then divide by &amp;lt;math&amp;gt;\frac{3}{2}Nk_B&amp;lt;/math&amp;gt; to get the &#039;&#039;instantaneous&#039;&#039; temperature &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. In general, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; will fluctuate, and will be different to our &#039;&#039;target&#039;&#039; temperature, &amp;lt;math&amp;gt;\mathfrak{T}&amp;lt;/math&amp;gt; (this is whatever value we specify in the input script). We can change the temperature by multiplying every velocity by a constant factor, &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* If &amp;lt;math&amp;gt; T &amp;gt; \mathfrak{T} &amp;lt;/math&amp;gt;, then the kinetic energy of the system is too high, and we need to reduce it. &amp;lt;math&amp;gt;\gamma &amp;lt; 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* If &amp;lt;math&amp;gt; T &amp;lt; \mathfrak{T} &amp;lt;/math&amp;gt;, then the kinetic energy of the system is too low, and we need to increase it. &amp;lt;math&amp;gt;\gamma &amp;gt; 1&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We need to choose a scaling parameter &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt; so that the temperature is correct &amp;lt;math&amp;gt;T = \mathfrak{T}&amp;lt;/math&amp;gt; if we multiply every velocity &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;. We can write two equations:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i v_i^2 = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i \left(\gamma v_i\right)^2 = \frac{3}{2} N k_B \mathfrak{T}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By combining these equations, one can see that &amp;lt;math&amp;gt; \gamma = \sqrt{\frac{\mathfrak{T}}{T}} &amp;lt;/math&amp;gt; (satisfy yourself that this is true!). A target value of &amp;lt;math&amp;gt; \gamma &amp;lt;/math&amp;gt; of 1 is required and thus, dependent on whether it&#039;s larger or smaller than 1 the simulation can target the desired temperature.&lt;br /&gt;
&lt;br /&gt;
Controlling the pressure is a little more involved, but the principle is largely the same: at each timestep, the pressure of the system is calculated; if the pressure is too high, then the simulation box is made a little larger, while if the pressure is too low the box is made smaller. Simulations in which the pressure is controlled are thus in the NpT ensemble &amp;amp;mdash; the volume of the simulation box is not constant!&lt;br /&gt;
&lt;br /&gt;
===Examining the Input Script===&lt;br /&gt;
&lt;br /&gt;
Open one of your input scripts (it doesn&#039;t matter which), and look at the section &#039;&#039;&#039;### BRING SYSTEM TO REQUIRED STATE ###&#039;&#039;&#039;. The line &amp;lt;pre&amp;gt;fix npt all npt temp ${T} ${T} ${tdamp} iso ${p} ${p} ${pdamp}&amp;lt;/pre&amp;gt; is the one responsible for switching on the temperature and pressure control. LAMMPS actually allows us to heat or cool the system over the course of a simulation, if we want to &amp;amp;mdash; this is the reason that the temperature appears twice in this line. The first ${T} is the desired starting temperature, and the second is the desired temperature at the end of the simulation. We want a constant average temperature, so we specify the same value twice. The same goes for the pressure.&lt;br /&gt;
&lt;br /&gt;
Now look at the lines near the end of the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### MEASURE SYSTEM STATE ###&lt;br /&gt;
thermo_style custom step etotal temp press density&lt;br /&gt;
variable dens equal density&lt;br /&gt;
variable dens2 equal density*density&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
variable press equal press&lt;br /&gt;
variable press2 equal press*press&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_dens v_temp v_press v_dens2 v_temp2 v_press2&lt;br /&gt;
run 100000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command, &#039;&#039;thermo_style&#039;&#039;, controls which thermodynamic properties are recorded, as before. The next lines are used to measure &#039;&#039;average&#039;&#039; thermodynamic properties for the system. To draw our equations of state, we need to know the average temperature, pressure, and density, and the statistical errors in those quantities. The six variable lines link those quantities (and their squared values, needed for the errors), to variable names that we can use in the averaging command, which is the line starting &#039;&#039;fix aves...&#039;&#039;. This command takes a number of input values and averages them every so many timesteps. Exactly how often this happens depends in the values of the three numbers which follow &#039;&#039;ave/time&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the fourth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Equilibration|Equilibration]], or jump ahead to the next section, [[Third year simulation experiment/Structural properties and the radial distribution function|Structural properties and the radial distribution function]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734686</id>
		<title>Third year simulation experiment/Equilibration</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734686"/>
		<updated>2018-10-29T14:35:03Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Checking equilibration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We will be using the LAMMPS program to carry out our molecular dynamics simulations.&lt;br /&gt;
&#039;&#039;&#039;In several places in this section, we will ask you to consult the LAMMPS manual to find out things about how the software works. You can find the manual [https://lammps.sandia.gov/doc/Manual.html here].&#039;&#039;&#039; We appreciate that the format of this document can make it a little hard to navigate, but it is the definitive resource on how different commands in LAMMPS work, and is therefore invaluable. The files you will need for this section can be found in the intro folder downloaded previously.&lt;br /&gt;
&lt;br /&gt;
===Creating the simulation box===&lt;br /&gt;
In the previous section, it was pointed out that before we can start a simulation, we need to know the initial states of all of the atoms in the system. Exactly what information we need about each atom depends on which method of numerical integration we need, but at the very least we need to specify the starting position of each atom. If we wanted to simulate a crystal, this information would be quite easy to come by &amp;amp;mdash; we could just look up the crystal structure, and use that to generate coordinates for however many unit cells we wanted. For this purpose, LAMMPS includes a command which generates crystal lattice structures.&lt;br /&gt;
&lt;br /&gt;
Generating coordinates for atoms in a liquid is more difficult. There is no long range order, so we can&#039;t use a single point of reference to work out the positions of every other atom like we can in a solid. We could generate a random position for each atom. This would certainly create a disordered structure, but causes larger problems when we try to run the simulation.&lt;br /&gt;
&lt;br /&gt;
Instead, we are going to place the atoms on the lattice points of a simple cubic lattice. This, of course, is not a situation in which the system is likely to be found physically. It turns out, though, that if we simulate for enough time we will find that the atoms rearrange themselves into more realistic configurations. We will discuss towards the end of this section exactly what is meant by &amp;quot;enough time&amp;quot;!&lt;br /&gt;
&lt;br /&gt;
Consider the line in the input file &amp;lt;pre&amp;gt;lattice sc 0.8&amp;lt;/pre&amp;gt; This command creates a grid of points forming a simple cubic lattice (one lattice point per unit cell). The parameter &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt; specifies the number density (number of lattice points per unit volume). In a corresponding output file, you will see the line &amp;lt;pre&amp;gt;Lattice spacing in x,y,z = 1.07722 1.07722 1.07722&amp;lt;/pre&amp;gt; This indicates that the distance between the points of this lattice is &amp;lt;math&amp;gt;1.07722&amp;lt;/math&amp;gt; (in reduced units, remember!).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 6: Satisfy yourself that this lattice spacing corresponds to a number density of lattice points of &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt;. Consider instead a face-centred cubic lattice with a lattice point number density of 1.2. What is the side length of the cubic unit cell? [3 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The next lines in the input file are&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
region box block 0 10 0 10 0 10&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The corresponding log file output is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Created orthogonal box = (0 0 0) to (10.7722 10.7722 10.7722)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The region command simply defines a geometrical region in space, which we call &amp;quot;box&amp;quot;. In this case, &amp;quot;box&amp;quot; is a cube extending ten lattice spacings from the origin in all three dimensions. The subsequent create_box command tells LAMMPS to use the geometrical region called &amp;quot;box&amp;quot; as a template for the simulation box. The number 1 between &amp;quot;create_box&amp;quot; and &amp;quot;box&amp;quot; indicates that our simulation will contain only one type (species) of atom.&lt;br /&gt;
&lt;br /&gt;
So far we have defined a simulation box which is based around a virtual simple cubic lattice. Our box contains 1000 (10x10x10) unit cells of this lattice, and so contains 1000 lattice points. We now need to fill our simulation box with atoms. The input command is &amp;lt;pre&amp;gt;create_atoms 1 box&amp;lt;/pre&amp;gt; while the log file simply contains an acknowledgement of this &amp;lt;pre&amp;gt;Created 1000 atoms&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The create_atoms command has two arguments; the first tells LAMMPS that all of the atoms that we create will be of type 1. Every atom in the simulation has a type &amp;amp;mdash; because we will be simulating a pure fluid, containing only one chemical species, every atom will have the same type. The actual type that we assign to each atom is arbitrary &amp;amp;mdash; type 1 does not, for example, need to correspond to the element with atomic number 1 (hydrogen). If we wanted to simulate water, we might make the hydrogen atoms type 1 and the oxygen atoms type 2. We will specify the physical and chemical properties of each atom type later in the input script.&lt;br /&gt;
&lt;br /&gt;
The remaining data in the log file isn&#039;t very instructive as it stands &amp;amp;mdash; it simply contains a list of the thermodynamic properties of the simulation at certain intervals. In a few sections time, we will plot this data, but for now you can close the log file. Keep the input script open.&lt;br /&gt;
&lt;br /&gt;
===Setting the properties of the atoms===&lt;br /&gt;
&lt;br /&gt;
In addition to their positions, we also need the physical properties of the atoms to be able to perform the simulation. We set these properties on a &#039;per-type&#039; basis, so that every atom of the same type has the same mass and the same interactions.&lt;br /&gt;
&lt;br /&gt;
So far we have created 1000 atoms, and we know the starting (&amp;lt;math&amp;gt;t = 0&amp;lt;/math&amp;gt;) position for each of them. We have also set their masses, and told LAMMPS what sort of forces to calculate between them. The final thing we need to specify to completely specify the initial conditions is the velocity of each atom.&lt;br /&gt;
&lt;br /&gt;
Choosing initial velocities for the atoms is a little easier than choosing initial positions. From the statistical thermodynamics lectures, you should know that, at equilibrium, the velocities of atoms in any system must be distributed according to the [http://en.wikipedia.org/wiki/Maxwell%E2%80%93Boltzmann_distribution Maxwell-Boltzmann (MB) distribution]. If we know the masses of the atoms, and we know what temperature we want to simulate, then we can determine the relevant MB distribution function. LAMMPS is able to give every atom a random velocity whilst ensuring that overall the MB distribution is followed. This is the purpose of the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
velocity all create 1.5 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see the manual page for this command [http://lammps.sandia.gov/doc/velocity.html here], but the key sections are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;all&#039;&#039;&#039;: the &#039;&#039;group&#039;&#039; of atoms on which the command acts. &#039;&#039;&#039;all&#039;&#039;&#039; simply specifies that we want every atom to have a velocity assigned to it.&lt;br /&gt;
* &#039;&#039;&#039;1.5&#039;&#039;&#039;: the temperature, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, needed to calculate the MB distribution(in reduced units, as always)&lt;br /&gt;
&lt;br /&gt;
===Monitoring thermodynamic properties===&lt;br /&gt;
&lt;br /&gt;
We need to be sure that our simulation is correctly modelling whatever physical system we want to study. It is relatively easy to set up simulations, but how can we be sure that the &amp;quot;results&amp;quot; we get make sense? One of the best ways is to calculate from the simulation things that we can measure in experiment, and see if they agree. For example, we might want to simulate our system at a particular temperature and pressure, and measure the resulting density. If we repeat this over a range of temperatures at the same pressure, we will be able to plot an &#039;&#039;equation of state&#039;&#039;, which we could compare to experimental measurements.&lt;br /&gt;
&lt;br /&gt;
LAMMPS is able to calculate a great deal of thermodynamic information for us (you can see a full list of the properties it is able to calculate [http://lammps.sandia.gov/doc/thermo_style.html here]), but in these first simulations we are only interested in those properties specified in these commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
thermo 10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first controls which properties will be printed out in the log file. In this case, we print how much time we have simulated so far (which is &#039;&#039;not&#039;&#039; the same as how long it has taken us to simulate it!), the total energy of the atoms, their temperature, and their pressure. The second line tells LAMMPS to print this information on every 10th timestep.&lt;br /&gt;
&lt;br /&gt;
===Running the simulation===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Look at the lines below.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### SPECIFY TIMESTEP ###&lt;br /&gt;
variable timestep equal 0.001&lt;br /&gt;
variable n_steps equal floor(100/${timestep})&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
### RUN SIMULATION ###&lt;br /&gt;
run ${n_steps}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The second line (starting &amp;quot;variable timestep...&amp;quot;) tells LAMMPS that if it encounters the text ${timestep} on a subsequent line, it should replace it by the value given. In this case, the value ${timestep} is always replaced by 0.001.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt; It is now time to run your first simulation, submit the input script with the data file in the intro folder of the files you have downloaded Try changing the timestep - what happens when you make the timestep larger?. &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Visualising the trajectory===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;trajectory files&#039;&#039;&#039; contain the positions of all the atoms in the simulation, recorded at a set interval (for all of these simulations, this was every ten timesteps &amp;amp;mdash; this is controlled by the &#039;&#039;&#039;dump&#039;&#039;&#039; command in the input scripts). We use a programme called [http://www.ks.uiuc.edu/Research/vmd/ &#039;&#039;&#039;VMD&#039;&#039;&#039;] to view these trajectories, which you should find is already installed on both the desktop and laptop computers. You can run VMD from the start menu with &#039;&#039;&#039;Start&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;All Programs&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;University of Illinois&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;VMD&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
====Loading a Trajectory====&lt;br /&gt;
&lt;br /&gt;
We&#039;ll start by looking at the output of the 0.02 timestep simulation. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;File&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;New Molecule&#039;&#039;&#039;. Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button, then select the relevant trajectory file. In the &#039;&#039;&#039;Determine file type&#039;&#039;&#039; dropdown, select &#039;&#039;&#039;LAMMPS Trajectory&#039;&#039;&#039;. Then click &#039;&#039;&#039;Load&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You will see that the &#039;&#039;&#039;VMD 1.9.1 OpenGL Display&#039;&#039;&#039; window now shows a horrible mess. VMD&#039;s default behaviour is to draw lines between atoms which it thinks might be chemically bonded. Our system doesn&#039;t model chemical bonds, so we want to turn this off. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;Graphics&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Representations&#039;&#039;&#039;. This shows a list of &amp;quot;representations&amp;quot; of our atoms. You will see that at the moment, there is a single representation listed, and it is selected. It will have the &#039;&#039;Lines&#039;&#039; style, the &#039;&#039;Name&#039;&#039; colour, and the selection &#039;&#039;all&#039;&#039;. &amp;quot;Selection&amp;quot; simply tells VMD which atoms we want it to draw. We want to show every atom, so the current selection is fine. The &#039;&#039;name&#039;&#039; colouring method just makes VMD give atoms colours according to their specified type. The colour isn&#039;t important to us, so we can leave this be too. The &amp;quot;style&amp;quot; tells VMD what we want it to display for each atom. Change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; from &#039;&#039;Lines&#039;&#039; to &#039;&#039;VDW&#039;&#039;. You will see that the mess of lines is replaced by a mess of low resolution, overlapping spheres. Change the &#039;&#039;&#039;Sphere Scale&#039;&#039;&#039; to 0.3, and the &#039;&#039;&#039;Sphere Resolution&#039;&#039;&#039; to 17. The result should look a little smoother. Close the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window. You will notice that in the bottom right of the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, there is a small play button. Click this, and you will see the animated version of your simulation trajectory.&lt;br /&gt;
&lt;br /&gt;
By clicking and dragging with the mouse, you can rotate the simulation box (though this may be sluggish). At any time, you can reset the view by pressing the equals key.&lt;br /&gt;
&lt;br /&gt;
====Tracking a Single Particle====&lt;br /&gt;
To illustrate the periodic boundary conditions that we are using, we are going to draw almost all of the atoms as points, but we will pick a single atom at random to draw as a sphere. This will make it easy to see how a single atom moves through the box. Reset the display using the equals key, then use the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window controls to pause the trajectory and reset it to the first trajectory (play with the different buttons until you find the one that does this). You should see the perfect cubic lattice. Use the option &#039;&#039;&#039;Display&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Orthographic&#039;&#039;&#039; to change the drawing mode, then rotate the displayed crystal so that you are looking at one vertex (looking down the 111 direction, in crystallographic terms).&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window again. Change the representation style from &#039;&#039;&#039;VDW&#039;&#039;&#039; to points, then click the &#039;&#039;&#039;Create Rep&#039;&#039;&#039; button. This creates a second representation, allowing a subset of the atoms to be drawn in a different way. The &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; box allows us to choose which atoms this representation applies to. We just want to pick two of them at random &amp;amp;mdash; VMD assigns every atom an index, from 0 to N-1. In our case, there are 1000 atoms, so choose two numbers between 0 and 999. Changed the &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; field to &amp;lt;pre&amp;gt;index i or index j&amp;lt;/pre&amp;gt; where i and j are your chosen numbers, press return, then change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; to &#039;&#039;&#039;VDW&#039;&#039;&#039;. You should now see only two atoms represented by spheres, with the rest shown as small points. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, click play. Try rotating the box, and changing the playback speed.&lt;br /&gt;
&lt;br /&gt;
You will see that sometimes one of the spheres seems to change position across the box very rapidly &amp;amp;mdash; this occurs when it reaches one periodic boundary, and is reflected back across the other face. Try playing with some of the other representation types in VMD &amp;amp;mdash; it  is a very powerful package, which is often used to render images of simulated proteins, so many of its options aren&#039;t relevant to our simple system!&lt;br /&gt;
&lt;br /&gt;
===Checking equilibration===&lt;br /&gt;
&lt;br /&gt;
When we first set up a simulation, it is very important to make sure that our system reaches an equilibrium state. We characterise equilibrium by the average values of thermodynamic quantities becoming constant (due to the approximations that we have made, there will always be fluctuations, but the average values will become constant).&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to plot the thermodynamic output of the simulation to see how long it takes to reach the equilibrium state (and indeed, whether this happens at all). Instructions are given below to import data from the LAMMPS log file into Microsoft Excel. Once you have the data in a spreadsheet, you can plot it. If you know how to use some of the other plotting software available on the chemistry computers (like Origin), you are welcome to use it.&lt;br /&gt;
&lt;br /&gt;
# Open a blank Excel workbook&lt;br /&gt;
# Copy the data in the textfile into the first cell&lt;br /&gt;
# With these data highlighted, click the Data tab and &amp;quot;Text to Columns&amp;quot;&lt;br /&gt;
# Click &amp;quot;Delimited&amp;quot;, continue and let it be space delimited&lt;br /&gt;
# Click finish&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 7: make plots of the energy, temperature, and pressure, against time for the 0.001 timestep experiment (attach a picture to your report). Does the simulation reach equilibrium? When you have done this, make a single plot which shows the energy versus time for all of the timesteps you have simulated (again, attach a picture to your report). Of the timesteps that you used, which timestep will you use for subsequent simulations and why? [9 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734685</id>
		<title>Third year simulation experiment/Equilibration</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734685"/>
		<updated>2018-10-29T14:21:50Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Loading a Trajectory */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We will be using the LAMMPS program to carry out our molecular dynamics simulations.&lt;br /&gt;
&#039;&#039;&#039;In several places in this section, we will ask you to consult the LAMMPS manual to find out things about how the software works. You can find the manual [https://lammps.sandia.gov/doc/Manual.html here].&#039;&#039;&#039; We appreciate that the format of this document can make it a little hard to navigate, but it is the definitive resource on how different commands in LAMMPS work, and is therefore invaluable. The files you will need for this section can be found in the intro folder downloaded previously.&lt;br /&gt;
&lt;br /&gt;
===Creating the simulation box===&lt;br /&gt;
In the previous section, it was pointed out that before we can start a simulation, we need to know the initial states of all of the atoms in the system. Exactly what information we need about each atom depends on which method of numerical integration we need, but at the very least we need to specify the starting position of each atom. If we wanted to simulate a crystal, this information would be quite easy to come by &amp;amp;mdash; we could just look up the crystal structure, and use that to generate coordinates for however many unit cells we wanted. For this purpose, LAMMPS includes a command which generates crystal lattice structures.&lt;br /&gt;
&lt;br /&gt;
Generating coordinates for atoms in a liquid is more difficult. There is no long range order, so we can&#039;t use a single point of reference to work out the positions of every other atom like we can in a solid. We could generate a random position for each atom. This would certainly create a disordered structure, but causes larger problems when we try to run the simulation.&lt;br /&gt;
&lt;br /&gt;
Instead, we are going to place the atoms on the lattice points of a simple cubic lattice. This, of course, is not a situation in which the system is likely to be found physically. It turns out, though, that if we simulate for enough time we will find that the atoms rearrange themselves into more realistic configurations. We will discuss towards the end of this section exactly what is meant by &amp;quot;enough time&amp;quot;!&lt;br /&gt;
&lt;br /&gt;
Consider the line in the input file &amp;lt;pre&amp;gt;lattice sc 0.8&amp;lt;/pre&amp;gt; This command creates a grid of points forming a simple cubic lattice (one lattice point per unit cell). The parameter &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt; specifies the number density (number of lattice points per unit volume). In a corresponding output file, you will see the line &amp;lt;pre&amp;gt;Lattice spacing in x,y,z = 1.07722 1.07722 1.07722&amp;lt;/pre&amp;gt; This indicates that the distance between the points of this lattice is &amp;lt;math&amp;gt;1.07722&amp;lt;/math&amp;gt; (in reduced units, remember!).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 6: Satisfy yourself that this lattice spacing corresponds to a number density of lattice points of &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt;. Consider instead a face-centred cubic lattice with a lattice point number density of 1.2. What is the side length of the cubic unit cell? [3 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The next lines in the input file are&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
region box block 0 10 0 10 0 10&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The corresponding log file output is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Created orthogonal box = (0 0 0) to (10.7722 10.7722 10.7722)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The region command simply defines a geometrical region in space, which we call &amp;quot;box&amp;quot;. In this case, &amp;quot;box&amp;quot; is a cube extending ten lattice spacings from the origin in all three dimensions. The subsequent create_box command tells LAMMPS to use the geometrical region called &amp;quot;box&amp;quot; as a template for the simulation box. The number 1 between &amp;quot;create_box&amp;quot; and &amp;quot;box&amp;quot; indicates that our simulation will contain only one type (species) of atom.&lt;br /&gt;
&lt;br /&gt;
So far we have defined a simulation box which is based around a virtual simple cubic lattice. Our box contains 1000 (10x10x10) unit cells of this lattice, and so contains 1000 lattice points. We now need to fill our simulation box with atoms. The input command is &amp;lt;pre&amp;gt;create_atoms 1 box&amp;lt;/pre&amp;gt; while the log file simply contains an acknowledgement of this &amp;lt;pre&amp;gt;Created 1000 atoms&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The create_atoms command has two arguments; the first tells LAMMPS that all of the atoms that we create will be of type 1. Every atom in the simulation has a type &amp;amp;mdash; because we will be simulating a pure fluid, containing only one chemical species, every atom will have the same type. The actual type that we assign to each atom is arbitrary &amp;amp;mdash; type 1 does not, for example, need to correspond to the element with atomic number 1 (hydrogen). If we wanted to simulate water, we might make the hydrogen atoms type 1 and the oxygen atoms type 2. We will specify the physical and chemical properties of each atom type later in the input script.&lt;br /&gt;
&lt;br /&gt;
The remaining data in the log file isn&#039;t very instructive as it stands &amp;amp;mdash; it simply contains a list of the thermodynamic properties of the simulation at certain intervals. In a few sections time, we will plot this data, but for now you can close the log file. Keep the input script open.&lt;br /&gt;
&lt;br /&gt;
===Setting the properties of the atoms===&lt;br /&gt;
&lt;br /&gt;
In addition to their positions, we also need the physical properties of the atoms to be able to perform the simulation. We set these properties on a &#039;per-type&#039; basis, so that every atom of the same type has the same mass and the same interactions.&lt;br /&gt;
&lt;br /&gt;
So far we have created 1000 atoms, and we know the starting (&amp;lt;math&amp;gt;t = 0&amp;lt;/math&amp;gt;) position for each of them. We have also set their masses, and told LAMMPS what sort of forces to calculate between them. The final thing we need to specify to completely specify the initial conditions is the velocity of each atom.&lt;br /&gt;
&lt;br /&gt;
Choosing initial velocities for the atoms is a little easier than choosing initial positions. From the statistical thermodynamics lectures, you should know that, at equilibrium, the velocities of atoms in any system must be distributed according to the [http://en.wikipedia.org/wiki/Maxwell%E2%80%93Boltzmann_distribution Maxwell-Boltzmann (MB) distribution]. If we know the masses of the atoms, and we know what temperature we want to simulate, then we can determine the relevant MB distribution function. LAMMPS is able to give every atom a random velocity whilst ensuring that overall the MB distribution is followed. This is the purpose of the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
velocity all create 1.5 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see the manual page for this command [http://lammps.sandia.gov/doc/velocity.html here], but the key sections are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;all&#039;&#039;&#039;: the &#039;&#039;group&#039;&#039; of atoms on which the command acts. &#039;&#039;&#039;all&#039;&#039;&#039; simply specifies that we want every atom to have a velocity assigned to it.&lt;br /&gt;
* &#039;&#039;&#039;1.5&#039;&#039;&#039;: the temperature, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, needed to calculate the MB distribution(in reduced units, as always)&lt;br /&gt;
&lt;br /&gt;
===Monitoring thermodynamic properties===&lt;br /&gt;
&lt;br /&gt;
We need to be sure that our simulation is correctly modelling whatever physical system we want to study. It is relatively easy to set up simulations, but how can we be sure that the &amp;quot;results&amp;quot; we get make sense? One of the best ways is to calculate from the simulation things that we can measure in experiment, and see if they agree. For example, we might want to simulate our system at a particular temperature and pressure, and measure the resulting density. If we repeat this over a range of temperatures at the same pressure, we will be able to plot an &#039;&#039;equation of state&#039;&#039;, which we could compare to experimental measurements.&lt;br /&gt;
&lt;br /&gt;
LAMMPS is able to calculate a great deal of thermodynamic information for us (you can see a full list of the properties it is able to calculate [http://lammps.sandia.gov/doc/thermo_style.html here]), but in these first simulations we are only interested in those properties specified in these commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
thermo 10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first controls which properties will be printed out in the log file. In this case, we print how much time we have simulated so far (which is &#039;&#039;not&#039;&#039; the same as how long it has taken us to simulate it!), the total energy of the atoms, their temperature, and their pressure. The second line tells LAMMPS to print this information on every 10th timestep.&lt;br /&gt;
&lt;br /&gt;
===Running the simulation===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Look at the lines below.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### SPECIFY TIMESTEP ###&lt;br /&gt;
variable timestep equal 0.001&lt;br /&gt;
variable n_steps equal floor(100/${timestep})&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
### RUN SIMULATION ###&lt;br /&gt;
run ${n_steps}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The second line (starting &amp;quot;variable timestep...&amp;quot;) tells LAMMPS that if it encounters the text ${timestep} on a subsequent line, it should replace it by the value given. In this case, the value ${timestep} is always replaced by 0.001.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt; It is now time to run your first simulation, submit the input script with the data file in the intro folder of the files you have downloaded Try changing the timestep - what happens when you make the timestep larger?. &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Visualising the trajectory===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;trajectory files&#039;&#039;&#039; contain the positions of all the atoms in the simulation, recorded at a set interval (for all of these simulations, this was every ten timesteps &amp;amp;mdash; this is controlled by the &#039;&#039;&#039;dump&#039;&#039;&#039; command in the input scripts). We use a programme called [http://www.ks.uiuc.edu/Research/vmd/ &#039;&#039;&#039;VMD&#039;&#039;&#039;] to view these trajectories, which you should find is already installed on both the desktop and laptop computers. You can run VMD from the start menu with &#039;&#039;&#039;Start&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;All Programs&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;University of Illinois&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;VMD&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
====Loading a Trajectory====&lt;br /&gt;
&lt;br /&gt;
We&#039;ll start by looking at the output of the 0.02 timestep simulation. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;File&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;New Molecule&#039;&#039;&#039;. Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button, then select the relevant trajectory file. In the &#039;&#039;&#039;Determine file type&#039;&#039;&#039; dropdown, select &#039;&#039;&#039;LAMMPS Trajectory&#039;&#039;&#039;. Then click &#039;&#039;&#039;Load&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You will see that the &#039;&#039;&#039;VMD 1.9.1 OpenGL Display&#039;&#039;&#039; window now shows a horrible mess. VMD&#039;s default behaviour is to draw lines between atoms which it thinks might be chemically bonded. Our system doesn&#039;t model chemical bonds, so we want to turn this off. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;Graphics&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Representations&#039;&#039;&#039;. This shows a list of &amp;quot;representations&amp;quot; of our atoms. You will see that at the moment, there is a single representation listed, and it is selected. It will have the &#039;&#039;Lines&#039;&#039; style, the &#039;&#039;Name&#039;&#039; colour, and the selection &#039;&#039;all&#039;&#039;. &amp;quot;Selection&amp;quot; simply tells VMD which atoms we want it to draw. We want to show every atom, so the current selection is fine. The &#039;&#039;name&#039;&#039; colouring method just makes VMD give atoms colours according to their specified type. The colour isn&#039;t important to us, so we can leave this be too. The &amp;quot;style&amp;quot; tells VMD what we want it to display for each atom. Change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; from &#039;&#039;Lines&#039;&#039; to &#039;&#039;VDW&#039;&#039;. You will see that the mess of lines is replaced by a mess of low resolution, overlapping spheres. Change the &#039;&#039;&#039;Sphere Scale&#039;&#039;&#039; to 0.3, and the &#039;&#039;&#039;Sphere Resolution&#039;&#039;&#039; to 17. The result should look a little smoother. Close the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window. You will notice that in the bottom right of the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, there is a small play button. Click this, and you will see the animated version of your simulation trajectory.&lt;br /&gt;
&lt;br /&gt;
By clicking and dragging with the mouse, you can rotate the simulation box (though this may be sluggish). At any time, you can reset the view by pressing the equals key.&lt;br /&gt;
&lt;br /&gt;
====Tracking a Single Particle====&lt;br /&gt;
To illustrate the periodic boundary conditions that we are using, we are going to draw almost all of the atoms as points, but we will pick a single atom at random to draw as a sphere. This will make it easy to see how a single atom moves through the box. Reset the display using the equals key, then use the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window controls to pause the trajectory and reset it to the first trajectory (play with the different buttons until you find the one that does this). You should see the perfect cubic lattice. Use the option &#039;&#039;&#039;Display&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Orthographic&#039;&#039;&#039; to change the drawing mode, then rotate the displayed crystal so that you are looking at one vertex (looking down the 111 direction, in crystallographic terms).&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window again. Change the representation style from &#039;&#039;&#039;VDW&#039;&#039;&#039; to points, then click the &#039;&#039;&#039;Create Rep&#039;&#039;&#039; button. This creates a second representation, allowing a subset of the atoms to be drawn in a different way. The &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; box allows us to choose which atoms this representation applies to. We just want to pick two of them at random &amp;amp;mdash; VMD assigns every atom an index, from 0 to N-1. In our case, there are 1000 atoms, so choose two numbers between 0 and 999. Changed the &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; field to &amp;lt;pre&amp;gt;index i or index j&amp;lt;/pre&amp;gt; where i and j are your chosen numbers, press return, then change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; to &#039;&#039;&#039;VDW&#039;&#039;&#039;. You should now see only two atoms represented by spheres, with the rest shown as small points. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, click play. Try rotating the box, and changing the playback speed.&lt;br /&gt;
&lt;br /&gt;
You will see that sometimes one of the spheres seems to change position across the box very rapidly &amp;amp;mdash; this occurs when it reaches one periodic boundary, and is reflected back across the other face. Try playing with some of the other representation types in VMD &amp;amp;mdash; it  is a very powerful package, which is often used to render images of simulated proteins, so many of its options aren&#039;t relevant to our simple system!&lt;br /&gt;
&lt;br /&gt;
===Checking equilibration===&lt;br /&gt;
&lt;br /&gt;
When we first set up a simulation, it is very important to make sure that our system reaches an equilibrium state. We characterise equilibrium by the average values of thermodynamic quantities becoming constant (due to the approximations that we have made, there will always be fluctuations, but the average values will become constant).&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to plot the thermodynamic output of the simulation to see how long it takes to reach the equilibrium state (and indeed, whether this happens at all). Instructions are given below to import data from the LAMMPS log file into Microsoft Excel. Once you have the data in a spreadsheet, you can plot it. If you know how to use some of the other plotting software available on the chemistry computers (like Origin), you are welcome to use it.&lt;br /&gt;
&lt;br /&gt;
# Open a blank Excel workbook&lt;br /&gt;
# Choose the &#039;&#039;&#039;Data&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;From Text&#039;&#039;&#039; button&lt;br /&gt;
# Select one of your simulation log files&lt;br /&gt;
# Set the &#039;&#039;&#039;Start import at row&#039;&#039;&#039; field to &#039;&#039;&#039;25&#039;&#039;&#039; (this ignores all of the diagnostic information at the top of the file)&lt;br /&gt;
# Set the &#039;&#039;&#039;Original Data type&#039;&#039;&#039; to &#039;&#039;&#039;Delimited&#039;&#039;&#039;, then click &#039;&#039;&#039;Next&#039;&#039;&#039;&lt;br /&gt;
# Tick the &#039;&#039;&#039;Space&#039;&#039;&#039; box, and make sure that &#039;&#039;&#039;Treat consecutive delimiters as one&#039;&#039;&#039; box is ticked.&lt;br /&gt;
# On the next dialog, you can select where you want the data to be inserted. When you are happy, click &#039;&#039;&#039;OK&#039;&#039;&#039;. The data will be inserted into your spreadsheet.&lt;br /&gt;
# Scroll to the bottom of the data &amp;amp;mdash; you will see a lot of timing information from the simulation. Delete everything beyond the end of your thermodynamic data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 7: make plots of the energy, temperature, and pressure, against time for the 0.001 timestep experiment (attach a picture to your report). Does the simulation reach equilibrium? When you have done this, make a single plot which shows the energy versus time for all of the timesteps you have simulated (again, attach a picture to your report). Of the timesteps that you used, which timestep will you use for subsequent simulations and why? [9 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Files_to_download&amp;diff=734684</id>
		<title>Third year simulation experiment/Files to download</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Files_to_download&amp;diff=734684"/>
		<updated>2018-10-29T10:43:36Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Getting the files for the experiment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the first section of the third year simulation experiment. You can return to the introduction page, [[Third year simulation experiment]], or jump ahead to the next section, [[Third year simulation experiment/Introduction to molecular dynamics simulation|Introduction to molecular dynamics simulation]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
All of the simulations that you run in this experiment are going to be performed on the Imperial [http://www3.imperial.ac.uk/ict/services/hpc High Performance Computing] (HPC) systems. To do this, you must login to one of the HPC machines, add your simulation task to a queue of jobs waiting to run, and then wait for it to finish. For the small-scale simulations that we will perform in this experiment, the queue time should not be too long. However, you should expect to have to wait up to several hours for results to be available, particularly in the later stages!&lt;br /&gt;
&lt;br /&gt;
In each section of the exercise, we have tried to provide a number of mathematical and/or research exercises that you should attempt while you are waiting for the simulations in that section to be completed. You can also use this time to write your report on the previous sections!&lt;br /&gt;
&lt;br /&gt;
In this first section, we will teach you how to login to the HPC computers and submit an example simulation. While you wait for that example to complete, you can move on to the next section and read about the theory of molecular dynamics simulations&lt;br /&gt;
&lt;br /&gt;
==Logging into the HPC Portal==&lt;br /&gt;
&lt;br /&gt;
The simulations that you will perform in this experiment can in principle be performed on a desktop computer. However, these machines can only do a single simulation at a time, and are rather slow. Instead, we are going to run simulations on the college&#039;s supercomputer resources. This offers two large advantages. Firstly, even the longest simulations we will perform should take only a few hours. More importantly, you will be able to perform several simulations at the same time. In fact, to use the HPC service you must add your simulations to a queue of &amp;quot;jobs&amp;quot; that the supercomputer will perform. You can add as many jobs as you like to this queue, and simple come back to collect the results some time later.&lt;br /&gt;
&lt;br /&gt;
To start, go to [http://portal.hpc.imperial.ac.uk the HPC portal login page]. You can login with your normal college credentials. We first need to create a &amp;quot;project&amp;quot; with which your simulations will be associated. Click &#039;&#039;&#039;Projects&#039;&#039;&#039; in the menu on the left hand side, then type a name in the &amp;quot;Add Project&amp;quot; box and click &#039;&#039;&#039;Add&#039;&#039;&#039;. You are free to choose whichever name you like, but a sensible choice might be something such as &amp;quot;ThirdYearSimulationExpt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Leave the HPC Portal webpage open for now &amp;amp;mdash; we will return to it shortly.&lt;br /&gt;
&lt;br /&gt;
==Getting the files for the experiment==&lt;br /&gt;
&lt;br /&gt;
You can download all of the files that you will need for this experiment [https://github.com/niallj/ImperialChem-Year3SimExpt1415/archive/master.zip from this address]. This .zip archive contains a folder called &#039;&#039;&#039;ImperialChem-Year3SimExpt1415-master&#039;&#039;&#039;, which you should extract to a location of your choice. It contains a number of subfolders &amp;amp;mdash; one for each section of the experiment. Every subsequent page of this lab manual will begin with a line telling you which folder contains the necessary files, like this one:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;&#039;&#039;&#039;THE FILES THAT YOU NEED FOR THIS SECTION ARE FOUND IN THE &amp;quot;Intro&amp;quot; SUBFOLDER&#039;&#039;&#039;.&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Have a look in the &#039;&#039;&#039;&amp;quot;Intro&amp;quot;&#039;&#039;&#039; folder now. It contains a file called &#039;&#039;&#039;melt_crystal.in&#039;&#039;&#039;, which you should open with a text editor (like Notepad++ which you can find in Software Hub on your Desktop). This file is called an &amp;quot;input script&amp;quot;, and it controls how the simulation software operates. We will perform all of our simulations with a software package called [http://lammps.sandia.gov LAMMPS]. Over the course of the experiment, you will learn what all of the commands in this file mean. For now, we are going to use this file to run a few trial simulations. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the first section of the third year simulation experiment.  You can return to the introduction page, [[Third year simulation experiment]], or jump ahead to the next section, [[Third year simulation experiment/Introduction to molecular dynamics simulation|Introduction to molecular dynamics simulation]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Files_to_download&amp;diff=734683</id>
		<title>Third year simulation experiment/Files to download</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Files_to_download&amp;diff=734683"/>
		<updated>2018-10-29T10:41:35Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Getting the files for the experiment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the first section of the third year simulation experiment. You can return to the introduction page, [[Third year simulation experiment]], or jump ahead to the next section, [[Third year simulation experiment/Introduction to molecular dynamics simulation|Introduction to molecular dynamics simulation]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
All of the simulations that you run in this experiment are going to be performed on the Imperial [http://www3.imperial.ac.uk/ict/services/hpc High Performance Computing] (HPC) systems. To do this, you must login to one of the HPC machines, add your simulation task to a queue of jobs waiting to run, and then wait for it to finish. For the small-scale simulations that we will perform in this experiment, the queue time should not be too long. However, you should expect to have to wait up to several hours for results to be available, particularly in the later stages!&lt;br /&gt;
&lt;br /&gt;
In each section of the exercise, we have tried to provide a number of mathematical and/or research exercises that you should attempt while you are waiting for the simulations in that section to be completed. You can also use this time to write your report on the previous sections!&lt;br /&gt;
&lt;br /&gt;
In this first section, we will teach you how to login to the HPC computers and submit an example simulation. While you wait for that example to complete, you can move on to the next section and read about the theory of molecular dynamics simulations&lt;br /&gt;
&lt;br /&gt;
==Logging into the HPC Portal==&lt;br /&gt;
&lt;br /&gt;
The simulations that you will perform in this experiment can in principle be performed on a desktop computer. However, these machines can only do a single simulation at a time, and are rather slow. Instead, we are going to run simulations on the college&#039;s supercomputer resources. This offers two large advantages. Firstly, even the longest simulations we will perform should take only a few hours. More importantly, you will be able to perform several simulations at the same time. In fact, to use the HPC service you must add your simulations to a queue of &amp;quot;jobs&amp;quot; that the supercomputer will perform. You can add as many jobs as you like to this queue, and simple come back to collect the results some time later.&lt;br /&gt;
&lt;br /&gt;
To start, go to [http://portal.hpc.imperial.ac.uk the HPC portal login page]. You can login with your normal college credentials. We first need to create a &amp;quot;project&amp;quot; with which your simulations will be associated. Click &#039;&#039;&#039;Projects&#039;&#039;&#039; in the menu on the left hand side, then type a name in the &amp;quot;Add Project&amp;quot; box and click &#039;&#039;&#039;Add&#039;&#039;&#039;. You are free to choose whichever name you like, but a sensible choice might be something such as &amp;quot;ThirdYearSimulationExpt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Leave the HPC Portal webpage open for now &amp;amp;mdash; we will return to it shortly.&lt;br /&gt;
&lt;br /&gt;
==Getting the files for the experiment==&lt;br /&gt;
&lt;br /&gt;
You can download all of the files that you will need for this experiment [https://github.com/niallj/ImperialChem-Year3SimExpt1415/archive/master.zip from this address]. This .zip archive contains a folder called &#039;&#039;&#039;ImperialChem-Year3SimExpt1415-master&#039;&#039;&#039;, which you should extract to a location of your choice. It contains a number of subfolders &amp;amp;mdash; one for each section of the experiment. Every subsequent page of this lab manual will begin with a line telling you which folder contains the necessary files, like this one:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;&#039;&#039;&#039;THE FILES THAT YOU NEED FOR THIS SECTION ARE FOUND IN THE &amp;quot;Intro&amp;quot; SUBFOLDER&#039;&#039;&#039;.&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Have a look in the &#039;&#039;&#039;&amp;quot;Intro&amp;quot;&#039;&#039;&#039; folder now. It contains a file called &#039;&#039;&#039;melt_crystal.in&#039;&#039;&#039;, which you should open with a text editor (like Notepad++ which you can find in Software Hub on your Desktop). This file is called an &amp;quot;input script&amp;quot;, and it controls how the simulation software operates. We will perform all of our simulations with a software package called [http://lammps.sandia.gov LAMMPS]. Over the course of the experiment, you will learn what all of the commands in this file mean. For now, we are going to use this file to run a few trial simulations. While you wait for them to finish you can read the next page, which explains the concepts of molecular dynamics simulation.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the first section of the third year simulation experiment.  You can return to the introduction page, [[Third year simulation experiment]], or jump ahead to the next section, [[Third year simulation experiment/Introduction to molecular dynamics simulation|Introduction to molecular dynamics simulation]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Structural_properties_and_the_radial_distribution_function&amp;diff=734680</id>
		<title>Third year simulation experiment/Structural properties and the radial distribution function</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Structural_properties_and_the_radial_distribution_function&amp;diff=734680"/>
		<updated>2018-10-18T13:22:58Z</updated>

		<summary type="html">&lt;p&gt;Otr12: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the fifth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Running_simulations_under_specific_conditions|Running simulations under specific conditions]], or jump ahead to the next section, [[Third year simulation experiment/Dynamical properties and the diffusion coefficient|Dynamical properties and the diffusion coefficient]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
We can characterise the structure of systems that we simulate using [http://en.wikipedia.org/wiki/Radial_distribution_function radial distribution functions], which we denote &amp;lt;math&amp;gt;g(r)&amp;lt;/math&amp;gt;. Calculating the RDF for a simulation is very useful &amp;amp;mdash; it can tell us the distances from an atom at which we will find it&#039;s nearest neighbour, second nearest neighbour, and so on; it is also a quantity that can be accessed experimentally, and so provides a good check that the forcefield in our simulation is correctly reproducing the structural features.&lt;br /&gt;
&lt;br /&gt;
In this section, you are going to use VMD to calculate the radial distribution function for the solid, liquid, and vapour phases of the Lennard-Jones fluid.&lt;br /&gt;
&lt;br /&gt;
===Simulations in this section===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;RDF&#039;&#039;&#039; subfolder contains an example input script that you can use to record an atomic trajectory to generate RDFs for the solid, liquid, and vapour phase Lennard Jones systems. Make three copies of that script (one for each phase), and modify the density and temperature parameters to give the phase that you want (a phase diagram for the Lennard-Jones system can be found [http://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151 here]). &amp;lt;big&amp;gt;&#039;&#039;&#039;Note: when simulating the solid, you will need to change the lattice type in the lattice command to fcc, rather than sc.&#039;&#039;&#039;&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 9: perform simulations of the Lennard-Jones system in the three phases. When each is complete, download the trajectory and calculate &amp;lt;math&amp;gt;g(r)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\int g(r)\mathrm{d}r&amp;lt;/math&amp;gt;. Plot the RDFs for the three systems on the same axes, and attach a copy to your report. Discuss qualitatively the differences between the three RDFs, and what this tells you about the structure of the system in each phase. In the solid case, illustrate which lattice sites the first three peaks correspond to. What is the lattice spacing? What is the coordination number for each of the first three peaks? [15 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the sixth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Running simulations under specific conditions|Running simulations under specific conditions]], or jump ahead to the next section, [[Third year simulation experiment/Dynamical properties and the diffusion coefficient|Dynamical properties and the diffusion coefficient]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Calculating &amp;lt;math&amp;gt;g(r)&amp;lt;/math&amp;gt; in VMD===&lt;br /&gt;
&lt;br /&gt;
# Start VMD as before and load the trajectory that you want to analyse.&lt;br /&gt;
# Select &#039;&#039;&#039;Extensions&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Analysis&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Radial Pair Distribution Function g(r)&#039;&#039;&#039;&lt;br /&gt;
# Set &#039;&#039;&#039;Selection 1&#039;&#039;&#039; to &#039;&#039;&#039;all&#039;&#039;&#039; and &#039;&#039;&#039;Selection 2&#039;&#039;&#039; to &#039;&#039;&#039;all&#039;&#039;&#039;&lt;br /&gt;
# Change &#039;&#039;&#039;delta r&#039;&#039;&#039; to &#039;&#039;&#039;0.05&#039;&#039;&#039; &amp;amp;mdash; this is the distance between points in the generated RDF.&lt;br /&gt;
# Ensure that &#039;&#039;&#039;Use PBC&#039;&#039;&#039;, &#039;&#039;&#039;Display g(r)&#039;&#039;&#039;, &#039;&#039;&#039;Display Int(g(r))&#039;&#039;&#039;, and &#039;&#039;&#039;Save to File&#039;&#039;&#039; are checked&lt;br /&gt;
# Click &#039;&#039;&#039;Compute g(r)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After a short pause while it performs the calculation, VMD will display both the RDF, and its running integral. You will then be prompted to save this data &amp;amp;mdash; choose a location for the file that you will be able to find easily later.&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Structural_properties_and_the_radial_distribution_function&amp;diff=734679</id>
		<title>Third year simulation experiment/Structural properties and the radial distribution function</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Structural_properties_and_the_radial_distribution_function&amp;diff=734679"/>
		<updated>2018-10-18T13:22:35Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Simulations in this section */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the fifth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Running_simulations_under_specific_conditions|Running simulations under specific conditions]], or jump ahead to the next section, [[Third year simulation experiment/Dynamical properties and the diffusion coefficient|Dynamical properties and the diffusion coefficient]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
We can characterise the structure of systems that we simulate using [http://en.wikipedia.org/wiki/Radial_distribution_function radial distribution functions], which we denote &amp;lt;math&amp;gt;g(r)&amp;lt;/math&amp;gt;. Calculating the RDF for a simulation is very useful &amp;amp;mdash; it can tell us the distances from an atom at which we will find it&#039;s nearest neighbour, second nearest neighbour, and so on; it is also a quantity that can be accessed experimentally, and so provides a good check that the forcefield in our simulation is correctly reproducing the structural features.&lt;br /&gt;
&lt;br /&gt;
In this section, you are going to use VMD to calculate the radial distribution function for the solid, liquid, and vapour phases of the Lennard-Jones fluid.&lt;br /&gt;
&lt;br /&gt;
===Calculating &amp;lt;math&amp;gt;g(r)&amp;lt;/math&amp;gt; in VMD===&lt;br /&gt;
&lt;br /&gt;
# Start VMD as before and load the trajectory that you want to analyse.&lt;br /&gt;
# Select &#039;&#039;&#039;Extensions&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Analysis&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Radial Pair Distribution Function g(r)&#039;&#039;&#039;&lt;br /&gt;
# Set &#039;&#039;&#039;Selection 1&#039;&#039;&#039; to &#039;&#039;&#039;all&#039;&#039;&#039; and &#039;&#039;&#039;Selection 2&#039;&#039;&#039; to &#039;&#039;&#039;all&#039;&#039;&#039;&lt;br /&gt;
# Change &#039;&#039;&#039;delta r&#039;&#039;&#039; to &#039;&#039;&#039;0.05&#039;&#039;&#039; &amp;amp;mdash; this is the distance between points in the generated RDF.&lt;br /&gt;
# Ensure that &#039;&#039;&#039;Use PBC&#039;&#039;&#039;, &#039;&#039;&#039;Display g(r)&#039;&#039;&#039;, &#039;&#039;&#039;Display Int(g(r))&#039;&#039;&#039;, and &#039;&#039;&#039;Save to File&#039;&#039;&#039; are checked&lt;br /&gt;
# Click &#039;&#039;&#039;Compute g(r)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After a short pause while it performs the calculation, VMD will display both the RDF, and its running integral. You will then be prompted to save this data &amp;amp;mdash; choose a location for the file that you will be able to find easily later.&lt;br /&gt;
&lt;br /&gt;
===Simulations in this section===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;RDF&#039;&#039;&#039; subfolder contains an example input script that you can use to record an atomic trajectory to generate RDFs for the solid, liquid, and vapour phase Lennard Jones systems. Make three copies of that script (one for each phase), and modify the density and temperature parameters to give the phase that you want (a phase diagram for the Lennard-Jones system can be found [http://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151 here]). &amp;lt;big&amp;gt;&#039;&#039;&#039;Note: when simulating the solid, you will need to change the lattice type in the lattice command to fcc, rather than sc.&#039;&#039;&#039;&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 9: perform simulations of the Lennard-Jones system in the three phases. When each is complete, download the trajectory and calculate &amp;lt;math&amp;gt;g(r)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\int g(r)\mathrm{d}r&amp;lt;/math&amp;gt;. Plot the RDFs for the three systems on the same axes, and attach a copy to your report. Discuss qualitatively the differences between the three RDFs, and what this tells you about the structure of the system in each phase. In the solid case, illustrate which lattice sites the first three peaks correspond to. What is the lattice spacing? What is the coordination number for each of the first three peaks? [15 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the sixth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Running simulations under specific conditions|Running simulations under specific conditions]], or jump ahead to the next section, [[Third year simulation experiment/Dynamical properties and the diffusion coefficient|Dynamical properties and the diffusion coefficient]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment&amp;diff=734678</id>
		<title>Third year simulation experiment</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment&amp;diff=734678"/>
		<updated>2018-10-18T12:06:04Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Assessment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;This is the optional experiment which may be chosen by any third year student. If you are looking for the compulsory simulation experiment for students studying chemistry with molecular physics, you will find it [[Third_year_CMP_compulsory_experiment|here]].&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Computer simulation is widely used to study a huge variety of chemical phenomena, from the behaviour of exotic materials under extreme conditions to protein folding and the properties of biological systems such as lipid membranes. In this experiment, we hope to give you a gentle introduction to one of the most powerful methods for the simulation of chemical systems, &#039;&#039;&#039;molecular dynamics simulation&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This course closely follows some of the ideas introduced in Professor Bresme&#039;s statistical thermodynamics lecture course. Do not worry if you are doing this experiment before the lectures begin, everything that you need to know to complete the experiment will be explained in these instructions. We will begin with a brief overview of the fundamental theory behind the method, before you start running your own simulations of a simple liquid using the college&#039;s [http://www.imperial.ac.uk/admin-services/ict/self-service/research-support/hpc/ high performance computing] facilities.&lt;br /&gt;
&lt;br /&gt;
At the end of this experiment, you will have performed your own simulations using state of the art software packages used by researchers all around the world, and used those simulations to calculate both structural and dynamic properties of a simple liquid. You will have seen how the concepts of statistical physics introduced by Professor Bresme are needed to calculate thermodynamic quantities such as temperature and pressure in computer simulations, and you will see how computers can be used to validate those concepts.&lt;br /&gt;
&lt;br /&gt;
All of the information that you need to complete the experiment is provided in these wiki pages. We have also tried to provide links to external resources and relevant textbooks where possible &amp;amp;mdash; unless explicitly stated, reading these resources &#039;&#039;&#039;is not required&#039;&#039;&#039;; they are provided only as further information for those interested in the subject.&lt;br /&gt;
&lt;br /&gt;
==Assessment==&lt;br /&gt;
&lt;br /&gt;
At the end of this experiment you must submit a report (pdf format via turnitin). The report should be structured:&lt;br /&gt;
&lt;br /&gt;
* Extended Abstract (20% of the total mark)&lt;br /&gt;
* Results and Discussion (60% of total mark)&lt;br /&gt;
* Conclusion (20% of total mark)&lt;br /&gt;
* References&lt;br /&gt;
&lt;br /&gt;
Relevant supplementary material can be added at the end of the report so long as it supports your discussion. The marking criteria is divided such that the abstract and introduction and the conclusion make up 20% of the total mark each. The results and discussion section, consisting of questions, will yield the remaining 60% of the total mark - each mark earned equates to 1% of the total mark. Importantly, work that presents an engaging dialogue and valid conclusion based on legitimate evidence will score highly. Presentation of results is arguably the most crucial part of science; you don&#039;t just show anything to the scientific community (for fear of inaccuracies being broadly spread and a retraction asked of you!), you show something relevant and defensible.&lt;br /&gt;
&lt;br /&gt;
The abstract is often confused with a conclusion because we&#039;re not really taught how to write one. It&#039;s a section you write after writing the rest of the paper and doesn&#039;t go into as much detail as the conclusion but you sum up the relevance of the research (intro), what you have done, what results you have to show to support this and the ultimate conclusion.&lt;br /&gt;
&lt;br /&gt;
Your introduction paints a picture of the background of the research; what has been done by others and where is the niche for your work. How will your work benefit the community - maybe it&#039;s a new technique. You open up the niche so the subsequent discussion inserts your work into the existing community or (for high impact journals like Nature) creates a question and novel direction that can be picked up and worked on by other interested parties. In this lab, it would be good if you can demonstrate some of the importance of your results and impact it had on Science and society.&lt;br /&gt;
&lt;br /&gt;
Results and Discussion consists of questions throughout the lab and it would be perfectly acceptable to copy the questions and write your answer beneath - there are a total of 10 tasks to complete.&lt;br /&gt;
&lt;br /&gt;
Conclusions - tie up the research and what your results show. Reread your intro, what are you trying to do? How does your research do this?&lt;br /&gt;
Work through the exercises and think about what each of your result mean physically. If you present something interesting in an engaging way, you will score highly. If anything is not clear here, please ask me in the lab or by email. Reports should be submitted to Blackboard by Wednesday 12:00 the week after you undertook the lab.&lt;br /&gt;
&lt;br /&gt;
==Getting Help==&lt;br /&gt;
&lt;br /&gt;
The demonstrators and assessors for this exercise are Ollie Robotham (oliver.robotham12@imperial.ac.uk) and Oli Gittus (org12@ic.ac.uk). Either one of us will be available in the second floor chemistry computer room between 2pm and 3pm on each day of the experiment. If you have questions outside of these times, you are of course welcome to send them by e-mail.&lt;br /&gt;
&lt;br /&gt;
The member of academic staff responsible for this exercise is Professor Fernando Bresme (f.bresme@imperial.ac.uk).&lt;br /&gt;
&lt;br /&gt;
==Structure of this Experiment==&lt;br /&gt;
&lt;br /&gt;
This experimental manual has been broken up into a number of subsections. To help you plan your time it is suggested you complete the following at these times:&lt;br /&gt;
&lt;br /&gt;
Monday (morning session): Theory - Introduction to molecular dynamics simulations&lt;br /&gt;
&lt;br /&gt;
Monday (afternoon session): Theory + Equilibration (submit your files for running)&lt;br /&gt;
&lt;br /&gt;
Tuesday (morning session): Equilibration (analyse your files)&lt;br /&gt;
&lt;br /&gt;
Tuesday (afternoon session): Running simulations under specific conditions (submit and read)&lt;br /&gt;
&lt;br /&gt;
Thursday (morning session): Checkpoint for progress. Submit your input files for the radial distribution function and analyse your equation of state from the previous section&lt;br /&gt;
&lt;br /&gt;
Thursday (afternoon session): Q&amp;amp;A session with Dr. Dominic Lee on theoretical background (ensembles, coexistence, radial distribtuion functions etc). Rdf data analysis and setting up diffusion simulations&lt;br /&gt;
&lt;br /&gt;
Friday (morning session): Analyse MSD diffusion simulations&lt;br /&gt;
&lt;br /&gt;
Friday (afternoon session): Analyse MSD diffusion simulations. Report write-up.&lt;br /&gt;
&lt;br /&gt;
Direct links to each of them may be found below. You should attempt them in order, and you should complete all of them to finish the experiment.&lt;br /&gt;
# [[Third year simulation experiment/Files to download|Downloading the Files]]&lt;br /&gt;
# [[Third year simulation experiment/Introduction to molecular dynamics simulation|Introduction to molecular dynamics simulation]]&lt;br /&gt;
# [[Third_year_simulation_experiment/Equilibration|Equilibration]]&lt;br /&gt;
# [[Third_year_simulation_experiment/Running_simulations_under_specific_conditions|Running simulations under specific conditions]]&lt;br /&gt;
# [[Third year simulation experiment/Structural properties and the radial distribution function|Structural properties and the radial distribution function]]&lt;br /&gt;
# [[Third year simulation experiment/Dynamical properties and the diffusion coefficient|Dynamical properties and the diffusion coefficient]]&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment&amp;diff=734677</id>
		<title>Third year simulation experiment</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment&amp;diff=734677"/>
		<updated>2018-10-18T11:42:50Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Assessment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;This is the optional experiment which may be chosen by any third year student. If you are looking for the compulsory simulation experiment for students studying chemistry with molecular physics, you will find it [[Third_year_CMP_compulsory_experiment|here]].&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Computer simulation is widely used to study a huge variety of chemical phenomena, from the behaviour of exotic materials under extreme conditions to protein folding and the properties of biological systems such as lipid membranes. In this experiment, we hope to give you a gentle introduction to one of the most powerful methods for the simulation of chemical systems, &#039;&#039;&#039;molecular dynamics simulation&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This course closely follows some of the ideas introduced in Professor Bresme&#039;s statistical thermodynamics lecture course. Do not worry if you are doing this experiment before the lectures begin, everything that you need to know to complete the experiment will be explained in these instructions. We will begin with a brief overview of the fundamental theory behind the method, before you start running your own simulations of a simple liquid using the college&#039;s [http://www.imperial.ac.uk/admin-services/ict/self-service/research-support/hpc/ high performance computing] facilities.&lt;br /&gt;
&lt;br /&gt;
At the end of this experiment, you will have performed your own simulations using state of the art software packages used by researchers all around the world, and used those simulations to calculate both structural and dynamic properties of a simple liquid. You will have seen how the concepts of statistical physics introduced by Professor Bresme are needed to calculate thermodynamic quantities such as temperature and pressure in computer simulations, and you will see how computers can be used to validate those concepts.&lt;br /&gt;
&lt;br /&gt;
All of the information that you need to complete the experiment is provided in these wiki pages. We have also tried to provide links to external resources and relevant textbooks where possible &amp;amp;mdash; unless explicitly stated, reading these resources &#039;&#039;&#039;is not required&#039;&#039;&#039;; they are provided only as further information for those interested in the subject.&lt;br /&gt;
&lt;br /&gt;
==Assessment==&lt;br /&gt;
&lt;br /&gt;
At the end of this experiment you must submit a report (pdf format via turnitin) no longer than 1500 words. The report should be structured:&lt;br /&gt;
&lt;br /&gt;
* Extended Abstract (20% of the total mark)&lt;br /&gt;
* Results and Discussion (60% of total mark)&lt;br /&gt;
* Conclusion (20% of total mark)&lt;br /&gt;
* References&lt;br /&gt;
&lt;br /&gt;
Relevant supplementary material can be added at the end of the report so long as it supports your discussion. The marking criteria is divided such that the abstract and introduction and the conclusion make up 20% of the total mark each. The results and discussion section, consisting of questions, will yield the remaining 60% of the total mark - each mark earned equates to 1% of the total mark. Importantly, work that presents an engaging dialogue and valid conclusion based on legitimate evidence will score highly. Presentation of results is arguably the most crucial part of science; you don&#039;t just show anything to the scientific community (for fear of inaccuracies being broadly spread and a retraction asked of you!), you show something relevant and defensible.&lt;br /&gt;
&lt;br /&gt;
The abstract is often confused with a conclusion because we&#039;re not really taught how to write one. It&#039;s a section you write after writing the rest of the paper and doesn&#039;t go into as much detail as the conclusion but you sum up the relevance of the research (intro), what you have done, what results you have to show to support this and the ultimate conclusion.&lt;br /&gt;
&lt;br /&gt;
Your introduction paints a picture of the background of the research; what has been done by others and where is the niche for your work. How will your work benefit the community - maybe it&#039;s a new technique. You open up the niche so the subsequent discussion inserts your work into the existing community or (for high impact journals like Nature) creates a question and novel direction that can be picked up and worked on by other interested parties. In this lab, it would be good if you can demonstrate some of the importance of your results and impact it had on Science and society.&lt;br /&gt;
&lt;br /&gt;
Results and Discussion consists of questions throughout the lab and it would be perfectly acceptable to copy the questions and write your answer beneath - there are a total of 10 tasks to complete.&lt;br /&gt;
&lt;br /&gt;
Conclusions - tie up the research and what your results show. Reread your intro, what are you trying to do? How does your research do this?&lt;br /&gt;
Work through the exercises and think about what each of your result mean physically. If you present something interesting in an engaging way, you will score highly. If anything is not clear here, please ask me in the lab or by email. Reports should be submitted to Blackboard by Wednesday 12:00 the week after you undertook the lab.&lt;br /&gt;
&lt;br /&gt;
==Getting Help==&lt;br /&gt;
&lt;br /&gt;
The demonstrators and assessors for this exercise are Ollie Robotham (oliver.robotham12@imperial.ac.uk) and Oli Gittus (org12@ic.ac.uk). Either one of us will be available in the second floor chemistry computer room between 2pm and 3pm on each day of the experiment. If you have questions outside of these times, you are of course welcome to send them by e-mail.&lt;br /&gt;
&lt;br /&gt;
The member of academic staff responsible for this exercise is Professor Fernando Bresme (f.bresme@imperial.ac.uk).&lt;br /&gt;
&lt;br /&gt;
==Structure of this Experiment==&lt;br /&gt;
&lt;br /&gt;
This experimental manual has been broken up into a number of subsections. To help you plan your time it is suggested you complete the following at these times:&lt;br /&gt;
&lt;br /&gt;
Monday (morning session): Theory - Introduction to molecular dynamics simulations&lt;br /&gt;
&lt;br /&gt;
Monday (afternoon session): Theory + Equilibration (submit your files for running)&lt;br /&gt;
&lt;br /&gt;
Tuesday (morning session): Equilibration (analyse your files)&lt;br /&gt;
&lt;br /&gt;
Tuesday (afternoon session): Running simulations under specific conditions (submit and read)&lt;br /&gt;
&lt;br /&gt;
Thursday (morning session): Checkpoint for progress. Submit your input files for the radial distribution function and analyse your equation of state from the previous section&lt;br /&gt;
&lt;br /&gt;
Thursday (afternoon session): Q&amp;amp;A session with Dr. Dominic Lee on theoretical background (ensembles, coexistence, radial distribtuion functions etc). Rdf data analysis and setting up diffusion simulations&lt;br /&gt;
&lt;br /&gt;
Friday (morning session): Analyse MSD diffusion simulations&lt;br /&gt;
&lt;br /&gt;
Friday (afternoon session): Analyse MSD diffusion simulations. Report write-up.&lt;br /&gt;
&lt;br /&gt;
Direct links to each of them may be found below. You should attempt them in order, and you should complete all of them to finish the experiment.&lt;br /&gt;
# [[Third year simulation experiment/Files to download|Downloading the Files]]&lt;br /&gt;
# [[Third year simulation experiment/Introduction to molecular dynamics simulation|Introduction to molecular dynamics simulation]]&lt;br /&gt;
# [[Third_year_simulation_experiment/Equilibration|Equilibration]]&lt;br /&gt;
# [[Third_year_simulation_experiment/Running_simulations_under_specific_conditions|Running simulations under specific conditions]]&lt;br /&gt;
# [[Third year simulation experiment/Structural properties and the radial distribution function|Structural properties and the radial distribution function]]&lt;br /&gt;
# [[Third year simulation experiment/Dynamical properties and the diffusion coefficient|Dynamical properties and the diffusion coefficient]]&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734599</id>
		<title>Third year simulation experiment/Equilibration</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734599"/>
		<updated>2018-10-15T09:22:12Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Running the simulation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We will be using the LAMMPS program to carry out our molecular dynamics simulations.&lt;br /&gt;
&#039;&#039;&#039;In several places in this section, we will ask you to consult the LAMMPS manual to find out things about how the software works. You can find the manual [https://lammps.sandia.gov/doc/Manual.html here].&#039;&#039;&#039; We appreciate that the format of this document can make it a little hard to navigate, but it is the definitive resource on how different commands in LAMMPS work, and is therefore invaluable. The files you will need for this section can be found in the intro folder downloaded previously.&lt;br /&gt;
&lt;br /&gt;
===Creating the simulation box===&lt;br /&gt;
In the previous section, it was pointed out that before we can start a simulation, we need to know the initial states of all of the atoms in the system. Exactly what information we need about each atom depends on which method of numerical integration we need, but at the very least we need to specify the starting position of each atom. If we wanted to simulate a crystal, this information would be quite easy to come by &amp;amp;mdash; we could just look up the crystal structure, and use that to generate coordinates for however many unit cells we wanted. For this purpose, LAMMPS includes a command which generates crystal lattice structures.&lt;br /&gt;
&lt;br /&gt;
Generating coordinates for atoms in a liquid is more difficult. There is no long range order, so we can&#039;t use a single point of reference to work out the positions of every other atom like we can in a solid. We could generate a random position for each atom. This would certainly create a disordered structure, but causes larger problems when we try to run the simulation.&lt;br /&gt;
&lt;br /&gt;
Instead, we are going to place the atoms on the lattice points of a simple cubic lattice. This, of course, is not a situation in which the system is likely to be found physically. It turns out, though, that if we simulate for enough time we will find that the atoms rearrange themselves into more realistic configurations. We will discuss towards the end of this section exactly what is meant by &amp;quot;enough time&amp;quot;!&lt;br /&gt;
&lt;br /&gt;
Consider the line in the input file &amp;lt;pre&amp;gt;lattice sc 0.8&amp;lt;/pre&amp;gt; This command creates a grid of points forming a simple cubic lattice (one lattice point per unit cell). The parameter &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt; specifies the number density (number of lattice points per unit volume). In a corresponding output file, you will see the line &amp;lt;pre&amp;gt;Lattice spacing in x,y,z = 1.07722 1.07722 1.07722&amp;lt;/pre&amp;gt; This indicates that the distance between the points of this lattice is &amp;lt;math&amp;gt;1.07722&amp;lt;/math&amp;gt; (in reduced units, remember!).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 6: Satisfy yourself that this lattice spacing corresponds to a number density of lattice points of &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt;. Consider instead a face-centred cubic lattice with a lattice point number density of 1.2. What is the side length of the cubic unit cell? [3 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The next lines in the input file are&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
region box block 0 10 0 10 0 10&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The corresponding log file output is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Created orthogonal box = (0 0 0) to (10.7722 10.7722 10.7722)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The region command simply defines a geometrical region in space, which we call &amp;quot;box&amp;quot;. In this case, &amp;quot;box&amp;quot; is a cube extending ten lattice spacings from the origin in all three dimensions. The subsequent create_box command tells LAMMPS to use the geometrical region called &amp;quot;box&amp;quot; as a template for the simulation box. The number 1 between &amp;quot;create_box&amp;quot; and &amp;quot;box&amp;quot; indicates that our simulation will contain only one type (species) of atom.&lt;br /&gt;
&lt;br /&gt;
So far we have defined a simulation box which is based around a virtual simple cubic lattice. Our box contains 1000 (10x10x10) unit cells of this lattice, and so contains 1000 lattice points. We now need to fill our simulation box with atoms. The input command is &amp;lt;pre&amp;gt;create_atoms 1 box&amp;lt;/pre&amp;gt; while the log file simply contains an acknowledgement of this &amp;lt;pre&amp;gt;Created 1000 atoms&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The create_atoms command has two arguments; the first tells LAMMPS that all of the atoms that we create will be of type 1. Every atom in the simulation has a type &amp;amp;mdash; because we will be simulating a pure fluid, containing only one chemical species, every atom will have the same type. The actual type that we assign to each atom is arbitrary &amp;amp;mdash; type 1 does not, for example, need to correspond to the element with atomic number 1 (hydrogen). If we wanted to simulate water, we might make the hydrogen atoms type 1 and the oxygen atoms type 2. We will specify the physical and chemical properties of each atom type later in the input script.&lt;br /&gt;
&lt;br /&gt;
The remaining data in the log file isn&#039;t very instructive as it stands &amp;amp;mdash; it simply contains a list of the thermodynamic properties of the simulation at certain intervals. In a few sections time, we will plot this data, but for now you can close the log file. Keep the input script open.&lt;br /&gt;
&lt;br /&gt;
===Setting the properties of the atoms===&lt;br /&gt;
&lt;br /&gt;
In addition to their positions, we also need the physical properties of the atoms to be able to perform the simulation. We set these properties on a &#039;per-type&#039; basis, so that every atom of the same type has the same mass and the same interactions.&lt;br /&gt;
&lt;br /&gt;
So far we have created 1000 atoms, and we know the starting (&amp;lt;math&amp;gt;t = 0&amp;lt;/math&amp;gt;) position for each of them. We have also set their masses, and told LAMMPS what sort of forces to calculate between them. The final thing we need to specify to completely specify the initial conditions is the velocity of each atom.&lt;br /&gt;
&lt;br /&gt;
Choosing initial velocities for the atoms is a little easier than choosing initial positions. From the statistical thermodynamics lectures, you should know that, at equilibrium, the velocities of atoms in any system must be distributed according to the [http://en.wikipedia.org/wiki/Maxwell%E2%80%93Boltzmann_distribution Maxwell-Boltzmann (MB) distribution]. If we know the masses of the atoms, and we know what temperature we want to simulate, then we can determine the relevant MB distribution function. LAMMPS is able to give every atom a random velocity whilst ensuring that overall the MB distribution is followed. This is the purpose of the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
velocity all create 1.5 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see the manual page for this command [http://lammps.sandia.gov/doc/velocity.html here], but the key sections are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;all&#039;&#039;&#039;: the &#039;&#039;group&#039;&#039; of atoms on which the command acts. &#039;&#039;&#039;all&#039;&#039;&#039; simply specifies that we want every atom to have a velocity assigned to it.&lt;br /&gt;
* &#039;&#039;&#039;1.5&#039;&#039;&#039;: the temperature, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, needed to calculate the MB distribution(in reduced units, as always)&lt;br /&gt;
&lt;br /&gt;
===Monitoring thermodynamic properties===&lt;br /&gt;
&lt;br /&gt;
We need to be sure that our simulation is correctly modelling whatever physical system we want to study. It is relatively easy to set up simulations, but how can we be sure that the &amp;quot;results&amp;quot; we get make sense? One of the best ways is to calculate from the simulation things that we can measure in experiment, and see if they agree. For example, we might want to simulate our system at a particular temperature and pressure, and measure the resulting density. If we repeat this over a range of temperatures at the same pressure, we will be able to plot an &#039;&#039;equation of state&#039;&#039;, which we could compare to experimental measurements.&lt;br /&gt;
&lt;br /&gt;
LAMMPS is able to calculate a great deal of thermodynamic information for us (you can see a full list of the properties it is able to calculate [http://lammps.sandia.gov/doc/thermo_style.html here]), but in these first simulations we are only interested in those properties specified in these commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
thermo 10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first controls which properties will be printed out in the log file. In this case, we print how much time we have simulated so far (which is &#039;&#039;not&#039;&#039; the same as how long it has taken us to simulate it!), the total energy of the atoms, their temperature, and their pressure. The second line tells LAMMPS to print this information on every 10th timestep.&lt;br /&gt;
&lt;br /&gt;
===Running the simulation===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Look at the lines below.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### SPECIFY TIMESTEP ###&lt;br /&gt;
variable timestep equal 0.001&lt;br /&gt;
variable n_steps equal floor(100/${timestep})&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
### RUN SIMULATION ###&lt;br /&gt;
run ${n_steps}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The second line (starting &amp;quot;variable timestep...&amp;quot;) tells LAMMPS that if it encounters the text ${timestep} on a subsequent line, it should replace it by the value given. In this case, the value ${timestep} is always replaced by 0.001.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt; It is now time to run your first simulation, submit the input script with the data file in the intro folder of the files you have downloaded Try changing the timestep - what happens when you make the timestep larger?. &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Visualising the trajectory===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;trajectory files&#039;&#039;&#039; contain the positions of all the atoms in the simulation, recorded at a set interval (for all of these simulations, this was every ten timesteps &amp;amp;mdash; this is controlled by the &#039;&#039;&#039;dump&#039;&#039;&#039; command in the input scripts). We use a programme called [http://www.ks.uiuc.edu/Research/vmd/ &#039;&#039;&#039;VMD&#039;&#039;&#039;] to view these trajectories, which you should find is already installed on both the desktop and laptop computers. You can run VMD from the start menu with &#039;&#039;&#039;Start&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;All Programs&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;University of Illinois&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;VMD&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
====Loading a Trajectory====&lt;br /&gt;
&lt;br /&gt;
We&#039;ll start by looking at the output of the 0.015 timestep simulation. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;File&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;New Molecule&#039;&#039;&#039;. Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button, then select the relevant trajectory file. In the &#039;&#039;&#039;Determine file type&#039;&#039;&#039; dropdown, select &#039;&#039;&#039;LAMMPS Trajectory&#039;&#039;&#039;. Then click &#039;&#039;&#039;Load&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You will see that the &#039;&#039;&#039;VMD 1.9.1 OpenGL Display&#039;&#039;&#039; window now shows a horrible mess. VMD&#039;s default behaviour is to draw lines between atoms which it thinks might be chemically bonded. Our system doesn&#039;t model chemical bonds, so we want to turn this off. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;Graphics&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Representations&#039;&#039;&#039;. This shows a list of &amp;quot;representations&amp;quot; of our atoms. You will see that at the moment, there is a single representation listed, and it is selected. It will have the &#039;&#039;Lines&#039;&#039; style, the &#039;&#039;Name&#039;&#039; colour, and the selection &#039;&#039;all&#039;&#039;. &amp;quot;Selection&amp;quot; simply tells VMD which atoms we want it to draw. We want to show every atom, so the current selection is fine. The &#039;&#039;name&#039;&#039; colouring method just makes VMD give atoms colours according to their specified type. The colour isn&#039;t important to us, so we can leave this be too. The &amp;quot;style&amp;quot; tells VMD what we want it to display for each atom. Change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; from &#039;&#039;Lines&#039;&#039; to &#039;&#039;VDW&#039;&#039;. You will see that the mess of lines is replaced by a mess of low resolution, overlapping spheres. Change the &#039;&#039;&#039;Sphere Scale&#039;&#039;&#039; to 0.3, and the &#039;&#039;&#039;Sphere Resolution&#039;&#039;&#039; to 17. The result should look a little smoother. Close the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window. You will notice that in the bottom right of the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, there is a small play button. Click this, and you will see the animated version of your simulation trajectory.&lt;br /&gt;
&lt;br /&gt;
By clicking and dragging with the mouse, you can rotate the simulation box (though this may be sluggish). At any time, you can reset the view by pressing the equals key.&lt;br /&gt;
&lt;br /&gt;
====Tracking a Single Particle====&lt;br /&gt;
To illustrate the periodic boundary conditions that we are using, we are going to draw almost all of the atoms as points, but we will pick a single atom at random to draw as a sphere. This will make it easy to see how a single atom moves through the box. Reset the display using the equals key, then use the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window controls to pause the trajectory and reset it to the first trajectory (play with the different buttons until you find the one that does this). You should see the perfect cubic lattice. Use the option &#039;&#039;&#039;Display&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Orthographic&#039;&#039;&#039; to change the drawing mode, then rotate the displayed crystal so that you are looking at one vertex (looking down the 111 direction, in crystallographic terms).&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window again. Change the representation style from &#039;&#039;&#039;VDW&#039;&#039;&#039; to points, then click the &#039;&#039;&#039;Create Rep&#039;&#039;&#039; button. This creates a second representation, allowing a subset of the atoms to be drawn in a different way. The &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; box allows us to choose which atoms this representation applies to. We just want to pick two of them at random &amp;amp;mdash; VMD assigns every atom an index, from 0 to N-1. In our case, there are 1000 atoms, so choose two numbers between 0 and 999. Changed the &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; field to &amp;lt;pre&amp;gt;index i or index j&amp;lt;/pre&amp;gt; where i and j are your chosen numbers, press return, then change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; to &#039;&#039;&#039;VDW&#039;&#039;&#039;. You should now see only two atoms represented by spheres, with the rest shown as small points. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, click play. Try rotating the box, and changing the playback speed.&lt;br /&gt;
&lt;br /&gt;
You will see that sometimes one of the spheres seems to change position across the box very rapidly &amp;amp;mdash; this occurs when it reaches one periodic boundary, and is reflected back across the other face. Try playing with some of the other representation types in VMD &amp;amp;mdash; it  is a very powerful package, which is often used to render images of simulated proteins, so many of its options aren&#039;t relevant to our simple system!&lt;br /&gt;
&lt;br /&gt;
===Checking equilibration===&lt;br /&gt;
&lt;br /&gt;
When we first set up a simulation, it is very important to make sure that our system reaches an equilibrium state. We characterise equilibrium by the average values of thermodynamic quantities becoming constant (due to the approximations that we have made, there will always be fluctuations, but the average values will become constant).&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to plot the thermodynamic output of the simulation to see how long it takes to reach the equilibrium state (and indeed, whether this happens at all). Instructions are given below to import data from the LAMMPS log file into Microsoft Excel. Once you have the data in a spreadsheet, you can plot it. If you know how to use some of the other plotting software available on the chemistry computers (like Origin), you are welcome to use it.&lt;br /&gt;
&lt;br /&gt;
# Open a blank Excel workbook&lt;br /&gt;
# Choose the &#039;&#039;&#039;Data&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;From Text&#039;&#039;&#039; button&lt;br /&gt;
# Select one of your simulation log files&lt;br /&gt;
# Set the &#039;&#039;&#039;Start import at row&#039;&#039;&#039; field to &#039;&#039;&#039;25&#039;&#039;&#039; (this ignores all of the diagnostic information at the top of the file)&lt;br /&gt;
# Set the &#039;&#039;&#039;Original Data type&#039;&#039;&#039; to &#039;&#039;&#039;Delimited&#039;&#039;&#039;, then click &#039;&#039;&#039;Next&#039;&#039;&#039;&lt;br /&gt;
# Tick the &#039;&#039;&#039;Space&#039;&#039;&#039; box, and make sure that &#039;&#039;&#039;Treat consecutive delimiters as one&#039;&#039;&#039; box is ticked.&lt;br /&gt;
# On the next dialog, you can select where you want the data to be inserted. When you are happy, click &#039;&#039;&#039;OK&#039;&#039;&#039;. The data will be inserted into your spreadsheet.&lt;br /&gt;
# Scroll to the bottom of the data &amp;amp;mdash; you will see a lot of timing information from the simulation. Delete everything beyond the end of your thermodynamic data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 7: make plots of the energy, temperature, and pressure, against time for the 0.001 timestep experiment (attach a picture to your report). Does the simulation reach equilibrium? When you have done this, make a single plot which shows the energy versus time for all of the timesteps you have simulated (again, attach a picture to your report). Of the timesteps that you used, which timestep will you use for subsequent simulations and why? [9 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734598</id>
		<title>Third year simulation experiment/Equilibration</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734598"/>
		<updated>2018-10-15T09:22:01Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Running the simulation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We will be using the LAMMPS program to carry out our molecular dynamics simulations.&lt;br /&gt;
&#039;&#039;&#039;In several places in this section, we will ask you to consult the LAMMPS manual to find out things about how the software works. You can find the manual [https://lammps.sandia.gov/doc/Manual.html here].&#039;&#039;&#039; We appreciate that the format of this document can make it a little hard to navigate, but it is the definitive resource on how different commands in LAMMPS work, and is therefore invaluable. The files you will need for this section can be found in the intro folder downloaded previously.&lt;br /&gt;
&lt;br /&gt;
===Creating the simulation box===&lt;br /&gt;
In the previous section, it was pointed out that before we can start a simulation, we need to know the initial states of all of the atoms in the system. Exactly what information we need about each atom depends on which method of numerical integration we need, but at the very least we need to specify the starting position of each atom. If we wanted to simulate a crystal, this information would be quite easy to come by &amp;amp;mdash; we could just look up the crystal structure, and use that to generate coordinates for however many unit cells we wanted. For this purpose, LAMMPS includes a command which generates crystal lattice structures.&lt;br /&gt;
&lt;br /&gt;
Generating coordinates for atoms in a liquid is more difficult. There is no long range order, so we can&#039;t use a single point of reference to work out the positions of every other atom like we can in a solid. We could generate a random position for each atom. This would certainly create a disordered structure, but causes larger problems when we try to run the simulation.&lt;br /&gt;
&lt;br /&gt;
Instead, we are going to place the atoms on the lattice points of a simple cubic lattice. This, of course, is not a situation in which the system is likely to be found physically. It turns out, though, that if we simulate for enough time we will find that the atoms rearrange themselves into more realistic configurations. We will discuss towards the end of this section exactly what is meant by &amp;quot;enough time&amp;quot;!&lt;br /&gt;
&lt;br /&gt;
Consider the line in the input file &amp;lt;pre&amp;gt;lattice sc 0.8&amp;lt;/pre&amp;gt; This command creates a grid of points forming a simple cubic lattice (one lattice point per unit cell). The parameter &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt; specifies the number density (number of lattice points per unit volume). In a corresponding output file, you will see the line &amp;lt;pre&amp;gt;Lattice spacing in x,y,z = 1.07722 1.07722 1.07722&amp;lt;/pre&amp;gt; This indicates that the distance between the points of this lattice is &amp;lt;math&amp;gt;1.07722&amp;lt;/math&amp;gt; (in reduced units, remember!).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 6: Satisfy yourself that this lattice spacing corresponds to a number density of lattice points of &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt;. Consider instead a face-centred cubic lattice with a lattice point number density of 1.2. What is the side length of the cubic unit cell? [3 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The next lines in the input file are&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
region box block 0 10 0 10 0 10&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The corresponding log file output is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Created orthogonal box = (0 0 0) to (10.7722 10.7722 10.7722)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The region command simply defines a geometrical region in space, which we call &amp;quot;box&amp;quot;. In this case, &amp;quot;box&amp;quot; is a cube extending ten lattice spacings from the origin in all three dimensions. The subsequent create_box command tells LAMMPS to use the geometrical region called &amp;quot;box&amp;quot; as a template for the simulation box. The number 1 between &amp;quot;create_box&amp;quot; and &amp;quot;box&amp;quot; indicates that our simulation will contain only one type (species) of atom.&lt;br /&gt;
&lt;br /&gt;
So far we have defined a simulation box which is based around a virtual simple cubic lattice. Our box contains 1000 (10x10x10) unit cells of this lattice, and so contains 1000 lattice points. We now need to fill our simulation box with atoms. The input command is &amp;lt;pre&amp;gt;create_atoms 1 box&amp;lt;/pre&amp;gt; while the log file simply contains an acknowledgement of this &amp;lt;pre&amp;gt;Created 1000 atoms&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The create_atoms command has two arguments; the first tells LAMMPS that all of the atoms that we create will be of type 1. Every atom in the simulation has a type &amp;amp;mdash; because we will be simulating a pure fluid, containing only one chemical species, every atom will have the same type. The actual type that we assign to each atom is arbitrary &amp;amp;mdash; type 1 does not, for example, need to correspond to the element with atomic number 1 (hydrogen). If we wanted to simulate water, we might make the hydrogen atoms type 1 and the oxygen atoms type 2. We will specify the physical and chemical properties of each atom type later in the input script.&lt;br /&gt;
&lt;br /&gt;
The remaining data in the log file isn&#039;t very instructive as it stands &amp;amp;mdash; it simply contains a list of the thermodynamic properties of the simulation at certain intervals. In a few sections time, we will plot this data, but for now you can close the log file. Keep the input script open.&lt;br /&gt;
&lt;br /&gt;
===Setting the properties of the atoms===&lt;br /&gt;
&lt;br /&gt;
In addition to their positions, we also need the physical properties of the atoms to be able to perform the simulation. We set these properties on a &#039;per-type&#039; basis, so that every atom of the same type has the same mass and the same interactions.&lt;br /&gt;
&lt;br /&gt;
So far we have created 1000 atoms, and we know the starting (&amp;lt;math&amp;gt;t = 0&amp;lt;/math&amp;gt;) position for each of them. We have also set their masses, and told LAMMPS what sort of forces to calculate between them. The final thing we need to specify to completely specify the initial conditions is the velocity of each atom.&lt;br /&gt;
&lt;br /&gt;
Choosing initial velocities for the atoms is a little easier than choosing initial positions. From the statistical thermodynamics lectures, you should know that, at equilibrium, the velocities of atoms in any system must be distributed according to the [http://en.wikipedia.org/wiki/Maxwell%E2%80%93Boltzmann_distribution Maxwell-Boltzmann (MB) distribution]. If we know the masses of the atoms, and we know what temperature we want to simulate, then we can determine the relevant MB distribution function. LAMMPS is able to give every atom a random velocity whilst ensuring that overall the MB distribution is followed. This is the purpose of the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
velocity all create 1.5 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see the manual page for this command [http://lammps.sandia.gov/doc/velocity.html here], but the key sections are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;all&#039;&#039;&#039;: the &#039;&#039;group&#039;&#039; of atoms on which the command acts. &#039;&#039;&#039;all&#039;&#039;&#039; simply specifies that we want every atom to have a velocity assigned to it.&lt;br /&gt;
* &#039;&#039;&#039;1.5&#039;&#039;&#039;: the temperature, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, needed to calculate the MB distribution(in reduced units, as always)&lt;br /&gt;
&lt;br /&gt;
===Monitoring thermodynamic properties===&lt;br /&gt;
&lt;br /&gt;
We need to be sure that our simulation is correctly modelling whatever physical system we want to study. It is relatively easy to set up simulations, but how can we be sure that the &amp;quot;results&amp;quot; we get make sense? One of the best ways is to calculate from the simulation things that we can measure in experiment, and see if they agree. For example, we might want to simulate our system at a particular temperature and pressure, and measure the resulting density. If we repeat this over a range of temperatures at the same pressure, we will be able to plot an &#039;&#039;equation of state&#039;&#039;, which we could compare to experimental measurements.&lt;br /&gt;
&lt;br /&gt;
LAMMPS is able to calculate a great deal of thermodynamic information for us (you can see a full list of the properties it is able to calculate [http://lammps.sandia.gov/doc/thermo_style.html here]), but in these first simulations we are only interested in those properties specified in these commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
thermo 10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first controls which properties will be printed out in the log file. In this case, we print how much time we have simulated so far (which is &#039;&#039;not&#039;&#039; the same as how long it has taken us to simulate it!), the total energy of the atoms, their temperature, and their pressure. The second line tells LAMMPS to print this information on every 10th timestep.&lt;br /&gt;
&lt;br /&gt;
===Running the simulation===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Look at the lines below.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### SPECIFY TIMESTEP ###&lt;br /&gt;
variable timestep equal 0.001&lt;br /&gt;
variable n_steps equal floor(100/${timestep})&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
### RUN SIMULATION ###&lt;br /&gt;
run ${n_steps}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The second line (starting &amp;quot;variable timestep...&amp;quot;) tells LAMMPS that if it encounters the text ${timestep} on a subsequent line, it should replace it by the value given. In this case, the value ${timestep} is always replaced by 0.001.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ask the demonstrator if you need help.&#039;&#039;&#039;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt; It is now time to run your first simulation, submit the input script with the data file in the intro folder of the files you have downloaded Try changing the timestep - what happens when you make the timestep larger?. &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Visualising the trajectory===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;trajectory files&#039;&#039;&#039; contain the positions of all the atoms in the simulation, recorded at a set interval (for all of these simulations, this was every ten timesteps &amp;amp;mdash; this is controlled by the &#039;&#039;&#039;dump&#039;&#039;&#039; command in the input scripts). We use a programme called [http://www.ks.uiuc.edu/Research/vmd/ &#039;&#039;&#039;VMD&#039;&#039;&#039;] to view these trajectories, which you should find is already installed on both the desktop and laptop computers. You can run VMD from the start menu with &#039;&#039;&#039;Start&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;All Programs&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;University of Illinois&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;VMD&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
====Loading a Trajectory====&lt;br /&gt;
&lt;br /&gt;
We&#039;ll start by looking at the output of the 0.015 timestep simulation. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;File&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;New Molecule&#039;&#039;&#039;. Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button, then select the relevant trajectory file. In the &#039;&#039;&#039;Determine file type&#039;&#039;&#039; dropdown, select &#039;&#039;&#039;LAMMPS Trajectory&#039;&#039;&#039;. Then click &#039;&#039;&#039;Load&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You will see that the &#039;&#039;&#039;VMD 1.9.1 OpenGL Display&#039;&#039;&#039; window now shows a horrible mess. VMD&#039;s default behaviour is to draw lines between atoms which it thinks might be chemically bonded. Our system doesn&#039;t model chemical bonds, so we want to turn this off. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;Graphics&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Representations&#039;&#039;&#039;. This shows a list of &amp;quot;representations&amp;quot; of our atoms. You will see that at the moment, there is a single representation listed, and it is selected. It will have the &#039;&#039;Lines&#039;&#039; style, the &#039;&#039;Name&#039;&#039; colour, and the selection &#039;&#039;all&#039;&#039;. &amp;quot;Selection&amp;quot; simply tells VMD which atoms we want it to draw. We want to show every atom, so the current selection is fine. The &#039;&#039;name&#039;&#039; colouring method just makes VMD give atoms colours according to their specified type. The colour isn&#039;t important to us, so we can leave this be too. The &amp;quot;style&amp;quot; tells VMD what we want it to display for each atom. Change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; from &#039;&#039;Lines&#039;&#039; to &#039;&#039;VDW&#039;&#039;. You will see that the mess of lines is replaced by a mess of low resolution, overlapping spheres. Change the &#039;&#039;&#039;Sphere Scale&#039;&#039;&#039; to 0.3, and the &#039;&#039;&#039;Sphere Resolution&#039;&#039;&#039; to 17. The result should look a little smoother. Close the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window. You will notice that in the bottom right of the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, there is a small play button. Click this, and you will see the animated version of your simulation trajectory.&lt;br /&gt;
&lt;br /&gt;
By clicking and dragging with the mouse, you can rotate the simulation box (though this may be sluggish). At any time, you can reset the view by pressing the equals key.&lt;br /&gt;
&lt;br /&gt;
====Tracking a Single Particle====&lt;br /&gt;
To illustrate the periodic boundary conditions that we are using, we are going to draw almost all of the atoms as points, but we will pick a single atom at random to draw as a sphere. This will make it easy to see how a single atom moves through the box. Reset the display using the equals key, then use the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window controls to pause the trajectory and reset it to the first trajectory (play with the different buttons until you find the one that does this). You should see the perfect cubic lattice. Use the option &#039;&#039;&#039;Display&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Orthographic&#039;&#039;&#039; to change the drawing mode, then rotate the displayed crystal so that you are looking at one vertex (looking down the 111 direction, in crystallographic terms).&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window again. Change the representation style from &#039;&#039;&#039;VDW&#039;&#039;&#039; to points, then click the &#039;&#039;&#039;Create Rep&#039;&#039;&#039; button. This creates a second representation, allowing a subset of the atoms to be drawn in a different way. The &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; box allows us to choose which atoms this representation applies to. We just want to pick two of them at random &amp;amp;mdash; VMD assigns every atom an index, from 0 to N-1. In our case, there are 1000 atoms, so choose two numbers between 0 and 999. Changed the &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; field to &amp;lt;pre&amp;gt;index i or index j&amp;lt;/pre&amp;gt; where i and j are your chosen numbers, press return, then change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; to &#039;&#039;&#039;VDW&#039;&#039;&#039;. You should now see only two atoms represented by spheres, with the rest shown as small points. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, click play. Try rotating the box, and changing the playback speed.&lt;br /&gt;
&lt;br /&gt;
You will see that sometimes one of the spheres seems to change position across the box very rapidly &amp;amp;mdash; this occurs when it reaches one periodic boundary, and is reflected back across the other face. Try playing with some of the other representation types in VMD &amp;amp;mdash; it  is a very powerful package, which is often used to render images of simulated proteins, so many of its options aren&#039;t relevant to our simple system!&lt;br /&gt;
&lt;br /&gt;
===Checking equilibration===&lt;br /&gt;
&lt;br /&gt;
When we first set up a simulation, it is very important to make sure that our system reaches an equilibrium state. We characterise equilibrium by the average values of thermodynamic quantities becoming constant (due to the approximations that we have made, there will always be fluctuations, but the average values will become constant).&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to plot the thermodynamic output of the simulation to see how long it takes to reach the equilibrium state (and indeed, whether this happens at all). Instructions are given below to import data from the LAMMPS log file into Microsoft Excel. Once you have the data in a spreadsheet, you can plot it. If you know how to use some of the other plotting software available on the chemistry computers (like Origin), you are welcome to use it.&lt;br /&gt;
&lt;br /&gt;
# Open a blank Excel workbook&lt;br /&gt;
# Choose the &#039;&#039;&#039;Data&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;From Text&#039;&#039;&#039; button&lt;br /&gt;
# Select one of your simulation log files&lt;br /&gt;
# Set the &#039;&#039;&#039;Start import at row&#039;&#039;&#039; field to &#039;&#039;&#039;25&#039;&#039;&#039; (this ignores all of the diagnostic information at the top of the file)&lt;br /&gt;
# Set the &#039;&#039;&#039;Original Data type&#039;&#039;&#039; to &#039;&#039;&#039;Delimited&#039;&#039;&#039;, then click &#039;&#039;&#039;Next&#039;&#039;&#039;&lt;br /&gt;
# Tick the &#039;&#039;&#039;Space&#039;&#039;&#039; box, and make sure that &#039;&#039;&#039;Treat consecutive delimiters as one&#039;&#039;&#039; box is ticked.&lt;br /&gt;
# On the next dialog, you can select where you want the data to be inserted. When you are happy, click &#039;&#039;&#039;OK&#039;&#039;&#039;. The data will be inserted into your spreadsheet.&lt;br /&gt;
# Scroll to the bottom of the data &amp;amp;mdash; you will see a lot of timing information from the simulation. Delete everything beyond the end of your thermodynamic data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 7: make plots of the energy, temperature, and pressure, against time for the 0.001 timestep experiment (attach a picture to your report). Does the simulation reach equilibrium? When you have done this, make a single plot which shows the energy versus time for all of the timesteps you have simulated (again, attach a picture to your report). Of the timesteps that you used, which timestep will you use for subsequent simulations and why? [9 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734597</id>
		<title>Third year simulation experiment/Equilibration</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734597"/>
		<updated>2018-10-15T09:21:42Z</updated>

		<summary type="html">&lt;p&gt;Otr12: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We will be using the LAMMPS program to carry out our molecular dynamics simulations.&lt;br /&gt;
&#039;&#039;&#039;In several places in this section, we will ask you to consult the LAMMPS manual to find out things about how the software works. You can find the manual [https://lammps.sandia.gov/doc/Manual.html here].&#039;&#039;&#039; We appreciate that the format of this document can make it a little hard to navigate, but it is the definitive resource on how different commands in LAMMPS work, and is therefore invaluable. The files you will need for this section can be found in the intro folder downloaded previously.&lt;br /&gt;
&lt;br /&gt;
===Creating the simulation box===&lt;br /&gt;
In the previous section, it was pointed out that before we can start a simulation, we need to know the initial states of all of the atoms in the system. Exactly what information we need about each atom depends on which method of numerical integration we need, but at the very least we need to specify the starting position of each atom. If we wanted to simulate a crystal, this information would be quite easy to come by &amp;amp;mdash; we could just look up the crystal structure, and use that to generate coordinates for however many unit cells we wanted. For this purpose, LAMMPS includes a command which generates crystal lattice structures.&lt;br /&gt;
&lt;br /&gt;
Generating coordinates for atoms in a liquid is more difficult. There is no long range order, so we can&#039;t use a single point of reference to work out the positions of every other atom like we can in a solid. We could generate a random position for each atom. This would certainly create a disordered structure, but causes larger problems when we try to run the simulation.&lt;br /&gt;
&lt;br /&gt;
Instead, we are going to place the atoms on the lattice points of a simple cubic lattice. This, of course, is not a situation in which the system is likely to be found physically. It turns out, though, that if we simulate for enough time we will find that the atoms rearrange themselves into more realistic configurations. We will discuss towards the end of this section exactly what is meant by &amp;quot;enough time&amp;quot;!&lt;br /&gt;
&lt;br /&gt;
Consider the line in the input file &amp;lt;pre&amp;gt;lattice sc 0.8&amp;lt;/pre&amp;gt; This command creates a grid of points forming a simple cubic lattice (one lattice point per unit cell). The parameter &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt; specifies the number density (number of lattice points per unit volume). In a corresponding output file, you will see the line &amp;lt;pre&amp;gt;Lattice spacing in x,y,z = 1.07722 1.07722 1.07722&amp;lt;/pre&amp;gt; This indicates that the distance between the points of this lattice is &amp;lt;math&amp;gt;1.07722&amp;lt;/math&amp;gt; (in reduced units, remember!).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 6: Satisfy yourself that this lattice spacing corresponds to a number density of lattice points of &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt;. Consider instead a face-centred cubic lattice with a lattice point number density of 1.2. What is the side length of the cubic unit cell? [3 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The next lines in the input file are&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
region box block 0 10 0 10 0 10&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The corresponding log file output is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Created orthogonal box = (0 0 0) to (10.7722 10.7722 10.7722)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The region command simply defines a geometrical region in space, which we call &amp;quot;box&amp;quot;. In this case, &amp;quot;box&amp;quot; is a cube extending ten lattice spacings from the origin in all three dimensions. The subsequent create_box command tells LAMMPS to use the geometrical region called &amp;quot;box&amp;quot; as a template for the simulation box. The number 1 between &amp;quot;create_box&amp;quot; and &amp;quot;box&amp;quot; indicates that our simulation will contain only one type (species) of atom.&lt;br /&gt;
&lt;br /&gt;
So far we have defined a simulation box which is based around a virtual simple cubic lattice. Our box contains 1000 (10x10x10) unit cells of this lattice, and so contains 1000 lattice points. We now need to fill our simulation box with atoms. The input command is &amp;lt;pre&amp;gt;create_atoms 1 box&amp;lt;/pre&amp;gt; while the log file simply contains an acknowledgement of this &amp;lt;pre&amp;gt;Created 1000 atoms&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The create_atoms command has two arguments; the first tells LAMMPS that all of the atoms that we create will be of type 1. Every atom in the simulation has a type &amp;amp;mdash; because we will be simulating a pure fluid, containing only one chemical species, every atom will have the same type. The actual type that we assign to each atom is arbitrary &amp;amp;mdash; type 1 does not, for example, need to correspond to the element with atomic number 1 (hydrogen). If we wanted to simulate water, we might make the hydrogen atoms type 1 and the oxygen atoms type 2. We will specify the physical and chemical properties of each atom type later in the input script.&lt;br /&gt;
&lt;br /&gt;
The remaining data in the log file isn&#039;t very instructive as it stands &amp;amp;mdash; it simply contains a list of the thermodynamic properties of the simulation at certain intervals. In a few sections time, we will plot this data, but for now you can close the log file. Keep the input script open.&lt;br /&gt;
&lt;br /&gt;
===Setting the properties of the atoms===&lt;br /&gt;
&lt;br /&gt;
In addition to their positions, we also need the physical properties of the atoms to be able to perform the simulation. We set these properties on a &#039;per-type&#039; basis, so that every atom of the same type has the same mass and the same interactions.&lt;br /&gt;
&lt;br /&gt;
So far we have created 1000 atoms, and we know the starting (&amp;lt;math&amp;gt;t = 0&amp;lt;/math&amp;gt;) position for each of them. We have also set their masses, and told LAMMPS what sort of forces to calculate between them. The final thing we need to specify to completely specify the initial conditions is the velocity of each atom.&lt;br /&gt;
&lt;br /&gt;
Choosing initial velocities for the atoms is a little easier than choosing initial positions. From the statistical thermodynamics lectures, you should know that, at equilibrium, the velocities of atoms in any system must be distributed according to the [http://en.wikipedia.org/wiki/Maxwell%E2%80%93Boltzmann_distribution Maxwell-Boltzmann (MB) distribution]. If we know the masses of the atoms, and we know what temperature we want to simulate, then we can determine the relevant MB distribution function. LAMMPS is able to give every atom a random velocity whilst ensuring that overall the MB distribution is followed. This is the purpose of the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
velocity all create 1.5 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see the manual page for this command [http://lammps.sandia.gov/doc/velocity.html here], but the key sections are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;all&#039;&#039;&#039;: the &#039;&#039;group&#039;&#039; of atoms on which the command acts. &#039;&#039;&#039;all&#039;&#039;&#039; simply specifies that we want every atom to have a velocity assigned to it.&lt;br /&gt;
* &#039;&#039;&#039;1.5&#039;&#039;&#039;: the temperature, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, needed to calculate the MB distribution(in reduced units, as always)&lt;br /&gt;
&lt;br /&gt;
===Monitoring thermodynamic properties===&lt;br /&gt;
&lt;br /&gt;
We need to be sure that our simulation is correctly modelling whatever physical system we want to study. It is relatively easy to set up simulations, but how can we be sure that the &amp;quot;results&amp;quot; we get make sense? One of the best ways is to calculate from the simulation things that we can measure in experiment, and see if they agree. For example, we might want to simulate our system at a particular temperature and pressure, and measure the resulting density. If we repeat this over a range of temperatures at the same pressure, we will be able to plot an &#039;&#039;equation of state&#039;&#039;, which we could compare to experimental measurements.&lt;br /&gt;
&lt;br /&gt;
LAMMPS is able to calculate a great deal of thermodynamic information for us (you can see a full list of the properties it is able to calculate [http://lammps.sandia.gov/doc/thermo_style.html here]), but in these first simulations we are only interested in those properties specified in these commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
thermo 10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first controls which properties will be printed out in the log file. In this case, we print how much time we have simulated so far (which is &#039;&#039;not&#039;&#039; the same as how long it has taken us to simulate it!), the total energy of the atoms, their temperature, and their pressure. The second line tells LAMMPS to print this information on every 10th timestep.&lt;br /&gt;
&lt;br /&gt;
===Running the simulation===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Look at the lines below.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### SPECIFY TIMESTEP ###&lt;br /&gt;
variable timestep equal 0.001&lt;br /&gt;
variable n_steps equal floor(100/${timestep})&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
### RUN SIMULATION ###&lt;br /&gt;
run ${n_steps}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The second line (starting &amp;quot;variable timestep...&amp;quot;) tells LAMMPS that if it encounters the text ${timestep} on a subsequent line, it should replace it by the value given. In this case, the value ${timestep} is always replaced by 0.001.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ask the demonstrator if you need help.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;big&amp;gt; It is now time to run your first simulation, submit the input script with the data file in the intro folder of the files you have downloaded Try changing the timestep - what happens when you make the timestep larger?. &amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Visualising the trajectory===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;trajectory files&#039;&#039;&#039; contain the positions of all the atoms in the simulation, recorded at a set interval (for all of these simulations, this was every ten timesteps &amp;amp;mdash; this is controlled by the &#039;&#039;&#039;dump&#039;&#039;&#039; command in the input scripts). We use a programme called [http://www.ks.uiuc.edu/Research/vmd/ &#039;&#039;&#039;VMD&#039;&#039;&#039;] to view these trajectories, which you should find is already installed on both the desktop and laptop computers. You can run VMD from the start menu with &#039;&#039;&#039;Start&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;All Programs&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;University of Illinois&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;VMD&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
====Loading a Trajectory====&lt;br /&gt;
&lt;br /&gt;
We&#039;ll start by looking at the output of the 0.015 timestep simulation. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;File&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;New Molecule&#039;&#039;&#039;. Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button, then select the relevant trajectory file. In the &#039;&#039;&#039;Determine file type&#039;&#039;&#039; dropdown, select &#039;&#039;&#039;LAMMPS Trajectory&#039;&#039;&#039;. Then click &#039;&#039;&#039;Load&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You will see that the &#039;&#039;&#039;VMD 1.9.1 OpenGL Display&#039;&#039;&#039; window now shows a horrible mess. VMD&#039;s default behaviour is to draw lines between atoms which it thinks might be chemically bonded. Our system doesn&#039;t model chemical bonds, so we want to turn this off. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;Graphics&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Representations&#039;&#039;&#039;. This shows a list of &amp;quot;representations&amp;quot; of our atoms. You will see that at the moment, there is a single representation listed, and it is selected. It will have the &#039;&#039;Lines&#039;&#039; style, the &#039;&#039;Name&#039;&#039; colour, and the selection &#039;&#039;all&#039;&#039;. &amp;quot;Selection&amp;quot; simply tells VMD which atoms we want it to draw. We want to show every atom, so the current selection is fine. The &#039;&#039;name&#039;&#039; colouring method just makes VMD give atoms colours according to their specified type. The colour isn&#039;t important to us, so we can leave this be too. The &amp;quot;style&amp;quot; tells VMD what we want it to display for each atom. Change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; from &#039;&#039;Lines&#039;&#039; to &#039;&#039;VDW&#039;&#039;. You will see that the mess of lines is replaced by a mess of low resolution, overlapping spheres. Change the &#039;&#039;&#039;Sphere Scale&#039;&#039;&#039; to 0.3, and the &#039;&#039;&#039;Sphere Resolution&#039;&#039;&#039; to 17. The result should look a little smoother. Close the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window. You will notice that in the bottom right of the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, there is a small play button. Click this, and you will see the animated version of your simulation trajectory.&lt;br /&gt;
&lt;br /&gt;
By clicking and dragging with the mouse, you can rotate the simulation box (though this may be sluggish). At any time, you can reset the view by pressing the equals key.&lt;br /&gt;
&lt;br /&gt;
====Tracking a Single Particle====&lt;br /&gt;
To illustrate the periodic boundary conditions that we are using, we are going to draw almost all of the atoms as points, but we will pick a single atom at random to draw as a sphere. This will make it easy to see how a single atom moves through the box. Reset the display using the equals key, then use the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window controls to pause the trajectory and reset it to the first trajectory (play with the different buttons until you find the one that does this). You should see the perfect cubic lattice. Use the option &#039;&#039;&#039;Display&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Orthographic&#039;&#039;&#039; to change the drawing mode, then rotate the displayed crystal so that you are looking at one vertex (looking down the 111 direction, in crystallographic terms).&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window again. Change the representation style from &#039;&#039;&#039;VDW&#039;&#039;&#039; to points, then click the &#039;&#039;&#039;Create Rep&#039;&#039;&#039; button. This creates a second representation, allowing a subset of the atoms to be drawn in a different way. The &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; box allows us to choose which atoms this representation applies to. We just want to pick two of them at random &amp;amp;mdash; VMD assigns every atom an index, from 0 to N-1. In our case, there are 1000 atoms, so choose two numbers between 0 and 999. Changed the &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; field to &amp;lt;pre&amp;gt;index i or index j&amp;lt;/pre&amp;gt; where i and j are your chosen numbers, press return, then change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; to &#039;&#039;&#039;VDW&#039;&#039;&#039;. You should now see only two atoms represented by spheres, with the rest shown as small points. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, click play. Try rotating the box, and changing the playback speed.&lt;br /&gt;
&lt;br /&gt;
You will see that sometimes one of the spheres seems to change position across the box very rapidly &amp;amp;mdash; this occurs when it reaches one periodic boundary, and is reflected back across the other face. Try playing with some of the other representation types in VMD &amp;amp;mdash; it  is a very powerful package, which is often used to render images of simulated proteins, so many of its options aren&#039;t relevant to our simple system!&lt;br /&gt;
&lt;br /&gt;
===Checking equilibration===&lt;br /&gt;
&lt;br /&gt;
When we first set up a simulation, it is very important to make sure that our system reaches an equilibrium state. We characterise equilibrium by the average values of thermodynamic quantities becoming constant (due to the approximations that we have made, there will always be fluctuations, but the average values will become constant).&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to plot the thermodynamic output of the simulation to see how long it takes to reach the equilibrium state (and indeed, whether this happens at all). Instructions are given below to import data from the LAMMPS log file into Microsoft Excel. Once you have the data in a spreadsheet, you can plot it. If you know how to use some of the other plotting software available on the chemistry computers (like Origin), you are welcome to use it.&lt;br /&gt;
&lt;br /&gt;
# Open a blank Excel workbook&lt;br /&gt;
# Choose the &#039;&#039;&#039;Data&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;From Text&#039;&#039;&#039; button&lt;br /&gt;
# Select one of your simulation log files&lt;br /&gt;
# Set the &#039;&#039;&#039;Start import at row&#039;&#039;&#039; field to &#039;&#039;&#039;25&#039;&#039;&#039; (this ignores all of the diagnostic information at the top of the file)&lt;br /&gt;
# Set the &#039;&#039;&#039;Original Data type&#039;&#039;&#039; to &#039;&#039;&#039;Delimited&#039;&#039;&#039;, then click &#039;&#039;&#039;Next&#039;&#039;&#039;&lt;br /&gt;
# Tick the &#039;&#039;&#039;Space&#039;&#039;&#039; box, and make sure that &#039;&#039;&#039;Treat consecutive delimiters as one&#039;&#039;&#039; box is ticked.&lt;br /&gt;
# On the next dialog, you can select where you want the data to be inserted. When you are happy, click &#039;&#039;&#039;OK&#039;&#039;&#039;. The data will be inserted into your spreadsheet.&lt;br /&gt;
# Scroll to the bottom of the data &amp;amp;mdash; you will see a lot of timing information from the simulation. Delete everything beyond the end of your thermodynamic data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 7: make plots of the energy, temperature, and pressure, against time for the 0.001 timestep experiment (attach a picture to your report). Does the simulation reach equilibrium? When you have done this, make a single plot which shows the energy versus time for all of the timesteps you have simulated (again, attach a picture to your report). Of the timesteps that you used, which timestep will you use for subsequent simulations and why? [9 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734594</id>
		<title>Third year simulation experiment/Equilibration</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734594"/>
		<updated>2018-10-15T08:26:14Z</updated>

		<summary type="html">&lt;p&gt;Otr12: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We will be using the LAMMPS program to carry out our molecular dynamics simulations.&lt;br /&gt;
&#039;&#039;&#039;In several places in this section, we will ask you to consult the LAMMPS manual to find out things about how the software works. You can find the manual [https://lammps.sandia.gov/doc/Manual.html here].&#039;&#039;&#039; We appreciate that the format of this document can make it a little hard to navigate, but it is the definitive resource on how different commands in LAMMPS work, and is therefore invaluable. The files you will need for this section can be found in the intro folder downloaded previously.&lt;br /&gt;
&lt;br /&gt;
===Creating the simulation box===&lt;br /&gt;
In the previous section, it was pointed out that before we can start a simulation, we need to know the initial states of all of the atoms in the system. Exactly what information we need about each atom depends on which method of numerical integration we need, but at the very least we need to specify the starting position of each atom. If we wanted to simulate a crystal, this information would be quite easy to come by &amp;amp;mdash; we could just look up the crystal structure, and use that to generate coordinates for however many unit cells we wanted. For this purpose, LAMMPS includes a command which generates crystal lattice structures.&lt;br /&gt;
&lt;br /&gt;
Generating coordinates for atoms in a liquid is more difficult. There is no long range order, so we can&#039;t use a single point of reference to work out the positions of every other atom like we can in a solid. We could generate a random position for each atom. This would certainly create a disordered structure, but causes larger problems when we try to run the simulation.&lt;br /&gt;
&lt;br /&gt;
Instead, we are going to place the atoms on the lattice points of a simple cubic lattice. This, of course, is not a situation in which the system is likely to be found physically. It turns out, though, that if we simulate for enough time we will find that the atoms rearrange themselves into more realistic configurations. We will discuss towards the end of this section exactly what is meant by &amp;quot;enough time&amp;quot;!&lt;br /&gt;
&lt;br /&gt;
Consider the line in the input file &amp;lt;pre&amp;gt;lattice sc 0.8&amp;lt;/pre&amp;gt; This command creates a grid of points forming a simple cubic lattice (one lattice point per unit cell). The parameter &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt; specifies the number density (number of lattice points per unit volume). In a corresponding output file, you will see the line &amp;lt;pre&amp;gt;Lattice spacing in x,y,z = 1.07722 1.07722 1.07722&amp;lt;/pre&amp;gt; This indicates that the distance between the points of this lattice is &amp;lt;math&amp;gt;1.07722&amp;lt;/math&amp;gt; (in reduced units, remember!).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 6: Satisfy yourself that this lattice spacing corresponds to a number density of lattice points of &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt;. Consider instead a face-centred cubic lattice with a lattice point number density of 1.2. What is the side length of the cubic unit cell? [3 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The next lines in the input file are&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
region box block 0 10 0 10 0 10&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The corresponding log file output is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Created orthogonal box = (0 0 0) to (10.7722 10.7722 10.7722)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The region command simply defines a geometrical region in space, which we call &amp;quot;box&amp;quot;. In this case, &amp;quot;box&amp;quot; is a cube extending ten lattice spacings from the origin in all three dimensions. The subsequent create_box command tells LAMMPS to use the geometrical region called &amp;quot;box&amp;quot; as a template for the simulation box. The number 1 between &amp;quot;create_box&amp;quot; and &amp;quot;box&amp;quot; indicates that our simulation will contain only one type (species) of atom.&lt;br /&gt;
&lt;br /&gt;
So far we have defined a simulation box which is based around a virtual simple cubic lattice. Our box contains 1000 (10x10x10) unit cells of this lattice, and so contains 1000 lattice points. We now need to fill our simulation box with atoms. The input command is &amp;lt;pre&amp;gt;create_atoms 1 box&amp;lt;/pre&amp;gt; while the log file simply contains an acknowledgement of this &amp;lt;pre&amp;gt;Created 1000 atoms&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The create_atoms command has two arguments; the first tells LAMMPS that all of the atoms that we create will be of type 1. Every atom in the simulation has a type &amp;amp;mdash; because we will be simulating a pure fluid, containing only one chemical species, every atom will have the same type. The actual type that we assign to each atom is arbitrary &amp;amp;mdash; type 1 does not, for example, need to correspond to the element with atomic number 1 (hydrogen). If we wanted to simulate water, we might make the hydrogen atoms type 1 and the oxygen atoms type 2. We will specify the physical and chemical properties of each atom type later in the input script.&lt;br /&gt;
&lt;br /&gt;
The remaining data in the log file isn&#039;t very instructive as it stands &amp;amp;mdash; it simply contains a list of the thermodynamic properties of the simulation at certain intervals. In a few sections time, we will plot this data, but for now you can close the log file. Keep the input script open.&lt;br /&gt;
&lt;br /&gt;
===Setting the properties of the atoms===&lt;br /&gt;
&lt;br /&gt;
In addition to their positions, we also need the physical properties of the atoms to be able to perform the simulation. We set these properties on a &#039;per-type&#039; basis, so that every atom of the same type has the same mass and the same interactions.&lt;br /&gt;
&lt;br /&gt;
So far we have created 1000 atoms, and we know the starting (&amp;lt;math&amp;gt;t = 0&amp;lt;/math&amp;gt;) position for each of them. We have also set their masses, and told LAMMPS what sort of forces to calculate between them. The final thing we need to specify to completely specify the initial conditions is the velocity of each atom.&lt;br /&gt;
&lt;br /&gt;
Choosing initial velocities for the atoms is a little easier than choosing initial positions. From the statistical thermodynamics lectures, you should know that, at equilibrium, the velocities of atoms in any system must be distributed according to the [http://en.wikipedia.org/wiki/Maxwell%E2%80%93Boltzmann_distribution Maxwell-Boltzmann (MB) distribution]. If we know the masses of the atoms, and we know what temperature we want to simulate, then we can determine the relevant MB distribution function. LAMMPS is able to give every atom a random velocity whilst ensuring that overall the MB distribution is followed. This is the purpose of the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
velocity all create 1.5 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see the manual page for this command [http://lammps.sandia.gov/doc/velocity.html here], but the key sections are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;all&#039;&#039;&#039;: the &#039;&#039;group&#039;&#039; of atoms on which the command acts. &#039;&#039;&#039;all&#039;&#039;&#039; simply specifies that we want every atom to have a velocity assigned to it.&lt;br /&gt;
* &#039;&#039;&#039;1.5&#039;&#039;&#039;: the temperature, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, needed to calculate the MB distribution(in reduced units, as always)&lt;br /&gt;
&lt;br /&gt;
===Monitoring thermodynamic properties===&lt;br /&gt;
&lt;br /&gt;
We need to be sure that our simulation is correctly modelling whatever physical system we want to study. It is relatively easy to set up simulations, but how can we be sure that the &amp;quot;results&amp;quot; we get make sense? One of the best ways is to calculate from the simulation things that we can measure in experiment, and see if they agree. For example, we might want to simulate our system at a particular temperature and pressure, and measure the resulting density. If we repeat this over a range of temperatures at the same pressure, we will be able to plot an &#039;&#039;equation of state&#039;&#039;, which we could compare to experimental measurements.&lt;br /&gt;
&lt;br /&gt;
LAMMPS is able to calculate a great deal of thermodynamic information for us (you can see a full list of the properties it is able to calculate [http://lammps.sandia.gov/doc/thermo_style.html here]), but in these first simulations we are only interested in those properties specified in these commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
thermo 10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first controls which properties will be printed out in the log file. In this case, we print how much time we have simulated so far (which is &#039;&#039;not&#039;&#039; the same as how long it has taken us to simulate it!), the total energy of the atoms, their temperature, and their pressure. The second line tells LAMMPS to print this information on every 10th timestep.&lt;br /&gt;
&lt;br /&gt;
===Running the simulation===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Look at the lines below.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### SPECIFY TIMESTEP ###&lt;br /&gt;
variable timestep equal 0.001&lt;br /&gt;
variable n_steps equal floor(100/${timestep})&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
### RUN SIMULATION ###&lt;br /&gt;
run ${n_steps}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The second line (starting &amp;quot;variable timestep...&amp;quot;) tells LAMMPS that if it encounters the text ${timestep} on a subsequent line, it should replace it by the value given. In this case, the value ${timestep} is always replaced by 0.001.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ask the demonstrator if you need help.&#039;&#039;&#039;&lt;br /&gt;
It is now time to run your first simulation, submit the input script with the data file in the intro folder of the files you have downloaded Try changing the timestep - what happens when you make the timestep larger?.&lt;br /&gt;
&lt;br /&gt;
===Visualising the trajectory===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;trajectory files&#039;&#039;&#039; contain the positions of all the atoms in the simulation, recorded at a set interval (for all of these simulations, this was every ten timesteps &amp;amp;mdash; this is controlled by the &#039;&#039;&#039;dump&#039;&#039;&#039; command in the input scripts). We use a programme called [http://www.ks.uiuc.edu/Research/vmd/ &#039;&#039;&#039;VMD&#039;&#039;&#039;] to view these trajectories, which you should find is already installed on both the desktop and laptop computers. You can run VMD from the start menu with &#039;&#039;&#039;Start&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;All Programs&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;University of Illinois&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;VMD&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
====Loading a Trajectory====&lt;br /&gt;
&lt;br /&gt;
We&#039;ll start by looking at the output of the 0.015 timestep simulation. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;File&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;New Molecule&#039;&#039;&#039;. Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button, then select the relevant trajectory file. In the &#039;&#039;&#039;Determine file type&#039;&#039;&#039; dropdown, select &#039;&#039;&#039;LAMMPS Trajectory&#039;&#039;&#039;. Then click &#039;&#039;&#039;Load&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You will see that the &#039;&#039;&#039;VMD 1.9.1 OpenGL Display&#039;&#039;&#039; window now shows a horrible mess. VMD&#039;s default behaviour is to draw lines between atoms which it thinks might be chemically bonded. Our system doesn&#039;t model chemical bonds, so we want to turn this off. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;Graphics&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Representations&#039;&#039;&#039;. This shows a list of &amp;quot;representations&amp;quot; of our atoms. You will see that at the moment, there is a single representation listed, and it is selected. It will have the &#039;&#039;Lines&#039;&#039; style, the &#039;&#039;Name&#039;&#039; colour, and the selection &#039;&#039;all&#039;&#039;. &amp;quot;Selection&amp;quot; simply tells VMD which atoms we want it to draw. We want to show every atom, so the current selection is fine. The &#039;&#039;name&#039;&#039; colouring method just makes VMD give atoms colours according to their specified type. The colour isn&#039;t important to us, so we can leave this be too. The &amp;quot;style&amp;quot; tells VMD what we want it to display for each atom. Change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; from &#039;&#039;Lines&#039;&#039; to &#039;&#039;VDW&#039;&#039;. You will see that the mess of lines is replaced by a mess of low resolution, overlapping spheres. Change the &#039;&#039;&#039;Sphere Scale&#039;&#039;&#039; to 0.3, and the &#039;&#039;&#039;Sphere Resolution&#039;&#039;&#039; to 17. The result should look a little smoother. Close the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window. You will notice that in the bottom right of the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, there is a small play button. Click this, and you will see the animated version of your simulation trajectory.&lt;br /&gt;
&lt;br /&gt;
By clicking and dragging with the mouse, you can rotate the simulation box (though this may be sluggish). At any time, you can reset the view by pressing the equals key.&lt;br /&gt;
&lt;br /&gt;
====Tracking a Single Particle====&lt;br /&gt;
To illustrate the periodic boundary conditions that we are using, we are going to draw almost all of the atoms as points, but we will pick a single atom at random to draw as a sphere. This will make it easy to see how a single atom moves through the box. Reset the display using the equals key, then use the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window controls to pause the trajectory and reset it to the first trajectory (play with the different buttons until you find the one that does this). You should see the perfect cubic lattice. Use the option &#039;&#039;&#039;Display&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Orthographic&#039;&#039;&#039; to change the drawing mode, then rotate the displayed crystal so that you are looking at one vertex (looking down the 111 direction, in crystallographic terms).&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window again. Change the representation style from &#039;&#039;&#039;VDW&#039;&#039;&#039; to points, then click the &#039;&#039;&#039;Create Rep&#039;&#039;&#039; button. This creates a second representation, allowing a subset of the atoms to be drawn in a different way. The &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; box allows us to choose which atoms this representation applies to. We just want to pick two of them at random &amp;amp;mdash; VMD assigns every atom an index, from 0 to N-1. In our case, there are 1000 atoms, so choose two numbers between 0 and 999. Changed the &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; field to &amp;lt;pre&amp;gt;index i or index j&amp;lt;/pre&amp;gt; where i and j are your chosen numbers, press return, then change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; to &#039;&#039;&#039;VDW&#039;&#039;&#039;. You should now see only two atoms represented by spheres, with the rest shown as small points. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, click play. Try rotating the box, and changing the playback speed.&lt;br /&gt;
&lt;br /&gt;
You will see that sometimes one of the spheres seems to change position across the box very rapidly &amp;amp;mdash; this occurs when it reaches one periodic boundary, and is reflected back across the other face. Try playing with some of the other representation types in VMD &amp;amp;mdash; it  is a very powerful package, which is often used to render images of simulated proteins, so many of its options aren&#039;t relevant to our simple system!&lt;br /&gt;
&lt;br /&gt;
===Checking equilibration===&lt;br /&gt;
&lt;br /&gt;
When we first set up a simulation, it is very important to make sure that our system reaches an equilibrium state. We characterise equilibrium by the average values of thermodynamic quantities becoming constant (due to the approximations that we have made, there will always be fluctuations, but the average values will become constant).&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to plot the thermodynamic output of the simulation to see how long it takes to reach the equilibrium state (and indeed, whether this happens at all). Instructions are given below to import data from the LAMMPS log file into Microsoft Excel. Once you have the data in a spreadsheet, you can plot it. If you know how to use some of the other plotting software available on the chemistry computers (like Origin), you are welcome to use it.&lt;br /&gt;
&lt;br /&gt;
# Open a blank Excel workbook&lt;br /&gt;
# Choose the &#039;&#039;&#039;Data&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;From Text&#039;&#039;&#039; button&lt;br /&gt;
# Select one of your simulation log files&lt;br /&gt;
# Set the &#039;&#039;&#039;Start import at row&#039;&#039;&#039; field to &#039;&#039;&#039;25&#039;&#039;&#039; (this ignores all of the diagnostic information at the top of the file)&lt;br /&gt;
# Set the &#039;&#039;&#039;Original Data type&#039;&#039;&#039; to &#039;&#039;&#039;Delimited&#039;&#039;&#039;, then click &#039;&#039;&#039;Next&#039;&#039;&#039;&lt;br /&gt;
# Tick the &#039;&#039;&#039;Space&#039;&#039;&#039; box, and make sure that &#039;&#039;&#039;Treat consecutive delimiters as one&#039;&#039;&#039; box is ticked.&lt;br /&gt;
# On the next dialog, you can select where you want the data to be inserted. When you are happy, click &#039;&#039;&#039;OK&#039;&#039;&#039;. The data will be inserted into your spreadsheet.&lt;br /&gt;
# Scroll to the bottom of the data &amp;amp;mdash; you will see a lot of timing information from the simulation. Delete everything beyond the end of your thermodynamic data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 7: make plots of the energy, temperature, and pressure, against time for the 0.001 timestep experiment (attach a picture to your report). Does the simulation reach equilibrium? When you have done this, make a single plot which shows the energy versus time for all of the timesteps you have simulated (again, attach a picture to your report). Of the timesteps that you used, which timestep will you use for subsequent simulations and why? [9 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation&amp;diff=734593</id>
		<title>Third year simulation experiment/Introduction to molecular dynamics simulation</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation&amp;diff=734593"/>
		<updated>2018-10-15T08:21:45Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Velocity Verlet Algorithm */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the second section of the third year simulation experiment. You can return to the previous section, [[Third year simulation experiment/Files to download|Downloading Files]], or jump ahead to the next section, [[Third year simulation experiment/Equilibration|Equilibration]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;This section contains background information about the theory of molecular dynamics simulations. It contains a number of relatively short exercises that you must complete as part of your lab write-up. These are labelled in bold and preceded by the word TASK in large print. It is recommended that you read the information on this page before carrying on with the rest of the experiment, but you are encouraged to save the TASKS for later; you can attempt them while you wait for long simulations to finish.&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this section, we briefly discuss the theory behind molecular dynamics (MD) simulations. When we perform MD, we calculate how a particular set of atoms move over time. Using statistical physics, we can use the positions, velocities, and forces, of the atoms to calculate thermodynamic quantities like temperature and pressure.&lt;br /&gt;
&lt;br /&gt;
==Theory==&lt;br /&gt;
&lt;br /&gt;
===The Classical Particle Approximation===&lt;br /&gt;
&lt;br /&gt;
As you may remember from your quantum chemistry lectures, it is very straightforward to write down the Schroedinger equation that describes the behaviour of any particular chemical system. For anything more complicated than a hydrogen atom, however, it is impossible to solve exactly. Even approximate solutions can be extremely computationally demanding. To be able to simulate a real system, we have to make some approximations.&lt;br /&gt;
&lt;br /&gt;
It turns out that, to a very good approximation, we can assume that atoms behave as classical particles. Imagine a collection of &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms. Each one of them will interact with all of the others, and so each atom will feel a force. Newton&#039;s second law tell us that that force causes the atom to accelerate.&lt;br /&gt;
&lt;br /&gt;
Throughout this section, we are going to use the following notation:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathbf{F}_i&amp;lt;/math&amp;gt; is the force acting on atom i.&lt;br /&gt;
* &amp;lt;math&amp;gt;m_i&amp;lt;/math&amp;gt; is the mass of atom i.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathbf{a}_i&amp;lt;/math&amp;gt; is the acceleration of atom i, the rate of change of its velocity.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathbf{v}_i&amp;lt;/math&amp;gt; is the velocity of atom i.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathbf{x}_i&amp;lt;/math&amp;gt; is the position of atom i.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{F}_i = m_i \mathbf{a}_i = m_i \frac{\mathrm{d}\mathbf{v}_i}{\mathrm{d}t} = m_i \frac{\mathrm{d}^2 \mathbf{x}_i}{\mathrm{d}t^2} \ \ (1)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a second order differential equation for the positions of the atoms &amp;amp;mdash; if we know how the force, &amp;lt;math&amp;gt;\mathbf{F}_i&amp;lt;/math&amp;gt;, behaves as a function of time, then we can determine the atomic positions and velocities at any time we like. Our system of &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms has &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; of these equations, one for each atom. This is one of the reasons that computer simulations are needed &amp;amp;mdash; if we want to model the behaviour of a liquid, we can hardly solve the necessary number of equations by hand.&lt;br /&gt;
&lt;br /&gt;
===Numerical Integration===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Numerical integration is a rather complex topic. In particular, the notation used below can be quite intimidating. Remember that you are encouraged to ask for help from the demonstrator if you want to discuss any part of this experiment!&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are a number of numerical algorithms to perform a molecular dynamics simulation, two are presented here- The Classical Verlet algorithm and The Velocity-Verlet algorithm.&lt;br /&gt;
&lt;br /&gt;
====Verlet Algorithm====&lt;br /&gt;
&lt;br /&gt;
To solve these equations numerically we have to &#039;&#039;discretise&#039;&#039; the problem: rather than treating the atomic positions, velocities, and forces as continuous functions of time, we break our simulation up into a sequence of &#039;&#039;&#039;timesteps&#039;&#039;&#039;, each of length &amp;lt;math&amp;gt;\delta t&amp;lt;/math&amp;gt;. This process is illustrated for a simple function in &#039;&#039;&#039;figure 1&#039;&#039;&#039;. The method that we are going to use to solve Newton&#039;s law for our atoms is usually called the Verlet algorithm (although it is an old method, and has been &#039;rediscovered&#039; many times!). To understand its origin, we will begin with a brief derivation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-Discretisation.png|300px|thumb|center|&#039;&#039;&#039;Figure 1&#039;&#039;&#039;: Discretisation of sin(x) between 0 and &amp;lt;math&amp;gt;2\pi&amp;lt;/math&amp;gt;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We denote the position of an atom, &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;, at time &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;\mathbf{x}_i \left(t\right)&amp;lt;/math&amp;gt;. Similarly, &amp;lt;math&amp;gt;\mathbf{v}_i \left(t\right)&amp;lt;/math&amp;gt; is the velocity of that atom at the same time. What we want to know is the position of the atoms at the next timestep, &amp;lt;math&amp;gt;t + \delta t&amp;lt;/math&amp;gt;. The basic Verlet algorithm is shown in &#039;&#039;&#039;figure 2&#039;&#039;&#039; - knowing a set of initial conditions the algorithm calculates forces and by Newton&#039;s second law, we can update the positions of a set of particles are a time &amp;lt;math&amp;gt;t + \delta t&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-Verlet-flowchart.svg|300px|thumb|center|&#039;&#039;&#039;Figure 2&#039;&#039;&#039;: Steps to implement the classic Verlet algorithm.]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt; TASK 1: By taking Taylor expansions of  &amp;lt;math&amp;gt;x(t + \delta t)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;x(t - \delta t)&amp;lt;/math&amp;gt;, write general expressions for them up to the fourth order &amp;lt;math&amp;gt;\mathcal{O}\left(\delta t^4\right)&amp;lt;/math&amp;gt; &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt; Having written these expressions, derive the formula in figure 2 to update positions as used in the classical Verlet algorithm &amp;lt;math&amp;gt; x(t + \delta t) \approx 2x_{i}(t) - x_{i}(t-\delta t) + \frac{F_{i}(t)}{m} \delta t^{2}&amp;lt;/math&amp;gt; by using Newton&#039;s second law to replace &amp;lt;math&amp;gt;\frac{\mathrm{d}^2\mathbf{x}_i\left(t\right)}{\mathrm{d}t^2}&amp;lt;/math&amp;gt; [6 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Using this last equation, we can use a sequence of steps like those shown in &#039;&#039;&#039;figure 2&#039;&#039;&#039; to get the positions. At no point are the velocities calculated in this method!&lt;br /&gt;
&lt;br /&gt;
====Velocity Verlet Algorithm====&lt;br /&gt;
&lt;br /&gt;
If we assume that the acceleration of an atom depends only on its position and not its velocity, then we are able to come up with a new algorithm that lets us calculate atomic velocities explicitly as shown in &#039;&#039;&#039;figure 3&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-VelocityVerlet-flowchart.svg|300px|thumb|center|&#039;&#039;&#039;Figure 3&#039;&#039;&#039;: Steps to implement the velocity Verlet algorithm.]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We start by noting that&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{v}_i\left(t + \delta t\right) = \mathbf{v}_i\left(t\right) + \frac{\mathbf{a}_i\left(t\right) + \mathbf{a}_i\left(t + \delta t\right)}{2}\delta t \ \ (6)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can Taylor expand the velocity by half a step, instead of a full step.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{v}_i\left(t + \frac{1}{2}\delta t\right) = \mathbf{v}_i\left(t\right) + \frac{1}{2} \mathbf{a}_i\left(t\right)\delta t \ \ (7)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then substitute this into your expansion for &amp;lt;math&amp;gt; x_{i} (t + \delta t) &amp;lt;/math&amp;gt; to obtain an accuracy up to &amp;lt;math&amp;gt; \delta t ^{2} &amp;lt;/math&amp;gt;. Notice that terms up to &amp;lt;math&amp;gt; \delta t ^{2} &amp;lt;/math&amp;gt; in your expansion can be written:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; \mathbf{x}_{i} (t + \delta t) = \mathbf{x}_{i} (t) + \mathbf{v}(t) \delta t + \frac{1}{2} \mathbf{a}(t) \delta t ^{2} &amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{x}_i\left(t + \delta t\right) = \mathbf{x}_i\left(t\right) + \mathbf{v}_i\left(t + \frac{1}{2}\delta t\right)\delta t \ \ (8)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When we know the updated atomic positions, we can calculate new forces, &amp;lt;math&amp;gt;\mathbf{a}_i\left(t + \delta t\right)&amp;lt;/math&amp;gt;. Finally, we substitute equation (7) into equation (6) to get the new velocities &amp;lt;math&amp;gt;\mathbf{v}_i\left(t + \delta t\right)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{v}_i\left(t + \delta t\right) = \mathbf{v}_i\left(t + \frac{1}{2}\delta t\right) + \frac{1}{2}\mathbf{a}_i\left(t + \delta t\right)\delta t \ \ (9)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that for both numerical integration algorithms, the first step is &amp;quot;specify initial conditions&amp;quot;. When using the Verlet algorithm, we need to know the starting positions of the atoms (&amp;lt;math&amp;gt;\mathbf{x}_i\left(0\right)&amp;lt;/math&amp;gt;), and their positions one timestep in the past (&amp;lt;math&amp;gt;\mathbf{x}_i\left(-\delta t\right)&amp;lt;/math&amp;gt;). If the velocity-Verlet algorithm is used, then we have to know the  the starting positions of the atoms (&amp;lt;math&amp;gt;\mathbf{x}_i\left(0\right)&amp;lt;/math&amp;gt;) and their velocities at the same time (&amp;lt;math&amp;gt;\mathbf{v}_i\left(0\right)&amp;lt;/math&amp;gt;). For this reason, we often start new simulations by using the output of older ones. If, however, you are performing your first simulations of a system (as we are now), then you must choose your initial conditions. The simulation software that we will use is able to do this for us, and this will be explained in the next section.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt; TASK 2: What could be an advantage of the Velocity-Verlet algorithm over the classical Verlet algorithm? [1 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Atomic Forces===&lt;br /&gt;
&lt;br /&gt;
Since we can&#039;t reasonably solve the equations from quantum physics necessary to determine the forces acting on a given configuration of atoms, we have to make approximations. We know from classical physics that the force acting on an object is determined by the potential that it experiences:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{F}_i = - \frac{\mathrm{d}U\left(\mathbf{r}^N\right)}{\mathrm{d}\mathbf{r}_i}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The shorthand notation &amp;lt;math&amp;gt;\mathbf{r}^N&amp;lt;/math&amp;gt; stands for the position vectors of &#039;&#039;&#039;every&#039;&#039;&#039; atom in system. In principle, the force that a single atom feels is determined by the position of every other atom in the simulation. All we then need to do is to find a function &amp;lt;math&amp;gt;U&amp;lt;/math&amp;gt; that captures all the key physics of the interatomic interactions in the system. For many simple liquids, it turns out that we can model the interactions between each pair of atoms extremely well using the Lennard-Jones potential. Overall, U takes the form:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;U\left(\mathbf{r}^N\right) = \sum_i^N \sum_{i \neq j}^{N} \left\{ 4\epsilon \left( \frac{\sigma^{12}}{r_{ij}^{12}} - \frac{\sigma^6}{r_{ij}^6} \right) \right\} \ \ (10)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 3: For a single Lennard-Jones interaction, &amp;lt;math&amp;gt;\phi\left(r\right) = 4\epsilon \left( \frac{\sigma^{12}}{r^{12}} - \frac{\sigma^6}{r^6} \right)&amp;lt;/math&amp;gt;, find the separation, &amp;lt;math&amp;gt;r_0&amp;lt;/math&amp;gt;, at which the potential energy is zero. What is the force at this separation? Find the equilibrium separation, &amp;lt;math&amp;gt;r_{eq}&amp;lt;/math&amp;gt;, and work out the well depth (&amp;lt;math&amp;gt;\phi\left(r_{eq}\right)&amp;lt;/math&amp;gt;). Evaluate the integrals &amp;lt;math&amp;gt;\int_{2\sigma}^\infty \phi\left(r\right)\mathrm{d}r&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\int_{2.5\sigma}^\infty \phi\left(r\right)\mathrm{d}r&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\int_{3\sigma}^\infty \phi\left(r\right)\mathrm{d}r&amp;lt;/math&amp;gt; when &amp;lt;math&amp;gt;\sigma = \epsilon = 1.0&amp;lt;/math&amp;gt; [4 marks]&amp;lt;/big&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
====Periodic Boundary Conditions====&lt;br /&gt;
&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-Box.png|200px|thumb|right|&#039;&#039;&#039;Figure 4&#039;&#039;&#039;: Diagram of a simulation box containing 2139 atoms. The blue lines indicate the boundaries of the box.]]&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-Periodic.svg|300px|thumb|left|&#039;&#039;&#039;Figure 5&#039;&#039;&#039;: Periodic boundary conditions in two dimensions.]]&lt;br /&gt;
&lt;br /&gt;
We cannot simulate realistic volumes of liquid. In fact, in our simulations, &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; will be between &amp;lt;math&amp;gt;1000&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;10000&amp;lt;/math&amp;gt;. The following task should illustrate why this must be so.&lt;br /&gt;
&lt;br /&gt;
In order for our simulations to approximate a bulk liquid, we have to use a computational trick. The atoms in the simulation are enclosed in a simulation box, of fixed dimensions (&#039;&#039;&#039;figure 4&#039;&#039;&#039;). This box is very often a cuboid, but parallelepipeds can also be used (and this can be very useful when simulating crystal structures). We pretend that we have repeated our box infinitely in all directions, so that the atoms at the very edges are not exposed to a vacuum. This is illustrated in two dimensions in &#039;&#039;&#039;figure 5&#039;&#039;&#039;. The darker coloured atoms in the central box are the &amp;quot;real&amp;quot; atoms. The faded atoms in the outer four boxes are the replicas. When an atom crosses the boundary of the box, one of its replicas enters the box through the opposite face. In this way, the number of atoms inside the box is always constant.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 4: Consider an atom at position &amp;lt;math&amp;gt;\left(0.5, 0.5, 0.5\right)&amp;lt;/math&amp;gt; in a cubic simulation box which runs from &amp;lt;math&amp;gt;\left(0, 0, 0\right)&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;\left(1, 1, 1\right)&amp;lt;/math&amp;gt;. In a single timestep, it moves along the vector &amp;lt;math&amp;gt;\left(0.7, 0.6, 0.2\right)&amp;lt;/math&amp;gt;. At what point does it end up, &#039;&#039;after the periodic boundary conditions have been applied&#039;&#039;? [1 marks]&#039;&#039;&#039; &amp;lt;/big&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
====Truncation====&lt;br /&gt;
&lt;br /&gt;
Periodic boundary conditions introduce their own problems. When we defined our potential function (equation 10), we specified that it depended on all possible pairs of atoms. If we have an infinite number of replicas of our system, how can we avoid calculating an infinite number of pair interactions?&lt;br /&gt;
&lt;br /&gt;
Think about the three integrals you calculated for the Lennard-Jones potential task. They represent the area under the Lennard-Jones potential curve between some specified distance (&amp;lt;math&amp;gt;2\sigma&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;2.5\sigma&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;3\sigma&amp;lt;/math&amp;gt;), and infinite separation (where there is no interaction). You should find that this value becomes rather small as the near distance is increased! The attractive &amp;lt;math&amp;gt;\frac{1}{r^6}&amp;lt;/math&amp;gt; part of the potential dominates here, and this decays rapidly with &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. We assume that this means that there is a distance beyond which the interaction is so small that we can safely ignore it. In fact, in most simulations this is chosen to be something close to &amp;lt;math&amp;gt;2.5\sigma&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;3\sigma&amp;lt;/math&amp;gt;. When the forces are calculated, we only calculate interactions between a pair of atoms if their separation is less than this cutoff.&lt;br /&gt;
&lt;br /&gt;
====Reduced Units====&lt;br /&gt;
&lt;br /&gt;
It is typical when using Lennard-Jones interactions to work in reduced units. By this, we mean that all quantities in our simulation are divided by scaling factors &amp;amp;mdash; for example, distances are divided by &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt;. The result of this is that the values become more manageable: all values that we might work out are typically around 1, rather than &amp;lt;math&amp;gt;1\times 10^{-10}&amp;lt;/math&amp;gt; (in the case of distance), &amp;lt;math&amp;gt;300&amp;lt;/math&amp;gt; (in the case of temperature), or &amp;lt;math&amp;gt;1\times 10^{-19}&amp;lt;/math&amp;gt; (in the case of energy).&lt;br /&gt;
&lt;br /&gt;
We denote these reduced quantities by a star, and they take the following conversion factors:&lt;br /&gt;
&lt;br /&gt;
* distance &amp;lt;math&amp;gt;r^* = \frac{r}{\sigma}&amp;lt;/math&amp;gt;&lt;br /&gt;
* energy &amp;lt;math&amp;gt;E^* = \frac{E}{\epsilon}&amp;lt;/math&amp;gt;&lt;br /&gt;
* temperature &amp;lt;math&amp;gt;T^* = \frac{k_BT}{\epsilon}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 5: The Lennard-Jones parameters for argon are &amp;lt;math&amp;gt;\sigma = 0.34\mathrm{nm}, \epsilon\ /\ k_B= 120 \mathrm{K}&amp;lt;/math&amp;gt;. If the LJ cutoff is &amp;lt;math&amp;gt;r^* = 3.2&amp;lt;/math&amp;gt;, what is it in real units? What is the well depth in &amp;lt;math&amp;gt;\mathrm{kJ\ mol}^{-1}&amp;lt;/math&amp;gt;? What is the reduced temperature &amp;lt;math&amp;gt;T^* = 1.5&amp;lt;/math&amp;gt; in real units? [1 marks]&amp;lt;/big&amp;gt; &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the second section of the third year simulation experiment. You can return to the previous section, [[Third year simulation experiment/Running your first simulation|Running your first simulation]], or jump ahead to the next section, [[Third year simulation experiment/Equilibration|Equilibration]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Dynamical_properties_and_the_diffusion_coefficient&amp;diff=734592</id>
		<title>Third year simulation experiment/Dynamical properties and the diffusion coefficient</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Dynamical_properties_and_the_diffusion_coefficient&amp;diff=734592"/>
		<updated>2018-10-15T08:14:22Z</updated>

		<summary type="html">&lt;p&gt;Otr12: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the sixth (and final) section of the third year simulation experiment. You can return to the previous page, [[Third year simulation experiment/Structural properties and the radial distribution function|Structural properties and the radial distribution function]], or go back to the [[Third_year_simulation_experiment|Introduction]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this final section, we are going to make measurements to get some idea of how much the atoms in our simulation move around. We can characterise this by the diffusion coefficient, which we will calculate by two different approaches.&lt;br /&gt;
&lt;br /&gt;
==Simulations in this Section==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 10: In the D subfolder, there is a file &#039;&#039;liq.in&#039;&#039; that will run a simulation at specified density and temperature to calculate the mean squared displacement and velocity autocorrelation function of your system. Run one of these simulations for a vapour, liquid, and solid. You have also been given some simulated data from much larger systems (approximately one million atoms). You will need these files later. make a plot for each of your simulations (solid, liquid, and gas), showing the mean squared displacement (the &amp;quot;total&amp;quot; MSD) as a function of timestep. Are these as you would expect? Estimate &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; in each case. Be careful with the units! Repeat this procedure for the MSD data that you were given from the one million atom simulations. Compare your data to the million atoms. [10 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Mean Squared Displacement==&lt;br /&gt;
The easiest way to measure &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is by exploiting its connection to the [http://en.wikipedia.org/wiki/Mean_squared_displacement mean squared displacement].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;D = \frac{1}{6}\frac{\partial\left\langle r^2\left(t\right)\right\rangle}{\partial t}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that in general, we expect the simulation to take a little time to establish this linear behaviour!&lt;br /&gt;
&lt;br /&gt;
The simulations that you have already performed have recorded the MSD for you. Download the &amp;quot;optional output-2&amp;quot; file for each of the simulations, and give it a suitable name. These are text files which contain 5 columns: the first is the number of timesteps since the start of the simulation (*not* the elapsed time in reduced units), the next three contain the mean squared displacement for each of the Cartesian directions (x,y,z), and the final column contains the &amp;quot;total&amp;quot; mean squared displacement.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the seventh (and final) section of the third year simulation experiment. You can return to the previous page, [[Third year simulation experiment/Structural properties and the radial distribution function|Structural properties and the radial distribution function]], or go back to the [[Third_year_simulation_experiment|Introduction]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Structural_properties_and_the_radial_distribution_function&amp;diff=734591</id>
		<title>Third year simulation experiment/Structural properties and the radial distribution function</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Structural_properties_and_the_radial_distribution_function&amp;diff=734591"/>
		<updated>2018-10-15T08:14:05Z</updated>

		<summary type="html">&lt;p&gt;Otr12: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the fifth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Running_simulations_under_specific_conditions|Running simulations under specific conditions]], or jump ahead to the next section, [[Third year simulation experiment/Dynamical properties and the diffusion coefficient|Dynamical properties and the diffusion coefficient]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
We can characterise the structure of systems that we simulate using [http://en.wikipedia.org/wiki/Radial_distribution_function radial distribution functions], which we denote &amp;lt;math&amp;gt;g(r)&amp;lt;/math&amp;gt;. Calculating the RDF for a simulation is very useful &amp;amp;mdash; it can tell us the distances from an atom at which we will find it&#039;s nearest neighbour, second nearest neighbour, and so on; it is also a quantity that can be accessed experimentally, and so provides a good check that the forcefield in our simulation is correctly reproducing the structural features.&lt;br /&gt;
&lt;br /&gt;
In this section, you are going to use VMD to calculate the radial distribution function for the solid, liquid, and vapour phases of the Lennard-Jones fluid.&lt;br /&gt;
&lt;br /&gt;
===Calculating &amp;lt;math&amp;gt;g(r)&amp;lt;/math&amp;gt; in VMD===&lt;br /&gt;
&lt;br /&gt;
# Start VMD as before and load the trajectory that you want to analyse.&lt;br /&gt;
# Select &#039;&#039;&#039;Extensions&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Analysis&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Radial Pair Distribution Function g(r)&#039;&#039;&#039;&lt;br /&gt;
# Set &#039;&#039;&#039;Selection 1&#039;&#039;&#039; to &#039;&#039;&#039;all&#039;&#039;&#039; and &#039;&#039;&#039;Selection 2&#039;&#039;&#039; to &#039;&#039;&#039;all&#039;&#039;&#039;&lt;br /&gt;
# Change &#039;&#039;&#039;delta r&#039;&#039;&#039; to &#039;&#039;&#039;0.05&#039;&#039;&#039; &amp;amp;mdash; this is the distance between points in the generated RDF.&lt;br /&gt;
# Ensure that &#039;&#039;&#039;Use PBC&#039;&#039;&#039;, &#039;&#039;&#039;Display g(r)&#039;&#039;&#039;, &#039;&#039;&#039;Display Int(g(r))&#039;&#039;&#039;, and &#039;&#039;&#039;Save to File&#039;&#039;&#039; are checked&lt;br /&gt;
# Click &#039;&#039;&#039;Compute g(r)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After a short pause while it performs the calculation, VMD will display both the RDF, and its running integral. You will then be prompted to save this data &amp;amp;mdash; choose a location for the file that you will be able to find easily later.&lt;br /&gt;
&lt;br /&gt;
===Simulations in this section===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;RDF&#039;&#039;&#039; subfolder contains an example input script that you can use to record an atomic trajectory to generate RDFs for the solid, liquid, and vapour phase Lennard Jones systems. Make three copies of that script (one for each phase), and modify the density and temperature parameters to give the phase that you want (a phase diagram for the Lennard-Jones system can be found [http://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151 here]). &#039;&#039;&#039;Note&#039;&#039;&#039;: when simulating the solid, you will need to change the lattice type in the lattice command to fcc, rather than sc.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 9: perform simulations of the Lennard-Jones system in the three phases. When each is complete, download the trajectory and calculate &amp;lt;math&amp;gt;g(r)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\int g(r)\mathrm{d}r&amp;lt;/math&amp;gt;. Plot the RDFs for the three systems on the same axes, and attach a copy to your report. Discuss qualitatively the differences between the three RDFs, and what this tells you about the structure of the system in each phase. In the solid case, illustrate which lattice sites the first three peaks correspond to. What is the lattice spacing? What is the coordination number for each of the first three peaks? [15 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the sixth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Running simulations under specific conditions|Running simulations under specific conditions]], or jump ahead to the next section, [[Third year simulation experiment/Dynamical properties and the diffusion coefficient|Dynamical properties and the diffusion coefficient]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment&amp;diff=734583</id>
		<title>Third year simulation experiment</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment&amp;diff=734583"/>
		<updated>2018-10-08T14:00:11Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Structure of this Experiment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;This is the optional experiment which may be chosen by any third year student. If you are looking for the compulsory simulation experiment for students studying chemistry with molecular physics, you will find it [[Third_year_CMP_compulsory_experiment|here]].&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Computer simulation is widely used to study a huge variety of chemical phenomena, from the behaviour of exotic materials under extreme conditions to protein folding and the properties of biological systems such as lipid membranes. In this experiment, we hope to give you a gentle introduction to one of the most powerful methods for the simulation of chemical systems, &#039;&#039;&#039;molecular dynamics simulation&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This course closely follows some of the ideas introduced in Professor Bresme&#039;s statistical thermodynamics lecture course. Do not worry if you are doing this experiment before the lectures begin, everything that you need to know to complete the experiment will be explained in these instructions. We will begin with a brief overview of the fundamental theory behind the method, before you start running your own simulations of a simple liquid using the college&#039;s [http://www.imperial.ac.uk/admin-services/ict/self-service/research-support/hpc/ high performance computing] facilities.&lt;br /&gt;
&lt;br /&gt;
At the end of this experiment, you will have performed your own simulations using state of the art software packages used by researchers all around the world, and used those simulations to calculate both structural and dynamic properties of a simple liquid. You will have seen how the concepts of statistical physics introduced by Professor Bresme are needed to calculate thermodynamic quantities such as temperature and pressure in computer simulations, and you will see how computers can be used to validate those concepts.&lt;br /&gt;
&lt;br /&gt;
All of the information that you need to complete the experiment is provided in these wiki pages. We have also tried to provide links to external resources and relevant textbooks where possible &amp;amp;mdash; unless explicitly stated, reading these resources &#039;&#039;&#039;is not required&#039;&#039;&#039;; they are provided only as further information for those interested in the subject.&lt;br /&gt;
&lt;br /&gt;
==Assessment==&lt;br /&gt;
&lt;br /&gt;
At the end of this experiment you must submit a report (pdf format via turnitin) no longer than 1500 words. The report should be structured:&lt;br /&gt;
&lt;br /&gt;
* Extended Abstract (20% of the total mark)&lt;br /&gt;
* Results and Discussion (60% of total mark)&lt;br /&gt;
* Conclusion (20% of total mark)&lt;br /&gt;
* References&lt;br /&gt;
&lt;br /&gt;
Relevant supplementary material can be added at the end of the report so long as it supports your discussion. The marking criteria is divided such that the abstract and introduction and the conclusion make up 20% of the total mark each. The results and discussion section, consisting of questions, will yield the remaining 60% of the total mark - each mark earned equates to 1% of the total mark. Importantly, work that presents an engaging dialogue and valid conclusion based on legitimate evidence will score highly. Presentation of results is arguably the most crucial part of science; you don&#039;t just show anything to the scientific community (for fear of inaccuracies being broadly spread and a retraction asked of you!), you show something relevant and defensible.&lt;br /&gt;
&lt;br /&gt;
The abstract is often confused with a conclusion because we&#039;re not really taught how to write one. It&#039;s a section you write after writing the rest of the paper and doesn&#039;t go into as much detail as the conclusion but you sum up the relevance of the research (intro), what you have done, what results you have to show to support this and the ultimate conclusion.&lt;br /&gt;
&lt;br /&gt;
Your introduction paints a picture of the background of the research; what has been done by others and where is the niche for your work. How will your work benefit the community - maybe it&#039;s a new technique. You open up the niche so the subsequent discussion inserts your work into the existing community or (for high impact journals like Nature) creates a question and novel direction that can be picked up and worked on by other interested parties. In this lab, it would be good if you can demonstrate some of the importance of your results and impact it had on Science and society.&lt;br /&gt;
&lt;br /&gt;
Results and Discussion consists of questions throughout the lab and it would be perfectly acceptable to copy the questions and write your answer beneath - there are a total of 10 tasks to complete.&lt;br /&gt;
&lt;br /&gt;
Conclusions - tie up the research and what your results show. Reread your intro, what are you trying to do? How does your research do this?&lt;br /&gt;
Work through the exercises and think about what each of your result mean physically. We ask you to perform an individual investigation at the end - there isn&#039;t really a wrong answer! - try to think about your own experiment before asking others what they did. If you present something interesting in an engaging way, you will score highly. If anything is not clear here, please ask me in the lab or by email. Reports should be submitted to Blackboard by Wednesday 12:00 the week after you undertook the lab.&lt;br /&gt;
&lt;br /&gt;
==Getting Help==&lt;br /&gt;
&lt;br /&gt;
The demonstrators and assessors for this exercise are Ollie Robotham (oliver.robotham12@imperial.ac.uk) and Oli Gittus (org12@ic.ac.uk). Either one of us will be available in the second floor chemistry computer room between 2pm and 3pm on each day of the experiment. If you have questions outside of these times, you are of course welcome to send them by e-mail.&lt;br /&gt;
&lt;br /&gt;
The member of academic staff responsible for this exercise is Professor Fernando Bresme (f.bresme@imperial.ac.uk).&lt;br /&gt;
&lt;br /&gt;
==Structure of this Experiment==&lt;br /&gt;
&lt;br /&gt;
This experimental manual has been broken up into a number of subsections. To help you plan your time it is suggested you complete the following at these times:&lt;br /&gt;
&lt;br /&gt;
Monday (morning session): Theory - Introduction to molecular dynamics simulations&lt;br /&gt;
&lt;br /&gt;
Monday (afternoon session): Theory + Equilibration (submit your files for running)&lt;br /&gt;
&lt;br /&gt;
Tuesday (morning session): Equilibration (analyse your files)&lt;br /&gt;
&lt;br /&gt;
Tuesday (afternoon session): Running simulations under specific conditions (submit and read)&lt;br /&gt;
&lt;br /&gt;
Thursday (morning session): Checkpoint for progress. Submit your input files for the radial distribution function and analyse your equation of state from the previous section&lt;br /&gt;
&lt;br /&gt;
Thursday (afternoon session): Q&amp;amp;A session with Dr. Dominic Lee on theoretical background (ensembles, coexistence, radial distribtuion functions etc). Rdf data analysis and setting up diffusion simulations&lt;br /&gt;
&lt;br /&gt;
Friday (morning session): Analyse MSD diffusion simulations&lt;br /&gt;
&lt;br /&gt;
Friday (afternoon session): Analyse MSD diffusion simulations. Report write-up.&lt;br /&gt;
&lt;br /&gt;
Direct links to each of them may be found below. You should attempt them in order, and you should complete all of them to finish the experiment.&lt;br /&gt;
# [[Third year simulation experiment/Files to download|Downloading the Files]]&lt;br /&gt;
# [[Third year simulation experiment/Introduction to molecular dynamics simulation|Introduction to molecular dynamics simulation]]&lt;br /&gt;
# [[Third_year_simulation_experiment/Equilibration|Equilibration]]&lt;br /&gt;
# [[Third_year_simulation_experiment/Running_simulations_under_specific_conditions|Running simulations under specific conditions]]&lt;br /&gt;
# [[Third year simulation experiment/Structural properties and the radial distribution function|Structural properties and the radial distribution function]]&lt;br /&gt;
# [[Third year simulation experiment/Dynamical properties and the diffusion coefficient|Dynamical properties and the diffusion coefficient]]&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment&amp;diff=734582</id>
		<title>Third year simulation experiment</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment&amp;diff=734582"/>
		<updated>2018-10-08T13:58:38Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Structure of this Experiment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;This is the optional experiment which may be chosen by any third year student. If you are looking for the compulsory simulation experiment for students studying chemistry with molecular physics, you will find it [[Third_year_CMP_compulsory_experiment|here]].&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Computer simulation is widely used to study a huge variety of chemical phenomena, from the behaviour of exotic materials under extreme conditions to protein folding and the properties of biological systems such as lipid membranes. In this experiment, we hope to give you a gentle introduction to one of the most powerful methods for the simulation of chemical systems, &#039;&#039;&#039;molecular dynamics simulation&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This course closely follows some of the ideas introduced in Professor Bresme&#039;s statistical thermodynamics lecture course. Do not worry if you are doing this experiment before the lectures begin, everything that you need to know to complete the experiment will be explained in these instructions. We will begin with a brief overview of the fundamental theory behind the method, before you start running your own simulations of a simple liquid using the college&#039;s [http://www.imperial.ac.uk/admin-services/ict/self-service/research-support/hpc/ high performance computing] facilities.&lt;br /&gt;
&lt;br /&gt;
At the end of this experiment, you will have performed your own simulations using state of the art software packages used by researchers all around the world, and used those simulations to calculate both structural and dynamic properties of a simple liquid. You will have seen how the concepts of statistical physics introduced by Professor Bresme are needed to calculate thermodynamic quantities such as temperature and pressure in computer simulations, and you will see how computers can be used to validate those concepts.&lt;br /&gt;
&lt;br /&gt;
All of the information that you need to complete the experiment is provided in these wiki pages. We have also tried to provide links to external resources and relevant textbooks where possible &amp;amp;mdash; unless explicitly stated, reading these resources &#039;&#039;&#039;is not required&#039;&#039;&#039;; they are provided only as further information for those interested in the subject.&lt;br /&gt;
&lt;br /&gt;
==Assessment==&lt;br /&gt;
&lt;br /&gt;
At the end of this experiment you must submit a report (pdf format via turnitin) no longer than 1500 words. The report should be structured:&lt;br /&gt;
&lt;br /&gt;
* Extended Abstract (20% of the total mark)&lt;br /&gt;
* Results and Discussion (60% of total mark)&lt;br /&gt;
* Conclusion (20% of total mark)&lt;br /&gt;
* References&lt;br /&gt;
&lt;br /&gt;
Relevant supplementary material can be added at the end of the report so long as it supports your discussion. The marking criteria is divided such that the abstract and introduction and the conclusion make up 20% of the total mark each. The results and discussion section, consisting of questions, will yield the remaining 60% of the total mark - each mark earned equates to 1% of the total mark. Importantly, work that presents an engaging dialogue and valid conclusion based on legitimate evidence will score highly. Presentation of results is arguably the most crucial part of science; you don&#039;t just show anything to the scientific community (for fear of inaccuracies being broadly spread and a retraction asked of you!), you show something relevant and defensible.&lt;br /&gt;
&lt;br /&gt;
The abstract is often confused with a conclusion because we&#039;re not really taught how to write one. It&#039;s a section you write after writing the rest of the paper and doesn&#039;t go into as much detail as the conclusion but you sum up the relevance of the research (intro), what you have done, what results you have to show to support this and the ultimate conclusion.&lt;br /&gt;
&lt;br /&gt;
Your introduction paints a picture of the background of the research; what has been done by others and where is the niche for your work. How will your work benefit the community - maybe it&#039;s a new technique. You open up the niche so the subsequent discussion inserts your work into the existing community or (for high impact journals like Nature) creates a question and novel direction that can be picked up and worked on by other interested parties. In this lab, it would be good if you can demonstrate some of the importance of your results and impact it had on Science and society.&lt;br /&gt;
&lt;br /&gt;
Results and Discussion consists of questions throughout the lab and it would be perfectly acceptable to copy the questions and write your answer beneath - there are a total of 10 tasks to complete.&lt;br /&gt;
&lt;br /&gt;
Conclusions - tie up the research and what your results show. Reread your intro, what are you trying to do? How does your research do this?&lt;br /&gt;
Work through the exercises and think about what each of your result mean physically. We ask you to perform an individual investigation at the end - there isn&#039;t really a wrong answer! - try to think about your own experiment before asking others what they did. If you present something interesting in an engaging way, you will score highly. If anything is not clear here, please ask me in the lab or by email. Reports should be submitted to Blackboard by Wednesday 12:00 the week after you undertook the lab.&lt;br /&gt;
&lt;br /&gt;
==Getting Help==&lt;br /&gt;
&lt;br /&gt;
The demonstrators and assessors for this exercise are Ollie Robotham (oliver.robotham12@imperial.ac.uk) and Oli Gittus (org12@ic.ac.uk). Either one of us will be available in the second floor chemistry computer room between 2pm and 3pm on each day of the experiment. If you have questions outside of these times, you are of course welcome to send them by e-mail.&lt;br /&gt;
&lt;br /&gt;
The member of academic staff responsible for this exercise is Professor Fernando Bresme (f.bresme@imperial.ac.uk).&lt;br /&gt;
&lt;br /&gt;
==Structure of this Experiment==&lt;br /&gt;
&lt;br /&gt;
This experimental manual has been broken up into a number of subsections. To help you plan your time it is suggested you complete the following at these times:&lt;br /&gt;
&lt;br /&gt;
Monday (morning session): Theory - Introduction to molecular dynamics simulations&lt;br /&gt;
&lt;br /&gt;
Monday (afternoon session): Theory + Equilibration (submit your files for running)&lt;br /&gt;
&lt;br /&gt;
Tuesday (morning session): Equilibration (analyse your files)&lt;br /&gt;
&lt;br /&gt;
Tuesday (afternoon session): Running simulations under specific conditions (submit and read)&lt;br /&gt;
&lt;br /&gt;
Thursday (morning session): Checkpoint for progress. Submit your input files for the radial distribution function and analyse your equation of state from the previous section&lt;br /&gt;
&lt;br /&gt;
Thursday (afternoon session): Q&amp;amp;A session with Dr. Dominic Lee on theoretical background. Rdf data analysis and setting up diffusion simulations&lt;br /&gt;
&lt;br /&gt;
Friday (morning session): Analyse MSD diffusion simulations&lt;br /&gt;
&lt;br /&gt;
Friday (afternoon session): Analyse MSD diffusion simulations. Report write-up.&lt;br /&gt;
&lt;br /&gt;
Direct links to each of them may be found below. You should attempt them in order, and you should complete all of them to finish the experiment.&lt;br /&gt;
# [[Third year simulation experiment/Files to download|Downloading the Files]]&lt;br /&gt;
# [[Third year simulation experiment/Introduction to molecular dynamics simulation|Introduction to molecular dynamics simulation]]&lt;br /&gt;
# [[Third_year_simulation_experiment/Equilibration|Equilibration]]&lt;br /&gt;
# [[Third_year_simulation_experiment/Running_simulations_under_specific_conditions|Running simulations under specific conditions]]&lt;br /&gt;
# [[Third year simulation experiment/Structural properties and the radial distribution function|Structural properties and the radial distribution function]]&lt;br /&gt;
# [[Third year simulation experiment/Dynamical properties and the diffusion coefficient|Dynamical properties and the diffusion coefficient]]&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment&amp;diff=734581</id>
		<title>Third year simulation experiment</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment&amp;diff=734581"/>
		<updated>2018-10-08T10:37:02Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Assessment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;This is the optional experiment which may be chosen by any third year student. If you are looking for the compulsory simulation experiment for students studying chemistry with molecular physics, you will find it [[Third_year_CMP_compulsory_experiment|here]].&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Computer simulation is widely used to study a huge variety of chemical phenomena, from the behaviour of exotic materials under extreme conditions to protein folding and the properties of biological systems such as lipid membranes. In this experiment, we hope to give you a gentle introduction to one of the most powerful methods for the simulation of chemical systems, &#039;&#039;&#039;molecular dynamics simulation&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This course closely follows some of the ideas introduced in Professor Bresme&#039;s statistical thermodynamics lecture course. Do not worry if you are doing this experiment before the lectures begin, everything that you need to know to complete the experiment will be explained in these instructions. We will begin with a brief overview of the fundamental theory behind the method, before you start running your own simulations of a simple liquid using the college&#039;s [http://www.imperial.ac.uk/admin-services/ict/self-service/research-support/hpc/ high performance computing] facilities.&lt;br /&gt;
&lt;br /&gt;
At the end of this experiment, you will have performed your own simulations using state of the art software packages used by researchers all around the world, and used those simulations to calculate both structural and dynamic properties of a simple liquid. You will have seen how the concepts of statistical physics introduced by Professor Bresme are needed to calculate thermodynamic quantities such as temperature and pressure in computer simulations, and you will see how computers can be used to validate those concepts.&lt;br /&gt;
&lt;br /&gt;
All of the information that you need to complete the experiment is provided in these wiki pages. We have also tried to provide links to external resources and relevant textbooks where possible &amp;amp;mdash; unless explicitly stated, reading these resources &#039;&#039;&#039;is not required&#039;&#039;&#039;; they are provided only as further information for those interested in the subject.&lt;br /&gt;
&lt;br /&gt;
==Assessment==&lt;br /&gt;
&lt;br /&gt;
At the end of this experiment you must submit a report (pdf format via turnitin) no longer than 1500 words. The report should be structured:&lt;br /&gt;
&lt;br /&gt;
* Extended Abstract (20% of the total mark)&lt;br /&gt;
* Results and Discussion (60% of total mark)&lt;br /&gt;
* Conclusion (20% of total mark)&lt;br /&gt;
* References&lt;br /&gt;
&lt;br /&gt;
Relevant supplementary material can be added at the end of the report so long as it supports your discussion. The marking criteria is divided such that the abstract and introduction and the conclusion make up 20% of the total mark each. The results and discussion section, consisting of questions, will yield the remaining 60% of the total mark - each mark earned equates to 1% of the total mark. Importantly, work that presents an engaging dialogue and valid conclusion based on legitimate evidence will score highly. Presentation of results is arguably the most crucial part of science; you don&#039;t just show anything to the scientific community (for fear of inaccuracies being broadly spread and a retraction asked of you!), you show something relevant and defensible.&lt;br /&gt;
&lt;br /&gt;
The abstract is often confused with a conclusion because we&#039;re not really taught how to write one. It&#039;s a section you write after writing the rest of the paper and doesn&#039;t go into as much detail as the conclusion but you sum up the relevance of the research (intro), what you have done, what results you have to show to support this and the ultimate conclusion.&lt;br /&gt;
&lt;br /&gt;
Your introduction paints a picture of the background of the research; what has been done by others and where is the niche for your work. How will your work benefit the community - maybe it&#039;s a new technique. You open up the niche so the subsequent discussion inserts your work into the existing community or (for high impact journals like Nature) creates a question and novel direction that can be picked up and worked on by other interested parties. In this lab, it would be good if you can demonstrate some of the importance of your results and impact it had on Science and society.&lt;br /&gt;
&lt;br /&gt;
Results and Discussion consists of questions throughout the lab and it would be perfectly acceptable to copy the questions and write your answer beneath - there are a total of 10 tasks to complete.&lt;br /&gt;
&lt;br /&gt;
Conclusions - tie up the research and what your results show. Reread your intro, what are you trying to do? How does your research do this?&lt;br /&gt;
Work through the exercises and think about what each of your result mean physically. We ask you to perform an individual investigation at the end - there isn&#039;t really a wrong answer! - try to think about your own experiment before asking others what they did. If you present something interesting in an engaging way, you will score highly. If anything is not clear here, please ask me in the lab or by email. Reports should be submitted to Blackboard by Wednesday 12:00 the week after you undertook the lab.&lt;br /&gt;
&lt;br /&gt;
==Getting Help==&lt;br /&gt;
&lt;br /&gt;
The demonstrators and assessors for this exercise are Ollie Robotham (oliver.robotham12@imperial.ac.uk) and Oli Gittus (org12@ic.ac.uk). Either one of us will be available in the second floor chemistry computer room between 2pm and 3pm on each day of the experiment. If you have questions outside of these times, you are of course welcome to send them by e-mail.&lt;br /&gt;
&lt;br /&gt;
The member of academic staff responsible for this exercise is Professor Fernando Bresme (f.bresme@imperial.ac.uk).&lt;br /&gt;
&lt;br /&gt;
==Structure of this Experiment==&lt;br /&gt;
&lt;br /&gt;
This experimental manual has been broken up into a number of subsections. To help you plan your time it is suggested you complete the following at these times:&lt;br /&gt;
&lt;br /&gt;
Monday (morning session): Theory - Introduction to molecular dynamics simulations&lt;br /&gt;
&lt;br /&gt;
Monday (afternoon session): Theory + Equilibration (submit your files for running)&lt;br /&gt;
&lt;br /&gt;
Tuesday (morning session): Equilibration (analyse your files)&lt;br /&gt;
&lt;br /&gt;
Tuesday (afternoon session): Running simulations under specific conditions (submit and read)&lt;br /&gt;
&lt;br /&gt;
Thursday (morning session): Submit your input files for the radial distribution function and analyse your equation of state from the previous section&lt;br /&gt;
&lt;br /&gt;
Thursday (afternoon session): Analyse the rdf data and setup diffusion simulations&lt;br /&gt;
&lt;br /&gt;
Friday (morning session): Analyse MSD diffusion simulations&lt;br /&gt;
&lt;br /&gt;
Friday (afternoon session): Analyse MSD diffusion simulations&lt;br /&gt;
&lt;br /&gt;
Direct links to each of them may be found below. You should attempt them in order, and you should complete all of them to finish the experiment.&lt;br /&gt;
# [[Third year simulation experiment/Files to download|Downloading the Files]]&lt;br /&gt;
# [[Third year simulation experiment/Introduction to molecular dynamics simulation|Introduction to molecular dynamics simulation]]&lt;br /&gt;
# [[Third_year_simulation_experiment/Equilibration|Equilibration]]&lt;br /&gt;
# [[Third_year_simulation_experiment/Running_simulations_under_specific_conditions|Running simulations under specific conditions]]&lt;br /&gt;
# [[Third year simulation experiment/Structural properties and the radial distribution function|Structural properties and the radial distribution function]]&lt;br /&gt;
# [[Third year simulation experiment/Dynamical properties and the diffusion coefficient|Dynamical properties and the diffusion coefficient]]&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment&amp;diff=734580</id>
		<title>Third year simulation experiment</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment&amp;diff=734580"/>
		<updated>2018-10-08T10:22:50Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Assessment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;This is the optional experiment which may be chosen by any third year student. If you are looking for the compulsory simulation experiment for students studying chemistry with molecular physics, you will find it [[Third_year_CMP_compulsory_experiment|here]].&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Computer simulation is widely used to study a huge variety of chemical phenomena, from the behaviour of exotic materials under extreme conditions to protein folding and the properties of biological systems such as lipid membranes. In this experiment, we hope to give you a gentle introduction to one of the most powerful methods for the simulation of chemical systems, &#039;&#039;&#039;molecular dynamics simulation&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This course closely follows some of the ideas introduced in Professor Bresme&#039;s statistical thermodynamics lecture course. Do not worry if you are doing this experiment before the lectures begin, everything that you need to know to complete the experiment will be explained in these instructions. We will begin with a brief overview of the fundamental theory behind the method, before you start running your own simulations of a simple liquid using the college&#039;s [http://www.imperial.ac.uk/admin-services/ict/self-service/research-support/hpc/ high performance computing] facilities.&lt;br /&gt;
&lt;br /&gt;
At the end of this experiment, you will have performed your own simulations using state of the art software packages used by researchers all around the world, and used those simulations to calculate both structural and dynamic properties of a simple liquid. You will have seen how the concepts of statistical physics introduced by Professor Bresme are needed to calculate thermodynamic quantities such as temperature and pressure in computer simulations, and you will see how computers can be used to validate those concepts.&lt;br /&gt;
&lt;br /&gt;
All of the information that you need to complete the experiment is provided in these wiki pages. We have also tried to provide links to external resources and relevant textbooks where possible &amp;amp;mdash; unless explicitly stated, reading these resources &#039;&#039;&#039;is not required&#039;&#039;&#039;; they are provided only as further information for those interested in the subject.&lt;br /&gt;
&lt;br /&gt;
==Assessment==&lt;br /&gt;
&lt;br /&gt;
At the end of this experiment you must submit a report (pdf format via turnitin) no longer than 1500 words. The report should be structured:&lt;br /&gt;
&lt;br /&gt;
* Extended Abstract (20% of the total mark)&lt;br /&gt;
* Results and Discussion (60% of total mark)&lt;br /&gt;
* Conclusion (20% of total mark)&lt;br /&gt;
* References&lt;br /&gt;
&lt;br /&gt;
Relevant supplementary material can be added at the end of the report so long as it supports your discussion. The marking criteria is divided such that the abstract and introduction and the conclusion make up 20% of the total mark each. The results and discussion section, consisting of questions, will yield the remaining 60% of the total mark - each mark earned equates to 1% of the total mark. Importantly, work that presents an engaging dialogue and valid conclusion based on legitimate evidence will score highly. Presentation of results is arguably the most crucial part of science; you don&#039;t just show anything to the scientific community (for fear of inaccuracies being broadly spread and a retraction asked of you!), you show something relevant and defensible.&lt;br /&gt;
&lt;br /&gt;
The abstract is often confused with a conclusion because we&#039;re not really taught how to write one. It&#039;s a section you write after writing the rest of the paper and doesn&#039;t go into as much detail as the conclusion but you sum up the relevance of the research (intro), what you have done, what results you have to show to support this and the ultimate conclusion.&lt;br /&gt;
&lt;br /&gt;
Your introduction paints a picture of the background of the research; what has been done by others and where is the niche for your work. How will your work benefit the community - maybe it&#039;s a new technique. You open up the niche so the subsequent discussion inserts your work into the existing community or (for high impact journals like Nature) creates a question and novel direction that can be picked up and worked on by other interested parties. In this lab, it would be good if you can demonstrate some of the importance of your results and impact it had on Science and society.&lt;br /&gt;
&lt;br /&gt;
Results and Discussion consists of questions throughout the lab and it would be perfectly acceptable to copy the questions and write your answer beneath. &lt;br /&gt;
&lt;br /&gt;
Conclusions - tie up the research and what your results show. Reread your intro, what are you trying to do? How does your research do this?&lt;br /&gt;
Work through the exercises and think about what each of your result mean physically. We ask you to perform an individual investigation at the end - there isn&#039;t really a wrong answer! - try to think about your own experiment before asking others what they did. If you present something interesting in an engaging way, you will score highly. If anything is not clear here, please ask me in the lab or by email. Reports should be submitted to Blackboard by Wednesday 12:00 the week after you undertook the lab.&lt;br /&gt;
&lt;br /&gt;
==Getting Help==&lt;br /&gt;
&lt;br /&gt;
The demonstrators and assessors for this exercise are Ollie Robotham (oliver.robotham12@imperial.ac.uk) and Oli Gittus (org12@ic.ac.uk). Either one of us will be available in the second floor chemistry computer room between 2pm and 3pm on each day of the experiment. If you have questions outside of these times, you are of course welcome to send them by e-mail.&lt;br /&gt;
&lt;br /&gt;
The member of academic staff responsible for this exercise is Professor Fernando Bresme (f.bresme@imperial.ac.uk).&lt;br /&gt;
&lt;br /&gt;
==Structure of this Experiment==&lt;br /&gt;
&lt;br /&gt;
This experimental manual has been broken up into a number of subsections. To help you plan your time it is suggested you complete the following at these times:&lt;br /&gt;
&lt;br /&gt;
Monday (morning session): Theory - Introduction to molecular dynamics simulations&lt;br /&gt;
&lt;br /&gt;
Monday (afternoon session): Theory + Equilibration (submit your files for running)&lt;br /&gt;
&lt;br /&gt;
Tuesday (morning session): Equilibration (analyse your files)&lt;br /&gt;
&lt;br /&gt;
Tuesday (afternoon session): Running simulations under specific conditions (submit and read)&lt;br /&gt;
&lt;br /&gt;
Thursday (morning session): Submit your input files for the radial distribution function and analyse your equation of state from the previous section&lt;br /&gt;
&lt;br /&gt;
Thursday (afternoon session): Analyse the rdf data and setup diffusion simulations&lt;br /&gt;
&lt;br /&gt;
Friday (morning session): Analyse MSD diffusion simulations&lt;br /&gt;
&lt;br /&gt;
Friday (afternoon session): Analyse MSD diffusion simulations&lt;br /&gt;
&lt;br /&gt;
Direct links to each of them may be found below. You should attempt them in order, and you should complete all of them to finish the experiment.&lt;br /&gt;
# [[Third year simulation experiment/Files to download|Downloading the Files]]&lt;br /&gt;
# [[Third year simulation experiment/Introduction to molecular dynamics simulation|Introduction to molecular dynamics simulation]]&lt;br /&gt;
# [[Third_year_simulation_experiment/Equilibration|Equilibration]]&lt;br /&gt;
# [[Third_year_simulation_experiment/Running_simulations_under_specific_conditions|Running simulations under specific conditions]]&lt;br /&gt;
# [[Third year simulation experiment/Structural properties and the radial distribution function|Structural properties and the radial distribution function]]&lt;br /&gt;
# [[Third year simulation experiment/Dynamical properties and the diffusion coefficient|Dynamical properties and the diffusion coefficient]]&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Dynamical_properties_and_the_diffusion_coefficient&amp;diff=734579</id>
		<title>Third year simulation experiment/Dynamical properties and the diffusion coefficient</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Dynamical_properties_and_the_diffusion_coefficient&amp;diff=734579"/>
		<updated>2018-10-08T10:08:10Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Mean Squared Displacement */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the seventh (and final) section of the third year simulation experiment. You can return to the previous page, [[Third year simulation experiment/Structural properties and the radial distribution function|Structural properties and the radial distribution function]], or go back to the [[Third_year_simulation_experiment|Introduction]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this final section, we are going to make measurements to get some idea of how much the atoms in our simulation move around. We can characterise this by the diffusion coefficient, which we will calculate by two different approaches.&lt;br /&gt;
&lt;br /&gt;
==Simulations in this Section==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 10: In the D subfolder, there is a file &#039;&#039;liq.in&#039;&#039; that will run a simulation at specified density and temperature to calculate the mean squared displacement and velocity autocorrelation function of your system. Run one of these simulations for a vapour, liquid, and solid. You have also been given some simulated data from much larger systems (approximately one million atoms). You will need these files later. make a plot for each of your simulations (solid, liquid, and gas), showing the mean squared displacement (the &amp;quot;total&amp;quot; MSD) as a function of timestep. Are these as you would expect? Estimate &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; in each case. Be careful with the units! Repeat this procedure for the MSD data that you were given from the one million atom simulations. Compare your data to the million atoms. [10 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Mean Squared Displacement==&lt;br /&gt;
The easiest way to measure &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is by exploiting its connection to the [http://en.wikipedia.org/wiki/Mean_squared_displacement mean squared displacement].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;D = \frac{1}{6}\frac{\partial\left\langle r^2\left(t\right)\right\rangle}{\partial t}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that in general, we expect the simulation to take a little time to establish this linear behaviour!&lt;br /&gt;
&lt;br /&gt;
The simulations that you have already performed have recorded the MSD for you. Download the &amp;quot;optional output-2&amp;quot; file for each of the simulations, and give it a suitable name. These are text files which contain 5 columns: the first is the number of timesteps since the start of the simulation (*not* the elapsed time in reduced units), the next three contain the mean squared displacement for each of the Cartesian directions (x,y,z), and the final column contains the &amp;quot;total&amp;quot; mean squared displacement.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the seventh (and final) section of the third year simulation experiment. You can return to the previous page, [[Third year simulation experiment/Structural properties and the radial distribution function|Structural properties and the radial distribution function]], or go back to the [[Third_year_simulation_experiment|Introduction]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Dynamical_properties_and_the_diffusion_coefficient&amp;diff=734578</id>
		<title>Third year simulation experiment/Dynamical properties and the diffusion coefficient</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Dynamical_properties_and_the_diffusion_coefficient&amp;diff=734578"/>
		<updated>2018-10-08T10:07:41Z</updated>

		<summary type="html">&lt;p&gt;Otr12: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the seventh (and final) section of the third year simulation experiment. You can return to the previous page, [[Third year simulation experiment/Structural properties and the radial distribution function|Structural properties and the radial distribution function]], or go back to the [[Third_year_simulation_experiment|Introduction]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this final section, we are going to make measurements to get some idea of how much the atoms in our simulation move around. We can characterise this by the diffusion coefficient, which we will calculate by two different approaches.&lt;br /&gt;
&lt;br /&gt;
==Simulations in this Section==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 10: In the D subfolder, there is a file &#039;&#039;liq.in&#039;&#039; that will run a simulation at specified density and temperature to calculate the mean squared displacement and velocity autocorrelation function of your system. Run one of these simulations for a vapour, liquid, and solid. You have also been given some simulated data from much larger systems (approximately one million atoms). You will need these files later. make a plot for each of your simulations (solid, liquid, and gas), showing the mean squared displacement (the &amp;quot;total&amp;quot; MSD) as a function of timestep. Are these as you would expect? Estimate &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; in each case. Be careful with the units! Repeat this procedure for the MSD data that you were given from the one million atom simulations. Compare your data to the million atoms. [10 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Mean Squared Displacement==&lt;br /&gt;
The easiest way to measure &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is by exploiting its connection to the [http://en.wikipedia.org/wiki/Mean_squared_displacement mean squared displacement].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;D = \frac{1}{6}\frac{\partial\left\langle r^2\left(t\right)\right\rangle}{\partial t}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that in general, we expect the simulation to take a little time to establish this linear behaviour!&lt;br /&gt;
&lt;br /&gt;
The simulations that you have already performed have recorded the MSD for you. Download the &amp;quot;optional output-2&amp;quot; file for each of the simulations, and give it a suitable name. These are text files which contain 5 columns: the first is the number of timesteps since the start of the simulation (*not* the elapsed time in reduced units), the next three contain the mean squared displacement for each of the Cartesian directions (x,y,z), and the final column contains the &amp;quot;total&amp;quot; mean squared displacement.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the seventh (and final) section of the third year simulation experiment. You can return to the previous page, [[Third year simulation experiment/Structural properties and the radial distribution function|Structural properties and the radial distribution function]], or go back to the [[Third_year_simulation_experiment|Introduction]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Structural_properties_and_the_radial_distribution_function&amp;diff=734577</id>
		<title>Third year simulation experiment/Structural properties and the radial distribution function</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Structural_properties_and_the_radial_distribution_function&amp;diff=734577"/>
		<updated>2018-10-08T10:07:30Z</updated>

		<summary type="html">&lt;p&gt;Otr12: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the sixth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Running_simulations_under_specific_conditions|Running simulations under specific conditions]], or jump ahead to the next section, [[Third year simulation experiment/Dynamical properties and the diffusion coefficient|Dynamical properties and the diffusion coefficient]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
We can characterise the structure of systems that we simulate using [http://en.wikipedia.org/wiki/Radial_distribution_function radial distribution functions], which we denote &amp;lt;math&amp;gt;g(r)&amp;lt;/math&amp;gt;. Calculating the RDF for a simulation is very useful &amp;amp;mdash; it can tell us the distances from an atom at which we will find it&#039;s nearest neighbour, second nearest neighbour, and so on; it is also a quantity that can be accessed experimentally, and so provides a good check that the forcefield in our simulation is correctly reproducing the structural features.&lt;br /&gt;
&lt;br /&gt;
In this section, you are going to use VMD to calculate the radial distribution function for the solid, liquid, and vapour phases of the Lennard-Jones fluid.&lt;br /&gt;
&lt;br /&gt;
===Calculating &amp;lt;math&amp;gt;g(r)&amp;lt;/math&amp;gt; in VMD===&lt;br /&gt;
&lt;br /&gt;
# Start VMD as before and load the trajectory that you want to analyse.&lt;br /&gt;
# Select &#039;&#039;&#039;Extensions&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Analysis&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Radial Pair Distribution Function g(r)&#039;&#039;&#039;&lt;br /&gt;
# Set &#039;&#039;&#039;Selection 1&#039;&#039;&#039; to &#039;&#039;&#039;all&#039;&#039;&#039; and &#039;&#039;&#039;Selection 2&#039;&#039;&#039; to &#039;&#039;&#039;all&#039;&#039;&#039;&lt;br /&gt;
# Change &#039;&#039;&#039;delta r&#039;&#039;&#039; to &#039;&#039;&#039;0.05&#039;&#039;&#039; &amp;amp;mdash; this is the distance between points in the generated RDF.&lt;br /&gt;
# Ensure that &#039;&#039;&#039;Use PBC&#039;&#039;&#039;, &#039;&#039;&#039;Display g(r)&#039;&#039;&#039;, &#039;&#039;&#039;Display Int(g(r))&#039;&#039;&#039;, and &#039;&#039;&#039;Save to File&#039;&#039;&#039; are checked&lt;br /&gt;
# Click &#039;&#039;&#039;Compute g(r)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After a short pause while it performs the calculation, VMD will display both the RDF, and its running integral. You will then be prompted to save this data &amp;amp;mdash; choose a location for the file that you will be able to find easily later.&lt;br /&gt;
&lt;br /&gt;
===Simulations in this section===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;RDF&#039;&#039;&#039; subfolder contains an example input script that you can use to record an atomic trajectory to generate RDFs for the solid, liquid, and vapour phase Lennard Jones systems. Make three copies of that script (one for each phase), and modify the density and temperature parameters to give the phase that you want (a phase diagram for the Lennard-Jones system can be found [http://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151 here]). &#039;&#039;&#039;Note&#039;&#039;&#039;: when simulating the solid, you will need to change the lattice type in the lattice command to fcc, rather than sc.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 9: perform simulations of the Lennard-Jones system in the three phases. When each is complete, download the trajectory and calculate &amp;lt;math&amp;gt;g(r)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\int g(r)\mathrm{d}r&amp;lt;/math&amp;gt;. Plot the RDFs for the three systems on the same axes, and attach a copy to your report. Discuss qualitatively the differences between the three RDFs, and what this tells you about the structure of the system in each phase. In the solid case, illustrate which lattice sites the first three peaks correspond to. What is the lattice spacing? What is the coordination number for each of the first three peaks? [15 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the sixth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Running simulations under specific conditions|Running simulations under specific conditions]], or jump ahead to the next section, [[Third year simulation experiment/Dynamical properties and the diffusion coefficient|Dynamical properties and the diffusion coefficient]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Running_simulations_under_specific_conditions&amp;diff=734576</id>
		<title>Third year simulation experiment/Running simulations under specific conditions</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Running_simulations_under_specific_conditions&amp;diff=734576"/>
		<updated>2018-10-08T10:06:49Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Thermostats and Barostats - controlling the thermodynamic properties */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the fourth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Equilibration|Equilibration]], or jump ahead to the next section, [[Third_year_simulation_experiment/Structural_properties_and_the_radial_distribution_function| Structural Properties and the Radial Distribution Functions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;THE FILES THAT YOU NEED FOR THIS SECTION ARE FOUND IN THE &amp;quot;NpT&amp;quot; SUBFOLDER.&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Changing Ensemble==&lt;br /&gt;
&lt;br /&gt;
So far, we have been able to do some simulations in which the number of particles and the volume of the simulation cell are held constant. The energy is also constant (within a certain degree of error, which is introduced by the approximations that we make to do the simulation). If the simulation is a working properly, then the pressure and temperature of the system should also reach a constant &#039;&#039;average&#039;&#039; value (although there will again be fluctuations). In the statistical thermodynamics lectures, you met the concept of ensembles, which are used in statistical mechanics to represent different sorts of experimental conditions. The simulations we have done so far are described by the &#039;&#039;microcanonical&#039;&#039;, or NVE ensemble (the letters represent those thermodynamic quantities which are constant).&lt;br /&gt;
&lt;br /&gt;
As chemists, we often want to understand what happens under particular experimental conditions &amp;amp;mdash; at 298K under 1 atmosphere of pressure, for example. These sorts of conditions are described by different ensembles in statistical mechanics, such as the NVT (&#039;&#039;canonical&#039;&#039;) or NpT (&#039;&#039;isobaric-isothermal&#039;&#039;) ensembles.&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to modify our simulations from the previous section to run under NpT conditions, and sketch an equation of state for our model fluid at atmospheric pressure.&lt;br /&gt;
&lt;br /&gt;
==Temperature and Pressure Control==&lt;br /&gt;
&lt;br /&gt;
The file npt.in can be used to perform a constant temperature/pressure simulation of our model fluid. It starts by melting a simple cubic crystal, just as before, so much of this file will look familiar to you. You will notice a new section near the top, however, called &#039;&#039;&#039;### SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&#039;&#039;&#039;. It contains three &#039;&#039;variables&#039;&#039; &amp;amp;mdash; these are used by the script later on to define the desired temperature, pressure, and timestep. The ellipses need to be replaced by the actual temperature, pressure and timestep that you want to use, so&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
variable T equal 0.5&lt;br /&gt;
variable p equal 1.0&lt;br /&gt;
variable timestep equal 0.75&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
would run a simulation at &amp;lt;math&amp;gt;T=0.5,\  p=1.0,\  \delta t=0.75&amp;lt;/math&amp;gt;. You should remember from the [[Third_year_simulation_experiment/Equilibration|Equilibration]] section that this is a poor choice of timestep!&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 8: Choose 5 temperatures (above the critical temperature &amp;lt;math&amp;gt;T^* = 1.5&amp;lt;/math&amp;gt;), and two pressures (you can get a good idea of what a reasonable pressure is in Lennard-Jones units by looking at the average pressure of your simulations from the last section). This gives ten phase points &amp;amp;mdash; five temperatures at each pressure. Create 10 copies of npt.in, and modify each to run a simulation at one of your chosen &amp;lt;math&amp;gt;\left(p, T\right)&amp;lt;/math&amp;gt; points. You should be able to use the results of the previous section to choose a timestep. Submit these ten jobs to the HPC portal. When your simulations have finished, download the log files as before. At the end of the log file, LAMMPS will output the values and errors for the pressure, temperature, and density &amp;lt;math&amp;gt;\left(\frac{N}{V}\right)&amp;lt;/math&amp;gt;. Use software of your choice to plot the density as a function of temperature for both of the pressures that you simulated.  Your graph(s) should include error bars in both the x and y directions. You should also include a line corresponding to the density predicted by the ideal gas law at that pressure. Is your simulated density lower or higher? Justify this. Does the discrepancy increase or decrease with pressure? [15 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Thermostats and Barostats - controlling the thermodynamic properties===&lt;br /&gt;
The statistical thermodynamics lectures will have introduced you to the &#039;&#039;equipartition theorem&#039;&#039;, which states that, on average, every degree of freedom in a system at equilibrium will have &amp;lt;math&amp;gt;\frac{1}{2}k_B T&amp;lt;/math&amp;gt; of energy. In our system with &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms, each with 3 degrees of freedom, we can write&lt;br /&gt;
&amp;lt;math&amp;gt;E_K = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i v_i^2 = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end of every timestep, we use the left hand side of this equation to calculate the kinetic energy, then divide by &amp;lt;math&amp;gt;\frac{3}{2}Nk_B&amp;lt;/math&amp;gt; to get the &#039;&#039;instantaneous&#039;&#039; temperature &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. In general, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; will fluctuate, and will be different to our &#039;&#039;target&#039;&#039; temperature, &amp;lt;math&amp;gt;\mathfrak{T}&amp;lt;/math&amp;gt; (this is whatever value we specify in the input script). We can change the temperature by multiplying every velocity by a constant factor, &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* If &amp;lt;math&amp;gt; T &amp;gt; \mathfrak{T} &amp;lt;/math&amp;gt;, then the kinetic energy of the system is too high, and we need to reduce it. &amp;lt;math&amp;gt;\gamma &amp;lt; 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* If &amp;lt;math&amp;gt; T &amp;lt; \mathfrak{T} &amp;lt;/math&amp;gt;, then the kinetic energy of the system is too low, and we need to increase it. &amp;lt;math&amp;gt;\gamma &amp;gt; 1&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We need to choose a scaling parameter &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt; so that the temperature is correct &amp;lt;math&amp;gt;T = \mathfrak{T}&amp;lt;/math&amp;gt; if we multiply every velocity &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;. We can write two equations:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i v_i^2 = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i \left(\gamma v_i\right)^2 = \frac{3}{2} N k_B \mathfrak{T}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By combining these equations, one can see that &amp;lt;math&amp;gt; \gamma = \sqrt{\frac{\mathfrak{T}}{T}} &amp;lt;/math&amp;gt; (satisfy yourself that this is true!). A target value of &amp;lt;math&amp;gt; \gamma &amp;lt;/math&amp;gt; of 1 is required and thus, dependent on whether it&#039;s larger or smaller than 1 the simulation can target the desired temperature.&lt;br /&gt;
&lt;br /&gt;
Controlling the pressure is a little more involved, but the principle is largely the same: at each timestep, the pressure of the system is calculated; if the pressure is too high, then the simulation box is made a little larger, while if the pressure is too low the box is made smaller. Simulations in which the pressure is controlled are thus in the NpT ensemble &amp;amp;mdash; the volume of the simulation box is not constant!&lt;br /&gt;
&lt;br /&gt;
===Examining the Input Script===&lt;br /&gt;
&lt;br /&gt;
Open one of your input scripts (it doesn&#039;t matter which), and look at the section &#039;&#039;&#039;### BRING SYSTEM TO REQUIRED STATE ###&#039;&#039;&#039;. The line &amp;lt;pre&amp;gt;fix npt all npt temp ${T} ${T} ${tdamp} iso ${p} ${p} ${pdamp}&amp;lt;/pre&amp;gt; is the one responsible for switching on the temperature and pressure control. LAMMPS actually allows us to heat or cool the system over the course of a simulation, if we want to &amp;amp;mdash; this is the reason that the temperature appears twice in this line. The first ${T} is the desired starting temperature, and the second is the desired temperature at the end of the simulation. We want a constant average temperature, so we specify the same value twice. The same goes for the pressure.&lt;br /&gt;
&lt;br /&gt;
Now look at the lines near the end of the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### MEASURE SYSTEM STATE ###&lt;br /&gt;
thermo_style custom step etotal temp press density&lt;br /&gt;
variable dens equal density&lt;br /&gt;
variable dens2 equal density*density&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
variable press equal press&lt;br /&gt;
variable press2 equal press*press&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_dens v_temp v_press v_dens2 v_temp2 v_press2&lt;br /&gt;
run 100000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command, &#039;&#039;thermo_style&#039;&#039;, controls which thermodynamic properties are recorded, as before. The next lines are used to measure &#039;&#039;average&#039;&#039; thermodynamic properties for the system. To draw our equations of state, we need to know the average temperature, pressure, and density, and the statistical errors in those quantities. The six variable lines link those quantities (and their squared values, needed for the errors), to variable names that we can use in the averaging command, which is the line starting &#039;&#039;fix aves...&#039;&#039;. This command takes a number of input values and averages them every so many timesteps. Exactly how often this happens depends in the values of the three numbers which follow &#039;&#039;ave/time&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the fourth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Equilibration|Equilibration]], or jump ahead to the next section, [[Third year simulation experiment/Structural properties and the radial distribution function|Structural properties and the radial distribution function]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Running_simulations_under_specific_conditions&amp;diff=734575</id>
		<title>Third year simulation experiment/Running simulations under specific conditions</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Running_simulations_under_specific_conditions&amp;diff=734575"/>
		<updated>2018-10-08T10:05:33Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Thermostats and Barostats - controlling the thermodynamic properties */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the fourth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Equilibration|Equilibration]], or jump ahead to the next section, [[Third_year_simulation_experiment/Structural_properties_and_the_radial_distribution_function| Structural Properties and the Radial Distribution Functions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;THE FILES THAT YOU NEED FOR THIS SECTION ARE FOUND IN THE &amp;quot;NpT&amp;quot; SUBFOLDER.&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Changing Ensemble==&lt;br /&gt;
&lt;br /&gt;
So far, we have been able to do some simulations in which the number of particles and the volume of the simulation cell are held constant. The energy is also constant (within a certain degree of error, which is introduced by the approximations that we make to do the simulation). If the simulation is a working properly, then the pressure and temperature of the system should also reach a constant &#039;&#039;average&#039;&#039; value (although there will again be fluctuations). In the statistical thermodynamics lectures, you met the concept of ensembles, which are used in statistical mechanics to represent different sorts of experimental conditions. The simulations we have done so far are described by the &#039;&#039;microcanonical&#039;&#039;, or NVE ensemble (the letters represent those thermodynamic quantities which are constant).&lt;br /&gt;
&lt;br /&gt;
As chemists, we often want to understand what happens under particular experimental conditions &amp;amp;mdash; at 298K under 1 atmosphere of pressure, for example. These sorts of conditions are described by different ensembles in statistical mechanics, such as the NVT (&#039;&#039;canonical&#039;&#039;) or NpT (&#039;&#039;isobaric-isothermal&#039;&#039;) ensembles.&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to modify our simulations from the previous section to run under NpT conditions, and sketch an equation of state for our model fluid at atmospheric pressure.&lt;br /&gt;
&lt;br /&gt;
==Temperature and Pressure Control==&lt;br /&gt;
&lt;br /&gt;
The file npt.in can be used to perform a constant temperature/pressure simulation of our model fluid. It starts by melting a simple cubic crystal, just as before, so much of this file will look familiar to you. You will notice a new section near the top, however, called &#039;&#039;&#039;### SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&#039;&#039;&#039;. It contains three &#039;&#039;variables&#039;&#039; &amp;amp;mdash; these are used by the script later on to define the desired temperature, pressure, and timestep. The ellipses need to be replaced by the actual temperature, pressure and timestep that you want to use, so&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
variable T equal 0.5&lt;br /&gt;
variable p equal 1.0&lt;br /&gt;
variable timestep equal 0.75&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
would run a simulation at &amp;lt;math&amp;gt;T=0.5,\  p=1.0,\  \delta t=0.75&amp;lt;/math&amp;gt;. You should remember from the [[Third_year_simulation_experiment/Equilibration|Equilibration]] section that this is a poor choice of timestep!&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 8: Choose 5 temperatures (above the critical temperature &amp;lt;math&amp;gt;T^* = 1.5&amp;lt;/math&amp;gt;), and two pressures (you can get a good idea of what a reasonable pressure is in Lennard-Jones units by looking at the average pressure of your simulations from the last section). This gives ten phase points &amp;amp;mdash; five temperatures at each pressure. Create 10 copies of npt.in, and modify each to run a simulation at one of your chosen &amp;lt;math&amp;gt;\left(p, T\right)&amp;lt;/math&amp;gt; points. You should be able to use the results of the previous section to choose a timestep. Submit these ten jobs to the HPC portal. When your simulations have finished, download the log files as before. At the end of the log file, LAMMPS will output the values and errors for the pressure, temperature, and density &amp;lt;math&amp;gt;\left(\frac{N}{V}\right)&amp;lt;/math&amp;gt;. Use software of your choice to plot the density as a function of temperature for both of the pressures that you simulated.  Your graph(s) should include error bars in both the x and y directions. You should also include a line corresponding to the density predicted by the ideal gas law at that pressure. Is your simulated density lower or higher? Justify this. Does the discrepancy increase or decrease with pressure? [15 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Thermostats and Barostats - controlling the thermodynamic properties===&lt;br /&gt;
The statistical thermodynamics lectures will have introduced you to the &#039;&#039;equipartition theorem&#039;&#039;, which states that, on average, every degree of freedom in a system at equilibrium will have &amp;lt;math&amp;gt;\frac{1}{2}k_B T&amp;lt;/math&amp;gt; of energy. In our system with &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms, each with 3 degrees of freedom, we can write&lt;br /&gt;
&amp;lt;math&amp;gt;E_K = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i v_i^2 = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end of every timestep, we use the left hand side of this equation to calculate the kinetic energy, then divide by &amp;lt;math&amp;gt;\frac{3}{2}Nk_B&amp;lt;/math&amp;gt; to get the &#039;&#039;instantaneous&#039;&#039; temperature &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. In general, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; will fluctuate, and will be different to our &#039;&#039;target&#039;&#039; temperature, &amp;lt;math&amp;gt;\mathfrak{T}&amp;lt;/math&amp;gt; (this is whatever value we specify in the input script). We can change the temperature by multiplying every velocity by a constant factor, &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* If &amp;lt;math&amp;gt; T &amp;gt; \mathfrak{T} &amp;lt;/math&amp;gt;, then the kinetic energy of the system is too high, and we need to reduce it. &amp;lt;math&amp;gt;\gamma &amp;lt; 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* If &amp;lt;math&amp;gt; T &amp;lt; \mathfrak{T} &amp;lt;/math&amp;gt;, then the kinetic energy of the system is too low, and we need to increase it. &amp;lt;math&amp;gt;\gamma &amp;gt; 1&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We need to choose a scaling parameter &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt; so that the temperature is correct &amp;lt;math&amp;gt;T = \mathfrak{T}&amp;lt;/math&amp;gt; if we multiply every velocity &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;. We can write two equations:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i v_i^2 = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i \left(\gamma v_i\right)^2 = \frac{3}{2} N k_B \mathfrak{T}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By combining these equations, one can see that &amp;lt;math&amp;gt; \gamma = \sqrt{\frac{\mathfrak{T}}{T}} &amp;lt;/math&amp;gt; (satisfy yourself that this is true!). Therefore &lt;br /&gt;
&lt;br /&gt;
Controlling the pressure is a little more involved, but the principle is largely the same: at each timestep, the pressure of the system is calculated; if the pressure is too high, then the simulation box is made a little larger, while if the pressure is too low the box is made smaller. Simulations in which the pressure is controlled are thus in the NpT ensemble &amp;amp;mdash; the volume of the simulation box is not constant!&lt;br /&gt;
&lt;br /&gt;
===Examining the Input Script===&lt;br /&gt;
&lt;br /&gt;
Open one of your input scripts (it doesn&#039;t matter which), and look at the section &#039;&#039;&#039;### BRING SYSTEM TO REQUIRED STATE ###&#039;&#039;&#039;. The line &amp;lt;pre&amp;gt;fix npt all npt temp ${T} ${T} ${tdamp} iso ${p} ${p} ${pdamp}&amp;lt;/pre&amp;gt; is the one responsible for switching on the temperature and pressure control. LAMMPS actually allows us to heat or cool the system over the course of a simulation, if we want to &amp;amp;mdash; this is the reason that the temperature appears twice in this line. The first ${T} is the desired starting temperature, and the second is the desired temperature at the end of the simulation. We want a constant average temperature, so we specify the same value twice. The same goes for the pressure.&lt;br /&gt;
&lt;br /&gt;
Now look at the lines near the end of the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### MEASURE SYSTEM STATE ###&lt;br /&gt;
thermo_style custom step etotal temp press density&lt;br /&gt;
variable dens equal density&lt;br /&gt;
variable dens2 equal density*density&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
variable press equal press&lt;br /&gt;
variable press2 equal press*press&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_dens v_temp v_press v_dens2 v_temp2 v_press2&lt;br /&gt;
run 100000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command, &#039;&#039;thermo_style&#039;&#039;, controls which thermodynamic properties are recorded, as before. The next lines are used to measure &#039;&#039;average&#039;&#039; thermodynamic properties for the system. To draw our equations of state, we need to know the average temperature, pressure, and density, and the statistical errors in those quantities. The six variable lines link those quantities (and their squared values, needed for the errors), to variable names that we can use in the averaging command, which is the line starting &#039;&#039;fix aves...&#039;&#039;. This command takes a number of input values and averages them every so many timesteps. Exactly how often this happens depends in the values of the three numbers which follow &#039;&#039;ave/time&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the fourth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Equilibration|Equilibration]], or jump ahead to the next section, [[Third year simulation experiment/Structural properties and the radial distribution function|Structural properties and the radial distribution function]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Running_simulations_under_specific_conditions&amp;diff=734574</id>
		<title>Third year simulation experiment/Running simulations under specific conditions</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Running_simulations_under_specific_conditions&amp;diff=734574"/>
		<updated>2018-10-08T10:05:04Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Thermostats and Barostats - controlling the thermodynamic properties */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the fourth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Equilibration|Equilibration]], or jump ahead to the next section, [[Third_year_simulation_experiment/Structural_properties_and_the_radial_distribution_function| Structural Properties and the Radial Distribution Functions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;THE FILES THAT YOU NEED FOR THIS SECTION ARE FOUND IN THE &amp;quot;NpT&amp;quot; SUBFOLDER.&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Changing Ensemble==&lt;br /&gt;
&lt;br /&gt;
So far, we have been able to do some simulations in which the number of particles and the volume of the simulation cell are held constant. The energy is also constant (within a certain degree of error, which is introduced by the approximations that we make to do the simulation). If the simulation is a working properly, then the pressure and temperature of the system should also reach a constant &#039;&#039;average&#039;&#039; value (although there will again be fluctuations). In the statistical thermodynamics lectures, you met the concept of ensembles, which are used in statistical mechanics to represent different sorts of experimental conditions. The simulations we have done so far are described by the &#039;&#039;microcanonical&#039;&#039;, or NVE ensemble (the letters represent those thermodynamic quantities which are constant).&lt;br /&gt;
&lt;br /&gt;
As chemists, we often want to understand what happens under particular experimental conditions &amp;amp;mdash; at 298K under 1 atmosphere of pressure, for example. These sorts of conditions are described by different ensembles in statistical mechanics, such as the NVT (&#039;&#039;canonical&#039;&#039;) or NpT (&#039;&#039;isobaric-isothermal&#039;&#039;) ensembles.&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to modify our simulations from the previous section to run under NpT conditions, and sketch an equation of state for our model fluid at atmospheric pressure.&lt;br /&gt;
&lt;br /&gt;
==Temperature and Pressure Control==&lt;br /&gt;
&lt;br /&gt;
The file npt.in can be used to perform a constant temperature/pressure simulation of our model fluid. It starts by melting a simple cubic crystal, just as before, so much of this file will look familiar to you. You will notice a new section near the top, however, called &#039;&#039;&#039;### SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&#039;&#039;&#039;. It contains three &#039;&#039;variables&#039;&#039; &amp;amp;mdash; these are used by the script later on to define the desired temperature, pressure, and timestep. The ellipses need to be replaced by the actual temperature, pressure and timestep that you want to use, so&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
variable T equal 0.5&lt;br /&gt;
variable p equal 1.0&lt;br /&gt;
variable timestep equal 0.75&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
would run a simulation at &amp;lt;math&amp;gt;T=0.5,\  p=1.0,\  \delta t=0.75&amp;lt;/math&amp;gt;. You should remember from the [[Third_year_simulation_experiment/Equilibration|Equilibration]] section that this is a poor choice of timestep!&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 8: Choose 5 temperatures (above the critical temperature &amp;lt;math&amp;gt;T^* = 1.5&amp;lt;/math&amp;gt;), and two pressures (you can get a good idea of what a reasonable pressure is in Lennard-Jones units by looking at the average pressure of your simulations from the last section). This gives ten phase points &amp;amp;mdash; five temperatures at each pressure. Create 10 copies of npt.in, and modify each to run a simulation at one of your chosen &amp;lt;math&amp;gt;\left(p, T\right)&amp;lt;/math&amp;gt; points. You should be able to use the results of the previous section to choose a timestep. Submit these ten jobs to the HPC portal. When your simulations have finished, download the log files as before. At the end of the log file, LAMMPS will output the values and errors for the pressure, temperature, and density &amp;lt;math&amp;gt;\left(\frac{N}{V}\right)&amp;lt;/math&amp;gt;. Use software of your choice to plot the density as a function of temperature for both of the pressures that you simulated.  Your graph(s) should include error bars in both the x and y directions. You should also include a line corresponding to the density predicted by the ideal gas law at that pressure. Is your simulated density lower or higher? Justify this. Does the discrepancy increase or decrease with pressure? [15 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Thermostats and Barostats - controlling the thermodynamic properties===&lt;br /&gt;
The statistical thermodynamics lectures will have introduced you to the &#039;&#039;equipartition theorem&#039;&#039;, which states that, on average, every degree of freedom in a system at equilibrium will have &amp;lt;math&amp;gt;\frac{1}{2}k_B T&amp;lt;/math&amp;gt; of energy. In our system with &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms, each with 3 degrees of freedom, we can write&lt;br /&gt;
&amp;lt;math&amp;gt;E_K = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i v_i^2 = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end of every timestep, we use the left hand side of this equation to calculate the kinetic energy, then divide by &amp;lt;math&amp;gt;\frac{3}{2}Nk_B&amp;lt;/math&amp;gt; to get the &#039;&#039;instantaneous&#039;&#039; temperature &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. In general, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; will fluctuate, and will be different to our &#039;&#039;target&#039;&#039; temperature, &amp;lt;math&amp;gt;\mathfrak{T}&amp;lt;/math&amp;gt; (this is whatever value we specify in the input script). We can change the temperature by multiplying every velocity by a constant factor, &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* If &amp;lt;math&amp;gt; T &amp;gt; \mathfrak{T} &amp;lt;/math&amp;gt;, then the kinetic energy of the system is too high, and we need to reduce it. &amp;lt;math&amp;gt;\gamma &amp;lt; 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* If &amp;lt;math&amp;gt; T &amp;lt; \mathfrak{T} &amp;lt;/math&amp;gt;, then the kinetic energy of the system is too low, and we need to increase it. &amp;lt;math&amp;gt;\gamma &amp;gt; 1&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We need to choose a scaling parameter &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt; so that the temperature is correct &amp;lt;math&amp;gt;T = \mathfrak{T}&amp;lt;/math&amp;gt; if we multiply every velocity &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;. We can write two equations:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i v_i^2 = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i \left(\gamma v_i\right)^2 = \frac{3}{2} N k_B \mathfrak{T}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By combining these equations, one can see that &amp;lt;math&amp;gt; \gamma = \sqrt{\frac{\mathfrak{T}}{T}} &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Controlling the pressure is a little more involved, but the principle is largely the same: at each timestep, the pressure of the system is calculated; if the pressure is too high, then the simulation box is made a little larger, while if the pressure is too low the box is made smaller. Simulations in which the pressure is controlled are thus in the NpT ensemble &amp;amp;mdash; the volume of the simulation box is not constant!&lt;br /&gt;
&lt;br /&gt;
===Examining the Input Script===&lt;br /&gt;
&lt;br /&gt;
Open one of your input scripts (it doesn&#039;t matter which), and look at the section &#039;&#039;&#039;### BRING SYSTEM TO REQUIRED STATE ###&#039;&#039;&#039;. The line &amp;lt;pre&amp;gt;fix npt all npt temp ${T} ${T} ${tdamp} iso ${p} ${p} ${pdamp}&amp;lt;/pre&amp;gt; is the one responsible for switching on the temperature and pressure control. LAMMPS actually allows us to heat or cool the system over the course of a simulation, if we want to &amp;amp;mdash; this is the reason that the temperature appears twice in this line. The first ${T} is the desired starting temperature, and the second is the desired temperature at the end of the simulation. We want a constant average temperature, so we specify the same value twice. The same goes for the pressure.&lt;br /&gt;
&lt;br /&gt;
Now look at the lines near the end of the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### MEASURE SYSTEM STATE ###&lt;br /&gt;
thermo_style custom step etotal temp press density&lt;br /&gt;
variable dens equal density&lt;br /&gt;
variable dens2 equal density*density&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
variable press equal press&lt;br /&gt;
variable press2 equal press*press&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_dens v_temp v_press v_dens2 v_temp2 v_press2&lt;br /&gt;
run 100000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command, &#039;&#039;thermo_style&#039;&#039;, controls which thermodynamic properties are recorded, as before. The next lines are used to measure &#039;&#039;average&#039;&#039; thermodynamic properties for the system. To draw our equations of state, we need to know the average temperature, pressure, and density, and the statistical errors in those quantities. The six variable lines link those quantities (and their squared values, needed for the errors), to variable names that we can use in the averaging command, which is the line starting &#039;&#039;fix aves...&#039;&#039;. This command takes a number of input values and averages them every so many timesteps. Exactly how often this happens depends in the values of the three numbers which follow &#039;&#039;ave/time&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the fourth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Equilibration|Equilibration]], or jump ahead to the next section, [[Third year simulation experiment/Structural properties and the radial distribution function|Structural properties and the radial distribution function]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Running_simulations_under_specific_conditions&amp;diff=734573</id>
		<title>Third year simulation experiment/Running simulations under specific conditions</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Running_simulations_under_specific_conditions&amp;diff=734573"/>
		<updated>2018-10-08T10:03:18Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Thermostats and Barostats - controlling the thermodynamic properties */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the fourth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Equilibration|Equilibration]], or jump ahead to the next section, [[Third_year_simulation_experiment/Structural_properties_and_the_radial_distribution_function| Structural Properties and the Radial Distribution Functions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;THE FILES THAT YOU NEED FOR THIS SECTION ARE FOUND IN THE &amp;quot;NpT&amp;quot; SUBFOLDER.&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Changing Ensemble==&lt;br /&gt;
&lt;br /&gt;
So far, we have been able to do some simulations in which the number of particles and the volume of the simulation cell are held constant. The energy is also constant (within a certain degree of error, which is introduced by the approximations that we make to do the simulation). If the simulation is a working properly, then the pressure and temperature of the system should also reach a constant &#039;&#039;average&#039;&#039; value (although there will again be fluctuations). In the statistical thermodynamics lectures, you met the concept of ensembles, which are used in statistical mechanics to represent different sorts of experimental conditions. The simulations we have done so far are described by the &#039;&#039;microcanonical&#039;&#039;, or NVE ensemble (the letters represent those thermodynamic quantities which are constant).&lt;br /&gt;
&lt;br /&gt;
As chemists, we often want to understand what happens under particular experimental conditions &amp;amp;mdash; at 298K under 1 atmosphere of pressure, for example. These sorts of conditions are described by different ensembles in statistical mechanics, such as the NVT (&#039;&#039;canonical&#039;&#039;) or NpT (&#039;&#039;isobaric-isothermal&#039;&#039;) ensembles.&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to modify our simulations from the previous section to run under NpT conditions, and sketch an equation of state for our model fluid at atmospheric pressure.&lt;br /&gt;
&lt;br /&gt;
==Temperature and Pressure Control==&lt;br /&gt;
&lt;br /&gt;
The file npt.in can be used to perform a constant temperature/pressure simulation of our model fluid. It starts by melting a simple cubic crystal, just as before, so much of this file will look familiar to you. You will notice a new section near the top, however, called &#039;&#039;&#039;### SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&#039;&#039;&#039;. It contains three &#039;&#039;variables&#039;&#039; &amp;amp;mdash; these are used by the script later on to define the desired temperature, pressure, and timestep. The ellipses need to be replaced by the actual temperature, pressure and timestep that you want to use, so&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
variable T equal 0.5&lt;br /&gt;
variable p equal 1.0&lt;br /&gt;
variable timestep equal 0.75&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
would run a simulation at &amp;lt;math&amp;gt;T=0.5,\  p=1.0,\  \delta t=0.75&amp;lt;/math&amp;gt;. You should remember from the [[Third_year_simulation_experiment/Equilibration|Equilibration]] section that this is a poor choice of timestep!&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 8: Choose 5 temperatures (above the critical temperature &amp;lt;math&amp;gt;T^* = 1.5&amp;lt;/math&amp;gt;), and two pressures (you can get a good idea of what a reasonable pressure is in Lennard-Jones units by looking at the average pressure of your simulations from the last section). This gives ten phase points &amp;amp;mdash; five temperatures at each pressure. Create 10 copies of npt.in, and modify each to run a simulation at one of your chosen &amp;lt;math&amp;gt;\left(p, T\right)&amp;lt;/math&amp;gt; points. You should be able to use the results of the previous section to choose a timestep. Submit these ten jobs to the HPC portal. When your simulations have finished, download the log files as before. At the end of the log file, LAMMPS will output the values and errors for the pressure, temperature, and density &amp;lt;math&amp;gt;\left(\frac{N}{V}\right)&amp;lt;/math&amp;gt;. Use software of your choice to plot the density as a function of temperature for both of the pressures that you simulated.  Your graph(s) should include error bars in both the x and y directions. You should also include a line corresponding to the density predicted by the ideal gas law at that pressure. Is your simulated density lower or higher? Justify this. Does the discrepancy increase or decrease with pressure? [15 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Thermostats and Barostats - controlling the thermodynamic properties===&lt;br /&gt;
The statistical thermodynamics lectures will have introduced you to the &#039;&#039;equipartition theorem&#039;&#039;, which states that, on average, every degree of freedom in a system at equilibrium will have &amp;lt;math&amp;gt;\frac{1}{2}k_B T&amp;lt;/math&amp;gt; of energy. In our system with &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms, each with 3 degrees of freedom, we can write&lt;br /&gt;
&amp;lt;math&amp;gt;E_K = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i v_i^2 = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end of every timestep, we use the left hand side of this equation to calculate the kinetic energy, then divide by &amp;lt;math&amp;gt;\frac{3}{2}Nk_B&amp;lt;/math&amp;gt; to get the &#039;&#039;instantaneous&#039;&#039; temperature &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. In general, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; will fluctuate, and will be different to our &#039;&#039;target&#039;&#039; temperature, &amp;lt;math&amp;gt;\mathfrak{T}&amp;lt;/math&amp;gt; (this is whatever value we specify in the input script). We can change the temperature by multiplying every velocity by a constant factor, &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* If &amp;lt;math&amp;gt; T &amp;gt; \mathfrak{T} &amp;lt;/math&amp;gt;, then the kinetic energy of the system is too high, and we need to reduce it. &amp;lt;math&amp;gt;\gamma &amp;lt; 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* If &amp;lt;math&amp;gt; T &amp;lt; \mathfrak{T} &amp;lt;/math&amp;gt;, then the kinetic energy of the system is too low, and we need to increase it. &amp;lt;math&amp;gt;\gamma &amp;gt; 1&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We need to choose a scaling parameter &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt; so that the temperature is correct &amp;lt;math&amp;gt;T = \mathfrak{T}&amp;lt;/math&amp;gt; if we multiply every velocity &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;. We can write two equations:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i v_i^2 = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i \left(\gamma v_i\right)^2 = \frac{3}{2} N k_B \mathfrak{T}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By combining these equations, one can see that &amp;lt;math&amp;gt; \gamma = &lt;br /&gt;
&lt;br /&gt;
Controlling the pressure is a little more involved, but the principle is largely the same: at each timestep, the pressure of the system is calculated; if the pressure is too high, then the simulation box is made a little larger, while if the pressure is too low the box is made smaller. Simulations in which the pressure is controlled are thus in the NpT ensemble &amp;amp;mdash; the volume of the simulation box is not constant!&lt;br /&gt;
&lt;br /&gt;
===Examining the Input Script===&lt;br /&gt;
&lt;br /&gt;
Open one of your input scripts (it doesn&#039;t matter which), and look at the section &#039;&#039;&#039;### BRING SYSTEM TO REQUIRED STATE ###&#039;&#039;&#039;. The line &amp;lt;pre&amp;gt;fix npt all npt temp ${T} ${T} ${tdamp} iso ${p} ${p} ${pdamp}&amp;lt;/pre&amp;gt; is the one responsible for switching on the temperature and pressure control. LAMMPS actually allows us to heat or cool the system over the course of a simulation, if we want to &amp;amp;mdash; this is the reason that the temperature appears twice in this line. The first ${T} is the desired starting temperature, and the second is the desired temperature at the end of the simulation. We want a constant average temperature, so we specify the same value twice. The same goes for the pressure.&lt;br /&gt;
&lt;br /&gt;
Now look at the lines near the end of the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### MEASURE SYSTEM STATE ###&lt;br /&gt;
thermo_style custom step etotal temp press density&lt;br /&gt;
variable dens equal density&lt;br /&gt;
variable dens2 equal density*density&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
variable press equal press&lt;br /&gt;
variable press2 equal press*press&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_dens v_temp v_press v_dens2 v_temp2 v_press2&lt;br /&gt;
run 100000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command, &#039;&#039;thermo_style&#039;&#039;, controls which thermodynamic properties are recorded, as before. The next lines are used to measure &#039;&#039;average&#039;&#039; thermodynamic properties for the system. To draw our equations of state, we need to know the average temperature, pressure, and density, and the statistical errors in those quantities. The six variable lines link those quantities (and their squared values, needed for the errors), to variable names that we can use in the averaging command, which is the line starting &#039;&#039;fix aves...&#039;&#039;. This command takes a number of input values and averages them every so many timesteps. Exactly how often this happens depends in the values of the three numbers which follow &#039;&#039;ave/time&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the fourth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Equilibration|Equilibration]], or jump ahead to the next section, [[Third year simulation experiment/Structural properties and the radial distribution function|Structural properties and the radial distribution function]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Running_simulations_under_specific_conditions&amp;diff=734572</id>
		<title>Third year simulation experiment/Running simulations under specific conditions</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Running_simulations_under_specific_conditions&amp;diff=734572"/>
		<updated>2018-10-08T10:01:22Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Temperature and Pressure Control */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the fourth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Equilibration|Equilibration]], or jump ahead to the next section, [[Third_year_simulation_experiment/Structural_properties_and_the_radial_distribution_function| Structural Properties and the Radial Distribution Functions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;THE FILES THAT YOU NEED FOR THIS SECTION ARE FOUND IN THE &amp;quot;NpT&amp;quot; SUBFOLDER.&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Changing Ensemble==&lt;br /&gt;
&lt;br /&gt;
So far, we have been able to do some simulations in which the number of particles and the volume of the simulation cell are held constant. The energy is also constant (within a certain degree of error, which is introduced by the approximations that we make to do the simulation). If the simulation is a working properly, then the pressure and temperature of the system should also reach a constant &#039;&#039;average&#039;&#039; value (although there will again be fluctuations). In the statistical thermodynamics lectures, you met the concept of ensembles, which are used in statistical mechanics to represent different sorts of experimental conditions. The simulations we have done so far are described by the &#039;&#039;microcanonical&#039;&#039;, or NVE ensemble (the letters represent those thermodynamic quantities which are constant).&lt;br /&gt;
&lt;br /&gt;
As chemists, we often want to understand what happens under particular experimental conditions &amp;amp;mdash; at 298K under 1 atmosphere of pressure, for example. These sorts of conditions are described by different ensembles in statistical mechanics, such as the NVT (&#039;&#039;canonical&#039;&#039;) or NpT (&#039;&#039;isobaric-isothermal&#039;&#039;) ensembles.&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to modify our simulations from the previous section to run under NpT conditions, and sketch an equation of state for our model fluid at atmospheric pressure.&lt;br /&gt;
&lt;br /&gt;
==Temperature and Pressure Control==&lt;br /&gt;
&lt;br /&gt;
The file npt.in can be used to perform a constant temperature/pressure simulation of our model fluid. It starts by melting a simple cubic crystal, just as before, so much of this file will look familiar to you. You will notice a new section near the top, however, called &#039;&#039;&#039;### SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&#039;&#039;&#039;. It contains three &#039;&#039;variables&#039;&#039; &amp;amp;mdash; these are used by the script later on to define the desired temperature, pressure, and timestep. The ellipses need to be replaced by the actual temperature, pressure and timestep that you want to use, so&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
variable T equal 0.5&lt;br /&gt;
variable p equal 1.0&lt;br /&gt;
variable timestep equal 0.75&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
would run a simulation at &amp;lt;math&amp;gt;T=0.5,\  p=1.0,\  \delta t=0.75&amp;lt;/math&amp;gt;. You should remember from the [[Third_year_simulation_experiment/Equilibration|Equilibration]] section that this is a poor choice of timestep!&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 8: Choose 5 temperatures (above the critical temperature &amp;lt;math&amp;gt;T^* = 1.5&amp;lt;/math&amp;gt;), and two pressures (you can get a good idea of what a reasonable pressure is in Lennard-Jones units by looking at the average pressure of your simulations from the last section). This gives ten phase points &amp;amp;mdash; five temperatures at each pressure. Create 10 copies of npt.in, and modify each to run a simulation at one of your chosen &amp;lt;math&amp;gt;\left(p, T\right)&amp;lt;/math&amp;gt; points. You should be able to use the results of the previous section to choose a timestep. Submit these ten jobs to the HPC portal. When your simulations have finished, download the log files as before. At the end of the log file, LAMMPS will output the values and errors for the pressure, temperature, and density &amp;lt;math&amp;gt;\left(\frac{N}{V}\right)&amp;lt;/math&amp;gt;. Use software of your choice to plot the density as a function of temperature for both of the pressures that you simulated.  Your graph(s) should include error bars in both the x and y directions. You should also include a line corresponding to the density predicted by the ideal gas law at that pressure. Is your simulated density lower or higher? Justify this. Does the discrepancy increase or decrease with pressure? [15 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Thermostats and Barostats - controlling the thermodynamic properties===&lt;br /&gt;
The statistical thermodynamics lectures will have introduced you to the &#039;&#039;equipartition theorem&#039;&#039;, which states that, on average, every degree of freedom in a system at equilibrium will have &amp;lt;math&amp;gt;\frac{1}{2}k_B T&amp;lt;/math&amp;gt; of energy. In our system with &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms, each with 3 degrees of freedom, we can write&lt;br /&gt;
&amp;lt;math&amp;gt;E_K = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i v_i^2 = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end of every timestep, we use the left hand side of this equation to calculate the kinetic energy, then divide by &amp;lt;math&amp;gt;\frac{3}{2}Nk_B&amp;lt;/math&amp;gt; to get the &#039;&#039;instantaneous&#039;&#039; temperature &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. In general, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; will fluctuate, and will be different to our &#039;&#039;target&#039;&#039; temperature, &amp;lt;math&amp;gt;\mathfrak{T}&amp;lt;/math&amp;gt; (this is whatever value we specify in the input script). We can change the temperature by multiplying every velocity by a constant factor, &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* If &amp;lt;math&amp;gt; T &amp;gt; \mathfrak{T} &amp;lt;/math&amp;gt;, then the kinetic energy of the system is too high, and we need to reduce it. &amp;lt;math&amp;gt;\gamma &amp;lt; 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* If &amp;lt;math&amp;gt; T &amp;lt; \mathfrak{T} &amp;lt;/math&amp;gt;, then the kinetic energy of the system is too low, and we need to increase it. &amp;lt;math&amp;gt;\gamma &amp;gt; 1&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 16: We need to choose &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt; so that the temperature is correct &amp;lt;math&amp;gt;T = \mathfrak{T}&amp;lt;/math&amp;gt; if we multiply every velocity &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;. We can write two equations:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i v_i^2 = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i \left(\gamma v_i\right)^2 = \frac{3}{2} N k_B \mathfrak{T}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solve these to determine &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;. &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Controlling the pressure is a little more involved, but the principle is largely the same: at each timestep, the pressure of the system is calculated; if the pressure is too high, then the simulation box is made a little larger, while if the pressure is too low the box is made smaller. Simulations in which the pressure is controlled are thus in the NpT ensemble &amp;amp;mdash; the volume of the simulation box is not constant!&lt;br /&gt;
&lt;br /&gt;
===Examining the Input Script===&lt;br /&gt;
&lt;br /&gt;
Open one of your input scripts (it doesn&#039;t matter which), and look at the section &#039;&#039;&#039;### BRING SYSTEM TO REQUIRED STATE ###&#039;&#039;&#039;. The line &amp;lt;pre&amp;gt;fix npt all npt temp ${T} ${T} ${tdamp} iso ${p} ${p} ${pdamp}&amp;lt;/pre&amp;gt; is the one responsible for switching on the temperature and pressure control. LAMMPS actually allows us to heat or cool the system over the course of a simulation, if we want to &amp;amp;mdash; this is the reason that the temperature appears twice in this line. The first ${T} is the desired starting temperature, and the second is the desired temperature at the end of the simulation. We want a constant average temperature, so we specify the same value twice. The same goes for the pressure.&lt;br /&gt;
&lt;br /&gt;
Now look at the lines near the end of the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### MEASURE SYSTEM STATE ###&lt;br /&gt;
thermo_style custom step etotal temp press density&lt;br /&gt;
variable dens equal density&lt;br /&gt;
variable dens2 equal density*density&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
variable press equal press&lt;br /&gt;
variable press2 equal press*press&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_dens v_temp v_press v_dens2 v_temp2 v_press2&lt;br /&gt;
run 100000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command, &#039;&#039;thermo_style&#039;&#039;, controls which thermodynamic properties are recorded, as before. The next lines are used to measure &#039;&#039;average&#039;&#039; thermodynamic properties for the system. To draw our equations of state, we need to know the average temperature, pressure, and density, and the statistical errors in those quantities. The six variable lines link those quantities (and their squared values, needed for the errors), to variable names that we can use in the averaging command, which is the line starting &#039;&#039;fix aves...&#039;&#039;. This command takes a number of input values and averages them every so many timesteps. Exactly how often this happens depends in the values of the three numbers which follow &#039;&#039;ave/time&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the fourth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Equilibration|Equilibration]], or jump ahead to the next section, [[Third year simulation experiment/Structural properties and the radial distribution function|Structural properties and the radial distribution function]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734571</id>
		<title>Third year simulation experiment/Equilibration</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734571"/>
		<updated>2018-10-08T10:01:06Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Checking equilibration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We will be using the LAMMPS program to carry out our molecular dynamics simulations.&lt;br /&gt;
&#039;&#039;&#039;In several places in this section, we will ask you to consult the LAMMPS manual to find out things about how the software works. You can find the manual [https://lammps.sandia.gov/doc/Manual.html here].&#039;&#039;&#039; We appreciate that the format of this document can make it a little hard to navigate, but it is the definitive resource on how different commands in LAMMPS work, and is therefore invaluable. &lt;br /&gt;
&lt;br /&gt;
===Creating the simulation box===&lt;br /&gt;
In the previous section, it was pointed out that before we can start a simulation, we need to know the initial states of all of the atoms in the system. Exactly what information we need about each atom depends on which method of numerical integration we need, but at the very least we need to specify the starting position of each atom. If we wanted to simulate a crystal, this information would be quite easy to come by &amp;amp;mdash; we could just look up the crystal structure, and use that to generate coordinates for however many unit cells we wanted. For this purpose, LAMMPS includes a command which generates crystal lattice structures.&lt;br /&gt;
&lt;br /&gt;
Generating coordinates for atoms in a liquid is more difficult. There is no long range order, so we can&#039;t use a single point of reference to work out the positions of every other atom like we can in a solid. We could generate a random position for each atom. This would certainly create a disordered structure, but causes larger problems when we try to run the simulation.&lt;br /&gt;
&lt;br /&gt;
Instead, we are going to place the atoms on the lattice points of a simple cubic lattice. This, of course, is not a situation in which the system is likely to be found physically. It turns out, though, that if we simulate for enough time we will find that the atoms rearrange themselves into more realistic configurations. We will discuss towards the end of this section exactly what is meant by &amp;quot;enough time&amp;quot;!&lt;br /&gt;
&lt;br /&gt;
Consider the line in the input file &amp;lt;pre&amp;gt;lattice sc 0.8&amp;lt;/pre&amp;gt; This command creates a grid of points forming a simple cubic lattice (one lattice point per unit cell). The parameter &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt; specifies the number density (number of lattice points per unit volume). In a corresponding output file, you will see the line &amp;lt;pre&amp;gt;Lattice spacing in x,y,z = 1.07722 1.07722 1.07722&amp;lt;/pre&amp;gt; This indicates that the distance between the points of this lattice is &amp;lt;math&amp;gt;1.07722&amp;lt;/math&amp;gt; (in reduced units, remember!).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 6: Satisfy yourself that this lattice spacing corresponds to a number density of lattice points of &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt;. Consider instead a face-centred cubic lattice with a lattice point number density of 1.2. What is the side length of the cubic unit cell? [3 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The next lines in the input file are&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
region box block 0 10 0 10 0 10&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The corresponding log file output is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Created orthogonal box = (0 0 0) to (10.7722 10.7722 10.7722)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The region command simply defines a geometrical region in space, which we call &amp;quot;box&amp;quot;. In this case, &amp;quot;box&amp;quot; is a cube extending ten lattice spacings from the origin in all three dimensions. The subsequent create_box command tells LAMMPS to use the geometrical region called &amp;quot;box&amp;quot; as a template for the simulation box. The number 1 between &amp;quot;create_box&amp;quot; and &amp;quot;box&amp;quot; indicates that our simulation will contain only one type (species) of atom.&lt;br /&gt;
&lt;br /&gt;
So far we have defined a simulation box which is based around a virtual simple cubic lattice. Our box contains 1000 (10x10x10) unit cells of this lattice, and so contains 1000 lattice points. We now need to fill our simulation box with atoms. The input command is &amp;lt;pre&amp;gt;create_atoms 1 box&amp;lt;/pre&amp;gt; while the log file simply contains an acknowledgement of this &amp;lt;pre&amp;gt;Created 1000 atoms&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The create_atoms command has two arguments; the first tells LAMMPS that all of the atoms that we create will be of type 1. Every atom in the simulation has a type &amp;amp;mdash; because we will be simulating a pure fluid, containing only one chemical species, every atom will have the same type. The actual type that we assign to each atom is arbitrary &amp;amp;mdash; type 1 does not, for example, need to correspond to the element with atomic number 1 (hydrogen). If we wanted to simulate water, we might make the hydrogen atoms type 1 and the oxygen atoms type 2. We will specify the physical and chemical properties of each atom type later in the input script.&lt;br /&gt;
&lt;br /&gt;
The remaining data in the log file isn&#039;t very instructive as it stands &amp;amp;mdash; it simply contains a list of the thermodynamic properties of the simulation at certain intervals. In a few sections time, we will plot this data, but for now you can close the log file. Keep the input script open.&lt;br /&gt;
&lt;br /&gt;
===Setting the properties of the atoms===&lt;br /&gt;
&lt;br /&gt;
In addition to their positions, we also need the physical properties of the atoms to be able to perform the simulation. We set these properties on a &#039;per-type&#039; basis, so that every atom of the same type has the same mass and the same interactions.&lt;br /&gt;
&lt;br /&gt;
So far we have created 1000 atoms, and we know the starting (&amp;lt;math&amp;gt;t = 0&amp;lt;/math&amp;gt;) position for each of them. We have also set their masses, and told LAMMPS what sort of forces to calculate between them. The final thing we need to specify to completely specify the initial conditions is the velocity of each atom.&lt;br /&gt;
&lt;br /&gt;
Choosing initial velocities for the atoms is a little easier than choosing initial positions. From the statistical thermodynamics lectures, you should know that, at equilibrium, the velocities of atoms in any system must be distributed according to the [http://en.wikipedia.org/wiki/Maxwell%E2%80%93Boltzmann_distribution Maxwell-Boltzmann (MB) distribution]. If we know the masses of the atoms, and we know what temperature we want to simulate, then we can determine the relevant MB distribution function. LAMMPS is able to give every atom a random velocity whilst ensuring that overall the MB distribution is followed. This is the purpose of the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
velocity all create 1.5 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see the manual page for this command [http://lammps.sandia.gov/doc/velocity.html here], but the key sections are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;all&#039;&#039;&#039;: the &#039;&#039;group&#039;&#039; of atoms on which the command acts. &#039;&#039;&#039;all&#039;&#039;&#039; simply specifies that we want every atom to have a velocity assigned to it.&lt;br /&gt;
* &#039;&#039;&#039;1.5&#039;&#039;&#039;: the temperature, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, needed to calculate the MB distribution(in reduced units, as always)&lt;br /&gt;
&lt;br /&gt;
===Monitoring thermodynamic properties===&lt;br /&gt;
&lt;br /&gt;
We need to be sure that our simulation is correctly modelling whatever physical system we want to study. It is relatively easy to set up simulations, but how can we be sure that the &amp;quot;results&amp;quot; we get make sense? One of the best ways is to calculate from the simulation things that we can measure in experiment, and see if they agree. For example, we might want to simulate our system at a particular temperature and pressure, and measure the resulting density. If we repeat this over a range of temperatures at the same pressure, we will be able to plot an &#039;&#039;equation of state&#039;&#039;, which we could compare to experimental measurements.&lt;br /&gt;
&lt;br /&gt;
LAMMPS is able to calculate a great deal of thermodynamic information for us (you can see a full list of the properties it is able to calculate [http://lammps.sandia.gov/doc/thermo_style.html here]), but in these first simulations we are only interested in those properties specified in these commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
thermo 10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first controls which properties will be printed out in the log file. In this case, we print how much time we have simulated so far (which is &#039;&#039;not&#039;&#039; the same as how long it has taken us to simulate it!), the total energy of the atoms, their temperature, and their pressure. The second line tells LAMMPS to print this information on every 10th timestep.&lt;br /&gt;
&lt;br /&gt;
===Running the simulation===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Look at the lines below.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### SPECIFY TIMESTEP ###&lt;br /&gt;
variable timestep equal 0.001&lt;br /&gt;
variable n_steps equal floor(100/${timestep})&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
### RUN SIMULATION ###&lt;br /&gt;
run ${n_steps}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The second line (starting &amp;quot;variable timestep...&amp;quot;) tells LAMMPS that if it encounters the text ${timestep} on a subsequent line, it should replace it by the value given. In this case, the value ${timestep} is always replaced by 0.001.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ask the demonstrator if you need help.&#039;&#039;&#039;&lt;br /&gt;
It is now time to run your first simulation, submit the input script with the data file in the intro folder of the files you have downloaded Try changing the timestep - what happens when you make the timestep larger?.&lt;br /&gt;
&lt;br /&gt;
===Visualising the trajectory===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;trajectory files&#039;&#039;&#039; contain the positions of all the atoms in the simulation, recorded at a set interval (for all of these simulations, this was every ten timesteps &amp;amp;mdash; this is controlled by the &#039;&#039;&#039;dump&#039;&#039;&#039; command in the input scripts). We use a programme called [http://www.ks.uiuc.edu/Research/vmd/ &#039;&#039;&#039;VMD&#039;&#039;&#039;] to view these trajectories, which you should find is already installed on both the desktop and laptop computers. You can run VMD from the start menu with &#039;&#039;&#039;Start&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;All Programs&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;University of Illinois&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;VMD&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
====Loading a Trajectory====&lt;br /&gt;
&lt;br /&gt;
We&#039;ll start by looking at the output of the 0.015 timestep simulation. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;File&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;New Molecule&#039;&#039;&#039;. Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button, then select the relevant trajectory file. In the &#039;&#039;&#039;Determine file type&#039;&#039;&#039; dropdown, select &#039;&#039;&#039;LAMMPS Trajectory&#039;&#039;&#039;. Then click &#039;&#039;&#039;Load&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You will see that the &#039;&#039;&#039;VMD 1.9.1 OpenGL Display&#039;&#039;&#039; window now shows a horrible mess. VMD&#039;s default behaviour is to draw lines between atoms which it thinks might be chemically bonded. Our system doesn&#039;t model chemical bonds, so we want to turn this off. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;Graphics&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Representations&#039;&#039;&#039;. This shows a list of &amp;quot;representations&amp;quot; of our atoms. You will see that at the moment, there is a single representation listed, and it is selected. It will have the &#039;&#039;Lines&#039;&#039; style, the &#039;&#039;Name&#039;&#039; colour, and the selection &#039;&#039;all&#039;&#039;. &amp;quot;Selection&amp;quot; simply tells VMD which atoms we want it to draw. We want to show every atom, so the current selection is fine. The &#039;&#039;name&#039;&#039; colouring method just makes VMD give atoms colours according to their specified type. The colour isn&#039;t important to us, so we can leave this be too. The &amp;quot;style&amp;quot; tells VMD what we want it to display for each atom. Change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; from &#039;&#039;Lines&#039;&#039; to &#039;&#039;VDW&#039;&#039;. You will see that the mess of lines is replaced by a mess of low resolution, overlapping spheres. Change the &#039;&#039;&#039;Sphere Scale&#039;&#039;&#039; to 0.3, and the &#039;&#039;&#039;Sphere Resolution&#039;&#039;&#039; to 17. The result should look a little smoother. Close the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window. You will notice that in the bottom right of the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, there is a small play button. Click this, and you will see the animated version of your simulation trajectory.&lt;br /&gt;
&lt;br /&gt;
By clicking and dragging with the mouse, you can rotate the simulation box (though this may be sluggish). At any time, you can reset the view by pressing the equals key.&lt;br /&gt;
&lt;br /&gt;
====Tracking a Single Particle====&lt;br /&gt;
To illustrate the periodic boundary conditions that we are using, we are going to draw almost all of the atoms as points, but we will pick a single atom at random to draw as a sphere. This will make it easy to see how a single atom moves through the box. Reset the display using the equals key, then use the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window controls to pause the trajectory and reset it to the first trajectory (play with the different buttons until you find the one that does this). You should see the perfect cubic lattice. Use the option &#039;&#039;&#039;Display&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Orthographic&#039;&#039;&#039; to change the drawing mode, then rotate the displayed crystal so that you are looking at one vertex (looking down the 111 direction, in crystallographic terms).&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window again. Change the representation style from &#039;&#039;&#039;VDW&#039;&#039;&#039; to points, then click the &#039;&#039;&#039;Create Rep&#039;&#039;&#039; button. This creates a second representation, allowing a subset of the atoms to be drawn in a different way. The &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; box allows us to choose which atoms this representation applies to. We just want to pick two of them at random &amp;amp;mdash; VMD assigns every atom an index, from 0 to N-1. In our case, there are 1000 atoms, so choose two numbers between 0 and 999. Changed the &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; field to &amp;lt;pre&amp;gt;index i or index j&amp;lt;/pre&amp;gt; where i and j are your chosen numbers, press return, then change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; to &#039;&#039;&#039;VDW&#039;&#039;&#039;. You should now see only two atoms represented by spheres, with the rest shown as small points. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, click play. Try rotating the box, and changing the playback speed.&lt;br /&gt;
&lt;br /&gt;
You will see that sometimes one of the spheres seems to change position across the box very rapidly &amp;amp;mdash; this occurs when it reaches one periodic boundary, and is reflected back across the other face. Try playing with some of the other representation types in VMD &amp;amp;mdash; it  is a very powerful package, which is often used to render images of simulated proteins, so many of its options aren&#039;t relevant to our simple system!&lt;br /&gt;
&lt;br /&gt;
===Checking equilibration===&lt;br /&gt;
&lt;br /&gt;
When we first set up a simulation, it is very important to make sure that our system reaches an equilibrium state. We characterise equilibrium by the average values of thermodynamic quantities becoming constant (due to the approximations that we have made, there will always be fluctuations, but the average values will become constant).&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to plot the thermodynamic output of the simulation to see how long it takes to reach the equilibrium state (and indeed, whether this happens at all). Instructions are given below to import data from the LAMMPS log file into Microsoft Excel. Once you have the data in a spreadsheet, you can plot it. If you know how to use some of the other plotting software available on the chemistry computers (like Origin), you are welcome to use it.&lt;br /&gt;
&lt;br /&gt;
# Open a blank Excel workbook&lt;br /&gt;
# Choose the &#039;&#039;&#039;Data&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;From Text&#039;&#039;&#039; button&lt;br /&gt;
# Select one of your simulation log files&lt;br /&gt;
# Set the &#039;&#039;&#039;Start import at row&#039;&#039;&#039; field to &#039;&#039;&#039;25&#039;&#039;&#039; (this ignores all of the diagnostic information at the top of the file)&lt;br /&gt;
# Set the &#039;&#039;&#039;Original Data type&#039;&#039;&#039; to &#039;&#039;&#039;Delimited&#039;&#039;&#039;, then click &#039;&#039;&#039;Next&#039;&#039;&#039;&lt;br /&gt;
# Tick the &#039;&#039;&#039;Space&#039;&#039;&#039; box, and make sure that &#039;&#039;&#039;Treat consecutive delimiters as one&#039;&#039;&#039; box is ticked.&lt;br /&gt;
# On the next dialog, you can select where you want the data to be inserted. When you are happy, click &#039;&#039;&#039;OK&#039;&#039;&#039;. The data will be inserted into your spreadsheet.&lt;br /&gt;
# Scroll to the bottom of the data &amp;amp;mdash; you will see a lot of timing information from the simulation. Delete everything beyond the end of your thermodynamic data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 7: make plots of the energy, temperature, and pressure, against time for the 0.001 timestep experiment (attach a picture to your report). Does the simulation reach equilibrium? When you have done this, make a single plot which shows the energy versus time for all of the timesteps you have simulated (again, attach a picture to your report). Of the timesteps that you used, which timestep will you use for subsequent simulations and why? [9 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734570</id>
		<title>Third year simulation experiment/Equilibration</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734570"/>
		<updated>2018-10-08T10:00:32Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Setting the properties of the atoms */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We will be using the LAMMPS program to carry out our molecular dynamics simulations.&lt;br /&gt;
&#039;&#039;&#039;In several places in this section, we will ask you to consult the LAMMPS manual to find out things about how the software works. You can find the manual [https://lammps.sandia.gov/doc/Manual.html here].&#039;&#039;&#039; We appreciate that the format of this document can make it a little hard to navigate, but it is the definitive resource on how different commands in LAMMPS work, and is therefore invaluable. &lt;br /&gt;
&lt;br /&gt;
===Creating the simulation box===&lt;br /&gt;
In the previous section, it was pointed out that before we can start a simulation, we need to know the initial states of all of the atoms in the system. Exactly what information we need about each atom depends on which method of numerical integration we need, but at the very least we need to specify the starting position of each atom. If we wanted to simulate a crystal, this information would be quite easy to come by &amp;amp;mdash; we could just look up the crystal structure, and use that to generate coordinates for however many unit cells we wanted. For this purpose, LAMMPS includes a command which generates crystal lattice structures.&lt;br /&gt;
&lt;br /&gt;
Generating coordinates for atoms in a liquid is more difficult. There is no long range order, so we can&#039;t use a single point of reference to work out the positions of every other atom like we can in a solid. We could generate a random position for each atom. This would certainly create a disordered structure, but causes larger problems when we try to run the simulation.&lt;br /&gt;
&lt;br /&gt;
Instead, we are going to place the atoms on the lattice points of a simple cubic lattice. This, of course, is not a situation in which the system is likely to be found physically. It turns out, though, that if we simulate for enough time we will find that the atoms rearrange themselves into more realistic configurations. We will discuss towards the end of this section exactly what is meant by &amp;quot;enough time&amp;quot;!&lt;br /&gt;
&lt;br /&gt;
Consider the line in the input file &amp;lt;pre&amp;gt;lattice sc 0.8&amp;lt;/pre&amp;gt; This command creates a grid of points forming a simple cubic lattice (one lattice point per unit cell). The parameter &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt; specifies the number density (number of lattice points per unit volume). In a corresponding output file, you will see the line &amp;lt;pre&amp;gt;Lattice spacing in x,y,z = 1.07722 1.07722 1.07722&amp;lt;/pre&amp;gt; This indicates that the distance between the points of this lattice is &amp;lt;math&amp;gt;1.07722&amp;lt;/math&amp;gt; (in reduced units, remember!).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 6: Satisfy yourself that this lattice spacing corresponds to a number density of lattice points of &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt;. Consider instead a face-centred cubic lattice with a lattice point number density of 1.2. What is the side length of the cubic unit cell? [3 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The next lines in the input file are&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
region box block 0 10 0 10 0 10&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The corresponding log file output is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Created orthogonal box = (0 0 0) to (10.7722 10.7722 10.7722)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The region command simply defines a geometrical region in space, which we call &amp;quot;box&amp;quot;. In this case, &amp;quot;box&amp;quot; is a cube extending ten lattice spacings from the origin in all three dimensions. The subsequent create_box command tells LAMMPS to use the geometrical region called &amp;quot;box&amp;quot; as a template for the simulation box. The number 1 between &amp;quot;create_box&amp;quot; and &amp;quot;box&amp;quot; indicates that our simulation will contain only one type (species) of atom.&lt;br /&gt;
&lt;br /&gt;
So far we have defined a simulation box which is based around a virtual simple cubic lattice. Our box contains 1000 (10x10x10) unit cells of this lattice, and so contains 1000 lattice points. We now need to fill our simulation box with atoms. The input command is &amp;lt;pre&amp;gt;create_atoms 1 box&amp;lt;/pre&amp;gt; while the log file simply contains an acknowledgement of this &amp;lt;pre&amp;gt;Created 1000 atoms&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The create_atoms command has two arguments; the first tells LAMMPS that all of the atoms that we create will be of type 1. Every atom in the simulation has a type &amp;amp;mdash; because we will be simulating a pure fluid, containing only one chemical species, every atom will have the same type. The actual type that we assign to each atom is arbitrary &amp;amp;mdash; type 1 does not, for example, need to correspond to the element with atomic number 1 (hydrogen). If we wanted to simulate water, we might make the hydrogen atoms type 1 and the oxygen atoms type 2. We will specify the physical and chemical properties of each atom type later in the input script.&lt;br /&gt;
&lt;br /&gt;
The remaining data in the log file isn&#039;t very instructive as it stands &amp;amp;mdash; it simply contains a list of the thermodynamic properties of the simulation at certain intervals. In a few sections time, we will plot this data, but for now you can close the log file. Keep the input script open.&lt;br /&gt;
&lt;br /&gt;
===Setting the properties of the atoms===&lt;br /&gt;
&lt;br /&gt;
In addition to their positions, we also need the physical properties of the atoms to be able to perform the simulation. We set these properties on a &#039;per-type&#039; basis, so that every atom of the same type has the same mass and the same interactions.&lt;br /&gt;
&lt;br /&gt;
So far we have created 1000 atoms, and we know the starting (&amp;lt;math&amp;gt;t = 0&amp;lt;/math&amp;gt;) position for each of them. We have also set their masses, and told LAMMPS what sort of forces to calculate between them. The final thing we need to specify to completely specify the initial conditions is the velocity of each atom.&lt;br /&gt;
&lt;br /&gt;
Choosing initial velocities for the atoms is a little easier than choosing initial positions. From the statistical thermodynamics lectures, you should know that, at equilibrium, the velocities of atoms in any system must be distributed according to the [http://en.wikipedia.org/wiki/Maxwell%E2%80%93Boltzmann_distribution Maxwell-Boltzmann (MB) distribution]. If we know the masses of the atoms, and we know what temperature we want to simulate, then we can determine the relevant MB distribution function. LAMMPS is able to give every atom a random velocity whilst ensuring that overall the MB distribution is followed. This is the purpose of the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
velocity all create 1.5 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see the manual page for this command [http://lammps.sandia.gov/doc/velocity.html here], but the key sections are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;all&#039;&#039;&#039;: the &#039;&#039;group&#039;&#039; of atoms on which the command acts. &#039;&#039;&#039;all&#039;&#039;&#039; simply specifies that we want every atom to have a velocity assigned to it.&lt;br /&gt;
* &#039;&#039;&#039;1.5&#039;&#039;&#039;: the temperature, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, needed to calculate the MB distribution(in reduced units, as always)&lt;br /&gt;
&lt;br /&gt;
===Monitoring thermodynamic properties===&lt;br /&gt;
&lt;br /&gt;
We need to be sure that our simulation is correctly modelling whatever physical system we want to study. It is relatively easy to set up simulations, but how can we be sure that the &amp;quot;results&amp;quot; we get make sense? One of the best ways is to calculate from the simulation things that we can measure in experiment, and see if they agree. For example, we might want to simulate our system at a particular temperature and pressure, and measure the resulting density. If we repeat this over a range of temperatures at the same pressure, we will be able to plot an &#039;&#039;equation of state&#039;&#039;, which we could compare to experimental measurements.&lt;br /&gt;
&lt;br /&gt;
LAMMPS is able to calculate a great deal of thermodynamic information for us (you can see a full list of the properties it is able to calculate [http://lammps.sandia.gov/doc/thermo_style.html here]), but in these first simulations we are only interested in those properties specified in these commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
thermo 10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first controls which properties will be printed out in the log file. In this case, we print how much time we have simulated so far (which is &#039;&#039;not&#039;&#039; the same as how long it has taken us to simulate it!), the total energy of the atoms, their temperature, and their pressure. The second line tells LAMMPS to print this information on every 10th timestep.&lt;br /&gt;
&lt;br /&gt;
===Running the simulation===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Look at the lines below.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### SPECIFY TIMESTEP ###&lt;br /&gt;
variable timestep equal 0.001&lt;br /&gt;
variable n_steps equal floor(100/${timestep})&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
### RUN SIMULATION ###&lt;br /&gt;
run ${n_steps}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The second line (starting &amp;quot;variable timestep...&amp;quot;) tells LAMMPS that if it encounters the text ${timestep} on a subsequent line, it should replace it by the value given. In this case, the value ${timestep} is always replaced by 0.001.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ask the demonstrator if you need help.&#039;&#039;&#039;&lt;br /&gt;
It is now time to run your first simulation, submit the input script with the data file in the intro folder of the files you have downloaded Try changing the timestep - what happens when you make the timestep larger?.&lt;br /&gt;
&lt;br /&gt;
===Visualising the trajectory===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;trajectory files&#039;&#039;&#039; contain the positions of all the atoms in the simulation, recorded at a set interval (for all of these simulations, this was every ten timesteps &amp;amp;mdash; this is controlled by the &#039;&#039;&#039;dump&#039;&#039;&#039; command in the input scripts). We use a programme called [http://www.ks.uiuc.edu/Research/vmd/ &#039;&#039;&#039;VMD&#039;&#039;&#039;] to view these trajectories, which you should find is already installed on both the desktop and laptop computers. You can run VMD from the start menu with &#039;&#039;&#039;Start&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;All Programs&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;University of Illinois&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;VMD&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
====Loading a Trajectory====&lt;br /&gt;
&lt;br /&gt;
We&#039;ll start by looking at the output of the 0.015 timestep simulation. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;File&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;New Molecule&#039;&#039;&#039;. Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button, then select the relevant trajectory file. In the &#039;&#039;&#039;Determine file type&#039;&#039;&#039; dropdown, select &#039;&#039;&#039;LAMMPS Trajectory&#039;&#039;&#039;. Then click &#039;&#039;&#039;Load&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You will see that the &#039;&#039;&#039;VMD 1.9.1 OpenGL Display&#039;&#039;&#039; window now shows a horrible mess. VMD&#039;s default behaviour is to draw lines between atoms which it thinks might be chemically bonded. Our system doesn&#039;t model chemical bonds, so we want to turn this off. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;Graphics&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Representations&#039;&#039;&#039;. This shows a list of &amp;quot;representations&amp;quot; of our atoms. You will see that at the moment, there is a single representation listed, and it is selected. It will have the &#039;&#039;Lines&#039;&#039; style, the &#039;&#039;Name&#039;&#039; colour, and the selection &#039;&#039;all&#039;&#039;. &amp;quot;Selection&amp;quot; simply tells VMD which atoms we want it to draw. We want to show every atom, so the current selection is fine. The &#039;&#039;name&#039;&#039; colouring method just makes VMD give atoms colours according to their specified type. The colour isn&#039;t important to us, so we can leave this be too. The &amp;quot;style&amp;quot; tells VMD what we want it to display for each atom. Change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; from &#039;&#039;Lines&#039;&#039; to &#039;&#039;VDW&#039;&#039;. You will see that the mess of lines is replaced by a mess of low resolution, overlapping spheres. Change the &#039;&#039;&#039;Sphere Scale&#039;&#039;&#039; to 0.3, and the &#039;&#039;&#039;Sphere Resolution&#039;&#039;&#039; to 17. The result should look a little smoother. Close the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window. You will notice that in the bottom right of the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, there is a small play button. Click this, and you will see the animated version of your simulation trajectory.&lt;br /&gt;
&lt;br /&gt;
By clicking and dragging with the mouse, you can rotate the simulation box (though this may be sluggish). At any time, you can reset the view by pressing the equals key.&lt;br /&gt;
&lt;br /&gt;
====Tracking a Single Particle====&lt;br /&gt;
To illustrate the periodic boundary conditions that we are using, we are going to draw almost all of the atoms as points, but we will pick a single atom at random to draw as a sphere. This will make it easy to see how a single atom moves through the box. Reset the display using the equals key, then use the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window controls to pause the trajectory and reset it to the first trajectory (play with the different buttons until you find the one that does this). You should see the perfect cubic lattice. Use the option &#039;&#039;&#039;Display&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Orthographic&#039;&#039;&#039; to change the drawing mode, then rotate the displayed crystal so that you are looking at one vertex (looking down the 111 direction, in crystallographic terms).&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window again. Change the representation style from &#039;&#039;&#039;VDW&#039;&#039;&#039; to points, then click the &#039;&#039;&#039;Create Rep&#039;&#039;&#039; button. This creates a second representation, allowing a subset of the atoms to be drawn in a different way. The &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; box allows us to choose which atoms this representation applies to. We just want to pick two of them at random &amp;amp;mdash; VMD assigns every atom an index, from 0 to N-1. In our case, there are 1000 atoms, so choose two numbers between 0 and 999. Changed the &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; field to &amp;lt;pre&amp;gt;index i or index j&amp;lt;/pre&amp;gt; where i and j are your chosen numbers, press return, then change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; to &#039;&#039;&#039;VDW&#039;&#039;&#039;. You should now see only two atoms represented by spheres, with the rest shown as small points. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, click play. Try rotating the box, and changing the playback speed.&lt;br /&gt;
&lt;br /&gt;
You will see that sometimes one of the spheres seems to change position across the box very rapidly &amp;amp;mdash; this occurs when it reaches one periodic boundary, and is reflected back across the other face. Try playing with some of the other representation types in VMD &amp;amp;mdash; it  is a very powerful package, which is often used to render images of simulated proteins, so many of its options aren&#039;t relevant to our simple system!&lt;br /&gt;
&lt;br /&gt;
===Checking equilibration===&lt;br /&gt;
&lt;br /&gt;
When we first set up a simulation, it is very important to make sure that our system reaches an equilibrium state. We characterise equilibrium by the average values of thermodynamic quantities becoming constant (due to the approximations that we have made, there will always be fluctuations, but the average values will become constant).&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to plot the thermodynamic output of the simulation to see how long it takes to reach the equilibrium state (and indeed, whether this happens at all). Instructions are given below to import data from the LAMMPS log file into Microsoft Excel. Once you have the data in a spreadsheet, you can plot it. If you know how to use some of the other plotting software available on the chemistry computers (like Origin), you are welcome to use it.&lt;br /&gt;
&lt;br /&gt;
# Open a blank Excel workbook&lt;br /&gt;
# Choose the &#039;&#039;&#039;Data&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;From Text&#039;&#039;&#039; button&lt;br /&gt;
# Select one of your simulation log files&lt;br /&gt;
# Set the &#039;&#039;&#039;Start import at row&#039;&#039;&#039; field to &#039;&#039;&#039;25&#039;&#039;&#039; (this ignores all of the diagnostic information at the top of the file)&lt;br /&gt;
# Set the &#039;&#039;&#039;Original Data type&#039;&#039;&#039; to &#039;&#039;&#039;Delimited&#039;&#039;&#039;, then click &#039;&#039;&#039;Next&#039;&#039;&#039;&lt;br /&gt;
# Tick the &#039;&#039;&#039;Space&#039;&#039;&#039; box, and make sure that &#039;&#039;&#039;Treat consecutive delimiters as one&#039;&#039;&#039; box is ticked.&lt;br /&gt;
# On the next dialog, you can select where you want the data to be inserted. When you are happy, click &#039;&#039;&#039;OK&#039;&#039;&#039;. The data will be inserted into your spreadsheet.&lt;br /&gt;
# Scroll to the bottom of the data &amp;amp;mdash; you will see a lot of timing information from the simulation. Delete everything beyond the end of your thermodynamic data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 14: make plots of the energy, temperature, and pressure, against time for the 0.001 timestep experiment (attach a picture to your report). Does the simulation reach equilibrium? When you have done this, make a single plot which shows the energy versus time for all of the timesteps you have simulated (again, attach a picture to your report). Of the timesteps that you used, which timestep will you use for subsequent simulations and why? [9 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734569</id>
		<title>Third year simulation experiment/Equilibration</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734569"/>
		<updated>2018-10-08T10:00:13Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Creating the simulation box */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We will be using the LAMMPS program to carry out our molecular dynamics simulations.&lt;br /&gt;
&#039;&#039;&#039;In several places in this section, we will ask you to consult the LAMMPS manual to find out things about how the software works. You can find the manual [https://lammps.sandia.gov/doc/Manual.html here].&#039;&#039;&#039; We appreciate that the format of this document can make it a little hard to navigate, but it is the definitive resource on how different commands in LAMMPS work, and is therefore invaluable. &lt;br /&gt;
&lt;br /&gt;
===Creating the simulation box===&lt;br /&gt;
In the previous section, it was pointed out that before we can start a simulation, we need to know the initial states of all of the atoms in the system. Exactly what information we need about each atom depends on which method of numerical integration we need, but at the very least we need to specify the starting position of each atom. If we wanted to simulate a crystal, this information would be quite easy to come by &amp;amp;mdash; we could just look up the crystal structure, and use that to generate coordinates for however many unit cells we wanted. For this purpose, LAMMPS includes a command which generates crystal lattice structures.&lt;br /&gt;
&lt;br /&gt;
Generating coordinates for atoms in a liquid is more difficult. There is no long range order, so we can&#039;t use a single point of reference to work out the positions of every other atom like we can in a solid. We could generate a random position for each atom. This would certainly create a disordered structure, but causes larger problems when we try to run the simulation.&lt;br /&gt;
&lt;br /&gt;
Instead, we are going to place the atoms on the lattice points of a simple cubic lattice. This, of course, is not a situation in which the system is likely to be found physically. It turns out, though, that if we simulate for enough time we will find that the atoms rearrange themselves into more realistic configurations. We will discuss towards the end of this section exactly what is meant by &amp;quot;enough time&amp;quot;!&lt;br /&gt;
&lt;br /&gt;
Consider the line in the input file &amp;lt;pre&amp;gt;lattice sc 0.8&amp;lt;/pre&amp;gt; This command creates a grid of points forming a simple cubic lattice (one lattice point per unit cell). The parameter &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt; specifies the number density (number of lattice points per unit volume). In a corresponding output file, you will see the line &amp;lt;pre&amp;gt;Lattice spacing in x,y,z = 1.07722 1.07722 1.07722&amp;lt;/pre&amp;gt; This indicates that the distance between the points of this lattice is &amp;lt;math&amp;gt;1.07722&amp;lt;/math&amp;gt; (in reduced units, remember!).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 6: Satisfy yourself that this lattice spacing corresponds to a number density of lattice points of &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt;. Consider instead a face-centred cubic lattice with a lattice point number density of 1.2. What is the side length of the cubic unit cell? [3 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The next lines in the input file are&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
region box block 0 10 0 10 0 10&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The corresponding log file output is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Created orthogonal box = (0 0 0) to (10.7722 10.7722 10.7722)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The region command simply defines a geometrical region in space, which we call &amp;quot;box&amp;quot;. In this case, &amp;quot;box&amp;quot; is a cube extending ten lattice spacings from the origin in all three dimensions. The subsequent create_box command tells LAMMPS to use the geometrical region called &amp;quot;box&amp;quot; as a template for the simulation box. The number 1 between &amp;quot;create_box&amp;quot; and &amp;quot;box&amp;quot; indicates that our simulation will contain only one type (species) of atom.&lt;br /&gt;
&lt;br /&gt;
So far we have defined a simulation box which is based around a virtual simple cubic lattice. Our box contains 1000 (10x10x10) unit cells of this lattice, and so contains 1000 lattice points. We now need to fill our simulation box with atoms. The input command is &amp;lt;pre&amp;gt;create_atoms 1 box&amp;lt;/pre&amp;gt; while the log file simply contains an acknowledgement of this &amp;lt;pre&amp;gt;Created 1000 atoms&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The create_atoms command has two arguments; the first tells LAMMPS that all of the atoms that we create will be of type 1. Every atom in the simulation has a type &amp;amp;mdash; because we will be simulating a pure fluid, containing only one chemical species, every atom will have the same type. The actual type that we assign to each atom is arbitrary &amp;amp;mdash; type 1 does not, for example, need to correspond to the element with atomic number 1 (hydrogen). If we wanted to simulate water, we might make the hydrogen atoms type 1 and the oxygen atoms type 2. We will specify the physical and chemical properties of each atom type later in the input script.&lt;br /&gt;
&lt;br /&gt;
The remaining data in the log file isn&#039;t very instructive as it stands &amp;amp;mdash; it simply contains a list of the thermodynamic properties of the simulation at certain intervals. In a few sections time, we will plot this data, but for now you can close the log file. Keep the input script open.&lt;br /&gt;
&lt;br /&gt;
===Setting the properties of the atoms===&lt;br /&gt;
&lt;br /&gt;
In addition to their positions, we also need the physical properties of the atoms to be able to perform the simulation. We set these properties on a &#039;per-type&#039; basis, so that every atom of the same type has the same mass and the same interactions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 11: Using the [https://lammps.sandia.gov/doc/Manual.html LAMMPS MANUAL], find the purpose of the following commands in the input script: [3 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mass 1 1.0&lt;br /&gt;
pair_style lj/cut 3.0&lt;br /&gt;
pair_coeff * * 1.0 1.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So far we have created 1000 atoms, and we know the starting (&amp;lt;math&amp;gt;t = 0&amp;lt;/math&amp;gt;) position for each of them. We have also set their masses, and told LAMMPS what sort of forces to calculate between them. The final thing we need to specify to completely specify the initial conditions is the velocity of each atom.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 12: Given that we are specifying &amp;lt;math&amp;gt;\mathbf{x}_i\left(0\right)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{v}_i\left(0\right)&amp;lt;/math&amp;gt;, which integration algorithm are we going to use? [1 mark]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Choosing initial velocities for the atoms is a little easier than choosing initial positions. From the statistical thermodynamics lectures, you should know that, at equilibrium, the velocities of atoms in any system must be distributed according to the [http://en.wikipedia.org/wiki/Maxwell%E2%80%93Boltzmann_distribution Maxwell-Boltzmann (MB) distribution]. If we know the masses of the atoms, and we know what temperature we want to simulate, then we can determine the relevant MB distribution function. LAMMPS is able to give every atom a random velocity whilst ensuring that overall the MB distribution is followed. This is the purpose of the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
velocity all create 1.5 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see the manual page for this command [http://lammps.sandia.gov/doc/velocity.html here], but the key sections are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;all&#039;&#039;&#039;: the &#039;&#039;group&#039;&#039; of atoms on which the command acts. &#039;&#039;&#039;all&#039;&#039;&#039; simply specifies that we want every atom to have a velocity assigned to it.&lt;br /&gt;
* &#039;&#039;&#039;1.5&#039;&#039;&#039;: the temperature, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, needed to calculate the MB distribution(in reduced units, as always)&lt;br /&gt;
&lt;br /&gt;
===Monitoring thermodynamic properties===&lt;br /&gt;
&lt;br /&gt;
We need to be sure that our simulation is correctly modelling whatever physical system we want to study. It is relatively easy to set up simulations, but how can we be sure that the &amp;quot;results&amp;quot; we get make sense? One of the best ways is to calculate from the simulation things that we can measure in experiment, and see if they agree. For example, we might want to simulate our system at a particular temperature and pressure, and measure the resulting density. If we repeat this over a range of temperatures at the same pressure, we will be able to plot an &#039;&#039;equation of state&#039;&#039;, which we could compare to experimental measurements.&lt;br /&gt;
&lt;br /&gt;
LAMMPS is able to calculate a great deal of thermodynamic information for us (you can see a full list of the properties it is able to calculate [http://lammps.sandia.gov/doc/thermo_style.html here]), but in these first simulations we are only interested in those properties specified in these commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
thermo 10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first controls which properties will be printed out in the log file. In this case, we print how much time we have simulated so far (which is &#039;&#039;not&#039;&#039; the same as how long it has taken us to simulate it!), the total energy of the atoms, their temperature, and their pressure. The second line tells LAMMPS to print this information on every 10th timestep.&lt;br /&gt;
&lt;br /&gt;
===Running the simulation===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Look at the lines below.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### SPECIFY TIMESTEP ###&lt;br /&gt;
variable timestep equal 0.001&lt;br /&gt;
variable n_steps equal floor(100/${timestep})&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
### RUN SIMULATION ###&lt;br /&gt;
run ${n_steps}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The second line (starting &amp;quot;variable timestep...&amp;quot;) tells LAMMPS that if it encounters the text ${timestep} on a subsequent line, it should replace it by the value given. In this case, the value ${timestep} is always replaced by 0.001.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ask the demonstrator if you need help.&#039;&#039;&#039;&lt;br /&gt;
It is now time to run your first simulation, submit the input script with the data file in the intro folder of the files you have downloaded Try changing the timestep - what happens when you make the timestep larger?.&lt;br /&gt;
&lt;br /&gt;
===Visualising the trajectory===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;trajectory files&#039;&#039;&#039; contain the positions of all the atoms in the simulation, recorded at a set interval (for all of these simulations, this was every ten timesteps &amp;amp;mdash; this is controlled by the &#039;&#039;&#039;dump&#039;&#039;&#039; command in the input scripts). We use a programme called [http://www.ks.uiuc.edu/Research/vmd/ &#039;&#039;&#039;VMD&#039;&#039;&#039;] to view these trajectories, which you should find is already installed on both the desktop and laptop computers. You can run VMD from the start menu with &#039;&#039;&#039;Start&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;All Programs&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;University of Illinois&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;VMD&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
====Loading a Trajectory====&lt;br /&gt;
&lt;br /&gt;
We&#039;ll start by looking at the output of the 0.015 timestep simulation. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;File&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;New Molecule&#039;&#039;&#039;. Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button, then select the relevant trajectory file. In the &#039;&#039;&#039;Determine file type&#039;&#039;&#039; dropdown, select &#039;&#039;&#039;LAMMPS Trajectory&#039;&#039;&#039;. Then click &#039;&#039;&#039;Load&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You will see that the &#039;&#039;&#039;VMD 1.9.1 OpenGL Display&#039;&#039;&#039; window now shows a horrible mess. VMD&#039;s default behaviour is to draw lines between atoms which it thinks might be chemically bonded. Our system doesn&#039;t model chemical bonds, so we want to turn this off. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;Graphics&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Representations&#039;&#039;&#039;. This shows a list of &amp;quot;representations&amp;quot; of our atoms. You will see that at the moment, there is a single representation listed, and it is selected. It will have the &#039;&#039;Lines&#039;&#039; style, the &#039;&#039;Name&#039;&#039; colour, and the selection &#039;&#039;all&#039;&#039;. &amp;quot;Selection&amp;quot; simply tells VMD which atoms we want it to draw. We want to show every atom, so the current selection is fine. The &#039;&#039;name&#039;&#039; colouring method just makes VMD give atoms colours according to their specified type. The colour isn&#039;t important to us, so we can leave this be too. The &amp;quot;style&amp;quot; tells VMD what we want it to display for each atom. Change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; from &#039;&#039;Lines&#039;&#039; to &#039;&#039;VDW&#039;&#039;. You will see that the mess of lines is replaced by a mess of low resolution, overlapping spheres. Change the &#039;&#039;&#039;Sphere Scale&#039;&#039;&#039; to 0.3, and the &#039;&#039;&#039;Sphere Resolution&#039;&#039;&#039; to 17. The result should look a little smoother. Close the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window. You will notice that in the bottom right of the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, there is a small play button. Click this, and you will see the animated version of your simulation trajectory.&lt;br /&gt;
&lt;br /&gt;
By clicking and dragging with the mouse, you can rotate the simulation box (though this may be sluggish). At any time, you can reset the view by pressing the equals key.&lt;br /&gt;
&lt;br /&gt;
====Tracking a Single Particle====&lt;br /&gt;
To illustrate the periodic boundary conditions that we are using, we are going to draw almost all of the atoms as points, but we will pick a single atom at random to draw as a sphere. This will make it easy to see how a single atom moves through the box. Reset the display using the equals key, then use the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window controls to pause the trajectory and reset it to the first trajectory (play with the different buttons until you find the one that does this). You should see the perfect cubic lattice. Use the option &#039;&#039;&#039;Display&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Orthographic&#039;&#039;&#039; to change the drawing mode, then rotate the displayed crystal so that you are looking at one vertex (looking down the 111 direction, in crystallographic terms).&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window again. Change the representation style from &#039;&#039;&#039;VDW&#039;&#039;&#039; to points, then click the &#039;&#039;&#039;Create Rep&#039;&#039;&#039; button. This creates a second representation, allowing a subset of the atoms to be drawn in a different way. The &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; box allows us to choose which atoms this representation applies to. We just want to pick two of them at random &amp;amp;mdash; VMD assigns every atom an index, from 0 to N-1. In our case, there are 1000 atoms, so choose two numbers between 0 and 999. Changed the &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; field to &amp;lt;pre&amp;gt;index i or index j&amp;lt;/pre&amp;gt; where i and j are your chosen numbers, press return, then change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; to &#039;&#039;&#039;VDW&#039;&#039;&#039;. You should now see only two atoms represented by spheres, with the rest shown as small points. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, click play. Try rotating the box, and changing the playback speed.&lt;br /&gt;
&lt;br /&gt;
You will see that sometimes one of the spheres seems to change position across the box very rapidly &amp;amp;mdash; this occurs when it reaches one periodic boundary, and is reflected back across the other face. Try playing with some of the other representation types in VMD &amp;amp;mdash; it  is a very powerful package, which is often used to render images of simulated proteins, so many of its options aren&#039;t relevant to our simple system!&lt;br /&gt;
&lt;br /&gt;
===Checking equilibration===&lt;br /&gt;
&lt;br /&gt;
When we first set up a simulation, it is very important to make sure that our system reaches an equilibrium state. We characterise equilibrium by the average values of thermodynamic quantities becoming constant (due to the approximations that we have made, there will always be fluctuations, but the average values will become constant).&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to plot the thermodynamic output of the simulation to see how long it takes to reach the equilibrium state (and indeed, whether this happens at all). Instructions are given below to import data from the LAMMPS log file into Microsoft Excel. Once you have the data in a spreadsheet, you can plot it. If you know how to use some of the other plotting software available on the chemistry computers (like Origin), you are welcome to use it.&lt;br /&gt;
&lt;br /&gt;
# Open a blank Excel workbook&lt;br /&gt;
# Choose the &#039;&#039;&#039;Data&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;From Text&#039;&#039;&#039; button&lt;br /&gt;
# Select one of your simulation log files&lt;br /&gt;
# Set the &#039;&#039;&#039;Start import at row&#039;&#039;&#039; field to &#039;&#039;&#039;25&#039;&#039;&#039; (this ignores all of the diagnostic information at the top of the file)&lt;br /&gt;
# Set the &#039;&#039;&#039;Original Data type&#039;&#039;&#039; to &#039;&#039;&#039;Delimited&#039;&#039;&#039;, then click &#039;&#039;&#039;Next&#039;&#039;&#039;&lt;br /&gt;
# Tick the &#039;&#039;&#039;Space&#039;&#039;&#039; box, and make sure that &#039;&#039;&#039;Treat consecutive delimiters as one&#039;&#039;&#039; box is ticked.&lt;br /&gt;
# On the next dialog, you can select where you want the data to be inserted. When you are happy, click &#039;&#039;&#039;OK&#039;&#039;&#039;. The data will be inserted into your spreadsheet.&lt;br /&gt;
# Scroll to the bottom of the data &amp;amp;mdash; you will see a lot of timing information from the simulation. Delete everything beyond the end of your thermodynamic data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 14: make plots of the energy, temperature, and pressure, against time for the 0.001 timestep experiment (attach a picture to your report). Does the simulation reach equilibrium? When you have done this, make a single plot which shows the energy versus time for all of the timesteps you have simulated (again, attach a picture to your report). Of the timesteps that you used, which timestep will you use for subsequent simulations and why? [9 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation&amp;diff=734568</id>
		<title>Third year simulation experiment/Introduction to molecular dynamics simulation</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation&amp;diff=734568"/>
		<updated>2018-10-08T09:59:22Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Atomic Forces */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the second section of the third year simulation experiment. You can return to the previous section, [[Third year simulation experiment/Files to download|Downloading Files]], or jump ahead to the next section, [[Third year simulation experiment/Equilibration|Equilibration]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;This section contains background information about the theory of molecular dynamics simulations. It contains a number of relatively short exercises that you must complete as part of your lab write-up. These are labelled in bold and preceded by the word TASK in large print. It is recommended that you read the information on this page before carrying on with the rest of the experiment, but you are encouraged to save the TASKS for later; you can attempt them while you wait for long simulations to finish.&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this section, we briefly discuss the theory behind molecular dynamics (MD) simulations. When we perform MD, we calculate how a particular set of atoms move over time. Using statistical physics, we can use the positions, velocities, and forces, of the atoms to calculate thermodynamic quantities like temperature and pressure.&lt;br /&gt;
&lt;br /&gt;
==Theory==&lt;br /&gt;
&lt;br /&gt;
===The Classical Particle Approximation===&lt;br /&gt;
&lt;br /&gt;
As you may remember from your quantum chemistry lectures, it is very straightforward to write down the Schroedinger equation that describes the behaviour of any particular chemical system. For anything more complicated than a hydrogen atom, however, it is impossible to solve exactly. Even approximate solutions can be extremely computationally demanding. To be able to simulate a real system, we have to make some approximations.&lt;br /&gt;
&lt;br /&gt;
It turns out that, to a very good approximation, we can assume that atoms behave as classical particles. Imagine a collection of &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms. Each one of them will interact with all of the others, and so each atom will feel a force. Newton&#039;s second law tell us that that force causes the atom to accelerate.&lt;br /&gt;
&lt;br /&gt;
Throughout this section, we are going to use the following notation:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathbf{F}_i&amp;lt;/math&amp;gt; is the force acting on atom i.&lt;br /&gt;
* &amp;lt;math&amp;gt;m_i&amp;lt;/math&amp;gt; is the mass of atom i.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathbf{a}_i&amp;lt;/math&amp;gt; is the acceleration of atom i, the rate of change of its velocity.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathbf{v}_i&amp;lt;/math&amp;gt; is the velocity of atom i.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathbf{x}_i&amp;lt;/math&amp;gt; is the position of atom i.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{F}_i = m_i \mathbf{a}_i = m_i \frac{\mathrm{d}\mathbf{v}_i}{\mathrm{d}t} = m_i \frac{\mathrm{d}^2 \mathbf{x}_i}{\mathrm{d}t^2} \ \ (1)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a second order differential equation for the positions of the atoms &amp;amp;mdash; if we know how the force, &amp;lt;math&amp;gt;\mathbf{F}_i&amp;lt;/math&amp;gt;, behaves as a function of time, then we can determine the atomic positions and velocities at any time we like. Our system of &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms has &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; of these equations, one for each atom. This is one of the reasons that computer simulations are needed &amp;amp;mdash; if we want to model the behaviour of a liquid, we can hardly solve the necessary number of equations by hand.&lt;br /&gt;
&lt;br /&gt;
===Numerical Integration===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Numerical integration is a rather complex topic. In particular, the notation used below can be quite intimidating. Remember that you are encouraged to ask for help from the demonstrator if you want to discuss any part of this experiment!&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are a number of numerical algorithms to perform a molecular dynamics simulation, two are presented here- The Classical Verlet algorithm and The Velocity-Verlet algorithm.&lt;br /&gt;
&lt;br /&gt;
====Verlet Algorithm====&lt;br /&gt;
&lt;br /&gt;
To solve these equations numerically we have to &#039;&#039;discretise&#039;&#039; the problem: rather than treating the atomic positions, velocities, and forces as continuous functions of time, we break our simulation up into a sequence of &#039;&#039;&#039;timesteps&#039;&#039;&#039;, each of length &amp;lt;math&amp;gt;\delta t&amp;lt;/math&amp;gt;. This process is illustrated for a simple function in &#039;&#039;&#039;figure 1&#039;&#039;&#039;. The method that we are going to use to solve Newton&#039;s law for our atoms is usually called the Verlet algorithm (although it is an old method, and has been &#039;rediscovered&#039; many times!). To understand its origin, we will begin with a brief derivation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-Discretisation.png|300px|thumb|center|&#039;&#039;&#039;Figure 1&#039;&#039;&#039;: Discretisation of sin(x) between 0 and &amp;lt;math&amp;gt;2\pi&amp;lt;/math&amp;gt;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We denote the position of an atom, &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;, at time &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;\mathbf{x}_i \left(t\right)&amp;lt;/math&amp;gt;. Similarly, &amp;lt;math&amp;gt;\mathbf{v}_i \left(t\right)&amp;lt;/math&amp;gt; is the velocity of that atom at the same time. What we want to know is the position of the atoms at the next timestep, &amp;lt;math&amp;gt;t + \delta t&amp;lt;/math&amp;gt;. The basic Verlet algorithm is shown in &#039;&#039;&#039;figure 2&#039;&#039;&#039; - knowing a set of initial conditions the algorithm calculates forces and by Newton&#039;s second law, we can update the positions of a set of particles are a time &amp;lt;math&amp;gt;t + \delta t&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-Verlet-flowchart.svg|300px|thumb|center|&#039;&#039;&#039;Figure 2&#039;&#039;&#039;: Steps to implement the classic Verlet algorithm.]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt; TASK 1: By taking Taylor expansions of  &amp;lt;math&amp;gt;x(t + \delta t)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;x(t - \delta t)&amp;lt;/math&amp;gt;, write general expressions for them up to the fourth order &amp;lt;math&amp;gt;\mathcal{O}\left(\delta t^4\right)&amp;lt;/math&amp;gt; &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt; Having written these expressions, derive the formula in figure 2 to update positions as used in the classical Verlet algorithm &amp;lt;math&amp;gt; x(t + \delta t) \approx 2x_{i}(t) - x_{i}(t-\delta t) + \frac{F_{i}(t)}{m} \delta t^{2}&amp;lt;/math&amp;gt; by using Newton&#039;s second law to replace &amp;lt;math&amp;gt;\frac{\mathrm{d}^2\mathbf{x}_i\left(t\right)}{\mathrm{d}t^2}&amp;lt;/math&amp;gt; [6 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Using this last equation, we can use a sequence of steps like those shown in &#039;&#039;&#039;figure 2&#039;&#039;&#039; to get the positions. At no point are the velocities calculated in this method!&lt;br /&gt;
&lt;br /&gt;
====Velocity Verlet Algorithm====&lt;br /&gt;
&lt;br /&gt;
If we assume that the acceleration of an atom depends only on its position and not its velocity, then we are able to come up with a new algorithm that lets us calculate atomic velocities explicitly as shown in &#039;&#039;&#039;figure 3&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-VelocityVerlet-flowchart.svg|300px|thumb|center|&#039;&#039;&#039;Figure 3&#039;&#039;&#039;: Steps to implement the velocity Verlet algorithm.]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We start by noting that&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{v}_i\left(t + \delta t\right) = \mathbf{v}_i\left(t\right) + \frac{\mathbf{a}_i\left(t\right) + \mathbf{a}_i\left(t + \delta t\right)}{2}\delta t \ \ (6)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can Taylor expand the velocity by half a step, instead of a full step.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{v}_i\left(t + \frac{1}{2}\delta t\right) = \mathbf{v}_i\left(t\right) + \frac{1}{2} \mathbf{a}_i\left(t\right)\delta t \ \ (7)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then substitute this into equation (2) to obtain an accuracy up to &amp;lt;math&amp;gt; \delta t ^{2} &amp;lt;/math&amp;gt;. Notice that terms up to &amp;lt;math&amp;gt; \delta t ^{2} &amp;lt;/math&amp;gt; in equation (2) can be written:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; \mathbf{x}_{i} (t + \delta t) = \mathbf{x}_{i} (t) + \mathbf{v}(t) \delta t + \frac{1}{2} \mathbf{a}(t) \delta t ^{2} &amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{x}_i\left(t + \delta t\right) = \mathbf{x}_i\left(t\right) + \mathbf{v}_i\left(t + \frac{1}{2}\delta t\right)\delta t \ \ (8)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When we know the updated atomic positions, we can calculate new forces, &amp;lt;math&amp;gt;\mathbf{a}_i\left(t + \delta t\right)&amp;lt;/math&amp;gt;. Finally, we substitute equation (7) into equation (6) to get the new velocities &amp;lt;math&amp;gt;\mathbf{v}_i\left(t + \delta t\right)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{v}_i\left(t + \delta t\right) = \mathbf{v}_i\left(t + \frac{1}{2}\delta t\right) + \frac{1}{2}\mathbf{a}_i\left(t + \delta t\right)\delta t \ \ (9)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that for both numerical integration algorithms, the first step is &amp;quot;specify initial conditions&amp;quot;. When using the Verlet algorithm, we need to know the starting positions of the atoms (&amp;lt;math&amp;gt;\mathbf{x}_i\left(0\right)&amp;lt;/math&amp;gt;), and their positions one timestep in the past (&amp;lt;math&amp;gt;\mathbf{x}_i\left(-\delta t\right)&amp;lt;/math&amp;gt;). If the velocity-Verlet algorithm is used, then we have to know the  the starting positions of the atoms (&amp;lt;math&amp;gt;\mathbf{x}_i\left(0\right)&amp;lt;/math&amp;gt;) and their velocities at the same time (&amp;lt;math&amp;gt;\mathbf{v}_i\left(0\right)&amp;lt;/math&amp;gt;). For this reason, we often start new simulations by using the output of older ones. If, however, you are performing your first simulations of a system (as we are now), then you must choose your initial conditions. The simulation software that we will use is able to do this for us, and this will be explained in the next section.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt; TASK 2: What could be an advantage of the Velocity-Verlet algorithm over the classical Verlet algorithm? [1 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Atomic Forces===&lt;br /&gt;
&lt;br /&gt;
Since we can&#039;t reasonably solve the equations from quantum physics necessary to determine the forces acting on a given configuration of atoms, we have to make approximations. We know from classical physics that the force acting on an object is determined by the potential that it experiences:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{F}_i = - \frac{\mathrm{d}U\left(\mathbf{r}^N\right)}{\mathrm{d}\mathbf{r}_i}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The shorthand notation &amp;lt;math&amp;gt;\mathbf{r}^N&amp;lt;/math&amp;gt; stands for the position vectors of &#039;&#039;&#039;every&#039;&#039;&#039; atom in system. In principle, the force that a single atom feels is determined by the position of every other atom in the simulation. All we then need to do is to find a function &amp;lt;math&amp;gt;U&amp;lt;/math&amp;gt; that captures all the key physics of the interatomic interactions in the system. For many simple liquids, it turns out that we can model the interactions between each pair of atoms extremely well using the Lennard-Jones potential. Overall, U takes the form:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;U\left(\mathbf{r}^N\right) = \sum_i^N \sum_{i \neq j}^{N} \left\{ 4\epsilon \left( \frac{\sigma^{12}}{r_{ij}^{12}} - \frac{\sigma^6}{r_{ij}^6} \right) \right\} \ \ (10)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 3: For a single Lennard-Jones interaction, &amp;lt;math&amp;gt;\phi\left(r\right) = 4\epsilon \left( \frac{\sigma^{12}}{r^{12}} - \frac{\sigma^6}{r^6} \right)&amp;lt;/math&amp;gt;, find the separation, &amp;lt;math&amp;gt;r_0&amp;lt;/math&amp;gt;, at which the potential energy is zero. What is the force at this separation? Find the equilibrium separation, &amp;lt;math&amp;gt;r_{eq}&amp;lt;/math&amp;gt;, and work out the well depth (&amp;lt;math&amp;gt;\phi\left(r_{eq}\right)&amp;lt;/math&amp;gt;). Evaluate the integrals &amp;lt;math&amp;gt;\int_{2\sigma}^\infty \phi\left(r\right)\mathrm{d}r&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\int_{2.5\sigma}^\infty \phi\left(r\right)\mathrm{d}r&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\int_{3\sigma}^\infty \phi\left(r\right)\mathrm{d}r&amp;lt;/math&amp;gt; when &amp;lt;math&amp;gt;\sigma = \epsilon = 1.0&amp;lt;/math&amp;gt; [4 marks]&amp;lt;/big&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
====Periodic Boundary Conditions====&lt;br /&gt;
&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-Box.png|200px|thumb|right|&#039;&#039;&#039;Figure 4&#039;&#039;&#039;: Diagram of a simulation box containing 2139 atoms. The blue lines indicate the boundaries of the box.]]&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-Periodic.svg|300px|thumb|left|&#039;&#039;&#039;Figure 5&#039;&#039;&#039;: Periodic boundary conditions in two dimensions.]]&lt;br /&gt;
&lt;br /&gt;
We cannot simulate realistic volumes of liquid. In fact, in our simulations, &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; will be between &amp;lt;math&amp;gt;1000&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;10000&amp;lt;/math&amp;gt;. The following task should illustrate why this must be so.&lt;br /&gt;
&lt;br /&gt;
In order for our simulations to approximate a bulk liquid, we have to use a computational trick. The atoms in the simulation are enclosed in a simulation box, of fixed dimensions (&#039;&#039;&#039;figure 4&#039;&#039;&#039;). This box is very often a cuboid, but parallelepipeds can also be used (and this can be very useful when simulating crystal structures). We pretend that we have repeated our box infinitely in all directions, so that the atoms at the very edges are not exposed to a vacuum. This is illustrated in two dimensions in &#039;&#039;&#039;figure 5&#039;&#039;&#039;. The darker coloured atoms in the central box are the &amp;quot;real&amp;quot; atoms. The faded atoms in the outer four boxes are the replicas. When an atom crosses the boundary of the box, one of its replicas enters the box through the opposite face. In this way, the number of atoms inside the box is always constant.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 4: Consider an atom at position &amp;lt;math&amp;gt;\left(0.5, 0.5, 0.5\right)&amp;lt;/math&amp;gt; in a cubic simulation box which runs from &amp;lt;math&amp;gt;\left(0, 0, 0\right)&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;\left(1, 1, 1\right)&amp;lt;/math&amp;gt;. In a single timestep, it moves along the vector &amp;lt;math&amp;gt;\left(0.7, 0.6, 0.2\right)&amp;lt;/math&amp;gt;. At what point does it end up, &#039;&#039;after the periodic boundary conditions have been applied&#039;&#039;? [1 marks]&#039;&#039;&#039; &amp;lt;/big&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
====Truncation====&lt;br /&gt;
&lt;br /&gt;
Periodic boundary conditions introduce their own problems. When we defined our potential function (equation 10), we specified that it depended on all possible pairs of atoms. If we have an infinite number of replicas of our system, how can we avoid calculating an infinite number of pair interactions?&lt;br /&gt;
&lt;br /&gt;
Think about the three integrals you calculated for the Lennard-Jones potential task. They represent the area under the Lennard-Jones potential curve between some specified distance (&amp;lt;math&amp;gt;2\sigma&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;2.5\sigma&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;3\sigma&amp;lt;/math&amp;gt;), and infinite separation (where there is no interaction). You should find that this value becomes rather small as the near distance is increased! The attractive &amp;lt;math&amp;gt;\frac{1}{r^6}&amp;lt;/math&amp;gt; part of the potential dominates here, and this decays rapidly with &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. We assume that this means that there is a distance beyond which the interaction is so small that we can safely ignore it. In fact, in most simulations this is chosen to be something close to &amp;lt;math&amp;gt;2.5\sigma&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;3\sigma&amp;lt;/math&amp;gt;. When the forces are calculated, we only calculate interactions between a pair of atoms if their separation is less than this cutoff.&lt;br /&gt;
&lt;br /&gt;
====Reduced Units====&lt;br /&gt;
&lt;br /&gt;
It is typical when using Lennard-Jones interactions to work in reduced units. By this, we mean that all quantities in our simulation are divided by scaling factors &amp;amp;mdash; for example, distances are divided by &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt;. The result of this is that the values become more manageable: all values that we might work out are typically around 1, rather than &amp;lt;math&amp;gt;1\times 10^{-10}&amp;lt;/math&amp;gt; (in the case of distance), &amp;lt;math&amp;gt;300&amp;lt;/math&amp;gt; (in the case of temperature), or &amp;lt;math&amp;gt;1\times 10^{-19}&amp;lt;/math&amp;gt; (in the case of energy).&lt;br /&gt;
&lt;br /&gt;
We denote these reduced quantities by a star, and they take the following conversion factors:&lt;br /&gt;
&lt;br /&gt;
* distance &amp;lt;math&amp;gt;r^* = \frac{r}{\sigma}&amp;lt;/math&amp;gt;&lt;br /&gt;
* energy &amp;lt;math&amp;gt;E^* = \frac{E}{\epsilon}&amp;lt;/math&amp;gt;&lt;br /&gt;
* temperature &amp;lt;math&amp;gt;T^* = \frac{k_BT}{\epsilon}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 5: The Lennard-Jones parameters for argon are &amp;lt;math&amp;gt;\sigma = 0.34\mathrm{nm}, \epsilon\ /\ k_B= 120 \mathrm{K}&amp;lt;/math&amp;gt;. If the LJ cutoff is &amp;lt;math&amp;gt;r^* = 3.2&amp;lt;/math&amp;gt;, what is it in real units? What is the well depth in &amp;lt;math&amp;gt;\mathrm{kJ\ mol}^{-1}&amp;lt;/math&amp;gt;? What is the reduced temperature &amp;lt;math&amp;gt;T^* = 1.5&amp;lt;/math&amp;gt; in real units? [1 marks]&amp;lt;/big&amp;gt; &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the second section of the third year simulation experiment. You can return to the previous section, [[Third year simulation experiment/Running your first simulation|Running your first simulation]], or jump ahead to the next section, [[Third year simulation experiment/Equilibration|Equilibration]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation&amp;diff=734567</id>
		<title>Third year simulation experiment/Introduction to molecular dynamics simulation</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation&amp;diff=734567"/>
		<updated>2018-10-08T09:58:19Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Velocity Verlet Algorithm */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the second section of the third year simulation experiment. You can return to the previous section, [[Third year simulation experiment/Files to download|Downloading Files]], or jump ahead to the next section, [[Third year simulation experiment/Equilibration|Equilibration]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;This section contains background information about the theory of molecular dynamics simulations. It contains a number of relatively short exercises that you must complete as part of your lab write-up. These are labelled in bold and preceded by the word TASK in large print. It is recommended that you read the information on this page before carrying on with the rest of the experiment, but you are encouraged to save the TASKS for later; you can attempt them while you wait for long simulations to finish.&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this section, we briefly discuss the theory behind molecular dynamics (MD) simulations. When we perform MD, we calculate how a particular set of atoms move over time. Using statistical physics, we can use the positions, velocities, and forces, of the atoms to calculate thermodynamic quantities like temperature and pressure.&lt;br /&gt;
&lt;br /&gt;
==Theory==&lt;br /&gt;
&lt;br /&gt;
===The Classical Particle Approximation===&lt;br /&gt;
&lt;br /&gt;
As you may remember from your quantum chemistry lectures, it is very straightforward to write down the Schroedinger equation that describes the behaviour of any particular chemical system. For anything more complicated than a hydrogen atom, however, it is impossible to solve exactly. Even approximate solutions can be extremely computationally demanding. To be able to simulate a real system, we have to make some approximations.&lt;br /&gt;
&lt;br /&gt;
It turns out that, to a very good approximation, we can assume that atoms behave as classical particles. Imagine a collection of &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms. Each one of them will interact with all of the others, and so each atom will feel a force. Newton&#039;s second law tell us that that force causes the atom to accelerate.&lt;br /&gt;
&lt;br /&gt;
Throughout this section, we are going to use the following notation:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathbf{F}_i&amp;lt;/math&amp;gt; is the force acting on atom i.&lt;br /&gt;
* &amp;lt;math&amp;gt;m_i&amp;lt;/math&amp;gt; is the mass of atom i.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathbf{a}_i&amp;lt;/math&amp;gt; is the acceleration of atom i, the rate of change of its velocity.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathbf{v}_i&amp;lt;/math&amp;gt; is the velocity of atom i.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathbf{x}_i&amp;lt;/math&amp;gt; is the position of atom i.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{F}_i = m_i \mathbf{a}_i = m_i \frac{\mathrm{d}\mathbf{v}_i}{\mathrm{d}t} = m_i \frac{\mathrm{d}^2 \mathbf{x}_i}{\mathrm{d}t^2} \ \ (1)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a second order differential equation for the positions of the atoms &amp;amp;mdash; if we know how the force, &amp;lt;math&amp;gt;\mathbf{F}_i&amp;lt;/math&amp;gt;, behaves as a function of time, then we can determine the atomic positions and velocities at any time we like. Our system of &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms has &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; of these equations, one for each atom. This is one of the reasons that computer simulations are needed &amp;amp;mdash; if we want to model the behaviour of a liquid, we can hardly solve the necessary number of equations by hand.&lt;br /&gt;
&lt;br /&gt;
===Numerical Integration===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Numerical integration is a rather complex topic. In particular, the notation used below can be quite intimidating. Remember that you are encouraged to ask for help from the demonstrator if you want to discuss any part of this experiment!&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are a number of numerical algorithms to perform a molecular dynamics simulation, two are presented here- The Classical Verlet algorithm and The Velocity-Verlet algorithm.&lt;br /&gt;
&lt;br /&gt;
====Verlet Algorithm====&lt;br /&gt;
&lt;br /&gt;
To solve these equations numerically we have to &#039;&#039;discretise&#039;&#039; the problem: rather than treating the atomic positions, velocities, and forces as continuous functions of time, we break our simulation up into a sequence of &#039;&#039;&#039;timesteps&#039;&#039;&#039;, each of length &amp;lt;math&amp;gt;\delta t&amp;lt;/math&amp;gt;. This process is illustrated for a simple function in &#039;&#039;&#039;figure 1&#039;&#039;&#039;. The method that we are going to use to solve Newton&#039;s law for our atoms is usually called the Verlet algorithm (although it is an old method, and has been &#039;rediscovered&#039; many times!). To understand its origin, we will begin with a brief derivation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-Discretisation.png|300px|thumb|center|&#039;&#039;&#039;Figure 1&#039;&#039;&#039;: Discretisation of sin(x) between 0 and &amp;lt;math&amp;gt;2\pi&amp;lt;/math&amp;gt;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We denote the position of an atom, &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;, at time &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;\mathbf{x}_i \left(t\right)&amp;lt;/math&amp;gt;. Similarly, &amp;lt;math&amp;gt;\mathbf{v}_i \left(t\right)&amp;lt;/math&amp;gt; is the velocity of that atom at the same time. What we want to know is the position of the atoms at the next timestep, &amp;lt;math&amp;gt;t + \delta t&amp;lt;/math&amp;gt;. The basic Verlet algorithm is shown in &#039;&#039;&#039;figure 2&#039;&#039;&#039; - knowing a set of initial conditions the algorithm calculates forces and by Newton&#039;s second law, we can update the positions of a set of particles are a time &amp;lt;math&amp;gt;t + \delta t&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-Verlet-flowchart.svg|300px|thumb|center|&#039;&#039;&#039;Figure 2&#039;&#039;&#039;: Steps to implement the classic Verlet algorithm.]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt; TASK 1: By taking Taylor expansions of  &amp;lt;math&amp;gt;x(t + \delta t)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;x(t - \delta t)&amp;lt;/math&amp;gt;, write general expressions for them up to the fourth order &amp;lt;math&amp;gt;\mathcal{O}\left(\delta t^4\right)&amp;lt;/math&amp;gt; &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt; Having written these expressions, derive the formula in figure 2 to update positions as used in the classical Verlet algorithm &amp;lt;math&amp;gt; x(t + \delta t) \approx 2x_{i}(t) - x_{i}(t-\delta t) + \frac{F_{i}(t)}{m} \delta t^{2}&amp;lt;/math&amp;gt; by using Newton&#039;s second law to replace &amp;lt;math&amp;gt;\frac{\mathrm{d}^2\mathbf{x}_i\left(t\right)}{\mathrm{d}t^2}&amp;lt;/math&amp;gt; [6 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Using this last equation, we can use a sequence of steps like those shown in &#039;&#039;&#039;figure 2&#039;&#039;&#039; to get the positions. At no point are the velocities calculated in this method!&lt;br /&gt;
&lt;br /&gt;
====Velocity Verlet Algorithm====&lt;br /&gt;
&lt;br /&gt;
If we assume that the acceleration of an atom depends only on its position and not its velocity, then we are able to come up with a new algorithm that lets us calculate atomic velocities explicitly as shown in &#039;&#039;&#039;figure 3&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-VelocityVerlet-flowchart.svg|300px|thumb|center|&#039;&#039;&#039;Figure 3&#039;&#039;&#039;: Steps to implement the velocity Verlet algorithm.]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We start by noting that&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{v}_i\left(t + \delta t\right) = \mathbf{v}_i\left(t\right) + \frac{\mathbf{a}_i\left(t\right) + \mathbf{a}_i\left(t + \delta t\right)}{2}\delta t \ \ (6)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can Taylor expand the velocity by half a step, instead of a full step.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{v}_i\left(t + \frac{1}{2}\delta t\right) = \mathbf{v}_i\left(t\right) + \frac{1}{2} \mathbf{a}_i\left(t\right)\delta t \ \ (7)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then substitute this into equation (2) to obtain an accuracy up to &amp;lt;math&amp;gt; \delta t ^{2} &amp;lt;/math&amp;gt;. Notice that terms up to &amp;lt;math&amp;gt; \delta t ^{2} &amp;lt;/math&amp;gt; in equation (2) can be written:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; \mathbf{x}_{i} (t + \delta t) = \mathbf{x}_{i} (t) + \mathbf{v}(t) \delta t + \frac{1}{2} \mathbf{a}(t) \delta t ^{2} &amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{x}_i\left(t + \delta t\right) = \mathbf{x}_i\left(t\right) + \mathbf{v}_i\left(t + \frac{1}{2}\delta t\right)\delta t \ \ (8)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When we know the updated atomic positions, we can calculate new forces, &amp;lt;math&amp;gt;\mathbf{a}_i\left(t + \delta t\right)&amp;lt;/math&amp;gt;. Finally, we substitute equation (7) into equation (6) to get the new velocities &amp;lt;math&amp;gt;\mathbf{v}_i\left(t + \delta t\right)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{v}_i\left(t + \delta t\right) = \mathbf{v}_i\left(t + \frac{1}{2}\delta t\right) + \frac{1}{2}\mathbf{a}_i\left(t + \delta t\right)\delta t \ \ (9)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that for both numerical integration algorithms, the first step is &amp;quot;specify initial conditions&amp;quot;. When using the Verlet algorithm, we need to know the starting positions of the atoms (&amp;lt;math&amp;gt;\mathbf{x}_i\left(0\right)&amp;lt;/math&amp;gt;), and their positions one timestep in the past (&amp;lt;math&amp;gt;\mathbf{x}_i\left(-\delta t\right)&amp;lt;/math&amp;gt;). If the velocity-Verlet algorithm is used, then we have to know the  the starting positions of the atoms (&amp;lt;math&amp;gt;\mathbf{x}_i\left(0\right)&amp;lt;/math&amp;gt;) and their velocities at the same time (&amp;lt;math&amp;gt;\mathbf{v}_i\left(0\right)&amp;lt;/math&amp;gt;). For this reason, we often start new simulations by using the output of older ones. If, however, you are performing your first simulations of a system (as we are now), then you must choose your initial conditions. The simulation software that we will use is able to do this for us, and this will be explained in the next section.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt; TASK 2: What could be an advantage of the Velocity-Verlet algorithm over the classical Verlet algorithm? [1 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Atomic Forces===&lt;br /&gt;
&lt;br /&gt;
Since we can&#039;t reasonably solve the equations from quantum physics necessary to determine the forces acting on a given configuration of atoms, we have to make approximations. We know from classical physics that the force acting on an object is determined by the potential that it experiences:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{F}_i = - \frac{\mathrm{d}U\left(\mathbf{r}^N\right)}{\mathrm{d}\mathbf{r}_i}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The shorthand notation &amp;lt;math&amp;gt;\mathbf{r}^N&amp;lt;/math&amp;gt; stands for the position vectors of &#039;&#039;&#039;every&#039;&#039;&#039; atom in system. In principle, the force that a single atom feels is determined by the position of every other atom in the simulation. All we then need to do is to find a function &amp;lt;math&amp;gt;U&amp;lt;/math&amp;gt; that captures all the key physics of the interatomic interactions in the system. For many simple liquids, it turns out that we can model the interactions between each pair of atoms extremely well using the Lennard-Jones potential. Overall, U takes the form:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;U\left(\mathbf{r}^N\right) = \sum_i^N \sum_{i \neq j}^{N} \left\{ 4\epsilon \left( \frac{\sigma^{12}}{r_{ij}^{12}} - \frac{\sigma^6}{r_{ij}^6} \right) \right\} \ \ (10)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 4: For a single Lennard-Jones interaction, &amp;lt;math&amp;gt;\phi\left(r\right) = 4\epsilon \left( \frac{\sigma^{12}}{r^{12}} - \frac{\sigma^6}{r^6} \right)&amp;lt;/math&amp;gt;, find the separation, &amp;lt;math&amp;gt;r_0&amp;lt;/math&amp;gt;, at which the potential energy is zero. What is the force at this separation? Find the equilibrium separation, &amp;lt;math&amp;gt;r_{eq}&amp;lt;/math&amp;gt;, and work out the well depth (&amp;lt;math&amp;gt;\phi\left(r_{eq}\right)&amp;lt;/math&amp;gt;). Evaluate the integrals &amp;lt;math&amp;gt;\int_{2\sigma}^\infty \phi\left(r\right)\mathrm{d}r&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\int_{2.5\sigma}^\infty \phi\left(r\right)\mathrm{d}r&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\int_{3\sigma}^\infty \phi\left(r\right)\mathrm{d}r&amp;lt;/math&amp;gt; when &amp;lt;math&amp;gt;\sigma = \epsilon = 1.0&amp;lt;/math&amp;gt; [4 marks]&amp;lt;/big&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
====Periodic Boundary Conditions====&lt;br /&gt;
&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-Box.png|200px|thumb|right|&#039;&#039;&#039;Figure 4&#039;&#039;&#039;: Diagram of a simulation box containing 2139 atoms. The blue lines indicate the boundaries of the box.]]&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-Periodic.svg|300px|thumb|left|&#039;&#039;&#039;Figure 5&#039;&#039;&#039;: Periodic boundary conditions in two dimensions.]]&lt;br /&gt;
&lt;br /&gt;
We cannot simulate realistic volumes of liquid. In fact, in our simulations, &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; will be between &amp;lt;math&amp;gt;1000&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;10000&amp;lt;/math&amp;gt;. The following task should illustrate why this must be so.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 5: Estimate the number of water molecules in 1ml of water under standard conditions. Estimate the volume of &amp;lt;math&amp;gt;10000&amp;lt;/math&amp;gt; water molecules under standard conditions [3 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In order for our simulations to approximate a bulk liquid, we have to use a computational trick. The atoms in the simulation are enclosed in a simulation box, of fixed dimensions (&#039;&#039;&#039;figure 4&#039;&#039;&#039;). This box is very often a cuboid, but parallelepipeds can also be used (and this can be very useful when simulating crystal structures). We pretend that we have repeated our box infinitely in all directions, so that the atoms at the very edges are not exposed to a vacuum. This is illustrated in two dimensions in &#039;&#039;&#039;figure 5&#039;&#039;&#039;. The darker coloured atoms in the central box are the &amp;quot;real&amp;quot; atoms. The faded atoms in the outer four boxes are the replicas. When an atom crosses the boundary of the box, one of its replicas enters the box through the opposite face. In this way, the number of atoms inside the box is always constant.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 6: Consider an atom at position &amp;lt;math&amp;gt;\left(0.5, 0.5, 0.5\right)&amp;lt;/math&amp;gt; in a cubic simulation box which runs from &amp;lt;math&amp;gt;\left(0, 0, 0\right)&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;\left(1, 1, 1\right)&amp;lt;/math&amp;gt;. In a single timestep, it moves along the vector &amp;lt;math&amp;gt;\left(0.7, 0.6, 0.2\right)&amp;lt;/math&amp;gt;. At what point does it end up, &#039;&#039;after the periodic boundary conditions have been applied&#039;&#039;? [2 marks]&#039;&#039;&#039; &amp;lt;/big&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
====Truncation====&lt;br /&gt;
&lt;br /&gt;
Periodic boundary conditions introduce their own problems. When we defined our potential function (equation 10), we specified that it depended on all possible pairs of atoms. If we have an infinite number of replicas of our system, how can we avoid calculating an infinite number of pair interactions?&lt;br /&gt;
&lt;br /&gt;
Think about the three integrals you calculated for the Lennard-Jones potential task. They represent the area under the Lennard-Jones potential curve between some specified distance (&amp;lt;math&amp;gt;2\sigma&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;2.5\sigma&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;3\sigma&amp;lt;/math&amp;gt;), and infinite separation (where there is no interaction). You should find that this value becomes rather small as the near distance is increased! The attractive &amp;lt;math&amp;gt;\frac{1}{r^6}&amp;lt;/math&amp;gt; part of the potential dominates here, and this decays rapidly with &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. We assume that this means that there is a distance beyond which the interaction is so small that we can safely ignore it. In fact, in most simulations this is chosen to be something close to &amp;lt;math&amp;gt;2.5\sigma&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;3\sigma&amp;lt;/math&amp;gt;. When the forces are calculated, we only calculate interactions between a pair of atoms if their separation is less than this cutoff.&lt;br /&gt;
&lt;br /&gt;
====Reduced Units====&lt;br /&gt;
&lt;br /&gt;
It is typical when using Lennard-Jones interactions to work in reduced units. By this, we mean that all quantities in our simulation are divided by scaling factors &amp;amp;mdash; for example, distances are divided by &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt;. The result of this is that the values become more manageable: all values that we might work out are typically around 1, rather than &amp;lt;math&amp;gt;1\times 10^{-10}&amp;lt;/math&amp;gt; (in the case of distance), &amp;lt;math&amp;gt;300&amp;lt;/math&amp;gt; (in the case of temperature), or &amp;lt;math&amp;gt;1\times 10^{-19}&amp;lt;/math&amp;gt; (in the case of energy).&lt;br /&gt;
&lt;br /&gt;
We denote these reduced quantities by a star, and they take the following conversion factors:&lt;br /&gt;
&lt;br /&gt;
* distance &amp;lt;math&amp;gt;r^* = \frac{r}{\sigma}&amp;lt;/math&amp;gt;&lt;br /&gt;
* energy &amp;lt;math&amp;gt;E^* = \frac{E}{\epsilon}&amp;lt;/math&amp;gt;&lt;br /&gt;
* temperature &amp;lt;math&amp;gt;T^* = \frac{k_BT}{\epsilon}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 7: The Lennard-Jones parameters for argon are &amp;lt;math&amp;gt;\sigma = 0.34\mathrm{nm}, \epsilon\ /\ k_B= 120 \mathrm{K}&amp;lt;/math&amp;gt;. If the LJ cutoff is &amp;lt;math&amp;gt;r^* = 3.2&amp;lt;/math&amp;gt;, what is it in real units? What is the well depth in &amp;lt;math&amp;gt;\mathrm{kJ\ mol}^{-1}&amp;lt;/math&amp;gt;? What is the reduced temperature &amp;lt;math&amp;gt;T^* = 1.5&amp;lt;/math&amp;gt; in real units? [2 marks]&amp;lt;/big&amp;gt; &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the second section of the third year simulation experiment. You can return to the previous section, [[Third year simulation experiment/Running your first simulation|Running your first simulation]], or jump ahead to the next section, [[Third year simulation experiment/Equilibration|Equilibration]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation&amp;diff=734566</id>
		<title>Third year simulation experiment/Introduction to molecular dynamics simulation</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation&amp;diff=734566"/>
		<updated>2018-10-08T09:57:45Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Verlet Algorithm */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the second section of the third year simulation experiment. You can return to the previous section, [[Third year simulation experiment/Files to download|Downloading Files]], or jump ahead to the next section, [[Third year simulation experiment/Equilibration|Equilibration]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;This section contains background information about the theory of molecular dynamics simulations. It contains a number of relatively short exercises that you must complete as part of your lab write-up. These are labelled in bold and preceded by the word TASK in large print. It is recommended that you read the information on this page before carrying on with the rest of the experiment, but you are encouraged to save the TASKS for later; you can attempt them while you wait for long simulations to finish.&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this section, we briefly discuss the theory behind molecular dynamics (MD) simulations. When we perform MD, we calculate how a particular set of atoms move over time. Using statistical physics, we can use the positions, velocities, and forces, of the atoms to calculate thermodynamic quantities like temperature and pressure.&lt;br /&gt;
&lt;br /&gt;
==Theory==&lt;br /&gt;
&lt;br /&gt;
===The Classical Particle Approximation===&lt;br /&gt;
&lt;br /&gt;
As you may remember from your quantum chemistry lectures, it is very straightforward to write down the Schroedinger equation that describes the behaviour of any particular chemical system. For anything more complicated than a hydrogen atom, however, it is impossible to solve exactly. Even approximate solutions can be extremely computationally demanding. To be able to simulate a real system, we have to make some approximations.&lt;br /&gt;
&lt;br /&gt;
It turns out that, to a very good approximation, we can assume that atoms behave as classical particles. Imagine a collection of &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms. Each one of them will interact with all of the others, and so each atom will feel a force. Newton&#039;s second law tell us that that force causes the atom to accelerate.&lt;br /&gt;
&lt;br /&gt;
Throughout this section, we are going to use the following notation:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathbf{F}_i&amp;lt;/math&amp;gt; is the force acting on atom i.&lt;br /&gt;
* &amp;lt;math&amp;gt;m_i&amp;lt;/math&amp;gt; is the mass of atom i.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathbf{a}_i&amp;lt;/math&amp;gt; is the acceleration of atom i, the rate of change of its velocity.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathbf{v}_i&amp;lt;/math&amp;gt; is the velocity of atom i.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathbf{x}_i&amp;lt;/math&amp;gt; is the position of atom i.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{F}_i = m_i \mathbf{a}_i = m_i \frac{\mathrm{d}\mathbf{v}_i}{\mathrm{d}t} = m_i \frac{\mathrm{d}^2 \mathbf{x}_i}{\mathrm{d}t^2} \ \ (1)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a second order differential equation for the positions of the atoms &amp;amp;mdash; if we know how the force, &amp;lt;math&amp;gt;\mathbf{F}_i&amp;lt;/math&amp;gt;, behaves as a function of time, then we can determine the atomic positions and velocities at any time we like. Our system of &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms has &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; of these equations, one for each atom. This is one of the reasons that computer simulations are needed &amp;amp;mdash; if we want to model the behaviour of a liquid, we can hardly solve the necessary number of equations by hand.&lt;br /&gt;
&lt;br /&gt;
===Numerical Integration===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Numerical integration is a rather complex topic. In particular, the notation used below can be quite intimidating. Remember that you are encouraged to ask for help from the demonstrator if you want to discuss any part of this experiment!&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are a number of numerical algorithms to perform a molecular dynamics simulation, two are presented here- The Classical Verlet algorithm and The Velocity-Verlet algorithm.&lt;br /&gt;
&lt;br /&gt;
====Verlet Algorithm====&lt;br /&gt;
&lt;br /&gt;
To solve these equations numerically we have to &#039;&#039;discretise&#039;&#039; the problem: rather than treating the atomic positions, velocities, and forces as continuous functions of time, we break our simulation up into a sequence of &#039;&#039;&#039;timesteps&#039;&#039;&#039;, each of length &amp;lt;math&amp;gt;\delta t&amp;lt;/math&amp;gt;. This process is illustrated for a simple function in &#039;&#039;&#039;figure 1&#039;&#039;&#039;. The method that we are going to use to solve Newton&#039;s law for our atoms is usually called the Verlet algorithm (although it is an old method, and has been &#039;rediscovered&#039; many times!). To understand its origin, we will begin with a brief derivation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-Discretisation.png|300px|thumb|center|&#039;&#039;&#039;Figure 1&#039;&#039;&#039;: Discretisation of sin(x) between 0 and &amp;lt;math&amp;gt;2\pi&amp;lt;/math&amp;gt;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We denote the position of an atom, &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;, at time &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;\mathbf{x}_i \left(t\right)&amp;lt;/math&amp;gt;. Similarly, &amp;lt;math&amp;gt;\mathbf{v}_i \left(t\right)&amp;lt;/math&amp;gt; is the velocity of that atom at the same time. What we want to know is the position of the atoms at the next timestep, &amp;lt;math&amp;gt;t + \delta t&amp;lt;/math&amp;gt;. The basic Verlet algorithm is shown in &#039;&#039;&#039;figure 2&#039;&#039;&#039; - knowing a set of initial conditions the algorithm calculates forces and by Newton&#039;s second law, we can update the positions of a set of particles are a time &amp;lt;math&amp;gt;t + \delta t&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-Verlet-flowchart.svg|300px|thumb|center|&#039;&#039;&#039;Figure 2&#039;&#039;&#039;: Steps to implement the classic Verlet algorithm.]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt; TASK 1: By taking Taylor expansions of  &amp;lt;math&amp;gt;x(t + \delta t)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;x(t - \delta t)&amp;lt;/math&amp;gt;, write general expressions for them up to the fourth order &amp;lt;math&amp;gt;\mathcal{O}\left(\delta t^4\right)&amp;lt;/math&amp;gt; &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt; Having written these expressions, derive the formula in figure 2 to update positions as used in the classical Verlet algorithm &amp;lt;math&amp;gt; x(t + \delta t) \approx 2x_{i}(t) - x_{i}(t-\delta t) + \frac{F_{i}(t)}{m} \delta t^{2}&amp;lt;/math&amp;gt; by using Newton&#039;s second law to replace &amp;lt;math&amp;gt;\frac{\mathrm{d}^2\mathbf{x}_i\left(t\right)}{\mathrm{d}t^2}&amp;lt;/math&amp;gt; [6 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Using this last equation, we can use a sequence of steps like those shown in &#039;&#039;&#039;figure 2&#039;&#039;&#039; to get the positions. At no point are the velocities calculated in this method!&lt;br /&gt;
&lt;br /&gt;
====Velocity Verlet Algorithm====&lt;br /&gt;
&lt;br /&gt;
If we assume that the acceleration of an atom depends only on its position and not its velocity, then we are able to come up with a new algorithm that lets us calculate atomic velocities explicitly as shown in &#039;&#039;&#039;figure 3&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-VelocityVerlet-flowchart.svg|300px|thumb|center|&#039;&#039;&#039;Figure 3&#039;&#039;&#039;: Steps to implement the velocity Verlet algorithm.]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We start by noting that&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{v}_i\left(t + \delta t\right) = \mathbf{v}_i\left(t\right) + \frac{\mathbf{a}_i\left(t\right) + \mathbf{a}_i\left(t + \delta t\right)}{2}\delta t \ \ (6)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can Taylor expand the velocity by half a step, instead of a full step.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{v}_i\left(t + \frac{1}{2}\delta t\right) = \mathbf{v}_i\left(t\right) + \frac{1}{2} \mathbf{a}_i\left(t\right)\delta t \ \ (7)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then substitute this into equation (2) to obtain an accuracy up to &amp;lt;math&amp;gt; \delta t ^{2} &amp;lt;/math&amp;gt;. Notice that terms up to &amp;lt;math&amp;gt; \delta t ^{2} &amp;lt;/math&amp;gt; in equation (2) can be written:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; \mathbf{x}_{i} (t + \delta t) = \mathbf{x}_{i} (t) + \mathbf{v}(t) \delta t + \frac{1}{2} \mathbf{a}(t) \delta t ^{2} &amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{x}_i\left(t + \delta t\right) = \mathbf{x}_i\left(t\right) + \mathbf{v}_i\left(t + \frac{1}{2}\delta t\right)\delta t \ \ (8)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When we know the updated atomic positions, we can calculate new forces, &amp;lt;math&amp;gt;\mathbf{a}_i\left(t + \delta t\right)&amp;lt;/math&amp;gt;. Finally, we substitute equation (7) into equation (6) to get the new velocities &amp;lt;math&amp;gt;\mathbf{v}_i\left(t + \delta t\right)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{v}_i\left(t + \delta t\right) = \mathbf{v}_i\left(t + \frac{1}{2}\delta t\right) + \frac{1}{2}\mathbf{a}_i\left(t + \delta t\right)\delta t \ \ (9)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that for both numerical integration algorithms, the first step is &amp;quot;specify initial conditions&amp;quot;. When using the Verlet algorithm, we need to know the starting positions of the atoms (&amp;lt;math&amp;gt;\mathbf{x}_i\left(0\right)&amp;lt;/math&amp;gt;), and their positions one timestep in the past (&amp;lt;math&amp;gt;\mathbf{x}_i\left(-\delta t\right)&amp;lt;/math&amp;gt;). If the velocity-Verlet algorithm is used, then we have to know the  the starting positions of the atoms (&amp;lt;math&amp;gt;\mathbf{x}_i\left(0\right)&amp;lt;/math&amp;gt;) and their velocities at the same time (&amp;lt;math&amp;gt;\mathbf{v}_i\left(0\right)&amp;lt;/math&amp;gt;). For this reason, we often start new simulations by using the output of older ones. If, however, you are performing your first simulations of a system (as we are now), then you must choose your initial conditions. The simulation software that we will use is able to do this for us, and this will be explained in the next section.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt; TASK 3: What could be an advantage of the Velocity-Verlet algorithm over the classical Verlet algorithm? [1 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Atomic Forces===&lt;br /&gt;
&lt;br /&gt;
Since we can&#039;t reasonably solve the equations from quantum physics necessary to determine the forces acting on a given configuration of atoms, we have to make approximations. We know from classical physics that the force acting on an object is determined by the potential that it experiences:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\mathbf{F}_i = - \frac{\mathrm{d}U\left(\mathbf{r}^N\right)}{\mathrm{d}\mathbf{r}_i}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The shorthand notation &amp;lt;math&amp;gt;\mathbf{r}^N&amp;lt;/math&amp;gt; stands for the position vectors of &#039;&#039;&#039;every&#039;&#039;&#039; atom in system. In principle, the force that a single atom feels is determined by the position of every other atom in the simulation. All we then need to do is to find a function &amp;lt;math&amp;gt;U&amp;lt;/math&amp;gt; that captures all the key physics of the interatomic interactions in the system. For many simple liquids, it turns out that we can model the interactions between each pair of atoms extremely well using the Lennard-Jones potential. Overall, U takes the form:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;U\left(\mathbf{r}^N\right) = \sum_i^N \sum_{i \neq j}^{N} \left\{ 4\epsilon \left( \frac{\sigma^{12}}{r_{ij}^{12}} - \frac{\sigma^6}{r_{ij}^6} \right) \right\} \ \ (10)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 4: For a single Lennard-Jones interaction, &amp;lt;math&amp;gt;\phi\left(r\right) = 4\epsilon \left( \frac{\sigma^{12}}{r^{12}} - \frac{\sigma^6}{r^6} \right)&amp;lt;/math&amp;gt;, find the separation, &amp;lt;math&amp;gt;r_0&amp;lt;/math&amp;gt;, at which the potential energy is zero. What is the force at this separation? Find the equilibrium separation, &amp;lt;math&amp;gt;r_{eq}&amp;lt;/math&amp;gt;, and work out the well depth (&amp;lt;math&amp;gt;\phi\left(r_{eq}\right)&amp;lt;/math&amp;gt;). Evaluate the integrals &amp;lt;math&amp;gt;\int_{2\sigma}^\infty \phi\left(r\right)\mathrm{d}r&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\int_{2.5\sigma}^\infty \phi\left(r\right)\mathrm{d}r&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\int_{3\sigma}^\infty \phi\left(r\right)\mathrm{d}r&amp;lt;/math&amp;gt; when &amp;lt;math&amp;gt;\sigma = \epsilon = 1.0&amp;lt;/math&amp;gt; [4 marks]&amp;lt;/big&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
====Periodic Boundary Conditions====&lt;br /&gt;
&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-Box.png|200px|thumb|right|&#039;&#039;&#039;Figure 4&#039;&#039;&#039;: Diagram of a simulation box containing 2139 atoms. The blue lines indicate the boundaries of the box.]]&lt;br /&gt;
[[File:ThirdYearSimulationExpt-Intro-Periodic.svg|300px|thumb|left|&#039;&#039;&#039;Figure 5&#039;&#039;&#039;: Periodic boundary conditions in two dimensions.]]&lt;br /&gt;
&lt;br /&gt;
We cannot simulate realistic volumes of liquid. In fact, in our simulations, &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; will be between &amp;lt;math&amp;gt;1000&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;10000&amp;lt;/math&amp;gt;. The following task should illustrate why this must be so.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 5: Estimate the number of water molecules in 1ml of water under standard conditions. Estimate the volume of &amp;lt;math&amp;gt;10000&amp;lt;/math&amp;gt; water molecules under standard conditions [3 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In order for our simulations to approximate a bulk liquid, we have to use a computational trick. The atoms in the simulation are enclosed in a simulation box, of fixed dimensions (&#039;&#039;&#039;figure 4&#039;&#039;&#039;). This box is very often a cuboid, but parallelepipeds can also be used (and this can be very useful when simulating crystal structures). We pretend that we have repeated our box infinitely in all directions, so that the atoms at the very edges are not exposed to a vacuum. This is illustrated in two dimensions in &#039;&#039;&#039;figure 5&#039;&#039;&#039;. The darker coloured atoms in the central box are the &amp;quot;real&amp;quot; atoms. The faded atoms in the outer four boxes are the replicas. When an atom crosses the boundary of the box, one of its replicas enters the box through the opposite face. In this way, the number of atoms inside the box is always constant.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 6: Consider an atom at position &amp;lt;math&amp;gt;\left(0.5, 0.5, 0.5\right)&amp;lt;/math&amp;gt; in a cubic simulation box which runs from &amp;lt;math&amp;gt;\left(0, 0, 0\right)&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;\left(1, 1, 1\right)&amp;lt;/math&amp;gt;. In a single timestep, it moves along the vector &amp;lt;math&amp;gt;\left(0.7, 0.6, 0.2\right)&amp;lt;/math&amp;gt;. At what point does it end up, &#039;&#039;after the periodic boundary conditions have been applied&#039;&#039;? [2 marks]&#039;&#039;&#039; &amp;lt;/big&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
====Truncation====&lt;br /&gt;
&lt;br /&gt;
Periodic boundary conditions introduce their own problems. When we defined our potential function (equation 10), we specified that it depended on all possible pairs of atoms. If we have an infinite number of replicas of our system, how can we avoid calculating an infinite number of pair interactions?&lt;br /&gt;
&lt;br /&gt;
Think about the three integrals you calculated for the Lennard-Jones potential task. They represent the area under the Lennard-Jones potential curve between some specified distance (&amp;lt;math&amp;gt;2\sigma&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;2.5\sigma&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;3\sigma&amp;lt;/math&amp;gt;), and infinite separation (where there is no interaction). You should find that this value becomes rather small as the near distance is increased! The attractive &amp;lt;math&amp;gt;\frac{1}{r^6}&amp;lt;/math&amp;gt; part of the potential dominates here, and this decays rapidly with &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. We assume that this means that there is a distance beyond which the interaction is so small that we can safely ignore it. In fact, in most simulations this is chosen to be something close to &amp;lt;math&amp;gt;2.5\sigma&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;3\sigma&amp;lt;/math&amp;gt;. When the forces are calculated, we only calculate interactions between a pair of atoms if their separation is less than this cutoff.&lt;br /&gt;
&lt;br /&gt;
====Reduced Units====&lt;br /&gt;
&lt;br /&gt;
It is typical when using Lennard-Jones interactions to work in reduced units. By this, we mean that all quantities in our simulation are divided by scaling factors &amp;amp;mdash; for example, distances are divided by &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt;. The result of this is that the values become more manageable: all values that we might work out are typically around 1, rather than &amp;lt;math&amp;gt;1\times 10^{-10}&amp;lt;/math&amp;gt; (in the case of distance), &amp;lt;math&amp;gt;300&amp;lt;/math&amp;gt; (in the case of temperature), or &amp;lt;math&amp;gt;1\times 10^{-19}&amp;lt;/math&amp;gt; (in the case of energy).&lt;br /&gt;
&lt;br /&gt;
We denote these reduced quantities by a star, and they take the following conversion factors:&lt;br /&gt;
&lt;br /&gt;
* distance &amp;lt;math&amp;gt;r^* = \frac{r}{\sigma}&amp;lt;/math&amp;gt;&lt;br /&gt;
* energy &amp;lt;math&amp;gt;E^* = \frac{E}{\epsilon}&amp;lt;/math&amp;gt;&lt;br /&gt;
* temperature &amp;lt;math&amp;gt;T^* = \frac{k_BT}{\epsilon}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 7: The Lennard-Jones parameters for argon are &amp;lt;math&amp;gt;\sigma = 0.34\mathrm{nm}, \epsilon\ /\ k_B= 120 \mathrm{K}&amp;lt;/math&amp;gt;. If the LJ cutoff is &amp;lt;math&amp;gt;r^* = 3.2&amp;lt;/math&amp;gt;, what is it in real units? What is the well depth in &amp;lt;math&amp;gt;\mathrm{kJ\ mol}^{-1}&amp;lt;/math&amp;gt;? What is the reduced temperature &amp;lt;math&amp;gt;T^* = 1.5&amp;lt;/math&amp;gt; in real units? [2 marks]&amp;lt;/big&amp;gt; &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the second section of the third year simulation experiment. You can return to the previous section, [[Third year simulation experiment/Running your first simulation|Running your first simulation]], or jump ahead to the next section, [[Third year simulation experiment/Equilibration|Equilibration]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734565</id>
		<title>Third year simulation experiment/Equilibration</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734565"/>
		<updated>2018-10-08T09:49:20Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Running the simulation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We will be using the LAMMPS program to carry out our molecular dynamics simulations.&lt;br /&gt;
&#039;&#039;&#039;In several places in this section, we will ask you to consult the LAMMPS manual to find out things about how the software works. You can find the manual [https://lammps.sandia.gov/doc/Manual.html here].&#039;&#039;&#039; We appreciate that the format of this document can make it a little hard to navigate, but it is the definitive resource on how different commands in LAMMPS work, and is therefore invaluable. &lt;br /&gt;
&lt;br /&gt;
===Creating the simulation box===&lt;br /&gt;
In the previous section, it was pointed out that before we can start a simulation, we need to know the initial states of all of the atoms in the system. Exactly what information we need about each atom depends on which method of numerical integration we need, but at the very least we need to specify the starting position of each atom. If we wanted to simulate a crystal, this information would be quite easy to come by &amp;amp;mdash; we could just look up the crystal structure, and use that to generate coordinates for however many unit cells we wanted. For this purpose, LAMMPS includes a command which generates crystal lattice structures.&lt;br /&gt;
&lt;br /&gt;
Generating coordinates for atoms in a liquid is more difficult. There is no long range order, so we can&#039;t use a single point of reference to work out the positions of every other atom like we can in a solid. We could generate a random position for each atom. This would certainly create a disordered structure, but causes larger problems when we try to run the simulation.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 8: Why do you think giving atoms random starting coordinates causes problems in simulations? Hint: what happens if two atoms happen to be generated close together? [2 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Instead, we are going to place the atoms on the lattice points of a simple cubic lattice. This, of course, is not a situation in which the system is likely to be found physically. It turns out, though, that if we simulate for enough time we will find that the atoms rearrange themselves into more realistic configurations. We will discuss towards the end of this section exactly what is meant by &amp;quot;enough time&amp;quot;!&lt;br /&gt;
&lt;br /&gt;
Consider the line in the input file &amp;lt;pre&amp;gt;lattice sc 0.8&amp;lt;/pre&amp;gt; This command creates a grid of points forming a simple cubic lattice (one lattice point per unit cell). The parameter &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt; specifies the number density (number of lattice points per unit volume). In a corresponding output file, you will see the line &amp;lt;pre&amp;gt;Lattice spacing in x,y,z = 1.07722 1.07722 1.07722&amp;lt;/pre&amp;gt; This indicates that the distance between the points of this lattice is &amp;lt;math&amp;gt;1.07722&amp;lt;/math&amp;gt; (in reduced units, remember!).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 9: Satisfy yourself that this lattice spacing corresponds to a number density of lattice points of &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt;. Consider instead a face-centred cubic lattice with a lattice point number density of 1.2. What is the side length of the cubic unit cell? [3 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The next lines in the input file are&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
region box block 0 10 0 10 0 10&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The corresponding log file output is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Created orthogonal box = (0 0 0) to (10.7722 10.7722 10.7722)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The region command simply defines a geometrical region in space, which we call &amp;quot;box&amp;quot;. In this case, &amp;quot;box&amp;quot; is a cube extending ten lattice spacings from the origin in all three dimensions. The subsequent create_box command tells LAMMPS to use the geometrical region called &amp;quot;box&amp;quot; as a template for the simulation box. The number 1 between &amp;quot;create_box&amp;quot; and &amp;quot;box&amp;quot; indicates that our simulation will contain only one type (species) of atom.&lt;br /&gt;
&lt;br /&gt;
So far we have defined a simulation box which is based around a virtual simple cubic lattice. Our box contains 1000 (10x10x10) unit cells of this lattice, and so contains 1000 lattice points. We now need to fill our simulation box with atoms. The input command is &amp;lt;pre&amp;gt;create_atoms 1 box&amp;lt;/pre&amp;gt; while the log file simply contains an acknowledgement of this &amp;lt;pre&amp;gt;Created 1000 atoms&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The create_atoms command has two arguments; the first tells LAMMPS that all of the atoms that we create will be of type 1. Every atom in the simulation has a type &amp;amp;mdash; because we will be simulating a pure fluid, containing only one chemical species, every atom will have the same type. The actual type that we assign to each atom is arbitrary &amp;amp;mdash; type 1 does not, for example, need to correspond to the element with atomic number 1 (hydrogen). If we wanted to simulate water, we might make the hydrogen atoms type 1 and the oxygen atoms type 2. We will specify the physical and chemical properties of each atom type later in the input script.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 10: Consider again the face-centred cubic lattice from the previous task. How many atoms would be created by the create_atoms command if you had defined that lattice instead? [1 mark]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The remaining data in the log file isn&#039;t very instructive as it stands &amp;amp;mdash; it simply contains a list of the thermodynamic properties of the simulation at certain intervals. In a few sections time, we will plot this data, but for now you can close the log file. Keep the input script open.&lt;br /&gt;
&lt;br /&gt;
===Setting the properties of the atoms===&lt;br /&gt;
&lt;br /&gt;
In addition to their positions, we also need the physical properties of the atoms to be able to perform the simulation. We set these properties on a &#039;per-type&#039; basis, so that every atom of the same type has the same mass and the same interactions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 11: Using the [https://lammps.sandia.gov/doc/Manual.html LAMMPS MANUAL], find the purpose of the following commands in the input script: [3 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mass 1 1.0&lt;br /&gt;
pair_style lj/cut 3.0&lt;br /&gt;
pair_coeff * * 1.0 1.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So far we have created 1000 atoms, and we know the starting (&amp;lt;math&amp;gt;t = 0&amp;lt;/math&amp;gt;) position for each of them. We have also set their masses, and told LAMMPS what sort of forces to calculate between them. The final thing we need to specify to completely specify the initial conditions is the velocity of each atom.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 12: Given that we are specifying &amp;lt;math&amp;gt;\mathbf{x}_i\left(0\right)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{v}_i\left(0\right)&amp;lt;/math&amp;gt;, which integration algorithm are we going to use? [1 mark]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Choosing initial velocities for the atoms is a little easier than choosing initial positions. From the statistical thermodynamics lectures, you should know that, at equilibrium, the velocities of atoms in any system must be distributed according to the [http://en.wikipedia.org/wiki/Maxwell%E2%80%93Boltzmann_distribution Maxwell-Boltzmann (MB) distribution]. If we know the masses of the atoms, and we know what temperature we want to simulate, then we can determine the relevant MB distribution function. LAMMPS is able to give every atom a random velocity whilst ensuring that overall the MB distribution is followed. This is the purpose of the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
velocity all create 1.5 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see the manual page for this command [http://lammps.sandia.gov/doc/velocity.html here], but the key sections are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;all&#039;&#039;&#039;: the &#039;&#039;group&#039;&#039; of atoms on which the command acts. &#039;&#039;&#039;all&#039;&#039;&#039; simply specifies that we want every atom to have a velocity assigned to it.&lt;br /&gt;
* &#039;&#039;&#039;1.5&#039;&#039;&#039;: the temperature, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, needed to calculate the MB distribution(in reduced units, as always)&lt;br /&gt;
&lt;br /&gt;
===Monitoring thermodynamic properties===&lt;br /&gt;
&lt;br /&gt;
We need to be sure that our simulation is correctly modelling whatever physical system we want to study. It is relatively easy to set up simulations, but how can we be sure that the &amp;quot;results&amp;quot; we get make sense? One of the best ways is to calculate from the simulation things that we can measure in experiment, and see if they agree. For example, we might want to simulate our system at a particular temperature and pressure, and measure the resulting density. If we repeat this over a range of temperatures at the same pressure, we will be able to plot an &#039;&#039;equation of state&#039;&#039;, which we could compare to experimental measurements.&lt;br /&gt;
&lt;br /&gt;
LAMMPS is able to calculate a great deal of thermodynamic information for us (you can see a full list of the properties it is able to calculate [http://lammps.sandia.gov/doc/thermo_style.html here]), but in these first simulations we are only interested in those properties specified in these commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
thermo 10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first controls which properties will be printed out in the log file. In this case, we print how much time we have simulated so far (which is &#039;&#039;not&#039;&#039; the same as how long it has taken us to simulate it!), the total energy of the atoms, their temperature, and their pressure. The second line tells LAMMPS to print this information on every 10th timestep.&lt;br /&gt;
&lt;br /&gt;
===Running the simulation===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Look at the lines below.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### SPECIFY TIMESTEP ###&lt;br /&gt;
variable timestep equal 0.001&lt;br /&gt;
variable n_steps equal floor(100/${timestep})&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
### RUN SIMULATION ###&lt;br /&gt;
run ${n_steps}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The second line (starting &amp;quot;variable timestep...&amp;quot;) tells LAMMPS that if it encounters the text ${timestep} on a subsequent line, it should replace it by the value given. In this case, the value ${timestep} is always replaced by 0.001.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ask the demonstrator if you need help.&#039;&#039;&#039;&lt;br /&gt;
It is now time to run your first simulation, submit the input script with the data file in the intro folder of the files you have downloaded Try changing the timestep - what happens when you make the timestep larger?.&lt;br /&gt;
&lt;br /&gt;
===Visualising the trajectory===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;trajectory files&#039;&#039;&#039; contain the positions of all the atoms in the simulation, recorded at a set interval (for all of these simulations, this was every ten timesteps &amp;amp;mdash; this is controlled by the &#039;&#039;&#039;dump&#039;&#039;&#039; command in the input scripts). We use a programme called [http://www.ks.uiuc.edu/Research/vmd/ &#039;&#039;&#039;VMD&#039;&#039;&#039;] to view these trajectories, which you should find is already installed on both the desktop and laptop computers. You can run VMD from the start menu with &#039;&#039;&#039;Start&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;All Programs&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;University of Illinois&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;VMD&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
====Loading a Trajectory====&lt;br /&gt;
&lt;br /&gt;
We&#039;ll start by looking at the output of the 0.015 timestep simulation. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;File&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;New Molecule&#039;&#039;&#039;. Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button, then select the relevant trajectory file. In the &#039;&#039;&#039;Determine file type&#039;&#039;&#039; dropdown, select &#039;&#039;&#039;LAMMPS Trajectory&#039;&#039;&#039;. Then click &#039;&#039;&#039;Load&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You will see that the &#039;&#039;&#039;VMD 1.9.1 OpenGL Display&#039;&#039;&#039; window now shows a horrible mess. VMD&#039;s default behaviour is to draw lines between atoms which it thinks might be chemically bonded. Our system doesn&#039;t model chemical bonds, so we want to turn this off. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;Graphics&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Representations&#039;&#039;&#039;. This shows a list of &amp;quot;representations&amp;quot; of our atoms. You will see that at the moment, there is a single representation listed, and it is selected. It will have the &#039;&#039;Lines&#039;&#039; style, the &#039;&#039;Name&#039;&#039; colour, and the selection &#039;&#039;all&#039;&#039;. &amp;quot;Selection&amp;quot; simply tells VMD which atoms we want it to draw. We want to show every atom, so the current selection is fine. The &#039;&#039;name&#039;&#039; colouring method just makes VMD give atoms colours according to their specified type. The colour isn&#039;t important to us, so we can leave this be too. The &amp;quot;style&amp;quot; tells VMD what we want it to display for each atom. Change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; from &#039;&#039;Lines&#039;&#039; to &#039;&#039;VDW&#039;&#039;. You will see that the mess of lines is replaced by a mess of low resolution, overlapping spheres. Change the &#039;&#039;&#039;Sphere Scale&#039;&#039;&#039; to 0.3, and the &#039;&#039;&#039;Sphere Resolution&#039;&#039;&#039; to 17. The result should look a little smoother. Close the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window. You will notice that in the bottom right of the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, there is a small play button. Click this, and you will see the animated version of your simulation trajectory.&lt;br /&gt;
&lt;br /&gt;
By clicking and dragging with the mouse, you can rotate the simulation box (though this may be sluggish). At any time, you can reset the view by pressing the equals key.&lt;br /&gt;
&lt;br /&gt;
====Tracking a Single Particle====&lt;br /&gt;
To illustrate the periodic boundary conditions that we are using, we are going to draw almost all of the atoms as points, but we will pick a single atom at random to draw as a sphere. This will make it easy to see how a single atom moves through the box. Reset the display using the equals key, then use the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window controls to pause the trajectory and reset it to the first trajectory (play with the different buttons until you find the one that does this). You should see the perfect cubic lattice. Use the option &#039;&#039;&#039;Display&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Orthographic&#039;&#039;&#039; to change the drawing mode, then rotate the displayed crystal so that you are looking at one vertex (looking down the 111 direction, in crystallographic terms).&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window again. Change the representation style from &#039;&#039;&#039;VDW&#039;&#039;&#039; to points, then click the &#039;&#039;&#039;Create Rep&#039;&#039;&#039; button. This creates a second representation, allowing a subset of the atoms to be drawn in a different way. The &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; box allows us to choose which atoms this representation applies to. We just want to pick two of them at random &amp;amp;mdash; VMD assigns every atom an index, from 0 to N-1. In our case, there are 1000 atoms, so choose two numbers between 0 and 999. Changed the &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; field to &amp;lt;pre&amp;gt;index i or index j&amp;lt;/pre&amp;gt; where i and j are your chosen numbers, press return, then change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; to &#039;&#039;&#039;VDW&#039;&#039;&#039;. You should now see only two atoms represented by spheres, with the rest shown as small points. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, click play. Try rotating the box, and changing the playback speed.&lt;br /&gt;
&lt;br /&gt;
You will see that sometimes one of the spheres seems to change position across the box very rapidly &amp;amp;mdash; this occurs when it reaches one periodic boundary, and is reflected back across the other face. Try playing with some of the other representation types in VMD &amp;amp;mdash; it  is a very powerful package, which is often used to render images of simulated proteins, so many of its options aren&#039;t relevant to our simple system!&lt;br /&gt;
&lt;br /&gt;
===Checking equilibration===&lt;br /&gt;
&lt;br /&gt;
When we first set up a simulation, it is very important to make sure that our system reaches an equilibrium state. We characterise equilibrium by the average values of thermodynamic quantities becoming constant (due to the approximations that we have made, there will always be fluctuations, but the average values will become constant).&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to plot the thermodynamic output of the simulation to see how long it takes to reach the equilibrium state (and indeed, whether this happens at all). Instructions are given below to import data from the LAMMPS log file into Microsoft Excel. Once you have the data in a spreadsheet, you can plot it. If you know how to use some of the other plotting software available on the chemistry computers (like Origin), you are welcome to use it.&lt;br /&gt;
&lt;br /&gt;
# Open a blank Excel workbook&lt;br /&gt;
# Choose the &#039;&#039;&#039;Data&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;From Text&#039;&#039;&#039; button&lt;br /&gt;
# Select one of your simulation log files&lt;br /&gt;
# Set the &#039;&#039;&#039;Start import at row&#039;&#039;&#039; field to &#039;&#039;&#039;25&#039;&#039;&#039; (this ignores all of the diagnostic information at the top of the file)&lt;br /&gt;
# Set the &#039;&#039;&#039;Original Data type&#039;&#039;&#039; to &#039;&#039;&#039;Delimited&#039;&#039;&#039;, then click &#039;&#039;&#039;Next&#039;&#039;&#039;&lt;br /&gt;
# Tick the &#039;&#039;&#039;Space&#039;&#039;&#039; box, and make sure that &#039;&#039;&#039;Treat consecutive delimiters as one&#039;&#039;&#039; box is ticked.&lt;br /&gt;
# On the next dialog, you can select where you want the data to be inserted. When you are happy, click &#039;&#039;&#039;OK&#039;&#039;&#039;. The data will be inserted into your spreadsheet.&lt;br /&gt;
# Scroll to the bottom of the data &amp;amp;mdash; you will see a lot of timing information from the simulation. Delete everything beyond the end of your thermodynamic data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 14: make plots of the energy, temperature, and pressure, against time for the 0.001 timestep experiment (attach a picture to your report). Does the simulation reach equilibrium? When you have done this, make a single plot which shows the energy versus time for all of the timesteps you have simulated (again, attach a picture to your report). Of the timesteps that you used, which timestep will you use for subsequent simulations and why? [9 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Dynamical_properties_and_the_diffusion_coefficient&amp;diff=734564</id>
		<title>Third year simulation experiment/Dynamical properties and the diffusion coefficient</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Dynamical_properties_and_the_diffusion_coefficient&amp;diff=734564"/>
		<updated>2018-10-08T09:47:14Z</updated>

		<summary type="html">&lt;p&gt;Otr12: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the seventh (and final) section of the third year simulation experiment. You can return to the previous page, [[Third year simulation experiment/Structural properties and the radial distribution function|Structural properties and the radial distribution function]], or go back to the [[Third_year_simulation_experiment|Introduction]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this final section, we are going to make measurements to get some idea of how much the atoms in our simulation move around. We can characterise this by the diffusion coefficient, which we will calculate by two different approaches.&lt;br /&gt;
&lt;br /&gt;
==Simulations in this Section==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 18: In the D subfolder, there is a file &#039;&#039;liq.in&#039;&#039; that will run a simulation at specified density and temperature to calculate the mean squared displacement and velocity autocorrelation function of your system. Run one of these simulations for a vapour, liquid, and solid. You have also been given some simulated data from much larger systems (approximately one million atoms). You will need these files later. make a plot for each of your simulations (solid, liquid, and gas), showing the mean squared displacement (the &amp;quot;total&amp;quot; MSD) as a function of timestep. Are these as you would expect? Estimate &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; in each case. Be careful with the units! Repeat this procedure for the MSD data that you were given from the one million atom simulations. Compare your data to the million atoms. [10 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Mean Squared Displacement==&lt;br /&gt;
The easiest way to measure &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is by exploiting its connection to the [http://en.wikipedia.org/wiki/Mean_squared_displacement mean squared displacement].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;D = \frac{1}{6}\frac{\partial\left\langle r^2\left(t\right)\right\rangle}{\partial t}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that in general, we expect the simulation to take a little time to establish this linear behaviour!&lt;br /&gt;
&lt;br /&gt;
The simulations that you have already performed have recorded the MSD for you. Download the &amp;quot;optional output-2&amp;quot; file for each of the simulations, and give it a suitable name. These are text files which contain 5 columns: the first is the number of timesteps since the start of the simulation (*not* the elapsed time in reduced units), the next three contain the mean squared displacement for each of the Cartesian directions (x,y,z), and the final column contains the &amp;quot;total&amp;quot; mean squared displacement.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the seventh (and final) section of the third year simulation experiment. You can return to the previous page, [[Third year simulation experiment/Structural properties and the radial distribution function|Structural properties and the radial distribution function]], or go back to the [[Third_year_simulation_experiment|Introduction]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Structural_properties_and_the_radial_distribution_function&amp;diff=734563</id>
		<title>Third year simulation experiment/Structural properties and the radial distribution function</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Structural_properties_and_the_radial_distribution_function&amp;diff=734563"/>
		<updated>2018-10-08T09:47:05Z</updated>

		<summary type="html">&lt;p&gt;Otr12: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the sixth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Running_simulations_under_specific_conditions|Running simulations under specific conditions]], or jump ahead to the next section, [[Third year simulation experiment/Dynamical properties and the diffusion coefficient|Dynamical properties and the diffusion coefficient]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
We can characterise the structure of systems that we simulate using [http://en.wikipedia.org/wiki/Radial_distribution_function radial distribution functions], which we denote &amp;lt;math&amp;gt;g(r)&amp;lt;/math&amp;gt;. Calculating the RDF for a simulation is very useful &amp;amp;mdash; it can tell us the distances from an atom at which we will find it&#039;s nearest neighbour, second nearest neighbour, and so on; it is also a quantity that can be accessed experimentally, and so provides a good check that the forcefield in our simulation is correctly reproducing the structural features.&lt;br /&gt;
&lt;br /&gt;
In this section, you are going to use VMD to calculate the radial distribution function for the solid, liquid, and vapour phases of the Lennard-Jones fluid.&lt;br /&gt;
&lt;br /&gt;
===Calculating &amp;lt;math&amp;gt;g(r)&amp;lt;/math&amp;gt; in VMD===&lt;br /&gt;
&lt;br /&gt;
# Start VMD as before and load the trajectory that you want to analyse.&lt;br /&gt;
# Select &#039;&#039;&#039;Extensions&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Analysis&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Radial Pair Distribution Function g(r)&#039;&#039;&#039;&lt;br /&gt;
# Set &#039;&#039;&#039;Selection 1&#039;&#039;&#039; to &#039;&#039;&#039;all&#039;&#039;&#039; and &#039;&#039;&#039;Selection 2&#039;&#039;&#039; to &#039;&#039;&#039;all&#039;&#039;&#039;&lt;br /&gt;
# Change &#039;&#039;&#039;delta r&#039;&#039;&#039; to &#039;&#039;&#039;0.05&#039;&#039;&#039; &amp;amp;mdash; this is the distance between points in the generated RDF.&lt;br /&gt;
# Ensure that &#039;&#039;&#039;Use PBC&#039;&#039;&#039;, &#039;&#039;&#039;Display g(r)&#039;&#039;&#039;, &#039;&#039;&#039;Display Int(g(r))&#039;&#039;&#039;, and &#039;&#039;&#039;Save to File&#039;&#039;&#039; are checked&lt;br /&gt;
# Click &#039;&#039;&#039;Compute g(r)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After a short pause while it performs the calculation, VMD will display both the RDF, and its running integral. You will then be prompted to save this data &amp;amp;mdash; choose a location for the file that you will be able to find easily later.&lt;br /&gt;
&lt;br /&gt;
===Simulations in this section===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;RDF&#039;&#039;&#039; subfolder contains an example input script that you can use to record an atomic trajectory to generate RDFs for the solid, liquid, and vapour phase Lennard Jones systems. Make three copies of that script (one for each phase), and modify the density and temperature parameters to give the phase that you want (a phase diagram for the Lennard-Jones system can be found [http://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151 here]). &#039;&#039;&#039;Note&#039;&#039;&#039;: when simulating the solid, you will need to change the lattice type in the lattice command to fcc, rather than sc.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 17: perform simulations of the Lennard-Jones system in the three phases. When each is complete, download the trajectory and calculate &amp;lt;math&amp;gt;g(r)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\int g(r)\mathrm{d}r&amp;lt;/math&amp;gt;. Plot the RDFs for the three systems on the same axes, and attach a copy to your report. Discuss qualitatively the differences between the three RDFs, and what this tells you about the structure of the system in each phase. In the solid case, illustrate which lattice sites the first three peaks correspond to. What is the lattice spacing? What is the coordination number for each of the first three peaks? [15 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the sixth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Running simulations under specific conditions|Running simulations under specific conditions]], or jump ahead to the next section, [[Third year simulation experiment/Dynamical properties and the diffusion coefficient|Dynamical properties and the diffusion coefficient]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Running_simulations_under_specific_conditions&amp;diff=734562</id>
		<title>Third year simulation experiment/Running simulations under specific conditions</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Running_simulations_under_specific_conditions&amp;diff=734562"/>
		<updated>2018-10-08T09:46:48Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Thermostats and Barostats - controlling the thermodynamic properties */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the fourth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Equilibration|Equilibration]], or jump ahead to the next section, [[Third_year_simulation_experiment/Structural_properties_and_the_radial_distribution_function| Structural Properties and the Radial Distribution Functions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;THE FILES THAT YOU NEED FOR THIS SECTION ARE FOUND IN THE &amp;quot;NpT&amp;quot; SUBFOLDER.&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Changing Ensemble==&lt;br /&gt;
&lt;br /&gt;
So far, we have been able to do some simulations in which the number of particles and the volume of the simulation cell are held constant. The energy is also constant (within a certain degree of error, which is introduced by the approximations that we make to do the simulation). If the simulation is a working properly, then the pressure and temperature of the system should also reach a constant &#039;&#039;average&#039;&#039; value (although there will again be fluctuations). In the statistical thermodynamics lectures, you met the concept of ensembles, which are used in statistical mechanics to represent different sorts of experimental conditions. The simulations we have done so far are described by the &#039;&#039;microcanonical&#039;&#039;, or NVE ensemble (the letters represent those thermodynamic quantities which are constant).&lt;br /&gt;
&lt;br /&gt;
As chemists, we often want to understand what happens under particular experimental conditions &amp;amp;mdash; at 298K under 1 atmosphere of pressure, for example. These sorts of conditions are described by different ensembles in statistical mechanics, such as the NVT (&#039;&#039;canonical&#039;&#039;) or NpT (&#039;&#039;isobaric-isothermal&#039;&#039;) ensembles.&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to modify our simulations from the previous section to run under NpT conditions, and sketch an equation of state for our model fluid at atmospheric pressure.&lt;br /&gt;
&lt;br /&gt;
==Temperature and Pressure Control==&lt;br /&gt;
&lt;br /&gt;
The file npt.in can be used to perform a constant temperature/pressure simulation of our model fluid. It starts by melting a simple cubic crystal, just as before, so much of this file will look familiar to you. You will notice a new section near the top, however, called &#039;&#039;&#039;### SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&#039;&#039;&#039;. It contains three &#039;&#039;variables&#039;&#039; &amp;amp;mdash; these are used by the script later on to define the desired temperature, pressure, and timestep. The ellipses need to be replaced by the actual temperature, pressure and timestep that you want to use, so&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
variable T equal 0.5&lt;br /&gt;
variable p equal 1.0&lt;br /&gt;
variable timestep equal 0.75&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
would run a simulation at &amp;lt;math&amp;gt;T=0.5,\  p=1.0,\  \delta t=0.75&amp;lt;/math&amp;gt;. You should remember from the [[Third_year_simulation_experiment/Equilibration|Equilibration]] section that this is a poor choice of timestep!&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 15: Choose 5 temperatures (above the critical temperature &amp;lt;math&amp;gt;T^* = 1.5&amp;lt;/math&amp;gt;), and two pressures (you can get a good idea of what a reasonable pressure is in Lennard-Jones units by looking at the average pressure of your simulations from the last section). This gives ten phase points &amp;amp;mdash; five temperatures at each pressure. Create 10 copies of npt.in, and modify each to run a simulation at one of your chosen &amp;lt;math&amp;gt;\left(p, T\right)&amp;lt;/math&amp;gt; points. You should be able to use the results of the previous section to choose a timestep. Submit these ten jobs to the HPC portal. When your simulations have finished, download the log files as before. At the end of the log file, LAMMPS will output the values and errors for the pressure, temperature, and density &amp;lt;math&amp;gt;\left(\frac{N}{V}\right)&amp;lt;/math&amp;gt;. Use software of your choice to plot the density as a function of temperature for both of the pressures that you simulated.  Your graph(s) should include error bars in both the x and y directions. You should also include a line corresponding to the density predicted by the ideal gas law at that pressure. Is your simulated density lower or higher? Justify this. Does the discrepancy increase or decrease with pressure? [15 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Thermostats and Barostats - controlling the thermodynamic properties===&lt;br /&gt;
The statistical thermodynamics lectures will have introduced you to the &#039;&#039;equipartition theorem&#039;&#039;, which states that, on average, every degree of freedom in a system at equilibrium will have &amp;lt;math&amp;gt;\frac{1}{2}k_B T&amp;lt;/math&amp;gt; of energy. In our system with &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms, each with 3 degrees of freedom, we can write&lt;br /&gt;
&amp;lt;math&amp;gt;E_K = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i v_i^2 = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end of every timestep, we use the left hand side of this equation to calculate the kinetic energy, then divide by &amp;lt;math&amp;gt;\frac{3}{2}Nk_B&amp;lt;/math&amp;gt; to get the &#039;&#039;instantaneous&#039;&#039; temperature &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. In general, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; will fluctuate, and will be different to our &#039;&#039;target&#039;&#039; temperature, &amp;lt;math&amp;gt;\mathfrak{T}&amp;lt;/math&amp;gt; (this is whatever value we specify in the input script). We can change the temperature by multiplying every velocity by a constant factor, &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* If &amp;lt;math&amp;gt; T &amp;gt; \mathfrak{T} &amp;lt;/math&amp;gt;, then the kinetic energy of the system is too high, and we need to reduce it. &amp;lt;math&amp;gt;\gamma &amp;lt; 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* If &amp;lt;math&amp;gt; T &amp;lt; \mathfrak{T} &amp;lt;/math&amp;gt;, then the kinetic energy of the system is too low, and we need to increase it. &amp;lt;math&amp;gt;\gamma &amp;gt; 1&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 16: We need to choose &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt; so that the temperature is correct &amp;lt;math&amp;gt;T = \mathfrak{T}&amp;lt;/math&amp;gt; if we multiply every velocity &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;. We can write two equations:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i v_i^2 = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i \left(\gamma v_i\right)^2 = \frac{3}{2} N k_B \mathfrak{T}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solve these to determine &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;. &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Controlling the pressure is a little more involved, but the principle is largely the same: at each timestep, the pressure of the system is calculated; if the pressure is too high, then the simulation box is made a little larger, while if the pressure is too low the box is made smaller. Simulations in which the pressure is controlled are thus in the NpT ensemble &amp;amp;mdash; the volume of the simulation box is not constant!&lt;br /&gt;
&lt;br /&gt;
===Examining the Input Script===&lt;br /&gt;
&lt;br /&gt;
Open one of your input scripts (it doesn&#039;t matter which), and look at the section &#039;&#039;&#039;### BRING SYSTEM TO REQUIRED STATE ###&#039;&#039;&#039;. The line &amp;lt;pre&amp;gt;fix npt all npt temp ${T} ${T} ${tdamp} iso ${p} ${p} ${pdamp}&amp;lt;/pre&amp;gt; is the one responsible for switching on the temperature and pressure control. LAMMPS actually allows us to heat or cool the system over the course of a simulation, if we want to &amp;amp;mdash; this is the reason that the temperature appears twice in this line. The first ${T} is the desired starting temperature, and the second is the desired temperature at the end of the simulation. We want a constant average temperature, so we specify the same value twice. The same goes for the pressure.&lt;br /&gt;
&lt;br /&gt;
Now look at the lines near the end of the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### MEASURE SYSTEM STATE ###&lt;br /&gt;
thermo_style custom step etotal temp press density&lt;br /&gt;
variable dens equal density&lt;br /&gt;
variable dens2 equal density*density&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
variable press equal press&lt;br /&gt;
variable press2 equal press*press&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_dens v_temp v_press v_dens2 v_temp2 v_press2&lt;br /&gt;
run 100000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command, &#039;&#039;thermo_style&#039;&#039;, controls which thermodynamic properties are recorded, as before. The next lines are used to measure &#039;&#039;average&#039;&#039; thermodynamic properties for the system. To draw our equations of state, we need to know the average temperature, pressure, and density, and the statistical errors in those quantities. The six variable lines link those quantities (and their squared values, needed for the errors), to variable names that we can use in the averaging command, which is the line starting &#039;&#039;fix aves...&#039;&#039;. This command takes a number of input values and averages them every so many timesteps. Exactly how often this happens depends in the values of the three numbers which follow &#039;&#039;ave/time&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the fourth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Equilibration|Equilibration]], or jump ahead to the next section, [[Third year simulation experiment/Structural properties and the radial distribution function|Structural properties and the radial distribution function]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Running_simulations_under_specific_conditions&amp;diff=734561</id>
		<title>Third year simulation experiment/Running simulations under specific conditions</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Running_simulations_under_specific_conditions&amp;diff=734561"/>
		<updated>2018-10-08T09:46:33Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Temperature and Pressure Control */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the fourth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Equilibration|Equilibration]], or jump ahead to the next section, [[Third_year_simulation_experiment/Structural_properties_and_the_radial_distribution_function| Structural Properties and the Radial Distribution Functions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;THE FILES THAT YOU NEED FOR THIS SECTION ARE FOUND IN THE &amp;quot;NpT&amp;quot; SUBFOLDER.&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Changing Ensemble==&lt;br /&gt;
&lt;br /&gt;
So far, we have been able to do some simulations in which the number of particles and the volume of the simulation cell are held constant. The energy is also constant (within a certain degree of error, which is introduced by the approximations that we make to do the simulation). If the simulation is a working properly, then the pressure and temperature of the system should also reach a constant &#039;&#039;average&#039;&#039; value (although there will again be fluctuations). In the statistical thermodynamics lectures, you met the concept of ensembles, which are used in statistical mechanics to represent different sorts of experimental conditions. The simulations we have done so far are described by the &#039;&#039;microcanonical&#039;&#039;, or NVE ensemble (the letters represent those thermodynamic quantities which are constant).&lt;br /&gt;
&lt;br /&gt;
As chemists, we often want to understand what happens under particular experimental conditions &amp;amp;mdash; at 298K under 1 atmosphere of pressure, for example. These sorts of conditions are described by different ensembles in statistical mechanics, such as the NVT (&#039;&#039;canonical&#039;&#039;) or NpT (&#039;&#039;isobaric-isothermal&#039;&#039;) ensembles.&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to modify our simulations from the previous section to run under NpT conditions, and sketch an equation of state for our model fluid at atmospheric pressure.&lt;br /&gt;
&lt;br /&gt;
==Temperature and Pressure Control==&lt;br /&gt;
&lt;br /&gt;
The file npt.in can be used to perform a constant temperature/pressure simulation of our model fluid. It starts by melting a simple cubic crystal, just as before, so much of this file will look familiar to you. You will notice a new section near the top, however, called &#039;&#039;&#039;### SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&#039;&#039;&#039;. It contains three &#039;&#039;variables&#039;&#039; &amp;amp;mdash; these are used by the script later on to define the desired temperature, pressure, and timestep. The ellipses need to be replaced by the actual temperature, pressure and timestep that you want to use, so&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
variable T equal 0.5&lt;br /&gt;
variable p equal 1.0&lt;br /&gt;
variable timestep equal 0.75&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
would run a simulation at &amp;lt;math&amp;gt;T=0.5,\  p=1.0,\  \delta t=0.75&amp;lt;/math&amp;gt;. You should remember from the [[Third_year_simulation_experiment/Equilibration|Equilibration]] section that this is a poor choice of timestep!&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 15: Choose 5 temperatures (above the critical temperature &amp;lt;math&amp;gt;T^* = 1.5&amp;lt;/math&amp;gt;), and two pressures (you can get a good idea of what a reasonable pressure is in Lennard-Jones units by looking at the average pressure of your simulations from the last section). This gives ten phase points &amp;amp;mdash; five temperatures at each pressure. Create 10 copies of npt.in, and modify each to run a simulation at one of your chosen &amp;lt;math&amp;gt;\left(p, T\right)&amp;lt;/math&amp;gt; points. You should be able to use the results of the previous section to choose a timestep. Submit these ten jobs to the HPC portal. When your simulations have finished, download the log files as before. At the end of the log file, LAMMPS will output the values and errors for the pressure, temperature, and density &amp;lt;math&amp;gt;\left(\frac{N}{V}\right)&amp;lt;/math&amp;gt;. Use software of your choice to plot the density as a function of temperature for both of the pressures that you simulated.  Your graph(s) should include error bars in both the x and y directions. You should also include a line corresponding to the density predicted by the ideal gas law at that pressure. Is your simulated density lower or higher? Justify this. Does the discrepancy increase or decrease with pressure? [15 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Thermostats and Barostats - controlling the thermodynamic properties===&lt;br /&gt;
The statistical thermodynamics lectures will have introduced you to the &#039;&#039;equipartition theorem&#039;&#039;, which states that, on average, every degree of freedom in a system at equilibrium will have &amp;lt;math&amp;gt;\frac{1}{2}k_B T&amp;lt;/math&amp;gt; of energy. In our system with &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms, each with 3 degrees of freedom, we can write&lt;br /&gt;
&amp;lt;math&amp;gt;E_K = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i v_i^2 = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end of every timestep, we use the left hand side of this equation to calculate the kinetic energy, then divide by &amp;lt;math&amp;gt;\frac{3}{2}Nk_B&amp;lt;/math&amp;gt; to get the &#039;&#039;instantaneous&#039;&#039; temperature &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. In general, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; will fluctuate, and will be different to our &#039;&#039;target&#039;&#039; temperature, &amp;lt;math&amp;gt;\mathfrak{T}&amp;lt;/math&amp;gt; (this is whatever value we specify in the input script). We can change the temperature by multiplying every velocity by a constant factor, &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* If &amp;lt;math&amp;gt; T &amp;gt; \mathfrak{T} &amp;lt;/math&amp;gt;, then the kinetic energy of the system is too high, and we need to reduce it. &amp;lt;math&amp;gt;\gamma &amp;lt; 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* If &amp;lt;math&amp;gt; T &amp;lt; \mathfrak{T} &amp;lt;/math&amp;gt;, then the kinetic energy of the system is too low, and we need to increase it. &amp;lt;math&amp;gt;\gamma &amp;gt; 1&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK: We need to choose &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt; so that the temperature is correct &amp;lt;math&amp;gt;T = \mathfrak{T}&amp;lt;/math&amp;gt; if we multiply every velocity &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;. We can write two equations:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i v_i^2 = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i \left(\gamma v_i\right)^2 = \frac{3}{2} N k_B \mathfrak{T}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solve these to determine &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;. &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Controlling the pressure is a little more involved, but the principle is largely the same: at each timestep, the pressure of the system is calculated; if the pressure is too high, then the simulation box is made a little larger, while if the pressure is too low the box is made smaller. Simulations in which the pressure is controlled are thus in the NpT ensemble &amp;amp;mdash; the volume of the simulation box is not constant!&lt;br /&gt;
&lt;br /&gt;
===Examining the Input Script===&lt;br /&gt;
&lt;br /&gt;
Open one of your input scripts (it doesn&#039;t matter which), and look at the section &#039;&#039;&#039;### BRING SYSTEM TO REQUIRED STATE ###&#039;&#039;&#039;. The line &amp;lt;pre&amp;gt;fix npt all npt temp ${T} ${T} ${tdamp} iso ${p} ${p} ${pdamp}&amp;lt;/pre&amp;gt; is the one responsible for switching on the temperature and pressure control. LAMMPS actually allows us to heat or cool the system over the course of a simulation, if we want to &amp;amp;mdash; this is the reason that the temperature appears twice in this line. The first ${T} is the desired starting temperature, and the second is the desired temperature at the end of the simulation. We want a constant average temperature, so we specify the same value twice. The same goes for the pressure.&lt;br /&gt;
&lt;br /&gt;
Now look at the lines near the end of the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### MEASURE SYSTEM STATE ###&lt;br /&gt;
thermo_style custom step etotal temp press density&lt;br /&gt;
variable dens equal density&lt;br /&gt;
variable dens2 equal density*density&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
variable press equal press&lt;br /&gt;
variable press2 equal press*press&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_dens v_temp v_press v_dens2 v_temp2 v_press2&lt;br /&gt;
run 100000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command, &#039;&#039;thermo_style&#039;&#039;, controls which thermodynamic properties are recorded, as before. The next lines are used to measure &#039;&#039;average&#039;&#039; thermodynamic properties for the system. To draw our equations of state, we need to know the average temperature, pressure, and density, and the statistical errors in those quantities. The six variable lines link those quantities (and their squared values, needed for the errors), to variable names that we can use in the averaging command, which is the line starting &#039;&#039;fix aves...&#039;&#039;. This command takes a number of input values and averages them every so many timesteps. Exactly how often this happens depends in the values of the three numbers which follow &#039;&#039;ave/time&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the fourth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Equilibration|Equilibration]], or jump ahead to the next section, [[Third year simulation experiment/Structural properties and the radial distribution function|Structural properties and the radial distribution function]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734560</id>
		<title>Third year simulation experiment/Equilibration</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734560"/>
		<updated>2018-10-08T09:46:21Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Checking equilibration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We will be using the LAMMPS program to carry out our molecular dynamics simulations.&lt;br /&gt;
&#039;&#039;&#039;In several places in this section, we will ask you to consult the LAMMPS manual to find out things about how the software works. You can find the manual [https://lammps.sandia.gov/doc/Manual.html here].&#039;&#039;&#039; We appreciate that the format of this document can make it a little hard to navigate, but it is the definitive resource on how different commands in LAMMPS work, and is therefore invaluable. &lt;br /&gt;
&lt;br /&gt;
===Creating the simulation box===&lt;br /&gt;
In the previous section, it was pointed out that before we can start a simulation, we need to know the initial states of all of the atoms in the system. Exactly what information we need about each atom depends on which method of numerical integration we need, but at the very least we need to specify the starting position of each atom. If we wanted to simulate a crystal, this information would be quite easy to come by &amp;amp;mdash; we could just look up the crystal structure, and use that to generate coordinates for however many unit cells we wanted. For this purpose, LAMMPS includes a command which generates crystal lattice structures.&lt;br /&gt;
&lt;br /&gt;
Generating coordinates for atoms in a liquid is more difficult. There is no long range order, so we can&#039;t use a single point of reference to work out the positions of every other atom like we can in a solid. We could generate a random position for each atom. This would certainly create a disordered structure, but causes larger problems when we try to run the simulation.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 8: Why do you think giving atoms random starting coordinates causes problems in simulations? Hint: what happens if two atoms happen to be generated close together? [2 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Instead, we are going to place the atoms on the lattice points of a simple cubic lattice. This, of course, is not a situation in which the system is likely to be found physically. It turns out, though, that if we simulate for enough time we will find that the atoms rearrange themselves into more realistic configurations. We will discuss towards the end of this section exactly what is meant by &amp;quot;enough time&amp;quot;!&lt;br /&gt;
&lt;br /&gt;
Consider the line in the input file &amp;lt;pre&amp;gt;lattice sc 0.8&amp;lt;/pre&amp;gt; This command creates a grid of points forming a simple cubic lattice (one lattice point per unit cell). The parameter &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt; specifies the number density (number of lattice points per unit volume). In a corresponding output file, you will see the line &amp;lt;pre&amp;gt;Lattice spacing in x,y,z = 1.07722 1.07722 1.07722&amp;lt;/pre&amp;gt; This indicates that the distance between the points of this lattice is &amp;lt;math&amp;gt;1.07722&amp;lt;/math&amp;gt; (in reduced units, remember!).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 9: Satisfy yourself that this lattice spacing corresponds to a number density of lattice points of &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt;. Consider instead a face-centred cubic lattice with a lattice point number density of 1.2. What is the side length of the cubic unit cell? [3 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The next lines in the input file are&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
region box block 0 10 0 10 0 10&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The corresponding log file output is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Created orthogonal box = (0 0 0) to (10.7722 10.7722 10.7722)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The region command simply defines a geometrical region in space, which we call &amp;quot;box&amp;quot;. In this case, &amp;quot;box&amp;quot; is a cube extending ten lattice spacings from the origin in all three dimensions. The subsequent create_box command tells LAMMPS to use the geometrical region called &amp;quot;box&amp;quot; as a template for the simulation box. The number 1 between &amp;quot;create_box&amp;quot; and &amp;quot;box&amp;quot; indicates that our simulation will contain only one type (species) of atom.&lt;br /&gt;
&lt;br /&gt;
So far we have defined a simulation box which is based around a virtual simple cubic lattice. Our box contains 1000 (10x10x10) unit cells of this lattice, and so contains 1000 lattice points. We now need to fill our simulation box with atoms. The input command is &amp;lt;pre&amp;gt;create_atoms 1 box&amp;lt;/pre&amp;gt; while the log file simply contains an acknowledgement of this &amp;lt;pre&amp;gt;Created 1000 atoms&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The create_atoms command has two arguments; the first tells LAMMPS that all of the atoms that we create will be of type 1. Every atom in the simulation has a type &amp;amp;mdash; because we will be simulating a pure fluid, containing only one chemical species, every atom will have the same type. The actual type that we assign to each atom is arbitrary &amp;amp;mdash; type 1 does not, for example, need to correspond to the element with atomic number 1 (hydrogen). If we wanted to simulate water, we might make the hydrogen atoms type 1 and the oxygen atoms type 2. We will specify the physical and chemical properties of each atom type later in the input script.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 10: Consider again the face-centred cubic lattice from the previous task. How many atoms would be created by the create_atoms command if you had defined that lattice instead? [1 mark]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The remaining data in the log file isn&#039;t very instructive as it stands &amp;amp;mdash; it simply contains a list of the thermodynamic properties of the simulation at certain intervals. In a few sections time, we will plot this data, but for now you can close the log file. Keep the input script open.&lt;br /&gt;
&lt;br /&gt;
===Setting the properties of the atoms===&lt;br /&gt;
&lt;br /&gt;
In addition to their positions, we also need the physical properties of the atoms to be able to perform the simulation. We set these properties on a &#039;per-type&#039; basis, so that every atom of the same type has the same mass and the same interactions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 11: Using the [https://lammps.sandia.gov/doc/Manual.html LAMMPS MANUAL], find the purpose of the following commands in the input script: [3 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mass 1 1.0&lt;br /&gt;
pair_style lj/cut 3.0&lt;br /&gt;
pair_coeff * * 1.0 1.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So far we have created 1000 atoms, and we know the starting (&amp;lt;math&amp;gt;t = 0&amp;lt;/math&amp;gt;) position for each of them. We have also set their masses, and told LAMMPS what sort of forces to calculate between them. The final thing we need to specify to completely specify the initial conditions is the velocity of each atom.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 12: Given that we are specifying &amp;lt;math&amp;gt;\mathbf{x}_i\left(0\right)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{v}_i\left(0\right)&amp;lt;/math&amp;gt;, which integration algorithm are we going to use? [1 mark]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Choosing initial velocities for the atoms is a little easier than choosing initial positions. From the statistical thermodynamics lectures, you should know that, at equilibrium, the velocities of atoms in any system must be distributed according to the [http://en.wikipedia.org/wiki/Maxwell%E2%80%93Boltzmann_distribution Maxwell-Boltzmann (MB) distribution]. If we know the masses of the atoms, and we know what temperature we want to simulate, then we can determine the relevant MB distribution function. LAMMPS is able to give every atom a random velocity whilst ensuring that overall the MB distribution is followed. This is the purpose of the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
velocity all create 1.5 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see the manual page for this command [http://lammps.sandia.gov/doc/velocity.html here], but the key sections are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;all&#039;&#039;&#039;: the &#039;&#039;group&#039;&#039; of atoms on which the command acts. &#039;&#039;&#039;all&#039;&#039;&#039; simply specifies that we want every atom to have a velocity assigned to it.&lt;br /&gt;
* &#039;&#039;&#039;1.5&#039;&#039;&#039;: the temperature, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, needed to calculate the MB distribution(in reduced units, as always)&lt;br /&gt;
&lt;br /&gt;
===Monitoring thermodynamic properties===&lt;br /&gt;
&lt;br /&gt;
We need to be sure that our simulation is correctly modelling whatever physical system we want to study. It is relatively easy to set up simulations, but how can we be sure that the &amp;quot;results&amp;quot; we get make sense? One of the best ways is to calculate from the simulation things that we can measure in experiment, and see if they agree. For example, we might want to simulate our system at a particular temperature and pressure, and measure the resulting density. If we repeat this over a range of temperatures at the same pressure, we will be able to plot an &#039;&#039;equation of state&#039;&#039;, which we could compare to experimental measurements.&lt;br /&gt;
&lt;br /&gt;
LAMMPS is able to calculate a great deal of thermodynamic information for us (you can see a full list of the properties it is able to calculate [http://lammps.sandia.gov/doc/thermo_style.html here]), but in these first simulations we are only interested in those properties specified in these commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
thermo 10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first controls which properties will be printed out in the log file. In this case, we print how much time we have simulated so far (which is &#039;&#039;not&#039;&#039; the same as how long it has taken us to simulate it!), the total energy of the atoms, their temperature, and their pressure. The second line tells LAMMPS to print this information on every 10th timestep.&lt;br /&gt;
&lt;br /&gt;
===Running the simulation===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Look at the lines below.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### SPECIFY TIMESTEP ###&lt;br /&gt;
variable timestep equal 0.001&lt;br /&gt;
variable n_steps equal floor(100/${timestep})&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
### RUN SIMULATION ###&lt;br /&gt;
run ${n_steps}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The second line (starting &amp;quot;variable timestep...&amp;quot;) tells LAMMPS that if it encounters the text ${timestep} on a subsequent line, it should replace it by the value given. In this case, the value ${timestep} is always replaced by 0.001.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; &amp;lt;big&amp;gt; TASK 13: In light of this, what do you think the purpose of these lines is? Why not just write:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
timestep 0.001&lt;br /&gt;
run 100000&lt;br /&gt;
&amp;lt;/pre&amp;gt; [1 mark] &amp;lt;/big&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Ask the demonstrator if you need help.&#039;&#039;&#039;&lt;br /&gt;
It is now time to run your first simulation, submit the input script with the data file in the intro folder of the files you have downloaded Try changing the timestep - what happens when you make the timestep larger?.&lt;br /&gt;
&lt;br /&gt;
===Visualising the trajectory===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;trajectory files&#039;&#039;&#039; contain the positions of all the atoms in the simulation, recorded at a set interval (for all of these simulations, this was every ten timesteps &amp;amp;mdash; this is controlled by the &#039;&#039;&#039;dump&#039;&#039;&#039; command in the input scripts). We use a programme called [http://www.ks.uiuc.edu/Research/vmd/ &#039;&#039;&#039;VMD&#039;&#039;&#039;] to view these trajectories, which you should find is already installed on both the desktop and laptop computers. You can run VMD from the start menu with &#039;&#039;&#039;Start&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;All Programs&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;University of Illinois&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;VMD&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
====Loading a Trajectory====&lt;br /&gt;
&lt;br /&gt;
We&#039;ll start by looking at the output of the 0.015 timestep simulation. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;File&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;New Molecule&#039;&#039;&#039;. Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button, then select the relevant trajectory file. In the &#039;&#039;&#039;Determine file type&#039;&#039;&#039; dropdown, select &#039;&#039;&#039;LAMMPS Trajectory&#039;&#039;&#039;. Then click &#039;&#039;&#039;Load&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You will see that the &#039;&#039;&#039;VMD 1.9.1 OpenGL Display&#039;&#039;&#039; window now shows a horrible mess. VMD&#039;s default behaviour is to draw lines between atoms which it thinks might be chemically bonded. Our system doesn&#039;t model chemical bonds, so we want to turn this off. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;Graphics&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Representations&#039;&#039;&#039;. This shows a list of &amp;quot;representations&amp;quot; of our atoms. You will see that at the moment, there is a single representation listed, and it is selected. It will have the &#039;&#039;Lines&#039;&#039; style, the &#039;&#039;Name&#039;&#039; colour, and the selection &#039;&#039;all&#039;&#039;. &amp;quot;Selection&amp;quot; simply tells VMD which atoms we want it to draw. We want to show every atom, so the current selection is fine. The &#039;&#039;name&#039;&#039; colouring method just makes VMD give atoms colours according to their specified type. The colour isn&#039;t important to us, so we can leave this be too. The &amp;quot;style&amp;quot; tells VMD what we want it to display for each atom. Change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; from &#039;&#039;Lines&#039;&#039; to &#039;&#039;VDW&#039;&#039;. You will see that the mess of lines is replaced by a mess of low resolution, overlapping spheres. Change the &#039;&#039;&#039;Sphere Scale&#039;&#039;&#039; to 0.3, and the &#039;&#039;&#039;Sphere Resolution&#039;&#039;&#039; to 17. The result should look a little smoother. Close the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window. You will notice that in the bottom right of the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, there is a small play button. Click this, and you will see the animated version of your simulation trajectory.&lt;br /&gt;
&lt;br /&gt;
By clicking and dragging with the mouse, you can rotate the simulation box (though this may be sluggish). At any time, you can reset the view by pressing the equals key.&lt;br /&gt;
&lt;br /&gt;
====Tracking a Single Particle====&lt;br /&gt;
To illustrate the periodic boundary conditions that we are using, we are going to draw almost all of the atoms as points, but we will pick a single atom at random to draw as a sphere. This will make it easy to see how a single atom moves through the box. Reset the display using the equals key, then use the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window controls to pause the trajectory and reset it to the first trajectory (play with the different buttons until you find the one that does this). You should see the perfect cubic lattice. Use the option &#039;&#039;&#039;Display&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Orthographic&#039;&#039;&#039; to change the drawing mode, then rotate the displayed crystal so that you are looking at one vertex (looking down the 111 direction, in crystallographic terms).&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window again. Change the representation style from &#039;&#039;&#039;VDW&#039;&#039;&#039; to points, then click the &#039;&#039;&#039;Create Rep&#039;&#039;&#039; button. This creates a second representation, allowing a subset of the atoms to be drawn in a different way. The &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; box allows us to choose which atoms this representation applies to. We just want to pick two of them at random &amp;amp;mdash; VMD assigns every atom an index, from 0 to N-1. In our case, there are 1000 atoms, so choose two numbers between 0 and 999. Changed the &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; field to &amp;lt;pre&amp;gt;index i or index j&amp;lt;/pre&amp;gt; where i and j are your chosen numbers, press return, then change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; to &#039;&#039;&#039;VDW&#039;&#039;&#039;. You should now see only two atoms represented by spheres, with the rest shown as small points. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, click play. Try rotating the box, and changing the playback speed.&lt;br /&gt;
&lt;br /&gt;
You will see that sometimes one of the spheres seems to change position across the box very rapidly &amp;amp;mdash; this occurs when it reaches one periodic boundary, and is reflected back across the other face. Try playing with some of the other representation types in VMD &amp;amp;mdash; it  is a very powerful package, which is often used to render images of simulated proteins, so many of its options aren&#039;t relevant to our simple system!&lt;br /&gt;
&lt;br /&gt;
===Checking equilibration===&lt;br /&gt;
&lt;br /&gt;
When we first set up a simulation, it is very important to make sure that our system reaches an equilibrium state. We characterise equilibrium by the average values of thermodynamic quantities becoming constant (due to the approximations that we have made, there will always be fluctuations, but the average values will become constant).&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to plot the thermodynamic output of the simulation to see how long it takes to reach the equilibrium state (and indeed, whether this happens at all). Instructions are given below to import data from the LAMMPS log file into Microsoft Excel. Once you have the data in a spreadsheet, you can plot it. If you know how to use some of the other plotting software available on the chemistry computers (like Origin), you are welcome to use it.&lt;br /&gt;
&lt;br /&gt;
# Open a blank Excel workbook&lt;br /&gt;
# Choose the &#039;&#039;&#039;Data&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;From Text&#039;&#039;&#039; button&lt;br /&gt;
# Select one of your simulation log files&lt;br /&gt;
# Set the &#039;&#039;&#039;Start import at row&#039;&#039;&#039; field to &#039;&#039;&#039;25&#039;&#039;&#039; (this ignores all of the diagnostic information at the top of the file)&lt;br /&gt;
# Set the &#039;&#039;&#039;Original Data type&#039;&#039;&#039; to &#039;&#039;&#039;Delimited&#039;&#039;&#039;, then click &#039;&#039;&#039;Next&#039;&#039;&#039;&lt;br /&gt;
# Tick the &#039;&#039;&#039;Space&#039;&#039;&#039; box, and make sure that &#039;&#039;&#039;Treat consecutive delimiters as one&#039;&#039;&#039; box is ticked.&lt;br /&gt;
# On the next dialog, you can select where you want the data to be inserted. When you are happy, click &#039;&#039;&#039;OK&#039;&#039;&#039;. The data will be inserted into your spreadsheet.&lt;br /&gt;
# Scroll to the bottom of the data &amp;amp;mdash; you will see a lot of timing information from the simulation. Delete everything beyond the end of your thermodynamic data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 14: make plots of the energy, temperature, and pressure, against time for the 0.001 timestep experiment (attach a picture to your report). Does the simulation reach equilibrium? When you have done this, make a single plot which shows the energy versus time for all of the timesteps you have simulated (again, attach a picture to your report). Of the timesteps that you used, which timestep will you use for subsequent simulations and why? [9 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734559</id>
		<title>Third year simulation experiment/Equilibration</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734559"/>
		<updated>2018-10-08T09:46:09Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Running the simulation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We will be using the LAMMPS program to carry out our molecular dynamics simulations.&lt;br /&gt;
&#039;&#039;&#039;In several places in this section, we will ask you to consult the LAMMPS manual to find out things about how the software works. You can find the manual [https://lammps.sandia.gov/doc/Manual.html here].&#039;&#039;&#039; We appreciate that the format of this document can make it a little hard to navigate, but it is the definitive resource on how different commands in LAMMPS work, and is therefore invaluable. &lt;br /&gt;
&lt;br /&gt;
===Creating the simulation box===&lt;br /&gt;
In the previous section, it was pointed out that before we can start a simulation, we need to know the initial states of all of the atoms in the system. Exactly what information we need about each atom depends on which method of numerical integration we need, but at the very least we need to specify the starting position of each atom. If we wanted to simulate a crystal, this information would be quite easy to come by &amp;amp;mdash; we could just look up the crystal structure, and use that to generate coordinates for however many unit cells we wanted. For this purpose, LAMMPS includes a command which generates crystal lattice structures.&lt;br /&gt;
&lt;br /&gt;
Generating coordinates for atoms in a liquid is more difficult. There is no long range order, so we can&#039;t use a single point of reference to work out the positions of every other atom like we can in a solid. We could generate a random position for each atom. This would certainly create a disordered structure, but causes larger problems when we try to run the simulation.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 8: Why do you think giving atoms random starting coordinates causes problems in simulations? Hint: what happens if two atoms happen to be generated close together? [2 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Instead, we are going to place the atoms on the lattice points of a simple cubic lattice. This, of course, is not a situation in which the system is likely to be found physically. It turns out, though, that if we simulate for enough time we will find that the atoms rearrange themselves into more realistic configurations. We will discuss towards the end of this section exactly what is meant by &amp;quot;enough time&amp;quot;!&lt;br /&gt;
&lt;br /&gt;
Consider the line in the input file &amp;lt;pre&amp;gt;lattice sc 0.8&amp;lt;/pre&amp;gt; This command creates a grid of points forming a simple cubic lattice (one lattice point per unit cell). The parameter &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt; specifies the number density (number of lattice points per unit volume). In a corresponding output file, you will see the line &amp;lt;pre&amp;gt;Lattice spacing in x,y,z = 1.07722 1.07722 1.07722&amp;lt;/pre&amp;gt; This indicates that the distance between the points of this lattice is &amp;lt;math&amp;gt;1.07722&amp;lt;/math&amp;gt; (in reduced units, remember!).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 9: Satisfy yourself that this lattice spacing corresponds to a number density of lattice points of &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt;. Consider instead a face-centred cubic lattice with a lattice point number density of 1.2. What is the side length of the cubic unit cell? [3 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The next lines in the input file are&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
region box block 0 10 0 10 0 10&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The corresponding log file output is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Created orthogonal box = (0 0 0) to (10.7722 10.7722 10.7722)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The region command simply defines a geometrical region in space, which we call &amp;quot;box&amp;quot;. In this case, &amp;quot;box&amp;quot; is a cube extending ten lattice spacings from the origin in all three dimensions. The subsequent create_box command tells LAMMPS to use the geometrical region called &amp;quot;box&amp;quot; as a template for the simulation box. The number 1 between &amp;quot;create_box&amp;quot; and &amp;quot;box&amp;quot; indicates that our simulation will contain only one type (species) of atom.&lt;br /&gt;
&lt;br /&gt;
So far we have defined a simulation box which is based around a virtual simple cubic lattice. Our box contains 1000 (10x10x10) unit cells of this lattice, and so contains 1000 lattice points. We now need to fill our simulation box with atoms. The input command is &amp;lt;pre&amp;gt;create_atoms 1 box&amp;lt;/pre&amp;gt; while the log file simply contains an acknowledgement of this &amp;lt;pre&amp;gt;Created 1000 atoms&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The create_atoms command has two arguments; the first tells LAMMPS that all of the atoms that we create will be of type 1. Every atom in the simulation has a type &amp;amp;mdash; because we will be simulating a pure fluid, containing only one chemical species, every atom will have the same type. The actual type that we assign to each atom is arbitrary &amp;amp;mdash; type 1 does not, for example, need to correspond to the element with atomic number 1 (hydrogen). If we wanted to simulate water, we might make the hydrogen atoms type 1 and the oxygen atoms type 2. We will specify the physical and chemical properties of each atom type later in the input script.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 10: Consider again the face-centred cubic lattice from the previous task. How many atoms would be created by the create_atoms command if you had defined that lattice instead? [1 mark]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The remaining data in the log file isn&#039;t very instructive as it stands &amp;amp;mdash; it simply contains a list of the thermodynamic properties of the simulation at certain intervals. In a few sections time, we will plot this data, but for now you can close the log file. Keep the input script open.&lt;br /&gt;
&lt;br /&gt;
===Setting the properties of the atoms===&lt;br /&gt;
&lt;br /&gt;
In addition to their positions, we also need the physical properties of the atoms to be able to perform the simulation. We set these properties on a &#039;per-type&#039; basis, so that every atom of the same type has the same mass and the same interactions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 11: Using the [https://lammps.sandia.gov/doc/Manual.html LAMMPS MANUAL], find the purpose of the following commands in the input script: [3 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mass 1 1.0&lt;br /&gt;
pair_style lj/cut 3.0&lt;br /&gt;
pair_coeff * * 1.0 1.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So far we have created 1000 atoms, and we know the starting (&amp;lt;math&amp;gt;t = 0&amp;lt;/math&amp;gt;) position for each of them. We have also set their masses, and told LAMMPS what sort of forces to calculate between them. The final thing we need to specify to completely specify the initial conditions is the velocity of each atom.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 12: Given that we are specifying &amp;lt;math&amp;gt;\mathbf{x}_i\left(0\right)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{v}_i\left(0\right)&amp;lt;/math&amp;gt;, which integration algorithm are we going to use? [1 mark]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Choosing initial velocities for the atoms is a little easier than choosing initial positions. From the statistical thermodynamics lectures, you should know that, at equilibrium, the velocities of atoms in any system must be distributed according to the [http://en.wikipedia.org/wiki/Maxwell%E2%80%93Boltzmann_distribution Maxwell-Boltzmann (MB) distribution]. If we know the masses of the atoms, and we know what temperature we want to simulate, then we can determine the relevant MB distribution function. LAMMPS is able to give every atom a random velocity whilst ensuring that overall the MB distribution is followed. This is the purpose of the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
velocity all create 1.5 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see the manual page for this command [http://lammps.sandia.gov/doc/velocity.html here], but the key sections are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;all&#039;&#039;&#039;: the &#039;&#039;group&#039;&#039; of atoms on which the command acts. &#039;&#039;&#039;all&#039;&#039;&#039; simply specifies that we want every atom to have a velocity assigned to it.&lt;br /&gt;
* &#039;&#039;&#039;1.5&#039;&#039;&#039;: the temperature, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, needed to calculate the MB distribution(in reduced units, as always)&lt;br /&gt;
&lt;br /&gt;
===Monitoring thermodynamic properties===&lt;br /&gt;
&lt;br /&gt;
We need to be sure that our simulation is correctly modelling whatever physical system we want to study. It is relatively easy to set up simulations, but how can we be sure that the &amp;quot;results&amp;quot; we get make sense? One of the best ways is to calculate from the simulation things that we can measure in experiment, and see if they agree. For example, we might want to simulate our system at a particular temperature and pressure, and measure the resulting density. If we repeat this over a range of temperatures at the same pressure, we will be able to plot an &#039;&#039;equation of state&#039;&#039;, which we could compare to experimental measurements.&lt;br /&gt;
&lt;br /&gt;
LAMMPS is able to calculate a great deal of thermodynamic information for us (you can see a full list of the properties it is able to calculate [http://lammps.sandia.gov/doc/thermo_style.html here]), but in these first simulations we are only interested in those properties specified in these commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
thermo 10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first controls which properties will be printed out in the log file. In this case, we print how much time we have simulated so far (which is &#039;&#039;not&#039;&#039; the same as how long it has taken us to simulate it!), the total energy of the atoms, their temperature, and their pressure. The second line tells LAMMPS to print this information on every 10th timestep.&lt;br /&gt;
&lt;br /&gt;
===Running the simulation===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Look at the lines below.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### SPECIFY TIMESTEP ###&lt;br /&gt;
variable timestep equal 0.001&lt;br /&gt;
variable n_steps equal floor(100/${timestep})&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
### RUN SIMULATION ###&lt;br /&gt;
run ${n_steps}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The second line (starting &amp;quot;variable timestep...&amp;quot;) tells LAMMPS that if it encounters the text ${timestep} on a subsequent line, it should replace it by the value given. In this case, the value ${timestep} is always replaced by 0.001.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; &amp;lt;big&amp;gt; TASK 13: In light of this, what do you think the purpose of these lines is? Why not just write:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
timestep 0.001&lt;br /&gt;
run 100000&lt;br /&gt;
&amp;lt;/pre&amp;gt; [1 mark] &amp;lt;/big&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Ask the demonstrator if you need help.&#039;&#039;&#039;&lt;br /&gt;
It is now time to run your first simulation, submit the input script with the data file in the intro folder of the files you have downloaded Try changing the timestep - what happens when you make the timestep larger?.&lt;br /&gt;
&lt;br /&gt;
===Visualising the trajectory===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;trajectory files&#039;&#039;&#039; contain the positions of all the atoms in the simulation, recorded at a set interval (for all of these simulations, this was every ten timesteps &amp;amp;mdash; this is controlled by the &#039;&#039;&#039;dump&#039;&#039;&#039; command in the input scripts). We use a programme called [http://www.ks.uiuc.edu/Research/vmd/ &#039;&#039;&#039;VMD&#039;&#039;&#039;] to view these trajectories, which you should find is already installed on both the desktop and laptop computers. You can run VMD from the start menu with &#039;&#039;&#039;Start&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;All Programs&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;University of Illinois&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;VMD&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
====Loading a Trajectory====&lt;br /&gt;
&lt;br /&gt;
We&#039;ll start by looking at the output of the 0.015 timestep simulation. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;File&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;New Molecule&#039;&#039;&#039;. Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button, then select the relevant trajectory file. In the &#039;&#039;&#039;Determine file type&#039;&#039;&#039; dropdown, select &#039;&#039;&#039;LAMMPS Trajectory&#039;&#039;&#039;. Then click &#039;&#039;&#039;Load&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You will see that the &#039;&#039;&#039;VMD 1.9.1 OpenGL Display&#039;&#039;&#039; window now shows a horrible mess. VMD&#039;s default behaviour is to draw lines between atoms which it thinks might be chemically bonded. Our system doesn&#039;t model chemical bonds, so we want to turn this off. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;Graphics&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Representations&#039;&#039;&#039;. This shows a list of &amp;quot;representations&amp;quot; of our atoms. You will see that at the moment, there is a single representation listed, and it is selected. It will have the &#039;&#039;Lines&#039;&#039; style, the &#039;&#039;Name&#039;&#039; colour, and the selection &#039;&#039;all&#039;&#039;. &amp;quot;Selection&amp;quot; simply tells VMD which atoms we want it to draw. We want to show every atom, so the current selection is fine. The &#039;&#039;name&#039;&#039; colouring method just makes VMD give atoms colours according to their specified type. The colour isn&#039;t important to us, so we can leave this be too. The &amp;quot;style&amp;quot; tells VMD what we want it to display for each atom. Change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; from &#039;&#039;Lines&#039;&#039; to &#039;&#039;VDW&#039;&#039;. You will see that the mess of lines is replaced by a mess of low resolution, overlapping spheres. Change the &#039;&#039;&#039;Sphere Scale&#039;&#039;&#039; to 0.3, and the &#039;&#039;&#039;Sphere Resolution&#039;&#039;&#039; to 17. The result should look a little smoother. Close the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window. You will notice that in the bottom right of the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, there is a small play button. Click this, and you will see the animated version of your simulation trajectory.&lt;br /&gt;
&lt;br /&gt;
By clicking and dragging with the mouse, you can rotate the simulation box (though this may be sluggish). At any time, you can reset the view by pressing the equals key.&lt;br /&gt;
&lt;br /&gt;
====Tracking a Single Particle====&lt;br /&gt;
To illustrate the periodic boundary conditions that we are using, we are going to draw almost all of the atoms as points, but we will pick a single atom at random to draw as a sphere. This will make it easy to see how a single atom moves through the box. Reset the display using the equals key, then use the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window controls to pause the trajectory and reset it to the first trajectory (play with the different buttons until you find the one that does this). You should see the perfect cubic lattice. Use the option &#039;&#039;&#039;Display&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Orthographic&#039;&#039;&#039; to change the drawing mode, then rotate the displayed crystal so that you are looking at one vertex (looking down the 111 direction, in crystallographic terms).&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window again. Change the representation style from &#039;&#039;&#039;VDW&#039;&#039;&#039; to points, then click the &#039;&#039;&#039;Create Rep&#039;&#039;&#039; button. This creates a second representation, allowing a subset of the atoms to be drawn in a different way. The &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; box allows us to choose which atoms this representation applies to. We just want to pick two of them at random &amp;amp;mdash; VMD assigns every atom an index, from 0 to N-1. In our case, there are 1000 atoms, so choose two numbers between 0 and 999. Changed the &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; field to &amp;lt;pre&amp;gt;index i or index j&amp;lt;/pre&amp;gt; where i and j are your chosen numbers, press return, then change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; to &#039;&#039;&#039;VDW&#039;&#039;&#039;. You should now see only two atoms represented by spheres, with the rest shown as small points. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, click play. Try rotating the box, and changing the playback speed.&lt;br /&gt;
&lt;br /&gt;
You will see that sometimes one of the spheres seems to change position across the box very rapidly &amp;amp;mdash; this occurs when it reaches one periodic boundary, and is reflected back across the other face. Try playing with some of the other representation types in VMD &amp;amp;mdash; it  is a very powerful package, which is often used to render images of simulated proteins, so many of its options aren&#039;t relevant to our simple system!&lt;br /&gt;
&lt;br /&gt;
===Checking equilibration===&lt;br /&gt;
&lt;br /&gt;
When we first set up a simulation, it is very important to make sure that our system reaches an equilibrium state. We characterise equilibrium by the average values of thermodynamic quantities becoming constant (due to the approximations that we have made, there will always be fluctuations, but the average values will become constant).&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to plot the thermodynamic output of the simulation to see how long it takes to reach the equilibrium state (and indeed, whether this happens at all). Instructions are given below to import data from the LAMMPS log file into Microsoft Excel. Once you have the data in a spreadsheet, you can plot it. If you know how to use some of the other plotting software available on the chemistry computers (like Origin), you are welcome to use it.&lt;br /&gt;
&lt;br /&gt;
# Open a blank Excel workbook&lt;br /&gt;
# Choose the &#039;&#039;&#039;Data&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;From Text&#039;&#039;&#039; button&lt;br /&gt;
# Select one of your simulation log files&lt;br /&gt;
# Set the &#039;&#039;&#039;Start import at row&#039;&#039;&#039; field to &#039;&#039;&#039;25&#039;&#039;&#039; (this ignores all of the diagnostic information at the top of the file)&lt;br /&gt;
# Set the &#039;&#039;&#039;Original Data type&#039;&#039;&#039; to &#039;&#039;&#039;Delimited&#039;&#039;&#039;, then click &#039;&#039;&#039;Next&#039;&#039;&#039;&lt;br /&gt;
# Tick the &#039;&#039;&#039;Space&#039;&#039;&#039; box, and make sure that &#039;&#039;&#039;Treat consecutive delimiters as one&#039;&#039;&#039; box is ticked.&lt;br /&gt;
# On the next dialog, you can select where you want the data to be inserted. When you are happy, click &#039;&#039;&#039;OK&#039;&#039;&#039;. The data will be inserted into your spreadsheet.&lt;br /&gt;
# Scroll to the bottom of the data &amp;amp;mdash; you will see a lot of timing information from the simulation. Delete everything beyond the end of your thermodynamic data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK: make plots of the energy, temperature, and pressure, against time for the 0.001 timestep experiment (attach a picture to your report). Does the simulation reach equilibrium? When you have done this, make a single plot which shows the energy versus time for all of the timesteps you have simulated (again, attach a picture to your report). Of the timesteps that you used, which timestep will you use for subsequent simulations and why? [9 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734558</id>
		<title>Third year simulation experiment/Equilibration</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734558"/>
		<updated>2018-10-08T09:45:49Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Setting the properties of the atoms */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We will be using the LAMMPS program to carry out our molecular dynamics simulations.&lt;br /&gt;
&#039;&#039;&#039;In several places in this section, we will ask you to consult the LAMMPS manual to find out things about how the software works. You can find the manual [https://lammps.sandia.gov/doc/Manual.html here].&#039;&#039;&#039; We appreciate that the format of this document can make it a little hard to navigate, but it is the definitive resource on how different commands in LAMMPS work, and is therefore invaluable. &lt;br /&gt;
&lt;br /&gt;
===Creating the simulation box===&lt;br /&gt;
In the previous section, it was pointed out that before we can start a simulation, we need to know the initial states of all of the atoms in the system. Exactly what information we need about each atom depends on which method of numerical integration we need, but at the very least we need to specify the starting position of each atom. If we wanted to simulate a crystal, this information would be quite easy to come by &amp;amp;mdash; we could just look up the crystal structure, and use that to generate coordinates for however many unit cells we wanted. For this purpose, LAMMPS includes a command which generates crystal lattice structures.&lt;br /&gt;
&lt;br /&gt;
Generating coordinates for atoms in a liquid is more difficult. There is no long range order, so we can&#039;t use a single point of reference to work out the positions of every other atom like we can in a solid. We could generate a random position for each atom. This would certainly create a disordered structure, but causes larger problems when we try to run the simulation.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 8: Why do you think giving atoms random starting coordinates causes problems in simulations? Hint: what happens if two atoms happen to be generated close together? [2 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Instead, we are going to place the atoms on the lattice points of a simple cubic lattice. This, of course, is not a situation in which the system is likely to be found physically. It turns out, though, that if we simulate for enough time we will find that the atoms rearrange themselves into more realistic configurations. We will discuss towards the end of this section exactly what is meant by &amp;quot;enough time&amp;quot;!&lt;br /&gt;
&lt;br /&gt;
Consider the line in the input file &amp;lt;pre&amp;gt;lattice sc 0.8&amp;lt;/pre&amp;gt; This command creates a grid of points forming a simple cubic lattice (one lattice point per unit cell). The parameter &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt; specifies the number density (number of lattice points per unit volume). In a corresponding output file, you will see the line &amp;lt;pre&amp;gt;Lattice spacing in x,y,z = 1.07722 1.07722 1.07722&amp;lt;/pre&amp;gt; This indicates that the distance between the points of this lattice is &amp;lt;math&amp;gt;1.07722&amp;lt;/math&amp;gt; (in reduced units, remember!).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 9: Satisfy yourself that this lattice spacing corresponds to a number density of lattice points of &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt;. Consider instead a face-centred cubic lattice with a lattice point number density of 1.2. What is the side length of the cubic unit cell? [3 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The next lines in the input file are&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
region box block 0 10 0 10 0 10&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The corresponding log file output is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Created orthogonal box = (0 0 0) to (10.7722 10.7722 10.7722)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The region command simply defines a geometrical region in space, which we call &amp;quot;box&amp;quot;. In this case, &amp;quot;box&amp;quot; is a cube extending ten lattice spacings from the origin in all three dimensions. The subsequent create_box command tells LAMMPS to use the geometrical region called &amp;quot;box&amp;quot; as a template for the simulation box. The number 1 between &amp;quot;create_box&amp;quot; and &amp;quot;box&amp;quot; indicates that our simulation will contain only one type (species) of atom.&lt;br /&gt;
&lt;br /&gt;
So far we have defined a simulation box which is based around a virtual simple cubic lattice. Our box contains 1000 (10x10x10) unit cells of this lattice, and so contains 1000 lattice points. We now need to fill our simulation box with atoms. The input command is &amp;lt;pre&amp;gt;create_atoms 1 box&amp;lt;/pre&amp;gt; while the log file simply contains an acknowledgement of this &amp;lt;pre&amp;gt;Created 1000 atoms&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The create_atoms command has two arguments; the first tells LAMMPS that all of the atoms that we create will be of type 1. Every atom in the simulation has a type &amp;amp;mdash; because we will be simulating a pure fluid, containing only one chemical species, every atom will have the same type. The actual type that we assign to each atom is arbitrary &amp;amp;mdash; type 1 does not, for example, need to correspond to the element with atomic number 1 (hydrogen). If we wanted to simulate water, we might make the hydrogen atoms type 1 and the oxygen atoms type 2. We will specify the physical and chemical properties of each atom type later in the input script.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 10: Consider again the face-centred cubic lattice from the previous task. How many atoms would be created by the create_atoms command if you had defined that lattice instead? [1 mark]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The remaining data in the log file isn&#039;t very instructive as it stands &amp;amp;mdash; it simply contains a list of the thermodynamic properties of the simulation at certain intervals. In a few sections time, we will plot this data, but for now you can close the log file. Keep the input script open.&lt;br /&gt;
&lt;br /&gt;
===Setting the properties of the atoms===&lt;br /&gt;
&lt;br /&gt;
In addition to their positions, we also need the physical properties of the atoms to be able to perform the simulation. We set these properties on a &#039;per-type&#039; basis, so that every atom of the same type has the same mass and the same interactions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 11: Using the [https://lammps.sandia.gov/doc/Manual.html LAMMPS MANUAL], find the purpose of the following commands in the input script: [3 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mass 1 1.0&lt;br /&gt;
pair_style lj/cut 3.0&lt;br /&gt;
pair_coeff * * 1.0 1.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So far we have created 1000 atoms, and we know the starting (&amp;lt;math&amp;gt;t = 0&amp;lt;/math&amp;gt;) position for each of them. We have also set their masses, and told LAMMPS what sort of forces to calculate between them. The final thing we need to specify to completely specify the initial conditions is the velocity of each atom.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 12: Given that we are specifying &amp;lt;math&amp;gt;\mathbf{x}_i\left(0\right)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{v}_i\left(0\right)&amp;lt;/math&amp;gt;, which integration algorithm are we going to use? [1 mark]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Choosing initial velocities for the atoms is a little easier than choosing initial positions. From the statistical thermodynamics lectures, you should know that, at equilibrium, the velocities of atoms in any system must be distributed according to the [http://en.wikipedia.org/wiki/Maxwell%E2%80%93Boltzmann_distribution Maxwell-Boltzmann (MB) distribution]. If we know the masses of the atoms, and we know what temperature we want to simulate, then we can determine the relevant MB distribution function. LAMMPS is able to give every atom a random velocity whilst ensuring that overall the MB distribution is followed. This is the purpose of the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
velocity all create 1.5 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see the manual page for this command [http://lammps.sandia.gov/doc/velocity.html here], but the key sections are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;all&#039;&#039;&#039;: the &#039;&#039;group&#039;&#039; of atoms on which the command acts. &#039;&#039;&#039;all&#039;&#039;&#039; simply specifies that we want every atom to have a velocity assigned to it.&lt;br /&gt;
* &#039;&#039;&#039;1.5&#039;&#039;&#039;: the temperature, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, needed to calculate the MB distribution(in reduced units, as always)&lt;br /&gt;
&lt;br /&gt;
===Monitoring thermodynamic properties===&lt;br /&gt;
&lt;br /&gt;
We need to be sure that our simulation is correctly modelling whatever physical system we want to study. It is relatively easy to set up simulations, but how can we be sure that the &amp;quot;results&amp;quot; we get make sense? One of the best ways is to calculate from the simulation things that we can measure in experiment, and see if they agree. For example, we might want to simulate our system at a particular temperature and pressure, and measure the resulting density. If we repeat this over a range of temperatures at the same pressure, we will be able to plot an &#039;&#039;equation of state&#039;&#039;, which we could compare to experimental measurements.&lt;br /&gt;
&lt;br /&gt;
LAMMPS is able to calculate a great deal of thermodynamic information for us (you can see a full list of the properties it is able to calculate [http://lammps.sandia.gov/doc/thermo_style.html here]), but in these first simulations we are only interested in those properties specified in these commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
thermo 10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first controls which properties will be printed out in the log file. In this case, we print how much time we have simulated so far (which is &#039;&#039;not&#039;&#039; the same as how long it has taken us to simulate it!), the total energy of the atoms, their temperature, and their pressure. The second line tells LAMMPS to print this information on every 10th timestep.&lt;br /&gt;
&lt;br /&gt;
===Running the simulation===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Look at the lines below.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### SPECIFY TIMESTEP ###&lt;br /&gt;
variable timestep equal 0.001&lt;br /&gt;
variable n_steps equal floor(100/${timestep})&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
### RUN SIMULATION ###&lt;br /&gt;
run ${n_steps}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The second line (starting &amp;quot;variable timestep...&amp;quot;) tells LAMMPS that if it encounters the text ${timestep} on a subsequent line, it should replace it by the value given. In this case, the value ${timestep} is always replaced by 0.001.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; &amp;lt;big&amp;gt; TASK: In light of this, what do you think the purpose of these lines is? Why not just write:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
timestep 0.001&lt;br /&gt;
run 100000&lt;br /&gt;
&amp;lt;/pre&amp;gt; [1 mark] &amp;lt;/big&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Ask the demonstrator if you need help.&#039;&#039;&#039;&lt;br /&gt;
It is now time to run your first simulation, submit the input script with the data file in the intro folder of the files you have downloaded Try changing the timestep - what happens when you make the timestep larger?.&lt;br /&gt;
&lt;br /&gt;
===Visualising the trajectory===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;trajectory files&#039;&#039;&#039; contain the positions of all the atoms in the simulation, recorded at a set interval (for all of these simulations, this was every ten timesteps &amp;amp;mdash; this is controlled by the &#039;&#039;&#039;dump&#039;&#039;&#039; command in the input scripts). We use a programme called [http://www.ks.uiuc.edu/Research/vmd/ &#039;&#039;&#039;VMD&#039;&#039;&#039;] to view these trajectories, which you should find is already installed on both the desktop and laptop computers. You can run VMD from the start menu with &#039;&#039;&#039;Start&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;All Programs&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;University of Illinois&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;VMD&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
====Loading a Trajectory====&lt;br /&gt;
&lt;br /&gt;
We&#039;ll start by looking at the output of the 0.015 timestep simulation. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;File&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;New Molecule&#039;&#039;&#039;. Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button, then select the relevant trajectory file. In the &#039;&#039;&#039;Determine file type&#039;&#039;&#039; dropdown, select &#039;&#039;&#039;LAMMPS Trajectory&#039;&#039;&#039;. Then click &#039;&#039;&#039;Load&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You will see that the &#039;&#039;&#039;VMD 1.9.1 OpenGL Display&#039;&#039;&#039; window now shows a horrible mess. VMD&#039;s default behaviour is to draw lines between atoms which it thinks might be chemically bonded. Our system doesn&#039;t model chemical bonds, so we want to turn this off. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;Graphics&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Representations&#039;&#039;&#039;. This shows a list of &amp;quot;representations&amp;quot; of our atoms. You will see that at the moment, there is a single representation listed, and it is selected. It will have the &#039;&#039;Lines&#039;&#039; style, the &#039;&#039;Name&#039;&#039; colour, and the selection &#039;&#039;all&#039;&#039;. &amp;quot;Selection&amp;quot; simply tells VMD which atoms we want it to draw. We want to show every atom, so the current selection is fine. The &#039;&#039;name&#039;&#039; colouring method just makes VMD give atoms colours according to their specified type. The colour isn&#039;t important to us, so we can leave this be too. The &amp;quot;style&amp;quot; tells VMD what we want it to display for each atom. Change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; from &#039;&#039;Lines&#039;&#039; to &#039;&#039;VDW&#039;&#039;. You will see that the mess of lines is replaced by a mess of low resolution, overlapping spheres. Change the &#039;&#039;&#039;Sphere Scale&#039;&#039;&#039; to 0.3, and the &#039;&#039;&#039;Sphere Resolution&#039;&#039;&#039; to 17. The result should look a little smoother. Close the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window. You will notice that in the bottom right of the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, there is a small play button. Click this, and you will see the animated version of your simulation trajectory.&lt;br /&gt;
&lt;br /&gt;
By clicking and dragging with the mouse, you can rotate the simulation box (though this may be sluggish). At any time, you can reset the view by pressing the equals key.&lt;br /&gt;
&lt;br /&gt;
====Tracking a Single Particle====&lt;br /&gt;
To illustrate the periodic boundary conditions that we are using, we are going to draw almost all of the atoms as points, but we will pick a single atom at random to draw as a sphere. This will make it easy to see how a single atom moves through the box. Reset the display using the equals key, then use the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window controls to pause the trajectory and reset it to the first trajectory (play with the different buttons until you find the one that does this). You should see the perfect cubic lattice. Use the option &#039;&#039;&#039;Display&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Orthographic&#039;&#039;&#039; to change the drawing mode, then rotate the displayed crystal so that you are looking at one vertex (looking down the 111 direction, in crystallographic terms).&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window again. Change the representation style from &#039;&#039;&#039;VDW&#039;&#039;&#039; to points, then click the &#039;&#039;&#039;Create Rep&#039;&#039;&#039; button. This creates a second representation, allowing a subset of the atoms to be drawn in a different way. The &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; box allows us to choose which atoms this representation applies to. We just want to pick two of them at random &amp;amp;mdash; VMD assigns every atom an index, from 0 to N-1. In our case, there are 1000 atoms, so choose two numbers between 0 and 999. Changed the &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; field to &amp;lt;pre&amp;gt;index i or index j&amp;lt;/pre&amp;gt; where i and j are your chosen numbers, press return, then change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; to &#039;&#039;&#039;VDW&#039;&#039;&#039;. You should now see only two atoms represented by spheres, with the rest shown as small points. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, click play. Try rotating the box, and changing the playback speed.&lt;br /&gt;
&lt;br /&gt;
You will see that sometimes one of the spheres seems to change position across the box very rapidly &amp;amp;mdash; this occurs when it reaches one periodic boundary, and is reflected back across the other face. Try playing with some of the other representation types in VMD &amp;amp;mdash; it  is a very powerful package, which is often used to render images of simulated proteins, so many of its options aren&#039;t relevant to our simple system!&lt;br /&gt;
&lt;br /&gt;
===Checking equilibration===&lt;br /&gt;
&lt;br /&gt;
When we first set up a simulation, it is very important to make sure that our system reaches an equilibrium state. We characterise equilibrium by the average values of thermodynamic quantities becoming constant (due to the approximations that we have made, there will always be fluctuations, but the average values will become constant).&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to plot the thermodynamic output of the simulation to see how long it takes to reach the equilibrium state (and indeed, whether this happens at all). Instructions are given below to import data from the LAMMPS log file into Microsoft Excel. Once you have the data in a spreadsheet, you can plot it. If you know how to use some of the other plotting software available on the chemistry computers (like Origin), you are welcome to use it.&lt;br /&gt;
&lt;br /&gt;
# Open a blank Excel workbook&lt;br /&gt;
# Choose the &#039;&#039;&#039;Data&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;From Text&#039;&#039;&#039; button&lt;br /&gt;
# Select one of your simulation log files&lt;br /&gt;
# Set the &#039;&#039;&#039;Start import at row&#039;&#039;&#039; field to &#039;&#039;&#039;25&#039;&#039;&#039; (this ignores all of the diagnostic information at the top of the file)&lt;br /&gt;
# Set the &#039;&#039;&#039;Original Data type&#039;&#039;&#039; to &#039;&#039;&#039;Delimited&#039;&#039;&#039;, then click &#039;&#039;&#039;Next&#039;&#039;&#039;&lt;br /&gt;
# Tick the &#039;&#039;&#039;Space&#039;&#039;&#039; box, and make sure that &#039;&#039;&#039;Treat consecutive delimiters as one&#039;&#039;&#039; box is ticked.&lt;br /&gt;
# On the next dialog, you can select where you want the data to be inserted. When you are happy, click &#039;&#039;&#039;OK&#039;&#039;&#039;. The data will be inserted into your spreadsheet.&lt;br /&gt;
# Scroll to the bottom of the data &amp;amp;mdash; you will see a lot of timing information from the simulation. Delete everything beyond the end of your thermodynamic data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK: make plots of the energy, temperature, and pressure, against time for the 0.001 timestep experiment (attach a picture to your report). Does the simulation reach equilibrium? When you have done this, make a single plot which shows the energy versus time for all of the timesteps you have simulated (again, attach a picture to your report). Of the timesteps that you used, which timestep will you use for subsequent simulations and why? [9 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734557</id>
		<title>Third year simulation experiment/Equilibration</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734557"/>
		<updated>2018-10-08T09:45:37Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Setting the properties of the atoms */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We will be using the LAMMPS program to carry out our molecular dynamics simulations.&lt;br /&gt;
&#039;&#039;&#039;In several places in this section, we will ask you to consult the LAMMPS manual to find out things about how the software works. You can find the manual [https://lammps.sandia.gov/doc/Manual.html here].&#039;&#039;&#039; We appreciate that the format of this document can make it a little hard to navigate, but it is the definitive resource on how different commands in LAMMPS work, and is therefore invaluable. &lt;br /&gt;
&lt;br /&gt;
===Creating the simulation box===&lt;br /&gt;
In the previous section, it was pointed out that before we can start a simulation, we need to know the initial states of all of the atoms in the system. Exactly what information we need about each atom depends on which method of numerical integration we need, but at the very least we need to specify the starting position of each atom. If we wanted to simulate a crystal, this information would be quite easy to come by &amp;amp;mdash; we could just look up the crystal structure, and use that to generate coordinates for however many unit cells we wanted. For this purpose, LAMMPS includes a command which generates crystal lattice structures.&lt;br /&gt;
&lt;br /&gt;
Generating coordinates for atoms in a liquid is more difficult. There is no long range order, so we can&#039;t use a single point of reference to work out the positions of every other atom like we can in a solid. We could generate a random position for each atom. This would certainly create a disordered structure, but causes larger problems when we try to run the simulation.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 8: Why do you think giving atoms random starting coordinates causes problems in simulations? Hint: what happens if two atoms happen to be generated close together? [2 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Instead, we are going to place the atoms on the lattice points of a simple cubic lattice. This, of course, is not a situation in which the system is likely to be found physically. It turns out, though, that if we simulate for enough time we will find that the atoms rearrange themselves into more realistic configurations. We will discuss towards the end of this section exactly what is meant by &amp;quot;enough time&amp;quot;!&lt;br /&gt;
&lt;br /&gt;
Consider the line in the input file &amp;lt;pre&amp;gt;lattice sc 0.8&amp;lt;/pre&amp;gt; This command creates a grid of points forming a simple cubic lattice (one lattice point per unit cell). The parameter &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt; specifies the number density (number of lattice points per unit volume). In a corresponding output file, you will see the line &amp;lt;pre&amp;gt;Lattice spacing in x,y,z = 1.07722 1.07722 1.07722&amp;lt;/pre&amp;gt; This indicates that the distance between the points of this lattice is &amp;lt;math&amp;gt;1.07722&amp;lt;/math&amp;gt; (in reduced units, remember!).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 9: Satisfy yourself that this lattice spacing corresponds to a number density of lattice points of &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt;. Consider instead a face-centred cubic lattice with a lattice point number density of 1.2. What is the side length of the cubic unit cell? [3 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The next lines in the input file are&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
region box block 0 10 0 10 0 10&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The corresponding log file output is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Created orthogonal box = (0 0 0) to (10.7722 10.7722 10.7722)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The region command simply defines a geometrical region in space, which we call &amp;quot;box&amp;quot;. In this case, &amp;quot;box&amp;quot; is a cube extending ten lattice spacings from the origin in all three dimensions. The subsequent create_box command tells LAMMPS to use the geometrical region called &amp;quot;box&amp;quot; as a template for the simulation box. The number 1 between &amp;quot;create_box&amp;quot; and &amp;quot;box&amp;quot; indicates that our simulation will contain only one type (species) of atom.&lt;br /&gt;
&lt;br /&gt;
So far we have defined a simulation box which is based around a virtual simple cubic lattice. Our box contains 1000 (10x10x10) unit cells of this lattice, and so contains 1000 lattice points. We now need to fill our simulation box with atoms. The input command is &amp;lt;pre&amp;gt;create_atoms 1 box&amp;lt;/pre&amp;gt; while the log file simply contains an acknowledgement of this &amp;lt;pre&amp;gt;Created 1000 atoms&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The create_atoms command has two arguments; the first tells LAMMPS that all of the atoms that we create will be of type 1. Every atom in the simulation has a type &amp;amp;mdash; because we will be simulating a pure fluid, containing only one chemical species, every atom will have the same type. The actual type that we assign to each atom is arbitrary &amp;amp;mdash; type 1 does not, for example, need to correspond to the element with atomic number 1 (hydrogen). If we wanted to simulate water, we might make the hydrogen atoms type 1 and the oxygen atoms type 2. We will specify the physical and chemical properties of each atom type later in the input script.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 10: Consider again the face-centred cubic lattice from the previous task. How many atoms would be created by the create_atoms command if you had defined that lattice instead? [1 mark]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The remaining data in the log file isn&#039;t very instructive as it stands &amp;amp;mdash; it simply contains a list of the thermodynamic properties of the simulation at certain intervals. In a few sections time, we will plot this data, but for now you can close the log file. Keep the input script open.&lt;br /&gt;
&lt;br /&gt;
===Setting the properties of the atoms===&lt;br /&gt;
&lt;br /&gt;
In addition to their positions, we also need the physical properties of the atoms to be able to perform the simulation. We set these properties on a &#039;per-type&#039; basis, so that every atom of the same type has the same mass and the same interactions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK: Using the [https://lammps.sandia.gov/doc/Manual.html LAMMPS MANUAL], find the purpose of the following commands in the input script: [3 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mass 1 1.0&lt;br /&gt;
pair_style lj/cut 3.0&lt;br /&gt;
pair_coeff * * 1.0 1.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So far we have created 1000 atoms, and we know the starting (&amp;lt;math&amp;gt;t = 0&amp;lt;/math&amp;gt;) position for each of them. We have also set their masses, and told LAMMPS what sort of forces to calculate between them. The final thing we need to specify to completely specify the initial conditions is the velocity of each atom.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 11: Given that we are specifying &amp;lt;math&amp;gt;\mathbf{x}_i\left(0\right)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{v}_i\left(0\right)&amp;lt;/math&amp;gt;, which integration algorithm are we going to use? [1 mark]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Choosing initial velocities for the atoms is a little easier than choosing initial positions. From the statistical thermodynamics lectures, you should know that, at equilibrium, the velocities of atoms in any system must be distributed according to the [http://en.wikipedia.org/wiki/Maxwell%E2%80%93Boltzmann_distribution Maxwell-Boltzmann (MB) distribution]. If we know the masses of the atoms, and we know what temperature we want to simulate, then we can determine the relevant MB distribution function. LAMMPS is able to give every atom a random velocity whilst ensuring that overall the MB distribution is followed. This is the purpose of the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
velocity all create 1.5 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see the manual page for this command [http://lammps.sandia.gov/doc/velocity.html here], but the key sections are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;all&#039;&#039;&#039;: the &#039;&#039;group&#039;&#039; of atoms on which the command acts. &#039;&#039;&#039;all&#039;&#039;&#039; simply specifies that we want every atom to have a velocity assigned to it.&lt;br /&gt;
* &#039;&#039;&#039;1.5&#039;&#039;&#039;: the temperature, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, needed to calculate the MB distribution(in reduced units, as always)&lt;br /&gt;
&lt;br /&gt;
===Monitoring thermodynamic properties===&lt;br /&gt;
&lt;br /&gt;
We need to be sure that our simulation is correctly modelling whatever physical system we want to study. It is relatively easy to set up simulations, but how can we be sure that the &amp;quot;results&amp;quot; we get make sense? One of the best ways is to calculate from the simulation things that we can measure in experiment, and see if they agree. For example, we might want to simulate our system at a particular temperature and pressure, and measure the resulting density. If we repeat this over a range of temperatures at the same pressure, we will be able to plot an &#039;&#039;equation of state&#039;&#039;, which we could compare to experimental measurements.&lt;br /&gt;
&lt;br /&gt;
LAMMPS is able to calculate a great deal of thermodynamic information for us (you can see a full list of the properties it is able to calculate [http://lammps.sandia.gov/doc/thermo_style.html here]), but in these first simulations we are only interested in those properties specified in these commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
thermo 10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first controls which properties will be printed out in the log file. In this case, we print how much time we have simulated so far (which is &#039;&#039;not&#039;&#039; the same as how long it has taken us to simulate it!), the total energy of the atoms, their temperature, and their pressure. The second line tells LAMMPS to print this information on every 10th timestep.&lt;br /&gt;
&lt;br /&gt;
===Running the simulation===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Look at the lines below.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### SPECIFY TIMESTEP ###&lt;br /&gt;
variable timestep equal 0.001&lt;br /&gt;
variable n_steps equal floor(100/${timestep})&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
### RUN SIMULATION ###&lt;br /&gt;
run ${n_steps}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The second line (starting &amp;quot;variable timestep...&amp;quot;) tells LAMMPS that if it encounters the text ${timestep} on a subsequent line, it should replace it by the value given. In this case, the value ${timestep} is always replaced by 0.001.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; &amp;lt;big&amp;gt; TASK: In light of this, what do you think the purpose of these lines is? Why not just write:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
timestep 0.001&lt;br /&gt;
run 100000&lt;br /&gt;
&amp;lt;/pre&amp;gt; [1 mark] &amp;lt;/big&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Ask the demonstrator if you need help.&#039;&#039;&#039;&lt;br /&gt;
It is now time to run your first simulation, submit the input script with the data file in the intro folder of the files you have downloaded Try changing the timestep - what happens when you make the timestep larger?.&lt;br /&gt;
&lt;br /&gt;
===Visualising the trajectory===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;trajectory files&#039;&#039;&#039; contain the positions of all the atoms in the simulation, recorded at a set interval (for all of these simulations, this was every ten timesteps &amp;amp;mdash; this is controlled by the &#039;&#039;&#039;dump&#039;&#039;&#039; command in the input scripts). We use a programme called [http://www.ks.uiuc.edu/Research/vmd/ &#039;&#039;&#039;VMD&#039;&#039;&#039;] to view these trajectories, which you should find is already installed on both the desktop and laptop computers. You can run VMD from the start menu with &#039;&#039;&#039;Start&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;All Programs&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;University of Illinois&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;VMD&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
====Loading a Trajectory====&lt;br /&gt;
&lt;br /&gt;
We&#039;ll start by looking at the output of the 0.015 timestep simulation. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;File&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;New Molecule&#039;&#039;&#039;. Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button, then select the relevant trajectory file. In the &#039;&#039;&#039;Determine file type&#039;&#039;&#039; dropdown, select &#039;&#039;&#039;LAMMPS Trajectory&#039;&#039;&#039;. Then click &#039;&#039;&#039;Load&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You will see that the &#039;&#039;&#039;VMD 1.9.1 OpenGL Display&#039;&#039;&#039; window now shows a horrible mess. VMD&#039;s default behaviour is to draw lines between atoms which it thinks might be chemically bonded. Our system doesn&#039;t model chemical bonds, so we want to turn this off. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;Graphics&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Representations&#039;&#039;&#039;. This shows a list of &amp;quot;representations&amp;quot; of our atoms. You will see that at the moment, there is a single representation listed, and it is selected. It will have the &#039;&#039;Lines&#039;&#039; style, the &#039;&#039;Name&#039;&#039; colour, and the selection &#039;&#039;all&#039;&#039;. &amp;quot;Selection&amp;quot; simply tells VMD which atoms we want it to draw. We want to show every atom, so the current selection is fine. The &#039;&#039;name&#039;&#039; colouring method just makes VMD give atoms colours according to their specified type. The colour isn&#039;t important to us, so we can leave this be too. The &amp;quot;style&amp;quot; tells VMD what we want it to display for each atom. Change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; from &#039;&#039;Lines&#039;&#039; to &#039;&#039;VDW&#039;&#039;. You will see that the mess of lines is replaced by a mess of low resolution, overlapping spheres. Change the &#039;&#039;&#039;Sphere Scale&#039;&#039;&#039; to 0.3, and the &#039;&#039;&#039;Sphere Resolution&#039;&#039;&#039; to 17. The result should look a little smoother. Close the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window. You will notice that in the bottom right of the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, there is a small play button. Click this, and you will see the animated version of your simulation trajectory.&lt;br /&gt;
&lt;br /&gt;
By clicking and dragging with the mouse, you can rotate the simulation box (though this may be sluggish). At any time, you can reset the view by pressing the equals key.&lt;br /&gt;
&lt;br /&gt;
====Tracking a Single Particle====&lt;br /&gt;
To illustrate the periodic boundary conditions that we are using, we are going to draw almost all of the atoms as points, but we will pick a single atom at random to draw as a sphere. This will make it easy to see how a single atom moves through the box. Reset the display using the equals key, then use the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window controls to pause the trajectory and reset it to the first trajectory (play with the different buttons until you find the one that does this). You should see the perfect cubic lattice. Use the option &#039;&#039;&#039;Display&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Orthographic&#039;&#039;&#039; to change the drawing mode, then rotate the displayed crystal so that you are looking at one vertex (looking down the 111 direction, in crystallographic terms).&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window again. Change the representation style from &#039;&#039;&#039;VDW&#039;&#039;&#039; to points, then click the &#039;&#039;&#039;Create Rep&#039;&#039;&#039; button. This creates a second representation, allowing a subset of the atoms to be drawn in a different way. The &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; box allows us to choose which atoms this representation applies to. We just want to pick two of them at random &amp;amp;mdash; VMD assigns every atom an index, from 0 to N-1. In our case, there are 1000 atoms, so choose two numbers between 0 and 999. Changed the &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; field to &amp;lt;pre&amp;gt;index i or index j&amp;lt;/pre&amp;gt; where i and j are your chosen numbers, press return, then change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; to &#039;&#039;&#039;VDW&#039;&#039;&#039;. You should now see only two atoms represented by spheres, with the rest shown as small points. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, click play. Try rotating the box, and changing the playback speed.&lt;br /&gt;
&lt;br /&gt;
You will see that sometimes one of the spheres seems to change position across the box very rapidly &amp;amp;mdash; this occurs when it reaches one periodic boundary, and is reflected back across the other face. Try playing with some of the other representation types in VMD &amp;amp;mdash; it  is a very powerful package, which is often used to render images of simulated proteins, so many of its options aren&#039;t relevant to our simple system!&lt;br /&gt;
&lt;br /&gt;
===Checking equilibration===&lt;br /&gt;
&lt;br /&gt;
When we first set up a simulation, it is very important to make sure that our system reaches an equilibrium state. We characterise equilibrium by the average values of thermodynamic quantities becoming constant (due to the approximations that we have made, there will always be fluctuations, but the average values will become constant).&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to plot the thermodynamic output of the simulation to see how long it takes to reach the equilibrium state (and indeed, whether this happens at all). Instructions are given below to import data from the LAMMPS log file into Microsoft Excel. Once you have the data in a spreadsheet, you can plot it. If you know how to use some of the other plotting software available on the chemistry computers (like Origin), you are welcome to use it.&lt;br /&gt;
&lt;br /&gt;
# Open a blank Excel workbook&lt;br /&gt;
# Choose the &#039;&#039;&#039;Data&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;From Text&#039;&#039;&#039; button&lt;br /&gt;
# Select one of your simulation log files&lt;br /&gt;
# Set the &#039;&#039;&#039;Start import at row&#039;&#039;&#039; field to &#039;&#039;&#039;25&#039;&#039;&#039; (this ignores all of the diagnostic information at the top of the file)&lt;br /&gt;
# Set the &#039;&#039;&#039;Original Data type&#039;&#039;&#039; to &#039;&#039;&#039;Delimited&#039;&#039;&#039;, then click &#039;&#039;&#039;Next&#039;&#039;&#039;&lt;br /&gt;
# Tick the &#039;&#039;&#039;Space&#039;&#039;&#039; box, and make sure that &#039;&#039;&#039;Treat consecutive delimiters as one&#039;&#039;&#039; box is ticked.&lt;br /&gt;
# On the next dialog, you can select where you want the data to be inserted. When you are happy, click &#039;&#039;&#039;OK&#039;&#039;&#039;. The data will be inserted into your spreadsheet.&lt;br /&gt;
# Scroll to the bottom of the data &amp;amp;mdash; you will see a lot of timing information from the simulation. Delete everything beyond the end of your thermodynamic data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK: make plots of the energy, temperature, and pressure, against time for the 0.001 timestep experiment (attach a picture to your report). Does the simulation reach equilibrium? When you have done this, make a single plot which shows the energy versus time for all of the timesteps you have simulated (again, attach a picture to your report). Of the timesteps that you used, which timestep will you use for subsequent simulations and why? [9 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734556</id>
		<title>Third year simulation experiment/Equilibration</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Equilibration&amp;diff=734556"/>
		<updated>2018-10-08T09:45:27Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Creating the simulation box */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We will be using the LAMMPS program to carry out our molecular dynamics simulations.&lt;br /&gt;
&#039;&#039;&#039;In several places in this section, we will ask you to consult the LAMMPS manual to find out things about how the software works. You can find the manual [https://lammps.sandia.gov/doc/Manual.html here].&#039;&#039;&#039; We appreciate that the format of this document can make it a little hard to navigate, but it is the definitive resource on how different commands in LAMMPS work, and is therefore invaluable. &lt;br /&gt;
&lt;br /&gt;
===Creating the simulation box===&lt;br /&gt;
In the previous section, it was pointed out that before we can start a simulation, we need to know the initial states of all of the atoms in the system. Exactly what information we need about each atom depends on which method of numerical integration we need, but at the very least we need to specify the starting position of each atom. If we wanted to simulate a crystal, this information would be quite easy to come by &amp;amp;mdash; we could just look up the crystal structure, and use that to generate coordinates for however many unit cells we wanted. For this purpose, LAMMPS includes a command which generates crystal lattice structures.&lt;br /&gt;
&lt;br /&gt;
Generating coordinates for atoms in a liquid is more difficult. There is no long range order, so we can&#039;t use a single point of reference to work out the positions of every other atom like we can in a solid. We could generate a random position for each atom. This would certainly create a disordered structure, but causes larger problems when we try to run the simulation.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 8: Why do you think giving atoms random starting coordinates causes problems in simulations? Hint: what happens if two atoms happen to be generated close together? [2 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Instead, we are going to place the atoms on the lattice points of a simple cubic lattice. This, of course, is not a situation in which the system is likely to be found physically. It turns out, though, that if we simulate for enough time we will find that the atoms rearrange themselves into more realistic configurations. We will discuss towards the end of this section exactly what is meant by &amp;quot;enough time&amp;quot;!&lt;br /&gt;
&lt;br /&gt;
Consider the line in the input file &amp;lt;pre&amp;gt;lattice sc 0.8&amp;lt;/pre&amp;gt; This command creates a grid of points forming a simple cubic lattice (one lattice point per unit cell). The parameter &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt; specifies the number density (number of lattice points per unit volume). In a corresponding output file, you will see the line &amp;lt;pre&amp;gt;Lattice spacing in x,y,z = 1.07722 1.07722 1.07722&amp;lt;/pre&amp;gt; This indicates that the distance between the points of this lattice is &amp;lt;math&amp;gt;1.07722&amp;lt;/math&amp;gt; (in reduced units, remember!).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 9: Satisfy yourself that this lattice spacing corresponds to a number density of lattice points of &amp;lt;math&amp;gt;0.8&amp;lt;/math&amp;gt;. Consider instead a face-centred cubic lattice with a lattice point number density of 1.2. What is the side length of the cubic unit cell? [3 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The next lines in the input file are&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
region box block 0 10 0 10 0 10&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The corresponding log file output is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Created orthogonal box = (0 0 0) to (10.7722 10.7722 10.7722)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The region command simply defines a geometrical region in space, which we call &amp;quot;box&amp;quot;. In this case, &amp;quot;box&amp;quot; is a cube extending ten lattice spacings from the origin in all three dimensions. The subsequent create_box command tells LAMMPS to use the geometrical region called &amp;quot;box&amp;quot; as a template for the simulation box. The number 1 between &amp;quot;create_box&amp;quot; and &amp;quot;box&amp;quot; indicates that our simulation will contain only one type (species) of atom.&lt;br /&gt;
&lt;br /&gt;
So far we have defined a simulation box which is based around a virtual simple cubic lattice. Our box contains 1000 (10x10x10) unit cells of this lattice, and so contains 1000 lattice points. We now need to fill our simulation box with atoms. The input command is &amp;lt;pre&amp;gt;create_atoms 1 box&amp;lt;/pre&amp;gt; while the log file simply contains an acknowledgement of this &amp;lt;pre&amp;gt;Created 1000 atoms&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The create_atoms command has two arguments; the first tells LAMMPS that all of the atoms that we create will be of type 1. Every atom in the simulation has a type &amp;amp;mdash; because we will be simulating a pure fluid, containing only one chemical species, every atom will have the same type. The actual type that we assign to each atom is arbitrary &amp;amp;mdash; type 1 does not, for example, need to correspond to the element with atomic number 1 (hydrogen). If we wanted to simulate water, we might make the hydrogen atoms type 1 and the oxygen atoms type 2. We will specify the physical and chemical properties of each atom type later in the input script.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK 10: Consider again the face-centred cubic lattice from the previous task. How many atoms would be created by the create_atoms command if you had defined that lattice instead? [1 mark]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The remaining data in the log file isn&#039;t very instructive as it stands &amp;amp;mdash; it simply contains a list of the thermodynamic properties of the simulation at certain intervals. In a few sections time, we will plot this data, but for now you can close the log file. Keep the input script open.&lt;br /&gt;
&lt;br /&gt;
===Setting the properties of the atoms===&lt;br /&gt;
&lt;br /&gt;
In addition to their positions, we also need the physical properties of the atoms to be able to perform the simulation. We set these properties on a &#039;per-type&#039; basis, so that every atom of the same type has the same mass and the same interactions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK: Using the [https://lammps.sandia.gov/doc/Manual.html LAMMPS MANUAL], find the purpose of the following commands in the input script: [3 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mass 1 1.0&lt;br /&gt;
pair_style lj/cut 3.0&lt;br /&gt;
pair_coeff * * 1.0 1.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So far we have created 1000 atoms, and we know the starting (&amp;lt;math&amp;gt;t = 0&amp;lt;/math&amp;gt;) position for each of them. We have also set their masses, and told LAMMPS what sort of forces to calculate between them. The final thing we need to specify to completely specify the initial conditions is the velocity of each atom.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK: Given that we are specifying &amp;lt;math&amp;gt;\mathbf{x}_i\left(0\right)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{v}_i\left(0\right)&amp;lt;/math&amp;gt;, which integration algorithm are we going to use? [1 mark]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Choosing initial velocities for the atoms is a little easier than choosing initial positions. From the statistical thermodynamics lectures, you should know that, at equilibrium, the velocities of atoms in any system must be distributed according to the [http://en.wikipedia.org/wiki/Maxwell%E2%80%93Boltzmann_distribution Maxwell-Boltzmann (MB) distribution]. If we know the masses of the atoms, and we know what temperature we want to simulate, then we can determine the relevant MB distribution function. LAMMPS is able to give every atom a random velocity whilst ensuring that overall the MB distribution is followed. This is the purpose of the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
velocity all create 1.5 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see the manual page for this command [http://lammps.sandia.gov/doc/velocity.html here], but the key sections are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;all&#039;&#039;&#039;: the &#039;&#039;group&#039;&#039; of atoms on which the command acts. &#039;&#039;&#039;all&#039;&#039;&#039; simply specifies that we want every atom to have a velocity assigned to it.&lt;br /&gt;
* &#039;&#039;&#039;1.5&#039;&#039;&#039;: the temperature, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, needed to calculate the MB distribution(in reduced units, as always)&lt;br /&gt;
&lt;br /&gt;
===Monitoring thermodynamic properties===&lt;br /&gt;
&lt;br /&gt;
We need to be sure that our simulation is correctly modelling whatever physical system we want to study. It is relatively easy to set up simulations, but how can we be sure that the &amp;quot;results&amp;quot; we get make sense? One of the best ways is to calculate from the simulation things that we can measure in experiment, and see if they agree. For example, we might want to simulate our system at a particular temperature and pressure, and measure the resulting density. If we repeat this over a range of temperatures at the same pressure, we will be able to plot an &#039;&#039;equation of state&#039;&#039;, which we could compare to experimental measurements.&lt;br /&gt;
&lt;br /&gt;
LAMMPS is able to calculate a great deal of thermodynamic information for us (you can see a full list of the properties it is able to calculate [http://lammps.sandia.gov/doc/thermo_style.html here]), but in these first simulations we are only interested in those properties specified in these commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
thermo 10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first controls which properties will be printed out in the log file. In this case, we print how much time we have simulated so far (which is &#039;&#039;not&#039;&#039; the same as how long it has taken us to simulate it!), the total energy of the atoms, their temperature, and their pressure. The second line tells LAMMPS to print this information on every 10th timestep.&lt;br /&gt;
&lt;br /&gt;
===Running the simulation===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Look at the lines below.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### SPECIFY TIMESTEP ###&lt;br /&gt;
variable timestep equal 0.001&lt;br /&gt;
variable n_steps equal floor(100/${timestep})&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
### RUN SIMULATION ###&lt;br /&gt;
run ${n_steps}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The second line (starting &amp;quot;variable timestep...&amp;quot;) tells LAMMPS that if it encounters the text ${timestep} on a subsequent line, it should replace it by the value given. In this case, the value ${timestep} is always replaced by 0.001.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; &amp;lt;big&amp;gt; TASK: In light of this, what do you think the purpose of these lines is? Why not just write:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
timestep 0.001&lt;br /&gt;
run 100000&lt;br /&gt;
&amp;lt;/pre&amp;gt; [1 mark] &amp;lt;/big&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Ask the demonstrator if you need help.&#039;&#039;&#039;&lt;br /&gt;
It is now time to run your first simulation, submit the input script with the data file in the intro folder of the files you have downloaded Try changing the timestep - what happens when you make the timestep larger?.&lt;br /&gt;
&lt;br /&gt;
===Visualising the trajectory===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;trajectory files&#039;&#039;&#039; contain the positions of all the atoms in the simulation, recorded at a set interval (for all of these simulations, this was every ten timesteps &amp;amp;mdash; this is controlled by the &#039;&#039;&#039;dump&#039;&#039;&#039; command in the input scripts). We use a programme called [http://www.ks.uiuc.edu/Research/vmd/ &#039;&#039;&#039;VMD&#039;&#039;&#039;] to view these trajectories, which you should find is already installed on both the desktop and laptop computers. You can run VMD from the start menu with &#039;&#039;&#039;Start&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;All Programs&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;University of Illinois&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;VMD&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
====Loading a Trajectory====&lt;br /&gt;
&lt;br /&gt;
We&#039;ll start by looking at the output of the 0.015 timestep simulation. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;File&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;New Molecule&#039;&#039;&#039;. Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button, then select the relevant trajectory file. In the &#039;&#039;&#039;Determine file type&#039;&#039;&#039; dropdown, select &#039;&#039;&#039;LAMMPS Trajectory&#039;&#039;&#039;. Then click &#039;&#039;&#039;Load&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You will see that the &#039;&#039;&#039;VMD 1.9.1 OpenGL Display&#039;&#039;&#039; window now shows a horrible mess. VMD&#039;s default behaviour is to draw lines between atoms which it thinks might be chemically bonded. Our system doesn&#039;t model chemical bonds, so we want to turn this off. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, select the menu option &#039;&#039;&#039;Graphics&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Representations&#039;&#039;&#039;. This shows a list of &amp;quot;representations&amp;quot; of our atoms. You will see that at the moment, there is a single representation listed, and it is selected. It will have the &#039;&#039;Lines&#039;&#039; style, the &#039;&#039;Name&#039;&#039; colour, and the selection &#039;&#039;all&#039;&#039;. &amp;quot;Selection&amp;quot; simply tells VMD which atoms we want it to draw. We want to show every atom, so the current selection is fine. The &#039;&#039;name&#039;&#039; colouring method just makes VMD give atoms colours according to their specified type. The colour isn&#039;t important to us, so we can leave this be too. The &amp;quot;style&amp;quot; tells VMD what we want it to display for each atom. Change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; from &#039;&#039;Lines&#039;&#039; to &#039;&#039;VDW&#039;&#039;. You will see that the mess of lines is replaced by a mess of low resolution, overlapping spheres. Change the &#039;&#039;&#039;Sphere Scale&#039;&#039;&#039; to 0.3, and the &#039;&#039;&#039;Sphere Resolution&#039;&#039;&#039; to 17. The result should look a little smoother. Close the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window. You will notice that in the bottom right of the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, there is a small play button. Click this, and you will see the animated version of your simulation trajectory.&lt;br /&gt;
&lt;br /&gt;
By clicking and dragging with the mouse, you can rotate the simulation box (though this may be sluggish). At any time, you can reset the view by pressing the equals key.&lt;br /&gt;
&lt;br /&gt;
====Tracking a Single Particle====&lt;br /&gt;
To illustrate the periodic boundary conditions that we are using, we are going to draw almost all of the atoms as points, but we will pick a single atom at random to draw as a sphere. This will make it easy to see how a single atom moves through the box. Reset the display using the equals key, then use the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window controls to pause the trajectory and reset it to the first trajectory (play with the different buttons until you find the one that does this). You should see the perfect cubic lattice. Use the option &#039;&#039;&#039;Display&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Orthographic&#039;&#039;&#039; to change the drawing mode, then rotate the displayed crystal so that you are looking at one vertex (looking down the 111 direction, in crystallographic terms).&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;&#039;Graphical Representations&#039;&#039;&#039; window again. Change the representation style from &#039;&#039;&#039;VDW&#039;&#039;&#039; to points, then click the &#039;&#039;&#039;Create Rep&#039;&#039;&#039; button. This creates a second representation, allowing a subset of the atoms to be drawn in a different way. The &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; box allows us to choose which atoms this representation applies to. We just want to pick two of them at random &amp;amp;mdash; VMD assigns every atom an index, from 0 to N-1. In our case, there are 1000 atoms, so choose two numbers between 0 and 999. Changed the &#039;&#039;&#039;Selected Atoms&#039;&#039;&#039; field to &amp;lt;pre&amp;gt;index i or index j&amp;lt;/pre&amp;gt; where i and j are your chosen numbers, press return, then change the &#039;&#039;&#039;Drawing Method&#039;&#039;&#039; to &#039;&#039;&#039;VDW&#039;&#039;&#039;. You should now see only two atoms represented by spheres, with the rest shown as small points. In the &#039;&#039;&#039;VMD Main&#039;&#039;&#039; window, click play. Try rotating the box, and changing the playback speed.&lt;br /&gt;
&lt;br /&gt;
You will see that sometimes one of the spheres seems to change position across the box very rapidly &amp;amp;mdash; this occurs when it reaches one periodic boundary, and is reflected back across the other face. Try playing with some of the other representation types in VMD &amp;amp;mdash; it  is a very powerful package, which is often used to render images of simulated proteins, so many of its options aren&#039;t relevant to our simple system!&lt;br /&gt;
&lt;br /&gt;
===Checking equilibration===&lt;br /&gt;
&lt;br /&gt;
When we first set up a simulation, it is very important to make sure that our system reaches an equilibrium state. We characterise equilibrium by the average values of thermodynamic quantities becoming constant (due to the approximations that we have made, there will always be fluctuations, but the average values will become constant).&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to plot the thermodynamic output of the simulation to see how long it takes to reach the equilibrium state (and indeed, whether this happens at all). Instructions are given below to import data from the LAMMPS log file into Microsoft Excel. Once you have the data in a spreadsheet, you can plot it. If you know how to use some of the other plotting software available on the chemistry computers (like Origin), you are welcome to use it.&lt;br /&gt;
&lt;br /&gt;
# Open a blank Excel workbook&lt;br /&gt;
# Choose the &#039;&#039;&#039;Data&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;From Text&#039;&#039;&#039; button&lt;br /&gt;
# Select one of your simulation log files&lt;br /&gt;
# Set the &#039;&#039;&#039;Start import at row&#039;&#039;&#039; field to &#039;&#039;&#039;25&#039;&#039;&#039; (this ignores all of the diagnostic information at the top of the file)&lt;br /&gt;
# Set the &#039;&#039;&#039;Original Data type&#039;&#039;&#039; to &#039;&#039;&#039;Delimited&#039;&#039;&#039;, then click &#039;&#039;&#039;Next&#039;&#039;&#039;&lt;br /&gt;
# Tick the &#039;&#039;&#039;Space&#039;&#039;&#039; box, and make sure that &#039;&#039;&#039;Treat consecutive delimiters as one&#039;&#039;&#039; box is ticked.&lt;br /&gt;
# On the next dialog, you can select where you want the data to be inserted. When you are happy, click &#039;&#039;&#039;OK&#039;&#039;&#039;. The data will be inserted into your spreadsheet.&lt;br /&gt;
# Scroll to the bottom of the data &amp;amp;mdash; you will see a lot of timing information from the simulation. Delete everything beyond the end of your thermodynamic data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK: make plots of the energy, temperature, and pressure, against time for the 0.001 timestep experiment (attach a picture to your report). Does the simulation reach equilibrium? When you have done this, make a single plot which shows the energy versus time for all of the timesteps you have simulated (again, attach a picture to your report). Of the timesteps that you used, which timestep will you use for subsequent simulations and why? [9 marks] &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the third section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Introduction_to_molecular_dynamics_simulation|Introduction to molecular dynamics simulation]], or jump ahead to the next section, [[Third year simulation experiment/Running simulations under specific conditions|Running simulations under specific conditions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Running_simulations_under_specific_conditions&amp;diff=734555</id>
		<title>Third year simulation experiment/Running simulations under specific conditions</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Third_year_simulation_experiment/Running_simulations_under_specific_conditions&amp;diff=734555"/>
		<updated>2018-10-08T09:43:01Z</updated>

		<summary type="html">&lt;p&gt;Otr12: /* Examining the Input Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the fourth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Equilibration|Equilibration]], or jump ahead to the next section, [[Third_year_simulation_experiment/Structural_properties_and_the_radial_distribution_function| Structural Properties and the Radial Distribution Functions]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;THE FILES THAT YOU NEED FOR THIS SECTION ARE FOUND IN THE &amp;quot;NpT&amp;quot; SUBFOLDER.&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Changing Ensemble==&lt;br /&gt;
&lt;br /&gt;
So far, we have been able to do some simulations in which the number of particles and the volume of the simulation cell are held constant. The energy is also constant (within a certain degree of error, which is introduced by the approximations that we make to do the simulation). If the simulation is a working properly, then the pressure and temperature of the system should also reach a constant &#039;&#039;average&#039;&#039; value (although there will again be fluctuations). In the statistical thermodynamics lectures, you met the concept of ensembles, which are used in statistical mechanics to represent different sorts of experimental conditions. The simulations we have done so far are described by the &#039;&#039;microcanonical&#039;&#039;, or NVE ensemble (the letters represent those thermodynamic quantities which are constant).&lt;br /&gt;
&lt;br /&gt;
As chemists, we often want to understand what happens under particular experimental conditions &amp;amp;mdash; at 298K under 1 atmosphere of pressure, for example. These sorts of conditions are described by different ensembles in statistical mechanics, such as the NVT (&#039;&#039;canonical&#039;&#039;) or NpT (&#039;&#039;isobaric-isothermal&#039;&#039;) ensembles.&lt;br /&gt;
&lt;br /&gt;
In this section, we are going to modify our simulations from the previous section to run under NpT conditions, and sketch an equation of state for our model fluid at atmospheric pressure.&lt;br /&gt;
&lt;br /&gt;
==Temperature and Pressure Control==&lt;br /&gt;
&lt;br /&gt;
The file npt.in can be used to perform a constant temperature/pressure simulation of our model fluid. It starts by melting a simple cubic crystal, just as before, so much of this file will look familiar to you. You will notice a new section near the top, however, called &#039;&#039;&#039;### SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&#039;&#039;&#039;. It contains three &#039;&#039;variables&#039;&#039; &amp;amp;mdash; these are used by the script later on to define the desired temperature, pressure, and timestep. The ellipses need to be replaced by the actual temperature, pressure and timestep that you want to use, so&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
variable T equal 0.5&lt;br /&gt;
variable p equal 1.0&lt;br /&gt;
variable timestep equal 0.75&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
would run a simulation at &amp;lt;math&amp;gt;T=0.5,\  p=1.0,\  \delta t=0.75&amp;lt;/math&amp;gt;. You should remember from the [[Third_year_simulation_experiment/Equilibration|Equilibration]] section that this is a poor choice of timestep!&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK: Choose 5 temperatures (above the critical temperature &amp;lt;math&amp;gt;T^* = 1.5&amp;lt;/math&amp;gt;), and two pressures (you can get a good idea of what a reasonable pressure is in Lennard-Jones units by looking at the average pressure of your simulations from the last section). This gives ten phase points &amp;amp;mdash; five temperatures at each pressure. Create 10 copies of npt.in, and modify each to run a simulation at one of your chosen &amp;lt;math&amp;gt;\left(p, T\right)&amp;lt;/math&amp;gt; points. You should be able to use the results of the previous section to choose a timestep. Submit these ten jobs to the HPC portal. When your simulations have finished, download the log files as before. At the end of the log file, LAMMPS will output the values and errors for the pressure, temperature, and density &amp;lt;math&amp;gt;\left(\frac{N}{V}\right)&amp;lt;/math&amp;gt;. Use software of your choice to plot the density as a function of temperature for both of the pressures that you simulated.  Your graph(s) should include error bars in both the x and y directions. You should also include a line corresponding to the density predicted by the ideal gas law at that pressure. Is your simulated density lower or higher? Justify this. Does the discrepancy increase or decrease with pressure? [15 marks]&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Thermostats and Barostats - controlling the thermodynamic properties===&lt;br /&gt;
The statistical thermodynamics lectures will have introduced you to the &#039;&#039;equipartition theorem&#039;&#039;, which states that, on average, every degree of freedom in a system at equilibrium will have &amp;lt;math&amp;gt;\frac{1}{2}k_B T&amp;lt;/math&amp;gt; of energy. In our system with &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms, each with 3 degrees of freedom, we can write&lt;br /&gt;
&amp;lt;math&amp;gt;E_K = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i v_i^2 = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end of every timestep, we use the left hand side of this equation to calculate the kinetic energy, then divide by &amp;lt;math&amp;gt;\frac{3}{2}Nk_B&amp;lt;/math&amp;gt; to get the &#039;&#039;instantaneous&#039;&#039; temperature &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. In general, &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; will fluctuate, and will be different to our &#039;&#039;target&#039;&#039; temperature, &amp;lt;math&amp;gt;\mathfrak{T}&amp;lt;/math&amp;gt; (this is whatever value we specify in the input script). We can change the temperature by multiplying every velocity by a constant factor, &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* If &amp;lt;math&amp;gt; T &amp;gt; \mathfrak{T} &amp;lt;/math&amp;gt;, then the kinetic energy of the system is too high, and we need to reduce it. &amp;lt;math&amp;gt;\gamma &amp;lt; 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* If &amp;lt;math&amp;gt; T &amp;lt; \mathfrak{T} &amp;lt;/math&amp;gt;, then the kinetic energy of the system is too low, and we need to increase it. &amp;lt;math&amp;gt;\gamma &amp;gt; 1&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;TASK: We need to choose &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt; so that the temperature is correct &amp;lt;math&amp;gt;T = \mathfrak{T}&amp;lt;/math&amp;gt; if we multiply every velocity &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;. We can write two equations:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i v_i^2 = \frac{3}{2} N k_B T&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{2}\sum_i m_i \left(\gamma v_i\right)^2 = \frac{3}{2} N k_B \mathfrak{T}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solve these to determine &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;. &amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Controlling the pressure is a little more involved, but the principle is largely the same: at each timestep, the pressure of the system is calculated; if the pressure is too high, then the simulation box is made a little larger, while if the pressure is too low the box is made smaller. Simulations in which the pressure is controlled are thus in the NpT ensemble &amp;amp;mdash; the volume of the simulation box is not constant!&lt;br /&gt;
&lt;br /&gt;
===Examining the Input Script===&lt;br /&gt;
&lt;br /&gt;
Open one of your input scripts (it doesn&#039;t matter which), and look at the section &#039;&#039;&#039;### BRING SYSTEM TO REQUIRED STATE ###&#039;&#039;&#039;. The line &amp;lt;pre&amp;gt;fix npt all npt temp ${T} ${T} ${tdamp} iso ${p} ${p} ${pdamp}&amp;lt;/pre&amp;gt; is the one responsible for switching on the temperature and pressure control. LAMMPS actually allows us to heat or cool the system over the course of a simulation, if we want to &amp;amp;mdash; this is the reason that the temperature appears twice in this line. The first ${T} is the desired starting temperature, and the second is the desired temperature at the end of the simulation. We want a constant average temperature, so we specify the same value twice. The same goes for the pressure.&lt;br /&gt;
&lt;br /&gt;
Now look at the lines near the end of the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### MEASURE SYSTEM STATE ###&lt;br /&gt;
thermo_style custom step etotal temp press density&lt;br /&gt;
variable dens equal density&lt;br /&gt;
variable dens2 equal density*density&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
variable press equal press&lt;br /&gt;
variable press2 equal press*press&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_dens v_temp v_press v_dens2 v_temp2 v_press2&lt;br /&gt;
run 100000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command, &#039;&#039;thermo_style&#039;&#039;, controls which thermodynamic properties are recorded, as before. The next lines are used to measure &#039;&#039;average&#039;&#039; thermodynamic properties for the system. To draw our equations of state, we need to know the average temperature, pressure, and density, and the statistical errors in those quantities. The six variable lines link those quantities (and their squared values, needed for the errors), to variable names that we can use in the averaging command, which is the line starting &#039;&#039;fix aves...&#039;&#039;. This command takes a number of input values and averages them every so many timesteps. Exactly how often this happens depends in the values of the three numbers which follow &#039;&#039;ave/time&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;big&amp;gt;&amp;lt;span style=&amp;quot;color:blue; &amp;quot;&amp;gt;This is the fourth section of the third year simulation experiment. You can return to the previous page, [[Third_year_simulation_experiment/Equilibration|Equilibration]], or jump ahead to the next section, [[Third year simulation experiment/Structural properties and the radial distribution function|Structural properties and the radial distribution function]].&amp;lt;/span&amp;gt;&amp;lt;/big&amp;gt;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Otr12</name></author>
	</entry>
</feed>