<?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=Ge715</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=Ge715"/>
	<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/wiki/Special:Contributions/Ge715"/>
	<updated>2026-05-16T13:14:24Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=657090</id>
		<title>Rep:Liquids GE715</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=657090"/>
		<updated>2018-01-26T19:41:58Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract ==&lt;br /&gt;
&lt;br /&gt;
In this experiment properties of liquids were modelled using molecular dynamics experiments. The effect of the temperature on the density as well as the effect of temperature on the heat capacity, and the radial distribution functions were explored.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Molecular dynamics is a modern computational technique concerned with calculating properties of substances by modelling them and their behaviour on atomic level with powerful computers.&lt;br /&gt;
&lt;br /&gt;
Lennard Jones potential equals &amp;lt;math&amp;gt;\phi\left(r\right) = 4\epsilon \left( \frac{\sigma^{12}}{r^{12}} - \frac{\sigma^6}{r^6} \right)&amp;lt;/math&amp;gt;. Potential energy is zero at the point when &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt;, thus &amp;lt;math&amp;gt;r_0=\sigma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Force is simply the derivative of the potential, thus &amp;lt;math&amp;gt;F = 4\epsilon \left( -12 \frac{\sigma^{12}}{r^{13}} + 6 \frac{\sigma^6}{r^7} \right)&amp;lt;/math&amp;gt;. At &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt; this equals &amp;lt;math&amp;gt;F = - \frac{24\epsilon}{\sigma}&amp;lt;/math&amp;gt;. Well depth is &amp;lt;math&amp;gt;\phi\left(r_{eq}\right) = - \epsilon&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;r_{eq}=\sigma \sqrt[6]{2}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The following integrals are equal to: &amp;lt;math&amp;gt;\int_{2\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.0248&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\int_{2.5\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00818&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\int_{3\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00329&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Introductory tasks ===&lt;br /&gt;
&lt;br /&gt;
==== Water ====&lt;br /&gt;
&lt;br /&gt;
There are roughly &amp;lt;math&amp;gt;3.3*10^{22}&amp;lt;/math&amp;gt; molecules in 1 mL of water. However, 10000 atoms of water take up about &amp;lt;math&amp;gt;3*10^{-19} mL&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;300 nm^{3}&amp;lt;/math&amp;gt;. This is a good illustration of how different atomic scale is from the scale on which the properties of substances tend to be observed.&lt;br /&gt;
&lt;br /&gt;
==== Atoms ====&lt;br /&gt;
&lt;br /&gt;
Atom at position &amp;lt;math&amp;gt;(0.5,0.5,0.5)&amp;lt;/math&amp;gt; moved for &amp;lt;math&amp;gt;(0.7,0.6,0.2)&amp;lt;/math&amp;gt; would be found at &amp;lt;math&amp;gt;(0.2,0.1,0.7)&amp;lt;/math&amp;gt;, since it would be copied in both x and y direction (assuming x,y,z).&lt;br /&gt;
&lt;br /&gt;
==== Reduced units ====&lt;br /&gt;
&lt;br /&gt;
Lennard-Jones parameters for argon were given, the macroscopic properties are calculated here.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;LJ_{cut-off}=1.088 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;T=180 K&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;r=0.382 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;E=1 \frac{kJ}{mol}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Aims and Objectives ==&lt;br /&gt;
&lt;br /&gt;
The aim of this experiment was to explore the modern use of molecular dynamics for simulating simple liquids.&lt;br /&gt;
&lt;br /&gt;
The objectives were to look at how timesteps used in experiment affect the quality of the results, how temperature affects density and find radial distribution functions and their integrals for different phases of matter.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
&lt;br /&gt;
The calculations were performed on a high performance computer using LAMMPS software package, while the calculations of radial distribution functions were done using VMD (delta r=0.05).&lt;br /&gt;
&lt;br /&gt;
== Equilibration ==&lt;br /&gt;
&lt;br /&gt;
If two atoms were generated very close together that would mean the force between them would be enormous, which would have a potential to heavily disturb the simulation (very high potential energy would increase the temperature).&lt;br /&gt;
&lt;br /&gt;
=== Commands ====&lt;br /&gt;
&lt;br /&gt;
mass 1 1.0 signifies that the mass of the first kind of particles (1) is 1.0.&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut 3.0 tells us where the interactions are cut off, as seen in the integral above, &amp;lt;math&amp;gt;3.0 \sigma&amp;lt;/math&amp;gt; is a very good cut-off, since there is no significant perturbation.&lt;br /&gt;
&lt;br /&gt;
The algorithm used for the calculations is velocity-Verlet, because the classical one does not use velocities.&lt;br /&gt;
&lt;br /&gt;
=== Simulations ===&lt;br /&gt;
&lt;br /&gt;
In the gallery below graphs are shown. It can be seen that as timesteps are increasing, the quality of results is decreasing. Timpestep of 0.015 s is wholy inappropriate, but I have chosen to run the experiments at the timestep of 0.0025 s. Results would probably also be almost as good using 0.01 s. We can see this by the fact that equilibrium is reached very quickly, for the first for timesteps in the space of 0.1 s -0.3 s. The highest timestep will mimic the reality better, but it might be too demanding computationally.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=200 px&amp;gt;&lt;br /&gt;
Image:GE715L1.PNG|Figure 1: Energy at timestep 0.001 s&lt;br /&gt;
Image:GE715L2.PNG|Figure 2: Temperature at timestep 0.001 s&lt;br /&gt;
Image:GE715L3.PNG|Figure 3: Pressure at timestep 0.001 s&lt;br /&gt;
Image:GE715L4.PNG|Figure 4: Energy at timestep 0.0025 s&lt;br /&gt;
Image:GE715L5.PNG|Figure 5: Energy at timestep 0.0075 s&lt;br /&gt;
Image:GE715L6.PNG|Figure 6: Energy at timestep 0.01 s&lt;br /&gt;
Image:GE715L7.PNG|Figure 7: Energy at timestep 0.015 s&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Specific conditions ==&lt;br /&gt;
&lt;br /&gt;
The next task was to run simulations varying temperatures at constant pressure. This shows the dependence of density on temperature at a constant pressure. Considering the ideal gas law the density will be inversely proportional with temperature.&lt;br /&gt;
&lt;br /&gt;
If we run simulations under different conditions, we get the results shown in the gallery below. Bear in mind that some errors are almost negligible.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400 px&amp;gt;&lt;br /&gt;
Image:GE715L8.PNG|Figure 8: Density vs temperature at p=2&lt;br /&gt;
Image:GE715L9.PNG|Figure 9: Density vs temperature at p=3&lt;br /&gt;
Image:GE715L16.PNG|Figure 10: Inverse of density vs temperature at p=2&lt;br /&gt;
Image:GE715L17.PNG|Figure 11: Inverse of density vs temperature at p=3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The inverses are of densities are shown to prove that this simulation obeys the proportionality proposed ideal gas law, where the density and temperature are inversely proportional.&lt;br /&gt;
&lt;br /&gt;
== Heat capacity calculation ==&lt;br /&gt;
&lt;br /&gt;
Heat capacity at constant volume may be calculated using equation &amp;lt;math&amp;gt;C_V = N^2\frac{\left\langle E^2\right\rangle - \left\langle E\right\rangle^2}{k_B T^2}&amp;lt;/math&amp;gt;, which LAMMPS software enables us to do. This was done at two different densities (0.2 and 0.8) and is shown in the gallery below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715L18.PNG|Figure 12: Heat capacity per volume vs temperature at d=0.2&lt;br /&gt;
Image:GE715L19.PNG|Figure 13: Heat capacity per volume vs temperature at d=0.8&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Any trends in heat capacity over a range of temperatures at a fixed volume is not entirely clear even though we would normally expect a gradual decrease in heat capacity with higher temperatures.&lt;br /&gt;
&lt;br /&gt;
An example of the code used to calculate this is shown below (d=0.2, T=2.0). Heat capacity was finally divided by a volume.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
### DEFINE SIMULATION BOX GEOMETRY ###&lt;br /&gt;
variable dens equal 0.2&lt;br /&gt;
lattice sc ${dens}&lt;br /&gt;
region box block 0 15 0 15 0 15&lt;br /&gt;
create_box 1 box&lt;br /&gt;
create_atoms 1 box&lt;br /&gt;
&lt;br /&gt;
### DEFINE PHYSICAL PROPERTIES OF ATOMS ###&lt;br /&gt;
mass 1 1.0&lt;br /&gt;
pair_style lj/cut/opt 3.0&lt;br /&gt;
pair_coeff 1 1 1.0 1.0&lt;br /&gt;
neighbor 2.0 bin&lt;br /&gt;
&lt;br /&gt;
### SPECIFY THE REQUIRED THERMODYNAMIC STATE ###&lt;br /&gt;
variable T equal 2.0&lt;br /&gt;
variable timestep equal 0.0025&lt;br /&gt;
&lt;br /&gt;
### ASSIGN ATOMIC VELOCITIES ###&lt;br /&gt;
velocity all create ${T} 12345 dist gaussian rot yes mom yes&lt;br /&gt;
&lt;br /&gt;
### SPECIFY ENSEMBLE ###&lt;br /&gt;
timestep ${timestep}&lt;br /&gt;
fix nve all nve&lt;br /&gt;
&lt;br /&gt;
### THERMODYNAMIC OUTPUT CONTROL ###&lt;br /&gt;
thermo_style custom time etotal temp press&lt;br /&gt;
thermo 10&lt;br /&gt;
&lt;br /&gt;
### RECORD TRAJECTORY ###&lt;br /&gt;
dump traj all custom 1000 output-1 id x y z&lt;br /&gt;
&lt;br /&gt;
### SPECIFY TIMESTEP ###&lt;br /&gt;
&lt;br /&gt;
### RUN SIMULATION TO MELT CRYSTAL ###&lt;br /&gt;
run 10000&lt;br /&gt;
unfix nve&lt;br /&gt;
&lt;br /&gt;
### BRING SYSTEM TO REQUIRED STATE ###&lt;br /&gt;
variable tdamp equal ${timestep}*100&lt;br /&gt;
fix nvt all nvt temp ${T} ${T} ${tdamp}&lt;br /&gt;
run 100000&lt;br /&gt;
reset_timestep 0&lt;br /&gt;
&lt;br /&gt;
### MEASURE SYSTEM STATE ###&lt;br /&gt;
thermo_style custom atoms etotal temp vol&lt;br /&gt;
variable N2 equal atoms*atoms&lt;br /&gt;
variable E equal etotal&lt;br /&gt;
variable E2 equal etotal*etotal&lt;br /&gt;
variable temp equal temp&lt;br /&gt;
variable temp2 equal temp*temp&lt;br /&gt;
variable vol equal vol&lt;br /&gt;
fix aves all ave/time 100 1000 100000 v_E v_E2 v_temp2&lt;br /&gt;
run 100000&lt;br /&gt;
&lt;br /&gt;
variable heatcapac equal N2*(f_aves[2]-f_aves[1]*f_aves[1])/(f_aves[3])&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Averages&amp;quot;&lt;br /&gt;
print &amp;quot;--------&amp;quot;&lt;br /&gt;
print &amp;quot;Heat Capacity: ${heatcapac}&amp;quot;&lt;br /&gt;
print &amp;quot;Volume: ${vol}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Radial distribution functions ==&lt;br /&gt;
&lt;br /&gt;
The radial distribution functions from the calculations are given in the gallery below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=300 px&amp;gt;&lt;br /&gt;
Image:GE715L10.PNG|Figure 14: RDF for a gas&lt;br /&gt;
Image:GE715L11.PNG|Figure 15: RDF for a liquid&lt;br /&gt;
Image:GE715L12.PNG|Figure 16: RDF for a solid&lt;br /&gt;
Image:GE715L13.PNG|Figure 17: Integral of RDF for a gas&lt;br /&gt;
Image:GE715L14.PNG|Figure 18: Integral of RDF for a liquid&lt;br /&gt;
Image:GE715L15.PNG|Figure 19: Integral of RDF for a solid&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see from the graphs the differences between different phases and their order. It is clear that in a solid lattice structure is fairly rigid (peaks are the neighbouring atoms), liquid is slightly less ordered, while gas has almost. no real order at all. Lattice spacing in a solid is &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt;, while the first peak represents the nearest neighbouring atoms, while the next two represent the atom that are not nearest neighbours, but are less than two atoms away in a straight line from the central atom. The interactions are dropping of with distance, as expected in Lennard-Jones model.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
It has been determined that appropriate timestep for dynamics calculations is 0.0025 s.&lt;br /&gt;
&lt;br /&gt;
Simulations were performed to determine that temperature and density of a liquid are inversely proportional.&lt;br /&gt;
&lt;br /&gt;
Another finding was that heat capacity does not necessarily have a clear strong dependence on temperature at constant volume.&lt;br /&gt;
&lt;br /&gt;
It was also found that radial distribution function depends heavily on the phase of matter, with order being clearly seen in solid lattice.&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L19.PNG&amp;diff=657079</id>
		<title>File:GE715L19.PNG</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L19.PNG&amp;diff=657079"/>
		<updated>2018-01-26T19:29:36Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L18.PNG&amp;diff=657078</id>
		<title>File:GE715L18.PNG</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L18.PNG&amp;diff=657078"/>
		<updated>2018-01-26T19:29:21Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=657013</id>
		<title>Rep:Liquids GE715</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=657013"/>
		<updated>2018-01-26T18:16:20Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract ==&lt;br /&gt;
&lt;br /&gt;
In this experiment properties of liquids were modelled using molecular dynamics experiments. The effect of the temperature on the density as well as the radial distribution functions were explored.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Molecular dynamics is a modern computational technique concerned with calculating properties of substances by modelling them and their behaviour on atomic level with powerful computers.&lt;br /&gt;
&lt;br /&gt;
Lennard Jones potential equals &amp;lt;math&amp;gt;\phi\left(r\right) = 4\epsilon \left( \frac{\sigma^{12}}{r^{12}} - \frac{\sigma^6}{r^6} \right)&amp;lt;/math&amp;gt;. Potential energy is zero at the point when &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt;, thus &amp;lt;math&amp;gt;r_0=\sigma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Force is simply the derivative of the potential, thus &amp;lt;math&amp;gt;F = 4\epsilon \left( -12 \frac{\sigma^{12}}{r^{13}} + 6 \frac{\sigma^6}{r^7} \right)&amp;lt;/math&amp;gt;. At &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt; this equals &amp;lt;math&amp;gt;F = - \frac{24\epsilon}{\sigma}&amp;lt;/math&amp;gt;. Well depth is &amp;lt;math&amp;gt;\phi\left(r_{eq}\right) = - \epsilon&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;r_{eq}=\sigma \sqrt[6]{2}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The following integrals are equal to: &amp;lt;math&amp;gt;\int_{2\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.0248&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\int_{2.5\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00818&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\int_{3\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00329&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Introductory tasks ===&lt;br /&gt;
&lt;br /&gt;
==== Water ====&lt;br /&gt;
&lt;br /&gt;
There are roughly &amp;lt;math&amp;gt;3.3*10^{22}&amp;lt;/math&amp;gt; molecules in 1 mL of water. However, 10000 atoms of water take up about &amp;lt;math&amp;gt;3*10^{-19} mL&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;300 nm^{3}&amp;lt;/math&amp;gt;. This is a good illustration of how different atomic scale is from the scale on which the properties of substances tend to be observed.&lt;br /&gt;
&lt;br /&gt;
==== Atoms ====&lt;br /&gt;
&lt;br /&gt;
Atom at position &amp;lt;math&amp;gt;(0.5,0.5,0.5)&amp;lt;/math&amp;gt; moved for &amp;lt;math&amp;gt;(0.7,0.6,0.2)&amp;lt;/math&amp;gt; would be found at &amp;lt;math&amp;gt;(0.2,0.1,0.7)&amp;lt;/math&amp;gt;, since it would be copied in both x and y direction (assuming x,y,z).&lt;br /&gt;
&lt;br /&gt;
==== Reduced units ====&lt;br /&gt;
&lt;br /&gt;
Lennard-Jones parameters for argon were given, the macroscopic properties are calculated here.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;LJ_{cut-off}=1.088 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;T=180 K&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;r=0.382 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;E=1 \frac{kJ}{mol}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Aims and Objectives ==&lt;br /&gt;
&lt;br /&gt;
The aim of this experiment was to explore the modern use of molecular dynamics for simulating simple liquids.&lt;br /&gt;
&lt;br /&gt;
The objectives were to look at how timesteps used in experiment affect the quality of the results, how temperature affects density and find radial distribution functions and their integrals for different phases of matter.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
&lt;br /&gt;
The calculations were performed on a high performance computer using LAMMPS software package, while the calculations of radial distribution functions were done using VMD (delta r=0.05).&lt;br /&gt;
&lt;br /&gt;
== Equilibration ==&lt;br /&gt;
&lt;br /&gt;
If two atoms were generated very close together that would mean the force between them would be enormous, which would have a potential to heavily disturb the simulation (very high potential energy would increase the temperature).&lt;br /&gt;
&lt;br /&gt;
=== Commands ====&lt;br /&gt;
&lt;br /&gt;
mass 1 1.0 signifies that the mass of the first kind of particles (1) is 1.0.&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut 3.0 tells us where the interactions are cut off, as seen in the integral above, &amp;lt;math&amp;gt;3.0 \sigma&amp;lt;/math&amp;gt; is a very good cut-off, since there is no significant perturbation.&lt;br /&gt;
&lt;br /&gt;
The algorithm used for the calculations is velocity-Verlet, because the classical one does not use velocities.&lt;br /&gt;
&lt;br /&gt;
=== Simulations ===&lt;br /&gt;
&lt;br /&gt;
In the gallery below graphs are shown. It can be seen that as timesteps are increasing, the quality of results is decreasing. Timpestep of 0.015 s is wholy inappropriate, but I have chosen to run the experiments at the timestep of 0.0025 s. Results would probably also be almost as good using 0.01 s. We can see this by the fact that equilibrium is reached very quickly, for the first for timesteps in the space of 0.1 s -0.3 s. The highest timestep will mimic the reality better, but it might be too demanding computationally.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=200 px&amp;gt;&lt;br /&gt;
Image:GE715L1.PNG|Figure 1: Energy at timestep 0.001 s&lt;br /&gt;
Image:GE715L2.PNG|Figure 2: Temperature at timestep 0.001 s&lt;br /&gt;
Image:GE715L3.PNG|Figure 3: Pressure at timestep 0.001 s&lt;br /&gt;
Image:GE715L4.PNG|Figure 4: Energy at timestep 0.0025 s&lt;br /&gt;
Image:GE715L5.PNG|Figure 5: Energy at timestep 0.0075 s&lt;br /&gt;
Image:GE715L6.PNG|Figure 6: Energy at timestep 0.01 s&lt;br /&gt;
Image:GE715L7.PNG|Figure 7: Energy at timestep 0.015 s&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Specific conditions ==&lt;br /&gt;
&lt;br /&gt;
The next task was to run simulations varying temperatures at constant pressure. This shows the dependence of density on temperature at a constant pressure. Considering the ideal gas law the density will be inversely proportional with temperature.&lt;br /&gt;
&lt;br /&gt;
If we run simulations under different conditions, we get the results shown in the gallery below. Bear in mind that some errors are almost negligible.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400 px&amp;gt;&lt;br /&gt;
Image:GE715L8.PNG|Figure 8: Density vs temperature at p=2&lt;br /&gt;
Image:GE715L9.PNG|Figure 9: Density vs temperature at p=3&lt;br /&gt;
Image:GE715L16.PNG|Figure 10: Inverse of density vs temperature at p=2&lt;br /&gt;
Image:GE715L17.PNG|Figure 11: Inverse of density vs temperature at p=3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The inverses are of densities are shown to prove that this simulation obeys the proportionality proposed ideal gas law, where the density and temperature are inversely proportional.&lt;br /&gt;
&lt;br /&gt;
== Radial distribution functions ==&lt;br /&gt;
&lt;br /&gt;
The radial distribution functions from the calculations are given in the gallery below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400 px&amp;gt;&lt;br /&gt;
Image:GE715L10.PNG|Figure 12: RDF for gas&lt;br /&gt;
Image:GE715L11.PNG|Figure 13: RDF for liquid&lt;br /&gt;
Image:GE715L12.PNG|Figure 14: RDF for solid&lt;br /&gt;
Image:GE715L13.PNG|Figure 15: Integral of RDF for gas&lt;br /&gt;
Image:GE715L14.PNG|Figure 16: Integral of RDF for liquid&lt;br /&gt;
Image:GE715L15.PNG|Figure 17: Integral of RDF for solid&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see from the graphs the differences between different phases and their order. It is clear that in a solid lattice structure is fairly rigid (peaks are the neighbouring atoms), liquid is slightly less ordered, while gas has almost. no real order at all. Lattice spacing in a solid is &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt;, while the first peak represents the nearest neighbouring atoms, while the next two represent the atom that are not nearest neighbours, but are less than two atoms away in a straight line from the central atom. The interactions are dropping of with distance, as expected in Lennard-Jones model.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
It has been determined that appropriate timestep for dynamics calculations is 0.0025 s. Simulations were performed to determine that temperature and density of a liquid are inversely proportional. It was also found that radial distribution function depends heavily on the phase of matter, with order being clearly seen in solid lattice.&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=657008</id>
		<title>Rep:Liquids GE715</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=657008"/>
		<updated>2018-01-26T18:11:14Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract ==&lt;br /&gt;
&lt;br /&gt;
In this experiment properties of liquids were modelled using molecular dynamics experiments. The effect of the temperature on the density as well as the radial distribution functions were explored.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Molecular dynamics is a modern computational technique concerned with calculating properties of substances by modelling them and their behaviour on atomic level with powerful computers.&lt;br /&gt;
&lt;br /&gt;
Lennard Jones potential equals &amp;lt;math&amp;gt;\phi\left(r\right) = 4\epsilon \left( \frac{\sigma^{12}}{r^{12}} - \frac{\sigma^6}{r^6} \right)&amp;lt;/math&amp;gt;. Potential energy is zero at the point when &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt;, thus &amp;lt;math&amp;gt;r_0=\sigma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Force is simply the derivative of the potential, thus &amp;lt;math&amp;gt;F = 4\epsilon \left( -12 \frac{\sigma^{12}}{r^{13}} + 6 \frac{\sigma^6}{r^7} \right)&amp;lt;/math&amp;gt;. At &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt; this equals &amp;lt;math&amp;gt;F = - \frac{24\epsilon}{\sigma}&amp;lt;/math&amp;gt;. Well depth is &amp;lt;math&amp;gt;\phi\left(r_{eq}\right) = - \epsilon&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;r_{eq}=\sigma \sqrt[6]{2}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The following integrals are equal to: &amp;lt;math&amp;gt;\int_{2\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.0248&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\int_{2.5\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00818&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\int_{3\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00329&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Introductory tasks ===&lt;br /&gt;
&lt;br /&gt;
==== Water ====&lt;br /&gt;
&lt;br /&gt;
There are roughly &amp;lt;math&amp;gt;3.3*10^{22}&amp;lt;/math&amp;gt; molecules in 1 mL of water. However, 10000 atoms of water take up about &amp;lt;math&amp;gt;3*10^{-19} mL&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;300 nm^{3}&amp;lt;/math&amp;gt;. This is a good illustration of how different atomic scale is from the scale on which the properties of substances tend to be observed.&lt;br /&gt;
&lt;br /&gt;
==== Atoms ====&lt;br /&gt;
&lt;br /&gt;
Atom at position &amp;lt;math&amp;gt;(0.5,0.5,0.5)&amp;lt;/math&amp;gt; moved for &amp;lt;math&amp;gt;(0.7,0.6,0.2)&amp;lt;/math&amp;gt; would be found at &amp;lt;math&amp;gt;(0.2,0.1,0.7)&amp;lt;/math&amp;gt;, since it would be copied in both x and y direction (assuming x,y,z).&lt;br /&gt;
&lt;br /&gt;
==== Reduced units ====&lt;br /&gt;
&lt;br /&gt;
Lennard-Jones parameters for argon were given, the macroscopic properties are calculated here.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;LJ_{cut-off}=1.088 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;T=180 K&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;r=0.382 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;E=1 \frac{kJ}{mol}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Aims and Objectives ==&lt;br /&gt;
&lt;br /&gt;
The aim of this experiment was to explore the modern use of molecular dynamics for simulating simple liquids.&lt;br /&gt;
&lt;br /&gt;
The objectives were to look at how timesteps used in experiment affect the quality of the results, how temperature affects density and find radial distribution functions and their integrals for different phases of matter.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
&lt;br /&gt;
The calculations were performed on a high performance computer using LAMMPS software package, while the calculations of radial distribution functions were done using VMD (delta r=0.05).&lt;br /&gt;
&lt;br /&gt;
== Equilibration ==&lt;br /&gt;
&lt;br /&gt;
If two atoms were generated very close together that would mean the force between them would be enormous, which would have a potential to heavily disturb the simulation (very high potential energy would increase the temperature).&lt;br /&gt;
&lt;br /&gt;
=== Commands ====&lt;br /&gt;
&lt;br /&gt;
mass 1 1.0 signifies that the mass of the first kind of particles (1) is 1.0.&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut 3.0 tells us where the interactions are cut off, as seen in the integral above, &amp;lt;math&amp;gt;3.0 \sigma&amp;lt;/math&amp;gt; is a very good cut-off, since there is no significant perturbation.&lt;br /&gt;
&lt;br /&gt;
The algorithm used for the calculations is velocity-Verlet, because the classical one does not use velocities.&lt;br /&gt;
&lt;br /&gt;
=== Simulations ===&lt;br /&gt;
&lt;br /&gt;
In the gallery below graphs are shown. It can be seen that as timesteps are increasing, the quality of results is decreasing. Timpestep of 0.015 s is wholy inappropriate, but I have chosen to run the experiments at the timestep of 0.0025 s. Results would probably also be almost as good using 0.01 s. We can see this by the fact that equilibrium is reached very quickly, for the first for timesteps in the space of 0.1 s -0.3 s. The highest timestep will mimic the reality better, but it might be too demanding computationally.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=200 px&amp;gt;&lt;br /&gt;
Image:GE715L1.PNG|Figure 1: Energy at timestep 0.001 s&lt;br /&gt;
Image:GE715L2.PNG|Figure 2: Temperature at timestep 0.001 s&lt;br /&gt;
Image:GE715L3.PNG|Figure 3: Pressure at timestep 0.001 s&lt;br /&gt;
Image:GE715L4.PNG|Figure 4: Energy at timestep 0.0025 s&lt;br /&gt;
Image:GE715L5.PNG|Figure 5: Energy at timestep 0.0075 s&lt;br /&gt;
Image:GE715L6.PNG|Figure 6: Energy at timestep 0.01 s&lt;br /&gt;
Image:GE715L7.PNG|Figure 7: Energy at timestep 0.015 s&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Specific conditions ==&lt;br /&gt;
&lt;br /&gt;
The next task was to run simulations varying temperatures at constant pressure. This shows the dependence of density on temperature at a constant pressure. Considering the ideal gas law the density will be inversely proportional with temperature.&lt;br /&gt;
&lt;br /&gt;
If we run simulations under different conditions, we get the results shown in the gallery below. Bear in mind that some errors are almost negligible.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400 px&amp;gt;&lt;br /&gt;
Image:GE715L8.PNG|Figure 8: Density vs temperature at p=2&lt;br /&gt;
Image:GE715L9.PNG|Figure 9: Density vs temperature at p=3&lt;br /&gt;
Image:GE715L16.PNG|Figure 10: Inverse of density vs temperature at p=2&lt;br /&gt;
Image:GE715L17.PNG|Figure 11: Inverse of density vs temperature at p=3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The inverses are of densities are shown to prove that this simulation obeys the proportionality proposed ideal gas law, where the density and temperature are inversely proportional.&lt;br /&gt;
&lt;br /&gt;
== Radial distribution functions ==&lt;br /&gt;
&lt;br /&gt;
The radial distribution functions from the calculations are given in the gallery below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400 px&amp;gt;&lt;br /&gt;
Image:GE715L10.PNG|Figure 12: RDF for gas&lt;br /&gt;
Image:GE715L11.PNG|Figure 13: RDF for liquid&lt;br /&gt;
Image:GE715L12.PNG|Figure 14: RDF for solid&lt;br /&gt;
Image:GE715L13.PNG|Figure 15: Integral of RDF for gas&lt;br /&gt;
Image:GE715L14.PNG|Figure 16: Integral of RDF for liquid&lt;br /&gt;
Image:GE715L15.PNG|Figure 17: Integral of RDF for solid&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see from the graphs the differences between different phases and their order. It is clear that in a solid lattice structure is fairly rigid (peaks are the neighbouring atoms), liquid is slightly less ordered, while gas has almost. no real order at all. Lattice spacing in a solid is &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt;, while the first peak represents the nearest neighbouring atoms, while the next two represent the atom that are not nearest neighbours, but are less than two atoms away in a straight line from the central atom.&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L17.PNG&amp;diff=657007</id>
		<title>File:GE715L17.PNG</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L17.PNG&amp;diff=657007"/>
		<updated>2018-01-26T18:11:04Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L16.PNG&amp;diff=657006</id>
		<title>File:GE715L16.PNG</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L16.PNG&amp;diff=657006"/>
		<updated>2018-01-26T18:10:43Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=656992</id>
		<title>Rep:Liquids GE715</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=656992"/>
		<updated>2018-01-26T17:42:34Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract ==&lt;br /&gt;
&lt;br /&gt;
In this experiment properties of liquids were modelled using molecular dynamics experiments. The effect of the temperature on the density as well as the radial distribution functions were explored.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Molecular dynamics is a modern computational technique concerned with calculating properties of substances by modelling them and their behaviour on atomic level with powerful computers.&lt;br /&gt;
&lt;br /&gt;
Lennard Jones potential equals &amp;lt;math&amp;gt;\phi\left(r\right) = 4\epsilon \left( \frac{\sigma^{12}}{r^{12}} - \frac{\sigma^6}{r^6} \right)&amp;lt;/math&amp;gt;. Potential energy is zero at the point when &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt;, thus &amp;lt;math&amp;gt;r_0=\sigma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Force is simply the derivative of the potential, thus &amp;lt;math&amp;gt;F = 4\epsilon \left( -12 \frac{\sigma^{12}}{r^{13}} + 6 \frac{\sigma^6}{r^7} \right)&amp;lt;/math&amp;gt;. At &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt; this equals &amp;lt;math&amp;gt;F = - \frac{24\epsilon}{\sigma}&amp;lt;/math&amp;gt;. Well depth is &amp;lt;math&amp;gt;\phi\left(r_{eq}\right) = - \epsilon&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;r_{eq}=\sigma \sqrt[6]{2}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The following integrals are equal to: &amp;lt;math&amp;gt;\int_{2\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.0248&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\int_{2.5\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00818&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\int_{3\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00329&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Water ===&lt;br /&gt;
&lt;br /&gt;
There are roughly &amp;lt;math&amp;gt;3.3*10^{22}&amp;lt;/math&amp;gt; molecules in 1 mL of water. However, 10000 atoms of water take up about &amp;lt;math&amp;gt;3*10^{-19} mL&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;300 nm^{3}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Atoms ===&lt;br /&gt;
&lt;br /&gt;
Atom at position &amp;lt;math&amp;gt;(0.5,0.5,0.5)&amp;lt;/math&amp;gt; moved for &amp;lt;math&amp;gt;(0.7,0.6,0.2)&amp;lt;/math&amp;gt; would be found at &amp;lt;math&amp;gt;(0.2,0.1,0.7)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Reduced units ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;LJ_{cut-off}=1.088 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;T=180 K&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;r=0.382 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;E=1 \frac{kJ}{mol}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Aims and Objectives ==&lt;br /&gt;
&lt;br /&gt;
The aim of this experiment was to explore the modern use of molecular dynamics for simulating simple liquids.&lt;br /&gt;
&lt;br /&gt;
The objectives were to look at how timesteps used in experiment affect the quality of the results, how temperature affects density and find radial distribution functions and their integrals for different phases of matter.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
&lt;br /&gt;
The calculations were performed on a high performance computer using LAMMPS software package, while the calculations of radial distribution functions were done using VMD (delta r=0.05).&lt;br /&gt;
&lt;br /&gt;
== Equilibration ==&lt;br /&gt;
&lt;br /&gt;
If two atoms were generated very close together that would mean the force between them would be huge, which would have a potential to heavily disturb the simulation.&lt;br /&gt;
&lt;br /&gt;
=== Commands ====&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut 3.0 tells us where the interactions are cut off, as seen in the integral above, &amp;lt;math&amp;gt;3.0 \sigma&amp;lt;/math&amp;gt; is a very good cut-off, since there is no significant perturbation.&lt;br /&gt;
&lt;br /&gt;
=== Simulations ===&lt;br /&gt;
&lt;br /&gt;
In the gallery below graphs are shown. It can be seen that as timesteps are increasing, the quality of results is decreasing. Timpestep of 0.015 s is wholy inappropriate, but I have chosen to run the experiments at the timestep of 0.0025 s. Results would probably also be almost as good using 0.01 s.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=200 px&amp;gt;&lt;br /&gt;
Image:GE715L1.PNG|Figure 1: Energy at timestep 0.001 s&lt;br /&gt;
Image:GE715L2.PNG|Figure 2: Temperature at timestep 0.001 s&lt;br /&gt;
Image:GE715L3.PNG|Figure 3: Pressure at timestep 0.001 s&lt;br /&gt;
Image:GE715L4.PNG|Figure 4: Energy at timestep 0.0025 s&lt;br /&gt;
Image:GE715L5.PNG|Figure 5: Energy at timestep 0.0075 s&lt;br /&gt;
Image:GE715L6.PNG|Figure 6: Energy at timestep 0.01 s&lt;br /&gt;
Image:GE715L7.PNG|Figure 7: Energy at timestep 0.015 s&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Specific conditions ==&lt;br /&gt;
&lt;br /&gt;
If we run simulations under different conditions, we get the results shown in the gallery below. Bear in mind that some errors are almost negligible.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400 px&amp;gt;&lt;br /&gt;
Image:GE715L8.PNG|Figure 8: Density vs temperature at p=2&lt;br /&gt;
Image:GE715L9.PNG|Figure 9: Density vs temperature at p=3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Radial distribution functions ==&lt;br /&gt;
&lt;br /&gt;
The radial distribution functions from the calculations are given in the gallery below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400 px&amp;gt;&lt;br /&gt;
Image:GE715L10.PNG|Figure 10: RDF for gas&lt;br /&gt;
Image:GE715L11.PNG|Figure 11: RDF for liquid&lt;br /&gt;
Image:GE715L12.PNG|Figure 12: RDF for solid&lt;br /&gt;
Image:GE715L13.PNG|Figure 13: Integral of RDF for gas&lt;br /&gt;
Image:GE715L14.PNG|Figure 14: Integral of RDF for liquid&lt;br /&gt;
Image:GE715L15.PNG|Figure 15: Integral of RDF for solid&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see from the graphs the differences between different phases and their order. It is clear that in a solid lattice structure is fairly rigid (peaks are the neighbouring atoms), liquid is slightly less ordered, while gas has almost. no real order at all. Lattice spacing in a solid is &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt;, while the first peak represents the nearest neighbouring atoms, while the next two represent the atom that are not nearest neighbours, but are less than two atoms away in a straight line from the central atom.&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=656985</id>
		<title>Rep:Liquids GE715</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=656985"/>
		<updated>2018-01-26T17:37:00Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract ==&lt;br /&gt;
&lt;br /&gt;
In this experiment properties of liquids were modelled using molecular dynamics experiments. The effect of the temperature on the density as well as the radial distribution functions were explored.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Molecular dynamics is a modern computational technique concerned with calculating properties of substances by modelling them and their behaviour on atomic level with powerful computers.&lt;br /&gt;
&lt;br /&gt;
Lennard Jones potential equals &amp;lt;math&amp;gt;\phi\left(r\right) = 4\epsilon \left( \frac{\sigma^{12}}{r^{12}} - \frac{\sigma^6}{r^6} \right)&amp;lt;/math&amp;gt;. Potential energy is zero at the point when &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt;, thus &amp;lt;math&amp;gt;r_0=\sigma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Force is simply the derivative of the potential, thus &amp;lt;math&amp;gt;F = 4\epsilon \left( -12 \frac{\sigma^{12}}{r^{13}} + 6 \frac{\sigma^6}{r^7} \right)&amp;lt;/math&amp;gt;. At &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt; this equals &amp;lt;math&amp;gt;F = - \frac{24\epsilon}{\sigma}&amp;lt;/math&amp;gt;. Well depth is &amp;lt;math&amp;gt;\phi\left(r_{eq}\right) = 1 \frac{kJ}{mol}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The following integrals are equal to: &amp;lt;math&amp;gt;\int_{2\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.0248&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\int_{2.5\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00818&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\int_{3\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00329&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Water ===&lt;br /&gt;
&lt;br /&gt;
There are roughly &amp;lt;math&amp;gt;3.3*10^{22}&amp;lt;/math&amp;gt; molecules in 1 mL of water. However, 10000 atoms of water take up about &amp;lt;math&amp;gt;3*10^{-19} mL&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;300 nm^{3}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Atoms ===&lt;br /&gt;
&lt;br /&gt;
Atom at position &amp;lt;math&amp;gt;(0.5,0.5,0.5)&amp;lt;/math&amp;gt; moved for &amp;lt;math&amp;gt;(0.7,0.6,0.2)&amp;lt;/math&amp;gt; would be found at &amp;lt;math&amp;gt;(0.2,0.1,0.7)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Reduced units ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;LJ_{cut-off}=1.088 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;T=180 K&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;r=0.382 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;E=1 \frac{kJ}{mol}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Aims and Objectives ==&lt;br /&gt;
&lt;br /&gt;
The aim of this experiment was to explore the modern use of molecular dynamics for simulating simple liquids.&lt;br /&gt;
&lt;br /&gt;
The objectives were to look at how timesteps used in experiment affect the quality of the results, how temperature affects density and find radial distribution functions and their integrals for different phases of matter.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
&lt;br /&gt;
The calculations were performed on a high performance computer using LAMMPS software package, while the calculations of radial distribution functions were done using VMD (delta r=0.05).&lt;br /&gt;
&lt;br /&gt;
== Equilibration ==&lt;br /&gt;
&lt;br /&gt;
If two atoms were generated very close together that would mean the force between them would be huge, which would have a potential to heavily disturb the simulation.&lt;br /&gt;
&lt;br /&gt;
=== Commands ====&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut 3.0 tells us where the interactions are cut off, as seen in the integral above, &amp;lt;math&amp;gt;3.0 \sigma&amp;lt;/math&amp;gt; is a very good cut-off, since there is no significant perturbation.&lt;br /&gt;
&lt;br /&gt;
=== Simulations ===&lt;br /&gt;
&lt;br /&gt;
In the gallery below graphs are shown. It can be seen that as timesteps are increasing, the quality of results is decreasing. Timpestep of 0.015 s is wholy inappropriate, but I have chosen to run the experiments at the timestep of 0.0025 s. Results would probably also be almost as good using 0.01 s.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=200 px&amp;gt;&lt;br /&gt;
Image:GE715L1.PNG|Figure 1: Energy at timestep 0.001 s&lt;br /&gt;
Image:GE715L2.PNG|Figure 2: Temperature at timestep 0.001 s&lt;br /&gt;
Image:GE715L3.PNG|Figure 3: Pressure at timestep 0.001 s&lt;br /&gt;
Image:GE715L4.PNG|Figure 4: Energy at timestep 0.0025 s&lt;br /&gt;
Image:GE715L5.PNG|Figure 5: Energy at timestep 0.0075 s&lt;br /&gt;
Image:GE715L6.PNG|Figure 6: Energy at timestep 0.01 s&lt;br /&gt;
Image:GE715L7.PNG|Figure 7: Energy at timestep 0.015 s&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Specific conditions ==&lt;br /&gt;
&lt;br /&gt;
If we run simulations under different conditions, we get the results shown in the gallery below. Bear in mind that some errors are almost negligible.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400 px&amp;gt;&lt;br /&gt;
Image:GE715L8.PNG|Figure 8: Density vs temperature at p=2&lt;br /&gt;
Image:GE715L9.PNG|Figure 9: Density vs temperature at p=3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Radial distribution functions ==&lt;br /&gt;
&lt;br /&gt;
The radial distribution functions from the calculations are given in the gallery below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400 px&amp;gt;&lt;br /&gt;
Image:GE715L10.PNG|Figure 10: RDF for gas&lt;br /&gt;
Image:GE715L11.PNG|Figure 11: RDF for liquid&lt;br /&gt;
Image:GE715L12.PNG|Figure 12: RDF for solid&lt;br /&gt;
Image:GE715L13.PNG|Figure 13: Integral of RDF for gas&lt;br /&gt;
Image:GE715L14.PNG|Figure 14: Integral of RDF for liquid&lt;br /&gt;
Image:GE715L15.PNG|Figure 15: Integral of RDF for solid&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see from the graphs the differences between different phases and their order. It is clear that in a solid lattice structure is fairly rigid (peaks are the neighbouring atoms), liquid is slightly less ordered, while gas has almost. no real order at all. Lattice spacing in a solid is &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt;, while the first peak represents the nearest neighbouring atoms, while the next two represent the atom that are not nearest neighbours, but are less than two atoms away in a straight line from the central atom.&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=656961</id>
		<title>Rep:Liquids GE715</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=656961"/>
		<updated>2018-01-26T17:19:21Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Lennard Jones potential equals &amp;lt;math&amp;gt;\phi\left(r\right) = 4\epsilon \left( \frac{\sigma^{12}}{r^{12}} - \frac{\sigma^6}{r^6} \right)&amp;lt;/math&amp;gt;. Potential energy is zero at the point when &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt;, thus &amp;lt;math&amp;gt;r_0=\sigma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Force is simply the derivative of the potential, thus &amp;lt;math&amp;gt;F = 4\epsilon \left( -12 \frac{\sigma^{12}}{r^{13}} + 6 \frac{\sigma^6}{r^7} \right)&amp;lt;/math&amp;gt;. At &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt; this equals &amp;lt;math&amp;gt;F = - \frac{24\epsilon}{\sigma}&amp;lt;/math&amp;gt;. Well depth is &amp;lt;math&amp;gt;\phi\left(r_{eq}\right) = 1 \frac{kJ}{mol}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The following integrals are equal to: &amp;lt;math&amp;gt;\int_{2\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.0248&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\int_{2.5\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00818&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\int_{3\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00329&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Water ===&lt;br /&gt;
&lt;br /&gt;
There are roughly &amp;lt;math&amp;gt;3.3*10^{22}&amp;lt;/math&amp;gt; molecules in 1 mL of water. However, 10000 atoms of water take up about &amp;lt;math&amp;gt;3*10^{-19} mL&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;300 nm^{3}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Atoms ===&lt;br /&gt;
&lt;br /&gt;
Atom at position &amp;lt;math&amp;gt;(0.5,0.5,0.5)&amp;lt;/math&amp;gt; moved for &amp;lt;math&amp;gt;(0.7,0.6,0.2)&amp;lt;/math&amp;gt; would be found at &amp;lt;math&amp;gt;(0.2,0.1,0.7)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Reduced units ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;LJ cut-off=1.088 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;T=180 K&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;r=0.382 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;E=1 \frac{kJ}{mol}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Equilibration ==&lt;br /&gt;
&lt;br /&gt;
If two atoms were generated very close together that would mean the force between them would be huge, which would have a potential to heavily disturb the simulation.&lt;br /&gt;
&lt;br /&gt;
=== Commands ====&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut 3.0 tells us where the interactions are cut off, as seen in the integral above, &amp;lt;math&amp;gt;3.0 \sigma&amp;lt;/math&amp;gt; is a very good cut-off, since there is no significant perturbation.&lt;br /&gt;
&lt;br /&gt;
=== Simulations ===&lt;br /&gt;
&lt;br /&gt;
In the gallery below graphs are shown. It can be seen that as timesteps are increasing, the quality of results is decreasing. Timpestep of 0.015 s is wholy inappropriate, but I have chosen to run the experiments at the timestep of 0.0025 s. Results would probably also be almost as good using 0.01 s.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=200 px&amp;gt;&lt;br /&gt;
Image:GE715L1.PNG|Figure 1: Energy at timestep 0.001 s&lt;br /&gt;
Image:GE715L2.PNG|Figure 2: Temperature at timestep 0.001 s&lt;br /&gt;
Image:GE715L3.PNG|Figure 3: Pressure at timestep 0.001 s&lt;br /&gt;
Image:GE715L4.PNG|Figure 4: Energy at timestep 0.0025 s&lt;br /&gt;
Image:GE715L5.PNG|Figure 5: Energy at timestep 0.0075 s&lt;br /&gt;
Image:GE715L6.PNG|Figure 6: Energy at timestep 0.01 s&lt;br /&gt;
Image:GE715L7.PNG|Figure 7: Energy at timestep 0.015 s&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Specific conditions ==&lt;br /&gt;
&lt;br /&gt;
If we run simulations under different conditions, we get the results shown in the gallery below. Bear in mind that some errors are almost negligible.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400 px&amp;gt;&lt;br /&gt;
Image:GE715L8.PNG|Figure 8: Density vs temperature at p=2&lt;br /&gt;
Image:GE715L9.PNG|Figure 9: Density vs temperature at p=3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Radial distribution functions ==&lt;br /&gt;
&lt;br /&gt;
The radial distribution functions from the calculations are given in the gallery below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400 px&amp;gt;&lt;br /&gt;
Image:GE715L10.PNG|Figure 10: RDF for gas&lt;br /&gt;
Image:GE715L11.PNG|Figure 11: RDF for liquid&lt;br /&gt;
Image:GE715L12.PNG|Figure 12: RDF for solid&lt;br /&gt;
Image:GE715L13.PNG|Figure 13: Integral of RDF for gas&lt;br /&gt;
Image:GE715L14.PNG|Figure 14: Integral of RDF for liquid&lt;br /&gt;
Image:GE715L15.PNG|Figure 15: Integral of RDF for solid&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see from the graphs the differences between different phases and their order. It is clear that in a solid lattice structure is fairly rigid (peaks are the neighbouring atoms), liquid is slightly less ordered, while gas has almost. no real order at all. Lattice spacing in a solid is &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt;, while the first peak represents the nearest neighbouring atoms, while the next two represent the atom that are not nearest neighbours, but are less than two atoms away in a straight line from the central atom.&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L15.PNG&amp;diff=656955</id>
		<title>File:GE715L15.PNG</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L15.PNG&amp;diff=656955"/>
		<updated>2018-01-26T17:12:45Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L14.PNG&amp;diff=656954</id>
		<title>File:GE715L14.PNG</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L14.PNG&amp;diff=656954"/>
		<updated>2018-01-26T17:12:30Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L13.PNG&amp;diff=656953</id>
		<title>File:GE715L13.PNG</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L13.PNG&amp;diff=656953"/>
		<updated>2018-01-26T17:12:00Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=656950</id>
		<title>Rep:Liquids GE715</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=656950"/>
		<updated>2018-01-26T17:11:22Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Lennard Jones potential equals &amp;lt;math&amp;gt;\phi\left(r\right) = 4\epsilon \left( \frac{\sigma^{12}}{r^{12}} - \frac{\sigma^6}{r^6} \right)&amp;lt;/math&amp;gt;. Potential energy is zero at the point when &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt;, thus &amp;lt;math&amp;gt;r_0=\sigma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Force is simply the derivative of the potential, thus &amp;lt;math&amp;gt;F = 4\epsilon \left( -12 \frac{\sigma^{12}}{r^{13}} + 6 \frac{\sigma^6}{r^7} \right)&amp;lt;/math&amp;gt;. At &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt; this equals &amp;lt;math&amp;gt;F = - \frac{24\epsilon}{\sigma}&amp;lt;/math&amp;gt;. Well depth is &amp;lt;math&amp;gt;\phi\left(r_{eq}\right) = 1 \frac{kJ}{mol}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The following integrals are equal to: &amp;lt;math&amp;gt;\int_{2\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.0248&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\int_{2.5\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00818&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\int_{3\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00329&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Water ===&lt;br /&gt;
&lt;br /&gt;
There are roughly &amp;lt;math&amp;gt;3.3*10^{22}&amp;lt;/math&amp;gt; molecules in 1 mL of water. However, 10000 atoms of water take up about &amp;lt;math&amp;gt;3*10^{-19} mL&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;300 nm^{3}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Atoms ===&lt;br /&gt;
&lt;br /&gt;
Atom at position &amp;lt;math&amp;gt;(0.5,0.5,0.5)&amp;lt;/math&amp;gt; moved for &amp;lt;math&amp;gt;(0.7,0.6,0.2)&amp;lt;/math&amp;gt; would be found at &amp;lt;math&amp;gt;(0.2,0.1,0.7)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Reduced units ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;LJ cut-off=1.088 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;T=180 K&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;r=0.382 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;E=1 \frac{kJ}{mol}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Equilibration ==&lt;br /&gt;
&lt;br /&gt;
If two atoms were generated very close together that would mean the force between them would be huge, which would have a potential to heavily disturb the simulation.&lt;br /&gt;
&lt;br /&gt;
=== Commands ====&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut 3.0 tells us where the interactions are cut off, as seen in the integral above, &amp;lt;math&amp;gt;3.0 \sigma&amp;lt;/math&amp;gt; is a very good cut-off, since there is no significant perturbation.&lt;br /&gt;
&lt;br /&gt;
=== Simulations ===&lt;br /&gt;
&lt;br /&gt;
In the gallery below graphs are shown. It can be seen that as timesteps are increasing, the quality of results is decreasing. Timpestep of 0.015 s is wholy inappropriate, but I have chosen to run the experiments at the timestep of 0.0025 s. Results would probably also be almost as good using 0.01 s.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=200 px&amp;gt;&lt;br /&gt;
Image:GE715L1.PNG|Figure 1: Energy at timestep 0.001 s&lt;br /&gt;
Image:GE715L2.PNG|Figure 2: Temperature at timestep 0.001 s&lt;br /&gt;
Image:GE715L3.PNG|Figure 3: Pressure at timestep 0.001 s&lt;br /&gt;
Image:GE715L4.PNG|Figure 4: Energy at timestep 0.0025 s&lt;br /&gt;
Image:GE715L5.PNG|Figure 5: Energy at timestep 0.0075 s&lt;br /&gt;
Image:GE715L6.PNG|Figure 6: Energy at timestep 0.01 s&lt;br /&gt;
Image:GE715L7.PNG|Figure 7: Energy at timestep 0.015 s&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Specific conditions ==&lt;br /&gt;
&lt;br /&gt;
If we run simulations under different conditions, we get the results shown in the gallery below. Bear in mind that some errors are almost negligible.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400 px&amp;gt;&lt;br /&gt;
Image:GE715L8.PNG|Figure 8: Density vs temperature at p=2&lt;br /&gt;
Image:GE715L9.PNG|Figure 9: Density vs temperature at p=3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Radial distribution functions ==&lt;br /&gt;
&lt;br /&gt;
The radial distribution functions from the calculations are given in the gallery below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400 px&amp;gt;&lt;br /&gt;
Image:GE715L10.PNG|Figure 10: RDF for gas&lt;br /&gt;
Image:GE715L11.PNG|Figure 11: RDF for liquid&lt;br /&gt;
Image:GE715L12.PNG|Figure 12: RDF for solid&lt;br /&gt;
Image:GE715L13.PNG|Figure 13: Integral of RDF for gas&lt;br /&gt;
Image:GE715L14.PNG|Figure 14: Integral of RDF for liquid&lt;br /&gt;
Image:GE715L15.PNG|Figure 15: Integral of RDF for solid&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L12.PNG&amp;diff=656940</id>
		<title>File:GE715L12.PNG</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L12.PNG&amp;diff=656940"/>
		<updated>2018-01-26T17:06:35Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=656931</id>
		<title>Rep:Liquids GE715</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=656931"/>
		<updated>2018-01-26T16:58:16Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Lennard Jones potential equals &amp;lt;math&amp;gt;\phi\left(r\right) = 4\epsilon \left( \frac{\sigma^{12}}{r^{12}} - \frac{\sigma^6}{r^6} \right)&amp;lt;/math&amp;gt;. Potential energy is zero at the point when &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt;, thus &amp;lt;math&amp;gt;r_0=\sigma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Force is simply the derivative of the potential, thus &amp;lt;math&amp;gt;F = 4\epsilon \left( -12 \frac{\sigma^{12}}{r^{13}} + 6 \frac{\sigma^6}{r^7} \right)&amp;lt;/math&amp;gt;. At &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt; this equals &amp;lt;math&amp;gt;F = - \frac{24\epsilon}{\sigma}&amp;lt;/math&amp;gt;. Well depth is &amp;lt;math&amp;gt;\phi\left(r_{eq}\right) = 1 \frac{kJ}{mol}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The following integrals are equal to: &amp;lt;math&amp;gt;\int_{2\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.0248&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\int_{2.5\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00818&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\int_{3\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00329&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Water ===&lt;br /&gt;
&lt;br /&gt;
There are roughly &amp;lt;math&amp;gt;3.3*10^{22}&amp;lt;/math&amp;gt; molecules in 1 mL of water. However, 10000 atoms of water take up about &amp;lt;math&amp;gt;3*10^{-19} mL&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;300 nm^{3}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Atoms ===&lt;br /&gt;
&lt;br /&gt;
Atom at position &amp;lt;math&amp;gt;(0.5,0.5,0.5)&amp;lt;/math&amp;gt; moved for &amp;lt;math&amp;gt;(0.7,0.6,0.2)&amp;lt;/math&amp;gt; would be found at &amp;lt;math&amp;gt;(0.2,0.1,0.7)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Reduced units ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;LJ cut-off=1.088 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;T=180 K&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;r=0.382 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;E=1 \frac{kJ}{mol}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Equilibration ==&lt;br /&gt;
&lt;br /&gt;
If two atoms were generated very close together that would mean the force between them would be huge, which would have a potential to heavily disturb the simulation.&lt;br /&gt;
&lt;br /&gt;
=== Commands ====&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut 3.0 tells us where the interactions are cut off, as seen in the integral above, &amp;lt;math&amp;gt;3.0 \sigma&amp;lt;/math&amp;gt; is a very good cut-off, since there is no significant perturbation.&lt;br /&gt;
&lt;br /&gt;
=== Simulations ===&lt;br /&gt;
&lt;br /&gt;
In the gallery below graphs are shown. It can be seen that as timesteps are increasing, the quality of results is decreasing. Timpestep of 0.015 s is wholy inappropriate, but I have chosen to run the experiments at the timestep of 0.0025 s. Results would probably also be almost as good using 0.01 s.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=200 px&amp;gt;&lt;br /&gt;
Image:GE715L1.PNG|Figure 1: Energy at timestep 0.001 s&lt;br /&gt;
Image:GE715L2.PNG|Figure 2: Temperature at timestep 0.001 s&lt;br /&gt;
Image:GE715L3.PNG|Figure 3: Pressure at timestep 0.001 s&lt;br /&gt;
Image:GE715L4.PNG|Figure 4: Energy at timestep 0.0025 s&lt;br /&gt;
Image:GE715L5.PNG|Figure 5: Energy at timestep 0.0075 s&lt;br /&gt;
Image:GE715L6.PNG|Figure 6: Energy at timestep 0.01 s&lt;br /&gt;
Image:GE715L7.PNG|Figure 7: Energy at timestep 0.015 s&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Specific conditions ==&lt;br /&gt;
&lt;br /&gt;
If we run simulations under different conditions, we get the results shown in the gallery below. Bear in mind that some errors are almost negligible.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400 px&amp;gt;&lt;br /&gt;
Image:GE715L8.PNG|Figure 8: Density vs temperature at p=2&lt;br /&gt;
Image:GE715L9.PNG|Figure 9: Density vs temperature at p=3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Radial distribution functions ==&lt;br /&gt;
&lt;br /&gt;
The radial distribution functions from the calculations are given in the gallery below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400 px&amp;gt;&lt;br /&gt;
Image:GE715L10.PNG|Figure 10: RDF for gas&lt;br /&gt;
Image:GE715L11.PNG|Figure 11: RDF for liquid&lt;br /&gt;
Image:GE715L12.PNG|Figure 12: RDF for solid&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L11.PNG&amp;diff=656930</id>
		<title>File:GE715L11.PNG</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L11.PNG&amp;diff=656930"/>
		<updated>2018-01-26T16:57:50Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=656923</id>
		<title>Rep:Liquids GE715</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=656923"/>
		<updated>2018-01-26T16:55:56Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Lennard Jones potential equals &amp;lt;math&amp;gt;\phi\left(r\right) = 4\epsilon \left( \frac{\sigma^{12}}{r^{12}} - \frac{\sigma^6}{r^6} \right)&amp;lt;/math&amp;gt;. Potential energy is zero at the point when &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt;, thus &amp;lt;math&amp;gt;r_0=\sigma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Force is simply the derivative of the potential, thus &amp;lt;math&amp;gt;F = 4\epsilon \left( -12 \frac{\sigma^{12}}{r^{13}} + 6 \frac{\sigma^6}{r^7} \right)&amp;lt;/math&amp;gt;. At &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt; this equals &amp;lt;math&amp;gt;F = - \frac{24\epsilon}{\sigma}&amp;lt;/math&amp;gt;. Well depth is &amp;lt;math&amp;gt;\phi\left(r_{eq}\right) = 1 \frac{kJ}{mol}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The following integrals are equal to: &amp;lt;math&amp;gt;\int_{2\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.0248&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\int_{2.5\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00818&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\int_{3\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00329&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Water ===&lt;br /&gt;
&lt;br /&gt;
There are roughly &amp;lt;math&amp;gt;3.3*10^{22}&amp;lt;/math&amp;gt; molecules in 1 mL of water. However, 10000 atoms of water take up about &amp;lt;math&amp;gt;3*10^{-19} mL&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;300 nm^{3}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Atoms ===&lt;br /&gt;
&lt;br /&gt;
Atom at position &amp;lt;math&amp;gt;(0.5,0.5,0.5)&amp;lt;/math&amp;gt; moved for &amp;lt;math&amp;gt;(0.7,0.6,0.2)&amp;lt;/math&amp;gt; would be found at &amp;lt;math&amp;gt;(0.2,0.1,0.7)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Reduced units ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;LJ cut-off=1.088 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;T=180 K&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;r=0.382 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;E=1 \frac{kJ}{mol}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Equilibration ==&lt;br /&gt;
&lt;br /&gt;
If two atoms were generated very close together that would mean the force between them would be huge, which would have a potential to heavily disturb the simulation.&lt;br /&gt;
&lt;br /&gt;
=== Commands ====&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut 3.0 tells us where the interactions are cut off, as seen in the integral above, &amp;lt;math&amp;gt;3.0 \sigma&amp;lt;/math&amp;gt; is a very good cut-off, since there is no significant perturbation.&lt;br /&gt;
&lt;br /&gt;
=== Simulations ===&lt;br /&gt;
&lt;br /&gt;
In the gallery below graphs are shown. It can be seen that as timesteps are increasing, the quality of results is decreasing. Timpestep of 0.015 s is wholy inappropriate, but I have chosen to run the experiments at the timestep of 0.0025 s. Results would probably also be almost as good using 0.01 s.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=200 px&amp;gt;&lt;br /&gt;
Image:GE715L1.PNG|Figure 1: Energy at timestep 0.001 s&lt;br /&gt;
Image:GE715L2.PNG|Figure 2: Temperature at timestep 0.001 s&lt;br /&gt;
Image:GE715L3.PNG|Figure 3: Pressure at timestep 0.001 s&lt;br /&gt;
Image:GE715L4.PNG|Figure 4: Energy at timestep 0.0025 s&lt;br /&gt;
Image:GE715L5.PNG|Figure 5: Energy at timestep 0.0075 s&lt;br /&gt;
Image:GE715L6.PNG|Figure 6: Energy at timestep 0.01 s&lt;br /&gt;
Image:GE715L7.PNG|Figure 7: Energy at timestep 0.015 s&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Specific conditions ==&lt;br /&gt;
&lt;br /&gt;
If we run simulations under different conditions, we get the results shown in the gallery below. Bear in mind that some errors are almost negligible.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400 px&amp;gt;&lt;br /&gt;
Image:GE715L8.PNG|Figure 8: Density vs temperature at p=2&lt;br /&gt;
Image:GE715L9.PNG|Figure 9: Density vs temperature at p=3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Radial distribution functions ==&lt;br /&gt;
&lt;br /&gt;
The radial distribution functions from the calculations are given in the gallery below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400 px&amp;gt;&lt;br /&gt;
Image:GE715L10.PNG|Figure 10: RDF for gas&lt;br /&gt;
Image:GE715L11.PNG|Figure 11: RDF for liquid&lt;br /&gt;
Image:GE715L11.PNG|Figure 12: RDF for solid&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L10.PNG&amp;diff=656920</id>
		<title>File:GE715L10.PNG</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L10.PNG&amp;diff=656920"/>
		<updated>2018-01-26T16:55:43Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L9.PNG&amp;diff=656912</id>
		<title>File:GE715L9.PNG</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L9.PNG&amp;diff=656912"/>
		<updated>2018-01-26T16:51:07Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=656895</id>
		<title>Rep:Liquids GE715</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=656895"/>
		<updated>2018-01-26T16:45:00Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Lennard Jones potential equals &amp;lt;math&amp;gt;\phi\left(r\right) = 4\epsilon \left( \frac{\sigma^{12}}{r^{12}} - \frac{\sigma^6}{r^6} \right)&amp;lt;/math&amp;gt;. Potential energy is zero at the point when &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt;, thus &amp;lt;math&amp;gt;r_0=\sigma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Force is simply the derivative of the potential, thus &amp;lt;math&amp;gt;F = 4\epsilon \left( -12 \frac{\sigma^{12}}{r^{13}} + 6 \frac{\sigma^6}{r^7} \right)&amp;lt;/math&amp;gt;. At &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt; this equals &amp;lt;math&amp;gt;F = - \frac{24\epsilon}{\sigma}&amp;lt;/math&amp;gt;. Well depth is &amp;lt;math&amp;gt;\phi\left(r_{eq}\right) = 1 \frac{kJ}{mol}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The following integrals are equal to: &amp;lt;math&amp;gt;\int_{2\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.0248&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\int_{2.5\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00818&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\int_{3\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00329&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Water ===&lt;br /&gt;
&lt;br /&gt;
There are roughly &amp;lt;math&amp;gt;3.3*10^{22}&amp;lt;/math&amp;gt; molecules in 1 mL of water. However, 10000 atoms of water take up about &amp;lt;math&amp;gt;3*10^{-19} mL&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;300 nm^{3}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Atoms ===&lt;br /&gt;
&lt;br /&gt;
Atom at position &amp;lt;math&amp;gt;(0.5,0.5,0.5)&amp;lt;/math&amp;gt; moved for &amp;lt;math&amp;gt;(0.7,0.6,0.2)&amp;lt;/math&amp;gt; would be found at &amp;lt;math&amp;gt;(0.2,0.1,0.7)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Reduced units ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;LJ cut-off=1.088 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;T=180 K&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;r=0.382 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;E=1 \frac{kJ}{mol}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Equilibration ==&lt;br /&gt;
&lt;br /&gt;
If two atoms were generated very close together that would mean the force between them would be huge, which would have a potential to heavily disturb the simulation.&lt;br /&gt;
&lt;br /&gt;
=== Commands ====&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut 3.0 tells us where the interactions are cut off, as seen in the integral above, &amp;lt;math&amp;gt;3.0 \sigma&amp;lt;/math&amp;gt; is a very good cut-off, since there is no significant perturbation.&lt;br /&gt;
&lt;br /&gt;
=== Simulations ===&lt;br /&gt;
&lt;br /&gt;
In the gallery below graphs are shown. It can be seen that as timesteps are increasing, the quality of results is decreasing. Timpestep of 0.015 s is wholy inappropriate, but I have chosen to run the experiments at the timestep of 0.0025 s. Results would probably also be almost as good using 0.01 s.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=200 px&amp;gt;&lt;br /&gt;
Image:GE715L1.PNG|Figure 1: Energy at timestep 0.001 s&lt;br /&gt;
Image:GE715L2.PNG|Figure 2: Temperature at timestep 0.001 s&lt;br /&gt;
Image:GE715L3.PNG|Figure 3: Pressure at timestep 0.001 s&lt;br /&gt;
Image:GE715L4.PNG|Figure 4: Energy at timestep 0.0025 s&lt;br /&gt;
Image:GE715L5.PNG|Figure 5: Energy at timestep 0.0075 s&lt;br /&gt;
Image:GE715L6.PNG|Figure 6: Energy at timestep 0.01 s&lt;br /&gt;
Image:GE715L7.PNG|Figure 7: Energy at timestep 0.015 s&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Specific conditions ==&lt;br /&gt;
&lt;br /&gt;
If we run simulations under different conditions, we get the results shown in the gallery below. Bear in mind that some errors are almost negligible.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400 px&amp;gt;&lt;br /&gt;
Image:GE715L8.PNG|Figure 8: Density vs temperature at p=2&lt;br /&gt;
Image:GE715L9.PNG|Figure 9: Density vs temperature at p=3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=656893</id>
		<title>Rep:Liquids GE715</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=656893"/>
		<updated>2018-01-26T16:44:07Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Lennard Jones potential equals &amp;lt;math&amp;gt;\phi\left(r\right) = 4\epsilon \left( \frac{\sigma^{12}}{r^{12}} - \frac{\sigma^6}{r^6} \right)&amp;lt;/math&amp;gt;. Potential energy is zero at the point when &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt;, thus &amp;lt;math&amp;gt;r_0=\sigma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Force is simply the derivative of the potential, thus &amp;lt;math&amp;gt;F = 4\epsilon \left( -12 \frac{\sigma^{12}}{r^{13}} + 6 \frac{\sigma^6}{r^7} \right)&amp;lt;/math&amp;gt;. At &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt; this equals &amp;lt;math&amp;gt;F = - \frac{24\epsilon}{\sigma}&amp;lt;/math&amp;gt;. Well depth is &amp;lt;math&amp;gt;\phi\left(r_{eq}\right) = 1 \frac{kJ}{mol}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The following integrals are equal to: &amp;lt;math&amp;gt;\int_{2\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.0248&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\int_{2.5\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00818&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\int_{3\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00329&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Water ===&lt;br /&gt;
&lt;br /&gt;
There are roughly &amp;lt;math&amp;gt;3.3*10^{22}&amp;lt;/math&amp;gt; molecules in 1 mL of water. However, 10000 atoms of water take up about &amp;lt;math&amp;gt;3*10^{-19} mL&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;300 nm^{3}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Atoms ===&lt;br /&gt;
&lt;br /&gt;
Atom at position &amp;lt;math&amp;gt;(0.5,0.5,0.5)&amp;lt;/math&amp;gt; moved for &amp;lt;math&amp;gt;(0.7,0.6,0.2)&amp;lt;/math&amp;gt; would be found at &amp;lt;math&amp;gt;(0.2,0.1,0.7)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Reduced units ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;LJ cut-off=1.088 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;T=180 K&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;r=0.382 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;E=1 \frac{kJ}{mol}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Equilibration ==&lt;br /&gt;
&lt;br /&gt;
If two atoms were generated very close together that would mean the force between them would be huge, which would have a potential to heavily disturb the simulation.&lt;br /&gt;
&lt;br /&gt;
=== Commands ====&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut 3.0 tells us where the interactions are cut off, as seen in the integral above, &amp;lt;math&amp;gt;3.0 \sigma&amp;lt;/math&amp;gt; is a very good cut-off, since there is no significant perturbation.&lt;br /&gt;
&lt;br /&gt;
=== Simulations ===&lt;br /&gt;
&lt;br /&gt;
In the gallery below graphs are shown. It can be seen that as timesteps are increasing, the quality of results is decreasing. Timpestep of 0.015 s is wholy inappropriate, but I have chosen to run the experiments at the timestep of 0.0025 s. Results would probably also be almost as good using 0.01 s.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=200 px&amp;gt;&lt;br /&gt;
Image:GE715L1.PNG|Figure 1: Energy at timestep 0.001 s&lt;br /&gt;
Image:GE715L2.PNG|Figure 2: Temperature at timestep 0.001 s&lt;br /&gt;
Image:GE715L3.PNG|Figure 3: Pressure at timestep 0.001 s&lt;br /&gt;
Image:GE715L4.PNG|Figure 4: Energy at timestep 0.0025 s&lt;br /&gt;
Image:GE715L5.PNG|Figure 5: Energy at timestep 0.0075 s&lt;br /&gt;
Image:GE715L6.PNG|Figure 6: Energy at timestep 0.01 s&lt;br /&gt;
Image:GE715L7.PNG|Figure 7: Energy at timestep 0.015 s&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Specific conditions ==&lt;br /&gt;
&lt;br /&gt;
If we run simulations under different conditions, we get the results shown in the gallery below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=800 px&amp;gt;&lt;br /&gt;
Image:GE715L8.PNG|Figure 8: Density vs temperature at p=2&lt;br /&gt;
Image:GE715L9.PNG|Figure 9: Density vs temperature at p=3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=656891</id>
		<title>Rep:Liquids GE715</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=656891"/>
		<updated>2018-01-26T16:43:52Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Lennard Jones potential equals &amp;lt;math&amp;gt;\phi\left(r\right) = 4\epsilon \left( \frac{\sigma^{12}}{r^{12}} - \frac{\sigma^6}{r^6} \right)&amp;lt;/math&amp;gt;. Potential energy is zero at the point when &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt;, thus &amp;lt;math&amp;gt;r_0=\sigma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Force is simply the derivative of the potential, thus &amp;lt;math&amp;gt;F = 4\epsilon \left( -12 \frac{\sigma^{12}}{r^{13}} + 6 \frac{\sigma^6}{r^7} \right)&amp;lt;/math&amp;gt;. At &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt; this equals &amp;lt;math&amp;gt;F = - \frac{24\epsilon}{\sigma}&amp;lt;/math&amp;gt;. Well depth is &amp;lt;math&amp;gt;\phi\left(r_{eq}\right) = 1 \frac{kJ}{mol}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The following integrals are equal to: &amp;lt;math&amp;gt;\int_{2\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.0248&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\int_{2.5\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00818&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\int_{3\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00329&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Water ===&lt;br /&gt;
&lt;br /&gt;
There are roughly &amp;lt;math&amp;gt;3.3*10^{22}&amp;lt;/math&amp;gt; molecules in 1 mL of water. However, 10000 atoms of water take up about &amp;lt;math&amp;gt;3*10^{-19} mL&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;300 nm^{3}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Atoms ===&lt;br /&gt;
&lt;br /&gt;
Atom at position &amp;lt;math&amp;gt;(0.5,0.5,0.5)&amp;lt;/math&amp;gt; moved for &amp;lt;math&amp;gt;(0.7,0.6,0.2)&amp;lt;/math&amp;gt; would be found at &amp;lt;math&amp;gt;(0.2,0.1,0.7)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Reduced units ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;LJ cut-off=1.088 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;T=180 K&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;r=0.382 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;E=1 \frac{kJ}{mol}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Equilibration ==&lt;br /&gt;
&lt;br /&gt;
If two atoms were generated very close together that would mean the force between them would be huge, which would have a potential to heavily disturb the simulation.&lt;br /&gt;
&lt;br /&gt;
=== Commands ====&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut 3.0 tells us where the interactions are cut off, as seen in the integral above, &amp;lt;math&amp;gt;3.0 \sigma&amp;lt;/math&amp;gt; is a very good cut-off, since there is no significant perturbation.&lt;br /&gt;
&lt;br /&gt;
=== Simulations ===&lt;br /&gt;
&lt;br /&gt;
In the gallery below graphs are shown. It can be seen that as timesteps are increasing, the quality of results is decreasing. Timpestep of 0.015 s is wholy inappropriate, but I have chosen to run the experiments at the timestep of 0.0025 s. Results would probably also be almost as good using 0.01 s.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=200 px&amp;gt;&lt;br /&gt;
Image:GE715L1.PNG|Figure 1: Energy at timestep 0.001 s&lt;br /&gt;
Image:GE715L2.PNG|Figure 2: Temperature at timestep 0.001 s&lt;br /&gt;
Image:GE715L3.PNG|Figure 3: Pressure at timestep 0.001 s&lt;br /&gt;
Image:GE715L4.PNG|Figure 4: Energy at timestep 0.0025 s&lt;br /&gt;
Image:GE715L5.PNG|Figure 5: Energy at timestep 0.0075 s&lt;br /&gt;
Image:GE715L6.PNG|Figure 6: Energy at timestep 0.01 s&lt;br /&gt;
Image:GE715L7.PNG|Figure 7: Energy at timestep 0.015 s&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Specific conditions ==&lt;br /&gt;
&lt;br /&gt;
If we run simulations under different conditions, we get the results shown in the gallery below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=200 px&amp;gt;&lt;br /&gt;
Image:GE715L8.PNG|Figure 8: Density vs temperature at p=2&lt;br /&gt;
Image:GE715L9.PNG|Figure 9: Density vs temperature at p=3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L8.PNG&amp;diff=656881</id>
		<title>File:GE715L8.PNG</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L8.PNG&amp;diff=656881"/>
		<updated>2018-01-26T16:41:54Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L7.PNG&amp;diff=656836</id>
		<title>File:GE715L7.PNG</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L7.PNG&amp;diff=656836"/>
		<updated>2018-01-26T16:27:01Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L6.PNG&amp;diff=656835</id>
		<title>File:GE715L6.PNG</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L6.PNG&amp;diff=656835"/>
		<updated>2018-01-26T16:26:46Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L5.PNG&amp;diff=656833</id>
		<title>File:GE715L5.PNG</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L5.PNG&amp;diff=656833"/>
		<updated>2018-01-26T16:26:32Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L4.PNG&amp;diff=656831</id>
		<title>File:GE715L4.PNG</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L4.PNG&amp;diff=656831"/>
		<updated>2018-01-26T16:26:19Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L3.PNG&amp;diff=656829</id>
		<title>File:GE715L3.PNG</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L3.PNG&amp;diff=656829"/>
		<updated>2018-01-26T16:25:59Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L2.PNG&amp;diff=656828</id>
		<title>File:GE715L2.PNG</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L2.PNG&amp;diff=656828"/>
		<updated>2018-01-26T16:25:45Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L1.PNG&amp;diff=656827</id>
		<title>File:GE715L1.PNG</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715L1.PNG&amp;diff=656827"/>
		<updated>2018-01-26T16:25:29Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=656826</id>
		<title>Rep:Liquids GE715</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:Liquids_GE715&amp;diff=656826"/>
		<updated>2018-01-26T16:24:56Z</updated>

		<summary type="html">&lt;p&gt;Ge715: Created page with &amp;quot;== Introduction ==  Lennard Jones potential equals &amp;lt;math&amp;gt;\phi\left(r\right) = 4\epsilon \left( \frac{\sigma^{12}}{r^{12}} - \frac{\sigma^6}{r^6} \right)&amp;lt;/math&amp;gt;. Potential ener...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Lennard Jones potential equals &amp;lt;math&amp;gt;\phi\left(r\right) = 4\epsilon \left( \frac{\sigma^{12}}{r^{12}} - \frac{\sigma^6}{r^6} \right)&amp;lt;/math&amp;gt;. Potential energy is zero at the point when &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt;, thus &amp;lt;math&amp;gt;r_0=\sigma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Force is simply the derivative of the potential, thus &amp;lt;math&amp;gt;F = 4\epsilon \left( -12 \frac{\sigma^{12}}{r^{13}} + 6 \frac{\sigma^6}{r^7} \right)&amp;lt;/math&amp;gt;. At &amp;lt;math&amp;gt;r=\sigma&amp;lt;/math&amp;gt; this equals &amp;lt;math&amp;gt;F = - \frac{24\epsilon}{\sigma}&amp;lt;/math&amp;gt;. Well depth is &amp;lt;math&amp;gt;\phi\left(r_{eq}\right) = 1 \frac{kJ}{mol}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The following integrals are equal to: &amp;lt;math&amp;gt;\int_{2\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.0248&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\int_{2.5\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00818&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\int_{3\sigma}^\infty \phi\left(r\right)\mathrm{d}r=-0.00329&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Water ===&lt;br /&gt;
&lt;br /&gt;
There are roughly &amp;lt;math&amp;gt;3.3*10^{22}&amp;lt;/math&amp;gt; molecules in 1 mL of water. However, 10000 atoms of water take up about &amp;lt;math&amp;gt;3*10^{-19} mL&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;300 nm^{3}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Atoms ===&lt;br /&gt;
&lt;br /&gt;
Atom at position &amp;lt;math&amp;gt;(0.5,0.5,0.5)&amp;lt;/math&amp;gt; moved for &amp;lt;math&amp;gt;(0.7,0.6,0.2)&amp;lt;/math&amp;gt; would be found at &amp;lt;math&amp;gt;(0.2,0.1,0.7)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Reduced units ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;LJ cut-off=1.088 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;T=180 K&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;r=0.382 nm&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;E=1 \frac{kJ}{mol}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Equilibration ==&lt;br /&gt;
&lt;br /&gt;
If two atoms were generated very close together that would mean the force between them would be huge, which would have a potential to heavily disturb the simulation.&lt;br /&gt;
&lt;br /&gt;
=== Commands ====&lt;br /&gt;
&lt;br /&gt;
pair_style lj/cut 3.0 tells us where the interactions are cut off, as seen in the integral above, &amp;lt;math&amp;gt;3.0 \sigma&amp;lt;/math&amp;gt; is a very good cut-off, since there is no significant perturbation.&lt;br /&gt;
&lt;br /&gt;
=== Simulations ===&lt;br /&gt;
&lt;br /&gt;
In the gallery below graphs are shown. It can be seen that as timesteps are increasing, the quality of results is decreasing. Timpestep of 0.015 s is wholy inappropriate, but I have chosen to run the experiments at the timestep of 0.0025 s.&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:CMPY3_GE715&amp;diff=645977</id>
		<title>Rep:CMPY3 GE715</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:CMPY3_GE715&amp;diff=645977"/>
		<updated>2017-11-22T11:57:41Z</updated>

		<summary type="html">&lt;p&gt;Ge715: /* Monte Carlo simulation */  Note&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Ising Model ==&lt;br /&gt;
&lt;br /&gt;
Ising model is built on the assumption that a lattice that can be of any dimensionality contains spins which can either be up (+1 or down (-1) and interactions can be studied using this model. The model is extremely simplified, since in real systems the spins can point in any direction, but the basic properties of magnetic systems, such as magnetisation, energy levels and Curie temperature, may be studied using this simplification. &lt;br /&gt;
&lt;br /&gt;
The interaction energy in Ising model is defined as &amp;lt;math&amp;gt;E=- \frac{1}{2} J \sum_i^N \sum_{j\  \in\  \mathrm{neighbours}\left(i\right)} s_i s_j&amp;lt;/math&amp;gt;. The energy will be the lowest possible when all the spins point in the same direction. In that case &amp;lt;math&amp;gt;s_i s_j=1&amp;lt;/math&amp;gt; for all possible &amp;lt;math&amp;gt;i,j&amp;lt;/math&amp;gt; pairs. The number of pairs for each &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; depends on the number of dimensions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;P=2D&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;P&amp;lt;/math&amp;gt; represents the number of pairs and &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; the number of dimensions. The lowest possible energy will thus be &amp;lt;math&amp;gt;E=- \frac{1}{2} JNP&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; represents the total number of spins. Thus the lowest possible energy may also be simplified as &amp;lt;math&amp;gt;E=-DNJ&amp;lt;/math&amp;gt;, as requested.&lt;br /&gt;
&lt;br /&gt;
The multiplicity of this particular state is 2 (all spins up or all spins down), thus &amp;lt;math&amp;gt;\Omega=2&amp;lt;/math&amp;gt;, entropy of the system is &amp;lt;math&amp;gt;S=k_b ln \Omega=9.6*10^{-24} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Flip of a spin ===&lt;br /&gt;
&lt;br /&gt;
If one of the spins flips, the energy increases. In the given case (&amp;lt;math&amp;gt;D=3, N=1000&amp;lt;/math&amp;gt;), the &amp;lt;math&amp;gt;E_i=-3000 J&amp;lt;/math&amp;gt;, while the flip of one spin increases the energy by &amp;lt;math&amp;gt;12 J&amp;lt;/math&amp;gt; (6 pairs, &amp;lt;math&amp;gt;2 J&amp;lt;/math&amp;gt; per pair), so that &amp;lt;math&amp;gt;E_f=-2988 J&amp;lt;/math&amp;gt;. Note that &amp;lt;math&amp;gt;J&amp;lt;/math&amp;gt; does not represent joules in this case.&lt;br /&gt;
&lt;br /&gt;
Multiplicity has increased to &amp;lt;math&amp;gt;\Omega=2000&amp;lt;/math&amp;gt;, thus &amp;lt;math&amp;gt;S=1.05*10^{-22} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\Delta S=1.04*10^{-22} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This means that entropy has increased by more than 100 times.&lt;br /&gt;
&lt;br /&gt;
=== Magnetisation in the sketch ===&lt;br /&gt;
&lt;br /&gt;
The 1D system shown has the magnetisation of &amp;lt;math&amp;gt;M=1&amp;lt;/math&amp;gt;. This is also true for the 2D system shown. For the model system with &amp;lt;math&amp;gt;N=1000, D=3&amp;lt;/math&amp;gt; the expected magnetisation at absolute zero would be &amp;lt;math&amp;gt;M=\pm 1000&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Code for magnetisation and energy ==&lt;br /&gt;
&lt;br /&gt;
Python code was written to calculate the energy and magnetisation of a configuration and tested a few times. The test results are shown in figure 1 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=800 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_0.png|Figure 1: Test results&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Monte Carlo simulation ==&lt;br /&gt;
&lt;br /&gt;
If no weighing is used, the calculation would be far too demanding even for current supercomputers, because 100 spins can take about &amp;lt;math&amp;gt;1.27*10^{30}&amp;lt;/math&amp;gt; arrangements, which means calculating the average for such system would take more than &amp;lt;math&amp;gt;1.3*10^{21} s&amp;lt;/math&amp;gt;, which is 40 trillion years, or about 3 times the age of the Universe, thus a better system must be used to do this quicker. One option is using Monte Carlo simulation, which mimics real transitions. It is essentially optimisation algorithm that is looking for stable state, but with a possibility of going into higher energy state should it have enough energy.&lt;br /&gt;
&lt;br /&gt;
Below Curie temperature it is to be expected, that absolute value of magnetisation will be close to LxL, where L is the size of the lattice (works also in more than 2 dimensions).&lt;br /&gt;
&lt;br /&gt;
The old code was accidentally deleted before it could be added to the report.&lt;br /&gt;
&lt;br /&gt;
== Accelerating the code ==&lt;br /&gt;
&lt;br /&gt;
The code at the beginning was written using a loop for magnetisation and a double loop for energy. 2000 Monte Carlo steps needed was &amp;lt;math&amp;gt;M=9.32 s \pm 0.10 s&amp;lt;/math&amp;gt;. After optimizing magnetisation only this has dropped to &amp;lt;math&amp;gt;M=8.88 s \pm 0.04 s&amp;lt;/math&amp;gt;, while after optimizing both magnetisation and energy with using Numpy&#039;s sum, roll and multiply functions, the time was further reduced to &amp;lt;math&amp;gt;M=0.0796 s \pm 0.018 s&amp;lt;/math&amp;gt;. It was later realised that only one roll in each direction is needed to produce the correct energy, so the final time for 2000 steps was successfully reduced to &amp;lt;math&amp;gt;M=0.418 s \pm 0.005 s&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The whole of the code used is given below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
&lt;br /&gt;
class IsingLattice:&lt;br /&gt;
&lt;br /&gt;
    E = 0.0&lt;br /&gt;
    E2 = 0.0&lt;br /&gt;
    M = 0.0&lt;br /&gt;
    M2 = 0.0&lt;br /&gt;
    energy_x=0&lt;br /&gt;
    energy2_x=0&lt;br /&gt;
    magnetisation_x=0&lt;br /&gt;
    magnetisation2_x=0&lt;br /&gt;
&lt;br /&gt;
    n_cycles = 0&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, n_rows, n_cols):&lt;br /&gt;
        self.n_rows = n_rows&lt;br /&gt;
        self.n_cols = n_cols&lt;br /&gt;
        self.lattice = np.random.choice([-1,1], size=(n_rows, n_cols))&lt;br /&gt;
&lt;br /&gt;
    def energy(self):&lt;br /&gt;
        a=np.roll(self.lattice,1,axis=0)&lt;br /&gt;
        a1=np.multiply(a,self.lattice)&lt;br /&gt;
        x1=np.sum(a1)&lt;br /&gt;
        c=np.roll(self.lattice,1,axis=1)&lt;br /&gt;
        c1=np.multiply(c,self.lattice)&lt;br /&gt;
        x2=np.sum(c1)&lt;br /&gt;
        x=x1+x2&lt;br /&gt;
        energy = -x&lt;br /&gt;
        return 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;
        return np.sum(self.lattice)&lt;br /&gt;
&lt;br /&gt;
    def energy_flip(self,random_i,random_j):&lt;br /&gt;
        &amp;quot;Return the total energy of the current lattice after flip configuration.&amp;quot;&lt;br /&gt;
        self.lattice[random_i][random_j]=-self.lattice[random_i][random_j]&lt;br /&gt;
        a=np.roll(self.lattice,1,axis=0)&lt;br /&gt;
        a1=np.multiply(a,self.lattice)&lt;br /&gt;
        x1=np.sum(a1)&lt;br /&gt;
        c=np.roll(self.lattice,1,axis=1)&lt;br /&gt;
        c1=np.multiply(c,self.lattice)&lt;br /&gt;
        x2=np.sum(c1)&lt;br /&gt;
        x=x1+x2&lt;br /&gt;
        energy = -x&lt;br /&gt;
        return energy&lt;br /&gt;
&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        # complete this function so that it performs a single Monte Carlo step&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        #the following two lines will select the coordinates of the random spin for you&lt;br /&gt;
        random_i = np.random.choice(range(0, self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(0, self.n_cols))&lt;br /&gt;
        #the following line will choose a random number in the range [0,1) for you&lt;br /&gt;
        random_number = np.random.random()&lt;br /&gt;
        self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
        energy2 = self.energy()&lt;br /&gt;
        dE = energy2 - energy&lt;br /&gt;
&lt;br /&gt;
        if energy2&amp;lt;energy or random_number&amp;lt;=np.e**(-(energy2-energy)/T):&lt;br /&gt;
            yyy=True&lt;br /&gt;
        else:&lt;br /&gt;
            self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
			&lt;br /&gt;
        self.n_cycles+=1&lt;br /&gt;
&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;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        # complete this function so that it calculates the correct values for the averages of E, E*E (E2), M, M*M (M2), and returns them&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.M / self.n_cycles&lt;br /&gt;
        return avE, avE2, avM, avM2, self.n_cycles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Temperature effects ==&lt;br /&gt;
&lt;br /&gt;
=== Correction of averaging code ===&lt;br /&gt;
&lt;br /&gt;
A few experiments were performed at different temperatures using ILfinalframe.py, to see how long it usually takes for the system to equilibrate. At low temperatures it usually happened before 1000 steps were performed, thus 1000 Monte Carlo steps was decided to be appropriate cut-off period for calculation of average values of magnetisation and energy. The figures 2-4, showing the experiments performed are shown in the gallery below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_1.png|Figure 2: Test result @ 0.5 K&lt;br /&gt;
Image:GE715_CMP_2.png|Figure 3: Test result @ 1 K&lt;br /&gt;
Image:GE715_CMP_3.png|Figure 4: Test result @ 1.5 K&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The definitions of two class functions were changed as shown below to accommodate this change.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        # complete this function so that it performs a single Monte Carlo step&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        #the following two lines will select the coordinates of the random spin for you&lt;br /&gt;
        random_i = np.random.choice(range(0, self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(0, self.n_cols))&lt;br /&gt;
        #the following line will choose a random number in the range [0,1) for you&lt;br /&gt;
        random_number = np.random.random()&lt;br /&gt;
        self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
        energy2 = self.energy()&lt;br /&gt;
        dE = energy2 - energy&lt;br /&gt;
&lt;br /&gt;
        if energy2&amp;lt;energy or random_number&amp;lt;=np.e**(-(energy2-energy)/T):&lt;br /&gt;
            yyy=True&lt;br /&gt;
        else:&lt;br /&gt;
            self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
			&lt;br /&gt;
        self.n_cycles+=1&lt;br /&gt;
        if self.n_cycles==1000:&lt;br /&gt;
            self.E=0&lt;br /&gt;
            self.E2=0&lt;br /&gt;
            self.M=0&lt;br /&gt;
            self.M2=0&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;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        # complete this function so that it calculates the correct values for the averages of E, E*E (E2), M, M*M (M2), and returns them&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.M / self.n_cycles&lt;br /&gt;
        if self.n_cycles&amp;gt;1000:&lt;br /&gt;
            avE = self.E / (self.n_cycles-1000)&lt;br /&gt;
            avE2 = self.E2 / (self.n_cycles-1000)&lt;br /&gt;
            avM = self.M / (self.n_cycles-1000)&lt;br /&gt;
            avM2 = self.M / (self.n_cycles-1000)&lt;br /&gt;
        return avE, avE2, avM, avM2, self.n_cycles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Range of temperatures ===&lt;br /&gt;
&lt;br /&gt;
The experiment was run for 8x8 lattice at a temperature range of 0.25 K-5.00 K, with a point every 0.05 K. The experiments using a different number of total steps were performed and the comparison is shown below in figures 5-7.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_4.png|Figure 5: Test result for 8x8 lattice with 11000 steps&lt;br /&gt;
Image:GE715_CMP_5.png|Figure 6: Test result for 8x8 lattice with 21000 steps&lt;br /&gt;
Image:GE715_CMP_6.png|Figure 7: Test result for 8x8 lattice with 101000 steps&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is a small, but noticeable improvement in the smoothness of the curves obtained for energy with using more steps, thus the highest number of steps (101000 steps) was used in the further experiments regardless of the higher need for computational power.&lt;br /&gt;
&lt;br /&gt;
== Lattice size effects ==&lt;br /&gt;
&lt;br /&gt;
With increasing lattice size the energy and magnetisation curves become more realistic, since the long range effects are better accounted for. 7 different lattice sizes were tested and energy and magnetisation for each are shown below in figure 8-14 and 15-21 respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_7.png|Figure 8: Energy result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_8.png|Figure 9: Energy result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_9.png|Figure 10: Energy result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_10.png|Figure 11: Energy result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_11.png|Figure 12: Energy result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_12.png|Figure 13: Energy result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_13.png|Figure 14: Energy result for 128x128 lattice&lt;br /&gt;
Image:GE715_CMP_14.png|Figure 15: Magnetisation result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_15.png|Figure 16: Magnetisation result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_16.png|Figure 17: Magnetisation result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_17.png|Figure 18: Magnetisation result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_18.png|Figure 19: Magnetisation result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_19.png|Figure 20: Magnetisation result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_20.png|Figure 21: Magnetisation result for 128x128 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Overall comparison of energy and magnetisation per spin in each lattice was made and can be seen in figures 22 and 23 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_21.png|Figure 22: Energy comparison&lt;br /&gt;
Image:GE715_CMP_22.png|Figure 23: Magnetisation comparison&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code used for producing figure 23 above is shown below. Other codes are analagous. Example for defining ls2 is also shown Others are similar..&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ls2=loadtxt(&amp;quot;2x2(100).dat&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
figsize(12,8)&lt;br /&gt;
plot(ls2[:,0],ls2[:,3]/4,color=&amp;quot;red&amp;quot;,label=&amp;quot;2x2&amp;quot;)&lt;br /&gt;
plot(ls4[:,0],ls4[:,3]/16,color=&amp;quot;orange&amp;quot;,label=&amp;quot;4x4&amp;quot;)&lt;br /&gt;
plot(ls8[:,0],ls8[:,3]/64,color=&amp;quot;yellow&amp;quot;,label=&amp;quot;8x8&amp;quot;)&lt;br /&gt;
plot(ls16[:,0],ls16[:,3]/256,color=&amp;quot;lime&amp;quot;,label=&amp;quot;16x16&amp;quot;)&lt;br /&gt;
plot(ls32[:,0],ls32[:,3]/1024,color=&amp;quot;blue&amp;quot;,label=&amp;quot;32x32&amp;quot;)&lt;br /&gt;
plot(ls64[:,0],ls64[:,3]/4096,color=&amp;quot;indigo&amp;quot;,label=&amp;quot;64x64&amp;quot;)&lt;br /&gt;
plot(ls128[:,0],ls128[:,3]/16384,color=&amp;quot;violet&amp;quot;,label=&amp;quot;128x128&amp;quot;)&lt;br /&gt;
title(&amp;quot;Magnetisation per spin&amp;quot;)&lt;br /&gt;
xlabel(&amp;quot;Temperature (K)&amp;quot;)&lt;br /&gt;
ylabel(&amp;quot;Magnetisation per spin&amp;quot;)&lt;br /&gt;
legend()&lt;br /&gt;
savefig(&amp;quot;Magnetisation.png&amp;quot;)&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Significant changes may be observed from 2x2 lattice up to 16x16 lattice, later the additional long range effects become less noticeable, but new effects are still present. It seems that most of the long range effects are captured by 16x16 lattice, but higher dimensions bring additional improvement.&lt;br /&gt;
&lt;br /&gt;
== Heat Capacity ==&lt;br /&gt;
&lt;br /&gt;
This formula holds true by definition: &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;
Variance of energy can be calculated  in the following way: &amp;lt;math&amp;gt;\mathrm{Var}[X] = \left\langle E^2\right\rangle - \left\langle E\right\rangle^2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Since expected energy can also be expressed as partition function: &amp;lt;math&amp;gt;\left\langle E\right\rangle = \frac{\partial}{\partial \beta}lnZ&amp;lt;/math&amp;gt;, variance may be expressed as &amp;lt;math&amp;gt;\mathrm{Var}[X] = \frac{\partial ^2}{\partial \beta ^2}lnZ = - \frac{\partial \left\langle E\right\rangle}{\partial \beta}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We can rearrange the equations given, because &amp;lt;math&amp;gt;T = \frac{1}{k_BT}&amp;lt;/math&amp;gt;, so that we obtain &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;
=== Heat capacity of the model ===&lt;br /&gt;
&lt;br /&gt;
Heat capacities of the models were calculated using the script given below (example for 2x2 lattice).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
figsize(6,4)&lt;br /&gt;
plot(ls2[:,0],(ls2[:,2]-ls2[:,1]**2)/ls2[:,0],color=&amp;quot;red&amp;quot;,label=&amp;quot;2x2&amp;quot;)&lt;br /&gt;
xlabel(&amp;quot;Temperature (K)&amp;quot;)&lt;br /&gt;
ylabel(&amp;quot;C&amp;quot;)&lt;br /&gt;
savefig(&amp;quot;C2.png&amp;quot;)&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphs of heat capacities are shown in the gallery below (figures 24-30). It can be seen that the model breaks down at low temperatures for bigger lattices, but it still gives a peak heat capacity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_23.png|Figure 24: C result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_24.png|Figure 25: C result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_25.png|Figure 26: C result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_26.png|Figure 27: C result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_27.png|Figure 28: C result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_28.png|Figure 29: C result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_29.png|Figure 30: C result for 128x128 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Comparison of heat capacity per spin is given in the figure 31 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_30.png|Figure 31: Heat capacity comparison&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Curie temperature ==&lt;br /&gt;
&lt;br /&gt;
Curie temperature can be deduced from where there is a peak in heat capacity per spin. The graphs of heat capacity vs temperature is shown below (figures 32 and 33) for two different lattice sizes, once using Python script and once using C++ data provided.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_31.png|Figure 32: 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_32.png|Figure 33: 64x64 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Polynomial fit ===&lt;br /&gt;
&lt;br /&gt;
The C++ data was also fitted with a polynomial, firstly over the whole range and afterwards just in the peak range. Fitting a polynomial proved to be hard as expected (since data is close to delta-like function), but it became more feasible when smaller range was used. Examples of both fits are shown in figures 34 and 35 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_33.png|Figure 34: Whole region fit&lt;br /&gt;
Image:GE715_CMP_34.png|Figure 35: Peak region fit&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Finding Curie temperature ===&lt;br /&gt;
&lt;br /&gt;
The last step was to find peak heat capacity for different lattice sizes in C++ data. The results are shown in the table below.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Lattice size&lt;br /&gt;
! Curie temperature&lt;br /&gt;
|-&lt;br /&gt;
|2x2&lt;br /&gt;
|2.48 K&lt;br /&gt;
|-&lt;br /&gt;
|4x4&lt;br /&gt;
|2.40 K&lt;br /&gt;
|-&lt;br /&gt;
|8x8&lt;br /&gt;
|2.32 K&lt;br /&gt;
|-&lt;br /&gt;
|16x16&lt;br /&gt;
|2.25 K&lt;br /&gt;
|-&lt;br /&gt;
|32x32&lt;br /&gt;
|2.30 K&lt;br /&gt;
|-&lt;br /&gt;
|64x64&lt;br /&gt;
|2.25 K&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The curie temperature for infinite lattice is known to be calculated from that of a finite lattice using equation &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 a constant. This was used to draw a graph shown in figure 36 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_35.png|Figure 36: Curie temperature for infinite lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Curie temperature for infinite lattice was found to be &amp;lt;math&amp;gt;T=2.26 K&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The code used for drawing the graph in figure 36 is shown below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
L=array([1/2,1/4,1/8,1/16,1/32,1/64])&lt;br /&gt;
T=array([2.48,2.4,2.32,2.25,2.3,2.25])&lt;br /&gt;
X=array([1/2,0])&lt;br /&gt;
figsize(9,6)&lt;br /&gt;
plot(L,T,marker=&amp;quot;D&amp;quot;,linestyle=&amp;quot; &amp;quot;)&lt;br /&gt;
xlabel(&amp;quot;1/L&amp;quot;)&lt;br /&gt;
ylabel(&amp;quot;T&amp;quot;)&lt;br /&gt;
a=polyfit(L,T,1)&lt;br /&gt;
ylim(2.23,2.5)&lt;br /&gt;
plot(X,a[0]*X+a[1],color=&amp;quot;lime&amp;quot;)&lt;br /&gt;
title(&amp;quot;Curie temperature&amp;quot;)&lt;br /&gt;
savefig(&amp;quot;Curie.png&amp;quot;)&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:CMPY3_GE715&amp;diff=645970</id>
		<title>Rep:CMPY3 GE715</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:CMPY3_GE715&amp;diff=645970"/>
		<updated>2017-11-22T11:54:20Z</updated>

		<summary type="html">&lt;p&gt;Ge715: Monte Carlo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Ising Model ==&lt;br /&gt;
&lt;br /&gt;
Ising model is built on the assumption that a lattice that can be of any dimensionality contains spins which can either be up (+1 or down (-1) and interactions can be studied using this model. The model is extremely simplified, since in real systems the spins can point in any direction, but the basic properties of magnetic systems, such as magnetisation, energy levels and Curie temperature, may be studied using this simplification. &lt;br /&gt;
&lt;br /&gt;
The interaction energy in Ising model is defined as &amp;lt;math&amp;gt;E=- \frac{1}{2} J \sum_i^N \sum_{j\  \in\  \mathrm{neighbours}\left(i\right)} s_i s_j&amp;lt;/math&amp;gt;. The energy will be the lowest possible when all the spins point in the same direction. In that case &amp;lt;math&amp;gt;s_i s_j=1&amp;lt;/math&amp;gt; for all possible &amp;lt;math&amp;gt;i,j&amp;lt;/math&amp;gt; pairs. The number of pairs for each &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; depends on the number of dimensions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;P=2D&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;P&amp;lt;/math&amp;gt; represents the number of pairs and &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; the number of dimensions. The lowest possible energy will thus be &amp;lt;math&amp;gt;E=- \frac{1}{2} JNP&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; represents the total number of spins. Thus the lowest possible energy may also be simplified as &amp;lt;math&amp;gt;E=-DNJ&amp;lt;/math&amp;gt;, as requested.&lt;br /&gt;
&lt;br /&gt;
The multiplicity of this particular state is 2 (all spins up or all spins down), thus &amp;lt;math&amp;gt;\Omega=2&amp;lt;/math&amp;gt;, entropy of the system is &amp;lt;math&amp;gt;S=k_b ln \Omega=9.6*10^{-24} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Flip of a spin ===&lt;br /&gt;
&lt;br /&gt;
If one of the spins flips, the energy increases. In the given case (&amp;lt;math&amp;gt;D=3, N=1000&amp;lt;/math&amp;gt;), the &amp;lt;math&amp;gt;E_i=-3000 J&amp;lt;/math&amp;gt;, while the flip of one spin increases the energy by &amp;lt;math&amp;gt;12 J&amp;lt;/math&amp;gt; (6 pairs, &amp;lt;math&amp;gt;2 J&amp;lt;/math&amp;gt; per pair), so that &amp;lt;math&amp;gt;E_f=-2988 J&amp;lt;/math&amp;gt;. Note that &amp;lt;math&amp;gt;J&amp;lt;/math&amp;gt; does not represent joules in this case.&lt;br /&gt;
&lt;br /&gt;
Multiplicity has increased to &amp;lt;math&amp;gt;\Omega=2000&amp;lt;/math&amp;gt;, thus &amp;lt;math&amp;gt;S=1.05*10^{-22} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\Delta S=1.04*10^{-22} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This means that entropy has increased by more than 100 times.&lt;br /&gt;
&lt;br /&gt;
=== Magnetisation in the sketch ===&lt;br /&gt;
&lt;br /&gt;
The 1D system shown has the magnetisation of &amp;lt;math&amp;gt;M=1&amp;lt;/math&amp;gt;. This is also true for the 2D system shown. For the model system with &amp;lt;math&amp;gt;N=1000, D=3&amp;lt;/math&amp;gt; the expected magnetisation at absolute zero would be &amp;lt;math&amp;gt;M=\pm 1000&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Code for magnetisation and energy ==&lt;br /&gt;
&lt;br /&gt;
Python code was written to calculate the energy and magnetisation of a configuration and tested a few times. The test results are shown in figure 1 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=800 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_0.png|Figure 1: Test results&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Monte Carlo simulation ==&lt;br /&gt;
&lt;br /&gt;
If no weighing is used, the calculation would be far too demanding even for current supercomputers, because 100 spins can take about &amp;lt;math&amp;gt;1.27*10^{30}&amp;lt;/math&amp;gt; arrangements, which means calculating the average for such system would take more than &amp;lt;math&amp;gt;1.3*10^{21} s&amp;lt;/math&amp;gt;, which is 40 trillion years, or about 3 times the age of the Universe, thus a better system must be used to do this quicker. One option is using Monte Carlo simulation, which mimics real transitions. It is essentially optimisation algorithm that is looking for stable state, but with a possibility of going into higher energy state should it have enough energy.&lt;br /&gt;
&lt;br /&gt;
Below Curie temperature it is to be expected, that absolute value of magnetisation will be close to LxL, where L is the size of the lattice (works also in more than 2 dimensions).&lt;br /&gt;
&lt;br /&gt;
== Accelerating the code ==&lt;br /&gt;
&lt;br /&gt;
The code at the beginning was written using a loop for magnetisation and a double loop for energy. 2000 Monte Carlo steps needed was &amp;lt;math&amp;gt;M=9.32 s \pm 0.10 s&amp;lt;/math&amp;gt;. After optimizing magnetisation only this has dropped to &amp;lt;math&amp;gt;M=8.88 s \pm 0.04 s&amp;lt;/math&amp;gt;, while after optimizing both magnetisation and energy with using Numpy&#039;s sum, roll and multiply functions, the time was further reduced to &amp;lt;math&amp;gt;M=0.0796 s \pm 0.018 s&amp;lt;/math&amp;gt;. It was later realised that only one roll in each direction is needed to produce the correct energy, so the final time for 2000 steps was successfully reduced to &amp;lt;math&amp;gt;M=0.418 s \pm 0.005 s&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The whole of the code used is given below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
&lt;br /&gt;
class IsingLattice:&lt;br /&gt;
&lt;br /&gt;
    E = 0.0&lt;br /&gt;
    E2 = 0.0&lt;br /&gt;
    M = 0.0&lt;br /&gt;
    M2 = 0.0&lt;br /&gt;
    energy_x=0&lt;br /&gt;
    energy2_x=0&lt;br /&gt;
    magnetisation_x=0&lt;br /&gt;
    magnetisation2_x=0&lt;br /&gt;
&lt;br /&gt;
    n_cycles = 0&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, n_rows, n_cols):&lt;br /&gt;
        self.n_rows = n_rows&lt;br /&gt;
        self.n_cols = n_cols&lt;br /&gt;
        self.lattice = np.random.choice([-1,1], size=(n_rows, n_cols))&lt;br /&gt;
&lt;br /&gt;
    def energy(self):&lt;br /&gt;
        a=np.roll(self.lattice,1,axis=0)&lt;br /&gt;
        a1=np.multiply(a,self.lattice)&lt;br /&gt;
        x1=np.sum(a1)&lt;br /&gt;
        c=np.roll(self.lattice,1,axis=1)&lt;br /&gt;
        c1=np.multiply(c,self.lattice)&lt;br /&gt;
        x2=np.sum(c1)&lt;br /&gt;
        x=x1+x2&lt;br /&gt;
        energy = -x&lt;br /&gt;
        return 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;
        return np.sum(self.lattice)&lt;br /&gt;
&lt;br /&gt;
    def energy_flip(self,random_i,random_j):&lt;br /&gt;
        &amp;quot;Return the total energy of the current lattice after flip configuration.&amp;quot;&lt;br /&gt;
        self.lattice[random_i][random_j]=-self.lattice[random_i][random_j]&lt;br /&gt;
        a=np.roll(self.lattice,1,axis=0)&lt;br /&gt;
        a1=np.multiply(a,self.lattice)&lt;br /&gt;
        x1=np.sum(a1)&lt;br /&gt;
        c=np.roll(self.lattice,1,axis=1)&lt;br /&gt;
        c1=np.multiply(c,self.lattice)&lt;br /&gt;
        x2=np.sum(c1)&lt;br /&gt;
        x=x1+x2&lt;br /&gt;
        energy = -x&lt;br /&gt;
        return energy&lt;br /&gt;
&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        # complete this function so that it performs a single Monte Carlo step&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        #the following two lines will select the coordinates of the random spin for you&lt;br /&gt;
        random_i = np.random.choice(range(0, self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(0, self.n_cols))&lt;br /&gt;
        #the following line will choose a random number in the range [0,1) for you&lt;br /&gt;
        random_number = np.random.random()&lt;br /&gt;
        self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
        energy2 = self.energy()&lt;br /&gt;
        dE = energy2 - energy&lt;br /&gt;
&lt;br /&gt;
        if energy2&amp;lt;energy or random_number&amp;lt;=np.e**(-(energy2-energy)/T):&lt;br /&gt;
            yyy=True&lt;br /&gt;
        else:&lt;br /&gt;
            self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
			&lt;br /&gt;
        self.n_cycles+=1&lt;br /&gt;
&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;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        # complete this function so that it calculates the correct values for the averages of E, E*E (E2), M, M*M (M2), and returns them&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.M / self.n_cycles&lt;br /&gt;
        return avE, avE2, avM, avM2, self.n_cycles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Temperature effects ==&lt;br /&gt;
&lt;br /&gt;
=== Correction of averaging code ===&lt;br /&gt;
&lt;br /&gt;
A few experiments were performed at different temperatures using ILfinalframe.py, to see how long it usually takes for the system to equilibrate. At low temperatures it usually happened before 1000 steps were performed, thus 1000 Monte Carlo steps was decided to be appropriate cut-off period for calculation of average values of magnetisation and energy. The figures 2-4, showing the experiments performed are shown in the gallery below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_1.png|Figure 2: Test result @ 0.5 K&lt;br /&gt;
Image:GE715_CMP_2.png|Figure 3: Test result @ 1 K&lt;br /&gt;
Image:GE715_CMP_3.png|Figure 4: Test result @ 1.5 K&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The definitions of two class functions were changed as shown below to accommodate this change.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        # complete this function so that it performs a single Monte Carlo step&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        #the following two lines will select the coordinates of the random spin for you&lt;br /&gt;
        random_i = np.random.choice(range(0, self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(0, self.n_cols))&lt;br /&gt;
        #the following line will choose a random number in the range [0,1) for you&lt;br /&gt;
        random_number = np.random.random()&lt;br /&gt;
        self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
        energy2 = self.energy()&lt;br /&gt;
        dE = energy2 - energy&lt;br /&gt;
&lt;br /&gt;
        if energy2&amp;lt;energy or random_number&amp;lt;=np.e**(-(energy2-energy)/T):&lt;br /&gt;
            yyy=True&lt;br /&gt;
        else:&lt;br /&gt;
            self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
			&lt;br /&gt;
        self.n_cycles+=1&lt;br /&gt;
        if self.n_cycles==1000:&lt;br /&gt;
            self.E=0&lt;br /&gt;
            self.E2=0&lt;br /&gt;
            self.M=0&lt;br /&gt;
            self.M2=0&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;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        # complete this function so that it calculates the correct values for the averages of E, E*E (E2), M, M*M (M2), and returns them&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.M / self.n_cycles&lt;br /&gt;
        if self.n_cycles&amp;gt;1000:&lt;br /&gt;
            avE = self.E / (self.n_cycles-1000)&lt;br /&gt;
            avE2 = self.E2 / (self.n_cycles-1000)&lt;br /&gt;
            avM = self.M / (self.n_cycles-1000)&lt;br /&gt;
            avM2 = self.M / (self.n_cycles-1000)&lt;br /&gt;
        return avE, avE2, avM, avM2, self.n_cycles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Range of temperatures ===&lt;br /&gt;
&lt;br /&gt;
The experiment was run for 8x8 lattice at a temperature range of 0.25 K-5.00 K, with a point every 0.05 K. The experiments using a different number of total steps were performed and the comparison is shown below in figures 5-7.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_4.png|Figure 5: Test result for 8x8 lattice with 11000 steps&lt;br /&gt;
Image:GE715_CMP_5.png|Figure 6: Test result for 8x8 lattice with 21000 steps&lt;br /&gt;
Image:GE715_CMP_6.png|Figure 7: Test result for 8x8 lattice with 101000 steps&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is a small, but noticeable improvement in the smoothness of the curves obtained for energy with using more steps, thus the highest number of steps (101000 steps) was used in the further experiments regardless of the higher need for computational power.&lt;br /&gt;
&lt;br /&gt;
== Lattice size effects ==&lt;br /&gt;
&lt;br /&gt;
With increasing lattice size the energy and magnetisation curves become more realistic, since the long range effects are better accounted for. 7 different lattice sizes were tested and energy and magnetisation for each are shown below in figure 8-14 and 15-21 respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_7.png|Figure 8: Energy result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_8.png|Figure 9: Energy result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_9.png|Figure 10: Energy result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_10.png|Figure 11: Energy result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_11.png|Figure 12: Energy result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_12.png|Figure 13: Energy result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_13.png|Figure 14: Energy result for 128x128 lattice&lt;br /&gt;
Image:GE715_CMP_14.png|Figure 15: Magnetisation result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_15.png|Figure 16: Magnetisation result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_16.png|Figure 17: Magnetisation result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_17.png|Figure 18: Magnetisation result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_18.png|Figure 19: Magnetisation result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_19.png|Figure 20: Magnetisation result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_20.png|Figure 21: Magnetisation result for 128x128 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Overall comparison of energy and magnetisation per spin in each lattice was made and can be seen in figures 22 and 23 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_21.png|Figure 22: Energy comparison&lt;br /&gt;
Image:GE715_CMP_22.png|Figure 23: Magnetisation comparison&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code used for producing figure 23 above is shown below. Other codes are analagous. Example for defining ls2 is also shown Others are similar..&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ls2=loadtxt(&amp;quot;2x2(100).dat&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
figsize(12,8)&lt;br /&gt;
plot(ls2[:,0],ls2[:,3]/4,color=&amp;quot;red&amp;quot;,label=&amp;quot;2x2&amp;quot;)&lt;br /&gt;
plot(ls4[:,0],ls4[:,3]/16,color=&amp;quot;orange&amp;quot;,label=&amp;quot;4x4&amp;quot;)&lt;br /&gt;
plot(ls8[:,0],ls8[:,3]/64,color=&amp;quot;yellow&amp;quot;,label=&amp;quot;8x8&amp;quot;)&lt;br /&gt;
plot(ls16[:,0],ls16[:,3]/256,color=&amp;quot;lime&amp;quot;,label=&amp;quot;16x16&amp;quot;)&lt;br /&gt;
plot(ls32[:,0],ls32[:,3]/1024,color=&amp;quot;blue&amp;quot;,label=&amp;quot;32x32&amp;quot;)&lt;br /&gt;
plot(ls64[:,0],ls64[:,3]/4096,color=&amp;quot;indigo&amp;quot;,label=&amp;quot;64x64&amp;quot;)&lt;br /&gt;
plot(ls128[:,0],ls128[:,3]/16384,color=&amp;quot;violet&amp;quot;,label=&amp;quot;128x128&amp;quot;)&lt;br /&gt;
title(&amp;quot;Magnetisation per spin&amp;quot;)&lt;br /&gt;
xlabel(&amp;quot;Temperature (K)&amp;quot;)&lt;br /&gt;
ylabel(&amp;quot;Magnetisation per spin&amp;quot;)&lt;br /&gt;
legend()&lt;br /&gt;
savefig(&amp;quot;Magnetisation.png&amp;quot;)&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Significant changes may be observed from 2x2 lattice up to 16x16 lattice, later the additional long range effects become less noticeable, but new effects are still present. It seems that most of the long range effects are captured by 16x16 lattice, but higher dimensions bring additional improvement.&lt;br /&gt;
&lt;br /&gt;
== Heat Capacity ==&lt;br /&gt;
&lt;br /&gt;
This formula holds true by definition: &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;
Variance of energy can be calculated  in the following way: &amp;lt;math&amp;gt;\mathrm{Var}[X] = \left\langle E^2\right\rangle - \left\langle E\right\rangle^2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Since expected energy can also be expressed as partition function: &amp;lt;math&amp;gt;\left\langle E\right\rangle = \frac{\partial}{\partial \beta}lnZ&amp;lt;/math&amp;gt;, variance may be expressed as &amp;lt;math&amp;gt;\mathrm{Var}[X] = \frac{\partial ^2}{\partial \beta ^2}lnZ = - \frac{\partial \left\langle E\right\rangle}{\partial \beta}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We can rearrange the equations given, because &amp;lt;math&amp;gt;T = \frac{1}{k_BT}&amp;lt;/math&amp;gt;, so that we obtain &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;
=== Heat capacity of the model ===&lt;br /&gt;
&lt;br /&gt;
Heat capacities of the models were calculated using the script given below (example for 2x2 lattice).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
figsize(6,4)&lt;br /&gt;
plot(ls2[:,0],(ls2[:,2]-ls2[:,1]**2)/ls2[:,0],color=&amp;quot;red&amp;quot;,label=&amp;quot;2x2&amp;quot;)&lt;br /&gt;
xlabel(&amp;quot;Temperature (K)&amp;quot;)&lt;br /&gt;
ylabel(&amp;quot;C&amp;quot;)&lt;br /&gt;
savefig(&amp;quot;C2.png&amp;quot;)&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphs of heat capacities are shown in the gallery below (figures 24-30). It can be seen that the model breaks down at low temperatures for bigger lattices, but it still gives a peak heat capacity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_23.png|Figure 24: C result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_24.png|Figure 25: C result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_25.png|Figure 26: C result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_26.png|Figure 27: C result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_27.png|Figure 28: C result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_28.png|Figure 29: C result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_29.png|Figure 30: C result for 128x128 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Comparison of heat capacity per spin is given in the figure 31 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_30.png|Figure 31: Heat capacity comparison&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Curie temperature ==&lt;br /&gt;
&lt;br /&gt;
Curie temperature can be deduced from where there is a peak in heat capacity per spin. The graphs of heat capacity vs temperature is shown below (figures 32 and 33) for two different lattice sizes, once using Python script and once using C++ data provided.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_31.png|Figure 32: 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_32.png|Figure 33: 64x64 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Polynomial fit ===&lt;br /&gt;
&lt;br /&gt;
The C++ data was also fitted with a polynomial, firstly over the whole range and afterwards just in the peak range. Fitting a polynomial proved to be hard as expected (since data is close to delta-like function), but it became more feasible when smaller range was used. Examples of both fits are shown in figures 34 and 35 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_33.png|Figure 34: Whole region fit&lt;br /&gt;
Image:GE715_CMP_34.png|Figure 35: Peak region fit&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Finding Curie temperature ===&lt;br /&gt;
&lt;br /&gt;
The last step was to find peak heat capacity for different lattice sizes in C++ data. The results are shown in the table below.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Lattice size&lt;br /&gt;
! Curie temperature&lt;br /&gt;
|-&lt;br /&gt;
|2x2&lt;br /&gt;
|2.48 K&lt;br /&gt;
|-&lt;br /&gt;
|4x4&lt;br /&gt;
|2.40 K&lt;br /&gt;
|-&lt;br /&gt;
|8x8&lt;br /&gt;
|2.32 K&lt;br /&gt;
|-&lt;br /&gt;
|16x16&lt;br /&gt;
|2.25 K&lt;br /&gt;
|-&lt;br /&gt;
|32x32&lt;br /&gt;
|2.30 K&lt;br /&gt;
|-&lt;br /&gt;
|64x64&lt;br /&gt;
|2.25 K&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The curie temperature for infinite lattice is known to be calculated from that of a finite lattice using equation &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 a constant. This was used to draw a graph shown in figure 36 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_35.png|Figure 36: Curie temperature for infinite lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Curie temperature for infinite lattice was found to be &amp;lt;math&amp;gt;T=2.26 K&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The code used for drawing the graph in figure 36 is shown below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
L=array([1/2,1/4,1/8,1/16,1/32,1/64])&lt;br /&gt;
T=array([2.48,2.4,2.32,2.25,2.3,2.25])&lt;br /&gt;
X=array([1/2,0])&lt;br /&gt;
figsize(9,6)&lt;br /&gt;
plot(L,T,marker=&amp;quot;D&amp;quot;,linestyle=&amp;quot; &amp;quot;)&lt;br /&gt;
xlabel(&amp;quot;1/L&amp;quot;)&lt;br /&gt;
ylabel(&amp;quot;T&amp;quot;)&lt;br /&gt;
a=polyfit(L,T,1)&lt;br /&gt;
ylim(2.23,2.5)&lt;br /&gt;
plot(X,a[0]*X+a[1],color=&amp;quot;lime&amp;quot;)&lt;br /&gt;
title(&amp;quot;Curie temperature&amp;quot;)&lt;br /&gt;
savefig(&amp;quot;Curie.png&amp;quot;)&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:CMPY3_GE715&amp;diff=645958</id>
		<title>Rep:CMPY3 GE715</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:CMPY3_GE715&amp;diff=645958"/>
		<updated>2017-11-22T11:42:07Z</updated>

		<summary type="html">&lt;p&gt;Ge715: /* Finding Curie temperature */  Code&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Ising Model ==&lt;br /&gt;
&lt;br /&gt;
Ising model is built on the assumption that a lattice that can be of any dimensionality contains spins which can either be up (+1 or down (-1) and interactions can be studied using this model. The model is extremely simplified, since in real systems the spins can point in any direction, but the basic properties of magnetic systems, such as magnetisation, energy levels and Curie temperature, may be studied using this simplification. &lt;br /&gt;
&lt;br /&gt;
The interaction energy in Ising model is defined as &amp;lt;math&amp;gt;E=- \frac{1}{2} J \sum_i^N \sum_{j\  \in\  \mathrm{neighbours}\left(i\right)} s_i s_j&amp;lt;/math&amp;gt;. The energy will be the lowest possible when all the spins point in the same direction. In that case &amp;lt;math&amp;gt;s_i s_j=1&amp;lt;/math&amp;gt; for all possible &amp;lt;math&amp;gt;i,j&amp;lt;/math&amp;gt; pairs. The number of pairs for each &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; depends on the number of dimensions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;P=2D&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;P&amp;lt;/math&amp;gt; represents the number of pairs and &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; the number of dimensions. The lowest possible energy will thus be &amp;lt;math&amp;gt;E=- \frac{1}{2} JNP&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; represents the total number of spins. Thus the lowest possible energy may also be simplified as &amp;lt;math&amp;gt;E=-DNJ&amp;lt;/math&amp;gt;, as requested.&lt;br /&gt;
&lt;br /&gt;
The multiplicity of this particular state is 2 (all spins up or all spins down), thus &amp;lt;math&amp;gt;\Omega=2&amp;lt;/math&amp;gt;, entropy of the system is &amp;lt;math&amp;gt;S=k_b ln \Omega=9.6*10^{-24} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Flip of a spin ===&lt;br /&gt;
&lt;br /&gt;
If one of the spins flips, the energy increases. In the given case (&amp;lt;math&amp;gt;D=3, N=1000&amp;lt;/math&amp;gt;), the &amp;lt;math&amp;gt;E_i=-3000 J&amp;lt;/math&amp;gt;, while the flip of one spin increases the energy by &amp;lt;math&amp;gt;12 J&amp;lt;/math&amp;gt; (6 pairs, &amp;lt;math&amp;gt;2 J&amp;lt;/math&amp;gt; per pair), so that &amp;lt;math&amp;gt;E_f=-2988 J&amp;lt;/math&amp;gt;. Note that &amp;lt;math&amp;gt;J&amp;lt;/math&amp;gt; does not represent joules in this case.&lt;br /&gt;
&lt;br /&gt;
Multiplicity has increased to &amp;lt;math&amp;gt;\Omega=2000&amp;lt;/math&amp;gt;, thus &amp;lt;math&amp;gt;S=1.05*10^{-22} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\Delta S=1.04*10^{-22} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This means that entropy has increased by more than 100 times.&lt;br /&gt;
&lt;br /&gt;
=== Magnetisation in the sketch ===&lt;br /&gt;
&lt;br /&gt;
The 1D system shown has the magnetisation of &amp;lt;math&amp;gt;M=1&amp;lt;/math&amp;gt;. This is also true for the 2D system shown. For the model system with &amp;lt;math&amp;gt;N=1000, D=3&amp;lt;/math&amp;gt; the expected magnetisation at absolute zero would be &amp;lt;math&amp;gt;M=\pm 1000&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Code for magnetisation and energy ==&lt;br /&gt;
&lt;br /&gt;
Python code was written to calculate the energy and magnetisation of a configuration and tested a few times. The test results are shown in figure 1 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=800 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_0.png|Figure 1: Test results&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Accelerating the code ==&lt;br /&gt;
&lt;br /&gt;
The code at the beginning was written using a loop for magnetisation and a double loop for energy. 2000 Monte Carlo steps needed was &amp;lt;math&amp;gt;M=9.32 s \pm 0.10 s&amp;lt;/math&amp;gt;. After optimizing magnetisation only this has dropped to &amp;lt;math&amp;gt;M=8.88 s \pm 0.04 s&amp;lt;/math&amp;gt;, while after optimizing both magnetisation and energy with using Numpy&#039;s sum, roll and multiply functions, the time was further reduced to &amp;lt;math&amp;gt;M=0.0796 s \pm 0.018 s&amp;lt;/math&amp;gt;. It was later realised that only one roll in each direction is needed to produce the correct energy, so the final time for 2000 steps was successfully reduced to &amp;lt;math&amp;gt;M=0.418 s \pm 0.005 s&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The whole of the code used is given below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
&lt;br /&gt;
class IsingLattice:&lt;br /&gt;
&lt;br /&gt;
    E = 0.0&lt;br /&gt;
    E2 = 0.0&lt;br /&gt;
    M = 0.0&lt;br /&gt;
    M2 = 0.0&lt;br /&gt;
    energy_x=0&lt;br /&gt;
    energy2_x=0&lt;br /&gt;
    magnetisation_x=0&lt;br /&gt;
    magnetisation2_x=0&lt;br /&gt;
&lt;br /&gt;
    n_cycles = 0&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, n_rows, n_cols):&lt;br /&gt;
        self.n_rows = n_rows&lt;br /&gt;
        self.n_cols = n_cols&lt;br /&gt;
        self.lattice = np.random.choice([-1,1], size=(n_rows, n_cols))&lt;br /&gt;
&lt;br /&gt;
    def energy(self):&lt;br /&gt;
        a=np.roll(self.lattice,1,axis=0)&lt;br /&gt;
        a1=np.multiply(a,self.lattice)&lt;br /&gt;
        x1=np.sum(a1)&lt;br /&gt;
        c=np.roll(self.lattice,1,axis=1)&lt;br /&gt;
        c1=np.multiply(c,self.lattice)&lt;br /&gt;
        x2=np.sum(c1)&lt;br /&gt;
        x=x1+x2&lt;br /&gt;
        energy = -x&lt;br /&gt;
        return 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;
        return np.sum(self.lattice)&lt;br /&gt;
&lt;br /&gt;
    def energy_flip(self,random_i,random_j):&lt;br /&gt;
        &amp;quot;Return the total energy of the current lattice after flip configuration.&amp;quot;&lt;br /&gt;
        self.lattice[random_i][random_j]=-self.lattice[random_i][random_j]&lt;br /&gt;
        a=np.roll(self.lattice,1,axis=0)&lt;br /&gt;
        a1=np.multiply(a,self.lattice)&lt;br /&gt;
        x1=np.sum(a1)&lt;br /&gt;
        c=np.roll(self.lattice,1,axis=1)&lt;br /&gt;
        c1=np.multiply(c,self.lattice)&lt;br /&gt;
        x2=np.sum(c1)&lt;br /&gt;
        x=x1+x2&lt;br /&gt;
        energy = -x&lt;br /&gt;
        return energy&lt;br /&gt;
&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        # complete this function so that it performs a single Monte Carlo step&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        #the following two lines will select the coordinates of the random spin for you&lt;br /&gt;
        random_i = np.random.choice(range(0, self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(0, self.n_cols))&lt;br /&gt;
        #the following line will choose a random number in the range [0,1) for you&lt;br /&gt;
        random_number = np.random.random()&lt;br /&gt;
        self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
        energy2 = self.energy()&lt;br /&gt;
        dE = energy2 - energy&lt;br /&gt;
&lt;br /&gt;
        if energy2&amp;lt;energy or random_number&amp;lt;=np.e**(-(energy2-energy)/T):&lt;br /&gt;
            yyy=True&lt;br /&gt;
        else:&lt;br /&gt;
            self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
			&lt;br /&gt;
        self.n_cycles+=1&lt;br /&gt;
&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;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        # complete this function so that it calculates the correct values for the averages of E, E*E (E2), M, M*M (M2), and returns them&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.M / self.n_cycles&lt;br /&gt;
        return avE, avE2, avM, avM2, self.n_cycles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Temperature effects ==&lt;br /&gt;
&lt;br /&gt;
=== Correction of averaging code ===&lt;br /&gt;
&lt;br /&gt;
A few experiments were performed at different temperatures using ILfinalframe.py, to see how long it usually takes for the system to equilibrate. At low temperatures it usually happened before 1000 steps were performed, thus 1000 Monte Carlo steps was decided to be appropriate cut-off period for calculation of average values of magnetisation and energy. The figures 2-4, showing the experiments performed are shown in the gallery below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_1.png|Figure 2: Test result @ 0.5 K&lt;br /&gt;
Image:GE715_CMP_2.png|Figure 3: Test result @ 1 K&lt;br /&gt;
Image:GE715_CMP_3.png|Figure 4: Test result @ 1.5 K&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The definitions of two class functions were changed as shown below to accommodate this change.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        # complete this function so that it performs a single Monte Carlo step&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        #the following two lines will select the coordinates of the random spin for you&lt;br /&gt;
        random_i = np.random.choice(range(0, self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(0, self.n_cols))&lt;br /&gt;
        #the following line will choose a random number in the range [0,1) for you&lt;br /&gt;
        random_number = np.random.random()&lt;br /&gt;
        self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
        energy2 = self.energy()&lt;br /&gt;
        dE = energy2 - energy&lt;br /&gt;
&lt;br /&gt;
        if energy2&amp;lt;energy or random_number&amp;lt;=np.e**(-(energy2-energy)/T):&lt;br /&gt;
            yyy=True&lt;br /&gt;
        else:&lt;br /&gt;
            self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
			&lt;br /&gt;
        self.n_cycles+=1&lt;br /&gt;
        if self.n_cycles==1000:&lt;br /&gt;
            self.E=0&lt;br /&gt;
            self.E2=0&lt;br /&gt;
            self.M=0&lt;br /&gt;
            self.M2=0&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;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        # complete this function so that it calculates the correct values for the averages of E, E*E (E2), M, M*M (M2), and returns them&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.M / self.n_cycles&lt;br /&gt;
        if self.n_cycles&amp;gt;1000:&lt;br /&gt;
            avE = self.E / (self.n_cycles-1000)&lt;br /&gt;
            avE2 = self.E2 / (self.n_cycles-1000)&lt;br /&gt;
            avM = self.M / (self.n_cycles-1000)&lt;br /&gt;
            avM2 = self.M / (self.n_cycles-1000)&lt;br /&gt;
        return avE, avE2, avM, avM2, self.n_cycles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Range of temperatures ===&lt;br /&gt;
&lt;br /&gt;
The experiment was run for 8x8 lattice at a temperature range of 0.25 K-5.00 K, with a point every 0.05 K. The experiments using a different number of total steps were performed and the comparison is shown below in figures 5-7.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_4.png|Figure 5: Test result for 8x8 lattice with 11000 steps&lt;br /&gt;
Image:GE715_CMP_5.png|Figure 6: Test result for 8x8 lattice with 21000 steps&lt;br /&gt;
Image:GE715_CMP_6.png|Figure 7: Test result for 8x8 lattice with 101000 steps&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is a small, but noticeable improvement in the smoothness of the curves obtained for energy with using more steps, thus the highest number of steps (101000 steps) was used in the further experiments regardless of the higher need for computational power.&lt;br /&gt;
&lt;br /&gt;
== Lattice size effects ==&lt;br /&gt;
&lt;br /&gt;
With increasing lattice size the energy and magnetisation curves become more realistic, since the long range effects are better accounted for. 7 different lattice sizes were tested and energy and magnetisation for each are shown below in figure 8-14 and 15-21 respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_7.png|Figure 8: Energy result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_8.png|Figure 9: Energy result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_9.png|Figure 10: Energy result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_10.png|Figure 11: Energy result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_11.png|Figure 12: Energy result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_12.png|Figure 13: Energy result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_13.png|Figure 14: Energy result for 128x128 lattice&lt;br /&gt;
Image:GE715_CMP_14.png|Figure 15: Magnetisation result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_15.png|Figure 16: Magnetisation result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_16.png|Figure 17: Magnetisation result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_17.png|Figure 18: Magnetisation result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_18.png|Figure 19: Magnetisation result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_19.png|Figure 20: Magnetisation result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_20.png|Figure 21: Magnetisation result for 128x128 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Overall comparison of energy and magnetisation per spin in each lattice was made and can be seen in figures 22 and 23 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_21.png|Figure 22: Energy comparison&lt;br /&gt;
Image:GE715_CMP_22.png|Figure 23: Magnetisation comparison&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code used for producing figure 23 above is shown below. Other codes are analagous. Example for defining ls2 is also shown Others are similar..&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ls2=loadtxt(&amp;quot;2x2(100).dat&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
figsize(12,8)&lt;br /&gt;
plot(ls2[:,0],ls2[:,3]/4,color=&amp;quot;red&amp;quot;,label=&amp;quot;2x2&amp;quot;)&lt;br /&gt;
plot(ls4[:,0],ls4[:,3]/16,color=&amp;quot;orange&amp;quot;,label=&amp;quot;4x4&amp;quot;)&lt;br /&gt;
plot(ls8[:,0],ls8[:,3]/64,color=&amp;quot;yellow&amp;quot;,label=&amp;quot;8x8&amp;quot;)&lt;br /&gt;
plot(ls16[:,0],ls16[:,3]/256,color=&amp;quot;lime&amp;quot;,label=&amp;quot;16x16&amp;quot;)&lt;br /&gt;
plot(ls32[:,0],ls32[:,3]/1024,color=&amp;quot;blue&amp;quot;,label=&amp;quot;32x32&amp;quot;)&lt;br /&gt;
plot(ls64[:,0],ls64[:,3]/4096,color=&amp;quot;indigo&amp;quot;,label=&amp;quot;64x64&amp;quot;)&lt;br /&gt;
plot(ls128[:,0],ls128[:,3]/16384,color=&amp;quot;violet&amp;quot;,label=&amp;quot;128x128&amp;quot;)&lt;br /&gt;
title(&amp;quot;Magnetisation per spin&amp;quot;)&lt;br /&gt;
xlabel(&amp;quot;Temperature (K)&amp;quot;)&lt;br /&gt;
ylabel(&amp;quot;Magnetisation per spin&amp;quot;)&lt;br /&gt;
legend()&lt;br /&gt;
savefig(&amp;quot;Magnetisation.png&amp;quot;)&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Significant changes may be observed from 2x2 lattice up to 16x16 lattice, later the additional long range effects become less noticeable, but new effects are still present. It seems that most of the long range effects are captured by 16x16 lattice, but higher dimensions bring additional improvement.&lt;br /&gt;
&lt;br /&gt;
== Heat Capacity ==&lt;br /&gt;
&lt;br /&gt;
This formula holds true by definition: &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;
Variance of energy can be calculated  in the following way: &amp;lt;math&amp;gt;\mathrm{Var}[X] = \left\langle E^2\right\rangle - \left\langle E\right\rangle^2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Since expected energy can also be expressed as partition function: &amp;lt;math&amp;gt;\left\langle E\right\rangle = \frac{\partial}{\partial \beta}lnZ&amp;lt;/math&amp;gt;, variance may be expressed as &amp;lt;math&amp;gt;\mathrm{Var}[X] = \frac{\partial ^2}{\partial \beta ^2}lnZ = - \frac{\partial \left\langle E\right\rangle}{\partial \beta}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We can rearrange the equations given, because &amp;lt;math&amp;gt;T = \frac{1}{k_BT}&amp;lt;/math&amp;gt;, so that we obtain &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;
=== Heat capacity of the model ===&lt;br /&gt;
&lt;br /&gt;
Heat capacities of the models were calculated using the script given below (example for 2x2 lattice).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
figsize(6,4)&lt;br /&gt;
plot(ls2[:,0],(ls2[:,2]-ls2[:,1]**2)/ls2[:,0],color=&amp;quot;red&amp;quot;,label=&amp;quot;2x2&amp;quot;)&lt;br /&gt;
xlabel(&amp;quot;Temperature (K)&amp;quot;)&lt;br /&gt;
ylabel(&amp;quot;C&amp;quot;)&lt;br /&gt;
savefig(&amp;quot;C2.png&amp;quot;)&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphs of heat capacities are shown in the gallery below (figures 24-30). It can be seen that the model breaks down at low temperatures for bigger lattices, but it still gives a peak heat capacity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_23.png|Figure 24: C result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_24.png|Figure 25: C result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_25.png|Figure 26: C result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_26.png|Figure 27: C result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_27.png|Figure 28: C result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_28.png|Figure 29: C result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_29.png|Figure 30: C result for 128x128 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Comparison of heat capacity per spin is given in the figure 31 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_30.png|Figure 31: Heat capacity comparison&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Curie temperature ==&lt;br /&gt;
&lt;br /&gt;
Curie temperature can be deduced from where there is a peak in heat capacity per spin. The graphs of heat capacity vs temperature is shown below (figures 32 and 33) for two different lattice sizes, once using Python script and once using C++ data provided.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_31.png|Figure 32: 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_32.png|Figure 33: 64x64 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Polynomial fit ===&lt;br /&gt;
&lt;br /&gt;
The C++ data was also fitted with a polynomial, firstly over the whole range and afterwards just in the peak range. Fitting a polynomial proved to be hard as expected (since data is close to delta-like function), but it became more feasible when smaller range was used. Examples of both fits are shown in figures 34 and 35 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_33.png|Figure 34: Whole region fit&lt;br /&gt;
Image:GE715_CMP_34.png|Figure 35: Peak region fit&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Finding Curie temperature ===&lt;br /&gt;
&lt;br /&gt;
The last step was to find peak heat capacity for different lattice sizes in C++ data. The results are shown in the table below.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Lattice size&lt;br /&gt;
! Curie temperature&lt;br /&gt;
|-&lt;br /&gt;
|2x2&lt;br /&gt;
|2.48 K&lt;br /&gt;
|-&lt;br /&gt;
|4x4&lt;br /&gt;
|2.40 K&lt;br /&gt;
|-&lt;br /&gt;
|8x8&lt;br /&gt;
|2.32 K&lt;br /&gt;
|-&lt;br /&gt;
|16x16&lt;br /&gt;
|2.25 K&lt;br /&gt;
|-&lt;br /&gt;
|32x32&lt;br /&gt;
|2.30 K&lt;br /&gt;
|-&lt;br /&gt;
|64x64&lt;br /&gt;
|2.25 K&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The curie temperature for infinite lattice is known to be calculated from that of a finite lattice using equation &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 a constant. This was used to draw a graph shown in figure 36 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_35.png|Figure 36: Curie temperature for infinite lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Curie temperature for infinite lattice was found to be &amp;lt;math&amp;gt;T=2.26 K&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The code used for drawing the graph in figure 36 is shown below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
L=array([1/2,1/4,1/8,1/16,1/32,1/64])&lt;br /&gt;
T=array([2.48,2.4,2.32,2.25,2.3,2.25])&lt;br /&gt;
X=array([1/2,0])&lt;br /&gt;
figsize(9,6)&lt;br /&gt;
plot(L,T,marker=&amp;quot;D&amp;quot;,linestyle=&amp;quot; &amp;quot;)&lt;br /&gt;
xlabel(&amp;quot;1/L&amp;quot;)&lt;br /&gt;
ylabel(&amp;quot;T&amp;quot;)&lt;br /&gt;
a=polyfit(L,T,1)&lt;br /&gt;
ylim(2.23,2.5)&lt;br /&gt;
plot(X,a[0]*X+a[1],color=&amp;quot;lime&amp;quot;)&lt;br /&gt;
title(&amp;quot;Curie temperature&amp;quot;)&lt;br /&gt;
savefig(&amp;quot;Curie.png&amp;quot;)&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:CMPY3_GE715&amp;diff=645955</id>
		<title>Rep:CMPY3 GE715</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:CMPY3_GE715&amp;diff=645955"/>
		<updated>2017-11-22T11:40:41Z</updated>

		<summary type="html">&lt;p&gt;Ge715: /* Ising Model */ Introduction&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Ising Model ==&lt;br /&gt;
&lt;br /&gt;
Ising model is built on the assumption that a lattice that can be of any dimensionality contains spins which can either be up (+1 or down (-1) and interactions can be studied using this model. The model is extremely simplified, since in real systems the spins can point in any direction, but the basic properties of magnetic systems, such as magnetisation, energy levels and Curie temperature, may be studied using this simplification. &lt;br /&gt;
&lt;br /&gt;
The interaction energy in Ising model is defined as &amp;lt;math&amp;gt;E=- \frac{1}{2} J \sum_i^N \sum_{j\  \in\  \mathrm{neighbours}\left(i\right)} s_i s_j&amp;lt;/math&amp;gt;. The energy will be the lowest possible when all the spins point in the same direction. In that case &amp;lt;math&amp;gt;s_i s_j=1&amp;lt;/math&amp;gt; for all possible &amp;lt;math&amp;gt;i,j&amp;lt;/math&amp;gt; pairs. The number of pairs for each &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; depends on the number of dimensions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;P=2D&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;P&amp;lt;/math&amp;gt; represents the number of pairs and &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; the number of dimensions. The lowest possible energy will thus be &amp;lt;math&amp;gt;E=- \frac{1}{2} JNP&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; represents the total number of spins. Thus the lowest possible energy may also be simplified as &amp;lt;math&amp;gt;E=-DNJ&amp;lt;/math&amp;gt;, as requested.&lt;br /&gt;
&lt;br /&gt;
The multiplicity of this particular state is 2 (all spins up or all spins down), thus &amp;lt;math&amp;gt;\Omega=2&amp;lt;/math&amp;gt;, entropy of the system is &amp;lt;math&amp;gt;S=k_b ln \Omega=9.6*10^{-24} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Flip of a spin ===&lt;br /&gt;
&lt;br /&gt;
If one of the spins flips, the energy increases. In the given case (&amp;lt;math&amp;gt;D=3, N=1000&amp;lt;/math&amp;gt;), the &amp;lt;math&amp;gt;E_i=-3000 J&amp;lt;/math&amp;gt;, while the flip of one spin increases the energy by &amp;lt;math&amp;gt;12 J&amp;lt;/math&amp;gt; (6 pairs, &amp;lt;math&amp;gt;2 J&amp;lt;/math&amp;gt; per pair), so that &amp;lt;math&amp;gt;E_f=-2988 J&amp;lt;/math&amp;gt;. Note that &amp;lt;math&amp;gt;J&amp;lt;/math&amp;gt; does not represent joules in this case.&lt;br /&gt;
&lt;br /&gt;
Multiplicity has increased to &amp;lt;math&amp;gt;\Omega=2000&amp;lt;/math&amp;gt;, thus &amp;lt;math&amp;gt;S=1.05*10^{-22} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\Delta S=1.04*10^{-22} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This means that entropy has increased by more than 100 times.&lt;br /&gt;
&lt;br /&gt;
=== Magnetisation in the sketch ===&lt;br /&gt;
&lt;br /&gt;
The 1D system shown has the magnetisation of &amp;lt;math&amp;gt;M=1&amp;lt;/math&amp;gt;. This is also true for the 2D system shown. For the model system with &amp;lt;math&amp;gt;N=1000, D=3&amp;lt;/math&amp;gt; the expected magnetisation at absolute zero would be &amp;lt;math&amp;gt;M=\pm 1000&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Code for magnetisation and energy ==&lt;br /&gt;
&lt;br /&gt;
Python code was written to calculate the energy and magnetisation of a configuration and tested a few times. The test results are shown in figure 1 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=800 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_0.png|Figure 1: Test results&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Accelerating the code ==&lt;br /&gt;
&lt;br /&gt;
The code at the beginning was written using a loop for magnetisation and a double loop for energy. 2000 Monte Carlo steps needed was &amp;lt;math&amp;gt;M=9.32 s \pm 0.10 s&amp;lt;/math&amp;gt;. After optimizing magnetisation only this has dropped to &amp;lt;math&amp;gt;M=8.88 s \pm 0.04 s&amp;lt;/math&amp;gt;, while after optimizing both magnetisation and energy with using Numpy&#039;s sum, roll and multiply functions, the time was further reduced to &amp;lt;math&amp;gt;M=0.0796 s \pm 0.018 s&amp;lt;/math&amp;gt;. It was later realised that only one roll in each direction is needed to produce the correct energy, so the final time for 2000 steps was successfully reduced to &amp;lt;math&amp;gt;M=0.418 s \pm 0.005 s&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The whole of the code used is given below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
&lt;br /&gt;
class IsingLattice:&lt;br /&gt;
&lt;br /&gt;
    E = 0.0&lt;br /&gt;
    E2 = 0.0&lt;br /&gt;
    M = 0.0&lt;br /&gt;
    M2 = 0.0&lt;br /&gt;
    energy_x=0&lt;br /&gt;
    energy2_x=0&lt;br /&gt;
    magnetisation_x=0&lt;br /&gt;
    magnetisation2_x=0&lt;br /&gt;
&lt;br /&gt;
    n_cycles = 0&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, n_rows, n_cols):&lt;br /&gt;
        self.n_rows = n_rows&lt;br /&gt;
        self.n_cols = n_cols&lt;br /&gt;
        self.lattice = np.random.choice([-1,1], size=(n_rows, n_cols))&lt;br /&gt;
&lt;br /&gt;
    def energy(self):&lt;br /&gt;
        a=np.roll(self.lattice,1,axis=0)&lt;br /&gt;
        a1=np.multiply(a,self.lattice)&lt;br /&gt;
        x1=np.sum(a1)&lt;br /&gt;
        c=np.roll(self.lattice,1,axis=1)&lt;br /&gt;
        c1=np.multiply(c,self.lattice)&lt;br /&gt;
        x2=np.sum(c1)&lt;br /&gt;
        x=x1+x2&lt;br /&gt;
        energy = -x&lt;br /&gt;
        return 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;
        return np.sum(self.lattice)&lt;br /&gt;
&lt;br /&gt;
    def energy_flip(self,random_i,random_j):&lt;br /&gt;
        &amp;quot;Return the total energy of the current lattice after flip configuration.&amp;quot;&lt;br /&gt;
        self.lattice[random_i][random_j]=-self.lattice[random_i][random_j]&lt;br /&gt;
        a=np.roll(self.lattice,1,axis=0)&lt;br /&gt;
        a1=np.multiply(a,self.lattice)&lt;br /&gt;
        x1=np.sum(a1)&lt;br /&gt;
        c=np.roll(self.lattice,1,axis=1)&lt;br /&gt;
        c1=np.multiply(c,self.lattice)&lt;br /&gt;
        x2=np.sum(c1)&lt;br /&gt;
        x=x1+x2&lt;br /&gt;
        energy = -x&lt;br /&gt;
        return energy&lt;br /&gt;
&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        # complete this function so that it performs a single Monte Carlo step&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        #the following two lines will select the coordinates of the random spin for you&lt;br /&gt;
        random_i = np.random.choice(range(0, self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(0, self.n_cols))&lt;br /&gt;
        #the following line will choose a random number in the range [0,1) for you&lt;br /&gt;
        random_number = np.random.random()&lt;br /&gt;
        self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
        energy2 = self.energy()&lt;br /&gt;
        dE = energy2 - energy&lt;br /&gt;
&lt;br /&gt;
        if energy2&amp;lt;energy or random_number&amp;lt;=np.e**(-(energy2-energy)/T):&lt;br /&gt;
            yyy=True&lt;br /&gt;
        else:&lt;br /&gt;
            self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
			&lt;br /&gt;
        self.n_cycles+=1&lt;br /&gt;
&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;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        # complete this function so that it calculates the correct values for the averages of E, E*E (E2), M, M*M (M2), and returns them&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.M / self.n_cycles&lt;br /&gt;
        return avE, avE2, avM, avM2, self.n_cycles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Temperature effects ==&lt;br /&gt;
&lt;br /&gt;
=== Correction of averaging code ===&lt;br /&gt;
&lt;br /&gt;
A few experiments were performed at different temperatures using ILfinalframe.py, to see how long it usually takes for the system to equilibrate. At low temperatures it usually happened before 1000 steps were performed, thus 1000 Monte Carlo steps was decided to be appropriate cut-off period for calculation of average values of magnetisation and energy. The figures 2-4, showing the experiments performed are shown in the gallery below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_1.png|Figure 2: Test result @ 0.5 K&lt;br /&gt;
Image:GE715_CMP_2.png|Figure 3: Test result @ 1 K&lt;br /&gt;
Image:GE715_CMP_3.png|Figure 4: Test result @ 1.5 K&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The definitions of two class functions were changed as shown below to accommodate this change.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        # complete this function so that it performs a single Monte Carlo step&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        #the following two lines will select the coordinates of the random spin for you&lt;br /&gt;
        random_i = np.random.choice(range(0, self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(0, self.n_cols))&lt;br /&gt;
        #the following line will choose a random number in the range [0,1) for you&lt;br /&gt;
        random_number = np.random.random()&lt;br /&gt;
        self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
        energy2 = self.energy()&lt;br /&gt;
        dE = energy2 - energy&lt;br /&gt;
&lt;br /&gt;
        if energy2&amp;lt;energy or random_number&amp;lt;=np.e**(-(energy2-energy)/T):&lt;br /&gt;
            yyy=True&lt;br /&gt;
        else:&lt;br /&gt;
            self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
			&lt;br /&gt;
        self.n_cycles+=1&lt;br /&gt;
        if self.n_cycles==1000:&lt;br /&gt;
            self.E=0&lt;br /&gt;
            self.E2=0&lt;br /&gt;
            self.M=0&lt;br /&gt;
            self.M2=0&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;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        # complete this function so that it calculates the correct values for the averages of E, E*E (E2), M, M*M (M2), and returns them&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.M / self.n_cycles&lt;br /&gt;
        if self.n_cycles&amp;gt;1000:&lt;br /&gt;
            avE = self.E / (self.n_cycles-1000)&lt;br /&gt;
            avE2 = self.E2 / (self.n_cycles-1000)&lt;br /&gt;
            avM = self.M / (self.n_cycles-1000)&lt;br /&gt;
            avM2 = self.M / (self.n_cycles-1000)&lt;br /&gt;
        return avE, avE2, avM, avM2, self.n_cycles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Range of temperatures ===&lt;br /&gt;
&lt;br /&gt;
The experiment was run for 8x8 lattice at a temperature range of 0.25 K-5.00 K, with a point every 0.05 K. The experiments using a different number of total steps were performed and the comparison is shown below in figures 5-7.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_4.png|Figure 5: Test result for 8x8 lattice with 11000 steps&lt;br /&gt;
Image:GE715_CMP_5.png|Figure 6: Test result for 8x8 lattice with 21000 steps&lt;br /&gt;
Image:GE715_CMP_6.png|Figure 7: Test result for 8x8 lattice with 101000 steps&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is a small, but noticeable improvement in the smoothness of the curves obtained for energy with using more steps, thus the highest number of steps (101000 steps) was used in the further experiments regardless of the higher need for computational power.&lt;br /&gt;
&lt;br /&gt;
== Lattice size effects ==&lt;br /&gt;
&lt;br /&gt;
With increasing lattice size the energy and magnetisation curves become more realistic, since the long range effects are better accounted for. 7 different lattice sizes were tested and energy and magnetisation for each are shown below in figure 8-14 and 15-21 respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_7.png|Figure 8: Energy result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_8.png|Figure 9: Energy result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_9.png|Figure 10: Energy result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_10.png|Figure 11: Energy result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_11.png|Figure 12: Energy result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_12.png|Figure 13: Energy result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_13.png|Figure 14: Energy result for 128x128 lattice&lt;br /&gt;
Image:GE715_CMP_14.png|Figure 15: Magnetisation result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_15.png|Figure 16: Magnetisation result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_16.png|Figure 17: Magnetisation result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_17.png|Figure 18: Magnetisation result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_18.png|Figure 19: Magnetisation result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_19.png|Figure 20: Magnetisation result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_20.png|Figure 21: Magnetisation result for 128x128 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Overall comparison of energy and magnetisation per spin in each lattice was made and can be seen in figures 22 and 23 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_21.png|Figure 22: Energy comparison&lt;br /&gt;
Image:GE715_CMP_22.png|Figure 23: Magnetisation comparison&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code used for producing figure 23 above is shown below. Other codes are analagous. Example for defining ls2 is also shown Others are similar..&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ls2=loadtxt(&amp;quot;2x2(100).dat&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
figsize(12,8)&lt;br /&gt;
plot(ls2[:,0],ls2[:,3]/4,color=&amp;quot;red&amp;quot;,label=&amp;quot;2x2&amp;quot;)&lt;br /&gt;
plot(ls4[:,0],ls4[:,3]/16,color=&amp;quot;orange&amp;quot;,label=&amp;quot;4x4&amp;quot;)&lt;br /&gt;
plot(ls8[:,0],ls8[:,3]/64,color=&amp;quot;yellow&amp;quot;,label=&amp;quot;8x8&amp;quot;)&lt;br /&gt;
plot(ls16[:,0],ls16[:,3]/256,color=&amp;quot;lime&amp;quot;,label=&amp;quot;16x16&amp;quot;)&lt;br /&gt;
plot(ls32[:,0],ls32[:,3]/1024,color=&amp;quot;blue&amp;quot;,label=&amp;quot;32x32&amp;quot;)&lt;br /&gt;
plot(ls64[:,0],ls64[:,3]/4096,color=&amp;quot;indigo&amp;quot;,label=&amp;quot;64x64&amp;quot;)&lt;br /&gt;
plot(ls128[:,0],ls128[:,3]/16384,color=&amp;quot;violet&amp;quot;,label=&amp;quot;128x128&amp;quot;)&lt;br /&gt;
title(&amp;quot;Magnetisation per spin&amp;quot;)&lt;br /&gt;
xlabel(&amp;quot;Temperature (K)&amp;quot;)&lt;br /&gt;
ylabel(&amp;quot;Magnetisation per spin&amp;quot;)&lt;br /&gt;
legend()&lt;br /&gt;
savefig(&amp;quot;Magnetisation.png&amp;quot;)&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Significant changes may be observed from 2x2 lattice up to 16x16 lattice, later the additional long range effects become less noticeable, but new effects are still present. It seems that most of the long range effects are captured by 16x16 lattice, but higher dimensions bring additional improvement.&lt;br /&gt;
&lt;br /&gt;
== Heat Capacity ==&lt;br /&gt;
&lt;br /&gt;
This formula holds true by definition: &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;
Variance of energy can be calculated  in the following way: &amp;lt;math&amp;gt;\mathrm{Var}[X] = \left\langle E^2\right\rangle - \left\langle E\right\rangle^2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Since expected energy can also be expressed as partition function: &amp;lt;math&amp;gt;\left\langle E\right\rangle = \frac{\partial}{\partial \beta}lnZ&amp;lt;/math&amp;gt;, variance may be expressed as &amp;lt;math&amp;gt;\mathrm{Var}[X] = \frac{\partial ^2}{\partial \beta ^2}lnZ = - \frac{\partial \left\langle E\right\rangle}{\partial \beta}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We can rearrange the equations given, because &amp;lt;math&amp;gt;T = \frac{1}{k_BT}&amp;lt;/math&amp;gt;, so that we obtain &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;
=== Heat capacity of the model ===&lt;br /&gt;
&lt;br /&gt;
Heat capacities of the models were calculated using the script given below (example for 2x2 lattice).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
figsize(6,4)&lt;br /&gt;
plot(ls2[:,0],(ls2[:,2]-ls2[:,1]**2)/ls2[:,0],color=&amp;quot;red&amp;quot;,label=&amp;quot;2x2&amp;quot;)&lt;br /&gt;
xlabel(&amp;quot;Temperature (K)&amp;quot;)&lt;br /&gt;
ylabel(&amp;quot;C&amp;quot;)&lt;br /&gt;
savefig(&amp;quot;C2.png&amp;quot;)&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphs of heat capacities are shown in the gallery below (figures 24-30). It can be seen that the model breaks down at low temperatures for bigger lattices, but it still gives a peak heat capacity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_23.png|Figure 24: C result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_24.png|Figure 25: C result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_25.png|Figure 26: C result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_26.png|Figure 27: C result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_27.png|Figure 28: C result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_28.png|Figure 29: C result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_29.png|Figure 30: C result for 128x128 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Comparison of heat capacity per spin is given in the figure 31 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_30.png|Figure 31: Heat capacity comparison&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Curie temperature ==&lt;br /&gt;
&lt;br /&gt;
Curie temperature can be deduced from where there is a peak in heat capacity per spin. The graphs of heat capacity vs temperature is shown below (figures 32 and 33) for two different lattice sizes, once using Python script and once using C++ data provided.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_31.png|Figure 32: 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_32.png|Figure 33: 64x64 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Polynomial fit ===&lt;br /&gt;
&lt;br /&gt;
The C++ data was also fitted with a polynomial, firstly over the whole range and afterwards just in the peak range. Fitting a polynomial proved to be hard as expected (since data is close to delta-like function), but it became more feasible when smaller range was used. Examples of both fits are shown in figures 34 and 35 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_33.png|Figure 34: Whole region fit&lt;br /&gt;
Image:GE715_CMP_34.png|Figure 35: Peak region fit&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Finding Curie temperature ===&lt;br /&gt;
&lt;br /&gt;
The last step was to find peak heat capacity for different lattice sizes in C++ data. The results are shown in the table below.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Lattice size&lt;br /&gt;
! Curie temperature&lt;br /&gt;
|-&lt;br /&gt;
|2x2&lt;br /&gt;
|2.48 K&lt;br /&gt;
|-&lt;br /&gt;
|4x4&lt;br /&gt;
|2.40 K&lt;br /&gt;
|-&lt;br /&gt;
|8x8&lt;br /&gt;
|2.32 K&lt;br /&gt;
|-&lt;br /&gt;
|16x16&lt;br /&gt;
|2.25 K&lt;br /&gt;
|-&lt;br /&gt;
|32x32&lt;br /&gt;
|2.30 K&lt;br /&gt;
|-&lt;br /&gt;
|64x64&lt;br /&gt;
|2.25 K&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The curie temperature for infinite lattice is known to be calculated from that of a finite lattice using equation &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 a constant. This was used to draw a graph shown in figure 36 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_35.png|Figure 36: Curie temperature for infinite lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Curie temperature for infinite lattice was found to be &amp;lt;math&amp;gt;T=2.26 K&amp;lt;/math&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715_CMP_35.png&amp;diff=645847</id>
		<title>File:GE715 CMP 35.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715_CMP_35.png&amp;diff=645847"/>
		<updated>2017-11-22T10:48:12Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:CMPY3_GE715&amp;diff=645843</id>
		<title>Rep:CMPY3 GE715</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:CMPY3_GE715&amp;diff=645843"/>
		<updated>2017-11-22T10:47:12Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Ising Model ==&lt;br /&gt;
&lt;br /&gt;
The interaction energy in Ising model is defined as &amp;lt;math&amp;gt;E=- \frac{1}{2} J \sum_i^N \sum_{j\  \in\  \mathrm{neighbours}\left(i\right)} s_i s_j&amp;lt;/math&amp;gt;. The energy will be the lowest possible when all the spins point in the same direction. In that case &amp;lt;math&amp;gt;s_i s_j=1&amp;lt;/math&amp;gt; for all possible &amp;lt;math&amp;gt;i,j&amp;lt;/math&amp;gt; pairs. The number of pairs for each &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; depends on the number of dimensions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;P=2D&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;P&amp;lt;/math&amp;gt; represents the number of pairs and &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; the number of dimensions. The lowest possible energy will thus be &amp;lt;math&amp;gt;E=- \frac{1}{2} JNP&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; represents the total number of spins. Thus the lowest possible energy may also be simplified as &amp;lt;math&amp;gt;E=-DNJ&amp;lt;/math&amp;gt;, as requested.&lt;br /&gt;
&lt;br /&gt;
The multiplicity of this particular state is 2 (all spins up or all spins down), thus &amp;lt;math&amp;gt;\Omega=2&amp;lt;/math&amp;gt;, entropy of the system is &amp;lt;math&amp;gt;S=k_b ln \Omega=9.6*10^{-24} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Flip of a spin ===&lt;br /&gt;
&lt;br /&gt;
If one of the spins flips, the energy increases. In the given case (&amp;lt;math&amp;gt;D=3, N=1000&amp;lt;/math&amp;gt;), the &amp;lt;math&amp;gt;E_i=-3000 J&amp;lt;/math&amp;gt;, while the flip of one spin increases the energy by &amp;lt;math&amp;gt;12 J&amp;lt;/math&amp;gt; (6 pairs, &amp;lt;math&amp;gt;2 J&amp;lt;/math&amp;gt; per pair), so that &amp;lt;math&amp;gt;E_f=-2988 J&amp;lt;/math&amp;gt;. Note that &amp;lt;math&amp;gt;J&amp;lt;/math&amp;gt; does not represent joules in this case.&lt;br /&gt;
&lt;br /&gt;
Multiplicity has increased to &amp;lt;math&amp;gt;\Omega=2000&amp;lt;/math&amp;gt;, thus &amp;lt;math&amp;gt;S=1.05*10^{-22} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\Delta S=1.04*10^{-22} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Magnetisation in the sketch ===&lt;br /&gt;
&lt;br /&gt;
The 1D system shown has the magnetisation of &amp;lt;math&amp;gt;M=1&amp;lt;/math&amp;gt;. This is also true for the 2D system shown. For the model system with &amp;lt;math&amp;gt;N=1000, D=3&amp;lt;/math&amp;gt; the expected magnetisation at absolute zero would be &amp;lt;math&amp;gt;M=\pm 1000&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Code for magnetisation and energy ==&lt;br /&gt;
&lt;br /&gt;
Python code was written to calculate the energy and magnetisation of a configuration and tested a few times. The test results are shown in figure 1 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=800 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_0.png|Figure 1: Test results&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Accelerating the code ==&lt;br /&gt;
&lt;br /&gt;
The code at the beginning was written using a loop for magnetisation and a double loop for energy. 2000 Monte Carlo steps needed was &amp;lt;math&amp;gt;M=9.32 s \pm 0.10 s&amp;lt;/math&amp;gt;. After optimizing magnetisation only this has dropped to &amp;lt;math&amp;gt;M=8.88 s \pm 0.04 s&amp;lt;/math&amp;gt;, while after optimizing both magnetisation and energy with using Numpy&#039;s sum, roll and multiply functions, the time was further reduced to &amp;lt;math&amp;gt;M=0.0796 s \pm 0.018 s&amp;lt;/math&amp;gt;. It was later realised that only one roll in each direction is needed to produce the correct energy, so the final time for 2000 steps was successfully reduced to &amp;lt;math&amp;gt;M=0.418 s \pm 0.005 s&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The whole of the code used is given below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
&lt;br /&gt;
class IsingLattice:&lt;br /&gt;
&lt;br /&gt;
    E = 0.0&lt;br /&gt;
    E2 = 0.0&lt;br /&gt;
    M = 0.0&lt;br /&gt;
    M2 = 0.0&lt;br /&gt;
    energy_x=0&lt;br /&gt;
    energy2_x=0&lt;br /&gt;
    magnetisation_x=0&lt;br /&gt;
    magnetisation2_x=0&lt;br /&gt;
&lt;br /&gt;
    n_cycles = 0&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, n_rows, n_cols):&lt;br /&gt;
        self.n_rows = n_rows&lt;br /&gt;
        self.n_cols = n_cols&lt;br /&gt;
        self.lattice = np.random.choice([-1,1], size=(n_rows, n_cols))&lt;br /&gt;
&lt;br /&gt;
    def energy(self):&lt;br /&gt;
        a=np.roll(self.lattice,1,axis=0)&lt;br /&gt;
        a1=np.multiply(a,self.lattice)&lt;br /&gt;
        x1=np.sum(a1)&lt;br /&gt;
        c=np.roll(self.lattice,1,axis=1)&lt;br /&gt;
        c1=np.multiply(c,self.lattice)&lt;br /&gt;
        x2=np.sum(c1)&lt;br /&gt;
        x=x1+x2&lt;br /&gt;
        energy = -x&lt;br /&gt;
        return 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;
        return np.sum(self.lattice)&lt;br /&gt;
&lt;br /&gt;
    def energy_flip(self,random_i,random_j):&lt;br /&gt;
        &amp;quot;Return the total energy of the current lattice after flip configuration.&amp;quot;&lt;br /&gt;
        self.lattice[random_i][random_j]=-self.lattice[random_i][random_j]&lt;br /&gt;
        a=np.roll(self.lattice,1,axis=0)&lt;br /&gt;
        a1=np.multiply(a,self.lattice)&lt;br /&gt;
        x1=np.sum(a1)&lt;br /&gt;
        c=np.roll(self.lattice,1,axis=1)&lt;br /&gt;
        c1=np.multiply(c,self.lattice)&lt;br /&gt;
        x2=np.sum(c1)&lt;br /&gt;
        x=x1+x2&lt;br /&gt;
        energy = -x&lt;br /&gt;
        return energy&lt;br /&gt;
&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        # complete this function so that it performs a single Monte Carlo step&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        #the following two lines will select the coordinates of the random spin for you&lt;br /&gt;
        random_i = np.random.choice(range(0, self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(0, self.n_cols))&lt;br /&gt;
        #the following line will choose a random number in the range [0,1) for you&lt;br /&gt;
        random_number = np.random.random()&lt;br /&gt;
        self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
        energy2 = self.energy()&lt;br /&gt;
        dE = energy2 - energy&lt;br /&gt;
&lt;br /&gt;
        if energy2&amp;lt;energy or random_number&amp;lt;=np.e**(-(energy2-energy)/T):&lt;br /&gt;
            yyy=True&lt;br /&gt;
        else:&lt;br /&gt;
            self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
			&lt;br /&gt;
        self.n_cycles+=1&lt;br /&gt;
&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;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        # complete this function so that it calculates the correct values for the averages of E, E*E (E2), M, M*M (M2), and returns them&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.M / self.n_cycles&lt;br /&gt;
        return avE, avE2, avM, avM2, self.n_cycles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Temperature effects ==&lt;br /&gt;
&lt;br /&gt;
=== Correction of averaging code ===&lt;br /&gt;
&lt;br /&gt;
A few experiments were performed at different temperatures using ILfinalframe.py, to see how long it usually takes for the system to equilibrate. At low temperatures it usually happened before 1000 steps were performed, thus 1000 Monte Carlo steps was decided to be appropriate cut-off period for calculation of average values of magnetisation and energy. The figures 2-4, showing the experiments performed are shown in the gallery below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_1.png|Figure 2: Test result @ 0.5 K&lt;br /&gt;
Image:GE715_CMP_2.png|Figure 3: Test result @ 1 K&lt;br /&gt;
Image:GE715_CMP_3.png|Figure 4: Test result @ 1.5 K&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The definitions of two class functions were changed as shown below to accommodate this change.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        # complete this function so that it performs a single Monte Carlo step&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        #the following two lines will select the coordinates of the random spin for you&lt;br /&gt;
        random_i = np.random.choice(range(0, self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(0, self.n_cols))&lt;br /&gt;
        #the following line will choose a random number in the range [0,1) for you&lt;br /&gt;
        random_number = np.random.random()&lt;br /&gt;
        self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
        energy2 = self.energy()&lt;br /&gt;
        dE = energy2 - energy&lt;br /&gt;
&lt;br /&gt;
        if energy2&amp;lt;energy or random_number&amp;lt;=np.e**(-(energy2-energy)/T):&lt;br /&gt;
            yyy=True&lt;br /&gt;
        else:&lt;br /&gt;
            self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
			&lt;br /&gt;
        self.n_cycles+=1&lt;br /&gt;
        if self.n_cycles==1000:&lt;br /&gt;
            self.E=0&lt;br /&gt;
            self.E2=0&lt;br /&gt;
            self.M=0&lt;br /&gt;
            self.M2=0&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;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        # complete this function so that it calculates the correct values for the averages of E, E*E (E2), M, M*M (M2), and returns them&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.M / self.n_cycles&lt;br /&gt;
        if self.n_cycles&amp;gt;1000:&lt;br /&gt;
            avE = self.E / (self.n_cycles-1000)&lt;br /&gt;
            avE2 = self.E2 / (self.n_cycles-1000)&lt;br /&gt;
            avM = self.M / (self.n_cycles-1000)&lt;br /&gt;
            avM2 = self.M / (self.n_cycles-1000)&lt;br /&gt;
        return avE, avE2, avM, avM2, self.n_cycles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Range of temperatures ===&lt;br /&gt;
&lt;br /&gt;
The experiment was run for 8x8 lattice at a temperature range of 0.25 K-5.00 K, with a point every 0.05 K. The experiments using a different number of total steps were performed and the comparison is shown below in figures 5-7.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_4.png|Figure 5: Test result for 8x8 lattice with 11000 steps&lt;br /&gt;
Image:GE715_CMP_5.png|Figure 6: Test result for 8x8 lattice with 21000 steps&lt;br /&gt;
Image:GE715_CMP_6.png|Figure 7: Test result for 8x8 lattice with 101000 steps&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is a small, but noticeable improvement in the smoothness of the curves obtained for energy with using more steps, thus the highest number of steps (101000 steps) was used in the further experiments regardless of the higher need for computational power.&lt;br /&gt;
&lt;br /&gt;
== Lattice size effects ==&lt;br /&gt;
&lt;br /&gt;
With increasing lattice size the energy and magnetisation curves become more realistic, since the long range effects are better accounted for. 7 different lattice sizes were tested and energy and magnetisation for each are shown below in figure 8-14 and 15-21 respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_7.png|Figure 8: Energy result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_8.png|Figure 9: Energy result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_9.png|Figure 10: Energy result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_10.png|Figure 11: Energy result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_11.png|Figure 12: Energy result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_12.png|Figure 13: Energy result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_13.png|Figure 14: Energy result for 128x128 lattice&lt;br /&gt;
Image:GE715_CMP_14.png|Figure 15: Magnetisation result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_15.png|Figure 16: Magnetisation result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_16.png|Figure 17: Magnetisation result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_17.png|Figure 18: Magnetisation result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_18.png|Figure 19: Magnetisation result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_19.png|Figure 20: Magnetisation result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_20.png|Figure 21: Magnetisation result for 128x128 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Overall comparison of energy and magnetisation per spin in each lattice was made and can be seen in figures 22 and 23 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_21.png|Figure 22: Energy comparison&lt;br /&gt;
Image:GE715_CMP_22.png|Figure 23: Magnetisation comparison&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code used for producing figure 23 above is shown below. Other codes are analagous. Example for defining ls2 is also shown Others are similar..&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ls2=loadtxt(&amp;quot;2x2(100).dat&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
figsize(12,8)&lt;br /&gt;
plot(ls2[:,0],ls2[:,3]/4,color=&amp;quot;red&amp;quot;,label=&amp;quot;2x2&amp;quot;)&lt;br /&gt;
plot(ls4[:,0],ls4[:,3]/16,color=&amp;quot;orange&amp;quot;,label=&amp;quot;4x4&amp;quot;)&lt;br /&gt;
plot(ls8[:,0],ls8[:,3]/64,color=&amp;quot;yellow&amp;quot;,label=&amp;quot;8x8&amp;quot;)&lt;br /&gt;
plot(ls16[:,0],ls16[:,3]/256,color=&amp;quot;lime&amp;quot;,label=&amp;quot;16x16&amp;quot;)&lt;br /&gt;
plot(ls32[:,0],ls32[:,3]/1024,color=&amp;quot;blue&amp;quot;,label=&amp;quot;32x32&amp;quot;)&lt;br /&gt;
plot(ls64[:,0],ls64[:,3]/4096,color=&amp;quot;indigo&amp;quot;,label=&amp;quot;64x64&amp;quot;)&lt;br /&gt;
plot(ls128[:,0],ls128[:,3]/16384,color=&amp;quot;violet&amp;quot;,label=&amp;quot;128x128&amp;quot;)&lt;br /&gt;
title(&amp;quot;Magnetisation per spin&amp;quot;)&lt;br /&gt;
xlabel(&amp;quot;Temperature (K)&amp;quot;)&lt;br /&gt;
ylabel(&amp;quot;Magnetisation per spin&amp;quot;)&lt;br /&gt;
legend()&lt;br /&gt;
savefig(&amp;quot;Magnetisation.png&amp;quot;)&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Significant changes may be observed from 2x2 lattice up to 16x16 lattice, later the additional long range effects become less noticeable, but new effects are still present. It seems that most of the long range effects are captured by 16x16 lattice, but higher dimensions bring additional improvement.&lt;br /&gt;
&lt;br /&gt;
== Heat Capacity ==&lt;br /&gt;
&lt;br /&gt;
This formula holds true by definition: &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;
Variance of energy can be calculated  in the following way: &amp;lt;math&amp;gt;\mathrm{Var}[X] = \left\langle E^2\right\rangle - \left\langle E\right\rangle^2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Since expected energy can also be expressed as partition function: &amp;lt;math&amp;gt;\left\langle E\right\rangle = \frac{\partial}{\partial \beta}lnZ&amp;lt;/math&amp;gt;, variance may be expressed as &amp;lt;math&amp;gt;\mathrm{Var}[X] = \frac{\partial ^2}{\partial \beta ^2}lnZ = - \frac{\partial \left\langle E\right\rangle}{\partial \beta}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We can rearrange the equations given, because &amp;lt;math&amp;gt;T = \frac{1}{k_BT}&amp;lt;/math&amp;gt;, so that we obtain &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;
=== Heat capacity of the model ===&lt;br /&gt;
&lt;br /&gt;
Heat capacities of the models were calculated using the script given below (example for 2x2 lattice).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
figsize(6,4)&lt;br /&gt;
plot(ls2[:,0],(ls2[:,2]-ls2[:,1]**2)/ls2[:,0],color=&amp;quot;red&amp;quot;,label=&amp;quot;2x2&amp;quot;)&lt;br /&gt;
xlabel(&amp;quot;Temperature (K)&amp;quot;)&lt;br /&gt;
ylabel(&amp;quot;C&amp;quot;)&lt;br /&gt;
savefig(&amp;quot;C2.png&amp;quot;)&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphs of heat capacities are shown in the gallery below (figures 24-30). It can be seen that the model breaks down at low temperatures for bigger lattices, but it still gives a peak heat capacity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_23.png|Figure 24: C result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_24.png|Figure 25: C result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_25.png|Figure 26: C result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_26.png|Figure 27: C result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_27.png|Figure 28: C result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_28.png|Figure 29: C result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_29.png|Figure 30: C result for 128x128 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Comparison of heat capacity per spin is given in the figure 31 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_30.png|Figure 31: Heat capacity comparison&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Curie temperature ==&lt;br /&gt;
&lt;br /&gt;
Curie temperature can be deduced from where there is a peak in heat capacity per spin. The graphs of heat capacity vs temperature is shown below (figures 32 and 33) for two different lattice sizes, once using Python script and once using C++ data provided.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_31.png|Figure 32: 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_32.png|Figure 33: 64x64 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Polynomial fit ===&lt;br /&gt;
&lt;br /&gt;
The C++ data was also fitted with a polynomial, firstly over the whole range and afterwards just in the peak range. Fitting a polynomial proved to be hard as expected (since data is close to delta-like function), but it became more feasible when smaller range was used. Examples of both fits are shown in figures 34 and 35 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_33.png|Figure 34: Whole region fit&lt;br /&gt;
Image:GE715_CMP_34.png|Figure 35: Peak region fit&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Finding Curie temperature ===&lt;br /&gt;
&lt;br /&gt;
The last step was to find peak heat capacity for different lattice sizes in C++ data. The results are shown in the table below.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Lattice size&lt;br /&gt;
! Curie temperature&lt;br /&gt;
|-&lt;br /&gt;
|2x2&lt;br /&gt;
|2.48 K&lt;br /&gt;
|-&lt;br /&gt;
|4x4&lt;br /&gt;
|2.40 K&lt;br /&gt;
|-&lt;br /&gt;
|8x8&lt;br /&gt;
|2.32 K&lt;br /&gt;
|-&lt;br /&gt;
|16x16&lt;br /&gt;
|2.25 K&lt;br /&gt;
|-&lt;br /&gt;
|32x32&lt;br /&gt;
|2.30 K&lt;br /&gt;
|-&lt;br /&gt;
|64x64&lt;br /&gt;
|2.25 K&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The curie temperature for infinite lattice is known to be calculated from that of a finite lattice using equation &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 a constant. This was used to draw a graph shown in figure 36 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_35.png|Figure 36: Curie temperature for infinite lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Curie temperature for infinite lattice was found to be &amp;lt;math&amp;gt;T=2.26 K&amp;lt;/math&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:CMPY3_GE715&amp;diff=645836</id>
		<title>Rep:CMPY3 GE715</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:CMPY3_GE715&amp;diff=645836"/>
		<updated>2017-11-22T10:44:05Z</updated>

		<summary type="html">&lt;p&gt;Ge715: /* Finding Curie temperature */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Ising Model ==&lt;br /&gt;
&lt;br /&gt;
The interaction energy in Ising model is defined as &amp;lt;math&amp;gt;E=- \frac{1}{2} J \sum_i^N \sum_{j\  \in\  \mathrm{neighbours}\left(i\right)} s_i s_j&amp;lt;/math&amp;gt;. The energy will be the lowest possible when all the spins point in the same direction. In that case &amp;lt;math&amp;gt;s_i s_j=1&amp;lt;/math&amp;gt; for all possible &amp;lt;math&amp;gt;i,j&amp;lt;/math&amp;gt; pairs. The number of pairs for each &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; depends on the number of dimensions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;P=2D&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;P&amp;lt;/math&amp;gt; represents the number of pairs and &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; the number of dimensions. The lowest possible energy will thus be &amp;lt;math&amp;gt;E=- \frac{1}{2} JNP&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; represents the total number of spins. Thus the lowest possible energy may also be simplified as &amp;lt;math&amp;gt;E=-DNJ&amp;lt;/math&amp;gt;, as requested.&lt;br /&gt;
&lt;br /&gt;
The multiplicity of this particular state is 2 (all spins up or all spins down), thus &amp;lt;math&amp;gt;\Omega=2&amp;lt;/math&amp;gt;, entropy of the system is &amp;lt;math&amp;gt;S=k_b ln \Omega=9.6*10^{-24} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Flip of a spin ===&lt;br /&gt;
&lt;br /&gt;
If one of the spins flips, the energy increases. In the given case (&amp;lt;math&amp;gt;D=3, N=1000&amp;lt;/math&amp;gt;), the &amp;lt;math&amp;gt;E_i=-3000 J&amp;lt;/math&amp;gt;, while the flip of one spin increases the energy by &amp;lt;math&amp;gt;12 J&amp;lt;/math&amp;gt; (6 pairs, &amp;lt;math&amp;gt;2 J&amp;lt;/math&amp;gt; per pair), so that &amp;lt;math&amp;gt;E_f=-2988 J&amp;lt;/math&amp;gt;. Note that &amp;lt;math&amp;gt;J&amp;lt;/math&amp;gt; does not represent joules in this case.&lt;br /&gt;
&lt;br /&gt;
Multiplicity has increased to &amp;lt;math&amp;gt;\Omega=2000&amp;lt;/math&amp;gt;, thus &amp;lt;math&amp;gt;S=1.05*10^{-22} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\Delta S=1.04*10^{-22} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Magnetisation in the sketch ===&lt;br /&gt;
&lt;br /&gt;
The 1D system shown has the magnetisation of &amp;lt;math&amp;gt;M=1&amp;lt;/math&amp;gt;. This is also true for the 2D system shown. For the model system with &amp;lt;math&amp;gt;N=1000, D=3&amp;lt;/math&amp;gt; the expected magnetisation at absolute zero would be &amp;lt;math&amp;gt;M=\pm 1000&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Code for magnetisation and energy ==&lt;br /&gt;
&lt;br /&gt;
Python code was written to calculate the energy and magnetisation of a configuration and tested a few times. The test results are shown in figure 1 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=800 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_0.png|Figure 1: Test results&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Accelerating the code ==&lt;br /&gt;
&lt;br /&gt;
The code at the beginning was written using a loop for magnetisation and a double loop for energy. 2000 Monte Carlo steps needed was &amp;lt;math&amp;gt;M=9.32 s \pm 0.10 s&amp;lt;/math&amp;gt;. After optimizing magnetisation only this has dropped to &amp;lt;math&amp;gt;M=8.88 s \pm 0.04 s&amp;lt;/math&amp;gt;, while after optimizing both magnetisation and energy with using Numpy&#039;s sum, roll and multiply functions, the time was further reduced to &amp;lt;math&amp;gt;M=0.0796 s \pm 0.018 s&amp;lt;/math&amp;gt;. It was later realised that only one roll in each direction is needed to produce the correct energy, so the final time for 2000 steps was successfully reduced to &amp;lt;math&amp;gt;M=0.418 s \pm 0.005 s&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The whole of the code used is given below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
&lt;br /&gt;
class IsingLattice:&lt;br /&gt;
&lt;br /&gt;
    E = 0.0&lt;br /&gt;
    E2 = 0.0&lt;br /&gt;
    M = 0.0&lt;br /&gt;
    M2 = 0.0&lt;br /&gt;
    energy_x=0&lt;br /&gt;
    energy2_x=0&lt;br /&gt;
    magnetisation_x=0&lt;br /&gt;
    magnetisation2_x=0&lt;br /&gt;
&lt;br /&gt;
    n_cycles = 0&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, n_rows, n_cols):&lt;br /&gt;
        self.n_rows = n_rows&lt;br /&gt;
        self.n_cols = n_cols&lt;br /&gt;
        self.lattice = np.random.choice([-1,1], size=(n_rows, n_cols))&lt;br /&gt;
&lt;br /&gt;
    def energy(self):&lt;br /&gt;
        a=np.roll(self.lattice,1,axis=0)&lt;br /&gt;
        a1=np.multiply(a,self.lattice)&lt;br /&gt;
        x1=np.sum(a1)&lt;br /&gt;
        c=np.roll(self.lattice,1,axis=1)&lt;br /&gt;
        c1=np.multiply(c,self.lattice)&lt;br /&gt;
        x2=np.sum(c1)&lt;br /&gt;
        x=x1+x2&lt;br /&gt;
        energy = -x&lt;br /&gt;
        return 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;
        return np.sum(self.lattice)&lt;br /&gt;
&lt;br /&gt;
    def energy_flip(self,random_i,random_j):&lt;br /&gt;
        &amp;quot;Return the total energy of the current lattice after flip configuration.&amp;quot;&lt;br /&gt;
        self.lattice[random_i][random_j]=-self.lattice[random_i][random_j]&lt;br /&gt;
        a=np.roll(self.lattice,1,axis=0)&lt;br /&gt;
        a1=np.multiply(a,self.lattice)&lt;br /&gt;
        x1=np.sum(a1)&lt;br /&gt;
        c=np.roll(self.lattice,1,axis=1)&lt;br /&gt;
        c1=np.multiply(c,self.lattice)&lt;br /&gt;
        x2=np.sum(c1)&lt;br /&gt;
        x=x1+x2&lt;br /&gt;
        energy = -x&lt;br /&gt;
        return energy&lt;br /&gt;
&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        # complete this function so that it performs a single Monte Carlo step&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        #the following two lines will select the coordinates of the random spin for you&lt;br /&gt;
        random_i = np.random.choice(range(0, self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(0, self.n_cols))&lt;br /&gt;
        #the following line will choose a random number in the range [0,1) for you&lt;br /&gt;
        random_number = np.random.random()&lt;br /&gt;
        self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
        energy2 = self.energy()&lt;br /&gt;
        dE = energy2 - energy&lt;br /&gt;
&lt;br /&gt;
        if energy2&amp;lt;energy or random_number&amp;lt;=np.e**(-(energy2-energy)/T):&lt;br /&gt;
            yyy=True&lt;br /&gt;
        else:&lt;br /&gt;
            self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
			&lt;br /&gt;
        self.n_cycles+=1&lt;br /&gt;
&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;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        # complete this function so that it calculates the correct values for the averages of E, E*E (E2), M, M*M (M2), and returns them&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.M / self.n_cycles&lt;br /&gt;
        return avE, avE2, avM, avM2, self.n_cycles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Temperature effects ==&lt;br /&gt;
&lt;br /&gt;
=== Correction of averaging code ===&lt;br /&gt;
&lt;br /&gt;
A few experiments were performed at different temperatures using ILfinalframe.py, to see how long it usually takes for the system to equilibrate. At low temperatures it usually happened before 1000 steps were performed, thus 1000 Monte Carlo steps was decided to be appropriate cut-off period for calculation of average values of magnetisation and energy. The figures 2-4, showing the experiments performed are shown in the gallery below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_1.png|Figure 2: Test result @ 0.5 K&lt;br /&gt;
Image:GE715_CMP_2.png|Figure 3: Test result @ 1 K&lt;br /&gt;
Image:GE715_CMP_3.png|Figure 4: Test result @ 1.5 K&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The definitions of two class functions were changed as shown below to accommodate this change.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        # complete this function so that it performs a single Monte Carlo step&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        #the following two lines will select the coordinates of the random spin for you&lt;br /&gt;
        random_i = np.random.choice(range(0, self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(0, self.n_cols))&lt;br /&gt;
        #the following line will choose a random number in the range [0,1) for you&lt;br /&gt;
        random_number = np.random.random()&lt;br /&gt;
        self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
        energy2 = self.energy()&lt;br /&gt;
        dE = energy2 - energy&lt;br /&gt;
&lt;br /&gt;
        if energy2&amp;lt;energy or random_number&amp;lt;=np.e**(-(energy2-energy)/T):&lt;br /&gt;
            yyy=True&lt;br /&gt;
        else:&lt;br /&gt;
            self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
			&lt;br /&gt;
        self.n_cycles+=1&lt;br /&gt;
        if self.n_cycles==1000:&lt;br /&gt;
            self.E=0&lt;br /&gt;
            self.E2=0&lt;br /&gt;
            self.M=0&lt;br /&gt;
            self.M2=0&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;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        # complete this function so that it calculates the correct values for the averages of E, E*E (E2), M, M*M (M2), and returns them&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.M / self.n_cycles&lt;br /&gt;
        if self.n_cycles&amp;gt;1000:&lt;br /&gt;
            avE = self.E / (self.n_cycles-1000)&lt;br /&gt;
            avE2 = self.E2 / (self.n_cycles-1000)&lt;br /&gt;
            avM = self.M / (self.n_cycles-1000)&lt;br /&gt;
            avM2 = self.M / (self.n_cycles-1000)&lt;br /&gt;
        return avE, avE2, avM, avM2, self.n_cycles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Range of temperatures ===&lt;br /&gt;
&lt;br /&gt;
The experiment was run for 8x8 lattice at a temperature range of 0.25 K-5.00 K, with a point every 0.05 K. The experiments using a different number of total steps were performed and the comparison is shown below in figures 5-7.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_4.png|Figure 5: Test result for 8x8 lattice with 11000 steps&lt;br /&gt;
Image:GE715_CMP_5.png|Figure 6: Test result for 8x8 lattice with 21000 steps&lt;br /&gt;
Image:GE715_CMP_6.png|Figure 7: Test result for 8x8 lattice with 101000 steps&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is a small, but noticeable improvement in the smoothness of the curves obtained for energy with using more steps, thus the highest number of steps (101000 steps) was used in the further experiments regardless of the higher need for computational power.&lt;br /&gt;
&lt;br /&gt;
== Lattice size effects ==&lt;br /&gt;
&lt;br /&gt;
With increasing lattice size the energy and magnetisation curves become more realistic, since the long range effects are better accounted for. 7 different lattice sizes were tested and energy and magnetisation for each are shown below in figure 8-14 and 15-21 respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_7.png|Figure 8: Energy result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_8.png|Figure 9: Energy result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_9.png|Figure 10: Energy result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_10.png|Figure 11: Energy result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_11.png|Figure 12: Energy result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_12.png|Figure 13: Energy result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_13.png|Figure 14: Energy result for 128x128 lattice&lt;br /&gt;
Image:GE715_CMP_14.png|Figure 15: Magnetisation result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_15.png|Figure 16: Magnetisation result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_16.png|Figure 17: Magnetisation result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_17.png|Figure 18: Magnetisation result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_18.png|Figure 19: Magnetisation result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_19.png|Figure 20: Magnetisation result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_20.png|Figure 21: Magnetisation result for 128x128 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Overall comparison of energy and magnetisation per spin in each lattice was made and can be seen in figures 22 and 23 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_21.png|Figure 22: Energy comparison&lt;br /&gt;
Image:GE715_CMP_22.png|Figure 23: Magnetisation comparison&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code used for producing figure 23 above is shown below. Other codes are analagous. Example for defining ls2 is also shown Others are similar..&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ls2=loadtxt(&amp;quot;2x2(100).dat&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
figsize(12,8)&lt;br /&gt;
plot(ls2[:,0],ls2[:,3]/4,color=&amp;quot;red&amp;quot;,label=&amp;quot;2x2&amp;quot;)&lt;br /&gt;
plot(ls4[:,0],ls4[:,3]/16,color=&amp;quot;orange&amp;quot;,label=&amp;quot;4x4&amp;quot;)&lt;br /&gt;
plot(ls8[:,0],ls8[:,3]/64,color=&amp;quot;yellow&amp;quot;,label=&amp;quot;8x8&amp;quot;)&lt;br /&gt;
plot(ls16[:,0],ls16[:,3]/256,color=&amp;quot;lime&amp;quot;,label=&amp;quot;16x16&amp;quot;)&lt;br /&gt;
plot(ls32[:,0],ls32[:,3]/1024,color=&amp;quot;blue&amp;quot;,label=&amp;quot;32x32&amp;quot;)&lt;br /&gt;
plot(ls64[:,0],ls64[:,3]/4096,color=&amp;quot;indigo&amp;quot;,label=&amp;quot;64x64&amp;quot;)&lt;br /&gt;
plot(ls128[:,0],ls128[:,3]/16384,color=&amp;quot;violet&amp;quot;,label=&amp;quot;128x128&amp;quot;)&lt;br /&gt;
title(&amp;quot;Magnetisation per spin&amp;quot;)&lt;br /&gt;
xlabel(&amp;quot;Temperature (K)&amp;quot;)&lt;br /&gt;
ylabel(&amp;quot;Magnetisation per spin&amp;quot;)&lt;br /&gt;
legend()&lt;br /&gt;
savefig(&amp;quot;Magnetisation.png&amp;quot;)&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Significant changes may be observed from 2x2 lattice up to 16x16 lattice, later the additional long range effects become less noticeable, but new effects are still present. It seems that most of the long range effects are captured by 16x16 lattice, but higher dimensions bring additional improvement.&lt;br /&gt;
&lt;br /&gt;
== Heat Capacity ==&lt;br /&gt;
&lt;br /&gt;
This formula holds true by definition: &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;
Variance of energy can be calculated  in the following way: &amp;lt;math&amp;gt;\mathrm{Var}[X] = \left\langle E^2\right\rangle - \left\langle E\right\rangle^2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Since expected energy can also be expressed as partition function: &amp;lt;math&amp;gt;\left\langle E\right\rangle = \frac{\partial}{\partial \beta}lnZ&amp;lt;/math&amp;gt;, variance may be expressed as &amp;lt;math&amp;gt;\mathrm{Var}[X] = \frac{\partial ^2}{\partial \beta ^2}lnZ = - \frac{\partial \left\langle E\right\rangle}{\partial \beta}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We can rearrange the equations given, because &amp;lt;math&amp;gt;T = \frac{1}{k_BT}&amp;lt;/math&amp;gt;, so that we obtain &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;
=== Heat capacity of the model ===&lt;br /&gt;
&lt;br /&gt;
Heat capacities of the models were calculated using the script given below (example for 2x2 lattice).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
figsize(6,4)&lt;br /&gt;
plot(ls2[:,0],(ls2[:,2]-ls2[:,1]**2)/ls2[:,0],color=&amp;quot;red&amp;quot;,label=&amp;quot;2x2&amp;quot;)&lt;br /&gt;
xlabel(&amp;quot;Temperature (K)&amp;quot;)&lt;br /&gt;
ylabel(&amp;quot;C&amp;quot;)&lt;br /&gt;
savefig(&amp;quot;C2.png&amp;quot;)&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphs of heat capacities are shown in the gallery below (figures 24-30). It can be seen that the model breaks down at low temperatures for bigger lattices, but it still gives a peak heat capacity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_23.png|Figure 24: C result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_24.png|Figure 25: C result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_25.png|Figure 26: C result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_26.png|Figure 27: C result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_27.png|Figure 28: C result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_28.png|Figure 29: C result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_29.png|Figure 30: C result for 128x128 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Comparison of heat capacity per spin is given in the figure 31 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_30.png|Figure 31: Heat capacity comparison&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Curie temperature ==&lt;br /&gt;
&lt;br /&gt;
Curie temperature can be deduced from where there is a peak in heat capacity per spin. The graphs of heat capacity vs temperature is shown below (figures 32 and 33) for two different lattice sizes, once using Python script and once using C++ data provided.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_31.png|Figure 32: 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_32.png|Figure 33: 64x64 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Polynomial fit ===&lt;br /&gt;
&lt;br /&gt;
The C++ data was also fitted with a polynomial, firstly over the whole range and afterwards just in the peak range. Fitting a polynomial proved to be hard as expected (since data is close to delta-like function), but it became more feasible when smaller range was used. Examples of both fits are shown in figures 34 and 35 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_33.png|Figure 34: Whole region fit&lt;br /&gt;
Image:GE715_CMP_34.png|Figure 35: Peak region fit&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Finding Curie temperature ===&lt;br /&gt;
&lt;br /&gt;
The last step was to find peak heat capacity for different lattice sizes in C++ data. The results are shown in the table below.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Lattice size&lt;br /&gt;
! Curie temperature&lt;br /&gt;
|-&lt;br /&gt;
|2x2&lt;br /&gt;
|2.48 K&lt;br /&gt;
|-&lt;br /&gt;
|4x4&lt;br /&gt;
|2.40 K&lt;br /&gt;
|-&lt;br /&gt;
|8x8&lt;br /&gt;
|2.32 K&lt;br /&gt;
|-&lt;br /&gt;
|16x16&lt;br /&gt;
|2.25 K&lt;br /&gt;
|-&lt;br /&gt;
|32x32&lt;br /&gt;
|2.30 K&lt;br /&gt;
|-&lt;br /&gt;
|64x64&lt;br /&gt;
|2.25 K&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The curie temperature for infinite lattice is known to be calculated from that of a finite lattice using equation &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 a constant. This was used to draw a graph shown in figure X below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Curie temperature for infinite lattice was found to be &amp;lt;math&amp;gt;T=2.26 K&amp;lt;/math&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:CMPY3_GE715&amp;diff=644400</id>
		<title>Rep:CMPY3 GE715</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:CMPY3_GE715&amp;diff=644400"/>
		<updated>2017-11-21T19:13:13Z</updated>

		<summary type="html">&lt;p&gt;Ge715: /* Finding Curie temperature */  Fail&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Ising Model ==&lt;br /&gt;
&lt;br /&gt;
The interaction energy in Ising model is defined as &amp;lt;math&amp;gt;E=- \frac{1}{2} J \sum_i^N \sum_{j\  \in\  \mathrm{neighbours}\left(i\right)} s_i s_j&amp;lt;/math&amp;gt;. The energy will be the lowest possible when all the spins point in the same direction. In that case &amp;lt;math&amp;gt;s_i s_j=1&amp;lt;/math&amp;gt; for all possible &amp;lt;math&amp;gt;i,j&amp;lt;/math&amp;gt; pairs. The number of pairs for each &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; depends on the number of dimensions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;P=2D&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;P&amp;lt;/math&amp;gt; represents the number of pairs and &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; the number of dimensions. The lowest possible energy will thus be &amp;lt;math&amp;gt;E=- \frac{1}{2} JNP&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; represents the total number of spins. Thus the lowest possible energy may also be simplified as &amp;lt;math&amp;gt;E=-DNJ&amp;lt;/math&amp;gt;, as requested.&lt;br /&gt;
&lt;br /&gt;
The multiplicity of this particular state is 2 (all spins up or all spins down), thus &amp;lt;math&amp;gt;\Omega=2&amp;lt;/math&amp;gt;, entropy of the system is &amp;lt;math&amp;gt;S=k_b ln \Omega=9.6*10^{-24} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Flip of a spin ===&lt;br /&gt;
&lt;br /&gt;
If one of the spins flips, the energy increases. In the given case (&amp;lt;math&amp;gt;D=3, N=1000&amp;lt;/math&amp;gt;), the &amp;lt;math&amp;gt;E_i=-3000 J&amp;lt;/math&amp;gt;, while the flip of one spin increases the energy by &amp;lt;math&amp;gt;12 J&amp;lt;/math&amp;gt; (6 pairs, &amp;lt;math&amp;gt;2 J&amp;lt;/math&amp;gt; per pair), so that &amp;lt;math&amp;gt;E_f=-2988 J&amp;lt;/math&amp;gt;. Note that &amp;lt;math&amp;gt;J&amp;lt;/math&amp;gt; does not represent joules in this case.&lt;br /&gt;
&lt;br /&gt;
Multiplicity has increased to &amp;lt;math&amp;gt;\Omega=2000&amp;lt;/math&amp;gt;, thus &amp;lt;math&amp;gt;S=1.05*10^{-22} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\Delta S=1.04*10^{-22} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Magnetisation in the sketch ===&lt;br /&gt;
&lt;br /&gt;
The 1D system shown has the magnetisation of &amp;lt;math&amp;gt;M=1&amp;lt;/math&amp;gt;. This is also true for the 2D system shown. For the model system with &amp;lt;math&amp;gt;N=1000, D=3&amp;lt;/math&amp;gt; the expected magnetisation at absolute zero would be &amp;lt;math&amp;gt;M=\pm 1000&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Code for magnetisation and energy ==&lt;br /&gt;
&lt;br /&gt;
Python code was written to calculate the energy and magnetisation of a configuration and tested a few times. The test results are shown in figure 1 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=800 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_0.png|Figure 1: Test results&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Accelerating the code ==&lt;br /&gt;
&lt;br /&gt;
The code at the beginning was written using a loop for magnetisation and a double loop for energy. 2000 Monte Carlo steps needed was &amp;lt;math&amp;gt;M=9.32 s \pm 0.10 s&amp;lt;/math&amp;gt;. After optimizing magnetisation only this has dropped to &amp;lt;math&amp;gt;M=8.88 s \pm 0.04 s&amp;lt;/math&amp;gt;, while after optimizing both magnetisation and energy with using Numpy&#039;s sum, roll and multiply functions, the time was further reduced to &amp;lt;math&amp;gt;M=0.0796 s \pm 0.018 s&amp;lt;/math&amp;gt;. It was later realised that only one roll in each direction is needed to produce the correct energy, so the final time for 2000 steps was successfully reduced to &amp;lt;math&amp;gt;M=0.418 s \pm 0.005 s&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The whole of the code used is given below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
&lt;br /&gt;
class IsingLattice:&lt;br /&gt;
&lt;br /&gt;
    E = 0.0&lt;br /&gt;
    E2 = 0.0&lt;br /&gt;
    M = 0.0&lt;br /&gt;
    M2 = 0.0&lt;br /&gt;
    energy_x=0&lt;br /&gt;
    energy2_x=0&lt;br /&gt;
    magnetisation_x=0&lt;br /&gt;
    magnetisation2_x=0&lt;br /&gt;
&lt;br /&gt;
    n_cycles = 0&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, n_rows, n_cols):&lt;br /&gt;
        self.n_rows = n_rows&lt;br /&gt;
        self.n_cols = n_cols&lt;br /&gt;
        self.lattice = np.random.choice([-1,1], size=(n_rows, n_cols))&lt;br /&gt;
&lt;br /&gt;
    def energy(self):&lt;br /&gt;
        a=np.roll(self.lattice,1,axis=0)&lt;br /&gt;
        a1=np.multiply(a,self.lattice)&lt;br /&gt;
        x1=np.sum(a1)&lt;br /&gt;
        c=np.roll(self.lattice,1,axis=1)&lt;br /&gt;
        c1=np.multiply(c,self.lattice)&lt;br /&gt;
        x2=np.sum(c1)&lt;br /&gt;
        x=x1+x2&lt;br /&gt;
        energy = -x&lt;br /&gt;
        return 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;
        return np.sum(self.lattice)&lt;br /&gt;
&lt;br /&gt;
    def energy_flip(self,random_i,random_j):&lt;br /&gt;
        &amp;quot;Return the total energy of the current lattice after flip configuration.&amp;quot;&lt;br /&gt;
        self.lattice[random_i][random_j]=-self.lattice[random_i][random_j]&lt;br /&gt;
        a=np.roll(self.lattice,1,axis=0)&lt;br /&gt;
        a1=np.multiply(a,self.lattice)&lt;br /&gt;
        x1=np.sum(a1)&lt;br /&gt;
        c=np.roll(self.lattice,1,axis=1)&lt;br /&gt;
        c1=np.multiply(c,self.lattice)&lt;br /&gt;
        x2=np.sum(c1)&lt;br /&gt;
        x=x1+x2&lt;br /&gt;
        energy = -x&lt;br /&gt;
        return energy&lt;br /&gt;
&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        # complete this function so that it performs a single Monte Carlo step&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        #the following two lines will select the coordinates of the random spin for you&lt;br /&gt;
        random_i = np.random.choice(range(0, self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(0, self.n_cols))&lt;br /&gt;
        #the following line will choose a random number in the range [0,1) for you&lt;br /&gt;
        random_number = np.random.random()&lt;br /&gt;
        self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
        energy2 = self.energy()&lt;br /&gt;
        dE = energy2 - energy&lt;br /&gt;
&lt;br /&gt;
        if energy2&amp;lt;energy or random_number&amp;lt;=np.e**(-(energy2-energy)/T):&lt;br /&gt;
            yyy=True&lt;br /&gt;
        else:&lt;br /&gt;
            self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
			&lt;br /&gt;
        self.n_cycles+=1&lt;br /&gt;
&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;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        # complete this function so that it calculates the correct values for the averages of E, E*E (E2), M, M*M (M2), and returns them&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.M / self.n_cycles&lt;br /&gt;
        return avE, avE2, avM, avM2, self.n_cycles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Temperature effects ==&lt;br /&gt;
&lt;br /&gt;
=== Correction of averaging code ===&lt;br /&gt;
&lt;br /&gt;
A few experiments were performed at different temperatures using ILfinalframe.py, to see how long it usually takes for the system to equilibrate. At low temperatures it usually happened before 1000 steps were performed, thus 1000 Monte Carlo steps was decided to be appropriate cut-off period for calculation of average values of magnetisation and energy. The figures 2-4, showing the experiments performed are shown in the gallery below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_1.png|Figure 2: Test result @ 0.5 K&lt;br /&gt;
Image:GE715_CMP_2.png|Figure 3: Test result @ 1 K&lt;br /&gt;
Image:GE715_CMP_3.png|Figure 4: Test result @ 1.5 K&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The definitions of two class functions were changed as shown below to accommodate this change.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        # complete this function so that it performs a single Monte Carlo step&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        #the following two lines will select the coordinates of the random spin for you&lt;br /&gt;
        random_i = np.random.choice(range(0, self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(0, self.n_cols))&lt;br /&gt;
        #the following line will choose a random number in the range [0,1) for you&lt;br /&gt;
        random_number = np.random.random()&lt;br /&gt;
        self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
        energy2 = self.energy()&lt;br /&gt;
        dE = energy2 - energy&lt;br /&gt;
&lt;br /&gt;
        if energy2&amp;lt;energy or random_number&amp;lt;=np.e**(-(energy2-energy)/T):&lt;br /&gt;
            yyy=True&lt;br /&gt;
        else:&lt;br /&gt;
            self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
			&lt;br /&gt;
        self.n_cycles+=1&lt;br /&gt;
        if self.n_cycles==1000:&lt;br /&gt;
            self.E=0&lt;br /&gt;
            self.E2=0&lt;br /&gt;
            self.M=0&lt;br /&gt;
            self.M2=0&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;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        # complete this function so that it calculates the correct values for the averages of E, E*E (E2), M, M*M (M2), and returns them&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.M / self.n_cycles&lt;br /&gt;
        if self.n_cycles&amp;gt;1000:&lt;br /&gt;
            avE = self.E / (self.n_cycles-1000)&lt;br /&gt;
            avE2 = self.E2 / (self.n_cycles-1000)&lt;br /&gt;
            avM = self.M / (self.n_cycles-1000)&lt;br /&gt;
            avM2 = self.M / (self.n_cycles-1000)&lt;br /&gt;
        return avE, avE2, avM, avM2, self.n_cycles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Range of temperatures ===&lt;br /&gt;
&lt;br /&gt;
The experiment was run for 8x8 lattice at a temperature range of 0.25 K-5.00 K, with a point every 0.05 K. The experiments using a different number of total steps were performed and the comparison is shown below in figures 5-7.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_4.png|Figure 5: Test result for 8x8 lattice with 11000 steps&lt;br /&gt;
Image:GE715_CMP_5.png|Figure 6: Test result for 8x8 lattice with 21000 steps&lt;br /&gt;
Image:GE715_CMP_6.png|Figure 7: Test result for 8x8 lattice with 101000 steps&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is a small, but noticeable improvement in the smoothness of the curves obtained for energy with using more steps, thus the highest number of steps (101000 steps) was used in the further experiments regardless of the higher need for computational power.&lt;br /&gt;
&lt;br /&gt;
== Lattice size effects ==&lt;br /&gt;
&lt;br /&gt;
With increasing lattice size the energy and magnetisation curves become more realistic, since the long range effects are better accounted for. 7 different lattice sizes were tested and energy and magnetisation for each are shown below in figure 8-14 and 15-21 respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_7.png|Figure 8: Energy result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_8.png|Figure 9: Energy result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_9.png|Figure 10: Energy result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_10.png|Figure 11: Energy result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_11.png|Figure 12: Energy result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_12.png|Figure 13: Energy result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_13.png|Figure 14: Energy result for 128x128 lattice&lt;br /&gt;
Image:GE715_CMP_14.png|Figure 15: Magnetisation result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_15.png|Figure 16: Magnetisation result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_16.png|Figure 17: Magnetisation result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_17.png|Figure 18: Magnetisation result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_18.png|Figure 19: Magnetisation result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_19.png|Figure 20: Magnetisation result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_20.png|Figure 21: Magnetisation result for 128x128 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Overall comparison of energy and magnetisation per spin in each lattice was made and can be seen in figures 22 and 23 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_21.png|Figure 22: Energy comparison&lt;br /&gt;
Image:GE715_CMP_22.png|Figure 23: Magnetisation comparison&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code used for producing figure 23 above is shown below. Other codes are analagous. Example for defining ls2 is also shown Others are similar..&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ls2=loadtxt(&amp;quot;2x2(100).dat&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
figsize(12,8)&lt;br /&gt;
plot(ls2[:,0],ls2[:,3]/4,color=&amp;quot;red&amp;quot;,label=&amp;quot;2x2&amp;quot;)&lt;br /&gt;
plot(ls4[:,0],ls4[:,3]/16,color=&amp;quot;orange&amp;quot;,label=&amp;quot;4x4&amp;quot;)&lt;br /&gt;
plot(ls8[:,0],ls8[:,3]/64,color=&amp;quot;yellow&amp;quot;,label=&amp;quot;8x8&amp;quot;)&lt;br /&gt;
plot(ls16[:,0],ls16[:,3]/256,color=&amp;quot;lime&amp;quot;,label=&amp;quot;16x16&amp;quot;)&lt;br /&gt;
plot(ls32[:,0],ls32[:,3]/1024,color=&amp;quot;blue&amp;quot;,label=&amp;quot;32x32&amp;quot;)&lt;br /&gt;
plot(ls64[:,0],ls64[:,3]/4096,color=&amp;quot;indigo&amp;quot;,label=&amp;quot;64x64&amp;quot;)&lt;br /&gt;
plot(ls128[:,0],ls128[:,3]/16384,color=&amp;quot;violet&amp;quot;,label=&amp;quot;128x128&amp;quot;)&lt;br /&gt;
title(&amp;quot;Magnetisation per spin&amp;quot;)&lt;br /&gt;
xlabel(&amp;quot;Temperature (K)&amp;quot;)&lt;br /&gt;
ylabel(&amp;quot;Magnetisation per spin&amp;quot;)&lt;br /&gt;
legend()&lt;br /&gt;
savefig(&amp;quot;Magnetisation.png&amp;quot;)&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Significant changes may be observed from 2x2 lattice up to 16x16 lattice, later the additional long range effects become less noticeable, but new effects are still present. It seems that most of the long range effects are captured by 16x16 lattice, but higher dimensions bring additional improvement.&lt;br /&gt;
&lt;br /&gt;
== Heat Capacity ==&lt;br /&gt;
&lt;br /&gt;
This formula holds true by definition: &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;
Variance of energy can be calculated  in the following way: &amp;lt;math&amp;gt;\mathrm{Var}[X] = \left\langle E^2\right\rangle - \left\langle E\right\rangle^2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Since expected energy can also be expressed as partition function: &amp;lt;math&amp;gt;\left\langle E\right\rangle = \frac{\partial}{\partial \beta}lnZ&amp;lt;/math&amp;gt;, variance may be expressed as &amp;lt;math&amp;gt;\mathrm{Var}[X] = \frac{\partial ^2}{\partial \beta ^2}lnZ = - \frac{\partial \left\langle E\right\rangle}{\partial \beta}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We can rearrange the equations given, because &amp;lt;math&amp;gt;T = \frac{1}{k_BT}&amp;lt;/math&amp;gt;, so that we obtain &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;
=== Heat capacity of the model ===&lt;br /&gt;
&lt;br /&gt;
Heat capacities of the models were calculated using the script given below (example for 2x2 lattice).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
figsize(6,4)&lt;br /&gt;
plot(ls2[:,0],(ls2[:,2]-ls2[:,1]**2)/ls2[:,0],color=&amp;quot;red&amp;quot;,label=&amp;quot;2x2&amp;quot;)&lt;br /&gt;
xlabel(&amp;quot;Temperature (K)&amp;quot;)&lt;br /&gt;
ylabel(&amp;quot;C&amp;quot;)&lt;br /&gt;
savefig(&amp;quot;C2.png&amp;quot;)&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphs of heat capacities are shown in the gallery below (figures 24-30). It can be seen that the model breaks down at low temperatures for bigger lattices, but it still gives a peak heat capacity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_23.png|Figure 24: C result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_24.png|Figure 25: C result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_25.png|Figure 26: C result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_26.png|Figure 27: C result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_27.png|Figure 28: C result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_28.png|Figure 29: C result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_29.png|Figure 30: C result for 128x128 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Comparison of heat capacity per spin is given in the figure 31 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_30.png|Figure 31: Heat capacity comparison&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Curie temperature ==&lt;br /&gt;
&lt;br /&gt;
Curie temperature can be deduced from where there is a peak in heat capacity per spin. The graphs of heat capacity vs temperature is shown below (figures 32 and 33) for two different lattice sizes, once using Python script and once using C++ data provided.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_31.png|Figure 32: 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_32.png|Figure 33: 64x64 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Polynomial fit ===&lt;br /&gt;
&lt;br /&gt;
The C++ data was also fitted with a polynomial, firstly over the whole range and afterwards just in the peak range. Fitting a polynomial proved to be hard as expected (since data is close to delta-like function), but it became more feasible when smaller range was used. Examples of both fits are shown in figures 34 and 35 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_33.png|Figure 34: Whole region fit&lt;br /&gt;
Image:GE715_CMP_34.png|Figure 35: Peak region fit&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Finding Curie temperature ===&lt;br /&gt;
&lt;br /&gt;
The last step was to find peak heat capacity for different lattice sizes in C++ data. The results are shown in the table below.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Lattice size&lt;br /&gt;
! Curie temperature&lt;br /&gt;
|-&lt;br /&gt;
|2x2&lt;br /&gt;
|2.48 K&lt;br /&gt;
|-&lt;br /&gt;
|4x4&lt;br /&gt;
|2.40 K&lt;br /&gt;
|-&lt;br /&gt;
|8x8&lt;br /&gt;
|2.32 K&lt;br /&gt;
|-&lt;br /&gt;
|16x16&lt;br /&gt;
|2.25 K&lt;br /&gt;
|-&lt;br /&gt;
|32x32&lt;br /&gt;
|2.30 K&lt;br /&gt;
|-&lt;br /&gt;
|64x64&lt;br /&gt;
|2.25 K&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:CMPY3_GE715&amp;diff=644387</id>
		<title>Rep:CMPY3 GE715</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:CMPY3_GE715&amp;diff=644387"/>
		<updated>2017-11-21T19:10:03Z</updated>

		<summary type="html">&lt;p&gt;Ge715: /* Finding Curie temperature */ Formatting mistake&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Ising Model ==&lt;br /&gt;
&lt;br /&gt;
The interaction energy in Ising model is defined as &amp;lt;math&amp;gt;E=- \frac{1}{2} J \sum_i^N \sum_{j\  \in\  \mathrm{neighbours}\left(i\right)} s_i s_j&amp;lt;/math&amp;gt;. The energy will be the lowest possible when all the spins point in the same direction. In that case &amp;lt;math&amp;gt;s_i s_j=1&amp;lt;/math&amp;gt; for all possible &amp;lt;math&amp;gt;i,j&amp;lt;/math&amp;gt; pairs. The number of pairs for each &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; depends on the number of dimensions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;P=2D&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;P&amp;lt;/math&amp;gt; represents the number of pairs and &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; the number of dimensions. The lowest possible energy will thus be &amp;lt;math&amp;gt;E=- \frac{1}{2} JNP&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; represents the total number of spins. Thus the lowest possible energy may also be simplified as &amp;lt;math&amp;gt;E=-DNJ&amp;lt;/math&amp;gt;, as requested.&lt;br /&gt;
&lt;br /&gt;
The multiplicity of this particular state is 2 (all spins up or all spins down), thus &amp;lt;math&amp;gt;\Omega=2&amp;lt;/math&amp;gt;, entropy of the system is &amp;lt;math&amp;gt;S=k_b ln \Omega=9.6*10^{-24} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Flip of a spin ===&lt;br /&gt;
&lt;br /&gt;
If one of the spins flips, the energy increases. In the given case (&amp;lt;math&amp;gt;D=3, N=1000&amp;lt;/math&amp;gt;), the &amp;lt;math&amp;gt;E_i=-3000 J&amp;lt;/math&amp;gt;, while the flip of one spin increases the energy by &amp;lt;math&amp;gt;12 J&amp;lt;/math&amp;gt; (6 pairs, &amp;lt;math&amp;gt;2 J&amp;lt;/math&amp;gt; per pair), so that &amp;lt;math&amp;gt;E_f=-2988 J&amp;lt;/math&amp;gt;. Note that &amp;lt;math&amp;gt;J&amp;lt;/math&amp;gt; does not represent joules in this case.&lt;br /&gt;
&lt;br /&gt;
Multiplicity has increased to &amp;lt;math&amp;gt;\Omega=2000&amp;lt;/math&amp;gt;, thus &amp;lt;math&amp;gt;S=1.05*10^{-22} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\Delta S=1.04*10^{-22} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Magnetisation in the sketch ===&lt;br /&gt;
&lt;br /&gt;
The 1D system shown has the magnetisation of &amp;lt;math&amp;gt;M=1&amp;lt;/math&amp;gt;. This is also true for the 2D system shown. For the model system with &amp;lt;math&amp;gt;N=1000, D=3&amp;lt;/math&amp;gt; the expected magnetisation at absolute zero would be &amp;lt;math&amp;gt;M=\pm 1000&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Code for magnetisation and energy ==&lt;br /&gt;
&lt;br /&gt;
Python code was written to calculate the energy and magnetisation of a configuration and tested a few times. The test results are shown in figure 1 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=800 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_0.png|Figure 1: Test results&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Accelerating the code ==&lt;br /&gt;
&lt;br /&gt;
The code at the beginning was written using a loop for magnetisation and a double loop for energy. 2000 Monte Carlo steps needed was &amp;lt;math&amp;gt;M=9.32 s \pm 0.10 s&amp;lt;/math&amp;gt;. After optimizing magnetisation only this has dropped to &amp;lt;math&amp;gt;M=8.88 s \pm 0.04 s&amp;lt;/math&amp;gt;, while after optimizing both magnetisation and energy with using Numpy&#039;s sum, roll and multiply functions, the time was further reduced to &amp;lt;math&amp;gt;M=0.0796 s \pm 0.018 s&amp;lt;/math&amp;gt;. It was later realised that only one roll in each direction is needed to produce the correct energy, so the final time for 2000 steps was successfully reduced to &amp;lt;math&amp;gt;M=0.418 s \pm 0.005 s&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The whole of the code used is given below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
&lt;br /&gt;
class IsingLattice:&lt;br /&gt;
&lt;br /&gt;
    E = 0.0&lt;br /&gt;
    E2 = 0.0&lt;br /&gt;
    M = 0.0&lt;br /&gt;
    M2 = 0.0&lt;br /&gt;
    energy_x=0&lt;br /&gt;
    energy2_x=0&lt;br /&gt;
    magnetisation_x=0&lt;br /&gt;
    magnetisation2_x=0&lt;br /&gt;
&lt;br /&gt;
    n_cycles = 0&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, n_rows, n_cols):&lt;br /&gt;
        self.n_rows = n_rows&lt;br /&gt;
        self.n_cols = n_cols&lt;br /&gt;
        self.lattice = np.random.choice([-1,1], size=(n_rows, n_cols))&lt;br /&gt;
&lt;br /&gt;
    def energy(self):&lt;br /&gt;
        a=np.roll(self.lattice,1,axis=0)&lt;br /&gt;
        a1=np.multiply(a,self.lattice)&lt;br /&gt;
        x1=np.sum(a1)&lt;br /&gt;
        c=np.roll(self.lattice,1,axis=1)&lt;br /&gt;
        c1=np.multiply(c,self.lattice)&lt;br /&gt;
        x2=np.sum(c1)&lt;br /&gt;
        x=x1+x2&lt;br /&gt;
        energy = -x&lt;br /&gt;
        return 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;
        return np.sum(self.lattice)&lt;br /&gt;
&lt;br /&gt;
    def energy_flip(self,random_i,random_j):&lt;br /&gt;
        &amp;quot;Return the total energy of the current lattice after flip configuration.&amp;quot;&lt;br /&gt;
        self.lattice[random_i][random_j]=-self.lattice[random_i][random_j]&lt;br /&gt;
        a=np.roll(self.lattice,1,axis=0)&lt;br /&gt;
        a1=np.multiply(a,self.lattice)&lt;br /&gt;
        x1=np.sum(a1)&lt;br /&gt;
        c=np.roll(self.lattice,1,axis=1)&lt;br /&gt;
        c1=np.multiply(c,self.lattice)&lt;br /&gt;
        x2=np.sum(c1)&lt;br /&gt;
        x=x1+x2&lt;br /&gt;
        energy = -x&lt;br /&gt;
        return energy&lt;br /&gt;
&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        # complete this function so that it performs a single Monte Carlo step&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        #the following two lines will select the coordinates of the random spin for you&lt;br /&gt;
        random_i = np.random.choice(range(0, self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(0, self.n_cols))&lt;br /&gt;
        #the following line will choose a random number in the range [0,1) for you&lt;br /&gt;
        random_number = np.random.random()&lt;br /&gt;
        self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
        energy2 = self.energy()&lt;br /&gt;
        dE = energy2 - energy&lt;br /&gt;
&lt;br /&gt;
        if energy2&amp;lt;energy or random_number&amp;lt;=np.e**(-(energy2-energy)/T):&lt;br /&gt;
            yyy=True&lt;br /&gt;
        else:&lt;br /&gt;
            self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
			&lt;br /&gt;
        self.n_cycles+=1&lt;br /&gt;
&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;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        # complete this function so that it calculates the correct values for the averages of E, E*E (E2), M, M*M (M2), and returns them&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.M / self.n_cycles&lt;br /&gt;
        return avE, avE2, avM, avM2, self.n_cycles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Temperature effects ==&lt;br /&gt;
&lt;br /&gt;
=== Correction of averaging code ===&lt;br /&gt;
&lt;br /&gt;
A few experiments were performed at different temperatures using ILfinalframe.py, to see how long it usually takes for the system to equilibrate. At low temperatures it usually happened before 1000 steps were performed, thus 1000 Monte Carlo steps was decided to be appropriate cut-off period for calculation of average values of magnetisation and energy. The figures 2-4, showing the experiments performed are shown in the gallery below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_1.png|Figure 2: Test result @ 0.5 K&lt;br /&gt;
Image:GE715_CMP_2.png|Figure 3: Test result @ 1 K&lt;br /&gt;
Image:GE715_CMP_3.png|Figure 4: Test result @ 1.5 K&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The definitions of two class functions were changed as shown below to accommodate this change.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        # complete this function so that it performs a single Monte Carlo step&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        #the following two lines will select the coordinates of the random spin for you&lt;br /&gt;
        random_i = np.random.choice(range(0, self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(0, self.n_cols))&lt;br /&gt;
        #the following line will choose a random number in the range [0,1) for you&lt;br /&gt;
        random_number = np.random.random()&lt;br /&gt;
        self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
        energy2 = self.energy()&lt;br /&gt;
        dE = energy2 - energy&lt;br /&gt;
&lt;br /&gt;
        if energy2&amp;lt;energy or random_number&amp;lt;=np.e**(-(energy2-energy)/T):&lt;br /&gt;
            yyy=True&lt;br /&gt;
        else:&lt;br /&gt;
            self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
			&lt;br /&gt;
        self.n_cycles+=1&lt;br /&gt;
        if self.n_cycles==1000:&lt;br /&gt;
            self.E=0&lt;br /&gt;
            self.E2=0&lt;br /&gt;
            self.M=0&lt;br /&gt;
            self.M2=0&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;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        # complete this function so that it calculates the correct values for the averages of E, E*E (E2), M, M*M (M2), and returns them&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.M / self.n_cycles&lt;br /&gt;
        if self.n_cycles&amp;gt;1000:&lt;br /&gt;
            avE = self.E / (self.n_cycles-1000)&lt;br /&gt;
            avE2 = self.E2 / (self.n_cycles-1000)&lt;br /&gt;
            avM = self.M / (self.n_cycles-1000)&lt;br /&gt;
            avM2 = self.M / (self.n_cycles-1000)&lt;br /&gt;
        return avE, avE2, avM, avM2, self.n_cycles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Range of temperatures ===&lt;br /&gt;
&lt;br /&gt;
The experiment was run for 8x8 lattice at a temperature range of 0.25 K-5.00 K, with a point every 0.05 K. The experiments using a different number of total steps were performed and the comparison is shown below in figures 5-7.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_4.png|Figure 5: Test result for 8x8 lattice with 11000 steps&lt;br /&gt;
Image:GE715_CMP_5.png|Figure 6: Test result for 8x8 lattice with 21000 steps&lt;br /&gt;
Image:GE715_CMP_6.png|Figure 7: Test result for 8x8 lattice with 101000 steps&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is a small, but noticeable improvement in the smoothness of the curves obtained for energy with using more steps, thus the highest number of steps (101000 steps) was used in the further experiments regardless of the higher need for computational power.&lt;br /&gt;
&lt;br /&gt;
== Lattice size effects ==&lt;br /&gt;
&lt;br /&gt;
With increasing lattice size the energy and magnetisation curves become more realistic, since the long range effects are better accounted for. 7 different lattice sizes were tested and energy and magnetisation for each are shown below in figure 8-14 and 15-21 respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_7.png|Figure 8: Energy result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_8.png|Figure 9: Energy result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_9.png|Figure 10: Energy result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_10.png|Figure 11: Energy result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_11.png|Figure 12: Energy result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_12.png|Figure 13: Energy result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_13.png|Figure 14: Energy result for 128x128 lattice&lt;br /&gt;
Image:GE715_CMP_14.png|Figure 15: Magnetisation result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_15.png|Figure 16: Magnetisation result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_16.png|Figure 17: Magnetisation result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_17.png|Figure 18: Magnetisation result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_18.png|Figure 19: Magnetisation result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_19.png|Figure 20: Magnetisation result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_20.png|Figure 21: Magnetisation result for 128x128 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Overall comparison of energy and magnetisation per spin in each lattice was made and can be seen in figures 22 and 23 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_21.png|Figure 22: Energy comparison&lt;br /&gt;
Image:GE715_CMP_22.png|Figure 23: Magnetisation comparison&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code used for producing figure 23 above is shown below. Other codes are analagous. Example for defining ls2 is also shown Others are similar..&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ls2=loadtxt(&amp;quot;2x2(100).dat&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
figsize(12,8)&lt;br /&gt;
plot(ls2[:,0],ls2[:,3]/4,color=&amp;quot;red&amp;quot;,label=&amp;quot;2x2&amp;quot;)&lt;br /&gt;
plot(ls4[:,0],ls4[:,3]/16,color=&amp;quot;orange&amp;quot;,label=&amp;quot;4x4&amp;quot;)&lt;br /&gt;
plot(ls8[:,0],ls8[:,3]/64,color=&amp;quot;yellow&amp;quot;,label=&amp;quot;8x8&amp;quot;)&lt;br /&gt;
plot(ls16[:,0],ls16[:,3]/256,color=&amp;quot;lime&amp;quot;,label=&amp;quot;16x16&amp;quot;)&lt;br /&gt;
plot(ls32[:,0],ls32[:,3]/1024,color=&amp;quot;blue&amp;quot;,label=&amp;quot;32x32&amp;quot;)&lt;br /&gt;
plot(ls64[:,0],ls64[:,3]/4096,color=&amp;quot;indigo&amp;quot;,label=&amp;quot;64x64&amp;quot;)&lt;br /&gt;
plot(ls128[:,0],ls128[:,3]/16384,color=&amp;quot;violet&amp;quot;,label=&amp;quot;128x128&amp;quot;)&lt;br /&gt;
title(&amp;quot;Magnetisation per spin&amp;quot;)&lt;br /&gt;
xlabel(&amp;quot;Temperature (K)&amp;quot;)&lt;br /&gt;
ylabel(&amp;quot;Magnetisation per spin&amp;quot;)&lt;br /&gt;
legend()&lt;br /&gt;
savefig(&amp;quot;Magnetisation.png&amp;quot;)&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Significant changes may be observed from 2x2 lattice up to 16x16 lattice, later the additional long range effects become less noticeable, but new effects are still present. It seems that most of the long range effects are captured by 16x16 lattice, but higher dimensions bring additional improvement.&lt;br /&gt;
&lt;br /&gt;
== Heat Capacity ==&lt;br /&gt;
&lt;br /&gt;
This formula holds true by definition: &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;
Variance of energy can be calculated  in the following way: &amp;lt;math&amp;gt;\mathrm{Var}[X] = \left\langle E^2\right\rangle - \left\langle E\right\rangle^2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Since expected energy can also be expressed as partition function: &amp;lt;math&amp;gt;\left\langle E\right\rangle = \frac{\partial}{\partial \beta}lnZ&amp;lt;/math&amp;gt;, variance may be expressed as &amp;lt;math&amp;gt;\mathrm{Var}[X] = \frac{\partial ^2}{\partial \beta ^2}lnZ = - \frac{\partial \left\langle E\right\rangle}{\partial \beta}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We can rearrange the equations given, because &amp;lt;math&amp;gt;T = \frac{1}{k_BT}&amp;lt;/math&amp;gt;, so that we obtain &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;
=== Heat capacity of the model ===&lt;br /&gt;
&lt;br /&gt;
Heat capacities of the models were calculated using the script given below (example for 2x2 lattice).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
figsize(6,4)&lt;br /&gt;
plot(ls2[:,0],(ls2[:,2]-ls2[:,1]**2)/ls2[:,0],color=&amp;quot;red&amp;quot;,label=&amp;quot;2x2&amp;quot;)&lt;br /&gt;
xlabel(&amp;quot;Temperature (K)&amp;quot;)&lt;br /&gt;
ylabel(&amp;quot;C&amp;quot;)&lt;br /&gt;
savefig(&amp;quot;C2.png&amp;quot;)&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphs of heat capacities are shown in the gallery below (figures 24-30). It can be seen that the model breaks down at low temperatures for bigger lattices, but it still gives a peak heat capacity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_23.png|Figure 24: C result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_24.png|Figure 25: C result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_25.png|Figure 26: C result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_26.png|Figure 27: C result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_27.png|Figure 28: C result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_28.png|Figure 29: C result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_29.png|Figure 30: C result for 128x128 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Comparison of heat capacity per spin is given in the figure 31 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_30.png|Figure 31: Heat capacity comparison&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Curie temperature ==&lt;br /&gt;
&lt;br /&gt;
Curie temperature can be deduced from where there is a peak in heat capacity per spin. The graphs of heat capacity vs temperature is shown below (figures 32 and 33) for two different lattice sizes, once using Python script and once using C++ data provided.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_31.png|Figure 32: 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_32.png|Figure 33: 64x64 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Polynomial fit ===&lt;br /&gt;
&lt;br /&gt;
The C++ data was also fitted with a polynomial, firstly over the whole range and afterwards just in the peak range. Fitting a polynomial proved to be hard as expected (since data is close to delta-like function), but it became more feasible when smaller range was used. Examples of both fits are shown in figures 34 and 35 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_33.png|Figure 34: Whole region fit&lt;br /&gt;
Image:GE715_CMP_34.png|Figure 35: Peak region fit&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Finding Curie temperature ===&lt;br /&gt;
&lt;br /&gt;
The last step was to find peak heat capacity for different lattice sizes in C++ data. The results are shown in the table below.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Lattice size&lt;br /&gt;
! Curie temperature&lt;br /&gt;
|-&lt;br /&gt;
|2x2&lt;br /&gt;
|2.48 K&lt;br /&gt;
|-&lt;br /&gt;
|4x4&lt;br /&gt;
|2.40 K&lt;br /&gt;
|-&lt;br /&gt;
|8x8&lt;br /&gt;
|2.32 K&lt;br /&gt;
|-&lt;br /&gt;
|16x16&lt;br /&gt;
|2.25 K&lt;br /&gt;
|-&lt;br /&gt;
|32x32&lt;br /&gt;
|2.30 K&lt;br /&gt;
|-&lt;br /&gt;
|64x64&lt;br /&gt;
|2.25 K&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
It becomes clear that for larger lattice sizes the calculated Curie temperature will slowly converge, thus we can conclude that for infinite lattice it will be in the region of 2.2-2.3 K.&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:CMPY3_GE715&amp;diff=644386</id>
		<title>Rep:CMPY3 GE715</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Rep:CMPY3_GE715&amp;diff=644386"/>
		<updated>2017-11-21T19:09:28Z</updated>

		<summary type="html">&lt;p&gt;Ge715: Part 8&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Ising Model ==&lt;br /&gt;
&lt;br /&gt;
The interaction energy in Ising model is defined as &amp;lt;math&amp;gt;E=- \frac{1}{2} J \sum_i^N \sum_{j\  \in\  \mathrm{neighbours}\left(i\right)} s_i s_j&amp;lt;/math&amp;gt;. The energy will be the lowest possible when all the spins point in the same direction. In that case &amp;lt;math&amp;gt;s_i s_j=1&amp;lt;/math&amp;gt; for all possible &amp;lt;math&amp;gt;i,j&amp;lt;/math&amp;gt; pairs. The number of pairs for each &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; depends on the number of dimensions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;P=2D&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;P&amp;lt;/math&amp;gt; represents the number of pairs and &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; the number of dimensions. The lowest possible energy will thus be &amp;lt;math&amp;gt;E=- \frac{1}{2} JNP&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; represents the total number of spins. Thus the lowest possible energy may also be simplified as &amp;lt;math&amp;gt;E=-DNJ&amp;lt;/math&amp;gt;, as requested.&lt;br /&gt;
&lt;br /&gt;
The multiplicity of this particular state is 2 (all spins up or all spins down), thus &amp;lt;math&amp;gt;\Omega=2&amp;lt;/math&amp;gt;, entropy of the system is &amp;lt;math&amp;gt;S=k_b ln \Omega=9.6*10^{-24} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Flip of a spin ===&lt;br /&gt;
&lt;br /&gt;
If one of the spins flips, the energy increases. In the given case (&amp;lt;math&amp;gt;D=3, N=1000&amp;lt;/math&amp;gt;), the &amp;lt;math&amp;gt;E_i=-3000 J&amp;lt;/math&amp;gt;, while the flip of one spin increases the energy by &amp;lt;math&amp;gt;12 J&amp;lt;/math&amp;gt; (6 pairs, &amp;lt;math&amp;gt;2 J&amp;lt;/math&amp;gt; per pair), so that &amp;lt;math&amp;gt;E_f=-2988 J&amp;lt;/math&amp;gt;. Note that &amp;lt;math&amp;gt;J&amp;lt;/math&amp;gt; does not represent joules in this case.&lt;br /&gt;
&lt;br /&gt;
Multiplicity has increased to &amp;lt;math&amp;gt;\Omega=2000&amp;lt;/math&amp;gt;, thus &amp;lt;math&amp;gt;S=1.05*10^{-22} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\Delta S=1.04*10^{-22} JK^{-1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Magnetisation in the sketch ===&lt;br /&gt;
&lt;br /&gt;
The 1D system shown has the magnetisation of &amp;lt;math&amp;gt;M=1&amp;lt;/math&amp;gt;. This is also true for the 2D system shown. For the model system with &amp;lt;math&amp;gt;N=1000, D=3&amp;lt;/math&amp;gt; the expected magnetisation at absolute zero would be &amp;lt;math&amp;gt;M=\pm 1000&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Code for magnetisation and energy ==&lt;br /&gt;
&lt;br /&gt;
Python code was written to calculate the energy and magnetisation of a configuration and tested a few times. The test results are shown in figure 1 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=800 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_0.png|Figure 1: Test results&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Accelerating the code ==&lt;br /&gt;
&lt;br /&gt;
The code at the beginning was written using a loop for magnetisation and a double loop for energy. 2000 Monte Carlo steps needed was &amp;lt;math&amp;gt;M=9.32 s \pm 0.10 s&amp;lt;/math&amp;gt;. After optimizing magnetisation only this has dropped to &amp;lt;math&amp;gt;M=8.88 s \pm 0.04 s&amp;lt;/math&amp;gt;, while after optimizing both magnetisation and energy with using Numpy&#039;s sum, roll and multiply functions, the time was further reduced to &amp;lt;math&amp;gt;M=0.0796 s \pm 0.018 s&amp;lt;/math&amp;gt;. It was later realised that only one roll in each direction is needed to produce the correct energy, so the final time for 2000 steps was successfully reduced to &amp;lt;math&amp;gt;M=0.418 s \pm 0.005 s&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The whole of the code used is given below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
&lt;br /&gt;
class IsingLattice:&lt;br /&gt;
&lt;br /&gt;
    E = 0.0&lt;br /&gt;
    E2 = 0.0&lt;br /&gt;
    M = 0.0&lt;br /&gt;
    M2 = 0.0&lt;br /&gt;
    energy_x=0&lt;br /&gt;
    energy2_x=0&lt;br /&gt;
    magnetisation_x=0&lt;br /&gt;
    magnetisation2_x=0&lt;br /&gt;
&lt;br /&gt;
    n_cycles = 0&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, n_rows, n_cols):&lt;br /&gt;
        self.n_rows = n_rows&lt;br /&gt;
        self.n_cols = n_cols&lt;br /&gt;
        self.lattice = np.random.choice([-1,1], size=(n_rows, n_cols))&lt;br /&gt;
&lt;br /&gt;
    def energy(self):&lt;br /&gt;
        a=np.roll(self.lattice,1,axis=0)&lt;br /&gt;
        a1=np.multiply(a,self.lattice)&lt;br /&gt;
        x1=np.sum(a1)&lt;br /&gt;
        c=np.roll(self.lattice,1,axis=1)&lt;br /&gt;
        c1=np.multiply(c,self.lattice)&lt;br /&gt;
        x2=np.sum(c1)&lt;br /&gt;
        x=x1+x2&lt;br /&gt;
        energy = -x&lt;br /&gt;
        return 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;
        return np.sum(self.lattice)&lt;br /&gt;
&lt;br /&gt;
    def energy_flip(self,random_i,random_j):&lt;br /&gt;
        &amp;quot;Return the total energy of the current lattice after flip configuration.&amp;quot;&lt;br /&gt;
        self.lattice[random_i][random_j]=-self.lattice[random_i][random_j]&lt;br /&gt;
        a=np.roll(self.lattice,1,axis=0)&lt;br /&gt;
        a1=np.multiply(a,self.lattice)&lt;br /&gt;
        x1=np.sum(a1)&lt;br /&gt;
        c=np.roll(self.lattice,1,axis=1)&lt;br /&gt;
        c1=np.multiply(c,self.lattice)&lt;br /&gt;
        x2=np.sum(c1)&lt;br /&gt;
        x=x1+x2&lt;br /&gt;
        energy = -x&lt;br /&gt;
        return energy&lt;br /&gt;
&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        # complete this function so that it performs a single Monte Carlo step&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        #the following two lines will select the coordinates of the random spin for you&lt;br /&gt;
        random_i = np.random.choice(range(0, self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(0, self.n_cols))&lt;br /&gt;
        #the following line will choose a random number in the range [0,1) for you&lt;br /&gt;
        random_number = np.random.random()&lt;br /&gt;
        self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
        energy2 = self.energy()&lt;br /&gt;
        dE = energy2 - energy&lt;br /&gt;
&lt;br /&gt;
        if energy2&amp;lt;energy or random_number&amp;lt;=np.e**(-(energy2-energy)/T):&lt;br /&gt;
            yyy=True&lt;br /&gt;
        else:&lt;br /&gt;
            self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
			&lt;br /&gt;
        self.n_cycles+=1&lt;br /&gt;
&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;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        # complete this function so that it calculates the correct values for the averages of E, E*E (E2), M, M*M (M2), and returns them&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.M / self.n_cycles&lt;br /&gt;
        return avE, avE2, avM, avM2, self.n_cycles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Temperature effects ==&lt;br /&gt;
&lt;br /&gt;
=== Correction of averaging code ===&lt;br /&gt;
&lt;br /&gt;
A few experiments were performed at different temperatures using ILfinalframe.py, to see how long it usually takes for the system to equilibrate. At low temperatures it usually happened before 1000 steps were performed, thus 1000 Monte Carlo steps was decided to be appropriate cut-off period for calculation of average values of magnetisation and energy. The figures 2-4, showing the experiments performed are shown in the gallery below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_1.png|Figure 2: Test result @ 0.5 K&lt;br /&gt;
Image:GE715_CMP_2.png|Figure 3: Test result @ 1 K&lt;br /&gt;
Image:GE715_CMP_3.png|Figure 4: Test result @ 1.5 K&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The definitions of two class functions were changed as shown below to accommodate this change.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def montecarlostep(self, T):&lt;br /&gt;
        # complete this function so that it performs a single Monte Carlo step&lt;br /&gt;
        energy = self.energy()&lt;br /&gt;
        #the following two lines will select the coordinates of the random spin for you&lt;br /&gt;
        random_i = np.random.choice(range(0, self.n_rows))&lt;br /&gt;
        random_j = np.random.choice(range(0, self.n_cols))&lt;br /&gt;
        #the following line will choose a random number in the range [0,1) for you&lt;br /&gt;
        random_number = np.random.random()&lt;br /&gt;
        self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
        energy2 = self.energy()&lt;br /&gt;
        dE = energy2 - energy&lt;br /&gt;
&lt;br /&gt;
        if energy2&amp;lt;energy or random_number&amp;lt;=np.e**(-(energy2-energy)/T):&lt;br /&gt;
            yyy=True&lt;br /&gt;
        else:&lt;br /&gt;
            self.lattice[random_i][random_j] = -self.lattice[random_i][random_j]&lt;br /&gt;
			&lt;br /&gt;
        self.n_cycles+=1&lt;br /&gt;
        if self.n_cycles==1000:&lt;br /&gt;
            self.E=0&lt;br /&gt;
            self.E2=0&lt;br /&gt;
            self.M=0&lt;br /&gt;
            self.M2=0&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;
        return self.energy(), self.magnetisation()&lt;br /&gt;
&lt;br /&gt;
    def statistics(self):&lt;br /&gt;
        # complete this function so that it calculates the correct values for the averages of E, E*E (E2), M, M*M (M2), and returns them&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.M / self.n_cycles&lt;br /&gt;
        if self.n_cycles&amp;gt;1000:&lt;br /&gt;
            avE = self.E / (self.n_cycles-1000)&lt;br /&gt;
            avE2 = self.E2 / (self.n_cycles-1000)&lt;br /&gt;
            avM = self.M / (self.n_cycles-1000)&lt;br /&gt;
            avM2 = self.M / (self.n_cycles-1000)&lt;br /&gt;
        return avE, avE2, avM, avM2, self.n_cycles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Range of temperatures ===&lt;br /&gt;
&lt;br /&gt;
The experiment was run for 8x8 lattice at a temperature range of 0.25 K-5.00 K, with a point every 0.05 K. The experiments using a different number of total steps were performed and the comparison is shown below in figures 5-7.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_4.png|Figure 5: Test result for 8x8 lattice with 11000 steps&lt;br /&gt;
Image:GE715_CMP_5.png|Figure 6: Test result for 8x8 lattice with 21000 steps&lt;br /&gt;
Image:GE715_CMP_6.png|Figure 7: Test result for 8x8 lattice with 101000 steps&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is a small, but noticeable improvement in the smoothness of the curves obtained for energy with using more steps, thus the highest number of steps (101000 steps) was used in the further experiments regardless of the higher need for computational power.&lt;br /&gt;
&lt;br /&gt;
== Lattice size effects ==&lt;br /&gt;
&lt;br /&gt;
With increasing lattice size the energy and magnetisation curves become more realistic, since the long range effects are better accounted for. 7 different lattice sizes were tested and energy and magnetisation for each are shown below in figure 8-14 and 15-21 respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_7.png|Figure 8: Energy result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_8.png|Figure 9: Energy result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_9.png|Figure 10: Energy result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_10.png|Figure 11: Energy result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_11.png|Figure 12: Energy result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_12.png|Figure 13: Energy result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_13.png|Figure 14: Energy result for 128x128 lattice&lt;br /&gt;
Image:GE715_CMP_14.png|Figure 15: Magnetisation result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_15.png|Figure 16: Magnetisation result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_16.png|Figure 17: Magnetisation result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_17.png|Figure 18: Magnetisation result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_18.png|Figure 19: Magnetisation result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_19.png|Figure 20: Magnetisation result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_20.png|Figure 21: Magnetisation result for 128x128 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Overall comparison of energy and magnetisation per spin in each lattice was made and can be seen in figures 22 and 23 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_21.png|Figure 22: Energy comparison&lt;br /&gt;
Image:GE715_CMP_22.png|Figure 23: Magnetisation comparison&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code used for producing figure 23 above is shown below. Other codes are analagous. Example for defining ls2 is also shown Others are similar..&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ls2=loadtxt(&amp;quot;2x2(100).dat&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
figsize(12,8)&lt;br /&gt;
plot(ls2[:,0],ls2[:,3]/4,color=&amp;quot;red&amp;quot;,label=&amp;quot;2x2&amp;quot;)&lt;br /&gt;
plot(ls4[:,0],ls4[:,3]/16,color=&amp;quot;orange&amp;quot;,label=&amp;quot;4x4&amp;quot;)&lt;br /&gt;
plot(ls8[:,0],ls8[:,3]/64,color=&amp;quot;yellow&amp;quot;,label=&amp;quot;8x8&amp;quot;)&lt;br /&gt;
plot(ls16[:,0],ls16[:,3]/256,color=&amp;quot;lime&amp;quot;,label=&amp;quot;16x16&amp;quot;)&lt;br /&gt;
plot(ls32[:,0],ls32[:,3]/1024,color=&amp;quot;blue&amp;quot;,label=&amp;quot;32x32&amp;quot;)&lt;br /&gt;
plot(ls64[:,0],ls64[:,3]/4096,color=&amp;quot;indigo&amp;quot;,label=&amp;quot;64x64&amp;quot;)&lt;br /&gt;
plot(ls128[:,0],ls128[:,3]/16384,color=&amp;quot;violet&amp;quot;,label=&amp;quot;128x128&amp;quot;)&lt;br /&gt;
title(&amp;quot;Magnetisation per spin&amp;quot;)&lt;br /&gt;
xlabel(&amp;quot;Temperature (K)&amp;quot;)&lt;br /&gt;
ylabel(&amp;quot;Magnetisation per spin&amp;quot;)&lt;br /&gt;
legend()&lt;br /&gt;
savefig(&amp;quot;Magnetisation.png&amp;quot;)&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Significant changes may be observed from 2x2 lattice up to 16x16 lattice, later the additional long range effects become less noticeable, but new effects are still present. It seems that most of the long range effects are captured by 16x16 lattice, but higher dimensions bring additional improvement.&lt;br /&gt;
&lt;br /&gt;
== Heat Capacity ==&lt;br /&gt;
&lt;br /&gt;
This formula holds true by definition: &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;
Variance of energy can be calculated  in the following way: &amp;lt;math&amp;gt;\mathrm{Var}[X] = \left\langle E^2\right\rangle - \left\langle E\right\rangle^2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Since expected energy can also be expressed as partition function: &amp;lt;math&amp;gt;\left\langle E\right\rangle = \frac{\partial}{\partial \beta}lnZ&amp;lt;/math&amp;gt;, variance may be expressed as &amp;lt;math&amp;gt;\mathrm{Var}[X] = \frac{\partial ^2}{\partial \beta ^2}lnZ = - \frac{\partial \left\langle E\right\rangle}{\partial \beta}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We can rearrange the equations given, because &amp;lt;math&amp;gt;T = \frac{1}{k_BT}&amp;lt;/math&amp;gt;, so that we obtain &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;
=== Heat capacity of the model ===&lt;br /&gt;
&lt;br /&gt;
Heat capacities of the models were calculated using the script given below (example for 2x2 lattice).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
figsize(6,4)&lt;br /&gt;
plot(ls2[:,0],(ls2[:,2]-ls2[:,1]**2)/ls2[:,0],color=&amp;quot;red&amp;quot;,label=&amp;quot;2x2&amp;quot;)&lt;br /&gt;
xlabel(&amp;quot;Temperature (K)&amp;quot;)&lt;br /&gt;
ylabel(&amp;quot;C&amp;quot;)&lt;br /&gt;
savefig(&amp;quot;C2.png&amp;quot;)&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphs of heat capacities are shown in the gallery below (figures 24-30). It can be seen that the model breaks down at low temperatures for bigger lattices, but it still gives a peak heat capacity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=250 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_23.png|Figure 24: C result for 2x2 lattice&lt;br /&gt;
Image:GE715_CMP_24.png|Figure 25: C result for 4x4 lattice&lt;br /&gt;
Image:GE715_CMP_25.png|Figure 26: C result for 8x8 lattice&lt;br /&gt;
Image:GE715_CMP_26.png|Figure 27: C result for 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_27.png|Figure 28: C result for 32x32 lattice&lt;br /&gt;
Image:GE715_CMP_28.png|Figure 29: C result for 64x64 lattice&lt;br /&gt;
Image:GE715_CMP_29.png|Figure 30: C result for 128x128 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Comparison of heat capacity per spin is given in the figure 31 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_30.png|Figure 31: Heat capacity comparison&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Curie temperature ==&lt;br /&gt;
&lt;br /&gt;
Curie temperature can be deduced from where there is a peak in heat capacity per spin. The graphs of heat capacity vs temperature is shown below (figures 32 and 33) for two different lattice sizes, once using Python script and once using C++ data provided.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_31.png|Figure 32: 16x16 lattice&lt;br /&gt;
Image:GE715_CMP_32.png|Figure 33: 64x64 lattice&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Polynomial fit ===&lt;br /&gt;
&lt;br /&gt;
The C++ data was also fitted with a polynomial, firstly over the whole range and afterwards just in the peak range. Fitting a polynomial proved to be hard as expected (since data is close to delta-like function), but it became more feasible when smaller range was used. Examples of both fits are shown in figures 34 and 35 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500 px&amp;gt;&lt;br /&gt;
Image:GE715_CMP_33.png|Figure 34: Whole region fit&lt;br /&gt;
Image:GE715_CMP_34.png|Figure 35: Peak region fit&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Finding Curie temperature ===&lt;br /&gt;
&lt;br /&gt;
The last step was to find peak heat capacity for different lattice sizes in C++ data. The results are shown in the table below.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Lattice size&lt;br /&gt;
! Curie temperature&lt;br /&gt;
|-&lt;br /&gt;
|2x2&lt;br /&gt;
|2.48 K&lt;br /&gt;
|-&lt;br /&gt;
|4x4&lt;br /&gt;
|2.40 K&lt;br /&gt;
|-&lt;br /&gt;
|8x8&lt;br /&gt;
|2.32 K&lt;br /&gt;
|-&lt;br /&gt;
|16x16&lt;br /&gt;
|2.25 K&lt;br /&gt;
|-&lt;br /&gt;
|32x32&lt;br /&gt;
|2.30 K&lt;br /&gt;
|-&lt;br /&gt;
|64x64&lt;br /&gt;
|2.25 K&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
It becomes clear that for larger lattice sizes the calculated Curie temperature will slowly converge, thus we can conclude that for infinite lattice it will be in the region of 2.2-2.3 K.&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715_CMP_34.png&amp;diff=644353</id>
		<title>File:GE715 CMP 34.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715_CMP_34.png&amp;diff=644353"/>
		<updated>2017-11-21T18:52:49Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715_CMP_33.png&amp;diff=644352</id>
		<title>File:GE715 CMP 33.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715_CMP_33.png&amp;diff=644352"/>
		<updated>2017-11-21T18:52:32Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715_CMP_32.png&amp;diff=644351</id>
		<title>File:GE715 CMP 32.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715_CMP_32.png&amp;diff=644351"/>
		<updated>2017-11-21T18:52:12Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715_CMP_31.png&amp;diff=644348</id>
		<title>File:GE715 CMP 31.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715_CMP_31.png&amp;diff=644348"/>
		<updated>2017-11-21T18:51:54Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715_CMP_30.png&amp;diff=644241</id>
		<title>File:GE715 CMP 30.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715_CMP_30.png&amp;diff=644241"/>
		<updated>2017-11-21T18:05:53Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715_CMP_29.png&amp;diff=644240</id>
		<title>File:GE715 CMP 29.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715_CMP_29.png&amp;diff=644240"/>
		<updated>2017-11-21T18:05:37Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715_CMP_28.png&amp;diff=644237</id>
		<title>File:GE715 CMP 28.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715_CMP_28.png&amp;diff=644237"/>
		<updated>2017-11-21T18:05:19Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715_CMP_27.png&amp;diff=644234</id>
		<title>File:GE715 CMP 27.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:GE715_CMP_27.png&amp;diff=644234"/>
		<updated>2017-11-21T18:04:00Z</updated>

		<summary type="html">&lt;p&gt;Ge715: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ge715</name></author>
	</entry>
</feed>