<?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=Sm6415</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=Sm6415"/>
	<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/wiki/Special:Contributions/Sm6415"/>
	<updated>2026-04-10T03:17:37Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659555</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659555"/>
		<updated>2018-01-31T11:30:13Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: /* Methods */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Liquid Simulations Computational Lab Assignment - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
Molecular dynamics simulations of particles interacting according to a Lennard-Jones potential were performed using the velocity-Verlet algorithm. Temperature dependence of density in the NpT ensemble was monitored, and significant deviation from the ideal gas law was observed at low temperatures due to the no collisions assumption breaking down. Heat capacity was monitored as a function of temperature in the NVT ensemble. The radial distribution functions were obtained for solid, liquid and gas systems, as were diffusion coefficients via the mean squared displacement. Furthermore, the diffusion coefficients obtained were realistic; D (solid) = 1.0 x10&amp;lt;sup&amp;gt;5 &amp;lt;/sup&amp;gt;m&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;/s), D (liquid = 3.47 x10&amp;lt;sup&amp;gt;9 &amp;lt;/sup&amp;gt;m&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;/s), D (gas = 3.47 x10&amp;lt;sup&amp;gt;10 &amp;lt;/sup&amp;gt;m&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;/s). Potential industrial applications for such molecular dynamics simulations are also discussed.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All un-equilibrated fluid systems will move via diffusion toward thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
One study on the extraction of basil essential oil from the&lt;br /&gt;
&amp;lt;em&amp;gt;Ocimum basilicum&amp;lt;/em&amp;gt; leaf exemplifies this&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;. The diffusion coefficient was&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, while the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates, due to different tissue structures inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. This knowledge allows manufacturers to fit the model&lt;br /&gt;
mathematically using parameters specific to their distillation setup, and use the result to find the best trade-off between extraction time (time and energy are expensive) and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to use computational models of particles interacting according to a Lennard-Jones potential to extract thermodynamic data about the system and ultimately calculate the diffusion coefficient. The experiment uses boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied to simulate a much larger &#039;effective system&#039;. The velocity-Verlet&lt;br /&gt;
algorithm&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; is used, which iterates the velocity and displacement for every particle in the system, from&lt;br /&gt;
an initial state, through the desired number of steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted, for e.g. Temperature can be obtained using the average kinetic energies in conjunction with the equipartition theorem.&lt;br /&gt;
&lt;br /&gt;
Reduced units throughout the experiment to make the magnitudes of the quantities used more managable.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq1.png|188x188px]]&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;r = inter-particle distance, σ = inter-particle distance when the potential = 0, E = potential, ε = depth of the potential well, T = temperature and k = the Boltzmann constant. Starred quantities represent the non-reduced&lt;br /&gt;
versions. Note the unites cancel out when forming these quantities and hence they are unitless.&lt;br /&gt;
&lt;br /&gt;
By cancelling through these reduced units, we obtain that time is also in reduced units and can be converted via:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq122.png]]&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
The open source software, LAMMPS, was used to run the molecular dynamics simulations. The experiment was run as 5 separate parts:&lt;br /&gt;
# The effect of the time step on the simulation was probed using a box of 1000 atoms, equally spaced with a number density of 0.8 atoms per unit volume. The ensemble was treated as microcanonical. The following time steps were trialed: 0.0150, 0.0100, 0.0075, 0.0025, 0.0010. Energy, temperature and pressure for the system were collected at each iteration. A timestep of 0.0025 was used for the two subsequent simulations - see results and discussion for justification.&lt;br /&gt;
# A set of simulations (1000 atoms) were run in the isobaric-isothermal (NpT) ensemble. At P = 2.5 &amp;amp; P = 3.0, the simulation was run over the following temperatures: T = 1.5, 2.0, 2.5, 3.5, 5. Density of the systems was extracted as an average after the simulation, and plotted against temperature to test the agreement with the ideal gas law.&lt;br /&gt;
# An experiment (1000 atoms) was run in the NVT ensemble at densities 0.2 &amp;amp; 0.8, over the temperatures T = 2.0, 2.2, 2.4, 2.6, 2.8. The average heat capacity and temperature were collected for each system.&lt;br /&gt;
# Simulations (8000 atoms) were performed for a solid, a liquid and a gas system. A timestep of 0.0020 was used. Parameters for this were selected based on a previous probe into the phase transitions of the Lennard-Jones system&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;; solid (density = 1.2, T = 0.5), liquid (density = 0.8, T = 1.2), gas (density = 0.2, T = 1.2). The output trajectories were used to calculate the RDF (radial distribution function), i.e. the radial frequency of meeting another particle averaged over all spherical angles.&lt;br /&gt;
# Simulations (8000 atoms) were again performed for a solid, a liquid and a gas phase system. A timestep of 0.0020 was used for this experiment, and the same density/temperature parameters at experiment 4. The MSD (mean squared displacement) was collected as a function of timestep.&lt;br /&gt;
&lt;br /&gt;
== Results &amp;amp; Discussion ==&lt;br /&gt;
&lt;br /&gt;
=== Experiment 1 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq2.png|404x404px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq3.png|406x406px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq4.png|468x468px]]&lt;br /&gt;
&lt;br /&gt;
These plots show how the thermodynamic state variables of the system vary with time. For all of the variables , we see a very quick convergence from the initial value to the steady state value. A closer inspection of these graphs reveal&lt;br /&gt;
equilibration happens after roughly 0.5 reduced time units. This shows how the system which is initially ordered quickly descends into chaos. After this point, the state variables proceed to oscillate randomly as a noise function. This occurs due to fluctuations in the system which is constantly moving. If the system had more particles, the average would be less noisy because there are more opportunities for the random imbalances to cancel each other out.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq5.png|514x514px]]&lt;br /&gt;
&lt;br /&gt;
The above plot shows how the energy varies with timestep. As the time step is increased the average energy&lt;br /&gt;
increases due to the resolution of the numerical solution decreasing. The largest timestep shows a clear divergence. Presumably the timestep is so large that particles are getting unrealistically close to each other. The reaction in the next timestep cascades such that the problem is transferred to neighbouring particles. At this point the simulation breaks down as the energies and particle positions become increasingly unrealistic. 0.0025 was the largest timestep which showed no sign of this increased energy or divergence, and hence the timestep used for all subsequent experiments was smaller than this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 2 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq6.png|501x501px]]&lt;br /&gt;
&lt;br /&gt;
The density decreases with temperature as expected; the&lt;br /&gt;
atoms have more kinetic energy, so push each other apart further during their&lt;br /&gt;
random motion. The higher pressure plots show a consistently higher density.&lt;br /&gt;
This is intuitive as at higher pressures, the atoms are squashed closer&lt;br /&gt;
together on average.  &lt;br /&gt;
&lt;br /&gt;
At lower temperatures, the ideal gas law result diverges&lt;br /&gt;
from the simulation. This is because the ideal gas law assumes no collisions.&lt;br /&gt;
At lower temperatures, particles of an ideal gas continue to be compressed into&lt;br /&gt;
a smaller space due to their diminishing kinetic energy, such that they are in&lt;br /&gt;
fact overlapping. In the simulation the particles collide, meaning a much&lt;br /&gt;
greater kinetic energy (temperature) reduction is required to achieve the same&lt;br /&gt;
increase in density. Also note that the ideal gas law allows for infinity as the&lt;br /&gt;
limiting density, whereas this becomes infinitely unlikely when using Van Der&lt;br /&gt;
Waals potential between the atoms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 3 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq7.png|486x486px]]&lt;br /&gt;
&lt;br /&gt;
The heat capacity is smaller for lower densities&lt;br /&gt;
as expected: there are less atoms to sink energy into, so the average kinetic energy&lt;br /&gt;
increases more quickly. The heat capacity decreases with temperature because at higher temperatures, the energy states are closer together, meaning it is easier to populate new states (higher density of states). This clearly outweighs any increased degeneracy in states, otherwise we would see the heat capacity increase with temperature as is often the case. The plateau could indicate a first order phase transition where the heat capacity tends to infinity. This would be made more clear with a higher resolution of data points. The radial distribution function could be calculated either side as the less ordered phase would have a smoother curve in the case of a transition.    &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 4 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq8.png|478x478px]]&lt;br /&gt;
&lt;br /&gt;
The radial distribution function (RDF) represents the density of particles around a single particle in the system on average as a function of radius, averaged over all possible angles in a sphere. The RDFs for the different phases are distinct. In the solid case, we se sharp peaks corresponding to when we hit a site in the crystalline lattice. In the liquid, the peaks are much less sharp, as there are many more positions the molecules can occupy easily relative to one another. Peaks are still defined as the distance between particles is roughly constant. A gas behaves like a liquid with very little order. It is less peaks if any (occur at higher densities) are much less well defined. There is still a sharp peak close to the particle as neighbouring particles spend the most time when changing direction during a collision as this is when velocity is the smallest. All three phases exhibit a cut-off displacement due to the steep positive region in the Lennard-Jones potential.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq9.png|533x533px]]&lt;br /&gt;
&lt;br /&gt;
When the RDF is viewed cumulatively, we see the steepest cumulation for the solid, followed by the liquid then gas. This is due to meeting particles more frequently when walking along the radius in the more dense phase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 5 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq10.png|687x687px]]&lt;br /&gt;
&lt;br /&gt;
The mean squared displacement plot used the same colours as before to represent a solid, liquid and gas. Initially the MSD is slow to rise, in particular for the gas. This is due to the particles taking some time to disperse properly and reach equilibrium velocity. &lt;br /&gt;
&lt;br /&gt;
The gas has the most freedom and kinetic energy so the MSD is the greatest. The opposite is true for the solid. The liquid is closer to the solid in terms of MSD because it is still relatively ordered, and there is some kind of activation barrier to molecules swapping between cages. The gradient for a solid is effectively zero as swapping positions in a crystalline lattice is extremely rare.&lt;br /&gt;
&lt;br /&gt;
The second plot shows a method of least squared fit, taking into account points after timestep = 1000 only, to avoid data from the equilibration period being considered. The gradients were as following:&lt;br /&gt;
&lt;br /&gt;
Solid: 2.94 x10&amp;lt;sup&amp;gt;-8&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Liquid: 1.02 x10&amp;lt;sup&amp;gt;-3&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gas: 1.00 x10&amp;lt;sup&amp;gt;-2&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The MSD is related to the diffusion coefficient by a simple relationship:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq11.png]]&lt;br /&gt;
&lt;br /&gt;
By simply using this relation, we obtain D as following (in timestep units):&lt;br /&gt;
&lt;br /&gt;
Solid: 4.9 x10&amp;lt;sup&amp;gt;-9&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Liquid: 1.7 x10&amp;lt;sup&amp;gt;-4&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gas: 1.7 x10&amp;lt;sup&amp;gt;-3&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To convert to the correct units, we must note 1 timestep corresponds to 48.89 fs, therefore we must divide by 49 x10&amp;lt;sup&amp;gt;-15&amp;lt;/sup&amp;gt; to get D in SI units:&lt;br /&gt;
&lt;br /&gt;
Solid: 1.0 x10&amp;lt;sup&amp;gt;5 &amp;lt;/sup&amp;gt;m&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;/s&lt;br /&gt;
&lt;br /&gt;
Liquid: 3.47 x10&amp;lt;sup&amp;gt;9 &amp;lt;/sup&amp;gt;m&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;/s&lt;br /&gt;
&lt;br /&gt;
Gas: 3.47 x10&amp;lt;sup&amp;gt;10 &amp;lt;/sup&amp;gt;m&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;/s&lt;br /&gt;
&lt;br /&gt;
Which is reasonable as diffusion coefficients for liquids are normally ~ 1 x10&amp;lt;sup&amp;gt;9 &amp;lt;/sup&amp;gt;m&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;/s&lt;br /&gt;
&lt;br /&gt;
Now it has been show we can model&lt;br /&gt;
the diffusion coefficient based purely on molecular dynamics simulations, we can see how similar simulations could be applied to real world&lt;br /&gt;
applications. In the basil leaf case introduced in the introduction, we could model the leaf&lt;br /&gt;
structure to follow the real leaf tissue, by using different densities. We would then be able to model accurately how the diffusion of basil&lt;br /&gt;
essential oil molecules changes as a vapour shell forms and molecules in the&lt;br /&gt;
leaf are depleted.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
The primary conclusion of this experiment is that molecular dynamics simulations are suitable for physical modelling, and can give more accurate results than ideal solutions such as the ideal gas law. The next step is to begin applying these models to real systems and test their ability to model accurately, such as in the basil leaf case.&lt;br /&gt;
&lt;br /&gt;
The molecular dynamics simulations gave a better estimate of the thermodynamic state variables than the ideal gas law because collisions were included. This is particularly relevant at low temperatures and high pressures. The heat capacity simulations showed that it is possible to observe phase transitions between phases. The RDF is a unique insight that would be much more difficult to measure in reality. It is a useful tool as is gives us detailed information on the structure of the system being studied. In a solid for example, the RDF peaks can be correlated to crystalline lattice sites. Having access to the displacements and velocities of each particle allows us to calculate a wealth of parameters, the diffusion coefficient being just one example. Obtaining a realistic diffusion coefficient implies that the method models the system realistically.&lt;br /&gt;
&lt;br /&gt;
It is clear that the amount of important data that can be quickly obtained for a system simulated using molecular dynamics is immense. It would be recommended that such methods are tested against real world experiments to gain a better understanding of their accuracy.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# J. Silveira, A. Costa and E. Costa Junior, &#039;&#039;Engenharia Agrícola&#039;&#039;, 2017, 37, 717-726.&lt;br /&gt;
# L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1967, 159, 98-103.&lt;br /&gt;
# J. Hansen and L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1969, 184, 151-161.&lt;br /&gt;
&lt;br /&gt;
Weblinks:&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;http://www.scielo.br/scielo.php?script=sci_arttext&amp;amp;pid=S0100-69162017000400717#B21&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.159.98&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
=== Previously unanswered tasks:[[File:Smliqt1.png|974x974px]] ===&lt;br /&gt;
&lt;br /&gt;
[[File:Smliqt2.png|953x953px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Smliqt3.png|1021x1021px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Smliqt4.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Smliqt5.png|958x958px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Smliqt6.png|979x979px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== LAMMPS script for heat capacity experiments: ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE SIMULATION BOX GEOMETRY ###&lt;br /&gt;
&lt;br /&gt;
variable dens equal 0.2&lt;br /&gt;
&lt;br /&gt;
lattice sc ${dens}&lt;br /&gt;
&lt;br /&gt;
region box block 0 15 0 15 0 15&lt;br /&gt;
&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&lt;br /&gt;
create_atoms 1 box&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE PHYSICAL PROPERTIES OF ATOMS ###&lt;br /&gt;
&lt;br /&gt;
mass 1 1.0&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut/opt 3.0&lt;br /&gt;
&lt;br /&gt;
pair_coeff 1 1 1.0 1.0&lt;br /&gt;
&lt;br /&gt;
neighbor 2.0 bin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&lt;br /&gt;
&lt;br /&gt;
variable T equal 2.0&lt;br /&gt;
&lt;br /&gt;
variable timestep equal 0.0075&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; ASSIGN ATOMIC VELOCITIES ###&lt;br /&gt;
&lt;br /&gt;
velocity all create ${T} 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY ENSEMBLE ###&lt;br /&gt;
&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; THERMODYNAMIC OUTPUT CONTROL ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
&lt;br /&gt;
thermo 10&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RECORD TRAJECTORY ###&lt;br /&gt;
&lt;br /&gt;
dump traj all custom 1000 output-1 id x y z&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY TIMESTEP ###&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RUN SIMULATION TO MELT CRYSTAL ###&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
unfix nve&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; BRING SYSTEM TO REQUIRED STATE ###&lt;br /&gt;
&lt;br /&gt;
variable tdamp equal ${timestep}*100&lt;br /&gt;
&lt;br /&gt;
fix nvt all nvt temp ${T} ${T} ${tdamp}&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
unfix nvt&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; MEASURE SYSTEM STATE ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom etotal temp atoms vol&lt;br /&gt;
&lt;br /&gt;
variable vol equal vol&lt;br /&gt;
&lt;br /&gt;
variable atoms equal atoms&lt;br /&gt;
&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
&lt;br /&gt;
variable N2 equal atoms*atoms&lt;br /&gt;
&lt;br /&gt;
variable E2 equal etotal*etotal&lt;br /&gt;
&lt;br /&gt;
variable E equal etotal&lt;br /&gt;
&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_temp2 v_E v_E2&lt;br /&gt;
&lt;br /&gt;
run 100000&lt;br /&gt;
&lt;br /&gt;
variable heatcapac equal&lt;br /&gt;
${N2}*(f_aves[3]-(f_aves[2]*f_aves[2]))/(f_aves[1])&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Averages&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;--------&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Heat Capacity: ${heatcapac}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Volume: ${vol}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;No of atoms: ${atoms}&amp;quot;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659552</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659552"/>
		<updated>2018-01-31T11:21:42Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Liquid Simulations Computational Lab Assignment - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
Molecular dynamics simulations of particles interacting according to a Lennard-Jones potential were performed using the velocity-Verlet algorithm. Temperature dependence of density in the NpT ensemble was monitored, and significant deviation from the ideal gas law was observed at low temperatures due to the no collisions assumption breaking down. Heat capacity was monitored as a function of temperature in the NVT ensemble. The radial distribution functions were obtained for solid, liquid and gas systems, as were diffusion coefficients via the mean squared displacement. Furthermore, the diffusion coefficients obtained were realistic; D (solid) = 1.0 x10&amp;lt;sup&amp;gt;5 &amp;lt;/sup&amp;gt;m&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;/s), D (liquid = 3.47 x10&amp;lt;sup&amp;gt;9 &amp;lt;/sup&amp;gt;m&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;/s), D (gas = 3.47 x10&amp;lt;sup&amp;gt;10 &amp;lt;/sup&amp;gt;m&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;/s). Potential industrial applications for such molecular dynamics simulations are also discussed.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All un-equilibrated fluid systems will move via diffusion toward thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
One study on the extraction of basil essential oil from the&lt;br /&gt;
&amp;lt;em&amp;gt;Ocimum basilicum&amp;lt;/em&amp;gt; leaf exemplifies this&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;. The diffusion coefficient was&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, while the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates, due to different tissue structures inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. This knowledge allows manufacturers to fit the model&lt;br /&gt;
mathematically using parameters specific to their distillation setup, and use the result to find the best trade-off between extraction time (time and energy are expensive) and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to use computational models of particles interacting according to a Lennard-Jones potential to extract thermodynamic data about the system and ultimately calculate the diffusion coefficient. The experiment uses boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied to simulate a much larger &#039;effective system&#039;. The velocity-Verlet&lt;br /&gt;
algorithm&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; is used, which iterates the velocity and displacement for every particle in the system, from&lt;br /&gt;
an initial state, through the desired number of steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted, for e.g. Temperature can be obtained using the average kinetic energies in conjunction with the equipartition theorem.&lt;br /&gt;
&lt;br /&gt;
Reduced units throughout the experiment to make the magnitudes of the quantities used more managable.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq1.png|188x188px]]&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;r = inter-particle distance, σ = inter-particle distance when the potential = 0, E = potential, ε = depth of the potential well, T = temperature and k = the Boltzmann constant. Starred quantities represent the non-reduced&lt;br /&gt;
versions. Note the unites cancel out when forming these quantities and hence they are unitless.&lt;br /&gt;
&lt;br /&gt;
By cancelling through these reduced units, we obtain that time is also in reduced units and can be converted via:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq122.png]]&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
The open source software, LAMMPS, was used to run the molecular dynamics simulations. The experiment was run as 5 separate parts:&lt;br /&gt;
# The effect of the time step on the simulation was probed using a box of 1000 atoms, equally spaced with a number density of 0.8 atoms per unit volume. The ensemble was treated as microcanonical. The following time steps were trialed: 0.0150, 0.0100, 0.0075, 0.0025, 0.0010. Energy, temperature and pressure for the system were collected at each iteration. A timestep of 0.0025 was used for the two subsequent simulations - see results and discussion for justification.&lt;br /&gt;
# A set of simulations were run in the isobaric-isothermal (NpT) ensemble. At P = 2.5 &amp;amp; P = 3.0, the simulation was run over the following temperatures: T = 1.5, 2.0, 2.5, 3.5, 5. Density of the systems was extracted as an average after the simulation, and plotted against temperature to test the agreement with the ideal gas law.&lt;br /&gt;
# An experiment was run in the NVT ensemble at densities 0.2 &amp;amp; 0.8, over the temperatures T = 2.0, 2.2, 2.4, 2.6, 2.8. The average heat capacity and temperature were collected for each system.&lt;br /&gt;
# Simulations were performed for a solid, a liquid and a gas system. A timestep of 0.0020 was used. Parameters for this were selected based on a previous probe into the phase transitions of the Lennard-Jones system&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;; solid (density = 1.2, T = 0.5), liquid (density = 0.8, T = 1.2), gas (density = 0.2, T = 1.2). The output trajectories were used to calculate the RDF (radial distribution function), i.e. the radial frequency of meeting another particle averaged over all spherical angles.&lt;br /&gt;
# Simulations were again performed for a solid, a liquid and a gas phase system. A timestep of 0.0020 was used for this experiment, and the same density/temperature parameters at experiment 4. The MSD (mean squared displacement) was collected as a function of timestep.&lt;br /&gt;
&lt;br /&gt;
== Results &amp;amp; Discussion ==&lt;br /&gt;
&lt;br /&gt;
=== Experiment 1 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq2.png|404x404px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq3.png|406x406px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq4.png|468x468px]]&lt;br /&gt;
&lt;br /&gt;
These plots show how the thermodynamic state variables of the system vary with time. For all of the variables , we see a very quick convergence from the initial value to the steady state value. A closer inspection of these graphs reveal&lt;br /&gt;
equilibration happens after roughly 0.5 reduced time units. This shows how the system which is initially ordered quickly descends into chaos. After this point, the state variables proceed to oscillate randomly as a noise function. This occurs due to fluctuations in the system which is constantly moving. If the system had more particles, the average would be less noisy because there are more opportunities for the random imbalances to cancel each other out.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq5.png|514x514px]]&lt;br /&gt;
&lt;br /&gt;
The above plot shows how the energy varies with timestep. As the time step is increased the average energy&lt;br /&gt;
increases due to the resolution of the numerical solution decreasing. The largest timestep shows a clear divergence. Presumably the timestep is so large that particles are getting unrealistically close to each other. The reaction in the next timestep cascades such that the problem is transferred to neighbouring particles. At this point the simulation breaks down as the energies and particle positions become increasingly unrealistic. 0.0025 was the largest timestep which showed no sign of this increased energy or divergence, and hence the timestep used for all subsequent experiments was smaller than this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 2 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq6.png|501x501px]]&lt;br /&gt;
&lt;br /&gt;
The density decreases with temperature as expected; the&lt;br /&gt;
atoms have more kinetic energy, so push each other apart further during their&lt;br /&gt;
random motion. The higher pressure plots show a consistently higher density.&lt;br /&gt;
This is intuitive as at higher pressures, the atoms are squashed closer&lt;br /&gt;
together on average.  &lt;br /&gt;
&lt;br /&gt;
At lower temperatures, the ideal gas law result diverges&lt;br /&gt;
from the simulation. This is because the ideal gas law assumes no collisions.&lt;br /&gt;
At lower temperatures, particles of an ideal gas continue to be compressed into&lt;br /&gt;
a smaller space due to their diminishing kinetic energy, such that they are in&lt;br /&gt;
fact overlapping. In the simulation the particles collide, meaning a much&lt;br /&gt;
greater kinetic energy (temperature) reduction is required to achieve the same&lt;br /&gt;
increase in density. Also note that the ideal gas law allows for infinity as the&lt;br /&gt;
limiting density, whereas this becomes infinitely unlikely when using Van Der&lt;br /&gt;
Waals potential between the atoms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 3 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq7.png|486x486px]]&lt;br /&gt;
&lt;br /&gt;
The heat capacity is smaller for lower densities&lt;br /&gt;
as expected: there are less atoms to sink energy into, so the average kinetic energy&lt;br /&gt;
increases more quickly. The heat capacity decreases with temperature because at higher temperatures, the energy states are closer together, meaning it is easier to populate new states (higher density of states). This clearly outweighs any increased degeneracy in states, otherwise we would see the heat capacity increase with temperature as is often the case. The plateau could indicate a first order phase transition where the heat capacity tends to infinity. This would be made more clear with a higher resolution of data points. The radial distribution function could be calculated either side as the less ordered phase would have a smoother curve.    &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 4 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq8.png|478x478px]]&lt;br /&gt;
&lt;br /&gt;
The radial distribution function (RDF) represents the density of particles around a single particle in the system on average as a function of radius, averaged over all possible angles in a sphere. The RDFs for the different phases are distinct. In the solid case, we se sharp peaks corresponding to when we hit a site in the crystalline lattice. In the liquid, the peaks are much less sharp, as there are many more positions the molecules can occupy easily relative to one another. Peaks are still defined as the distance between particles is roughly constant. A gas behaves like a liquid with very little order. It is less peaks if any (occur at higher densities) are much less well defined. There is still a sharp peak close to the particle as neighbouring particles spend the most time when changing direction during a collision as this is when velocity is the smallest. All three phases exhibit a cut-off displacement due to the steep positive region in the Lennard-Jones potential.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq9.png|533x533px]]&lt;br /&gt;
&lt;br /&gt;
When the RDF is viewed cumulatively, we see the steepest cumulation for the solid, followed by the liquid then gas. This is due to meeting particles more frequently when in the more dense phase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 5 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq10.png|687x687px]]&lt;br /&gt;
&lt;br /&gt;
The mean squared displacement plot used the same colours as before to represent a solid, liquid and gas. Initially the MSD is slow to rise, in particular for the gas. This is due to the particles taking some time to disperse properly and reach equilibrium velocity. The gas has the most freedom and kinetic energy so the MSD is the greatest. The opposite is true for the solid. The liquid is closer to the solid in terms of MSD because it is still relatively ordered, and there is some kind of activation barrier to molecules swapping between cages. The gradient for a solid is effectively zero as swapping positions in a crystalline lattice is extremely rare.&lt;br /&gt;
&lt;br /&gt;
The second plot shows a method of least squared fit, taking into account points after timestep = 1000 only, to avoid data from the equilibration period being considered. The gradients were as following:&lt;br /&gt;
&lt;br /&gt;
Solid: 2.94 x10&amp;lt;sup&amp;gt;-8&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Liquid: 1.02 x10&amp;lt;sup&amp;gt;-3&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gas: 1.00 x10&amp;lt;sup&amp;gt;-2&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The MSD is related to the diffusion coefficient by a simple relationship:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq11.png]]&lt;br /&gt;
&lt;br /&gt;
By simply using this relation, we obtain D as following (in timestep units):&lt;br /&gt;
&lt;br /&gt;
Solid: 4.9 x10&amp;lt;sup&amp;gt;-9&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Liquid: 1.7 x10&amp;lt;sup&amp;gt;-4&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gas: 1.7 x10&amp;lt;sup&amp;gt;-3&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To convert to the correct units, we must note 1 timestep corresponds to 48.89 fs, therefore we must divide by 49 x10&amp;lt;sup&amp;gt;-15&amp;lt;/sup&amp;gt; to get D in SI units:&lt;br /&gt;
&lt;br /&gt;
Solid: 1.0 x10&amp;lt;sup&amp;gt;5 &amp;lt;/sup&amp;gt;m&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;/s&lt;br /&gt;
&lt;br /&gt;
Liquid: 3.47 x10&amp;lt;sup&amp;gt;9 &amp;lt;/sup&amp;gt;m&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;/s&lt;br /&gt;
&lt;br /&gt;
Gas: 3.47 x10&amp;lt;sup&amp;gt;10 &amp;lt;/sup&amp;gt;m&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;/s&lt;br /&gt;
&lt;br /&gt;
Which is reasonable as diffusion coefficients for liquids are normally ~ 1 x10&amp;lt;sup&amp;gt;9 &amp;lt;/sup&amp;gt;m&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;/s&lt;br /&gt;
&lt;br /&gt;
Now it has been show we can model&lt;br /&gt;
the diffusion coefficient based purely on molecular dynamics simulations, we can see how similar simulations could be applied to real world&lt;br /&gt;
applications. In the basil leaf case introduced in the introduction, we could model the leaf&lt;br /&gt;
structure to follow the real leaf tissue, by using different densities. We would then be able to model accurately how the diffusion of basil&lt;br /&gt;
essential oil molecules changes as a vapour shell forms and molecules in the&lt;br /&gt;
leaf are depleted.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
The primary conclusion of this experiment is that molecular dynamics simulations are suitable for physical modelling, and can give more accurate results than ideal solutions such as the ideal gas law. The next step is to begin applying these models to real systems and test their ability to model accurately.&lt;br /&gt;
&lt;br /&gt;
The molecular dynamics simulations gave a better estimate of the thermodynamic state variables because collisions were included. This is particularly relevant at low temperatures and high pressures. The heat capacity simulations showed that it is possible to observe phase transitions between phases. The RDF is a unique insight that would be much more difficult to measure in reality. It is a useful tool as is gives us detailed information on the structure of the system being studied. In a solid for example, the RDF peaks can be correlated to crystalline lattice sites. Having access to the displacements and velocities of each particle allows us to calculate a wealth of parameters, the diffusion coefficient being just one example. Obtaining a realistic diffusion coefficient implies that the method models the system realistically.&lt;br /&gt;
&lt;br /&gt;
It is clear that the amount of important data that can be quickly obtained for a system simulated using molecular dynamics is immense. It would be recommended that such methods are tested against real world experiments to gain a better understanding of their accuracy.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# J. Silveira, A. Costa and E. Costa Junior, &#039;&#039;Engenharia Agrícola&#039;&#039;, 2017, 37, 717-726.&lt;br /&gt;
# L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1967, 159, 98-103.&lt;br /&gt;
# J. Hansen and L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1969, 184, 151-161.&lt;br /&gt;
&lt;br /&gt;
Weblinks:&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;http://www.scielo.br/scielo.php?script=sci_arttext&amp;amp;pid=S0100-69162017000400717#B21&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.159.98&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
=== Previously unanswered tasks:[[File:Smliqt1.png|974x974px]] ===&lt;br /&gt;
&lt;br /&gt;
[[File:Smliqt2.png|953x953px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Smliqt3.png|1021x1021px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Smliqt4.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Smliqt5.png|958x958px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Smliqt6.png|979x979px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== LAMMPS script for heat capacity experiments: ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE SIMULATION BOX GEOMETRY ###&lt;br /&gt;
&lt;br /&gt;
variable dens equal 0.2&lt;br /&gt;
&lt;br /&gt;
lattice sc ${dens}&lt;br /&gt;
&lt;br /&gt;
region box block 0 15 0 15 0 15&lt;br /&gt;
&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&lt;br /&gt;
create_atoms 1 box&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE PHYSICAL PROPERTIES OF ATOMS ###&lt;br /&gt;
&lt;br /&gt;
mass 1 1.0&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut/opt 3.0&lt;br /&gt;
&lt;br /&gt;
pair_coeff 1 1 1.0 1.0&lt;br /&gt;
&lt;br /&gt;
neighbor 2.0 bin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&lt;br /&gt;
&lt;br /&gt;
variable T equal 2.0&lt;br /&gt;
&lt;br /&gt;
variable timestep equal 0.0075&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; ASSIGN ATOMIC VELOCITIES ###&lt;br /&gt;
&lt;br /&gt;
velocity all create ${T} 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY ENSEMBLE ###&lt;br /&gt;
&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; THERMODYNAMIC OUTPUT CONTROL ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
&lt;br /&gt;
thermo 10&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RECORD TRAJECTORY ###&lt;br /&gt;
&lt;br /&gt;
dump traj all custom 1000 output-1 id x y z&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY TIMESTEP ###&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RUN SIMULATION TO MELT CRYSTAL ###&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
unfix nve&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; BRING SYSTEM TO REQUIRED STATE ###&lt;br /&gt;
&lt;br /&gt;
variable tdamp equal ${timestep}*100&lt;br /&gt;
&lt;br /&gt;
fix nvt all nvt temp ${T} ${T} ${tdamp}&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
unfix nvt&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; MEASURE SYSTEM STATE ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom etotal temp atoms vol&lt;br /&gt;
&lt;br /&gt;
variable vol equal vol&lt;br /&gt;
&lt;br /&gt;
variable atoms equal atoms&lt;br /&gt;
&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
&lt;br /&gt;
variable N2 equal atoms*atoms&lt;br /&gt;
&lt;br /&gt;
variable E2 equal etotal*etotal&lt;br /&gt;
&lt;br /&gt;
variable E equal etotal&lt;br /&gt;
&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_temp2 v_E v_E2&lt;br /&gt;
&lt;br /&gt;
run 100000&lt;br /&gt;
&lt;br /&gt;
variable heatcapac equal&lt;br /&gt;
${N2}*(f_aves[3]-(f_aves[2]*f_aves[2]))/(f_aves[1])&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Averages&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;--------&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Heat Capacity: ${heatcapac}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Volume: ${vol}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;No of atoms: ${atoms}&amp;quot;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliqt4.png&amp;diff=659513</id>
		<title>File:Smliqt4.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliqt4.png&amp;diff=659513"/>
		<updated>2018-01-31T10:49:45Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659509</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659509"/>
		<updated>2018-01-31T10:47:24Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: /* Appendix */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Liquid Simulations Computational Lab Assignment - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
Molecular dynamics simulations of particles interacting according to a Lennard-Jones potential were performed using the velocity-Verlet algorithm. Temperature dependence of density in the NpT ensemble was monitored, and significant deviation from the ideal gas law was observed at low temperatures due to the no collisions assumption breaking down. Heat capacity was monitored as a function of temperature in the NVT ensemble. The radial distribution functions were obtained for solid, liquid and gas systems, as were diffusion coefficients via the mean squared displacement. Potential industrial applications for such molecular dynamics simulations are also discussed.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All un-equilibrated fluid systems will move via diffusion toward thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
One study on the extraction of basil essential oil from the&lt;br /&gt;
&amp;lt;em&amp;gt;Ocimum basilicum&amp;lt;/em&amp;gt; leaf exemplifies this&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;. The diffusion coefficient was&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, while the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates, due to different tissue structures inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. This knowledge allows manufacturers to fit the model&lt;br /&gt;
mathematically using parameters specific to their distillation setup, and use the result to find the best trade-off between extraction time (time and energy are expensive) and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to use computational models of particles interacting according to a Lennard-Jones potential to extract thermodynamic data about the system and ultimately calculate the diffusion coefficient. The experiment uses boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied to simulate a much larger &#039;effective system&#039;. The velocity-Verlet&lt;br /&gt;
algorithm&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; is used, which iterates the velocity and displacement for every particle in the system, from&lt;br /&gt;
an initial state, through the desired number of steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted, for e.g. Temperature can be obtained using the average kinetic energies in conjunction with the equipartition theorem.&lt;br /&gt;
&lt;br /&gt;
Reduced units throughout the experiment to make the magnitudes of the quantities used more managable.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq1.png|188x188px]]&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;r = inter-particle distance, σ = inter-particle distance when the potential = 0, E = potential, ε = depth of the potential well, T = temperature and k = the Boltzmann constant. Starred quantities represent the non-reduced&lt;br /&gt;
versions. Note the unites cancel out when forming these quantities and hence they are unitless.&lt;br /&gt;
&lt;br /&gt;
By cancelling through these reduced units, we obtain that time is also in reduced units and can be converted via:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq122.png]]&lt;br /&gt;
&lt;br /&gt;
This is used for calculating the diffusion coefficient, though may be used to obtain the true timescale for any of the simulations.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
The open source software, LAMMPS, was used to run the molecular dynamics simulations. The experiment was run as 5 separate parts:&lt;br /&gt;
# The effect of the time step on the simulation was probed using a box of 1000 atoms, equally spaced with a number density of 0.8 atoms per unit volume. The ensemble was treated as microcanonical. The following time steps were trialed: 0.0150, 0.0100, 0.0075, 0.0025, 0.0010. Energy, temperature and pressure for the system were collected at each iteration. A timestep of 0.0025 was used for the two subsequent simulations - see results and discussion for justification.&lt;br /&gt;
# A set of simulations were run in the isobaric-isothermal (NpT) ensemble. At P = 2.5 &amp;amp; P = 3.0, the simulation was run over the following temperatures: T = 1.5, 2.0, 2.5, 3.5, 5. Density of the systems was extracted as an average after the simulation, and plotted against temperature to test the agreement with the ideal gas law.&lt;br /&gt;
# An experiment was run in the NVT ensemble at densities 0.2 &amp;amp; 0.8, over the temperatures T = 2.0, 2.2, 2.4, 2.6, 2.8. The average heat capacity and temperature were collected for each system.&lt;br /&gt;
# Simulations were performed for a solid, a liquid and a gas system. A timestep of 0.0020 was used. Parameters for this were selected based on a previous probe into the phase transitions of the Lennard-Jones system&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;; solid (density = 1.2, T = 0.5), liquid (density = 0.8, T = 1.2), gas (density = 0.2, T = 1.2). The output trajectories were used to calculate the RDF (radial distribution function), i.e. the radial frequency of meeting another particle averaged over all spherical angles.&lt;br /&gt;
# Simulations were again performed for a solid, a liquid and a gas phase system. A timestep of 0.0020 was used for this experiment, and the same density/temperature parameters at experiment 4. The MSD (mean squared displacement) was collected as a function of timestep.&lt;br /&gt;
&lt;br /&gt;
== Results &amp;amp; Discussion ==&lt;br /&gt;
&lt;br /&gt;
=== Experiment 1 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq2.png|404x404px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq3.png|406x406px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq4.png|468x468px]]&lt;br /&gt;
&lt;br /&gt;
These plots show how the thermodynamic state variables of the system vary with time. For all of the variables , we see a very quick convergence from the initial value to the steady state value. A closer inspection of these graphs reveal&lt;br /&gt;
equilibration happens after roughly 0.5 reduced time units. This shows how the system which is initially ordered quickly descends into chaos. After this point, the state variables proceed to oscillate randomly as a noise function. This occurs due to fluctuations in the system which is constantly moving. If the system had more particles, the average would be less noisy because there are more opportunities for the random imbalances to cancel each other out.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq5.png|514x514px]]&lt;br /&gt;
&lt;br /&gt;
The above plot shows how the energy varies with timestep. As the time step is increased the average energy&lt;br /&gt;
increases due to the resolution of the numerical solution decreasing. The largest timestep shows a clear divergence. Presumably the timestep is so large that particles are getting unrealistically close to each other. The reaction in the next timestep cascades such that the problem is transferred to neighbouring particles. At this point the simulation breaks down as the energies and particle positions become increasingly unrealistic. 0.0025 was the largest timestep which showed no sign of this increased energy or divergence, and hence the timestep used for all subsequent experiments was smaller than this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 2 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq6.png|501x501px]]&lt;br /&gt;
&lt;br /&gt;
The density decreases with temperature as expected; the&lt;br /&gt;
atoms have more kinetic energy, so push each other apart further during their&lt;br /&gt;
random motion. The higher pressure plots show a consistently higher density.&lt;br /&gt;
This is intuitive as at higher pressures, the atoms are squashed closer&lt;br /&gt;
together on average.  &lt;br /&gt;
&lt;br /&gt;
At lower temperatures, the ideal gas law result diverges&lt;br /&gt;
from the simulation. This is because the ideal gas law assumes no collisions.&lt;br /&gt;
At lower temperatures, particles of an ideal gas continue to be compressed into&lt;br /&gt;
a smaller space due to their diminishing kinetic energy, such that they are in&lt;br /&gt;
fact overlapping. In the simulation the particles collide, meaning a much&lt;br /&gt;
greater kinetic energy (temperature) reduction is required to achieve the same&lt;br /&gt;
increase in density. Also note that the ideal gas law allows for infinity as the&lt;br /&gt;
limiting density, whereas this becomes infinitely unlikely when using Van Der&lt;br /&gt;
Waals potential between the atoms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 3 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq7.png|486x486px]]&lt;br /&gt;
&lt;br /&gt;
The heat capacity is smaller for lower densities&lt;br /&gt;
as expected: there are less atoms to sink energy into, so the average kinetic energy&lt;br /&gt;
increases more quickly. The heat capacity decreases with temperature because at higher temperatures, the energy states are closer together, meaning it is easier to populate new states (higher density of states). This clearly outweighs any increased degeneracy in states, otherwise we would see the heat capacity increase with temperature as is often the case. The plateau could indicate a first order phase transition where the heat capacity tends to infinity. This would be made more clear with a higher resolution of data points. The radial distribution function could be calculated either side as the less ordered phase would have a smoother curve.    &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 4 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq8.png|478x478px]]&lt;br /&gt;
&lt;br /&gt;
The radial distribution function (RDF) represents the density of particles around a single particle in the system on average as a function of radius, averaged over all possible angles in a sphere. The RDFs for the different phases are distinct. In the solid case, we se sharp peaks corresponding to when we hit a site in the crystalline lattice. In the liquid, the peaks are much less sharp, as there are many more positions the molecules can occupy easily relative to one another. Peaks are still defined as the distance between particles is roughly constant. A gas behaves like a liquid with very little order. It is less peaks if any (occur at higher densities) are much less well defined. There is still a sharp peak close to the particle as neighbouring particles spend the most time when changing direction during a collision as this is when velocity is the smallest. All three phases exhibit a cut-off displacement due to the steep positive region in the Lennard-Jones potential.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq9.png|533x533px]]&lt;br /&gt;
&lt;br /&gt;
When the RDF is viewed cumulatively, we see the steepest cumulation for the solid, followed by the liquid then gas. This is due to meeting particles more frequently when in the more dense phase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 5 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq10.png|687x687px]]&lt;br /&gt;
&lt;br /&gt;
The mean squared displacement plot used the same colours as before to represent a solid, liquid and gas. Initially the MSD is slow to rise, in particular for the gas. This is due to the particles taking some time to disperse properly and reach equilibrium velocity. The gas has the most freedom and kinetic energy so the MSD is the greatest. The opposite is true for the solid. The liquid is closer to the solid in terms of MSD because it is still relatively ordered, and there is some kind of activation barrier to molecules swapping between cages. The gradient for a solid is effectively zero as swapping positions in a crystalline lattice is extremely rare.&lt;br /&gt;
&lt;br /&gt;
The second plot shows a method of least squared fit, taking into account points after timestep = 1000 only, to avoid data from the equilibration period being considered. The gradients were as following:&lt;br /&gt;
&lt;br /&gt;
Solid: 2.94 x10&amp;lt;sup&amp;gt;-8&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Liquid: 1.02 x10&amp;lt;sup&amp;gt;-3&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gas: 1.00 x10&amp;lt;sup&amp;gt;-2&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The MSD is related to the diffusion coefficient by a simple relationship:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq11.png]]&lt;br /&gt;
&lt;br /&gt;
By simply using this relation, we obtain D as following (in timestep units):&lt;br /&gt;
&lt;br /&gt;
Solid: 4.9 x10&amp;lt;sup&amp;gt;-9&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Liquid: 1.7 x10&amp;lt;sup&amp;gt;-4&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gas: 1.7 x10&amp;lt;sup&amp;gt;-3&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To convert to the correct units, we must simply apply:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq122.png]]&lt;br /&gt;
&lt;br /&gt;
Now it has been show we can model&lt;br /&gt;
the diffusion coefficient based purely on molecular dynamics simulations, we can see how similar simulations could be applied to real world&lt;br /&gt;
applications. In the basil leaf case introduced in the introduction, we could model the leaf&lt;br /&gt;
structure to follow the real leaf tissue, by using different densities. We would then be able to model accurately how the diffusion of basil&lt;br /&gt;
essential oil molecules changes as a vapour shell forms and molecules in the&lt;br /&gt;
leaf are depleted.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
The primary conclusion of this experiment is that molecular dynamics simulations are suitable for physical modelling, and can give more accurate results than ideal solutions such as the ideal gas law. The next step is to begin applying these models to real systems and test their ability to model accurately.&lt;br /&gt;
&lt;br /&gt;
The molecular dynamics simulations gave a better estimate of the thermodynamic state variables because collisions were included. This is particularly relevant at low temperatures and high pressures. The heat capacity simulations showed that it is possible to observe phase transitions between phases. The RDF is a unique insight that would be much more difficult to measure in reality. It is a useful tool as is gives us detailed information on the structure of the system being studied. In a solid for example, the RDF peaks can be correlated to crystalline lattice sites. Having access to the displacements and velocities of each particle allows us to calculate a wealth of parameters, the diffusion coefficient being just one example.&lt;br /&gt;
&lt;br /&gt;
It is clear that the amount of important data that can be quickly obtained for a system simulated using molecular dynamics is immense. It would be recommended that such methods are tested against real world experiments to gain a better understanding of their accuracy.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# J. Silveira, A. Costa and E. Costa Junior, &#039;&#039;Engenharia Agrícola&#039;&#039;, 2017, 37, 717-726.&lt;br /&gt;
# L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1967, 159, 98-103.&lt;br /&gt;
# J. Hansen and L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1969, 184, 151-161.&lt;br /&gt;
&lt;br /&gt;
Weblinks:&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;http://www.scielo.br/scielo.php?script=sci_arttext&amp;amp;pid=S0100-69162017000400717#B21&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.159.98&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
=== Previously unanswered tasks:[[File:Smliqt1.png|974x974px]] ===&lt;br /&gt;
&lt;br /&gt;
[[File:Smliqt2.png|953x953px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Smliqt3.png|1021x1021px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Smliqt4.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Smliqt5.png|958x958px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Smliqt6.png|979x979px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== LAMMPS script for heat capacity experiments: ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE SIMULATION BOX GEOMETRY ###&lt;br /&gt;
&lt;br /&gt;
variable dens equal 0.2&lt;br /&gt;
&lt;br /&gt;
lattice sc ${dens}&lt;br /&gt;
&lt;br /&gt;
region box block 0 15 0 15 0 15&lt;br /&gt;
&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&lt;br /&gt;
create_atoms 1 box&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE PHYSICAL PROPERTIES OF ATOMS ###&lt;br /&gt;
&lt;br /&gt;
mass 1 1.0&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut/opt 3.0&lt;br /&gt;
&lt;br /&gt;
pair_coeff 1 1 1.0 1.0&lt;br /&gt;
&lt;br /&gt;
neighbor 2.0 bin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&lt;br /&gt;
&lt;br /&gt;
variable T equal 2.0&lt;br /&gt;
&lt;br /&gt;
variable timestep equal 0.0075&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; ASSIGN ATOMIC VELOCITIES ###&lt;br /&gt;
&lt;br /&gt;
velocity all create ${T} 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY ENSEMBLE ###&lt;br /&gt;
&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; THERMODYNAMIC OUTPUT CONTROL ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
&lt;br /&gt;
thermo 10&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RECORD TRAJECTORY ###&lt;br /&gt;
&lt;br /&gt;
dump traj all custom 1000 output-1 id x y z&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY TIMESTEP ###&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RUN SIMULATION TO MELT CRYSTAL ###&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
unfix nve&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; BRING SYSTEM TO REQUIRED STATE ###&lt;br /&gt;
&lt;br /&gt;
variable tdamp equal ${timestep}*100&lt;br /&gt;
&lt;br /&gt;
fix nvt all nvt temp ${T} ${T} ${tdamp}&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
unfix nvt&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; MEASURE SYSTEM STATE ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom etotal temp atoms vol&lt;br /&gt;
&lt;br /&gt;
variable vol equal vol&lt;br /&gt;
&lt;br /&gt;
variable atoms equal atoms&lt;br /&gt;
&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
&lt;br /&gt;
variable N2 equal atoms*atoms&lt;br /&gt;
&lt;br /&gt;
variable E2 equal etotal*etotal&lt;br /&gt;
&lt;br /&gt;
variable E equal etotal&lt;br /&gt;
&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_temp2 v_E v_E2&lt;br /&gt;
&lt;br /&gt;
run 100000&lt;br /&gt;
&lt;br /&gt;
variable heatcapac equal&lt;br /&gt;
${N2}*(f_aves[3]-(f_aves[2]*f_aves[2]))/(f_aves[1])&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Averages&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;--------&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Heat Capacity: ${heatcapac}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Volume: ${vol}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;No of atoms: ${atoms}&amp;quot;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659508</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659508"/>
		<updated>2018-01-31T10:43:46Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Liquid Simulations Computational Lab Assignment - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
Molecular dynamics simulations of particles interacting according to a Lennard-Jones potential were performed using the velocity-Verlet algorithm. Temperature dependence of density in the NpT ensemble was monitored, and significant deviation from the ideal gas law was observed at low temperatures due to the no collisions assumption breaking down. Heat capacity was monitored as a function of temperature in the NVT ensemble. The radial distribution functions were obtained for solid, liquid and gas systems, as were diffusion coefficients via the mean squared displacement. Potential industrial applications for such molecular dynamics simulations are also discussed.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All un-equilibrated fluid systems will move via diffusion toward thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
One study on the extraction of basil essential oil from the&lt;br /&gt;
&amp;lt;em&amp;gt;Ocimum basilicum&amp;lt;/em&amp;gt; leaf exemplifies this&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;. The diffusion coefficient was&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, while the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates, due to different tissue structures inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. This knowledge allows manufacturers to fit the model&lt;br /&gt;
mathematically using parameters specific to their distillation setup, and use the result to find the best trade-off between extraction time (time and energy are expensive) and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to use computational models of particles interacting according to a Lennard-Jones potential to extract thermodynamic data about the system and ultimately calculate the diffusion coefficient. The experiment uses boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied to simulate a much larger &#039;effective system&#039;. The velocity-Verlet&lt;br /&gt;
algorithm&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; is used, which iterates the velocity and displacement for every particle in the system, from&lt;br /&gt;
an initial state, through the desired number of steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted, for e.g. Temperature can be obtained using the average kinetic energies in conjunction with the equipartition theorem.&lt;br /&gt;
&lt;br /&gt;
Reduced units throughout the experiment to make the magnitudes of the quantities used more managable.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq1.png|188x188px]]&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;r = inter-particle distance, σ = inter-particle distance when the potential = 0, E = potential, ε = depth of the potential well, T = temperature and k = the Boltzmann constant. Starred quantities represent the non-reduced&lt;br /&gt;
versions. Note the unites cancel out when forming these quantities and hence they are unitless.&lt;br /&gt;
&lt;br /&gt;
By cancelling through these reduced units, we obtain that time is also in reduced units and can be converted via:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq122.png]]&lt;br /&gt;
&lt;br /&gt;
This is used for calculating the diffusion coefficient, though may be used to obtain the true timescale for any of the simulations.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
The open source software, LAMMPS, was used to run the molecular dynamics simulations. The experiment was run as 5 separate parts:&lt;br /&gt;
# The effect of the time step on the simulation was probed using a box of 1000 atoms, equally spaced with a number density of 0.8 atoms per unit volume. The ensemble was treated as microcanonical. The following time steps were trialed: 0.0150, 0.0100, 0.0075, 0.0025, 0.0010. Energy, temperature and pressure for the system were collected at each iteration. A timestep of 0.0025 was used for the two subsequent simulations - see results and discussion for justification.&lt;br /&gt;
# A set of simulations were run in the isobaric-isothermal (NpT) ensemble. At P = 2.5 &amp;amp; P = 3.0, the simulation was run over the following temperatures: T = 1.5, 2.0, 2.5, 3.5, 5. Density of the systems was extracted as an average after the simulation, and plotted against temperature to test the agreement with the ideal gas law.&lt;br /&gt;
# An experiment was run in the NVT ensemble at densities 0.2 &amp;amp; 0.8, over the temperatures T = 2.0, 2.2, 2.4, 2.6, 2.8. The average heat capacity and temperature were collected for each system.&lt;br /&gt;
# Simulations were performed for a solid, a liquid and a gas system. A timestep of 0.0020 was used. Parameters for this were selected based on a previous probe into the phase transitions of the Lennard-Jones system&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;; solid (density = 1.2, T = 0.5), liquid (density = 0.8, T = 1.2), gas (density = 0.2, T = 1.2). The output trajectories were used to calculate the RDF (radial distribution function), i.e. the radial frequency of meeting another particle averaged over all spherical angles.&lt;br /&gt;
# Simulations were again performed for a solid, a liquid and a gas phase system. A timestep of 0.0020 was used for this experiment, and the same density/temperature parameters at experiment 4. The MSD (mean squared displacement) was collected as a function of timestep.&lt;br /&gt;
&lt;br /&gt;
== Results &amp;amp; Discussion ==&lt;br /&gt;
&lt;br /&gt;
=== Experiment 1 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq2.png|404x404px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq3.png|406x406px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq4.png|468x468px]]&lt;br /&gt;
&lt;br /&gt;
These plots show how the thermodynamic state variables of the system vary with time. For all of the variables , we see a very quick convergence from the initial value to the steady state value. A closer inspection of these graphs reveal&lt;br /&gt;
equilibration happens after roughly 0.5 reduced time units. This shows how the system which is initially ordered quickly descends into chaos. After this point, the state variables proceed to oscillate randomly as a noise function. This occurs due to fluctuations in the system which is constantly moving. If the system had more particles, the average would be less noisy because there are more opportunities for the random imbalances to cancel each other out.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq5.png|514x514px]]&lt;br /&gt;
&lt;br /&gt;
The above plot shows how the energy varies with timestep. As the time step is increased the average energy&lt;br /&gt;
increases due to the resolution of the numerical solution decreasing. The largest timestep shows a clear divergence. Presumably the timestep is so large that particles are getting unrealistically close to each other. The reaction in the next timestep cascades such that the problem is transferred to neighbouring particles. At this point the simulation breaks down as the energies and particle positions become increasingly unrealistic. 0.0025 was the largest timestep which showed no sign of this increased energy or divergence, and hence the timestep used for all subsequent experiments was smaller than this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 2 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq6.png|501x501px]]&lt;br /&gt;
&lt;br /&gt;
The density decreases with temperature as expected; the&lt;br /&gt;
atoms have more kinetic energy, so push each other apart further during their&lt;br /&gt;
random motion. The higher pressure plots show a consistently higher density.&lt;br /&gt;
This is intuitive as at higher pressures, the atoms are squashed closer&lt;br /&gt;
together on average.  &lt;br /&gt;
&lt;br /&gt;
At lower temperatures, the ideal gas law result diverges&lt;br /&gt;
from the simulation. This is because the ideal gas law assumes no collisions.&lt;br /&gt;
At lower temperatures, particles of an ideal gas continue to be compressed into&lt;br /&gt;
a smaller space due to their diminishing kinetic energy, such that they are in&lt;br /&gt;
fact overlapping. In the simulation the particles collide, meaning a much&lt;br /&gt;
greater kinetic energy (temperature) reduction is required to achieve the same&lt;br /&gt;
increase in density. Also note that the ideal gas law allows for infinity as the&lt;br /&gt;
limiting density, whereas this becomes infinitely unlikely when using Van Der&lt;br /&gt;
Waals potential between the atoms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 3 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq7.png|486x486px]]&lt;br /&gt;
&lt;br /&gt;
The heat capacity is smaller for lower densities&lt;br /&gt;
as expected: there are less atoms to sink energy into, so the average kinetic energy&lt;br /&gt;
increases more quickly. The heat capacity decreases with temperature because at higher temperatures, the energy states are closer together, meaning it is easier to populate new states (higher density of states). This clearly outweighs any increased degeneracy in states, otherwise we would see the heat capacity increase with temperature as is often the case. The plateau could indicate a first order phase transition where the heat capacity tends to infinity. This would be made more clear with a higher resolution of data points. The radial distribution function could be calculated either side as the less ordered phase would have a smoother curve.    &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 4 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq8.png|478x478px]]&lt;br /&gt;
&lt;br /&gt;
The radial distribution function (RDF) represents the density of particles around a single particle in the system on average as a function of radius, averaged over all possible angles in a sphere. The RDFs for the different phases are distinct. In the solid case, we se sharp peaks corresponding to when we hit a site in the crystalline lattice. In the liquid, the peaks are much less sharp, as there are many more positions the molecules can occupy easily relative to one another. Peaks are still defined as the distance between particles is roughly constant. A gas behaves like a liquid with very little order. It is less peaks if any (occur at higher densities) are much less well defined. There is still a sharp peak close to the particle as neighbouring particles spend the most time when changing direction during a collision as this is when velocity is the smallest. All three phases exhibit a cut-off displacement due to the steep positive region in the Lennard-Jones potential.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq9.png|533x533px]]&lt;br /&gt;
&lt;br /&gt;
When the RDF is viewed cumulatively, we see the steepest cumulation for the solid, followed by the liquid then gas. This is due to meeting particles more frequently when in the more dense phase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 5 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq10.png|687x687px]]&lt;br /&gt;
&lt;br /&gt;
The mean squared displacement plot used the same colours as before to represent a solid, liquid and gas. Initially the MSD is slow to rise, in particular for the gas. This is due to the particles taking some time to disperse properly and reach equilibrium velocity. The gas has the most freedom and kinetic energy so the MSD is the greatest. The opposite is true for the solid. The liquid is closer to the solid in terms of MSD because it is still relatively ordered, and there is some kind of activation barrier to molecules swapping between cages. The gradient for a solid is effectively zero as swapping positions in a crystalline lattice is extremely rare.&lt;br /&gt;
&lt;br /&gt;
The second plot shows a method of least squared fit, taking into account points after timestep = 1000 only, to avoid data from the equilibration period being considered. The gradients were as following:&lt;br /&gt;
&lt;br /&gt;
Solid: 2.94 x10&amp;lt;sup&amp;gt;-8&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Liquid: 1.02 x10&amp;lt;sup&amp;gt;-3&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gas: 1.00 x10&amp;lt;sup&amp;gt;-2&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The MSD is related to the diffusion coefficient by a simple relationship:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq11.png]]&lt;br /&gt;
&lt;br /&gt;
By simply using this relation, we obtain D as following (in timestep units):&lt;br /&gt;
&lt;br /&gt;
Solid: 4.9 x10&amp;lt;sup&amp;gt;-9&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Liquid: 1.7 x10&amp;lt;sup&amp;gt;-4&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gas: 1.7 x10&amp;lt;sup&amp;gt;-3&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To convert to the correct units, we must simply apply:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq122.png]]&lt;br /&gt;
&lt;br /&gt;
Now it has been show we can model&lt;br /&gt;
the diffusion coefficient based purely on molecular dynamics simulations, we can see how similar simulations could be applied to real world&lt;br /&gt;
applications. In the basil leaf case introduced in the introduction, we could model the leaf&lt;br /&gt;
structure to follow the real leaf tissue, by using different densities. We would then be able to model accurately how the diffusion of basil&lt;br /&gt;
essential oil molecules changes as a vapour shell forms and molecules in the&lt;br /&gt;
leaf are depleted.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
The primary conclusion of this experiment is that molecular dynamics simulations are suitable for physical modelling, and can give more accurate results than ideal solutions such as the ideal gas law. The next step is to begin applying these models to real systems and test their ability to model accurately.&lt;br /&gt;
&lt;br /&gt;
The molecular dynamics simulations gave a better estimate of the thermodynamic state variables because collisions were included. This is particularly relevant at low temperatures and high pressures. The heat capacity simulations showed that it is possible to observe phase transitions between phases. The RDF is a unique insight that would be much more difficult to measure in reality. It is a useful tool as is gives us detailed information on the structure of the system being studied. In a solid for example, the RDF peaks can be correlated to crystalline lattice sites. Having access to the displacements and velocities of each particle allows us to calculate a wealth of parameters, the diffusion coefficient being just one example.&lt;br /&gt;
&lt;br /&gt;
It is clear that the amount of important data that can be quickly obtained for a system simulated using molecular dynamics is immense. It would be recommended that such methods are tested against real world experiments to gain a better understanding of their accuracy.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# J. Silveira, A. Costa and E. Costa Junior, &#039;&#039;Engenharia Agrícola&#039;&#039;, 2017, 37, 717-726.&lt;br /&gt;
# L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1967, 159, 98-103.&lt;br /&gt;
# J. Hansen and L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1969, 184, 151-161.&lt;br /&gt;
&lt;br /&gt;
Weblinks:&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;http://www.scielo.br/scielo.php?script=sci_arttext&amp;amp;pid=S0100-69162017000400717#B21&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.159.98&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
Previously unanswered tasks:&lt;br /&gt;
[[File:Smliqt1.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Smliqt2.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Smliqt3.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Smliqt4.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Smliqt5.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Smliqt6.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
LAMMPS script for heat capacity experiments:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE SIMULATION BOX GEOMETRY ###&lt;br /&gt;
&lt;br /&gt;
variable dens equal 0.2&lt;br /&gt;
&lt;br /&gt;
lattice sc ${dens}&lt;br /&gt;
&lt;br /&gt;
region box block 0 15 0 15 0 15&lt;br /&gt;
&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&lt;br /&gt;
create_atoms 1 box&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE PHYSICAL PROPERTIES OF ATOMS ###&lt;br /&gt;
&lt;br /&gt;
mass 1 1.0&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut/opt 3.0&lt;br /&gt;
&lt;br /&gt;
pair_coeff 1 1 1.0 1.0&lt;br /&gt;
&lt;br /&gt;
neighbor 2.0 bin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&lt;br /&gt;
&lt;br /&gt;
variable T equal 2.0&lt;br /&gt;
&lt;br /&gt;
variable timestep equal 0.0075&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; ASSIGN ATOMIC VELOCITIES ###&lt;br /&gt;
&lt;br /&gt;
velocity all create ${T} 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY ENSEMBLE ###&lt;br /&gt;
&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; THERMODYNAMIC OUTPUT CONTROL ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
&lt;br /&gt;
thermo 10&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RECORD TRAJECTORY ###&lt;br /&gt;
&lt;br /&gt;
dump traj all custom 1000 output-1 id x y z&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY TIMESTEP ###&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RUN SIMULATION TO MELT CRYSTAL ###&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
unfix nve&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; BRING SYSTEM TO REQUIRED STATE ###&lt;br /&gt;
&lt;br /&gt;
variable tdamp equal ${timestep}*100&lt;br /&gt;
&lt;br /&gt;
fix nvt all nvt temp ${T} ${T} ${tdamp}&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
unfix nvt&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; MEASURE SYSTEM STATE ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom etotal temp atoms vol&lt;br /&gt;
&lt;br /&gt;
variable vol equal vol&lt;br /&gt;
&lt;br /&gt;
variable atoms equal atoms&lt;br /&gt;
&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
&lt;br /&gt;
variable N2 equal atoms*atoms&lt;br /&gt;
&lt;br /&gt;
variable E2 equal etotal*etotal&lt;br /&gt;
&lt;br /&gt;
variable E equal etotal&lt;br /&gt;
&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_temp2 v_E v_E2&lt;br /&gt;
&lt;br /&gt;
run 100000&lt;br /&gt;
&lt;br /&gt;
variable heatcapac equal&lt;br /&gt;
${N2}*(f_aves[3]-(f_aves[2]*f_aves[2]))/(f_aves[1])&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Averages&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;--------&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Heat Capacity: ${heatcapac}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Volume: ${vol}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;No of atoms: ${atoms}&amp;quot;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliqt6.png&amp;diff=659507</id>
		<title>File:Smliqt6.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliqt6.png&amp;diff=659507"/>
		<updated>2018-01-31T10:42:31Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659506</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659506"/>
		<updated>2018-01-31T10:42:24Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Liquid Simulations Computational Lab Assignment - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
Molecular dynamics simulations of particles interacting according to a Lennard-Jones potential were performed using the velocity-Verlet algorithm. Temperature dependence of density in the NpT ensemble was monitored, and significant deviation from the ideal gas law was observed at low temperatures due to the no collisions assumption breaking down. Heat capacity was monitored as a function of temperature in the NVT ensemble. The radial distribution functions were obtained for solid, liquid and gas systems, as were diffusion coefficients via the mean squared displacement. Potential industrial applications for such molecular dynamics simulations are also discussed.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All un-equilibrated fluid systems will move via diffusion toward thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
One study on the extraction of basil essential oil from the&lt;br /&gt;
&amp;lt;em&amp;gt;Ocimum basilicum&amp;lt;/em&amp;gt; leaf exemplifies this&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;. The diffusion coefficient was&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, while the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates, due to different tissue structures inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. This knowledge allows manufacturers to fit the model&lt;br /&gt;
mathematically using parameters specific to their distillation setup, and use the result to find the best trade-off between extraction time (time and energy are expensive) and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to use computational models of particles interacting according to a Lennard-Jones potential to extract thermodynamic data about the system and ultimately calculate the diffusion coefficient. The experiment uses boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied to simulate a much larger &#039;effective system&#039;. The velocity-Verlet&lt;br /&gt;
algorithm&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; is used, which iterates the velocity and displacement for every particle in the system, from&lt;br /&gt;
an initial state, through the desired number of steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted, for e.g. Temperature can be obtained using the average kinetic energies in conjunction with the equipartition theorem.&lt;br /&gt;
&lt;br /&gt;
Reduced units throughout the experiment to make the magnitudes of the quantities used more managable.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq1.png|188x188px]]&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;r = inter-particle distance, σ = inter-particle distance when the potential = 0, E = potential, ε = depth of the potential well, T = temperature and k = the Boltzmann constant. Starred quantities represent the non-reduced&lt;br /&gt;
versions. Note the unites cancel out when forming these quantities and hence they are unitless.&lt;br /&gt;
&lt;br /&gt;
By cancelling through these reduced units, we obtain that time is also in reduced units and can be converted via:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq122.png]]&lt;br /&gt;
&lt;br /&gt;
This is used for calculating the diffusion coefficient, though may be used to obtain the true timescale for any of the simulations.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
The open source software, LAMMPS, was used to run the molecular dynamics simulations. The experiment was run as 5 separate parts:&lt;br /&gt;
# The effect of the time step on the simulation was probed using a box of 1000 atoms, equally spaced with a number density of 0.8 atoms per unit volume. The ensemble was treated as microcanonical. The following time steps were trialed: 0.0150, 0.0100, 0.0075, 0.0025, 0.0010. Energy, temperature and pressure for the system were collected at each iteration. A timestep of 0.0025 was used for the two subsequent simulations - see results and discussion for justification.&lt;br /&gt;
# A set of simulations were run in the isobaric-isothermal (NpT) ensemble. At P = 2.5 &amp;amp; P = 3.0, the simulation was run over the following temperatures: T = 1.5, 2.0, 2.5, 3.5, 5. Density of the systems was extracted as an average after the simulation, and plotted against temperature to test the agreement with the ideal gas law.&lt;br /&gt;
# An experiment was run in the NVT ensemble at densities 0.2 &amp;amp; 0.8, over the temperatures T = 2.0, 2.2, 2.4, 2.6, 2.8. The average heat capacity and temperature were collected for each system.&lt;br /&gt;
# Simulations were performed for a solid, a liquid and a gas system. A timestep of 0.0020 was used. Parameters for this were selected based on a previous probe into the phase transitions of the Lennard-Jones system&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;; solid (density = 1.2, T = 0.5), liquid (density = 0.8, T = 1.2), gas (density = 0.2, T = 1.2). The output trajectories were used to calculate the RDF (radial distribution function), i.e. the radial frequency of meeting another particle averaged over all spherical angles.&lt;br /&gt;
# Simulations were again performed for a solid, a liquid and a gas phase system. A timestep of 0.0020 was used for this experiment, and the same density/temperature parameters at experiment 4. The MSD (mean squared displacement) was collected as a function of timestep.&lt;br /&gt;
&lt;br /&gt;
== Results &amp;amp; Discussion ==&lt;br /&gt;
&lt;br /&gt;
=== Experiment 1 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq2.png|404x404px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq3.png|406x406px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq4.png|468x468px]]&lt;br /&gt;
&lt;br /&gt;
These plots show how the thermodynamic state variables of the system vary with time. For all of the variables , we see a very quick convergence from the initial value to the steady state value. A closer inspection of these graphs reveal&lt;br /&gt;
equilibration happens after roughly 0.5 reduced time units. This shows how the system which is initially ordered quickly descends into chaos. After this point, the state variables proceed to oscillate randomly as a noise function. This occurs due to fluctuations in the system which is constantly moving. If the system had more particles, the average would be less noisy because there are more opportunities for the random imbalances to cancel each other out.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq5.png|514x514px]]&lt;br /&gt;
&lt;br /&gt;
The above plot shows how the energy varies with timestep. As the time step is increased the average energy&lt;br /&gt;
increases due to the resolution of the numerical solution decreasing. The largest timestep shows a clear divergence. Presumably the timestep is so large that particles are getting unrealistically close to each other. The reaction in the next timestep cascades such that the problem is transferred to neighbouring particles. At this point the simulation breaks down as the energies and particle positions become increasingly unrealistic. 0.0025 was the largest timestep which showed no sign of this increased energy or divergence, and hence the timestep used for all subsequent experiments was smaller than this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 2 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq6.png|501x501px]]&lt;br /&gt;
&lt;br /&gt;
The density decreases with temperature as expected; the&lt;br /&gt;
atoms have more kinetic energy, so push each other apart further during their&lt;br /&gt;
random motion. The higher pressure plots show a consistently higher density.&lt;br /&gt;
This is intuitive as at higher pressures, the atoms are squashed closer&lt;br /&gt;
together on average.  &lt;br /&gt;
&lt;br /&gt;
At lower temperatures, the ideal gas law result diverges&lt;br /&gt;
from the simulation. This is because the ideal gas law assumes no collisions.&lt;br /&gt;
At lower temperatures, particles of an ideal gas continue to be compressed into&lt;br /&gt;
a smaller space due to their diminishing kinetic energy, such that they are in&lt;br /&gt;
fact overlapping. In the simulation the particles collide, meaning a much&lt;br /&gt;
greater kinetic energy (temperature) reduction is required to achieve the same&lt;br /&gt;
increase in density. Also note that the ideal gas law allows for infinity as the&lt;br /&gt;
limiting density, whereas this becomes infinitely unlikely when using Van Der&lt;br /&gt;
Waals potential between the atoms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 3 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq7.png|486x486px]]&lt;br /&gt;
&lt;br /&gt;
The heat capacity is smaller for lower densities&lt;br /&gt;
as expected: there are less atoms to sink energy into, so the average kinetic energy&lt;br /&gt;
increases more quickly. The heat capacity decreases with temperature because at higher temperatures, the energy states are closer together, meaning it is easier to populate new states (higher density of states). This clearly outweighs any increased degeneracy in states, otherwise we would see the heat capacity increase with temperature as is often the case. The plateau could indicate a first order phase transition where the heat capacity tends to infinity. This would be made more clear with a higher resolution of data points. The radial distribution function could be calculated either side as the less ordered phase would have a smoother curve.    &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 4 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq8.png|478x478px]]&lt;br /&gt;
&lt;br /&gt;
The radial distribution function (RDF) represents the density of particles around a single particle in the system on average as a function of radius, averaged over all possible angles in a sphere. The RDFs for the different phases are distinct. In the solid case, we se sharp peaks corresponding to when we hit a site in the crystalline lattice. In the liquid, the peaks are much less sharp, as there are many more positions the molecules can occupy easily relative to one another. Peaks are still defined as the distance between particles is roughly constant. A gas behaves like a liquid with very little order. It is less peaks if any (occur at higher densities) are much less well defined. There is still a sharp peak close to the particle as neighbouring particles spend the most time when changing direction during a collision as this is when velocity is the smallest. All three phases exhibit a cut-off displacement due to the steep positive region in the Lennard-Jones potential.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq9.png|533x533px]]&lt;br /&gt;
&lt;br /&gt;
When the RDF is viewed cumulatively, we see the steepest cumulation for the solid, followed by the liquid then gas. This is due to meeting particles more frequently when in the more dense phase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 5 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq10.png|687x687px]]&lt;br /&gt;
&lt;br /&gt;
The mean squared displacement plot used the same colours as before to represent a solid, liquid and gas. Initially the MSD is slow to rise, in particular for the gas. This is due to the particles taking some time to disperse properly and reach equilibrium velocity. The gas has the most freedom and kinetic energy so the MSD is the greatest. The opposite is true for the solid. The liquid is closer to the solid in terms of MSD because it is still relatively ordered, and there is some kind of activation barrier to molecules swapping between cages. The gradient for a solid is effectively zero as swapping positions in a crystalline lattice is extremely rare.&lt;br /&gt;
&lt;br /&gt;
The second plot shows a method of least squared fit, taking into account points after timestep = 1000 only, to avoid data from the equilibration period being considered. The gradients were as following:&lt;br /&gt;
&lt;br /&gt;
Solid: 2.94 x10&amp;lt;sup&amp;gt;-8&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Liquid: 1.02 x10&amp;lt;sup&amp;gt;-3&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gas: 1.00 x10&amp;lt;sup&amp;gt;-2&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The MSD is related to the diffusion coefficient by a simple relationship:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq11.png]]&lt;br /&gt;
&lt;br /&gt;
By simply using this relation, we obtain D as following (in timestep units):&lt;br /&gt;
&lt;br /&gt;
Solid: 4.9 x10&amp;lt;sup&amp;gt;-9&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Liquid: 1.7 x10&amp;lt;sup&amp;gt;-4&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gas: 1.7 x10&amp;lt;sup&amp;gt;-3&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To convert to the correct units, we must simply apply:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq122.png]]&lt;br /&gt;
&lt;br /&gt;
Now it has been show we can model&lt;br /&gt;
the diffusion coefficient based purely on molecular dynamics simulations, we can see how similar simulations could be applied to real world&lt;br /&gt;
applications. In the basil leaf case introduced in the introduction, we could model the leaf&lt;br /&gt;
structure to follow the real leaf tissue, by using different densities. We would then be able to model accurately how the diffusion of basil&lt;br /&gt;
essential oil molecules changes as a vapour shell forms and molecules in the&lt;br /&gt;
leaf are depleted.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
The primary conclusion of this experiment is that molecular dynamics simulations are suitable for physical modelling, and can give more accurate results than ideal solutions such as the ideal gas law. The next step is to begin applying these models to real systems and test their ability to model accurately.&lt;br /&gt;
&lt;br /&gt;
The molecular dynamics simulations gave a better estimate of the thermodynamic state variables because collisions were included. This is particularly relevant at low temperatures and high pressures. The heat capacity simulations showed that it is possible to observe phase transitions between phases. The RDF is a unique insight that would be much more difficult to measure in reality. It is a useful tool as is gives us detailed information on the structure of the system being studied. In a solid for example, the RDF peaks can be correlated to crystalline lattice sites. Having access to the displacements and velocities of each particle allows us to calculate a wealth of parameters, the diffusion coefficient being just one example.&lt;br /&gt;
&lt;br /&gt;
It is clear that the amount of important data that can be quickly obtained for a system simulated using molecular dynamics is immense. It would be recommended that such methods are tested against real world experiments to gain a better understanding of their accuracy.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# J. Silveira, A. Costa and E. Costa Junior, &#039;&#039;Engenharia Agrícola&#039;&#039;, 2017, 37, 717-726.&lt;br /&gt;
# L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1967, 159, 98-103.&lt;br /&gt;
# J. Hansen and L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1969, 184, 151-161.&lt;br /&gt;
&lt;br /&gt;
Weblinks:&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;http://www.scielo.br/scielo.php?script=sci_arttext&amp;amp;pid=S0100-69162017000400717#B21&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.159.98&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
LAMMPS script for heat capacity experiments&lt;br /&gt;
&lt;br /&gt;
Heat capacity LAMMPS input:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE SIMULATION BOX GEOMETRY ###&lt;br /&gt;
&lt;br /&gt;
variable dens equal 0.2&lt;br /&gt;
&lt;br /&gt;
lattice sc ${dens}&lt;br /&gt;
&lt;br /&gt;
region box block 0 15 0 15 0 15&lt;br /&gt;
&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&lt;br /&gt;
create_atoms 1 box&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE PHYSICAL PROPERTIES OF ATOMS ###&lt;br /&gt;
&lt;br /&gt;
mass 1 1.0&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut/opt 3.0&lt;br /&gt;
&lt;br /&gt;
pair_coeff 1 1 1.0 1.0&lt;br /&gt;
&lt;br /&gt;
neighbor 2.0 bin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&lt;br /&gt;
&lt;br /&gt;
variable T equal 2.0&lt;br /&gt;
&lt;br /&gt;
variable timestep equal 0.0075&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; ASSIGN ATOMIC VELOCITIES ###&lt;br /&gt;
&lt;br /&gt;
velocity all create ${T} 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY ENSEMBLE ###&lt;br /&gt;
&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; THERMODYNAMIC OUTPUT CONTROL ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
&lt;br /&gt;
thermo 10&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RECORD TRAJECTORY ###&lt;br /&gt;
&lt;br /&gt;
dump traj all custom 1000 output-1 id x y z&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY TIMESTEP ###&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RUN SIMULATION TO MELT CRYSTAL ###&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
unfix nve&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; BRING SYSTEM TO REQUIRED STATE ###&lt;br /&gt;
&lt;br /&gt;
variable tdamp equal ${timestep}*100&lt;br /&gt;
&lt;br /&gt;
fix nvt all nvt temp ${T} ${T} ${tdamp}&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
unfix nvt&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; MEASURE SYSTEM STATE ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom etotal temp atoms vol&lt;br /&gt;
&lt;br /&gt;
variable vol equal vol&lt;br /&gt;
&lt;br /&gt;
variable atoms equal atoms&lt;br /&gt;
&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
&lt;br /&gt;
variable N2 equal atoms*atoms&lt;br /&gt;
&lt;br /&gt;
variable E2 equal etotal*etotal&lt;br /&gt;
&lt;br /&gt;
variable E equal etotal&lt;br /&gt;
&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_temp2 v_E v_E2&lt;br /&gt;
&lt;br /&gt;
run 100000&lt;br /&gt;
&lt;br /&gt;
variable heatcapac equal&lt;br /&gt;
${N2}*(f_aves[3]-(f_aves[2]*f_aves[2]))/(f_aves[1])&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Averages&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;--------&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Heat Capacity: ${heatcapac}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Volume: ${vol}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;No of atoms: ${atoms}&amp;quot;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliqt5.png&amp;diff=659505</id>
		<title>File:Smliqt5.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliqt5.png&amp;diff=659505"/>
		<updated>2018-01-31T10:41:56Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliqt3.png&amp;diff=659504</id>
		<title>File:Smliqt3.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliqt3.png&amp;diff=659504"/>
		<updated>2018-01-31T10:41:10Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliqt2.png&amp;diff=659500</id>
		<title>File:Smliqt2.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliqt2.png&amp;diff=659500"/>
		<updated>2018-01-31T10:37:00Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliqt1.png&amp;diff=659498</id>
		<title>File:Smliqt1.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliqt1.png&amp;diff=659498"/>
		<updated>2018-01-31T10:36:16Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659470</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659470"/>
		<updated>2018-01-31T10:06:42Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Liquid Simulations Computational Lab Assignment - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
Molecular dynamics simulations of particles interacting according to a Lennard-Jones potential were performed using the velocity-Verlet algorithm. Temperature dependence of density in the NpT ensemble was monitored, and significant deviation from the ideal gas law was observed at low temperatures due to the no collisions assumption breaking down. Heat capacity was monitored as a function of temperature in the NVT ensemble. The radial distribution functions were obtained for solid, liquid and gas systems, as were diffusion coefficients via the mean squared displacement. Potential industrial applications for such molecular dynamics simulations are also discussed.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All un-equilibrated fluid systems will move via diffusion toward thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
One study on the extraction of basil essential oil from the&lt;br /&gt;
&amp;lt;em&amp;gt;Ocimum basilicum&amp;lt;/em&amp;gt; leaf exemplifies this&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;. The diffusion coefficient was&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, while the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates, due to different tissue structures inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. This knowledge allows manufacturers to fit the model&lt;br /&gt;
mathematically using parameters specific to their distillation setup, and use the result to find the best trade-off between extraction time (time and energy are expensive) and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to use computational models of particles interacting according to a Lennard-Jones potential to extract thermodynamic data about the system and ultimately calculate the diffusion coefficient. The experiment uses boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied to simulate a much larger &#039;effective system&#039;. The velocity-Verlet&lt;br /&gt;
algorithm&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; is used, which iterates the velocity and displacement for every particle in the system, from&lt;br /&gt;
an initial state, through the desired number of steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted, for e.g. Temperature can be obtained using the average kinetic energies in conjunction with the equipartition theorem.&lt;br /&gt;
&lt;br /&gt;
Reduced units throughout the experiment to make the magnitudes of the quantities used more managable.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq1.png|188x188px]]&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;r = inter-particle distance, σ = inter-particle distance when the potential = 0, E = potential, ε = depth of the potential well, T = temperature and k = the Boltzmann constant. Starred quantities represent the non-reduced&lt;br /&gt;
versions. Note the unites cancel out when forming these quantities and hence they are unitless.&lt;br /&gt;
&lt;br /&gt;
By cancelling through these reduced units, we obtain that time is also in reduced units and can be converted via:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq122.png]]&lt;br /&gt;
&lt;br /&gt;
This is used for calculating the diffusion coefficient, though may be used to obtain the true timescale for any of the simulations.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
The open source software, LAMMPS, was used to run the molecular dynamics simulations. The experiment was run as 5 separate parts:&lt;br /&gt;
# The effect of the time step on the simulation was probed using a box of 1000 atoms, equally spaced with a number density of 0.8 atoms per unit volume. The ensemble was treated as microcanonical. The following time steps were trialed: 0.0150, 0.0100, 0.0075, 0.0025, 0.0010. Energy, temperature and pressure for the system were collected at each iteration. A timestep of 0.0025 was used for the two subsequent simulations - see results and discussion for justification.&lt;br /&gt;
# A set of simulations were run in the isobaric-isothermal (NpT) ensemble. At P = 2.5 &amp;amp; P = 3.0, the simulation was run over the following temperatures: T = 1.5, 2.0, 2.5, 3.5, 5. Density of the systems was extracted as an average after the simulation, and plotted against temperature to test the agreement with the ideal gas law.&lt;br /&gt;
# An experiment was run in the NVT ensemble at densities 0.2 &amp;amp; 0.8, over the temperatures T = 2.0, 2.2, 2.4, 2.6, 2.8. The average heat capacity and temperature were collected for each system.&lt;br /&gt;
# Simulations were performed for a solid, a liquid and a gas system. A timestep of 0.0020 was used. Parameters for this were selected based on a previous probe into the phase transitions of the Lennard-Jones system&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;; solid (density = 1.2, T = 0.5), liquid (density = 0.8, T = 1.2), gas (density = 0.2, T = 1.2). The output trajectories were used to calculate the RDF (radial distribution function), i.e. the radial frequency of meeting another particle averaged over all spherical angles.&lt;br /&gt;
# Simulations were again performed for a solid, a liquid and a gas phase system. A timestep of 0.0020 was used for this experiment, and the same density/temperature parameters at experiment 4. The MSD (mean squared displacement) was collected as a function of timestep.&lt;br /&gt;
&lt;br /&gt;
== Results &amp;amp; Discussion ==&lt;br /&gt;
&lt;br /&gt;
=== Experiment 1 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq2.png|404x404px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq3.png|406x406px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq4.png|468x468px]]&lt;br /&gt;
&lt;br /&gt;
These plots show how the thermodynamic state variables of the system vary with time. For all of the variables , we see a very quick convergence from the initial value to the steady state value. A closer inspection of these graphs reveal&lt;br /&gt;
equilibration happens after roughly 0.5 reduced time units. This shows how the system which is initially ordered quickly descends into chaos. After this point, the state variables proceed to oscillate randomly as a noise function. This occurs due to fluctuations in the system which is constantly moving. If the system had more particles, the average would be less noisy because there are more opportunities for the random imbalances to cancel each other out.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq5.png|514x514px]]&lt;br /&gt;
&lt;br /&gt;
The above plot shows how the energy varies with timestep. As the time step is increased the average energy&lt;br /&gt;
increases due to the resolution of the numerical solution decreasing. The largest timestep shows a clear divergence. Presumably the timestep is so large that particles are getting unrealistically close to each other. The reaction in the next timestep cascades such that the problem is transferred to neighbouring particles. At this point the simulation breaks down as the energies and particle positions become increasingly unrealistic. 0.0025 was the largest timestep which showed no sign of this increased energy or divergence, and hence the timestep used for all subsequent experiments was smaller than this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 2 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq6.png|501x501px]]&lt;br /&gt;
&lt;br /&gt;
The density decreases with temperature as expected; the&lt;br /&gt;
atoms have more kinetic energy, so push each other apart further during their&lt;br /&gt;
random motion. The higher pressure plots show a consistently higher density.&lt;br /&gt;
This is intuitive as at higher pressures, the atoms are squashed closer&lt;br /&gt;
together on average.  &lt;br /&gt;
&lt;br /&gt;
At lower temperatures, the ideal gas law result diverges&lt;br /&gt;
from the simulation. This is because the ideal gas law assumes no collisions.&lt;br /&gt;
At lower temperatures, particles of an ideal gas continue to be compressed into&lt;br /&gt;
a smaller space due to their diminishing kinetic energy, such that they are in&lt;br /&gt;
fact overlapping. In the simulation the particles collide, meaning a much&lt;br /&gt;
greater kinetic energy (temperature) reduction is required to achieve the same&lt;br /&gt;
increase in density. Also note that the ideal gas law allows for infinity as the&lt;br /&gt;
limiting density, whereas this becomes infinitely unlikely when using Van Der&lt;br /&gt;
Waals potential between the atoms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 3 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq7.png|486x486px]]&lt;br /&gt;
&lt;br /&gt;
The heat capacity is smaller for lower densities&lt;br /&gt;
as expected: there are less atoms to sink energy into, so the average kinetic energy&lt;br /&gt;
increases more quickly. The heat capacity decreases with temperature because at higher temperatures, the energy states are closer together, meaning it is easier to populate new states (higher density of states). This clearly outweighs any increased degeneracy in states, otherwise we would see the heat capacity increase with temperature as is often the case. The plateau could indicate a first order phase transition where the heat capacity tends to infinity. This would be made more clear with a higher resolution of data points. The radial distribution function could be calculated either side as the less ordered phase would have a smoother curve.    &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 4 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq8.png|478x478px]]&lt;br /&gt;
&lt;br /&gt;
The radial distribution function (RDF) represents the density of particles around a single particle in the system on average as a function of radius, averaged over all possible angles in a sphere. The RDFs for the different phases are distinct. In the solid case, we se sharp peaks corresponding to when we hit a site in the crystalline lattice. In the liquid, the peaks are much less sharp, as there are many more positions the molecules can occupy easily relative to one another. Peaks are still defined as the distance between particles is roughly constant. A gas behaves like a liquid with very little order. It is less peaks if any (occur at higher densities) are much less well defined. There is still a sharp peak close to the particle as neighbouring particles spend the most time when changing direction during a collision as this is when velocity is the smallest. All three phases exhibit a cut-off displacement due to the steep positive region in the Lennard-Jones potential.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq9.png|533x533px]]&lt;br /&gt;
&lt;br /&gt;
When the RDF is viewed cumulatively, we see the steepest cumulation for the solid, followed by the liquid then gas. This is due to meeting particles more frequently when in the more dense phase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 5 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq10.png|687x687px]]&lt;br /&gt;
&lt;br /&gt;
The mean squared displacement plot used the same colours as before to represent a solid, liquid and gas. Initially the MSD is slow to rise, in particular for the gas. This is due to the particles taking some time to disperse properly and reach equilibrium velocity. The gas has the most freedom and kinetic energy so the MSD is the greatest. The opposite is true for the solid. The liquid is closer to the solid in terms of MSD because it is still relatively ordered, and there is some kind of activation barrier to molecules swapping between cages. The gradient for a solid is effectively zero as swapping positions in a crystalline lattice is extremely rare.&lt;br /&gt;
&lt;br /&gt;
The second plot shows a method of least squared fit, taking into account points after timestep = 1000 only, to avoid data from the equilibration period being considered. The gradients were as following:&lt;br /&gt;
&lt;br /&gt;
Solid: 2.94 x10&amp;lt;sup&amp;gt;-8&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Liquid: 1.02 x10&amp;lt;sup&amp;gt;-3&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gas: 1.00 x10&amp;lt;sup&amp;gt;-2&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The MSD is related to the diffusion coefficient by a simple relationship:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq11.png]]&lt;br /&gt;
&lt;br /&gt;
By simply using this relation, we obtain D as following:&lt;br /&gt;
&lt;br /&gt;
Solid: 2.94 x10&amp;lt;sup&amp;gt;-8&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Liquid: 1.02 x10&amp;lt;sup&amp;gt;-3&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gas: 1.00 x10&amp;lt;sup&amp;gt;-2&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To convert to the correct units, we must simply divide by sigma&lt;br /&gt;
&lt;br /&gt;
Now it has been show we can model&lt;br /&gt;
the diffusion coefficient based purely on molecular dynamics simulations, we can see how similar simulations could be applied to real world&lt;br /&gt;
applications. In the basil leaf case introduced in the introduction, we could model the leaf&lt;br /&gt;
structure to follow the real leaf tissue, by using different densities. We would then be able to model accurately how the diffusion of basil&lt;br /&gt;
essential oil molecules changes as a vapour shell forms and molecules in the&lt;br /&gt;
leaf are depleted.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
The primary conclusion of this experiment is that molecular dynamics simulations are suitable for physical modelling, and can give more accurate results than ideal solutions such as the ideal gas law. The next step is to begin applying these models to real systems and test their ability to model accurately.&lt;br /&gt;
&lt;br /&gt;
The molecular dynamics simulations gave a better estimate of the thermodynamic state variables because collisions were included. This is particularly relevant at low temperatures and high pressures. The heat capacity simulations showed that it is possible to observe phase transitions between phases. The RDF is a unique insight that would be much more difficult to measure in reality. It is a useful tool as is gives us detailed information on the structure of the system being studied. In a solid for example, the RDF peaks can be correlated to crystalline lattice sites. Having access to the displacements and velocities of each particle allows us to calculate a wealth of parameters, the diffusion coefficient being just one example.&lt;br /&gt;
&lt;br /&gt;
It is clear that the amount of important data that can be quickly obtained for a system simulated using molecular dynamics is immense. It would be recommended that such methods are tested against real world experiments to gain a better understanding of their accuracy.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# J. Silveira, A. Costa and E. Costa Junior, &#039;&#039;Engenharia Agrícola&#039;&#039;, 2017, 37, 717-726.&lt;br /&gt;
# L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1967, 159, 98-103.&lt;br /&gt;
# J. Hansen and L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1969, 184, 151-161.&lt;br /&gt;
&lt;br /&gt;
Weblinks:&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;http://www.scielo.br/scielo.php?script=sci_arttext&amp;amp;pid=S0100-69162017000400717#B21&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.159.98&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
LAMMPS script for heat capacity experiments&lt;br /&gt;
&lt;br /&gt;
Heat capacity LAMMPS input:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE SIMULATION BOX GEOMETRY ###&lt;br /&gt;
&lt;br /&gt;
variable dens equal 0.2&lt;br /&gt;
&lt;br /&gt;
lattice sc ${dens}&lt;br /&gt;
&lt;br /&gt;
region box block 0 15 0 15 0 15&lt;br /&gt;
&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&lt;br /&gt;
create_atoms 1 box&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE PHYSICAL PROPERTIES OF ATOMS ###&lt;br /&gt;
&lt;br /&gt;
mass 1 1.0&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut/opt 3.0&lt;br /&gt;
&lt;br /&gt;
pair_coeff 1 1 1.0 1.0&lt;br /&gt;
&lt;br /&gt;
neighbor 2.0 bin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&lt;br /&gt;
&lt;br /&gt;
variable T equal 2.0&lt;br /&gt;
&lt;br /&gt;
variable timestep equal 0.0075&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; ASSIGN ATOMIC VELOCITIES ###&lt;br /&gt;
&lt;br /&gt;
velocity all create ${T} 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY ENSEMBLE ###&lt;br /&gt;
&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; THERMODYNAMIC OUTPUT CONTROL ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
&lt;br /&gt;
thermo 10&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RECORD TRAJECTORY ###&lt;br /&gt;
&lt;br /&gt;
dump traj all custom 1000 output-1 id x y z&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY TIMESTEP ###&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RUN SIMULATION TO MELT CRYSTAL ###&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
unfix nve&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; BRING SYSTEM TO REQUIRED STATE ###&lt;br /&gt;
&lt;br /&gt;
variable tdamp equal ${timestep}*100&lt;br /&gt;
&lt;br /&gt;
fix nvt all nvt temp ${T} ${T} ${tdamp}&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
unfix nvt&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; MEASURE SYSTEM STATE ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom etotal temp atoms vol&lt;br /&gt;
&lt;br /&gt;
variable vol equal vol&lt;br /&gt;
&lt;br /&gt;
variable atoms equal atoms&lt;br /&gt;
&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
&lt;br /&gt;
variable N2 equal atoms*atoms&lt;br /&gt;
&lt;br /&gt;
variable E2 equal etotal*etotal&lt;br /&gt;
&lt;br /&gt;
variable E equal etotal&lt;br /&gt;
&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_temp2 v_E v_E2&lt;br /&gt;
&lt;br /&gt;
run 100000&lt;br /&gt;
&lt;br /&gt;
variable heatcapac equal&lt;br /&gt;
${N2}*(f_aves[3]-(f_aves[2]*f_aves[2]))/(f_aves[1])&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Averages&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;--------&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Heat Capacity: ${heatcapac}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Volume: ${vol}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;No of atoms: ${atoms}&amp;quot;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq122.png&amp;diff=659462</id>
		<title>File:Smliq122.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq122.png&amp;diff=659462"/>
		<updated>2018-01-31T09:44:38Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659461</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659461"/>
		<updated>2018-01-31T09:43:34Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Liquid Simulations Computational Lab Assignment - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
Molecular dynamics simulations of particles interacting according to a Lennard-Jones potential were performed using the velocity-Verlet algorithm. Temperature dependence of density in the NpT ensemble was monitored, and significant deviation from the ideal gas law was observed at low temperatures due to the no collisions assumption breaking down. Heat capacity was monitored as a function of temperature in the NVT ensemble. The radial distribution functions were obtained for solid, liquid and gas systems, as were diffusion coefficients via the mean squared displacement. Potential industrial applications for such molecular dynamics simulations are also discussed.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All un-equilibrated fluid systems will move via diffusion toward thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
One study on the extraction of basil essential oil from the&lt;br /&gt;
&amp;lt;em&amp;gt;Ocimum basilicum&amp;lt;/em&amp;gt; leaf exemplifies this&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;. The diffusion coefficient was&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, while the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates, due to different tissue structures inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. This knowledge allows manufacturers to fit the model&lt;br /&gt;
mathematically using parameters specific to their distillation setup, and use the result to find the best trade-off between extraction time (time and energy are expensive) and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to use computational models of particles interacting according to a Lennard-Jones potential to extract thermodynamic data about the system and ultimately calculate the diffusion coefficient. The experiment uses boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied to simulate a much larger &#039;effective system&#039;. The velocity-Verlet&lt;br /&gt;
algorithm&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; is used, which iterates the velocity and displacement for every particle in the system, from&lt;br /&gt;
an initial state, through the desired number of steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted, for e.g. Temperature can be obtained using the average kinetic energies in conjunction with the equipartition theorem.&lt;br /&gt;
&lt;br /&gt;
Reduced units throughout the experiment to make the magnitudes of the quantities used more managable.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq1.png|188x188px]]&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;r = inter-particle distance, σ = inter-particle distance when the potential = 0, E = potential, ε = depth of the potential well, T = temperature and k = the Boltzmann constant. Starred quantities represent the non-reduced&lt;br /&gt;
versions. Note the unites cancel out when forming these quantities and hence they are unitless.&lt;br /&gt;
&lt;br /&gt;
By cancelling through these reduced units, we obtain that time is also in reduced units and can be converted via:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq122.png]]&lt;br /&gt;
&lt;br /&gt;
This is used for calculating the diffusion coefficient, though may be used to obtain the true timescale for any of the simulations.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
The open source software, LAMMPS, was used to run the molecular dynamics simulations. The experiment was run as 5 separate parts:&lt;br /&gt;
# The effect of the time step on the simulation was probed using a box of 1000 atoms, equally spaced with a number density of 0.8 atoms per unit volume. The ensemble was treated as microcanonical. The following time steps were trialed: 0.0150, 0.0100, 0.0075, 0.0025, 0.0010. Energy, temperature and pressure for the system were collected at each iteration. A timestep of 0.0025 was used for the two subsequent simulations - see results and discussion for justification.&lt;br /&gt;
# A set of simulations were run in the isobaric-isothermal (NpT) ensemble. At P = 2.5 &amp;amp; P = 3.0, the simulation was run over the following temperatures: T = 1.5, 2.0, 2.5, 3.5, 5. Density of the systems was extracted as an average after the simulation, and plotted against temperature to test the agreement with the ideal gas law.&lt;br /&gt;
# An experiment was run in the NVT ensemble at densities 0.2 &amp;amp; 0.8, over the temperatures T = 2.0, 2.2, 2.4, 2.6, 2.8. The average heat capacity and temperature were collected for each system.&lt;br /&gt;
# Simulations were performed for a solid, a liquid and a gas system. A timestep of 0.0020 was used. Parameters for this were selected based on a previous probe into the phase transitions of the Lennard-Jones system&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;; solid (density = 1.2, T = 0.5), liquid (density = 0.8, T = 1.2), gas (density = 0.2, T = 1.2). The output trajectories were used to calculate the RDF (radial distribution function), i.e. the radial frequency of meeting another particle averaged over all spherical angles.&lt;br /&gt;
# Simulations were again performed for a solid, a liquid and a gas phase system. A timestep of 0.0020 was used for this experiment, and the same density/temperature parameters at experiment 4. The MSD (mean squared displacement) was collected as a function of timestep.&lt;br /&gt;
&lt;br /&gt;
== Results &amp;amp; Discussion ==&lt;br /&gt;
&lt;br /&gt;
=== Experiment 1 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq2.png|404x404px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq3.png|406x406px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq4.png|468x468px]]&lt;br /&gt;
&lt;br /&gt;
These plots show how the thermodynamic state variables of the system vary with time. For all of the variables , we see a very quick convergence from the initial value to the steady state value. A closer inspection of these graphs reveal&lt;br /&gt;
equilibration happens after roughly 0.5 reduced time units. This shows how the system which is initially ordered quickly descends into chaos. After this point, the state variables proceed to oscillate randomly as a noise function. This occurs due to fluctuations in the system which is constantly moving. If the system had more particles, the average would be less noisy because there are more opportunities for the random imbalances to cancel each other out.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq5.png|514x514px]]&lt;br /&gt;
&lt;br /&gt;
The above plot shows how the energy varies with timestep. As the time step is increased the average energy&lt;br /&gt;
increases due to the resolution of the numerical solution decreasing. The largest timestep shows a clear divergence. Presumably the timestep is so large that particles are getting unrealistically close to each other. The reaction in the next timestep cascades such that the problem is transferred to neighbouring particles. At this point the simulation breaks down as the energies and particle positions become increasingly unrealistic. 0.0025 was the largest timestep which showed no sign of this increased energy or divergence, and hence the timestep used for all subsequent experiments was smaller than this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 2 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq6.png|501x501px]]&lt;br /&gt;
&lt;br /&gt;
The density decreases with temperature as expected; the&lt;br /&gt;
atoms have more kinetic energy, so push each other apart further during their&lt;br /&gt;
random motion. The higher pressure plots show a consistently higher density.&lt;br /&gt;
This is intuitive as at higher pressures, the atoms are squashed closer&lt;br /&gt;
together on average.  &lt;br /&gt;
&lt;br /&gt;
At lower temperatures, the ideal gas law result diverges&lt;br /&gt;
from the simulation. This is because the ideal gas law assumes no collisions.&lt;br /&gt;
At lower temperatures, particles of an ideal gas continue to be compressed into&lt;br /&gt;
a smaller space due to their diminishing kinetic energy, such that they are in&lt;br /&gt;
fact overlapping. In the simulation the particles collide, meaning a much&lt;br /&gt;
greater kinetic energy (temperature) reduction is required to achieve the same&lt;br /&gt;
increase in density. Also note that the ideal gas law allows for infinity as the&lt;br /&gt;
limiting density, whereas this becomes infinitely unlikely when using Van Der&lt;br /&gt;
Waals potential between the atoms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 3 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq7.png|486x486px]]&lt;br /&gt;
&lt;br /&gt;
The heat capacity is smaller for lower densities&lt;br /&gt;
as expected: there are less atoms to sink energy into, so the average kinetic energy&lt;br /&gt;
increases more quickly. The heat capacity decreases with temperature because at higher temperatures, the energy states are closer together, meaning it is easier to populate new states (higher density of states). This clearly outweighs any increased degeneracy in states, otherwise we would see the heat capacity increase with temperature as is often the case. The plateau could indicate a first order phase transition where the heat capacity tends to infinity. This would be made more clear with a higher resolution of data points. The radial distribution function could be calculated either side as the less ordered phase would have a smoother curve.    &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 4 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq8.png|478x478px]]&lt;br /&gt;
&lt;br /&gt;
The radial distribution function (RDF) represents the density of particles around a single particle in the system on average as a function of radius, averaged over all possible angles in a sphere. The RDFs for the different phases are distinct. In the solid case, we se sharp peaks corresponding to when we hit a site in the crystalline lattice. In the liquid, the peaks are much less sharp, as there are many more positions the molecules can occupy easily relative to one another. Peaks are still defined as the distance between particles is roughly constant. A gas behaves like a liquid with very little order. It is less peaks if any (occur at higher densities) are much less well defined. There is still a sharp peak close to the particle as neighbouring particles spend the most time when changing direction during a collision as this is when velocity is the smallest. All three phases exhibit a cut-off displacement due to the steep positive region in the Lennard-Jones potential.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq9.png|533x533px]]&lt;br /&gt;
&lt;br /&gt;
When the RDF is viewed cumulatively, we see the steepest cumulation for the solid, followed by the liquid then gas. This is due to meeting particles more frequently when in the more dense phase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 5 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq10.png|687x687px]]&lt;br /&gt;
&lt;br /&gt;
The mean squared displacement plot used the same colours as before to represent a solid, liquid and gas. Initially the MSD is slow to rise, in particular for the gas. This is due to the particles taking some time to disperse properly and reach equilibrium velocity. The gas has the most freedom and kinetic energy so the MSD is the greatest. The opposite is true for the solid. The liquid is closer to the solid in terms of MSD because it is still relatively ordered, and there is some kind of activation barrier to molecules swapping between cages. The gradient for a solid is effectively zero as swapping positions in a crystalline lattice is extremely rare.&lt;br /&gt;
&lt;br /&gt;
The second plot shows a method of least squared fit, taking into account points after timestep = 1000 only, to avoid data from the equilibration period being considered. The gradients were as following:&lt;br /&gt;
&lt;br /&gt;
Solid: 2.94 x10&amp;lt;sup&amp;gt;-8&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Liquid: 1.02 x10&amp;lt;sup&amp;gt;-3&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gas: 1.00 x10&amp;lt;sup&amp;gt;-2&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The MSD is related to the diffusion coefficient by a simple relationship:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq11.png]]&lt;br /&gt;
&lt;br /&gt;
By simply using this relation, we obtain D as following:&lt;br /&gt;
&lt;br /&gt;
Solid: 2.94 x10&amp;lt;sup&amp;gt;-8&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Liquid: 1.02 x10&amp;lt;sup&amp;gt;-3&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gas: 1.00 x10&amp;lt;sup&amp;gt;-2&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To convert to the correct units, we must simply divide by sigma&lt;br /&gt;
&lt;br /&gt;
Now it has been show we can model&lt;br /&gt;
the diffusion coefficient based purely on molecular dynamics simulations, we can see how similar simulations could be applied to real world&lt;br /&gt;
applications. In the basil leaf case introduced in the introduction, we could model the leaf&lt;br /&gt;
structure to follow the real leaf tissue, by using different densities. We would then be able to model accurately how the diffusion of basil&lt;br /&gt;
essential oil molecules changes as a vapour shell forms and molecules in the&lt;br /&gt;
leaf are depleted.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# J. Silveira, A. Costa and E. Costa Junior, &#039;&#039;Engenharia Agrícola&#039;&#039;, 2017, 37, 717-726.&lt;br /&gt;
# L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1967, 159, 98-103.&lt;br /&gt;
# J. Hansen and L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1969, 184, 151-161.&lt;br /&gt;
&lt;br /&gt;
Weblinks:&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;http://www.scielo.br/scielo.php?script=sci_arttext&amp;amp;pid=S0100-69162017000400717#B21&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.159.98&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
LAMMPS script for heat capacity experiments&lt;br /&gt;
&lt;br /&gt;
Heat capacity LAMMPS input:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE SIMULATION BOX GEOMETRY ###&lt;br /&gt;
&lt;br /&gt;
variable dens equal 0.2&lt;br /&gt;
&lt;br /&gt;
lattice sc ${dens}&lt;br /&gt;
&lt;br /&gt;
region box block 0 15 0 15 0 15&lt;br /&gt;
&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&lt;br /&gt;
create_atoms 1 box&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE PHYSICAL PROPERTIES OF ATOMS ###&lt;br /&gt;
&lt;br /&gt;
mass 1 1.0&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut/opt 3.0&lt;br /&gt;
&lt;br /&gt;
pair_coeff 1 1 1.0 1.0&lt;br /&gt;
&lt;br /&gt;
neighbor 2.0 bin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&lt;br /&gt;
&lt;br /&gt;
variable T equal 2.0&lt;br /&gt;
&lt;br /&gt;
variable timestep equal 0.0075&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; ASSIGN ATOMIC VELOCITIES ###&lt;br /&gt;
&lt;br /&gt;
velocity all create ${T} 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY ENSEMBLE ###&lt;br /&gt;
&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; THERMODYNAMIC OUTPUT CONTROL ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
&lt;br /&gt;
thermo 10&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RECORD TRAJECTORY ###&lt;br /&gt;
&lt;br /&gt;
dump traj all custom 1000 output-1 id x y z&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY TIMESTEP ###&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RUN SIMULATION TO MELT CRYSTAL ###&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
unfix nve&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; BRING SYSTEM TO REQUIRED STATE ###&lt;br /&gt;
&lt;br /&gt;
variable tdamp equal ${timestep}*100&lt;br /&gt;
&lt;br /&gt;
fix nvt all nvt temp ${T} ${T} ${tdamp}&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
unfix nvt&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; MEASURE SYSTEM STATE ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom etotal temp atoms vol&lt;br /&gt;
&lt;br /&gt;
variable vol equal vol&lt;br /&gt;
&lt;br /&gt;
variable atoms equal atoms&lt;br /&gt;
&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
&lt;br /&gt;
variable N2 equal atoms*atoms&lt;br /&gt;
&lt;br /&gt;
variable E2 equal etotal*etotal&lt;br /&gt;
&lt;br /&gt;
variable E equal etotal&lt;br /&gt;
&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_temp2 v_E v_E2&lt;br /&gt;
&lt;br /&gt;
run 100000&lt;br /&gt;
&lt;br /&gt;
variable heatcapac equal&lt;br /&gt;
${N2}*(f_aves[3]-(f_aves[2]*f_aves[2]))/(f_aves[1])&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Averages&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;--------&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Heat Capacity: ${heatcapac}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Volume: ${vol}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;No of atoms: ${atoms}&amp;quot;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659459</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659459"/>
		<updated>2018-01-31T09:42:11Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Liquid Simulations Computational Lab Assignment - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
Molecular dynamics simulations of particles interacting according to a Lennard-Jones potential were performed using the velocity-Verlet algorithm. Temperature dependence of density in the NpT ensemble was monitored, and significant deviation from the ideal gas law was observed at low temperatures due to the no collisions assumption breaking down. Heat capacity was monitored as a function of temperature in the NVT ensemble. The radial distribution functions were obtained for solid, liquid and gas systems, as were diffusion coefficients via the mean squared displacement. Potential industrial applications for such molecular dynamics simulations are also discussed.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All un-equilibrated fluid systems will move via diffusion toward thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
One study on the extraction of basil essential oil from the&lt;br /&gt;
&amp;lt;em&amp;gt;Ocimum basilicum&amp;lt;/em&amp;gt; leaf exemplifies this&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;. The diffusion coefficient was&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, while the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates, due to different tissue structures inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. This knowledge allows manufacturers to fit the model&lt;br /&gt;
mathematically using parameters specific to their distillation setup, and use the result to find the best trade-off between extraction time (time and energy are expensive) and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to use computational models of particles interacting according to a Lennard-Jones potential to extract thermodynamic data about the system and ultimately calculate the diffusion coefficient. The experiment uses boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied to simulate a much larger &#039;effective system&#039;. The velocity-Verlet&lt;br /&gt;
algorithm&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; is used, which iterates the velocity and displacement for every particle in the system, from&lt;br /&gt;
an initial state, through the desired number of steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted, for e.g. Temperature can be obtained using the average kinetic energies in conjunction with the equipartition theorem.&lt;br /&gt;
&lt;br /&gt;
Reduced units throughout the experiment to make the magnitudes of the quantities used more managable.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq1.png|188x188px]]&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;r = inter-particle distance, σ = inter-particle distance when the potential = 0, E = potential, ε = depth of the potential well, T = temperature and k = the Boltzmann constant. Starred quantities represent the non-reduced&lt;br /&gt;
versions. Note the unites cancel out when forming these quantities and hence they are unitless.&lt;br /&gt;
&lt;br /&gt;
By cancelling through these reduced units, we obtain that time is also in reduced units and can be converted via:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq12.png]]&lt;br /&gt;
&lt;br /&gt;
This is used for calculating the diffusion coefficient, though may be used to obtain the true timescale for any of the simulations.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
The open source software, LAMMPS, was used to run the molecular dynamics simulations. The experiment was run as 5 separate parts:&lt;br /&gt;
# The effect of the time step on the simulation was probed using a box of 1000 atoms, equally spaced with a number density of 0.8 atoms per unit volume. The ensemble was treated as microcanonical. The following time steps were trialed: 0.0150, 0.0100, 0.0075, 0.0025, 0.0010. Energy, temperature and pressure for the system were collected at each iteration. A timestep of 0.0025 was used for the two subsequent simulations - see results and discussion for justification.&lt;br /&gt;
# A set of simulations were run in the isobaric-isothermal (NpT) ensemble. At P = 2.5 &amp;amp; P = 3.0, the simulation was run over the following temperatures: T = 1.5, 2.0, 2.5, 3.5, 5. Density of the systems was extracted as an average after the simulation, and plotted against temperature to test the agreement with the ideal gas law.&lt;br /&gt;
# An experiment was run in the NVT ensemble at densities 0.2 &amp;amp; 0.8, over the temperatures T = 2.0, 2.2, 2.4, 2.6, 2.8. The average heat capacity and temperature were collected for each system.&lt;br /&gt;
# Simulations were performed for a solid, a liquid and a gas system. A timestep of 0.0020 was used. Parameters for this were selected based on a previous probe into the phase transitions of the Lennard-Jones system&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;; solid (density = 1.2, T = 0.5), liquid (density = 0.8, T = 1.2), gas (density = 0.2, T = 1.2). The output trajectories were used to calculate the RDF (radial distribution function), i.e. the radial frequency of meeting another particle averaged over all spherical angles.&lt;br /&gt;
# Simulations were again performed for a solid, a liquid and a gas phase system. A timestep of 0.0020 was used for this experiment, and the same density/temperature parameters at experiment 4. The MSD (mean squared displacement) was collected as a function of timestep.&lt;br /&gt;
&lt;br /&gt;
== Results &amp;amp; Discussion ==&lt;br /&gt;
&lt;br /&gt;
=== Experiment 1 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq2.png|404x404px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq3.png|406x406px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq4.png|468x468px]]&lt;br /&gt;
&lt;br /&gt;
These plots show how the thermodynamic state variables of the system vary with time. For all of the variables , we see a very quick convergence from the initial value to the steady state value. A closer inspection of these graphs reveal&lt;br /&gt;
equilibration happens after roughly 0.5 reduced time units. This shows how the system which is initially ordered quickly descends into chaos. After this point, the state variables proceed to oscillate randomly as a noise function. This occurs due to fluctuations in the system which is constantly moving. If the system had more particles, the average would be less noisy because there are more opportunities for the random imbalances to cancel each other out.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq5.png|514x514px]]&lt;br /&gt;
&lt;br /&gt;
The above plot shows how the energy varies with timestep. As the time step is increased the average energy&lt;br /&gt;
increases due to the resolution of the numerical solution decreasing. The largest timestep shows a clear divergence. Presumably the timestep is so large that particles are getting unrealistically close to each other. The reaction in the next timestep cascades such that the problem is transferred to neighbouring particles. At this point the simulation breaks down as the energies and particle positions become increasingly unrealistic. 0.0025 was the largest timestep which showed no sign of this increased energy or divergence, and hence the timestep used for all subsequent experiments was smaller than this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 2 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq6.png|501x501px]]&lt;br /&gt;
&lt;br /&gt;
The density decreases with temperature as expected; the&lt;br /&gt;
atoms have more kinetic energy, so push each other apart further during their&lt;br /&gt;
random motion. The higher pressure plots show a consistently higher density.&lt;br /&gt;
This is intuitive as at higher pressures, the atoms are squashed closer&lt;br /&gt;
together on average.  &lt;br /&gt;
&lt;br /&gt;
At lower temperatures, the ideal gas law result diverges&lt;br /&gt;
from the simulation. This is because the ideal gas law assumes no collisions.&lt;br /&gt;
At lower temperatures, particles of an ideal gas continue to be compressed into&lt;br /&gt;
a smaller space due to their diminishing kinetic energy, such that they are in&lt;br /&gt;
fact overlapping. In the simulation the particles collide, meaning a much&lt;br /&gt;
greater kinetic energy (temperature) reduction is required to achieve the same&lt;br /&gt;
increase in density. Also note that the ideal gas law allows for infinity as the&lt;br /&gt;
limiting density, whereas this becomes infinitely unlikely when using Van Der&lt;br /&gt;
Waals potential between the atoms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 3 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq7.png|486x486px]]&lt;br /&gt;
&lt;br /&gt;
The heat capacity is smaller for lower densities&lt;br /&gt;
as expected: there are less atoms to sink energy into, so the average kinetic energy&lt;br /&gt;
increases more quickly. The heat capacity decreases with temperature because at higher temperatures, the energy states are closer together, meaning it is easier to populate new states (higher density of states). This clearly outweighs any increased degeneracy in states, otherwise we would see the heat capacity increase with temperature as is often the case. The plateau could indicate a first order phase transition where the heat capacity tends to infinity. This would be made more clear with a higher resolution of data points. The radial distribution function could be calculated either side as the less ordered phase would have a smoother curve.    &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 4 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq8.png|478x478px]]&lt;br /&gt;
&lt;br /&gt;
The radial distribution function (RDF) represents the density of particles around a single particle in the system on average as a function of radius, averaged over all possible angles in a sphere. The RDFs for the different phases are distinct. In the solid case, we se sharp peaks corresponding to when we hit a site in the crystalline lattice. In the liquid, the peaks are much less sharp, as there are many more positions the molecules can occupy easily relative to one another. Peaks are still defined as the distance between particles is roughly constant. A gas behaves like a liquid with very little order. It is less peaks if any (occur at higher densities) are much less well defined. There is still a sharp peak close to the particle as neighbouring particles spend the most time when changing direction during a collision as this is when velocity is the smallest. All three phases exhibit a cut-off displacement due to the steep positive region in the Lennard-Jones potential.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq9.png|533x533px]]&lt;br /&gt;
&lt;br /&gt;
When the RDF is viewed cumulatively, we see the steepest cumulation for the solid, followed by the liquid then gas. This is due to meeting particles more frequently when in the more dense phase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 5 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq10.png|687x687px]]&lt;br /&gt;
&lt;br /&gt;
The mean squared displacement plot used the same colours as before to represent a solid, liquid and gas. Initially the MSD is slow to rise, in particular for the gas. This is due to the particles taking some time to disperse properly and reach equilibrium velocity. The gas has the most freedom and kinetic energy so the MSD is the greatest. The opposite is true for the solid. The liquid is closer to the solid in terms of MSD because it is still relatively ordered, and there is some kind of activation barrier to molecules swapping between cages. The gradient for a solid is effectively zero as swapping positions in a crystalline lattice is extremely rare.&lt;br /&gt;
&lt;br /&gt;
The second plot shows a method of least squared fit, taking into account points after timestep = 1000 only, to avoid data from the equilibration period being considered. The gradients were as following:&lt;br /&gt;
&lt;br /&gt;
Solid: 2.94 x10&amp;lt;sup&amp;gt;-8&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Liquid: 1.02 x10&amp;lt;sup&amp;gt;-3&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gas: 1.00 x10&amp;lt;sup&amp;gt;-2&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The MSD is related to the diffusion coefficient by a simple relationship:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq11.png]]&lt;br /&gt;
&lt;br /&gt;
By simply using this relation, we obtain D as following:&lt;br /&gt;
&lt;br /&gt;
Solid: 2.94 x10&amp;lt;sup&amp;gt;-8&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Liquid: 1.02 x10&amp;lt;sup&amp;gt;-3&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gas: 1.00 x10&amp;lt;sup&amp;gt;-2&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To convert to the correct units, we must simply divide by sigma&lt;br /&gt;
&lt;br /&gt;
Now it has been show we can model&lt;br /&gt;
the diffusion coefficient based purely on molecular dynamics simulations, we can see how similar simulations could be applied to real world&lt;br /&gt;
applications. In the basil leaf case introduced in the introduction, we could model the leaf&lt;br /&gt;
structure to follow the real leaf tissue, by using different densities. We would then be able to model accurately how the diffusion of basil&lt;br /&gt;
essential oil molecules changes as a vapour shell forms and molecules in the&lt;br /&gt;
leaf are depleted.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# J. Silveira, A. Costa and E. Costa Junior, &#039;&#039;Engenharia Agrícola&#039;&#039;, 2017, 37, 717-726.&lt;br /&gt;
# L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1967, 159, 98-103.&lt;br /&gt;
# J. Hansen and L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1969, 184, 151-161.&lt;br /&gt;
&lt;br /&gt;
Weblinks:&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;http://www.scielo.br/scielo.php?script=sci_arttext&amp;amp;pid=S0100-69162017000400717#B21&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.159.98&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
LAMMPS script for heat capacity experiments&lt;br /&gt;
&lt;br /&gt;
Heat capacity LAMMPS input:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE SIMULATION BOX GEOMETRY ###&lt;br /&gt;
&lt;br /&gt;
variable dens equal 0.2&lt;br /&gt;
&lt;br /&gt;
lattice sc ${dens}&lt;br /&gt;
&lt;br /&gt;
region box block 0 15 0 15 0 15&lt;br /&gt;
&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&lt;br /&gt;
create_atoms 1 box&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE PHYSICAL PROPERTIES OF ATOMS ###&lt;br /&gt;
&lt;br /&gt;
mass 1 1.0&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut/opt 3.0&lt;br /&gt;
&lt;br /&gt;
pair_coeff 1 1 1.0 1.0&lt;br /&gt;
&lt;br /&gt;
neighbor 2.0 bin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&lt;br /&gt;
&lt;br /&gt;
variable T equal 2.0&lt;br /&gt;
&lt;br /&gt;
variable timestep equal 0.0075&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; ASSIGN ATOMIC VELOCITIES ###&lt;br /&gt;
&lt;br /&gt;
velocity all create ${T} 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY ENSEMBLE ###&lt;br /&gt;
&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; THERMODYNAMIC OUTPUT CONTROL ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
&lt;br /&gt;
thermo 10&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RECORD TRAJECTORY ###&lt;br /&gt;
&lt;br /&gt;
dump traj all custom 1000 output-1 id x y z&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY TIMESTEP ###&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RUN SIMULATION TO MELT CRYSTAL ###&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
unfix nve&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; BRING SYSTEM TO REQUIRED STATE ###&lt;br /&gt;
&lt;br /&gt;
variable tdamp equal ${timestep}*100&lt;br /&gt;
&lt;br /&gt;
fix nvt all nvt temp ${T} ${T} ${tdamp}&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
unfix nvt&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; MEASURE SYSTEM STATE ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom etotal temp atoms vol&lt;br /&gt;
&lt;br /&gt;
variable vol equal vol&lt;br /&gt;
&lt;br /&gt;
variable atoms equal atoms&lt;br /&gt;
&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
&lt;br /&gt;
variable N2 equal atoms*atoms&lt;br /&gt;
&lt;br /&gt;
variable E2 equal etotal*etotal&lt;br /&gt;
&lt;br /&gt;
variable E equal etotal&lt;br /&gt;
&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_temp2 v_E v_E2&lt;br /&gt;
&lt;br /&gt;
run 100000&lt;br /&gt;
&lt;br /&gt;
variable heatcapac equal&lt;br /&gt;
${N2}*(f_aves[3]-(f_aves[2]*f_aves[2]))/(f_aves[1])&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Averages&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;--------&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Heat Capacity: ${heatcapac}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Volume: ${vol}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;No of atoms: ${atoms}&amp;quot;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq12.png&amp;diff=659448</id>
		<title>File:Smliq12.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq12.png&amp;diff=659448"/>
		<updated>2018-01-31T09:32:23Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: Sm6415 uploaded a new version of File:Smliq12.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659441</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659441"/>
		<updated>2018-01-31T09:06:57Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Liquid Simulations Computational Lab Assignment - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All un-equilibrated fluid systems will move via diffusion toward thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
One study on the extraction of basil essential oil from the&lt;br /&gt;
&amp;lt;em&amp;gt;Ocimum basilicum&amp;lt;/em&amp;gt; leaf exemplifies this&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;. The diffusion coefficient was&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, while the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates, due to different tissue structures inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. This knowledge allows manufacturers to fit the model&lt;br /&gt;
mathematically using parameters specific to their distillation setup, and use the result to find the best trade-off between extraction time (time and energy are expensive) and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to use computational models of particles interacting according to a Lennard-Jones potential to extract thermodynamic data about the system and ultimately calculate the diffusion coefficient. The experiment uses boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied to simulate a much larger &#039;effective system&#039;. The velocity-Verlet&lt;br /&gt;
algorithm&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; is used, which iterates the velocity and displacement for every particle in the system, from&lt;br /&gt;
an initial state, through the desired number of steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted, for e.g. Temperature can be obtained using the average kinetic energies in conjunction with the equipartition theorem.&lt;br /&gt;
&lt;br /&gt;
Reduced units throughout the experiment to make the magnitudes of the quantities used more managable.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq1.png|188x188px]]&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;r = inter-particle distance, σ = inter-particle distance when the potential = 0, E = potential, ε = depth of the potential well, T = temperature and k = the Boltzmann constant. Starred quantities represent the non-reduced&lt;br /&gt;
versions. Note the unites cancel out when forming these quantities and hence they are unitless.&lt;br /&gt;
&lt;br /&gt;
By cancelling through these reduced units, we obtain that time is also in reduced units and can be converted via:&lt;br /&gt;
[[File:Smliq12.png]]&lt;br /&gt;
This is used for calculating the diffusion coefficient, though may be used to obtain the true timescale for any of the simulations.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
The open source software, LAMMPS, was used to run the molecular dynamics simulations. The experiment was run as 5 separate parts:&lt;br /&gt;
# The effect of the time step on the simulation was probed using a box of 1000 atoms, equally spaced with a number density of 0.8 atoms per unit volume. The ensemble was treated as microcanonical. The following time steps were trialed: 0.0150, 0.0100, 0.0075, 0.0025, 0.0010. Energy, temperature and pressure for the system were collected at each iteration. A timestep of 0.0025 was used for the two subsequent simulations - see results and discussion for justification.&lt;br /&gt;
# A set of simulations were run in the isobaric-isothermal (NpT) ensemble. At P = 2.5 &amp;amp; P = 3.0, the simulation was run over the following temperatures: T = 1.5, 2.0, 2.5, 3.5, 5. Density of the systems was extracted as an average after the simulation, and plotted against temperature to test the agreement with the ideal gas law.&lt;br /&gt;
# An experiment was run in the NVT ensemble at densities 0.2 &amp;amp; 0.8, over the temperatures T = 2.0, 2.2, 2.4, 2.6, 2.8. The average heat capacity and temperature were collected for each system.&lt;br /&gt;
# Simulations were performed for a solid, a liquid and a gas system. A timestep of 0.0020 was used. Parameters for this were selected based on a previous probe into the phase transitions of the Lennard-Jones system&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;; solid (density = 1.2, T = 0.5), liquid (density = 0.8, T = 1.2), gas (density = 0.2, T = 1.2). The output trajectories were used to calculate the RDF (radial distribution function), i.e. the radial frequency of meeting another particle averaged over all spherical angles.&lt;br /&gt;
# Simulations were again performed for a solid, a liquid and a gas phase system. A timestep of 0.0020 was used for this experiment, and the same density/temperature parameters at experiment 4. The MSD (mean squared displacement) was collected as a function of timestep.&lt;br /&gt;
&lt;br /&gt;
== Results &amp;amp; Discussion ==&lt;br /&gt;
&lt;br /&gt;
=== Experiment 1 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq2.png|404x404px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq3.png|406x406px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq4.png|468x468px]]&lt;br /&gt;
&lt;br /&gt;
These plots show how the thermodynamic state variables of the system vary with time. For all of the variables , we see a very quick convergence from the initial value to the steady state value. A closer inspection of these graphs reveal&lt;br /&gt;
equilibration happens after roughly 0.5 reduced time units. This shows how the system which is initially ordered quickly descends into chaos. After this point, the state variables proceed to oscillate randomly as a noise function. This occurs due to fluctuations in the system which is constantly moving. If the system had more particles, the average would be less noisy because there are more opportunities for the random imbalances to cancel each other out.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq5.png|514x514px]]&lt;br /&gt;
&lt;br /&gt;
The above plot shows how the energy varies with timestep. As the time step is increased the average energy&lt;br /&gt;
increases due to the resolution of the numerical solution decreasing. The largest timestep shows a clear divergence. Presumably the timestep is so large that particles are getting unrealistically close to each other. The reaction in the next timestep cascades such that the problem is transferred to neighbouring particles. At this point the simulation breaks down as the energies and particle positions become increasingly unrealistic. 0.0025 was the largest timestep which showed no sign of this increased energy or divergence, and hence the timestep used for all subsequent experiments was smaller than this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 2 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq6.png|501x501px]]&lt;br /&gt;
&lt;br /&gt;
The density decreases with temperature as expected; the&lt;br /&gt;
atoms have more kinetic energy, so push each other apart further during their&lt;br /&gt;
random motion. The higher pressure plots show a consistently higher density.&lt;br /&gt;
This is intuitive as at higher pressures, the atoms are squashed closer&lt;br /&gt;
together on average.  &lt;br /&gt;
&lt;br /&gt;
At lower temperatures, the ideal gas law result diverges&lt;br /&gt;
from the simulation. This is because the ideal gas law assumes no collisions.&lt;br /&gt;
At lower temperatures, particles of an ideal gas continue to be compressed into&lt;br /&gt;
a smaller space due to their diminishing kinetic energy, such that they are in&lt;br /&gt;
fact overlapping. In the simulation the particles collide, meaning a much&lt;br /&gt;
greater kinetic energy (temperature) reduction is required to achieve the same&lt;br /&gt;
increase in density. Also note that the ideal gas law allows for infinity as the&lt;br /&gt;
limiting density, whereas this becomes infinitely unlikely when using Van Der&lt;br /&gt;
Waals potential between the atoms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 3 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq7.png|486x486px]]&lt;br /&gt;
&lt;br /&gt;
The heat capacity is smaller for lower densities&lt;br /&gt;
as expected: there are less atoms to sink energy into, so the average kinetic energy&lt;br /&gt;
increases more quickly. The heat capacity decreases with temperature because at higher temperatures, the energy states are closer together, meaning it is easier to populate new states (higher density of states). This clearly outweighs any increased degeneracy in states, otherwise we would see the heat capacity increase with temperature as is often the case. The plateau could indicate a first order phase transition where the heat capacity tends to infinity. This would be made more clear with a higher resolution of data points. The radial distribution function could be calculated either side as the less ordered phase would have a smoother curve.    &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 4 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq8.png|478x478px]]&lt;br /&gt;
&lt;br /&gt;
The radial distribution function (RDF) represents the density of particles around a single particle in the system on average as a function of radius, averaged over all possible angles in a sphere. The RDFs for the different phases are distinct. In the solid case, we se sharp peaks corresponding to when we hit a site in the crystalline lattice. In the liquid, the peaks are much less sharp, as there are many more positions the molecules can occupy easily relative to one another. Peaks are still defined as the distance between particles is roughly constant. A gas behaves like a liquid with very little order. It is less peaks if any (occur at higher densities) are much less well defined. There is still a sharp peak close to the particle as neighbouring particles spend the most time when changing direction during a collision as this is when velocity is the smallest. All three phases exhibit a cut-off displacement due to the steep positive region in the Lennard-Jones potential.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq9.png|533x533px]]&lt;br /&gt;
&lt;br /&gt;
When the RDF is viewed cumulatively, we see the steepest cumulation for the solid, followed by the liquid then gas. This is due to meeting particles more frequently when in the more dense phase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 5 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq10.png|687x687px]]&lt;br /&gt;
&lt;br /&gt;
The mean squared displacement plot used the same colours as before to represent a solid, liquid and gas. Initially the MSD is slow to rise, in particular for the gas. This is due to the particles taking some time to disperse properly and reach equilibrium velocity. The gas has the most freedom and kinetic energy so the MSD is the greatest. The opposite is true for the solid. The liquid is closer to the solid in terms of MSD because it is still relatively ordered, and there is some kind of activation barrier to molecules swapping between cages. The gradient for a solid is effectively zero as swapping positions in a crystalline lattice is extremely rare.&lt;br /&gt;
&lt;br /&gt;
The second plot shows a method of least squared fit, taking into account points after timestep = 1000 only, to avoid data from the equilibration period being considered. The gradients were as following:&lt;br /&gt;
&lt;br /&gt;
Solid: 2.94 x10&amp;lt;sup&amp;gt;-8&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Liquid: 1.02 x10&amp;lt;sup&amp;gt;-3&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gas: 1.00 x10&amp;lt;sup&amp;gt;-2&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The MSD is related to the diffusion coefficient by a simple relationship:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq11.png]]&lt;br /&gt;
&lt;br /&gt;
Now it has been show we can model&lt;br /&gt;
the diffusion coefficient, similar simulations could be applied to real world&lt;br /&gt;
applications. For e.g. in the basil leaf example, we could model the leaf&lt;br /&gt;
structure with different densities, and see how the diffusion of basil&lt;br /&gt;
essential oil molecules changes as a vapour shell forms and molecules in the&lt;br /&gt;
leaf are depleted.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# J. Silveira, A. Costa and E. Costa Junior, &#039;&#039;Engenharia Agrícola&#039;&#039;, 2017, 37, 717-726.&lt;br /&gt;
# L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1967, 159, 98-103.&lt;br /&gt;
# J. Hansen and L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1969, 184, 151-161.&lt;br /&gt;
&lt;br /&gt;
Weblinks:&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;http://www.scielo.br/scielo.php?script=sci_arttext&amp;amp;pid=S0100-69162017000400717#B21&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.159.98&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
LAMMPS script for heat capacity experiments&lt;br /&gt;
&lt;br /&gt;
Heat capacity LAMMPS input:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE SIMULATION BOX GEOMETRY ###&lt;br /&gt;
&lt;br /&gt;
variable dens equal 0.2&lt;br /&gt;
&lt;br /&gt;
lattice sc ${dens}&lt;br /&gt;
&lt;br /&gt;
region box block 0 15 0 15 0 15&lt;br /&gt;
&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&lt;br /&gt;
create_atoms 1 box&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE PHYSICAL PROPERTIES OF ATOMS ###&lt;br /&gt;
&lt;br /&gt;
mass 1 1.0&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut/opt 3.0&lt;br /&gt;
&lt;br /&gt;
pair_coeff 1 1 1.0 1.0&lt;br /&gt;
&lt;br /&gt;
neighbor 2.0 bin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&lt;br /&gt;
&lt;br /&gt;
variable T equal 2.0&lt;br /&gt;
&lt;br /&gt;
variable timestep equal 0.0075&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; ASSIGN ATOMIC VELOCITIES ###&lt;br /&gt;
&lt;br /&gt;
velocity all create ${T} 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY ENSEMBLE ###&lt;br /&gt;
&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; THERMODYNAMIC OUTPUT CONTROL ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
&lt;br /&gt;
thermo 10&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RECORD TRAJECTORY ###&lt;br /&gt;
&lt;br /&gt;
dump traj all custom 1000 output-1 id x y z&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY TIMESTEP ###&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RUN SIMULATION TO MELT CRYSTAL ###&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
unfix nve&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; BRING SYSTEM TO REQUIRED STATE ###&lt;br /&gt;
&lt;br /&gt;
variable tdamp equal ${timestep}*100&lt;br /&gt;
&lt;br /&gt;
fix nvt all nvt temp ${T} ${T} ${tdamp}&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
unfix nvt&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; MEASURE SYSTEM STATE ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom etotal temp atoms vol&lt;br /&gt;
&lt;br /&gt;
variable vol equal vol&lt;br /&gt;
&lt;br /&gt;
variable atoms equal atoms&lt;br /&gt;
&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
&lt;br /&gt;
variable N2 equal atoms*atoms&lt;br /&gt;
&lt;br /&gt;
variable E2 equal etotal*etotal&lt;br /&gt;
&lt;br /&gt;
variable E equal etotal&lt;br /&gt;
&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_temp2 v_E v_E2&lt;br /&gt;
&lt;br /&gt;
run 100000&lt;br /&gt;
&lt;br /&gt;
variable heatcapac equal&lt;br /&gt;
${N2}*(f_aves[3]-(f_aves[2]*f_aves[2]))/(f_aves[1])&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Averages&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;--------&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Heat Capacity: ${heatcapac}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Volume: ${vol}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;No of atoms: ${atoms}&amp;quot;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659440</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659440"/>
		<updated>2018-01-31T09:06:31Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Liquid Simulations Computational Lab Assignment - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All un-equilibrated fluid systems will move via diffusion toward thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
One study on the extraction of basil essential oil from the&lt;br /&gt;
&amp;lt;em&amp;gt;Ocimum basilicum&amp;lt;/em&amp;gt; leaf exemplifies this&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;. The diffusion coefficient was&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, while the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates, due to different tissue structures inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. This knowledge allows manufacturers to fit the model&lt;br /&gt;
mathematically using parameters specific to their distillation setup, and use the result to find the best trade-off between extraction time (time and energy are expensive) and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to use computational models of particles interacting according to a Lennard-Jones potential to extract thermodynamic data about the system and ultimately calculate the diffusion coefficient. The experiment uses boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied to simulate a much larger &#039;effective system&#039;. The velocity-Verlet&lt;br /&gt;
algorithm&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; is used, which iterates the velocity and displacement for every particle in the system, from&lt;br /&gt;
an initial state, through the desired number of steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted, for e.g. Temperature can be obtained using the average kinetic energies in conjunction with the equipartition theorem.&lt;br /&gt;
&lt;br /&gt;
Reduced units throughout the experiment to make the magnitudes of the quantities used more managable.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq1.png|188x188px]]&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;r = inter-particle distance, σ = inter-particle distance when the potential = 0, E = potential, ε = depth of the potential well, T = temperature and k = the Boltzmann constant. Starred quantities represent the non-reduced&lt;br /&gt;
versions. Note the unites cancel out when forming these quantities and hence they are unitless.&lt;br /&gt;
&lt;br /&gt;
By cancelling through these reduced units, we obtain that time is also in reduced units and can be converted via:&lt;br /&gt;
&lt;br /&gt;
This is used for calculating the diffusion coefficient, though may be used to obtain the true timescale for any of the simulations.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
The open source software, LAMMPS, was used to run the molecular dynamics simulations. The experiment was run as 5 separate parts:&lt;br /&gt;
# The effect of the time step on the simulation was probed using a box of 1000 atoms, equally spaced with a number density of 0.8 atoms per unit volume. The ensemble was treated as microcanonical. The following time steps were trialed: 0.0150, 0.0100, 0.0075, 0.0025, 0.0010. Energy, temperature and pressure for the system were collected at each iteration. A timestep of 0.0025 was used for the two subsequent simulations - see results and discussion for justification.&lt;br /&gt;
# A set of simulations were run in the isobaric-isothermal (NpT) ensemble. At P = 2.5 &amp;amp; P = 3.0, the simulation was run over the following temperatures: T = 1.5, 2.0, 2.5, 3.5, 5. Density of the systems was extracted as an average after the simulation, and plotted against temperature to test the agreement with the ideal gas law.&lt;br /&gt;
# An experiment was run in the NVT ensemble at densities 0.2 &amp;amp; 0.8, over the temperatures T = 2.0, 2.2, 2.4, 2.6, 2.8. The average heat capacity and temperature were collected for each system.&lt;br /&gt;
# Simulations were performed for a solid, a liquid and a gas system. A timestep of 0.0020 was used. Parameters for this were selected based on a previous probe into the phase transitions of the Lennard-Jones system&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;; solid (density = 1.2, T = 0.5), liquid (density = 0.8, T = 1.2), gas (density = 0.2, T = 1.2). The output trajectories were used to calculate the RDF (radial distribution function), i.e. the radial frequency of meeting another particle averaged over all spherical angles.&lt;br /&gt;
# Simulations were again performed for a solid, a liquid and a gas phase system. A timestep of 0.0020 was used for this experiment, and the same density/temperature parameters at experiment 4. The MSD (mean squared displacement) was collected as a function of timestep.&lt;br /&gt;
&lt;br /&gt;
== Results &amp;amp; Discussion ==&lt;br /&gt;
&lt;br /&gt;
=== Experiment 1 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq2.png|404x404px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq3.png|406x406px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq4.png|468x468px]]&lt;br /&gt;
&lt;br /&gt;
These plots show how the thermodynamic state variables of the system vary with time. For all of the variables , we see a very quick convergence from the initial value to the steady state value. A closer inspection of these graphs reveal&lt;br /&gt;
equilibration happens after roughly 0.5 reduced time units. This shows how the system which is initially ordered quickly descends into chaos. After this point, the state variables proceed to oscillate randomly as a noise function. This occurs due to fluctuations in the system which is constantly moving. If the system had more particles, the average would be less noisy because there are more opportunities for the random imbalances to cancel each other out.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq5.png|514x514px]]&lt;br /&gt;
&lt;br /&gt;
The above plot shows how the energy varies with timestep. As the time step is increased the average energy&lt;br /&gt;
increases due to the resolution of the numerical solution decreasing. The largest timestep shows a clear divergence. Presumably the timestep is so large that particles are getting unrealistically close to each other. The reaction in the next timestep cascades such that the problem is transferred to neighbouring particles. At this point the simulation breaks down as the energies and particle positions become increasingly unrealistic. 0.0025 was the largest timestep which showed no sign of this increased energy or divergence, and hence the timestep used for all subsequent experiments was smaller than this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 2 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq6.png|501x501px]]&lt;br /&gt;
&lt;br /&gt;
The density decreases with temperature as expected; the&lt;br /&gt;
atoms have more kinetic energy, so push each other apart further during their&lt;br /&gt;
random motion. The higher pressure plots show a consistently higher density.&lt;br /&gt;
This is intuitive as at higher pressures, the atoms are squashed closer&lt;br /&gt;
together on average.  &lt;br /&gt;
&lt;br /&gt;
At lower temperatures, the ideal gas law result diverges&lt;br /&gt;
from the simulation. This is because the ideal gas law assumes no collisions.&lt;br /&gt;
At lower temperatures, particles of an ideal gas continue to be compressed into&lt;br /&gt;
a smaller space due to their diminishing kinetic energy, such that they are in&lt;br /&gt;
fact overlapping. In the simulation the particles collide, meaning a much&lt;br /&gt;
greater kinetic energy (temperature) reduction is required to achieve the same&lt;br /&gt;
increase in density. Also note that the ideal gas law allows for infinity as the&lt;br /&gt;
limiting density, whereas this becomes infinitely unlikely when using Van Der&lt;br /&gt;
Waals potential between the atoms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 3 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq7.png|486x486px]]&lt;br /&gt;
&lt;br /&gt;
The heat capacity is smaller for lower densities&lt;br /&gt;
as expected: there are less atoms to sink energy into, so the average kinetic energy&lt;br /&gt;
increases more quickly. The heat capacity decreases with temperature because at higher temperatures, the energy states are closer together, meaning it is easier to populate new states (higher density of states). This clearly outweighs any increased degeneracy in states, otherwise we would see the heat capacity increase with temperature as is often the case. The plateau could indicate a first order phase transition where the heat capacity tends to infinity. This would be made more clear with a higher resolution of data points. The radial distribution function could be calculated either side as the less ordered phase would have a smoother curve.    &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 4 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq8.png|478x478px]]&lt;br /&gt;
&lt;br /&gt;
The radial distribution function (RDF) represents the density of particles around a single particle in the system on average as a function of radius, averaged over all possible angles in a sphere. The RDFs for the different phases are distinct. In the solid case, we se sharp peaks corresponding to when we hit a site in the crystalline lattice. In the liquid, the peaks are much less sharp, as there are many more positions the molecules can occupy easily relative to one another. Peaks are still defined as the distance between particles is roughly constant. A gas behaves like a liquid with very little order. It is less peaks if any (occur at higher densities) are much less well defined. There is still a sharp peak close to the particle as neighbouring particles spend the most time when changing direction during a collision as this is when velocity is the smallest. All three phases exhibit a cut-off displacement due to the steep positive region in the Lennard-Jones potential.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq9.png|533x533px]]&lt;br /&gt;
&lt;br /&gt;
When the RDF is viewed cumulatively, we see the steepest cumulation for the solid, followed by the liquid then gas. This is due to meeting particles more frequently when in the more dense phase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 5 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq10.png|687x687px]]&lt;br /&gt;
&lt;br /&gt;
The mean squared displacement plot used the same colours as before to represent a solid, liquid and gas. Initially the MSD is slow to rise, in particular for the gas. This is due to the particles taking some time to disperse properly and reach equilibrium velocity. The gas has the most freedom and kinetic energy so the MSD is the greatest. The opposite is true for the solid. The liquid is closer to the solid in terms of MSD because it is still relatively ordered, and there is some kind of activation barrier to molecules swapping between cages. The gradient for a solid is effectively zero as swapping positions in a crystalline lattice is extremely rare.&lt;br /&gt;
&lt;br /&gt;
The second plot shows a method of least squared fit, taking into account points after timestep = 1000 only, to avoid data from the equilibration period being considered. The gradients were as following:&lt;br /&gt;
&lt;br /&gt;
Solid: 2.94 x10&amp;lt;sup&amp;gt;-8&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Liquid: 1.02 x10&amp;lt;sup&amp;gt;-3&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gas: 1.00 x10&amp;lt;sup&amp;gt;-2&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The MSD is related to the diffusion coefficient by a simple relationship:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq11.png]]&lt;br /&gt;
&lt;br /&gt;
Now it has been show we can model&lt;br /&gt;
the diffusion coefficient, similar simulations could be applied to real world&lt;br /&gt;
applications. For e.g. in the basil leaf example, we could model the leaf&lt;br /&gt;
structure with different densities, and see how the diffusion of basil&lt;br /&gt;
essential oil molecules changes as a vapour shell forms and molecules in the&lt;br /&gt;
leaf are depleted.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# J. Silveira, A. Costa and E. Costa Junior, &#039;&#039;Engenharia Agrícola&#039;&#039;, 2017, 37, 717-726.&lt;br /&gt;
# L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1967, 159, 98-103.&lt;br /&gt;
# J. Hansen and L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1969, 184, 151-161.&lt;br /&gt;
&lt;br /&gt;
Weblinks:&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;http://www.scielo.br/scielo.php?script=sci_arttext&amp;amp;pid=S0100-69162017000400717#B21&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.159.98&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
LAMMPS script for heat capacity experiments&lt;br /&gt;
&lt;br /&gt;
Heat capacity LAMMPS input:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE SIMULATION BOX GEOMETRY ###&lt;br /&gt;
&lt;br /&gt;
variable dens equal 0.2&lt;br /&gt;
&lt;br /&gt;
lattice sc ${dens}&lt;br /&gt;
&lt;br /&gt;
region box block 0 15 0 15 0 15&lt;br /&gt;
&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&lt;br /&gt;
create_atoms 1 box&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE PHYSICAL PROPERTIES OF ATOMS ###&lt;br /&gt;
&lt;br /&gt;
mass 1 1.0&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut/opt 3.0&lt;br /&gt;
&lt;br /&gt;
pair_coeff 1 1 1.0 1.0&lt;br /&gt;
&lt;br /&gt;
neighbor 2.0 bin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&lt;br /&gt;
&lt;br /&gt;
variable T equal 2.0&lt;br /&gt;
&lt;br /&gt;
variable timestep equal 0.0075&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; ASSIGN ATOMIC VELOCITIES ###&lt;br /&gt;
&lt;br /&gt;
velocity all create ${T} 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY ENSEMBLE ###&lt;br /&gt;
&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; THERMODYNAMIC OUTPUT CONTROL ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
&lt;br /&gt;
thermo 10&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RECORD TRAJECTORY ###&lt;br /&gt;
&lt;br /&gt;
dump traj all custom 1000 output-1 id x y z&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY TIMESTEP ###&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RUN SIMULATION TO MELT CRYSTAL ###&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
unfix nve&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; BRING SYSTEM TO REQUIRED STATE ###&lt;br /&gt;
&lt;br /&gt;
variable tdamp equal ${timestep}*100&lt;br /&gt;
&lt;br /&gt;
fix nvt all nvt temp ${T} ${T} ${tdamp}&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
unfix nvt&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; MEASURE SYSTEM STATE ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom etotal temp atoms vol&lt;br /&gt;
&lt;br /&gt;
variable vol equal vol&lt;br /&gt;
&lt;br /&gt;
variable atoms equal atoms&lt;br /&gt;
&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
&lt;br /&gt;
variable N2 equal atoms*atoms&lt;br /&gt;
&lt;br /&gt;
variable E2 equal etotal*etotal&lt;br /&gt;
&lt;br /&gt;
variable E equal etotal&lt;br /&gt;
&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_temp2 v_E v_E2&lt;br /&gt;
&lt;br /&gt;
run 100000&lt;br /&gt;
&lt;br /&gt;
variable heatcapac equal&lt;br /&gt;
${N2}*(f_aves[3]-(f_aves[2]*f_aves[2]))/(f_aves[1])&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Averages&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;--------&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Heat Capacity: ${heatcapac}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Volume: ${vol}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;No of atoms: ${atoms}&amp;quot;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq12.png&amp;diff=659439</id>
		<title>File:Smliq12.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq12.png&amp;diff=659439"/>
		<updated>2018-01-31T09:04:03Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659430</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659430"/>
		<updated>2018-01-31T08:53:15Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Liquid Simulations Computational Lab Assignment - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
Time units converstion&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All un-equilibrated fluid systems will move via diffusion toward thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
One study on the extraction of basil essential oil from the&lt;br /&gt;
&amp;lt;em&amp;gt;Ocimum basilicum&amp;lt;/em&amp;gt; leaf exemplifies this&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;. The diffusion coefficient was&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, while the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates, due to different tissue structures inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. This knowledge allows manufacturers to fit the model&lt;br /&gt;
mathematically using parameters specific to their distillation setup, and use the result to find the best trade-off between extraction time (time and energy are expensive) and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to use computational models of particles interacting according to a Lennard-Jones potential to extract thermodynamic data about the system and ultimately calculate the diffusion coefficient. The experiment uses boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied to simulate a much larger &#039;effective system&#039;. The velocity-Verlet&lt;br /&gt;
algorithm&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; is used, which iterates the velocity and displacement for every particle in the system, from&lt;br /&gt;
an initial state, through the desired number of steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted, for e.g. Temperature can be obtained using the average kinetic energies in conjunction with the equipartition theorem.&lt;br /&gt;
&lt;br /&gt;
Reduced units throughout the experiment to make the magnitudes of the quantities used more managable.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq1.png|188x188px]]&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;r = inter-particle distance, σ = inter-particle distance when the potential = 0, E = potential, ε = depth of the potential well, T = temperature and k = the Boltzmann constant. Starred quantities represent the non-reduced&lt;br /&gt;
versions. Note the unites cancel out when forming these quantities and hence they are unitless.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
The open source software, LAMMPS, was used to run the molecular dynamics simulations. The experiment was run as 5 separate parts:&lt;br /&gt;
# The effect of the time step on the simulation was probed using a box of 1000 atoms, equally spaced with a number density of 0.8 atoms per unit volume. The ensemble was treated as microcanonical. The following time steps were trialed: 0.0150, 0.0100, 0.0075, 0.0025, 0.0010. Energy, temperature and pressure for the system were collected at each iteration. A timestep of 0.0025 was used for the two subsequent simulations - see results and discussion for justification.&lt;br /&gt;
# A set of simulations were run in the isobaric-isothermal (NpT) ensemble. At P = 2.5 &amp;amp; P = 3.0, the simulation was run over the following temperatures: T = 1.5, 2.0, 2.5, 3.5, 5. Density of the systems was extracted as an average after the simulation, and plotted against temperature to test the agreement with the ideal gas law.&lt;br /&gt;
# An experiment was run in the NVT ensemble at densities 0.2 &amp;amp; 0.8, over the temperatures T = 2.0, 2.2, 2.4, 2.6, 2.8. The average heat capacity and temperature were collected for each system.&lt;br /&gt;
# Simulations were performed for a solid, a liquid and a gas system. A timestep of 0.0020 was used. Parameters for this were selected based on a previous probe into the phase transitions of the Lennard-Jones system&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;; solid (density = 1.2, T = 0.5), liquid (density = 0.8, T = 1.2), gas (density = 0.2, T = 1.2). The output trajectories were used to calculate the RDF (radial distribution function), i.e. the radial frequency of meeting another particle averaged over all spherical angles.&lt;br /&gt;
# Simulations were again performed for a solid, a liquid and a gas phase system. A timestep of 0.0020 was used for this experiment, and the same density/temperature parameters at experiment 4. The MSD (mean squared displacement) was collected as a function of timestep.&lt;br /&gt;
&lt;br /&gt;
== Results &amp;amp; Discussion ==&lt;br /&gt;
&lt;br /&gt;
=== Experiment 1 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq2.png|404x404px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq3.png|406x406px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq4.png|468x468px]]&lt;br /&gt;
&lt;br /&gt;
These plots show how the thermodynamic state variables of the system vary with time. For all of the variables , we see a very quick convergence from the initial value to the steady state value. A closer inspection of these graphs reveal&lt;br /&gt;
equilibration happens after roughly 0.5 reduced time units. This shows how the system which is initially ordered quickly descends into chaos. After this point, the state variables proceed to oscillate randomly as a noise function. This occurs due to fluctuations in the system which is constantly moving. If the system had more particles, the average would be less noisy because there are more opportunities for the random imbalances to cancel each other out.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq5.png|514x514px]]&lt;br /&gt;
&lt;br /&gt;
The above plot shows how the energy varies with timestep. As the time step is increased the average energy&lt;br /&gt;
increases due to the resolution of the numerical solution decreasing. The largest timestep shows a clear divergence. Presumably the timestep is so large that particles are getting unrealistically close to each other. The reaction in the next timestep cascades such that the problem is transferred to neighbouring particles. At this point the simulation breaks down as the energies and particle positions become increasingly unrealistic. 0.0025 was the largest timestep which showed no sign of this increased energy or divergence, and hence the timestep used for all subsequent experiments was smaller than this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 2 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq6.png|501x501px]]&lt;br /&gt;
&lt;br /&gt;
The density decreases with temperature as expected; the&lt;br /&gt;
atoms have more kinetic energy, so push each other apart further during their&lt;br /&gt;
random motion. The higher pressure plots show a consistently higher density.&lt;br /&gt;
This is intuitive as at higher pressures, the atoms are squashed closer&lt;br /&gt;
together on average.  &lt;br /&gt;
&lt;br /&gt;
At lower temperatures, the ideal gas law result diverges&lt;br /&gt;
from the simulation. This is because the ideal gas law assumes no collisions.&lt;br /&gt;
At lower temperatures, particles of an ideal gas continue to be compressed into&lt;br /&gt;
a smaller space due to their diminishing kinetic energy, such that they are in&lt;br /&gt;
fact overlapping. In the simulation the particles collide, meaning a much&lt;br /&gt;
greater kinetic energy (temperature) reduction is required to achieve the same&lt;br /&gt;
increase in density. Also note that the ideal gas law allows for infinity as the&lt;br /&gt;
limiting density, whereas this becomes infinitely unlikely when using Van Der&lt;br /&gt;
Waals potential between the atoms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 3 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq7.png|486x486px]]&lt;br /&gt;
&lt;br /&gt;
The heat capacity is smaller for lower densities&lt;br /&gt;
as expected: there are less atoms to sink energy into, so the average kinetic energy&lt;br /&gt;
increases more quickly. The heat capacity decreases with temperature because at higher temperatures, the energy states are closer together, meaning it is easier to populate new states (higher density of states). This clearly outweighs any increased degeneracy in states, otherwise we would see the heat capacity increase with temperature as is often the case. The plateau could indicate a first order phase transition where the heat capacity tends to infinity. This would be made more clear with a higher resolution of data points. The radial distribution function could be calculated either side as the less ordered phase would have a smoother curve.    &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 4 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq8.png|478x478px]]&lt;br /&gt;
&lt;br /&gt;
The radial distribution function (RDF) represents the density of particles around a single particle in the system on average as a function of radius, averaged over all possible angles in a sphere. The RDFs for the different phases are distinct. In the solid case, we se sharp peaks corresponding to when we hit a site in the crystalline lattice. In the liquid, the peaks are much less sharp, as there are many more positions the molecules can occupy easily relative to one another. Peaks are still defined as the distance between particles is roughly constant. A gas behaves like a liquid with very little order. It is less peaks if any (occur at higher densities) are much less well defined. There is still a sharp peak close to the particle as neighbouring particles spend the most time when changing direction during a collision as this is when velocity is the smallest. All three phases exhibit a cut-off displacement due to the steep positive region in the Lennard-Jones potential.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq9.png|533x533px]]&lt;br /&gt;
&lt;br /&gt;
When the RDF is viewed cumulatively, we see the steepest cumulation for the solid, followed by the liquid then gas. This is due to meeting particles more frequently when in the more dense phase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 5 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq10.png|687x687px]]&lt;br /&gt;
&lt;br /&gt;
The mean squared displacement plot used the same colours as before to represent a solid, liquid and gas. Initially the MSD is slow to rise, in particular for the gas. This is due to the particles taking some time to disperse properly and reach equilibrium velocity. The gas has the most freedom and kinetic energy so the MSD is the greatest. The opposite is true for the solid. The liquid is closer to the solid in terms of MSD because it is still relatively ordered, and there is some kind of activation barrier to molecules swapping between cages. The gradient for a solid is effectively zero as swapping positions in a crystalline lattice is extremely rare.&lt;br /&gt;
&lt;br /&gt;
The second plot shows a method of least squared fit, taking into account points after timestep = 1000 only, to avoid data from the equilibration period being considered. The gradients were as following:&lt;br /&gt;
&lt;br /&gt;
Solid: 2.94 x10&amp;lt;sup&amp;gt;-8&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Liquid: 1.02 x10&amp;lt;sup&amp;gt;-3&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gas: 1.00 x10&amp;lt;sup&amp;gt;-2&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2.94294621678e-08&lt;br /&gt;
0.00102392434763 0.010088346616 for solid, liquid and gas respectively. D is&lt;br /&gt;
simply a sixth of this multiplied by the unit conversion factor.&lt;br /&gt;
[[File:Smliq11.png]]&lt;br /&gt;
&lt;br /&gt;
Now it has been show we can model&lt;br /&gt;
the diffusion coefficient, similar simulations could be applied to real world&lt;br /&gt;
applications. For e.g. in the basil leaf example, we could model the leaf&lt;br /&gt;
structure with different densities, and see how the diffusion of basil&lt;br /&gt;
essential oil molecules changes as a vapour shell forms and molecules in the&lt;br /&gt;
leaf are depleted.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# J. Silveira, A. Costa and E. Costa Junior, &#039;&#039;Engenharia Agrícola&#039;&#039;, 2017, 37, 717-726.&lt;br /&gt;
# L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1967, 159, 98-103.&lt;br /&gt;
# J. Hansen and L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1969, 184, 151-161.&lt;br /&gt;
&lt;br /&gt;
Weblinks:&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;http://www.scielo.br/scielo.php?script=sci_arttext&amp;amp;pid=S0100-69162017000400717#B21&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.159.98&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
LAMMPS script for heat capacity experiments&lt;br /&gt;
&lt;br /&gt;
Heat capacity LAMMPS input:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE SIMULATION BOX GEOMETRY ###&lt;br /&gt;
&lt;br /&gt;
variable dens equal 0.2&lt;br /&gt;
&lt;br /&gt;
lattice sc ${dens}&lt;br /&gt;
&lt;br /&gt;
region box block 0 15 0 15 0 15&lt;br /&gt;
&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&lt;br /&gt;
create_atoms 1 box&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE PHYSICAL PROPERTIES OF ATOMS ###&lt;br /&gt;
&lt;br /&gt;
mass 1 1.0&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut/opt 3.0&lt;br /&gt;
&lt;br /&gt;
pair_coeff 1 1 1.0 1.0&lt;br /&gt;
&lt;br /&gt;
neighbor 2.0 bin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&lt;br /&gt;
&lt;br /&gt;
variable T equal 2.0&lt;br /&gt;
&lt;br /&gt;
variable timestep equal 0.0075&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; ASSIGN ATOMIC VELOCITIES ###&lt;br /&gt;
&lt;br /&gt;
velocity all create ${T} 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY ENSEMBLE ###&lt;br /&gt;
&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; THERMODYNAMIC OUTPUT CONTROL ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
&lt;br /&gt;
thermo 10&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RECORD TRAJECTORY ###&lt;br /&gt;
&lt;br /&gt;
dump traj all custom 1000 output-1 id x y z&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY TIMESTEP ###&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RUN SIMULATION TO MELT CRYSTAL ###&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
unfix nve&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; BRING SYSTEM TO REQUIRED STATE ###&lt;br /&gt;
&lt;br /&gt;
variable tdamp equal ${timestep}*100&lt;br /&gt;
&lt;br /&gt;
fix nvt all nvt temp ${T} ${T} ${tdamp}&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
unfix nvt&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; MEASURE SYSTEM STATE ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom etotal temp atoms vol&lt;br /&gt;
&lt;br /&gt;
variable vol equal vol&lt;br /&gt;
&lt;br /&gt;
variable atoms equal atoms&lt;br /&gt;
&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
&lt;br /&gt;
variable N2 equal atoms*atoms&lt;br /&gt;
&lt;br /&gt;
variable E2 equal etotal*etotal&lt;br /&gt;
&lt;br /&gt;
variable E equal etotal&lt;br /&gt;
&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_temp2 v_E v_E2&lt;br /&gt;
&lt;br /&gt;
run 100000&lt;br /&gt;
&lt;br /&gt;
variable heatcapac equal&lt;br /&gt;
${N2}*(f_aves[3]-(f_aves[2]*f_aves[2]))/(f_aves[1])&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Averages&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;--------&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Heat Capacity: ${heatcapac}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Volume: ${vol}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;No of atoms: ${atoms}&amp;quot;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659428</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659428"/>
		<updated>2018-01-31T08:52:30Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Liquid Simulations Computational Lab Assignment - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
Time units converstion&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All un-equilibrated fluid systems will move via diffusion toward thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
One study on the extraction of basil essential oil from the&lt;br /&gt;
&amp;lt;em&amp;gt;Ocimum basilicum&amp;lt;/em&amp;gt; leaf exemplifies this&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;. The diffusion coefficient was&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, while the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates, due to different tissue structures inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. This knowledge allows manufacturers to fit the model&lt;br /&gt;
mathematically using parameters specific to their distillation setup, and use the result to find the best trade-off between extraction time (time and energy are expensive) and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to use computational models of particles interacting according to a Lennard-Jones potential to extract thermodynamic data about the system and ultimately calculate the diffusion coefficient. The experiment uses boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied to simulate a much larger &#039;effective system&#039;. The velocity-Verlet&lt;br /&gt;
algorithm&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; is used, which iterates the velocity and displacement for every particle in the system, from&lt;br /&gt;
an initial state, through the desired number of steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted, for e.g. Temperature can be obtained using the average kinetic energies in conjunction with the equipartition theorem.&lt;br /&gt;
&lt;br /&gt;
Reduced units throughout the experiment to make the magnitudes of the quantities used more managable.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq1.png|188x188px]]&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;r = inter-particle distance, σ = inter-particle distance when the potential = 0, E = potential, ε = depth of the potential well, T = temperature and k = the Boltzmann constant. Starred quantities represent the non-reduced&lt;br /&gt;
versions. Note the unites cancel out when forming these quantities and hence they are unitless.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
The open source software, LAMMPS, was used to run the molecular dynamics simulations. The experiment was run as 5 separate parts:&lt;br /&gt;
# The effect of the time step on the simulation was probed using a box of 1000 atoms, equally spaced with a number density of 0.8 atoms per unit volume. The ensemble was treated as microcanonical. The following time steps were trialed: 0.0150, 0.0100, 0.0075, 0.0025, 0.0010. Energy, temperature and pressure for the system were collected at each iteration. A timestep of 0.0025 was used for the two subsequent simulations - see results and discussion for justification.&lt;br /&gt;
# A set of simulations were run in the isobaric-isothermal (NpT) ensemble. At P = 2.5 &amp;amp; P = 3.0, the simulation was run over the following temperatures: T = 1.5, 2.0, 2.5, 3.5, 5. Density of the systems was extracted as an average after the simulation, and plotted against temperature to test the agreement with the ideal gas law.&lt;br /&gt;
# An experiment was run in the NVT ensemble at densities 0.2 &amp;amp; 0.8, over the temperatures T = 2.0, 2.2, 2.4, 2.6, 2.8. The average heat capacity and temperature were collected for each system.&lt;br /&gt;
# Simulations were performed for a solid, a liquid and a gas system. A timestep of 0.0020 was used. Parameters for this were selected based on a previous probe into the phase transitions of the Lennard-Jones system&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;; solid (density = 1.2, T = 0.5), liquid (density = 0.8, T = 1.2), gas (density = 0.2, T = 1.2). The output trajectories were used to calculate the RDF (radial distribution function), i.e. the radial frequency of meeting another particle averaged over all spherical angles.&lt;br /&gt;
# Simulations were again performed for a solid, a liquid and a gas phase system. A timestep of 0.0020 was used for this experiment, and the same density/temperature parameters at experiment 4. The MSD (mean squared displacement) was collected as a function of timestep.&lt;br /&gt;
&lt;br /&gt;
== Results &amp;amp; Discussion ==&lt;br /&gt;
&lt;br /&gt;
=== Experiment 1 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq2.png|404x404px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq3.png|406x406px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq4.png|468x468px]]&lt;br /&gt;
&lt;br /&gt;
These plots show how the thermodynamic state variables of the system vary with time. For all of the variables , we see a very quick convergence from the initial value to the steady state value. A closer inspection of these graphs reveal&lt;br /&gt;
equilibration happens after roughly 0.5 reduced time units. This shows how the system which is initially ordered quickly descends into chaos. After this point, the state variables proceed to oscillate randomly as a noise function. This occurs due to fluctuations in the system which is constantly moving. If the system had more particles, the average would be less noisy because there are more opportunities for the random imbalances to cancel each other out.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq5.png|514x514px]]&lt;br /&gt;
&lt;br /&gt;
The above plot shows how the energy varies with timestep. As the time step is increased the average energy&lt;br /&gt;
increases due to the resolution of the numerical solution decreasing. The largest timestep shows a clear divergence. Presumably the timestep is so large that particles are getting unrealistically close to each other. The reaction in the next timestep cascades such that the problem is transferred to neighbouring particles. At this point the simulation breaks down as the energies and particle positions become increasingly unrealistic. 0.0025 was the largest timestep which showed no sign of this increased energy or divergence, and hence the timestep used for all subsequent experiments was smaller than this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 2 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq6.png|501x501px]]&lt;br /&gt;
&lt;br /&gt;
The density decreases with temperature as expected; the&lt;br /&gt;
atoms have more kinetic energy, so push each other apart further during their&lt;br /&gt;
random motion. The higher pressure plots show a consistently higher density.&lt;br /&gt;
This is intuitive as at higher pressures, the atoms are squashed closer&lt;br /&gt;
together on average.  &lt;br /&gt;
&lt;br /&gt;
At lower temperatures, the ideal gas law result diverges&lt;br /&gt;
from the simulation. This is because the ideal gas law assumes no collisions.&lt;br /&gt;
At lower temperatures, particles of an ideal gas continue to be compressed into&lt;br /&gt;
a smaller space due to their diminishing kinetic energy, such that they are in&lt;br /&gt;
fact overlapping. In the simulation the particles collide, meaning a much&lt;br /&gt;
greater kinetic energy (temperature) reduction is required to achieve the same&lt;br /&gt;
increase in density. Also note that the ideal gas law allows for infinity as the&lt;br /&gt;
limiting density, whereas this becomes infinitely unlikely when using Van Der&lt;br /&gt;
Waals potential between the atoms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 3 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq7.png|486x486px]]&lt;br /&gt;
&lt;br /&gt;
The heat capacity is smaller for lower densities&lt;br /&gt;
as expected: there are less atoms to sink energy into, so the average kinetic energy&lt;br /&gt;
increases more quickly. The heat capacity decreases with temperature because at higher temperatures, the energy states are closer together, meaning it is easier to populate new states (higher density of states). This clearly outweighs any increased degeneracy in states, otherwise we would see the heat capacity increase with temperature as is often the case. The plateau could indicate a first order phase transition where the heat capacity tends to infinity. This would be made more clear with a higher resolution of data points. The radial distribution function could be calculated either side as the less ordered phase would have a smoother curve.    &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 4 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq8.png|478x478px]]&lt;br /&gt;
&lt;br /&gt;
The radial distribution function (RDF) represents the density of particles around a single particle in the system on average as a function of radius, averaged over all possible angles in a sphere. The RDFs for the different phases are distinct. In the solid case, we se sharp peaks corresponding to when we hit a site in the crystalline lattice. In the liquid, the peaks are much less sharp, as there are many more positions the molecules can occupy easily relative to one another. Peaks are still defined as the distance between particles is roughly constant. A gas behaves like a liquid with very little order. It is less peaks if any (occur at higher densities) are much less well defined. There is still a sharp peak close to the particle as neighbouring particles spend the most time when changing direction during a collision as this is when velocity is the smallest. All three phases exhibit a cut-off displacement due to the steep positive region in the Lennard-Jones potential.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq9.png|533x533px]]&lt;br /&gt;
&lt;br /&gt;
When the RDF is viewed cumulatively, we see the steepest cumulation for the solid, followed by the liquid then gas. This is due to meeting particles more frequently when in the more dense phase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 5 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq10.png|687x687px]]&lt;br /&gt;
&lt;br /&gt;
The mean squared displacement plot used the same colours as before to represent a solid, liquid and gas. Initially the MSD is slow to rise, in particular for the gas. This is due to the particles taking some time to disperse properly and reach equilibrium velocity. The gas has the most freedom and kinetic energy so the MSD is the greatest. The opposite is true for the solid. The liquid is closer to the solid in terms of MSD because it is still relatively ordered, and there is some kind of activation barrier to molecules swapping between cages. The gradient for a solid is effectively zero as swapping positions in a crystalline lattice is extremely rare.&lt;br /&gt;
&lt;br /&gt;
The second plot shows a method of least squared fit, taking into account points after timestep = 1000 only, to avoid data from the equilibration period being considered. The gradients were as following:&lt;br /&gt;
&lt;br /&gt;
Solid: 2.94 x10&amp;lt;sup&amp;gt;-8&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Liquid: 1.02 x10&amp;lt;sup&amp;gt;-3&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gas: 1.00 x10&amp;lt;sup&amp;gt;-2&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2.94294621678e-08&lt;br /&gt;
0.00102392434763 0.010088346616 for solid, liquid and gas respectively. D is&lt;br /&gt;
simply a sixth of this multiplied by the unit conversion factor.&lt;br /&gt;
&lt;br /&gt;
Now it has been show we can model&lt;br /&gt;
the diffusion coefficient, similar simulations could be applied to real world&lt;br /&gt;
applications. For e.g. in the basil leaf example, we could model the leaf&lt;br /&gt;
structure with different densities, and see how the diffusion of basil&lt;br /&gt;
essential oil molecules changes as a vapour shell forms and molecules in the&lt;br /&gt;
leaf are depleted.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# J. Silveira, A. Costa and E. Costa Junior, &#039;&#039;Engenharia Agrícola&#039;&#039;, 2017, 37, 717-726.&lt;br /&gt;
# L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1967, 159, 98-103.&lt;br /&gt;
# J. Hansen and L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1969, 184, 151-161.&lt;br /&gt;
&lt;br /&gt;
Weblinks:&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;http://www.scielo.br/scielo.php?script=sci_arttext&amp;amp;pid=S0100-69162017000400717#B21&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.159.98&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
LAMMPS script for heat capacity experiments&lt;br /&gt;
&lt;br /&gt;
Heat capacity LAMMPS input:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE SIMULATION BOX GEOMETRY ###&lt;br /&gt;
&lt;br /&gt;
variable dens equal 0.2&lt;br /&gt;
&lt;br /&gt;
lattice sc ${dens}&lt;br /&gt;
&lt;br /&gt;
region box block 0 15 0 15 0 15&lt;br /&gt;
&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&lt;br /&gt;
create_atoms 1 box&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE PHYSICAL PROPERTIES OF ATOMS ###&lt;br /&gt;
&lt;br /&gt;
mass 1 1.0&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut/opt 3.0&lt;br /&gt;
&lt;br /&gt;
pair_coeff 1 1 1.0 1.0&lt;br /&gt;
&lt;br /&gt;
neighbor 2.0 bin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&lt;br /&gt;
&lt;br /&gt;
variable T equal 2.0&lt;br /&gt;
&lt;br /&gt;
variable timestep equal 0.0075&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; ASSIGN ATOMIC VELOCITIES ###&lt;br /&gt;
&lt;br /&gt;
velocity all create ${T} 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY ENSEMBLE ###&lt;br /&gt;
&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; THERMODYNAMIC OUTPUT CONTROL ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
&lt;br /&gt;
thermo 10&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RECORD TRAJECTORY ###&lt;br /&gt;
&lt;br /&gt;
dump traj all custom 1000 output-1 id x y z&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY TIMESTEP ###&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RUN SIMULATION TO MELT CRYSTAL ###&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
unfix nve&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; BRING SYSTEM TO REQUIRED STATE ###&lt;br /&gt;
&lt;br /&gt;
variable tdamp equal ${timestep}*100&lt;br /&gt;
&lt;br /&gt;
fix nvt all nvt temp ${T} ${T} ${tdamp}&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
unfix nvt&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; MEASURE SYSTEM STATE ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom etotal temp atoms vol&lt;br /&gt;
&lt;br /&gt;
variable vol equal vol&lt;br /&gt;
&lt;br /&gt;
variable atoms equal atoms&lt;br /&gt;
&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
&lt;br /&gt;
variable N2 equal atoms*atoms&lt;br /&gt;
&lt;br /&gt;
variable E2 equal etotal*etotal&lt;br /&gt;
&lt;br /&gt;
variable E equal etotal&lt;br /&gt;
&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_temp2 v_E v_E2&lt;br /&gt;
&lt;br /&gt;
run 100000&lt;br /&gt;
&lt;br /&gt;
variable heatcapac equal&lt;br /&gt;
${N2}*(f_aves[3]-(f_aves[2]*f_aves[2]))/(f_aves[1])&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Averages&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;--------&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Heat Capacity: ${heatcapac}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Volume: ${vol}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;No of atoms: ${atoms}&amp;quot;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq11.png&amp;diff=659427</id>
		<title>File:Smliq11.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq11.png&amp;diff=659427"/>
		<updated>2018-01-31T08:51:47Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659204</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659204"/>
		<updated>2018-01-30T23:38:41Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Liquid Simulations Computational Lab Assignment - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
Time units converstion&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All un-equilibrated fluid systems will move via diffusion toward thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
One study on the extraction of basil essential oil from the&lt;br /&gt;
&amp;lt;em&amp;gt;Ocimum basilicum&amp;lt;/em&amp;gt; leaf exemplifies this&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;. The diffusion coefficient was&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, while the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates, due to different tissue structures inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. This knowledge allows manufacturers to fit the model&lt;br /&gt;
mathematically using parameters specific to their distillation setup, and use the result to find the best trade-off between extraction time (time and energy are expensive) and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to use computational models of particles interacting according to a Lennard-Jones potential to extract thermodynamic data about the system and ultimately calculate the diffusion coefficient. The experiment uses boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied to simulate a much larger &#039;effective system&#039;. The velocity-Verlet&lt;br /&gt;
algorithm&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; is used, which iterates the velocity and displacement for every particle in the system, from&lt;br /&gt;
an initial state, through the desired number of steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted, for e.g. Temperature can be obtained using the average kinetic energies in conjunction with the equipartition theorem.&lt;br /&gt;
&lt;br /&gt;
Reduced units throughout the experiment to make the magnitudes of the quantities used more managable.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq1.png|188x188px]]&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;r = inter-particle distance, σ = inter-particle distance when the potential = 0, E = potential, ε = depth of the potential well, T = temperature and k = the Boltzmann constant. Starred quantities represent the non-reduced&lt;br /&gt;
versions. Note the unites cancel out when forming these quantities and hence they are unitless.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
The open source software, LAMMPS, was used to run the molecular dynamics simulations. The experiment was run as 5 separate parts:&lt;br /&gt;
# The effect of the time step on the simulation was probed using a box of 1000 atoms, equally spaced with a number density of 0.8 atoms per unit volume. The ensemble was treated as microcanonical. The following time steps were trialed: 0.0150, 0.0100, 0.0075, 0.0025, 0.0010. Energy, temperature and pressure for the system were collected at each iteration. A timestep of 0.0025 was used for the two subsequent simulations - see results and discussion for justification.&lt;br /&gt;
# A set of simulations were run in the isobaric-isothermal (NpT) ensemble. At P = 2.5 &amp;amp; P = 3.0, the simulation was run over the following temperatures: T = 1.5, 2.0, 2.5, 3.5, 5. Density of the systems was extracted as an average after the simulation, and plotted against temperature to test the agreement with the ideal gas law.&lt;br /&gt;
# An experiment was run in the NVT ensemble at densities 0.2 &amp;amp; 0.8, over the temperatures T = 2.0, 2.2, 2.4, 2.6, 2.8. The average heat capacity and temperature were collected for each system.&lt;br /&gt;
# Simulations were performed for a solid, a liquid and a gas system. A timestep of 0.0020 was used. Parameters for this were selected based on a previous probe into the phase transitions of the Lennard-Jones system&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;; solid (density = 1.2, T = 0.5), liquid (density = 0.8, T = 1.2), gas (density = 0.2, T = 1.2). The output trajectories were used to calculate the RDF (radial distribution function), i.e. the radial frequency of meeting another particle averaged over all spherical angles.&lt;br /&gt;
# Simulations were again performed for a solid, a liquid and a gas phase system. A timestep of 0.0020 was used for this experiment, and the same density/temperature parameters at experiment 4. The MSD (mean squared displacement) was collected as a function of timestep.&lt;br /&gt;
&lt;br /&gt;
== Results &amp;amp; Discussion ==&lt;br /&gt;
&lt;br /&gt;
=== Experiment 1 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq2.png|404x404px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq3.png|406x406px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq4.png|468x468px]]&lt;br /&gt;
&lt;br /&gt;
These plots show how the thermodynamic state variables of the system vary with time. For all of the variables , we see a very quick convergence from the initial value to the steady state value. A closer inspection of these graphs reveal&lt;br /&gt;
equilibration happens after roughly 0.5 reduced time units. This shows how the system which is initially ordered quickly descends into chaos. After this point, the state variables proceed to oscillate randomly as a noise function. This occurs due to fluctuations in the system which is constantly moving. If the system had more particles, the average would be less noisy because there are more opportunities for the random imbalances to cancel each other out.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq5.png|514x514px]]&lt;br /&gt;
&lt;br /&gt;
The above plot shows how the energy varies with timestep. As the time step is increased the average energy&lt;br /&gt;
increases due to the resolution of the numerical solution decreasing. The largest timestep shows a clear divergence. Presumably the timestep is so large that particles are getting unrealistically close to each other. The reaction in the next timestep cascades such that the problem is transferred to neighbouring particles. At this point the simulation breaks down as the energies and particle positions become increasingly unrealistic. 0.0025 was the largest timestep which showed no sign of this increased energy or divergence, and hence the timestep used for all subsequent experiments was smaller than this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 2 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq6.png|501x501px]]&lt;br /&gt;
&lt;br /&gt;
The density decreases with temperature as expected; the&lt;br /&gt;
atoms have more kinetic energy, so push each other apart further during their&lt;br /&gt;
random motion. The higher pressure plots show a consistently higher density.&lt;br /&gt;
This is intuitive as at higher pressures, the atoms are squashed closer&lt;br /&gt;
together on average. &lt;br /&gt;
&lt;br /&gt;
At lower temperatures, the ideal gas law result diverges&lt;br /&gt;
from the simulation. This is because the ideal gas law assumes no collisions.&lt;br /&gt;
At lower temperatures, particles of an ideal gas continue to be compressed into&lt;br /&gt;
a smaller space due to their diminishing kinetic energy, such that they are in&lt;br /&gt;
fact overlapping. In the simulation the particles collide, meaning a much&lt;br /&gt;
greater kinetic energy (temperature) reduction is required to achieve the same&lt;br /&gt;
increase in density. Also note that the ideal gas law allows for infinity as the&lt;br /&gt;
limiting density, whereas this becomes infinitely unlikely when using Van Der&lt;br /&gt;
Waals potential between the atoms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 3 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq7.png|486x486px]]&lt;br /&gt;
&lt;br /&gt;
The heat capacity is smaller for lower densities&lt;br /&gt;
as expected: there are less atoms to sink energy into, so the average kinetic energy&lt;br /&gt;
increases more quickly. The heat capacity decreases with temperature because at higher temperatures, the energy states are closer together, meaning it is easier to populate new states (higher density of states). This clearly outweighs any increased degeneracy in states, otherwise we would see the heat capacity increase with temperature as is often the case. The plateau could indicate a first order phase transition where the heat capacity tends to infinity. This would be made more clear with a higher resolution of data points. The radial distribution function could be calculated either side as the less ordered phase would have a smoother curve.    &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 4 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq8.png|478x478px]]&lt;br /&gt;
&lt;br /&gt;
The radial distribution function (RDF) represents the density of particles around a single particle in the system on average as a function of radius, averaged over all possible angles in a sphere. The RDFs for the different phases are distinct. In the solid case, we se sharp peaks corresponding to when we hit a site in the crystalline lattice. In the liquid, the peaks are much less sharp, as there are many more positions the molecules can occupy easily relative to one another. Peaks are still defined as the distance between particles is roughly constant. A gas behaves like a liquid with very little order. It is less peaks if any (occur at higher densities) are much less well defined. There is still a sharp peak close to the particle as neighbouring particles spend the most time when changing direction during a collision as this is when velocity is the smallest. All three phases exhibit a cut-off displacement due to the steep positive region in the Lennard-Jones potential.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq9.png|533x533px]]&lt;br /&gt;
&lt;br /&gt;
When the RDF is viewed cumulatively, we see the steepest cumulation for the solid, followed by the liquid then gas. This is due to meeting particles more frequently when in the more dense phase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 5 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq10.png|687x687px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# J. Silveira, A. Costa and E. Costa Junior, &#039;&#039;Engenharia Agrícola&#039;&#039;, 2017, 37, 717-726.&lt;br /&gt;
# L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1967, 159, 98-103.&lt;br /&gt;
# J. Hansen and L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1969, 184, 151-161.&lt;br /&gt;
&lt;br /&gt;
Weblinks:&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;http://www.scielo.br/scielo.php?script=sci_arttext&amp;amp;pid=S0100-69162017000400717#B21&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.159.98&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
LAMMPS script for heat capacity experiments&lt;br /&gt;
&lt;br /&gt;
Heat capacity LAMMPS input:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE SIMULATION BOX GEOMETRY ###&lt;br /&gt;
&lt;br /&gt;
variable dens equal 0.2&lt;br /&gt;
&lt;br /&gt;
lattice sc ${dens}&lt;br /&gt;
&lt;br /&gt;
region box block 0 15 0 15 0 15&lt;br /&gt;
&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&lt;br /&gt;
create_atoms 1 box&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE PHYSICAL PROPERTIES OF ATOMS ###&lt;br /&gt;
&lt;br /&gt;
mass 1 1.0&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut/opt 3.0&lt;br /&gt;
&lt;br /&gt;
pair_coeff 1 1 1.0 1.0&lt;br /&gt;
&lt;br /&gt;
neighbor 2.0 bin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&lt;br /&gt;
&lt;br /&gt;
variable T equal 2.0&lt;br /&gt;
&lt;br /&gt;
variable timestep equal 0.0075&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; ASSIGN ATOMIC VELOCITIES ###&lt;br /&gt;
&lt;br /&gt;
velocity all create ${T} 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY ENSEMBLE ###&lt;br /&gt;
&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; THERMODYNAMIC OUTPUT CONTROL ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
&lt;br /&gt;
thermo 10&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RECORD TRAJECTORY ###&lt;br /&gt;
&lt;br /&gt;
dump traj all custom 1000 output-1 id x y z&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY TIMESTEP ###&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RUN SIMULATION TO MELT CRYSTAL ###&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
unfix nve&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; BRING SYSTEM TO REQUIRED STATE ###&lt;br /&gt;
&lt;br /&gt;
variable tdamp equal ${timestep}*100&lt;br /&gt;
&lt;br /&gt;
fix nvt all nvt temp ${T} ${T} ${tdamp}&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
unfix nvt&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; MEASURE SYSTEM STATE ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom etotal temp atoms vol&lt;br /&gt;
&lt;br /&gt;
variable vol equal vol&lt;br /&gt;
&lt;br /&gt;
variable atoms equal atoms&lt;br /&gt;
&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
&lt;br /&gt;
variable N2 equal atoms*atoms&lt;br /&gt;
&lt;br /&gt;
variable E2 equal etotal*etotal&lt;br /&gt;
&lt;br /&gt;
variable E equal etotal&lt;br /&gt;
&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_temp2 v_E v_E2&lt;br /&gt;
&lt;br /&gt;
run 100000&lt;br /&gt;
&lt;br /&gt;
variable heatcapac equal&lt;br /&gt;
${N2}*(f_aves[3]-(f_aves[2]*f_aves[2]))/(f_aves[1])&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Averages&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;--------&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Heat Capacity: ${heatcapac}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Volume: ${vol}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;No of atoms: ${atoms}&amp;quot;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659183</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659183"/>
		<updated>2018-01-30T23:23:44Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Liquid Simulations Computational Lab Assignment - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
Time units converstion&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All un-equilibrated fluid systems will move via diffusion toward thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
One study on the extraction of basil essential oil from the&lt;br /&gt;
&amp;lt;em&amp;gt;Ocimum basilicum&amp;lt;/em&amp;gt; leaf exemplifies this&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;. The diffusion coefficient was&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, while the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates, due to different tissue structures inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. This knowledge allows manufacturers to fit the model&lt;br /&gt;
mathematically using parameters specific to their distillation setup, and use the result to find the best trade-off between extraction time (time and energy are expensive) and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to use computational models of particles interacting according to a Lennard-Jones potential to extract thermodynamic data about the system and ultimately calculate the diffusion coefficient. The experiment uses boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied to simulate a much larger &#039;effective system&#039;. The velocity-Verlet&lt;br /&gt;
algorithm&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; is used, which iterates the velocity and displacement for every particle in the system, from&lt;br /&gt;
an initial state, through the desired number of steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted, for e.g. Temperature can be obtained using the average kinetic energies in conjunction with the equipartition theorem.&lt;br /&gt;
&lt;br /&gt;
Reduced units throughout the experiment to make the magnitudes of the quantities used more managable.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq1.png|188x188px]]&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;r = inter-particle distance, σ = inter-particle distance when the potential = 0, E = potential, ε = depth of the potential well, T = temperature and k = the Boltzmann constant. Starred quantities represent the non-reduced&lt;br /&gt;
versions. Note the unites cancel out when forming these quantities and hence they are unitless.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
The open source software, LAMMPS, was used to run the molecular dynamics simulations. The experiment was run as 5 separate parts:&lt;br /&gt;
# The effect of the time step on the simulation was probed using a box of 1000 atoms, equally spaced with a number density of 0.8 atoms per unit volume. The ensemble was treated as microcanonical. The following time steps were trialed: 0.0150, 0.0100, 0.0075, 0.0025, 0.0010. Energy, temperature and pressure for the system were collected at each iteration. A timestep of 0.0025 was used for the two subsequent simulations - see results and discussion for justification.&lt;br /&gt;
# A set of simulations were run in the isobaric-isothermal (NpT) ensemble. At P = 2.5 &amp;amp; P = 3.0, the simulation was run over the following temperatures: T = 1.5, 2.0, 2.5, 3.5, 5. Density of the systems was extracted as an average after the simulation, and plotted against temperature to test the agreement with the ideal gas law.&lt;br /&gt;
# An experiment was run in the NVT ensemble at densities 0.2 &amp;amp; 0.8, over the temperatures T = 2.0, 2.2, 2.4, 2.6, 2.8. The average heat capacity and temperature were collected for each system.&lt;br /&gt;
# Simulations were performed for a solid, a liquid and a gas system. A timestep of 0.0020 was used. Parameters for this were selected based on a previous probe into the phase transitions of the Lennard-Jones system&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;; solid (density = 1.2, T = 0.5), liquid (density = 0.8, T = 1.2), gas (density = 0.2, T = 1.2). The output trajectories were used to calculate the RDF (radial distribution function), i.e. the radial frequency of meeting another particle averaged over all spherical angles.&lt;br /&gt;
# Simulations were again performed for a solid, a liquid and a gas phase system. A timestep of 0.0020 was used for this experiment, and the same density/temperature parameters at experiment 4. The MSD (mean squared displacement) was collected as a function of timestep.&lt;br /&gt;
&lt;br /&gt;
== Results &amp;amp; Discussion ==&lt;br /&gt;
&lt;br /&gt;
=== Experiment 1 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq2.png|404x404px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq3.png|406x406px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq4.png|468x468px]]&lt;br /&gt;
&lt;br /&gt;
These plots show how the thermodynamic state variables of the system vary with time. For all of the variables , we see a very quick convergence from the initial value to the steady state value. A closer inspection of these graphs reveal&lt;br /&gt;
equilibration happens after roughly 0.5 reduced time units. This shows how the system which is initially ordered quickly descends into chaos. After this point, the state variables proceed to oscillate randomly as a noise function. This occurs due to fluctuations in the system which is constantly moving. If the system had more particles, the average would be less noisy because there are more opportunities for the random imbalances to cancel each other out.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq5.png|562x562px]]&lt;br /&gt;
&lt;br /&gt;
The above plot shows how the energy varies with timestep. As the time step is increased the average energy&lt;br /&gt;
increases due to the resolution of the numerical solution decreasing. The largest timestep shows a clear divergence. Presumably the timestep is so large that particles are getting unrealistically close to each other. The reaction in the next timestep cascades such that the problem is transferred to neighbouring particles. At this point the simulation breaks down as the energies and particle positions become increasingly unrealistic. 0.0025 was the largest timestep which showed no sign of this increased energy or divergence, and hence the timestep used for all subsequent experiments was smaller than this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 2 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq6.png|780x780px]]&lt;br /&gt;
&lt;br /&gt;
The density decreases with temperature as expected; the&lt;br /&gt;
atoms have more kinetic energy, so push each other apart further during their&lt;br /&gt;
random motion. The higher pressure plots show a consistently higher density.&lt;br /&gt;
This is intuitive as at higher pressures, the atoms are squashed closer&lt;br /&gt;
together on average. &lt;br /&gt;
&lt;br /&gt;
At lower temperatures, the ideal gas law result diverges&lt;br /&gt;
from the simulation. This is because the ideal gas law assumes no collisions.&lt;br /&gt;
At lower temperatures, particles of an ideal gas continue to be compressed into&lt;br /&gt;
a smaller space due to their diminishing kinetic energy, such that they are in&lt;br /&gt;
fact overlapping. In the simulation the particles collide, meaning a much&lt;br /&gt;
greater kinetic energy (temperature) reduction is required to achieve the same&lt;br /&gt;
increase in density. Also note that the ideal gas law allows for infinity as the&lt;br /&gt;
limiting density, whereas this becomes infinitely unlikely when using Van Der&lt;br /&gt;
Waals potential between the atoms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 3 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq7.png|695x695px]]&lt;br /&gt;
&lt;br /&gt;
The heat capacity is smaller for lower densities&lt;br /&gt;
as expected: there are less atoms to sink energy into, so the average kinetic energy&lt;br /&gt;
increases more quickly. The heat capacity decreases with temperature because at higher temperatures, the energy states are closer together, meaning it is easier to populate new states (higher density of states). This clearly outweighs any increased degeneracy in states, otherwise we would see the heat capacity increase with temperature as is often the case. The plateau could indicate a first order phase transition where the heat capacity tends to infinity. This would be made more clear with a higher resolution of data points. The radial distribution function could be calculated either side as the less ordered phase would have a smoother curve.    &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 4 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq8.png|531x531px]]&lt;br /&gt;
[[File:Smliq9.png|555x555px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 5 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq10.png|687x687px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
== References ==&lt;br /&gt;
# J. Silveira, A. Costa and E. Costa Junior, &#039;&#039;Engenharia Agrícola&#039;&#039;, 2017, 37, 717-726.&lt;br /&gt;
# L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1967, 159, 98-103.&lt;br /&gt;
# J. Hansen and L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1969, 184, 151-161.&lt;br /&gt;
&lt;br /&gt;
Weblinks:&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;http://www.scielo.br/scielo.php?script=sci_arttext&amp;amp;pid=S0100-69162017000400717#B21&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.159.98&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
LAMMPS script for heat capacity experiments&lt;br /&gt;
&lt;br /&gt;
Heat capacity LAMMPS input:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE SIMULATION BOX GEOMETRY ###&lt;br /&gt;
&lt;br /&gt;
variable dens equal 0.2&lt;br /&gt;
&lt;br /&gt;
lattice sc ${dens}&lt;br /&gt;
&lt;br /&gt;
region box block 0 15 0 15 0 15&lt;br /&gt;
&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&lt;br /&gt;
create_atoms 1 box&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE PHYSICAL PROPERTIES OF ATOMS ###&lt;br /&gt;
&lt;br /&gt;
mass 1 1.0&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut/opt 3.0&lt;br /&gt;
&lt;br /&gt;
pair_coeff 1 1 1.0 1.0&lt;br /&gt;
&lt;br /&gt;
neighbor 2.0 bin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&lt;br /&gt;
&lt;br /&gt;
variable T equal 2.0&lt;br /&gt;
&lt;br /&gt;
variable timestep equal 0.0075&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; ASSIGN ATOMIC VELOCITIES ###&lt;br /&gt;
&lt;br /&gt;
velocity all create ${T} 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY ENSEMBLE ###&lt;br /&gt;
&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; THERMODYNAMIC OUTPUT CONTROL ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
&lt;br /&gt;
thermo 10&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RECORD TRAJECTORY ###&lt;br /&gt;
&lt;br /&gt;
dump traj all custom 1000 output-1 id x y z&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY TIMESTEP ###&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RUN SIMULATION TO MELT CRYSTAL ###&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
unfix nve&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; BRING SYSTEM TO REQUIRED STATE ###&lt;br /&gt;
&lt;br /&gt;
variable tdamp equal ${timestep}*100&lt;br /&gt;
&lt;br /&gt;
fix nvt all nvt temp ${T} ${T} ${tdamp}&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
unfix nvt&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; MEASURE SYSTEM STATE ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom etotal temp atoms vol&lt;br /&gt;
&lt;br /&gt;
variable vol equal vol&lt;br /&gt;
&lt;br /&gt;
variable atoms equal atoms&lt;br /&gt;
&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
&lt;br /&gt;
variable N2 equal atoms*atoms&lt;br /&gt;
&lt;br /&gt;
variable E2 equal etotal*etotal&lt;br /&gt;
&lt;br /&gt;
variable E equal etotal&lt;br /&gt;
&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_temp2 v_E v_E2&lt;br /&gt;
&lt;br /&gt;
run 100000&lt;br /&gt;
&lt;br /&gt;
variable heatcapac equal&lt;br /&gt;
${N2}*(f_aves[3]-(f_aves[2]*f_aves[2]))/(f_aves[1])&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Averages&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;--------&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Heat Capacity: ${heatcapac}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Volume: ${vol}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;No of atoms: ${atoms}&amp;quot;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659172</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659172"/>
		<updated>2018-01-30T23:07:33Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Liquid Simulations Computational Lab Assignment - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
Time units converstion&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All un-equilibrated fluid systems will move via diffusion toward thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
One study on the extraction of basil essential oil from the&lt;br /&gt;
&amp;lt;em&amp;gt;Ocimum basilicum&amp;lt;/em&amp;gt; leaf exemplifies this&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;. The diffusion coefficient was&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, while the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates, due to different tissue structures inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. This knowledge allows manufacturers to fit the model&lt;br /&gt;
mathematically using parameters specific to their distillation setup, and use the result to find the best trade-off between extraction time (time and energy are expensive) and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to use computational models of particles interacting according to a Lennard-Jones potential to extract thermodynamic data about the system and ultimately calculate the diffusion coefficient. The experiment uses boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied to simulate a much larger &#039;effective system&#039;. The velocity-Verlet&lt;br /&gt;
algorithm&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; is used, which iterates the velocity and displacement for every particle in the system, from&lt;br /&gt;
an initial state, through the desired number of steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted, for e.g. Temperature can be obtained using the average kinetic energies in conjunction with the equipartition theorem.&lt;br /&gt;
&lt;br /&gt;
Reduced units throughout the experiment to make the magnitudes of the quantities used more managable.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq1.png|188x188px]]&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;r = inter-particle distance, σ = inter-particle distance when the potential = 0, E = potential, ε = depth of the potential well, T = temperature and k = the Boltzmann constant. Starred quantities represent the non-reduced&lt;br /&gt;
versions. Note the unites cancel out when forming these quantities and hence they are unitless.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
The open source software, LAMMPS, was used to run the molecular dynamics simulations. The experiment was run as 5 separate parts:&lt;br /&gt;
# The effect of the time step on the simulation was probed using a box of 1000 atoms, equally spaced with a number density of 0.8 atoms per unit volume. The ensemble was treated as microcanonical. The following time steps were trialed: 0.0150, 0.0100, 0.0075, 0.0025, 0.0010. Energy, temperature and pressure for the system were collected at each iteration. A timestep of 0.0025 was used for the two subsequent simulations - see results and discussion for justification.&lt;br /&gt;
# A set of simulations were run in the isobaric-isothermal (NpT) ensemble. At P = 2.5 &amp;amp; P = 3.0, the simulation was run over the following temperatures: T = 1.5, 2.0, 2.5, 3.5, 5. Density of the systems was extracted as an average after the simulation, and plotted against temperature to test the agreement with the ideal gas law.&lt;br /&gt;
# An experiment was run in the NVT ensemble at densities 0.2 &amp;amp; 0.8, over the temperatures T = 2.0, 2.2, 2.4, 2.6, 2.8. The average heat capacity and temperature were collected for each system.&lt;br /&gt;
# Simulations were performed for a solid, a liquid and a gas system. A timestep of 0.0020 was used. Parameters for this were selected based on a previous probe into the phase transitions of the Lennard-Jones system&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;; solid (density = 1.2, T = 0.5), liquid (density = 0.8, T = 1.2), gas (density = 0.2, T = 1.2). The output trajectories were used to calculate the RDF (radial distribution function), i.e. the radial frequency of meeting another particle averaged over all spherical angles.&lt;br /&gt;
# Simulations were again performed for a solid, a liquid and a gas phase system. A timestep of 0.0020 was used for this experiment, and the same density/temperature parameters at experiment 4. The MSD (mean squared displacement) was collected as a function of timestep.&lt;br /&gt;
&lt;br /&gt;
== Results &amp;amp; Discussion ==&lt;br /&gt;
&lt;br /&gt;
=== Experiment 1 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq2.png|404x404px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq3.png|406x406px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq4.png|468x468px]]&lt;br /&gt;
&lt;br /&gt;
These plots show how the thermodynamic state variables of the system vary with time. For all of the variables , we see a very quick convergence from the initial value to the steady state value. A closer inspection of these graphs reveal&lt;br /&gt;
equilibration happens after roughly 0.5 reduced time units. This shows how the system which is initially ordered quickly descends into chaos. After this point, the state variables proceed to oscillate randomly as a noise function. This occurs due to fluctuations in the system which is constantly moving. If the system had more particles, the average would be less noisy because there are more opportunities for the random imbalances to cancel each other out.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq5.png|562x562px]]&lt;br /&gt;
&lt;br /&gt;
The above plot shows how the energy varies with timestep. As the time step is increased the average energy&lt;br /&gt;
increases due to the resolution of the numerical solution decreasing. The largest timestep shows a clear divergence. Presumably the timestep is so large that particles are getting unrealistically close to each other. The reaction in the next timestep cascades such that the problem is transferred to neighbouring particles. At this point the simulation breaks down as the energies and particle positions become increasingly unrealistic. 0.0025 was the largest timestep which showed no sign of this increased energy or divergence, and hence the timestep used for all subsequent experiments was smaller than this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 2 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq6.png|780x780px]]&lt;br /&gt;
&lt;br /&gt;
The density decreases with temperature as expected; the&lt;br /&gt;
atoms have more kinetic energy, so push each other apart further during their&lt;br /&gt;
random motion. The higher pressure plots show a consistently higher density.&lt;br /&gt;
This is intuitive as at higher pressures, the atoms are squashed closer&lt;br /&gt;
together on average. &lt;br /&gt;
&lt;br /&gt;
At lower temperatures, the ideal gas law result diverges&lt;br /&gt;
from the simulation. This is because the ideal gas law assumes no collisions.&lt;br /&gt;
At lower temperatures, particles of an ideal gas continue to be compressed into&lt;br /&gt;
a smaller space due to their diminishing kinetic energy, such that they are in&lt;br /&gt;
fact overlapping. In the simulation the particles collide, meaning a much&lt;br /&gt;
greater kinetic energy (temperature) reduction is required to achieve the same&lt;br /&gt;
increase in density. Also note that the ideal gas law allows for infinity as the&lt;br /&gt;
limiting density, whereas this becomes infinitely unlikely when using Van Der&lt;br /&gt;
Waals potential between the atoms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 3 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq7.png|695x695px]]&lt;br /&gt;
&lt;br /&gt;
The heat capacity is smaller for lower densities&lt;br /&gt;
as expected: there are less atoms to sink energy into, so the average kinetic energy&lt;br /&gt;
increases more quickly.    &lt;br /&gt;
&lt;br /&gt;
[[File:Smliq8.png|531x531px]]&lt;br /&gt;
[[File:Smliq9.png|506x506px]]&lt;br /&gt;
[[File:Smliq10.png|687x687px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
== References ==&lt;br /&gt;
# J. Silveira, A. Costa and E. Costa Junior, &#039;&#039;Engenharia Agrícola&#039;&#039;, 2017, 37, 717-726.&lt;br /&gt;
# L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1967, 159, 98-103.&lt;br /&gt;
# J. Hansen and L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1969, 184, 151-161.&lt;br /&gt;
&lt;br /&gt;
Weblinks:&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;http://www.scielo.br/scielo.php?script=sci_arttext&amp;amp;pid=S0100-69162017000400717#B21&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.159.98&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
LAMMPS script for heat capacity experiments&lt;br /&gt;
&lt;br /&gt;
Heat capacity LAMMPS input:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE SIMULATION BOX GEOMETRY ###&lt;br /&gt;
&lt;br /&gt;
variable dens equal 0.2&lt;br /&gt;
&lt;br /&gt;
lattice sc ${dens}&lt;br /&gt;
&lt;br /&gt;
region box block 0 15 0 15 0 15&lt;br /&gt;
&lt;br /&gt;
create_box 1 box&lt;br /&gt;
&lt;br /&gt;
create_atoms 1 box&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; DEFINE PHYSICAL PROPERTIES OF ATOMS ###&lt;br /&gt;
&lt;br /&gt;
mass 1 1.0&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut/opt 3.0&lt;br /&gt;
&lt;br /&gt;
pair_coeff 1 1 1.0 1.0&lt;br /&gt;
&lt;br /&gt;
neighbor 2.0 bin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&lt;br /&gt;
&lt;br /&gt;
variable T equal 2.0&lt;br /&gt;
&lt;br /&gt;
variable timestep equal 0.0075&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; ASSIGN ATOMIC VELOCITIES ###&lt;br /&gt;
&lt;br /&gt;
velocity all create ${T} 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY ENSEMBLE ###&lt;br /&gt;
&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; THERMODYNAMIC OUTPUT CONTROL ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
&lt;br /&gt;
thermo 10&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RECORD TRAJECTORY ###&lt;br /&gt;
&lt;br /&gt;
dump traj all custom 1000 output-1 id x y z&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; SPECIFY TIMESTEP ###&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; RUN SIMULATION TO MELT CRYSTAL ###&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
unfix nve&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; BRING SYSTEM TO REQUIRED STATE ###&lt;br /&gt;
&lt;br /&gt;
variable tdamp equal ${timestep}*100&lt;br /&gt;
&lt;br /&gt;
fix nvt all nvt temp ${T} ${T} ${tdamp}&lt;br /&gt;
&lt;br /&gt;
run 10000&lt;br /&gt;
&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
unfix nvt&lt;br /&gt;
&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;###&amp;lt;/nowiki&amp;gt; MEASURE SYSTEM STATE ###&lt;br /&gt;
&lt;br /&gt;
thermo_style custom etotal temp atoms vol&lt;br /&gt;
&lt;br /&gt;
variable vol equal vol&lt;br /&gt;
&lt;br /&gt;
variable atoms equal atoms&lt;br /&gt;
&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
&lt;br /&gt;
variable N2 equal atoms*atoms&lt;br /&gt;
&lt;br /&gt;
variable E2 equal etotal*etotal&lt;br /&gt;
&lt;br /&gt;
variable E equal etotal&lt;br /&gt;
&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_temp2 v_E v_E2&lt;br /&gt;
&lt;br /&gt;
run 100000&lt;br /&gt;
&lt;br /&gt;
variable heatcapac equal&lt;br /&gt;
${N2}*(f_aves[3]-(f_aves[2]*f_aves[2]))/(f_aves[1])&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Averages&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;--------&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Heat Capacity: ${heatcapac}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Volume: ${vol}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;No of atoms: ${atoms}&amp;quot;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659158</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=659158"/>
		<updated>2018-01-30T23:01:16Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Liquid Simulations Computational Lab Assignment - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
Time units converstion&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All un-equilibrated fluid systems will move via diffusion toward thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
One study on the extraction of basil essential oil from the&lt;br /&gt;
&amp;lt;em&amp;gt;Ocimum basilicum&amp;lt;/em&amp;gt; leaf exemplifies this&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;. The diffusion coefficient was&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, while the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates, due to different tissue structures inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. This knowledge allows manufacturers to fit the model&lt;br /&gt;
mathematically using parameters specific to their distillation setup, and use the result to find the best trade-off between extraction time (time and energy are expensive) and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to use computational models of particles interacting according to a Lennard-Jones potential to extract thermodynamic data about the system and ultimately calculate the diffusion coefficient. The experiment uses boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied to simulate a much larger &#039;effective system&#039;. The velocity-Verlet&lt;br /&gt;
algorithm&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; is used, which iterates the velocity and displacement for every particle in the system, from&lt;br /&gt;
an initial state, through the desired number of steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted, for e.g. Temperature can be obtained using the average kinetic energies in conjunction with the equipartition theorem.&lt;br /&gt;
&lt;br /&gt;
Reduced units throughout the experiment to make the magnitudes of the quantities used more managable.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq1.png|188x188px]]&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;r = inter-particle distance, σ = inter-particle distance when the potential = 0, E = potential, ε = depth of the potential well, T = temperature and k = the Boltzmann constant. Starred quantities represent the non-reduced&lt;br /&gt;
versions. Note the unites cancel out when forming these quantities and hence they are unitless.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
The open source software, LAMMPS, was used to run the molecular dynamics simulations. The experiment was run as 5 separate parts:&lt;br /&gt;
# The effect of the time step on the simulation was probed using a box of 1000 atoms, equally spaced with a number density of 0.8 atoms per unit volume. The ensemble was treated as microcanonical. The following time steps were trialed: 0.0150, 0.0100, 0.0075, 0.0025, 0.0010. Energy, temperature and pressure for the system were collected at each iteration. A timestep of 0.0025 was used for the two subsequent simulations - see results and discussion for justification.&lt;br /&gt;
# A set of simulations were run in the isobaric-isothermal (NpT) ensemble. At P = 2.5 &amp;amp; P = 3.0, the simulation was run over the following temperatures: T = 1.5, 2.0, 2.5, 3.5, 5. Density of the systems was extracted as an average after the simulation, and plotted against temperature to test the agreement with the ideal gas law.&lt;br /&gt;
# An experiment was run in the NVT ensemble at densities 0.2 &amp;amp; 0.8, over the temperatures T = 2.0, 2.2, 2.4, 2.6, 2.8. The average heat capacity and temperature were collected for each system.&lt;br /&gt;
# Simulations were performed for a solid, a liquid and a gas system. A timestep of 0.0020 was used. Parameters for this were selected based on a previous probe into the phase transitions of the Lennard-Jones system&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;; solid (density = 1.2, T = 0.5), liquid (density = 0.8, T = 1.2), gas (density = 0.2, T = 1.2). The output trajectories were used to calculate the RDF (radial distribution function), i.e. the radial frequency of meeting another particle averaged over all spherical angles.&lt;br /&gt;
# Simulations were again performed for a solid, a liquid and a gas phase system. A timestep of 0.0020 was used for this experiment, and the same density/temperature parameters at experiment 4. The MSD (mean squared displacement) was collected as a function of timestep.&lt;br /&gt;
&lt;br /&gt;
== Results &amp;amp; Discussion ==&lt;br /&gt;
&lt;br /&gt;
=== Experiment 1 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq2.png|404x404px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq3.png|406x406px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq4.png|468x468px]]&lt;br /&gt;
&lt;br /&gt;
These plots show how the thermodynamic state variables of the system vary with time. For all of the variables , we see a very quick convergence from the initial value to the steady state value. A closer inspection of these graphs reveal&lt;br /&gt;
equilibration happens after roughly 0.5 reduced time units. This shows how the system which is initially ordered quickly descends into chaos. After this point, the state variables proceed to oscillate randomly as a noise function. This occurs due to fluctuations in the system which is constantly moving. If the system had more particles, the average would be less noisy because there are more opportunities for the random imbalances to cancel each other out.&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq5.png|562x562px]]&lt;br /&gt;
&lt;br /&gt;
The above plot shows how the energy varies with timestep. As the time step is increased the average energy&lt;br /&gt;
increases due to the resolution of the numerical solution decreasing. The largest timestep shows a clear divergence. Presumably the timestep is so large that particles are getting unrealistically close to each other. The reaction in the next timestep cascades such that the problem is transferred to neighbouring particles. At this point the simulation breaks down as the energies and particle positions become increasingly unrealistic. 0.0025 was the largest timestep which showed no sign of this increased energy or divergence, and hence the timestep used for all subsequent experiments was smaller than this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 2 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq6.png|780x780px]]&lt;br /&gt;
&lt;br /&gt;
The density decreases with temperature as expected; the&lt;br /&gt;
atoms have more kinetic energy, so push each other apart further during their&lt;br /&gt;
random motion. The higher pressure plots show a consistently higher density.&lt;br /&gt;
This is intuitive as at higher pressures, the atoms are squashed closer&lt;br /&gt;
together on average. &lt;br /&gt;
&lt;br /&gt;
At lower temperatures, the ideal gas law result diverges&lt;br /&gt;
from the simulation. This is because the ideal gas law assumes no collisions.&lt;br /&gt;
At lower temperatures, particles of an ideal gas continue to be compressed into&lt;br /&gt;
a smaller space due to their diminishing kinetic energy, such that they are in&lt;br /&gt;
fact overlapping. In the simulation the particles collide, meaning a much&lt;br /&gt;
greater kinetic energy (temperature) reduction is required to achieve the same&lt;br /&gt;
increase in density. Also note that the ideal gas law allows for infinity as the&lt;br /&gt;
limiting density, whereas this becomes infinitely unlikely when using Van Der&lt;br /&gt;
Waals potential between the atoms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Experiment 3 ===&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq7.png|695x695px]]&lt;br /&gt;
&lt;br /&gt;
The heat capacity is smaller for lower densities&lt;br /&gt;
as expected: there are less atoms to sink energy into, so the average kinetic energy&lt;br /&gt;
increases more quickly.    &lt;br /&gt;
&lt;br /&gt;
[[File:Smliq8.png|531x531px]]&lt;br /&gt;
[[File:Smliq9.png|506x506px]]&lt;br /&gt;
[[File:Smliq10.png|687x687px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
== References ==&lt;br /&gt;
# J. Silveira, A. Costa and E. Costa Junior, &#039;&#039;Engenharia Agrícola&#039;&#039;, 2017, 37, 717-726.&lt;br /&gt;
# L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1967, 159, 98-103.&lt;br /&gt;
# J. Hansen and L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1969, 184, 151-161.&lt;br /&gt;
&lt;br /&gt;
Weblinks:&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;http://www.scielo.br/scielo.php?script=sci_arttext&amp;amp;pid=S0100-69162017000400717#B21&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.159.98&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=658723</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=658723"/>
		<updated>2018-01-30T15:38:42Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Liquid Simulations Computational Lab Assignment - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All un-equilibrated fluid systems will move via diffusion toward thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
One study on the extraction of basil essential oil from the&lt;br /&gt;
&amp;lt;em&amp;gt;Ocimum basilicum&amp;lt;/em&amp;gt; leaf exemplifies this&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;. The diffusion coefficient was&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, while the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates, due to different tissue structures inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. This knowledge allows manufacturers to fit the model&lt;br /&gt;
mathematically using parameters specific to their distillation setup, and use the result to find the best trade-off between extraction time (time and energy are expensive) and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to use computational models of particles interacting according to a Lennard-Jones potential to extract thermodynamic data about the system and ultimately calculate the diffusion coefficient. The experiment uses boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied to simulate a much larger &#039;effective system&#039;. The velocity-Verlet&lt;br /&gt;
algorithm&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; is used, which iterates the velocity and displacement for every particle in the system, from&lt;br /&gt;
an initial state, through the desired number of steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted, for e.g. Temperature can be obtained using the average kinetic energies in conjunction with the equipartition theorem.&lt;br /&gt;
&lt;br /&gt;
Reduced units throughout the experiment to make the magnitudes of the quantities used more managable.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq1.png|188x188px]]&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;r = inter-particle distance, σ = inter-particle distance when the potential = 0, E = potential, ε = depth of the potential well, T = temperature and k = the Boltzmann constant. Starred quantities represent the non-reduced&lt;br /&gt;
versions. Note the unites cancel out when forming these quantities and hence they are unitless.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
The open source software, LAMMPS, was used to run the molecular dynamics simulations. The experiment was run as 5 separate parts:&lt;br /&gt;
# The effect of the time step on the simulation was probed using a box of 1000 atoms, equally spaced with a number density of 0.8 atoms per unit volume. The ensemble was treated as microcanonical. The following time steps were trialed: 0.0150, 0.0100, 0.0075, 0.0025, 0.0010. Energy, temperature and pressure for the system were collected at each iteration. A timestep of 0.0025 was used for the two subsequent simulations - see results and discussion for justification.&lt;br /&gt;
# A set of simulations were run in the isobaric-isothermal (NpT) ensemble. At P = 2.5 &amp;amp; P = 3.0, the simulation was run over the following temperatures: T = 1.5, 2.0, 2.5, 3.5, 5. Density of the systems was extracted as an average after the simulation, and plotted against temperature to test the agreement with the ideal gas law.&lt;br /&gt;
# An experiment was run in the NVT ensemble at densities 0.2 &amp;amp; 0.8, over the temperatures T = 2.0, 2.2, 2.4, 2.6, 2.8. The average heat capacity and temperature were collected for each system.&lt;br /&gt;
# Simulations were performed for a solid, a liquid and a gas system. A timestep of 0.0020 was used. Parameters for this were selected based on a previous probe into the phase transitions of the Lennard-Jones system&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;; solid (density = 1.2, T = 0.5), liquid (density = 0.8, T = 1.2), gas (density = 0.2, T = 1.2). The output trajectories were used to calculate the RDF (radial distribution function), i.e. the radial frequency of meeting another particle averaged over all spherical angles.&lt;br /&gt;
# Simulations were again performed for a solid, a liquid and a gas phase system. A timestep of 0.0020 was used for this experiment, and the same density/temperature parameters at experiment 4. The MSD (mean squared displacement) was collected as a function of timestep.&lt;br /&gt;
&lt;br /&gt;
== Results &amp;amp; Discussion ==&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Smliq2.png|404x404px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq3.png|406x406px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq4.png|443x443px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq5.png|716x716px]]&lt;br /&gt;
[[File:Smliq6.png|780x780px]]&lt;br /&gt;
[[File:Smliq7.png|695x695px]]&lt;br /&gt;
[[File:Smliq8.png|531x531px]]&lt;br /&gt;
[[File:Smliq9.png|506x506px]]&lt;br /&gt;
[[File:Smliq10.png|687x687px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
== References ==&lt;br /&gt;
# J. Silveira, A. Costa and E. Costa Junior, &#039;&#039;Engenharia Agrícola&#039;&#039;, 2017, 37, 717-726.&lt;br /&gt;
# L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1967, 159, 98-103.&lt;br /&gt;
# J. Hansen and L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1969, 184, 151-161.&lt;br /&gt;
&lt;br /&gt;
Weblinks:&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;http://www.scielo.br/scielo.php?script=sci_arttext&amp;amp;pid=S0100-69162017000400717#B21&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.159.98&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=658721</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=658721"/>
		<updated>2018-01-30T15:36:05Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Liquid Simulations Computational Lab Assignment - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All un-equilibrated fluid systems will move via diffusion toward thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
One study on the extraction of basil essential oil from the&lt;br /&gt;
&amp;lt;em&amp;gt;Ocimum basilicum&amp;lt;/em&amp;gt; leaf exemplifies this&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;. The diffusion coefficient was&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, while the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates, due to different tissue structures inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. This knowledge allows manufacturers to fit the model&lt;br /&gt;
mathematically using parameters specific to their distillation setup, and use the result to find the best trade-off between extraction time (time and energy are expensive) and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to use computational models of particles interacting according to a Lennard-Jones potential to extract thermodynamic data about the system and ultimately calculate the diffusion coefficient. The experiment uses boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied to simulate a much larger &#039;effective system&#039;. The velocity-Verlet&lt;br /&gt;
algorithm&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; is used, which iterates the velocity and displacement for every particle in the system, from&lt;br /&gt;
an initial state, through the desired number of steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted, for e.g. Temperature can be obtained using the average kinetic energies in conjunction with the equipartition theorem.&lt;br /&gt;
&lt;br /&gt;
Reduced units throughout the experiment to make the magnitudes of the quantities used more managable.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq1.png|188x188px]]&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;r = inter-particle distance, σ = inter-particle distance when the potential = 0, E = potential, ε = depth of the potential well, T = temperature and k = the Boltzmann constant. Starred quantities represent the non-reduced&lt;br /&gt;
versions. Note the unites cancel out when forming these quantities and hence they are unitless.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
The open source software, LAMMPS, was used to run the molecular dynamics simulations. The experiment was run as 5 separate parts:&lt;br /&gt;
# The effect of the time step on the simulation was probed using a box of 1000 atoms, equally spaced with a number density of 0.8 atoms per unit volume. The ensemble was treated as microcanonical. The following time steps were trialed: 0.0150, 0.0100, 0.0075, 0.0025, 0.0010. Energy, temperature and pressure for the system were collected at each iteration. A timestep of 0.0025 was used for the two subsequent simulations - see results and discussion for justification.&lt;br /&gt;
# A set of simulations were run in the isobaric-isothermal (NpT) ensemble. At P = 2.5 &amp;amp; P = 3.0, the simulation was run over the following temperatures: T = 1.5, 2.0, 2.5, 3.5, 5. Density of the systems was extracted as an average after the simulation, and plotted against temperature to test the agreement with the ideal gas law.&lt;br /&gt;
# An experiment was run in the NVT ensemble at densities 0.2 &amp;amp; 0.8, over the temperatures T = 2.0, 2.2, 2.4, 2.6, 2.8. The average heat capacity and temperature were collected for each system.&lt;br /&gt;
# Simulations were performed for a solid, a liquid and a gas system. A timestep of 0.0020 was used. Parameters for this were selected based on a previous probe into the phase transitions of the Lennard-Jones system&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;; solid (density = 1.2, T = 0.5), liquid (density = 0.8, T = 1.2), gas (density = 0.2, T = 1.2). The output trajectories were used to calculate the RDF (radial distribution function), i.e. the radial frequency of meeting another particle averaged over all spherical angles.&lt;br /&gt;
# Simulations were again performed for a solid, a liquid and a gas phase system. A timestep of 0.0020 was used for this experiment, and the same density/temperature parameters at experiment 4. The MSD (mean squared displacement) was collected as a function of timestep.&lt;br /&gt;
&lt;br /&gt;
== Results &amp;amp; Discussion ==&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq2.png|404x404px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq3.png|406x406px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq4.png|443x443px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq5.png|716x716px]]&lt;br /&gt;
[[File:Smliq6.png|780x780px]]&lt;br /&gt;
[[File:Smliq7.png|695x695px]]&lt;br /&gt;
[[File:Smliq8.png|531x531px]]&lt;br /&gt;
[[File:Smliq9.png|506x506px]]&lt;br /&gt;
[[File:Smliq10.png|687x687px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&amp;lt;nowiki/&amp;gt;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# J. Silveira, A. Costa and E. Costa Junior, &#039;&#039;Engenharia Agrícola&#039;&#039;, 2017, 37, 717-726.&lt;br /&gt;
# L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1967, 159, 98-103.&lt;br /&gt;
# J. Hansen and L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1969, 184, 151-161.&lt;br /&gt;
&lt;br /&gt;
Weblinks:&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;http://www.scielo.br/scielo.php?script=sci_arttext&amp;amp;pid=S0100-69162017000400717#B21&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.159.98&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq10.png&amp;diff=658718</id>
		<title>File:Smliq10.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq10.png&amp;diff=658718"/>
		<updated>2018-01-30T15:30:47Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq9.png&amp;diff=658717</id>
		<title>File:Smliq9.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq9.png&amp;diff=658717"/>
		<updated>2018-01-30T15:30:30Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq8.png&amp;diff=658716</id>
		<title>File:Smliq8.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq8.png&amp;diff=658716"/>
		<updated>2018-01-30T15:30:08Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq7.png&amp;diff=658714</id>
		<title>File:Smliq7.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq7.png&amp;diff=658714"/>
		<updated>2018-01-30T15:29:46Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq6.png&amp;diff=658713</id>
		<title>File:Smliq6.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq6.png&amp;diff=658713"/>
		<updated>2018-01-30T15:28:10Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq5.png&amp;diff=658712</id>
		<title>File:Smliq5.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq5.png&amp;diff=658712"/>
		<updated>2018-01-30T15:27:41Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq4.png&amp;diff=658711</id>
		<title>File:Smliq4.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq4.png&amp;diff=658711"/>
		<updated>2018-01-30T15:27:23Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq3.png&amp;diff=658710</id>
		<title>File:Smliq3.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq3.png&amp;diff=658710"/>
		<updated>2018-01-30T15:27:11Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq2.png&amp;diff=658709</id>
		<title>File:Smliq2.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq2.png&amp;diff=658709"/>
		<updated>2018-01-30T15:26:57Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=658708</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=658708"/>
		<updated>2018-01-30T15:26:44Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: /* Results &amp;amp; Discussion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Liquid Simulations Computational Lab Assignment - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All un-equilibrated fluid systems will move via diffusion toward thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
One study on the extraction of basil essential oil from the&lt;br /&gt;
&amp;lt;em&amp;gt;Ocimum basilicum&amp;lt;/em&amp;gt; leaf exemplifies this&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;. The diffusion coefficient was&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, while the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates, due to different tissue structures inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. This knowledge allows manufacturers to fit the model&lt;br /&gt;
mathematically using parameters specific to their distillation setup, and use the result to find the best trade-off between extraction time (time and energy are expensive) and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to use computational models of particles interacting according to a Lennard-Jones potential to extract thermodynamic data about the system and ultimately calculate the diffusion coefficient. The experiment uses boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied to simulate a much larger &#039;effective system&#039;. The velocity-Verlet&lt;br /&gt;
algorithm&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; is used, which iterates the velocity and displacement for every particle in the system, from&lt;br /&gt;
an initial state, through the desired number of steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted, for e.g. Temperature can be obtained using the average kinetic energies in conjunction with the equipartition theorem.&lt;br /&gt;
&lt;br /&gt;
Reduced units throughout the experiment to make the magnitudes of the quantities used more managable.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq1.png]]&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;r = inter-particle distance, σ = inter-particle distance when the potential = 0, E = potential, ε = depth of the potential well, T = temperature and k = the Boltzmann constant. Starred quantities represent the non-reduced&lt;br /&gt;
versions. Note the unites cancel out when forming these quantities and hence they are unitless.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
The open source software, LAMMPS, was used to run the molecular dynamics simulations. The experiment was run as 5 separate parts:&lt;br /&gt;
# The effect of the time step on the simulation was probed using a box of 1000 atoms, equally spaced with a number density of 0.8 atoms per unit volume. The ensemble was treated as microcanonical. The following time steps were trialed: 0.0150, 0.0100, 0.0075, 0.0025, 0.0010. Energy, temperature and pressure for the system were collected at each iteration. A timestep of 0.0025 was used for the two subsequent simulations - see results and discussion for justification.&lt;br /&gt;
# A set of simulations were run in the isobaric-isothermal (NpT) ensemble. At P = 2.5 &amp;amp; P = 3.0, the simulation was run over the following temperatures: T = 1.5, 2.0, 2.5, 3.5, 5. Density of the systems was extracted as an average after the simulation, and plotted against temperature to test the agreement with the ideal gas law.&lt;br /&gt;
# An experiment was run in the NVT ensemble at densities 0.2 &amp;amp; 0.8, over the temperatures T = 2.0, 2.2, 2.4, 2.6, 2.8. The average heat capacity and temperature were collected for each system.&lt;br /&gt;
# Simulations were performed for a solid, a liquid and a gas system. A timestep of 0.0020 was used. Parameters for this were selected based on a previous probe into the phase transitions of the Lennard-Jones system&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;; solid (density = 1.2, T = 0.5), liquid (density = 0.8, T = 1.2), gas (density = 0.2, T = 1.2). The output trajectories were used to calculate the RDF (radial distribution function), i.e. the radial frequency of meeting another particle averaged over all spherical angles.&lt;br /&gt;
# Simulations were again performed for a solid, a liquid and a gas phase system. A timestep of 0.0020 was used for this experiment, and the same density/temperature parameters at experiment 4. The MSD (mean squared displacement) was collected as a function of timestep.&lt;br /&gt;
&lt;br /&gt;
== Results &amp;amp; Discussion ==&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq2.png]]&lt;br /&gt;
[[File:Smliq3.png]]&lt;br /&gt;
[[File:Smliq4.png]]&lt;br /&gt;
[[File:Smliq5.png]]&lt;br /&gt;
[[File:Smliq6.png]]&lt;br /&gt;
[[File:Smliq7.png]]&lt;br /&gt;
[[File:Smliq8.png]]&lt;br /&gt;
[[File:Smliq9.png]]&lt;br /&gt;
[[File:Smliq10.png]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&amp;lt;nowiki/&amp;gt;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# J. Silveira, A. Costa and E. Costa Junior, &#039;&#039;Engenharia Agrícola&#039;&#039;, 2017, 37, 717-726.&lt;br /&gt;
# L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1967, 159, 98-103.&lt;br /&gt;
# J. Hansen and L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1969, 184, 151-161.&lt;br /&gt;
&lt;br /&gt;
Weblinks:&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;http://www.scielo.br/scielo.php?script=sci_arttext&amp;amp;pid=S0100-69162017000400717#B21&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.159.98&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=658687</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=658687"/>
		<updated>2018-01-30T15:12:56Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: /* Aims &amp;amp; Objectives */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Liquid Simulations Computational Lab Assignment - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All un-equilibrated fluid systems will move via diffusion toward thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
One study on the extraction of basil essential oil from the&lt;br /&gt;
&amp;lt;em&amp;gt;Ocimum basilicum&amp;lt;/em&amp;gt; leaf exemplifies this&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;. The diffusion coefficient was&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, while the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates, due to different tissue structures inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. This knowledge allows manufacturers to fit the model&lt;br /&gt;
mathematically using parameters specific to their distillation setup, and use the result to find the best trade-off between extraction time (time and energy are expensive) and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to use computational models of particles interacting according to a Lennard-Jones potential to extract thermodynamic data about the system and ultimately calculate the diffusion coefficient. The experiment uses boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied to simulate a much larger &#039;effective system&#039;. The velocity-Verlet&lt;br /&gt;
algorithm&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; is used, which iterates the velocity and displacement for every particle in the system, from&lt;br /&gt;
an initial state, through the desired number of steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted, for e.g. Temperature can be obtained using the average kinetic energies in conjunction with the equipartition theorem.&lt;br /&gt;
&lt;br /&gt;
Reduced units throughout the experiment to make the magnitudes of the quantities used more managable.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
[[File:Smliq1.png]]&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;r = inter-particle distance, σ = inter-particle distance when the potential = 0, E = potential, ε = depth of the potential well, T = temperature and k = the Boltzmann constant. Starred quantities represent the non-reduced&lt;br /&gt;
versions. Note the unites cancel out when forming these quantities and hence they are unitless.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
The open source software, LAMMPS, was used to run the molecular dynamics simulations. The experiment was run as 5 separate parts:&lt;br /&gt;
# The effect of the time step on the simulation was probed using a box of 1000 atoms, equally spaced with a number density of 0.8 atoms per unit volume. The ensemble was treated as microcanonical. The following time steps were trialed: 0.0150, 0.0100, 0.0075, 0.0025, 0.0010. Energy, temperature and pressure for the system were collected at each iteration. A timestep of 0.0025 was used for the two subsequent simulations - see results and discussion for justification.&lt;br /&gt;
# A set of simulations were run in the isobaric-isothermal (NpT) ensemble. At P = 2.5 &amp;amp; P = 3.0, the simulation was run over the following temperatures: T = 1.5, 2.0, 2.5, 3.5, 5. Density of the systems was extracted as an average after the simulation, and plotted against temperature to test the agreement with the ideal gas law.&lt;br /&gt;
# An experiment was run in the NVT ensemble at densities 0.2 &amp;amp; 0.8, over the temperatures T = 2.0, 2.2, 2.4, 2.6, 2.8. The average heat capacity and temperature were collected for each system.&lt;br /&gt;
# Simulations were performed for a solid, a liquid and a gas system. A timestep of 0.0020 was used. Parameters for this were selected based on a previous probe into the phase transitions of the Lennard-Jones system&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;; solid (density = 1.2, T = 0.5), liquid (density = 0.8, T = 1.2), gas (density = 0.2, T = 1.2). The output trajectories were used to calculate the RDF (radial distribution function), i.e. the radial frequency of meeting another particle averaged over all spherical angles.&lt;br /&gt;
# Simulations were again performed for a solid, a liquid and a gas phase system. A timestep of 0.0020 was used for this experiment, and the same density/temperature parameters at experiment 4. The MSD (mean squared displacement) was collected as a function of timestep.&lt;br /&gt;
&lt;br /&gt;
== Results &amp;amp; Discussion ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&amp;lt;nowiki/&amp;gt;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# J. Silveira, A. Costa and E. Costa Junior, &#039;&#039;Engenharia Agrícola&#039;&#039;, 2017, 37, 717-726.&lt;br /&gt;
# L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1967, 159, 98-103.&lt;br /&gt;
# J. Hansen and L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1969, 184, 151-161.&lt;br /&gt;
&lt;br /&gt;
Weblinks:&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;http://www.scielo.br/scielo.php?script=sci_arttext&amp;amp;pid=S0100-69162017000400717#B21&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.159.98&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq1.png&amp;diff=658686</id>
		<title>File:Smliq1.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Smliq1.png&amp;diff=658686"/>
		<updated>2018-01-30T15:12:27Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=658670</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=658670"/>
		<updated>2018-01-30T15:03:54Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: /* Methods */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Liquid Simulations Computational Lab Assignment - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All un-equilibrated fluid systems will move via diffusion toward thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
One study on the extraction of basil essential oil from the&lt;br /&gt;
&amp;lt;em&amp;gt;Ocimum basilicum&amp;lt;/em&amp;gt; leaf exemplifies this&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;. The diffusion coefficient was&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, while the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates, due to different tissue structures inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. This knowledge allows manufacturers to fit the model&lt;br /&gt;
mathematically using parameters specific to their distillation setup, and use the result to find the best trade-off between extraction time (time and energy are expensive) and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to use computational models of particles interacting according to a Lennard-Jones potential to extract thermodynamic data about the system and ultimately calculate the diffusion coefficient. The experiment uses boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied to simulate a much larger &#039;effective system&#039;. The velocity-Verlet&lt;br /&gt;
algorithm&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; is used, which iterates the velocity and displacement for every particle in the system, from&lt;br /&gt;
an initial state, through the desired number of steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted, for e.g. Temperature can be obtained using the average kinetic energies in conjunction with the equipartition theorem.&lt;br /&gt;
&lt;br /&gt;
Reduced units throughout the experiment to make the magnitudes of the quantities used more managable.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
IMAGE&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;r = inter-particle distance, σ = inter-particle distance when the potential = 0, E = potential, ε = depth of the potential well, T = temperature and k = the Boltzmann constant. Starred quantities represent the non-reduced&lt;br /&gt;
versions. Note the unites cancel out when forming these quantities and hence they are unitless.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
The open source software, LAMMPS, was used to run the molecular dynamics simulations. The experiment was run as 5 separate parts:&lt;br /&gt;
# The effect of the time step on the simulation was probed using a box of 1000 atoms, equally spaced with a number density of 0.8 atoms per unit volume. The ensemble was treated as microcanonical. The following time steps were trialed: 0.0150, 0.0100, 0.0075, 0.0025, 0.0010. Energy, temperature and pressure for the system were collected at each iteration. A timestep of 0.0025 was used for the two subsequent simulations - see results and discussion for justification.&lt;br /&gt;
# A set of simulations were run in the isobaric-isothermal (NpT) ensemble. At P = 2.5 &amp;amp; P = 3.0, the simulation was run over the following temperatures: T = 1.5, 2.0, 2.5, 3.5, 5. Density of the systems was extracted as an average after the simulation, and plotted against temperature to test the agreement with the ideal gas law.&lt;br /&gt;
# An experiment was run in the NVT ensemble at densities 0.2 &amp;amp; 0.8, over the temperatures T = 2.0, 2.2, 2.4, 2.6, 2.8. The average heat capacity and temperature were collected for each system.&lt;br /&gt;
# Simulations were performed for a solid, a liquid and a gas system. A timestep of 0.0020 was used. Parameters for this were selected based on a previous probe into the phase transitions of the Lennard-Jones system&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;; solid (density = 1.2, T = 0.5), liquid (density = 0.8, T = 1.2), gas (density = 0.2, T = 1.2). The output trajectories were used to calculate the RDF (radial distribution function), i.e. the radial frequency of meeting another particle averaged over all spherical angles.&lt;br /&gt;
# Simulations were again performed for a solid, a liquid and a gas phase system. A timestep of 0.0020 was used for this experiment, and the same density/temperature parameters at experiment 4. The MSD (mean squared displacement) was collected as a function of timestep.&lt;br /&gt;
&lt;br /&gt;
== Results &amp;amp; Discussion ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&amp;lt;nowiki/&amp;gt;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# J. Silveira, A. Costa and E. Costa Junior, &#039;&#039;Engenharia Agrícola&#039;&#039;, 2017, 37, 717-726.&lt;br /&gt;
# L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1967, 159, 98-103.&lt;br /&gt;
# J. Hansen and L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1969, 184, 151-161.&lt;br /&gt;
&lt;br /&gt;
Weblinks:&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;http://www.scielo.br/scielo.php?script=sci_arttext&amp;amp;pid=S0100-69162017000400717#B21&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.159.98&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=658643</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=658643"/>
		<updated>2018-01-30T14:40:14Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Liquid Simulations Computational Lab Assignment - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All un-equilibrated fluid systems will move via diffusion toward thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
One study on the extraction of basil essential oil from the&lt;br /&gt;
&amp;lt;em&amp;gt;Ocimum basilicum&amp;lt;/em&amp;gt; leaf exemplifies this&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;. The diffusion coefficient was&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, while the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates, due to different tissue structures inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. This knowledge allows manufacturers to fit the model&lt;br /&gt;
mathematically using parameters specific to their distillation setup, and use the result to find the best trade-off between extraction time (time and energy are expensive) and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to use computational models of particles interacting according to a Lennard-Jones potential to extract thermodynamic data about the system and ultimately calculate the diffusion coefficient. The experiment uses boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied to simulate a much larger &#039;effective system&#039;. The velocity-Verlet&lt;br /&gt;
algorithm&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; is used, which iterates the velocity and displacement for every particle in the system, from&lt;br /&gt;
an initial state, through the desired number of steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted, for e.g. Temperature can be obtained using the average kinetic energies in conjunction with the equipartition theorem.&lt;br /&gt;
&lt;br /&gt;
Reduced units throughout the experiment to make the magnitudes of the quantities used more managable.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
IMAGE&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;r = inter-particle distance, σ = inter-particle distance when the potential = 0, E = potential, ε = depth of the potential well, T = temperature and k = the Boltzmann constant. Starred quantities represent the non-reduced&lt;br /&gt;
versions. Note the unites cancel out when forming these quantities and hence they are unitless.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
The open source software, LAMMPS, was used to run the molecular dynamics simulations. The experiment was run as 5 separate part:&lt;br /&gt;
&lt;br /&gt;
1.    &lt;br /&gt;
The effect of the time step on the simulation was&lt;br /&gt;
probed using a box of 1000 atoms, equally spaced with a number density of 0.8&lt;br /&gt;
atoms per unit volume. The ensemble was treated as microcanonical. The&lt;br /&gt;
following time steps were trialed: 0.0150, 0.0100, 0.0075, 0.0025, 0.0010. Energy,&lt;br /&gt;
temperature and pressure for the system were collected at each iteration.&lt;br /&gt;
&lt;br /&gt;
2.    &lt;br /&gt;
A set of experiments were then run in the isobaric-isothermal&lt;br /&gt;
(NpT) ensemble. At P = 2.5 &amp;amp; P = 3.0, the simulation was run over the&lt;br /&gt;
following temperatures: T = 1.5, 2.0, 2.5, 3.5, 5. Density of the systems was&lt;br /&gt;
extracted and plotted against temperature to test the agreement with the ideal&lt;br /&gt;
gas law.&lt;br /&gt;
&lt;br /&gt;
3.    &lt;br /&gt;
An experiment was run in the NVT ensemble at densities&lt;br /&gt;
0.2 &amp;amp; 0.8, over the temperatures T = 2.0, 2.2, 2.4, 2.6, 2.8. The results&lt;br /&gt;
were used to calculate the heat capacity of the system.&lt;br /&gt;
&lt;br /&gt;
4.    &lt;br /&gt;
Simulations were performed for a solid, liquid and gas&lt;br /&gt;
system. Data on the radial distribution function was collected, and the mean&lt;br /&gt;
squared displacement which was used to calculate the density.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&amp;lt;nowiki/&amp;gt;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# J. Silveira, A. Costa and E. Costa Junior, &#039;&#039;Engenharia Agrícola&#039;&#039;, 2017, 37, 717-726.&lt;br /&gt;
# L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1967, 159, 98-103.&lt;br /&gt;
&lt;br /&gt;
Weblinks:&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;http://www.scielo.br/scielo.php?script=sci_arttext&amp;amp;pid=S0100-69162017000400717#B21&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;https://journals.aps.org/pr/abstract/10.1103/PhysRev.159.98&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=658630</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=658630"/>
		<updated>2018-01-30T14:20:05Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract ==&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All un-equilibrated fluid systems will move via diffusion toward thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
One study on the extraction of basil essential oil from the&lt;br /&gt;
&amp;lt;em&amp;gt;Ocimum basilicum&amp;lt;/em&amp;gt; leaf exemplifies this&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt;. The diffusion coefficient was&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, while the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates, due to different tissue structures inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. This knowledge allows manufacturers to fit the model&lt;br /&gt;
mathematically using parameters specific to their distillation setup, and use the result to find the best trade-off between extraction time (time and energy are expensive) and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to use computational models of particles interacting according to a Lennard-Jones potential to extract thermodynamic data about the system and ultimately calculate the diffusion coefficient. The experiment uses boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied to simulate a much larger &#039;effective system&#039;. The velocity-Verlet&lt;br /&gt;
algorithm&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; is used, which iterates the velocity and displacement for every particle in the system, from&lt;br /&gt;
an initial state, through the desired number of steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted, for e.g. Temperature can be obtained using the average kinetic energies in conjunction with the equipartition theorem.&lt;br /&gt;
&lt;br /&gt;
Reduced units throughout the experiment to make the magnitudes of the quantities used more managable.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
IMAGE&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;r = inter-particle distance, σ = inter-particle distance when the potential = 0, E = potential, ε = depth of the potential well, T = temperature and k = the Boltzmann constant. Starred quantities represent the non-reduced&lt;br /&gt;
versions. Note the unites cancel out when forming these quantities and hence they are unitless.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# J. Silveira, A. Costa and E. Costa Junior, &#039;&#039;Engenharia Agrícola&#039;&#039;, 2017, 37, 717-726.&lt;br /&gt;
# L. Verlet, &#039;&#039;Physical Review&#039;&#039;, 1967, 159, 98-103.&lt;br /&gt;
&lt;br /&gt;
Weblinks:&lt;br /&gt;
# &amp;lt;nowiki&amp;gt;http://www.scielo.br/scielo.php?script=sci_arttext&amp;amp;pid=S0100-69162017000400717#B21&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=658612</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=658612"/>
		<updated>2018-01-30T13:56:30Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract ==&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Diffusion is a fundamental form of transport in fluid and soft-condensed phases. All unequilibrated fluid systems will move via diffusion to thermodynamic equilibrium. Many industrial chemical processes could benefit from an optimisation considering diffusion involving the fluid or soft-condensed system being processed. For example, consider piping different coloured icings onto a cupcake to form a pattern. The manufacturer may wish to&lt;br /&gt;
prevent the diffusion of the two colouring molecules between the bulk of the icing, as this would ruin the pattern. Studying the temperature dependence of&lt;br /&gt;
this diffusion could allow them to find the maximum temperature at which the cupcake&lt;br /&gt;
could be safely packaged without significant diffusion occurring.&lt;br /&gt;
&lt;br /&gt;
A study on the extraction of basil essential oil from the&lt;br /&gt;
basil leaf exemplifies this&amp;lt;sup&amp;gt;reference&amp;lt;/sup&amp;gt;. The diffusion coefficient is&lt;br /&gt;
found to change over the course of the extraction; the vapour pressure of the&lt;br /&gt;
basil oil in the surrounding air increases, and the homogeneity of oil&lt;br /&gt;
distribution in the leaf diminished as it is depleted from different areas at&lt;br /&gt;
different rates due to structures of different cells inside the leaf. The study used models based on Fick’s second law of diffusion, and ultimately elucidated a&lt;br /&gt;
quadratic relationship between the concentration and diffusion coefficient for&lt;br /&gt;
the system. Knowledge of this allows manufacturers to fit the model&lt;br /&gt;
mathematically with parameters specific to their setup, and use the result to find the best trade-off between extraction time and extraction yield.&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Objectives ==&lt;br /&gt;
The aim of this experiment is to compare two methods of&lt;br /&gt;
calculating diffusion coefficients, as well as other thermodynamic properties.&lt;br /&gt;
&lt;br /&gt;
The experiment uses simulations of boxes of between 1000 and&lt;br /&gt;
10000 atoms, with periodic boundary conditions applied. The velocity-Verlet&lt;br /&gt;
algorithm is used, which iterates velocity and displacement of the system from&lt;br /&gt;
an initial state through many steps. At each of these steps, thermodynamic&lt;br /&gt;
state variables of the system can be extracted.&lt;br /&gt;
&lt;br /&gt;
Note the use of reduced units throughout the experiment.&lt;br /&gt;
Given the Lennard-Jones potential:&lt;br /&gt;
&lt;br /&gt;
r = r*/σ&lt;br /&gt;
&lt;br /&gt;
E = E*/ε&lt;br /&gt;
&lt;br /&gt;
T = kT*/ε&lt;br /&gt;
&lt;br /&gt;
Where the starred quantities represent the non-reduced&lt;br /&gt;
versions.&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=654968</id>
		<title>Rep:SMliqsim</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:SMliqsim&amp;diff=654968"/>
		<updated>2018-01-23T10:17:51Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: Created page with &amp;quot;Liquid Simulations&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Liquid Simulations&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Sm_ising&amp;diff=645980</id>
		<title>Rep:Sm ising</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Sm_ising&amp;diff=645980"/>
		<updated>2017-11-22T11:59:26Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: /* Finding the Curie temperature (Tc) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Ising Model Report - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== The Ising model, energy and magnetisation ==&lt;br /&gt;
The Ising model is a simple model which examines the magnetic phase behaviour of a system. The system is set up as an n-dimensional lattice of particles which are either spin up (+1) or spin down (-1). The interaction between any two particles that share a face is counted as an additive contribution towards the overall energy of the system. Each interaction is calculated by multiplying the two spins and then multiplying by some constant J to convert units to energy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 1:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In a lowest energy configuration, all spins will be oriented in the same direction (+1 or -1) to maximise the magnitude of the sum or the interacting spin pairs.&lt;br /&gt;
&lt;br /&gt;
Per dimension, there are two directions in which each spin can interact given that only neighbours sharing a face can interact (modelling the spins as cubes, weather arranged in a line, plane or box).&lt;br /&gt;
&lt;br /&gt;
This means per particle there are 2D interactions, where D = number of dimensions in the system.&lt;br /&gt;
&lt;br /&gt;
The total number of interactions is therefore 2DN/2, where we divide by 2 as each interaction is double counted when we sum interactions over all the particles, where N = number of particles in the system.&lt;br /&gt;
&lt;br /&gt;
Weather each interaction is -1 with -1 or 1 with 1, the magnitude will always be 1, so the total magnitude of the energy of all the interactions will be J * 1.0 * number of interactions where J is some constant converting the units of the energy from arbitrary units into joules.&lt;br /&gt;
&lt;br /&gt;
This simplifies to: Magnitude of the energy of all interactions = DNJ. We know the energy is negative as all spins in alignment correponds to the greatest energy reduction for the system, so we may conclude:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Lowest possible interaction energy for a system (E) = -DNJ&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Only two configurations give this state: when either all spins are +1 or all spins are -1. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;The multiplicity is therefore given by 2 * N!/N! (= 2) where N is the number of spins in the system.&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Entropy (S) = k ln(M) where k is the Boltzmann constant and M is the number of equivalent microstates, so the lowest entropy of the Ising system is given by:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;S = k ln(2)&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 2:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
From the lowest energy configuration, if one of the spins were to instantaneously flip, the new configuration would be all spins aligned but one; i.e all +1 with one -1 or all -1 with one +1.&lt;br /&gt;
&lt;br /&gt;
Multiplicity therefore = 2 * N!/(N - 1)!&lt;br /&gt;
&lt;br /&gt;
The entropy for the D =3, N =1000 system is therefore k ln(2 * (1000!/999!))&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;S = k ln(2 * (1000!/999!))&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;S = k ln(2000)&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In terms of the energy, one spin interacts with 6 neighbours in a 3D lattice. One positive interaction changing into one negative interaction increases the energy by 2J, so overall, flipping one spin leads to a 12J increase in energy to the system.&lt;br /&gt;
&lt;br /&gt;
=== Magnetisation ===&lt;br /&gt;
The magnetisation of the system is defined as the sum of all the spins in the system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 3:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
System 1:&lt;br /&gt;
&lt;br /&gt;
+ + + - -&lt;br /&gt;
&lt;br /&gt;
For system 1, the total magnetisation is 3 - 2:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Magnetisation = + 1&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
System 1:&lt;br /&gt;
&lt;br /&gt;
+ + + + -&lt;br /&gt;
&lt;br /&gt;
+ + + - -&lt;br /&gt;
&lt;br /&gt;
+ + + - -&lt;br /&gt;
&lt;br /&gt;
+ + - - -&lt;br /&gt;
&lt;br /&gt;
+ - - - -&lt;br /&gt;
&lt;br /&gt;
For system 1, the total magnetisation is 13 - 12:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Magnetisation = + 1&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
At absolute zero the entropic contribution would be minimised, so one would expect the energetic contribution to dominate and align all the spins.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;At absolute zero therefore, for a 3D system of 1000 spins, magnetisation = 1000&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Python (Energy and magnetisation) ==&lt;br /&gt;
&#039;&#039;&#039;Task 4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Functions to extract the energy and magnetisation of a system were then written in python;&lt;br /&gt;
&lt;br /&gt;
    def energy(self):&lt;br /&gt;
        &amp;quot;Return the total energy of the current lattice configuration.&amp;quot;&lt;br /&gt;
        # Function works by cycling through each element and then interacting with each neighbour on a grid of coordinates. The energy is halved to prevent double counting and made negative.&lt;br /&gt;
        energy = 0.0&lt;br /&gt;
        net_interaction = 0&lt;br /&gt;
        y = 0&lt;br /&gt;
        x = 0&lt;br /&gt;
        for row in self.lattice:&lt;br /&gt;
                for element in row:&lt;br /&gt;
                    # interact right&lt;br /&gt;
                    if x != self.n_cols - 1:&lt;br /&gt;
                        net_interaction += (element * self.lattice[y, x + 1])&lt;br /&gt;
                    else:&lt;br /&gt;
                        # if we are at the end element, interact with the adjacent system&lt;br /&gt;
                        net_interaction += (element * self.lattice[y, 0])&lt;br /&gt;
                    # interact left&lt;br /&gt;
                    if x != 0:&lt;br /&gt;
                        net_interaction += (element * self.lattice[y, x - 1])&lt;br /&gt;
                    else:&lt;br /&gt;
                        # if we are at the start element, interact with the adjacent system&lt;br /&gt;
                        net_interaction += (element * self.lattice[y, self.n_cols - 1])&lt;br /&gt;
                    # interact bottom&lt;br /&gt;
                    if y != self.n_rows - 1:&lt;br /&gt;
                        net_interaction += (element * self.lattice[y + 1, x])&lt;br /&gt;
                    else:&lt;br /&gt;
                        # if we are at the end element, interact with the adjacent system&lt;br /&gt;
                        net_interaction += (element * self.lattice[0, x])&lt;br /&gt;
                    # interact top&lt;br /&gt;
                    if y != 0:&lt;br /&gt;
                        net_interaction += (element * self.lattice[y - 1, x])&lt;br /&gt;
                    else:&lt;br /&gt;
                        # if we are at the start element, interact with the adjacent system&lt;br /&gt;
                        net_interaction += (element * self.lattice[self.n_rows - 1, x])&lt;br /&gt;
                    # iterate selected spin&lt;br /&gt;
                    if x == self.n_cols - 1:&lt;br /&gt;
                        x = 0&lt;br /&gt;
                        y += 1&lt;br /&gt;
                    else:&lt;br /&gt;
                        x += 1&lt;br /&gt;
        interaction_energy = - 0.5 * net_interaction&lt;br /&gt;
        return interaction_energy&lt;br /&gt;
&lt;br /&gt;
    def magnetisation(self):&lt;br /&gt;
        &amp;quot;Return the total magnetisation of the current lattice configuration.&amp;quot;&lt;br /&gt;
        magnetisation = 0&lt;br /&gt;
        for row in self.lattice:&lt;br /&gt;
            for element in row:&lt;br /&gt;
                magnetisation += element&lt;br /&gt;
        return magnetisation&lt;br /&gt;
&#039;&#039;&#039;Task 5&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;ILcheck.py&#039; script was then ran multiple times to check the energy and magnetisation functions gave consistently correct results:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising001.png|400px]][[File:Ising002.png|400px]][[File:Ising003.png|400px]]&lt;br /&gt;
&lt;br /&gt;
== Python (Monte Carlo Function) ==&lt;br /&gt;
&#039;&#039;&#039;Task 6&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Let us consider a system with 100 spins. Considering each spin has two possible states, there are &amp;lt;math&amp;gt;2^{100} = 1.27 *10^{30}&amp;lt;/math&amp;gt; potential configurations of the system. Even if we could analyse &amp;lt;math&amp;gt;10^9&amp;lt;/math&amp;gt; configurations per second, it would still take us &amp;lt;math&amp;gt;1.27 *10^{21} s&amp;lt;/math&amp;gt; to calculate the magnetisations of all of the configurations to take an average. Clearly this would take too long so we must look for an alternative method of gathering data on the behaviour of the energy. One way of doing this is using a Monte Carlo simulation where we start with a random configuration and randomly flip spins. We accept the new configuration if there is an energy reduction. Otherwise we accept the new configuration at a rate proportional to the Boltzmann factor as this reflects how often a particle would theoretically have enough energy to flip to a higher energy state.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 7&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A Monte-Carlo simulation was coded in python as follows:&lt;br /&gt;
&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        &amp;quot;preforms a single Monte Carlo step&amp;quot;&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        current_lattice = self.lattice&lt;br /&gt;
        # create a new lattice with on spin flipped&lt;br /&gt;
            #the following two lines select the coordinates of the random spin&lt;br /&gt;
        random_i = np.random.choice(range(self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(self.n_cols))&lt;br /&gt;
        self.lattice[random_i][random_j] =  -self.lattice[random_i][random_j]&lt;br /&gt;
        new_E = self.energy()&lt;br /&gt;
        # compare energies and decided what configuration to adopt, then update parameters&lt;br /&gt;
        dE = new_E - energy&lt;br /&gt;
        if dE &amp;lt; 0:&lt;br /&gt;
            # print(&#039;new energy lower: lattice updated&#039;)&lt;br /&gt;
            pass&lt;br /&gt;
        else:&lt;br /&gt;
            # the following line will choose a random number in the range (0,1)&lt;br /&gt;
            randNumb = np.random.random()&lt;br /&gt;
            if randNumb &amp;lt;= math.exp(-dE/T):&lt;br /&gt;
                # print(&#039;lattice was updated&#039;)&lt;br /&gt;
                pass&lt;br /&gt;
            else:&lt;br /&gt;
                # print(&#039;lattice was not updated&#039;)&lt;br /&gt;
                self.lattice[random_i][random_j] =  -self.lattice[random_i][random_j]&lt;br /&gt;
        self.E += self.energy()&lt;br /&gt;
        self.E2 += self.energy()**2&lt;br /&gt;
        self.M += self.magnetisation()&lt;br /&gt;
        self.M2 += self.magnetisation()**2&lt;br /&gt;
        # converts cycle index x to cycle number x + 1 (the next machine cycle step number)&lt;br /&gt;
        # In other words increments the counter of number of cycles&lt;br /&gt;
        self.n_cycles += 1&lt;br /&gt;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        &amp;quot;returns statistical data collected during a Monte Carlo simulation&amp;quot;&lt;br /&gt;
        avE = self.E / self.n_cycles&lt;br /&gt;
        avE2 = self.E2 / self.n_cycles&lt;br /&gt;
        avM = self.M / self.n_cycles&lt;br /&gt;
        avM2 = self.M2 / self.n_cycles&lt;br /&gt;
        N = self.n_cycles&lt;br /&gt;
        return avE, avE2, avM, avM2, N&lt;br /&gt;
&#039;&#039;&#039;Task 8&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
When the temperature of the system is above the Curie Temperature (Tc), the system is paramagnetic at thermodynamic equilibrium, i.e. the spins are oriented randomly in the absence of an external magnetic field. When the temperature of the system is below the Curie Temperature, the system is ferromagnetic at thermodynamic equilibrium (spins align). In the case T &amp;lt; Tc, one would therefore expect the system to spontaneously magnetise (spins align) as it attains the most thermodynamically stable state.&lt;br /&gt;
&lt;br /&gt;
Indeed, when we run our Monte Carlo simulation for an 8x8 lattice at T = 0.5 K, it can be seen that the spins tend toward alignment in on direction as the energy minimises;&lt;br /&gt;
&lt;br /&gt;
[[File:Ising004.png|center]]&lt;br /&gt;
    Averaged quantities:&lt;br /&gt;
    E =  -1.96841896186&lt;br /&gt;
    E*E =  3.88120282707&lt;br /&gt;
    M =  -0.991326800847&lt;br /&gt;
    M*M =  0.983257746292&lt;br /&gt;
&lt;br /&gt;
== Accelerating the code ==&lt;br /&gt;
&#039;&#039;&#039;Task 9&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In an attempt to accelerate the code and save time, the energy() and magnetisation() functions were made more efficient using functions within the numpy python library:&lt;br /&gt;
&lt;br /&gt;
    def energy(self):&lt;br /&gt;
        &amp;quot;Improved energy function which implements numpy&#039;s roll and multiply functions&amp;quot;&lt;br /&gt;
        # multiply by a shifted grid to apply vertical energy contribution&lt;br /&gt;
        vertical_energy = -np.sum(np.multiply(self.lattice, np.roll(self.lattice, 1, axis = 0)))&lt;br /&gt;
        # multiply by a shifted grid to apply the horizontal energy contribution&lt;br /&gt;
        total_energy = vertical_energy - np.sum(np.multiply(self.lattice, np.roll(self.lattice, 1, axis = 1)))&lt;br /&gt;
        return total_energy&lt;br /&gt;
&lt;br /&gt;
    def magnetisation(self):&lt;br /&gt;
        &amp;quot;Improved magnetisation function that implements numpy&#039;s sum function:&amp;quot;&lt;br /&gt;
        return np.sum(self.lattice)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 10&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Time trials were used to compare the speed of the old and updated energy functions:&lt;br /&gt;
&lt;br /&gt;
    New function:&lt;br /&gt;
    2.4918089999999893 s&lt;br /&gt;
    2.4761589999999956 s&lt;br /&gt;
    2.540256999999997 s&lt;br /&gt;
    2.4700420000000065 s&lt;br /&gt;
    2.5968489999999917 s&lt;br /&gt;
    &lt;br /&gt;
    Average = 2.52 s&lt;br /&gt;
    Standard error of average = 0.024 s&lt;br /&gt;
    &lt;br /&gt;
    Old function:&lt;br /&gt;
    10.844294 s&lt;br /&gt;
    10.496529000000002 s&lt;br /&gt;
    10.151754999999998 s&lt;br /&gt;
    10.489855999999996 s&lt;br /&gt;
    9.988599999999998 s&lt;br /&gt;
    &lt;br /&gt;
    Average = 10.39 s&lt;br /&gt;
    Standard error of average = 0.149 s&lt;br /&gt;
&lt;br /&gt;
The result is the improved function only takes 24.3 % of the time took by the old function to do the same thing.&lt;br /&gt;
==The effect of temperature==&lt;br /&gt;
The following plots were produced by running 150000 steps of the Monte Carlo simulation at T = 0.5 K and T = 2.0 K respectively:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising005.png|500px]][[File:Ising006.png|500px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Ising007.png|500px]][[File:Ising008.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Note, in the second system, we see that there must be a realistic chance for the whole system to flip the net spin direction as this is what can be seen from the graph to occur. This happens because in this system there are two global minimum points on the potential energy surface separated by a barrier. At this temperature there is enough energy to only occasionally overcome this barrier.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 11&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Looking at the dynamics of the systems, we can see in the temperature region in which we are working, the region after 3000 steps should be a sufficient representation of the system at equilibrium. The Monte Carlo step and statistics functions were updated to only begin the statistics functionality after 3000 steps:&lt;br /&gt;
&lt;br /&gt;
    # Defines first cycle in which statistical data is collected&lt;br /&gt;
    statsStartStep = 3000&lt;br /&gt;
    # Converts cycle nummber into the machine read index of the cycle (humans count from 1, machine indexes from 0)&lt;br /&gt;
    statsStartStep -= 1&lt;br /&gt;
&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        &amp;quot;preforms a single Monte Carlo step&amp;quot;&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        current_lattice = self.lattice&lt;br /&gt;
        # create a new lattice with on spin flipped&lt;br /&gt;
            #the following two lines select the coordinates of the random spin&lt;br /&gt;
        random_i = np.random.choice(range(self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(self.n_cols))&lt;br /&gt;
        self.lattice[random_i][random_j] =  -self.lattice[random_i][random_j]&lt;br /&gt;
        new_E = self.energy()&lt;br /&gt;
        # compare energies and decided what configuration to adopt, then update parameters&lt;br /&gt;
        dE = new_E - energy&lt;br /&gt;
        if dE &amp;lt; 0:&lt;br /&gt;
            # print(&#039;new energy lower: lattice updated&#039;)&lt;br /&gt;
            pass&lt;br /&gt;
        else:&lt;br /&gt;
            # the following line will choose a random number in the range (0,1)&lt;br /&gt;
            randNumb = np.random.random()&lt;br /&gt;
            if randNumb &amp;lt;= math.exp(-dE/T):&lt;br /&gt;
                # print(&#039;lattice was updated&#039;)&lt;br /&gt;
                pass&lt;br /&gt;
            else:&lt;br /&gt;
                # print(&#039;lattice was not updated&#039;)&lt;br /&gt;
                self.lattice[random_i][random_j] =  -self.lattice[random_i][random_j]&lt;br /&gt;
        # Update the running total IF we are in the region we are gathering stats for&lt;br /&gt;
        if self.n_cycles &amp;gt;= self.statsStartStep:&lt;br /&gt;
            self.E += self.energy()&lt;br /&gt;
            self.E2 += self.energy()**2&lt;br /&gt;
            self.M += self.magnetisation()&lt;br /&gt;
            self.M2 += self.magnetisation()**2&lt;br /&gt;
        # converts cycle index x to cycle number x + 1 (the next machine cycle step number)&lt;br /&gt;
        self.n_cycles += 1&lt;br /&gt;
        # print(self.n_cycles)&lt;br /&gt;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        # Updated statistics function&lt;br /&gt;
        if self.n_cycles &amp;gt;= self.statsStartStep:&lt;br /&gt;
            avE = self.E / (self.n_cycles - self.statsStartStep)&lt;br /&gt;
            avE2 = self.E2 / (self.n_cycles - self.statsStartStep)&lt;br /&gt;
            avM = self.M / (self.n_cycles - self.statsStartStep)&lt;br /&gt;
            avM2 = self.M2 / (self.n_cycles - self.statsStartStep)&lt;br /&gt;
            N = self.n_cycles&lt;br /&gt;
        return avE, avE2, avM, avM2, N&lt;br /&gt;
&lt;br /&gt;
== The effect of system size ==&lt;br /&gt;
&#039;&#039;&#039;Task 12&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A function was then used to plot average energy per spin and average magnetisation per spin against temperature from T = 0.25 K to T = 5 K in 0.25 K intervals. Error bars represent one standard deviation&#039;s worth of uncertainty for the calculation. This was done for 2x2, 4x4, 8x8, 16x16 and 32x32 size lattices, graphed in the same order:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising009.png|500px]]&lt;br /&gt;
&lt;br /&gt;
2x2&lt;br /&gt;
&lt;br /&gt;
[[File:Ising010.png|500px]]&lt;br /&gt;
&lt;br /&gt;
4x4&lt;br /&gt;
&lt;br /&gt;
[[File:Ising011.png|500px]]&lt;br /&gt;
&lt;br /&gt;
8x8&lt;br /&gt;
&lt;br /&gt;
[[File:Ising012.png|500px]]&lt;br /&gt;
&lt;br /&gt;
16x16&lt;br /&gt;
&lt;br /&gt;
[[File:Ising013.png|500px]]&lt;br /&gt;
&lt;br /&gt;
32x32&lt;br /&gt;
&lt;br /&gt;
All of the graphs show a convergence to a limiting value at high temperatures showing the Temperature a) ceases to affect magnetisation (the paramagnetic state) and b) subsequently ceases to affect energy stabilisation due to spin alignment (there are no more static alignment effects). The magnetisation graphs show an oscillating convergence because the spin of the hole system can flip near the Curie temperature as explained earlier. Both +1 and -1 spin systems provide the same energy stabilisation to the system, so energy does not oscillate in it&#039;s convergence. &lt;br /&gt;
&lt;br /&gt;
The error bars for both quantities peak around the Curie temperate presumably as at this point the system is most often undergoing full system spin flips, causing a large variance. At the beginning of the plot the variance is low as expected because there is little dynamic activity. At the end of the plot, even though there is a lot of noise and hence wild oscillation of the spins in the system, there is so much energy that almost any change is accepted, and so the extreme configurations (i.e. all aligned) rarely occur because statistically they are so unlikely to occur. This means the variation in energy and magnetisation for the most part varies within a smaller range and so the errorbars of one standard deviation (95% confidence) are smaller.&lt;br /&gt;
&lt;br /&gt;
The variation between the plots themselves can also be elucidated:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 13&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The average energy per spin plots were superimposed. What we see is the convergence of the energy to a certain curve for large lattices:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising014.png|500px]]&lt;br /&gt;
&lt;br /&gt;
This shows the lattice size is large enough to properly model long range effects as increasing the lattice size has little further effect.&lt;br /&gt;
&lt;br /&gt;
[[File:Pl2mag.png|500px]]&lt;br /&gt;
&lt;br /&gt;
The plot superimposing the magnetisations is also interesting. Firstly we see the magnitude of magnetisation per spin is pretty constant which is exactly what we would expect. Secondly we can see the oscillating convergence much more clearly. Finally we see the convergence is quickest for the smaller lattices, presumably because it&#039;s much easier kinetically to have an even distribution of spins.&lt;br /&gt;
&lt;br /&gt;
== Determining the heat capacity (C)==&lt;br /&gt;
&#039;&#039;&#039;Task 14&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
We know the average energy is equal to the probability of each energy times the energy. In terms of the partition function (Z, Statistical thermodynamics), we can write this and rearrange to get: &amp;lt;math&amp;gt;\left\langle E\right\rangle = -\frac{\partial}{\partial \beta}logZ&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Considering &amp;lt;math&amp;gt;\mathrm{Var}[E] = \left\langle E^2\right\rangle - \left\langle E\right\rangle^2&amp;lt;/math&amp;gt;, we can rearrange (by equating the squared average energy in both equations) to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{Var}[E] = -\frac{\partial \left\langle E\right\rangle}{\partial \beta}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using (The defenition of heat capacity):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;C = \frac{\partial \left\langle E\right\rangle}{\partial T}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We obtain via integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;C = \frac{\mathrm{Var}[E]}{k_B T^2}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 15&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Heat capacity can therefore be worked out using;&lt;br /&gt;
    x2 = np.array(np.loadtxt(&#039;2x2.dat&#039;))&lt;br /&gt;
    varEx2 = x2[:,2]-x2[:,1]**2&lt;br /&gt;
    cx2 = varEx2 / x2[:,0]**2&lt;br /&gt;
    # Plot and make the heat capacity per spin by dividing by lattice size&lt;br /&gt;
    pl.plot(x2[:,0], cx2/4, color = &#039;green&#039;)&lt;br /&gt;
for each lattice size, where 2x2.dat is a table with columns [Temperature, Average energy, Average squared energy, Average Magnetisation, Average Squared Magnetisation]. After running each simulation 5 times and then averaging for more accurate data, the Heat capacity per spin was subsequently plotted as a function of temperature and lattice size:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising016.png|500px]]&lt;br /&gt;
&lt;br /&gt;
The plot shows that as you increase the lattice size, there is a tighter convergence to some central peak, which implies an infinite lattice would contain a sharp, infinite peak. This is characteristic of a first order phase transition. Based on the observed behaviour of our spins, this phase transition would be the ferromagnetic - paramagnetic phase transition at the Curie temperature.&lt;br /&gt;
&lt;br /&gt;
== Finding the Curie temperature (Tc)==&lt;br /&gt;
&#039;&#039;&#039;Task 17&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A set of data ranging from 2x2 to 64x64 lattices using a more advanced simulation written in C++ was provided. This data was plotted and compared to the data from this experiment. An example plot is shown (for the 32x32 lattice size). The C++ data exhibits a much taller and sharper peak. This may be partially down to the low (T = 0.25 K spacing) resolution of the python data (which could be resolved better given more time). The non-peak regions match well which suggests that overall the experimental method is good.&lt;br /&gt;
&lt;br /&gt;
[[File:Ising017.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 18&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A plot was then written to fit a polynomial to the C++ data;&lt;br /&gt;
    import numpy as np&lt;br /&gt;
    import matplotlib.pyplot as pl&lt;br /&gt;
    data = np.loadtxt(&#039;32x32C.dat&#039;) #assume data is now a 2D array containing two columns, T and C&lt;br /&gt;
    T = data[:,0] #get the first column&lt;br /&gt;
    C = data[:,5] # get the second column&lt;br /&gt;
    #first we fit the polynomial to the data&lt;br /&gt;
    fit = np.polyfit(T, C, 3) # fit a third order polynomial&lt;br /&gt;
    #now we generate interpolated values of the fitted polynomial over the range of our function&lt;br /&gt;
    T_min = np.min(T)&lt;br /&gt;
    T_max = np.max(T)&lt;br /&gt;
    T_range = np.linspace(T_min, T_max, 1000) #generate 1000 evenly spaced points between T_min and T_max&lt;br /&gt;
    fitted_C_values = np.polyval(fit, T_range) # use the fit object to generate the corresponding values of C&lt;br /&gt;
    pl.plot(T_range, fitted_C_values, color = &#039;green&#039;)&lt;br /&gt;
    fit50 = np.polyfit(T, C, 50)&lt;br /&gt;
    fitted_C_values50 = np.polyval(fit50, T_range) # use the fit object to generate the corresponding values of C&lt;br /&gt;
    pl.plot(T_range, fitted_C_values50, color = &#039;red&#039;)&lt;br /&gt;
    x32C = np.array(np.loadtxt(&#039;32x32C.dat&#039;))&lt;br /&gt;
    pl.plot(x32C[:,0], x32C[:,5], color = &#039;black&#039;)&lt;br /&gt;
    pl.ylabel(&#039;Heat capacity per spin&#039;)&lt;br /&gt;
    pl.xlabel(&#039;Temperature&#039;)&lt;br /&gt;
    pl.legend([&#039;Third Order Fit&#039;, &#039;50 Order fit&#039;, &#039;Raw C++ Data&#039;])&lt;br /&gt;
    pl.show()&lt;br /&gt;
The graph shows both the original data, a polynomial fir of order 3 and a polynomial fit of order 50:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising018.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Even though using higher order polynomials provides a much more accurate fit, upon increasing the order we get diminishing returns on accurately modelling the peak.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 19&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
As we are mainly interested in finding the Curie temperature, an accurate fit of the peak is most important. An updated plot was executed to fit only in the region around the fit:&lt;br /&gt;
&lt;br /&gt;
    import numpy as np&lt;br /&gt;
    import matplotlib.pyplot as pl&lt;br /&gt;
&lt;br /&gt;
    data = np.loadtxt(&#039;32x32C.dat&#039;) #assume data is now a 2D array containing two columns, T and C&lt;br /&gt;
    T = data[:,0] #get the first column&lt;br /&gt;
    C = data[:,5] # get the second column&lt;br /&gt;
    Tmin = 2.1 #for example&lt;br /&gt;
    Tmax = 2.6 #for example&lt;br /&gt;
    selection = np.logical_and(T &amp;gt; Tmin, T &amp;lt; Tmax) #choose only those rows where both conditions are true&lt;br /&gt;
    peak_T_values = T[selection]&lt;br /&gt;
    peak_C_values = C[selection]&lt;br /&gt;
    selection = np.logical_and(T &amp;gt; Tmin, T &amp;lt; Tmax) #choose only those rows where both conditions are true&lt;br /&gt;
    #first we fit the polynomial to the data&lt;br /&gt;
    fit = np.polyfit(peak_T_values, peak_C_values, 3) # fit a third order polynomial&lt;br /&gt;
    #now we generate interpolated values of the fitted polynomial over the range of our function&lt;br /&gt;
    T_range = np.linspace(Tmin, Tmax, 1000) #generate 1000 evenly spaced points between T_min and T_max&lt;br /&gt;
    fitted_C_values = np.polyval(fit, T_range) # use the fit object to generate the corresponding values of C&lt;br /&gt;
    pl.plot(T_range, fitted_C_values, color = &#039;green&#039;)&lt;br /&gt;
    fit50 = np.polyfit(peak_T_values, peak_C_values, 50)&lt;br /&gt;
    fitted_C_values50 = np.polyval(fit50, T_range) # use the fit object to generate the corresponding values of C&lt;br /&gt;
    pl.plot(T_range, fitted_C_values50, color = &#039;red&#039;, linestyle=&#039;--&#039;)&lt;br /&gt;
    x32C = np.array(np.loadtxt(&#039;32x32C.dat&#039;))&lt;br /&gt;
    pl.plot(x32C[:,0], x32C[:,5], color = &#039;black&#039;, linestyle=&#039;:&#039;)&lt;br /&gt;
    pl.ylabel(&#039;Heat capacity per spin&#039;)&lt;br /&gt;
    pl.xlabel(&#039;Temperature&#039;)&lt;br /&gt;
    pl.legend([&#039;Third Order Fit&#039;, &#039;50 Order fit&#039;, &#039;Raw C++ Data&#039;])&lt;br /&gt;
    pl.show()&lt;br /&gt;
&lt;br /&gt;
[[File:Ising019.png|500px]]&lt;br /&gt;
&lt;br /&gt;
The peak was found to be at the [T, C] coordinate: [2.29369369, 1.85691773891] for the 32x32 lattice.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 20&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The above was then repeated to get the Curie temperature as a function of lattice size:&lt;br /&gt;
&lt;br /&gt;
    Lattice Size Curie Temperature&lt;br /&gt;
    2 2.5105105105105103&lt;br /&gt;
    4 2.4564564564564564&lt;br /&gt;
    8 2.3283283283283285&lt;br /&gt;
    16 2.31031031031031&lt;br /&gt;
    32 2.293693693693694&lt;br /&gt;
    64 2.2732732732732734&lt;br /&gt;
&lt;br /&gt;
It can be shown:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;T_{C, L} = \frac{A}{L} + T_{C,\infty}&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;T_{C, L}&amp;lt;/math&amp;gt; is the Curie temperature of an &amp;lt;math&amp;gt;L\times L&amp;lt;/math&amp;gt;lattice, &amp;lt;math&amp;gt;T_{C,\infty}&amp;lt;/math&amp;gt; is the Curie temperature of an infinite lattice, and &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt; is some constant.&lt;br /&gt;
&lt;br /&gt;
In order to obtain the Curie temperature of an infinite lattice, 1/L was plotted against Tc(L) and a linear fit was performed:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising020.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Tc for an infinite lattice is T at the Tc(L) intercept: &amp;lt;math&amp;gt;T_{C,\infty} = 2.27916772 J&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The data appears to have a reasonable fit, though there are only 5 data points, so the fit would benefit from using more lattice sizes.&lt;br /&gt;
&lt;br /&gt;
According to the literature, the theoretical Curie temperature for an infinite lattice is Tc = 2.269J &#039;&#039;(Source: Numerical Methods for Chemical Engineering: Applications in MATLAB&lt;br /&gt;
By Kenneth J. Beers.)&#039;&#039; This is only 0.01 away from the fitted result, which shows the experimental data and fitting equation are both fairly accurate.&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Sm_ising&amp;diff=645976</id>
		<title>Rep:Sm ising</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Sm_ising&amp;diff=645976"/>
		<updated>2017-11-22T11:57:30Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Ising Model Report - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== The Ising model, energy and magnetisation ==&lt;br /&gt;
The Ising model is a simple model which examines the magnetic phase behaviour of a system. The system is set up as an n-dimensional lattice of particles which are either spin up (+1) or spin down (-1). The interaction between any two particles that share a face is counted as an additive contribution towards the overall energy of the system. Each interaction is calculated by multiplying the two spins and then multiplying by some constant J to convert units to energy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 1:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In a lowest energy configuration, all spins will be oriented in the same direction (+1 or -1) to maximise the magnitude of the sum or the interacting spin pairs.&lt;br /&gt;
&lt;br /&gt;
Per dimension, there are two directions in which each spin can interact given that only neighbours sharing a face can interact (modelling the spins as cubes, weather arranged in a line, plane or box).&lt;br /&gt;
&lt;br /&gt;
This means per particle there are 2D interactions, where D = number of dimensions in the system.&lt;br /&gt;
&lt;br /&gt;
The total number of interactions is therefore 2DN/2, where we divide by 2 as each interaction is double counted when we sum interactions over all the particles, where N = number of particles in the system.&lt;br /&gt;
&lt;br /&gt;
Weather each interaction is -1 with -1 or 1 with 1, the magnitude will always be 1, so the total magnitude of the energy of all the interactions will be J * 1.0 * number of interactions where J is some constant converting the units of the energy from arbitrary units into joules.&lt;br /&gt;
&lt;br /&gt;
This simplifies to: Magnitude of the energy of all interactions = DNJ. We know the energy is negative as all spins in alignment correponds to the greatest energy reduction for the system, so we may conclude:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Lowest possible interaction energy for a system (E) = -DNJ&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Only two configurations give this state: when either all spins are +1 or all spins are -1. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;The multiplicity is therefore given by 2 * N!/N! (= 2) where N is the number of spins in the system.&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Entropy (S) = k ln(M) where k is the Boltzmann constant and M is the number of equivalent microstates, so the lowest entropy of the Ising system is given by:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;S = k ln(2)&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 2:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
From the lowest energy configuration, if one of the spins were to instantaneously flip, the new configuration would be all spins aligned but one; i.e all +1 with one -1 or all -1 with one +1.&lt;br /&gt;
&lt;br /&gt;
Multiplicity therefore = 2 * N!/(N - 1)!&lt;br /&gt;
&lt;br /&gt;
The entropy for the D =3, N =1000 system is therefore k ln(2 * (1000!/999!))&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;S = k ln(2 * (1000!/999!))&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;S = k ln(2000)&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In terms of the energy, one spin interacts with 6 neighbours in a 3D lattice. One positive interaction changing into one negative interaction increases the energy by 2J, so overall, flipping one spin leads to a 12J increase in energy to the system.&lt;br /&gt;
&lt;br /&gt;
=== Magnetisation ===&lt;br /&gt;
The magnetisation of the system is defined as the sum of all the spins in the system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 3:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
System 1:&lt;br /&gt;
&lt;br /&gt;
+ + + - -&lt;br /&gt;
&lt;br /&gt;
For system 1, the total magnetisation is 3 - 2:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Magnetisation = + 1&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
System 1:&lt;br /&gt;
&lt;br /&gt;
+ + + + -&lt;br /&gt;
&lt;br /&gt;
+ + + - -&lt;br /&gt;
&lt;br /&gt;
+ + + - -&lt;br /&gt;
&lt;br /&gt;
+ + - - -&lt;br /&gt;
&lt;br /&gt;
+ - - - -&lt;br /&gt;
&lt;br /&gt;
For system 1, the total magnetisation is 13 - 12:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Magnetisation = + 1&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
At absolute zero the entropic contribution would be minimised, so one would expect the energetic contribution to dominate and align all the spins.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;At absolute zero therefore, for a 3D system of 1000 spins, magnetisation = 1000&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Python (Energy and magnetisation) ==&lt;br /&gt;
&#039;&#039;&#039;Task 4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Functions to extract the energy and magnetisation of a system were then written in python;&lt;br /&gt;
&lt;br /&gt;
    def energy(self):&lt;br /&gt;
        &amp;quot;Return the total energy of the current lattice configuration.&amp;quot;&lt;br /&gt;
        # Function works by cycling through each element and then interacting with each neighbour on a grid of coordinates. The energy is halved to prevent double counting and made negative.&lt;br /&gt;
        energy = 0.0&lt;br /&gt;
        net_interaction = 0&lt;br /&gt;
        y = 0&lt;br /&gt;
        x = 0&lt;br /&gt;
        for row in self.lattice:&lt;br /&gt;
                for element in row:&lt;br /&gt;
                    # interact right&lt;br /&gt;
                    if x != self.n_cols - 1:&lt;br /&gt;
                        net_interaction += (element * self.lattice[y, x + 1])&lt;br /&gt;
                    else:&lt;br /&gt;
                        # if we are at the end element, interact with the adjacent system&lt;br /&gt;
                        net_interaction += (element * self.lattice[y, 0])&lt;br /&gt;
                    # interact left&lt;br /&gt;
                    if x != 0:&lt;br /&gt;
                        net_interaction += (element * self.lattice[y, x - 1])&lt;br /&gt;
                    else:&lt;br /&gt;
                        # if we are at the start element, interact with the adjacent system&lt;br /&gt;
                        net_interaction += (element * self.lattice[y, self.n_cols - 1])&lt;br /&gt;
                    # interact bottom&lt;br /&gt;
                    if y != self.n_rows - 1:&lt;br /&gt;
                        net_interaction += (element * self.lattice[y + 1, x])&lt;br /&gt;
                    else:&lt;br /&gt;
                        # if we are at the end element, interact with the adjacent system&lt;br /&gt;
                        net_interaction += (element * self.lattice[0, x])&lt;br /&gt;
                    # interact top&lt;br /&gt;
                    if y != 0:&lt;br /&gt;
                        net_interaction += (element * self.lattice[y - 1, x])&lt;br /&gt;
                    else:&lt;br /&gt;
                        # if we are at the start element, interact with the adjacent system&lt;br /&gt;
                        net_interaction += (element * self.lattice[self.n_rows - 1, x])&lt;br /&gt;
                    # iterate selected spin&lt;br /&gt;
                    if x == self.n_cols - 1:&lt;br /&gt;
                        x = 0&lt;br /&gt;
                        y += 1&lt;br /&gt;
                    else:&lt;br /&gt;
                        x += 1&lt;br /&gt;
        interaction_energy = - 0.5 * net_interaction&lt;br /&gt;
        return interaction_energy&lt;br /&gt;
&lt;br /&gt;
    def magnetisation(self):&lt;br /&gt;
        &amp;quot;Return the total magnetisation of the current lattice configuration.&amp;quot;&lt;br /&gt;
        magnetisation = 0&lt;br /&gt;
        for row in self.lattice:&lt;br /&gt;
            for element in row:&lt;br /&gt;
                magnetisation += element&lt;br /&gt;
        return magnetisation&lt;br /&gt;
&#039;&#039;&#039;Task 5&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;ILcheck.py&#039; script was then ran multiple times to check the energy and magnetisation functions gave consistently correct results:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising001.png|400px]][[File:Ising002.png|400px]][[File:Ising003.png|400px]]&lt;br /&gt;
&lt;br /&gt;
== Python (Monte Carlo Function) ==&lt;br /&gt;
&#039;&#039;&#039;Task 6&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Let us consider a system with 100 spins. Considering each spin has two possible states, there are &amp;lt;math&amp;gt;2^{100} = 1.27 *10^{30}&amp;lt;/math&amp;gt; potential configurations of the system. Even if we could analyse &amp;lt;math&amp;gt;10^9&amp;lt;/math&amp;gt; configurations per second, it would still take us &amp;lt;math&amp;gt;1.27 *10^{21} s&amp;lt;/math&amp;gt; to calculate the magnetisations of all of the configurations to take an average. Clearly this would take too long so we must look for an alternative method of gathering data on the behaviour of the energy. One way of doing this is using a Monte Carlo simulation where we start with a random configuration and randomly flip spins. We accept the new configuration if there is an energy reduction. Otherwise we accept the new configuration at a rate proportional to the Boltzmann factor as this reflects how often a particle would theoretically have enough energy to flip to a higher energy state.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 7&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A Monte-Carlo simulation was coded in python as follows:&lt;br /&gt;
&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        &amp;quot;preforms a single Monte Carlo step&amp;quot;&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        current_lattice = self.lattice&lt;br /&gt;
        # create a new lattice with on spin flipped&lt;br /&gt;
            #the following two lines select the coordinates of the random spin&lt;br /&gt;
        random_i = np.random.choice(range(self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(self.n_cols))&lt;br /&gt;
        self.lattice[random_i][random_j] =  -self.lattice[random_i][random_j]&lt;br /&gt;
        new_E = self.energy()&lt;br /&gt;
        # compare energies and decided what configuration to adopt, then update parameters&lt;br /&gt;
        dE = new_E - energy&lt;br /&gt;
        if dE &amp;lt; 0:&lt;br /&gt;
            # print(&#039;new energy lower: lattice updated&#039;)&lt;br /&gt;
            pass&lt;br /&gt;
        else:&lt;br /&gt;
            # the following line will choose a random number in the range (0,1)&lt;br /&gt;
            randNumb = np.random.random()&lt;br /&gt;
            if randNumb &amp;lt;= math.exp(-dE/T):&lt;br /&gt;
                # print(&#039;lattice was updated&#039;)&lt;br /&gt;
                pass&lt;br /&gt;
            else:&lt;br /&gt;
                # print(&#039;lattice was not updated&#039;)&lt;br /&gt;
                self.lattice[random_i][random_j] =  -self.lattice[random_i][random_j]&lt;br /&gt;
        self.E += self.energy()&lt;br /&gt;
        self.E2 += self.energy()**2&lt;br /&gt;
        self.M += self.magnetisation()&lt;br /&gt;
        self.M2 += self.magnetisation()**2&lt;br /&gt;
        # converts cycle index x to cycle number x + 1 (the next machine cycle step number)&lt;br /&gt;
        # In other words increments the counter of number of cycles&lt;br /&gt;
        self.n_cycles += 1&lt;br /&gt;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        &amp;quot;returns statistical data collected during a Monte Carlo simulation&amp;quot;&lt;br /&gt;
        avE = self.E / self.n_cycles&lt;br /&gt;
        avE2 = self.E2 / self.n_cycles&lt;br /&gt;
        avM = self.M / self.n_cycles&lt;br /&gt;
        avM2 = self.M2 / self.n_cycles&lt;br /&gt;
        N = self.n_cycles&lt;br /&gt;
        return avE, avE2, avM, avM2, N&lt;br /&gt;
&#039;&#039;&#039;Task 8&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
When the temperature of the system is above the Curie Temperature (Tc), the system is paramagnetic at thermodynamic equilibrium, i.e. the spins are oriented randomly in the absence of an external magnetic field. When the temperature of the system is below the Curie Temperature, the system is ferromagnetic at thermodynamic equilibrium (spins align). In the case T &amp;lt; Tc, one would therefore expect the system to spontaneously magnetise (spins align) as it attains the most thermodynamically stable state.&lt;br /&gt;
&lt;br /&gt;
Indeed, when we run our Monte Carlo simulation for an 8x8 lattice at T = 0.5 K, it can be seen that the spins tend toward alignment in on direction as the energy minimises;&lt;br /&gt;
&lt;br /&gt;
[[File:Ising004.png|center]]&lt;br /&gt;
    Averaged quantities:&lt;br /&gt;
    E =  -1.96841896186&lt;br /&gt;
    E*E =  3.88120282707&lt;br /&gt;
    M =  -0.991326800847&lt;br /&gt;
    M*M =  0.983257746292&lt;br /&gt;
&lt;br /&gt;
== Accelerating the code ==&lt;br /&gt;
&#039;&#039;&#039;Task 9&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In an attempt to accelerate the code and save time, the energy() and magnetisation() functions were made more efficient using functions within the numpy python library:&lt;br /&gt;
&lt;br /&gt;
    def energy(self):&lt;br /&gt;
        &amp;quot;Improved energy function which implements numpy&#039;s roll and multiply functions&amp;quot;&lt;br /&gt;
        # multiply by a shifted grid to apply vertical energy contribution&lt;br /&gt;
        vertical_energy = -np.sum(np.multiply(self.lattice, np.roll(self.lattice, 1, axis = 0)))&lt;br /&gt;
        # multiply by a shifted grid to apply the horizontal energy contribution&lt;br /&gt;
        total_energy = vertical_energy - np.sum(np.multiply(self.lattice, np.roll(self.lattice, 1, axis = 1)))&lt;br /&gt;
        return total_energy&lt;br /&gt;
&lt;br /&gt;
    def magnetisation(self):&lt;br /&gt;
        &amp;quot;Improved magnetisation function that implements numpy&#039;s sum function:&amp;quot;&lt;br /&gt;
        return np.sum(self.lattice)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 10&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Time trials were used to compare the speed of the old and updated energy functions:&lt;br /&gt;
&lt;br /&gt;
    New function:&lt;br /&gt;
    2.4918089999999893 s&lt;br /&gt;
    2.4761589999999956 s&lt;br /&gt;
    2.540256999999997 s&lt;br /&gt;
    2.4700420000000065 s&lt;br /&gt;
    2.5968489999999917 s&lt;br /&gt;
    &lt;br /&gt;
    Average = 2.52 s&lt;br /&gt;
    Standard error of average = 0.024 s&lt;br /&gt;
    &lt;br /&gt;
    Old function:&lt;br /&gt;
    10.844294 s&lt;br /&gt;
    10.496529000000002 s&lt;br /&gt;
    10.151754999999998 s&lt;br /&gt;
    10.489855999999996 s&lt;br /&gt;
    9.988599999999998 s&lt;br /&gt;
    &lt;br /&gt;
    Average = 10.39 s&lt;br /&gt;
    Standard error of average = 0.149 s&lt;br /&gt;
&lt;br /&gt;
The result is the improved function only takes 24.3 % of the time took by the old function to do the same thing.&lt;br /&gt;
==The effect of temperature==&lt;br /&gt;
The following plots were produced by running 150000 steps of the Monte Carlo simulation at T = 0.5 K and T = 2.0 K respectively:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising005.png|500px]][[File:Ising006.png|500px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Ising007.png|500px]][[File:Ising008.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Note, in the second system, we see that there must be a realistic chance for the whole system to flip the net spin direction as this is what can be seen from the graph to occur. This happens because in this system there are two global minimum points on the potential energy surface separated by a barrier. At this temperature there is enough energy to only occasionally overcome this barrier.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 11&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Looking at the dynamics of the systems, we can see in the temperature region in which we are working, the region after 3000 steps should be a sufficient representation of the system at equilibrium. The Monte Carlo step and statistics functions were updated to only begin the statistics functionality after 3000 steps:&lt;br /&gt;
&lt;br /&gt;
    # Defines first cycle in which statistical data is collected&lt;br /&gt;
    statsStartStep = 3000&lt;br /&gt;
    # Converts cycle nummber into the machine read index of the cycle (humans count from 1, machine indexes from 0)&lt;br /&gt;
    statsStartStep -= 1&lt;br /&gt;
&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        &amp;quot;preforms a single Monte Carlo step&amp;quot;&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        current_lattice = self.lattice&lt;br /&gt;
        # create a new lattice with on spin flipped&lt;br /&gt;
            #the following two lines select the coordinates of the random spin&lt;br /&gt;
        random_i = np.random.choice(range(self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(self.n_cols))&lt;br /&gt;
        self.lattice[random_i][random_j] =  -self.lattice[random_i][random_j]&lt;br /&gt;
        new_E = self.energy()&lt;br /&gt;
        # compare energies and decided what configuration to adopt, then update parameters&lt;br /&gt;
        dE = new_E - energy&lt;br /&gt;
        if dE &amp;lt; 0:&lt;br /&gt;
            # print(&#039;new energy lower: lattice updated&#039;)&lt;br /&gt;
            pass&lt;br /&gt;
        else:&lt;br /&gt;
            # the following line will choose a random number in the range (0,1)&lt;br /&gt;
            randNumb = np.random.random()&lt;br /&gt;
            if randNumb &amp;lt;= math.exp(-dE/T):&lt;br /&gt;
                # print(&#039;lattice was updated&#039;)&lt;br /&gt;
                pass&lt;br /&gt;
            else:&lt;br /&gt;
                # print(&#039;lattice was not updated&#039;)&lt;br /&gt;
                self.lattice[random_i][random_j] =  -self.lattice[random_i][random_j]&lt;br /&gt;
        # Update the running total IF we are in the region we are gathering stats for&lt;br /&gt;
        if self.n_cycles &amp;gt;= self.statsStartStep:&lt;br /&gt;
            self.E += self.energy()&lt;br /&gt;
            self.E2 += self.energy()**2&lt;br /&gt;
            self.M += self.magnetisation()&lt;br /&gt;
            self.M2 += self.magnetisation()**2&lt;br /&gt;
        # converts cycle index x to cycle number x + 1 (the next machine cycle step number)&lt;br /&gt;
        self.n_cycles += 1&lt;br /&gt;
        # print(self.n_cycles)&lt;br /&gt;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        # Updated statistics function&lt;br /&gt;
        if self.n_cycles &amp;gt;= self.statsStartStep:&lt;br /&gt;
            avE = self.E / (self.n_cycles - self.statsStartStep)&lt;br /&gt;
            avE2 = self.E2 / (self.n_cycles - self.statsStartStep)&lt;br /&gt;
            avM = self.M / (self.n_cycles - self.statsStartStep)&lt;br /&gt;
            avM2 = self.M2 / (self.n_cycles - self.statsStartStep)&lt;br /&gt;
            N = self.n_cycles&lt;br /&gt;
        return avE, avE2, avM, avM2, N&lt;br /&gt;
&lt;br /&gt;
== The effect of system size ==&lt;br /&gt;
&#039;&#039;&#039;Task 12&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A function was then used to plot average energy per spin and average magnetisation per spin against temperature from T = 0.25 K to T = 5 K in 0.25 K intervals. Error bars represent one standard deviation&#039;s worth of uncertainty for the calculation. This was done for 2x2, 4x4, 8x8, 16x16 and 32x32 size lattices, graphed in the same order:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising009.png|500px]]&lt;br /&gt;
&lt;br /&gt;
2x2&lt;br /&gt;
&lt;br /&gt;
[[File:Ising010.png|500px]]&lt;br /&gt;
&lt;br /&gt;
4x4&lt;br /&gt;
&lt;br /&gt;
[[File:Ising011.png|500px]]&lt;br /&gt;
&lt;br /&gt;
8x8&lt;br /&gt;
&lt;br /&gt;
[[File:Ising012.png|500px]]&lt;br /&gt;
&lt;br /&gt;
16x16&lt;br /&gt;
&lt;br /&gt;
[[File:Ising013.png|500px]]&lt;br /&gt;
&lt;br /&gt;
32x32&lt;br /&gt;
&lt;br /&gt;
All of the graphs show a convergence to a limiting value at high temperatures showing the Temperature a) ceases to affect magnetisation (the paramagnetic state) and b) subsequently ceases to affect energy stabilisation due to spin alignment (there are no more static alignment effects). The magnetisation graphs show an oscillating convergence because the spin of the hole system can flip near the Curie temperature as explained earlier. Both +1 and -1 spin systems provide the same energy stabilisation to the system, so energy does not oscillate in it&#039;s convergence. &lt;br /&gt;
&lt;br /&gt;
The error bars for both quantities peak around the Curie temperate presumably as at this point the system is most often undergoing full system spin flips, causing a large variance. At the beginning of the plot the variance is low as expected because there is little dynamic activity. At the end of the plot, even though there is a lot of noise and hence wild oscillation of the spins in the system, there is so much energy that almost any change is accepted, and so the extreme configurations (i.e. all aligned) rarely occur because statistically they are so unlikely to occur. This means the variation in energy and magnetisation for the most part varies within a smaller range and so the errorbars of one standard deviation (95% confidence) are smaller.&lt;br /&gt;
&lt;br /&gt;
The variation between the plots themselves can also be elucidated:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 13&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The average energy per spin plots were superimposed. What we see is the convergence of the energy to a certain curve for large lattices:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising014.png|500px]]&lt;br /&gt;
&lt;br /&gt;
This shows the lattice size is large enough to properly model long range effects as increasing the lattice size has little further effect.&lt;br /&gt;
&lt;br /&gt;
[[File:Pl2mag.png|500px]]&lt;br /&gt;
&lt;br /&gt;
The plot superimposing the magnetisations is also interesting. Firstly we see the magnitude of magnetisation per spin is pretty constant which is exactly what we would expect. Secondly we can see the oscillating convergence much more clearly. Finally we see the convergence is quickest for the smaller lattices, presumably because it&#039;s much easier kinetically to have an even distribution of spins.&lt;br /&gt;
&lt;br /&gt;
== Determining the heat capacity (C)==&lt;br /&gt;
&#039;&#039;&#039;Task 14&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
We know the average energy is equal to the probability of each energy times the energy. In terms of the partition function (Z, Statistical thermodynamics), we can write this and rearrange to get: &amp;lt;math&amp;gt;\left\langle E\right\rangle = -\frac{\partial}{\partial \beta}logZ&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Considering &amp;lt;math&amp;gt;\mathrm{Var}[E] = \left\langle E^2\right\rangle - \left\langle E\right\rangle^2&amp;lt;/math&amp;gt;, we can rearrange (by equating the squared average energy in both equations) to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{Var}[E] = -\frac{\partial \left\langle E\right\rangle}{\partial \beta}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using (The defenition of heat capacity):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;C = \frac{\partial \left\langle E\right\rangle}{\partial T}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We obtain via integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;C = \frac{\mathrm{Var}[E]}{k_B T^2}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 15&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Heat capacity can therefore be worked out using;&lt;br /&gt;
    x2 = np.array(np.loadtxt(&#039;2x2.dat&#039;))&lt;br /&gt;
    varEx2 = x2[:,2]-x2[:,1]**2&lt;br /&gt;
    cx2 = varEx2 / x2[:,0]**2&lt;br /&gt;
    # Plot and make the heat capacity per spin by dividing by lattice size&lt;br /&gt;
    pl.plot(x2[:,0], cx2/4, color = &#039;green&#039;)&lt;br /&gt;
for each lattice size, where 2x2.dat is a table with columns [Temperature, Average energy, Average squared energy, Average Magnetisation, Average Squared Magnetisation]. After running each simulation 5 times and then averaging for more accurate data, the Heat capacity per spin was subsequently plotted as a function of temperature and lattice size:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising016.png|500px]]&lt;br /&gt;
&lt;br /&gt;
The plot shows that as you increase the lattice size, there is a tighter convergence to some central peak, which implies an infinite lattice would contain a sharp, infinite peak. This is characteristic of a first order phase transition. Based on the observed behaviour of our spins, this phase transition would be the ferromagnetic - paramagnetic phase transition at the Curie temperature.&lt;br /&gt;
&lt;br /&gt;
== Finding the Curie temperature (Tc)==&lt;br /&gt;
&#039;&#039;&#039;Task 17&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A set of data ranging from 2x2 to 64x64 lattices using a more advanced simulation written in C++ was provided. This data was plotted and compared to the data from this experiment. An example plot is shown (for the 32x32 lattice size). The C++ data exhibits a much taller and sharper peak. This may be partially down to the low (T = 0.25 K spacing) resolution of the python data (which could be resolved better given more time). The non-peak regions match well which suggests that overall the experimental method is good.&lt;br /&gt;
&lt;br /&gt;
[[File:Ising017.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 18&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A plot was then written to fit a polynomial to the C++ data;&lt;br /&gt;
    import numpy as np&lt;br /&gt;
    import matplotlib.pyplot as pl&lt;br /&gt;
    data = np.loadtxt(&#039;32x32C.dat&#039;) #assume data is now a 2D array containing two columns, T and C&lt;br /&gt;
    T = data[:,0] #get the first column&lt;br /&gt;
    C = data[:,5] # get the second column&lt;br /&gt;
    #first we fit the polynomial to the data&lt;br /&gt;
    fit = np.polyfit(T, C, 3) # fit a third order polynomial&lt;br /&gt;
    #now we generate interpolated values of the fitted polynomial over the range of our function&lt;br /&gt;
    T_min = np.min(T)&lt;br /&gt;
    T_max = np.max(T)&lt;br /&gt;
    T_range = np.linspace(T_min, T_max, 1000) #generate 1000 evenly spaced points between T_min and T_max&lt;br /&gt;
    fitted_C_values = np.polyval(fit, T_range) # use the fit object to generate the corresponding values of C&lt;br /&gt;
    pl.plot(T_range, fitted_C_values, color = &#039;green&#039;)&lt;br /&gt;
    fit50 = np.polyfit(T, C, 50)&lt;br /&gt;
    fitted_C_values50 = np.polyval(fit50, T_range) # use the fit object to generate the corresponding values of C&lt;br /&gt;
    pl.plot(T_range, fitted_C_values50, color = &#039;red&#039;)&lt;br /&gt;
    x32C = np.array(np.loadtxt(&#039;32x32C.dat&#039;))&lt;br /&gt;
    pl.plot(x32C[:,0], x32C[:,5], color = &#039;black&#039;)&lt;br /&gt;
    pl.ylabel(&#039;Heat capacity per spin&#039;)&lt;br /&gt;
    pl.xlabel(&#039;Temperature&#039;)&lt;br /&gt;
    pl.legend([&#039;Third Order Fit&#039;, &#039;50 Order fit&#039;, &#039;Raw C++ Data&#039;])&lt;br /&gt;
    pl.show()&lt;br /&gt;
The graph shows both the original data, a polynomial fir of order 3 and a polynomial fit of order 50:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising018.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Even though using higher order polynomials provides a much more accurate fit, upon increasing the order we get diminishing returns on accurately modelling the peak.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 19&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
As we are mainly interested in finding the Curie temperature, an accurate fit of the peak is most important. An updated plot was executed to fit only in the region around the fit:&lt;br /&gt;
&lt;br /&gt;
    import numpy as np&lt;br /&gt;
    import matplotlib.pyplot as pl&lt;br /&gt;
&lt;br /&gt;
    data = np.loadtxt(&#039;32x32C.dat&#039;) #assume data is now a 2D array containing two columns, T and C&lt;br /&gt;
    T = data[:,0] #get the first column&lt;br /&gt;
    C = data[:,5] # get the second column&lt;br /&gt;
    Tmin = 2.1 #for example&lt;br /&gt;
    Tmax = 2.6 #for example&lt;br /&gt;
    selection = np.logical_and(T &amp;gt; Tmin, T &amp;lt; Tmax) #choose only those rows where both conditions are true&lt;br /&gt;
    peak_T_values = T[selection]&lt;br /&gt;
    peak_C_values = C[selection]&lt;br /&gt;
    selection = np.logical_and(T &amp;gt; Tmin, T &amp;lt; Tmax) #choose only those rows where both conditions are true&lt;br /&gt;
    #first we fit the polynomial to the data&lt;br /&gt;
    fit = np.polyfit(peak_T_values, peak_C_values, 3) # fit a third order polynomial&lt;br /&gt;
    #now we generate interpolated values of the fitted polynomial over the range of our function&lt;br /&gt;
    T_range = np.linspace(Tmin, Tmax, 1000) #generate 1000 evenly spaced points between T_min and T_max&lt;br /&gt;
    fitted_C_values = np.polyval(fit, T_range) # use the fit object to generate the corresponding values of C&lt;br /&gt;
    pl.plot(T_range, fitted_C_values, color = &#039;green&#039;)&lt;br /&gt;
    fit50 = np.polyfit(peak_T_values, peak_C_values, 50)&lt;br /&gt;
    fitted_C_values50 = np.polyval(fit50, T_range) # use the fit object to generate the corresponding values of C&lt;br /&gt;
    pl.plot(T_range, fitted_C_values50, color = &#039;red&#039;, linestyle=&#039;--&#039;)&lt;br /&gt;
    x32C = np.array(np.loadtxt(&#039;32x32C.dat&#039;))&lt;br /&gt;
    pl.plot(x32C[:,0], x32C[:,5], color = &#039;black&#039;, linestyle=&#039;:&#039;)&lt;br /&gt;
    pl.ylabel(&#039;Heat capacity per spin&#039;)&lt;br /&gt;
    pl.xlabel(&#039;Temperature&#039;)&lt;br /&gt;
    pl.legend([&#039;Third Order Fit&#039;, &#039;50 Order fit&#039;, &#039;Raw C++ Data&#039;])&lt;br /&gt;
    pl.show()&lt;br /&gt;
&lt;br /&gt;
[[File:Ising019.png|500px]]&lt;br /&gt;
&lt;br /&gt;
The peak was found to be at the [T, C] coordinate: [2.29369369, 1.85691773891] for the 32x32 lattice.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 20&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The above was then repeated to get the Curie temperature as a function of lattice size:&lt;br /&gt;
&lt;br /&gt;
    Lattice Size Curie Temperature&lt;br /&gt;
    2 2.5105105105105103&lt;br /&gt;
    4 2.4564564564564564&lt;br /&gt;
    8 2.3283283283283285&lt;br /&gt;
    16 2.31031031031031&lt;br /&gt;
    32 2.293693693693694&lt;br /&gt;
    64 2.2732732732732734&lt;br /&gt;
&lt;br /&gt;
It can be show:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;T_{C, L} = \frac{A}{L} + T_{C,\infty}&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;T_{C, L}&amp;lt;/math&amp;gt; is the Curie temperature of an &amp;lt;math&amp;gt;L\times L&amp;lt;/math&amp;gt;lattice, &amp;lt;math&amp;gt;T_{C,\infty}&amp;lt;/math&amp;gt; is the Curie temperature of an infinite lattice, and &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt; is some constant.&lt;br /&gt;
&lt;br /&gt;
In order to obtain the Curie temperature of an infinite lattice, 1/L was plotted against Tc(L) and a linear fit was performed:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising020.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Tc for an infinite lattice is T at the Tc(L) intercept: &amp;lt;math&amp;gt;T_{C,\infty} = 2.27916772 J&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The data appears to have a reasonable fit, though there are only 5 data points, so the fit would benefit from using more lattice sizes.&lt;br /&gt;
&lt;br /&gt;
According to the literature, the theoretical Curie temperature for an infinite lattice is Tc = 2.269J Source: Numerical Methods for Chemical Engineering: Applications in MATLAB&lt;br /&gt;
By Kenneth J. Beers. This is only 0.01 away from the fitted result, which shows the experimental data and fitting equation are both fairly accurate.&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Sm_ising&amp;diff=645953</id>
		<title>Rep:Sm ising</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Sm_ising&amp;diff=645953"/>
		<updated>2017-11-22T11:38:31Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: /* Determining the heat capacity */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Ising Model Report - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== The Ising model, energy and magnetisation ==&lt;br /&gt;
The Ising model is a simple model which examines the magnetic phase behaviour of a system. The system is set up as an n-dimensional lattice of particles which are either spin up (+1) or spin down (-1). The interaction between any two particles that share a face is counted as an additive contribution towards the overall energy of the system. Each interaction is calculated by multiplying the two spins and then multiplying by some constant J to convert units to energy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 1:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In a lowest energy configuration, all spins will be oriented in the same direction (+1 or -1) to maximise the magnitude of the sum or the interacting spin pairs.&lt;br /&gt;
&lt;br /&gt;
Per dimension, there are two directions in which each spin can interact given that only neighbours sharing a face can interact (modelling the spins as cubes, weather arranged in a line, plane or box).&lt;br /&gt;
&lt;br /&gt;
This means per particle there are 2D interactions, where D = number of dimensions in the system.&lt;br /&gt;
&lt;br /&gt;
The total number of interactions is therefore 2DN/2, where we divide by 2 as each interaction is double counted when we sum interactions over all the particles, where N = number of particles in the system.&lt;br /&gt;
&lt;br /&gt;
Weather each interaction is -1 with -1 or 1 with 1, the magnitude will always be 1, so the total magnitude of the energy of all the interactions will be J * 1.0 * number of interactions where J is some constant converting the units of the energy from arbitrary units into joules.&lt;br /&gt;
&lt;br /&gt;
This simplifies to: Magnitude of the energy of all interactions = DNJ. We know the energy is negative as all spins in alignment correponds to the greatest energy reduction for the system, so we may conclude:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Lowest possible interaction energy for a system (E) = -DNJ&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Only two configurations give this state: when either all spins are +1 or all spins are -1. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;The multiplicity is therefore given by 2 * N!/N! (= 2) where N is the number of spins in the system.&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Entropy (S) = k ln(M) where k is the Boltzmann constant and M is the number of equivalent microstates, so the lowest entropy of the Ising system is given by:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;S = k ln(2)&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 2:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
From the lowest energy configuration, if one of the spins were to instantaneously flip, the new configuration would be all spins aligned but one; i.e all +1 with one -1 or all -1 with one +1.&lt;br /&gt;
&lt;br /&gt;
Multiplicity therefore = 2 * N!/(N - 1)!&lt;br /&gt;
&lt;br /&gt;
The entropy for the D =3, N =1000 system is therefore k ln(2 * (1000!/999!))&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;S = k ln(2 * (1000!/999!))&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;S = k ln(2000)&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In terms of the energy, one spin interacts with 6 neighbours in a 3D lattice. One positive interaction changing into one negative interaction increases the energy by 2J, so overall, flipping one spin leads to a 12J increase in energy to the system.&lt;br /&gt;
&lt;br /&gt;
=== Magnetisation ===&lt;br /&gt;
The magnetisation of the system is defined as the sum of all the spins in the system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 3:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
System 1:&lt;br /&gt;
&lt;br /&gt;
+ + + - -&lt;br /&gt;
&lt;br /&gt;
For system 1, the total magnetisation is 3 - 2:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Magnetisation = + 1&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
System 1:&lt;br /&gt;
&lt;br /&gt;
+ + + + -&lt;br /&gt;
&lt;br /&gt;
+ + + - -&lt;br /&gt;
&lt;br /&gt;
+ + + - -&lt;br /&gt;
&lt;br /&gt;
+ + - - -&lt;br /&gt;
&lt;br /&gt;
+ - - - -&lt;br /&gt;
&lt;br /&gt;
For system 1, the total magnetisation is 13 - 12:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Magnetisation = + 1&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
At absolute zero the entropic contribution would be minimised, so one would expect the energetic contribution to dominate and align all the spins.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;At absolute zero therefore, for a 3D system of 1000 spins, magnetisation = 1000&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Python (Energy and magnetisation) ==&lt;br /&gt;
&#039;&#039;&#039;Task 4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Functions to extract the energy and magnetisation of a system were then written in python;&lt;br /&gt;
&lt;br /&gt;
    def energy(self):&lt;br /&gt;
        &amp;quot;Return the total energy of the current lattice configuration.&amp;quot;&lt;br /&gt;
        # Function works by cycling through each element and then interacting with each neighbour on a grid of coordinates. The energy is halved to prevent double counting and made negative.&lt;br /&gt;
        energy = 0.0&lt;br /&gt;
        net_interaction = 0&lt;br /&gt;
        y = 0&lt;br /&gt;
        x = 0&lt;br /&gt;
        for row in self.lattice:&lt;br /&gt;
                for element in row:&lt;br /&gt;
                    # interact right&lt;br /&gt;
                    if x != self.n_cols - 1:&lt;br /&gt;
                        net_interaction += (element * self.lattice[y, x + 1])&lt;br /&gt;
                    else:&lt;br /&gt;
                        # if we are at the end element, interact with the adjacent system&lt;br /&gt;
                        net_interaction += (element * self.lattice[y, 0])&lt;br /&gt;
                    # interact left&lt;br /&gt;
                    if x != 0:&lt;br /&gt;
                        net_interaction += (element * self.lattice[y, x - 1])&lt;br /&gt;
                    else:&lt;br /&gt;
                        # if we are at the start element, interact with the adjacent system&lt;br /&gt;
                        net_interaction += (element * self.lattice[y, self.n_cols - 1])&lt;br /&gt;
                    # interact bottom&lt;br /&gt;
                    if y != self.n_rows - 1:&lt;br /&gt;
                        net_interaction += (element * self.lattice[y + 1, x])&lt;br /&gt;
                    else:&lt;br /&gt;
                        # if we are at the end element, interact with the adjacent system&lt;br /&gt;
                        net_interaction += (element * self.lattice[0, x])&lt;br /&gt;
                    # interact top&lt;br /&gt;
                    if y != 0:&lt;br /&gt;
                        net_interaction += (element * self.lattice[y - 1, x])&lt;br /&gt;
                    else:&lt;br /&gt;
                        # if we are at the start element, interact with the adjacent system&lt;br /&gt;
                        net_interaction += (element * self.lattice[self.n_rows - 1, x])&lt;br /&gt;
                    # iterate selected spin&lt;br /&gt;
                    if x == self.n_cols - 1:&lt;br /&gt;
                        x = 0&lt;br /&gt;
                        y += 1&lt;br /&gt;
                    else:&lt;br /&gt;
                        x += 1&lt;br /&gt;
        interaction_energy = - 0.5 * net_interaction&lt;br /&gt;
        return interaction_energy&lt;br /&gt;
&lt;br /&gt;
    def magnetisation(self):&lt;br /&gt;
        &amp;quot;Return the total magnetisation of the current lattice configuration.&amp;quot;&lt;br /&gt;
        magnetisation = 0&lt;br /&gt;
        for row in self.lattice:&lt;br /&gt;
            for element in row:&lt;br /&gt;
                magnetisation += element&lt;br /&gt;
        return magnetisation&lt;br /&gt;
&#039;&#039;&#039;Task 5&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;ILcheck.py&#039; script was then ran multiple times to check the energy and magnetisation functions gave consistently correct results:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising001.png|400px]][[File:Ising002.png|400px]][[File:Ising003.png|400px]]&lt;br /&gt;
&lt;br /&gt;
== Python (Monte Carlo Function) ==&lt;br /&gt;
&#039;&#039;&#039;Task 6&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Let us consider a system with 100 spins. Considering each spin has two possible states, there are &amp;lt;math&amp;gt;2^{100} = 1.27 *10^{30}&amp;lt;/math&amp;gt; potential configurations of the system. Even if we could analyse &amp;lt;math&amp;gt;10^9&amp;lt;/math&amp;gt; configurations per second, it would still take us &amp;lt;math&amp;gt;1.27 *10^{21} s&amp;lt;/math&amp;gt; to calculate the magnetisations of all of the configurations to take an average. Clearly this would take too long so we must look for an alternative method of gathering data on the behaviour of the energy. One way of doing this is using a Monte Carlo simulation where we start with a random configuration and randomly flip spins. We accept the new configuration if there is an energy reduction. Otherwise we accept the new configuration at a rate proportional to the Boltzmann factor as this reflects how often a particle would theoretically have enough energy to flip to a higher energy state.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 7&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A Monte-Carlo simulation was coded in python as follows:&lt;br /&gt;
&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        &amp;quot;preforms a single Monte Carlo step&amp;quot;&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        current_lattice = self.lattice&lt;br /&gt;
        # create a new lattice with on spin flipped&lt;br /&gt;
            #the following two lines select the coordinates of the random spin&lt;br /&gt;
        random_i = np.random.choice(range(self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(self.n_cols))&lt;br /&gt;
        self.lattice[random_i][random_j] =  -self.lattice[random_i][random_j]&lt;br /&gt;
        new_E = self.energy()&lt;br /&gt;
        # compare energies and decided what configuration to adopt, then update parameters&lt;br /&gt;
        dE = new_E - energy&lt;br /&gt;
        if dE &amp;lt; 0:&lt;br /&gt;
            # print(&#039;new energy lower: lattice updated&#039;)&lt;br /&gt;
            pass&lt;br /&gt;
        else:&lt;br /&gt;
            # the following line will choose a random number in the range (0,1)&lt;br /&gt;
            randNumb = np.random.random()&lt;br /&gt;
            if randNumb &amp;lt;= math.exp(-dE/T):&lt;br /&gt;
                # print(&#039;lattice was updated&#039;)&lt;br /&gt;
                pass&lt;br /&gt;
            else:&lt;br /&gt;
                # print(&#039;lattice was not updated&#039;)&lt;br /&gt;
                self.lattice[random_i][random_j] =  -self.lattice[random_i][random_j]&lt;br /&gt;
        self.E += self.energy()&lt;br /&gt;
        self.E2 += self.energy()**2&lt;br /&gt;
        self.M += self.magnetisation()&lt;br /&gt;
        self.M2 += self.magnetisation()**2&lt;br /&gt;
        # converts cycle index x to cycle number x + 1 (the next machine cycle step number)&lt;br /&gt;
        # In other words increments the counter of number of cycles&lt;br /&gt;
        self.n_cycles += 1&lt;br /&gt;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        &amp;quot;returns statistical data collected during a Monte Carlo simulation&amp;quot;&lt;br /&gt;
        avE = self.E / self.n_cycles&lt;br /&gt;
        avE2 = self.E2 / self.n_cycles&lt;br /&gt;
        avM = self.M / self.n_cycles&lt;br /&gt;
        avM2 = self.M2 / self.n_cycles&lt;br /&gt;
        N = self.n_cycles&lt;br /&gt;
        return avE, avE2, avM, avM2, N&lt;br /&gt;
&#039;&#039;&#039;Task 8&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
When the temperature of the system is above the Curie Temperature (Tc), the system is paramagnetic at thermodynamic equilibrium, i.e. the spins are oriented randomly in the absence of an external magnetic field. When the temperature of the system is below the Curie Temperature, the system is ferromagnetic at thermodynamic equilibrium (spins align). In the case T &amp;lt; Tc, one would therefore expect the system to spontaneously magnetise (spins align) as it attains the most thermodynamically stable state.&lt;br /&gt;
&lt;br /&gt;
Indeed, when we run our Monte Carlo simulation for an 8x8 lattice at T = 0.5 K, it can be seen that the spins tend toward alignment in on direction as the energy minimises;&lt;br /&gt;
&lt;br /&gt;
[[File:Ising004.png|center]]&lt;br /&gt;
    Averaged quantities:&lt;br /&gt;
    E =  -1.96841896186&lt;br /&gt;
    E*E =  3.88120282707&lt;br /&gt;
    M =  -0.991326800847&lt;br /&gt;
    M*M =  0.983257746292&lt;br /&gt;
&lt;br /&gt;
== Accelerating the code ==&lt;br /&gt;
&#039;&#039;&#039;Task 9&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In an attempt to accelerate the code and save time, the energy() and magnetisation() functions were made more efficient using functions within the numpy python library:&lt;br /&gt;
&lt;br /&gt;
    def energy(self):&lt;br /&gt;
        &amp;quot;Improved energy function which implements numpy&#039;s roll and multiply functions&amp;quot;&lt;br /&gt;
        # multiply by a shifted grid to apply vertical energy contribution&lt;br /&gt;
        vertical_energy = -np.sum(np.multiply(self.lattice, np.roll(self.lattice, 1, axis = 0)))&lt;br /&gt;
        # multiply by a shifted grid to apply the horizontal energy contribution&lt;br /&gt;
        total_energy = vertical_energy - np.sum(np.multiply(self.lattice, np.roll(self.lattice, 1, axis = 1)))&lt;br /&gt;
        return total_energy&lt;br /&gt;
&lt;br /&gt;
    def magnetisation(self):&lt;br /&gt;
        &amp;quot;Improved magnetisation function that implements numpy&#039;s sum function:&amp;quot;&lt;br /&gt;
        return np.sum(self.lattice)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 10&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Time trials were used to compare the speed of the old and updated energy functions:&lt;br /&gt;
&lt;br /&gt;
    New function:&lt;br /&gt;
    2.4918089999999893 s&lt;br /&gt;
    2.4761589999999956 s&lt;br /&gt;
    2.540256999999997 s&lt;br /&gt;
    2.4700420000000065 s&lt;br /&gt;
    2.5968489999999917 s&lt;br /&gt;
    &lt;br /&gt;
    Average = 2.52 s&lt;br /&gt;
    Standard error of average = 0.024 s&lt;br /&gt;
    &lt;br /&gt;
    Old function:&lt;br /&gt;
    10.844294 s&lt;br /&gt;
    10.496529000000002 s&lt;br /&gt;
    10.151754999999998 s&lt;br /&gt;
    10.489855999999996 s&lt;br /&gt;
    9.988599999999998 s&lt;br /&gt;
    &lt;br /&gt;
    Average = 10.39 s&lt;br /&gt;
    Standard error of average = 0.149 s&lt;br /&gt;
&lt;br /&gt;
The result is the improved function only takes 24.3 % of the time took by the old function to do the same thing.&lt;br /&gt;
==The effect of temperature==&lt;br /&gt;
The following plots were produced by running 150000 steps of the Monte Carlo simulation at T = 0.5 K and T = 2.0 K respectively:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising005.png|500px]][[File:Ising006.png|500px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Ising007.png|500px]][[File:Ising008.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Note, in the second system, we see that there must be a realistic chance for the whole system to flip the net spin direction as this is what can be seen from the graph to occur. This happens because in this system there are two global minimum points on the potential energy surface separated by a barrier. At this temperature there is enough energy to only occasionally overcome this barrier.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 11&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Looking at the dynamics of the systems, we can see in the temperature region in which we are working, the region after 3000 steps should be a sufficient representation of the system at equilibrium. The Monte Carlo step and statistics functions were updated to only begin the statistics functionality after 3000 steps:&lt;br /&gt;
&lt;br /&gt;
    # Defines first cycle in which statistical data is collected&lt;br /&gt;
    statsStartStep = 3000&lt;br /&gt;
    # Converts cycle nummber into the machine read index of the cycle (humans count from 1, machine indexes from 0)&lt;br /&gt;
    statsStartStep -= 1&lt;br /&gt;
&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        &amp;quot;preforms a single Monte Carlo step&amp;quot;&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        current_lattice = self.lattice&lt;br /&gt;
        # create a new lattice with on spin flipped&lt;br /&gt;
            #the following two lines select the coordinates of the random spin&lt;br /&gt;
        random_i = np.random.choice(range(self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(self.n_cols))&lt;br /&gt;
        self.lattice[random_i][random_j] =  -self.lattice[random_i][random_j]&lt;br /&gt;
        new_E = self.energy()&lt;br /&gt;
        # compare energies and decided what configuration to adopt, then update parameters&lt;br /&gt;
        dE = new_E - energy&lt;br /&gt;
        if dE &amp;lt; 0:&lt;br /&gt;
            # print(&#039;new energy lower: lattice updated&#039;)&lt;br /&gt;
            pass&lt;br /&gt;
        else:&lt;br /&gt;
            # the following line will choose a random number in the range (0,1)&lt;br /&gt;
            randNumb = np.random.random()&lt;br /&gt;
            if randNumb &amp;lt;= math.exp(-dE/T):&lt;br /&gt;
                # print(&#039;lattice was updated&#039;)&lt;br /&gt;
                pass&lt;br /&gt;
            else:&lt;br /&gt;
                # print(&#039;lattice was not updated&#039;)&lt;br /&gt;
                self.lattice[random_i][random_j] =  -self.lattice[random_i][random_j]&lt;br /&gt;
        # Update the running total IF we are in the region we are gathering stats for&lt;br /&gt;
        if self.n_cycles &amp;gt;= self.statsStartStep:&lt;br /&gt;
            self.E += self.energy()&lt;br /&gt;
            self.E2 += self.energy()**2&lt;br /&gt;
            self.M += self.magnetisation()&lt;br /&gt;
            self.M2 += self.magnetisation()**2&lt;br /&gt;
        # converts cycle index x to cycle number x + 1 (the next machine cycle step number)&lt;br /&gt;
        self.n_cycles += 1&lt;br /&gt;
        # print(self.n_cycles)&lt;br /&gt;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        # Updated statistics function&lt;br /&gt;
        if self.n_cycles &amp;gt;= self.statsStartStep:&lt;br /&gt;
            avE = self.E / (self.n_cycles - self.statsStartStep)&lt;br /&gt;
            avE2 = self.E2 / (self.n_cycles - self.statsStartStep)&lt;br /&gt;
            avM = self.M / (self.n_cycles - self.statsStartStep)&lt;br /&gt;
            avM2 = self.M2 / (self.n_cycles - self.statsStartStep)&lt;br /&gt;
            N = self.n_cycles&lt;br /&gt;
        return avE, avE2, avM, avM2, N&lt;br /&gt;
&lt;br /&gt;
== The effect of system size ==&lt;br /&gt;
&#039;&#039;&#039;Task 12&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A function was then used to plot average energy per spin and average magnetisation per spin against temperature from T = 0.25 K to T = 5 K in 0.25 K intervals. Error bars represent one standard deviation&#039;s worth of uncertainty for the calculation. This was done for 2x2, 4x4, 8x8, 16x16 and 32x32 size lattices, graphed in the same order:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising009.png|500px]]&lt;br /&gt;
&lt;br /&gt;
2x2&lt;br /&gt;
&lt;br /&gt;
[[File:Ising010.png|500px]]&lt;br /&gt;
&lt;br /&gt;
4x4&lt;br /&gt;
&lt;br /&gt;
[[File:Ising011.png|500px]]&lt;br /&gt;
&lt;br /&gt;
8x8&lt;br /&gt;
&lt;br /&gt;
[[File:Ising012.png|500px]]&lt;br /&gt;
&lt;br /&gt;
16x16&lt;br /&gt;
&lt;br /&gt;
[[File:Ising013.png|500px]]&lt;br /&gt;
&lt;br /&gt;
32x32&lt;br /&gt;
&lt;br /&gt;
All of the graphs show a convergence to a limiting value at high temperatures showing the Temperature a) ceases to affect magnetisation (the paramagnetic state) and b) subsequently ceases to affect energy stabilisation due to spin alignment (there are no more static alignment effects). The magnetisation graphs show an oscillating convergence because the spin of the hole system can flip near the Curie temperature as explained earlier. Both +1 and -1 spin systems provide the same energy stabilisation to the system, so energy does not oscillate in it&#039;s convergence. &lt;br /&gt;
&lt;br /&gt;
The error bars for both quantities peak around the Curie temperate presumably as at this point the system is most often undergoing full system spin flips, causing a large variance. At the beginning of the plot the variance is low as expected because there is little dynamic activity. At the end of the plot, even though there is a lot of noise and hence wild oscillation of the spins in the system, there is so much energy that almost any change is accepted, and so the extreme configurations (i.e. all aligned) rarely occur because statistically they are so unlikely to occur. This means the variation in energy and magnetisation for the most part varies within a smaller range and so the errorbars of one standard deviation (95% confidence) are smaller.&lt;br /&gt;
&lt;br /&gt;
The variation between the plots themselves can also be elucidated:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 13&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The average energy per spin plots were superimposed. What we see is the convergence of the energy to a certain curve for large lattices:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising014.png|500px]]&lt;br /&gt;
&lt;br /&gt;
This shows the lattice size is large enough to properly model long range effects as increasing the lattice size has little further effect.&lt;br /&gt;
&lt;br /&gt;
[[File:Pl2mag.png|500px]]&lt;br /&gt;
&lt;br /&gt;
The plot superimposing the magnetisations is also interesting. Firstly we see the magnitude of magnetisation per spin is pretty constant which is exactly what we would expect. Secondly we can see the oscillating convergence much more clearly. Finally we see the convergence is quickest for the smaller lattices, presumably because it&#039;s much easier kinetically to have an even distribution of spins.&lt;br /&gt;
&lt;br /&gt;
== Determining the heat capacity ==&lt;br /&gt;
&#039;&#039;&#039;Task 14&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
We know the average energy is equal to the probability of each energy times the energy. In terms of the partition function (Z, Statistical thermodynamics), we can write this and rearrange to get: &amp;lt;math&amp;gt;\left\langle E\right\rangle = -\frac{\partial}{\partial \beta}logZ&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Considering &amp;lt;math&amp;gt;\mathrm{Var}[E] = \left\langle E^2\right\rangle - \left\langle E\right\rangle^2&amp;lt;/math&amp;gt;, we can rearrange (by equating the squared average energy in both equations) to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{Var}[E] = -\frac{\partial \left\langle E\right\rangle}{\partial \beta}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using (The defenition of heat capacity):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;C = \frac{\partial \left\langle E\right\rangle}{\partial T}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We obtain via integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;C = \frac{\mathrm{Var}[E]}{k_B T^2}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 15&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Heat capacity can therefore be worked out using;&lt;br /&gt;
    x2 = np.array(np.loadtxt(&#039;2x2.dat&#039;))&lt;br /&gt;
    varEx2 = x2[:,2]-x2[:,1]**2&lt;br /&gt;
    cx2 = varEx2 / x2[:,0]**2&lt;br /&gt;
    # Plot and make the heat capacity per spin by dividing by lattice size&lt;br /&gt;
    pl.plot(x2[:,0], cx2/4, color = &#039;green&#039;)&lt;br /&gt;
for each lattice size, where 2x2.dat is a table with columns [Temperature, Average energy, Average squared energy, Average Magnetisation, Average Squared Magnetisation]. After running each simulation 5 times and then averaging for more accurate data, the Heat capacity per spin was subsequently plotted as a function of temperature and lattice size:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising016.png|500px]]&lt;br /&gt;
&lt;br /&gt;
The plot shows that as you increase the lattice size, there is a tighter convergence to some central peak, which implies an infinite lattice would contain a sharp, infinite peak. This is characteristic of a first order phase transition. Based on the observed behaviour of our spins, this phase transition would be the ferromagnetic - paramagnetic phase transition at the Curie temperature.&lt;br /&gt;
&lt;br /&gt;
== Finding the Curie temperature ==&lt;br /&gt;
&#039;&#039;&#039;Task 17&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A set of data ranging from 2x2 to 64x64 lattices using a more advanced simulation written in C++ was provided. This data was plotted and compared to the data from this experiment. An example plot is shown (for the 32x32 lattice size). The C++ data exhibits a much taller and sharper peak. This may be partially down to the low (T = 0.25 K spacing) resolution of the python data (which could be resolved better given more time). The non-peak regions match well which suggests that overall the experimental method is good.&lt;br /&gt;
&lt;br /&gt;
[[File:Ising017.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 18&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A plot was then written to fit a polynomial to the C++ data;&lt;br /&gt;
    import numpy as np&lt;br /&gt;
    import matplotlib.pyplot as pl&lt;br /&gt;
    data = np.loadtxt(&#039;32x32C.dat&#039;) #assume data is now a 2D array containing two columns, T and C&lt;br /&gt;
    T = data[:,0] #get the first column&lt;br /&gt;
    C = data[:,5] # get the second column&lt;br /&gt;
    #first we fit the polynomial to the data&lt;br /&gt;
    fit = np.polyfit(T, C, 3) # fit a third order polynomial&lt;br /&gt;
    #now we generate interpolated values of the fitted polynomial over the range of our function&lt;br /&gt;
    T_min = np.min(T)&lt;br /&gt;
    T_max = np.max(T)&lt;br /&gt;
    T_range = np.linspace(T_min, T_max, 1000) #generate 1000 evenly spaced points between T_min and T_max&lt;br /&gt;
    fitted_C_values = np.polyval(fit, T_range) # use the fit object to generate the corresponding values of C&lt;br /&gt;
    pl.plot(T_range, fitted_C_values, color = &#039;green&#039;)&lt;br /&gt;
    fit50 = np.polyfit(T, C, 50)&lt;br /&gt;
    fitted_C_values50 = np.polyval(fit50, T_range) # use the fit object to generate the corresponding values of C&lt;br /&gt;
    pl.plot(T_range, fitted_C_values50, color = &#039;red&#039;)&lt;br /&gt;
    x32C = np.array(np.loadtxt(&#039;32x32C.dat&#039;))&lt;br /&gt;
    pl.plot(x32C[:,0], x32C[:,5], color = &#039;black&#039;)&lt;br /&gt;
    pl.ylabel(&#039;Heat capacity per spin&#039;)&lt;br /&gt;
    pl.xlabel(&#039;Temperature&#039;)&lt;br /&gt;
    pl.legend([&#039;Third Order Fit&#039;, &#039;50 Order fit&#039;, &#039;Raw C++ Data&#039;])&lt;br /&gt;
    pl.show()&lt;br /&gt;
The graph shows both the original data, a polynomial fir of order 3 and a polynomial fit of order 50:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising018.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Even though using higher order polynomials provides a much more accurate fit, upon increasing the order we get diminishing returns on accurately modelling the peak.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 19&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
As we are mainly interested in finding the Curie temperature, an accurate fit of the peak is most important. An updated plot was executed to fit only in the region around the fit:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising019.png|500px]]&lt;br /&gt;
&lt;br /&gt;
The fit was repeated for a smaller range. The peak was found to be: 1.85691773891 [ 2.29369369]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 20&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Ising020.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Tc for an infinite lattice: 2.27916772 K&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Ising019.png&amp;diff=645947</id>
		<title>File:Ising019.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Ising019.png&amp;diff=645947"/>
		<updated>2017-11-22T11:35:17Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Sm_ising&amp;diff=645912</id>
		<title>Rep:Sm ising</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Sm_ising&amp;diff=645912"/>
		<updated>2017-11-22T11:17:18Z</updated>

		<summary type="html">&lt;p&gt;Sm6415: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Ising Model Report - Sam Macer =&lt;br /&gt;
&lt;br /&gt;
== The Ising model, energy and magnetisation ==&lt;br /&gt;
The Ising model is a simple model which examines the magnetic phase behaviour of a system. The system is set up as an n-dimensional lattice of particles which are either spin up (+1) or spin down (-1). The interaction between any two particles that share a face is counted as an additive contribution towards the overall energy of the system. Each interaction is calculated by multiplying the two spins and then multiplying by some constant J to convert units to energy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 1:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In a lowest energy configuration, all spins will be oriented in the same direction (+1 or -1) to maximise the magnitude of the sum or the interacting spin pairs.&lt;br /&gt;
&lt;br /&gt;
Per dimension, there are two directions in which each spin can interact given that only neighbours sharing a face can interact (modelling the spins as cubes, weather arranged in a line, plane or box).&lt;br /&gt;
&lt;br /&gt;
This means per particle there are 2D interactions, where D = number of dimensions in the system.&lt;br /&gt;
&lt;br /&gt;
The total number of interactions is therefore 2DN/2, where we divide by 2 as each interaction is double counted when we sum interactions over all the particles, where N = number of particles in the system.&lt;br /&gt;
&lt;br /&gt;
Weather each interaction is -1 with -1 or 1 with 1, the magnitude will always be 1, so the total magnitude of the energy of all the interactions will be J * 1.0 * number of interactions where J is some constant converting the units of the energy from arbitrary units into joules.&lt;br /&gt;
&lt;br /&gt;
This simplifies to: Magnitude of the energy of all interactions = DNJ. We know the energy is negative as all spins in alignment correponds to the greatest energy reduction for the system, so we may conclude:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Lowest possible interaction energy for a system (E) = -DNJ&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Only two configurations give this state: when either all spins are +1 or all spins are -1. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;The multiplicity is therefore given by 2 * N!/N! (= 2) where N is the number of spins in the system.&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Entropy (S) = k ln(M) where k is the Boltzmann constant and M is the number of equivalent microstates, so the lowest entropy of the Ising system is given by:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;S = k ln(2)&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 2:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
From the lowest energy configuration, if one of the spins were to instantaneously flip, the new configuration would be all spins aligned but one; i.e all +1 with one -1 or all -1 with one +1.&lt;br /&gt;
&lt;br /&gt;
Multiplicity therefore = 2 * N!/(N - 1)!&lt;br /&gt;
&lt;br /&gt;
The entropy for the D =3, N =1000 system is therefore k ln(2 * (1000!/999!))&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;S = k ln(2 * (1000!/999!))&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;S = k ln(2000)&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In terms of the energy, one spin interacts with 6 neighbours in a 3D lattice. One positive interaction changing into one negative interaction increases the energy by 2J, so overall, flipping one spin leads to a 12J increase in energy to the system.&lt;br /&gt;
&lt;br /&gt;
=== Magnetisation ===&lt;br /&gt;
The magnetisation of the system is defined as the sum of all the spins in the system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 3:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
System 1:&lt;br /&gt;
&lt;br /&gt;
+ + + - -&lt;br /&gt;
&lt;br /&gt;
For system 1, the total magnetisation is 3 - 2:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Magnetisation = + 1&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
System 1:&lt;br /&gt;
&lt;br /&gt;
+ + + + -&lt;br /&gt;
&lt;br /&gt;
+ + + - -&lt;br /&gt;
&lt;br /&gt;
+ + + - -&lt;br /&gt;
&lt;br /&gt;
+ + - - -&lt;br /&gt;
&lt;br /&gt;
+ - - - -&lt;br /&gt;
&lt;br /&gt;
For system 1, the total magnetisation is 13 - 12:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Magnetisation = + 1&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
At absolute zero the entropic contribution would be minimised, so one would expect the energetic contribution to dominate and align all the spins.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;At absolute zero therefore, for a 3D system of 1000 spins, magnetisation = 1000&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Python (Energy and magnetisation) ==&lt;br /&gt;
&#039;&#039;&#039;Task 4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Functions to extract the energy and magnetisation of a system were then written in python;&lt;br /&gt;
&lt;br /&gt;
    def energy(self):&lt;br /&gt;
        &amp;quot;Return the total energy of the current lattice configuration.&amp;quot;&lt;br /&gt;
        # Function works by cycling through each element and then interacting with each neighbour on a grid of coordinates. The energy is halved to prevent double counting and made negative.&lt;br /&gt;
        energy = 0.0&lt;br /&gt;
        net_interaction = 0&lt;br /&gt;
        y = 0&lt;br /&gt;
        x = 0&lt;br /&gt;
        for row in self.lattice:&lt;br /&gt;
                for element in row:&lt;br /&gt;
                    # interact right&lt;br /&gt;
                    if x != self.n_cols - 1:&lt;br /&gt;
                        net_interaction += (element * self.lattice[y, x + 1])&lt;br /&gt;
                    else:&lt;br /&gt;
                        # if we are at the end element, interact with the adjacent system&lt;br /&gt;
                        net_interaction += (element * self.lattice[y, 0])&lt;br /&gt;
                    # interact left&lt;br /&gt;
                    if x != 0:&lt;br /&gt;
                        net_interaction += (element * self.lattice[y, x - 1])&lt;br /&gt;
                    else:&lt;br /&gt;
                        # if we are at the start element, interact with the adjacent system&lt;br /&gt;
                        net_interaction += (element * self.lattice[y, self.n_cols - 1])&lt;br /&gt;
                    # interact bottom&lt;br /&gt;
                    if y != self.n_rows - 1:&lt;br /&gt;
                        net_interaction += (element * self.lattice[y + 1, x])&lt;br /&gt;
                    else:&lt;br /&gt;
                        # if we are at the end element, interact with the adjacent system&lt;br /&gt;
                        net_interaction += (element * self.lattice[0, x])&lt;br /&gt;
                    # interact top&lt;br /&gt;
                    if y != 0:&lt;br /&gt;
                        net_interaction += (element * self.lattice[y - 1, x])&lt;br /&gt;
                    else:&lt;br /&gt;
                        # if we are at the start element, interact with the adjacent system&lt;br /&gt;
                        net_interaction += (element * self.lattice[self.n_rows - 1, x])&lt;br /&gt;
                    # iterate selected spin&lt;br /&gt;
                    if x == self.n_cols - 1:&lt;br /&gt;
                        x = 0&lt;br /&gt;
                        y += 1&lt;br /&gt;
                    else:&lt;br /&gt;
                        x += 1&lt;br /&gt;
        interaction_energy = - 0.5 * net_interaction&lt;br /&gt;
        return interaction_energy&lt;br /&gt;
&lt;br /&gt;
    def magnetisation(self):&lt;br /&gt;
        &amp;quot;Return the total magnetisation of the current lattice configuration.&amp;quot;&lt;br /&gt;
        magnetisation = 0&lt;br /&gt;
        for row in self.lattice:&lt;br /&gt;
            for element in row:&lt;br /&gt;
                magnetisation += element&lt;br /&gt;
        return magnetisation&lt;br /&gt;
&#039;&#039;&#039;Task 5&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;ILcheck.py&#039; script was then ran multiple times to check the energy and magnetisation functions gave consistently correct results:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising001.png|400px]][[File:Ising002.png|400px]][[File:Ising003.png|400px]]&lt;br /&gt;
&lt;br /&gt;
== Python (Monte Carlo Function) ==&lt;br /&gt;
&#039;&#039;&#039;Task 6&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Let us consider a system with 100 spins. Considering each spin has two possible states, there are &amp;lt;math&amp;gt;2^{100} = 1.27 *10^{30}&amp;lt;/math&amp;gt; potential configurations of the system. Even if we could analyse &amp;lt;math&amp;gt;10^9&amp;lt;/math&amp;gt; configurations per second, it would still take us &amp;lt;math&amp;gt;1.27 *10^{21} s&amp;lt;/math&amp;gt; to calculate the magnetisations of all of the configurations to take an average. Clearly this would take too long so we must look for an alternative method of gathering data on the behaviour of the energy. One way of doing this is using a Monte Carlo simulation where we start with a random configuration and randomly flip spins. We accept the new configuration if there is an energy reduction. Otherwise we accept the new configuration at a rate proportional to the Boltzmann factor as this reflects how often a particle would theoretically have enough energy to flip to a higher energy state.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 7&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A Monte-Carlo simulation was coded in python as follows:&lt;br /&gt;
&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        &amp;quot;preforms a single Monte Carlo step&amp;quot;&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        current_lattice = self.lattice&lt;br /&gt;
        # create a new lattice with on spin flipped&lt;br /&gt;
            #the following two lines select the coordinates of the random spin&lt;br /&gt;
        random_i = np.random.choice(range(self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(self.n_cols))&lt;br /&gt;
        self.lattice[random_i][random_j] =  -self.lattice[random_i][random_j]&lt;br /&gt;
        new_E = self.energy()&lt;br /&gt;
        # compare energies and decided what configuration to adopt, then update parameters&lt;br /&gt;
        dE = new_E - energy&lt;br /&gt;
        if dE &amp;lt; 0:&lt;br /&gt;
            # print(&#039;new energy lower: lattice updated&#039;)&lt;br /&gt;
            pass&lt;br /&gt;
        else:&lt;br /&gt;
            # the following line will choose a random number in the range (0,1)&lt;br /&gt;
            randNumb = np.random.random()&lt;br /&gt;
            if randNumb &amp;lt;= math.exp(-dE/T):&lt;br /&gt;
                # print(&#039;lattice was updated&#039;)&lt;br /&gt;
                pass&lt;br /&gt;
            else:&lt;br /&gt;
                # print(&#039;lattice was not updated&#039;)&lt;br /&gt;
                self.lattice[random_i][random_j] =  -self.lattice[random_i][random_j]&lt;br /&gt;
        self.E += self.energy()&lt;br /&gt;
        self.E2 += self.energy()**2&lt;br /&gt;
        self.M += self.magnetisation()&lt;br /&gt;
        self.M2 += self.magnetisation()**2&lt;br /&gt;
        # converts cycle index x to cycle number x + 1 (the next machine cycle step number)&lt;br /&gt;
        # In other words increments the counter of number of cycles&lt;br /&gt;
        self.n_cycles += 1&lt;br /&gt;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        &amp;quot;returns statistical data collected during a Monte Carlo simulation&amp;quot;&lt;br /&gt;
        avE = self.E / self.n_cycles&lt;br /&gt;
        avE2 = self.E2 / self.n_cycles&lt;br /&gt;
        avM = self.M / self.n_cycles&lt;br /&gt;
        avM2 = self.M2 / self.n_cycles&lt;br /&gt;
        N = self.n_cycles&lt;br /&gt;
        return avE, avE2, avM, avM2, N&lt;br /&gt;
&#039;&#039;&#039;Task 8&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
When the temperature of the system is above the Curie Temperature (Tc), the system is paramagnetic at thermodynamic equilibrium, i.e. the spins are oriented randomly in the absence of an external magnetic field. When the temperature of the system is below the Curie Temperature, the system is ferromagnetic at thermodynamic equilibrium (spins align). In the case T &amp;lt; Tc, one would therefore expect the system to spontaneously magnetise (spins align) as it attains the most thermodynamically stable state.&lt;br /&gt;
&lt;br /&gt;
Indeed, when we run our Monte Carlo simulation for an 8x8 lattice at T = 0.5 K, it can be seen that the spins tend toward alignment in on direction as the energy minimises;&lt;br /&gt;
&lt;br /&gt;
[[File:Ising004.png|center]]&lt;br /&gt;
    Averaged quantities:&lt;br /&gt;
    E =  -1.96841896186&lt;br /&gt;
    E*E =  3.88120282707&lt;br /&gt;
    M =  -0.991326800847&lt;br /&gt;
    M*M =  0.983257746292&lt;br /&gt;
&lt;br /&gt;
== Accelerating the code ==&lt;br /&gt;
&#039;&#039;&#039;Task 9&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In an attempt to accelerate the code and save time, the energy() and magnetisation() functions were made more efficient using functions within the numpy python library:&lt;br /&gt;
&lt;br /&gt;
    def energy(self):&lt;br /&gt;
        &amp;quot;Improved energy function which implements numpy&#039;s roll and multiply functions&amp;quot;&lt;br /&gt;
        # multiply by a shifted grid to apply vertical energy contribution&lt;br /&gt;
        vertical_energy = -np.sum(np.multiply(self.lattice, np.roll(self.lattice, 1, axis = 0)))&lt;br /&gt;
        # multiply by a shifted grid to apply the horizontal energy contribution&lt;br /&gt;
        total_energy = vertical_energy - np.sum(np.multiply(self.lattice, np.roll(self.lattice, 1, axis = 1)))&lt;br /&gt;
        return total_energy&lt;br /&gt;
&lt;br /&gt;
    def magnetisation(self):&lt;br /&gt;
        &amp;quot;Improved magnetisation function that implements numpy&#039;s sum function:&amp;quot;&lt;br /&gt;
        return np.sum(self.lattice)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 10&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Time trials were used to compare the speed of the old and updated energy functions:&lt;br /&gt;
&lt;br /&gt;
    New function:&lt;br /&gt;
    2.4918089999999893 s&lt;br /&gt;
    2.4761589999999956 s&lt;br /&gt;
    2.540256999999997 s&lt;br /&gt;
    2.4700420000000065 s&lt;br /&gt;
    2.5968489999999917 s&lt;br /&gt;
    &lt;br /&gt;
    Average = 2.52 s&lt;br /&gt;
    Standard error of average = 0.024 s&lt;br /&gt;
    &lt;br /&gt;
    Old function:&lt;br /&gt;
    10.844294 s&lt;br /&gt;
    10.496529000000002 s&lt;br /&gt;
    10.151754999999998 s&lt;br /&gt;
    10.489855999999996 s&lt;br /&gt;
    9.988599999999998 s&lt;br /&gt;
    &lt;br /&gt;
    Average = 10.39 s&lt;br /&gt;
    Standard error of average = 0.149 s&lt;br /&gt;
&lt;br /&gt;
The result is the improved function only takes 24.3 % of the time took by the old function to do the same thing.&lt;br /&gt;
==The effect of temperature==&lt;br /&gt;
The following plots were produced by running 150000 steps of the Monte Carlo simulation at T = 0.5 K and T = 2.0 K respectively:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising005.png|500px]][[File:Ising006.png|500px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Ising007.png|500px]][[File:Ising008.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Note, in the second system, we see that there must be a realistic chance for the whole system to flip the net spin direction as this is what can be seen from the graph to occur. This happens because in this system there are two global minimum points on the potential energy surface separated by a barrier. At this temperature there is enough energy to only occasionally overcome this barrier.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 11&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Looking at the dynamics of the systems, we can see in the temperature region in which we are working, the region after 3000 steps should be a sufficient representation of the system at equilibrium. The Monte Carlo step and statistics functions were updated to only begin the statistics functionality after 3000 steps:&lt;br /&gt;
&lt;br /&gt;
    # Defines first cycle in which statistical data is collected&lt;br /&gt;
    statsStartStep = 3000&lt;br /&gt;
    # Converts cycle nummber into the machine read index of the cycle (humans count from 1, machine indexes from 0)&lt;br /&gt;
    statsStartStep -= 1&lt;br /&gt;
&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        &amp;quot;preforms a single Monte Carlo step&amp;quot;&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        current_lattice = self.lattice&lt;br /&gt;
        # create a new lattice with on spin flipped&lt;br /&gt;
            #the following two lines select the coordinates of the random spin&lt;br /&gt;
        random_i = np.random.choice(range(self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(self.n_cols))&lt;br /&gt;
        self.lattice[random_i][random_j] =  -self.lattice[random_i][random_j]&lt;br /&gt;
        new_E = self.energy()&lt;br /&gt;
        # compare energies and decided what configuration to adopt, then update parameters&lt;br /&gt;
        dE = new_E - energy&lt;br /&gt;
        if dE &amp;lt; 0:&lt;br /&gt;
            # print(&#039;new energy lower: lattice updated&#039;)&lt;br /&gt;
            pass&lt;br /&gt;
        else:&lt;br /&gt;
            # the following line will choose a random number in the range (0,1)&lt;br /&gt;
            randNumb = np.random.random()&lt;br /&gt;
            if randNumb &amp;lt;= math.exp(-dE/T):&lt;br /&gt;
                # print(&#039;lattice was updated&#039;)&lt;br /&gt;
                pass&lt;br /&gt;
            else:&lt;br /&gt;
                # print(&#039;lattice was not updated&#039;)&lt;br /&gt;
                self.lattice[random_i][random_j] =  -self.lattice[random_i][random_j]&lt;br /&gt;
        # Update the running total IF we are in the region we are gathering stats for&lt;br /&gt;
        if self.n_cycles &amp;gt;= self.statsStartStep:&lt;br /&gt;
            self.E += self.energy()&lt;br /&gt;
            self.E2 += self.energy()**2&lt;br /&gt;
            self.M += self.magnetisation()&lt;br /&gt;
            self.M2 += self.magnetisation()**2&lt;br /&gt;
        # converts cycle index x to cycle number x + 1 (the next machine cycle step number)&lt;br /&gt;
        self.n_cycles += 1&lt;br /&gt;
        # print(self.n_cycles)&lt;br /&gt;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        # Updated statistics function&lt;br /&gt;
        if self.n_cycles &amp;gt;= self.statsStartStep:&lt;br /&gt;
            avE = self.E / (self.n_cycles - self.statsStartStep)&lt;br /&gt;
            avE2 = self.E2 / (self.n_cycles - self.statsStartStep)&lt;br /&gt;
            avM = self.M / (self.n_cycles - self.statsStartStep)&lt;br /&gt;
            avM2 = self.M2 / (self.n_cycles - self.statsStartStep)&lt;br /&gt;
            N = self.n_cycles&lt;br /&gt;
        return avE, avE2, avM, avM2, N&lt;br /&gt;
&lt;br /&gt;
== The effect of system size ==&lt;br /&gt;
&#039;&#039;&#039;Task 12&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A function was then used to plot average energy per spin and average magnetisation per spin against temperature from T = 0.25 K to T = 5 K in 0.25 K intervals. Error bars represent one standard deviation&#039;s worth of uncertainty for the calculation. This was done for 2x2, 4x4, 8x8, 16x16 and 32x32 size lattices, graphed in the same order:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising009.png|500px]]&lt;br /&gt;
&lt;br /&gt;
2x2&lt;br /&gt;
&lt;br /&gt;
[[File:Ising010.png|500px]]&lt;br /&gt;
&lt;br /&gt;
4x4&lt;br /&gt;
&lt;br /&gt;
[[File:Ising011.png|500px]]&lt;br /&gt;
&lt;br /&gt;
8x8&lt;br /&gt;
&lt;br /&gt;
[[File:Ising012.png|500px]]&lt;br /&gt;
&lt;br /&gt;
16x16&lt;br /&gt;
&lt;br /&gt;
[[File:Ising013.png|500px]]&lt;br /&gt;
&lt;br /&gt;
32x32&lt;br /&gt;
&lt;br /&gt;
All of the graphs show a convergence to a limiting value at high temperatures showing the Temperature a) ceases to affect magnetisation (the paramagnetic state) and b) subsequently ceases to affect energy stabilisation due to spin alignment (there are no more static alignment effects). The magnetisation graphs show an oscillating convergence because the spin of the hole system can flip near the Curie temperature as explained earlier. Both +1 and -1 spin systems provide the same energy stabilisation to the system, so energy does not oscillate in it&#039;s convergence. &lt;br /&gt;
&lt;br /&gt;
The error bars for both quantities peak around the Curie temperate presumably as at this point the system is most often undergoing full system spin flips, causing a large variance. At the beginning of the plot the variance is low as expected because there is little dynamic activity. At the end of the plot, even though there is a lot of noise and hence wild oscillation of the spins in the system, there is so much energy that almost any change is accepted, and so the extreme configurations (i.e. all aligned) rarely occur because statistically they are so unlikely to occur. This means the variation in energy and magnetisation for the most part varies within a smaller range and so the errorbars of one standard deviation (95% confidence) are smaller.&lt;br /&gt;
&lt;br /&gt;
The variation between the plots themselves can also be elucidated:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 13&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The average energy per spin plots were superimposed. What we see is the convergence of the energy to a certain curve for large lattices:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising014.png|500px]]&lt;br /&gt;
&lt;br /&gt;
This shows the lattice size is large enough to properly model long range effects as increasing the lattice size has little further effect.&lt;br /&gt;
&lt;br /&gt;
[[File:Pl2mag.png|500px]]&lt;br /&gt;
&lt;br /&gt;
The plot superimposing the magnetisations is also interesting. Firstly we see the magnitude of magnetisation per spin is pretty constant which is exactly what we would expect. Secondly we can see the oscillating convergence much more clearly. Finally we see the convergence is quickest for the smaller lattices, presumably because it&#039;s much easier kinetically to have an even distribution of spins.&lt;br /&gt;
&lt;br /&gt;
== Determining the heat capacity ==&lt;br /&gt;
&#039;&#039;&#039;Task 14&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
We know the average energy is equal to the probability of each energy times the energy. In terms of the partition function (Z, Statistical thermodynamics), we can write this and rearrange to get: &amp;lt;math&amp;gt;\left\langle E\right\rangle = -\frac{\partial}{\partial \beta}logZ&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Considering &amp;lt;math&amp;gt;\mathrm{Var}[E] = \left\langle E^2\right\rangle - \left\langle E\right\rangle^2&amp;lt;/math&amp;gt;, we can rearrange (by equating the squared average energy in both equations) to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{Var}[E] = -\frac{\partial \left\langle E\right\rangle}{\partial \beta}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using (The defenition of heat capacity):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;C = \frac{\partial \left\langle E\right\rangle}{\partial T}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We obtain via integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;C = \frac{\mathrm{Var}[E]}{k_B T^2}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 15&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Ising015.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 16&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Heat capacity can therefore be worked out using:&lt;br /&gt;
    x2 = np.array(np.loadtxt(&#039;2x2.dat&#039;))&lt;br /&gt;
    varEx2 = x2[:,2]-x2[:,1]**2&lt;br /&gt;
    cx2 = varEx2 / x2[:,0]**2&lt;br /&gt;
    # Plot and make the heat capacity per spin by dividing by lattice size&lt;br /&gt;
    pl.plot(x2[:,0], cx2/4, color = &#039;green&#039;)&lt;br /&gt;
for each lattice size where 2x2.dat is a table with columns [Temperature, Average energy, Average squared energy, Average Magnetisation, Average Squared Magnetisation]&lt;br /&gt;
&lt;br /&gt;
The Heat capacity per spin was subsequently plotted as a function of temperature and lattice size:&lt;br /&gt;
&lt;br /&gt;
[[File:Ising016.png|500px]]&lt;br /&gt;
&lt;br /&gt;
== Finding the Curie temperature ==&lt;br /&gt;
&#039;&#039;&#039;Task 17&#039;&#039;&#039;&lt;br /&gt;
[[File:Ising017.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 18&#039;&#039;&#039;&lt;br /&gt;
    import numpy as np&lt;br /&gt;
    import matplotlib.pyplot as pl&lt;br /&gt;
    data = np.loadtxt(&#039;32x32C.dat&#039;) #assume data is now a 2D array containing two columns, T and C&lt;br /&gt;
    T = data[:,0] #get the first column&lt;br /&gt;
    C = data[:,5] # get the second column&lt;br /&gt;
    #first we fit the polynomial to the data&lt;br /&gt;
    fit = np.polyfit(T, C, 3) # fit a third order polynomial&lt;br /&gt;
    #now we generate interpolated values of the fitted polynomial over the range of our function&lt;br /&gt;
    T_min = np.min(T)&lt;br /&gt;
    T_max = np.max(T)&lt;br /&gt;
    T_range = np.linspace(T_min, T_max, 1000) #generate 1000 evenly spaced points between T_min and T_max&lt;br /&gt;
    fitted_C_values = np.polyval(fit, T_range) # use the fit object to generate the corresponding values of C&lt;br /&gt;
    pl.plot(T_range, fitted_C_values, color = &#039;green&#039;)&lt;br /&gt;
    fit50 = np.polyfit(T, C, 50)&lt;br /&gt;
    fitted_C_values50 = np.polyval(fit50, T_range) # use the fit object to generate the corresponding values of C&lt;br /&gt;
    pl.plot(T_range, fitted_C_values50, color = &#039;red&#039;)&lt;br /&gt;
    x32C = np.array(np.loadtxt(&#039;32x32C.dat&#039;))&lt;br /&gt;
    pl.plot(x32C[:,0], x32C[:,5], color = &#039;black&#039;)&lt;br /&gt;
    pl.ylabel(&#039;Heat capacity per spin&#039;)&lt;br /&gt;
    pl.xlabel(&#039;Temperature&#039;)&lt;br /&gt;
    pl.legend([&#039;Third Order Fit&#039;, &#039;50 Order fit&#039;, &#039;Raw C++ Data&#039;])&lt;br /&gt;
    pl.show()&lt;br /&gt;
&lt;br /&gt;
[[File:Ising018.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 19&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Ising019.png|500px]]&lt;br /&gt;
&lt;br /&gt;
The fit was repeated for a smaller range. The peak was found to be: 1.85691773891 [ 2.29369369]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Task 20&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Ising020.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Tc for an infinite lattice: 2.27916772 K&lt;/div&gt;</summary>
		<author><name>Sm6415</name></author>
	</entry>
</feed>